From 5188586ceb5eb65fdf0953f2a8a7951fc8fb1057 Mon Sep 17 00:00:00 2001 From: duongynhi000005-oss Date: Mon, 25 May 2026 06:54:56 +0000 Subject: [PATCH] Add max balance shortcuts to pool deposit/withdraw modals --- src/components/modals/Deposit.svelte | 16 +++++++++++----- src/components/modals/Withdraw.svelte | 16 ++++++++++++---- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/src/components/modals/Deposit.svelte b/src/components/modals/Deposit.svelte index 131b8ea..b40d2a6 100644 --- a/src/components/modals/Deposit.svelte +++ b/src/components/modals/Deposit.svelte @@ -7,8 +7,7 @@ import { onMount } from 'svelte' - import { BPS_DIVIDER } from '@lib/config' - import { numberWithCommas } from '@lib/formatters' + import { formatForDisplay, numberWithCommas } from '@lib/formatters' import { deposit, getPoolWithdrawalFee, getPoolDepositTaxBps, getGlobalUPL } from '@api/pool' import { approveAsset, getAllowance, getUserAssetBalances } from '@api/assets' import { allowances, poolDepositTaxes, globalUPLs, poolWithdrawalFees, balances } from '@lib/stores' @@ -17,6 +16,9 @@ let amount, asset, isSubmitting, costBps; + $: walletBalance = $balances[asset] || 0; + $: formattedWalletBalance = formatForDisplay(walletBalance); + async function selectAsset(_asset) { asset = _asset; getGlobalUPL(_asset); @@ -99,12 +101,16 @@
+ { amount = walletBalance; }} + />
-
- {amount = $balances[asset]}} /> -
diff --git a/src/components/modals/Withdraw.svelte b/src/components/modals/Withdraw.svelte index d0b92b3..a31c170 100644 --- a/src/components/modals/Withdraw.svelte +++ b/src/components/modals/Withdraw.svelte @@ -7,7 +7,6 @@ import { onMount } from 'svelte' - import { BPS_DIVIDER } from '@lib/config' import { poolStakes, globalUPLs } from '@lib/stores' import { withdraw, getPoolWithdrawalTaxBps, getGlobalUPL } from '@api/pool' import { focusInput, hideModal } from '@lib/ui' @@ -16,6 +15,9 @@ let amount, asset, costBps, isSubmitting; + $: withdrawableAmount = $poolStakes[asset] || 0; + $: formattedWithdrawableAmount = formatForDisplay(withdrawableAmount); + async function selectAsset(_asset) { asset = _asset; getGlobalUPL(_asset); @@ -87,11 +89,17 @@
+ { amount = withdrawableAmount; }} + />
-
{amount = $poolStakes[asset]}} />
-
+
@@ -107,4 +115,4 @@ - \ No newline at end of file +