@lifi/perps-sdk 25.0.2 → 27.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.
Files changed (99) hide show
  1. package/README.md +66 -1
  2. package/dist/cjs/client/PerpsClient.d.ts +5 -5
  3. package/dist/cjs/client/PerpsClient.d.ts.map +1 -1
  4. package/dist/cjs/client/PerpsClient.js +73 -75
  5. package/dist/cjs/client/PerpsClient.js.map +1 -1
  6. package/dist/cjs/errors/PerpsExecutionError.d.ts +9 -0
  7. package/dist/cjs/errors/PerpsExecutionError.d.ts.map +1 -0
  8. package/dist/cjs/errors/PerpsExecutionError.js +29 -0
  9. package/dist/cjs/errors/PerpsExecutionError.js.map +1 -0
  10. package/dist/cjs/index.d.ts +6 -4
  11. package/dist/cjs/index.d.ts.map +1 -1
  12. package/dist/cjs/index.js +16 -12
  13. package/dist/cjs/index.js.map +1 -1
  14. package/dist/cjs/math/fills.d.ts +0 -1
  15. package/dist/cjs/math/fills.d.ts.map +1 -1
  16. package/dist/cjs/math/fills.js +0 -18
  17. package/dist/cjs/math/fills.js.map +1 -1
  18. package/dist/cjs/math/order.d.ts +5 -5
  19. package/dist/cjs/math/order.d.ts.map +1 -1
  20. package/dist/cjs/math/order.js +10 -10
  21. package/dist/cjs/math/order.js.map +1 -1
  22. package/dist/cjs/math/position.d.ts +2 -2
  23. package/dist/cjs/math/position.d.ts.map +1 -1
  24. package/dist/cjs/math/position.js +5 -5
  25. package/dist/cjs/math/position.js.map +1 -1
  26. package/dist/cjs/types/api.d.ts +1 -10
  27. package/dist/cjs/types/api.d.ts.map +1 -1
  28. package/dist/cjs/types/provider.d.ts +5 -1
  29. package/dist/cjs/types/provider.d.ts.map +1 -1
  30. package/dist/cjs/utils/actionResult.d.ts +3 -0
  31. package/dist/cjs/utils/actionResult.d.ts.map +1 -0
  32. package/dist/cjs/utils/actionResult.js +9 -0
  33. package/dist/cjs/utils/actionResult.js.map +1 -0
  34. package/dist/cjs/version.d.ts +1 -1
  35. package/dist/cjs/version.js +1 -1
  36. package/dist/esm/client/PerpsClient.d.ts +64 -47
  37. package/dist/esm/client/PerpsClient.d.ts.map +1 -1
  38. package/dist/esm/client/PerpsClient.js +134 -128
  39. package/dist/esm/client/PerpsClient.js.map +1 -1
  40. package/dist/esm/errors/PerpsExecutionError.d.ts +24 -0
  41. package/dist/esm/errors/PerpsExecutionError.d.ts.map +1 -0
  42. package/dist/esm/errors/PerpsExecutionError.js +39 -0
  43. package/dist/esm/errors/PerpsExecutionError.js.map +1 -0
  44. package/dist/esm/index.d.ts +6 -4
  45. package/dist/esm/index.d.ts.map +1 -1
  46. package/dist/esm/index.js +5 -3
  47. package/dist/esm/index.js.map +1 -1
  48. package/dist/esm/math/fills.d.ts +0 -9
  49. package/dist/esm/math/fills.d.ts.map +1 -1
  50. package/dist/esm/math/fills.js +0 -25
  51. package/dist/esm/math/fills.js.map +1 -1
  52. package/dist/esm/math/order.d.ts +6 -6
  53. package/dist/esm/math/order.d.ts.map +1 -1
  54. package/dist/esm/math/order.js +6 -6
  55. package/dist/esm/math/order.js.map +1 -1
  56. package/dist/esm/math/position.d.ts +2 -2
  57. package/dist/esm/math/position.d.ts.map +1 -1
  58. package/dist/esm/math/position.js +3 -3
  59. package/dist/esm/math/position.js.map +1 -1
  60. package/dist/esm/types/api.d.ts +1 -18
  61. package/dist/esm/types/api.d.ts.map +1 -1
  62. package/dist/esm/types/provider.d.ts +21 -4
  63. package/dist/esm/types/provider.d.ts.map +1 -1
  64. package/dist/esm/utils/actionResult.d.ts +4 -0
  65. package/dist/esm/utils/actionResult.d.ts.map +1 -0
  66. package/dist/esm/utils/actionResult.js +7 -0
  67. package/dist/esm/utils/actionResult.js.map +1 -0
  68. package/dist/esm/version.d.ts +1 -1
  69. package/dist/esm/version.js +1 -1
  70. package/dist/types/client/PerpsClient.d.ts +64 -47
  71. package/dist/types/client/PerpsClient.d.ts.map +1 -1
  72. package/dist/types/errors/PerpsExecutionError.d.ts +24 -0
  73. package/dist/types/errors/PerpsExecutionError.d.ts.map +1 -0
  74. package/dist/types/index.d.ts +6 -4
  75. package/dist/types/index.d.ts.map +1 -1
  76. package/dist/types/math/fills.d.ts +0 -9
  77. package/dist/types/math/fills.d.ts.map +1 -1
  78. package/dist/types/math/order.d.ts +6 -6
  79. package/dist/types/math/order.d.ts.map +1 -1
  80. package/dist/types/math/position.d.ts +2 -2
  81. package/dist/types/math/position.d.ts.map +1 -1
  82. package/dist/types/types/api.d.ts +1 -18
  83. package/dist/types/types/api.d.ts.map +1 -1
  84. package/dist/types/types/provider.d.ts +21 -4
  85. package/dist/types/types/provider.d.ts.map +1 -1
  86. package/dist/types/utils/actionResult.d.ts +4 -0
  87. package/dist/types/utils/actionResult.d.ts.map +1 -0
  88. package/dist/types/version.d.ts +1 -1
  89. package/package.json +2 -2
  90. package/src/client/PerpsClient.ts +165 -166
  91. package/src/errors/PerpsExecutionError.ts +54 -0
  92. package/src/index.ts +13 -8
  93. package/src/math/fills.ts +0 -29
  94. package/src/math/order.ts +11 -11
  95. package/src/math/position.ts +3 -3
  96. package/src/types/api.ts +0 -21
  97. package/src/types/provider.ts +22 -4
  98. package/src/utils/actionResult.ts +10 -0
  99. 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,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,MAAM,EACN,SAAS,EACT,cAAc,EACd,KAAK,EACL,WAAW,EACX,cAAc,EACd,WAAW,EACX,WAAW,EACX,qBAAqB,EACrB,wBAAwB,EACxB,QAAQ,EACR,iBAAiB,EACjB,KAAK,EACL,SAAS,EACT,WAAW,EACX,gBAAgB,EAChB,aAAa,EACb,SAAS,EACV,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;;;;;;;;OAQG;IACH,mBAAmB,CAAC,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAA;CACzD;AAED;;;;;;;;;GASG;AACH,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,aAAa,EACb,MAAM,EACN,SAAS,EACT,cAAc,EACd,KAAK,EACL,WAAW,EACX,cAAc,EACd,WAAW,EACX,WAAW,EACX,qBAAqB,EACrB,wBAAwB,EACxB,QAAQ,EACR,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;AACpB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,KAAK,EACV,2BAA2B,EAC3B,qBAAqB,EACrB,YAAY,EACb,MAAM,iBAAiB,CAAA;AAExB;;;;;;GAMG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,MAAM,EAAE,eAAe,CAAA;IAChC,6EAA6E;IAC7E,QAAQ,CAAC,UAAU,CAAC,EAAE,iBAAiB,CAAA;IACvC,6DAA6D;IAC7D,QAAQ,CAAC,SAAS,EAAE,aAAa,EAAE,CAAA;IACnC,uDAAuD;IACvD,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS,CAAA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AA;IAEtE;;;;;;;;;;;;OAYG;IACH,aAAa,CACX,MAAM,EAAE,aAAa,EACrB,KAAK,EAAE,WAAW,EAAE,GACnB,oBAAoB,EAAE,CAAA;IAEzB;;;;;;;;OAQG;IACH,kBAAkB,CAAC,CACjB,MAAM,EAAE,UAAU,EAClB,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;IAEnC;;;;;;;;;;;;;;;OAeG;IACH,oBAAoB,CAAC,CACnB,MAAM,EAAE,UAAU,EAClB,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,WAAW,GAClB,OAAO,CAAC,wBAAwB,CAAC,CAAA;IAEpC;;;;;;;;;;;;;;;;OAgBG;IACH,WAAW,CAAC,CACV,MAAM,EAAE,aAAa,EACrB,KAAK,EAAE,UAAU,EAAE,EACnB,OAAO,EAAE,OAAO,EAChB,GAAG,CAAC,EAAE,kBAAkB,GACvB,OAAO,CAAC,iBAAiB,CAAC,CAAA;IAE7B;;;;;OAKG;IACH,gBAAgB,CAAC,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAE3E;;;;;;;;OAQG;IACH,mBAAmB,CAAC,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAA;CACzD;AAED;;;;;;;;;GASG;AACH,MAAM,MAAM,aAAa,GAAG,IAAI,CAAC,mBAAmB,EAAE,MAAM,CAAC,CAAA"}
