Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
8bafe86
feat : procedures to deploy contracts
Kogaroshi Nov 3, 2025
d95101b
feat : add batch contracts for deploy
Kogaroshi Nov 5, 2025
00ba92a
feat : add Logger for Deploy Engine
Kogaroshi Nov 5, 2025
9f6c70d
feat : Input helper for Deploy Engine
Kogaroshi Nov 5, 2025
4a51e33
Merge branch 'main' of https://github.com/aave/aave-v4 into feat/payl…
Kogaroshi Nov 7, 2025
cecd4f3
feat : add orchestration methods & 1st draft deploy payload
Kogaroshi Nov 7, 2025
460c2e0
fix : separate batch for configurators
Kogaroshi Nov 10, 2025
2aaeb00
feat : roles procedures & small fixes
Kogaroshi Nov 10, 2025
4581387
feat : test env orchestration (WIP)
Kogaroshi Nov 11, 2025
b94ed13
fix : fix errors test env orchestration
Kogaroshi Nov 11, 2025
3ba9fad
Merge branch 'main' of https://github.com/aave/aave-v4 into feat/payl…
Kogaroshi Nov 12, 2025
e455afb
fix : apply latest main changes
Kogaroshi Nov 12, 2025
00433e9
feat : procedures for Hub & Spoke configs setup (WIP)
Kogaroshi Nov 12, 2025
945619f
feat : finish test config engine & reorder structs
Kogaroshi Nov 13, 2025
8680dd6
fix : fix Licenses for payload engine
Kogaroshi Nov 14, 2025
21033d1
feat : use orchestration in test setup (WIP)
Kogaroshi Nov 14, 2025
5304e6c
pull latest from main
Kogaroshi Dec 1, 2025
9545217
fix : missing action
Kogaroshi Dec 1, 2025
4d36444
fix: clean up file paths; refactor
yan-man Dec 2, 2025
a951c30
feat: use toml; clean up logs; rft; naming
yan-man Dec 3, 2025
384aeef
fix: StdToml import
yan-man Dec 3, 2025
ac1dc8a
fix: debug mismatch of spoke instance
yan-man Dec 4, 2025
1fd5830
tmp: push deploy progress w output json
yan-man Dec 5, 2025
dd459c1
fix: min logger interface; mv input toml file; resolve computeCreated…
yan-man Dec 5, 2025
11be630
rft: DeployCore lib
yan-man Dec 5, 2025
7b16818
rft: metadata logger
yan-man Dec 5, 2025
8f7d6f7
feat: include timestamp in log output
yan-man Dec 5, 2025
63c93f9
fix: debug set roles
yan-man Dec 5, 2025
e38a93c
fix: clean up comments
yan-man Dec 5, 2025
563f04f
feat: broadcast flag; BatchTestProcedures tests
yan-man Dec 6, 2025
a455a57
test: batch deployment
yan-man Dec 6, 2025
e3642d3
fix: move test files
yan-man Dec 6, 2025
b06da1a
fix: CI
yan-man Dec 6, 2025
05c0dc0
fix: comments
yan-man Dec 6, 2025
d5affff
fix: CI
yan-man Dec 6, 2025
265a3a7
fix: CI
yan-man Dec 6, 2025
8d4cef0
fix: clean up;
yan-man Dec 6, 2025
beea923
fix: CI; move back to json
yan-man Dec 6, 2025
31509cf
fix: clean up logger
yan-man Dec 6, 2025
ac59e59
fix: lint
yan-man Dec 6, 2025
a224fe8
rft: hub/spoke roles + tests
yan-man Dec 8, 2025
17db1f2
feat: loadWarnings; abstract contract; zero addr native wrapper case
yan-man Dec 8, 2025
c49467f
fix: warnings
yan-man Dec 8, 2025
65b44c9
fix: consolidate setting roles
yan-man Dec 8, 2025
25a3ae4
feat: grantRoles bool; conditional test logic
yan-man Dec 9, 2025
e597f1c
rft: test suite setup
yan-man Dec 12, 2025
6c5c0b5
fix: rename roles for clarity
yan-man Dec 13, 2025
70e4501
fix: specify admin inputs
yan-man Dec 13, 2025
8f14c51
fix: AaveV4DeployBatchScript configurable inputs
yan-man Dec 13, 2025
e7f4ea5
fix: user warnings prompt
yan-man Dec 13, 2025
f6787b9
test: computeCreateAddress; pr comments
yan-man Dec 13, 2025
27260d0
fix: pr comments; re-order imports
yan-man Dec 13, 2025
8c26cf3
test: fix
yan-man Dec 13, 2025
0ad7618
fix: pr comments
yan-man Dec 16, 2025
198fc50
fix: rm named arg
yan-man Dec 16, 2025
5b13830
fix: pr comments
yan-man Dec 17, 2025
4358d33
fix: rename validation func
yan-man Dec 17, 2025
b3cf5e5
fix: func names
yan-man Dec 17, 2025
92eab04
test: AaveV4DeployBatchBaseScriptTest
yan-man Dec 17, 2025
d851888
fix: create2 factory; expand and clean up tests
yan-man Dec 17, 2025
5492653
chore: clean up logging
yan-man Dec 17, 2025
90f133f
fix: pragma consistency; errors
yan-man Dec 19, 2025
b8acf9c
fix: pr comments
yan-man Dec 20, 2025
7a82a0b
fix: tmp fix for CI
yan-man Dec 20, 2025
dfe4808
test: resolve
yan-man Dec 23, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,6 @@ lcov*
report/

