@gvnrdao/dh-sdk 0.0.327 → 0.0.329

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.
@@ -521,6 +521,14 @@ var MAINNET_DEPLOYMENT = {
521
521
  reason: "2026-08 agent-stack release. The mainnet PositionManagerViews at 0x9225647a was deployed as a BARE implementation (EIP-1967 slot 0x00), so upgradeToAndCall reverts UUPSUnauthorizedCallContext \u2014 it could never be upgraded. PositionManager.setViews (added in the same Execute B batch) removed the repoint blocker, so Views was replaced behind a new proxy rather than upgraded. This makes the Pashov F3 renewal debt-ceiling check REACHABLE for the first time: ExceedsMaxLoan (0x499e7985) is present in 0xE68DC096 and absent from 0x9225647a. Views holds no protocol state (8 wiring slots + roles + pause), which is what made replacement safe. The old contract is ABANDONED, not decommissioned \u2014 it stays live and callable as the rollback target for setViews. NOTE: VERSION reads 1.1.1 on both sides; verify by address.",
522
522
  executeTx: "0xf1f8d5fc13f45d7a3f932bf1a2d6e29381fdd41cd31298ad785bf7688df07fe6",
523
523
  block: 25673200
524
+ },
525
+ AgentDelegationRegistry: {
526
+ newImplementation: "0xa9fF405Edd4329fc3159a64F56B37EBD253e4928",
527
+ upgradedAt: "2026-07-31T22:03:35.000Z",
528
+ upgradedBy: "AdminModule/Safe audit-batch upgradeToAndCall; executed by 0xEba7BfAeB35ee18408b424Ee0BB45AdDf776589f in tx 0x8fed0ab7eee3aaaa3792a35b40b0ef74bd09cfb1a175934afd846bee546048d4 (block 25655710)",
529
+ reason: "Reconciled from chain \u2014 mainnet audit rollout batch (cross-ref onchain-auth/.safe-batches/mainnet-audit-execute.json)",
530
+ executeTx: "0x8fed0ab7eee3aaaa3792a35b40b0ef74bd09cfb1a175934afd846bee546048d4",
531
+ block: 25655710
524
532
  }
525
533
  },
526
534
  latestEnv: {
@@ -488,6 +488,14 @@ var MAINNET_DEPLOYMENT = {
488
488
  reason: "2026-08 agent-stack release. The mainnet PositionManagerViews at 0x9225647a was deployed as a BARE implementation (EIP-1967 slot 0x00), so upgradeToAndCall reverts UUPSUnauthorizedCallContext \u2014 it could never be upgraded. PositionManager.setViews (added in the same Execute B batch) removed the repoint blocker, so Views was replaced behind a new proxy rather than upgraded. This makes the Pashov F3 renewal debt-ceiling check REACHABLE for the first time: ExceedsMaxLoan (0x499e7985) is present in 0xE68DC096 and absent from 0x9225647a. Views holds no protocol state (8 wiring slots + roles + pause), which is what made replacement safe. The old contract is ABANDONED, not decommissioned \u2014 it stays live and callable as the rollback target for setViews. NOTE: VERSION reads 1.1.1 on both sides; verify by address.",
489
489
  executeTx: "0xf1f8d5fc13f45d7a3f932bf1a2d6e29381fdd41cd31298ad785bf7688df07fe6",
490
490
  block: 25673200
491
+ },
492
+ AgentDelegationRegistry: {
493
+ newImplementation: "0xa9fF405Edd4329fc3159a64F56B37EBD253e4928",
494
+ upgradedAt: "2026-07-31T22:03:35.000Z",
495
+ upgradedBy: "AdminModule/Safe audit-batch upgradeToAndCall; executed by 0xEba7BfAeB35ee18408b424Ee0BB45AdDf776589f in tx 0x8fed0ab7eee3aaaa3792a35b40b0ef74bd09cfb1a175934afd846bee546048d4 (block 25655710)",
496
+ reason: "Reconciled from chain \u2014 mainnet audit rollout batch (cross-ref onchain-auth/.safe-batches/mainnet-audit-execute.json)",
497
+ executeTx: "0x8fed0ab7eee3aaaa3792a35b40b0ef74bd09cfb1a175934afd846bee546048d4",
498
+ block: 25655710
491
499
  }
492
500
  },
