@@ -4,7 +4,8 @@ pragma solidity ^0.8.17;
44import "forge-std/Script.sol " ;
55import "stringutils/strings.sol " ;
66
7- import {IntentGatewayV2, Params, Deployment} from "../src/apps/IntentGatewayV2.sol " ;
7+ import {IntentGatewayV2, Params} from "../src/apps/IntentGatewayV2.sol " ;
8+ import {ERC1967Proxy } from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol " ;
89import {BaseScript} from "./BaseScript.sol " ;
910import {CallDispatcher} from "../src/utils/CallDispatcher.sol " ;
1011import {SolverAccount} from "../src/apps/intentsv2/SolverAccount.sol " ;
@@ -17,200 +18,57 @@ contract DeployScript is BaseScript {
1718 /// @notice Main deployment logic - called by BaseScript's run() functions
1819 /// @dev This function is called within a broadcast context
1920 function deploy () internal override {
20- IntentGatewayV2 intentGateway = new IntentGatewayV2 {salt: salt}(admin);
21- console.log ("IntentGateway deployed at: " , address (intentGateway));
22-
23- SolverAccount solverAccount = new SolverAccount {salt: salt}(address (intentGateway));
24- console.log ("SolverAccount deployed at: " , address (solverAccount));
25-
21+ // Deploy implementation and proxy via CREATE2 with the same salt. The proxy is initialized
22+ // atomically through its init data. The cross-chain peer registry is passed in by chain id
23+ // only — `initialize` binds each to `address(this)` — so no peer address is embedded in the
24+ // init data. The address depends on (impl address, salt, params, peer chain ids), all of
25+ // which are identical across chains, keeping the proxy address identical everywhere.
2626 address priceOracle = address (0 );
27- // address priceOracle = deployPriceOracle(address(intentGateway));
28-
29- Deployment[] memory deployments;
27+ IntentGatewayV2 implementation = new IntentGatewayV2 {salt: salt}(admin);
28+ bytes [] memory peerChains;
3029 if (config.get ("is_mainnet " ).toBool ()) {
31- deployments = new Deployment [](9 );
32- deployments[0 ] = Deployment ({
33- chain: StateMachine.evm (1 ), // ethereum
34- gateway: address (intentGateway)
35- });
36- deployments[1 ] = Deployment ({
37- chain: StateMachine.evm (10 ), // optimism
38- gateway: address (intentGateway)
39- });
40- deployments[2 ] = Deployment ({
41- chain: StateMachine.evm (42161 ), // arbitrum
42- gateway: address (intentGateway)
43- });
44- deployments[3 ] = Deployment ({
45- chain: StateMachine.evm (8453 ), // base
46- gateway: address (intentGateway)
47- });
48- deployments[4 ] = Deployment ({
49- chain: StateMachine.evm (56 ), // bsc
50- gateway: address (intentGateway)
51- });
52- deployments[5 ] = Deployment ({
53- chain: StateMachine.evm (100 ), // gnosis
54- gateway: address (intentGateway)
55- });
56- deployments[6 ] = Deployment ({
57- chain: StateMachine.evm (137 ), // polygon
58- gateway: address (intentGateway)
59- });
60- deployments[7 ] = Deployment ({
61- chain: StateMachine.evm (420420419 ), // polkadot
62- gateway: address (intentGateway)
63- });
64- deployments[8 ] = Deployment ({
65- chain: StateMachine.evm (1868 ), // soneium
66- gateway: address (intentGateway)
67- });
30+ peerChains = new bytes [](9 );
31+ peerChains[0 ] = StateMachine.evm (1 ); // ethereum
32+ peerChains[1 ] = StateMachine.evm (10 ); // optimism
33+ peerChains[2 ] = StateMachine.evm (42161 ); // arbitrum
34+ peerChains[3 ] = StateMachine.evm (8453 ); // base
35+ peerChains[4 ] = StateMachine.evm (56 ); // bsc
36+ peerChains[5 ] = StateMachine.evm (100 ); // gnosis
37+ peerChains[6 ] = StateMachine.evm (137 ); // polygon
38+ peerChains[7 ] = StateMachine.evm (420420419 ); // polkadot
39+ peerChains[8 ] = StateMachine.evm (1868 ); // soneium
6840 } else {
69- deployments = new Deployment [](2 );
70- deployments[0 ] = Deployment ({
71- chain: StateMachine.evm (97 ), // bsc testnet (chapel)
72- gateway: address (intentGateway)
73- });
74- deployments[1 ] = Deployment ({
75- chain: StateMachine.evm (80002 ), // polygon amoy
76- gateway: address (intentGateway)
77- });
41+ peerChains = new bytes [](2 );
42+ peerChains[0 ] = StateMachine.evm (97 ); // bsc testnet (chapel)
43+ peerChains[1 ] = StateMachine.evm (80002 ); // polygon amoy
7844 }
7945
80- intentGateway.init (
81- Params ({
82- host: HOST_ADDRESS,
83- dispatcher: config.get ("CALL_DISPATCHER " ).toAddress (),
84- solverSelection: config.get ("7702 " ).toBool (),
85- surplusShareBps: 5_000 , // 50%
86- protocolFeeBps: 30 , // 0.3%
87- priceOracle: address (priceOracle)
88- }),
89- deployments
46+ bytes memory initData = abi.encodeCall (
47+ IntentGatewayV2.initialize,
48+ (
49+ Params ({
50+ host: HOST_ADDRESS,
51+ dispatcher: config.get ("CALL_DISPATCHER " ).toAddress (),
52+ solverSelection: config.get ("7702 " ).toBool (),
53+ surplusShareBps: 5_000 , // 50%
54+ protocolFeeBps: 30 , // 0.3%
55+ priceOracle: priceOracle
56+ }),
57+ peerChains
58+ )
9059 );
60+ ERC1967Proxy proxy = new ERC1967Proxy {salt: salt}(address (implementation), initData);
61+ IntentGatewayV2 intentGateway = IntentGatewayV2 (payable (address (proxy)));
62+ SolverAccount solverAccount = new SolverAccount {salt: salt}(address (intentGateway));
9163
9264 vm.stopBroadcast ();
65+
66+ console.log ("IntentGateway implementation deployed at: " , address (implementation));
67+ console.log ("IntentGateway proxy deployed at: " , address (intentGateway));
68+ console.log ("SolverAccount deployed at: " , address (solverAccount));
69+
9370 config.set ("INTENT_GATEWAY_V2 " , address (intentGateway));
9471 config.set ("SOLVER_ACCOUNT " , address (solverAccount));
9572 config.set ("PRICE_ORACLE " , address (priceOracle));
9673 }
97-
98- function deployPriceOracle (address intentGateway ) internal returns (address ) {
99- VWAPOracle priceOracle = new VWAPOracle {salt: salt}(admin, intentGateway);
100- console.log ("VWAPOracle deployed at: " , address (priceOracle));
101-
102- // Initialize price oracle with token decimals
103- VWAPOracle.TokenDecimalsUpdate[] memory decimalsUpdates = new VWAPOracle.TokenDecimalsUpdate [](9 );
104-
105- // Ethereum
106- decimalsUpdates[0 ].sourceChain = bytes ("EVM-1 " );
107- decimalsUpdates[0 ].tokens = new VWAPOracle.TokenDecimal [](2 );
108- decimalsUpdates[0 ].tokens[0 ] = VWAPOracle.TokenDecimal ({
109- token: 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48 , // USDC
110- decimals: 6
111- });
112- decimalsUpdates[0 ].tokens[1 ] = VWAPOracle.TokenDecimal ({
113- token: 0xdAC17F958D2ee523a2206206994597C13D831ec7 , // USDT
114- decimals: 6
115- });
116-
117- // Arbitrum
118- decimalsUpdates[1 ].sourceChain = bytes ("EVM-42161 " );
119- decimalsUpdates[1 ].tokens = new VWAPOracle.TokenDecimal [](2 );
120- decimalsUpdates[1 ].tokens[0 ] = VWAPOracle.TokenDecimal ({
121- token: 0xaf88d065e77c8cC2239327C5EDb3A432268e5831 , // USDC
122- decimals: 6
123- });
124- decimalsUpdates[1 ].tokens[1 ] = VWAPOracle.TokenDecimal ({
125- token: 0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9 , // USDT
126- decimals: 6
127- });
128-
129- // Optimism
130- decimalsUpdates[2 ].sourceChain = bytes ("EVM-10 " );
131- decimalsUpdates[2 ].tokens = new VWAPOracle.TokenDecimal [](2 );
132- decimalsUpdates[2 ].tokens[0 ] = VWAPOracle.TokenDecimal ({
133- token: 0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85 , // USDC
134- decimals: 6
135- });
136- decimalsUpdates[2 ].tokens[1 ] = VWAPOracle.TokenDecimal ({
137- token: 0x94b008aA00579c1307B0EF2c499aD98a8ce58e58 , // USDT
138- decimals: 6
139- });
140-
141- // Base
142- decimalsUpdates[3 ].sourceChain = bytes ("EVM-8453 " );
143- decimalsUpdates[3 ].tokens = new VWAPOracle.TokenDecimal [](2 );
144- decimalsUpdates[3 ].tokens[0 ] = VWAPOracle.TokenDecimal ({
145- token: 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913 , // USDC
146- decimals: 6
147- });
148- decimalsUpdates[3 ].tokens[1 ] = VWAPOracle.TokenDecimal ({
149- token: 0xfde4C96c8593536E31F229EA8f37b2ADa2699bb2 , // USDT
150- decimals: 6
151- });
152-
153- // BSC
154- decimalsUpdates[4 ].sourceChain = bytes ("EVM-56 " );
155- decimalsUpdates[4 ].tokens = new VWAPOracle.TokenDecimal [](2 );
156- decimalsUpdates[4 ].tokens[0 ] = VWAPOracle.TokenDecimal ({
157- token: 0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d , // USDC
158- decimals: 18
159- });
160- decimalsUpdates[4 ].tokens[1 ] = VWAPOracle.TokenDecimal ({
161- token: 0x55d398326f99059fF775485246999027B3197955 , // USDT
162- decimals: 18
163- });
164-
165- // Gnosis
166- decimalsUpdates[5 ].sourceChain = bytes ("EVM-100 " );
167- decimalsUpdates[5 ].tokens = new VWAPOracle.TokenDecimal [](2 );
168- decimalsUpdates[5 ].tokens[0 ] = VWAPOracle.TokenDecimal ({
169- token: 0xDDAfbb505ad214D7b80b1f830fcCc89B60fb7A83 , // USDC (WXDAI)
170- decimals: 6
171- });
172- decimalsUpdates[5 ].tokens[1 ] = VWAPOracle.TokenDecimal ({
173- token: 0x4ECaBa5870353805a9F068101A40E0f32ed605C6 , // USDT
174- decimals: 6
175- });
176-
177- // Polygon
178- decimalsUpdates[6 ].sourceChain = bytes ("EVM-137 " );
179- decimalsUpdates[6 ].tokens = new VWAPOracle.TokenDecimal [](2 );
180- decimalsUpdates[6 ].tokens[0 ] = VWAPOracle.TokenDecimal ({
181- token: 0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359 , // USDC
182- decimals: 6
183- });
184- decimalsUpdates[6 ].tokens[1 ] = VWAPOracle.TokenDecimal ({
185- token: 0xc2132D05D31c914a87C6611C10748AEb04B58e8F , // USDT
186- decimals: 6
187- });
188-
189- // Unichain
190- decimalsUpdates[7 ].sourceChain = bytes ("EVM-130 " );
191- decimalsUpdates[7 ].tokens = new VWAPOracle.TokenDecimal [](2 );
192- decimalsUpdates[7 ].tokens[0 ] = VWAPOracle.TokenDecimal ({
193- token: 0x078D782b760474a361dDA0AF3839290b0EF57AD6 , // USDC
194- decimals: 6
195- });
196- decimalsUpdates[7 ].tokens[1 ] = VWAPOracle.TokenDecimal ({
197- token: 0x9151434b16b9763660705744891fA906F660EcC5 , // USDT
198- decimals: 6
199- });
200-
201- // Tron
202- decimalsUpdates[8 ].sourceChain = bytes ("EVM-728126428 " );
203- decimalsUpdates[8 ].tokens = new VWAPOracle.TokenDecimal [](2 );
204- decimalsUpdates[8 ].tokens[0 ] = VWAPOracle.TokenDecimal ({
205- token: 0x742b023b58488B4be587bBA63ed11134b02217B3 , // USDC
206- decimals: 6
207- });
208- decimalsUpdates[8 ].tokens[1 ] = VWAPOracle.TokenDecimal ({
209- token: 0xa614f803B6FD780986A42c78Ec9c7f77e6DeD13C , // USDT
210- decimals: 6
211- });
212- priceOracle.init (HOST_ADDRESS, decimalsUpdates);
213-
214- return address (priceOracle);
215- }
21674}
0 commit comments