@gvnrdao/dh-sdk 0.0.210 → 0.0.211

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -41,7 +41,7 @@ export type { DiamondHandsSDKConfig, SDKMode, ContractAddresses, BitcoinProvider
41
41
  export type { PKPData, PKPCreationRequest, PKPCreationResult, PKPValidationResult, } from './interfaces/chunks/pkp-integration.i';
42
42
  export type { AuthorizationRequest, AuthorizationResult, BTCDepositRequest, BTCDepositResult, } from './interfaces/chunks/requests.i';
43
43
  export { LoanStatus } from './types/loanStatus';
44
- export type { LoanEvents, LoanEventsFilter, PaymentEvent, StatusUpdateEvent, LiquidationEvent, UCDMintEvent, FeeDistributionEvent, } from './types/event-types';
44
+ export type { LoanEvents, LoanEventsFilter, PaymentEvent, StatusUpdateEvent, LiquidationEvent, UCDMintEvent, FeeDistributionEvent, WithdrawalEvent, RenewalEvent, } from './types/event-types';
45
45
  export { PaymentType, PositionStatus, isValidPositionStatus, isValidPaymentType, numericToPositionStatus, EventHelpers, } from './types/event-types';
46
46
  export { fetchProtocolPauseStatus, assertProtocolNotPaused, } from './protocol/protocol-pause';
47
47
  export type { ProtocolPauseStatus, ProtocolPauseKey, } from './protocol/protocol-pause';
package/dist/index.js CHANGED
@@ -36262,7 +36262,8 @@ var DiamondHandsGraph = class {
36262
36262
  status: !eventTypes || eventTypes.includes("status"),
36263
36263
  liquidation: !eventTypes || eventTypes.includes("liquidation"),
36264
36264
  mint: !eventTypes || eventTypes.includes("mint"),
36265
- fee: !eventTypes || eventTypes.includes("fee")
36265
+ withdrawal: !eventTypes || eventTypes.includes("withdrawal"),
36266
+ renewal: !eventTypes || eventTypes.includes("renewal")
36266
36267
  };
36267
36268
  const query = `
36268
36269
  query GetLoanEvents($positionId: Bytes!, $limit: Int!, $orderDirection: OrderDirection!) {
@@ -36319,28 +36320,45 @@ var DiamondHandsGraph = class {
36319
36320
  revealDelay
36320
36321
  }
36321
36322
  ` : ""}
36323
+
36324
+ ${shouldQuery.withdrawal ? `
36325
+ withdrawals(
36326
+ first: $limit,
36327
+ orderBy: timestamp,
36328
+ orderDirection: $orderDirection
36329
+ ) {
36330
+ id
36331
+ withdrawalAmount
36332
+ withdrawalAddress
36333
+ networkFee
36334
+ timestamp
36335
+ blockNumber
36336
+ transactionHash
36337
+ logIndex
36338
+ }
36339
+ ` : ""}
36340
+
36341
+ ${shouldQuery.renewal ? `
36342
+ renewals(
36343
+ first: $limit,
36344
+ orderBy: timestamp,
36345
+ orderDirection: $orderDirection
36346
+ ) {
36347
+ id
36348
+ extensionTerm
36349
+ extensionFee
36350
+ newExpiryDate
36351
+ timestamp
36352
+ blockNumber
36353
+ transactionHash
36354
+ logIndex
36355
+ }
36356
+ ` : ""}
36322
36357
  }
36323
36358
 
36324
36359
 
36325
36360
  # TODO: Re-enable ucdMintEvents query when subgraph schema is updated
36326
36361
  # ${shouldQuery.mint ? `ucdMintEvents(...)` : ""}
36327
-
36328
- ${shouldQuery.fee ? `
36329
- communityFeeDistributions(
36330
- ${buildWhereClause()}
36331
- first: $limit,
36332
- orderBy: timestamp,
36333
- orderDirection: $orderDirection
36334
- ) {
36335
- id
36336
- recipient { id }
36337
- amount
36338
- feeType
36339
- timestamp
36340
- blockNumber
36341
- transactionHash
36342
- }
36343
- ` : ""}
36344
36362
  }
