Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions src/components/modals/Deposit.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -17,6 +16,9 @@

let amount, asset, isSubmitting, costBps;

$: walletBalance = $balances[asset] || 0;
$: formattedWalletBalance = formatForDisplay(walletBalance);

async function selectAsset(_asset) {
asset = _asset;
getGlobalUPL(_asset);
Expand Down Expand Up @@ -99,12 +101,16 @@

<div class="group">
<Input label='Amount' bind:value={amount} />
<LabelValue
label='Wallet Balance'
value={formattedWalletBalance}
isClickable={true}
hasSemiPadding={true}
on:click={() => { amount = walletBalance; }}
/>
</div>

<div class="group">
<div class='group-row'>
<LabelValue label='Available' value={numberWithCommas($balances[asset])} isClickable={true} on:click={() => {amount = $balances[asset]}} />
</div>
<div class='group-row'><LabelValue label='Total Trader UP/L' value={numberWithCommas($globalUPLs[asset])} /></div>
<LabelValue label='Deposit Cost' value={`${costBps || 0}%`} />
</div>
Expand Down
16 changes: 12 additions & 4 deletions src/components/modals/Withdraw.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -16,6 +15,9 @@

let amount, asset, costBps, isSubmitting;

$: withdrawableAmount = $poolStakes[asset] || 0;
$: formattedWithdrawableAmount = formatForDisplay(withdrawableAmount);

async function selectAsset(_asset) {
asset = _asset;
getGlobalUPL(_asset);
Expand Down Expand Up @@ -87,11 +89,17 @@

<div class="group">
<Input label='Amount' bind:value={amount} />
<LabelValue
label='Available to Withdraw'
value={formattedWithdrawableAmount}
isClickable={true}
hasSemiPadding={true}
on:click={() => { amount = withdrawableAmount; }}
/>
</div>

<div class="group">
<div class='group-row'><LabelValue label='Available' value={formatForDisplay($poolStakes[asset])} isClickable={true} on:click={() => {amount = $poolStakes[asset]}} /></div>
<div class='group-row'><LabelValue label='Total Trader UP/L' value={numberWithCommas($globalUPLs[asset])} /></div>
<div class='group-row'><LabelValue label='Total Trader UP/L' value={numberWithCommas($globalUPLs[asset])} /></div>
<LabelValue label='Withdrawal Cost' value={`${costBps || 0}%`} />
</div>

Expand All @@ -107,4 +115,4 @@

</div>

</Modal>
</Modal>