Skip to content

Commit

Permalink
fix: upgrade to address book v4
Browse files Browse the repository at this point in the history
  • Loading branch information
sakulstra committed Oct 21, 2024
1 parent 086f584 commit 4a89fb7
Show file tree
Hide file tree
Showing 12 changed files with 133 additions and 1,471 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@
"access": "public"
},
"dependencies": {
"@bgd-labs/aave-address-book": "^3.0.0",
"@bgd-labs/aave-v3-governance-cache": "^1.0.6",
"@bgd-labs/aave-address-book": "^4.2.0",
"@bgd-labs/aave-v3-governance-cache": "^1.0.8",
"@bgd-labs/js-utils": "^1.4.2",
"@commander-js/extra-typings": "^11.1.0",
"@inquirer/prompts": "^3.3.2",
Expand All @@ -72,7 +72,7 @@
"ipfs-unixfs-importer": "^15.3.1",
"json-bigint": "^1.0.0",
"object-hash": "^3.0.0",
"viem": "^2.17.11",
"viem": "^2.21.32",
"zod": "^3.23.8"
}
}
3 changes: 1 addition & 2 deletions src/commands/governance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
IDataWarehouse_ABI,
IVotingMachineWithProofs_ABI,
IVotingPortal_ABI,
} from '@bgd-labs/aave-address-book';
} from '@bgd-labs/aave-address-book/abis';
import {CHAIN_ID_CLIENT_MAP} from '@bgd-labs/js-utils';
import type {Command} from '@commander-js/extra-typings';
import {confirm, input, select} from '@inquirer/prompts';
Expand All @@ -14,7 +14,6 @@ import {getAccountRPL, getBlockRLP} from '../govv3/proofs';
import {simulateProposal} from '../govv3/simulate';
import {findPayloadsController} from '../govv3/utils/checkAddress';
import {toAddressLink, toTxLink} from '../govv3/utils/markdownUtils';
import {getCachedIpfs} from '../ipfs/getCachedProposalMetaData';
import {DEFAULT_GOVERNANCE, DEFAULT_GOVERNANCE_CLIENT, FORMAT} from '../utils/constants';
import {logError, logInfo, logSuccess} from '../utils/logger';
import {getBlock} from 'viem/actions';
Expand Down
1,103 changes: 0 additions & 1,103 deletions src/govv3/__snapshots__/generatePayloadReport.spec.ts.snap

This file was deleted.

262 changes: 17 additions & 245 deletions src/govv3/checks/__snapshots__/state.spec.ts.snap

Large diffs are not rendered by default.

