diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..974f6b0 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,19 @@ +name: "publish package to npm" + +on: push + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - name: checkout + uses: actions/checkout@v2 + - name: node + uses: actions/setup-node@v2 + with: + node-version: 16 + registry-url: https://registry.npmjs.org + - name: publish + run: npm publish --access public + env: + NODE_AUTH_TOKEN: ${{secrets.NPM_AUTH_TOKEN}} diff --git a/README.md b/README.md index a6c1a82..e02480a 100644 --- a/README.md +++ b/README.md @@ -5,55 +5,39 @@ This is a script for automatic interaction with the onchain protocol by setting # Supported protocols 1. Base AAVE - - deposit 0.001 ETH -> approve -> withdraw + - Deposit ETH -> approve -> withdraw 2. Base Uniswap - - swap DAI <-> 0.0001 ETH + - Swap DAI <-> ETH -# How to start ? +# Getting started -Two options for starting the bot - -1. Node.js -2. Docker - -## Prerequisites - -Create `.env` file with `.env.example` - -You can change default value of variables in `.env.example` to `.env` if you need - -## Docker - -1. Build image +1. Install CLI globally ```bash -npm run docker:build +npm install -g airdrop-bot ``` -2. Run container +2. Check version ```bash -npm run docker:run +airdrop-bot -v +# 0.0.1 ``` -3. Check docker logs +3. Interact protocols (AAVE / Uniswap) -```bash -npm run docker:logs -``` - -## Node.js - -1. Install packages +For example, interact aave by 0.01 ETH and setup delay 10 minutes ```bash -yarn -``` +# set your private key to environment variables +export PK= -2. Run app +# check private key +echo $PK +``` ```bash -npm run app +airdrop-bot aave -p $PK --delay 10 --amount 0.01 ``` --- @@ -72,8 +56,8 @@ Account Print below information when starting a new round -- Trigger start/end time (yime zone: Asia/Taipei) -- Random delay seconds (limit base on `$DELAY` variable in `.env`) +- Trigger start / end time (time zone: Asia/Taipei) +- Random delay seconds (limit base on `--delay` command option) - Each txs hash and status (retry sent tx if status is `reverted`) ```bash diff --git a/dist/commands/aave.js b/dist/commands/aave.js new file mode 100644 index 0000000..e956966 --- /dev/null +++ b/dist/commands/aave.js @@ -0,0 +1,18 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.aave = void 0; +const viem_1 = require("viem"); +const commander_1 = require("commander"); +const protocol_1 = require("../types/protocol"); +const aave_1 = require("../utils/aave"); +exports.aave = new commander_1.Command("aave"); +exports.aave + .description("Start the aave protocol") + .option("-p, --pk ", "private key of signer") + .option(" --amount ", "amount of ETH") + .option("-d, --delay ", "delay in minutes") + .action((options) => { + const cronTab = process.env.CRONJOB || "* * * * * *"; + const aaveProtocol = new protocol_1.Protocol(aave_1.aave, options.pk, (0, viem_1.parseEther)(options.amount), cronTab, Number(options.delay)); + aaveProtocol.execute(); +}); diff --git a/dist/commands/uniswap.js b/dist/commands/uniswap.js new file mode 100644 index 0000000..4eccfd7 --- /dev/null +++ b/dist/commands/uniswap.js @@ -0,0 +1,18 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.uniswap = void 0; +const viem_1 = require("viem"); +const commander_1 = require("commander"); +const protocol_1 = require("../types/protocol"); +const uniswap_1 = require("../utils/uniswap"); +exports.uniswap = new commander_1.Command("uniswap"); +exports.uniswap + .description("Start the uniswap protocol") + .option("-p, --pk ", "private key of signer") + .option(" --amount ", "amount of ETH") + .option("-d, --delay ", "delay in minutes") + .action((options) => { + const cronTab = process.env.CRONJOB || "* * * * * *"; + const uniswapProtocol = new protocol_1.Protocol(uniswap_1.uniswap, options.pk, (0, viem_1.parseEther)(options.amount), cronTab, Number(options.delay)); + uniswapProtocol.execute(); +}); diff --git a/dist/index.js b/dist/index.js new file mode 100755 index 0000000..0b8c012 --- /dev/null +++ b/dist/index.js @@ -0,0 +1,18 @@ +#!/usr/bin/env node +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.program = void 0; +const commander_1 = require("commander"); +const figlet_1 = require("figlet"); +const aave_1 = require("./commands/aave"); +const uniswap_1 = require("./commands/uniswap"); +console.log((0, figlet_1.textSync)("BOT")); +exports.program = new commander_1.Command(); +// Main +exports.program + .version("0.0.1", "-v, --versions", "output the current version") + .description("A simple airdrop bot") + .addCommand(uniswap_1.uniswap) + .addCommand(aave_1.aave) + .showHelpAfterError("(add --help for additional information)"); +exports.program.parse(); diff --git a/dist/libs/cron.js b/dist/libs/cron.js new file mode 100644 index 0000000..221a124 --- /dev/null +++ b/dist/libs/cron.js @@ -0,0 +1,30 @@ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.createConfig = void 0; +const time_1 = require("./time"); +function createConfig(interaction, cronTime, delay) { + return { + cronTime: cronTime, + onTick: function () { + return __awaiter(this, void 0, void 0, function* () { + console.log("Start new round"); + yield (0, time_1.randomDelay)(delay); + yield interaction(); + console.log(`End time ${(0, time_1.getTime)()}`); + console.log("============================="); + }); + }, + start: true, + timeZone: "Asia/Taipei", + }; +} +exports.createConfig = createConfig; diff --git a/dist/libs/time.js b/dist/libs/time.js new file mode 100644 index 0000000..85839bd --- /dev/null +++ b/dist/libs/time.js @@ -0,0 +1,38 @@ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.delay = exports.randomDelay = exports.getTime = void 0; +function getTime() { + const date = new Date(Date.now()); + const formatStakeTime = date.toLocaleString("zh-TW", { + timeZone: "Asia/Taipei", + }); + return formatStakeTime; +} +exports.getTime = getTime; +function randomDelay() { + return __awaiter(this, arguments, void 0, function* (delay_ = 0) { + const MINUTES = 60; // 60 seconds + const LIMIT = Number(delay_) * MINUTES; // 最多不超過延遲 $DELAY 分鐘 + const rand = Math.floor(Math.random() * LIMIT); + console.log(`Start time: ${getTime()} | Delay ${rand} seconds`); + yield delay(rand * 1000); + }); +} +exports.randomDelay = randomDelay; +function delay(ms) { + return __awaiter(this, void 0, void 0, function* () { + return new Promise(function (resolve) { + setTimeout(resolve, ms); + }); + }); +} +exports.delay = delay; diff --git a/dist/libs/transaction.js b/dist/libs/transaction.js new file mode 100644 index 0000000..2f817e5 --- /dev/null +++ b/dist/libs/transaction.js @@ -0,0 +1,30 @@ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.sendTransaction = void 0; +const public_1 = require("../utils/clients/public"); +function sendTransaction(request, signer) { + return __awaiter(this, void 0, void 0, function* () { + while (1) { + const hash = yield signer.writeContract(request); + const transaction = yield public_1.PUBLIC_CLIENT.waitForTransactionReceipt({ + confirmations: 5, + hash, + pollingInterval: 12000, + }); + console.log(`Tx Hash: ${transaction.transactionHash} - ${transaction.status}`); + if (transaction.status === "success") + break; + console.log("Reverted !! Retrying..."); + } + }); +} +exports.sendTransaction = sendTransaction; diff --git a/dist/types/protocol.js b/dist/types/protocol.js new file mode 100644 index 0000000..8ae3485 --- /dev/null +++ b/dist/types/protocol.js @@ -0,0 +1,37 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Protocol = void 0; +const cron_1 = require("cron"); +const viem_1 = require("viem"); +const accounts_1 = require("viem/accounts"); +const cron_2 = require("../libs/cron"); +const config_1 = require("../utils/clients/config"); +class Protocol { + constructor(interaction, privateKey, amount, cronTime = "* * * * * *", delay = 0) { + this.amount = amount; + this.cronTime = cronTime; + this.delay = delay; + const _signer = this.setSigner(privateKey); + const _interaction = interaction.bind(null, _signer, amount); + const config = (0, cron_2.createConfig)(_interaction, cronTime, delay); + this.cron = new cron_1.CronJob(config.cronTime, config.onTick, null, config.start, config.timeZone); + } + execute() { + var _a; + console.log(`Starting app ...`); + console.log(`Mode ${process.env.MODE}`); + console.log(`Time ${this.cronTime} | Delay ${this.delay} minutes`); + console.log(`Account ${(_a = this.signer.account) === null || _a === void 0 ? void 0 : _a.address}`); + this.cron.start(); + } + getSigner() { + return this.signer; + } + setSigner(privateKey) { + const account = (0, accounts_1.privateKeyToAccount)(privateKey); + const _signer = (0, viem_1.createWalletClient)(Object.assign({ account }, config_1.CONFIG)); + this.signer = _signer; + return _signer; + } +} +exports.Protocol = Protocol; diff --git a/dist/utils/aave.js b/dist/utils/aave.js new file mode 100644 index 0000000..40a1402 --- /dev/null +++ b/dist/utils/aave.js @@ -0,0 +1,42 @@ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.aave = void 0; +const viem_1 = require("viem"); +const transaction_1 = require("../libs/transaction"); +const aave_1 = require("./contracts/aave"); +function deposit(signer, amount) { + return __awaiter(this, void 0, void 0, function* () { + const { account } = signer; + const { request } = yield aave_1.AAVE.simulate.depositETH([viem_1.zeroAddress, account.address, 0], { + value: amount, + account, + }); + console.log("Deposit..."); + yield (0, transaction_1.sendTransaction)(request, signer); + }); +} +function withdraw(signer, amount) { + return __awaiter(this, void 0, void 0, function* () { + const { account } = signer; + const { request: approveReq } = yield aave_1.WETH.simulate.approve([aave_1.AAVE.address, amount], { account: account }); + console.log("Approving..."); + yield (0, transaction_1.sendTransaction)(approveReq, signer); + const { request: withdrawReq } = yield aave_1.AAVE.simulate.withdrawETH([viem_1.zeroAddress, amount, account.address], { account: account }); + console.log("Withdraw..."); + yield (0, transaction_1.sendTransaction)(withdrawReq, signer); + }); +} +const aave = (_signer, amount) => __awaiter(void 0, void 0, void 0, function* () { + yield deposit(_signer, amount); + yield withdraw(_signer, amount); +}); +exports.aave = aave; diff --git a/dist/utils/clients/config.js b/dist/utils/clients/config.js new file mode 100644 index 0000000..12d9ddf --- /dev/null +++ b/dist/utils/clients/config.js @@ -0,0 +1,36 @@ +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.CONFIG = void 0; +const chains_1 = require("viem/chains"); +const viem_1 = require("viem"); +const dotenv = __importStar(require("dotenv")); +dotenv.config({ + path: `.env${process.env.NODE_ENV ? `.${process.env.NODE_ENV}` : ""}`, +}); +exports.CONFIG = { + chain: process.env.MODE === "dev" ? chains_1.sepolia : chains_1.base, + transport: (0, viem_1.http)(process.env.RPC), +}; diff --git a/dist/utils/clients/public.js b/dist/utils/clients/public.js new file mode 100644 index 0000000..174c137 --- /dev/null +++ b/dist/utils/clients/public.js @@ -0,0 +1,6 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.PUBLIC_CLIENT = void 0; +const viem_1 = require("viem"); +const config_1 = require("./config"); +exports.PUBLIC_CLIENT = (0, viem_1.createPublicClient)(config_1.CONFIG); diff --git a/dist/utils/constants.js b/dist/utils/constants.js new file mode 100644 index 0000000..ef14163 --- /dev/null +++ b/dist/utils/constants.js @@ -0,0 +1,34 @@ +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.UNI_V3_POOL_ADDR = exports.UNISWAP_ROUTER_ADDR = exports.WETH_ADDR = exports.AAVE_ADDR = void 0; +const dotenv = __importStar(require("dotenv")); +dotenv.config({ + path: `.env${process.env.NODE_ENV ? `.${process.env.NODE_ENV}` : ""}`, +}); +exports.AAVE_ADDR = process.env.AAVE; +exports.WETH_ADDR = process.env.WETH; +exports.UNISWAP_ROUTER_ADDR = process.env.UNISWAP_ROUTER; +exports.UNI_V3_POOL_ADDR = process.env.UNI_V3_POOL; diff --git a/dist/utils/contracts/aave.js b/dist/utils/contracts/aave.js new file mode 100644 index 0000000..4dcf8ac --- /dev/null +++ b/dist/utils/contracts/aave.js @@ -0,0 +1,17 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.WETH = exports.AAVE = void 0; +const viem_1 = require("viem"); +const abis_1 = require("./abis"); +const public_1 = require("../clients/public"); +const constants_1 = require("../constants"); +exports.AAVE = (0, viem_1.getContract)({ + address: constants_1.AAVE_ADDR, + abi: abis_1.AAVE_ABI, + client: { public: public_1.PUBLIC_CLIENT }, +}); +exports.WETH = (0, viem_1.getContract)({ + address: constants_1.WETH_ADDR, + abi: abis_1.WETH_ABI, + client: { public: public_1.PUBLIC_CLIENT }, +}); diff --git a/dist/utils/contracts/abis.js b/dist/utils/contracts/abis.js new file mode 100644 index 0000000..41a01f3 --- /dev/null +++ b/dist/utils/contracts/abis.js @@ -0,0 +1,1722 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.UNI_V3_POOL_ABI = exports.ERC20_ABI = exports.UNISWAP_ROUTER_ABI = exports.WETH_ABI = exports.AAVE_ABI = void 0; +exports.AAVE_ABI = [ + { + inputs: [ + { internalType: "address", name: "weth", type: "address" }, + { internalType: "address", name: "owner", type: "address" }, + { internalType: "contract IPool", name: "pool", type: "address" }, + ], + stateMutability: "nonpayable", + type: "constructor", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "previousOwner", + type: "address", + }, + { + indexed: true, + internalType: "address", + name: "newOwner", + type: "address", + }, + ], + name: "OwnershipTransferred", + type: "event", + }, + { stateMutability: "payable", type: "fallback" }, + { + inputs: [], + name: "POOL", + outputs: [{ internalType: "contract IPool", name: "", type: "address" }], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "WETH", + outputs: [{ internalType: "contract IWETH", name: "", type: "address" }], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { internalType: "address", name: "", type: "address" }, + { internalType: "uint256", name: "amount", type: "uint256" }, + { internalType: "uint256", name: "interestRateMode", type: "uint256" }, + { internalType: "uint16", name: "referralCode", type: "uint16" }, + ], + name: "borrowETH", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { internalType: "address", name: "", type: "address" }, + { internalType: "address", name: "onBehalfOf", type: "address" }, + { internalType: "uint16", name: "referralCode", type: "uint16" }, + ], + name: "depositETH", + outputs: [], + stateMutability: "payable", + type: "function", + }, + { + inputs: [ + { internalType: "address", name: "to", type: "address" }, + { internalType: "uint256", name: "amount", type: "uint256" }, + ], + name: "emergencyEtherTransfer", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { internalType: "address", name: "token", type: "address" }, + { internalType: "address", name: "to", type: "address" }, + { internalType: "uint256", name: "amount", type: "uint256" }, + ], + name: "emergencyTokenTransfer", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [], + name: "getWETHAddress", + 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: "renounceOwnership", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { internalType: "address", name: "", type: "address" }, + { internalType: "uint256", name: "amount", type: "uint256" }, + { internalType: "uint256", name: "rateMode", type: "uint256" }, + { internalType: "address", name: "onBehalfOf", type: "address" }, + ], + name: "repayETH", + outputs: [], + stateMutability: "payable", + type: "function", + }, + { + inputs: [{ internalType: "address", name: "newOwner", type: "address" }], + name: "transferOwnership", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { internalType: "address", name: "", type: "address" }, + { internalType: "uint256", name: "amount", type: "uint256" }, + { internalType: "address", name: "to", type: "address" }, + ], + name: "withdrawETH", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { internalType: "address", name: "", type: "address" }, + { internalType: "uint256", name: "amount", type: "uint256" }, + { internalType: "address", name: "to", type: "address" }, + { internalType: "uint256", name: "deadline", type: "uint256" }, + { internalType: "uint8", name: "permitV", type: "uint8" }, + { internalType: "bytes32", name: "permitR", type: "bytes32" }, + { internalType: "bytes32", name: "permitS", type: "bytes32" }, + ], + name: "withdrawETHWithPermit", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { stateMutability: "payable", type: "receive" }, +]; +exports.WETH_ABI = [ + { + inputs: [{ internalType: "contract IPool", name: "pool", type: "address" }], + stateMutability: "nonpayable", + type: "constructor", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "owner", + type: "address", + }, + { + indexed: true, + internalType: "address", + name: "spender", + type: "address", + }, + { + indexed: false, + internalType: "uint256", + name: "value", + type: "uint256", + }, + ], + name: "Approval", + type: "event", + }, + { + anonymous: false, + inputs: [ + { indexed: true, internalType: "address", name: "from", type: "address" }, + { indexed: true, internalType: "address", name: "to", type: "address" }, + { + indexed: false, + internalType: "uint256", + name: "value", + type: "uint256", + }, + { + indexed: false, + internalType: "uint256", + name: "index", + type: "uint256", + }, + ], + name: "BalanceTransfer", + type: "event", + }, + { + anonymous: false, + inputs: [ + { indexed: true, internalType: "address", name: "from", type: "address" }, + { + indexed: true, + internalType: "address", + name: "target", + type: "address", + }, + { + indexed: false, + internalType: "uint256", + name: "value", + type: "uint256", + }, + { + indexed: false, + internalType: "uint256", + name: "balanceIncrease", + type: "uint256", + }, + { + indexed: false, + internalType: "uint256", + name: "index", + type: "uint256", + }, + ], + name: "Burn", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "underlyingAsset", + type: "address", + }, + { indexed: true, internalType: "address", name: "pool", type: "address" }, + { + indexed: false, + internalType: "address", + name: "treasury", + type: "address", + }, + { + indexed: false, + internalType: "address", + name: "incentivesController", + type: "address", + }, + { + indexed: false, + internalType: "uint8", + name: "ATOKENDecimals", + type: "uint8", + }, + { + indexed: false, + internalType: "string", + name: "ATOKENName", + type: "string", + }, + { + indexed: false, + internalType: "string", + name: "ATOKENSymbol", + type: "string", + }, + { indexed: false, internalType: "bytes", name: "params", type: "bytes" }, + ], + name: "Initialized", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "caller", + type: "address", + }, + { + indexed: true, + internalType: "address", + name: "onBehalfOf", + type: "address", + }, + { + indexed: false, + internalType: "uint256", + name: "value", + type: "uint256", + }, + { + indexed: false, + internalType: "uint256", + name: "balanceIncrease", + type: "uint256", + }, + { + indexed: false, + internalType: "uint256", + name: "index", + type: "uint256", + }, + ], + name: "Mint", + type: "event", + }, + { + anonymous: false, + inputs: [ + { indexed: true, internalType: "address", name: "from", type: "address" }, + { indexed: true, internalType: "address", name: "to", type: "address" }, + { + indexed: false, + internalType: "uint256", + name: "value", + type: "uint256", + }, + ], + name: "Transfer", + type: "event", + }, + { + inputs: [], + name: "ATOKEN_REVISION", + outputs: [{ internalType: "uint256", name: "", type: "uint256" }], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "DOMAIN_SEPARATOR", + outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "EIP712_REVISION", + outputs: [{ internalType: "bytes", name: "", type: "bytes" }], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "PERMIT_TYPEHASH", + outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "POOL", + outputs: [{ internalType: "contract IPool", name: "", type: "address" }], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "RESERVE_TREASURY_ADDRESS", + outputs: [{ internalType: "address", name: "", type: "address" }], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "UNDERLYING_ASSET_ADDRESS", + outputs: [{ internalType: "address", name: "", type: "address" }], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { internalType: "address", name: "owner", type: "address" }, + { internalType: "address", name: "spender", type: "address" }, + ], + name: "allowance", + outputs: [{ internalType: "uint256", name: "", type: "uint256" }], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { internalType: "address", name: "spender", type: "address" }, + { internalType: "uint256", name: "amount", type: "uint256" }, + ], + name: "approve", + outputs: [{ internalType: "bool", name: "", type: "bool" }], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [{ internalType: "address", name: "user", type: "address" }], + name: "balanceOf", + outputs: [{ internalType: "uint256", name: "", type: "uint256" }], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { internalType: "address", name: "from", type: "address" }, + { + internalType: "address", + name: "receiverOfUnderlying", + type: "address", + }, + { internalType: "uint256", name: "amount", type: "uint256" }, + { internalType: "uint256", name: "index", type: "uint256" }, + ], + name: "burn", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [], + name: "decimals", + outputs: [{ internalType: "uint8", name: "", type: "uint8" }], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { internalType: "address", name: "spender", type: "address" }, + { internalType: "uint256", name: "subtractedValue", type: "uint256" }, + ], + name: "decreaseAllowance", + outputs: [{ internalType: "bool", name: "", type: "bool" }], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [], + name: "getIncentivesController", + outputs: [ + { + internalType: "contract IAaveIncentivesController", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [{ internalType: "address", name: "user", type: "address" }], + name: "getPreviousIndex", + outputs: [{ internalType: "uint256", name: "", type: "uint256" }], + stateMutability: "view", + type: "function", + }, + { + inputs: [{ internalType: "address", name: "user", type: "address" }], + name: "getScaledUserBalanceAndSupply", + outputs: [ + { internalType: "uint256", name: "", type: "uint256" }, + { internalType: "uint256", name: "", type: "uint256" }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { internalType: "address", name: "user", type: "address" }, + { internalType: "address", name: "onBehalfOf", type: "address" }, + { internalType: "uint256", name: "amount", type: "uint256" }, + ], + name: "handleRepayment", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { internalType: "address", name: "spender", type: "address" }, + { internalType: "uint256", name: "addedValue", type: "uint256" }, + ], + name: "increaseAllowance", + outputs: [{ internalType: "bool", name: "", type: "bool" }], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "contract IPool", + name: "initializingPool", + type: "address", + }, + { internalType: "address", name: "treasury", type: "address" }, + { internalType: "address", name: "underlyingAsset", type: "address" }, + { + internalType: "contract IAaveIncentivesController", + name: "incentivesController", + type: "address", + }, + { internalType: "uint8", name: "ATOKENDecimals", type: "uint8" }, + { internalType: "string", name: "ATOKENName", type: "string" }, + { internalType: "string", name: "ATOKENSymbol", type: "string" }, + { internalType: "bytes", name: "params", type: "bytes" }, + ], + name: "initialize", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { internalType: "address", name: "caller", type: "address" }, + { internalType: "address", name: "onBehalfOf", type: "address" }, + { internalType: "uint256", name: "amount", type: "uint256" }, + { internalType: "uint256", name: "index", type: "uint256" }, + ], + name: "mint", + outputs: [{ internalType: "bool", name: "", type: "bool" }], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { internalType: "uint256", name: "amount", type: "uint256" }, + { internalType: "uint256", name: "index", type: "uint256" }, + ], + name: "mintToTreasury", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [], + name: "name", + outputs: [{ internalType: "string", name: "", type: "string" }], + stateMutability: "view", + type: "function", + }, + { + inputs: [{ internalType: "address", name: "owner", type: "address" }], + name: "nonces", + outputs: [{ internalType: "uint256", name: "", type: "uint256" }], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { internalType: "address", name: "owner", type: "address" }, + { internalType: "address", name: "spender", type: "address" }, + { internalType: "uint256", name: "value", type: "uint256" }, + { internalType: "uint256", name: "deadline", type: "uint256" }, + { internalType: "uint8", name: "v", type: "uint8" }, + { internalType: "bytes32", name: "r", type: "bytes32" }, + { internalType: "bytes32", name: "s", type: "bytes32" }, + ], + name: "permit", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { internalType: "address", name: "token", type: "address" }, + { internalType: "address", name: "to", type: "address" }, + { internalType: "uint256", name: "amount", type: "uint256" }, + ], + name: "rescueTokens", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [{ internalType: "address", name: "user", type: "address" }], + name: "scaledBalanceOf", + outputs: [{ internalType: "uint256", name: "", type: "uint256" }], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "scaledTotalSupply", + outputs: [{ internalType: "uint256", name: "", type: "uint256" }], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "contract IAaveIncentivesController", + name: "controller", + type: "address", + }, + ], + name: "setIncentivesController", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [], + name: "symbol", + outputs: [{ internalType: "string", name: "", type: "string" }], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "totalSupply", + outputs: [{ internalType: "uint256", name: "", type: "uint256" }], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { internalType: "address", name: "recipient", type: "address" }, + { internalType: "uint256", name: "amount", type: "uint256" }, + ], + name: "transfer", + outputs: [{ internalType: "bool", name: "", type: "bool" }], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { internalType: "address", name: "sender", type: "address" }, + { internalType: "address", name: "recipient", type: "address" }, + { internalType: "uint256", name: "amount", type: "uint256" }, + ], + name: "transferFrom", + outputs: [{ internalType: "bool", name: "", type: "bool" }], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { internalType: "address", name: "from", type: "address" }, + { internalType: "address", name: "to", type: "address" }, + { internalType: "uint256", name: "value", type: "uint256" }, + ], + name: "transferOnLiquidation", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { internalType: "address", name: "target", type: "address" }, + { internalType: "uint256", name: "amount", type: "uint256" }, + ], + name: "transferUnderlyingTo", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, +]; +exports.UNISWAP_ROUTER_ABI = [ + { + inputs: [ + { + components: [ + { internalType: "address", name: "permit2", type: "address" }, + { internalType: "address", name: "weth9", type: "address" }, + { internalType: "address", name: "seaportV1_5", type: "address" }, + { internalType: "address", name: "seaportV1_4", type: "address" }, + { internalType: "address", name: "openseaConduit", type: "address" }, + { internalType: "address", name: "nftxZap", type: "address" }, + { internalType: "address", name: "x2y2", type: "address" }, + { internalType: "address", name: "foundation", type: "address" }, + { internalType: "address", name: "sudoswap", type: "address" }, + { internalType: "address", name: "elementMarket", type: "address" }, + { internalType: "address", name: "nft20Zap", type: "address" }, + { internalType: "address", name: "cryptopunks", type: "address" }, + { internalType: "address", name: "looksRareV2", type: "address" }, + { + internalType: "address", + name: "routerRewardsDistributor", + type: "address", + }, + { + internalType: "address", + name: "looksRareRewardsDistributor", + type: "address", + }, + { internalType: "address", name: "looksRareToken", type: "address" }, + { internalType: "address", name: "v2Factory", type: "address" }, + { internalType: "address", name: "v3Factory", type: "address" }, + { + internalType: "bytes32", + name: "pairInitCodeHash", + type: "bytes32", + }, + { + internalType: "bytes32", + name: "poolInitCodeHash", + type: "bytes32", + }, + ], + internalType: "struct RouterParameters", + name: "params", + type: "tuple", + }, + ], + stateMutability: "nonpayable", + type: "constructor", + }, + { inputs: [], name: "BalanceTooLow", type: "error" }, + { inputs: [], name: "BuyPunkFailed", type: "error" }, + { inputs: [], name: "ContractLocked", type: "error" }, + { inputs: [], name: "ETHNotAccepted", type: "error" }, + { + inputs: [ + { internalType: "uint256", name: "commandIndex", type: "uint256" }, + { internalType: "bytes", name: "message", type: "bytes" }, + ], + name: "ExecutionFailed", + type: "error", + }, + { inputs: [], name: "FromAddressIsNotOwner", type: "error" }, + { inputs: [], name: "InsufficientETH", type: "error" }, + { inputs: [], name: "InsufficientToken", type: "error" }, + { inputs: [], name: "InvalidBips", type: "error" }, + { + inputs: [{ internalType: "uint256", name: "commandType", type: "uint256" }], + name: "InvalidCommandType", + type: "error", + }, + { inputs: [], name: "InvalidOwnerERC1155", type: "error" }, + { inputs: [], name: "InvalidOwnerERC721", type: "error" }, + { inputs: [], name: "InvalidPath", type: "error" }, + { inputs: [], name: "InvalidReserves", type: "error" }, + { inputs: [], name: "InvalidSpender", type: "error" }, + { inputs: [], name: "LengthMismatch", type: "error" }, + { inputs: [], name: "SliceOutOfBounds", type: "error" }, + { inputs: [], name: "TransactionDeadlinePassed", type: "error" }, + { inputs: [], name: "UnableToClaim", type: "error" }, + { inputs: [], name: "UnsafeCast", type: "error" }, + { inputs: [], name: "V2InvalidPath", type: "error" }, + { inputs: [], name: "V2TooLittleReceived", type: "error" }, + { inputs: [], name: "V2TooMuchRequested", type: "error" }, + { inputs: [], name: "V3InvalidAmountOut", type: "error" }, + { inputs: [], name: "V3InvalidCaller", type: "error" }, + { inputs: [], name: "V3InvalidSwap", type: "error" }, + { inputs: [], name: "V3TooLittleReceived", type: "error" }, + { inputs: [], name: "V3TooMuchRequested", type: "error" }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "uint256", + name: "amount", + type: "uint256", + }, + ], + name: "RewardsSent", + type: "event", + }, + { + inputs: [{ internalType: "bytes", name: "looksRareClaim", type: "bytes" }], + name: "collectRewards", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { internalType: "bytes", name: "commands", type: "bytes" }, + { internalType: "bytes[]", name: "inputs", type: "bytes[]" }, + ], + name: "execute", + outputs: [], + stateMutability: "payable", + type: "function", + }, + { + inputs: [ + { internalType: "bytes", name: "commands", type: "bytes" }, + { internalType: "bytes[]", name: "inputs", type: "bytes[]" }, + { internalType: "uint256", name: "deadline", type: "uint256" }, + ], + name: "execute", + outputs: [], + stateMutability: "payable", + type: "function", + }, + { + inputs: [ + { internalType: "address", name: "", type: "address" }, + { internalType: "address", name: "", type: "address" }, + { internalType: "uint256[]", name: "", type: "uint256[]" }, + { internalType: "uint256[]", name: "", type: "uint256[]" }, + { internalType: "bytes", name: "", type: "bytes" }, + ], + name: "onERC1155BatchReceived", + outputs: [{ internalType: "bytes4", name: "", type: "bytes4" }], + stateMutability: "pure", + type: "function", + }, + { + inputs: [ + { internalType: "address", name: "", type: "address" }, + { internalType: "address", name: "", type: "address" }, + { internalType: "uint256", name: "", type: "uint256" }, + { internalType: "uint256", name: "", type: "uint256" }, + { internalType: "bytes", name: "", type: "bytes" }, + ], + name: "onERC1155Received", + outputs: [{ internalType: "bytes4", name: "", type: "bytes4" }], + stateMutability: "pure", + type: "function", + }, + { + inputs: [ + { internalType: "address", name: "", type: "address" }, + { internalType: "address", name: "", type: "address" }, + { internalType: "uint256", name: "", type: "uint256" }, + { internalType: "bytes", name: "", type: "bytes" }, + ], + name: "onERC721Received", + outputs: [{ internalType: "bytes4", name: "", type: "bytes4" }], + stateMutability: "pure", + type: "function", + }, + { + inputs: [{ internalType: "bytes4", name: "interfaceId", type: "bytes4" }], + name: "supportsInterface", + outputs: [{ internalType: "bool", name: "", type: "bool" }], + stateMutability: "pure", + type: "function", + }, + { + inputs: [ + { internalType: "int256", name: "amount0Delta", type: "int256" }, + { internalType: "int256", name: "amount1Delta", type: "int256" }, + { internalType: "bytes", name: "data", type: "bytes" }, + ], + name: "uniswapV3SwapCallback", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { stateMutability: "payable", type: "receive" }, +]; +exports.ERC20_ABI = [ + { + constant: true, + inputs: [], + name: "name", + outputs: [ + { + name: "", + type: "string", + }, + ], + payable: false, + stateMutability: "view", + type: "function", + }, + { + constant: false, + inputs: [ + { + name: "_spender", + type: "address", + }, + { + name: "_value", + 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: "_from", + type: "address", + }, + { + name: "_to", + type: "address", + }, + { + name: "_value", + type: "uint256", + }, + ], + name: "transferFrom", + outputs: [ + { + name: "", + type: "bool", + }, + ], + 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: "_owner", + type: "address", + }, + ], + name: "balanceOf", + outputs: [ + { + name: "balance", + 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: "_to", + type: "address", + }, + { + name: "_value", + type: "uint256", + }, + ], + name: "transfer", + outputs: [ + { + name: "", + type: "bool", + }, + ], + payable: false, + stateMutability: "nonpayable", + type: "function", + }, + { + constant: true, + inputs: [ + { + name: "_owner", + type: "address", + }, + { + name: "_spender", + 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: "owner", + type: "address", + }, + { + indexed: true, + name: "spender", + type: "address", + }, + { + indexed: false, + name: "value", + type: "uint256", + }, + ], + name: "Approval", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + name: "from", + type: "address", + }, + { + indexed: true, + name: "to", + type: "address", + }, + { + indexed: false, + name: "value", + type: "uint256", + }, + ], + name: "Transfer", + type: "event", + }, +]; +exports.UNI_V3_POOL_ABI = [ + { inputs: [], stateMutability: "nonpayable", type: "constructor" }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "owner", + type: "address", + }, + { + indexed: true, + internalType: "int24", + name: "tickLower", + type: "int24", + }, + { + indexed: true, + internalType: "int24", + name: "tickUpper", + type: "int24", + }, + { + indexed: false, + internalType: "uint128", + name: "amount", + type: "uint128", + }, + { + indexed: false, + internalType: "uint256", + name: "amount0", + type: "uint256", + }, + { + indexed: false, + internalType: "uint256", + name: "amount1", + type: "uint256", + }, + ], + name: "Burn", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "owner", + type: "address", + }, + { + indexed: false, + internalType: "address", + name: "recipient", + type: "address", + }, + { + indexed: true, + internalType: "int24", + name: "tickLower", + type: "int24", + }, + { + indexed: true, + internalType: "int24", + name: "tickUpper", + type: "int24", + }, + { + indexed: false, + internalType: "uint128", + name: "amount0", + type: "uint128", + }, + { + indexed: false, + internalType: "uint128", + name: "amount1", + type: "uint128", + }, + ], + name: "Collect", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "sender", + type: "address", + }, + { + indexed: true, + internalType: "address", + name: "recipient", + type: "address", + }, + { + indexed: false, + internalType: "uint128", + name: "amount0", + type: "uint128", + }, + { + indexed: false, + internalType: "uint128", + name: "amount1", + type: "uint128", + }, + ], + name: "CollectProtocol", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "sender", + type: "address", + }, + { + indexed: true, + internalType: "address", + name: "recipient", + type: "address", + }, + { + indexed: false, + internalType: "uint256", + name: "amount0", + type: "uint256", + }, + { + indexed: false, + internalType: "uint256", + name: "amount1", + type: "uint256", + }, + { + indexed: false, + internalType: "uint256", + name: "paid0", + type: "uint256", + }, + { + indexed: false, + internalType: "uint256", + name: "paid1", + type: "uint256", + }, + ], + name: "Flash", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "uint16", + name: "observationCardinalityNextOld", + type: "uint16", + }, + { + indexed: false, + internalType: "uint16", + name: "observationCardinalityNextNew", + type: "uint16", + }, + ], + name: "IncreaseObservationCardinalityNext", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "uint160", + name: "sqrtPriceX96", + type: "uint160", + }, + { indexed: false, internalType: "int24", name: "tick", type: "int24" }, + ], + name: "Initialize", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "address", + name: "sender", + type: "address", + }, + { + indexed: true, + internalType: "address", + name: "owner", + type: "address", + }, + { + indexed: true, + internalType: "int24", + name: "tickLower", + type: "int24", + }, + { + indexed: true, + internalType: "int24", + name: "tickUpper", + type: "int24", + }, + { + indexed: false, + internalType: "uint128", + name: "amount", + type: "uint128", + }, + { + indexed: false, + internalType: "uint256", + name: "amount0", + type: "uint256", + }, + { + indexed: false, + internalType: "uint256", + name: "amount1", + type: "uint256", + }, + ], + name: "Mint", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "uint8", + name: "feeProtocol0Old", + type: "uint8", + }, + { + indexed: false, + internalType: "uint8", + name: "feeProtocol1Old", + type: "uint8", + }, + { + indexed: false, + internalType: "uint8", + name: "feeProtocol0New", + type: "uint8", + }, + { + indexed: false, + internalType: "uint8", + name: "feeProtocol1New", + type: "uint8", + }, + ], + name: "SetFeeProtocol", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "sender", + type: "address", + }, + { + indexed: true, + internalType: "address", + name: "recipient", + type: "address", + }, + { + indexed: false, + internalType: "int256", + name: "amount0", + type: "int256", + }, + { + indexed: false, + internalType: "int256", + name: "amount1", + type: "int256", + }, + { + indexed: false, + internalType: "uint160", + name: "sqrtPriceX96", + type: "uint160", + }, + { + indexed: false, + internalType: "uint128", + name: "liquidity", + type: "uint128", + }, + { indexed: false, internalType: "int24", name: "tick", type: "int24" }, + ], + name: "Swap", + type: "event", + }, + { + inputs: [ + { internalType: "int24", name: "tickLower", type: "int24" }, + { internalType: "int24", name: "tickUpper", type: "int24" }, + { internalType: "uint128", name: "amount", type: "uint128" }, + ], + name: "burn", + outputs: [ + { internalType: "uint256", name: "amount0", type: "uint256" }, + { internalType: "uint256", name: "amount1", type: "uint256" }, + ], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { internalType: "address", name: "recipient", type: "address" }, + { internalType: "int24", name: "tickLower", type: "int24" }, + { internalType: "int24", name: "tickUpper", type: "int24" }, + { internalType: "uint128", name: "amount0Requested", type: "uint128" }, + { internalType: "uint128", name: "amount1Requested", type: "uint128" }, + ], + name: "collect", + outputs: [ + { internalType: "uint128", name: "amount0", type: "uint128" }, + { internalType: "uint128", name: "amount1", type: "uint128" }, + ], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { internalType: "address", name: "recipient", type: "address" }, + { internalType: "uint128", name: "amount0Requested", type: "uint128" }, + { internalType: "uint128", name: "amount1Requested", type: "uint128" }, + ], + name: "collectProtocol", + outputs: [ + { internalType: "uint128", name: "amount0", type: "uint128" }, + { internalType: "uint128", name: "amount1", type: "uint128" }, + ], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [], + name: "factory", + outputs: [{ internalType: "address", name: "", type: "address" }], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "fee", + outputs: [{ internalType: "uint24", name: "", type: "uint24" }], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "feeGrowthGlobal0X128", + outputs: [{ internalType: "uint256", name: "", type: "uint256" }], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "feeGrowthGlobal1X128", + outputs: [{ internalType: "uint256", name: "", type: "uint256" }], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { internalType: "address", name: "recipient", type: "address" }, + { internalType: "uint256", name: "amount0", type: "uint256" }, + { internalType: "uint256", name: "amount1", type: "uint256" }, + { internalType: "bytes", name: "data", type: "bytes" }, + ], + name: "flash", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "uint16", + name: "observationCardinalityNext", + type: "uint16", + }, + ], + name: "increaseObservationCardinalityNext", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { internalType: "uint160", name: "sqrtPriceX96", type: "uint160" }, + ], + name: "initialize", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [], + name: "liquidity", + outputs: [{ internalType: "uint128", name: "", type: "uint128" }], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "maxLiquidityPerTick", + outputs: [{ internalType: "uint128", name: "", type: "uint128" }], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { internalType: "address", name: "recipient", type: "address" }, + { internalType: "int24", name: "tickLower", type: "int24" }, + { internalType: "int24", name: "tickUpper", type: "int24" }, + { internalType: "uint128", name: "amount", type: "uint128" }, + { internalType: "bytes", name: "data", type: "bytes" }, + ], + name: "mint", + outputs: [ + { internalType: "uint256", name: "amount0", type: "uint256" }, + { internalType: "uint256", name: "amount1", type: "uint256" }, + ], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [{ internalType: "uint256", name: "", type: "uint256" }], + name: "observations", + outputs: [ + { internalType: "uint32", name: "blockTimestamp", type: "uint32" }, + { internalType: "int56", name: "tickCumulative", type: "int56" }, + { + internalType: "uint160", + name: "secondsPerLiquidityCumulativeX128", + type: "uint160", + }, + { internalType: "bool", name: "initialized", type: "bool" }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { internalType: "uint32[]", name: "secondsAgos", type: "uint32[]" }, + ], + name: "observe", + outputs: [ + { internalType: "int56[]", name: "tickCumulatives", type: "int56[]" }, + { + internalType: "uint160[]", + name: "secondsPerLiquidityCumulativeX128s", + type: "uint160[]", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [{ internalType: "bytes32", name: "", type: "bytes32" }], + name: "positions", + outputs: [ + { internalType: "uint128", name: "liquidity", type: "uint128" }, + { + internalType: "uint256", + name: "feeGrowthInside0LastX128", + type: "uint256", + }, + { + internalType: "uint256", + name: "feeGrowthInside1LastX128", + type: "uint256", + }, + { internalType: "uint128", name: "tokensOwed0", type: "uint128" }, + { internalType: "uint128", name: "tokensOwed1", type: "uint128" }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "protocolFees", + outputs: [ + { internalType: "uint128", name: "token0", type: "uint128" }, + { internalType: "uint128", name: "token1", type: "uint128" }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { internalType: "uint8", name: "feeProtocol0", type: "uint8" }, + { internalType: "uint8", name: "feeProtocol1", type: "uint8" }, + ], + name: "setFeeProtocol", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [], + name: "slot0", + outputs: [ + { internalType: "uint160", name: "sqrtPriceX96", type: "uint160" }, + { internalType: "int24", name: "tick", type: "int24" }, + { internalType: "uint16", name: "observationIndex", type: "uint16" }, + { + internalType: "uint16", + name: "observationCardinality", + type: "uint16", + }, + { + internalType: "uint16", + name: "observationCardinalityNext", + type: "uint16", + }, + { internalType: "uint8", name: "feeProtocol", type: "uint8" }, + { internalType: "bool", name: "unlocked", type: "bool" }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { internalType: "int24", name: "tickLower", type: "int24" }, + { internalType: "int24", name: "tickUpper", type: "int24" }, + ], + name: "snapshotCumulativesInside", + outputs: [ + { internalType: "int56", name: "tickCumulativeInside", type: "int56" }, + { + internalType: "uint160", + name: "secondsPerLiquidityInsideX128", + type: "uint160", + }, + { internalType: "uint32", name: "secondsInside", type: "uint32" }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { internalType: "address", name: "recipient", type: "address" }, + { internalType: "bool", name: "zeroForOne", type: "bool" }, + { internalType: "int256", name: "amountSpecified", type: "int256" }, + { internalType: "uint160", name: "sqrtPriceLimitX96", type: "uint160" }, + { internalType: "bytes", name: "data", type: "bytes" }, + ], + name: "swap", + outputs: [ + { internalType: "int256", name: "amount0", type: "int256" }, + { internalType: "int256", name: "amount1", type: "int256" }, + ], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [{ internalType: "int16", name: "", type: "int16" }], + name: "tickBitmap", + outputs: [{ internalType: "uint256", name: "", type: "uint256" }], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "tickSpacing", + outputs: [{ internalType: "int24", name: "", type: "int24" }], + stateMutability: "view", + type: "function", + }, + { + inputs: [{ internalType: "int24", name: "", type: "int24" }], + name: "ticks", + outputs: [ + { internalType: "uint128", name: "liquidityGross", type: "uint128" }, + { internalType: "int128", name: "liquidityNet", type: "int128" }, + { + internalType: "uint256", + name: "feeGrowthOutside0X128", + type: "uint256", + }, + { + internalType: "uint256", + name: "feeGrowthOutside1X128", + type: "uint256", + }, + { internalType: "int56", name: "tickCumulativeOutside", type: "int56" }, + { + internalType: "uint160", + name: "secondsPerLiquidityOutsideX128", + type: "uint160", + }, + { internalType: "uint32", name: "secondsOutside", type: "uint32" }, + { internalType: "bool", name: "initialized", type: "bool" }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "token0", + outputs: [{ internalType: "address", name: "", type: "address" }], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "token1", + outputs: [{ internalType: "address", name: "", type: "address" }], + stateMutability: "view", + type: "function", + }, +]; diff --git a/dist/utils/contracts/uniswap/index.js b/dist/utils/contracts/uniswap/index.js new file mode 100644 index 0000000..ff8d9f3 --- /dev/null +++ b/dist/utils/contracts/uniswap/index.js @@ -0,0 +1,17 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.UNI_V3_POOl = exports.UNISWAP_ROUTER = void 0; +const viem_1 = require("viem"); +const abis_1 = require("../abis"); +const public_1 = require("../../clients/public"); +const constants_1 = require("../../constants"); +exports.UNISWAP_ROUTER = (0, viem_1.getContract)({ + address: constants_1.UNISWAP_ROUTER_ADDR, + abi: abis_1.UNISWAP_ROUTER_ABI, + client: { public: public_1.PUBLIC_CLIENT }, +}); +exports.UNI_V3_POOl = (0, viem_1.getContract)({ + address: constants_1.UNI_V3_POOL_ADDR, + abi: abis_1.UNI_V3_POOL_ABI, + client: { public: public_1.PUBLIC_CLIENT }, +}); diff --git a/dist/utils/contracts/uniswap/params.js b/dist/utils/contracts/uniswap/params.js new file mode 100644 index 0000000..0a1e12f --- /dev/null +++ b/dist/utils/contracts/uniswap/params.js @@ -0,0 +1,84 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.UniswapParams = void 0; +const viem_1 = require("viem"); +const INPUT_ABI = { + warp: [ + { name: "receipt", type: "address" }, + { name: "amount", type: "uint256" }, + ], + swap: [ + { name: "receipt", type: "address" }, + { name: "amount", type: "uint256" }, + { name: "amountMin", type: "uint256" }, + { name: "pathOffset", type: "uint256" }, + { name: "payIsUser", type: "bool" }, + ], + payportion: [ + { name: "token", type: "address" }, + { name: "receipt", type: "address" }, + { name: "bips", type: "uint256" }, + ], + sweep: [ + { name: "token", type: "address" }, + { name: "receipt", type: "address" }, + { name: "amountMin", type: "uint256" }, + ], +}; +class Input { +} +class UniswapParams { + constructor(amountMin, amount) { + this.amountMin = amountMin; + this.amount = amount; + this.command = "0x0b000604"; + this.DAI = "0x50c5725949a6f0c72e6c4a641f24049a917db0cb"; + this.inputs = new Input(); + this.inputs.warp = this.getParams("warp", [this.toReceipt(2), this.amount]); + this.inputs.swap = this.getSwapParams(); + this.inputs.payportion = this.getParams("payportion", [ + this.DAI, + "0x067170777ba8027ced27e034102d54074d062d71", + BigInt(25), + ]); + this.inputs.sweep = this.getParams("sweep", [ + this.DAI, + this.toReceipt(1), + this.amountMin, + ]); + } + formatInputs() { + const formatInputs = []; + formatInputs.push(this.inputs.warp); + formatInputs.push(this.inputs.swap); + formatInputs.push(this.inputs.payportion); + formatInputs.push(this.inputs.sweep); + return formatInputs; + } + getParams(type, value) { + return (0, viem_1.encodeAbiParameters)(INPUT_ABI[type], value); + } + getSwapParams() { + let inputBytes = this.getParams("swap", [ + this.toReceipt(2), + this.amount, + this.amountMin, + BigInt(160), + false, + ]); + const parsePath = this.getPath().join(""); + inputBytes += parsePath; + return inputBytes; + } + getPath() { + return [ + "000000000000000000000000000000000000000000000000000000000000002b", + "42000000000000000000000000000000000000060001f450c5725949a6f0c72e", + "6c4a641f24049a917db0cb000000000000000000000000000000000000000000", + ]; + } + toReceipt(index) { + return (0, viem_1.toHex)(index, { size: 20 }); + } +} +exports.UniswapParams = UniswapParams; diff --git a/dist/utils/uniswap.js b/dist/utils/uniswap.js new file mode 100644 index 0000000..29e773d --- /dev/null +++ b/dist/utils/uniswap.js @@ -0,0 +1,47 @@ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.uniswap = void 0; +const transaction_1 = require("../libs/transaction"); +const params_1 = require("./contracts/uniswap/params"); +const uniswap_1 = require("./contracts/uniswap"); +const public_1 = require("./clients/public"); +function getPrice() { + return __awaiter(this, void 0, void 0, function* () { + const latestBlockNumber = yield public_1.PUBLIC_CLIENT.getBlockNumber(); + const logs = yield uniswap_1.UNI_V3_POOl.getEvents.Swap(undefined, { + fromBlock: latestBlockNumber - BigInt(100), + toBlock: latestBlockNumber, + }); + const { args } = logs[logs.length - 1]; + let { amount0, amount1 } = args; + if (amount0 && amount1) { + if (amount0 < BigInt(1)) + amount0 = amount0 * BigInt(-1); + if (amount1 < BigInt(1)) + amount1 = amount1 * BigInt(-1); + return amount1 / amount0; + } + throw new Error("No price found"); + }); +} +const uniswap = (_signer, amount) => __awaiter(void 0, void 0, void 0, function* () { + const price = yield getPrice(); + const deadline = BigInt(Math.floor(Date.now() / 1000)) + BigInt(60 * 5); + const params = new params_1.UniswapParams(BigInt(price), amount); + const { request } = yield uniswap_1.UNISWAP_ROUTER.simulate.execute([params.command, params.formatInputs(), deadline], { + account: _signer.account, + value: amount, + }); + console.log("Swap..."); + yield (0, transaction_1.sendTransaction)(request, _signer); +}); +exports.uniswap = uniswap; diff --git a/package.json b/package.json index e5c4e4e..c5ec7f7 100644 --- a/package.json +++ b/package.json @@ -1,32 +1,36 @@ { - "name": "base-bot", - "version": "1.0.0", - "description": "", - "main": "index.js", + "name": "airdrop-bot", + "version": "0.0.1", + "description": "This is a simple airdrop bot that can be used to interact onchain protocols", + "main": "dist/index.js", + "bin": { + "airdrop-bot": "./dist/index.js" + }, "scripts": { "bot": "ts-node ./src", - "docker:build": "docker build -t bot .", - "docker:run": "docker run -it -d --name=airdrop-bot bot", - "docker:delete": "docker rm -f airdrop-bot && docker image rm -f bot", - "docker:logs": "docker logs -f airdrop-bot", - "docker:rebuild": "npm run docker:delete && npm run docker:build && npm run docker:run" + "build": "npx tsc" }, - "keywords": [], - "author": "", + "keywords": [ + "cli", + "blockchain", + "bot", + "airdrop" + ], + "author": "LI-YONG-QI", "license": "ISC", "dependencies": { - "@types/commander": "^2.12.2", - "@types/figlet": "^1.5.8", - "@types/node": "^20.12.7", "commander": "^12.0.0", "cron": "^3.1.7", "dotenv": "^16.4.5", "figlet": "^1.7.0", - "ts-node": "^10.9.2", - "typescript": "^5.4.5", "viem": "^2.9.22" }, "devDependencies": { + "@types/commander": "^2.12.2", + "@types/figlet": "^1.5.8", + "@types/node": "^20.12.7", + "ts-node": "^10.9.2", + "typescript": "^5.4.5", "tsconfig-paths": "^4.2.0" } } diff --git a/src/commands/aave.ts b/src/commands/aave.ts index 33c6af0..960db1e 100644 --- a/src/commands/aave.ts +++ b/src/commands/aave.ts @@ -1,8 +1,8 @@ import { parseEther } from "viem"; import { Command } from "commander"; -import { Protocol } from "@/types/protocol"; -import { aave as aaveFn } from "@/utils/aave"; +import { Protocol } from "../types/protocol"; +import { aave as aaveFn } from "../utils/aave"; export const aave = new Command("aave"); diff --git a/src/commands/uniswap.ts b/src/commands/uniswap.ts index 8b013b5..fbb314d 100644 --- a/src/commands/uniswap.ts +++ b/src/commands/uniswap.ts @@ -1,8 +1,8 @@ import { parseEther } from "viem"; import { Command } from "commander"; -import { Protocol } from "@/types/protocol"; -import { uniswap as uniswapFn } from "@/utils/uniswap"; +import { Protocol } from "../types/protocol"; +import { uniswap as uniswapFn } from "../utils/uniswap"; export const uniswap = new Command("uniswap"); diff --git a/src/index.ts b/src/index.ts old mode 100644 new mode 100755 index 3e93dc4..bbbbedf --- a/src/index.ts +++ b/src/index.ts @@ -1,8 +1,10 @@ +#!/usr/bin/env node + import { Command } from "commander"; import { textSync } from "figlet"; -import { aave } from "@/commands/aave"; -import { uniswap } from "@/commands/uniswap"; +import { aave } from "./commands/aave"; +import { uniswap } from "./commands/uniswap"; console.log(textSync("BOT")); diff --git a/src/libs/cron.ts b/src/libs/cron.ts index bc45427..9f844d0 100644 --- a/src/libs/cron.ts +++ b/src/libs/cron.ts @@ -1,4 +1,4 @@ -import { getTime, randomDelay } from "@/libs/time"; +import { getTime, randomDelay } from "./time"; export function createConfig( interaction: () => Promise, diff --git a/src/libs/transaction.ts b/src/libs/transaction.ts index 54e2793..90f2d75 100644 --- a/src/libs/transaction.ts +++ b/src/libs/transaction.ts @@ -1,4 +1,4 @@ -import { PUBLIC_CLIENT } from "@/utils/clients/public"; +import { PUBLIC_CLIENT } from "../utils/clients/public"; import { WalletClient } from "viem"; export async function sendTransaction(request: any, signer: WalletClient) { diff --git a/src/types/protocol.ts b/src/types/protocol.ts index 67fcba1..9535870 100644 --- a/src/types/protocol.ts +++ b/src/types/protocol.ts @@ -9,8 +9,8 @@ import { } from "viem"; import { privateKeyToAccount } from "viem/accounts"; -import { createConfig } from "@/libs/cron"; -import { CONFIG } from "@/utils/clients/config"; +import { createConfig } from "../libs/cron"; +import { CONFIG } from "../utils/clients/config"; export type Interaction = ( _signer: WalletClient, diff --git a/src/utils/aave.ts b/src/utils/aave.ts index bef7c1f..f68cf90 100644 --- a/src/utils/aave.ts +++ b/src/utils/aave.ts @@ -6,9 +6,9 @@ import { Chain, } from "viem"; -import { sendTransaction } from "@/libs/transaction"; -import { AAVE, WETH } from "@/utils/contracts/aave"; -import { Interaction } from "@/types/protocol"; +import { sendTransaction } from "../libs/transaction"; +import { AAVE, WETH } from "./contracts/aave"; +import { Interaction } from "../types/protocol"; async function deposit( signer: WalletClient, diff --git a/src/utils/clients/public.ts b/src/utils/clients/public.ts index 527cdf6..1800f02 100644 --- a/src/utils/clients/public.ts +++ b/src/utils/clients/public.ts @@ -1,4 +1,4 @@ import { createPublicClient } from "viem"; -import { CONFIG } from "@/utils/clients/config"; +import { CONFIG } from "./config"; export const PUBLIC_CLIENT = createPublicClient(CONFIG); diff --git a/src/utils/contracts/aave.ts b/src/utils/contracts/aave.ts index c641586..e849253 100644 --- a/src/utils/contracts/aave.ts +++ b/src/utils/contracts/aave.ts @@ -1,8 +1,8 @@ import { getContract } from "viem"; -import { AAVE_ABI, WETH_ABI } from "@/utils/contracts/abis"; -import { PUBLIC_CLIENT } from "@/utils/clients/public"; -import { AAVE_ADDR, WETH_ADDR } from "@/utils/constants"; +import { AAVE_ABI, WETH_ABI } from "./abis"; +import { PUBLIC_CLIENT } from "../clients/public"; +import { AAVE_ADDR, WETH_ADDR } from "../constants"; export const AAVE = getContract({ address: AAVE_ADDR, diff --git a/src/utils/contracts/uniswap/index.ts b/src/utils/contracts/uniswap/index.ts index 17bc36c..a65c018 100644 --- a/src/utils/contracts/uniswap/index.ts +++ b/src/utils/contracts/uniswap/index.ts @@ -1,8 +1,8 @@ import { Address, getContract } from "viem"; -import { UNISWAP_ROUTER_ABI, UNI_V3_POOL_ABI } from "@/utils/contracts/abis"; -import { PUBLIC_CLIENT } from "@/utils/clients/public"; -import { UNISWAP_ROUTER_ADDR, UNI_V3_POOL_ADDR } from "@/utils/constants"; +import { UNISWAP_ROUTER_ABI, UNI_V3_POOL_ABI } from "../abis"; +import { PUBLIC_CLIENT } from "../../clients/public"; +import { UNISWAP_ROUTER_ADDR, UNI_V3_POOL_ADDR } from "../../constants"; export const UNISWAP_ROUTER = getContract({ address: UNISWAP_ROUTER_ADDR as Address, diff --git a/src/utils/contracts/uniswap/params.ts b/src/utils/contracts/uniswap/params.ts index ee25554..b6eb4c4 100644 --- a/src/utils/contracts/uniswap/params.ts +++ b/src/utils/contracts/uniswap/params.ts @@ -50,7 +50,7 @@ export class UniswapParams { this.inputs.payportion = this.getParams("payportion", [ this.DAI, "0x067170777ba8027ced27e034102d54074d062d71", - 25n, + BigInt(25), ]); this.inputs.sweep = this.getParams("sweep", [ @@ -80,7 +80,7 @@ export class UniswapParams { this.toReceipt(2), this.amount, this.amountMin, - 160n, + BigInt(160), false, ]); diff --git a/src/utils/uniswap.ts b/src/utils/uniswap.ts index 14ced72..6ba7cf1 100644 --- a/src/utils/uniswap.ts +++ b/src/utils/uniswap.ts @@ -1,8 +1,8 @@ -import { sendTransaction } from "@/libs/transaction"; -import { UniswapParams } from "@/utils/contracts/uniswap/params"; -import { UNISWAP_ROUTER, UNI_V3_POOl } from "@/utils/contracts/uniswap"; -import { PUBLIC_CLIENT } from "@/utils/clients/public"; -import { Interaction } from "@/types/protocol"; +import { sendTransaction } from "../libs/transaction"; +import { UniswapParams } from "./contracts/uniswap/params"; +import { UNISWAP_ROUTER, UNI_V3_POOl } from "./contracts/uniswap"; +import { PUBLIC_CLIENT } from "./clients/public"; +import { Interaction } from "../types/protocol"; async function getPrice() { const latestBlockNumber = await PUBLIC_CLIENT.getBlockNumber(); @@ -29,7 +29,7 @@ async function getPrice() { export const uniswap: Interaction = async (_signer, amount) => { const price = await getPrice(); const deadline = BigInt(Math.floor(Date.now() / 1000)) + BigInt(60 * 5); - const params = new UniswapParams(price, amount); + const params = new UniswapParams(BigInt(price), amount); const { request } = await UNISWAP_ROUTER.simulate.execute( [params.command, params.formatInputs(), deadline], diff --git a/tsconfig.json b/tsconfig.json index ebcc759..a5ad14a 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -11,7 +11,7 @@ // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ /* Language and Environment */ - "target": "es2020" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */, + "target": "es6" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */, // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ // "jsx": "preserve", /* Specify what JSX code is generated. */ // "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */ @@ -28,10 +28,7 @@ "module": "commonjs" /* Specify what module code is generated. */, // "rootDir": "./", /* Specify the root folder within your source files. */ // "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */ - "baseUrl": "./" /* Specify the base directory to resolve non-relative module names. */, - "paths": { - "@/*": ["src/*"] - } /* Specify a set of entries that re-map imports to additional lookup locations. */, + /* Specify a set of entries that re-map imports to additional lookup locations. */ // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */ // "types": [], /* Specify type package names to be included without being referenced in a source file. */ @@ -57,7 +54,7 @@ // "sourceMap": true, /* Create source map files for emitted JavaScript files. */ // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */ - // "outDir": "./", /* Specify an output folder for all emitted files. */ + "outDir": "dist" /* Specify an output folder for all emitted files. */, // "removeComments": true, /* Disable emitting comments. */ // "noEmit": true, /* Disable emitting files from a compilation. */ // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ @@ -107,10 +104,5 @@ /* Completeness */ // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ "skipLibCheck": true /* Skip type checking all .d.ts files. */ - }, - - "ts-node": { - // Do not forget to `npm i -D tsconfig-paths` - "require": ["tsconfig-paths/register"] } }