diff --git a/src/reports/__snapshots__/diff-report.spec.ts.snap b/src/reports/__snapshots__/diff-report.spec.ts.snap index 6d110bd..bb6cdca 100644 --- a/src/reports/__snapshots__/diff-report.spec.ts.snap +++ b/src/reports/__snapshots__/diff-report.spec.ts.snap @@ -445,7 +445,7 @@ exports[`report > should generate a well formatted report for 3.0 to 3.1 1`] = ` exports[`report > should generate a well formatted report for 3.1 1`] = ` "## Reserve changes -### Reserve altered +### Reserves altered #### GHO ([0x40D16FC0246aD3160Ccc09B8D0D3A2cD28aE6C2f](https://etherscan.io/address/0x40D16FC0246aD3160Ccc09B8D0D3A2cD28aE6C2f)) @@ -455,60 +455,17 @@ exports[`report > should generate a well formatted report for 3.1 1`] = ` | baseVariableBorrowRate | 7 % | 6 % | | interestRate | ![before](/.assets/e03975867d1c729d1a52bbec364211baff2dab5a.svg) | ![after](/.assets/a1a7ab1f1b9fcdf6ffa41ac7a8b4daf2daf98328.svg) | -#### wstETH ([0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0](https://etherscan.io/address/0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0)) - -| description | value before | value after | -| --- | --- | --- | -| eMode.liquidationBonus | 1 % | 2 % | - - -#### ETHx ([0xA35b1B31Ce002FBF2058D22F30f95D405200A15b](https://etherscan.io/address/0xA35b1B31Ce002FBF2058D22F30f95D405200A15b)) - -| description | value before | value after | -| --- | --- | --- | -| eMode.liquidationBonus | 1 % | 2 % | - - -#### cbETH ([0xBe9895146f7AF43049ca1c1AE358B0541Ea49704](https://etherscan.io/address/0xBe9895146f7AF43049ca1c1AE358B0541Ea49704)) - -| description | value before | value after | -| --- | --- | --- | -| eMode.liquidationBonus | 1 % | 2 % | - - -#### WETH ([0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2](https://etherscan.io/address/0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2)) - -| description | value before | value after | -| --- | --- | --- | -| eMode.liquidationBonus | 1 % | 2 % | - - -#### weETH ([0xCd5fE23C85820F7B72D0926FC9b05b43E359b7ee](https://etherscan.io/address/0xCd5fE23C85820F7B72D0926FC9b05b43E359b7ee)) - -| description | value before | value after | -| --- | --- | --- | -| eMode.liquidationBonus | 1 % | 2 % | - - -#### rETH ([0xae78736Cd615f374D3085123A210448E74Fc6393](https://etherscan.io/address/0xae78736Cd615f374D3085123A210448E74Fc6393)) - -| description | value before | value after | -| --- | --- | --- | -| eMode.liquidationBonus | 1 % | 2 % | - +## Emodes changes -#### osETH ([0xf1C9acDc66974dFB6dEcB12aA385b9cD01190E38](https://etherscan.io/address/0xf1C9acDc66974dFB6dEcB12aA385b9cD01190E38)) +### EMode: ETH correlated(id: 1) -| description | value before | value after | -| --- | --- | --- | +| eMode.label (unchanged) | ETH correlated | ETH correlated | +| eMode.ltv (unchanged) | 93 % | 93 % | +| eMode.liquidationThreshold (unchanged) | 95 % | 95 % | | eMode.liquidationBonus | 1 % | 2 % | +| eMode.priceSource (unchanged) | 0x0000000000000000000000000000000000000000 | 0x0000000000000000000000000000000000000000 | -## Emodes changes - -### EMode 1:ETH correlated - -| eMode.liquidationBonus | 1 % | 2 % | ## Raw diff \`\`\`json @@ -691,18 +648,39 @@ exports[`report > should generate a well formatted report for 3.2 1`] = ` ## Emodes changes -### EMode 1:Stablecoins +### EMode: Stablecoins(id: 1) + +| eMode.borrowableBitmap | - | DAI, USDC, USDT, EURS, jEUR, EURA, miMATIC, USDC | +| eMode.collateralBitmap | - | DAI, USDC, USDT, EURS, jEUR, EURA, miMATIC, USDC | +| eMode.label (unchanged) | Stablecoins | Stablecoins | +| eMode.ltv (unchanged) | 93 % | 93 % | +| eMode.liquidationThreshold (unchanged) | 95 % | 95 % | +| eMode.liquidationBonus (unchanged) | 1 % | 1 % | +| eMode.priceSource (unchanged) | 0x0000000000000000000000000000000000000000 | 0x0000000000000000000000000000000000000000 | + + +### EMode: MATIC correlated(id: 2) + +| eMode.borrowableBitmap | - | WMATIC, stMATIC, MaticX | +| eMode.collateralBitmap | - | WMATIC, stMATIC, MaticX | +| 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 | + + +### EMode: ETH correlated(id: 3) -| eMode.borrowableBitmap | - | DAI,USDC,USDT,EURS,jEUR,EURA,miMATIC,USDC | -| eMode.collateralBitmap | - | DAI,USDC,USDT,EURS,jEUR,EURA,miMATIC,USDC | -### EMode 2:MATIC correlated +| 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 (unchanged) | 0x0000000000000000000000000000000000000000 | 0x0000000000000000000000000000000000000000 | -| eMode.borrowableBitmap | - | WMATIC,stMATIC,MaticX | -| eMode.collateralBitmap | - | WMATIC,stMATIC,MaticX | -### EMode 3:ETH correlated -| eMode.borrowableBitmap | - | WETH,wstETH | -| eMode.collateralBitmap | - | WETH,wstETH | ## Raw diff \`\`\`json diff --git a/src/reports/diff-reports.ts b/src/reports/diff-reports.ts index ddcf86d..d239bb3 100644 --- a/src/reports/diff-reports.ts +++ b/src/reports/diff-reports.ts @@ -1,6 +1,6 @@ import hash from 'object-hash'; import {diff} from './diff'; -import {renderEmode, renderEmodeDiff} from './emode'; +import {renderEmodeDiff} from './emode'; import {fetchRateStrategyImage} from './fetch-IR-strategy'; import {renderReserve, renderReserveDiff} from './reserve'; import {AaveV3Reserve, type AaveV3Snapshot} from './snapshot-types'; @@ -42,12 +42,6 @@ export async function diffReports { - it('should properly render new strategy', () => { - const out = renderEmode(EMODE_1); - expect(out).eq(`| eMode.label | Stablecoins | -| eMode.ltv | 97 % | -| eMode.liquidationThreshold | 97.5 % | -| eMode.liquidationBonus | 1 % | -| eMode.priceSource | 0x0000000000000000000000000000000000000000 | -`); - }); - it('should properly render strategy diff', () => { const result = diff(EMODE_1, EMODE_2); - expect(renderEmodeDiff(result as any)).eq(`| eMode.label | Stablecoins | Stablecoins (altered) | + expect(renderEmodeDiff(result as any, {} as any, {} as any)) + .eq(`| eMode.label | Stablecoins | Stablecoins (altered) | | eMode.ltv | 97 % | 2.5 % | | eMode.liquidationThreshold | 97.5 % | 5 % | | eMode.liquidationBonus | 1 % | -90 % | +| eMode.priceSource (unchanged) | 0x0000000000000000000000000000000000000000 | 0x0000000000000000000000000000000000000000 | `); }); }); diff --git a/src/reports/emode.ts b/src/reports/emode.ts index 3c5ecd0..07494dc 100644 --- a/src/reports/emode.ts +++ b/src/reports/emode.ts @@ -14,12 +14,14 @@ export function renderEModeValue( return emode[key] === 0 ? '0 %' : `${((emode[key] as number) - 10000) / 100} %`; if (key === 'borrowableBitmap' || key === 'collateralBitmap') { const indexes = bitMapToIndexes(BigInt(emode[key])); - return indexes.map( - (i) => - snapshot.reserves[ - Object.keys(snapshot.reserves).find((key) => snapshot.reserves[key].id === i) as any - ].symbol, - ); + return indexes + .map( + (i) => + snapshot.reserves[ + Object.keys(snapshot.reserves).find((key) => snapshot.reserves[key].id === i) as any + ].symbol, + ) + .join(', '); } return emode[key]; } @@ -50,17 +52,6 @@ function sortEmodeKeys(a: keyof AaveV3Emode, b: keyof AaveV3Emode) { const OMIT_KEYS: (keyof AaveV3Emode)[] = ['eModeCategory']; -export function renderEmode(eMode: AaveV3Emode) { - let content = ''; - (Object.keys(eMode) as (keyof AaveV3Emode)[]) - .filter((key) => !OMIT_KEYS.includes(key)) - .sort(sortEmodeKeys) - .map((key) => { - content += `| eMode.${key} | ${renderEModeValue(key, eMode)} |\n`; - }); - return content; -} - export type EmodeDiff = { [key in keyof AaveV3Emode]: A[key] & { from: A[key] | null; @@ -73,17 +64,21 @@ export function renderEmodeDiff(diff: EmodeDiff, pre: AaveV3Snapshot, post: Aave (Object.keys(diff) as (keyof AaveV3Emode)[]) .filter((key) => !OMIT_KEYS.includes(key)) - .filter((key) => diff[key].hasOwnProperty('from')) .sort(sortEmodeKeys) .map((key) => { - content += `| eMode.${key} | ${renderEModeValue( - key, - { - ...diff, - [key]: diff[key].from, - }, - pre, - )} | ${renderEModeValue(key, {...diff, [key]: diff[key].to}, post)} |\n`; + if (typeof diff[key] === 'object' && diff[key].hasOwnProperty('from')) + content += `| eMode.${key} | ${renderEModeValue( + key, + { + ...diff, + [key]: diff[key].from, + }, + pre, + )} | ${renderEModeValue(key, {...diff, [key]: diff[key].to}, post)} |\n`; + else { + const value = renderEModeValue(key, diff, pre); + content += `| eMode.${key} (unchanged) | ${value} | ${value} |\n`; + } }); return content;