Skip to content

Commit 756a4aa

Browse files
authored
✨ Implement Sonic market (#33)
* ⬆️ bump aave-helpers * ✨ implement Sonic to repo * 🐛 fix rpc urls * 🐛 update example * 🐛 add deploy script * 🐛 fix comment example script * ⬆️ bump aave-capo * 🔧 update evm version of sonic for cancun * ⬆️ bump risk steward test mainnet block * ⬆️ bump viem version
1 parent 9b6767c commit 756a4aa

File tree

10 files changed

+68
-9
lines changed

10 files changed

+68
-9
lines changed

foundry.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ zksolc = '1.5.7'
3232
[profile.linea]
3333
evm_version = 'london'
3434

35+
[profile.sonic]
36+
evm_version = 'cancun'
37+
3538
[rpc_endpoints]
3639
mainnet = "${RPC_MAINNET}"
3740
optimism = "${RPC_OPTIMISM}"
@@ -48,6 +51,7 @@ bnb = "${RPC_BNB}"
4851
scroll = "${RPC_SCROLL}"
4952
zksync = "${RPC_ZKSYNC}"
5053
linea = "${RPC_LINEA}"
54+
sonic = "${RPC_SONIC}"
5155

5256
[etherscan]
5357
mainnet = { key="${ETHERSCAN_API_KEY_MAINNET}", chainId=1 }
@@ -64,5 +68,6 @@ bnb = { key="${ETHERSCAN_API_KEY_BNB}", chainId=56, url='https://api.bscscan.com
6468
scroll = { key="${ETHERSCAN_API_KEY_SCROLL}", chainId= 534352 }
6569
zksync = { key="${ETHERSCAN_API_KEY_ZKSYNC}", chainId= 324 }
6670
linea = { key="${ETHERSCAN_API_KEY_LINEA}", chain = 59144 }
71+
sonic = { key="${ETHERSCAN_API_KEY_SONIC}", chain = 146 }
6772

6873
# See more config options https://github.com/gakonst/foundry/tree/master/config

generator/common.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ import {
1212
gnosis,
1313
scroll,
1414
zkSync,
15-
linea
15+
linea,
16+
sonic,
1617
} from 'viem/chains';
1718

1819
export const AVAILABLE_CHAINS = [
@@ -29,7 +30,8 @@ export const AVAILABLE_CHAINS = [
2930
'Gnosis',
3031
'Scroll',
3132
'ZkSync',
32-
'Linea'
33+
'Linea',
34+
'Sonic',
3335
] as const;
3436

3537
export function getAssets(pool: PoolIdentifier): string[] {
@@ -114,6 +116,7 @@ export const CHAIN_TO_CHAIN_ID = {
114116
Scroll: scroll.id,
115117
ZkSync: zkSync.id,
116118
Linea: linea.id,
119+
Sonic: sonic.id,
117120
};
118121

119122
export function flagAsRequired(message: string, required?: boolean) {

generator/types.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,10 @@ export const V3_POOLS = [
2222
'AaveV3BNB',
2323
'AaveV3ZkSync',
2424
'AaveV3Linea',
25+
'AaveV3Sonic',
2526
] as const satisfies readonly (keyof typeof addressBook)[];
2627

27-
export const POOLS = [
28-
...V3_POOLS,
29-
] as const satisfies readonly (keyof typeof addressBook)[];
28+
export const POOLS = [...V3_POOLS] as const satisfies readonly (keyof typeof addressBook)[];
3029

3130
export type PoolIdentifier = (typeof POOLS)[number];
3231
export type PoolIdentifierV3 = (typeof V3_POOLS)[number];

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"ethers": "5.7.2",
4242
"ts-node": "^10.9.1",
4343
"tsx": "^4.16.3",
44-
"viem": "^2.18.6",
44+
"viem": "^2.23.6",
4545
"typescript": "^5.0.4"
4646
}
4747
}

scripts/deploy/DeployStewards.s.sol

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ import {AaveV3Metis} from 'aave-address-book/AaveV3Metis.sol';
2626
import {GovernanceV3Metis} from 'aave-address-book/GovernanceV3Metis.sol';
2727
import {AaveV3Linea} from 'aave-address-book/AaveV3Linea.sol';
2828
import {GovernanceV3Linea} from 'aave-address-book/GovernanceV3Linea.sol';
29+
import {AaveV3Sonic} from 'aave-address-book/AaveV3Sonic.sol';
30+
import {GovernanceV3Sonic} from 'aave-address-book/GovernanceV3Sonic.sol';
2931
import {IOwnable} from 'aave-address-book/common/IOwnable.sol';
3032
import {RiskSteward, IRiskSteward, IPoolDataProvider, IEngine} from '../../src/contracts/RiskSteward.sol';
3133

@@ -257,3 +259,17 @@ contract DeployLinea is LineaScript {
257259
vm.stopBroadcast();
258260
}
259261
}
262+
263+
// make deploy-ledger contract=scripts/deploy/DeployStewards.s.sol:DeploySonic chain=sonic
264+
contract DeploySonic is SonicScript {
265+
function run() external {
266+
vm.startBroadcast();
267+
DeployRiskStewards._deployRiskStewards(
268+
address(AaveV3Sonic.AAVE_PROTOCOL_DATA_PROVIDER),
269+
AaveV3Sonic.CONFIG_ENGINE,
270+
0x1dE39A17a9Fa8c76899fff37488482EEb7835d04, // sonic-risk-council
271+
GovernanceV3Sonic.EXECUTOR_LVL_1
272+
);
273+
vm.stopBroadcast();
274+
}
275+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.0;
3+
4+
import {AaveV3Sonic} from 'aave-address-book/AaveV3Sonic.sol';
5+
import {RiskStewardsBase} from '../RiskStewardsBase.s.sol';
6+
7+
abstract contract RiskStewardsSonic is RiskStewardsBase {
8+
constructor() RiskStewardsBase(address(AaveV3Sonic.POOL), AaveV3Sonic.RISK_STEWARD) {}
9+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.0;
3+
4+
import {AaveV3SonicAssets} from 'aave-address-book/AaveV3Sonic.sol';
5+
import {IAaveV3ConfigEngine as IEngine} from 'aave-v3-origin/src/contracts/extensions/v3-config-engine/IAaveV3ConfigEngine.sol';
6+
import {EngineFlags} from 'aave-v3-origin/src/contracts/extensions/v3-config-engine/EngineFlags.sol';
7+
import {RiskStewardsSonic} from '../../../scripts/networks/RiskStewardsSonic.s.sol';
8+
9+
// make run-script network=sonic contract=src/contracts/examples/SonicExample.sol:SonicExample broadcast=false generate_diff=true skip_timelock=false
10+
contract SonicExample is RiskStewardsSonic {
11+
/**
12+
* @return string name identifier used for the diff
13+
*/
14+
function name() public pure override returns (string memory) {
15+
return 'sonic_example';
16+
}
17+
18+
function capsUpdates() public pure override returns (IEngine.CapsUpdate[] memory) {
19+
IEngine.CapsUpdate[] memory capUpdates = new IEngine.CapsUpdate[](1);
20+
capUpdates[0] = IEngine.CapsUpdate(
21+
AaveV3SonicAssets.wS_UNDERLYING,
22+
21_000_000,
23+
EngineFlags.KEEP_CURRENT
24+
);
25+
return capUpdates;
26+
}
27+
}

tests/RiskSteward.t.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ contract RiskSteward_Test is Test {
2424
event RiskConfigSet(IRiskSteward.Config indexed riskConfig);
2525

2626
function setUp() public virtual {
27-
vm.createSelectFork(vm.rpcUrl('mainnet'), 20934847);
27+
vm.createSelectFork(vm.rpcUrl('mainnet'), 21974363);
2828

2929
configEngine = AaveV3Ethereum.CONFIG_ENGINE;
3030

0 commit comments

Comments
 (0)