8 changes: 2 additions & 6 deletions src/govv3/governance.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import {
AaveSafetyModule,
AaveV3Ethereum,
GovernanceV3Ethereum,
IGovernanceCore_ABI,
} from '@bgd-labs/aave-address-book';
import {AaveSafetyModule, AaveV3Ethereum, GovernanceV3Ethereum} from '@bgd-labs/aave-address-book';
import {IGovernanceCore_ABI} from '@bgd-labs/aave-address-book/abis';
import merge from 'deepmerge';
import {
type Client,
Expand Down
2 changes: 1 addition & 1 deletion src/govv3/payloadsController.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {IPayloadsControllerCore_ABI} from '@bgd-labs/aave-address-book';
import {IPayloadsControllerCore_ABI} from '@bgd-labs/aave-address-book/abis';
import {
type Client,
type GetContractReturnType,
Expand Down
4 changes: 2 additions & 2 deletions src/govv3/utils/checkAddress.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as addresses from '@bgd-labs/aave-address-book';
import {IPool_ABI} from '@bgd-labs/aave-address-book';
import {IPool_ABI, IERC20Detailed_ABI} from '@bgd-labs/aave-address-book/abis';
import {findObjectPaths} from 'find-object-paths';
import {type Address, type Client, HDKey, type Hex, getAddress, getContract} from 'viem';

Expand Down Expand Up @@ -54,7 +54,7 @@ export async function findAsset(client: Client, address: Hex) {
const chainId = client.chain!.id;
const asset = assetsCache[chainId][address];
if (asset) return asset;
const erc20Contract = getContract({client, address: address, abi: addresses.IERC20Detailed_ABI});
const erc20Contract = getContract({client, address: address, abi: IERC20Detailed_ABI});
let symbol = 'unknown';
let decimals = 0;
try {
Expand Down
57 changes: 38 additions & 19 deletions src/reports/__snapshots__/diff-report.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,29 @@ exports[`report > should generate a well formatted report 1`] = `
| maxExcessUsageRatio | 10 % | 20 % |
| interestRate | ![before](/.assets/1baf85e415bd720bc42ec928d822cffbd4236d90.svg) | ![after](/.assets/8a10dd458958b063af4177af8f709f1971c58974.svg) |
## Emodes changes
## Emodes changed
### EMode: Stablecoins(id: 1)
| description | value before | value after |
| --- | --- | --- |
| eMode.label (unchanged) | Stablecoins | Stablecoins |
| eMode.ltv (unchanged) | 97 % | 97 % |
| eMode.liquidationThreshold (unchanged) | 97.5 % | 97.5 % |
| eMode.liquidationBonus (unchanged) | 1 % | 1 % |
| eMode.priceSource (unchanged) | 0x0000000000000000000000000000000000000000 | 0x0000000000000000000000000000000000000000 |
### EMode: MATIC correlated(id: 2)
| description | value before | value after |
| --- | --- | --- |
| eMode.label (unchanged) | MATIC correlated | MATIC correlated |
| eMode.ltv (unchanged) | 92.5 % | 92.5 % |
| eMode.liquidationThreshold (unchanged) | 95 % | 95 % |
| eMode.liquidationBonus (unchanged) | 1 % | 1 % |
| eMode.priceSource (unchanged) | 0x0000000000000000000000000000000000000000 | 0x0000000000000000000000000000000000000000 |
## Raw diff
Expand Down Expand Up @@ -455,7 +477,7 @@ exports[`report > should generate a well formatted report for 3.1 1`] = `
| baseVariableBorrowRate | 7 % | 6 % |
| interestRate | ![before](/.assets/e03975867d1c729d1a52bbec364211baff2dab5a.svg) | ![after](/.assets/a1a7ab1f1b9fcdf6ffa41ac7a8b4daf2daf98328.svg) |
## Emodes changes
## Emodes changed
### EMode: ETH correlated(id: 1)
Expand Down Expand Up @@ -725,7 +747,7 @@ exports[`report > should generate a well formatted report for 3.2 1`] = `
| virtualBalance | 59,674,820.1425 MaticX [59674820142506423784946083] | 48,949,624.5780 MaticX [48949624578017424059164451] |
| interestRate | ![before](/.assets/bb82eaef94e0b09bad831160b0da80f2328914fd.svg) | ![after](/.assets/78c0f3b7f769cca3cb57e2779e98f21b765db629.svg) |
## Emodes changes
## Emodes changed
### EMode: Stablecoins(id: 1)
Expand Down Expand Up @@ -757,13 +779,12 @@ exports[`report > should generate a well formatted report for 3.2 1`] = `
| description | value before | value after |
| --- | --- | --- |
| eMode.label | - | ETH correlated |
| eMode.ltv | - | 90 % |
| eMode.liquidationThreshold | - | 93 % |
| eMode.liquidationBonus | - | 1 % |
| eMode.borrowableBitmap | - | WETH, wstETH |
| eMode.collateralBitmap | - | WETH, wstETH |
| eMode.label (unchanged) | ETH correlated | ETH correlated |
| eMode.ltv (unchanged) | 90 % | 90 % |
| eMode.liquidationThreshold (unchanged) | 93 % | 93 % |
| eMode.liquidationBonus (unchanged) | 1 % | 1 % |
| eMode.priceSource | 0x0000000000000000000000000000000000000000 | - |
## Raw diff
Expand Down Expand Up @@ -800,17 +821,15 @@ exports[`report > should generate a well formatted report for 3.2 1`] = `
}
},
"3": {
"priceSource": {
"from": "0x0000000000000000000000000000000000000000",
"to": null
},
"borrowableBitmap": {
"from": null,
"to": "524304"
},
"collateralBitmap": {
"from": null,
"to": "524304"
"from": null,
"to": {
"borrowableBitmap": "524304",
"collateralBitmap": "524304",
"eModeCategory": 3,
"label": "ETH correlated",
"liquidationBonus": 10100,
"liquidationThreshold": 9300,
"ltv": 9000
}
}
},
Expand Down
20 changes: 9 additions & 11 deletions src/reports/__snapshots__/diff.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -332,17 +332,15 @@ exports[`diff > should find all the changes in 3.2 1`] = `
},
},
"3": {
"borrowableBitmap": {
"from": null,
"to": "524304",
},
"collateralBitmap": {
"from": null,
"to": "524304",
},
"priceSource": {
"from": "0x0000000000000000000000000000000000000000",
"to": null,
"from": null,
"to": {
"borrowableBitmap": "524304",
"collateralBitmap": "524304",
"eModeCategory": 3,
"label": "ETH correlated",
"liquidationBonus": 10100,
"liquidationThreshold": 9300,
"ltv": 9000,
},
},
},
Expand Down
14 changes: 11 additions & 3 deletions src/reports/diff-reports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ function hasDiff(input: Record<string, any>): boolean {
return !!Object.keys(input).find(
(key) =>
typeof input[key as keyof typeof input] === 'object' &&
input[key as keyof typeof input] !== null &&
(input[key as keyof typeof input].hasOwnProperty('from') ||
input[key as keyof typeof input].hasOwnProperty('to')),
);
Expand Down Expand Up @@ -102,18 +103,25 @@ export async function diffReports<A extends AaveV3Snapshot, B extends AaveV3Snap
}

if (diffResult.eModes) {
content += '## Emodes changes\n\n';
content += '## Emodes changed\n\n';
for (const eMode of Object.keys(diffResult.eModes)) {
const hasChanges = hasDiff(diffResult.eModes?.[eMode]);
content += `### EMode: ${post.eModes[eMode].label}(id: ${post.eModes[eMode].eModeCategory})\n\n`;
if (hasChanges) {
content += `### EMode: ${pre.eModes[eMode].label}(id: ${pre.eModes[eMode].eModeCategory})\n\n`;
content += renderEmodeDiff(
diff(pre.eModes[eMode] || {}, post.eModes[eMode] || {}) as any,
pre,
post,
);
content += '\n\n';
// when it doesn't have changes it means the eMode is new
} else {
content += renderEmodeDiff(
diff(pre.eModes[eMode] || {}, post.eModes[eMode] || {}) as any,
pre,
post,
);
}
content += '\n\n';
}
}

Expand Down
8 changes: 0 additions & 8 deletions src/reports/mocks/pre3-2.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,6 @@
"liquidationThreshold": 9500,
"ltv": 9250,
"priceSource": "0x0000000000000000000000000000000000000000"
},
"3": {
"eModeCategory": 3,
"label": "ETH correlated",
"liquidationBonus": 10100,
"liquidationThreshold": 9300,
"ltv": 9000,
"priceSource": "0x0000000000000000000000000000000000000000"
}
},
"poolConfig": {
Expand Down
Loading

0 comments on commit 4a89fb7

Please sign in to comment.