File tree Expand file tree Collapse file tree 1 file changed +3
-2
lines changed
token-lending/sdk/src/state Expand file tree Collapse file tree 1 file changed +3
-2
lines changed Original file line number Diff line number Diff line change @@ -511,10 +511,11 @@ impl ReserveLiquidity {
511
511
/// Calculate the liquidity utilization rate of the reserve
512
512
pub fn utilization_rate ( & self ) -> Result < Rate , ProgramError > {
513
513
let total_supply = self . total_supply ( ) ?;
514
- if total_supply == Decimal :: zero ( ) {
514
+ if total_supply == Decimal :: zero ( ) || self . borrowed_amount_wads == Decimal :: zero ( ) {
515
515
return Ok ( Rate :: zero ( ) ) ;
516
516
}
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 ( )
518
519
}
519
520
520
521
/// Compound current borrow rate over elapsed slots
You can’t perform that action at this time.
0 commit comments