.DS_Store
.venv/
.venv/

output/
9 changes: 9 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,12 @@ coverage :
make coverage-clean
make coverage-report
make coverage-badge

# Deploy

# Full deployment, including hubs, spokes, and gateways
deploy-full :;
FOUNDRY_PROFILE=${CHAIN} forge script scripts/deploy/AaveV4DeployBatch.s.sol:AaveV4DeployBatchScript \
--rpc-url ${CHAIN} --sender ${SENDER} --account ${ACCOUNT} --slow \
--broadcast

15 changes: 15 additions & 0 deletions config/AaveV4DeployInput.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"accessManagerAdmin": "0x0000000000000000000000000000000000000001",
"hubConfiguratorOwner": "0x0000000000000000000000000000000000000002",
"hubAdmin": "0x0000000000000000000000000000000000000003",
"treasurySpokeOwner": "0x0000000000000000000000000000000000000003",
"spokeConfiguratorOwner": "0x0000000000000000000000000000000000000004",
"spokeAdmin": "0x0000000000000000000000000000000000000005",
"spokeProxyAdminOwner": "0x0000000000000000000000000000000000000005",
"gatewayOwner": "0x0000000000000000000000000000000000000005",
"nativeWrapper": "0x0000000000000000000000000000000000000006",
"grantRoles": true,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copying thread from #1053

avniculae
Contributor
Author

what use case is there for setRoles = false?

yan-man replied

yan-man
Contributor

i think perhaps deploying an instance via aave labs and not setting roles till an AIP to hand off to DAO, cc @Kogaroshi

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, since some Spoke/Hubs might not be controlled by the deploying entity, this would allow to deploy them with "empty" configs until ready to be configured by the entity managing it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i did the setRoles by default (for the defined targetFunctionSelectors, but grantRole i made into a boolean, see latest

"hubLabels": ["Hub 1", "Hub 2", "Hub 3"],
"spokeLabels": ["Spoke 1", "Spoke 2", "Spoke 3"],
"salt": "salt"
}
8 changes: 7 additions & 1 deletion foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,19 @@ src = 'src'
test = 'tests'
out = 'out'
libs = ['lib']
fs_permissions = [{ access = "read", path = "tests/mocks/JsonBindings.sol" }]
fs_permissions = [
{ access = "read", path = "tests/mocks/JsonBindings.sol" },
{ access = "read", path = "./config" },
{ access = "read-write", path = "./output" }
]
solc_version = "0.8.28"
evm_version = "cancun"
optimizer = true
optimizer_runs = 200
bytecode_hash = "none"
gas_snapshot_check = false
gas_limit = 1099511627776
ffi = true

[bind_json]
out = "tests/mocks/JsonBindings.sol"
Expand Down Expand Up @@ -49,6 +54,7 @@ zkevm = "${RPC_ZKEVM}"
gnosis = "${RPC_GNOSIS}"
bnb = "${RPC_BNB}"
celo = "${RPC_CELO}"
anvil = "http://127.0.0.1:8545"

[etherscan]
mainnet = { key = "${ETHERSCAN_API_KEY_MAINNET}", chainId = 1 }
Expand Down
11 changes: 11 additions & 0 deletions scripts/deploy/AaveV4DeployBatch.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// SPDX-License-Identifier: UNLICENSED
// Copyright (c) 2025 Aave Labs
pragma solidity ^0.8.0;

