diff options
| author | Adam Soltys <[email protected]> | 2026-03-16 04:15:28 +0000 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-03-16 04:15:28 +0000 |
| commit | 7de046504a95ad0baca6660fc1d8f52582045e2e (patch) | |
| tree | 2956ded55c54dd338e2a6d2afa644e422c1ba420 /src | |
| parent | a9f31d3c9211e6b90be1a996406c667c2e7f7b93 (diff) | |
| download | coinos-ui-7de046504a95ad0baca6660fc1d8f52582045e2e.tar.gz coinos-ui-7de046504a95ad0baca6660fc1d8f52582045e2e.zip | |
max fee calc
Diffstat (limited to 'src')
| -rw-r--r-- | src/routes/(app)/pay/[username]/[...amount]/+page.svelte | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/src/routes/(app)/pay/[username]/[...amount]/+page.svelte b/src/routes/(app)/pay/[username]/[...amount]/+page.svelte index 618504ca..99502f95 100644 --- a/src/routes/(app)/pay/[username]/[...amount]/+page.svelte +++ b/src/routes/(app)/pay/[username]/[...amount]/+page.svelte @@ -20,20 +20,13 @@ let fiat = $state(!initialAmount); let formElement = $state(); - let setMax = async (e) => { + let setMax = (e) => { e.preventDefault(); - let body = new FormData(formElement); - body.set("fiat", false); - body.set("amount", user.balance); - - const response = await fetch(formElement.action, { - method: "POST", - body, - }); - - const result = deserialize(await response.text()); - if (result.type === "success") await invalidateAll(); - applyAction(result); + fiat = false; + const bal = user.balance; + const maxfee = Math.max(5, Math.round(bal * 0.02)); + const platformFee = Math.round(bal * 0.001); + amount = Math.max(0, bal - maxfee - platformFee); }; </script> @@ -62,7 +55,7 @@ type="button" class="btn !w-auto grow" onclick={setMax} - onkeydown={setMax}>Max ⚡️{s(user.balance)}</button + onkeydown={setMax}>Max</button > {/if} |
