Skip to content

Commit

Permalink
refactor: refactor address input (#31)
Browse files Browse the repository at this point in the history
* feat: refactor address input

* fix: update snapshot

* fix: refactor address input

* fix: update snapshots

* fix: remove unused code

* refactor: move asset select as well

* fix: remove test

* fix: also migrate assets select

* fix: add priceFeedsTest

* fix: patch some issues in eMode updates

* fix: remove accidentally comitted test

* fix: bump highest eMode
  • Loading branch information
sakulstra authored Nov 3, 2023
1 parent efdbcbf commit b8d4bbb
Show file tree
Hide file tree
Showing 23 changed files with 549 additions and 198 deletions.
4 changes: 4 additions & 0 deletions generator/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,7 @@ export const CHAIN_TO_CHAIN_OBJECT = {
Bsc: bsc,
Gnosis: gnosis,
};

export function flagAsRequired(message: string, required?: boolean) {
return required ? `${message}*` : message;
}
45 changes: 23 additions & 22 deletions generator/features/__snapshots__/assetListing.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -50,23 +50,23 @@ Copyright and related rights waived via [CC0](https://creativecommons.org/public
\\"liqBonus\\": \\"5_00\\",
\\"debtCeiling\\": \\"100_000\\",
\\"liqProtocolFee\\": \\"20_00\\",
\\"enabledToBorrow\\": \\"ENABLED\\",
\\"flashloanable\\": \\"ENABLED\\",
\\"stableRateModeEnabled\\": \\"DISABLED\\",
\\"borrowableInIsolation\\": \\"DISABLED\\",
\\"withSiloedBorrowing\\": \\"DISABLED\\",
\\"enabledToBorrow\\": \\"EngineFlags.ENABLED\\",
\\"flashloanable\\": \\"EngineFlags.ENABLED\\",
\\"stableRateModeEnabled\\": \\"EngineFlags.DISABLED\\",
\\"borrowableInIsolation\\": \\"EngineFlags.DISABLED\\",
\\"withSiloedBorrowing\\": \\"EngineFlags.DISABLED\\",
\\"reserveFactor\\": \\"20_00\\",
\\"supplyCap\\": \\"10_000\\",
\\"borrowCap\\": \\"5_000\\",
\\"rateStrategyParams\\": {
\\"optimalUtilizationRate\\": \\"_bpsToRay(80_00)\\",
\\"baseVariableBorrowRate\\": \\"_bpsToRay(0_00)\\",
\\"baseVariableBorrowRate\\": \\"_bpsToRay(0)\\",
\\"variableRateSlope1\\": \\"_bpsToRay(10_00)\\",
\\"variableRateSlope2\\": \\"_bpsToRay(100_00)\\",
\\"stableRateSlope1\\": \\"_bpsToRay(10_00)\\",
\\"stableRateSlope2\\": \\"_bpsToRay(100_00)\\",
\\"baseStableRateOffset\\": \\"_bpsToRay(1_00)\\",
\\"stableRateExcessOffset\\": \\"_bpsToRay()\\",
\\"stableRateExcessOffset\\": \\"_bpsToRay(0)\\",
\\"optimalStableToTotalDebtRatio\\": \\"_bpsToRay(10_00)\\"
},
\\"eModeCategory\\": \\"AaveV3EthereumEModes.NONE\\",
Expand All @@ -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 {EngineFlags} from 'aave-helpers/v3-config-engine/EngineFlags.sol';
import {IAaveV3ConfigEngine} from 'aave-helpers/v3-config-engine/IAaveV3ConfigEngine.sol';
import {IV3RateStrategyFactory} from 'aave-helpers/v3-config-engine/IV3RateStrategyFactory.sol';
import {IERC20} from 'solidity-utils/contracts/oz-common/interfaces/IERC20.sol';
Expand Down Expand Up @@ -118,11 +119,11 @@ contract AaveV3Ethereum_Test_20231023 is AaveV3PayloadEthereum {
assetSymbol: 'PSP',
priceFeed: 0x72AFAECF99C9d9C8215fF44C77B94B99C28741e8,
eModeCategory: AaveV3EthereumEModes.NONE,
enabledToBorrow: ENABLED,
stableRateModeEnabled: DISABLED,
borrowableInIsolation: DISABLED,
withSiloedBorrowing: DISABLED,
flashloanable: ENABLED,
enabledToBorrow: EngineFlags.ENABLED,
stableRateModeEnabled: EngineFlags.DISABLED,
borrowableInIsolation: EngineFlags.DISABLED,
withSiloedBorrowing: EngineFlags.DISABLED,
flashloanable: EngineFlags.ENABLED,
ltv: 40_00,
liqThreshold: 50_00,
liqBonus: 5_00,
Expand All @@ -133,13 +134,13 @@ contract AaveV3Ethereum_Test_20231023 is AaveV3PayloadEthereum {
liqProtocolFee: 20_00,
rateStrategyParams: IV3RateStrategyFactory.RateStrategyParams({
optimalUsageRatio: _bpsToRay(80_00),
baseVariableBorrowRate: _bpsToRay(0_00),
baseVariableBorrowRate: _bpsToRay(0),
variableRateSlope1: _bpsToRay(10_00),
variableRateSlope2: _bpsToRay(100_00),
stableRateSlope1: _bpsToRay(10_00),
stableRateSlope2: _bpsToRay(100_00),
baseStableRateOffset: _bpsToRay(1_00),
stableRateExcessOffset: _bpsToRay(),
stableRateExcessOffset: _bpsToRay(0),
optimalStableToTotalDebtRatio: _bpsToRay(10_00)
})
});
Expand Down Expand Up @@ -167,7 +168,7 @@ contract AaveV3Ethereum_Test_20231023_Test is ProtocolV3TestBase {
AaveV3Ethereum_Test_20231023 internal proposal;
function setUp() public {
vm.createSelectFork(vm.rpcUrl('mainnet'), 18484119);
vm.createSelectFork(vm.rpcUrl('mainnet'), 18487480);
proposal = new AaveV3Ethereum_Test_20231023();
}
Expand Down Expand Up @@ -262,11 +263,11 @@ exports[`feature: assetListing > should return reasonable code 1`] = `
assetSymbol: \\"PSP\\",
priceFeed: 0x72AFAECF99C9d9C8215fF44C77B94B99C28741e8,
eModeCategory: AaveV3EthereumEModes.NONE,
enabledToBorrow: ENABLED,
stableRateModeEnabled: DISABLED,
borrowableInIsolation: DISABLED,
withSiloedBorrowing: DISABLED,
flashloanable: ENABLED,
enabledToBorrow: EngineFlags.ENABLED,
stableRateModeEnabled: EngineFlags.DISABLED,
borrowableInIsolation: EngineFlags.DISABLED,
withSiloedBorrowing: EngineFlags.DISABLED,
flashloanable: EngineFlags.ENABLED,
ltv: 40_00,
liqThreshold: 50_00,
liqBonus: 5_00,
Expand All @@ -277,13 +278,13 @@ exports[`feature: assetListing > should return reasonable code 1`] = `
liqProtocolFee: 20_00,
rateStrategyParams: IV3RateStrategyFactory.RateStrategyParams({
optimalUsageRatio: _bpsToRay(80_00),
baseVariableBorrowRate: _bpsToRay(0_00),
baseVariableBorrowRate: _bpsToRay(0),
variableRateSlope1: _bpsToRay(10_00),
variableRateSlope2: _bpsToRay(100_00),
stableRateSlope1: _bpsToRay(10_00),
stableRateSlope2: _bpsToRay(100_00),
baseStableRateOffset: _bpsToRay(1_00),
stableRateExcessOffset: _bpsToRay(),
stableRateExcessOffset: _bpsToRay(0),
optimalStableToTotalDebtRatio: _bpsToRay(10_00)
})
});
Expand Down
192 changes: 192 additions & 0 deletions generator/features/__snapshots__/priceFeedsUpdate.spec.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`feature: priceFeedsUpdates > should properly generate files 1`] = `
{
"aip": "---
title: \\"test\\"
author: \\"test\\"
discussions: \\"test\\"
---
## Simple Summary
## Motivation
## Specification
## References
- Implementation: [AaveV3Ethereum](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20231023_AaveV3Ethereum_Test/AaveV3Ethereum_Test_20231023.sol)
- Tests: [AaveV3Ethereum](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20231023_AaveV3Ethereum_Test/AaveV3Ethereum_Test_20231023.t.sol)
- [Snapshot](test)
- [Discussion](test)
## Copyright
Copyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/).
",
"jsonConfig": "{
\\"rootOptions\\": {
\\"pools\\": [
\\"AaveV3Ethereum\\"
],
\\"title\\": \\"test\\",
\\"shortName\\": \\"Test\\",
\\"date\\": \\"20231023\\",
\\"author\\": \\"test\\",
\\"discussion\\": \\"test\\",
\\"snapshot\\": \\"test\\"
},
\\"poolOptions\\": {
\\"AaveV3Ethereum\\": {
\\"configs\\": {
\\"PRICE_FEEDS_UPDATE\\": [
{
\\"asset\\": \\"DAI\\",
\\"priceFeed\\": \\"0xae7ab96520de3a18e5e111b5eaab095312d7fe84\\"
}
]
},
\\"features\\": [
\\"PRICE_FEEDS_UPDATE\\"
]
}
}
}",
"payloads": [
{
"contractName": "AaveV3Ethereum_Test_20231023",
"payload": "// 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 test
* - Snapshot: test
* - Discussion: test
*/
contract AaveV3Ethereum_Test_20231023 is AaveV3PayloadEthereum {
function priceFeedsUpdates()
public
pure
override
returns (IAaveV3ConfigEngine.PriceFeedUpdate[] memory)
{
IAaveV3ConfigEngine.PriceFeedUpdate[]
memory priceFeedUpdates = new IAaveV3ConfigEngine.PriceFeedUpdate[](1);
priceFeedUpdates[0] = IAaveV3ConfigEngine.PriceFeedUpdate({
asset: AaveV3EthereumAssets.DAI_UNDERLYING,
priceFeed: 0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84
});
return priceFeedUpdates;
}
}
",
"test": "// 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_20231023} from './AaveV3Ethereum_Test_20231023.sol';
/**
* @dev Test for AaveV3Ethereum_Test_20231023
* command: make test-contract filter=AaveV3Ethereum_Test_20231023
*/
contract AaveV3Ethereum_Test_20231023_Test is ProtocolV3TestBase {
AaveV3Ethereum_Test_20231023 internal proposal;
function setUp() public {
vm.createSelectFork(vm.rpcUrl('mainnet'), 18487480);
proposal = new AaveV3Ethereum_Test_20231023();
}
/**
* @dev executes the generic test suite including e2e and config snapshots
*/
function test_defaultProposalExecution() public {
defaultTest('AaveV3Ethereum_Test_20231023', AaveV3Ethereum.POOL, address(proposal));
}
}
",
},
],
"script": "// 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_20231023} from './AaveV3Ethereum_Test_20231023.sol';
/**
* @dev Deploy Ethereum
* command: make deploy-ledger contract=src/20231023_AaveV3Ethereum_Test/Test_20231023.s.sol:DeployEthereum chain=mainnet
*/
contract DeployEthereum is EthereumScript {
function run() external broadcast {
// deploy payloads
AaveV3Ethereum_Test_20231023 payload0 = new AaveV3Ethereum_Test_20231023();
// 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/20231023_AaveV3Ethereum_Test/Test_20231023.s.sol:CreateProposal chain=mainnet
*/
contract CreateProposal is EthereumScript {
function run() external {
// 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
vm.startBroadcast();
GovV3Helpers.createProposal2_5(
payloads,
GovV3Helpers.ipfsHashFile(vm, 'src/20231023_AaveV3Ethereum_Test/Test.md')
);
}
}
",
}
`;
exports[`feature: priceFeedsUpdates > should return reasonable code 1`] = `
{
"code": {
"fn": [
"function priceFeedsUpdates() public pure override returns (IAaveV3ConfigEngine.PriceFeedUpdate[] memory) {
IAaveV3ConfigEngine.PriceFeedUpdate[] memory priceFeedUpdates = new IAaveV3ConfigEngine.PriceFeedUpdate[](1);
priceFeedUpdates[0] = IAaveV3ConfigEngine.PriceFeedUpdate({
asset: AaveV3EthereumAssets.DAI_UNDERLYING,
priceFeed: 0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84
});
return priceFeedUpdates;
}",
],
},
}
`;
Loading

