@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.
- package/README.md +13 -0
- package/dist/cjs/index.d.ts +2 -2
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +5 -3
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/math/position.d.ts +20 -0
- package/dist/cjs/math/position.d.ts.map +1 -1
- package/dist/cjs/math/position.js +63 -8
- package/dist/cjs/math/position.js.map +1 -1
- package/dist/cjs/types/deposit.d.ts +3 -3
- package/dist/cjs/types/deposit.d.ts.map +1 -1
- package/dist/cjs/types/provider.d.ts +4 -1
- package/dist/cjs/types/provider.d.ts.map +1 -1
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/math/position.d.ts +62 -10
- package/dist/esm/math/position.d.ts.map +1 -1
- package/dist/esm/math/position.js +104 -18
- package/dist/esm/math/position.js.map +1 -1
- package/dist/esm/services/getGasRecommendation.d.ts +2 -2
- package/dist/esm/services/getGasRecommendation.js +1 -1
- package/dist/esm/types/deposit.d.ts +9 -8
- package/dist/esm/types/deposit.d.ts.map +1 -1
- package/dist/esm/types/provider.d.ts +20 -7
- package/dist/esm/types/provider.d.ts.map +1 -1
- package/dist/esm/utils/depositAssets.d.ts +3 -3
- package/dist/esm/utils/depositAssets.js +3 -3
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/math/position.d.ts +62 -10
- package/dist/types/math/position.d.ts.map +1 -1
- package/dist/types/services/getGasRecommendation.d.ts +2 -2
- package/dist/types/types/deposit.d.ts +9 -8
- package/dist/types/types/deposit.d.ts.map +1 -1
- package/dist/types/types/provider.d.ts +20 -7
- package/dist/types/types/provider.d.ts.map +1 -1
- package/dist/types/utils/depositAssets.d.ts +3 -3
- package/dist/types/version.d.ts +1 -1
- package/package.json +2 -2
- package/src/index.ts +3 -1
- package/src/math/position.ts +123 -19
- package/src/services/getGasRecommendation.ts +2 -2
- package/src/types/deposit.ts +9 -8
- package/src/types/provider.ts +20 -6
- package/src/utils/depositAssets.ts +3 -3
- package/src/version.ts +1 -1
package/src/types/deposit.ts
CHANGED
|
@@ -37,20 +37,21 @@ export interface DepositFlowLifiSwap {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
/**
|
|
40
|
-
* Fund an address that has no venue account yet
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
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
|
|
48
|
-
kind: '
|
|
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
|
|
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
|
-
|
|
|
81
|
+
| DepositFlowVenueDepositPipeline
|
|
81
82
|
| DepositFlowSetupRequired
|
package/src/types/provider.ts
CHANGED
|
@@ -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
|
|
637
|
-
* using the venue's margin model
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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