@gvnrdao/dh-sdk 0.0.125 → 0.0.128
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/browser/dist/397.browser.js +2 -0
- package/browser/dist/397.browser.js.LICENSE.txt +1 -0
- package/browser/dist/833.browser.js +1 -0
- package/browser/dist/browser.js +8 -0
- package/browser/dist/browser.js.LICENSE.txt +90 -0
- package/browser/dist/index.d.ts +9 -0
- package/browser/dist/index.d.ts.map +1 -0
- package/browser/dist/index.js +24 -0
- package/dist/index.d.mts +455 -463
- package/dist/index.d.ts +455 -463
- package/dist/index.js +35011 -36248
- package/dist/index.mjs +34425 -35662
- package/package.json +12 -7
package/dist/index.d.mts
CHANGED
|
@@ -122,306 +122,6 @@ declare function match<T, E, U>(result: Result$1<T, E>, handlers: {
|
|
|
122
122
|
failure: (error: E) => U;
|
|
123
123
|
}): U;
|
|
124
124
|
|
|
125
|
-
/**
|
|
126
|
-
* Production-Ready Error Handler for PKP Validation and Loan Creation
|
|
127
|
-
*/
|
|
128
|
-
/**
|
|
129
|
-
* Error categories for SDK operations
|
|
130
|
-
*/
|
|
131
|
-
declare enum ErrorCategory {
|
|
132
|
-
CONFIGURATION = "CONFIGURATION",
|
|
133
|
-
INITIALIZATION = "INITIALIZATION",
|
|
134
|
-
NETWORK = "NETWORK",
|
|
135
|
-
CONTRACT = "CONTRACT",
|
|
136
|
-
PKP = "PKP",
|
|
137
|
-
BITCOIN = "BITCOIN",
|
|
138
|
-
AUTHORIZATION = "AUTHORIZATION",
|
|
139
|
-
VALIDATION = "VALIDATION",
|
|
140
|
-
TRANSACTION = "TRANSACTION",
|
|
141
|
-
SUBGRAPH = "SUBGRAPH",
|
|
142
|
-
CACHE = "CACHE",
|
|
143
|
-
UNKNOWN = "UNKNOWN"
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* Error severity levels
|
|
147
|
-
*/
|
|
148
|
-
declare enum ErrorSeverity {
|
|
149
|
-
LOW = "LOW",
|
|
150
|
-
MEDIUM = "MEDIUM",
|
|
151
|
-
HIGH = "HIGH",
|
|
152
|
-
CRITICAL = "CRITICAL"
|
|
153
|
-
}
|
|
154
|
-
/**
|
|
155
|
-
* Modern SDK Error class with structured error handling
|
|
156
|
-
*/
|
|
157
|
-
declare class SDKError extends Error {
|
|
158
|
-
readonly category: ErrorCategory;
|
|
159
|
-
readonly severity: ErrorSeverity;
|
|
160
|
-
readonly retryable: boolean;
|
|
161
|
-
readonly context?: Record<string, any>;
|
|
162
|
-
readonly originalError?: Error;
|
|
163
|
-
readonly timestamp: number;
|
|
164
|
-
constructor(params: {
|
|
165
|
-
message: string;
|
|
166
|
-
category: ErrorCategory;
|
|
167
|
-
severity: ErrorSeverity;
|
|
168
|
-
retryable?: boolean;
|
|
169
|
-
context?: Record<string, any>;
|
|
170
|
-
originalError?: Error;
|
|
171
|
-
});
|
|
172
|
-
/**
|
|
173
|
-
* Convert to JSON-serializable format
|
|
174
|
-
*/
|
|
175
|
-
toJSON(): {
|
|
176
|
-
name: string;
|
|
177
|
-
message: string;
|
|
178
|
-
category: ErrorCategory;
|
|
179
|
-
severity: ErrorSeverity;
|
|
180
|
-
retryable: boolean;
|
|
181
|
-
context: Record<string, any> | undefined;
|
|
182
|
-
timestamp: number;
|
|
183
|
-
stack: string | undefined;
|
|
184
|
-
};
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
/**
|
|
188
|
-
* Generic Cache Manager Module
|
|
189
|
-
*
|
|
190
|
-
* Provides a type-safe, generic LRU cache with TTL support.
|
|
191
|
-
* Can be used for any data type (Bitcoin balances, addresses, query results, etc.)
|
|
192
|
-
*
|
|
193
|
-
* Features:
|
|
194
|
-
* - Generic type support
|
|
195
|
-
* - TTL-based expiration
|
|
196
|
-
* - LRU eviction policy
|
|
197
|
-
* - Hit/miss statistics
|
|
198
|
-
* - Memory-efficient
|
|
199
|
-
* - Thread-safe operations
|
|
200
|
-
*/
|
|
201
|
-
|
|
202
|
-
/**
|
|
203
|
-
* Cache entry with metadata
|
|
204
|
-
*/
|
|
205
|
-
interface CacheEntry<T> {
|
|
206
|
-
/** Cached value */
|
|
207
|
-
value: T;
|
|
208
|
-
/** Unix timestamp when entry was created (ms) */
|
|
209
|
-
timestamp: number;
|
|
210
|
-
/** Number of times this entry was accessed */
|
|
211
|
-
hits: number;
|
|
212
|
-
/** Unix timestamp of last access (ms) */
|
|
213
|
-
lastAccessed: number;
|
|
214
|
-
}
|
|
215
|
-
/**
|
|
216
|
-
* Cache statistics
|
|
217
|
-
*/
|
|
218
|
-
interface CacheStats {
|
|
219
|
-
/** Current number of entries in cache */
|
|
220
|
-
size: number;
|
|
221
|
-
/** Total cache hits */
|
|
222
|
-
hits: number;
|
|
223
|
-
/** Total cache misses */
|
|
224
|
-
misses: number;
|
|
225
|
-
/** Total evictions performed */
|
|
226
|
-
evictions: number;
|
|
227
|
-
/** Timestamp of oldest entry (ms) */
|
|
228
|
-
oldestEntry: number;
|
|
229
|
-
/** Timestamp of newest entry (ms) */
|
|
230
|
-
newestEntry: number;
|
|
231
|
-
/** Hit rate as percentage (0-100) */
|
|
232
|
-
hitRate: number;
|
|
233
|
-
}
|
|
234
|
-
/**
|
|
235
|
-
* Cache configuration
|
|
236
|
-
*/
|
|
237
|
-
interface CacheConfig {
|
|
238
|
-
/** Maximum number of entries (default: 1000) */
|
|
239
|
-
maxSize?: number;
|
|
240
|
-
/** Time-to-live in milliseconds (default: 60000 = 1 minute) */
|
|
241
|
-
ttlMs?: number;
|
|
242
|
-
/** Enable debug logging (default: false) */
|
|
243
|
-
debug?: boolean;
|
|
244
|
-
/** Cache name for logging (default: 'Cache') */
|
|
245
|
-
name?: string;
|
|
246
|
-
}
|
|
247
|
-
/**
|
|
248
|
-
* Generic LRU Cache with TTL support
|
|
249
|
-
*
|
|
250
|
-
* @template K - Key type (usually string)
|
|
251
|
-
* @template V - Value type
|
|
252
|
-
*
|
|
253
|
-
* @example
|
|
254
|
-
* ```typescript
|
|
255
|
-
* // Create a cache for Bitcoin balances
|
|
256
|
-
* const balanceCache = new LRUCache<string, BitcoinBalance>({
|
|
257
|
-
* maxSize: 500,
|
|
258
|
-
* ttlMs: 60000,
|
|
259
|
-
* name: 'BitcoinBalance'
|
|
260
|
-
* });
|
|
261
|
-
*
|
|
262
|
-
* // Set value
|
|
263
|
-
* balanceCache.set('bc1q...', { balance: Satoshis(50000000n) });
|
|
264
|
-
*
|
|
265
|
-
* // Get value
|
|
266
|
-
* const balance = balanceCache.get('bc1q...');
|
|
267
|
-
* if (balance) {
|
|
268
|
-
* console.log('Cached balance:', balance.balance);
|
|
269
|
-
* }
|
|
270
|
-
* ```
|
|
271
|
-
*/
|
|
272
|
-
declare class LRUCache<K, V> {
|
|
273
|
-
private cache;
|
|
274
|
-
private readonly maxSize;
|
|
275
|
-
private readonly ttlMs;
|
|
276
|
-
private readonly debug;
|
|
277
|
-
private readonly name;
|
|
278
|
-
private stats;
|
|
279
|
-
constructor(config?: CacheConfig);
|
|
280
|
-
/**
|
|
281
|
-
* Get value from cache
|
|
282
|
-
*
|
|
283
|
-
* Returns null if:
|
|
284
|
-
* - Key not found
|
|
285
|
-
* - Entry has expired
|
|
286
|
-
*
|
|
287
|
-
* @param key - Cache key
|
|
288
|
-
* @returns Cached value or null
|
|
289
|
-
*/
|
|
290
|
-
get(key: K): V | null;
|
|
291
|
-
/**
|
|
292
|
-
* Get value from cache with Result wrapper
|
|
293
|
-
*
|
|
294
|
-
* Useful when you want to distinguish between "not found" and "expired"
|
|
295
|
-
*/
|
|
296
|
-
getResult(key: K): Result$1<V, SDKError>;
|
|
297
|
-
/**
|
|
298
|
-
* Set value in cache
|
|
299
|
-
*
|
|
300
|
-
* If cache is full, evicts the least recently used entry
|
|
301
|
-
*
|
|
302
|
-
* @param key - Cache key
|
|
303
|
-
* @param value - Value to cache
|
|
304
|
-
* @param ttl - Optional custom TTL for this entry (ms)
|
|
305
|
-
*/
|
|
306
|
-
set(key: K, value: V, ttl?: number): void;
|
|
307
|
-
/**
|
|
308
|
-
* Set value in cache with Result wrapper
|
|
309
|
-
*/
|
|
310
|
-
setResult(key: K, value: V, ttl?: number): Result$1<void, SDKError>;
|
|
311
|
-
/**
|
|
312
|
-
* Check if key exists in cache (without affecting stats)
|
|
313
|
-
*/
|
|
314
|
-
has(key: K): boolean;
|
|
315
|
-
/**
|
|
316
|
-
* Delete specific key from cache
|
|
317
|
-
*/
|
|
318
|
-
delete(key: K): boolean;
|
|
319
|
-
/**
|
|
320
|
-
* Clear entire cache
|
|
321
|
-
*/
|
|
322
|
-
clear(): void;
|
|
323
|
-
/**
|
|
324
|
-
* Get current cache size
|
|
325
|
-
*/
|
|
326
|
-
size(): number;
|
|
327
|
-
/**
|
|
328
|
-
* Get cache statistics
|
|
329
|
-
*/
|
|
330
|
-
getStats(): CacheStats;
|
|
331
|
-
/**
|
|
332
|
-
* Get hit rate percentage
|
|
333
|
-
*/
|
|
334
|
-
getHitRate(): number;
|
|
335
|
-
/**
|
|
336
|
-
* Get all cached keys (for debugging)
|
|
337
|
-
*/
|
|
338
|
-
getKeys(): K[];
|
|
339
|
-
/**
|
|
340
|
-
* Get all cached values (for debugging)
|
|
341
|
-
*/
|
|
342
|
-
getValues(): V[];
|
|
343
|
-
/**
|
|
344
|
-
* Get all cache entries with metadata (for debugging)
|
|
345
|
-
*/
|
|
346
|
-
getEntries(): Array<{
|
|
347
|
-
key: K;
|
|
348
|
-
value: V;
|
|
349
|
-
metadata: Omit<CacheEntry<V>, 'value'>;
|
|
350
|
-
}>;
|
|
351
|
-
/**
|
|
352
|
-
* Clean up expired entries
|
|
353
|
-
*
|
|
354
|
-
* Useful for periodic maintenance
|
|
355
|
-
*
|
|
356
|
-
* @returns Number of entries cleaned
|
|
357
|
-
*/
|
|
358
|
-
cleanExpired(): number;
|
|
359
|
-
/**
|
|
360
|
-
* Check if cache entry is expired
|
|
361
|
-
*/
|
|
362
|
-
private isExpired;
|
|
363
|
-
/**
|
|
364
|
-
* Evict least recently used entry
|
|
365
|
-
*/
|
|
366
|
-
private evictLRU;
|
|
367
|
-
/**
|
|
368
|
-
* Get or compute value
|
|
369
|
-
*
|
|
370
|
-
* If key exists in cache, returns cached value.
|
|
371
|
-
* Otherwise, computes value using provided function and caches it.
|
|
372
|
-
*
|
|
373
|
-
* @param key - Cache key
|
|
374
|
-
* @param compute - Function to compute value if not in cache
|
|
375
|
-
* @param ttl - Optional custom TTL for this entry
|
|
376
|
-
* @returns Cached or computed value
|
|
377
|
-
*/
|
|
378
|
-
getOrCompute(key: K, compute: () => Promise<V>, ttl?: number): Promise<V>;
|
|
379
|
-
/**
|
|
380
|
-
* Get or compute value with Result wrapper
|
|
381
|
-
*/
|
|
382
|
-
getOrComputeResult(key: K, compute: () => Promise<Result$1<V, SDKError>>, ttl?: number): Promise<Result$1<V, SDKError>>;
|
|
383
|
-
}
|
|
384
|
-
/**
|
|
385
|
-
* Cache Manager - Factory for creating specialized caches
|
|
386
|
-
*/
|
|
387
|
-
declare class CacheManager {
|
|
388
|
-
private caches;
|
|
389
|
-
private readonly globalConfig;
|
|
390
|
-
constructor(globalConfig?: CacheConfig);
|
|
391
|
-
/**
|
|
392
|
-
* Create or get a named cache
|
|
393
|
-
*
|
|
394
|
-
* @param name - Unique cache name
|
|
395
|
-
* @param config - Optional cache-specific configuration
|
|
396
|
-
* @returns LRU cache instance
|
|
397
|
-
*/
|
|
398
|
-
getCache<K, V>(name: string, config?: CacheConfig): LRUCache<K, V>;
|
|
399
|
-
/**
|
|
400
|
-
* Clear all caches
|
|
401
|
-
*/
|
|
402
|
-
clearAll(): void;
|
|
403
|
-
/**
|
|
404
|
-
* Clean expired entries from all caches
|
|
405
|
-
*/
|
|
406
|
-
cleanAllExpired(): number;
|
|
407
|
-
/**
|
|
408
|
-
* Get statistics for all caches
|
|
409
|
-
*/
|
|
410
|
-
getAllStats(): Record<string, CacheStats>;
|
|
411
|
-
/**
|
|
412
|
-
* Get list of all cache names
|
|
413
|
-
*/
|
|
414
|
-
getCacheNames(): string[];
|
|
415
|
-
/**
|
|
416
|
-
* Delete a named cache
|
|
417
|
-
*/
|
|
418
|
-
deleteCache(name: string): boolean;
|
|
419
|
-
}
|
|
420
|
-
/**
|
|
421
|
-
* Factory function to create a CacheManager instance
|
|
422
|
-
*/
|
|
423
|
-
declare function createCacheManager(config?: CacheConfig): CacheManager;
|
|
424
|
-
|
|
425
125
|
/**
|
|
426
126
|
* Branded types for domain-specific values to prevent mixing incompatible units
|
|
427
127
|
*
|
|
@@ -554,6 +254,68 @@ declare namespace BPSConversions {
|
|
|
554
254
|
function format(bps: BPS): string;
|
|
555
255
|
}
|
|
556
256
|
|
|
257
|
+
/**
|
|
258
|
+
* Production-Ready Error Handler for PKP Validation and Loan Creation
|
|
259
|
+
*/
|
|
260
|
+
/**
|
|
261
|
+
* Error categories for SDK operations
|
|
262
|
+
*/
|
|
263
|
+
declare enum ErrorCategory {
|
|
264
|
+
CONFIGURATION = "CONFIGURATION",
|
|
265
|
+
INITIALIZATION = "INITIALIZATION",
|
|
266
|
+
NETWORK = "NETWORK",
|
|
267
|
+
CONTRACT = "CONTRACT",
|
|
268
|
+
PKP = "PKP",
|
|
269
|
+
BITCOIN = "BITCOIN",
|
|
270
|
+
AUTHORIZATION = "AUTHORIZATION",
|
|
271
|
+
VALIDATION = "VALIDATION",
|
|
272
|
+
TRANSACTION = "TRANSACTION",
|
|
273
|
+
SUBGRAPH = "SUBGRAPH",
|
|
274
|
+
CACHE = "CACHE",
|
|
275
|
+
UNKNOWN = "UNKNOWN"
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Error severity levels
|
|
279
|
+
*/
|
|
280
|
+
declare enum ErrorSeverity {
|
|
281
|
+
LOW = "LOW",
|
|
282
|
+
MEDIUM = "MEDIUM",
|
|
283
|
+
HIGH = "HIGH",
|
|
284
|
+
CRITICAL = "CRITICAL"
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Modern SDK Error class with structured error handling
|
|
288
|
+
*/
|
|
289
|
+
declare class SDKError extends Error {
|
|
290
|
+
readonly category: ErrorCategory;
|
|
291
|
+
readonly severity: ErrorSeverity;
|
|
292
|
+
readonly retryable: boolean;
|
|
293
|
+
readonly context?: Record<string, any>;
|
|
294
|
+
readonly originalError?: Error;
|
|
295
|
+
readonly timestamp: number;
|
|
296
|
+
constructor(params: {
|
|
297
|
+
message: string;
|
|
298
|
+
category: ErrorCategory;
|
|
299
|
+
severity: ErrorSeverity;
|
|
300
|
+
retryable?: boolean;
|
|
301
|
+
context?: Record<string, any>;
|
|
302
|
+
originalError?: Error;
|
|
303
|
+
});
|
|
304
|
+
/**
|
|
305
|
+
* Convert to JSON-serializable format
|
|
306
|
+
*/
|
|
307
|
+
toJSON(): {
|
|
308
|
+
name: string;
|
|
309
|
+
message: string;
|
|
310
|
+
category: ErrorCategory;
|
|
311
|
+
severity: ErrorSeverity;
|
|
312
|
+
retryable: boolean;
|
|
313
|
+
context: Record<string, any> | undefined;
|
|
314
|
+
timestamp: number;
|
|
315
|
+
stack: string | undefined;
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
|
|
557
319
|
/**
|
|
558
320
|
* SDK Configuration Interfaces
|
|
559
321
|
*/
|
|
@@ -569,6 +331,7 @@ interface ContractAddresses {
|
|
|
569
331
|
simplePsmV2?: string;
|
|
570
332
|
loanOperationsManager?: string;
|
|
571
333
|
termManager?: string;
|
|
334
|
+
collateralManager?: string;
|
|
572
335
|
ucdController?: string;
|
|
573
336
|
circuitBreaker?: string;
|
|
574
337
|
communityManager?: string;
|
|
@@ -602,6 +365,7 @@ interface BaseSDKConfig {
|
|
|
602
365
|
bitcoinRpcUrl?: string;
|
|
603
366
|
bitcoinProviders?: BitcoinProviderConfig[];
|
|
604
367
|
bitcoinConsensusMode?: "single" | "majority";
|
|
368
|
+
priceProviders?: PriceProviderConfig[];
|
|
605
369
|
bitcoinFaucetUrl?: string;
|
|
606
370
|
contractAddresses?: ContractAddresses;
|
|
607
371
|
subgraphs?: {
|
|
@@ -654,16 +418,6 @@ interface BaseSDKConfig {
|
|
|
654
418
|
verboseInProduction?: boolean;
|
|
655
419
|
};
|
|
656
420
|
validatorVersion?: number;
|
|
657
|
-
/**
|
|
658
|
-
* Lit Action execution mode (standalone mode only)
|
|
659
|
-
* In service mode, actions are always executed via the service endpoint
|
|
660
|
-
* - 'ipfs': Execute from IPFS CID (client-side, default for standalone)
|
|
661
|
-
* - 'code': Execute inline code via service
|
|
662
|
-
* @note This setting is ignored when mode === 'service'
|
|
663
|
-
*/
|
|
664
|
-
litActionExecution?: 'ipfs' | 'code';
|
|
665
|
-
ucdMintValidatorCid?: string;
|
|
666
|
-
btcWithdrawalCid?: string;
|
|
667
421
|
defaultSelectedTermMonths?: number;
|
|
668
422
|
telegram?: {
|
|
669
423
|
chatId: string;
|
|
@@ -766,6 +520,14 @@ interface BitcoinProviderConfig {
|
|
|
766
520
|
name?: string;
|
|
767
521
|
priority?: number;
|
|
768
522
|
}
|
|
523
|
+
/**
|
|
524
|
+
* Price Provider Configuration
|
|
525
|
+
*/
|
|
526
|
+
interface PriceProviderConfig {
|
|
527
|
+
name: string;
|
|
528
|
+
apiKey?: string;
|
|
529
|
+
apiSecret?: string;
|
|
530
|
+
}
|
|
769
531
|
|
|
770
532
|
interface TypedDeferredTopicFilter<_TCEvent extends TypedContractEvent> extends DeferredTopicFilter {
|
|
771
533
|
}
|
|
@@ -876,7 +638,6 @@ declare namespace IPositionManager {
|
|
|
876
638
|
positionId: BytesLike;
|
|
877
639
|
pkpId: BytesLike;
|
|
878
640
|
ucdDebt: BigNumberish;
|
|
879
|
-
vaultAddress: string;
|
|
880
641
|
borrower: AddressLike;
|
|
881
642
|
createdAt: BigNumberish;
|
|
882
643
|
lastUpdated: BigNumberish;
|
|
@@ -888,7 +649,6 @@ declare namespace IPositionManager {
|
|
|
888
649
|
positionId: string,
|
|
889
650
|
pkpId: string,
|
|
890
651
|
ucdDebt: bigint,
|
|
891
|
-
vaultAddress: string,
|
|
892
652
|
borrower: string,
|
|
893
653
|
createdAt: bigint,
|
|
894
654
|
lastUpdated: bigint,
|
|
@@ -899,7 +659,6 @@ declare namespace IPositionManager {
|
|
|
899
659
|
positionId: string;
|
|
900
660
|
pkpId: string;
|
|
901
661
|
ucdDebt: bigint;
|
|
902
|
-
vaultAddress: string;
|
|
903
662
|
borrower: string;
|
|
904
663
|
createdAt: bigint;
|
|
905
664
|
lastUpdated: bigint;
|
|
@@ -908,9 +667,49 @@ declare namespace IPositionManager {
|
|
|
908
667
|
status: bigint;
|
|
909
668
|
};
|
|
910
669
|
}
|
|
670
|
+
declare namespace ICollateralManager {
|
|
671
|
+
type WithdrawalParamsStruct = {
|
|
672
|
+
positionId: BytesLike;
|
|
673
|
+
actionHash: BytesLike;
|
|
674
|
+
authorizedSpendsHash: BytesLike;
|
|
675
|
+
ucdDebtHash: BytesLike;
|
|
676
|
+
withdrawalAddress: string;
|
|
677
|
+
totalDeduction: BigNumberish;
|
|
678
|
+
newCollateral: BigNumberish;
|
|
679
|
+
quantumTimestamp: BigNumberish;
|
|
680
|
+
btcPrice: BigNumberish;
|
|
681
|
+
utxoTxid: string;
|
|
682
|
+
utxoVout: BigNumberish;
|
|
683
|
+
};
|
|
684
|
+
type WithdrawalParamsStructOutput = [
|
|
685
|
+
positionId: string,
|
|
686
|
+
actionHash: string,
|
|
687
|
+
authorizedSpendsHash: string,
|
|
688
|
+
ucdDebtHash: string,
|
|
689
|
+
withdrawalAddress: string,
|
|
690
|
+
totalDeduction: bigint,
|
|
691
|
+
newCollateral: bigint,
|
|
692
|
+
quantumTimestamp: bigint,
|
|
693
|
+
btcPrice: bigint,
|
|
694
|
+
utxoTxid: string,
|
|
695
|
+
utxoVout: bigint
|
|
696
|
+
] & {
|
|
697
|
+
positionId: string;
|
|
698
|
+
actionHash: string;
|
|
699
|
+
authorizedSpendsHash: string;
|
|
700
|
+
ucdDebtHash: string;
|
|
701
|
+
withdrawalAddress: string;
|
|
702
|
+
totalDeduction: bigint;
|
|
703
|
+
newCollateral: bigint;
|
|
704
|
+
quantumTimestamp: bigint;
|
|
705
|
+
btcPrice: bigint;
|
|
706
|
+
utxoTxid: string;
|
|
707
|
+
utxoVout: bigint;
|
|
708
|
+
};
|
|
709
|
+
}
|
|
911
710
|
interface PositionManagerInterface extends Interface {
|
|
912
|
-
getFunction(nameOrSignature: "ADMIN_ROLE" | "COMMUNITY_FEE_DISTRIBUTOR_ROLE" | "COMMUNITY_MINTER_ROLE" | "DEFAULT_ADMIN_ROLE" | "EMERGENCY_PAUSE_ROLE" | "LIQUIDATOR_ROLE" | "ORACLE_UPDATER_ROLE" | "UPGRADE_INTERFACE_VERSION" | "VERSION" | "_performExtensionValidation" | "admin" | "authorizationRegistry" | "calculateCollateralRatio" | "circuitBreaker" | "collateral" | "commitLiquidation" | "communityManager" | "core" | "createPosition" | "extendPosition" | "getExpiredLoanLiquidationThreshold" | "getPKPLoanParams" | "getPKPPositionData" | "getPositionDetails" | "getPositionStatus" | "getRoleAdmin" | "grantRole" | "hasRole" | "initialize" | "isExpiredLoanLiquidatable" | "liquidatePosition" | "liquidation" | "loanOps" | "makePartialPayment" | "paused" | "pkpValidationRegistry" | "proxiableUUID" | "renounceRole" | "repayPosition" | "revealAndLiquidate" | "revokeRole" | "setAuthorizationRegistry" | "setPKPValidationRegistry" | "supportsInterface" | "termManager" | "updateDebtFromLoanOps" | "updateModules" | "updatePosition" | "updatePositionStatusFromLoanOps" | "upgradeToAndCall" | "validatePKPLogic" | "validateUpgrade" | "views" | "withdrawBTC"): FunctionFragment;
|
|
913
|
-
getEvent(nameOrSignatureOrTopic: "CollateralRatioUpdated" | "Initialized" | "IntegrityCheckFailed" | "ModulesUpdatedBatch" | "PKPLogicValidated" | "PKPValidationRegistryUpdated" | "PartialPaymentMade" | "Paused" | "PositionClosed" | "PositionCreated" | "PositionLiquidated" | "PositionRenewed" | "PositionRepaid" | "PositionStatusUpdated" | "PositionUpdated" | "RoleAdminChanged" | "RoleGranted" | "RoleRevoked" | "UCDMinted" | "Unpaused" | "Upgraded"
|
|
711
|
+
getFunction(nameOrSignature: "ADMIN_ROLE" | "COMMUNITY_FEE_DISTRIBUTOR_ROLE" | "COMMUNITY_MINTER_ROLE" | "DEFAULT_ADMIN_ROLE" | "EMERGENCY_PAUSE_ROLE" | "LIQUIDATOR_ROLE" | "ORACLE_UPDATER_ROLE" | "UPGRADE_INTERFACE_VERSION" | "VERSION" | "_performExtensionValidation" | "admin" | "authorizationRegistry" | "calculateCollateralRatio" | "circuitBreaker" | "clearExtensionPending" | "collateral" | "commitLiquidation" | "communityManager" | "core" | "createPosition" | "extendPosition" | "getExpiredLoanLiquidationThreshold" | "getPKPLoanParams" | "getPKPPositionData" | "getPositionDetails" | "getPositionStatus" | "getRoleAdmin" | "grantRole" | "hasRole" | "initialize" | "isExpiredLoanLiquidatable" | "liquidatePosition" | "liquidation" | "loanOps" | "makePartialPayment" | "paused" | "pkpValidationRegistry" | "proxiableUUID" | "renounceRole" | "repayPosition" | "revealAndLiquidate" | "revokeRole" | "setAuthorizationRegistry" | "setPKPValidationRegistry" | "supportsInterface" | "termManager" | "updateDebtFromLoanOps" | "updateModules" | "updatePosition" | "updatePositionStatusFromLoanOps" | "upgradeToAndCall" | "validatePKPLogic" | "validateUpgrade" | "views" | "withdrawBTC"): FunctionFragment;
|
|
712
|
+
getEvent(nameOrSignatureOrTopic: "CollateralRatioUpdated" | "ExtensionPendingCleared" | "Initialized" | "IntegrityCheckFailed" | "ModulesUpdatedBatch" | "PKPLogicValidated" | "PKPValidationRegistryUpdated" | "PartialPaymentMade" | "Paused" | "PositionClosed" | "PositionCreated" | "PositionLiquidated" | "PositionRenewed" | "PositionRepaid" | "PositionStatusUpdated" | "PositionUpdated" | "RoleAdminChanged" | "RoleGranted" | "RoleRevoked" | "UCDMinted" | "Unpaused" | "Upgraded"): EventFragment;
|
|
914
713
|
encodeFunctionData(functionFragment: "ADMIN_ROLE", values?: undefined): string;
|
|
915
714
|
encodeFunctionData(functionFragment: "COMMUNITY_FEE_DISTRIBUTOR_ROLE", values?: undefined): string;
|
|
916
715
|
encodeFunctionData(functionFragment: "COMMUNITY_MINTER_ROLE", values?: undefined): string;
|
|
@@ -920,17 +719,18 @@ interface PositionManagerInterface extends Interface {
|
|
|
920
719
|
encodeFunctionData(functionFragment: "ORACLE_UPDATER_ROLE", values?: undefined): string;
|
|
921
720
|
encodeFunctionData(functionFragment: "UPGRADE_INTERFACE_VERSION", values?: undefined): string;
|
|
922
721
|
encodeFunctionData(functionFragment: "VERSION", values?: undefined): string;
|
|
923
|
-
encodeFunctionData(functionFragment: "_performExtensionValidation", values: [IPositionManagerCore.PositionStruct, BigNumberish]): string;
|
|
722
|
+
encodeFunctionData(functionFragment: "_performExtensionValidation", values: [IPositionManagerCore.PositionStruct, BigNumberish, BigNumberish]): string;
|
|
924
723
|
encodeFunctionData(functionFragment: "admin", values?: undefined): string;
|
|
925
724
|
encodeFunctionData(functionFragment: "authorizationRegistry", values?: undefined): string;
|
|
926
725
|
encodeFunctionData(functionFragment: "calculateCollateralRatio", values: [BytesLike]): string;
|
|
927
726
|
encodeFunctionData(functionFragment: "circuitBreaker", values?: undefined): string;
|
|
727
|
+
encodeFunctionData(functionFragment: "clearExtensionPending", values: [BytesLike]): string;
|
|
928
728
|
encodeFunctionData(functionFragment: "collateral", values?: undefined): string;
|
|
929
729
|
encodeFunctionData(functionFragment: "commitLiquidation", values: [BytesLike, BytesLike]): string;
|
|
930
730
|
encodeFunctionData(functionFragment: "communityManager", values?: undefined): string;
|
|
931
731
|
encodeFunctionData(functionFragment: "core", values?: undefined): string;
|
|
932
|
-
encodeFunctionData(functionFragment: "createPosition", values: [BytesLike, BytesLike, string, BigNumberish, BigNumberish]): string;
|
|
933
|
-
encodeFunctionData(functionFragment: "extendPosition", values: [BytesLike, BigNumberish]): string;
|
|
732
|
+
encodeFunctionData(functionFragment: "createPosition", values: [BytesLike, BytesLike, string, string, BigNumberish, BigNumberish]): string;
|
|
733
|
+
encodeFunctionData(functionFragment: "extendPosition", values: [BytesLike, BigNumberish, BigNumberish, BigNumberish, BytesLike]): string;
|
|
934
734
|
encodeFunctionData(functionFragment: "getExpiredLoanLiquidationThreshold", values: [BytesLike]): string;
|
|
935
735
|
encodeFunctionData(functionFragment: "getPKPLoanParams", values: [BytesLike]): string;
|
|
936
736
|
encodeFunctionData(functionFragment: "getPKPPositionData", values: [BytesLike]): string;
|
|
@@ -983,14 +783,7 @@ interface PositionManagerInterface extends Interface {
|
|
|
983
783
|
encodeFunctionData(functionFragment: "validatePKPLogic", values: [BytesLike]): string;
|
|
984
784
|
encodeFunctionData(functionFragment: "validateUpgrade", values: [AddressLike]): string;
|
|
985
785
|
encodeFunctionData(functionFragment: "views", values?: undefined): string;
|
|
986
|
-
encodeFunctionData(functionFragment: "withdrawBTC", values: [
|
|
987
|
-
BytesLike,
|
|
988
|
-
string,
|
|
989
|
-
BigNumberish,
|
|
990
|
-
BigNumberish,
|
|
991
|
-
BigNumberish,
|
|
992
|
-
BytesLike
|
|
993
|
-
]): string;
|
|
786
|
+
encodeFunctionData(functionFragment: "withdrawBTC", values: [ICollateralManager.WithdrawalParamsStruct, BytesLike]): string;
|
|
994
787
|
decodeFunctionResult(functionFragment: "ADMIN_ROLE", data: BytesLike): Result$2;
|
|
995
788
|
decodeFunctionResult(functionFragment: "COMMUNITY_FEE_DISTRIBUTOR_ROLE", data: BytesLike): Result$2;
|
|
996
789
|
decodeFunctionResult(functionFragment: "COMMUNITY_MINTER_ROLE", data: BytesLike): Result$2;
|
|
@@ -1005,6 +798,7 @@ interface PositionManagerInterface extends Interface {
|
|
|
1005
798
|
decodeFunctionResult(functionFragment: "authorizationRegistry", data: BytesLike): Result$2;
|
|
1006
799
|
decodeFunctionResult(functionFragment: "calculateCollateralRatio", data: BytesLike): Result$2;
|
|
1007
800
|
decodeFunctionResult(functionFragment: "circuitBreaker", data: BytesLike): Result$2;
|
|
801
|
+
decodeFunctionResult(functionFragment: "clearExtensionPending", data: BytesLike): Result$2;
|
|
1008
802
|
decodeFunctionResult(functionFragment: "collateral", data: BytesLike): Result$2;
|
|
1009
803
|
decodeFunctionResult(functionFragment: "commitLiquidation", data: BytesLike): Result$2;
|
|
1010
804
|
decodeFunctionResult(functionFragment: "communityManager", data: BytesLike): Result$2;
|
|
@@ -1067,6 +861,18 @@ declare namespace CollateralRatioUpdatedEvent {
|
|
|
1067
861
|
type Log = TypedEventLog<Event>;
|
|
1068
862
|
type LogDescription = TypedLogDescription<Event>;
|
|
1069
863
|
}
|
|
864
|
+
declare namespace ExtensionPendingClearedEvent {
|
|
865
|
+
type InputTuple = [positionId: BytesLike, clearedBy: AddressLike];
|
|
866
|
+
type OutputTuple = [positionId: string, clearedBy: string];
|
|
867
|
+
interface OutputObject {
|
|
868
|
+
positionId: string;
|
|
869
|
+
clearedBy: string;
|
|
870
|
+
}
|
|
871
|
+
type Event = TypedContractEvent<InputTuple, OutputTuple, OutputObject>;
|
|
872
|
+
type Filter = TypedDeferredTopicFilter<Event>;
|
|
873
|
+
type Log = TypedEventLog<Event>;
|
|
874
|
+
type LogDescription = TypedLogDescription<Event>;
|
|
875
|
+
}
|
|
1070
876
|
declare namespace InitializedEvent$1 {
|
|
1071
877
|
type InputTuple = [version: BigNumberish];
|
|
1072
878
|
type OutputTuple = [version: bigint];
|
|
@@ -1453,39 +1259,6 @@ declare namespace UpgradedEvent$1 {
|
|
|
1453
1259
|
type Log = TypedEventLog<Event>;
|
|
1454
1260
|
type LogDescription = TypedLogDescription<Event>;
|
|
1455
1261
|
}
|
|
1456
|
-
declare namespace WithdrawBTCSignatureDebugEvent {
|
|
1457
|
-
type InputTuple = [
|
|
1458
|
-
positionId: BytesLike,
|
|
1459
|
-
messageHash: BytesLike,
|
|
1460
|
-
expectedPkp: AddressLike,
|
|
1461
|
-
recoveredPkp: AddressLike,
|
|
1462
|
-
isValid: boolean,
|
|
1463
|
-
btcPrice: BigNumberish,
|
|
1464
|
-
quantumTimestamp: BigNumberish
|
|
1465
|
-
];
|
|
1466
|
-
type OutputTuple = [
|
|
1467
|
-
positionId: string,
|
|
1468
|
-
messageHash: string,
|
|
1469
|
-
expectedPkp: string,
|
|
1470
|
-
recoveredPkp: string,
|
|
1471
|
-
isValid: boolean,
|
|
1472
|
-
btcPrice: bigint,
|
|
1473
|
-
quantumTimestamp: bigint
|
|
1474
|
-
];
|
|
1475
|
-
interface OutputObject {
|
|
1476
|
-
positionId: string;
|
|
1477
|
-
messageHash: string;
|
|
1478
|
-
expectedPkp: string;
|
|
1479
|
-
recoveredPkp: string;
|
|
1480
|
-
isValid: boolean;
|
|
1481
|
-
btcPrice: bigint;
|
|
1482
|
-
quantumTimestamp: bigint;
|
|
1483
|
-
}
|
|
1484
|
-
type Event = TypedContractEvent<InputTuple, OutputTuple, OutputObject>;
|
|
1485
|
-
type Filter = TypedDeferredTopicFilter<Event>;
|
|
1486
|
-
type Log = TypedEventLog<Event>;
|
|
1487
|
-
type LogDescription = TypedLogDescription<Event>;
|
|
1488
|
-
}
|
|
1489
1262
|
interface PositionManager extends BaseContract {
|
|
1490
1263
|
connect(runner?: ContractRunner | null): PositionManager;
|
|
1491
1264
|
waitForDeployment(): Promise<this>;
|
|
@@ -1510,7 +1283,8 @@ interface PositionManager extends BaseContract {
|
|
|
1510
1283
|
VERSION: TypedContractMethod<[], [string], "view">;
|
|
1511
1284
|
_performExtensionValidation: TypedContractMethod<[
|
|
1512
1285
|
position: IPositionManagerCore.PositionStruct,
|
|
1513
|
-
selectedTerm: BigNumberish
|
|
1286
|
+
selectedTerm: BigNumberish,
|
|
1287
|
+
btcPrice: BigNumberish
|
|
1514
1288
|
], [
|
|
1515
1289
|
[
|
|
1516
1290
|
bigint,
|
|
@@ -1532,6 +1306,11 @@ interface PositionManager extends BaseContract {
|
|
|
1532
1306
|
bigint
|
|
1533
1307
|
], "view">;
|
|
1534
1308
|
circuitBreaker: TypedContractMethod<[], [string], "view">;
|
|
1309
|
+
clearExtensionPending: TypedContractMethod<[
|
|
1310
|
+
positionId: BytesLike
|
|
1311
|
+
], [
|
|
1312
|
+
void
|
|
1313
|
+
], "nonpayable">;
|
|
1535
1314
|
collateral: TypedContractMethod<[], [string], "view">;
|
|
1536
1315
|
commitLiquidation: TypedContractMethod<[
|
|
1537
1316
|
positionId: BytesLike,
|
|
@@ -1544,7 +1323,8 @@ interface PositionManager extends BaseContract {
|
|
|
1544
1323
|
createPosition: TypedContractMethod<[
|
|
1545
1324
|
pkpId: BytesLike,
|
|
1546
1325
|
validatorSignature: BytesLike,
|
|
1547
|
-
|
|
1326
|
+
mainnetVaultAddress: string,
|
|
1327
|
+
regtestVaultAddress: string,
|
|
1548
1328
|
selectedTermMonths: BigNumberish,
|
|
1549
1329
|
validatorVersion: BigNumberish
|
|
1550
1330
|
], [
|
|
@@ -1552,7 +1332,10 @@ interface PositionManager extends BaseContract {
|
|
|
1552
1332
|
], "nonpayable">;
|
|
1553
1333
|
extendPosition: TypedContractMethod<[
|
|
1554
1334
|
positionId: BytesLike,
|
|
1555
|
-
selectedTerm: BigNumberish
|
|
1335
|
+
selectedTerm: BigNumberish,
|
|
1336
|
+
quantumTimestamp: BigNumberish,
|
|
1337
|
+
btcPrice: BigNumberish,
|
|
1338
|
+
extensionValidatorSignature: BytesLike
|
|
1556
1339
|
], [
|
|
1557
1340
|
boolean
|
|
1558
1341
|
], "nonpayable">;
|
|
@@ -1716,11 +1499,7 @@ interface PositionManager extends BaseContract {
|
|
|
1716
1499
|
], "view">;
|
|
1717
1500
|
views: TypedContractMethod<[], [string], "view">;
|
|
1718
1501
|
withdrawBTC: TypedContractMethod<[
|
|
1719
|
-
|
|
1720
|
-
withdrawalAddress: string,
|
|
1721
|
-
networkFee: BigNumberish,
|
|
1722
|
-
quantumTimestamp: BigNumberish,
|
|
1723
|
-
btcPrice: BigNumberish,
|
|
1502
|
+
params: ICollateralManager.WithdrawalParamsStruct,
|
|
1724
1503
|
withdrawalValidatorSignature: BytesLike
|
|
1725
1504
|
], [
|
|
1726
1505
|
boolean
|
|
@@ -1737,7 +1516,8 @@ interface PositionManager extends BaseContract {
|
|
|
1737
1516
|
getFunction(nameOrSignature: "VERSION"): TypedContractMethod<[], [string], "view">;
|
|
1738
1517
|
getFunction(nameOrSignature: "_performExtensionValidation"): TypedContractMethod<[
|
|
1739
1518
|
position: IPositionManagerCore.PositionStruct,
|
|
1740
|
-
selectedTerm: BigNumberish
|
|
1519
|
+
selectedTerm: BigNumberish,
|
|
1520
|
+
btcPrice: BigNumberish
|
|
1741
1521
|
], [
|
|
1742
1522
|
[
|
|
1743
1523
|
bigint,
|
|
@@ -1755,6 +1535,7 @@ interface PositionManager extends BaseContract {
|
|
|
1755
1535
|
getFunction(nameOrSignature: "authorizationRegistry"): TypedContractMethod<[], [string], "view">;
|
|
1756
1536
|
getFunction(nameOrSignature: "calculateCollateralRatio"): TypedContractMethod<[positionId: BytesLike], [bigint], "view">;
|
|
1757
1537
|
getFunction(nameOrSignature: "circuitBreaker"): TypedContractMethod<[], [string], "view">;
|
|
1538
|
+
getFunction(nameOrSignature: "clearExtensionPending"): TypedContractMethod<[positionId: BytesLike], [void], "nonpayable">;
|
|
1758
1539
|
getFunction(nameOrSignature: "collateral"): TypedContractMethod<[], [string], "view">;
|
|
1759
1540
|
getFunction(nameOrSignature: "commitLiquidation"): TypedContractMethod<[
|
|
1760
1541
|
positionId: BytesLike,
|
|
@@ -1767,7 +1548,8 @@ interface PositionManager extends BaseContract {
|
|
|
1767
1548
|
getFunction(nameOrSignature: "createPosition"): TypedContractMethod<[
|
|
1768
1549
|
pkpId: BytesLike,
|
|
1769
1550
|
validatorSignature: BytesLike,
|
|
1770
|
-
|
|
1551
|
+
mainnetVaultAddress: string,
|
|
1552
|
+
regtestVaultAddress: string,
|
|
1771
1553
|
selectedTermMonths: BigNumberish,
|
|
1772
1554
|
validatorVersion: BigNumberish
|
|
1773
1555
|
], [
|
|
@@ -1775,7 +1557,10 @@ interface PositionManager extends BaseContract {
|
|
|
1775
1557
|
], "nonpayable">;
|
|
1776
1558
|
getFunction(nameOrSignature: "extendPosition"): TypedContractMethod<[
|
|
1777
1559
|
positionId: BytesLike,
|
|
1778
|
-
selectedTerm: BigNumberish
|
|
1560
|
+
selectedTerm: BigNumberish,
|
|
1561
|
+
quantumTimestamp: BigNumberish,
|
|
1562
|
+
btcPrice: BigNumberish,
|
|
1563
|
+
extensionValidatorSignature: BytesLike
|
|
1779
1564
|
], [
|
|
1780
1565
|
boolean
|
|
1781
1566
|
], "nonpayable">;
|
|
@@ -1907,16 +1692,13 @@ interface PositionManager extends BaseContract {
|
|
|
1907
1692
|
getFunction(nameOrSignature: "validateUpgrade"): TypedContractMethod<[newImplementation: AddressLike], [boolean], "view">;
|
|
1908
1693
|
getFunction(nameOrSignature: "views"): TypedContractMethod<[], [string], "view">;
|
|
1909
1694
|
getFunction(nameOrSignature: "withdrawBTC"): TypedContractMethod<[
|
|
1910
|
-
|
|
1911
|
-
withdrawalAddress: string,
|
|
1912
|
-
networkFee: BigNumberish,
|
|
1913
|
-
quantumTimestamp: BigNumberish,
|
|
1914
|
-
btcPrice: BigNumberish,
|
|
1695
|
+
params: ICollateralManager.WithdrawalParamsStruct,
|
|
1915
1696
|
withdrawalValidatorSignature: BytesLike
|
|
1916
1697
|
], [
|
|
1917
1698
|
boolean
|
|
1918
1699
|
], "nonpayable">;
|
|
1919
1700
|
getEvent(key: "CollateralRatioUpdated"): TypedContractEvent<CollateralRatioUpdatedEvent.InputTuple, CollateralRatioUpdatedEvent.OutputTuple, CollateralRatioUpdatedEvent.OutputObject>;
|
|
1701
|
+
getEvent(key: "ExtensionPendingCleared"): TypedContractEvent<ExtensionPendingClearedEvent.InputTuple, ExtensionPendingClearedEvent.OutputTuple, ExtensionPendingClearedEvent.OutputObject>;
|
|
1920
1702
|
getEvent(key: "Initialized"): TypedContractEvent<InitializedEvent$1.InputTuple, InitializedEvent$1.OutputTuple, InitializedEvent$1.OutputObject>;
|
|
1921
1703
|
getEvent(key: "IntegrityCheckFailed"): TypedContractEvent<IntegrityCheckFailedEvent.InputTuple, IntegrityCheckFailedEvent.OutputTuple, IntegrityCheckFailedEvent.OutputObject>;
|
|
1922
1704
|
getEvent(key: "ModulesUpdatedBatch"): TypedContractEvent<ModulesUpdatedBatchEvent.InputTuple, ModulesUpdatedBatchEvent.OutputTuple, ModulesUpdatedBatchEvent.OutputObject>;
|
|
@@ -1937,10 +1719,11 @@ interface PositionManager extends BaseContract {
|
|
|
1937
1719
|
getEvent(key: "UCDMinted"): TypedContractEvent<UCDMintedEvent$1.InputTuple, UCDMintedEvent$1.OutputTuple, UCDMintedEvent$1.OutputObject>;
|
|
1938
1720
|
getEvent(key: "Unpaused"): TypedContractEvent<UnpausedEvent$1.InputTuple, UnpausedEvent$1.OutputTuple, UnpausedEvent$1.OutputObject>;
|
|
1939
1721
|
getEvent(key: "Upgraded"): TypedContractEvent<UpgradedEvent$1.InputTuple, UpgradedEvent$1.OutputTuple, UpgradedEvent$1.OutputObject>;
|
|
1940
|
-
getEvent(key: "WithdrawBTCSignatureDebug"): TypedContractEvent<WithdrawBTCSignatureDebugEvent.InputTuple, WithdrawBTCSignatureDebugEvent.OutputTuple, WithdrawBTCSignatureDebugEvent.OutputObject>;
|
|
1941
1722
|
filters: {
|
|
1942
1723
|
"CollateralRatioUpdated(bytes32,uint256,uint256)": TypedContractEvent<CollateralRatioUpdatedEvent.InputTuple, CollateralRatioUpdatedEvent.OutputTuple, CollateralRatioUpdatedEvent.OutputObject>;
|
|
1943
1724
|
CollateralRatioUpdated: TypedContractEvent<CollateralRatioUpdatedEvent.InputTuple, CollateralRatioUpdatedEvent.OutputTuple, CollateralRatioUpdatedEvent.OutputObject>;
|
|
1725
|
+
"ExtensionPendingCleared(bytes32,address)": TypedContractEvent<ExtensionPendingClearedEvent.InputTuple, ExtensionPendingClearedEvent.OutputTuple, ExtensionPendingClearedEvent.OutputObject>;
|
|
1726
|
+
ExtensionPendingCleared: TypedContractEvent<ExtensionPendingClearedEvent.InputTuple, ExtensionPendingClearedEvent.OutputTuple, ExtensionPendingClearedEvent.OutputObject>;
|
|
1944
1727
|
"Initialized(uint64)": TypedContractEvent<InitializedEvent$1.InputTuple, InitializedEvent$1.OutputTuple, InitializedEvent$1.OutputObject>;
|
|
1945
1728
|
Initialized: TypedContractEvent<InitializedEvent$1.InputTuple, InitializedEvent$1.OutputTuple, InitializedEvent$1.OutputObject>;
|
|
1946
1729
|
"IntegrityCheckFailed(bytes32,string,string,uint256)": TypedContractEvent<IntegrityCheckFailedEvent.InputTuple, IntegrityCheckFailedEvent.OutputTuple, IntegrityCheckFailedEvent.OutputObject>;
|
|
@@ -1981,8 +1764,6 @@ interface PositionManager extends BaseContract {
|
|
|
1981
1764
|
Unpaused: TypedContractEvent<UnpausedEvent$1.InputTuple, UnpausedEvent$1.OutputTuple, UnpausedEvent$1.OutputObject>;
|
|
1982
1765
|
"Upgraded(address)": TypedContractEvent<UpgradedEvent$1.InputTuple, UpgradedEvent$1.OutputTuple, UpgradedEvent$1.OutputObject>;
|
|
1983
1766
|
Upgraded: TypedContractEvent<UpgradedEvent$1.InputTuple, UpgradedEvent$1.OutputTuple, UpgradedEvent$1.OutputObject>;
|
|
1984
|
-
"WithdrawBTCSignatureDebug(bytes32,bytes32,address,address,bool,uint256,uint256)": TypedContractEvent<WithdrawBTCSignatureDebugEvent.InputTuple, WithdrawBTCSignatureDebugEvent.OutputTuple, WithdrawBTCSignatureDebugEvent.OutputObject>;
|
|
1985
|
-
WithdrawBTCSignatureDebug: TypedContractEvent<WithdrawBTCSignatureDebugEvent.InputTuple, WithdrawBTCSignatureDebugEvent.OutputTuple, WithdrawBTCSignatureDebugEvent.OutputObject>;
|
|
1986
1767
|
};
|
|
1987
1768
|
}
|
|
1988
1769
|
|
|
@@ -2465,8 +2246,17 @@ interface ILiquidationManager extends BaseContract {
|
|
|
2465
2246
|
}
|
|
2466
2247
|
|
|
2467
2248
|
interface ILoanOperationsManagerInterface extends Interface {
|
|
2468
|
-
getFunction(nameOrSignature: "calculateCollateralRatio" | "getCurrentBTCPrice" | "getOriginationFeeBalance" | "getPKPActualCollateral" | "getUcdController" | "isPriceFeedStale" | "liquidationThreshold" | "maximumLtvRatio" | "minimumLoanValueWei" | "mintUCD" | "processPartialPayment" | "repayPosition" | "supportsInterface" | "transferOriginationFee" | "ucdToken" | "updatePosition"): FunctionFragment;
|
|
2249
|
+
getFunction(nameOrSignature: "authorizeBTCSpend" | "calculateCollateralRatio" | "getCurrentBTCPrice" | "getOriginationFeeBalance" | "getPKPActualCollateral" | "getUcdController" | "isPriceFeedStale" | "liquidationThreshold" | "maximumLtvRatio" | "minimumLoanValueWei" | "mintUCD" | "processPartialPayment" | "repayPosition" | "supportsInterface" | "transferOriginationFee" | "ucdToken" | "updatePosition"): FunctionFragment;
|
|
2469
2250
|
getEvent(nameOrSignatureOrTopic: "PositionRepaid" | "PositionUpdated" | "UCDMinted"): EventFragment;
|
|
2251
|
+
encodeFunctionData(functionFragment: "authorizeBTCSpend", values: [
|
|
2252
|
+
BytesLike,
|
|
2253
|
+
string,
|
|
2254
|
+
BigNumberish,
|
|
2255
|
+
BigNumberish,
|
|
2256
|
+
string,
|
|
2257
|
+
BigNumberish,
|
|
2258
|
+
BytesLike
|
|
2259
|
+
]): string;
|
|
2470
2260
|
encodeFunctionData(functionFragment: "calculateCollateralRatio", values: [BytesLike]): string;
|
|
2471
2261
|
encodeFunctionData(functionFragment: "getCurrentBTCPrice", values?: undefined): string;
|
|
2472
2262
|
encodeFunctionData(functionFragment: "getOriginationFeeBalance", values?: undefined): string;
|
|
@@ -2493,6 +2283,7 @@ interface ILoanOperationsManagerInterface extends Interface {
|
|
|
2493
2283
|
encodeFunctionData(functionFragment: "transferOriginationFee", values: [AddressLike, BigNumberish]): string;
|
|
2494
2284
|
encodeFunctionData(functionFragment: "ucdToken", values?: undefined): string;
|
|
2495
2285
|
encodeFunctionData(functionFragment: "updatePosition", values: [BytesLike, BigNumberish]): string;
|
|
2286
|
+
decodeFunctionResult(functionFragment: "authorizeBTCSpend", data: BytesLike): Result$2;
|
|
2496
2287
|
decodeFunctionResult(functionFragment: "calculateCollateralRatio", data: BytesLike): Result$2;
|
|
2497
2288
|
decodeFunctionResult(functionFragment: "getCurrentBTCPrice", data: BytesLike): Result$2;
|
|
2498
2289
|
decodeFunctionResult(functionFragment: "getOriginationFeeBalance", data: BytesLike): Result$2;
|
|
@@ -2586,6 +2377,17 @@ interface ILoanOperationsManager extends BaseContract {
|
|
|
2586
2377
|
listeners<TCEvent extends TypedContractEvent>(event: TCEvent): Promise<Array<TypedListener<TCEvent>>>;
|
|
2587
2378
|
listeners(eventName?: string): Promise<Array<Listener>>;
|
|
2588
2379
|
removeAllListeners<TCEvent extends TypedContractEvent>(event?: TCEvent): Promise<this>;
|
|
2380
|
+
authorizeBTCSpend: TypedContractMethod<[
|
|
2381
|
+
positionId: BytesLike,
|
|
2382
|
+
txid: string,
|
|
2383
|
+
vout: BigNumberish,
|
|
2384
|
+
satoshis: BigNumberish,
|
|
2385
|
+
targetAddress: string,
|
|
2386
|
+
targetAmount: BigNumberish,
|
|
2387
|
+
litSignature: BytesLike
|
|
2388
|
+
], [
|
|
2389
|
+
bigint
|
|
2390
|
+
], "nonpayable">;
|
|
2589
2391
|
calculateCollateralRatio: TypedContractMethod<[
|
|
2590
2392
|
positionId: BytesLike
|
|
2591
2393
|
], [
|
|
@@ -2647,6 +2449,17 @@ interface ILoanOperationsManager extends BaseContract {
|
|
|
2647
2449
|
boolean
|
|
2648
2450
|
], "nonpayable">;
|
|
2649
2451
|
getFunction<T extends ContractMethod = ContractMethod>(key: string | FunctionFragment): T;
|
|
2452
|
+
getFunction(nameOrSignature: "authorizeBTCSpend"): TypedContractMethod<[
|
|
2453
|
+
positionId: BytesLike,
|
|
2454
|
+
txid: string,
|
|
2455
|
+
vout: BigNumberish,
|
|
2456
|
+
satoshis: BigNumberish,
|
|
2457
|
+
targetAddress: string,
|
|
2458
|
+
targetAmount: BigNumberish,
|
|
2459
|
+
litSignature: BytesLike
|
|
2460
|
+
], [
|
|
2461
|
+
bigint
|
|
2462
|
+
], "nonpayable">;
|
|
2650
2463
|
getFunction(nameOrSignature: "calculateCollateralRatio"): TypedContractMethod<[positionId: BytesLike], [bigint], "view">;
|
|
2651
2464
|
getFunction(nameOrSignature: "getCurrentBTCPrice"): TypedContractMethod<[], [bigint], "view">;
|
|
2652
2465
|
getFunction(nameOrSignature: "getOriginationFeeBalance"): TypedContractMethod<[], [bigint], "view">;
|
|
@@ -4148,6 +3961,99 @@ declare class MockTokenManager {
|
|
|
4148
3961
|
*/
|
|
4149
3962
|
declare function createMockTokenManager(config: MockTokenManagerConfig): Result$1<MockTokenManager, SDKError>;
|
|
4150
3963
|
|
|
3964
|
+
/**
|
|
3965
|
+
* Cache Manager Module
|
|
3966
|
+
*
|
|
3967
|
+
* Provides a simple cache factory for SDK modules.
|
|
3968
|
+
* Each cache is an independent LRU cache with TTL support.
|
|
3969
|
+
*/
|
|
3970
|
+
interface CacheConfig {
|
|
3971
|
+
maxSize: number;
|
|
3972
|
+
ttlMs: number;
|
|
3973
|
+
}
|
|
3974
|
+
interface CacheStats {
|
|
3975
|
+
size: number;
|
|
3976
|
+
maxSize: number;
|
|
3977
|
+
ttlMs: number;
|
|
3978
|
+
}
|
|
3979
|
+
/**
|
|
3980
|
+
* Simple LRU Cache with TTL support
|
|
3981
|
+
*/
|
|
3982
|
+
declare class Cache<T = any> {
|
|
3983
|
+
private cache;
|
|
3984
|
+
private readonly maxSize;
|
|
3985
|
+
private readonly ttlMs;
|
|
3986
|
+
constructor(config: CacheConfig);
|
|
3987
|
+
/**
|
|
3988
|
+
* Get value from cache
|
|
3989
|
+
*/
|
|
3990
|
+
get(key: string): T | undefined;
|
|
3991
|
+
/**
|
|
3992
|
+
* Set value in cache
|
|
3993
|
+
*/
|
|
3994
|
+
set(key: string, value: T, ttl?: number): void;
|
|
3995
|
+
/**
|
|
3996
|
+
* Check if key exists in cache
|
|
3997
|
+
*/
|
|
3998
|
+
has(key: string): boolean;
|
|
3999
|
+
/**
|
|
4000
|
+
* Delete key from cache
|
|
4001
|
+
*/
|
|
4002
|
+
delete(key: string): boolean;
|
|
4003
|
+
/**
|
|
4004
|
+
* Clear all cache entries
|
|
4005
|
+
*/
|
|
4006
|
+
clear(): void;
|
|
4007
|
+
/**
|
|
4008
|
+
* Clean expired entries
|
|
4009
|
+
*/
|
|
4010
|
+
cleanExpired(): number;
|
|
4011
|
+
/**
|
|
4012
|
+
* Get cache statistics
|
|
4013
|
+
*/
|
|
4014
|
+
getStats(): {
|
|
4015
|
+
size: number;
|
|
4016
|
+
maxSize: number;
|
|
4017
|
+
ttlMs: number;
|
|
4018
|
+
};
|
|
4019
|
+
}
|
|
4020
|
+
/**
|
|
4021
|
+
* Cache Manager
|
|
4022
|
+
*
|
|
4023
|
+
* Factory for creating named caches with specific configurations
|
|
4024
|
+
*/
|
|
4025
|
+
declare class CacheManager {
|
|
4026
|
+
private caches;
|
|
4027
|
+
private readonly debug;
|
|
4028
|
+
constructor(config?: {
|
|
4029
|
+
debug?: boolean;
|
|
4030
|
+
});
|
|
4031
|
+
/**
|
|
4032
|
+
* Get or create a cache instance
|
|
4033
|
+
*/
|
|
4034
|
+
getCache<T = any>(name: string, config: CacheConfig): Cache<T>;
|
|
4035
|
+
/**
|
|
4036
|
+
* Clear all caches
|
|
4037
|
+
*/
|
|
4038
|
+
clearAll(): void;
|
|
4039
|
+
/**
|
|
4040
|
+
* Clean expired entries from all caches
|
|
4041
|
+
*/
|
|
4042
|
+
cleanAllExpired(): number;
|
|
4043
|
+
/**
|
|
4044
|
+
* Get statistics for all caches
|
|
4045
|
+
*/
|
|
4046
|
+
getAllStats(): Record<string, ReturnType<Cache["getStats"]>>;
|
|
4047
|
+
/**
|
|
4048
|
+
* Destroy cache manager
|
|
4049
|
+
*/
|
|
4050
|
+
destroy(): void;
|
|
4051
|
+
}
|
|
4052
|
+
|
|
4053
|
+
declare function createCacheManager(config?: {
|
|
4054
|
+
debug?: boolean;
|
|
4055
|
+
}): CacheManager;
|
|
4056
|
+
|
|
4151
4057
|
declare enum LoanStatus {
|
|
4152
4058
|
PENDING_DEPOSIT = 0,
|
|
4153
4059
|
PENDING_MINT = 1,
|
|
@@ -4363,6 +4269,8 @@ interface BTCWithdrawalResult {
|
|
|
4363
4269
|
networkFee?: number;
|
|
4364
4270
|
amountWithdrawn?: string;
|
|
4365
4271
|
bitcoinTransactionHash?: string;
|
|
4272
|
+
utxoTxid?: string;
|
|
4273
|
+
utxoVout?: number;
|
|
4366
4274
|
error?: string;
|
|
4367
4275
|
}
|
|
4368
4276
|
/**
|
|
@@ -4477,6 +4385,18 @@ interface BitcoinBalanceResult {
|
|
|
4477
4385
|
timestamp: number;
|
|
4478
4386
|
}
|
|
4479
4387
|
|
|
4388
|
+
/**
|
|
4389
|
+
* Bitcoin Operations Module
|
|
4390
|
+
*
|
|
4391
|
+
* Responsible for:
|
|
4392
|
+
* - Deriving Bitcoin addresses from PKP public keys
|
|
4393
|
+
* - Querying Bitcoin balances (with multi-provider consensus)
|
|
4394
|
+
* - Validating Bitcoin transactions
|
|
4395
|
+
* - Caching Bitcoin data for performance
|
|
4396
|
+
*
|
|
4397
|
+
* Uses branded types (Satoshis) for type-safe Bitcoin amounts
|
|
4398
|
+
*/
|
|
4399
|
+
|
|
4480
4400
|
/**
|
|
4481
4401
|
* Bitcoin network type
|
|
4482
4402
|
*/
|
|
@@ -4492,9 +4412,9 @@ interface BitcoinOperationsConfig {
|
|
|
4492
4412
|
/** Consensus mode: single or majority */
|
|
4493
4413
|
consensusMode?: "single" | "majority";
|
|
4494
4414
|
/** Cache for balance results */
|
|
4495
|
-
balanceCache?:
|
|
4415
|
+
balanceCache?: Cache<BitcoinBalanceResult>;
|
|
4496
4416
|
/** Cache for address derivations */
|
|
4497
|
-
addressCache?:
|
|
4417
|
+
addressCache?: Cache<BitcoinAddresses>;
|
|
4498
4418
|
/** LitOps instance for price oracle queries (optional) */
|
|
4499
4419
|
litOps?: any;
|
|
4500
4420
|
/** Signer for LIT Protocol operations (required for getBTCPrice) */
|
|
@@ -4641,11 +4561,19 @@ declare class BitcoinOperations {
|
|
|
4641
4561
|
/**
|
|
4642
4562
|
* Get balance cache statistics
|
|
4643
4563
|
*/
|
|
4644
|
-
getBalanceCacheStats():
|
|
4564
|
+
getBalanceCacheStats(): {
|
|
4565
|
+
size: number;
|
|
4566
|
+
maxSize: number;
|
|
4567
|
+
ttlMs: number;
|
|
4568
|
+
} | null;
|
|
4645
4569
|
/**
|
|
4646
4570
|
* Get address cache statistics
|
|
4647
4571
|
*/
|
|
4648
|
-
getAddressCacheStats():
|
|
4572
|
+
getAddressCacheStats(): {
|
|
4573
|
+
size: number;
|
|
4574
|
+
maxSize: number;
|
|
4575
|
+
ttlMs: number;
|
|
4576
|
+
} | null;
|
|
4649
4577
|
/**
|
|
4650
4578
|
* Get current network configuration
|
|
4651
4579
|
*/
|
|
@@ -4946,13 +4874,11 @@ declare class DiamondHandsSDK {
|
|
|
4946
4874
|
private readonly cacheManager;
|
|
4947
4875
|
private readonly litOps;
|
|
4948
4876
|
private readonly pkpManager;
|
|
4949
|
-
private readonly pkpAuthorization;
|
|
4950
4877
|
private readonly loanCreator;
|
|
4951
4878
|
private readonly loanQuery;
|
|
4952
4879
|
private readonly bitcoinOperations;
|
|
4953
4880
|
private readonly mockTokenManager?;
|
|
4954
4881
|
private readonly graphClient;
|
|
4955
|
-
private readonly btcWithdrawalCid;
|
|
4956
4882
|
private isInitialized;
|
|
4957
4883
|
private isDisposed;
|
|
4958
4884
|
/**
|
|
@@ -5027,64 +4953,6 @@ declare class DiamondHandsSDK {
|
|
|
5027
4953
|
* Check if SDK is ready for operations
|
|
5028
4954
|
*/
|
|
5029
4955
|
private checkInitialized;
|
|
5030
|
-
/**
|
|
5031
|
-
* Pre-validate quantum state before Lit Action execution
|
|
5032
|
-
*
|
|
5033
|
-
* Checks on-chain quantum state to prevent wasted Lit Action executions:
|
|
5034
|
-
* 1. If quantum was already used for this position
|
|
5035
|
-
* 2. Current quantum and safe zone status
|
|
5036
|
-
* 3. Calculates wait time if quantum is already used
|
|
5037
|
-
*
|
|
5038
|
-
* @param positionIdBytes32 - Position ID in bytes32 format
|
|
5039
|
-
* @returns Pre-validation result with canProceed flag and optional wait time
|
|
5040
|
-
*/
|
|
5041
|
-
private preValidateQuantumState;
|
|
5042
|
-
/**
|
|
5043
|
-
* Wait for optimal quantum timing before starting LIT Action
|
|
5044
|
-
*
|
|
5045
|
-
* Goal: Start LIT Action execution early in a quantum window to maximize
|
|
5046
|
-
* the chance that contract submission happens within safe window.
|
|
5047
|
-
*
|
|
5048
|
-
* Optimal window: 10-15 seconds into quantum (200s window)
|
|
5049
|
-
* - Narrower window for more predictable timing
|
|
5050
|
-
* - Avoids start dead zone (0-7s)
|
|
5051
|
-
* - Leaves maximum time for LIT Action + submission (up to 185s with 200s window)
|
|
5052
|
-
*
|
|
5053
|
-
* MAX WAIT: 50 seconds to cover full quantum transition without landing in dead zone
|
|
5054
|
-
*/
|
|
5055
|
-
private waitForOptimalQuantumTiming;
|
|
5056
|
-
/**
|
|
5057
|
-
* Validate quantum timestamp on-chain before contract call
|
|
5058
|
-
*
|
|
5059
|
-
* Checks:
|
|
5060
|
-
* 1. If quantum was already used for this position
|
|
5061
|
-
* 2. If quantum is in dead zone
|
|
5062
|
-
* 3. If quantum matches current quantum
|
|
5063
|
-
*
|
|
5064
|
-
* @param positionIdBytes32 - Position ID in bytes32 format
|
|
5065
|
-
* @param quantumTimestamp - Quantum timestamp to validate
|
|
5066
|
-
* @returns Validation result with isValid flag and reason if invalid
|
|
5067
|
-
*/
|
|
5068
|
-
private validateQuantumOnChain;
|
|
5069
|
-
/**
|
|
5070
|
-
* Ensure we're in a safe quantum window before submitting contract transaction
|
|
5071
|
-
*
|
|
5072
|
-
* Strategy: Be conservative and fail fast if we're too close to dead zones or quantum expired.
|
|
5073
|
-
* This forces the caller to retry with a fresh signature rather than risk hitting dead zone
|
|
5074
|
-
* during transaction submission.
|
|
5075
|
-
*
|
|
5076
|
-
* Safe submission window: 10-150 seconds into quantum (140s window with 200s quantum)
|
|
5077
|
-
* - Avoids start dead zone: 0-9s (extra buffer for clock drift)
|
|
5078
|
-
* - Avoids end dead zone: 192-199s
|
|
5079
|
-
* - 42s buffer before end dead zone accounts for:
|
|
5080
|
-
* * Network latency to RPC node (1-5s)
|
|
5081
|
-
* * Clock drift between client and RPC node (up to 70s observed)
|
|
5082
|
-
* * Gas estimation time (1-3s)
|
|
5083
|
-
* * Safety margin (5-10s)
|
|
5084
|
-
*
|
|
5085
|
-
* @param targetTimestamp - Target timestamp (may have offset, e.g., quantum + 10)
|
|
5086
|
-
*/
|
|
5087
|
-
private ensureSafeQuantum;
|
|
5088
4956
|
/**
|
|
5089
4957
|
* Get SDK initialization state
|
|
5090
4958
|
*/
|
|
@@ -5111,17 +4979,18 @@ declare class DiamondHandsSDK {
|
|
|
5111
4979
|
*/
|
|
5112
4980
|
requestMintUCD(request: UCDMintRequest): Promise<UCDMintResult>;
|
|
5113
4981
|
/**
|
|
5114
|
-
*
|
|
5115
|
-
*
|
|
4982
|
+
* Extend position term
|
|
4983
|
+
*
|
|
4984
|
+
* @param positionId - Position identifier
|
|
4985
|
+
* @param selectedTerm - Extension term in months
|
|
4986
|
+
* @returns Transaction receipt
|
|
5116
4987
|
*/
|
|
5117
|
-
private executeMintUCD;
|
|
5118
4988
|
/**
|
|
5119
4989
|
* Make a partial payment on a loan
|
|
5120
4990
|
*
|
|
5121
4991
|
* @param request - Partial payment request with position ID and amount
|
|
5122
4992
|
* @returns Partial payment result with transaction details
|
|
5123
4993
|
*/
|
|
5124
|
-
partPayment(request: PartialPaymentRequest): Promise<PartialPaymentResult>;
|
|
5125
4994
|
/**
|
|
5126
4995
|
* Withdraw Bitcoin from a position
|
|
5127
4996
|
*
|
|
@@ -5131,7 +5000,94 @@ declare class DiamondHandsSDK {
|
|
|
5131
5000
|
* @param networkFee - Network fee for Bitcoin transaction in satoshis (REQUIRED)
|
|
5132
5001
|
* @returns Withdrawal result with transaction details
|
|
5133
5002
|
*/
|
|
5134
|
-
|
|
5003
|
+
/**
|
|
5004
|
+
* Withdraw BTC from position vault
|
|
5005
|
+
*
|
|
5006
|
+
* IMPORTANT: withdrawalAmount is the TOTAL DEDUCTION from vault.
|
|
5007
|
+
* The operator will deduct the actual network fee at execution time.
|
|
5008
|
+
* User receives: withdrawalAmount - actualNetworkFee
|
|
5009
|
+
*
|
|
5010
|
+
* @param positionId - Position identifier
|
|
5011
|
+
* @param withdrawalAddress - Bitcoin address to receive withdrawn funds
|
|
5012
|
+
* @param withdrawalAmount - Total amount to deduct from vault in satoshis (includes fee)
|
|
5013
|
+
* @param customRpcUrl - Optional custom RPC URL for LIT Action (for local testing)
|
|
5014
|
+
* @param customBitcoinRpcUrl - Optional custom Bitcoin RPC URL (for local testing)
|
|
5015
|
+
* @returns Withdrawal result with transaction details
|
|
5016
|
+
*/
|
|
5017
|
+
withdrawBTC(positionId: string, withdrawalAddress: string, withdrawalAmount: number, customRpcUrl?: string, customBitcoinRpcUrl?: string): Promise<BTCWithdrawalResult>;
|
|
5018
|
+
/**
|
|
5019
|
+
* Execute Bitcoin withdrawal (Phase 2)
|
|
5020
|
+
*
|
|
5021
|
+
* Signs and broadcasts the Bitcoin transaction for an authorized withdrawal.
|
|
5022
|
+
* User must have previously authorized the withdrawal via withdrawBTC().
|
|
5023
|
+
*
|
|
5024
|
+
* @param request - Execution request with positionId, utxoIdentifier, and networkFee
|
|
5025
|
+
* @returns Execution result with Bitcoin txid
|
|
5026
|
+
*/
|
|
5027
|
+
executeBTCWithdrawal(request: {
|
|
5028
|
+
positionId: string;
|
|
5029
|
+
utxoIdentifier: string;
|
|
5030
|
+
networkFee: number;
|
|
5031
|
+
destination: string;
|
|
5032
|
+
customRpcUrl?: string;
|
|
5033
|
+
customBitcoinRpcUrl?: string;
|
|
5034
|
+
}): Promise<{
|
|
5035
|
+
success: boolean;
|
|
5036
|
+
txid?: string;
|
|
5037
|
+
amountSent?: number;
|
|
5038
|
+
networkFee?: number;
|
|
5039
|
+
destination?: string;
|
|
5040
|
+
error?: string;
|
|
5041
|
+
}>;
|
|
5042
|
+
/**
|
|
5043
|
+
* Execute pending Bitcoin transfers
|
|
5044
|
+
*
|
|
5045
|
+
* Queries authorized spends that haven't been broadcast to Bitcoin network yet
|
|
5046
|
+
* and executes them by signing and broadcasting the transactions.
|
|
5047
|
+
*
|
|
5048
|
+
* @param positionId - Position identifier
|
|
5049
|
+
* @param networkFee - Network fee for Bitcoin transaction in satoshis
|
|
5050
|
+
* @param customRpcUrl - Optional custom RPC URL for LIT Action (for local testing)
|
|
5051
|
+
* @returns Array of execution results for each pending transfer
|
|
5052
|
+
*/
|
|
5053
|
+
executePendingBtcTransfers(positionId: string, networkFee: number, customRpcUrl?: string): Promise<Array<{
|
|
5054
|
+
success: boolean;
|
|
5055
|
+
utxoIdentifier?: string;
|
|
5056
|
+
txid?: string;
|
|
5057
|
+
amountSent?: number;
|
|
5058
|
+
networkFee?: number;
|
|
5059
|
+
destination?: string;
|
|
5060
|
+
error?: string;
|
|
5061
|
+
}>>;
|
|
5062
|
+
/**
|
|
5063
|
+
* Withdraw BTC and execute transfer (Complete Flow)
|
|
5064
|
+
*
|
|
5065
|
+
* Performs both Phase 1 (authorization) and Phase 2 (execution) in sequence:
|
|
5066
|
+
* 1. Authorizes withdrawal on contract (withdrawBTC)
|
|
5067
|
+
* 2. Executes pending Bitcoin transfers (signs and broadcasts)
|
|
5068
|
+
*
|
|
5069
|
+
* @param positionId - Position identifier
|
|
5070
|
+
* @param withdrawalAddress - Bitcoin address to receive withdrawn funds
|
|
5071
|
+
* @param withdrawalAmount - Total amount to deduct from vault in satoshis
|
|
5072
|
+
* @param networkFee - Network fee for Bitcoin transaction in satoshis
|
|
5073
|
+
* @param customRpcUrl - Optional custom RPC URL for LIT Action (for local testing)
|
|
5074
|
+
* @param customBitcoinRpcUrl - Optional custom Bitcoin RPC URL (for local testing)
|
|
5075
|
+
* @returns Complete withdrawal result with both authorization and execution details
|
|
5076
|
+
*/
|
|
5077
|
+
withdrawBTCAndExecute(positionId: string, withdrawalAddress: string, withdrawalAmount: number, networkFee: number, customRpcUrl?: string, customBitcoinRpcUrl?: string): Promise<{
|
|
5078
|
+
success: boolean;
|
|
5079
|
+
authorization?: BTCWithdrawalResult;
|
|
5080
|
+
transfers?: Array<{
|
|
5081
|
+
success: boolean;
|
|
5082
|
+
utxoIdentifier?: string;
|
|
5083
|
+
txid?: string;
|
|
5084
|
+
amountSent?: number;
|
|
5085
|
+
networkFee?: number;
|
|
5086
|
+
destination?: string;
|
|
5087
|
+
error?: string;
|
|
5088
|
+
}>;
|
|
5089
|
+
error?: string;
|
|
5090
|
+
}>;
|
|
5135
5091
|
/**
|
|
5136
5092
|
* Get loan data by position ID
|
|
5137
5093
|
*
|
|
@@ -5266,7 +5222,11 @@ declare class DiamondHandsSDK {
|
|
|
5266
5222
|
/**
|
|
5267
5223
|
* Get cache statistics
|
|
5268
5224
|
*/
|
|
5269
|
-
getCacheStats(): Record<string,
|
|
5225
|
+
getCacheStats(): Record<string, {
|
|
5226
|
+
size: number;
|
|
5227
|
+
maxSize: number;
|
|
5228
|
+
ttlMs: number;
|
|
5229
|
+
}>;
|
|
5270
5230
|
/**
|
|
5271
5231
|
* Get contract manager (for advanced usage)
|
|
5272
5232
|
*/
|
|
@@ -5361,7 +5321,7 @@ interface BaseAuthParams {
|
|
|
5361
5321
|
* Parameters for creating a new loan/position
|
|
5362
5322
|
*/
|
|
5363
5323
|
interface CreateLoanAuthParams extends BaseAuthParams {
|
|
5364
|
-
type:
|
|
5324
|
+
type: "create";
|
|
5365
5325
|
/** Selected loan term in months (e.g., 12, 24, 36) */
|
|
5366
5326
|
selectedTerm: number;
|
|
5367
5327
|
/** Borrower's Ethereum address */
|
|
@@ -5373,7 +5333,7 @@ interface CreateLoanAuthParams extends BaseAuthParams {
|
|
|
5373
5333
|
* Parameters for minting UCD against existing collateral
|
|
5374
5334
|
*/
|
|
5375
5335
|
interface MintUCDAuthParams extends BaseAuthParams {
|
|
5376
|
-
type:
|
|
5336
|
+
type: "mint";
|
|
5377
5337
|
/** Position/loan identifier */
|
|
5378
5338
|
positionId: string;
|
|
5379
5339
|
/** Amount of UCD to mint (in wei, 18 decimals) */
|
|
@@ -5389,15 +5349,13 @@ interface MintUCDAuthParams extends BaseAuthParams {
|
|
|
5389
5349
|
* Parameters for withdrawing Bitcoin from vault
|
|
5390
5350
|
*/
|
|
5391
5351
|
interface WithdrawBTCAuthParams extends BaseAuthParams {
|
|
5392
|
-
type:
|
|
5352
|
+
type: "withdraw";
|
|
5393
5353
|
/** Position/loan identifier */
|
|
5394
5354
|
positionId: string;
|
|
5395
5355
|
/** Destination Bitcoin address */
|
|
5396
5356
|
destinationAddress: string;
|
|
5397
5357
|
/** Amount to withdraw in satoshis */
|
|
5398
5358
|
amount: Satoshis;
|
|
5399
|
-
/** Network fee for Bitcoin transaction in satoshis */
|
|
5400
|
-
networkFee: Satoshis;
|
|
5401
5359
|
/** PKP public key */
|
|
5402
5360
|
publicKey: string;
|
|
5403
5361
|
}
|
|
@@ -5405,7 +5363,7 @@ interface WithdrawBTCAuthParams extends BaseAuthParams {
|
|
|
5405
5363
|
* Parameters for repaying UCD debt
|
|
5406
5364
|
*/
|
|
5407
5365
|
interface RepayDebtAuthParams extends BaseAuthParams {
|
|
5408
|
-
type:
|
|
5366
|
+
type: "repay";
|
|
5409
5367
|
/** Position/loan identifier */
|
|
5410
5368
|
positionId: string;
|
|
5411
5369
|
/** Amount of UCD to repay (in wei, 18 decimals) */
|
|
@@ -5417,7 +5375,7 @@ interface RepayDebtAuthParams extends BaseAuthParams {
|
|
|
5417
5375
|
* Parameters for extending loan term
|
|
5418
5376
|
*/
|
|
5419
5377
|
interface ExtendTermAuthParams extends BaseAuthParams {
|
|
5420
|
-
type:
|
|
5378
|
+
type: "extend";
|
|
5421
5379
|
/** Position/loan identifier */
|
|
5422
5380
|
positionId: string;
|
|
5423
5381
|
/** New term length in months */
|
|
@@ -5429,7 +5387,7 @@ interface ExtendTermAuthParams extends BaseAuthParams {
|
|
|
5429
5387
|
* Parameters for closing a position
|
|
5430
5388
|
*/
|
|
5431
5389
|
interface ClosePositionAuthParams extends BaseAuthParams {
|
|
5432
|
-
type:
|
|
5390
|
+
type: "close";
|
|
5433
5391
|
/** Position/loan identifier */
|
|
5434
5392
|
positionId: string;
|
|
5435
5393
|
/** Final debt amount being repaid */
|
|
@@ -5584,6 +5542,20 @@ interface PKPSigningResult {
|
|
|
5584
5542
|
publicKey?: string;
|
|
5585
5543
|
}
|
|
5586
5544
|
|
|
5545
|
+
/**
|
|
5546
|
+
* PKP Manager Module
|
|
5547
|
+
*
|
|
5548
|
+
* Responsible for:
|
|
5549
|
+
* - Creating new PKPs (via service or direct)
|
|
5550
|
+
* - Querying PKP data from contracts
|
|
5551
|
+
* - Managing PKP lifecycle
|
|
5552
|
+
* - Caching PKP data for performance
|
|
5553
|
+
*
|
|
5554
|
+
* Supports two modes:
|
|
5555
|
+
* - Service mode: Uses lit-ops-server for PKP operations
|
|
5556
|
+
* - Direct mode: Directly interacts with LIT Protocol
|
|
5557
|
+
*/
|
|
5558
|
+
|
|
5587
5559
|
/**
|
|
5588
5560
|
* PKP Manager configuration
|
|
5589
5561
|
*/
|
|
@@ -5599,7 +5571,7 @@ interface PKPManagerConfig {
|
|
|
5599
5571
|
/** Direct mode: wallet for PKP operations */
|
|
5600
5572
|
litOpsWallet?: Wallet;
|
|
5601
5573
|
/** Optional cache for PKP data */
|
|
5602
|
-
cache?:
|
|
5574
|
+
cache?: Cache<PKPData>;
|
|
5603
5575
|
/** Enable debug logging */
|
|
5604
5576
|
debug?: boolean;
|
|
5605
5577
|
/** Timeout for service requests (ms) */
|
|
@@ -5691,7 +5663,11 @@ declare class PKPManager {
|
|
|
5691
5663
|
/**
|
|
5692
5664
|
* Get cache statistics
|
|
5693
5665
|
*/
|
|
5694
|
-
getCacheStats():
|
|
5666
|
+
getCacheStats(): {
|
|
5667
|
+
size: number;
|
|
5668
|
+
maxSize: number;
|
|
5669
|
+
ttlMs: number;
|
|
5670
|
+
} | null;
|
|
5695
5671
|
}
|
|
5696
5672
|
/**
|
|
5697
5673
|
* Factory function to create a PKPManager instance
|
|
@@ -5728,7 +5704,7 @@ interface LoanCreatorConfig {
|
|
|
5728
5704
|
/** Wallet for LIT Protocol operations (Yellowstone signer, capacity credits owner) - standalone mode only */
|
|
5729
5705
|
litOpsSigner?: Wallet;
|
|
5730
5706
|
/** SDK mode: 'service' or 'standalone' */
|
|
5731
|
-
mode?:
|
|
5707
|
+
mode?: "service" | "standalone";
|
|
5732
5708
|
/** LIT Action CID for loan creation */
|
|
5733
5709
|
litActionCid: string;
|
|
5734
5710
|
/** User ID (typically wallet address) */
|
|
@@ -6412,6 +6388,18 @@ declare class DiamondHandsGraph {
|
|
|
6412
6388
|
}
|
|
6413
6389
|
type DiamondHandsGraphClient = DiamondHandsGraph;
|
|
6414
6390
|
|
|
6391
|
+
/**
|
|
6392
|
+
* Loan Query Module
|
|
6393
|
+
*
|
|
6394
|
+
* Responsible for:
|
|
6395
|
+
* - Querying loan data from subgraph
|
|
6396
|
+
* - Enriching loans with Bitcoin balance data
|
|
6397
|
+
* - Caching query results for performance
|
|
6398
|
+
* - Supporting pagination for large result sets
|
|
6399
|
+
*
|
|
6400
|
+
* Uses the existing DiamondHandsGraphClient for subgraph queries
|
|
6401
|
+
*/
|
|
6402
|
+
|
|
6415
6403
|
/**
|
|
6416
6404
|
* Loan query filters
|
|
6417
6405
|
*/
|
|
@@ -6449,7 +6437,7 @@ interface LoanQueryConfig {
|
|
|
6449
6437
|
/** Ethereum provider for PKP public key retrieval */
|
|
6450
6438
|
provider?: providers.Provider;
|
|
6451
6439
|
/** Cache for loan query results */
|
|
6452
|
-
cache?:
|
|
6440
|
+
cache?: Cache<LoanData>;
|
|
6453
6441
|
/** Enable debug logging */
|
|
6454
6442
|
debug?: boolean;
|
|
6455
6443
|
/** Default page size for pagination */
|
|
@@ -6578,7 +6566,11 @@ declare class LoanQuery {
|
|
|
6578
6566
|
/**
|
|
6579
6567
|
* Get cache statistics
|
|
6580
6568
|
*/
|
|
6581
|
-
getCacheStats():
|
|
6569
|
+
getCacheStats(): {
|
|
6570
|
+
size: number;
|
|
6571
|
+
maxSize: number;
|
|
6572
|
+
ttlMs: number;
|
|
6573
|
+
} | null;
|
|
6582
6574
|
}
|
|
6583
6575
|
/**
|
|
6584
6576
|
* Factory function to create a LoanQuery instance
|
|
@@ -6794,4 +6786,4 @@ declare const DEFAULT_BITCOIN_CONSENSUS_MODE: "majority";
|
|
|
6794
6786
|
*/
|
|
6795
6787
|
declare const MIN_BITCOIN_PROVIDERS_FOR_CONSENSUS = 2;
|
|
6796
6788
|
|
|
6797
|
-
export { AuditTrail, AuthParamsValidation, AuthorizationParams, AuthorizationRequest, AuthorizationResult, BPS, BPSConversions, BTCDepositRequest, BTCDepositResult, BTCProof, BTCTransaction, BTCWithdrawalResult, BasicNetworkConfig, BitcoinAddresses, BitcoinBalanceResult, BitcoinNetwork, BitcoinOperations, BitcoinOperationsConfig, BitcoinProviderConfig, BitcoinUTXO, BlockNumber, CacheConfig, CacheManager, CacheStats, ClosePositionAuthParams, ConfirmationResult, ContractAddresses, ContractCallOptions, ContractManager, ContractManagerConfig, ContractQueryOptions, ContractTransactionResult, CreateLoanAuthParams, CreateLoanRequest, CreateLoanResult, DEFAULT_BALANCE_CACHE_SIZE, DEFAULT_BALANCE_CACHE_TTL_MS, DEFAULT_BITCOIN_CONSENSUS_MODE, DEFAULT_CACHE_CLEANUP_INTERVAL_MS, DEFAULT_CONCURRENCY_LIMIT, DEFAULT_LIT_NETWORKS, DEFAULT_MAX_RETRIES, DEFAULT_NETWORKS, DEFAULT_NETWORK_CONFIG, DEFAULT_OPERATION_TIMEOUT_MS, DEFAULT_PAGINATION_ROWS, DEFAULT_PKP_CACHE_SIZE, DEFAULT_PKP_CACHE_TTL_MS, DebugInfo, DiamondHandsSDK, DiamondHandsSDKConfig, EnrichedBitcoinBalance, EnvironmentName, ErrorCategory, ErrorSeverity, EventFilter, EventHelpers, EventLog, ExtendTermAuthParams, Failure, FeeDistributionEvent, IBTCProof, ILitAction, IPKPManager, IUCDMinting, LRUCache, LiquidationEvent, LiquidationRequest, LitActionAuth, LitActionParams, LitActionResult, LitActionValidationResult, LoanCreationAudit, LoanCreator, LoanCreatorConfig, LoanData, LoanDataDetail, LoanEvents, LoanEventsFilter, LoanManagerConfig, LoanQuery, LoanQueryConfig, LoanQueryFilters, LoanStatus, LoansQuery, MAX_PAGINATION_ROWS, MIN_BITCOIN_PROVIDERS_FOR_CONSENSUS, ManagedContracts, MintUCDAuthParams, MintingParams, MintingResult, MockTokenManager, MockTokenManagerConfig, MockTokenTransactionResult, MonitoringOptions, NETWORK_CONFIGS, NetworkConfig, PKPCreationRequest, PKPCreationResult, PKPData, PKPIssuanceRequest, PKPManager, PKPManagerConfig, PKPSigningRequest, PKPSigningResult, PKPValidationData, PKPValidationRequest, PKPValidationResult, POSITION_MANAGER_ABI, PRICE_FEED_CONSUMER_ABI, PSM_ABI, PSM_MAX_OPERATIONS_PER_WINDOW, PSM_RATE_LIMIT_RESET_BLOCKS, PaginatedLoansResponse, PaginatedResult, Pagination, PaginationParams, PartialPaymentRequest, PartialPaymentResult, PaymentEvent, PaymentType, Position, PositionDetails, PositionQueryOptions, PositionQueryResult, PositionStatus, PositionWithBTCStatus, RepayDebtAuthParams, Result$1 as Result, RetryConfig, RewardDistribution, SDKConfig, SDKError, SDKInitOptions, SDKMode, SDK_DEFAULTS, SDK_ERROR_MESSAGES, Satoshis, SatoshisConversions, ServiceModeConfig, StandaloneModeConfig, StatusUpdateEvent, Success, THE_GRAPH_MAX_BATCH_SIZE, UCD, UCDConversions, UCDMintEvent, UCDMintRequest, UCDMintResult, UCD_TOKEN_ABI, UnixTimestamp, ValidationRequest, Wei, WeiConversions, WithdrawBTCAuthParams, andThen, collectFailures, collectSuccesses, combine, createBitcoinOperations, createCacheManager, createContractManager, createLoanCreator, createLoanQuery, createMockTokenManager, createPKPManager, DiamondHandsSDK as default, envLog, failure, firstSuccess, fromPromise, getAllNetworkConfigs, getCurrentEnvironment, getLitNetworkConfig, getNetworkConfig, getNetworkConfigByName, isClosePositionAuth, isCreateLoanAuth, isExtendTermAuth, isFailure, isMintUCDAuth, isNetworkSupported, isRepayDebtAuth, isServiceModeConfig, isStandaloneModeConfig, isSuccess, isValidPaymentType, isValidPositionStatus, isWithdrawBTCAuth, loadSDKConfig, map, mapError, match, numericToPositionStatus, success, toPromise, tryCatch, tryCatchAsync, unwrap, unwrapOr, validateSDKConfig, validateSDKEnvironment, validateServiceModeConfig, validateStandaloneModeConfig };
|
|
6789
|
+
export { AuditTrail, AuthParamsValidation, AuthorizationParams, AuthorizationRequest, AuthorizationResult, BPS, BPSConversions, BTCDepositRequest, BTCDepositResult, BTCProof, BTCTransaction, BTCWithdrawalResult, BasicNetworkConfig, BitcoinAddresses, BitcoinBalanceResult, BitcoinNetwork, BitcoinOperations, BitcoinOperationsConfig, BitcoinProviderConfig, BitcoinUTXO, BlockNumber, CacheConfig, CacheManager, CacheStats, ClosePositionAuthParams, ConfirmationResult, ContractAddresses, ContractCallOptions, ContractManager, ContractManagerConfig, ContractQueryOptions, ContractTransactionResult, CreateLoanAuthParams, CreateLoanRequest, CreateLoanResult, DEFAULT_BALANCE_CACHE_SIZE, DEFAULT_BALANCE_CACHE_TTL_MS, DEFAULT_BITCOIN_CONSENSUS_MODE, DEFAULT_CACHE_CLEANUP_INTERVAL_MS, DEFAULT_CONCURRENCY_LIMIT, DEFAULT_LIT_NETWORKS, DEFAULT_MAX_RETRIES, DEFAULT_NETWORKS, DEFAULT_NETWORK_CONFIG, DEFAULT_OPERATION_TIMEOUT_MS, DEFAULT_PAGINATION_ROWS, DEFAULT_PKP_CACHE_SIZE, DEFAULT_PKP_CACHE_TTL_MS, DebugInfo, DiamondHandsSDK, DiamondHandsSDKConfig, EnrichedBitcoinBalance, EnvironmentName, ErrorCategory, ErrorSeverity, EventFilter, EventHelpers, EventLog, ExtendTermAuthParams, Failure, FeeDistributionEvent, IBTCProof, ILitAction, IPKPManager, IUCDMinting, Cache as LRUCache, LiquidationEvent, LiquidationRequest, LitActionAuth, LitActionParams, LitActionResult, LitActionValidationResult, LoanCreationAudit, LoanCreator, LoanCreatorConfig, LoanData, LoanDataDetail, LoanEvents, LoanEventsFilter, LoanManagerConfig, LoanQuery, LoanQueryConfig, LoanQueryFilters, LoanStatus, LoansQuery, MAX_PAGINATION_ROWS, MIN_BITCOIN_PROVIDERS_FOR_CONSENSUS, ManagedContracts, MintUCDAuthParams, MintingParams, MintingResult, MockTokenManager, MockTokenManagerConfig, MockTokenTransactionResult, MonitoringOptions, NETWORK_CONFIGS, NetworkConfig, PKPCreationRequest, PKPCreationResult, PKPData, PKPIssuanceRequest, PKPManager, PKPManagerConfig, PKPSigningRequest, PKPSigningResult, PKPValidationData, PKPValidationRequest, PKPValidationResult, POSITION_MANAGER_ABI, PRICE_FEED_CONSUMER_ABI, PSM_ABI, PSM_MAX_OPERATIONS_PER_WINDOW, PSM_RATE_LIMIT_RESET_BLOCKS, PaginatedLoansResponse, PaginatedResult, Pagination, PaginationParams, PartialPaymentRequest, PartialPaymentResult, PaymentEvent, PaymentType, Position, PositionDetails, PositionQueryOptions, PositionQueryResult, PositionStatus, PositionWithBTCStatus, PriceProviderConfig, RepayDebtAuthParams, Result$1 as Result, RetryConfig, RewardDistribution, SDKConfig, SDKError, SDKInitOptions, SDKMode, SDK_DEFAULTS, SDK_ERROR_MESSAGES, Satoshis, SatoshisConversions, ServiceModeConfig, StandaloneModeConfig, StatusUpdateEvent, Success, THE_GRAPH_MAX_BATCH_SIZE, UCD, UCDConversions, UCDMintEvent, UCDMintRequest, UCDMintResult, UCD_TOKEN_ABI, UnixTimestamp, ValidationRequest, Wei, WeiConversions, WithdrawBTCAuthParams, andThen, collectFailures, collectSuccesses, combine, createBitcoinOperations, createCacheManager, createContractManager, createLoanCreator, createLoanQuery, createMockTokenManager, createPKPManager, DiamondHandsSDK as default, envLog, failure, firstSuccess, fromPromise, getAllNetworkConfigs, getCurrentEnvironment, getLitNetworkConfig, getNetworkConfig, getNetworkConfigByName, isClosePositionAuth, isCreateLoanAuth, isExtendTermAuth, isFailure, isMintUCDAuth, isNetworkSupported, isRepayDebtAuth, isServiceModeConfig, isStandaloneModeConfig, isSuccess, isValidPaymentType, isValidPositionStatus, isWithdrawBTCAuth, loadSDKConfig, map, mapError, match, numericToPositionStatus, success, toPromise, tryCatch, tryCatchAsync, unwrap, unwrapOr, validateSDKConfig, validateSDKEnvironment, validateServiceModeConfig, validateStandaloneModeConfig };
|