Skip to content

Commit

Permalink
changing util rate calc to exclude non-claimed fees (solana-labs#132)
Browse files Browse the repository at this point in the history
  • Loading branch information
nope-finance authored Mar 5, 2023
1 parent 7e2aca3 commit 5a53f75
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions token-lending/sdk/src/state/reserve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -511,10 +511,13 @@ impl ReserveLiquidity {
/// Calculate the liquidity utilization rate of the reserve
pub fn utilization_rate(&self) -> Result<Rate, ProgramError> {
let total_supply = self.total_supply()?;
if total_supply == Decimal::zero() {
if total_supply == Decimal::zero() || self.borrowed_amount_wads == Decimal::zero() {
return Ok(Rate::zero());
}
self.borrowed_amount_wads.try_div(total_supply)?.try_into()
let denominator = self
.borrowed_amount_wads
.try_add(Decimal::from(self.available_amount))?;
self.borrowed_amount_wads.try_div(denominator)?.try_into()
}

/// Compound current borrow rate over elapsed slots
Expand Down

0 comments on commit 5a53f75

Please sign in to comment.