From 0960594752b4ba37894355ba40a8534e7debde06 Mon Sep 17 00:00:00 2001 From: cryptopavelsan <99785705+cryptopavelsan@users.noreply.github.com> Date: Sat, 10 Dec 2022 00:39:37 -0500 Subject: [PATCH] Fix issue with output token decimals The output token amount from the swap was using the input token's decimals. Would work of if they matches but fails for tokens like USDC to SOL swaps. This fixes it to use the correct decimal number for the correct display of the swap amount on screen to the user. --- src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 1e5997c..569d3e0 100644 --- a/src/index.ts +++ b/src/index.ts @@ -54,7 +54,7 @@ const jupiterSwap = async ({ ); process.stdout.write(`${inputToken.symbol} -> `); process.stdout.write( - `${swapResult.outputAmount / (10 ** inputToken.decimals)} ` + `${swapResult.outputAmount / (10 ** outputToken.decimals)} ` ); process.stdout.write(`${outputToken.symbol}: `); console.log(`https://solscan.io/tx/${swapResult.txid}`);