MP-3521: updated the APR calculation (#572)
This commit is contained in:
parent
70e27ea8fa
commit
013bfcaa15
@ -71,9 +71,11 @@ export const calculateAccountApr = (
|
|||||||
const depositValue = calculateAccountValue('deposits', account, prices)
|
const depositValue = calculateAccountValue('deposits', account, prices)
|
||||||
const lendsValue = calculateAccountValue('lends', account, prices)
|
const lendsValue = calculateAccountValue('lends', account, prices)
|
||||||
const vaultsValue = calculateAccountValue('vaults', account, prices)
|
const vaultsValue = calculateAccountValue('vaults', account, prices)
|
||||||
|
const debtsValue = calculateAccountValue('debts', account, prices)
|
||||||
const totalValue = depositValue.plus(lendsValue).plus(vaultsValue)
|
const totalValue = depositValue.plus(lendsValue).plus(vaultsValue)
|
||||||
|
const totalNetValue = totalValue.minus(debtsValue)
|
||||||
|
|
||||||
if (totalValue.isZero()) return BN_ZERO
|
if (totalNetValue.isLessThanOrEqualTo(0)) return BN_ZERO
|
||||||
const { vaults, lends, debts } = account
|
const { vaults, lends, debts } = account
|
||||||
|
|
||||||
let totalLendsInterestValue = BN_ZERO
|
let totalLendsInterestValue = BN_ZERO
|
||||||
@ -114,7 +116,7 @@ export const calculateAccountApr = (
|
|||||||
.plus(totalVaultsInterestValue)
|
.plus(totalVaultsInterestValue)
|
||||||
.minus(totalDebtInterestValue)
|
.minus(totalDebtInterestValue)
|
||||||
|
|
||||||
return totalInterstValue.dividedBy(totalValue).times(100)
|
return totalInterstValue.dividedBy(totalNetValue).times(100)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function calculateAccountLeverage(account: Account, prices: BNCoin[]) {
|
export function calculateAccountLeverage(account: Account, prices: BNCoin[]) {
|
||||||
|
Loading…
Reference in New Issue
Block a user