@lifi/perps-sdk 28.1.0 → 29.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 (52) hide show
  1. package/README.md +13 -0
  2. package/dist/cjs/index.d.ts +2 -2
  3. package/dist/cjs/index.d.ts.map +1 -1
  4. package/dist/cjs/index.js +5 -3
  5. package/dist/cjs/index.js.map +1 -1
  6. package/dist/cjs/math/position.d.ts +20 -0
  7. package/dist/cjs/math/position.d.ts.map +1 -1
  8. package/dist/cjs/math/position.js +63 -8
  9. package/dist/cjs/math/position.js.map +1 -1
  10. package/dist/cjs/types/deposit.d.ts +3 -3
  11. package/dist/cjs/types/deposit.d.ts.map +1 -1
  12. package/dist/cjs/types/provider.d.ts +4 -1
  13. package/dist/cjs/types/provider.d.ts.map +1 -1
  14. package/dist/cjs/version.d.ts +1 -1
  15. package/dist/cjs/version.js +1 -1
  16. package/dist/esm/index.d.ts +2 -2
  17. package/dist/esm/index.d.ts.map +1 -1
  18. package/dist/esm/index.js +1 -1
  19. package/dist/esm/index.js.map +1 -1
  20. package/dist/esm/math/position.d.ts +62 -10
  21. package/dist/esm/math/position.d.ts.map +1 -1
  22. package/dist/esm/math/position.js +104 -18
  23. package/dist/esm/math/position.js.map +1 -1
  24. package/dist/esm/services/getGasRecommendation.d.ts +2 -2
  25. package/dist/esm/services/getGasRecommendation.js +1 -1
  26. package/dist/esm/types/deposit.d.ts +9 -8
  27. package/dist/esm/types/deposit.d.ts.map +1 -1
  28. package/dist/esm/types/provider.d.ts +20 -7
  29. package/dist/esm/types/provider.d.ts.map +1 -1
  30. package/dist/esm/utils/depositAssets.d.ts +3 -3
  31. package/dist/esm/utils/depositAssets.js +3 -3
  32. package/dist/esm/version.d.ts +1 -1
  33. package/dist/esm/version.js +1 -1
  34. package/dist/types/index.d.ts +2 -2
  35. package/dist/types/index.d.ts.map +1 -1
  36. package/dist/types/math/position.d.ts +62 -10
  37. package/dist/types/math/position.d.ts.map +1 -1
  38. package/dist/types/services/getGasRecommendation.d.ts +2 -2
  39. package/dist/types/types/deposit.d.ts +9 -8
  40. package/dist/types/types/deposit.d.ts.map +1 -1
  41. package/dist/types/types/provider.d.ts +20 -7
  42. package/dist/types/types/provider.d.ts.map +1 -1
  43. package/dist/types/utils/depositAssets.d.ts +3 -3
  44. package/dist/types/version.d.ts +1 -1
  45. package/package.json +2 -2
  46. package/src/index.ts +3 -1
  47. package/src/math/position.ts +123 -19
  48. package/src/services/getGasRecommendation.ts +2 -2
  49. package/src/types/deposit.ts +9 -8
  50. package/src/types/provider.ts +20 -6
  51. package/src/utils/depositAssets.ts +3 -3
  52. package/src/version.ts +1 -1
@@ -37,20 +37,21 @@ export interface DepositFlowLifiSwap {
37
37
  }
38
38
 
39
39
  /**
40
- * Fund an address that has no venue account yet. Collateral and the native gas
41
- * to broadcast with are both needed on `chainId`, where the venue's
42
- * {@link ActionType.DEPOSIT} action stages the on-chain legs that open the
43
- * account.
40
+ * Fund an address that has no venue account yet, or an existing account on a
41
+ * venue whose collateral no LI.FI route credits directly. Collateral and the
42
+ * native gas to broadcast with are both needed on `chainId`, where the venue's
43
+ * {@link ActionType.DEPOSIT} action stages the on-chain legs that credit the
44
+ * account and open it when none exists.
44
45
  *
45
46
  * @public
46
47
  */
