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
4 changes: 4 additions & 0 deletions src/api/assets.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ export async function approveAsset(assetLabel, spenderName) {
return true;
}
} catch(e) {
if (e && e.code === 'ACTION_REJECTED' || e && e.code === 4001) {
// User rejected the wallet confirmation — not an error
return false;
}
showError(e);
}
}
7 changes: 6 additions & 1 deletion src/components/modals/EditMargin.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@
}, 50);
}

let funding = data.funding || 0;
let funding = data.funding || 0;
let currentLiqPrice = data.position.liqprice;
let newLiqPrice = data.position.liqprice;
let newMargin = 0;
function calculateNewLiquidationPrice(marginDelta, mode) {
Expand Down Expand Up @@ -151,6 +152,10 @@
<Input label={`${selected} ${data.position.asset}`} bind:value={margin} />
</div>

<div class='row'>
<LabelValue label='Current Liq. Price' value={`${formatForDisplay(currentLiqPrice) || "-"}`} />
</div>

<div class='row'>
<LabelValue label='New Liq. Price' value={`${formatForDisplay(newLiqPrice) || "-"}`} />
</div>
Expand Down
5 changes: 4 additions & 1 deletion src/components/modals/StakeCAP.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import LabelValue from '../layout/LabelValue.svelte'

let amount, isSubmitting, walletBalance = "0.0";
let isApproving = false;

$: formattedWalletBalance = formatCAPForDisplay(walletBalance);

Expand All @@ -35,7 +36,9 @@
}

async function _approveAsset() {
isApproving = true;
const result = await approveAsset('CAP', 'FundStore');
isApproving = false;
}

async function getBalance() {
Expand Down Expand Up @@ -75,7 +78,7 @@

<div>
{#if $allowances['CAP']?.['FundStore'] * 1 <= amount * 1}
<Button noSubmit={true} label={`Approve CAP`} on:click={_approveAsset} />
<Button noSubmit={true} isLoading={isApproving} label={`Approve CAP`} on:click={_approveAsset} />
{:else}
<Button isLoading={isSubmitting} label={`Stake`} />
{/if}
Expand Down