Sfoglia il codice sorgente

fix: big number overflow

wren 1 anno fa
parent
commit
2552b433db
1 ha cambiato i file con 1 aggiunte e 1 eliminazioni
  1. 1 1
      js-runtime/src/script/zksync2/mute/swapUsdcForEth.js

+ 1 - 1
js-runtime/src/script/zksync2/mute/swapUsdcForEth.js

@@ -14,7 +14,7 @@ async function sendSwapTx(amountNumber, router, signer, provider, wallet, approv
     let timestamp = new Date().getTime();
     timestamp = (timestamp / 1000 + 20 * 60).toFixed(0);
     const amountsOut = await router.getAmountsOut(amountIn, path, stable);
-    const amountOut = (amountsOut[1].toNumber() * 995 / 1000).toFixed(0);
+    const amountOut = (amountsOut[1].mul(995).div(1000));
     const swapTx = await router.swapExactTokensForETHSupportingFeeOnTransferTokens(amountIn, amountOut, path, signer.address, timestamp, stable)
     await swapTx.wait();
     const swapReceipt = await provider.getTransactionReceipt(swapTx.hash);