@gvnrdao/dh-sdk 0.0.236 → 0.0.244
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/dist/constants/chunks/deployment-addresses.d.ts +2 -0
- package/dist/constants/chunks/network-configs.d.ts +2 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +20482 -31339
- package/dist/index.mjs +20288 -31147
- package/dist/interfaces/chunks/config.i.d.ts +20 -10
- package/dist/interfaces/chunks/contract-interactions.i.d.ts +2 -2
- package/dist/interfaces/chunks/contract-types.i.d.ts +95 -91
- package/dist/interfaces/chunks/loan-operations.i.d.ts +2 -3
- package/dist/modules/bitcoin/bitcoin-operations.module.d.ts +37 -0
- package/dist/modules/cache/cache-manager.module.d.ts +8 -0
- package/dist/modules/contract/contract-manager.module.d.ts +5 -5
- package/dist/modules/diamond-hands-sdk.d.ts +103 -7
- package/dist/modules/loan/loan-creator.module.d.ts +1 -1
- package/dist/modules/loan/loan-query.module.d.ts +3 -3
- package/dist/modules/pkp/pkp-manager.module.d.ts +6 -2
- package/dist/protocol/protocol-pause.d.ts +2 -2
- package/dist/utils/address-conversion.utils.d.ts +39 -0
- package/dist/utils/bitcoin-provider.utils.d.ts +36 -0
- package/dist/utils/btc-withdrawal-message.d.ts +60 -0
- package/dist/utils/chunks/bitcoin-utils.d.ts +10 -0
- package/dist/utils/chunks/eip1559-broadcast.utils.d.ts +8 -9
- package/dist/utils/eip712-login.d.ts +27 -0
- package/dist/utils/extend-authorization.utils.d.ts +2 -2
- package/dist/utils/mint-authorization.utils.d.ts +9 -8
- package/dist/utils/position-delegate.utils.d.ts +41 -0
- package/dist/utils/server-session.d.ts +44 -0
- package/dist/utils/signature-tempering.utils.d.ts +6 -3
- package/package.json +5 -7
- package/dist/utils/bitcoin-signature.d.ts +0 -20
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* SDK Configuration Interfaces
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import type { Wallet, Signer, Provider } from "ethers";
|
|
5
5
|
import { LitNetwork } from "@gvnrdao/dh-lit-ops";
|
|
6
6
|
export type SDKMode = "standalone" | "service";
|
|
7
7
|
/**
|
|
@@ -28,6 +28,10 @@ export interface ContractAddresses {
|
|
|
28
28
|
btcSpendAuthorizer?: string;
|
|
29
29
|
/** BitcoinProviderRegistry proxy; required on non-hardhat chains when chain policy disallows arbitrary providers. */
|
|
30
30
|
bitcoinProviderRegistry?: string;
|
|
31
|
+
/** ContractVersionRegistry proxy; used for cross-contract version pinning. */
|
|
32
|
+
contractVersionRegistry?: string;
|
|
33
|
+
/** PositionDelegateRegistry proxy; consumed by LIT Action authorization verifier as the third recovery arm for Safe-as-borrower flows. */
|
|
34
|
+
positionDelegateRegistry?: string;
|
|
31
35
|
mockUsdcToken?: string;
|
|
32
36
|
mockUsdcOwner?: string;
|
|
33
37
|
mockUsdtToken?: string;
|
|
@@ -38,21 +42,26 @@ export interface ContractAddresses {
|
|
|
38
42
|
*/
|
|
39
43
|
interface BaseSDKConfig {
|
|
40
44
|
litNetwork?: LitNetwork;
|
|
41
|
-
contractSigner?:
|
|
45
|
+
contractSigner?: Wallet | Signer;
|
|
46
|
+
/**
|
|
47
|
+
* Optional signer used exclusively for EIP-712 server-session login.
|
|
48
|
+
* When provided, `ServerSession` uses this instead of `contractSigner` so
|
|
49
|
+
* the two concerns (auth identity vs on-chain msg.sender) can differ. In
|
|
50
|
+
* Safe mode the CLI passes the raw agent EOA here while `contractSigner`
|
|
51
|
+
* is a SafeModuleSignerAdapter that routes transactions through the module.
|
|
52
|
+
*/
|
|
53
|
+
authSigner?: Wallet | Signer;
|
|
42
54
|
ethRpcUrl?: string;
|
|
43
55
|
chainId?: number;
|
|
44
56
|
networkOverride?: {
|
|
45
57
|
chainId: number;
|
|
46
58
|
name: string;
|
|
47
59
|
};
|
|
48
|
-
provider?:
|
|
60
|
+
provider?: Provider;
|
|
49
61
|
chain?: string;
|
|
50
62
|
litActionCid?: string;
|
|
51
63
|
litNodeConnectTimeoutMs?: number;
|
|
52
64
|
subgraphUrl?: string;
|
|
53
|
-
bitcoinRpcUrl?: string;
|
|
54
|
-
bitcoinProviders?: BitcoinProviderConfig[];
|
|
55
|
-
bitcoinConsensusMode?: "single" | "majority";
|
|
56
65
|
priceProviders?: PriceProviderConfig[];
|
|
57
66
|
/** PKP Ethereum address for signed price oracle (Lit jsParams pkpId); optional */
|
|
58
67
|
priceOraclePkpId?: string;
|
|
@@ -79,6 +88,8 @@ interface BaseSDKConfig {
|
|
|
79
88
|
transactionTimeoutMs?: number;
|
|
80
89
|
retryAttempts?: number;
|
|
81
90
|
debug?: boolean;
|
|
91
|
+
/** Notification label for server Telegram notifications. Default: "DH SDK". Set "DH APP" in the web app. */
|
|
92
|
+
callerLabel?: string;
|
|
82
93
|
/**
|
|
83
94
|
* Optional: Override quantum timing buffer (in seconds)
|
|
84
95
|
* Default: Auto-detected based on network (10s for local, 50s for Sepolia, 35s for mainnet)
|
|
@@ -159,7 +170,6 @@ interface BaseSDKConfig {
|
|
|
159
170
|
export interface ServiceModeConfig extends BaseSDKConfig {
|
|
160
171
|
mode: "service";
|
|
161
172
|
serviceEndpoint: string;
|
|
162
|
-
serviceAuthToken?: string;
|
|
163
173
|
litOpsSigner?: never;
|
|
164
174
|
}
|
|
165
175
|
/**
|
|
@@ -168,9 +178,8 @@ export interface ServiceModeConfig extends BaseSDKConfig {
|
|
|
168
178
|
*/
|
|
169
179
|
export interface StandaloneModeConfig extends BaseSDKConfig {
|
|
170
180
|
mode: "standalone";
|
|
171
|
-
litOpsSigner:
|
|
181
|
+
litOpsSigner: Wallet;
|
|
172
182
|
serviceEndpoint?: never;
|
|
173
|
-
serviceAuthToken?: never;
|
|
174
183
|
}
|
|
175
184
|
/**
|
|
176
185
|
* Main SDK Configuration - Discriminated Union
|
|
@@ -222,7 +231,7 @@ export declare function validateSDKConfig(config: DiamondHandsSDKConfig): string
|
|
|
222
231
|
*/
|
|
223
232
|
export interface SDKInitOptions {
|
|
224
233
|
overrideDefaults?: boolean;
|
|
225
|
-
customProvider?:
|
|
234
|
+
customProvider?: Provider;
|
|
226
235
|
skipNetworkCheck?: boolean;
|
|
227
236
|
}
|
|
228
237
|
/**
|
|
@@ -252,6 +261,7 @@ export interface BitcoinProviderConfig {
|
|
|
252
261
|
*/
|
|
253
262
|
export interface PriceProviderConfig {
|
|
254
263
|
name: string;
|
|
264
|
+
pkpId?: string;
|
|
255
265
|
apiKey?: string;
|
|
256
266
|
apiSecret?: string;
|
|
257
267
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Smart Contract Interaction Interfaces
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import type { TransactionReceipt } from "ethers";
|
|
5
5
|
/**
|
|
6
6
|
* Contract Call Options Interface
|
|
7
7
|
*/
|
|
@@ -18,7 +18,7 @@ export interface ContractTransactionResult {
|
|
|
18
18
|
success: boolean;
|
|
19
19
|
error?: string;
|
|
20
20
|
transactionHash?: string;
|
|
21
|
-
receipt?:
|
|
21
|
+
receipt?: TransactionReceipt;
|
|
22
22
|
gasUsed?: string;
|
|
23
23
|
events?: any[];
|
|
24
24
|
}
|
|
@@ -5,20 +5,19 @@
|
|
|
5
5
|
* They are independent definitions - NOT imported from the contracts package.
|
|
6
6
|
* Based on Solidity interfaces from contracts/src/interfaces/
|
|
7
7
|
*/
|
|
8
|
-
import {
|
|
9
|
-
import type { BigNumber } from "ethers";
|
|
8
|
+
import type { BaseContract, ContractTransactionResponse } from "ethers";
|
|
10
9
|
/**
|
|
11
10
|
* Position Manager Contract Interface
|
|
12
11
|
* Based on contracts/src/interfaces/IPositionManager.sol
|
|
13
12
|
*/
|
|
14
|
-
export interface PositionManager extends
|
|
15
|
-
createPosition(pkpId: string, validatorSignature: string, mainnetVaultAddress: string, regtestVaultAddress: string, selectedTermMonths: number |
|
|
16
|
-
mintUCD(positionId: string, mintAmount:
|
|
17
|
-
liquidatePosition(positionId: string, btcPrice:
|
|
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>;
|
|
18
17
|
getPosition(positionId: string): Promise<{
|
|
19
18
|
positionId: string;
|
|
20
19
|
pkpId: string;
|
|
21
|
-
ucdDebt:
|
|
20
|
+
ucdDebt: bigint;
|
|
22
21
|
borrower: string;
|
|
23
22
|
createdAt: number;
|
|
24
23
|
lastUpdated: number;
|
|
@@ -26,67 +25,71 @@ export interface PositionManager extends ethers5.Contract {
|
|
|
26
25
|
expiryAt: number;
|
|
27
26
|
status: number;
|
|
28
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>;
|
|
29
32
|
pkpValidationRegistry(): Promise<string>;
|
|
30
|
-
updateBalance(positionId: string, newBtcBalance: string | number |
|
|
33
|
+
updateBalance(positionId: string, newBtcBalance: string | number | bigint, btcPrice: string | number | bigint, quantumTimestamp: string | number | bigint, signature: string): Promise<ContractTransactionResponse>;
|
|
31
34
|
}
|
|
32
35
|
/**
|
|
33
36
|
* Loan Operations Manager Contract Interface
|
|
34
37
|
* Based on contracts/src/interfaces/ILoanOperationsManager.sol
|
|
35
38
|
*/
|
|
36
|
-
export interface ILoanOperationsManager extends
|
|
37
|
-
mintUCD(positionId: string, mintAmount:
|
|
38
|
-
processPayment(positionId: string, paymentAmount:
|
|
39
|
-
updatePosition(positionId: string, newDebt:
|
|
40
|
-
transferOriginationFee(recipient: string, amount:
|
|
41
|
-
mintExtensionFee(amount:
|
|
42
|
-
getOriginationFeeBalance(): Promise<
|
|
43
|
-
authorizeBTCSpend(positionId: string, txid: string, vout: number, satoshis:
|
|
44
|
-
liquidationThreshold(): Promise<
|
|
45
|
-
minimumLoanValueWei(): Promise<
|
|
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
|
+
transferOriginationFee(recipient: string, amount: bigint): Promise<ContractTransactionResponse>;
|
|
44
|
+
mintExtensionFee(amount: bigint): Promise<ContractTransactionResponse>;
|
|
45
|
+
getOriginationFeeBalance(): Promise<bigint>;
|
|
46
|
+
authorizeBTCSpend(positionId: string, txid: string, vout: number, satoshis: bigint, targetAddress: string, targetAmount: bigint, litSignature: string): Promise<ContractTransactionResponse>;
|
|
47
|
+
liquidationThreshold(): Promise<bigint>;
|
|
48
|
+
minimumLoanValueWei(): Promise<bigint>;
|
|
46
49
|
ucdToken(): Promise<string>;
|
|
47
50
|
getUcdController(): Promise<string>;
|
|
48
|
-
getPKPActualCollateral(pkpId: string): Promise<
|
|
51
|
+
getPKPActualCollateral(pkpId: string): Promise<bigint>;
|
|
49
52
|
isPriceFeedStale(): Promise<boolean>;
|
|
50
|
-
calculateCollateralRatio(positionId: string, btcPrice:
|
|
51
|
-
getTotalAuthorizedSats(positionId: string): Promise<
|
|
52
|
-
extendPosition(positionId: string, newTermMonths:
|
|
53
|
-
withdrawBTC(positionId: string, btcTxid: string, btcVout: number, satoshis:
|
|
53
|
+
calculateCollateralRatio(positionId: string, btcPrice: bigint): Promise<bigint>;
|
|
54
|
+
getTotalAuthorizedSats(positionId: string): Promise<bigint>;
|
|
55
|
+
extendPosition(positionId: string, newTermMonths: bigint, extensionFee: bigint, quantumTimestamp: bigint, btcPrice: bigint, extendValidatorSignature: string): Promise<ContractTransactionResponse>;
|
|
56
|
+
withdrawBTC(positionId: string, btcTxid: string, btcVout: number, satoshis: bigint, destinationAddress: string, quantumTimestamp: bigint, btcPrice: bigint, btcWithdrawalSignature: string): Promise<ContractTransactionResponse>;
|
|
54
57
|
}
|
|
55
58
|
/**
|
|
56
59
|
* UCD Controller Contract Interface
|
|
57
60
|
* Based on contracts/src/interfaces/IUCDController.sol
|
|
58
61
|
*/
|
|
59
|
-
export interface IUCDController extends
|
|
60
|
-
mintFromLoanOps(to: string, amount:
|
|
61
|
-
mintFromPsm(to: string, amount:
|
|
62
|
-
burnTokens(from: string, amount:
|
|
63
|
-
setAdminModule(_adminModule: string): Promise<
|
|
64
|
-
setAuthorizedMinter(minter: string, authorized: boolean): Promise<
|
|
65
|
-
setAuthorizedBurner(burner: string, authorized: boolean): Promise<
|
|
66
|
-
setMaxSupply(newMaxSupply:
|
|
67
|
-
setDailyMintLimit(newLimit:
|
|
68
|
-
setDailyBurnLimit(newLimit:
|
|
69
|
-
setUCDToken(newToken: string): Promise<
|
|
70
|
-
getCurrentSupply(): Promise<
|
|
71
|
-
getRemainingMintCapacity(): Promise<
|
|
72
|
-
getRemainingBurnCapacity(): Promise<
|
|
73
|
-
getRemainingPsmMintCapacity(): Promise<
|
|
62
|
+
export interface IUCDController extends BaseContract {
|
|
63
|
+
mintFromLoanOps(to: string, amount: bigint, positionId: string, debtAfterMint: bigint): Promise<ContractTransactionResponse>;
|
|
64
|
+
mintFromPsm(to: string, amount: bigint, stablecoin: string, amountIn: bigint): Promise<ContractTransactionResponse>;
|
|
65
|
+
burnTokens(from: string, amount: bigint): Promise<ContractTransactionResponse>;
|
|
66
|
+
setAdminModule(_adminModule: string): Promise<ContractTransactionResponse>;
|
|
67
|
+
setAuthorizedMinter(minter: string, authorized: boolean): Promise<ContractTransactionResponse>;
|
|
68
|
+
setAuthorizedBurner(burner: string, authorized: boolean): Promise<ContractTransactionResponse>;
|
|
69
|
+
setMaxSupply(newMaxSupply: bigint): Promise<ContractTransactionResponse>;
|
|
70
|
+
setDailyMintLimit(newLimit: bigint): Promise<ContractTransactionResponse>;
|
|
71
|
+
setDailyBurnLimit(newLimit: bigint): Promise<ContractTransactionResponse>;
|
|
72
|
+
setUCDToken(newToken: string): Promise<ContractTransactionResponse>;
|
|
73
|
+
getCurrentSupply(): Promise<bigint>;
|
|
74
|
+
getRemainingMintCapacity(): Promise<bigint>;
|
|
75
|
+
getRemainingBurnCapacity(): Promise<bigint>;
|
|
76
|
+
getRemainingPsmMintCapacity(): Promise<bigint>;
|
|
74
77
|
isAuthorizedMinter(account: string): Promise<boolean>;
|
|
75
78
|
isAuthorizedBurner(account: string): Promise<boolean>;
|
|
76
79
|
authorizedMinters(account: string): Promise<boolean>;
|
|
77
80
|
authorizedBurners(account: string): Promise<boolean>;
|
|
78
|
-
burnedPerAddress(account: string): Promise<
|
|
79
|
-
totalMinted(): Promise<
|
|
80
|
-
totalBurned(): Promise<
|
|
81
|
-
maxSupply(): Promise<
|
|
82
|
-
dailyMintLimit(): Promise<
|
|
83
|
-
dailyBurnLimit(): Promise<
|
|
84
|
-
lastMintReset(): Promise<
|
|
85
|
-
lastBurnReset(): Promise<
|
|
86
|
-
dailyMinted(): Promise<
|
|
87
|
-
dailyBurned(): Promise<
|
|
88
|
-
dailyPsmMinted(): Promise<
|
|
89
|
-
psmDailyMintLimit(): Promise<
|
|
81
|
+
burnedPerAddress(account: string): Promise<bigint>;
|
|
82
|
+
totalMinted(): Promise<bigint>;
|
|
83
|
+
totalBurned(): Promise<bigint>;
|
|
84
|
+
maxSupply(): Promise<bigint>;
|
|
85
|
+
dailyMintLimit(): Promise<bigint>;
|
|
86
|
+
dailyBurnLimit(): Promise<bigint>;
|
|
87
|
+
lastMintReset(): Promise<bigint>;
|
|
88
|
+
lastBurnReset(): Promise<bigint>;
|
|
89
|
+
dailyMinted(): Promise<bigint>;
|
|
90
|
+
dailyBurned(): Promise<bigint>;
|
|
91
|
+
dailyPsmMinted(): Promise<bigint>;
|
|
92
|
+
psmDailyMintLimit(): Promise<bigint>;
|
|
90
93
|
circuitBreaker(): Promise<string>;
|
|
91
94
|
ucdToken(): Promise<string>;
|
|
92
95
|
adminModule(): Promise<string>;
|
|
@@ -94,72 +97,73 @@ export interface IUCDController extends ethers5.Contract {
|
|
|
94
97
|
/**
|
|
95
98
|
* Price Feed Consumer Contract Interface
|
|
96
99
|
*/
|
|
97
|
-
export interface IPriceFeedConsumer extends
|
|
98
|
-
updatePrice(): Promise<
|
|
99
|
-
getCurrentPrice(): Promise<
|
|
100
|
-
getPriceAge(): Promise<
|
|
100
|
+
export interface IPriceFeedConsumer extends BaseContract {
|
|
101
|
+
updatePrice(): Promise<ContractTransactionResponse>;
|
|
102
|
+
getCurrentPrice(): Promise<bigint>;
|
|
103
|
+
getPriceAge(): Promise<bigint>;
|
|
101
104
|
isPriceStale(): Promise<boolean>;
|
|
102
105
|
validatePriceFeed(): Promise<boolean>;
|
|
103
|
-
getLatestBTCPrice(): Promise<
|
|
106
|
+
getLatestBTCPrice(): Promise<bigint>;
|
|
104
107
|
decimals(): Promise<number>;
|
|
105
108
|
}
|
|
106
109
|
/**
|
|
107
110
|
* Term Manager Contract Interface
|
|
108
111
|
* Based on contracts/src/interfaces/ITermManager.sol
|
|
109
112
|
*/
|
|
110
|
-
export interface ITermManager extends
|
|
111
|
-
addTerm(termMonths:
|
|
112
|
-
removeTerm(termMonths:
|
|
113
|
-
updateTermFees(termMonths:
|
|
114
|
-
getTermFees(termMonths:
|
|
115
|
-
originationFee:
|
|
116
|
-
extensionFee:
|
|
113
|
+
export interface ITermManager extends BaseContract {
|
|
114
|
+
addTerm(termMonths: bigint, originationFee: bigint, extensionFee: bigint): Promise<ContractTransactionResponse>;
|
|
115
|
+
removeTerm(termMonths: bigint): Promise<ContractTransactionResponse>;
|
|
116
|
+
updateTermFees(termMonths: bigint, originationFee: bigint, extensionFee: bigint): Promise<ContractTransactionResponse>;
|
|
117
|
+
getTermFees(termMonths: bigint): Promise<{
|
|
118
|
+
originationFee: bigint;
|
|
119
|
+
extensionFee: bigint;
|
|
117
120
|
}>;
|
|
118
|
-
isValidTerm(termMonths:
|
|
121
|
+
isValidTerm(termMonths: bigint): Promise<boolean>;
|
|
119
122
|
getValidTermsWithFees(): Promise<{
|
|
120
|
-
terms:
|
|
121
|
-
originationFees:
|
|
122
|
-
extensionFees:
|
|
123
|
+
terms: bigint[];
|
|
124
|
+
originationFees: bigint[];
|
|
125
|
+
extensionFees: bigint[];
|
|
123
126
|
}>;
|
|
124
|
-
getTermDataById(termId:
|
|
125
|
-
termMonths:
|
|
126
|
-
originationFee:
|
|
127
|
-
extensionFee:
|
|
127
|
+
getTermDataById(termId: bigint): Promise<{
|
|
128
|
+
termMonths: bigint;
|
|
129
|
+
originationFee: bigint;
|
|
130
|
+
extensionFee: bigint;
|
|
128
131
|
isActive: boolean;
|
|
129
132
|
}>;
|
|
130
|
-
getAllTerms(): Promise<
|
|
131
|
-
updateDependencies(newCore: string, newUcdController: string): Promise<
|
|
133
|
+
getAllTerms(): Promise<bigint[]>;
|
|
134
|
+
updateDependencies(newCore: string, newUcdController: string): Promise<ContractTransactionResponse>;
|
|
132
135
|
supportsInterface(interfaceId: string): Promise<boolean>;
|
|
133
136
|
}
|
|
134
137
|
/**
|
|
135
138
|
* Circuit Breaker Module Contract Interface
|
|
136
139
|
* Based on contracts/src/interfaces/ICircuitBreakerModule.sol
|
|
137
140
|
*/
|
|
138
|
-
export interface CircuitBreakerModule extends
|
|
139
|
-
circuitBreakerCheck(ucdAmount:
|
|
140
|
-
proposeLimitUpdate(newMaxLoanValue:
|
|
141
|
-
signLimitUpdate(proposalHash: string): Promise<
|
|
142
|
-
executeLimitUpdate(proposalHash: string, newMaxLoanValue:
|
|
143
|
-
activateCircuitBreaker(): Promise<
|
|
144
|
-
deactivateCircuitBreaker(): Promise<
|
|
145
|
-
signCircuitBreakerDeactivation(): Promise<
|
|
146
|
-
maxSingleLoanValue(): Promise<
|
|
147
|
-
maxBtcPerPosition(): Promise<
|
|
148
|
-
dailyVolumeLimit(): Promise<
|
|
141
|
+
export interface CircuitBreakerModule extends BaseContract {
|
|
142
|
+
circuitBreakerCheck(ucdAmount: bigint, btcAmount: bigint): Promise<ContractTransactionResponse>;
|
|
143
|
+
proposeLimitUpdate(newMaxLoanValue: bigint, newMaxBtcPerPosition: bigint, newDailyLimit: bigint): Promise<ContractTransactionResponse>;
|
|
144
|
+
signLimitUpdate(proposalHash: string): Promise<ContractTransactionResponse>;
|
|
145
|
+
executeLimitUpdate(proposalHash: string, newMaxLoanValue: bigint, newMaxBtcPerPosition: bigint, newDailyLimit: bigint): Promise<ContractTransactionResponse>;
|
|
146
|
+
activateCircuitBreaker(): Promise<ContractTransactionResponse>;
|
|
147
|
+
deactivateCircuitBreaker(): Promise<ContractTransactionResponse>;
|
|
148
|
+
signCircuitBreakerDeactivation(): Promise<ContractTransactionResponse>;
|
|
149
|
+
maxSingleLoanValue(): Promise<bigint>;
|
|
150
|
+
maxBtcPerPosition(): Promise<bigint>;
|
|
151
|
+
dailyVolumeLimit(): Promise<bigint>;
|
|
149
152
|
circuitBreakerActive(): Promise<boolean>;
|
|
150
|
-
circuitBreakerActivatedAt(): Promise<
|
|
151
|
-
dailyUcdVolume(day:
|
|
152
|
-
dailyBtcVolume(day:
|
|
153
|
+
circuitBreakerActivatedAt(): Promise<bigint>;
|
|
154
|
+
dailyUcdVolume(day: bigint): Promise<bigint>;
|
|
155
|
+
dailyBtcVolume(day: bigint): Promise<bigint>;
|
|
153
156
|
supportsInterface(interfaceId: string): Promise<boolean>;
|
|
154
157
|
}
|
|
155
158
|
/**
|
|
156
159
|
* Liquidation Manager Contract Interface
|
|
157
160
|
* Based on contracts/src/interfaces/ILiquidationManager.sol
|
|
158
161
|
*/
|
|
159
|
-
export interface ILiquidationManager extends
|
|
160
|
-
liquidatePosition(positionId: string, btcPrice:
|
|
161
|
-
commitLiquidation(positionId: string, quantumTimestamp:
|
|
162
|
-
revealAndLiquidate(positionId: string, quantumTimestamp:
|
|
163
|
-
isLiquidatable(positionId: string, btcPrice:
|
|
162
|
+
export interface ILiquidationManager extends BaseContract {
|
|
163
|
+
liquidatePosition(positionId: string, btcPrice: bigint, quantumTimestamp: bigint): Promise<ContractTransactionResponse>;
|
|
164
|
+
commitLiquidation(positionId: string, quantumTimestamp: bigint, btcPrice: bigint): Promise<ContractTransactionResponse>;
|
|
165
|
+
revealAndLiquidate(positionId: string, quantumTimestamp: bigint, btcPrice: bigint, liquidationValidatorSignature: string, deadline: bigint): Promise<ContractTransactionResponse>;
|
|
166
|
+
isLiquidatable(positionId: string, btcPrice: bigint, quantumTimestamp: bigint, liquidationValidatorSignature: string): Promise<boolean>;
|
|
167
|
+
vrfSeeds(positionId: string): Promise<bigint>;
|
|
164
168
|
supportsInterface(interfaceId: string): Promise<boolean>;
|
|
165
169
|
}
|
|
@@ -169,7 +169,6 @@ export interface UCDMintRequest {
|
|
|
169
169
|
selectedTerm?: number;
|
|
170
170
|
skipValidation?: boolean;
|
|
171
171
|
rpcUrl?: string;
|
|
172
|
-
customBitcoinRpcUrl?: string;
|
|
173
172
|
testBtcPrice?: number;
|
|
174
173
|
debugOverrides?: {
|
|
175
174
|
useStubbedBtcData?: boolean;
|
|
@@ -232,6 +231,8 @@ export interface BTCWithdrawalResult {
|
|
|
232
231
|
bitcoinTransactionHash?: string;
|
|
233
232
|
utxoTxid?: string;
|
|
234
233
|
utxoVout?: number;
|
|
234
|
+
/** Full satoshi value of the authorized UTXO; needed by Phase 2 broadcast. */
|
|
235
|
+
utxoSatoshis?: string;
|
|
235
236
|
error?: string;
|
|
236
237
|
}
|
|
237
238
|
/**
|
|
@@ -247,7 +248,6 @@ export interface LiquidationRequest {
|
|
|
247
248
|
*/
|
|
248
249
|
skipUcdApproval?: boolean;
|
|
249
250
|
rpcUrl?: string;
|
|
250
|
-
customBitcoinRpcUrl?: string;
|
|
251
251
|
}
|
|
252
252
|
/**
|
|
253
253
|
* Liquidation Result Interface
|
|
@@ -272,7 +272,6 @@ export interface PartialPaymentRequest {
|
|
|
272
272
|
positionId: string;
|
|
273
273
|
paymentAmount: number;
|
|
274
274
|
rpcUrl?: string;
|
|
275
|
-
customBitcoinRpcUrl?: string;
|
|
276
275
|
}
|
|
277
276
|
/**
|
|
278
277
|
* Confirm Balance Result Interface
|
|
@@ -197,6 +197,43 @@ export declare class BitcoinOperations {
|
|
|
197
197
|
* Check if consensus mode is enabled
|
|
198
198
|
*/
|
|
199
199
|
isConsensusEnabled(): boolean;
|
|
200
|
+
/**
|
|
201
|
+
* Audit CRIT-2: verify a Phase-2 BTC withdrawal that the lit-ops-server
|
|
202
|
+
* claimed broadcast actually exists on chain and matches the user's
|
|
203
|
+
* authorization.
|
|
204
|
+
*
|
|
205
|
+
* Behavior:
|
|
206
|
+
* - If we successfully fetch the tx AND it disagrees with what the user
|
|
207
|
+
* authorized → throws (hard fail; server lied).
|
|
208
|
+
* - If we fetch the tx and it matches → returns `{ verified: true }`.
|
|
209
|
+
* - If no provider has the tx after `maxAttempts` retries → returns
|
|
210
|
+
* `{ verified: false, reason: "not yet visible" }`. The caller decides
|
|
211
|
+
* whether to log a warning and proceed (e.g., regtest without an
|
|
212
|
+
* Esplora indexer, or extreme propagation delay) or to escalate.
|
|
213
|
+
* - If no Bitcoin providers are configured → returns `{ verified: false,
|
|
214
|
+
* reason: "no providers" }` immediately.
|
|
215
|
+
*
|
|
216
|
+
* The expected `value` is `targetAmount - networkFee` (what reaches the
|
|
217
|
+
* recipient after the fee), matching the Lit Action's
|
|
218
|
+
* `userReceivesAmount` computation.
|
|
219
|
+
*/
|
|
220
|
+
verifyBroadcastTx(args: {
|
|
221
|
+
txid: string;
|
|
222
|
+
expectedInput: {
|
|
223
|
+
txid: string;
|
|
224
|
+
vout: number;
|
|
225
|
+
};
|
|
226
|
+
expectedOutput: {
|
|
227
|
+
address: string;
|
|
228
|
+
value: number;
|
|
229
|
+
};
|
|
230
|
+
maxAttempts?: number;
|
|
231
|
+
delayMs?: number;
|
|
232
|
+
}): Promise<{
|
|
233
|
+
verified: boolean;
|
|
234
|
+
reason?: string;
|
|
235
|
+
confirmed?: boolean;
|
|
236
|
+
}>;
|
|
200
237
|
/**
|
|
201
238
|
* Get current BTC price using LIT Protocol price oracle
|
|
202
239
|
*
|
|
@@ -86,6 +86,14 @@ export interface CacheConfig {
|
|
|
86
86
|
*/
|
|
87
87
|
export declare class LRUCache<K, V> {
|
|
88
88
|
private cache;
|
|
89
|
+
/**
|
|
90
|
+
* Audit M-J: singleflight registry for `getOrCompute` / `getOrComputeResult`.
|
|
91
|
+
* Concurrent cache-miss callers for the same key share one inflight promise
|
|
92
|
+
* instead of each running `compute()` independently — important when the
|
|
93
|
+
* compute spends a paid LIT capacity credit or hits a rate-limited upstream.
|
|
94
|
+
*/
|
|
95
|
+
private inflight;
|
|
96
|
+
private inflightResult;
|
|
89
97
|
private readonly maxSize;
|
|
90
98
|
private readonly ttlMs;
|
|
91
99
|
private readonly debug;
|
|
@@ -10,19 +10,19 @@
|
|
|
10
10
|
* This module centralizes all contract interaction setup and provides
|
|
11
11
|
* a clean interface for other modules to access contracts.
|
|
12
12
|
*/
|
|
13
|
-
import {
|
|
13
|
+
import { type Provider, type Signer } from "ethers";
|
|
14
14
|
import type { ContractAddresses } from "../../interfaces/chunks/config.i";
|
|
15
15
|
import { Result } from "../../types/result";
|
|
16
16
|
import { SDKError } from "../../utils/error-handler";
|
|
17
17
|
import type { PositionManager, ILoanOperationsManager, IUCDController, IPriceFeedConsumer, ITermManager, CircuitBreakerModule, ILiquidationManager } from "../../interfaces/chunks/contract-types.i";
|
|
18
18
|
/**
|
|
19
|
-
* Type alias for ethers
|
|
19
|
+
* Type alias for ethers v6 provider (used throughout SDK)
|
|
20
20
|
*/
|
|
21
|
-
export type Provider
|
|
21
|
+
export type { Provider };
|
|
22
22
|
/**
|
|
23
|
-
* Type alias for ethers
|
|
23
|
+
* Type alias for ethers v6 signer
|
|
24
24
|
*/
|
|
25
|
-
export type Signer
|
|
25
|
+
export type { Signer };
|
|
26
26
|
/**
|
|
27
27
|
* Type alias for contract runner (provider or signer)
|
|
28
28
|
*/
|