| 12345678910111213141516171819202122232425262728293031323334353637383940 |
- import Web3, { eth } from "web3";
- import { BigNumber } from "bignumber.js";
- import { Wallet, Provider } from "zksync-web3";
- import SyncSwapPoolAbi 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 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(SyncSwapPoolAbi, "0xf2FD2bc2fBC12842aAb6FbB8b1159a6a83E72006");
- const res = await poolFactory.methods
- .getPool("0x20b28b1e4665fff290650586ad76e977eab90c5d", "0x0faF6df7054946141266420b43783387A78d82A9")
- .call();
- console.log("res: ", res);
- const router = new web3.eth.Contract(SyncSwapRouterAbi, "0xB3b7fCbb8Db37bC6f572634299A58f51622A847e");
- console.log(ethers.utils.parseEther("0.001", 18).toString())
- const addLiquidity = router.methods.addLiquidity2(
- "0xcFA3d5C02D827c0d1A48B4241700AEBF751458FA",
- [
- ["0x20b28b1e4665fff290650586ad76e977eab90c5d", ethers.utils.parseEther("0.001", 18).toString()],
- ["0x0faF6df7054946141266420b43783387A78d82A9", ethers.utils.parseEther("0", 6).toString()],
- ],
- //encode abi
- ethers.utils.defaultAbiCoder.encode(["uint256"], [walletAddress]),
- 0,
- "0x0000000000000000000000000000000000000000",
- "0x"
- );
- const gas = await addLiquidity.estimateGas({ from: walletAddress });
- console.log("gas: ", gas);
|