@lifi/perps-sdk 6.2.1 → 6.4.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 (52) hide show
  1. package/dist/cjs/client/PerpsClient.d.ts +3 -1
  2. package/dist/cjs/client/PerpsClient.d.ts.map +1 -1
  3. package/dist/cjs/client/PerpsClient.js +36 -0
  4. package/dist/cjs/client/PerpsClient.js.map +1 -1
  5. package/dist/cjs/index.d.ts +3 -2
  6. package/dist/cjs/index.d.ts.map +1 -1
  7. package/dist/cjs/index.js.map +1 -1
  8. package/dist/cjs/types/api.d.ts +5 -1
  9. package/dist/cjs/types/api.d.ts.map +1 -1
  10. package/dist/cjs/types/provider.d.ts +5 -0
  11. package/dist/cjs/types/provider.d.ts.map +1 -1
  12. package/dist/cjs/types/withdrawal.d.ts +13 -0
  13. package/dist/cjs/types/withdrawal.d.ts.map +1 -0
  14. package/dist/cjs/types/withdrawal.js +3 -0
  15. package/dist/cjs/types/withdrawal.js.map +1 -0
  16. package/dist/cjs/version.d.ts +1 -1
  17. package/dist/cjs/version.js +1 -1
  18. package/dist/esm/client/PerpsClient.d.ts +17 -1
  19. package/dist/esm/client/PerpsClient.d.ts.map +1 -1
  20. package/dist/esm/client/PerpsClient.js +47 -0
  21. package/dist/esm/client/PerpsClient.js.map +1 -1
  22. package/dist/esm/index.d.ts +3 -2
  23. package/dist/esm/index.d.ts.map +1 -1
  24. package/dist/esm/index.js.map +1 -1
  25. package/dist/esm/types/api.d.ts +10 -1
  26. package/dist/esm/types/api.d.ts.map +1 -1
  27. package/dist/esm/types/provider.d.ts +20 -0
  28. package/dist/esm/types/provider.d.ts.map +1 -1
  29. package/dist/esm/types/withdrawal.d.ts +37 -0
  30. package/dist/esm/types/withdrawal.d.ts.map +1 -0
  31. package/dist/esm/types/withdrawal.js +2 -0
  32. package/dist/esm/types/withdrawal.js.map +1 -0
  33. package/dist/esm/version.d.ts +1 -1
  34. package/dist/esm/version.js +1 -1
  35. package/dist/types/client/PerpsClient.d.ts +17 -1
  36. package/dist/types/client/PerpsClient.d.ts.map +1 -1
  37. package/dist/types/index.d.ts +3 -2
  38. package/dist/types/index.d.ts.map +1 -1
  39. package/dist/types/types/api.d.ts +10 -1
  40. package/dist/types/types/api.d.ts.map +1 -1
  41. package/dist/types/types/provider.d.ts +20 -0
  42. package/dist/types/types/provider.d.ts.map +1 -1
  43. package/dist/types/types/withdrawal.d.ts +37 -0
  44. package/dist/types/types/withdrawal.d.ts.map +1 -0
  45. package/dist/types/version.d.ts +1 -1
  46. package/package.json +4 -3
  47. package/src/client/PerpsClient.ts +55 -0
  48. package/src/index.ts +7 -0
  49. package/src/types/api.ts +11 -1
  50. package/src/types/provider.ts +25 -0
  51. package/src/types/withdrawal.ts +39 -0
  52. package/src/version.ts +1 -1