import 'scripts/deploy/AaveV4DeployBatchBase.s.sol';

contract AaveV4DeployBatchScript is AaveV4DeployBatchBaseScript {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't think aavev4 prefix is needed on any of these

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agnostic but just a copy of v3 style - @miguelmtzinf thoughts?

string internal constant INPUT_FILE = 'AaveV4DeployInput.json';
string internal constant OUTPUT_FILE = 'AaveV4DeployBatch.json';
constructor() AaveV4DeployBatchBaseScript(INPUT_FILE, OUTPUT_FILE) {}
}
150 changes: 150 additions & 0 deletions scripts/deploy/AaveV4DeployBatchBase.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
// SPDX-License-Identifier: UNLICENSED
// Copyright (c) 2025 Aave Labs
pragma solidity ^0.8.0;

import {OrchestrationReports} from 'src/deployments/libraries/OrchestrationReports.sol';
import {InputUtils} from 'src/deployments/utils/InputUtils.sol';
import {MetadataLogger} from 'src/deployments/utils/MetadataLogger.sol';
import {
AaveV4DeployOrchestration
} from 'src/deployments/orchestration/AaveV4DeployOrchestration.sol';

import {Script} from 'forge-std/Script.sol';

abstract contract AaveV4DeployBatchBaseScript is Script, InputUtils {
struct Warnings {
string[] s;
}

string internal constant INPUT_PATH = 'config/';
string internal constant OUTPUT_DIR = 'output/reports/deployments/';
string internal _inputFileName;
string internal _outputFileName;
Warnings internal _warnings;

constructor(string memory inputFileName_, string memory outputFileName_) {
_inputFileName = inputFileName_;
_outputFileName = outputFileName_;
}

function run() external virtual {
vm.createDir(OUTPUT_DIR, true);
MetadataLogger logger = new MetadataLogger(OUTPUT_DIR);
FullDeployInputs memory inputs = loadFullDeployInputs(
string.concat(INPUT_PATH, _inputFileName)
);
(, address deployer, ) = vm.readCallers();
inputs = _loadWarningsAndSanitizeInputs(logger, inputs, deployer);

logger.log('CHAIN ID', block.chainid);
logger.log('...Starting Aave V4 Batch Deployment...');
vm.startBroadcast(deployer);
OrchestrationReports.FullDeploymentReport memory report = AaveV4DeployOrchestration
.deployAaveV4(logger, deployer, inputs);
vm.stopBroadcast();
logger.writeJsonReportMarket(report);
logger.log('...Batch Deployment Completed...');
logger.log('...Saving Logs...');
logger.save({fileName: _outputFileName, withTimestamp: true});
}

function _loadWarningsAndSanitizeInputs(
MetadataLogger logger,
FullDeployInputs memory inputs,
address deployer
) internal virtual returns (FullDeployInputs memory) {
string memory message = ' is zero address';
string memory outcome = '; defaulting to deployer';

FullDeployInputs memory sanitizedInputs = inputs;
bool hadWarnings = false;
if (inputs.grantRoles) {
_logAndAppend(logger, string.concat('Roles are being set'));
hadWarnings = true;
if (inputs.accessManagerAdmin == address(0)) {
_logAndAppend(logger, string.concat('Access Manager Admin', message, outcome));
sanitizedInputs.accessManagerAdmin = deployer;
}
if (inputs.hubConfiguratorOwner == address(0)) {
_logAndAppend(logger, string.concat('Hub Configurator Owner', message, outcome));
sanitizedInputs.hubConfiguratorOwner = deployer;
}
if (inputs.spokeConfiguratorOwner == address(0)) {
_logAndAppend(logger, string.concat('Spoke Configurator Owner', message, outcome));
sanitizedInputs.spokeConfiguratorOwner = deployer;
}
if (inputs.spokeProxyAdminOwner == address(0)) {
_logAndAppend(logger, string.concat('Spoke Proxy Admin Owner', message, outcome));
sanitizedInputs.spokeProxyAdminOwner = deployer;
}
if (inputs.treasurySpokeOwner == address(0)) {
_logAndAppend(logger, string.concat('Treasury Spoke Owner', message, outcome));
sanitizedInputs.treasurySpokeOwner = deployer;
}
if (inputs.spokeAdmin == address(0)) {
_logAndAppend(logger, string.concat('Spoke Admin', message, outcome));
sanitizedInputs.spokeAdmin = deployer;
}
if (inputs.hubAdmin == address(0)) {
_logAndAppend(logger, string.concat('Hub Admin', message, outcome));
sanitizedInputs.hubAdmin = deployer;
}
}
if (inputs.hubLabels.length == 0) {
_logAndAppend(logger, string.concat('Hub will not be deployed'));
hadWarnings = true;
sanitizedInputs.hubLabels = new string[](0);
}
if (inputs.spokeLabels.length == 0) {
_logAndAppend(logger, string.concat('Spoke will not be deployed'));
hadWarnings = true;
sanitizedInputs.spokeLabels = new string[](0);
}
if (inputs.nativeWrapper == address(0)) {
_logAndAppend(
logger,
string.concat(
'Native wrapper',
message,
"; NativeTokenGateway & SignatureGateway will not be deployed'"
)
);
hadWarnings = true;
sanitizedInputs.nativeWrapper = address(0);
}
if (inputs.gatewayOwner == address(0)) {
_logAndAppend(logger, string.concat('Gateway owner', message, outcome));
hadWarnings = true;
sanitizedInputs.gatewayOwner = deployer;
}
if (hadWarnings) {
_executeUserPrompt();
}
return sanitizedInputs;
}

function _executeUserPrompt() internal virtual {
string memory ack = vm.prompt(
string.concat(_joinWarnings(_warnings), "\nEnter 'y' to continue")
);
if (keccak256(bytes(ack)) != keccak256(bytes('y'))) {
revert('User did not acknowledge warnings. Please try again.');
}
}

function _logAndAppend(MetadataLogger logger, string memory warning) internal virtual {
warning = string.concat('WARNING: ', warning);
logger.log(warning);
_warnings.s.push(warning);
}

function _joinWarnings(Warnings storage warnings) internal view virtual returns (string memory) {
uint256 n = warnings.s.length;
if (n == 0) return '';
string memory out = warnings.s[0];
for (uint256 i = 1; i < n; i++) {
out = string.concat(out, '\n', warnings.s[i]);
}
return string.concat(out, '\n');
}
}
6 changes: 3 additions & 3 deletions snapshots/Hub.Operations.json
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are they changing? foundry version?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no foundry version update. was trying to dig into this but couldnt id exactly why, base set up was just refactored.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"add": "88006",
"add: with transfer": "109613",
"add: with transfer": "109652",
"draw": "105931",
"eliminateDeficit: full": "59781",
"eliminateDeficit: partial": "69429",
Expand All @@ -11,8 +11,8 @@
"remove: partial": "81640",
"reportDeficit": "115225",
"restore: full": "80471",
"restore: full - with transfer": "173377",
"restore: full - with transfer": "173421",
"restore: partial": "89137",
"restore: partial - with transfer": "147400",
"restore: partial - with transfer": "147439",
"transferShares": "71192"
}
4 changes: 2 additions & 2 deletions snapshots/SignatureGateway.Operations.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"borrowWithSig": "215605",
"repayWithSig": "188872",
"setSelfAsUserPositionManagerWithSig": "75402",
"repayWithSig": "188860",
"setSelfAsUserPositionManagerWithSig": "75390",
"setUsingAsCollateralWithSig": "85053",
"supplyWithSig": "153205",
"updateUserDynamicConfigWithSig": "62769",
Expand Down
2 changes: 1 addition & 1 deletion snapshots/Spoke.Operations.ZeroRiskPremium.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"permitReserve + supply + enable collateral (multicall)": "160573",
"repay: full": "126094",
"repay: partial": "130983",
"setUserPositionManagerWithSig: disable": "44846",
"setUserPositionManagerWithSig: disable": "44822",
"setUserPositionManagerWithSig: enable": "68875",
"supply + enable collateral (multicall)": "140624",
"supply: 0 borrows, collateral disabled": "123679",
Expand Down
2 changes: 1 addition & 1 deletion snapshots/Spoke.Operations.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"permitReserve + supply + enable collateral (multicall)": "160573",
"repay: full": "120256",
"repay: partial": "139545",
"setUserPositionManagerWithSig: disable": "44846",
"setUserPositionManagerWithSig: disable": "44822",
"setUserPositionManagerWithSig: enable": "68875",
"supply + enable collateral (multicall)": "140624",
"supply: 0 borrows, collateral disabled": "123679",
Expand Down
24 changes: 24 additions & 0 deletions src/deployments/batches/AaveV4AccessBatch.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// SPDX-License-Identifier: UNLICENSED
// Copyright (c) 2025 Aave Labs
pragma solidity ^0.8.0;

