return 0 on depositRate and borrowRate when no deposits or borrows

This commit is contained in:
dd 2021-02-23 11:27:29 -05:00
parent a5b5aabbd3
commit 28585ffacd
1 changed files with 7 additions and 1 deletions

View File

@ -89,6 +89,10 @@ export class MangoGroup {
const totalBorrows = this.getUiTotalBorrow(tokenIndex)
const totalDeposits = this.getUiTotalDeposit(tokenIndex)
if (totalDeposits === 0 && totalBorrows === 0) {
return 0
}
if (totalDeposits <= totalBorrows) {
return MAX_RATE
}
@ -107,7 +111,9 @@ export class MangoGroup {
const borrowRate = this.getBorrowRate(tokenIndex)
const totalBorrows = this.getUiTotalBorrow(tokenIndex)
const totalDeposits = this.getUiTotalDeposit(tokenIndex)
if (totalDeposits === 0) {
if (totalDeposits === 0 && totalBorrows === 0) {
return 0
} else if (totalDeposits === 0) {
return MAX_RATE
}
const utilization = totalBorrows / totalDeposits