From 08a571106b114bcaba166dd6a6aa7aa50c8609db Mon Sep 17 00:00:00 2001 From: sonlha Date: Tue, 12 Dec 2023 15:18:01 +0700 Subject: [PATCH] remove redundant code --- .../src/universal-swap/config/abi/erc20.json | 222 ---- .../universal-swap/config/abi/gravity.json | 912 ---------------- .../abi/v2-periphery/contracts/index.ts | 4 - .../interfaces/IUniswapV2Router01__factory.ts | 775 -------------- .../interfaces/IUniswapV2Router02__factory.ts | 977 ------------------ .../contracts/interfaces/index.ts | 5 - .../config/abi/v2-periphery/index.ts | 4 - .../src/universal-swap/config/bridgeTokens.ts | 33 - .../src/universal-swap/config/chainInfos.ts | 633 ------------ .../src/universal-swap/config/ibcInfos.ts | 0 .../common/src/universal-swap/config/index.ts | 1 - .../common/src/universal-swap/config/pools.ts | 0 packages/common/src/universal-swap/index.ts | 1 - .../common/src/universal-swap/wallet/index.ts | 224 ---- .../hooks/src/universal-swap/use-client.ts | 3 +- .../src/universal-swap/use-load-tokens.ts | 4 +- .../src/universal-swap/use-relayer-fee.ts | 3 +- .../hooks/src/universal-swap/use-tax-rate.ts | 3 +- 18 files changed, 8 insertions(+), 3796 deletions(-) delete mode 100644 packages/common/src/universal-swap/config/abi/erc20.json delete mode 100644 packages/common/src/universal-swap/config/abi/gravity.json delete mode 100644 packages/common/src/universal-swap/config/abi/v2-periphery/contracts/index.ts delete mode 100644 packages/common/src/universal-swap/config/abi/v2-periphery/contracts/interfaces/IUniswapV2Router01__factory.ts delete mode 100644 packages/common/src/universal-swap/config/abi/v2-periphery/contracts/interfaces/IUniswapV2Router02__factory.ts delete mode 100644 packages/common/src/universal-swap/config/abi/v2-periphery/contracts/interfaces/index.ts delete mode 100644 packages/common/src/universal-swap/config/abi/v2-periphery/index.ts delete mode 100644 packages/common/src/universal-swap/config/chainInfos.ts delete mode 100644 packages/common/src/universal-swap/config/ibcInfos.ts delete mode 100644 packages/common/src/universal-swap/config/pools.ts delete mode 100644 packages/common/src/universal-swap/wallet/index.ts diff --git a/packages/common/src/universal-swap/config/abi/erc20.json b/packages/common/src/universal-swap/config/abi/erc20.json deleted file mode 100644 index 668d6979f..000000000 --- a/packages/common/src/universal-swap/config/abi/erc20.json +++ /dev/null @@ -1,222 +0,0 @@ -[ - { - "constant": true, - "inputs": [], - "name": "name", - "outputs": [ - { - "name": "", - "type": "string" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "name": "_spender", - "type": "address" - }, - { - "name": "_value", - "type": "uint256" - } - ], - "name": "approve", - "outputs": [ - { - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "totalSupply", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "name": "_from", - "type": "address" - }, - { - "name": "_to", - "type": "address" - }, - { - "name": "_value", - "type": "uint256" - } - ], - "name": "transferFrom", - "outputs": [ - { - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "decimals", - "outputs": [ - { - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "name": "_owner", - "type": "address" - } - ], - "name": "balanceOf", - "outputs": [ - { - "name": "balance", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "symbol", - "outputs": [ - { - "name": "", - "type": "string" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "name": "_to", - "type": "address" - }, - { - "name": "_value", - "type": "uint256" - } - ], - "name": "transfer", - "outputs": [ - { - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "name": "_owner", - "type": "address" - }, - { - "name": "_spender", - "type": "address" - } - ], - "name": "allowance", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "payable": true, - "stateMutability": "payable", - "type": "fallback" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "name": "owner", - "type": "address" - }, - { - "indexed": true, - "name": "spender", - "type": "address" - }, - { - "indexed": false, - "name": "value", - "type": "uint256" - } - ], - "name": "Approval", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "name": "from", - "type": "address" - }, - { - "indexed": true, - "name": "to", - "type": "address" - }, - { - "indexed": false, - "name": "value", - "type": "uint256" - } - ], - "name": "Transfer", - "type": "event" - } -] \ No newline at end of file diff --git a/packages/common/src/universal-swap/config/abi/gravity.json b/packages/common/src/universal-swap/config/abi/gravity.json deleted file mode 100644 index 7f560cb15..000000000 --- a/packages/common/src/universal-swap/config/abi/gravity.json +++ /dev/null @@ -1,912 +0,0 @@ -[ - { - "inputs": [ - { - "internalType": "bytes32", - "name": "_gravityId", - "type": "bytes32" - }, - { - "internalType": "address[]", - "name": "_validators", - "type": "address[]" - }, - { - "internalType": "uint256[]", - "name": "_powers", - "type": "uint256[]" - } - ], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "inputs": [], - "name": "BatchTimedOut", - "type": "error" - }, - { - "inputs": [], - "name": "IncorrectCheckpoint", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "cumulativePower", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "powerThreshold", - "type": "uint256" - } - ], - "name": "InsufficientPower", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "newNonce", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "currentNonce", - "type": "uint256" - } - ], - "name": "InvalidBatchNonce", - "type": "error" - }, - { - "inputs": [], - "name": "InvalidLogicCallFees", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "newNonce", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "currentNonce", - "type": "uint256" - } - ], - "name": "InvalidLogicCallNonce", - "type": "error" - }, - { - "inputs": [], - "name": "InvalidLogicCallTransfers", - "type": "error" - }, - { - "inputs": [], - "name": "InvalidSendToCosmos", - "type": "error" - }, - { - "inputs": [], - "name": "InvalidSignature", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "newNonce", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "currentNonce", - "type": "uint256" - } - ], - "name": "InvalidValsetNonce", - "type": "error" - }, - { - "inputs": [], - "name": "LogicCallTimedOut", - "type": "error" - }, - { - "inputs": [], - "name": "MalformedBatch", - "type": "error" - }, - { - "inputs": [], - "name": "MalformedCurrentValidatorSet", - "type": "error" - }, - { - "inputs": [], - "name": "MalformedNewValidatorSet", - "type": "error" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "string", - "name": "_cosmosDenom", - "type": "string" - }, - { - "indexed": true, - "internalType": "address", - "name": "_tokenContract", - "type": "address" - }, - { - "indexed": false, - "internalType": "string", - "name": "_name", - "type": "string" - }, - { - "indexed": false, - "internalType": "string", - "name": "_symbol", - "type": "string" - }, - { - "indexed": false, - "internalType": "uint8", - "name": "_decimals", - "type": "uint8" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "_eventNonce", - "type": "uint256" - } - ], - "name": "ERC20DeployedEvent", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "bytes32", - "name": "_invalidationId", - "type": "bytes32" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "_invalidationNonce", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "bytes", - "name": "_returnData", - "type": "bytes" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "_eventNonce", - "type": "uint256" - } - ], - "name": "LogicCallEvent", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "_tokenContract", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "_sender", - "type": "address" - }, - { - "indexed": false, - "internalType": "string", - "name": "_destination", - "type": "string" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "_amount", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "_eventNonce", - "type": "uint256" - } - ], - "name": "SendToCosmosEvent", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "uint256", - "name": "_batchNonce", - "type": "uint256" - }, - { - "indexed": true, - "internalType": "address", - "name": "_token", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "_eventNonce", - "type": "uint256" - } - ], - "name": "TransactionBatchExecutedEvent", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "uint256", - "name": "_newValsetNonce", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "_eventNonce", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "_rewardAmount", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "address", - "name": "_rewardToken", - "type": "address" - }, - { - "indexed": false, - "internalType": "address[]", - "name": "_validators", - "type": "address[]" - }, - { - "indexed": false, - "internalType": "uint256[]", - "name": "_powers", - "type": "uint256[]" - } - ], - "name": "ValsetUpdatedEvent", - "type": "event" - }, - { - "inputs": [ - { - "internalType": "string", - "name": "_cosmosDenom", - "type": "string" - }, - { - "internalType": "string", - "name": "_name", - "type": "string" - }, - { - "internalType": "string", - "name": "_symbol", - "type": "string" - }, - { - "internalType": "uint8", - "name": "_decimals", - "type": "uint8" - } - ], - "name": "deployERC20", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_erc20Address", - "type": "address" - } - ], - "name": "lastBatchNonce", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "_invalidation_id", - "type": "bytes32" - } - ], - "name": "lastLogicCallNonce", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_tokenContract", - "type": "address" - }, - { - "internalType": "string", - "name": "_destination", - "type": "string" - }, - { - "internalType": "uint256", - "name": "_amount", - "type": "uint256" - } - ], - "name": "sendToCosmos", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "state_gravityId", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "name": "state_invalidationMapping", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "state_lastBatchNonces", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "state_lastEventNonce", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "state_lastValsetCheckpoint", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "state_lastValsetNonce", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "components": [ - { - "internalType": "address[]", - "name": "validators", - "type": "address[]" - }, - { - "internalType": "uint256[]", - "name": "powers", - "type": "uint256[]" - }, - { - "internalType": "uint256", - "name": "valsetNonce", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "rewardAmount", - "type": "uint256" - }, - { - "internalType": "address", - "name": "rewardToken", - "type": "address" - } - ], - "internalType": "struct ValsetArgs", - "name": "_currentValset", - "type": "tuple" - }, - { - "components": [ - { - "internalType": "uint8", - "name": "v", - "type": "uint8" - }, - { - "internalType": "bytes32", - "name": "r", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "s", - "type": "bytes32" - } - ], - "internalType": "struct Signature[]", - "name": "_sigs", - "type": "tuple[]" - }, - { - "internalType": "uint256[]", - "name": "_amounts", - "type": "uint256[]" - }, - { - "internalType": "address[]", - "name": "_destinations", - "type": "address[]" - }, - { - "internalType": "uint256[]", - "name": "_fees", - "type": "uint256[]" - }, - { - "internalType": "uint256", - "name": "_batchNonce", - "type": "uint256" - }, - { - "internalType": "address", - "name": "_tokenContract", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_batchTimeout", - "type": "uint256" - } - ], - "name": "submitBatch", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "components": [ - { - "internalType": "address[]", - "name": "validators", - "type": "address[]" - }, - { - "internalType": "uint256[]", - "name": "powers", - "type": "uint256[]" - }, - { - "internalType": "uint256", - "name": "valsetNonce", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "rewardAmount", - "type": "uint256" - }, - { - "internalType": "address", - "name": "rewardToken", - "type": "address" - } - ], - "internalType": "struct ValsetArgs", - "name": "_currentValset", - "type": "tuple" - }, - { - "components": [ - { - "internalType": "uint8", - "name": "v", - "type": "uint8" - }, - { - "internalType": "bytes32", - "name": "r", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "s", - "type": "bytes32" - } - ], - "internalType": "struct Signature[]", - "name": "_sigs", - "type": "tuple[]" - }, - { - "components": [ - { - "internalType": "uint256[]", - "name": "transferAmounts", - "type": "uint256[]" - }, - { - "internalType": "address[]", - "name": "transferTokenContracts", - "type": "address[]" - }, - { - "internalType": "uint256[]", - "name": "feeAmounts", - "type": "uint256[]" - }, - { - "internalType": "address[]", - "name": "feeTokenContracts", - "type": "address[]" - }, - { - "internalType": "address", - "name": "logicContractAddress", - "type": "address" - }, - { - "internalType": "bytes", - "name": "payload", - "type": "bytes" - }, - { - "internalType": "uint256", - "name": "timeOut", - "type": "uint256" - }, - { - "internalType": "bytes32", - "name": "invalidationId", - "type": "bytes32" - }, - { - "internalType": "uint256", - "name": "invalidationNonce", - "type": "uint256" - } - ], - "internalType": "struct LogicCallArgs", - "name": "_args", - "type": "tuple" - } - ], - "name": "submitLogicCall", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "components": [ - { - "internalType": "address[]", - "name": "validators", - "type": "address[]" - }, - { - "internalType": "uint256[]", - "name": "powers", - "type": "uint256[]" - }, - { - "internalType": "uint256", - "name": "valsetNonce", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "rewardAmount", - "type": "uint256" - }, - { - "internalType": "address", - "name": "rewardToken", - "type": "address" - } - ], - "internalType": "struct ValsetArgs", - "name": "_currentValset", - "type": "tuple" - }, - { - "components": [ - { - "internalType": "uint8", - "name": "v", - "type": "uint8" - }, - { - "internalType": "bytes32", - "name": "r", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "s", - "type": "bytes32" - } - ], - "internalType": "struct Signature[]", - "name": "_sigs", - "type": "tuple[]" - }, - { - "internalType": "bytes32", - "name": "_theHash", - "type": "bytes32" - }, - { - "internalType": "uint256", - "name": "_powerThreshold", - "type": "uint256" - } - ], - "name": "testCheckValidatorSignatures", - "outputs": [], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [ - { - "components": [ - { - "internalType": "address[]", - "name": "validators", - "type": "address[]" - }, - { - "internalType": "uint256[]", - "name": "powers", - "type": "uint256[]" - }, - { - "internalType": "uint256", - "name": "valsetNonce", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "rewardAmount", - "type": "uint256" - }, - { - "internalType": "address", - "name": "rewardToken", - "type": "address" - } - ], - "internalType": "struct ValsetArgs", - "name": "_valsetArgs", - "type": "tuple" - }, - { - "internalType": "bytes32", - "name": "_gravityId", - "type": "bytes32" - } - ], - "name": "testMakeCheckpoint", - "outputs": [], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [ - { - "components": [ - { - "internalType": "address[]", - "name": "validators", - "type": "address[]" - }, - { - "internalType": "uint256[]", - "name": "powers", - "type": "uint256[]" - }, - { - "internalType": "uint256", - "name": "valsetNonce", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "rewardAmount", - "type": "uint256" - }, - { - "internalType": "address", - "name": "rewardToken", - "type": "address" - } - ], - "internalType": "struct ValsetArgs", - "name": "_newValset", - "type": "tuple" - }, - { - "components": [ - { - "internalType": "address[]", - "name": "validators", - "type": "address[]" - }, - { - "internalType": "uint256[]", - "name": "powers", - "type": "uint256[]" - }, - { - "internalType": "uint256", - "name": "valsetNonce", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "rewardAmount", - "type": "uint256" - }, - { - "internalType": "address", - "name": "rewardToken", - "type": "address" - } - ], - "internalType": "struct ValsetArgs", - "name": "_currentValset", - "type": "tuple" - }, - { - "components": [ - { - "internalType": "uint8", - "name": "v", - "type": "uint8" - }, - { - "internalType": "bytes32", - "name": "r", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "s", - "type": "bytes32" - } - ], - "internalType": "struct Signature[]", - "name": "_sigs", - "type": "tuple[]" - } - ], - "name": "updateValset", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - } -] \ No newline at end of file diff --git a/packages/common/src/universal-swap/config/abi/v2-periphery/contracts/index.ts b/packages/common/src/universal-swap/config/abi/v2-periphery/contracts/index.ts deleted file mode 100644 index 1d3444d5b..000000000 --- a/packages/common/src/universal-swap/config/abi/v2-periphery/contracts/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -/* Autogenerated file. Do not edit manually. */ -/* tslint:disable */ -/* eslint-disable */ -export * as interfaces from "./interfaces"; diff --git a/packages/common/src/universal-swap/config/abi/v2-periphery/contracts/interfaces/IUniswapV2Router01__factory.ts b/packages/common/src/universal-swap/config/abi/v2-periphery/contracts/interfaces/IUniswapV2Router01__factory.ts deleted file mode 100644 index 1560f6e47..000000000 --- a/packages/common/src/universal-swap/config/abi/v2-periphery/contracts/interfaces/IUniswapV2Router01__factory.ts +++ /dev/null @@ -1,775 +0,0 @@ -/* Autogenerated file. Do not edit manually. */ -/* tslint:disable */ -/* eslint-disable */ - -import { Contract, Signer, utils } from 'ethers'; -import type { Provider } from '@ethersproject/providers'; -import { - IUniswapV2Router01, - IUniswapV2Router01Interface -} from 'src/universal-swap/types/typechain-types/@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router01'; - -const _abi = [ - { - inputs: [], - name: 'WETH', - outputs: [ - { - internalType: 'address', - name: '', - type: 'address' - } - ], - stateMutability: 'pure', - type: 'function' - }, - { - inputs: [ - { - internalType: 'address', - name: 'tokenA', - type: 'address' - }, - { - internalType: 'address', - name: 'tokenB', - type: 'address' - }, - { - internalType: 'uint256', - name: 'amountADesired', - type: 'uint256' - }, - { - internalType: 'uint256', - name: 'amountBDesired', - type: 'uint256' - }, - { - internalType: 'uint256', - name: 'amountAMin', - type: 'uint256' - }, - { - internalType: 'uint256', - name: 'amountBMin', - type: 'uint256' - }, - { - internalType: 'address', - name: 'to', - type: 'address' - }, - { - internalType: 'uint256', - name: 'deadline', - type: 'uint256' - } - ], - name: 'addLiquidity', - outputs: [ - { - internalType: 'uint256', - name: 'amountA', - type: 'uint256' - }, - { - internalType: 'uint256', - name: 'amountB', - type: 'uint256' - }, - { - internalType: 'uint256', - name: 'liquidity', - type: 'uint256' - } - ], - stateMutability: 'nonpayable', - type: 'function' - }, - { - inputs: [ - { - internalType: 'address', - name: 'token', - type: 'address' - }, - { - internalType: 'uint256', - name: 'amountTokenDesired', - type: 'uint256' - }, - { - internalType: 'uint256', - name: 'amountTokenMin', - type: 'uint256' - }, - { - internalType: 'uint256', - name: 'amountETHMin', - type: 'uint256' - }, - { - internalType: 'address', - name: 'to', - type: 'address' - }, - { - internalType: 'uint256', - name: 'deadline', - type: 'uint256' - } - ], - name: 'addLiquidityETH', - outputs: [ - { - internalType: 'uint256', - name: 'amountToken', - type: 'uint256' - }, - { - internalType: 'uint256', - name: 'amountETH', - type: 'uint256' - }, - { - internalType: 'uint256', - name: 'liquidity', - type: 'uint256' - } - ], - stateMutability: 'payable', - type: 'function' - }, - { - inputs: [], - name: 'factory', - outputs: [ - { - internalType: 'address', - name: '', - type: 'address' - } - ], - stateMutability: 'pure', - type: 'function' - }, - { - inputs: [ - { - internalType: 'uint256', - name: 'amountOut', - type: 'uint256' - }, - { - internalType: 'uint256', - name: 'reserveIn', - type: 'uint256' - }, - { - internalType: 'uint256', - name: 'reserveOut', - type: 'uint256' - } - ], - name: 'getAmountIn', - outputs: [ - { - internalType: 'uint256', - name: 'amountIn', - type: 'uint256' - } - ], - stateMutability: 'pure', - type: 'function' - }, - { - inputs: [ - { - internalType: 'uint256', - name: 'amountIn', - type: 'uint256' - }, - { - internalType: 'uint256', - name: 'reserveIn', - type: 'uint256' - }, - { - internalType: 'uint256', - name: 'reserveOut', - type: 'uint256' - } - ], - name: 'getAmountOut', - outputs: [ - { - internalType: 'uint256', - name: 'amountOut', - type: 'uint256' - } - ], - stateMutability: 'pure', - type: 'function' - }, - { - inputs: [ - { - internalType: 'uint256', - name: 'amountOut', - type: 'uint256' - }, - { - internalType: 'address[]', - name: 'path', - type: 'address[]' - } - ], - name: 'getAmountsIn', - outputs: [ - { - internalType: 'uint256[]', - name: 'amounts', - type: 'uint256[]' - } - ], - stateMutability: 'view', - type: 'function' - }, - { - inputs: [ - { - internalType: 'uint256', - name: 'amountIn', - type: 'uint256' - }, - { - internalType: 'address[]', - name: 'path', - type: 'address[]' - } - ], - name: 'getAmountsOut', - outputs: [ - { - internalType: 'uint256[]', - name: 'amounts', - type: 'uint256[]' - } - ], - stateMutability: 'view', - type: 'function' - }, - { - inputs: [ - { - internalType: 'uint256', - name: 'amountA', - type: 'uint256' - }, - { - internalType: 'uint256', - name: 'reserveA', - type: 'uint256' - }, - { - internalType: 'uint256', - name: 'reserveB', - type: 'uint256' - } - ], - name: 'quote', - outputs: [ - { - internalType: 'uint256', - name: 'amountB', - type: 'uint256' - } - ], - stateMutability: 'pure', - type: 'function' - }, - { - inputs: [ - { - internalType: 'address', - name: 'tokenA', - type: 'address' - }, - { - internalType: 'address', - name: 'tokenB', - type: 'address' - }, - { - internalType: 'uint256', - name: 'liquidity', - type: 'uint256' - }, - { - internalType: 'uint256', - name: 'amountAMin', - type: 'uint256' - }, - { - internalType: 'uint256', - name: 'amountBMin', - type: 'uint256' - }, - { - internalType: 'address', - name: 'to', - type: 'address' - }, - { - internalType: 'uint256', - name: 'deadline', - type: 'uint256' - } - ], - name: 'removeLiquidity', - outputs: [ - { - internalType: 'uint256', - name: 'amountA', - type: 'uint256' - }, - { - internalType: 'uint256', - name: 'amountB', - type: 'uint256' - } - ], - stateMutability: 'nonpayable', - type: 'function' - }, - { - inputs: [ - { - internalType: 'address', - name: 'token', - type: 'address' - }, - { - internalType: 'uint256', - name: 'liquidity', - type: 'uint256' - }, - { - internalType: 'uint256', - name: 'amountTokenMin', - type: 'uint256' - }, - { - internalType: 'uint256', - name: 'amountETHMin', - type: 'uint256' - }, - { - internalType: 'address', - name: 'to', - type: 'address' - }, - { - internalType: 'uint256', - name: 'deadline', - type: 'uint256' - } - ], - name: 'removeLiquidityETH', - outputs: [ - { - internalType: 'uint256', - name: 'amountToken', - type: 'uint256' - }, - { - internalType: 'uint256', - name: 'amountETH', - type: 'uint256' - } - ], - stateMutability: 'nonpayable', - type: 'function' - }, - { - inputs: [ - { - internalType: 'address', - name: 'token', - type: 'address' - }, - { - internalType: 'uint256', - name: 'liquidity', - type: 'uint256' - }, - { - internalType: 'uint256', - name: 'amountTokenMin', - type: 'uint256' - }, - { - internalType: 'uint256', - name: 'amountETHMin', - type: 'uint256' - }, - { - internalType: 'address', - name: 'to', - type: 'address' - }, - { - internalType: 'uint256', - name: 'deadline', - type: 'uint256' - }, - { - internalType: 'bool', - name: 'approveMax', - type: 'bool' - }, - { - internalType: 'uint8', - name: 'v', - type: 'uint8' - }, - { - internalType: 'bytes32', - name: 'r', - type: 'bytes32' - }, - { - internalType: 'bytes32', - name: 's', - type: 'bytes32' - } - ], - name: 'removeLiquidityETHWithPermit', - outputs: [ - { - internalType: 'uint256', - name: 'amountToken', - type: 'uint256' - }, - { - internalType: 'uint256', - name: 'amountETH', - type: 'uint256' - } - ], - stateMutability: 'nonpayable', - type: 'function' - }, - { - inputs: [ - { - internalType: 'address', - name: 'tokenA', - type: 'address' - }, - { - internalType: 'address', - name: 'tokenB', - type: 'address' - }, - { - internalType: 'uint256', - name: 'liquidity', - type: 'uint256' - }, - { - internalType: 'uint256', - name: 'amountAMin', - type: 'uint256' - }, - { - internalType: 'uint256', - name: 'amountBMin', - type: 'uint256' - }, - { - internalType: 'address', - name: 'to', - type: 'address' - }, - { - internalType: 'uint256', - name: 'deadline', - type: 'uint256' - }, - { - internalType: 'bool', - name: 'approveMax', - type: 'bool' - }, - { - internalType: 'uint8', - name: 'v', - type: 'uint8' - }, - { - internalType: 'bytes32', - name: 'r', - type: 'bytes32' - }, - { - internalType: 'bytes32', - name: 's', - type: 'bytes32' - } - ], - name: 'removeLiquidityWithPermit', - outputs: [ - { - internalType: 'uint256', - name: 'amountA', - type: 'uint256' - }, - { - internalType: 'uint256', - name: 'amountB', - type: 'uint256' - } - ], - stateMutability: 'nonpayable', - type: 'function' - }, - { - inputs: [ - { - internalType: 'uint256', - name: 'amountOut', - type: 'uint256' - }, - { - internalType: 'address[]', - name: 'path', - type: 'address[]' - }, - { - internalType: 'address', - name: 'to', - type: 'address' - }, - { - internalType: 'uint256', - name: 'deadline', - type: 'uint256' - } - ], - name: 'swapETHForExactTokens', - outputs: [ - { - internalType: 'uint256[]', - name: 'amounts', - type: 'uint256[]' - } - ], - stateMutability: 'payable', - type: 'function' - }, - { - inputs: [ - { - internalType: 'uint256', - name: 'amountOutMin', - type: 'uint256' - }, - { - internalType: 'address[]', - name: 'path', - type: 'address[]' - }, - { - internalType: 'address', - name: 'to', - type: 'address' - }, - { - internalType: 'uint256', - name: 'deadline', - type: 'uint256' - } - ], - name: 'swapExactETHForTokens', - outputs: [ - { - internalType: 'uint256[]', - name: 'amounts', - type: 'uint256[]' - } - ], - stateMutability: 'payable', - type: 'function' - }, - { - inputs: [ - { - internalType: 'uint256', - name: 'amountIn', - type: 'uint256' - }, - { - internalType: 'uint256', - name: 'amountOutMin', - type: 'uint256' - }, - { - internalType: 'address[]', - name: 'path', - type: 'address[]' - }, - { - internalType: 'address', - name: 'to', - type: 'address' - }, - { - internalType: 'uint256', - name: 'deadline', - type: 'uint256' - } - ], - name: 'swapExactTokensForETH', - outputs: [ - { - internalType: 'uint256[]', - name: 'amounts', - type: 'uint256[]' - } - ], - stateMutability: 'nonpayable', - type: 'function' - }, - { - inputs: [ - { - internalType: 'uint256', - name: 'amountIn', - type: 'uint256' - }, - { - internalType: 'uint256', - name: 'amountOutMin', - type: 'uint256' - }, - { - internalType: 'address[]', - name: 'path', - type: 'address[]' - }, - { - internalType: 'address', - name: 'to', - type: 'address' - }, - { - internalType: 'uint256', - name: 'deadline', - type: 'uint256' - } - ], - name: 'swapExactTokensForTokens', - outputs: [ - { - internalType: 'uint256[]', - name: 'amounts', - type: 'uint256[]' - } - ], - stateMutability: 'nonpayable', - type: 'function' - }, - { - inputs: [ - { - internalType: 'uint256', - name: 'amountOut', - type: 'uint256' - }, - { - internalType: 'uint256', - name: 'amountInMax', - type: 'uint256' - }, - { - internalType: 'address[]', - name: 'path', - type: 'address[]' - }, - { - internalType: 'address', - name: 'to', - type: 'address' - }, - { - internalType: 'uint256', - name: 'deadline', - type: 'uint256' - } - ], - name: 'swapTokensForExactETH', - outputs: [ - { - internalType: 'uint256[]', - name: 'amounts', - type: 'uint256[]' - } - ], - stateMutability: 'nonpayable', - type: 'function' - }, - { - inputs: [ - { - internalType: 'uint256', - name: 'amountOut', - type: 'uint256' - }, - { - internalType: 'uint256', - name: 'amountInMax', - type: 'uint256' - }, - { - internalType: 'address[]', - name: 'path', - type: 'address[]' - }, - { - internalType: 'address', - name: 'to', - type: 'address' - }, - { - internalType: 'uint256', - name: 'deadline', - type: 'uint256' - } - ], - name: 'swapTokensForExactTokens', - outputs: [ - { - internalType: 'uint256[]', - name: 'amounts', - type: 'uint256[]' - } - ], - stateMutability: 'nonpayable', - type: 'function' - } -] as const; - -export class IUniswapV2Router01__factory { - static readonly abi = _abi; - static createInterface(): IUniswapV2Router01Interface { - return new utils.Interface(_abi) as IUniswapV2Router01Interface; - } - static connect( - address: string, - signerOrProvider: Signer | Provider - ): IUniswapV2Router01 { - return new Contract(address, _abi, signerOrProvider) as IUniswapV2Router01; - } -} diff --git a/packages/common/src/universal-swap/config/abi/v2-periphery/contracts/interfaces/IUniswapV2Router02__factory.ts b/packages/common/src/universal-swap/config/abi/v2-periphery/contracts/interfaces/IUniswapV2Router02__factory.ts deleted file mode 100644 index 43a6aef03..000000000 --- a/packages/common/src/universal-swap/config/abi/v2-periphery/contracts/interfaces/IUniswapV2Router02__factory.ts +++ /dev/null @@ -1,977 +0,0 @@ -/* Autogenerated file. Do not edit manually. */ -/* tslint:disable */ -/* eslint-disable */ - -import { Contract, Signer, utils } from 'ethers'; -import type { Provider } from '@ethersproject/providers'; -import { - IUniswapV2Router02, - IUniswapV2Router02Interface -} from 'src/universal-swap/types/typechain-types/@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02'; - -const _abi = [ - { - inputs: [], - name: 'WETH', - outputs: [ - { - internalType: 'address', - name: '', - type: 'address' - } - ], - stateMutability: 'pure', - type: 'function' - }, - { - inputs: [ - { - internalType: 'address', - name: 'tokenA', - type: 'address' - }, - { - internalType: 'address', - name: 'tokenB', - type: 'address' - }, - { - internalType: 'uint256', - name: 'amountADesired', - type: 'uint256' - }, - { - internalType: 'uint256', - name: 'amountBDesired', - type: 'uint256' - }, - { - internalType: 'uint256', - name: 'amountAMin', - type: 'uint256' - }, - { - internalType: 'uint256', - name: 'amountBMin', - type: 'uint256' - }, - { - internalType: 'address', - name: 'to', - type: 'address' - }, - { - internalType: 'uint256', - name: 'deadline', - type: 'uint256' - } - ], - name: 'addLiquidity', - outputs: [ - { - internalType: 'uint256', - name: 'amountA', - type: 'uint256' - }, - { - internalType: 'uint256', - name: 'amountB', - type: 'uint256' - }, - { - internalType: 'uint256', - name: 'liquidity', - type: 'uint256' - } - ], - stateMutability: 'nonpayable', - type: 'function' - }, - { - inputs: [ - { - internalType: 'address', - name: 'token', - type: 'address' - }, - { - internalType: 'uint256', - name: 'amountTokenDesired', - type: 'uint256' - }, - { - internalType: 'uint256', - name: 'amountTokenMin', - type: 'uint256' - }, - { - internalType: 'uint256', - name: 'amountETHMin', - type: 'uint256' - }, - { - internalType: 'address', - name: 'to', - type: 'address' - }, - { - internalType: 'uint256', - name: 'deadline', - type: 'uint256' - } - ], - name: 'addLiquidityETH', - outputs: [ - { - internalType: 'uint256', - name: 'amountToken', - type: 'uint256' - }, - { - internalType: 'uint256', - name: 'amountETH', - type: 'uint256' - }, - { - internalType: 'uint256', - name: 'liquidity', - type: 'uint256' - } - ], - stateMutability: 'payable', - type: 'function' - }, - { - inputs: [], - name: 'factory', - outputs: [ - { - internalType: 'address', - name: '', - type: 'address' - } - ], - stateMutability: 'pure', - type: 'function' - }, - { - inputs: [ - { - internalType: 'uint256', - name: 'amountOut', - type: 'uint256' - }, - { - internalType: 'uint256', - name: 'reserveIn', - type: 'uint256' - }, - { - internalType: 'uint256', - name: 'reserveOut', - type: 'uint256' - } - ], - name: 'getAmountIn', - outputs: [ - { - internalType: 'uint256', - name: 'amountIn', - type: 'uint256' - } - ], - stateMutability: 'pure', - type: 'function' - }, - { - inputs: [ - { - internalType: 'uint256', - name: 'amountIn', - type: 'uint256' - }, - { - internalType: 'uint256', - name: 'reserveIn', - type: 'uint256' - }, - { - internalType: 'uint256', - name: 'reserveOut', - type: 'uint256' - } - ], - name: 'getAmountOut', - outputs: [ - { - internalType: 'uint256', - name: 'amountOut', - type: 'uint256' - } - ], - stateMutability: 'pure', - type: 'function' - }, - { - inputs: [ - { - internalType: 'uint256', - name: 'amountOut', - type: 'uint256' - }, - { - internalType: 'address[]', - name: 'path', - type: 'address[]' - } - ], - name: 'getAmountsIn', - outputs: [ - { - internalType: 'uint256[]', - name: 'amounts', - type: 'uint256[]' - } - ], - stateMutability: 'view', - type: 'function' - }, - { - inputs: [ - { - internalType: 'uint256', - name: 'amountIn', - type: 'uint256' - }, - { - internalType: 'address[]', - name: 'path', - type: 'address[]' - } - ], - name: 'getAmountsOut', - outputs: [ - { - internalType: 'uint256[]', - name: 'amounts', - type: 'uint256[]' - } - ], - stateMutability: 'view', - type: 'function' - }, - { - inputs: [ - { - internalType: 'uint256', - name: 'amountA', - type: 'uint256' - }, - { - internalType: 'uint256', - name: 'reserveA', - type: 'uint256' - }, - { - internalType: 'uint256', - name: 'reserveB', - type: 'uint256' - } - ], - name: 'quote', - outputs: [ - { - internalType: 'uint256', - name: 'amountB', - type: 'uint256' - } - ], - stateMutability: 'pure', - type: 'function' - }, - { - inputs: [ - { - internalType: 'address', - name: 'tokenA', - type: 'address' - }, - { - internalType: 'address', - name: 'tokenB', - type: 'address' - }, - { - internalType: 'uint256', - name: 'liquidity', - type: 'uint256' - }, - { - internalType: 'uint256', - name: 'amountAMin', - type: 'uint256' - }, - { - internalType: 'uint256', - name: 'amountBMin', - type: 'uint256' - }, - { - internalType: 'address', - name: 'to', - type: 'address' - }, - { - internalType: 'uint256', - name: 'deadline', - type: 'uint256' - } - ], - name: 'removeLiquidity', - outputs: [ - { - internalType: 'uint256', - name: 'amountA', - type: 'uint256' - }, - { - internalType: 'uint256', - name: 'amountB', - type: 'uint256' - } - ], - stateMutability: 'nonpayable', - type: 'function' - }, - { - inputs: [ - { - internalType: 'address', - name: 'token', - type: 'address' - }, - { - internalType: 'uint256', - name: 'liquidity', - type: 'uint256' - }, - { - internalType: 'uint256', - name: 'amountTokenMin', - type: 'uint256' - }, - { - internalType: 'uint256', - name: 'amountETHMin', - type: 'uint256' - }, - { - internalType: 'address', - name: 'to', - type: 'address' - }, - { - internalType: 'uint256', - name: 'deadline', - type: 'uint256' - } - ], - name: 'removeLiquidityETH', - outputs: [ - { - internalType: 'uint256', - name: 'amountToken', - type: 'uint256' - }, - { - internalType: 'uint256', - name: 'amountETH', - type: 'uint256' - } - ], - stateMutability: 'nonpayable', - type: 'function' - }, - { - inputs: [ - { - internalType: 'address', - name: 'token', - type: 'address' - }, - { - internalType: 'uint256', - name: 'liquidity', - type: 'uint256' - }, - { - internalType: 'uint256', - name: 'amountTokenMin', - type: 'uint256' - }, - { - internalType: 'uint256', - name: 'amountETHMin', - type: 'uint256' - }, - { - internalType: 'address', - name: 'to', - type: 'address' - }, - { - internalType: 'uint256', - name: 'deadline', - type: 'uint256' - } - ], - name: 'removeLiquidityETHSupportingFeeOnTransferTokens', - outputs: [ - { - internalType: 'uint256', - name: 'amountETH', - type: 'uint256' - } - ], - stateMutability: 'nonpayable', - type: 'function' - }, - { - inputs: [ - { - internalType: 'address', - name: 'token', - type: 'address' - }, - { - internalType: 'uint256', - name: 'liquidity', - type: 'uint256' - }, - { - internalType: 'uint256', - name: 'amountTokenMin', - type: 'uint256' - }, - { - internalType: 'uint256', - name: 'amountETHMin', - type: 'uint256' - }, - { - internalType: 'address', - name: 'to', - type: 'address' - }, - { - internalType: 'uint256', - name: 'deadline', - type: 'uint256' - }, - { - internalType: 'bool', - name: 'approveMax', - type: 'bool' - }, - { - internalType: 'uint8', - name: 'v', - type: 'uint8' - }, - { - internalType: 'bytes32', - name: 'r', - type: 'bytes32' - }, - { - internalType: 'bytes32', - name: 's', - type: 'bytes32' - } - ], - name: 'removeLiquidityETHWithPermit', - outputs: [ - { - internalType: 'uint256', - name: 'amountToken', - type: 'uint256' - }, - { - internalType: 'uint256', - name: 'amountETH', - type: 'uint256' - } - ], - stateMutability: 'nonpayable', - type: 'function' - }, - { - inputs: [ - { - internalType: 'address', - name: 'token', - type: 'address' - }, - { - internalType: 'uint256', - name: 'liquidity', - type: 'uint256' - }, - { - internalType: 'uint256', - name: 'amountTokenMin', - type: 'uint256' - }, - { - internalType: 'uint256', - name: 'amountETHMin', - type: 'uint256' - }, - { - internalType: 'address', - name: 'to', - type: 'address' - }, - { - internalType: 'uint256', - name: 'deadline', - type: 'uint256' - }, - { - internalType: 'bool', - name: 'approveMax', - type: 'bool' - }, - { - internalType: 'uint8', - name: 'v', - type: 'uint8' - }, - { - internalType: 'bytes32', - name: 'r', - type: 'bytes32' - }, - { - internalType: 'bytes32', - name: 's', - type: 'bytes32' - } - ], - name: 'removeLiquidityETHWithPermitSupportingFeeOnTransferTokens', - outputs: [ - { - internalType: 'uint256', - name: 'amountETH', - type: 'uint256' - } - ], - stateMutability: 'nonpayable', - type: 'function' - }, - { - inputs: [ - { - internalType: 'address', - name: 'tokenA', - type: 'address' - }, - { - internalType: 'address', - name: 'tokenB', - type: 'address' - }, - { - internalType: 'uint256', - name: 'liquidity', - type: 'uint256' - }, - { - internalType: 'uint256', - name: 'amountAMin', - type: 'uint256' - }, - { - internalType: 'uint256', - name: 'amountBMin', - type: 'uint256' - }, - { - internalType: 'address', - name: 'to', - type: 'address' - }, - { - internalType: 'uint256', - name: 'deadline', - type: 'uint256' - }, - { - internalType: 'bool', - name: 'approveMax', - type: 'bool' - }, - { - internalType: 'uint8', - name: 'v', - type: 'uint8' - }, - { - internalType: 'bytes32', - name: 'r', - type: 'bytes32' - }, - { - internalType: 'bytes32', - name: 's', - type: 'bytes32' - } - ], - name: 'removeLiquidityWithPermit', - outputs: [ - { - internalType: 'uint256', - name: 'amountA', - type: 'uint256' - }, - { - internalType: 'uint256', - name: 'amountB', - type: 'uint256' - } - ], - stateMutability: 'nonpayable', - type: 'function' - }, - { - inputs: [ - { - internalType: 'uint256', - name: 'amountOut', - type: 'uint256' - }, - { - internalType: 'address[]', - name: 'path', - type: 'address[]' - }, - { - internalType: 'address', - name: 'to', - type: 'address' - }, - { - internalType: 'uint256', - name: 'deadline', - type: 'uint256' - } - ], - name: 'swapETHForExactTokens', - outputs: [ - { - internalType: 'uint256[]', - name: 'amounts', - type: 'uint256[]' - } - ], - stateMutability: 'payable', - type: 'function' - }, - { - inputs: [ - { - internalType: 'uint256', - name: 'amountOutMin', - type: 'uint256' - }, - { - internalType: 'address[]', - name: 'path', - type: 'address[]' - }, - { - internalType: 'address', - name: 'to', - type: 'address' - }, - { - internalType: 'uint256', - name: 'deadline', - type: 'uint256' - } - ], - name: 'swapExactETHForTokens', - outputs: [ - { - internalType: 'uint256[]', - name: 'amounts', - type: 'uint256[]' - } - ], - stateMutability: 'payable', - type: 'function' - }, - { - inputs: [ - { - internalType: 'uint256', - name: 'amountOutMin', - type: 'uint256' - }, - { - internalType: 'address[]', - name: 'path', - type: 'address[]' - }, - { - internalType: 'address', - name: 'to', - type: 'address' - }, - { - internalType: 'uint256', - name: 'deadline', - type: 'uint256' - } - ], - name: 'swapExactETHForTokensSupportingFeeOnTransferTokens', - outputs: [], - stateMutability: 'payable', - type: 'function' - }, - { - inputs: [ - { - internalType: 'uint256', - name: 'amountIn', - type: 'uint256' - }, - { - internalType: 'uint256', - name: 'amountOutMin', - type: 'uint256' - }, - { - internalType: 'address[]', - name: 'path', - type: 'address[]' - }, - { - internalType: 'address', - name: 'to', - type: 'address' - }, - { - internalType: 'uint256', - name: 'deadline', - type: 'uint256' - } - ], - name: 'swapExactTokensForETH', - outputs: [ - { - internalType: 'uint256[]', - name: 'amounts', - type: 'uint256[]' - } - ], - stateMutability: 'nonpayable', - type: 'function' - }, - { - inputs: [ - { - internalType: 'uint256', - name: 'amountIn', - type: 'uint256' - }, - { - internalType: 'uint256', - name: 'amountOutMin', - type: 'uint256' - }, - { - internalType: 'address[]', - name: 'path', - type: 'address[]' - }, - { - internalType: 'address', - name: 'to', - type: 'address' - }, - { - internalType: 'uint256', - name: 'deadline', - type: 'uint256' - } - ], - name: 'swapExactTokensForETHSupportingFeeOnTransferTokens', - outputs: [], - stateMutability: 'nonpayable', - type: 'function' - }, - { - inputs: [ - { - internalType: 'uint256', - name: 'amountIn', - type: 'uint256' - }, - { - internalType: 'uint256', - name: 'amountOutMin', - type: 'uint256' - }, - { - internalType: 'address[]', - name: 'path', - type: 'address[]' - }, - { - internalType: 'address', - name: 'to', - type: 'address' - }, - { - internalType: 'uint256', - name: 'deadline', - type: 'uint256' - } - ], - name: 'swapExactTokensForTokens', - outputs: [ - { - internalType: 'uint256[]', - name: 'amounts', - type: 'uint256[]' - } - ], - stateMutability: 'nonpayable', - type: 'function' - }, - { - inputs: [ - { - internalType: 'uint256', - name: 'amountIn', - type: 'uint256' - }, - { - internalType: 'uint256', - name: 'amountOutMin', - type: 'uint256' - }, - { - internalType: 'address[]', - name: 'path', - type: 'address[]' - }, - { - internalType: 'address', - name: 'to', - type: 'address' - }, - { - internalType: 'uint256', - name: 'deadline', - type: 'uint256' - } - ], - name: 'swapExactTokensForTokensSupportingFeeOnTransferTokens', - outputs: [], - stateMutability: 'nonpayable', - type: 'function' - }, - { - inputs: [ - { - internalType: 'uint256', - name: 'amountOut', - type: 'uint256' - }, - { - internalType: 'uint256', - name: 'amountInMax', - type: 'uint256' - }, - { - internalType: 'address[]', - name: 'path', - type: 'address[]' - }, - { - internalType: 'address', - name: 'to', - type: 'address' - }, - { - internalType: 'uint256', - name: 'deadline', - type: 'uint256' - } - ], - name: 'swapTokensForExactETH', - outputs: [ - { - internalType: 'uint256[]', - name: 'amounts', - type: 'uint256[]' - } - ], - stateMutability: 'nonpayable', - type: 'function' - }, - { - inputs: [ - { - internalType: 'uint256', - name: 'amountOut', - type: 'uint256' - }, - { - internalType: 'uint256', - name: 'amountInMax', - type: 'uint256' - }, - { - internalType: 'address[]', - name: 'path', - type: 'address[]' - }, - { - internalType: 'address', - name: 'to', - type: 'address' - }, - { - internalType: 'uint256', - name: 'deadline', - type: 'uint256' - } - ], - name: 'swapTokensForExactTokens', - outputs: [ - { - internalType: 'uint256[]', - name: 'amounts', - type: 'uint256[]' - } - ], - stateMutability: 'nonpayable', - type: 'function' - } -] as const; - -export class IUniswapV2Router02__factory { - static readonly abi = _abi; - static createInterface(): IUniswapV2Router02Interface { - return new utils.Interface(_abi) as IUniswapV2Router02Interface; - } - static connect( - address: string, - signerOrProvider: Signer | Provider - ): IUniswapV2Router02 { - return new Contract(address, _abi, signerOrProvider) as IUniswapV2Router02; - } -} diff --git a/packages/common/src/universal-swap/config/abi/v2-periphery/contracts/interfaces/index.ts b/packages/common/src/universal-swap/config/abi/v2-periphery/contracts/interfaces/index.ts deleted file mode 100644 index 612b1e8fd..000000000 --- a/packages/common/src/universal-swap/config/abi/v2-periphery/contracts/interfaces/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -/* Autogenerated file. Do not edit manually. */ -/* tslint:disable */ -/* eslint-disable */ -export { IUniswapV2Router01__factory } from "./IUniswapV2Router01__factory"; -export { IUniswapV2Router02__factory } from "./IUniswapV2Router02__factory"; diff --git a/packages/common/src/universal-swap/config/abi/v2-periphery/index.ts b/packages/common/src/universal-swap/config/abi/v2-periphery/index.ts deleted file mode 100644 index 6397da096..000000000 --- a/packages/common/src/universal-swap/config/abi/v2-periphery/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -/* Autogenerated file. Do not edit manually. */ -/* tslint:disable */ -/* eslint-disable */ -export * as contracts from "./contracts"; diff --git a/packages/common/src/universal-swap/config/bridgeTokens.ts b/packages/common/src/universal-swap/config/bridgeTokens.ts index dd5093939..0da19e4d1 100644 --- a/packages/common/src/universal-swap/config/bridgeTokens.ts +++ b/packages/common/src/universal-swap/config/bridgeTokens.ts @@ -3,9 +3,7 @@ import uniqBy from 'lodash/uniqBy'; import { CustomChainInfo, CoinGeckoId, - CoinIcon, chainInfos, - EvmChainId, NetworkChainId, NetworkName, oraichainNetwork @@ -99,8 +97,6 @@ export const cw20Tokens = uniqBy( c => c.denom ); -export const cw20TokenMap = Object.fromEntries(cw20Tokens.map(c => [c.contractAddress, c])); - export const evmTokens = uniqBy( flattenTokens.filter( token => @@ -109,32 +105,3 @@ export const evmTokens = uniqBy( ), c => c.denom ); - -export const kawaiiTokens = uniqBy( - cosmosTokens.filter(token => token.chainId === 'kawaii_6886-1'), - c => c.denom -); - -export const gravityContracts: Omit, '0x1ae6'> = { - '0x38': process.env.REACT_APP_GRAVITY_BSC_CONTRACT, - '0x01': process.env.REACT_APP_GRAVITY_ETH_CONTRACT, - '0x2b6653dc': process.env.REACT_APP_GRAVITY_TRON_CONTRACT -}; - -// universal swap. Currently we dont support from tokens that are not using the ibc wasm channel -export const swapFromTokens = flattenTokens.filter( - token => - token.coinGeckoId !== 'kawaii-islands' && - token.coinGeckoId !== 'milky-token' && - token.chainId !== 'oraibridge-subnet-2' && - token.chainId !== 'cosmoshub-4' && - token.chainId !== 'osmosis-1' && - token.chainId !== 'kawaii_6886-1' -); -// universal swap. We dont support kwt & milky for simplicity. We also skip OraiBridge tokens because users dont care about them -export const swapToTokens = flattenTokens.filter( - token => - token.coinGeckoId !== 'kawaii-islands' && - token.coinGeckoId !== 'milky-token' && - token.chainId !== 'oraibridge-subnet-2' -); diff --git a/packages/common/src/universal-swap/config/chainInfos.ts b/packages/common/src/universal-swap/config/chainInfos.ts deleted file mode 100644 index 542a9f47d..000000000 --- a/packages/common/src/universal-swap/config/chainInfos.ts +++ /dev/null @@ -1,633 +0,0 @@ -import { CoinGeckoId, NetworkChainId, EvmChainId, CustomChainInfo } from '@oraichain/oraidex-common'; -import { - AIRI_BSC_CONTRACT, - KWT_BSC_CONTRACT, - KWT_DENOM, - MILKY_BSC_CONTRACT, - MILKY_DENOM, - MILKY_ERC_CONTRACT, - ORAI_BRIDGE_EVM_DENOM_PREFIX, - ORAI_BRIDGE_EVM_ETH_DENOM_PREFIX, - ORAI_BRIDGE_EVM_TRON_DENOM_PREFIX, - ORAI_BSC_CONTRACT, - ORAI_ETH_CONTRACT, - USDC_ETH_CONTRACT, - USDT_BSC_CONTRACT, - USDT_TRON_CONTRACT, - WRAP_TRON_TRX_CONTRACT -} from './constants'; - -const OraiIcon = 'https://s2.coinmarketcap.com/static/img/coins/64x64/7533.png'; -const OraiLightIcon = 'https://s2.coinmarketcap.com/static/img/coins/64x64/7533.png'; -const AtomIcon = 'https://s2.coinmarketcap.com/static/img/coins/64x64/3794.png'; -const AiriIcon = 'https://i.ibb.co/m8mCyMr/airi.png'; -const UsdtIcon = 'https://s2.coinmarketcap.com/static/img/coins/64x64/825.png'; -const KwtIcon = 'https://s2.coinmarketcap.com/static/img/coins/64x64/12313.png'; -const OsmoLightIcon = 'https://assets.coingecko.com/coins/images/16724/large/osmo.png?1632763885'; -const OsmoIcon = 'https://assets.coingecko.com/coins/images/16724/large/osmo.png?1632763885'; -const UsdcIcon = 'https://s2.coinmarketcap.com/static/img/coins/64x64/3408.png'; -const ScOraiIcon = 'https://s2.coinmarketcap.com/static/img/coins/64x64/7533.png'; -const OraixIcon = 'https://i.ibb.co/VmMJtf7/oraix.png'; -const MilkyIcon = 'https://s2.coinmarketcap.com/static/img/coins/64x64/14418.png'; -const TronIcon = 'https://s2.coinmarketcap.com/static/img/coins/64x64/1958.png'; -const ScAtomIcon = 'https://s2.coinmarketcap.com/static/img/coins/64x64/3794.png'; -const EthIcon = 'https://s2.coinmarketcap.com/static/img/coins/64x64/1027.png'; -const BnbIcon = 'https://s2.coinmarketcap.com/static/img/coins/64x64/1839.png'; -const OraixLightIcon = 'https://i.ibb.co/VmMJtf7/oraix.png'; - -export type NetworkType = 'cosmos' | 'evm'; -export type CoinIcon = React.FunctionComponent>; -export type BridgeAppCurrency = any & { - readonly bridgeTo?: NetworkChainId[]; - readonly coinGeckoId?: CoinGeckoId; - readonly Icon?: string; - readonly IconLight?: string; - readonly bridgeNetworkIdentifier?: EvmChainId; - readonly coinDecimals: 6 | 18; - readonly contractAddress?: string; - readonly prefixToken?: string; -}; - -export type CoinType = 118 | 60 | 195; - -export const defaultBech32Config = ( - mainPrefix: string, - validatorPrefix = 'val', - consensusPrefix = 'cons', - publicPrefix = 'pub', - operatorPrefix = 'oper' -) => { - return { - bech32PrefixAccAddr: mainPrefix, - bech32PrefixAccPub: mainPrefix + publicPrefix, - bech32PrefixValAddr: mainPrefix + validatorPrefix + operatorPrefix, - bech32PrefixValPub: mainPrefix + validatorPrefix + operatorPrefix + publicPrefix, - bech32PrefixConsAddr: mainPrefix + validatorPrefix + consensusPrefix, - bech32PrefixConsPub: mainPrefix + validatorPrefix + consensusPrefix + publicPrefix - }; -}; - -export const OraiToken: BridgeAppCurrency = { - coinDenom: 'ORAI', - coinMinimalDenom: 'orai', - coinDecimals: 6, - coinGeckoId: 'oraichain-token', - Icon: OraiIcon, - IconLight: OraiLightIcon, - bridgeTo: ['0x38', '0x01'], - gasPriceStep: { - low: 0.003, - average: 0.005, - high: 0.007 - } -}; - -const OraiBToken: BridgeAppCurrency = { - coinDenom: 'ORAIB', - coinMinimalDenom: 'uoraib', - coinDecimals: 6, - gasPriceStep: { - low: 0, - average: 0, - high: 0 - } -}; - -const KawaiiToken: BridgeAppCurrency = { - coinDenom: 'ORAIE', - coinMinimalDenom: 'oraie', - coinDecimals: 18, - coinGeckoId: 'kawaii-islands', - Icon: KwtIcon, - gasPriceStep: { - low: 0, - average: 0.000025, - high: 0.00004 - } -}; - -export const oraichainNetwork: CustomChainInfo = { - rpc: 'https://rpc.orai.io', - rest: 'https://lcd.orai.io', - chainId: 'Oraichain', - chainName: 'Oraichain', - networkType: 'cosmos', - stakeCurrency: OraiToken, - bip44: { - coinType: 118 - }, - bech32Config: defaultBech32Config('orai'), - feeCurrencies: [OraiToken], - - Icon: OraiIcon, - IconLight: OraiLightIcon, - features: ['ibc-transfer', 'cosmwasm', 'wasmd_0.24+'], - currencies: [ - OraiToken, - { - coinDenom: 'ATOM', - coinGeckoId: 'cosmos', - coinMinimalDenom: process.env.REACT_APP_ATOM_ORAICHAIN_DENOM, - bridgeTo: ['cosmoshub-4'], - coinDecimals: 6, - Icon: AtomIcon, - IconLight: AtomIcon - }, - // { - // coinDenom: 'BEP20 AIRI', - // coinGeckoId: 'airight', - // coinMinimalDenom: process.env.REACT_APP_AIRIBSC_ORAICHAIN_DENOM, - // coinDecimals: 18, - // Icon: AiriIcon - // }, - { - coinDenom: 'AIRI', - coinGeckoId: 'airight', - coinMinimalDenom: 'airi', - type: 'cw20', - contractAddress: process.env.REACT_APP_AIRI_CONTRACT, - bridgeTo: ['0x38'], - coinDecimals: 6, - Icon: AiriIcon - }, - { - coinDenom: 'USDT', - coinGeckoId: 'tether', - coinMinimalDenom: 'usdt', - type: 'cw20', - contractAddress: process.env.REACT_APP_USDT_CONTRACT, - bridgeTo: ['0x38', '0x2b6653dc'], - coinDecimals: 6, - Icon: UsdtIcon - }, - { - coinDenom: 'USDC', - coinGeckoId: 'usd-coin', - coinMinimalDenom: 'usdc', - type: 'cw20', - contractAddress: process.env.REACT_APP_USDC_CONTRACT, - bridgeTo: ['0x01'], - coinDecimals: 6, - Icon: UsdcIcon - }, - { - coinDenom: 'OSMO', - coinMinimalDenom: process.env.REACT_APP_OSMOSIS_ORAICHAIN_DENOM, - coinDecimals: 6, - coinGeckoId: 'osmosis', - bridgeTo: ['osmosis-1'], - Icon: OsmoIcon, - IconLight: OsmoLightIcon - }, - { - coinDenom: 'BEP20 KWT', - coinGeckoId: 'kawaii-islands', - coinMinimalDenom: process.env.REACT_APP_KWTBSC_ORAICHAIN_DENOM, - coinDecimals: 18, - Icon: KwtIcon - }, - { - coinDenom: 'KWT', - coinGeckoId: 'kawaii-islands', - coinMinimalDenom: 'kwt', - type: 'cw20', - contractAddress: process.env.REACT_APP_KWT_CONTRACT, - bridgeTo: ['kawaii_6886-1', '0x38'], - coinDecimals: 6, - Icon: KwtIcon - }, - { - coinDenom: 'BEP20 MILKY', - coinGeckoId: 'milky-token', - coinMinimalDenom: process.env.REACT_APP_MILKYBSC_ORAICHAIN_DENOM, - coinDecimals: 18, - Icon: MilkyIcon - }, - { - coinDenom: 'MILKY', - coinGeckoId: 'milky-token', - coinMinimalDenom: 'milky', - type: 'cw20', - contractAddress: process.env.REACT_APP_MILKY_CONTRACT, - bridgeTo: ['kawaii_6886-1', '0x38'], - coinDecimals: 6, - Icon: MilkyIcon - }, - { - coinDenom: 'ORAIX', - coinMinimalDenom: 'oraix', - type: 'cw20', - contractAddress: process.env.REACT_APP_ORAIX_CONTRACT, - coinGeckoId: 'oraidex', - coinDecimals: 6, - Icon: OraixIcon, - IconLight: OraixLightIcon - }, - { - coinDenom: 'scORAI', - coinMinimalDenom: 'scorai', - type: 'cw20', - contractAddress: process.env.REACT_APP_SCORAI_CONTRACT, - coinGeckoId: 'scorai', - coinDecimals: 6, - Icon: ScOraiIcon - }, - { - coinDenom: 'wTRX', - coinGeckoId: 'tron', - coinMinimalDenom: 'trx', - type: 'cw20', - contractAddress: process.env.REACT_APP_TRX_CONTRACT, - bridgeTo: ['0x2b6653dc'], - coinDecimals: 6, - Icon: TronIcon - }, - { - coinDenom: 'scATOM', - coinMinimalDenom: 'scatom', - type: 'cw20', - contractAddress: process.env.REACT_APP_SCATOM_CONTRACT, - coinGeckoId: 'scatom', - coinDecimals: 6, - Icon: ScAtomIcon - } - // { - // coinDenom: 'ATOM-CW20', - // coinGeckoId: 'cosmos', - // coinMinimalDenom: 'uatom', - // type: 'cw20', - // contractAddress: 'orai17l2zk3arrx0a0fyuneyx8raln68622a2lrsz8ph75u7gw9tgz3esayqryf', - // bridgeTo: ['cosmoshub-4'], - // coinDecimals: 6, - // Icon: AtomIcon - // } - ] -}; - -export const chainInfos: CustomChainInfo[] = [ - // networks to add on keplr - oraichainNetwork, - { - rpc: 'https://bridge-v2.rpc.orai.io', - rest: 'https://bridge-v2.lcd.orai.io', - chainId: 'oraibridge-subnet-2', - chainName: 'OraiBridge', - networkType: 'cosmos', - bip44: { - coinType: 118 - }, - bech32Config: defaultBech32Config('oraib'), - - features: ['ibc-transfer'], - stakeCurrency: OraiBToken, - feeCurrencies: [OraiBToken], - // not use oraib as currency - currencies: [ - OraiBToken, - { - coinDenom: 'ORAI', - coinMinimalDenom: ORAI_BRIDGE_EVM_DENOM_PREFIX + ORAI_BSC_CONTRACT, - bridgeNetworkIdentifier: '0x38', - coinDecimals: 18, - coinGeckoId: 'oraichain-token', - IconLight: OraiLightIcon, - Icon: OraiIcon - }, - { - coinDenom: 'ORAI', - coinMinimalDenom: ORAI_BRIDGE_EVM_ETH_DENOM_PREFIX + ORAI_ETH_CONTRACT, - bridgeNetworkIdentifier: '0x01', - coinDecimals: 18, - coinGeckoId: 'oraichain-token', - IconLight: OraiLightIcon, - prefixToken: ORAI_BRIDGE_EVM_ETH_DENOM_PREFIX, - Icon: OraiIcon - }, - { - coinDenom: 'USDC', - coinMinimalDenom: ORAI_BRIDGE_EVM_ETH_DENOM_PREFIX + USDC_ETH_CONTRACT, - bridgeNetworkIdentifier: '0x01', - coinDecimals: 6, - coinGeckoId: 'usd-coin', - prefixToken: ORAI_BRIDGE_EVM_ETH_DENOM_PREFIX, - Icon: UsdcIcon - }, - { - coinDenom: 'AIRI', - coinMinimalDenom: ORAI_BRIDGE_EVM_DENOM_PREFIX + AIRI_BSC_CONTRACT, - bridgeNetworkIdentifier: '0x38', - coinDecimals: 18, - coinGeckoId: 'airight', - Icon: AiriIcon - }, - { - coinDenom: 'USDT', - coinMinimalDenom: ORAI_BRIDGE_EVM_DENOM_PREFIX + USDT_BSC_CONTRACT, - bridgeNetworkIdentifier: '0x38', - coinDecimals: 18, - coinGeckoId: 'tether', - Icon: UsdtIcon - }, - { - coinDenom: 'USDT', - coinMinimalDenom: ORAI_BRIDGE_EVM_TRON_DENOM_PREFIX + USDT_TRON_CONTRACT, - bridgeNetworkIdentifier: '0x2b6653dc', - prefixToken: ORAI_BRIDGE_EVM_TRON_DENOM_PREFIX, - coinDecimals: 6, - coinGeckoId: 'tether', - Icon: UsdtIcon - }, - { - coinDenom: 'wTRX', - coinMinimalDenom: ORAI_BRIDGE_EVM_TRON_DENOM_PREFIX + WRAP_TRON_TRX_CONTRACT, - bridgeNetworkIdentifier: '0x2b6653dc', - coinDecimals: 6, - coinGeckoId: 'tron', - prefixToken: ORAI_BRIDGE_EVM_TRON_DENOM_PREFIX, - Icon: TronIcon - }, - { - coinDenom: 'KWT', - bridgeNetworkIdentifier: '0x38', - coinMinimalDenom: KWT_DENOM, - coinDecimals: 18, - coinGeckoId: 'kawaii-islands', - Icon: KwtIcon - }, - { - coinDenom: 'MILKY', - bridgeNetworkIdentifier: '0x38', - coinMinimalDenom: MILKY_DENOM, - coinDecimals: 18, - coinGeckoId: 'milky-token', - Icon: MilkyIcon - } - ] - }, - { - rpc: 'https://tendermint1.kawaii.global', - rest: 'https://cosmos1.kawaii.global', - chainId: 'kawaii_6886-1', - chainName: 'Kawaiiverse', - networkType: 'cosmos', - stakeCurrency: KawaiiToken, - bip44: { - coinType: 60 - }, - bech32Config: defaultBech32Config('oraie'), - feeCurrencies: [KawaiiToken], - - Icon: KwtIcon, - // features: ['ibc-transfer'], - features: ['ibc-transfer', 'ibc-go', 'stargate', 'eth-address-gen', 'eth-key-sign'], - currencies: [ - KawaiiToken, - { - coinDenom: 'MILKY', - coinGeckoId: 'milky-token', - coinMinimalDenom: process.env.REACT_APP_MILKY_SUB_NETWORK_DENOM, - coinDecimals: 18, - bridgeTo: ['Oraichain', 'kawaii_6886-1'], - Icon: MilkyIcon - }, - { - coinDenom: 'ERC20 MILKY', - coinMinimalDenom: 'erc20_milky', - bridgeTo: ['Oraichain', 'kawaii_6886-1'], - contractAddress: MILKY_ERC_CONTRACT, - coinDecimals: 18, - coinGeckoId: 'milky-token', - Icon: MilkyIcon - }, - { - coinDenom: 'KWT', - coinMinimalDenom: process.env.REACT_APP_KWT_SUB_NETWORK_DENOM, - coinDecimals: 18, - bridgeTo: ['Oraichain', 'kawaii_6886-1'], - coinGeckoId: 'kawaii-islands', - Icon: KwtIcon - }, - { - coinDenom: 'ERC20 KWT', - bridgeTo: ['Oraichain', 'kawaii_6886-1'], - coinMinimalDenom: 'erc20_kwt', - contractAddress: '0x80b5a32E4F032B2a058b4F29EC95EEfEEB87aDcd', - coinDecimals: 18, - coinGeckoId: 'kawaii-islands', - Icon: KwtIcon - } - ] - }, - - /// popular networks already included - { - rpc: 'https://osmosis-rpc.polkachu.com', - rest: 'https://osmosis-api.polkachu.com', - chainId: 'osmosis-1', - chainName: 'Osmosis', - networkType: 'cosmos', - bip44: { - coinType: 118 - }, - Icon: OsmoIcon, - IconLight: OsmoLightIcon, - bech32Config: defaultBech32Config('osmo'), - currencies: [ - { - coinDenom: 'OSMO', - coinMinimalDenom: 'uosmo', - coinDecimals: 6, - coinGeckoId: 'osmosis', - bridgeTo: ['Oraichain'], - Icon: OsmoIcon, - IconLight: OsmoLightIcon - } - ] - }, - { - rpc: 'https://rpc-cosmos.oraidex.io', - rest: 'https://lcd-cosmos.oraidex.io', - chainId: 'cosmoshub-4', - chainName: 'Cosmos Hub', - networkType: 'cosmos', - bip44: { - coinType: 118 - }, - Icon: AtomIcon, - bech32Config: defaultBech32Config('cosmos'), - currencies: [ - { - coinDenom: 'ATOM', - coinGeckoId: 'cosmos', - coinMinimalDenom: 'uatom', - coinDecimals: 6, - bridgeTo: ['Oraichain'], - Icon: AtomIcon - } - ] - }, - - /// evm chain info - { - rpc: 'https://rpc.ankr.com/eth', - chainId: '0x01', - chainName: 'Ethereum', - bip44: { - coinType: 60 - }, - Icon: EthIcon, - networkType: 'evm', - currencies: [ - { - coinDenom: 'ORAI', - coinMinimalDenom: 'erc20_orai', - contractAddress: ORAI_ETH_CONTRACT, - coinDecimals: 18, - bridgeTo: ['Oraichain'], - coinGeckoId: 'oraichain-token', - IconLight: OraiLightIcon, - prefixToken: ORAI_BRIDGE_EVM_ETH_DENOM_PREFIX, - Icon: OraiIcon - }, - { - coinDenom: 'USDC', - coinMinimalDenom: 'erc20_usdc', - contractAddress: USDC_ETH_CONTRACT, - coinDecimals: 6, - bridgeTo: ['Oraichain'], - coinGeckoId: 'usd-coin', - prefixToken: ORAI_BRIDGE_EVM_ETH_DENOM_PREFIX, - Icon: UsdcIcon - } - ] - }, - { - rpc: 'https://api.trongrid.io/jsonrpc', - rest: 'https://api.trongrid.io', - chainId: '0x2b6653dc', - networkType: 'evm', - chainName: 'Tron Network', - Icon: TronIcon, - currencies: [ - { - coinDenom: 'USDT', - coinMinimalDenom: 'trx20_usdt', - contractAddress: USDT_TRON_CONTRACT, - bridgeTo: ['Oraichain'], - coinDecimals: 6, - coinGeckoId: 'tether', - prefixToken: ORAI_BRIDGE_EVM_TRON_DENOM_PREFIX, - Icon: UsdtIcon - }, - { - coinDenom: 'wTRX', - coinMinimalDenom: 'trx20_trx', - contractAddress: WRAP_TRON_TRX_CONTRACT, - bridgeTo: ['Oraichain'], - coinDecimals: 6, - coinGeckoId: 'tron', - prefixToken: ORAI_BRIDGE_EVM_TRON_DENOM_PREFIX, - Icon: TronIcon - } - ], - bip44: { - coinType: 195 - } - }, - { - rpc: 'https://bsc-dataseed1.binance.org', - networkType: 'evm', - Icon: BnbIcon, - chainId: '0x38', - chainName: 'BNB Chain', - bip44: { - coinType: 60 - }, - currencies: [ - { - coinDenom: 'ORAI', - coinMinimalDenom: 'bep20_orai', - contractAddress: ORAI_BSC_CONTRACT, - bridgeTo: ['Oraichain'], - coinDecimals: 18, - coinGeckoId: 'oraichain-token', - prefixToken: ORAI_BRIDGE_EVM_DENOM_PREFIX, - Icon: OraiIcon, - IconLight: OraiLightIcon - }, - { - coinDenom: 'AIRI', - coinMinimalDenom: 'bep20_airi', - contractAddress: AIRI_BSC_CONTRACT, - bridgeTo: ['Oraichain'], - coinDecimals: 18, - coinGeckoId: 'airight', - prefixToken: ORAI_BRIDGE_EVM_DENOM_PREFIX, - Icon: AiriIcon - }, - { - coinDenom: 'USDT', - coinMinimalDenom: 'bep20_usdt', - contractAddress: USDT_BSC_CONTRACT, - bridgeTo: ['Oraichain'], - coinDecimals: 18, - coinGeckoId: 'tether', - prefixToken: ORAI_BRIDGE_EVM_DENOM_PREFIX, - Icon: UsdtIcon - }, - { - coinDenom: 'KWT', - coinMinimalDenom: 'bep20_kwt', - contractAddress: KWT_BSC_CONTRACT, - bridgeTo: ['Oraichain'], - coinDecimals: 18, - coinGeckoId: 'kawaii-islands', - Icon: KwtIcon - }, - { - coinDenom: 'MILKY', - coinMinimalDenom: 'bep20_milky', - contractAddress: MILKY_BSC_CONTRACT, - coinDecimals: 18, - coinGeckoId: 'milky-token', - bridgeTo: ['Oraichain'], - Icon: MilkyIcon - } - ] - }, - { - rpc: 'https://endpoint1.kawaii.global', - chainId: '0x1ae6', - networkType: 'evm', - chainName: 'Kawaiiverse EVM', - Icon: KwtIcon, - bip44: { - coinType: 60 - }, - currencies: [ - { - coinDenom: 'ERC20 MILKY', - coinMinimalDenom: 'erc20_milky', - bridgeTo: ['Oraichain', 'kawaii_6886-1'], - contractAddress: MILKY_ERC_CONTRACT, - coinDecimals: 18, - coinGeckoId: 'milky-token', - Icon: MilkyIcon - }, - { - coinDenom: 'ERC20 KWT', - bridgeTo: ['Oraichain', 'kawaii_6886-1'], - coinMinimalDenom: 'erc20_kwt', - contractAddress: '0x80b5a32E4F032B2a058b4F29EC95EEfEEB87aDcd', - coinDecimals: 18, - coinGeckoId: 'kawaii-islands', - Icon: KwtIcon - } - ] - } -]; - -// exclude kawaiverse subnet and other special evm that has different cointype -export const evmChains = chainInfos.filter( - c => c.networkType === 'evm' && c.bip44.coinType === 60 && c.chainId !== '0x1ae6' -); diff --git a/packages/common/src/universal-swap/config/ibcInfos.ts b/packages/common/src/universal-swap/config/ibcInfos.ts deleted file mode 100644 index e69de29bb..000000000 diff --git a/packages/common/src/universal-swap/config/index.ts b/packages/common/src/universal-swap/config/index.ts index 4b27970d6..542463f89 100644 --- a/packages/common/src/universal-swap/config/index.ts +++ b/packages/common/src/universal-swap/config/index.ts @@ -1,3 +1,2 @@ export * from './bridgeTokens'; -export * from './chainInfos'; export * from './constants'; diff --git a/packages/common/src/universal-swap/config/pools.ts b/packages/common/src/universal-swap/config/pools.ts deleted file mode 100644 index e69de29bb..000000000 diff --git a/packages/common/src/universal-swap/index.ts b/packages/common/src/universal-swap/index.ts index 9d8a4600b..cd5d4740f 100644 --- a/packages/common/src/universal-swap/index.ts +++ b/packages/common/src/universal-swap/index.ts @@ -4,4 +4,3 @@ export * from './config'; export * from './libs'; export * from './types'; export * from './cw-stargate'; -export * from './wallet'; diff --git a/packages/common/src/universal-swap/wallet/index.ts b/packages/common/src/universal-swap/wallet/index.ts deleted file mode 100644 index 8e38f1dbe..000000000 --- a/packages/common/src/universal-swap/wallet/index.ts +++ /dev/null @@ -1,224 +0,0 @@ -import { JsonRpcProvider, JsonRpcSigner } from '@ethersproject/providers'; -import { - CosmosWallet, - EvmWallet, - NetworkChainId, - CosmosChainId, - TokenItemType, - EvmResponse, - Networks, - IERC20Upgradeable__factory, - ethToTronAddress -} from '@oraichain/oraidex-common'; -import { OfflineSigner } from '@cosmjs/proto-signing'; -import { SigningCosmWasmClient } from '@cosmjs/cosmwasm-stargate'; -import { OWallet, Ethereum, TronWeb } from '@owallet/types'; -import { SigningStargateClient, SigningStargateClientOptions } from '@cosmjs/stargate'; -import { ethers } from 'ethers'; -import { tronToEthAddress } from '../helper'; - -export class SwapCosmosWallet extends CosmosWallet { - private client: SigningCosmWasmClient; - private owallet: OWallet; - constructor(params: { client: SigningCosmWasmClient; owallet: OWallet }) { - super(); - this.client = params.client; - this.owallet = params.owallet; - } - - async getKeplrAddr(chainId?: NetworkChainId | undefined): Promise { - try { - const key = await this.owallet.getKey(chainId); - return key?.bech32Address; - } catch (ex) { - console.log(ex, chainId); - } - } - - async createCosmosSigner(chainId: string): Promise { - if (!this.owallet) { - throw new Error('You have to have OWallet first if you do not use a mnemonic to sign transactions'); - } - return await this.owallet.getOfflineSignerAuto(chainId); - } - - async getCosmWasmClient( - config: { - signer?: OfflineSigner; - rpc?: string; - chainId: CosmosChainId; - }, - options?: SigningStargateClientOptions - ): Promise<{ - wallet: OfflineSigner; - client: SigningCosmWasmClient; - // defaultAddress: AccountData; - stargateClient: SigningStargateClient; - }> { - const { chainId, signer, rpc } = config; - const wallet = signer ?? (await this.createCosmosSigner(chainId)); - // const defaultAddress = (await wallet.getAccounts())[0]; - const stargateClient = await SigningStargateClient.connectWithSigner(rpc, wallet, options); - - return new Promise(resolve => - resolve({ - client: this.client, - wallet: wallet ?? config.signer!, - // defaultAddress, - stargateClient: stargateClient - }) - ); - } -} - -export class SwapEvmWallet extends EvmWallet { - private provider: JsonRpcProvider; - private ethereum: Ethereum; - //@ts-ignore - private tronWeb: TronWeb; - private isTronToken: boolean; - constructor(params: { isTronToken: boolean; tronWeb: TronWeb; ethereum: Ethereum }) { - super(); - this.ethereum = params.ethereum; - this.isTronToken = params.isTronToken; - this.tronWeb = params.tronWeb; - // used 'any' to fix the following bug: https://github.com/ethers-io/ethers.js/issues/1107 -> https://github.com/Geo-Web-Project/cadastre/pull/220/files - this.provider = new ethers.providers.Web3Provider(this.ethereum, 'any'); - } - - async switchNetwork(chainId: string | number): Promise { - return this.ethereum.request!({ - method: 'wallet_switchEthereumChain', - chainId: '0x' + Number(chainId).toString(16), - params: [{ chainId: '0x' + Number(chainId).toString(16) }] - }); - } - - async getEthAddress(): Promise { - if (this.checkEthereum()) { - const [address] = await this.ethereum.request({ - method: 'eth_requestAccounts', - params: [] - }); - return address; - } - } - - checkEthereum(): boolean { - return !this.isTronToken; - } - - public isTron(chainId: string | number) { - return Number(chainId) === Networks.tron; - } - - checkTron(): boolean { - return this.isTronToken; - } - - getSigner(): JsonRpcSigner { - return this.provider.getSigner(); - } - - public async submitTronSmartContract( - address: string, - functionSelector: string, - options: { feeLimit?: number } = { feeLimit: 40 * 1e6 }, // submitToCosmos costs about 40 TRX - parameters = [], - issuerAddress: string - ): Promise { - if (!this.tronWeb) { - throw new Error('You need to initialize tron web before calling submitTronSmartContract.'); - } - try { - const uint256Index = parameters.findIndex(param => param.type === 'uint256'); - - // type uint256 is bigint, so we need to convert to string if its uint256 because the JSONUint8Array can not stringify bigint - if (uint256Index && parameters.length > uint256Index) { - parameters[uint256Index] = { - ...parameters[uint256Index], - value: - typeof parameters[uint256Index].value === 'bigint' - ? parameters[uint256Index].value.toString() - : parameters[uint256Index].value - }; - } - - const transaction = await this.tronWeb.triggerSmartContract( - address, - functionSelector, - options, - parameters, - ethToTronAddress(issuerAddress) - ); - - console.log('transaction builder: ', transaction); - - if (!transaction.result || !transaction.result.result) { - throw new Error('Unknown trigger error: ' + JSON.stringify(transaction.transaction)); - } - console.log('before signing'); - - // sign from inject tronWeb - const singedTransaction = (await this.tronWeb.sign(transaction.transaction)) as { - raw_data: any; - raw_data_hex: string; - txID: string; - visible?: boolean; - }; - console.log('signed tx: ', singedTransaction); - const result = (await this.tronWeb.sendRawTransaction(singedTransaction)) as { - txid?: string; - }; - if (result) { - return { transactionHash: result.txid }; - } - } catch (error) { - console.log('error', error); - - throw new Error(error); - } - } - - public async checkOrIncreaseAllowance( - token: TokenItemType, - owner: string, - spender: string, - amount: string - ): Promise { - // we store the tron address in base58 form, so we need to convert to hex if its tron because the contracts are using the hex form as parameters - if (!token.contractAddress) return; - - const ownerHex = this.isTron(token.chainId) ? tronToEthAddress(owner) : owner; - // using static rpc for querying both tron and evm - const tokenContract = IERC20Upgradeable__factory.connect( - token.contractAddress, - new ethers.providers.JsonRpcProvider(token.rpc) - ); - - const currentAllowance = await tokenContract.allowance(ownerHex, spender); - - if (BigInt(currentAllowance.toString()) >= BigInt(amount)) return; - - if (this.isTron(token.chainId)) { - if (this.checkTron()) - return this.submitTronSmartContract( - ethToTronAddress(token.contractAddress), - 'approve(address,uint256)', - {}, - [ - { type: 'address', value: spender }, - { type: 'uint256', value: amount } - ], - ownerHex - ); - } else if (this.checkEthereum()) { - // using ethereum for signing - // if you call this function on evm, you have to switch network before calling. Otherwise, unexpected errors may happen - const tokenContract = IERC20Upgradeable__factory.connect(token.contractAddress, this.getSigner()); - const result = await tokenContract.approve(spender, amount, { from: ownerHex }); - await result.wait(); - return { transactionHash: result.hash }; - } - } -} diff --git a/packages/hooks/src/universal-swap/use-client.ts b/packages/hooks/src/universal-swap/use-client.ts index a359e6eee..008e6661e 100644 --- a/packages/hooks/src/universal-swap/use-client.ts +++ b/packages/hooks/src/universal-swap/use-client.ts @@ -1,4 +1,5 @@ -import { CWStargate, oraichainNetwork, ChainIdEnum } from '@owallet/common'; +import { CWStargate, ChainIdEnum } from '@owallet/common'; +import { oraichainNetwork } from '@oraichain/oraidex-common'; import { useEffect, useState } from 'react'; import { SigningCosmWasmClient } from '@cosmjs/cosmwasm-stargate'; import { AccountWithAll } from '@owallet/stores'; diff --git a/packages/hooks/src/universal-swap/use-load-tokens.ts b/packages/hooks/src/universal-swap/use-load-tokens.ts index 04b38d4ce..b403848c3 100644 --- a/packages/hooks/src/universal-swap/use-load-tokens.ts +++ b/packages/hooks/src/universal-swap/use-load-tokens.ts @@ -4,10 +4,10 @@ import { MulticallQueryClient } from '@oraichain/common-contracts-sdk'; import { OraiswapTokenTypes } from '@oraichain/oraidex-contracts-sdk'; import { JsonRpcProvider } from '@ethersproject/providers'; import { fromBech32, toBech32 } from '@cosmjs/encoding'; -import { CustomChainInfo, EVM_BALANCE_RETRY_COUNT, ERC20__factory } from '@oraichain/oraidex-common'; +import { CustomChainInfo, EVM_BALANCE_RETRY_COUNT, ERC20__factory, evmChains } from '@oraichain/oraidex-common'; import flatten from 'lodash/flatten'; import { ContractCallResults } from 'ethereum-multicall'; -import { Multicall, evmChains, evmTokens, isEvmNetworkNativeSwapSupported, getEvmAddress } from '@owallet/common'; +import { Multicall, evmTokens, isEvmNetworkNativeSwapSupported, getEvmAddress } from '@owallet/common'; import { chainInfos, network } from '@oraichain/oraidex-common'; import { cosmosTokens, oraichainTokens, tokenMap } from '@oraichain/oraidex-common'; import { CWStargate } from '@owallet/common'; diff --git a/packages/hooks/src/universal-swap/use-relayer-fee.ts b/packages/hooks/src/universal-swap/use-relayer-fee.ts index eef3b89fc..3b7e86d84 100644 --- a/packages/hooks/src/universal-swap/use-relayer-fee.ts +++ b/packages/hooks/src/universal-swap/use-relayer-fee.ts @@ -1,5 +1,6 @@ import { useEffect, useState } from 'react'; -import { CWStargate, fetchRelayerFee, oraichainNetwork, ChainIdEnum } from '@owallet/common'; +import { CWStargate, fetchRelayerFee, ChainIdEnum } from '@owallet/common'; +import { oraichainNetwork } from '@oraichain/oraidex-common'; import { AccountWithAll } from '@owallet/stores'; export const useRelayerFee = (accountOrai: AccountWithAll) => { diff --git a/packages/hooks/src/universal-swap/use-tax-rate.ts b/packages/hooks/src/universal-swap/use-tax-rate.ts index 19bcdcf5c..9ff7e1d23 100644 --- a/packages/hooks/src/universal-swap/use-tax-rate.ts +++ b/packages/hooks/src/universal-swap/use-tax-rate.ts @@ -1,4 +1,5 @@ -import { CWStargate, fetchTaxRate, oraichainNetwork, ChainIdEnum } from '@owallet/common'; +import { CWStargate, fetchTaxRate, ChainIdEnum } from '@owallet/common'; +import { oraichainNetwork } from '@oraichain/oraidex-common'; import { useEffect, useState } from 'react'; import { AccountWithAll } from '@owallet/stores';