36345
36363
  `;
36346
36364
  const variables = {
@@ -36398,24 +36416,38 @@ var DiamondHandsGraph = class {
36398
36416
  blockNumber: m.blockNumber,
36399
36417
  transactionHash: m.transactionHash
36400
36418
  }));
36401
- const feeDistributions = (result.communityFeeDistributions || []).map((f) => ({
36402
- id: f.id,
36419
+ const withdrawals = (result.position?.withdrawals || []).map((w) => ({
36420
+ id: w.id,
36421
+ positionId,
36422
+ withdrawalAmount: w.withdrawalAmount,
36423
+ withdrawalAddress: w.withdrawalAddress,
36424
+ networkFee: w.networkFee,
36425
+ timestamp: w.timestamp,
36426
+ blockNumber: w.blockNumber,
36427
+ transactionHash: w.transactionHash,
36428
+ logIndex: w.logIndex
36429
+ }));
36430
+ const renewals = (result.position?.renewals || []).map((r2) => ({
36431
+ id: r2.id,
36403
36432
  positionId,
36404
- recipient: f.recipient.id,
36405
- amount: f.amount,
36406
- feeType: f.feeType,
36407
- timestamp: f.timestamp,
36408
- blockNumber: f.blockNumber,
36409
- transactionHash: f.transactionHash
36433
+ extensionTerm: r2.extensionTerm,
36434
+ extensionFee: r2.extensionFee,
36435
+ newExpiryDate: r2.newExpiryDate,
36436
+ timestamp: r2.timestamp,
36437
+ blockNumber: r2.blockNumber,
36438
+ transactionHash: r2.transactionHash,
36439
+ logIndex: r2.logIndex
36410
36440
  }));
36411
- const totalEvents = payments.length + statusUpdates.length + (liquidation ? 1 : 0) + mints.length + feeDistributions.length;
36441
+ const totalEvents = payments.length + statusUpdates.length + (liquidation ? 1 : 0) + mints.length + withdrawals.length + renewals.length;
36412
36442
  return {
36413
36443
  positionId,
36414
36444
  payments,
36415
36445
  statusUpdates,
36416
36446
  liquidation,
36417
36447
  mints,
36418
- feeDistributions,
36448
+ withdrawals,
36449
+ renewals,
36450
+ feeDistributions: [],
36419
36451
  totalEvents
36420
36452
  };
36421
36453
  }
@@ -43175,7 +43207,7 @@ var EventHelpers = {
43175
43207
  * Get total count of all events
43176
43208
  */
43177
43209
  getTotalCount(events) {
43178
- return events.payments.length + events.statusUpdates.length + (events.liquidation ? 1 : 0) + events.mints.length + events.feeDistributions.length;
43210
+ return events.payments.length + events.statusUpdates.length + (events.liquidation ? 1 : 0) + events.mints.length + events.withdrawals.length + events.renewals.length;
43179
43211
  },
43180
43212
  /**
43181
43213
  * Merge and sort all events by timestamp
@@ -43186,7 +43218,8 @@ var EventHelpers = {
43186
43218
  ...events.statusUpdates.map((e) => ({ ...e, eventType: "status" })),
43187
43219
  ...events.liquidation ? [{ ...events.liquidation, eventType: "liquidation" }] : [],
43188
43220
  ...events.mints.map((e) => ({ ...e, eventType: "mint" })),
43189
- ...events.feeDistributions.map((e) => ({ ...e, eventType: "fee" }))
43221
+ ...events.withdrawals.map((e) => ({ ...e, eventType: "withdrawal" })),
43222
+ ...events.renewals.map((e) => ({ ...e, eventType: "renewal" }))
43190
43223
  ];
43191
43224
  return allEvents.sort((a, b) => {
43192
43225
  const diff = BigInt(a.timestamp) - BigInt(b.timestamp);
package/dist/index.mjs CHANGED
@@ -36190,7 +36190,8 @@ var DiamondHandsGraph = class {
36190
36190
  status: !eventTypes || eventTypes.includes("status"),
36191
36191
  liquidation: !eventTypes || eventTypes.includes("liquidation"),
36192
36192
  mint: !eventTypes || eventTypes.includes("mint"),
36193
- fee: !eventTypes || eventTypes.includes("fee")
36193
+ withdrawal: !eventTypes || eventTypes.includes("withdrawal"),
36194
+ renewal: !eventTypes || eventTypes.includes("renewal")
36194
36195
  };
36195
36196
  const query = `
