fix: fixed the incentives APY

This commit is contained in:
Linkie Link 2023-02-07 19:47:55 +01:00
parent 3bf8b96b8c
commit 9b57aaced2
No known key found for this signature in database
GPG Key ID: 5318B0F2564D38EA
2 changed files with 12 additions and 17 deletions

View File

@ -31,15 +31,10 @@ const redBankSlice = (set: NamedSet<Store>, get: GetState<Store>): 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<Store>, get: GetState<Store>): 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<Store>, get: GetState<Store>): 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(),

View File

@ -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
}