-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy path002_DeployOriginARM.s.sol
More file actions
118 lines (95 loc) · 5.23 KB
/
Copy path002_DeployOriginARM.s.sol
File metadata and controls
118 lines (95 loc) · 5.23 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
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.36;
// Contract
import {Proxy} from "contracts/Proxy.sol";
import {Sonic} from "contracts/utils/Addresses.sol";
import {IERC20} from "contracts/Interfaces.sol";
import {OriginARM} from "contracts/OriginARM.sol";
import {ZapperARM} from "contracts/ZapperARM.sol";
import {SiloMarket} from "contracts/markets/SiloMarket.sol";
import {CapManager} from "contracts/CapManager.sol";
import {SonicHarvester} from "contracts/SonicHarvester.sol";
// Deployment
import {AbstractDeployScript} from "script/deploy/helpers/AbstractDeployScript.s.sol";
contract $002_DeployOriginARMScript is AbstractDeployScript("002_DeployOriginARMScript") {
Proxy originARMProxy;
function _execute() internal override {
originARMProxy = Proxy(payable(resolver.resolve("ORIGIN_ARM")));
// 1. Deploy proxy for the CapManager
Proxy capManProxy = new Proxy();
_recordDeployment("ORIGIN_ARM_CAP_MAN", address(capManProxy));
// 2. Deploy CapManager implementation
CapManager capManagerImpl = new CapManager(address(originARMProxy));
_recordDeployment("ORIGIN_ARM_CAP_IMPL", address(capManagerImpl));
// 3. Initialize Proxy with CapManager implementation and set the owner to the deployer for now
bytes memory data = abi.encodeWithSelector(CapManager.initialize.selector, Sonic.RELAYER);
capManProxy.initialize(address(capManagerImpl), deployer, data);
CapManager capManager = CapManager(address(capManProxy));
// 4. Set total wS cap
capManager.setTotalAssetsCap(200 ether);
// 5. Transfer ownership of CapManager to the Sonic 5/8 Admin multisig
capManProxy.setOwner(Sonic.ADMIN);
// 6. Deploy new Origin ARM implementation
uint256 claimDelay = 10 minutes;
OriginARM originARMImpl = new OriginARM(Sonic.OS, Sonic.WS, Sonic.OS_VAULT, claimDelay, 1e7, 1e18);
_recordDeployment("ORIGIN_ARM_IMPL", address(originARMImpl));
// 7. Approve a little bit of wS to be transferred to the ARM proxy
// This is needed for the initialize function which will mint some ARM LP tokens
// and send to a dead address
IERC20(Sonic.WS).approve(address(originARMProxy), 1e12);
// 8. Initialize Proxy with Origin ARM implementation and set the owner to the deployer for now
data = abi.encodeWithSignature(
"initialize(string,string,address,uint256,address,address)",
"Origin ARM",
"ARM-WS-OS",
Sonic.RELAYER,
2000, // 20% fee
Sonic.MULTISIG_2_OF_8,
address(capManProxy)
);
originARMProxy.initialize(address(originARMImpl), deployer, data);
OriginARM originARM = OriginARM(address(originARMProxy));
// 9. Deploy the Silo market proxies
Proxy silo_Varlamore_S_MarketProxy = new Proxy();
_recordDeployment("SILO_VARLAMORE_S_MARKET", address(silo_Varlamore_S_MarketProxy));
// 10. Deploy the Silo market implementations
SiloMarket silo_Varlamore_S_MarketImpl =
new SiloMarket(address(originARM), Sonic.SILO_VARLAMORE_S_VAULT, Sonic.SILO_VARLAMORE_S_GAUGE);
_recordDeployment("SILO_VARLAMORE_S_MARKET_IMPL", address(silo_Varlamore_S_MarketImpl));
// 11. Initialize Silo market Proxies, setting governor to Timelock and set Harvester to Relayer for now
data = abi.encodeWithSignature("initialize(address)", Sonic.RELAYER);
silo_Varlamore_S_MarketProxy.initialize(address(silo_Varlamore_S_MarketImpl), Sonic.TIMELOCK, data);
// 12. Set the supported lending markets
address[] memory markets = new address[](1);
// These both have gauges so using a market proxy
markets[0] = address(silo_Varlamore_S_MarketProxy);
originARM.addMarkets(markets);
// 13. Transfer ownership of OriginARM to the Sonic 5/8 Admin multisig
originARM.setOwner(Sonic.ADMIN);
// 14. Deploy the Zapper
ZapperARM zapper = new ZapperARM(Sonic.WS);
zapper.setOwner(Sonic.ADMIN);
_recordDeployment("ORIGIN_ARM_ZAPPER", address(zapper));
// 15. Deploy the SonicHarvester proxy
Proxy harvesterProxy = new Proxy();
_recordDeployment("HARVESTER", address(harvesterProxy));
// 16. Deploy the SonicHarvester implementation
SonicHarvester harvesterImpl = new SonicHarvester(Sonic.WS);
_recordDeployment("HARVESTER_IMPL", address(harvesterImpl));
// 17. Initialize Proxy with SonicHarvester implementation and set the owner to the deployer for now
address PriceProvider = address(0);
data = abi.encodeWithSignature(
"initialize(address,uint256,address,address)",
PriceProvider,
200,
address(originARMProxy),
Sonic.MAGPIE_ROUTER
);
harvesterProxy.initialize(address(harvesterImpl), deployer, data);
SonicHarvester harvester = SonicHarvester(address(harvesterProxy));
// 18. Set the supported Silo market strategies
harvester.setSupportedStrategy(address(silo_Varlamore_S_MarketProxy), true);
// 19. Transfer ownership of SonicHarvester to the Sonic 5/8 Admin multisig
harvesterProxy.setOwner(Sonic.ADMIN);
}
}