@lifi/perps-sdk 0.0.0-preview-7bd1054 → 0.0.0-preview-e927c9c

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 (68) hide show
  1. package/dist/cjs/client/PerpsClient.d.ts.map +1 -1
  2. package/dist/cjs/client/PerpsClient.js.map +1 -1
  3. package/dist/cjs/services/getActivity.d.ts.map +1 -1
  4. package/dist/cjs/services/getActivity.js.map +1 -1
  5. package/dist/cjs/services/getFills.d.ts.map +1 -1
  6. package/dist/cjs/services/getFills.js.map +1 -1
  7. package/dist/cjs/services/getOrder.d.ts.map +1 -1
  8. package/dist/cjs/services/getOrder.js.map +1 -1
  9. package/dist/cjs/services/getOrders.d.ts.map +1 -1
  10. package/dist/cjs/services/getOrders.js.map +1 -1
  11. package/dist/cjs/services/getPositions.d.ts.map +1 -1
  12. package/dist/cjs/services/getPositions.js.map +1 -1
  13. package/dist/cjs/types/withdrawal.d.ts +5 -5
  14. package/dist/cjs/types/withdrawal.d.ts.map +1 -1
  15. package/dist/cjs/version.d.ts +1 -1
  16. package/dist/cjs/version.js +1 -1
  17. package/dist/esm/client/PerpsClient.d.ts +37 -5
  18. package/dist/esm/client/PerpsClient.d.ts.map +1 -1
  19. package/dist/esm/client/PerpsClient.js +37 -5
  20. package/dist/esm/client/PerpsClient.js.map +1 -1
  21. package/dist/esm/services/getActivity.d.ts +4 -0
  22. package/dist/esm/services/getActivity.d.ts.map +1 -1
  23. package/dist/esm/services/getActivity.js +4 -0
  24. package/dist/esm/services/getActivity.js.map +1 -1
  25. package/dist/esm/services/getFills.d.ts +4 -0
  26. package/dist/esm/services/getFills.d.ts.map +1 -1
  27. package/dist/esm/services/getFills.js +4 -0
  28. package/dist/esm/services/getFills.js.map +1 -1
  29. package/dist/esm/services/getOrder.d.ts +4 -0
  30. package/dist/esm/services/getOrder.d.ts.map +1 -1
  31. package/dist/esm/services/getOrder.js +4 -0
  32. package/dist/esm/services/getOrder.js.map +1 -1
  33. package/dist/esm/services/getOrders.d.ts +10 -1
  34. package/dist/esm/services/getOrders.d.ts.map +1 -1
  35. package/dist/esm/services/getOrders.js +10 -1
  36. package/dist/esm/services/getOrders.js.map +1 -1
  37. package/dist/esm/services/getPositions.d.ts +4 -0
  38. package/dist/esm/services/getPositions.d.ts.map +1 -1
  39. package/dist/esm/services/getPositions.js +4 -0
  40. package/dist/esm/services/getPositions.js.map +1 -1
  41. package/dist/esm/types/withdrawal.d.ts +5 -5
  42. package/dist/esm/types/withdrawal.d.ts.map +1 -1
  43. package/dist/esm/version.d.ts +1 -1
  44. package/dist/esm/version.js +1 -1
  45. package/dist/types/client/PerpsClient.d.ts +37 -5
  46. package/dist/types/client/PerpsClient.d.ts.map +1 -1
  47. package/dist/types/services/getActivity.d.ts +4 -0
  48. package/dist/types/services/getActivity.d.ts.map +1 -1
  49. package/dist/types/services/getFills.d.ts +4 -0
  50. package/dist/types/services/getFills.d.ts.map +1 -1
  51. package/dist/types/services/getOrder.d.ts +4 -0
  52. package/dist/types/services/getOrder.d.ts.map +1 -1
  53. package/dist/types/services/getOrders.d.ts +10 -1
  54. package/dist/types/services/getOrders.d.ts.map +1 -1
  55. package/dist/types/services/getPositions.d.ts +4 -0
  56. package/dist/types/services/getPositions.d.ts.map +1 -1
  57. package/dist/types/types/withdrawal.d.ts +5 -5
  58. package/dist/types/types/withdrawal.d.ts.map +1 -1
  59. package/dist/types/version.d.ts +1 -1
  60. package/package.json +2 -2
  61. package/src/client/PerpsClient.ts +37 -5
  62. package/src/services/getActivity.ts +4 -0
  63. package/src/services/getFills.ts +4 -0
  64. package/src/services/getOrder.ts +4 -0
  65. package/src/services/getOrders.ts +10 -1
  66. package/src/services/getPositions.ts +4 -0
  67. package/src/types/withdrawal.ts +5 -10
  68. package/src/version.ts +1 -1
@@ -360,7 +360,14 @@ export class PerpsClient {
360
360
  return resolveProvider(this.sdkClient, provider)
361
361
  }
362
362
 
