-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathFullDeployer.s.sol
More file actions
806 lines (681 loc) · 31.7 KB
/
FullDeployer.s.sol
File metadata and controls
806 lines (681 loc) · 31.7 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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.28;
import {CoreInput, CoreReport, CoreDeployer, CoreActionBatcher} from "./CoreDeployer.s.sol";
import {SetConfigParam, ILayerZeroEndpointV2Like} from "./utils/ILayerZeroEndpointV2Like.sol";
import {PoolId} from "../src/core/types/PoolId.sol";
import {IAdapter} from "../src/core/messaging/interfaces/IAdapter.sol";
import {MAX_ADAPTER_COUNT} from "../src/core/messaging/interfaces/IMultiAdapter.sol";
import {Root} from "../src/admin/Root.sol";
import {ISafe} from "../src/admin/interfaces/ISafe.sol";
import {OpsGuardian} from "../src/admin/OpsGuardian.sol";
import {TokenRecoverer} from "../src/admin/TokenRecoverer.sol";
import {ProtocolGuardian} from "../src/admin/ProtocolGuardian.sol";
import {FreezeOnly} from "../src/hooks/FreezeOnly.sol";
import {FullRestrictions} from "../src/hooks/FullRestrictions.sol";
import {FreelyTransferable} from "../src/hooks/FreelyTransferable.sol";
import {RedemptionRestrictions} from "../src/hooks/RedemptionRestrictions.sol";
import {NAVManager} from "../src/managers/hub/NAVManager.sol";
import {QueueManager} from "../src/managers/spoke/QueueManager.sol";
import {VaultDecoder} from "../src/managers/spoke/decoders/VaultDecoder.sol";
import {SimplePriceManager} from "../src/managers/hub/SimplePriceManager.sol";
import {CircleDecoder} from "../src/managers/spoke/decoders/CircleDecoder.sol";
import {OnOfframpManagerFactory} from "../src/managers/spoke/OnOfframpManager.sol";
import {MerkleProofManagerFactory} from "../src/managers/spoke/MerkleProofManager.sol";
import {OracleValuation} from "../src/valuations/OracleValuation.sol";
import {IdentityValuation} from "../src/valuations/IdentityValuation.sol";
import {SyncManager} from "../src/vaults/SyncManager.sol";
import {VaultRouter} from "../src/vaults/VaultRouter.sol";
import {AsyncRequestManager} from "../src/vaults/AsyncRequestManager.sol";
import {BatchRequestManager} from "../src/vaults/BatchRequestManager.sol";
import {AsyncVaultFactory} from "../src/vaults/factories/AsyncVaultFactory.sol";
import {SyncDepositVaultFactory} from "../src/vaults/factories/SyncDepositVaultFactory.sol";
import "forge-std/Script.sol";
import {TokenBridge} from "../src/bridge/TokenBridge.sol";
import {SubsidyManager} from "../src/utils/SubsidyManager.sol";
import {AxelarAdapter} from "../src/adapters/AxelarAdapter.sol";
import {WormholeAdapter} from "../src/adapters/WormholeAdapter.sol";
import {ChainlinkAdapter} from "../src/adapters/ChainlinkAdapter.sol";
import {LayerZeroAdapter} from "../src/adapters/LayerZeroAdapter.sol";
import {RefundEscrowFactory} from "../src/utils/RefundEscrowFactory.sol";
struct WormholeInput {
bool shouldDeploy;
address relayer;
}
struct AxelarInput {
bool shouldDeploy;
address gateway;
address gasService;
}
struct LayerZeroInput {
bool shouldDeploy;
address endpoint;
address delegate;
}
struct ChainlinkInput {
bool shouldDeploy;
address ccipRouter;
}
struct AdapterConnections {
uint16 centrifugeId;
uint32 layerZeroId;
uint16 wormholeId;
string axelarId;
uint64 chainlinkId;
uint8 threshold;
// Pre-computed LayerZero ULN config
// Should contain SetConfigParam[] for both send and receive libraries
SetConfigParam[] layerZeroConfigParams;
}
struct AdaptersInput {
LayerZeroInput layerZero;
WormholeInput wormhole;
AxelarInput axelar;
ChainlinkInput chainlink;
AdapterConnections[] connections;
}
struct FullInput {
ISafe adminSafe;
ISafe opsSafe;
CoreInput core;
AdaptersInput adapters;
}
struct FullReport {
CoreReport core;
Root root;
TokenRecoverer tokenRecoverer;
ProtocolGuardian protocolGuardian;
OpsGuardian opsGuardian;
TokenBridge tokenBridge;
SubsidyManager subsidyManager;
RefundEscrowFactory refundEscrowFactory;
AsyncVaultFactory asyncVaultFactory;
AsyncRequestManager asyncRequestManager;
SyncDepositVaultFactory syncDepositVaultFactory;
SyncManager syncManager;
VaultRouter vaultRouter;
FreezeOnly freezeOnlyHook;
FullRestrictions fullRestrictionsHook;
FreelyTransferable freelyTransferableHook;
RedemptionRestrictions redemptionRestrictionsHook;
QueueManager queueManager;
OnOfframpManagerFactory onOfframpManagerFactory;
MerkleProofManagerFactory merkleProofManagerFactory;
VaultDecoder vaultDecoder;
CircleDecoder circleDecoder;
BatchRequestManager batchRequestManager;
IdentityValuation identityValuation;
OracleValuation oracleValuation;
NAVManager navManager;
SimplePriceManager simplePriceManager;
LayerZeroAdapter layerZeroAdapter;
WormholeAdapter wormholeAdapter;
AxelarAdapter axelarAdapter;
ChainlinkAdapter chainlinkAdapter;
}
contract FullActionBatcher is CoreActionBatcher {
constructor(address deployer_) CoreActionBatcher(deployer_) {}
function engageFull(
FullReport memory report,
ISafe adminSafe,
ISafe opsSafe,
AdapterConnections[] memory connectionList,
string memory remoteAxelarAdapter,
address layerZeroDelegate
) public onlyDeployer {
// Rely Root
report.tokenRecoverer.rely(address(report.root));
report.tokenBridge.rely(address(report.root));
report.subsidyManager.rely(address(report.root));
report.refundEscrowFactory.rely(address(report.root));
report.asyncVaultFactory.rely(address(report.root));
report.asyncRequestManager.rely(address(report.root));
report.syncDepositVaultFactory.rely(address(report.root));
report.syncManager.rely(address(report.root));
report.vaultRouter.rely(address(report.root));
report.freezeOnlyHook.rely(address(report.root));
report.fullRestrictionsHook.rely(address(report.root));
report.freelyTransferableHook.rely(address(report.root));
report.redemptionRestrictionsHook.rely(address(report.root));
report.batchRequestManager.rely(address(report.root));
_relyAdapters(report, address(report.root));
// Rely spoke
report.asyncRequestManager.rely(address(report.core.spoke));
report.freezeOnlyHook.rely(address(report.core.spoke));
report.fullRestrictionsHook.rely(address(report.core.spoke));
report.freelyTransferableHook.rely(address(report.core.spoke));
report.redemptionRestrictionsHook.rely(address(report.core.spoke));
// Rely vaultRegistry
report.asyncVaultFactory.rely(address(report.core.vaultRegistry));
report.syncDepositVaultFactory.rely(address(report.core.vaultRegistry));
// Rely contractUpdater
report.syncManager.rely(address(report.core.contractUpdater));
report.asyncRequestManager.rely(address(report.core.contractUpdater));
// Rely protocolGuardian
report.core.gateway.rely(address(report.protocolGuardian));
report.core.multiAdapter.rely(address(report.protocolGuardian));
report.core.messageDispatcher.rely(address(report.protocolGuardian));
report.root.rely(address(report.protocolGuardian));
report.tokenRecoverer.rely(address(report.protocolGuardian));
report.tokenBridge.rely(address(report.protocolGuardian));
// Permanent ward for ongoing adapter maintenance
_relyAdapters(report, address(report.protocolGuardian));
// Rely opsGuardian
report.core.multiAdapter.rely(address(report.opsGuardian));
report.core.hub.rely(address(report.opsGuardian));
// Temporal ward for initial adapter wiring
_relyAdapters(report, address(report.opsGuardian));
// Rely tokenRecoverer
report.root.rely(address(report.tokenRecoverer));
// Rely messageDispatcher
report.root.rely(address(report.core.messageDispatcher));
report.tokenRecoverer.rely(address(report.core.messageDispatcher));
// Rely messageProcessor
report.root.rely(address(report.core.messageProcessor));
report.tokenRecoverer.rely(address(report.core.messageProcessor));
// Rely hub
report.batchRequestManager.rely(address(report.core.hub));
// Rely hubHandler
report.batchRequestManager.rely(address(report.core.hubHandler));
// Rely subsidyManager
report.refundEscrowFactory.rely(address(report.subsidyManager));
// Rely asyncRequestManager
report.subsidyManager.rely(address(report.asyncRequestManager));
// Rely asyncVaultFactory
report.asyncRequestManager.rely(address(report.asyncVaultFactory));
// Rely syncDepositVaultFactory
report.syncManager.rely(address(report.syncDepositVaultFactory));
report.asyncRequestManager.rely(address(report.syncDepositVaultFactory));
// Rely adminSafe
if (address(report.layerZeroAdapter) != address(0)) {
// Needed for setDelegate calls
report.layerZeroAdapter.rely(address(adminSafe));
}
// File methods
report.core.messageDispatcher.file("tokenRecoverer", address(report.tokenRecoverer));
report.core.messageProcessor.file("tokenRecoverer", address(report.tokenRecoverer));
report.opsGuardian.file("opsSafe", address(opsSafe));
report.protocolGuardian.file("safe", address(adminSafe));
report.refundEscrowFactory.file(bytes32("controller"), address(report.subsidyManager));
report.asyncRequestManager.file("spoke", address(report.core.spoke));
report.asyncRequestManager.file("balanceSheet", address(report.core.balanceSheet));
report.asyncRequestManager.file("vaultRegistry", address(report.core.vaultRegistry));
report.syncManager.file("spoke", address(report.core.spoke));
report.syncManager.file("balanceSheet", address(report.core.balanceSheet));
report.syncManager.file("vaultRegistry", address(report.core.vaultRegistry));
report.batchRequestManager.file("hub", address(report.core.hub));
// Endorse methods
report.root.endorse(address(report.core.balanceSheet));
report.root.endorse(address(report.asyncRequestManager));
report.root.endorse(address(report.vaultRouter));
report.root.endorse(address(report.tokenBridge));
// Connect adapters
for (uint256 i; i < connectionList.length; i++) {
AdapterConnections memory connections = connectionList[i];
uint256 n;
IAdapter[] memory adapters = new IAdapter[](MAX_ADAPTER_COUNT);
if (address(report.layerZeroAdapter) != address(0) && connections.layerZeroId != 0) {
report.layerZeroAdapter
.wire(connections.centrifugeId, abi.encode(connections.layerZeroId, report.layerZeroAdapter));
adapters[n++] = report.layerZeroAdapter;
if (connections.layerZeroConfigParams.length > 0) {
_setLayerZeroUlnConfig(
report.layerZeroAdapter, connections.layerZeroId, connections.layerZeroConfigParams
);
}
}
if (address(report.wormholeAdapter) != address(0) && connections.wormholeId != 0) {
report.wormholeAdapter
.wire(connections.centrifugeId, abi.encode(connections.wormholeId, report.wormholeAdapter));
adapters[n++] = report.wormholeAdapter;
}
if (address(report.axelarAdapter) != address(0) && bytes(connections.axelarId).length != 0) {
report.axelarAdapter
.wire(connections.centrifugeId, abi.encode(connections.axelarId, remoteAxelarAdapter));
adapters[n++] = report.axelarAdapter;
}
if (address(report.chainlinkAdapter) != address(0) && connections.chainlinkId != 0) {
report.chainlinkAdapter
.wire(connections.centrifugeId, abi.encode(connections.chainlinkId, report.chainlinkAdapter));
adapters[n++] = report.chainlinkAdapter;
}
if (n > 0) {
assembly { mstore(adapters, n) }
report.core.multiAdapter
.setAdapters(
connections.centrifugeId,
PoolId.wrap(0),
adapters,
connections.threshold > 0 ? connections.threshold : uint8(adapters.length),
uint8(adapters.length)
);
}
}
if (address(report.layerZeroAdapter) != address(0)) {
// Set delegate to the right address after setting the ULN config
report.layerZeroAdapter.setDelegate(layerZeroDelegate);
}
}
function revokeFull(FullReport memory report) public onlyDeployer {
if (report.root.wards(address(this)) == 1) report.root.deny(address(this));
report.tokenRecoverer.deny(address(this));
report.tokenBridge.deny(address(this));
report.refundEscrowFactory.deny(address(this));
report.asyncVaultFactory.deny(address(this));
report.asyncRequestManager.deny(address(this));
report.syncDepositVaultFactory.deny(address(this));
report.syncManager.deny(address(this));
report.vaultRouter.deny(address(this));
report.subsidyManager.deny(address(this));
report.freezeOnlyHook.deny(address(this));
report.fullRestrictionsHook.deny(address(this));
report.freelyTransferableHook.deny(address(this));
report.redemptionRestrictionsHook.deny(address(this));
report.batchRequestManager.deny(address(this));
if (address(report.wormholeAdapter) != address(0)) report.wormholeAdapter.deny(address(this));
if (address(report.axelarAdapter) != address(0)) report.axelarAdapter.deny(address(this));
if (address(report.layerZeroAdapter) != address(0)) report.layerZeroAdapter.deny(address(this));
if (address(report.chainlinkAdapter) != address(0)) report.chainlinkAdapter.deny(address(this));
}
/// @dev helper function to save some bytes
function _relyAdapters(FullReport memory report, address ward) internal {
if (address(report.layerZeroAdapter) != address(0)) report.layerZeroAdapter.rely(ward);
if (address(report.wormholeAdapter) != address(0)) report.wormholeAdapter.rely(ward);
if (address(report.axelarAdapter) != address(0)) report.axelarAdapter.rely(ward);
if (address(report.chainlinkAdapter) != address(0)) report.chainlinkAdapter.rely(ward);
}
function _setLayerZeroUlnConfig(LayerZeroAdapter adapter, uint32 eid, SetConfigParam[] memory params) internal {
ILayerZeroEndpointV2Like endpoint = ILayerZeroEndpointV2Like(address(adapter.endpoint()));
address oapp = address(adapter);
address sendLib = endpoint.defaultSendLibrary(eid);
address recvLib = endpoint.defaultReceiveLibrary(eid);
// Set send and receive libraries
// Because we set the config on these libraries, we need to set them explicitly
// Even though they are the default ones, as the defaults may change
endpoint.setSendLibrary(oapp, eid, sendLib);
endpoint.setReceiveLibrary(oapp, eid, recvLib, 0);
endpoint.setConfig(oapp, sendLib, params);
endpoint.setConfig(oapp, recvLib, params);
}
}
contract FullDeployer is CoreDeployer {
uint256 public constant DELAY = 48 hours;
ISafe public adminSafe;
ISafe public opsSafe;
Root public root;
TokenRecoverer public tokenRecoverer;
ProtocolGuardian public protocolGuardian;
OpsGuardian public opsGuardian;
TokenBridge public tokenBridge;
SubsidyManager public subsidyManager;
RefundEscrowFactory public refundEscrowFactory;
AsyncVaultFactory public asyncVaultFactory;
AsyncRequestManager public asyncRequestManager;
SyncDepositVaultFactory public syncDepositVaultFactory;
SyncManager public syncManager;
VaultRouter public vaultRouter;
FreezeOnly public freezeOnlyHook;
FullRestrictions public fullRestrictionsHook;
FreelyTransferable public freelyTransferableHook;
RedemptionRestrictions public redemptionRestrictionsHook;
QueueManager public queueManager;
OnOfframpManagerFactory public onOfframpManagerFactory;
MerkleProofManagerFactory public merkleProofManagerFactory;
VaultDecoder public vaultDecoder;
CircleDecoder public circleDecoder;
BatchRequestManager public batchRequestManager;
IdentityValuation public identityValuation;
OracleValuation public oracleValuation;
NAVManager public navManager;
SimplePriceManager public simplePriceManager;
ChainlinkAdapter chainlinkAdapter;
AxelarAdapter axelarAdapter;
WormholeAdapter wormholeAdapter;
LayerZeroAdapter layerZeroAdapter;
function deployFull(FullInput memory input, FullActionBatcher batcher) public {
_init(input.core.version, batcher.deployer());
adminSafe = input.adminSafe;
opsSafe = input.opsSafe;
root =
Root(create3(generateSalt("root"), abi.encodePacked(type(Root).creationCode, abi.encode(DELAY, batcher))));
deployCore(input.core, batcher, address(root));
tokenRecoverer = TokenRecoverer(
create3(
generateSalt("tokenRecoverer"),
abi.encodePacked(type(TokenRecoverer).creationCode, abi.encode(root, batcher))
)
);
tokenBridge = TokenBridge(
create3(
generateSalt("tokenBridge"),
abi.encodePacked(type(TokenBridge).creationCode, abi.encode(spoke, batcher))
)
);
protocolGuardian = ProtocolGuardian(
create3(
generateSalt("protocolGuardian"),
abi.encodePacked(
type(ProtocolGuardian).creationCode,
abi.encode(ISafe(address(batcher)), root, gateway, messageDispatcher, tokenBridge)
)
)
);
opsGuardian = OpsGuardian(
create3(
generateSalt("opsGuardian"),
abi.encodePacked(type(OpsGuardian).creationCode, abi.encode(ISafe(address(batcher)), hub, multiAdapter))
)
);
refundEscrowFactory = RefundEscrowFactory(
create3(
generateSalt("refundEscrowFactory"),
abi.encodePacked(type(RefundEscrowFactory).creationCode, abi.encode(batcher))
)
);
subsidyManager = SubsidyManager(
create3(
generateSalt("subsidyManager"),
abi.encodePacked(type(SubsidyManager).creationCode, abi.encode(refundEscrowFactory, batcher))
)
);
asyncRequestManager = AsyncRequestManager(
payable(create3(
generateSalt("asyncRequestManager"),
abi.encodePacked(type(AsyncRequestManager).creationCode, abi.encode(subsidyManager, batcher))
))
);
syncManager = SyncManager(
create3(generateSalt("syncManager"), abi.encodePacked(type(SyncManager).creationCode, abi.encode(batcher)))
);
vaultRouter = VaultRouter(
create3(
generateSalt("vaultRouter"),
abi.encodePacked(type(VaultRouter).creationCode, abi.encode(gateway, spoke, vaultRegistry, batcher))
)
);
asyncVaultFactory = AsyncVaultFactory(
create3(
generateSalt("asyncVaultFactory"),
abi.encodePacked(
type(AsyncVaultFactory).creationCode, abi.encode(address(root), asyncRequestManager, batcher)
)
)
);
syncDepositVaultFactory = SyncDepositVaultFactory(
create3(
generateSalt("syncDepositVaultFactory"),
abi.encodePacked(
type(SyncDepositVaultFactory).creationCode,
abi.encode(address(root), syncManager, asyncRequestManager, batcher)
)
)
);
freezeOnlyHook = FreezeOnly(
create3(
generateSalt("freezeOnlyHook"),
abi.encodePacked(
type(FreezeOnly).creationCode,
abi.encode(
address(root),
address(spoke),
address(balanceSheet),
address(spoke),
batcher,
address(poolEscrowFactory),
address(0)
)
)
)
);
fullRestrictionsHook = FullRestrictions(
create3(
generateSalt("fullRestrictionsHook"),
abi.encodePacked(
type(FullRestrictions).creationCode,
abi.encode(
address(root),
address(spoke),
address(balanceSheet),
address(spoke),
batcher,
address(poolEscrowFactory),
address(0)
)
)
)
);
freelyTransferableHook = FreelyTransferable(
create3(
generateSalt("freelyTransferableHook"),
abi.encodePacked(
type(FreelyTransferable).creationCode,
abi.encode(
address(root),
address(spoke),
address(balanceSheet),
address(spoke),
batcher,
address(poolEscrowFactory),
address(0)
)
)
)
);
redemptionRestrictionsHook = RedemptionRestrictions(
create3(
generateSalt("redemptionRestrictionsHook"),
abi.encodePacked(
type(RedemptionRestrictions).creationCode,
abi.encode(
address(root),
address(spoke),
address(balanceSheet),
address(spoke),
batcher,
address(poolEscrowFactory),
address(0)
)
)
)
);
queueManager = QueueManager(
create3(
generateSalt("queueManager"),
abi.encodePacked(
type(QueueManager).creationCode, abi.encode(contractUpdater, balanceSheet, address(batcher))
)
)
);
onOfframpManagerFactory = OnOfframpManagerFactory(
create3(
generateSalt("onOfframpManagerFactory"),
abi.encodePacked(type(OnOfframpManagerFactory).creationCode, abi.encode(contractUpdater, balanceSheet))
)
);
merkleProofManagerFactory = MerkleProofManagerFactory(
create3(
generateSalt("merkleProofManagerFactory"),
abi.encodePacked(
type(MerkleProofManagerFactory).creationCode, abi.encode(contractUpdater, balanceSheet)
)
)
);
vaultDecoder =
VaultDecoder(create3(generateSalt("vaultDecoder"), abi.encodePacked(type(VaultDecoder).creationCode)));
circleDecoder =
CircleDecoder(create3(generateSalt("circleDecoder"), abi.encodePacked(type(CircleDecoder).creationCode)));
batchRequestManager = BatchRequestManager(
create3(
generateSalt("batchRequestManager"),
abi.encodePacked(type(BatchRequestManager).creationCode, abi.encode(hubRegistry, gateway, batcher))
)
);
identityValuation = IdentityValuation(
create3(
generateSalt("identityValuation"),
abi.encodePacked(type(IdentityValuation).creationCode, abi.encode(hubRegistry))
)
);
oracleValuation = OracleValuation(
create3(
generateSalt("oracleValuation"),
abi.encodePacked(type(OracleValuation).creationCode, abi.encode(hub, hubRegistry))
)
);
navManager = NAVManager(
create3(generateSalt("navManager"), abi.encodePacked(type(NAVManager).creationCode, abi.encode(hub)))
);
simplePriceManager = SimplePriceManager(
create3(
generateSalt("simplePriceManager"),
abi.encodePacked(type(SimplePriceManager).creationCode, abi.encode(hub, address(navManager)))
)
);
if (input.adapters.layerZero.shouldDeploy) {
require(input.adapters.layerZero.endpoint != address(0), "LayerZero endpoint address cannot be zero");
require(input.adapters.layerZero.endpoint.code.length > 0, "LayerZero endpoint must be a deployed contract");
require(input.adapters.layerZero.delegate != address(0), "LayerZero delegate address cannot be zero");
layerZeroAdapter = LayerZeroAdapter(
create3(
generateSalt("layerZeroAdapter"),
abi.encodePacked(
type(LayerZeroAdapter).creationCode,
// Set delegate to batcher initially, to be able to set ULN config
abi.encode(multiAdapter, input.adapters.layerZero.endpoint, batcher, batcher)
)
)
);
}
if (input.adapters.wormhole.shouldDeploy) {
require(input.adapters.wormhole.relayer != address(0), "Wormhole relayer address cannot be zero");
require(input.adapters.wormhole.relayer.code.length > 0, "Wormhole relayer must be a deployed contract");
wormholeAdapter = WormholeAdapter(
create3(
generateSalt("wormholeAdapter"),
abi.encodePacked(
type(WormholeAdapter).creationCode,
abi.encode(multiAdapter, input.adapters.wormhole.relayer, batcher)
)
)
);
}
if (input.adapters.axelar.shouldDeploy) {
require(input.adapters.axelar.gateway != address(0), "Axelar gateway address cannot be zero");
require(input.adapters.axelar.gasService != address(0), "Axelar gas service address cannot be zero");
require(input.adapters.axelar.gateway.code.length > 0, "Axelar gateway must be a deployed contract");
require(input.adapters.axelar.gasService.code.length > 0, "Axelar gas service must be a deployed contract");
axelarAdapter = AxelarAdapter(
create3(
generateSalt("axelarAdapter"),
abi.encodePacked(
type(AxelarAdapter).creationCode,
abi.encode(
multiAdapter, input.adapters.axelar.gateway, input.adapters.axelar.gasService, batcher
)
)
)
);
}
if (input.adapters.chainlink.shouldDeploy) {
require(input.adapters.chainlink.ccipRouter != address(0), "Chainlink ccipRouter address cannot be zero");
require(
input.adapters.chainlink.ccipRouter.code.length > 0, "Chainlink ccipRouter must be a deployed contract"
);
chainlinkAdapter = ChainlinkAdapter(
create3(
generateSalt("chainlinkAdapter"),
abi.encodePacked(
type(ChainlinkAdapter).creationCode,
abi.encode(multiAdapter, input.adapters.chainlink.ccipRouter, batcher)
)
)
);
}
register("root", address(root));
register("tokenRecoverer", address(tokenRecoverer));
register("protocolGuardian", address(protocolGuardian));
register("opsGuardian", address(opsGuardian));
register("tokenBridge", address(tokenBridge));
register("refundEscrowFactory", address(refundEscrowFactory));
register("subsidyManager", address(subsidyManager));
register("asyncVaultFactory", address(asyncVaultFactory));
register("asyncRequestManager", address(asyncRequestManager));
register("syncDepositVaultFactory", address(syncDepositVaultFactory));
register("syncManager", address(syncManager));
register("vaultRouter", address(vaultRouter));
register("freezeOnlyHook", address(freezeOnlyHook));
register("fullRestrictionsHook", address(fullRestrictionsHook));
register("freelyTransferableHook", address(freelyTransferableHook));
register("redemptionRestrictionsHook", address(redemptionRestrictionsHook));
register("queueManager", address(queueManager));
register("onOfframpManagerFactory", address(onOfframpManagerFactory));
register("merkleProofManagerFactory", address(merkleProofManagerFactory));
register("vaultDecoder", address(vaultDecoder));
register("circleDecoder", address(circleDecoder));
register("batchRequestManager", address(batchRequestManager));
register("identityValuation", address(identityValuation));
register("oracleValuation", address(oracleValuation));
register("navManager", address(navManager));
register("simplePriceManager", address(simplePriceManager));
if (input.adapters.wormhole.shouldDeploy) register("wormholeAdapter", address(wormholeAdapter));
if (input.adapters.axelar.shouldDeploy) register("axelarAdapter", address(axelarAdapter));
if (input.adapters.layerZero.shouldDeploy) register("layerZeroAdapter", address(layerZeroAdapter));
if (input.adapters.chainlink.shouldDeploy) register("chainlinkAdapter", address(chainlinkAdapter));
batcher.engageFull(
fullReport(),
input.adminSafe,
input.opsSafe,
input.adapters.connections,
vm.toString(address(axelarAdapter)),
input.adapters.layerZero.delegate
);
}
function fullReport() public view returns (FullReport memory) {
return FullReport(
coreReport(),
root,
tokenRecoverer,
protocolGuardian,
opsGuardian,
tokenBridge,
subsidyManager,
refundEscrowFactory,
asyncVaultFactory,
asyncRequestManager,
syncDepositVaultFactory,
syncManager,
vaultRouter,
freezeOnlyHook,
fullRestrictionsHook,
freelyTransferableHook,
redemptionRestrictionsHook,
queueManager,
onOfframpManagerFactory,
merkleProofManagerFactory,
vaultDecoder,
circleDecoder,
batchRequestManager,
identityValuation,
oracleValuation,
navManager,
simplePriceManager,
layerZeroAdapter,
wormholeAdapter,
axelarAdapter,
chainlinkAdapter
);
}
function removeFullDeployerAccess(FullActionBatcher batcher) public {
removeCoreDeployerAccess(batcher);
batcher.revokeFull(fullReport());
}
}
function noAdaptersInput() pure returns (AdaptersInput memory) {
return AdaptersInput({
wormhole: WormholeInput({shouldDeploy: false, relayer: address(0)}),
axelar: AxelarInput({shouldDeploy: false, gateway: address(0), gasService: address(0)}),
layerZero: LayerZeroInput({shouldDeploy: false, endpoint: address(0), delegate: address(0)}),
chainlink: ChainlinkInput({shouldDeploy: false, ccipRouter: address(0)}),
connections: new AdapterConnections[](0)
});
}
function defaultTxLimits() pure returns (uint8[32] memory) {}