mars-v2-frontend/src/components/Earn/Lend/Lends.tsx
Linkie Link fb830c08cc
Added chain agnostic v2 (#710)
* update assets config and chains

* make clients dynamic

* feat: formatted ChainSelect

* fix infinite rerender on trade page

* feat: added NTRN icon

* fix: fixed ChainInfoID

* fix: fixed autoLendEnabled for NTRN

* fix: fixed the navigation and dependencies

* fix: fixed the pricefeed id

* fix: fixed the header menu

* fix: fixed the trading charts

* fix: fixed the healthbars

* fix: fixed naming of pion-1

* feast: updated xdefi image

* env: updated contracts

* make localStorage chain agnostic

* fix: made the selected chain persistant

* fix: fixed the wallet providers

* fix: updated auto connect

* fix: fixed auto connecting

* fix: added ChainSelect to focusMode

* store raw strings in localstorage

* 🔥 remnove tests

* update caching keys + disconnect wallet on change chain

* fix: fixed the chain select

* env: bumped version

---------

Co-authored-by: Bob van der Helm <34470358+bobthebuidlr@users.noreply.github.com>
2024-01-03 15:50:38 +01:00

47 lines
1.2 KiB
TypeScript

import AvailableLendsTable from 'components/Earn/Lend/Table/AvailableLendsTable'
import DepositedLendsTable from 'components/Earn/Lend/Table/DepositedLendsTable'
import { BN_ZERO } from 'constants/math'
import useLendEnabledAssets from 'hooks/assets/useLendEnabledAssets'
import useLendingMarketAssetsTableData from 'hooks/useLendingMarketAssetsTableData'
export default function Lends() {
const { accountLentAssets, availableAssets, allAssets } = useLendingMarketAssetsTableData()
if (!allAssets?.length) {
return <Fallback />
}
return (
<>
<DepositedLendsTable data={accountLentAssets} isLoading={false} />
<AvailableLendsTable data={availableAssets} isLoading={false} />
</>
)
}
function Fallback() {
const assets = useLendEnabledAssets()
const data: LendingMarketTableData[] = assets.map((asset) => ({
asset,
marketDepositCap: BN_ZERO,
borrowEnabled: false,
marketDepositAmount: BN_ZERO,
marketLiquidityAmount: BN_ZERO,
cap: {
max: BN_ZERO,
used: BN_ZERO,
denom: asset.denom,
},
apy: {
borrow: 0,
deposit: 0,
},
ltv: {
max: 0,
liq: 0,
},
}))
return <AvailableLendsTable data={data} isLoading />
}