mirror of
https://github.com/scroll-tech/scroll.git
synced 2026-04-23 03:00:50 -04:00
fix abi
This commit is contained in:
1
contracts/scripts/abi/ERC20.json
Normal file
1
contracts/scripts/abi/ERC20.json
Normal file
@@ -0,0 +1 @@
|
||||
[{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"guy","type":"address"},{"name":"wad","type":"uint256"}],"name":"approve","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"src","type":"address"},{"name":"dst","type":"address"},{"name":"wad","type":"uint256"}],"name":"transferFrom","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"wad","type":"uint256"}],"name":"withdraw","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"balanceOf","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"dst","type":"address"},{"name":"wad","type":"uint256"}],"name":"transfer","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"deposit","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"},{"name":"","type":"address"}],"name":"allowance","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"payable":true,"stateMutability":"payable","type":"fallback"},{"anonymous":false,"inputs":[{"indexed":true,"name":"src","type":"address"},{"indexed":true,"name":"guy","type":"address"},{"indexed":false,"name":"wad","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"src","type":"address"},{"indexed":true,"name":"dst","type":"address"},{"indexed":false,"name":"wad","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"dst","type":"address"},{"indexed":false,"name":"wad","type":"uint256"}],"name":"Deposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"src","type":"address"},{"indexed":false,"name":"wad","type":"uint256"}],"name":"Withdrawal","type":"event"}]
|
||||
99
contracts/scripts/abi/UniswapV3Factory.json
Normal file
99
contracts/scripts/abi/UniswapV3Factory.json
Normal file
@@ -0,0 +1,99 @@
|
||||
[
|
||||
{ "inputs": [], "stateMutability": "nonpayable", "type": "constructor" },
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{ "indexed": true, "internalType": "uint24", "name": "fee", "type": "uint24" },
|
||||
{ "indexed": true, "internalType": "int24", "name": "tickSpacing", "type": "int24" }
|
||||
],
|
||||
"name": "FeeAmountEnabled",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{ "indexed": true, "internalType": "address", "name": "oldOwner", "type": "address" },
|
||||
{ "indexed": true, "internalType": "address", "name": "newOwner", "type": "address" }
|
||||
],
|
||||
"name": "OwnerChanged",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{ "indexed": true, "internalType": "address", "name": "token0", "type": "address" },
|
||||
{ "indexed": true, "internalType": "address", "name": "token1", "type": "address" },
|
||||
{ "indexed": true, "internalType": "uint24", "name": "fee", "type": "uint24" },
|
||||
{ "indexed": false, "internalType": "int24", "name": "tickSpacing", "type": "int24" },
|
||||
{ "indexed": false, "internalType": "address", "name": "pool", "type": "address" }
|
||||
],
|
||||
"name": "PoolCreated",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{ "internalType": "address", "name": "tokenA", "type": "address" },
|
||||
{ "internalType": "address", "name": "tokenB", "type": "address" },
|
||||
{ "internalType": "uint24", "name": "fee", "type": "uint24" }
|
||||
],
|
||||
"name": "createPool",
|
||||
"outputs": [{ "internalType": "address", "name": "pool", "type": "address" }],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{ "internalType": "uint24", "name": "fee", "type": "uint24" },
|
||||
{ "internalType": "int24", "name": "tickSpacing", "type": "int24" }
|
||||
],
|
||||
"name": "enableFeeAmount",
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [{ "internalType": "uint24", "name": "", "type": "uint24" }],
|
||||
"name": "feeAmountTickSpacing",
|
||||
"outputs": [{ "internalType": "int24", "name": "", "type": "int24" }],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{ "internalType": "address", "name": "", "type": "address" },
|
||||
{ "internalType": "address", "name": "", "type": "address" },
|
||||
{ "internalType": "uint24", "name": "", "type": "uint24" }
|
||||
],
|
||||
"name": "getPool",
|
||||
"outputs": [{ "internalType": "address", "name": "", "type": "address" }],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "owner",
|
||||
"outputs": [{ "internalType": "address", "name": "", "type": "address" }],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "parameters",
|
||||
"outputs": [
|
||||
{ "internalType": "address", "name": "factory", "type": "address" },
|
||||
{ "internalType": "address", "name": "token0", "type": "address" },
|
||||
{ "internalType": "address", "name": "token1", "type": "address" },
|
||||
{ "internalType": "uint24", "name": "fee", "type": "uint24" },
|
||||
{ "internalType": "int24", "name": "tickSpacing", "type": "int24" }
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [{ "internalType": "address", "name": "_owner", "type": "address" }],
|
||||
"name": "setOwner",
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
}
|
||||
]
|
||||
@@ -42,7 +42,6 @@
|
||||
{ "internalType": "address", "name": "tokenOut", "type": "address" },
|
||||
{ "internalType": "uint24", "name": "fee", "type": "uint24" },
|
||||
{ "internalType": "address", "name": "recipient", "type": "address" },
|
||||
{ "internalType": "uint256", "name": "deadline", "type": "uint256" },
|
||||
{ "internalType": "uint256", "name": "amountIn", "type": "uint256" },
|
||||
{ "internalType": "uint256", "name": "amountOutMinimum", "type": "uint256" },
|
||||
{ "internalType": "uint160", "name": "sqrtPriceLimitX96", "type": "uint160" }
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
/* eslint-disable node/no-missing-import */
|
||||
import { constants, Contract, providers, utils, Wallet } from "ethers";
|
||||
import { Contract, providers, utils, Wallet } from "ethers";
|
||||
import * as dotenv from "dotenv";
|
||||
|
||||
import ERC20ABI from "./abi/ERC20.json";
|
||||
import UniswapV3RouterABI from "./abi/UniswapV3Router.json";
|
||||
import UniswapV3FactoryABI from "./abi/UniswapV3Factory.json";
|
||||
|
||||
dotenv.config();
|
||||
|
||||
@@ -14,15 +16,27 @@ async function main() {
|
||||
|
||||
const USDC: string = "0x429C6C7b33Edb8cB19BD8cC0d1940B13Cca746C4";
|
||||
const WETH: string = await UniswapV3Router.WETH9();
|
||||
const factory: string = await UniswapV3Router.factory();
|
||||
const UniswapV3Factory = new Contract(factory, UniswapV3FactoryABI, signer);
|
||||
|
||||
const usdc = new Contract(USDC, ERC20ABI, signer);
|
||||
const weth = new Contract(WETH, ERC20ABI, signer);
|
||||
|
||||
const pool = await UniswapV3Factory.getPool(WETH, USDC, fee);
|
||||
|
||||
console.log("Signer address:", signer.address);
|
||||
console.log("Pool address:", pool);
|
||||
console.log("USDC in pool:", (await usdc.balanceOf(pool)).toString());
|
||||
console.log("WETH in pool:", (await weth.balanceOf(pool)).toString());
|
||||
|
||||
let nonce = await signer.getTransactionCount();
|
||||
for (let i = 0; i < 100; i++) {
|
||||
const data = UniswapV3Router.interface.encodeFunctionData("exactInputSingle", [
|
||||
{
|
||||
tokenIn: WETH,
|
||||
tokenOut: USDC,
|
||||
fee: fee,
|
||||
fee,
|
||||
recipient: signer.address,
|
||||
deadline: constants.MaxUint256,
|
||||
amountIn: utils.parseEther("0.0001"),
|
||||
amountOutMinimum: 0,
|
||||
sqrtPriceLimitX96: 0,
|
||||
@@ -32,8 +46,10 @@ async function main() {
|
||||
to: UniswapV3Router.address,
|
||||
data,
|
||||
nonce,
|
||||
value: utils.parseEther("0.0001"),
|
||||
});
|
||||
nonce = nonce + 1;
|
||||
console.log(tx);
|
||||
console.log("send tx with hash:", tx.hash, "nonce:", nonce);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user