Skip to content

Commit 4a89fb7

Browse files
committed
fix: upgrade to address book v4
1 parent 086f584 commit 4a89fb7

File tree

12 files changed

+133
-1471
lines changed

12 files changed

+133
-1471
lines changed

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@
5858
"access": "public"
5959
},
6060
"dependencies": {
61-
"@bgd-labs/aave-address-book": "^3.0.0",
62-
"@bgd-labs/aave-v3-governance-cache": "^1.0.6",
61+
"@bgd-labs/aave-address-book": "^4.2.0",
62+
"@bgd-labs/aave-v3-governance-cache": "^1.0.8",
6363
"@bgd-labs/js-utils": "^1.4.2",
6464
"@commander-js/extra-typings": "^11.1.0",
6565
"@inquirer/prompts": "^3.3.2",
@@ -72,7 +72,7 @@
7272
"ipfs-unixfs-importer": "^15.3.1",
7373
"json-bigint": "^1.0.0",
7474
"object-hash": "^3.0.0",
75-
"viem": "^2.17.11",
75+
"viem": "^2.21.32",
7676
"zod": "^3.23.8"
7777
}
7878
}

src/commands/governance.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {
22
IDataWarehouse_ABI,
33
IVotingMachineWithProofs_ABI,
44
IVotingPortal_ABI,
5-
} from '@bgd-labs/aave-address-book';
5+
} from '@bgd-labs/aave-address-book/abis';
66
import {CHAIN_ID_CLIENT_MAP} from '@bgd-labs/js-utils';
77
import type {Command} from '@commander-js/extra-typings';
88
import {confirm, input, select} from '@inquirer/prompts';
@@ -14,7 +14,6 @@ import {getAccountRPL, getBlockRLP} from '../govv3/proofs';
1414
import {simulateProposal} from '../govv3/simulate';
1515
import {findPayloadsController} from '../govv3/utils/checkAddress';
1616
import {toAddressLink, toTxLink} from '../govv3/utils/markdownUtils';
17-
import {getCachedIpfs} from '../ipfs/getCachedProposalMetaData';
1817
import {DEFAULT_GOVERNANCE, DEFAULT_GOVERNANCE_CLIENT, FORMAT} from '../utils/constants';
1918
import {logError, logInfo, logSuccess} from '../utils/logger';
2019
import {getBlock} from 'viem/actions';

src/govv3/__snapshots__/generatePayloadReport.spec.ts.snap

Lines changed: 0 additions & 1103 deletions
This file was deleted.

src/govv3/checks/__snapshots__/state.spec.ts.snap

Lines changed: 17 additions & 245 deletions
Large diffs are not rendered by default.

