From fdb562fed8997f0bde39729444e016006f578f0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CF=87=C2=B2?= <88190723+ChiTimesChi@users.noreply.github.com> Date: Mon, 22 Jul 2024 13:43:11 +0100 Subject: [PATCH] Deploy/bsc fast bridge router (#325) * build: add BSC FB deployment * deploy: FastBridgeRouter, SwapQuoterV2 on BNB * build: generate config for SwapQuoterV2 --- deployments/bsc/DefaultPoolCalc.json | 30 + deployments/bsc/FastBridge.json | 4 + deployments/bsc/FastBridgeRouter.json | 391 +++++++++++++ deployments/bsc/SwapQuoterV2.json | 703 ++++++++++++++++++++++++ script/configs/bsc/SwapQuoterV2.dc.json | 10 + 5 files changed, 1138 insertions(+) create mode 100644 deployments/bsc/DefaultPoolCalc.json create mode 100644 deployments/bsc/FastBridge.json create mode 100644 deployments/bsc/FastBridgeRouter.json create mode 100644 deployments/bsc/SwapQuoterV2.json create mode 100644 script/configs/bsc/SwapQuoterV2.dc.json diff --git a/deployments/bsc/DefaultPoolCalc.json b/deployments/bsc/DefaultPoolCalc.json new file mode 100644 index 000000000..c8d3c5586 --- /dev/null +++ b/deployments/bsc/DefaultPoolCalc.json @@ -0,0 +1,30 @@ +{ + "address": "0x0000000000Cc5af216a3E1614091a20e11bbfD32", + "constructorArgs": "0x", + "abi": [ + { + "type": "function", + "name": "calculateAddLiquidity", + "inputs": [ + { + "name": "pool", + "type": "address", + "internalType": "address" + }, + { + "name": "amounts", + "type": "uint256[]", + "internalType": "uint256[]" + } + ], + "outputs": [ + { + "name": "amountOut", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + } + ] +} \ No newline at end of file diff --git a/deployments/bsc/FastBridge.json b/deployments/bsc/FastBridge.json new file mode 100644 index 000000000..49b7c8b81 --- /dev/null +++ b/deployments/bsc/FastBridge.json @@ -0,0 +1,4 @@ +{ + "address": "0x5523D3c98809DdDB82C686E152F5C58B1B0fB59E", + "constructorArgs": "0x000000000000000000000000bd88862fcc17de436f7bd17276c537acadda9a67" +} diff --git a/deployments/bsc/FastBridgeRouter.json b/deployments/bsc/FastBridgeRouter.json new file mode 100644 index 000000000..64f929154 --- /dev/null +++ b/deployments/bsc/FastBridgeRouter.json @@ -0,0 +1,391 @@ +{ + "address": "0x0000000000489d89D2B233D3375C045dfD05745F", + "constructorArgs": "0x0000000000000000000000000fea3e5840334fc758a3decf14546bfdfbef5cd3", + "abi": [ + { + "type": "constructor", + "inputs": [ + { + "name": "owner_", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "receive", + "stateMutability": "payable" + }, + { + "type": "function", + "name": "GAS_REBATE_FLAG", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "bytes1", + "internalType": "bytes1" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "adapterSwap", + "inputs": [ + { + "name": "recipient", + "type": "address", + "internalType": "address" + }, + { + "name": "tokenIn", + "type": "address", + "internalType": "address" + }, + { + "name": "amountIn", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "tokenOut", + "type": "address", + "internalType": "address" + }, + { + "name": "rawParams", + "type": "bytes", + "internalType": "bytes" + } + ], + "outputs": [ + { + "name": "amountOut", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "payable" + }, + { + "type": "function", + "name": "bridge", + "inputs": [ + { + "name": "recipient", + "type": "address", + "internalType": "address" + }, + { + "name": "chainId", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "token", + "type": "address", + "internalType": "address" + }, + { + "name": "amount", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "originQuery", + "type": "tuple", + "internalType": "struct SwapQuery", + "components": [ + { + "name": "routerAdapter", + "type": "address", + "internalType": "address" + }, + { + "name": "tokenOut", + "type": "address", + "internalType": "address" + }, + { + "name": "minAmountOut", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "deadline", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "rawParams", + "type": "bytes", + "internalType": "bytes" + } + ] + }, + { + "name": "destQuery", + "type": "tuple", + "internalType": "struct SwapQuery", + "components": [ + { + "name": "routerAdapter", + "type": "address", + "internalType": "address" + }, + { + "name": "tokenOut", + "type": "address", + "internalType": "address" + }, + { + "name": "minAmountOut", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "deadline", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "rawParams", + "type": "bytes", + "internalType": "bytes" + } + ] + } + ], + "outputs": [], + "stateMutability": "payable" + }, + { + "type": "function", + "name": "fastBridge", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "getOriginAmountOut", + "inputs": [ + { + "name": "tokenIn", + "type": "address", + "internalType": "address" + }, + { + "name": "rfqTokens", + "type": "address[]", + "internalType": "address[]" + }, + { + "name": "amountIn", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "originQueries", + "type": "tuple[]", + "internalType": "struct SwapQuery[]", + "components": [ + { + "name": "routerAdapter", + "type": "address", + "internalType": "address" + }, + { + "name": "tokenOut", + "type": "address", + "internalType": "address" + }, + { + "name": "minAmountOut", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "deadline", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "rawParams", + "type": "bytes", + "internalType": "bytes" + } + ] + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "owner", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "renounceOwnership", + "inputs": [], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "setFastBridge", + "inputs": [ + { + "name": "fastBridge_", + "type": "address", + "internalType": "address" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "setSwapQuoter", + "inputs": [ + { + "name": "swapQuoter_", + "type": "address", + "internalType": "address" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "swapQuoter", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "transferOwnership", + "inputs": [ + { + "name": "newOwner", + "type": "address", + "internalType": "address" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "event", + "name": "FastBridgeSet", + "inputs": [ + { + "name": "newFastBridge", + "type": "address", + "indexed": false, + "internalType": "address" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "OwnershipTransferred", + "inputs": [ + { + "name": "previousOwner", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "newOwner", + "type": "address", + "indexed": true, + "internalType": "address" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "SwapQuoterSet", + "inputs": [ + { + "name": "newSwapQuoter", + "type": "address", + "indexed": false, + "internalType": "address" + } + ], + "anonymous": false + }, + { + "type": "error", + "name": "DeadlineExceeded", + "inputs": [] + }, + { + "type": "error", + "name": "InsufficientOutputAmount", + "inputs": [] + }, + { + "type": "error", + "name": "MsgValueIncorrect", + "inputs": [] + }, + { + "type": "error", + "name": "PoolNotFound", + "inputs": [] + }, + { + "type": "error", + "name": "TokenAddressMismatch", + "inputs": [] + }, + { + "type": "error", + "name": "TokenNotContract", + "inputs": [] + }, + { + "type": "error", + "name": "TokenNotETH", + "inputs": [] + }, + { + "type": "error", + "name": "TokensIdentical", + "inputs": [] + } + ] +} \ No newline at end of file diff --git a/deployments/bsc/SwapQuoterV2.json b/deployments/bsc/SwapQuoterV2.json new file mode 100644 index 000000000..40f47d427 --- /dev/null +++ b/deployments/bsc/SwapQuoterV2.json @@ -0,0 +1,703 @@ +{ + "address": "0x1Db5a1d5D80fDEfc098635d3869Fa94d6fA44F5a", + "constructorArgs": "0x0000000000000000000000007e7a0e201fd38d3adaa9523da6c109a07118c96a0000000000000000000000000000000000cc5af216a3e1614091a20e11bbfd32000000000000000000000000bb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c0000000000000000000000000fea3e5840334fc758a3decf14546bfdfbef5cd3", + "abi": [ + { + "type": "constructor", + "inputs": [ + { + "name": "synapseRouter_", + "type": "address", + "internalType": "address" + }, + { + "name": "defaultPoolCalc_", + "type": "address", + "internalType": "address" + }, + { + "name": "weth_", + "type": "address", + "internalType": "address" + }, + { + "name": "owner_", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "addPools", + "inputs": [ + { + "name": "pools", + "type": "tuple[]", + "internalType": "struct SwapQuoterV2.BridgePool[]", + "components": [ + { + "name": "bridgeToken", + "type": "address", + "internalType": "address" + }, + { + "name": "poolType", + "type": "uint8", + "internalType": "enum SwapQuoterV2.PoolType" + }, + { + "name": "pool", + "type": "address", + "internalType": "address" + } + ] + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "allPools", + "inputs": [], + "outputs": [ + { + "name": "pools", + "type": "tuple[]", + "internalType": "struct Pool[]", + "components": [ + { + "name": "pool", + "type": "address", + "internalType": "address" + }, + { + "name": "lpToken", + "type": "address", + "internalType": "address" + }, + { + "name": "tokens", + "type": "tuple[]", + "internalType": "struct PoolToken[]", + "components": [ + { + "name": "isWeth", + "type": "bool", + "internalType": "bool" + }, + { + "name": "token", + "type": "address", + "internalType": "address" + } + ] + } + ] + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "areConnectedTokens", + "inputs": [ + { + "name": "tokenIn", + "type": "tuple", + "internalType": "struct LimitedToken", + "components": [ + { + "name": "actionMask", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "token", + "type": "address", + "internalType": "address" + } + ] + }, + { + "name": "tokenOut", + "type": "address", + "internalType": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "bool", + "internalType": "bool" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "calculateAddLiquidity", + "inputs": [ + { + "name": "pool", + "type": "address", + "internalType": "address" + }, + { + "name": "amounts", + "type": "uint256[]", + "internalType": "uint256[]" + } + ], + "outputs": [ + { + "name": "amountOut", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "calculateRemoveLiquidity", + "inputs": [ + { + "name": "pool", + "type": "address", + "internalType": "address" + }, + { + "name": "amount", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "amountsOut", + "type": "uint256[]", + "internalType": "uint256[]" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "calculateSwap", + "inputs": [ + { + "name": "pool", + "type": "address", + "internalType": "address" + }, + { + "name": "tokenIndexFrom", + "type": "uint8", + "internalType": "uint8" + }, + { + "name": "tokenIndexTo", + "type": "uint8", + "internalType": "uint8" + }, + { + "name": "dx", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "amountOut", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "calculateWithdrawOneToken", + "inputs": [ + { + "name": "pool", + "type": "address", + "internalType": "address" + }, + { + "name": "tokenAmount", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "tokenIndex", + "type": "uint8", + "internalType": "uint8" + } + ], + "outputs": [ + { + "name": "amountOut", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "defaultPoolCalc", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "findConnectedTokens", + "inputs": [ + { + "name": "bridgeTokensIn", + "type": "tuple[]", + "internalType": "struct LimitedToken[]", + "components": [ + { + "name": "actionMask", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "token", + "type": "address", + "internalType": "address" + } + ] + }, + { + "name": "tokenOut", + "type": "address", + "internalType": "address" + } + ], + "outputs": [ + { + "name": "amountFound", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "isConnected", + "type": "bool[]", + "internalType": "bool[]" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "getAmountOut", + "inputs": [ + { + "name": "tokenIn", + "type": "tuple", + "internalType": "struct LimitedToken", + "components": [ + { + "name": "actionMask", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "token", + "type": "address", + "internalType": "address" + } + ] + }, + { + "name": "tokenOut", + "type": "address", + "internalType": "address" + }, + { + "name": "amountIn", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "query", + "type": "tuple", + "internalType": "struct SwapQuery", + "components": [ + { + "name": "routerAdapter", + "type": "address", + "internalType": "address" + }, + { + "name": "tokenOut", + "type": "address", + "internalType": "address" + }, + { + "name": "minAmountOut", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "deadline", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "rawParams", + "type": "bytes", + "internalType": "bytes" + } + ] + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "getBridgePools", + "inputs": [], + "outputs": [ + { + "name": "bridgePools", + "type": "tuple[]", + "internalType": "struct SwapQuoterV2.BridgePool[]", + "components": [ + { + "name": "bridgeToken", + "type": "address", + "internalType": "address" + }, + { + "name": "poolType", + "type": "uint8", + "internalType": "enum SwapQuoterV2.PoolType" + }, + { + "name": "pool", + "type": "address", + "internalType": "address" + } + ] + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "getOriginDefaultPools", + "inputs": [], + "outputs": [ + { + "name": "originDefaultPools", + "type": "address[]", + "internalType": "address[]" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "getOriginLinkedPools", + "inputs": [], + "outputs": [ + { + "name": "originLinkedPools", + "type": "address[]", + "internalType": "address[]" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "owner", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "poolInfo", + "inputs": [ + { + "name": "pool", + "type": "address", + "internalType": "address" + } + ], + "outputs": [ + { + "name": "numTokens", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "lpToken", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "poolTokens", + "inputs": [ + { + "name": "pool", + "type": "address", + "internalType": "address" + } + ], + "outputs": [ + { + "name": "tokens", + "type": "tuple[]", + "internalType": "struct PoolToken[]", + "components": [ + { + "name": "isWeth", + "type": "bool", + "internalType": "bool" + }, + { + "name": "token", + "type": "address", + "internalType": "address" + } + ] + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "poolsAmount", + "inputs": [], + "outputs": [ + { + "name": "amtPools", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "removePools", + "inputs": [ + { + "name": "pools", + "type": "tuple[]", + "internalType": "struct SwapQuoterV2.BridgePool[]", + "components": [ + { + "name": "bridgeToken", + "type": "address", + "internalType": "address" + }, + { + "name": "poolType", + "type": "uint8", + "internalType": "enum SwapQuoterV2.PoolType" + }, + { + "name": "pool", + "type": "address", + "internalType": "address" + } + ] + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "renounceOwnership", + "inputs": [], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "setSynapseRouter", + "inputs": [ + { + "name": "synapseRouter_", + "type": "address", + "internalType": "address" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "synapseRouter", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "transferOwnership", + "inputs": [ + { + "name": "newOwner", + "type": "address", + "internalType": "address" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "weth", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "view" + }, + { + "type": "event", + "name": "OwnershipTransferred", + "inputs": [ + { + "name": "previousOwner", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "newOwner", + "type": "address", + "indexed": true, + "internalType": "address" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "PoolAdded", + "inputs": [ + { + "name": "bridgeToken", + "type": "address", + "indexed": false, + "internalType": "address" + }, + { + "name": "poolType", + "type": "uint8", + "indexed": false, + "internalType": "enum SwapQuoterV2.PoolType" + }, + { + "name": "pool", + "type": "address", + "indexed": false, + "internalType": "address" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "PoolRemoved", + "inputs": [ + { + "name": "bridgeToken", + "type": "address", + "indexed": false, + "internalType": "address" + }, + { + "name": "poolType", + "type": "uint8", + "indexed": false, + "internalType": "enum SwapQuoterV2.PoolType" + }, + { + "name": "pool", + "type": "address", + "indexed": false, + "internalType": "address" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "SynapseRouterUpdated", + "inputs": [ + { + "name": "synapseRouter", + "type": "address", + "indexed": false, + "internalType": "address" + } + ], + "anonymous": false + }, + { + "type": "error", + "name": "SwapQuoterV2__DuplicatedPool", + "inputs": [ + { + "name": "pool", + "type": "address", + "internalType": "address" + } + ] + }, + { + "type": "error", + "name": "SwapQuoterV2__UnknownPool", + "inputs": [ + { + "name": "pool", + "type": "address", + "internalType": "address" + } + ] + } + ] +} \ No newline at end of file diff --git a/script/configs/bsc/SwapQuoterV2.dc.json b/script/configs/bsc/SwapQuoterV2.dc.json new file mode 100644 index 000000000..f358ed009 --- /dev/null +++ b/script/configs/bsc/SwapQuoterV2.dc.json @@ -0,0 +1,10 @@ +{ + "pools": { + "0": { + "description": "nUSD", + "isLinked": false, + "pool": "0x28ec0B36F0819ecB5005cAB836F4ED5a2eCa4D13", + "token": "0x23b891e5C62E0955ae2bD185990103928Ab817b3" + } + } +} \ No newline at end of file