Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: sync router configs #313

Merged
merged 5 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions script/configs/arbitrum/SynapseRouter.dc.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@
"UNIDX",
"PEPE"
],
"pools": [
"0x9Dd329F5411466d9e0C488fF72519CA9fEf0cb40",
"0xa067668661C84476aFcDc6fA5D758C4c01C34352"
],
"tokens": {
"GMX": {
"bridgeFee": 5000000,
Expand Down Expand Up @@ -145,7 +141,7 @@
"bridgeToken": "0x3ea9B0ab55F34Fb188824Ee288CeaEfC63cf908e",
"decimals": 18,
"maxFee": "0x000000000000000000000000000000000000000000032dcba101cb7220c6938c",
"minFee": "0x00000000000000000000000000000000000000000000000000038d7ea4c68000",
"minFee": "0x0000000000000000000000000000000000000000000000000001c6bf52634000",
"token": "0x3ea9B0ab55F34Fb188824Ee288CeaEfC63cf908e",
"tokenType": 0
},
Expand Down
3 changes: 0 additions & 3 deletions script/configs/aurora/SynapseRouter.dc.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
"SYN",
"UST"
],
"pools": [
"0xCCd87854f58773fe75CdDa542457aC48E46c2D65"
],
"tokens": {
"SYN": {
"bridgeFee": 5000000,
Expand Down
9 changes: 2 additions & 7 deletions script/configs/avalanche/SynapseRouter.dc.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@
"H2O",
"BTCB"
],
"pools": [
"0xED2a7edd7413021d440b09D654f3b87712abAB66",
"0xdd60483Ace9B215a7c019A44Be2F22Aa9982652E",
"0xa6Fa14A446B1b86619De3c27D10eeaAd84a0FcCd"
],
"tokens": {
"AVAX": {
"bridgeFee": 4000000,
Expand Down Expand Up @@ -136,7 +131,7 @@
"bridgeToken": "0x19E1ae0eE35c0404f835521146206595d37981ae",
"decimals": 18,
"maxFee": "0x000000000000000000000000000000000000000000032dcba101cb7220c6938c",
"minFee": "0x0000000000000000000000000000000000000000000000000001c6bf52634000",
"minFee": "0x00000000000000000000000000000000000000000000000000071afd498d0000",
"token": "0x19E1ae0eE35c0404f835521146206595d37981ae",
"tokenType": 0
},
Expand All @@ -145,7 +140,7 @@
"bridgeToken": "0xCFc37A6AB183dd4aED08C204D1c2773c0b1BDf46",
"decimals": 18,
"maxFee": "0x000000000000000000000000000000000000000000032dcba101cb7220c6938c",
"minFee": "0x0000000000000000000000000000000000000000000000000de0b6b3a7640000",
"minFee": "0x00000000000000000000000000000000000000000000000022b1c8c1227a0000",
"token": "0xCFc37A6AB183dd4aED08C204D1c2773c0b1BDf46",
"tokenType": 0
},
Expand Down
3 changes: 0 additions & 3 deletions script/configs/base/SynapseRouter.dc.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
"nETH",
"UNIDX"
],
"pools": [
"0x6223bD82010E2fB69F329933De20897e7a4C225f"
],
"tokens": {
"SYN": {
"bridgeFee": 5000000,
Expand Down
4 changes: 0 additions & 4 deletions script/configs/boba/SynapseRouter.dc.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
"gOHM",
"UST"
],
"pools": [
"0x75FF037256b36F15919369AC58695550bE72fead",
"0x753bb855c8fe814233d26Bb23aF61cb3d2022bE5"
],
"tokens": {
"SYN": {
"bridgeFee": 5000000,
Expand Down
3 changes: 0 additions & 3 deletions script/configs/bsc/SynapseRouter.dc.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
"H2O",
"BUSD"
],
"pools": [
"0x28ec0B36F0819ecB5005cAB836F4ED5a2eCa4D13"
],
"tokens": {
"BUSD": {
"bridgeFee": 10000000,
Expand Down
4 changes: 0 additions & 4 deletions script/configs/canto/SynapseRouter.dc.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
"SYN",
"nETH"
],
"pools": [
"0x0271984e4cfA2A0f02664baACD551CcFCC9920E8",
"0xF60F88bA0CB381b8D8A662744fF93486273c22F9"
],
"tokens": {
"SYN": {
"bridgeFee": 5000000,
Expand Down
3 changes: 0 additions & 3 deletions script/configs/cronos/SynapseRouter.dc.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
"SYN",
"gOHM"
],
"pools": [
"0xCb6674548586F20ca39C97A52A0ded86f48814De"
],
"tokens": {
"SYN": {
"bridgeFee": 5000000,
Expand Down
3 changes: 0 additions & 3 deletions script/configs/dfk/SynapseRouter.dc.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
"FTM",
"BTCB"
],
"pools": [
"0x0000000000000000000000000000000000000000"
],
"tokens": {
"AVAX": {
"bridgeFee": 4000000,
Expand Down
3 changes: 0 additions & 3 deletions script/configs/dogechain/SynapseRouter.dc.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
"DAI",
"BUSD"
],
"pools": [
"0x0000000000000000000000000000000000000000"
],
"tokens": {
"BUSD": {
"bridgeFee": 10000000,
Expand Down
1 change: 0 additions & 1 deletion script/configs/fantom/SynapseRouter.dc.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
"FTM",
"UNIDX"
],
"pools": [],
"tokens": {
"FTM": {
"bridgeFee": 10000000,
Expand Down
4 changes: 0 additions & 4 deletions script/configs/harmony/SynapseRouter.dc.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@
"xJEWEL",
"JEWEL"
],
"pools": [
"0x00A4F57D926781f62D09bb05ec76e6D8aE4268da",
"0x7bE461cce1501f07969BCE24Ccb2140fCA0a35b3"
],
"tokens": {
"AVAX": {
"bridgeFee": 4000000,
Expand Down
4 changes: 0 additions & 4 deletions script/configs/klatyn/SynapseRouter.dc.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@
"BTCB",
"LINK"
],
"pools": [
"0x0150E4bb98422f3b38aE8524E0cE0B7E734923eB",
"0x0150E4bb98422f3b38aE8524E0cE0B7E734923eB"
],
"tokens": {
"AVAX": {
"bridgeFee": 4000000,
Expand Down
5 changes: 1 addition & 4 deletions script/configs/mainnet/SynapseRouter.dc.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@
"UNIDX",
"PEPE"
],
"pools": [
"0x1116898DdA4015eD8dDefb84b6e8Bc24528Af2d8"
],
"tokens": {
"DAI": {
"bridgeFee": 10000000,
Expand Down Expand Up @@ -204,7 +201,7 @@
"bridgeToken": "0x1B84765dE8B7566e4cEAF4D0fD3c5aF52D3DdE4F",
"decimals": 18,
"maxFee": "0x000000000000000000000000000000000000000000032dcba101cb7220c6938c",
"minFee": "0x000000000000000000000000000000000000000000000001a055690d9db80000",
"minFee": "0x0000000000000000000000000000000000000000000000022b1c8c1227a00000",
"token": "0x1B84765dE8B7566e4cEAF4D0fD3c5aF52D3DdE4F",
"tokenType": 1
},
Expand Down
4 changes: 0 additions & 4 deletions script/configs/metis/SynapseRouter.dc.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@
"gOHM",
"UST"
],
"pools": [
"0x555982d2E211745b96736665e19D9308B615F78e",
"0x09fEC30669d63A13c666d2129230dD5588E2e240"
],
"tokens": {
"JUMP": {
"bridgeFee": 10000000,
Expand Down
3 changes: 0 additions & 3 deletions script/configs/moonbeam/SynapseRouter.dc.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
"UST",
"H2O"
],
"pools": [
"0x0000000000000000000000000000000000000000"
],
"tokens": {
"AVAX": {
"bridgeFee": 5000000,
Expand Down
1 change: 0 additions & 1 deletion script/configs/moonriver/SynapseRouter.dc.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"UST",
"H2O"
],
"pools": [],
"tokens": {
"H2O": {
"bridgeFee": 10000000,
Expand Down
8 changes: 2 additions & 6 deletions script/configs/optimism/SynapseRouter.dc.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@
"PLS",
"UNIDX"
],
"pools": [
"0xF44938b0125A6662f9536281aD2CD6c499F22004",
"0xE27BFf97CE92C3e1Ff7AA9f86781FDd6D48F5eE9"
],
"tokens": {
"H2O": {
"bridgeFee": 10000000,
Expand Down Expand Up @@ -94,7 +90,7 @@
"bridgeToken": "0x809DC529f07651bD43A172e8dB6f4a7a0d771036",
"decimals": 18,
"maxFee": "0x000000000000000000000000000000000000000000032dcba101cb7220c6938c",
"minFee": "0x0000000000000000000000000000000000000000000000000005543df729c000",
"minFee": "0x0000000000000000000000000000000000000000000000000001c6bf52634000",
"token": "0x809DC529f07651bD43A172e8dB6f4a7a0d771036",
"tokenType": 0
},
Expand All @@ -103,7 +99,7 @@
"bridgeToken": "0x67C10C397dD0Ba417329543c1a40eb48AAa7cd00",
"decimals": 18,
"maxFee": "0x000000000000000000000000000000000000000000032dcba101cb7220c6938c",
"minFee": "0x00000000000000000000000000000000000000000000000029a2241af62c0000",
"minFee": "0x0000000000000000000000000000000000000000000000000de0b6b3a7640000",
"token": "0x67C10C397dD0Ba417329543c1a40eb48AAa7cd00",
"tokenType": 0
}
Expand Down
3 changes: 0 additions & 3 deletions script/configs/polygon/SynapseRouter.dc.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
"H2O",
"MATIC"
],
"pools": [
"0x85fCD7Dd0a1e1A9FCD5FD886ED522dE8221C3EE5"
],
"tokens": {
"DOG": {
"bridgeFee": 10000000,
Expand Down
1 change: 0 additions & 1 deletion script/configs/zkevm/SynapseRouter.dc.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"bridge": "0x432036208d2717394d2614d6697c46DF3Ed69540",
"ids": [],
"pools": [],
"tokens": "",
"wgas": "0x4F9A0e7FD2Bf6067db6994CF12E4495Df938E6e9"
}
2 changes: 1 addition & 1 deletion script/networks.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"metis": "--legacy",
"moonbeam": "--skip-simulation --slow",
"moonriver": "--skip-simulation --slow",
"optimism": "--with-gas-price 1337",
"optimism": "--with-gas-price 100000000",
"polygon": "--slow"
}
}
34 changes: 2 additions & 32 deletions script/router/SaveRouterConfig.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,7 @@ contract SaveRouterConfigScript is BridgeConfigV3Lens, SynapseScript {
uint256 chainId = _chainId();
string memory ethRPC = vm.envString("MAINNET_API");
vm.createSelectFork(ethRPC);
(LocalBridgeConfig.BridgeTokenConfig[] memory tokens, address[] memory pools) = getChainConfig(chainId);
// Filter out MockSwap and duplicated pools
pools = _filterPools(pools);

(LocalBridgeConfig.BridgeTokenConfig[] memory tokens, ) = getChainConfig(chainId);
_loadIgnoredIds();

for (uint256 i = 0; i < tokens.length; ++i) {
Expand All @@ -69,38 +66,11 @@ contract SaveRouterConfigScript is BridgeConfigV3Lens, SynapseScript {
tokensConfig = string("tokens").serialize(tokens[i].id, token);
}
fullConfig.serialize("ids", ids);
fullConfig.serialize("tokens", tokensConfig);
fullConfig = fullConfig.serialize("pools", pools);
fullConfig = fullConfig.serialize("tokens", tokensConfig);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The serialization of tokens directly assigns tokensConfig without apparent aggregation or concatenation logic for multiple tokens. This could lead to only the last token's configuration being saved if multiple tokens exist. Verify the serialization logic to ensure it correctly handles multiple tokens.

- tokensConfig = string("tokens").serialize(tokens[i].id, token);
+ tokensConfig = tokensConfig.serialize(tokens[i].id, token);

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
fullConfig = fullConfig.serialize("tokens", tokensConfig);
fullConfig = tokensConfig.serialize(tokens[i].id, token);


saveDeployConfig(ROUTER, fullConfig);
}

function _filterPools(address[] memory pools) internal returns (address[] memory filteredPools) {
address mockSwap = tryLoadDeployment("MockSwap");
bool[] memory isRealAndUnique = new bool[](pools.length);
uint256 count = 0;
for (uint256 i = 0; i < pools.length; ++i) {
// Skip MockSwap
if (pools[i] == mockSwap) continue;
// Skip pools that are already in the list
bool isUnique = true;
for (uint256 j = 0; j < i; ++j) {
if (pools[i] == pools[j]) {
isUnique = false;
break;
}
}
if (!isUnique) continue;
isRealAndUnique[i] = true;
++count;
}
filteredPools = new address[](count);
count = 0;
for (uint256 i = 0; i < pools.length; ++i) {
if (isRealAndUnique[i]) filteredPools[count++] = pools[i];
}
}

function _loadIgnoredIds() internal {
string memory ignored = loadGlobalConfig("SynapseRouter.ignored");
string[] memory _ids = ignored.readStringArray(".ids");
Expand Down
Loading
Loading