add cache for asset params (#683)
This commit is contained in:
parent
5bc8afb410
commit
aef2940ed0
@ -61,3 +61,4 @@ export const allParamsCache: Cache<AssetParamsBaseForAddr[]> = new Map()
|
|||||||
export const underlyingDebtCache: Cache<string> = new Map()
|
export const underlyingDebtCache: Cache<string> = new Map()
|
||||||
export const previewDepositCache: Cache<{ vaultAddress: string; amount: string }> = new Map()
|
export const previewDepositCache: Cache<{ vaultAddress: string; amount: string }> = new Map()
|
||||||
export const stakingAprCache: Cache<StakingApr[]> = new Map()
|
export const stakingAprCache: Cache<StakingApr[]> = new Map()
|
||||||
|
export const assetParamsCache: Cache<AssetParamsBaseForAddr[]> = new Map()
|
||||||
|
@ -1,11 +1,19 @@
|
|||||||
|
import { assetParamsCache, cacheFn } from 'api/cache'
|
||||||
import { getParamsQueryClient } from 'api/cosmwasm-client'
|
import { getParamsQueryClient } from 'api/cosmwasm-client'
|
||||||
import { AssetParamsBaseForAddr } from 'types/generated/mars-params/MarsParams.types'
|
import { AssetParamsBaseForAddr } from 'types/generated/mars-params/MarsParams.types'
|
||||||
import iterateContractQuery from 'utils/iterateContractQuery'
|
import iterateContractQuery from 'utils/iterateContractQuery'
|
||||||
|
|
||||||
export default async function getAssetParams(): Promise<AssetParamsBaseForAddr[]> {
|
export default async function getAssetParams(): Promise<AssetParamsBaseForAddr[]> {
|
||||||
try {
|
try {
|
||||||
|
return await cacheFn(
|
||||||
|
async () => {
|
||||||
const paramsQueryClient = await getParamsQueryClient()
|
const paramsQueryClient = await getParamsQueryClient()
|
||||||
return iterateContractQuery(paramsQueryClient.allAssetParams)
|
return iterateContractQuery(paramsQueryClient.allAssetParams)
|
||||||
|
},
|
||||||
|
assetParamsCache,
|
||||||
|
'assetParams',
|
||||||
|
600,
|
||||||
|
)
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
throw ex
|
throw ex
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ async function getVaultPositionStatusAndUnlockIdAndUnlockTime(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function flatVaultPositionAmount(
|
export function flatVaultPositionAmount(
|
||||||
vaultPositionAmount: VaultPositionAmount,
|
vaultPositionAmount: VaultPositionAmount,
|
||||||
): VaultPositionFlatAmounts {
|
): VaultPositionFlatAmounts {
|
||||||
const amounts = {
|
const amounts = {
|
||||||
@ -82,7 +82,7 @@ function flatVaultPositionAmount(
|
|||||||
return amounts
|
return amounts
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getLpTokensForVaultPosition(
|
export async function getLpTokensForVaultPosition(
|
||||||
vault: Vault,
|
vault: Vault,
|
||||||
vaultPosition: VaultPosition,
|
vaultPosition: VaultPosition,
|
||||||
): Promise<Coin[]> {
|
): Promise<Coin[]> {
|
||||||
|
Loading…
Reference in New Issue
Block a user