@@ -0,0 +1,4 @@
1
+ import type { ActionResult } from '@lifi/perps-types';
2
+ /** Whether the action took effect: its status is `Submitted` or `Accepted`. */
3
+ export declare function isSubmittedOrAccepted(result: ActionResult): boolean;
4
+ //# sourceMappingURL=actionResult.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"actionResult.d.ts","sourceRoot":"","sources":["../../../src/utils/actionResult.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAGrD,+EAA+E;AAC/E,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAKnE"}
@@ -9,5 +9,5 @@ export declare const name = "@lifi/perps-sdk";
9
9
  *
10
10
  * @public
11
11
  */
12
- export declare const version = "25.0.2";
12
+ export declare const version = "27.0.0";
13
13
  //# sourceMappingURL=version.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lifi/perps-sdk",
3
- "version": "25.0.2",
3
+ "version": "27.0.0",
4
4
  "description": "LI.FI Perps SDK for perpetuals trading",
5
5
  "homepage": "https://github.com/lifinance/perps-sdk",
6
6
  "bugs": {
@@ -46,7 +46,7 @@
46
46
  "big.js": "^7.0.1",
47
47
  "partysocket": "^1.1.19",
48
48
  "viem": "^2.55.18",
49
- "@lifi/perps-types": "^22.0.0"
49
+ "@lifi/perps-types": "^24.0.0"
50
50
  },
