@lifi/perps-types 4.0.0 → 4.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.
Files changed (78) hide show
  1. package/dist/cjs/account.d.ts.map +1 -1
  2. package/dist/cjs/action.d.ts +1 -0
  3. package/dist/cjs/action.d.ts.map +1 -1
  4. package/dist/cjs/asset.d.ts.map +1 -1
  5. package/dist/cjs/enums.d.ts.map +1 -1
  6. package/dist/cjs/enums.js.map +1 -1
  7. package/dist/cjs/errors.d.ts.map +1 -1
  8. package/dist/cjs/market.d.ts.map +1 -1
  9. package/dist/cjs/primitives.d.ts.map +1 -1
  10. package/dist/cjs/providers.d.ts.map +1 -1
  11. package/dist/cjs/subscriptions.d.ts.map +1 -1
  12. package/dist/cjs/typedData.d.ts.map +1 -1
  13. package/dist/cjs/vote.d.ts.map +1 -1
  14. package/dist/cjs/vote.js.map +1 -1
  15. package/dist/esm/account.d.ts +194 -31
  16. package/dist/esm/account.d.ts.map +1 -1
  17. package/dist/esm/action.d.ts +205 -37
  18. package/dist/esm/action.d.ts.map +1 -1
  19. package/dist/esm/asset.d.ts +1 -4
  20. package/dist/esm/asset.d.ts.map +1 -1
  21. package/dist/esm/enums.d.ts +34 -20
  22. package/dist/esm/enums.d.ts.map +1 -1
  23. package/dist/esm/enums.js +33 -19
  24. package/dist/esm/enums.js.map +1 -1
  25. package/dist/esm/errors.d.ts +6 -1
  26. package/dist/esm/errors.d.ts.map +1 -1
  27. package/dist/esm/market.d.ts +47 -14
  28. package/dist/esm/market.d.ts.map +1 -1
  29. package/dist/esm/primitives.d.ts +12 -2
  30. package/dist/esm/primitives.d.ts.map +1 -1
  31. package/dist/esm/providers.d.ts +19 -6
  32. package/dist/esm/providers.d.ts.map +1 -1
  33. package/dist/esm/quote.d.ts +2 -2
  34. package/dist/esm/quote.d.ts.map +1 -1
  35. package/dist/esm/subscriptions.d.ts +27 -19
  36. package/dist/esm/subscriptions.d.ts.map +1 -1
  37. package/dist/esm/typedData.d.ts +15 -5
  38. package/dist/esm/typedData.d.ts.map +1 -1
  39. package/dist/esm/vote.d.ts +1 -3
  40. package/dist/esm/vote.d.ts.map +1 -1
  41. package/dist/esm/vote.js.map +1 -1
  42. package/dist/types/account.d.ts +194 -31
  43. package/dist/types/account.d.ts.map +1 -1
  44. package/dist/types/action.d.ts +205 -37
  45. package/dist/types/action.d.ts.map +1 -1
  46. package/dist/types/asset.d.ts +1 -4
  47. package/dist/types/asset.d.ts.map +1 -1
  48. package/dist/types/enums.d.ts +34 -20
  49. package/dist/types/enums.d.ts.map +1 -1
  50. package/dist/types/errors.d.ts +6 -1
  51. package/dist/types/errors.d.ts.map +1 -1
  52. package/dist/types/market.d.ts +47 -14
  53. package/dist/types/market.d.ts.map +1 -1
  54. package/dist/types/primitives.d.ts +12 -2
  55. package/dist/types/primitives.d.ts.map +1 -1
  56. package/dist/types/providers.d.ts +19 -6
  57. package/dist/types/providers.d.ts.map +1 -1
  58. package/dist/types/quote.d.ts +2 -2
  59. package/dist/types/quote.d.ts.map +1 -1
  60. package/dist/types/subscriptions.d.ts +27 -19
  61. package/dist/types/subscriptions.d.ts.map +1 -1
  62. package/dist/types/typedData.d.ts +15 -5
  63. package/dist/types/typedData.d.ts.map +1 -1
  64. package/dist/types/vote.d.ts +1 -3
  65. package/dist/types/vote.d.ts.map +1 -1
  66. package/package.json +1 -1
  67. package/src/account.ts +194 -36
  68. package/src/action.ts +205 -37
  69. package/src/asset.ts +1 -4
  70. package/src/enums.ts +34 -20
  71. package/src/errors.ts +6 -1
  72. package/src/market.ts +47 -14
  73. package/src/primitives.ts +12 -2
  74. package/src/providers.ts +19 -6
  75. package/src/quote.ts +2 -2
  76. package/src/subscriptions.ts +27 -19
  77. package/src/typedData.ts +15 -5
  78. package/src/vote.ts +1 -3
