Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changing util rate calc to exclude non-claimed fees #132

Merged
merged 1 commit into from
Mar 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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