Skip to content

Commit bdc58c8

Browse files
committed
feat : add orchestration methods & 1st draft deploy payload
1 parent 4a51e33 commit bdc58c8

File tree

8 files changed

+250
-8
lines changed

8 files changed

+250
-8
lines changed

foundry.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ libs = ['lib']
77
fs_permissions = [
88
{ access = "read", path = "tests/mocks/JsonBindings.sol" },
99
{ access = "read", path = "./config" },
10-
{ access = "read-write", path = "./output" }
10+
{ access = "read-write", path = "./output" },
11+
{ access = "read-write", path = "./scripts/input" }
1112
]
1213
solc_version = "0.8.28"
1314
evm_version = "cancun"
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.0;
3+
4+
import {Script} from 'forge-std/Script.sol';
5+
6+
import {InputUtils} from 'src/deployments/utils/InputUtils.sol';
7+
import {DeployUtils} from 'src/deployments/utils/DeployUtils.sol';
8+
import {Logger} from 'src/deployments/utils/Logger.sol';
9+
10+
import {BatchReports} from 'src/deployments/types/BatchReports.sol';
11+
12+
import {AaveV4DeployOrchestration} from 'src/deployments/orchestration/AaveV4DeployOrchestration.sol';
13+
14+
contract AaveV4DeployBatchScript is Script, DeployUtils, InputUtils {
15+
string internal constant INPUT_PATH = 'scripts/deploy/input/AaveV4DeployInput.json';
16+
string internal constant OUTPUT_PATH = 'output/reports/deployments/AaveV4DeployBatch.json';
17+
18+
constructor() {}
19+
20+
function run() external {
21+
Logger logger = new Logger(OUTPUT_PATH);
22+
FullDeployInputs memory inputs = loadFullDeployInputs(INPUT_PATH);
23+
//TODO : load roles
24+
25+
address deployer = msg.sender;
26+
27+
logger.log('Starting Aave V4 Batch Deployment');
28+
29+
vm.startBroadcast();
30+
AaveV4DeployOrchestration.FullDeploymentReport memory report = AaveV4DeployOrchestration
31+
.deployAaveV4(
32+
logger,
33+
deployer,
34+
inputs.admin,
35+
inputs.nativeWrapperAddress,
36+
inputs.hubLabels,
37+
inputs.spokeLabels
38+
);
39+
vm.stopBroadcast();
40+
41+
// TODO : apply roles
42+
43+
logger.log('Batch Deployment Completed');
44+
logger.log('Saving Logs');
45+
logger.save();
46+
}
47+
}

