Skip to content

Commit

Permalink
changing util rate calc to exclude non-claimed fees
Browse files Browse the repository at this point in the history
  • Loading branch information
nope-finance committed Mar 5, 2023
1 parent 7e2aca3 commit dafede4
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 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,11 @@ 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 dafede4

Please sign in to comment.