@lifi/perps-types 17.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 (81) hide show
  1. package/dist/cjs/account.d.ts +63 -60
  2. package/dist/cjs/account.d.ts.map +1 -1
  3. package/dist/cjs/action.d.ts +21 -20
  4. package/dist/cjs/action.d.ts.map +1 -1
  5. package/dist/cjs/asset.d.ts +2 -1
  6. package/dist/cjs/asset.d.ts.map +1 -1
  7. package/dist/cjs/decimal.d.ts +4 -0
  8. package/dist/cjs/decimal.d.ts.map +1 -0
  9. package/dist/cjs/decimal.js +9 -0
  10. package/dist/cjs/decimal.js.map +1 -0
  11. package/dist/cjs/index.d.ts +1 -0
  12. package/dist/cjs/index.d.ts.map +1 -1
  13. package/dist/cjs/index.js +1 -0
  14. package/dist/cjs/index.js.map +1 -1
  15. package/dist/cjs/market.d.ts +25 -23
  16. package/dist/cjs/market.d.ts.map +1 -1
  17. package/dist/cjs/portfolioHistory.d.ts +5 -4
  18. package/dist/cjs/portfolioHistory.d.ts.map +1 -1
  19. package/dist/cjs/quote.d.ts +7 -6
  20. package/dist/cjs/quote.d.ts.map +1 -1
  21. package/dist/cjs/referral.d.ts +5 -4
  22. package/dist/cjs/referral.d.ts.map +1 -1
  23. package/dist/cjs/referral.js.map +1 -1
  24. package/dist/cjs/subscriptions.d.ts +2 -1
  25. package/dist/cjs/subscriptions.d.ts.map +1 -1
  26. package/dist/esm/account.d.ts +81 -68
  27. package/dist/esm/account.d.ts.map +1 -1
  28. package/dist/esm/action.d.ts +40 -28
  29. package/dist/esm/action.d.ts.map +1 -1
  30. package/dist/esm/asset.d.ts +2 -1
  31. package/dist/esm/asset.d.ts.map +1 -1
  32. package/dist/esm/decimal.d.ts +23 -0
  33. package/dist/esm/decimal.d.ts.map +1 -0
  34. package/dist/esm/decimal.js +17 -0
  35. package/dist/esm/decimal.js.map +1 -0
  36. package/dist/esm/index.d.ts +1 -0
  37. package/dist/esm/index.d.ts.map +1 -1
  38. package/dist/esm/index.js +1 -0
  39. package/dist/esm/index.js.map +1 -1
  40. package/dist/esm/market.d.ts +29 -23
  41. package/dist/esm/market.d.ts.map +1 -1
  42. package/dist/esm/portfolioHistory.d.ts +5 -4
  43. package/dist/esm/portfolioHistory.d.ts.map +1 -1
  44. package/dist/esm/quote.d.ts +7 -6
  45. package/dist/esm/quote.d.ts.map +1 -1
  46. package/dist/esm/referral.d.ts +5 -5
  47. package/dist/esm/referral.d.ts.map +1 -1
  48. package/dist/esm/referral.js.map +1 -1
  49. package/dist/esm/subscriptions.d.ts +2 -1
  50. package/dist/esm/subscriptions.d.ts.map +1 -1
  51. package/dist/types/account.d.ts +81 -68
  52. package/dist/types/account.d.ts.map +1 -1
  53. package/dist/types/action.d.ts +40 -28
  54. package/dist/types/action.d.ts.map +1 -1
  55. package/dist/types/asset.d.ts +2 -1
  56. package/dist/types/asset.d.ts.map +1 -1
  57. package/dist/types/decimal.d.ts +23 -0
  58. package/dist/types/decimal.d.ts.map +1 -0
  59. package/dist/types/index.d.ts +1 -0
  60. package/dist/types/index.d.ts.map +1 -1
  61. package/dist/types/market.d.ts +29 -23
  62. package/dist/types/market.d.ts.map +1 -1
  63. package/dist/types/portfolioHistory.d.ts +5 -4
  64. package/dist/types/portfolioHistory.d.ts.map +1 -1
  65. package/dist/types/quote.d.ts +7 -6
  66. package/dist/types/quote.d.ts.map +1 -1
  67. package/dist/types/referral.d.ts +5 -5
  68. package/dist/types/referral.d.ts.map +1 -1
  69. package/dist/types/subscriptions.d.ts +2 -1
  70. package/dist/types/subscriptions.d.ts.map +1 -1
  71. package/package.json +1 -1
  72. package/src/account.ts +81 -68
  73. package/src/action.ts +41 -28
  74. package/src/asset.ts +3 -1
  75. package/src/decimal.ts +26 -0
  76. package/src/index.ts +1 -0
  77. package/src/market.ts +29 -23
  78. package/src/portfolioHistory.ts +6 -4
  79. package/src/quote.ts +7 -6
  80. package/src/referral.ts +5 -5
  81. package/src/subscriptions.ts +2 -1
