import BigNumber from 'bignumber.js' import FormattedNumber from 'components/FormattedNumber' import ArrowRightLine from 'components/Icons/arrow-right-line.svg' import Text from 'components/Text' import useAccountStats from 'hooks/useAccountStats' import useCreditAccountPositions from 'hooks/useCreditAccountPositions' import useMarkets from 'hooks/useMarkets' import useTokenPrices from 'hooks/useTokenPrices' import useCreditManagerStore from 'stores/useCreditManagerStore' import useWalletStore from 'stores/useWalletStore' import { chain } from 'utils/chains' import { getTokenDecimals, getTokenSymbol } from 'utils/tokens' const CreditManager = () => { const address = useWalletStore((s) => s.address) const selectedAccount = useCreditManagerStore((s) => s.selectedAccount) const toggleCreditManager = useCreditManagerStore((s) => s.actions.toggleCreditManager) const { data: positionsData, isLoading: isLoadingPositions } = useCreditAccountPositions( selectedAccount ?? '', ) const { data: tokenPrices } = useTokenPrices() const { data: marketsData } = useMarkets() const accountStats = useAccountStats() const getTokenTotalUSDValue = (amount: string, denom: string) => { // early return if prices are not fetched yet if (!tokenPrices) return 0 return ( BigNumber(amount) .div(10 ** getTokenDecimals(denom)) .toNumber() * tokenPrices[denom] ) } return (