36196
36197
  query GetLoanEvents($positionId: Bytes!, $limit: Int!, $orderDirection: OrderDirection!) {
@@ -36247,28 +36248,45 @@ var DiamondHandsGraph = class {
36247
36248
  revealDelay
36248
36249
  }
36249
36250
  ` : ""}
36251
+
36252
+ ${shouldQuery.withdrawal ? `
36253
+ withdrawals(
36254
+ first: $limit,
36255
+ orderBy: timestamp,
36256
+ orderDirection: $orderDirection
36257
+ ) {
36258
+ id
36259
+ withdrawalAmount
36260
+ withdrawalAddress
36261
+ networkFee
36262
+ timestamp
36263
+ blockNumber
36264
+ transactionHash
36265
+ logIndex
36266
+ }
36267
+ ` : ""}
36268
+
36269
+ ${shouldQuery.renewal ? `
36270
+ renewals(
36271
+ first: $limit,
36272
+ orderBy: timestamp,
36273
+ orderDirection: $orderDirection
36274
+ ) {
36275
+ id
36276
+ extensionTerm
36277
+ extensionFee
36278
+ newExpiryDate
36279
+ timestamp
36280
+ blockNumber
36281
+ transactionHash
36282
+ logIndex
36283
+ }
36284
+ ` : ""}
36250
36285
  }
36251
36286
 
36252
36287
 
36253
36288
  # TODO: Re-enable ucdMintEvents query when subgraph schema is updated
36254
36289
  # ${shouldQuery.mint ? `ucdMintEvents(...)` : ""}
36255
-
36256
- ${shouldQuery.fee ? `
36257
- communityFeeDistributions(
36258
- ${buildWhereClause()}
36259
- first: $limit,
36260
- orderBy: timestamp,
36261
- orderDirection: $orderDirection
36262
- ) {
36263
- id
36264
- recipient { id }
36265
- amount
36266
- feeType
36267
- timestamp
36268
- blockNumber
36269
- transactionHash
36270
- }
36271
- ` : ""}
36272
36290
  }
36273
36291
  `;
36274
36292
  const variables = {
@@ -36326,24 +36344,38 @@ var DiamondHandsGraph = class {
36326
36344
  blockNumber: m.blockNumber,
36327
36345
  transactionHash: m.transactionHash
36328
36346
  }));
