@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.
- package/README.md +66 -1
- package/dist/cjs/client/PerpsClient.d.ts +5 -5
- package/dist/cjs/client/PerpsClient.d.ts.map +1 -1
- package/dist/cjs/client/PerpsClient.js +73 -75
- package/dist/cjs/client/PerpsClient.js.map +1 -1
- package/dist/cjs/errors/PerpsExecutionError.d.ts +9 -0
- package/dist/cjs/errors/PerpsExecutionError.d.ts.map +1 -0
- package/dist/cjs/errors/PerpsExecutionError.js +29 -0
- package/dist/cjs/errors/PerpsExecutionError.js.map +1 -0
- package/dist/cjs/index.d.ts +6 -4
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +16 -12
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/math/fills.d.ts +0 -1
- package/dist/cjs/math/fills.d.ts.map +1 -1
- package/dist/cjs/math/fills.js +0 -18
- package/dist/cjs/math/fills.js.map +1 -1
- package/dist/cjs/math/order.d.ts +5 -5
- package/dist/cjs/math/order.d.ts.map +1 -1
- package/dist/cjs/math/order.js +10 -10
- package/dist/cjs/math/order.js.map +1 -1
- package/dist/cjs/math/position.d.ts +2 -2
- package/dist/cjs/math/position.d.ts.map +1 -1
- package/dist/cjs/math/position.js +5 -5
- package/dist/cjs/math/position.js.map +1 -1
- package/dist/cjs/types/api.d.ts +1 -10
- package/dist/cjs/types/api.d.ts.map +1 -1
- package/dist/cjs/types/provider.d.ts +5 -1
- package/dist/cjs/types/provider.d.ts.map +1 -1
- package/dist/cjs/utils/actionResult.d.ts +3 -0
- package/dist/cjs/utils/actionResult.d.ts.map +1 -0
- package/dist/cjs/utils/actionResult.js +9 -0
- package/dist/cjs/utils/actionResult.js.map +1 -0
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/client/PerpsClient.d.ts +64 -47
- package/dist/esm/client/PerpsClient.d.ts.map +1 -1
- package/dist/esm/client/PerpsClient.js +134 -128
- package/dist/esm/client/PerpsClient.js.map +1 -1
- package/dist/esm/errors/PerpsExecutionError.d.ts +24 -0
- package/dist/esm/errors/PerpsExecutionError.d.ts.map +1 -0
- package/dist/esm/errors/PerpsExecutionError.js +39 -0
- package/dist/esm/errors/PerpsExecutionError.js.map +1 -0
- 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/math/fills.d.ts +0 -9
- package/dist/esm/math/fills.d.ts.map +1 -1
- package/dist/esm/math/fills.js +0 -25
- package/dist/esm/math/fills.js.map +1 -1
- package/dist/esm/math/order.d.ts +6 -6
- package/dist/esm/math/order.d.ts.map +1 -1
- package/dist/esm/math/order.js +6 -6
- package/dist/esm/math/order.js.map +1 -1
- package/dist/esm/math/position.d.ts +2 -2
- package/dist/esm/math/position.d.ts.map +1 -1
- package/dist/esm/math/position.js +3 -3
- package/dist/esm/math/position.js.map +1 -1
- package/dist/esm/types/api.d.ts +1 -18
- package/dist/esm/types/api.d.ts.map +1 -1
- package/dist/esm/types/provider.d.ts +21 -4
- package/dist/esm/types/provider.d.ts.map +1 -1
- package/dist/esm/utils/actionResult.d.ts +4 -0
- package/dist/esm/utils/actionResult.d.ts.map +1 -0
- package/dist/esm/utils/actionResult.js +7 -0
- package/dist/esm/utils/actionResult.js.map +1 -0
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/types/client/PerpsClient.d.ts +64 -47
- package/dist/types/client/PerpsClient.d.ts.map +1 -1
- package/dist/types/errors/PerpsExecutionError.d.ts +24 -0
- package/dist/types/errors/PerpsExecutionError.d.ts.map +1 -0
- package/dist/types/index.d.ts +6 -4
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/math/fills.d.ts +0 -9
- package/dist/types/math/fills.d.ts.map +1 -1
- package/dist/types/math/order.d.ts +6 -6
- package/dist/types/math/order.d.ts.map +1 -1
- package/dist/types/math/position.d.ts +2 -2
- package/dist/types/math/position.d.ts.map +1 -1
- package/dist/types/types/api.d.ts +1 -18
- package/dist/types/types/api.d.ts.map +1 -1
- package/dist/types/types/provider.d.ts +21 -4
- package/dist/types/types/provider.d.ts.map +1 -1
- package/dist/types/utils/actionResult.d.ts +4 -0
- package/dist/types/utils/actionResult.d.ts.map +1 -0
- package/dist/types/version.d.ts +1 -1
- package/package.json +2 -2
- package/src/client/PerpsClient.ts +165 -166
- package/src/errors/PerpsExecutionError.ts +54 -0
- package/src/index.ts +13 -8
- package/src/math/fills.ts +0 -29
- package/src/math/order.ts +11 -11
- package/src/math/position.ts +3 -3
- package/src/types/api.ts +0 -21
- package/src/types/provider.ts +22 -4
- package/src/utils/actionResult.ts +10 -0
- 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,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,2BA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AG,aAAa,CAAA;IAEjE;;;;;;;;;;;OAWG;IACH,wBAAwB,CACtB,MAAM,EAAE,WAAW,EACnB,MAAM,EAAE,yBAAyB,GAChC,MAAM,GAAG,SAAS,CAAA;IAErB;;;;;;;;;;OAUG;IACH,uBAAuB,CAAC,QAAQ,EAAE,QAAQ,GAAG,aAAa,GAAG,SAAS,CAAA;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,
|
|
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,EAC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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 @@
|
|
|
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"}
|
package/dist/types/version.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lifi/perps-sdk",
|
|
3
|
-
"version": "
|
|
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": "^
|
|
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<
|
|
458
|
+
): Promise<SignActionsResult> {
|
|
466
459
|
const plugin = this.requireProvider(provider)
|
|
467
|
-
|
|
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
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
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
|
-
|
|
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
|
|
493
|
-
*
|
|
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
|
|
509
|
-
*
|
|
510
|
-
*
|
|
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 (
|
|
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
|
|
614
|
-
*
|
|
615
|
-
*
|
|
616
|
-
*
|
|
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
|
|
671
|
+
private async runProviderSetupStep(
|
|
625
672
|
provider: string,
|
|
626
673
|
address: Address,
|
|
627
674
|
step: ActionStep
|
|
628
|
-
): Promise<
|
|
675
|
+
): Promise<ActionResult[]> {
|
|
629
676
|
const metadata = await this.getProviderMetadata(provider)
|
|
630
|
-
const
|
|
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
|
-
|
|
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
|
|
1146
|
-
* blocks setup — the step stays unsatisfied and is
|
|
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
|
|
1234
|
+
const results = await this.runProviderSetupStep(
|
|
1170
1235
|
provider,
|
|
1171
1236
|
address,
|
|
1172
1237
|
step
|
|
1173
1238
|
)
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
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,
|
|
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<
|
|
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
|
-
|
|
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
|
-
*
|
|
1381
|
+
* through the same {@link execute} pipeline as a trade.
|
|
1364
1382
|
*
|
|
1365
|
-
*
|
|
1366
|
-
*
|
|
1367
|
-
*
|
|
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}
|
|
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<
|
|
1394
|
+
}): Promise<ExecuteActionResponse> {
|
|
1381
1395
|
const { provider, address, option } = params
|
|
1382
|
-
|
|
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
|
|
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<
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
1724
|
-
*
|
|
1725
|
-
*
|
|
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
|
-
|
|
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
|
}
|