@aave-dao/aave-helpers-js 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,301 @@
1
+ import { Hex } from "viem";
2
+ import { z } from "zod";
3
+
4
+ //#region snapshot-types.d.ts
5
+ declare const CHAIN_ID: {
6
+ readonly MAINNET: 1;
7
+ readonly OPTIMISM: 10;
8
+ readonly POLYGON: 137;
9
+ readonly FANTOM: 250;
10
+ readonly ARBITRUM: 42161;
11
+ readonly AVALANCHE: 43114;
12
+ readonly METIS: 1088;
13
+ readonly BASE: 8453;
14
+ readonly SCROLL: 534352;
15
+ readonly BNB: 56;
16
+ readonly GNOSIS: 100;
17
+ readonly CELO: 42220;
18
+ readonly ZKSYNC: 324;
19
+ };
20
+ declare const zodChainId: z.ZodEnum<{
21
+ readonly MAINNET: 1;
22
+ readonly OPTIMISM: 10;
23
+ readonly POLYGON: 137;
24
+ readonly FANTOM: 250;
25
+ readonly ARBITRUM: 42161;
26
+ readonly AVALANCHE: 43114;
27
+ readonly METIS: 1088;
28
+ readonly BASE: 8453;
29
+ readonly SCROLL: 534352;
30
+ readonly BNB: 56;
31
+ readonly GNOSIS: 100;
32
+ readonly CELO: 42220;
33
+ readonly ZKSYNC: 324;
34
+ }>;
35
+ type CHAIN_ID = z.infer<typeof zodChainId>;
36
+ declare const aaveV3ConfigSchema: z.ZodObject<{
37
+ oracle: z.ZodString;
38
+ pool: z.ZodString;
39
+ poolAddressesProvider: z.ZodString;
40
+ poolConfigurator: z.ZodString;
41
+ priceOracleSentinel: z.ZodString;
42
+ protocolDataProvider: z.ZodString;
43
+ }, z.core.$strip>;
44
+ type AaveV3Config = z.infer<typeof aaveV3ConfigSchema>;
45
+ declare const aaveV3ReserveSchema: z.ZodObject<{
46
+ id: z.ZodNumber;
47
+ symbol: z.ZodString;
48
+ underlying: z.ZodString;
49
+ decimals: z.ZodNumber;
50
+ isActive: z.ZodBoolean;
51
+ isFrozen: z.ZodBoolean;
52
+ isPaused: z.ZodBoolean;
53
+ isSiloed: z.ZodBoolean;
54
+ isFlashloanable: z.ZodBoolean;
55
+ isBorrowableInIsolation: z.ZodBoolean;
56
+ borrowingEnabled: z.ZodBoolean;
57
+ usageAsCollateralEnabled: z.ZodBoolean;
58
+ ltv: z.ZodNumber;
59
+ liquidationThreshold: z.ZodNumber;
60
+ liquidationBonus: z.ZodNumber;
61
+ liquidationProtocolFee: z.ZodNumber;
62
+ reserveFactor: z.ZodNumber;
63
+ supplyCap: z.ZodNumber;
64
+ borrowCap: z.ZodNumber;
65
+ debtCeiling: z.ZodNumber;
66
+ oracle: z.ZodString;
67
+ oracleDecimals: z.ZodNumber;
68
+ oracleDescription: z.ZodOptional<z.ZodString>;
69
+ oracleName: z.ZodOptional<z.ZodString>;
70
+ oracleLatestAnswer: z.ZodString;
71
+ interestRateStrategy: z.ZodString;
72
+ aToken: z.ZodString;
73
+ aTokenName: z.ZodString;
74
+ aTokenSymbol: z.ZodString;
75
+ aTokenUnderlyingBalance: z.ZodString;
76
+ variableDebtToken: z.ZodString;
77
+ variableDebtTokenName: z.ZodString;
78
+ variableDebtTokenSymbol: z.ZodString;
79
+ virtualBalance: z.ZodString;
80
+ }, z.core.$strip>;
81
+ type AaveV3Reserve = z.infer<typeof aaveV3ReserveSchema>;
82
+ declare const aaveV3StrategySchema: z.ZodObject<{
83
+ address: z.ZodString;
84
+ baseVariableBorrowRate: z.ZodString;
85
+ optimalUsageRatio: z.ZodString;
86
+ variableRateSlope1: z.ZodString;
87
+ variableRateSlope2: z.ZodString;
88
+ maxVariableBorrowRate: z.ZodString;
89
+ }, z.core.$strip>;
90
+ type AaveV3Strategy = z.infer<typeof aaveV3StrategySchema>;
91
+ declare const aaveV3EmodeSchema: z.ZodObject<{
92
+ eModeCategory: z.ZodNumber;
93
+ label: z.ZodString;
94
+ ltv: z.ZodNumber;
95
+ liquidationThreshold: z.ZodNumber;
96
+ liquidationBonus: z.ZodNumber;
97
+ priceSource: z.ZodOptional<z.ZodString>;
98
+ borrowableBitmap: z.ZodString;
99
+ collateralBitmap: z.ZodString;
100
+ }, z.core.$strip>;
101
+ type AaveV3Emode = z.infer<typeof aaveV3EmodeSchema>;
102
+ declare const slotDiffSchema: z.ZodObject<{
103
+ previousValue: z.ZodType<Hex>;
104
+ newValue: z.ZodType<Hex>;
105
+ label: z.ZodOptional<z.ZodString>;
106
+ type: z.ZodOptional<z.ZodString>;
107
+ offset: z.ZodOptional<z.ZodNumber>;
108
+ slot: z.ZodOptional<z.ZodString>;
109
+ decoded: z.ZodOptional<z.ZodObject<{
110
+ previousValue: z.ZodString;
111
+ newValue: z.ZodString;
112
+ }, z.core.$strip>>;
113
+ key: z.ZodOptional<z.ZodString>;
114
+ }, z.core.$strip>;
115
+ type SlotDiff = z.infer<typeof slotDiffSchema>;
116
+ declare const valueDiffSchema: z.ZodObject<{
117
+ previousValue: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
118
+ newValue: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
119
+ }, z.core.$strip>;
120
+ type ValueDiff = z.infer<typeof valueDiffSchema>;
121
+ declare const rawStorageSchema: z.ZodRecord<z.ZodType<`0x${string}`, unknown, z.core.$ZodTypeInternals<`0x${string}`, unknown>>, z.ZodObject<{
122
+ label: z.ZodNullable<z.ZodString>;
123
+ contract: z.ZodNullable<z.ZodString>;
124
+ balanceDiff: z.ZodNullable<z.ZodObject<{
125
+ previousValue: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
126
+ newValue: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
127
+ }, z.core.$strip>>;
128
+ nonceDiff: z.ZodNullable<z.ZodObject<{
129
+ previousValue: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
130
+ newValue: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
131
+ }, z.core.$strip>>;
132
+ stateDiff: z.ZodRecord<z.ZodString, z.ZodObject<{
133
+ previousValue: z.ZodType<Hex>;
134
+ newValue: z.ZodType<Hex>;
135
+ label: z.ZodOptional<z.ZodString>;
136
+ type: z.ZodOptional<z.ZodString>;
137
+ offset: z.ZodOptional<z.ZodNumber>;
138
+ slot: z.ZodOptional<z.ZodString>;
139
+ decoded: z.ZodOptional<z.ZodObject<{
140
+ previousValue: z.ZodString;
141
+ newValue: z.ZodString;
142
+ }, z.core.$strip>>;
143
+ key: z.ZodOptional<z.ZodString>;
144
+ }, z.core.$strip>>;
145
+ }, z.core.$strip>>;
146
+ type RawStorage = z.infer<typeof rawStorageSchema>;
147
+ declare const logSchema: z.ZodObject<{
148
+ topics: z.ZodArray<z.ZodString>;
149
+ data: z.ZodString;
150
+ emitter: z.ZodString;
151
+ }, z.core.$strip>;
152
+ type Log = z.infer<typeof logSchema>;
153
+ declare const aaveV3SnapshotSchema: z.ZodObject<{
154
+ chainId: z.ZodEnum<{
155
+ readonly MAINNET: 1;
156
+ readonly OPTIMISM: 10;
157
+ readonly POLYGON: 137;
158
+ readonly FANTOM: 250;
159
+ readonly ARBITRUM: 42161;
160
+ readonly AVALANCHE: 43114;
161
+ readonly METIS: 1088;
162
+ readonly BASE: 8453;
163
+ readonly SCROLL: 534352;
164
+ readonly BNB: 56;
165
+ readonly GNOSIS: 100;
166
+ readonly CELO: 42220;
167
+ readonly ZKSYNC: 324;
168
+ }>;
169
+ reserves: z.ZodRecord<z.ZodString, z.ZodObject<{
170
+ id: z.ZodNumber;
171
+ symbol: z.ZodString;
172
+ underlying: z.ZodString;
173
+ decimals: z.ZodNumber;
174
+ isActive: z.ZodBoolean;
175
+ isFrozen: z.ZodBoolean;
176
+ isPaused: z.ZodBoolean;
177
+ isSiloed: z.ZodBoolean;
178
+ isFlashloanable: z.ZodBoolean;
179
+ isBorrowableInIsolation: z.ZodBoolean;
180
+ borrowingEnabled: z.ZodBoolean;
181
+ usageAsCollateralEnabled: z.ZodBoolean;
182
+ ltv: z.ZodNumber;
183
+ liquidationThreshold: z.ZodNumber;
184
+ liquidationBonus: z.ZodNumber;
185
+ liquidationProtocolFee: z.ZodNumber;
186
+ reserveFactor: z.ZodNumber;
187
+ supplyCap: z.ZodNumber;
188
+ borrowCap: z.ZodNumber;
189
+ debtCeiling: z.ZodNumber;
190
+ oracle: z.ZodString;
191
+ oracleDecimals: z.ZodNumber;
192
+ oracleDescription: z.ZodOptional<z.ZodString>;
193
+ oracleName: z.ZodOptional<z.ZodString>;
194
+ oracleLatestAnswer: z.ZodString;
195
+ interestRateStrategy: z.ZodString;
196
+ aToken: z.ZodString;
197
+ aTokenName: z.ZodString;
198
+ aTokenSymbol: z.ZodString;
199
+ aTokenUnderlyingBalance: z.ZodString;
200
+ variableDebtToken: z.ZodString;
201
+ variableDebtTokenName: z.ZodString;
202
+ variableDebtTokenSymbol: z.ZodString;
203
+ virtualBalance: z.ZodString;
204
+ }, z.core.$strip>>;
205
+ strategies: z.ZodRecord<z.ZodString, z.ZodObject<{
206
+ address: z.ZodString;
207
+ baseVariableBorrowRate: z.ZodString;
208
+ optimalUsageRatio: z.ZodString;
209
+ variableRateSlope1: z.ZodString;
210
+ variableRateSlope2: z.ZodString;
211
+ maxVariableBorrowRate: z.ZodString;
212
+ }, z.core.$strip>>;
213
+ eModes: z.ZodRecord<z.ZodString, z.ZodObject<{
214
+ eModeCategory: z.ZodNumber;
215
+ label: z.ZodString;
216
+ ltv: z.ZodNumber;
217
+ liquidationThreshold: z.ZodNumber;
218
+ liquidationBonus: z.ZodNumber;
219
+ priceSource: z.ZodOptional<z.ZodString>;
220
+ borrowableBitmap: z.ZodString;
221
+ collateralBitmap: z.ZodString;
222
+ }, z.core.$strip>>;
223
+ poolConfig: z.ZodObject<{
224
+ oracle: z.ZodString;
225
+ pool: z.ZodString;
226
+ poolAddressesProvider: z.ZodString;
227
+ poolConfigurator: z.ZodString;
228
+ priceOracleSentinel: z.ZodString;
229
+ protocolDataProvider: z.ZodString;
230
+ }, z.core.$strip>;
231
+ raw: z.ZodOptional<z.ZodRecord<z.ZodType<`0x${string}`, unknown, z.core.$ZodTypeInternals<`0x${string}`, unknown>>, z.ZodObject<{
232
+ label: z.ZodNullable<z.ZodString>;
233
+ contract: z.ZodNullable<z.ZodString>;
234
+ balanceDiff: z.ZodNullable<z.ZodObject<{
235
+ previousValue: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
236
+ newValue: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
237
+ }, z.core.$strip>>;
238
+ nonceDiff: z.ZodNullable<z.ZodObject<{
239
+ previousValue: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
240
+ newValue: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
241
+ }, z.core.$strip>>;
242
+ stateDiff: z.ZodRecord<z.ZodString, z.ZodObject<{
243
+ previousValue: z.ZodType<Hex>;
244
+ newValue: z.ZodType<Hex>;
245
+ label: z.ZodOptional<z.ZodString>;
246
+ type: z.ZodOptional<z.ZodString>;
247
+ offset: z.ZodOptional<z.ZodNumber>;
248
+ slot: z.ZodOptional<z.ZodString>;
249
+ decoded: z.ZodOptional<z.ZodObject<{
250
+ previousValue: z.ZodString;
251
+ newValue: z.ZodString;
252
+ }, z.core.$strip>>;
253
+ key: z.ZodOptional<z.ZodString>;
254
+ }, z.core.$strip>>;
255
+ }, z.core.$strip>>>;
256
+ logs: z.ZodOptional<z.ZodArray<z.ZodObject<{
257
+ topics: z.ZodArray<z.ZodString>;
258
+ data: z.ZodString;
259
+ emitter: z.ZodString;
260
+ }, z.core.$strip>>>;
261
+ }, z.core.$strip>;
262
+ type AaveV3Snapshot = z.infer<typeof aaveV3SnapshotSchema>;
263
+ //#endregion
264
+ //#region protocol-diff.d.ts
265
+ /**
266
+ * Diff two Aave V3 protocol snapshots and produce a formatted markdown report.
267
+ *
268
+ * The `raw` and `logs` sections only exist in the "after" snapshot and are
269
+ * rendered as-is (they already represent the diff / changes).
270
+ */
271
+ declare function diffSnapshots(before: AaveV3Snapshot, after: AaveV3Snapshot): Promise<string>;
272
+ //#endregion
273
+ //#region diff.d.ts
274
+ /**
275
+ * Generic recursive object diff.
276
+ *
277
+ * For each key present in either `a` or `b`:
278
+ * - If both have the key and the values are objects, recurse.
279
+ * - If both have the key and the values are equal primitives, keep as-is (or omit if `removeUnchanged`).
280
+ * - If both have the key but values differ, produce `{ from, to }`.
281
+ * - If only `a` has the key, produce `{ from: value, to: null }`.
282
+ * - If only `b` has the key, produce `{ from: null, to: value }`.
283
+ */
284
+ /** A changed field: carries the old and new value. */
285
+ type Change<T> = {
286
+ from: T | null;
287
+ to: T | null;
288
+ };
289
+ /** Recursively maps each field to either its unchanged value, a Change, or a nested diff. */
290
+ type DiffResult<T extends Record<string, any>> = { [K in keyof T]?: T[K] extends Record<string, any> ? DiffResult<T[K]> | Change<T[K]> : T[K] | Change<T[K]> };
291
+ declare function diff<T extends Record<string, any>>(a: T, b: T, removeUnchanged?: boolean): DiffResult<T>;
292
+ /**
293
+ * Check if a diff entry represents a changed value (has `from`/`to` shape).
294
+ */
295
+ declare function isChange<T = any>(value: any): value is Change<T>;
296
+ /**
297
+ * Check if any direct child of the diff object has changes.
298
+ */
299
+ declare function hasChanges<T extends Record<string, any>>(diffObj: DiffResult<T> | Record<string, unknown> | null | undefined): boolean;
300
+ //#endregion
301
+ export { type AaveV3Config, type AaveV3Emode, type AaveV3Reserve, type AaveV3Snapshot, type AaveV3Strategy, type CHAIN_ID, type Change, type DiffResult, type Log, type RawStorage, type SlotDiff, type ValueDiff, diff, diffSnapshots, hasChanges, isChange };
@@ -0,0 +1,301 @@
1
+ import { Hex } from "viem";
2
+ import { z } from "zod";
3
+
4
+ //#region snapshot-types.d.ts
5
+ declare const CHAIN_ID: {
6
+ readonly MAINNET: 1;
7
+ readonly OPTIMISM: 10;
8
+ readonly POLYGON: 137;
9
+ readonly FANTOM: 250;
10
+ readonly ARBITRUM: 42161;
11
+ readonly AVALANCHE: 43114;
12
+ readonly METIS: 1088;
13
+ readonly BASE: 8453;
14
+ readonly SCROLL: 534352;
15
+ readonly BNB: 56;
16
+ readonly GNOSIS: 100;
17
+ readonly CELO: 42220;
18
+ readonly ZKSYNC: 324;
19
+ };
20
+ declare const zodChainId: z.ZodEnum<{
21
+ readonly MAINNET: 1;
22
+ readonly OPTIMISM: 10;
23
+ readonly POLYGON: 137;
24
+ readonly FANTOM: 250;
25
+ readonly ARBITRUM: 42161;
26
+ readonly AVALANCHE: 43114;
27
+ readonly METIS: 1088;
28
+ readonly BASE: 8453;
29
+ readonly SCROLL: 534352;
30
+ readonly BNB: 56;
31
+ readonly GNOSIS: 100;
32
+ readonly CELO: 42220;
33
+ readonly ZKSYNC: 324;
34
+ }>;
35
+ type CHAIN_ID = z.infer<typeof zodChainId>;
36
+ declare const aaveV3ConfigSchema: z.ZodObject<{
37
+ oracle: z.ZodString;
38
+ pool: z.ZodString;
39
+ poolAddressesProvider: z.ZodString;
40
+ poolConfigurator: z.ZodString;
41
+ priceOracleSentinel: z.ZodString;
42
+ protocolDataProvider: z.ZodString;
43
+ }, z.core.$strip>;
44
+ type AaveV3Config = z.infer<typeof aaveV3ConfigSchema>;
45
+ declare const aaveV3ReserveSchema: z.ZodObject<{
46
+ id: z.ZodNumber;
47
+ symbol: z.ZodString;
48
+ underlying: z.ZodString;
49
+ decimals: z.ZodNumber;
50
+ isActive: z.ZodBoolean;
51
+ isFrozen: z.ZodBoolean;
52
+ isPaused: z.ZodBoolean;
53
+ isSiloed: z.ZodBoolean;
54
+ isFlashloanable: z.ZodBoolean;
55
+ isBorrowableInIsolation: z.ZodBoolean;
56
+ borrowingEnabled: z.ZodBoolean;
57
+ usageAsCollateralEnabled: z.ZodBoolean;
58
+ ltv: z.ZodNumber;
59
+ liquidationThreshold: z.ZodNumber;
60
+ liquidationBonus: z.ZodNumber;
61
+ liquidationProtocolFee: z.ZodNumber;
62
+ reserveFactor: z.ZodNumber;
63
+ supplyCap: z.ZodNumber;
64
+ borrowCap: z.ZodNumber;
65
+ debtCeiling: z.ZodNumber;
66
+ oracle: z.ZodString;
67
+ oracleDecimals: z.ZodNumber;
68
+ oracleDescription: z.ZodOptional<z.ZodString>;
69
+ oracleName: z.ZodOptional<z.ZodString>;
70
+ oracleLatestAnswer: z.ZodString;
71
+ interestRateStrategy: z.ZodString;
72
+ aToken: z.ZodString;
73
+ aTokenName: z.ZodString;
74
+ aTokenSymbol: z.ZodString;
75
+ aTokenUnderlyingBalance: z.ZodString;
76
+ variableDebtToken: z.ZodString;
77
+ variableDebtTokenName: z.ZodString;
78
+ variableDebtTokenSymbol: z.ZodString;
79
+ virtualBalance: z.ZodString;
80
+ }, z.core.$strip>;
81
+ type AaveV3Reserve = z.infer<typeof aaveV3ReserveSchema>;
82
+ declare const aaveV3StrategySchema: z.ZodObject<{
83
+ address: z.ZodString;
84
+ baseVariableBorrowRate: z.ZodString;
85
+ optimalUsageRatio: z.ZodString;
86
+ variableRateSlope1: z.ZodString;
87
+ variableRateSlope2: z.ZodString;
88
+ maxVariableBorrowRate: z.ZodString;
89
+ }, z.core.$strip>;
90
+ type AaveV3Strategy = z.infer<typeof aaveV3StrategySchema>;
91
+ declare const aaveV3EmodeSchema: z.ZodObject<{
92
+ eModeCategory: z.ZodNumber;
93
+ label: z.ZodString;
94
+ ltv: z.ZodNumber;
95
+ liquidationThreshold: z.ZodNumber;
96
+ liquidationBonus: z.ZodNumber;
97
+ priceSource: z.ZodOptional<z.ZodString>;
98
+ borrowableBitmap: z.ZodString;
99
+ collateralBitmap: z.ZodString;
100
+ }, z.core.$strip>;
101
+ type AaveV3Emode = z.infer<typeof aaveV3EmodeSchema>;
102
+ declare const slotDiffSchema: z.ZodObject<{
103
+ previousValue: z.ZodType<Hex>;
104
+ newValue: z.ZodType<Hex>;
105
+ label: z.ZodOptional<z.ZodString>;
106
+ type: z.ZodOptional<z.ZodString>;
107
+ offset: z.ZodOptional<z.ZodNumber>;
108
+ slot: z.ZodOptional<z.ZodString>;
109
+ decoded: z.ZodOptional<z.ZodObject<{
110
+ previousValue: z.ZodString;
111
+ newValue: z.ZodString;
112
+ }, z.core.$strip>>;
113
+ key: z.ZodOptional<z.ZodString>;
114
+ }, z.core.$strip>;
115
+ type SlotDiff = z.infer<typeof slotDiffSchema>;
116
+ declare const valueDiffSchema: z.ZodObject<{
117
+ previousValue: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
118
+ newValue: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
119
+ }, z.core.$strip>;
120
+ type ValueDiff = z.infer<typeof valueDiffSchema>;
121
+ declare const rawStorageSchema: z.ZodRecord<z.ZodType<`0x${string}`, unknown, z.core.$ZodTypeInternals<`0x${string}`, unknown>>, z.ZodObject<{
122
+ label: z.ZodNullable<z.ZodString>;
123
+ contract: z.ZodNullable<z.ZodString>;
124
+ balanceDiff: z.ZodNullable<z.ZodObject<{
125
+ previousValue: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
126
+ newValue: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
127
+ }, z.core.$strip>>;
128
+ nonceDiff: z.ZodNullable<z.ZodObject<{
129
+ previousValue: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
130
+ newValue: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
131
+ }, z.core.$strip>>;
132
+ stateDiff: z.ZodRecord<z.ZodString, z.ZodObject<{
133
+ previousValue: z.ZodType<Hex>;
134
+ newValue: z.ZodType<Hex>;
135
+ label: z.ZodOptional<z.ZodString>;
136
+ type: z.ZodOptional<z.ZodString>;
137
+ offset: z.ZodOptional<z.ZodNumber>;
138
+ slot: z.ZodOptional<z.ZodString>;
139
+ decoded: z.ZodOptional<z.ZodObject<{
140
+ previousValue: z.ZodString;
141
+ newValue: z.ZodString;
142
+ }, z.core.$strip>>;
143
+ key: z.ZodOptional<z.ZodString>;
144
+ }, z.core.$strip>>;
145
+ }, z.core.$strip>>;
146
+ type RawStorage = z.infer<typeof rawStorageSchema>;
147
+ declare const logSchema: z.ZodObject<{
148
+ topics: z.ZodArray<z.ZodString>;
149
+ data: z.ZodString;
150
+ emitter: z.ZodString;
151
+ }, z.core.$strip>;
152
+ type Log = z.infer<typeof logSchema>;
153
+ declare const aaveV3SnapshotSchema: z.ZodObject<{
154
+ chainId: z.ZodEnum<{
155
+ readonly MAINNET: 1;
156
+ readonly OPTIMISM: 10;
157
+ readonly POLYGON: 137;
158
+ readonly FANTOM: 250;
159
+ readonly ARBITRUM: 42161;
160
+ readonly AVALANCHE: 43114;
161
+ readonly METIS: 1088;
162
+ readonly BASE: 8453;
163
+ readonly SCROLL: 534352;
164
+ readonly BNB: 56;
165
+ readonly GNOSIS: 100;
166
+ readonly CELO: 42220;
167
+ readonly ZKSYNC: 324;
168
+ }>;
169
+ reserves: z.ZodRecord<z.ZodString, z.ZodObject<{
170
+ id: z.ZodNumber;
171
+ symbol: z.ZodString;
172
+ underlying: z.ZodString;
173
+ decimals: z.ZodNumber;
174
+ isActive: z.ZodBoolean;
175
+ isFrozen: z.ZodBoolean;
176
+ isPaused: z.ZodBoolean;
177
+ isSiloed: z.ZodBoolean;
178
+ isFlashloanable: z.ZodBoolean;
179
+ isBorrowableInIsolation: z.ZodBoolean;
180
+ borrowingEnabled: z.ZodBoolean;
181
+ usageAsCollateralEnabled: z.ZodBoolean;
182
+ ltv: z.ZodNumber;
183
+ liquidationThreshold: z.ZodNumber;
184
+ liquidationBonus: z.ZodNumber;
185
+ liquidationProtocolFee: z.ZodNumber;
186
+ reserveFactor: z.ZodNumber;
187
+ supplyCap: z.ZodNumber;
188
+ borrowCap: z.ZodNumber;
189
+ debtCeiling: z.ZodNumber;
190
+ oracle: z.ZodString;
191
+ oracleDecimals: z.ZodNumber;
192
+ oracleDescription: z.ZodOptional<z.ZodString>;
193
+ oracleName: z.ZodOptional<z.ZodString>;
194
+ oracleLatestAnswer: z.ZodString;
195
+ interestRateStrategy: z.ZodString;
196
+ aToken: z.ZodString;
197
+ aTokenName: z.ZodString;
198
+ aTokenSymbol: z.ZodString;
199
+ aTokenUnderlyingBalance: z.ZodString;
200
+ variableDebtToken: z.ZodString;
201
+ variableDebtTokenName: z.ZodString;
202
+ variableDebtTokenSymbol: z.ZodString;
203
+ virtualBalance: z.ZodString;
204
+ }, z.core.$strip>>;
205
+ strategies: z.ZodRecord<z.ZodString, z.ZodObject<{
206
+ address: z.ZodString;
207
+ baseVariableBorrowRate: z.ZodString;
208
+ optimalUsageRatio: z.ZodString;
209
+ variableRateSlope1: z.ZodString;
210
+ variableRateSlope2: z.ZodString;
211
+ maxVariableBorrowRate: z.ZodString;
212
+ }, z.core.$strip>>;
213
+ eModes: z.ZodRecord<z.ZodString, z.ZodObject<{
214
+ eModeCategory: z.ZodNumber;
215
+ label: z.ZodString;
216
+ ltv: z.ZodNumber;
217
+ liquidationThreshold: z.ZodNumber;
218
+ liquidationBonus: z.ZodNumber;
219
+ priceSource: z.ZodOptional<z.ZodString>;
220
+ borrowableBitmap: z.ZodString;
221
+ collateralBitmap: z.ZodString;
222
+ }, z.core.$strip>>;
223
+ poolConfig: z.ZodObject<{
224
+ oracle: z.ZodString;
225
+ pool: z.ZodString;
226
+ poolAddressesProvider: z.ZodString;
227
+ poolConfigurator: z.ZodString;
228
+ priceOracleSentinel: z.ZodString;
229
+ protocolDataProvider: z.ZodString;
230
+ }, z.core.$strip>;
231
+ raw: z.ZodOptional<z.ZodRecord<z.ZodType<`0x${string}`, unknown, z.core.$ZodTypeInternals<`0x${string}`, unknown>>, z.ZodObject<{
232
+ label: z.ZodNullable<z.ZodString>;
233
+ contract: z.ZodNullable<z.ZodString>;
234
+ balanceDiff: z.ZodNullable<z.ZodObject<{
235
+ previousValue: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
236
+ newValue: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
237
+ }, z.core.$strip>>;
238
+ nonceDiff: z.ZodNullable<z.ZodObject<{
239
+ previousValue: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
240
+ newValue: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
241
+ }, z.core.$strip>>;
242
+ stateDiff: z.ZodRecord<z.ZodString, z.ZodObject<{
243
+ previousValue: z.ZodType<Hex>;
244
+ newValue: z.ZodType<Hex>;
245
+ label: z.ZodOptional<z.ZodString>;
246
+ type: z.ZodOptional<z.ZodString>;
247
+ offset: z.ZodOptional<z.ZodNumber>;
248
+ slot: z.ZodOptional<z.ZodString>;
249
+ decoded: z.ZodOptional<z.ZodObject<{
250
+ previousValue: z.ZodString;
251
+ newValue: z.ZodString;
252
+ }, z.core.$strip>>;
253
+ key: z.ZodOptional<z.ZodString>;
254
+ }, z.core.$strip>>;
255
+ }, z.core.$strip>>>;
256
+ logs: z.ZodOptional<z.ZodArray<z.ZodObject<{
257
+ topics: z.ZodArray<z.ZodString>;
258
+ data: z.ZodString;
259
+ emitter: z.ZodString;
260
+ }, z.core.$strip>>>;
261
+ }, z.core.$strip>;
262
+ type AaveV3Snapshot = z.infer<typeof aaveV3SnapshotSchema>;
263
+ //#endregion
264
+ //#region protocol-diff.d.ts
265
+ /**
266
+ * Diff two Aave V3 protocol snapshots and produce a formatted markdown report.
267
+ *
268
+ * The `raw` and `logs` sections only exist in the "after" snapshot and are
269
+ * rendered as-is (they already represent the diff / changes).
270
+ */
271
+ declare function diffSnapshots(before: AaveV3Snapshot, after: AaveV3Snapshot): Promise<string>;
272
+ //#endregion
273
+ //#region diff.d.ts
274
+ /**
275
+ * Generic recursive object diff.
276
+ *
277
+ * For each key present in either `a` or `b`:
278
+ * - If both have the key and the values are objects, recurse.
279
+ * - If both have the key and the values are equal primitives, keep as-is (or omit if `removeUnchanged`).
280
+ * - If both have the key but values differ, produce `{ from, to }`.
281
+ * - If only `a` has the key, produce `{ from: value, to: null }`.
282
+ * - If only `b` has the key, produce `{ from: null, to: value }`.
283
+ */
284
+ /** A changed field: carries the old and new value. */
285
+ type Change<T> = {
286
+ from: T | null;
287
+ to: T | null;
288
+ };
289
+ /** Recursively maps each field to either its unchanged value, a Change, or a nested diff. */
290
+ type DiffResult<T extends Record<string, any>> = { [K in keyof T]?: T[K] extends Record<string, any> ? DiffResult<T[K]> | Change<T[K]> : T[K] | Change<T[K]> };
291
+ declare function diff<T extends Record<string, any>>(a: T, b: T, removeUnchanged?: boolean): DiffResult<T>;
292
+ /**
293
+ * Check if a diff entry represents a changed value (has `from`/`to` shape).
294
+ */
295
+ declare function isChange<T = any>(value: any): value is Change<T>;
296
+ /**
297
+ * Check if any direct child of the diff object has changes.
298
+ */
299
+ declare function hasChanges<T extends Record<string, any>>(diffObj: DiffResult<T> | Record<string, unknown> | null | undefined): boolean;
300
+ //#endregion
301
+ export { type AaveV3Config, type AaveV3Emode, type AaveV3Reserve, type AaveV3Snapshot, type AaveV3Strategy, type CHAIN_ID, type Change, type DiffResult, type Log, type RawStorage, type SlotDiff, type ValueDiff, diff, diffSnapshots, hasChanges, isChange };
package/dist/index.mjs ADDED
@@ -0,0 +1,3 @@
1
+ import { i as isChange, n as diff, r as hasChanges, t as diffSnapshots } from "./protocol-diff-M_rYNx6y.mjs";
2
+
3
+ export { diff, diffSnapshots, hasChanges, isChange };