Skip to content

Commit e367a5d

Browse files
authored
feat: router plus on mainnet eth (#663)
1 parent 68aef17 commit e367a5d

8 files changed

+201
-49
lines changed

script/deployments/v1_deployment/1/Ethereum-latest.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,6 @@
2929
"DeBridgeForwarderValidator": "0xDEa392D62cA1Edb74FB9210Aed714ad8F12b3E60",
3030
"DeBridgeValidator": "0x04A9e7318544DA4dd8c3d76E9c72d2087e285a8d",
3131
"AsyncStateRegistry": "0x0000000000000000000000000000000000000000",
32-
"ERC7540Form": "0x0000000000000000000000000000000000000000"
32+
"ERC7540Form": "0x0000000000000000000000000000000000000000",
33+
"SuperformRouterPlus": "0x4393C2a521ef115cd32C1d45897E7ce33aDa7aa9"
3334
}

script/forge-scripts/Abstract.Deploy.Single.s.sol

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ struct SetupVars {
110110
address payMaster;
111111
address emergencyQueue;
112112
address rewardsDistributor;
113+
address routerPlus;
113114
SuperRegistry superRegistryC;
114115
SuperRBAC superRBACC;
115116
LiFiValidator lv;
@@ -128,7 +129,7 @@ abstract contract AbstractDeploySingle is BatchScript {
128129
address public constant CANONICAL_PERMIT2 = 0x000000000022D473030F116dDEE9F6B43aC78BA3;
129130
mapping(uint64 chainId => mapping(bytes32 implementation => address at)) public contracts;
130131

131-
string[33] public contractNames = [
132+
string[34] public contractNames = [
132133
"CoreStateRegistry",
133134
"BroadcastRegistry",
134135
"LayerzeroImplementation",
@@ -161,7 +162,8 @@ abstract contract AbstractDeploySingle is BatchScript {
161162
"SuperformRouterPlus",
162163
"SuperformRouterPlusAsync",
163164
"AsyncStateRegistry",
164-
"ERC7540Form"
165+
"ERC7540Form",
166+
"SuperformRouterPlus"
165167
];
166168

167169
enum Chains {
@@ -361,7 +363,7 @@ abstract contract AbstractDeploySingle is BatchScript {
361363
uint64 public constant BLAST = 81_457;
362364
uint64 public constant BARTIO = 80_084;
363365

364-
uint256[] public manualNonces = [22, 22, 22, 22, 21, 21, 20, 9, 3, 2, 0];
366+
uint256[] public manualNonces = [23, 22, 22, 22, 21, 21, 20, 9, 3, 2, 0];
365367
uint64[] public chainIds = [1, 56, 43_114, 137, 42_161, 10, 8453, 250, 59_144, 81_457, 80_084];
366368
string[] public chainNames = [
367369
"Ethereum",
@@ -1095,6 +1097,10 @@ abstract contract AbstractDeploySingle is BatchScript {
10951097

10961098
vars.superRBACC.setRoleAdmin(rewardsAdminRole, vars.superRBACC.PROTOCOL_ADMIN_ROLE());
10971099
vars.superRBACC.grantRole(rewardsAdminRole, REWARDS_ADMIN);
1100+
/// @dev 21 deploy router plus: NOTE - router plus async not deployed yet, because probably it won't be used
1101+
vars.routerPlus = address(new SuperformRouterPlus{ salt: salt }(vars.superRegistry));
1102+
contracts[vars.chainId][bytes32(bytes("SuperformRouterPlus"))] = vars.routerPlus;
1103+
SuperRegistry(vars.superRegistry).setAddress(keccak256("SUPERFORM_ROUTER_PLUS"), vars.routerPlus, vars.chainId);
10981104

10991105
vm.stopBroadcast();
11001106

script/forge-scripts/misc/Abstract.Deploy.RouterPlus.s.sol

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,104 @@ abstract contract AbstractDeployRouterPlus is EnvironmentUtils {
6565
);
6666
}
6767
}
68+
69+
function _deployRouterPlus(
70+
uint256 env,
71+
uint256 i,
72+
uint256 trueIndex,
73+
Cycle cycle,
74+
uint64[] memory finalDeployedChains
75+
)
76+
internal
77+
setEnvDeploy(cycle)
78+
{
79+
assert(salt.length > 0);
80+
UpdateVars memory vars;
81+
82+
vars.chainId = finalDeployedChains[i];
83+
84+
cycle == Cycle.Dev ? vm.startBroadcast(deployerPrivateKey) : vm.startBroadcast();
85+
86+
address superRegistry = _readContractsV1(env, chainNames[trueIndex], vars.chainId, "SuperRegistry");
87+
address expectedSr;
88+
89+
if (env == 0) {
90+
expectedSr = vars.chainId == 250
91+
? 0x7feB31d18E43E2faeC718EEd2D7f34402c3e27b4
92+
: 0x17A332dC7B40aE701485023b219E9D6f493a2514;
93+
} else {
94+
expectedSr = vars.chainId == 250
95+
? 0x7B8d68f90dAaC67C577936d3Ce451801864EF189
96+
: 0xB2C097ac459aFAc892ae5b35f6bd6a9Dd3071F47;
97+
}
98+
99+
assert(superRegistry == expectedSr);
100+
101+
address superformRouterPlus = address(new SuperformRouterPlus{ salt: salt }(superRegistry));
102+
contracts[vars.chainId][bytes32(bytes("SuperformRouterPlus"))] = superformRouterPlus;
103+
104+
console.log("superformRouterPlus", superformRouterPlus);
105+
// address superformRouterPlusAsync = address(new SuperformRouterPlusAsync{ salt: salt }(superRegistry));
106+
// contracts[vars.chainId][bytes32(bytes("SuperformRouterPlusAsync"))] = superformRouterPlusAsync;
107+
108+
vm.stopBroadcast();
109+
110+
/// @dev we use normal export contract to not override v1 contracts
111+
for (uint256 j = 0; j < contractNames.length; j++) {
112+
_exportContract(
113+
chainNames[trueIndex], contractNames[j], getContract(vars.chainId, contractNames[j]), vars.chainId
114+
);
115+
}
116+
}
117+
118+
function _configureRouterPlusProd(
119+
uint256 env,
120+
uint256 i,
121+
uint256 trueIndex,
122+
Cycle cycle,
123+
uint64[] memory finalDeployedChains
124+
)
125+
internal
126+
setEnvDeploy(cycle)
127+
{
128+
assert(salt.length > 0);
129+
UpdateVars memory vars;
130+
131+
vars.chainId = finalDeployedChains[i];
132+
133+
address superRegistry = _readContractsV1(env, chainNames[trueIndex], vars.chainId, "SuperRegistry");
134+
address expectedSr;
135+
136+
if (env == 0) {
137+
expectedSr = vars.chainId == 250
138+
? 0x7feB31d18E43E2faeC718EEd2D7f34402c3e27b4
139+
: 0x17A332dC7B40aE701485023b219E9D6f493a2514;
140+
} else {
141+
expectedSr = vars.chainId == 250
142+
? 0x7B8d68f90dAaC67C577936d3Ce451801864EF189
143+
: 0xB2C097ac459aFAc892ae5b35f6bd6a9Dd3071F47;
144+
}
145+
146+
assert(superRegistry == expectedSr);
147+
148+
address superformRouterPlus = _readContractsV1(env, chainNames[trueIndex], vars.chainId, "SuperformRouterPlus");
149+
assert(superformRouterPlus != address(0));
150+
bytes memory txn = abi.encodeWithSelector(
151+
SuperRegistry.setAddress.selector, keccak256("SUPERFORM_ROUTER_PLUS"), superformRouterPlus, vars.chainId
152+
);
153+
addToBatch(superRegistry, 0, txn);
154+
155+
// address superformRouterPlusAsync =
156+
// _readContractsV1(env, chainNames[trueIndex], vars.chainId, "SuperformRouterPlusAsync");
157+
// assert(superformRouterPlusAsync != address(0));
158+
// txn = abi.encodeWithSelector(
159+
// SuperRegistry.setAddress.selector,
160+
// keccak256("SUPERFORM_ROUTER_PLUS_ASYNC"),
161+
// superformRouterPlusAsync,
162+
// vars.chainId
163+
// );
164+
// addToBatch(superRegistry, 0, txn);
165+
166+
executeBatch(vars.chainId, PROTOCOL_ADMINS[trueIndex], manualNonces[trueIndex], true);
167+
}
68168
}

script/forge-scripts/misc/Mainnet.Deploy.SuperformRouterPlus.s.sol

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ pragma solidity ^0.8.23;
44
import { AbstractDeployRouterPlus } from "./Abstract.Deploy.RouterPlus.s.sol";
55

66
contract MainnetDeployRouterPlus is AbstractDeployRouterPlus {
7-
function deployRouterPlus(uint256 env, uint256 selectedChainIndex, uint256 useNewSalt) external {
7+
function deployRouterPlusStaging(uint256 env, uint256 selectedChainIndex, uint256 useNewSalt) external {
88
_setEnvironment(env, useNewSalt == 1 ? true : false);
99
_preDeploymentSetup();
1010

@@ -19,4 +19,36 @@ contract MainnetDeployRouterPlus is AbstractDeployRouterPlus {
1919
_deployRouterPlusStaging(env, selectedChainIndex, trueIndex, Cycle.Prod, TARGET_CHAINS);
2020
}
2121
}
22+
23+
function deployRouterPlusProd(uint256 env, uint256 selectedChainIndex, uint256 useNewSalt) external {
24+
_setEnvironment(env, useNewSalt == 1 ? true : false);
25+
_preDeploymentSetup();
26+
27+
uint256 trueIndex;
28+
for (uint256 i = 0; i < chainIds.length; i++) {
29+
if (TARGET_CHAINS[selectedChainIndex] == chainIds[i]) {
30+
trueIndex = i;
31+
break;
32+
}
33+
}
34+
if (env == 0) {
35+
_deployRouterPlus(env, selectedChainIndex, trueIndex, Cycle.Prod, TARGET_CHAINS);
36+
}
37+
}
38+
39+
function configureRouterPlusProd(uint256 env, uint256 selectedChainIndex, uint256 useNewSalt) external {
40+
_setEnvironment(env, useNewSalt == 1 ? true : false);
41+
_preDeploymentSetup();
42+
43+
uint256 trueIndex;
44+
for (uint256 i = 0; i < chainIds.length; i++) {
45+
if (TARGET_CHAINS[selectedChainIndex] == chainIds[i]) {
46+
trueIndex = i;
47+
break;
48+
}
49+
}
50+
if (env == 0) {
51+
_configureRouterPlusProd(env, selectedChainIndex, trueIndex, Cycle.Prod, TARGET_CHAINS);
52+
}
53+
}
2254
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/usr/bin/env bash
2+
# Note: How to set default - https://www.youtube.com/watch?v=VQe7cIpaE54
3+
4+
export ETHEREUM_RPC_URL=$(op read op://5ylebqljbh3x6zomdxi3qd7tsa/ETHEREUM_RPC_URL/credential)
5+
export BSC_RPC_URL=$(op read op://5ylebqljbh3x6zomdxi3qd7tsa/BSC_RPC_URL/credential)
6+
export AVALANCHE_RPC_URL=$(op read op://5ylebqljbh3x6zomdxi3qd7tsa/AVALANCHE_RPC_URL/credential)
7+
export POLYGON_RPC_URL=$(op read op://5ylebqljbh3x6zomdxi3qd7tsa/POLYGON_RPC_URL/credential)
8+
export ARBITRUM_RPC_URL=$(op read op://5ylebqljbh3x6zomdxi3qd7tsa/ARBITRUM_RPC_URL/credential)
9+
export OPTIMISM_RPC_URL=$(op read op://5ylebqljbh3x6zomdxi3qd7tsa/OPTIMISM_RPC_URL/credential)
10+
export BASE_RPC_URL=$(op read op://5ylebqljbh3x6zomdxi3qd7tsa/BASE_RPC_URL/credential)
11+
export FANTOM_RPC_URL=$(op read op://5ylebqljbh3x6zomdxi3qd7tsa/FANTOM_RPC_URL/credential)
12+
export LINEA_RPC_URL=$(op read op://5ylebqljbh3x6zomdxi3qd7tsa/LINEA_RPC_URL/credential)
13+
export BLAST_RPC_URL=$(op read op://5ylebqljbh3x6zomdxi3qd7tsa/BLAST_RPC_URL/credential)
14+
15+
# Run the script
16+
echo Deploying Router Plus on prod: ...
17+
18+
# FOUNDRY_PROFILE=production forge script script/forge-scripts/misc/Mainnet.Deploy.SuperformRouterPlus.s.sol:MainnetDeployRouterPlus --sig "deployRouterPlusProd(uint256,uint256,uint256)" 0 0 0 --rpc-url $ETHEREUM_RPC_URL --slow --account default --broadcast --sender 0x48aB8AdF869Ba9902Ad483FB1Ca2eFDAb6eabe92 --legacy
19+
# wait
20+
21+
FOUNDRY_PROFILE=production forge script script/forge-scripts/misc/Mainnet.Deploy.SuperformRouterPlus.s.sol:MainnetDeployRouterPlus --sig "configureRouterPlusProd(uint256,uint256,uint256)" 0 0 0 --rpc-url $ETHEREUM_RPC_URL --slow --sender 0x1985df46791BEBb1e3ed9Ec60417F38CECc1D349
22+
wait
23+
24+
# echo Deploying Router Plus and Router Plus Async on staging: ...
25+
26+
# FOUNDRY_PROFILE=production forge script script/forge-scripts/misc/Mainnet.Deploy.SuperformRouterPlus.s.sol:MainnetDeployRouterPlus --sig "deployRouterPlus(uint256,uint256,uint256)" 1 0 0 --rpc-url $BSC_RPC_URL --slow --broadcast --account default --sender 0x48aB8AdF869Ba9902Ad483FB1Ca2eFDAb6eabe92 --legacy
27+
# wait
28+
29+
# FOUNDRY_PROFILE=production forge script script/forge-scripts/misc/Mainnet.Deploy.SuperformRouterPlus.s.sol:MainnetDeployRouterPlus --sig "deployRouterPlus(uint256,uint256,uint256)" 1 1 0 --rpc-url $ARBITRUM_RPC_URL --slow --broadcast --account default --sender 0x48aB8AdF869Ba9902Ad483FB1Ca2eFDAb6eabe92
30+
# wait
31+
32+
# FOUNDRY_PROFILE=production forge script script/forge-scripts/misc/Mainnet.Deploy.SuperformRouterPlus.s.sol:MainnetDeployRouterPlus --sig "deployRouterPlus(uint256,uint256,uint256)" 1 2 0 --rpc-url $OPTIMISM_RPC_URL --slow --broadcast --account default --sender 0x48aB8AdF869Ba9902Ad483FB1Ca2eFDAb6eabe92 --legacy
33+
# wait
34+
35+
# FOUNDRY_PROFILE=production forge script script/forge-scripts/misc/Mainnet.Deploy.SuperformRouterPlus.s.sol:MainnetDeployRouterPlus --sig "deployRouterPlus(uint256,uint256,uint256)" 1 3 0 --rpc-url $BASE_RPC_URL --slow --broadcast --account default --sender 0x48aB8AdF869Ba9902Ad483FB1Ca2eFDAb6eabe92 --legacy
36+
# wait
37+
38+
# FOUNDRY_PROFILE=production forge script script/forge-scripts/misc/Mainnet.Deploy.SuperformRouterPlus.s.sol:MainnetDeployRouterPlus --sig "deployRouterPlus(uint256,uint256,uint256)" 1 4 0 --rpc-url $FANTOM_RPC_URL --slow --broadcast --account default --sender 0x48aB8AdF869Ba9902Ad483FB1Ca2eFDAb6eabe92 --legacy
39+
# wait
40+
41+
# FOUNDRY_PROFILE=production forge script script/forge-scripts/misc/Mainnet.Deploy.SuperformRouterPlus.s.sol:MainnetDeployRouterPlus --sig "deployRouterPlus(uint256,uint256,uint256)" 1 5 0 --rpc-url $LINEA_RPC_URL --slow --broadcast --account default --sender 0x48aB8AdF869Ba9902Ad483FB1Ca2eFDAb6eabe92 --legacy --with-gas-price 600000000
42+
# wait
43+
44+
# FOUNDRY_PROFILE=production forge script script/forge-scripts/misc/Mainnet.Deploy.SuperformRouterPlus.s.sol:MainnetDeployRouterPlus --sig "deployRouterPlus(uint256,uint256,uint256)" 1 6 0 --rpc-url $BLAST_RPC_URL --slow --broadcast --account default --sender 0x48aB8AdF869Ba9902Ad483FB1Ca2eFDAb6eabe92 --legacy
45+
# wait

script/utils/misc/run_script_mainnet_staging_routerplus.sh

Lines changed: 0 additions & 37 deletions
This file was deleted.

script/utils/verify_contracts.sh

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ file_names=(
8383
"src/forms/ERC5115Form.sol"
8484
"src/forms/wrappers/ERC5115To4626WrapperFactory.sol"
8585
"src/crosschain-data/adapters/layerzero/LayerzeroImplementation.sol"
86+
"src/router-plus/SuperformRouterPlus.sol"
8687
# Add more file names here if needed
8788
)
8889

@@ -149,6 +150,7 @@ contract_names=(
149150
"ERC5115Form"
150151
"ERC5115To4626WrapperFactory"
151152
"LayerzeroImplementation"
153+
"SuperformRouterPlus"
152154
# Add more contract names here if needed
153155
)
154156

@@ -182,6 +184,7 @@ contract_addresses=(
182184
0x35E3057FF29ebC5b8dEF18EC66FEde16f1B237F5
183185
0x664E1e7b8393DF4aC4EFAbEf9d56B2100098FCE2
184186
0xc100592b40eeb4CBC7524092A00400917421ab64
187+
0x4393C2a521ef115cd32C1d45897E7ce33aDa7aa9
185188
# Add more addresses here if needed
186189
)
187190

@@ -313,6 +316,7 @@ constructor_args=(
313316
$super_constructor_arg
314317
$super_constructor_arg
315318
$super_constructor_arg
319+
$super_constructor_arg
316320
)
317321

318322
constructor_args_ftm=(
@@ -367,7 +371,7 @@ for i in "${!networks[@]}"; do
367371
forge verify-contract $contract_address \
368372
--chain-id $network \
369373
--num-of-optimizations 200 \
370-
--watch --compiler-version v0.8.23+commit.f704f362 \
374+
--watch --compiler-version v0.8.23 \
371375
--constructor-args "$constructor_arg" \
372376
"$file_name:$contract_name" \
373377
--etherscan-api-key "$api_key" \
@@ -376,31 +380,31 @@ for i in "${!networks[@]}"; do
376380
forge verify-contract $contract_address_fantom \
377381
--chain-id $network \
378382
--num-of-optimizations 200 \
379-
--watch --compiler-version v0.8.23+commit.f704f362 \
383+
--watch --compiler-version v0.8.23 \
380384
--constructor-args "$constructor_arg_ftm" \
381385
"$file_name:$contract_name" \
382386
--etherscan-api-key "$api_key"
383387
elif [[ $network == 59144 ]]; then
384388
forge verify-contract $contract_address_linea \
385389
--chain-id $network \
386390
--num-of-optimizations 200 \
387-
--watch --compiler-version v0.8.23+commit.f704f362 \
391+
--watch --compiler-version v0.8.23 \
388392
--constructor-args "$constructor_arg" \
389393
"$file_name:$contract_name" \
390394
--etherscan-api-key "$api_key"
391395
elif [[ $network == 81457 ]]; then
392396
forge verify-contract $contract_address_blast \
393397
--chain-id $network \
394398
--num-of-optimizations 200 \
395-
--watch --compiler-version v0.8.23+commit.f704f362 \
399+
--watch --compiler-version v0.8.23 \
396400
--constructor-args "$constructor_arg" \
397401
"$file_name_blast:$contract_name" \
398402
--etherscan-api-key "$api_key"
399403
else
400404
forge verify-contract $contract_address \
401405
--chain-id $network \
402406
--num-of-optimizations 200 \
403-
--watch --compiler-version v0.8.23+commit.f704f362 \
407+
--watch --compiler-version v0.8.23 \
404408
--constructor-args "$constructor_arg" \
405409
"$file_name:$contract_name" \
406410
--etherscan-api-key "$api_key"

test/mainnet/SmokeTest.t.sol

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ contract SmokeTest is MainnetBaseSetup {
7474
function test_superRegistryAddresses() public {
7575
SuperRegistry sr;
7676

77-
uint256 len = 10;
77+
uint256 len = 11;
7878
bytes32[] memory ids = new bytes32[](len);
7979
ids[0] = keccak256("PAYMENT_ADMIN");
8080
ids[1] = keccak256("CORE_REGISTRY_PROCESSOR");
@@ -86,6 +86,7 @@ contract SmokeTest is MainnetBaseSetup {
8686
ids[7] = keccak256("DST_SWAPPER_PROCESSOR");
8787
ids[8] = keccak256("SUPERFORM_RECEIVER");
8888
ids[9] = keccak256("REWARDS_DISTRIBUTOR");
89+
ids[10] = keccak256("SUPERFORM_ROUTER_PLUS");
8990

9091
address[] memory newAddresses = new address[](len);
9192
newAddresses[0] = 0xD911673eAF0D3e15fe662D58De15511c5509bAbB;
@@ -97,7 +98,7 @@ contract SmokeTest is MainnetBaseSetup {
9798
newAddresses[6] = 0x7c9c8C0A9aA5D8a2c2e6C746641117Cc9591296a;
9899
newAddresses[7] = 0x1666660D2F506e754CB5c8E21BDedC7DdEc6Be1C;
99100
newAddresses[8] = 0x1a6805487322565202848f239C1B5bC32303C2FE;
100-
101+
newAddresses[9] = 0x4393C2a521ef115cd32C1d45897E7ce33aDa7aa9;
101102
for (uint256 i = 0; i < TARGET_DEPLOYMENT_CHAINS.length; ++i) {
102103
vm.selectFork(FORKS[TARGET_DEPLOYMENT_CHAINS[i]]);
103104

0 commit comments

Comments
 (0)