@lifi/perps-sdk 18.0.0 → 18.1.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 (49) hide show
  1. package/README.md +12 -0
  2. package/dist/cjs/client/PerpsClient.d.ts +3 -2
  3. package/dist/cjs/client/PerpsClient.d.ts.map +1 -1
  4. package/dist/cjs/client/PerpsClient.js +4 -0
  5. package/dist/cjs/client/PerpsClient.js.map +1 -1
  6. package/dist/cjs/index.d.ts +3 -3
  7. package/dist/cjs/index.d.ts.map +1 -1
  8. package/dist/cjs/index.js.map +1 -1
  9. package/dist/cjs/types/api.d.ts +4 -0
  10. package/dist/cjs/types/api.d.ts.map +1 -1
  11. package/dist/cjs/types/provider.d.ts +5 -1
  12. package/dist/cjs/types/provider.d.ts.map +1 -1
  13. package/dist/cjs/types/withdrawal.d.ts +11 -1
  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 +13 -2
  18. package/dist/esm/client/PerpsClient.d.ts.map +1 -1
  19. package/dist/esm/client/PerpsClient.js +14 -0
  20. package/dist/esm/client/PerpsClient.js.map +1 -1
  21. package/dist/esm/index.d.ts +3 -3
  22. package/dist/esm/index.d.ts.map +1 -1
  23. package/dist/esm/index.js.map +1 -1
  24. package/dist/esm/types/api.d.ts +9 -0
  25. package/dist/esm/types/api.d.ts.map +1 -1
  26. package/dist/esm/types/provider.d.ts +18 -1
  27. package/dist/esm/types/provider.d.ts.map +1 -1
  28. package/dist/esm/types/withdrawal.d.ts +30 -1
  29. package/dist/esm/types/withdrawal.d.ts.map +1 -1
  30. package/dist/esm/version.d.ts +1 -1
  31. package/dist/esm/version.js +1 -1
  32. package/dist/types/client/PerpsClient.d.ts +13 -2
  33. package/dist/types/client/PerpsClient.d.ts.map +1 -1
  34. package/dist/types/index.d.ts +3 -3
  35. package/dist/types/index.d.ts.map +1 -1
  36. package/dist/types/types/api.d.ts +9 -0
  37. package/dist/types/types/api.d.ts.map +1 -1
  38. package/dist/types/types/provider.d.ts +18 -1
  39. package/dist/types/types/provider.d.ts.map +1 -1
  40. package/dist/types/types/withdrawal.d.ts +30 -1
  41. package/dist/types/types/withdrawal.d.ts.map +1 -1
  42. package/dist/types/version.d.ts +1 -1
  43. package/package.json +2 -2
  44. package/src/client/PerpsClient.ts +19 -1
  45. package/src/index.ts +5 -0
  46. package/src/types/api.ts +10 -0
  47. package/src/types/provider.ts +23 -1
  48. package/src/types/withdrawal.ts +33 -1
  49. package/src/version.ts +1 -1
