@gvnrdao/dh-sdk 0.0.172 → 0.0.206
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/LICENSE +21 -0
- package/README.md +86 -5
- package/browser/dist/index.d.ts +3 -4
- package/browser/dist/index.d.ts.map +1 -1
- package/browser/dist/index.js +4 -3
- package/dist/constants/chunks/contract-abis.d.ts +7 -0
- package/dist/constants/chunks/deployment-addresses.d.ts +68 -0
- package/dist/constants/chunks/encrypted-provider-params.d.ts +21 -0
- package/dist/constants/chunks/environment.browser.d.ts +45 -0
- package/dist/constants/chunks/environment.d.ts +57 -0
- package/dist/constants/chunks/network-configs.d.ts +65 -0
- package/dist/constants/chunks/sdk-config.d.ts +33 -0
- package/dist/constants/chunks/sdk-limits.d.ts +66 -0
- package/dist/constants/index.d.ts +15 -0
- package/dist/graphs/client.d.ts +19 -0
- package/dist/graphs/diamond-hands.d.ts +248 -0
- package/dist/index.d.ts +47 -7319
- package/dist/index.js +4439 -16783
- package/dist/index.mjs +4452 -16773
- package/dist/interfaces/chunks/btc.i.d.ts +36 -0
- package/dist/interfaces/chunks/config.i.d.ts +245 -0
- package/dist/interfaces/chunks/contract-interactions.i.d.ts +64 -0
- package/dist/interfaces/chunks/contract-types.i.d.ts +165 -0
- package/dist/interfaces/chunks/lit-actions-results.i.d.ts +165 -0
- package/dist/interfaces/chunks/lit-actions.i.d.ts +98 -0
- package/dist/interfaces/chunks/loan-operations.i.d.ts +332 -0
- package/dist/interfaces/chunks/pkp-integration.i.d.ts +87 -0
- package/dist/interfaces/chunks/position-query.i.d.ts +76 -0
- package/dist/interfaces/chunks/requests.i.d.ts +55 -0
- package/dist/interfaces/chunks/ucd-minting.i.d.ts +34 -0
- package/dist/interfaces/chunks/utility.i.d.ts +64 -0
- package/dist/interfaces/index.d.ts +17 -0
- package/dist/modules/bitcoin/bitcoin-operations.module.d.ts +215 -0
- package/dist/modules/cache/cache-manager.module.d.ts +251 -0
- package/dist/modules/contract/contract-manager.module.d.ts +136 -0
- package/dist/modules/diamond-hands-sdk.d.ts +666 -0
- package/dist/modules/loan/loan-creator.module.d.ts +143 -0
- package/dist/modules/loan/loan-query.module.d.ts +204 -0
- package/dist/modules/mock/mock-token-manager.module.d.ts +83 -0
- package/dist/modules/pkp/pkp-manager.module.d.ts +132 -0
- package/dist/protocol/protocol-pause.d.ts +19 -0
- package/dist/server.d.ts +17 -0
- package/dist/server.js +285 -0
- package/dist/server.mjs +242 -0
- package/dist/types/authorization-params.d.ts +160 -0
- package/dist/types/branded/domain-values.d.ts +138 -0
- package/dist/types/branded/ids.d.ts +23 -0
- package/dist/types/event-types.d.ts +235 -0
- package/dist/types/graph-dtos.d.ts +228 -0
- package/dist/types/loanStatus.d.ts +10 -0
- package/dist/types/result.d.ts +120 -0
- package/dist/utils/bitcoin-address-cache.utils.d.ts +87 -0
- package/dist/utils/bitcoin-provider.utils.d.ts +48 -0
- package/dist/utils/bitcoin-signature.d.ts +20 -0
- package/dist/utils/chunks/bitcoin-utils.d.ts +75 -0
- package/dist/utils/chunks/eip1559-broadcast.utils.d.ts +24 -0
- package/dist/utils/error-handler.d.ts +106 -0
- package/dist/utils/ethers-interop.utils.d.ts +146 -0
- package/dist/utils/extend-authorization.utils.d.ts +61 -0
- package/dist/utils/lit-signature.utils.d.ts +6 -0
- package/dist/utils/logger.utils.d.ts +142 -0
- package/dist/utils/mint-authorization.utils.d.ts +231 -0
- package/dist/utils/quantum-timing.d.ts +75 -0
- package/dist/utils/signature-tempering.utils.d.ts +31 -0
- package/dist/utils/telegram-messaging.utils.d.ts +188 -0
- package/package.json +43 -23
- package/browser/dist/20.browser.js +0 -1
- package/browser/dist/397.browser.js +0 -2
- package/browser/dist/397.browser.js.LICENSE.txt +0 -1
- package/browser/dist/833.browser.js +0 -2
- package/browser/dist/833.browser.js.LICENSE.txt +0 -1
- package/browser/dist/browser.js +0 -14
- package/browser/dist/browser.js.LICENSE.txt +0 -90
- package/dist/index.d.mts +0 -7320
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import type { LoanData } from "../interfaces";
|
|
2
|
+
import type { GraphPositionWithBorrowerDTO } from "../types/graph-dtos";
|
|
3
|
+
import type { LoanEvents, LoanEventsFilter } from "../types/event-types";
|
|
4
|
+
import type { BitcoinOperations, EnrichedBitcoinBalance } from "../modules/bitcoin/bitcoin-operations.module";
|
|
5
|
+
export interface DiamondHandsGraphConfig {
|
|
6
|
+
endpoint: string;
|
|
7
|
+
requestTimeoutMs?: number;
|
|
8
|
+
maxRetries?: number;
|
|
9
|
+
defaultPageSize?: number;
|
|
10
|
+
headers?: Record<string, string>;
|
|
11
|
+
}
|
|
12
|
+
export interface UserData {
|
|
13
|
+
id: string;
|
|
14
|
+
positions: LoanData[];
|
|
15
|
+
totalBorrowed: string;
|
|
16
|
+
totalRepaid: string;
|
|
17
|
+
activePositions: string;
|
|
18
|
+
firstInteractionTimestamp: string;
|
|
19
|
+
lastInteractionTimestamp: string;
|
|
20
|
+
}
|
|
21
|
+
export interface LoanTermData {
|
|
22
|
+
id: string;
|
|
23
|
+
months: string;
|
|
24
|
+
mintFeeBps?: string;
|
|
25
|
+
extensionFeeBps?: string;
|
|
26
|
+
isValid?: boolean;
|
|
27
|
+
createdAt?: string;
|
|
28
|
+
createdAtBlock?: string;
|
|
29
|
+
}
|
|
30
|
+
export interface PSMConfigurationData {
|
|
31
|
+
id: string;
|
|
32
|
+
version: string;
|
|
33
|
+
redeemEnabled: boolean;
|
|
34
|
+
totalSwapVolume: string;
|
|
35
|
+
totalRedeemVolume: string;
|
|
36
|
+
supportedStablecoinsCount: string;
|
|
37
|
+
lastUpdated: string;
|
|
38
|
+
}
|
|
39
|
+
export interface SupportedStablecoinData {
|
|
40
|
+
id: string;
|
|
41
|
+
address: string;
|
|
42
|
+
isSupported: boolean;
|
|
43
|
+
exchangeRate: string;
|
|
44
|
+
entryFee: string;
|
|
45
|
+
exitFee: string;
|
|
46
|
+
reserves: string;
|
|
47
|
+
decimals: string;
|
|
48
|
+
totalSwapVolume: string;
|
|
49
|
+
totalRedeemVolume: string;
|
|
50
|
+
swapCount: string;
|
|
51
|
+
redeemCount: string;
|
|
52
|
+
addedAt: string;
|
|
53
|
+
lastUpdated: string;
|
|
54
|
+
}
|
|
55
|
+
export interface PSMTransactionData {
|
|
56
|
+
id: string;
|
|
57
|
+
type: string;
|
|
58
|
+
user: string;
|
|
59
|
+
stablecoin: SupportedStablecoinData;
|
|
60
|
+
stablecoinAmount: string;
|
|
61
|
+
ucdAmount: string;
|
|
62
|
+
fee: string;
|
|
63
|
+
effectiveRate: string;
|
|
64
|
+
timestamp: string;
|
|
65
|
+
blockNumber: string;
|
|
66
|
+
transactionHash: string;
|
|
67
|
+
}
|
|
68
|
+
export interface UserRateLimitData {
|
|
69
|
+
id: string;
|
|
70
|
+
user: string;
|
|
71
|
+
stablecoin: SupportedStablecoinData;
|
|
72
|
+
lastOperationBlock: string;
|
|
73
|
+
operationCount: string;
|
|
74
|
+
isCurrentlyLimited: boolean;
|
|
75
|
+
nextResetBlock: string;
|
|
76
|
+
lastUpdated: string;
|
|
77
|
+
}
|
|
78
|
+
export declare class DiamondHandsGraph {
|
|
79
|
+
private client;
|
|
80
|
+
private defaultPageSize;
|
|
81
|
+
private bitcoinOps?;
|
|
82
|
+
constructor(config: DiamondHandsGraphConfig, bitcoinOps?: BitcoinOperations);
|
|
83
|
+
/**
|
|
84
|
+
* Transform graph position data to LoanData interface
|
|
85
|
+
* Converts flat graph structure to nested LoanData structure
|
|
86
|
+
*/
|
|
87
|
+
private transformGraphPositionToLoanData;
|
|
88
|
+
/**
|
|
89
|
+
* Helper: Get total count by paginating through all results
|
|
90
|
+
* The Graph has a hard limit of 1000 items per query, so we need to paginate
|
|
91
|
+
*
|
|
92
|
+
* NOTE: This implementation fetches minimal data (just IDs) for counting.
|
|
93
|
+
* The Graph protocol does not currently support count-only aggregation queries,
|
|
94
|
+
* so this batching approach is optimal for total count determination.
|
|
95
|
+
* Future optimization: If The Graph adds support for aggregate functions
|
|
96
|
+
* (e.g., `positions_aggregate { count }`), this should be updated.
|
|
97
|
+
*
|
|
98
|
+
* @param entityName The GraphQL entity name (e.g., "positions", "users")
|
|
99
|
+
* @param whereClause Optional GraphQL where clause (e.g., "{ borrower: $borrower }")
|
|
100
|
+
* @param variables Optional variables for the where clause
|
|
101
|
+
* @returns Total count of items
|
|
102
|
+
*/
|
|
103
|
+
private getTotalCountPaginated;
|
|
104
|
+
/**
|
|
105
|
+
* Get user positions from subgraph
|
|
106
|
+
*/
|
|
107
|
+
getUserPositions(userAddress: string, first?: number, skip?: number, orderBy?: string, orderDirection?: string): Promise<{
|
|
108
|
+
positions: LoanData[];
|
|
109
|
+
total: number;
|
|
110
|
+
}>;
|
|
111
|
+
/**
|
|
112
|
+
* Get user positions with enriched Bitcoin balance data
|
|
113
|
+
*
|
|
114
|
+
* Same as getUserPositions but queries actual BTC balance from Bitcoin network
|
|
115
|
+
* for each vault address in parallel.
|
|
116
|
+
*
|
|
117
|
+
* @param userAddress - User's Ethereum address
|
|
118
|
+
* @param first - Optional: max number of positions to return (default: 10)
|
|
119
|
+
* @param skip - Optional: number of positions to skip (default: 0)
|
|
120
|
+
* @param orderBy - Optional: field to order by (default: "createdAt")
|
|
121
|
+
* @param orderDirection - Optional: asc or desc (default: "desc" - most recent first)
|
|
122
|
+
* @returns Positions with actual BTC balances from Bitcoin network
|
|
123
|
+
*/
|
|
124
|
+
getUserPositionsWithBtc(userAddress: string, first?: number, skip?: number, orderBy?: string, orderDirection?: "asc" | "desc"): Promise<{
|
|
125
|
+
positions: (LoanData & {
|
|
126
|
+
btcBalance?: EnrichedBitcoinBalance;
|
|
127
|
+
})[];
|
|
128
|
+
total: number;
|
|
129
|
+
}>;
|
|
130
|
+
/**
|
|
131
|
+
* Get position by PKP ID from subgraph
|
|
132
|
+
*/
|
|
133
|
+
getPositionByPKP(pkpId: string): Promise<LoanData | null>;
|
|
134
|
+
/**
|
|
135
|
+
* Get detailed position data by PKP ID from subgraph
|
|
136
|
+
*/
|
|
137
|
+
getDetailedPositionByPkpId(pkpId: string): Promise<any | null>;
|
|
138
|
+
/**
|
|
139
|
+
* Get detailed position data by position ID from subgraph
|
|
140
|
+
*/
|
|
141
|
+
getDetailedPositionById(positionId: string): Promise<GraphPositionWithBorrowerDTO | null>;
|
|
142
|
+
/**
|
|
143
|
+
* Get all positions with pagination
|
|
144
|
+
*/
|
|
145
|
+
getAllPositions(options?: {
|
|
146
|
+
pageSize?: number;
|
|
147
|
+
maxPages?: number;
|
|
148
|
+
}): Promise<LoanData[]>;
|
|
149
|
+
/**
|
|
150
|
+
* Get all positions directly (simple query with pagination support)
|
|
151
|
+
*/
|
|
152
|
+
getPositions(first?: number, orderBy?: string, orderDirection?: "asc" | "desc", skip?: number, includeTotalCount?: boolean): Promise<{
|
|
153
|
+
positions: LoanData[];
|
|
154
|
+
total: number;
|
|
155
|
+
}>;
|
|
156
|
+
/**
|
|
157
|
+
* Get positions filtered by an array of statuses
|
|
158
|
+
*/
|
|
159
|
+
getPositionsByStatus(statuses: string[], first?: number, orderBy?: string, orderDirection?: "asc" | "desc", skip?: number): Promise<{
|
|
160
|
+
positions: LoanData[];
|
|
161
|
+
total: number;
|
|
162
|
+
}>;
|
|
163
|
+
/**
|
|
164
|
+
* Get active positions only
|
|
165
|
+
*/
|
|
166
|
+
getActivePositions(options?: {
|
|
167
|
+
pageSize?: number;
|
|
168
|
+
maxPages?: number;
|
|
169
|
+
}): Promise<LoanData[]>;
|
|
170
|
+
/**
|
|
171
|
+
* Get protocol statistics
|
|
172
|
+
*/
|
|
173
|
+
getProtocolStats(): Promise<{
|
|
174
|
+
totalValueLocked: string;
|
|
175
|
+
totalBorrowed: string;
|
|
176
|
+
totalRepaid: string;
|
|
177
|
+
totalLiquidated: string;
|
|
178
|
+
totalPositions: string;
|
|
179
|
+
activePositions: string;
|
|
180
|
+
totalUsers: string;
|
|
181
|
+
} | null>;
|
|
182
|
+
/**
|
|
183
|
+
* Health check for subgraph
|
|
184
|
+
*/
|
|
185
|
+
healthCheck(): Promise<{
|
|
186
|
+
isHealthy: boolean;
|
|
187
|
+
latestBlock?: string;
|
|
188
|
+
}>;
|
|
189
|
+
/**
|
|
190
|
+
* Get all configured loan terms (from subgraph)
|
|
191
|
+
* Note: If the subgraph does not seed default terms from the contract, this may return an empty array.
|
|
192
|
+
*/
|
|
193
|
+
getLoanTerms(options?: {
|
|
194
|
+
first?: number;
|
|
195
|
+
skip?: number;
|
|
196
|
+
}): Promise<LoanTermData[]>;
|
|
197
|
+
/**
|
|
198
|
+
* Get a single loan term by months (from subgraph)
|
|
199
|
+
* Typical id is the months as string, e.g., "12".
|
|
200
|
+
*/
|
|
201
|
+
getLoanTerm(months: number | string): Promise<LoanTermData | null>;
|
|
202
|
+
/**
|
|
203
|
+
* Get PSM configuration from subgraph
|
|
204
|
+
*/
|
|
205
|
+
getPSMConfiguration(): Promise<PSMConfigurationData | null>;
|
|
206
|
+
/**
|
|
207
|
+
* Get all supported stablecoins from subgraph
|
|
208
|
+
*/
|
|
209
|
+
getSupportedStablecoins(onlySupported?: boolean): Promise<SupportedStablecoinData[]>;
|
|
210
|
+
/**
|
|
211
|
+
* Get stablecoin details by address
|
|
212
|
+
*/
|
|
213
|
+
getStablecoinDetails(address: string): Promise<SupportedStablecoinData | null>;
|
|
214
|
+
/**
|
|
215
|
+
* Get user rate limit status for a specific stablecoin
|
|
216
|
+
*/
|
|
217
|
+
getUserRateLimit(userAddress: string, stablecoinAddress: string): Promise<UserRateLimitData | null>;
|
|
218
|
+
/**
|
|
219
|
+
* Get PSM transactions with filters
|
|
220
|
+
*/
|
|
221
|
+
getPSMTransactions(filters?: {
|
|
222
|
+
user?: string;
|
|
223
|
+
stablecoin?: string;
|
|
224
|
+
type?: "SWAP" | "REDEEM";
|
|
225
|
+
first?: number;
|
|
226
|
+
skip?: number;
|
|
227
|
+
}): Promise<PSMTransactionData[]>;
|
|
228
|
+
/**
|
|
229
|
+
* Get PSM analytics for a date range
|
|
230
|
+
*/
|
|
231
|
+
getPSMDailyMetrics(startDate?: string, endDate?: string, first?: number): Promise<any[]>;
|
|
232
|
+
/**
|
|
233
|
+
* Get all events for a specific loan position
|
|
234
|
+
*
|
|
235
|
+
* Returns a comprehensive event history including:
|
|
236
|
+
* - Payments (full repayments, partial payments, extension fees)
|
|
237
|
+
* - Status updates with reasons
|
|
238
|
+
* - Liquidation event (if liquidated)
|
|
239
|
+
* - UCD mint events
|
|
240
|
+
* - Community fee distributions
|
|
241
|
+
*
|
|
242
|
+
* @param positionId - The position ID to query events for
|
|
243
|
+
* @param filter - Optional filters to apply
|
|
244
|
+
* @returns Complete event history for the position
|
|
245
|
+
*/
|
|
246
|
+
getLoanEvents(positionId: string, filter?: LoanEventsFilter): Promise<LoanEvents>;
|
|
247
|
+
}
|
|
248
|
+
export type DiamondHandsGraphClient = DiamondHandsGraph;
|