@lifi/perps-sdk 18.1.0 → 20.0.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/README.md +15 -5
- package/dist/cjs/client/PerpsClient.d.ts +14 -8
- package/dist/cjs/client/PerpsClient.d.ts.map +1 -1
- package/dist/cjs/client/PerpsClient.js +145 -53
- package/dist/cjs/client/PerpsClient.js.map +1 -1
- package/dist/cjs/client/createPerpsClient.d.ts +1 -6
- package/dist/cjs/client/createPerpsClient.d.ts.map +1 -1
- package/dist/cjs/client/createPerpsClient.js +1 -14
- package/dist/cjs/client/createPerpsClient.js.map +1 -1
- package/dist/cjs/index.d.ts +6 -4
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +11 -3
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/services/getOhlcv.d.ts.map +1 -1
- package/dist/cjs/services/getOhlcv.js.map +1 -1
- package/dist/cjs/types/api.d.ts +7 -6
- package/dist/cjs/types/api.d.ts.map +1 -1
- package/dist/cjs/types/config.d.ts +0 -9
- package/dist/cjs/types/config.d.ts.map +1 -1
- package/dist/cjs/types/provider.d.ts +5 -6
- package/dist/cjs/types/provider.d.ts.map +1 -1
- package/dist/cjs/types/withdrawal.d.ts +4 -2
- package/dist/cjs/types/withdrawal.d.ts.map +1 -1
- package/dist/cjs/utils/calculations.d.ts.map +1 -1
- package/dist/cjs/utils/calculations.js +107 -38
- package/dist/cjs/utils/calculations.js.map +1 -1
- package/dist/cjs/utils/decimal.d.ts +4 -0
- package/dist/cjs/utils/decimal.d.ts.map +1 -0
- package/dist/cjs/utils/decimal.js +14 -0
- package/dist/cjs/utils/decimal.js.map +1 -0
- package/dist/cjs/utils/math.d.ts +4 -0
- package/dist/cjs/utils/math.d.ts.map +1 -0
- package/dist/cjs/utils/math.js +8 -0
- package/dist/cjs/utils/math.js.map +1 -0
- package/dist/cjs/utils/parse.d.ts +1 -0
- package/dist/cjs/utils/parse.d.ts.map +1 -1
- package/dist/cjs/utils/parse.js +15 -0
- package/dist/cjs/utils/parse.js.map +1 -1
- package/dist/cjs/utils/positionMath.d.ts +5 -0
- package/dist/cjs/utils/positionMath.d.ts.map +1 -1
- package/dist/cjs/utils/positionMath.js +53 -6
- package/dist/cjs/utils/positionMath.js.map +1 -1
- package/dist/cjs/utils/setupActions.d.ts +4 -2
- package/dist/cjs/utils/setupActions.d.ts.map +1 -1
- package/dist/cjs/utils/setupActions.js +9 -1
- package/dist/cjs/utils/setupActions.js.map +1 -1
- package/dist/cjs/utils/switchChain.js +1 -1
- package/dist/cjs/utils/switchChain.js.map +1 -1
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/websocket/PerpsWsClient.d.ts +0 -1
- package/dist/cjs/websocket/PerpsWsClient.d.ts.map +1 -1
- package/dist/cjs/websocket/PerpsWsClient.js +0 -7
- package/dist/cjs/websocket/PerpsWsClient.js.map +1 -1
- package/dist/esm/client/PerpsClient.d.ts +70 -61
- package/dist/esm/client/PerpsClient.d.ts.map +1 -1
- package/dist/esm/client/PerpsClient.js +215 -107
- package/dist/esm/client/PerpsClient.js.map +1 -1
- package/dist/esm/client/createPerpsClient.d.ts +1 -12
- package/dist/esm/client/createPerpsClient.d.ts.map +1 -1
- package/dist/esm/client/createPerpsClient.js +1 -19
- package/dist/esm/client/createPerpsClient.js.map +1 -1
- package/dist/esm/client/requireProvider.d.ts +1 -1
- package/dist/esm/client/requireProvider.js +1 -1
- package/dist/esm/index.d.ts +6 -4
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +5 -3
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/services/getOhlcv.d.ts +1 -0
- package/dist/esm/services/getOhlcv.d.ts.map +1 -1
- package/dist/esm/services/getOhlcv.js.map +1 -1
- package/dist/esm/types/api.d.ts +39 -36
- package/dist/esm/types/api.d.ts.map +1 -1
- package/dist/esm/types/config.d.ts +0 -27
- package/dist/esm/types/config.d.ts.map +1 -1
- package/dist/esm/types/provider.d.ts +28 -33
- package/dist/esm/types/provider.d.ts.map +1 -1
- package/dist/esm/types/withdrawal.d.ts +24 -15
- package/dist/esm/types/withdrawal.d.ts.map +1 -1
- package/dist/esm/utils/calculations.d.ts +3 -2
- package/dist/esm/utils/calculations.d.ts.map +1 -1
- package/dist/esm/utils/calculations.js +109 -39
- package/dist/esm/utils/calculations.js.map +1 -1
- package/dist/esm/utils/decimal.d.ts +9 -0
- package/dist/esm/utils/decimal.d.ts.map +1 -0
- package/dist/esm/utils/decimal.js +12 -0
- package/dist/esm/utils/decimal.js.map +1 -0
- package/dist/esm/utils/math.d.ts +6 -0
- package/dist/esm/utils/math.d.ts.map +1 -0
- package/dist/esm/utils/math.js +5 -0
- package/dist/esm/utils/math.js.map +1 -0
- package/dist/esm/utils/parse.d.ts +7 -0
- package/dist/esm/utils/parse.d.ts.map +1 -1
- package/dist/esm/utils/parse.js +20 -0
- package/dist/esm/utils/parse.js.map +1 -1
- package/dist/esm/utils/positionMath.d.ts +13 -0
- package/dist/esm/utils/positionMath.d.ts.map +1 -1
- package/dist/esm/utils/positionMath.js +60 -6
- package/dist/esm/utils/positionMath.js.map +1 -1
- package/dist/esm/utils/setupActions.d.ts +17 -8
- package/dist/esm/utils/setupActions.d.ts.map +1 -1
- package/dist/esm/utils/setupActions.js +20 -7
- package/dist/esm/utils/setupActions.js.map +1 -1
- package/dist/esm/utils/switchChain.js +1 -1
- package/dist/esm/utils/switchChain.js.map +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/websocket/PerpsWsClient.d.ts +0 -7
- package/dist/esm/websocket/PerpsWsClient.d.ts.map +1 -1
- package/dist/esm/websocket/PerpsWsClient.js +0 -7
- package/dist/esm/websocket/PerpsWsClient.js.map +1 -1
- package/dist/types/client/PerpsClient.d.ts +70 -61
- package/dist/types/client/PerpsClient.d.ts.map +1 -1
- package/dist/types/client/createPerpsClient.d.ts +1 -12
- package/dist/types/client/createPerpsClient.d.ts.map +1 -1
- package/dist/types/client/requireProvider.d.ts +1 -1
- package/dist/types/index.d.ts +6 -4
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/services/getOhlcv.d.ts +1 -0
- package/dist/types/services/getOhlcv.d.ts.map +1 -1
- package/dist/types/types/api.d.ts +39 -36
- package/dist/types/types/api.d.ts.map +1 -1
- package/dist/types/types/config.d.ts +0 -27
- package/dist/types/types/config.d.ts.map +1 -1
- package/dist/types/types/provider.d.ts +28 -33
- package/dist/types/types/provider.d.ts.map +1 -1
- package/dist/types/types/withdrawal.d.ts +24 -15
- package/dist/types/types/withdrawal.d.ts.map +1 -1
- package/dist/types/utils/calculations.d.ts +3 -2
- package/dist/types/utils/calculations.d.ts.map +1 -1
- package/dist/types/utils/decimal.d.ts +9 -0
- package/dist/types/utils/decimal.d.ts.map +1 -0
- package/dist/types/utils/math.d.ts +6 -0
- package/dist/types/utils/math.d.ts.map +1 -0
- package/dist/types/utils/parse.d.ts +7 -0
- package/dist/types/utils/parse.d.ts.map +1 -1
- package/dist/types/utils/positionMath.d.ts +13 -0
- package/dist/types/utils/positionMath.d.ts.map +1 -1
- package/dist/types/utils/setupActions.d.ts +17 -8
- package/dist/types/utils/setupActions.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/dist/types/websocket/PerpsWsClient.d.ts +0 -7
- package/dist/types/websocket/PerpsWsClient.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/client/PerpsClient.ts +296 -137
- package/src/client/createPerpsClient.ts +4 -32
- package/src/client/requireProvider.ts +1 -1
- package/src/index.ts +8 -5
- package/src/services/getOhlcv.ts +1 -0
- package/src/types/api.ts +40 -40
- package/src/types/config.ts +0 -30
- package/src/types/provider.ts +29 -36
- package/src/types/withdrawal.ts +24 -15
- package/src/utils/calculations.ts +114 -43
- package/src/utils/decimal.ts +13 -0
- package/src/utils/math.ts +7 -0
- package/src/utils/parse.ts +25 -0
- package/src/utils/positionMath.ts +66 -6
- package/src/utils/setupActions.ts +27 -13
- package/src/utils/switchChain.ts +1 -1
- package/src/version.ts +1 -1
- package/src/websocket/PerpsWsClient.ts +0 -19
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { AccountResponse, AccountSummary, ActionParamsMap, ActionStep, AvailableToTrade, CreateActionResponse, ExecuteActionResponse, MarketRef, MarketSettings, MetaActionType, Order, OrdersResponse, PortfolioHistoryResponse, Position } from '@lifi/perps-types';
|
|
1
|
+
import type { AccountResponse, AccountSummary, ActionParamsMap, ActionStep, AvailableToTrade, CreateActionResponse, ExecuteActionResponse, MarketRef, MarketSettings, MetaActionType, Order, OrdersResponse, PortfolioHistoryResponse, Position, SetupAction, SetupOption } from '@lifi/perps-types';
|
|
2
2
|
import { ActionType } from '@lifi/perps-types';
|
|
3
3
|
import type { Address } from 'viem';
|
|
4
4
|
import { type GetOrderParams } from '../services/getOrder.js';
|
|
5
5
|
import { type GetOrdersParams } from '../services/getOrders.js';
|
|
6
|
-
import type { BuildProviderSetupParams, CancelOrdersParams, CancelTwapOrderParams, CreateReferralCodeActionParams, ExecuteMetaActionParams, GetAccountResult, GetDepositFlowParams, GetPortfolioHistoryParams, GetSetupParams, GetWithdrawableBalancesParams, GetWithdrawFlowParams, ModifyOrdersParams, PerpsClientOptions, PlaceOrderParams, PlaceTriggerOrderParams, PlaceTwapOrderParams, ProviderSetup, SendAssetActionParams, SubmitOnboardingParams, WithdrawParams } from '../types/api.js';
|
|
6
|
+
import type { BuildProviderSetupParams, CancelOrdersParams, CancelTwapOrderParams, CreateReferralCodeActionParams, ExecuteMetaActionParams, GetAccountResult, GetDepositFlowParams, GetPortfolioHistoryParams, GetSetupParams, GetWithdrawableBalancesParams, GetWithdrawFlowParams, ModifyOrdersParams, PerpsClientOptions, PlaceOrderParams, PlaceTriggerOrderParams, PlaceTwapOrderParams, ProviderSetup, SendAssetActionParams, SetupChecklistItem, SubmitOnboardingParams, WithdrawParams } from '../types/api.js';
|
|
7
7
|
import type { SDKRequestOptions, SwitchChainHook } from '../types/config.js';
|
|
8
8
|
import type { DepositFlow } from '../types/deposit.js';
|
|
9
9
|
import type { PerpsSDKClient, SignActionProgress } from '../types/provider.js';
|
|
@@ -24,7 +24,7 @@ export declare class PerpsClient {
|
|
|
24
24
|
constructor(options: PerpsClientOptions);
|
|
25
25
|
/**
|
|
26
26
|
* Set or update the end-user's wallet. Used whenever an action's descriptor
|
|
27
|
-
* names
|
|
27
|
+
* names `PerpsSigner.USER` as its `signer`. Pass undefined to clear.
|
|
28
28
|
*
|
|
29
29
|
* @public
|
|
30
30
|
*/
|
|
@@ -59,7 +59,7 @@ export declare class PerpsClient {
|
|
|
59
59
|
* Ask the provider plugin for the signer-bearing wire fields of `action` —
|
|
60
60
|
* the on-wire `signerAddress` and any signer-derived params (e.g.
|
|
61
61
|
* Hyperliquid's `agentAddress` for `APPROVE_AGENT`). Forwards the descriptor's
|
|
62
|
-
* `
|
|
62
|
+
* `signer` so the plugin can branch on signer role. Returns empty when the
|
|
63
63
|
* plugin signs as the user or with a non-EVM credential. Core constructs no
|
|
64
64
|
* `signerAddress` itself; signer identity is plugin-owned.
|
|
65
65
|
*/
|
|
@@ -67,10 +67,10 @@ export declare class PerpsClient {
|
|
|
67
67
|
/**
|
|
68
68
|
* Delegate signing of `actions` to the provider plugin, one call per
|
|
69
69
|
* consecutive run of steps sharing a descriptor. Each call carries that
|
|
70
|
-
* descriptor's `signingMethod` and `
|
|
70
|
+
* descriptor's `signingMethod` and `signer`, so a mixed batch signs every
|
|
71
71
|
* step with the signer its own descriptor declares; the signed steps come
|
|
72
72
|
* back in the batch's original order. The plugin owns every signing arm and
|
|
73
|
-
* branches on `
|
|
73
|
+
* branches on `signer` internally, reading the end-user's wallet from the
|
|
74
74
|
* {@link SignActionsContext} when an arm signs as the user.
|
|
75
75
|
*
|
|
76
76
|
* @throws {PerpsError} When a step's action is not declared by the provider,
|
|
@@ -105,9 +105,9 @@ export declare class PerpsClient {
|
|
|
105
105
|
private resolveMetaSigningWallet;
|
|
106
106
|
/**
|
|
107
107
|
* Assemble the per-call context the provider plugin needs in order to sign:
|
|
108
|
-
* the end-user's wallet and the descriptor's declared `
|
|
109
|
-
* forwards `
|
|
110
|
-
* branch on
|
|
108
|
+
* the end-user's wallet and the descriptor's declared `signer`. Core
|
|
109
|
+
* forwards `signer` as data so the plugin can pick WHO signs; it does not
|
|
110
|
+
* branch on it. Provider-owned session credentials (the Hyperliquid agent
|
|
111
111
|
* keypair, Lighter's API key) are resolved inside the provider's
|
|
112
112
|
* `signActions`, not threaded through here.
|
|
113
113
|
*
|
|
@@ -148,7 +148,7 @@ export declare class PerpsClient {
|
|
|
148
148
|
/**
|
|
149
149
|
* Fetch the user's account state from the backend and attach the
|
|
150
150
|
* SDK-projected `settings` array — one `AccountConfigSetting` per
|
|
151
|
-
* descriptor on `Provider.setup
|
|
151
|
+
* descriptor on `Provider.setup`. Callers read
|
|
152
152
|
* `result.settings` directly without re-deriving values from the typed
|
|
153
153
|
* `AccountConfig`.
|
|
154
154
|
*
|
|
@@ -161,19 +161,20 @@ export declare class PerpsClient {
|
|
|
161
161
|
address: Address;
|
|
162
162
|
}): Promise<GetAccountResult>;
|
|
163
163
|
/**
|
|
164
|
-
* The user's current venue-side settings for a market — the margin
|
|
165
|
-
* and leverage the next order on it will use. Resolves
|
|
166
|
-
*
|
|
167
|
-
* has no such read at all).
|
|
164
|
+
* The user's current venue-side settings for a perps market — the margin
|
|
165
|
+
* mode and leverage the next order on it will use. Resolves the venue value
|
|
166
|
+
* or throws.
|
|
168
167
|
*
|
|
169
|
-
* @throws {PerpsError} When the provider plugin is not registered
|
|
168
|
+
* @throws {PerpsError} When the provider plugin is not registered,
|
|
169
|
+
* `ValidationError` for a spot market, or any other `PerpsError` when the
|
|
170
|
+
* venue read fails or carries no usable value.
|
|
170
171
|
* @public
|
|
171
172
|
*/
|
|
172
173
|
getMarketSettings(params: {
|
|
173
174
|
provider: string;
|
|
174
175
|
address: Address;
|
|
175
176
|
market: MarketRef;
|
|
176
|
-
}): Promise<MarketSettings
|
|
177
|
+
}): Promise<MarketSettings>;
|
|
177
178
|
/**
|
|
178
179
|
* The amounts `params.address` can still buy and sell on one market, in
|
|
179
180
|
* that market's margin asset. The order panel reads this per-market figure;
|
|
@@ -255,7 +256,7 @@ export declare class PerpsClient {
|
|
|
255
256
|
* @returns `undefined` when the registered plugin declares no withdrawable
|
|
256
257
|
* read.
|
|
257
258
|
* @throws {PerpsError} When the provider plugin is not registered, when
|
|
258
|
-
* either the plugin read or the asset sync fails,
|
|
259
|
+
* either the plugin read or the asset sync fails, when a row's
|
|
259
260
|
* `withdrawalFee` is not a non-negative decimal.
|
|
260
261
|
* @public
|
|
261
262
|
*/
|
|
@@ -270,28 +271,29 @@ export declare class PerpsClient {
|
|
|
270
271
|
*/
|
|
271
272
|
getPortfolioHistory(params: GetPortfolioHistoryParams, options?: SDKRequestOptions): Promise<PortfolioHistoryResponse>;
|
|
272
273
|
/**
|
|
273
|
-
* Return the
|
|
274
|
-
*
|
|
275
|
-
* `checklist` carries the renderable onboarding list: every
|
|
276
|
-
*
|
|
277
|
-
* omitted.
|
|
274
|
+
* Return the setup steps this account must still sign as a flat,
|
|
275
|
+
* self-describing list. Trading is gated on `isReady === true`.
|
|
276
|
+
* `checklist` carries the renderable onboarding list: every choice step and
|
|
277
|
+
* every `USER`-signed step with its satisfied state, with not-required
|
|
278
|
+
* conditional steps omitted.
|
|
278
279
|
*
|
|
279
|
-
* `
|
|
280
|
-
*
|
|
281
|
-
*
|
|
280
|
+
* A non-choice `SDK`-signed step is NEVER returned here — the SDK drains it
|
|
281
|
+
* with the provider's own credentials. A choice is listed but never staged
|
|
282
|
+
* or executed, whatever its `signer`: the user picks an option through
|
|
283
|
+
* {@link executeProviderOption}, and `isReady` stays `false` until every
|
|
284
|
+
* choice on `checklist` is satisfied.
|
|
282
285
|
*
|
|
283
286
|
* @public
|
|
284
287
|
*/
|
|
285
288
|
checkSetup(params: GetSetupParams): Promise<ProviderSetup>;
|
|
286
289
|
/**
|
|
287
|
-
*
|
|
288
|
-
*
|
|
289
|
-
*
|
|
290
|
+
* Project the provider's own typed account config onto its setup steps. This
|
|
291
|
+
* catches client-held auth state (e.g. Ondo SIWE/JWT) that the backend
|
|
292
|
+
* cannot observe, and carries the current value of each choice.
|
|
290
293
|
*/
|
|
291
|
-
private
|
|
294
|
+
private resolveSetupSettings;
|
|
292
295
|
/**
|
|
293
|
-
* Drain the pending
|
|
294
|
-
* `PerpsProviderPlugin.internalSetupActions`. Each step is built, signed,
|
|
296
|
+
* Drain the pending `SDK`-signed non-choice steps: each is built, signed,
|
|
295
297
|
* and executed in place with the provider's own credentials. A step is
|
|
296
298
|
* deferred while any staged user-facing step with a lower `sequence` is
|
|
297
299
|
* outstanding — it cannot succeed before its prerequisite (e.g. SET_REFERRAL
|
|
@@ -300,7 +302,7 @@ export declare class PerpsClient {
|
|
|
300
302
|
* blocks setup — the step stays unsatisfied and is retried on a later
|
|
301
303
|
* `checkSetup`.
|
|
302
304
|
*/
|
|
303
|
-
private
|
|
305
|
+
private drainSetup;
|
|
304
306
|
/**
|
|
305
307
|
* Build unsigned setup steps for the supplied descriptor subset, preserving
|
|
306
308
|
* provider sequence order with SIWE descriptors prioritized.
|
|
@@ -308,9 +310,11 @@ export declare class PerpsClient {
|
|
|
308
310
|
private buildProviderSetupActions;
|
|
309
311
|
/**
|
|
310
312
|
* Build the unsigned setup `ActionStep`s still outstanding for an account,
|
|
311
|
-
* ordered by descriptor `sequence`.
|
|
312
|
-
*
|
|
313
|
-
*
|
|
313
|
+
* ordered by descriptor `sequence`. Only a `USER`-signed non-choice step is
|
|
314
|
+
* staged: an `SDK`-signed non-choice step drains inside {@link checkSetup}
|
|
315
|
+
* and a choice executes the option the user picks. The backend filters
|
|
316
|
+
* already-satisfied setup; each plugin contributes its own signer-bearing
|
|
317
|
+
* request fields and any local-state params (e.g. Lighter's known pubkey).
|
|
314
318
|
*
|
|
315
319
|
* @public
|
|
316
320
|
*/
|
|
@@ -325,41 +329,30 @@ export declare class PerpsClient {
|
|
|
325
329
|
/**
|
|
326
330
|
* Sign and submit one pre-staged setup `ActionStep` end-to-end.
|
|
327
331
|
*
|
|
328
|
-
*
|
|
329
|
-
*
|
|
330
|
-
*
|
|
331
|
-
*
|
|
332
|
-
* through submit. If the cached step has gone stale (Lighter's `/nextNonce`
|
|
333
|
-
* advanced underneath us), `executeProviderSetup` will surface a nonce
|
|
334
|
-
* conflict that the caller invalidates on, refetches `checkSetup`, and
|
|
335
|
-
* retries with a fresh step.
|
|
332
|
+
* `step` and `checklist` must come from the same {@link checkSetup} result.
|
|
333
|
+
* This preserves the nonce allocated while staging and validates sequence
|
|
334
|
+
* prerequisites against that same snapshot, without another `createAction`
|
|
335
|
+
* round-trip.
|
|
336
336
|
*
|
|
337
337
|
* @throws {PerpsError} When the step's action is not in the provider's
|
|
338
|
-
* `setup` descriptors
|
|
338
|
+
* `setup` descriptors, or when a lower-`sequence` step on the same
|
|
339
|
+
* checklist, a choice included, is still unsatisfied.
|
|
339
340
|
* @public
|
|
340
341
|
*/
|
|
341
342
|
executeProviderSetupAction(params: {
|
|
342
343
|
provider: string;
|
|
343
344
|
address: Address;
|
|
344
345
|
step: ActionStep;
|
|
346
|
+
checklist: SetupChecklistItem[];
|
|
345
347
|
}): Promise<void>;
|
|
346
348
|
/**
|
|
347
|
-
*
|
|
348
|
-
*
|
|
349
|
-
*
|
|
349
|
+
* Execute one option of a choice setup step (Lighter `ACCOUNT_TYPE`,
|
|
350
|
+
* Hyperliquid `ACCOUNT_MODE`) end-to-end with its bound `{ type, params }`,
|
|
351
|
+
* throwing on a venue rejection.
|
|
350
352
|
*
|
|
351
|
-
*
|
|
352
|
-
* trades, but unlike a trade an option change is a single mandatory action:
|
|
353
|
+
* The option runs through the same {@link execute} pipeline as a trade, but
|
|
353
354
|
* a per-action `success: false` (returned as a 200 OK) means the user's
|
|
354
|
-
* selection was rejected and must surface, not be silently dropped.
|
|
355
|
-
* wrapper inspects the result and throws a {@link PerpsError} carrying the
|
|
356
|
-
* venue `error`, giving options the same throw contract that setup has via
|
|
357
|
-
* {@link executeProviderSetupAction}. The only structural difference is that
|
|
358
|
-
* an option carries `params` (the selected value) rather than a pre-staged
|
|
359
|
-
* step.
|
|
360
|
-
*
|
|
361
|
-
* `execute` itself is unchanged — it still returns results without throwing,
|
|
362
|
-
* which the trade hooks rely on for partial-fill handling.
|
|
355
|
+
* selection was rejected and must surface, not be silently dropped.
|
|
363
356
|
*
|
|
364
357
|
* @throws {PerpsError} Carrying the venue error when any returned result has
|
|
365
358
|
* `success: false`, under that result's `errorCode` when the backend
|
|
@@ -368,11 +361,25 @@ export declare class PerpsClient {
|
|
|
368
361
|
* signer, signing failure).
|
|
369
362
|
* @public
|
|
370
363
|
*/
|
|
371
|
-
executeProviderOption
|
|
364
|
+
executeProviderOption(params: {
|
|
372
365
|
provider: string;
|
|
373
366
|
address: Address;
|
|
374
|
-
|
|
375
|
-
|
|
367
|
+
option: SetupOption;
|
|
368
|
+
}): Promise<void>;
|
|
369
|
+
/**
|
|
370
|
+
* Undo a satisfied setup step by executing its `revoke` action through
|
|
371
|
+
* create, sign and execute, signed with that action's `Provider.actions`
|
|
372
|
+
* descriptor. The step stages again on the next {@link checkSetup}.
|
|
373
|
+
*
|
|
374
|
+
* @throws {PerpsError} `SDKError` when `step.revoke` is `null` or when
|
|
375
|
+
* `createAction` stages nothing to revoke; otherwise the errors
|
|
376
|
+
* {@link executeProviderOption} throws.
|
|
377
|
+
* @public
|
|
378
|
+
*/
|
|
379
|
+
executeProviderRevoke(params: {
|
|
380
|
+
provider: string;
|
|
381
|
+
address: Address;
|
|
382
|
+
step: SetupAction;
|
|
376
383
|
}): Promise<void>;
|
|
377
384
|
/**
|
|
378
385
|
* Place a market or limit order. Convenience wrapper over {@link execute}
|
|
@@ -486,6 +493,8 @@ export declare class PerpsClient {
|
|
|
486
493
|
* deposit); called as each leg is submitted and confirmed. */
|
|
487
494
|
onProgress?: (progress: SignActionProgress) => void;
|
|
488
495
|
}): Promise<ExecuteActionResponse>;
|
|
496
|
+
/** {@link execute}, also returning the steps `createAction` staged. */
|
|
497
|
+
private runAction;
|
|
489
498
|
/**
|
|
490
499
|
* Accept the current terms and, when a code is supplied and the backend
|
|
491
500
|
* accepts it, attach that internal referral code — in one signature.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PerpsClient.d.ts","sourceRoot":"","sources":["../../../src/client/PerpsClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"PerpsClient.d.ts","sourceRoot":"","sources":["../../../src/client/PerpsClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,eAAe,EACf,cAAc,EACd,eAAe,EAEf,UAAU,EACV,gBAAgB,EAChB,oBAAoB,EACpB,qBAAqB,EACrB,SAAS,EACT,cAAc,EACd,cAAc,EACd,KAAK,EACL,cAAc,EACd,wBAAwB,EACxB,QAAQ,EAGR,WAAW,EACX,WAAW,EAEZ,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EAEL,UAAU,EAKX,MAAM,mBAAmB,CAAA;AAE1B,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAOnC,OAAO,EAEL,KAAK,cAAc,EACpB,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAEL,KAAK,eAAe,EACrB,MAAM,0BAA0B,CAAA;AAEjC,OAAO,KAAK,EACV,wBAAwB,EACxB,kBAAkB,EAClB,qBAAqB,EACrB,8BAA8B,EAC9B,uBAAuB,EAGvB,gBAAgB,EAChB,oBAAoB,EACpB,yBAAyB,EACzB,cAAc,EACd,6BAA6B,EAC7B,qBAAqB,EACrB,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,EAChB,uBAAuB,EACvB,oBAAoB,EACpB,aAAa,EACb,qBAAqB,EACrB,kBAAkB,EAClB,sBAAsB,EACtB,cAAc,EACf,MAAM,iBAAiB,CAAA;AAC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