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 all 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
21 changes: 21 additions & 0 deletions src/20240104_Multi_Patch/AaveV3Arbitrum_Patch_20240104.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {AaveV3Arbitrum} from 'aave-address-book/AaveV3Arbitrum.sol';
import {PoolAddresses} from './PoolLibrary.sol';
import {AaveV3GenericPatch_20240104} from './AaveV3GenericPatch_20240104.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 AaveV3GenericPatch_20240104 {
constructor()
AaveV3GenericPatch_20240104(
PoolAddresses.ARBITRUM_POOL_IMPL_ADDRESS,
AaveV3Arbitrum.POOL_ADDRESSES_PROVIDER
)
{}
}
16 changes: 16 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,16 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {AaveV3Generic_Patch_20240104_Test} from './AaveV3Generic_Patch_20240104_Test.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 AaveV3Generic_Patch_20240104_Test {
function setUp() public {
vm.createSelectFork(vm.rpcUrl('arbitrum'), 167017329);
proposal = address(new AaveV3Arbitrum_Patch_20240104());
}
}
21 changes: 21 additions & 0 deletions src/20240104_Multi_Patch/AaveV3Avalanche_Patch_20240104.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {AaveV3Avalanche} from 'aave-address-book/AaveV3Avalanche.sol';
import {PoolAddresses} from './PoolLibrary.sol';
import {AaveV3GenericPatch_20240104} from './AaveV3GenericPatch_20240104.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 AaveV3GenericPatch_20240104 {
constructor()
AaveV3GenericPatch_20240104(
PoolAddresses.AVALANCHE_POOL_IMPL_ADDRESS,
AaveV3Avalanche.POOL_ADDRESSES_PROVIDER
)
{}
}
16 changes: 16 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,16 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {AaveV3Generic_Patch_20240104_Test} from './AaveV3Generic_Patch_20240104_Test.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 AaveV3Generic_Patch_20240104_Test {
function setUp() public {
vm.createSelectFork(vm.rpcUrl('avalanche'), 39925983);
proposal = address(new AaveV3Avalanche_Patch_20240104());
}
}
21 changes: 21 additions & 0 deletions src/20240104_Multi_Patch/AaveV3Base_Patch_20240104.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {AaveV3Base} from 'aave-address-book/AaveV3Base.sol';
import {PoolAddresses} from './PoolLibrary.sol';
import {AaveV3GenericPatch_20240104} from './AaveV3GenericPatch_20240104.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 AaveV3GenericPatch_20240104 {
constructor()
AaveV3GenericPatch_20240104(
PoolAddresses.BASE_POOL_IMPL_ADDRESS,
AaveV3Base.POOL_ADDRESSES_PROVIDER
)
{}
}
16 changes: 16 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,16 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {AaveV3Generic_Patch_20240104_Test} from './AaveV3Generic_Patch_20240104_Test.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 AaveV3Generic_Patch_20240104_Test {
function setUp() public {
vm.createSelectFork(vm.rpcUrl('base'), 8792857);
proposal = address(new AaveV3Base_Patch_20240104());
}
}
21 changes: 21 additions & 0 deletions src/20240104_Multi_Patch/AaveV3Ethereum_Patch_20240104.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {AaveV3Ethereum} from 'aave-address-book/AaveV3Ethereum.sol';
import {PoolAddresses} from './PoolLibrary.sol';
import {AaveV3GenericPatch_20240104} from './AaveV3GenericPatch_20240104.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 AaveV3GenericPatch_20240104 {
constructor()
AaveV3GenericPatch_20240104(
PoolAddresses.ETHEREUM_POOL_IMPL_ADDRESS,
AaveV3Ethereum.POOL_ADDRESSES_PROVIDER
)
{}
}
16 changes: 16 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,16 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {AaveV3Generic_Patch_20240104_Test} from './AaveV3Generic_Patch_20240104_Test.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 AaveV3Generic_Patch_20240104_Test {
function setUp() public {
vm.createSelectFork(vm.rpcUrl('mainnet'), 18934274);
proposal = address(new AaveV3Ethereum_Patch_20240104());
}
}
21 changes: 21 additions & 0 deletions src/20240104_Multi_Patch/AaveV3GenericPatch_20240104.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

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

contract AaveV3GenericPatch_20240104 is IProposalGenericExecutor {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
contract AaveV3GenericPatch_20240104 is IProposalGenericExecutor {
abstract contract AaveV3GenericPatch_20240104 is IProposalGenericExecutor {

@kyzia551 Maybe we can make this contract abstract?

address public immutable NEW_POOL_IMPL;
IPoolAddressesProvider public immutable POOL_ADDRESSES_PROVIDER;

constructor(address newPoolImpl, IPoolAddressesProvider poolAddressesProvider) {
NEW_POOL_IMPL = newPoolImpl;
POOL_ADDRESSES_PROVIDER = poolAddressesProvider;
}

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

import {ProtocolV3TestBase} from 'aave-helpers/ProtocolV3TestBase.sol';

contract AaveV3Generic_Patch_20240104_Test is ProtocolV3TestBase {
address internal proposal;

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

import {AaveV3Gnosis} from 'aave-address-book/AaveV3Gnosis.sol';
import {PoolAddresses} from './PoolLibrary.sol';
import {AaveV3GenericPatch_20240104} from './AaveV3GenericPatch_20240104.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 AaveV3GenericPatch_20240104 {
constructor()
AaveV3GenericPatch_20240104(
PoolAddresses.GNOSIS_POOL_IMPL_ADDRESS,
AaveV3Gnosis.POOL_ADDRESSES_PROVIDER
)
{}
}
16 changes: 16 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,16 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {AaveV3Generic_Patch_20240104_Test} from './AaveV3Generic_Patch_20240104_Test.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 AaveV3Generic_Patch_20240104_Test {
function setUp() public {
vm.createSelectFork(vm.rpcUrl('gnosis'), 31781458);
proposal = address(new AaveV3Gnosis_Patch_20240104());
}
}
21 changes: 21 additions & 0 deletions src/20240104_Multi_Patch/AaveV3Optimism_Patch_20240104.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {AaveV3Optimism} from 'aave-address-book/AaveV3Optimism.sol';
import {PoolAddresses} from './PoolLibrary.sol';
import {AaveV3GenericPatch_20240104} from './AaveV3GenericPatch_20240104.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 AaveV3GenericPatch_20240104 {
constructor()
AaveV3GenericPatch_20240104(
PoolAddresses.OPTIMISM_POOL_IMPL_ADDRESS,
AaveV3Optimism.POOL_ADDRESSES_PROVIDER
)
{}
}
16 changes: 16 additions & 0 deletions src/20240104_Multi_Patch/AaveV3Optimism_Patch_20240104.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {AaveV3Generic_Patch_20240104_Test} from './AaveV3Generic_Patch_20240104_Test.sol';
import {AaveV3Optimism_Patch_20240104} from './AaveV3Optimism_Patch_20240104.sol';

/**
* @dev Test for AaveV3Optimism_Patch_20240104
* command: make test-contract filter=AaveV3Optimism_Patch_20240104
*/
contract AaveV3Optimism_Patch_20240104_Test is AaveV3Generic_Patch_20240104_Test {
function setUp() public {
vm.createSelectFork(vm.rpcUrl('optimism'), 114388130);
proposal = address(new AaveV3Optimism_Patch_20240104());
}
}
Loading