493
501
  latestEnv: {
@@ -86,6 +86,174 @@ export interface UserRateLimitData {
86
86
  nextResetBlock: string;
87
87
  lastUpdated: string;
88
88
  }
89
+ export interface LoanEventsQueryResponse {
90
+ position: {
91
+ id: string;
92
+ payments?: Array<{
93
+ id: string;
94
+ payer: {
95
+ id: string;
96
+ };
97
+ amount: string;
98
+ type: string;
99
+ transactionHash: string;
100
+ timestamp: string;
101
+ blockNumber: string;
102
+ logIndex: string;
103
+ newDebt: string;
104
+ newCollateralRatio: string;
105
+ }>;
106
+ statusUpdates?: Array<{
107
+ id: string;
108
+ oldStatus: string;
109
+ newStatus: string;
110
+ reason?: string;
111
+ timestamp: string;
112
+ blockNumber: string;
113
+ transactionHash: string;
114
+ }>;
115
+ liquidation?: {
116
+ id: string;
117
+ liquidator: string;
118
+ liquidatedAmount: string;
119
+ collateralSeized: string;
120
+ transactionHash: string;
121
+ timestamp: string;
122
+ blockNumber: string;
123
+ commitHash?: string;
124
+ commitTimestamp?: string;
125
+ revealDelay?: string;
126
+ };
127
+ withdrawals?: Array<{
128
+ id: string;
129
+ withdrawalAmount: string;
130
+ withdrawalAddress: string;
131
+ networkFee?: string;
132
+ timestamp: string;
133
+ blockNumber: string;
134
+ transactionHash: string;
135
+ logIndex: string;
136
+ }>;
137
+ renewals?: Array<{
138
+ id: string;
139
+ extensionTerm: string;
140
+ extensionFee: string;
141
+ newExpiryDate: string;
142
+ timestamp: string;
143
+ blockNumber: string;
144
+ transactionHash: string;
145
+ logIndex: string;
146
+ }>;
147
+ operationFailures?: Array<{
148
+ id: string;
149
+ operationType: string;
150
+ reason: string;
151
+ errorCode?: string;
152
+ amount?: string;
153
+ timestamp: string;
154
+ blockNumber: string;
155
+ transactionHash: string;
156
+ logIndex: string;
157
+ }>;
158
+ mintRequests?: Array<{
159
+ id: string;
160
+ pkpId: string;
161
+ borrower: {
162
+ id: string;
163
+ };
164
+ mintAmount: string;
165
+ originationFee: string;
166
+ newDebt: string;
167
+ newCollateralRatio: string;
168
+ btcPrice: string;
169
+ quantumTimestamp: string;
170
+ opId: string;
171
+ timestamp: string;
172
+ blockNumber: string;
173
+ transactionHash: string;
174
+ logIndex: string;
175
+ }>;
176
+ burnRequests?: Array<{
177
+ id: string;
178
+ pkpId: string;
179
+ borrower: {
180
+ id: string;
181
+ };
182
+ burnAmount: string;
183
+ remainingDebt: string;
184
+ newCollateralRatio: string;
185
+ opId: string;
186
+ timestamp: string;
187
+ blockNumber: string;
188
+ transactionHash: string;
189
+ logIndex: string;
190
+ }>;
191
+ mintingFees?: Array<{
192
+ id: string;
193
+ borrower: {
194
+ id: string;
195
+ };
196
+ feeAmount: string;
197
+ mintAmount: string;
198
+ newDebt: string;
199
+ btcPrice: string;
200
+ quantumTimestamp: string;
201
+ timestamp: string;
202
+ blockNumber: string;
203
+ transactionHash: string;
204
+ logIndex: string;
205
+ }>;
206
+ renewalFees?: Array<{
207
+ id: string;
208
+ borrower: {
209
+ id: string;
210
+ };
211
+ feeAmount: string;
212
+ extensionTerm: string;
213
+ newExpiryDate: string;
214
+ timestamp: string;
215
+ blockNumber: string;
216
+ transactionHash: string;
217
+ logIndex: string;
218
+ }>;
219
+ };
220
+ positionCreatedEvents?: Array<{
221
+ id: string;
222
+ pkpId: string;
223
+ borrower: {
224
+ id: string;
225
+ };
226
+ requestedCollateralRatio: string;
227
+ selectedTerm: string;
228
+ expiryAt: string;
229
+ timestamp: string;
230
+ blockNumber: string;
231
+ transactionHash: string;
232
+ }>;
233
+ ucdmintEvents?: Array<{
234
+ id: string;
235
+ amount: string;
236
+ proof: string;
237
+ minter: {
238
+ id: string;
239
+ };
240
+ isCommunityMint: boolean;
241
+ timestamp: string;
242
+ blockNumber: string;
243
+ transactionHash: string;
244
+ }>;
245
+ collateralEvents?: Array<{
246
+ id: string;
247
+ eventType: string;
248
+ networkFee?: string;
249
+ remainingCollateral?: string;
250
+ collateralRatio?: string;
251
+ timestamp: string;
252
+ blockNumber: string;
253
+ transactionHash: string;
254
+ logIndex: string;
255
+ }>;
256
+ }
89
257
  export declare class DiamondHandsGraph {
90
258
  private client;
91
259
  private defaultPageSize;
@@ -115,6 +283,15 @@ export declare class DiamondHandsGraph {
115
283
  /**
116
284
  * Get user positions from subgraph
117
285
  */
286
+ private getUserPositionsOnly;
287
+ /**
288
+ * Get user positions, plus an accurate total count.
289
+ *
290
+ * The count is a SECOND round trip (`getTotalCountPaginated`, which pages to handle
291
+ * >1000 items). Callers that only need the rows should use `getUserPositionsOnly` and
292
+ * skip it — the event paths did not, and paid for a count they immediately discarded on
293
+ * every activity refresh.
294
+ */
118
295
  getUserPositions(userAddress: string, first?: number, skip?: number, orderBy?: string, orderDirection?: string): Promise<{
119
296
  positions: LoanData[];
120
297
  total: number;
@@ -262,6 +439,14 @@ export declare class DiamondHandsGraph {
262
439
  * @returns Complete event history for the position
263
440
  */
264
441
  getLoanEvents(positionId: string, filter?: LoanEventsFilter): Promise<LoanEvents>;
442
+ /**
443
+ * Map one position's raw event payload into `LoanEvents`.
444
+ *
445
+ * Extracted verbatim from getLoanEvents so the wallet-collapsed path produces
446
+ * byte-identical objects by construction rather than by a second implementation
447
+ * that has to be kept in step by hand.
448
+ */
449
+ private assembleLoanEvents;
265
450
  /**
266
451
  * Get the full loan-event history for every position owned by a wallet.
267
452
  *
@@ -280,6 +465,31 @@ export declare class DiamondHandsGraph {
280
465
  * @returns One LoanEvents object per position; empty array if the wallet has none.
281
466
  */
282
467
  getWalletLoanEvents(userAddress: string, filter?: LoanEventsFilter): Promise<LoanEvents[]>;
468
+ /**
469
+ * The per-position path: enumerate the wallet's positions, then one `GetLoanEvents` each.
470
+ *
471
+ * Used for filtered calls, and as the completeness fallback when the collapsed document
472
+ * hits a page limit. Costs `1 + N` requests, which is exactly why it is not the default.
473
+ */
474
+ private getWalletLoanEventsFanout;
475
+ /**
476
+ * The whole wallet's event history in ONE request.
477
+ *
478
+ * Replaces `1 + N` round trips (one position enumeration plus one per position) with a
479
+ * single document. Measured on Sepolia: a wallet holding 44 positions cost 46 requests
480
+ * per activity refresh against a per-wallet budget of 30/min — this makes it 1.
481
+ *
482
+ * Three subgraph facts make it possible, all verified against the deployed schema rather
483
+ * than assumed:
484
+ * - ten event collections are `@derivedFrom` on Position, so they nest under a
485
+ * borrower-filtered `positions(...)`;
486
+ * - `positionCreatedEvents` is ALSO derived on Position — `getLoanEvents` queries it
487
+ * top-level, which it never needed to;
488
+ * - `ucdmintEvents` / `collateralEvents` are not derived and carry no `borrower`
489
+ * field, but graph-node's nested `position_: { borrower }` filter reaches them.
490
+ * Without that last one this would be two requests, not one.
491
+ */
492
+ private getWalletLoanEventsCollapsed;
283
493
  /**
284
494
  * Retrieve events across the full protocol, optionally narrowed to a position.
285
495
  * Returns a merged, sorted discriminated-union timeline suitable for explorers.