@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.
Files changed (76) hide show
  1. package/browser/dist/833.browser.js +1 -1
  2. package/browser/dist/browser.js +1 -1
  3. package/browser/dist/browser.js.LICENSE.txt +5 -10
  4. package/dist/constants/chunks/contract-abis.d.ts +20 -0
  5. package/dist/constants/chunks/deployment-addresses.d.ts +79 -0
  6. package/dist/constants/chunks/encrypted-provider-params.d.ts +21 -0
  7. package/dist/constants/chunks/environment.browser.d.ts +44 -0
  8. package/dist/constants/chunks/environment.d.ts +57 -0
  9. package/dist/constants/chunks/network-configs.d.ts +72 -0
  10. package/dist/constants/chunks/sdk-config.d.ts +33 -0
  11. package/dist/constants/chunks/sdk-limits.d.ts +66 -0
  12. package/dist/constants/index.d.ts +15 -0
  13. package/dist/contracts/typechain-contracts/common.d.ts +50 -0
  14. package/dist/contracts/typechain-contracts/factories/src/psm/SimplePSMV2__factory.d.ts +1996 -0
  15. package/dist/contracts/typechain-contracts/src/psm/SimplePSMV2.d.ts +1198 -0
  16. package/dist/deployments.js +21 -45
  17. package/dist/deployments.mjs +21 -45
  18. package/dist/graphs/client.d.ts +22 -0
  19. package/dist/graphs/diamond-hands.d.ts +259 -0
  20. package/dist/index.d.ts +56 -0
  21. package/dist/index.js +1123 -628
  22. package/dist/index.mjs +1123 -628
  23. package/dist/interfaces/chunks/btc.i.d.ts +36 -0
  24. package/dist/interfaces/chunks/config.i.d.ts +270 -0
  25. package/dist/interfaces/chunks/contract-interactions.i.d.ts +64 -0
  26. package/dist/interfaces/chunks/contract-types.i.d.ts +171 -0
  27. package/dist/interfaces/chunks/lit-actions-results.i.d.ts +165 -0
  28. package/dist/interfaces/chunks/lit-actions.i.d.ts +98 -0
  29. package/dist/interfaces/chunks/loan-operations.i.d.ts +331 -0
  30. package/dist/interfaces/chunks/pkp-integration.i.d.ts +87 -0
  31. package/dist/interfaces/chunks/position-query.i.d.ts +76 -0
  32. package/dist/interfaces/chunks/requests.i.d.ts +55 -0
  33. package/dist/interfaces/chunks/ucd-minting.i.d.ts +34 -0
  34. package/dist/interfaces/chunks/utility.i.d.ts +64 -0
  35. package/dist/interfaces/index.d.ts +17 -0
  36. package/dist/modules/bitcoin/bitcoin-operations.module.d.ts +254 -0
  37. package/dist/modules/cache/cache-manager.module.d.ts +259 -0
  38. package/dist/modules/contract/contract-manager.module.d.ts +152 -0
  39. package/dist/modules/diamond-hands-sdk.d.ts +969 -0
  40. package/dist/modules/loan/loan-creator.module.d.ts +132 -0
  41. package/dist/modules/loan/loan-query.module.d.ts +204 -0
  42. package/dist/modules/mock/mock-token-manager.module.d.ts +83 -0
  43. package/dist/modules/pkp/pkp-manager.module.d.ts +136 -0
  44. package/dist/modules/withdrawal-address/withdrawal-address.module.d.ts +78 -0
  45. package/dist/protocol/protocol-pause.d.ts +19 -0
  46. package/dist/server.d.ts +17 -0
  47. package/dist/types/authorization-params.d.ts +160 -0
  48. package/dist/types/branded/domain-values.d.ts +138 -0
  49. package/dist/types/branded/ids.d.ts +23 -0
  50. package/dist/types/event-types.d.ts +261 -0
  51. package/dist/types/graph-dtos.d.ts +228 -0
  52. package/dist/types/loanStatus.d.ts +10 -0
  53. package/dist/types/protocol-event-types.d.ts +99 -0
  54. package/dist/types/result.d.ts +120 -0
  55. package/dist/utils/address-conversion.utils.d.ts +51 -0
  56. package/dist/utils/bitcoin-address-cache.utils.d.ts +87 -0
  57. package/dist/utils/bitcoin-provider.utils.d.ts +84 -0
  58. package/dist/utils/btc-withdrawal-message.d.ts +60 -0
  59. package/dist/utils/chunks/bitcoin-utils.d.ts +85 -0
  60. package/dist/utils/chunks/eip1559-broadcast.utils.d.ts +33 -0
  61. package/dist/utils/eip712-login.d.ts +34 -0
  62. package/dist/utils/error-handler.d.ts +106 -0
  63. package/dist/utils/ethers-interop.utils.d.ts +146 -0
  64. package/dist/utils/extend-authorization.utils.d.ts +61 -0
  65. package/dist/utils/lit-signature.utils.d.ts +6 -0
  66. package/dist/utils/logger.utils.d.ts +142 -0
  67. package/dist/utils/mint-authorization.utils.d.ts +248 -0
  68. package/dist/utils/position-delegate.utils.d.ts +41 -0
  69. package/dist/utils/quantum-timing.d.ts +75 -0
  70. package/dist/utils/server-session.d.ts +50 -0
  71. package/dist/utils/service-endpoint-policy.d.ts +16 -0
  72. package/dist/utils/signature-tempering.utils.d.ts +34 -0
  73. package/dist/utils/telegram-messaging.utils.d.ts +188 -0
  74. package/package.json +1 -1
  75. package/browser/dist/397.browser.js +0 -2
  76. package/browser/dist/397.browser.js.LICENSE.txt +0 -1
