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: pool upgrade #156

Merged
merged 8 commits into from
Jan 5, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
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
2 changes: 2 additions & 0 deletions generator/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {borrowsUpdates} from './features/borrowsUpdates';
import {eModeUpdates} from './features/eModesUpdates';
import {eModeAssets} from './features/eModesAssets';
import {priceFeedsUpdates} from './features/priceFeedsUpdates';
import {freezeUpdates} from './features/freeze';
import {assetListing, assetListingCustom} from './features/assetListing';
import {generateFiles, writeFiles} from './generator';
import {PublicClient} from 'viem';
Expand Down Expand Up @@ -70,6 +71,7 @@ const FEATURE_MODULES_V3 = [
eModeAssets,
assetListing,
assetListingCustom,
freezeUpdates,
PLACEHOLDER_MODULE,
];

Expand Down
41 changes: 41 additions & 0 deletions generator/features/freeze.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import {confirm} from '@inquirer/prompts';
import {CodeArtifact, FEATURE, FeatureModule} from '../types';
import {FreezeUpdate} from './types';
import {
assetsSelectPrompt,
translateAssetToAssetLibUnderlying,
} from '../prompts/assetsSelectPrompt';

export const freezeUpdates: FeatureModule<FreezeUpdate[]> = {
value: FEATURE.FREEZE,
description: 'Freeze/Unfreeze a reserve',
async cli({pool}) {
const response: FreezeUpdate[] = [];
const assets = await assetsSelectPrompt({
message: 'Select the assets you want to change',
pool,
});
for (const asset of assets) {
console.log(`collecting info for ${asset}`);
response.push({
asset,
shouldBeFrozen: await confirm({message: 'Should the asset be frozen?'}),
});
}
return response;
},
build({pool, cfg}) {
const response: CodeArtifact = {
code: {
execute: cfg.map(
(cfg) =>
`${pool}.POOL_CONFIGURATOR.setReserveFreeze(${translateAssetToAssetLibUnderlying(
cfg.asset,
pool
)}, false);`
),
},
};
return response;
},
};
7 changes: 6 additions & 1 deletion generator/features/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {Hex} from 'viem';
import {BooleanSelectValues, NumberInputValues, PercentInputValues} from '../prompts';
import {NumberInputValues, PercentInputValues} from '../prompts';
import {BooleanSelectValues} from '../prompts/boolPrompt';