36329
- const feeDistributions = (result.communityFeeDistributions || []).map((f) => ({
36330
- id: f.id,
36347
+ const withdrawals = (result.position?.withdrawals || []).map((w) => ({
36348
+ id: w.id,
36349
+ positionId,
36350
+ withdrawalAmount: w.withdrawalAmount,
36351
+ withdrawalAddress: w.withdrawalAddress,
36352
+ networkFee: w.networkFee,
36353
+ timestamp: w.timestamp,
36354
+ blockNumber: w.blockNumber,
36355
+ transactionHash: w.transactionHash,
36356
+ logIndex: w.logIndex
36357
+ }));
36358
+ const renewals = (result.position?.renewals || []).map((r2) => ({
36359
+ id: r2.id,
36331
36360
  positionId,
36332
- recipient: f.recipient.id,
36333
- amount: f.amount,
36334
- feeType: f.feeType,
36335
- timestamp: f.timestamp,
36336
- blockNumber: f.blockNumber,
36337
- transactionHash: f.transactionHash
36361
+ extensionTerm: r2.extensionTerm,
36362
+ extensionFee: r2.extensionFee,
36363
+ newExpiryDate: r2.newExpiryDate,
36364
+ timestamp: r2.timestamp,
36365
+ blockNumber: r2.blockNumber,
36366
+ transactionHash: r2.transactionHash,
36367
+ logIndex: r2.logIndex
36338
36368
  }));
36339
- const totalEvents = payments.length + statusUpdates.length + (liquidation ? 1 : 0) + mints.length + feeDistributions.length;
36369
+ const totalEvents = payments.length + statusUpdates.length + (liquidation ? 1 : 0) + mints.length + withdrawals.length + renewals.length;
36340
36370
  return {
36341
36371
  positionId,
36342
36372
  payments,
36343
36373
  statusUpdates,
36344
36374
  liquidation,
36345
36375
  mints,
36346
- feeDistributions,
36376
+ withdrawals,
36377
+ renewals,
36378
+ feeDistributions: [],
36347
36379
  totalEvents
36348
36380
  };
36349
36381
  }
@@ -43103,7 +43135,7 @@ var EventHelpers = {
43103
43135
  * Get total count of all events
43104
43136
  */
43105
43137
  getTotalCount(events) {
43106
- return events.payments.length + events.statusUpdates.length + (events.liquidation ? 1 : 0) + events.mints.length + events.feeDistributions.length;
43138
+ return events.payments.length + events.statusUpdates.length + (events.liquidation ? 1 : 0) + events.mints.length + events.withdrawals.length + events.renewals.length;
43107
43139
  },
43108
43140
  /**
43109
43141
  * Merge and sort all events by timestamp
@@ -43114,7 +43146,8 @@ var EventHelpers = {
43114
43146
  ...events.statusUpdates.map((e) => ({ ...e, eventType: "status" })),
43115
43147
  ...events.liquidation ? [{ ...events.liquidation, eventType: "liquidation" }] : [],
43116
43148
  ...events.mints.map((e) => ({ ...e, eventType: "mint" })),
43117
- ...events.feeDistributions.map((e) => ({ ...e, eventType: "fee" }))
43149
+ ...events.withdrawals.map((e) => ({ ...e, eventType: "withdrawal" })),
43150
+ ...events.renewals.map((e) => ({ ...e, eventType: "renewal" }))
43118
43151
  ];
43119
43152
  return allEvents.sort((a, b) => {
43120
43153
  const diff = BigInt(a.timestamp) - BigInt(b.timestamp);
@@ -121,6 +121,52 @@ export interface UCDMintEvent {
121
121
  /** Transaction hash */
122
122
  transactionHash: string;
123
123
  }
124
+ /**
125
+ * BTC withdrawal event - tracks collateral withdrawals
126
+ */
127
+ export interface WithdrawalEvent {
128
+ /** Unique event ID (transaction hash + log index) */
129
+ id: string;
130
+ /** Position ID */
131
+ positionId: string;
132
+ /** Amount withdrawn in satoshis */
133
+ withdrawalAmount: string;
134
+ /** Bitcoin destination address */
135
+ withdrawalAddress: string;
136
+ /** Network fee deducted (satoshis, optional) */
137
+ networkFee?: string;
138
+ /** Block timestamp */
139
+ timestamp: string;
140
+ /** Block number */
141
+ blockNumber: string;
142
+ /** Transaction hash */
143
+ transactionHash: string;
144
+ /** Log index in the transaction */
145
+ logIndex: string;
146
+ }
147
+ /**
148
+ * Position renewal/extension event
149
+ */
150
+ export interface RenewalEvent {
151
+ /** Unique event ID (transaction hash + log index) */
152
+ id: string;
153
+ /** Position ID */
154
+ positionId: string;
155
+ /** Additional term in months */
156
+ extensionTerm: string;
157
+ /** Extension fee paid (UCD wei) */
158
+ extensionFee: string;
159
+ /** New expiry timestamp after extension */
160
+ newExpiryDate: string;
161
+ /** Block timestamp */
162
+ timestamp: string;
163
+ /** Block number */
164
+ blockNumber: string;
165
+ /** Transaction hash */
166
+ transactionHash: string;
167
+ /** Log index in the transaction */
168
+ logIndex: string;
169
+ }
124
170
  /**
125
171
  * Community fee distribution event
126
172
  */
@@ -156,6 +202,10 @@ export interface LoanEvents {
156
202
  liquidation?: LiquidationEvent;
157
203
  /** All UCD mint events */
158
204
  mints: UCDMintEvent[];
205
+ /** All BTC withdrawal events */
206
+ withdrawals: WithdrawalEvent[];
207
+ /** All position renewal/extension events */
208
+ renewals: RenewalEvent[];
159
209
  /** All community fee distribution events */
160
210
  feeDistributions: FeeDistributionEvent[];
161
211
  /** Total number of events */
@@ -166,7 +216,7 @@ export interface LoanEvents {
166
216
  */
167
217
  export interface LoanEventsFilter {
168
218
  /** Filter by event types */
169
- eventTypes?: Array<'payment' | 'status' | 'liquidation' | 'mint' | 'fee'>;
219
+ eventTypes?: Array<'payment' | 'status' | 'liquidation' | 'mint' | 'withdrawal' | 'renewal'>;
170
220
  /** Filter by minimum timestamp */
171
221
  fromTimestamp?: string;
172
222
  /** Filter by maximum timestamp */
@@ -229,7 +279,9 @@ export declare const EventHelpers: {
229
279
  eventType: "liquidation";
230
280
  }) | (UCDMintEvent & {
231
281
  eventType: "mint";
232
- }) | (FeeDistributionEvent & {
233
- eventType: "fee";
282
+ }) | (WithdrawalEvent & {
283
+ eventType: "withdrawal";
284
+ }) | (RenewalEvent & {
285
+ eventType: "renewal";
234
286
  })>;
235
287
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gvnrdao/dh-sdk",
3
- "version": "0.0.210",
3
+ "version": "0.0.211",
4
4
  "description": "TypeScript SDK for Diamond Hands Protocol - Bitcoin-backed lending with LIT Protocol PKPs",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/sdk/src/index.d.ts",