51
51
  "publishConfig": {
52
52
  "access": "public"
@@ -35,6 +35,7 @@ import type { Address } from 'viem'
35
35
  import { isDecimalStringGreaterThan } from '../decimal/compare.js'
36
36
  import { unknownToDecimalString } from '../decimal/parse.js'
37
37
  import { PerpsError } from '../errors/PerpsError.js'
38
+ import { rethrowWithKnownResults } from '../errors/PerpsExecutionError.js'
38
39
  import { getAssetRegistry, toAssetDisplay } from '../registry/assetRegistry.js'
39
40
  import { getMarketRegistry } from '../registry/marketRegistry.js'
40
41
  import { createAction } from '../services/createAction.js'
@@ -55,8 +56,6 @@ import type {
55
56
  CancelTwapOrderParams,
56
57
  CreateReferralCodeActionParams,
57
58
  ExecuteMetaActionParams,
58
- ExecuteProviderSetupParams,
59
- ExecuteProviderSetupResult,
60
59
  GetAccountResult,
61
60
  GetDepositFlowParams,
62
61
  GetPortfolioHistoryParams,
@@ -87,12 +86,14 @@ import type {
87
86
  PerpsSDKClient,
88
87
  SignActionProgress,
89
88
  SignActionsContext,
89
+ SignActionsResult,
90
90
  } from '../types/provider.js'
91
91
  import type {
92
92
  WithdrawableBalance,
93
93
  WithdrawalSourceTypes,
94
94
  WithdrawFlow,
95
95
  } from '../types/withdrawal.js'
96
+ import { isSubmittedOrAccepted } from '../utils/actionResult.js'
96
97
  import { isUserFacingSetupStep } from '../utils/setupActions.js'
97
98
  import { signTypedDataWithSigner } from '../utils/signTypedData.js'
98
99
  import {
@@ -213,17 +214,6 @@ function currentChoiceValue(
213
214
  return value === null ? null : String(value)
214
215
  }
215
216
 
216
- /** Throw the first per-action failure a 200 OK `/executeAction` carried. */
217
- function assertAllSucceeded(results: ActionResult[]): void {
218
- const failure = results.find((r) => !r.success)
219
- if (failure) {
220
- throw new PerpsError(
221
- failure.errorCode ?? PerpsErrorCode.ExchangeRejected,
222
- failure.error
223
- )
224
- }
225
- }
226
-
227
217
  function isNonNegativeDecimal(value: string): boolean {
228
218
  try {
229
219
  return !isDecimalStringGreaterThan(
@@ -451,10 +441,13 @@ export class PerpsClient {
451
441
  * step with the signer its own descriptor declares; the signed steps come
452
442
  * back in the batch's original order. The plugin owns every signing arm and
453
443
  * branches on `signer` internally, reading the end-user's wallet from the
454
- * {@link SignActionsContext} when an arm signs as the user.
444
+ * {@link SignActionsContext} when an arm signs as the user. Signing stops
445
+ * after the first group that executed a step without an acknowledgement.
455
446
  *
456
447
  * @throws {PerpsError} When a step's action is not declared by the provider,
457
448
  * or the plugin implements no `signActions`.
449
+ * @throws {PerpsExecutionError} When a group throws after an earlier group
450
+ * executed steps.
458
451
  */
459
452
  private async delegateSignActions(
460
453
  provider: string,
@@ -462,36 +455,90 @@ export class PerpsClient {
462
455
  metadata: Provider,
463
456
  actions: ActionStep[],
464
457
  onProgress?: (progress: SignActionProgress) => void
465
- ): Promise<SignedActionStep[]> {
458
+ ): Promise<SignActionsResult> {
466
459
  const plugin = this.requireProvider(provider)
467
- if (typeof plugin.signActions !== 'function') {
460
+ const signActions = plugin.signActions?.bind(plugin)
461
+ if (signActions === undefined) {
468
462
  throw new PerpsError(
469
463
  PerpsErrorCode.SDKError,
470
464
  `Provider '${provider}' does not implement signActions.`
471
465
  )
472
466
  }
473
467
  const signed: SignedActionStep[] = []
468
+ const executed: ActionResult[] = []
474
469
  for (const group of groupStepsByDescriptor(metadata, actions)) {
475
- const userWallet = await this.resolveSigningWallet(
476
- group.descriptor,
477
- group.steps
478
- )
479
- signed.push(
480
- ...(await plugin.signActions(
470
+ try {
471
+ const userWallet = await this.resolveSigningWallet(
472
+ group.descriptor,
473
+ group.steps
474
+ )
475
+ const result = await signActions(
481
476
  group.descriptor.signingMethod,
482
477
  group.steps,
483
478
  address,
484
479
  this.buildSignActionsContext(group.descriptor, userWallet, onProgress)
485
- ))
486
- )
480
+ )
481
+ signed.push(...result.signed)
482
+ executed.push(...result.executed)
483
+ } catch (error) {
484
+ rethrowWithKnownResults(executed, error)
485
+ }
486
+ if (!executed.every(isSubmittedOrAccepted)) {
487
+ break
488
+ }
489
+ }
490
+ return { signed, executed }
491
+ }
492
+
493
+ /**
494
+ * Submit `signed` to `/executeAction` when every step the plugin executed
495
+ * while signing was acknowledged, then resolve explorer links and notify the
496
+ * plugin. Resolves to the full report: `executed`, then the `/executeAction`
497
+ * results. An empty report means nothing executed.
498
+ *
499
+ * @throws {PerpsExecutionError} When the submission or the plugin callback
500
+ * throws after a result is known.
501
+ */
502
+ private async submitSignedActions(
503
+ provider: string,
504
+ address: Address,
505
+ action: ActionType,
506
+ signerAddress: Address | undefined,
507
+ { signed, executed }: SignActionsResult
508
+ ): Promise<ActionResult[]> {
509
+ let results = executed
510
+ if (signed.length > 0 && executed.every(isSubmittedOrAccepted)) {
511
+ try {
512
+ const response = await executeAction(this.sdkClient, {
513
+ provider,
514
+ address,
515
+ // The submitting account: the plugin-resolved signer (Hyperliquid's
516
+ // agent) when present, else the end-user's address.
517
+ signerAddress: signerAddress ?? address,
518
+ action,
519
+ actions: signed,
520
+ })
521
+ results = [...executed, ...response.results]
522
+ } catch (error) {
523
+ rethrowWithKnownResults(executed, error)
524
+ }
487
525
  }
488
- return signed
526
+ if (results.length === 0) {
527
+ return results
528
+ }
529
+
530
+ try {
531
+ results = this.resolveExplorerLinks(provider, results)
532
+ await this.notifyExecuteResults(provider, address, results)
533
+ } catch (error) {
534
+ rethrowWithKnownResults(results, error)
535
+ }
536
+ return results
489
537
  }
490
538
 
491
539
  /**
492
- * Let the plugin observe `/executeAction` per-step results before the core
493
- * surfaces failures — e.g. to evict a locally stored credential the venue
494
- * rejected.
540
+ * Let the plugin observe an execution report before the core returns it —
541
+ * e.g. to evict a locally stored credential the venue refused.
495
542
  */
496
543
  private async notifyExecuteResults(
497
544
  provider: string,
@@ -505,9 +552,10 @@ export class PerpsClient {
505
552
  }
506
553
 
507
554
  /**
508
- * Attach a provider-built explorer URL to every result the backend returned a
509
- * venue `txHash` on. The provider owns its explorer target, so core only asks
510
- * — a plugin without the hook leaves results untouched.
555
+ * Attach a provider-built explorer URL to every result that carries a venue
556
+ * `txHash`, whatever its status: an unacknowledged hash is what the user
557
+ * inspects. The provider owns its explorer target, so core only asks — a
558
+ * plugin without the hook leaves results untouched.
511
559
  */
512
560
  private resolveExplorerLinks(
513
561
  provider: string,
@@ -519,7 +567,7 @@ export class PerpsClient {
519
567
  return results
520
568
  }
521
569
  return results.map((result) => {
522
- if (!result.success || result.txHash === undefined) {
570
+ if (result.txHash === undefined) {
523
571
  return result
524
572
  }
525
573
  const explorerLink = resolveLink(result.txHash)
@@ -610,30 +658,47 @@ export class PerpsClient {
610
658
  }
611
659
 
612
660
  /**
613
- * Sign a single provider setup action step by delegating to the provider
614
- * plugin, which branches on the step's signing scheme internally. Lets
615
- * consumers collect signed setup actions without embedding per-method
616
- * signing logic.
617
- *
618
- * Returns `undefined` when the plugin executed the action entirely
619
- * client-side (e.g. Lighter's token-authenticated venue mutations), leaving
620
- * no backend-bound step to submit.
661
+ * Sign one provider setup step through the provider plugin and submit it.
662
+ * A step the plugin executed client-side (e.g. Lighter's token-authenticated
663
+ * venue mutations) reports the plugin's own result instead of an
664
+ * `/executeAction` result.
621
665
  *
622
- * @throws {PerpsError} When the step's action is not declared by the provider.
666
+ * @throws {PerpsError} When the step's action is not declared by the provider,
667
+ * or signing or submission fails before any result is known.
668
+ * @throws {PerpsExecutionError} When a later stage fails after a result is
669
+ * known.
623
670
  */
624
- private async signProviderSetupAction(
671
+ private async runProviderSetupStep(
625
672
  provider: string,
626
673
  address: Address,
627
674
  step: ActionStep
628
- ): Promise<SignedActionStep | undefined> {
675
+ ): Promise<ActionResult[]> {
629
676
  const metadata = await this.getProviderMetadata(provider)
630
- const [signed] = await this.delegateSignActions(
677
+ const descriptor = findActionDescriptor(metadata, step.action)
678
+ const signResult = await this.delegateSignActions(
631
679
  provider,
632
680
  address,
633
681
  metadata,
634
682
  [step]
635
683
  )
636
- return signed
684
+ let signerAddress: Address | undefined
685
+ try {
686
+ const request = await this.resolveActionRequest(
687
+ provider,
688
+ descriptor,
689
+ address
690
+ )
691
+ signerAddress = request.signerAddress
692
+ } catch (error) {
693
+ rethrowWithKnownResults(signResult.executed, error)
694
+ }
695
+ return this.submitSignedActions(
696
+ provider,
697
+ address,
698
+ step.action,
699
+ signerAddress,
700
+ signResult
701
+ )
637
702
  }
638
703
 
639
704
  /**
@@ -1142,9 +1207,9 @@ export class PerpsClient {
1142
1207
  * deferred while any staged user-facing step with a lower `sequence` is
1143
1208
  * outstanding — it cannot succeed before its prerequisite (e.g. SET_REFERRAL
1144
1209
  * authenticates with the credential REGISTER_API_KEY installs) and each
1145
- * doomed attempt is venue traffic. A drain failure is swallowed so it never
1146
- * blocks setup — the step stays unsatisfied and is retried on a later
1147
- * `checkSetup`.
1210
+ * doomed attempt is venue traffic. A drain failure, thrown or reported, is
1211
+ * swallowed so it never blocks setup — the step stays unsatisfied and is
1212
+ * retried on a later `checkSetup`.
1148
1213
  */
1149
1214
  private async drainSetup(
1150
1215
  provider: string,
@@ -1166,18 +1231,20 @@ export class PerpsClient {
1166
1231
  descriptor,
1167
1232
  ])
1168
1233
  for (const step of steps) {
1169
- const signed = await this.signProviderSetupAction(
1234
+ const results = await this.runProviderSetupStep(
1170
1235
  provider,
1171
1236
  address,
1172
1237
  step
1173
1238
  )
1174
- if (signed !== undefined) {
1175
- await this.executeProviderSetup({
1176
- provider,
1177
- address,
1178
- setup: [step],
1179
- signedActions: [signed],
1180
- })
1239
+ const failure = results.find(
1240
+ (result) => !isSubmittedOrAccepted(result)
1241
+ )
1242
+ if (failure !== undefined) {
1243
+ console.debug(
1244
+ `[perps-sdk] setup step '${descriptor.type}' for '${provider}' reported '${failure.status}'; will retry on the next checkSetup.`,
1245
+ failure
1246
+ )
1247
+ break
1181
1248
  }
1182
1249
  }
1183
1250
  } catch (error) {
@@ -1256,49 +1323,6 @@ export class PerpsClient {
1256
1323
  return { actions }
1257
1324
  }
1258
1325
 
1259
- /**
1260
- * Submit the signed setup steps returned by `checkSetup` (and signed by the
1261
- * caller / `signProviderSetupAction`). Routes the batch on the first step's
1262
- * action and lets the plugin contribute that action's `signerAddress`.
1263
- * Throws on any per-step venue rejection.
1264
- */
1265
- private async executeProviderSetup(
1266
- params: ExecuteProviderSetupParams
1267
- ): Promise<ExecuteProviderSetupResult> {
1268
- const { provider, address, setup, signedActions } = params
1269
-
1270
- if (signedActions.length === 0) {
1271
- return { results: { results: [] } }
1272
- }
1273
-
1274
- const action = setup[0]?.action ?? signedActions[0].action
1275
- const metadata = await this.getProviderMetadata(provider)
1276
- const descriptor = findActionDescriptor(metadata, action)
1277
- const { signerAddress } = await this.resolveActionRequest(
1278
- provider,
1279
- descriptor,
1280
- address
1281
- )
1282
-
1283
- const response = await executeAction(this.sdkClient, {
1284
- provider,
1285
- address,
1286
- // The submitting account: the plugin-resolved signer (Hyperliquid's
1287
- // agent) when present, else the end-user's address.
1288
- signerAddress: signerAddress ?? address,
1289
- action,
1290
- actions: signedActions,
1291
- })
1292
-
1293
- const results = this.resolveExplorerLinks(provider, response.results)
1294
-
1295
- await this.notifyExecuteResults(provider, address, results)
1296
-
1297
- assertAllSucceeded(results)
1298
-
1299
- return { results: { results } }
1300
- }
1301
-
1302
1326
  /**
1303
1327
  * Sign and submit one pre-staged setup `ActionStep` end-to-end.
1304
1328
  *
@@ -1307,9 +1331,15 @@ export class PerpsClient {
1307
1331
  * prerequisites against that same snapshot, without another `createAction`
1308
1332
  * round-trip.
1309
1333
  *
1334
+ * Resolves to the execution report. A `Failed` or `Indeterminate` action is
1335
+ * a result in the report, not an exception.
1336
+ *
1310
1337
  * @throws {PerpsError} When the step's action is not in the provider's
1311
- * `setup` descriptors, or when a lower-`sequence` step on the same
1312
- * checklist, a choice included, is still unsatisfied.
1338
+ * `setup` descriptors, when a lower-`sequence` step on the same
1339
+ * checklist, a choice included, is still unsatisfied, or when signing or
1340
+ * submission fails before any result is known.
1341
+ * @throws {PerpsExecutionError} When a later stage fails after a result is
1342
+ * known; its `response` holds the known results.
1313
1343
  * @public
1314
1344
  */
1315
1345
  async executeProviderSetupAction(params: {
@@ -1317,7 +1347,7 @@ export class PerpsClient {
1317
1347
  address: Address
1318
1348
  step: ActionStep
1319
1349
  checklist: SetupChecklistItem[]
1320
- }): Promise<void> {
1350
+ }): Promise<ExecuteActionResponse> {
1321
1351
  const { provider, address, step, checklist } = params
1322
1352
 
1323
1353
  const metadata = await this.getProviderMetadata(provider)
@@ -1340,52 +1370,35 @@ export class PerpsClient {
1340
1370
  )
1341
1371
  }
1342
1372
 
1343
- const signed = await this.signProviderSetupAction(provider, address, step)
1344
-
1345
- // A client-executed setup action (Lighter SET_REFERRAL) produces no
1346
- // backend-bound step — it already ran during signing, so there is nothing
1347
- // to submit.
1348
- if (signed === undefined) {
1349
- return
1373
+ return {
1374
+ results: await this.runProviderSetupStep(provider, address, step),
1350
1375
  }
1351
-
1352
- await this.executeProviderSetup({
1353
- provider,
1354
- address,
1355
- setup: [step],
1356
- signedActions: [signed],
1357
- })
1358
1376
  }
1359
1377
 
1360
1378
  /**
1361
1379
  * Execute one option of a choice setup step (Lighter `ACCOUNT_TYPE`,
1362
1380
  * Hyperliquid `ACCOUNT_MODE`) end-to-end with its bound `{ type, params }`,
1363
- * throwing on a venue rejection.
1381
+ * through the same {@link execute} pipeline as a trade.
1364
1382
  *
1365
- * The option runs through the same {@link execute} pipeline as a trade, but
1366
- * a per-action `success: false` (returned as a 200 OK) means the user's
1367
- * selection was rejected and must surface, not be silently dropped.
1383
+ * Resolves to the execution report. Read each result's `status`: a `Failed`
1384
+ * or `Indeterminate` selection is a result, not an exception. `Submitted` and
1385
+ * `Accepted` mean the selection took effect.
1368
1386
  *
1369
- * @throws {PerpsError} Carrying the venue error when any returned result has
1370
- * `success: false`, under that result's `errorCode` when the backend
1371
- * classified the failure and `PerpsErrorCode.ExchangeRejected` otherwise;
1372
- * also the errors `execute` itself can throw (unregistered provider, no
1373
- * signer, signing failure).
1387
+ * @throws {PerpsError} The errors {@link execute} throws.
1374
1388
  * @public
1375
1389
  */
1376
1390
  async executeProviderOption(params: {
1377
1391
  provider: string
1378
1392
  address: Address
1379
1393
  option: SetupOption
1380
- }): Promise<void> {
1394
+ }): Promise<ExecuteActionResponse> {
1381
1395
  const { provider, address, option } = params
1382
- const { results } = await this.execute({
1396
+ return this.execute({
1383
1397
  provider,
1384
1398
  address,
1385
1399
  action: option.type,
1386
1400
  params: option.params,
1387
1401
  })
1388
- assertAllSucceeded(results)
1389
1402
  }
1390
1403
 
1391
1404
  /**
@@ -1393,16 +1406,18 @@ export class PerpsClient {
1393
1406
  * create, sign and execute, signed with that action's `Provider.actions`
1394
1407
  * descriptor. The step stages again on the next {@link checkSetup}.
1395
1408
  *
1409
+ * Resolves to the execution report.
1410
+ *
1396
1411
  * @throws {PerpsError} `SDKError` when `step.revoke` is `null` or when
1397
1412
  * `createAction` stages nothing to revoke; otherwise the errors
1398
- * {@link executeProviderOption} throws.
1413
+ * {@link execute} throws.
1399
1414
  * @public
1400
1415
  */
1401
1416
  async executeProviderRevoke(params: {
1402
1417
  provider: string
1403
1418
  address: Address
1404
1419
  step: SetupAction
1405
- }): Promise<void> {
1420
+ }): Promise<ExecuteActionResponse> {
1406
1421
  const { provider, address, step } = params
1407
1422
  if (step.revoke === null) {
1408
1423
  throw new PerpsError(
@@ -1422,7 +1437,7 @@ export class PerpsClient {
1422
1437
  `Nothing to revoke for setup step '${step.type}' on '${provider}'.`
1423
1438
  )
1424
1439
  }
1425
- assertAllSucceeded(results)
1440
+ return { results }
1426
1441
  }
1427
1442
 
1428
1443
  /**
@@ -1590,8 +1605,15 @@ export class PerpsClient {
1590
1605
  * descriptor's scheme and signer internally), and submit. Core stays
1591
1606
  * signer-agnostic — the plugin owns WHO signs and HOW.
1592
1607
  *
1608
+ * Resolves to the execution report: one result per executed step, in
1609
+ * execution order, each with its own `status`. An empty report means
1610
+ * nothing executed.
1611
+ *
1593
1612
  * @throws {PerpsError} When the action is not declared by the provider,
1594
- * the plugin cannot sign it, or submission fails.
1613
+ * the plugin cannot sign it, or submission fails before any result is
1614
+ * known.
1615
+ * @throws {PerpsExecutionError} When a later stage fails after a result is
1616
+ * known; its `response` holds the known results.
1595
1617
  * @public
1596
1618
  */
1597
1619
  async execute<T extends ActionType>(params: {
@@ -1633,7 +1655,7 @@ export class PerpsClient {
1633
1655
  } as ActionParamsMap[T],
1634
1656
  })
1635
1657
 
1636
- const signedActions = await this.delegateSignActions(
1658
+ const signResult = await this.delegateSignActions(
1637
1659
  provider,
1638
1660
  address,
1639
1661
  metadata,
@@ -1641,27 +1663,13 @@ export class PerpsClient {
1641
1663
  onProgress
1642
1664
  )
1643
1665
 
1644
- // A plugin may execute an action entirely client-side (e.g. Lighter's
1645
- // token-authenticated venue mutations), leaving no backend-bound step. With
1646
- // nothing to submit, skip the `/executeAction` hop.
1647
- if (signedActions.length === 0) {
1648
- return { staged: actions, results: [] }
1649
- }
1650
-
1651
- const response = await executeAction(this.sdkClient, {
1666
+ const results = await this.submitSignedActions(
1652
1667
  provider,
1653
1668
  address,
1654
- // The submitting account: the plugin-resolved signer (Hyperliquid's
1655
- // agent) when present, else the end-user's address.
1656
- signerAddress: signerAddress ?? address,
1657
1669
  action,
1658
- actions: signedActions,
1659
- })
1660
-
1661
- const results = this.resolveExplorerLinks(provider, response.results)
1662
-
1663
- await this.notifyExecuteResults(provider, address, results)
1664
-
1670
+ signerAddress,
1671
+ signResult
1672
+ )
1665
1673
  return { staged: actions, results }
1666
1674
  }
1667
1675
 
@@ -1717,12 +1725,13 @@ export class PerpsClient {
1717
1725
  * typed data with the configured user wallet.
1718
1726
  *
1719
1727
  * The backend returns at most one step. Resolves to `{ results: [] }` when it
1720
- * returns none, meaning no consent is outstanding for this address.
1728
+ * returns none, meaning no consent is outstanding for this address. Else it
1729
+ * resolves to the backend's execution report; read each result's `status`.
1721
1730
  *
1722
1731
  * @throws {PerpsError} When no user wallet is configured, the backend returns
1723
- * more than one step or a non-EIP-712 step, or the submitted step reports a
1724
- * failed result. A signature refusal from the wallet client propagates as
1725
- * the wallet's own error.
1732
+ * more than one step or a non-EIP-712 step, or the submission fails. A
1733
+ * signature refusal from the wallet client propagates as the wallet's own
1734
+ * error.
1726
1735
  * @public
1727
1736
  */
1728
1737
  async executeMetaAction<T extends MetaActionType>(
@@ -1757,21 +1766,11 @@ export class PerpsClient {
1757
1766
  const wallet = await this.resolveMetaSigningWallet(actions)
1758
1767
  const signature = await signTypedDataWithSigner(wallet, step.typedData)
1759
1768
 
1760
- const response = await executeAction(this.sdkClient, {
1769
+ return executeAction(this.sdkClient, {
1761
1770
  provider: META_PROVIDER,
1762
1771
  address,
1763
1772
  action,
1764
1773
  actions: [{ ...step, signature }],
1765
1774
  })
1766
-
1767
- const failure = response.results.find((r) => !r.success)
1768
- if (failure) {
1769
- throw new PerpsError(
1770
- failure.errorCode ?? PerpsErrorCode.ExchangeRejected,
1771
- failure.error
1772
- )
1773
- }
1774
-
1775
- return response
1776
1775
  }
1777
1776
  }