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 previewDepositCache: Cache<{ vaultAddress: string; amount: string }> = 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 { AssetParamsBaseForAddr } from 'types/generated/mars-params/MarsParams.types'
|
||||
import iterateContractQuery from 'utils/iterateContractQuery'
|
||||
|
||||
export default async function getAssetParams(): Promise<AssetParamsBaseForAddr[]> {
|
||||
try {
|
||||
const paramsQueryClient = await getParamsQueryClient()
|
||||
return iterateContractQuery(paramsQueryClient.allAssetParams)
|
||||
return await cacheFn(
|
||||
async () => {
|
||||
const paramsQueryClient = await getParamsQueryClient()
|
||||
return iterateContractQuery(paramsQueryClient.allAssetParams)
|
||||
},
|
||||
assetParamsCache,
|
||||
'assetParams',
|
||||
600,
|
||||
)
|
||||
} catch (ex) {
|
||||
throw ex
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ async function getVaultPositionStatusAndUnlockIdAndUnlockTime(
|
||||
}
|
||||
}
|
||||
|
||||
function flatVaultPositionAmount(
|
||||
export function flatVaultPositionAmount(
|
||||
vaultPositionAmount: VaultPositionAmount,
|
||||
): VaultPositionFlatAmounts {
|
||||
const amounts = {
|
||||
@ -82,7 +82,7 @@ function flatVaultPositionAmount(
|
||||
return amounts
|
||||
}
|
||||
|
||||
async function getLpTokensForVaultPosition(
|
||||
export async function getLpTokensForVaultPosition(
|
||||
vault: Vault,
|
||||
vaultPosition: VaultPosition,
|
||||
): Promise<Coin[]> {
|
||||
|
Loading…
Reference in New Issue
Block a user