diff --git a/.changeset/purple-papayas-breathe.md b/.changeset/purple-papayas-breathe.md new file mode 100644 index 00000000..90dbfd00 --- /dev/null +++ b/.changeset/purple-papayas-breathe.md @@ -0,0 +1,5 @@ +--- +'@protocolink/logics': minor +--- + +add wagmi diff --git a/.env.iota.pb b/.env.iota.pb index 19039ea5..93c8c8a3 100644 --- a/.env.iota.pb +++ b/.env.iota.pb @@ -1,3 +1,3 @@ CHAIN_ID=8822 -BLOCK_NUMBER=292100 +BLOCK_NUMBER=1126425 HTTP_RPC_URL=https://json-rpc.evm.iotaledger.net diff --git a/src/logics/index.ts b/src/logics/index.ts index af5166ae..e3b900a5 100644 --- a/src/logics/index.ts +++ b/src/logics/index.ts @@ -16,4 +16,5 @@ export * as stargatev2 from './stargate-v2'; export * as syncswap from './syncswap'; export * as uniswapv3 from './uniswap-v3'; export * as utility from './utility'; +export * as wagmi from './wagmi'; export * as zeroexv4 from './zeroex-v4'; diff --git a/src/logics/uniswap-v3/logic.swap-token.ts b/src/logics/uniswap-v3/logic.swap-token.ts index 4d166c46..efacf150 100644 --- a/src/logics/uniswap-v3/logic.swap-token.ts +++ b/src/logics/uniswap-v3/logic.swap-token.ts @@ -1,3 +1,5 @@ +import { FeeAmount, computePoolAddress } from '@uniswap/v3-sdk'; +import { Token } from '@uniswap/sdk-core'; import { TokenList } from '@uniswap/token-lists'; import { axios } from 'src/utils'; import * as common from '@protocolink/common'; @@ -39,4 +41,20 @@ export class SwapTokenLogic return tokenList; } + + public async computePoolAddress({ + factoryAddress, + tokenA, + tokenB, + fee, + initCodeHashManualOverride, + }: { + factoryAddress: string; + tokenA: Token; + tokenB: Token; + fee: FeeAmount; + initCodeHashManualOverride?: string | undefined; + }): Promise { + return computePoolAddress({ factoryAddress, tokenA, tokenB, fee, initCodeHashManualOverride }); + } } diff --git a/src/logics/wagmi/abis/SwapRouter02.json b/src/logics/wagmi/abis/SwapRouter02.json new file mode 100644 index 00000000..3ae95dec --- /dev/null +++ b/src/logics/wagmi/abis/SwapRouter02.json @@ -0,0 +1,995 @@ +[ + { + "inputs": [ + { + "internalType": "address", + "name": "_factoryV2", + "type": "address" + }, + { + "internalType": "address", + "name": "factoryV3", + "type": "address" + }, + { + "internalType": "address", + "name": "_positionManager", + "type": "address" + }, + { + "internalType": "address", + "name": "_WETH9", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [], + "name": "WETH9", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "approveMax", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "approveMaxMinusOne", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "approveZeroThenMax", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "approveZeroThenMaxMinusOne", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "callPositionManager", + "outputs": [ + { + "internalType": "bytes", + "name": "result", + "type": "bytes" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes[]", + "name": "paths", + "type": "bytes[]" + }, + { + "internalType": "uint128[]", + "name": "amounts", + "type": "uint128[]" + }, + { + "internalType": "uint24", + "name": "maximumTickDivergence", + "type": "uint24" + }, + { + "internalType": "uint32", + "name": "secondsAgo", + "type": "uint32" + } + ], + "name": "checkOracleSlippage", + "outputs": [], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "path", + "type": "bytes" + }, + { + "internalType": "uint24", + "name": "maximumTickDivergence", + "type": "uint24" + }, + { + "internalType": "uint32", + "name": "secondsAgo", + "type": "uint32" + } + ], + "name": "checkOracleSlippage", + "outputs": [], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "bytes", + "name": "path", + "type": "bytes" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amountIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amountOutMinimum", + "type": "uint256" + } + ], + "internalType": "struct IV3SwapRouter.ExactInputParams", + "name": "params", + "type": "tuple" + } + ], + "name": "exactInput", + "outputs": [ + { + "internalType": "uint256", + "name": "amountOut", + "type": "uint256" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "tokenIn", + "type": "address" + }, + { + "internalType": "address", + "name": "tokenOut", + "type": "address" + }, + { + "internalType": "uint24", + "name": "fee", + "type": "uint24" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amountIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amountOutMinimum", + "type": "uint256" + }, + { + "internalType": "uint160", + "name": "sqrtPriceLimitX96", + "type": "uint160" + } + ], + "internalType": "struct IV3SwapRouter.ExactInputSingleParams", + "name": "params", + "type": "tuple" + } + ], + "name": "exactInputSingle", + "outputs": [ + { + "internalType": "uint256", + "name": "amountOut", + "type": "uint256" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "bytes", + "name": "path", + "type": "bytes" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amountOut", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amountInMaximum", + "type": "uint256" + } + ], + "internalType": "struct IV3SwapRouter.ExactOutputParams", + "name": "params", + "type": "tuple" + } + ], + "name": "exactOutput", + "outputs": [ + { + "internalType": "uint256", + "name": "amountIn", + "type": "uint256" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "tokenIn", + "type": "address" + }, + { + "internalType": "address", + "name": "tokenOut", + "type": "address" + }, + { + "internalType": "uint24", + "name": "fee", + "type": "uint24" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amountOut", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amountInMaximum", + "type": "uint256" + }, + { + "internalType": "uint160", + "name": "sqrtPriceLimitX96", + "type": "uint160" + } + ], + "internalType": "struct IV3SwapRouter.ExactOutputSingleParams", + "name": "params", + "type": "tuple" + } + ], + "name": "exactOutputSingle", + "outputs": [ + { + "internalType": "uint256", + "name": "amountIn", + "type": "uint256" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "factory", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "factoryV2", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "getApprovalType", + "outputs": [ + { + "internalType": "enum IApproveAndCall.ApprovalType", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "token0", + "type": "address" + }, + { + "internalType": "address", + "name": "token1", + "type": "address" + }, + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amount0Min", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amount1Min", + "type": "uint256" + } + ], + "internalType": "struct IApproveAndCall.IncreaseLiquidityParams", + "name": "params", + "type": "tuple" + } + ], + "name": "increaseLiquidity", + "outputs": [ + { + "internalType": "bytes", + "name": "result", + "type": "bytes" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "token0", + "type": "address" + }, + { + "internalType": "address", + "name": "token1", + "type": "address" + }, + { + "internalType": "uint24", + "name": "fee", + "type": "uint24" + }, + { + "internalType": "int24", + "name": "tickLower", + "type": "int24" + }, + { + "internalType": "int24", + "name": "tickUpper", + "type": "int24" + }, + { + "internalType": "uint256", + "name": "amount0Min", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amount1Min", + "type": "uint256" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + } + ], + "internalType": "struct IApproveAndCall.MintParams", + "name": "params", + "type": "tuple" + } + ], + "name": "mint", + "outputs": [ + { + "internalType": "bytes", + "name": "result", + "type": "bytes" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "previousBlockhash", + "type": "bytes32" + }, + { + "internalType": "bytes[]", + "name": "data", + "type": "bytes[]" + } + ], + "name": "multicall", + "outputs": [ + { + "internalType": "bytes[]", + "name": "", + "type": "bytes[]" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + }, + { + "internalType": "bytes[]", + "name": "data", + "type": "bytes[]" + } + ], + "name": "multicall", + "outputs": [ + { + "internalType": "bytes[]", + "name": "", + "type": "bytes[]" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes[]", + "name": "data", + "type": "bytes[]" + } + ], + "name": "multicall", + "outputs": [ + { + "internalType": "bytes[]", + "name": "results", + "type": "bytes[]" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "positionManager", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "pull", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "refundETH", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "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": "selfPermit", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "expiry", + "type": "uint256" + }, + { + "internalType": "uint8", + "name": "v", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "r", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "s", + "type": "bytes32" + } + ], + "name": "selfPermitAllowed", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "expiry", + "type": "uint256" + }, + { + "internalType": "uint8", + "name": "v", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "r", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "s", + "type": "bytes32" + } + ], + "name": "selfPermitAllowedIfNecessary", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "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": "selfPermitIfNecessary", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amountMinimum", + "type": "uint256" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + } + ], + "name": "sweepToken", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amountMinimum", + "type": "uint256" + } + ], + "name": "sweepToken", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amountMinimum", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "feeBips", + "type": "uint256" + }, + { + "internalType": "address", + "name": "feeRecipient", + "type": "address" + } + ], + "name": "sweepTokenWithFee", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amountMinimum", + "type": "uint256" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "feeBips", + "type": "uint256" + }, + { + "internalType": "address", + "name": "feeRecipient", + "type": "address" + } + ], + "name": "sweepTokenWithFee", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "int256", + "name": "amount0Delta", + "type": "int256" + }, + { + "internalType": "int256", + "name": "amount1Delta", + "type": "int256" + }, + { + "internalType": "bytes", + "name": "_data", + "type": "bytes" + } + ], + "name": "uniswapV3SwapCallback", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amountMinimum", + "type": "uint256" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + } + ], + "name": "unwrapWETH9", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amountMinimum", + "type": "uint256" + } + ], + "name": "unwrapWETH9", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amountMinimum", + "type": "uint256" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "feeBips", + "type": "uint256" + }, + { + "internalType": "address", + "name": "feeRecipient", + "type": "address" + } + ], + "name": "unwrapWETH9WithFee", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amountMinimum", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "feeBips", + "type": "uint256" + }, + { + "internalType": "address", + "name": "feeRecipient", + "type": "address" + } + ], + "name": "unwrapWETH9WithFee", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "wrapETH", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + } +] diff --git a/src/logics/wagmi/abis/UniswapV3Factory.json b/src/logics/wagmi/abis/UniswapV3Factory.json new file mode 100644 index 00000000..efbd50a5 --- /dev/null +++ b/src/logics/wagmi/abis/UniswapV3Factory.json @@ -0,0 +1,236 @@ +[ + { + "inputs": [], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint24", + "name": "fee", + "type": "uint24" + }, + { + "indexed": true, + "internalType": "int24", + "name": "tickSpacing", + "type": "int24" + } + ], + "name": "FeeAmountEnabled", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "oldOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnerChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "token0", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "token1", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint24", + "name": "fee", + "type": "uint24" + }, + { + "indexed": false, + "internalType": "int24", + "name": "tickSpacing", + "type": "int24" + }, + { + "indexed": false, + "internalType": "address", + "name": "pool", + "type": "address" + } + ], + "name": "PoolCreated", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "tokenA", + "type": "address" + }, + { + "internalType": "address", + "name": "tokenB", + "type": "address" + }, + { + "internalType": "uint24", + "name": "fee", + "type": "uint24" + } + ], + "name": "createPool", + "outputs": [ + { + "internalType": "address", + "name": "pool", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint24", + "name": "fee", + "type": "uint24" + }, + { + "internalType": "int24", + "name": "tickSpacing", + "type": "int24" + } + ], + "name": "enableFeeAmount", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint24", + "name": "", + "type": "uint24" + } + ], + "name": "feeAmountTickSpacing", + "outputs": [ + { + "internalType": "int24", + "name": "", + "type": "int24" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "uint24", + "name": "", + "type": "uint24" + } + ], + "name": "getPool", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "parameters", + "outputs": [ + { + "internalType": "address", + "name": "factory", + "type": "address" + }, + { + "internalType": "address", + "name": "token0", + "type": "address" + }, + { + "internalType": "address", + "name": "token1", + "type": "address" + }, + { + "internalType": "uint24", + "name": "fee", + "type": "uint24" + }, + { + "internalType": "int24", + "name": "tickSpacing", + "type": "int24" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_owner", + "type": "address" + } + ], + "name": "setOwner", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } +] diff --git a/src/logics/wagmi/configs.ts b/src/logics/wagmi/configs.ts new file mode 100644 index 00000000..cfa801df --- /dev/null +++ b/src/logics/wagmi/configs.ts @@ -0,0 +1,28 @@ +import { FeeAmount } from '@uniswap/v3-sdk'; +import * as common from '@protocolink/common'; +import { iotaTokens } from './tokens'; +import * as univ3 from 'src/modules/univ3'; + +export const configs: univ3.Config[] = [ + { + chainId: common.ChainId.iota, + factoryAddress: '0x01Bd510B2eA106917e711f9a05a42fC162bee2Ac', + quoter: { address: '0x5C08A6762CAF9ec8a42F249eBC23aAE66097218D', isV2: true }, + swapRouterAddress: '0xaE7b92C8B14E7bdB523408aE0A6fFbf3f589adD9', // swapRouter02 + feeAmounts: [FeeAmount.LOWEST - 100, FeeAmount.LOW, FeeAmount.LOW + 1000, FeeAmount.MEDIUM, FeeAmount.HIGH], + bases: [iotaTokens.wIOTA, iotaTokens.USDT, iotaTokens.WETH], + }, +]; + +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 getConfig(chainId: number) { + return configMap[chainId]; +} diff --git a/src/logics/wagmi/contracts/SwapRouter02.ts b/src/logics/wagmi/contracts/SwapRouter02.ts new file mode 100644 index 00000000..f861c089 --- /dev/null +++ b/src/logics/wagmi/contracts/SwapRouter02.ts @@ -0,0 +1,1354 @@ +/* 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 declare namespace IV3SwapRouter { + export type ExactInputParamsStruct = { + path: BytesLike; + recipient: string; + amountIn: BigNumberish; + amountOutMinimum: BigNumberish; + }; + + export type ExactInputParamsStructOutput = [string, string, BigNumber, BigNumber] & { + path: string; + recipient: string; + amountIn: BigNumber; + amountOutMinimum: BigNumber; + }; + + export type ExactInputSingleParamsStruct = { + tokenIn: string; + tokenOut: string; + fee: BigNumberish; + recipient: string; + amountIn: BigNumberish; + amountOutMinimum: BigNumberish; + sqrtPriceLimitX96: BigNumberish; + }; + + export type ExactInputSingleParamsStructOutput = [string, string, number, string, BigNumber, BigNumber, BigNumber] & { + tokenIn: string; + tokenOut: string; + fee: number; + recipient: string; + amountIn: BigNumber; + amountOutMinimum: BigNumber; + sqrtPriceLimitX96: BigNumber; + }; + + export type ExactOutputParamsStruct = { + path: BytesLike; + recipient: string; + amountOut: BigNumberish; + amountInMaximum: BigNumberish; + }; + + export type ExactOutputParamsStructOutput = [string, string, BigNumber, BigNumber] & { + path: string; + recipient: string; + amountOut: BigNumber; + amountInMaximum: BigNumber; + }; + + export type ExactOutputSingleParamsStruct = { + tokenIn: string; + tokenOut: string; + fee: BigNumberish; + recipient: string; + amountOut: BigNumberish; + amountInMaximum: BigNumberish; + sqrtPriceLimitX96: BigNumberish; + }; + + export type ExactOutputSingleParamsStructOutput = [ + string, + string, + number, + string, + BigNumber, + BigNumber, + BigNumber + ] & { + tokenIn: string; + tokenOut: string; + fee: number; + recipient: string; + amountOut: BigNumber; + amountInMaximum: BigNumber; + sqrtPriceLimitX96: BigNumber; + }; +} + +export declare namespace IApproveAndCall { + export type IncreaseLiquidityParamsStruct = { + token0: string; + token1: string; + tokenId: BigNumberish; + amount0Min: BigNumberish; + amount1Min: BigNumberish; + }; + + export type IncreaseLiquidityParamsStructOutput = [string, string, BigNumber, BigNumber, BigNumber] & { + token0: string; + token1: string; + tokenId: BigNumber; + amount0Min: BigNumber; + amount1Min: BigNumber; + }; + + export type MintParamsStruct = { + token0: string; + token1: string; + fee: BigNumberish; + tickLower: BigNumberish; + tickUpper: BigNumberish; + amount0Min: BigNumberish; + amount1Min: BigNumberish; + recipient: string; + }; + + export type MintParamsStructOutput = [string, string, number, number, number, BigNumber, BigNumber, string] & { + token0: string; + token1: string; + fee: number; + tickLower: number; + tickUpper: number; + amount0Min: BigNumber; + amount1Min: BigNumber; + recipient: string; + }; +} + +export interface SwapRouter02Interface extends utils.Interface { + functions: { + 'WETH9()': FunctionFragment; + 'approveMax(address)': FunctionFragment; + 'approveMaxMinusOne(address)': FunctionFragment; + 'approveZeroThenMax(address)': FunctionFragment; + 'approveZeroThenMaxMinusOne(address)': FunctionFragment; + 'callPositionManager(bytes)': FunctionFragment; + 'checkOracleSlippage(bytes[],uint128[],uint24,uint32)': FunctionFragment; + 'checkOracleSlippage(bytes,uint24,uint32)': FunctionFragment; + 'exactInput((bytes,address,uint256,uint256))': FunctionFragment; + 'exactInputSingle((address,address,uint24,address,uint256,uint256,uint160))': FunctionFragment; + 'exactOutput((bytes,address,uint256,uint256))': FunctionFragment; + 'exactOutputSingle((address,address,uint24,address,uint256,uint256,uint160))': FunctionFragment; + 'factory()': FunctionFragment; + 'factoryV2()': FunctionFragment; + 'getApprovalType(address,uint256)': FunctionFragment; + 'increaseLiquidity((address,address,uint256,uint256,uint256))': FunctionFragment; + 'mint((address,address,uint24,int24,int24,uint256,uint256,address))': FunctionFragment; + 'multicall(bytes32,bytes[])': FunctionFragment; + 'multicall(uint256,bytes[])': FunctionFragment; + 'multicall(bytes[])': FunctionFragment; + 'positionManager()': FunctionFragment; + 'pull(address,uint256)': FunctionFragment; + 'refundETH()': FunctionFragment; + 'selfPermit(address,uint256,uint256,uint8,bytes32,bytes32)': FunctionFragment; + 'selfPermitAllowed(address,uint256,uint256,uint8,bytes32,bytes32)': FunctionFragment; + 'selfPermitAllowedIfNecessary(address,uint256,uint256,uint8,bytes32,bytes32)': FunctionFragment; + 'selfPermitIfNecessary(address,uint256,uint256,uint8,bytes32,bytes32)': FunctionFragment; + 'sweepToken(address,uint256,address)': FunctionFragment; + 'sweepToken(address,uint256)': FunctionFragment; + 'sweepTokenWithFee(address,uint256,uint256,address)': FunctionFragment; + 'sweepTokenWithFee(address,uint256,address,uint256,address)': FunctionFragment; + 'uniswapV3SwapCallback(int256,int256,bytes)': FunctionFragment; + 'unwrapWETH9(uint256,address)': FunctionFragment; + 'unwrapWETH9(uint256)': FunctionFragment; + 'unwrapWETH9WithFee(uint256,address,uint256,address)': FunctionFragment; + 'unwrapWETH9WithFee(uint256,uint256,address)': FunctionFragment; + 'wrapETH(uint256)': FunctionFragment; + }; + + getFunction( + nameOrSignatureOrTopic: + | 'WETH9' + | 'approveMax' + | 'approveMaxMinusOne' + | 'approveZeroThenMax' + | 'approveZeroThenMaxMinusOne' + | 'callPositionManager' + | 'checkOracleSlippage(bytes[],uint128[],uint24,uint32)' + | 'checkOracleSlippage(bytes,uint24,uint32)' + | 'exactInput' + | 'exactInputSingle' + | 'exactOutput' + | 'exactOutputSingle' + | 'factory' + | 'factoryV2' + | 'getApprovalType' + | 'increaseLiquidity' + | 'mint' + | 'multicall(bytes32,bytes[])' + | 'multicall(uint256,bytes[])' + | 'multicall(bytes[])' + | 'positionManager' + | 'pull' + | 'refundETH' + | 'selfPermit' + | 'selfPermitAllowed' + | 'selfPermitAllowedIfNecessary' + | 'selfPermitIfNecessary' + | 'sweepToken(address,uint256,address)' + | 'sweepToken(address,uint256)' + | 'sweepTokenWithFee(address,uint256,uint256,address)' + | 'sweepTokenWithFee(address,uint256,address,uint256,address)' + | 'uniswapV3SwapCallback' + | 'unwrapWETH9(uint256,address)' + | 'unwrapWETH9(uint256)' + | 'unwrapWETH9WithFee(uint256,address,uint256,address)' + | 'unwrapWETH9WithFee(uint256,uint256,address)' + | 'wrapETH' + ): FunctionFragment; + + encodeFunctionData(functionFragment: 'WETH9', values?: undefined): string; + encodeFunctionData(functionFragment: 'approveMax', values: [string]): string; + encodeFunctionData(functionFragment: 'approveMaxMinusOne', values: [string]): string; + encodeFunctionData(functionFragment: 'approveZeroThenMax', values: [string]): string; + encodeFunctionData(functionFragment: 'approveZeroThenMaxMinusOne', values: [string]): string; + encodeFunctionData(functionFragment: 'callPositionManager', values: [BytesLike]): string; + encodeFunctionData( + functionFragment: 'checkOracleSlippage(bytes[],uint128[],uint24,uint32)', + values: [BytesLike[], BigNumberish[], BigNumberish, BigNumberish] + ): string; + encodeFunctionData( + functionFragment: 'checkOracleSlippage(bytes,uint24,uint32)', + values: [BytesLike, BigNumberish, BigNumberish] + ): string; + encodeFunctionData(functionFragment: 'exactInput', values: [IV3SwapRouter.ExactInputParamsStruct]): string; + encodeFunctionData( + functionFragment: 'exactInputSingle', + values: [IV3SwapRouter.ExactInputSingleParamsStruct] + ): string; + encodeFunctionData(functionFragment: 'exactOutput', values: [IV3SwapRouter.ExactOutputParamsStruct]): string; + encodeFunctionData( + functionFragment: 'exactOutputSingle', + values: [IV3SwapRouter.ExactOutputSingleParamsStruct] + ): string; + encodeFunctionData(functionFragment: 'factory', values?: undefined): string; + encodeFunctionData(functionFragment: 'factoryV2', values?: undefined): string; + encodeFunctionData(functionFragment: 'getApprovalType', values: [string, BigNumberish]): string; + encodeFunctionData( + functionFragment: 'increaseLiquidity', + values: [IApproveAndCall.IncreaseLiquidityParamsStruct] + ): string; + encodeFunctionData(functionFragment: 'mint', values: [IApproveAndCall.MintParamsStruct]): string; + encodeFunctionData(functionFragment: 'multicall(bytes32,bytes[])', values: [BytesLike, BytesLike[]]): string; + encodeFunctionData(functionFragment: 'multicall(uint256,bytes[])', values: [BigNumberish, BytesLike[]]): string; + encodeFunctionData(functionFragment: 'multicall(bytes[])', values: [BytesLike[]]): string; + encodeFunctionData(functionFragment: 'positionManager', values?: undefined): string; + encodeFunctionData(functionFragment: 'pull', values: [string, BigNumberish]): string; + encodeFunctionData(functionFragment: 'refundETH', values?: undefined): string; + encodeFunctionData( + functionFragment: 'selfPermit', + values: [string, BigNumberish, BigNumberish, BigNumberish, BytesLike, BytesLike] + ): string; + encodeFunctionData( + functionFragment: 'selfPermitAllowed', + values: [string, BigNumberish, BigNumberish, BigNumberish, BytesLike, BytesLike] + ): string; + encodeFunctionData( + functionFragment: 'selfPermitAllowedIfNecessary', + values: [string, BigNumberish, BigNumberish, BigNumberish, BytesLike, BytesLike] + ): string; + encodeFunctionData( + functionFragment: 'selfPermitIfNecessary', + values: [string, BigNumberish, BigNumberish, BigNumberish, BytesLike, BytesLike] + ): string; + encodeFunctionData( + functionFragment: 'sweepToken(address,uint256,address)', + values: [string, BigNumberish, string] + ): string; + encodeFunctionData(functionFragment: 'sweepToken(address,uint256)', values: [string, BigNumberish]): string; + encodeFunctionData( + functionFragment: 'sweepTokenWithFee(address,uint256,uint256,address)', + values: [string, BigNumberish, BigNumberish, string] + ): string; + encodeFunctionData( + functionFragment: 'sweepTokenWithFee(address,uint256,address,uint256,address)', + values: [string, BigNumberish, string, BigNumberish, string] + ): string; + encodeFunctionData( + functionFragment: 'uniswapV3SwapCallback', + values: [BigNumberish, BigNumberish, BytesLike] + ): string; + encodeFunctionData(functionFragment: 'unwrapWETH9(uint256,address)', values: [BigNumberish, string]): string; + encodeFunctionData(functionFragment: 'unwrapWETH9(uint256)', values: [BigNumberish]): string; + encodeFunctionData( + functionFragment: 'unwrapWETH9WithFee(uint256,address,uint256,address)', + values: [BigNumberish, string, BigNumberish, string] + ): string; + encodeFunctionData( + functionFragment: 'unwrapWETH9WithFee(uint256,uint256,address)', + values: [BigNumberish, BigNumberish, string] + ): string; + encodeFunctionData(functionFragment: 'wrapETH', values: [BigNumberish]): string; + + decodeFunctionResult(functionFragment: 'WETH9', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'approveMax', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'approveMaxMinusOne', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'approveZeroThenMax', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'approveZeroThenMaxMinusOne', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'callPositionManager', data: BytesLike): Result; + decodeFunctionResult( + functionFragment: 'checkOracleSlippage(bytes[],uint128[],uint24,uint32)', + data: BytesLike + ): Result; + decodeFunctionResult(functionFragment: 'checkOracleSlippage(bytes,uint24,uint32)', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'exactInput', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'exactInputSingle', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'exactOutput', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'exactOutputSingle', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'factory', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'factoryV2', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'getApprovalType', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'increaseLiquidity', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'mint', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'multicall(bytes32,bytes[])', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'multicall(uint256,bytes[])', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'multicall(bytes[])', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'positionManager', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'pull', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'refundETH', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'selfPermit', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'selfPermitAllowed', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'selfPermitAllowedIfNecessary', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'selfPermitIfNecessary', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'sweepToken(address,uint256,address)', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'sweepToken(address,uint256)', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'sweepTokenWithFee(address,uint256,uint256,address)', data: BytesLike): Result; + decodeFunctionResult( + functionFragment: 'sweepTokenWithFee(address,uint256,address,uint256,address)', + data: BytesLike + ): Result; + decodeFunctionResult(functionFragment: 'uniswapV3SwapCallback', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'unwrapWETH9(uint256,address)', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'unwrapWETH9(uint256)', data: BytesLike): Result; + decodeFunctionResult( + functionFragment: 'unwrapWETH9WithFee(uint256,address,uint256,address)', + data: BytesLike + ): Result; + decodeFunctionResult(functionFragment: 'unwrapWETH9WithFee(uint256,uint256,address)', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'wrapETH', data: BytesLike): Result; + + events: {}; +} + +export interface SwapRouter02 extends BaseContract { + connect(signerOrProvider: Signer | Provider | string): this; + attach(addressOrName: string): this; + deployed(): Promise; + + interface: SwapRouter02Interface; + + 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: { + WETH9(overrides?: CallOverrides): Promise<[string]>; + + approveMax(token: string, overrides?: PayableOverrides & { from?: string }): Promise; + + approveMaxMinusOne(token: string, overrides?: PayableOverrides & { from?: string }): Promise; + + approveZeroThenMax(token: string, overrides?: PayableOverrides & { from?: string }): Promise; + + approveZeroThenMaxMinusOne( + token: string, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + callPositionManager( + data: BytesLike, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + 'checkOracleSlippage(bytes[],uint128[],uint24,uint32)'( + paths: BytesLike[], + amounts: BigNumberish[], + maximumTickDivergence: BigNumberish, + secondsAgo: BigNumberish, + overrides?: CallOverrides + ): Promise<[void]>; + + 'checkOracleSlippage(bytes,uint24,uint32)'( + path: BytesLike, + maximumTickDivergence: BigNumberish, + secondsAgo: BigNumberish, + overrides?: CallOverrides + ): Promise<[void]>; + + exactInput( + params: IV3SwapRouter.ExactInputParamsStruct, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + exactInputSingle( + params: IV3SwapRouter.ExactInputSingleParamsStruct, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + exactOutput( + params: IV3SwapRouter.ExactOutputParamsStruct, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + exactOutputSingle( + params: IV3SwapRouter.ExactOutputSingleParamsStruct, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + factory(overrides?: CallOverrides): Promise<[string]>; + + factoryV2(overrides?: CallOverrides): Promise<[string]>; + + getApprovalType( + token: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + increaseLiquidity( + params: IApproveAndCall.IncreaseLiquidityParamsStruct, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + mint( + params: IApproveAndCall.MintParamsStruct, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + 'multicall(bytes32,bytes[])'( + previousBlockhash: BytesLike, + data: BytesLike[], + overrides?: PayableOverrides & { from?: string } + ): Promise; + + 'multicall(uint256,bytes[])'( + deadline: BigNumberish, + data: BytesLike[], + overrides?: PayableOverrides & { from?: string } + ): Promise; + + 'multicall(bytes[])'( + data: BytesLike[], + overrides?: PayableOverrides & { from?: string } + ): Promise; + + positionManager(overrides?: CallOverrides): Promise<[string]>; + + pull( + token: string, + value: BigNumberish, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + refundETH(overrides?: PayableOverrides & { from?: string }): Promise; + + selfPermit( + token: string, + value: BigNumberish, + deadline: BigNumberish, + v: BigNumberish, + r: BytesLike, + s: BytesLike, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + selfPermitAllowed( + token: string, + nonce: BigNumberish, + expiry: BigNumberish, + v: BigNumberish, + r: BytesLike, + s: BytesLike, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + selfPermitAllowedIfNecessary( + token: string, + nonce: BigNumberish, + expiry: BigNumberish, + v: BigNumberish, + r: BytesLike, + s: BytesLike, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + selfPermitIfNecessary( + token: string, + value: BigNumberish, + deadline: BigNumberish, + v: BigNumberish, + r: BytesLike, + s: BytesLike, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + 'sweepToken(address,uint256,address)'( + token: string, + amountMinimum: BigNumberish, + recipient: string, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + 'sweepToken(address,uint256)'( + token: string, + amountMinimum: BigNumberish, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + 'sweepTokenWithFee(address,uint256,uint256,address)'( + token: string, + amountMinimum: BigNumberish, + feeBips: BigNumberish, + feeRecipient: string, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + 'sweepTokenWithFee(address,uint256,address,uint256,address)'( + token: string, + amountMinimum: BigNumberish, + recipient: string, + feeBips: BigNumberish, + feeRecipient: string, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + uniswapV3SwapCallback( + amount0Delta: BigNumberish, + amount1Delta: BigNumberish, + _data: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise; + + 'unwrapWETH9(uint256,address)'( + amountMinimum: BigNumberish, + recipient: string, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + 'unwrapWETH9(uint256)'( + amountMinimum: BigNumberish, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + 'unwrapWETH9WithFee(uint256,address,uint256,address)'( + amountMinimum: BigNumberish, + recipient: string, + feeBips: BigNumberish, + feeRecipient: string, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + 'unwrapWETH9WithFee(uint256,uint256,address)'( + amountMinimum: BigNumberish, + feeBips: BigNumberish, + feeRecipient: string, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + wrapETH(value: BigNumberish, overrides?: PayableOverrides & { from?: string }): Promise; + }; + + WETH9(overrides?: CallOverrides): Promise; + + approveMax(token: string, overrides?: PayableOverrides & { from?: string }): Promise; + + approveMaxMinusOne(token: string, overrides?: PayableOverrides & { from?: string }): Promise; + + approveZeroThenMax(token: string, overrides?: PayableOverrides & { from?: string }): Promise; + + approveZeroThenMaxMinusOne( + token: string, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + callPositionManager(data: BytesLike, overrides?: PayableOverrides & { from?: string }): Promise; + + 'checkOracleSlippage(bytes[],uint128[],uint24,uint32)'( + paths: BytesLike[], + amounts: BigNumberish[], + maximumTickDivergence: BigNumberish, + secondsAgo: BigNumberish, + overrides?: CallOverrides + ): Promise; + + 'checkOracleSlippage(bytes,uint24,uint32)'( + path: BytesLike, + maximumTickDivergence: BigNumberish, + secondsAgo: BigNumberish, + overrides?: CallOverrides + ): Promise; + + exactInput( + params: IV3SwapRouter.ExactInputParamsStruct, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + exactInputSingle( + params: IV3SwapRouter.ExactInputSingleParamsStruct, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + exactOutput( + params: IV3SwapRouter.ExactOutputParamsStruct, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + exactOutputSingle( + params: IV3SwapRouter.ExactOutputSingleParamsStruct, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + factory(overrides?: CallOverrides): Promise; + + factoryV2(overrides?: CallOverrides): Promise; + + getApprovalType( + token: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + increaseLiquidity( + params: IApproveAndCall.IncreaseLiquidityParamsStruct, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + mint( + params: IApproveAndCall.MintParamsStruct, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + 'multicall(bytes32,bytes[])'( + previousBlockhash: BytesLike, + data: BytesLike[], + overrides?: PayableOverrides & { from?: string } + ): Promise; + + 'multicall(uint256,bytes[])'( + deadline: BigNumberish, + data: BytesLike[], + overrides?: PayableOverrides & { from?: string } + ): Promise; + + 'multicall(bytes[])'( + data: BytesLike[], + overrides?: PayableOverrides & { from?: string } + ): Promise; + + positionManager(overrides?: CallOverrides): Promise; + + pull( + token: string, + value: BigNumberish, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + refundETH(overrides?: PayableOverrides & { from?: string }): Promise; + + selfPermit( + token: string, + value: BigNumberish, + deadline: BigNumberish, + v: BigNumberish, + r: BytesLike, + s: BytesLike, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + selfPermitAllowed( + token: string, + nonce: BigNumberish, + expiry: BigNumberish, + v: BigNumberish, + r: BytesLike, + s: BytesLike, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + selfPermitAllowedIfNecessary( + token: string, + nonce: BigNumberish, + expiry: BigNumberish, + v: BigNumberish, + r: BytesLike, + s: BytesLike, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + selfPermitIfNecessary( + token: string, + value: BigNumberish, + deadline: BigNumberish, + v: BigNumberish, + r: BytesLike, + s: BytesLike, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + 'sweepToken(address,uint256,address)'( + token: string, + amountMinimum: BigNumberish, + recipient: string, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + 'sweepToken(address,uint256)'( + token: string, + amountMinimum: BigNumberish, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + 'sweepTokenWithFee(address,uint256,uint256,address)'( + token: string, + amountMinimum: BigNumberish, + feeBips: BigNumberish, + feeRecipient: string, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + 'sweepTokenWithFee(address,uint256,address,uint256,address)'( + token: string, + amountMinimum: BigNumberish, + recipient: string, + feeBips: BigNumberish, + feeRecipient: string, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + uniswapV3SwapCallback( + amount0Delta: BigNumberish, + amount1Delta: BigNumberish, + _data: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise; + + 'unwrapWETH9(uint256,address)'( + amountMinimum: BigNumberish, + recipient: string, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + 'unwrapWETH9(uint256)'( + amountMinimum: BigNumberish, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + 'unwrapWETH9WithFee(uint256,address,uint256,address)'( + amountMinimum: BigNumberish, + recipient: string, + feeBips: BigNumberish, + feeRecipient: string, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + 'unwrapWETH9WithFee(uint256,uint256,address)'( + amountMinimum: BigNumberish, + feeBips: BigNumberish, + feeRecipient: string, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + wrapETH(value: BigNumberish, overrides?: PayableOverrides & { from?: string }): Promise; + + callStatic: { + WETH9(overrides?: CallOverrides): Promise; + + approveMax(token: string, overrides?: CallOverrides): Promise; + + approveMaxMinusOne(token: string, overrides?: CallOverrides): Promise; + + approveZeroThenMax(token: string, overrides?: CallOverrides): Promise; + + approveZeroThenMaxMinusOne(token: string, overrides?: CallOverrides): Promise; + + callPositionManager(data: BytesLike, overrides?: CallOverrides): Promise; + + 'checkOracleSlippage(bytes[],uint128[],uint24,uint32)'( + paths: BytesLike[], + amounts: BigNumberish[], + maximumTickDivergence: BigNumberish, + secondsAgo: BigNumberish, + overrides?: CallOverrides + ): Promise; + + 'checkOracleSlippage(bytes,uint24,uint32)'( + path: BytesLike, + maximumTickDivergence: BigNumberish, + secondsAgo: BigNumberish, + overrides?: CallOverrides + ): Promise; + + exactInput(params: IV3SwapRouter.ExactInputParamsStruct, overrides?: CallOverrides): Promise; + + exactInputSingle(params: IV3SwapRouter.ExactInputSingleParamsStruct, overrides?: CallOverrides): Promise; + + exactOutput(params: IV3SwapRouter.ExactOutputParamsStruct, overrides?: CallOverrides): Promise; + + exactOutputSingle( + params: IV3SwapRouter.ExactOutputSingleParamsStruct, + overrides?: CallOverrides + ): Promise; + + factory(overrides?: CallOverrides): Promise; + + factoryV2(overrides?: CallOverrides): Promise; + + getApprovalType(token: string, amount: BigNumberish, overrides?: CallOverrides): Promise; + + increaseLiquidity( + params: IApproveAndCall.IncreaseLiquidityParamsStruct, + overrides?: CallOverrides + ): Promise; + + mint(params: IApproveAndCall.MintParamsStruct, overrides?: CallOverrides): Promise; + + 'multicall(bytes32,bytes[])'( + previousBlockhash: BytesLike, + data: BytesLike[], + overrides?: CallOverrides + ): Promise; + + 'multicall(uint256,bytes[])'( + deadline: BigNumberish, + data: BytesLike[], + overrides?: CallOverrides + ): Promise; + + 'multicall(bytes[])'(data: BytesLike[], overrides?: CallOverrides): Promise; + + positionManager(overrides?: CallOverrides): Promise; + + pull(token: string, value: BigNumberish, overrides?: CallOverrides): Promise; + + refundETH(overrides?: CallOverrides): Promise; + + selfPermit( + token: string, + value: BigNumberish, + deadline: BigNumberish, + v: BigNumberish, + r: BytesLike, + s: BytesLike, + overrides?: CallOverrides + ): Promise; + + selfPermitAllowed( + token: string, + nonce: BigNumberish, + expiry: BigNumberish, + v: BigNumberish, + r: BytesLike, + s: BytesLike, + overrides?: CallOverrides + ): Promise; + + selfPermitAllowedIfNecessary( + token: string, + nonce: BigNumberish, + expiry: BigNumberish, + v: BigNumberish, + r: BytesLike, + s: BytesLike, + overrides?: CallOverrides + ): Promise; + + selfPermitIfNecessary( + token: string, + value: BigNumberish, + deadline: BigNumberish, + v: BigNumberish, + r: BytesLike, + s: BytesLike, + overrides?: CallOverrides + ): Promise; + + 'sweepToken(address,uint256,address)'( + token: string, + amountMinimum: BigNumberish, + recipient: string, + overrides?: CallOverrides + ): Promise; + + 'sweepToken(address,uint256)'(token: string, amountMinimum: BigNumberish, overrides?: CallOverrides): Promise; + + 'sweepTokenWithFee(address,uint256,uint256,address)'( + token: string, + amountMinimum: BigNumberish, + feeBips: BigNumberish, + feeRecipient: string, + overrides?: CallOverrides + ): Promise; + + 'sweepTokenWithFee(address,uint256,address,uint256,address)'( + token: string, + amountMinimum: BigNumberish, + recipient: string, + feeBips: BigNumberish, + feeRecipient: string, + overrides?: CallOverrides + ): Promise; + + uniswapV3SwapCallback( + amount0Delta: BigNumberish, + amount1Delta: BigNumberish, + _data: BytesLike, + overrides?: CallOverrides + ): Promise; + + 'unwrapWETH9(uint256,address)'( + amountMinimum: BigNumberish, + recipient: string, + overrides?: CallOverrides + ): Promise; + + 'unwrapWETH9(uint256)'(amountMinimum: BigNumberish, overrides?: CallOverrides): Promise; + + 'unwrapWETH9WithFee(uint256,address,uint256,address)'( + amountMinimum: BigNumberish, + recipient: string, + feeBips: BigNumberish, + feeRecipient: string, + overrides?: CallOverrides + ): Promise; + + 'unwrapWETH9WithFee(uint256,uint256,address)'( + amountMinimum: BigNumberish, + feeBips: BigNumberish, + feeRecipient: string, + overrides?: CallOverrides + ): Promise; + + wrapETH(value: BigNumberish, overrides?: CallOverrides): Promise; + }; + + filters: {}; + + estimateGas: { + WETH9(overrides?: CallOverrides): Promise; + + approveMax(token: string, overrides?: PayableOverrides & { from?: string }): Promise; + + approveMaxMinusOne(token: string, overrides?: PayableOverrides & { from?: string }): Promise; + + approveZeroThenMax(token: string, overrides?: PayableOverrides & { from?: string }): Promise; + + approveZeroThenMaxMinusOne(token: string, overrides?: PayableOverrides & { from?: string }): Promise; + + callPositionManager(data: BytesLike, overrides?: PayableOverrides & { from?: string }): Promise; + + 'checkOracleSlippage(bytes[],uint128[],uint24,uint32)'( + paths: BytesLike[], + amounts: BigNumberish[], + maximumTickDivergence: BigNumberish, + secondsAgo: BigNumberish, + overrides?: CallOverrides + ): Promise; + + 'checkOracleSlippage(bytes,uint24,uint32)'( + path: BytesLike, + maximumTickDivergence: BigNumberish, + secondsAgo: BigNumberish, + overrides?: CallOverrides + ): Promise; + + exactInput( + params: IV3SwapRouter.ExactInputParamsStruct, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + exactInputSingle( + params: IV3SwapRouter.ExactInputSingleParamsStruct, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + exactOutput( + params: IV3SwapRouter.ExactOutputParamsStruct, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + exactOutputSingle( + params: IV3SwapRouter.ExactOutputSingleParamsStruct, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + factory(overrides?: CallOverrides): Promise; + + factoryV2(overrides?: CallOverrides): Promise; + + getApprovalType(token: string, amount: BigNumberish, overrides?: Overrides & { from?: string }): Promise; + + increaseLiquidity( + params: IApproveAndCall.IncreaseLiquidityParamsStruct, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + mint( + params: IApproveAndCall.MintParamsStruct, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + 'multicall(bytes32,bytes[])'( + previousBlockhash: BytesLike, + data: BytesLike[], + overrides?: PayableOverrides & { from?: string } + ): Promise; + + 'multicall(uint256,bytes[])'( + deadline: BigNumberish, + data: BytesLike[], + overrides?: PayableOverrides & { from?: string } + ): Promise; + + 'multicall(bytes[])'(data: BytesLike[], overrides?: PayableOverrides & { from?: string }): Promise; + + positionManager(overrides?: CallOverrides): Promise; + + pull(token: string, value: BigNumberish, overrides?: PayableOverrides & { from?: string }): Promise; + + refundETH(overrides?: PayableOverrides & { from?: string }): Promise; + + selfPermit( + token: string, + value: BigNumberish, + deadline: BigNumberish, + v: BigNumberish, + r: BytesLike, + s: BytesLike, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + selfPermitAllowed( + token: string, + nonce: BigNumberish, + expiry: BigNumberish, + v: BigNumberish, + r: BytesLike, + s: BytesLike, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + selfPermitAllowedIfNecessary( + token: string, + nonce: BigNumberish, + expiry: BigNumberish, + v: BigNumberish, + r: BytesLike, + s: BytesLike, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + selfPermitIfNecessary( + token: string, + value: BigNumberish, + deadline: BigNumberish, + v: BigNumberish, + r: BytesLike, + s: BytesLike, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + 'sweepToken(address,uint256,address)'( + token: string, + amountMinimum: BigNumberish, + recipient: string, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + 'sweepToken(address,uint256)'( + token: string, + amountMinimum: BigNumberish, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + 'sweepTokenWithFee(address,uint256,uint256,address)'( + token: string, + amountMinimum: BigNumberish, + feeBips: BigNumberish, + feeRecipient: string, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + 'sweepTokenWithFee(address,uint256,address,uint256,address)'( + token: string, + amountMinimum: BigNumberish, + recipient: string, + feeBips: BigNumberish, + feeRecipient: string, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + uniswapV3SwapCallback( + amount0Delta: BigNumberish, + amount1Delta: BigNumberish, + _data: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise; + + 'unwrapWETH9(uint256,address)'( + amountMinimum: BigNumberish, + recipient: string, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + 'unwrapWETH9(uint256)'( + amountMinimum: BigNumberish, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + 'unwrapWETH9WithFee(uint256,address,uint256,address)'( + amountMinimum: BigNumberish, + recipient: string, + feeBips: BigNumberish, + feeRecipient: string, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + 'unwrapWETH9WithFee(uint256,uint256,address)'( + amountMinimum: BigNumberish, + feeBips: BigNumberish, + feeRecipient: string, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + wrapETH(value: BigNumberish, overrides?: PayableOverrides & { from?: string }): Promise; + }; + + populateTransaction: { + WETH9(overrides?: CallOverrides): Promise; + + approveMax(token: string, overrides?: PayableOverrides & { from?: string }): Promise; + + approveMaxMinusOne(token: string, overrides?: PayableOverrides & { from?: string }): Promise; + + approveZeroThenMax(token: string, overrides?: PayableOverrides & { from?: string }): Promise; + + approveZeroThenMaxMinusOne( + token: string, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + callPositionManager( + data: BytesLike, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + 'checkOracleSlippage(bytes[],uint128[],uint24,uint32)'( + paths: BytesLike[], + amounts: BigNumberish[], + maximumTickDivergence: BigNumberish, + secondsAgo: BigNumberish, + overrides?: CallOverrides + ): Promise; + + 'checkOracleSlippage(bytes,uint24,uint32)'( + path: BytesLike, + maximumTickDivergence: BigNumberish, + secondsAgo: BigNumberish, + overrides?: CallOverrides + ): Promise; + + exactInput( + params: IV3SwapRouter.ExactInputParamsStruct, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + exactInputSingle( + params: IV3SwapRouter.ExactInputSingleParamsStruct, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + exactOutput( + params: IV3SwapRouter.ExactOutputParamsStruct, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + exactOutputSingle( + params: IV3SwapRouter.ExactOutputSingleParamsStruct, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + factory(overrides?: CallOverrides): Promise; + + factoryV2(overrides?: CallOverrides): Promise; + + getApprovalType( + token: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + increaseLiquidity( + params: IApproveAndCall.IncreaseLiquidityParamsStruct, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + mint( + params: IApproveAndCall.MintParamsStruct, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + 'multicall(bytes32,bytes[])'( + previousBlockhash: BytesLike, + data: BytesLike[], + overrides?: PayableOverrides & { from?: string } + ): Promise; + + 'multicall(uint256,bytes[])'( + deadline: BigNumberish, + data: BytesLike[], + overrides?: PayableOverrides & { from?: string } + ): Promise; + + 'multicall(bytes[])'( + data: BytesLike[], + overrides?: PayableOverrides & { from?: string } + ): Promise; + + positionManager(overrides?: CallOverrides): Promise; + + pull( + token: string, + value: BigNumberish, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + refundETH(overrides?: PayableOverrides & { from?: string }): Promise; + + selfPermit( + token: string, + value: BigNumberish, + deadline: BigNumberish, + v: BigNumberish, + r: BytesLike, + s: BytesLike, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + selfPermitAllowed( + token: string, + nonce: BigNumberish, + expiry: BigNumberish, + v: BigNumberish, + r: BytesLike, + s: BytesLike, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + selfPermitAllowedIfNecessary( + token: string, + nonce: BigNumberish, + expiry: BigNumberish, + v: BigNumberish, + r: BytesLike, + s: BytesLike, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + selfPermitIfNecessary( + token: string, + value: BigNumberish, + deadline: BigNumberish, + v: BigNumberish, + r: BytesLike, + s: BytesLike, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + 'sweepToken(address,uint256,address)'( + token: string, + amountMinimum: BigNumberish, + recipient: string, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + 'sweepToken(address,uint256)'( + token: string, + amountMinimum: BigNumberish, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + 'sweepTokenWithFee(address,uint256,uint256,address)'( + token: string, + amountMinimum: BigNumberish, + feeBips: BigNumberish, + feeRecipient: string, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + 'sweepTokenWithFee(address,uint256,address,uint256,address)'( + token: string, + amountMinimum: BigNumberish, + recipient: string, + feeBips: BigNumberish, + feeRecipient: string, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + uniswapV3SwapCallback( + amount0Delta: BigNumberish, + amount1Delta: BigNumberish, + _data: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise; + + 'unwrapWETH9(uint256,address)'( + amountMinimum: BigNumberish, + recipient: string, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + 'unwrapWETH9(uint256)'( + amountMinimum: BigNumberish, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + 'unwrapWETH9WithFee(uint256,address,uint256,address)'( + amountMinimum: BigNumberish, + recipient: string, + feeBips: BigNumberish, + feeRecipient: string, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + 'unwrapWETH9WithFee(uint256,uint256,address)'( + amountMinimum: BigNumberish, + feeBips: BigNumberish, + feeRecipient: string, + overrides?: PayableOverrides & { from?: string } + ): Promise; + + wrapETH(value: BigNumberish, overrides?: PayableOverrides & { from?: string }): Promise; + }; +} diff --git a/src/logics/wagmi/contracts/UniswapV3Factory.ts b/src/logics/wagmi/contracts/UniswapV3Factory.ts new file mode 100644 index 00000000..88342cc8 --- /dev/null +++ b/src/logics/wagmi/contracts/UniswapV3Factory.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 UniswapV3FactoryInterface extends utils.Interface { + functions: { + 'createPool(address,address,uint24)': FunctionFragment; + 'enableFeeAmount(uint24,int24)': FunctionFragment; + 'feeAmountTickSpacing(uint24)': FunctionFragment; + 'getPool(address,address,uint24)': FunctionFragment; + 'owner()': FunctionFragment; + 'parameters()': FunctionFragment; + 'setOwner(address)': FunctionFragment; + }; + + getFunction( + nameOrSignatureOrTopic: + | 'createPool' + | 'enableFeeAmount' + | 'feeAmountTickSpacing' + | 'getPool' + | 'owner' + | 'parameters' + | 'setOwner' + ): FunctionFragment; + + encodeFunctionData(functionFragment: 'createPool', values: [string, string, BigNumberish]): string; + encodeFunctionData(functionFragment: 'enableFeeAmount', values: [BigNumberish, BigNumberish]): string; + encodeFunctionData(functionFragment: 'feeAmountTickSpacing', values: [BigNumberish]): string; + encodeFunctionData(functionFragment: 'getPool', values: [string, string, BigNumberish]): string; + encodeFunctionData(functionFragment: 'owner', values?: undefined): string; + encodeFunctionData(functionFragment: 'parameters', values?: undefined): string; + encodeFunctionData(functionFragment: 'setOwner', values: [string]): string; + + decodeFunctionResult(functionFragment: 'createPool', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'enableFeeAmount', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'feeAmountTickSpacing', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'getPool', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'owner', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'parameters', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'setOwner', data: BytesLike): Result; + + events: { + 'FeeAmountEnabled(uint24,int24)': EventFragment; + 'OwnerChanged(address,address)': EventFragment; + 'PoolCreated(address,address,uint24,int24,address)': EventFragment; + }; + + getEvent(nameOrSignatureOrTopic: 'FeeAmountEnabled'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'OwnerChanged'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'PoolCreated'): EventFragment; +} + +export interface FeeAmountEnabledEventObject { + fee: number; + tickSpacing: number; +} +export type FeeAmountEnabledEvent = TypedEvent<[number, number], FeeAmountEnabledEventObject>; + +export type FeeAmountEnabledEventFilter = TypedEventFilter; + +export interface OwnerChangedEventObject { + oldOwner: string; + newOwner: string; +} +export type OwnerChangedEvent = TypedEvent<[string, string], OwnerChangedEventObject>; + +export type OwnerChangedEventFilter = TypedEventFilter; + +export interface PoolCreatedEventObject { + token0: string; + token1: string; + fee: number; + tickSpacing: number; + pool: string; +} +export type PoolCreatedEvent = TypedEvent<[string, string, number, number, string], PoolCreatedEventObject>; + +export type PoolCreatedEventFilter = TypedEventFilter; + +export interface UniswapV3Factory extends BaseContract { + connect(signerOrProvider: Signer | Provider | string): this; + attach(addressOrName: string): this; + deployed(): Promise; + + interface: UniswapV3FactoryInterface; + + 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: { + createPool( + tokenA: string, + tokenB: string, + fee: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + enableFeeAmount( + fee: BigNumberish, + tickSpacing: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + feeAmountTickSpacing(arg0: BigNumberish, overrides?: CallOverrides): Promise<[number]>; + + getPool(arg0: string, arg1: string, arg2: BigNumberish, overrides?: CallOverrides): Promise<[string]>; + + owner(overrides?: CallOverrides): Promise<[string]>; + + parameters(overrides?: CallOverrides): Promise< + [string, string, string, number, number] & { + factory: string; + token0: string; + token1: string; + fee: number; + tickSpacing: number; + } + >; + + setOwner(_owner: string, overrides?: Overrides & { from?: string }): Promise; + }; + + createPool( + tokenA: string, + tokenB: string, + fee: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + enableFeeAmount( + fee: BigNumberish, + tickSpacing: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + feeAmountTickSpacing(arg0: BigNumberish, overrides?: CallOverrides): Promise; + + getPool(arg0: string, arg1: string, arg2: BigNumberish, overrides?: CallOverrides): Promise; + + owner(overrides?: CallOverrides): Promise; + + parameters(overrides?: CallOverrides): Promise< + [string, string, string, number, number] & { + factory: string; + token0: string; + token1: string; + fee: number; + tickSpacing: number; + } + >; + + setOwner(_owner: string, overrides?: Overrides & { from?: string }): Promise; + + callStatic: { + createPool(tokenA: string, tokenB: string, fee: BigNumberish, overrides?: CallOverrides): Promise; + + enableFeeAmount(fee: BigNumberish, tickSpacing: BigNumberish, overrides?: CallOverrides): Promise; + + feeAmountTickSpacing(arg0: BigNumberish, overrides?: CallOverrides): Promise; + + getPool(arg0: string, arg1: string, arg2: BigNumberish, overrides?: CallOverrides): Promise; + + owner(overrides?: CallOverrides): Promise; + + parameters(overrides?: CallOverrides): Promise< + [string, string, string, number, number] & { + factory: string; + token0: string; + token1: string; + fee: number; + tickSpacing: number; + } + >; + + setOwner(_owner: string, overrides?: CallOverrides): Promise; + }; + + filters: { + 'FeeAmountEnabled(uint24,int24)'( + fee?: BigNumberish | null, + tickSpacing?: BigNumberish | null + ): FeeAmountEnabledEventFilter; + FeeAmountEnabled(fee?: BigNumberish | null, tickSpacing?: BigNumberish | null): FeeAmountEnabledEventFilter; + + 'OwnerChanged(address,address)'(oldOwner?: string | null, newOwner?: string | null): OwnerChangedEventFilter; + OwnerChanged(oldOwner?: string | null, newOwner?: string | null): OwnerChangedEventFilter; + + 'PoolCreated(address,address,uint24,int24,address)'( + token0?: string | null, + token1?: string | null, + fee?: BigNumberish | null, + tickSpacing?: null, + pool?: null + ): PoolCreatedEventFilter; + PoolCreated( + token0?: string | null, + token1?: string | null, + fee?: BigNumberish | null, + tickSpacing?: null, + pool?: null + ): PoolCreatedEventFilter; + }; + + estimateGas: { + createPool( + tokenA: string, + tokenB: string, + fee: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + enableFeeAmount( + fee: BigNumberish, + tickSpacing: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + feeAmountTickSpacing(arg0: BigNumberish, overrides?: CallOverrides): Promise; + + getPool(arg0: string, arg1: string, arg2: BigNumberish, overrides?: CallOverrides): Promise; + + owner(overrides?: CallOverrides): Promise; + + parameters(overrides?: CallOverrides): Promise; + + setOwner(_owner: string, overrides?: Overrides & { from?: string }): Promise; + }; + + populateTransaction: { + createPool( + tokenA: string, + tokenB: string, + fee: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + enableFeeAmount( + fee: BigNumberish, + tickSpacing: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + feeAmountTickSpacing(arg0: BigNumberish, overrides?: CallOverrides): Promise; + + getPool(arg0: string, arg1: string, arg2: BigNumberish, overrides?: CallOverrides): Promise; + + owner(overrides?: CallOverrides): Promise; + + parameters(overrides?: CallOverrides): Promise; + + setOwner(_owner: string, overrides?: Overrides & { from?: string }): Promise; + }; +} diff --git a/src/logics/wagmi/contracts/common.ts b/src/logics/wagmi/contracts/common.ts new file mode 100644 index 00000000..6cfb1042 --- /dev/null +++ b/src/logics/wagmi/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/wagmi/contracts/factories/SwapRouter02__factory.ts b/src/logics/wagmi/contracts/factories/SwapRouter02__factory.ts new file mode 100644 index 00000000..53983927 --- /dev/null +++ b/src/logics/wagmi/contracts/factories/SwapRouter02__factory.ts @@ -0,0 +1,1013 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ + +import { Contract, Signer, utils } from 'ethers'; +import type { Provider } from '@ethersproject/providers'; +import type { SwapRouter02, SwapRouter02Interface } from '../SwapRouter02'; + +const _abi = [ + { + inputs: [ + { + internalType: 'address', + name: '_factoryV2', + type: 'address', + }, + { + internalType: 'address', + name: 'factoryV3', + type: 'address', + }, + { + internalType: 'address', + name: '_positionManager', + type: 'address', + }, + { + internalType: 'address', + name: '_WETH9', + type: 'address', + }, + ], + stateMutability: 'nonpayable', + type: 'constructor', + }, + { + inputs: [], + name: 'WETH9', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'token', + type: 'address', + }, + ], + name: 'approveMax', + outputs: [], + stateMutability: 'payable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'token', + type: 'address', + }, + ], + name: 'approveMaxMinusOne', + outputs: [], + stateMutability: 'payable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'token', + type: 'address', + }, + ], + name: 'approveZeroThenMax', + outputs: [], + stateMutability: 'payable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'token', + type: 'address', + }, + ], + name: 'approveZeroThenMaxMinusOne', + outputs: [], + stateMutability: 'payable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'bytes', + name: 'data', + type: 'bytes', + }, + ], + name: 'callPositionManager', + outputs: [ + { + internalType: 'bytes', + name: 'result', + type: 'bytes', + }, + ], + stateMutability: 'payable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'bytes[]', + name: 'paths', + type: 'bytes[]', + }, + { + internalType: 'uint128[]', + name: 'amounts', + type: 'uint128[]', + }, + { + internalType: 'uint24', + name: 'maximumTickDivergence', + type: 'uint24', + }, + { + internalType: 'uint32', + name: 'secondsAgo', + type: 'uint32', + }, + ], + name: 'checkOracleSlippage', + outputs: [], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'bytes', + name: 'path', + type: 'bytes', + }, + { + internalType: 'uint24', + name: 'maximumTickDivergence', + type: 'uint24', + }, + { + internalType: 'uint32', + name: 'secondsAgo', + type: 'uint32', + }, + ], + name: 'checkOracleSlippage', + outputs: [], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + components: [ + { + internalType: 'bytes', + name: 'path', + type: 'bytes', + }, + { + internalType: 'address', + name: 'recipient', + type: 'address', + }, + { + internalType: 'uint256', + name: 'amountIn', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'amountOutMinimum', + type: 'uint256', + }, + ], + internalType: 'struct IV3SwapRouter.ExactInputParams', + name: 'params', + type: 'tuple', + }, + ], + name: 'exactInput', + outputs: [ + { + internalType: 'uint256', + name: 'amountOut', + type: 'uint256', + }, + ], + stateMutability: 'payable', + type: 'function', + }, + { + inputs: [ + { + components: [ + { + internalType: 'address', + name: 'tokenIn', + type: 'address', + }, + { + internalType: 'address', + name: 'tokenOut', + type: 'address', + }, + { + internalType: 'uint24', + name: 'fee', + type: 'uint24', + }, + { + internalType: 'address', + name: 'recipient', + type: 'address', + }, + { + internalType: 'uint256', + name: 'amountIn', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'amountOutMinimum', + type: 'uint256', + }, + { + internalType: 'uint160', + name: 'sqrtPriceLimitX96', + type: 'uint160', + }, + ], + internalType: 'struct IV3SwapRouter.ExactInputSingleParams', + name: 'params', + type: 'tuple', + }, + ], + name: 'exactInputSingle', + outputs: [ + { + internalType: 'uint256', + name: 'amountOut', + type: 'uint256', + }, + ], + stateMutability: 'payable', + type: 'function', + }, + { + inputs: [ + { + components: [ + { + internalType: 'bytes', + name: 'path', + type: 'bytes', + }, + { + internalType: 'address', + name: 'recipient', + type: 'address', + }, + { + internalType: 'uint256', + name: 'amountOut', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'amountInMaximum', + type: 'uint256', + }, + ], + internalType: 'struct IV3SwapRouter.ExactOutputParams', + name: 'params', + type: 'tuple', + }, + ], + name: 'exactOutput', + outputs: [ + { + internalType: 'uint256', + name: 'amountIn', + type: 'uint256', + }, + ], + stateMutability: 'payable', + type: 'function', + }, + { + inputs: [ + { + components: [ + { + internalType: 'address', + name: 'tokenIn', + type: 'address', + }, + { + internalType: 'address', + name: 'tokenOut', + type: 'address', + }, + { + internalType: 'uint24', + name: 'fee', + type: 'uint24', + }, + { + internalType: 'address', + name: 'recipient', + type: 'address', + }, + { + internalType: 'uint256', + name: 'amountOut', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'amountInMaximum', + type: 'uint256', + }, + { + internalType: 'uint160', + name: 'sqrtPriceLimitX96', + type: 'uint160', + }, + ], + internalType: 'struct IV3SwapRouter.ExactOutputSingleParams', + name: 'params', + type: 'tuple', + }, + ], + name: 'exactOutputSingle', + outputs: [ + { + internalType: 'uint256', + name: 'amountIn', + type: 'uint256', + }, + ], + stateMutability: 'payable', + type: 'function', + }, + { + inputs: [], + name: 'factory', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'factoryV2', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'token', + type: 'address', + }, + { + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + ], + name: 'getApprovalType', + outputs: [ + { + internalType: 'enum IApproveAndCall.ApprovalType', + name: '', + type: 'uint8', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + components: [ + { + internalType: 'address', + name: 'token0', + type: 'address', + }, + { + internalType: 'address', + name: 'token1', + type: 'address', + }, + { + internalType: 'uint256', + name: 'tokenId', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'amount0Min', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'amount1Min', + type: 'uint256', + }, + ], + internalType: 'struct IApproveAndCall.IncreaseLiquidityParams', + name: 'params', + type: 'tuple', + }, + ], + name: 'increaseLiquidity', + outputs: [ + { + internalType: 'bytes', + name: 'result', + type: 'bytes', + }, + ], + stateMutability: 'payable', + type: 'function', + }, + { + inputs: [ + { + components: [ + { + internalType: 'address', + name: 'token0', + type: 'address', + }, + { + internalType: 'address', + name: 'token1', + type: 'address', + }, + { + internalType: 'uint24', + name: 'fee', + type: 'uint24', + }, + { + internalType: 'int24', + name: 'tickLower', + type: 'int24', + }, + { + internalType: 'int24', + name: 'tickUpper', + type: 'int24', + }, + { + internalType: 'uint256', + name: 'amount0Min', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'amount1Min', + type: 'uint256', + }, + { + internalType: 'address', + name: 'recipient', + type: 'address', + }, + ], + internalType: 'struct IApproveAndCall.MintParams', + name: 'params', + type: 'tuple', + }, + ], + name: 'mint', + outputs: [ + { + internalType: 'bytes', + name: 'result', + type: 'bytes', + }, + ], + stateMutability: 'payable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'bytes32', + name: 'previousBlockhash', + type: 'bytes32', + }, + { + internalType: 'bytes[]', + name: 'data', + type: 'bytes[]', + }, + ], + name: 'multicall', + outputs: [ + { + internalType: 'bytes[]', + name: '', + type: 'bytes[]', + }, + ], + stateMutability: 'payable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: 'deadline', + type: 'uint256', + }, + { + internalType: 'bytes[]', + name: 'data', + type: 'bytes[]', + }, + ], + name: 'multicall', + outputs: [ + { + internalType: 'bytes[]', + name: '', + type: 'bytes[]', + }, + ], + stateMutability: 'payable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'bytes[]', + name: 'data', + type: 'bytes[]', + }, + ], + name: 'multicall', + outputs: [ + { + internalType: 'bytes[]', + name: 'results', + type: 'bytes[]', + }, + ], + stateMutability: 'payable', + type: 'function', + }, + { + inputs: [], + name: 'positionManager', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'token', + type: 'address', + }, + { + internalType: 'uint256', + name: 'value', + type: 'uint256', + }, + ], + name: 'pull', + outputs: [], + stateMutability: 'payable', + type: 'function', + }, + { + inputs: [], + name: 'refundETH', + outputs: [], + stateMutability: 'payable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'token', + 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: 'selfPermit', + outputs: [], + stateMutability: 'payable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'token', + type: 'address', + }, + { + internalType: 'uint256', + name: 'nonce', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'expiry', + type: 'uint256', + }, + { + internalType: 'uint8', + name: 'v', + type: 'uint8', + }, + { + internalType: 'bytes32', + name: 'r', + type: 'bytes32', + }, + { + internalType: 'bytes32', + name: 's', + type: 'bytes32', + }, + ], + name: 'selfPermitAllowed', + outputs: [], + stateMutability: 'payable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'token', + type: 'address', + }, + { + internalType: 'uint256', + name: 'nonce', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'expiry', + type: 'uint256', + }, + { + internalType: 'uint8', + name: 'v', + type: 'uint8', + }, + { + internalType: 'bytes32', + name: 'r', + type: 'bytes32', + }, + { + internalType: 'bytes32', + name: 's', + type: 'bytes32', + }, + ], + name: 'selfPermitAllowedIfNecessary', + outputs: [], + stateMutability: 'payable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'token', + 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: 'selfPermitIfNecessary', + outputs: [], + stateMutability: 'payable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'token', + type: 'address', + }, + { + internalType: 'uint256', + name: 'amountMinimum', + type: 'uint256', + }, + { + internalType: 'address', + name: 'recipient', + type: 'address', + }, + ], + name: 'sweepToken', + outputs: [], + stateMutability: 'payable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'token', + type: 'address', + }, + { + internalType: 'uint256', + name: 'amountMinimum', + type: 'uint256', + }, + ], + name: 'sweepToken', + outputs: [], + stateMutability: 'payable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'token', + type: 'address', + }, + { + internalType: 'uint256', + name: 'amountMinimum', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'feeBips', + type: 'uint256', + }, + { + internalType: 'address', + name: 'feeRecipient', + type: 'address', + }, + ], + name: 'sweepTokenWithFee', + outputs: [], + stateMutability: 'payable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'token', + type: 'address', + }, + { + internalType: 'uint256', + name: 'amountMinimum', + type: 'uint256', + }, + { + internalType: 'address', + name: 'recipient', + type: 'address', + }, + { + internalType: 'uint256', + name: 'feeBips', + type: 'uint256', + }, + { + internalType: 'address', + name: 'feeRecipient', + type: 'address', + }, + ], + name: 'sweepTokenWithFee', + outputs: [], + stateMutability: 'payable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'int256', + name: 'amount0Delta', + type: 'int256', + }, + { + internalType: 'int256', + name: 'amount1Delta', + type: 'int256', + }, + { + internalType: 'bytes', + name: '_data', + type: 'bytes', + }, + ], + name: 'uniswapV3SwapCallback', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: 'amountMinimum', + type: 'uint256', + }, + { + internalType: 'address', + name: 'recipient', + type: 'address', + }, + ], + name: 'unwrapWETH9', + outputs: [], + stateMutability: 'payable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: 'amountMinimum', + type: 'uint256', + }, + ], + name: 'unwrapWETH9', + outputs: [], + stateMutability: 'payable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: 'amountMinimum', + type: 'uint256', + }, + { + internalType: 'address', + name: 'recipient', + type: 'address', + }, + { + internalType: 'uint256', + name: 'feeBips', + type: 'uint256', + }, + { + internalType: 'address', + name: 'feeRecipient', + type: 'address', + }, + ], + name: 'unwrapWETH9WithFee', + outputs: [], + stateMutability: 'payable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: 'amountMinimum', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'feeBips', + type: 'uint256', + }, + { + internalType: 'address', + name: 'feeRecipient', + type: 'address', + }, + ], + name: 'unwrapWETH9WithFee', + outputs: [], + stateMutability: 'payable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: 'value', + type: 'uint256', + }, + ], + name: 'wrapETH', + outputs: [], + stateMutability: 'payable', + type: 'function', + }, + { + stateMutability: 'payable', + type: 'receive', + }, +] as const; + +export class SwapRouter02__factory { + static readonly abi = _abi; + static createInterface(): SwapRouter02Interface { + return new utils.Interface(_abi) as SwapRouter02Interface; + } + static connect(address: string, signerOrProvider: Signer | Provider): SwapRouter02 { + return new Contract(address, _abi, signerOrProvider) as SwapRouter02; + } +} diff --git a/src/logics/wagmi/contracts/factories/UniswapV3Factory__factory.ts b/src/logics/wagmi/contracts/factories/UniswapV3Factory__factory.ts new file mode 100644 index 00000000..08528dec --- /dev/null +++ b/src/logics/wagmi/contracts/factories/UniswapV3Factory__factory.ts @@ -0,0 +1,254 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ + +import { Contract, Signer, utils } from 'ethers'; +import type { Provider } from '@ethersproject/providers'; +import type { UniswapV3Factory, UniswapV3FactoryInterface } from '../UniswapV3Factory'; + +const _abi = [ + { + inputs: [], + stateMutability: 'nonpayable', + type: 'constructor', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'uint24', + name: 'fee', + type: 'uint24', + }, + { + indexed: true, + internalType: 'int24', + name: 'tickSpacing', + type: 'int24', + }, + ], + name: 'FeeAmountEnabled', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'oldOwner', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'newOwner', + type: 'address', + }, + ], + name: 'OwnerChanged', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'token0', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'token1', + type: 'address', + }, + { + indexed: true, + internalType: 'uint24', + name: 'fee', + type: 'uint24', + }, + { + indexed: false, + internalType: 'int24', + name: 'tickSpacing', + type: 'int24', + }, + { + indexed: false, + internalType: 'address', + name: 'pool', + type: 'address', + }, + ], + name: 'PoolCreated', + type: 'event', + }, + { + inputs: [ + { + internalType: 'address', + name: 'tokenA', + type: 'address', + }, + { + internalType: 'address', + name: 'tokenB', + type: 'address', + }, + { + internalType: 'uint24', + name: 'fee', + type: 'uint24', + }, + ], + name: 'createPool', + outputs: [ + { + internalType: 'address', + name: 'pool', + type: 'address', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint24', + name: 'fee', + type: 'uint24', + }, + { + internalType: 'int24', + name: 'tickSpacing', + type: 'int24', + }, + ], + name: 'enableFeeAmount', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint24', + name: '', + type: 'uint24', + }, + ], + name: 'feeAmountTickSpacing', + outputs: [ + { + internalType: 'int24', + name: '', + type: 'int24', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + { + internalType: 'address', + name: '', + type: 'address', + }, + { + internalType: 'uint24', + name: '', + type: 'uint24', + }, + ], + name: 'getPool', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'owner', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'parameters', + outputs: [ + { + internalType: 'address', + name: 'factory', + type: 'address', + }, + { + internalType: 'address', + name: 'token0', + type: 'address', + }, + { + internalType: 'address', + name: 'token1', + type: 'address', + }, + { + internalType: 'uint24', + name: 'fee', + type: 'uint24', + }, + { + internalType: 'int24', + name: 'tickSpacing', + type: 'int24', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: '_owner', + type: 'address', + }, + ], + name: 'setOwner', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, +] as const; + +export class UniswapV3Factory__factory { + static readonly abi = _abi; + static createInterface(): UniswapV3FactoryInterface { + return new utils.Interface(_abi) as UniswapV3FactoryInterface; + } + static connect(address: string, signerOrProvider: Signer | Provider): UniswapV3Factory { + return new Contract(address, _abi, signerOrProvider) as UniswapV3Factory; + } +} diff --git a/src/logics/wagmi/contracts/factories/index.ts b/src/logics/wagmi/contracts/factories/index.ts new file mode 100644 index 00000000..4285c012 --- /dev/null +++ b/src/logics/wagmi/contracts/factories/index.ts @@ -0,0 +1,5 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +export { SwapRouter02__factory } from './SwapRouter02__factory'; +export { UniswapV3Factory__factory } from './UniswapV3Factory__factory'; diff --git a/src/logics/wagmi/contracts/index.ts b/src/logics/wagmi/contracts/index.ts new file mode 100644 index 00000000..47c2b79d --- /dev/null +++ b/src/logics/wagmi/contracts/index.ts @@ -0,0 +1,8 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +export type { SwapRouter02 } from './SwapRouter02'; +export type { UniswapV3Factory } from './UniswapV3Factory'; +export * as factories from './factories'; +export { SwapRouter02__factory } from './factories/SwapRouter02__factory'; +export { UniswapV3Factory__factory } from './factories/UniswapV3Factory__factory'; diff --git a/src/logics/wagmi/index.ts b/src/logics/wagmi/index.ts new file mode 100644 index 00000000..78d94ba9 --- /dev/null +++ b/src/logics/wagmi/index.ts @@ -0,0 +1,3 @@ +export * from './configs'; +export * from './logic.swap-token'; +export * from './tokens'; diff --git a/src/logics/wagmi/logic.swap-token.test.ts b/src/logics/wagmi/logic.swap-token.test.ts new file mode 100644 index 00000000..5752833a --- /dev/null +++ b/src/logics/wagmi/logic.swap-token.test.ts @@ -0,0 +1,148 @@ +import { LogicTestCase } from 'test/types'; +import { SwapRouter02__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 { getConfig } from './configs'; +import * as univ3 from 'src/modules/univ3'; + +describe('Wagmi SwapTokenLogic', function () { + 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 chainId = common.ChainId.iota; + const config = getConfig(chainId); + const logic = new SwapTokenLogic(chainId); + const iface = SwapRouter02__factory.createInterface(); + + const testCases: LogicTestCase[] = [ + { + fields: { + tradeType: core.TradeType.exactIn, + input: new common.TokenAmount(common.iotaTokens.IOTA, '100'), + output: new common.TokenAmount(common.iotaTokens.USDT, '13.7665'), + fee: 500, + slippage: 100, + }, + options: { account: '0xaAaAaAaaAaAaAaaAaAAAAAAAAaaaAaAaAaaAaaAa' }, + }, + { + fields: { + tradeType: core.TradeType.exactIn, + input: new common.TokenAmount(common.iotaTokens.IOTA, '100'), + output: new common.TokenAmount(common.iotaTokens.USDT, '13.7665'), + path: '0x6e47f8d48a01b44df3fff35d258a10a3aedc114c0001f4160345fc359604fc6e70e3c5facbde5f7a9342d80001f4c1b8045a6ef2934cf0f78b0dbd489969fa9be7e4', + slippage: 100, + }, + options: { account: '0xaAaAaAaaAaAaAaaAaAAAAAAAAaaaAaAaAaaAaaAa' }, + }, + { + fields: { + tradeType: core.TradeType.exactIn, + input: new common.TokenAmount(common.iotaTokens.USDT, '100'), + output: new common.TokenAmount(common.iotaTokens.IOTA, '785.62'), + fee: 500, + slippage: 100, + }, + options: { account: '0xaAaAaAaaAaAaAaaAaAAAAAAAAaaaAaAaAaaAaaAa' }, + }, + { + fields: { + tradeType: core.TradeType.exactIn, + input: new common.TokenAmount(common.iotaTokens.USDT, '100'), + output: new common.TokenAmount(common.iotaTokens.IOTA, '785.62'), + path: '0xc1b8045a6ef2934cf0f78b0dbd489969fa9be7e40001f4160345fc359604fc6e70e3c5facbde5f7a9342d80001f46e47f8d48a01b44df3fff35d258a10a3aedc114c', + slippage: 100, + }, + options: { account: '0xaAaAaAaaAaAaAaaAaAAAAAAAAaaaAaAaAaaAaaAa' }, + }, + { + fields: { + tradeType: core.TradeType.exactOut, + input: new common.TokenAmount(common.iotaTokens.IOTA, '100'), + output: new common.TokenAmount(common.iotaTokens.USDT, '13.7665'), + fee: 500, + slippage: 100, + }, + options: { account: '0xaAaAaAaaAaAaAaaAaAAAAAAAAaaaAaAaAaaAaaAa' }, + }, + { + fields: { + tradeType: core.TradeType.exactOut, + input: new common.TokenAmount(common.iotaTokens.IOTA, '100'), + output: new common.TokenAmount(common.iotaTokens.USDT, '13.7665'), + path: '0x6e47f8d48a01b44df3fff35d258a10a3aedc114c0001f4160345fc359604fc6e70e3c5facbde5f7a9342d80001f4c1b8045a6ef2934cf0f78b0dbd489969fa9be7e4', + slippage: 100, + }, + options: { account: '0xaAaAaAaaAaAaAaaAaAAAAAAAAaaaAaAaAaaAaaAa' }, + }, + { + fields: { + tradeType: core.TradeType.exactOut, + input: new common.TokenAmount(common.iotaTokens.USDT, '100'), + output: new common.TokenAmount(common.iotaTokens.IOTA, '785.62'), + fee: 500, + slippage: 100, + }, + options: { account: '0xaAaAaAaaAaAaAaaAaAAAAAAAAaaaAaAaAaaAaaAa' }, + }, + { + fields: { + tradeType: core.TradeType.exactOut, + input: new common.TokenAmount(common.iotaTokens.USDT, '100'), + output: new common.TokenAmount(common.iotaTokens.IOTA, '785.62'), + path: '0xc1b8045a6ef2934cf0f78b0dbd489969fa9be7e40001f4160345fc359604fc6e70e3c5facbde5f7a9342d80001f46e47f8d48a01b44df3fff35d258a10a3aedc114c', + slippage: 100, + }, + options: { account: '0xaAaAaAaaAaAaAaaAaAAAAAAAAaaaAaAaAaaAaaAa' }, + }, + ]; + + testCases.forEach(({ fields, options }) => { + it(`${fields.input.token.symbol} to ${fields.output.token.symbol} ${fields.tradeType} ${ + univ3.isSwapTokenLogicSingleHopFields(fields) ? 'Single' : '' + }`, async function () { + const routerLogic = await logic.build(fields, options); + const sig = routerLogic.data.substring(0, 10); + const { tradeType, input, output, balanceBps } = fields; + + expect(routerLogic.to).to.eq(config.swapRouterAddress); + expect(utils.isBytesLike(routerLogic.data)).to.be.true; + expect(sig).to.eq( + iface.getSighash( + `exact${tradeType === core.TradeType.exactIn ? 'Input' : 'Output'}${ + univ3.isSwapTokenLogicSingleHopFields(fields) ? 'Single' : '' + }` + ) + ); + 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(1)); + } 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/wagmi/logic.swap-token.ts b/src/logics/wagmi/logic.swap-token.ts new file mode 100644 index 00000000..a7a99429 --- /dev/null +++ b/src/logics/wagmi/logic.swap-token.ts @@ -0,0 +1,87 @@ +import { BigNumber, constants, providers } from 'ethers'; +import { FeeAmount } from '@uniswap/v3-sdk'; +import { Token } from '@uniswap/sdk-core'; +import { TokenList } from '@uniswap/token-lists'; +import { UniswapV3Factory__factory } from './contracts'; +import { axios } from 'src/utils'; +import * as common from '@protocolink/common'; +import * as core from '@protocolink/core'; +import { getConfig, supportedChainIds } from './configs'; +import * as univ3 from 'src/modules/univ3'; + +export type SwapTokenLogicTokenList = common.Token[]; + +export type SwapTokenLogicParams = univ3.SwapTokenLogicParams; + +export type SwapTokenLogicFields = univ3.SwapTokenLogicFields; + +export type SwapTokenLogicOptions = univ3.SwapTokenLogicOptions; + +export class SwapTokenLogic + extends univ3.SwapTokenLogic + implements core.LogicTokenListInterface, core.LogicOracleInterface, core.LogicBuilderInterface +{ + static id = 'swap-token'; + static protocolId = 'wagmi'; + static readonly supportedChainIds = supportedChainIds; + + constructor(chainId: number, provider?: providers.Provider) { + super({ chainId, provider, config: getConfig(chainId) }); + } + + async getTokenList() { + const { data } = await axios.get( + 'https://raw.githubusercontent.com/RealWagmi/tokenlists/main/tokenlist.json' + ); + + const tmp: Record = { [this.nativeToken.address]: true }; + const tokenList: SwapTokenLogicTokenList = [this.nativeToken]; + for (const { chainId, address, decimals, symbol, name, logoURI } of data.tokens) { + if (tmp[address] || chainId !== this.chainId) continue; + tokenList.push(new common.Token(chainId, address, decimals, symbol, name, logoURI)); + tmp[address] = true; + } + + return tokenList; + } + + public async computePoolAddress({ + factoryAddress, + tokenA, + tokenB, + fee, + }: { + factoryAddress: string; + tokenA: Token; + tokenB: Token; + fee: FeeAmount; + }): Promise { + const callsGetPool: common.Multicall3.CallStruct[] = []; + const iface = UniswapV3Factory__factory.createInterface(); + + if (tokenA && tokenB && !tokenA.equals(tokenB)) { + const tokenIn = univ3.toPTLKToken(tokenA); + const tokenOut = univ3.toPTLKToken(tokenB); + const [token0, token1] = tokenIn.sortsBefore(tokenOut) ? [tokenIn, tokenOut] : [tokenOut, tokenIn]; + + const callDataGetPool = iface.encodeFunctionData('getPool', [ + token0.address, + token1.address, + BigNumber.from(fee.toString()), + ]); + + callsGetPool.push({ target: factoryAddress, callData: callDataGetPool }); + } else { + } + + const [resultsGetPool] = await Promise.all([this.multicall3.callStatic.tryAggregate(false, callsGetPool)]); + + // decode multicall results + let poolAddress = constants.AddressZero; + const resultGetPair = resultsGetPool[0]; + if (resultGetPair.success && resultGetPair.returnData !== '0x') { + [poolAddress] = iface.decodeFunctionResult('getPool', resultGetPair.returnData); + } + return poolAddress; + } +} diff --git a/src/logics/wagmi/tokens/data/iota.json b/src/logics/wagmi/tokens/data/iota.json new file mode 100644 index 00000000..0967ef42 --- /dev/null +++ b/src/logics/wagmi/tokens/data/iota.json @@ -0,0 +1 @@ +{} diff --git a/src/logics/wagmi/tokens/index.ts b/src/logics/wagmi/tokens/index.ts new file mode 100644 index 00000000..e5687ff0 --- /dev/null +++ b/src/logics/wagmi/tokens/index.ts @@ -0,0 +1,11 @@ +import * as common from '@protocolink/common'; +import iotaTokensJSON from './data/iota.json'; +import * as univ3 from 'src/modules/univ3'; + +type IotaTokenSymbols = keyof typeof iotaTokensJSON; +type CommonIotaTokenSymbols = keyof typeof common.iotaTokens; + +export const iotaTokens = { + ...univ3.toTokenMap(iotaTokensJSON), + ...univ3.toTokenMap(common.iotaTokens), +}; diff --git a/src/modules/univ3/logic.swap-token.ts b/src/modules/univ3/logic.swap-token.ts index 7f18a97a..949493f7 100644 --- a/src/modules/univ3/logic.swap-token.ts +++ b/src/modules/univ3/logic.swap-token.ts @@ -7,7 +7,7 @@ import { isSwapTokenLogicSingleHopFields, } from './types'; import { Currency, CurrencyAmount, Token, TradeType } from '@uniswap/sdk-core'; -import { FeeAmount, Pool, Route, SwapQuoter, computePoolAddress, encodeRouteToPath } from '@uniswap/v3-sdk'; +import { FeeAmount, Pool, Route, SwapQuoter, encodeRouteToPath } from '@uniswap/v3-sdk'; import { IV3SwapRouter } from './contracts/SwapRouter02'; import JSBI from 'jsbi'; import { Pool__factory, SwapRouter02__factory } from './contracts'; @@ -22,7 +22,7 @@ export interface LogicOptions { config: Config; } -export class SwapTokenLogic extends core.Logic { +export abstract class SwapTokenLogic extends core.Logic { public readonly config: Config; constructor({ chainId, provider, config }: LogicOptions) { @@ -222,6 +222,7 @@ export class SwapTokenLogic extends core.Logic { }, { route: null, inputAmount: null, outputAmount: null } ); + if (!route || !inputAmount || !outputAmount) throw UNSUPPORTED_TOKEN_ERROR; return { route, inputAmount, outputAmount }; @@ -231,7 +232,6 @@ export class SwapTokenLogic extends core.Logic { public async getAllRoutes(currencyIn: Currency, currencyOut: Currency) { const pools = await this.getPools(currencyIn, currencyOut); const routes = this.computeAllRoutes(currencyIn, currencyOut, pools, [], [], currencyIn, 2); - return routes; } @@ -250,7 +250,12 @@ export class SwapTokenLogic extends core.Logic { const callsSlot0: common.Multicall3.CallStruct[] = []; const callsLiquidity: common.Multicall3.CallStruct[] = []; for (const [tokenA, tokenB, fee] of poolTokens) { - const poolAddress = computePoolAddress({ factoryAddress: this.config.factoryAddress, tokenA, tokenB, fee }); + const poolAddress = await this.computePoolAddress({ + factoryAddress: this.config.factoryAddress, + tokenA, + tokenB, + fee, + }); callsSlot0.push({ target: poolAddress, callData: callDataSlot0 }); callsLiquidity.push({ target: poolAddress, callData: callDataLiquidity }); } @@ -384,4 +389,18 @@ export class SwapTokenLogic extends core.Logic { return allPaths; } + + public abstract computePoolAddress({ + factoryAddress, + tokenA, + tokenB, + fee, + initCodeHashManualOverride, + }: { + factoryAddress: string; + tokenA: Token; + tokenB: Token; + fee: FeeAmount; + initCodeHashManualOverride?: string; + }): Promise; } diff --git a/src/modules/univ3/utils.ts b/src/modules/univ3/utils.ts index 1932bb91..e7ad3ad8 100644 --- a/src/modules/univ3/utils.ts +++ b/src/modules/univ3/utils.ts @@ -5,6 +5,10 @@ export function toUniToken(token: common.TokenTypes) { return new Token(token.chainId, token.address, token.decimals, token.symbol, token.name); } +export function toPTLKToken(token: Token) { + return new common.Token(token.chainId, token.address, token.decimals, token.symbol!, token.name!); +} + export function toTokenMap(tokenObjectMap: Record): Record { return Object.keys(tokenObjectMap).reduce((accumulator, symbol) => { accumulator[symbol] = toUniToken(tokenObjectMap[symbol]); diff --git a/test/logics/wagmi/swap-token.test.ts b/test/logics/wagmi/swap-token.test.ts new file mode 100644 index 00000000..9adaef65 --- /dev/null +++ b/test/logics/wagmi/swap-token.test.ts @@ -0,0 +1,118 @@ +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 * as utils from 'test/utils'; +import * as wagmi from 'src/logics/wagmi'; + +describe('iota-pb: Test Wagmi 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, + common.iotaTokens.USDT, + '5000', + '0x7fA6e7C26Fac91541306B0240f930599F6e1D041' + ); + }); + + snapshotAndRevertEach(); + + const testCases = [ + { + params: { + input: new common.TokenAmount(common.iotaTokens.IOTA, '100'), + tokenOut: common.iotaTokens.USDT, + slippage: 5000, + }, + }, + { + params: { + input: new common.TokenAmount(common.iotaTokens.USDT, '100'), + tokenOut: common.iotaTokens.IOTA, + slippage: 5000, + }, + }, + { + params: { + input: new common.TokenAmount(common.iotaTokens.USDT, '100'), + tokenOut: common.iotaTokens.WETH, + slippage: 5000, + }, + }, + { + params: { + input: new common.TokenAmount(common.iotaTokens.IOTA, '100'), + tokenOut: common.iotaTokens.USDT, + slippage: 5000, + }, + balanceBps: 5000, + }, + { + params: { + input: new common.TokenAmount(common.iotaTokens.USDT, '100'), + tokenOut: common.iotaTokens.IOTA, + slippage: 5000, + }, + balanceBps: 5000, + }, + { + params: { + input: new common.TokenAmount(common.iotaTokens.USDT, '100'), + tokenOut: common.iotaTokens.WETH, + slippage: 5000, + }, + balanceBps: 5000, + }, + ]; + + testCases.forEach(({ params, balanceBps }, i) => { + it(`case ${i + 1}`, async function () { + // 1. get input or output + const wagmiSwapTokenLogic = new wagmi.SwapTokenLogic(chainId); + const quotation = await wagmiSwapTokenLogic.quote(params); + const { tradeType, input, output } = quotation; + + // 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 wagmiSwapTokenLogic.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); + } + }); + }); +});