export interface AssetSelector {
asset: string;
Expand Down Expand Up @@ -100,3 +101,7 @@ export interface TokenStream {
duration: string;
amount: string;
}

export interface FreezeUpdate extends AssetSelector {
shouldBeFrozen: boolean;
}
2 changes: 1 addition & 1 deletion generator/templates/proposal.template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const proposalTemplate = (

let optionalExecute = '';
const usesConfigEngine = Object.keys(poolConfig.configs).some(
(f) => ![FEATURE.OTHERS, FEATURE.FLASH_BORROWER].includes(f)
(f) => ![FEATURE.OTHERS, FEATURE.FLASH_BORROWER, FEATURE.FREEZE].includes(f)
);
const isAssetListing = Object.keys(poolConfig.configs).some((f) =>
[FEATURE.ASSET_LISTING, FEATURE.ASSET_LISTING_CUSTOM].includes(f)
Expand Down
3 changes: 3 additions & 0 deletions generator/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
ListingWithCustomImpl,
PriceFeedUpdate,
RateStrategyUpdate,
FreezeUpdate,
} from './features/types';
import {FlashBorrower} from './features/flashBorrower';

Expand Down Expand Up @@ -80,6 +81,7 @@ export enum FEATURE {
PRICE_FEEDS_UPDATE = 'PRICE_FEEDS_UPDATE',
RATE_UPDATE_V3 = 'RATE_UPDATE_V3',
RATE_UPDATE_V2 = 'RATE_UPDATE_V2',
FREEZE = 'FREEZE',
OTHERS = 'OTHERS',
}

Expand Down Expand Up @@ -121,6 +123,7 @@ export interface PoolConfig {
[FEATURE.PRICE_FEEDS_UPDATE]?: PriceFeedUpdate[];
[FEATURE.RATE_UPDATE_V3]?: RateStrategyUpdate[]; // TODO: type could be improved
[FEATURE.RATE_UPDATE_V2]?: RateStrategyUpdate[];
[FEATURE.FREEZE]?: FreezeUpdate[];
[FEATURE.OTHERS]?: {};
};
cache: PoolCache;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"vitest": "^1.0.4"
},
"dependencies": {
"@bgd-labs/aave-address-book": "^2.13.0",
"@bgd-labs/aave-address-book": "^2.14.0",
"@bgd-labs/aave-cli": "0.2.1",
"@inquirer/prompts": "^3.3.0",
"@inquirer/testing": "^2.1.9",
Expand Down
22 changes: 22 additions & 0 deletions src/20240104_Multi_Patch/AaveV3Arbitrum_Patch_20240104.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {IProposalGenericExecutor} from 'aave-helpers/interfaces/IProposalGenericExecutor.sol';
import {AaveV3Arbitrum} from 'aave-address-book/AaveV3Arbitrum.sol';
import {PoolAddresses} from './PoolLibrary.sol';
import {Address} from 'solidity-utils/contracts/oz-common/Address.sol';

/**
* @title Patch
* @author BGD Labs @bgdlabs
* - Snapshot: N/A
* - Discussion: https://governance.aave.com/t/pre-cautionary-measures-on-three-aave-v3-assets/16037
*/
contract AaveV3Arbitrum_Patch_20240104 is IProposalGenericExecutor {
address public constant NEW_POOL_IMPL = address(PoolAddresses.ARBITRUM_POOL_IMPL_ADDRESS);
kyzia551 marked this conversation as resolved.
Show resolved Hide resolved

function execute() external {
require(Address.isContract(NEW_POOL_IMPL), 'CONTRACT_NON_YET_DEPLOYED');
AaveV3Arbitrum.POOL_ADDRESSES_PROVIDER.setPoolImpl(NEW_POOL_IMPL);
}
}
28 changes: 28 additions & 0 deletions src/20240104_Multi_Patch/AaveV3Arbitrum_Patch_20240104.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {AaveV3Arbitrum} from 'aave-address-book/AaveV3Arbitrum.sol';

import 'forge-std/Test.sol';
import {ProtocolV3TestBase, ReserveConfig} from 'aave-helpers/ProtocolV3TestBase.sol';
import {AaveV3Arbitrum_Patch_20240104} from './AaveV3Arbitrum_Patch_20240104.sol';

/**
* @dev Test for AaveV3Arbitrum_Patch_20240104
* command: make test-contract filter=AaveV3Arbitrum_Patch_20240104
*/
contract AaveV3Arbitrum_Patch_20240104_Test is ProtocolV3TestBase {
AaveV3Arbitrum_Patch_20240104 internal proposal;

function setUp() public {
vm.createSelectFork(vm.rpcUrl('arbitrum'), 167017329);
proposal = new AaveV3Arbitrum_Patch_20240104();
}

/**
* @dev execution will fail because logic is not yet deployed
*/
function testFail_defaultProposalExecution() public {
executePayload(vm, address(proposal));
}
}
22 changes: 22 additions & 0 deletions src/20240104_Multi_Patch/AaveV3Avalanche_Patch_20240104.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {AaveV3Avalanche} from 'aave-address-book/AaveV3Avalanche.sol';
import {IProposalGenericExecutor} from 'aave-helpers/interfaces/IProposalGenericExecutor.sol';
import {PoolAddresses} from './PoolLibrary.sol';
import {Address} from 'solidity-utils/contracts/oz-common/Address.sol';

/**
* @title Patch
* @author BGD Labs @bgdlabs
* - Snapshot: N/A
* - Discussion: https://governance.aave.com/t/pre-cautionary-measures-on-three-aave-v3-assets/16037
*/
contract AaveV3Avalanche_Patch_20240104 is IProposalGenericExecutor {
address public constant NEW_POOL_IMPL = address(PoolAddresses.AVALANCHE_POOL_IMPL_ADDRESS);

function execute() external {
require(Address.isContract(NEW_POOL_IMPL), 'CONTRACT_NON_YET_DEPLOYED');
AaveV3Avalanche.POOL_ADDRESSES_PROVIDER.setPoolImpl(NEW_POOL_IMPL);
}
}
28 changes: 28 additions & 0 deletions src/20240104_Multi_Patch/AaveV3Avalanche_Patch_20240104.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {AaveV3Avalanche} from 'aave-address-book/AaveV3Avalanche.sol';

import 'forge-std/Test.sol';
import {ProtocolV3TestBase, ReserveConfig} from 'aave-helpers/ProtocolV3TestBase.sol';
import {AaveV3Avalanche_Patch_20240104} from './AaveV3Avalanche_Patch_20240104.sol';

/**
* @dev Test for AaveV3Avalanche_Patch_20240104
* command: make test-contract filter=AaveV3Avalanche_Patch_20240104
*/
contract AaveV3Avalanche_Patch_20240104_Test is ProtocolV3TestBase {
AaveV3Avalanche_Patch_20240104 internal proposal;

function setUp() public {
vm.createSelectFork(vm.rpcUrl('avalanche'), 39925983);
proposal = new AaveV3Avalanche_Patch_20240104();
}

/**
* @dev execution will fail because logic is not yet deployed
*/
function testFail_defaultProposalExecution() public {
executePayload(vm, address(proposal));
}
}
22 changes: 22 additions & 0 deletions src/20240104_Multi_Patch/AaveV3Base_Patch_20240104.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {IProposalGenericExecutor} from 'aave-helpers/interfaces/IProposalGenericExecutor.sol';
import {AaveV3Base} from 'aave-address-book/AaveV3Base.sol';
import {PoolAddresses} from './PoolLibrary.sol';
import {Address} from 'solidity-utils/contracts/oz-common/Address.sol';

/**
* @title Patch
* @author BGD Labs @bgdlabs
* - Snapshot: N/A
* - Discussion: https://governance.aave.com/t/pre-cautionary-measures-on-three-aave-v3-assets/16037
*/
contract AaveV3Base_Patch_20240104 is IProposalGenericExecutor {
address public constant NEW_POOL_IMPL = address(PoolAddresses.BASE_POOL_IMPL_ADDRESS);

function execute() external {
require(Address.isContract(NEW_POOL_IMPL), 'CONTRACT_NON_YET_DEPLOYED');
AaveV3Base.POOL_ADDRESSES_PROVIDER.setPoolImpl(NEW_POOL_IMPL);
}
}
28 changes: 28 additions & 0 deletions src/20240104_Multi_Patch/AaveV3Base_Patch_20240104.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {AaveV3Base} from 'aave-address-book/AaveV3Base.sol';

import 'forge-std/Test.sol';
import {ProtocolV3TestBase, ReserveConfig} from 'aave-helpers/ProtocolV3TestBase.sol';
import {AaveV3Base_Patch_20240104} from './AaveV3Base_Patch_20240104.sol';

/**
* @dev Test for AaveV3Base_Patch_20240104
* command: make test-contract filter=AaveV3Base_Patch_20240104
*/
contract AaveV3Base_Patch_20240104_Test is ProtocolV3TestBase {
AaveV3Base_Patch_20240104 internal proposal;

function setUp() public {
vm.createSelectFork(vm.rpcUrl('base'), 8792857);
proposal = new AaveV3Base_Patch_20240104();
}

/**
* @dev execution will fail because logic is not yet deployed
*/
function testFail_defaultProposalExecution() public {
executePayload(vm, address(proposal));
}
}
22 changes: 22 additions & 0 deletions src/20240104_Multi_Patch/AaveV3Ethereum_Patch_20240104.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {IProposalGenericExecutor} from 'aave-helpers/interfaces/IProposalGenericExecutor.sol';
import {AaveV3Ethereum} from 'aave-address-book/AaveV3Ethereum.sol';
import {PoolAddresses} from './PoolLibrary.sol';
import {Address} from 'solidity-utils/contracts/oz-common/Address.sol';

/**
* @title Patch
* @author BGD Labs @bgdlabs
* - Snapshot: N/A
* - Discussion: https://governance.aave.com/t/pre-cautionary-measures-on-three-aave-v3-assets/16037
*/
contract AaveV3Ethereum_Patch_20240104 is IProposalGenericExecutor {
address public constant NEW_POOL_IMPL = address(PoolAddresses.ETHEREUM_POOL_IMPL_ADDRESS);

function execute() external {
require(Address.isContract(NEW_POOL_IMPL), 'CONTRACT_NON_YET_DEPLOYED');
AaveV3Ethereum.POOL_ADDRESSES_PROVIDER.setPoolImpl(NEW_POOL_IMPL);
}
}
28 changes: 28 additions & 0 deletions src/20240104_Multi_Patch/AaveV3Ethereum_Patch_20240104.t.sol
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_Patch_20240104} from './AaveV3Ethereum_Patch_20240104.sol';

/**
* @dev Test for AaveV3Ethereum_Patch_20240104
* command: make test-contract filter=AaveV3Ethereum_Patch_20240104
*/
contract AaveV3Ethereum_Patch_20240104_Test is ProtocolV3TestBase {
AaveV3Ethereum_Patch_20240104 internal proposal;

function setUp() public {
vm.createSelectFork(vm.rpcUrl('mainnet'), 18934274);
proposal = new AaveV3Ethereum_Patch_20240104();
}

/**
* @dev execution will fail because logic is not yet deployed
*/
function testFail_defaultProposalExecution() public {
executePayload(vm, address(proposal));
}
}
22 changes: 22 additions & 0 deletions src/20240104_Multi_Patch/AaveV3Gnosis_Patch_20240104.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {IProposalGenericExecutor} from 'aave-helpers/interfaces/IProposalGenericExecutor.sol';
import {AaveV3Gnosis} from 'aave-address-book/AaveV3Gnosis.sol';
import {PoolAddresses} from './PoolLibrary.sol';
import {Address} from 'solidity-utils/contracts/oz-common/Address.sol';

/**
* @title Patch
* @author BGD Labs @bgdlabs
* - Snapshot: N/A
* - Discussion: https://governance.aave.com/t/pre-cautionary-measures-on-three-aave-v3-assets/16037
*/
contract AaveV3Gnosis_Patch_20240104 is IProposalGenericExecutor {
address public constant NEW_POOL_IMPL = address(PoolAddresses.GNOSIS_POOL_IMPL_ADDRESS);

function execute() external {
require(Address.isContract(NEW_POOL_IMPL), 'CONTRACT_NON_YET_DEPLOYED');
AaveV3Gnosis.POOL_ADDRESSES_PROVIDER.setPoolImpl(NEW_POOL_IMPL);
}
}
28 changes: 28 additions & 0 deletions src/20240104_Multi_Patch/AaveV3Gnosis_Patch_20240104.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {AaveV3Gnosis} from 'aave-address-book/AaveV3Gnosis.sol';

import 'forge-std/Test.sol';
import {ProtocolV3TestBase, ReserveConfig} from 'aave-helpers/ProtocolV3TestBase.sol';
import {AaveV3Gnosis_Patch_20240104} from './AaveV3Gnosis_Patch_20240104.sol';

/**
* @dev Test for AaveV3Gnosis_Patch_20240104
* command: make test-contract filter=AaveV3Gnosis_Patch_20240104
*/
contract AaveV3Gnosis_Patch_20240104_Test is ProtocolV3TestBase {
AaveV3Gnosis_Patch_20240104 internal proposal;

function setUp() public {
vm.createSelectFork(vm.rpcUrl('gnosis'), 31781458);
proposal = new AaveV3Gnosis_Patch_20240104();
}

/**
* @dev execution will fail because logic is not yet deployed
*/
function testFail_defaultProposalExecution() public {
executePayload(vm, address(proposal));
}
}
22 changes: 22 additions & 0 deletions src/20240104_Multi_Patch/AaveV3Optimism_Patch_20240104.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {IProposalGenericExecutor} from 'aave-helpers/interfaces/IProposalGenericExecutor.sol';
import {AaveV3Optimism} from 'aave-address-book/AaveV3Optimism.sol';
import {PoolAddresses} from './PoolLibrary.sol';
import {Address} from 'solidity-utils/contracts/oz-common/Address.sol';

/**
* @title Patch
* @author BGD Labs @bgdlabs
* - Snapshot: N/A
* - Discussion: https://governance.aave.com/t/pre-cautionary-measures-on-three-aave-v3-assets/16037
*/
contract AaveV3Optimism_Patch_20240104 is IProposalGenericExecutor {
address public constant NEW_POOL_IMPL = address(PoolAddresses.OPTIMISM_POOL_IMPL_ADDRESS);

function execute() external {
require(Address.isContract(NEW_POOL_IMPL), 'CONTRACT_NON_YET_DEPLOYED');
AaveV3Optimism.POOL_ADDRESSES_PROVIDER.setPoolImpl(NEW_POOL_IMPL);
}
}
Loading