package/src/market.ts CHANGED
@@ -1,23 +1,34 @@
1
1
  import type { Asset } from './asset.js'
2
2
  import type { PositionMarginAdjustment } from './enums.js'
3
3
 
4
- /** @public */
4
+ /**
5
+ * Current funding rate and next funding timestamp for a perpetual market.
6
+ * `rate` is a decimal fraction; `nextFundingTime` is Unix milliseconds.
7
+ *
8
+ * @public
9
+ */
5
10
  export interface FundingInfo {
11
+ /** Funding rate as a decimal fraction. */
6
12
  rate: string
13
+ /** Next funding timestamp in Unix milliseconds. */
7
14
  nextFundingTime: number
8
15
  }
9
16
 
10
- /** @public */
17
+ /**
18
+ * Shared market metadata for perpetual and spot instruments.
19
+ *
20
+ * @public
21
+ */
11
22
  export interface BaseMarket {
12
23
  providerId: string
13
24
  /** Opaque provider market id; referenced elsewhere as `marketId`. */
14
25
  id: string
15
- /** Whether the venue has delisted this market. */
16
26
  isDelisted?: boolean
17
27
  /** References a {@link ProviderCategory} by id. */
18
28
  categoryId: string
19
29
  baseAsset: Asset
20
30
  quoteAsset: Asset
31
+ /** Maximum fractional precision accepted for order sizes. */
21
32
  szDecimals: number
22
33
  /**
23
34
  * Maximum decimal places the venue accepts for order prices on this market.
@@ -42,7 +53,11 @@ export interface BaseMarket {
42
53
  sizeIncrement?: string
43
54
  }
44
55
 
45
- /** @public */
56
+ /**
57
+ * Perpetual market metadata, including leverage and margin constraints.
58
+ *
59
+ * @public
60
+ */
46
61
  export interface PerpsMarket extends BaseMarket {
47
62
  maxLeverage: number
48
63
  onlyIsolated: boolean
@@ -64,10 +79,15 @@ export interface SpotMarket extends BaseMarket {
64
79
  positionMarginAdjustment?: never
65
80
  }
66
81
 
67
- /** @public */
82
+ /** Union of perpetual and spot market representations. @public */
68
83
  export type Market = PerpsMarket | SpotMarket
69
84
 
70
- /** @public */
85
+ /**
86
+ * UI-safe market projection containing identity, category, assets, and
87
+ * delisting state without provider-specific trading constraints.
88
+ *
89
+ * @public
90
+ */
71
91
  export type MarketDisplay = Pick<
72
92
  BaseMarket,
73
93
  'providerId' | 'id' | 'categoryId' | 'baseAsset' | 'quoteAsset' | 'isDelisted'
@@ -96,7 +116,7 @@ export interface MarketRef {
96
116
  categoryId: string
97
117
  }
98
118
 
99
- /** @public */
119
+ /** Response containing all markets returned for a provider. @public */
100
120
  export interface MarketsResponse {
101
121
  markets: Market[]
102
122
  }
@@ -111,8 +131,11 @@ export interface MarketsResponse {
111
131
  * @public
112
132
  */
113
133
  export interface MarketContext {
134
+ /** Opaque provider market identifier for this context frame. */
114
135
  marketId: string
136
+ /** Current order-book midpoint, as a decimal quote string. */
115
137
  midPrice: string
138
+ /** Provider mark price, as a decimal quote string. */
116
139
  markPrice: string
117
140
  oraclePrice?: string
118
141
  prevDayPrice?: string
@@ -123,12 +146,17 @@ export interface MarketContext {
123
146
  funding?: FundingInfo
124
147
  }
125
148
 
126
- /** @public */
149
+ /** Response containing live context for requested markets. @public */
127
150
  export interface PricesResponse {
128
151
  prices: MarketContext[]
129
152
  }
130
153
 
131
- /** @public */
154
+ /**
155
+ * OHLCV candle with Unix-millisecond open time and decimal-string OHLCV
156
+ * values. Field names follow the compact provider response shape.
157
+ *
158
+ * @public
159
+ */
132
160
  export interface Candle {
133
161
  t: number
134
162
  o: string
@@ -138,7 +166,7 @@ export interface Candle {
138
166
  v: string
139
167
  }
140
168
 
141
- /** @public */
169
+ /** Response containing candles for one provider market and interval. @public */
142
170
  export interface OhlcvResponse {
143
171
  provider: string
144
172
  marketId: string
@@ -146,7 +174,12 @@ export interface OhlcvResponse {
146
174
  candles: Candle[]
147
175
  }
148
176
 
149
- /** @public */
177
+ /**
178
+ * Supported OHLCV intervals. Values are wire interval strings (`1M` is one
179
+ * month; lowercase `m` values are minutes).
180
+ *
181
+ * @public
182
+ */
150
183
  export type OhlcvInterval =
151
184
  | '1m'
152
185
  | '3m'
@@ -163,13 +196,13 @@ export type OhlcvInterval =
163
196
  | '1w'
164
197
  | '1M'
165
198
 
166
- /** @public */
199
+ /** One price/size level in an order book; both values are decimal strings. @public */
167
200
  export interface OrderbookLevel {
168
201
  price: string
169
202
  size: string
170
203
  }
171
204
 
172
- /** @public */
205
+ /** Snapshot of bids and asks for one market. `timestamp` is Unix milliseconds. @public */
173
206
  export interface OrderbookResponse {
174
207
  provider: string
175
208
  marketId: string
@@ -178,7 +211,7 @@ export interface OrderbookResponse {
178
211
  timestamp: number
179
212
  }
180
213
 
181
- /** @public */
214
+ /** Recent trade normalized for a market; `timestamp` is Unix milliseconds. @public */
182
215
  export interface Trade {
183
216
  provider: string
184
217
  marketId: string
package/src/primitives.ts CHANGED
@@ -1,5 +1,15 @@
1
- /** @public */
1
+ /**
2
+ * Hex-prefixed EVM address string. The type validates only the `0x` prefix;
3
+ * checksum and byte-length validation remain runtime/provider concerns.
4
+ *
5
+ * @public
6
+ */
2
7
  export type Address = `0x${string}`
3
8
 
4
- /** @public */
9
+ /**
10
+ * Hex-prefixed byte string used for hashes, signatures, salts, and other EVM
11
+ * wire values. The type does not constrain byte length.
12
+ *
13
+ * @public
14
+ */
5
15
  export type Hex = `0x${string}`
package/src/providers.ts CHANGED
@@ -2,13 +2,17 @@ import type { Asset, DepositAsset } from './asset.js'
2
2
  import type { ActionType, PerpsSigner, SigningMethod } from './enums.js'
3
3
  import type { OhlcvInterval } from './market.js'
4
4
 
5
- /** @public */
5
+ /** A fixed option value presented for a provider action parameter. @public */
6
6
  export interface ParamOption {
7
7
  value: string
8
8
  label: string
9
9
  }
10
10
 
11
- /** @public */
11
+ /**
12
+ * Metadata describing one provider action parameter and its UI constraints.
13
+ *
14
+ * @public
15
+ */
12
16
  export interface Param {
13
17
  /** Wire key for the action params object: `{ [param.name]: value }`. */
14
18
  name: string
@@ -60,7 +64,11 @@ export interface TradeNotice {
60
64
  message: string
61
65
  }
62
66
 
63
- /** @public */
67
+ /**
68
+ * Provider category metadata, including quote asset and optional market notice.
69
+ *
70
+ * @public
71
+ */
64
72
  export interface ProviderCategory {
65
73
  id: string
66
74
  logoURI?: string
@@ -69,7 +77,7 @@ export interface ProviderCategory {
69
77
  tradeNotice?: TradeNotice
70
78
  }
71
79
 
72
- /** @public */
80
+ /** Provider-wide funding cadence metadata, expressed in seconds. @public */
73
81
  export interface ProviderFunding {
74
82
  /** Number of seconds represented by the provider's funding rate. */
75
83
  ratePeriodSeconds: number
@@ -77,7 +85,12 @@ export interface ProviderFunding {
77
85
  payoutCadenceSeconds: number
78
86
  }
79
87
 
80
- /** @public */
88
+ /**
89
+ * Provider descriptor containing capabilities, actions, categories, and
90
+ * optional deposit/trading limits.
91
+ *
92
+ * @public
93
+ */
81
94
  export interface Provider {
82
95
  key: string
83
96
  name: string
@@ -142,7 +155,7 @@ export interface Provider {
142
155
  supportedIntervals: OhlcvInterval[]
143
156
  }
144
157
 
145
- /** @public */
158
+ /** Response containing provider descriptors available to the client. @public */
146
159
  export interface ProvidersResponse {
147
160
  providers: Provider[]
148
161
  }
package/src/quote.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  import type { FeeTier } from './account.js'
2
2
  import type { FundingInfo } from './market.js'
3
3
 
4
- /** @public */
4
+ /** Side of the quoted market order, using lowercase wire values. @public */
5
5
  export type QuoteSide = 'buy' | 'sell'
6
6
 
7
- /** @public */
7
+ /** Trade instrument kind represented by the quote. @public */
8
8
  export type TradeType = 'perps' | 'spot'
9
9
 
10
10
  /**
@@ -15,18 +15,18 @@ import type {
15
15
  } from './market.js'
16
16
  import type { Address } from './primitives.js'
17
17
 
18
- /** @public */
18
+ /** Subscription for the provider's aggregate market-context stream. @public */
19
19
  export type MarketsContextSubscription = {
20
20
  channel: 'marketsContext'
21
21
  dex: string
22
22
  }
23
- /** @public */
23
+ /** Subscription for one market's live context stream. @public */
24
24
  export type MarketContextSubscription = {
25
25
  channel: 'marketContext'
26
26
  dex: string
27
27
  marketId: string
28
28
  }
29
- /** @public */
29
+ /** Subscription for streamed order-book updates for one market. @public */
30
30
  export type OrderbookSubscription = {
31
31
  channel: 'orderbook'
32
32
  dex: string
@@ -40,51 +40,55 @@ export type OrderbookSubscription = {
40
40
  */
41
41
  priceStep?: number
42
42
  }
43
- /** @public */
43
+ /** Subscription for OHLCV candle updates for one market and interval. @public */
44
44
  export type CandleSubscription = {
45
45
  channel: 'candle'
46
46
  dex: string
47
47
  marketId: string
48
48
  interval: OhlcvInterval
49
49
  }
50
- /** @public */
50
+ /** Subscription for recent trade updates for one market. @public */
51
51
  export type TradesSubscription = {
52
52
  channel: 'trades'
53
53
  dex: string
54
54
  marketId: string
55
55
  }
56
- /** @public */
56
+ /** Subscription for order lifecycle updates for one account. @public */
57
57
  export type OrderUpdatesSubscription = {
58
58
  channel: 'orderUpdates'
59
59
  dex: string
60
60
  address: Address
61
61
  }
62
- /** @public */
62
+ /** Subscription for execution/fill updates for one account. @public */
63
63
  export type FillsSubscription = {
64
64
  channel: 'fills'
65
65
  dex: string
66
66
  address: Address
67
67
  }
68
- /** @public */
68
+ /** Subscription for the full open-position set for one account. @public */
69
69
  export type PositionsSubscription = {
70
70
  channel: 'positions'
71
71
  dex: string
72
72
  address: Address
73
73
  }
74
- /** @public */
74
+ /** Subscription for spot-balance updates for one account. @public */
75
75
  export type SpotBalancesSubscription = {
76
76
  channel: 'spotBalances'
77
77
  dex: string
78
78
  address: Address
79
79
  }
80
- /** @public */
80
+ /** Subscription for aggregate account-summary updates for one account. @public */
81
81
  export type AccountSummarySubscription = {
82
82
  channel: 'accountSummary'
83
83
  dex: string
84
84
  address: Address
85
85
  }
86
86
 
87
- /** @public */
87
+ /**
88
+ * Union of all websocket subscription request shapes.
89
+ *
90
+ * @public
91
+ */
88
92
  export type Subscription =
89
93
  | MarketsContextSubscription
90
94
  | MarketContextSubscription
@@ -97,23 +101,23 @@ export type Subscription =
97
101
  | SpotBalancesSubscription
98
102
  | AccountSummarySubscription
99
103
 
100
- /** @public */
104
+ /** Event containing the provider's aggregate market contexts. @public */
101
105
  export type MarketsContextEvent = {
102
106
  channel: 'marketsContext'
103
107
  data: Record<string, MarketContext>
104
108
  }
105
- /** @public */
109
+ /** Event containing one market's live context. @public */
106
110
  export type MarketContextEvent = {
107
111
  channel: 'marketContext'
108
112
  data: MarketContext
109
113
  }
110
- /** @public */
114
+ /** Event containing an order-book snapshot or update. @public */
111
115
  export type OrderbookEvent = { channel: 'orderbook'; data: OrderbookResponse }
112
- /** @public */
116
+ /** Event containing one OHLCV candle. @public */
113
117
  export type CandleEvent = { channel: 'candle'; data: Candle }
114
- /** @public */
118
+ /** Event containing recent trades. @public */
115
119
  export type TradesEvent = { channel: 'trades'; data: Trade[] }
116
- /** @public */
120
+ /** Event containing order upserts and terminal order ids. @public */
117
121
  export type OrderUpdatesEvent = {
118
122
  channel: 'orderUpdates'
119
123
  data: {
@@ -128,7 +132,7 @@ export type OrderUpdatesEvent = {
128
132
  terminated: string[]
129
133
  }
130
134
  }
131
- /** @public */
135
+ /** Event containing newly observed executions/fills. @public */
132
136
  export type FillsEvent = { channel: 'fills'; data: Fill[] }
133
137
  /**
134
138
  * Positions stream frame. `data` is always the full set of currently open
@@ -159,7 +163,11 @@ export type AccountSummaryEvent = {
159
163
  data: AccountSummary
160
164
  }
161
165
 
162
- /** @public */
166
+ /**
167
+ * Union of all websocket event frame shapes emitted for subscriptions.
168
+ *
169
+ * @public
170
+ */
163
171
  export type SubscriptionEvent =
164
172
  | MarketsContextEvent
165
173
  | MarketContextEvent
package/src/typedData.ts CHANGED
@@ -1,6 +1,11 @@
1
1
  import type { Address, Hex } from './primitives.js'
2
2
 
3
- /** @public */
3
+ /**
4
+ * EIP-712 domain fields used to identify a signing domain. `chainId` is the
5
+ * numeric EVM chain id when present.
6
+ *
7
+ * @public
8
+ */
4
9
  export interface TypedDataDomain {
5
10
  name?: string
6
11
  version?: string
@@ -9,16 +14,21 @@ export interface TypedDataDomain {
9
14
  salt?: Hex
10
15
  }
11
16
 
12
- /** @public */
17
+ /** One named field in an EIP-712 primary type definition. @public */
13
18
  export interface TypedDataParameter {
14
19
  name: string
15
20
  type: string
16
21
  }
17
22
 
18
- /** @public */
23
+ /** Primary-type name used by a perps EIP-712 payload. @public */
19
24
  export type PerpsPrimaryType = string
20
25
 
21
- /** @public */
26
+ /**
27
+ * Provider-neutral EIP-712 payload passed between backend and SDK. `message`
28
+ * intentionally remains open because each action defines its own fields.
29
+ *
30
+ * @public
31
+ */
22
32
  export type PerpsTypedData = {
23
33
  domain: TypedDataDomain
24
34
  types: Record<string, readonly TypedDataParameter[]>
@@ -26,7 +36,7 @@ export type PerpsTypedData = {
26
36
  message: Record<string, any>
27
37
  }
28
38
 
29
- /** @public */
39
+ /** EIP-712 payload accompanied by its client-produced signature. @public */
30
40
  export type PerpsSignedTypedData = PerpsTypedData & {
31
41
  signature: Hex
32
42
  }
package/src/vote.ts CHANGED
@@ -9,7 +9,7 @@ import type { PerpsTypedData, TypedDataParameter } from './typedData.js'
9
9
  */
10
10
  export const META_PROVIDER = 'meta'
11
11
 
12
- /** @public */
12
+ /** Type alias for the {@link META_PROVIDER} provider-independent sentinel. @public */
13
13
  export type MetaProvider = typeof META_PROVIDER
14
14
 
15
15
  /**
@@ -34,7 +34,6 @@ export type VoteType = 'provider'
34
34
  * @public
35
35
  */
36
36
  export interface VoteParams {
37
- /** Key of the inactive provider being voted on (the voted-on subject). */
38
37
  targetProvider: string
39
38
  direction: VoteDirection
40
39
  voteType: VoteType
@@ -45,7 +44,6 @@ export interface VoteParams {
45
44
  * @public
46
45
  */
47
46
  export interface VoteMessage {
48
- /** Key of the inactive provider being voted on. */
49
47
  targetProvider: string
50
48
  direction: VoteDirection
51
49
  voteType: VoteType