-
Notifications
You must be signed in to change notification settings - Fork 83
/
Copy pathdeployActions.js
1661 lines (1447 loc) · 52.5 KB
/
deployActions.js
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
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
const hre = require("hardhat");
const addresses = require("../utils/addresses");
const {
getAssetAddresses,
getOracleAddresses,
isMainnet,
isHolesky,
isHoleskyOrFork,
isSonicOrFork,
isTest,
} = require("../test/helpers.js");
const { deployWithConfirmation, withConfirmation } = require("../utils/deploy");
const {
metapoolLPCRVPid,
lusdMetapoolLPCRVPid,
} = require("../utils/constants");
const log = require("../utils/logger")("deploy:core");
/**
* Deploy AAVE Strategy which only supports DAI.
* Deploys a proxy, the actual strategy, initializes the proxy and initializes
* the strategy.
*/
const deployAaveStrategy = async () => {
const assetAddresses = await getAssetAddresses(hre.deployments);
const { governorAddr } = await getNamedAccounts();
const cVaultProxy = await ethers.getContract("VaultProxy");
const dAaveStrategyProxy = await deployWithConfirmation(
"AaveStrategyProxy",
[],
"InitializeGovernedUpgradeabilityProxy"
);
const cAaveStrategyProxy = await ethers.getContract("AaveStrategyProxy");
const dAaveStrategy = await deployWithConfirmation("AaveStrategy", [
[assetAddresses.AAVE_ADDRESS_PROVIDER, cVaultProxy.address],
]);
const cAaveStrategy = await ethers.getContractAt(
"AaveStrategy",
dAaveStrategyProxy.address
);
const cAaveIncentivesController = await ethers.getContract(
"MockAaveIncentivesController"
);
const initData = cAaveStrategy.interface.encodeFunctionData(
"initialize(address[],address[],address[],address,address)",
[
[assetAddresses.AAVE_TOKEN],
[assetAddresses.DAI],
[assetAddresses.aDAI],
cAaveIncentivesController.address,
assetAddresses.STKAAVE,
]
);
await withConfirmation(
cAaveStrategyProxy["initialize(address,address,bytes)"](
dAaveStrategy.address,
governorAddr,
initData
)
);
log("Initialized AaveStrategyProxy");
return cAaveStrategy;
};
/**
* Deploy Compound Strategy which only supports DAI.
* Deploys a proxy, the actual strategy, initializes the proxy and initializes
* the strategy.
*/
const deployCompoundStrategy = async () => {
const assetAddresses = await getAssetAddresses(deployments);
const { governorAddr } = await getNamedAccounts();
const cVaultProxy = await ethers.getContract("VaultProxy");
const dCompoundStrategyProxy = await deployWithConfirmation(
"CompoundStrategyProxy"
);
const cCompoundStrategyProxy = await ethers.getContract(
"CompoundStrategyProxy"
);
const dCompoundStrategy = await deployWithConfirmation("CompoundStrategy", [
[addresses.dead, cVaultProxy.address],
]);
const cCompoundStrategy = await ethers.getContractAt(
"CompoundStrategy",
dCompoundStrategyProxy.address
);
const initData = cCompoundStrategy.interface.encodeFunctionData(
"initialize(address[],address[],address[])",
[[assetAddresses.COMP], [assetAddresses.DAI], [assetAddresses.cDAI]]
);
await withConfirmation(
cCompoundStrategyProxy["initialize(address,address,bytes)"](
dCompoundStrategy.address,
governorAddr,
initData
)
);
return cCompoundStrategy;
};
/**
* Deploys a 3pool Strategy which supports USDC, USDT and DAI.
* Deploys a proxy, the actual strategy, initializes the proxy and initializes
*/
const deployThreePoolStrategy = async () => {
const assetAddresses = await getAssetAddresses(deployments);
const { deployerAddr, governorAddr } = await getNamedAccounts();
// Signers
const sDeployer = await ethers.provider.getSigner(deployerAddr);
const sGovernor = await ethers.provider.getSigner(governorAddr);
// Initialize Strategies
const cVaultProxy = await ethers.getContract("VaultProxy");
await deployWithConfirmation("ThreePoolStrategyProxy");
const cThreePoolStrategyProxy = await ethers.getContract(
"ThreePoolStrategyProxy"
);
const dThreePoolStrategy = await deployWithConfirmation("ThreePoolStrategy", [
[assetAddresses.ThreePool, cVaultProxy.address],
]);
const cThreePoolStrategy = await ethers.getContractAt(
"ThreePoolStrategy",
cThreePoolStrategyProxy.address
);
await withConfirmation(
cThreePoolStrategyProxy["initialize(address,address,bytes)"](
dThreePoolStrategy.address,
deployerAddr,
[]
)
);
log("Initialized ThreePoolStrategyProxy");
await withConfirmation(
cThreePoolStrategy.connect(sDeployer)[
// eslint-disable-next-line no-unexpected-multiline
"initialize(address[],address[],address[],address,address)"
]([assetAddresses.CRV], [assetAddresses.DAI, assetAddresses.USDC, assetAddresses.USDT], [assetAddresses.ThreePoolToken, assetAddresses.ThreePoolToken, assetAddresses.ThreePoolToken], assetAddresses.ThreePoolGauge, assetAddresses.CRVMinter)
);
log("Initialized ThreePoolStrategy");
await withConfirmation(
cThreePoolStrategy.connect(sDeployer).transferGovernance(governorAddr)
);
log(`ThreePoolStrategy transferGovernance(${governorAddr}) called`);
// On Mainnet the governance transfer gets executed separately, via the
// multi-sig wallet. On other networks, this migration script can claim
// governance by the governor.
if (!isMainnet) {
await withConfirmation(
cThreePoolStrategy
.connect(sGovernor) // Claim governance with governor
.claimGovernance()
);
log("Claimed governance for ThreePoolStrategy");
}
return cThreePoolStrategy;
};
/**
* Deploys a Convex Strategy which supports USDC, USDT and DAI.
*/
const deployConvexStrategy = async () => {
const assetAddresses = await getAssetAddresses(deployments);
const { deployerAddr, governorAddr } = await getNamedAccounts();
// Signers
const sDeployer = await ethers.provider.getSigner(deployerAddr);
const sGovernor = await ethers.provider.getSigner(governorAddr);
const cVaultProxy = await ethers.getContract("VaultProxy");
await deployWithConfirmation("ConvexStrategyProxy");
const cConvexStrategyProxy = await ethers.getContract("ConvexStrategyProxy");
const dConvexStrategy = await deployWithConfirmation("ConvexStrategy", [
[assetAddresses.ThreePool, cVaultProxy.address],
]);
const cConvexStrategy = await ethers.getContractAt(
"ConvexStrategy",
cConvexStrategyProxy.address
);
await withConfirmation(
cConvexStrategyProxy["initialize(address,address,bytes)"](
dConvexStrategy.address,
deployerAddr,
[]
)
);
log("Initialized ConvexStrategyProxy");
// Initialize Strategies
const mockBooster = await ethers.getContract("MockBooster");
const mockRewardPool = await ethers.getContract("MockRewardPool");
await withConfirmation(
cConvexStrategy.connect(sDeployer)[
// eslint-disable-next-line no-unexpected-multiline
"initialize(address[],address[],address[],address,address,uint256)"
](
[assetAddresses.CRV, assetAddresses.CVX],
[assetAddresses.DAI, assetAddresses.USDC, assetAddresses.USDT],
[
assetAddresses.ThreePoolToken,
assetAddresses.ThreePoolToken,
assetAddresses.ThreePoolToken,
],
mockBooster.address, // _cvxDepositorAddress,
mockRewardPool.address, // _cvxRewardStakerAddress,
9 // _cvxDepositorPTokenId
)
);
log("Initialized ConvexStrategy");
await withConfirmation(
cConvexStrategy.connect(sDeployer).transferGovernance(governorAddr)
);
log(`ConvexStrategy transferGovernance(${governorAddr}) called`);
// On Mainnet the governance transfer gets executed separately, via the
// multi-sig wallet. On other networks, this migration script can claim
// governance by the governor.
if (!isMainnet) {
await withConfirmation(
cConvexStrategy
.connect(sGovernor) // Claim governance with governor
.claimGovernance()
);
log("Claimed governance for ConvexStrategy");
}
return cConvexStrategy;
};
/**
* Deploys a Convex Generalized Meta Strategy with LUSD token configuration
*/
const deployConvexLUSDMetaStrategy = async () => {
const assetAddresses = await getAssetAddresses(deployments);
const { deployerAddr, governorAddr } = await getNamedAccounts();
// Signers
const sDeployer = await ethers.provider.getSigner(deployerAddr);
const sGovernor = await ethers.provider.getSigner(governorAddr);
const cVaultProxy = await ethers.getContract("VaultProxy");
await deployWithConfirmation("ConvexLUSDMetaStrategyProxy");
const cConvexLUSDMetaStrategyProxy = await ethers.getContract(
"ConvexLUSDMetaStrategyProxy"
);
const dConvexLUSDMetaStrategy = await deployWithConfirmation(
"ConvexGeneralizedMetaStrategy",
[[assetAddresses.ThreePool, cVaultProxy.address]]
);
const cConvexLUSDMetaStrategy = await ethers.getContractAt(
"ConvexGeneralizedMetaStrategy",
cConvexLUSDMetaStrategyProxy.address
);
await withConfirmation(
cConvexLUSDMetaStrategyProxy["initialize(address,address,bytes)"](
dConvexLUSDMetaStrategy.address,
deployerAddr,
[]
)
);
log("Initialized ConvexLUSDMetaStrategyProxy");
// Initialize Strategies
const mockBooster = await ethers.getContract("MockBooster");
const mockRewardPool = await ethers.getContract("MockRewardPool");
const LUSD = await ethers.getContract("MockLUSD");
await withConfirmation(
cConvexLUSDMetaStrategy.connect(sDeployer)[
// eslint-disable-next-line no-unexpected-multiline
"initialize(address[],address[],address[],(address,address,address,address,address,uint256))"
](
[assetAddresses.CVX, assetAddresses.CRV],
[assetAddresses.DAI, assetAddresses.USDC, assetAddresses.USDT],
[
assetAddresses.ThreePoolToken,
assetAddresses.ThreePoolToken,
assetAddresses.ThreePoolToken,
],
[
mockBooster.address, // _cvxDepositorAddress,
assetAddresses.ThreePoolLUSDMetapool, // metapool address,
LUSD.address, // LUSD
mockRewardPool.address, // _cvxRewardStakerAddress,
assetAddresses.LUSDMetapoolToken, // metapoolLpToken
lusdMetapoolLPCRVPid, // _cvxDepositorPTokenId
]
)
);
log("Initialized ConvexLUSDMetaStrategy");
await withConfirmation(
cConvexLUSDMetaStrategy.connect(sDeployer).transferGovernance(governorAddr)
);
log(`ConvexLUSDMetaStrategy transferGovernance(${governorAddr}) called`);
// On Mainnet the governance transfer gets executed separately, via the
// multi-sig wallet. On other networks, this migration script can claim
// governance by the governor.
if (!isMainnet) {
await withConfirmation(
cConvexLUSDMetaStrategy
.connect(sGovernor) // Claim governance with governor
.claimGovernance()
);
log("Claimed governance for ConvexLUSDMetaStrategy");
}
return cConvexLUSDMetaStrategy;
};
/**
* Deploys a Convex Meta Strategy which supports OUSD / 3Crv
*/
const deployConvexOUSDMetaStrategy = async () => {
const assetAddresses = await getAssetAddresses(deployments);
const { deployerAddr, governorAddr } = await getNamedAccounts();
// Signers
const sDeployer = await ethers.provider.getSigner(deployerAddr);
const sGovernor = await ethers.provider.getSigner(governorAddr);
const cVaultProxy = await ethers.getContract("VaultProxy");
await deployWithConfirmation("ConvexOUSDMetaStrategyProxy");
const cConvexOUSDMetaStrategyProxy = await ethers.getContract(
"ConvexOUSDMetaStrategyProxy"
);
const dConvexOUSDMetaStrategy = await deployWithConfirmation(
"ConvexOUSDMetaStrategy",
[[assetAddresses.ThreePool, cVaultProxy.address]]
);
const cConvexOUSDMetaStrategy = await ethers.getContractAt(
"ConvexOUSDMetaStrategy",
cConvexOUSDMetaStrategyProxy.address
);
await withConfirmation(
cConvexOUSDMetaStrategyProxy["initialize(address,address,bytes)"](
dConvexOUSDMetaStrategy.address,
deployerAddr,
[]
)
);
log("Initialized ConvexOUSDMetaStrategyProxy");
// Initialize Strategies
const mockBooster = await ethers.getContract("MockBooster");
const mockRewardPool = await ethers.getContract("MockRewardPool");
const ousd = await ethers.getContract("OUSDProxy");
await withConfirmation(
cConvexOUSDMetaStrategy.connect(sDeployer)[
// eslint-disable-next-line no-unexpected-multiline
"initialize(address[],address[],address[],(address,address,address,address,address,uint256))"
](
[assetAddresses.CVX, assetAddresses.CRV],
[assetAddresses.DAI, assetAddresses.USDC, assetAddresses.USDT],
[
assetAddresses.ThreePoolToken,
assetAddresses.ThreePoolToken,
assetAddresses.ThreePoolToken,
],
[
mockBooster.address, // _cvxDepositorAddress,
assetAddresses.ThreePoolOUSDMetapool, // metapool address,
ousd.address, // _ousdAddress,
mockRewardPool.address, // _cvxRewardStakerAddress,
assetAddresses.ThreePoolOUSDMetapool, // metapoolLpToken (metapool address),
metapoolLPCRVPid, // _cvxDepositorPTokenId
]
)
);
log("Initialized ConvexOUSDMetaStrategy");
await withConfirmation(
cConvexOUSDMetaStrategy.connect(sDeployer).transferGovernance(governorAddr)
);
log(`ConvexOUSDMetaStrategy transferGovernance(${governorAddr}) called`);
// On Mainnet the governance transfer gets executed separately, via the
// multi-sig wallet. On other networks, this migration script can claim
// governance by the governor.
if (!isMainnet) {
await withConfirmation(
cConvexOUSDMetaStrategy
.connect(sGovernor) // Claim governance with governor
.claimGovernance()
);
log("Claimed governance for ConvexOUSDMetaStrategy");
}
return cConvexOUSDMetaStrategy;
};
/**
* Configure Vault by adding supported assets and Strategies.
*/
const configureVault = async () => {
const assetAddresses = await getAssetAddresses(deployments);
const { governorAddr, strategistAddr } = await getNamedAccounts();
// Signers
const sGovernor = await ethers.provider.getSigner(governorAddr);
const cVault = await ethers.getContractAt(
"VaultAdmin",
(
await ethers.getContract("VaultProxy")
).address
);
// Set up supported assets for Vault
await withConfirmation(
cVault.connect(sGovernor).supportAsset(assetAddresses.DAI, 0)
);
log("Added DAI asset to Vault");
await withConfirmation(
cVault.connect(sGovernor).supportAsset(assetAddresses.USDT, 0)
);
log("Added USDT asset to Vault");
await withConfirmation(
cVault.connect(sGovernor).supportAsset(assetAddresses.USDC, 0)
);
log("Added USDC asset to Vault");
// Unpause deposits
await withConfirmation(cVault.connect(sGovernor).unpauseCapital());
log("Unpaused deposits on Vault");
// Set Strategist address.
await withConfirmation(
cVault.connect(sGovernor).setStrategistAddr(strategistAddr)
);
};
/**
* Configure OETH Vault by adding supported assets and Strategies.
*/
const configureOETHVault = async (isSimpleOETH) => {
const assetAddresses = await getAssetAddresses(deployments);
const { governorAddr, strategistAddr } = await getNamedAccounts();
// Signers
const sGovernor = await ethers.provider.getSigner(governorAddr);
const cVault = await ethers.getContractAt(
"IVault",
(
await ethers.getContract("OETHVaultProxy")
).address
);
// Set up supported assets for Vault
const { WETH, RETH, stETH, frxETH } = assetAddresses;
const assets = isSimpleOETH ? [WETH] : [WETH, RETH, stETH, frxETH];
for (const asset of assets) {
await withConfirmation(cVault.connect(sGovernor).supportAsset(asset, 0));
}
log("Added assets to OETH Vault");
// Unpause deposits
await withConfirmation(cVault.connect(sGovernor).unpauseCapital());
log("Unpaused deposits on OETH Vault");
// Set Strategist address.
await withConfirmation(
cVault.connect(sGovernor).setStrategistAddr(strategistAddr)
);
// Cache WETH asset address
await withConfirmation(cVault.connect(sGovernor).cacheWETHAssetIndex());
// Redeem fee to 0
await withConfirmation(cVault.connect(sGovernor).setRedeemFeeBps(0));
// Allocate threshold
await withConfirmation(
cVault
.connect(sGovernor)
.setAutoAllocateThreshold(ethers.utils.parseUnits("25", 18))
);
// Rebase threshold
await withConfirmation(
cVault
.connect(sGovernor)
.setAutoAllocateThreshold(ethers.utils.parseUnits("5", 18))
);
// Set withdrawal claim delay to 10m
await withConfirmation(
cVault.connect(sGovernor).setWithdrawalClaimDelay(10 * 60)
);
};
const deployOUSDHarvester = async (ousdDripper) => {
const assetAddresses = await getAssetAddresses(deployments);
const { governorAddr } = await getNamedAccounts();
const sGovernor = await ethers.provider.getSigner(governorAddr);
const cVaultProxy = await ethers.getContract("VaultProxy");
const dHarvesterProxy = await deployWithConfirmation(
"HarvesterProxy",
[],
"InitializeGovernedUpgradeabilityProxy"
);
const cHarvesterProxy = await ethers.getContract("HarvesterProxy");
const dHarvester = await deployWithConfirmation("Harvester", [
cVaultProxy.address,
assetAddresses.USDT,
]);
const cHarvester = await ethers.getContractAt(
"Harvester",
dHarvesterProxy.address
);
await withConfirmation(
cHarvesterProxy["initialize(address,address,bytes)"](
dHarvester.address,
governorAddr,
[]
)
);
log("Initialized HarvesterProxy");
await withConfirmation(
cHarvester
.connect(sGovernor)
.setRewardProceedsAddress(
isMainnet || isHolesky ? ousdDripper.address : cVaultProxy.address
)
);
return dHarvesterProxy;
};
const upgradeOETHHarvester = async () => {
const assetAddresses = await getAssetAddresses(deployments);
const cOETHVaultProxy = await ethers.getContract("OETHVaultProxy");
const cOETHHarvesterProxy = await ethers.getContract("OETHHarvesterProxy");
const dOETHHarvester = await deployWithConfirmation("OETHHarvester", [
cOETHVaultProxy.address,
assetAddresses.WETH,
]);
await withConfirmation(cOETHHarvesterProxy.upgradeTo(dOETHHarvester.address));
log("Upgraded OETHHarvesterProxy");
return cOETHHarvesterProxy;
};
const deployOETHHarvester = async (oethDripper) => {
const assetAddresses = await getAssetAddresses(deployments);
const { governorAddr } = await getNamedAccounts();
const sGovernor = await ethers.provider.getSigner(governorAddr);
const cOETHVaultProxy = await ethers.getContract("OETHVaultProxy");
const dOETHHarvesterProxy = await deployWithConfirmation(
"OETHHarvesterProxy",
[],
"InitializeGovernedUpgradeabilityProxy"
);
const cOETHHarvesterProxy = await ethers.getContract("OETHHarvesterProxy");
const dOETHHarvester = await deployWithConfirmation("OETHHarvester", [
cOETHVaultProxy.address,
assetAddresses.WETH,
]);
const cOETHHarvester = await ethers.getContractAt(
"OETHHarvester",
dOETHHarvesterProxy.address
);
await withConfirmation(
// prettier-ignore
cOETHHarvesterProxy["initialize(address,address,bytes)"](
dOETHHarvester.address,
governorAddr,
[]
)
);
log("Initialized OETHHarvesterProxy");
await withConfirmation(
cOETHHarvester
.connect(sGovernor)
.setRewardProceedsAddress(
isMainnet || isHolesky ? oethDripper.address : cOETHVaultProxy.address
)
);
return cOETHHarvester;
};
/**
* Deploy Harvester
*/
const deployHarvesters = async (ousdDripper, oethDripper) => {
const dHarvesterProxy = await deployOUSDHarvester(ousdDripper);
const dOETHHarvesterProxy = await deployOETHHarvester(oethDripper);
return [dHarvesterProxy, dOETHHarvesterProxy];
};
/**
* Configure Strategies by setting the Harvester address
*/
const configureStrategies = async (harvesterProxy, oethHarvesterProxy) => {
const { governorAddr } = await getNamedAccounts();
// Signers
const sGovernor = await ethers.provider.getSigner(governorAddr);
const compoundProxy = await ethers.getContract("CompoundStrategyProxy");
const compound = await ethers.getContractAt(
"CompoundStrategy",
compoundProxy.address
);
await withConfirmation(
compound.connect(sGovernor).setHarvesterAddress(harvesterProxy.address)
);
const aaveProxy = await ethers.getContract("AaveStrategyProxy");
const aave = await ethers.getContractAt("AaveStrategy", aaveProxy.address);
await withConfirmation(
aave.connect(sGovernor).setHarvesterAddress(harvesterProxy.address)
);
const convexProxy = await ethers.getContract("ConvexStrategyProxy");
const convex = await ethers.getContractAt(
"ConvexStrategy",
convexProxy.address
);
await withConfirmation(
convex.connect(sGovernor).setHarvesterAddress(harvesterProxy.address)
);
const OUSDmetaStrategyProxy = await ethers.getContract(
"ConvexOUSDMetaStrategyProxy"
);
const metaStrategy = await ethers.getContractAt(
"ConvexOUSDMetaStrategy",
OUSDmetaStrategyProxy.address
);
await withConfirmation(
metaStrategy.connect(sGovernor).setHarvesterAddress(harvesterProxy.address)
);
const LUSDMetaStrategyProxy = await ethers.getContract(
"ConvexLUSDMetaStrategyProxy"
);
const LUSDMetaStrategy = await ethers.getContractAt(
"ConvexGeneralizedMetaStrategy",
LUSDMetaStrategyProxy.address
);
await withConfirmation(
LUSDMetaStrategy.connect(sGovernor).setHarvesterAddress(
harvesterProxy.address
)
);
const threePoolProxy = await ethers.getContract("ThreePoolStrategyProxy");
const threePool = await ethers.getContractAt(
"ThreePoolStrategy",
threePoolProxy.address
);
await withConfirmation(
threePool.connect(sGovernor).setHarvesterAddress(harvesterProxy.address)
);
// OETH Strategies
const fraxEthStrategyProxy = await ethers.getContract("FraxETHStrategyProxy");
const fraxEthStrategy = await ethers.getContractAt(
"FraxETHStrategy",
fraxEthStrategyProxy.address
);
await withConfirmation(
fraxEthStrategy
.connect(sGovernor)
.setHarvesterAddress(oethHarvesterProxy.address)
);
const nativeStakingSSVStrategyProxy = await ethers.getContract(
"NativeStakingSSVStrategyProxy"
);
const nativeStakingSSVStrategy = await ethers.getContractAt(
"NativeStakingSSVStrategy",
nativeStakingSSVStrategyProxy.address
);
await withConfirmation(
nativeStakingSSVStrategy
.connect(sGovernor)
.setHarvesterAddress(oethHarvesterProxy.address)
);
};
const deployOUSDDripper = async () => {
const { governorAddr } = await getNamedAccounts();
const assetAddresses = await getAssetAddresses(deployments);
const cVaultProxy = await ethers.getContract("VaultProxy");
const cVault = await ethers.getContractAt("IVault", cVaultProxy.address);
// Deploy Dripper Impl
const dDripper = await deployWithConfirmation("Dripper", [
cVaultProxy.address,
assetAddresses.USDT,
]);
await deployWithConfirmation("DripperProxy");
// Deploy Dripper Proxy
const cDripperProxy = await ethers.getContract("DripperProxy");
await withConfirmation(
cDripperProxy["initialize(address,address,bytes)"](
dDripper.address,
governorAddr,
[]
)
);
const cDripper = await ethers.getContractAt(
"OETHDripper",
cDripperProxy.address
);
const sGovernor = await ethers.provider.getSigner(governorAddr);
// duration of 14 days
await withConfirmation(
cDripper.connect(sGovernor).setDripDuration(14 * 24 * 60 * 60)
);
await withConfirmation(
cVault.connect(sGovernor).setDripper(cDripperProxy.address)
);
return cDripper;
};
const deployOETHDripper = async () => {
const { governorAddr } = await getNamedAccounts();
const assetAddresses = await getAssetAddresses(deployments);
const cVaultProxy = await ethers.getContract("OETHVaultProxy");
const cVault = await ethers.getContractAt("IVault", cVaultProxy.address);
// Deploy Dripper Impl
const dDripper = await deployWithConfirmation("OETHDripper", [
cVaultProxy.address,
assetAddresses.WETH,
]);
await deployWithConfirmation("OETHDripperProxy");
// Deploy Dripper Proxy
const cDripperProxy = await ethers.getContract("OETHDripperProxy");
await withConfirmation(
cDripperProxy["initialize(address,address,bytes)"](
dDripper.address,
governorAddr,
[]
)
);
const cDripper = await ethers.getContractAt(
"OETHDripper",
cDripperProxy.address
);
const sGovernor = await ethers.provider.getSigner(governorAddr);
// duration of 14 days
await withConfirmation(
cDripper.connect(sGovernor).setDripDuration(14 * 24 * 60 * 60)
);
await withConfirmation(
cVault.connect(sGovernor).setDripper(cDripperProxy.address)
);
return cDripper;
};
const deployDrippers = async () => {
const ousdDripper = await deployOUSDDripper();
const oethDripper = await deployOETHDripper();
return [ousdDripper, oethDripper];
};
/**
* Deploy FraxETHStrategy
* Deploys a proxy, the actual strategy, initializes the proxy and initializes
* the strategy.
*/
const deployFraxEthStrategy = async () => {
const assetAddresses = await getAssetAddresses(deployments);
const { governorAddr } = await getNamedAccounts();
const cOETHVaultProxy = await ethers.getContract("OETHVaultProxy");
log("Deploy FraxETHStrategyProxy");
const dFraxETHStrategyProxy = await deployWithConfirmation(
"FraxETHStrategyProxy"
);
const cFraxETHStrategyProxy = await ethers.getContract(
"FraxETHStrategyProxy"
);
log("Deploy FraxETHStrategy");
const dFraxETHStrategy = await deployWithConfirmation("FraxETHStrategy", [
[assetAddresses.sfrxETH, cOETHVaultProxy.address],
assetAddresses.frxETH,
]);
const cFraxETHStrategy = await ethers.getContractAt(
"FraxETHStrategy",
dFraxETHStrategyProxy.address
);
log("Initialize FraxETHStrategyProxy");
const initData = cFraxETHStrategy.interface.encodeFunctionData(
"initialize()",
[]
);
await withConfirmation(
cFraxETHStrategyProxy["initialize(address,address,bytes)"](
dFraxETHStrategy.address,
governorAddr,
initData
)
);
return cFraxETHStrategy;
};
/**
* upgradeNativeStakingFeeAccumulator
*/
const upgradeNativeStakingFeeAccumulator = async () => {
const { deployerAddr } = await getNamedAccounts();
const sDeployer = await ethers.provider.getSigner(deployerAddr);
const strategyProxy = await ethers.getContract(
"NativeStakingSSVStrategyProxy"
);
const feeAccumulatorProxy = await ethers.getContract(
"NativeStakingFeeAccumulatorProxy"
);
log("About to deploy FeeAccumulator implementation");
const dFeeAccumulatorImpl = await deployWithConfirmation("FeeAccumulator", [
strategyProxy.address, // STRATEGY
]);
log(`New FeeAccumulator implementation: ${dFeeAccumulatorImpl.address}`);
await withConfirmation(
feeAccumulatorProxy
.connect(sDeployer)
.upgradeTo(dFeeAccumulatorImpl.address)
);
};
/**
* Upgrade NativeStakingSSVStrategy
*/
const upgradeNativeStakingSSVStrategy = async () => {
const assetAddresses = await getAssetAddresses(deployments);
const { deployerAddr } = await getNamedAccounts();
const cOETHVaultProxy = await ethers.getContract("OETHVaultProxy");
const strategyProxy = await ethers.getContract(
"NativeStakingSSVStrategyProxy"
);
const sDeployer = await ethers.provider.getSigner(deployerAddr);
const cFeeAccumulatorProxy = await ethers.getContract(
"NativeStakingFeeAccumulatorProxy"
);
log("About to deploy NativeStakingSSVStrategy implementation");
const dStrategyImpl = await deployWithConfirmation(
"NativeStakingSSVStrategy",
[
[addresses.zero, cOETHVaultProxy.address], //_baseConfig
assetAddresses.WETH, // wethAddress
assetAddresses.SSV, // ssvToken
assetAddresses.SSVNetwork, // ssvNetwork
500, // maxValidators
cFeeAccumulatorProxy.address, // feeAccumulator
assetAddresses.beaconChainDepositContract, // depositContractMock
]
);
log(`New NativeStakingSSVStrategy implementation: ${dStrategyImpl.address}`);
await withConfirmation(
strategyProxy.connect(sDeployer).upgradeTo(dStrategyImpl.address)
);
};
/**
* Deploy NativeStakingSSVStrategy
* Deploys a proxy, the actual strategy, initializes the proxy and initializes
* the strategy.
*/
const deployNativeStakingSSVStrategy = async () => {
const assetAddresses = await getAssetAddresses(deployments);
const { governorAddr, deployerAddr } = await getNamedAccounts();
const sDeployer = await ethers.provider.getSigner(deployerAddr);
const cOETHVaultProxy = await ethers.getContract("OETHVaultProxy");
log("Deploy NativeStakingSSVStrategyProxy");
const dNativeStakingSSVStrategyProxy = await deployWithConfirmation(
"NativeStakingSSVStrategyProxy"
);
const cNativeStakingSSVStrategyProxy = await ethers.getContract(
"NativeStakingSSVStrategyProxy"
);
log("Deploy FeeAccumulator proxy");
const dFeeAccumulatorProxy = await deployWithConfirmation(
"NativeStakingFeeAccumulatorProxy"
);
const cFeeAccumulatorProxy = await ethers.getContractAt(
"NativeStakingFeeAccumulatorProxy",
dFeeAccumulatorProxy.address
);
log("Deploy NativeStakingSSVStrategy");
const dStrategyImpl = await deployWithConfirmation(
"NativeStakingSSVStrategy",
[
[addresses.zero, cOETHVaultProxy.address], //_baseConfig
assetAddresses.WETH, // wethAddress
assetAddresses.SSV, // ssvToken
assetAddresses.SSVNetwork, // ssvNetwork
500, // maxValidators
dFeeAccumulatorProxy.address, // feeAccumulator
assetAddresses.beaconChainDepositContract, // depositContractMock
]
);
const cStrategyImpl = await ethers.getContractAt(
"NativeStakingSSVStrategy",
dStrategyImpl.address
);
log("Deploy encode initialize function of the strategy contract");
const initData = cStrategyImpl.interface.encodeFunctionData(
"initialize(address[],address[],address[])",
[
[assetAddresses.WETH], // reward token addresses
/* no need to specify WETH as an asset, since we have that overriden in the "supportsAsset"
* function on the strategy
*/
[], // asset token addresses
[], // platform tokens addresses
]
);
log("Initialize the proxy and execute the initialize strategy function");
await withConfirmation(
cNativeStakingSSVStrategyProxy.connect(sDeployer)[
// eslint-disable-next-line no-unexpected-multiline
"initialize(address,address,bytes)"
](
cStrategyImpl.address, // implementation address
governorAddr, // governance
initData // data for call to the initialize function on the strategy
)
);
const cStrategy = await ethers.getContractAt(
"NativeStakingSSVStrategy",
dNativeStakingSSVStrategyProxy.address
);
log("Approve spending of the SSV token");
await withConfirmation(cStrategy.connect(sDeployer).safeApproveAllTokens());
log("Deploy fee accumulator implementation");
const dFeeAccumulator = await deployWithConfirmation("FeeAccumulator", [
cNativeStakingSSVStrategyProxy.address, // STRATEGY
]);
const cFeeAccumulator = await ethers.getContractAt(
"FeeAccumulator",
dFeeAccumulator.address
);
log("Init fee accumulator proxy");
await withConfirmation(
cFeeAccumulatorProxy.connect(sDeployer)[
// eslint-disable-next-line no-unexpected-multiline