@lifi/perps-sdk 0.0.0-preview-5cdfc44 → 0.0.0-preview-b49efcc

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/README.md +22 -0
  2. package/dist/cjs/client/PerpsClient.d.ts +7 -3
  3. package/dist/cjs/client/PerpsClient.d.ts.map +1 -1
  4. package/dist/cjs/client/PerpsClient.js +43 -47
  5. package/dist/cjs/client/PerpsClient.js.map +1 -1
  6. package/dist/cjs/index.d.ts +2 -2
  7. package/dist/cjs/index.d.ts.map +1 -1
  8. package/dist/cjs/index.js +4 -3
  9. package/dist/cjs/index.js.map +1 -1
  10. package/dist/cjs/registry/assetRegistry.d.ts +2 -1
  11. package/dist/cjs/registry/assetRegistry.d.ts.map +1 -1
  12. package/dist/cjs/registry/assetRegistry.js +11 -1
  13. package/dist/cjs/registry/assetRegistry.js.map +1 -1
  14. package/dist/cjs/types/api.d.ts +2 -2
  15. package/dist/cjs/types/api.d.ts.map +1 -1
  16. package/dist/cjs/types/provider.d.ts +8 -2
  17. package/dist/cjs/types/provider.d.ts.map +1 -1
  18. package/dist/cjs/version.d.ts +1 -1
  19. package/dist/cjs/version.js +1 -1
  20. package/dist/esm/client/PerpsClient.d.ts +54 -47
  21. package/dist/esm/client/PerpsClient.d.ts.map +1 -1
  22. package/dist/esm/client/PerpsClient.js +92 -102
  23. package/dist/esm/client/PerpsClient.js.map +1 -1
  24. package/dist/esm/index.d.ts +2 -2
  25. package/dist/esm/index.d.ts.map +1 -1
  26. package/dist/esm/index.js +1 -1
  27. package/dist/esm/index.js.map +1 -1
  28. package/dist/esm/registry/assetRegistry.d.ts +7 -1
  29. package/dist/esm/registry/assetRegistry.d.ts.map +1 -1
  30. package/dist/esm/registry/assetRegistry.js +14 -0
  31. package/dist/esm/registry/assetRegistry.js.map +1 -1
  32. package/dist/esm/types/api.d.ts +11 -13
  33. package/dist/esm/types/api.d.ts.map +1 -1
  34. package/dist/esm/types/provider.d.ts +33 -6
  35. package/dist/esm/types/provider.d.ts.map +1 -1
  36. package/dist/esm/version.d.ts +1 -1
  37. package/dist/esm/version.js +1 -1
  38. package/dist/types/client/PerpsClient.d.ts +54 -47
  39. package/dist/types/client/PerpsClient.d.ts.map +1 -1
  40. package/dist/types/index.d.ts +2 -2
  41. package/dist/types/index.d.ts.map +1 -1
  42. package/dist/types/registry/assetRegistry.d.ts +7 -1
  43. package/dist/types/registry/assetRegistry.d.ts.map +1 -1
  44. package/dist/types/types/api.d.ts +11 -13
  45. package/dist/types/types/api.d.ts.map +1 -1
  46. package/dist/types/types/provider.d.ts +33 -6
  47. package/dist/types/types/provider.d.ts.map +1 -1
  48. package/dist/types/version.d.ts +1 -1
  49. package/package.json +2 -2
  50. package/src/client/PerpsClient.ts +130 -138
  51. package/src/index.ts +6 -1
  52. package/src/registry/assetRegistry.ts +16 -1
  53. package/src/types/api.ts +11 -13
  54. package/src/types/provider.ts +41 -6
  55. package/src/version.ts +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../src/types/provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,oBAAoB,EACpB,eAAe,EACf,cAAc,EACd,YAAY,EACZ,UAAU,EACV,UAAU,EACV,kBAAkB,EAClB,YAAY,EACZ,aAAa,EACb,MAAM,EACN,SAAS,EACT,cAAc,EACd,KAAK,EACL,WAAW,EACX,cAAc,EACd,WAAW,EACX,WAAW,EACX,qBAAqB,EACrB,wBAAwB,EACxB,QAAQ,EACR,yBAAyB,EACzB,iBAAiB,EACjB,KAAK,EACL,SAAS,EACT,WAAW,EACX,gBAAgB,EAChB,aAAa,EACb,SAAS,EACV,MAAM,mBAAmB,CAAA;AAC1B,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AACnC,OAAO,KAAK,EACV,eAAe,EACf,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,aAAa,CAAA;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AAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;IAkBnC,oBAAoB,CAAC,CACnB,MAAM,EAAE,UAAU,EAClB,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,WAAW,EAAE,GACrB,OAAO,CAAC,wBAAwB,CAAC,CAAA;IAmBpC,WAAW,CAAC,CACV,MAAM,EAAE,aAAa,EACrB,KAAK,EAAE,UAAU,EAAE,EACnB,OAAO,EAAE,OAAO,EAChB,GAAG,CAAC,EAAE,kBAAkB,GACvB,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAAA;IAO9B,gBAAgB,CAAC,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAW3E,mBAAmB,CAAC,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAA;CACzD;AAYD,MAAM,MAAM,aAAa,GAAG,IAAI,CAAC,mBAAmB,EAAE,MAAM,CAAC,CAAA"}
