diff --git a/.gitmodules b/.gitmodules index 78d40275f..f7316a1d6 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,3 @@ -[submodule "lib/forge-std"] - path = lib/forge-std - url = https://github.com/foundry-rs/forge-std [submodule "lib/aave-helpers"] path = lib/aave-helpers url = https://github.com/bgd-labs/aave-helpers diff --git a/generator/features/__snapshots__/assetListing.spec.ts.snap b/generator/features/__snapshots__/assetListing.spec.ts.snap index a7c999c3c..428e19738 100644 --- a/generator/features/__snapshots__/assetListing.spec.ts.snap +++ b/generator/features/__snapshots__/assetListing.spec.ts.snap @@ -88,6 +88,7 @@ pragma solidity ^0.8.0; import {AaveV3Ethereum, AaveV3EthereumEModes} from 'aave-address-book/AaveV3Ethereum.sol'; import {AaveV3PayloadEthereum} from 'aave-helpers/v3-config-engine/AaveV3PayloadEthereum.sol'; +import {IAaveV3ConfigEngine} from 'aave-helpers/v3-config-engine/IAaveV3ConfigEngine.sol'; /** * @title test @@ -102,10 +103,10 @@ contract AaveV3Ethereum_Test_20231023 is AaveV3PayloadEthereum { AaveV3Ethereum.POOL.supply(PSP, 10 ** 18, AaveV3Ethereum.COLLECTOR, 0); } - function newListings() public pure override returns (IEngine.Listing[] memory) { - IEngine.Listing[] memory listings = new IEngine.Listing[](1); + function newListings() public pure override returns (IAaveV3ConfigEngine.Listing[] memory) { + IAaveV3ConfigEngine.Listing[] memory listings = new IAaveV3ConfigEngine.Listing[](1); - listings[0] = IEngine.Listing({ + listings[0] = IAaveV3ConfigEngine.Listing({ asset: PSP, assetSymbol: 'PSP', priceFeed: 0x72AFAECF99C9d9C8215fF44C77B94B99C28741e8, @@ -158,7 +159,7 @@ contract AaveV3Ethereum_Test_20231023_Test is ProtocolV3TestBase { AaveV3Ethereum_Test_20231023 internal proposal; function setUp() public { - vm.createSelectFork(vm.rpcUrl('mainnet'), 18413630); + vm.createSelectFork(vm.rpcUrl('mainnet'), 18420741); proposal = new AaveV3Ethereum_Test_20231023(); } @@ -222,7 +223,7 @@ contract CreateProposal is EthereumScript { payloads[0] = GovV3Helpers.buildMainnetPayload(vm, actionsEthereum); // create proposal - GovV3Helpers.createProposal( + GovV3Helpers.createProposal2_5( payloads, GovV3Helpers.ipfsHashFile(vm, 'src/20231023_AaveV3Ethereum_Test/Test.md') ); @@ -242,10 +243,10 @@ exports[`feature: assetListing > should return reasonable code 1`] = ` "AaveV3Ethereum.POOL.supply(PSP, 10 ** 18, AaveV3Ethereum.COLLECTOR, 0);", ], "fn": [ - "function newListings() public pure override returns (IEngine.Listing[] memory) { - IEngine.Listing[] memory listings = new IEngine.Listing[](1); + "function newListings() public pure override returns (IAaveV3ConfigEngine.Listing[] memory) { + IAaveV3ConfigEngine.Listing[] memory listings = new IAaveV3ConfigEngine.Listing[](1); - listings[0] = IEngine.Listing({ + listings[0] = IAaveV3ConfigEngine.Listing({ asset: PSP, assetSymbol: \\"PSP\\", priceFeed: 0x72AFAECF99C9d9C8215fF44C77B94B99C28741e8, diff --git a/generator/features/assetListing.ts b/generator/features/assetListing.ts index 2bf723105..00bae7c5a 100644 --- a/generator/features/assetListing.ts +++ b/generator/features/assetListing.ts @@ -108,12 +108,14 @@ export const assetListing: FeatureModule = { `${pool}.POOL.supply(${cfg.assetSymbol}, 10 ** ${cfg.decimals}, ${pool}.COLLECTOR, 0);` ), fn: [ - `function newListings() public pure override returns (IEngine.Listing[] memory) { - IEngine.Listing[] memory listings = new IEngine.Listing[](${cfg.length}); + `function newListings() public pure override returns (IAaveV3ConfigEngine.Listing[] memory) { + IAaveV3ConfigEngine.Listing[] memory listings = new IAaveV3ConfigEngine.Listing[](${ + cfg.length + }); ${cfg .map( - (cfg, ix) => `listings[${ix}] = IEngine.Listing({ + (cfg, ix) => `listings[${ix}] = IAaveV3ConfigEngine.Listing({ asset: ${cfg.assetSymbol}, assetSymbol: "${cfg.assetSymbol}", priceFeed: ${cfg.priceFeed}, @@ -186,15 +188,15 @@ export const assetListingCustom: FeatureModule = { `${pool}.POOL.supply(${cfg.base.assetSymbol}, 10 ** ${cfg.base.decimals}, ${pool}.COLLECTOR, 0);` ), fn: [ - `function newListingsCustom() public pure override returns (IEngine.ListingWithCustomImpl[] memory) { - IEngine.ListingWithCustomImpl[] memory listings = new IEngine.ListingWithCustomImpl[](${ + `function newListingsCustom() public pure override returns (IAaveV3ConfigEngine.ListingWithCustomImpl[] memory) { + IAaveV3ConfigEngine.ListingWithCustomImpl[] memory listings = new IAaveV3ConfigEngine.ListingWithCustomImpl[](${ cfg.length }); ${cfg .map( - (cfg, ix) => `listings[${ix}] = IEngine.ListingWithCustomImpl( - IEngine.Listing({ + (cfg, ix) => `listings[${ix}] = IAaveV3ConfigEngine.ListingWithCustomImpl( + IAaveV3ConfigEngine.Listing({ asset: ${cfg.base.assetSymbol}, assetSymbol: "${cfg.base.assetSymbol}", priceFeed: ${cfg.base.priceFeed}, @@ -224,7 +226,7 @@ export const assetListingCustom: FeatureModule = { optimalStableToTotalDebtRatio: ${cfg.base.rateStrategyParams.optimalStableToTotalDebtRatio} }) }), - IEngine.TokenImplementations({ + IAaveV3ConfigEngine.TokenImplementations({ aToken: ${cfg.implementations.aToken}, vToken: ${cfg.implementations.vToken}, sToken: ${cfg.implementations.sToken} diff --git a/generator/features/borrowsUpdates.ts b/generator/features/borrowsUpdates.ts index 4eef29600..029751679 100644 --- a/generator/features/borrowsUpdates.ts +++ b/generator/features/borrowsUpdates.ts @@ -56,12 +56,14 @@ export const borrowsUpdates: FeatureModule = { const response: CodeArtifact = { code: { fn: [ - `function borrowsUpdates() public pure override returns (IEngine.BorrowUpdate[] memory) { - IEngine.BorrowUpdate[] memory borrowUpdates = new IEngine.BorrowUpdate[](${cfg.length}); + `function borrowsUpdates() public pure override returns (IAaveV3ConfigEngine.BorrowUpdate[] memory) { + IAaveV3ConfigEngine.BorrowUpdate[] memory borrowUpdates = new IAaveV3ConfigEngine.BorrowUpdate[](${ + cfg.length + }); ${cfg .map( - (cfg, ix) => `borrowUpdates[${ix}] = IEngine.BorrowUpdate({ + (cfg, ix) => `borrowUpdates[${ix}] = IAaveV3ConfigEngine.BorrowUpdate({ asset: ${cfg.asset}, enabledToBorrow: ${cfg.enabledToBorrow}, flashloanable: ${cfg.flashloanable}, diff --git a/generator/features/capsUpdates.ts b/generator/features/capsUpdates.ts index 8444163f0..f172f07f6 100644 --- a/generator/features/capsUpdates.ts +++ b/generator/features/capsUpdates.ts @@ -38,12 +38,14 @@ export const capsUpdates: FeatureModule = { const response: CodeArtifact = { code: { fn: [ - `function capsUpdates() public pure override returns (IEngine.CapsUpdate[] memory) { - IEngine.CapsUpdate[] memory capsUpdate = new IEngine.CapsUpdate[](${cfg.length}); + `function capsUpdates() public pure override returns (IAaveV3ConfigEngine.CapsUpdate[] memory) { + IAaveV3ConfigEngine.CapsUpdate[] memory capsUpdate = new IAaveV3ConfigEngine.CapsUpdate[](${ + cfg.length + }); ${cfg .map( - (cfg, ix) => `capsUpdate[${ix}] = IEngine.CapsUpdate({ + (cfg, ix) => `capsUpdate[${ix}] = IAaveV3ConfigEngine.CapsUpdate({ asset: ${cfg.asset}, supplyCap: ${cfg.supplyCap}, borrowCap: ${cfg.borrowCap} diff --git a/generator/features/collateralsUpdates.ts b/generator/features/collateralsUpdates.ts index c6327cc6c..b34f6c4ce 100644 --- a/generator/features/collateralsUpdates.ts +++ b/generator/features/collateralsUpdates.ts @@ -54,14 +54,14 @@ export const collateralsUpdates: FeatureModule = { const response: CodeArtifact = { code: { fn: [ - `function collateralsUpdates() public pure override returns (IEngine.CollateralUpdate[] memory) { - IEngine.CollateralUpdate[] memory collateralUpdate = new IEngine.CollateralUpdate[](${ + `function collateralsUpdates() public pure override returns (IAaveV3ConfigEngine.CollateralUpdate[] memory) { + IAaveV3ConfigEngine.CollateralUpdate[] memory collateralUpdate = new IAaveV3ConfigEngine.CollateralUpdate[](${ cfg.length }); ${cfg .map( - (cfg, ix) => `collateralUpdate[${ix}] = IEngine.CollateralUpdate({ + (cfg, ix) => `collateralUpdate[${ix}] = IAaveV3ConfigEngine.CollateralUpdate({ asset: ${cfg.asset}, ltv: ${cfg.ltv}, liqThreshold: ${cfg.liqThreshold}, diff --git a/generator/features/eModesAssets.ts b/generator/features/eModesAssets.ts index 5409e1b1f..6ec33d3d3 100644 --- a/generator/features/eModesAssets.ts +++ b/generator/features/eModesAssets.ts @@ -36,14 +36,14 @@ export const eModeAssets: FeatureModule = { const response: CodeArtifact = { code: { fn: [ - `function assetsEModeUpdates() public pure override returns (IEngine.AssetEModeUpdate[] memory) { - IEngine.AssetEModeUpdate[] memory assetEModeUpdates = new IEngine.AssetEModeUpdate[](${ + `function assetsEModeUpdates() public pure override returns (IAaveV3ConfigEngine.AssetEModeUpdate[] memory) { + IAaveV3ConfigEngine.AssetEModeUpdate[] memory assetEModeUpdates = new IAaveV3ConfigEngine.AssetEModeUpdate[](${ cfg.length }); ${cfg .map( - (cfg, ix) => `assetEModeUpdates[${ix}] = IEngine.AssetEModeUpdate({ + (cfg, ix) => `assetEModeUpdates[${ix}] = IAaveV3ConfigEngine.AssetEModeUpdate({ asset: ${cfg.asset}, eModeCategory: ${cfg.eModeCategory} });` diff --git a/generator/features/eModesUpdates.ts b/generator/features/eModesUpdates.ts index a6c8d4871..8a6ff2455 100644 --- a/generator/features/eModesUpdates.ts +++ b/generator/features/eModesUpdates.ts @@ -44,14 +44,14 @@ export const eModeUpdates: FeatureModule = { const response: CodeArtifact = { code: { fn: [ - `function eModeCategoriesUpdates() public pure override returns (IEngine.EModeCategoryUpdate[] memory) { - IEngine.EModeCategoryUpdate[] memory eModeUpdates = new IEngine.EModeCategoryUpdate[](${ + `function eModeCategoriesUpdates() public pure override returns (IAaveV3ConfigEngine.EModeCategoryUpdate[] memory) { + IAaveV3ConfigEngine.EModeCategoryUpdate[] memory eModeUpdates = new IAaveV3ConfigEngine.EModeCategoryUpdate[](${ cfg.length }); ${cfg .map( - (cfg, ix) => `eModeUpdates[${ix}] = IEngine.EModeCategoryUpdate({ + (cfg, ix) => `eModeUpdates[${ix}] = IAaveV3ConfigEngine.EModeCategoryUpdate({ eModeCategory: ${cfg.eModeCategory}, ltv: ${cfg.ltv}, liqThreshold: ${cfg.liqThreshold}, diff --git a/generator/features/priceFeedsUpdates.ts b/generator/features/priceFeedsUpdates.ts index 6bac2d2fe..42e1b5c2b 100644 --- a/generator/features/priceFeedsUpdates.ts +++ b/generator/features/priceFeedsUpdates.ts @@ -30,14 +30,14 @@ export const priceFeedsUpdates: FeatureModule = { const response: CodeArtifact = { code: { fn: [ - `function priceFeedsUpdates() public pure override returns (IEngine.PriceFeedUpdate[] memory) { - IEngine.PriceFeedUpdate[] memory priceFeedsUpdates = new IEngine.PriceFeedUpdate[](${ + `function priceFeedsUpdates() public pure override returns (IAaveV3ConfigEngine.PriceFeedUpdate[] memory) { + IAaveV3ConfigEngine.PriceFeedUpdate[] memory priceFeedsUpdates = new IAaveV3ConfigEngine.PriceFeedUpdate[](${ cfg.length }); ${cfg .map( - (cfg, ix) => `priceFeedsUpdates[${ix}] = IEngine.PriceFeedUpdate({ + (cfg, ix) => `priceFeedsUpdates[${ix}] = IAaveV3ConfigEngine.PriceFeedUpdate({ asset: ${cfg.asset}, priceFeed: ${cfg.priceFeed} });` diff --git a/generator/features/rateUpdates.ts b/generator/features/rateUpdates.ts index 4f65a5764..68e1b4152 100644 --- a/generator/features/rateUpdates.ts +++ b/generator/features/rateUpdates.ts @@ -85,14 +85,14 @@ export const rateUpdatesV2: FeatureModule = { public pure override - returns (IEngine.RateStrategyUpdate[] memory) + returns (IAaveV2ConfigEngine.RateStrategyUpdate[] memory) { - IEngine.RateStrategyUpdate[] memory rateStrategies = new IEngine.RateStrategyUpdate[](${ + IAaveV2ConfigEngine.RateStrategyUpdate[] memory rateStrategies = new IAaveV2ConfigEngine.RateStrategyUpdate[](${ cfg.length }); ${cfg .map( - (cfg, ix) => `rateStrategies[${ix}] = IEngine.RateStrategyUpdate({ + (cfg, ix) => `rateStrategies[${ix}] = IAaveV2ConfigEngine.RateStrategyUpdate({ asset: ${cfg.asset}, params: Rates.RateStrategyParams({ optimalUtilizationRate: ${cfg.params.optimalUtilizationRate}, @@ -140,14 +140,14 @@ export const rateUpdatesV3: FeatureModule = { public pure override - returns (IEngine.RateStrategyUpdate[] memory) + returns (IAaveV3ConfigEngine.RateStrategyUpdate[] memory) { - IEngine.RateStrategyUpdate[] memory rateStrategies = new IEngine.RateStrategyUpdate[](${ + IAaveV3ConfigEngine.RateStrategyUpdate[] memory rateStrategies = new IAaveV3ConfigEngine.RateStrategyUpdate[](${ cfg.length }); ${cfg .map( - (cfg, ix) => `rateStrategies[${ix}] = IEngine.RateStrategyUpdate({ + (cfg, ix) => `rateStrategies[${ix}] = IAaveV3ConfigEngine.RateStrategyUpdate({ asset: ${cfg.asset}, params: Rates.RateStrategyParams({ optimalUsageRatio: ${cfg.params.optimalUtilizationRate}, diff --git a/lib/aave-helpers b/lib/aave-helpers index 8f3870f8f..707ad78ff 160000 --- a/lib/aave-helpers +++ b/lib/aave-helpers @@ -1 +1 @@ -Subproject commit 8f3870f8fc162d356062f16b42d2769145b3b696 +Subproject commit 707ad78ffd9f58fedd85a029f32ac52ef74af15a diff --git a/lib/forge-std b/lib/forge-std deleted file mode 160000 index f73c73d20..000000000 --- a/lib/forge-std +++ /dev/null @@ -1 +0,0 @@ -Subproject commit f73c73d2018eb6a111f35e4dae7b4f27401e9421 diff --git a/src/20231024_AaveV3Ethereum_Test/AaveV3Ethereum_Test_20231024.sol b/src/20231024_AaveV3Ethereum_Test/AaveV3Ethereum_Test_20231024.sol new file mode 100644 index 000000000..6523e9bdd --- /dev/null +++ b/src/20231024_AaveV3Ethereum_Test/AaveV3Ethereum_Test_20231024.sol @@ -0,0 +1,26 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import {AaveV3EthereumAssets} from 'aave-address-book/AaveV3Ethereum.sol'; +import {AaveV3PayloadEthereum} from 'aave-helpers/v3-config-engine/AaveV3PayloadEthereum.sol'; +import {IAaveV3ConfigEngine} from 'aave-helpers/v3-config-engine/IAaveV3ConfigEngine.sol'; + +/** + * @title Test + * @author BGD + * - Snapshot: link + * - Discussion: link + */ +contract AaveV3Ethereum_Test_20231024 is AaveV3PayloadEthereum { + function capsUpdates() public pure override returns (IAaveV3ConfigEngine.CapsUpdate[] memory) { + IAaveV3ConfigEngine.CapsUpdate[] memory capsUpdate = new IAaveV3ConfigEngine.CapsUpdate[](1); + + capsUpdate[0] = IAaveV3ConfigEngine.CapsUpdate({ + asset: AaveV3EthereumAssets.wstETH_UNDERLYING, + supplyCap: 10_000_000, + borrowCap: 100_000 + }); + + return capsUpdate; + } +} diff --git a/src/20231024_AaveV3Ethereum_Test/AaveV3Ethereum_Test_20231024.t.sol b/src/20231024_AaveV3Ethereum_Test/AaveV3Ethereum_Test_20231024.t.sol new file mode 100644 index 000000000..3267fcf13 --- /dev/null +++ b/src/20231024_AaveV3Ethereum_Test/AaveV3Ethereum_Test_20231024.t.sol @@ -0,0 +1,28 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import {AaveV3Ethereum} from 'aave-address-book/AaveV3Ethereum.sol'; + +import 'forge-std/Test.sol'; +import {ProtocolV3TestBase, ReserveConfig} from 'aave-helpers/ProtocolV3TestBase.sol'; +import {AaveV3Ethereum_Test_20231024} from './AaveV3Ethereum_Test_20231024.sol'; + +/** + * @dev Test for AaveV3Ethereum_Test_20231024 + * command: make test-contract filter=AaveV3Ethereum_Test_20231024 + */ +contract AaveV3Ethereum_Test_20231024_Test is ProtocolV3TestBase { + AaveV3Ethereum_Test_20231024 internal proposal; + + function setUp() public { + vm.createSelectFork(vm.rpcUrl('mainnet'), 18420791); + proposal = new AaveV3Ethereum_Test_20231024(); + } + + /** + * @dev executes the generic test suite including e2e and config snapshots + */ + function test_defaultProposalExecution() public { + defaultTest('AaveV3Ethereum_Test_20231024', AaveV3Ethereum.POOL, address(proposal)); + } +} diff --git a/src/20231024_AaveV3Ethereum_Test/Test.md b/src/20231024_AaveV3Ethereum_Test/Test.md new file mode 100644 index 000000000..a7a499cd4 --- /dev/null +++ b/src/20231024_AaveV3Ethereum_Test/Test.md @@ -0,0 +1,22 @@ +--- +title: "Test" +author: "BGD" +discussions: "link" +--- + +## Simple Summary + +## Motivation + +## Specification + +## References + +- Implementation: [AaveV3Ethereum](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20231024_AaveV3Ethereum_Test/AaveV3Ethereum_Test_20231024.sol) +- Tests: [AaveV3Ethereum](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20231024_AaveV3Ethereum_Test/AaveV3Ethereum_Test_20231024.t.sol) +- [Snapshot](link) +- [Discussion](link) + +## Copyright + +Copyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/). diff --git a/src/20231024_AaveV3Ethereum_Test/Test_20231024.s.sol b/src/20231024_AaveV3Ethereum_Test/Test_20231024.s.sol new file mode 100644 index 000000000..54774de98 --- /dev/null +++ b/src/20231024_AaveV3Ethereum_Test/Test_20231024.s.sol @@ -0,0 +1,48 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import {GovV3Helpers, IPayloadsControllerCore, PayloadsControllerUtils} from 'aave-helpers/GovV3Helpers.sol'; +import {EthereumScript} from 'aave-helpers/ScriptUtils.sol'; +import {AaveV3Ethereum_Test_20231024} from './AaveV3Ethereum_Test_20231024.sol'; + +/** + * @dev Deploy Ethereum + * command: make deploy-ledger contract=src/20231024_AaveV3Ethereum_Test/Test_20231024.s.sol:DeployEthereum chain=mainnet + */ +contract DeployEthereum is EthereumScript { + function run() external broadcast { + // deploy payloads + AaveV3Ethereum_Test_20231024 payload0 = new AaveV3Ethereum_Test_20231024(); + + // compose action + IPayloadsControllerCore.ExecutionAction[] + memory actions = new IPayloadsControllerCore.ExecutionAction[](1); + actions[0] = GovV3Helpers.buildAction(address(payload0)); + + // register action at payloadsController + GovV3Helpers.createPayload(actions); + } +} + +/** + * @dev Create Proposal + * command: make deploy-ledger contract=src/20231024_AaveV3Ethereum_Test/Test_20231024.s.sol:CreateProposal chain=mainnet + */ +contract CreateProposal is EthereumScript { + function run() external broadcast { + // create payloads + PayloadsControllerUtils.Payload[] memory payloads = new PayloadsControllerUtils.Payload[](1); + + // compose actions for validation + IPayloadsControllerCore.ExecutionAction[] + memory actionsEthereum = new IPayloadsControllerCore.ExecutionAction[](1); + actionsEthereum[0] = GovV3Helpers.buildAction(address(0)); + payloads[0] = GovV3Helpers.buildMainnetPayload(vm, actionsEthereum); + + // create proposal + GovV3Helpers.createProposal2_5( + payloads, + GovV3Helpers.ipfsHashFile(vm, 'src/20231024_AaveV3Ethereum_Test/Test.md') + ); + } +} diff --git a/src/20231024_AaveV3Ethereum_Test/config.json b/src/20231024_AaveV3Ethereum_Test/config.json new file mode 100644 index 000000000..4bffb50dc --- /dev/null +++ b/src/20231024_AaveV3Ethereum_Test/config.json @@ -0,0 +1,29 @@ +{ + "rootOptions": { + "pools": [ + "AaveV3Ethereum" + ], + "title": "Test", + "shortName": "Test", + "date": "20231024", + "author": "BGD", + "discussion": "link", + "snapshot": "link" + }, + "poolOptions": { + "AaveV3Ethereum": { + "configs": { + "CAPS_UPDATE": [ + { + "asset": "AaveV3EthereumAssets.wstETH_UNDERLYING", + "supplyCap": "10_000_000", + "borrowCap": "100_000" + } + ] + }, + "features": [ + "CAPS_UPDATE" + ] + } + } +} \ No newline at end of file