Merge pull request #6 from mars-protocol/hotfix/incentives-apy

fix: fixed the incentives
This commit is contained in:
Linkie Link 2023-02-07 20:02:52 +01:00 committed by GitHub
commit 41e2ee2e22
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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
}
}