@lifi/perps-types 0.2.0-alpha.0 → 1.0.1
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 +4 -30
- package/dist/cjs/acceptTerms.d.ts +20 -0
- package/dist/cjs/acceptTerms.d.ts.map +1 -0
- package/dist/cjs/acceptTerms.js +10 -0
- package/dist/cjs/acceptTerms.js.map +1 -0
- package/dist/cjs/account.d.ts +191 -0
- package/dist/cjs/account.d.ts.map +1 -0
- package/{src/_esm → dist/cjs}/account.js.map +1 -1
- package/dist/cjs/action.d.ts +200 -0
- package/dist/cjs/action.d.ts.map +1 -0
- package/dist/cjs/action.js.map +1 -0
- package/dist/cjs/asset.d.ts +11 -0
- package/dist/cjs/asset.d.ts.map +1 -0
- package/dist/cjs/asset.js.map +1 -0
- package/{src/_types → dist/cjs}/enums.d.ts +6 -12
- package/dist/cjs/enums.d.ts.map +1 -0
- package/{src/_cjs → dist/cjs}/enums.js +4 -0
- package/dist/cjs/enums.js.map +1 -0
- package/dist/cjs/errors.d.ts.map +1 -0
- package/dist/cjs/errors.js.map +1 -0
- package/{src/_types → dist/cjs}/index.d.ts +11 -5
- package/dist/cjs/index.d.ts.map +1 -0
- package/{src/_cjs → dist/cjs}/index.js +11 -5
- package/dist/cjs/index.js.map +1 -0
- package/{src/_types/asset.d.ts → dist/cjs/market.d.ts} +33 -25
- package/dist/cjs/market.d.ts.map +1 -0
- package/dist/cjs/market.js +3 -0
- package/dist/cjs/market.js.map +1 -0
- package/dist/cjs/meta.d.ts +17 -0
- package/dist/cjs/meta.d.ts.map +1 -0
- package/dist/cjs/meta.js +3 -0
- package/dist/cjs/meta.js.map +1 -0
- package/dist/cjs/primitives.d.ts +3 -0
- package/dist/cjs/primitives.d.ts.map +1 -0
- package/dist/cjs/primitives.js +3 -0
- package/dist/cjs/primitives.js.map +1 -0
- package/dist/cjs/providers.d.ts +58 -0
- package/dist/cjs/providers.d.ts.map +1 -0
- package/{src/_cjs → dist/cjs}/providers.js.map +1 -1
- package/dist/cjs/quote.d.ts +23 -0
- package/dist/cjs/quote.d.ts.map +1 -0
- package/dist/cjs/quote.js +3 -0
- package/dist/cjs/quote.js.map +1 -0
- package/{src/_types → dist/cjs}/subscriptions.d.ts +14 -13
- package/dist/cjs/subscriptions.d.ts.map +1 -0
- package/{src/_cjs → dist/cjs}/subscriptions.js.map +1 -1
- package/dist/cjs/typedData.d.ts +23 -0
- package/dist/cjs/typedData.d.ts.map +1 -0
- package/{src/_cjs → dist/cjs}/typedData.js.map +1 -1
- package/dist/cjs/vote.d.ts +27 -0
- package/dist/cjs/vote.d.ts.map +1 -0
- package/dist/cjs/vote.js +12 -0
- package/dist/cjs/vote.js.map +1 -0
- package/dist/esm/acceptTerms.d.ts +45 -0
- package/dist/esm/acceptTerms.d.ts.map +1 -0
- package/dist/esm/acceptTerms.js +12 -0
- package/dist/esm/acceptTerms.js.map +1 -0
- package/dist/esm/account.d.ts +229 -0
- package/dist/esm/account.d.ts.map +1 -0
- package/{src/_cjs → dist/esm}/account.js.map +1 -1
- package/{src/_types → dist/esm}/action.d.ts +56 -69
- package/dist/esm/action.d.ts.map +1 -0
- package/dist/esm/action.js +2 -0
- package/dist/esm/action.js.map +1 -0
- package/dist/esm/asset.d.ts +25 -0
- package/dist/esm/asset.d.ts.map +1 -0
- package/dist/esm/asset.js.map +1 -0
- package/dist/esm/enums.d.ts +171 -0
- package/dist/esm/enums.d.ts.map +1 -0
- package/{src/_esm → dist/esm}/enums.js +26 -10
- package/dist/esm/enums.js.map +1 -0
- package/dist/esm/errors.d.ts +8 -0
- package/dist/esm/errors.d.ts.map +1 -0
- package/dist/esm/errors.js.map +1 -0
- package/dist/esm/index.d.ts +23 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +23 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/market.d.ts +107 -0
- package/dist/esm/market.d.ts.map +1 -0
- package/dist/esm/market.js +2 -0
- package/dist/esm/market.js.map +1 -0
- package/dist/esm/meta.d.ts +37 -0
- package/dist/esm/meta.d.ts.map +1 -0
- package/dist/esm/meta.js +2 -0
- package/dist/esm/meta.js.map +1 -0
- package/dist/esm/primitives.d.ts +5 -0
- package/dist/esm/primitives.d.ts.map +1 -0
- package/dist/esm/primitives.js +2 -0
- package/dist/esm/primitives.js.map +1 -0
- package/dist/esm/providers.d.ts +116 -0
- package/dist/esm/providers.d.ts.map +1 -0
- package/{src/_esm → dist/esm}/providers.js.map +1 -1
- package/dist/esm/quote.d.ts +47 -0
- package/dist/esm/quote.d.ts.map +1 -0
- package/dist/esm/quote.js +2 -0
- package/dist/esm/quote.js.map +1 -0
- package/dist/esm/subscriptions.d.ts +115 -0
- package/dist/esm/subscriptions.d.ts.map +1 -0
- package/{src/_esm → dist/esm}/subscriptions.js.map +1 -1
- package/dist/esm/typedData.d.ts +28 -0
- package/dist/esm/typedData.d.ts.map +1 -0
- package/{src/_esm → dist/esm}/typedData.js.map +1 -1
- package/dist/esm/vote.d.ts +68 -0
- package/dist/esm/vote.d.ts.map +1 -0
- package/dist/esm/vote.js +20 -0
- package/dist/esm/vote.js.map +1 -0
- package/dist/types/acceptTerms.d.ts +45 -0
- package/dist/types/acceptTerms.d.ts.map +1 -0
- package/dist/types/account.d.ts +229 -0
- package/dist/types/account.d.ts.map +1 -0
- package/dist/types/action.d.ts +248 -0
- package/dist/types/action.d.ts.map +1 -0
- package/dist/types/asset.d.ts +25 -0
- package/dist/types/asset.d.ts.map +1 -0
- package/dist/types/enums.d.ts +171 -0
- package/dist/types/enums.d.ts.map +1 -0
- package/dist/types/errors.d.ts +8 -0
- package/dist/types/errors.d.ts.map +1 -0
- package/dist/types/index.d.ts +23 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/market.d.ts +107 -0
- package/dist/types/market.d.ts.map +1 -0
- package/dist/types/meta.d.ts +37 -0
- package/dist/types/meta.d.ts.map +1 -0
- package/dist/types/primitives.d.ts +5 -0
- package/dist/types/primitives.d.ts.map +1 -0
- package/dist/types/providers.d.ts +116 -0
- package/dist/types/providers.d.ts.map +1 -0
- package/dist/types/quote.d.ts +47 -0
- package/dist/types/quote.d.ts.map +1 -0
- package/dist/types/subscriptions.d.ts +115 -0
- package/dist/types/subscriptions.d.ts.map +1 -0
- package/dist/types/typedData.d.ts +28 -0
- package/dist/types/typedData.d.ts.map +1 -0
- package/dist/types/vote.d.ts +68 -0
- package/dist/types/vote.d.ts.map +1 -0
- package/package.json +37 -65
- package/src/acceptTerms.ts +53 -0
- package/src/account.ts +74 -111
- package/src/action.ts +64 -96
- package/src/asset.ts +19 -82
- package/src/enums.ts +27 -10
- package/src/errors.ts +1 -0
- package/src/index.ts +20 -5
- package/src/market.ts +137 -0
- package/src/meta.ts +38 -0
- package/src/primitives.ts +5 -0
- package/src/providers.ts +79 -110
- package/src/quote.ts +49 -0
- package/src/subscriptions.ts +62 -18
- package/src/typedData.ts +20 -11
- package/src/vote.ts +79 -0
- package/providers/hyperliquid/package.json +0 -5
- package/providers/lighter/package.json +0 -5
- package/src/_cjs/action.js.map +0 -1
- package/src/_cjs/asset.js.map +0 -1
- package/src/_cjs/enums.js.map +0 -1
- package/src/_cjs/errors.js.map +0 -1
- package/src/_cjs/index.js.map +0 -1
- package/src/_cjs/providers/_shared/fillClassification.js +0 -37
- package/src/_cjs/providers/_shared/fillClassification.js.map +0 -1
- package/src/_cjs/providers/hyperliquid/assetId.js +0 -21
- package/src/_cjs/providers/hyperliquid/assetId.js.map +0 -1
- package/src/_cjs/providers/hyperliquid/index.js +0 -20
- package/src/_cjs/providers/hyperliquid/index.js.map +0 -1
- package/src/_cjs/providers/hyperliquid/mappers/_market.js +0 -15
- package/src/_cjs/providers/hyperliquid/mappers/_market.js.map +0 -1
- package/src/_cjs/providers/hyperliquid/mappers/activity.js +0 -128
- package/src/_cjs/providers/hyperliquid/mappers/activity.js.map +0 -1
- package/src/_cjs/providers/hyperliquid/mappers/asset.js +0 -29
- package/src/_cjs/providers/hyperliquid/mappers/asset.js.map +0 -1
- package/src/_cjs/providers/hyperliquid/mappers/fill.js +0 -36
- package/src/_cjs/providers/hyperliquid/mappers/fill.js.map +0 -1
- package/src/_cjs/providers/hyperliquid/mappers/index.js +0 -20
- package/src/_cjs/providers/hyperliquid/mappers/index.js.map +0 -1
- package/src/_cjs/providers/hyperliquid/mappers/order.js +0 -153
- package/src/_cjs/providers/hyperliquid/mappers/order.js.map +0 -1
- package/src/_cjs/providers/hyperliquid/mappers/position.js +0 -32
- package/src/_cjs/providers/hyperliquid/mappers/position.js.map +0 -1
- package/src/_cjs/providers/hyperliquid/mappers/shared.js +0 -2
- package/src/_cjs/providers/hyperliquid/mappers/shared.js.map +0 -1
- package/src/_cjs/providers/hyperliquid/types.js +0 -21
- package/src/_cjs/providers/hyperliquid/types.js.map +0 -1
- package/src/_cjs/providers/lighter/apiTypes.js +0 -3
- package/src/_cjs/providers/lighter/apiTypes.js.map +0 -1
- package/src/_cjs/providers/lighter/index.js +0 -20
- package/src/_cjs/providers/lighter/index.js.map +0 -1
- package/src/_cjs/providers/lighter/mappers/fill.js +0 -34
- package/src/_cjs/providers/lighter/mappers/fill.js.map +0 -1
- package/src/_cjs/providers/lighter/mappers/index.js +0 -13
- package/src/_cjs/providers/lighter/mappers/index.js.map +0 -1
- package/src/_cjs/providers/lighter/mappers/order.js +0 -142
- package/src/_cjs/providers/lighter/mappers/order.js.map +0 -1
- package/src/_cjs/providers/lighter/mappers/position.js +0 -35
- package/src/_cjs/providers/lighter/mappers/position.js.map +0 -1
- package/src/_cjs/providers/lighter/types.js +0 -23
- package/src/_cjs/providers/lighter/types.js.map +0 -1
- package/src/_esm/action.js +0 -2
- package/src/_esm/action.js.map +0 -1
- package/src/_esm/asset.js.map +0 -1
- package/src/_esm/enums.js.map +0 -1
- package/src/_esm/errors.js.map +0 -1
- package/src/_esm/index.js +0 -9
- package/src/_esm/index.js.map +0 -1
- package/src/_esm/providers/_shared/fillClassification.js +0 -43
- package/src/_esm/providers/_shared/fillClassification.js.map +0 -1
- package/src/_esm/providers/hyperliquid/assetId.js +0 -25
- package/src/_esm/providers/hyperliquid/assetId.js.map +0 -1
- package/src/_esm/providers/hyperliquid/index.js +0 -4
- package/src/_esm/providers/hyperliquid/index.js.map +0 -1
- package/src/_esm/providers/hyperliquid/mappers/_market.js +0 -22
- package/src/_esm/providers/hyperliquid/mappers/_market.js.map +0 -1
- package/src/_esm/providers/hyperliquid/mappers/activity.js +0 -138
- package/src/_esm/providers/hyperliquid/mappers/activity.js.map +0 -1
- package/src/_esm/providers/hyperliquid/mappers/asset.js +0 -25
- package/src/_esm/providers/hyperliquid/mappers/asset.js.map +0 -1
- package/src/_esm/providers/hyperliquid/mappers/fill.js +0 -32
- package/src/_esm/providers/hyperliquid/mappers/fill.js.map +0 -1
- package/src/_esm/providers/hyperliquid/mappers/index.js +0 -6
- package/src/_esm/providers/hyperliquid/mappers/index.js.map +0 -1
- package/src/_esm/providers/hyperliquid/mappers/order.js +0 -151
- package/src/_esm/providers/hyperliquid/mappers/order.js.map +0 -1
- package/src/_esm/providers/hyperliquid/mappers/position.js +0 -28
- package/src/_esm/providers/hyperliquid/mappers/position.js.map +0 -1
- package/src/_esm/providers/hyperliquid/mappers/shared.js +0 -2
- package/src/_esm/providers/hyperliquid/mappers/shared.js.map +0 -1
- package/src/_esm/providers/hyperliquid/types.js +0 -35
- package/src/_esm/providers/hyperliquid/types.js.map +0 -1
- package/src/_esm/providers/lighter/apiTypes.js +0 -5
- package/src/_esm/providers/lighter/apiTypes.js.map +0 -1
- package/src/_esm/providers/lighter/index.js +0 -4
- package/src/_esm/providers/lighter/index.js.map +0 -1
- package/src/_esm/providers/lighter/mappers/fill.js +0 -39
- package/src/_esm/providers/lighter/mappers/fill.js.map +0 -1
- package/src/_esm/providers/lighter/mappers/index.js +0 -4
- package/src/_esm/providers/lighter/mappers/index.js.map +0 -1
- package/src/_esm/providers/lighter/mappers/order.js +0 -162
- package/src/_esm/providers/lighter/mappers/order.js.map +0 -1
- package/src/_esm/providers/lighter/mappers/position.js +0 -38
- package/src/_esm/providers/lighter/mappers/position.js.map +0 -1
- package/src/_esm/providers/lighter/types.js +0 -26
- package/src/_esm/providers/lighter/types.js.map +0 -1
- package/src/_types/account.d.ts +0 -268
- package/src/_types/account.d.ts.map +0 -1
- package/src/_types/action.d.ts.map +0 -1
- package/src/_types/asset.d.ts.map +0 -1
- package/src/_types/enums.d.ts.map +0 -1
- package/src/_types/errors.d.ts.map +0 -1
- package/src/_types/index.d.ts.map +0 -1
- package/src/_types/providers/_shared/fillClassification.d.ts +0 -12
- package/src/_types/providers/_shared/fillClassification.d.ts.map +0 -1
- package/src/_types/providers/hyperliquid/assetId.d.ts +0 -14
- package/src/_types/providers/hyperliquid/assetId.d.ts.map +0 -1
- package/src/_types/providers/hyperliquid/index.d.ts +0 -4
- package/src/_types/providers/hyperliquid/index.d.ts.map +0 -1
- package/src/_types/providers/hyperliquid/mappers/_market.d.ts +0 -13
- package/src/_types/providers/hyperliquid/mappers/_market.d.ts.map +0 -1
- package/src/_types/providers/hyperliquid/mappers/activity.d.ts +0 -13
- package/src/_types/providers/hyperliquid/mappers/activity.d.ts.map +0 -1
- package/src/_types/providers/hyperliquid/mappers/asset.d.ts +0 -4
- package/src/_types/providers/hyperliquid/mappers/asset.d.ts.map +0 -1
- package/src/_types/providers/hyperliquid/mappers/fill.d.ts +0 -6
- package/src/_types/providers/hyperliquid/mappers/fill.d.ts.map +0 -1
- package/src/_types/providers/hyperliquid/mappers/index.d.ts +0 -6
- package/src/_types/providers/hyperliquid/mappers/index.d.ts.map +0 -1
- package/src/_types/providers/hyperliquid/mappers/order.d.ts +0 -18
- package/src/_types/providers/hyperliquid/mappers/order.d.ts.map +0 -1
- package/src/_types/providers/hyperliquid/mappers/position.d.ts +0 -4
- package/src/_types/providers/hyperliquid/mappers/position.d.ts.map +0 -1
- package/src/_types/providers/hyperliquid/mappers/shared.d.ts +0 -1
- package/src/_types/providers/hyperliquid/mappers/shared.d.ts.map +0 -1
- package/src/_types/providers/hyperliquid/types.d.ts +0 -289
- package/src/_types/providers/hyperliquid/types.d.ts.map +0 -1
- package/src/_types/providers/lighter/apiTypes.d.ts +0 -76
- package/src/_types/providers/lighter/apiTypes.d.ts.map +0 -1
- package/src/_types/providers/lighter/index.d.ts +0 -4
- package/src/_types/providers/lighter/index.d.ts.map +0 -1
- package/src/_types/providers/lighter/mappers/fill.d.ts +0 -9
- package/src/_types/providers/lighter/mappers/fill.d.ts.map +0 -1
- package/src/_types/providers/lighter/mappers/index.d.ts +0 -4
- package/src/_types/providers/lighter/mappers/index.d.ts.map +0 -1
- package/src/_types/providers/lighter/mappers/order.d.ts +0 -35
- package/src/_types/providers/lighter/mappers/order.d.ts.map +0 -1
- package/src/_types/providers/lighter/mappers/position.d.ts +0 -8
- package/src/_types/providers/lighter/mappers/position.d.ts.map +0 -1
- package/src/_types/providers/lighter/types.d.ts +0 -90
- package/src/_types/providers/lighter/types.d.ts.map +0 -1
- package/src/_types/providers.d.ts +0 -145
- package/src/_types/providers.d.ts.map +0 -1
- package/src/_types/subscriptions.d.ts.map +0 -1
- package/src/_types/typedData.d.ts +0 -18
- package/src/_types/typedData.d.ts.map +0 -1
- package/src/providers/_shared/fillClassification.ts +0 -50
- package/src/providers/hyperliquid/assetId.ts +0 -32
- package/src/providers/hyperliquid/index.ts +0 -3
- package/src/providers/hyperliquid/mappers/_market.ts +0 -21
- package/src/providers/hyperliquid/mappers/activity.ts +0 -169
- package/src/providers/hyperliquid/mappers/asset.ts +0 -33
- package/src/providers/hyperliquid/mappers/fill.ts +0 -41
- package/src/providers/hyperliquid/mappers/index.ts +0 -11
- package/src/providers/hyperliquid/mappers/order.ts +0 -169
- package/src/providers/hyperliquid/mappers/position.ts +0 -33
- package/src/providers/hyperliquid/mappers/shared.ts +0 -0
- package/src/providers/hyperliquid/types.ts +0 -379
- package/src/providers/lighter/apiTypes.ts +0 -87
- package/src/providers/lighter/index.ts +0 -3
- package/src/providers/lighter/mappers/fill.ts +0 -57
- package/src/providers/lighter/mappers/index.ts +0 -8
- package/src/providers/lighter/mappers/order.ts +0 -184
- package/src/providers/lighter/mappers/position.ts +0 -46
- package/src/providers/lighter/types.ts +0 -111
- /package/{src/_cjs → dist/cjs}/account.js +0 -0
- /package/{src/_cjs → dist/cjs}/action.js +0 -0
- /package/{src/_cjs → dist/cjs}/asset.js +0 -0
- /package/{src/_types → dist/cjs}/errors.d.ts +0 -0
- /package/{src/_cjs → dist/cjs}/errors.js +0 -0
- /package/{src/_cjs → dist/cjs}/package.json +0 -0
- /package/{src/_cjs → dist/cjs}/providers.js +0 -0
- /package/{src/_cjs → dist/cjs}/subscriptions.js +0 -0
- /package/{src/_cjs → dist/cjs}/typedData.js +0 -0
- /package/{src/_esm → dist/esm}/account.js +0 -0
- /package/{src/_esm → dist/esm}/asset.js +0 -0
- /package/{src/_esm → dist/esm}/errors.js +0 -0
- /package/{src/_esm → dist/esm}/package.json +0 -0
- /package/{src/_esm → dist/esm}/providers.js +0 -0
- /package/{src/_esm → dist/esm}/subscriptions.js +0 -0
- /package/{src/_esm → dist/esm}/typedData.js +0 -0
package/src/market.ts
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import type { Asset } from './asset.js'
|
|
2
|
+
|
|
3
|
+
/** @public */
|
|
4
|
+
export interface FundingInfo {
|
|
5
|
+
rate: string
|
|
6
|
+
nextFundingTime: number
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/** @public */
|
|
10
|
+
export interface BaseMarket {
|
|
11
|
+
providerId: string
|
|
12
|
+
/** Opaque provider market id; referenced elsewhere as `marketId`. */
|
|
13
|
+
id: string
|
|
14
|
+
/** References a {@link ProviderCategory} by id. */
|
|
15
|
+
categoryId: string
|
|
16
|
+
baseAsset: Asset
|
|
17
|
+
quoteAsset: Asset
|
|
18
|
+
szDecimals: number
|
|
19
|
+
/**
|
|
20
|
+
* Maximum decimal places the venue accepts for order prices on this market.
|
|
21
|
+
* Some venues impose further constraints on top of this budget (e.g. a
|
|
22
|
+
* significant-figure cap), so always format prices through the provider's
|
|
23
|
+
* `formatOrderPrice` rather than applying this field directly.
|
|
24
|
+
*/
|
|
25
|
+
priceDecimals?: number
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** @public */
|
|
29
|
+
export interface PerpsMarket extends BaseMarket {
|
|
30
|
+
maxLeverage: number
|
|
31
|
+
onlyIsolated: boolean
|
|
32
|
+
/**
|
|
33
|
+
* Venue maintenance margin rate for this market as a fraction (e.g. `0.012`
|
|
34
|
+
* = 1.2%). Feeds client-side liquidation-price estimates via the provider's
|
|
35
|
+
* `estimateLiquidationPrice`.
|
|
36
|
+
*/
|
|
37
|
+
maintenanceMarginRate?: number
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** @public */
|
|
41
|
+
export interface SpotMarket extends BaseMarket {}
|
|
42
|
+
|
|
43
|
+
/** @public */
|
|
44
|
+
export type Market = PerpsMarket | SpotMarket
|
|
45
|
+
|
|
46
|
+
/** @public */
|
|
47
|
+
export type MarketDisplay = Pick<
|
|
48
|
+
BaseMarket,
|
|
49
|
+
'providerId' | 'id' | 'categoryId' | 'baseAsset' | 'quoteAsset'
|
|
50
|
+
>
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Minimal market reference for write-action params: identifies a market by
|
|
54
|
+
* its opaque `marketId` within a `categoryId`. Embeds no Assets — write
|
|
55
|
+
* params reference by id, not value.
|
|
56
|
+
* @public
|
|
57
|
+
*/
|
|
58
|
+
export interface MarketRef {
|
|
59
|
+
marketId: string
|
|
60
|
+
categoryId: string
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** @public */
|
|
64
|
+
export interface MarketsResponse {
|
|
65
|
+
markets: Market[]
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Live per-market data for the `/prices` endpoint. `price` is the mid;
|
|
70
|
+
* `markPrice`, `prevDayPrice` and `volume24h` apply to every market type,
|
|
71
|
+
* while `openInterest` and `funding` are perp-only and absent for spot.
|
|
72
|
+
* @public
|
|
73
|
+
*/
|
|
74
|
+
export interface MarketPrice {
|
|
75
|
+
marketId: string
|
|
76
|
+
price: string
|
|
77
|
+
markPrice: string
|
|
78
|
+
prevDayPrice?: string
|
|
79
|
+
volume24h?: string
|
|
80
|
+
openInterest?: string
|
|
81
|
+
funding?: FundingInfo
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** @public */
|
|
85
|
+
export interface PricesResponse {
|
|
86
|
+
prices: MarketPrice[]
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** @public */
|
|
90
|
+
export interface Candle {
|
|
91
|
+
t: number
|
|
92
|
+
o: string
|
|
93
|
+
h: string
|
|
94
|
+
l: string
|
|
95
|
+
c: string
|
|
96
|
+
v: string
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** @public */
|
|
100
|
+
export interface OhlcvResponse {
|
|
101
|
+
provider: string
|
|
102
|
+
marketId: string
|
|
103
|
+
interval: string
|
|
104
|
+
candles: Candle[]
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** @public */
|
|
108
|
+
export type OhlcvInterval =
|
|
109
|
+
| '1m'
|
|
110
|
+
| '3m'
|
|
111
|
+
| '5m'
|
|
112
|
+
| '15m'
|
|
113
|
+
| '30m'
|
|
114
|
+
| '1h'
|
|
115
|
+
| '2h'
|
|
116
|
+
| '4h'
|
|
117
|
+
| '8h'
|
|
118
|
+
| '12h'
|
|
119
|
+
| '1d'
|
|
120
|
+
| '3d'
|
|
121
|
+
| '1w'
|
|
122
|
+
| '1M'
|
|
123
|
+
|
|
124
|
+
/** @public */
|
|
125
|
+
export interface OrderbookLevel {
|
|
126
|
+
price: string
|
|
127
|
+
size: string
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/** @public */
|
|
131
|
+
export interface OrderbookResponse {
|
|
132
|
+
provider: string
|
|
133
|
+
marketId: string
|
|
134
|
+
bids: OrderbookLevel[]
|
|
135
|
+
asks: OrderbookLevel[]
|
|
136
|
+
timestamp: number
|
|
137
|
+
}
|
package/src/meta.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A single platform-level advisory shown to all users, independent of any
|
|
3
|
+
* provider or market.
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
export interface Notice {
|
|
7
|
+
/** Unix epoch milliseconds. */
|
|
8
|
+
timestamp: number
|
|
9
|
+
title: string
|
|
10
|
+
message: string
|
|
11
|
+
/** Optional URL the notice links to; rendered as a hyperlink when present. */
|
|
12
|
+
link?: string
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Read-only platform metadata served by `GET /v1/perps/meta`.
|
|
17
|
+
* @public
|
|
18
|
+
*/
|
|
19
|
+
export interface Meta {
|
|
20
|
+
version: string
|
|
21
|
+
notices: Notice[]
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Current Terms-of-Service and this address's acceptance, served by
|
|
26
|
+
* `GET /v1/perps/meta/terms?address=`.
|
|
27
|
+
* @public
|
|
28
|
+
*/
|
|
29
|
+
export interface TermsAcceptanceStatus {
|
|
30
|
+
/** Backend-owned version identifier for the current terms. */
|
|
31
|
+
termsVersion: string
|
|
32
|
+
/** Full current terms-of-service text. */
|
|
33
|
+
content: string
|
|
34
|
+
/** Whether the queried address has accepted {@link TermsAcceptanceStatus.termsVersion}. */
|
|
35
|
+
accepted: boolean
|
|
36
|
+
/** Unix epoch milliseconds the address accepted; absent when not accepted. */
|
|
37
|
+
acceptedAt?: number
|
|
38
|
+
}
|
package/src/providers.ts
CHANGED
|
@@ -1,122 +1,75 @@
|
|
|
1
|
+
import type { Asset } from './asset.js'
|
|
1
2
|
import type { ActionType, PerpsSigner, SigningMethod } from './enums.js'
|
|
3
|
+
import type { OhlcvInterval } from './market.js'
|
|
2
4
|
|
|
3
|
-
|
|
4
|
-
type: ActionType
|
|
5
|
-
signers: PerpsSigner[]
|
|
6
|
-
/**
|
|
7
|
-
* How the SDK must sign this specific action. Most actions match the
|
|
8
|
-
* provider's dominant pattern (Hyperliquid: EIP712, Lighter: WASM_BLOB),
|
|
9
|
-
* but on-chain bridge actions like DEPOSIT are EVM_TX regardless of
|
|
10
|
-
* provider — the SDK dispatches by this field rather than by
|
|
11
|
-
* `Provider.signingMethod`.
|
|
12
|
-
*/
|
|
13
|
-
signingMethod: SigningMethod
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* One selectable value on a `Param` whose `values` are enumerated.
|
|
18
|
-
*
|
|
19
|
-
* `value` is the opaque per-provider identifier the SDK passes back to the
|
|
20
|
-
* backend in the corresponding action params (e.g. the string assigned to
|
|
21
|
-
* `mode` for `ACCOUNT_MODE`, or `tier` for `ACCOUNT_TYPE`).
|
|
22
|
-
* `label` is the user-facing string the widget renders.
|
|
23
|
-
*/
|
|
5
|
+
/** @public */
|
|
24
6
|
export interface ParamOption {
|
|
25
7
|
value: string
|
|
26
8
|
label: string
|
|
27
9
|
}
|
|
28
10
|
|
|
29
|
-
/**
|
|
30
|
-
* A single parameter the widget must collect from the user before
|
|
31
|
-
* dispatching an action.
|
|
32
|
-
*
|
|
33
|
-
* `name` is the wire key the widget passes through to `execute()` — for the
|
|
34
|
-
* existing `ACCOUNT_MODE` action that's `'mode'`, for `ACCOUNT_TYPE` it's
|
|
35
|
-
* `'tier'`, etc. The widget builds the action's params object as
|
|
36
|
-
* `{ [param.name]: <selected value> }` straight from the descriptor at
|
|
37
|
-
* dispatch time; there is no per-ActionType translation layer.
|
|
38
|
-
*
|
|
39
|
-
* `type` describes the primitive shape of the value. Currently only
|
|
40
|
-
* `'string'` is admitted — numeric / boolean primitives are deferred until
|
|
41
|
-
* a real descriptor needs them.
|
|
42
|
-
*
|
|
43
|
-
* `values` is present iff the parameter has a fixed enumeration of
|
|
44
|
-
* admissible values (e.g. Hyperliquid abstraction modes, Lighter account
|
|
45
|
-
* tiers). When absent the widget renders a free-form input appropriate to
|
|
46
|
-
* the primitive `type`.
|
|
47
|
-
*
|
|
48
|
-
* `default` flags the suggested choice when `values` is provided. Must be
|
|
49
|
-
* one of the entries in `values` if specified; consumers should fall back
|
|
50
|
-
* to "no selection" when absent and let the user pick.
|
|
51
|
-
*
|
|
52
|
-
* `readOnly: true` means the widget must render the control disabled —
|
|
53
|
-
* typically used when the provider exposes the current value but does not
|
|
54
|
-
* allow the user to change it from this surface (e.g. Lighter account
|
|
55
|
-
* mode, which is set during onboarding and immutable thereafter).
|
|
56
|
-
*/
|
|
11
|
+
/** @public */
|
|
57
12
|
export interface Param {
|
|
13
|
+
/** Wire key for the action params object: `{ [param.name]: value }`. */
|
|
58
14
|
name: string
|
|
59
15
|
type: 'string'
|
|
16
|
+
/** Present iff the parameter has a fixed enumeration of admissible values. */
|
|
60
17
|
values?: ParamOption[]
|
|
61
18
|
default?: ParamOption
|
|
62
19
|
readOnly?: boolean
|
|
63
20
|
}
|
|
64
21
|
|
|
65
22
|
/**
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
* `params` is the list of parameters the widget must collect from the
|
|
74
|
-
* user (zero-or-more); each entry tells the widget the wire key, the
|
|
75
|
-
* primitive type, optional enumeration of admissible values, and
|
|
76
|
-
* optional default. See `Param` for the field-level semantics.
|
|
77
|
-
*
|
|
78
|
-
* Categorisation of a descriptor as "setup" vs "options" is carried by
|
|
79
|
-
* which array on `Provider` it appears in (`Provider.setup` vs
|
|
80
|
-
* `Provider.options`), NOT by a field on the descriptor — by design.
|
|
81
|
-
* `ProviderSetup` and `ProviderOption` are type aliases for this same
|
|
82
|
-
* shape with no additional fields.
|
|
23
|
+
* A single provider action. The same shape backs `Provider.setup`,
|
|
24
|
+
* `Provider.options`, and `Provider.actions` — categorisation lives in which
|
|
25
|
+
* array it sits in, not in the type. The core three fields are always present;
|
|
26
|
+
* the rest are presentation/ordering hints provided per-action in the
|
|
27
|
+
* provider's hardcoded metadata.
|
|
28
|
+
* @public
|
|
83
29
|
*/
|
|
84
|
-
export interface
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
30
|
+
export interface ProviderAction {
|
|
31
|
+
type: ActionType
|
|
32
|
+
signers: PerpsSigner[]
|
|
33
|
+
signingMethod: SigningMethod
|
|
34
|
+
/**
|
|
35
|
+
* Human label. Drives the card heading in the setup/options modals, and may
|
|
36
|
+
* also front an in-flight trading action ("{title} is working…").
|
|
37
|
+
*/
|
|
38
|
+
title?: string
|
|
39
|
+
description?: string
|
|
40
|
+
/** UI form fields the widget renders to collect input for this action. */
|
|
41
|
+
params?: Param[]
|
|
42
|
+
/**
|
|
43
|
+
* Ascending order in which the user satisfies setup steps. Cloud-init
|
|
44
|
+
* convention: 10, 20, 30, … with 99 reserved for "always last"; the gaps
|
|
45
|
+
* leave room to insert steps later without renumbering. Lower runs first;
|
|
46
|
+
* a step may depend on every lower-sequenced step already being satisfied.
|
|
47
|
+
*/
|
|
48
|
+
sequence?: number
|
|
91
49
|
}
|
|
92
50
|
|
|
93
51
|
/**
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
* whenever setup becomes unsatisfied (e.g. Hyperliquid agent expiry).
|
|
98
|
-
*
|
|
99
|
-
* Type alias for `ProviderActionDescriptor` — no additional fields. The
|
|
100
|
-
* setup-vs-options distinction is the array, not a flag on the item.
|
|
101
|
-
*/
|
|
102
|
-
export type ProviderSetup = ProviderActionDescriptor
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* A post-setup descriptor the user MAY interact with to tune provider
|
|
106
|
-
* behaviour (e.g. switching Hyperliquid abstraction modes, switching
|
|
107
|
-
* Lighter account tier). The widget renders these in `<OptionsModal />`
|
|
108
|
-
* behind a cog icon; they never gate trading.
|
|
109
|
-
*
|
|
110
|
-
* Type alias for `ProviderActionDescriptor` — no additional fields. The
|
|
111
|
-
* setup-vs-options distinction is the array, not a flag on the item.
|
|
52
|
+
* Provider-attached advisory shown against a market. Provider-agnostic: the
|
|
53
|
+
* producer decides when to emit one (e.g. an HL HIP-3 sub-dex risk warning).
|
|
54
|
+
* @public
|
|
112
55
|
*/
|
|
113
|
-
export
|
|
56
|
+
export interface TradeNotice {
|
|
57
|
+
/** Maps to the widget's panel styling: `warn` → warning, `info` → info. */
|
|
58
|
+
level: 'info' | 'warn'
|
|
59
|
+
/** Plaintext; any URL is rendered as text, not a hyperlink. */
|
|
60
|
+
message: string
|
|
61
|
+
}
|
|
114
62
|
|
|
115
|
-
|
|
63
|
+
/** @public */
|
|
64
|
+
export interface ProviderCategory {
|
|
116
65
|
id: string
|
|
117
|
-
|
|
66
|
+
logoURI?: string
|
|
67
|
+
/** `null` for the "spot" category — no single fixed quote. */
|
|
68
|
+
quoteAsset: Asset | null
|
|
69
|
+
tradeNotice?: TradeNotice
|
|
118
70
|
}
|
|
119
71
|
|
|
72
|
+
/** @public */
|
|
120
73
|
export interface Provider {
|
|
121
74
|
key: string
|
|
122
75
|
name: string
|
|
@@ -124,30 +77,46 @@ export interface Provider {
|
|
|
124
77
|
signingMethod: SigningMethod
|
|
125
78
|
/** When false, the provider is announced but not yet selectable in clients. */
|
|
126
79
|
active: boolean
|
|
80
|
+
setup: ProviderAction[]
|
|
81
|
+
options: ProviderAction[]
|
|
82
|
+
actions: ProviderAction[]
|
|
83
|
+
categories: ProviderCategory[]
|
|
84
|
+
wsUrl?: string
|
|
85
|
+
/** Absent means no minimum advertised. */
|
|
86
|
+
minDepositUsd?: number
|
|
127
87
|
/**
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
-
* which auto-pops whenever setup becomes unsatisfied. An empty array
|
|
131
|
-
* is valid and indicates the provider has no setup gates.
|
|
88
|
+
* Minimum order notional value in USD. Feeds the SDK's `validateMargin`
|
|
89
|
+
* `minMarginUsd` parameter. Absent means no minimum advertised.
|
|
132
90
|
*/
|
|
133
|
-
|
|
91
|
+
minOrderValueUsd?: number
|
|
134
92
|
/**
|
|
135
|
-
*
|
|
136
|
-
*
|
|
137
|
-
*
|
|
93
|
+
* Minimum order notional value in USD for reduce-only orders, when the
|
|
94
|
+
* provider applies a lower floor than `minOrderValueUsd`. Absent means
|
|
95
|
+
* reduce-only orders use the same floor as `minOrderValueUsd`.
|
|
138
96
|
*/
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
97
|
+
minReduceOrderValueUsd?: number
|
|
98
|
+
/** Minimum withdrawal notional in USD. Absent means no minimum advertised. */
|
|
99
|
+
minWithdrawalUsd?: number
|
|
100
|
+
/** Flat deposit fee in USD the provider charges. Absent means no fee advertised. */
|
|
101
|
+
depositFeeUsd?: number
|
|
102
|
+
/** Flat withdrawal fee in USD the provider charges. Absent means no fee advertised. */
|
|
103
|
+
withdrawalFeeUsd?: number
|
|
143
104
|
/**
|
|
144
|
-
*
|
|
145
|
-
*
|
|
146
|
-
* gate the deposit UX on a value they don't have.
|
|
105
|
+
* Aggregate up-votes for this provider. Populated only for inactive
|
|
106
|
+
* providers (those gathering demand before launch); absent once `active`.
|
|
147
107
|
*/
|
|
148
|
-
|
|
108
|
+
upVotes?: number
|
|
109
|
+
/** Aggregate down-votes. Populated only for inactive providers; see {@link upVotes}. */
|
|
110
|
+
downVotes?: number
|
|
111
|
+
/**
|
|
112
|
+
* Candle intervals this provider supports for OHLCV/chart requests, in
|
|
113
|
+
* ascending order. Drives the client's chart interval selector. Empty for
|
|
114
|
+
* providers that expose no candle data.
|
|
115
|
+
*/
|
|
116
|
+
supportedIntervals: OhlcvInterval[]
|
|
149
117
|
}
|
|
150
118
|
|
|
119
|
+
/** @public */
|
|
151
120
|
export interface ProvidersResponse {
|
|
152
121
|
providers: Provider[]
|
|
153
122
|
}
|
package/src/quote.ts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { FeeTier } from './account.js'
|
|
2
|
+
import type { FundingInfo } from './market.js'
|
|
3
|
+
|
|
4
|
+
/** @public */
|
|
5
|
+
export type QuoteSide = 'buy' | 'sell'
|
|
6
|
+
|
|
7
|
+
/** @public */
|
|
8
|
+
export type TradeType = 'perps' | 'spot'
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* One-shot fill estimate for a market order of `sizeUsd` notional on a single
|
|
12
|
+
* venue: the VWAP fill walked from the orderbook, the price impact versus the
|
|
13
|
+
* mark, the base-tier taker fee, and (for perps) the current funding rate.
|
|
14
|
+
*
|
|
15
|
+
* `priceImpactBps` is signed-magnitude basis points (1 bps = 0.01%) of the
|
|
16
|
+
* VWAP fill's deviation from `markPrice` — always non-negative, since a buy
|
|
17
|
+
* fills above mark and a sell below.
|
|
18
|
+
* @public
|
|
19
|
+
*/
|
|
20
|
+
export interface Quote {
|
|
21
|
+
provider: string
|
|
22
|
+
/** Human `displaySymbol` the quote was resolved against, e.g. `"BTC"`. */
|
|
23
|
+
symbol: string
|
|
24
|
+
/** Opaque resolved `Market.id`. */
|
|
25
|
+
marketId: string
|
|
26
|
+
type: TradeType
|
|
27
|
+
side: QuoteSide
|
|
28
|
+
/** Input notional in USD. */
|
|
29
|
+
sizeUsd: string
|
|
30
|
+
/** Base amount the book filled for `sizeUsd` (or the most obtainable when the book is too thin). */
|
|
31
|
+
baseSize: string
|
|
32
|
+
markPrice: string
|
|
33
|
+
/** Volume-weighted average fill price from the book walk. */
|
|
34
|
+
expectedFillPrice: string
|
|
35
|
+
/** VWAP deviation from `markPrice` in basis points; non-negative. */
|
|
36
|
+
priceImpactBps: string
|
|
37
|
+
/** Base maker/taker fee fractions (not bps) for the public tier. */
|
|
38
|
+
feeTier: FeeTier
|
|
39
|
+
/** Always `true` in v1 — quotes use the public base tier, never a per-account tier. */
|
|
40
|
+
isDefaultFeeTier: boolean
|
|
41
|
+
/** Taker fee on the filled notional in USD: `filledNotional * feeTier.taker`. */
|
|
42
|
+
feeUsd: string
|
|
43
|
+
/** Current funding for perps; `null` for spot. */
|
|
44
|
+
funding: FundingInfo | null
|
|
45
|
+
/** `true` when the book could not fill the full `sizeUsd` — `baseSize`/fill reflect the best obtainable. */
|
|
46
|
+
insufficientLiquidity: boolean
|
|
47
|
+
/** Unix milliseconds the quote was produced. */
|
|
48
|
+
timestamp: number
|
|
49
|
+
}
|
package/src/subscriptions.ts
CHANGED
|
@@ -1,44 +1,62 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import type {
|
|
2
|
+
Balance,
|
|
3
|
+
Fill,
|
|
4
|
+
OpenOrder,
|
|
5
|
+
Position,
|
|
6
|
+
TriggerOrder,
|
|
7
|
+
} from './account.js'
|
|
8
|
+
import type { Candle, OhlcvInterval, OrderbookResponse } from './market.js'
|
|
9
|
+
import type { Address } from './primitives.js'
|
|
7
10
|
|
|
11
|
+
/** @public */
|
|
8
12
|
export type PricesSubscription = { channel: 'prices'; dex: string }
|
|
13
|
+
/** @public */
|
|
9
14
|
export type OrderbookSubscription = {
|
|
10
15
|
channel: 'orderbook'
|
|
11
16
|
dex: string
|
|
12
|
-
|
|
17
|
+
marketId: string
|
|
13
18
|
depth?: number
|
|
19
|
+
/**
|
|
20
|
+
* Desired price granularity of streamed levels, in quote currency (e.g.
|
|
21
|
+
* `10` buckets a BTC book into $10-wide levels). Providers that aggregate
|
|
22
|
+
* the book server-side honour it best-effort; providers that stream the
|
|
23
|
+
* full book ignore it. `undefined` requests full precision.
|
|
24
|
+
*/
|
|
25
|
+
priceStep?: number
|
|
14
26
|
}
|
|
27
|
+
/** @public */
|
|
15
28
|
export type CandleSubscription = {
|
|
16
29
|
channel: 'candle'
|
|
17
30
|
dex: string
|
|
18
|
-
|
|
31
|
+
marketId: string
|
|
19
32
|
interval: OhlcvInterval
|
|
20
33
|
}
|
|
34
|
+
/** @public */
|
|
21
35
|
export type OrderUpdatesSubscription = {
|
|
22
36
|
channel: 'orderUpdates'
|
|
23
37
|
dex: string
|
|
24
38
|
address: Address
|
|
25
39
|
}
|
|
40
|
+
/** @public */
|
|
26
41
|
export type FillsSubscription = {
|
|
27
42
|
channel: 'fills'
|
|
28
43
|
dex: string
|
|
29
44
|
address: Address
|
|
30
45
|
}
|
|
46
|
+
/** @public */
|
|
31
47
|
export type PositionsSubscription = {
|
|
32
48
|
channel: 'positions'
|
|
33
49
|
dex: string
|
|
34
50
|
address: Address
|
|
35
51
|
}
|
|
52
|
+
/** @public */
|
|
36
53
|
export type SpotBalancesSubscription = {
|
|
37
54
|
channel: 'spotBalances'
|
|
38
55
|
dex: string
|
|
39
56
|
address: Address
|
|
40
57
|
}
|
|
41
58
|
|
|
59
|
+
/** @public */
|
|
42
60
|
export type Subscription =
|
|
43
61
|
| PricesSubscription
|
|
44
62
|
| OrderbookSubscription
|
|
@@ -48,22 +66,48 @@ export type Subscription =
|
|
|
48
66
|
| PositionsSubscription
|
|
49
67
|
| SpotBalancesSubscription
|
|
50
68
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
export interface SpotBalance {
|
|
54
|
-
coin: string
|
|
55
|
-
total: string
|
|
56
|
-
hold: string
|
|
57
|
-
}
|
|
58
|
-
|
|
69
|
+
/** @public */
|
|
59
70
|
export type PricesEvent = { channel: 'prices'; data: Record<string, string> }
|
|
71
|
+
/** @public */
|
|
60
72
|
export type OrderbookEvent = { channel: 'orderbook'; data: OrderbookResponse }
|
|
73
|
+
/** @public */
|
|
61
74
|
export type CandleEvent = { channel: 'candle'; data: Candle }
|
|
62
|
-
|
|
75
|
+
/** @public */
|
|
76
|
+
export type OrderUpdatesEvent = {
|
|
77
|
+
channel: 'orderUpdates'
|
|
78
|
+
data: {
|
|
79
|
+
/** Upserts — active orders, non-trigger. */
|
|
80
|
+
openOrders: OpenOrder[]
|
|
81
|
+
/** Upserts — active orders with trigger semantics (TP/SL). */
|
|
82
|
+
triggerOrders: TriggerOrder[]
|
|
83
|
+
/**
|
|
84
|
+
* orderIds whose status just transitioned to terminal (filled, cancelled,
|
|
85
|
+
* rejected, expired). Consumers should evict these from both buckets.
|
|
86
|
+
*/
|
|
87
|
+
terminated: string[]
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
/** @public */
|
|
63
91
|
export type FillsEvent = { channel: 'fills'; data: Fill[] }
|
|
92
|
+
/**
|
|
93
|
+
* Positions stream frame. `data` is always the full set of currently open
|
|
94
|
+
* positions for the subscribed address, never a partial update: zero-size
|
|
95
|
+
* entries never appear, and a close is observed as the market's absence from
|
|
96
|
+
* the next frame. Consumers replace their state; they must not merge.
|
|
97
|
+
* @public
|
|
98
|
+
*/
|
|
64
99
|
export type PositionsEvent = { channel: 'positions'; data: Position[] }
|
|
65
|
-
|
|
100
|
+
/**
|
|
101
|
+
* Spot holdings as typed {@link Balance}s, each carrying the venue-locked
|
|
102
|
+
* portion (`locked` = reserved against open orders; `available = units − locked`).
|
|
103
|
+
* @public
|
|
104
|
+
*/
|
|
105
|
+
export type SpotBalancesEvent = {
|
|
106
|
+
channel: 'spotBalances'
|
|
107
|
+
data: (Balance & { locked: string })[]
|
|
108
|
+
}
|
|
66
109
|
|
|
110
|
+
/** @public */
|
|
67
111
|
export type SubscriptionEvent =
|
|
68
112
|
| PricesEvent
|
|
69
113
|
| OrderbookEvent
|
package/src/typedData.ts
CHANGED
|
@@ -1,23 +1,32 @@
|
|
|
1
|
-
import type { Address, Hex
|
|
2
|
-
import type { HlPrimaryType } from './providers/hyperliquid/types.js'
|
|
1
|
+
import type { Address, Hex } from './primitives.js'
|
|
3
2
|
|
|
4
|
-
/**
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
/** @public */
|
|
4
|
+
export interface TypedDataDomain {
|
|
5
|
+
name?: string
|
|
6
|
+
version?: string
|
|
7
|
+
chainId?: number
|
|
8
|
+
verifyingContract?: Address
|
|
9
|
+
salt?: Hex
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** @public */
|
|
13
|
+
export interface TypedDataParameter {
|
|
14
|
+
name: string
|
|
15
|
+
type: string
|
|
16
|
+
}
|
|
9
17
|
|
|
18
|
+
/** @public */
|
|
19
|
+
export type PerpsPrimaryType = string
|
|
20
|
+
|
|
21
|
+
/** @public */
|
|
10
22
|
export type PerpsTypedData = {
|
|
11
23
|
domain: TypedDataDomain
|
|
12
24
|
types: Record<string, readonly TypedDataParameter[]>
|
|
13
25
|
primaryType: PerpsPrimaryType
|
|
14
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
15
26
|
message: Record<string, any>
|
|
16
27
|
}
|
|
17
28
|
|
|
29
|
+
/** @public */
|
|
18
30
|
export type PerpsSignedTypedData = PerpsTypedData & {
|
|
19
31
|
signature: Hex
|
|
20
32
|
}
|
|
21
|
-
|
|
22
|
-
// Re-export viem primitives used across perps types
|
|
23
|
-
export type { Address, Hex, TypedDataDomain, TypedDataParameter }
|