@gvnrdao/dh-sdk 0.0.166 → 0.0.205

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.
Files changed (71) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +86 -5
  3. package/browser/dist/397.browser.js +1 -1
  4. package/browser/dist/833.browser.js +1 -1
  5. package/browser/dist/browser.js +1 -13
  6. package/browser/dist/browser.js.LICENSE.txt +1 -70
  7. package/browser/dist/index.d.ts +3 -4
  8. package/browser/dist/index.d.ts.map +1 -1
  9. package/browser/dist/index.js +4 -3
  10. package/dist/constants/chunks/contract-abis.d.ts +7 -0
  11. package/dist/constants/chunks/deployment-addresses.d.ts +68 -0
  12. package/dist/constants/chunks/encrypted-provider-params.d.ts +21 -0
  13. package/dist/constants/chunks/environment.browser.d.ts +45 -0
  14. package/dist/constants/chunks/environment.d.ts +57 -0
  15. package/dist/constants/chunks/network-configs.d.ts +65 -0
  16. package/dist/constants/chunks/sdk-config.d.ts +33 -0
  17. package/dist/constants/chunks/sdk-limits.d.ts +66 -0
  18. package/dist/constants/index.d.ts +15 -0
  19. package/dist/graphs/client.d.ts +19 -0
  20. package/dist/graphs/diamond-hands.d.ts +248 -0
  21. package/dist/index.d.ts +47 -7391
  22. package/dist/index.js +4525 -16860
  23. package/dist/index.mjs +4489 -16801
  24. package/dist/interfaces/chunks/btc.i.d.ts +36 -0
  25. package/dist/interfaces/chunks/config.i.d.ts +250 -0
  26. package/dist/interfaces/chunks/contract-interactions.i.d.ts +64 -0
  27. package/dist/interfaces/chunks/contract-types.i.d.ts +165 -0
  28. package/dist/interfaces/chunks/lit-actions-results.i.d.ts +165 -0
  29. package/dist/interfaces/chunks/lit-actions.i.d.ts +98 -0
  30. package/dist/interfaces/chunks/loan-operations.i.d.ts +332 -0
  31. package/dist/interfaces/chunks/pkp-integration.i.d.ts +87 -0
  32. package/dist/interfaces/chunks/position-query.i.d.ts +76 -0
  33. package/dist/interfaces/chunks/requests.i.d.ts +55 -0
  34. package/dist/interfaces/chunks/ucd-minting.i.d.ts +34 -0
  35. package/dist/interfaces/chunks/utility.i.d.ts +64 -0
  36. package/dist/interfaces/index.d.ts +17 -0
  37. package/dist/modules/bitcoin/bitcoin-operations.module.d.ts +223 -0
  38. package/dist/modules/cache/cache-manager.module.d.ts +92 -0
  39. package/dist/modules/contract/contract-manager.module.d.ts +136 -0
  40. package/dist/modules/diamond-hands-sdk.d.ts +669 -0
  41. package/dist/modules/loan/loan-creator.module.d.ts +143 -0
  42. package/dist/modules/loan/loan-query.module.d.ts +206 -0
  43. package/dist/modules/mock/mock-token-manager.module.d.ts +83 -0
  44. package/dist/modules/pkp/pkp-manager.module.d.ts +136 -0
  45. package/dist/protocol/protocol-pause.d.ts +19 -0
  46. package/dist/server.d.ts +17 -0
  47. package/dist/server.js +285 -0
  48. package/dist/server.mjs +242 -0
  49. package/dist/types/authorization-params.d.ts +160 -0
  50. package/dist/types/branded/domain-values.d.ts +138 -0
  51. package/dist/types/branded/ids.d.ts +23 -0
  52. package/dist/types/event-types.d.ts +235 -0
  53. package/dist/types/graph-dtos.d.ts +228 -0
  54. package/dist/types/loanStatus.d.ts +10 -0
  55. package/dist/types/result.d.ts +120 -0
  56. package/dist/utils/bitcoin-address-cache.utils.d.ts +87 -0
  57. package/dist/utils/bitcoin-provider.utils.d.ts +48 -0
  58. package/dist/utils/bitcoin-signature.d.ts +20 -0
  59. package/dist/utils/chunks/bitcoin-utils.d.ts +75 -0
  60. package/dist/utils/chunks/eip1559-broadcast.utils.d.ts +24 -0
  61. package/dist/utils/error-handler.d.ts +106 -0
  62. package/dist/utils/ethers-interop.utils.d.ts +146 -0
  63. package/dist/utils/extend-authorization.utils.d.ts +61 -0
  64. package/dist/utils/lit-signature.utils.d.ts +6 -0
  65. package/dist/utils/logger.utils.d.ts +142 -0
  66. package/dist/utils/mint-authorization.utils.d.ts +224 -0
  67. package/dist/utils/quantum-timing.d.ts +75 -0
  68. package/dist/utils/signature-tempering.utils.d.ts +31 -0
  69. package/dist/utils/telegram-messaging.utils.d.ts +188 -0
  70. package/package.json +43 -22
  71. package/dist/index.d.mts +0 -7392
