@aave-dao/aave-helpers-js 1.2.1 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.cjs +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +17 -0
- package/dist/index.d.mts +17 -0
- package/dist/index.mjs +1 -1
- package/dist/{protocol-diff-v4-DJXB5OyC.mjs → protocol-diff-v4-7huxoHpS.mjs} +162 -4
- package/dist/{protocol-diff-v4-D8is4kDx.cjs → protocol-diff-v4-BVmy9cTR.cjs} +162 -4
- package/package.json +2 -2
package/dist/cli.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
const require_protocol_diff_v4 = require('./protocol-diff-v4-
|
|
2
|
+
const require_protocol_diff_v4 = require('./protocol-diff-v4-BVmy9cTR.cjs');
|
|
3
3
|
let _bgd_labs_toolbox = require("@bgd-labs/toolbox");
|
|
4
4
|
let viem = require("viem");
|
|
5
5
|
let fs = require("fs");
|
package/dist/cli.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { n as diffSnapshots, t as diffV4Snapshots } from "./protocol-diff-v4-
|
|
2
|
+
import { n as diffSnapshots, t as diffV4Snapshots } from "./protocol-diff-v4-7huxoHpS.mjs";
|
|
3
3
|
import { Aip, IPayloadsController_ABI, cidV0ToBs58, getMdContractName, getPayloadsController, hash, makePayloadExecutableOnTestClient, parseFrontmatterMd, renderTenderlyReport, tenderly_createVnet } from "@bgd-labs/toolbox";
|
|
4
4
|
import { encodeFunctionData, parseAbi, zeroAddress } from "viem";
|
|
5
5
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
|
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_protocol_diff_v4 = require('./protocol-diff-v4-
|
|
2
|
+
const require_protocol_diff_v4 = require('./protocol-diff-v4-BVmy9cTR.cjs');
|
|
3
3
|
|
|
4
4
|
exports.diff = require_protocol_diff_v4.diff;
|
|
5
5
|
exports.diffSnapshots = require_protocol_diff_v4.diffSnapshots;
|
package/dist/index.d.cts
CHANGED
|
@@ -287,6 +287,11 @@ declare const v4SpokeReserveSchema: z.ZodObject<{
|
|
|
287
287
|
collateralFactor: z.ZodNumber;
|
|
288
288
|
maxLiquidationBonus: z.ZodNumber;
|
|
289
289
|
liquidationFee: z.ZodNumber;
|
|
290
|
+
dynamicConfigs: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
291
|
+
collateralFactor: z.ZodNumber;
|
|
292
|
+
maxLiquidationBonus: z.ZodNumber;
|
|
293
|
+
liquidationFee: z.ZodNumber;
|
|
294
|
+
}, z.core.$strip>>;
|
|
290
295
|
oracleAddress: z.ZodString;
|
|
291
296
|
priceSource: z.ZodString;
|
|
292
297
|
oraclePrice: z.ZodString;
|
|
@@ -344,6 +349,11 @@ declare const aaveV4SnapshotSchema: z.ZodObject<{
|
|
|
344
349
|
collateralFactor: z.ZodNumber;
|
|
345
350
|
maxLiquidationBonus: z.ZodNumber;
|
|
346
351
|
liquidationFee: z.ZodNumber;
|
|
352
|
+
dynamicConfigs: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
353
|
+
collateralFactor: z.ZodNumber;
|
|
354
|
+
maxLiquidationBonus: z.ZodNumber;
|
|
355
|
+
liquidationFee: z.ZodNumber;
|
|
356
|
+
}, z.core.$strip>>;
|
|
347
357
|
oracleAddress: z.ZodString;
|
|
348
358
|
priceSource: z.ZodString;
|
|
349
359
|
oraclePrice: z.ZodString;
|
|
@@ -380,6 +390,13 @@ declare const aaveV4SnapshotSchema: z.ZodObject<{
|
|
|
380
390
|
active: z.ZodBoolean;
|
|
381
391
|
halted: z.ZodBoolean;
|
|
382
392
|
}, z.core.$strip>>;
|
|
393
|
+
positionManagers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodBoolean>>>;
|
|
394
|
+
accessManagerRoles: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
395
|
+
label: z.ZodString;
|
|
396
|
+
members: z.ZodArray<z.ZodString>;
|
|
397
|
+
targets: z.ZodArray<z.ZodString>;
|
|
398
|
+
selectors: z.ZodArray<z.ZodString>;
|
|
399
|
+
}, z.core.$strip>>>>;
|
|
383
400
|
raw: z.ZodOptional<z.ZodRecord<z.ZodType<`0x${string}`, unknown, z.core.$ZodTypeInternals<`0x${string}`, unknown>>, z.ZodObject<{
|
|
384
401
|
label: z.ZodNullable<z.ZodString>;
|
|
385
402
|
contract: z.ZodNullable<z.ZodString>;
|
package/dist/index.d.mts
CHANGED
|
@@ -287,6 +287,11 @@ declare const v4SpokeReserveSchema: z.ZodObject<{
|
|
|
287
287
|
collateralFactor: z.ZodNumber;
|
|
288
288
|
maxLiquidationBonus: z.ZodNumber;
|
|
289
289
|
liquidationFee: z.ZodNumber;
|
|
290
|
+
dynamicConfigs: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
291
|
+
collateralFactor: z.ZodNumber;
|
|
292
|
+
maxLiquidationBonus: z.ZodNumber;
|
|
293
|
+
liquidationFee: z.ZodNumber;
|
|
294
|
+
}, z.core.$strip>>;
|
|
290
295
|
oracleAddress: z.ZodString;
|
|
291
296
|
priceSource: z.ZodString;
|
|
292
297
|
oraclePrice: z.ZodString;
|
|
@@ -344,6 +349,11 @@ declare const aaveV4SnapshotSchema: z.ZodObject<{
|
|
|
344
349
|
collateralFactor: z.ZodNumber;
|
|
345
350
|
maxLiquidationBonus: z.ZodNumber;
|
|
346
351
|
liquidationFee: z.ZodNumber;
|
|
352
|
+
dynamicConfigs: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
353
|
+
collateralFactor: z.ZodNumber;
|
|
354
|
+
maxLiquidationBonus: z.ZodNumber;
|
|
355
|
+
liquidationFee: z.ZodNumber;
|
|
356
|
+
}, z.core.$strip>>;
|
|
347
357
|
oracleAddress: z.ZodString;
|
|
348
358
|
priceSource: z.ZodString;
|
|
349
359
|
oraclePrice: z.ZodString;
|
|
@@ -380,6 +390,13 @@ declare const aaveV4SnapshotSchema: z.ZodObject<{
|
|
|
380
390
|
active: z.ZodBoolean;
|
|
381
391
|
halted: z.ZodBoolean;
|
|
382
392
|
}, z.core.$strip>>;
|
|
393
|
+
positionManagers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodBoolean>>>;
|
|
394
|
+
accessManagerRoles: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
395
|
+
label: z.ZodString;
|
|
396
|
+
members: z.ZodArray<z.ZodString>;
|
|
397
|
+
targets: z.ZodArray<z.ZodString>;
|
|
398
|
+
selectors: z.ZodArray<z.ZodString>;
|
|
399
|
+
}, z.core.$strip>>>>;
|
|
383
400
|
raw: z.ZodOptional<z.ZodRecord<z.ZodType<`0x${string}`, unknown, z.core.$ZodTypeInternals<`0x${string}`, unknown>>, z.ZodObject<{
|
|
384
401
|
label: z.ZodNullable<z.ZodString>;
|
|
385
402
|
contract: z.ZodNullable<z.ZodString>;
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { a as hasChanges, i as diff, n as diffSnapshots, o as isChange, r as eventDb, t as diffV4Snapshots } from "./protocol-diff-v4-
|
|
1
|
+
import { a as hasChanges, i as diff, n as diffSnapshots, o as isChange, r as eventDb, t as diffV4Snapshots } from "./protocol-diff-v4-7huxoHpS.mjs";
|
|
2
2
|
|
|
3
3
|
export { diff, diffSnapshots, diffV4Snapshots, eventDb, hasChanges, isChange };
|
|
@@ -6967,7 +6967,9 @@ function formatV4Value(section, key, value, ctx) {
|
|
|
6967
6967
|
//#endregion
|
|
6968
6968
|
//#region sections/spoke-reserves.ts
|
|
6969
6969
|
/** All fields in display order. Every field is compared — even identity fields
|
|
6970
|
-
* that "shouldn't" change — so unexpected mutations are never silently missed.
|
|
6970
|
+
* that "shouldn't" change — so unexpected mutations are never silently missed.
|
|
6971
|
+
* `dynamicConfigs` is excluded from this list and rendered separately because
|
|
6972
|
+
* it is a nested record per key, not a single value. */
|
|
6971
6973
|
const FIELD_ORDER$3 = [
|
|
6972
6974
|
"symbol",
|
|
6973
6975
|
"underlying",
|
|
@@ -6987,6 +6989,41 @@ const FIELD_ORDER$3 = [
|
|
|
6987
6989
|
"priceSource",
|
|
6988
6990
|
"oraclePrice"
|
|
6989
6991
|
];
|
|
6992
|
+
const DYNAMIC_CONFIG_FIELDS = [
|
|
6993
|
+
"collateralFactor",
|
|
6994
|
+
"maxLiquidationBonus",
|
|
6995
|
+
"liquidationFee"
|
|
6996
|
+
];
|
|
6997
|
+
function fmtDynamicConfigField(field, value) {
|
|
6998
|
+
if (field === "maxLiquidationBonus") {
|
|
6999
|
+
if (value === 0) return "0.00 % [0]";
|
|
7000
|
+
return `${((value - 1e4) / 100).toFixed(2)} % [${value}]`;
|
|
7001
|
+
}
|
|
7002
|
+
const w = Math.floor(value / 100);
|
|
7003
|
+
const f = value % 100;
|
|
7004
|
+
return `${w}.${f < 10 ? `0${f}` : `${f}`} % [${value}]`;
|
|
7005
|
+
}
|
|
7006
|
+
function renderDynamicConfigsBlock(before, after) {
|
|
7007
|
+
const allKeys = new Set([...Object.keys(before ?? {}), ...Object.keys(after ?? {})]);
|
|
7008
|
+
const rows = [];
|
|
7009
|
+
for (const key of [...allKeys].sort((a, b) => Number(a) - Number(b))) {
|
|
7010
|
+
const b = before?.[key];
|
|
7011
|
+
const a = after?.[key];
|
|
7012
|
+
for (const field of DYNAMIC_CONFIG_FIELDS) {
|
|
7013
|
+
const bv = b?.[field];
|
|
7014
|
+
const av = a?.[field];
|
|
7015
|
+
if (String(bv) === String(av)) continue;
|
|
7016
|
+
const fromFmt = bv === void 0 ? "*missing*" : fmtDynamicConfigField(field, bv);
|
|
7017
|
+
const toFmt = av === void 0 ? "*missing*" : fmtDynamicConfigField(field, av);
|
|
7018
|
+
rows.push(`| key ${key} | ${field} | ${fromFmt} | ${toFmt} |`);
|
|
7019
|
+
}
|
|
7020
|
+
}
|
|
7021
|
+
if (rows.length === 0) return "";
|
|
7022
|
+
let md = "**dynamicConfigs**\n\n";
|
|
7023
|
+
md += "| key | field | before | after |\n| --- | --- | --- | --- |\n";
|
|
7024
|
+
md += rows.join("\n") + "\n\n";
|
|
7025
|
+
return md;
|
|
7026
|
+
}
|
|
6990
7027
|
function reserveHeader(reserve, spokeAddr, reserveId, chainId) {
|
|
6991
7028
|
const client = getClient(chainId, {});
|
|
6992
7029
|
const underlyingLink = toAddressLink(reserve.underlying, true, client);
|
|
@@ -6998,6 +7035,8 @@ function renderNewReserve(reserve, spokeAddr, reserveId, ctx) {
|
|
|
6998
7035
|
md += "**NEW RESERVE**\n\n";
|
|
6999
7036
|
md += "| description | value |\n| --- | --- |\n";
|
|
7000
7037
|
for (const key of FIELD_ORDER$3) md += `| ${key} | ${formatV4Value("spokeReserve", key, reserve[key], ctx)} |\n`;
|
|
7038
|
+
md += "\n";
|
|
7039
|
+
md += renderDynamicConfigsBlock(void 0, reserve.dynamicConfigs);
|
|
7001
7040
|
return md + "\n";
|
|
7002
7041
|
}
|
|
7003
7042
|
function renderReserveDiff(before, after, spokeAddr, reserveId, ctx) {
|
|
@@ -7010,10 +7049,14 @@ function renderReserveDiff(before, after, spokeAddr, reserveId, ctx) {
|
|
|
7010
7049
|
const toFmt = formatV4Value("spokeReserve", key, aVal, ctx);
|
|
7011
7050
|
rows.push(`| ${key} | ${fromFmt} | ${toFmt} |`);
|
|
7012
7051
|
}
|
|
7013
|
-
|
|
7052
|
+
const dynamicConfigsBlock = renderDynamicConfigsBlock(before.dynamicConfigs, after.dynamicConfigs);
|
|
7053
|
+
if (rows.length === 0 && !dynamicConfigsBlock) return "";
|
|
7014
7054
|
let md = reserveHeader(after, spokeAddr, reserveId, ctx.chainId);
|
|
7015
|
-
|
|
7016
|
-
|
|
7055
|
+
if (rows.length > 0) {
|
|
7056
|
+
md += "| description | value before | value after |\n| --- | --- | --- |\n";
|
|
7057
|
+
md += rows.join("\n") + "\n\n";
|
|
7058
|
+
}
|
|
7059
|
+
md += dynamicConfigsBlock;
|
|
7017
7060
|
return md + "\n";
|
|
7018
7061
|
}
|
|
7019
7062
|
function renderSpokeReservesSection(before, after) {
|
|
@@ -7232,6 +7275,119 @@ function renderSpokeLiquidationSection(before, after) {
|
|
|
7232
7275
|
return `## Spoke Liquidation Config Changes\n\n${body}`;
|
|
7233
7276
|
}
|
|
7234
7277
|
|
|
7278
|
+
//#endregion
|
|
7279
|
+
//#region sections/position-managers.ts
|
|
7280
|
+
/**
|
|
7281
|
+
* Renders the per-spoke position-manager registration diff. Each row is a
|
|
7282
|
+
* (spoke, positionManager) pair whose `active` flag changed.
|
|
7283
|
+
*/
|
|
7284
|
+
function renderPositionManagersSection(before, after) {
|
|
7285
|
+
const beforePm = before.positionManagers ?? {};
|
|
7286
|
+
const afterPm = after.positionManagers ?? {};
|
|
7287
|
+
const allSpokes = new Set([...Object.keys(beforePm), ...Object.keys(afterPm)]);
|
|
7288
|
+
const client = getClient(after.chainId, {});
|
|
7289
|
+
const rows = [];
|
|
7290
|
+
for (const spokeAddr of allSpokes) {
|
|
7291
|
+
const beforeSpoke = beforePm[spokeAddr] ?? {};
|
|
7292
|
+
const afterSpoke = afterPm[spokeAddr] ?? {};
|
|
7293
|
+
const allManagers = new Set([...Object.keys(beforeSpoke), ...Object.keys(afterSpoke)]);
|
|
7294
|
+
for (const manager of allManagers) {
|
|
7295
|
+
const bv = beforeSpoke[manager];
|
|
7296
|
+
const av = afterSpoke[manager];
|
|
7297
|
+
if (bv === av) continue;
|
|
7298
|
+
const spokeLink = toAddressLink(spokeAddr, true, client);
|
|
7299
|
+
const managerLink = toAddressLink(manager, true, client);
|
|
7300
|
+
const fromFmt = bv === void 0 ? "*missing*" : boolToMarkdown(bv);
|
|
7301
|
+
const toFmt = av === void 0 ? "*missing*" : boolToMarkdown(av);
|
|
7302
|
+
rows.push(`| ${spokeLink} | ${managerLink} | ${fromFmt} | ${toFmt} |`);
|
|
7303
|
+
}
|
|
7304
|
+
}
|
|
7305
|
+
if (rows.length === 0) return "";
|
|
7306
|
+
let md = "## Position Manager Changes\n\n";
|
|
7307
|
+
md += "| spoke | position manager | active before | active after |\n";
|
|
7308
|
+
md += "| --- | --- | --- | --- |\n";
|
|
7309
|
+
md += rows.join("\n") + "\n\n";
|
|
7310
|
+
return md;
|
|
7311
|
+
}
|
|
7312
|
+
|
|
7313
|
+
//#endregion
|
|
7314
|
+
//#region sections/access-manager-roles.ts
|
|
7315
|
+
function setOf(arr) {
|
|
7316
|
+
return new Set((arr ?? []).map((v) => v.toLowerCase()));
|
|
7317
|
+
}
|
|
7318
|
+
function diffSets(b, a) {
|
|
7319
|
+
const added = [];
|
|
7320
|
+
const removed = [];
|
|
7321
|
+
for (const v of a) if (!b.has(v)) added.push(v);
|
|
7322
|
+
for (const v of b) if (!a.has(v)) removed.push(v);
|
|
7323
|
+
return {
|
|
7324
|
+
added,
|
|
7325
|
+
removed
|
|
7326
|
+
};
|
|
7327
|
+
}
|
|
7328
|
+
function renderAddrList(values, chainId) {
|
|
7329
|
+
if (values.length === 0) return "*(none)*";
|
|
7330
|
+
const client = getClient(chainId, {});
|
|
7331
|
+
return values.map((v) => toAddressLink(v, true, client)).join(", ");
|
|
7332
|
+
}
|
|
7333
|
+
function diffTargetSelectorPairs(b, a) {
|
|
7334
|
+
const beforePairs = /* @__PURE__ */ new Set();
|
|
7335
|
+
const afterPairs = /* @__PURE__ */ new Set();
|
|
7336
|
+
for (let i = 0; i < (b?.targets.length ?? 0); i++) beforePairs.add(`${b.targets[i].toLowerCase()}|${b.selectors[i]}`);
|
|
7337
|
+
for (let i = 0; i < (a?.targets.length ?? 0); i++) afterPairs.add(`${a.targets[i].toLowerCase()}|${a.selectors[i]}`);
|
|
7338
|
+
const added = [];
|
|
7339
|
+
const removed = [];
|
|
7340
|
+
for (const p of afterPairs) if (!beforePairs.has(p)) added.push(p);
|
|
7341
|
+
for (const p of beforePairs) if (!afterPairs.has(p)) removed.push(p);
|
|
7342
|
+
return {
|
|
7343
|
+
added,
|
|
7344
|
+
removed
|
|
7345
|
+
};
|
|
7346
|
+
}
|
|
7347
|
+
function renderRoleDiff(amAddr, roleId, before, after, chainId) {
|
|
7348
|
+
const members = diffSets(setOf(before?.members), setOf(after?.members));
|
|
7349
|
+
const targetSelectors = diffTargetSelectorPairs(before, after);
|
|
7350
|
+
const labelChanged = (before?.label ?? "") !== (after?.label ?? "");
|
|
7351
|
+
if (!labelChanged && members.added.length === 0 && members.removed.length === 0 && targetSelectors.added.length === 0 && targetSelectors.removed.length === 0) return "";
|
|
7352
|
+
const client = getClient(chainId, {});
|
|
7353
|
+
let md = `#### ${toAddressLink(amAddr, true, client)} role ${roleId}`;
|
|
7354
|
+
if ((after ?? before)?.label) md += ` (${(after ?? before).label})`;
|
|
7355
|
+
md += "\n\n";
|
|
7356
|
+
if (labelChanged) md += `- label: "${before?.label ?? ""}" -> "${after?.label ?? ""}"\n`;
|
|
7357
|
+
if (members.added.length > 0) md += `- members added: ${renderAddrList(members.added, chainId)}\n`;
|
|
7358
|
+
if (members.removed.length > 0) md += `- members removed: ${renderAddrList(members.removed, chainId)}\n`;
|
|
7359
|
+
if (targetSelectors.added.length > 0) {
|
|
7360
|
+
md += `- target/selector grants added:\n`;
|
|
7361
|
+
for (const p of targetSelectors.added) {
|
|
7362
|
+
const [t, s] = p.split("|");
|
|
7363
|
+
md += ` - ${toAddressLink(t, true, client)} ${s}\n`;
|
|
7364
|
+
}
|
|
7365
|
+
}
|
|
7366
|
+
if (targetSelectors.removed.length > 0) {
|
|
7367
|
+
md += `- target/selector grants removed:\n`;
|
|
7368
|
+
for (const p of targetSelectors.removed) {
|
|
7369
|
+
const [t, s] = p.split("|");
|
|
7370
|
+
md += ` - ${toAddressLink(t, true, client)} ${s}\n`;
|
|
7371
|
+
}
|
|
7372
|
+
}
|
|
7373
|
+
md += "\n";
|
|
7374
|
+
return md;
|
|
7375
|
+
}
|
|
7376
|
+
function renderAccessManagerRolesSection(before, after) {
|
|
7377
|
+
const beforeAm = before.accessManagerRoles ?? {};
|
|
7378
|
+
const afterAm = after.accessManagerRoles ?? {};
|
|
7379
|
+
const allAms = new Set([...Object.keys(beforeAm), ...Object.keys(afterAm)]);
|
|
7380
|
+
let body = "";
|
|
7381
|
+
for (const amAddr of allAms) {
|
|
7382
|
+
const beforeRoles = beforeAm[amAddr] ?? {};
|
|
7383
|
+
const afterRoles = afterAm[amAddr] ?? {};
|
|
7384
|
+
const allRoles = new Set([...Object.keys(beforeRoles), ...Object.keys(afterRoles)]);
|
|
7385
|
+
for (const roleId of [...allRoles].sort((a, b) => Number(a) - Number(b))) body += renderRoleDiff(amAddr, roleId, beforeRoles[roleId], afterRoles[roleId], after.chainId);
|
|
7386
|
+
}
|
|
7387
|
+
if (!body) return "";
|
|
7388
|
+
return `## Access Manager Role Changes\n\n${body}`;
|
|
7389
|
+
}
|
|
7390
|
+
|
|
7235
7391
|
//#endregion
|
|
7236
7392
|
//#region protocol-diff-v4.ts
|
|
7237
7393
|
/**
|
|
@@ -7257,6 +7413,8 @@ async function diffV4Snapshots(before, after) {
|
|
|
7257
7413
|
md += renderHubAssetsSection(before, postCopy);
|
|
7258
7414
|
md += renderSpokeConfigsSection(before, postCopy);
|
|
7259
7415
|
md += renderSpokeLiquidationSection(before, postCopy);
|
|
7416
|
+
md += renderPositionManagersSection(before, postCopy);
|
|
7417
|
+
md += renderAccessManagerRolesSection(before, postCopy);
|
|
7260
7418
|
md += await renderLogsSection(logs, after.chainId);
|
|
7261
7419
|
md += renderRawSection(raw, after.chainId);
|
|
7262
7420
|
const preCopy = { ...before };
|
|
@@ -6995,7 +6995,9 @@ function formatV4Value(section, key, value, ctx) {
|
|
|
6995
6995
|
//#endregion
|
|
6996
6996
|
//#region sections/spoke-reserves.ts
|
|
6997
6997
|
/** All fields in display order. Every field is compared — even identity fields
|
|
6998
|
-
* that "shouldn't" change — so unexpected mutations are never silently missed.
|
|
6998
|
+
* that "shouldn't" change — so unexpected mutations are never silently missed.
|
|
6999
|
+
* `dynamicConfigs` is excluded from this list and rendered separately because
|
|
7000
|
+
* it is a nested record per key, not a single value. */
|
|
6999
7001
|
const FIELD_ORDER$3 = [
|
|
7000
7002
|
"symbol",
|
|
7001
7003
|
"underlying",
|
|
@@ -7015,6 +7017,41 @@ const FIELD_ORDER$3 = [
|
|
|
7015
7017
|
"priceSource",
|
|
7016
7018
|
"oraclePrice"
|
|
7017
7019
|
];
|
|
7020
|
+
const DYNAMIC_CONFIG_FIELDS = [
|
|
7021
|
+
"collateralFactor",
|
|
7022
|
+
"maxLiquidationBonus",
|
|
7023
|
+
"liquidationFee"
|
|
7024
|
+
];
|
|
7025
|
+
function fmtDynamicConfigField(field, value) {
|
|
7026
|
+
if (field === "maxLiquidationBonus") {
|
|
7027
|
+
if (value === 0) return "0.00 % [0]";
|
|
7028
|
+
return `${((value - 1e4) / 100).toFixed(2)} % [${value}]`;
|
|
7029
|
+
}
|
|
7030
|
+
const w = Math.floor(value / 100);
|
|
7031
|
+
const f = value % 100;
|
|
7032
|
+
return `${w}.${f < 10 ? `0${f}` : `${f}`} % [${value}]`;
|
|
7033
|
+
}
|
|
7034
|
+
function renderDynamicConfigsBlock(before, after) {
|
|
7035
|
+
const allKeys = new Set([...Object.keys(before ?? {}), ...Object.keys(after ?? {})]);
|
|
7036
|
+
const rows = [];
|
|
7037
|
+
for (const key of [...allKeys].sort((a, b) => Number(a) - Number(b))) {
|
|
7038
|
+
const b = before?.[key];
|
|
7039
|
+
const a = after?.[key];
|
|
7040
|
+
for (const field of DYNAMIC_CONFIG_FIELDS) {
|
|
7041
|
+
const bv = b?.[field];
|
|
7042
|
+
const av = a?.[field];
|
|
7043
|
+
if (String(bv) === String(av)) continue;
|
|
7044
|
+
const fromFmt = bv === void 0 ? "*missing*" : fmtDynamicConfigField(field, bv);
|
|
7045
|
+
const toFmt = av === void 0 ? "*missing*" : fmtDynamicConfigField(field, av);
|
|
7046
|
+
rows.push(`| key ${key} | ${field} | ${fromFmt} | ${toFmt} |`);
|
|
7047
|
+
}
|
|
7048
|
+
}
|
|
7049
|
+
if (rows.length === 0) return "";
|
|
7050
|
+
let md = "**dynamicConfigs**\n\n";
|
|
7051
|
+
md += "| key | field | before | after |\n| --- | --- | --- | --- |\n";
|
|
7052
|
+
md += rows.join("\n") + "\n\n";
|
|
7053
|
+
return md;
|
|
7054
|
+
}
|
|
7018
7055
|
function reserveHeader(reserve, spokeAddr, reserveId, chainId) {
|
|
7019
7056
|
const client = (0, _bgd_labs_toolbox.getClient)(chainId, {});
|
|
7020
7057
|
const underlyingLink = toAddressLink(reserve.underlying, true, client);
|
|
@@ -7026,6 +7063,8 @@ function renderNewReserve(reserve, spokeAddr, reserveId, ctx) {
|
|
|
7026
7063
|
md += "**NEW RESERVE**\n\n";
|
|
7027
7064
|
md += "| description | value |\n| --- | --- |\n";
|
|
7028
7065
|
for (const key of FIELD_ORDER$3) md += `| ${key} | ${formatV4Value("spokeReserve", key, reserve[key], ctx)} |\n`;
|
|
7066
|
+
md += "\n";
|
|
7067
|
+
md += renderDynamicConfigsBlock(void 0, reserve.dynamicConfigs);
|
|
7029
7068
|
return md + "\n";
|
|
7030
7069
|
}
|
|
7031
7070
|
function renderReserveDiff(before, after, spokeAddr, reserveId, ctx) {
|
|
@@ -7038,10 +7077,14 @@ function renderReserveDiff(before, after, spokeAddr, reserveId, ctx) {
|
|
|
7038
7077
|
const toFmt = formatV4Value("spokeReserve", key, aVal, ctx);
|
|
7039
7078
|
rows.push(`| ${key} | ${fromFmt} | ${toFmt} |`);
|
|
7040
7079
|
}
|
|
7041
|
-
|
|
7080
|
+
const dynamicConfigsBlock = renderDynamicConfigsBlock(before.dynamicConfigs, after.dynamicConfigs);
|
|
7081
|
+
if (rows.length === 0 && !dynamicConfigsBlock) return "";
|
|
7042
7082
|
let md = reserveHeader(after, spokeAddr, reserveId, ctx.chainId);
|
|
7043
|
-
|
|
7044
|
-
|
|
7083
|
+
if (rows.length > 0) {
|
|
7084
|
+
md += "| description | value before | value after |\n| --- | --- | --- |\n";
|
|
7085
|
+
md += rows.join("\n") + "\n\n";
|
|
7086
|
+
}
|
|
7087
|
+
md += dynamicConfigsBlock;
|
|
7045
7088
|
return md + "\n";
|
|
7046
7089
|
}
|
|
7047
7090
|
function renderSpokeReservesSection(before, after) {
|
|
@@ -7260,6 +7303,119 @@ function renderSpokeLiquidationSection(before, after) {
|
|
|
7260
7303
|
return `## Spoke Liquidation Config Changes\n\n${body}`;
|
|
7261
7304
|
}
|
|
7262
7305
|
|
|
7306
|
+
//#endregion
|
|
7307
|
+
//#region sections/position-managers.ts
|
|
7308
|
+
/**
|
|
7309
|
+
* Renders the per-spoke position-manager registration diff. Each row is a
|
|
7310
|
+
* (spoke, positionManager) pair whose `active` flag changed.
|
|
7311
|
+
*/
|
|
7312
|
+
function renderPositionManagersSection(before, after) {
|
|
7313
|
+
const beforePm = before.positionManagers ?? {};
|
|
7314
|
+
const afterPm = after.positionManagers ?? {};
|
|
7315
|
+
const allSpokes = new Set([...Object.keys(beforePm), ...Object.keys(afterPm)]);
|
|
7316
|
+
const client = (0, _bgd_labs_toolbox.getClient)(after.chainId, {});
|
|
7317
|
+
const rows = [];
|
|
7318
|
+
for (const spokeAddr of allSpokes) {
|
|
7319
|
+
const beforeSpoke = beforePm[spokeAddr] ?? {};
|
|
7320
|
+
const afterSpoke = afterPm[spokeAddr] ?? {};
|
|
7321
|
+
const allManagers = new Set([...Object.keys(beforeSpoke), ...Object.keys(afterSpoke)]);
|
|
7322
|
+
for (const manager of allManagers) {
|
|
7323
|
+
const bv = beforeSpoke[manager];
|
|
7324
|
+
const av = afterSpoke[manager];
|
|
7325
|
+
if (bv === av) continue;
|
|
7326
|
+
const spokeLink = toAddressLink(spokeAddr, true, client);
|
|
7327
|
+
const managerLink = toAddressLink(manager, true, client);
|
|
7328
|
+
const fromFmt = bv === void 0 ? "*missing*" : boolToMarkdown(bv);
|
|
7329
|
+
const toFmt = av === void 0 ? "*missing*" : boolToMarkdown(av);
|
|
7330
|
+
rows.push(`| ${spokeLink} | ${managerLink} | ${fromFmt} | ${toFmt} |`);
|
|
7331
|
+
}
|
|
7332
|
+
}
|
|
7333
|
+
if (rows.length === 0) return "";
|
|
7334
|
+
let md = "## Position Manager Changes\n\n";
|
|
7335
|
+
md += "| spoke | position manager | active before | active after |\n";
|
|
7336
|
+
md += "| --- | --- | --- | --- |\n";
|
|
7337
|
+
md += rows.join("\n") + "\n\n";
|
|
7338
|
+
return md;
|
|
7339
|
+
}
|
|
7340
|
+
|
|
7341
|
+
//#endregion
|
|
7342
|
+
//#region sections/access-manager-roles.ts
|
|
7343
|
+
function setOf(arr) {
|
|
7344
|
+
return new Set((arr ?? []).map((v) => v.toLowerCase()));
|
|
7345
|
+
}
|
|
7346
|
+
function diffSets(b, a) {
|
|
7347
|
+
const added = [];
|
|
7348
|
+
const removed = [];
|
|
7349
|
+
for (const v of a) if (!b.has(v)) added.push(v);
|
|
7350
|
+
for (const v of b) if (!a.has(v)) removed.push(v);
|
|
7351
|
+
return {
|
|
7352
|
+
added,
|
|
7353
|
+
removed
|
|
7354
|
+
};
|
|
7355
|
+
}
|
|
7356
|
+
function renderAddrList(values, chainId) {
|
|
7357
|
+
if (values.length === 0) return "*(none)*";
|
|
7358
|
+
const client = (0, _bgd_labs_toolbox.getClient)(chainId, {});
|
|
7359
|
+
return values.map((v) => toAddressLink(v, true, client)).join(", ");
|
|
7360
|
+
}
|
|
7361
|
+
function diffTargetSelectorPairs(b, a) {
|
|
7362
|
+
const beforePairs = /* @__PURE__ */ new Set();
|
|
7363
|
+
const afterPairs = /* @__PURE__ */ new Set();
|
|
7364
|
+
for (let i = 0; i < (b?.targets.length ?? 0); i++) beforePairs.add(`${b.targets[i].toLowerCase()}|${b.selectors[i]}`);
|
|
7365
|
+
for (let i = 0; i < (a?.targets.length ?? 0); i++) afterPairs.add(`${a.targets[i].toLowerCase()}|${a.selectors[i]}`);
|
|
7366
|
+
const added = [];
|
|
7367
|
+
const removed = [];
|
|
7368
|
+
for (const p of afterPairs) if (!beforePairs.has(p)) added.push(p);
|
|
7369
|
+
for (const p of beforePairs) if (!afterPairs.has(p)) removed.push(p);
|
|
7370
|
+
return {
|
|
7371
|
+
added,
|
|
7372
|
+
removed
|
|
7373
|
+
};
|
|
7374
|
+
}
|
|
7375
|
+
function renderRoleDiff(amAddr, roleId, before, after, chainId) {
|
|
7376
|
+
const members = diffSets(setOf(before?.members), setOf(after?.members));
|
|
7377
|
+
const targetSelectors = diffTargetSelectorPairs(before, after);
|
|
7378
|
+
const labelChanged = (before?.label ?? "") !== (after?.label ?? "");
|
|
7379
|
+
if (!labelChanged && members.added.length === 0 && members.removed.length === 0 && targetSelectors.added.length === 0 && targetSelectors.removed.length === 0) return "";
|
|
7380
|
+
const client = (0, _bgd_labs_toolbox.getClient)(chainId, {});
|
|
7381
|
+
let md = `#### ${toAddressLink(amAddr, true, client)} role ${roleId}`;
|
|
7382
|
+
if ((after ?? before)?.label) md += ` (${(after ?? before).label})`;
|
|
7383
|
+
md += "\n\n";
|
|
7384
|
+
if (labelChanged) md += `- label: "${before?.label ?? ""}" -> "${after?.label ?? ""}"\n`;
|
|
7385
|
+
if (members.added.length > 0) md += `- members added: ${renderAddrList(members.added, chainId)}\n`;
|
|
7386
|
+
if (members.removed.length > 0) md += `- members removed: ${renderAddrList(members.removed, chainId)}\n`;
|
|
7387
|
+
if (targetSelectors.added.length > 0) {
|
|
7388
|
+
md += `- target/selector grants added:\n`;
|
|
7389
|
+
for (const p of targetSelectors.added) {
|
|
7390
|
+
const [t, s] = p.split("|");
|
|
7391
|
+
md += ` - ${toAddressLink(t, true, client)} ${s}\n`;
|
|
7392
|
+
}
|
|
7393
|
+
}
|
|
7394
|
+
if (targetSelectors.removed.length > 0) {
|
|
7395
|
+
md += `- target/selector grants removed:\n`;
|
|
7396
|
+
for (const p of targetSelectors.removed) {
|
|
7397
|
+
const [t, s] = p.split("|");
|
|
7398
|
+
md += ` - ${toAddressLink(t, true, client)} ${s}\n`;
|
|
7399
|
+
}
|
|
7400
|
+
}
|
|
7401
|
+
md += "\n";
|
|
7402
|
+
return md;
|
|
7403
|
+
}
|
|
7404
|
+
function renderAccessManagerRolesSection(before, after) {
|
|
7405
|
+
const beforeAm = before.accessManagerRoles ?? {};
|
|
7406
|
+
const afterAm = after.accessManagerRoles ?? {};
|
|
7407
|
+
const allAms = new Set([...Object.keys(beforeAm), ...Object.keys(afterAm)]);
|
|
7408
|
+
let body = "";
|
|
7409
|
+
for (const amAddr of allAms) {
|
|
7410
|
+
const beforeRoles = beforeAm[amAddr] ?? {};
|
|
7411
|
+
const afterRoles = afterAm[amAddr] ?? {};
|
|
7412
|
+
const allRoles = new Set([...Object.keys(beforeRoles), ...Object.keys(afterRoles)]);
|
|
7413
|
+
for (const roleId of [...allRoles].sort((a, b) => Number(a) - Number(b))) body += renderRoleDiff(amAddr, roleId, beforeRoles[roleId], afterRoles[roleId], after.chainId);
|
|
7414
|
+
}
|
|
7415
|
+
if (!body) return "";
|
|
7416
|
+
return `## Access Manager Role Changes\n\n${body}`;
|
|
7417
|
+
}
|
|
7418
|
+
|
|
7263
7419
|
//#endregion
|
|
7264
7420
|
//#region protocol-diff-v4.ts
|
|
7265
7421
|
/**
|
|
@@ -7285,6 +7441,8 @@ async function diffV4Snapshots(before, after) {
|
|
|
7285
7441
|
md += renderHubAssetsSection(before, postCopy);
|
|
7286
7442
|
md += renderSpokeConfigsSection(before, postCopy);
|
|
7287
7443
|
md += renderSpokeLiquidationSection(before, postCopy);
|
|
7444
|
+
md += renderPositionManagersSection(before, postCopy);
|
|
7445
|
+
md += renderAccessManagerRolesSection(before, postCopy);
|
|
7288
7446
|
md += await renderLogsSection(logs, after.chainId);
|
|
7289
7447
|
md += renderRawSection(raw, after.chainId);
|
|
7290
7448
|
const preCopy = { ...before };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aave-dao/aave-helpers-js",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"dist"
|
|
29
29
|
],
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@aave-dao/aave-address-book": "^4.
|
|
31
|
+
"@aave-dao/aave-address-book": "^4.52.5",
|
|
32
32
|
"@bgd-labs/toolbox": "^0.2.24",
|
|
33
33
|
"commander": "^14.0.3",
|
|
34
34
|
"find-object-paths": "^1.1.0",
|