Skip to content

Commit

Permalink
feat: linea script and use rpc env (aave-dao#28)
Browse files Browse the repository at this point in the history
* feat: linea script and use rpc env

* fix: js test
  • Loading branch information
brotherlymite authored Jan 28, 2025
1 parent 72e78d7 commit 264fae5
Show file tree
Hide file tree
Showing 13 changed files with 49 additions and 11 deletions.
7 changes: 7 additions & 0 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ test = 'tests'
script = 'scripts'
out = 'out'
solc = '0.8.20'
optimizer = true
optimizer_runs = 200
libs = ['lib']
remappings = [
]
Expand All @@ -27,6 +29,9 @@ fallback_oz = true
optimizer_mode = 'z'
zksolc = '1.5.7'

[profile.linea]
evm_version = 'london'

[rpc_endpoints]
mainnet = "${RPC_MAINNET}"
optimism = "${RPC_OPTIMISM}"
Expand All @@ -42,6 +47,7 @@ gnosis = "${RPC_GNOSIS}"
bnb = "${RPC_BNB}"
scroll = "${RPC_SCROLL}"
zksync = "${RPC_ZKSYNC}"
linea = "${RPC_LINEA}"

[etherscan]
mainnet = { key="${ETHERSCAN_API_KEY_MAINNET}", chainId=1 }
Expand All @@ -57,5 +63,6 @@ gnosis = { key="${ETHERSCAN_API_KEY_GNOSIS}", chainId=100 }
bnb = { key="${ETHERSCAN_API_KEY_BNB}", chainId=56, url='https://api.bscscan.com/api' }
scroll = { key="${ETHERSCAN_API_KEY_SCROLL}", chainId= 534352 }
zksync = { key="${ETHERSCAN_API_KEY_ZKSYNC}", chainId= 324 }
linea = { key="${ETHERSCAN_API_KEY_LINEA}", chain = 59144 }

# See more config options https://github.com/gakonst/foundry/tree/master/config
4 changes: 2 additions & 2 deletions generator/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {collateralsUpdates} from './features/collateralsUpdates';
import {lstPriceCapsUpdates} from './features/lstPriceCapsUpdates';
import {stablePriceCapsUpdates} from './features/stablePriceCapsUpdates';
import {generateFiles, writeFiles} from './generator';
import {CHAIN_ID_CLIENT_MAP} from '@bgd-labs/js-utils';
import {getClient} from '@bgd-labs/rpc-env';
import {getBlockNumber} from 'viem/actions';

const program = new Command();
Expand Down Expand Up @@ -47,7 +47,7 @@ const FEATURE_MODULES_V3 = [

async function generateDeterministicPoolCache(pool: PoolIdentifier): Promise<PoolCache> {
const chain = getPoolChain(pool);
const client = CHAIN_ID_CLIENT_MAP[CHAIN_TO_CHAIN_ID[chain]];
const client = getClient(CHAIN_TO_CHAIN_ID[chain], {});
return {blockNumber: Number(await getBlockNumber(client))};
}

Expand Down
3 changes: 3 additions & 0 deletions generator/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
gnosis,
scroll,
zkSync,
linea
} from 'viem/chains';

export const AVAILABLE_CHAINS = [
Expand All @@ -28,6 +29,7 @@ export const AVAILABLE_CHAINS = [
'Gnosis',
'Scroll',
'ZkSync',
'Linea'
] as const;

export function getAssets(pool: PoolIdentifier): string[] {
Expand Down Expand Up @@ -111,6 +113,7 @@ export const CHAIN_TO_CHAIN_ID = {
Gnosis: gnosis.id,
Scroll: scroll.id,
ZkSync: zkSync.id,
Linea: linea.id,
};

export function flagAsRequired(message: string, required?: boolean) {
Expand Down
2 changes: 1 addition & 1 deletion generator/features/__snapshots__/capUpdates.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import {IAaveV3ConfigEngine} from 'aave-v3-origin/src/contracts/extensions/v3-co
* @title test
* @author test
* - discussion: test
* - deploy-command: make run-script contract=src/contracts/updates/20231023_AaveV3Ethereum_Test/AaveV3Ethereum_Test_20231023.sol:AaveV3Ethereum_Test_20231023 network=mainnet broadcast=false generate_diff=true
* - deploy-command: make run-script contract=src/contracts/updates/20231023_AaveV3Ethereum_Test/AaveV3Ethereum_Test_20231023.sol:AaveV3Ethereum_Test_20231023 network=mainnet broadcast=false generate_diff=true skip_timelock=false
*/
contract AaveV3Ethereum_Test_20231023 is RiskStewardsEthereum {
function name() public pure override returns (string memory) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ import {IAaveV3ConfigEngine} from 'aave-v3-origin/src/contracts/extensions/v3-co
* @title test
* @author test
* - discussion: test
* - deploy-command: make run-script contract=src/contracts/updates/20231023_AaveV3Ethereum_Test/AaveV3Ethereum_Test_20231023.sol:AaveV3Ethereum_Test_20231023 network=mainnet broadcast=false generate_diff=true
* - deploy-command: make run-script contract=src/contracts/updates/20231023_AaveV3Ethereum_Test/AaveV3Ethereum_Test_20231023.sol:AaveV3Ethereum_Test_20231023 network=mainnet broadcast=false generate_diff=true skip_timelock=false
*/
contract AaveV3Ethereum_Test_20231023 is RiskStewardsEthereum {
function name() public pure override returns (string memory) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import {IRiskSteward, IPriceCapAdapter} from '../../../interfaces/IRiskSteward.s
* @title test
* @author test
* - discussion: test
* - deploy-command: make run-script contract=src/contracts/updates/20231023_AaveV3Ethereum_Test/AaveV3Ethereum_Test_20231023.sol:AaveV3Ethereum_Test_20231023 network=mainnet broadcast=false generate_diff=true
* - deploy-command: make run-script contract=src/contracts/updates/20231023_AaveV3Ethereum_Test/AaveV3Ethereum_Test_20231023.sol:AaveV3Ethereum_Test_20231023 network=mainnet broadcast=false generate_diff=true skip_timelock=false
*/
contract AaveV3Ethereum_Test_20231023 is RiskStewardsEthereum {
function name() public pure override returns (string memory) {
Expand Down
2 changes: 1 addition & 1 deletion generator/features/__snapshots__/rateUpdates.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ import {IAaveV3ConfigEngine} from 'aave-v3-origin/src/contracts/extensions/v3-co
* @title test
* @author test
* - discussion: test
* - deploy-command: make run-script contract=src/contracts/updates/20231023_AaveV3Ethereum_Test/AaveV3Ethereum_Test_20231023.sol:AaveV3Ethereum_Test_20231023 network=mainnet broadcast=false generate_diff=true
* - deploy-command: make run-script contract=src/contracts/updates/20231023_AaveV3Ethereum_Test/AaveV3Ethereum_Test_20231023.sol:AaveV3Ethereum_Test_20231023 network=mainnet broadcast=false generate_diff=true skip_timelock=false
*/
contract AaveV3Ethereum_Test_20231023 is RiskStewardsEthereum {
function name() public pure override returns (string memory) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import {IRiskSteward} from '../../../interfaces/IRiskSteward.sol';
* @title test
* @author test
* - discussion: test
* - deploy-command: make run-script contract=src/contracts/updates/20231023_AaveV3Ethereum_Test/AaveV3Ethereum_Test_20231023.sol:AaveV3Ethereum_Test_20231023 network=mainnet broadcast=false generate_diff=true
* - deploy-command: make run-script contract=src/contracts/updates/20231023_AaveV3Ethereum_Test/AaveV3Ethereum_Test_20231023.sol:AaveV3Ethereum_Test_20231023 network=mainnet broadcast=false generate_diff=true skip_timelock=false
*/
contract AaveV3Ethereum_Test_20231023 is RiskStewardsEthereum {
function name() public pure override returns (string memory) {
Expand Down
3 changes: 2 additions & 1 deletion generator/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ export const V3_POOLS = [
'AaveV3Gnosis',
'AaveV3Scroll',
'AaveV3BNB',
'AaveV3ZkSync'
'AaveV3ZkSync',
'AaveV3Linea',
] as const satisfies readonly (keyof typeof addressBook)[];

export const POOLS = [
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
"prettier": "2.8.7",
"prettier-plugin-solidity": "1.1.3",
"vitest": "^2.0.4",
"@bgd-labs/aave-address-book": "^4.3.2",
"@bgd-labs/aave-address-book": "^4.8.1",
"@bgd-labs/aave-cli": "^1.1.12",
"@bgd-labs/js-utils": "^1.4.2",
"@bgd-labs/js-utils": "^1.4.7",
"@inquirer/prompts": "^3.3.0",
"@inquirer/testing": "^2.1.13",
"commander": "^12.1.0",
Expand Down
16 changes: 16 additions & 0 deletions scripts/deploy/DeployStewards.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import {AaveV3Base} from 'aave-address-book/AaveV3Base.sol';
import {GovernanceV3Base} from 'aave-address-book/GovernanceV3Base.sol';
import {AaveV3Metis} from 'aave-address-book/AaveV3Metis.sol';
import {GovernanceV3Metis} from 'aave-address-book/GovernanceV3Metis.sol';
import {AaveV3Linea} from 'aave-address-book/AaveV3Linea.sol';
import {GovernanceV3Linea} from 'aave-address-book/GovernanceV3Linea.sol';
import {IOwnable} from 'aave-address-book/common/IOwnable.sol';
import {RiskSteward, IRiskSteward, IPoolDataProvider, IEngine} from '../../src/contracts/RiskSteward.sol';

Expand Down Expand Up @@ -241,3 +243,17 @@ contract DeployMetis is MetisScript {
vm.stopBroadcast();
}
}

// make deploy-ledger contract=scripts/deploy/DeployStewards.s.sol:DeployLinea chain=linea
contract DeployLinea is LineaScript {
function run() external {
vm.startBroadcast();
DeployRiskStewards._deployRiskStewards(
address(AaveV3Linea.AAVE_PROTOCOL_DATA_PROVIDER),
AaveV3Linea.CONFIG_ENGINE,
0xF092A5aC5E284E7c433dAFE5b8B138bFcA53a4Ee, // linea-risk-council
GovernanceV3Linea.EXECUTOR_LVL_1
);
vm.stopBroadcast();
}
}
11 changes: 11 additions & 0 deletions scripts/networks/RiskStewardsLinea.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {AaveV3Linea} from 'aave-address-book/AaveV3Linea.sol';
import {RiskStewardsBase} from '../RiskStewardsBase.s.sol';

abstract contract RiskStewardsLinea is RiskStewardsBase {
constructor()
RiskStewardsBase(address(AaveV3Linea.POOL), AaveV3Linea.RISK_STEWARD)
{}
}

0 comments on commit 264fae5

Please sign in to comment.