@lifi/perps-types 4.0.0 → 4.0.1
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/cjs/account.d.ts.map +1 -1
- package/dist/cjs/action.d.ts +1 -0
- package/dist/cjs/action.d.ts.map +1 -1
- package/dist/cjs/asset.d.ts.map +1 -1
- package/dist/cjs/enums.d.ts.map +1 -1
- package/dist/cjs/enums.js.map +1 -1
- package/dist/cjs/errors.d.ts.map +1 -1
- package/dist/cjs/market.d.ts.map +1 -1
- package/dist/cjs/primitives.d.ts.map +1 -1
- package/dist/cjs/providers.d.ts.map +1 -1
- package/dist/cjs/subscriptions.d.ts.map +1 -1
- package/dist/cjs/typedData.d.ts.map +1 -1
- package/dist/cjs/vote.d.ts.map +1 -1
- package/dist/cjs/vote.js.map +1 -1
- package/dist/esm/account.d.ts +194 -31
- package/dist/esm/account.d.ts.map +1 -1
- package/dist/esm/action.d.ts +205 -37
- package/dist/esm/action.d.ts.map +1 -1
- package/dist/esm/asset.d.ts +1 -4
- package/dist/esm/asset.d.ts.map +1 -1
- package/dist/esm/enums.d.ts +34 -20
- package/dist/esm/enums.d.ts.map +1 -1
- package/dist/esm/enums.js +33 -19
- package/dist/esm/enums.js.map +1 -1
- package/dist/esm/errors.d.ts +6 -1
- package/dist/esm/errors.d.ts.map +1 -1
- package/dist/esm/market.d.ts +47 -14
- package/dist/esm/market.d.ts.map +1 -1
- package/dist/esm/primitives.d.ts +12 -2
- package/dist/esm/primitives.d.ts.map +1 -1
- package/dist/esm/providers.d.ts +19 -6
- package/dist/esm/providers.d.ts.map +1 -1
- package/dist/esm/quote.d.ts +2 -2
- package/dist/esm/quote.d.ts.map +1 -1
- package/dist/esm/subscriptions.d.ts +27 -19
- package/dist/esm/subscriptions.d.ts.map +1 -1
- package/dist/esm/typedData.d.ts +15 -5
- package/dist/esm/typedData.d.ts.map +1 -1
- package/dist/esm/vote.d.ts +1 -3
- package/dist/esm/vote.d.ts.map +1 -1
- package/dist/esm/vote.js.map +1 -1
- package/dist/types/account.d.ts +194 -31
- package/dist/types/account.d.ts.map +1 -1
- package/dist/types/action.d.ts +205 -37
- package/dist/types/action.d.ts.map +1 -1
- package/dist/types/asset.d.ts +1 -4
- package/dist/types/asset.d.ts.map +1 -1
- package/dist/types/enums.d.ts +34 -20
- package/dist/types/enums.d.ts.map +1 -1
- package/dist/types/errors.d.ts +6 -1
- package/dist/types/errors.d.ts.map +1 -1
- package/dist/types/market.d.ts +47 -14
- package/dist/types/market.d.ts.map +1 -1
- package/dist/types/primitives.d.ts +12 -2
- package/dist/types/primitives.d.ts.map +1 -1
- package/dist/types/providers.d.ts +19 -6
- package/dist/types/providers.d.ts.map +1 -1
- package/dist/types/quote.d.ts +2 -2
- package/dist/types/quote.d.ts.map +1 -1
- package/dist/types/subscriptions.d.ts +27 -19
- package/dist/types/subscriptions.d.ts.map +1 -1
- package/dist/types/typedData.d.ts +15 -5
- package/dist/types/typedData.d.ts.map +1 -1
- package/dist/types/vote.d.ts +1 -3
- package/dist/types/vote.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/account.ts +194 -36
- package/src/action.ts +205 -37
- package/src/asset.ts +1 -4
- package/src/enums.ts +34 -20
- package/src/errors.ts +6 -1
- package/src/market.ts +47 -14
- package/src/primitives.ts +12 -2
- package/src/providers.ts +19 -6
- package/src/quote.ts +2 -2
- package/src/subscriptions.ts +27 -19
- package/src/typedData.ts +15 -5
- package/src/vote.ts +1 -3
package/src/action.ts
CHANGED
|
@@ -14,13 +14,22 @@ import type { Address, Hex } from './primitives.js'
|
|
|
14
14
|
import type { PerpsTypedData } from './typedData.js'
|
|
15
15
|
import type { VoteParams } from './vote.js'
|
|
16
16
|
|
|
17
|
-
/**
|
|
17
|
+
/**
|
|
18
|
+
* Unsigned EIP-712 action step containing typed data for client signing.
|
|
19
|
+
*
|
|
20
|
+
* @public
|
|
21
|
+
*/
|
|
18
22
|
export interface Eip712ActionStep {
|
|
19
23
|
action: ActionType
|
|
20
24
|
typedData: PerpsTypedData
|
|
21
25
|
}
|
|
22
26
|
|
|
23
|
-
/**
|
|
27
|
+
/**
|
|
28
|
+
* Unsigned WASM-blob action step containing provider-specific signing
|
|
29
|
+
* parameters for the client.
|
|
30
|
+
*
|
|
31
|
+
* @public
|
|
32
|
+
*/
|
|
24
33
|
export interface WasmBlobActionStep {
|
|
25
34
|
action: ActionType
|
|
26
35
|
wasmSignParams: Record<string, unknown>
|
|
@@ -37,12 +46,18 @@ export interface EvmCall {
|
|
|
37
46
|
chainId: number
|
|
38
47
|
to: Address
|
|
39
48
|
functionName: string
|
|
49
|
+
/** Function arguments supplied to the contract call in declaration order. */
|
|
40
50
|
args: readonly unknown[]
|
|
41
51
|
/** Human-readable ABI signatures, e.g. `'function approve(address,uint256) returns (bool)'`, fed to viem `parseAbi`. */
|
|
42
52
|
abi: readonly string[]
|
|
43
53
|
}
|
|
44
54
|
|
|
45
|
-
/**
|
|
55
|
+
/**
|
|
56
|
+
* Unsigned EVM transaction action step. `txParams` describes the call that the
|
|
57
|
+
* client encodes and submits.
|
|
58
|
+
*
|
|
59
|
+
* @public
|
|
60
|
+
*/
|
|
46
61
|
export interface EvmTxActionStep {
|
|
47
62
|
action: ActionType
|
|
48
63
|
txParams: EvmCall
|
|
@@ -78,12 +93,20 @@ export interface HmacActionStep {
|
|
|
78
93
|
* @public
|
|
79
94
|
*/
|
|
80
95
|
export interface CreateDepositAddressSessionMarker {
|
|
96
|
+
/** Source network for the provider deposit address. */
|
|
81
97
|
network: 'ethereum'
|
|
98
|
+
/** Deposit asset symbol; currently constrained to USDC. */
|
|
82
99
|
symbol: 'USDC'
|
|
100
|
+
/** Provider wallet destination policy; currently constrained to margin. */
|
|
83
101
|
depositDestination: { wallet: 'margin' }
|
|
84
102
|
}
|
|
85
103
|
|
|
86
|
-
/**
|
|
104
|
+
/**
|
|
105
|
+
* Client-only session action step, with a provider session request marker or
|
|
106
|
+
* an empty session payload for actions that do not need one.
|
|
107
|
+
*
|
|
108
|
+
* @public
|
|
109
|
+
*/
|
|
87
110
|
export type SessionActionStep =
|
|
88
111
|
| {
|
|
89
112
|
action: Exclude<ActionType, ActionType.CREATE_DEPOSIT_ADDRESS>
|
|
@@ -94,17 +117,26 @@ export type SessionActionStep =
|
|
|
94
117
|
session: CreateDepositAddressSessionMarker
|
|
95
118
|
}
|
|
96
119
|
|
|
97
|
-
/**
|
|
120
|
+
/**
|
|
121
|
+
* Unsigned SIWE action step containing the backend-issued login challenge.
|
|
122
|
+
*
|
|
123
|
+
* @public
|
|
124
|
+
*/
|
|
98
125
|
export interface SiweActionStep {
|
|
99
126
|
action: ActionType
|
|
100
127
|
siwe: {
|
|
128
|
+
/** Backend identifier for the SIWE challenge. */
|
|
101
129
|
challengeId: string
|
|
102
130
|
/** The backend-built ERC-4361 challenge the wallet must `personal_sign`. */
|
|
103
131
|
message: string
|
|
104
132
|
}
|
|
105
133
|
}
|
|
106
134
|
|
|
107
|
-
/**
|
|
135
|
+
/**
|
|
136
|
+
* Union of all unsigned action-step encodings produced by `createAction`.
|
|
137
|
+
*
|
|
138
|
+
* @public
|
|
139
|
+
*/
|
|
108
140
|
export type ActionStep =
|
|
109
141
|
| Eip712ActionStep
|
|
110
142
|
| WasmBlobActionStep
|
|
@@ -113,14 +145,22 @@ export type ActionStep =
|
|
|
113
145
|
| SessionActionStep
|
|
114
146
|
| SiweActionStep
|
|
115
147
|
|
|
116
|
-
/**
|
|
148
|
+
/**
|
|
149
|
+
* Signed EIP-712 action step ready for backend execution.
|
|
150
|
+
*
|
|
151
|
+
* @public
|
|
152
|
+
*/
|
|
117
153
|
export interface Eip712SignedActionStep {
|
|
118
154
|
action: ActionType
|
|
119
155
|
typedData: PerpsTypedData
|
|
120
156
|
signature: Hex
|
|
121
157
|
}
|
|
122
158
|
|
|
123
|
-
/**
|
|
159
|
+
/**
|
|
160
|
+
* Signed WASM-blob action step, including provider wire transaction details.
|
|
161
|
+
*
|
|
162
|
+
* @public
|
|
163
|
+
*/
|
|
124
164
|
export interface WasmBlobSignedActionStep {
|
|
125
165
|
action: ActionType
|
|
126
166
|
wasmSignParams: Record<string, unknown>
|
|
@@ -131,14 +171,22 @@ export interface WasmBlobSignedActionStep {
|
|
|
131
171
|
}
|
|
132
172
|
}
|
|
133
173
|
|
|
134
|
-
/**
|
|
174
|
+
/**
|
|
175
|
+
* Signed EVM transaction action step with the submitted transaction hash.
|
|
176
|
+
*
|
|
177
|
+
* @public
|
|
178
|
+
*/
|
|
135
179
|
export interface EvmTxSignedActionStep {
|
|
136
180
|
action: ActionType
|
|
137
181
|
txParams: EvmCall
|
|
138
182
|
txHash: string
|
|
139
183
|
}
|
|
140
184
|
|
|
141
|
-
/**
|
|
185
|
+
/**
|
|
186
|
+
* HMAC-authenticated venue request ready for backend execution.
|
|
187
|
+
*
|
|
188
|
+
* @public
|
|
189
|
+
*/
|
|
142
190
|
export interface HmacSignedActionStep {
|
|
143
191
|
action: ActionType
|
|
144
192
|
request: HmacActionStep['request']
|
|
@@ -154,14 +202,22 @@ export interface HmacSignedActionStep {
|
|
|
154
202
|
}
|
|
155
203
|
}
|
|
156
204
|
|
|
157
|
-
/**
|
|
205
|
+
/**
|
|
206
|
+
* Signed SIWE login action step.
|
|
207
|
+
*
|
|
208
|
+
* @public
|
|
209
|
+
*/
|
|
158
210
|
export interface SiweSignedActionStep {
|
|
159
211
|
action: ActionType
|
|
160
212
|
siwe: SiweActionStep['siwe']
|
|
161
213
|
signature: Hex
|
|
162
214
|
}
|
|
163
215
|
|
|
164
|
-
/**
|
|
216
|
+
/**
|
|
217
|
+
* Union of all signed action-step encodings accepted by `executeAction`.
|
|
218
|
+
*
|
|
219
|
+
* @public
|
|
220
|
+
*/
|
|
165
221
|
export type SignedActionStep =
|
|
166
222
|
| Eip712SignedActionStep
|
|
167
223
|
| WasmBlobSignedActionStep
|
|
@@ -169,7 +225,12 @@ export type SignedActionStep =
|
|
|
169
225
|
| HmacSignedActionStep
|
|
170
226
|
| SiweSignedActionStep
|
|
171
227
|
|
|
172
|
-
/**
|
|
228
|
+
/**
|
|
229
|
+
* Per-action execution result. Success arms may include a provider order id;
|
|
230
|
+
* failure arms carry a message and optional structured error code.
|
|
231
|
+
*
|
|
232
|
+
* @public
|
|
233
|
+
*/
|
|
173
234
|
export type ActionResult =
|
|
174
235
|
| {
|
|
175
236
|
action: ActionType
|
|
@@ -184,13 +245,27 @@ export type ActionResult =
|
|
|
184
245
|
errorCode?: PerpsErrorCode
|
|
185
246
|
}
|
|
186
247
|
|
|
187
|
-
/**
|
|
248
|
+
/**
|
|
249
|
+
* Trigger prices used to configure take-profit or stop-loss behavior.
|
|
250
|
+
* Prices are decimal strings in the market's quote currency.
|
|
251
|
+
*
|
|
252
|
+
* @public
|
|
253
|
+
*/
|
|
188
254
|
export interface TriggerOrderInput {
|
|
189
255
|
triggerPrice: string
|
|
190
256
|
limitPrice?: string
|
|
257
|
+
/**
|
|
258
|
+
* Base-asset size the trigger closes. Omitted covers the entire position,
|
|
259
|
+
* tracking later size changes; set, it is a fixed partial amount.
|
|
260
|
+
*/
|
|
261
|
+
size?: string
|
|
191
262
|
}
|
|
192
263
|
|
|
193
|
-
/**
|
|
264
|
+
/**
|
|
265
|
+
* Mutable fields for an existing order, identified by venue order id.
|
|
266
|
+
*
|
|
267
|
+
* @public
|
|
268
|
+
*/
|
|
194
269
|
export interface ModifyOrderInput {
|
|
195
270
|
id: string
|
|
196
271
|
price?: string
|
|
@@ -199,7 +274,12 @@ export interface ModifyOrderInput {
|
|
|
199
274
|
limitPrice?: string
|
|
200
275
|
}
|
|
201
276
|
|
|
202
|
-
/**
|
|
277
|
+
/**
|
|
278
|
+
* Normalized order returned by a provider, including lifecycle and trigger
|
|
279
|
+
* metadata. Quantities and prices are decimal strings.
|
|
280
|
+
*
|
|
281
|
+
* @public
|
|
282
|
+
*/
|
|
203
283
|
export interface Order {
|
|
204
284
|
orderId: string
|
|
205
285
|
market: MarketDisplay
|
|
@@ -223,7 +303,11 @@ export interface Order {
|
|
|
223
303
|
updatedAt: string
|
|
224
304
|
}
|
|
225
305
|
|
|
226
|
-
/**
|
|
306
|
+
/**
|
|
307
|
+
* Parameters for placing a regular order on a market.
|
|
308
|
+
*
|
|
309
|
+
* @public
|
|
310
|
+
*/
|
|
227
311
|
export interface PlaceOrderParams {
|
|
228
312
|
market: MarketRef
|
|
229
313
|
side: OrderSide
|
|
@@ -240,7 +324,11 @@ export interface PlaceOrderParams {
|
|
|
240
324
|
stopLoss?: TriggerOrderInput
|
|
241
325
|
}
|
|
242
326
|
|
|
243
|
-
/**
|
|
327
|
+
/**
|
|
328
|
+
* Parameters for placing a take-profit or stop-loss trigger order.
|
|
329
|
+
*
|
|
330
|
+
* @public
|
|
331
|
+
*/
|
|
244
332
|
export interface PlaceTriggerOrderParams {
|
|
245
333
|
market: MarketRef
|
|
246
334
|
side: OrderSide
|
|
@@ -248,7 +336,11 @@ export interface PlaceTriggerOrderParams {
|
|
|
248
336
|
stopLoss?: TriggerOrderInput
|
|
249
337
|
}
|
|
250
338
|
|
|
251
|
-
/**
|
|
339
|
+
/**
|
|
340
|
+
* Parameters for cancelling one or more venue orders.
|
|
341
|
+
*
|
|
342
|
+
* @public
|
|
343
|
+
*/
|
|
252
344
|
export interface CancelOrderParams {
|
|
253
345
|
/** Venue order ids. Venues whose ids are scoped per market (e.g. Lighter's
|
|
254
346
|
* `order_index`) also accept the composite `"<market_id>:<order_id>"`. */
|
|
@@ -257,12 +349,20 @@ export interface CancelOrderParams {
|
|
|
257
349
|
assetId?: string
|
|
258
350
|
}
|
|
259
351
|
|
|
260
|
-
/**
|
|
352
|
+
/**
|
|
353
|
+
* Parameters for applying one or more modifications to existing orders.
|
|
354
|
+
*
|
|
355
|
+
* @public
|
|
356
|
+
*/
|
|
261
357
|
export interface ModifyOrderParams {
|
|
262
358
|
modifications: ModifyOrderInput[]
|
|
263
359
|
}
|
|
264
360
|
|
|
265
|
-
/**
|
|
361
|
+
/**
|
|
362
|
+
* Parameters for changing leverage on a market.
|
|
363
|
+
*
|
|
364
|
+
* @public
|
|
365
|
+
*/
|
|
266
366
|
export interface UpdateLeverageParams {
|
|
267
367
|
market: MarketRef
|
|
268
368
|
leverage: number
|
|
@@ -270,14 +370,23 @@ export interface UpdateLeverageParams {
|
|
|
270
370
|
marginMode?: MarginMode
|
|
271
371
|
}
|
|
272
372
|
|
|
273
|
-
/**
|
|
373
|
+
/**
|
|
374
|
+
* Parameters for adding or removing margin from a market position.
|
|
375
|
+
* `amount` is a decimal string in the venue's collateral units.
|
|
376
|
+
*
|
|
377
|
+
* @public
|
|
378
|
+
*/
|
|
274
379
|
export interface UpdatePositionMarginParams {
|
|
275
380
|
market: MarketRef
|
|
276
381
|
action: 'add' | 'remove'
|
|
277
382
|
amount: string
|
|
278
383
|
}
|
|
279
384
|
|
|
280
|
-
/**
|
|
385
|
+
/**
|
|
386
|
+
* Parameters for enabling or disabling an asset as cross-margin collateral.
|
|
387
|
+
*
|
|
388
|
+
* @public
|
|
389
|
+
*/
|
|
281
390
|
export interface UpdateAssetCollateralParams {
|
|
282
391
|
/** Provider-native spot asset id (matches `Asset.id`), keyed per asset — not per market. */
|
|
283
392
|
assetId: string
|
|
@@ -285,13 +394,21 @@ export interface UpdateAssetCollateralParams {
|
|
|
285
394
|
enabled: boolean
|
|
286
395
|
}
|
|
287
396
|
|
|
288
|
-
/**
|
|
397
|
+
/**
|
|
398
|
+
* Parameters for withdrawing a decimal-string amount to an EVM address.
|
|
399
|
+
*
|
|
400
|
+
* @public
|
|
401
|
+
*/
|
|
289
402
|
export interface WithdrawalParams {
|
|
290
403
|
destination: Address
|
|
291
404
|
amount: string
|
|
292
405
|
}
|
|
293
406
|
|
|
294
|
-
/**
|
|
407
|
+
/**
|
|
408
|
+
* Parameters for depositing a token from an EVM source chain.
|
|
409
|
+
*
|
|
410
|
+
* @public
|
|
411
|
+
*/
|
|
295
412
|
export interface DepositParams {
|
|
296
413
|
/** Amount of the token to deposit (human-readable, e.g. "100.5"). */
|
|
297
414
|
amount: string
|
|
@@ -301,23 +418,40 @@ export interface DepositParams {
|
|
|
301
418
|
chainId: number
|
|
302
419
|
}
|
|
303
420
|
|
|
304
|
-
/**
|
|
421
|
+
/**
|
|
422
|
+
* Parameters for approving an account agent, including an optional TTL in
|
|
423
|
+
* milliseconds.
|
|
424
|
+
*
|
|
425
|
+
* @public
|
|
426
|
+
*/
|
|
305
427
|
export interface ApproveAgentParams {
|
|
306
428
|
agentAddress: string
|
|
307
429
|
agentTtlMs?: number
|
|
308
430
|
}
|
|
309
431
|
|
|
310
|
-
/**
|
|
432
|
+
/**
|
|
433
|
+
* Parameters for selecting a provider account mode by its wire value.
|
|
434
|
+
*
|
|
435
|
+
* @public
|
|
436
|
+
*/
|
|
311
437
|
export interface AccountModeParams {
|
|
312
438
|
mode: string
|
|
313
439
|
}
|
|
314
440
|
|
|
315
|
-
/**
|
|
441
|
+
/**
|
|
442
|
+
* Parameters for selecting a provider account tier by its wire value.
|
|
443
|
+
*
|
|
444
|
+
* @public
|
|
445
|
+
*/
|
|
316
446
|
export interface AccountTypeParams {
|
|
317
447
|
tier: string
|
|
318
448
|
}
|
|
319
449
|
|
|
320
|
-
/**
|
|
450
|
+
/**
|
|
451
|
+
* Parameters for moving an asset between provider DEX accounts.
|
|
452
|
+
*
|
|
453
|
+
* @public
|
|
454
|
+
*/
|
|
321
455
|
export interface SendAssetParams {
|
|
322
456
|
/** Canonical `Asset.id` of the asset being moved (for Hyperliquid spot
|
|
323
457
|
* assets, the token index as a string) — never a display symbol. */
|
|
@@ -327,7 +461,12 @@ export interface SendAssetParams {
|
|
|
327
461
|
amount: string
|
|
328
462
|
}
|
|
329
463
|
|
|
330
|
-
/**
|
|
464
|
+
/**
|
|
465
|
+
* Parameters for cancelling all orders immediately or through a scheduled
|
|
466
|
+
* cancellation instruction.
|
|
467
|
+
*
|
|
468
|
+
* @public
|
|
469
|
+
*/
|
|
331
470
|
export interface CancelAllOrdersParams {
|
|
332
471
|
/** 0=immediate (cancel GTC), 1=scheduled, 2=abort scheduled */
|
|
333
472
|
timeInForce: number
|
|
@@ -335,7 +474,11 @@ export interface CancelAllOrdersParams {
|
|
|
335
474
|
timestampMs?: number
|
|
336
475
|
}
|
|
337
476
|
|
|
338
|
-
/**
|
|
477
|
+
/**
|
|
478
|
+
* Parameters for registering a provider API key in a specific slot.
|
|
479
|
+
*
|
|
480
|
+
* @public
|
|
481
|
+
*/
|
|
339
482
|
export interface RegisterApiKeyParams {
|
|
340
483
|
/** The API key slot index to register (0-255). Reusing a fixed slot overwrites the old key. */
|
|
341
484
|
apiKeyIndex: number
|
|
@@ -348,7 +491,11 @@ export interface RegisterApiKeyParams {
|
|
|
348
491
|
knownPublicKey?: string
|
|
349
492
|
}
|
|
350
493
|
|
|
351
|
-
/**
|
|
494
|
+
/**
|
|
495
|
+
* Parameters for approving a Lighter read-only token and its scope/expiry.
|
|
496
|
+
*
|
|
497
|
+
* @public
|
|
498
|
+
*/
|
|
352
499
|
export interface ApproveReadOnlyTokenParams {
|
|
353
500
|
accountIndex: number
|
|
354
501
|
/** Absolute unix-seconds expiry. Lighter requires lifetime between 1 day and 10 years. */
|
|
@@ -356,7 +503,12 @@ export interface ApproveReadOnlyTokenParams {
|
|
|
356
503
|
scope: 'single' | 'all'
|
|
357
504
|
}
|
|
358
505
|
|
|
359
|
-
/**
|
|
506
|
+
/**
|
|
507
|
+
* Mapping from each {@link ActionType} to its action-specific parameter shape.
|
|
508
|
+
* `Record<string, never>` marks actions whose params object must be empty.
|
|
509
|
+
*
|
|
510
|
+
* @public
|
|
511
|
+
*/
|
|
360
512
|
export interface ActionParamsMap {
|
|
361
513
|
[ActionType.APPROVE_AGENT]: ApproveAgentParams
|
|
362
514
|
[ActionType.APPROVE_BUILDER_FEE]: Record<string, never>
|
|
@@ -385,7 +537,11 @@ export interface ActionParamsMap {
|
|
|
385
537
|
[ActionType.META_ACCEPT_TERMS]: AcceptTermsParams
|
|
386
538
|
}
|
|
387
539
|
|
|
388
|
-
/**
|
|
540
|
+
/**
|
|
541
|
+
* Discriminated request sent to create unsigned steps for one action.
|
|
542
|
+
*
|
|
543
|
+
* @public
|
|
544
|
+
*/
|
|
389
545
|
export type CreateActionRequest = {
|
|
390
546
|
[K in ActionType]: {
|
|
391
547
|
provider: string
|
|
@@ -396,12 +552,20 @@ export type CreateActionRequest = {
|
|
|
396
552
|
}
|
|
397
553
|
}[ActionType]
|
|
398
554
|
|
|
399
|
-
/**
|
|
555
|
+
/**
|
|
556
|
+
* Response containing the unsigned steps created for an action request.
|
|
557
|
+
*
|
|
558
|
+
* @public
|
|
559
|
+
*/
|
|
400
560
|
export interface CreateActionResponse {
|
|
401
561
|
actions: ActionStep[]
|
|
402
562
|
}
|
|
403
563
|
|
|
404
|
-
/**
|
|
564
|
+
/**
|
|
565
|
+
* Discriminated request sent to execute signed steps for one action.
|
|
566
|
+
*
|
|
567
|
+
* @public
|
|
568
|
+
*/
|
|
405
569
|
export type ExecuteActionRequest = {
|
|
406
570
|
[K in ActionType]: {
|
|
407
571
|
provider: string
|
|
@@ -412,7 +576,11 @@ export type ExecuteActionRequest = {
|
|
|
412
576
|
}
|
|
413
577
|
}[ActionType]
|
|
414
578
|
|
|
415
|
-
/**
|
|
579
|
+
/**
|
|
580
|
+
* Response containing per-action execution results.
|
|
581
|
+
*
|
|
582
|
+
* @public
|
|
583
|
+
*/
|
|
416
584
|
export interface ExecuteActionResponse {
|
|
417
585
|
results: ActionResult[]
|
|
418
586
|
}
|
package/src/asset.ts
CHANGED
|
@@ -56,15 +56,12 @@ export interface DepositAsset {
|
|
|
56
56
|
address: Address
|
|
57
57
|
/** ERC-20 decimals, used to scale deposit amounts. */
|
|
58
58
|
decimals: number
|
|
59
|
-
/** Display ticker for UI labels; same semantics as {@link Asset.displaySymbol}. */
|
|
60
59
|
displaySymbol: string
|
|
61
|
-
/** Token logo for UI; same semantics as {@link Asset.logoURI}. */
|
|
62
60
|
logoURI: string
|
|
63
|
-
/** Optional longer display name; same semantics as {@link Asset.displayName}. */
|
|
64
61
|
displayName?: string
|
|
65
62
|
}
|
|
66
63
|
|
|
67
|
-
/** @public */
|
|
64
|
+
/** Response containing the provider's normalized asset registry. @public */
|
|
68
65
|
export interface AssetsResponse {
|
|
69
66
|
assets: Asset[]
|
|
70
67
|
}
|
package/src/enums.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* Numeric error codes returned by the perps API.
|
|
3
|
+
*
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
2
6
|
export enum PerpsErrorCode {
|
|
3
7
|
// Base errors (2000-2009)
|
|
4
8
|
DefaultError = 2000,
|
|
@@ -36,13 +40,13 @@ export enum PerpsErrorCode {
|
|
|
36
40
|
RouteNotFound = 2060,
|
|
37
41
|
}
|
|
38
42
|
|
|
39
|
-
/** @public */
|
|
43
|
+
/** Side of an order or execution, using provider wire values. @public */
|
|
40
44
|
export enum OrderSide {
|
|
41
45
|
BUY = 'BUY',
|
|
42
46
|
SELL = 'SELL',
|
|
43
47
|
}
|
|
44
48
|
|
|
45
|
-
/** @public */
|
|
49
|
+
/** Supported regular and trigger order kinds, using provider wire values. @public */
|
|
46
50
|
export enum OrderType {
|
|
47
51
|
MARKET = 'MARKET',
|
|
48
52
|
LIMIT = 'LIMIT',
|
|
@@ -53,13 +57,13 @@ export enum OrderType {
|
|
|
53
57
|
TRIGGER_ONLY = 'TRIGGER_ONLY',
|
|
54
58
|
}
|
|
55
59
|
|
|
56
|
-
/** @public */
|
|
60
|
+
/** Direction of an open position. @public */
|
|
57
61
|
export enum PositionSide {
|
|
58
62
|
LONG = 'LONG',
|
|
59
63
|
SHORT = 'SHORT',
|
|
60
64
|
}
|
|
61
65
|
|
|
62
|
-
/** @public */
|
|
66
|
+
/** Margin allocation mode for a position. @public */
|
|
63
67
|
export enum MarginMode {
|
|
64
68
|
ISOLATED = 'ISOLATED',
|
|
65
69
|
CROSS = 'CROSS',
|
|
@@ -75,7 +79,7 @@ export enum PositionMarginAdjustment {
|
|
|
75
79
|
ADD_AND_REMOVE = 'ADD_AND_REMOVE',
|
|
76
80
|
}
|
|
77
81
|
|
|
78
|
-
/** @public */
|
|
82
|
+
/** Provider order time-in-force policies. @public */
|
|
79
83
|
export enum TimeInForce {
|
|
80
84
|
GTC = 'GTC',
|
|
81
85
|
IOC = 'IOC',
|
|
@@ -83,7 +87,7 @@ export enum TimeInForce {
|
|
|
83
87
|
GTT = 'GTT',
|
|
84
88
|
}
|
|
85
89
|
|
|
86
|
-
/** @public */
|
|
90
|
+
/** Lifecycle status of a provider order. @public */
|
|
87
91
|
export enum OrderStatus {
|
|
88
92
|
PENDING = 'PENDING',
|
|
89
93
|
OPEN = 'OPEN',
|
|
@@ -95,7 +99,7 @@ export enum OrderStatus {
|
|
|
95
99
|
TRIGGERED = 'TRIGGERED',
|
|
96
100
|
}
|
|
97
101
|
|
|
98
|
-
/** @public */
|
|
102
|
+
/** Lifecycle status of an execution/fill. @public */
|
|
99
103
|
export enum FillStatus {
|
|
100
104
|
FILLED = 'FILLED',
|
|
101
105
|
PARTIALLY_FILLED = 'PARTIALLY_FILLED',
|
|
@@ -103,13 +107,18 @@ export enum FillStatus {
|
|
|
103
107
|
REJECTED = 'REJECTED',
|
|
104
108
|
}
|
|
105
109
|
|
|
106
|
-
/** @public */
|
|
110
|
+
/** Whether a fill supplied maker or taker liquidity. @public */
|
|
107
111
|
export enum LiquidityRole {
|
|
108
112
|
MAKER = 'maker',
|
|
109
113
|
TAKER = 'taker',
|
|
110
114
|
}
|
|
111
115
|
|
|
112
|
-
/**
|
|
116
|
+
/**
|
|
117
|
+
* Action identifiers used in setup, create-action, and execute-action
|
|
118
|
+
* requests. Values are the backend wire strings.
|
|
119
|
+
*
|
|
120
|
+
* @public
|
|
121
|
+
*/
|
|
113
122
|
export enum ActionType {
|
|
114
123
|
APPROVE_AGENT = 'approveAgent',
|
|
115
124
|
APPROVE_BUILDER_FEE = 'approveBuilderFee',
|
|
@@ -141,26 +150,26 @@ export enum ActionType {
|
|
|
141
150
|
META_ACCEPT_TERMS = 'metaAcceptTerms',
|
|
142
151
|
}
|
|
143
152
|
|
|
144
|
-
/** @public */
|
|
153
|
+
/** Price relation that activates a trigger order. @public */
|
|
145
154
|
export enum TriggerCondition {
|
|
146
155
|
ABOVE = 'ABOVE',
|
|
147
156
|
BELOW = 'BELOW',
|
|
148
157
|
}
|
|
149
158
|
|
|
150
|
-
/** @public */
|
|
159
|
+
/** Take-profit or stop-loss trigger order classification. @public */
|
|
151
160
|
export enum TriggerOrderType {
|
|
152
161
|
TAKE_PROFIT = 'TAKE_PROFIT',
|
|
153
162
|
STOP_LOSS = 'STOP_LOSS',
|
|
154
163
|
}
|
|
155
164
|
|
|
156
|
-
/** @public */
|
|
165
|
+
/** Lifecycle status of a trigger order. @public */
|
|
157
166
|
export enum TriggerOrderStatus {
|
|
158
167
|
WAITING = 'WAITING',
|
|
159
168
|
TRIGGERED = 'TRIGGERED',
|
|
160
169
|
CANCELLED = 'CANCELLED',
|
|
161
170
|
}
|
|
162
171
|
|
|
163
|
-
/** @public */
|
|
172
|
+
/** Account activity record categories. @public */
|
|
164
173
|
export enum ActivityType {
|
|
165
174
|
DEPOSIT = 'DEPOSIT',
|
|
166
175
|
WITHDRAWAL = 'WITHDRAWAL',
|
|
@@ -169,7 +178,7 @@ export enum ActivityType {
|
|
|
169
178
|
TRANSFER = 'TRANSFER',
|
|
170
179
|
}
|
|
171
180
|
|
|
172
|
-
/** @public */
|
|
181
|
+
/** Human-readable classification of how a fill changed a position. @public */
|
|
173
182
|
export enum FillClassification {
|
|
174
183
|
OPENED_LONG = 'Opened Long',
|
|
175
184
|
OPENED_SHORT = 'Opened Short',
|
|
@@ -185,24 +194,24 @@ export enum FillClassification {
|
|
|
185
194
|
SPOT_SELL = 'Spot Sell',
|
|
186
195
|
}
|
|
187
196
|
|
|
188
|
-
/** @public */
|
|
197
|
+
/** Classification emitted for a liquidation activity. @public */
|
|
189
198
|
export enum LiquidationClassification {
|
|
190
199
|
LIQUIDATED = 'Liquidated',
|
|
191
200
|
}
|
|
192
201
|
|
|
193
|
-
/** @public */
|
|
202
|
+
/** Classification emitted for a funding activity. @public */
|
|
194
203
|
export enum FundingClassification {
|
|
195
204
|
FUNDING = 'Funding',
|
|
196
205
|
}
|
|
197
206
|
|
|
198
|
-
/** @public */
|
|
207
|
+
/** Classification emitted for an inbound, outbound, or internal transfer. @public */
|
|
199
208
|
export enum TransferClassification {
|
|
200
209
|
DEPOSIT = 'Deposit',
|
|
201
210
|
WITHDRAWAL = 'Withdrawal',
|
|
202
211
|
TRANSFER = 'Transfer',
|
|
203
212
|
}
|
|
204
213
|
|
|
205
|
-
/** @public */
|
|
214
|
+
/** Union of classifications emitted by all activity record categories. @public */
|
|
206
215
|
export type ActivityClassification =
|
|
207
216
|
| FillClassification
|
|
208
217
|
| LiquidationClassification
|
|
@@ -223,7 +232,12 @@ export enum PerpsSigner {
|
|
|
223
232
|
SDK = 'SDK',
|
|
224
233
|
}
|
|
225
234
|
|
|
226
|
-
/**
|
|
235
|
+
/**
|
|
236
|
+
* Signing mechanisms supported by action steps. Values are serialized in
|
|
237
|
+
* provider metadata and action responses.
|
|
238
|
+
*
|
|
239
|
+
* @public
|
|
240
|
+
*/
|
|
227
241
|
export enum SigningMethod {
|
|
228
242
|
EIP712 = 'eip712',
|
|
229
243
|
WASM_BLOB = 'wasmBlob',
|
package/src/errors.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import type { PerpsErrorCode } from './enums.js'
|
|
2
2
|
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* Structured perps API error payload. `code` is the stable classification;
|
|
5
|
+
* `tool` identifies the backend tool when the provider supplies one.
|
|
6
|
+
*
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
4
9
|
export interface PerpsErrorBody {
|
|
5
10
|
code: PerpsErrorCode
|
|
6
11
|
tool?: string
|