import type { Asset } from '@vegaprotocol/assets'; import { CompactNumber } from '@vegaprotocol/react-helpers'; import { KeyValueTable, KeyValueTableRow, Tooltip, } from '@vegaprotocol/ui-toolkit'; import type BigNumber from 'bignumber.js'; import { formatNumber, quantumDecimalPlaces } from '@vegaprotocol/utils'; import { useT } from './use-t'; // Note: all of the values here are with correct asset's decimals // See `libs/deposits/src/lib/use-deposit-balances.ts` interface DepositLimitsProps { max: BigNumber; deposited: BigNumber; asset: Asset; balance?: BigNumber; allowance?: BigNumber; exempt?: boolean; } export const DepositLimits = ({ max, deposited, asset, balance, allowance, exempt, }: DepositLimitsProps) => { const t = useT(); const limits = [ { key: 'BALANCE_AVAILABLE', label: t('Balance available'), rawValue: balance, value: balance ? ( ) : ( '-' ), }, { key: 'REMAINING', label: (

{t( 'VEGA has a lifetime deposit limit of {{amount}} {{assetSymbol}} per address. This can be changed through governance', { amount: formatNumber(max.toString()), assetSymbol: asset.symbol, } )}

{t( 'To date, {{currentDeposit}} {{assetSymbol}} has been deposited from this Ethereum address, so you can deposit up to {{remainingDeposit}} {{assetSymbol}} more.', { currentDeposit: formatNumber(deposited.toString()), assetSymbol: asset.symbol, remainingDeposit: formatNumber( max.minus(deposited).toString() ), } )}

} >
), rawValue: max.minus(deposited), value: !exempt ? ( ) : (
{t('Exempt')}
), }, { key: 'ALLOWANCE', label: ( {t( 'The deposit cap is set when you approve an asset for use with this app. To increase this cap, approve {{assetSymbol}} again and choose a higher cap. Check the documentation for your Ethereum wallet app for details.', { assetSymbol: asset.symbol } )}

} >
), rawValue: allowance, value: allowance ? ( ) : ( '-' ), }, ]; return ( {limits.map(({ key, label, rawValue, value }) => (
{label}
{value}
))}
); };