Skip to content

Commit be92df7

Browse files
committed
0xripleys borrow coefficient (#127)
Add a borrow weight to the Reserve
1 parent 95a4e55 commit be92df7

File tree

10 files changed

+576
-19
lines changed

10 files changed

+576
-19
lines changed

token-lending/cli/src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -872,6 +872,7 @@ fn main() {
872872
fee_receiver: liquidity_fee_receiver_keypair.pubkey(),
873873
protocol_liquidation_fee,
874874
protocol_take_rate,
875+
added_borrow_weight_bps: 10000,
875876
},
876877
source_liquidity_pubkey,
877878
source_liquidity_owner_keypair,

token-lending/program/src/processor.rs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -961,18 +961,11 @@ fn process_refresh_obligation(program_id: &Pubkey, accounts: &[AccountInfo]) ->
961961

962962
liquidity.accrue_interest(borrow_reserve.liquidity.cumulative_borrow_rate_wads)?;
963963

964-
// @TODO: add lookup table https://git.io/JOCYq
965-
let decimals = 10u64
966-
.checked_pow(borrow_reserve.liquidity.mint_decimals as u32)
967-
.ok_or(LendingError::MathOverflow)?;
968-
969-
let market_value = liquidity
970-
.borrowed_amount_wads
971-
.try_mul(borrow_reserve.liquidity.market_price)?
972-
.try_div(decimals)?;
964+
let market_value = borrow_reserve.market_value(liquidity.borrowed_amount_wads)?;
973965
liquidity.market_value = market_value;
974966

975-
borrowed_value = borrowed_value.try_add(market_value)?;
967+
borrowed_value =
968+
borrowed_value.try_add(market_value.try_mul(borrow_reserve.borrow_weight())?)?;
976969
}
977970

978971
if account_info_iter.peek().is_some() {

0 commit comments

Comments
 (0)