functions for rates in bank in ui

Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
This commit is contained in:
microwavedcola1 2022-08-19 11:58:10 +02:00
parent 8f55e20a05
commit f0dff030a7
1 changed files with 24 additions and 0 deletions

View File

@ -268,6 +268,10 @@ export class Bank {
).toNumber();
}
/**
*
* @returns borrow rate, 0 is 0% where 1 is 100%
*/
getBorrowRate(): I80F48 {
const totalBorrows = this.nativeBorrows();
const totalDeposits = this.nativeDeposits();
@ -298,6 +302,18 @@ export class Bank {
}
}
/**
*
* @returns borrow rate percentage
*/
getBorrowRateUi(): number {
return this.getBorrowRate().toNumber() * 100;
}
/**
*
* @returns deposit rate, 0 is 0% where 1 is 100%
*/
getDepositRate(): I80F48 {
const borrowRate = this.getBorrowRate();
const totalBorrows = this.nativeBorrows();
@ -312,6 +328,14 @@ export class Bank {
const utilization = totalBorrows.div(totalDeposits);
return utilization.mul(borrowRate);
}
/**
*
* @returns deposit rate percentage
*/
getDepositRateUi(): number {
return this.getDepositRate().toNumber() * 100;
}
}
export class MintInfo {