INNER CODE UNIT · JavaScript
buyTokens
CleBeert/crypto-trading-bot-eth-bnb · Arbitrage.js:172
async function buyTokens(transactionDetails){
if(true){
const gasPrice = transactionDetails.gasPrice
const newGasPrice = Math.floor(parseInt(gasPrice) + parseInt(1))
const gasLimit = Math.floor(transactionDetails.gas * 1.2)
const inputEth = parseFloat(ETH_AMOUNT) * 0.99;
const ethAmount = ethers.utils.parseEther(inputEth.toString());
const trade = new Trade(route, new TokenAmount(weth, ethAmount), TradeType.EXACT_INPUT);
const path = [weth.address, token.address];
const deadline = Math.floor(Date.now() / 1000) + 60 * 20;
const deadlineHex = ethers.BigNumber.from(deadline.toString()).toHexString();
tokensToSell = trade.outputAmount.raw
const amountOutHex = ethers.BigNumber.from(tokensToSell.toString()).toHexString();
const ethAmt = parseFloat(ETH_AMOUNT) * 1.2;
const amountInMax = ethers.utils.parseEther(ethAmt.toString());