From 9b57aaced20431a2c2f9284ed5bb023b1da86bfc Mon Sep 17 00:00:00 2001 From: Linkie Link Date: Tue, 7 Feb 2023 19:47:55 +0100 Subject: [PATCH] fix: fixed the incentives APY --- src/store/slices/redBank.ts | 21 +++++++++------------ src/types/interfaces/redbank.d.ts | 8 +++----- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/src/store/slices/redBank.ts b/src/store/slices/redBank.ts index 39d975f..1175310 100644 --- a/src/store/slices/redBank.ts +++ b/src/store/slices/redBank.ts @@ -31,15 +31,10 @@ const redBankSlice = (set: NamedSet, get: GetState): RedBankSlice const whitelistedAssets = get().whitelistedAssets const convertToBaseCurrency = get().convertToBaseCurrency const marsAsset = get().otherAssets?.find((asset) => asset.denom === MARS_SYMBOL) - if ( - !incentive?.asset_incentive || - !marketTotalLiquidity || - !whitelistedAssets || - !convertToBaseCurrency - ) - return - const anualEmission = Number(incentive.asset_incentive.emission_per_second) * SECONDS_IN_YEAR + if (!incentive || !marketTotalLiquidity || !whitelistedAssets || !convertToBaseCurrency) return + + const anualEmission = Number(incentive.emission_per_second) * SECONDS_IN_YEAR const anualEmissionVaule = convertToBaseCurrency({ denom: lookupDenomBySymbol(MARS_SYMBOL, otherAssets), amount: anualEmission.toString(), @@ -85,10 +80,6 @@ const redBankSlice = (set: NamedSet, get: GetState): RedBankSlice const convertToBaseCurrency = get().convertToBaseCurrency const reserveInfo = findByDenom(get().marketInfo, asset.denom) const depositApy = reserveInfo?.liquidity_rate || 0 - const incentiveInfo = get().calculateIncentiveAssetInfo( - findByDenom(get().marketIncentiveInfo, asset.denom), - { denom: asset.denom, amount: get().computeMarketLiquidity(asset.denom).toString() }, - ) const borrowApy = reserveInfo?.borrow_rate || 0 const depositBalance = get().findUserDeposit(asset.denom) const borrowBalance = get().findUserDebt(asset.denom) @@ -101,6 +92,12 @@ const redBankSlice = (set: NamedSet, get: GetState): RedBankSlice const marketLiquidity = (depositLiquidity - debtLiquidity).toString() marketAssetLiquidity.push({ denom: asset.denom, amount: marketLiquidity }) + + const incentiveInfo = get().calculateIncentiveAssetInfo( + findByDenom(get().marketIncentiveInfo, asset.denom), + { denom: asset.denom, amount: marketLiquidity }, + ) + const redBankAsset: RedBankAsset = { ...asset, walletBalance: assetWallet?.amount.toString(), diff --git a/src/types/interfaces/redbank.d.ts b/src/types/interfaces/redbank.d.ts index fa10c44..34af362 100644 --- a/src/types/interfaces/redbank.d.ts +++ b/src/types/interfaces/redbank.d.ts @@ -44,9 +44,7 @@ interface InterestRateModel { interface MarketIncentive { denom: string - asset_incentive: { - emission_per_second: number - index: number - last_updated: number - } + emission_per_second: number + index: number + last_updated: number }