From 7de046504a95ad0baca6660fc1d8f52582045e2e Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Mon, 16 Mar 2026 04:15:28 +0000 Subject: max fee calc --- .../(app)/pay/[username]/[...amount]/+page.svelte | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) (limited to 'src') 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); }; @@ -62,7 +55,7 @@ type="button" class="btn !w-auto grow" onclick={setMax} - onkeydown={setMax}>Max ⚡️{s(user.balance)}Max {/if} -- cgit v1.2.3