@aave-dao/aave-helpers-js 1.0.14 → 1.2.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.
@@ -71,13 +71,13 @@ function boolToMarkdown(value) {
71
71
 
72
72
  //#endregion
73
73
  //#region formatters.ts
74
- function getExplorerClient(chainId) {
74
+ function getExplorerClient$1(chainId) {
75
75
  return getClient(chainId, {});
76
76
  }
77
- function addressLink(value, chainId) {
78
- return toAddressLink(value, true, getExplorerClient(chainId));
77
+ function addressLink$1(value, chainId) {
78
+ return toAddressLink(value, true, getExplorerClient$1(chainId));
79
79
  }
80
- function isAddress(value) {
80
+ function isAddress$1(value) {
81
81
  return typeof value === "string" && /^0x[0-9a-fA-F]{40}$/.test(value);
82
82
  }
83
83
  const RESERVE_PERCENTAGE_FIELDS = [
@@ -127,7 +127,7 @@ reserveFormatters["oracleLatestAnswer"] = (value, ctx) => {
127
127
  const decimals = ctx.reserve?.oracleDecimals ?? 8;
128
128
  return formatUnits(BigInt(value), decimals) + " $";
129
129
  };
130
- for (const field of RESERVE_ADDRESS_FIELDS) reserveFormatters[field] = (value, ctx) => addressLink(value, ctx.chainId);
130
+ for (const field of RESERVE_ADDRESS_FIELDS) reserveFormatters[field] = (value, ctx) => addressLink$1(value, ctx.chainId);
131
131
  for (const field of RESERVE_BOOL_FIELDS) reserveFormatters[field] = (value) => boolToMarkdown(value);
132
132
  const STRATEGY_RATE_FIELDS = [
133
133
  "baseVariableBorrowRate",
@@ -138,7 +138,7 @@ const STRATEGY_RATE_FIELDS = [
138
138
  ];
139
139
  const strategyFormatters = {};
140
140
  for (const field of STRATEGY_RATE_FIELDS) strategyFormatters[field] = (value) => `${formatUnits(BigInt(value), 25)} %`;
141
- strategyFormatters["address"] = (value, ctx) => addressLink(value, ctx.chainId);
141
+ strategyFormatters["address"] = (value, ctx) => addressLink$1(value, ctx.chainId);
142
142
  const emodeFormatters = {};
143
143
  emodeFormatters["ltv"] = (value) => `${formatUnits(BigInt(value), 2)} %`;
144
144
  emodeFormatters["liquidationThreshold"] = (value) => `${formatUnits(BigInt(value), 2)} %`;
@@ -153,18 +153,18 @@ emodeFormatters["borrowableBitmap"] = (value, ctx) => {
153
153
  }).join(", ");
154
154
  };
155
155
  emodeFormatters["collateralBitmap"] = emodeFormatters["borrowableBitmap"];
156
- emodeFormatters["priceSource"] = (value, ctx) => addressLink(value, ctx.chainId);
157
- const formattersMap = {
156
+ emodeFormatters["priceSource"] = (value, ctx) => addressLink$1(value, ctx.chainId);
157
+ const formattersMap$1 = {
158
158
  reserve: reserveFormatters,
159
159
  strategy: strategyFormatters,
160
160
  emode: emodeFormatters
161
161
  };
162
162
  function formatValue$1(section, key, value, ctx) {
163
- const formatter = formattersMap[section][key];
163
+ const formatter = formattersMap$1[section][key];
164
164
  if (formatter) return formatter(value, ctx);
165
165
  if (typeof value === "boolean") return boolToMarkdown(value);
166
166
  if (typeof value === "number") return value.toLocaleString("en-US");
167
- if (isAddress(value)) return addressLink(value, ctx.chainId);
167
+ if (isAddress$1(value)) return addressLink$1(value, ctx.chainId);
168
168
  return String(value);
169
169
  }
170
170
 
@@ -4727,106 +4727,2546 @@ const eventDb = [
4727
4727
  }],
4728
4728
  name: "WithdrawAddressSet",
4729
4729
  type: "event"
4730
- }
4731
- ];
4732
-
4733
- //#endregion
4734
- //#region sections/logs.ts
4735
- async function renderLogsSection(logs, chainId) {
4736
- if (!logs || !logs.length) return "";
4737
- const parsed = parseLogs({
4738
- logs: logs.map((log) => ({
4739
- topics: log.topics,
4740
- data: log.data,
4741
- address: log.emitter
4742
- })),
4743
- eventDb
4744
- });
4745
- const entries = (await enhanceLogs(getClient(chainId, {}), parsed)).map((log, i) => {
4746
- const emitter = logs[i].emitter;
4747
- let event;
4748
- if (log.eventName) {
4749
- const args = log.args ? formatArgs(log.args) : "";
4750
- event = `${log.eventName}(${args})`;
4751
- } else event = `topics: ${logs[i].topics.map((t) => `\`${t}\``).join(", ")}, data: \`${logs[i].data.length > 66 ? `${logs[i].data.slice(0, 66)}...` : logs[i].data}\``;
4752
- return {
4753
- emitter,
4754
- event,
4755
- index: i
4756
- };
4757
- });
4758
- const grouped = /* @__PURE__ */ new Map();
4759
- for (const entry of entries) {
4760
- let group = grouped.get(entry.emitter);
4761
- if (!group) {
4762
- group = {
4763
- emitter: entry.emitter,
4764
- events: []
4765
- };
4766
- grouped.set(entry.emitter, group);
4767
- }
4768
- group.events.push({
4769
- index: entry.index,
4770
- event: entry.event
4771
- });
4772
- }
4773
- let md = "## Event logs\n\n";
4774
- for (const group of grouped.values()) {
4775
- const knownName = isKnownAddress(group.emitter, chainId);
4776
- const label = knownName ? knownName.join(", ") : null;
4777
- const heading = label ? `${group.emitter} (${label})` : group.emitter;
4778
- md += `#### ${heading}\n\n`;
4779
- md += "| index | event |\n| --- | --- |\n";
4780
- for (const entry of group.events) md += `| ${entry.index} | ${entry.event} |\n`;
4781
- md += "\n";
4782
- }
4783
- return md;
4784
- }
4785
- function formatArgs(args) {
4786
- if (Array.isArray(args)) return args.map((v) => formatValue(v)).join(", ");
4787
- if (typeof args === "object" && args !== null) return Object.entries(args).map(([k, v]) => `${k}: ${formatValue(v)}`).join(", ");
4788
- return String(args);
4789
- }
4790
- function formatValue(v) {
4791
- if (typeof v === "bigint") return v.toString();
4792
- if (typeof v === "string") return v;
4793
- if (typeof v === "boolean") return String(v);
4794
- if (Array.isArray(v)) return `[${v.map(formatValue).join(", ")}]`;
4795
- if (typeof v === "object" && v !== null) return `{${Object.entries(v).map(([k, val]) => `${k}: ${formatValue(val)}`).join(", ")}}`;
4796
- return String(v);
4797
- }
4798
-
4799
- //#endregion
4800
- //#region protocol-diff.ts
4801
- /**
4802
- * Diff two Aave V3 protocol snapshots and produce a formatted markdown report.
4803
- *
4804
- * The `raw` and `logs` sections only exist in the "after" snapshot and are
4805
- * rendered as-is (they already represent the diff / changes).
4806
- */
4807
- async function diffSnapshots(before, after) {
4808
- let raw;
4809
- let logs;
4810
- const postCopy = { ...after };
4811
- if (postCopy.raw) {
4812
- raw = postCopy.raw;
4813
- delete postCopy.raw;
4814
- }
4815
- if (postCopy.logs) {
4816
- logs = [...postCopy.logs];
4817
- delete postCopy.logs;
4818
- }
4819
- const diffResult = diff(before, postCopy);
4820
- let md = "";
4821
- md += renderReservesSection(diffResult, before, after);
4822
- md += renderEmodesSection(diffResult, before, after);
4823
- md += renderPoolConfigSection(diffResult, after.chainId);
4824
- md += await renderLogsSection(logs, after.chainId);
4825
- md += renderRawSection(raw, after.chainId);
4826
- const diffWithoutUnchanged = diff(before, postCopy, true);
4730
+ },
4731
+ {
4732
+ anonymous: false,
4733
+ inputs: [{
4734
+ indexed: true,
4735
+ internalType: "bytes32",
4736
+ name: "operationId",
4737
+ type: "bytes32"
4738
+ }, {
4739
+ indexed: true,
4740
+ internalType: "uint32",
4741
+ name: "nonce",
4742
+ type: "uint32"
4743
+ }],
4744
+ name: "OperationCanceled",
4745
+ type: "event"
4746
+ },
4747
+ {
4748
+ anonymous: false,
4749
+ inputs: [{
4750
+ indexed: true,
4751
+ internalType: "bytes32",
4752
+ name: "operationId",
4753
+ type: "bytes32"
4754
+ }, {
4755
+ indexed: true,
4756
+ internalType: "uint32",
4757
+ name: "nonce",
4758
+ type: "uint32"
4759
+ }],
4760
+ name: "OperationExecuted",
4761
+ type: "event"
4762
+ },
4763
+ {
4764
+ anonymous: false,
4765
+ inputs: [
4766
+ {
4767
+ indexed: true,
4768
+ internalType: "bytes32",
4769
+ name: "operationId",
4770
+ type: "bytes32"
4771
+ },
4772
+ {
4773
+ indexed: true,
4774
+ internalType: "uint32",
4775
+ name: "nonce",
4776
+ type: "uint32"
4777
+ },
4778
+ {
4779
+ indexed: false,
4780
+ internalType: "uint48",
4781
+ name: "schedule",
4782
+ type: "uint48"
4783
+ },
4784
+ {
4785
+ indexed: false,
4786
+ internalType: "address",
4787
+ name: "caller",
4788
+ type: "address"
4789
+ },
4790
+ {
4791
+ indexed: false,
4792
+ internalType: "address",
4793
+ name: "target",
4794
+ type: "address"
4795
+ },
4796
+ {
4797
+ indexed: false,
4798
+ internalType: "bytes",
4799
+ name: "data",
4800
+ type: "bytes"
4801
+ }
4802
+ ],
4803
+ name: "OperationScheduled",
4804
+ type: "event"
4805
+ },
4806
+ {
4807
+ anonymous: false,
4808
+ inputs: [{
4809
+ indexed: true,
4810
+ internalType: "uint64",
4811
+ name: "roleId",
4812
+ type: "uint64"
4813
+ }, {
4814
+ indexed: true,
4815
+ internalType: "uint64",
4816
+ name: "admin",
4817
+ type: "uint64"
4818
+ }],
4819
+ name: "RoleAdminChanged",
4820
+ type: "event"
4821
+ },
4822
+ {
4823
+ anonymous: false,
4824
+ inputs: [
4825
+ {
4826
+ indexed: true,
4827
+ internalType: "uint64",
4828
+ name: "roleId",
4829
+ type: "uint64"
4830
+ },
4831
+ {
4832
+ indexed: false,
4833
+ internalType: "uint32",
4834
+ name: "delay",
4835
+ type: "uint32"
4836
+ },
4837
+ {
4838
+ indexed: false,
4839
+ internalType: "uint48",
4840
+ name: "since",
4841
+ type: "uint48"
4842
+ }
4843
+ ],
4844
+ name: "RoleGrantDelayChanged",
4845
+ type: "event"
4846
+ },
4847
+ {
4848
+ anonymous: false,
4849
+ inputs: [
4850
+ {
4851
+ indexed: true,
4852
+ internalType: "uint64",
4853
+ name: "roleId",
4854
+ type: "uint64"
4855
+ },
4856
+ {
4857
+ indexed: true,
4858
+ internalType: "address",
4859
+ name: "account",
4860
+ type: "address"
4861
+ },
4862
+ {
4863
+ indexed: false,
4864
+ internalType: "uint32",
4865
+ name: "delay",
4866
+ type: "uint32"
4867
+ },
4868
+ {
4869
+ indexed: false,
4870
+ internalType: "uint48",
4871
+ name: "since",
4872
+ type: "uint48"
4873
+ },
4874
+ {
4875
+ indexed: false,
4876
+ internalType: "bool",
4877
+ name: "newMember",
4878
+ type: "bool"
4879
+ }
4880
+ ],
4881
+ name: "RoleGranted",
4882
+ type: "event"
4883
+ },
4884
+ {
4885
+ anonymous: false,
4886
+ inputs: [{
4887
+ indexed: true,
4888
+ internalType: "uint64",
4889
+ name: "roleId",
4890
+ type: "uint64"
4891
+ }, {
4892
+ indexed: true,
4893
+ internalType: "uint64",
4894
+ name: "guardian",
4895
+ type: "uint64"
4896
+ }],
4897
+ name: "RoleGuardianChanged",
4898
+ type: "event"
4899
+ },
4900
+ {
4901
+ anonymous: false,
4902
+ inputs: [{
4903
+ indexed: true,
4904
+ internalType: "uint64",
4905
+ name: "roleId",
4906
+ type: "uint64"
4907
+ }, {
4908
+ indexed: false,
4909
+ internalType: "string",
4910
+ name: "label",
4911
+ type: "string"
4912
+ }],
4913
+ name: "RoleLabel",
4914
+ type: "event"
4915
+ },
4916
+ {
4917
+ anonymous: false,
4918
+ inputs: [{
4919
+ indexed: true,
4920
+ internalType: "uint64",
4921
+ name: "roleId",
4922
+ type: "uint64"
4923
+ }, {
4924
+ indexed: true,
4925
+ internalType: "address",
4926
+ name: "account",
4927
+ type: "address"
4928
+ }],
4929
+ name: "RoleRevoked",
4930
+ type: "event"
4931
+ },
4932
+ {
4933
+ anonymous: false,
4934
+ inputs: [
4935
+ {
4936
+ indexed: true,
4937
+ internalType: "address",
4938
+ name: "target",
4939
+ type: "address"
4940
+ },
4941
+ {
4942
+ indexed: false,
4943
+ internalType: "uint32",
4944
+ name: "delay",
4945
+ type: "uint32"
4946
+ },
4947
+ {
4948
+ indexed: false,
4949
+ internalType: "uint48",
4950
+ name: "since",
4951
+ type: "uint48"
4952
+ }
4953
+ ],
4954
+ name: "TargetAdminDelayUpdated",
4955
+ type: "event"
4956
+ },
4957
+ {
4958
+ anonymous: false,
4959
+ inputs: [{
4960
+ indexed: true,
4961
+ internalType: "address",
4962
+ name: "target",
4963
+ type: "address"
4964
+ }, {
4965
+ indexed: false,
4966
+ internalType: "bool",
4967
+ name: "closed",
4968
+ type: "bool"
4969
+ }],
4970
+ name: "TargetClosed",
4971
+ type: "event"
4972
+ },
4973
+ {
4974
+ anonymous: false,
4975
+ inputs: [
4976
+ {
4977
+ indexed: true,
4978
+ internalType: "address",
4979
+ name: "target",
4980
+ type: "address"
4981
+ },
4982
+ {
4983
+ indexed: false,
4984
+ internalType: "bytes4",
4985
+ name: "selector",
4986
+ type: "bytes4"
4987
+ },
4988
+ {
4989
+ indexed: true,
4990
+ internalType: "uint64",
4991
+ name: "roleId",
4992
+ type: "uint64"
4993
+ }
4994
+ ],
4995
+ name: "TargetFunctionRoleUpdated",
4996
+ type: "event"
4997
+ },
4998
+ {
4999
+ anonymous: false,
5000
+ inputs: [{
5001
+ indexed: false,
5002
+ internalType: "address",
5003
+ name: "authority",
5004
+ type: "address"
5005
+ }],
5006
+ name: "AuthorityUpdated",
5007
+ type: "event"
5008
+ },
5009
+ {
5010
+ anonymous: false,
5011
+ inputs: [
5012
+ {
5013
+ indexed: true,
5014
+ internalType: "uint256",
5015
+ name: "assetId",
5016
+ type: "uint256"
5017
+ },
5018
+ {
5019
+ indexed: true,
5020
+ internalType: "address",
5021
+ name: "spoke",
5022
+ type: "address"
5023
+ },
5024
+ {
5025
+ indexed: false,
5026
+ internalType: "uint256",
5027
+ name: "shares",
5028
+ type: "uint256"
5029
+ },
5030
+ {
5031
+ indexed: false,
5032
+ internalType: "uint256",
5033
+ name: "amount",
5034
+ type: "uint256"
5035
+ }
5036
+ ],
5037
+ name: "Add",
5038
+ type: "event"
5039
+ },
5040
+ {
5041
+ anonymous: false,
5042
+ inputs: [
5043
+ {
5044
+ indexed: true,
5045
+ internalType: "uint256",
5046
+ name: "assetId",
5047
+ type: "uint256"
5048
+ },
5049
+ {
5050
+ indexed: true,
5051
+ internalType: "address",
5052
+ name: "underlying",
5053
+ type: "address"
5054
+ },
5055
+ {
5056
+ indexed: false,
5057
+ internalType: "uint8",
5058
+ name: "decimals",
5059
+ type: "uint8"
5060
+ }
5061
+ ],
5062
+ name: "AddAsset",
5063
+ type: "event"
5064
+ },
5065
+ {
5066
+ anonymous: false,
5067
+ inputs: [{
5068
+ indexed: true,
5069
+ internalType: "uint256",
5070
+ name: "assetId",
5071
+ type: "uint256"
5072
+ }, {
5073
+ indexed: true,
5074
+ internalType: "address",
5075
+ name: "spoke",
5076
+ type: "address"
5077
+ }],
5078
+ name: "AddSpoke",
5079
+ type: "event"
5080
+ },
5081
+ {
5082
+ anonymous: false,
5083
+ inputs: [
5084
+ {
5085
+ indexed: true,
5086
+ internalType: "uint256",
5087
+ name: "assetId",
5088
+ type: "uint256"
5089
+ },
5090
+ {
5091
+ indexed: true,
5092
+ internalType: "address",
5093
+ name: "spoke",
5094
+ type: "address"
5095
+ },
5096
+ {
5097
+ indexed: false,
5098
+ internalType: "uint256",
5099
+ name: "drawnShares",
5100
+ type: "uint256"
5101
+ },
5102
+ {
5103
+ indexed: false,
5104
+ internalType: "uint256",
5105
+ name: "drawnAmount",
5106
+ type: "uint256"
5107
+ }
5108
+ ],
5109
+ name: "Draw",
5110
+ type: "event"
5111
+ },
5112
+ {
5113
+ anonymous: false,
5114
+ inputs: [
5115
+ {
5116
+ indexed: true,
5117
+ internalType: "uint256",
5118
+ name: "assetId",
5119
+ type: "uint256"
5120
+ },
5121
+ {
5122
+ indexed: true,
5123
+ internalType: "address",
5124
+ name: "callerSpoke",
5125
+ type: "address"
5126
+ },
5127
+ {
5128
+ indexed: true,
5129
+ internalType: "address",
5130
+ name: "coveredSpoke",
5131
+ type: "address"
5132
+ },
5133
+ {
5134
+ indexed: false,
5135
+ internalType: "uint256",
5136
+ name: "shares",
5137
+ type: "uint256"
5138
+ },
5139
+ {
5140
+ indexed: false,
5141
+ internalType: "uint256",
5142
+ name: "deficitAmountRay",
5143
+ type: "uint256"
5144
+ }
5145
+ ],
5146
+ name: "EliminateDeficit",
5147
+ type: "event"
5148
+ },
5149
+ {
5150
+ anonymous: false,
5151
+ inputs: [
5152
+ {
5153
+ indexed: true,
5154
+ internalType: "uint256",
5155
+ name: "assetId",
5156
+ type: "uint256"
5157
+ },
5158
+ {
5159
+ indexed: true,
5160
+ internalType: "address",
5161
+ name: "feeReceiver",
5162
+ type: "address"
5163
+ },
5164
+ {
5165
+ indexed: false,
5166
+ internalType: "uint256",
5167
+ name: "shares",
5168
+ type: "uint256"
5169
+ },
5170
+ {
5171
+ indexed: false,
5172
+ internalType: "uint256",
5173
+ name: "assets",
5174
+ type: "uint256"
5175
+ }
5176
+ ],
5177
+ name: "MintFeeShares",
5178
+ type: "event"
5179
+ },
5180
+ {
5181
+ anonymous: false,
5182
+ inputs: [
5183
+ {
5184
+ indexed: true,
5185
+ internalType: "uint256",
5186
+ name: "assetId",
5187
+ type: "uint256"
5188
+ },
5189
+ {
5190
+ indexed: true,
5191
+ internalType: "address",
5192
+ name: "reinvestmentController",
5193
+ type: "address"
5194
+ },
5195
+ {
5196
+ indexed: false,
5197
+ internalType: "uint256",
5198
+ name: "amount",
5199
+ type: "uint256"
5200
+ }
5201
+ ],
5202
+ name: "Reclaim",
5203
+ type: "event"
5204
+ },
5205
+ {
5206
+ anonymous: false,
5207
+ inputs: [
5208
+ {
5209
+ indexed: true,
5210
+ internalType: "uint256",
5211
+ name: "assetId",
5212
+ type: "uint256"
5213
+ },
5214
+ {
5215
+ indexed: true,
5216
+ internalType: "address",
5217
+ name: "spoke",
5218
+ type: "address"
5219
+ },
5220
+ {
5221
+ components: [
5222
+ {
5223
+ internalType: "int256",
5224
+ name: "sharesDelta",
5225
+ type: "int256"
5226
+ },
5227
+ {
5228
+ internalType: "int256",
5229
+ name: "offsetRayDelta",
5230
+ type: "int256"
5231
+ },
5232
+ {
5233
+ internalType: "uint256",
5234
+ name: "restoredPremiumRay",
5235
+ type: "uint256"
5236
+ }
5237
+ ],
5238
+ indexed: false,
5239
+ internalType: "struct IHubBase.PremiumDelta",
5240
+ name: "premiumDelta",
5241
+ type: "tuple"
5242
+ }
5243
+ ],
5244
+ name: "RefreshPremium",
5245
+ type: "event"
5246
+ },
5247
+ {
5248
+ anonymous: false,
5249
+ inputs: [
5250
+ {
5251
+ indexed: true,
5252
+ internalType: "uint256",
5253
+ name: "assetId",
5254
+ type: "uint256"
5255
+ },
5256
+ {
5257
+ indexed: true,
5258
+ internalType: "address",
5259
+ name: "spoke",
5260
+ type: "address"
5261
+ },
5262
+ {
5263
+ indexed: false,
5264
+ internalType: "uint256",
5265
+ name: "shares",
5266
+ type: "uint256"
5267
+ },
5268
+ {
5269
+ indexed: false,
5270
+ internalType: "uint256",
5271
+ name: "amount",
5272
+ type: "uint256"
5273
+ }
5274
+ ],
5275
+ name: "Remove",
5276
+ type: "event"
5277
+ },
5278
+ {
5279
+ anonymous: false,
5280
+ inputs: [
5281
+ {
5282
+ indexed: true,
5283
+ internalType: "uint256",
5284
+ name: "assetId",
5285
+ type: "uint256"
5286
+ },
5287
+ {
5288
+ indexed: true,
5289
+ internalType: "address",
5290
+ name: "spoke",
5291
+ type: "address"
5292
+ },
5293
+ {
5294
+ indexed: false,
5295
+ internalType: "uint256",
5296
+ name: "drawnShares",
5297
+ type: "uint256"
5298
+ },
5299
+ {
5300
+ components: [
5301
+ {
5302
+ internalType: "int256",
5303
+ name: "sharesDelta",
5304
+ type: "int256"
5305
+ },
5306
+ {
5307
+ internalType: "int256",
5308
+ name: "offsetRayDelta",
5309
+ type: "int256"
5310
+ },
5311
+ {
5312
+ internalType: "uint256",
5313
+ name: "restoredPremiumRay",
5314
+ type: "uint256"
5315
+ }
5316
+ ],
5317
+ indexed: false,
5318
+ internalType: "struct IHubBase.PremiumDelta",
5319
+ name: "premiumDelta",
5320
+ type: "tuple"
5321
+ },
5322
+ {
5323
+ indexed: false,
5324
+ internalType: "uint256",
5325
+ name: "deficitAmountRay",
5326
+ type: "uint256"
5327
+ }
5328
+ ],
5329
+ name: "ReportDeficit",
5330
+ type: "event"
5331
+ },
5332
+ {
5333
+ anonymous: false,
5334
+ inputs: [
5335
+ {
5336
+ indexed: true,
5337
+ internalType: "uint256",
5338
+ name: "assetId",
5339
+ type: "uint256"
5340
+ },
5341
+ {
5342
+ indexed: true,
5343
+ internalType: "address",
5344
+ name: "spoke",
5345
+ type: "address"
5346
+ },
5347
+ {
5348
+ indexed: false,
5349
+ internalType: "uint256",
5350
+ name: "drawnShares",
5351
+ type: "uint256"
5352
+ },
5353
+ {
5354
+ components: [
5355
+ {
5356
+ internalType: "int256",
5357
+ name: "sharesDelta",
5358
+ type: "int256"
5359
+ },
5360
+ {
5361
+ internalType: "int256",
5362
+ name: "offsetRayDelta",
5363
+ type: "int256"
5364
+ },
5365
+ {
5366
+ internalType: "uint256",
5367
+ name: "restoredPremiumRay",
5368
+ type: "uint256"
5369
+ }
5370
+ ],
5371
+ indexed: false,
5372
+ internalType: "struct IHubBase.PremiumDelta",
5373
+ name: "premiumDelta",
5374
+ type: "tuple"
5375
+ },
5376
+ {
5377
+ indexed: false,
5378
+ internalType: "uint256",
5379
+ name: "drawnAmount",
5380
+ type: "uint256"
5381
+ },
5382
+ {
5383
+ indexed: false,
5384
+ internalType: "uint256",
5385
+ name: "premiumAmount",
5386
+ type: "uint256"
5387
+ }
5388
+ ],
5389
+ name: "Restore",
5390
+ type: "event"
5391
+ },
5392
+ {
5393
+ anonymous: false,
5394
+ inputs: [
5395
+ {
5396
+ indexed: true,
5397
+ internalType: "uint256",
5398
+ name: "assetId",
5399
+ type: "uint256"
5400
+ },
5401
+ {
5402
+ indexed: true,
5403
+ internalType: "address",
5404
+ name: "reinvestmentController",
5405
+ type: "address"
5406
+ },
5407
+ {
5408
+ indexed: false,
5409
+ internalType: "uint256",
5410
+ name: "amount",
5411
+ type: "uint256"
5412
+ }
5413
+ ],
5414
+ name: "Sweep",
5415
+ type: "event"
5416
+ },
5417
+ {
5418
+ anonymous: false,
5419
+ inputs: [
5420
+ {
5421
+ indexed: true,
5422
+ internalType: "uint256",
5423
+ name: "assetId",
5424
+ type: "uint256"
5425
+ },
5426
+ {
5427
+ indexed: true,
5428
+ internalType: "address",
5429
+ name: "sender",
5430
+ type: "address"
5431
+ },
5432
+ {
5433
+ indexed: true,
5434
+ internalType: "address",
5435
+ name: "receiver",
5436
+ type: "address"
5437
+ },
5438
+ {
5439
+ indexed: false,
5440
+ internalType: "uint256",
5441
+ name: "shares",
5442
+ type: "uint256"
5443
+ }
5444
+ ],
5445
+ name: "TransferShares",
5446
+ type: "event"
5447
+ },
5448
+ {
5449
+ anonymous: false,
5450
+ inputs: [
5451
+ {
5452
+ indexed: true,
5453
+ internalType: "uint256",
5454
+ name: "assetId",
5455
+ type: "uint256"
5456
+ },
5457
+ {
5458
+ indexed: false,
5459
+ internalType: "uint256",
5460
+ name: "drawnIndex",
5461
+ type: "uint256"
5462
+ },
5463
+ {
5464
+ indexed: false,
5465
+ internalType: "uint256",
5466
+ name: "drawnRate",
5467
+ type: "uint256"
5468
+ },
5469
+ {
5470
+ indexed: false,
5471
+ internalType: "uint256",
5472
+ name: "accruedFees",
5473
+ type: "uint256"
5474
+ }
5475
+ ],
5476
+ name: "UpdateAsset",
5477
+ type: "event"
5478
+ },
5479
+ {
5480
+ anonymous: false,
5481
+ inputs: [{
5482
+ indexed: true,
5483
+ internalType: "uint256",
5484
+ name: "assetId",
5485
+ type: "uint256"
5486
+ }, {
5487
+ components: [
5488
+ {
5489
+ internalType: "address",
5490
+ name: "feeReceiver",
5491
+ type: "address"
5492
+ },
5493
+ {
5494
+ internalType: "uint16",
5495
+ name: "liquidityFee",
5496
+ type: "uint16"
5497
+ },
5498
+ {
5499
+ internalType: "address",
5500
+ name: "irStrategy",
5501
+ type: "address"
5502
+ },
5503
+ {
5504
+ internalType: "address",
5505
+ name: "reinvestmentController",
5506
+ type: "address"
5507
+ }
5508
+ ],
5509
+ indexed: false,
5510
+ internalType: "struct IHub.AssetConfig",
5511
+ name: "config",
5512
+ type: "tuple"
5513
+ }],
5514
+ name: "UpdateAssetConfig",
5515
+ type: "event"
5516
+ },
5517
+ {
5518
+ anonymous: false,
5519
+ inputs: [
5520
+ {
5521
+ indexed: true,
5522
+ internalType: "uint256",
5523
+ name: "assetId",
5524
+ type: "uint256"
5525
+ },
5526
+ {
5527
+ indexed: true,
5528
+ internalType: "address",
5529
+ name: "spoke",
5530
+ type: "address"
5531
+ },
5532
+ {
5533
+ components: [
5534
+ {
5535
+ internalType: "uint40",
5536
+ name: "addCap",
5537
+ type: "uint40"
5538
+ },
5539
+ {
5540
+ internalType: "uint40",
5541
+ name: "drawCap",
5542
+ type: "uint40"
5543
+ },
5544
+ {
5545
+ internalType: "uint24",
5546
+ name: "riskPremiumThreshold",
5547
+ type: "uint24"
5548
+ },
5549
+ {
5550
+ internalType: "bool",
5551
+ name: "active",
5552
+ type: "bool"
5553
+ },
5554
+ {
5555
+ internalType: "bool",
5556
+ name: "halted",
5557
+ type: "bool"
5558
+ }
5559
+ ],
5560
+ indexed: false,
5561
+ internalType: "struct IHub.SpokeConfig",
5562
+ name: "config",
5563
+ type: "tuple"
5564
+ }
5565
+ ],
5566
+ name: "UpdateSpokeConfig",
5567
+ type: "event"
5568
+ },
5569
+ {
5570
+ anonymous: false,
5571
+ inputs: [
5572
+ {
5573
+ indexed: true,
5574
+ internalType: "uint256",
5575
+ name: "reserveId",
5576
+ type: "uint256"
5577
+ },
5578
+ {
5579
+ indexed: true,
5580
+ internalType: "uint32",
5581
+ name: "dynamicConfigKey",
5582
+ type: "uint32"
5583
+ },
5584
+ {
5585
+ components: [
5586
+ {
5587
+ internalType: "uint16",
5588
+ name: "collateralFactor",
5589
+ type: "uint16"
5590
+ },
5591
+ {
5592
+ internalType: "uint32",
5593
+ name: "maxLiquidationBonus",
5594
+ type: "uint32"
5595
+ },
5596
+ {
5597
+ internalType: "uint16",
5598
+ name: "liquidationFee",
5599
+ type: "uint16"
5600
+ }
5601
+ ],
5602
+ indexed: false,
5603
+ internalType: "struct ISpoke.DynamicReserveConfig",
5604
+ name: "config",
5605
+ type: "tuple"
5606
+ }
5607
+ ],
5608
+ name: "AddDynamicReserveConfig",
5609
+ type: "event"
5610
+ },
5611
+ {
5612
+ anonymous: false,
5613
+ inputs: [
5614
+ {
5615
+ indexed: true,
5616
+ internalType: "uint256",
5617
+ name: "reserveId",
5618
+ type: "uint256"
5619
+ },
5620
+ {
5621
+ indexed: true,
5622
+ internalType: "uint256",
5623
+ name: "assetId",
5624
+ type: "uint256"
5625
+ },
5626
+ {
5627
+ indexed: true,
5628
+ internalType: "address",
5629
+ name: "hub",
5630
+ type: "address"
5631
+ }
5632
+ ],
5633
+ name: "AddReserve",
5634
+ type: "event"
5635
+ },
5636
+ {
5637
+ anonymous: false,
5638
+ inputs: [
5639
+ {
5640
+ indexed: true,
5641
+ internalType: "uint256",
5642
+ name: "reserveId",
5643
+ type: "uint256"
5644
+ },
5645
+ {
5646
+ indexed: true,
5647
+ internalType: "address",
5648
+ name: "caller",
5649
+ type: "address"
5650
+ },
5651
+ {
5652
+ indexed: true,
5653
+ internalType: "address",
5654
+ name: "user",
5655
+ type: "address"
5656
+ },
5657
+ {
5658
+ indexed: false,
5659
+ internalType: "uint256",
5660
+ name: "drawnShares",
5661
+ type: "uint256"
5662
+ },
5663
+ {
5664
+ indexed: false,
5665
+ internalType: "uint256",
5666
+ name: "drawnAmount",
5667
+ type: "uint256"
5668
+ }
5669
+ ],
5670
+ name: "Borrow",
5671
+ type: "event"
5672
+ },
5673
+ {
5674
+ anonymous: false,
5675
+ inputs: [
5676
+ {
5677
+ indexed: true,
5678
+ internalType: "uint256",
5679
+ name: "collateralReserveId",
5680
+ type: "uint256"
5681
+ },
5682
+ {
5683
+ indexed: true,
5684
+ internalType: "uint256",
5685
+ name: "debtReserveId",
5686
+ type: "uint256"
5687
+ },
5688
+ {
5689
+ indexed: true,
5690
+ internalType: "address",
5691
+ name: "user",
5692
+ type: "address"
5693
+ },
5694
+ {
5695
+ indexed: false,
5696
+ internalType: "address",
5697
+ name: "liquidator",
5698
+ type: "address"
5699
+ },
5700
+ {
5701
+ indexed: false,
5702
+ internalType: "bool",
5703
+ name: "receiveShares",
5704
+ type: "bool"
5705
+ },
5706
+ {
5707
+ indexed: false,
5708
+ internalType: "uint256",
5709
+ name: "debtAmountRestored",
5710
+ type: "uint256"
5711
+ },
5712
+ {
5713
+ indexed: false,
5714
+ internalType: "uint256",
5715
+ name: "drawnSharesLiquidated",
5716
+ type: "uint256"
5717
+ },
5718
+ {
5719
+ components: [
5720
+ {
5721
+ internalType: "int256",
5722
+ name: "sharesDelta",
5723
+ type: "int256"
5724
+ },
5725
+ {
5726
+ internalType: "int256",
5727
+ name: "offsetRayDelta",
5728
+ type: "int256"
5729
+ },
5730
+ {
5731
+ internalType: "uint256",
5732
+ name: "restoredPremiumRay",
5733
+ type: "uint256"
5734
+ }
5735
+ ],
5736
+ indexed: false,
5737
+ internalType: "struct IHubBase.PremiumDelta",
5738
+ name: "premiumDelta",
5739
+ type: "tuple"
5740
+ },
5741
+ {
5742
+ indexed: false,
5743
+ internalType: "uint256",
5744
+ name: "collateralAmountRemoved",
5745
+ type: "uint256"
5746
+ },
5747
+ {
5748
+ indexed: false,
5749
+ internalType: "uint256",
5750
+ name: "collateralSharesLiquidated",
5751
+ type: "uint256"
5752
+ },
5753
+ {
5754
+ indexed: false,
5755
+ internalType: "uint256",
5756
+ name: "collateralSharesToLiquidator",
5757
+ type: "uint256"
5758
+ }
5759
+ ],
5760
+ name: "LiquidationCall",
5761
+ type: "event"
5762
+ },
5763
+ {
5764
+ anonymous: false,
5765
+ inputs: [{
5766
+ indexed: true,
5767
+ internalType: "address",
5768
+ name: "user",
5769
+ type: "address"
5770
+ }],
5771
+ name: "RefreshAllUserDynamicConfig",
5772
+ type: "event"
5773
+ },
5774
+ {
5775
+ anonymous: false,
5776
+ inputs: [
5777
+ {
5778
+ indexed: true,
5779
+ internalType: "uint256",
5780
+ name: "reserveId",
5781
+ type: "uint256"
5782
+ },
5783
+ {
5784
+ indexed: true,
5785
+ internalType: "address",
5786
+ name: "user",
5787
+ type: "address"
5788
+ },
5789
+ {
5790
+ components: [
5791
+ {
5792
+ internalType: "int256",
5793
+ name: "sharesDelta",
5794
+ type: "int256"
5795
+ },
5796
+ {
5797
+ internalType: "int256",
5798
+ name: "offsetRayDelta",
5799
+ type: "int256"
5800
+ },
5801
+ {
5802
+ internalType: "uint256",
5803
+ name: "restoredPremiumRay",
5804
+ type: "uint256"
5805
+ }
5806
+ ],
5807
+ indexed: false,
5808
+ internalType: "struct IHubBase.PremiumDelta",
5809
+ name: "premiumDelta",
5810
+ type: "tuple"
5811
+ }
5812
+ ],
5813
+ name: "RefreshPremiumDebt",
5814
+ type: "event"
5815
+ },
5816
+ {
5817
+ anonymous: false,
5818
+ inputs: [{
5819
+ indexed: true,
5820
+ internalType: "address",
5821
+ name: "user",
5822
+ type: "address"
5823
+ }, {
5824
+ indexed: false,
5825
+ internalType: "uint256",
5826
+ name: "reserveId",
5827
+ type: "uint256"
5828
+ }],
5829
+ name: "RefreshSingleUserDynamicConfig",
5830
+ type: "event"
5831
+ },
5832
+ {
5833
+ anonymous: false,
5834
+ inputs: [
5835
+ {
5836
+ indexed: true,
5837
+ internalType: "uint256",
5838
+ name: "reserveId",
5839
+ type: "uint256"
5840
+ },
5841
+ {
5842
+ indexed: true,
5843
+ internalType: "address",
5844
+ name: "caller",
5845
+ type: "address"
5846
+ },
5847
+ {
5848
+ indexed: true,
5849
+ internalType: "address",
5850
+ name: "user",
5851
+ type: "address"
5852
+ },
5853
+ {
5854
+ indexed: false,
5855
+ internalType: "uint256",
5856
+ name: "drawnShares",
5857
+ type: "uint256"
5858
+ },
5859
+ {
5860
+ indexed: false,
5861
+ internalType: "uint256",
5862
+ name: "totalAmountRepaid",
5863
+ type: "uint256"
5864
+ },
5865
+ {
5866
+ components: [
5867
+ {
5868
+ internalType: "int256",
5869
+ name: "sharesDelta",
5870
+ type: "int256"
5871
+ },
5872
+ {
5873
+ internalType: "int256",
5874
+ name: "offsetRayDelta",
5875
+ type: "int256"
5876
+ },
5877
+ {
5878
+ internalType: "uint256",
5879
+ name: "restoredPremiumRay",
5880
+ type: "uint256"
5881
+ }
5882
+ ],
5883
+ indexed: false,
5884
+ internalType: "struct IHubBase.PremiumDelta",
5885
+ name: "premiumDelta",
5886
+ type: "tuple"
5887
+ }
5888
+ ],
5889
+ name: "Repay",
5890
+ type: "event"
5891
+ },
5892
+ {
5893
+ anonymous: false,
5894
+ inputs: [
5895
+ {
5896
+ indexed: true,
5897
+ internalType: "uint256",
5898
+ name: "reserveId",
5899
+ type: "uint256"
5900
+ },
5901
+ {
5902
+ indexed: true,
5903
+ internalType: "address",
5904
+ name: "user",
5905
+ type: "address"
5906
+ },
5907
+ {
5908
+ indexed: false,
5909
+ internalType: "uint256",
5910
+ name: "drawnShares",
5911
+ type: "uint256"
5912
+ },
5913
+ {
5914
+ components: [
5915
+ {
5916
+ internalType: "int256",
5917
+ name: "sharesDelta",
5918
+ type: "int256"
5919
+ },
5920
+ {
5921
+ internalType: "int256",
5922
+ name: "offsetRayDelta",
5923
+ type: "int256"
5924
+ },
5925
+ {
5926
+ internalType: "uint256",
5927
+ name: "restoredPremiumRay",
5928
+ type: "uint256"
5929
+ }
5930
+ ],
5931
+ indexed: false,
5932
+ internalType: "struct IHubBase.PremiumDelta",
5933
+ name: "premiumDelta",
5934
+ type: "tuple"
5935
+ }
5936
+ ],
5937
+ name: "ReportDeficit",
5938
+ type: "event"
5939
+ },
5940
+ {
5941
+ anonymous: false,
5942
+ inputs: [{
5943
+ indexed: true,
5944
+ internalType: "address",
5945
+ name: "oracle",
5946
+ type: "address"
5947
+ }, {
5948
+ indexed: false,
5949
+ internalType: "uint16",
5950
+ name: "maxUserReservesLimit",
5951
+ type: "uint16"
5952
+ }],
5953
+ name: "SetSpokeImmutables",
5954
+ type: "event"
5955
+ },
5956
+ {
5957
+ anonymous: false,
5958
+ inputs: [
5959
+ {
5960
+ indexed: true,
5961
+ internalType: "address",
5962
+ name: "user",
5963
+ type: "address"
5964
+ },
5965
+ {
5966
+ indexed: true,
5967
+ internalType: "address",
5968
+ name: "positionManager",
5969
+ type: "address"
5970
+ },
5971
+ {
5972
+ indexed: false,
5973
+ internalType: "bool",
5974
+ name: "approve",
5975
+ type: "bool"
5976
+ }
5977
+ ],
5978
+ name: "SetUserPositionManager",
5979
+ type: "event"
5980
+ },
5981
+ {
5982
+ anonymous: false,
5983
+ inputs: [
5984
+ {
5985
+ indexed: true,
5986
+ internalType: "uint256",
5987
+ name: "reserveId",
5988
+ type: "uint256"
5989
+ },
5990
+ {
5991
+ indexed: true,
5992
+ internalType: "address",
5993
+ name: "caller",
5994
+ type: "address"
5995
+ },
5996
+ {
5997
+ indexed: true,
5998
+ internalType: "address",
5999
+ name: "user",
6000
+ type: "address"
6001
+ },
6002
+ {
6003
+ indexed: false,
6004
+ internalType: "bool",
6005
+ name: "usingAsCollateral",
6006
+ type: "bool"
6007
+ }
6008
+ ],
6009
+ name: "SetUsingAsCollateral",
6010
+ type: "event"
6011
+ },
6012
+ {
6013
+ anonymous: false,
6014
+ inputs: [
6015
+ {
6016
+ indexed: true,
6017
+ internalType: "uint256",
6018
+ name: "reserveId",
6019
+ type: "uint256"
6020
+ },
6021
+ {
6022
+ indexed: true,
6023
+ internalType: "address",
6024
+ name: "caller",
6025
+ type: "address"
6026
+ },
6027
+ {
6028
+ indexed: true,
6029
+ internalType: "address",
6030
+ name: "user",
6031
+ type: "address"
6032
+ },
6033
+ {
6034
+ indexed: false,
6035
+ internalType: "uint256",
6036
+ name: "suppliedShares",
6037
+ type: "uint256"
6038
+ },
6039
+ {
6040
+ indexed: false,
6041
+ internalType: "uint256",
6042
+ name: "suppliedAmount",
6043
+ type: "uint256"
6044
+ }
6045
+ ],
6046
+ name: "Supply",
6047
+ type: "event"
6048
+ },
6049
+ {
6050
+ anonymous: false,
6051
+ inputs: [
6052
+ {
6053
+ indexed: true,
6054
+ internalType: "uint256",
6055
+ name: "reserveId",
6056
+ type: "uint256"
6057
+ },
6058
+ {
6059
+ indexed: true,
6060
+ internalType: "uint32",
6061
+ name: "dynamicConfigKey",
6062
+ type: "uint32"
6063
+ },
6064
+ {
6065
+ components: [
6066
+ {
6067
+ internalType: "uint16",
6068
+ name: "collateralFactor",
6069
+ type: "uint16"
6070
+ },
6071
+ {
6072
+ internalType: "uint32",
6073
+ name: "maxLiquidationBonus",
6074
+ type: "uint32"
6075
+ },
6076
+ {
6077
+ internalType: "uint16",
6078
+ name: "liquidationFee",
6079
+ type: "uint16"
6080
+ }
6081
+ ],
6082
+ indexed: false,
6083
+ internalType: "struct ISpoke.DynamicReserveConfig",
6084
+ name: "config",
6085
+ type: "tuple"
6086
+ }
6087
+ ],
6088
+ name: "UpdateDynamicReserveConfig",
6089
+ type: "event"
6090
+ },
6091
+ {
6092
+ anonymous: false,
6093
+ inputs: [{
6094
+ components: [
6095
+ {
6096
+ internalType: "uint128",
6097
+ name: "targetHealthFactor",
6098
+ type: "uint128"
6099
+ },
6100
+ {
6101
+ internalType: "uint64",
6102
+ name: "healthFactorForMaxBonus",
6103
+ type: "uint64"
6104
+ },
6105
+ {
6106
+ internalType: "uint16",
6107
+ name: "liquidationBonusFactor",
6108
+ type: "uint16"
6109
+ }
6110
+ ],
6111
+ indexed: false,
6112
+ internalType: "struct ISpoke.LiquidationConfig",
6113
+ name: "config",
6114
+ type: "tuple"
6115
+ }],
6116
+ name: "UpdateLiquidationConfig",
6117
+ type: "event"
6118
+ },
6119
+ {
6120
+ anonymous: false,
6121
+ inputs: [{
6122
+ indexed: true,
6123
+ internalType: "address",
6124
+ name: "positionManager",
6125
+ type: "address"
6126
+ }, {
6127
+ indexed: false,
6128
+ internalType: "bool",
6129
+ name: "active",
6130
+ type: "bool"
6131
+ }],
6132
+ name: "UpdatePositionManager",
6133
+ type: "event"
6134
+ },
6135
+ {
6136
+ anonymous: false,
6137
+ inputs: [{
6138
+ indexed: true,
6139
+ internalType: "uint256",
6140
+ name: "reserveId",
6141
+ type: "uint256"
6142
+ }, {
6143
+ components: [
6144
+ {
6145
+ internalType: "uint24",
6146
+ name: "collateralRisk",
6147
+ type: "uint24"
6148
+ },
6149
+ {
6150
+ internalType: "bool",
6151
+ name: "paused",
6152
+ type: "bool"
6153
+ },
6154
+ {
6155
+ internalType: "bool",
6156
+ name: "frozen",
6157
+ type: "bool"
6158
+ },
6159
+ {
6160
+ internalType: "bool",
6161
+ name: "borrowable",
6162
+ type: "bool"
6163
+ },
6164
+ {
6165
+ internalType: "bool",
6166
+ name: "receiveSharesEnabled",
6167
+ type: "bool"
6168
+ }
6169
+ ],
6170
+ indexed: false,
6171
+ internalType: "struct ISpoke.ReserveConfig",
6172
+ name: "config",
6173
+ type: "tuple"
6174
+ }],
6175
+ name: "UpdateReserveConfig",
6176
+ type: "event"
6177
+ },
6178
+ {
6179
+ anonymous: false,
6180
+ inputs: [{
6181
+ indexed: true,
6182
+ internalType: "uint256",
6183
+ name: "reserveId",
6184
+ type: "uint256"
6185
+ }, {
6186
+ indexed: true,
6187
+ internalType: "address",
6188
+ name: "priceSource",
6189
+ type: "address"
6190
+ }],
6191
+ name: "UpdateReservePriceSource",
6192
+ type: "event"
6193
+ },
6194
+ {
6195
+ anonymous: false,
6196
+ inputs: [{
6197
+ indexed: true,
6198
+ internalType: "address",
6199
+ name: "user",
6200
+ type: "address"
6201
+ }, {
6202
+ indexed: false,
6203
+ internalType: "uint256",
6204
+ name: "riskPremium",
6205
+ type: "uint256"
6206
+ }],
6207
+ name: "UpdateUserRiskPremium",
6208
+ type: "event"
6209
+ },
6210
+ {
6211
+ anonymous: false,
6212
+ inputs: [
6213
+ {
6214
+ indexed: true,
6215
+ internalType: "uint256",
6216
+ name: "reserveId",
6217
+ type: "uint256"
6218
+ },
6219
+ {
6220
+ indexed: true,
6221
+ internalType: "address",
6222
+ name: "caller",
6223
+ type: "address"
6224
+ },
6225
+ {
6226
+ indexed: true,
6227
+ internalType: "address",
6228
+ name: "user",
6229
+ type: "address"
6230
+ },
6231
+ {
6232
+ indexed: false,
6233
+ internalType: "uint256",
6234
+ name: "withdrawnShares",
6235
+ type: "uint256"
6236
+ },
6237
+ {
6238
+ indexed: false,
6239
+ internalType: "uint256",
6240
+ name: "withdrawnAmount",
6241
+ type: "uint256"
6242
+ }
6243
+ ],
6244
+ name: "Withdraw",
6245
+ type: "event"
6246
+ },
6247
+ {
6248
+ anonymous: false,
6249
+ inputs: [
6250
+ {
6251
+ indexed: true,
6252
+ internalType: "address",
6253
+ name: "sender",
6254
+ type: "address"
6255
+ },
6256
+ {
6257
+ indexed: true,
6258
+ internalType: "address",
6259
+ name: "owner",
6260
+ type: "address"
6261
+ },
6262
+ {
6263
+ indexed: false,
6264
+ internalType: "uint256",
6265
+ name: "assets",
6266
+ type: "uint256"
6267
+ },
6268
+ {
6269
+ indexed: false,
6270
+ internalType: "uint256",
6271
+ name: "shares",
6272
+ type: "uint256"
6273
+ }
6274
+ ],
6275
+ name: "Deposit",
6276
+ type: "event"
6277
+ },
6278
+ {
6279
+ anonymous: false,
6280
+ inputs: [{
6281
+ indexed: true,
6282
+ internalType: "address",
6283
+ name: "hub",
6284
+ type: "address"
6285
+ }, {
6286
+ indexed: true,
6287
+ internalType: "uint256",
6288
+ name: "assetId",
6289
+ type: "uint256"
6290
+ }],
6291
+ name: "SetTokenizationSpokeImmutables",
6292
+ type: "event"
6293
+ },
6294
+ {
6295
+ anonymous: false,
6296
+ inputs: [
6297
+ {
6298
+ indexed: true,
6299
+ internalType: "address",
6300
+ name: "sender",
6301
+ type: "address"
6302
+ },
6303
+ {
6304
+ indexed: true,
6305
+ internalType: "address",
6306
+ name: "receiver",
6307
+ type: "address"
6308
+ },
6309
+ {
6310
+ indexed: true,
6311
+ internalType: "address",
6312
+ name: "owner",
6313
+ type: "address"
6314
+ },
6315
+ {
6316
+ indexed: false,
6317
+ internalType: "uint256",
6318
+ name: "assets",
6319
+ type: "uint256"
6320
+ },
6321
+ {
6322
+ indexed: false,
6323
+ internalType: "uint256",
6324
+ name: "shares",
6325
+ type: "uint256"
6326
+ }
6327
+ ],
6328
+ name: "Withdraw",
6329
+ type: "event"
6330
+ },
6331
+ {
6332
+ anonymous: false,
6333
+ inputs: [{
6334
+ indexed: true,
6335
+ internalType: "address",
6336
+ name: "previousOwner",
6337
+ type: "address"
6338
+ }, {
6339
+ indexed: true,
6340
+ internalType: "address",
6341
+ name: "newOwner",
6342
+ type: "address"
6343
+ }],
6344
+ name: "OwnershipTransferStarted",
6345
+ type: "event"
6346
+ },
6347
+ {
6348
+ anonymous: false,
6349
+ inputs: [{
6350
+ indexed: true,
6351
+ internalType: "address",
6352
+ name: "spoke",
6353
+ type: "address"
6354
+ }, {
6355
+ indexed: false,
6356
+ internalType: "bool",
6357
+ name: "registered",
6358
+ type: "bool"
6359
+ }],
6360
+ name: "RegisterSpoke",
6361
+ type: "event"
6362
+ },
6363
+ {
6364
+ anonymous: false,
6365
+ inputs: [
6366
+ {
6367
+ indexed: true,
6368
+ internalType: "address",
6369
+ name: "spoke",
6370
+ type: "address"
6371
+ },
6372
+ {
6373
+ indexed: true,
6374
+ internalType: "address",
6375
+ name: "caller",
6376
+ type: "address"
6377
+ },
6378
+ {
6379
+ indexed: true,
6380
+ internalType: "address",
6381
+ name: "onBehalfOf",
6382
+ type: "address"
6383
+ },
6384
+ {
6385
+ indexed: false,
6386
+ internalType: "uint256",
6387
+ name: "reserveId",
6388
+ type: "uint256"
6389
+ },
6390
+ {
6391
+ indexed: false,
6392
+ internalType: "uint256",
6393
+ name: "repaidShares",
6394
+ type: "uint256"
6395
+ },
6396
+ {
6397
+ indexed: false,
6398
+ internalType: "uint256",
6399
+ name: "repaidAmount",
6400
+ type: "uint256"
6401
+ }
6402
+ ],
6403
+ name: "RepayOnBehalfOf",
6404
+ type: "event"
6405
+ },
6406
+ {
6407
+ anonymous: false,
6408
+ inputs: [
6409
+ {
6410
+ indexed: true,
6411
+ internalType: "address",
6412
+ name: "spoke",
6413
+ type: "address"
6414
+ },
6415
+ {
6416
+ indexed: true,
6417
+ internalType: "address",
6418
+ name: "caller",
6419
+ type: "address"
6420
+ },
6421
+ {
6422
+ indexed: true,
6423
+ internalType: "address",
6424
+ name: "onBehalfOf",
6425
+ type: "address"
6426
+ },
6427
+ {
6428
+ indexed: false,
6429
+ internalType: "uint256",
6430
+ name: "reserveId",
6431
+ type: "uint256"
6432
+ },
6433
+ {
6434
+ indexed: false,
6435
+ internalType: "uint256",
6436
+ name: "suppliedShares",
6437
+ type: "uint256"
6438
+ },
6439
+ {
6440
+ indexed: false,
6441
+ internalType: "uint256",
6442
+ name: "suppliedAmount",
6443
+ type: "uint256"
6444
+ }
6445
+ ],
6446
+ name: "SupplyOnBehalfOf",
6447
+ type: "event"
6448
+ },
6449
+ {
6450
+ anonymous: false,
6451
+ inputs: [
6452
+ {
6453
+ indexed: true,
6454
+ internalType: "address",
6455
+ name: "spoke",
6456
+ type: "address"
6457
+ },
6458
+ {
6459
+ indexed: true,
6460
+ internalType: "uint256",
6461
+ name: "reserveId",
6462
+ type: "uint256"
6463
+ },
6464
+ {
6465
+ indexed: true,
6466
+ internalType: "address",
6467
+ name: "owner",
6468
+ type: "address"
6469
+ },
6470
+ {
6471
+ indexed: false,
6472
+ internalType: "address",
6473
+ name: "spender",
6474
+ type: "address"
6475
+ },
6476
+ {
6477
+ indexed: false,
6478
+ internalType: "uint256",
6479
+ name: "amount",
6480
+ type: "uint256"
6481
+ }
6482
+ ],
6483
+ name: "BorrowApproval",
6484
+ type: "event"
6485
+ },
6486
+ {
6487
+ anonymous: false,
6488
+ inputs: [
6489
+ {
6490
+ indexed: true,
6491
+ internalType: "address",
6492
+ name: "spoke",
6493
+ type: "address"
6494
+ },
6495
+ {
6496
+ indexed: true,
6497
+ internalType: "address",
6498
+ name: "caller",
6499
+ type: "address"
6500
+ },
6501
+ {
6502
+ indexed: true,
6503
+ internalType: "address",
6504
+ name: "onBehalfOf",
6505
+ type: "address"
6506
+ },
6507
+ {
6508
+ indexed: false,
6509
+ internalType: "uint256",
6510
+ name: "reserveId",
6511
+ type: "uint256"
6512
+ },
6513
+ {
6514
+ indexed: false,
6515
+ internalType: "uint256",
6516
+ name: "drawnShares",
6517
+ type: "uint256"
6518
+ },
6519
+ {
6520
+ indexed: false,
6521
+ internalType: "uint256",
6522
+ name: "drawnAmount",
6523
+ type: "uint256"
6524
+ }
6525
+ ],
6526
+ name: "BorrowOnBehalfOf",
6527
+ type: "event"
6528
+ },
6529
+ {
6530
+ anonymous: false,
6531
+ inputs: [
6532
+ {
6533
+ indexed: true,
6534
+ internalType: "address",
6535
+ name: "spoke",
6536
+ type: "address"
6537
+ },
6538
+ {
6539
+ indexed: true,
6540
+ internalType: "uint256",
6541
+ name: "reserveId",
6542
+ type: "uint256"
6543
+ },
6544
+ {
6545
+ indexed: true,
6546
+ internalType: "address",
6547
+ name: "owner",
6548
+ type: "address"
6549
+ },
6550
+ {
6551
+ indexed: false,
6552
+ internalType: "address",
6553
+ name: "spender",
6554
+ type: "address"
6555
+ },
6556
+ {
6557
+ indexed: false,
6558
+ internalType: "uint256",
6559
+ name: "amount",
6560
+ type: "uint256"
6561
+ }
6562
+ ],
6563
+ name: "WithdrawApproval",
6564
+ type: "event"
6565
+ },
6566
+ {
6567
+ anonymous: false,
6568
+ inputs: [
6569
+ {
6570
+ indexed: true,
6571
+ internalType: "address",
6572
+ name: "spoke",
6573
+ type: "address"
6574
+ },
6575
+ {
6576
+ indexed: true,
6577
+ internalType: "address",
6578
+ name: "caller",
6579
+ type: "address"
6580
+ },
6581
+ {
6582
+ indexed: true,
6583
+ internalType: "address",
6584
+ name: "onBehalfOf",
6585
+ type: "address"
6586
+ },
6587
+ {
6588
+ indexed: false,
6589
+ internalType: "uint256",
6590
+ name: "reserveId",
6591
+ type: "uint256"
6592
+ },
6593
+ {
6594
+ indexed: false,
6595
+ internalType: "uint256",
6596
+ name: "withdrawnShares",
6597
+ type: "uint256"
6598
+ },
6599
+ {
6600
+ indexed: false,
6601
+ internalType: "uint256",
6602
+ name: "withdrawnAmount",
6603
+ type: "uint256"
6604
+ }
6605
+ ],
6606
+ name: "WithdrawOnBehalfOf",
6607
+ type: "event"
6608
+ },
6609
+ {
6610
+ anonymous: false,
6611
+ inputs: [
6612
+ {
6613
+ indexed: true,
6614
+ internalType: "address",
6615
+ name: "spoke",
6616
+ type: "address"
6617
+ },
6618
+ {
6619
+ indexed: true,
6620
+ internalType: "address",
6621
+ name: "caller",
6622
+ type: "address"
6623
+ },
6624
+ {
6625
+ indexed: true,
6626
+ internalType: "address",
6627
+ name: "onBehalfOf",
6628
+ type: "address"
6629
+ },
6630
+ {
6631
+ indexed: false,
6632
+ internalType: "uint256",
6633
+ name: "reserveId",
6634
+ type: "uint256"
6635
+ },
6636
+ {
6637
+ indexed: false,
6638
+ internalType: "bool",
6639
+ name: "usingAsCollateral",
6640
+ type: "bool"
6641
+ }
6642
+ ],
6643
+ name: "SetUsingAsCollateralOnBehalfOf",
6644
+ type: "event"
6645
+ },
6646
+ {
6647
+ anonymous: false,
6648
+ inputs: [
6649
+ {
6650
+ indexed: true,
6651
+ internalType: "address",
6652
+ name: "spoke",
6653
+ type: "address"
6654
+ },
6655
+ {
6656
+ indexed: true,
6657
+ internalType: "address",
6658
+ name: "delegator",
6659
+ type: "address"
6660
+ },
6661
+ {
6662
+ indexed: true,
6663
+ internalType: "address",
6664
+ name: "delegatee",
6665
+ type: "address"
6666
+ },
6667
+ {
6668
+ indexed: false,
6669
+ internalType: "ConfigPermissions",
6670
+ name: "oldPermissions",
6671
+ type: "uint8"
6672
+ },
6673
+ {
6674
+ indexed: false,
6675
+ internalType: "ConfigPermissions",
6676
+ name: "newPermissions",
6677
+ type: "uint8"
6678
+ }
6679
+ ],
6680
+ name: "UpdateConfigPermissions",
6681
+ type: "event"
6682
+ },
6683
+ {
6684
+ anonymous: false,
6685
+ inputs: [
6686
+ {
6687
+ indexed: true,
6688
+ internalType: "address",
6689
+ name: "spoke",
6690
+ type: "address"
6691
+ },
6692
+ {
6693
+ indexed: true,
6694
+ internalType: "address",
6695
+ name: "caller",
6696
+ type: "address"
6697
+ },
6698
+ {
6699
+ indexed: true,
6700
+ internalType: "address",
6701
+ name: "onBehalfOf",
6702
+ type: "address"
6703
+ }
6704
+ ],
6705
+ name: "UpdateUserDynamicConfigOnBehalfOf",
6706
+ type: "event"
6707
+ },
6708
+ {
6709
+ anonymous: false,
6710
+ inputs: [
6711
+ {
6712
+ indexed: true,
6713
+ internalType: "address",
6714
+ name: "spoke",
6715
+ type: "address"
6716
+ },
6717
+ {
6718
+ indexed: true,
6719
+ internalType: "address",
6720
+ name: "caller",
6721
+ type: "address"
6722
+ },
6723
+ {
6724
+ indexed: true,
6725
+ internalType: "address",
6726
+ name: "onBehalfOf",
6727
+ type: "address"
6728
+ }
6729
+ ],
6730
+ name: "UpdateUserRiskPremiumOnBehalfOf",
6731
+ type: "event"
6732
+ },
6733
+ {
6734
+ anonymous: false,
6735
+ inputs: [{
6736
+ indexed: true,
6737
+ internalType: "address",
6738
+ name: "spoke",
6739
+ type: "address"
6740
+ }],
6741
+ name: "SetSpoke",
6742
+ type: "event"
6743
+ },
6744
+ {
6745
+ anonymous: false,
6746
+ inputs: [{
6747
+ indexed: true,
6748
+ internalType: "uint256",
6749
+ name: "reserveId",
6750
+ type: "uint256"
6751
+ }, {
6752
+ indexed: true,
6753
+ internalType: "address",
6754
+ name: "source",
6755
+ type: "address"
6756
+ }],
6757
+ name: "UpdateReserveSource",
6758
+ type: "event"
6759
+ }
6760
+ ];
6761
+
6762
+ //#endregion
6763
+ //#region sections/logs.ts
6764
+ async function renderLogsSection(logs, chainId) {
6765
+ if (!logs || !logs.length) return "";
6766
+ const parsed = parseLogs({
6767
+ logs: logs.map((log) => ({
6768
+ topics: log.topics,
6769
+ data: log.data,
6770
+ address: log.emitter
6771
+ })),
6772
+ eventDb
6773
+ });
6774
+ const entries = (await enhanceLogs(getClient(chainId, {}), parsed)).map((log, i) => {
6775
+ const emitter = logs[i].emitter;
6776
+ let event;
6777
+ if (log.eventName) {
6778
+ const args = log.args ? formatArgs(log.args) : "";
6779
+ event = `${log.eventName}(${args})`;
6780
+ } else event = `topics: ${logs[i].topics.map((t) => `\`${t}\``).join(", ")}, data: \`${logs[i].data.length > 66 ? `${logs[i].data.slice(0, 66)}...` : logs[i].data}\``;
6781
+ return {
6782
+ emitter,
6783
+ event,
6784
+ index: i
6785
+ };
6786
+ });
6787
+ const grouped = /* @__PURE__ */ new Map();
6788
+ for (const entry of entries) {
6789
+ let group = grouped.get(entry.emitter);
6790
+ if (!group) {
6791
+ group = {
6792
+ emitter: entry.emitter,
6793
+ events: []
6794
+ };
6795
+ grouped.set(entry.emitter, group);
6796
+ }
6797
+ group.events.push({
6798
+ index: entry.index,
6799
+ event: entry.event
6800
+ });
6801
+ }
6802
+ let md = "## Event logs\n\n";
6803
+ for (const group of grouped.values()) {
6804
+ const knownName = isKnownAddress(group.emitter, chainId);
6805
+ const label = knownName ? knownName.join(", ") : null;
6806
+ const heading = label ? `${group.emitter} (${label})` : group.emitter;
6807
+ md += `#### ${heading}\n\n`;
6808
+ md += "| index | event |\n| --- | --- |\n";
6809
+ for (const entry of group.events) md += `| ${entry.index} | ${entry.event} |\n`;
6810
+ md += "\n";
6811
+ }
6812
+ return md;
6813
+ }
6814
+ function formatArgs(args) {
6815
+ if (Array.isArray(args)) return args.map((v) => formatValue(v)).join(", ");
6816
+ if (typeof args === "object" && args !== null) return Object.entries(args).map(([k, v]) => `${k}: ${formatValue(v)}`).join(", ");
6817
+ return String(args);
6818
+ }
6819
+ function formatValue(v) {
6820
+ if (typeof v === "bigint") return v.toString();
6821
+ if (typeof v === "string") return v;
6822
+ if (typeof v === "boolean") return String(v);
6823
+ if (Array.isArray(v)) return `[${v.map(formatValue).join(", ")}]`;
6824
+ if (typeof v === "object" && v !== null) return `{${Object.entries(v).map(([k, val]) => `${k}: ${formatValue(val)}`).join(", ")}}`;
6825
+ return String(v);
6826
+ }
6827
+
6828
+ //#endregion
6829
+ //#region protocol-diff.ts
6830
+ /**
6831
+ * Diff two Aave V3 protocol snapshots and produce a formatted markdown report.
6832
+ *
6833
+ * The `raw` and `logs` sections only exist in the "after" snapshot and are
6834
+ * rendered as-is (they already represent the diff / changes).
6835
+ */
6836
+ async function diffSnapshots(before, after) {
6837
+ let raw;
6838
+ let logs;
6839
+ const postCopy = { ...after };
6840
+ if (postCopy.raw) {
6841
+ raw = postCopy.raw;
6842
+ delete postCopy.raw;
6843
+ }
6844
+ if (postCopy.logs) {
6845
+ logs = [...postCopy.logs];
6846
+ delete postCopy.logs;
6847
+ }
6848
+ const diffResult = diff(before, postCopy);
6849
+ let md = "";
6850
+ md += renderReservesSection(diffResult, before, after);
6851
+ md += renderEmodesSection(diffResult, before, after);
6852
+ md += renderPoolConfigSection(diffResult, after.chainId);
6853
+ md += await renderLogsSection(logs, after.chainId);
6854
+ md += renderRawSection(raw, after.chainId);
6855
+ const diffWithoutUnchanged = diff(before, postCopy, true);
6856
+ md += `## Raw diff\n\n\`\`\`json\n${JSON.stringify(diffWithoutUnchanged, null, 2)}\n\`\`\`\n`;
6857
+ return md;
6858
+ }
6859
+
6860
+ //#endregion
6861
+ //#region formatters-v4.ts
6862
+ function getExplorerClient(chainId) {
6863
+ return getClient(chainId, {});
6864
+ }
6865
+ function addressLink(value, chainId) {
6866
+ return toAddressLink(value, true, getExplorerClient(chainId));
6867
+ }
6868
+ function isAddress(value) {
6869
+ return typeof value === "string" && /^0x[0-9a-fA-F]{40}$/.test(value);
6870
+ }
6871
+ /** Format BPS value as percentage, matching Solidity _ps(): "W.FF % [bps]" */
6872
+ function formatBps(bps) {
6873
+ const w = Math.floor(bps / 100);
6874
+ const f = bps % 100;
6875
+ return `${w}.${f < 10 ? `0${f}` : `${f}`} % [${bps}]`;
6876
+ }
6877
+ /** Render a uint as "1,500,000 (1.5e6) USDT"; suffix (e.g. asset symbol) goes
6878
+ * at the end after the exponential. Values < 1000 skip the exponential.
6879
+ * Exponential uses `Number.toExponential()`, so bigints exceeding
6880
+ * Number.MAX_SAFE_INTEGER (~9e15) the exponent is rounded */
6881
+ function formatBigIntWithExp(value, suffix) {
6882
+ return `${value.toLocaleString("en-US")}${value >= 1000n || value <= -1000n ? ` (${Number(value).toExponential().replace("e+", "e")})` : ""}${suffix ? ` ${suffix}` : ""}`;
6883
+ }
6884
+ const SPOKE_RESERVE_BPS_FIELDS = [
6885
+ "collateralRisk",
6886
+ "collateralFactor",
6887
+ "liquidationFee"
6888
+ ];
6889
+ /** ISpoke.DynamicReserveConfig: 100_00 represents 0.00% bonus — subtract PERCENTAGE_FACTOR (100_00) for the actual bonus. */
6890
+ function formatLiquidationBonus(value) {
6891
+ if (value === 0) return "0.00 % [0]";
6892
+ return `${((value - 1e4) / 100).toFixed(2)} % [${value}]`;
6893
+ }
6894
+ const SPOKE_RESERVE_BOOL_FIELDS = [
6895
+ "paused",
6896
+ "frozen",
6897
+ "borrowable",
6898
+ "receiveSharesEnabled"
6899
+ ];
6900
+ const SPOKE_RESERVE_ADDRESS_FIELDS = [
6901
+ "underlying",
6902
+ "hub",
6903
+ "oracleAddress",
6904
+ "priceSource"
6905
+ ];
6906
+ const spokeReserveFormatters = {};
6907
+ for (const field of SPOKE_RESERVE_BPS_FIELDS) spokeReserveFormatters[field] = (value) => formatBps(value);
6908
+ spokeReserveFormatters["maxLiquidationBonus"] = (value) => formatLiquidationBonus(value);
6909
+ for (const field of SPOKE_RESERVE_BOOL_FIELDS) spokeReserveFormatters[field] = (value) => boolToMarkdown(value);
6910
+ for (const field of SPOKE_RESERVE_ADDRESS_FIELDS) spokeReserveFormatters[field] = (value, ctx) => addressLink(value, ctx.chainId);
6911
+ const HUB_ASSET_BPS_FIELDS = ["liquidityFee"];
6912
+ /** IR strategy fields — per-asset on V4, BPS scale (unlike V3 RAY). */
6913
+ const HUB_ASSET_IR_STRATEGY_BPS_FIELDS = [
6914
+ "optimalUsageRatio",
6915
+ "baseDrawnRate",
6916
+ "rateGrowthBeforeOptimal",
6917
+ "rateGrowthAfterOptimal"
6918
+ ];
6919
+ const HUB_ASSET_ADDRESS_FIELDS = [
6920
+ "underlying",
6921
+ "irStrategy",
6922
+ "feeReceiver",
6923
+ "reinvestmentController"
6924
+ ];
6925
+ const hubAssetFormatters = {};
6926
+ for (const field of HUB_ASSET_BPS_FIELDS) hubAssetFormatters[field] = (value) => formatBps(value);
6927
+ for (const field of HUB_ASSET_IR_STRATEGY_BPS_FIELDS) hubAssetFormatters[field] = (value) => formatBps(value);
6928
+ hubAssetFormatters["maxDrawnRate"] = (value) => formatBps(Number(value));
6929
+ for (const field of HUB_ASSET_ADDRESS_FIELDS) hubAssetFormatters[field] = (value, ctx) => addressLink(value, ctx.chainId);
6930
+ hubAssetFormatters["deficitRay"] = (value) => `${formatUnits(BigInt(value), 27)} [${value}]`;
6931
+ hubAssetFormatters["premiumOffsetRay"] = (value) => `${formatUnits(BigInt(value), 27)} [${value}]`;
6932
+ const SPOKE_CONFIG_FLAGS = ["active", "halted"];
6933
+ /** uint40 token-unit cap fields — formatted with thousands separators + asset symbol. */
6934
+ const SPOKE_CONFIG_TOKEN_AMOUNT_FIELDS = ["addCap", "drawCap"];
6935
+ const MAX_ALLOWED_SPOKE_CAP = 2 ** 40 - 1;
6936
+ const MAX_RISK_PREMIUM_THRESHOLD = 2 ** 24 - 1;
6937
+ const spokeConfigFormatters = {};
6938
+ for (const field of SPOKE_CONFIG_FLAGS) spokeConfigFormatters[field] = (value) => boolToMarkdown(value);
6939
+ for (const field of SPOKE_CONFIG_TOKEN_AMOUNT_FIELDS) spokeConfigFormatters[field] = (value, ctx) => {
6940
+ if (value === MAX_ALLOWED_SPOKE_CAP) return "sentinel value - no cap";
6941
+ return formatBigIntWithExp(BigInt(value), ctx.spokeConfig?.assetSymbol);
6942
+ };
6943
+ spokeConfigFormatters["riskPremiumThreshold"] = (value) => {
6944
+ if (value === MAX_RISK_PREMIUM_THRESHOLD) return "sentinel value - no threshold";
6945
+ return formatBps(value);
6946
+ };
6947
+ const spokeLiqFormatters = {};
6948
+ spokeLiqFormatters["targetHealthFactor"] = (value) => `${formatUnits(BigInt(value), 18)} [${value}]`;
6949
+ spokeLiqFormatters["healthFactorForMaxBonus"] = (value) => `${formatUnits(BigInt(value), 18)} [${value}]`;
6950
+ spokeLiqFormatters["liquidationBonusFactor"] = (value) => formatBps(value);
6951
+ const formattersMap = {
6952
+ spokeReserve: spokeReserveFormatters,
6953
+ hubAsset: hubAssetFormatters,
6954
+ spokeConfig: spokeConfigFormatters,
6955
+ spokeLiq: spokeLiqFormatters
6956
+ };
6957
+ function formatV4Value(section, key, value, ctx) {
6958
+ const formatter = formattersMap[section][key];
6959
+ if (formatter) return formatter(value, ctx);
6960
+ if (typeof value === "boolean") return boolToMarkdown(value);
6961
+ if (typeof value === "number") return value.toLocaleString("en-US");
6962
+ if (isAddress(value)) return addressLink(value, ctx.chainId);
6963
+ if (typeof value === "string" && /^-?\d+$/.test(value)) return formatBigIntWithExp(BigInt(value));
6964
+ return String(value);
6965
+ }
6966
+
6967
+ //#endregion
6968
+ //#region sections/spoke-reserves.ts
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. */
6971
+ const FIELD_ORDER$3 = [
6972
+ "symbol",
6973
+ "underlying",
6974
+ "hub",
6975
+ "assetId",
6976
+ "decimals",
6977
+ "collateralRisk",
6978
+ "paused",
6979
+ "frozen",
6980
+ "borrowable",
6981
+ "receiveSharesEnabled",
6982
+ "dynamicConfigKey",
6983
+ "collateralFactor",
6984
+ "maxLiquidationBonus",
6985
+ "liquidationFee",
6986
+ "oracleAddress",
6987
+ "priceSource",
6988
+ "oraclePrice"
6989
+ ];
6990
+ function reserveHeader(reserve, spokeAddr, reserveId, chainId) {
6991
+ const client = getClient(chainId, {});
6992
+ const underlyingLink = toAddressLink(reserve.underlying, true, client);
6993
+ const spokeLink = toAddressLink(spokeAddr, true, client);
6994
+ return `### ${reserve.symbol} (${underlyingLink}) on Spoke ${spokeLink} [reserveId: ${reserveId}]\n\n`;
6995
+ }
6996
+ function renderNewReserve(reserve, spokeAddr, reserveId, ctx) {
6997
+ let md = reserveHeader(reserve, spokeAddr, reserveId, ctx.chainId);
6998
+ md += "**NEW RESERVE**\n\n";
6999
+ md += "| description | value |\n| --- | --- |\n";
7000
+ for (const key of FIELD_ORDER$3) md += `| ${key} | ${formatV4Value("spokeReserve", key, reserve[key], ctx)} |\n`;
7001
+ return md + "\n";
7002
+ }
7003
+ function renderReserveDiff(before, after, spokeAddr, reserveId, ctx) {
7004
+ const rows = [];
7005
+ for (const key of FIELD_ORDER$3) {
7006
+ const bVal = before[key];
7007
+ const aVal = after[key];
7008
+ if (String(bVal) === String(aVal)) continue;
7009
+ const fromFmt = formatV4Value("spokeReserve", key, bVal, ctx);
7010
+ const toFmt = formatV4Value("spokeReserve", key, aVal, ctx);
7011
+ rows.push(`| ${key} | ${fromFmt} | ${toFmt} |`);
7012
+ }
7013
+ if (rows.length === 0) return "";
7014
+ let md = reserveHeader(after, spokeAddr, reserveId, ctx.chainId);
7015
+ md += "| description | value before | value after |\n| --- | --- | --- |\n";
7016
+ md += rows.join("\n") + "\n";
7017
+ return md + "\n";
7018
+ }
7019
+ function renderSpokeReservesSection(before, after) {
7020
+ const ctx = { chainId: after.chainId };
7021
+ const allSpokeAddrs = new Set([...Object.keys(before.spokeReserves), ...Object.keys(after.spokeReserves)]);
7022
+ let body = "";
7023
+ for (const spokeAddr of allSpokeAddrs) {
7024
+ const beforeSpoke = before.spokeReserves[spokeAddr] ?? {};
7025
+ const afterSpoke = after.spokeReserves[spokeAddr] ?? {};
7026
+ const allReserveIds = new Set([...Object.keys(beforeSpoke), ...Object.keys(afterSpoke)]);
7027
+ for (const reserveId of allReserveIds) {
7028
+ const bRes = beforeSpoke[reserveId];
7029
+ const aRes = afterSpoke[reserveId];
7030
+ if (bRes && aRes) body += renderReserveDiff(bRes, aRes, spokeAddr, reserveId, ctx);
7031
+ else if (aRes) body += renderNewReserve(aRes, spokeAddr, reserveId, ctx);
7032
+ else if (bRes) body += reserveHeader(bRes, spokeAddr, reserveId, ctx.chainId) + "**REMOVED**\n\n";
7033
+ }
7034
+ }
7035
+ if (!body) return "";
7036
+ return `## Spoke Reserve Changes\n\n${body}`;
7037
+ }
7038
+
7039
+ //#endregion
7040
+ //#region sections/hub-assets.ts
7041
+ /** All fields in display order. Every field is compared — even identity fields
7042
+ * that "shouldn't" change — so unexpected mutations are never silently missed. */
7043
+ const FIELD_ORDER$2 = [
7044
+ "symbol",
7045
+ "underlying",
7046
+ "decimals",
7047
+ "liquidityFee",
7048
+ "irStrategy",
7049
+ "feeReceiver",
7050
+ "reinvestmentController",
7051
+ "optimalUsageRatio",
7052
+ "baseDrawnRate",
7053
+ "rateGrowthBeforeOptimal",
7054
+ "rateGrowthAfterOptimal",
7055
+ "maxDrawnRate",
7056
+ "deficitRay",
7057
+ "swept",
7058
+ "premiumShares",
7059
+ "premiumOffsetRay"
7060
+ ];
7061
+ function hubAssetHeader(asset, hubAddr, assetId, chainId) {
7062
+ const hubLink = toAddressLink(hubAddr, true, getClient(chainId, {}));
7063
+ return `### ${asset.symbol} (assetId: ${assetId}) on Hub ${hubLink}\n\n`;
7064
+ }
7065
+ function renderNewHubAsset(asset, hubAddr, assetId, ctx) {
7066
+ let md = hubAssetHeader(asset, hubAddr, assetId, ctx.chainId);
7067
+ md += "**NEW ASSET**\n\n";
7068
+ md += "| description | value |\n| --- | --- |\n";
7069
+ for (const key of FIELD_ORDER$2) md += `| ${key} | ${formatV4Value("hubAsset", key, asset[key], ctx)} |\n`;
7070
+ return md + "\n";
7071
+ }
7072
+ function renderHubAssetDiff(before, after, hubAddr, assetId, ctx) {
7073
+ const rows = [];
7074
+ for (const key of FIELD_ORDER$2) {
7075
+ const bVal = before[key];
7076
+ const aVal = after[key];
7077
+ if (String(bVal) === String(aVal)) continue;
7078
+ const fromFmt = formatV4Value("hubAsset", key, bVal, ctx);
7079
+ const toFmt = formatV4Value("hubAsset", key, aVal, ctx);
7080
+ rows.push(`| ${key} | ${fromFmt} | ${toFmt} |`);
7081
+ }
7082
+ if (rows.length === 0) return "";
7083
+ let md = hubAssetHeader(after, hubAddr, assetId, ctx.chainId);
7084
+ md += "| description | value before | value after |\n| --- | --- | --- |\n";
7085
+ md += rows.join("\n") + "\n";
7086
+ return md + "\n";
7087
+ }
7088
+ function renderHubAssetsSection(before, after) {
7089
+ const ctx = { chainId: after.chainId };
7090
+ const allHubAddrs = new Set([...Object.keys(before.hubAssets), ...Object.keys(after.hubAssets)]);
7091
+ let body = "";
7092
+ for (const hubAddr of allHubAddrs) {
7093
+ const beforeHub = before.hubAssets[hubAddr] ?? {};
7094
+ const afterHub = after.hubAssets[hubAddr] ?? {};
7095
+ const allAssetIds = new Set([...Object.keys(beforeHub), ...Object.keys(afterHub)]);
7096
+ for (const assetId of allAssetIds) {
7097
+ const bAsset = beforeHub[assetId];
7098
+ const aAsset = afterHub[assetId];
7099
+ if (bAsset && aAsset) body += renderHubAssetDiff(bAsset, aAsset, hubAddr, assetId, ctx);
7100
+ else if (aAsset) body += renderNewHubAsset(aAsset, hubAddr, assetId, ctx);
7101
+ else if (bAsset) body += hubAssetHeader(bAsset, hubAddr, assetId, ctx.chainId) + "**REMOVED**\n\n";
7102
+ }
7103
+ }
7104
+ if (!body) return "";
7105
+ return `## Hub Asset Changes\n\n${body}`;
7106
+ }
7107
+
7108
+ //#endregion
7109
+ //#region sections/spoke-configs.ts
7110
+ /** All fields in display order. Every field is compared */
7111
+ const FIELD_ORDER$1 = [
7112
+ "assetSymbol",
7113
+ "addCap",
7114
+ "drawCap",
7115
+ "riskPremiumThreshold",
7116
+ "active",
7117
+ "halted"
7118
+ ];
7119
+ /**
7120
+ * Parse the composite key "hubAddr_assetId_spokeAddr".
7121
+ */
7122
+ function parseConfigKey(key) {
7123
+ const hubAddr = key.slice(0, 42);
7124
+ const rest = key.slice(43);
7125
+ const underscoreIdx = rest.indexOf("_");
7126
+ return {
7127
+ hubAddr,
7128
+ assetId: rest.slice(0, underscoreIdx),
7129
+ spokeAddr: rest.slice(underscoreIdx + 1)
7130
+ };
7131
+ }
7132
+ function configHeader(cfg, hubAddr, assetId, spokeAddr, chainId) {
7133
+ const client = getClient(chainId, {});
7134
+ const hubLink = toAddressLink(hubAddr, true, client);
7135
+ const spokeLink = toAddressLink(spokeAddr, true, client);
7136
+ return `### ${cfg.assetSymbol} (assetId: ${assetId}) on Hub ${hubLink} / Spoke ${spokeLink}\n\n`;
7137
+ }
7138
+ function renderNewConfig(cfg, hubAddr, assetId, spokeAddr, ctx) {
7139
+ const cfgCtx = {
7140
+ ...ctx,
7141
+ spokeConfig: cfg
7142
+ };
7143
+ let md = configHeader(cfg, hubAddr, assetId, spokeAddr, ctx.chainId);
7144
+ md += "**NEW SPOKE**\n\n";
7145
+ md += "| description | value |\n| --- | --- |\n";
7146
+ for (const key of FIELD_ORDER$1) md += `| ${key} | ${formatV4Value("spokeConfig", key, cfg[key], cfgCtx)} |\n`;
7147
+ return md + "\n";
7148
+ }
7149
+ function renderConfigDiff(before, after, hubAddr, assetId, spokeAddr, ctx) {
7150
+ const cfgCtx = {
7151
+ ...ctx,
7152
+ spokeConfig: after
7153
+ };
7154
+ const rows = [];
7155
+ for (const key of FIELD_ORDER$1) {
7156
+ const bVal = before[key];
7157
+ const aVal = after[key];
7158
+ if (String(bVal) === String(aVal)) continue;
7159
+ const fromFmt = formatV4Value("spokeConfig", key, bVal, cfgCtx);
7160
+ const toFmt = formatV4Value("spokeConfig", key, aVal, cfgCtx);
7161
+ rows.push(`| ${key} | ${fromFmt} | ${toFmt} |`);
7162
+ }
7163
+ if (rows.length === 0) return "";
7164
+ let md = configHeader(after, hubAddr, assetId, spokeAddr, ctx.chainId);
7165
+ md += "| description | value before | value after |\n| --- | --- | --- |\n";
7166
+ md += rows.join("\n") + "\n";
7167
+ return md + "\n";
7168
+ }
7169
+ function renderSpokeConfigsSection(before, after) {
7170
+ const ctx = { chainId: after.chainId };
7171
+ const allKeys = new Set([...Object.keys(before.spokeConfigs), ...Object.keys(after.spokeConfigs)]);
7172
+ let body = "";
7173
+ for (const key of allKeys) {
7174
+ const { hubAddr, assetId, spokeAddr } = parseConfigKey(key);
7175
+ const bCfg = before.spokeConfigs[key];
7176
+ const aCfg = after.spokeConfigs[key];
7177
+ if (bCfg && aCfg) body += renderConfigDiff(bCfg, aCfg, hubAddr, assetId, spokeAddr, ctx);
7178
+ else if (aCfg) body += renderNewConfig(aCfg, hubAddr, assetId, spokeAddr, ctx);
7179
+ else if (bCfg) body += configHeader(bCfg, hubAddr, assetId, spokeAddr, ctx.chainId) + "**REMOVED**\n\n";
7180
+ }
7181
+ if (!body) return "";
7182
+ return `## Hub Spoke Config Changes\n\n${body}`;
7183
+ }
7184
+
7185
+ //#endregion
7186
+ //#region sections/spoke-liquidation.ts
7187
+ /** All fields in display order (this section already covers every field). */
7188
+ const FIELD_ORDER = [
7189
+ "targetHealthFactor",
7190
+ "healthFactorForMaxBonus",
7191
+ "liquidationBonusFactor",
7192
+ "maxUserReservesLimit"
7193
+ ];
7194
+ function spokeHeader(spokeAddr, chainId) {
7195
+ return `### Spoke ${toAddressLink(spokeAddr, true, getClient(chainId, {}))}\n\n`;
7196
+ }
7197
+ function renderNewSpokeLiq(config, spokeAddr, ctx) {
7198
+ let md = spokeHeader(spokeAddr, ctx.chainId);
7199
+ md += "**NEW**\n\n";
7200
+ md += "| description | value |\n| --- | --- |\n";
7201
+ for (const key of FIELD_ORDER) md += `| ${key} | ${formatV4Value("spokeLiq", key, config[key], ctx)} |\n`;
7202
+ return md + "\n";
7203
+ }
7204
+ function renderSpokeLiqDiff(before, after, spokeAddr, ctx) {
7205
+ const rows = [];
7206
+ for (const key of FIELD_ORDER) {
7207
+ const bVal = before[key];
7208
+ const aVal = after[key];
7209
+ if (String(bVal) === String(aVal)) continue;
7210
+ const fromFmt = formatV4Value("spokeLiq", key, bVal, ctx);
7211
+ const toFmt = formatV4Value("spokeLiq", key, aVal, ctx);
7212
+ rows.push(`| ${key} | ${fromFmt} | ${toFmt} |`);
7213
+ }
7214
+ if (rows.length === 0) return "";
7215
+ let md = spokeHeader(spokeAddr, ctx.chainId);
7216
+ md += "| description | value before | value after |\n| --- | --- | --- |\n";
7217
+ md += rows.join("\n") + "\n";
7218
+ return md + "\n";
7219
+ }
7220
+ function renderSpokeLiquidationSection(before, after) {
7221
+ const ctx = { chainId: after.chainId };
7222
+ const allSpokeAddrs = new Set([...Object.keys(before.spokeLiquidationConfigs), ...Object.keys(after.spokeLiquidationConfigs)]);
7223
+ let body = "";
7224
+ for (const spokeAddr of allSpokeAddrs) {
7225
+ const bConfig = before.spokeLiquidationConfigs[spokeAddr];
7226
+ const aConfig = after.spokeLiquidationConfigs[spokeAddr];
7227
+ if (bConfig && aConfig) body += renderSpokeLiqDiff(bConfig, aConfig, spokeAddr, ctx);
7228
+ else if (aConfig) body += renderNewSpokeLiq(aConfig, spokeAddr, ctx);
7229
+ else if (bConfig) body += spokeHeader(spokeAddr, ctx.chainId) + "**REMOVED**\n\n";
7230
+ }
7231
+ if (!body) return "";
7232
+ return `## Spoke Liquidation Config Changes\n\n${body}`;
7233
+ }
7234
+
7235
+ //#endregion
7236
+ //#region protocol-diff-v4.ts
7237
+ /**
7238
+ * Diff two Aave V4 protocol snapshots and produce a formatted markdown report.
7239
+ *
7240
+ * The `raw` and `logs` sections only exist in the "after" snapshot and are
7241
+ * rendered as-is (they already represent the diff / changes).
7242
+ */
7243
+ async function diffV4Snapshots(before, after) {
7244
+ let raw;
7245
+ let logs;
7246
+ const postCopy = { ...after };
7247
+ if (postCopy.raw) {
7248
+ raw = postCopy.raw;
7249
+ delete postCopy.raw;
7250
+ }
7251
+ if (postCopy.logs) {
7252
+ logs = [...postCopy.logs];
7253
+ delete postCopy.logs;
7254
+ }
7255
+ let md = "";
7256
+ md += renderSpokeReservesSection(before, postCopy);
7257
+ md += renderHubAssetsSection(before, postCopy);
7258
+ md += renderSpokeConfigsSection(before, postCopy);
7259
+ md += renderSpokeLiquidationSection(before, postCopy);
7260
+ md += await renderLogsSection(logs, after.chainId);
7261
+ md += renderRawSection(raw, after.chainId);
7262
+ const preCopy = { ...before };
7263
+ delete preCopy.raw;
7264
+ delete preCopy.logs;
7265
+ const diffWithoutUnchanged = diff(preCopy, postCopy, true);
4827
7266
  md += `## Raw diff\n\n\`\`\`json\n${JSON.stringify(diffWithoutUnchanged, null, 2)}\n\`\`\`\n`;
7267
+ if (!md.trim() || md.trim() === "## Raw diff\n\n```json\n{}\n```") return "No configuration changes detected.\n";
4828
7268
  return md;
4829
7269
  }
4830
7270
 
4831
7271
  //#endregion
4832
- export { isChange as a, hasChanges as i, eventDb as n, diff as r, diffSnapshots as t };
7272
+ export { hasChanges as a, diff as i, diffSnapshots as n, isChange as o, eventDb as r, diffV4Snapshots as t };