src/govv3/governance.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
import {
2-
AaveSafetyModule,
3-
AaveV3Ethereum,
4-
GovernanceV3Ethereum,
5-
IGovernanceCore_ABI,
6-
} from '@bgd-labs/aave-address-book';
1+
import {AaveSafetyModule, AaveV3Ethereum, GovernanceV3Ethereum} from '@bgd-labs/aave-address-book';
2+
import {IGovernanceCore_ABI} from '@bgd-labs/aave-address-book/abis';
73
import merge from 'deepmerge';
84
import {
95
type Client,

src/govv3/payloadsController.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {IPayloadsControllerCore_ABI} from '@bgd-labs/aave-address-book';
1+
import {IPayloadsControllerCore_ABI} from '@bgd-labs/aave-address-book/abis';
22
import {
33
type Client,
44
type GetContractReturnType,

src/govv3/utils/checkAddress.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as addresses from '@bgd-labs/aave-address-book';
2-
import {IPool_ABI} from '@bgd-labs/aave-address-book';
2+
import {IPool_ABI, IERC20Detailed_ABI} from '@bgd-labs/aave-address-book/abis';
33
import {findObjectPaths} from 'find-object-paths';
44
import {type Address, type Client, HDKey, type Hex, getAddress, getContract} from 'viem';
55

@@ -54,7 +54,7 @@ export async function findAsset(client: Client, address: Hex) {
5454
const chainId = client.chain!.id;
5555
const asset = assetsCache[chainId][address];
5656
if (asset) return asset;
57-
const erc20Contract = getContract({client, address: address, abi: addresses.IERC20Detailed_ABI});
57+
const erc20Contract = getContract({client, address: address, abi: IERC20Detailed_ABI});
5858
let symbol = 'unknown';
5959
let decimals = 0;
6060
try {

src/reports/__snapshots__/diff-report.spec.ts.snap

Lines changed: 38 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,29 @@ exports[`report > should generate a well formatted report 1`] = `
9090
| maxExcessUsageRatio | 10 % | 20 % |
9191
| interestRate | ![before](/.assets/1baf85e415bd720bc42ec928d822cffbd4236d90.svg) | ![after](/.assets/8a10dd458958b063af4177af8f709f1971c58974.svg) |
9292
93-
## Emodes changes
93+
## Emodes changed
94+
95+
### EMode: Stablecoins(id: 1)
96+
97+
| description | value before | value after |
98+
| --- | --- | --- |
99+
| eMode.label (unchanged) | Stablecoins | Stablecoins |
100+
| eMode.ltv (unchanged) | 97 % | 97 % |
101+
| eMode.liquidationThreshold (unchanged) | 97.5 % | 97.5 % |
102+
| eMode.liquidationBonus (unchanged) | 1 % | 1 % |
103+
| eMode.priceSource (unchanged) | 0x0000000000000000000000000000000000000000 | 0x0000000000000000000000000000000000000000 |
104+
105+
106+
### EMode: MATIC correlated(id: 2)
107+
108+
| description | value before | value after |
109+
| --- | --- | --- |
110+
| eMode.label (unchanged) | MATIC correlated | MATIC correlated |
111+
| eMode.ltv (unchanged) | 92.5 % | 92.5 % |
112+
| eMode.liquidationThreshold (unchanged) | 95 % | 95 % |
113+
| eMode.liquidationBonus (unchanged) | 1 % | 1 % |
114+
| eMode.priceSource (unchanged) | 0x0000000000000000000000000000000000000000 | 0x0000000000000000000000000000000000000000 |
115+
94116
95117
## Raw diff
96118
@@ -455,7 +477,7 @@ exports[`report > should generate a well formatted report for 3.1 1`] = `
455477
| baseVariableBorrowRate | 7 % | 6 % |
456478
| interestRate | ![before](/.assets/e03975867d1c729d1a52bbec364211baff2dab5a.svg) | ![after](/.assets/a1a7ab1f1b9fcdf6ffa41ac7a8b4daf2daf98328.svg) |
457479
458-
## Emodes changes
480+
## Emodes changed
459481
460482
### EMode: ETH correlated(id: 1)
461483
@@ -725,7 +747,7 @@ exports[`report > should generate a well formatted report for 3.2 1`] = `
725747
| virtualBalance | 59,674,820.1425 MaticX [59674820142506423784946083] | 48,949,624.5780 MaticX [48949624578017424059164451] |
726748
| interestRate | ![before](/.assets/bb82eaef94e0b09bad831160b0da80f2328914fd.svg) | ![after](/.assets/78c0f3b7f769cca3cb57e2779e98f21b765db629.svg) |
727749
728-
## Emodes changes
750+
## Emodes changed
729751
730752
### EMode: Stablecoins(id: 1)
731753
@@ -757,13 +779,12 @@ exports[`report > should generate a well formatted report for 3.2 1`] = `
757779
758780
| description | value before | value after |
759781
| --- | --- | --- |
782+
| eMode.label | - | ETH correlated |
783+
| eMode.ltv | - | 90 % |
784+
| eMode.liquidationThreshold | - | 93 % |
785+
| eMode.liquidationBonus | - | 1 % |
760786
| eMode.borrowableBitmap | - | WETH, wstETH |
761787
| eMode.collateralBitmap | - | WETH, wstETH |
762-
| eMode.label (unchanged) | ETH correlated | ETH correlated |
763-
| eMode.ltv (unchanged) | 90 % | 90 % |
764-
| eMode.liquidationThreshold (unchanged) | 93 % | 93 % |
765-
| eMode.liquidationBonus (unchanged) | 1 % | 1 % |
766-
| eMode.priceSource | 0x0000000000000000000000000000000000000000 | - |
767788
768789
769790
## Raw diff
@@ -800,17 +821,15 @@ exports[`report > should generate a well formatted report for 3.2 1`] = `
800821
}
801822
},
802823
"3": {
803-
"priceSource": {
804-
"from": "0x0000000000000000000000000000000000000000",
805-
"to": null
806-
},
807-
"borrowableBitmap": {
808-
"from": null,
809-
"to": "524304"
810-
},
811-
"collateralBitmap": {
812-
"from": null,
813-
"to": "524304"
824+
"from": null,
825+
"to": {
826+
"borrowableBitmap": "524304",
827+
"collateralBitmap": "524304",
828+
"eModeCategory": 3,
829+
"label": "ETH correlated",
830+
"liquidationBonus": 10100,
831+
"liquidationThreshold": 9300,
832+
"ltv": 9000
814833
}
815834
}
816835
},

src/reports/__snapshots__/diff.spec.ts.snap

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -332,17 +332,15 @@ exports[`diff > should find all the changes in 3.2 1`] = `
332332
},
333333
},
334334
"3": {
335-
"borrowableBitmap": {
336-
"from": null,
337-
"to": "524304",
338-
},
339-
"collateralBitmap": {
340-
"from": null,
341-
"to": "524304",
342-
},
343-
"priceSource": {
344-
"from": "0x0000000000000000000000000000000000000000",
345-
"to": null,
335+
"from": null,
336+
"to": {
337+
"borrowableBitmap": "524304",
338+
"collateralBitmap": "524304",
339+
"eModeCategory": 3,
340+
"label": "ETH correlated",
341+
"liquidationBonus": 10100,
342+
"liquidationThreshold": 9300,
343+
"ltv": 9000,
346344
},
347345
},
348346
},

src/reports/diff-reports.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ function hasDiff(input: Record<string, any>): boolean {
1313
return !!Object.keys(input).find(
1414
(key) =>
1515
typeof input[key as keyof typeof input] === 'object' &&
16+
input[key as keyof typeof input] !== null &&
1617
(input[key as keyof typeof input].hasOwnProperty('from') ||
1718
input[key as keyof typeof input].hasOwnProperty('to')),
1819
);
@@ -102,18 +103,25 @@ export async function diffReports<A extends AaveV3Snapshot, B extends AaveV3Snap
102103
}
103104

104105
if (diffResult.eModes) {
105-
content += '## Emodes changes\n\n';
106+
content += '## Emodes changed\n\n';
106107
for (const eMode of Object.keys(diffResult.eModes)) {
107108
const hasChanges = hasDiff(diffResult.eModes?.[eMode]);
109+
content += `### EMode: ${post.eModes[eMode].label}(id: ${post.eModes[eMode].eModeCategory})\n\n`;
108110
if (hasChanges) {
109-
content += `### EMode: ${pre.eModes[eMode].label}(id: ${pre.eModes[eMode].eModeCategory})\n\n`;
110111
content += renderEmodeDiff(
111112
diff(pre.eModes[eMode] || {}, post.eModes[eMode] || {}) as any,
112113
pre,
113114
post,
114115
);
115-
content += '\n\n';
116+
// when it doesn't have changes it means the eMode is new
117+
} else {
118+
content += renderEmodeDiff(
119+
diff(pre.eModes[eMode] || {}, post.eModes[eMode] || {}) as any,
120+
pre,
121+
post,
122+
);
116123
}
124+
content += '\n\n';
117125
}
118126
}
119127

0 commit comments

Comments
 (0)