fix: do update the health on sliding the margin back to 0 (#593)

This commit is contained in:
Linkie Link 2023-10-27 18:15:37 +02:00 committed by GitHub
parent 0c7f39a6a7
commit 1d8bab3206
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -52,6 +52,7 @@ export default function SwapForm(props: Props) {
const [estimatedFee, setEstimatedFee] = useState(defaultFee)
const { autoLendEnabledAccountIds } = useAutoLend()
const isAutoLendEnabled = account ? autoLendEnabledAccountIds.includes(account.id) : false
const modal = useStore<string | null>((s) => s.fundAndWithdrawModal)
const throttledEstimateExactIn = useMemo(() => asyncThrottle(estimateExactIn, 250), [])
const { simulateTrade, removedLends } = useUpdatedAccount(account)
@ -210,7 +211,8 @@ export default function SwapForm(props: Props) {
? sellAssetAmount.minus(sellSideMarginThreshold)
: BN_ZERO
if (removeDepositAmount.isZero() && addDebtAmount.isZero() && buyAssetAmount.isZero()) return
if (removeDepositAmount.isZero() && addDebtAmount.isZero() && buyAssetAmount.isZero() && modal)
return
const removeCoin = BNCoin.fromDenomAndBigNumber(sellAsset.denom, removeDepositAmount)
const debtCoin = BNCoin.fromDenomAndBigNumber(sellAsset.denom, addDebtAmount)
const addCoin = BNCoin.fromDenomAndBigNumber(buyAsset.denom, buyAssetAmount)
@ -223,6 +225,7 @@ export default function SwapForm(props: Props) {
buyAsset.denom,
sellAsset.denom,
debouncedUpdateAccount,
modal,
])
useEffect(() => {