1 comment on commit b8d4bbb

@github-actions
Copy link

Choose a reason for hiding this comment

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

Foundry report

forge 0.2.0 (09fe3e0 2023-11-02T00:21:11.736779974Z)
Build log
Compiling 111 files with 0.8.19
Solc 0.8.19 finished in 19.29s
Compiler run successful with warnings:
Warning (5667): Unused function parameter. Remove or comment out the variable name to silence this warning.
   --> lib/aave-helpers/src/GovV3Helpers.sol:734:5:
    |
734 |     address votingPortal
    |     ^^^^^^^^^^^^^^^^^^^^

| Contract                                     | Size (kB) | Margin (kB) |
|----------------------------------------------|-----------|-------------|
| AaveGovernanceV2                             | 0.086     | 24.49       |
| AaveV2Avalanche                              | 0.086     | 24.49       |
| AaveV2AvalancheAssets                        | 0.086     | 24.49       |
| AaveV2Ethereum                               | 0.086     | 24.49       |
| AaveV2EthereumAMM                            | 0.086     | 24.49       |
| AaveV2EthereumAMMAssets                      | 0.086     | 24.49       |
| AaveV2EthereumAssets                         | 0.086     | 24.49       |
| AaveV2Polygon                                | 0.086     | 24.49       |
| AaveV2PolygonAssets                          | 0.086     | 24.49       |
| AaveV3Arbitrum                               | 0.086     | 24.49       |
| AaveV3ArbitrumAssets                         | 0.086     | 24.49       |
| AaveV3ArbitrumEModes                         | 0.086     | 24.49       |
| AaveV3Avalanche                              | 0.086     | 24.49       |
| AaveV3AvalancheAssets                        | 0.086     | 24.49       |
| AaveV3AvalancheEModes                        | 0.086     | 24.49       |
| AaveV3Ethereum                               | 0.086     | 24.49       |
| AaveV3EthereumAssets                         | 0.086     | 24.49       |
| AaveV3EthereumEModes                         | 0.086     | 24.49       |
| AaveV3Ethereum_ACIPhaseII_20231029           | 0.682     | 23.894      |
| AaveV3Fantom                                 | 0.086     | 24.49       |
| AaveV3FantomAssets                           | 0.086     | 24.49       |
| AaveV3FantomEModes                           | 0.086     | 24.49       |
| AaveV3Gnosis                                 | 0.086     | 24.49       |
| AaveV3GnosisAssets                           | 0.086     | 24.49       |
| AaveV3GnosisEModes                           | 0.086     | 24.49       |
| AaveV3Gnosis_AaveV3GnosisActivation_20231026 | 8.802     | 15.774      |
| AaveV3Harmony                                | 0.086     | 24.49       |
| AaveV3HarmonyAssets                          | 0.086     | 24.49       |
| AaveV3HarmonyEModes                          | 0.086     | 24.49       |
| AaveV3Optimism                               | 0.086     | 24.49       |
| AaveV3OptimismAssets                         | 0.086     | 24.49       |
| AaveV3OptimismEModes                         | 0.086     | 24.49       |
| AaveV3Polygon                                | 0.086     | 24.49       |
| AaveV3PolygonAssets                          | 0.086     | 24.49       |
| AaveV3PolygonEModes                          | 0.086     | 24.49       |
| Address                                      | 0.086     | 24.49       |
| ChainHelpers                                 | 0.086     | 24.49       |
| ChainIds                                     | 0.086     | 24.49       |
| ConfiguratorInputTypes                       | 0.086     | 24.49       |
| Create2Utils                                 | 0.164     | 24.412      |
| DataTypes                                    | 0.086     | 24.49       |
| EngineFlags                                  | 0.086     | 24.49       |
| Errors                                       | 4.714     | 19.862      |
| GovHelpers                                   | 0.086     | 24.49       |
| GovV3Helpers                                 | 0.086     | 24.49       |
| GovV3StorageHelpers                          | 0.086     | 24.49       |
| GovernanceV3Arbitrum                         | 0.086     | 24.49       |
| GovernanceV3Avalanche                        | 0.086     | 24.49       |
| GovernanceV3BNB                              | 0.086     | 24.49       |
| GovernanceV3Base                             | 0.086     | 24.49       |
| GovernanceV3Ethereum                         | 0.086     | 24.49       |
| GovernanceV3Gnosis                           | 0.086     | 24.49       |
| GovernanceV3Metis                            | 0.086     | 24.49       |
| GovernanceV3Optimism                         | 0.086     | 24.49       |
| GovernanceV3Polygon                          | 0.086     | 24.49       |
| IpfsUtils                                    | 0.086     | 24.49       |
| MiscEthereum                                 | 0.086     | 24.49       |
| MockExecutor                                 | 0.437     | 24.139      |
| PayloadsControllerUtils                      | 0.086     | 24.49       |
| ProxyHelpers                                 | 0.086     | 24.49       |
| ReserveConfiguration                         | 0.171     | 24.405      |
| SafeERC20                                    | 0.086     | 24.49       |
| StdStyle                                     | 0.086     | 24.49       |
| StorageHelpers                               | 0.086     | 24.49       |
| WadRayMath                                   | 0.086     | 24.49       |
| console                                      | 0.086     | 24.49       |
| console2                                     | 0.086     | 24.49       |
| safeconsole                                  | 0.086     | 24.49       |
| stdError                                     | 0.591     | 23.985      |
| stdJson                                      | 0.086     | 24.49       |
| stdMath                                      | 0.086     | 24.49       |
| stdStorage                                   | 0.086     | 24.49       |
| stdStorageSafe                               | 0.086     | 24.49       |
Test success 🌈

Please sign in to comment.