Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: refactor address input #31

Merged
merged 12 commits into from
Nov 3, 2023
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