Approving ERC20s in our multicall
import erc20Abi from "./abi/erc20.json";
const sushiRouterAddress = "0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506"
const usdcTokenAddress = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"
const usdcContractInterface = new ethers.utils.Interface(erc20Abi as any);
const approveEncodeData = usdcContractInterface.encodeFunctionData(
"approve",
[
sushiRouterAddress,
"0" // Amount to approve. See below for why this is zero.
]
);
const approveCall = {
callType: 1,
target: usdcTokenAddress,
value: "0", // native value to be sent with call
callData: approveEncodeData,
payload: {
tokenAddress: usdcTokenAddress, // balance of this token replaces 0 on line 13
inputPos: 1
},
estimatedGas: "400000"
}payload
Last updated