47
- export interface DepositFlowFirstDepositPipeline {
48
- kind: 'firstDepositPipeline'
48
+ export interface DepositFlowVenueDepositPipeline {
49
+ kind: 'venueDepositPipeline'
49
50
  /** Chain on which the deposit legs broadcast; the wallet must be switched here. */
50
51
  chainId: number
51
52
  /** Native gas asset needed to broadcast the deposit legs. */
52
53
  gasAsset: DeclaredDepositAsset
53
- /** Collateral asset credited by the first deposit. */
54
+ /** Collateral asset the venue deposit credits. */
54
55
  collateral: DeclaredDepositAsset
55
56
  /** Action type used to stage the deposit pipeline. */
56
57
  bridgeAction: ActionType.DEPOSIT
@@ -77,5 +78,5 @@ export interface DepositFlowSetupRequired {
77
78
  */
78
79
  export type DepositFlow =
79
80
  | DepositFlowLifiSwap
80
- | DepositFlowFirstDepositPipeline
81
+ | DepositFlowVenueDepositPipeline
81
82
  | DepositFlowSetupRequired
@@ -11,6 +11,7 @@ import type {
11
11
  AvailableToTrade,
12
12
  DecimalString,
13
13
  FillsResponse,
14
+ MarginMode,
14
15
  Market,
15
16
  MarketRef,
16
17
  MarketSettings,
@@ -160,7 +161,8 @@ export interface ActionSignerContribution {
160
161
  }
161
162
 
162
163
  /**
163
- * Inputs for {@link PerpsProviderPlugin.estimateLiquidationPrice}:
164
+ * Inputs for {@link PerpsProviderPlugin.estimateLiquidationPrice}: the order
165
+ * and, when the order adds to one, the open position on the market.
164
166
  * `leverage` is the user-selected leverage for the new position, `isLong`
165
167
  * carries direction.
166
168
  *
@@ -172,6 +174,14 @@ export interface LiquidationEstimateParams {
172
174
  leverage: string
173
175
  /** `true` for long, `false` for short. */
174
176
  isLong: boolean
177
+ marginMode: MarginMode
178
+ /**
179
+ * Order size in base-asset units. The estimate reads it only with
180
+ * `position`, to blend the order into that position.
181
+ */
182
+ size?: DecimalString
183
+ /** Open position on the market that the order joins. */
184
+ position?: Position
175
185
  }
176
186
 
177
187
  /**
@@ -633,16 +643,20 @@ export interface PerpsProviderPlugin {
633
643
  }
634
644
 
635
645
  /**
636
- * Estimate the liquidation price of a new isolated position on `market`
637
- * using the venue's margin model. A preview helper — for existing
646
+ * Estimate the liquidation price of the position that the order leaves on
647
+ * `market` using the venue's margin model: a new position, or the blend of
648
+ * the order into `params.position`. A preview helper — for existing
638
649
  * positions, prefer `Position.liquidationPrice` from the venue. Pure —
639
650
  * does no I/O.
640
651
  *
641
652
  * @returns The estimated liquidation price, or `undefined` when `market`
642
- * lacks the margin metadata the model needs or `leverage` leaves no
643
- * margin above the maintenance requirement.
653
+ * lacks the margin metadata the model needs, `leverage` leaves no
654
+ * margin above the maintenance requirement, or the venue model cannot
655
+ * give a correct price for the margin mode and position, such as a cross
656
+ * position whose liquidation depends on the whole account.
644
657
  * @throws {PerpsError} `ValidationError` when an input does not match the
645
- * decimal pattern or is degenerate, such as a zero leverage.
658
+ * decimal pattern or is degenerate, such as a zero leverage or a
659
+ * `position` without a `size`.
646
660
  */
647
661
  estimateLiquidationPrice(
648
662
  market: PerpsMarket,
@@ -3,7 +3,7 @@ import { zeroAddress } from 'viem'
3
3
  import type { DeclaredDepositAsset } from '../types/deposit.js'
4
4
 
5
5
  /**
6
- * USDC on Ethereum mainnet — the collateral leg of Lighter's first-deposit
6
+ * USDC on Ethereum mainnet — the collateral leg of Lighter's venue-deposit
7
7
  * pipeline, and the token Ondo's provisioned deposit address is funded in.
8
8
  *
9
9
  * @public
@@ -15,7 +15,7 @@ export const ETHEREUM_USDC: DeclaredDepositAsset = {
15
15
  }
16
16
 
17
17
  /**
18
- * Ether on Ethereum mainnet, to broadcast the first-deposit pipeline's legs
18
+ * Ether on Ethereum mainnet, to broadcast the venue-deposit pipeline's legs
19
19
  * with.
20
20
  *
21
21
  * @public
@@ -65,7 +65,7 @@ export const ROBINHOOD_USDG: DeclaredDepositAsset = {
65
65
  }
66
66
 
67
67
  /**
68
- * Ether on Robinhood Chain, to broadcast the Robinhood first-deposit pipeline's
68
+ * Ether on Robinhood Chain, to broadcast the Robinhood venue-deposit pipeline's
69
69
  * legs with.
70
70
  *
71
71
  * @public
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 = '28.1.0'
13
+ export const version = '29.1.0'