-
Notifications
You must be signed in to change notification settings - Fork 125
Expand file tree
/
Copy pathDeployIntentGateway.s.sol
More file actions
216 lines (195 loc) · 8.62 KB
/
Copy pathDeployIntentGateway.s.sol
File metadata and controls
216 lines (195 loc) · 8.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.17;
import "forge-std/Script.sol";
import "stringutils/strings.sol";
import {IntentGatewayV2, Params, Deployment} from "../src/apps/IntentGatewayV2.sol";
import {BaseScript} from "./BaseScript.sol";
import {CallDispatcher} from "../src/utils/CallDispatcher.sol";
import {SolverAccount} from "../src/apps/intentsv2/SolverAccount.sol";
import {VWAPOracle} from "../src/utils/VWAPOracle.sol";
import {StateMachine} from "@hyperbridge/core/libraries/StateMachine.sol";
contract DeployScript is BaseScript {
using strings for *;
/// @notice Main deployment logic - called by BaseScript's run() functions
/// @dev This function is called within a broadcast context
function deploy() internal override {
IntentGatewayV2 intentGateway = new IntentGatewayV2{salt: salt}(admin);
console.log("IntentGateway deployed at:", address(intentGateway));
SolverAccount solverAccount = new SolverAccount{salt: salt}(address(intentGateway));
console.log("SolverAccount deployed at:", address(solverAccount));
address priceOracle = address(0);
// address priceOracle = deployPriceOracle(address(intentGateway));
Deployment[] memory deployments;
if (config.get("is_mainnet").toBool()) {
deployments = new Deployment[](9);
deployments[0] = Deployment({
chain: StateMachine.evm(1), // ethereum
gateway: address(intentGateway)
});
deployments[1] = Deployment({
chain: StateMachine.evm(10), // optimism
gateway: address(intentGateway)
});
deployments[2] = Deployment({
chain: StateMachine.evm(42161), // arbitrum
gateway: address(intentGateway)
});
deployments[3] = Deployment({
chain: StateMachine.evm(8453), // base
gateway: address(intentGateway)
});
deployments[4] = Deployment({
chain: StateMachine.evm(56), // bsc
gateway: address(intentGateway)
});
deployments[5] = Deployment({
chain: StateMachine.evm(100), // gnosis
gateway: address(intentGateway)
});
deployments[6] = Deployment({
chain: StateMachine.evm(137), // polygon
gateway: address(intentGateway)
});
deployments[7] = Deployment({
chain: StateMachine.evm(420420419), // polkadot
gateway: address(intentGateway)
});
deployments[8] = Deployment({
chain: StateMachine.evm(1868), // soneium
gateway: address(intentGateway)
});
} else {
deployments = new Deployment[](2);
deployments[0] = Deployment({
chain: StateMachine.evm(97), // bsc testnet (chapel)
gateway: address(intentGateway)
});
deployments[1] = Deployment({
chain: StateMachine.evm(80002), // polygon amoy
gateway: address(intentGateway)
});
}
intentGateway.init(
Params({
host: HOST_ADDRESS,
dispatcher: config.get("CALL_DISPATCHER").toAddress(),
solverSelection: config.get("7702").toBool(),
surplusShareBps: 5_000, // 50%
protocolFeeBps: 30, // 0.3%
priceOracle: address(priceOracle)
}),
deployments
);
vm.stopBroadcast();
config.set("INTENT_GATEWAY_V2", address(intentGateway));
config.set("SOLVER_ACCOUNT", address(solverAccount));
config.set("PRICE_ORACLE", address(priceOracle));
}
function deployPriceOracle(address intentGateway) internal returns (address) {
VWAPOracle priceOracle = new VWAPOracle{salt: salt}(admin, intentGateway);
console.log("VWAPOracle deployed at:", address(priceOracle));
// Initialize price oracle with token decimals
VWAPOracle.TokenDecimalsUpdate[] memory decimalsUpdates = new VWAPOracle.TokenDecimalsUpdate[](9);
// Ethereum
decimalsUpdates[0].sourceChain = bytes("EVM-1");
decimalsUpdates[0].tokens = new VWAPOracle.TokenDecimal[](2);
decimalsUpdates[0].tokens[0] = VWAPOracle.TokenDecimal({
token: 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48, // USDC
decimals: 6
});
decimalsUpdates[0].tokens[1] = VWAPOracle.TokenDecimal({
token: 0xdAC17F958D2ee523a2206206994597C13D831ec7, // USDT
decimals: 6
});
// Arbitrum
decimalsUpdates[1].sourceChain = bytes("EVM-42161");
decimalsUpdates[1].tokens = new VWAPOracle.TokenDecimal[](2);
decimalsUpdates[1].tokens[0] = VWAPOracle.TokenDecimal({
token: 0xaf88d065e77c8cC2239327C5EDb3A432268e5831, // USDC
decimals: 6
});
decimalsUpdates[1].tokens[1] = VWAPOracle.TokenDecimal({
token: 0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9, // USDT
decimals: 6
});
// Optimism
decimalsUpdates[2].sourceChain = bytes("EVM-10");
decimalsUpdates[2].tokens = new VWAPOracle.TokenDecimal[](2);
decimalsUpdates[2].tokens[0] = VWAPOracle.TokenDecimal({
token: 0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85, // USDC
decimals: 6
});
decimalsUpdates[2].tokens[1] = VWAPOracle.TokenDecimal({
token: 0x94b008aA00579c1307B0EF2c499aD98a8ce58e58, // USDT
decimals: 6
});
// Base
decimalsUpdates[3].sourceChain = bytes("EVM-8453");
decimalsUpdates[3].tokens = new VWAPOracle.TokenDecimal[](2);
decimalsUpdates[3].tokens[0] = VWAPOracle.TokenDecimal({
token: 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913, // USDC
decimals: 6
});
decimalsUpdates[3].tokens[1] = VWAPOracle.TokenDecimal({
token: 0xfde4C96c8593536E31F229EA8f37b2ADa2699bb2, // USDT
decimals: 6
});
// BSC
decimalsUpdates[4].sourceChain = bytes("EVM-56");
decimalsUpdates[4].tokens = new VWAPOracle.TokenDecimal[](2);
decimalsUpdates[4].tokens[0] = VWAPOracle.TokenDecimal({
token: 0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d, // USDC
decimals: 18
});
decimalsUpdates[4].tokens[1] = VWAPOracle.TokenDecimal({
token: 0x55d398326f99059fF775485246999027B3197955, // USDT
decimals: 18
});
// Gnosis
decimalsUpdates[5].sourceChain = bytes("EVM-100");
decimalsUpdates[5].tokens = new VWAPOracle.TokenDecimal[](2);
decimalsUpdates[5].tokens[0] = VWAPOracle.TokenDecimal({
token: 0xDDAfbb505ad214D7b80b1f830fcCc89B60fb7A83, // USDC (WXDAI)
decimals: 6
});
decimalsUpdates[5].tokens[1] = VWAPOracle.TokenDecimal({
token: 0x4ECaBa5870353805a9F068101A40E0f32ed605C6, // USDT
decimals: 6
});
// Polygon
decimalsUpdates[6].sourceChain = bytes("EVM-137");
decimalsUpdates[6].tokens = new VWAPOracle.TokenDecimal[](2);
decimalsUpdates[6].tokens[0] = VWAPOracle.TokenDecimal({
token: 0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359, // USDC
decimals: 6
});
decimalsUpdates[6].tokens[1] = VWAPOracle.TokenDecimal({
token: 0xc2132D05D31c914a87C6611C10748AEb04B58e8F, // USDT
decimals: 6
});
// Unichain
decimalsUpdates[7].sourceChain = bytes("EVM-130");
decimalsUpdates[7].tokens = new VWAPOracle.TokenDecimal[](2);
decimalsUpdates[7].tokens[0] = VWAPOracle.TokenDecimal({
token: 0x078D782b760474a361dDA0AF3839290b0EF57AD6, // USDC
decimals: 6
});
decimalsUpdates[7].tokens[1] = VWAPOracle.TokenDecimal({
token: 0x9151434b16b9763660705744891fA906F660EcC5, // USDT
decimals: 6
});
// Tron
decimalsUpdates[8].sourceChain = bytes("EVM-728126428");
decimalsUpdates[8].tokens = new VWAPOracle.TokenDecimal[](2);
decimalsUpdates[8].tokens[0] = VWAPOracle.TokenDecimal({
token: 0x742b023b58488B4be587bBA63ed11134b02217B3, // USDC
decimals: 6
});
decimalsUpdates[8].tokens[1] = VWAPOracle.TokenDecimal({
token: 0xa614f803B6FD780986A42c78Ec9c7f77e6DeD13C, // USDT
decimals: 6
});
priceOracle.init(HOST_ADDRESS, decimalsUpdates);
return address(priceOracle);
}
}