@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,36 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SDK Configuration Interfaces
|
|
3
|
+
*/
|
|
4
|
+
import { ethers as ethers5 } 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
|
+
mockUsdcToken?: string;
|
|
32
|
+
mockUsdcOwner?: string;
|
|
33
|
+
mockUsdtToken?: string;
|
|
34
|
+
mockUsdtOwner?: string;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Base configuration shared by all SDK modes
|
|
38
|
+
*/
|
|
39
|
+
interface BaseSDKConfig {
|
|
40
|
+
litNetwork?: LitNetwork;
|
|
41
|
+
contractSigner?: ethers5.Wallet | ethers5.Signer;
|
|
42
|
+
ethRpcUrl?: string;
|
|
43
|
+
chainId?: number;
|
|
44
|
+
networkOverride?: {
|
|
45
|
+
chainId: number;
|
|
46
|
+
name: string;
|
|
47
|
+
};
|
|
48
|
+
provider?: ethers5.providers.Provider;
|
|
49
|
+
chain?: string;
|
|
50
|
+
litActionCid?: string;
|
|
51
|
+
litNodeConnectTimeoutMs?: number;
|
|
52
|
+
subgraphUrl?: string;
|
|
53
|
+
bitcoinRpcUrl?: string;
|
|
54
|
+
bitcoinProviders?: BitcoinProviderConfig[];
|
|
55
|
+
bitcoinConsensusMode?: "single" | "majority";
|
|
56
|
+
priceProviders?: PriceProviderConfig[];
|
|
57
|
+
/** PKP Ethereum address for signed price oracle (Lit jsParams pkpId); optional */
|
|
58
|
+
priceOraclePkpId?: string;
|
|
59
|
+
bitcoinFaucetUrl?: string;
|
|
60
|
+
contractAddresses?: ContractAddresses;
|
|
61
|
+
subgraphs?: {
|
|
62
|
+
tokenGvnrUrl?: string;
|
|
63
|
+
diamondHandsUrl?: string;
|
|
64
|
+
};
|
|
65
|
+
graphApiKey?: string;
|
|
66
|
+
graphOptions?: {
|
|
67
|
+
requestTimeoutMs?: number;
|
|
68
|
+
maxRetries?: number;
|
|
69
|
+
pageSize?: number;
|
|
70
|
+
};
|
|
71
|
+
mockUsdcTokenAddress?: string;
|
|
72
|
+
mockUsdcOwnerAddress?: string;
|
|
73
|
+
mockUsdcDecimals?: number;
|
|
74
|
+
mockUsdtTokenAddress?: string;
|
|
75
|
+
mockUsdtOwnerAddress?: string;
|
|
76
|
+
mockUsdtDecimals?: number;
|
|
77
|
+
ucdTokenAddress?: string;
|
|
78
|
+
sessionExpirationMinutes?: number;
|
|
79
|
+
transactionTimeoutMs?: number;
|
|
80
|
+
retryAttempts?: number;
|
|
81
|
+
debug?: boolean;
|
|
82
|
+
/**
|
|
83
|
+
* Optional: Override quantum timing buffer (in seconds)
|
|
84
|
+
* Default: Auto-detected based on network (10s for local, 50s for Sepolia, 35s for mainnet)
|
|
85
|
+
*
|
|
86
|
+
* Network-specific defaults:
|
|
87
|
+
* - Local networks (1337, 31337): 10s
|
|
88
|
+
* - Testnets (Sepolia 11155111, Goerli 5): 45-50s
|
|
89
|
+
* - Mainnet (1): 35s
|
|
90
|
+
*
|
|
91
|
+
* Only override if you have specific latency requirements.
|
|
92
|
+
* Recommended: Leave undefined to use automatic network detection.
|
|
93
|
+
*/
|
|
94
|
+
quantumBufferSeconds?: number;
|
|
95
|
+
/**
|
|
96
|
+
* @deprecated No longer read. On Sepolia (11155111), when `eth_estimateGas` fails for
|
|
97
|
+
* `mintUCD` but a static `eth_call` succeeds, the SDK always broadcasts with a fixed
|
|
98
|
+
* gas ceiling (EIP-1559). Retained for backward-compatible configs.
|
|
99
|
+
*/
|
|
100
|
+
skipGasEstimation?: boolean;
|
|
101
|
+
pkpServiceTimeoutMs?: number;
|
|
102
|
+
pkpServiceRetryCount?: number;
|
|
103
|
+
pkpServiceRetryDelayMs?: number;
|
|
104
|
+
balanceCacheOptions?: {
|
|
105
|
+
enabled?: boolean;
|
|
106
|
+
ttlMs?: number;
|
|
107
|
+
maxSize?: number;
|
|
108
|
+
};
|
|
109
|
+
addressCacheOptions?: {
|
|
110
|
+
enabled?: boolean;
|
|
111
|
+
ttlMs?: number;
|
|
112
|
+
maxSize?: number;
|
|
113
|
+
debug?: boolean;
|
|
114
|
+
};
|
|
115
|
+
concurrencyOptions?: {
|
|
116
|
+
enabled?: boolean;
|
|
117
|
+
concurrency?: number;
|
|
118
|
+
timeout?: number;
|
|
119
|
+
debug?: boolean;
|
|
120
|
+
};
|
|
121
|
+
loggingOptions?: {
|
|
122
|
+
enabled?: boolean;
|
|
123
|
+
level?: "debug" | "info" | "warn" | "error";
|
|
124
|
+
includeTimestamp?: boolean;
|
|
125
|
+
includeContext?: boolean;
|
|
126
|
+
maxContextKeys?: number;
|
|
127
|
+
verboseInProduction?: boolean;
|
|
128
|
+
};
|
|
129
|
+
validators?: {
|
|
130
|
+
/** Validator version for position creation (createPosition) - usually v1 for PKP security validation */
|
|
131
|
+
loanCreation: number;
|
|
132
|
+
/** Validator version for UCD minting (mintUCD) - usually v4 for business rules validation */
|
|
133
|
+
minting: number;
|
|
134
|
+
/** Validator version for partial payments (makePayment) - usually v1 for payment validation */
|
|
135
|
+
payment: number;
|
|
136
|
+
/** Validator version for loan extension/renewal (extendPosition) - usually v4 for extension validation */
|
|
137
|
+
extension: number;
|
|
138
|
+
};
|
|
139
|
+
defaultSelectedTermMonths?: number;
|
|
140
|
+
telegram?: {
|
|
141
|
+
chatId: string;
|
|
142
|
+
chatToken: string;
|
|
143
|
+
threadId?: number;
|
|
144
|
+
};
|
|
145
|
+
temperSignaturesTest?: boolean;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Service Mode Configuration
|
|
149
|
+
* Uses lit-ops-server for PKP operations
|
|
150
|
+
*/
|
|
151
|
+
export interface ServiceModeConfig extends BaseSDKConfig {
|
|
152
|
+
mode: "service";
|
|
153
|
+
serviceEndpoint: string;
|
|
154
|
+
serviceAuthToken?: string;
|
|
155
|
+
litOpsSigner?: never;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Standalone Mode Configuration
|
|
159
|
+
* User provides signer for direct LIT operations
|
|
160
|
+
*/
|
|
161
|
+
export interface StandaloneModeConfig extends BaseSDKConfig {
|
|
162
|
+
mode: "standalone";
|
|
163
|
+
litOpsSigner: ethers5.Wallet;
|
|
164
|
+
serviceEndpoint?: never;
|
|
165
|
+
serviceAuthToken?: never;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Main SDK Configuration - Discriminated Union
|
|
169
|
+
*
|
|
170
|
+
* Use ServiceModeConfig for production deployments with lit-ops-server
|
|
171
|
+
* Use StandaloneModeConfig for development/testing with direct LIT access
|
|
172
|
+
*
|
|
173
|
+
* @example Service Mode
|
|
174
|
+
* ```typescript
|
|
175
|
+
* const config: DiamondHandsSDKConfig = {
|
|
176
|
+
* mode: 'service',
|
|
177
|
+
* serviceEndpoint: 'https://lit-ops.example.com',
|
|
178
|
+
* contractSigner: wallet
|
|
179
|
+
* };
|
|
180
|
+
* ```
|
|
181
|
+
*
|
|
182
|
+
* @example Standalone Mode
|
|
183
|
+
* ```typescript
|
|
184
|
+
* const config: DiamondHandsSDKConfig = {
|
|
185
|
+
* mode: 'standalone',
|
|
186
|
+
* litOpsSigner: wallet,
|
|
187
|
+
* contractSigner: wallet
|
|
188
|
+
* };
|
|
189
|
+
* ```
|
|
190
|
+
*/
|
|
191
|
+
export type DiamondHandsSDKConfig = ServiceModeConfig | StandaloneModeConfig;
|
|
192
|
+
/**
|
|
193
|
+
* Type guard to check if config is ServiceModeConfig
|
|
194
|
+
*/
|
|
195
|
+
export declare function isServiceModeConfig(config: DiamondHandsSDKConfig): config is ServiceModeConfig;
|
|
196
|
+
/**
|
|
197
|
+
* Type guard to check if config is StandaloneModeConfig
|
|
198
|
+
*/
|
|
199
|
+
export declare function isStandaloneModeConfig(config: DiamondHandsSDKConfig): config is StandaloneModeConfig;
|
|
200
|
+
/**
|
|
201
|
+
* Validates that ServiceModeConfig has required fields
|
|
202
|
+
*/
|
|
203
|
+
export declare function validateServiceModeConfig(config: ServiceModeConfig): string | null;
|
|
204
|
+
/**
|
|
205
|
+
* Validates that StandaloneModeConfig has required fields
|
|
206
|
+
*/
|
|
207
|
+
export declare function validateStandaloneModeConfig(config: StandaloneModeConfig): string | null;
|
|
208
|
+
/**
|
|
209
|
+
* Validates SDK configuration based on mode
|
|
210
|
+
*/
|
|
211
|
+
export declare function validateSDKConfig(config: DiamondHandsSDKConfig): string | null;
|
|
212
|
+
/**
|
|
213
|
+
* SDK Initialization Options
|
|
214
|
+
*/
|
|
215
|
+
export interface SDKInitOptions {
|
|
216
|
+
overrideDefaults?: boolean;
|
|
217
|
+
customProvider?: ethers5.providers.Provider;
|
|
218
|
+
skipNetworkCheck?: boolean;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Network Configuration (basic)
|
|
222
|
+
*/
|
|
223
|
+
export interface BasicNetworkConfig {
|
|
224
|
+
name: string;
|
|
225
|
+
chainId: number;
|
|
226
|
+
rpcUrl: string;
|
|
227
|
+
blockExplorerUrl?: string;
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Bitcoin Provider Configuration
|
|
231
|
+
*/
|
|
232
|
+
export interface BitcoinProviderConfig {
|
|
233
|
+
url: string;
|
|
234
|
+
network: "mainnet" | "regtest";
|
|
235
|
+
auth?: {
|
|
236
|
+
username: string;
|
|
237
|
+
password: string;
|
|
238
|
+
};
|
|
239
|
+
name?: string;
|
|
240
|
+
priority?: number;
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Price Provider Configuration
|
|
244
|
+
*/
|
|
245
|
+
export interface PriceProviderConfig {
|
|
246
|
+
name: string;
|
|
247
|
+
apiKey?: string;
|
|
248
|
+
apiSecret?: string;
|
|
249
|
+
}
|
|
250
|
+
export {};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Smart Contract Interaction Interfaces
|
|
3
|
+
*/
|
|
4
|
+
import { ethers as ethers5 } from "ethers";
|
|
5
|
+
/**
|
|
6
|
+
* Contract Call Options Interface
|
|
7
|
+
*/
|
|
8
|
+
export interface ContractCallOptions {
|
|
9
|
+
gasLimit?: number;
|
|
10
|
+
gasPrice?: string;
|
|
11
|
+
value?: string;
|
|
12
|
+
timeout?: number;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Contract Transaction Result Interface
|
|
16
|
+
*/
|
|
17
|
+
export interface ContractTransactionResult {
|
|
18
|
+
success: boolean;
|
|
19
|
+
error?: string;
|
|
20
|
+
transactionHash?: string;
|
|
21
|
+
receipt?: ethers5.providers.TransactionReceipt;
|
|
22
|
+
gasUsed?: string;
|
|
23
|
+
events?: any[];
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Position Details Interface
|
|
27
|
+
*/
|
|
28
|
+
export interface PositionDetails {
|
|
29
|
+
positionId: string;
|
|
30
|
+
pkpId: string;
|
|
31
|
+
borrower: string;
|
|
32
|
+
ucdDebt: string;
|
|
33
|
+
createdAt: number;
|
|
34
|
+
lastUpdated: number;
|
|
35
|
+
collateralRatio: string;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Contract Query Options Interface
|
|
39
|
+
*/
|
|
40
|
+
export interface ContractQueryOptions {
|
|
41
|
+
blockTag?: number | "latest" | "pending";
|
|
42
|
+
contractAddress?: string;
|
|
43
|
+
abi?: string[];
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Event Filter Interface
|
|
47
|
+
*/
|
|
48
|
+
export interface EventFilter {
|
|
49
|
+
address?: string;
|
|
50
|
+
topics?: (string | string[])[];
|
|
51
|
+
fromBlock?: number | "latest";
|
|
52
|
+
toBlock?: number | "latest";
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Event Log Interface
|
|
56
|
+
*/
|
|
57
|
+
export interface EventLog {
|
|
58
|
+
address: string;
|
|
59
|
+
topics: string[];
|
|
60
|
+
data: string;
|
|
61
|
+
blockNumber: number;
|
|
62
|
+
transactionHash: string;
|
|
63
|
+
logIndex: number;
|
|
64
|
+
}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Smart Contract Type Interfaces
|
|
3
|
+
*
|
|
4
|
+
* These interfaces define the TypeScript types for smart contracts used in the SDK.
|
|
5
|
+
* They are independent definitions - NOT imported from the contracts package.
|
|
6
|
+
* Based on Solidity interfaces from contracts/src/interfaces/
|
|
7
|
+
*/
|
|
8
|
+
import { ethers as ethers5 } from "ethers";
|
|
9
|
+
import type { BigNumber } from "ethers";
|
|
10
|
+
/**
|
|
11
|
+
* Position Manager Contract Interface
|
|
12
|
+
* Based on contracts/src/interfaces/IPositionManager.sol
|
|
13
|
+
*/
|
|
14
|
+
export interface PositionManager extends ethers5.Contract {
|
|
15
|
+
createPosition(pkpId: string, validatorSignature: string, mainnetVaultAddress: string, regtestVaultAddress: string, selectedTermMonths: number | BigNumber, validatorVersion: number | BigNumber): Promise<ethers5.ContractTransaction>;
|
|
16
|
+
mintUCD(positionId: string, mintAmount: BigNumber, mintFee: BigNumber, newDebt: BigNumber, newCollateral: BigNumber, btcPrice: BigNumber, authorizedSpendsHash: string, ucdDebtHash: string, contractHash: string, quantumTimestamp: BigNumber, mintValidatorSignature: string): Promise<ethers5.ContractTransaction>;
|
|
17
|
+
liquidatePosition(positionId: string, btcPrice: BigNumber, quantumTimestamp: BigNumber, liquidationValidatorSignature: string): Promise<ethers5.ContractTransaction>;
|
|
18
|
+
getPosition(positionId: string): Promise<{
|
|
19
|
+
positionId: string;
|
|
20
|
+
pkpId: string;
|
|
21
|
+
ucdDebt: BigNumber;
|
|
22
|
+
borrower: string;
|
|
23
|
+
createdAt: number;
|
|
24
|
+
lastUpdated: number;
|
|
25
|
+
selectedTerm: number;
|
|
26
|
+
expiryAt: number;
|
|
27
|
+
status: number;
|
|
28
|
+
}>;
|
|
29
|
+
pkpValidationRegistry(): Promise<string>;
|
|
30
|
+
updateBalance(positionId: string, newBtcBalance: string | number | BigNumber, btcPrice: string | number | BigNumber, quantumTimestamp: string | number | BigNumber, signature: string): Promise<ethers5.ContractTransaction>;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Loan Operations Manager Contract Interface
|
|
34
|
+
* Based on contracts/src/interfaces/ILoanOperationsManager.sol
|
|
35
|
+
*/
|
|
36
|
+
export interface ILoanOperationsManager extends ethers5.Contract {
|
|
37
|
+
mintUCD(positionId: string, mintAmount: BigNumber, mintFee: BigNumber, newDebt: BigNumber, newCollateral: BigNumber, btcPrice: BigNumber, authorizedSpendsHash: string, ucdDebtHash: string, quantumTimestamp: BigNumber): Promise<ethers5.ContractTransaction>;
|
|
38
|
+
processPayment(positionId: string, paymentAmount: BigNumber, quantumTimestamp: BigNumber, btcPrice: BigNumber): Promise<ethers5.ContractTransaction>;
|
|
39
|
+
updatePosition(positionId: string, newDebt: BigNumber, quantumTimestamp: BigNumber, btcPrice: BigNumber, updateValidatorSignature: string): Promise<ethers5.ContractTransaction>;
|
|
40
|
+
transferOriginationFee(recipient: string, amount: BigNumber): Promise<ethers5.ContractTransaction>;
|
|
41
|
+
mintExtensionFee(amount: BigNumber): Promise<ethers5.ContractTransaction>;
|
|
42
|
+
getOriginationFeeBalance(): Promise<BigNumber>;
|
|
43
|
+
authorizeBTCSpend(positionId: string, txid: string, vout: number, satoshis: BigNumber, targetAddress: string, targetAmount: BigNumber, litSignature: string): Promise<ethers5.ContractTransaction>;
|
|
44
|
+
liquidationThreshold(): Promise<BigNumber>;
|
|
45
|
+
minimumLoanValueWei(): Promise<BigNumber>;
|
|
46
|
+
ucdToken(): Promise<string>;
|
|
47
|
+
getUcdController(): Promise<string>;
|
|
48
|
+
getPKPActualCollateral(pkpId: string): Promise<BigNumber>;
|
|
49
|
+
isPriceFeedStale(): Promise<boolean>;
|
|
50
|
+
calculateCollateralRatio(positionId: string, btcPrice: BigNumber): Promise<BigNumber>;
|
|
51
|
+
getTotalAuthorizedSats(positionId: string): Promise<BigNumber>;
|
|
52
|
+
extendPosition(positionId: string, newTermMonths: BigNumber, extensionFee: BigNumber, quantumTimestamp: BigNumber, btcPrice: BigNumber, extendValidatorSignature: string): Promise<ethers5.ContractTransaction>;
|
|
53
|
+
withdrawBTC(positionId: string, btcTxid: string, btcVout: number, satoshis: BigNumber, destinationAddress: string, quantumTimestamp: BigNumber, btcPrice: BigNumber, btcWithdrawalSignature: string): Promise<ethers5.ContractTransaction>;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* UCD Controller Contract Interface
|
|
57
|
+
* Based on contracts/src/interfaces/IUCDController.sol
|
|
58
|
+
*/
|
|
59
|
+
export interface IUCDController extends ethers5.Contract {
|
|
60
|
+
mintFromLoanOps(to: string, amount: BigNumber, positionId: string, debtAfterMint: BigNumber): Promise<ethers5.ContractTransaction>;
|
|
61
|
+
mintFromPsm(to: string, amount: BigNumber, stablecoin: string, amountIn: BigNumber): Promise<ethers5.ContractTransaction>;
|
|
62
|
+
burnTokens(from: string, amount: BigNumber): Promise<ethers5.ContractTransaction>;
|
|
63
|
+
setAdminModule(_adminModule: string): Promise<ethers5.ContractTransaction>;
|
|
64
|
+
setAuthorizedMinter(minter: string, authorized: boolean): Promise<ethers5.ContractTransaction>;
|
|
65
|
+
setAuthorizedBurner(burner: string, authorized: boolean): Promise<ethers5.ContractTransaction>;
|
|
66
|
+
setMaxSupply(newMaxSupply: BigNumber): Promise<ethers5.ContractTransaction>;
|
|
67
|
+
setDailyMintLimit(newLimit: BigNumber): Promise<ethers5.ContractTransaction>;
|
|
68
|
+
setDailyBurnLimit(newLimit: BigNumber): Promise<ethers5.ContractTransaction>;
|
|
69
|
+
setUCDToken(newToken: string): Promise<ethers5.ContractTransaction>;
|
|
70
|
+
getCurrentSupply(): Promise<BigNumber>;
|
|
71
|
+
getRemainingMintCapacity(): Promise<BigNumber>;
|
|
72
|
+
getRemainingBurnCapacity(): Promise<BigNumber>;
|
|
73
|
+
getRemainingPsmMintCapacity(): Promise<BigNumber>;
|
|
74
|
+
isAuthorizedMinter(account: string): Promise<boolean>;
|
|
75
|
+
isAuthorizedBurner(account: string): Promise<boolean>;
|
|
76
|
+
authorizedMinters(account: string): Promise<boolean>;
|
|
77
|
+
authorizedBurners(account: string): Promise<boolean>;
|
|
78
|
+
burnedPerAddress(account: string): Promise<BigNumber>;
|
|
79
|
+
totalMinted(): Promise<BigNumber>;
|
|
80
|
+
totalBurned(): Promise<BigNumber>;
|
|
81
|
+
maxSupply(): Promise<BigNumber>;
|
|
82
|
+
dailyMintLimit(): Promise<BigNumber>;
|
|
83
|
+
dailyBurnLimit(): Promise<BigNumber>;
|
|
84
|
+
lastMintReset(): Promise<BigNumber>;
|
|
85
|
+
lastBurnReset(): Promise<BigNumber>;
|
|
86
|
+
dailyMinted(): Promise<BigNumber>;
|
|
87
|
+
dailyBurned(): Promise<BigNumber>;
|
|
88
|
+
dailyPsmMinted(): Promise<BigNumber>;
|
|
89
|
+
psmDailyMintLimit(): Promise<BigNumber>;
|
|
90
|
+
circuitBreaker(): Promise<string>;
|
|
91
|
+
ucdToken(): Promise<string>;
|
|
92
|
+
adminModule(): Promise<string>;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Price Feed Consumer Contract Interface
|
|
96
|
+
*/
|
|
97
|
+
export interface IPriceFeedConsumer extends ethers5.Contract {
|
|
98
|
+
updatePrice(): Promise<ethers5.ContractTransaction>;
|
|
99
|
+
getCurrentPrice(): Promise<BigNumber>;
|
|
100
|
+
getPriceAge(): Promise<BigNumber>;
|
|
101
|
+
isPriceStale(): Promise<boolean>;
|
|
102
|
+
validatePriceFeed(): Promise<boolean>;
|
|
103
|
+
getLatestBTCPrice(): Promise<BigNumber>;
|
|
104
|
+
decimals(): Promise<number>;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Term Manager Contract Interface
|
|
108
|
+
* Based on contracts/src/interfaces/ITermManager.sol
|
|
109
|
+
*/
|
|
110
|
+
export interface ITermManager extends ethers5.Contract {
|
|
111
|
+
addTerm(termMonths: BigNumber, originationFee: BigNumber, extensionFee: BigNumber): Promise<ethers5.ContractTransaction>;
|
|
112
|
+
removeTerm(termMonths: BigNumber): Promise<ethers5.ContractTransaction>;
|
|
113
|
+
updateTermFees(termMonths: BigNumber, originationFee: BigNumber, extensionFee: BigNumber): Promise<ethers5.ContractTransaction>;
|
|
114
|
+
getTermFees(termMonths: BigNumber): Promise<{
|
|
115
|
+
originationFee: BigNumber;
|
|
116
|
+
extensionFee: BigNumber;
|
|
117
|
+
}>;
|
|
118
|
+
isValidTerm(termMonths: BigNumber): Promise<boolean>;
|
|
119
|
+
getValidTermsWithFees(): Promise<{
|
|
120
|
+
terms: BigNumber[];
|
|
121
|
+
originationFees: BigNumber[];
|
|
122
|
+
extensionFees: BigNumber[];
|
|
123
|
+
}>;
|
|
124
|
+
getTermDataById(termId: BigNumber): Promise<{
|
|
125
|
+
termMonths: BigNumber;
|
|
126
|
+
originationFee: BigNumber;
|
|
127
|
+
extensionFee: BigNumber;
|
|
128
|
+
isActive: boolean;
|
|
129
|
+
}>;
|
|
130
|
+
getAllTerms(): Promise<BigNumber[]>;
|
|
131
|
+
updateDependencies(newCore: string, newUcdController: string): Promise<ethers5.ContractTransaction>;
|
|
132
|
+
supportsInterface(interfaceId: string): Promise<boolean>;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Circuit Breaker Module Contract Interface
|
|
136
|
+
* Based on contracts/src/interfaces/ICircuitBreakerModule.sol
|
|
137
|
+
*/
|
|
138
|
+
export interface CircuitBreakerModule extends ethers5.Contract {
|
|
139
|
+
circuitBreakerCheck(ucdAmount: BigNumber, btcAmount: BigNumber): Promise<ethers5.ContractTransaction>;
|
|
140
|
+
proposeLimitUpdate(newMaxLoanValue: BigNumber, newMaxBtcPerPosition: BigNumber, newDailyLimit: BigNumber): Promise<ethers5.ContractTransaction>;
|
|
141
|
+
signLimitUpdate(proposalHash: string): Promise<ethers5.ContractTransaction>;
|
|
142
|
+
executeLimitUpdate(proposalHash: string, newMaxLoanValue: BigNumber, newMaxBtcPerPosition: BigNumber, newDailyLimit: BigNumber): Promise<ethers5.ContractTransaction>;
|
|
143
|
+
activateCircuitBreaker(): Promise<ethers5.ContractTransaction>;
|
|
144
|
+
deactivateCircuitBreaker(): Promise<ethers5.ContractTransaction>;
|
|
145
|
+
signCircuitBreakerDeactivation(): Promise<ethers5.ContractTransaction>;
|
|
146
|
+
maxSingleLoanValue(): Promise<BigNumber>;
|
|
147
|
+
maxBtcPerPosition(): Promise<BigNumber>;
|
|
148
|
+
dailyVolumeLimit(): Promise<BigNumber>;
|
|
149
|
+
circuitBreakerActive(): Promise<boolean>;
|
|
150
|
+
circuitBreakerActivatedAt(): Promise<BigNumber>;
|
|
151
|
+
dailyUcdVolume(day: BigNumber): Promise<BigNumber>;
|
|
152
|
+
dailyBtcVolume(day: BigNumber): Promise<BigNumber>;
|
|
153
|
+
supportsInterface(interfaceId: string): Promise<boolean>;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Liquidation Manager Contract Interface
|
|
157
|
+
* Based on contracts/src/interfaces/ILiquidationManager.sol
|
|
158
|
+
*/
|
|
159
|
+
export interface ILiquidationManager extends ethers5.Contract {
|
|
160
|
+
liquidatePosition(positionId: string, btcPrice: BigNumber, quantumTimestamp: BigNumber): Promise<ethers5.ContractTransaction>;
|
|
161
|
+
commitLiquidation(positionId: string, quantumTimestamp: BigNumber, btcPrice: BigNumber): Promise<ethers5.ContractTransaction>;
|
|
162
|
+
revealAndLiquidate(positionId: string, quantumTimestamp: BigNumber, btcPrice: BigNumber, liquidationValidatorSignature: string, deadline: BigNumber): Promise<ethers5.ContractTransaction>;
|
|
163
|
+
isLiquidatable(positionId: string, btcPrice: BigNumber, quantumTimestamp: BigNumber, liquidationValidatorSignature: string): Promise<boolean>;
|
|
164
|
+
supportsInterface(interfaceId: string): Promise<boolean>;
|
|
165
|
+
}
|
|
@@ -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;
|