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

feat: gnosis activation proposal #8

Merged
merged 46 commits into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
08c9051
fix: typo
brotherlymite Oct 25, 2023
50339c5
chore: fix text
brotherlymite Oct 25, 2023
c7a3381
feat: add new e-mode category via the generator
brotherlymite Oct 25, 2023
5ad1c71
fix: KEEP_CURRENT_STRING
brotherlymite Oct 25, 2023
18a73cd
fix: emode label
brotherlymite Oct 25, 2023
a611687
fix: generator booleanSelect ENABLED DISABLED
brotherlymite Oct 25, 2023
5ae475a
fix: collateral updates code artifacts
brotherlymite Oct 25, 2023
85b67fa
refactor: eModesUpdates
brotherlymite Oct 25, 2023
b6632d1
fix: lint
brotherlymite Oct 25, 2023
1e69d05
fix: generator shadows an existing priceFeedsUpdates var
brotherlymite Oct 25, 2023
60aa9c8
fix: v3 config engine rates import generator
brotherlymite Oct 25, 2023
11ef02c
fix: v2 v3 engine rates import generator
brotherlymite Oct 25, 2023
6373d7e
forge install: aave-address-book
brotherlymite Oct 25, 2023
754e245
chore: update address book
brotherlymite Oct 25, 2023
008a61f
fix: use correct contract an asset listings
sakulstra Oct 25, 2023
8aa8b71
fix: some minor patches
sakulstra Oct 25, 2023
9675c68
fix: remapping
brotherlymite Oct 26, 2023
28461fd
chore: some cleanup
brotherlymite Oct 26, 2023
cfe6ce9
fix: do not revert when no e-mode category exists on the pool
brotherlymite Oct 26, 2023
105498c
feat: initial gnosis listing payload
brotherlymite Oct 26, 2023
2e88263
chore: update aave-helpers lib
brotherlymite Oct 26, 2023
0d38c52
fix: update payloads and add reports
brotherlymite Oct 26, 2023
23512d7
fix: tests
brotherlymite Oct 26, 2023
5fd9ff3
fix: token amount
brotherlymite Oct 26, 2023
75d3a43
feat: add sDAI
brotherlymite Oct 26, 2023
712d99e
feat: add aip text
brotherlymite Oct 26, 2023
90ed0a3
fix: lint
brotherlymite Oct 26, 2023
9a879b2
fix: add more tests
brotherlymite Oct 27, 2023
0f1893e
fix: add sDAI to aip text table
brotherlymite Oct 27, 2023
538ba70
fix: use forceApprove
brotherlymite Oct 27, 2023
67bcb07
chore: update test block
brotherlymite Oct 30, 2023
41ea61e
fix: ci
brotherlymite Oct 30, 2023
b5141e0
Merge branch 'main' into feat/gnosis
brotherlymite Oct 30, 2023
1b2a1bf
refactor: supply
brotherlymite Oct 30, 2023
5eebde2
fix: make guardian the pool admin
brotherlymite Oct 30, 2023
552dfb9
chore: update aave helpers lib
brotherlymite Oct 31, 2023
50dde6e
Update src/20231026_AaveV3Gnosis_AaveV3GnosisActivation/AaveV3GnosisA…
brotherlymite Oct 31, 2023
46ddaad
fix: update latest risk params
brotherlymite Oct 31, 2023
199dbed
fix: readme
brotherlymite Oct 31, 2023
f484c77
chore: check ci
brotherlymite Oct 31, 2023
d789196
fix: ci
brotherlymite Oct 31, 2023
131d28f
fix: script
sakulstra Nov 1, 2023
7d1c82b
Merge branch 'main' into feat/gnosis
sakulstra Nov 1, 2023
e13c620
fix: update aave helpers
sakulstra Nov 1, 2023
a2d3831
Update src/20231026_AaveV3Gnosis_AaveV3GnosisActivation/AaveV3GnosisA…
brotherlymite Nov 1, 2023
0367b17
chore: add deploy address
brotherlymite Nov 1, 2023
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
1 change: 1 addition & 0 deletions .assets/380953098cfaf9c52baabfd063712d8e6bcef690.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions .assets/64a0110786c519e361963abb7399874664375a85.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions .assets/b5cb0fd07fde8594230045982589445fc02ace52.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
src = 'src'
test = 'tests'
script = 'scripts'
solc = '0.8.19'
out = 'out'
libs = ['lib']
remappings = [
Expand Down
20 changes: 12 additions & 8 deletions generator/features/__snapshots__/assetListing.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,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';
import {IV3RateStrategyFactory} from 'aave-helpers/v3-config-engine/IV3RateStrategyFactory.sol';

/**
* @title test
Expand All @@ -100,7 +101,7 @@ contract AaveV3Ethereum_Test_20231023 is AaveV3PayloadEthereum {
address public constant PSP = address(0xcAfE001067cDEF266AfB7Eb5A286dCFD277f3dE5);

function _postExecute() internal override {
AaveV3Ethereum.POOL.supply(PSP, 10 ** 18, AaveV3Ethereum.COLLECTOR, 0);
AaveV3Ethereum.POOL.supply(PSP, 10 ** 18, address(AaveV3Ethereum.COLLECTOR), 0);
}

function newListings() public pure override returns (IAaveV3ConfigEngine.Listing[] memory) {
Expand All @@ -124,7 +125,7 @@ contract AaveV3Ethereum_Test_20231023 is AaveV3PayloadEthereum {
borrowCap: 5_000,
debtCeiling: 100_000,
liqProtocolFee: 20_00,
rateStrategyParams: Rates.RateStrategyParams({
rateStrategyParams: IV3RateStrategyFactory.RateStrategyParams({
optimalUsageRatio: _bpsToRay(80_00),
baseVariableBorrowRate: _bpsToRay(0_00),
variableRateSlope1: _bpsToRay(10_00),
Expand All @@ -146,6 +147,7 @@ pragma solidity ^0.8.0;

import {GovV3Helpers} from 'aave-helpers/GovV3Helpers.sol';
import {AaveV3Ethereum} from 'aave-address-book/AaveV3Ethereum.sol';
import {IERC20} from 'solidity-utils/contracts/oz-common/interfaces/IERC20.sol';

import 'forge-std/Test.sol';
import {ProtocolV3TestBase, ReserveConfig} from 'aave-helpers/ProtocolV3TestBase.sol';
Expand All @@ -159,7 +161,7 @@ contract AaveV3Ethereum_Test_20231023_Test is ProtocolV3TestBase {
AaveV3Ethereum_Test_20231023 internal proposal;

function setUp() public {
vm.createSelectFork(vm.rpcUrl('mainnet'), 18420741);
vm.createSelectFork(vm.rpcUrl('mainnet'), 18430155);
proposal = new AaveV3Ethereum_Test_20231023();
}

Expand All @@ -172,8 +174,10 @@ contract AaveV3Ethereum_Test_20231023_Test is ProtocolV3TestBase {

function test_collectorHasPSPFunds() public {
GovV3Helpers.executePayload(vm, address(proposal));
assertGte(
IERC20(0xcAfE001067cDEF266AfB7Eb5A286dCFD277f3dE5).balanceOf(AaveV3Ethereum.COLLECTOR),
assertGe(
IERC20(0xcAfE001067cDEF266AfB7Eb5A286dCFD277f3dE5).balanceOf(
address(AaveV3Ethereum.COLLECTOR)
),
10 ** 18
);
}
Expand Down Expand Up @@ -240,7 +244,7 @@ exports[`feature: assetListing > should return reasonable code 1`] = `
"address public constant PSP = address(0xcAfE001067cDEF266AfB7Eb5A286dCFD277f3dE5);",
],
"execute": [
"AaveV3Ethereum.POOL.supply(PSP, 10 ** 18, AaveV3Ethereum.COLLECTOR, 0);",
"AaveV3Ethereum.POOL.supply(PSP, 10 ** 18, address(AaveV3Ethereum.COLLECTOR), 0);",
],
"fn": [
"function newListings() public pure override returns (IAaveV3ConfigEngine.Listing[] memory) {
Expand All @@ -264,7 +268,7 @@ exports[`feature: assetListing > should return reasonable code 1`] = `
borrowCap: 5_000,
debtCeiling: 100_000,
liqProtocolFee: 20_00,
rateStrategyParams: Rates.RateStrategyParams({
rateStrategyParams: IV3RateStrategyFactory.RateStrategyParams({
optimalUsageRatio: _bpsToRay(80_00),
baseVariableBorrowRate: _bpsToRay(0_00),
variableRateSlope1: _bpsToRay(10_00),
Expand All @@ -285,7 +289,7 @@ exports[`feature: assetListing > should return reasonable code 1`] = `
"fn": [
"function test_collectorHasPSPFunds() public {
GovV3Helpers.executePayload(vm,address(proposal));
assertGte(IERC20(0xcAfE001067cDEF266AfB7Eb5A286dCFD277f3dE5).balanceOf(AaveV3Ethereum.COLLECTOR), 10 ** 18);
assertGe(IERC20(0xcAfE001067cDEF266AfB7Eb5A286dCFD277f3dE5).balanceOf(address(AaveV3Ethereum.COLLECTOR)), 10 ** 18);
}",
],
},
Expand Down
10 changes: 5 additions & 5 deletions generator/features/assetListing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {TEST_EXECUTE_PROPOSAL} from '../utils/constants';

async function fetchListing(pool: PoolIdentifier): Promise<Listing> {
const asset = await addressInput({
message: 'enter the asset you want to list',
message: 'Enter the address of the asset you want to list',
disableKeepCurrent: true,
});

Expand Down Expand Up @@ -105,7 +105,7 @@ export const assetListing: FeatureModule<Listing[]> = {
),
execute: cfg.map(
(cfg) =>
`${pool}.POOL.supply(${cfg.assetSymbol}, 10 ** ${cfg.decimals}, ${pool}.COLLECTOR, 0);`
`${pool}.POOL.supply(${cfg.assetSymbol}, 10 ** ${cfg.decimals}, address(${pool}.COLLECTOR), 0);`
),
fn: [
`function newListings() public pure override returns (IAaveV3ConfigEngine.Listing[] memory) {
Expand Down Expand Up @@ -133,7 +133,7 @@ export const assetListing: FeatureModule<Listing[]> = {
borrowCap: ${cfg.borrowCap},
debtCeiling: ${cfg.debtCeiling},
liqProtocolFee: ${cfg.liqProtocolFee},
rateStrategyParams: Rates.RateStrategyParams({
rateStrategyParams: IV3RateStrategyFactory.RateStrategyParams({
optimalUsageRatio: ${cfg.rateStrategyParams.optimalUtilizationRate},
baseVariableBorrowRate: ${cfg.rateStrategyParams.baseVariableBorrowRate},
variableRateSlope1: ${cfg.rateStrategyParams.variableRateSlope1},
Expand All @@ -156,7 +156,7 @@ export const assetListing: FeatureModule<Listing[]> = {
fn: cfg.map(
(cfg) => `function test_collectorHas${cfg.assetSymbol}Funds() public {
${TEST_EXECUTE_PROPOSAL}
assertGte(IERC20(${cfg.asset}).balanceOf(${pool}.COLLECTOR), 10 ** ${cfg.decimals});
assertGe(IERC20(${cfg.asset}).balanceOf(address(${pool}.COLLECTOR)), 10 ** ${cfg.decimals});
}`
),
},
Expand Down Expand Up @@ -214,7 +214,7 @@ export const assetListingCustom: FeatureModule<ListingWithCustomImpl[]> = {
borrowCap: ${cfg.base.borrowCap},
debtCeiling: ${cfg.base.debtCeiling},
liqProtocolFee: ${cfg.base.liqProtocolFee},
rateStrategyParams: Rates.RateStrategyParams({
rateStrategyParams: IV3RateStrategyFactory.RateStrategyParams({
optimalUsageRatio: ${cfg.base.rateStrategyParams.optimalUtilizationRate},
baseVariableBorrowRate: ${cfg.base.rateStrategyParams.baseVariableBorrowRate},
variableRateSlope1: ${cfg.base.rateStrategyParams.variableRateSlope1},
Expand Down
7 changes: 3 additions & 4 deletions generator/features/collateralsUpdates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ export const collateralsUpdates: FeatureModule<CollateralUpdates> = {
code: {
fn: [
`function collateralsUpdates() public pure override returns (IAaveV3ConfigEngine.CollateralUpdate[] memory) {
IAaveV3ConfigEngine.CollateralUpdate[] memory collateralUpdate = new IAaveV3ConfigEngine.CollateralUpdate[](${
cfg.length
});
IAaveV3ConfigEngine.CollateralUpdate[] memory collateralUpdate = new IAaveV3ConfigEngine.CollateralUpdate[](${
cfg.length
});
${cfg
.map(
Expand All @@ -68,7 +68,6 @@ export const collateralsUpdates: FeatureModule<CollateralUpdates> = {
liqBonus: ${cfg.liqBonus},
debtCeiling: ${cfg.debtCeiling},
liqProtocolFee: ${cfg.liqProtocolFee}
}
});`
)
.join('\n')}
Expand Down
84 changes: 61 additions & 23 deletions generator/features/eModesUpdates.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,69 @@
import {CodeArtifact, FEATURE, FeatureModule, PoolIdentifier} from '../types';
import {addressInput, eModesSelect, percentInput, stringInput} from '../prompts';
import {EModeCategoryUpdate} from './types';
import {confirm} from '@inquirer/prompts';

async function fetchEmodeCategoryUpdate<T extends boolean>(
disableKeepCurrent?: T,
eModeCategory?: string
): Promise<EModeCategoryUpdate> {
return {
eModeCategory:
eModeCategory ?? (await stringInput({message: 'eModeCategory', disableKeepCurrent})),
ltv: await percentInput({
message: 'ltv',
disableKeepCurrent,
}),
liqThreshold: await percentInput({
message: 'liqThreshold',
disableKeepCurrent,
}),
liqBonus: await percentInput({
message: 'liqBonus',
disableKeepCurrent,
}),
priceSource: await addressInput({
message: 'Price Source',
disableKeepCurrent,
}),
label: await stringInput({
message: 'label',
disableKeepCurrent,
}),
};
}

async function subCli(pool: PoolIdentifier) {
console.log(`Fetching information for EModes on ${pool}`);
const eModeCategories = await eModesSelect({
message: 'Select the eModes you want to amend',
pool,
});
const answers: EmodeUpdates = [];
for (const eModeCategory of eModeCategories) {
console.log(`collecting info for ${eModeCategory}`);
answers.push({
eModeCategory,
ltv: await percentInput({
message: 'ltv',
}),
liqThreshold: await percentInput({
message: 'liqThreshold',
}),
liqBonus: await percentInput({
message: 'liqBonus',
}),
priceSource: await addressInput({
message: 'Price Source',
}),
label: await stringInput({message: 'label'}),

const shouldAddNewCategory = await confirm({
message: 'Do you wish to add a new emode category?',
default: false,
});
if (shouldAddNewCategory) {
let more: boolean = true;
while (more) {
answers.push(await fetchEmodeCategoryUpdate(true));
more = await confirm({message: 'Do you want to add another emode category?', default: false});
}
}

const shouldAmendCategory = await confirm({
message: 'Do you wish to amend existing emode category?',
default: false,
});
if (shouldAmendCategory) {
const eModeCategories = await eModesSelect({
message: 'Select the eModes you want to amend',
pool,
});

for (const eModeCategory of eModeCategories) {
console.log(`collecting info for ${eModeCategory}`);
answers.push(await fetchEmodeCategoryUpdate(false, eModeCategory));
}
}

return answers;
}

Expand Down Expand Up @@ -57,7 +93,9 @@ export const eModeUpdates: FeatureModule<EmodeUpdates> = {
liqThreshold: ${cfg.liqThreshold},
liqBonus: ${cfg.liqBonus},
priceSource: ${cfg.priceSource},
label: ${cfg.label}
label: ${
cfg.label == 'EngineFlags.KEEP_CURRENT_STRING' ? cfg.label : `"${cfg.label}"`
}
});`
)
.join('\n')}
Expand Down
6 changes: 3 additions & 3 deletions generator/features/priceFeedsUpdates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,20 @@ export const priceFeedsUpdates: FeatureModule<PriceFeedUpdate[]> = {
code: {
fn: [
`function priceFeedsUpdates() public pure override returns (IAaveV3ConfigEngine.PriceFeedUpdate[] memory) {
IAaveV3ConfigEngine.PriceFeedUpdate[] memory priceFeedsUpdates = new IAaveV3ConfigEngine.PriceFeedUpdate[](${
IAaveV3ConfigEngine.PriceFeedUpdate[] memory priceFeedUpdates = new IAaveV3ConfigEngine.PriceFeedUpdate[](${
cfg.length
});

${cfg
.map(
(cfg, ix) => `priceFeedsUpdates[${ix}] = IAaveV3ConfigEngine.PriceFeedUpdate({
(cfg, ix) => `priceFeedUpdates[${ix}] = IAaveV3ConfigEngine.PriceFeedUpdate({
asset: ${cfg.asset},
priceFeed: ${cfg.priceFeed}
});`
)
.join('\n')}

return priceFeedsUpdates;
return priceFeedUpdates;
}`,
],
},
Expand Down
6 changes: 3 additions & 3 deletions generator/features/rateUpdates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export async function fetchRateStrategyParamsV3(disableKeepCurrent?: boolean) {
disableKeepCurrent,
}),
optimalStableToTotalDebtRatio: await percentInput({
message: 'stableRateExcessOffset',
message: 'optimalStableToTotalDebtRatio',
toRay: true,
disableKeepCurrent,
}),
Expand Down Expand Up @@ -94,7 +94,7 @@ export const rateUpdatesV2: FeatureModule<RateStrategyUpdate[]> = {
.map(
(cfg, ix) => `rateStrategies[${ix}] = IAaveV2ConfigEngine.RateStrategyUpdate({
asset: ${cfg.asset},
params: Rates.RateStrategyParams({
params: IV2RateStrategyFactory.RateStrategyParams({
optimalUtilizationRate: ${cfg.params.optimalUtilizationRate},
baseVariableBorrowRate: ${cfg.params.baseVariableBorrowRate},
variableRateSlope1: ${cfg.params.variableRateSlope1},
Expand Down Expand Up @@ -149,7 +149,7 @@ export const rateUpdatesV3: FeatureModule<RateStrategyUpdate[]> = {
.map(
(cfg, ix) => `rateStrategies[${ix}] = IAaveV3ConfigEngine.RateStrategyUpdate({
asset: ${cfg.asset},
params: Rates.RateStrategyParams({
params: IV3RateStrategyFactory.RateStrategyParams({
optimalUsageRatio: ${cfg.params.optimalUtilizationRate},
baseVariableBorrowRate: ${cfg.params.baseVariableBorrowRate},
variableRateSlope1: ${cfg.params.variableRateSlope1},
Expand Down
2 changes: 2 additions & 0 deletions generator/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export async function generateFiles(options: Options, poolConfigs: PoolConfigs):
default: false,
});
}

async function createPayloadAndTest(options: Options, pool: PoolIdentifier) {
const contractName = generateContractName(options, pool);
const testCode = await testTemplate(options, poolConfigs[pool]!);
Expand All @@ -62,6 +63,7 @@ export async function generateFiles(options: Options, poolConfigs: PoolConfigs):
contractName: contractName,
};
}

console.log('generating script');
const script = prettier.format(generateScript(options), {
...prettierSolCfg,
Expand Down
Loading
Loading