From 4e473ee5c74ec30ef6adb002d4324424e15a2f23 Mon Sep 17 00:00:00 2001 From: JD Date: Wed, 11 Dec 2024 11:32:37 -0500 Subject: [PATCH] feat: add slippage for preview amounts (#98) --- src/utils/component-swap-data.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/utils/component-swap-data.ts b/src/utils/component-swap-data.ts index 427bc300..ff13bcdd 100644 --- a/src/utils/component-swap-data.ts +++ b/src/utils/component-swap-data.ts @@ -207,7 +207,11 @@ async function getAmount( functionName: isMinting ? 'previewMint' : 'previewRedeem', args: [issuanceUnits], })) as bigint - return preview + if (isMinting) { + return (preview * BigInt(10001)) / BigInt(10000) + } else { + return (preview * BigInt(9999)) / BigInt(10000) + } } catch { // eslint-disable-next-line @typescript-eslint/no-non-null-assertion const usdc = getTokenByChainAndSymbol(chainId, 'USDC')!