package/src/index.ts CHANGED
@@ -118,6 +118,7 @@ export type {
118
118
  GetPortfolioHistoryParams,
119
119
  GetSetupParams,
120
120
  GetWithdrawableBalancesParams,
121
+ GetWithdrawFlowParams,
121
122
  ModifyOrdersParams,
122
123
  PerpsClientOptions,
123
124
  PerpsConfig,
@@ -166,6 +167,7 @@ export type {
166
167
  ProviderGetPositionsParams,
167
168
  ProviderGetQuoteParams,
168
169
  ProviderGetWithdrawableBalancesParams,
170
+ ProviderGetWithdrawFlowParams,
169
171
  QuoteListener,
170
172
  SignActionProgress,
171
173
  SignActionsContext,
@@ -174,6 +176,9 @@ export type {
174
176
  ProviderWithdrawableBalance,
175
177
  WithdrawableBalance,
176
178
  WithdrawalRoute,
179
+ WithdrawFlow,
180
+ WithdrawFlowReady,
181
+ WithdrawFlowSetupRequired,
177
182
  } from './types/withdrawal.js'
178
183
  export { paginateActivity } from './utils/activityPaging.js'
179
184
  export type { ExpectedPnl } from './utils/calculations.js'
package/src/types/api.ts CHANGED
@@ -289,6 +289,16 @@ export interface GetDepositFlowParams {
289
289
  address: Address
290
290
  }
291
291
 
292
+ /**
293
+ * Parameters for {@link PerpsClient.getWithdrawFlow}.
294
+ *
295
+ * @public
296
+ */
297
+ export interface GetWithdrawFlowParams {
298
+ provider: string
299
+ address: Address
300
+ }
301
+
292
302
  /**
293
303
  * Parameters for {@link PerpsClient.getWithdrawableBalances}.
294
304
  *
@@ -36,7 +36,7 @@ import type {
36
36
  SDKRequestOptions,
37
37
  } from './config.js'
38
38
  import type { DepositFlow } from './deposit.js'
39
- import type { ProviderWithdrawableBalance } from './withdrawal.js'
39
+ import type { ProviderWithdrawableBalance, WithdrawFlow } from './withdrawal.js'
40
40
 
41
41
  /**
42
42
  * Low-level SDK client: resolved config, the optional end-user wallet, and the
@@ -180,6 +180,15 @@ export interface ProviderGetDepositFlowParams {
180
180
  address: Address
181
181
  }
182
182
 
183
+ /**
184
+ * Read params for {@link PerpsProviderPlugin.getWithdrawFlow}.
185
+ *
186
+ * @public
187
+ */
188
+ export interface ProviderGetWithdrawFlowParams {
189
+ address: Address
190
+ }
191
+
183
192
  /**
184
193
  * Read params for {@link PerpsProviderPlugin.getWithdrawableBalances}.
185
194
  *
@@ -421,6 +430,19 @@ export interface PerpsProviderPlugin {
421
430
  options?: SDKRequestOptions
422
431
  ): Promise<DepositFlow>
423
432
 
433
+ /**
434
+ * The withdrawal flow this venue offers `params.address`, resolved from the
435
+ * venue's own account and setup state — the destination a withdrawal goes
436
+ * to, or the venue setup that must come first.
437
+ *
438
+ * Optional: a provider without a gated withdrawal destination omits it, and
439
+ * `PerpsClient.getWithdrawFlow` then resolves `undefined`.
440
+ */
441
+ getWithdrawFlow?(
442
+ params: ProviderGetWithdrawFlowParams,
443
+ options?: SDKRequestOptions
444
+ ): Promise<WithdrawFlow>
445
+
424
446
  /**
425
447
  * The `(asset, route)` pairs `params.address` currently has something to
426
448
  * withdraw from, keyed by provider-native asset id. Only the venue knows how
@@ -1,4 +1,5 @@
1
- import type { Asset } from '@lifi/perps-types'
1
+ import type { ActionType, Asset } from '@lifi/perps-types'
2
+ import type { Address } from 'viem'
2
3
 
3
4
  /**
4
5
  * Which of a venue's two balance routes a withdrawal is drawn from. Lighter's
@@ -49,3 +50,34 @@ export interface WithdrawableBalance {
49
50
  */
50
51
  withdrawalFee?: string
51
52
  }
53
+
54
+ /**
55
+ * The venue accepts a withdrawal to `destination` now.
56
+ *
57
+ * @public
58
+ */
59
+ export interface WithdrawFlowReady {
60
+ kind: 'ready'
61
+ destination: Address
62
+ }
63
+
64
+ /**
65
+ * The venue cannot accept a withdrawal until the listed setup actions are
66
+ * satisfied — Ondo sends funds only to an address in its address book, behind
67
+ * a signed-in session.
68
+ *
69
+ * @public
70
+ */
71
+ export interface WithdrawFlowSetupRequired {
72
+ kind: 'setupRequired'
73
+ /** Setup action types that must be completed, in execution order. */
74
+ setup: ActionType[]
75
+ }
76
+
77
+ /**
78
+ * The single withdrawal flow a venue offers one address, resolved from the
79
+ * venue's account and setup state.
80
+ *
81
+ * @public
82
+ */
83
+ export type WithdrawFlow = WithdrawFlowReady | WithdrawFlowSetupRequired
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 = '18.0.0'
13
+ export const version = '18.1.0'