mirror of
https://github.com/cerc-io/mars-interface.git
synced 2024-12-22 20:27:44 +00:00
Merge pull request #6 from mars-protocol/hotfix/incentives-apy
fix: fixed the incentives
This commit is contained in:
commit
41e2ee2e22
@ -31,15 +31,10 @@ const redBankSlice = (set: NamedSet<Store>, get: GetState<Store>): RedBankSlice
|
|||||||
const whitelistedAssets = get().whitelistedAssets
|
const whitelistedAssets = get().whitelistedAssets
|
||||||
const convertToBaseCurrency = get().convertToBaseCurrency
|
const convertToBaseCurrency = get().convertToBaseCurrency
|
||||||
const marsAsset = get().otherAssets?.find((asset) => asset.denom === MARS_SYMBOL)
|
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({
|
const anualEmissionVaule = convertToBaseCurrency({
|
||||||
denom: lookupDenomBySymbol(MARS_SYMBOL, otherAssets),
|
denom: lookupDenomBySymbol(MARS_SYMBOL, otherAssets),
|
||||||
amount: anualEmission.toString(),
|
amount: anualEmission.toString(),
|
||||||
@ -85,10 +80,6 @@ const redBankSlice = (set: NamedSet<Store>, get: GetState<Store>): RedBankSlice
|
|||||||
const convertToBaseCurrency = get().convertToBaseCurrency
|
const convertToBaseCurrency = get().convertToBaseCurrency
|
||||||
const reserveInfo = findByDenom(get().marketInfo, asset.denom)
|
const reserveInfo = findByDenom(get().marketInfo, asset.denom)
|
||||||
const depositApy = reserveInfo?.liquidity_rate || 0
|
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 borrowApy = reserveInfo?.borrow_rate || 0
|
||||||
const depositBalance = get().findUserDeposit(asset.denom)
|
const depositBalance = get().findUserDeposit(asset.denom)
|
||||||
const borrowBalance = get().findUserDebt(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()
|
const marketLiquidity = (depositLiquidity - debtLiquidity).toString()
|
||||||
marketAssetLiquidity.push({ denom: asset.denom, amount: marketLiquidity })
|
marketAssetLiquidity.push({ denom: asset.denom, amount: marketLiquidity })
|
||||||
|
|
||||||
|
const incentiveInfo = get().calculateIncentiveAssetInfo(
|
||||||
|
findByDenom(get().marketIncentiveInfo, asset.denom),
|
||||||
|
{ denom: asset.denom, amount: marketLiquidity },
|
||||||
|
)
|
||||||
|
|
||||||
const redBankAsset: RedBankAsset = {
|
const redBankAsset: RedBankAsset = {
|
||||||
...asset,
|
...asset,
|
||||||
walletBalance: assetWallet?.amount.toString(),
|
walletBalance: assetWallet?.amount.toString(),
|
||||||
|
2
src/types/interfaces/redbank.d.ts
vendored
2
src/types/interfaces/redbank.d.ts
vendored
@ -44,9 +44,7 @@ interface InterestRateModel {
|
|||||||
|
|
||||||
interface MarketIncentive {
|
interface MarketIncentive {
|
||||||
denom: string
|
denom: string
|
||||||
asset_incentive: {
|
|
||||||
emission_per_second: number
|
emission_per_second: number
|
||||||
index: number
|
index: number
|
||||||
last_updated: number
|
last_updated: number
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user