@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.
- package/LICENSE +21 -0
- package/README.md +86 -5
- package/browser/dist/397.browser.js +1 -1
- package/browser/dist/833.browser.js +1 -1
- package/browser/dist/browser.js +1 -13
- package/browser/dist/browser.js.LICENSE.txt +1 -70
- 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 -7391
- package/dist/index.js +4525 -16860
- package/dist/index.mjs +4489 -16801
- package/dist/interfaces/chunks/btc.i.d.ts +36 -0
- package/dist/interfaces/chunks/config.i.d.ts +250 -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 +223 -0
- package/dist/modules/cache/cache-manager.module.d.ts +92 -0
- package/dist/modules/contract/contract-manager.module.d.ts +136 -0
- package/dist/modules/diamond-hands-sdk.d.ts +669 -0
- package/dist/modules/loan/loan-creator.module.d.ts +143 -0
- package/dist/modules/loan/loan-query.module.d.ts +206 -0
- package/dist/modules/mock/mock-token-manager.module.d.ts +83 -0
- package/dist/modules/pkp/pkp-manager.module.d.ts +136 -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 +224 -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 -22
- package/dist/index.d.mts +0 -7392
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LIT Action Types and Interfaces (SDK boundary)
|
|
3
|
+
*
|
|
4
|
+
* This file provides the strongly-typed SDK view of LIT Actions and
|
|
5
|
+
* re-exports the action registry interfaces from the @gvnrdao/dh-lit-actions
|
|
6
|
+
* package so that action names and configs stay in sync across packages.
|
|
7
|
+
*/
|
|
8
|
+
import type { DiamondHandsLitActions, LitActionName } from "@gvnrdao/dh-lit-actions";
|
|
9
|
+
import type { UcdMintValidatorResult, BtcWithdrawalValidatorResult, LiquidationValidatorResult, ExtendPositionValidatorResult, ProcessPaymentValidatorResult, LoanVaultBtcBalanceValidatorResult } from "./lit-actions-results.i";
|
|
10
|
+
/**
|
|
11
|
+
* Re-export registry types so SDK consumers can use the same action name space.
|
|
12
|
+
*/
|
|
13
|
+
export type { DiamondHandsLitActions, LitActionName };
|
|
14
|
+
/**
|
|
15
|
+
* Core LIT Action execution description.
|
|
16
|
+
*
|
|
17
|
+
* TParams describes the jsParams structure, TAuth describes the authSig shape.
|
|
18
|
+
* Both default to safe, unknown-based records instead of `any`.
|
|
19
|
+
*/
|
|
20
|
+
export interface ILitAction<TParams extends Record<string, unknown> = Record<string, unknown>, TAuth = LitActionAuth> {
|
|
21
|
+
code: string;
|
|
22
|
+
ipfsId?: string;
|
|
23
|
+
jsParams: TParams;
|
|
24
|
+
authSig: TAuth;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Parameters passed to lit-node-client.executeJs.
|
|
28
|
+
*
|
|
29
|
+
* This mirrors ILitAction but is named for historic reasons.
|
|
30
|
+
*/
|
|
31
|
+
export interface LitActionParams<TParams extends Record<string, unknown> = Record<string, unknown>, TAuth = LitActionAuth> {
|
|
32
|
+
code: string;
|
|
33
|
+
jsParams: TParams;
|
|
34
|
+
authSig: TAuth;
|
|
35
|
+
debug?: boolean;
|
|
36
|
+
pkpId?: string;
|
|
37
|
+
userAddress?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Collateral amount used by some actions (e.g. mint flows).
|
|
40
|
+
* Replaces legacy btcAmount naming.
|
|
41
|
+
*/
|
|
42
|
+
collateralAmount?: string;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Raw result returned from LIT Action execution.
|
|
46
|
+
*
|
|
47
|
+
* Callers are encouraged to wrap this in action-specific result
|
|
48
|
+
* types instead of accessing the generic `data` bag directly.
|
|
49
|
+
*/
|
|
50
|
+
export interface LitActionResult<TData = unknown> {
|
|
51
|
+
success: boolean;
|
|
52
|
+
signedData?: unknown;
|
|
53
|
+
decryptedData?: unknown;
|
|
54
|
+
claimedKeyId?: string;
|
|
55
|
+
signatures?: unknown;
|
|
56
|
+
/**
|
|
57
|
+
* Alias for signatures used by some helpers.
|
|
58
|
+
*/
|
|
59
|
+
signature?: string;
|
|
60
|
+
decryptions?: unknown;
|
|
61
|
+
claims?: unknown;
|
|
62
|
+
response?: string;
|
|
63
|
+
logs?: string;
|
|
64
|
+
/**
|
|
65
|
+
* Action-specific payload. Prefer narrowing this via generics.
|
|
66
|
+
*/
|
|
67
|
+
data?: TData;
|
|
68
|
+
/**
|
|
69
|
+
* Human-readable error (if any).
|
|
70
|
+
*/
|
|
71
|
+
error?: string;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Discriminated union of typed results for the core Diamond Hands actions.
|
|
75
|
+
*
|
|
76
|
+
* This can be used by higher-level SDK helpers to express that a given
|
|
77
|
+
* execution is expected to return a particular validator payload.
|
|
78
|
+
*/
|
|
79
|
+
export type DiamondHandsLitActionResult = LitActionResult<UcdMintValidatorResult> | LitActionResult<BtcWithdrawalValidatorResult> | LitActionResult<LiquidationValidatorResult> | LitActionResult<ExtendPositionValidatorResult> | LitActionResult<ProcessPaymentValidatorResult> | LitActionResult<LoanVaultBtcBalanceValidatorResult>;
|
|
80
|
+
/**
|
|
81
|
+
* Standard EIP-191 style authorization signature used by LIT.
|
|
82
|
+
*/
|
|
83
|
+
export interface LitActionAuth {
|
|
84
|
+
sig: string;
|
|
85
|
+
derivedVia: string;
|
|
86
|
+
signedMessage: string;
|
|
87
|
+
address: string;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Generic validation result used by some helper actions.
|
|
91
|
+
*
|
|
92
|
+
* Callers should prefer action-specific result types where available.
|
|
93
|
+
*/
|
|
94
|
+
export interface LitActionValidationResult<TDetails = unknown> {
|
|
95
|
+
valid: boolean;
|
|
96
|
+
error?: string;
|
|
97
|
+
details?: TDetails;
|
|
98
|
+
}
|
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loan Operations Interfaces
|
|
3
|
+
*/
|
|
4
|
+
import { LoanStatus } from "../../types/loanStatus";
|
|
5
|
+
export type BitcoinAddresses = {
|
|
6
|
+
mainnet: string;
|
|
7
|
+
testnet: string;
|
|
8
|
+
regtest: string;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Create Loan Request Interface
|
|
12
|
+
*/
|
|
13
|
+
export interface CreateLoanRequest {
|
|
14
|
+
selectedTerm: number;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* PKP Validation Data Interface
|
|
18
|
+
*/
|
|
19
|
+
export interface PKPValidationData {
|
|
20
|
+
tokenId: string;
|
|
21
|
+
publicKey: string;
|
|
22
|
+
ethAddress: string;
|
|
23
|
+
validationSignature: string;
|
|
24
|
+
btcAddresses: {
|
|
25
|
+
mainnet: string;
|
|
26
|
+
testnet: string;
|
|
27
|
+
regtest: string;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Create Loan Result Interface
|
|
32
|
+
*/
|
|
33
|
+
export interface CreateLoanResult {
|
|
34
|
+
success: boolean;
|
|
35
|
+
error?: string;
|
|
36
|
+
transactionHash?: string;
|
|
37
|
+
positionId?: string;
|
|
38
|
+
pkpData?: PKPValidationData;
|
|
39
|
+
vaultAddress?: string;
|
|
40
|
+
auditTrail?: {
|
|
41
|
+
pkpCreation: any;
|
|
42
|
+
validation: any;
|
|
43
|
+
contractCall: any;
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Loan Data Interface (Graph/SDK simplified shape)
|
|
48
|
+
*/
|
|
49
|
+
export interface LoanData {
|
|
50
|
+
id: string;
|
|
51
|
+
pkpId: string;
|
|
52
|
+
borrower: {
|
|
53
|
+
createdAt: number;
|
|
54
|
+
id: string;
|
|
55
|
+
};
|
|
56
|
+
createdAt: number;
|
|
57
|
+
lastUpdatedAt: number;
|
|
58
|
+
loan: {
|
|
59
|
+
ucdMinted: number;
|
|
60
|
+
ucdPaid: number;
|
|
61
|
+
ucdDebt: number;
|
|
62
|
+
selectedTerm: number;
|
|
63
|
+
status: LoanStatus;
|
|
64
|
+
expiryAt: number;
|
|
65
|
+
};
|
|
66
|
+
collateral: {
|
|
67
|
+
vaultAddress: string | BitcoinAddresses;
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Paginated Loans Response Interface
|
|
72
|
+
* Used by loan query methods that support pagination
|
|
73
|
+
*/
|
|
74
|
+
export interface PaginatedLoansResponse {
|
|
75
|
+
loans: LoanData[];
|
|
76
|
+
page: number;
|
|
77
|
+
maxRows: number;
|
|
78
|
+
totalLoans: number;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Detailed Loan Data Interface (used by getLoanById / PKP)
|
|
82
|
+
*/
|
|
83
|
+
export interface LoanDataDetail {
|
|
84
|
+
id: string;
|
|
85
|
+
pkpId: string;
|
|
86
|
+
borrower: {
|
|
87
|
+
id: string;
|
|
88
|
+
createdAt: number;
|
|
89
|
+
};
|
|
90
|
+
createdAt: number;
|
|
91
|
+
createdAtBlock: number;
|
|
92
|
+
lastUpdatedAt: number;
|
|
93
|
+
lastUpdatedAtBlock: number;
|
|
94
|
+
expiryAt: number;
|
|
95
|
+
loan: {
|
|
96
|
+
ucdMinted: number;
|
|
97
|
+
ucdPaid: number;
|
|
98
|
+
ucdDebt: number;
|
|
99
|
+
status: LoanStatus;
|
|
100
|
+
expiryAt: number;
|
|
101
|
+
currentTerm: {
|
|
102
|
+
id: string;
|
|
103
|
+
createdAt: number;
|
|
104
|
+
selectedTerm: number;
|
|
105
|
+
extensionFeeRate: number;
|
|
106
|
+
extensionFeeUCD: number;
|
|
107
|
+
};
|
|
108
|
+
extensions: {
|
|
109
|
+
extendedAt: number;
|
|
110
|
+
expiredAt: number;
|
|
111
|
+
term: number;
|
|
112
|
+
extensionFeeRate: number;
|
|
113
|
+
extensionFeeUCD: number;
|
|
114
|
+
};
|
|
115
|
+
totalExtensions: number;
|
|
116
|
+
payments: Array<{
|
|
117
|
+
amount: number;
|
|
118
|
+
blockNumber: number;
|
|
119
|
+
id: string;
|
|
120
|
+
newCollateralRatio: number;
|
|
121
|
+
newDebt: number;
|
|
122
|
+
payer: {
|
|
123
|
+
id: string;
|
|
124
|
+
};
|
|
125
|
+
createdAt: number;
|
|
126
|
+
transactionHash: string;
|
|
127
|
+
type: string;
|
|
128
|
+
}>;
|
|
129
|
+
totalPayments: number;
|
|
130
|
+
totalPaid: number;
|
|
131
|
+
};
|
|
132
|
+
collateral: {
|
|
133
|
+
vaultAddress: string | BitcoinAddresses;
|
|
134
|
+
};
|
|
135
|
+
liquidation: {
|
|
136
|
+
blockNumber: number;
|
|
137
|
+
collateralSeized: number;
|
|
138
|
+
commitHash: string;
|
|
139
|
+
commitTimestamp: string;
|
|
140
|
+
id: string;
|
|
141
|
+
liquidatedAmount: number;
|
|
142
|
+
liquidator: string;
|
|
143
|
+
revealDelay: string;
|
|
144
|
+
timestamp: number;
|
|
145
|
+
transactionHash: string;
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Loans Query Interface
|
|
150
|
+
*/
|
|
151
|
+
export interface LoansQuery {
|
|
152
|
+
ownerWalletAddress?: string;
|
|
153
|
+
status?: LoanStatus;
|
|
154
|
+
expiryRange?: {
|
|
155
|
+
from: number;
|
|
156
|
+
to: number;
|
|
157
|
+
};
|
|
158
|
+
creationRange?: {
|
|
159
|
+
from: number;
|
|
160
|
+
to: number;
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* UCD Mint Request Interface
|
|
165
|
+
*/
|
|
166
|
+
export interface UCDMintRequest {
|
|
167
|
+
positionId: string;
|
|
168
|
+
amount: number;
|
|
169
|
+
selectedTerm?: number;
|
|
170
|
+
skipValidation?: boolean;
|
|
171
|
+
rpcUrl?: string;
|
|
172
|
+
customBitcoinRpcUrl?: string;
|
|
173
|
+
testBtcPrice?: number;
|
|
174
|
+
debugOverrides?: {
|
|
175
|
+
useStubbedBtcData?: boolean;
|
|
176
|
+
stubbedBtcPriceUsd?: string;
|
|
177
|
+
stubbedAvailableBtcSats?: string;
|
|
178
|
+
stubbedAuthorizedSpendsHash?: string;
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* UCD Mint Result Interface
|
|
183
|
+
*/
|
|
184
|
+
export interface UCDMintResult {
|
|
185
|
+
success: boolean;
|
|
186
|
+
transactionHash?: string;
|
|
187
|
+
blockNumber?: number;
|
|
188
|
+
blockHash?: string;
|
|
189
|
+
gasUsed?: string;
|
|
190
|
+
effectiveGasPrice?: string;
|
|
191
|
+
positionId?: string;
|
|
192
|
+
amountMinted?: string;
|
|
193
|
+
amountMintedUCD?: number;
|
|
194
|
+
error?: string;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Renew Position Result Interface
|
|
198
|
+
*/
|
|
199
|
+
export interface RenewPositionResult {
|
|
200
|
+
success: boolean;
|
|
201
|
+
transactionHash?: string;
|
|
202
|
+
blockNumber?: number;
|
|
203
|
+
blockHash?: string;
|
|
204
|
+
gasUsed?: string;
|
|
205
|
+
effectiveGasPrice?: string;
|
|
206
|
+
positionId?: string;
|
|
207
|
+
extensionTerm?: number;
|
|
208
|
+
newExpiryAt?: number;
|
|
209
|
+
error?: string;
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Renew Position Request Interface
|
|
213
|
+
*/
|
|
214
|
+
export interface RenewPositionRequest {
|
|
215
|
+
positionId: string;
|
|
216
|
+
selectedTerm: number;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* BTC Withdrawal Result Interface
|
|
220
|
+
*/
|
|
221
|
+
export interface BTCWithdrawalResult {
|
|
222
|
+
success: boolean;
|
|
223
|
+
evmTransactionHash?: string;
|
|
224
|
+
blockNumber?: number;
|
|
225
|
+
blockHash?: string;
|
|
226
|
+
gasUsed?: string;
|
|
227
|
+
effectiveGasPrice?: string;
|
|
228
|
+
positionId?: string;
|
|
229
|
+
withdrawalAddress?: string;
|
|
230
|
+
networkFee?: number;
|
|
231
|
+
amountWithdrawn?: string;
|
|
232
|
+
bitcoinTransactionHash?: string;
|
|
233
|
+
utxoTxid?: string;
|
|
234
|
+
utxoVout?: number;
|
|
235
|
+
error?: string;
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Liquidation Request Interface
|
|
239
|
+
*/
|
|
240
|
+
export interface LiquidationRequest {
|
|
241
|
+
positionId: string;
|
|
242
|
+
forceContractCall?: boolean;
|
|
243
|
+
/**
|
|
244
|
+
* When true, the SDK will not send a UCD `approve(UCDController, …)` transaction.
|
|
245
|
+
* Use when the liquidator wallet has already approved UCDController (e.g. multisig flow).
|
|
246
|
+
* If allowance is insufficient, liquidation returns an error instead of approving.
|
|
247
|
+
*/
|
|
248
|
+
skipUcdApproval?: boolean;
|
|
249
|
+
rpcUrl?: string;
|
|
250
|
+
customBitcoinRpcUrl?: string;
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Liquidation Result Interface
|
|
254
|
+
*/
|
|
255
|
+
export interface LiquidationResult {
|
|
256
|
+
success: boolean;
|
|
257
|
+
error?: string;
|
|
258
|
+
transactionHash?: string;
|
|
259
|
+
blockNumber?: number;
|
|
260
|
+
positionId?: string;
|
|
261
|
+
debtAmount?: string;
|
|
262
|
+
collateralAmount?: string;
|
|
263
|
+
wasLiquidated?: boolean;
|
|
264
|
+
notLiquidatedReason?: string;
|
|
265
|
+
btcPrice?: string;
|
|
266
|
+
btcVaultBalance?: string;
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Partial Payment Request Interface
|
|
270
|
+
*/
|
|
271
|
+
export interface PartialPaymentRequest {
|
|
272
|
+
positionId: string;
|
|
273
|
+
paymentAmount: number;
|
|
274
|
+
rpcUrl?: string;
|
|
275
|
+
customBitcoinRpcUrl?: string;
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Confirm Balance Result Interface
|
|
279
|
+
*/
|
|
280
|
+
export interface ConfirmBalanceResult {
|
|
281
|
+
success: boolean;
|
|
282
|
+
transactionHash?: string;
|
|
283
|
+
blockNumber?: number;
|
|
284
|
+
blockHash?: string;
|
|
285
|
+
gasUsed?: string;
|
|
286
|
+
effectiveGasPrice?: string;
|
|
287
|
+
positionId?: string;
|
|
288
|
+
confirmedBalance?: string;
|
|
289
|
+
btcPrice?: string;
|
|
290
|
+
newStatus?: LoanStatus;
|
|
291
|
+
error?: string;
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Confirm Balance Request Interface
|
|
295
|
+
*/
|
|
296
|
+
export interface ConfirmBalanceRequest {
|
|
297
|
+
positionId: string;
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Partial Payment Result Interface
|
|
301
|
+
*/
|
|
302
|
+
export interface PartialPaymentResult {
|
|
303
|
+
success: boolean;
|
|
304
|
+
transactionHash?: string;
|
|
305
|
+
blockNumber?: number;
|
|
306
|
+
blockHash?: string;
|
|
307
|
+
gasUsed?: string;
|
|
308
|
+
effectiveGasPrice?: string;
|
|
309
|
+
positionId?: string;
|
|
310
|
+
paymentAmountUCD?: number;
|
|
311
|
+
error?: string;
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* Term with Fees Interface
|
|
315
|
+
*/
|
|
316
|
+
export interface TermWithFees {
|
|
317
|
+
termMonths: number;
|
|
318
|
+
originationFeeBps: number;
|
|
319
|
+
extensionFeeBps: number;
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Terms with Fees Result Interface
|
|
323
|
+
*/
|
|
324
|
+
export interface TermsWithFeesResult {
|
|
325
|
+
terms: TermWithFees[];
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* Configuration for Loan Operations Manager
|
|
329
|
+
*/
|
|
330
|
+
export interface LoanManagerConfig {
|
|
331
|
+
debug?: boolean;
|
|
332
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PKP Integration Interfaces
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* PKP Manager Interface
|
|
6
|
+
*/
|
|
7
|
+
export interface IPKPManager {
|
|
8
|
+
issuePKP(request: PKPIssuanceRequest): Promise<PKPData>;
|
|
9
|
+
validatePKP(pkpId: string): Promise<PKPValidationResult>;
|
|
10
|
+
getPKPData(pkpId: string): Promise<PKPData | null>;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* PKP Data Interface
|
|
14
|
+
*/
|
|
15
|
+
export interface PKPData {
|
|
16
|
+
tokenId: string;
|
|
17
|
+
publicKey: string;
|
|
18
|
+
ethAddress: string;
|
|
19
|
+
litActionCid?: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* PKP Issuance Request Interface
|
|
23
|
+
*/
|
|
24
|
+
export interface PKPIssuanceRequest {
|
|
25
|
+
userId: string;
|
|
26
|
+
metadata?: {
|
|
27
|
+
name?: string;
|
|
28
|
+
description?: string;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* PKP Creation Request Interface
|
|
33
|
+
*/
|
|
34
|
+
export interface PKPCreationRequest {
|
|
35
|
+
userId: string;
|
|
36
|
+
litActionCid: string;
|
|
37
|
+
metadata?: {
|
|
38
|
+
name?: string;
|
|
39
|
+
description?: string;
|
|
40
|
+
attributes?: Record<string, any>;
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* PKP Creation Result Interface
|
|
45
|
+
*/
|
|
46
|
+
export interface PKPCreationResult {
|
|
47
|
+
success: boolean;
|
|
48
|
+
error?: string;
|
|
49
|
+
tokenId?: string;
|
|
50
|
+
publicKey?: string;
|
|
51
|
+
ethAddress?: string;
|
|
52
|
+
transactionHash?: string;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* PKP Validation Request Interface
|
|
56
|
+
*/
|
|
57
|
+
export interface PKPValidationRequest {
|
|
58
|
+
pkpId: string;
|
|
59
|
+
message: string;
|
|
60
|
+
signature: string;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* PKP Validation Result Interface
|
|
64
|
+
*/
|
|
65
|
+
export interface PKPValidationResult {
|
|
66
|
+
valid: boolean;
|
|
67
|
+
error?: string;
|
|
68
|
+
validatorAddress?: string;
|
|
69
|
+
signature?: string;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* PKP Signing Request Interface
|
|
73
|
+
*/
|
|
74
|
+
export interface PKPSigningRequest {
|
|
75
|
+
pkpId: string;
|
|
76
|
+
messageHash: string;
|
|
77
|
+
params?: Record<string, any>;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* PKP Signing Result Interface
|
|
81
|
+
*/
|
|
82
|
+
export interface PKPSigningResult {
|
|
83
|
+
success: boolean;
|
|
84
|
+
error?: string;
|
|
85
|
+
signature?: string;
|
|
86
|
+
publicKey?: string;
|
|
87
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Position Query Interfaces
|
|
3
|
+
*/
|
|
4
|
+
import { LoanStatus } from "../../types/loanStatus";
|
|
5
|
+
/**
|
|
6
|
+
* Position data structure (from contract)
|
|
7
|
+
*/
|
|
8
|
+
export interface Position {
|
|
9
|
+
positionId: string;
|
|
10
|
+
pkpId: string;
|
|
11
|
+
borrower: string;
|
|
12
|
+
vaultAddress: string;
|
|
13
|
+
vaultAddressRegtest?: string;
|
|
14
|
+
ucdDebt: bigint;
|
|
15
|
+
createdAt: number;
|
|
16
|
+
lastUpdated: number;
|
|
17
|
+
expiryAt: number;
|
|
18
|
+
status: LoanStatus;
|
|
19
|
+
collateralRatio?: number;
|
|
20
|
+
requestedCollateralRatio?: number;
|
|
21
|
+
selectedTerm: number;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Bitcoin UTXO (Unspent Transaction Output)
|
|
25
|
+
*/
|
|
26
|
+
export interface BitcoinUTXO {
|
|
27
|
+
txId: string;
|
|
28
|
+
vout: number;
|
|
29
|
+
value: number;
|
|
30
|
+
confirmations: number;
|
|
31
|
+
scriptPubKey?: string;
|
|
32
|
+
address?: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Position with Bitcoin status
|
|
36
|
+
*/
|
|
37
|
+
export interface PositionWithBTCStatus extends Position {
|
|
38
|
+
btcStatus: {
|
|
39
|
+
actualAmount: bigint;
|
|
40
|
+
confirmations: number;
|
|
41
|
+
utxos: BitcoinUTXO[];
|
|
42
|
+
lastCheckedAt: number;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Position query options
|
|
47
|
+
*/
|
|
48
|
+
export interface PositionQueryOptions {
|
|
49
|
+
borrower?: string;
|
|
50
|
+
status?: LoanStatus | LoanStatus[];
|
|
51
|
+
verifyBTC?: boolean;
|
|
52
|
+
offset?: number;
|
|
53
|
+
limit?: number;
|
|
54
|
+
sortBy?: 'createdAt' | 'lastUpdated' | 'ucdDebt';
|
|
55
|
+
sortDirection?: 'asc' | 'desc';
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Position query result
|
|
59
|
+
*/
|
|
60
|
+
export interface PositionQueryResult {
|
|
61
|
+
positions: Position[] | PositionWithBTCStatus[];
|
|
62
|
+
total: number;
|
|
63
|
+
hasMore: boolean;
|
|
64
|
+
executionTimeMs: number;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Bitcoin balance check result
|
|
68
|
+
*/
|
|
69
|
+
export interface BitcoinBalanceResult {
|
|
70
|
+
address: string;
|
|
71
|
+
balance: bigint;
|
|
72
|
+
utxos: BitcoinUTXO[];
|
|
73
|
+
confirmations: number;
|
|
74
|
+
provider: string;
|
|
75
|
+
timestamp: number;
|
|
76
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* General Request/Response Types and Interfaces
|
|
3
|
+
*/
|
|
4
|
+
import { AuthorizationParams } from '../../types/authorization-params';
|
|
5
|
+
/**
|
|
6
|
+
* Authorization request with type-safe parameters
|
|
7
|
+
*/
|
|
8
|
+
export interface AuthorizationRequest {
|
|
9
|
+
/** PKP token ID */
|
|
10
|
+
pkpId: string;
|
|
11
|
+
/** Action being authorized (derived from params.type) */
|
|
12
|
+
action: string;
|
|
13
|
+
/** Type-safe authorization parameters (discriminated union) */
|
|
14
|
+
params: AuthorizationParams;
|
|
15
|
+
/** Authorization signature */
|
|
16
|
+
signature: string;
|
|
17
|
+
/** Request timestamp */
|
|
18
|
+
timestamp: number;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Result of an authorization check
|
|
22
|
+
*/
|
|
23
|
+
export interface AuthorizationResult {
|
|
24
|
+
/** Whether the authorization was successful */
|
|
25
|
+
authorized: boolean;
|
|
26
|
+
/** PKP token ID that was checked */
|
|
27
|
+
pkpId: string;
|
|
28
|
+
/** Error message if authorization failed */
|
|
29
|
+
error?: string;
|
|
30
|
+
/** Additional details about the authorization (type-safe per action) */
|
|
31
|
+
details?: unknown;
|
|
32
|
+
}
|
|
33
|
+
export interface ValidationRequest {
|
|
34
|
+
data: any;
|
|
35
|
+
rules: string[];
|
|
36
|
+
context?: Record<string, any>;
|
|
37
|
+
}
|
|
38
|
+
export interface ConfirmationResult {
|
|
39
|
+
confirmed: boolean;
|
|
40
|
+
confirmations: number;
|
|
41
|
+
blockHeight?: number;
|
|
42
|
+
txHash?: string;
|
|
43
|
+
error?: string;
|
|
44
|
+
}
|
|
45
|
+
export interface BTCDepositRequest {
|
|
46
|
+
positionId: string;
|
|
47
|
+
}
|
|
48
|
+
export interface BTCDepositResult {
|
|
49
|
+
success: boolean;
|
|
50
|
+
positionId?: string;
|
|
51
|
+
vaultBalance?: string;
|
|
52
|
+
hasBalance?: boolean;
|
|
53
|
+
validationResponse?: any;
|
|
54
|
+
error?: string;
|
|
55
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UCD Minting Types and Interfaces
|
|
3
|
+
*/
|
|
4
|
+
export interface IUCDMinting {
|
|
5
|
+
mint(params: MintingParams): Promise<MintingResult>;
|
|
6
|
+
calculateRewards(amount: string): Promise<RewardDistribution>;
|
|
7
|
+
validateMinting(params: MintingParams): Promise<boolean>;
|
|
8
|
+
}
|
|
9
|
+
export interface MintingParams {
|
|
10
|
+
amount: string;
|
|
11
|
+
recipient: string;
|
|
12
|
+
collateralType: string;
|
|
13
|
+
collateralAmount: string;
|
|
14
|
+
oracleData?: any;
|
|
15
|
+
}
|
|
16
|
+
export interface MintingResult {
|
|
17
|
+
success: boolean;
|
|
18
|
+
txHash?: string;
|
|
19
|
+
mintedAmount?: string;
|
|
20
|
+
fees?: string;
|
|
21
|
+
rewards?: RewardDistribution;
|
|
22
|
+
error?: string;
|
|
23
|
+
}
|
|
24
|
+
export interface RewardDistribution {
|
|
25
|
+
totalRewards: string;
|
|
26
|
+
operatorReward: string;
|
|
27
|
+
protocolReward: string;
|
|
28
|
+
liquidityProviderReward: string;
|
|
29
|
+
distribution: {
|
|
30
|
+
operator: string;
|
|
31
|
+
protocol: string;
|
|
32
|
+
liquidityProvider: string;
|
|
33
|
+
};
|
|
34
|
+
}
|