import {BatchReports} from 'src/deployments/libraries/BatchReports.sol';
import {
AaveV4AccessManagerEnumerableDeployProcedure
} from 'src/deployments/procedures/deploy/AaveV4AccessManagerEnumerableDeployProcedure.sol';

contract AaveV4AccessBatch is AaveV4AccessManagerEnumerableDeployProcedure {
BatchReports.AccessBatchReport internal _report;

constructor(address admin_, bytes32 salt_) {
address accessManager = _deployAccessManagerEnumerable(
admin_,
keccak256(abi.encodePacked(SALT, salt_, 'accessManager'))
);
_report = BatchReports.AccessBatchReport({accessManager: accessManager});
}

function getReport() external view returns (BatchReports.AccessBatchReport memory) {
return _report;
}
}
38 changes: 38 additions & 0 deletions src/deployments/batches/AaveV4ConfiguratorBatch.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// SPDX-License-Identifier: UNLICENSED
// Copyright (c) 2025 Aave Labs
pragma solidity ^0.8.0;

import {BatchReports} from 'src/deployments/libraries/BatchReports.sol';
import {
AaveV4HubConfiguratorDeployProcedure
} from 'src/deployments/procedures/deploy/hub/AaveV4HubConfiguratorDeployProcedure.sol';
import {
AaveV4SpokeConfiguratorDeployProcedure
} from 'src/deployments/procedures/deploy/spoke/AaveV4SpokeConfiguratorDeployProcedure.sol';