1
+ {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../src/types/provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,oBAAoB,EACpB,eAAe,EACf,cAAc,EACd,YAAY,EACZ,UAAU,EACV,UAAU,EACV,kBAAkB,EAClB,YAAY,EACZ,gBAAgB,EAChB,aAAa,EACb,MAAM,EACN,SAAS,EACT,cAAc,EACd,KAAK,EACL,WAAW,EACX,cAAc,EACd,WAAW,EACX,WAAW,EACX,qBAAqB,EACrB,wBAAwB,EACxB,QAAQ,EACR,yBAAyB,EACzB,iBAAiB,EACjB,cAAc,EACd,KAAK,EACL,SAAS,EACT,gBAAgB,EAChB,aAAa,EACb,SAAS,EACV,MAAM,mBAAmB,CAAA;AAC1B,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AACnC,OAAO,KAAK,EACV,eAAe,EACf,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,aAAa,CAA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B,GAChC,MAAM,GAAG,SAAS,CAAA;IAUrB,yBAAyB,CACvB,QAAQ,EAAE,QAAQ,GACjB,yBAAyB,GAAG,SAAS,CAAA;IAYxC,aAAa,CACX,MAAM,EAAE,aAAa,EACrB,KAAK,EAAE,cAAc,EAAE,EACvB,OAAO,EAAE,cAAc,EAAE,GACxB,oBAAoB,EAAE,CAAA;IAUzB,kBAAkB,CAAC,CACjB,MAAM,EAAE,UAAU,EAClB,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;IAkBnC,oBAAoB,CAAC,CACnB,MAAM,EAAE,UAAU,EAClB,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,WAAW,EAAE,GACrB,OAAO,CAAC,wBAAwB,CAAC,CAAA;IAmBpC,WAAW,CAAC,CACV,MAAM,EAAE,aAAa,EACrB,KAAK,EAAE,UAAU,EAAE,EACnB,OAAO,EAAE,OAAO,EAChB,GAAG,CAAC,EAAE,kBAAkB,GACvB,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAAA;IAO9B,gBAAgB,CAAC,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAW3E,mBAAmB,CAAC,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAA;CACzD;AAYD,MAAM,MAAM,aAAa,GAAG,IAAI,CAAC,mBAAmB,EAAE,MAAM,CAAC,CAAA"}
@@ -1,3 +1,3 @@
1
1
  export declare const name = "@lifi/perps-sdk";
2
- export declare const version = "0.0.0-preview-5cdfc44";
2
+ export declare const version = "0.0.0-preview-b49efcc";
3
3
  //# sourceMappingURL=version.d.ts.map
@@ -2,5 +2,5 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.version = exports.name = void 0;
4
4
  exports.name = '@lifi/perps-sdk';
5
- exports.version = '0.0.0-preview-5cdfc44';
5
+ exports.version = '0.0.0-preview-b49efcc';
6
6
  //# sourceMappingURL=version.js.map
@@ -1,4 +1,4 @@
1
- import type { AccountResponse, AccountSummary, ActionParamsMap, ActionStep, CreateActionResponse, ExecuteActionResponse, MarketRef, MarketSettings, MetaActionType, Order, OrdersResponse, PortfolioHistoryResponse, Position, PositionMarginConstraints } from '@lifi/perps-types';
1
+ import type { AccountResponse, AccountSummary, ActionParamsMap, ActionStep, AvailableToTrade, CreateActionResponse, ExecuteActionResponse, MarketRef, MarketSettings, MetaActionType, Order, OrdersResponse, PortfolioHistoryResponse, Position, PositionMarginConstraints } 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';
@@ -142,7 +142,7 @@ export declare class PerpsClient {
142
142
  /**
143
143
  * Fetch the user's account state from the backend and attach the
144
144
  * SDK-projected `settings` array — one `AccountConfigSetting` per
145
- * descriptor on `Provider.setup`. Callers read
145
+ * descriptor on `Provider.setup` + `Provider.options`. Callers read
146
146
  * `result.settings` directly without re-deriving values from the typed
147
147
  * `AccountConfig`.
148
148
  *
@@ -168,6 +168,25 @@ export declare class PerpsClient {
168
168
  address: Address;
169
169
  market: MarketRef;
170
170
  }): Promise<MarketSettings | undefined>;
171
+ /**
172
+ * The amounts `params.address` can still buy and sell on one market, in
173
+ * that market's margin asset. The order panel reads this per-market figure;
174
+ * account displays read the account-scoped
175
+ * {@link AccountSummary.availableMargin} instead.
176
+ *
177
+ * Providers that read a per-market figure answer it directly. For every
178
+ * other provider this falls back to the account summary, so both sides
179
+ * equal `availableMargin` and the asset is the market's quote asset.
180
+ *
181
+ * @throws {PerpsError} When the provider plugin is not registered, or the
182
+ * market is unknown to the provider's market registry.
183
+ * @public
184
+ */
185
+ getAvailableToTrade(params: {
186
+ provider: string;
187
+ address: Address;
188
+ marketId: string;
189
+ }, options?: SDKRequestOptions): Promise<AvailableToTrade>;
171
190
  /**
172
191
  * Resolve the exact venue-owned margin requirements for `position`.
173
192
  * Returns `undefined` when the position has no individual margin adjustment.
@@ -230,16 +249,15 @@ export declare class PerpsClient {
230
249
  */
231
250
  getPortfolioHistory(params: GetPortfolioHistoryParams, options?: SDKRequestOptions): Promise<PortfolioHistoryResponse>;
232
251
  /**
233
- * Return the setup steps this account must still sign as a flat,
234
- * self-describing list. Trading is gated on `isReady === true`.
235
- * `checklist` carries the renderable onboarding list: every `approval` and
236
- * `preference` descriptor with its satisfied state, with not-required
237
- * conditional steps omitted.
252
+ * Return the unsatisfied entries on `Provider.setup` for this account as a
253
+ * flat, self-describing list. Trading is gated on `isReady === true`.
254
+ * `checklist` carries the renderable onboarding list: every USER-signed
255
+ * descriptor with its satisfied state, with not-required conditional steps
256
+ * omitted.
238
257
  *
239
- * `automatic` descriptors are NEVER returned here — the SDK drains them with
240
- * the provider's own credentials. A `preference` is listed but never staged:
241
- * the user re-enters it through {@link executeProviderOption}, and the SDK
242
- * applies the descriptor's declared default while it stays unsatisfied.
258
+ * `Provider.options` descriptors are NEVER returned here — options are
259
+ * post-setup tunables and never gate trading. Option state is surfaced
260
+ * separately via `getAccount().settings`.
243
261
  *
244
262
  * @public
245
263
  */
@@ -251,17 +269,17 @@ export declare class PerpsClient {
251
269
  */
252
270
  private resolveSatisfiedSetup;
253
271
  /**
254
- * Drain the pending setup steps the SDK fulfils without user input: every
255
- * `automatic` step, and every unsatisfied `preference` whose descriptor
256
- * declares a parameter default. Each step is built, signed, and executed in
257
- * place with the provider's own credentials. A step is deferred while any
258
- * staged user-facing step with a lower `sequence` is outstanding — it cannot
259
- * succeed before its prerequisite (e.g. SET_REFERRAL authenticates with the
260
- * credential REGISTER_API_KEY installs) and each doomed attempt is venue
261
- * traffic. A drain failure is swallowed so it never blocks setup — the step
262
- * stays unsatisfied and is retried on a later `checkSetup`.
272
+ * Drain the pending setup steps the provider declares as internal via
273
+ * `PerpsProviderPlugin.internalSetupActions`. Each step is built, signed,
274
+ * and executed in place with the provider's own credentials. A step is
275
+ * deferred while any staged user-facing step with a lower `sequence` is
276
+ * outstanding — it cannot succeed before its prerequisite (e.g. SET_REFERRAL
277
+ * authenticates with the credential REGISTER_API_KEY installs) and each
278
+ * doomed attempt is venue traffic. A drain failure is swallowed so it never
279
+ * blocks setup — the step stays unsatisfied and is retried on a later
280
+ * `checkSetup`.
263
281
  */
264
- private drainSetup;
282
+ private drainInternalSetup;
265
283
  /**
266
284
  * Build unsigned setup steps for the supplied descriptor subset, preserving
267
285
  * provider sequence order with SIWE descriptors prioritized.
@@ -269,9 +287,7 @@ export declare class PerpsClient {
269
287
  private buildProviderSetupActions;
270
288
  /**
271
289
  * Build the unsigned setup `ActionStep`s still outstanding for an account,
272
- * ordered by descriptor `sequence`. Only an `approval` step is staged: an
273
- * `automatic` step drains inside {@link checkSetup} and a `preference`
274
- * carries the user's own selection. The backend filters already-satisfied
290
+ * ordered by descriptor `sequence`. The backend filters already-satisfied
275
291
  * setup; each plugin contributes its own signer-bearing request fields and
276
292
  * any local-state params (e.g. Lighter's known pubkey).
277
293
  *
@@ -285,14 +301,6 @@ export declare class PerpsClient {
285
301
  * Throws on any per-step venue rejection.
286
302
  */
287
303
  private executeProviderSetup;
288
- /**
289
- * The lowest-`sequence` visible setup step that runs before `descriptor` and
290
- * is not satisfied, or `undefined` when nothing blocks it. A `preference`
291
- * reads its satisfied state from the plugin projection; an `approval` is
292
- * satisfied once the provider stages no action for it, so only the earlier
293
- * steps are staged here.
294
- */
295
- private findBlockingSetupStep;
296
304
  /**
297
305
  * Sign and submit one pre-staged setup `ActionStep` end-to-end.
298
306
  *
@@ -306,8 +314,7 @@ export declare class PerpsClient {
306
314
  * retries with a fresh step.
307
315
  *
308
316
  * @throws {PerpsError} When the step's action is not in the provider's
309
- * `setup` descriptors, or when a lower-`sequence` step on the same
310
- * checklist is still unsatisfied.
317
+ * `setup` descriptors.
311
318
  * @public
312
319
  */
313
320
  executeProviderSetupAction(params: {
@@ -316,19 +323,19 @@ export declare class PerpsClient {
316
323
  step: ActionStep;
317
324
  }): Promise<void>;
318
325
  /**
319
- * Sign and submit a single preference change (a `preference` setup step such
320
- * as Lighter `ACCOUNT_TYPE` or Hyperliquid `ACCOUNT_MODE`) end-to-end,
321
- * throwing on a venue rejection.
322
- *
323
- * Preferences are dispatched through the same {@link execute} pipeline as
324
- * trades, but unlike a trade a preference change is a single mandatory
325
- * action: a per-action `success: false` (returned as a 200 OK) means the
326
- * user's selection was rejected and must surface, not be silently dropped.
327
- * This wrapper inspects the result and throws a {@link PerpsError} carrying
328
- * the venue `error`, giving a preference the same throw contract that setup
329
- * has via {@link executeProviderSetupAction}. The only structural difference
330
- * is that a preference carries `params` (the selected value) rather than a
331
- * pre-staged step.
326
+ * Sign and submit a single provider-option change (a `Provider.options`
327
+ * tunable such as Lighter `ACCOUNT_TYPE` or Hyperliquid `ACCOUNT_MODE`)
328
+ * end-to-end, throwing on a venue rejection.
329
+ *
330
+ * Options are dispatched through the same {@link execute} pipeline as
331
+ * trades, but unlike a trade an option change is a single mandatory action:
332
+ * a per-action `success: false` (returned as a 200 OK) means the user's
333
+ * selection was rejected and must surface, not be silently dropped. This
334
+ * wrapper inspects the result and throws a {@link PerpsError} carrying the
335
+ * venue `error`, giving options the same throw contract that setup has via
336
+ * {@link executeProviderSetupAction}. The only structural difference is that
337
+ * an option carries `params` (the selected value) rather than a pre-staged
338
+ * step.
332
339
  *
333
340
  * `execute` itself is unchanged — it still returns results without throwing,
334
341
  * which the trade hooks rely on for partial-fill handling.
@@ -1 +1 @@
1
- {"version":3,"file":"PerpsClient.d.ts","sourceRoot":"","sources":["../../../src/client/PerpsClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,cAAc,EACd,eAAe,EAEf,UAAU,EACV,oBAAoB,EACpB,qBAAqB,EACrB,SAAS,EACT,cAAc,EACd,cAAc,EACd,KAAK,EACL,cAAc,EACd,wBAAwB,EACxB,QAAQ,EACR,yBAAyB,EAK1B,MAAM,mBA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C8D;QAC9D,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,kBAAkB,KAAK,IAAI,CAAA;KACpD,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAmDlC;;;;;;;;;;;;OAYG;IACG,gBAAgB,CACpB,MAAM,EAAE,sBAAsB,GAC7B,OAAO,CAAC,qBAAqB,CAAC;IASjC;;;;;;;;OAQG;IACG,kBAAkB,CACtB,MAAM,EAAE,8BAA8B,GACrC,OAAO,CAAC,qBAAqB,CAAC;IASjC;;;;;;;;;;;;;;;OAeG;IACG,iBAAiB,CAAC,CAAC,SAAS,cAAc,EAC9C,MAAM,EAAE,uBAAuB,CAAC,CAAC,CAAC,GACjC,OAAO,CAAC,qBAAqB,CAAC;CA+ClC"}
@@ -1,7 +1,8 @@
1
- import { ActionType, META_PROVIDER, PerpsErrorCode, SigningMethod, } from '@lifi/perps-types';
1
+ import { ActionType, META_PROVIDER, PerpsErrorCode, PerpsSigner, SigningMethod, } from '@lifi/perps-types';
2
2
  import Big from 'big.js';
3
3
  import { PerpsError } from '../errors/PerpsError.js';
4
- import { getAssetRegistry } from '../registry/assetRegistry.js';
4
+ import { getAssetRegistry, toAssetDisplay } from '../registry/assetRegistry.js';
5
+ import { getMarketRegistry } from '../registry/marketRegistry.js';
5
6
  import { createAction } from '../services/createAction.js';
6
7
  import { executeAction } from '../services/executeAction.js';
7
8
  import { getAccount as fetchAccount } from '../services/getAccount.js';
@@ -12,25 +13,16 @@ import { signTypedDataWithSigner } from '../utils/signTypedData.js';
12
13
  import { eip712DomainChainId, switchSigningChain, userEip712TargetChainId, } from '../utils/switchChain.js';
13
14
  import { createPerpsClient } from './createPerpsClient.js';
14
15
  import { requireProvider as resolveProvider } from './requireProvider.js';
15
- /** Absent `sequence` sorts last, so an unordered step gates nothing. */
16
- function sequenceOf(descriptor) {
17
- return descriptor.sequence ?? Number.MAX_SAFE_INTEGER;
18
- }
19
- /**
20
- * Whether the SDK can apply a preference without user input. Every declared
21
- * parameter must carry a `default`, since the action's params object is only
22
- * complete when each one has a value.
23
- */
24
- function declaresDefault(descriptor) {
25
- const params = descriptor.params ?? [];
26
- return (params.length > 0 && params.every((param) => param.default !== undefined));
27
- }
28
16
  /**
29
17
  * Look up an action's descriptor in the provider's metadata. Throws if the
30
18
  * action isn't declared — defensive: better to fail loudly than to mis-sign.
31
19
  */
32
20
  function findActionDescriptor(metadata, action) {
33
- const descriptor = [...metadata.setup, ...metadata.actions].find((d) => d.type === action);
21
+ const descriptor = [
22
+ ...metadata.setup,
23
+ ...metadata.options,
24
+ ...metadata.actions,
25
+ ].find((d) => d.type === action);
34
26
  if (!descriptor) {
35
27
  throw new PerpsError(PerpsErrorCode.SDKError, `Provider '${metadata.key}' does not declare action '${action}'.`);
36
28
  }
@@ -291,7 +283,7 @@ export class PerpsClient {
291
283
  /**
292
284
  * Fetch the user's account state from the backend and attach the
293
285
  * SDK-projected `settings` array — one `AccountConfigSetting` per
294
- * descriptor on `Provider.setup`. Callers read
286
+ * descriptor on `Provider.setup` + `Provider.options`. Callers read
295
287
  * `result.settings` directly without re-deriving values from the typed
296
288
  * `AccountConfig`.
297
289
  *
@@ -305,7 +297,7 @@ export class PerpsClient {
305
297
  fetchAccount(this.sdkClient, params),
306
298
  this.getProviderMetadata(params.provider),
307
299
  ]);
308
- const settings = plugin.projectConfig(response.config, metadata.setup);
300
+ const settings = plugin.projectConfig(response.config, metadata.setup, metadata.options);
309
301
  return { ...response, settings };
310
302
  }
311
303
  /**
@@ -324,6 +316,39 @@ export class PerpsClient {
324
316
  market: params.market,
325
317
  });
326
318
  }
319
+ /**
320
+ * The amounts `params.address` can still buy and sell on one market, in
321
+ * that market's margin asset. The order panel reads this per-market figure;
322
+ * account displays read the account-scoped
323
+ * {@link AccountSummary.availableMargin} instead.
324
+ *
325
+ * Providers that read a per-market figure answer it directly. For every
326
+ * other provider this falls back to the account summary, so both sides
327
+ * equal `availableMargin` and the asset is the market's quote asset.
328
+ *
329
+ * @throws {PerpsError} When the provider plugin is not registered, or the
330
+ * market is unknown to the provider's market registry.
331
+ * @public
332
+ */
333
+ async getAvailableToTrade(params, options) {
334
+ const plugin = this.requireProvider(params.provider);
335
+ const perMarket = await plugin.getAvailableToTrade?.({ address: params.address, marketId: params.marketId }, options);
336
+ if (perMarket !== undefined) {
337
+ return perMarket;
338
+ }
339
+ const registry = getMarketRegistry(this.sdkClient, params.provider);
340
+ await registry.sync();
341
+ const market = registry.require(params.marketId);
342
+ const account = await fetchAccount(this.sdkClient, { provider: params.provider, address: params.address }, options);
343
+ const { availableMargin } = plugin.getAccountSummary(account, account.positions);
344
+ return {
345
+ providerId: market.providerId,
346
+ marketId: market.id,
347
+ asset: toAssetDisplay(market.quoteAsset),
348
+ buy: availableMargin,
349
+ sell: availableMargin,
350
+ };
351
+ }
327
352
  /**
328
353
  * Resolve the exact venue-owned margin requirements for `position`.
329
354
  * Returns `undefined` when the position has no individual margin adjustment.
@@ -431,16 +456,15 @@ export class PerpsClient {
431
456
  return plugin.getPortfolioHistory({ address: params.address, range: params.range }, options);
432
457
  }
433
458
  /**
434
- * Return the setup steps this account must still sign as a flat,
435
- * self-describing list. Trading is gated on `isReady === true`.
436
- * `checklist` carries the renderable onboarding list: every `approval` and
437
- * `preference` descriptor with its satisfied state, with not-required
438
- * conditional steps omitted.
459
+ * Return the unsatisfied entries on `Provider.setup` for this account as a
460
+ * flat, self-describing list. Trading is gated on `isReady === true`.
461
+ * `checklist` carries the renderable onboarding list: every USER-signed
462
+ * descriptor with its satisfied state, with not-required conditional steps
463
+ * omitted.
439
464
  *
440
- * `automatic` descriptors are NEVER returned here — the SDK drains them with
441
- * the provider's own credentials. A `preference` is listed but never staged:
442
- * the user re-enters it through {@link executeProviderOption}, and the SDK
443
- * applies the descriptor's declared default while it stays unsatisfied.
465
+ * `Provider.options` descriptors are NEVER returned here — options are
466
+ * post-setup tunables and never gate trading. Option state is surfaced
467
+ * separately via `getAccount().settings`.
444
468
  *
445
469
  * @public
446
470
  */
@@ -464,32 +488,30 @@ export class PerpsClient {
464
488
  const satisfiedSetup = await this.resolveSatisfiedSetup(provider, address);
465
489
  const pendingSetup = metadata.setup.filter((descriptor) => !satisfiedSetup.has(descriptor.type));
466
490
  const plugin = this.sdkClient.getProvider(provider);
467
- // Only an `approval` is staged by the generic loop: an `automatic` step is
468
- // drained below, and a `preference` is re-entered by the user through
469
- // `executeProviderOption` rather than signed off a staged step.
470
- const stageable = pendingSetup.filter((descriptor) => descriptor.kind === 'approval');
491
+ const internalTypes = new Set(plugin?.internalSetupActions ?? []);
492
+ const isInternal = (descriptor) => internalTypes.has(descriptor.type) &&
493
+ !descriptor.signers.includes(PerpsSigner.USER);
494
+ const visibleSetup = pendingSetup.filter((descriptor) => !isInternal(descriptor));
471
495
  // The backend filters already-satisfied setup actions and returns typed
472
496
  // data for those still outstanding; each plugin contributes its own
473
497
  // signer-bearing request fields.
474
- const actions = await this.buildProviderSetupActions(provider, address, stageable);
498
+ const actions = await this.buildProviderSetupActions(provider, address, visibleSetup);
475
499
  // A staged step is one the build produced actions for — a pending
476
500
  // descriptor the backend staged nothing for is either satisfied
477
501
  // (backend-gated) or not applicable to this account.
478
502
  const stagedTypes = new Set(actions.map((step) => step.action));
479
503
  const conditionalTypes = new Set(plugin?.conditionalSetupActions ?? []);
504
+ const sequenceOf = (descriptor) => descriptor.sequence ?? Number.MAX_SAFE_INTEGER;
480
505
  const checklist = metadata.setup
481
- .filter((descriptor) => descriptor.kind !== 'automatic')
506
+ .filter((descriptor) => descriptor.signers.includes(PerpsSigner.USER))
482
507
  .filter((descriptor) => !conditionalTypes.has(descriptor.type) ||
483
508
  stagedTypes.has(descriptor.type))
484
509
  .sort((a, b) => sequenceOf(a) - sequenceOf(b))
485
510
  .map((descriptor) => ({
486
511
  descriptor,
487
- satisfied: descriptor.kind === 'preference'
488
- ? satisfiedSetup.has(descriptor.type)
489
- : !stagedTypes.has(descriptor.type),
512
+ satisfied: !stagedTypes.has(descriptor.type),
490
513
  }));
491
- await this.drainSetup(provider, address, pendingSetup.filter((descriptor) => descriptor.kind === 'automatic' ||
492
- (descriptor.kind === 'preference' && declaresDefault(descriptor))), stageable.filter((descriptor) => stagedTypes.has(descriptor.type)));
514
+ await this.drainInternalSetup(provider, address, pendingSetup.filter(isInternal), visibleSetup.filter((descriptor) => stagedTypes.has(descriptor.type)));
493
515
  return {
494
516
  accountExists: true,
495
517
  setup: actions,
@@ -509,26 +531,28 @@ export class PerpsClient {
509
531
  return new Set();
510
532
  }
511
533
  const account = await plugin.getAccount({ address });
512
- const settings = plugin.projectConfig(account.config, metadata.setup);
534
+ const settings = plugin.projectConfig(account.config, metadata.setup, metadata.options);
535
+ const setupTypes = new Set(metadata.setup.map((descriptor) => descriptor.type));
513
536
  return new Set(settings
514
- .filter((setting) => setting.satisfied)
537
+ .filter((setting) => setting.satisfied && setupTypes.has(setting.type))
515
538
  .map((setting) => setting.type));
516
539
  }
517
540
  /**
518
- * Drain the pending setup steps the SDK fulfils without user input: every
519
- * `automatic` step, and every unsatisfied `preference` whose descriptor
520
- * declares a parameter default. Each step is built, signed, and executed in
521
- * place with the provider's own credentials. A step is deferred while any
522
- * staged user-facing step with a lower `sequence` is outstanding — it cannot
523
- * succeed before its prerequisite (e.g. SET_REFERRAL authenticates with the
524
- * credential REGISTER_API_KEY installs) and each doomed attempt is venue
525
- * traffic. A drain failure is swallowed so it never blocks setup — the step
526
- * stays unsatisfied and is retried on a later `checkSetup`.
541
+ * Drain the pending setup steps the provider declares as internal via
542
+ * `PerpsProviderPlugin.internalSetupActions`. Each step is built, signed,
543
+ * and executed in place with the provider's own credentials. A step is
544
+ * deferred while any staged user-facing step with a lower `sequence` is
545
+ * outstanding — it cannot succeed before its prerequisite (e.g. SET_REFERRAL
546
+ * authenticates with the credential REGISTER_API_KEY installs) and each
547
+ * doomed attempt is venue traffic. A drain failure is swallowed so it never
548
+ * blocks setup — the step stays unsatisfied and is retried on a later
549
+ * `checkSetup`.
527
550
  */
528
- async drainSetup(provider, address, drainable, stagedVisible) {
529
- for (const descriptor of drainable) {
551
+ async drainInternalSetup(provider, address, internalPending, stagedVisible) {
552
+ const sequenceOf = (descriptor) => descriptor.sequence ?? Number.MAX_SAFE_INTEGER;
553
+ for (const descriptor of internalPending) {
530
554
  // A tie (equal sequences, or both absent) declares no order, so the
531
- // drained step defers to the next checkSetup rather than racing.
555
+ // internal step defers to the next checkSetup rather than racing.
532
556
  const blocked = stagedVisible.some((staged) => sequenceOf(staged) <= sequenceOf(descriptor));
533
557
  if (blocked) {
534
558
  continue;
@@ -550,7 +574,7 @@ export class PerpsClient {
550
574
  }
551
575
  }
552
576
  catch (error) {
553
- console.debug(`[perps-sdk] setup step '${descriptor.type}' for '${provider}' did not drain; will retry on the next checkSetup.`, error);
577
+ console.debug(`[perps-sdk] internal setup step '${descriptor.type}' for '${provider}' did not complete; will retry on the next checkSetup.`, error);
554
578
  }
555
579
  }
556
580
  }
@@ -587,9 +611,7 @@ export class PerpsClient {
587
611
  }
588
612
  /**
589
613
  * Build the unsigned setup `ActionStep`s still outstanding for an account,
590
- * ordered by descriptor `sequence`. Only an `approval` step is staged: an
591
- * `automatic` step drains inside {@link checkSetup} and a `preference`
592
- * carries the user's own selection. The backend filters already-satisfied
614
+ * ordered by descriptor `sequence`. The backend filters already-satisfied
593
615
  * setup; each plugin contributes its own signer-bearing request fields and
594
616
  * any local-state params (e.g. Lighter's known pubkey).
595
617
  *
@@ -598,7 +620,7 @@ export class PerpsClient {
598
620
  async buildProviderSetup(params) {
599
621
  const { provider, address } = params;
600
622
  const metadata = await this.getProviderMetadata(provider);
601
- const actions = await this.buildProviderSetupActions(provider, address, metadata.setup.filter((descriptor) => descriptor.kind === 'approval'));
623
+ const actions = await this.buildProviderSetupActions(provider, address, metadata.setup);
602
624
  return { actions };
603
625
  }
604
626
  /**
@@ -633,33 +655,6 @@ export class PerpsClient {
633
655
  }
634
656
  return { results: { results } };
635
657
  }
636
- /**
637
- * The lowest-`sequence` visible setup step that runs before `descriptor` and
638
- * is not satisfied, or `undefined` when nothing blocks it. A `preference`
639
- * reads its satisfied state from the plugin projection; an `approval` is
640
- * satisfied once the provider stages no action for it, so only the earlier
641
- * steps are staged here.
642
- */
643
- async findBlockingSetupStep(provider, address, descriptor) {
644
- const metadata = await this.getProviderMetadata(provider);
645
- const earlier = metadata.setup
646
- .filter((d) => d.kind !== 'automatic' && sequenceOf(d) < sequenceOf(descriptor))
647
- .sort((a, b) => sequenceOf(a) - sequenceOf(b));
648
- if (earlier.length === 0) {
649
- return undefined;
650
- }
651
- const satisfiedSetup = await this.resolveSatisfiedSetup(provider, address);
652
- const pending = earlier.filter((d) => !satisfiedSetup.has(d.type));
653
- if (pending.length === 0) {
654
- return undefined;
655
- }
656
- const stageable = pending.filter((d) => d.kind === 'approval');
657
- const staged = stageable.length === 0
658
- ? []
659
- : await this.buildProviderSetupActions(provider, address, stageable);
660
- const stagedTypes = new Set(staged.map((action) => action.action));
661
- return pending.find((d) => d.kind === 'preference' || stagedTypes.has(d.type));
662
- }
663
658
  /**
664
659
  * Sign and submit one pre-staged setup `ActionStep` end-to-end.
665
660
  *
@@ -673,8 +668,7 @@ export class PerpsClient {
673
668
  * retries with a fresh step.
674
669
  *
675
670
  * @throws {PerpsError} When the step's action is not in the provider's
676
- * `setup` descriptors, or when a lower-`sequence` step on the same
677
- * checklist is still unsatisfied.
671
+ * `setup` descriptors.
678
672
  * @public
679
673
  */
680
674
  async executeProviderSetupAction(params) {
@@ -684,10 +678,6 @@ export class PerpsClient {
684
678
  if (!descriptor) {
685
679
  throw new PerpsError(PerpsErrorCode.SDKError, `Action '${step.action}' is not in '${provider}'.setup`);
686
680
  }
687
- const blocking = await this.findBlockingSetupStep(provider, address, descriptor);
688
- if (blocking) {
689
- throw new PerpsError(PerpsErrorCode.SDKError, `Setup step '${step.action}' for '${provider}' is blocked: '${blocking.type}' runs first and is not satisfied.`);
690
- }
691
681
  const signed = await this.signProviderSetupAction(provider, address, step);
692
682
  // A client-executed setup action (Lighter SET_REFERRAL) produces no
693
683
  // backend-bound step — it already ran during signing, so there is nothing
@@ -703,19 +693,19 @@ export class PerpsClient {
703
693
  });
704
694
  }
705
695
  /**
706
- * Sign and submit a single preference change (a `preference` setup step such
707
- * as Lighter `ACCOUNT_TYPE` or Hyperliquid `ACCOUNT_MODE`) end-to-end,
708
- * throwing on a venue rejection.
696
+ * Sign and submit a single provider-option change (a `Provider.options`
697
+ * tunable such as Lighter `ACCOUNT_TYPE` or Hyperliquid `ACCOUNT_MODE`)
698
+ * end-to-end, throwing on a venue rejection.
709
699
  *
710
- * Preferences are dispatched through the same {@link execute} pipeline as
711
- * trades, but unlike a trade a preference change is a single mandatory
712
- * action: a per-action `success: false` (returned as a 200 OK) means the
713
- * user's selection was rejected and must surface, not be silently dropped.
714
- * This wrapper inspects the result and throws a {@link PerpsError} carrying
715
- * the venue `error`, giving a preference the same throw contract that setup
716
- * has via {@link executeProviderSetupAction}. The only structural difference
717
- * is that a preference carries `params` (the selected value) rather than a
718
- * pre-staged step.
700
+ * Options are dispatched through the same {@link execute} pipeline as
701
+ * trades, but unlike a trade an option change is a single mandatory action:
702
+ * a per-action `success: false` (returned as a 200 OK) means the user's
703
+ * selection was rejected and must surface, not be silently dropped. This
704
+ * wrapper inspects the result and throws a {@link PerpsError} carrying the
705
+ * venue `error`, giving options the same throw contract that setup has via
706
+ * {@link executeProviderSetupAction}. The only structural difference is that
707
+ * an option carries `params` (the selected value) rather than a pre-staged
708
+ * step.
719
709
  *
720
710
  * `execute` itself is unchanged — it still returns results without throwing,
721
711
  * which the trade hooks rely on for partial-fill handling.