From 4530357b3b394576786f794619659ee52aafb9e2 Mon Sep 17 00:00:00 2001 From: sakulstra Date: Wed, 24 Jul 2024 15:40:10 +0200 Subject: [PATCH] fix: properly render virtual balance fields --- ...f9cbdfc80fe1053a3498957e9ebcc43204ca2e.svg | 1 + ...5444425ee9452f419610e3fd51b1682c09f4e7.svg | 1 + package.json | 12 +- .../adi-diff-report.spec.ts.snap | 30 ++ src/reports/__snapshots__/diff.spec.ts.snap | 301 ++++++++++++++++++ src/reports/__snapshots__/report.spec.ts.snap | 144 +++++++++ .../__snapshots__/reserve.spec.ts.snap | 6 + ...report.spec.ts => adi-diff-report.spec.ts} | 0 src/reports/diff.spec.ts | 9 +- src/reports/mocks/post3-1.json | 186 +++++++++++ src/reports/mocks/pre3-1.json | 168 ++++++++++ src/reports/report.spec.ts | 11 + src/reports/reserve.spec.ts | 3 + src/reports/reserve.ts | 6 + 14 files changed, 871 insertions(+), 7 deletions(-) create mode 100644 .assets/25f9cbdfc80fe1053a3498957e9ebcc43204ca2e.svg create mode 100644 .assets/c95444425ee9452f419610e3fd51b1682c09f4e7.svg create mode 100644 src/reports/__snapshots__/adi-diff-report.spec.ts.snap create mode 100644 src/reports/__snapshots__/diff.spec.ts.snap rename src/reports/{adi-report.spec.ts => adi-diff-report.spec.ts} (100%) create mode 100644 src/reports/mocks/post3-1.json create mode 100644 src/reports/mocks/pre3-1.json diff --git a/.assets/25f9cbdfc80fe1053a3498957e9ebcc43204ca2e.svg b/.assets/25f9cbdfc80fe1053a3498957e9ebcc43204ca2e.svg new file mode 100644 index 0000000..87c395c --- /dev/null +++ b/.assets/25f9cbdfc80fe1053a3498957e9ebcc43204ca2e.svg @@ -0,0 +1 @@ + Borrow APR, variableBorrow APR, stable0%25%50%75%100%0%20%40%60%80%Optimal utilization 45%Optimal utilization 45% \ No newline at end of file diff --git a/.assets/c95444425ee9452f419610e3fd51b1682c09f4e7.svg b/.assets/c95444425ee9452f419610e3fd51b1682c09f4e7.svg new file mode 100644 index 0000000..87c395c --- /dev/null +++ b/.assets/c95444425ee9452f419610e3fd51b1682c09f4e7.svg @@ -0,0 +1 @@ + Borrow APR, variableBorrow APR, stable0%25%50%75%100%0%20%40%60%80%Optimal utilization 45%Optimal utilization 45% \ No newline at end of file diff --git a/package.json b/package.json index 3a4e41f..37b3503 100644 --- a/package.json +++ b/package.json @@ -57,21 +57,21 @@ "access": "public" }, "dependencies": { - "@bgd-labs/aave-address-book": "^2.25.1", - "@bgd-labs/aave-v3-governance-cache": "^0.0.13", - "@bgd-labs/js-utils": "^1.3.0", + "@bgd-labs/aave-address-book": "^3.0.0", + "@bgd-labs/aave-v3-governance-cache": "^1.0.6", + "@bgd-labs/js-utils": "^1.4.2", "@commander-js/extra-typings": "^11.1.0", "@inquirer/prompts": "^3.3.2", "chalk": "^4.1.2", "commander": "^11.1.0", "deepmerge": "^4.3.1", "dotenv": "^16.4.1", - "find-object-paths": "^1.0.2", + "find-object-paths": "^1.1.0", "gray-matter": "^4.0.3", "ipfs-only-hash": "^4.0.0", "json-bigint": "^1.0.0", "object-hash": "^3.0.0", - "viem": "^2.9.20", - "zod": "^3.22.4" + "viem": "^2.17.11", + "zod": "^3.23.8" } } diff --git a/src/reports/__snapshots__/adi-diff-report.spec.ts.snap b/src/reports/__snapshots__/adi-diff-report.spec.ts.snap new file mode 100644 index 0000000..024c323 --- /dev/null +++ b/src/reports/__snapshots__/adi-diff-report.spec.ts.snap @@ -0,0 +1,30 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`adi report > should generate a well formatted adi report 1`] = ` +"## Raw diff + +\`\`\`json +{ + "forwarderAdaptersByChain": { + "1": { + "destination_3": { + "from": "0xb13712De579E1f9943502FFCf72eab6ec348cF79", + "to": "0x1562F1b2487F892BBA8Ef325aF054Fd157510a71" + }, + "origin_3": { + "from": "0xb13712De579E1f9943502FFCf72eab6ec348cF79", + "to": "0x853649f897383f89d8441346Cf26a9ed02720B02" + } + } + }, + "receiverAdaptersByChain": { + "1": { + "receiver_3": { + "from": "0xb13712De579E1f9943502FFCf72eab6ec348cF79", + "to": "0x853649f897383f89d8441346Cf26a9ed02720B02" + } + } + } +} +\`\`\`" +`; diff --git a/src/reports/__snapshots__/diff.spec.ts.snap b/src/reports/__snapshots__/diff.spec.ts.snap new file mode 100644 index 0000000..b8f169c --- /dev/null +++ b/src/reports/__snapshots__/diff.spec.ts.snap @@ -0,0 +1,301 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`diff > should find all the changes 1`] = ` +{ + "reserves": { + "0x0b3F868E0BE5597D5DB7fEB59E1CADBb0fdDa50a": { + "currentLiquidityRate": { + "from": 1.3415266124935912e+22, + "to": 1.3515266124935913e+22, + }, + "currentVariableBorrowRate": { + "from": 1.6150925573283835e+24, + "to": 1.7150925573283834e+24, + }, + "liquidityIndex": { + "from": 1.0030723628446084e+27, + "to": 1.1020723628446084e+27, + }, + "variableBorrowIndex": { + "from": 1.0191200042968116e+27, + "to": 1.0211200042968116e+27, + }, + }, + "0x385Eeac5cB85A38A9a07A70c73e0a3271CfB54A7": { + "reserveFactor": { + "from": 2000, + "to": 3500, + }, + }, + "0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619": { + "interestRateStrategy": { + "from": "0x03733F4E008d36f2e37F0080fF1c8DF756622E6F", + "to": "0x27eFE5db315b71753b2a38ED3d5dd7E9362ba93F", + }, + "reserveFactor": { + "from": 1000, + "to": 1500, + }, + }, + "0x85955046DF4668e1DD369D2DE9f3AEB98DD2A369": { + "reserveFactor": { + "from": 2000, + "to": 3500, + }, + }, + "0xE0B52e49357Fd4DAf2c15e02058DCE6BC0057db4": { + "interestRateStrategy": { + "from": "0x41B66b4b6b4c9dab039d96528D1b88f7BAF8C5A4", + "to": "0xA9F3C3caE095527061e6d270DBE163693e6fda9D", + }, + }, + "0xE111178A87A3BFf0c8d18DECBa5798827539Ae99": { + "interestRateStrategy": { + "from": "0x41B66b4b6b4c9dab039d96528D1b88f7BAF8C5A4", + "to": "0xA9F3C3caE095527061e6d270DBE163693e6fda9D", + }, + }, + "0xa3Fa99A148fA48D14Ed51d610c367C61876997F1": { + "interestRateStrategy": { + "from": "0x41B66b4b6b4c9dab039d96528D1b88f7BAF8C5A4", + "to": "0xA9F3C3caE095527061e6d270DBE163693e6fda9D", + }, + "reserveFactor": { + "from": 1000, + "to": 2000, + }, + }, + "0xc2132D05D31c914a87C6611C10748AEb04B58e8F": { + "interestRateStrategy": { + "from": "0x41B66b4b6b4c9dab039d96528D1b88f7BAF8C5A4", + "to": "0xA9F3C3caE095527061e6d270DBE163693e6fda9D", + }, + }, + }, + "strategies": { + "0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619": { + "address": { + "from": "0x03733F4E008d36f2e37F0080fF1c8DF756622E6F", + "to": "0x27eFE5db315b71753b2a38ED3d5dd7E9362ba93F", + }, + "baseStableBorrowRate": { + "from": 9e+25, + "to": 6.8e+25, + }, + "baseVariableBorrowRate": { + "from": 0, + "to": 1e+25, + }, + "maxExcessUsageRatio": { + "from": 5.5e+26, + "to": 2e+26, + }, + "optimalUsageRatio": { + "from": 4.5e+26, + "to": 8e+26, + }, + "stableRateSlope1": { + "from": 0, + "to": 4e+25, + }, + "stableRateSlope2": { + "from": 0, + "to": 8e+26, + }, + "variableRateSlope1": { + "from": 7e+25, + "to": 3.8e+25, + }, + "variableRateSlope2": { + "from": 3e+27, + "to": 8e+26, + }, + }, + "0xE0B52e49357Fd4DAf2c15e02058DCE6BC0057db4": { + "address": { + "from": "0x41B66b4b6b4c9dab039d96528D1b88f7BAF8C5A4", + "to": "0xA9F3C3caE095527061e6d270DBE163693e6fda9D", + }, + "maxExcessUsageRatio": { + "from": 1e+26, + "to": 2e+26, + }, + "optimalUsageRatio": { + "from": 9e+26, + "to": 8e+26, + }, + "stableRateSlope2": { + "from": 6e+26, + "to": 7.5e+26, + }, + "variableRateSlope2": { + "from": 6e+26, + "to": 7.5e+26, + }, + }, + "0xE111178A87A3BFf0c8d18DECBa5798827539Ae99": { + "address": { + "from": "0x41B66b4b6b4c9dab039d96528D1b88f7BAF8C5A4", + "to": "0xA9F3C3caE095527061e6d270DBE163693e6fda9D", + }, + "maxExcessUsageRatio": { + "from": 1e+26, + "to": 2e+26, + }, + "optimalUsageRatio": { + "from": 9e+26, + "to": 8e+26, + }, + "stableRateSlope2": { + "from": 6e+26, + "to": 7.5e+26, + }, + "variableRateSlope2": { + "from": 6e+26, + "to": 7.5e+26, + }, + }, + "0xa3Fa99A148fA48D14Ed51d610c367C61876997F1": { + "address": { + "from": "0x41B66b4b6b4c9dab039d96528D1b88f7BAF8C5A4", + "to": "0xA9F3C3caE095527061e6d270DBE163693e6fda9D", + }, + "maxExcessUsageRatio": { + "from": 1e+26, + "to": 2e+26, + }, + "optimalUsageRatio": { + "from": 9e+26, + "to": 8e+26, + }, + "stableRateSlope2": { + "from": 6e+26, + "to": 7.5e+26, + }, + "variableRateSlope2": { + "from": 6e+26, + "to": 7.5e+26, + }, + }, + "0xc2132D05D31c914a87C6611C10748AEb04B58e8F": { + "address": { + "from": "0x41B66b4b6b4c9dab039d96528D1b88f7BAF8C5A4", + "to": "0xA9F3C3caE095527061e6d270DBE163693e6fda9D", + }, + "maxExcessUsageRatio": { + "from": 1e+26, + "to": 2e+26, + }, + "optimalUsageRatio": { + "from": 9e+26, + "to": 8e+26, + }, + "stableRateSlope2": { + "from": 6e+26, + "to": 7.5e+26, + }, + "variableRateSlope2": { + "from": 6e+26, + "to": 7.5e+26, + }, + }, + }, +} +`; + +exports[`diff > should find all the changes 2`] = ` +{ + "reserves": { + "0x3C8Ca53ee5661D29d3d3C0732689a4b86947EAF0": { + "address": { + "from": null, + "to": "0xF9514C867b37D36a5affB003582b1818dA3870eb", + }, + "baseVariableBorrowRate": { + "from": null, + "to": "0", + }, + "maxVariableBorrowRate": { + "from": null, + "to": "640000000000000000000000000", + }, + "optimalUsageRatio": { + "from": null, + "to": "450000000000000000000000000", + }, + "variableRateSlope1": { + "from": null, + "to": "40000000000000000000000000", + }, + "variableRateSlope2": { + "from": null, + "to": "600000000000000000000000000", + }, + }, + "0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f": { + "address": { + "from": null, + "to": "0xF9514C867b37D36a5affB003582b1818dA3870eb", + }, + "baseVariableBorrowRate": { + "from": null, + "to": "0", + }, + "maxVariableBorrowRate": { + "from": null, + "to": "640000000000000000000000000", + }, + "optimalUsageRatio": { + "from": null, + "to": "450000000000000000000000000", + }, + "variableRateSlope1": { + "from": null, + "to": "40000000000000000000000000", + }, + "variableRateSlope2": { + "from": null, + "to": "600000000000000000000000000", + }, + }, + "0xffD4505B3452Dc22f8473616d50503bA9E1710Ac": { + "address": { + "from": null, + "to": "0xF9514C867b37D36a5affB003582b1818dA3870eb", + }, + "baseVariableBorrowRate": { + "from": null, + "to": "0", + }, + "liquidationBonus": { + "from": 10500, + "to": 11100, + }, + "liquidationThreshold": { + "from": 8600, + "to": 9000, + }, + "ltv": { + "from": 8250, + "to": 6200, + }, + "maxVariableBorrowRate": { + "from": null, + "to": "640000000000000000000000000", + }, + "optimalUsageRatio": { + "from": null, + "to": "450000000000000000000000000", + }, + "variableRateSlope1": { + "from": null, + "to": "40000000000000000000000000", + }, + "variableRateSlope2": { + "from": null, + "to": "600000000000000000000000000", + }, + }, + }, +} +`; diff --git a/src/reports/__snapshots__/report.spec.ts.snap b/src/reports/__snapshots__/report.spec.ts.snap index 335b080..f5e1811 100644 --- a/src/reports/__snapshots__/report.spec.ts.snap +++ b/src/reports/__snapshots__/report.spec.ts.snap @@ -295,3 +295,147 @@ exports[`report > should generate a well formatted report 1`] = ` } \`\`\`" `; + +exports[`report > should generate a well formatted report for 3.1 1`] = ` +"## Reserve changes + +### Reserve altered + +#### WBTC (0x3C8Ca53ee5661D29d3d3C0732689a4b86947EAF0) + +| description | value before | value after | +| --- | --- | --- | +| address | null | 0xF9514C867b37D36a5affB003582b1818dA3870eb | +| baseVariableBorrowRate | null | 0 | +| maxVariableBorrowRate | null | 640000000000000000000000000 | +| optimalUsageRatio | null | 450000000000000000000000000 | +| variableRateSlope1 | null | 40000000000000000000000000 | +| variableRateSlope2 | null | 600000000000000000000000000 | + + +#### WETH (0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f) + +| description | value before | value after | +| --- | --- | --- | +| address | null | 0xF9514C867b37D36a5affB003582b1818dA3870eb | +| baseVariableBorrowRate | null | 0 | +| maxVariableBorrowRate | null | 640000000000000000000000000 | +| optimalUsageRatio | null | 450000000000000000000000000 | +| variableRateSlope1 | null | 40000000000000000000000000 | +| variableRateSlope2 | null | 600000000000000000000000000 | + + +#### USDX (0xffD4505B3452Dc22f8473616d50503bA9E1710Ac) + +| description | value before | value after | +| --- | --- | --- | +| ltv | 82.5 % [8250] | 62 % [6200] | +| liquidationThreshold | 86 % [8600] | 90 % [9000] | +| liquidationBonus | 5 % | 11 % | +| address | null | 0xF9514C867b37D36a5affB003582b1818dA3870eb | +| baseVariableBorrowRate | null | 0 | +| maxVariableBorrowRate | null | 640000000000000000000000000 | +| optimalUsageRatio | null | 450000000000000000000000000 | +| variableRateSlope1 | null | 40000000000000000000000000 | +| variableRateSlope2 | null | 600000000000000000000000000 | + + +## Raw diff + +\`\`\`json +{ + "reserves": { + "0x3C8Ca53ee5661D29d3d3C0732689a4b86947EAF0": { + "address": { + "from": null, + "to": "0xF9514C867b37D36a5affB003582b1818dA3870eb" + }, + "baseVariableBorrowRate": { + "from": null, + "to": "0" + }, + "maxVariableBorrowRate": { + "from": null, + "to": "640000000000000000000000000" + }, + "optimalUsageRatio": { + "from": null, + "to": "450000000000000000000000000" + }, + "variableRateSlope1": { + "from": null, + "to": "40000000000000000000000000" + }, + "variableRateSlope2": { + "from": null, + "to": "600000000000000000000000000" + } + }, + "0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f": { + "address": { + "from": null, + "to": "0xF9514C867b37D36a5affB003582b1818dA3870eb" + }, + "baseVariableBorrowRate": { + "from": null, + "to": "0" + }, + "maxVariableBorrowRate": { + "from": null, + "to": "640000000000000000000000000" + }, + "optimalUsageRatio": { + "from": null, + "to": "450000000000000000000000000" + }, + "variableRateSlope1": { + "from": null, + "to": "40000000000000000000000000" + }, + "variableRateSlope2": { + "from": null, + "to": "600000000000000000000000000" + } + }, + "0xffD4505B3452Dc22f8473616d50503bA9E1710Ac": { + "liquidationBonus": { + "from": 10500, + "to": 11100 + }, + "liquidationThreshold": { + "from": 8600, + "to": 9000 + }, + "ltv": { + "from": 8250, + "to": 6200 + }, + "address": { + "from": null, + "to": "0xF9514C867b37D36a5affB003582b1818dA3870eb" + }, + "baseVariableBorrowRate": { + "from": null, + "to": "0" + }, + "maxVariableBorrowRate": { + "from": null, + "to": "640000000000000000000000000" + }, + "optimalUsageRatio": { + "from": null, + "to": "450000000000000000000000000" + }, + "variableRateSlope1": { + "from": null, + "to": "40000000000000000000000000" + }, + "variableRateSlope2": { + "from": null, + "to": "600000000000000000000000000" + } + } + } +} +\`\`\`" +`; diff --git a/src/reports/__snapshots__/reserve.spec.ts.snap b/src/reports/__snapshots__/reserve.spec.ts.snap index b7a78b9..86def61 100644 --- a/src/reports/__snapshots__/reserve.spec.ts.snap +++ b/src/reports/__snapshots__/reserve.spec.ts.snap @@ -44,6 +44,9 @@ exports[`reserve > renderReserve > should properly render new reserve 1`] = ` | stableBorrowRateEnabled | false | | isBorrowableInIsolation | false | | interestRateStrategy | [0x9b34E3e183c9b0d1a08fF57a8fb59c821616295f](https://etherscan.io/address/0x9b34E3e183c9b0d1a08fF57a8fb59c821616295f) | +| aTokenUnderlyingBalance | 0 WBTC [0] | +| virtualAccountingActive | true | +| virtualBalance | 0 WBTC [0] | " `; @@ -82,6 +85,9 @@ exports[`reserve > renderReserve > should properly render new reserve with local | stableBorrowRateEnabled | false | | isBorrowableInIsolation | false | | interestRateStrategy | 0x9b34E3e183c9b0d1a08fF57a8fb59c821616295f | +| aTokenUnderlyingBalance | 0 WBTC [0] | +| virtualAccountingActive | true | +| virtualBalance | 0 WBTC [0] | " `; diff --git a/src/reports/adi-report.spec.ts b/src/reports/adi-diff-report.spec.ts similarity index 100% rename from src/reports/adi-report.spec.ts rename to src/reports/adi-diff-report.spec.ts diff --git a/src/reports/diff.spec.ts b/src/reports/diff.spec.ts index e36c9c3..d5239fe 100644 --- a/src/reports/diff.spec.ts +++ b/src/reports/diff.spec.ts @@ -2,6 +2,8 @@ import {describe, expect, it} from 'vitest'; import {diff} from './diff'; import post from './mocks/postTestEngineArbV3.json'; import pre from './mocks/preTestEngineArbV3.json'; +import pre31 from './mocks/pre3-1.json'; +import post31 from './mocks/post3-1.json'; describe('diff', () => { it('should return same object if no changes were found', () => { @@ -25,6 +27,11 @@ describe('diff', () => { it('should find all the changes', () => { const out = diff(pre, post, true); - console.log(JSON.stringify(out, null, 2)); + expect(out).toMatchSnapshot(); + }); + + it('should find all the changes', () => { + const out = diff(pre31, post31, true); + expect(out).toMatchSnapshot(); }); }); diff --git a/src/reports/mocks/post3-1.json b/src/reports/mocks/post3-1.json new file mode 100644 index 0000000..feadf67 --- /dev/null +++ b/src/reports/mocks/post3-1.json @@ -0,0 +1,186 @@ +{ + "chainId": 31337, + "eModes": {}, + "poolConfig": { + "oracle": "0xA3102C4b8D385a0A4760dF3fAc4Ab5CB1d94Ce74", + "pool": "0xb21Bdf7973F6302236dACC401D45f919FcB53F13", + "poolAddressesProvider": "0xDF9ABb650b00831c5d826e95908dEa15cb8b7489", + "poolConfigurator": "0x8160B362Bd5664E5E8C69bFB7Ab229ebD8de6843", + "poolConfiguratorImpl": "0x0bB60150F9f38a3751e6B623A120E0B23319Be3c", + "poolImpl": "0xa2188f575649510E7130dde290f7B112B4e054E9", + "priceOracleSentinel": "0x0000000000000000000000000000000000000000", + "protocolDataProvider": "0xf7Fb61FDFEA9a31D44aC3a25b569E0Ab7f4D62Bc" + }, + "reserves": { + "0x3C8Ca53ee5661D29d3d3C0732689a4b86947EAF0": { + "aToken": "0xE8AF9f5a9dbe9D0D05C4AF8E0990F656Ff25734D", + "aTokenImpl": "0x810B46eD6f4252B2b736ec1968E3a9100B09356D", + "aTokenName": "Aave Local WBTC", + "aTokenSymbol": "aLocWBTC", + "aTokenUnderlyingBalance": 0, + "address": "0xF9514C867b37D36a5affB003582b1818dA3870eb", + "baseVariableBorrowRate": "0", + "borrowCap": 0, + "borrowingEnabled": true, + "debtCeiling": 0, + "decimals": 8, + "eModeCategory": 0, + "interestRateStrategy": "0xF9514C867b37D36a5affB003582b1818dA3870eb", + "isActive": true, + "isBorrowableInIsolation": false, + "isFlashloanable": true, + "isFrozen": false, + "isPaused": false, + "isSiloed": false, + "liquidationBonus": 10500, + "liquidationProtocolFee": 1000, + "liquidationThreshold": 8600, + "ltv": 8250, + "maxVariableBorrowRate": "640000000000000000000000000", + "optimalUsageRatio": "450000000000000000000000000", + "oracle": "0x76006C4471fb6aDd17728e9c9c8B67d5AF06cDA0", + "oracleDecimals": 8, + "oracleLatestAnswer": 2700000000000, + "reserveFactor": 1000, + "stableBorrowRateEnabled": false, + "stableDebtToken": "0x16d5b202Ca1D554E7545eA51875fa0DCFff4b464", + "stableDebtTokenImpl": "0x120d8c3E70A8B0a50eFA5Ff2B2B6eBb122BF2061", + "stableDebtTokenName": "Aave Local Stable Debt WBTC", + "stableDebtTokenSymbol": "stableDebtLocWBTC", + "supplyCap": 0, + "symbol": "WBTC", + "underlying": "0x3C8Ca53ee5661D29d3d3C0732689a4b86947EAF0", + "usageAsCollateralEnabled": true, + "variableDebtToken": "0x879868dCb2a699Bc253E0281Ed08401cEc586072", + "variableDebtTokenImpl": "0x663b056e5373b6e62BA18F883783022923967Fa7", + "variableDebtTokenName": "Aave Local Variable Debt WBTC", + "variableDebtTokenSymbol": "variableDebtLocWBTC", + "variableRateSlope1": "40000000000000000000000000", + "variableRateSlope2": "600000000000000000000000000", + "virtualAccountingActive": true, + "virtualBalance": 0 + }, + "0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f": { + "aToken": "0xA98bB1Fe0F9d55e7118F4Dbb9Fc3fBF1F01B5482", + "aTokenImpl": "0x810B46eD6f4252B2b736ec1968E3a9100B09356D", + "aTokenName": "Aave Local WETH", + "aTokenSymbol": "aLocWETH", + "aTokenUnderlyingBalance": 0, + "address": "0xF9514C867b37D36a5affB003582b1818dA3870eb", + "baseVariableBorrowRate": "0", + "borrowCap": 0, + "borrowingEnabled": true, + "debtCeiling": 0, + "decimals": 18, + "eModeCategory": 0, + "interestRateStrategy": "0xF9514C867b37D36a5affB003582b1818dA3870eb", + "isActive": true, + "isBorrowableInIsolation": false, + "isFlashloanable": true, + "isFrozen": false, + "isPaused": false, + "isSiloed": false, + "liquidationBonus": 10500, + "liquidationProtocolFee": 1000, + "liquidationThreshold": 8600, + "ltv": 8250, + "maxVariableBorrowRate": "640000000000000000000000000", + "optimalUsageRatio": "450000000000000000000000000", + "oracle": "0x6891e60906DEBeA401F670D74d01D117a3bEAD39", + "oracleDecimals": 8, + "oracleLatestAnswer": 180000000000, + "reserveFactor": 1000, + "stableBorrowRateEnabled": false, + "stableDebtToken": "0x6697E3eBE991C0be177A71FC40D5B2B0944e2bc9", + "stableDebtTokenImpl": "0x120d8c3E70A8B0a50eFA5Ff2B2B6eBb122BF2061", + "stableDebtTokenName": "Aave Local Stable Debt WETH", + "stableDebtTokenSymbol": "stableDebtLocWETH", + "supplyCap": 0, + "symbol": "WETH", + "underlying": "0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f", + "usageAsCollateralEnabled": true, + "variableDebtToken": "0x1208b8D04046Bcfa16d0896e29219157794af99F", + "variableDebtTokenImpl": "0x663b056e5373b6e62BA18F883783022923967Fa7", + "variableDebtTokenName": "Aave Local Variable Debt WETH", + "variableDebtTokenSymbol": "variableDebtLocWETH", + "variableRateSlope1": "40000000000000000000000000", + "variableRateSlope2": "600000000000000000000000000", + "virtualAccountingActive": true, + "virtualBalance": 0 + }, + "0xffD4505B3452Dc22f8473616d50503bA9E1710Ac": { + "aToken": "0xcF63D4456FCF098EF4012F6dbd2FA3a30f122D43", + "aTokenImpl": "0x810B46eD6f4252B2b736ec1968E3a9100B09356D", + "aTokenName": "Aave Local USDX", + "aTokenSymbol": "aLocUSDX", + "aTokenUnderlyingBalance": 0, + "address": "0xF9514C867b37D36a5affB003582b1818dA3870eb", + "baseVariableBorrowRate": "0", + "borrowCap": 0, + "borrowingEnabled": true, + "debtCeiling": 0, + "decimals": 6, + "eModeCategory": 0, + "interestRateStrategy": "0xF9514C867b37D36a5affB003582b1818dA3870eb", + "isActive": true, + "isBorrowableInIsolation": false, + "isFlashloanable": true, + "isFrozen": false, + "isPaused": false, + "isSiloed": false, + "liquidationBonus": 11100, + "liquidationProtocolFee": 1000, + "liquidationThreshold": 9000, + "ltv": 6200, + "maxVariableBorrowRate": "640000000000000000000000000", + "optimalUsageRatio": "450000000000000000000000000", + "oracle": "0x8d2C17FAd02B7bb64139109c6533b7C2b9CADb81", + "oracleDecimals": 8, + "oracleLatestAnswer": 100000000, + "reserveFactor": 1000, + "stableBorrowRateEnabled": false, + "stableDebtToken": "0x1b67680FdA181CcF8c813e0CabF1DEB8bdAE3a66", + "stableDebtTokenImpl": "0x120d8c3E70A8B0a50eFA5Ff2B2B6eBb122BF2061", + "stableDebtTokenName": "Aave Local Stable Debt USDX", + "stableDebtTokenSymbol": "stableDebtLocUSDX", + "supplyCap": 0, + "symbol": "USDX", + "underlying": "0xffD4505B3452Dc22f8473616d50503bA9E1710Ac", + "usageAsCollateralEnabled": true, + "variableDebtToken": "0x9e1971387CA78910Ed778e240833388b16B214F0", + "variableDebtTokenImpl": "0x663b056e5373b6e62BA18F883783022923967Fa7", + "variableDebtTokenName": "Aave Local Variable Debt USDX", + "variableDebtTokenSymbol": "variableDebtLocUSDX", + "variableRateSlope1": "40000000000000000000000000", + "variableRateSlope2": "600000000000000000000000000", + "virtualAccountingActive": true, + "virtualBalance": 0 + } + }, + "strategies": { + "0x3C8Ca53ee5661D29d3d3C0732689a4b86947EAF0": { + "address": "0xF9514C867b37D36a5affB003582b1818dA3870eb", + "baseVariableBorrowRate": "0", + "maxVariableBorrowRate": "640000000000000000000000000", + "optimalUsageRatio": "450000000000000000000000000", + "variableRateSlope1": "40000000000000000000000000", + "variableRateSlope2": "600000000000000000000000000" + }, + "0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f": { + "address": "0xF9514C867b37D36a5affB003582b1818dA3870eb", + "baseVariableBorrowRate": "0", + "maxVariableBorrowRate": "640000000000000000000000000", + "optimalUsageRatio": "450000000000000000000000000", + "variableRateSlope1": "40000000000000000000000000", + "variableRateSlope2": "600000000000000000000000000" + }, + "0xffD4505B3452Dc22f8473616d50503bA9E1710Ac": { + "address": "0xF9514C867b37D36a5affB003582b1818dA3870eb", + "baseVariableBorrowRate": "0", + "maxVariableBorrowRate": "640000000000000000000000000", + "optimalUsageRatio": "450000000000000000000000000", + "variableRateSlope1": "40000000000000000000000000", + "variableRateSlope2": "600000000000000000000000000" + } + } +} diff --git a/src/reports/mocks/pre3-1.json b/src/reports/mocks/pre3-1.json new file mode 100644 index 0000000..1991940 --- /dev/null +++ b/src/reports/mocks/pre3-1.json @@ -0,0 +1,168 @@ +{ + "chainId": 31337, + "eModes": {}, + "poolConfig": { + "oracle": "0xA3102C4b8D385a0A4760dF3fAc4Ab5CB1d94Ce74", + "pool": "0xb21Bdf7973F6302236dACC401D45f919FcB53F13", + "poolAddressesProvider": "0xDF9ABb650b00831c5d826e95908dEa15cb8b7489", + "poolConfigurator": "0x8160B362Bd5664E5E8C69bFB7Ab229ebD8de6843", + "poolConfiguratorImpl": "0x0bB60150F9f38a3751e6B623A120E0B23319Be3c", + "poolImpl": "0xa2188f575649510E7130dde290f7B112B4e054E9", + "priceOracleSentinel": "0x0000000000000000000000000000000000000000", + "protocolDataProvider": "0xf7Fb61FDFEA9a31D44aC3a25b569E0Ab7f4D62Bc" + }, + "reserves": { + "0x3C8Ca53ee5661D29d3d3C0732689a4b86947EAF0": { + "aToken": "0xE8AF9f5a9dbe9D0D05C4AF8E0990F656Ff25734D", + "aTokenImpl": "0x810B46eD6f4252B2b736ec1968E3a9100B09356D", + "aTokenName": "Aave Local WBTC", + "aTokenSymbol": "aLocWBTC", + "aTokenUnderlyingBalance": 0, + "borrowCap": 0, + "borrowingEnabled": true, + "debtCeiling": 0, + "decimals": 8, + "eModeCategory": 0, + "interestRateStrategy": "0xF9514C867b37D36a5affB003582b1818dA3870eb", + "isActive": true, + "isBorrowableInIsolation": false, + "isFlashloanable": true, + "isFrozen": false, + "isPaused": false, + "isSiloed": false, + "liquidationBonus": 10500, + "liquidationProtocolFee": 1000, + "liquidationThreshold": 8600, + "ltv": 8250, + "oracle": "0x76006C4471fb6aDd17728e9c9c8B67d5AF06cDA0", + "oracleDecimals": 8, + "oracleLatestAnswer": 2700000000000, + "reserveFactor": 1000, + "stableBorrowRateEnabled": false, + "stableDebtToken": "0x16d5b202Ca1D554E7545eA51875fa0DCFff4b464", + "stableDebtTokenImpl": "0x120d8c3E70A8B0a50eFA5Ff2B2B6eBb122BF2061", + "stableDebtTokenName": "Aave Local Stable Debt WBTC", + "stableDebtTokenSymbol": "stableDebtLocWBTC", + "supplyCap": 0, + "symbol": "WBTC", + "underlying": "0x3C8Ca53ee5661D29d3d3C0732689a4b86947EAF0", + "usageAsCollateralEnabled": true, + "variableDebtToken": "0x879868dCb2a699Bc253E0281Ed08401cEc586072", + "variableDebtTokenImpl": "0x663b056e5373b6e62BA18F883783022923967Fa7", + "variableDebtTokenName": "Aave Local Variable Debt WBTC", + "variableDebtTokenSymbol": "variableDebtLocWBTC", + "virtualAccountingActive": true, + "virtualBalance": 0 + }, + "0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f": { + "aToken": "0xA98bB1Fe0F9d55e7118F4Dbb9Fc3fBF1F01B5482", + "aTokenImpl": "0x810B46eD6f4252B2b736ec1968E3a9100B09356D", + "aTokenName": "Aave Local WETH", + "aTokenSymbol": "aLocWETH", + "aTokenUnderlyingBalance": 0, + "borrowCap": 0, + "borrowingEnabled": true, + "debtCeiling": 0, + "decimals": 18, + "eModeCategory": 0, + "interestRateStrategy": "0xF9514C867b37D36a5affB003582b1818dA3870eb", + "isActive": true, + "isBorrowableInIsolation": false, + "isFlashloanable": true, + "isFrozen": false, + "isPaused": false, + "isSiloed": false, + "liquidationBonus": 10500, + "liquidationProtocolFee": 1000, + "liquidationThreshold": 8600, + "ltv": 8250, + "oracle": "0x6891e60906DEBeA401F670D74d01D117a3bEAD39", + "oracleDecimals": 8, + "oracleLatestAnswer": 180000000000, + "reserveFactor": 1000, + "stableBorrowRateEnabled": false, + "stableDebtToken": "0x6697E3eBE991C0be177A71FC40D5B2B0944e2bc9", + "stableDebtTokenImpl": "0x120d8c3E70A8B0a50eFA5Ff2B2B6eBb122BF2061", + "stableDebtTokenName": "Aave Local Stable Debt WETH", + "stableDebtTokenSymbol": "stableDebtLocWETH", + "supplyCap": 0, + "symbol": "WETH", + "underlying": "0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f", + "usageAsCollateralEnabled": true, + "variableDebtToken": "0x1208b8D04046Bcfa16d0896e29219157794af99F", + "variableDebtTokenImpl": "0x663b056e5373b6e62BA18F883783022923967Fa7", + "variableDebtTokenName": "Aave Local Variable Debt WETH", + "variableDebtTokenSymbol": "variableDebtLocWETH", + "virtualAccountingActive": true, + "virtualBalance": 0 + }, + "0xffD4505B3452Dc22f8473616d50503bA9E1710Ac": { + "aToken": "0xcF63D4456FCF098EF4012F6dbd2FA3a30f122D43", + "aTokenImpl": "0x810B46eD6f4252B2b736ec1968E3a9100B09356D", + "aTokenName": "Aave Local USDX", + "aTokenSymbol": "aLocUSDX", + "aTokenUnderlyingBalance": 0, + "borrowCap": 0, + "borrowingEnabled": true, + "debtCeiling": 0, + "decimals": 6, + "eModeCategory": 0, + "interestRateStrategy": "0xF9514C867b37D36a5affB003582b1818dA3870eb", + "isActive": true, + "isBorrowableInIsolation": false, + "isFlashloanable": true, + "isFrozen": false, + "isPaused": false, + "isSiloed": false, + "liquidationBonus": 10500, + "liquidationProtocolFee": 1000, + "liquidationThreshold": 8600, + "ltv": 8250, + "oracle": "0x8d2C17FAd02B7bb64139109c6533b7C2b9CADb81", + "oracleDecimals": 8, + "oracleLatestAnswer": 100000000, + "reserveFactor": 1000, + "stableBorrowRateEnabled": false, + "stableDebtToken": "0x1b67680FdA181CcF8c813e0CabF1DEB8bdAE3a66", + "stableDebtTokenImpl": "0x120d8c3E70A8B0a50eFA5Ff2B2B6eBb122BF2061", + "stableDebtTokenName": "Aave Local Stable Debt USDX", + "stableDebtTokenSymbol": "stableDebtLocUSDX", + "supplyCap": 0, + "symbol": "USDX", + "underlying": "0xffD4505B3452Dc22f8473616d50503bA9E1710Ac", + "usageAsCollateralEnabled": true, + "variableDebtToken": "0x9e1971387CA78910Ed778e240833388b16B214F0", + "variableDebtTokenImpl": "0x663b056e5373b6e62BA18F883783022923967Fa7", + "variableDebtTokenName": "Aave Local Variable Debt USDX", + "variableDebtTokenSymbol": "variableDebtLocUSDX", + "virtualAccountingActive": true, + "virtualBalance": 0 + } + }, + "strategies": { + "0x3C8Ca53ee5661D29d3d3C0732689a4b86947EAF0": { + "address": "0xF9514C867b37D36a5affB003582b1818dA3870eb", + "baseVariableBorrowRate": "0", + "maxVariableBorrowRate": "640000000000000000000000000", + "optimalUsageRatio": "450000000000000000000000000", + "variableRateSlope1": "40000000000000000000000000", + "variableRateSlope2": "600000000000000000000000000" + }, + "0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f": { + "address": "0xF9514C867b37D36a5affB003582b1818dA3870eb", + "baseVariableBorrowRate": "0", + "maxVariableBorrowRate": "640000000000000000000000000", + "optimalUsageRatio": "450000000000000000000000000", + "variableRateSlope1": "40000000000000000000000000", + "variableRateSlope2": "600000000000000000000000000" + }, + "0xffD4505B3452Dc22f8473616d50503bA9E1710Ac": { + "address": "0xF9514C867b37D36a5affB003582b1818dA3870eb", + "baseVariableBorrowRate": "0", + "maxVariableBorrowRate": "640000000000000000000000000", + "optimalUsageRatio": "450000000000000000000000000", + "variableRateSlope1": "40000000000000000000000000", + "variableRateSlope2": "600000000000000000000000000" + } + } +} diff --git a/src/reports/report.spec.ts b/src/reports/report.spec.ts index 6605e9e..bec3ecf 100644 --- a/src/reports/report.spec.ts +++ b/src/reports/report.spec.ts @@ -14,4 +14,15 @@ describe('report', () => { }, {timeout: 30000}, ); + it( + 'should generate a well formatted report for 3.1', + async () => { + const from = readJsonFile('/src/reports/mocks/pre3-1.json'); + const to = readJsonFile('/src/reports/mocks/post3-1.json'); + const content = await diffReports(from, to); + console.log(content); + expect(content).toMatchSnapshot(); + }, + {timeout: 30000}, + ); }); diff --git a/src/reports/reserve.spec.ts b/src/reports/reserve.spec.ts index 240d22b..5e5405f 100644 --- a/src/reports/reserve.spec.ts +++ b/src/reports/reserve.spec.ts @@ -6,6 +6,7 @@ import type {AaveV3Reserve, CHAIN_ID} from './snapshot-types'; const WBTC_MOCK = { aToken: '0x078f358208685046a11C85e8ad32895DED33A249', aTokenImpl: '0xa5ba6E5EC19a1Bf23C857991c857dB62b2Aa187B', + aTokenUnderlyingBalance: 0, borrowCap: 1115, borrowingEnabled: true, debtCeiling: 100000, @@ -36,6 +37,8 @@ const WBTC_MOCK = { usageAsCollateralEnabled: true, variableDebtToken: '0x92b42c66840C7AD907b4BF74879FF3eF7c529473', variableDebtTokenImpl: '0x81387c40EB75acB02757C1Ae55D5936E78c9dEd3', + virtualAccountingActive: true, + virtualBalance: 0, }; describe('reserve', () => { diff --git a/src/reports/reserve.ts b/src/reports/reserve.ts index e8303c9..1de4d47 100644 --- a/src/reports/reserve.ts +++ b/src/reports/reserve.ts @@ -12,6 +12,12 @@ export function renderReserveValue( return prettifyNumber({value: reserve[key] as string, decimals: 2, suffix: '%'}); if (['supplyCap', 'borrowCap'].includes(key)) return `${reserve[key].toLocaleString('en-US')} ${reserve.symbol}`; + if (['aTokenUnderlyingBalance', 'virtualBalance'].includes(key)) + return prettifyNumber({ + value: reserve[key] as string, + decimals: reserve.decimals, + suffix: reserve.symbol, + }); if (key === 'debtCeiling') return prettifyNumber({value: reserve[key] as string, decimals: 2, suffix: '$'}); if (['liquidityIndex', 'variableBorrowIndex'].includes(key))