@@ -7,13 +7,25 @@ import "forge-std/Script.sol";
7
7
import {ModuleBeaconDeployer_v1} from
8
8
"script/deploymentSuite/ModuleBeaconDeployer_v1.s.sol " ;
9
9
10
- // Constants
10
+ // Interfaces
11
+ import {IDeterministicFactory_v1} from
12
+ "@df/interfaces/IDeterministicFactory_v1.sol " ;
13
+
14
+ // Contracts
11
15
import {Governor_v1} from "@ex/governance/Governor_v1.sol " ;
12
16
import {FeeManager_v1} from "@ex/fees/FeeManager_v1.sol " ;
17
+ import {TransactionForwarder_v1} from
18
+ "@ex/forwarder/TransactionForwarder_v1.sol " ;
13
19
import {ModuleFactory_v1} from "src/factories/ModuleFactory_v1.sol " ;
14
20
import {OrchestratorFactory_v1} from "src/factories/OrchestratorFactory_v1.sol " ;
15
- import {IDeterministicFactory_v1} from
16
- "@df/interfaces/IDeterministicFactory_v1.sol " ;
21
+ import {
22
+ InverterBeacon_v1,
23
+ IInverterBeacon_v1
24
+ } from "src/proxies/InverterBeacon_v1.sol " ;
25
+ import {Orchestrator_v1} from "src/orchestrator/Orchestrator_v1.sol " ;
26
+ import {Module_v1} from "src/modules/base/Module_v1.sol " ;
27
+ import {Ownable} from "@oz/access/Ownable.sol " ;
28
+ import {EIP712} from "@oz/utils/cryptography/EIP712.sol " ;
17
29
18
30
/**
19
31
* @title Inverter Deployment Script
@@ -26,6 +38,7 @@ import {IDeterministicFactory_v1} from
26
38
* @author Inverter Network
27
39
*/
28
40
contract DeploymentScript is ModuleBeaconDeployer_v1 {
41
+ // Contracts
29
42
address public inverterReverter;
30
43
31
44
address public governor;
@@ -35,6 +48,14 @@ contract DeploymentScript is ModuleBeaconDeployer_v1 {
35
48
address public moduleFactory;
36
49
address public orchestratorFactory;
37
50
51
+ // Beacons
52
+ address public governorBeacon;
53
+ address public forwarderBeacon;
54
+ address public feeManagerBeacon;
55
+
56
+ address public moduleFactoryBeacon;
57
+ address public orchestratorFactoryBeacon;
58
+
38
59
function run ()
39
60
public
40
61
virtual
@@ -67,7 +88,8 @@ contract DeploymentScript is ModuleBeaconDeployer_v1 {
67
88
);
68
89
console2.log (" Deploy External Contracts " );
69
90
70
- governor = proxyAndBeaconDeployer.deployBeaconAndSetupProxy (
91
+ (governorBeacon, governor) = proxyAndBeaconDeployer
92
+ .deployBeaconAndSetupProxy (
71
93
governorMetadata.title,
72
94
inverterReverter,
73
95
communityMultisig,
@@ -77,7 +99,8 @@ contract DeploymentScript is ModuleBeaconDeployer_v1 {
77
99
governorMetadata.patchVersion
78
100
);
79
101
80
- forwarder = proxyAndBeaconDeployer.deployBeaconAndSetupProxy (
102
+ (forwarderBeacon, forwarder) = proxyAndBeaconDeployer
103
+ .deployBeaconAndSetupProxy (
81
104
forwarderMetadata.title,
82
105
inverterReverter,
83
106
governor,
@@ -87,7 +110,8 @@ contract DeploymentScript is ModuleBeaconDeployer_v1 {
87
110
forwarderMetadata.patchVersion
88
111
);
89
112
90
- feeManager = proxyAndBeaconDeployer.deployBeaconAndSetupProxy (
113
+ (feeManagerBeacon, feeManager) = proxyAndBeaconDeployer
114
+ .deployBeaconAndSetupProxy (
91
115
feeManagerMetadata.title,
92
116
inverterReverter,
93
117
governor,
@@ -106,7 +130,8 @@ contract DeploymentScript is ModuleBeaconDeployer_v1 {
106
130
);
107
131
console2.log (" Deploy Factory Contracts " );
108
132
109
- moduleFactory = proxyAndBeaconDeployer.deployBeaconAndSetupProxy (
133
+ (moduleFactoryBeacon, moduleFactory) = proxyAndBeaconDeployer
134
+ .deployBeaconAndSetupProxy (
110
135
moduleFactoryMetadata.title,
111
136
inverterReverter,
112
137
governor,
@@ -116,7 +141,8 @@ contract DeploymentScript is ModuleBeaconDeployer_v1 {
116
141
moduleFactoryMetadata.patchVersion
117
142
);
118
143
119
- orchestratorFactory = proxyAndBeaconDeployer.deployBeaconAndSetupProxy (
144
+ (orchestratorFactoryBeacon, orchestratorFactory) =
145
+ proxyAndBeaconDeployer.deployBeaconAndSetupProxy (
120
146
orchestratorFactoryMetadata.title,
121
147
inverterReverter,
122
148
governor,
@@ -164,6 +190,10 @@ contract DeploymentScript is ModuleBeaconDeployer_v1 {
164
190
);
165
191
console2.log ("\t... FeeManager initialized " );
166
192
193
+ // TransactionForwarder
194
+ TransactionForwarder_v1 (forwarder).init ();
195
+ console2.log ("\t... TransactionForwarder initialized " );
196
+
167
197
// ModuleFactory
168
198
ModuleFactory_v1 (moduleFactory).init (
169
199
governor, initialMetadataRegistration, initialBeaconRegistration
@@ -183,51 +213,246 @@ contract DeploymentScript is ModuleBeaconDeployer_v1 {
183
213
184
214
// ------------------------------------------------------------------------
185
215
// In order to verify that the deployment was successful, we
186
- // verify that the core contracts have been initialized correctly.
216
+ // verify that the contracts have been initialized correctly and all
217
+ // important values have been set as expected.
218
+
219
+ verifyDeployment ();
220
+
221
+ // ------------------------------------------------------------------------
222
+ }
223
+
224
+ function verifyDeployment () public {
225
+ // ------------------------------------------------------------------------
226
+ // >>> Governor
187
227
188
- // Governor
228
+ // Verify that the Community Multisig is set correctly
189
229
require (
190
230
Governor_v1 (governor).hasRole (
191
231
Governor_v1 (governor).COMMUNITY_MULTISIG_ROLE (),
192
232
communityMultisig
193
233
) == true ,
194
- "Deployment failed - Governor not initialized correctly, Community Multisig is not set. "
234
+ "Deployment failed - Governor not initialized correctly, Community Multisig is not set correctly . "
195
235
);
236
+
237
+ // Verify that the Team Multisig is set correctly
196
238
require (
197
239
Governor_v1 (governor).hasRole (
198
240
Governor_v1 (governor).TEAM_MULTISIG_ROLE (), teamMultisig
199
241
) == true ,
200
- "Deployment failed - Governor not initialized correctly, Team Multisig is not set. "
242
+ "Deployment failed - Governor not initialized correctly, Team Multisig is not set correctly . "
201
243
);
244
+
245
+ // Verify that Module Factory is linked correctly
202
246
require (
203
247
Governor_v1 (governor).getModuleFactory () == moduleFactory,
204
- "Deployment failed - Governor not initialized correctly, ModuleFactory is not set . "
248
+ "Deployment failed - Governor not initialized correctly, ModuleFactory is not correct . "
205
249
);
250
+
251
+ // Verify that Fee Manager is linked correctly
206
252
require (
207
253
Governor_v1 (governor).getFeeManager () == feeManager,
208
- "Deployment failed - Governor not initialized correctly, FeeManager is not set. "
254
+ "Deployment failed - Governor not initialized correctly, FeeManager is not correct. "
255
+ );
256
+
257
+ // Verify that the Timelock Period is set correctly
258
+ require (
259
+ Governor_v1 (governor).timelockPeriod () == governor_timelockPeriod,
260
+ "Deployment failed - Governor not initialized correctly, Timelock Period is not correct. "
261
+ );
262
+
263
+ // Verify that the Reverter is linked correctly
264
+ require (
265
+ IInverterBeacon_v1 (governorBeacon).getReverterAddress ()
266
+ == inverterReverter,
267
+ "Deployment failed - Governor Beacon not initialized correctly, Reverter is not correct. "
209
268
);
210
269
211
- // ModuleFactory
270
+ // ------------------------------------------------------------------------
271
+ // >>> ModuleFactory
272
+
273
+ // Verify that the ModuleFactory is owned by the Governor
212
274
require (
213
275
ModuleFactory_v1 (moduleFactory).owner () == governor,
214
276
"Deployment failed - ModuleFactory not initialized correctly, not owned by Governor. "
215
277
);
216
278
217
- // OrchestratorFactory
279
+ // Verify that the TransactionForwarder is linked correctly
280
+ require (
281
+ ModuleFactory_v1 (moduleFactory).trustedForwarder () == forwarder,
282
+ "Deployment failed - ModuleFactory not initialized correctly, Forwarder is not correct. "
283
+ );
284
+
285
+ // Verify that the Reverter is linked correctly
286
+ require (
287
+ ModuleFactory_v1 (moduleFactory).reverter () == inverterReverter,
288
+ "Deployment failed - ModuleFactory not initialized correctly, Reverter is not correct. "
289
+ );
290
+
291
+ // Verify that the Reverter is linked correctly
292
+ require (
293
+ IInverterBeacon_v1 (moduleFactoryBeacon).getReverterAddress ()
294
+ == inverterReverter,
295
+ "Deployment failed - ModuleFactory Beacon not initialized correctly, Reverter is not correct. "
296
+ );
297
+
298
+ // ------------------------------------------------------------------------
299
+ // >>> OrchestratorFactory
300
+
301
+ // Verify that the ModuleFactory is linked correctly
218
302
require (
219
303
OrchestratorFactory_v1 (orchestratorFactory).moduleFactory ()
220
304
== moduleFactory,
221
- "Deployment failed - OrchestratorFactory not initialized correctly, ModuleFactory is not set. "
305
+ "Deployment failed - OrchestratorFactory not initialized correctly, ModuleFactory is not correct. "
306
+ );
307
+
308
+ // Verify that the TransactionForwarder is linked correctly
309
+ require (
310
+ OrchestratorFactory_v1 (orchestratorFactory).trustedForwarder ()
311
+ == forwarder,
312
+ "Deployment failed - OrchestratorFactory not initialized correctly, Forwarder is not correct. "
222
313
);
223
314
224
- // FeeManager
315
+ // Verify that the Reverter is linked correctly
316
+ require (
317
+ IInverterBeacon_v1 (orchestratorFactoryBeacon).getReverterAddress ()
318
+ == inverterReverter,
319
+ "Deployment failed - OrchestratorFactory Beacon not initialized correctly, Reverter is not correct. "
320
+ );
321
+
322
+ // ------------------------------------------------------------------------
323
+ // >>> FeeManager
324
+
325
+ // Verify that the FeeManager is owned by the Governor
225
326
require (
226
327
FeeManager_v1 (feeManager).owner () == governor,
227
328
"Deployment failed - FeeManager not initialized correctly, not owned by Governor. "
228
329
);
229
330
331
+ // Verify that the Treasury is set correctly
332
+ require (
333
+ FeeManager_v1 (feeManager).getDefaultProtocolTreasury () == treasury,
334
+ "Deployment failed - FeeManager not initialized correctly, Treasury is not correct. "
335
+ );
336
+
337
+ // Verify that the Default Collateral Fee is set correctly
338
+ require (
339
+ FeeManager_v1 (feeManager).getDefaultCollateralFee ()
340
+ == feeManager_defaultCollateralFee,
341
+ "Deployment failed - FeeManager not initialized correctly, Default Collateral Fee is not correct. "
342
+ );
343
+
344
+ // Verify that the Default Issuance Fee is set correctly
345
+ require (
346
+ FeeManager_v1 (feeManager).getDefaultIssuanceFee ()
347
+ == feeManager_defaultIssuanceFee,
348
+ "Deployment failed - FeeManager not initialized correctly, Default Issuance Fee is not correct. "
349
+ );
350
+
351
+ // Verify that the Reverter is linked correctly
352
+ require (
353
+ IInverterBeacon_v1 (feeManagerBeacon).getReverterAddress ()
354
+ == inverterReverter,
355
+ "Deployment failed - FeeManager Beacon not initialized correctly, Reverter is not correct. "
356
+ );
357
+
230
358
// ------------------------------------------------------------------------
359
+ // >>> TransactionForwarder
360
+
361
+ // Verify that the TransactionForwarder has been initialized correctly
362
+ (
363
+ ,
364
+ string memory _name ,
365
+ string memory _version ,
366
+ uint _chainId ,
367
+ address _verifyingContract ,
368
+ ,
369
+ ) = EIP712 (forwarder).eip712Domain ();
370
+ require (
371
+ _chainId == block .chainid
372
+ && keccak256 (abi.encodePacked (_version))
373
+ == keccak256 (abi.encodePacked ("1 " ))
374
+ && keccak256 (abi.encodePacked (_name))
375
+ == keccak256 (abi.encodePacked ("Inverter TransactionForwarder_v1 " ))
376
+ && _verifyingContract == forwarder,
377
+ "Deployment failed - TransactionForwarder not initialized correctly. "
378
+ );
379
+
380
+ // Verify that the Reverter is linked correctly
381
+ require (
382
+ IInverterBeacon_v1 (forwarderBeacon).getReverterAddress ()
383
+ == inverterReverter,
384
+ "Deployment failed - TransactionForwarder Beacon not initialized correctly, Reverter is not correct. "
385
+ );
386
+
387
+ // ------------------------------------------------------------------------
388
+ // >>> Orchestrator
389
+
390
+ // Verify that the Orchestrator Beacon is owned by the Governor
391
+ require (
392
+ Ownable (address (orchestratorBeacon)).owner () == governor,
393
+ "Deployment failed - Orchestrator Beacon not initialized correctly, not owned by Governor. "
394
+ );
395
+
396
+ // Verify that the TransactionForwarder is linked correctly in the Orchestrator
397
+ require (
398
+ Orchestrator_v1 (orchestratorBeacon.getImplementationAddress ())
399
+ .trustedForwarder () == forwarder,
400
+ "Deployment failed - Orchestrator Beacon not initialized correctly, Forwarder is not correct. "
401
+ );
402
+
403
+ // Verify that the Orchestrator Beacon references the right version
404
+ (
405
+ uint _orchestratorMajor ,
406
+ uint _orchestratorMinor ,
407
+ uint _orchestratorPatch
408
+ ) = orchestratorBeacon.version ();
409
+ require (
410
+ _orchestratorMajor == orchestratorMetadata.majorVersion
411
+ && _orchestratorMinor == orchestratorMetadata.minorVersion
412
+ && _orchestratorPatch == orchestratorMetadata.patchVersion,
413
+ "Deployment failed - Orchestrator Beacon not initialized correctly, version is not correct. "
414
+ );
415
+
416
+ // Verify that the Reverter is linked correctly
417
+ require (
418
+ orchestratorBeacon.getReverterAddress () == inverterReverter,
419
+ "Deployment failed - Orchestrator Beacon not initialized correctly, Reverter is not correct. "
420
+ );
421
+
422
+ // ------------------------------------------------------------------------
423
+ // >>> Modules
424
+
425
+ for (uint i; i < initialMetadataRegistration.length ; i++ ) {
426
+ // Verify that the Module Beacon is linked to the right metadata
427
+ (IInverterBeacon_v1 _moduleBeacon ,) = ModuleFactory_v1 (
428
+ moduleFactory
429
+ ).getBeaconAndId (initialMetadataRegistration[i]);
430
+ require (
431
+ _moduleBeacon == initialBeaconRegistration[i],
432
+ "Deployment failed - Module Metadata doesn't match registration data. "
433
+ );
434
+
435
+ // Verify that the Module Beacon is owned by the Governor
436
+ require (
437
+ Ownable (address (_moduleBeacon)).owner () == governor,
438
+ "Deployment failed - Module Beacon not initialized correctly, not owned by Governor. "
439
+ );
440
+
441
+ // Verify that the Module Beacon references the right version
442
+ (uint _major , uint _minor , uint _patch ) = _moduleBeacon.version ();
443
+ require (
444
+ _major == initialMetadataRegistration[i].majorVersion
445
+ && _minor == initialMetadataRegistration[i].minorVersion
446
+ && _patch == initialMetadataRegistration[i].patchVersion,
447
+ "Deployment failed - Module Beacon not initialized correctly, version is not correct. "
448
+ );
449
+
450
+ // Verify that the Reverter is linked correctly
451
+ require (
452
+ _moduleBeacon.getReverterAddress () == inverterReverter,
453
+ "Deployment failed - Module Beacon not initialized correctly, Reverter is not correct. "
454
+ );
455
+ }
231
456
}
232
457
233
458
modifier verifyRequiredParameters () {
0 commit comments