package/src/market.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import type { Asset } from './asset.js'
2
+ import type { DecimalString } from './decimal.js'
2
3
  import type { PositionMarginAdjustment } from './enums.js'
3
4
 
4
5
  /**
@@ -9,7 +10,7 @@ import type { PositionMarginAdjustment } from './enums.js'
9
10
  */
10
11
  export interface FundingInfo {
11
12
  /** Funding rate as a decimal fraction. */
12
- rate: string
13
+ rate: DecimalString
13
14
  /** Next funding timestamp in Unix milliseconds. */
14
15
  nextFundingTime: number
15
16
  }
@@ -43,14 +44,14 @@ export interface BaseMarket {
43
44
  * describe the tick. Format prices through the provider's `formatOrderPrice`
44
45
  * rather than applying this field directly.
45
46
  */
46
- priceIncrement?: string
47
+ priceIncrement?: DecimalString
47
48
  /**
48
49
  * Exact size lot as a plain decimal string (e.g. `'0.05'`). Present when the
49
50
  * venue's grid is not a power of ten, where `szDecimals` alone cannot
50
51
  * describe the lot. Format sizes through the provider's `formatOrderSize`
51
52
  * rather than applying this field directly.
52
53
  */
53
- sizeIncrement?: string
54
+ sizeIncrement?: DecimalString
54
55
  }
55
56
 
56
57
  /**
@@ -60,17 +61,22 @@ export interface BaseMarket {
60
61
  */
