@gvnrdao/dh-sdk 0.0.211 → 0.0.212
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 +1 -1
- package/dist/index.js +251 -16
- package/dist/index.mjs +251 -16
- package/dist/types/event-types.d.ts +119 -1
- package/package.json +1 -1
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, WithdrawalEvent, RenewalEvent, } from './types/event-types';
|
|
44
|
+
export type { LoanEvents, LoanEventsFilter, PaymentEvent, StatusUpdateEvent, LiquidationEvent, UCDMintEvent, FeeDistributionEvent, WithdrawalEvent, RenewalEvent, OperationFailureEvent, MintRequestEvent, BurnRequestEvent, CollateralContractEvent, CircuitBreakerProtocolEvent, TermFeeUpdateEvent, } 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
|
@@ -36245,7 +36245,21 @@ var DiamondHandsGraph = class {
|
|
|
36245
36245
|
limit = 1e3,
|
|
36246
36246
|
orderDirection = "desc"
|
|
36247
36247
|
} = filter || {};
|
|
36248
|
-
const
|
|
36248
|
+
const shouldQuery = {
|
|
36249
|
+
payment: !eventTypes || eventTypes.includes("payment"),
|
|
36250
|
+
status: !eventTypes || eventTypes.includes("status"),
|
|
36251
|
+
liquidation: !eventTypes || eventTypes.includes("liquidation"),
|
|
36252
|
+
mint: !eventTypes || eventTypes.includes("mint"),
|
|
36253
|
+
withdrawal: !eventTypes || eventTypes.includes("withdrawal"),
|
|
36254
|
+
renewal: !eventTypes || eventTypes.includes("renewal"),
|
|
36255
|
+
operationFailure: !eventTypes || eventTypes.includes("operationFailure"),
|
|
36256
|
+
mintRequest: !eventTypes || eventTypes.includes("mintRequest"),
|
|
36257
|
+
burnRequest: !eventTypes || eventTypes.includes("burnRequest"),
|
|
36258
|
+
collateralEvent: !eventTypes || eventTypes.includes("collateralEvent"),
|
|
36259
|
+
circuitBreaker: !eventTypes || eventTypes.includes("circuitBreaker"),
|
|
36260
|
+
termFeeUpdate: !eventTypes || eventTypes.includes("termFeeUpdate")
|
|
36261
|
+
};
|
|
36262
|
+
const buildPositionWhereClause = () => {
|
|
36249
36263
|
const conditions = [`position: "${positionId.toLowerCase()}"`];
|
|
36250
36264
|
if (fromTimestamp)
|
|
36251
36265
|
conditions.push(`timestamp_gte: "${fromTimestamp}"`);
|
|
@@ -36255,15 +36269,19 @@ var DiamondHandsGraph = class {
|
|
|
36255
36269
|
conditions.push(`blockNumber_gte: "${fromBlock}"`);
|
|
36256
36270
|
if (toBlock)
|
|
36257
36271
|
conditions.push(`blockNumber_lte: "${toBlock}"`);
|
|
36258
|
-
return
|
|
36272
|
+
return `where: { ${conditions.join(", ")} }`;
|
|
36259
36273
|
};
|
|
36260
|
-
const
|
|
36261
|
-
|
|
36262
|
-
|
|
36263
|
-
|
|
36264
|
-
|
|
36265
|
-
|
|
36266
|
-
|
|
36274
|
+
const buildProtocolWhereClause = () => {
|
|
36275
|
+
const conditions = [];
|
|
36276
|
+
if (fromTimestamp)
|
|
36277
|
+
conditions.push(`timestamp_gte: "${fromTimestamp}"`);
|
|
36278
|
+
if (toTimestamp)
|
|
36279
|
+
conditions.push(`timestamp_lte: "${toTimestamp}"`);
|
|
36280
|
+
if (fromBlock)
|
|
36281
|
+
conditions.push(`blockNumber_gte: "${fromBlock}"`);
|
|
36282
|
+
if (toBlock)
|
|
36283
|
+
conditions.push(`blockNumber_lte: "${toBlock}"`);
|
|
36284
|
+
return conditions.length > 0 ? `where: { ${conditions.join(", ")} }` : "";
|
|
36267
36285
|
};
|
|
36268
36286
|
const query = `
|
|
36269
36287
|
query GetLoanEvents($positionId: Bytes!, $limit: Int!, $orderDirection: OrderDirection!) {
|
|
@@ -36274,7 +36292,7 @@ var DiamondHandsGraph = class {
|
|
|
36274
36292
|
first: $limit,
|
|
36275
36293
|
orderBy: timestamp,
|
|
36276
36294
|
orderDirection: $orderDirection
|
|
36277
|
-
${
|
|
36295
|
+
${buildProtocolWhereClause()}
|
|
36278
36296
|
) {
|
|
36279
36297
|
id
|
|
36280
36298
|
payer { id }
|
|
@@ -36294,7 +36312,7 @@ var DiamondHandsGraph = class {
|
|
|
36294
36312
|
first: $limit,
|
|
36295
36313
|
orderBy: timestamp,
|
|
36296
36314
|
orderDirection: $orderDirection
|
|
36297
|
-
${
|
|
36315
|
+
${buildProtocolWhereClause()}
|
|
36298
36316
|
) {
|
|
36299
36317
|
id
|
|
36300
36318
|
oldStatus
|
|
@@ -36354,11 +36372,141 @@ var DiamondHandsGraph = class {
|
|
|
36354
36372
|
logIndex
|
|
36355
36373
|
}
|
|
36356
36374
|
` : ""}
|
|
36375
|
+
|
|
36376
|
+
${shouldQuery.operationFailure ? `
|
|
36377
|
+
operationFailures(
|
|
36378
|
+
first: $limit,
|
|
36379
|
+
orderBy: timestamp,
|
|
36380
|
+
orderDirection: $orderDirection
|
|
36381
|
+
) {
|
|
36382
|
+
id
|
|
36383
|
+
operationType
|
|
36384
|
+
reason
|
|
36385
|
+
errorCode
|
|
36386
|
+
amount
|
|
36387
|
+
timestamp
|
|
36388
|
+
blockNumber
|
|
36389
|
+
transactionHash
|
|
36390
|
+
logIndex
|
|
36391
|
+
}
|
|
36392
|
+
` : ""}
|
|
36393
|
+
|
|
36394
|
+
${shouldQuery.mintRequest ? `
|
|
36395
|
+
mintRequests(
|
|
36396
|
+
first: $limit,
|
|
36397
|
+
orderBy: timestamp,
|
|
36398
|
+
orderDirection: $orderDirection
|
|
36399
|
+
) {
|
|
36400
|
+
id
|
|
36401
|
+
pkpId
|
|
36402
|
+
borrower { id }
|
|
36403
|
+
mintAmount
|
|
36404
|
+
originationFee
|
|
36405
|
+
newDebt
|
|
36406
|
+
newCollateralRatio
|
|
36407
|
+
btcPrice
|
|
36408
|
+
quantumTimestamp
|
|
36409
|
+
opId
|
|
36410
|
+
timestamp
|
|
36411
|
+
blockNumber
|
|
36412
|
+
transactionHash
|
|
36413
|
+
logIndex
|
|
36414
|
+
}
|
|
36415
|
+
` : ""}
|
|
36416
|
+
|
|
36417
|
+
${shouldQuery.burnRequest ? `
|
|
36418
|
+
burnRequests(
|
|
36419
|
+
first: $limit,
|
|
36420
|
+
orderBy: timestamp,
|
|
36421
|
+
orderDirection: $orderDirection
|
|
36422
|
+
) {
|
|
36423
|
+
id
|
|
36424
|
+
pkpId
|
|
36425
|
+
borrower { id }
|
|
36426
|
+
burnAmount
|
|
36427
|
+
remainingDebt
|
|
36428
|
+
newCollateralRatio
|
|
36429
|
+
opId
|
|
36430
|
+
timestamp
|
|
36431
|
+
blockNumber
|
|
36432
|
+
transactionHash
|
|
36433
|
+
logIndex
|
|
36434
|
+
}
|
|
36435
|
+
` : ""}
|
|
36436
|
+
}
|
|
36437
|
+
|
|
36438
|
+
${shouldQuery.mint ? `
|
|
36439
|
+
ucdMintEvents(
|
|
36440
|
+
${buildPositionWhereClause()}
|
|
36441
|
+
first: $limit,
|
|
36442
|
+
orderBy: timestamp,
|
|
36443
|
+
orderDirection: $orderDirection
|
|
36444
|
+
) {
|
|
36445
|
+
id
|
|
36446
|
+
amount
|
|
36447
|
+
proof
|
|
36448
|
+
minter { id }
|
|
36449
|
+
isCommunityMint
|
|
36450
|
+
timestamp
|
|
36451
|
+
blockNumber
|
|
36452
|
+
transactionHash
|
|
36357
36453
|
}
|
|
36454
|
+
` : ""}
|
|
36358
36455
|
|
|
36456
|
+
${shouldQuery.collateralEvent ? `
|
|
36457
|
+
collateralEvents(
|
|
36458
|
+
${buildPositionWhereClause()}
|
|
36459
|
+
first: $limit,
|
|
36460
|
+
orderBy: timestamp,
|
|
36461
|
+
orderDirection: $orderDirection
|
|
36462
|
+
) {
|
|
36463
|
+
id
|
|
36464
|
+
eventType
|
|
36465
|
+
networkFee
|
|
36466
|
+
remainingCollateral
|
|
36467
|
+
collateralRatio
|
|
36468
|
+
timestamp
|
|
36469
|
+
blockNumber
|
|
36470
|
+
transactionHash
|
|
36471
|
+
logIndex
|
|
36472
|
+
}
|
|
36473
|
+
` : ""}
|
|
36359
36474
|
|
|
36360
|
-
|
|
36361
|
-
|
|
36475
|
+
${shouldQuery.circuitBreaker ? `
|
|
36476
|
+
circuitBreakerEvents(
|
|
36477
|
+
${buildProtocolWhereClause()}
|
|
36478
|
+
first: $limit,
|
|
36479
|
+
orderBy: timestamp,
|
|
36480
|
+
orderDirection: $orderDirection
|
|
36481
|
+
) {
|
|
36482
|
+
id
|
|
36483
|
+
isActivated
|
|
36484
|
+
admin
|
|
36485
|
+
reason
|
|
36486
|
+
timestamp
|
|
36487
|
+
blockNumber
|
|
36488
|
+
transactionHash
|
|
36489
|
+
}
|
|
36490
|
+
` : ""}
|
|
36491
|
+
|
|
36492
|
+
${shouldQuery.termFeeUpdate ? `
|
|
36493
|
+
termFeeUpdates(
|
|
36494
|
+
${buildProtocolWhereClause()}
|
|
36495
|
+
first: $limit,
|
|
36496
|
+
orderBy: timestamp,
|
|
36497
|
+
orderDirection: $orderDirection
|
|
36498
|
+
) {
|
|
36499
|
+
id
|
|
36500
|
+
term { id }
|
|
36501
|
+
oldOriginationFee
|
|
36502
|
+
newOriginationFee
|
|
36503
|
+
oldExtensionFee
|
|
36504
|
+
newExtensionFee
|
|
36505
|
+
timestamp
|
|
36506
|
+
blockNumber
|
|
36507
|
+
transactionHash
|
|
36508
|
+
}
|
|
36509
|
+
` : ""}
|
|
36362
36510
|
}
|
|
36363
36511
|
`;
|
|
36364
36512
|
const variables = {
|
|
@@ -36438,7 +36586,82 @@ var DiamondHandsGraph = class {
|
|
|
36438
36586
|
transactionHash: r2.transactionHash,
|
|
36439
36587
|
logIndex: r2.logIndex
|
|
36440
36588
|
}));
|
|
36441
|
-
const
|
|
36589
|
+
const operationFailures = (result.position?.operationFailures || []).map((o) => ({
|
|
36590
|
+
id: o.id,
|
|
36591
|
+
positionId,
|
|
36592
|
+
operationType: o.operationType,
|
|
36593
|
+
reason: o.reason,
|
|
36594
|
+
errorCode: o.errorCode,
|
|
36595
|
+
amount: o.amount,
|
|
36596
|
+
timestamp: o.timestamp,
|
|
36597
|
+
blockNumber: o.blockNumber,
|
|
36598
|
+
transactionHash: o.transactionHash,
|
|
36599
|
+
logIndex: o.logIndex
|
|
36600
|
+
}));
|
|
36601
|
+
const mintRequests = (result.position?.mintRequests || []).map((m) => ({
|
|
36602
|
+
id: m.id,
|
|
36603
|
+
positionId,
|
|
36604
|
+
pkpId: m.pkpId,
|
|
36605
|
+
borrower: m.borrower.id,
|
|
36606
|
+
mintAmount: m.mintAmount,
|
|
36607
|
+
originationFee: m.originationFee,
|
|
36608
|
+
newDebt: m.newDebt,
|
|
36609
|
+
newCollateralRatio: m.newCollateralRatio,
|
|
36610
|
+
btcPrice: m.btcPrice,
|
|
36611
|
+
quantumTimestamp: m.quantumTimestamp,
|
|
36612
|
+
opId: m.opId,
|
|
36613
|
+
timestamp: m.timestamp,
|
|
36614
|
+
blockNumber: m.blockNumber,
|
|
36615
|
+
transactionHash: m.transactionHash,
|
|
36616
|
+
logIndex: m.logIndex
|
|
36617
|
+
}));
|
|
36618
|
+
const burnRequests = (result.position?.burnRequests || []).map((b) => ({
|
|
36619
|
+
id: b.id,
|
|
36620
|
+
positionId,
|
|
36621
|
+
pkpId: b.pkpId,
|
|
36622
|
+
borrower: b.borrower.id,
|
|
36623
|
+
burnAmount: b.burnAmount,
|
|
36624
|
+
remainingDebt: b.remainingDebt,
|
|
36625
|
+
newCollateralRatio: b.newCollateralRatio,
|
|
36626
|
+
opId: b.opId,
|
|
36627
|
+
timestamp: b.timestamp,
|
|
36628
|
+
blockNumber: b.blockNumber,
|
|
36629
|
+
transactionHash: b.transactionHash,
|
|
36630
|
+
logIndex: b.logIndex
|
|
36631
|
+
}));
|
|
36632
|
+
const collateralEvents = (result.collateralEvents || []).map((c) => ({
|
|
36633
|
+
id: c.id,
|
|
36634
|
+
positionId,
|
|
36635
|
+
eventType: c.eventType,
|
|
36636
|
+
networkFee: c.networkFee,
|
|
36637
|
+
remainingCollateral: c.remainingCollateral,
|
|
36638
|
+
collateralRatio: c.collateralRatio,
|
|
36639
|
+
timestamp: c.timestamp,
|
|
36640
|
+
blockNumber: c.blockNumber,
|
|
36641
|
+
transactionHash: c.transactionHash,
|
|
36642
|
+
logIndex: c.logIndex
|
|
36643
|
+
}));
|
|
36644
|
+
const circuitBreakerEvents = (result.circuitBreakerEvents || []).map((cb) => ({
|
|
36645
|
+
id: cb.id,
|
|
36646
|
+
isActivated: cb.isActivated,
|
|
36647
|
+
admin: cb.admin,
|
|
36648
|
+
reason: cb.reason,
|
|
36649
|
+
timestamp: cb.timestamp,
|
|
36650
|
+
blockNumber: cb.blockNumber,
|
|
36651
|
+
transactionHash: cb.transactionHash
|
|
36652
|
+
}));
|
|
36653
|
+
const termFeeUpdates = (result.termFeeUpdates || []).map((t) => ({
|
|
36654
|
+
id: t.id,
|
|
36655
|
+
termMonths: t.term.id,
|
|
36656
|
+
oldOriginationFee: t.oldOriginationFee,
|
|
36657
|
+
newOriginationFee: t.newOriginationFee,
|
|
36658
|
+
oldExtensionFee: t.oldExtensionFee,
|
|
36659
|
+
newExtensionFee: t.newExtensionFee,
|
|
36660
|
+
timestamp: t.timestamp,
|
|
36661
|
+
blockNumber: t.blockNumber,
|
|
36662
|
+
transactionHash: t.transactionHash
|
|
36663
|
+
}));
|
|
36664
|
+
const totalEvents = payments.length + statusUpdates.length + (liquidation ? 1 : 0) + mints.length + withdrawals.length + renewals.length + operationFailures.length + mintRequests.length + burnRequests.length + collateralEvents.length + circuitBreakerEvents.length + termFeeUpdates.length;
|
|
36442
36665
|
return {
|
|
36443
36666
|
positionId,
|
|
36444
36667
|
payments,
|
|
@@ -36447,6 +36670,12 @@ var DiamondHandsGraph = class {
|
|
|
36447
36670
|
mints,
|
|
36448
36671
|
withdrawals,
|
|
36449
36672
|
renewals,
|
|
36673
|
+
operationFailures,
|
|
36674
|
+
mintRequests,
|
|
36675
|
+
burnRequests,
|
|
36676
|
+
collateralEvents,
|
|
36677
|
+
circuitBreakerEvents,
|
|
36678
|
+
termFeeUpdates,
|
|
36450
36679
|
feeDistributions: [],
|
|
36451
36680
|
totalEvents
|
|
36452
36681
|
};
|
|
@@ -43207,7 +43436,7 @@ var EventHelpers = {
|
|
|
43207
43436
|
* Get total count of all events
|
|
43208
43437
|
*/
|
|
43209
43438
|
getTotalCount(events) {
|
|
43210
|
-
return events.payments.length + events.statusUpdates.length + (events.liquidation ? 1 : 0) + events.mints.length + events.withdrawals.length + events.renewals.length;
|
|
43439
|
+
return events.payments.length + events.statusUpdates.length + (events.liquidation ? 1 : 0) + events.mints.length + events.withdrawals.length + events.renewals.length + events.operationFailures.length + events.mintRequests.length + events.burnRequests.length + events.collateralEvents.length + events.circuitBreakerEvents.length + events.termFeeUpdates.length;
|
|
43211
43440
|
},
|
|
43212
43441
|
/**
|
|
43213
43442
|
* Merge and sort all events by timestamp
|
|
@@ -43219,7 +43448,13 @@ var EventHelpers = {
|
|
|
43219
43448
|
...events.liquidation ? [{ ...events.liquidation, eventType: "liquidation" }] : [],
|
|
43220
43449
|
...events.mints.map((e) => ({ ...e, eventType: "mint" })),
|
|
43221
43450
|
...events.withdrawals.map((e) => ({ ...e, eventType: "withdrawal" })),
|
|
43222
|
-
...events.renewals.map((e) => ({ ...e, eventType: "renewal" }))
|
|
43451
|
+
...events.renewals.map((e) => ({ ...e, eventType: "renewal" })),
|
|
43452
|
+
...events.operationFailures.map((e) => ({ ...e, eventType: "operationFailure" })),
|
|
43453
|
+
...events.mintRequests.map((e) => ({ ...e, eventType: "mintRequest" })),
|
|
43454
|
+
...events.burnRequests.map((e) => ({ ...e, eventType: "burnRequest" })),
|
|
43455
|
+
...events.collateralEvents.map((e) => ({ ...e, eventType: "collateralEvent" })),
|
|
43456
|
+
...events.circuitBreakerEvents.map((e) => ({ ...e, eventType: "circuitBreaker" })),
|
|
43457
|
+
...events.termFeeUpdates.map((e) => ({ ...e, eventType: "termFeeUpdate" }))
|
|
43223
43458
|
];
|
|
43224
43459
|
return allEvents.sort((a, b) => {
|
|
43225
43460
|
const diff = BigInt(a.timestamp) - BigInt(b.timestamp);
|
package/dist/index.mjs
CHANGED
|
@@ -36173,7 +36173,21 @@ var DiamondHandsGraph = class {
|
|
|
36173
36173
|
limit = 1e3,
|
|
36174
36174
|
orderDirection = "desc"
|
|
36175
36175
|
} = filter || {};
|
|
36176
|
-
const
|
|
36176
|
+
const shouldQuery = {
|
|
36177
|
+
payment: !eventTypes || eventTypes.includes("payment"),
|
|
36178
|
+
status: !eventTypes || eventTypes.includes("status"),
|
|
36179
|
+
liquidation: !eventTypes || eventTypes.includes("liquidation"),
|
|
36180
|
+
mint: !eventTypes || eventTypes.includes("mint"),
|
|
36181
|
+
withdrawal: !eventTypes || eventTypes.includes("withdrawal"),
|
|
36182
|
+
renewal: !eventTypes || eventTypes.includes("renewal"),
|
|
36183
|
+
operationFailure: !eventTypes || eventTypes.includes("operationFailure"),
|
|
36184
|
+
mintRequest: !eventTypes || eventTypes.includes("mintRequest"),
|
|
36185
|
+
burnRequest: !eventTypes || eventTypes.includes("burnRequest"),
|
|
36186
|
+
collateralEvent: !eventTypes || eventTypes.includes("collateralEvent"),
|
|
36187
|
+
circuitBreaker: !eventTypes || eventTypes.includes("circuitBreaker"),
|
|
36188
|
+
termFeeUpdate: !eventTypes || eventTypes.includes("termFeeUpdate")
|
|
36189
|
+
};
|
|
36190
|
+
const buildPositionWhereClause = () => {
|
|
36177
36191
|
const conditions = [`position: "${positionId.toLowerCase()}"`];
|
|
36178
36192
|
if (fromTimestamp)
|
|
36179
36193
|
conditions.push(`timestamp_gte: "${fromTimestamp}"`);
|
|
@@ -36183,15 +36197,19 @@ var DiamondHandsGraph = class {
|
|
|
36183
36197
|
conditions.push(`blockNumber_gte: "${fromBlock}"`);
|
|
36184
36198
|
if (toBlock)
|
|
36185
36199
|
conditions.push(`blockNumber_lte: "${toBlock}"`);
|
|
36186
|
-
return
|
|
36200
|
+
return `where: { ${conditions.join(", ")} }`;
|
|
36187
36201
|
};
|
|
36188
|
-
const
|
|
36189
|
-
|
|
36190
|
-
|
|
36191
|
-
|
|
36192
|
-
|
|
36193
|
-
|
|
36194
|
-
|
|
36202
|
+
const buildProtocolWhereClause = () => {
|
|
36203
|
+
const conditions = [];
|
|
36204
|
+
if (fromTimestamp)
|
|
36205
|
+
conditions.push(`timestamp_gte: "${fromTimestamp}"`);
|
|
36206
|
+
if (toTimestamp)
|
|
36207
|
+
conditions.push(`timestamp_lte: "${toTimestamp}"`);
|
|
36208
|
+
if (fromBlock)
|
|
36209
|
+
conditions.push(`blockNumber_gte: "${fromBlock}"`);
|
|
36210
|
+
if (toBlock)
|
|
36211
|
+
conditions.push(`blockNumber_lte: "${toBlock}"`);
|
|
36212
|
+
return conditions.length > 0 ? `where: { ${conditions.join(", ")} }` : "";
|
|
36195
36213
|
};
|
|
36196
36214
|
const query = `
|
|
36197
36215
|
query GetLoanEvents($positionId: Bytes!, $limit: Int!, $orderDirection: OrderDirection!) {
|
|
@@ -36202,7 +36220,7 @@ var DiamondHandsGraph = class {
|
|
|
36202
36220
|
first: $limit,
|
|
36203
36221
|
orderBy: timestamp,
|
|
36204
36222
|
orderDirection: $orderDirection
|
|
36205
|
-
${
|
|
36223
|
+
${buildProtocolWhereClause()}
|
|
36206
36224
|
) {
|
|
36207
36225
|
id
|
|
36208
36226
|
payer { id }
|
|
@@ -36222,7 +36240,7 @@ var DiamondHandsGraph = class {
|
|
|
36222
36240
|
first: $limit,
|
|
36223
36241
|
orderBy: timestamp,
|
|
36224
36242
|
orderDirection: $orderDirection
|
|
36225
|
-
${
|
|
36243
|
+
${buildProtocolWhereClause()}
|
|
36226
36244
|
) {
|
|
36227
36245
|
id
|
|
36228
36246
|
oldStatus
|
|
@@ -36282,11 +36300,141 @@ var DiamondHandsGraph = class {
|
|
|
36282
36300
|
logIndex
|
|
36283
36301
|
}
|
|
36284
36302
|
` : ""}
|
|
36303
|
+
|
|
36304
|
+
${shouldQuery.operationFailure ? `
|
|
36305
|
+
operationFailures(
|
|
36306
|
+
first: $limit,
|
|
36307
|
+
orderBy: timestamp,
|
|
36308
|
+
orderDirection: $orderDirection
|
|
36309
|
+
) {
|
|
36310
|
+
id
|
|
36311
|
+
operationType
|
|
36312
|
+
reason
|
|
36313
|
+
errorCode
|
|
36314
|
+
amount
|
|
36315
|
+
timestamp
|
|
36316
|
+
blockNumber
|
|
36317
|
+
transactionHash
|
|
36318
|
+
logIndex
|
|
36319
|
+
}
|
|
36320
|
+
` : ""}
|
|
36321
|
+
|
|
36322
|
+
${shouldQuery.mintRequest ? `
|
|
36323
|
+
mintRequests(
|
|
36324
|
+
first: $limit,
|
|
36325
|
+
orderBy: timestamp,
|
|
36326
|
+
orderDirection: $orderDirection
|
|
36327
|
+
) {
|
|
36328
|
+
id
|
|
36329
|
+
pkpId
|
|
36330
|
+
borrower { id }
|
|
36331
|
+
mintAmount
|
|
36332
|
+
originationFee
|
|
36333
|
+
newDebt
|
|
36334
|
+
newCollateralRatio
|
|
36335
|
+
btcPrice
|
|
36336
|
+
quantumTimestamp
|
|
36337
|
+
opId
|
|
36338
|
+
timestamp
|
|
36339
|
+
blockNumber
|
|
36340
|
+
transactionHash
|
|
36341
|
+
logIndex
|
|
36342
|
+
}
|
|
36343
|
+
` : ""}
|
|
36344
|
+
|
|
36345
|
+
${shouldQuery.burnRequest ? `
|
|
36346
|
+
burnRequests(
|
|
36347
|
+
first: $limit,
|
|
36348
|
+
orderBy: timestamp,
|
|
36349
|
+
orderDirection: $orderDirection
|
|
36350
|
+
) {
|
|
36351
|
+
id
|
|
36352
|
+
pkpId
|
|
36353
|
+
borrower { id }
|
|
36354
|
+
burnAmount
|
|
36355
|
+
remainingDebt
|
|
36356
|
+
newCollateralRatio
|
|
36357
|
+
opId
|
|
36358
|
+
timestamp
|
|
36359
|
+
blockNumber
|
|
36360
|
+
transactionHash
|
|
36361
|
+
logIndex
|
|
36362
|
+
}
|
|
36363
|
+
` : ""}
|
|
36364
|
+
}
|
|
36365
|
+
|
|
36366
|
+
${shouldQuery.mint ? `
|
|
36367
|
+
ucdMintEvents(
|
|
36368
|
+
${buildPositionWhereClause()}
|
|
36369
|
+
first: $limit,
|
|
36370
|
+
orderBy: timestamp,
|
|
36371
|
+
orderDirection: $orderDirection
|
|
36372
|
+
) {
|
|
36373
|
+
id
|
|
36374
|
+
amount
|
|
36375
|
+
proof
|
|
36376
|
+
minter { id }
|
|
36377
|
+
isCommunityMint
|
|
36378
|
+
timestamp
|
|
36379
|
+
blockNumber
|
|
36380
|
+
transactionHash
|
|
36285
36381
|
}
|
|
36382
|
+
` : ""}
|
|
36286
36383
|
|
|
36384
|
+
${shouldQuery.collateralEvent ? `
|
|
36385
|
+
collateralEvents(
|
|
36386
|
+
${buildPositionWhereClause()}
|
|
36387
|
+
first: $limit,
|
|
36388
|
+
orderBy: timestamp,
|
|
36389
|
+
orderDirection: $orderDirection
|
|
36390
|
+
) {
|
|
36391
|
+
id
|
|
36392
|
+
eventType
|
|
36393
|
+
networkFee
|
|
36394
|
+
remainingCollateral
|
|
36395
|
+
collateralRatio
|
|
36396
|
+
timestamp
|
|
36397
|
+
blockNumber
|
|
36398
|
+
transactionHash
|
|
36399
|
+
logIndex
|
|
36400
|
+
}
|
|
36401
|
+
` : ""}
|
|
36287
36402
|
|
|
36288
|
-
|
|
36289
|
-
|
|
36403
|
+
${shouldQuery.circuitBreaker ? `
|
|
36404
|
+
circuitBreakerEvents(
|
|
36405
|
+
${buildProtocolWhereClause()}
|
|
36406
|
+
first: $limit,
|
|
36407
|
+
orderBy: timestamp,
|
|
36408
|
+
orderDirection: $orderDirection
|
|
36409
|
+
) {
|
|
36410
|
+
id
|
|
36411
|
+
isActivated
|
|
36412
|
+
admin
|
|
36413
|
+
reason
|
|
36414
|
+
timestamp
|
|
36415
|
+
blockNumber
|
|
36416
|
+
transactionHash
|
|
36417
|
+
}
|
|
36418
|
+
` : ""}
|
|
36419
|
+
|
|
36420
|
+
${shouldQuery.termFeeUpdate ? `
|
|
36421
|
+
termFeeUpdates(
|
|
36422
|
+
${buildProtocolWhereClause()}
|
|
36423
|
+
first: $limit,
|
|
36424
|
+
orderBy: timestamp,
|
|
36425
|
+
orderDirection: $orderDirection
|
|
36426
|
+
) {
|
|
36427
|
+
id
|
|
36428
|
+
term { id }
|
|
36429
|
+
oldOriginationFee
|
|
36430
|
+
newOriginationFee
|
|
36431
|
+
oldExtensionFee
|
|
36432
|
+
newExtensionFee
|
|
36433
|
+
timestamp
|
|
36434
|
+
blockNumber
|
|
36435
|
+
transactionHash
|
|
36436
|
+
}
|
|
36437
|
+
` : ""}
|
|
36290
36438
|
}
|
|
36291
36439
|
`;
|
|
36292
36440
|
const variables = {
|
|
@@ -36366,7 +36514,82 @@ var DiamondHandsGraph = class {
|
|
|
36366
36514
|
transactionHash: r2.transactionHash,
|
|
36367
36515
|
logIndex: r2.logIndex
|
|
36368
36516
|
}));
|
|
36369
|
-
const
|
|
36517
|
+
const operationFailures = (result.position?.operationFailures || []).map((o) => ({
|
|
36518
|
+
id: o.id,
|
|
36519
|
+
positionId,
|
|
36520
|
+
operationType: o.operationType,
|
|
36521
|
+
reason: o.reason,
|
|
36522
|
+
errorCode: o.errorCode,
|
|
36523
|
+
amount: o.amount,
|
|
36524
|
+
timestamp: o.timestamp,
|
|
36525
|
+
blockNumber: o.blockNumber,
|
|
36526
|
+
transactionHash: o.transactionHash,
|
|
36527
|
+
logIndex: o.logIndex
|
|
36528
|
+
}));
|
|
36529
|
+
const mintRequests = (result.position?.mintRequests || []).map((m) => ({
|
|
36530
|
+
id: m.id,
|
|
36531
|
+
positionId,
|
|
36532
|
+
pkpId: m.pkpId,
|
|
36533
|
+
borrower: m.borrower.id,
|
|
36534
|
+
mintAmount: m.mintAmount,
|
|
36535
|
+
originationFee: m.originationFee,
|
|
36536
|
+
newDebt: m.newDebt,
|
|
36537
|
+
newCollateralRatio: m.newCollateralRatio,
|
|
36538
|
+
btcPrice: m.btcPrice,
|
|
36539
|
+
quantumTimestamp: m.quantumTimestamp,
|
|
36540
|
+
opId: m.opId,
|
|
36541
|
+
timestamp: m.timestamp,
|
|
36542
|
+
blockNumber: m.blockNumber,
|
|
36543
|
+
transactionHash: m.transactionHash,
|
|
36544
|
+
logIndex: m.logIndex
|
|
36545
|
+
}));
|
|
36546
|
+
const burnRequests = (result.position?.burnRequests || []).map((b) => ({
|
|
36547
|
+
id: b.id,
|
|
36548
|
+
positionId,
|
|
36549
|
+
pkpId: b.pkpId,
|
|
36550
|
+
borrower: b.borrower.id,
|
|
36551
|
+
burnAmount: b.burnAmount,
|
|
36552
|
+
remainingDebt: b.remainingDebt,
|
|
36553
|
+
newCollateralRatio: b.newCollateralRatio,
|
|
36554
|
+
opId: b.opId,
|
|
36555
|
+
timestamp: b.timestamp,
|
|
36556
|
+
blockNumber: b.blockNumber,
|
|
36557
|
+
transactionHash: b.transactionHash,
|
|
36558
|
+
logIndex: b.logIndex
|
|
36559
|
+
}));
|
|
36560
|
+
const collateralEvents = (result.collateralEvents || []).map((c) => ({
|
|
36561
|
+
id: c.id,
|
|
36562
|
+
positionId,
|
|
36563
|
+
eventType: c.eventType,
|
|
36564
|
+
networkFee: c.networkFee,
|
|
36565
|
+
remainingCollateral: c.remainingCollateral,
|
|
36566
|
+
collateralRatio: c.collateralRatio,
|
|
36567
|
+
timestamp: c.timestamp,
|
|
36568
|
+
blockNumber: c.blockNumber,
|
|
36569
|
+
transactionHash: c.transactionHash,
|
|
36570
|
+
logIndex: c.logIndex
|
|
36571
|
+
}));
|
|
36572
|
+
const circuitBreakerEvents = (result.circuitBreakerEvents || []).map((cb) => ({
|
|
36573
|
+
id: cb.id,
|
|
36574
|
+
isActivated: cb.isActivated,
|
|
36575
|
+
admin: cb.admin,
|
|
36576
|
+
reason: cb.reason,
|
|
36577
|
+
timestamp: cb.timestamp,
|
|
36578
|
+
blockNumber: cb.blockNumber,
|
|
36579
|
+
transactionHash: cb.transactionHash
|
|
36580
|
+
}));
|
|
36581
|
+
const termFeeUpdates = (result.termFeeUpdates || []).map((t) => ({
|
|
36582
|
+
id: t.id,
|
|
36583
|
+
termMonths: t.term.id,
|
|
36584
|
+
oldOriginationFee: t.oldOriginationFee,
|
|
36585
|
+
newOriginationFee: t.newOriginationFee,
|
|
36586
|
+
oldExtensionFee: t.oldExtensionFee,
|
|
36587
|
+
newExtensionFee: t.newExtensionFee,
|
|
36588
|
+
timestamp: t.timestamp,
|
|
36589
|
+
blockNumber: t.blockNumber,
|
|
36590
|
+
transactionHash: t.transactionHash
|
|
36591
|
+
}));
|
|
36592
|
+
const totalEvents = payments.length + statusUpdates.length + (liquidation ? 1 : 0) + mints.length + withdrawals.length + renewals.length + operationFailures.length + mintRequests.length + burnRequests.length + collateralEvents.length + circuitBreakerEvents.length + termFeeUpdates.length;
|
|
36370
36593
|
return {
|
|
36371
36594
|
positionId,
|
|
36372
36595
|
payments,
|
|
@@ -36375,6 +36598,12 @@ var DiamondHandsGraph = class {
|
|
|
36375
36598
|
mints,
|
|
36376
36599
|
withdrawals,
|
|
36377
36600
|
renewals,
|
|
36601
|
+
operationFailures,
|
|
36602
|
+
mintRequests,
|
|
36603
|
+
burnRequests,
|
|
36604
|
+
collateralEvents,
|
|
36605
|
+
circuitBreakerEvents,
|
|
36606
|
+
termFeeUpdates,
|
|
36378
36607
|
feeDistributions: [],
|
|
36379
36608
|
totalEvents
|
|
36380
36609
|
};
|
|
@@ -43135,7 +43364,7 @@ var EventHelpers = {
|
|
|
43135
43364
|
* Get total count of all events
|
|
43136
43365
|
*/
|
|
43137
43366
|
getTotalCount(events) {
|
|
43138
|
-
return events.payments.length + events.statusUpdates.length + (events.liquidation ? 1 : 0) + events.mints.length + events.withdrawals.length + events.renewals.length;
|
|
43367
|
+
return events.payments.length + events.statusUpdates.length + (events.liquidation ? 1 : 0) + events.mints.length + events.withdrawals.length + events.renewals.length + events.operationFailures.length + events.mintRequests.length + events.burnRequests.length + events.collateralEvents.length + events.circuitBreakerEvents.length + events.termFeeUpdates.length;
|
|
43139
43368
|
},
|
|
43140
43369
|
/**
|
|
43141
43370
|
* Merge and sort all events by timestamp
|
|
@@ -43147,7 +43376,13 @@ var EventHelpers = {
|
|
|
43147
43376
|
...events.liquidation ? [{ ...events.liquidation, eventType: "liquidation" }] : [],
|
|
43148
43377
|
...events.mints.map((e) => ({ ...e, eventType: "mint" })),
|
|
43149
43378
|
...events.withdrawals.map((e) => ({ ...e, eventType: "withdrawal" })),
|
|
43150
|
-
...events.renewals.map((e) => ({ ...e, eventType: "renewal" }))
|
|
43379
|
+
...events.renewals.map((e) => ({ ...e, eventType: "renewal" })),
|
|
43380
|
+
...events.operationFailures.map((e) => ({ ...e, eventType: "operationFailure" })),
|
|
43381
|
+
...events.mintRequests.map((e) => ({ ...e, eventType: "mintRequest" })),
|
|
43382
|
+
...events.burnRequests.map((e) => ({ ...e, eventType: "burnRequest" })),
|
|
43383
|
+
...events.collateralEvents.map((e) => ({ ...e, eventType: "collateralEvent" })),
|
|
43384
|
+
...events.circuitBreakerEvents.map((e) => ({ ...e, eventType: "circuitBreaker" })),
|
|
43385
|
+
...events.termFeeUpdates.map((e) => ({ ...e, eventType: "termFeeUpdate" }))
|
|
43151
43386
|
];
|
|
43152
43387
|
return allEvents.sort((a, b) => {
|
|
43153
43388
|
const diff = BigInt(a.timestamp) - BigInt(b.timestamp);
|
|
@@ -167,6 +167,100 @@ export interface RenewalEvent {
|
|
|
167
167
|
/** Log index in the transaction */
|
|
168
168
|
logIndex: string;
|
|
169
169
|
}
|
|
170
|
+
/**
|
|
171
|
+
* Failed operation event - tracks mint/burn/repay/renew/withdraw failures
|
|
172
|
+
*/
|
|
173
|
+
export interface OperationFailureEvent {
|
|
174
|
+
id: string;
|
|
175
|
+
positionId: string;
|
|
176
|
+
operationType: string;
|
|
177
|
+
reason: string;
|
|
178
|
+
errorCode?: string;
|
|
179
|
+
amount?: string;
|
|
180
|
+
timestamp: string;
|
|
181
|
+
blockNumber: string;
|
|
182
|
+
transactionHash: string;
|
|
183
|
+
logIndex: string;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* UCD mint request - records a successful mintUCD call with all parameters
|
|
187
|
+
*/
|
|
188
|
+
export interface MintRequestEvent {
|
|
189
|
+
id: string;
|
|
190
|
+
positionId: string;
|
|
191
|
+
pkpId: string;
|
|
192
|
+
borrower: string;
|
|
193
|
+
mintAmount: string;
|
|
194
|
+
originationFee: string;
|
|
195
|
+
newDebt: string;
|
|
196
|
+
newCollateralRatio: string;
|
|
197
|
+
btcPrice: string;
|
|
198
|
+
quantumTimestamp: string;
|
|
199
|
+
opId: string;
|
|
200
|
+
timestamp: string;
|
|
201
|
+
blockNumber: string;
|
|
202
|
+
transactionHash: string;
|
|
203
|
+
logIndex: string;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Burn request - records a successful makePayment/repay call
|
|
207
|
+
*/
|
|
208
|
+
export interface BurnRequestEvent {
|
|
209
|
+
id: string;
|
|
210
|
+
positionId: string;
|
|
211
|
+
pkpId: string;
|
|
212
|
+
borrower: string;
|
|
213
|
+
burnAmount: string;
|
|
214
|
+
remainingDebt: string;
|
|
215
|
+
newCollateralRatio: string;
|
|
216
|
+
opId: string;
|
|
217
|
+
timestamp: string;
|
|
218
|
+
blockNumber: string;
|
|
219
|
+
transactionHash: string;
|
|
220
|
+
logIndex: string;
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Collateral contract event - position-level collateral manager outcomes
|
|
224
|
+
* (POSITION_CLOSED, NETWORK_FEE_DEDUCTED, VALIDATION_FAILED, EXCESSIVE_FEE_REJECTED)
|
|
225
|
+
*/
|
|
226
|
+
export interface CollateralContractEvent {
|
|
227
|
+
id: string;
|
|
228
|
+
positionId: string;
|
|
229
|
+
eventType: string;
|
|
230
|
+
networkFee?: string;
|
|
231
|
+
remainingCollateral?: string;
|
|
232
|
+
collateralRatio?: string;
|
|
233
|
+
timestamp: string;
|
|
234
|
+
blockNumber: string;
|
|
235
|
+
transactionHash: string;
|
|
236
|
+
logIndex: string;
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Protocol-level circuit breaker event (activation, deactivation, limit updates)
|
|
240
|
+
*/
|
|
241
|
+
export interface CircuitBreakerProtocolEvent {
|
|
242
|
+
id: string;
|
|
243
|
+
isActivated: boolean;
|
|
244
|
+
admin: string;
|
|
245
|
+
reason?: string;
|
|
246
|
+
timestamp: string;
|
|
247
|
+
blockNumber: string;
|
|
248
|
+
transactionHash: string;
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Protocol-level term fee update event
|
|
252
|
+
*/
|
|
253
|
+
export interface TermFeeUpdateEvent {
|
|
254
|
+
id: string;
|
|
255
|
+
termMonths: string;
|
|
256
|
+
oldOriginationFee: string;
|
|
257
|
+
newOriginationFee: string;
|
|
258
|
+
oldExtensionFee: string;
|
|
259
|
+
newExtensionFee: string;
|
|
260
|
+
timestamp: string;
|
|
261
|
+
blockNumber: string;
|
|
262
|
+
transactionHash: string;
|
|
263
|
+
}
|
|
170
264
|
/**
|
|
171
265
|
* Community fee distribution event
|
|
172
266
|
*/
|
|
@@ -206,6 +300,18 @@ export interface LoanEvents {
|
|
|
206
300
|
withdrawals: WithdrawalEvent[];
|
|
207
301
|
/** All position renewal/extension events */
|
|
208
302
|
renewals: RenewalEvent[];
|
|
303
|
+
/** All failed operation events */
|
|
304
|
+
operationFailures: OperationFailureEvent[];
|
|
305
|
+
/** All mint request events (successful mintUCD calls) */
|
|
306
|
+
mintRequests: MintRequestEvent[];
|
|
307
|
+
/** All burn request events (successful repay/payment calls) */
|
|
308
|
+
burnRequests: BurnRequestEvent[];
|
|
309
|
+
/** All collateral contract events (close, fee deduction, validation failures) */
|
|
310
|
+
collateralEvents: CollateralContractEvent[];
|
|
311
|
+
/** Protocol-level circuit breaker events */
|
|
312
|
+
circuitBreakerEvents: CircuitBreakerProtocolEvent[];
|
|
313
|
+
/** Protocol-level term fee update events */
|
|
314
|
+
termFeeUpdates: TermFeeUpdateEvent[];
|
|
209
315
|
/** All community fee distribution events */
|
|
210
316
|
feeDistributions: FeeDistributionEvent[];
|
|
211
317
|
/** Total number of events */
|
|
@@ -216,7 +322,7 @@ export interface LoanEvents {
|
|
|
216
322
|
*/
|
|
217
323
|
export interface LoanEventsFilter {
|
|
218
324
|
/** Filter by event types */
|
|
219
|
-
eventTypes?: Array<'payment' | 'status' | 'liquidation' | 'mint' | 'withdrawal' | 'renewal'>;
|
|
325
|
+
eventTypes?: Array<'payment' | 'status' | 'liquidation' | 'mint' | 'withdrawal' | 'renewal' | 'operationFailure' | 'mintRequest' | 'burnRequest' | 'collateralEvent' | 'circuitBreaker' | 'termFeeUpdate'>;
|
|
220
326
|
/** Filter by minimum timestamp */
|
|
221
327
|
fromTimestamp?: string;
|
|
222
328
|
/** Filter by maximum timestamp */
|
|
@@ -283,5 +389,17 @@ export declare const EventHelpers: {
|
|
|
283
389
|
eventType: "withdrawal";
|
|
284
390
|
}) | (RenewalEvent & {
|
|
285
391
|
eventType: "renewal";
|
|
392
|
+
}) | (OperationFailureEvent & {
|
|
393
|
+
eventType: "operationFailure";
|
|
394
|
+
}) | (MintRequestEvent & {
|
|
395
|
+
eventType: "mintRequest";
|
|
396
|
+
}) | (BurnRequestEvent & {
|
|
397
|
+
eventType: "burnRequest";
|
|
398
|
+
}) | (CollateralContractEvent & {
|
|
399
|
+
eventType: "collateralEvent";
|
|
400
|
+
}) | (CircuitBreakerProtocolEvent & {
|
|
401
|
+
eventType: "circuitBreaker";
|
|
402
|
+
}) | (TermFeeUpdateEvent & {
|
|
403
|
+
eventType: "termFeeUpdate";
|
|
286
404
|
})>;
|
|
287
405
|
};
|
package/package.json
CHANGED