package/src/index.ts CHANGED
@@ -101,6 +101,7 @@ export type {
101
101
  GetAccountResult,
102
102
  GetDepositFlowParams,
103
103
  GetSetupParams,
104
+ GetWithdrawableBalancesParams,
104
105
  ModifyOrdersParams,
105
106
  PerpsClientOptions,
106
107
  PerpsConfig,
@@ -143,10 +144,16 @@ export type {
143
144
  ProviderGetOrdersParams,
144
145
  ProviderGetPositionsParams,
145
146
  ProviderGetQuoteParams,
147
+ ProviderGetWithdrawableBalancesParams,
146
148
  QuoteListener,
147
149
  SignActionProgress,
148
150
  SignActionsContext,
149
151
  } from './types/provider.js'
152
+ export type {
153
+ ProviderWithdrawableBalance,
154
+ WithdrawableBalance,
155
+ WithdrawalRoute,
156
+ } from './types/withdrawal.js'
150
157
  export {
151
158
  type CollateralSemantics,
152
159
  summarizeAccount,
package/src/types/api.ts CHANGED
@@ -126,7 +126,7 @@ export interface PlaceOrderParams {
126
126
  /** Opaque provider market reference. */
127
127
  market: MarketRef
128
128
  side: OrderSide
129
- type: OrderType
129
+ type: Exclude<OrderType, OrderType.TWAP>
130
130
  /** Base-asset size as a decimal wire string. */
131
131
  size: string
132
132
  /** Limit price as a decimal wire string; required by limit-style orders. */
@@ -243,6 +243,16 @@ export interface GetDepositFlowParams {
243
243
  address: Address
244
244
  }
245
245
 
246
+ /**
247
+ * Parameters for {@link PerpsClient.getWithdrawableBalances}.
248
+ *
249
+ * @public
250
+ */
251
+ export interface GetWithdrawableBalancesParams {
252
+ provider: string
253
+ address: Address
254
+ }
255
+
246
256
  /**
247
257
  * Result from {@link PerpsClient.checkSetup}.
248
258
  *
@@ -33,6 +33,7 @@ import type {
33
33
  SDKRequestOptions,
34
34
  } from './config.js'
35
35
  import type { DepositFlow } from './deposit.js'
36
+ import type { ProviderWithdrawableBalance } from './withdrawal.js'
36
37
 
37
38
  /**
38
39
  * Low-level SDK client: resolved config, the optional end-user wallet, and the
@@ -176,6 +177,15 @@ export interface ProviderGetDepositFlowParams {
176
177
  address: Address
177
178
  }
178
179
 
180
+ /**
181
+ * Read params for {@link PerpsProviderPlugin.getWithdrawableBalances}.
182
+ *
183
+ * @public
184
+ */
185
+ export interface ProviderGetWithdrawableBalancesParams {
186
+ address: Address
187
+ }
188
+
179
189
  /**
180
190
  * Read params for {@link PerpsProvider.getPositions}.
181
191
  *
@@ -377,6 +387,21 @@ export interface PerpsProviderPlugin {
377
387
  options?: SDKRequestOptions
378
388
  ): Promise<DepositFlow>
379
389
 
390
+ /**
391
+ * The `(asset, route)` pairs `params.address` currently has something to
392
+ * withdraw from, keyed by provider-native asset id. Only the venue knows how
393
+ * its balance payload splits across routes, so the split is owned here; the
394
+ * per-asset venue minimum is applied by `PerpsClient.getWithdrawableBalances`,
395
+ * which holds the core asset registry.
396
+ *
397
+ * Optional: a provider whose withdrawals are not a per-route selection omits
398
+ * it, and `PerpsClient.getWithdrawableBalances` then resolves `undefined`.
399
+ */
400
+ getWithdrawableBalances?(
401
+ params: ProviderGetWithdrawableBalancesParams,
402
+ options?: SDKRequestOptions
403
+ ): Promise<ProviderWithdrawableBalance[]>
404
+
380
405
  getPositions(
381
406
  params: ProviderGetPositionsParams,
382
407
  options?: SDKRequestOptions
@@ -0,0 +1,39 @@
1
+ import type { Asset } from '@lifi/perps-types'
2
+
3
+ /**
4
+ * Which of a venue's two balance routes a withdrawal is drawn from. Lighter's
5
+ * own vocabulary, carried in the signed tx as `AssetRouteType` (`perps` = 0,
6
+ * `spot` = 1); an account's mode changes what the two balances mean, never
7
+ * which route the tx names.
8
+ *
9
+ * @public
10
+ */
11
+ export type WithdrawalRoute = 'perps' | 'spot'
12
+
13
+ /**
14
+ * One withdrawable `(asset, route)` selection as the provider reports it, keyed
15
+ * by provider-native asset id and awaiting the core asset-metadata join.
16
+ *
17
+ * @public
18
+ */
19
+ export interface ProviderWithdrawableBalance {
20
+ /** Provider-native `Asset.id`; never a display symbol. */
21
+ assetId: string
22
+ route: WithdrawalRoute
23
+ /** Withdrawable amount in the asset's own units. Always greater than zero. */
24
+ available: string
25
+ }
26
+
27
+ /**
28
+ * One withdrawable `(asset, route)` selection a caller can act on: the amount
29
+ * clears the asset's venue minimum, and `asset` carries the precision and
30
+ * minimum needed to scale and validate the withdrawal.
31
+ *
32
+ * @public
33
+ */
34
+ export interface WithdrawableBalance {
35
+ asset: Asset
36
+ route: WithdrawalRoute
37
+ /** Withdrawable amount in the asset's own units. */
38
+ available: string
39
+ }
package/src/version.ts CHANGED
@@ -10,4 +10,4 @@ export const name = '@lifi/perps-sdk'
10
10
  *
11
11
  * @public
12
12
  */
13
- export const version = '6.2.1'
13
+ export const version = '6.4.0'