@@ -0,0 +1,143 @@
1
+ /**
2
+ * Loan Creator Module
3
+ *
4
+ * Responsible for:
5
+ * - Orchestrating the multi-step loan creation flow
6
+ * - Creating PKP for custody
7
+ * - Authorizing loan creation
8
+ * - Submitting loan creation transaction
9
+ * - Building comprehensive audit trail
10
+ *
11
+ * Flow: PKP Creation → Authorization → Contract Call → Verification
12
+ */
13
+ import type { Wallet } from "ethers";
14
+ import { Result } from "../../types/result";
15
+ import { SDKError } from "../../utils/error-handler";
16
+ import type { PKPManager } from "../pkp/pkp-manager.module";
17
+ import type { ContractManager } from "../contract/contract-manager.module";
18
+ import type { BitcoinOperations } from "../bitcoin/bitcoin-operations.module";
19
+ import type { CreateLoanRequest, CreateLoanResult } from "../../interfaces/chunks/loan-operations.i";
20
+ import type { LitOps } from "@gvnrdao/dh-lit-ops";
21
+ /**
22
+ * Loan Creator configuration
23
+ */
24
+ export interface LoanCreatorConfig {
25
+ /** LitOps instance for PKP operations */
26
+ litOps: LitOps;
27
+ /** PKP Manager for PKP operations */
28
+ pkpManager: PKPManager;
29
+ /** Contract Manager for contract interactions */
30
+ contractManager: ContractManager;
31
+ /** Bitcoin Operations for address derivation */
32
+ bitcoinOperations: BitcoinOperations;
33
+ /** Wallet for contract transactions (Ethereum mainnet/Sepolia) */
34
+ wallet: Wallet;
35
+ /** Wallet for LIT Protocol operations (Yellowstone signer, capacity credits owner) - standalone mode only */
36
+ litOpsSigner?: Wallet;
37
+ /** SDK mode: 'service' or 'standalone' */
38
+ mode?: "service" | "standalone";
39
+ /** LIT Action CID for loan creation */
40
+ litActionCid: string;
41
+ /** User ID (typically wallet address) */
42
+ userId: string;
43
+ /** Lit Protocol network (e.g. 'chipotle') */
44
+ litNetwork?: string;
45
+ /** Enable debug logging */
46
+ debug?: boolean;
47
+ /** Transaction timeout (ms) */
48
+ transactionTimeoutMs?: number;
49
+ /** Validator version for loan creation (createPosition) - REQUIRED */
50
+ loanCreationValidatorVersion: number;
51
+ /** EVM JSON-RPC URL for service-mode PKP flow (forwards to lit-ops-server) */
52
+ ethRpcUrl?: string;
53
+ /** Security testing: Temper signatures to test contract validation */
54
+ temperSignaturesTest?: boolean;
55
+ /**
56
+ * Optional: Custom PKP creator.
57
+ * When provided, bypasses the default LitOps PKP flow and creates the PKP using
58
+ * this function.
59
+ */
60
+ nagaLoanPkpCreator?: () => Promise<{
61
+ tokenId: string;
62
+ publicKey: string;
63
+ ethAddress: string;
64
+ validatorSignature: string;
65
+ }>;
66
+ }
67
+ /**
68
+ * Loan creation audit trail
69
+ */
70
+ export interface LoanCreationAudit {
71
+ /** PKP creation details */
72
+ pkpCreation: {
73
+ tokenId: string;
74
+ publicKey: string;
75
+ ethAddress: string;
76
+ timestamp: number;
77
+ };
78
+ /** Bitcoin addresses derived */
79
+ bitcoinAddresses: {
80
+ mainnet: string;
81
+ testnet: string;
82
+ regtest: string;
83
+ };
84
+ /** Authorization details */
85
+ authorization: {
86
+ signature: string;
87
+ timestamp: number;
88
+ };
89
+ /** Contract call details */
90
+ contractCall: {
91
+ transactionHash: string;
92
+ blockNumber: number;
93
+ gasUsed: string;
94
+ timestamp: number;
95
+ };
96
+ }
97
+ /**
98
+ * Loan Creator Module
99
+ *
100
+ * Orchestrates the complete loan creation flow with comprehensive error handling
101
+ */
102
+ export declare class LoanCreator {
103
+ private readonly config;
104
+ private readonly transactionTimeoutMs;
105
+ private pkpValidationRegistryAddressCache;
106
+ constructor(config: LoanCreatorConfig);
107
+ /**
108
+ * Create a new loan
109
+ *
110
+ * Complete flow:
111
+ * 1. Create PKP for Bitcoin custody
112
+ * 2. Derive Bitcoin addresses
113
+ * 3. Build authorization signature
114
+ * 4. Authorize loan creation (LIT Action)
115
+ * 5. Submit loan creation transaction
116
+ * 6. Wait for confirmation
117
+ * 7. Build audit trail
118
+ *
119
+ * @param request - Loan creation request
120
+ * @returns Loan creation result with audit trail
121
+ */
122
+ createLoan(request: CreateLoanRequest): Promise<Result<CreateLoanResult, SDKError>>;
123
+ /**
124
+ * Step 2: Derive Bitcoin addresses from PKP public key
125
+ */
126
+ private deriveBitcoinAddresses;
127
+ /**
128
+ * Step 3: Submit loan creation transaction
129
+ */
130
+ private submitLoanCreation;
131
+ /**
132
+ * Extract position ID from transaction receipt
133
+ */
134
+ private extractPositionId;
135
+ /**
136
+ * Get vault address for current network
137
+ */
138
+ private getVaultAddressForNetwork;
139
+ }
140
+ /**
141
+ * Factory function to create a LoanCreator instance
142
+ */
143
+ export declare function createLoanCreator(config: LoanCreatorConfig): Result<LoanCreator, SDKError>;
@@ -0,0 +1,206 @@
1
+ /**
2
+ * Loan Query Module
3
+ *
4
+ * Responsible for:
5
+ * - Querying loan data from subgraph
6
+ * - Enriching loans with Bitcoin balance data
7
+ * - Caching query results for performance
8
+ * - Supporting pagination for large result sets
9
+ *
10
+ * Uses the existing DiamondHandsGraphClient for subgraph queries
11
+ */
12
+ import { Result } from "../../types/result";
13
+ import { SDKError } from "../../utils/error-handler";
14
+ import type { BitcoinOperations } from "../bitcoin/bitcoin-operations.module";
15
+ import type { Cache } from "../cache/cache-manager.module";
16
+ import type { LoanData, LoanDataDetail, PaginatedLoansResponse } from "../../interfaces/chunks/loan-operations.i";
17
+ import type { LoanEvents, LoanEventsFilter } from "../../types/event-types";
18
+ import { DiamondHandsGraphClient } from "@graphs/diamond-hands";
19
+ import type { providers } from "ethers";
20
+ /**
21
+ * Loan query filters
22
+ */
23
+ export interface LoanQueryFilters {
24
+ /** Filter by borrower address */
25
+ borrower?: string;
26
+ /** Filter by status */
27
+ status?: number;
28
+ /** Filter by minimum collateral ratio (BPS) */
29
+ minCollateralRatio?: number;
30
+ /** Filter by maximum collateral ratio (BPS) */
31
+ maxCollateralRatio?: number;
32
+ /** Order by field */
33
+ orderBy?: "createdAt" | "lastUpdatedAt" | "ucdDebt";
34
+ /** Order direction */
35
+ orderDirection?: "asc" | "desc";
36
+ }
37
+ /**
38
+ * Pagination parameters
39
+ */
40
+ export interface PaginationParams {
41
+ /** Page number (0-indexed) */
42
+ page: number;
43
+ /** Number of items per page */
44
+ pageSize: number;
45
+ }
46
+ /**
47
+ * Loan Query configuration
48
+ */
49
+ export interface LoanQueryConfig {
50
+ /** Subgraph client for queries */
51
+ graphClient: DiamondHandsGraphClient;
52
+ /** Bitcoin operations for balance enrichment */
53
+ bitcoinOperations: BitcoinOperations;
54
+ /** Ethereum provider for PKP public key retrieval */
55
+ provider?: providers.Provider;
56
+ /** Cache for loan query results (keyed by PKP ID) */
57
+ cache?: Cache<LoanData>;
58
+ /** Enable debug logging */
59
+ debug?: boolean;
60
+ /** Default page size for pagination */
61
+ defaultPageSize?: number;
62
+ }
63
+ /**
64
+ * Loan Query Module
65
+ *
66
+ * Handles all loan data queries with caching and balance enrichment
67
+ */
68
+ export declare class LoanQuery {
69
+ private readonly config;
70
+ private readonly defaultPageSize;
71
+ constructor(config: LoanQueryConfig);
72
+ /**
73
+ * Get loan by position ID
74
+ *
75
+ * @param positionId - Position ID
76
+ * @param enrichBalance - Whether to enrich with Bitcoin balance
77
+ * @returns Detailed loan data
78
+ */
79
+ getLoanById(positionId: string, enrichBalance?: boolean): Promise<Result<LoanDataDetail | null, SDKError>>;
80
+ /**
81
+ * Get loan by PKP ID
82
+ *
83
+ * @param pkpId - PKP token ID
84
+ * @param enrichBalance - Whether to enrich with Bitcoin balance
85
+ * @returns Loan data
86
+ */
87
+ getLoanByPkpId(pkpId: string, enrichBalance?: boolean): Promise<Result<LoanData | null, SDKError>>;
88
+ /**
89
+ * Get loans with filters and pagination
90
+ *
91
+ * @param filters - Query filters
92
+ * @param pagination - Pagination parameters
93
+ * @returns Paginated loans response
94
+ */
95
+ getLoans(filters?: LoanQueryFilters, pagination?: PaginationParams): Promise<Result<PaginatedLoansResponse, SDKError>>;
96
+ /**
97
+ * Get loans with BTC balance data from Bitcoin network
98
+ *
99
+ * Same as getLoans but includes actual Bitcoin balance for each position's vault.
100
+ * Queries BTC balances in parallel for performance.
101
+ *
102
+ * @param filters - Query filters
103
+ * @param pagination - Pagination parameters
104
+ * @returns Paginated loans response with BTC balance data
105
+ */
106
+ getLoansWithBtc(filters?: LoanQueryFilters, pagination?: PaginationParams): Promise<Result<PaginatedLoansResponse, SDKError>>;
107
+ /**
108
+ * Enrich loans with vault addresses derived from PKP public keys
109
+ *
110
+ * @param loans - Array of loans to enrich
111
+ * @returns Enriched loans with vault addresses for all networks
112
+ */
113
+ private enrichLoansWithVaultAddresses;
114
+ /**
115
+ * Map numeric status to string for subgraph queries
116
+ */
117
+ private mapStatusToString;
118
+ /**
119
+ * Map string status to numeric for filtering
120
+ */
121
+ private mapStringToStatus;
122
+ /**
123
+ * Validate if a string is a valid loan status
124
+ */
125
+ private isValidStatus;
126
+ /**
127
+ * Get loans for a borrower
128
+ *
129
+ * @param borrower - Borrower address
130
+ * @param pagination - Pagination parameters
131
+ * @returns Paginated loans for borrower
132
+ */
133
+ getLoansByBorrower(borrower: string, pagination?: PaginationParams): Promise<Result<PaginatedLoansResponse, SDKError>>;
134
+ /**
135
+ * Get active loans (status = 0)
136
+ *
137
+ * @param pagination - Pagination parameters
138
+ * @returns Paginated active loans
139
+ */
140
+ getActiveLoans(pagination?: PaginationParams): Promise<Result<PaginatedLoansResponse, SDKError>>;
141
+ /**
142
+ * Get loans by state/status
143
+ *
144
+ * @param state - Loan state (PENDING_DEPOSIT, ACTIVE, EXPIRED, REPAID, LIQUIDATED, EXTENDED, CLOSED)
145
+ * @param pagination - Pagination parameters
146
+ * @returns Paginated loans matching the specified state
147
+ */
148
+ getLoansByState(state: string, pagination?: PaginationParams): Promise<Result<PaginatedLoansResponse, SDKError>>;
149
+ /**
150
+ * Enrich a loan with current Bitcoin balance
151
+ *
152
+ * Note: btcAmount field removed - balance is now queried on-chain via lit-actions with signature validation
153
+ * This method is kept for potential future use but no longer sets btcAmount
154
+ */
155
+ private enrichLoanWithBalance;
156
+ /**
157
+ * Get all events for a loan position
158
+ *
159
+ * Retrieves complete event history including:
160
+ * - Payments (full repayments, partial payments, extension fees)
161
+ * - Status updates with reasons
162
+ * - Liquidation event (if liquidated)
163
+ * - UCD mint events
164
+ * - Community fee distributions
165
+ *
166
+ * @param positionId - Position ID to query events for
167
+ * @param filter - Optional filters (date range, event types, etc.)
168
+ * @returns Complete event history for the position
169
+ *
170
+ * @example
171
+ * ```typescript
172
+ * // Get all events
173
+ * const result = await loanQuery.getLoanEvents('0x123...');
174
+ *
175
+ * // Get only payment events
176
+ * const paymentsOnly = await loanQuery.getLoanEvents('0x123...', {
177
+ * eventTypes: ['payment']
178
+ * });
179
+ *
180
+ * // Get events in date range
181
+ * const recent = await loanQuery.getLoanEvents('0x123...', {
182
+ * fromTimestamp: '1640000000',
183
+ * toTimestamp: '1650000000'
184
+ * });
185
+ * ```
186
+ */
187
+ getLoanEvents(positionId: string, filter?: LoanEventsFilter): Promise<Result<LoanEvents, SDKError>>;
188
+ /**
189
+ * Clear loan cache
190
+ *
191
+ * @param pkpId - PKP ID to clear, or undefined to clear all
192
+ */
193
+ clearCache(pkpId?: string): void;
194
+ /**
195
+ * Get cache statistics
196
+ */
197
+ getCacheStats(): {
198
+ size: number;
199
+ maxSize: number;
200
+ ttlMs: number;
201
+ } | null;
202
+ }
203
+ /**
204
+ * Factory function to create a LoanQuery instance
205
+ */
206
+ export declare function createLoanQuery(config: LoanQueryConfig): Result<LoanQuery, SDKError>;
@@ -0,0 +1,83 @@
1
+ /**
2
+ * Mock Token Manager Module
3
+ *
4
+ * Responsible for:
5
+ * - Managing mock Bitcoin tokens for testing
6
+ * - Minting mock BTC tokens
7
+ * - Approving mock BTC spending
8
+ * - Querying mock BTC balances
9
+ *
10
+ * This module is for testing only and should not be used in production
11
+ */
12
+ import { Result } from '../../types/result';
13
+ import { Satoshis } from '../../types/branded/domain-values';
14
+ import { SDKError } from '../../utils/error-handler';
15
+ import type { ContractManager } from '../contract/contract-manager.module';
16
+ /**
17
+ * Mock Token Manager configuration
18
+ */
19
+ export interface MockTokenManagerConfig {
20
+ /** Contract manager for accessing mock token contracts */
21
+ contractManager: ContractManager;
22
+ /** Network identifier */
23
+ network: string;
24
+ /** Enable debug logging */
25
+ debug?: boolean;
26
+ /** Transaction timeout (ms) */
27
+ transactionTimeoutMs?: number;
28
+ }
29
+ /**
30
+ * Mock token transaction result
31
+ */
32
+ export interface MockTokenTransactionResult {
33
+ /** Transaction hash */
34
+ transactionHash: string;
35
+ /** Block number */
36
+ blockNumber: number;
37
+ /** Gas used */
38
+ gasUsed: string;
39
+ /** Transaction was successful */
40
+ success: boolean;
41
+ }
42
+ /**
43
+ * Mock Token Manager Module
44
+ *
45
+ * Provides utilities for working with mock Bitcoin tokens in test environments
46
+ *
47
+ * ⚠️ WARNING: This module is for testing only. Do not use in production.
48
+ */
49
+ export declare class MockTokenManager {
50
+ private readonly config;
51
+ constructor(config: MockTokenManagerConfig);
52
+ /**
53
+ * Mint mock BTC tokens
54
+ *
55
+ * @param amount - Amount to mint in satoshis
56
+ * @param recipient - Recipient address
57
+ * @returns Transaction result
58
+ */
59
+ mintMockBTC(amount: Satoshis, recipient: string): Promise<Result<MockTokenTransactionResult, SDKError>>;
60
+ /**
61
+ * Approve mock BTC spending
62
+ *
63
+ * @param spender - Spender address
64
+ * @param amount - Amount to approve in satoshis
65
+ * @returns Transaction result
66
+ */
67
+ approveMockBTC(spender: string, amount: Satoshis): Promise<Result<MockTokenTransactionResult, SDKError>>;
68
+ /**
69
+ * Get mock BTC balance
70
+ *
71
+ * @param address - Address to query
72
+ * @returns Balance in satoshis
73
+ */
74
+ getMockBTCBalance(address: string): Promise<Result<Satoshis, SDKError>>;
75
+ /**
76
+ * Check if current network is production (mainnet)
77
+ */
78
+ private isProductionNetwork;
79
+ }
80
+ /**
81
+ * Factory function to create a MockTokenManager instance
82
+ */
83
+ export declare function createMockTokenManager(config: MockTokenManagerConfig): Result<MockTokenManager, SDKError>;
@@ -0,0 +1,136 @@
1
+ /**
2
+ * PKP Manager Module
3
+ *
4
+ * Responsible for:
5
+ * - Creating new PKPs (via service or direct)
6
+ * - Querying PKP data from contracts
7
+ * - Managing PKP lifecycle
8
+ * - Caching PKP data for performance
9
+ *
10
+ * Supports two modes:
11
+ * - Service mode: Uses lit-ops-server for PKP operations
12
+ * - Direct mode: Directly interacts with LIT Protocol
13
+ */
14
+ import type { Wallet } from "ethers";
15
+ import { Result } from "../../types/result";
16
+ import { SDKError } from "../../utils/error-handler";
17
+ import type { Cache } from "../cache/cache-manager.module";
18
+ import type { PKPData, PKPCreationRequest, PKPCreationResult, PKPValidationResult } from "../../interfaces/chunks/pkp-integration.i";
19
+ import type { SDKMode } from "../../interfaces/chunks/config.i";
20
+ /**
21
+ * PKP Manager configuration
22
+ */
23
+ export interface PKPManagerConfig {
24
+ /** Operation mode: service (via lit-ops-server) or direct (LIT Protocol) */
25
+ mode: SDKMode;
26
+ /** LIT network (naga, naga-test, naga-dev, etc.) */
27
+ litNetwork: string;
28
+ /** Service mode: endpoint for lit-ops-server */
29
+ serviceEndpoint?: string;
30
+ /** Service mode: authentication token */
31
+ serviceAuthToken?: string;
32
+ /** Direct mode: wallet for PKP operations */
33
+ litOpsWallet?: Wallet;
34
+ /** Optional cache for PKP data */
35
+ cache?: Cache<PKPData>;
36
+ /** Enable debug logging */
37
+ debug?: boolean;
38
+ /** Timeout for service requests (ms) */
39
+ serviceTimeoutMs?: number;
40
+ /** Max retries for failed operations */
41
+ maxRetries?: number;
42
+ }
43
+ /**
44
+ * PKP Manager Module
45
+ *
46
+ * Manages PKP creation, querying, and lifecycle with support for
47
+ * both service mode and direct mode operations.
48
+ */
49
+ export declare class PKPManager {
50
+ private readonly config;
51
+ private readonly serviceTimeoutMs;
52
+ constructor(config: PKPManagerConfig);
53
+ /**
54
+ * Validate PKPManager configuration
55
+ */
56
+ private validateConfig;
57
+ /**
58
+ * Create a new PKP
59
+ *
60
+ * Routes to service mode or direct mode based on configuration.
61
+ *
62
+ * @param request - PKP creation request
63
+ * @returns PKP creation result
64
+ */
65
+ createPKP(request: PKPCreationRequest): Promise<Result<PKPCreationResult, SDKError>>;
66
+ /**
67
+ * Create PKP via lit-ops-server (service mode)
68
+ */
69
+ private createPKPViaService;
70
+ /**
71
+ * Create PKP directly via LIT Protocol (standalone mode)
72
+ *
73
+ * Note: This is a placeholder implementation. In production, this would
74
+ * use the LIT SDK directly to mint a PKP.
75
+ */
76
+ private createPKPDirect;
77
+ /**
78
+ * Get PKP data by token ID
79
+ *
80
+ * Checks cache first, then queries from service/contract if needed.
81
+ *
82
+ * @param tokenId - PKP token ID
83
+ * @returns PKP data or null if not found
84
+ */
85
+ getPKPData(tokenId: string): Promise<Result<PKPData | null, SDKError>>;
86
+ /**
87
+ * Get PKP data from service
88
+ */
89
+ private getPKPDataFromService;
90
+ /**
91
+ * Get PKP data from contract (direct mode)
92
+ *
93
+ * Note: This is a placeholder. In production, would query PKP registry contract.
94
+ */
95
+ private getPKPDataFromContract;
96
+ /**
97
+ * Get PKP public key from token ID
98
+ *
99
+ * Convenience method that extracts just the public key.
100
+ *
101
+ * @param tokenId - PKP token ID
102
+ * @returns PKP public key
103
+ */
104
+ getPKPPublicKey(tokenId: string): Promise<Result<string, SDKError>>;
105
+ /**
106
+ * Validate that a PKP exists and is active
107
+ *
108
+ * @param tokenId - PKP token ID
109
+ * @returns Validation result
110
+ */
111
+ validatePKP(tokenId: string): Promise<Result<PKPValidationResult, SDKError>>;
112
+ /**
113
+ * Clear PKP from cache
114
+ *
115
+ * Useful when PKP data may have changed.
116
+ *
117
+ * @param tokenId - PKP token ID
118
+ */
119
+ clearCache(tokenId: string): void;
120
+ /**
121
+ * Clear all cached PKP data
122
+ */
123
+ clearAllCache(): void;
124
+ /**
125
+ * Get cache statistics
126
+ */
127
+ getCacheStats(): {
128
+ size: number;
129
+ maxSize: number;
130
+ ttlMs: number;
131
+ } | null;
132
+ }
133
+ /**
134
+ * Factory function to create a PKPManager instance
135
+ */
136
+ export declare function createPKPManager(config: PKPManagerConfig): Result<PKPManager, SDKError>;
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Helpers for `PositionManager.getProtocolPauseStatus()` (Lit Actions / client fast-fail).
3
+ */
4
+ import { ethers } from 'ethers';
5
+ export type ProtocolPauseStatus = {
6
+ positionManagerPaused: boolean;
7
+ positionManagerLiquidationsPaused: boolean;
8
+ positionManagerCorePaused: boolean;
9
+ loanOperationsPaused: boolean;
10
+ collateralManagerPaused: boolean;
11
+ liquidationManagerPaused: boolean;
12
+ circuitBreakerPaused: boolean;
13
+ ucdControllerPaused: boolean;
14
+ ucdTokenPaused: boolean;
15
+ simplePsmPaused: boolean;
16
+ };
17
+ export declare function fetchProtocolPauseStatus(provider: ethers.providers.Provider, positionManagerAddress: string): Promise<ProtocolPauseStatus>;
18
+ export type ProtocolPauseKey = keyof ProtocolPauseStatus;
19
+ export declare function assertProtocolNotPaused(status: ProtocolPauseStatus, requiredKeys: readonly ProtocolPauseKey[]): void;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Node-only entry for the Diamond Hands SDK (PKP mint / server env).
3
+ *
4
+ * Use this subpath when you need {@link loadSDKConfig} with `.env` discovery
5
+ * (`environment.ts`) and optional `PKP_MINT_PRIVATE_KEY` for mint-wallet flows.
6
+ *
7
+ * The main package export (`@gvnrdao/dh-sdk`) re-exports browser-safe config from
8
+ * `environment.browser` — suitable for read-only and user-wallet flows in any runtime.
9
+ * Do **not** put `PKP_MINT_PRIVATE_KEY` in client bundles; import from here only in Node
10
+ * scripts, lit-ops-server, CI, or other trusted server contexts.
11
+ *
12
+ * @see {@link https://github.com/gvnrdao/diamond-hands/blob/main/docs/security/SECRETS-POLICY.md | SECRETS-POLICY.md}
13
+ * @module @gvnrdao/dh-sdk/server
14
+ */
15
+ export { loadSDKConfig, validateSDKEnvironment, getCurrentEnvironment, resolveLitNetworkFromEnv, envLog, } from "./constants/chunks/environment";
16
+ export { loadEncryptedProviderRegistry, getEncryptedPriceProviders, } from "./constants/chunks/encrypted-provider-params";
17
+ export type { SDKConfig, EnvironmentName } from "./constants/chunks/environment";