contract AaveV4ConfiguratorBatch is
AaveV4HubConfiguratorDeployProcedure,
AaveV4SpokeConfiguratorDeployProcedure
{
BatchReports.ConfiguratorBatchReport internal _report;

constructor(address hubConfiguratorOwner_, address spokeConfiguratorOwner_, bytes32 salt_) {
address hubConfigurator = _deployHubConfigurator(
hubConfiguratorOwner_,
keccak256(abi.encodePacked(SALT, salt_, 'hubConfigurator'))
);
address spokeConfigurator = _deploySpokeConfigurator(
spokeConfiguratorOwner_,
keccak256(abi.encodePacked(SALT, salt_, 'spokeConfigurator'))
);

_report = BatchReports.ConfiguratorBatchReport({
hubConfigurator: hubConfigurator,
spokeConfigurator: spokeConfigurator
});
}

function getReport() external view returns (BatchReports.ConfiguratorBatchReport memory) {
return _report;
}
}
39 changes: 39 additions & 0 deletions src/deployments/batches/AaveV4GatewayBatch.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// SPDX-License-Identifier: UNLICENSED
// Copyright (c) 2025 Aave Labs
pragma solidity ^0.8.0;

import {BatchReports} from 'src/deployments/libraries/BatchReports.sol';
import {
AaveV4NativeTokenGatewayDeployProcedure
} from 'src/deployments/procedures/deploy/position-manager/AaveV4NativeTokenGatewayDeployProcedure.sol';
import {
AaveV4SignatureGatewayDeployProcedure
} from 'src/deployments/procedures/deploy/position-manager/AaveV4SignatureGatewayDeployProcedure.sol';

contract AaveV4GatewayBatch is
AaveV4NativeTokenGatewayDeployProcedure,
AaveV4SignatureGatewayDeployProcedure
{
BatchReports.GatewaysBatchReport internal _report;

constructor(address owner_, address nativeWrapper_, bytes32 salt_) {
address nativeGateway = _deployNativeTokenGateway({
nativeWrapper: nativeWrapper_,
owner: owner_,
salt: keccak256(abi.encodePacked(SALT, salt_, 'nativeGateway'))
});
address signatureGateway = _deploySignatureGateway(
owner_,
keccak256(abi.encodePacked(SALT, salt_, 'signatureGateway'))
);

_report = BatchReports.GatewaysBatchReport({
nativeGateway: nativeGateway,
signatureGateway: signatureGateway
});
}

function getReport() external view returns (BatchReports.GatewaysBatchReport memory) {
return _report;
}
}
Loading
Loading