src/deployments/batches/AaveV4GatewaysBatch.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ contract AaveV4GatewaysBatch is
1111
{
1212
BatchReports.GatewaysBatchReport internal _report;
1313

14-
constructor(address nativeWrapper_, address admin_) {
14+
constructor(address admin_, address nativeWrapper_) {
1515
address nativeGatewayAddress = _deployNativeTokenGateway(nativeWrapper_, admin_);
1616
address signatureGatewayAddress = _deploySignatureGateway(admin_);
1717

src/deployments/batches/AaveV4SpokeInstanceBatch.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ contract AaveV4SpokeInstanceBatch is
3636
oracleDescription_
3737
);
3838
address spokeImplementationAddress = _deploySpokeInstance(aaveOracleAddress);
39-
address spokeProxyAddress = _deployTransparentUpgradeableProxy(
39+
address spokeProxyAddress = _proxify(
4040
spokeImplementationAddress,
4141
admin_,
4242
abi.encodeWithSignature('initialize(address)', accessManagerAddress_)
Lines changed: 197 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,197 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.0;
3+
4+
import 'forge-std/Vm.sol';
5+
6+
import {Logger} from 'src/deployments/utils/Logger.sol';
7+
import {BatchReports} from 'src/deployments/types/BatchReports.sol';
8+
import {AaveV4AccessBatch} from 'src/deployments/batches/AaveV4AccessBatch.sol';
9+
import {AaveV4HubBatch} from 'src/deployments/batches/AaveV4HubBatch.sol';
10+
import {AaveV4SpokeInstanceBatch} from 'src/deployments/batches/AaveV4SpokeInstanceBatch.sol';
11+
import {AaveV4GatewaysBatch} from 'src/deployments/batches/AaveV4GatewaysBatch.sol';
12+
13+
library AaveV4DeployOrchestration {
14+
Vm private constant vm = Vm(address(bytes20(uint160(uint256(keccak256('hevm cheat code'))))));
15+
16+
uint256 constant ORACLE_DECIMALS = 8;
17+
string constant ORACLE_SUFFIX = ' (USD)';
18+
19+
struct SpokeDeploymentReport {
20+
string label;
21+
BatchReports.SpokeInstanceBatchReport report;
22+
}
23+
24+
struct HubDeploymentReport {
25+
string label;
26+
BatchReports.HubBatchReport report;
27+
}
28+
29+
struct FullDeploymentReport {
30+
BatchReports.AccessBatchReport accessBatchReport;
31+
SpokeDeploymentReport spokeInstanceBatchReport;
32+
HubDeploymentReport hubBatchReport;
33+
BatchReports.GatewaysBatchReport gatewaysBatchReport;
34+
}
35+
36+
function deployAaveV4(
37+
Logger logger,
38+
address deployer,
39+
address admin,
40+
address nativeWrapper,
41+
string[] memory hubLabels,
42+
string[] memory spokeLabels
43+
) internal returns (FullDeploymentReport memory) {
44+
FullDeploymentReport memory report;
45+
46+
// Deploy Access Batch
47+
report.accessBatchReport = _deployAccessBatch(admin);
48+
logger.log('AccessManager', report.accessBatchReport.accessManagerAddress);
49+
50+
// Deploy Hub Batches
51+
uint256 hubCount = hubLabels.length;
52+
Logger.AddressEntry[] memory hubEntries = new Logger.AddressEntry[](hubCount);
53+
for (uint256 i; i < hubCount; i++) {
54+
report.hubBatchReport.label = hubLabels[i];
55+
report.hubBatchReport.report = deployHub(
56+
admin,
57+
report.accessBatchReport.accessManagerAddress,
58+
hubLabels[i]
59+
);
60+
hubEntries[i] = Logger.AddressEntry({
61+
label: hubLabels[i],
62+
value: report.hubBatchReport.report.hubAddress
63+
});
64+
logger.log(
65+
string.concat(hubLabels[i], ' Hub'),
66+
report.hubBatchReport.report.hubAddress
67+
);
68+
logger.log(
69+
string.concat(hubLabels[i], ' InterestRateStrategy'),
70+
report.hubBatchReport.report.irStrategyAddress
71+
);
72+
logger.log(
73+
string.concat(hubLabels[i], ' TreasurySpoke'),
74+
report.hubBatchReport.report.treasurySpokeAddress
75+
);
76+
logger.log(
77+
string.concat(hubLabels[i], ' HubConfigurator'),
78+
report.hubBatchReport.report.hubConfiguratorAddress
79+
);
80+
}
81+
logger.writeGroup('Hubs', hubEntries);
82+
83+
// Deploy Spoke Instance Batches
84+
uint256 spokeCount = spokeLabels.length;
85+
Logger.AddressEntry[] memory spokeEntries = new Logger.AddressEntry[](spokeCount);
86+
for (uint256 i; i < spokeCount; i++) {
87+
report.spokeInstanceBatchReport.label = spokeLabels[i];
88+
report.spokeInstanceBatchReport.report = deploySpoke(
89+
deployer,
90+
admin,
91+
report.accessBatchReport.accessManagerAddress,
92+
spokeLabels[i]
93+
);
94+
spokeEntries[i] = Logger.AddressEntry({
95+
label: spokeLabels[i],
96+
value: report.spokeInstanceBatchReport.report.spokeProxyAddress
97+
});
98+
logger.log(
99+
string.concat(spokeLabels[i], ' SpokeInstance Proxy'),
100+
report.spokeInstanceBatchReport.report.spokeProxyAddress
101+
);
102+
logger.log(
103+
string.concat(spokeLabels[i], ' SpokeInstance Implementation'),
104+
report.spokeInstanceBatchReport.report.spokeImplementationAddress
105+
);
106+
logger.log(
107+
string.concat(spokeLabels[i], ' AaveOracle'),
108+
report.spokeInstanceBatchReport.report.aaveOracleAddress
109+
);
110+
logger.log(
111+
string.concat(spokeLabels[i], ' SpokeConfigurator'),
112+
report.spokeInstanceBatchReport.report.spokeConfiguratorAddress
113+
);
114+
}
115+
logger.writeGroup('SpokeInstances', spokeEntries);
116+
117+
// Deploy Gateways Batch
118+
report.gatewaysBatchReport = _deployGatewaysBatch(admin, nativeWrapper);
119+
logger.log('NativeTokenGateway', report.gatewaysBatchReport.nativeGatewayAddress);
120+
logger.log('SignatureGateway', report.gatewaysBatchReport.signatureGatewayAddress);
121+
122+
return report;
123+
}
124+
125+
function deployHub(
126+
Logger logger,
127+
address admin,
128+
address accessManagerAddress,
129+
string memory label
130+
) internal returns (HubDeploymentReport memory) {
131+
HubDeploymentReport memory hubReport;
132+
hubReport.label = label;
133+
hubReport.report = _deployHubBatch(admin, accessManagerAddress);
134+
logger.write('Hub', hubReport.report.hubAddress);
135+
logger.write('InterestRateStrategy', hubReport.report.irStrategyAddress);
136+
logger.write('TreasurySpoke', hubReport.report.treasurySpokeAddress);
137+
logger.write('HubConfigurator', hubReport.report.hubConfiguratorAddress);
138+
return hubReport;
139+
}
140+
141+
function deploySpoke(
142+
Logger logger,
143+
address deployer,
144+
address admin,
145+
address accessManagerAddress,
146+
string memory label
147+
) internal returns (SpokeDeploymentReport memory) {
148+
SpokeDeploymentReport memory spokeReport;
149+
spokeReport.label = label;
150+
spokeReport.report = _deploySpokeInstanceBatch(deployer, admin, accessManagerAddress, label);
151+
logger.write('SpokeInstance Proxy', spokeReport.report.spokeProxyAddress);
152+
logger.write('SpokeInstance Implementation', spokeReport.report.spokeImplementationAddress);
153+
logger.write('AaveOracle', spokeReport.report.aaveOracleAddress);
154+
logger.write('SpokeConfigurator', spokeReport.report.spokeConfiguratorAddress);
155+
return spokeReport;
156+
}
157+
158+
function _deployAccessBatch(
159+
address admin
160+
) private returns (BatchReports.AccessBatchReport memory) {
161+
AaveV4AccessBatch accessBatch = new AaveV4AccessBatch(admin);
162+
return accessBatch.getReport();
163+
}
164+
165+
function _deployHubBatch(
166+
address admin,
167+
address accessManagerAddress
168+
) private returns (BatchReports.HubBatchReport memory) {
169+
AaveV4HubBatch hubBatch = new AaveV4HubBatch(admin, accessManagerAddress);
170+
return hubBatch.getReport();
171+
}
172+
173+
function _deploySpokeInstanceBatch(
174+
address deployer,
175+
address admin,
176+
address accessManagerAddress,
177+
string memory label
178+
) private returns (BatchReports.SpokeInstanceBatchReport memory) {
179+
AaveV4SpokeInstanceBatch spokeInstanceBatch = new AaveV4SpokeInstanceBatch(
180+
vm,
181+
deployer,
182+
admin,
183+
accessManagerAddress,
184+
ORACLE_DECIMALS,
185+
string.concat(label, ORACLE_SUFFIX)
186+
);
187+
return spokeInstanceBatch.getReport();
188+
}
189+
190+
function _deployGatewaysBatch(
191+
address admin,
192+
address nativeWrapper
193+
) private returns (BatchReports.GatewaysBatchReport memory) {
194+
AaveV4GatewaysBatch gatewaysBatch = new AaveV4GatewaysBatch(admin, nativeWrapper);
195+
return gatewaysBatch.getReport();
196+
}
197+
}

src/deployments/procedures/AaveV4TransparentUpgradeableProxyDeployProcedure.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ pragma solidity ^0.8.0;
44
import {TransparentUpgradeableProxy} from 'src/dependencies/openzeppelin/TransparentUpgradeableProxy.sol';
55

66
contract AaveV4TransparentUpgradeableProxyDeployProcedure {
7-
function _deployTransparentUpgradeableProxy(
7+
function _proxify(
88
address logic_,
99
address initialOwner_,
1010
bytes memory data_
Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
// SPDX-License-Identifier: MIT
22
pragma solidity ^0.8.0;
33

4-
import 'forge-std/StdJson.sol';
54
import 'forge-std/Vm.sol';
65

76
contract DeployUtils {
8-
using stdJson for string;
9-
107
Vm private constant vm = Vm(address(bytes20(uint160(uint256(keccak256('hevm cheat code'))))));
118
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import 'forge-std/StdJson.sol';
55
import 'forge-std/Vm.sol';
66
import {console} from 'forge-std/console.sol';
77

8-
contract LogUtils {
8+
contract Logger {
99
using stdJson for string;
1010

1111
struct AddressEntry {

0 commit comments

Comments
 (0)