@aave-dao/aave-helpers-js 1.0.13 → 1.1.0
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 +7 -2
- package/dist/cli.mjs +6 -1
- package/dist/index.cjs +7 -6
- package/dist/index.d.cts +153 -1
- package/dist/index.d.mts +153 -1
- package/dist/index.mjs +2 -2
- package/dist/{protocol-diff-B6fP3E2n.mjs → protocol-diff-v4-7OfLBu6D.mjs} +641 -11
- package/dist/{protocol-diff-DxfBiCSN.cjs → protocol-diff-v4-DyoIo_CY.cjs} +646 -10
- package/package.json +1 -1
|
@@ -99,13 +99,13 @@ function boolToMarkdown(value) {
|
|
|
99
99
|
|
|
100
100
|
//#endregion
|
|
101
101
|
//#region formatters.ts
|
|
102
|
-
function getExplorerClient(chainId) {
|
|
102
|
+
function getExplorerClient$1(chainId) {
|
|
103
103
|
return (0, _bgd_labs_toolbox.getClient)(chainId, {});
|
|
104
104
|
}
|
|
105
|
-
function addressLink(value, chainId) {
|
|
106
|
-
return toAddressLink(value, true, getExplorerClient(chainId));
|
|
105
|
+
function addressLink$1(value, chainId) {
|
|
106
|
+
return toAddressLink(value, true, getExplorerClient$1(chainId));
|
|
107
107
|
}
|
|
108
|
-
function isAddress(value) {
|
|
108
|
+
function isAddress$1(value) {
|
|
109
109
|
return typeof value === "string" && /^0x[0-9a-fA-F]{40}$/.test(value);
|
|
110
110
|
}
|
|
111
111
|
const RESERVE_PERCENTAGE_FIELDS = [
|
|
@@ -155,7 +155,7 @@ reserveFormatters["oracleLatestAnswer"] = (value, ctx) => {
|
|
|
155
155
|
const decimals = ctx.reserve?.oracleDecimals ?? 8;
|
|
156
156
|
return (0, viem.formatUnits)(BigInt(value), decimals) + " $";
|
|
157
157
|
};
|
|
158
|
-
for (const field of RESERVE_ADDRESS_FIELDS) reserveFormatters[field] = (value, ctx) => addressLink(value, ctx.chainId);
|
|
158
|
+
for (const field of RESERVE_ADDRESS_FIELDS) reserveFormatters[field] = (value, ctx) => addressLink$1(value, ctx.chainId);
|
|
159
159
|
for (const field of RESERVE_BOOL_FIELDS) reserveFormatters[field] = (value) => boolToMarkdown(value);
|
|
160
160
|
const STRATEGY_RATE_FIELDS = [
|
|
161
161
|
"baseVariableBorrowRate",
|
|
@@ -166,7 +166,7 @@ const STRATEGY_RATE_FIELDS = [
|
|
|
166
166
|
];
|
|
167
167
|
const strategyFormatters = {};
|
|
168
168
|
for (const field of STRATEGY_RATE_FIELDS) strategyFormatters[field] = (value) => `${(0, viem.formatUnits)(BigInt(value), 25)} %`;
|
|
169
|
-
strategyFormatters["address"] = (value, ctx) => addressLink(value, ctx.chainId);
|
|
169
|
+
strategyFormatters["address"] = (value, ctx) => addressLink$1(value, ctx.chainId);
|
|
170
170
|
const emodeFormatters = {};
|
|
171
171
|
emodeFormatters["ltv"] = (value) => `${(0, viem.formatUnits)(BigInt(value), 2)} %`;
|
|
172
172
|
emodeFormatters["liquidationThreshold"] = (value) => `${(0, viem.formatUnits)(BigInt(value), 2)} %`;
|
|
@@ -181,18 +181,18 @@ emodeFormatters["borrowableBitmap"] = (value, ctx) => {
|
|
|
181
181
|
}).join(", ");
|
|
182
182
|
};
|
|
183
183
|
emodeFormatters["collateralBitmap"] = emodeFormatters["borrowableBitmap"];
|
|
184
|
-
emodeFormatters["priceSource"] = (value, ctx) => addressLink(value, ctx.chainId);
|
|
185
|
-
const formattersMap = {
|
|
184
|
+
emodeFormatters["priceSource"] = (value, ctx) => addressLink$1(value, ctx.chainId);
|
|
185
|
+
const formattersMap$1 = {
|
|
186
186
|
reserve: reserveFormatters,
|
|
187
187
|
strategy: strategyFormatters,
|
|
188
188
|
emode: emodeFormatters
|
|
189
189
|
};
|
|
190
190
|
function formatValue$1(section, key, value, ctx) {
|
|
191
|
-
const formatter = formattersMap[section][key];
|
|
191
|
+
const formatter = formattersMap$1[section][key];
|
|
192
192
|
if (formatter) return formatter(value, ctx);
|
|
193
193
|
if (typeof value === "boolean") return boolToMarkdown(value);
|
|
194
194
|
if (typeof value === "number") return value.toLocaleString("en-US");
|
|
195
|
-
if (isAddress(value)) return addressLink(value, ctx.chainId);
|
|
195
|
+
if (isAddress$1(value)) return addressLink$1(value, ctx.chainId);
|
|
196
196
|
return String(value);
|
|
197
197
|
}
|
|
198
198
|
|
|
@@ -4536,6 +4536,225 @@ const eventDb = [
|
|
|
4536
4536
|
}],
|
|
4537
4537
|
name: "Bridge",
|
|
4538
4538
|
type: "event"
|
|
4539
|
+
},
|
|
4540
|
+
{
|
|
4541
|
+
anonymous: false,
|
|
4542
|
+
inputs: [
|
|
4543
|
+
{
|
|
4544
|
+
indexed: true,
|
|
4545
|
+
internalType: "uint256",
|
|
4546
|
+
name: "id",
|
|
4547
|
+
type: "uint256"
|
|
4548
|
+
},
|
|
4549
|
+
{
|
|
4550
|
+
indexed: true,
|
|
4551
|
+
internalType: "address",
|
|
4552
|
+
name: "upkeep",
|
|
4553
|
+
type: "address"
|
|
4554
|
+
},
|
|
4555
|
+
{
|
|
4556
|
+
indexed: true,
|
|
4557
|
+
internalType: "uint32",
|
|
4558
|
+
name: "gasLimit",
|
|
4559
|
+
type: "uint32"
|
|
4560
|
+
}
|
|
4561
|
+
],
|
|
4562
|
+
name: "GasLimitSet",
|
|
4563
|
+
type: "event"
|
|
4564
|
+
},
|
|
4565
|
+
{
|
|
4566
|
+
anonymous: false,
|
|
4567
|
+
inputs: [
|
|
4568
|
+
{
|
|
4569
|
+
indexed: false,
|
|
4570
|
+
internalType: "address",
|
|
4571
|
+
name: "keeperRegistry",
|
|
4572
|
+
type: "address"
|
|
4573
|
+
},
|
|
4574
|
+
{
|
|
4575
|
+
indexed: false,
|
|
4576
|
+
internalType: "address",
|
|
4577
|
+
name: "keeperRegistrar",
|
|
4578
|
+
type: "address"
|
|
4579
|
+
},
|
|
4580
|
+
{
|
|
4581
|
+
indexed: false,
|
|
4582
|
+
internalType: "address",
|
|
4583
|
+
name: "linkWithdrawAddress",
|
|
4584
|
+
type: "address"
|
|
4585
|
+
},
|
|
4586
|
+
{
|
|
4587
|
+
indexed: false,
|
|
4588
|
+
internalType: "address",
|
|
4589
|
+
name: "operatorOwner",
|
|
4590
|
+
type: "address"
|
|
4591
|
+
},
|
|
4592
|
+
{
|
|
4593
|
+
indexed: false,
|
|
4594
|
+
internalType: "address",
|
|
4595
|
+
name: "operatorGuardian",
|
|
4596
|
+
type: "address"
|
|
4597
|
+
}
|
|
4598
|
+
],
|
|
4599
|
+
name: "Initialized",
|
|
4600
|
+
type: "event"
|
|
4601
|
+
},
|
|
4602
|
+
{
|
|
4603
|
+
anonymous: false,
|
|
4604
|
+
inputs: [{
|
|
4605
|
+
indexed: true,
|
|
4606
|
+
internalType: "uint256",
|
|
4607
|
+
name: "id",
|
|
4608
|
+
type: "uint256"
|
|
4609
|
+
}, {
|
|
4610
|
+
indexed: true,
|
|
4611
|
+
internalType: "address",
|
|
4612
|
+
name: "upkeep",
|
|
4613
|
+
type: "address"
|
|
4614
|
+
}],
|
|
4615
|
+
name: "KeeperCancelled",
|
|
4616
|
+
type: "event"
|
|
4617
|
+
},
|
|
4618
|
+
{
|
|
4619
|
+
anonymous: false,
|
|
4620
|
+
inputs: [{
|
|
4621
|
+
indexed: true,
|
|
4622
|
+
internalType: "uint256",
|
|
4623
|
+
name: "id",
|
|
4624
|
+
type: "uint256"
|
|
4625
|
+
}],
|
|
4626
|
+
name: "KeeperPaused",
|
|
4627
|
+
type: "event"
|
|
4628
|
+
},
|
|
4629
|
+
{
|
|
4630
|
+
anonymous: false,
|
|
4631
|
+
inputs: [
|
|
4632
|
+
{
|
|
4633
|
+
indexed: true,
|
|
4634
|
+
internalType: "uint256",
|
|
4635
|
+
name: "id",
|
|
4636
|
+
type: "uint256"
|
|
4637
|
+
},
|
|
4638
|
+
{
|
|
4639
|
+
indexed: true,
|
|
4640
|
+
internalType: "address",
|
|
4641
|
+
name: "from",
|
|
4642
|
+
type: "address"
|
|
4643
|
+
},
|
|
4644
|
+
{
|
|
4645
|
+
indexed: true,
|
|
4646
|
+
internalType: "uint96",
|
|
4647
|
+
name: "amount",
|
|
4648
|
+
type: "uint96"
|
|
4649
|
+
}
|
|
4650
|
+
],
|
|
4651
|
+
name: "KeeperRefilled",
|
|
4652
|
+
type: "event"
|
|
4653
|
+
},
|
|
4654
|
+
{
|
|
4655
|
+
anonymous: false,
|
|
4656
|
+
inputs: [{
|
|
4657
|
+
indexed: true,
|
|
4658
|
+
internalType: "address",
|
|
4659
|
+
name: "newKeeperRegistrar",
|
|
4660
|
+
type: "address"
|
|
4661
|
+
}],
|
|
4662
|
+
name: "KeeperRegistrarSet",
|
|
4663
|
+
type: "event"
|
|
4664
|
+
},
|
|
4665
|
+
{
|
|
4666
|
+
anonymous: false,
|
|
4667
|
+
inputs: [{
|
|
4668
|
+
indexed: true,
|
|
4669
|
+
internalType: "address",
|
|
4670
|
+
name: "newKeeperRegistry",
|
|
4671
|
+
type: "address"
|
|
4672
|
+
}],
|
|
4673
|
+
name: "KeeperRegistrySet",
|
|
4674
|
+
type: "event"
|
|
4675
|
+
},
|
|
4676
|
+
{
|
|
4677
|
+
anonymous: false,
|
|
4678
|
+
inputs: [{
|
|
4679
|
+
indexed: true,
|
|
4680
|
+
internalType: "uint256",
|
|
4681
|
+
name: "id",
|
|
4682
|
+
type: "uint256"
|
|
4683
|
+
}],
|
|
4684
|
+
name: "KeeperUnpaused",
|
|
4685
|
+
type: "event"
|
|
4686
|
+
},
|
|
4687
|
+
{
|
|
4688
|
+
anonymous: false,
|
|
4689
|
+
inputs: [
|
|
4690
|
+
{
|
|
4691
|
+
indexed: true,
|
|
4692
|
+
internalType: "uint256[]",
|
|
4693
|
+
name: "ids",
|
|
4694
|
+
type: "uint256[]"
|
|
4695
|
+
},
|
|
4696
|
+
{
|
|
4697
|
+
indexed: true,
|
|
4698
|
+
internalType: "address",
|
|
4699
|
+
name: "newKeeperRegistry",
|
|
4700
|
+
type: "address"
|
|
4701
|
+
},
|
|
4702
|
+
{
|
|
4703
|
+
indexed: true,
|
|
4704
|
+
internalType: "address",
|
|
4705
|
+
name: "newKeeperRegistrar",
|
|
4706
|
+
type: "address"
|
|
4707
|
+
}
|
|
4708
|
+
],
|
|
4709
|
+
name: "KeepersMigrated",
|
|
4710
|
+
type: "event"
|
|
4711
|
+
},
|
|
4712
|
+
{
|
|
4713
|
+
anonymous: false,
|
|
4714
|
+
inputs: [
|
|
4715
|
+
{
|
|
4716
|
+
indexed: true,
|
|
4717
|
+
internalType: "uint256",
|
|
4718
|
+
name: "id",
|
|
4719
|
+
type: "uint256"
|
|
4720
|
+
},
|
|
4721
|
+
{
|
|
4722
|
+
indexed: true,
|
|
4723
|
+
internalType: "address",
|
|
4724
|
+
name: "upkeep",
|
|
4725
|
+
type: "address"
|
|
4726
|
+
},
|
|
4727
|
+
{
|
|
4728
|
+
indexed: true,
|
|
4729
|
+
internalType: "address",
|
|
4730
|
+
name: "to",
|
|
4731
|
+
type: "address"
|
|
4732
|
+
}
|
|
4733
|
+
],
|
|
4734
|
+
name: "LinkWithdrawn",
|
|
4735
|
+
type: "event"
|
|
4736
|
+
},
|
|
4737
|
+
{
|
|
4738
|
+
anonymous: false,
|
|
4739
|
+
inputs: [{
|
|
4740
|
+
indexed: true,
|
|
4741
|
+
internalType: "uint256",
|
|
4742
|
+
name: "id",
|
|
4743
|
+
type: "uint256"
|
|
4744
|
+
}],
|
|
4745
|
+
name: "TriggerConfigSet",
|
|
4746
|
+
type: "event"
|
|
4747
|
+
},
|
|
4748
|
+
{
|
|
4749
|
+
anonymous: false,
|
|
4750
|
+
inputs: [{
|
|
4751
|
+
indexed: true,
|
|
4752
|
+
internalType: "address",
|
|
4753
|
+
name: "newWithdrawAddress",
|
|
4754
|
+
type: "address"
|
|
4755
|
+
}],
|
|
4756
|
+
name: "WithdrawAddressSet",
|
|
4757
|
+
type: "event"
|
|
4539
4758
|
}
|
|
4540
4759
|
];
|
|
4541
4760
|
|
|
@@ -4637,6 +4856,417 @@ async function diffSnapshots(before, after) {
|
|
|
4637
4856
|
return md;
|
|
4638
4857
|
}
|
|
4639
4858
|
|
|
4859
|
+
//#endregion
|
|
4860
|
+
//#region formatters-v4.ts
|
|
4861
|
+
function getExplorerClient(chainId) {
|
|
4862
|
+
return (0, _bgd_labs_toolbox.getClient)(chainId, {});
|
|
4863
|
+
}
|
|
4864
|
+
function addressLink(value, chainId) {
|
|
4865
|
+
return toAddressLink(value, true, getExplorerClient(chainId));
|
|
4866
|
+
}
|
|
4867
|
+
function isAddress(value) {
|
|
4868
|
+
return typeof value === "string" && /^0x[0-9a-fA-F]{40}$/.test(value);
|
|
4869
|
+
}
|
|
4870
|
+
/** Format BPS value as percentage, matching Solidity _ps(): "W.FF % [bps]" */
|
|
4871
|
+
function formatBps(bps) {
|
|
4872
|
+
const w = Math.floor(bps / 100);
|
|
4873
|
+
const f = bps % 100;
|
|
4874
|
+
return `${w}.${f < 10 ? `0${f}` : `${f}`} % [${bps}]`;
|
|
4875
|
+
}
|
|
4876
|
+
/** Render a uint as "1,500,000 (1.5e6) USDT"; suffix (e.g. asset symbol) goes
|
|
4877
|
+
* at the end after the exponential. Values < 1000 skip the exponential.
|
|
4878
|
+
* Exponential uses `Number.toExponential()`, so bigints exceeding
|
|
4879
|
+
* Number.MAX_SAFE_INTEGER (~9e15) the exponent is rounded */
|
|
4880
|
+
function formatBigIntWithExp(value, suffix) {
|
|
4881
|
+
return `${value.toLocaleString("en-US")}${value >= 1000n || value <= -1000n ? ` (${Number(value).toExponential().replace("e+", "e")})` : ""}${suffix ? ` ${suffix}` : ""}`;
|
|
4882
|
+
}
|
|
4883
|
+
const SPOKE_RESERVE_BPS_FIELDS = [
|
|
4884
|
+
"collateralRisk",
|
|
4885
|
+
"collateralFactor",
|
|
4886
|
+
"liquidationFee"
|
|
4887
|
+
];
|
|
4888
|
+
/** ISpoke.DynamicReserveConfig: 100_00 represents 0.00% bonus — subtract PERCENTAGE_FACTOR (100_00) for the actual bonus. */
|
|
4889
|
+
function formatLiquidationBonus(value) {
|
|
4890
|
+
if (value === 0) return "0.00 % [0]";
|
|
4891
|
+
return `${((value - 1e4) / 100).toFixed(2)} % [${value}]`;
|
|
4892
|
+
}
|
|
4893
|
+
const SPOKE_RESERVE_BOOL_FIELDS = [
|
|
4894
|
+
"paused",
|
|
4895
|
+
"frozen",
|
|
4896
|
+
"borrowable",
|
|
4897
|
+
"receiveSharesEnabled"
|
|
4898
|
+
];
|
|
4899
|
+
const SPOKE_RESERVE_ADDRESS_FIELDS = [
|
|
4900
|
+
"underlying",
|
|
4901
|
+
"hub",
|
|
4902
|
+
"oracleAddress",
|
|
4903
|
+
"priceSource"
|
|
4904
|
+
];
|
|
4905
|
+
const spokeReserveFormatters = {};
|
|
4906
|
+
for (const field of SPOKE_RESERVE_BPS_FIELDS) spokeReserveFormatters[field] = (value) => formatBps(value);
|
|
4907
|
+
spokeReserveFormatters["maxLiquidationBonus"] = (value) => formatLiquidationBonus(value);
|
|
4908
|
+
for (const field of SPOKE_RESERVE_BOOL_FIELDS) spokeReserveFormatters[field] = (value) => boolToMarkdown(value);
|
|
4909
|
+
for (const field of SPOKE_RESERVE_ADDRESS_FIELDS) spokeReserveFormatters[field] = (value, ctx) => addressLink(value, ctx.chainId);
|
|
4910
|
+
const HUB_ASSET_BPS_FIELDS = ["liquidityFee"];
|
|
4911
|
+
/** IR strategy fields — per-asset on V4, BPS scale (unlike V3 RAY). */
|
|
4912
|
+
const HUB_ASSET_IR_STRATEGY_BPS_FIELDS = [
|
|
4913
|
+
"optimalUsageRatio",
|
|
4914
|
+
"baseDrawnRate",
|
|
4915
|
+
"rateGrowthBeforeOptimal",
|
|
4916
|
+
"rateGrowthAfterOptimal"
|
|
4917
|
+
];
|
|
4918
|
+
const HUB_ASSET_ADDRESS_FIELDS = [
|
|
4919
|
+
"underlying",
|
|
4920
|
+
"irStrategy",
|
|
4921
|
+
"feeReceiver",
|
|
4922
|
+
"reinvestmentController"
|
|
4923
|
+
];
|
|
4924
|
+
const hubAssetFormatters = {};
|
|
4925
|
+
for (const field of HUB_ASSET_BPS_FIELDS) hubAssetFormatters[field] = (value) => formatBps(value);
|
|
4926
|
+
for (const field of HUB_ASSET_IR_STRATEGY_BPS_FIELDS) hubAssetFormatters[field] = (value) => formatBps(value);
|
|
4927
|
+
hubAssetFormatters["maxDrawnRate"] = (value) => formatBps(Number(value));
|
|
4928
|
+
for (const field of HUB_ASSET_ADDRESS_FIELDS) hubAssetFormatters[field] = (value, ctx) => addressLink(value, ctx.chainId);
|
|
4929
|
+
hubAssetFormatters["deficitRay"] = (value) => `${(0, viem.formatUnits)(BigInt(value), 27)} [${value}]`;
|
|
4930
|
+
hubAssetFormatters["premiumOffsetRay"] = (value) => `${(0, viem.formatUnits)(BigInt(value), 27)} [${value}]`;
|
|
4931
|
+
const SPOKE_CONFIG_FLAGS = ["active", "halted"];
|
|
4932
|
+
/** uint40 token-unit cap fields — formatted with thousands separators + asset symbol. */
|
|
4933
|
+
const SPOKE_CONFIG_TOKEN_AMOUNT_FIELDS = ["addCap", "drawCap"];
|
|
4934
|
+
const MAX_ALLOWED_SPOKE_CAP = 2 ** 40 - 1;
|
|
4935
|
+
const MAX_RISK_PREMIUM_THRESHOLD = 2 ** 24 - 1;
|
|
4936
|
+
const spokeConfigFormatters = {};
|
|
4937
|
+
for (const field of SPOKE_CONFIG_FLAGS) spokeConfigFormatters[field] = (value) => boolToMarkdown(value);
|
|
4938
|
+
for (const field of SPOKE_CONFIG_TOKEN_AMOUNT_FIELDS) spokeConfigFormatters[field] = (value, ctx) => {
|
|
4939
|
+
if (value === MAX_ALLOWED_SPOKE_CAP) return "sentinel value - no cap";
|
|
4940
|
+
return formatBigIntWithExp(BigInt(value), ctx.spokeConfig?.assetSymbol);
|
|
4941
|
+
};
|
|
4942
|
+
spokeConfigFormatters["riskPremiumThreshold"] = (value) => {
|
|
4943
|
+
if (value === MAX_RISK_PREMIUM_THRESHOLD) return "sentinel value - no threshold";
|
|
4944
|
+
return formatBps(value);
|
|
4945
|
+
};
|
|
4946
|
+
const spokeLiqFormatters = {};
|
|
4947
|
+
spokeLiqFormatters["targetHealthFactor"] = (value) => `${(0, viem.formatUnits)(BigInt(value), 18)} [${value}]`;
|
|
4948
|
+
spokeLiqFormatters["healthFactorForMaxBonus"] = (value) => `${(0, viem.formatUnits)(BigInt(value), 18)} [${value}]`;
|
|
4949
|
+
spokeLiqFormatters["liquidationBonusFactor"] = (value) => formatBps(value);
|
|
4950
|
+
const formattersMap = {
|
|
4951
|
+
spokeReserve: spokeReserveFormatters,
|
|
4952
|
+
hubAsset: hubAssetFormatters,
|
|
4953
|
+
spokeConfig: spokeConfigFormatters,
|
|
4954
|
+
spokeLiq: spokeLiqFormatters
|
|
4955
|
+
};
|
|
4956
|
+
function formatV4Value(section, key, value, ctx) {
|
|
4957
|
+
const formatter = formattersMap[section][key];
|
|
4958
|
+
if (formatter) return formatter(value, ctx);
|
|
4959
|
+
if (typeof value === "boolean") return boolToMarkdown(value);
|
|
4960
|
+
if (typeof value === "number") return value.toLocaleString("en-US");
|
|
4961
|
+
if (isAddress(value)) return addressLink(value, ctx.chainId);
|
|
4962
|
+
if (typeof value === "string" && /^-?\d+$/.test(value)) return formatBigIntWithExp(BigInt(value));
|
|
4963
|
+
return String(value);
|
|
4964
|
+
}
|
|
4965
|
+
|
|
4966
|
+
//#endregion
|
|
4967
|
+
//#region sections/spoke-reserves.ts
|
|
4968
|
+
/** All fields in display order. Every field is compared — even identity fields
|
|
4969
|
+
* that "shouldn't" change — so unexpected mutations are never silently missed. */
|
|
4970
|
+
const FIELD_ORDER$3 = [
|
|
4971
|
+
"symbol",
|
|
4972
|
+
"underlying",
|
|
4973
|
+
"hub",
|
|
4974
|
+
"assetId",
|
|
4975
|
+
"decimals",
|
|
4976
|
+
"collateralRisk",
|
|
4977
|
+
"paused",
|
|
4978
|
+
"frozen",
|
|
4979
|
+
"borrowable",
|
|
4980
|
+
"receiveSharesEnabled",
|
|
4981
|
+
"dynamicConfigKey",
|
|
4982
|
+
"collateralFactor",
|
|
4983
|
+
"maxLiquidationBonus",
|
|
4984
|
+
"liquidationFee",
|
|
4985
|
+
"oracleAddress",
|
|
4986
|
+
"priceSource",
|
|
4987
|
+
"oraclePrice"
|
|
4988
|
+
];
|
|
4989
|
+
function reserveHeader(reserve, spokeAddr, reserveId, chainId) {
|
|
4990
|
+
const client = (0, _bgd_labs_toolbox.getClient)(chainId, {});
|
|
4991
|
+
const underlyingLink = toAddressLink(reserve.underlying, true, client);
|
|
4992
|
+
const spokeLink = toAddressLink(spokeAddr, true, client);
|
|
4993
|
+
return `### ${reserve.symbol} (${underlyingLink}) on Spoke ${spokeLink} [reserveId: ${reserveId}]\n\n`;
|
|
4994
|
+
}
|
|
4995
|
+
function renderNewReserve(reserve, spokeAddr, reserveId, ctx) {
|
|
4996
|
+
let md = reserveHeader(reserve, spokeAddr, reserveId, ctx.chainId);
|
|
4997
|
+
md += "**NEW RESERVE**\n\n";
|
|
4998
|
+
md += "| description | value |\n| --- | --- |\n";
|
|
4999
|
+
for (const key of FIELD_ORDER$3) md += `| ${key} | ${formatV4Value("spokeReserve", key, reserve[key], ctx)} |\n`;
|
|
5000
|
+
return md + "\n";
|
|
5001
|
+
}
|
|
5002
|
+
function renderReserveDiff(before, after, spokeAddr, reserveId, ctx) {
|
|
5003
|
+
const rows = [];
|
|
5004
|
+
for (const key of FIELD_ORDER$3) {
|
|
5005
|
+
const bVal = before[key];
|
|
5006
|
+
const aVal = after[key];
|
|
5007
|
+
if (String(bVal) === String(aVal)) continue;
|
|
5008
|
+
const fromFmt = formatV4Value("spokeReserve", key, bVal, ctx);
|
|
5009
|
+
const toFmt = formatV4Value("spokeReserve", key, aVal, ctx);
|
|
5010
|
+
rows.push(`| ${key} | ${fromFmt} | ${toFmt} |`);
|
|
5011
|
+
}
|
|
5012
|
+
if (rows.length === 0) return "";
|
|
5013
|
+
let md = reserveHeader(after, spokeAddr, reserveId, ctx.chainId);
|
|
5014
|
+
md += "| description | value before | value after |\n| --- | --- | --- |\n";
|
|
5015
|
+
md += rows.join("\n") + "\n";
|
|
5016
|
+
return md + "\n";
|
|
5017
|
+
}
|
|
5018
|
+
function renderSpokeReservesSection(before, after) {
|
|
5019
|
+
const ctx = { chainId: after.chainId };
|
|
5020
|
+
const allSpokeAddrs = new Set([...Object.keys(before.spokeReserves), ...Object.keys(after.spokeReserves)]);
|
|
5021
|
+
let body = "";
|
|
5022
|
+
for (const spokeAddr of allSpokeAddrs) {
|
|
5023
|
+
const beforeSpoke = before.spokeReserves[spokeAddr] ?? {};
|
|
5024
|
+
const afterSpoke = after.spokeReserves[spokeAddr] ?? {};
|
|
5025
|
+
const allReserveIds = new Set([...Object.keys(beforeSpoke), ...Object.keys(afterSpoke)]);
|
|
5026
|
+
for (const reserveId of allReserveIds) {
|
|
5027
|
+
const bRes = beforeSpoke[reserveId];
|
|
5028
|
+
const aRes = afterSpoke[reserveId];
|
|
5029
|
+
if (bRes && aRes) body += renderReserveDiff(bRes, aRes, spokeAddr, reserveId, ctx);
|
|
5030
|
+
else if (aRes) body += renderNewReserve(aRes, spokeAddr, reserveId, ctx);
|
|
5031
|
+
else if (bRes) body += reserveHeader(bRes, spokeAddr, reserveId, ctx.chainId) + "**REMOVED**\n\n";
|
|
5032
|
+
}
|
|
5033
|
+
}
|
|
5034
|
+
if (!body) return "";
|
|
5035
|
+
return `## Spoke Reserve Changes\n\n${body}`;
|
|
5036
|
+
}
|
|
5037
|
+
|
|
5038
|
+
//#endregion
|
|
5039
|
+
//#region sections/hub-assets.ts
|
|
5040
|
+
/** All fields in display order. Every field is compared — even identity fields
|
|
5041
|
+
* that "shouldn't" change — so unexpected mutations are never silently missed. */
|
|
5042
|
+
const FIELD_ORDER$2 = [
|
|
5043
|
+
"symbol",
|
|
5044
|
+
"underlying",
|
|
5045
|
+
"decimals",
|
|
5046
|
+
"liquidityFee",
|
|
5047
|
+
"irStrategy",
|
|
5048
|
+
"feeReceiver",
|
|
5049
|
+
"reinvestmentController",
|
|
5050
|
+
"optimalUsageRatio",
|
|
5051
|
+
"baseDrawnRate",
|
|
5052
|
+
"rateGrowthBeforeOptimal",
|
|
5053
|
+
"rateGrowthAfterOptimal",
|
|
5054
|
+
"maxDrawnRate",
|
|
5055
|
+
"deficitRay",
|
|
5056
|
+
"swept",
|
|
5057
|
+
"premiumShares",
|
|
5058
|
+
"premiumOffsetRay"
|
|
5059
|
+
];
|
|
5060
|
+
function hubAssetHeader(asset, hubAddr, assetId, chainId) {
|
|
5061
|
+
const hubLink = toAddressLink(hubAddr, true, (0, _bgd_labs_toolbox.getClient)(chainId, {}));
|
|
5062
|
+
return `### ${asset.symbol} (assetId: ${assetId}) on Hub ${hubLink}\n\n`;
|
|
5063
|
+
}
|
|
5064
|
+
function renderNewHubAsset(asset, hubAddr, assetId, ctx) {
|
|
5065
|
+
let md = hubAssetHeader(asset, hubAddr, assetId, ctx.chainId);
|
|
5066
|
+
md += "**NEW ASSET**\n\n";
|
|
5067
|
+
md += "| description | value |\n| --- | --- |\n";
|
|
5068
|
+
for (const key of FIELD_ORDER$2) md += `| ${key} | ${formatV4Value("hubAsset", key, asset[key], ctx)} |\n`;
|
|
5069
|
+
return md + "\n";
|
|
5070
|
+
}
|
|
5071
|
+
function renderHubAssetDiff(before, after, hubAddr, assetId, ctx) {
|
|
5072
|
+
const rows = [];
|
|
5073
|
+
for (const key of FIELD_ORDER$2) {
|
|
5074
|
+
const bVal = before[key];
|
|
5075
|
+
const aVal = after[key];
|
|
5076
|
+
if (String(bVal) === String(aVal)) continue;
|
|
5077
|
+
const fromFmt = formatV4Value("hubAsset", key, bVal, ctx);
|
|
5078
|
+
const toFmt = formatV4Value("hubAsset", key, aVal, ctx);
|
|
5079
|
+
rows.push(`| ${key} | ${fromFmt} | ${toFmt} |`);
|
|
5080
|
+
}
|
|
5081
|
+
if (rows.length === 0) return "";
|
|
5082
|
+
let md = hubAssetHeader(after, hubAddr, assetId, ctx.chainId);
|
|
5083
|
+
md += "| description | value before | value after |\n| --- | --- | --- |\n";
|
|
5084
|
+
md += rows.join("\n") + "\n";
|
|
5085
|
+
return md + "\n";
|
|
5086
|
+
}
|
|
5087
|
+
function renderHubAssetsSection(before, after) {
|
|
5088
|
+
const ctx = { chainId: after.chainId };
|
|
5089
|
+
const allHubAddrs = new Set([...Object.keys(before.hubAssets), ...Object.keys(after.hubAssets)]);
|
|
5090
|
+
let body = "";
|
|
5091
|
+
for (const hubAddr of allHubAddrs) {
|
|
5092
|
+
const beforeHub = before.hubAssets[hubAddr] ?? {};
|
|
5093
|
+
const afterHub = after.hubAssets[hubAddr] ?? {};
|
|
5094
|
+
const allAssetIds = new Set([...Object.keys(beforeHub), ...Object.keys(afterHub)]);
|
|
5095
|
+
for (const assetId of allAssetIds) {
|
|
5096
|
+
const bAsset = beforeHub[assetId];
|
|
5097
|
+
const aAsset = afterHub[assetId];
|
|
5098
|
+
if (bAsset && aAsset) body += renderHubAssetDiff(bAsset, aAsset, hubAddr, assetId, ctx);
|
|
5099
|
+
else if (aAsset) body += renderNewHubAsset(aAsset, hubAddr, assetId, ctx);
|
|
5100
|
+
else if (bAsset) body += hubAssetHeader(bAsset, hubAddr, assetId, ctx.chainId) + "**REMOVED**\n\n";
|
|
5101
|
+
}
|
|
5102
|
+
}
|
|
5103
|
+
if (!body) return "";
|
|
5104
|
+
return `## Hub Asset Changes\n\n${body}`;
|
|
5105
|
+
}
|
|
5106
|
+
|
|
5107
|
+
//#endregion
|
|
5108
|
+
//#region sections/spoke-configs.ts
|
|
5109
|
+
/** All fields in display order. Every field is compared */
|
|
5110
|
+
const FIELD_ORDER$1 = [
|
|
5111
|
+
"assetSymbol",
|
|
5112
|
+
"addCap",
|
|
5113
|
+
"drawCap",
|
|
5114
|
+
"riskPremiumThreshold",
|
|
5115
|
+
"active",
|
|
5116
|
+
"halted"
|
|
5117
|
+
];
|
|
5118
|
+
/**
|
|
5119
|
+
* Parse the composite key "hubAddr_assetId_spokeAddr".
|
|
5120
|
+
*/
|
|
5121
|
+
function parseConfigKey(key) {
|
|
5122
|
+
const hubAddr = key.slice(0, 42);
|
|
5123
|
+
const rest = key.slice(43);
|
|
5124
|
+
const underscoreIdx = rest.indexOf("_");
|
|
5125
|
+
return {
|
|
5126
|
+
hubAddr,
|
|
5127
|
+
assetId: rest.slice(0, underscoreIdx),
|
|
5128
|
+
spokeAddr: rest.slice(underscoreIdx + 1)
|
|
5129
|
+
};
|
|
5130
|
+
}
|
|
5131
|
+
function configHeader(cfg, hubAddr, assetId, spokeAddr, chainId) {
|
|
5132
|
+
const client = (0, _bgd_labs_toolbox.getClient)(chainId, {});
|
|
5133
|
+
const hubLink = toAddressLink(hubAddr, true, client);
|
|
5134
|
+
const spokeLink = toAddressLink(spokeAddr, true, client);
|
|
5135
|
+
return `### ${cfg.assetSymbol} (assetId: ${assetId}) on Hub ${hubLink} / Spoke ${spokeLink}\n\n`;
|
|
5136
|
+
}
|
|
5137
|
+
function renderNewConfig(cfg, hubAddr, assetId, spokeAddr, ctx) {
|
|
5138
|
+
const cfgCtx = {
|
|
5139
|
+
...ctx,
|
|
5140
|
+
spokeConfig: cfg
|
|
5141
|
+
};
|
|
5142
|
+
let md = configHeader(cfg, hubAddr, assetId, spokeAddr, ctx.chainId);
|
|
5143
|
+
md += "**NEW SPOKE**\n\n";
|
|
5144
|
+
md += "| description | value |\n| --- | --- |\n";
|
|
5145
|
+
for (const key of FIELD_ORDER$1) md += `| ${key} | ${formatV4Value("spokeConfig", key, cfg[key], cfgCtx)} |\n`;
|
|
5146
|
+
return md + "\n";
|
|
5147
|
+
}
|
|
5148
|
+
function renderConfigDiff(before, after, hubAddr, assetId, spokeAddr, ctx) {
|
|
5149
|
+
const cfgCtx = {
|
|
5150
|
+
...ctx,
|
|
5151
|
+
spokeConfig: after
|
|
5152
|
+
};
|
|
5153
|
+
const rows = [];
|
|
5154
|
+
for (const key of FIELD_ORDER$1) {
|
|
5155
|
+
const bVal = before[key];
|
|
5156
|
+
const aVal = after[key];
|
|
5157
|
+
if (String(bVal) === String(aVal)) continue;
|
|
5158
|
+
const fromFmt = formatV4Value("spokeConfig", key, bVal, cfgCtx);
|
|
5159
|
+
const toFmt = formatV4Value("spokeConfig", key, aVal, cfgCtx);
|
|
5160
|
+
rows.push(`| ${key} | ${fromFmt} | ${toFmt} |`);
|
|
5161
|
+
}
|
|
5162
|
+
if (rows.length === 0) return "";
|
|
5163
|
+
let md = configHeader(after, hubAddr, assetId, spokeAddr, ctx.chainId);
|
|
5164
|
+
md += "| description | value before | value after |\n| --- | --- | --- |\n";
|
|
5165
|
+
md += rows.join("\n") + "\n";
|
|
5166
|
+
return md + "\n";
|
|
5167
|
+
}
|
|
5168
|
+
function renderSpokeConfigsSection(before, after) {
|
|
5169
|
+
const ctx = { chainId: after.chainId };
|
|
5170
|
+
const allKeys = new Set([...Object.keys(before.spokeConfigs), ...Object.keys(after.spokeConfigs)]);
|
|
5171
|
+
let body = "";
|
|
5172
|
+
for (const key of allKeys) {
|
|
5173
|
+
const { hubAddr, assetId, spokeAddr } = parseConfigKey(key);
|
|
5174
|
+
const bCfg = before.spokeConfigs[key];
|
|
5175
|
+
const aCfg = after.spokeConfigs[key];
|
|
5176
|
+
if (bCfg && aCfg) body += renderConfigDiff(bCfg, aCfg, hubAddr, assetId, spokeAddr, ctx);
|
|
5177
|
+
else if (aCfg) body += renderNewConfig(aCfg, hubAddr, assetId, spokeAddr, ctx);
|
|
5178
|
+
else if (bCfg) body += configHeader(bCfg, hubAddr, assetId, spokeAddr, ctx.chainId) + "**REMOVED**\n\n";
|
|
5179
|
+
}
|
|
5180
|
+
if (!body) return "";
|
|
5181
|
+
return `## Hub Spoke Config Changes\n\n${body}`;
|
|
5182
|
+
}
|
|
5183
|
+
|
|
5184
|
+
//#endregion
|
|
5185
|
+
//#region sections/spoke-liquidation.ts
|
|
5186
|
+
/** All fields in display order (this section already covers every field). */
|
|
5187
|
+
const FIELD_ORDER = [
|
|
5188
|
+
"targetHealthFactor",
|
|
5189
|
+
"healthFactorForMaxBonus",
|
|
5190
|
+
"liquidationBonusFactor",
|
|
5191
|
+
"maxUserReservesLimit"
|
|
5192
|
+
];
|
|
5193
|
+
function spokeHeader(spokeAddr, chainId) {
|
|
5194
|
+
return `### Spoke ${toAddressLink(spokeAddr, true, (0, _bgd_labs_toolbox.getClient)(chainId, {}))}\n\n`;
|
|
5195
|
+
}
|
|
5196
|
+
function renderNewSpokeLiq(config, spokeAddr, ctx) {
|
|
5197
|
+
let md = spokeHeader(spokeAddr, ctx.chainId);
|
|
5198
|
+
md += "**NEW**\n\n";
|
|
5199
|
+
md += "| description | value |\n| --- | --- |\n";
|
|
5200
|
+
for (const key of FIELD_ORDER) md += `| ${key} | ${formatV4Value("spokeLiq", key, config[key], ctx)} |\n`;
|
|
5201
|
+
return md + "\n";
|
|
5202
|
+
}
|
|
5203
|
+
function renderSpokeLiqDiff(before, after, spokeAddr, ctx) {
|
|
5204
|
+
const rows = [];
|
|
5205
|
+
for (const key of FIELD_ORDER) {
|
|
5206
|
+
const bVal = before[key];
|
|
5207
|
+
const aVal = after[key];
|
|
5208
|
+
if (String(bVal) === String(aVal)) continue;
|
|
5209
|
+
const fromFmt = formatV4Value("spokeLiq", key, bVal, ctx);
|
|
5210
|
+
const toFmt = formatV4Value("spokeLiq", key, aVal, ctx);
|
|
5211
|
+
rows.push(`| ${key} | ${fromFmt} | ${toFmt} |`);
|
|
5212
|
+
}
|
|
5213
|
+
if (rows.length === 0) return "";
|
|
5214
|
+
let md = spokeHeader(spokeAddr, ctx.chainId);
|
|
5215
|
+
md += "| description | value before | value after |\n| --- | --- | --- |\n";
|
|
5216
|
+
md += rows.join("\n") + "\n";
|
|
5217
|
+
return md + "\n";
|
|
5218
|
+
}
|
|
5219
|
+
function renderSpokeLiquidationSection(before, after) {
|
|
5220
|
+
const ctx = { chainId: after.chainId };
|
|
5221
|
+
const allSpokeAddrs = new Set([...Object.keys(before.spokeLiquidationConfigs), ...Object.keys(after.spokeLiquidationConfigs)]);
|
|
5222
|
+
let body = "";
|
|
5223
|
+
for (const spokeAddr of allSpokeAddrs) {
|
|
5224
|
+
const bConfig = before.spokeLiquidationConfigs[spokeAddr];
|
|
5225
|
+
const aConfig = after.spokeLiquidationConfigs[spokeAddr];
|
|
5226
|
+
if (bConfig && aConfig) body += renderSpokeLiqDiff(bConfig, aConfig, spokeAddr, ctx);
|
|
5227
|
+
else if (aConfig) body += renderNewSpokeLiq(aConfig, spokeAddr, ctx);
|
|
5228
|
+
else if (bConfig) body += spokeHeader(spokeAddr, ctx.chainId) + "**REMOVED**\n\n";
|
|
5229
|
+
}
|
|
5230
|
+
if (!body) return "";
|
|
5231
|
+
return `## Spoke Liquidation Config Changes\n\n${body}`;
|
|
5232
|
+
}
|
|
5233
|
+
|
|
5234
|
+
//#endregion
|
|
5235
|
+
//#region protocol-diff-v4.ts
|
|
5236
|
+
/**
|
|
5237
|
+
* Diff two Aave V4 protocol snapshots and produce a formatted markdown report.
|
|
5238
|
+
*
|
|
5239
|
+
* The `raw` and `logs` sections only exist in the "after" snapshot and are
|
|
5240
|
+
* rendered as-is (they already represent the diff / changes).
|
|
5241
|
+
*/
|
|
5242
|
+
async function diffV4Snapshots(before, after) {
|
|
5243
|
+
let raw;
|
|
5244
|
+
let logs;
|
|
5245
|
+
const postCopy = { ...after };
|
|
5246
|
+
if (postCopy.raw) {
|
|
5247
|
+
raw = postCopy.raw;
|
|
5248
|
+
delete postCopy.raw;
|
|
5249
|
+
}
|
|
5250
|
+
if (postCopy.logs) {
|
|
5251
|
+
logs = [...postCopy.logs];
|
|
5252
|
+
delete postCopy.logs;
|
|
5253
|
+
}
|
|
5254
|
+
let md = "";
|
|
5255
|
+
md += renderSpokeReservesSection(before, postCopy);
|
|
5256
|
+
md += renderHubAssetsSection(before, postCopy);
|
|
5257
|
+
md += renderSpokeConfigsSection(before, postCopy);
|
|
5258
|
+
md += renderSpokeLiquidationSection(before, postCopy);
|
|
5259
|
+
md += await renderLogsSection(logs, after.chainId);
|
|
5260
|
+
md += renderRawSection(raw, after.chainId);
|
|
5261
|
+
const preCopy = { ...before };
|
|
5262
|
+
delete preCopy.raw;
|
|
5263
|
+
delete preCopy.logs;
|
|
5264
|
+
const diffWithoutUnchanged = diff(preCopy, postCopy, true);
|
|
5265
|
+
md += `## Raw diff\n\n\`\`\`json\n${JSON.stringify(diffWithoutUnchanged, null, 2)}\n\`\`\`\n`;
|
|
5266
|
+
if (!md.trim() || md.trim() === "## Raw diff\n\n```json\n{}\n```") return "No configuration changes detected.\n";
|
|
5267
|
+
return md;
|
|
5268
|
+
}
|
|
5269
|
+
|
|
4640
5270
|
//#endregion
|
|
4641
5271
|
Object.defineProperty(exports, '__toESM', {
|
|
4642
5272
|
enumerable: true,
|
|
@@ -4656,6 +5286,12 @@ Object.defineProperty(exports, 'diffSnapshots', {
|
|
|
4656
5286
|
return diffSnapshots;
|
|
4657
5287
|
}
|
|
4658
5288
|
});
|
|
5289
|
+
Object.defineProperty(exports, 'diffV4Snapshots', {
|
|
5290
|
+
enumerable: true,
|
|
5291
|
+
get: function () {
|
|
5292
|
+
return diffV4Snapshots;
|
|
5293
|
+
}
|
|
5294
|
+
});
|
|
4659
5295
|
Object.defineProperty(exports, 'eventDb', {
|
|
4660
5296
|
enumerable: true,
|
|
4661
5297
|
get: function () {
|