This commit is contained in:
Linkie Link 2023-10-24 19:47:52 +02:00
commit a64f266cda
No known key found for this signature in database
GPG Key ID: 5318B0F2564D38EA
4 changed files with 68 additions and 1 deletions

View File

@ -0,0 +1,34 @@
import { getCreditManagerQueryClient } from 'api/cosmwasm-client'
import getAssetParams from 'api/params/getAssetParams'
import { getVaultConfigs } from 'api/vaults/getVaultConfigs'
import { BN } from 'utils/helpers'
import { resolveHLSStrategies } from 'utils/resolvers'
export default async function getHLSVaults() {
const assetParams = await getAssetParams()
const client = await getCreditManagerQueryClient()
const vaultConfigs = await getVaultConfigs()
const HLSAssets = assetParams.filter((asset) => asset.credit_manager.hls)
const strategies = resolveHLSStrategies('vault', HLSAssets)
const vaultUtilizations$ = strategies.map((strategy) =>
client.vaultUtilization({ vault: { address: strategy.denoms.deposit } }),
)
return Promise.all(vaultUtilizations$).then((vaultUtilizations) =>
vaultUtilizations.map(
(utilization, index) =>
({
...strategies[index],
depositCap: {
denom: utilization.vault.address,
used: BN(utilization.utilization.amount),
max: BN(
vaultConfigs.find((config) => config.addr === utilization.vault.address)?.deposit_cap
.amount || 0,
),
},
}) as HLSStrategy,
),
)
}

View File

@ -0,0 +1,19 @@
import React from 'react'
import TitleAndSubCell from 'components/TitleAndSubCell'
interface Props {
strategy: HLSStrategy
}
export default function Name(props: Props) {
return (
<div className='flex'>
<TitleAndSubCell
className='ml-2 mr-2 text-left'
title={`${props.strategy.denoms.deposit}-${props.strategy.denoms.borrow}`}
sub={'Via Mars'}
/>
</div>
)
}

View File

@ -48,7 +48,11 @@ export default function AssetOverlay(props: Props) {
}
return (
<Overlay className='inset-0 w-full' show={props.state !== 'closed'} setShow={handleClose}>
<Overlay
className='inset-0 w-full overflow-y-scroll scrollbar-hide'
show={props.state !== 'closed'}
setShow={handleClose}
>
<div className='flex justify-between p-4 overflow-hidden'>
<Text>Select asset</Text>
<EscButton onClick={handleClose} enableKeyPress />

10
src/hooks/useHLSVaults.ts Normal file
View File

@ -0,0 +1,10 @@
import useSWR from 'swr'
import getHLSVaults from 'api/hls/getHLSVaults'
export default function useHLSVaults() {
return useSWR('hls-vaults', getHLSVaults, {
fallbackData: [],
revalidateOnFocus: false,
})
}