@lifi/perps-sdk 0.0.0-preview-e6f120b → 0.0.0-preview-d0c0a79
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 +14 -3
- package/dist/cjs/client/PerpsClient.d.ts +3 -7
- package/dist/cjs/client/PerpsClient.d.ts.map +1 -1
- package/dist/cjs/client/PerpsClient.js +36 -17
- package/dist/cjs/client/PerpsClient.js.map +1 -1
- package/dist/cjs/client/createPerpsClient.d.ts +1 -1
- package/dist/cjs/client/createPerpsClient.d.ts.map +1 -1
- package/dist/cjs/client/createPerpsClient.js +1 -1
- package/dist/cjs/client/createPerpsClient.js.map +1 -1
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/api.d.ts +13 -3
- package/dist/cjs/types/api.d.ts.map +1 -1
- package/dist/cjs/types/config.d.ts.map +1 -1
- package/dist/cjs/types/provider.d.ts +1 -0
- package/dist/cjs/types/provider.d.ts.map +1 -1
- package/dist/cjs/utils/setupActions.d.ts.map +1 -1
- package/dist/cjs/utils/setupActions.js.map +1 -1
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/client/PerpsClient.d.ts +17 -14
- package/dist/esm/client/PerpsClient.d.ts.map +1 -1
- package/dist/esm/client/PerpsClient.js +56 -25
- package/dist/esm/client/PerpsClient.js.map +1 -1
- package/dist/esm/client/createPerpsClient.d.ts +1 -1
- package/dist/esm/client/createPerpsClient.d.ts.map +1 -1
- package/dist/esm/client/createPerpsClient.js +1 -1
- package/dist/esm/client/createPerpsClient.js.map +1 -1
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/api.d.ts +50 -9
- package/dist/esm/types/api.d.ts.map +1 -1
- package/dist/esm/types/config.d.ts +6 -1
- package/dist/esm/types/config.d.ts.map +1 -1
- package/dist/esm/types/provider.d.ts +9 -0
- package/dist/esm/types/provider.d.ts.map +1 -1
- package/dist/esm/utils/setupActions.d.ts +4 -3
- package/dist/esm/utils/setupActions.d.ts.map +1 -1
- package/dist/esm/utils/setupActions.js +4 -3
- package/dist/esm/utils/setupActions.js.map +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/types/client/PerpsClient.d.ts +17 -14
- package/dist/types/client/PerpsClient.d.ts.map +1 -1
- package/dist/types/client/createPerpsClient.d.ts +1 -1
- package/dist/types/client/createPerpsClient.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/types/api.d.ts +50 -9
- package/dist/types/types/api.d.ts.map +1 -1
- package/dist/types/types/config.d.ts +6 -1
- package/dist/types/types/config.d.ts.map +1 -1
- package/dist/types/types/provider.d.ts +9 -0
- package/dist/types/types/provider.d.ts.map +1 -1
- package/dist/types/utils/setupActions.d.ts +4 -3
- package/dist/types/utils/setupActions.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +2 -2
- package/src/client/PerpsClient.ts +82 -37
- package/src/client/createPerpsClient.ts +1 -1
- package/src/index.ts +2 -0
- package/src/types/api.ts +54 -8
- package/src/types/config.ts +6 -1
- package/src/types/provider.ts +10 -0
- package/src/utils/setupActions.ts +4 -3
- package/src/version.ts +1 -1
package/src/index.ts
CHANGED
|
@@ -104,6 +104,7 @@ export type {
|
|
|
104
104
|
CancelOrdersParams,
|
|
105
105
|
CancelTwapOrderParams as ClientCancelTwapOrderParams,
|
|
106
106
|
CreateReferralCodeActionParams,
|
|
107
|
+
ExecuteMetaActionParams,
|
|
107
108
|
GetAccountResult,
|
|
108
109
|
GetDepositFlowParams,
|
|
109
110
|
GetSetupParams,
|
|
@@ -116,6 +117,7 @@ export type {
|
|
|
116
117
|
PlaceTwapOrderParams as ClientPlaceTwapOrderParams,
|
|
117
118
|
ProviderSetup,
|
|
118
119
|
SendAssetActionParams,
|
|
120
|
+
SetupChecklistItem,
|
|
119
121
|
SubmitOnboardingParams,
|
|
120
122
|
WithdrawParams,
|
|
121
123
|
} from './types/api.js'
|
package/src/types/api.ts
CHANGED
|
@@ -3,15 +3,18 @@ import type {
|
|
|
3
3
|
AccountResponse,
|
|
4
4
|
CancelTwapOrderParams as ActionCancelTwapOrderParams,
|
|
5
5
|
CreateReferralCodeParams as ActionCreateReferralCodeParams,
|
|
6
|
+
ActionParamsMap,
|
|
6
7
|
PlaceTwapOrderParams as ActionPlaceTwapOrderParams,
|
|
7
8
|
ActionStep,
|
|
8
9
|
ExecuteActionResponse,
|
|
9
10
|
MarginMode,
|
|
10
11
|
MarketRef,
|
|
12
|
+
MetaActionType,
|
|
11
13
|
ModifyOrderInput,
|
|
12
14
|
OnboardParams,
|
|
13
15
|
OrderSide,
|
|
14
16
|
OrderType,
|
|
17
|
+
ProviderAction,
|
|
15
18
|
SignedActionStep,
|
|
16
19
|
TimeInForce,
|
|
17
20
|
TriggerOrderInput,
|
|
@@ -34,12 +37,17 @@ import type { PerpsProviderPlugin } from './provider.js'
|
|
|
34
37
|
export interface PerpsConfig {
|
|
35
38
|
/**
|
|
36
39
|
* Optional integrator assertion. Sent as `x-lifi-integrator` only when
|
|
37
|
-
* `apiKey` is also set. The backend
|
|
38
|
-
*
|
|
40
|
+
* `apiKey` is also set. The backend rejects an integrator that disagrees
|
|
41
|
+
* with the key.
|
|
39
42
|
*/
|
|
40
43
|
integrator?: string
|
|
41
|
-
/**
|
|
42
|
-
|
|
44
|
+
/**
|
|
45
|
+
* Optional LI.FI API key. The production host `https://li.quest/v1/perps`
|
|
46
|
+
* accepts anonymous requests, so a key is not required there. The
|
|
47
|
+
* `develop.li.quest` and `staging.li.quest` hosts require a key. Get one at
|
|
48
|
+
* https://portal.li.fi/.
|
|
49
|
+
*/
|
|
50
|
+
apiKey?: string
|
|
43
51
|
/** Perps API base URL; defaults to {@link DEFAULT_API_URL}. */
|
|
44
52
|
apiUrl?: string
|
|
45
53
|
/** Skip the SDK-version compatibility check when set. */
|
|
@@ -94,12 +102,17 @@ export interface PerpsConfig {
|
|
|
94
102
|
export interface PerpsClientOptions {
|
|
95
103
|
/**
|
|
96
104
|
* Optional integrator assertion. Sent as `x-lifi-integrator` only when
|
|
97
|
-
* `apiKey` is also set. The backend
|
|
98
|
-
*
|
|
105
|
+
* `apiKey` is also set. The backend rejects an integrator that disagrees
|
|
106
|
+
* with the key.
|
|
99
107
|
*/
|
|
100
108
|
integrator?: string
|
|
101
|
-
/**
|
|
102
|
-
|
|
109
|
+
/**
|
|
110
|
+
* Optional LI.FI API key. The production host `https://li.quest/v1/perps`
|
|
111
|
+
* accepts anonymous requests, so a key is not required there. The
|
|
112
|
+
* `develop.li.quest` and `staging.li.quest` hosts require a key. Get one at
|
|
113
|
+
* https://portal.li.fi/.
|
|
114
|
+
*/
|
|
115
|
+
apiKey?: string
|
|
103
116
|
/** Perps API base URL; defaults to {@link DEFAULT_API_URL}. */
|
|
104
117
|
apiUrl?: string
|
|
105
118
|
/**
|
|
@@ -285,6 +298,19 @@ export interface GetWithdrawableBalancesParams {
|
|
|
285
298
|
address: Address
|
|
286
299
|
}
|
|
287
300
|
|
|
301
|
+
/**
|
|
302
|
+
* One entry on {@link ProviderSetup.checklist}: a user-facing setup
|
|
303
|
+
* descriptor plus its satisfied state for the queried account.
|
|
304
|
+
*
|
|
305
|
+
* @public
|
|
306
|
+
*/
|
|
307
|
+
export interface SetupChecklistItem {
|
|
308
|
+
/** The `Provider.setup` descriptor for this step. */
|
|
309
|
+
descriptor: ProviderAction
|
|
310
|
+
/** Whether the step is already satisfied for this account. */
|
|
311
|
+
satisfied: boolean
|
|
312
|
+
}
|
|
313
|
+
|
|
288
314
|
/**
|
|
289
315
|
* Result from {@link PerpsClient.checkSetup}.
|
|
290
316
|
*
|
|
@@ -310,6 +336,15 @@ export interface ProviderSetup {
|
|
|
310
336
|
setup: ActionStep[]
|
|
311
337
|
/** Whether all setup items are already satisfied (ready to trade) */
|
|
312
338
|
isReady: boolean
|
|
339
|
+
/**
|
|
340
|
+
* The renderable onboarding list: every USER-signed setup descriptor with
|
|
341
|
+
* its satisfied state, ordered by `sequence`. SDK-internal steps and
|
|
342
|
+
* conditional steps that staged no work for this account (see
|
|
343
|
+
* `PerpsProviderPlugin.conditionalSetupActions`) are omitted. Consumers
|
|
344
|
+
* render this list directly instead of joining `Provider.setup` metadata
|
|
345
|
+
* with the staged `setup` steps.
|
|
346
|
+
*/
|
|
347
|
+
checklist: SetupChecklistItem[]
|
|
313
348
|
}
|
|
314
349
|
|
|
315
350
|
/**
|
|
@@ -365,3 +400,14 @@ export interface CreateReferralCodeActionParams
|
|
|
365
400
|
extends ActionCreateReferralCodeParams {
|
|
366
401
|
address: Address
|
|
367
402
|
}
|
|
403
|
+
|
|
404
|
+
/**
|
|
405
|
+
* Parameters for {@link PerpsClient.executeMetaAction}.
|
|
406
|
+
*
|
|
407
|
+
* @public
|
|
408
|
+
*/
|
|
409
|
+
export interface ExecuteMetaActionParams<T extends MetaActionType> {
|
|
410
|
+
address: Address
|
|
411
|
+
action: T
|
|
412
|
+
params: ActionParamsMap[T]
|
|
413
|
+
}
|
package/src/types/config.ts
CHANGED
|
@@ -92,7 +92,12 @@ export interface PerpsBaseConfig {
|
|
|
92
92
|
* transport sends it only when `apiKey` is also non-empty.
|
|
93
93
|
*/
|
|
94
94
|
integrator?: string
|
|
95
|
-
/**
|
|
95
|
+
/**
|
|
96
|
+
* Resolved API key, or `''` when the client was built without one. The
|
|
97
|
+
* transport sends `x-lifi-api-key` only when it is non-empty. The production
|
|
98
|
+
* host `https://li.quest/v1/perps` accepts anonymous requests; the
|
|
99
|
+
* `develop.li.quest` and `staging.li.quest` hosts require a key.
|
|
100
|
+
*/
|
|
96
101
|
apiKey: string
|
|
97
102
|
/** Resolved perps API base URL. */
|
|
98
103
|
apiUrl: string
|
package/src/types/provider.ts
CHANGED
|
@@ -358,6 +358,16 @@ export interface PerpsProviderPlugin {
|
|
|
358
358
|
*/
|
|
359
359
|
readonly internalSetupActions?: readonly ActionType[]
|
|
360
360
|
|
|
361
|
+
/**
|
|
362
|
+
* Setup actions that stage work only when the account needs remediation
|
|
363
|
+
* (e.g. Hyperliquid's REVOKE_AGENT frees an agent slot only when every
|
|
364
|
+
* named slot is taken). When such a step stages no actions,
|
|
365
|
+
* `PerpsClient.checkSetup` omits it from `ProviderSetup.checklist` instead
|
|
366
|
+
* of rendering it as satisfied. Omit when every setup step is
|
|
367
|
+
* unconditional.
|
|
368
|
+
*/
|
|
369
|
+
readonly conditionalSetupActions?: readonly ActionType[]
|
|
370
|
+
|
|
361
371
|
/**
|
|
362
372
|
* Inject the runtime {@link PerpsSDKClient} into the plugin once, during
|
|
363
373
|
* {@link createPerpsClient}. The plugin captures it (config, fetch, retry,
|
|
@@ -8,9 +8,10 @@ import { PerpsSigner } from '@lifi/perps-types'
|
|
|
8
8
|
* them inline, so surfacing them would render inert cards the user can't act on.
|
|
9
9
|
*
|
|
10
10
|
* Membership is a property of the descriptor's `signers` alone, independent of
|
|
11
|
-
* any account
|
|
12
|
-
*
|
|
13
|
-
*
|
|
11
|
+
* any account. When an account is available, prefer `ProviderSetup.checklist`
|
|
12
|
+
* from `checkSetup` for the onboarding list — it applies this filter, omits
|
|
13
|
+
* not-required conditional steps, and carries each entry's satisfied state.
|
|
14
|
+
* This function remains the static, account-free projection.
|
|
14
15
|
*
|
|
15
16
|
* @param setup The provider's `setup` descriptors, in their declared order.
|
|
16
17
|
* @public
|
package/src/version.ts
CHANGED