@gvnrdao/dh-sdk 0.0.288 → 0.0.289
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/833.browser.js +1 -1
- package/browser/dist/browser.js +1 -1
- package/browser/dist/browser.js.LICENSE.txt +5 -10
- package/dist/constants/chunks/contract-abis.d.ts +20 -0
- package/dist/constants/chunks/deployment-addresses.d.ts +79 -0
- package/dist/constants/chunks/encrypted-provider-params.d.ts +21 -0
- package/dist/constants/chunks/environment.browser.d.ts +44 -0
- package/dist/constants/chunks/environment.d.ts +57 -0
- package/dist/constants/chunks/network-configs.d.ts +72 -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/contracts/typechain-contracts/common.d.ts +50 -0
- package/dist/contracts/typechain-contracts/factories/src/psm/SimplePSMV2__factory.d.ts +1996 -0
- package/dist/contracts/typechain-contracts/src/psm/SimplePSMV2.d.ts +1198 -0
- package/dist/deployments.js +21 -45
- package/dist/deployments.mjs +21 -45
- package/dist/graphs/client.d.ts +22 -0
- package/dist/graphs/diamond-hands.d.ts +259 -0
- package/dist/index.d.ts +56 -0
- package/dist/index.js +1123 -628
- package/dist/index.mjs +1123 -628
- package/dist/interfaces/chunks/btc.i.d.ts +36 -0
- package/dist/interfaces/chunks/config.i.d.ts +270 -0
- package/dist/interfaces/chunks/contract-interactions.i.d.ts +64 -0
- package/dist/interfaces/chunks/contract-types.i.d.ts +171 -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 +331 -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 +254 -0
- package/dist/modules/cache/cache-manager.module.d.ts +259 -0
- package/dist/modules/contract/contract-manager.module.d.ts +152 -0
- package/dist/modules/diamond-hands-sdk.d.ts +969 -0
- package/dist/modules/loan/loan-creator.module.d.ts +132 -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 +136 -0
- package/dist/modules/withdrawal-address/withdrawal-address.module.d.ts +78 -0
- package/dist/protocol/protocol-pause.d.ts +19 -0
- package/dist/server.d.ts +17 -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 +261 -0
- package/dist/types/graph-dtos.d.ts +228 -0
- package/dist/types/loanStatus.d.ts +10 -0
- package/dist/types/protocol-event-types.d.ts +99 -0
- package/dist/types/result.d.ts +120 -0
- package/dist/utils/address-conversion.utils.d.ts +51 -0
- package/dist/utils/bitcoin-address-cache.utils.d.ts +87 -0
- package/dist/utils/bitcoin-provider.utils.d.ts +84 -0
- package/dist/utils/btc-withdrawal-message.d.ts +60 -0
- package/dist/utils/chunks/bitcoin-utils.d.ts +85 -0
- package/dist/utils/chunks/eip1559-broadcast.utils.d.ts +33 -0
- package/dist/utils/eip712-login.d.ts +34 -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 +248 -0
- package/dist/utils/position-delegate.utils.d.ts +41 -0
- package/dist/utils/quantum-timing.d.ts +75 -0
- package/dist/utils/server-session.d.ts +50 -0
- package/dist/utils/service-endpoint-policy.d.ts +16 -0
- package/dist/utils/signature-tempering.utils.d.ts +34 -0
- package/dist/utils/telegram-messaging.utils.d.ts +188 -0
- package/package.json +1 -1
- package/browser/dist/397.browser.js +0 -2
- package/browser/dist/397.browser.js.LICENSE.txt +0 -1
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed responses for critical Diamond Hands LIT Actions.
|
|
3
|
+
*
|
|
4
|
+
* These mirror the JSON payloads passed to `Lit.Actions.setResponse(...)`
|
|
5
|
+
* in the lit-actions package and are intended to be used as the `TData`
|
|
6
|
+
* parameter on `LitActionResult<TData>`.
|
|
7
|
+
*/
|
|
8
|
+
import type { PositionId } from "../../types/branded/ids";
|
|
9
|
+
/**
|
|
10
|
+
* Base shape for approval-style validator responses.
|
|
11
|
+
*/
|
|
12
|
+
export interface BaseValidatorResponse {
|
|
13
|
+
approved: boolean;
|
|
14
|
+
positionId?: PositionId | string;
|
|
15
|
+
reason?: string;
|
|
16
|
+
failedStep?: string;
|
|
17
|
+
timestamp: number | string;
|
|
18
|
+
/**
|
|
19
|
+
* Optional low-level execution error from lit-ops / LIT runtime.
|
|
20
|
+
*/
|
|
21
|
+
error?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Some flows attach the raw signature JSON here (service wrappers).
|
|
24
|
+
*/
|
|
25
|
+
signature?: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* UCD Mint Validator response (ucdMintValidator).
|
|
29
|
+
* Source: lit-actions/src/ucd-mint-validator.ts
|
|
30
|
+
*/
|
|
31
|
+
export interface UcdMintValidatorResponse extends BaseValidatorResponse {
|
|
32
|
+
approved: true;
|
|
33
|
+
mintAmount: string;
|
|
34
|
+
mintFee: string;
|
|
35
|
+
newDebt: string;
|
|
36
|
+
newCollateral: string;
|
|
37
|
+
newCollateralRatioBps: number;
|
|
38
|
+
btcPrice: string;
|
|
39
|
+
authorizedSpendsHash: string;
|
|
40
|
+
ucdDebtHash: string;
|
|
41
|
+
contractBundleHash: string;
|
|
42
|
+
signature: string;
|
|
43
|
+
validatorPkp: string;
|
|
44
|
+
/**
|
|
45
|
+
* Optional: Exact parameter values used for signing.
|
|
46
|
+
* If present, SDK should use these values instead of response values
|
|
47
|
+
* to ensure contract receives identical parameters that were signed.
|
|
48
|
+
*/
|
|
49
|
+
signingParams?: {
|
|
50
|
+
positionId: string;
|
|
51
|
+
actionHash: string;
|
|
52
|
+
authorizedSpendsHash: string;
|
|
53
|
+
ucdDebtHash: string;
|
|
54
|
+
contractBundleHash: string;
|
|
55
|
+
btcPrice: string;
|
|
56
|
+
mintAmount: string;
|
|
57
|
+
mintFee: string;
|
|
58
|
+
newCollateral: string;
|
|
59
|
+
newDebt: string;
|
|
60
|
+
timestamp: string;
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
export interface UcdMintValidatorErrorResponse extends BaseValidatorResponse {
|
|
64
|
+
approved: false;
|
|
65
|
+
}
|
|
66
|
+
export type UcdMintValidatorResult = UcdMintValidatorResponse | UcdMintValidatorErrorResponse;
|
|
67
|
+
/**
|
|
68
|
+
* BTC Withdrawal Validator response (btcWithdrawal).
|
|
69
|
+
* Source: lit-actions/src/btc-withdrawal.ts
|
|
70
|
+
*/
|
|
71
|
+
export interface BtcWithdrawalValidatorResponse extends BaseValidatorResponse {
|
|
72
|
+
approved: true;
|
|
73
|
+
actionHash: string;
|
|
74
|
+
authorizedSpendsHash: string;
|
|
75
|
+
ucdDebtHash: string;
|
|
76
|
+
totalDeduction: string;
|
|
77
|
+
remainingCollateral: string;
|
|
78
|
+
newCollateralRatioBps?: number;
|
|
79
|
+
destinationAddress: string;
|
|
80
|
+
signature: string;
|
|
81
|
+
btcPrice: string;
|
|
82
|
+
/**
|
|
83
|
+
* Optional UTXO fields used by enhanced BTC withdrawal flow.
|
|
84
|
+
* These are populated by the LIT Action when BIP-143 validation is enabled.
|
|
85
|
+
*/
|
|
86
|
+
utxoTxid?: string;
|
|
87
|
+
utxoVout?: number;
|
|
88
|
+
}
|
|
89
|
+
export interface BtcWithdrawalValidatorErrorResponse extends BaseValidatorResponse {
|
|
90
|
+
approved: false;
|
|
91
|
+
}
|
|
92
|
+
export type BtcWithdrawalValidatorResult = BtcWithdrawalValidatorResponse | BtcWithdrawalValidatorErrorResponse;
|
|
93
|
+
/**
|
|
94
|
+
* Liquidation Validator response (liquidationValidator).
|
|
95
|
+
* Source: lit-actions/src/liquidation-validator.ts
|
|
96
|
+
*/
|
|
97
|
+
export interface LiquidationValidatorResponse extends BaseValidatorResponse {
|
|
98
|
+
approved: true;
|
|
99
|
+
btcPrice: string;
|
|
100
|
+
btcAmountSats: string;
|
|
101
|
+
signature: string;
|
|
102
|
+
signatureBonus: string;
|
|
103
|
+
validatorPkp: string;
|
|
104
|
+
}
|
|
105
|
+
export interface LiquidationValidatorErrorResponse extends BaseValidatorResponse {
|
|
106
|
+
approved: false;
|
|
107
|
+
}
|
|
108
|
+
export type LiquidationValidatorResult = LiquidationValidatorResponse | LiquidationValidatorErrorResponse;
|
|
109
|
+
/**
|
|
110
|
+
* Extend Position Validator response (extendPositionValidator).
|
|
111
|
+
* Source: lit-actions/src/extend-position-validator.ts
|
|
112
|
+
*/
|
|
113
|
+
export interface ExtendPositionValidatorResponse extends BaseValidatorResponse {
|
|
114
|
+
approved: true;
|
|
115
|
+
selectedTerm: number;
|
|
116
|
+
btcPrice: string;
|
|
117
|
+
availableBTCBalance: string;
|
|
118
|
+
extensionFee: string;
|
|
119
|
+
newTotalDebt: string;
|
|
120
|
+
newCollateralRatioBps: string;
|
|
121
|
+
signature: string;
|
|
122
|
+
timestamp: number;
|
|
123
|
+
quantumTimestamp: number;
|
|
124
|
+
validatorPkp: string;
|
|
125
|
+
}
|
|
126
|
+
export interface ExtendPositionValidatorErrorResponse extends BaseValidatorResponse {
|
|
127
|
+
approved: false;
|
|
128
|
+
}
|
|
129
|
+
export type ExtendPositionValidatorResult = ExtendPositionValidatorResponse | ExtendPositionValidatorErrorResponse;
|
|
130
|
+
/**
|
|
131
|
+
* Process Payment Validator response (processPaymentValidator).
|
|
132
|
+
* Source: lit-actions/src/process-payment-validator.ts
|
|
133
|
+
*/
|
|
134
|
+
export interface ProcessPaymentValidatorResponse extends BaseValidatorResponse {
|
|
135
|
+
approved: true;
|
|
136
|
+
paymentAmount: string;
|
|
137
|
+
btcPrice: string;
|
|
138
|
+
btcAmountSats: string;
|
|
139
|
+
signature: string;
|
|
140
|
+
timestamp: number;
|
|
141
|
+
validatorPkp: string;
|
|
142
|
+
}
|
|
143
|
+
export interface ProcessPaymentValidatorErrorResponse extends BaseValidatorResponse {
|
|
144
|
+
approved: false;
|
|
145
|
+
}
|
|
146
|
+
export type ProcessPaymentValidatorResult = ProcessPaymentValidatorResponse | ProcessPaymentValidatorErrorResponse;
|
|
147
|
+
/**
|
|
148
|
+
* Loan vault BTC balance / deposit validator response (loanVaultBtcBalance).
|
|
149
|
+
* Source: lit-actions/src/loan-vault-btc-balance.ts
|
|
150
|
+
*/
|
|
151
|
+
export interface LoanVaultBtcBalanceValidatorResponse {
|
|
152
|
+
vaultAddress: string;
|
|
153
|
+
vaultBalance: string;
|
|
154
|
+
positionId: PositionId | string;
|
|
155
|
+
btcPrice: string;
|
|
156
|
+
signature: string;
|
|
157
|
+
timestamp: number;
|
|
158
|
+
validatorPkp: string;
|
|
159
|
+
}
|
|
160
|
+
export interface LoanVaultBtcBalanceValidatorErrorResponse {
|
|
161
|
+
error: string;
|
|
162
|
+
positionId: PositionId | string | null;
|
|
163
|
+
timestamp: number;
|
|
164
|
+
}
|
|
165
|
+
export type LoanVaultBtcBalanceValidatorResult = LoanVaultBtcBalanceValidatorResponse | LoanVaultBtcBalanceValidatorErrorResponse;
|
|
@@ -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,331 @@
|
|
|
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
|
+
testBtcPrice?: number;
|
|
173
|
+
debugOverrides?: {
|
|
174
|
+
useStubbedBtcData?: boolean;
|
|
175
|
+
stubbedBtcPriceUsd?: string;
|
|
176
|
+
stubbedAvailableBtcSats?: string;
|
|
177
|
+
stubbedAuthorizedSpendsHash?: string;
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* UCD Mint Result Interface
|
|
182
|
+
*/
|
|
183
|
+
export interface UCDMintResult {
|
|
184
|
+
success: boolean;
|
|
185
|
+
transactionHash?: string;
|
|
186
|
+
blockNumber?: number;
|
|
187
|
+
blockHash?: string;
|
|
188
|
+
gasUsed?: string;
|
|
189
|
+
effectiveGasPrice?: string;
|
|
190
|
+
positionId?: string;
|
|
191
|
+
amountMinted?: string;
|
|
192
|
+
amountMintedUCD?: number;
|
|
193
|
+
error?: string;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Renew Position Result Interface
|
|
197
|
+
*/
|
|
198
|
+
export interface RenewPositionResult {
|
|
199
|
+
success: boolean;
|
|
200
|
+
transactionHash?: string;
|
|
201
|
+
blockNumber?: number;
|
|
202
|
+
blockHash?: string;
|
|
203
|
+
gasUsed?: string;
|
|
204
|
+
effectiveGasPrice?: string;
|
|
205
|
+
positionId?: string;
|
|
206
|
+
extensionTerm?: number;
|
|
207
|
+
newExpiryAt?: number;
|
|
208
|
+
error?: string;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Renew Position Request Interface
|
|
212
|
+
*/
|
|
213
|
+
export interface RenewPositionRequest {
|
|
214
|
+
positionId: string;
|
|
215
|
+
selectedTerm: number;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* BTC Withdrawal Result Interface
|
|
219
|
+
*/
|
|
220
|
+
export interface BTCWithdrawalResult {
|
|
221
|
+
success: boolean;
|
|
222
|
+
evmTransactionHash?: string;
|
|
223
|
+
blockNumber?: number;
|
|
224
|
+
blockHash?: string;
|
|
225
|
+
gasUsed?: string;
|
|
226
|
+
effectiveGasPrice?: string;
|
|
227
|
+
positionId?: string;
|
|
228
|
+
withdrawalAddress?: string;
|
|
229
|
+
networkFee?: number;
|
|
230
|
+
amountWithdrawn?: string;
|
|
231
|
+
bitcoinTransactionHash?: string;
|
|
232
|
+
utxoTxid?: string;
|
|
233
|
+
utxoVout?: number;
|
|
234
|
+
/** Full satoshi value of the authorized UTXO; needed by Phase 2 broadcast. */
|
|
235
|
+
utxoSatoshis?: string;
|
|
236
|
+
error?: string;
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Liquidation Request Interface
|
|
240
|
+
*/
|
|
241
|
+
export interface LiquidationRequest {
|
|
242
|
+
positionId: string;
|
|
243
|
+
forceContractCall?: boolean;
|
|
244
|
+
/**
|
|
245
|
+
* When true, the SDK will not send a UCD `approve(UCDController, …)` transaction.
|
|
246
|
+
* Use when the liquidator wallet has already approved UCDController (e.g. multisig flow).
|
|
247
|
+
* If allowance is insufficient, liquidation returns an error instead of approving.
|
|
248
|
+
*/
|
|
249
|
+
skipUcdApproval?: boolean;
|
|
250
|
+
rpcUrl?: 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
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Confirm Balance Result Interface
|
|
278
|
+
*/
|
|
279
|
+
export interface ConfirmBalanceResult {
|
|
280
|
+
success: boolean;
|
|
281
|
+
transactionHash?: string;
|
|
282
|
+
blockNumber?: number;
|
|
283
|
+
blockHash?: string;
|
|
284
|
+
gasUsed?: string;
|
|
285
|
+
effectiveGasPrice?: string;
|
|
286
|
+
positionId?: string;
|
|
287
|
+
confirmedBalance?: string;
|
|
288
|
+
btcPrice?: string;
|
|
289
|
+
newStatus?: LoanStatus;
|
|
290
|
+
error?: string;
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Confirm Balance Request Interface
|
|
294
|
+
*/
|
|
295
|
+
export interface ConfirmBalanceRequest {
|
|
296
|
+
positionId: string;
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Partial Payment Result Interface
|
|
300
|
+
*/
|
|
301
|
+
export interface PartialPaymentResult {
|
|
302
|
+
success: boolean;
|
|
303
|
+
transactionHash?: string;
|
|
304
|
+
blockNumber?: number;
|
|
305
|
+
blockHash?: string;
|
|
306
|
+
gasUsed?: string;
|
|
307
|
+
effectiveGasPrice?: string;
|
|
308
|
+
positionId?: string;
|
|
309
|
+
paymentAmountUCD?: number;
|
|
310
|
+
error?: string;
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Term with Fees Interface
|
|
314
|
+
*/
|
|
315
|
+
export interface TermWithFees {
|
|
316
|
+
termMonths: number;
|
|
317
|
+
originationFeeBps: number;
|
|
318
|
+
extensionFeeBps: number;
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Terms with Fees Result Interface
|
|
322
|
+
*/
|
|
323
|
+
export interface TermsWithFeesResult {
|
|
324
|
+
terms: TermWithFees[];
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* Configuration for Loan Operations Manager
|
|
328
|
+
*/
|
|
329
|
+
export interface LoanManagerConfig {
|
|
330
|
+
debug?: boolean;
|
|
331
|
+
}
|
|
@@ -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
|
+
}
|