Skip to content

Commit e74ca40

Browse files
authored
fix: use bigint accumulator in native sell reduce (#103)
1 parent 8bd9f34 commit e74ca40

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

src/index.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,12 +241,13 @@ export async function parseSwap({
241241
(acc, curr) => ({
242242
symbol: curr.symbol,
243243
amount: formatUnits(
244-
BigInt(acc.amount) + parseUnits(curr.amount, curr.decimals),
244+
acc.amountRaw + curr.amountRaw,
245245
curr.decimals
246246
),
247+
amountRaw: acc.amountRaw + curr.amountRaw,
247248
address: curr.address,
248249
}),
249-
{ symbol: "", amount: "", address: "" }
250+
{ symbol: "", amount: "", amountRaw: 0n, address: "" }
250251
);
251252

252253
return {
@@ -255,7 +256,11 @@ export async function parseSwap({
255256
address: NATIVE_TOKEN_ADDRESS,
256257
amount: nativeSellAmount,
257258
},
258-
tokenOut,
259+
tokenOut: {
260+
symbol: tokenOut.symbol,
261+
amount: tokenOut.amount,
262+
address: tokenOut.address,
263+
},
259264
};
260265
}
261266

0 commit comments

Comments
 (0)