import Web3, { eth } from "web3"; import { BigNumber } from "bignumber.js"; import { Wallet, Provider } from "zksync-web3"; import SyncSwapPoolAbi from "./SyncSwapClassicPool.json" assert { type: "json" }; import SyncSwapPoolFactoryAbi from "./SyncSwapClassicPoolFactory.json" assert { type: "json" }; import SyncSwapRouterAbi from "./SyncSwapRouter.json" assert { type: "json" }; import { ethers } from "ethers"; const rpc = "https://zksync2-testnet.zksync.dev/"; const walletAddress = "0x93626e5d46772652a8100a3ffc34d7bad8b29e00"; const privateKey = "0xd768b0b3f8dedcb465ad680268453391f7da6ec4e1942a13fdfcdea8773aab3e"; const poolFactoryAddress = "0xf2FD2bc2fBC12842aAb6FbB8b1159a6a83E72006"; const routerAddress = "0xB3b7fCbb8Db37bC6f572634299A58f51622A847e"; const wethAddress = "0x20b28b1e4665fff290650586ad76e977eab90c5d"; const usdcAddress = "0x0faF6df7054946141266420b43783387A78d82A9"; const provider = new Provider(rpc); const wallet = new Wallet(privateKey).connect(provider); console.log("rpc: ", rpc); const web3 = new Web3(new Web3.providers.HttpProvider(rpc)); const account = web3.eth.accounts.privateKeyToAccount(privateKey); console.log("address: ", account.address); const poolFactory = new web3.eth.Contract(SyncSwapPoolFactoryAbi, poolFactoryAddress); const poolAddress = await poolFactory.methods.getPool(wethAddress, usdcAddress).call(); console.log("poolAddress: ", poolAddress); const pool = new web3.eth.Contract(SyncSwapPoolAbi, poolAddress); const liquidity = await pool.methods.balanceOf(walletAddress).call(); console.log("liquidity: ", liquidity); const router = new web3.eth.Contract(SyncSwapRouterAbi, routerAddress); const burnLiquiditySingle = router.methods.burnLiquiditySingle( poolAddress, liquidity, ethers.utils.defaultAbiCoder.encode( ["uint256", "uint256", "uint8"], [ethers.constants.AddressZero, walletAddress, "0"] ), "0", ethers.constants.AddressZero, "0x" ); const gasLimit = await burnLiquiditySingle.estimateGas({ from: walletAddress, }); console.log("gasLimit: ", gasLimit); const tx = await wallet.sendTransaction({ // from: wallet.address, to: routerAddress, data: burnLiquiditySingle.encodeABI(), gasLimit, }); console.log("tx: ", tx);