363
- /** Read active or historical orders from the selected venue. */
363
+ /**
364
+ * Read active or historical orders from the selected venue.
365
+ *
366
+ * @throws {PerpsError} `SetupRequired` when the venue needs a credential (a
367
+ * Lighter auth token or an Ondo session) and none is stored.
368
+ * @throws {PerpsError} `Unauthorized` when the venue rejects the credential.
369
+ * @throws {PerpsError} `AccountNotFound` when the wallet has no venue account.
370
+ */
364
371
  async getOrders(
365
372
  params: GetOrdersParams,
366
373
  options?: SDKRequestOptions
@@ -368,7 +375,14 @@ export class PerpsClient {
368
375
  return fetchOrders(this.sdkClient, params, options)
369
376
  }
370
377
 
371
- /** Read one venue order through the provider's unified mapper. */
378
+ /**
379
+ * Read one venue order through the provider's unified mapper.
380
+ *
381
+ * @throws {PerpsError} `SetupRequired` when the venue needs a credential (a
382
+ * Lighter auth token or an Ondo session) and none is stored.
383
+ * @throws {PerpsError} `Unauthorized` when the venue rejects the credential.
384
+ * @throws {PerpsError} `AccountNotFound` when the wallet has no venue account.
385
+ */
372
386
  async getOrder(
373
387
  params: GetOrderParams,
374
388
  options?: SDKRequestOptions
@@ -654,6 +668,9 @@ export class PerpsClient {
654
668
  * @throws {PerpsError} When the provider plugin is not registered,
655
669
  * `ValidationError` for a spot market, or any other `PerpsError` when the
656
670
  * venue read fails or carries no usable value.
671
+ * @throws {PerpsError} `SetupRequired` when the venue needs a credential (an
672
+ * Ondo session) and none is stored.
673
+ * @throws {PerpsError} `Unauthorized` when the venue rejects the credential.
657
674
  * @public
658
675
  */
659
676
  async getMarketSettings(params: {
@@ -674,12 +691,19 @@ export class PerpsClient {
674
691
  * account displays read the account-scoped
675
692
  * {@link AccountSummary.availableMargin} instead.
676
693
  *
677
- * Providers that read a per-market figure answer it directly. For every
678
- * other provider this falls back to the account summary, so both sides
679
- * equal `availableMargin` and the asset is the market's quote asset.
694
+ * Providers that read a per-market figure answer it directly. A provider
695
+ * that has no per-market figure for the market (a Hyperliquid or Lighter
696
+ * spot market) resolves `undefined`, and this falls back to the account
697
+ * summary, so both sides equal `availableMargin` and the asset is the
698
+ * market's quote asset. A provider read that throws propagates and never
699
+ * falls back.
680
700
  *
681
701
  * @throws {PerpsError} When the provider plugin is not registered, or the
682
702
  * market is unknown to the provider's market registry.
703
+ * @throws {PerpsError} `SetupRequired` when the venue needs a credential (a
704
+ * Lighter auth token or an Ondo session) and none is stored.
705
+ * @throws {PerpsError} `Unauthorized` when the venue rejects the credential.
706
+ * @throws {PerpsError} `AccountNotFound` when the wallet has no venue account.
683
707
  * @public
684
708
  */
685
709
  async getAvailableToTrade(
@@ -813,6 +837,10 @@ export class PerpsClient {
813
837
  * @throws {PerpsError} When the provider plugin is not registered, when
814
838
  * either the plugin read or the asset sync fails, when a row's
815
839
  * `withdrawalFee` is not a non-negative decimal.
840
+ * @throws {PerpsError} `SetupRequired` when the venue needs a credential (a
841
+ * Lighter auth token or an Ondo session) and none is stored.
842
+ * @throws {PerpsError} `Unauthorized` when the venue rejects the credential.
843
+ * @throws {PerpsError} `AccountNotFound` when the wallet has no venue account.
816
844
  * @public
817
845
  */
818
846
  async getWithdrawableBalances(
@@ -877,6 +905,10 @@ export class PerpsClient {
877
905
  *
878
906
  * @throws {PerpsError} When the provider plugin is not registered, when it
879
907
  * declares no portfolio history read, or when the venue read fails.
908
+ * @throws {PerpsError} `SetupRequired` when the venue needs a credential (a
909
+ * Lighter auth token or an Ondo session) and none is stored.
910
+ * @throws {PerpsError} `Unauthorized` when the venue rejects the credential.
911
+ * @throws {PerpsError} `AccountNotFound` when the wallet has no venue account.
880
912
  * @public
881
913
  */
882
914
  async getPortfolioHistory(
@@ -30,6 +30,10 @@ export interface GetActivityParams {
30
30
  *
31
31
  * @throws {PerpsError} When the provider plugin is not registered, or on
32
32
  * backend / network / parsing errors.
33
+ * @throws {PerpsError} `SetupRequired` when the venue needs a credential (a
34
+ * Lighter auth token or an Ondo session) and none is stored.
35
+ * @throws {PerpsError} `Unauthorized` when the venue rejects the credential.
36
+ * @throws {PerpsError} `AccountNotFound` when the wallet has no venue account.
33
37
  * @example
34
38
  * ```ts
35
39
  * const { items, pagination } = await getActivity(client, {
@@ -29,6 +29,10 @@ export interface GetFillsParams {
29
29
  *
30
30
  * @throws {PerpsError} When the provider plugin is not registered, or on
31
31
  * backend / network / parsing errors.
32
+ * @throws {PerpsError} `SetupRequired` when the venue needs a credential (a
33
+ * Lighter auth token or an Ondo session) and none is stored.
34
+ * @throws {PerpsError} `Unauthorized` when the venue rejects the credential.
35
+ * @throws {PerpsError} `AccountNotFound` when the wallet has no venue account.
32
36
  * @example
33
37
  * ```ts
34
38
  * const { items, pagination } = await getFills(client, {
@@ -23,6 +23,10 @@ export interface GetOrderParams {
23
23
  *
24
24
  * @throws {PerpsError} When the provider plugin is not registered, or on
25
25
  * backend / network / parsing errors.
26
+ * @throws {PerpsError} `SetupRequired` when the venue needs a credential (a
27
+ * Lighter auth token or an Ondo session) and none is stored.
28
+ * @throws {PerpsError} `Unauthorized` when the venue rejects the credential.
29
+ * @throws {PerpsError} `AccountNotFound` when the wallet has no venue account.
26
30
  * @example
27
31
  * ```ts
28
32
  * const order = await getOrder(client, {
@@ -22,7 +22,16 @@ export interface GetOrdersParams {
22
22
  cursor?: string
23
23
  }
24
24
 
25
- /** Read account orders with active lifecycle statuses as the default filter. */
25
+ /**
26
+ * Read account orders with active lifecycle statuses as the default filter.
27
+ *
28
+ * @throws {PerpsError} When the provider plugin is not registered, or on
29
+ * backend / network / parsing errors.
30
+ * @throws {PerpsError} `SetupRequired` when the venue needs a credential (a
31
+ * Lighter auth token or an Ondo session) and none is stored.
32
+ * @throws {PerpsError} `Unauthorized` when the venue rejects the credential.
33
+ * @throws {PerpsError} `AccountNotFound` when the wallet has no venue account.
34
+ */
26
35
  export async function getOrders(
27
36
  client: PerpsSDKClient,
28
37
  params: GetOrdersParams,
@@ -27,6 +27,10 @@ export interface GetPositionsParams {
27
27
  *
28
28
  * @throws {PerpsError} When the provider plugin is not registered, or on
29
29
  * backend / network / parsing errors.
30
+ * @throws {PerpsError} `SetupRequired` when the venue needs a credential (a
31
+ * Lighter auth token or an Ondo session) and none is stored.
32
+ * @throws {PerpsError} `Unauthorized` when the venue rejects the credential.
33
+ * @throws {PerpsError} `AccountNotFound` when the wallet has no venue account.
30
34
  * @example
31
35
  * ```ts
32
36
  * const { positions } = await getPositions(client, {
@@ -1,9 +1,4 @@
1
- import type {
2
- ActionType,
3
- Asset,
4
- DecimalString,
5
- WithdrawalRoute,
6
- } from '@lifi/perps-types'
1
+ import type { ActionType, Asset, WithdrawalRoute } from '@lifi/perps-types'
7
2
  import type { Address } from 'viem'
8
3
 
9
4
  export type { WithdrawalRoute }
@@ -19,13 +14,13 @@ export interface ProviderWithdrawableBalance {
19
14
  assetId: string
20
15
  route: WithdrawalRoute
21
16
  /** Withdrawable amount in the asset's own units. Always greater than zero. */
22
- available: DecimalString
17
+ available: string
23
18
  /**
24
19
  * Flat venue fee on a withdrawal from this row, in the asset's own units.
25
20
  * Absent when the venue publishes no fee for the asset. The client rejects
26
21
  * a value that is not a non-negative decimal.
27
22
  */
28
- withdrawalFee?: DecimalString
23
+ withdrawalFee?: string
29
24
  /**
30
25
  * `true` when the venue takes `withdrawalFee` out of the requested amount,
31
26
  * `false` when it charges the fee in addition. Set together with
@@ -45,7 +40,7 @@ export interface WithdrawableBalance {
45
40
  asset: Asset
46
41
  route: WithdrawalRoute
47
42
  /** Withdrawable amount in the asset's own units. */
48
- available: DecimalString
43
+ available: string
49
44
  /**
50
45
  * Flat venue fee on a withdrawal from this row, in the asset's own units.
51
46
  * Absent when the venue publishes no fee for the asset. With
@@ -56,7 +51,7 @@ export interface WithdrawableBalance {
56
51
  * is zero or negative when the fee is at or above `available`, and the row
57
52
  * then funds no withdrawal.
58
53
  */
59
- withdrawalFee?: DecimalString
54
+ withdrawalFee?: string
60
55
  /**
61
56
  * Present only together with `withdrawalFee`. Absent on a row from a
62
57
  * provider plugin that does not report it; absence means unknown, not
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 = '0.0.0-preview-7bd1054'
13
+ export const version = '0.0.0-preview-e927c9c'