@gvnrdao/dh-sdk 0.0.286 → 0.0.288
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 -1
- package/browser/dist/browser.js +1 -1
- package/browser/dist/browser.js.LICENSE.txt +10 -5
- package/dist/deployments.js +45 -21
- package/dist/deployments.mjs +45 -21
- package/dist/index.js +620 -1103
- package/dist/index.mjs +620 -1103
- package/package.json +1 -1
- package/dist/constants/chunks/contract-abis.d.ts +0 -20
- package/dist/constants/chunks/deployment-addresses.d.ts +0 -79
- package/dist/constants/chunks/encrypted-provider-params.d.ts +0 -21
- package/dist/constants/chunks/environment.browser.d.ts +0 -44
- package/dist/constants/chunks/environment.d.ts +0 -57
- package/dist/constants/chunks/network-configs.d.ts +0 -72
- package/dist/constants/chunks/sdk-config.d.ts +0 -33
- package/dist/constants/chunks/sdk-limits.d.ts +0 -66
- package/dist/constants/index.d.ts +0 -15
- package/dist/contracts/typechain-contracts/common.d.ts +0 -50
- package/dist/contracts/typechain-contracts/factories/src/psm/SimplePSMV2__factory.d.ts +0 -1996
- package/dist/contracts/typechain-contracts/src/psm/SimplePSMV2.d.ts +0 -1198
- package/dist/graphs/client.d.ts +0 -22
- package/dist/graphs/diamond-hands.d.ts +0 -259
- package/dist/index.d.ts +0 -56
- package/dist/interfaces/chunks/btc.i.d.ts +0 -36
- package/dist/interfaces/chunks/config.i.d.ts +0 -270
- package/dist/interfaces/chunks/contract-interactions.i.d.ts +0 -64
- package/dist/interfaces/chunks/contract-types.i.d.ts +0 -171
- package/dist/interfaces/chunks/lit-actions-results.i.d.ts +0 -165
- package/dist/interfaces/chunks/lit-actions.i.d.ts +0 -98
- package/dist/interfaces/chunks/loan-operations.i.d.ts +0 -331
- package/dist/interfaces/chunks/pkp-integration.i.d.ts +0 -87
- package/dist/interfaces/chunks/position-query.i.d.ts +0 -76
- package/dist/interfaces/chunks/requests.i.d.ts +0 -55
- package/dist/interfaces/chunks/ucd-minting.i.d.ts +0 -34
- package/dist/interfaces/chunks/utility.i.d.ts +0 -64
- package/dist/interfaces/index.d.ts +0 -17
- package/dist/modules/bitcoin/bitcoin-operations.module.d.ts +0 -254
- package/dist/modules/cache/cache-manager.module.d.ts +0 -259
- package/dist/modules/contract/contract-manager.module.d.ts +0 -152
- package/dist/modules/diamond-hands-sdk.d.ts +0 -969
- package/dist/modules/loan/loan-creator.module.d.ts +0 -132
- package/dist/modules/loan/loan-query.module.d.ts +0 -204
- package/dist/modules/mock/mock-token-manager.module.d.ts +0 -83
- package/dist/modules/pkp/pkp-manager.module.d.ts +0 -136
- package/dist/modules/withdrawal-address/withdrawal-address.module.d.ts +0 -78
- package/dist/protocol/protocol-pause.d.ts +0 -19
- package/dist/server.d.ts +0 -17
- package/dist/types/authorization-params.d.ts +0 -160
- package/dist/types/branded/domain-values.d.ts +0 -138
- package/dist/types/branded/ids.d.ts +0 -23
- package/dist/types/event-types.d.ts +0 -261
- package/dist/types/graph-dtos.d.ts +0 -228
- package/dist/types/loanStatus.d.ts +0 -10
- package/dist/types/protocol-event-types.d.ts +0 -99
- package/dist/types/result.d.ts +0 -120
- package/dist/utils/address-conversion.utils.d.ts +0 -51
- package/dist/utils/bitcoin-address-cache.utils.d.ts +0 -87
- package/dist/utils/bitcoin-provider.utils.d.ts +0 -84
- package/dist/utils/btc-withdrawal-message.d.ts +0 -60
- package/dist/utils/chunks/bitcoin-utils.d.ts +0 -85
- package/dist/utils/chunks/eip1559-broadcast.utils.d.ts +0 -33
- package/dist/utils/eip712-login.d.ts +0 -34
- package/dist/utils/error-handler.d.ts +0 -106
- package/dist/utils/ethers-interop.utils.d.ts +0 -146
- package/dist/utils/extend-authorization.utils.d.ts +0 -61
- package/dist/utils/lit-signature.utils.d.ts +0 -6
- package/dist/utils/logger.utils.d.ts +0 -142
- package/dist/utils/mint-authorization.utils.d.ts +0 -248
- package/dist/utils/position-delegate.utils.d.ts +0 -41
- package/dist/utils/quantum-timing.d.ts +0 -75
- package/dist/utils/server-session.d.ts +0 -50
- package/dist/utils/service-endpoint-policy.d.ts +0 -16
- package/dist/utils/signature-tempering.utils.d.ts +0 -34
- package/dist/utils/telegram-messaging.utils.d.ts +0 -188
package/dist/graphs/client.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export interface GraphClientConfig {
|
|
2
|
-
endpoint: string;
|
|
3
|
-
requestTimeoutMs?: number;
|
|
4
|
-
maxRetries?: number;
|
|
5
|
-
headers?: Record<string, string>;
|
|
6
|
-
/** Optional async supplier for per-request headers (e.g. session JWT). */
|
|
7
|
-
getHeaders?: () => Promise<Record<string, string>>;
|
|
8
|
-
}
|
|
9
|
-
export declare class GraphClient {
|
|
10
|
-
private endpoint;
|
|
11
|
-
private requestTimeoutMs;
|
|
12
|
-
private maxRetries;
|
|
13
|
-
private headers?;
|
|
14
|
-
private getHeadersFn?;
|
|
15
|
-
constructor(config: GraphClientConfig);
|
|
16
|
-
execute<T>(query: string, variables?: Record<string, any>): Promise<T>;
|
|
17
|
-
paginate<TItem>(query: string, variables: Record<string, any>, select: (page: any) => TItem[], options?: {
|
|
18
|
-
pageSize?: number;
|
|
19
|
-
maxPages?: number;
|
|
20
|
-
}): Promise<TItem[]>;
|
|
21
|
-
private backoff;
|
|
22
|
-
}
|
|
@@ -1,259 +0,0 @@
|
|
|
1
|
-
import type { ProtocolEventsFilter, ProtocolEventsResult } from "../types/protocol-event-types";
|
|
2
|
-
import type { LoanData } from "../interfaces";
|
|
3
|
-
import type { GraphPositionWithBorrowerDTO } from "../types/graph-dtos";
|
|
4
|
-
import type { LoanEvents, LoanEventsFilter } from "../types/event-types";
|
|
5
|
-
import type { BitcoinOperations, EnrichedBitcoinBalance } from "../modules/bitcoin/bitcoin-operations.module";
|
|
6
|
-
export interface DiamondHandsGraphConfig {
|
|
7
|
-
endpoint: string;
|
|
8
|
-
requestTimeoutMs?: number;
|
|
9
|
-
maxRetries?: number;
|
|
10
|
-
defaultPageSize?: number;
|
|
11
|
-
headers?: Record<string, string>;
|
|
12
|
-
/** Optional async supplier for per-request headers (e.g. session JWT). */
|
|
13
|
-
getHeaders?: () => Promise<Record<string, string>>;
|
|
14
|
-
}
|
|
15
|
-
export interface UserData {
|
|
16
|
-
id: string;
|
|
17
|
-
positions: LoanData[];
|
|
18
|
-
totalBorrowed: string;
|
|
19
|
-
totalRepaid: string;
|
|
20
|
-
activePositions: string;
|
|
21
|
-
firstInteractionTimestamp: string;
|
|
22
|
-
lastInteractionTimestamp: string;
|
|
23
|
-
}
|
|
24
|
-
export interface LoanTermData {
|
|
25
|
-
id: string;
|
|
26
|
-
months: string;
|
|
27
|
-
mintFeeBps?: string;
|
|
28
|
-
extensionFeeBps?: string;
|
|
29
|
-
isValid?: boolean;
|
|
30
|
-
createdAt?: string;
|
|
31
|
-
createdAtBlock?: string;
|
|
32
|
-
}
|
|
33
|
-
export interface PSMConfigurationData {
|
|
34
|
-
id: string;
|
|
35
|
-
version: string;
|
|
36
|
-
redeemEnabled: boolean;
|
|
37
|
-
totalSwapVolume: string;
|
|
38
|
-
totalRedeemVolume: string;
|
|
39
|
-
supportedStablecoinsCount: string;
|
|
40
|
-
lastUpdated: string;
|
|
41
|
-
}
|
|
42
|
-
export interface SupportedStablecoinData {
|
|
43
|
-
id: string;
|
|
44
|
-
address: string;
|
|
45
|
-
isSupported: boolean;
|
|
46
|
-
exchangeRate: string;
|
|
47
|
-
entryFee: string;
|
|
48
|
-
exitFee: string;
|
|
49
|
-
reserves: string;
|
|
50
|
-
decimals: string;
|
|
51
|
-
totalSwapVolume: string;
|
|
52
|
-
totalRedeemVolume: string;
|
|
53
|
-
swapCount: string;
|
|
54
|
-
redeemCount: string;
|
|
55
|
-
addedAt: string;
|
|
56
|
-
lastUpdated: string;
|
|
57
|
-
}
|
|
58
|
-
export interface PSMTransactionData {
|
|
59
|
-
id: string;
|
|
60
|
-
type: string;
|
|
61
|
-
user: string;
|
|
62
|
-
stablecoin: SupportedStablecoinData;
|
|
63
|
-
stablecoinAmount: string;
|
|
64
|
-
ucdAmount: string;
|
|
65
|
-
fee: string;
|
|
66
|
-
effectiveRate: string;
|
|
67
|
-
timestamp: string;
|
|
68
|
-
blockNumber: string;
|
|
69
|
-
transactionHash: string;
|
|
70
|
-
}
|
|
71
|
-
export interface UserRateLimitData {
|
|
72
|
-
id: string;
|
|
73
|
-
user: string;
|
|
74
|
-
stablecoin: SupportedStablecoinData;
|
|
75
|
-
lastOperationBlock: string;
|
|
76
|
-
operationCount: string;
|
|
77
|
-
isCurrentlyLimited: boolean;
|
|
78
|
-
nextResetBlock: string;
|
|
79
|
-
lastUpdated: string;
|
|
80
|
-
}
|
|
81
|
-
export declare class DiamondHandsGraph {
|
|
82
|
-
private client;
|
|
83
|
-
private defaultPageSize;
|
|
84
|
-
private bitcoinOps?;
|
|
85
|
-
constructor(config: DiamondHandsGraphConfig, bitcoinOps?: BitcoinOperations);
|
|
86
|
-
/**
|
|
87
|
-
* Transform graph position data to LoanData interface
|
|
88
|
-
* Converts flat graph structure to nested LoanData structure
|
|
89
|
-
*/
|
|
90
|
-
private transformGraphPositionToLoanData;
|
|
91
|
-
/**
|
|
92
|
-
* Helper: Get total count by paginating through all results
|
|
93
|
-
* The Graph has a hard limit of 1000 items per query, so we need to paginate
|
|
94
|
-
*
|
|
95
|
-
* NOTE: This implementation fetches minimal data (just IDs) for counting.
|
|
96
|
-
* The Graph protocol does not currently support count-only aggregation queries,
|
|
97
|
-
* so this batching approach is optimal for total count determination.
|
|
98
|
-
* Future optimization: If The Graph adds support for aggregate functions
|
|
99
|
-
* (e.g., `positions_aggregate { count }`), this should be updated.
|
|
100
|
-
*
|
|
101
|
-
* @param entityName The GraphQL entity name (e.g., "positions", "users")
|
|
102
|
-
* @param whereClause Optional GraphQL where clause (e.g., "{ borrower: $borrower }")
|
|
103
|
-
* @param variables Optional variables for the where clause
|
|
104
|
-
* @returns Total count of items
|
|
105
|
-
*/
|
|
106
|
-
private getTotalCountPaginated;
|
|
107
|
-
/**
|
|
108
|
-
* Get user positions from subgraph
|
|
109
|
-
*/
|
|
110
|
-
getUserPositions(userAddress: string, first?: number, skip?: number, orderBy?: string, orderDirection?: string): Promise<{
|
|
111
|
-
positions: LoanData[];
|
|
112
|
-
total: number;
|
|
113
|
-
}>;
|
|
114
|
-
/**
|
|
115
|
-
* Get user positions with enriched Bitcoin balance data
|
|
116
|
-
*
|
|
117
|
-
* Same as getUserPositions but queries actual BTC balance from Bitcoin network
|
|
118
|
-
* for each vault address in parallel.
|
|
119
|
-
*
|
|
120
|
-
* @param userAddress - User's Ethereum address
|
|
121
|
-
* @param first - Optional: max number of positions to return (default: 10)
|
|
122
|
-
* @param skip - Optional: number of positions to skip (default: 0)
|
|
123
|
-
* @param orderBy - Optional: field to order by (default: "createdAt")
|
|
124
|
-
* @param orderDirection - Optional: asc or desc (default: "desc" - most recent first)
|
|
125
|
-
* @returns Positions with actual BTC balances from Bitcoin network
|
|
126
|
-
*/
|
|
127
|
-
getUserPositionsWithBtc(userAddress: string, first?: number, skip?: number, orderBy?: string, orderDirection?: "asc" | "desc"): Promise<{
|
|
128
|
-
positions: (LoanData & {
|
|
129
|
-
btcBalance?: EnrichedBitcoinBalance;
|
|
130
|
-
})[];
|
|
131
|
-
total: number;
|
|
132
|
-
}>;
|
|
133
|
-
/**
|
|
134
|
-
* Get position by PKP ID from subgraph
|
|
135
|
-
*/
|
|
136
|
-
getPositionByPKP(pkpId: string): Promise<LoanData | null>;
|
|
137
|
-
/**
|
|
138
|
-
* Get detailed position data by PKP ID from subgraph
|
|
139
|
-
*/
|
|
140
|
-
getDetailedPositionByPkpId(pkpId: string): Promise<any | null>;
|
|
141
|
-
/**
|
|
142
|
-
* Get detailed position data by position ID from subgraph
|
|
143
|
-
*/
|
|
144
|
-
getDetailedPositionById(positionId: string): Promise<GraphPositionWithBorrowerDTO | null>;
|
|
145
|
-
/**
|
|
146
|
-
* Get all positions with pagination
|
|
147
|
-
*/
|
|
148
|
-
getAllPositions(options?: {
|
|
149
|
-
pageSize?: number;
|
|
150
|
-
maxPages?: number;
|
|
151
|
-
}): Promise<LoanData[]>;
|
|
152
|
-
/**
|
|
153
|
-
* Get all positions directly (simple query with pagination support)
|
|
154
|
-
*/
|
|
155
|
-
getPositions(first?: number, orderBy?: string, orderDirection?: "asc" | "desc", skip?: number, includeTotalCount?: boolean): Promise<{
|
|
156
|
-
positions: LoanData[];
|
|
157
|
-
total: number;
|
|
158
|
-
}>;
|
|
159
|
-
/**
|
|
160
|
-
* Get positions filtered by an array of statuses
|
|
161
|
-
*/
|
|
162
|
-
getPositionsByStatus(statuses: string[], first?: number, orderBy?: string, orderDirection?: "asc" | "desc", skip?: number): Promise<{
|
|
163
|
-
positions: LoanData[];
|
|
164
|
-
total: number;
|
|
165
|
-
}>;
|
|
166
|
-
/**
|
|
167
|
-
* Get active positions only
|
|
168
|
-
*/
|
|
169
|
-
getActivePositions(options?: {
|
|
170
|
-
pageSize?: number;
|
|
171
|
-
maxPages?: number;
|
|
172
|
-
}): Promise<LoanData[]>;
|
|
173
|
-
/**
|
|
174
|
-
* Get protocol statistics
|
|
175
|
-
*/
|
|
176
|
-
getProtocolStats(): Promise<{
|
|
177
|
-
totalValueLocked: string;
|
|
178
|
-
totalBorrowed: string;
|
|
179
|
-
totalRepaid: string;
|
|
180
|
-
totalLiquidated: string;
|
|
181
|
-
totalPositions: string;
|
|
182
|
-
activePositions: string;
|
|
183
|
-
totalUsers: string;
|
|
184
|
-
} | null>;
|
|
185
|
-
/**
|
|
186
|
-
* Health check for subgraph
|
|
187
|
-
*/
|
|
188
|
-
healthCheck(): Promise<{
|
|
189
|
-
isHealthy: boolean;
|
|
190
|
-
latestBlock?: string;
|
|
191
|
-
}>;
|
|
192
|
-
/**
|
|
193
|
-
* Get all configured loan terms (from subgraph)
|
|
194
|
-
* Note: If the subgraph does not seed default terms from the contract, this may return an empty array.
|
|
195
|
-
*/
|
|
196
|
-
getLoanTerms(options?: {
|
|
197
|
-
first?: number;
|
|
198
|
-
skip?: number;
|
|
199
|
-
}): Promise<LoanTermData[]>;
|
|
200
|
-
/**
|
|
201
|
-
* Get a single loan term by months (from subgraph)
|
|
202
|
-
* Typical id is the months as string, e.g., "12".
|
|
203
|
-
*/
|
|
204
|
-
getLoanTerm(months: number | string): Promise<LoanTermData | null>;
|
|
205
|
-
/**
|
|
206
|
-
* Get PSM configuration from subgraph
|
|
207
|
-
*/
|
|
208
|
-
getPSMConfiguration(): Promise<PSMConfigurationData | null>;
|
|
209
|
-
/**
|
|
210
|
-
* Get all supported stablecoins from subgraph
|
|
211
|
-
*/
|
|
212
|
-
getSupportedStablecoins(onlySupported?: boolean): Promise<SupportedStablecoinData[]>;
|
|
213
|
-
/**
|
|
214
|
-
* Get stablecoin details by address
|
|
215
|
-
*/
|
|
216
|
-
getStablecoinDetails(address: string): Promise<SupportedStablecoinData | null>;
|
|
217
|
-
/**
|
|
218
|
-
* Get user rate limit status for a specific stablecoin
|
|
219
|
-
*/
|
|
220
|
-
getUserRateLimit(userAddress: string, stablecoinAddress: string): Promise<UserRateLimitData | null>;
|
|
221
|
-
/**
|
|
222
|
-
* Get PSM transactions with filters
|
|
223
|
-
*/
|
|
224
|
-
getPSMTransactions(filters?: {
|
|
225
|
-
user?: string;
|
|
226
|
-
stablecoin?: string;
|
|
227
|
-
type?: "SWAP" | "REDEEM";
|
|
228
|
-
first?: number;
|
|
229
|
-
skip?: number;
|
|
230
|
-
}): Promise<PSMTransactionData[]>;
|
|
231
|
-
/**
|
|
232
|
-
* Get PSM analytics for a date range
|
|
233
|
-
*/
|
|
234
|
-
getPSMDailyMetrics(startDate?: string, endDate?: string, first?: number): Promise<any[]>;
|
|
235
|
-
/**
|
|
236
|
-
* Get all events for a specific loan position
|
|
237
|
-
*
|
|
238
|
-
* Returns a comprehensive event history including:
|
|
239
|
-
* - Payments (full repayments, partial payments, extension fees)
|
|
240
|
-
* - Status updates with reasons
|
|
241
|
-
* - Liquidation event (if liquidated)
|
|
242
|
-
* - UCD mint events
|
|
243
|
-
* - Community fee distributions
|
|
244
|
-
*
|
|
245
|
-
* @param positionId - The position ID to query events for
|
|
246
|
-
* @param filter - Optional filters to apply
|
|
247
|
-
* @returns Complete event history for the position
|
|
248
|
-
*/
|
|
249
|
-
getLoanEvents(positionId: string, filter?: LoanEventsFilter): Promise<LoanEvents>;
|
|
250
|
-
/**
|
|
251
|
-
* Retrieve events across the full protocol, optionally narrowed to a position.
|
|
252
|
-
* Returns a merged, sorted discriminated-union timeline suitable for explorers.
|
|
253
|
-
*
|
|
254
|
-
* Protocol-global admin events (circuit breaker, term fees, etc.) are included
|
|
255
|
-
* by default; pass `kinds` to restrict.
|
|
256
|
-
*/
|
|
257
|
-
getAllEvents(filter?: ProtocolEventsFilter): Promise<ProtocolEventsResult>;
|
|
258
|
-
}
|
|
259
|
-
export type DiamondHandsGraphClient = DiamondHandsGraph;
|
package/dist/index.d.ts
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Diamond Hands SDK Package
|
|
3
|
-
* Diamond Hands Protocol - SDK Operations
|
|
4
|
-
*
|
|
5
|
-
* Provides high-level interface for Diamond Hands Protocol operations supporting:
|
|
6
|
-
* - Loan creation with PKP integration
|
|
7
|
-
* - Smart contract interactions
|
|
8
|
-
* - LIT Protocol operations
|
|
9
|
-
* - Bitcoin custody and operations
|
|
10
|
-
*
|
|
11
|
-
* Version 2.0 - Complete rewrite with full type safety
|
|
12
|
-
*/
|
|
13
|
-
export { DiamondHandsSDK } from './modules/diamond-hands-sdk';
|
|
14
|
-
export { DiamondHandsSDK as default } from './modules/diamond-hands-sdk';
|
|
15
|
-
export type { UCD, Satoshis, Wei, BPS, UnixTimestamp, BlockNumber, } from './types/branded/domain-values';
|
|
16
|
-
export { UCDConversions, SatoshisConversions, WeiConversions, BPSConversions, } from './types/branded/domain-values';
|
|
17
|
-
export type { Result, Success, Failure, } from './types/result';
|
|
18
|
-
export { success, failure, isSuccess, isFailure, unwrap, unwrapOr, map, mapError, andThen, firstSuccess, collectSuccesses, collectFailures, combine, tryCatch, tryCatchAsync, toPromise, fromPromise, match, } from './types/result';
|
|
19
|
-
export type { AuthorizationParams, CreateLoanAuthParams, MintUCDAuthParams, WithdrawBTCAuthParams, RepayDebtAuthParams, ExtendTermAuthParams, ClosePositionAuthParams, } from './types/authorization-params';
|
|
20
|
-
export { isCreateLoanAuth, isMintUCDAuth, isWithdrawBTCAuth, isRepayDebtAuth, isExtendTermAuth, isClosePositionAuth, AuthParamsValidation, } from './types/authorization-params';
|
|
21
|
-
export { ContractManager, createContractManager, } from './modules/contract/contract-manager.module';
|
|
22
|
-
export type { ContractManagerConfig, ManagedContracts, } from './modules/contract/contract-manager.module';
|
|
23
|
-
export { LRUCache, CacheManager, createCacheManager, } from './modules/cache/cache-manager.module';
|
|
24
|
-
export type { CacheConfig, CacheStats, } from './modules/cache/cache-manager.module';
|
|
25
|
-
export { PKPManager, createPKPManager, } from './modules/pkp/pkp-manager.module';
|
|
26
|
-
export type { PKPManagerConfig, } from './modules/pkp/pkp-manager.module';
|
|
27
|
-
export { LoanCreator, createLoanCreator, } from './modules/loan/loan-creator.module';
|
|
28
|
-
export type { LoanCreatorConfig, LoanCreationAudit, } from './modules/loan/loan-creator.module';
|
|
29
|
-
export { LoanQuery, createLoanQuery, } from './modules/loan/loan-query.module';
|
|
30
|
-
export type { LoanQueryConfig, LoanQueryFilters, PaginationParams, } from './modules/loan/loan-query.module';
|
|
31
|
-
export { WithdrawalAddressModule, createWithdrawalAddressModule, } from './modules/withdrawal-address/withdrawal-address.module';
|
|
32
|
-
export type { WithdrawalAddressModuleConfig, WithdrawalAddressEntry, } from './modules/withdrawal-address/withdrawal-address.module';
|
|
33
|
-
export { BitcoinOperations, createBitcoinOperations, } from './modules/bitcoin/bitcoin-operations.module';
|
|
34
|
-
export type { BitcoinOperationsConfig, BitcoinNetwork, EnrichedBitcoinBalance, } from './modules/bitcoin/bitcoin-operations.module';
|
|
35
|
-
export { MockTokenManager, createMockTokenManager, } from './modules/mock/mock-token-manager.module';
|
|
36
|
-
export type { SupportedStablecoinData } from './graphs/diamond-hands';
|
|
37
|
-
export type { MockTokenManagerConfig, MockTokenTransactionResult, } from './modules/mock/mock-token-manager.module';
|
|
38
|
-
export { validateSDKConfig, validateServiceModeConfig, validateStandaloneModeConfig, isServiceModeConfig, isStandaloneModeConfig, } from './interfaces/chunks/config.i';
|
|
39
|
-
export { assertSafeServiceEndpoint } from './utils/service-endpoint-policy';
|
|
40
|
-
export { DEFAULT_LIT_NETWORK, VALID_LIT_NETWORKS, SDK_DEFAULTS, } from './constants/chunks/sdk-config';
|
|
41
|
-
export { ALL_CONTRACTS, ALL_DEPLOYMENTS, getContractsByNetwork, getDeploymentByNetwork, LOCALHOST_CONTRACTS, SEPOLIA_CONTRACTS, } from './constants/chunks/deployment-addresses';
|
|
42
|
-
export type { DeploymentContracts, DeploymentData, DeploymentLatestEnv, } from './constants/chunks/deployment-addresses';
|
|
43
|
-
export type { CreateLoanRequest, CreateLoanResult, LoanData, LoanDataDetail, PaginatedLoansResponse, PKPValidationData, BitcoinAddresses, } from './interfaces/chunks/loan-operations.i';
|
|
44
|
-
export type { DiamondHandsSDKConfig, SDKMode, ContractAddresses, BitcoinProviderConfig, } from './interfaces/chunks/config.i';
|
|
45
|
-
export type { PKPData, PKPCreationRequest, PKPCreationResult, PKPValidationResult, } from './interfaces/chunks/pkp-integration.i';
|
|
46
|
-
export type { AuthorizationRequest, AuthorizationResult, BTCDepositRequest, BTCDepositResult, } from './interfaces/chunks/requests.i';
|
|
47
|
-
export { LoanStatus } from './types/loanStatus';
|
|
48
|
-
export type { LoanEvents, LoanEventsFilter, PositionCreatedEvent, PaymentEvent, StatusUpdateEvent, LiquidationEvent, UCDMintEvent, WithdrawalEvent, RenewalEvent, OperationFailureEvent, MintRequestEvent, BurnRequestEvent, CollateralContractEvent, } from './types/event-types';
|
|
49
|
-
export { PaymentType, PositionStatus, isValidPositionStatus, isValidPaymentType, numericToPositionStatus, EventHelpers, } from './types/event-types';
|
|
50
|
-
export type { ProtocolEvent, ProtocolEventsFilter, ProtocolEventsResult, } from './types/protocol-event-types';
|
|
51
|
-
export { fetchProtocolPauseStatus, assertProtocolNotPaused, } from './protocol/protocol-pause';
|
|
52
|
-
export type { ProtocolPauseStatus, ProtocolPauseKey, } from './protocol/protocol-pause';
|
|
53
|
-
export { SDKError, ErrorCategory, ErrorSeverity } from './utils/error-handler';
|
|
54
|
-
export { setPositionDelegate, getPositionDelegate } from './utils/position-delegate.utils';
|
|
55
|
-
export { buildBtcExecuteEnvelope, } from './utils/btc-withdrawal-message';
|
|
56
|
-
export type { BtcExecuteSignParams, BtcExecuteSignedEnvelope, } from './utils/btc-withdrawal-message';
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Bitcoin-related Types and Interfaces
|
|
3
|
-
*/
|
|
4
|
-
export interface IBTCProof {
|
|
5
|
-
transactionId: string;
|
|
6
|
-
blockHeight: number;
|
|
7
|
-
confirmations: number;
|
|
8
|
-
merkleProof: string[];
|
|
9
|
-
blockHeader: string;
|
|
10
|
-
}
|
|
11
|
-
export interface BTCTransaction {
|
|
12
|
-
txid: string;
|
|
13
|
-
txHash: string;
|
|
14
|
-
blockHeight: number;
|
|
15
|
-
confirmations: number;
|
|
16
|
-
value: string;
|
|
17
|
-
from: string;
|
|
18
|
-
to: string;
|
|
19
|
-
timestamp: number;
|
|
20
|
-
}
|
|
21
|
-
export interface BTCProof {
|
|
22
|
-
transaction: BTCTransaction;
|
|
23
|
-
proof: IBTCProof;
|
|
24
|
-
valid: boolean;
|
|
25
|
-
verified?: boolean;
|
|
26
|
-
merkleProof?: string[];
|
|
27
|
-
}
|
|
28
|
-
export interface MonitoringOptions {
|
|
29
|
-
confirmations: number;
|
|
30
|
-
minConfirmations?: number;
|
|
31
|
-
timeoutMs: number;
|
|
32
|
-
timeout?: number;
|
|
33
|
-
retryAttempts: number;
|
|
34
|
-
retryDelayMs: number;
|
|
35
|
-
onConfirmation?: (confirmations: number) => void;
|
|
36
|
-
}
|
|
@@ -1,270 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* SDK Configuration Interfaces
|
|
3
|
-
*/
|
|
4
|
-
import type { Wallet, Signer, Provider } from "ethers";
|
|
5
|
-
import { LitNetwork } from "@gvnrdao/dh-lit-ops";
|
|
6
|
-
export type SDKMode = "standalone" | "service";
|
|
7
|
-
/**
|
|
8
|
-
* Contract Addresses Configuration
|
|
9
|
-
*/
|
|
10
|
-
export interface ContractAddresses {
|
|
11
|
-
positionManager: string;
|
|
12
|
-
positionManagerCore?: string;
|
|
13
|
-
positionManagerViews?: string;
|
|
14
|
-
simplePsmV2?: string;
|
|
15
|
-
loanOperationsManager?: string;
|
|
16
|
-
termManager?: string;
|
|
17
|
-
collateralManager?: string;
|
|
18
|
-
ucdController?: string;
|
|
19
|
-
circuitBreaker?: string;
|
|
20
|
-
liquidationManager?: string;
|
|
21
|
-
ucdToken: string;
|
|
22
|
-
/** Optional when priceProviders is used (LIT actions fetch prices) */
|
|
23
|
-
priceFeedConsumer?: string;
|
|
24
|
-
operationAuthorizationRegistry?: string;
|
|
25
|
-
btcProofValidator?: string;
|
|
26
|
-
litActionValidator?: string;
|
|
27
|
-
/** BTCSpendAuthorizer proxy; required in dev for lit-actions `BtcSpendAuth` when passed via `contractAddresses`. */
|
|
28
|
-
btcSpendAuthorizer?: string;
|
|
29
|
-
/** BitcoinProviderRegistry proxy; required on non-hardhat chains when chain policy disallows arbitrary providers. */
|
|
30
|
-
bitcoinProviderRegistry?: string;
|
|
31
|
-
/** ContractVersionRegistry proxy; used for cross-contract version pinning. */
|
|
32
|
-
contractVersionRegistry?: string;
|
|
33
|
-
/** FeeRecipientRegistry proxy; M-8 fix — allowlist consulted by LoanOperationsManager.transferFee and SimplePSMV2.transferFee. */
|
|
34
|
-
feeRecipientRegistry?: string;
|
|
35
|
-
/** PositionDelegateRegistry proxy; consumed by LIT Action authorization verifier as the third recovery arm for Safe-as-borrower flows. */
|
|
36
|
-
positionDelegateRegistry?: string;
|
|
37
|
-
/** BitcoinWithdrawalAddressRegistry proxy; per-wallet allowlist that gates borrower-initiated BTC withdrawal destinations (24h time-lock). */
|
|
38
|
-
bitcoinWithdrawalAddressRegistry?: string;
|
|
39
|
-
mockUsdcToken?: string;
|
|
40
|
-
mockUsdcOwner?: string;
|
|
41
|
-
mockUsdtToken?: string;
|
|
42
|
-
mockUsdtOwner?: string;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Base configuration shared by all SDK modes
|
|
46
|
-
*/
|
|
47
|
-
interface BaseSDKConfig {
|
|
48
|
-
litNetwork?: LitNetwork;
|
|
49
|
-
contractSigner?: Wallet | Signer;
|
|
50
|
-
/**
|
|
51
|
-
* Optional signer used exclusively for EIP-712 server-session login.
|
|
52
|
-
* When provided, `ServerSession` uses this instead of `contractSigner` so
|
|
53
|
-
* the two concerns (auth identity vs on-chain msg.sender) can differ. In
|
|
54
|
-
* Safe mode the CLI passes the raw agent EOA here while `contractSigner`
|
|
55
|
-
* is a SafeModuleSignerAdapter that routes transactions through the module.
|
|
56
|
-
*/
|
|
57
|
-
authSigner?: Wallet | Signer;
|
|
58
|
-
ethRpcUrl?: string;
|
|
59
|
-
chainId?: number;
|
|
60
|
-
networkOverride?: {
|
|
61
|
-
chainId: number;
|
|
62
|
-
name: string;
|
|
63
|
-
};
|
|
64
|
-
provider?: Provider;
|
|
65
|
-
chain?: string;
|
|
66
|
-
bitcoinNetwork?: "mainnet" | "testnet" | "regtest";
|
|
67
|
-
litActionCid?: string;
|
|
68
|
-
litNodeConnectTimeoutMs?: number;
|
|
69
|
-
subgraphUrl?: string;
|
|
70
|
-
priceProviders?: PriceProviderConfig[];
|
|
71
|
-
/** PKP Ethereum address for signed price oracle (Lit jsParams pkpId); optional */
|
|
72
|
-
priceOraclePkpId?: string;
|
|
73
|
-
bitcoinFaucetUrl?: string;
|
|
74
|
-
contractAddresses?: ContractAddresses;
|
|
75
|
-
subgraphs?: {
|
|
76
|
-
tokenGvnrUrl?: string;
|
|
77
|
-
diamondHandsUrl?: string;
|
|
78
|
-
};
|
|
79
|
-
graphApiKey?: string;
|
|
80
|
-
graphOptions?: {
|
|
81
|
-
requestTimeoutMs?: number;
|
|
82
|
-
maxRetries?: number;
|
|
83
|
-
pageSize?: number;
|
|
84
|
-
};
|
|
85
|
-
mockUsdcTokenAddress?: string;
|
|
86
|
-
mockUsdcOwnerAddress?: string;
|
|
87
|
-
mockUsdcDecimals?: number;
|
|
88
|
-
mockUsdtTokenAddress?: string;
|
|
89
|
-
mockUsdtOwnerAddress?: string;
|
|
90
|
-
mockUsdtDecimals?: number;
|
|
91
|
-
ucdTokenAddress?: string;
|
|
92
|
-
sessionExpirationMinutes?: number;
|
|
93
|
-
transactionTimeoutMs?: number;
|
|
94
|
-
retryAttempts?: number;
|
|
95
|
-
debug?: boolean;
|
|
96
|
-
/** Notification label for server Telegram notifications. Default: "DH SDK". Set "DH APP" in the web app. */
|
|
97
|
-
callerLabel?: string;
|
|
98
|
-
/**
|
|
99
|
-
* Optional: Override quantum timing buffer (in seconds)
|
|
100
|
-
* Default: Auto-detected based on network (10s for local, 50s for Sepolia, 35s for mainnet)
|
|
101
|
-
*
|
|
102
|
-
* Network-specific defaults:
|
|
103
|
-
* - Local networks (1337, 31337): 10s
|
|
104
|
-
* - Testnets (Sepolia 11155111, Goerli 5): 45-50s
|
|
105
|
-
* - Mainnet (1): 35s
|
|
106
|
-
*
|
|
107
|
-
* Only override if you have specific latency requirements.
|
|
108
|
-
* Recommended: Leave undefined to use automatic network detection.
|
|
109
|
-
*/
|
|
110
|
-
quantumBufferSeconds?: number;
|
|
111
|
-
/**
|
|
112
|
-
* @deprecated No longer read. On Sepolia (11155111), when `eth_estimateGas` fails for
|
|
113
|
-
* `mintUCD` but a static `eth_call` succeeds, the SDK always broadcasts with a fixed
|
|
114
|
-
* gas ceiling (EIP-1559). Retained for backward-compatible configs.
|
|
115
|
-
*/
|
|
116
|
-
skipGasEstimation?: boolean;
|
|
117
|
-
pkpServiceTimeoutMs?: number;
|
|
118
|
-
pkpServiceRetryCount?: number;
|
|
119
|
-
pkpServiceRetryDelayMs?: number;
|
|
120
|
-
balanceCacheOptions?: {
|
|
121
|
-
enabled?: boolean;
|
|
122
|
-
ttlMs?: number;
|
|
123
|
-
maxSize?: number;
|
|
124
|
-
};
|
|
125
|
-
addressCacheOptions?: {
|
|
126
|
-
enabled?: boolean;
|
|
127
|
-
ttlMs?: number;
|
|
128
|
-
maxSize?: number;
|
|
129
|
-
debug?: boolean;
|
|
130
|
-
};
|
|
131
|
-
concurrencyOptions?: {
|
|
132
|
-
enabled?: boolean;
|
|
133
|
-
concurrency?: number;
|
|
134
|
-
timeout?: number;
|
|
135
|
-
debug?: boolean;
|
|
136
|
-
};
|
|
137
|
-
loggingOptions?: {
|
|
138
|
-
enabled?: boolean;
|
|
139
|
-
level?: "debug" | "info" | "warn" | "error";
|
|
140
|
-
includeTimestamp?: boolean;
|
|
141
|
-
includeContext?: boolean;
|
|
142
|
-
maxContextKeys?: number;
|
|
143
|
-
verboseInProduction?: boolean;
|
|
144
|
-
};
|
|
145
|
-
validators?: {
|
|
146
|
-
/** Validator version for position creation (createPosition) - usually v1 for PKP security validation */
|
|
147
|
-
loanCreation: number;
|
|
148
|
-
/** Validator version for UCD minting (mintUCD) - usually v4 for business rules validation */
|
|
149
|
-
minting: number;
|
|
150
|
-
/** Validator version for partial payments (makePayment) - usually v1 for payment validation */
|
|
151
|
-
payment: number;
|
|
152
|
-
/** Validator version for loan extension/renewal (extendPosition) - usually v4 for extension validation */
|
|
153
|
-
extension: number;
|
|
154
|
-
};
|
|
155
|
-
defaultSelectedTermMonths?: number;
|
|
156
|
-
temperSignaturesTest?: boolean;
|
|
157
|
-
/**
|
|
158
|
-
* Optional in-process notification sink invoked alongside the existing service-mode
|
|
159
|
-
* HTTP relay. Fires in BOTH `standalone` and `service` mode so consumers can observe
|
|
160
|
-
* lifecycle events (e.g. loan renewal, mint, payment, withdrawal) without depending
|
|
161
|
-
* on `lit-ops-server`. The SDK already emits messages via `formatLoan*Message` helpers
|
|
162
|
-
* — this hook just exposes them locally. Errors thrown by the handler are swallowed
|
|
163
|
-
* so notification failures cannot break business operations.
|
|
164
|
-
*
|
|
165
|
-
* @example
|
|
166
|
-
* const notifications: string[] = [];
|
|
167
|
-
* sdkConfig.notificationHandler = (msg) => { notifications.push(msg); };
|
|
168
|
-
*/
|
|
169
|
-
notificationHandler?: (message: string) => void | Promise<void>;
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* Service Mode Configuration
|
|
173
|
-
* Uses lit-ops-server for PKP operations
|
|
174
|
-
*/
|
|
175
|
-
export interface ServiceModeConfig extends BaseSDKConfig {
|
|
176
|
-
mode: "service";
|
|
177
|
-
serviceEndpoint: string;
|
|
178
|
-
litOpsSigner?: never;
|
|
179
|
-
}
|
|
180
|
-
/**
|
|
181
|
-
* Standalone Mode Configuration
|
|
182
|
-
* User provides signer for direct LIT operations
|
|
183
|
-
*/
|
|
184
|
-
export interface StandaloneModeConfig extends BaseSDKConfig {
|
|
185
|
-
mode: "standalone";
|
|
186
|
-
litOpsSigner: Wallet;
|
|
187
|
-
serviceEndpoint?: never;
|
|
188
|
-
}
|
|
189
|
-
/**
|
|
190
|
-
* Main SDK Configuration - Discriminated Union
|
|
191
|
-
*
|
|
192
|
-
* Use ServiceModeConfig for production deployments with lit-ops-server
|
|
193
|
-
* Use StandaloneModeConfig for development/testing with direct LIT access
|
|
194
|
-
*
|
|
195
|
-
* @example Service Mode
|
|
196
|
-
* ```typescript
|
|
197
|
-
* const config: DiamondHandsSDKConfig = {
|
|
198
|
-
* mode: 'service',
|
|
199
|
-
* serviceEndpoint: 'https://lit-ops.example.com',
|
|
200
|
-
* contractSigner: wallet
|
|
201
|
-
* };
|
|
202
|
-
* ```
|
|
203
|
-
*
|
|
204
|
-
* @example Standalone Mode
|
|
205
|
-
* ```typescript
|
|
206
|
-
* const config: DiamondHandsSDKConfig = {
|
|
207
|
-
* mode: 'standalone',
|
|
208
|
-
* litOpsSigner: wallet,
|
|
209
|
-
* contractSigner: wallet
|
|
210
|
-
* };
|
|
211
|
-
* ```
|
|
212
|
-
*/
|
|
213
|
-
export type DiamondHandsSDKConfig = ServiceModeConfig | StandaloneModeConfig;
|
|
214
|
-
/**
|
|
215
|
-
* Type guard to check if config is ServiceModeConfig
|
|
216
|
-
*/
|
|
217
|
-
export declare function isServiceModeConfig(config: DiamondHandsSDKConfig): config is ServiceModeConfig;
|
|
218
|
-
/**
|
|
219
|
-
* Type guard to check if config is StandaloneModeConfig
|
|
220
|
-
*/
|
|
221
|
-
export declare function isStandaloneModeConfig(config: DiamondHandsSDKConfig): config is StandaloneModeConfig;
|
|
222
|
-
export declare function validateServiceModeConfig(config: ServiceModeConfig): string | null;
|
|
223
|
-
/**
|
|
224
|
-
* Validates that StandaloneModeConfig has required fields
|
|
225
|
-
*/
|
|
226
|
-
export declare function validateStandaloneModeConfig(config: StandaloneModeConfig): string | null;
|
|
227
|
-
/**
|
|
228
|
-
* Validates SDK configuration based on mode
|
|
229
|
-
*/
|
|
230
|
-
export declare function validateSDKConfig(config: DiamondHandsSDKConfig): string | null;
|
|
231
|
-
/**
|
|
232
|
-
* SDK Initialization Options
|
|
233
|
-
*/
|
|
234
|
-
export interface SDKInitOptions {
|
|
235
|
-
overrideDefaults?: boolean;
|
|
236
|
-
customProvider?: Provider;
|
|
237
|
-
skipNetworkCheck?: boolean;
|
|
238
|
-
}
|
|
239
|
-
/**
|
|
240
|
-
* Network Configuration (basic)
|
|
241
|
-
*/
|
|
242
|
-
export interface BasicNetworkConfig {
|
|
243
|
-
name: string;
|
|
244
|
-
chainId: number;
|
|
245
|
-
rpcUrl: string;
|
|
246
|
-
blockExplorerUrl?: string;
|
|
247
|
-
}
|
|
248
|
-
/**
|
|
249
|
-
* Bitcoin Provider Configuration
|
|
250
|
-
*/
|
|
251
|
-
export interface BitcoinProviderConfig {
|
|
252
|
-
url: string;
|
|
253
|
-
network: "mainnet" | "regtest";
|
|
254
|
-
auth?: {
|
|
255
|
-
username: string;
|
|
256
|
-
password: string;
|
|
257
|
-
};
|
|
258
|
-
name?: string;
|
|
259
|
-
priority?: number;
|
|
260
|
-
}
|
|
261
|
-
/**
|
|
262
|
-
* Price Provider Configuration
|
|
263
|
-
*/
|
|
264
|
-
export interface PriceProviderConfig {
|
|
265
|
-
name: string;
|
|
266
|
-
pkpId?: string;
|
|
267
|
-
apiKey?: string;
|
|
268
|
-
apiSecret?: string;
|
|
269
|
-
}
|
|
270
|
-
export {};
|