@domfi/sdk 0.1.0
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 +16 -0
- package/README.md +786 -0
- package/dist/actions.cjs +1 -0
- package/dist/actions.d.cts +17 -0
- package/dist/actions.d.ts +17 -0
- package/dist/actions.js +1 -0
- package/dist/api.cjs +1 -0
- package/dist/api.d.cts +664 -0
- package/dist/api.d.ts +664 -0
- package/dist/api.js +0 -0
- package/dist/chunk-2VSPOLVO.js +1 -0
- package/dist/chunk-5YZVCHRU.js +0 -0
- package/dist/chunk-77XMXAXE.js +1 -0
- package/dist/chunk-7OVWNPZQ.js +1 -0
- package/dist/chunk-BMYMNNJK.js +1 -0
- package/dist/chunk-C5Y2WM7C.js +1 -0
- package/dist/chunk-C64LJM7D.js +2 -0
- package/dist/chunk-CLOFJTBP.js +1 -0
- package/dist/chunk-CMREWGOI.js +1 -0
- package/dist/chunk-D5VE2O4F.js +1 -0
- package/dist/chunk-LDE3JHVE.js +1 -0
- package/dist/chunk-N4Q67DTE.js +1 -0
- package/dist/chunk-SZE5DE54.js +1 -0
- package/dist/chunk-XHQVWI2J.js +1 -0
- package/dist/chunk-YU5DN3PI.js +1 -0
- package/dist/config.cjs +2 -0
- package/dist/config.d.cts +132 -0
- package/dist/config.d.ts +132 -0
- package/dist/config.js +1 -0
- package/dist/contracts.cjs +1 -0
- package/dist/contracts.d.cts +13073 -0
- package/dist/contracts.d.ts +13073 -0
- package/dist/contracts.js +1 -0
- package/dist/delegation.cjs +1 -0
- package/dist/delegation.d.cts +7 -0
- package/dist/delegation.d.ts +7 -0
- package/dist/delegation.js +0 -0
- package/dist/errors.cjs +3 -0
- package/dist/errors.d.cts +155 -0
- package/dist/errors.d.ts +155 -0
- package/dist/errors.js +3 -0
- package/dist/index.cjs +2 -0
- package/dist/index.d.cts +216 -0
- package/dist/index.d.ts +216 -0
- package/dist/index.js +1 -0
- package/dist/math.cjs +1 -0
- package/dist/math.d.cts +273 -0
- package/dist/math.d.ts +273 -0
- package/dist/math.js +1 -0
- package/dist/position-BnhSFyGe.d.cts +56 -0
- package/dist/position-BnhSFyGe.d.ts +56 -0
- package/dist/rawSchemas-MAT7EZCV.js +1 -0
- package/dist/referrals.cjs +1 -0
- package/dist/referrals.d.cts +66 -0
- package/dist/referrals.d.ts +66 -0
- package/dist/referrals.js +1 -0
- package/dist/serde.cjs +1 -0
- package/dist/serde.d.cts +24 -0
- package/dist/serde.d.ts +24 -0
- package/dist/serde.js +1 -0
- package/dist/token.cjs +1 -0
- package/dist/token.d.cts +32 -0
- package/dist/token.d.ts +32 -0
- package/dist/token.js +0 -0
- package/dist/trading.cjs +1 -0
- package/dist/trading.d.cts +20 -0
- package/dist/trading.d.ts +20 -0
- package/dist/trading.js +1 -0
- package/dist/types-7s13ZSql.d.ts +533 -0
- package/dist/types-BK6dYOXr.d.cts +118 -0
- package/dist/types-CMtixBIP.d.cts +464 -0
- package/dist/types-DB1r_Ppi.d.ts +464 -0
- package/dist/types-DDgJiEFg.d.ts +780 -0
- package/dist/types-DJBX-p4X.d.cts +780 -0
- package/dist/types-DQft82W7.d.cts +533 -0
- package/dist/types-DhCzEwnS.d.ts +118 -0
- package/dist/types-veTDfbhq.d.ts +436 -0
- package/dist/types-x1MvxSdy.d.cts +436 -0
- package/dist/units-BYd75H7U.d.cts +22 -0
- package/dist/units-BYd75H7U.d.ts +22 -0
- package/dist/units.cjs +1 -0
- package/dist/units.d.cts +248 -0
- package/dist/units.d.ts +248 -0
- package/dist/units.js +1 -0
- package/dist/valuation.cjs +1 -0
- package/dist/valuation.d.cts +5 -0
- package/dist/valuation.d.ts +5 -0
- package/dist/valuation.js +1 -0
- package/dist/vault.cjs +1 -0
- package/dist/vault.d.cts +34 -0
- package/dist/vault.d.ts +34 -0
- package/dist/vault.js +1 -0
- package/package.json +181 -0
|
@@ -0,0 +1,780 @@
|
|
|
1
|
+
import * as viem from 'viem';
|
|
2
|
+
import { DiagnosticsEnvelope } from '@domfi/sdk/errors';
|
|
3
|
+
import { R as ReadOptions, k as OrderLifecycle, l as RemoveCollateralTracking, m as AccountTrade, O as OpenAccountPosition, V as VerifiedPositionRef, a as ReceiptVerifiedOpenTriggerOrderRef, b as VerifiedOpenTriggerOrderRef } from './types-DQft82W7.cjs';
|
|
4
|
+
import { Address, Hex, ClosePercent, Collateral, Leverage, UsdP6, Price, UnsignedP18, SlippagePercent, WholePercent, TradeId, PairIndex, DecimalInput, OrderId } from './units.cjs';
|
|
5
|
+
import { ReferralCodeIdInput } from './referrals.cjs';
|
|
6
|
+
|
|
7
|
+
/** Trader account whose delegated permissions should be used for a transaction. */
|
|
8
|
+
type DelegationTarget = {
|
|
9
|
+
trader: Address;
|
|
10
|
+
};
|
|
11
|
+
/** Read controls for delegation helpers. */
|
|
12
|
+
type DelegationReadOptions = Pick<ReadOptions, "signal" | "timeoutMs"> & {
|
|
13
|
+
readinessPolicy?: never;
|
|
14
|
+
};
|
|
15
|
+
/** Read controls for delegation typed-data generation. */
|
|
16
|
+
type DelegationTypedDataOptions = DelegationReadOptions;
|
|
17
|
+
/** Send controls for delegation transactions. */
|
|
18
|
+
type DelegationSendOptions = Pick<SendOptions, "account" | "gas" | "nonce" | "maxFeePerGas" | "signal"> & {
|
|
19
|
+
readinessPolicy?: never;
|
|
20
|
+
timeoutMs?: never;
|
|
21
|
+
maxOracleFeeWei?: never;
|
|
22
|
+
skipApprovalCheck?: never;
|
|
23
|
+
delegation?: never;
|
|
24
|
+
trader?: never;
|
|
25
|
+
};
|
|
26
|
+
/** Parameters used to build or sign DomFi delegation EIP-712 typed data. */
|
|
27
|
+
type DelegationTypedDataParams = {
|
|
28
|
+
delegator: Address;
|
|
29
|
+
delegate: Address;
|
|
30
|
+
/** Unix timestamp in seconds, matching DomfiTrading's block.timestamp comparison. */
|
|
31
|
+
expiry: bigint;
|
|
32
|
+
nonce?: bigint;
|
|
33
|
+
};
|
|
34
|
+
/** DomFi delegation EIP-712 payload for wallet signing. */
|
|
35
|
+
type DelegationTypedData = {
|
|
36
|
+
domain: {
|
|
37
|
+
name: "Domination Finance";
|
|
38
|
+
version: "1";
|
|
39
|
+
chainId: number;
|
|
40
|
+
verifyingContract: Address;
|
|
41
|
+
};
|
|
42
|
+
primaryType: "Delegation";
|
|
43
|
+
types: {
|
|
44
|
+
Delegation: readonly [
|
|
45
|
+
{
|
|
46
|
+
readonly name: "delegator";
|
|
47
|
+
readonly type: "address";
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
readonly name: "delegate";
|
|
51
|
+
readonly type: "address";
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
readonly name: "nonce";
|
|
55
|
+
readonly type: "uint256";
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
readonly name: "expiry";
|
|
59
|
+
readonly type: "uint256";
|
|
60
|
+
}
|
|
61
|
+
];
|
|
62
|
+
};
|
|
63
|
+
message: {
|
|
64
|
+
delegator: Address;
|
|
65
|
+
delegate: Address;
|
|
66
|
+
nonce: bigint;
|
|
67
|
+
expiry: bigint;
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
/** Signed delegation payload accepted by `setDelegateWithSignature`. */
|
|
71
|
+
type SignedDelegation = {
|
|
72
|
+
delegator: Address;
|
|
73
|
+
delegate: Address;
|
|
74
|
+
nonce: bigint;
|
|
75
|
+
/** Unix timestamp in seconds, matching DomfiTrading's block.timestamp comparison. */
|
|
76
|
+
expiry: bigint;
|
|
77
|
+
signature: Hex;
|
|
78
|
+
};
|
|
79
|
+
/** Onchain delegation client for approving a secondary trading wallet. */
|
|
80
|
+
type DelegationClient = {
|
|
81
|
+
/** Reads the active delegate for a trader, if one is set. */
|
|
82
|
+
getDelegate(trader: Address, opts?: DelegationReadOptions): Promise<Address | undefined>;
|
|
83
|
+
/** Checks whether `delegate` is currently authorized for `trader`. */
|
|
84
|
+
isDelegateFor(trader: Address, delegate: Address, opts?: DelegationReadOptions): Promise<boolean>;
|
|
85
|
+
/** Reads the current delegation nonce for a trader. */
|
|
86
|
+
getNonce(trader: Address, opts?: DelegationReadOptions): Promise<bigint>;
|
|
87
|
+
/** Sends a transaction from the trader to set `delegate` as authorized. */
|
|
88
|
+
setDelegate(delegate: Address, opts?: DelegationSendOptions): Promise<ReceiptOnlyHandle>;
|
|
89
|
+
/** Sends a transaction from the trader to remove the active delegate. */
|
|
90
|
+
removeDelegate(opts?: DelegationSendOptions): Promise<ReceiptOnlyHandle>;
|
|
91
|
+
/** Builds the EIP-712 typed data for an offchain delegation signature. */
|
|
92
|
+
typedData(params: DelegationTypedDataParams, opts?: DelegationTypedDataOptions): Promise<DelegationTypedData>;
|
|
93
|
+
/** Signs a delegation payload with the provided or SDK-configured wallet client. */
|
|
94
|
+
sign(params: DelegationTypedDataParams, walletClient?: WalletClient, opts?: DelegationTypedDataOptions): Promise<SignedDelegation>;
|
|
95
|
+
/** Sends a signed delegation payload onchain. */
|
|
96
|
+
setDelegateWithSignature(signed: SignedDelegation, opts?: DelegationSendOptions): Promise<ReceiptOnlyHandle>;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
/** Result returned by a client-side trading constraint check. */
|
|
100
|
+
type ConstraintCheckResult = {
|
|
101
|
+
status: "ok";
|
|
102
|
+
code: string;
|
|
103
|
+
message?: string;
|
|
104
|
+
} | {
|
|
105
|
+
status: "violation";
|
|
106
|
+
code: string;
|
|
107
|
+
message: string;
|
|
108
|
+
severity: "warning" | "error";
|
|
109
|
+
} | {
|
|
110
|
+
status: "unchecked";
|
|
111
|
+
code: string;
|
|
112
|
+
reason: string;
|
|
113
|
+
message?: string;
|
|
114
|
+
};
|
|
115
|
+
/** Inputs for checking market min/max leverage bounds. */
|
|
116
|
+
type CheckLeverageBoundsInput = {
|
|
117
|
+
leverage: Leverage;
|
|
118
|
+
minLeverage: Leverage;
|
|
119
|
+
maxLeverage: Leverage;
|
|
120
|
+
};
|
|
121
|
+
/** Inputs for checking a market minimum position size. */
|
|
122
|
+
type CheckMinimumPositionSizeInput = {
|
|
123
|
+
notionalUsd: UsdP6;
|
|
124
|
+
minPositionSize: Collateral;
|
|
125
|
+
};
|
|
126
|
+
/** Inputs for checking max allowed collateral. */
|
|
127
|
+
type CheckMaxCollateralInput = {
|
|
128
|
+
collateral: Collateral;
|
|
129
|
+
maxAllowedCollateral: Collateral;
|
|
130
|
+
};
|
|
131
|
+
/** Inputs for checking whether a new order would exceed open-interest caps. */
|
|
132
|
+
type CheckOiCapInput = {
|
|
133
|
+
price: Price;
|
|
134
|
+
currentSideOi: UnsignedP18;
|
|
135
|
+
requestedNotional: UsdP6;
|
|
136
|
+
oiCap: UsdP6;
|
|
137
|
+
};
|
|
138
|
+
/** Inputs for checking market group collateral caps. */
|
|
139
|
+
type CheckGroupCollateralCapInput = {
|
|
140
|
+
requestedCollateral: Collateral;
|
|
141
|
+
groupMaxCollateral: Collateral;
|
|
142
|
+
currentGroupCollateral?: Collateral;
|
|
143
|
+
};
|
|
144
|
+
/** Inputs for checking market slippage bounds. */
|
|
145
|
+
type CheckSlippageBoundsInput = {
|
|
146
|
+
slippage: SlippagePercent;
|
|
147
|
+
maxSlP: WholePercent;
|
|
148
|
+
};
|
|
149
|
+
/** Inputs for checking close percentage bounds. */
|
|
150
|
+
type CheckClosePercentBoundsInput = {
|
|
151
|
+
closePercent: ClosePercent;
|
|
152
|
+
};
|
|
153
|
+
/** Checks whether leverage is within a market's min/max leverage bounds. */
|
|
154
|
+
declare function checkLeverageBounds(input: CheckLeverageBoundsInput): ConstraintCheckResult;
|
|
155
|
+
/** Checks whether notional value satisfies a market's minimum position size. */
|
|
156
|
+
declare function checkMinimumPositionSize(input: CheckMinimumPositionSizeInput): ConstraintCheckResult;
|
|
157
|
+
/** Checks whether collateral is at or below a market's maximum collateral limit. */
|
|
158
|
+
declare function checkMaxCollateral(input: CheckMaxCollateralInput): ConstraintCheckResult;
|
|
159
|
+
/** Checks whether requested notional would exceed side open-interest capacity. */
|
|
160
|
+
declare function checkOiCap(input: CheckOiCapInput): ConstraintCheckResult;
|
|
161
|
+
/** Checks whether requested collateral would exceed a market group's collateral cap. */
|
|
162
|
+
declare function checkGroupCollateralCap(input: CheckGroupCollateralCapInput): ConstraintCheckResult;
|
|
163
|
+
/** Checks whether slippage is within a market's maximum slippage percentage. */
|
|
164
|
+
declare function checkSlippageBounds(input: CheckSlippageBoundsInput): ConstraintCheckResult;
|
|
165
|
+
/** Validates close-percent raw bounds through the `ClosePercent` codec. */
|
|
166
|
+
declare function checkClosePercentBounds(input: CheckClosePercentBoundsInput): ConstraintCheckResult;
|
|
167
|
+
|
|
168
|
+
/** viem public client type accepted by the SDK. */
|
|
169
|
+
type PublicClient = viem.PublicClient;
|
|
170
|
+
/** viem wallet client type accepted by the SDK. */
|
|
171
|
+
type WalletClient = viem.WalletClient;
|
|
172
|
+
/** viem transaction receipt returned by wait helpers. */
|
|
173
|
+
type TransactionReceipt = viem.TransactionReceipt;
|
|
174
|
+
/** Onchain trading operation name used by prepared transaction and receipt helpers. */
|
|
175
|
+
type TradingVerb = "openMarket" | "openLimit" | "openStop" | "closeMarket" | "updateTakeProfit" | "updateStopLoss" | "topUpCollateral" | "removeCollateral" | "updateOpenLimitOrder" | "cancelOpenLimitOrder" | "handleTradeMarketTimeout";
|
|
176
|
+
/** Position direction for open trades. */
|
|
177
|
+
type TradeDirection = "long" | "short";
|
|
178
|
+
/** Runtime constants for trade direction values. */
|
|
179
|
+
declare const TradeDirection: {
|
|
180
|
+
readonly Long: "long";
|
|
181
|
+
readonly Short: "short";
|
|
182
|
+
};
|
|
183
|
+
/** Order kind accepted by open-trade parameters. */
|
|
184
|
+
type TradeOrderKind = "market" | "limit" | "stop";
|
|
185
|
+
/** Normalized order kind used by trading reads and helpers. */
|
|
186
|
+
type OrderKind = TradeOrderKind | "remove_collateral";
|
|
187
|
+
/** Runtime constants for normalized order kind values. */
|
|
188
|
+
declare const OrderKind: {
|
|
189
|
+
readonly Market: "market";
|
|
190
|
+
readonly Limit: "limit";
|
|
191
|
+
readonly Stop: "stop";
|
|
192
|
+
readonly RemoveCollateral: "remove_collateral";
|
|
193
|
+
};
|
|
194
|
+
/** Price input accepted by low-level trading helpers. */
|
|
195
|
+
type PriceInput = Price | DecimalInput;
|
|
196
|
+
/** Shared parameters for all open-trade variants. */
|
|
197
|
+
type OpenTradeBaseParams = {
|
|
198
|
+
pairIndex: PairIndex;
|
|
199
|
+
direction: TradeDirection;
|
|
200
|
+
collateral: Collateral | DecimalInput;
|
|
201
|
+
leverage: Leverage | DecimalInput;
|
|
202
|
+
takeProfit?: Price | DecimalInput;
|
|
203
|
+
stopLoss?: Price | DecimalInput;
|
|
204
|
+
referralCodeId?: ReferralCodeIdInput;
|
|
205
|
+
};
|
|
206
|
+
/** Market-open trade parameters. */
|
|
207
|
+
type OpenMarketParams = OpenTradeBaseParams & {
|
|
208
|
+
orderKind: "market";
|
|
209
|
+
slippage: SlippagePercent;
|
|
210
|
+
wantedPrice?: Price | DecimalInput;
|
|
211
|
+
entryPrice?: never;
|
|
212
|
+
triggerPrice?: never;
|
|
213
|
+
};
|
|
214
|
+
/** Limit-order open parameters. */
|
|
215
|
+
type OpenLimitParams = OpenTradeBaseParams & {
|
|
216
|
+
orderKind: "limit";
|
|
217
|
+
entryPrice: Price | DecimalInput;
|
|
218
|
+
executionSlippage?: never;
|
|
219
|
+
slippage?: never;
|
|
220
|
+
wantedPrice?: never;
|
|
221
|
+
triggerPrice?: never;
|
|
222
|
+
};
|
|
223
|
+
/** Stop-order open parameters. */
|
|
224
|
+
type OpenStopParams = OpenTradeBaseParams & {
|
|
225
|
+
orderKind: "stop";
|
|
226
|
+
triggerPrice: Price | DecimalInput;
|
|
227
|
+
executionSlippage?: never;
|
|
228
|
+
slippage?: never;
|
|
229
|
+
wantedPrice?: never;
|
|
230
|
+
entryPrice?: never;
|
|
231
|
+
};
|
|
232
|
+
/** Union of all open-trade parameter shapes, discriminated by `orderKind`. */
|
|
233
|
+
type OpenTradeParams = OpenMarketParams | OpenLimitParams | OpenStopParams;
|
|
234
|
+
/** Market-close parameters. */
|
|
235
|
+
type ClosePositionParams = {
|
|
236
|
+
closePercent?: ClosePercent;
|
|
237
|
+
slippage: SlippagePercent;
|
|
238
|
+
wantedPrice?: Price | DecimalInput;
|
|
239
|
+
};
|
|
240
|
+
/** Sentinel value that clears an existing take-profit or stop-loss trigger. */
|
|
241
|
+
type ClearTriggerValue = {
|
|
242
|
+
clear: true;
|
|
243
|
+
};
|
|
244
|
+
/** Trigger update value, either a concrete price or `{ clear: true }`. */
|
|
245
|
+
type TriggerValueInput = Price | DecimalInput | ClearTriggerValue;
|
|
246
|
+
/** Take-profit update parameters. */
|
|
247
|
+
type UpdateTakeProfitParams = {
|
|
248
|
+
takeProfit: TriggerValueInput;
|
|
249
|
+
};
|
|
250
|
+
/** Stop-loss update parameters. */
|
|
251
|
+
type UpdateStopLossParams = {
|
|
252
|
+
stopLoss: TriggerValueInput;
|
|
253
|
+
};
|
|
254
|
+
/** Collateral top-up parameters. */
|
|
255
|
+
type TopUpCollateralParams = {
|
|
256
|
+
collateral: Collateral | DecimalInput;
|
|
257
|
+
};
|
|
258
|
+
/** Collateral removal parameters. */
|
|
259
|
+
type RemoveCollateralParams = {
|
|
260
|
+
collateral: Collateral | DecimalInput;
|
|
261
|
+
};
|
|
262
|
+
/** Limit/stop trigger-order update parameters. */
|
|
263
|
+
type UpdateOpenTriggerOrderParams = {
|
|
264
|
+
targetPrice: Price | DecimalInput;
|
|
265
|
+
takeProfit?: TriggerValueInput;
|
|
266
|
+
stopLoss?: TriggerValueInput;
|
|
267
|
+
};
|
|
268
|
+
/** Options for direct, non-delegated transaction preparation. */
|
|
269
|
+
interface DirectPrepareOptions extends ReadOptions {
|
|
270
|
+
account?: Address;
|
|
271
|
+
delegation?: never;
|
|
272
|
+
}
|
|
273
|
+
/** Options for delegated transaction preparation. */
|
|
274
|
+
interface DelegatedPrepareOptions extends ReadOptions {
|
|
275
|
+
account?: Address;
|
|
276
|
+
delegation: DelegationTarget;
|
|
277
|
+
}
|
|
278
|
+
/** Preparation options for direct or delegated trading transactions. */
|
|
279
|
+
type PrepareOptions = DirectPrepareOptions | DelegatedPrepareOptions;
|
|
280
|
+
/** Simulation options for prepared trading transactions. */
|
|
281
|
+
type SimulateOptions = ReadOptions & {
|
|
282
|
+
account?: Address;
|
|
283
|
+
maxOracleFeeWei?: bigint;
|
|
284
|
+
};
|
|
285
|
+
/** Send options for trading transactions. */
|
|
286
|
+
type SendOptions = ReadOptions & {
|
|
287
|
+
account?: Address;
|
|
288
|
+
maxOracleFeeWei?: bigint;
|
|
289
|
+
gas?: bigint;
|
|
290
|
+
nonce?: number;
|
|
291
|
+
maxFeePerGas?: bigint;
|
|
292
|
+
skipApprovalCheck?: boolean;
|
|
293
|
+
};
|
|
294
|
+
/** Direct timeout-handler options. */
|
|
295
|
+
type DirectMarketTimeoutOptions = SendOptions & {
|
|
296
|
+
delegation?: never;
|
|
297
|
+
};
|
|
298
|
+
/** Delegated timeout-handler options. */
|
|
299
|
+
type DelegatedMarketTimeoutOptions = SendOptions & {
|
|
300
|
+
delegation: DelegationTarget;
|
|
301
|
+
};
|
|
302
|
+
/** Options for handling a timed-out market order. */
|
|
303
|
+
type MarketTimeoutOptions = DirectMarketTimeoutOptions | DelegatedMarketTimeoutOptions;
|
|
304
|
+
/** Send options for closing a position. */
|
|
305
|
+
type ClosePositionOptions = SendOptions;
|
|
306
|
+
/** Controls for waiting on transaction receipts. */
|
|
307
|
+
type WaitReceiptOptions = ReadOptions & {
|
|
308
|
+
confirmations?: number;
|
|
309
|
+
/**
|
|
310
|
+
* Receipt polling interval in milliseconds. Defaults to half the chain
|
|
311
|
+
* profile's `blockTimeMs` (1s on Base), falling back to 1s.
|
|
312
|
+
*
|
|
313
|
+
* Best-effort hint: concurrent waits on the same handle share one underlying
|
|
314
|
+
* wait per confirmation count, and the first caller's interval wins.
|
|
315
|
+
*/
|
|
316
|
+
pollingIntervalMs?: number;
|
|
317
|
+
};
|
|
318
|
+
/** REST/API tracking options for an order. */
|
|
319
|
+
type TrackOrderOptions = ReadOptions & {
|
|
320
|
+
/**
|
|
321
|
+
* Expected trader wallet for the order being tracked. When set, tracking
|
|
322
|
+
* returns `identity_mismatch` if the indexed order belongs to another wallet.
|
|
323
|
+
* This does not select the RPC sender.
|
|
324
|
+
*/
|
|
325
|
+
account?: Address;
|
|
326
|
+
intervalMs?: number;
|
|
327
|
+
maxAttempts?: number;
|
|
328
|
+
maxDurationMs?: number;
|
|
329
|
+
expectedTradeId?: TradeId;
|
|
330
|
+
};
|
|
331
|
+
/** Direct transaction recovery options. */
|
|
332
|
+
interface DirectRecoverTransactionOptions extends WaitReceiptOptions {
|
|
333
|
+
verb?: TradingVerb;
|
|
334
|
+
account?: Address;
|
|
335
|
+
delegation?: never;
|
|
336
|
+
pairIndex?: PairIndex;
|
|
337
|
+
initiatedTradeId?: TradeId;
|
|
338
|
+
terminalTradeId?: TradeId;
|
|
339
|
+
}
|
|
340
|
+
/** Delegated transaction recovery options. */
|
|
341
|
+
interface DelegatedRecoverTransactionOptions extends WaitReceiptOptions {
|
|
342
|
+
verb?: TradingVerb;
|
|
343
|
+
account?: never;
|
|
344
|
+
delegation: DelegationTarget;
|
|
345
|
+
pairIndex?: PairIndex;
|
|
346
|
+
initiatedTradeId?: TradeId;
|
|
347
|
+
terminalTradeId?: TradeId;
|
|
348
|
+
}
|
|
349
|
+
/** Options for recovering a transaction into an SDK handle. */
|
|
350
|
+
type RecoverTransactionOptions = DirectRecoverTransactionOptions | DelegatedRecoverTransactionOptions;
|
|
351
|
+
/** Options for tracking a transaction through receipt recovery and REST order polling. */
|
|
352
|
+
type ReceiptBackedTrackOptions = TrackOrderOptions & RecoverTransactionOptions;
|
|
353
|
+
/** ERC-20 approval state needed before a trading transaction can be sent. */
|
|
354
|
+
type ApprovalNeed = {
|
|
355
|
+
owner: Address;
|
|
356
|
+
token: Address;
|
|
357
|
+
spender: Address;
|
|
358
|
+
currentAllowance: Collateral;
|
|
359
|
+
requiredAllowance: Collateral;
|
|
360
|
+
action: "none" | "approve";
|
|
361
|
+
};
|
|
362
|
+
/** Non-fatal preflight warning produced while preparing a trading transaction. */
|
|
363
|
+
type PreflightWarning = {
|
|
364
|
+
code: string;
|
|
365
|
+
message: string;
|
|
366
|
+
severity: "info" | "warning" | "error";
|
|
367
|
+
};
|
|
368
|
+
/** Computed or externally sourced estimate returned by preflight. */
|
|
369
|
+
type ComputedEstimate<T> = {
|
|
370
|
+
value: T;
|
|
371
|
+
source: "computed" | "api" | "rpc";
|
|
372
|
+
parityTarget?: string;
|
|
373
|
+
};
|
|
374
|
+
|
|
375
|
+
/** Normalized action subset used by trading preflight reports. */
|
|
376
|
+
type NormalizedActionParams = {
|
|
377
|
+
kind: "openMarket";
|
|
378
|
+
params: OpenMarketParams;
|
|
379
|
+
} | {
|
|
380
|
+
kind: "closePosition";
|
|
381
|
+
params: ClosePositionParams;
|
|
382
|
+
} | {
|
|
383
|
+
kind: "removeCollateral";
|
|
384
|
+
params: RemoveCollateralParams;
|
|
385
|
+
};
|
|
386
|
+
/** Summary of a prepared trading transaction before simulation or send. */
|
|
387
|
+
type PreflightReport = {
|
|
388
|
+
normalizedParams?: NormalizedActionParams;
|
|
389
|
+
approvals: ApprovalNeed[];
|
|
390
|
+
oracleFeeWei?: bigint;
|
|
391
|
+
maxOracleFeeWei?: bigint;
|
|
392
|
+
executionPriceBounds?: {
|
|
393
|
+
min?: Price;
|
|
394
|
+
max?: Price;
|
|
395
|
+
};
|
|
396
|
+
estimatedLiquidationPrice?: Price;
|
|
397
|
+
estimatedOpeningFee?: ComputedEstimate<Collateral>;
|
|
398
|
+
estimatedClosingFee?: ComputedEstimate<Collateral>;
|
|
399
|
+
resultingLeverage?: ComputedEstimate<Leverage>;
|
|
400
|
+
checks?: ConstraintCheckResult[];
|
|
401
|
+
warnings: PreflightWarning[];
|
|
402
|
+
};
|
|
403
|
+
/** Simulation result for a prepared trading transaction. */
|
|
404
|
+
type SimResult = {
|
|
405
|
+
request: {
|
|
406
|
+
to: Address;
|
|
407
|
+
data: Hex;
|
|
408
|
+
value?: bigint;
|
|
409
|
+
account: Address;
|
|
410
|
+
};
|
|
411
|
+
gas?: bigint;
|
|
412
|
+
result?: unknown;
|
|
413
|
+
warnings: PreflightWarning[];
|
|
414
|
+
};
|
|
415
|
+
/** Handle for transactions whose terminal state is the transaction receipt itself. */
|
|
416
|
+
type ReceiptOnlyHandle = {
|
|
417
|
+
kind: "receipt";
|
|
418
|
+
hash: Hex;
|
|
419
|
+
/**
|
|
420
|
+
* @throws TimeoutError when receipt polling exceeds the configured timeout.
|
|
421
|
+
* @throws AbortError when the caller-provided signal aborts the wait.
|
|
422
|
+
* @throws TransportError for RPC transport failures.
|
|
423
|
+
*/
|
|
424
|
+
waitReceipt(opts?: WaitReceiptOptions): Promise<TransactionReceipt>;
|
|
425
|
+
};
|
|
426
|
+
/** Handle for open limit/stop placement transactions that can recover a verified order ref. */
|
|
427
|
+
type TriggerPlacementHandle = {
|
|
428
|
+
kind: "trigger_order";
|
|
429
|
+
hash: Hex;
|
|
430
|
+
/**
|
|
431
|
+
* @throws TimeoutError when receipt polling exceeds the configured timeout.
|
|
432
|
+
* @throws AbortError when the caller-provided signal aborts the wait.
|
|
433
|
+
* @throws TransportError for RPC transport failures.
|
|
434
|
+
*/
|
|
435
|
+
waitReceipt(opts?: WaitReceiptOptions): Promise<TransactionReceipt>;
|
|
436
|
+
/**
|
|
437
|
+
* @throws ValidationError when receipt logs do not contain a valid trigger placement identity.
|
|
438
|
+
* @throws TimeoutError or AbortError from receipt waiting.
|
|
439
|
+
*/
|
|
440
|
+
verifiedRef(opts?: WaitReceiptOptions): Promise<ReceiptVerifiedOpenTriggerOrderRef>;
|
|
441
|
+
};
|
|
442
|
+
/** RPC-only handle for async market orders where REST tracking is unavailable. */
|
|
443
|
+
type AsyncOrderHandleNoApi = {
|
|
444
|
+
kind: "async_order";
|
|
445
|
+
verb: "openMarket" | "closeMarket" | "removeCollateral";
|
|
446
|
+
hash: Hex;
|
|
447
|
+
/**
|
|
448
|
+
* @throws TimeoutError when receipt polling exceeds the configured timeout.
|
|
449
|
+
* @throws AbortError when the caller-provided signal aborts the wait.
|
|
450
|
+
* @throws TransportError for RPC transport failures.
|
|
451
|
+
*/
|
|
452
|
+
waitReceipt(opts?: WaitReceiptOptions): Promise<TransactionReceipt>;
|
|
453
|
+
/**
|
|
454
|
+
* @throws ValidationError when the receipt cannot be mapped to an order id.
|
|
455
|
+
* @throws TimeoutError or AbortError from receipt waiting.
|
|
456
|
+
*/
|
|
457
|
+
orderId(opts?: WaitReceiptOptions): Promise<OrderId>;
|
|
458
|
+
};
|
|
459
|
+
/** Order fields shared by REST-backed tracking results. */
|
|
460
|
+
type TrackResultOrderFields = {
|
|
461
|
+
order: OrderLifecycle;
|
|
462
|
+
removeCollateral?: RemoveCollateralTracking;
|
|
463
|
+
diagnostics?: DiagnosticsEnvelope;
|
|
464
|
+
};
|
|
465
|
+
/** Open position returned after tracking an executed open-market order. */
|
|
466
|
+
type OpenedPositionResult = OpenAccountPosition & {
|
|
467
|
+
verifiedRef: VerifiedPositionRef;
|
|
468
|
+
};
|
|
469
|
+
/** Terminal or intermediate tracking result for a market order. */
|
|
470
|
+
type TrackResult = ({
|
|
471
|
+
status: "pending_execution";
|
|
472
|
+
} & TrackResultOrderFields) | ({
|
|
473
|
+
status: "executed";
|
|
474
|
+
trade?: AccountTrade;
|
|
475
|
+
openedPosition?: OpenedPositionResult;
|
|
476
|
+
positionRef?: VerifiedPositionRef;
|
|
477
|
+
} & TrackResultOrderFields) | ({
|
|
478
|
+
status: "canceled";
|
|
479
|
+
reason?: number;
|
|
480
|
+
} & TrackResultOrderFields) | ({
|
|
481
|
+
status: "timeout_available";
|
|
482
|
+
canHandleTimeout: boolean;
|
|
483
|
+
} & TrackResultOrderFields) | ({
|
|
484
|
+
status: "timed_out";
|
|
485
|
+
} & TrackResultOrderFields) | ({
|
|
486
|
+
status: "identity_mismatch";
|
|
487
|
+
expectedTradeId?: TradeId;
|
|
488
|
+
actualTradeId?: TradeId;
|
|
489
|
+
expectedPairIndex?: PairIndex;
|
|
490
|
+
actualPairIndex?: PairIndex;
|
|
491
|
+
expectedWallet?: Address;
|
|
492
|
+
actualWallet?: Address;
|
|
493
|
+
} & TrackResultOrderFields) | {
|
|
494
|
+
status: "unknown";
|
|
495
|
+
order?: OrderLifecycle;
|
|
496
|
+
removeCollateral?: RemoveCollateralTracking;
|
|
497
|
+
diagnostics?: DiagnosticsEnvelope;
|
|
498
|
+
};
|
|
499
|
+
/** Phases emitted while watching a transaction/order lifecycle. */
|
|
500
|
+
type LifecyclePhase = "submitted" | "mined" | "indexed" | "tracking" | "terminal" | "unknown";
|
|
501
|
+
/** Lifecycle state emitted by `AsyncOrderHandle.watch`. */
|
|
502
|
+
type LifecycleState = {
|
|
503
|
+
phase: "submitted";
|
|
504
|
+
hash: Hex;
|
|
505
|
+
} | {
|
|
506
|
+
phase: "mined";
|
|
507
|
+
hash: Hex;
|
|
508
|
+
receipt: TransactionReceipt;
|
|
509
|
+
} | {
|
|
510
|
+
phase: "indexed";
|
|
511
|
+
hash: Hex;
|
|
512
|
+
orderId: OrderId;
|
|
513
|
+
} | {
|
|
514
|
+
phase: "tracking";
|
|
515
|
+
hash: Hex;
|
|
516
|
+
orderId: OrderId;
|
|
517
|
+
result: TrackResult;
|
|
518
|
+
} | {
|
|
519
|
+
phase: "terminal";
|
|
520
|
+
hash: Hex;
|
|
521
|
+
orderId: OrderId;
|
|
522
|
+
result: TrackResult;
|
|
523
|
+
} | {
|
|
524
|
+
phase: "unknown";
|
|
525
|
+
hash: Hex;
|
|
526
|
+
orderId?: OrderId;
|
|
527
|
+
result?: TrackResult;
|
|
528
|
+
};
|
|
529
|
+
/** REST-backed async order handle with tracking and lifecycle watching. */
|
|
530
|
+
type AsyncOrderHandle = AsyncOrderHandleNoApi & {
|
|
531
|
+
/**
|
|
532
|
+
* @throws ReadModelNotReadyError when strict readiness rejects order tracking reads.
|
|
533
|
+
* @throws ValidationError for invalid tracking options or inconsistent transaction identity.
|
|
534
|
+
* @throws TimeoutError or AbortError when polling is timed out or aborted.
|
|
535
|
+
* @throws ApiError or TransportError for read/transport failures.
|
|
536
|
+
*/
|
|
537
|
+
track(opts?: ReceiptBackedTrackOptions): Promise<TrackResult>;
|
|
538
|
+
/**
|
|
539
|
+
* @throws ReadModelNotReadyError, ValidationError, TimeoutError, AbortError, ApiError, or TransportError from transaction tracking.
|
|
540
|
+
*/
|
|
541
|
+
waitTerminal(opts?: ReceiptBackedTrackOptions): Promise<TrackResult>;
|
|
542
|
+
/**
|
|
543
|
+
* @throws ValidationError for invalid watch options.
|
|
544
|
+
*/
|
|
545
|
+
watch(opts?: ReceiptBackedTrackOptions): AsyncIterable<LifecycleState>;
|
|
546
|
+
};
|
|
547
|
+
/** Any transaction handle returned by an API-enabled trading client. */
|
|
548
|
+
type TxHandle = AsyncOrderHandle | TriggerPlacementHandle | ReceiptOnlyHandle;
|
|
549
|
+
/** Any transaction handle returned by an RPC-only trading client. */
|
|
550
|
+
type TxHandleNoApi = AsyncOrderHandleNoApi | TriggerPlacementHandle | ReceiptOnlyHandle;
|
|
551
|
+
/** Transaction handle returned for a specific trading verb on API-enabled clients. */
|
|
552
|
+
type TxHandleForVerb<Verb extends TradingVerb> = Verb extends "openMarket" | "closeMarket" | "removeCollateral" ? AsyncOrderHandle : Verb extends "openLimit" | "openStop" ? TriggerPlacementHandle : ReceiptOnlyHandle;
|
|
553
|
+
/** Transaction handle returned for a specific trading verb on RPC-only clients. */
|
|
554
|
+
type TxHandleForVerbNoApi<Verb extends TradingVerb> = Verb extends "openMarket" | "closeMarket" | "removeCollateral" ? AsyncOrderHandleNoApi : Verb extends "openLimit" | "openStop" ? TriggerPlacementHandle : ReceiptOnlyHandle;
|
|
555
|
+
/** Prepared trading transaction that can be summarized, simulated, or sent. */
|
|
556
|
+
type PreparedTradingTx<Verb extends TradingVerb> = {
|
|
557
|
+
verb: Verb;
|
|
558
|
+
to: Address;
|
|
559
|
+
data: Hex;
|
|
560
|
+
value?: bigint;
|
|
561
|
+
preparedAccount?: Address;
|
|
562
|
+
estimatedOracleFeeWei?: bigint;
|
|
563
|
+
requiredApprovals: {
|
|
564
|
+
status: "checked";
|
|
565
|
+
approvals: ApprovalNeed[];
|
|
566
|
+
} | {
|
|
567
|
+
status: "unchecked";
|
|
568
|
+
};
|
|
569
|
+
/**
|
|
570
|
+
* Returns the preflight summary for this prepared transaction.
|
|
571
|
+
*
|
|
572
|
+
* @throws ValidationError when prepared transaction parameters cannot be summarized.
|
|
573
|
+
*/
|
|
574
|
+
summary(): Promise<PreflightReport>;
|
|
575
|
+
/**
|
|
576
|
+
* Simulates the prepared transaction.
|
|
577
|
+
*
|
|
578
|
+
* @throws ValidationError, MissingPublicClientError, TimeoutError, AbortError, OracleFeeCapExceededError, ContractRevertError, or TransportError during simulation.
|
|
579
|
+
*/
|
|
580
|
+
simulate(opts?: SimulateOptions): Promise<SimResult>;
|
|
581
|
+
/**
|
|
582
|
+
* Sends the prepared transaction with the SDK-configured wallet client.
|
|
583
|
+
*
|
|
584
|
+
* @throws ValidationError, MissingWalletClientError, MissingPublicClientError, TimeoutError, AbortError, ContractRevertError, or wallet/transport SDK errors.
|
|
585
|
+
*/
|
|
586
|
+
send(opts?: SendOptions): Promise<TxHandleForVerb<Verb>>;
|
|
587
|
+
/**
|
|
588
|
+
* Sends the prepared transaction with an explicit wallet client.
|
|
589
|
+
*
|
|
590
|
+
* @throws ValidationError, MissingWalletClientError, MissingPublicClientError, TimeoutError, AbortError, ContractRevertError, or wallet/transport SDK errors.
|
|
591
|
+
*/
|
|
592
|
+
send(walletClient: WalletClient, opts?: SendOptions): Promise<TxHandleForVerb<Verb>>;
|
|
593
|
+
};
|
|
594
|
+
/** Prepared trading transaction returned by RPC-only clients. */
|
|
595
|
+
type PreparedTradingTxNoApi<Verb extends TradingVerb> = Omit<PreparedTradingTx<Verb>, "send"> & {
|
|
596
|
+
/**
|
|
597
|
+
* Sends the prepared transaction with the SDK-configured wallet client.
|
|
598
|
+
*
|
|
599
|
+
* @throws ValidationError, MissingWalletClientError, MissingPublicClientError, TimeoutError, AbortError, ContractRevertError, or wallet/transport SDK errors.
|
|
600
|
+
*/
|
|
601
|
+
send(opts?: SendOptions): Promise<TxHandleForVerbNoApi<Verb>>;
|
|
602
|
+
/**
|
|
603
|
+
* Sends the prepared transaction with an explicit wallet client.
|
|
604
|
+
*
|
|
605
|
+
* @throws ValidationError, MissingWalletClientError, MissingPublicClientError, TimeoutError, AbortError, ContractRevertError, or wallet/transport SDK errors.
|
|
606
|
+
*/
|
|
607
|
+
send(walletClient: WalletClient, opts?: SendOptions): Promise<TxHandleForVerbNoApi<Verb>>;
|
|
608
|
+
};
|
|
609
|
+
/** Order identity needed to call the market-timeout handler. */
|
|
610
|
+
type TrackableMarketOrderRef = {
|
|
611
|
+
orderId: OrderId;
|
|
612
|
+
wallet: Address;
|
|
613
|
+
pairIndex: PairIndex;
|
|
614
|
+
expectedTradeId?: TradeId;
|
|
615
|
+
initiatedTxHash?: Hex;
|
|
616
|
+
};
|
|
617
|
+
/** Full trading client with transaction preparation, sending, and REST-backed tracking. */
|
|
618
|
+
type TradingClient = {
|
|
619
|
+
/**
|
|
620
|
+
* Prepares a market-open transaction.
|
|
621
|
+
*
|
|
622
|
+
* @throws ValidationError, ReadModelNotReadyError, TimeoutError, AbortError, or transport/wallet SDK errors during preflight reads.
|
|
623
|
+
*/
|
|
624
|
+
prepareOpenTrade(params: OpenMarketParams, opts?: PrepareOptions): Promise<PreparedTradingTx<"openMarket">>;
|
|
625
|
+
/**
|
|
626
|
+
* Prepares a limit-open order placement transaction.
|
|
627
|
+
*
|
|
628
|
+
* @throws ValidationError, ReadModelNotReadyError, TimeoutError, AbortError, or transport/wallet SDK errors during preflight reads.
|
|
629
|
+
*/
|
|
630
|
+
prepareOpenTrade(params: OpenLimitParams, opts?: PrepareOptions): Promise<PreparedTradingTx<"openLimit">>;
|
|
631
|
+
/**
|
|
632
|
+
* Prepares a stop-open order placement transaction.
|
|
633
|
+
*
|
|
634
|
+
* @throws ValidationError, ReadModelNotReadyError, TimeoutError, AbortError, or transport/wallet SDK errors during preflight reads.
|
|
635
|
+
*/
|
|
636
|
+
prepareOpenTrade(params: OpenStopParams, opts?: PrepareOptions): Promise<PreparedTradingTx<"openStop">>;
|
|
637
|
+
/**
|
|
638
|
+
* Prepares a market-close transaction for a verified position.
|
|
639
|
+
*
|
|
640
|
+
* @throws ValidationError, ReadModelNotReadyError, TimeoutError, AbortError, or transport/wallet SDK errors during preflight reads.
|
|
641
|
+
*/
|
|
642
|
+
prepareClosePosition(position: VerifiedPositionRef, params: ClosePositionParams, opts?: PrepareOptions): Promise<PreparedTradingTx<"closeMarket">>;
|
|
643
|
+
/**
|
|
644
|
+
* Prepares a take-profit update transaction for a verified position.
|
|
645
|
+
*
|
|
646
|
+
* @throws ValidationError, ReadModelNotReadyError, TimeoutError, AbortError, or transport/wallet SDK errors during preflight reads.
|
|
647
|
+
*/
|
|
648
|
+
prepareUpdateTakeProfit(position: VerifiedPositionRef, params: UpdateTakeProfitParams, opts?: PrepareOptions): Promise<PreparedTradingTx<"updateTakeProfit">>;
|
|
649
|
+
/**
|
|
650
|
+
* Prepares a stop-loss update transaction for a verified position.
|
|
651
|
+
*
|
|
652
|
+
* @throws ValidationError, ReadModelNotReadyError, TimeoutError, AbortError, or transport/wallet SDK errors during preflight reads.
|
|
653
|
+
*/
|
|
654
|
+
prepareUpdateStopLoss(position: VerifiedPositionRef, params: UpdateStopLossParams, opts?: PrepareOptions): Promise<PreparedTradingTx<"updateStopLoss">>;
|
|
655
|
+
/**
|
|
656
|
+
* Prepares a collateral top-up transaction for a verified position.
|
|
657
|
+
*
|
|
658
|
+
* @throws ValidationError, ReadModelNotReadyError, TimeoutError, AbortError, or transport/wallet SDK errors during preflight reads.
|
|
659
|
+
*/
|
|
660
|
+
prepareTopUpCollateral(position: VerifiedPositionRef, params: TopUpCollateralParams, opts?: PrepareOptions): Promise<PreparedTradingTx<"topUpCollateral">>;
|
|
661
|
+
/**
|
|
662
|
+
* Prepares a collateral removal transaction for a verified position.
|
|
663
|
+
*
|
|
664
|
+
* @throws ValidationError, ReadModelNotReadyError, TimeoutError, AbortError, or transport/wallet SDK errors during preflight reads.
|
|
665
|
+
*/
|
|
666
|
+
prepareRemoveCollateral(position: VerifiedPositionRef, params: RemoveCollateralParams, opts?: PrepareOptions): Promise<PreparedTradingTx<"removeCollateral">>;
|
|
667
|
+
/**
|
|
668
|
+
* Prepares an open limit/stop trigger-order update transaction.
|
|
669
|
+
*
|
|
670
|
+
* @throws ValidationError, ReadModelNotReadyError, TimeoutError, AbortError, or transport/wallet SDK errors during preflight reads.
|
|
671
|
+
*/
|
|
672
|
+
prepareUpdateOpenLimitOrder(order: VerifiedOpenTriggerOrderRef, params: UpdateOpenTriggerOrderParams, opts?: PrepareOptions): Promise<PreparedTradingTx<"updateOpenLimitOrder">>;
|
|
673
|
+
/**
|
|
674
|
+
* Prepares an open limit/stop trigger-order cancellation transaction.
|
|
675
|
+
*
|
|
676
|
+
* @throws ValidationError, ReadModelNotReadyError, TimeoutError, AbortError, or transport/wallet SDK errors during preflight reads.
|
|
677
|
+
*/
|
|
678
|
+
prepareCancelOpenLimitOrder(order: VerifiedOpenTriggerOrderRef, opts?: PrepareOptions): Promise<PreparedTradingTx<"cancelOpenLimitOrder">>;
|
|
679
|
+
/**
|
|
680
|
+
* Handles a market order whose timeout is available.
|
|
681
|
+
*
|
|
682
|
+
* @throws ValidationError, TimeoutError, AbortError, ContractRevertError, or transport/wallet SDK errors.
|
|
683
|
+
*/
|
|
684
|
+
handleTradeMarketTimeout(order: TrackableMarketOrderRef, opts?: MarketTimeoutOptions): Promise<ReceiptOnlyHandle>;
|
|
685
|
+
/**
|
|
686
|
+
* Tracks an order lifecycle by order id.
|
|
687
|
+
*
|
|
688
|
+
* @throws ReadModelNotReadyError, ValidationError, TimeoutError, AbortError, ApiError, or TransportError.
|
|
689
|
+
*/
|
|
690
|
+
trackOrder(orderId: OrderId, opts?: TrackOrderOptions): Promise<TrackResult>;
|
|
691
|
+
/**
|
|
692
|
+
* Recovers an SDK transaction handle from a transaction hash.
|
|
693
|
+
*
|
|
694
|
+
* @throws ValidationError, TimeoutError, AbortError, or TransportError while recovering receipt-backed state.
|
|
695
|
+
*/
|
|
696
|
+
recoverTransaction(hash: Hex, opts?: RecoverTransactionOptions): Promise<TxHandle>;
|
|
697
|
+
/**
|
|
698
|
+
* Recovers and tracks a transaction hash through REST order state.
|
|
699
|
+
*
|
|
700
|
+
* @throws ReadModelNotReadyError, ValidationError, TimeoutError, AbortError, ApiError, or TransportError.
|
|
701
|
+
*/
|
|
702
|
+
trackTransaction(hash: Hex, opts?: ReceiptBackedTrackOptions): Promise<TrackResult>;
|
|
703
|
+
};
|
|
704
|
+
/** RPC-only trading client without REST order tracking helpers. */
|
|
705
|
+
type TradingClientNoApi = {
|
|
706
|
+
/**
|
|
707
|
+
* Prepares a market-open transaction without REST tracking support.
|
|
708
|
+
*
|
|
709
|
+
* @throws ValidationError, MissingPublicClientError, TimeoutError, AbortError, or transport SDK errors during preflight reads.
|
|
710
|
+
*/
|
|
711
|
+
prepareOpenTrade(params: OpenMarketParams, opts?: PrepareOptions): Promise<PreparedTradingTxNoApi<"openMarket">>;
|
|
712
|
+
/**
|
|
713
|
+
* Prepares a limit-open order placement transaction without REST tracking support.
|
|
714
|
+
*
|
|
715
|
+
* @throws ValidationError, MissingPublicClientError, TimeoutError, AbortError, or transport SDK errors during preflight reads.
|
|
716
|
+
*/
|
|
717
|
+
prepareOpenTrade(params: OpenLimitParams, opts?: PrepareOptions): Promise<PreparedTradingTxNoApi<"openLimit">>;
|
|
718
|
+
/**
|
|
719
|
+
* Prepares a stop-open order placement transaction without REST tracking support.
|
|
720
|
+
*
|
|
721
|
+
* @throws ValidationError, MissingPublicClientError, TimeoutError, AbortError, or transport SDK errors during preflight reads.
|
|
722
|
+
*/
|
|
723
|
+
prepareOpenTrade(params: OpenStopParams, opts?: PrepareOptions): Promise<PreparedTradingTxNoApi<"openStop">>;
|
|
724
|
+
/**
|
|
725
|
+
* Prepares a market-close transaction without REST tracking support.
|
|
726
|
+
*
|
|
727
|
+
* @throws ValidationError, MissingPublicClientError, TimeoutError, AbortError, or transport SDK errors during preflight reads.
|
|
728
|
+
*/
|
|
729
|
+
prepareClosePosition(position: VerifiedPositionRef, params: ClosePositionParams, opts?: PrepareOptions): Promise<PreparedTradingTxNoApi<"closeMarket">>;
|
|
730
|
+
/**
|
|
731
|
+
* Prepares a take-profit update transaction without REST tracking support.
|
|
732
|
+
*
|
|
733
|
+
* @throws ValidationError, MissingPublicClientError, TimeoutError, AbortError, or transport SDK errors during preflight reads.
|
|
734
|
+
*/
|
|
735
|
+
prepareUpdateTakeProfit(position: VerifiedPositionRef, params: UpdateTakeProfitParams, opts?: PrepareOptions): Promise<PreparedTradingTxNoApi<"updateTakeProfit">>;
|
|
736
|
+
/**
|
|
737
|
+
* Prepares a stop-loss update transaction without REST tracking support.
|
|
738
|
+
*
|
|
739
|
+
* @throws ValidationError, MissingPublicClientError, TimeoutError, AbortError, or transport SDK errors during preflight reads.
|
|
740
|
+
*/
|
|
741
|
+
prepareUpdateStopLoss(position: VerifiedPositionRef, params: UpdateStopLossParams, opts?: PrepareOptions): Promise<PreparedTradingTxNoApi<"updateStopLoss">>;
|
|
742
|
+
/**
|
|
743
|
+
* Prepares a collateral top-up transaction without REST tracking support.
|
|
744
|
+
*
|
|
745
|
+
* @throws ValidationError, MissingPublicClientError, TimeoutError, AbortError, or transport SDK errors during preflight reads.
|
|
746
|
+
*/
|
|
747
|
+
prepareTopUpCollateral(position: VerifiedPositionRef, params: TopUpCollateralParams, opts?: PrepareOptions): Promise<PreparedTradingTxNoApi<"topUpCollateral">>;
|
|
748
|
+
/**
|
|
749
|
+
* Prepares a collateral removal transaction without REST tracking support.
|
|
750
|
+
*
|
|
751
|
+
* @throws ValidationError, MissingPublicClientError, TimeoutError, AbortError, or transport SDK errors during preflight reads.
|
|
752
|
+
*/
|
|
753
|
+
prepareRemoveCollateral(position: VerifiedPositionRef, params: RemoveCollateralParams, opts?: PrepareOptions): Promise<PreparedTradingTxNoApi<"removeCollateral">>;
|
|
754
|
+
/**
|
|
755
|
+
* Prepares an open limit/stop trigger-order update without REST tracking support.
|
|
756
|
+
*
|
|
757
|
+
* @throws ValidationError, MissingPublicClientError, TimeoutError, AbortError, or transport SDK errors during preflight reads.
|
|
758
|
+
*/
|
|
759
|
+
prepareUpdateOpenLimitOrder(order: VerifiedOpenTriggerOrderRef, params: UpdateOpenTriggerOrderParams, opts?: PrepareOptions): Promise<PreparedTradingTxNoApi<"updateOpenLimitOrder">>;
|
|
760
|
+
/**
|
|
761
|
+
* Prepares an open limit/stop trigger-order cancellation without REST tracking support.
|
|
762
|
+
*
|
|
763
|
+
* @throws ValidationError, MissingPublicClientError, TimeoutError, AbortError, or transport SDK errors during preflight reads.
|
|
764
|
+
*/
|
|
765
|
+
prepareCancelOpenLimitOrder(order: VerifiedOpenTriggerOrderRef, opts?: PrepareOptions): Promise<PreparedTradingTxNoApi<"cancelOpenLimitOrder">>;
|
|
766
|
+
/**
|
|
767
|
+
* Handles a market order timeout without REST tracking support.
|
|
768
|
+
*
|
|
769
|
+
* @throws ValidationError, MissingWalletClientError, MissingPublicClientError, TimeoutError, AbortError, ContractRevertError, or transport/wallet SDK errors.
|
|
770
|
+
*/
|
|
771
|
+
handleTradeMarketTimeout(order: TrackableMarketOrderRef, opts?: MarketTimeoutOptions): Promise<ReceiptOnlyHandle>;
|
|
772
|
+
/**
|
|
773
|
+
* Recovers an RPC-only SDK transaction handle from a transaction hash.
|
|
774
|
+
*
|
|
775
|
+
* @throws ValidationError, MissingPublicClientError, TimeoutError, AbortError, or TransportError while recovering receipt-backed state.
|
|
776
|
+
*/
|
|
777
|
+
recoverTransaction(hash: Hex, opts?: RecoverTransactionOptions): Promise<TxHandleNoApi>;
|
|
778
|
+
};
|
|
779
|
+
|
|
780
|
+
export { type TradingVerb as $, type ApprovalNeed as A, type PrepareOptions as B, type ClearTriggerValue as C, type DelegationTarget as D, type PreparedTradingTx as E, type PreparedTradingTxNoApi as F, type PriceInput as G, type ReceiptBackedTrackOptions as H, type RecoverTransactionOptions as I, type RemoveCollateralParams as J, type SimResult as K, type LifecyclePhase as L, type MarketTimeoutOptions as M, type NormalizedActionParams as N, type OpenLimitParams as O, type PublicClient as P, type SimulateOptions as Q, type ReceiptOnlyHandle as R, type SendOptions as S, type TransactionReceipt as T, type TopUpCollateralParams as U, type TrackOrderOptions as V, type WaitReceiptOptions as W, type TrackResultOrderFields as X, type TrackableMarketOrderRef as Y, TradeDirection as Z, type TradeOrderKind as _, type TrackResult as a, type TriggerPlacementHandle as a0, type TriggerValueInput as a1, type TxHandle as a2, type TxHandleForVerb as a3, type TxHandleForVerbNoApi as a4, type TxHandleNoApi as a5, type UpdateOpenTriggerOrderParams as a6, type UpdateStopLossParams as a7, type UpdateTakeProfitParams as a8, type CheckClosePercentBoundsInput as a9, type CheckGroupCollateralCapInput as aa, type CheckLeverageBoundsInput as ab, type CheckMaxCollateralInput as ac, type CheckMinimumPositionSizeInput as ad, type CheckOiCapInput as ae, type CheckSlippageBoundsInput as af, checkClosePercentBounds as ag, checkGroupCollateralCap as ah, checkLeverageBounds as ai, checkMaxCollateral as aj, checkMinimumPositionSize as ak, checkOiCap as al, checkSlippageBounds as am, type DelegationReadOptions as an, type DelegationSendOptions as ao, type DelegationTypedData as ap, type DelegationTypedDataOptions as aq, type DelegationTypedDataParams as ar, type SignedDelegation as as, type WalletClient as b, type DelegationClient as c, type TradingClient as d, type TradingClientNoApi as e, type AsyncOrderHandle as f, type AsyncOrderHandleNoApi as g, type ClosePositionOptions as h, type ClosePositionParams as i, type ComputedEstimate as j, type ConstraintCheckResult as k, type DelegatedMarketTimeoutOptions as l, type DelegatedPrepareOptions as m, type DelegatedRecoverTransactionOptions as n, type DirectMarketTimeoutOptions as o, type DirectPrepareOptions as p, type DirectRecoverTransactionOptions as q, type LifecycleState as r, type OpenMarketParams as s, type OpenStopParams as t, type OpenTradeBaseParams as u, type OpenTradeParams as v, type OpenedPositionResult as w, OrderKind as x, type PreflightReport as y, type PreflightWarning as z };
|