Skip to content

Commit cecd4f3

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

File tree

8 files changed

+246
-8
lines changed

8 files changed

+246
-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: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
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+
uint8 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 = _deployHubBatch(
56+
admin,
57+
report.accessBatchReport.accessManagerAddress
58+
);
59+
hubEntries[i] = Logger.AddressEntry({
60+
label: hubLabels[i],
61+
value: report.hubBatchReport.report.hubAddress
62+
});
63+
logger.log(string.concat(hubLabels[i], ' Hub'), report.hubBatchReport.report.hubAddress);
64+
logger.log(
65+
string.concat(hubLabels[i], ' InterestRateStrategy'),
66+
report.hubBatchReport.report.irStrategyAddress
67+
);
68+
logger.log(
69+
string.concat(hubLabels[i], ' TreasurySpoke'),
70+
report.hubBatchReport.report.treasurySpokeAddress
71+
);
72+
logger.log(
73+
string.concat(hubLabels[i], ' HubConfigurator'),
74+
report.hubBatchReport.report.hubConfiguratorAddress
75+
);
76+
}
77+
logger.writeGroup('Hubs', hubEntries);
78+
79+
// Deploy Spoke Instance Batches
80+
uint256 spokeCount = spokeLabels.length;
81+
Logger.AddressEntry[] memory spokeEntries = new Logger.AddressEntry[](spokeCount);
82+
for (uint256 i; i < spokeCount; i++) {
83+
report.spokeInstanceBatchReport.label = spokeLabels[i];
84+
report.spokeInstanceBatchReport.report = _deploySpokeInstanceBatch(
85+
deployer,
86+
admin,
87+
report.accessBatchReport.accessManagerAddress,
88+
spokeLabels[i]
89+
);
90+
spokeEntries[i] = Logger.AddressEntry({
91+
label: spokeLabels[i],
92+
value: report.spokeInstanceBatchReport.report.spokeProxyAddress
93+
});
94+
logger.log(
95+
string.concat(spokeLabels[i], ' SpokeInstance Proxy'),
96+
report.spokeInstanceBatchReport.report.spokeProxyAddress
97+
);
98+
logger.log(
99+
string.concat(spokeLabels[i], ' SpokeInstance Implementation'),
100+
report.spokeInstanceBatchReport.report.spokeImplementationAddress
101+
);
102+
logger.log(
103+
string.concat(spokeLabels[i], ' AaveOracle'),
104+
report.spokeInstanceBatchReport.report.aaveOracleAddress
105+
);
106+
logger.log(
107+
string.concat(spokeLabels[i], ' SpokeConfigurator'),
108+
report.spokeInstanceBatchReport.report.spokeConfiguratorAddress
109+
);
110+
}
111+
logger.writeGroup('SpokeInstances', spokeEntries);
112+
113+
// Deploy Gateways Batch
114+
report.gatewaysBatchReport = _deployGatewaysBatch(admin, nativeWrapper);
115+
logger.log('NativeTokenGateway', report.gatewaysBatchReport.nativeGatewayAddress);
116+
logger.log('SignatureGateway', report.gatewaysBatchReport.signatureGatewayAddress);
117+
118+
return report;
119+
}
120+
121+
function deployHub(
122+
Logger logger,
123+
address admin,
124+
address accessManagerAddress,
125+
string memory label
126+
) internal returns (HubDeploymentReport memory) {
127+
HubDeploymentReport memory hubReport;
128+
hubReport.label = label;
129+
hubReport.report = _deployHubBatch(admin, accessManagerAddress);
130+
logger.write('Hub', hubReport.report.hubAddress);
131+
logger.write('InterestRateStrategy', hubReport.report.irStrategyAddress);
132+
logger.write('TreasurySpoke', hubReport.report.treasurySpokeAddress);
133+
logger.write('HubConfigurator', hubReport.report.hubConfiguratorAddress);
134+
return hubReport;
135+
}
136+
137+
function deploySpoke(
138+
Logger logger,
139+
address deployer,
140+
address admin,
141+
address accessManagerAddress,
142+
string memory label
143+
) internal returns (SpokeDeploymentReport memory) {
144+
SpokeDeploymentReport memory spokeReport;
145+
spokeReport.label = label;
146+
spokeReport.report = _deploySpokeInstanceBatch(deployer, admin, accessManagerAddress, label);
147+
logger.write('SpokeInstance Proxy', spokeReport.report.spokeProxyAddress);
148+
logger.write('SpokeInstance Implementation', spokeReport.report.spokeImplementationAddress);
149+
logger.write('AaveOracle', spokeReport.report.aaveOracleAddress);
150+
logger.write('SpokeConfigurator', spokeReport.report.spokeConfiguratorAddress);
151+
return spokeReport;
152+
}
153+
154+
function _deployAccessBatch(
155+
address admin
156+
) internal returns (BatchReports.AccessBatchReport memory) {
157+
AaveV4AccessBatch accessBatch = new AaveV4AccessBatch(admin);
158+
return accessBatch.getReport();
159+
}
160+
161+
function _deployHubBatch(
162+
address admin,
163+
address accessManagerAddress
164+
) internal returns (BatchReports.HubBatchReport memory) {
165+
AaveV4HubBatch hubBatch = new AaveV4HubBatch(admin, accessManagerAddress);
166+
return hubBatch.getReport();
167+
}
168+
169+
function _deploySpokeInstanceBatch(
170+
address deployer,
171+
address admin,
172+
address accessManagerAddress,
173+
string memory label
174+
) internal returns (BatchReports.SpokeInstanceBatchReport memory) {
175+
AaveV4SpokeInstanceBatch spokeInstanceBatch = new AaveV4SpokeInstanceBatch(
176+
vm,
177+
deployer,
178+
admin,
179+
accessManagerAddress,
180+
ORACLE_DECIMALS,
181+
string.concat(label, ORACLE_SUFFIX)
182+
);
183+
return spokeInstanceBatch.getReport();
184+
}
185+
186+
function _deployGatewaysBatch(
187+
address admin,
188+
address nativeWrapper
189+
) internal returns (BatchReports.GatewaysBatchReport memory) {
190+
AaveV4GatewaysBatch gatewaysBatch = new AaveV4GatewaysBatch(admin, nativeWrapper);
191+
return gatewaysBatch.getReport();
192+
}
193+
}

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)