Merge branch 'develop' of https://github.com/mars-protocol/mars-v2-frontend into develop
This commit is contained in:
commit
a64f266cda
34
src/api/hls/getHLSVaults.ts
Normal file
34
src/api/hls/getHLSVaults.ts
Normal 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,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
}
|
19
src/components/HLS/Farm/Table/Columns/Name.tsx
Normal file
19
src/components/HLS/Farm/Table/Columns/Name.tsx
Normal 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>
|
||||||
|
)
|
||||||
|
}
|
@ -48,7 +48,11 @@ export default function AssetOverlay(props: Props) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
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'>
|
<div className='flex justify-between p-4 overflow-hidden'>
|
||||||
<Text>Select asset</Text>
|
<Text>Select asset</Text>
|
||||||
<EscButton onClick={handleClose} enableKeyPress />
|
<EscButton onClick={handleClose} enableKeyPress />
|
||||||
|
10
src/hooks/useHLSVaults.ts
Normal file
10
src/hooks/useHLSVaults.ts
Normal 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,
|
||||||
|
})
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user