Skip to content

Commit dafede4

Browse files
committed
changing util rate calc to exclude non-claimed fees
1 parent 7e2aca3 commit dafede4

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

token-lending/sdk/src/state/reserve.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -511,10 +511,11 @@ impl ReserveLiquidity {
511511
/// Calculate the liquidity utilization rate of the reserve
512512
pub fn utilization_rate(&self) -> Result<Rate, ProgramError> {
513513
let total_supply = self.total_supply()?;
514-
if total_supply == Decimal::zero() {
514+
if total_supply == Decimal::zero() || self.borrowed_amount_wads == Decimal::zero() {
515515
return Ok(Rate::zero());
516516
}
517-
self.borrowed_amount_wads.try_div(total_supply)?.try_into()
517+
let denominator = self.borrowed_amount_wads.try_add(Decimal::from(self.available_amount))?;
518+
self.borrowed_amount_wads.try_div(denominator)?.try_into()
518519
}
519520

520521
/// Compound current borrow rate over elapsed slots

0 commit comments

Comments
 (0)