From 19b055fcf832556b7d1f937a0d91336a1ac7a09c Mon Sep 17 00:00:00 2001 From: ChiTimesChi <88190723+ChiTimesChi@users.noreply.github.com> Date: Thu, 14 Mar 2024 18:04:15 +0000 Subject: [PATCH 1/4] Update QuoterV2 config auto saving script --- script/router/quoter/SaveConfigQuoterV2.s.sol | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/script/router/quoter/SaveConfigQuoterV2.s.sol b/script/router/quoter/SaveConfigQuoterV2.s.sol index 7f9dbce70..556d168f4 100644 --- a/script/router/quoter/SaveConfigQuoterV2.s.sol +++ b/script/router/quoter/SaveConfigQuoterV2.s.sol @@ -46,18 +46,28 @@ contract SaveConfigQuoterV2 is BasicSynapseScript, BridgeConfigLens { /// @notice Loads the list of pools that should be ignored by the Quoter function loadIgnoredPools() internal { string memory ignoredJson = getGlobalConfig(QUOTER_V2, "ignored"); - string[] memory ignoredContractNames = ignoredJson.readStringArray(".contractNames"); - // Add existing deployments to the ignored list - for (uint256 i = 0; i < ignoredContractNames.length; ++i) { - address ignoredPool = tryGetDeploymentAddress(ignoredContractNames[i]); - if (ignoredPool != address(0)) { - isIgnoredPool[ignoredPool] = true; - } + string[] memory globallyIgnoredNames = ignoredJson.readStringArray(".global"); + markIgnoredPools(globallyIgnoredNames); + string memory chainIgnoredKey = string.concat(".chain.", activeChain); + if (vm.keyExists(ignoredJson, chainIgnoredKey)) { + string[] memory chainIgnoredNames = ignoredJson.readStringArray(chainIgnoredKey); + markIgnoredPools(chainIgnoredNames); } // Add the zero address to the ignored list to simplify the logic isIgnoredPool[address(0)] = true; } + /// @notice Marks the pools as ignored + function markIgnoredPools(string[] memory contractNames) internal { + for (uint256 i = 0; i < contractNames.length; ++i) { + address pool = tryGetDeploymentAddress(contractNames[i]); + if (pool != address(0)) { + console2.log(" Ignoring pool: %s at %s", contractNames[i], pool); + isIgnoredPool[pool] = true; + } + } + } + /// @notice Saves pool to be later added to SwapQuoterV2 config function savePoolIfNotIgnored( address bridgeToken, From 60a6311c516ffbe3e04ee754dcfd4cd5275b9ffa Mon Sep 17 00:00:00 2001 From: ChiTimesChi <88190723+ChiTimesChi@users.noreply.github.com> Date: Tue, 13 Feb 2024 20:20:09 +0000 Subject: [PATCH 2/4] Deploy SwapQuoterV2 on Canto --- deployments/canto/DefaultPoolCalc.json | 30 ++ deployments/canto/SwapQuoterV2.json | 703 +++++++++++++++++++++++++ 2 files changed, 733 insertions(+) create mode 100644 deployments/canto/DefaultPoolCalc.json create mode 100644 deployments/canto/SwapQuoterV2.json diff --git a/deployments/canto/DefaultPoolCalc.json b/deployments/canto/DefaultPoolCalc.json new file mode 100644 index 000000000..c8d3c5586 --- /dev/null +++ b/deployments/canto/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/canto/SwapQuoterV2.json b/deployments/canto/SwapQuoterV2.json new file mode 100644 index 000000000..78ff1a711 --- /dev/null +++ b/deployments/canto/SwapQuoterV2.json @@ -0,0 +1,703 @@ +{ + "address": "0x55DEc55aDbd9a2102438339A294CB921A5248285", + "constructorArgs": "0x0000000000000000000000007e7a0e201fd38d3adaa9523da6c109a07118c96a0000000000000000000000000000000000cc5af216a3e1614091a20e11bbfd32000000000000000000000000826551890dc65655a0aceca109ab11abdbd7a07b0000000000000000000000000fea3e5840334fc758a3decf14546bfdfbef5cd3", + "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 From a51dd1c245f208d45110c13f37563cff2cfab105 Mon Sep 17 00:00:00 2001 From: ChiTimesChi <88190723+ChiTimesChi@users.noreply.github.com> Date: Tue, 13 Feb 2024 20:23:55 +0000 Subject: [PATCH 3/4] Chore: update Avax QuoterV2 config --- script/configs/avalanche/SwapQuoterV2.dc.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/configs/avalanche/SwapQuoterV2.dc.json b/script/configs/avalanche/SwapQuoterV2.dc.json index 6dbe113f6..4e0b82acd 100644 --- a/script/configs/avalanche/SwapQuoterV2.dc.json +++ b/script/configs/avalanche/SwapQuoterV2.dc.json @@ -9,7 +9,7 @@ "1": { "description": "nUSD", "isLinked": false, - "pool": "0xED2a7edd7413021d440b09D654f3b87712abAB66", + "pool": "0xA196a03653f6cc5cA0282A8BD7Ec60e93f620afc", "token": "0xCFc37A6AB183dd4aED08C204D1c2773c0b1BDf46" }, "2": { From 5f35fa2b5f8d8c704bad5db17c65d0b3595d0b45 Mon Sep 17 00:00:00 2001 From: ChiTimesChi <88190723+ChiTimesChi@users.noreply.github.com> Date: Thu, 14 Mar 2024 18:09:40 +0000 Subject: [PATCH 4/4] Save QuoterV2 config for Canto --- script/configs/SwapQuoterV2.ignored.json | 5 ++++- script/configs/canto/SwapQuoterV2.dc.json | 10 ++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 script/configs/canto/SwapQuoterV2.dc.json diff --git a/script/configs/SwapQuoterV2.ignored.json b/script/configs/SwapQuoterV2.ignored.json index 110759645..a7f0c2f90 100644 --- a/script/configs/SwapQuoterV2.ignored.json +++ b/script/configs/SwapQuoterV2.ignored.json @@ -1,3 +1,6 @@ { - "contractNames": ["AvaxJewelSwap", "MockSwap"] + "global": ["AvaxJewelSwap", "MockSwap"], + "chain": { + "canto": ["ETHPool"] + } } diff --git a/script/configs/canto/SwapQuoterV2.dc.json b/script/configs/canto/SwapQuoterV2.dc.json new file mode 100644 index 000000000..d6d42a157 --- /dev/null +++ b/script/configs/canto/SwapQuoterV2.dc.json @@ -0,0 +1,10 @@ +{ + "pools": { + "0": { + "description": "nUSD", + "isLinked": false, + "pool": "0x0271984e4cfA2A0f02664baACD551CcFCC9920E8", + "token": "0xD8836aF2e565D3Befce7D906Af63ee45a57E8f80" + } + } +} \ No newline at end of file