@gvnrdao/dh-sdk 0.0.126 → 0.0.129

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -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;
@@ -655,16 +418,6 @@ interface BaseSDKConfig {
655
418
  verboseInProduction?: boolean;
656
419
  };
657
420
  validatorVersion?: number;
658
- /**
659
- * Lit Action execution mode (standalone mode only)
660
- * In service mode, actions are always executed via the service endpoint
661
- * - 'ipfs': Execute from IPFS CID (client-side, default for standalone)
662
- * - 'code': Execute inline code via service
663
- * @note This setting is ignored when mode === 'service'
664
- */
665
- litActionExecution?: 'ipfs' | 'code';
666
- ucdMintValidatorCid?: string;
667
- btcWithdrawalCid?: string;
668
421
  defaultSelectedTermMonths?: number;
669
422
  telegram?: {
670
423
  chatId: string;
@@ -773,6 +526,7 @@ interface BitcoinProviderConfig {
773
526
  interface PriceProviderConfig {
774
527
  name: string;
775
528
  apiKey?: string;
529
+ apiSecret?: string;
776
530
  }
777
531
 
778
532
  interface TypedDeferredTopicFilter<_TCEvent extends TypedContractEvent> extends DeferredTopicFilter {
@@ -884,7 +638,6 @@ declare namespace IPositionManager {
884
638
  positionId: BytesLike;
885
639
  pkpId: BytesLike;
886
640
  ucdDebt: BigNumberish;
887
- vaultAddress: string;
888
641
  borrower: AddressLike;
889
642
  createdAt: BigNumberish;
890
643
  lastUpdated: BigNumberish;
@@ -896,7 +649,6 @@ declare namespace IPositionManager {
896
649
  positionId: string,
897
650
  pkpId: string,
898
651
  ucdDebt: bigint,
899
- vaultAddress: string,
900
652
  borrower: string,
901
653
  createdAt: bigint,
902
654
  lastUpdated: bigint,
@@ -907,7 +659,6 @@ declare namespace IPositionManager {
907
659
  positionId: string;
908
660
  pkpId: string;
909
661
  ucdDebt: bigint;
910
- vaultAddress: string;
911
662
  borrower: string;
912
663
  createdAt: bigint;
913
664
  lastUpdated: bigint;
@@ -916,9 +667,49 @@ declare namespace IPositionManager {
916
667
  status: bigint;
917
668
  };
918
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
+ }
919
710
  interface PositionManagerInterface extends Interface {
920
- 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;
921
- getEvent(nameOrSignatureOrTopic: "CollateralRatioUpdated" | "Initialized" | "IntegrityCheckFailed" | "ModulesUpdatedBatch" | "PKPLogicValidated" | "PKPValidationRegistryUpdated" | "PartialPaymentMade" | "Paused" | "PositionClosed" | "PositionCreated" | "PositionLiquidated" | "PositionRenewed" | "PositionRepaid" | "PositionStatusUpdated" | "PositionUpdated" | "RoleAdminChanged" | "RoleGranted" | "RoleRevoked" | "UCDMinted" | "Unpaused" | "Upgraded" | "WithdrawBTCSignatureDebug"): EventFragment;
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;
922
713
  encodeFunctionData(functionFragment: "ADMIN_ROLE", values?: undefined): string;
923
714
  encodeFunctionData(functionFragment: "COMMUNITY_FEE_DISTRIBUTOR_ROLE", values?: undefined): string;
924
715
  encodeFunctionData(functionFragment: "COMMUNITY_MINTER_ROLE", values?: undefined): string;
@@ -928,17 +719,18 @@ interface PositionManagerInterface extends Interface {
928
719
  encodeFunctionData(functionFragment: "ORACLE_UPDATER_ROLE", values?: undefined): string;
929
720
  encodeFunctionData(functionFragment: "UPGRADE_INTERFACE_VERSION", values?: undefined): string;
930
721
  encodeFunctionData(functionFragment: "VERSION", values?: undefined): string;
931
- encodeFunctionData(functionFragment: "_performExtensionValidation", values: [IPositionManagerCore.PositionStruct, BigNumberish]): string;
722
+ encodeFunctionData(functionFragment: "_performExtensionValidation", values: [IPositionManagerCore.PositionStruct, BigNumberish, BigNumberish]): string;
932
723
  encodeFunctionData(functionFragment: "admin", values?: undefined): string;
933
724
  encodeFunctionData(functionFragment: "authorizationRegistry", values?: undefined): string;
934
725
  encodeFunctionData(functionFragment: "calculateCollateralRatio", values: [BytesLike]): string;
935
726
  encodeFunctionData(functionFragment: "circuitBreaker", values?: undefined): string;
727
+ encodeFunctionData(functionFragment: "clearExtensionPending", values: [BytesLike]): string;
936
728
  encodeFunctionData(functionFragment: "collateral", values?: undefined): string;
937
729
  encodeFunctionData(functionFragment: "commitLiquidation", values: [BytesLike, BytesLike]): string;
938
730
  encodeFunctionData(functionFragment: "communityManager", values?: undefined): string;
939
731
  encodeFunctionData(functionFragment: "core", values?: undefined): string;
940
- encodeFunctionData(functionFragment: "createPosition", values: [BytesLike, BytesLike, string, BigNumberish, BigNumberish]): string;
941
- 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;
942
734
  encodeFunctionData(functionFragment: "getExpiredLoanLiquidationThreshold", values: [BytesLike]): string;
943
735
  encodeFunctionData(functionFragment: "getPKPLoanParams", values: [BytesLike]): string;
944
736
  encodeFunctionData(functionFragment: "getPKPPositionData", values: [BytesLike]): string;
@@ -991,14 +783,7 @@ interface PositionManagerInterface extends Interface {
991
783
  encodeFunctionData(functionFragment: "validatePKPLogic", values: [BytesLike]): string;
992
784
  encodeFunctionData(functionFragment: "validateUpgrade", values: [AddressLike]): string;
993
785
  encodeFunctionData(functionFragment: "views", values?: undefined): string;
994
- encodeFunctionData(functionFragment: "withdrawBTC", values: [
995
- BytesLike,
996
- string,
997
- BigNumberish,
998
- BigNumberish,
999
- BigNumberish,
1000
- BytesLike
1001
- ]): string;
786
+ encodeFunctionData(functionFragment: "withdrawBTC", values: [ICollateralManager.WithdrawalParamsStruct, BytesLike]): string;
1002
787
  decodeFunctionResult(functionFragment: "ADMIN_ROLE", data: BytesLike): Result$2;
1003
788
  decodeFunctionResult(functionFragment: "COMMUNITY_FEE_DISTRIBUTOR_ROLE", data: BytesLike): Result$2;
1004
789
  decodeFunctionResult(functionFragment: "COMMUNITY_MINTER_ROLE", data: BytesLike): Result$2;
@@ -1013,6 +798,7 @@ interface PositionManagerInterface extends Interface {
1013
798
  decodeFunctionResult(functionFragment: "authorizationRegistry", data: BytesLike): Result$2;
1014
799
  decodeFunctionResult(functionFragment: "calculateCollateralRatio", data: BytesLike): Result$2;
1015
800
  decodeFunctionResult(functionFragment: "circuitBreaker", data: BytesLike): Result$2;
801
+ decodeFunctionResult(functionFragment: "clearExtensionPending", data: BytesLike): Result$2;
1016
802
  decodeFunctionResult(functionFragment: "collateral", data: BytesLike): Result$2;
1017
803
  decodeFunctionResult(functionFragment: "commitLiquidation", data: BytesLike): Result$2;
1018
804
  decodeFunctionResult(functionFragment: "communityManager", data: BytesLike): Result$2;
@@ -1075,6 +861,18 @@ declare namespace CollateralRatioUpdatedEvent {
1075
861
  type Log = TypedEventLog<Event>;
1076
862
  type LogDescription = TypedLogDescription<Event>;
1077
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
+ }
1078
876
  declare namespace InitializedEvent$1 {
1079
877
  type InputTuple = [version: BigNumberish];
1080
878
  type OutputTuple = [version: bigint];
@@ -1461,39 +1259,6 @@ declare namespace UpgradedEvent$1 {
1461
1259
  type Log = TypedEventLog<Event>;
1462
1260
  type LogDescription = TypedLogDescription<Event>;
1463
1261
  }
1464
- declare namespace WithdrawBTCSignatureDebugEvent {
1465
- type InputTuple = [
1466
- positionId: BytesLike,
1467
- messageHash: BytesLike,
1468
- expectedPkp: AddressLike,
1469
- recoveredPkp: AddressLike,
1470
- isValid: boolean,
1471
- btcPrice: BigNumberish,
1472
- quantumTimestamp: BigNumberish
1473
- ];
1474
- type OutputTuple = [
1475
- positionId: string,
1476
- messageHash: string,
1477
- expectedPkp: string,
1478
- recoveredPkp: string,
1479
- isValid: boolean,
1480
- btcPrice: bigint,
1481
- quantumTimestamp: bigint
1482
- ];
1483
- interface OutputObject {
1484
- positionId: string;
1485
- messageHash: string;
1486
- expectedPkp: string;
1487
- recoveredPkp: string;
1488
- isValid: boolean;
1489
- btcPrice: bigint;
1490
- quantumTimestamp: bigint;
1491
- }
1492
- type Event = TypedContractEvent<InputTuple, OutputTuple, OutputObject>;
1493
- type Filter = TypedDeferredTopicFilter<Event>;
1494
- type Log = TypedEventLog<Event>;
1495
- type LogDescription = TypedLogDescription<Event>;
1496
- }
1497
1262
  interface PositionManager extends BaseContract {
1498
1263
  connect(runner?: ContractRunner | null): PositionManager;
1499
1264
  waitForDeployment(): Promise<this>;
@@ -1518,7 +1283,8 @@ interface PositionManager extends BaseContract {
1518
1283
  VERSION: TypedContractMethod<[], [string], "view">;
1519
1284
  _performExtensionValidation: TypedContractMethod<[
1520
1285
  position: IPositionManagerCore.PositionStruct,
1521
- selectedTerm: BigNumberish
1286
+ selectedTerm: BigNumberish,
1287
+ btcPrice: BigNumberish
1522
1288
  ], [
1523
1289
  [
1524
1290
  bigint,
@@ -1540,6 +1306,11 @@ interface PositionManager extends BaseContract {
1540
1306
  bigint
1541
1307
  ], "view">;
1542
1308
  circuitBreaker: TypedContractMethod<[], [string], "view">;
1309
+ clearExtensionPending: TypedContractMethod<[
1310
+ positionId: BytesLike
1311
+ ], [
1312
+ void
1313
+ ], "nonpayable">;
1543
1314
  collateral: TypedContractMethod<[], [string], "view">;
1544
1315
  commitLiquidation: TypedContractMethod<[
1545
1316
  positionId: BytesLike,
@@ -1552,7 +1323,8 @@ interface PositionManager extends BaseContract {
1552
1323
  createPosition: TypedContractMethod<[
1553
1324
  pkpId: BytesLike,
1554
1325
  validatorSignature: BytesLike,
1555
- vaultAddress: string,
1326
+ mainnetVaultAddress: string,
1327
+ regtestVaultAddress: string,
1556
1328
  selectedTermMonths: BigNumberish,
1557
1329
  validatorVersion: BigNumberish
1558
1330
  ], [
@@ -1560,7 +1332,10 @@ interface PositionManager extends BaseContract {
1560
1332
  ], "nonpayable">;
1561
1333
  extendPosition: TypedContractMethod<[
1562
1334
  positionId: BytesLike,
1563
- selectedTerm: BigNumberish
1335
+ selectedTerm: BigNumberish,
1336
+ quantumTimestamp: BigNumberish,
1337
+ btcPrice: BigNumberish,
1338
+ extensionValidatorSignature: BytesLike
1564
1339
  ], [
1565
1340
  boolean
1566
1341
  ], "nonpayable">;
@@ -1724,11 +1499,7 @@ interface PositionManager extends BaseContract {
1724
1499
  ], "view">;
1725
1500
  views: TypedContractMethod<[], [string], "view">;
1726
1501
  withdrawBTC: TypedContractMethod<[
1727
- positionId: BytesLike,
1728
- withdrawalAddress: string,
1729
- networkFee: BigNumberish,
1730
- quantumTimestamp: BigNumberish,
1731
- btcPrice: BigNumberish,
1502
+ params: ICollateralManager.WithdrawalParamsStruct,
1732
1503
  withdrawalValidatorSignature: BytesLike
1733
1504
  ], [
1734
1505
  boolean
@@ -1745,7 +1516,8 @@ interface PositionManager extends BaseContract {
1745
1516
  getFunction(nameOrSignature: "VERSION"): TypedContractMethod<[], [string], "view">;
1746
1517
  getFunction(nameOrSignature: "_performExtensionValidation"): TypedContractMethod<[
1747
1518
  position: IPositionManagerCore.PositionStruct,
1748
- selectedTerm: BigNumberish
1519
+ selectedTerm: BigNumberish,
1520
+ btcPrice: BigNumberish
1749
1521
  ], [
1750
1522
  [
1751
1523
  bigint,
@@ -1763,6 +1535,7 @@ interface PositionManager extends BaseContract {
1763
1535
  getFunction(nameOrSignature: "authorizationRegistry"): TypedContractMethod<[], [string], "view">;
1764
1536
  getFunction(nameOrSignature: "calculateCollateralRatio"): TypedContractMethod<[positionId: BytesLike], [bigint], "view">;
1765
1537
  getFunction(nameOrSignature: "circuitBreaker"): TypedContractMethod<[], [string], "view">;
1538
+ getFunction(nameOrSignature: "clearExtensionPending"): TypedContractMethod<[positionId: BytesLike], [void], "nonpayable">;
1766
1539
  getFunction(nameOrSignature: "collateral"): TypedContractMethod<[], [string], "view">;
1767
1540
  getFunction(nameOrSignature: "commitLiquidation"): TypedContractMethod<[
1768
1541
  positionId: BytesLike,
@@ -1775,7 +1548,8 @@ interface PositionManager extends BaseContract {
1775
1548
  getFunction(nameOrSignature: "createPosition"): TypedContractMethod<[
1776
1549
  pkpId: BytesLike,
1777
1550
  validatorSignature: BytesLike,
1778
- vaultAddress: string,
1551
+ mainnetVaultAddress: string,
1552
+ regtestVaultAddress: string,
1779
1553
  selectedTermMonths: BigNumberish,
1780
1554
  validatorVersion: BigNumberish
1781
1555
  ], [
@@ -1783,7 +1557,10 @@ interface PositionManager extends BaseContract {
1783
1557
  ], "nonpayable">;
1784
1558
  getFunction(nameOrSignature: "extendPosition"): TypedContractMethod<[
1785
1559
  positionId: BytesLike,
1786
- selectedTerm: BigNumberish
1560
+ selectedTerm: BigNumberish,
1561
+ quantumTimestamp: BigNumberish,
1562
+ btcPrice: BigNumberish,
1563
+ extensionValidatorSignature: BytesLike
1787
1564
  ], [
1788
1565
  boolean
1789
1566
  ], "nonpayable">;
@@ -1915,16 +1692,13 @@ interface PositionManager extends BaseContract {
1915
1692
  getFunction(nameOrSignature: "validateUpgrade"): TypedContractMethod<[newImplementation: AddressLike], [boolean], "view">;
1916
1693
  getFunction(nameOrSignature: "views"): TypedContractMethod<[], [string], "view">;
1917
1694
  getFunction(nameOrSignature: "withdrawBTC"): TypedContractMethod<[
1918
- positionId: BytesLike,
1919
- withdrawalAddress: string,
1920
- networkFee: BigNumberish,
1921
- quantumTimestamp: BigNumberish,
1922
- btcPrice: BigNumberish,
1695
+ params: ICollateralManager.WithdrawalParamsStruct,
1923
1696
  withdrawalValidatorSignature: BytesLike
1924
1697
  ], [
1925
1698
  boolean
1926
1699
  ], "nonpayable">;
1927
1700
  getEvent(key: "CollateralRatioUpdated"): TypedContractEvent<CollateralRatioUpdatedEvent.InputTuple, CollateralRatioUpdatedEvent.OutputTuple, CollateralRatioUpdatedEvent.OutputObject>;
1701
+ getEvent(key: "ExtensionPendingCleared"): TypedContractEvent<ExtensionPendingClearedEvent.InputTuple, ExtensionPendingClearedEvent.OutputTuple, ExtensionPendingClearedEvent.OutputObject>;
1928
1702
  getEvent(key: "Initialized"): TypedContractEvent<InitializedEvent$1.InputTuple, InitializedEvent$1.OutputTuple, InitializedEvent$1.OutputObject>;
1929
1703
  getEvent(key: "IntegrityCheckFailed"): TypedContractEvent<IntegrityCheckFailedEvent.InputTuple, IntegrityCheckFailedEvent.OutputTuple, IntegrityCheckFailedEvent.OutputObject>;
1930
1704
  getEvent(key: "ModulesUpdatedBatch"): TypedContractEvent<ModulesUpdatedBatchEvent.InputTuple, ModulesUpdatedBatchEvent.OutputTuple, ModulesUpdatedBatchEvent.OutputObject>;
@@ -1945,10 +1719,11 @@ interface PositionManager extends BaseContract {
1945
1719
  getEvent(key: "UCDMinted"): TypedContractEvent<UCDMintedEvent$1.InputTuple, UCDMintedEvent$1.OutputTuple, UCDMintedEvent$1.OutputObject>;
1946
1720
  getEvent(key: "Unpaused"): TypedContractEvent<UnpausedEvent$1.InputTuple, UnpausedEvent$1.OutputTuple, UnpausedEvent$1.OutputObject>;
1947
1721
  getEvent(key: "Upgraded"): TypedContractEvent<UpgradedEvent$1.InputTuple, UpgradedEvent$1.OutputTuple, UpgradedEvent$1.OutputObject>;
1948
- getEvent(key: "WithdrawBTCSignatureDebug"): TypedContractEvent<WithdrawBTCSignatureDebugEvent.InputTuple, WithdrawBTCSignatureDebugEvent.OutputTuple, WithdrawBTCSignatureDebugEvent.OutputObject>;
1949
1722
  filters: {
1950
1723
  "CollateralRatioUpdated(bytes32,uint256,uint256)": TypedContractEvent<CollateralRatioUpdatedEvent.InputTuple, CollateralRatioUpdatedEvent.OutputTuple, CollateralRatioUpdatedEvent.OutputObject>;
1951
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>;
1952
1727
  "Initialized(uint64)": TypedContractEvent<InitializedEvent$1.InputTuple, InitializedEvent$1.OutputTuple, InitializedEvent$1.OutputObject>;
1953
1728
  Initialized: TypedContractEvent<InitializedEvent$1.InputTuple, InitializedEvent$1.OutputTuple, InitializedEvent$1.OutputObject>;
1954
1729
  "IntegrityCheckFailed(bytes32,string,string,uint256)": TypedContractEvent<IntegrityCheckFailedEvent.InputTuple, IntegrityCheckFailedEvent.OutputTuple, IntegrityCheckFailedEvent.OutputObject>;
@@ -1989,8 +1764,6 @@ interface PositionManager extends BaseContract {
1989
1764
  Unpaused: TypedContractEvent<UnpausedEvent$1.InputTuple, UnpausedEvent$1.OutputTuple, UnpausedEvent$1.OutputObject>;
1990
1765
  "Upgraded(address)": TypedContractEvent<UpgradedEvent$1.InputTuple, UpgradedEvent$1.OutputTuple, UpgradedEvent$1.OutputObject>;
1991
1766
  Upgraded: TypedContractEvent<UpgradedEvent$1.InputTuple, UpgradedEvent$1.OutputTuple, UpgradedEvent$1.OutputObject>;
1992
- "WithdrawBTCSignatureDebug(bytes32,bytes32,address,address,bool,uint256,uint256)": TypedContractEvent<WithdrawBTCSignatureDebugEvent.InputTuple, WithdrawBTCSignatureDebugEvent.OutputTuple, WithdrawBTCSignatureDebugEvent.OutputObject>;
1993
- WithdrawBTCSignatureDebug: TypedContractEvent<WithdrawBTCSignatureDebugEvent.InputTuple, WithdrawBTCSignatureDebugEvent.OutputTuple, WithdrawBTCSignatureDebugEvent.OutputObject>;
1994
1767
  };
1995
1768
  }
1996
1769
 
@@ -2473,8 +2246,17 @@ interface ILiquidationManager extends BaseContract {
2473
2246
  }
2474
2247
 
2475
2248
  interface ILoanOperationsManagerInterface extends Interface {
2476
- 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;
2477
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;
2478
2260
  encodeFunctionData(functionFragment: "calculateCollateralRatio", values: [BytesLike]): string;
2479
2261
  encodeFunctionData(functionFragment: "getCurrentBTCPrice", values?: undefined): string;
2480
2262
  encodeFunctionData(functionFragment: "getOriginationFeeBalance", values?: undefined): string;
@@ -2501,6 +2283,7 @@ interface ILoanOperationsManagerInterface extends Interface {
2501
2283
  encodeFunctionData(functionFragment: "transferOriginationFee", values: [AddressLike, BigNumberish]): string;
2502
2284
  encodeFunctionData(functionFragment: "ucdToken", values?: undefined): string;
2503
2285
  encodeFunctionData(functionFragment: "updatePosition", values: [BytesLike, BigNumberish]): string;
2286
+ decodeFunctionResult(functionFragment: "authorizeBTCSpend", data: BytesLike): Result$2;
2504
2287
  decodeFunctionResult(functionFragment: "calculateCollateralRatio", data: BytesLike): Result$2;
2505
2288
  decodeFunctionResult(functionFragment: "getCurrentBTCPrice", data: BytesLike): Result$2;
2506
2289
  decodeFunctionResult(functionFragment: "getOriginationFeeBalance", data: BytesLike): Result$2;
@@ -2594,6 +2377,17 @@ interface ILoanOperationsManager extends BaseContract {
2594
2377
  listeners<TCEvent extends TypedContractEvent>(event: TCEvent): Promise<Array<TypedListener<TCEvent>>>;
2595
2378
  listeners(eventName?: string): Promise<Array<Listener>>;
2596
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">;
2597
2391
  calculateCollateralRatio: TypedContractMethod<[
2598
2392
  positionId: BytesLike
2599
2393
  ], [
@@ -2655,6 +2449,17 @@ interface ILoanOperationsManager extends BaseContract {
2655
2449
  boolean
2656
2450
  ], "nonpayable">;
2657
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">;
2658
2463
  getFunction(nameOrSignature: "calculateCollateralRatio"): TypedContractMethod<[positionId: BytesLike], [bigint], "view">;
2659
2464
  getFunction(nameOrSignature: "getCurrentBTCPrice"): TypedContractMethod<[], [bigint], "view">;
2660
2465
  getFunction(nameOrSignature: "getOriginationFeeBalance"): TypedContractMethod<[], [bigint], "view">;
@@ -4156,6 +3961,99 @@ declare class MockTokenManager {
4156
3961
  */
4157
3962
  declare function createMockTokenManager(config: MockTokenManagerConfig): Result$1<MockTokenManager, SDKError>;
4158
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
+
4159
4057
  declare enum LoanStatus {
4160
4058
  PENDING_DEPOSIT = 0,
4161
4059
  PENDING_MINT = 1,
@@ -4371,6 +4269,8 @@ interface BTCWithdrawalResult {
4371
4269
  networkFee?: number;
4372
4270
  amountWithdrawn?: string;
4373
4271
  bitcoinTransactionHash?: string;
4272
+ utxoTxid?: string;
4273
+ utxoVout?: number;
4374
4274
  error?: string;
4375
4275
  }
4376
4276
  /**
@@ -4485,6 +4385,18 @@ interface BitcoinBalanceResult {
4485
4385
  timestamp: number;
4486
4386
  }
4487
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
+
4488
4400
  /**
4489
4401
  * Bitcoin network type
4490
4402
  */
@@ -4500,9 +4412,9 @@ interface BitcoinOperationsConfig {
4500
4412
  /** Consensus mode: single or majority */
4501
4413
  consensusMode?: "single" | "majority";
4502
4414
  /** Cache for balance results */
4503
- balanceCache?: LRUCache<string, BitcoinBalanceResult>;
4415
+ balanceCache?: Cache<BitcoinBalanceResult>;
4504
4416
  /** Cache for address derivations */
4505
- addressCache?: LRUCache<string, BitcoinAddresses>;
4417
+ addressCache?: Cache<BitcoinAddresses>;
4506
4418
  /** LitOps instance for price oracle queries (optional) */
4507
4419
  litOps?: any;
4508
4420
  /** Signer for LIT Protocol operations (required for getBTCPrice) */
@@ -4649,11 +4561,19 @@ declare class BitcoinOperations {
4649
4561
  /**
4650
4562
  * Get balance cache statistics
4651
4563
  */
4652
- getBalanceCacheStats(): CacheStats | null;
4564
+ getBalanceCacheStats(): {
4565
+ size: number;
4566
+ maxSize: number;
4567
+ ttlMs: number;
4568
+ } | null;
4653
4569
  /**
4654
4570
  * Get address cache statistics
4655
4571
  */
4656
- getAddressCacheStats(): CacheStats | null;
4572
+ getAddressCacheStats(): {
4573
+ size: number;
4574
+ maxSize: number;
4575
+ ttlMs: number;
4576
+ } | null;
4657
4577
  /**
4658
4578
  * Get current network configuration
4659
4579
  */
@@ -4954,13 +4874,11 @@ declare class DiamondHandsSDK {
4954
4874
  private readonly cacheManager;
4955
4875
  private readonly litOps;
4956
4876
  private readonly pkpManager;
4957
- private readonly pkpAuthorization;
4958
4877
  private readonly loanCreator;
4959
4878
  private readonly loanQuery;
4960
4879
  private readonly bitcoinOperations;
4961
4880
  private readonly mockTokenManager?;
4962
4881
  private readonly graphClient;
4963
- private readonly btcWithdrawalCid;
4964
4882
  private isInitialized;
4965
4883
  private isDisposed;
4966
4884
  /**
@@ -5035,64 +4953,6 @@ declare class DiamondHandsSDK {
5035
4953
  * Check if SDK is ready for operations
5036
4954
  */
5037
4955
  private checkInitialized;
5038
- /**
5039
- * Pre-validate quantum state before Lit Action execution
5040
- *
5041
- * Checks on-chain quantum state to prevent wasted Lit Action executions:
5042
- * 1. If quantum was already used for this position
5043
- * 2. Current quantum and safe zone status
5044
- * 3. Calculates wait time if quantum is already used
5045
- *
5046
- * @param positionIdBytes32 - Position ID in bytes32 format
5047
- * @returns Pre-validation result with canProceed flag and optional wait time
5048
- */
5049
- private preValidateQuantumState;
5050
- /**
5051
- * Wait for optimal quantum timing before starting LIT Action
5052
- *
5053
- * Goal: Start LIT Action execution early in a quantum window to maximize
5054
- * the chance that contract submission happens within safe window.
5055
- *
5056
- * Optimal window: 10-15 seconds into quantum (100s window)
5057
- * - Narrower window for more predictable timing
5058
- * - Avoids start dead zone (0-7s)
5059
- * - Leaves maximum time for LIT Action + submission (up to 85s with 100s window)
5060
- *
5061
- * MAX WAIT: 50 seconds to cover full quantum transition without landing in dead zone
5062
- */
5063
- private waitForOptimalQuantumTiming;
5064
- /**
5065
- * Validate quantum timestamp on-chain before contract call
5066
- *
5067
- * Checks:
5068
- * 1. If quantum was already used for this position
5069
- * 2. If quantum is in dead zone
5070
- * 3. If quantum matches current quantum
5071
- *
5072
- * @param positionIdBytes32 - Position ID in bytes32 format
5073
- * @param quantumTimestamp - Quantum timestamp to validate
5074
- * @returns Validation result with isValid flag and reason if invalid
5075
- */
5076
- private validateQuantumOnChain;
5077
- /**
5078
- * Ensure we're in a safe quantum window before submitting contract transaction
5079
- *
5080
- * Strategy: Be conservative and fail fast if we're too close to dead zones or quantum expired.
5081
- * This forces the caller to retry with a fresh signature rather than risk hitting dead zone
5082
- * during transaction submission.
5083
- *
5084
- * Safe submission window: 10-91 seconds into quantum (81s window with 100s quantum)
5085
- * - Avoids start dead zone: 0-9s (extra buffer for clock drift)
5086
- * - Avoids end dead zone: 192-199s
5087
- * - 42s buffer before end dead zone accounts for:
5088
- * * Network latency to RPC node (1-5s)
5089
- * * Clock drift between client and RPC node (up to 70s observed)
5090
- * * Gas estimation time (1-3s)
5091
- * * Safety margin (5-10s)
5092
- *
5093
- * @param targetTimestamp - Target timestamp (may have offset, e.g., quantum + 10)
5094
- */
5095
- private ensureSafeQuantum;
5096
4956
  /**
5097
4957
  * Get SDK initialization state
5098
4958
  */
@@ -5119,17 +4979,18 @@ declare class DiamondHandsSDK {
5119
4979
  */
5120
4980
  requestMintUCD(request: UCDMintRequest): Promise<UCDMintResult>;
5121
4981
  /**
5122
- * Execute UCD mint request (internal implementation)
5123
- * Separated to enable retry logic
4982
+ * Extend position term
4983
+ *
4984
+ * @param positionId - Position identifier
4985
+ * @param selectedTerm - Extension term in months
4986
+ * @returns Transaction receipt
5124
4987
  */
5125
- private executeMintUCD;
5126
4988
  /**
5127
4989
  * Make a partial payment on a loan
5128
4990
  *
5129
4991
  * @param request - Partial payment request with position ID and amount
5130
4992
  * @returns Partial payment result with transaction details
5131
4993
  */
5132
- partPayment(request: PartialPaymentRequest): Promise<PartialPaymentResult>;
5133
4994
  /**
5134
4995
  * Withdraw Bitcoin from a position
5135
4996
  *
@@ -5139,7 +5000,94 @@ declare class DiamondHandsSDK {
5139
5000
  * @param networkFee - Network fee for Bitcoin transaction in satoshis (REQUIRED)
5140
5001
  * @returns Withdrawal result with transaction details
5141
5002
  */
5142
- withdrawBTC(positionId: string, withdrawalAddress: string, withdrawalAmount: number, networkFee: number): Promise<BTCWithdrawalResult>;
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
+ }>;
5143
5091
  /**
5144
5092
  * Get loan data by position ID
5145
5093
  *
@@ -5274,7 +5222,11 @@ declare class DiamondHandsSDK {
5274
5222
  /**
5275
5223
  * Get cache statistics
5276
5224
  */
5277
- getCacheStats(): Record<string, CacheStats>;
5225
+ getCacheStats(): Record<string, {
5226
+ size: number;
5227
+ maxSize: number;
5228
+ ttlMs: number;
5229
+ }>;
5278
5230
  /**
5279
5231
  * Get contract manager (for advanced usage)
5280
5232
  */
@@ -5369,7 +5321,7 @@ interface BaseAuthParams {
5369
5321
  * Parameters for creating a new loan/position
5370
5322
  */
5371
5323
  interface CreateLoanAuthParams extends BaseAuthParams {
5372
- type: 'create';
5324
+ type: "create";
5373
5325
  /** Selected loan term in months (e.g., 12, 24, 36) */
5374
5326
  selectedTerm: number;
5375
5327
  /** Borrower's Ethereum address */
@@ -5381,7 +5333,7 @@ interface CreateLoanAuthParams extends BaseAuthParams {
5381
5333
  * Parameters for minting UCD against existing collateral
5382
5334
  */
5383
5335
  interface MintUCDAuthParams extends BaseAuthParams {
5384
- type: 'mint';
5336
+ type: "mint";
5385
5337
  /** Position/loan identifier */
5386
5338
  positionId: string;
5387
5339
  /** Amount of UCD to mint (in wei, 18 decimals) */
@@ -5397,15 +5349,13 @@ interface MintUCDAuthParams extends BaseAuthParams {
5397
5349
  * Parameters for withdrawing Bitcoin from vault
5398
5350
  */
5399
5351
  interface WithdrawBTCAuthParams extends BaseAuthParams {
5400
- type: 'withdraw';
5352
+ type: "withdraw";
5401
5353
  /** Position/loan identifier */
5402
5354
  positionId: string;
5403
5355
  /** Destination Bitcoin address */
5404
5356
  destinationAddress: string;
5405
5357
  /** Amount to withdraw in satoshis */
5406
5358
  amount: Satoshis;
5407
- /** Network fee for Bitcoin transaction in satoshis */
5408
- networkFee: Satoshis;
5409
5359
  /** PKP public key */
5410
5360
  publicKey: string;
5411
5361
  }
@@ -5413,7 +5363,7 @@ interface WithdrawBTCAuthParams extends BaseAuthParams {
5413
5363
  * Parameters for repaying UCD debt
5414
5364
  */
5415
5365
  interface RepayDebtAuthParams extends BaseAuthParams {
5416
- type: 'repay';
5366
+ type: "repay";
5417
5367
  /** Position/loan identifier */
5418
5368
  positionId: string;
5419
5369
  /** Amount of UCD to repay (in wei, 18 decimals) */
@@ -5425,7 +5375,7 @@ interface RepayDebtAuthParams extends BaseAuthParams {
5425
5375
  * Parameters for extending loan term
5426
5376
  */
5427
5377
  interface ExtendTermAuthParams extends BaseAuthParams {
5428
- type: 'extend';
5378
+ type: "extend";
5429
5379
  /** Position/loan identifier */
5430
5380
  positionId: string;
5431
5381
  /** New term length in months */
@@ -5437,7 +5387,7 @@ interface ExtendTermAuthParams extends BaseAuthParams {
5437
5387
  * Parameters for closing a position
5438
5388
  */
5439
5389
  interface ClosePositionAuthParams extends BaseAuthParams {
5440
- type: 'close';
5390
+ type: "close";
5441
5391
  /** Position/loan identifier */
5442
5392
  positionId: string;
5443
5393
  /** Final debt amount being repaid */
@@ -5592,6 +5542,20 @@ interface PKPSigningResult {
5592
5542
  publicKey?: string;
5593
5543
  }
5594
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
+
5595
5559
  /**
5596
5560
  * PKP Manager configuration
5597
5561
  */
@@ -5607,7 +5571,7 @@ interface PKPManagerConfig {
5607
5571
  /** Direct mode: wallet for PKP operations */
5608
5572
  litOpsWallet?: Wallet;
5609
5573
  /** Optional cache for PKP data */
5610
- cache?: LRUCache<string, PKPData>;
5574
+ cache?: Cache<PKPData>;
5611
5575
  /** Enable debug logging */
5612
5576
  debug?: boolean;
5613
5577
  /** Timeout for service requests (ms) */
@@ -5699,7 +5663,11 @@ declare class PKPManager {
5699
5663
  /**
5700
5664
  * Get cache statistics
5701
5665
  */
5702
- getCacheStats(): CacheStats | null;
5666
+ getCacheStats(): {
5667
+ size: number;
5668
+ maxSize: number;
5669
+ ttlMs: number;
5670
+ } | null;
5703
5671
  }
5704
5672
  /**
5705
5673
  * Factory function to create a PKPManager instance
@@ -5736,7 +5704,7 @@ interface LoanCreatorConfig {
5736
5704
  /** Wallet for LIT Protocol operations (Yellowstone signer, capacity credits owner) - standalone mode only */
5737
5705
  litOpsSigner?: Wallet;
5738
5706
  /** SDK mode: 'service' or 'standalone' */
5739
- mode?: 'service' | 'standalone';
5707
+ mode?: "service" | "standalone";
5740
5708
  /** LIT Action CID for loan creation */
5741
5709
  litActionCid: string;
5742
5710
  /** User ID (typically wallet address) */
@@ -6420,6 +6388,18 @@ declare class DiamondHandsGraph {
6420
6388
  }
6421
6389
  type DiamondHandsGraphClient = DiamondHandsGraph;
6422
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
+
6423
6403
  /**
6424
6404
  * Loan query filters
6425
6405
  */
@@ -6457,7 +6437,7 @@ interface LoanQueryConfig {
6457
6437
  /** Ethereum provider for PKP public key retrieval */
6458
6438
  provider?: providers.Provider;
6459
6439
  /** Cache for loan query results */
6460
- cache?: LRUCache<string, LoanData>;
6440
+ cache?: Cache<LoanData>;
6461
6441
  /** Enable debug logging */
6462
6442
  debug?: boolean;
6463
6443
  /** Default page size for pagination */
@@ -6586,7 +6566,11 @@ declare class LoanQuery {
6586
6566
  /**
6587
6567
  * Get cache statistics
6588
6568
  */
6589
- getCacheStats(): CacheStats | null;
6569
+ getCacheStats(): {
6570
+ size: number;
6571
+ maxSize: number;
6572
+ ttlMs: number;
6573
+ } | null;
6590
6574
  }
6591
6575
  /**
6592
6576
  * Factory function to create a LoanQuery instance
@@ -6802,4 +6786,4 @@ declare const DEFAULT_BITCOIN_CONSENSUS_MODE: "majority";
6802
6786
  */
6803
6787
  declare const MIN_BITCOIN_PROVIDERS_FOR_CONSENSUS = 2;
6804
6788
 
6805
- 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, 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 };
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 };