Skip to content

Commit 4f47411

Browse files
committed
feat!: ts eModes exports (#629)
BREAKING CHANGE: The eMode exports on the js side now contain the full eMode configuration with the decoded bitmaps. Abis are exported via /abis to no longer mix with the addresses. Removing tokenlist from ts exports as there's no good reason to use it from here (integrations work with the toplevel json)
1 parent 1296c81 commit 4f47411

File tree

91 files changed

+3570
-8691
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+3570
-8691
lines changed

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ import { AaveV2Avalanche } from "@bgd-labs/aave-address-book"; // import specifi
6262
console.log(AaveV2Avalanche.POOL_ADDRESSES_PROVIDER);
6363
// "0xa97684ead0e402dC232d5A977953DF7ECBaB3CDb"
6464

65-
// in addition the chainId of the respecitve addresses is exported alongside
65+
// in addition the chainId of the respective addresses is exported alongside
6666
console.log(AaveV2Avalanche.CHAIN_ID);
6767
// 43114
6868
```
@@ -106,3 +106,11 @@ b) Adding an address that **cannot be obtained via onchain calls** so it needs t
106106
To achieve an addition here, you need to alter the [additionalAddresses section](https://github.com/bgd-labs/aave-address-book/blob/main/scripts/config.ts#L46) on the pool type and add your address to the respective pools. Additional addresses will currently be exported as type `address`. There's currently no possibility to define a custom type.
107107

108108
In any case you need to run `yarn generate:addresses` afterwards and commit the altered artifacts.
109+
110+
### Troubleshooting
111+
112+
#### Error generating the addresses
113+
114+
This repository will try to use public rpcs.
115+
For some networks they are not very reliable though, therefore you can set `RPC_<NETWORK>` in your .env to use a private rpc.
116+
Check https://github.com/bgd-labs/aave-address-book/blob/main/scripts/clients.ts#L39 for the chain naming convention.

package.json

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,18 @@
2525
},
2626
"types": "./dist/AaveAddressBook.d.ts",
2727
"default": "./dist/AaveAddressBook.js"
28+
},
29+
"./abis": {
30+
"require": {
31+
"types": "./dist/abis/index.d.ts",
32+
"default": "./dist/abis/index.js"
33+
},
34+
"import": {
35+
"types": "./dist/abis/index.mts",
36+
"default": "./dist/abis/index.mjs"
37+
},
38+
"types": "./dist/abis/index.d.ts",
39+
"default": "./dist/abis/index.js"
2840
}
2941
},
3042
"sideEffects": false,
@@ -52,7 +64,7 @@
5264
"homepage": "https://github.com/bgd-labs/aave-address-book#readme",
5365
"devDependencies": {
5466
"@bgd-labs/js-utils": "1.4.2",
55-
"@bgd-labs/react-web3-icons": "^1.4.4",
67+
"@bgd-labs/react-web3-icons": "^1.5.3",
5668
"@types/node": "^22.4.1",
5769
"@uniswap/token-lists": "^1.0.0-beta.33",
5870
"ajv": "^8.12.0",

safe.csv

Lines changed: 24 additions & 182 deletions
Large diffs are not rendered by default.

scripts/checks/utils.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import * as addressBook from '../../src/ts/AaveAddressBook';
2+
3+
export function getGovernance(chainId: number) {
4+
for (const [name, lib] of Object.entries(addressBook)) {
5+
if (name.startsWith('GovernanceV3') && lib.CHAIN_ID === chainId) return lib;
6+
}
7+
}
8+
9+
export function getMisc(chainId: number) {
10+
for (const [name, lib] of Object.entries(addressBook)) {
11+
if (name.startsWith('Misc') && lib.CHAIN_ID === chainId) return lib;
12+
}
13+
}

scripts/checks/wethGateway.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import {getContract} from 'viem';
2+
import {CHAIN_ID_CLIENT_MAP} from '../clients';
3+
import {IOwnable_ABI} from '../../src/ts/abis/IOwnable';
4+
import {getGovernance} from './utils';
5+
6+
export async function check(addresses: Record<string, any>) {
7+
if (addresses.WETH_GATEWAY) {
8+
const client = CHAIN_ID_CLIENT_MAP[addresses.CHAIN_ID];
9+
// on testnets owners are usually not governance
10+
if (!client.chain?.testnet) {
11+
const gateway = getContract({
12+
abi: IOwnable_ABI,
13+
address: addresses.WETH_GATEWAY,
14+
client,
15+
});
16+
const owner = await gateway.read.owner();
17+
const governance = getGovernance(addresses.CHAIN_ID);
18+
if (!governance) {
19+
console.log(
20+
'SANITY_GATEWAY: Skipped due to missing governance on chainId: ${addresses.CHAIN_ID}',
21+
);
22+
} else {
23+
const l1Executor = (governance as any).EXECUTOR_LVL_1;
24+
// prettier would be to check against executor lvl_1
25+
if (owner !== l1Executor) {
26+
throw new Error(
27+
`SANITY_GATEWAY: OWNER MISMATCH ${addresses.POOL}.${addresses.WETH_GATEWAY}:${owner} != ${l1Executor}`,
28+
);
29+
}
30+
}
31+
}
32+
}
33+
}

scripts/configs/abis.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export const ABI_INTERFACES = [
2121
'IAToken',
2222
'IDefaultInterestRateStrategy',
2323
'lib/aave-v3-origin/src/contracts/interfaces/IAaveOracle.sol:IAaveOracle',
24+
'lib/aave-v3-origin/src/contracts/rewards/interfaces/IRewardsController.sol:IRewardsController',
2425
'IExecutor',
2526
'ICrossChainController',
2627
'IWithGuardian',
@@ -35,6 +36,7 @@ export const ABI_INTERFACES = [
3536
'IStakeToken',
3637
'IStataTokenFactory',
3738
'IStataTokenV2',
39+
'lib/aave-v3-origin/src/contracts/helpers/interfaces/IWrappedTokenGatewayV3.sol:IWrappedTokenGatewayV3',
3840
];
3941

4042
/**

scripts/configs/types.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ export type ReserveData = {
8181
symbol: string;
8282
UNDERLYING: Hex;
8383
decimals: number;
84+
id: number;
8485
A_TOKEN: Hex;
8586
V_TOKEN: Hex;
8687
INTEREST_RATE_STRATEGY: Hex;
@@ -89,6 +90,15 @@ export type ReserveData = {
8990
STATA_TOKEN?: Hex;
9091
};
9192

93+
export type EMode = {
94+
label: string;
95+
ltv: number;
96+
liquidationThreshold: number;
97+
liquidationBonus: number;
98+
collateralBitmap: bigint;
99+
borrowableBitmap: bigint;
100+
};
101+
92102
/**
93103
* @dev config for addresses that belong more to a network then to a specific pool
94104
*/

scripts/generateABIs.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ export async function generateABIs(removeExisting: boolean) {
1515
} else {
1616
mkdirSync('./src/ts/abis');
1717
}
18-
const imports: string[] = [];
1918
for (const INTERFACE_PATH of ABI_INTERFACES) {
2019
const {stdout, stderr} = await awaitableExec(`forge inspect ${INTERFACE_PATH} abi`);
2120
const INTERFACE =

scripts/generateAddresses.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,8 @@ async function main() {
163163

164164
const abis = generateABIImports();
165165

166+
writeFileSync('./src/ts/abis/index.ts', abis.join('\n'));
167+
166168
const imports = [
167169
governanceNames,
168170
v1Library,
@@ -172,7 +174,6 @@ async function main() {
172174
govImports,
173175
smImports,
174176
tokenListImports,
175-
abis,
176177
].flat();
177178

178179
const jsExports = imports.map((f) => f.js).flat();

scripts/generator/abis.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,11 @@ export function generateABIImports() {
66
const INTERFACE =
77
INTERFACE_PATH.split(':').length > 1 ? INTERFACE_PATH.split(':')[1] : INTERFACE_PATH;
88
const varName = `${INTERFACE}_ABI`;
9-
jsExports.push(`export {${varName}} from './abis/${INTERFACE}';`);
9+
jsExports.push(`export {${varName}} from './${INTERFACE}';`);
1010
}
1111
for (const INTERFACE of DOWNLOAD_ABI_INTERFACES) {
1212
const varName = `${INTERFACE.name}_ABI`;
13-
jsExports.push(`export {${varName}} from './abis/${INTERFACE.name}';`);
13+
jsExports.push(`export {${varName}} from './${INTERFACE.name}';`);
1414
}
15-
return {
16-
solidity: [],
17-
js: jsExports,
18-
};
15+
return jsExports;
1916
}

0 commit comments

Comments
 (0)