@@ -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,270 @@
1
+ /**
2
+ * SDK Configuration Interfaces
3
+ */
4
+ import type { Wallet, Signer, Provider } from "ethers";
5
+ import { LitNetwork } from "@gvnrdao/dh-lit-ops";
6
+ export type SDKMode = "standalone" | "service";
7
+ /**
8
+ * Contract Addresses Configuration
9
+ */
10
+ export interface ContractAddresses {
11
+ positionManager: string;
12
+ positionManagerCore?: string;
13
+ positionManagerViews?: string;
14
+ simplePsmV2?: string;
15
+ loanOperationsManager?: string;
16
+ termManager?: string;
17
+ collateralManager?: string;
18
+ ucdController?: string;
19
+ circuitBreaker?: string;
20
+ liquidationManager?: string;
21
+ ucdToken: string;
22
+ /** Optional when priceProviders is used (LIT actions fetch prices) */
23
+ priceFeedConsumer?: string;
24
+ operationAuthorizationRegistry?: string;
25
+ btcProofValidator?: string;
26
+ litActionValidator?: string;
27
+ /** BTCSpendAuthorizer proxy; required in dev for lit-actions `BtcSpendAuth` when passed via `contractAddresses`. */
28
+ btcSpendAuthorizer?: string;
29
+ /** BitcoinProviderRegistry proxy; required on non-hardhat chains when chain policy disallows arbitrary providers. */
30
+ bitcoinProviderRegistry?: string;
31
+ /** ContractVersionRegistry proxy; used for cross-contract version pinning. */
32
+ contractVersionRegistry?: string;
33
+ /** FeeRecipientRegistry proxy; M-8 fix — allowlist consulted by LoanOperationsManager.transferFee and SimplePSMV2.transferFee. */
34
+ feeRecipientRegistry?: string;
35
+ /** PositionDelegateRegistry proxy; consumed by LIT Action authorization verifier as the third recovery arm for Safe-as-borrower flows. */
36
+ positionDelegateRegistry?: string;
37
+ /** BitcoinWithdrawalAddressRegistry proxy; per-wallet allowlist that gates borrower-initiated BTC withdrawal destinations (24h time-lock). */
38
+ bitcoinWithdrawalAddressRegistry?: string;
39
+ mockUsdcToken?: string;
40
+ mockUsdcOwner?: string;
41
+ mockUsdtToken?: string;
42
+ mockUsdtOwner?: string;
43
+ }
44
+ /**
45
+ * Base configuration shared by all SDK modes
46
+ */
47
+ interface BaseSDKConfig {
48
+ litNetwork?: LitNetwork;
49
+ contractSigner?: Wallet | Signer;
50
+ /**
51
+ * Optional signer used exclusively for EIP-712 server-session login.
52
+ * When provided, `ServerSession` uses this instead of `contractSigner` so
53
+ * the two concerns (auth identity vs on-chain msg.sender) can differ. In
54
+ * Safe mode the CLI passes the raw agent EOA here while `contractSigner`
55
+ * is a SafeModuleSignerAdapter that routes transactions through the module.
56
+ */
57
+ authSigner?: Wallet | Signer;
58
+ ethRpcUrl?: string;
59
+ chainId?: number;
60
+ networkOverride?: {
61
+ chainId: number;
62
+ name: string;
63
+ };
64
+ provider?: Provider;
65
+ chain?: string;
66
+ bitcoinNetwork?: "mainnet" | "testnet" | "regtest";
67
+ litActionCid?: string;
68
+ litNodeConnectTimeoutMs?: number;
69
+ subgraphUrl?: string;
70
+ priceProviders?: PriceProviderConfig[];
71
+ /** PKP Ethereum address for signed price oracle (Lit jsParams pkpId); optional */
72
+ priceOraclePkpId?: string;
73
+ bitcoinFaucetUrl?: string;
74
+ contractAddresses?: ContractAddresses;
75
+ subgraphs?: {
76
+ tokenGvnrUrl?: string;
77
+ diamondHandsUrl?: string;
78
+ };
79
+ graphApiKey?: string;
80
+ graphOptions?: {
81
+ requestTimeoutMs?: number;
82
+ maxRetries?: number;
83
+ pageSize?: number;
84
+ };
85
+ mockUsdcTokenAddress?: string;
86
+ mockUsdcOwnerAddress?: string;
87
+ mockUsdcDecimals?: number;
88
+ mockUsdtTokenAddress?: string;
89
+ mockUsdtOwnerAddress?: string;
90
+ mockUsdtDecimals?: number;
91
+ ucdTokenAddress?: string;
92
+ sessionExpirationMinutes?: number;
93
+ transactionTimeoutMs?: number;
94
+ retryAttempts?: number;
95
+ debug?: boolean;
96
+ /** Notification label for server Telegram notifications. Default: "DH SDK". Set "DH APP" in the web app. */
97
+ callerLabel?: string;
98
+ /**
99
+ * Optional: Override quantum timing buffer (in seconds)
100
+ * Default: Auto-detected based on network (10s for local, 50s for Sepolia, 35s for mainnet)
101
+ *
102
+ * Network-specific defaults:
103
+ * - Local networks (1337, 31337): 10s
104
+ * - Testnets (Sepolia 11155111, Goerli 5): 45-50s
105
+ * - Mainnet (1): 35s
106
+ *
107
+ * Only override if you have specific latency requirements.
108
+ * Recommended: Leave undefined to use automatic network detection.
109
+ */
110
+ quantumBufferSeconds?: number;
111
+ /**
112
+ * @deprecated No longer read. On Sepolia (11155111), when `eth_estimateGas` fails for
113
+ * `mintUCD` but a static `eth_call` succeeds, the SDK always broadcasts with a fixed
114
+ * gas ceiling (EIP-1559). Retained for backward-compatible configs.
115
+ */
116
+ skipGasEstimation?: boolean;
117
+ pkpServiceTimeoutMs?: number;
118
+ pkpServiceRetryCount?: number;
119
+ pkpServiceRetryDelayMs?: number;
120
+ balanceCacheOptions?: {
121
+ enabled?: boolean;
122
+ ttlMs?: number;
123
+ maxSize?: number;
124
+ };
125
+ addressCacheOptions?: {
126
+ enabled?: boolean;
127
+ ttlMs?: number;
128
+ maxSize?: number;
129
+ debug?: boolean;
130
+ };
131
+ concurrencyOptions?: {
132
+ enabled?: boolean;
133
+ concurrency?: number;
134
+ timeout?: number;
135
+ debug?: boolean;
136
+ };
137
+ loggingOptions?: {
138
+ enabled?: boolean;
139
+ level?: "debug" | "info" | "warn" | "error";
140
+ includeTimestamp?: boolean;
141
+ includeContext?: boolean;
142
+ maxContextKeys?: number;
143
+ verboseInProduction?: boolean;
144
+ };
145
+ validators?: {
146
+ /** Validator version for position creation (createPosition) - usually v1 for PKP security validation */
147
+ loanCreation: number;
148
+ /** Validator version for UCD minting (mintUCD) - usually v4 for business rules validation */
149
+ minting: number;
150
+ /** Validator version for partial payments (makePayment) - usually v1 for payment validation */
151
+ payment: number;
152
+ /** Validator version for loan extension/renewal (extendPosition) - usually v4 for extension validation */
153
+ extension: number;
154
+ };
155
+ defaultSelectedTermMonths?: number;
156
+ temperSignaturesTest?: boolean;
157
+ /**
158
+ * Optional in-process notification sink invoked alongside the existing service-mode
159
+ * HTTP relay. Fires in BOTH `standalone` and `service` mode so consumers can observe
160
+ * lifecycle events (e.g. loan renewal, mint, payment, withdrawal) without depending
161
+ * on `lit-ops-server`. The SDK already emits messages via `formatLoan*Message` helpers
162
+ * — this hook just exposes them locally. Errors thrown by the handler are swallowed
163
+ * so notification failures cannot break business operations.
164
+ *
165
+ * @example
166
+ * const notifications: string[] = [];
167
+ * sdkConfig.notificationHandler = (msg) => { notifications.push(msg); };
168
+ */
169
+ notificationHandler?: (message: string) => void | Promise<void>;
170
+ }
171
+ /**
172
+ * Service Mode Configuration
173
+ * Uses lit-ops-server for PKP operations
174
+ */
175
+ export interface ServiceModeConfig extends BaseSDKConfig {
176
+ mode: "service";
177
+ serviceEndpoint: string;
178
+ litOpsSigner?: never;
179
+ }
180
+ /**
181
+ * Standalone Mode Configuration
182
+ * User provides signer for direct LIT operations
183
+ */
184
+ export interface StandaloneModeConfig extends BaseSDKConfig {
185
+ mode: "standalone";
186
+ litOpsSigner: Wallet;
187
+ serviceEndpoint?: never;
188
+ }
189
+ /**
190
+ * Main SDK Configuration - Discriminated Union
191
+ *
192
+ * Use ServiceModeConfig for production deployments with lit-ops-server
193
+ * Use StandaloneModeConfig for development/testing with direct LIT access
194
+ *
195
+ * @example Service Mode
196
+ * ```typescript
197
+ * const config: DiamondHandsSDKConfig = {
198
+ * mode: 'service',
199
+ * serviceEndpoint: 'https://lit-ops.example.com',
200
+ * contractSigner: wallet
201
+ * };
202
+ * ```
203
+ *
204
+ * @example Standalone Mode
205
+ * ```typescript
206
+ * const config: DiamondHandsSDKConfig = {
207
+ * mode: 'standalone',
208
+ * litOpsSigner: wallet,
209
+ * contractSigner: wallet
210
+ * };
211
+ * ```
212
+ */
213
+ export type DiamondHandsSDKConfig = ServiceModeConfig | StandaloneModeConfig;
214
+ /**
215
+ * Type guard to check if config is ServiceModeConfig
216
+ */
217
+ export declare function isServiceModeConfig(config: DiamondHandsSDKConfig): config is ServiceModeConfig;
218
+ /**
219
+ * Type guard to check if config is StandaloneModeConfig
220
+ */
221
+ export declare function isStandaloneModeConfig(config: DiamondHandsSDKConfig): config is StandaloneModeConfig;
222
+ export declare function validateServiceModeConfig(config: ServiceModeConfig): string | null;
223
+ /**
224
+ * Validates that StandaloneModeConfig has required fields
225
+ */
226
+ export declare function validateStandaloneModeConfig(config: StandaloneModeConfig): string | null;
227
+ /**
228
+ * Validates SDK configuration based on mode
229
+ */
230
+ export declare function validateSDKConfig(config: DiamondHandsSDKConfig): string | null;
231
+ /**
232
+ * SDK Initialization Options
233
+ */
234
+ export interface SDKInitOptions {
235
+ overrideDefaults?: boolean;
236
+ customProvider?: Provider;
237
+ skipNetworkCheck?: boolean;
238
+ }
239
+ /**
240
+ * Network Configuration (basic)
241
+ */
242
+ export interface BasicNetworkConfig {
243
+ name: string;
244
+ chainId: number;
245
+ rpcUrl: string;
246
+ blockExplorerUrl?: string;
247
+ }
248
+ /**
249
+ * Bitcoin Provider Configuration
250
+ */
251
+ export interface BitcoinProviderConfig {
252
+ url: string;
253
+ network: "mainnet" | "regtest";
254
+ auth?: {
255
+ username: string;
256
+ password: string;
257
+ };
258
+ name?: string;
259
+ priority?: number;
260
+ }
261
+ /**
262
+ * Price Provider Configuration
263
+ */
264
+ export interface PriceProviderConfig {
265
+ name: string;
266
+ pkpId?: string;
267
+ apiKey?: string;
268
+ apiSecret?: string;
269
+ }
270
+ export {};
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Smart Contract Interaction Interfaces
3
+ */
4
+ import type { TransactionReceipt } 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?: 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,171 @@
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 type { BaseContract, ContractTransactionResponse } from "ethers";
9
+ /**
10
+ * Position Manager Contract Interface
11
+ * Based on contracts/src/interfaces/IPositionManager.sol
12
+ */
13
+ export interface PositionManager extends BaseContract {
14
+ createPosition(pkpId: string, validatorSignature: string, mainnetVaultAddress: string, regtestVaultAddress: string, selectedTermMonths: number | bigint, validatorVersion: number | bigint, pkpPublicKey: string): Promise<ContractTransactionResponse>;
15
+ mintUCD(positionId: string, mintAmount: bigint, mintFee: bigint, newDebt: bigint, newCollateral: bigint, btcPrice: bigint, authorizedSpendsHash: string, ucdDebtHash: string, contractHash: string, quantumTimestamp: bigint, mintValidatorSignature: string): Promise<ContractTransactionResponse>;
16
+ liquidatePosition(positionId: string, btcPrice: bigint, quantumTimestamp: bigint, liquidationValidatorSignature: string): Promise<ContractTransactionResponse>;
17
+ getPosition(positionId: string): Promise<{
18
+ positionId: string;
19
+ pkpId: string;
20
+ ucdDebt: bigint;
21
+ borrower: string;
22
+ createdAt: number;
23
+ lastUpdated: number;
24
+ selectedTerm: number;
25
+ expiryAt: number;
26
+ status: number;
27
+ }>;
28
+ extendPosition(positionId: string, selectedTerm: bigint, quantumTimestamp: bigint, btcPrice: bigint, availableBTCBalance: bigint, proRataRenewalFee: bigint, extensionValidatorSignature: string): Promise<ContractTransactionResponse>;
29
+ commitLiquidation(positionId: string, quantumTimestamp: bigint, btcPrice: bigint, btcVaultBalance: bigint, liquidationValidatorSignature: string, overrides?: object): Promise<ContractTransactionResponse>;
30
+ revealAndLiquidate(positionId: string, quantumTimestamp: bigint, btcPrice: bigint, btcVaultBalance: bigint, liquidationValidatorSignature: string, deadline: bigint, overrides?: object): Promise<ContractTransactionResponse>;
31
+ makePayment(positionId: string, paymentAmount: bigint | string, quantumTimestamp: bigint | string, btcPrice: bigint | string, paymentValidatorSignature: string): Promise<ContractTransactionResponse>;
32
+ pkpValidationRegistry(): Promise<string>;
33
+ updateBalance(positionId: string, newBtcBalance: string | number | bigint, btcPrice: string | number | bigint, quantumTimestamp: string | number | bigint, signature: string): Promise<ContractTransactionResponse>;
34
+ }
35
+ /**
36
+ * Loan Operations Manager Contract Interface
37
+ * Based on contracts/src/interfaces/ILoanOperationsManager.sol
38
+ */
39
+ export interface ILoanOperationsManager extends BaseContract {
40
+ mintUCD(positionId: string, mintAmount: bigint, mintFee: bigint, newDebt: bigint, newCollateral: bigint, btcPrice: bigint, authorizedSpendsHash: string, ucdDebtHash: string, quantumTimestamp: bigint): Promise<ContractTransactionResponse>;
41
+ processPayment(positionId: string, paymentAmount: bigint, quantumTimestamp: bigint, btcPrice: bigint): Promise<ContractTransactionResponse>;
42
+ updatePosition(positionId: string, newDebt: bigint, quantumTimestamp: bigint, btcPrice: bigint, updateValidatorSignature: string): Promise<ContractTransactionResponse>;
43
+ transferFee(recipient: string, amount: bigint): Promise<ContractTransactionResponse>;
44
+ mintExtensionFee(amount: bigint): Promise<ContractTransactionResponse>;
45
+ feeBalance(): Promise<bigint>;
46
+ setFeeRecipientRegistry(registry: string): Promise<ContractTransactionResponse>;
47
+ feeRecipientRegistry(): Promise<string>;
48
+ authorizeBTCSpend(positionId: string, txid: string, vout: number, satoshis: bigint, targetAddress: string, targetAmount: bigint, litSignature: string): Promise<ContractTransactionResponse>;
49
+ liquidationThreshold(): Promise<bigint>;
50
+ minimumLoanValueWei(): Promise<bigint>;
51
+ ucdToken(): Promise<string>;
52
+ getUcdController(): Promise<string>;
53
+ getPKPActualCollateral(pkpId: string): Promise<bigint>;
54
+ isPriceFeedStale(): Promise<boolean>;
55
+ calculateCollateralRatio(positionId: string, btcPrice: bigint): Promise<bigint>;
56
+ getTotalAuthorizedSats(positionId: string): Promise<bigint>;
57
+ extendPosition(positionId: string, newTermMonths: bigint, extensionFee: bigint, quantumTimestamp: bigint, btcPrice: bigint, extendValidatorSignature: string): Promise<ContractTransactionResponse>;
58
+ withdrawBTC(positionId: string, btcTxid: string, btcVout: number, satoshis: bigint, destinationAddress: string, quantumTimestamp: bigint, btcPrice: bigint, btcWithdrawalSignature: string): Promise<ContractTransactionResponse>;
59
+ }
60
+ /**
61
+ * UCD Controller Contract Interface
62
+ * Based on contracts/src/interfaces/IUCDController.sol
63
+ */
64
+ export interface IUCDController extends BaseContract {
65
+ mintFromLoanOps(to: string, amount: bigint, positionId: string, debtAfterMint: bigint): Promise<ContractTransactionResponse>;
66
+ mintFromPsm(to: string, amount: bigint, stablecoin: string, amountIn: bigint): Promise<ContractTransactionResponse>;
67
+ burnTokens(from: string, amount: bigint): Promise<ContractTransactionResponse>;
68
+ setAdminModule(_adminModule: string): Promise<ContractTransactionResponse>;
69
+ setAuthorizedMinter(minter: string, authorized: boolean): Promise<ContractTransactionResponse>;
70
+ setAuthorizedBurner(burner: string, authorized: boolean): Promise<ContractTransactionResponse>;
71
+ setMaxSupply(newMaxSupply: bigint): Promise<ContractTransactionResponse>;
72
+ setDailyMintLimit(newLimit: bigint): Promise<ContractTransactionResponse>;
73
+ setDailyBurnLimit(newLimit: bigint): Promise<ContractTransactionResponse>;
74
+ setUCDToken(newToken: string): Promise<ContractTransactionResponse>;
75
+ getCurrentSupply(): Promise<bigint>;
76
+ getRemainingMintCapacity(): Promise<bigint>;
77
+ getRemainingBurnCapacity(): Promise<bigint>;
78
+ getRemainingPsmMintCapacity(): Promise<bigint>;
79
+ isAuthorizedMinter(account: string): Promise<boolean>;
80
+ isAuthorizedBurner(account: string): Promise<boolean>;
81
+ authorizedMinters(account: string): Promise<boolean>;
82
+ authorizedBurners(account: string): Promise<boolean>;
83
+ burnedPerAddress(account: string): Promise<bigint>;
84
+ totalMinted(): Promise<bigint>;
85
+ totalBurned(): Promise<bigint>;
86
+ maxSupply(): Promise<bigint>;
87
+ dailyMintLimit(): Promise<bigint>;
88
+ dailyBurnLimit(): Promise<bigint>;
89
+ lastMintReset(): Promise<bigint>;
90
+ lastBurnReset(): Promise<bigint>;
91
+ dailyMinted(): Promise<bigint>;
92
+ dailyBurned(): Promise<bigint>;
93
+ dailyPsmMinted(): Promise<bigint>;
94
+ psmDailyMintLimit(): Promise<bigint>;
95
+ circuitBreaker(): Promise<string>;
96
+ ucdToken(): Promise<string>;
97
+ adminModule(): Promise<string>;
98
+ }
99
+ /**
100
+ * Price Feed Consumer Contract Interface
101
+ */
102
+ export interface IPriceFeedConsumer extends BaseContract {
103
+ updatePrice(): Promise<ContractTransactionResponse>;
104
+ getCurrentPrice(): Promise<bigint>;
105
+ getPriceAge(): Promise<bigint>;
106
+ isPriceStale(): Promise<boolean>;
107
+ validatePriceFeed(): Promise<boolean>;
108
+ getLatestBTCPrice(): Promise<bigint>;
109
+ decimals(): Promise<number>;
110
+ }
111
+ /**
112
+ * Term Manager Contract Interface
113
+ * Based on contracts/src/interfaces/ITermManager.sol
114
+ */
115
+ export interface ITermManager extends BaseContract {
116
+ addTerm(termMonths: bigint, originationFee: bigint, extensionFee: bigint): Promise<ContractTransactionResponse>;
117
+ removeTerm(termMonths: bigint): Promise<ContractTransactionResponse>;
118
+ updateTermFees(termMonths: bigint, originationFee: bigint, extensionFee: bigint): Promise<ContractTransactionResponse>;
119
+ getTermFees(termMonths: bigint): Promise<{
120
+ originationFee: bigint;
121
+ extensionFee: bigint;
122
+ }>;
123
+ isValidTerm(termMonths: bigint): Promise<boolean>;
124
+ getValidTermsWithFees(): Promise<{
125
+ terms: bigint[];
126
+ originationFees: bigint[];
127
+ extensionFees: bigint[];
128
+ }>;
129
+ getTermDataById(termId: bigint): Promise<{
130
+ termMonths: bigint;
131
+ originationFee: bigint;
132
+ extensionFee: bigint;
133
+ isActive: boolean;
134
+ }>;
135
+ getAllTerms(): Promise<bigint[]>;
136
+ updateDependencies(newCore: string, newUcdController: string): Promise<ContractTransactionResponse>;
137
+ supportsInterface(interfaceId: string): Promise<boolean>;
138
+ }
139
+ /**
140
+ * Circuit Breaker Module Contract Interface
141
+ * Based on contracts/src/interfaces/ICircuitBreakerModule.sol
142
+ */
143
+ export interface CircuitBreakerModule extends BaseContract {
144
+ circuitBreakerCheck(ucdAmount: bigint, btcAmount: bigint): Promise<ContractTransactionResponse>;
145
+ proposeLimitUpdate(newMaxLoanValue: bigint, newMaxBtcPerPosition: bigint, newDailyLimit: bigint): Promise<ContractTransactionResponse>;
146
+ signLimitUpdate(proposalHash: string): Promise<ContractTransactionResponse>;
147
+ executeLimitUpdate(proposalHash: string, newMaxLoanValue: bigint, newMaxBtcPerPosition: bigint, newDailyLimit: bigint): Promise<ContractTransactionResponse>;
148
+ activateCircuitBreaker(): Promise<ContractTransactionResponse>;
149
+ deactivateCircuitBreaker(): Promise<ContractTransactionResponse>;
150
+ signCircuitBreakerDeactivation(): Promise<ContractTransactionResponse>;
151
+ maxSingleLoanValue(): Promise<bigint>;
152
+ maxBtcPerPosition(): Promise<bigint>;
153
+ dailyVolumeLimit(): Promise<bigint>;
154
+ circuitBreakerActive(): Promise<boolean>;
155
+ circuitBreakerActivatedAt(): Promise<bigint>;
156
+ dailyUcdVolume(day: bigint): Promise<bigint>;
157
+ dailyBtcVolume(day: bigint): Promise<bigint>;
158
+ supportsInterface(interfaceId: string): Promise<boolean>;
159
+ }
160
+ /**
161
+ * Liquidation Manager Contract Interface
162
+ * Based on contracts/src/interfaces/ILiquidationManager.sol
163
+ */
164
+ export interface ILiquidationManager extends BaseContract {
165
+ liquidatePosition(positionId: string, btcPrice: bigint, quantumTimestamp: bigint): Promise<ContractTransactionResponse>;
166
+ commitLiquidation(positionId: string, quantumTimestamp: bigint, btcPrice: bigint): Promise<ContractTransactionResponse>;
167
+ revealAndLiquidate(positionId: string, quantumTimestamp: bigint, btcPrice: bigint, liquidationValidatorSignature: string, deadline: bigint): Promise<ContractTransactionResponse>;
168
+ isLiquidatable(positionId: string, btcPrice: bigint, quantumTimestamp: bigint, liquidationValidatorSignature: string): Promise<boolean>;
169
+ vrfSeeds(positionId: string): Promise<bigint>;
170
+ supportsInterface(interfaceId: string): Promise<boolean>;
171
+ }