Fix getBorrowRate() to include loan upkeep
This commit is contained in:
parent
d3e950875f
commit
5ad1bb4c7d
|
@ -407,18 +407,15 @@ export class Bank implements BankForHealth {
|
|||
|
||||
/**
|
||||
*
|
||||
* @returns borrow rate, 0 is 0% where 1 is 100%
|
||||
* @returns borrow rate, 0 is 0% where 1 is 100%; not including loan upkeep rate
|
||||
*/
|
||||
getBorrowRate(): I80F48 {
|
||||
getBorrowRateWithoutUpkeepRate(): I80F48 {
|
||||
const totalBorrows = this.nativeBorrows();
|
||||
const totalDeposits = this.nativeDeposits();
|
||||
|
||||
if (totalDeposits.isZero() && totalBorrows.isZero()) {
|
||||
return ZERO_I80F48();
|
||||
}
|
||||
if (totalDeposits.lte(totalBorrows)) {
|
||||
return this.maxRate;
|
||||
}
|
||||
|
||||
const utilization = totalBorrows.div(totalDeposits);
|
||||
if (utilization.lte(this.util0)) {
|
||||
|
@ -439,7 +436,15 @@ export class Bank implements BankForHealth {
|
|||
|
||||
/**
|
||||
*
|
||||
* @returns borrow rate percentage
|
||||
* @returns total borrow rate, 0 is 0% where 1 is 100% (including loan upkeep rate)
|
||||
*/
|
||||
getBorrowRate(): I80F48 {
|
||||
return this.getBorrowRateWithoutUpkeepRate().add(this.loanFeeRate);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @returns total borrow rate percentage (including loan upkeep rate)
|
||||
*/
|
||||
getBorrowRateUi(): number {
|
||||
return this.getBorrowRate().toNumber() * 100;
|
||||
|
|
Loading…
Reference in New Issue