Skip to content

Commit

Permalink
fix: update aave-helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
sakulstra committed Oct 24, 2023
1 parent 90c81d9 commit 4af3d37
Show file tree
Hide file tree
Showing 17 changed files with 201 additions and 45 deletions.
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -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
17 changes: 9 additions & 8 deletions generator/features/__snapshots__/assetListing.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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')
);
Expand All @@ -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,
Expand Down
18 changes: 10 additions & 8 deletions generator/features/assetListing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,14 @@ export const assetListing: FeatureModule<Listing[]> = {
`${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},
Expand Down Expand Up @@ -186,15 +188,15 @@ export const assetListingCustom: FeatureModule<ListingWithCustomImpl[]> = {
`${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},
Expand Down Expand Up @@ -224,7 +226,7 @@ export const assetListingCustom: FeatureModule<ListingWithCustomImpl[]> = {
optimalStableToTotalDebtRatio: ${cfg.base.rateStrategyParams.optimalStableToTotalDebtRatio}
})
}),
IEngine.TokenImplementations({
IAaveV3ConfigEngine.TokenImplementations({
aToken: ${cfg.implementations.aToken},
vToken: ${cfg.implementations.vToken},
sToken: ${cfg.implementations.sToken}
Expand Down
8 changes: 5 additions & 3 deletions generator/features/borrowsUpdates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,14 @@ export const borrowsUpdates: FeatureModule<BorrowUpdates> = {
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},
Expand Down
8 changes: 5 additions & 3 deletions generator/features/capsUpdates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,14 @@ export const capsUpdates: FeatureModule<CapsUpdates> = {
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}
Expand Down
6 changes: 3 additions & 3 deletions generator/features/collateralsUpdates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ export const collateralsUpdates: FeatureModule<CollateralUpdates> = {
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},
Expand Down
6 changes: 3 additions & 3 deletions generator/features/eModesAssets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ export const eModeAssets: FeatureModule<EmodeAssetUpdates> = {
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}
});`
Expand Down
6 changes: 3 additions & 3 deletions generator/features/eModesUpdates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ export const eModeUpdates: FeatureModule<EmodeUpdates> = {
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},
Expand Down
6 changes: 3 additions & 3 deletions generator/features/priceFeedsUpdates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ export const priceFeedsUpdates: FeatureModule<PriceFeedUpdate[]> = {
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}
});`
Expand Down
12 changes: 6 additions & 6 deletions generator/features/rateUpdates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,14 @@ export const rateUpdatesV2: FeatureModule<RateStrategyUpdate[]> = {
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},
Expand Down Expand Up @@ -140,14 +140,14 @@ export const rateUpdatesV3: FeatureModule<RateStrategyUpdate[]> = {
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},
Expand Down
2 changes: 1 addition & 1 deletion lib/aave-helpers
1 change: 0 additions & 1 deletion lib/forge-std
Submodule forge-std deleted from f73c73
26 changes: 26 additions & 0 deletions src/20231024_AaveV3Ethereum_Test/AaveV3Ethereum_Test_20231024.sol
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -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));
}
}
22 changes: 22 additions & 0 deletions src/20231024_AaveV3Ethereum_Test/Test.md
Original file line number Diff line number Diff line change
@@ -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/).
48 changes: 48 additions & 0 deletions src/20231024_AaveV3Ethereum_Test/Test_20231024.s.sol
Original file line number Diff line number Diff line change
@@ -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')
);
}
}
Loading

0 comments on commit 4af3d37

Please sign in to comment.