diff --git a/.changeset/serious-snails-drive.md b/.changeset/serious-snails-drive.md new file mode 100644 index 00000000..f9c6a975 --- /dev/null +++ b/.changeset/serious-snails-drive.md @@ -0,0 +1,5 @@ +--- +'@protocolink/logics': minor +--- + +add Magic Sea on IOTA diff --git a/.env.iota.pb b/.env.iota.pb new file mode 100644 index 00000000..19039ea5 --- /dev/null +++ b/.env.iota.pb @@ -0,0 +1,3 @@ +CHAIN_ID=8822 +BLOCK_NUMBER=292100 +HTTP_RPC_URL=https://json-rpc.evm.iotaledger.net diff --git a/.github/workflows/e2e-test-iota-pb.yml b/.github/workflows/e2e-test-iota-pb.yml new file mode 100644 index 00000000..c9d8858e --- /dev/null +++ b/.github/workflows/e2e-test-iota-pb.yml @@ -0,0 +1,24 @@ +name: E2E Iota Pinned Block + +on: + push: + pull_request: + +jobs: + run-e2e-test: + name: iota pb + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version: 16 + + - name: Install dependencies + run: yarn install + + - name: Run e2e test + run: yarn test:e2e:iota:pb diff --git a/package.json b/package.json index 36043151..14fabd24 100644 --- a/package.json +++ b/package.json @@ -24,15 +24,17 @@ "test:e2e:mainnet": "env-cmd -f .env.mainnet hardhat test --grep 'mainnet:'", "test:e2e:mainnet:pb": "env-cmd -f .env.mainnet.pb hardhat test --grep 'mainnet-pb:'", "test:e2e:optimism:pb": "env-cmd -f .env.optimism.pb hardhat test --grep 'optimism-pb:'", + "test:e2e:iota:pb": "env-cmd -f .env.iota.pb hardhat test --grep 'iota-pb:'", "test:e2e:metis": "env-cmd -f .env.metis hardhat test --grep 'metis:'", "test:unit": "mocha --recursive src" }, "dependencies": { "@paraswap/sdk": "^6.6.0", - "@protocolink/common": "^0.3.11", - "@protocolink/core": "^0.4.13", + "@protocolink/common": "^0.4.1", + "@protocolink/core": "^0.5.0", "@protocolink/smart-accounts": "^0.1.3", "@types/lodash": "^4.14.195", + "@uniswap/sdk": "^3.0.3", "@uniswap/sdk-core": "^3.2.6", "@uniswap/token-lists": "^1.0.0-beta.31", "@uniswap/v3-sdk": "^3.9.0", @@ -48,7 +50,7 @@ "@nomicfoundation/hardhat-chai-matchers": "^1.0.6", "@nomicfoundation/hardhat-network-helpers": "^1.0.8", "@nomiclabs/hardhat-ethers": "^2.2.3", - "@protocolink/test-helpers": "^0.3.8", + "@protocolink/test-helpers": "^0.4.0", "@typechain/ethers-v5": "^11.0.0", "@types/chai": "^4.3.5", "@types/fs-extra": "^11.0.1", diff --git a/src/logics/index.ts b/src/logics/index.ts index 0d32d08c..b7ec934a 100644 --- a/src/logics/index.ts +++ b/src/logics/index.ts @@ -3,6 +3,7 @@ export * as aavev3 from './aave-v3'; export * as balancerv2 from './balancer-v2'; export * as compoundv2 from './compound-v2'; export * as compoundv3 from './compound-v3'; +export * as magicsea from './magicsea'; export * as morphoblue from './morphoblue'; export * as openoceanv2 from './openocean-v2'; export * as paraswapv5 from './paraswap-v5'; diff --git a/src/logics/magicsea/abis/MagicSeaFactory.json b/src/logics/magicsea/abis/MagicSeaFactory.json new file mode 100644 index 00000000..c257c01a --- /dev/null +++ b/src/logics/magicsea/abis/MagicSeaFactory.json @@ -0,0 +1,241 @@ +[ + { + "inputs": [ + { + "internalType": "address", + "name": "_feeToSetter", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "token0", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "token1", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "pair", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "PairCreated", + "type": "event" + }, + { + "inputs": [], + "name": "FEE_DENOMINATOR", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "INIT_CODE_PAIR_HASH", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "OWNER_FEE_SHARE_MAX", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "allPairs", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "allPairsLength", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "tokenA", + "type": "address" + }, + { + "internalType": "address", + "name": "tokenB", + "type": "address" + } + ], + "name": "createPair", + "outputs": [ + { + "internalType": "address", + "name": "pair", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "feeTo", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "feeToSetter", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "getPair", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "ownerFeeShare", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_feeTo", + "type": "address" + } + ], + "name": "setFeeTo", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_feeToSetter", + "type": "address" + } + ], + "name": "setFeeToSetter", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "newOwnerFeeShare", + "type": "uint256" + } + ], + "name": "setOwnerFeeShare", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } +] diff --git a/src/logics/magicsea/abis/MagicSeaPair.json b/src/logics/magicsea/abis/MagicSeaPair.json new file mode 100644 index 00000000..7d573c3d --- /dev/null +++ b/src/logics/magicsea/abis/MagicSeaPair.json @@ -0,0 +1,755 @@ +[ + { + "inputs": [], + "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": "sender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount0", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount1", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + } + ], + "name": "Burn", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "prevFeeAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "feeAmount", + "type": "uint256" + } + ], + "name": "FeeAmountUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount0", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount1", + "type": "uint256" + } + ], + "name": "Mint", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount0In", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount1In", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount0Out", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount1Out", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + } + ], + "name": "Swap", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint112", + "name": "reserve0", + "type": "uint112" + }, + { + "indexed": false, + "internalType": "uint112", + "name": "reserve1", + "type": "uint112" + } + ], + "name": "Sync", + "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": "FEE_DENOMINATOR", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MAX_FEE_AMOUNT", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MINIMUM_LIQUIDITY", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MIN_FEE_AMOUNT", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "PERMIT_TYPEHASH", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "PRECISION_FACTOR", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "allowance", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "approve", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "to", + "type": "address" + } + ], + "name": "burn", + "outputs": [ + { + "internalType": "uint256", + "name": "amount0", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amount1", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "decimals", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "domainSeparator", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "factory", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "feeAmount", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getReserves", + "outputs": [ + { + "internalType": "uint112", + "name": "_reserve0", + "type": "uint112" + }, + { + "internalType": "uint112", + "name": "_reserve1", + "type": "uint112" + }, + { + "internalType": "uint32", + "name": "_blockTimestampLast", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_token0", + "type": "address" + }, + { + "internalType": "address", + "name": "_token1", + "type": "address" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "kLast", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "to", + "type": "address" + } + ], + "name": "mint", + "outputs": [ + { + "internalType": "uint256", + "name": "liquidity", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "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": [], + "name": "price0CumulativeLast", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "price1CumulativeLast", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "newFeeAmount", + "type": "uint256" + } + ], + "name": "setFeeAmount", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "to", + "type": "address" + } + ], + "name": "skim", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amount0Out", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amount1Out", + "type": "uint256" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "swap", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "symbol", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "sync", + "outputs": [], + "stateMutability": "nonpayable", + "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" + }, + { + "inputs": [], + "name": "totalSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "transfer", + "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": "transferFrom", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + } +] diff --git a/src/logics/magicsea/abis/MagicSeaRouter.json b/src/logics/magicsea/abis/MagicSeaRouter.json new file mode 100644 index 00000000..be865152 --- /dev/null +++ b/src/logics/magicsea/abis/MagicSeaRouter.json @@ -0,0 +1,983 @@ +[ + { + "inputs": [ + { + "internalType": "address", + "name": "_factory", + "type": "address" + }, + { + "internalType": "address", + "name": "_WETH", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [], + "name": "WETH", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "tokenA", + "type": "address" + }, + { + "internalType": "address", + "name": "tokenB", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amountADesired", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amountBDesired", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amountAMin", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amountBMin", + "type": "uint256" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + } + ], + "name": "addLiquidity", + "outputs": [ + { + "internalType": "uint256", + "name": "amountA", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amountB", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "liquidity", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amountTokenDesired", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amountTokenMin", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amountETHMin", + "type": "uint256" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + } + ], + "name": "addLiquidityETH", + "outputs": [ + { + "internalType": "uint256", + "name": "amountToken", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amountETH", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "liquidity", + "type": "uint256" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "factory", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amountOut", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "reserveIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "reserveOut", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "feeAmount", + "type": "uint256" + } + ], + "name": "getAmountIn", + "outputs": [ + { + "internalType": "uint256", + "name": "amountIn", + "type": "uint256" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amountIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "reserveIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "reserveOut", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "feeAmount", + "type": "uint256" + } + ], + "name": "getAmountOut", + "outputs": [ + { + "internalType": "uint256", + "name": "amountOut", + "type": "uint256" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amountOut", + "type": "uint256" + }, + { + "internalType": "address[]", + "name": "path", + "type": "address[]" + } + ], + "name": "getAmountsIn", + "outputs": [ + { + "internalType": "uint256[]", + "name": "amounts", + "type": "uint256[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amountIn", + "type": "uint256" + }, + { + "internalType": "address[]", + "name": "path", + "type": "address[]" + } + ], + "name": "getAmountsOut", + "outputs": [ + { + "internalType": "uint256[]", + "name": "amounts", + "type": "uint256[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amountA", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "reserveA", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "reserveB", + "type": "uint256" + } + ], + "name": "quote", + "outputs": [ + { + "internalType": "uint256", + "name": "amountB", + "type": "uint256" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "tokenA", + "type": "address" + }, + { + "internalType": "address", + "name": "tokenB", + "type": "address" + }, + { + "internalType": "uint256", + "name": "liquidity", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amountAMin", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amountBMin", + "type": "uint256" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + } + ], + "name": "removeLiquidity", + "outputs": [ + { + "internalType": "uint256", + "name": "amountA", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amountB", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "liquidity", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amountTokenMin", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amountETHMin", + "type": "uint256" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + } + ], + "name": "removeLiquidityETH", + "outputs": [ + { + "internalType": "uint256", + "name": "amountToken", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amountETH", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "liquidity", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amountTokenMin", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amountETHMin", + "type": "uint256" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + } + ], + "name": "removeLiquidityETHSupportingFeeOnTransferTokens", + "outputs": [ + { + "internalType": "uint256", + "name": "amountETH", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "liquidity", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amountTokenMin", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amountETHMin", + "type": "uint256" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "approveMax", + "type": "bool" + }, + { + "internalType": "uint8", + "name": "v", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "r", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "s", + "type": "bytes32" + } + ], + "name": "removeLiquidityETHWithPermit", + "outputs": [ + { + "internalType": "uint256", + "name": "amountToken", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amountETH", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "liquidity", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amountTokenMin", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amountETHMin", + "type": "uint256" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "approveMax", + "type": "bool" + }, + { + "internalType": "uint8", + "name": "v", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "r", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "s", + "type": "bytes32" + } + ], + "name": "removeLiquidityETHWithPermitSupportingFeeOnTransferTokens", + "outputs": [ + { + "internalType": "uint256", + "name": "amountETH", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "tokenA", + "type": "address" + }, + { + "internalType": "address", + "name": "tokenB", + "type": "address" + }, + { + "internalType": "uint256", + "name": "liquidity", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amountAMin", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amountBMin", + "type": "uint256" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "approveMax", + "type": "bool" + }, + { + "internalType": "uint8", + "name": "v", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "r", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "s", + "type": "bytes32" + } + ], + "name": "removeLiquidityWithPermit", + "outputs": [ + { + "internalType": "uint256", + "name": "amountA", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amountB", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amountOut", + "type": "uint256" + }, + { + "internalType": "address[]", + "name": "path", + "type": "address[]" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + } + ], + "name": "swapETHForExactTokens", + "outputs": [ + { + "internalType": "uint256[]", + "name": "amounts", + "type": "uint256[]" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amountOutMin", + "type": "uint256" + }, + { + "internalType": "address[]", + "name": "path", + "type": "address[]" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + } + ], + "name": "swapExactETHForTokens", + "outputs": [ + { + "internalType": "uint256[]", + "name": "amounts", + "type": "uint256[]" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amountOutMin", + "type": "uint256" + }, + { + "internalType": "address[]", + "name": "path", + "type": "address[]" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + } + ], + "name": "swapExactETHForTokensSupportingFeeOnTransferTokens", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amountIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amountOutMin", + "type": "uint256" + }, + { + "internalType": "address[]", + "name": "path", + "type": "address[]" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + } + ], + "name": "swapExactTokensForETH", + "outputs": [ + { + "internalType": "uint256[]", + "name": "amounts", + "type": "uint256[]" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amountIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amountOutMin", + "type": "uint256" + }, + { + "internalType": "address[]", + "name": "path", + "type": "address[]" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + } + ], + "name": "swapExactTokensForETHSupportingFeeOnTransferTokens", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amountIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amountOutMin", + "type": "uint256" + }, + { + "internalType": "address[]", + "name": "path", + "type": "address[]" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + } + ], + "name": "swapExactTokensForTokens", + "outputs": [ + { + "internalType": "uint256[]", + "name": "amounts", + "type": "uint256[]" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amountIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amountOutMin", + "type": "uint256" + }, + { + "internalType": "address[]", + "name": "path", + "type": "address[]" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + } + ], + "name": "swapExactTokensForTokensSupportingFeeOnTransferTokens", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amountOut", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amountInMax", + "type": "uint256" + }, + { + "internalType": "address[]", + "name": "path", + "type": "address[]" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + } + ], + "name": "swapTokensForExactETH", + "outputs": [ + { + "internalType": "uint256[]", + "name": "amounts", + "type": "uint256[]" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amountOut", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amountInMax", + "type": "uint256" + }, + { + "internalType": "address[]", + "name": "path", + "type": "address[]" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + } + ], + "name": "swapTokensForExactTokens", + "outputs": [ + { + "internalType": "uint256[]", + "name": "amounts", + "type": "uint256[]" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + } +] diff --git a/src/logics/magicsea/configs.ts b/src/logics/magicsea/configs.ts new file mode 100644 index 00000000..bb3143b9 --- /dev/null +++ b/src/logics/magicsea/configs.ts @@ -0,0 +1,47 @@ +import * as common from '@protocolink/common'; +import { iotaTokens } from './tokens'; + +type ContractNames = 'Factory' | 'Router'; + +export interface Config { + chainId: number; + contract: Record; + tokenListUrls: string[]; + bases: common.Token[]; +} + +export const configs: Config[] = [ + { + chainId: common.ChainId.iota, + contract: { + Factory: '0x349aaAc3a500014981CBA11b64C76c66a6c1e8D0', + Router: '0x531777F8c35fDe8DA9baB6cC7093A7D14a99D73E', + }, + tokenListUrls: [ + 'https://raw.githubusercontent.com/MagicSea-Finance/tokenlist/main/token.default.json', + 'https://raw.githubusercontent.com/moonpadxyz/tokenlist/main/token.default.json', + ], + bases: [common.iotaTokens.wIOTA, iotaTokens['USDC.e'], iotaTokens.USDT], + }, +]; + +export const [supportedChainIds, configMap] = configs.reduce( + (accumulator, config) => { + accumulator[0].push(config.chainId); + accumulator[1][config.chainId] = config; + return accumulator; + }, + [[], {}] as [number[], Record] +); + +export function getContractAddress(chainId: number, name: ContractNames) { + return configMap[chainId].contract[name]; +} + +export function getTokenListUrls(chainId: number) { + return configMap[chainId].tokenListUrls; +} + +export function getBaseTokens(chainId: number) { + return configMap[chainId].bases; +} diff --git a/src/logics/magicsea/contracts/MagicSeaFactory.ts b/src/logics/magicsea/contracts/MagicSeaFactory.ts new file mode 100644 index 00000000..69108c6a --- /dev/null +++ b/src/logics/magicsea/contracts/MagicSeaFactory.ts @@ -0,0 +1,281 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +import type { + BaseContract, + BigNumber, + BigNumberish, + BytesLike, + CallOverrides, + ContractTransaction, + Overrides, + PopulatedTransaction, + Signer, + utils, +} from 'ethers'; +import type { FunctionFragment, Result, EventFragment } from '@ethersproject/abi'; +import type { Listener, Provider } from '@ethersproject/providers'; +import type { TypedEventFilter, TypedEvent, TypedListener, OnEvent } from './common'; + +export interface MagicSeaFactoryInterface extends utils.Interface { + functions: { + 'FEE_DENOMINATOR()': FunctionFragment; + 'INIT_CODE_PAIR_HASH()': FunctionFragment; + 'OWNER_FEE_SHARE_MAX()': FunctionFragment; + 'allPairs(uint256)': FunctionFragment; + 'allPairsLength()': FunctionFragment; + 'createPair(address,address)': FunctionFragment; + 'feeTo()': FunctionFragment; + 'feeToSetter()': FunctionFragment; + 'getPair(address,address)': FunctionFragment; + 'ownerFeeShare()': FunctionFragment; + 'setFeeTo(address)': FunctionFragment; + 'setFeeToSetter(address)': FunctionFragment; + 'setOwnerFeeShare(uint256)': FunctionFragment; + }; + + getFunction( + nameOrSignatureOrTopic: + | 'FEE_DENOMINATOR' + | 'INIT_CODE_PAIR_HASH' + | 'OWNER_FEE_SHARE_MAX' + | 'allPairs' + | 'allPairsLength' + | 'createPair' + | 'feeTo' + | 'feeToSetter' + | 'getPair' + | 'ownerFeeShare' + | 'setFeeTo' + | 'setFeeToSetter' + | 'setOwnerFeeShare' + ): FunctionFragment; + + encodeFunctionData(functionFragment: 'FEE_DENOMINATOR', values?: undefined): string; + encodeFunctionData(functionFragment: 'INIT_CODE_PAIR_HASH', values?: undefined): string; + encodeFunctionData(functionFragment: 'OWNER_FEE_SHARE_MAX', values?: undefined): string; + encodeFunctionData(functionFragment: 'allPairs', values: [BigNumberish]): string; + encodeFunctionData(functionFragment: 'allPairsLength', values?: undefined): string; + encodeFunctionData(functionFragment: 'createPair', values: [string, string]): string; + encodeFunctionData(functionFragment: 'feeTo', values?: undefined): string; + encodeFunctionData(functionFragment: 'feeToSetter', values?: undefined): string; + encodeFunctionData(functionFragment: 'getPair', values: [string, string]): string; + encodeFunctionData(functionFragment: 'ownerFeeShare', values?: undefined): string; + encodeFunctionData(functionFragment: 'setFeeTo', values: [string]): string; + encodeFunctionData(functionFragment: 'setFeeToSetter', values: [string]): string; + encodeFunctionData(functionFragment: 'setOwnerFeeShare', values: [BigNumberish]): string; + + decodeFunctionResult(functionFragment: 'FEE_DENOMINATOR', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'INIT_CODE_PAIR_HASH', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'OWNER_FEE_SHARE_MAX', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'allPairs', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'allPairsLength', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'createPair', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'feeTo', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'feeToSetter', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'getPair', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'ownerFeeShare', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'setFeeTo', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'setFeeToSetter', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'setOwnerFeeShare', data: BytesLike): Result; + + events: { + 'PairCreated(address,address,address,uint256)': EventFragment; + }; + + getEvent(nameOrSignatureOrTopic: 'PairCreated'): EventFragment; +} + +export interface PairCreatedEventObject { + token0: string; + token1: string; + pair: string; + arg3: BigNumber; +} +export type PairCreatedEvent = TypedEvent<[string, string, string, BigNumber], PairCreatedEventObject>; + +export type PairCreatedEventFilter = TypedEventFilter; + +export interface MagicSeaFactory extends BaseContract { + connect(signerOrProvider: Signer | Provider | string): this; + attach(addressOrName: string): this; + deployed(): Promise; + + interface: MagicSeaFactoryInterface; + + queryFilter( + event: TypedEventFilter, + fromBlockOrBlockhash?: string | number | undefined, + toBlock?: string | number | undefined + ): Promise>; + + listeners(eventFilter?: TypedEventFilter): Array>; + listeners(eventName?: string): Array; + removeAllListeners(eventFilter: TypedEventFilter): this; + removeAllListeners(eventName?: string): this; + off: OnEvent; + on: OnEvent; + once: OnEvent; + removeListener: OnEvent; + + functions: { + FEE_DENOMINATOR(overrides?: CallOverrides): Promise<[BigNumber]>; + + INIT_CODE_PAIR_HASH(overrides?: CallOverrides): Promise<[string]>; + + OWNER_FEE_SHARE_MAX(overrides?: CallOverrides): Promise<[BigNumber]>; + + allPairs(arg0: BigNumberish, overrides?: CallOverrides): Promise<[string]>; + + allPairsLength(overrides?: CallOverrides): Promise<[BigNumber]>; + + createPair(tokenA: string, tokenB: string, overrides?: Overrides & { from?: string }): Promise; + + feeTo(overrides?: CallOverrides): Promise<[string]>; + + feeToSetter(overrides?: CallOverrides): Promise<[string]>; + + getPair(arg0: string, arg1: string, overrides?: CallOverrides): Promise<[string]>; + + ownerFeeShare(overrides?: CallOverrides): Promise<[BigNumber]>; + + setFeeTo(_feeTo: string, overrides?: Overrides & { from?: string }): Promise; + + setFeeToSetter(_feeToSetter: string, overrides?: Overrides & { from?: string }): Promise; + + setOwnerFeeShare( + newOwnerFeeShare: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + }; + + FEE_DENOMINATOR(overrides?: CallOverrides): Promise; + + INIT_CODE_PAIR_HASH(overrides?: CallOverrides): Promise; + + OWNER_FEE_SHARE_MAX(overrides?: CallOverrides): Promise; + + allPairs(arg0: BigNumberish, overrides?: CallOverrides): Promise; + + allPairsLength(overrides?: CallOverrides): Promise; + + createPair(tokenA: string, tokenB: string, overrides?: Overrides & { from?: string }): Promise; + + feeTo(overrides?: CallOverrides): Promise; + + feeToSetter(overrides?: CallOverrides): Promise; + + getPair(arg0: string, arg1: string, overrides?: CallOverrides): Promise; + + ownerFeeShare(overrides?: CallOverrides): Promise; + + setFeeTo(_feeTo: string, overrides?: Overrides & { from?: string }): Promise; + + setFeeToSetter(_feeToSetter: string, overrides?: Overrides & { from?: string }): Promise; + + setOwnerFeeShare( + newOwnerFeeShare: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + callStatic: { + FEE_DENOMINATOR(overrides?: CallOverrides): Promise; + + INIT_CODE_PAIR_HASH(overrides?: CallOverrides): Promise; + + OWNER_FEE_SHARE_MAX(overrides?: CallOverrides): Promise; + + allPairs(arg0: BigNumberish, overrides?: CallOverrides): Promise; + + allPairsLength(overrides?: CallOverrides): Promise; + + createPair(tokenA: string, tokenB: string, overrides?: CallOverrides): Promise; + + feeTo(overrides?: CallOverrides): Promise; + + feeToSetter(overrides?: CallOverrides): Promise; + + getPair(arg0: string, arg1: string, overrides?: CallOverrides): Promise; + + ownerFeeShare(overrides?: CallOverrides): Promise; + + setFeeTo(_feeTo: string, overrides?: CallOverrides): Promise; + + setFeeToSetter(_feeToSetter: string, overrides?: CallOverrides): Promise; + + setOwnerFeeShare(newOwnerFeeShare: BigNumberish, overrides?: CallOverrides): Promise; + }; + + filters: { + 'PairCreated(address,address,address,uint256)'( + token0?: string | null, + token1?: string | null, + pair?: null, + arg3?: null + ): PairCreatedEventFilter; + PairCreated(token0?: string | null, token1?: string | null, pair?: null, arg3?: null): PairCreatedEventFilter; + }; + + estimateGas: { + FEE_DENOMINATOR(overrides?: CallOverrides): Promise; + + INIT_CODE_PAIR_HASH(overrides?: CallOverrides): Promise; + + OWNER_FEE_SHARE_MAX(overrides?: CallOverrides): Promise; + + allPairs(arg0: BigNumberish, overrides?: CallOverrides): Promise; + + allPairsLength(overrides?: CallOverrides): Promise; + + createPair(tokenA: string, tokenB: string, overrides?: Overrides & { from?: string }): Promise; + + feeTo(overrides?: CallOverrides): Promise; + + feeToSetter(overrides?: CallOverrides): Promise; + + getPair(arg0: string, arg1: string, overrides?: CallOverrides): Promise; + + ownerFeeShare(overrides?: CallOverrides): Promise; + + setFeeTo(_feeTo: string, overrides?: Overrides & { from?: string }): Promise; + + setFeeToSetter(_feeToSetter: string, overrides?: Overrides & { from?: string }): Promise; + + setOwnerFeeShare(newOwnerFeeShare: BigNumberish, overrides?: Overrides & { from?: string }): Promise; + }; + + populateTransaction: { + FEE_DENOMINATOR(overrides?: CallOverrides): Promise; + + INIT_CODE_PAIR_HASH(overrides?: CallOverrides): Promise; + + OWNER_FEE_SHARE_MAX(overrides?: CallOverrides): Promise; + + allPairs(arg0: BigNumberish, overrides?: CallOverrides): Promise; + + allPairsLength(overrides?: CallOverrides): Promise; + + createPair( + tokenA: string, + tokenB: string, + overrides?: Overrides & { from?: string } + ): Promise; + + feeTo(overrides?: CallOverrides): Promise; + + feeToSetter(overrides?: CallOverrides): Promise; + + getPair(arg0: string, arg1: string, overrides?: CallOverrides): Promise; + + ownerFeeShare(overrides?: CallOverrides): Promise; + + setFeeTo(_feeTo: string, overrides?: Overrides & { from?: string }): Promise; + + setFeeToSetter(_feeToSetter: string, overrides?: Overrides & { from?: string }): Promise; + + setOwnerFeeShare( + newOwnerFeeShare: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + }; +} diff --git a/src/logics/magicsea/contracts/MagicSeaPair.ts b/src/logics/magicsea/contracts/MagicSeaPair.ts new file mode 100644 index 00000000..8369fa04 --- /dev/null +++ b/src/logics/magicsea/contracts/MagicSeaPair.ts @@ -0,0 +1,790 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +import type { + BaseContract, + BigNumber, + BigNumberish, + BytesLike, + CallOverrides, + ContractTransaction, + Overrides, + PopulatedTransaction, + Signer, + utils, +} from 'ethers'; +import type { FunctionFragment, Result, EventFragment } from '@ethersproject/abi'; +import type { Listener, Provider } from '@ethersproject/providers'; +import type { TypedEventFilter, TypedEvent, TypedListener, OnEvent } from './common'; + +export interface MagicSeaPairInterface extends utils.Interface { + functions: { + 'FEE_DENOMINATOR()': FunctionFragment; + 'MAX_FEE_AMOUNT()': FunctionFragment; + 'MINIMUM_LIQUIDITY()': FunctionFragment; + 'MIN_FEE_AMOUNT()': FunctionFragment; + 'PERMIT_TYPEHASH()': FunctionFragment; + 'PRECISION_FACTOR()': FunctionFragment; + 'allowance(address,address)': FunctionFragment; + 'approve(address,uint256)': FunctionFragment; + 'balanceOf(address)': FunctionFragment; + 'burn(address)': FunctionFragment; + 'decimals()': FunctionFragment; + 'domainSeparator()': FunctionFragment; + 'factory()': FunctionFragment; + 'feeAmount()': FunctionFragment; + 'getReserves()': FunctionFragment; + 'initialize(address,address)': FunctionFragment; + 'kLast()': FunctionFragment; + 'mint(address)': FunctionFragment; + 'name()': FunctionFragment; + 'nonces(address)': FunctionFragment; + 'permit(address,address,uint256,uint256,uint8,bytes32,bytes32)': FunctionFragment; + 'price0CumulativeLast()': FunctionFragment; + 'price1CumulativeLast()': FunctionFragment; + 'setFeeAmount(uint256)': FunctionFragment; + 'skim(address)': FunctionFragment; + 'swap(uint256,uint256,address,bytes)': FunctionFragment; + 'symbol()': FunctionFragment; + 'sync()': FunctionFragment; + 'token0()': FunctionFragment; + 'token1()': FunctionFragment; + 'totalSupply()': FunctionFragment; + 'transfer(address,uint256)': FunctionFragment; + 'transferFrom(address,address,uint256)': FunctionFragment; + }; + + getFunction( + nameOrSignatureOrTopic: + | 'FEE_DENOMINATOR' + | 'MAX_FEE_AMOUNT' + | 'MINIMUM_LIQUIDITY' + | 'MIN_FEE_AMOUNT' + | 'PERMIT_TYPEHASH' + | 'PRECISION_FACTOR' + | 'allowance' + | 'approve' + | 'balanceOf' + | 'burn' + | 'decimals' + | 'domainSeparator' + | 'factory' + | 'feeAmount' + | 'getReserves' + | 'initialize' + | 'kLast' + | 'mint' + | 'name' + | 'nonces' + | 'permit' + | 'price0CumulativeLast' + | 'price1CumulativeLast' + | 'setFeeAmount' + | 'skim' + | 'swap' + | 'symbol' + | 'sync' + | 'token0' + | 'token1' + | 'totalSupply' + | 'transfer' + | 'transferFrom' + ): FunctionFragment; + + encodeFunctionData(functionFragment: 'FEE_DENOMINATOR', values?: undefined): string; + encodeFunctionData(functionFragment: 'MAX_FEE_AMOUNT', values?: undefined): string; + encodeFunctionData(functionFragment: 'MINIMUM_LIQUIDITY', values?: undefined): string; + encodeFunctionData(functionFragment: 'MIN_FEE_AMOUNT', values?: undefined): string; + encodeFunctionData(functionFragment: 'PERMIT_TYPEHASH', values?: undefined): string; + encodeFunctionData(functionFragment: 'PRECISION_FACTOR', values?: undefined): string; + encodeFunctionData(functionFragment: 'allowance', values: [string, string]): string; + encodeFunctionData(functionFragment: 'approve', values: [string, BigNumberish]): string; + encodeFunctionData(functionFragment: 'balanceOf', values: [string]): string; + encodeFunctionData(functionFragment: 'burn', values: [string]): string; + encodeFunctionData(functionFragment: 'decimals', values?: undefined): string; + encodeFunctionData(functionFragment: 'domainSeparator', values?: undefined): string; + encodeFunctionData(functionFragment: 'factory', values?: undefined): string; + encodeFunctionData(functionFragment: 'feeAmount', values?: undefined): string; + encodeFunctionData(functionFragment: 'getReserves', values?: undefined): string; + encodeFunctionData(functionFragment: 'initialize', values: [string, string]): string; + encodeFunctionData(functionFragment: 'kLast', values?: undefined): string; + encodeFunctionData(functionFragment: 'mint', values: [string]): string; + encodeFunctionData(functionFragment: 'name', values?: undefined): string; + encodeFunctionData(functionFragment: 'nonces', values: [string]): string; + encodeFunctionData( + functionFragment: 'permit', + values: [string, string, BigNumberish, BigNumberish, BigNumberish, BytesLike, BytesLike] + ): string; + encodeFunctionData(functionFragment: 'price0CumulativeLast', values?: undefined): string; + encodeFunctionData(functionFragment: 'price1CumulativeLast', values?: undefined): string; + encodeFunctionData(functionFragment: 'setFeeAmount', values: [BigNumberish]): string; + encodeFunctionData(functionFragment: 'skim', values: [string]): string; + encodeFunctionData(functionFragment: 'swap', values: [BigNumberish, BigNumberish, string, BytesLike]): string; + encodeFunctionData(functionFragment: 'symbol', values?: undefined): string; + encodeFunctionData(functionFragment: 'sync', values?: undefined): string; + encodeFunctionData(functionFragment: 'token0', values?: undefined): string; + encodeFunctionData(functionFragment: 'token1', values?: undefined): string; + encodeFunctionData(functionFragment: 'totalSupply', values?: undefined): string; + encodeFunctionData(functionFragment: 'transfer', values: [string, BigNumberish]): string; + encodeFunctionData(functionFragment: 'transferFrom', values: [string, string, BigNumberish]): string; + + decodeFunctionResult(functionFragment: 'FEE_DENOMINATOR', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'MAX_FEE_AMOUNT', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'MINIMUM_LIQUIDITY', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'MIN_FEE_AMOUNT', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'PERMIT_TYPEHASH', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'PRECISION_FACTOR', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'allowance', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'approve', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'balanceOf', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'burn', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'decimals', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'domainSeparator', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'factory', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'feeAmount', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'getReserves', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'initialize', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'kLast', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'mint', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'name', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'nonces', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'permit', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'price0CumulativeLast', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'price1CumulativeLast', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'setFeeAmount', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'skim', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'swap', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'symbol', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'sync', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'token0', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'token1', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'totalSupply', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'transfer', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'transferFrom', data: BytesLike): Result; + + events: { + 'Approval(address,address,uint256)': EventFragment; + 'Burn(address,uint256,uint256,address)': EventFragment; + 'FeeAmountUpdated(uint256,uint256)': EventFragment; + 'Mint(address,uint256,uint256)': EventFragment; + 'Swap(address,uint256,uint256,uint256,uint256,address)': EventFragment; + 'Sync(uint112,uint112)': EventFragment; + 'Transfer(address,address,uint256)': EventFragment; + }; + + getEvent(nameOrSignatureOrTopic: 'Approval'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'Burn'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'FeeAmountUpdated'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'Mint'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'Swap'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'Sync'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'Transfer'): EventFragment; +} + +export interface ApprovalEventObject { + owner: string; + spender: string; + value: BigNumber; +} +export type ApprovalEvent = TypedEvent<[string, string, BigNumber], ApprovalEventObject>; + +export type ApprovalEventFilter = TypedEventFilter; + +export interface BurnEventObject { + sender: string; + amount0: BigNumber; + amount1: BigNumber; + to: string; +} +export type BurnEvent = TypedEvent<[string, BigNumber, BigNumber, string], BurnEventObject>; + +export type BurnEventFilter = TypedEventFilter; + +export interface FeeAmountUpdatedEventObject { + prevFeeAmount: BigNumber; + feeAmount: BigNumber; +} +export type FeeAmountUpdatedEvent = TypedEvent<[BigNumber, BigNumber], FeeAmountUpdatedEventObject>; + +export type FeeAmountUpdatedEventFilter = TypedEventFilter; + +export interface MintEventObject { + sender: string; + amount0: BigNumber; + amount1: BigNumber; +} +export type MintEvent = TypedEvent<[string, BigNumber, BigNumber], MintEventObject>; + +export type MintEventFilter = TypedEventFilter; + +export interface SwapEventObject { + sender: string; + amount0In: BigNumber; + amount1In: BigNumber; + amount0Out: BigNumber; + amount1Out: BigNumber; + to: string; +} +export type SwapEvent = TypedEvent<[string, BigNumber, BigNumber, BigNumber, BigNumber, string], SwapEventObject>; + +export type SwapEventFilter = TypedEventFilter; + +export interface SyncEventObject { + reserve0: BigNumber; + reserve1: BigNumber; +} +export type SyncEvent = TypedEvent<[BigNumber, BigNumber], SyncEventObject>; + +export type SyncEventFilter = TypedEventFilter; + +export interface TransferEventObject { + from: string; + to: string; + value: BigNumber; +} +export type TransferEvent = TypedEvent<[string, string, BigNumber], TransferEventObject>; + +export type TransferEventFilter = TypedEventFilter; + +export interface MagicSeaPair extends BaseContract { + connect(signerOrProvider: Signer | Provider | string): this; + attach(addressOrName: string): this; + deployed(): Promise; + + interface: MagicSeaPairInterface; + + queryFilter( + event: TypedEventFilter, + fromBlockOrBlockhash?: string | number | undefined, + toBlock?: string | number | undefined + ): Promise>; + + listeners(eventFilter?: TypedEventFilter): Array>; + listeners(eventName?: string): Array; + removeAllListeners(eventFilter: TypedEventFilter): this; + removeAllListeners(eventName?: string): this; + off: OnEvent; + on: OnEvent; + once: OnEvent; + removeListener: OnEvent; + + functions: { + FEE_DENOMINATOR(overrides?: CallOverrides): Promise<[BigNumber]>; + + MAX_FEE_AMOUNT(overrides?: CallOverrides): Promise<[BigNumber]>; + + MINIMUM_LIQUIDITY(overrides?: CallOverrides): Promise<[BigNumber]>; + + MIN_FEE_AMOUNT(overrides?: CallOverrides): Promise<[BigNumber]>; + + PERMIT_TYPEHASH(overrides?: CallOverrides): Promise<[string]>; + + PRECISION_FACTOR(overrides?: CallOverrides): Promise<[BigNumber]>; + + allowance(arg0: string, arg1: string, overrides?: CallOverrides): Promise<[BigNumber]>; + + approve( + spender: string, + value: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + balanceOf(arg0: string, overrides?: CallOverrides): Promise<[BigNumber]>; + + burn(to: string, overrides?: Overrides & { from?: string }): Promise; + + decimals(overrides?: CallOverrides): Promise<[number]>; + + domainSeparator(overrides?: CallOverrides): Promise<[string]>; + + factory(overrides?: CallOverrides): Promise<[string]>; + + feeAmount(overrides?: CallOverrides): Promise<[BigNumber]>; + + getReserves(overrides?: CallOverrides): Promise< + [BigNumber, BigNumber, number] & { + _reserve0: BigNumber; + _reserve1: BigNumber; + _blockTimestampLast: number; + } + >; + + initialize( + _token0: string, + _token1: string, + overrides?: Overrides & { from?: string } + ): Promise; + + kLast(overrides?: CallOverrides): Promise<[BigNumber]>; + + mint(to: string, overrides?: Overrides & { from?: string }): Promise; + + name(overrides?: CallOverrides): Promise<[string]>; + + nonces(arg0: string, overrides?: CallOverrides): Promise<[BigNumber]>; + + permit( + owner: string, + spender: string, + value: BigNumberish, + deadline: BigNumberish, + v: BigNumberish, + r: BytesLike, + s: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise; + + price0CumulativeLast(overrides?: CallOverrides): Promise<[BigNumber]>; + + price1CumulativeLast(overrides?: CallOverrides): Promise<[BigNumber]>; + + setFeeAmount(newFeeAmount: BigNumberish, overrides?: Overrides & { from?: string }): Promise; + + skim(to: string, overrides?: Overrides & { from?: string }): Promise; + + swap( + amount0Out: BigNumberish, + amount1Out: BigNumberish, + to: string, + data: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise; + + symbol(overrides?: CallOverrides): Promise<[string]>; + + sync(overrides?: Overrides & { from?: string }): Promise; + + token0(overrides?: CallOverrides): Promise<[string]>; + + token1(overrides?: CallOverrides): Promise<[string]>; + + totalSupply(overrides?: CallOverrides): Promise<[BigNumber]>; + + transfer(to: string, value: BigNumberish, overrides?: Overrides & { from?: string }): Promise; + + transferFrom( + from: string, + to: string, + value: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + }; + + FEE_DENOMINATOR(overrides?: CallOverrides): Promise; + + MAX_FEE_AMOUNT(overrides?: CallOverrides): Promise; + + MINIMUM_LIQUIDITY(overrides?: CallOverrides): Promise; + + MIN_FEE_AMOUNT(overrides?: CallOverrides): Promise; + + PERMIT_TYPEHASH(overrides?: CallOverrides): Promise; + + PRECISION_FACTOR(overrides?: CallOverrides): Promise; + + allowance(arg0: string, arg1: string, overrides?: CallOverrides): Promise; + + approve( + spender: string, + value: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + balanceOf(arg0: string, overrides?: CallOverrides): Promise; + + burn(to: string, overrides?: Overrides & { from?: string }): Promise; + + decimals(overrides?: CallOverrides): Promise; + + domainSeparator(overrides?: CallOverrides): Promise; + + factory(overrides?: CallOverrides): Promise; + + feeAmount(overrides?: CallOverrides): Promise; + + getReserves(overrides?: CallOverrides): Promise< + [BigNumber, BigNumber, number] & { + _reserve0: BigNumber; + _reserve1: BigNumber; + _blockTimestampLast: number; + } + >; + + initialize(_token0: string, _token1: string, overrides?: Overrides & { from?: string }): Promise; + + kLast(overrides?: CallOverrides): Promise; + + mint(to: string, overrides?: Overrides & { from?: string }): Promise; + + name(overrides?: CallOverrides): Promise; + + nonces(arg0: string, overrides?: CallOverrides): Promise; + + permit( + owner: string, + spender: string, + value: BigNumberish, + deadline: BigNumberish, + v: BigNumberish, + r: BytesLike, + s: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise; + + price0CumulativeLast(overrides?: CallOverrides): Promise; + + price1CumulativeLast(overrides?: CallOverrides): Promise; + + setFeeAmount(newFeeAmount: BigNumberish, overrides?: Overrides & { from?: string }): Promise; + + skim(to: string, overrides?: Overrides & { from?: string }): Promise; + + swap( + amount0Out: BigNumberish, + amount1Out: BigNumberish, + to: string, + data: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise; + + symbol(overrides?: CallOverrides): Promise; + + sync(overrides?: Overrides & { from?: string }): Promise; + + token0(overrides?: CallOverrides): Promise; + + token1(overrides?: CallOverrides): Promise; + + totalSupply(overrides?: CallOverrides): Promise; + + transfer(to: string, value: BigNumberish, overrides?: Overrides & { from?: string }): Promise; + + transferFrom( + from: string, + to: string, + value: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + callStatic: { + FEE_DENOMINATOR(overrides?: CallOverrides): Promise; + + MAX_FEE_AMOUNT(overrides?: CallOverrides): Promise; + + MINIMUM_LIQUIDITY(overrides?: CallOverrides): Promise; + + MIN_FEE_AMOUNT(overrides?: CallOverrides): Promise; + + PERMIT_TYPEHASH(overrides?: CallOverrides): Promise; + + PRECISION_FACTOR(overrides?: CallOverrides): Promise; + + allowance(arg0: string, arg1: string, overrides?: CallOverrides): Promise; + + approve(spender: string, value: BigNumberish, overrides?: CallOverrides): Promise; + + balanceOf(arg0: string, overrides?: CallOverrides): Promise; + + burn( + to: string, + overrides?: CallOverrides + ): Promise<[BigNumber, BigNumber] & { amount0: BigNumber; amount1: BigNumber }>; + + decimals(overrides?: CallOverrides): Promise; + + domainSeparator(overrides?: CallOverrides): Promise; + + factory(overrides?: CallOverrides): Promise; + + feeAmount(overrides?: CallOverrides): Promise; + + getReserves(overrides?: CallOverrides): Promise< + [BigNumber, BigNumber, number] & { + _reserve0: BigNumber; + _reserve1: BigNumber; + _blockTimestampLast: number; + } + >; + + initialize(_token0: string, _token1: string, overrides?: CallOverrides): Promise; + + kLast(overrides?: CallOverrides): Promise; + + mint(to: string, overrides?: CallOverrides): Promise; + + name(overrides?: CallOverrides): Promise; + + nonces(arg0: string, overrides?: CallOverrides): Promise; + + permit( + owner: string, + spender: string, + value: BigNumberish, + deadline: BigNumberish, + v: BigNumberish, + r: BytesLike, + s: BytesLike, + overrides?: CallOverrides + ): Promise; + + price0CumulativeLast(overrides?: CallOverrides): Promise; + + price1CumulativeLast(overrides?: CallOverrides): Promise; + + setFeeAmount(newFeeAmount: BigNumberish, overrides?: CallOverrides): Promise; + + skim(to: string, overrides?: CallOverrides): Promise; + + swap( + amount0Out: BigNumberish, + amount1Out: BigNumberish, + to: string, + data: BytesLike, + overrides?: CallOverrides + ): Promise; + + symbol(overrides?: CallOverrides): Promise; + + sync(overrides?: CallOverrides): Promise; + + token0(overrides?: CallOverrides): Promise; + + token1(overrides?: CallOverrides): Promise; + + totalSupply(overrides?: CallOverrides): Promise; + + transfer(to: string, value: BigNumberish, overrides?: CallOverrides): Promise; + + transferFrom(from: string, to: string, value: BigNumberish, overrides?: CallOverrides): Promise; + }; + + filters: { + 'Approval(address,address,uint256)'( + owner?: string | null, + spender?: string | null, + value?: null + ): ApprovalEventFilter; + Approval(owner?: string | null, spender?: string | null, value?: null): ApprovalEventFilter; + + 'Burn(address,uint256,uint256,address)'( + sender?: string | null, + amount0?: null, + amount1?: null, + to?: string | null + ): BurnEventFilter; + Burn(sender?: string | null, amount0?: null, amount1?: null, to?: string | null): BurnEventFilter; + + 'FeeAmountUpdated(uint256,uint256)'(prevFeeAmount?: null, feeAmount?: null): FeeAmountUpdatedEventFilter; + FeeAmountUpdated(prevFeeAmount?: null, feeAmount?: null): FeeAmountUpdatedEventFilter; + + 'Mint(address,uint256,uint256)'(sender?: string | null, amount0?: null, amount1?: null): MintEventFilter; + Mint(sender?: string | null, amount0?: null, amount1?: null): MintEventFilter; + + 'Swap(address,uint256,uint256,uint256,uint256,address)'( + sender?: string | null, + amount0In?: null, + amount1In?: null, + amount0Out?: null, + amount1Out?: null, + to?: string | null + ): SwapEventFilter; + Swap( + sender?: string | null, + amount0In?: null, + amount1In?: null, + amount0Out?: null, + amount1Out?: null, + to?: string | null + ): SwapEventFilter; + + 'Sync(uint112,uint112)'(reserve0?: null, reserve1?: null): SyncEventFilter; + Sync(reserve0?: null, reserve1?: null): SyncEventFilter; + + 'Transfer(address,address,uint256)'(from?: string | null, to?: string | null, value?: null): TransferEventFilter; + Transfer(from?: string | null, to?: string | null, value?: null): TransferEventFilter; + }; + + estimateGas: { + FEE_DENOMINATOR(overrides?: CallOverrides): Promise; + + MAX_FEE_AMOUNT(overrides?: CallOverrides): Promise; + + MINIMUM_LIQUIDITY(overrides?: CallOverrides): Promise; + + MIN_FEE_AMOUNT(overrides?: CallOverrides): Promise; + + PERMIT_TYPEHASH(overrides?: CallOverrides): Promise; + + PRECISION_FACTOR(overrides?: CallOverrides): Promise; + + allowance(arg0: string, arg1: string, overrides?: CallOverrides): Promise; + + approve(spender: string, value: BigNumberish, overrides?: Overrides & { from?: string }): Promise; + + balanceOf(arg0: string, overrides?: CallOverrides): Promise; + + burn(to: string, overrides?: Overrides & { from?: string }): Promise; + + decimals(overrides?: CallOverrides): Promise; + + domainSeparator(overrides?: CallOverrides): Promise; + + factory(overrides?: CallOverrides): Promise; + + feeAmount(overrides?: CallOverrides): Promise; + + getReserves(overrides?: CallOverrides): Promise; + + initialize(_token0: string, _token1: string, overrides?: Overrides & { from?: string }): Promise; + + kLast(overrides?: CallOverrides): Promise; + + mint(to: string, overrides?: Overrides & { from?: string }): Promise; + + name(overrides?: CallOverrides): Promise; + + nonces(arg0: string, overrides?: CallOverrides): Promise; + + permit( + owner: string, + spender: string, + value: BigNumberish, + deadline: BigNumberish, + v: BigNumberish, + r: BytesLike, + s: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise; + + price0CumulativeLast(overrides?: CallOverrides): Promise; + + price1CumulativeLast(overrides?: CallOverrides): Promise; + + setFeeAmount(newFeeAmount: BigNumberish, overrides?: Overrides & { from?: string }): Promise; + + skim(to: string, overrides?: Overrides & { from?: string }): Promise; + + swap( + amount0Out: BigNumberish, + amount1Out: BigNumberish, + to: string, + data: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise; + + symbol(overrides?: CallOverrides): Promise; + + sync(overrides?: Overrides & { from?: string }): Promise; + + token0(overrides?: CallOverrides): Promise; + + token1(overrides?: CallOverrides): Promise; + + totalSupply(overrides?: CallOverrides): Promise; + + transfer(to: string, value: BigNumberish, overrides?: Overrides & { from?: string }): Promise; + + transferFrom( + from: string, + to: string, + value: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + }; + + populateTransaction: { + FEE_DENOMINATOR(overrides?: CallOverrides): Promise; + + MAX_FEE_AMOUNT(overrides?: CallOverrides): Promise; + + MINIMUM_LIQUIDITY(overrides?: CallOverrides): Promise; + + MIN_FEE_AMOUNT(overrides?: CallOverrides): Promise; + + PERMIT_TYPEHASH(overrides?: CallOverrides): Promise; + + PRECISION_FACTOR(overrides?: CallOverrides): Promise; + + allowance(arg0: string, arg1: string, overrides?: CallOverrides): Promise; + + approve( + spender: string, + value: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + balanceOf(arg0: string, overrides?: CallOverrides): Promise; + + burn(to: string, overrides?: Overrides & { from?: string }): Promise; + + decimals(overrides?: CallOverrides): Promise; + + domainSeparator(overrides?: CallOverrides): Promise; + + factory(overrides?: CallOverrides): Promise; + + feeAmount(overrides?: CallOverrides): Promise; + + getReserves(overrides?: CallOverrides): Promise; + + initialize( + _token0: string, + _token1: string, + overrides?: Overrides & { from?: string } + ): Promise; + + kLast(overrides?: CallOverrides): Promise; + + mint(to: string, overrides?: Overrides & { from?: string }): Promise; + + name(overrides?: CallOverrides): Promise; + + nonces(arg0: string, overrides?: CallOverrides): Promise; + + permit( + owner: string, + spender: string, + value: BigNumberish, + deadline: BigNumberish, + v: BigNumberish, + r: BytesLike, + s: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise; + + price0CumulativeLast(overrides?: CallOverrides): Promise; + + price1CumulativeLast(overrides?: CallOverrides): Promise; + + setFeeAmount(newFeeAmount: BigNumberish, overrides?: Overrides & { from?: string }): Promise; + + skim(to: string, overrides?: Overrides & { from?: string }): Promise; + + swap( + amount0Out: BigNumberish, + amount1Out: BigNumberish, + to: string, + data: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise; + + symbol(overrides?: CallOverrides): Promise; + + sync(overrides?: Overrides & { from?: string }): Promise; + + token0(overrides?: CallOverrides): Promise; + + token1(overrides?: CallOverrides): Promise; + + totalSupply(overrides?: CallOverrides): Promise; + + transfer(to: string, value: BigNumberish, overrides?: Overrides & { from?: string }): Promise; + + transferFrom( + from: string, + to: string, + value: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + }; +} diff --git a/src/logics/magicsea/contracts/MagicSeaRouter.ts b/src/logics/magicsea/contracts/MagicSeaRouter.ts new file mode 100644 index 00000000..14d8e14a --- /dev/null +++ b/src/logics/magicsea/contracts/MagicSeaRouter.ts @@ -0,0 +1,1303 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +import type { + BaseContract, + BigNumber, + BigNumberish, + BytesLike, + CallOverrides, + ContractTransaction, + Overrides, + PayableOverrides, + PopulatedTransaction, + Signer, + utils, +} from 'ethers'; +import type { FunctionFragment, Result } from '@ethersproject/abi'; +import type { Listener, Provider } from '@ethersproject/providers'; +import type { TypedEventFilter, TypedEvent, TypedListener, OnEvent } from './common'; + +export interface MagicSeaRouterInterface extends utils.Interface { + functions: { + 'WETH()': FunctionFragment; + 'addLiquidity(address,address,uint256,uint256,uint256,uint256,address,uint256)': FunctionFragment; + 'addLiquidityETH(address,uint256,uint256,uint256,address,uint256)': FunctionFragment; + 'factory()': FunctionFragment; + 'getAmountIn(uint256,uint256,uint256,uint256)': FunctionFragment; + 'getAmountOut(uint256,uint256,uint256,uint256)': FunctionFragment; + 'getAmountsIn(uint256,address[])': FunctionFragment; + 'getAmountsOut(uint256,address[])': FunctionFragment; + 'quote(uint256,uint256,uint256)': FunctionFragment; + 'removeLiquidity(address,address,uint256,uint256,uint256,address,uint256)': FunctionFragment; + 'removeLiquidityETH(address,uint256,uint256,uint256,address,uint256)': FunctionFragment; + 'removeLiquidityETHSupportingFeeOnTransferTokens(address,uint256,uint256,uint256,address,uint256)': FunctionFragment; + 'removeLiquidityETHWithPermit(address,uint256,uint256,uint256,address,uint256,bool,uint8,bytes32,bytes32)': FunctionFragment; + 'removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(address,uint256,uint256,uint256,address,uint256,bool,uint8,bytes32,bytes32)': FunctionFragment; + 'removeLiquidityWithPermit(address,address,uint256,uint256,uint256,address,uint256,bool,uint8,bytes32,bytes32)': FunctionFragment; + 'swapETHForExactTokens(uint256,address[],address,uint256)': FunctionFragment; + 'swapExactETHForTokens(uint256,address[],address,uint256)': FunctionFragment; + 'swapExactETHForTokensSupportingFeeOnTransferTokens(uint256,address[],address,uint256)': FunctionFragment; + 'swapExactTokensForETH(uint256,uint256,address[],address,uint256)': FunctionFragment; + 'swapExactTokensForETHSupportingFeeOnTransferTokens(uint256,uint256,address[],address,uint256)': FunctionFragment; + 'swapExactTokensForTokens(uint256,uint256,address[],address,uint256)': FunctionFragment; + 'swapExactTokensForTokensSupportingFeeOnTransferTokens(uint256,uint256,address[],address,uint256)': FunctionFragment; + 'swapTokensForExactETH(uint256,uint256,address[],address,uint256)': FunctionFragment; + 'swapTokensForExactTokens(uint256,uint256,address[],address,uint256)': FunctionFragment; + }; + + getFunction( + nameOrSignatureOrTopic: + | 'WETH' + | 'addLiquidity' + | 'addLiquidityETH' + | 'factory' + | 'getAmountIn' + | 'getAmountOut' + | 'getAmountsIn' + | 'getAmountsOut' + | 'quote' + | 'removeLiquidity' + | 'removeLiquidityETH' + | 'removeLiquidityETHSupportingFeeOnTransferTokens' + | 'removeLiquidityETHWithPermit' + | 'removeLiquidityETHWithPermitSupportingFeeOnTransferTokens' + | 'removeLiquidityWithPermit' + | 'swapETHForExactTokens' + | 'swapExactETHForTokens' + | 'swapExactETHForTokensSupportingFeeOnTransferTokens' + | 'swapExactTokensForETH' + | 'swapExactTokensForETHSupportingFeeOnTransferTokens' + | 'swapExactTokensForTokens' + | 'swapExactTokensForTokensSupportingFeeOnTransferTokens' + | 'swapTokensForExactETH' + | 'swapTokensForExactTokens' + ): FunctionFragment; + + encodeFunctionData(functionFragment: 'WETH', values?: undefined): string; + encodeFunctionData( + functionFragment: 'addLiquidity', + values: [string, string, BigNumberish, BigNumberish, BigNumberish, BigNumberish, string, BigNumberish] + ): string; + encodeFunctionData( + functionFragment: 'addLiquidityETH', + values: [string, BigNumberish, BigNumberish, BigNumberish, string, BigNumberish] + ): string; + encodeFunctionData(functionFragment: 'factory', values?: undefined): string; + encodeFunctionData( + functionFragment: 'getAmountIn', + values: [BigNumberish, BigNumberish, BigNumberish, BigNumberish] + ): string; + encodeFunctionData( + functionFragment: 'getAmountOut', + values: [BigNumberish, BigNumberish, BigNumberish, BigNumberish] + ): string; + encodeFunctionData(functionFragment: 'getAmountsIn', values: [BigNumberish, string[]]): string; + encodeFunctionData(functionFragment: 'getAmountsOut', values: [BigNumberish, string[]]): string; + encodeFunctionData(functionFragment: 'quote', values: [BigNumberish, BigNumberish, BigNumberish]): string; + encodeFunctionData( + functionFragment: 'removeLiquidity', + values: [string, string, BigNumberish, BigNumberish, BigNumberish, string, BigNumberish] + ): string; + encodeFunctionData( + functionFragment: 'removeLiquidityETH', + values: [string, BigNumberish, BigNumberish, BigNumberish, string, BigNumberish] + ): string; + encodeFunctionData( + functionFragment: 'removeLiquidityETHSupportingFeeOnTransferTokens', + values: [string, BigNumberish, BigNumberish, BigNumberish, string, BigNumberish] + ): string; + encodeFunctionData( + functionFragment: 'removeLiquidityETHWithPermit', + values: [ + string, + BigNumberish, + BigNumberish, + BigNumberish, + string, + BigNumberish, + boolean, + BigNumberish, + BytesLike, + BytesLike + ] + ): string; + encodeFunctionData( + functionFragment: 'removeLiquidityETHWithPermitSupportingFeeOnTransferTokens', + values: [ + string, + BigNumberish, + BigNumberish, + BigNumberish, + string, + BigNumberish, + boolean, + BigNumberish, + BytesLike, + BytesLike + ] + ): string; + encodeFunctionData( + functionFragment: 'removeLiquidityWithPermit', + values: [ + string, + string, + BigNumberish, + BigNumberish, + BigNumberish, + string, + BigNumberish, + boolean, + BigNumberish, + BytesLike, + BytesLike + ] + ): string; + encodeFunctionData( + functionFragment: 'swapETHForExactTokens', + values: [BigNumberish, string[], string, BigNumberish] + ): string; + encodeFunctionData( + functionFragment: 'swapExactETHForTokens', + values: [BigNumberish, string[], string, BigNumberish] + ): string; + encodeFunctionData( + functionFragment: 'swapExactETHForTokensSupportingFeeOnTransferTokens', + values: [BigNumberish, string[], string, BigNumberish] + ): string; + encodeFunctionData( + functionFragment: 'swapExactTokensForETH', + values: [BigNumberish, BigNumberish, string[], string, BigNumberish] + ): string; + encodeFunctionData( + functionFragment: 'swapExactTokensForETHSupportingFeeOnTransferTokens', + values: [BigNumberish, BigNumberish, string[], string, BigNumberish] + ): string; + encodeFunctionData( + functionFragment: 'swapExactTokensForTokens', + values: [BigNumberish, BigNumberish, string[], string, BigNumberish] + ): string; + encodeFunctionData( + functionFragment: 'swapExactTokensForTokensSupportingFeeOnTransferTokens', + values: [BigNumberish, BigNumberish, string[], string, BigNumberish] + ): string; + encodeFunctionData( + functionFragment: 'swapTokensForExactETH', + values: [BigNumberish, BigNumberish, string[], string, BigNumberish] + ): string; + encodeFunctionData( + functionFragment: 'swapTokensForExactTokens', + values: [BigNumberish, BigNumberish, string[], string, BigNumberish] + ): string; + + decodeFunctionResult(functionFragment: 'WETH', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'addLiquidity', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'addLiquidityETH', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'factory', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'getAmountIn', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'getAmountOut', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'getAmountsIn', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'getAmountsOut', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'quote', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'removeLiquidity', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'removeLiquidityETH', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'removeLiquidityETHSupportingFeeOnTransferTokens', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'removeLiquidityETHWithPermit', data: BytesLike): Result; + decodeFunctionResult( + functionFragment: 'removeLiquidityETHWithPermitSupportingFeeOnTransferTokens', + data: BytesLike + ): Result; + decodeFunctionResult(functionFragment: 'removeLiquidityWithPermit', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'swapETHForExactTokens', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'swapExactETHForTokens', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'swapExactETHForTokensSupportingFeeOnTransferTokens', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'swapExactTokensForETH', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'swapExactTokensForETHSupportingFeeOnTransferTokens', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'swapExactTokensForTokens', data: BytesLike): Result; + decodeFunctionResult( + functionFragment: 'swapExactTokensForTokensSupportingFeeOnTransferTokens', + data: BytesLike + ): Result; + decodeFunctionResult(functionFragment: 'swapTokensForExactETH', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'swapTokensForExactTokens', data: BytesLike): Result; + + events: {}; +} + +export interface MagicSeaRouter extends BaseContract { + connect(signerOrProvider: Signer | Provider | string): this; + attach(addressOrName: string): this; + deployed(): Promise; + + interface: MagicSeaRouterInterface; + + queryFilter( + event: TypedEventFilter, + fromBlockOrBlockhash?: string | number | undefined, + toBlock?: string | number | undefined + ): Promise>; + + listeners(eventFilter?: TypedEventFilter): Array>; + listeners(eventName?: string): Array; + removeAllListeners(eventFilter: TypedEventFilter): this; + removeAllListeners(eventName?: string): this; + off: OnEvent; + on: OnEvent; + once: OnEvent; + removeListener: OnEvent; + + functions: { + WETH(overrides?: CallOverrides): Promise<[string]>; + + addLiquidity( + tokenA: string, + tokenB: string, + amountADesired: BigNumberish, + amountBDesired: BigNumberish, + amountAMin: BigNumberish, + amountBMin: BigNumberish, + to: string, + deadline: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + addLiquidityETH( + token: string, + amountTokenDesired: BigNumberish, + amountTokenMin: BigNumberish, + amountETHMin: BigNumberish, + to: string, + deadline: BigNumberish, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + factory(overrides?: CallOverrides): Promise<[string]>; + + getAmountIn( + amountOut: BigNumberish, + reserveIn: BigNumberish, + reserveOut: BigNumberish, + feeAmount: BigNumberish, + overrides?: CallOverrides + ): Promise<[BigNumber] & { amountIn: BigNumber }>; + + getAmountOut( + amountIn: BigNumberish, + reserveIn: BigNumberish, + reserveOut: BigNumberish, + feeAmount: BigNumberish, + overrides?: CallOverrides + ): Promise<[BigNumber] & { amountOut: BigNumber }>; + + getAmountsIn( + amountOut: BigNumberish, + path: string[], + overrides?: CallOverrides + ): Promise<[BigNumber[]] & { amounts: BigNumber[] }>; + + getAmountsOut( + amountIn: BigNumberish, + path: string[], + overrides?: CallOverrides + ): Promise<[BigNumber[]] & { amounts: BigNumber[] }>; + + quote( + amountA: BigNumberish, + reserveA: BigNumberish, + reserveB: BigNumberish, + overrides?: CallOverrides + ): Promise<[BigNumber] & { amountB: BigNumber }>; + + removeLiquidity( + tokenA: string, + tokenB: string, + liquidity: BigNumberish, + amountAMin: BigNumberish, + amountBMin: BigNumberish, + to: string, + deadline: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + removeLiquidityETH( + token: string, + liquidity: BigNumberish, + amountTokenMin: BigNumberish, + amountETHMin: BigNumberish, + to: string, + deadline: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + removeLiquidityETHSupportingFeeOnTransferTokens( + token: string, + liquidity: BigNumberish, + amountTokenMin: BigNumberish, + amountETHMin: BigNumberish, + to: string, + deadline: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + removeLiquidityETHWithPermit( + token: string, + liquidity: BigNumberish, + amountTokenMin: BigNumberish, + amountETHMin: BigNumberish, + to: string, + deadline: BigNumberish, + approveMax: boolean, + v: BigNumberish, + r: BytesLike, + s: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise; + + removeLiquidityETHWithPermitSupportingFeeOnTransferTokens( + token: string, + liquidity: BigNumberish, + amountTokenMin: BigNumberish, + amountETHMin: BigNumberish, + to: string, + deadline: BigNumberish, + approveMax: boolean, + v: BigNumberish, + r: BytesLike, + s: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise; + + removeLiquidityWithPermit( + tokenA: string, + tokenB: string, + liquidity: BigNumberish, + amountAMin: BigNumberish, + amountBMin: BigNumberish, + to: string, + deadline: BigNumberish, + approveMax: boolean, + v: BigNumberish, + r: BytesLike, + s: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise; + + swapETHForExactTokens( + amountOut: BigNumberish, + path: string[], + to: string, + deadline: BigNumberish, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + swapExactETHForTokens( + amountOutMin: BigNumberish, + path: string[], + to: string, + deadline: BigNumberish, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + swapExactETHForTokensSupportingFeeOnTransferTokens( + amountOutMin: BigNumberish, + path: string[], + to: string, + deadline: BigNumberish, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + swapExactTokensForETH( + amountIn: BigNumberish, + amountOutMin: BigNumberish, + path: string[], + to: string, + deadline: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + swapExactTokensForETHSupportingFeeOnTransferTokens( + amountIn: BigNumberish, + amountOutMin: BigNumberish, + path: string[], + to: string, + deadline: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + swapExactTokensForTokens( + amountIn: BigNumberish, + amountOutMin: BigNumberish, + path: string[], + to: string, + deadline: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + swapExactTokensForTokensSupportingFeeOnTransferTokens( + amountIn: BigNumberish, + amountOutMin: BigNumberish, + path: string[], + to: string, + deadline: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + swapTokensForExactETH( + amountOut: BigNumberish, + amountInMax: BigNumberish, + path: string[], + to: string, + deadline: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + swapTokensForExactTokens( + amountOut: BigNumberish, + amountInMax: BigNumberish, + path: string[], + to: string, + deadline: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + }; + + WETH(overrides?: CallOverrides): Promise; + + addLiquidity( + tokenA: string, + tokenB: string, + amountADesired: BigNumberish, + amountBDesired: BigNumberish, + amountAMin: BigNumberish, + amountBMin: BigNumberish, + to: string, + deadline: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + addLiquidityETH( + token: string, + amountTokenDesired: BigNumberish, + amountTokenMin: BigNumberish, + amountETHMin: BigNumberish, + to: string, + deadline: BigNumberish, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + factory(overrides?: CallOverrides): Promise; + + getAmountIn( + amountOut: BigNumberish, + reserveIn: BigNumberish, + reserveOut: BigNumberish, + feeAmount: BigNumberish, + overrides?: CallOverrides + ): Promise; + + getAmountOut( + amountIn: BigNumberish, + reserveIn: BigNumberish, + reserveOut: BigNumberish, + feeAmount: BigNumberish, + overrides?: CallOverrides + ): Promise; + + getAmountsIn(amountOut: BigNumberish, path: string[], overrides?: CallOverrides): Promise; + + getAmountsOut(amountIn: BigNumberish, path: string[], overrides?: CallOverrides): Promise; + + quote( + amountA: BigNumberish, + reserveA: BigNumberish, + reserveB: BigNumberish, + overrides?: CallOverrides + ): Promise; + + removeLiquidity( + tokenA: string, + tokenB: string, + liquidity: BigNumberish, + amountAMin: BigNumberish, + amountBMin: BigNumberish, + to: string, + deadline: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + removeLiquidityETH( + token: string, + liquidity: BigNumberish, + amountTokenMin: BigNumberish, + amountETHMin: BigNumberish, + to: string, + deadline: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + removeLiquidityETHSupportingFeeOnTransferTokens( + token: string, + liquidity: BigNumberish, + amountTokenMin: BigNumberish, + amountETHMin: BigNumberish, + to: string, + deadline: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + removeLiquidityETHWithPermit( + token: string, + liquidity: BigNumberish, + amountTokenMin: BigNumberish, + amountETHMin: BigNumberish, + to: string, + deadline: BigNumberish, + approveMax: boolean, + v: BigNumberish, + r: BytesLike, + s: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise; + + removeLiquidityETHWithPermitSupportingFeeOnTransferTokens( + token: string, + liquidity: BigNumberish, + amountTokenMin: BigNumberish, + amountETHMin: BigNumberish, + to: string, + deadline: BigNumberish, + approveMax: boolean, + v: BigNumberish, + r: BytesLike, + s: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise; + + removeLiquidityWithPermit( + tokenA: string, + tokenB: string, + liquidity: BigNumberish, + amountAMin: BigNumberish, + amountBMin: BigNumberish, + to: string, + deadline: BigNumberish, + approveMax: boolean, + v: BigNumberish, + r: BytesLike, + s: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise; + + swapETHForExactTokens( + amountOut: BigNumberish, + path: string[], + to: string, + deadline: BigNumberish, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + swapExactETHForTokens( + amountOutMin: BigNumberish, + path: string[], + to: string, + deadline: BigNumberish, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + swapExactETHForTokensSupportingFeeOnTransferTokens( + amountOutMin: BigNumberish, + path: string[], + to: string, + deadline: BigNumberish, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + swapExactTokensForETH( + amountIn: BigNumberish, + amountOutMin: BigNumberish, + path: string[], + to: string, + deadline: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + swapExactTokensForETHSupportingFeeOnTransferTokens( + amountIn: BigNumberish, + amountOutMin: BigNumberish, + path: string[], + to: string, + deadline: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + swapExactTokensForTokens( + amountIn: BigNumberish, + amountOutMin: BigNumberish, + path: string[], + to: string, + deadline: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + swapExactTokensForTokensSupportingFeeOnTransferTokens( + amountIn: BigNumberish, + amountOutMin: BigNumberish, + path: string[], + to: string, + deadline: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + swapTokensForExactETH( + amountOut: BigNumberish, + amountInMax: BigNumberish, + path: string[], + to: string, + deadline: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + swapTokensForExactTokens( + amountOut: BigNumberish, + amountInMax: BigNumberish, + path: string[], + to: string, + deadline: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + callStatic: { + WETH(overrides?: CallOverrides): Promise; + + addLiquidity( + tokenA: string, + tokenB: string, + amountADesired: BigNumberish, + amountBDesired: BigNumberish, + amountAMin: BigNumberish, + amountBMin: BigNumberish, + to: string, + deadline: BigNumberish, + overrides?: CallOverrides + ): Promise< + [BigNumber, BigNumber, BigNumber] & { + amountA: BigNumber; + amountB: BigNumber; + liquidity: BigNumber; + } + >; + + addLiquidityETH( + token: string, + amountTokenDesired: BigNumberish, + amountTokenMin: BigNumberish, + amountETHMin: BigNumberish, + to: string, + deadline: BigNumberish, + overrides?: CallOverrides + ): Promise< + [BigNumber, BigNumber, BigNumber] & { + amountToken: BigNumber; + amountETH: BigNumber; + liquidity: BigNumber; + } + >; + + factory(overrides?: CallOverrides): Promise; + + getAmountIn( + amountOut: BigNumberish, + reserveIn: BigNumberish, + reserveOut: BigNumberish, + feeAmount: BigNumberish, + overrides?: CallOverrides + ): Promise; + + getAmountOut( + amountIn: BigNumberish, + reserveIn: BigNumberish, + reserveOut: BigNumberish, + feeAmount: BigNumberish, + overrides?: CallOverrides + ): Promise; + + getAmountsIn(amountOut: BigNumberish, path: string[], overrides?: CallOverrides): Promise; + + getAmountsOut(amountIn: BigNumberish, path: string[], overrides?: CallOverrides): Promise; + + quote( + amountA: BigNumberish, + reserveA: BigNumberish, + reserveB: BigNumberish, + overrides?: CallOverrides + ): Promise; + + removeLiquidity( + tokenA: string, + tokenB: string, + liquidity: BigNumberish, + amountAMin: BigNumberish, + amountBMin: BigNumberish, + to: string, + deadline: BigNumberish, + overrides?: CallOverrides + ): Promise<[BigNumber, BigNumber] & { amountA: BigNumber; amountB: BigNumber }>; + + removeLiquidityETH( + token: string, + liquidity: BigNumberish, + amountTokenMin: BigNumberish, + amountETHMin: BigNumberish, + to: string, + deadline: BigNumberish, + overrides?: CallOverrides + ): Promise<[BigNumber, BigNumber] & { amountToken: BigNumber; amountETH: BigNumber }>; + + removeLiquidityETHSupportingFeeOnTransferTokens( + token: string, + liquidity: BigNumberish, + amountTokenMin: BigNumberish, + amountETHMin: BigNumberish, + to: string, + deadline: BigNumberish, + overrides?: CallOverrides + ): Promise; + + removeLiquidityETHWithPermit( + token: string, + liquidity: BigNumberish, + amountTokenMin: BigNumberish, + amountETHMin: BigNumberish, + to: string, + deadline: BigNumberish, + approveMax: boolean, + v: BigNumberish, + r: BytesLike, + s: BytesLike, + overrides?: CallOverrides + ): Promise<[BigNumber, BigNumber] & { amountToken: BigNumber; amountETH: BigNumber }>; + + removeLiquidityETHWithPermitSupportingFeeOnTransferTokens( + token: string, + liquidity: BigNumberish, + amountTokenMin: BigNumberish, + amountETHMin: BigNumberish, + to: string, + deadline: BigNumberish, + approveMax: boolean, + v: BigNumberish, + r: BytesLike, + s: BytesLike, + overrides?: CallOverrides + ): Promise; + + removeLiquidityWithPermit( + tokenA: string, + tokenB: string, + liquidity: BigNumberish, + amountAMin: BigNumberish, + amountBMin: BigNumberish, + to: string, + deadline: BigNumberish, + approveMax: boolean, + v: BigNumberish, + r: BytesLike, + s: BytesLike, + overrides?: CallOverrides + ): Promise<[BigNumber, BigNumber] & { amountA: BigNumber; amountB: BigNumber }>; + + swapETHForExactTokens( + amountOut: BigNumberish, + path: string[], + to: string, + deadline: BigNumberish, + overrides?: CallOverrides + ): Promise; + + swapExactETHForTokens( + amountOutMin: BigNumberish, + path: string[], + to: string, + deadline: BigNumberish, + overrides?: CallOverrides + ): Promise; + + swapExactETHForTokensSupportingFeeOnTransferTokens( + amountOutMin: BigNumberish, + path: string[], + to: string, + deadline: BigNumberish, + overrides?: CallOverrides + ): Promise; + + swapExactTokensForETH( + amountIn: BigNumberish, + amountOutMin: BigNumberish, + path: string[], + to: string, + deadline: BigNumberish, + overrides?: CallOverrides + ): Promise; + + swapExactTokensForETHSupportingFeeOnTransferTokens( + amountIn: BigNumberish, + amountOutMin: BigNumberish, + path: string[], + to: string, + deadline: BigNumberish, + overrides?: CallOverrides + ): Promise; + + swapExactTokensForTokens( + amountIn: BigNumberish, + amountOutMin: BigNumberish, + path: string[], + to: string, + deadline: BigNumberish, + overrides?: CallOverrides + ): Promise; + + swapExactTokensForTokensSupportingFeeOnTransferTokens( + amountIn: BigNumberish, + amountOutMin: BigNumberish, + path: string[], + to: string, + deadline: BigNumberish, + overrides?: CallOverrides + ): Promise; + + swapTokensForExactETH( + amountOut: BigNumberish, + amountInMax: BigNumberish, + path: string[], + to: string, + deadline: BigNumberish, + overrides?: CallOverrides + ): Promise; + + swapTokensForExactTokens( + amountOut: BigNumberish, + amountInMax: BigNumberish, + path: string[], + to: string, + deadline: BigNumberish, + overrides?: CallOverrides + ): Promise; + }; + + filters: {}; + + estimateGas: { + WETH(overrides?: CallOverrides): Promise; + + addLiquidity( + tokenA: string, + tokenB: string, + amountADesired: BigNumberish, + amountBDesired: BigNumberish, + amountAMin: BigNumberish, + amountBMin: BigNumberish, + to: string, + deadline: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + addLiquidityETH( + token: string, + amountTokenDesired: BigNumberish, + amountTokenMin: BigNumberish, + amountETHMin: BigNumberish, + to: string, + deadline: BigNumberish, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + factory(overrides?: CallOverrides): Promise; + + getAmountIn( + amountOut: BigNumberish, + reserveIn: BigNumberish, + reserveOut: BigNumberish, + feeAmount: BigNumberish, + overrides?: CallOverrides + ): Promise; + + getAmountOut( + amountIn: BigNumberish, + reserveIn: BigNumberish, + reserveOut: BigNumberish, + feeAmount: BigNumberish, + overrides?: CallOverrides + ): Promise; + + getAmountsIn(amountOut: BigNumberish, path: string[], overrides?: CallOverrides): Promise; + + getAmountsOut(amountIn: BigNumberish, path: string[], overrides?: CallOverrides): Promise; + + quote( + amountA: BigNumberish, + reserveA: BigNumberish, + reserveB: BigNumberish, + overrides?: CallOverrides + ): Promise; + + removeLiquidity( + tokenA: string, + tokenB: string, + liquidity: BigNumberish, + amountAMin: BigNumberish, + amountBMin: BigNumberish, + to: string, + deadline: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + removeLiquidityETH( + token: string, + liquidity: BigNumberish, + amountTokenMin: BigNumberish, + amountETHMin: BigNumberish, + to: string, + deadline: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + removeLiquidityETHSupportingFeeOnTransferTokens( + token: string, + liquidity: BigNumberish, + amountTokenMin: BigNumberish, + amountETHMin: BigNumberish, + to: string, + deadline: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + removeLiquidityETHWithPermit( + token: string, + liquidity: BigNumberish, + amountTokenMin: BigNumberish, + amountETHMin: BigNumberish, + to: string, + deadline: BigNumberish, + approveMax: boolean, + v: BigNumberish, + r: BytesLike, + s: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise; + + removeLiquidityETHWithPermitSupportingFeeOnTransferTokens( + token: string, + liquidity: BigNumberish, + amountTokenMin: BigNumberish, + amountETHMin: BigNumberish, + to: string, + deadline: BigNumberish, + approveMax: boolean, + v: BigNumberish, + r: BytesLike, + s: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise; + + removeLiquidityWithPermit( + tokenA: string, + tokenB: string, + liquidity: BigNumberish, + amountAMin: BigNumberish, + amountBMin: BigNumberish, + to: string, + deadline: BigNumberish, + approveMax: boolean, + v: BigNumberish, + r: BytesLike, + s: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise; + + swapETHForExactTokens( + amountOut: BigNumberish, + path: string[], + to: string, + deadline: BigNumberish, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + swapExactETHForTokens( + amountOutMin: BigNumberish, + path: string[], + to: string, + deadline: BigNumberish, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + swapExactETHForTokensSupportingFeeOnTransferTokens( + amountOutMin: BigNumberish, + path: string[], + to: string, + deadline: BigNumberish, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + swapExactTokensForETH( + amountIn: BigNumberish, + amountOutMin: BigNumberish, + path: string[], + to: string, + deadline: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + swapExactTokensForETHSupportingFeeOnTransferTokens( + amountIn: BigNumberish, + amountOutMin: BigNumberish, + path: string[], + to: string, + deadline: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + swapExactTokensForTokens( + amountIn: BigNumberish, + amountOutMin: BigNumberish, + path: string[], + to: string, + deadline: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + swapExactTokensForTokensSupportingFeeOnTransferTokens( + amountIn: BigNumberish, + amountOutMin: BigNumberish, + path: string[], + to: string, + deadline: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + swapTokensForExactETH( + amountOut: BigNumberish, + amountInMax: BigNumberish, + path: string[], + to: string, + deadline: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + swapTokensForExactTokens( + amountOut: BigNumberish, + amountInMax: BigNumberish, + path: string[], + to: string, + deadline: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + }; + + populateTransaction: { + WETH(overrides?: CallOverrides): Promise; + + addLiquidity( + tokenA: string, + tokenB: string, + amountADesired: BigNumberish, + amountBDesired: BigNumberish, + amountAMin: BigNumberish, + amountBMin: BigNumberish, + to: string, + deadline: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + addLiquidityETH( + token: string, + amountTokenDesired: BigNumberish, + amountTokenMin: BigNumberish, + amountETHMin: BigNumberish, + to: string, + deadline: BigNumberish, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + factory(overrides?: CallOverrides): Promise; + + getAmountIn( + amountOut: BigNumberish, + reserveIn: BigNumberish, + reserveOut: BigNumberish, + feeAmount: BigNumberish, + overrides?: CallOverrides + ): Promise; + + getAmountOut( + amountIn: BigNumberish, + reserveIn: BigNumberish, + reserveOut: BigNumberish, + feeAmount: BigNumberish, + overrides?: CallOverrides + ): Promise; + + getAmountsIn(amountOut: BigNumberish, path: string[], overrides?: CallOverrides): Promise; + + getAmountsOut(amountIn: BigNumberish, path: string[], overrides?: CallOverrides): Promise; + + quote( + amountA: BigNumberish, + reserveA: BigNumberish, + reserveB: BigNumberish, + overrides?: CallOverrides + ): Promise; + + removeLiquidity( + tokenA: string, + tokenB: string, + liquidity: BigNumberish, + amountAMin: BigNumberish, + amountBMin: BigNumberish, + to: string, + deadline: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + removeLiquidityETH( + token: string, + liquidity: BigNumberish, + amountTokenMin: BigNumberish, + amountETHMin: BigNumberish, + to: string, + deadline: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + removeLiquidityETHSupportingFeeOnTransferTokens( + token: string, + liquidity: BigNumberish, + amountTokenMin: BigNumberish, + amountETHMin: BigNumberish, + to: string, + deadline: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + removeLiquidityETHWithPermit( + token: string, + liquidity: BigNumberish, + amountTokenMin: BigNumberish, + amountETHMin: BigNumberish, + to: string, + deadline: BigNumberish, + approveMax: boolean, + v: BigNumberish, + r: BytesLike, + s: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise; + + removeLiquidityETHWithPermitSupportingFeeOnTransferTokens( + token: string, + liquidity: BigNumberish, + amountTokenMin: BigNumberish, + amountETHMin: BigNumberish, + to: string, + deadline: BigNumberish, + approveMax: boolean, + v: BigNumberish, + r: BytesLike, + s: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise; + + removeLiquidityWithPermit( + tokenA: string, + tokenB: string, + liquidity: BigNumberish, + amountAMin: BigNumberish, + amountBMin: BigNumberish, + to: string, + deadline: BigNumberish, + approveMax: boolean, + v: BigNumberish, + r: BytesLike, + s: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise; + + swapETHForExactTokens( + amountOut: BigNumberish, + path: string[], + to: string, + deadline: BigNumberish, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + swapExactETHForTokens( + amountOutMin: BigNumberish, + path: string[], + to: string, + deadline: BigNumberish, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + swapExactETHForTokensSupportingFeeOnTransferTokens( + amountOutMin: BigNumberish, + path: string[], + to: string, + deadline: BigNumberish, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + swapExactTokensForETH( + amountIn: BigNumberish, + amountOutMin: BigNumberish, + path: string[], + to: string, + deadline: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + swapExactTokensForETHSupportingFeeOnTransferTokens( + amountIn: BigNumberish, + amountOutMin: BigNumberish, + path: string[], + to: string, + deadline: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + swapExactTokensForTokens( + amountIn: BigNumberish, + amountOutMin: BigNumberish, + path: string[], + to: string, + deadline: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + swapExactTokensForTokensSupportingFeeOnTransferTokens( + amountIn: BigNumberish, + amountOutMin: BigNumberish, + path: string[], + to: string, + deadline: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + swapTokensForExactETH( + amountOut: BigNumberish, + amountInMax: BigNumberish, + path: string[], + to: string, + deadline: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + swapTokensForExactTokens( + amountOut: BigNumberish, + amountInMax: BigNumberish, + path: string[], + to: string, + deadline: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + }; +} diff --git a/src/logics/magicsea/contracts/common.ts b/src/logics/magicsea/contracts/common.ts new file mode 100644 index 00000000..6cfb1042 --- /dev/null +++ b/src/logics/magicsea/contracts/common.ts @@ -0,0 +1,30 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +import type { Listener } from '@ethersproject/providers'; +import type { Event, EventFilter } from 'ethers'; + +export interface TypedEvent = any, TArgsObject = any> extends Event { + args: TArgsArray & TArgsObject; +} + +export interface TypedEventFilter<_TEvent extends TypedEvent> extends EventFilter {} + +export interface TypedListener { + (...listenerArg: [...__TypechainArgsArray, TEvent]): void; +} + +type __TypechainArgsArray = T extends TypedEvent ? U : never; + +export interface OnEvent { + (eventFilter: TypedEventFilter, listener: TypedListener): TRes; + (eventName: string, listener: Listener): TRes; +} + +export type MinEthersFactory = { + deploy(...a: ARGS[]): Promise; +}; + +export type GetContractTypeFromFactory = F extends MinEthersFactory ? C : never; + +export type GetARGsTypeFromFactory = F extends MinEthersFactory ? Parameters : never; diff --git a/src/logics/magicsea/contracts/factories/MagicSeaFactory__factory.ts b/src/logics/magicsea/contracts/factories/MagicSeaFactory__factory.ts new file mode 100644 index 00000000..a9faa8e2 --- /dev/null +++ b/src/logics/magicsea/contracts/factories/MagicSeaFactory__factory.ts @@ -0,0 +1,259 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ + +import { Contract, Signer, utils } from 'ethers'; +import type { Provider } from '@ethersproject/providers'; +import type { MagicSeaFactory, MagicSeaFactoryInterface } from '../MagicSeaFactory'; + +const _abi = [ + { + inputs: [ + { + internalType: 'address', + name: '_feeToSetter', + type: 'address', + }, + ], + stateMutability: 'nonpayable', + type: 'constructor', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'token0', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'token1', + type: 'address', + }, + { + indexed: false, + internalType: 'address', + name: 'pair', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + name: 'PairCreated', + type: 'event', + }, + { + inputs: [], + name: 'FEE_DENOMINATOR', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'INIT_CODE_PAIR_HASH', + outputs: [ + { + internalType: 'bytes32', + name: '', + type: 'bytes32', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'OWNER_FEE_SHARE_MAX', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + name: 'allPairs', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'allPairsLength', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'tokenA', + type: 'address', + }, + { + internalType: 'address', + name: 'tokenB', + type: 'address', + }, + ], + name: 'createPair', + outputs: [ + { + internalType: 'address', + name: 'pair', + type: 'address', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'feeTo', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'feeToSetter', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + name: 'getPair', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'ownerFeeShare', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: '_feeTo', + type: 'address', + }, + ], + name: 'setFeeTo', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: '_feeToSetter', + type: 'address', + }, + ], + name: 'setFeeToSetter', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: 'newOwnerFeeShare', + type: 'uint256', + }, + ], + name: 'setOwnerFeeShare', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, +] as const; + +export class MagicSeaFactory__factory { + static readonly abi = _abi; + static createInterface(): MagicSeaFactoryInterface { + return new utils.Interface(_abi) as MagicSeaFactoryInterface; + } + static connect(address: string, signerOrProvider: Signer | Provider): MagicSeaFactory { + return new Contract(address, _abi, signerOrProvider) as MagicSeaFactory; + } +} diff --git a/src/logics/magicsea/contracts/factories/MagicSeaPair__factory.ts b/src/logics/magicsea/contracts/factories/MagicSeaPair__factory.ts new file mode 100644 index 00000000..6c0b3fb0 --- /dev/null +++ b/src/logics/magicsea/contracts/factories/MagicSeaPair__factory.ts @@ -0,0 +1,773 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ + +import { Contract, Signer, utils } from 'ethers'; +import type { Provider } from '@ethersproject/providers'; +import type { MagicSeaPair, MagicSeaPairInterface } from '../MagicSeaPair'; + +const _abi = [ + { + inputs: [], + 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: 'sender', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'amount0', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'amount1', + type: 'uint256', + }, + { + indexed: true, + internalType: 'address', + name: 'to', + type: 'address', + }, + ], + name: 'Burn', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: 'uint256', + name: 'prevFeeAmount', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'feeAmount', + type: 'uint256', + }, + ], + name: 'FeeAmountUpdated', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'sender', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'amount0', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'amount1', + type: 'uint256', + }, + ], + name: 'Mint', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'sender', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'amount0In', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'amount1In', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'amount0Out', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'amount1Out', + type: 'uint256', + }, + { + indexed: true, + internalType: 'address', + name: 'to', + type: 'address', + }, + ], + name: 'Swap', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: 'uint112', + name: 'reserve0', + type: 'uint112', + }, + { + indexed: false, + internalType: 'uint112', + name: 'reserve1', + type: 'uint112', + }, + ], + name: 'Sync', + 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: 'FEE_DENOMINATOR', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'MAX_FEE_AMOUNT', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'MINIMUM_LIQUIDITY', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'MIN_FEE_AMOUNT', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'PERMIT_TYPEHASH', + outputs: [ + { + internalType: 'bytes32', + name: '', + type: 'bytes32', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'PRECISION_FACTOR', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + name: 'allowance', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'spender', + type: 'address', + }, + { + internalType: 'uint256', + name: 'value', + type: 'uint256', + }, + ], + name: 'approve', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + name: 'balanceOf', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'to', + type: 'address', + }, + ], + name: 'burn', + outputs: [ + { + internalType: 'uint256', + name: 'amount0', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'amount1', + type: 'uint256', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'decimals', + outputs: [ + { + internalType: 'uint8', + name: '', + type: 'uint8', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'domainSeparator', + outputs: [ + { + internalType: 'bytes32', + name: '', + type: 'bytes32', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'factory', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'feeAmount', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'getReserves', + outputs: [ + { + internalType: 'uint112', + name: '_reserve0', + type: 'uint112', + }, + { + internalType: 'uint112', + name: '_reserve1', + type: 'uint112', + }, + { + internalType: 'uint32', + name: '_blockTimestampLast', + type: 'uint32', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: '_token0', + type: 'address', + }, + { + internalType: 'address', + name: '_token1', + type: 'address', + }, + ], + name: 'initialize', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'kLast', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'to', + type: 'address', + }, + ], + name: 'mint', + outputs: [ + { + internalType: 'uint256', + name: 'liquidity', + type: 'uint256', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'name', + outputs: [ + { + internalType: 'string', + name: '', + type: 'string', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: '', + 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: [], + name: 'price0CumulativeLast', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'price1CumulativeLast', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: 'newFeeAmount', + type: 'uint256', + }, + ], + name: 'setFeeAmount', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'to', + type: 'address', + }, + ], + name: 'skim', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: 'amount0Out', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'amount1Out', + type: 'uint256', + }, + { + internalType: 'address', + name: 'to', + type: 'address', + }, + { + internalType: 'bytes', + name: 'data', + type: 'bytes', + }, + ], + name: 'swap', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'symbol', + outputs: [ + { + internalType: 'string', + name: '', + type: 'string', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'sync', + outputs: [], + stateMutability: 'nonpayable', + 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', + }, + { + inputs: [], + name: 'totalSupply', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'to', + type: 'address', + }, + { + internalType: 'uint256', + name: 'value', + type: 'uint256', + }, + ], + name: 'transfer', + 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: 'transferFrom', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, +] as const; + +export class MagicSeaPair__factory { + static readonly abi = _abi; + static createInterface(): MagicSeaPairInterface { + return new utils.Interface(_abi) as MagicSeaPairInterface; + } + static connect(address: string, signerOrProvider: Signer | Provider): MagicSeaPair { + return new Contract(address, _abi, signerOrProvider) as MagicSeaPair; + } +} diff --git a/src/logics/magicsea/contracts/factories/MagicSeaRouter__factory.ts b/src/logics/magicsea/contracts/factories/MagicSeaRouter__factory.ts new file mode 100644 index 00000000..4edfd19f --- /dev/null +++ b/src/logics/magicsea/contracts/factories/MagicSeaRouter__factory.ts @@ -0,0 +1,1001 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ + +import { Contract, Signer, utils } from 'ethers'; +import type { Provider } from '@ethersproject/providers'; +import type { MagicSeaRouter, MagicSeaRouterInterface } from '../MagicSeaRouter'; + +const _abi = [ + { + inputs: [ + { + internalType: 'address', + name: '_factory', + type: 'address', + }, + { + internalType: 'address', + name: '_WETH', + type: 'address', + }, + ], + stateMutability: 'nonpayable', + type: 'constructor', + }, + { + inputs: [], + name: 'WETH', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'tokenA', + type: 'address', + }, + { + internalType: 'address', + name: 'tokenB', + type: 'address', + }, + { + internalType: 'uint256', + name: 'amountADesired', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'amountBDesired', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'amountAMin', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'amountBMin', + type: 'uint256', + }, + { + internalType: 'address', + name: 'to', + type: 'address', + }, + { + internalType: 'uint256', + name: 'deadline', + type: 'uint256', + }, + ], + name: 'addLiquidity', + outputs: [ + { + internalType: 'uint256', + name: 'amountA', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'amountB', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'liquidity', + type: 'uint256', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'token', + type: 'address', + }, + { + internalType: 'uint256', + name: 'amountTokenDesired', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'amountTokenMin', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'amountETHMin', + type: 'uint256', + }, + { + internalType: 'address', + name: 'to', + type: 'address', + }, + { + internalType: 'uint256', + name: 'deadline', + type: 'uint256', + }, + ], + name: 'addLiquidityETH', + outputs: [ + { + internalType: 'uint256', + name: 'amountToken', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'amountETH', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'liquidity', + type: 'uint256', + }, + ], + stateMutability: 'payable', + type: 'function', + }, + { + inputs: [], + name: 'factory', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: 'amountOut', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'reserveIn', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'reserveOut', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'feeAmount', + type: 'uint256', + }, + ], + name: 'getAmountIn', + outputs: [ + { + internalType: 'uint256', + name: 'amountIn', + type: 'uint256', + }, + ], + stateMutability: 'pure', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: 'amountIn', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'reserveIn', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'reserveOut', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'feeAmount', + type: 'uint256', + }, + ], + name: 'getAmountOut', + outputs: [ + { + internalType: 'uint256', + name: 'amountOut', + type: 'uint256', + }, + ], + stateMutability: 'pure', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: 'amountOut', + type: 'uint256', + }, + { + internalType: 'address[]', + name: 'path', + type: 'address[]', + }, + ], + name: 'getAmountsIn', + outputs: [ + { + internalType: 'uint256[]', + name: 'amounts', + type: 'uint256[]', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: 'amountIn', + type: 'uint256', + }, + { + internalType: 'address[]', + name: 'path', + type: 'address[]', + }, + ], + name: 'getAmountsOut', + outputs: [ + { + internalType: 'uint256[]', + name: 'amounts', + type: 'uint256[]', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: 'amountA', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'reserveA', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'reserveB', + type: 'uint256', + }, + ], + name: 'quote', + outputs: [ + { + internalType: 'uint256', + name: 'amountB', + type: 'uint256', + }, + ], + stateMutability: 'pure', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'tokenA', + type: 'address', + }, + { + internalType: 'address', + name: 'tokenB', + type: 'address', + }, + { + internalType: 'uint256', + name: 'liquidity', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'amountAMin', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'amountBMin', + type: 'uint256', + }, + { + internalType: 'address', + name: 'to', + type: 'address', + }, + { + internalType: 'uint256', + name: 'deadline', + type: 'uint256', + }, + ], + name: 'removeLiquidity', + outputs: [ + { + internalType: 'uint256', + name: 'amountA', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'amountB', + type: 'uint256', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'token', + type: 'address', + }, + { + internalType: 'uint256', + name: 'liquidity', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'amountTokenMin', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'amountETHMin', + type: 'uint256', + }, + { + internalType: 'address', + name: 'to', + type: 'address', + }, + { + internalType: 'uint256', + name: 'deadline', + type: 'uint256', + }, + ], + name: 'removeLiquidityETH', + outputs: [ + { + internalType: 'uint256', + name: 'amountToken', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'amountETH', + type: 'uint256', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'token', + type: 'address', + }, + { + internalType: 'uint256', + name: 'liquidity', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'amountTokenMin', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'amountETHMin', + type: 'uint256', + }, + { + internalType: 'address', + name: 'to', + type: 'address', + }, + { + internalType: 'uint256', + name: 'deadline', + type: 'uint256', + }, + ], + name: 'removeLiquidityETHSupportingFeeOnTransferTokens', + outputs: [ + { + internalType: 'uint256', + name: 'amountETH', + type: 'uint256', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'token', + type: 'address', + }, + { + internalType: 'uint256', + name: 'liquidity', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'amountTokenMin', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'amountETHMin', + type: 'uint256', + }, + { + internalType: 'address', + name: 'to', + type: 'address', + }, + { + internalType: 'uint256', + name: 'deadline', + type: 'uint256', + }, + { + internalType: 'bool', + name: 'approveMax', + type: 'bool', + }, + { + internalType: 'uint8', + name: 'v', + type: 'uint8', + }, + { + internalType: 'bytes32', + name: 'r', + type: 'bytes32', + }, + { + internalType: 'bytes32', + name: 's', + type: 'bytes32', + }, + ], + name: 'removeLiquidityETHWithPermit', + outputs: [ + { + internalType: 'uint256', + name: 'amountToken', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'amountETH', + type: 'uint256', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'token', + type: 'address', + }, + { + internalType: 'uint256', + name: 'liquidity', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'amountTokenMin', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'amountETHMin', + type: 'uint256', + }, + { + internalType: 'address', + name: 'to', + type: 'address', + }, + { + internalType: 'uint256', + name: 'deadline', + type: 'uint256', + }, + { + internalType: 'bool', + name: 'approveMax', + type: 'bool', + }, + { + internalType: 'uint8', + name: 'v', + type: 'uint8', + }, + { + internalType: 'bytes32', + name: 'r', + type: 'bytes32', + }, + { + internalType: 'bytes32', + name: 's', + type: 'bytes32', + }, + ], + name: 'removeLiquidityETHWithPermitSupportingFeeOnTransferTokens', + outputs: [ + { + internalType: 'uint256', + name: 'amountETH', + type: 'uint256', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'tokenA', + type: 'address', + }, + { + internalType: 'address', + name: 'tokenB', + type: 'address', + }, + { + internalType: 'uint256', + name: 'liquidity', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'amountAMin', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'amountBMin', + type: 'uint256', + }, + { + internalType: 'address', + name: 'to', + type: 'address', + }, + { + internalType: 'uint256', + name: 'deadline', + type: 'uint256', + }, + { + internalType: 'bool', + name: 'approveMax', + type: 'bool', + }, + { + internalType: 'uint8', + name: 'v', + type: 'uint8', + }, + { + internalType: 'bytes32', + name: 'r', + type: 'bytes32', + }, + { + internalType: 'bytes32', + name: 's', + type: 'bytes32', + }, + ], + name: 'removeLiquidityWithPermit', + outputs: [ + { + internalType: 'uint256', + name: 'amountA', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'amountB', + type: 'uint256', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: 'amountOut', + type: 'uint256', + }, + { + internalType: 'address[]', + name: 'path', + type: 'address[]', + }, + { + internalType: 'address', + name: 'to', + type: 'address', + }, + { + internalType: 'uint256', + name: 'deadline', + type: 'uint256', + }, + ], + name: 'swapETHForExactTokens', + outputs: [ + { + internalType: 'uint256[]', + name: 'amounts', + type: 'uint256[]', + }, + ], + stateMutability: 'payable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: 'amountOutMin', + type: 'uint256', + }, + { + internalType: 'address[]', + name: 'path', + type: 'address[]', + }, + { + internalType: 'address', + name: 'to', + type: 'address', + }, + { + internalType: 'uint256', + name: 'deadline', + type: 'uint256', + }, + ], + name: 'swapExactETHForTokens', + outputs: [ + { + internalType: 'uint256[]', + name: 'amounts', + type: 'uint256[]', + }, + ], + stateMutability: 'payable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: 'amountOutMin', + type: 'uint256', + }, + { + internalType: 'address[]', + name: 'path', + type: 'address[]', + }, + { + internalType: 'address', + name: 'to', + type: 'address', + }, + { + internalType: 'uint256', + name: 'deadline', + type: 'uint256', + }, + ], + name: 'swapExactETHForTokensSupportingFeeOnTransferTokens', + outputs: [], + stateMutability: 'payable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: 'amountIn', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'amountOutMin', + type: 'uint256', + }, + { + internalType: 'address[]', + name: 'path', + type: 'address[]', + }, + { + internalType: 'address', + name: 'to', + type: 'address', + }, + { + internalType: 'uint256', + name: 'deadline', + type: 'uint256', + }, + ], + name: 'swapExactTokensForETH', + outputs: [ + { + internalType: 'uint256[]', + name: 'amounts', + type: 'uint256[]', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: 'amountIn', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'amountOutMin', + type: 'uint256', + }, + { + internalType: 'address[]', + name: 'path', + type: 'address[]', + }, + { + internalType: 'address', + name: 'to', + type: 'address', + }, + { + internalType: 'uint256', + name: 'deadline', + type: 'uint256', + }, + ], + name: 'swapExactTokensForETHSupportingFeeOnTransferTokens', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: 'amountIn', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'amountOutMin', + type: 'uint256', + }, + { + internalType: 'address[]', + name: 'path', + type: 'address[]', + }, + { + internalType: 'address', + name: 'to', + type: 'address', + }, + { + internalType: 'uint256', + name: 'deadline', + type: 'uint256', + }, + ], + name: 'swapExactTokensForTokens', + outputs: [ + { + internalType: 'uint256[]', + name: 'amounts', + type: 'uint256[]', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: 'amountIn', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'amountOutMin', + type: 'uint256', + }, + { + internalType: 'address[]', + name: 'path', + type: 'address[]', + }, + { + internalType: 'address', + name: 'to', + type: 'address', + }, + { + internalType: 'uint256', + name: 'deadline', + type: 'uint256', + }, + ], + name: 'swapExactTokensForTokensSupportingFeeOnTransferTokens', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: 'amountOut', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'amountInMax', + type: 'uint256', + }, + { + internalType: 'address[]', + name: 'path', + type: 'address[]', + }, + { + internalType: 'address', + name: 'to', + type: 'address', + }, + { + internalType: 'uint256', + name: 'deadline', + type: 'uint256', + }, + ], + name: 'swapTokensForExactETH', + outputs: [ + { + internalType: 'uint256[]', + name: 'amounts', + type: 'uint256[]', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: 'amountOut', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'amountInMax', + type: 'uint256', + }, + { + internalType: 'address[]', + name: 'path', + type: 'address[]', + }, + { + internalType: 'address', + name: 'to', + type: 'address', + }, + { + internalType: 'uint256', + name: 'deadline', + type: 'uint256', + }, + ], + name: 'swapTokensForExactTokens', + outputs: [ + { + internalType: 'uint256[]', + name: 'amounts', + type: 'uint256[]', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + stateMutability: 'payable', + type: 'receive', + }, +] as const; + +export class MagicSeaRouter__factory { + static readonly abi = _abi; + static createInterface(): MagicSeaRouterInterface { + return new utils.Interface(_abi) as MagicSeaRouterInterface; + } + static connect(address: string, signerOrProvider: Signer | Provider): MagicSeaRouter { + return new Contract(address, _abi, signerOrProvider) as MagicSeaRouter; + } +} diff --git a/src/logics/magicsea/contracts/factories/index.ts b/src/logics/magicsea/contracts/factories/index.ts new file mode 100644 index 00000000..99437890 --- /dev/null +++ b/src/logics/magicsea/contracts/factories/index.ts @@ -0,0 +1,6 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +export { MagicSeaFactory__factory } from './MagicSeaFactory__factory'; +export { MagicSeaPair__factory } from './MagicSeaPair__factory'; +export { MagicSeaRouter__factory } from './MagicSeaRouter__factory'; diff --git a/src/logics/magicsea/contracts/index.ts b/src/logics/magicsea/contracts/index.ts new file mode 100644 index 00000000..381398a5 --- /dev/null +++ b/src/logics/magicsea/contracts/index.ts @@ -0,0 +1,10 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +export type { MagicSeaFactory } from './MagicSeaFactory'; +export type { MagicSeaPair } from './MagicSeaPair'; +export type { MagicSeaRouter } from './MagicSeaRouter'; +export * as factories from './factories'; +export { MagicSeaFactory__factory } from './factories/MagicSeaFactory__factory'; +export { MagicSeaPair__factory } from './factories/MagicSeaPair__factory'; +export { MagicSeaRouter__factory } from './factories/MagicSeaRouter__factory'; diff --git a/src/logics/magicsea/index.ts b/src/logics/magicsea/index.ts new file mode 100644 index 00000000..78d94ba9 --- /dev/null +++ b/src/logics/magicsea/index.ts @@ -0,0 +1,3 @@ +export * from './configs'; +export * from './logic.swap-token'; +export * from './tokens'; diff --git a/src/logics/magicsea/logic.swap-token.test.ts b/src/logics/magicsea/logic.swap-token.test.ts new file mode 100644 index 00000000..2fdb6612 --- /dev/null +++ b/src/logics/magicsea/logic.swap-token.test.ts @@ -0,0 +1,155 @@ +import { LogicTestCaseWithChainId } from 'test/types'; +import { MagicSeaRouter__factory } from './contracts'; +import { SwapTokenLogic, SwapTokenLogicFields, SwapTokenLogicOptions } from './logic.swap-token'; +import * as common from '@protocolink/common'; +import { constants, utils } from 'ethers'; +import * as core from '@protocolink/core'; +import { expect } from 'chai'; +import { getContractAddress, getTokenListUrls } from './configs'; +import { iotaTokens } from './tokens'; + +describe('MagicSea SwapTokenLogic', function () { + context('Test getTokenListUrls', function () { + SwapTokenLogic.supportedChainIds.forEach((chainId) => { + it(`network: ${common.toNetworkId(chainId)}`, function () { + const urls = getTokenListUrls(chainId); + expect(urls).to.have.lengthOf.above(0); + }); + }); + }); + + context('Test getTokenList', async function () { + SwapTokenLogic.supportedChainIds.forEach((chainId) => { + it(`network: ${common.toNetworkId(chainId)}`, async function () { + const logic = new SwapTokenLogic(chainId); + const tokenList = await logic.getTokenList(); + expect(tokenList).to.have.lengthOf.above(0); + }); + }); + }); + + context('Test build', function () { + const iface = MagicSeaRouter__factory.createInterface(); + + const testCases: LogicTestCaseWithChainId[] = [ + { + chainId: common.ChainId.iota, + fields: { + tradeType: core.TradeType.exactIn, + input: new common.TokenAmount(iotaTokens.IOTA, '1'), + output: new common.TokenAmount(iotaTokens['USDC.e'], '0'), + path: [], + slippage: 500, + }, + options: { account: '0xaAaAaAaaAaAaAaaAaAAAAAAAAaaaAaAaAaaAaaAa' }, + }, + { + chainId: common.ChainId.iota, + fields: { + tradeType: core.TradeType.exactIn, + input: new common.TokenAmount(iotaTokens['USDC.e'], '1'), + output: new common.TokenAmount(iotaTokens.IOTA, '6'), + path: [], + slippage: 500, + }, + options: { account: '0xaAaAaAaaAaAaAaaAaAAAAAAAAaaaAaAaAaaAaaAa' }, + }, + { + chainId: common.ChainId.iota, + fields: { + tradeType: core.TradeType.exactIn, + input: new common.TokenAmount(iotaTokens['USDC.e'], '1'), + output: new common.TokenAmount(iotaTokens.GIGA, '2115920'), + path: [], + slippage: 500, + }, + options: { account: '0xaAaAaAaaAaAaAaaAaAAAAAAAAaaaAaAaAaaAaaAa' }, + }, + { + chainId: common.ChainId.iota, + fields: { + tradeType: core.TradeType.exactIn, + input: new common.TokenAmount(iotaTokens['USDC.e'], '1'), + output: new common.TokenAmount(iotaTokens.IOTA, '6'), + path: [], + slippage: 500, + }, + options: { account: '0xaAaAaAaaAaAaAaaAaAAAAAAAAaaaAaAaAaaAaaAa' }, + }, + { + chainId: common.ChainId.iota, + fields: { + tradeType: core.TradeType.exactOut, + input: new common.TokenAmount(iotaTokens.IOTA, '6'), + output: new common.TokenAmount(iotaTokens['USDC.e'], '1'), + path: [], + slippage: 500, + }, + options: { account: '0xaAaAaAaaAaAaAaaAaAAAAAAAAaaaAaAaAaaAaaAa' }, + }, + { + chainId: common.ChainId.iota, + fields: { + tradeType: core.TradeType.exactOut, + input: new common.TokenAmount(iotaTokens['USDC.e'], '1'), + output: new common.TokenAmount(iotaTokens.IOTA, '6'), + path: [], + slippage: 500, + }, + options: { account: '0xaAaAaAaaAaAaAaaAaAAAAAAAAaaaAaAaAaaAaaAa' }, + }, + { + chainId: common.ChainId.iota, + fields: { + tradeType: core.TradeType.exactOut, + input: new common.TokenAmount(iotaTokens['USDC.e'], '1'), + output: new common.TokenAmount(iotaTokens.GIGA, '2115920'), + path: [], + slippage: 500, + }, + options: { account: '0xaAaAaAaaAaAaAaaAaAAAAAAAAaaaAaAaAaaAaaAa' }, + }, + ]; + + testCases.forEach(({ chainId, fields, options }) => { + it(`${fields.input.token.symbol} to ${fields.output.token.symbol}`, async function () { + const logic = new SwapTokenLogic(chainId); + const routerLogic = await logic.build(fields, options); + const sig = routerLogic.data.substring(0, 10); + const { tradeType, input, output, balanceBps } = fields; + const magicRouterAddress = getContractAddress(chainId, 'Router'); + + expect(routerLogic.to).to.eq(magicRouterAddress); + expect(utils.isBytesLike(routerLogic.data)).to.be.true; + + if (tradeType === core.TradeType.exactIn) { + expect(sig).to.eq(iface.getSighash('swapExactTokensForTokens')); + } else { + expect(sig).to.eq(iface.getSighash('swapTokensForExactTokens')); + } + + if (input.token.isNative) { + expect(routerLogic.inputs[0].token).to.eq(input.token.wrapped.address); + } + + if (balanceBps) { + expect(routerLogic.inputs[0].balanceBps).to.eq(balanceBps); + expect(routerLogic.inputs[0].amountOrOffset).to.eq(common.getParamOffset(0)); + } else { + expect(routerLogic.inputs[0].balanceBps).to.eq(core.BPS_NOT_USED); + expect(routerLogic.inputs[0].amountOrOffset).eq(input.amountWei); + } + + expect(routerLogic.wrapMode).to.eq( + input.token.isNative + ? core.WrapMode.wrapBefore + : output.token.isNative + ? core.WrapMode.unwrapAfter + : core.WrapMode.none + ); + expect(routerLogic.approveTo).to.eq(constants.AddressZero); + expect(routerLogic.callback).to.eq(constants.AddressZero); + }); + }); + }); +}); diff --git a/src/logics/magicsea/logic.swap-token.ts b/src/logics/magicsea/logic.swap-token.ts new file mode 100644 index 00000000..edccf03c --- /dev/null +++ b/src/logics/magicsea/logic.swap-token.ts @@ -0,0 +1,294 @@ +import { BigNumber, constants, ethers } from 'ethers'; +import { BigintIsh, JSBI, Pair, Percent, Token, TokenAmount, Trade } from '@uniswap/sdk'; +import { MagicSeaFactory__factory, MagicSeaPair__factory, MagicSeaRouter__factory } from './contracts'; +import { axios } from 'src/utils'; +import * as common from '@protocolink/common'; +import * as core from '@protocolink/core'; +import { getBaseTokens, getContractAddress, getTokenListUrls, supportedChainIds } from './configs'; +import { toCurrency, toCurrencyAmount, toToken, toUniToken } from './utils'; + +export type SwapTokenLogicTokenList = common.Token[]; + +export type SwapTokenLogicParams = core.TokenToTokenParams<{ slippage?: number }>; + +export type SwapTokenLogicFields = core.TokenToTokenFields<{ path: string[]; slippage?: number }>; + +export type SwapTokenLogicOptions = Pick; + +export class SwapTokenLogic + extends core.Logic + implements core.LogicTokenListInterface, core.LogicOracleInterface, core.LogicBuilderInterface +{ + static id = 'swap-token'; + static protocolId = 'magicsea'; + static readonly supportedChainIds = supportedChainIds; + + async getTokenList() { + const tokenListUrls = getTokenListUrls(this.chainId); + const tokenList: SwapTokenLogicTokenList = [this.nativeToken]; + const tmp: Record = { [this.nativeToken.address]: true }; + + await Promise.all( + tokenListUrls.map(async (tokenListUrl) => { + try { + const { data } = await axios.get<{ + tokens: { + name: string; + symbol: string; + decimals: number; + logoURI: string; + address: string; + chainId: number; + }[]; + }>(tokenListUrl); + for (const { name, symbol, decimals, logoURI, address, chainId } of data.tokens) { + const lowerCaseAddress = address.toLowerCase(); + + if ( + tmp[lowerCaseAddress] || + chainId !== this.chainId || + !name || + !symbol || + !decimals || + !ethers.utils.isAddress(address) + ) { + continue; + } + tokenList.push(new common.Token(chainId, address, decimals, symbol, name, logoURI)); + tmp[lowerCaseAddress] = true; + } + } catch {} + }) + ); + + return tokenList; + } + + async quote(params: SwapTokenLogicParams) { + const maxHops = 3; + const maxNumResults = 3; + + let path: string[] = []; + let priceImpact = '0'; + + if (core.isTokenToTokenExactInParams(params)) { + const tradeType = core.TradeType.exactIn; + const { input, slippage } = params; + + const tokenIn = input.token.wrapped; + const tokenOut = params.tokenOut.wrapped; + + const pairs = await this.getAllCommonPairs(toUniToken(tokenIn), toUniToken(tokenOut)); + const trade = Trade.bestTradeExactIn( + pairs, + toCurrencyAmount(tokenIn, input.amountWei.toString()), + toCurrency(tokenOut), + { + maxHops: maxHops, + maxNumResults: maxNumResults, + } + )[0]; + + let amountOut = '0'; + if (trade) { + amountOut = trade.outputAmount.toFixed(); + path = trade.route.path.map((token) => token.address); + priceImpact = trade.priceImpact.toFixed(); + } + const output = new common.TokenAmount(params.tokenOut).set(amountOut); + + return { + tradeType, + input, + output, + path, + priceImpact, + slippage, + }; + } else { + const tradeType = core.TradeType.exactOut; + const { output, slippage } = params; + + const tokenIn = params.tokenIn.wrapped; + const tokenOut = output.token.wrapped; + + const pairs = await this.getAllCommonPairs(toUniToken(tokenIn), toUniToken(tokenOut)); + const trade = Trade.bestTradeExactOut( + pairs, + toCurrency(tokenIn), + toCurrencyAmount(tokenOut, output.amountWei.toString()), + { + maxHops: maxHops, + maxNumResults: maxNumResults, + } + )[0]; + + let amountIn = '0'; + if (trade) { + amountIn = slippage + ? trade.maximumAmountIn(new Percent(JSBI.BigInt(slippage), JSBI.BigInt(10000))).toFixed() + : trade.inputAmount.toFixed(); + + path = trade.route.path.map((token) => token.address); + priceImpact = trade.priceImpact.toFixed(); + } + const input = new common.TokenAmount(params.tokenIn).set(amountIn); + + return { + tradeType, + input, + output, + path, + priceImpact, + slippage, + }; + } + } + + async build(fields: SwapTokenLogicFields, options: SwapTokenLogicOptions) { + const { tradeType, input, output, path, slippage, balanceBps } = fields; + const { account } = options; + + const receiver = await this.calcAgent(account); + const deadline = BigNumber.from(Math.floor(Date.now() / 1000)).add(1800); // 30m + + let data, inputs; + if (tradeType === core.TradeType.exactIn) { + const amountIn = input.amountWei; + const amountOutMin = slippage ? common.calcSlippage(output.amountWei, slippage) : output.amountWei; + data = MagicSeaRouter__factory.createInterface().encodeFunctionData('swapExactTokensForTokens', [ + amountIn, + amountOutMin, + path, + receiver, + deadline, + ]); + + const amountOffset = balanceBps ? common.getParamOffset(0) : undefined; + inputs = [ + core.newLogicInput({ + input: new common.TokenAmount(input.token.wrapped, input.amount), + balanceBps, + amountOffset, + }), + ]; + + const wrapMode = input.token.isNative + ? core.WrapMode.wrapBefore + : output.token.isNative + ? core.WrapMode.unwrapAfter + : core.WrapMode.none; + + return core.newLogic({ to: getContractAddress(this.chainId, 'Router'), data, inputs, wrapMode }); + } else { + const amountInMax = input.amountWei; + const amountOut = output.amountWei; + data = MagicSeaRouter__factory.createInterface().encodeFunctionData('swapTokensForExactTokens', [ + amountOut, + amountInMax, + path, + receiver, + deadline, + ]); + + inputs = [ + core.newLogicInput({ + input: new common.TokenAmount(input.token.wrapped, input.amount), + }), + ]; + + const wrapMode = input.token.isNative + ? core.WrapMode.wrapBefore + : output.token.isNative + ? core.WrapMode.unwrapAfter + : core.WrapMode.none; + + return core.newLogic({ to: getContractAddress(this.chainId, 'Router'), data, inputs, wrapMode }); + } + } + + async getAllCommonPairs(tokenA: Token, tokenB: Token, isAll = true): Promise { + const pairTokens = this.generateAllRoutePairs(tokenA, tokenB); + const pairAddresses = await this.getPairAddresses(pairTokens); + const addresses = isAll ? pairAddresses : [pairAddresses[0]]; + + const results: [BigintIsh, BigintIsh][] = []; + for (let i = 0; i < addresses.length; i++) { + const pairAddress = addresses[i]; + if (!pairAddress) { + results.push(['0', '0']); + } else { + const pair = MagicSeaPair__factory.connect(pairAddress, this.provider); + const [reserve0, reserve1] = await pair.getReserves(); + results.push([reserve0.toString(), reserve1.toString()]); + } + } + + const pairs = results.reduce((accumulator, result, i) => { + if (result) { + const tokenA = pairTokens[i][0]; + const tokenB = pairTokens[i][1]; + + const [reserve0, reserve1] = result; + const [token0, token1] = tokenA.sortsBefore(tokenB) ? [tokenA, tokenB] : [tokenB, tokenA]; + + const pair = new Pair( + new TokenAmount(token0, reserve0.toString()), + new TokenAmount(token1, reserve1.toString()) + ); + + accumulator.push(pair); + } + + return accumulator; + }, [] as Pair[]); + + return pairs; + } + + generateAllRoutePairs(tokenA?: Token, tokenB?: Token): [Token, Token][] { + const allBases = getBaseTokens(this.chainId).map((baseToken) => toUniToken(baseToken)); + + const basePairs: [Token, Token][] = []; + for (let i = 0; i < allBases.length; i++) { + for (let j = i + 1; j < allBases.length; j++) { + basePairs.push([allBases[i], allBases[j]]); + } + } + + return [ + // the direct pair + [tokenA, tokenB], + // token A against all bases + ...allBases.map((base): [Token | undefined, Token] => [tokenA, base]), + // token B against all bases + ...allBases.map((base): [Token | undefined, Token] => [tokenB, base]), + // each base against all bases + ...basePairs, + ] + .filter((tokens): tokens is [Token, Token] => Boolean(tokens[0] && tokens[1])) + .filter(([t0, t1]) => t0.address !== t1.address); + } + + async getPairAddresses(pairTokens: Token[][]): Promise> { + const pairAddresses = []; + + for (let i = 0; i < pairTokens.length; i++) { + const tokenA = pairTokens[i][0]; + const tokenB = pairTokens[i][1]; + let poolAddress = undefined; + if (tokenA && tokenB && !tokenA.equals(tokenB)) { + poolAddress = await this.getPairAddress(toToken(tokenA), toToken(tokenB)); + } + pairAddresses.push(poolAddress); + } + return pairAddresses; + } + + async getPairAddress(tokenIn: common.Token, tokenOut: common.Token) { + const factory = MagicSeaFactory__factory.connect(getContractAddress(this.chainId, 'Factory'), this.provider); + const [token0, token1] = tokenIn.sortsBefore(tokenOut) ? [tokenIn, tokenOut] : [tokenOut, tokenIn]; + const poolAddress = await factory.getPair(token0.address, token1.address); + return poolAddress === constants.AddressZero ? undefined : poolAddress; + } +} diff --git a/src/logics/magicsea/tokens/data/iota.json b/src/logics/magicsea/tokens/data/iota.json new file mode 100644 index 00000000..b399d47b --- /dev/null +++ b/src/logics/magicsea/tokens/data/iota.json @@ -0,0 +1,23 @@ +{ + "USDC.e": { + "chainId": 8822, + "address": "0xFbDa5F676cB37624f28265A144A48B0d6e87d3b6", + "decimals": 6, + "symbol": "USDC.e", + "name": "Stargate USDC" + }, + "GIGA": { + "chainId": 8822, + "address": "0x7c311AD614cA8b7441739cEab8A218587ecc6554", + "decimals": 18, + "symbol": "GIGA", + "name": "GigaFish" + }, + "USDT": { + "chainId": 8822, + "address": "0xC1B8045A6ef2934Cf0f78B0dbD489969Fa9Be7E4", + "decimals": 6, + "symbol": "USDT", + "name": "Tether USD" + } +} diff --git a/src/logics/magicsea/tokens/index.ts b/src/logics/magicsea/tokens/index.ts new file mode 100644 index 00000000..e0b1439b --- /dev/null +++ b/src/logics/magicsea/tokens/index.ts @@ -0,0 +1,6 @@ +import * as common from '@protocolink/common'; +import iotaTokensJSON from './data/iota.json'; + +type IotaTokenSymbols = keyof typeof iotaTokensJSON; + +export const iotaTokens = { ...common.toTokenMap(iotaTokensJSON), ...common.iotaTokens }; diff --git a/src/logics/magicsea/utils.ts b/src/logics/magicsea/utils.ts new file mode 100644 index 00000000..5aa39618 --- /dev/null +++ b/src/logics/magicsea/utils.ts @@ -0,0 +1,19 @@ +import { BigintIsh, Currency, Token, TokenAmount } from '@uniswap/sdk'; +import * as common from '@protocolink/common'; + +export function toCurrency(token: common.TokenTypes): Currency { + return toUniToken(token); +} + +// token must be wrapped +export function toCurrencyAmount(token: common.TokenTypes, amount: BigintIsh): TokenAmount { + return new TokenAmount(toUniToken(token), amount); +} + +export function toUniToken(token: common.TokenTypes) { + return new Token(token.chainId, token.address, token.decimals, token.symbol, token.name); +} + +export function toToken(token: Token) { + return new common.Token(token.chainId, token.address, token.decimals, token.symbol!, token.name!); +} diff --git a/test/logics/magicsea/swap-token.test.ts b/test/logics/magicsea/swap-token.test.ts new file mode 100644 index 00000000..fdac29c6 --- /dev/null +++ b/test/logics/magicsea/swap-token.test.ts @@ -0,0 +1,120 @@ +import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers'; +import { claimToken, getChainId, snapshotAndRevertEach } from '@protocolink/test-helpers'; +import * as common from '@protocolink/common'; +import * as core from '@protocolink/core'; +import { expect } from 'chai'; +import hre from 'hardhat'; +import { iotaTokens } from 'src/logics/magicsea/tokens'; +import * as magicsea from 'src/logics/magicsea'; +import * as utils from 'test/utils'; + +describe('iota-pb: Test MagicSea SwapToken Logic', function () { + let chainId: number; + let user: SignerWithAddress; + + before(async function () { + chainId = await getChainId(); + [, user] = await hre.ethers.getSigners(); + + await claimToken(chainId, user.address, iotaTokens.GIGA, '5000000', '0x67eFFE3187C54C23dBC82728677DD522EA813928'); + await claimToken(chainId, user.address, iotaTokens.USDT, '5000', '0xEbFC9b9665044A1C5D6F0f5738f98dd30ed8D278'); + }); + + snapshotAndRevertEach(); + + const testCases = [ + { + params: { + input: new common.TokenAmount(iotaTokens.IOTA, '100'), + tokenOut: iotaTokens.GIGA, + slippage: 5000, + }, + }, + { + params: { + input: new common.TokenAmount(iotaTokens.GIGA, '30000'), + tokenOut: iotaTokens.IOTA, + slippage: 5000, + }, + }, + { + params: { + input: new common.TokenAmount(iotaTokens.GIGA, '30000'), + tokenOut: iotaTokens.USDT, + slippage: 5000, + }, + }, + { + params: { + tokenIn: iotaTokens.IOTA, + output: new common.TokenAmount(iotaTokens.GIGA, '30000'), + slippage: 5000, + }, + }, + { + params: { + tokenIn: iotaTokens.GIGA, + output: new common.TokenAmount(iotaTokens.IOTA, '1'), + slippage: 5000, + }, + }, + { + params: { + tokenIn: iotaTokens.USDT, + output: new common.TokenAmount(iotaTokens.GIGA, '30000'), + slippage: 5000, + }, + }, + ]; + + testCases.forEach(({ params, balanceBps }, i) => { + it(`case ${i + 1}`, async function () { + // 1. get input or output + const magicseaSwapTokenLogic = new magicsea.SwapTokenLogic(chainId); + const quotation = await magicseaSwapTokenLogic.quote(params); + const { tradeType, input, output } = quotation; + + const tokenIn = tradeType === core.TradeType.exactIn ? params.input.token : params.tokenIn; + const tokenOut = tradeType === core.TradeType.exactIn ? params.tokenOut : params.output.token; + + expect(quotation.input.token.is(tokenIn)).to.be.true; + expect(quotation.output.token.is(tokenOut)).to.be.true; + + // 2. build funds, tokensReturn + const tokensReturn = [output.token.elasticAddress]; + const funds = new common.TokenAmounts(); + if (balanceBps) { + funds.add(utils.calcRequiredAmountByBalanceBps(input, balanceBps)); + tokensReturn.push(input.token.elasticAddress); + } else { + funds.add(input); + } + + // 3. build router logics + const routerLogics: core.DataType.LogicStruct[] = []; + routerLogics.push(await magicseaSwapTokenLogic.build(quotation, { account: user.address })); + + // 4. get router permit2 datas + const permit2Datas = await utils.getRouterPermit2Datas(chainId, user, funds.erc20); + + // 5. send router tx + const routerKit = new core.RouterKit(chainId); + const transactionRequest = routerKit.buildExecuteTransactionRequest({ + permit2Datas, + routerLogics, + tokensReturn, + value: funds.native?.amountWei ?? 0, + }); + + await expect(user.sendTransaction(transactionRequest)).to.not.be.reverted; + + if (tradeType === core.TradeType.exactIn) { + await expect(user.address).to.changeBalance(input.token, -input.amount); + await expect(user.address).to.changeBalance(output.token, output.amount, params.slippage); + } else { + await expect(user.address).to.changeBalance(input.token, -input.amount, params.slippage); + await expect(user.address).to.changeBalance(output.token, output.amount); + } + }); + }); +}); diff --git a/yarn.lock b/yarn.lock index b1a0d4ed..c463de51 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1035,12 +1035,27 @@ type-fest "^3.12.0" zksync-web3 "^0.14.3" -"@protocolink/core@^0.4.13": - version "0.4.13" - resolved "https://registry.yarnpkg.com/@protocolink/core/-/core-0.4.13.tgz#844c6c31d1ea60a0a5db8fd6b89104b006aaaefd" - integrity sha512-Ufapa3YUKVBzxMAeU6AgAQJqHmBagsH5lkr6bVwvHj7RyoSXD6TJVuOEXKA+jZuUZbgYYMNZBGj7LPCbIUMhsA== +"@protocolink/common@^0.4.1": + version "0.4.1" + resolved "https://registry.yarnpkg.com/@protocolink/common/-/common-0.4.1.tgz#43d0897d37ee8c71535f8ded0539431ac1c23bc5" + integrity sha512-7h7DLFRiFb9jzk9W8cnF77ioeaXo/QOB5KWtfyZ4a711qP2CcBtj+fW34zVX0xwg/myp/zzwpe0X27S/vfCAqg== dependencies: - "@protocolink/common" "^0.3.11" + "@types/lodash" "^4.14.195" + axios "^1.3.6" + axios-retry "^3.5.1" + bignumber.js "^9.1.1" + ethers "^5.7.2" + lodash "^4.17.21" + tiny-invariant "^1.3.1" + type-fest "^3.12.0" + zksync-web3 "^0.14.3" + +"@protocolink/core@^0.5.0": + version "0.5.0" + resolved "https://registry.yarnpkg.com/@protocolink/core/-/core-0.5.0.tgz#fc2ea588e4308bebc9d8d7c1d3bbaae2a0c882ab" + integrity sha512-jO18Gwg+pqj5rBHle4zvyK/nclnzW70peC+pkGmQb1IiBcJOsu7399Y4AjH+A0NoxsJDpm+ZTMBbxdfmZ0ae2g== + dependencies: + "@protocolink/common" "^0.4.1" "@uniswap/permit2-sdk" "^1.2.0" ethers "^5.7.2" tiny-invariant "^1.3.1" @@ -1054,15 +1069,15 @@ ethers "^5.7.2" tiny-invariant "^1.3.1" -"@protocolink/test-helpers@^0.3.8": - version "0.3.8" - resolved "https://registry.yarnpkg.com/@protocolink/test-helpers/-/test-helpers-0.3.8.tgz#28299205476ac9e64881ecc327d080fb9b5f2df1" - integrity sha512-zRMtcU1f1ithOstYFvcStNbFAXeH/y9YXIMjBIi+hSzP1laMJevzlfhh4IS47cGi+IIaAbwrgdGxp5RTAVuBHw== +"@protocolink/test-helpers@^0.4.0": + version "0.4.0" + resolved "https://registry.yarnpkg.com/@protocolink/test-helpers/-/test-helpers-0.4.0.tgz#34a6eb2ea8dce067e6218eac9f00b3ce3a6e62e3" + integrity sha512-VqYjGfd/DdcqLWtbT1VkrRLHPpcy9pd3rY+8/+gfj6CP/4UUBPXPGHsmm9OwmNeZon2HUU9m5tC7CyB3MXzKhQ== dependencies: "@nomicfoundation/hardhat-chai-matchers" "^1.0.6" "@nomicfoundation/hardhat-network-helpers" "^1.0.8" "@nomiclabs/hardhat-ethers" "^2.2.3" - "@protocolink/common" "^0.3.11" + "@protocolink/common" "^0.4.1" "@types/chai" "^4.3.5" "@types/mocha" "^10.0.1" chai "^4.3.7" @@ -1556,6 +1571,19 @@ tiny-invariant "^1.1.0" toformat "^2.0.0" +"@uniswap/sdk@^3.0.3": + version "3.0.3" + resolved "https://registry.yarnpkg.com/@uniswap/sdk/-/sdk-3.0.3.tgz#8201c7c72215d0030cb99acc7e661eff895c18a9" + integrity sha512-t4s8bvzaCFSiqD2qfXIm3rWhbdnXp+QjD3/mRaeVDHK7zWevs6RGEb1ohMiNgOCTZANvBayb4j8p+XFdnMBadQ== + dependencies: + "@uniswap/v2-core" "^1.0.0" + big.js "^5.2.2" + decimal.js-light "^2.5.0" + jsbi "^3.1.1" + tiny-invariant "^1.1.0" + tiny-warning "^1.0.3" + toformat "^2.0.0" + "@uniswap/swap-router-contracts@^1.2.1": version "1.3.0" resolved "https://registry.yarnpkg.com/@uniswap/swap-router-contracts/-/swap-router-contracts-1.3.0.tgz#8d555ca6d74b888d6e02a26ebb806ce315605f1f" @@ -1573,7 +1601,7 @@ resolved "https://registry.yarnpkg.com/@uniswap/token-lists/-/token-lists-1.0.0-beta.31.tgz#ff3852bd505ec7b4c276625c762ea79a93a919ec" integrity sha512-BQVoelKCRf64IToPEs1wxiXOnhr/ukwPOF78XG11PrTAOL4F8umjYKFb8ZPv1/dIJsPaC7GhLSriEqyp94SasQ== -"@uniswap/v2-core@1.0.1": +"@uniswap/v2-core@1.0.1", "@uniswap/v2-core@^1.0.0": version "1.0.1" resolved "https://registry.yarnpkg.com/@uniswap/v2-core/-/v2-core-1.0.1.tgz#af8f508bf183204779938969e2e54043e147d425" integrity sha512-MtybtkUPSyysqLY2U210NBDeCHX+ltHt3oADGdjqoThZaFRDKwM6k1Nb3F0A3hk5hwuQvytFWhrWHOEq6nVJ8Q== @@ -3843,7 +3871,7 @@ js-yaml@^3.13.0, js-yaml@^3.13.1, js-yaml@^3.6.1: argparse "^1.0.7" esprima "^4.0.0" -jsbi@^3.1.4: +jsbi@^3.1.1, jsbi@^3.1.4: version "3.2.5" resolved "https://registry.yarnpkg.com/jsbi/-/jsbi-3.2.5.tgz#b37bb90e0e5c2814c1c2a1bcd8c729888a2e37d6" integrity sha512-aBE4n43IPvjaddScbvWRA2YlTzKEynHzu7MqOyTipdHucf/VxS63ViCjxYRg86M8Rxwbt/GfzHl1kKERkt45fQ==