diff --git a/src/components/Account/AccountBalancesTable/index.tsx b/src/components/Account/AccountBalancesTable/index.tsx index 0d0daa94..3cc53287 100644 --- a/src/components/Account/AccountBalancesTable/index.tsx +++ b/src/components/Account/AccountBalancesTable/index.tsx @@ -19,7 +19,6 @@ import { FormattedNumber } from 'components/FormattedNumber' import { SortAsc, SortDesc, SortNone } from 'components/Icons' import Text from 'components/Text' import { ASSETS } from 'constants/assets' -import { BN_ZERO } from 'constants/math' import { ORACLE_DENOM } from 'constants/oracle' import useCurrentAccount from 'hooks/useCurrentAccount' import useStore from 'store' @@ -85,8 +84,8 @@ export default function Index(props: Props) { accessorKey: 'size', header: 'Size', cell: ({ row }) => { - if (row.original.amount.isEqualTo(BN_ZERO)) - return – + if (row.original.type === 'vault') + return
–
const color = getAmountChangeColor(row.original.type, row.original.amountChange) const amount = demagnify( row.original.amount, @@ -229,4 +228,4 @@ export default function Index(props: Props) { ) -} \ No newline at end of file +} diff --git a/src/components/FormattedNumber.tsx b/src/components/FormattedNumber.tsx index ac378dce..35728f15 100644 --- a/src/components/FormattedNumber.tsx +++ b/src/components/FormattedNumber.tsx @@ -28,8 +28,8 @@ export const FormattedNumber = React.memo( }, [props.amount]) const springAmount = useSpring({ - number: props.amount, - from: { number: prevAmountRef.current }, + number: isNaN(props.amount) ? 0 : props.amount, + from: { number: isNaN(prevAmountRef.current) ? 0 : prevAmountRef.current }, config: { duration: 1000 }, }) diff --git a/src/components/Modals/BorrowModal.tsx b/src/components/Modals/BorrowModal.tsx index d50ea9b4..10d94faf 100644 --- a/src/components/Modals/BorrowModal.tsx +++ b/src/components/Modals/BorrowModal.tsx @@ -65,6 +65,7 @@ function BorrowModal(props: Props) { const { simulateBorrow, simulateRepay } = useUpdatedAccount(account) const { autoLendEnabledAccountIds } = useAutoLend() + const apr = modal.marketData?.borrowRate ?? '0' const isAutoLendEnabled = autoLendEnabledAccountIds.includes(account.id) const { computeMaxBorrowAmount } = useHealthComputer(account) @@ -112,7 +113,13 @@ function BorrowModal(props: Props) { (newAmount: BigNumber) => { const coin = BNCoin.fromDenomAndBigNumber(asset.denom, newAmount) if (!amount.isEqualTo(newAmount)) setAmount(newAmount) - if (isRepay) simulateRepay(coin) + if (isRepay) { + const totalDebt = BN(getDebtAmount(modal)) + const repayCoin = coin.amount.isGreaterThan(totalDebt) + ? BNCoin.fromDenomAndBigNumber(asset.denom, totalDebt) + : coin + simulateRepay(repayCoin) + } }, [asset, amount, isRepay, simulateRepay], ) @@ -124,7 +131,10 @@ function BorrowModal(props: Props) { const lendBalance = account.lends.find(byDenom(asset.denom))?.amount ?? BN_ZERO const maxBalance = depositBalance.plus(lendBalance) const totalDebt = BN(getDebtAmount(modal)) - const maxRepayAmount = BigNumber.min(maxBalance, totalDebt) + const maxRepayAmount = BigNumber.min( + maxBalance, + totalDebt.times(1 + Number(apr) / 365 / 24).integerValue(), + ) setMax(maxRepayAmount) return }