61
62
  export interface PerpsMarket extends BaseMarket {
62
63
  maxLeverage: number
64
+ /**
65
+ * The display leverage the venue applies to a market with no stored user
66
+ * setting. Absent when the venue publishes no default.
67
+ */
68
+ defaultLeverage?: number
63
69
  /**
64
70
  * Minimum order notional in USD for this market, as a plain decimal string.
65
71
  * Lighter applies it to resting (post-only) orders only. Separate from the
66
72
  * venue-wide `Provider.minOrderValueUsd`, which is a `number`; parse this
67
73
  * string before comparing the two.
68
74
  */
69
- minOrderValueUsd?: string
75
+ minOrderValueUsd?: DecimalString
70
76
  /** Maximum market-order notional in USD, as a plain decimal string. */
71
- maxMarketOrderUsd?: string
77
+ maxMarketOrderUsd?: DecimalString
72
78
  /** Maximum limit-order notional in USD, as a plain decimal string. */
73
- maxLimitOrderUsd?: string
79
+ maxLimitOrderUsd?: DecimalString
74
80
  onlyIsolated: boolean
75
81
  /** Whether individual position margin can be added and/or removed. */
76
82
  positionMarginAdjustment: PositionMarginAdjustment
@@ -145,16 +151,16 @@ export interface MarketContext {
145
151
  /** Opaque provider market identifier for this context frame. */
146
152
  marketId: string
147
153
  /** Current order-book midpoint, as a decimal quote string. */
148
- midPrice: string
154
+ midPrice: DecimalString
149
155
  /** Provider mark price, as a decimal quote string. */
150
- markPrice: string
151
- oraclePrice?: string
152
- prevDayPrice?: string
153
- priceChange24h?: string
154
- volume24h?: string
155
- marketCap?: string
156
+ markPrice: DecimalString
157
+ oraclePrice?: DecimalString
158
+ prevDayPrice?: DecimalString
159
+ priceChange24h?: DecimalString
160
+ volume24h?: DecimalString
161
+ marketCap?: DecimalString
156
162
  /** Quote-asset open-interest notional as a decimal string. */
157
- openInterest?: string
163
+ openInterest?: DecimalString
158
164
  funding?: FundingInfo
159
165
  }
160
166
 
@@ -171,11 +177,11 @@ export interface PricesResponse {
171
177
  */
172
178
  export interface Candle {
173
179
  t: number
174
- o: string
175
- h: string
176
- l: string
177
- c: string
178
- v: string
180
+ o: DecimalString
181
+ h: DecimalString
182
+ l: DecimalString
183
+ c: DecimalString
184
+ v: DecimalString
179
185
  }
180
186
 
181
187
  /** Response containing candles for one provider market and interval. @public */
@@ -210,8 +216,8 @@ export type OhlcvInterval =
210
216
 
211
217
  /** One price/size level in an order book; both values are decimal strings. @public */
212
218
  export interface OrderbookLevel {
213
- price: string
214
- size: string
219
+ price: DecimalString
220
+ size: DecimalString
215
221
  }
216
222
 
217
223
  /** Snapshot of bids and asks for one market. `timestamp` is Unix milliseconds. @public */
@@ -227,8 +233,8 @@ export interface OrderbookResponse {
227
233
  export interface Trade {
228
234
  provider: string
229
235
  marketId: string
230
- price: string
231
- size: string
236
+ price: DecimalString
237
+ size: DecimalString
232
238
  timestamp: number
233
239
  side: 'buy' | 'sell'
234
240
  id?: string
@@ -1,3 +1,5 @@
1
+ import type { DecimalString } from './decimal.js'
2
+
1
3
  /** Lookback window of a portfolio history read. @public */
2
4
  export type PortfolioHistoryRange = '24h' | '7d' | '30d' | 'all'
3
5
 
@@ -9,9 +11,9 @@ export type PortfolioHistoryRange = '24h' | '7d' | '30d' | 'all'
9
11
  export interface PortfolioHistoryPoint {
10
12
  /** Unix milliseconds. */
11
13
  timestamp: number
12
- accountValue: string
14
+ accountValue: DecimalString
13
15
  /** Cumulative PnL from the start of the requested window. */
14
- pnl: string
16
+ pnl: DecimalString
15
17
  }
16
18
 
17
19
  /**
@@ -22,6 +24,6 @@ export interface PortfolioHistoryPoint {
22
24
  export interface PortfolioHistoryResponse {
23
25
  range: PortfolioHistoryRange
24
26
  points: PortfolioHistoryPoint[]
25
- volume?: string
26
- totalPnl?: string
27
+ volume?: DecimalString
28
+ totalPnl?: DecimalString
27
29
  }
package/src/quote.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import type { FeeTier } from './account.js'
2
+ import type { DecimalString } from './decimal.js'
2
3
  import type { FundingInfo } from './market.js'
3
4
 
4
5
  /** Side of the quoted market order, using lowercase wire values. @public */
@@ -26,20 +27,20 @@ export interface Quote {
26
27
  type: TradeType
27
28
  side: QuoteSide
28
29
  /** Input notional in USD. */
29
- sizeUsd: string
30
+ sizeUsd: DecimalString
30
31
  /** Base amount the book filled for `sizeUsd` (or the most obtainable when the book is too thin). */
31
- baseSize: string
32
- markPrice: string
32
+ baseSize: DecimalString
33
+ markPrice: DecimalString
33
34
  /** Volume-weighted average fill price from the book walk. */
34
- expectedFillPrice: string
35
+ expectedFillPrice: DecimalString
35
36
  /** VWAP deviation from `markPrice` in basis points; non-negative. */
36
- priceImpactBps: string
37
+ priceImpactBps: DecimalString
37
38
  /** Base maker/taker fee fractions (not bps) for the public tier. */
38
39
  feeTier: FeeTier
39
40
  /** Always `true` in v1 — quotes use the public base tier, never a per-account tier. */
40
41
  isDefaultFeeTier: boolean
41
42
  /** Taker fee on the filled notional in USD: `filledNotional * feeTier.taker`. */
42
- feeUsd: string
43
+ feeUsd: DecimalString
43
44
  /** Current funding for perps; `null` for spot. */
44
45
  funding: FundingInfo | null
45
46
  /** `true` when the book could not fill the full `sizeUsd` — `baseSize`/fill reflect the best obtainable. */
package/src/referral.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import type { Pagination } from './account.js'
2
+ import type { DecimalString } from './decimal.js'
2
3
  import type { Address } from './primitives.js'
3
4
  import type { PerpsTypedData, TypedDataParameter } from './typedData.js'
4
5
 
@@ -71,9 +72,9 @@ export interface OwnedReferralCodeEligibility {
71
72
  * Executed notional the address must reach, as a decimal string in the
72
73
  * backend's reporting currency. Absent when the backend does not disclose it.
73
74
  */
74
- requiredNotional?: string
75
+ requiredNotional?: DecimalString
75
76
  /** The address's executed notional so far, in the same units as `requiredNotional`. */
76
- currentNotional?: string
77
+ currentNotional?: DecimalString
77
78
  }
78
79
 
79
80
  /**
@@ -125,7 +126,7 @@ export interface ReferralActivityItem {
125
126
  * Executed notional recorded against this attachment, as a decimal string in
126
127
  * the backend's reporting currency.
127
128
  */
128
- notional: string
129
+ notional: DecimalString
129
130
  }
130
131
 
131
132
  /**
@@ -217,8 +218,7 @@ export interface OnboardTypedData extends PerpsTypedData {
217
218
  * @public
218
219
  */
219
220
  export interface CreateReferralCodeParams {
220
- /** Desired code; omit to let the backend generate one. */
221
- code?: string
221
+ code: string
222
222
  }
223
223
 
224
224
  /**
@@ -6,6 +6,7 @@ import type {
6
6
  Order,
7
7
  Position,
8
8
  } from './account.js'
9
+ import type { DecimalString } from './decimal.js'
9
10
  import type {
10
11
  Candle,
11
12
  MarketContext,
@@ -152,7 +153,7 @@ export type PositionsEvent = { channel: 'positions'; data: Position[] }
152
153
  */
153
154
  export type SpotBalancesEvent = {
154
155
  channel: 'spotBalances'
155
- data: (Balance & { locked: string })[]
156
+ data: (Balance & { locked: DecimalString })[]
156
157
  }
157
158
 
158
159
  /**