@lifi/perps-types 0.1.1-alpha.8 → 0.2.0-alpha.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 (206) hide show
  1. package/package.json +18 -4
  2. package/providers/lighter/package.json +5 -0
  3. package/src/_cjs/{market.js → action.js} +1 -1
  4. package/src/_cjs/action.js.map +1 -0
  5. package/src/_cjs/{trading.js → asset.js} +1 -1
  6. package/src/_cjs/asset.js.map +1 -0
  7. package/src/_cjs/enums.js +88 -15
  8. package/src/_cjs/enums.js.map +1 -1
  9. package/src/_cjs/index.js +3 -4
  10. package/src/_cjs/index.js.map +1 -1
  11. package/src/_cjs/providers/_shared/fillClassification.js +37 -0
  12. package/src/_cjs/providers/_shared/fillClassification.js.map +1 -0
  13. package/src/_cjs/providers/hyperliquid/assetId.js +11 -9
  14. package/src/_cjs/providers/hyperliquid/assetId.js.map +1 -1
  15. package/src/_cjs/providers/hyperliquid/mappers/_market.js +15 -0
  16. package/src/_cjs/providers/hyperliquid/mappers/_market.js.map +1 -0
  17. package/src/_cjs/providers/hyperliquid/mappers/activity.js +128 -0
  18. package/src/_cjs/providers/hyperliquid/mappers/activity.js.map +1 -0
  19. package/src/_cjs/providers/hyperliquid/mappers/{market.js → asset.js} +10 -9
  20. package/src/_cjs/providers/hyperliquid/mappers/asset.js.map +1 -0
  21. package/src/_cjs/providers/hyperliquid/mappers/fill.js +36 -0
  22. package/src/_cjs/providers/hyperliquid/mappers/fill.js.map +1 -0
  23. package/src/_cjs/providers/hyperliquid/mappers/index.js +12 -7
  24. package/src/_cjs/providers/hyperliquid/mappers/index.js.map +1 -1
  25. package/src/_cjs/providers/hyperliquid/mappers/order.js +86 -9
  26. package/src/_cjs/providers/hyperliquid/mappers/order.js.map +1 -1
  27. package/src/_cjs/providers/hyperliquid/mappers/position.js +8 -5
  28. package/src/_cjs/providers/hyperliquid/mappers/position.js.map +1 -1
  29. package/src/_cjs/providers/hyperliquid/mappers/shared.js +0 -10
  30. package/src/_cjs/providers/hyperliquid/mappers/shared.js.map +1 -1
  31. package/src/_cjs/providers/hyperliquid/types.js +18 -0
  32. package/src/_cjs/providers/hyperliquid/types.js.map +1 -1
  33. package/src/_cjs/{authorization.js → providers/lighter/apiTypes.js} +1 -1
  34. package/src/_cjs/providers/lighter/apiTypes.js.map +1 -0
  35. package/src/_cjs/providers/lighter/index.js +20 -0
  36. package/src/_cjs/providers/lighter/index.js.map +1 -0
  37. package/src/_cjs/providers/lighter/mappers/fill.js +34 -0
  38. package/src/_cjs/providers/lighter/mappers/fill.js.map +1 -0
  39. package/src/_cjs/providers/lighter/mappers/index.js +13 -0
  40. package/src/_cjs/providers/lighter/mappers/index.js.map +1 -0
  41. package/src/_cjs/providers/lighter/mappers/order.js +142 -0
  42. package/src/_cjs/providers/lighter/mappers/order.js.map +1 -0
  43. package/src/_cjs/providers/lighter/mappers/position.js +35 -0
  44. package/src/_cjs/providers/lighter/mappers/position.js.map +1 -0
  45. package/src/_cjs/providers/lighter/types.js +23 -0
  46. package/src/_cjs/providers/lighter/types.js.map +1 -0
  47. package/src/_cjs/{withdrawal.js → providers.js} +1 -1
  48. package/src/_cjs/providers.js.map +1 -0
  49. package/src/_esm/action.js +2 -0
  50. package/src/_esm/action.js.map +1 -0
  51. package/src/_esm/asset.js +2 -0
  52. package/src/_esm/asset.js.map +1 -0
  53. package/src/_esm/enums.js +97 -14
  54. package/src/_esm/enums.js.map +1 -1
  55. package/src/_esm/index.js +3 -4
  56. package/src/_esm/index.js.map +1 -1
  57. package/src/_esm/providers/_shared/fillClassification.js +43 -0
  58. package/src/_esm/providers/_shared/fillClassification.js.map +1 -0
  59. package/src/_esm/providers/hyperliquid/assetId.js +13 -11
  60. package/src/_esm/providers/hyperliquid/assetId.js.map +1 -1
  61. package/src/_esm/providers/hyperliquid/mappers/_market.js +22 -0
  62. package/src/_esm/providers/hyperliquid/mappers/_market.js.map +1 -0
  63. package/src/_esm/providers/hyperliquid/mappers/activity.js +138 -0
  64. package/src/_esm/providers/hyperliquid/mappers/activity.js.map +1 -0
  65. package/src/_esm/providers/hyperliquid/mappers/{market.js → asset.js} +8 -7
  66. package/src/_esm/providers/hyperliquid/mappers/asset.js.map +1 -0
  67. package/src/_esm/providers/hyperliquid/mappers/fill.js +32 -0
  68. package/src/_esm/providers/hyperliquid/mappers/fill.js.map +1 -0
  69. package/src/_esm/providers/hyperliquid/mappers/index.js +4 -4
  70. package/src/_esm/providers/hyperliquid/mappers/index.js.map +1 -1
  71. package/src/_esm/providers/hyperliquid/mappers/order.js +88 -8
  72. package/src/_esm/providers/hyperliquid/mappers/order.js.map +1 -1
  73. package/src/_esm/providers/hyperliquid/mappers/position.js +8 -5
  74. package/src/_esm/providers/hyperliquid/mappers/position.js.map +1 -1
  75. package/src/_esm/providers/hyperliquid/mappers/shared.js +1 -12
  76. package/src/_esm/providers/hyperliquid/mappers/shared.js.map +1 -1
  77. package/src/_esm/providers/hyperliquid/types.js +32 -2
  78. package/src/_esm/providers/hyperliquid/types.js.map +1 -1
  79. package/src/_esm/providers/lighter/apiTypes.js +5 -0
  80. package/src/_esm/providers/lighter/apiTypes.js.map +1 -0
  81. package/src/_esm/providers/lighter/index.js +4 -0
  82. package/src/_esm/providers/lighter/index.js.map +1 -0
  83. package/src/_esm/providers/lighter/mappers/fill.js +39 -0
  84. package/src/_esm/providers/lighter/mappers/fill.js.map +1 -0
  85. package/src/_esm/providers/lighter/mappers/index.js +4 -0
  86. package/src/_esm/providers/lighter/mappers/index.js.map +1 -0
  87. package/src/_esm/providers/lighter/mappers/order.js +162 -0
  88. package/src/_esm/providers/lighter/mappers/order.js.map +1 -0
  89. package/src/_esm/providers/lighter/mappers/position.js +38 -0
  90. package/src/_esm/providers/lighter/mappers/position.js.map +1 -0
  91. package/src/_esm/providers/lighter/types.js +26 -0
  92. package/src/_esm/providers/lighter/types.js.map +1 -0
  93. package/src/_esm/providers.js +2 -0
  94. package/src/_esm/providers.js.map +1 -0
  95. package/src/_types/account.d.ts +211 -18
  96. package/src/_types/account.d.ts.map +1 -1
  97. package/src/_types/action.d.ts +261 -0
  98. package/src/_types/action.d.ts.map +1 -0
  99. package/src/_types/{market.d.ts → asset.d.ts} +23 -34
  100. package/src/_types/asset.d.ts.map +1 -0
  101. package/src/_types/enums.d.ts +81 -5
  102. package/src/_types/enums.d.ts.map +1 -1
  103. package/src/_types/index.d.ts +3 -4
  104. package/src/_types/index.d.ts.map +1 -1
  105. package/src/_types/providers/_shared/fillClassification.d.ts +12 -0
  106. package/src/_types/providers/_shared/fillClassification.d.ts.map +1 -0
  107. package/src/_types/providers/hyperliquid/assetId.d.ts +8 -6
  108. package/src/_types/providers/hyperliquid/assetId.d.ts.map +1 -1
  109. package/src/_types/providers/hyperliquid/mappers/_market.d.ts +13 -0
  110. package/src/_types/providers/hyperliquid/mappers/_market.d.ts.map +1 -0
  111. package/src/_types/providers/hyperliquid/mappers/activity.d.ts +13 -0
  112. package/src/_types/providers/hyperliquid/mappers/activity.d.ts.map +1 -0
  113. package/src/_types/providers/hyperliquid/mappers/asset.d.ts +4 -0
  114. package/src/_types/providers/hyperliquid/mappers/asset.d.ts.map +1 -0
  115. package/src/_types/providers/hyperliquid/mappers/fill.d.ts +6 -0
  116. package/src/_types/providers/hyperliquid/mappers/fill.d.ts.map +1 -0
  117. package/src/_types/providers/hyperliquid/mappers/index.d.ts +4 -4
  118. package/src/_types/providers/hyperliquid/mappers/index.d.ts.map +1 -1
  119. package/src/_types/providers/hyperliquid/mappers/order.d.ts +15 -3
  120. package/src/_types/providers/hyperliquid/mappers/order.d.ts.map +1 -1
  121. package/src/_types/providers/hyperliquid/mappers/position.d.ts +1 -1
  122. package/src/_types/providers/hyperliquid/mappers/position.d.ts.map +1 -1
  123. package/src/_types/providers/hyperliquid/mappers/shared.d.ts +0 -6
  124. package/src/_types/providers/hyperliquid/mappers/shared.d.ts.map +1 -1
  125. package/src/_types/providers/hyperliquid/types.d.ts +112 -0
  126. package/src/_types/providers/hyperliquid/types.d.ts.map +1 -1
  127. package/src/_types/providers/lighter/apiTypes.d.ts +76 -0
  128. package/src/_types/providers/lighter/apiTypes.d.ts.map +1 -0
  129. package/src/_types/providers/lighter/index.d.ts +4 -0
  130. package/src/_types/providers/lighter/index.d.ts.map +1 -0
  131. package/src/_types/providers/lighter/mappers/fill.d.ts +9 -0
  132. package/src/_types/providers/lighter/mappers/fill.d.ts.map +1 -0
  133. package/src/_types/providers/lighter/mappers/index.d.ts +4 -0
  134. package/src/_types/providers/lighter/mappers/index.d.ts.map +1 -0
  135. package/src/_types/providers/lighter/mappers/order.d.ts +35 -0
  136. package/src/_types/providers/lighter/mappers/order.d.ts.map +1 -0
  137. package/src/_types/providers/lighter/mappers/position.d.ts +8 -0
  138. package/src/_types/providers/lighter/mappers/position.d.ts.map +1 -0
  139. package/src/_types/providers/lighter/types.d.ts +90 -0
  140. package/src/_types/providers/lighter/types.d.ts.map +1 -0
  141. package/src/_types/providers.d.ts +145 -0
  142. package/src/_types/providers.d.ts.map +1 -0
  143. package/src/_types/subscriptions.d.ts +23 -18
  144. package/src/_types/subscriptions.d.ts.map +1 -1
  145. package/src/_types/typedData.d.ts +13 -5
  146. package/src/_types/typedData.d.ts.map +1 -1
  147. package/src/account.ts +244 -18
  148. package/src/action.ts +324 -0
  149. package/src/asset.ts +88 -0
  150. package/src/enums.ts +92 -3
  151. package/src/index.ts +3 -4
  152. package/src/providers/_shared/fillClassification.ts +50 -0
  153. package/src/providers/hyperliquid/assetId.ts +18 -12
  154. package/src/providers/hyperliquid/mappers/_market.ts +21 -0
  155. package/src/providers/hyperliquid/mappers/activity.ts +169 -0
  156. package/src/providers/hyperliquid/mappers/{market.ts → asset.ts} +10 -12
  157. package/src/providers/hyperliquid/mappers/fill.ts +41 -0
  158. package/src/providers/hyperliquid/mappers/index.ts +10 -4
  159. package/src/providers/hyperliquid/mappers/order.ts +95 -14
  160. package/src/providers/hyperliquid/mappers/position.ts +8 -10
  161. package/src/providers/hyperliquid/mappers/shared.ts +0 -15
  162. package/src/providers/hyperliquid/types.ts +158 -0
  163. package/src/providers/lighter/apiTypes.ts +87 -0
  164. package/src/providers/lighter/index.ts +3 -0
  165. package/src/providers/lighter/mappers/fill.ts +57 -0
  166. package/src/providers/lighter/mappers/index.ts +8 -0
  167. package/src/providers/lighter/mappers/order.ts +184 -0
  168. package/src/providers/lighter/mappers/position.ts +46 -0
  169. package/src/providers/lighter/types.ts +111 -0
  170. package/src/providers.ts +153 -0
  171. package/src/subscriptions.ts +21 -20
  172. package/src/typedData.ts +15 -5
  173. package/src/_cjs/authorization.js.map +0 -1
  174. package/src/_cjs/market.js.map +0 -1
  175. package/src/_cjs/providers/hyperliquid/mappers/history.js +0 -22
  176. package/src/_cjs/providers/hyperliquid/mappers/history.js.map +0 -1
  177. package/src/_cjs/providers/hyperliquid/mappers/market.js.map +0 -1
  178. package/src/_cjs/trading.js.map +0 -1
  179. package/src/_cjs/withdrawal.js.map +0 -1
  180. package/src/_esm/authorization.js +0 -2
  181. package/src/_esm/authorization.js.map +0 -1
  182. package/src/_esm/market.js +0 -2
  183. package/src/_esm/market.js.map +0 -1
  184. package/src/_esm/providers/hyperliquid/mappers/history.js +0 -18
  185. package/src/_esm/providers/hyperliquid/mappers/history.js.map +0 -1
  186. package/src/_esm/providers/hyperliquid/mappers/market.js.map +0 -1
  187. package/src/_esm/trading.js +0 -2
  188. package/src/_esm/trading.js.map +0 -1
  189. package/src/_esm/withdrawal.js +0 -2
  190. package/src/_esm/withdrawal.js.map +0 -1
  191. package/src/_types/authorization.d.ts +0 -39
  192. package/src/_types/authorization.d.ts.map +0 -1
  193. package/src/_types/market.d.ts.map +0 -1
  194. package/src/_types/providers/hyperliquid/mappers/history.d.ts +0 -4
  195. package/src/_types/providers/hyperliquid/mappers/history.d.ts.map +0 -1
  196. package/src/_types/providers/hyperliquid/mappers/market.d.ts +0 -4
  197. package/src/_types/providers/hyperliquid/mappers/market.d.ts.map +0 -1
  198. package/src/_types/trading.d.ts +0 -80
  199. package/src/_types/trading.d.ts.map +0 -1
  200. package/src/_types/withdrawal.d.ts +0 -37
  201. package/src/_types/withdrawal.d.ts.map +0 -1
  202. package/src/authorization.ts +0 -46
  203. package/src/market.ts +0 -97
  204. package/src/providers/hyperliquid/mappers/history.ts +0 -25
  205. package/src/trading.ts +0 -97
  206. package/src/withdrawal.ts +0 -44
@@ -1,13 +1,12 @@
1
1
  import type { Address } from './typedData.js';
2
- import type { HistoryItemStatus, MarginMode, OrderSide, OrderType, PositionSide } from './enums.js';
2
+ import type { AssetDisplay } from './asset.js';
3
+ import type { ActionType, ActivityType, FillClassification, FillStatus, LiquidityRole, MarginMode, OrderSide, OrderType, PositionSide } from './enums.js';
3
4
  export interface FeeTier {
4
5
  maker: string;
5
6
  taker: string;
6
7
  }
7
8
  export interface Position {
8
- symbol: string;
9
- assetId: number;
10
- dex: string;
9
+ asset: AssetDisplay;
11
10
  side: PositionSide;
12
11
  size: string;
13
12
  entryPrice: string;
@@ -20,15 +19,14 @@ export interface Position {
20
19
  }
21
20
  export interface OpenOrder {
22
21
  id: string;
23
- symbol: string;
24
- assetId: number;
25
- dex: string;
22
+ asset: AssetDisplay;
26
23
  side: OrderSide;
27
24
  type: OrderType;
28
25
  size: string;
29
26
  price: string;
30
27
  filledSize: string;
31
28
  reduceOnly: boolean;
29
+ label?: string;
32
30
  createdAt: string;
33
31
  }
34
32
  export interface Balance {
@@ -36,29 +34,57 @@ export interface Balance {
36
34
  amount: string;
37
35
  }
38
36
  export interface AccountResponse {
39
- dex: string;
37
+ provider: string;
40
38
  address: Address;
41
- balances: Balance[];
39
+ balances: Record<string, Balance[]>;
42
40
  marginUsed: string;
43
41
  unrealizedPnl: string;
44
42
  feeTier: FeeTier;
43
+ /**
44
+ * Per-provider account state, strongly typed and discriminated on
45
+ * `config.provider`. Consumers narrow with `config.provider === 'hyperliquid'`
46
+ * etc. to get access to the provider-specific fields. There is no untyped
47
+ * escape hatch — fields specific to a future provider belong on a new
48
+ * variant of `AccountConfig`, not on a generic `Record<string, unknown>`.
49
+ */
50
+ config: AccountConfig;
51
+ }
52
+ export interface TriggerOrder {
53
+ id: string;
54
+ asset: AssetDisplay;
55
+ type: OrderType;
56
+ size: string;
57
+ triggerPrice: string;
58
+ limitPrice?: string;
59
+ label?: string;
60
+ createdAt: string;
61
+ }
62
+ export interface PositionsResponse {
63
+ provider: string;
45
64
  positions: Position[];
65
+ pagination: Pagination;
66
+ }
67
+ export interface OrdersResponse {
68
+ provider: string;
46
69
  openOrders: OpenOrder[];
47
- config: Record<string, unknown>;
70
+ triggerOrders: TriggerOrder[];
71
+ pagination: Pagination;
48
72
  }
49
- export interface HistoryItem {
73
+ export interface Fill {
50
74
  id: string;
51
- symbol: string;
52
- assetId: number;
53
- dex: string;
75
+ orderId: string;
76
+ asset: AssetDisplay;
54
77
  side: OrderSide;
55
78
  type: OrderType;
56
79
  size: string;
57
80
  price: string;
58
- status: HistoryItemStatus;
81
+ status: FillStatus;
82
+ liquidity: LiquidityRole;
59
83
  filledSize?: string;
60
84
  fee?: string;
61
85
  realizedPnl?: string | null;
86
+ startPosition?: string;
87
+ classification: FillClassification;
62
88
  createdAt: string;
63
89
  }
64
90
  export interface Pagination {
@@ -67,9 +93,176 @@ export interface Pagination {
67
93
  cursor?: string;
68
94
  nextUrl?: string;
69
95
  }
70
- export interface HistoryResponse {
71
- dex: string;
72
- items: HistoryItem[];
96
+ export interface FillsResponse {
97
+ provider: string;
98
+ items: Fill[];
99
+ pagination: Pagination;
100
+ }
101
+ export interface BaseActivity {
102
+ id: string;
103
+ provider: string;
104
+ timestamp: string;
105
+ }
106
+ export interface DepositActivity extends BaseActivity {
107
+ type: ActivityType.DEPOSIT;
108
+ amount: string;
109
+ }
110
+ export interface WithdrawalActivity extends BaseActivity {
111
+ type: ActivityType.WITHDRAWAL;
112
+ amount: string;
113
+ fee: string;
114
+ }
115
+ export interface LiquidatedPosition {
116
+ asset: AssetDisplay;
117
+ size: string;
118
+ }
119
+ export interface LiquidationActivity extends BaseActivity {
120
+ type: ActivityType.LIQUIDATION;
121
+ liquidatedNotionalPosition: string;
122
+ accountValue: string;
123
+ leverageType: string;
124
+ liquidatedPositions: LiquidatedPosition[];
125
+ }
126
+ export interface FundingActivity extends BaseActivity {
127
+ type: ActivityType.FUNDING;
128
+ asset: AssetDisplay;
129
+ amount: string;
130
+ positionSize: string;
131
+ fundingRate: string;
132
+ }
133
+ /**
134
+ * Internal transfer between two accounts on the same provider (e.g. Lighter
135
+ * `/api/v1/transfer/history`, Hyperliquid `spotTransfer` ledger entry).
136
+ * Direction is relative to the queried account.
137
+ *
138
+ * The counterparty is identified by either an account index (integer L2
139
+ * account identifier — Lighter) or a wallet address (Hyperliquid, where
140
+ * accounts ARE addresses). The type is a discriminated union over these two
141
+ * shapes: at least one of `counterpartyAccountIndex` / `counterpartyAddress`
142
+ * MUST be present, and either may appear alone or alongside the other.
143
+ *
144
+ * Consumers that render counterparties should prefer `counterpartyAccountIndex`
145
+ * when present (it's the canonical handle on index-based providers) and fall
146
+ * back to a truncated `counterpartyAddress` otherwise.
147
+ */
148
+ export type TransferActivity = BaseActivity & {
149
+ type: ActivityType.TRANSFER;
150
+ direction: 'IN' | 'OUT';
151
+ asset: string;
152
+ amount: string;
153
+ meta?: Record<string, unknown>;
154
+ } & ({
155
+ counterpartyAccountIndex: number;
156
+ counterpartyAddress?: string;
157
+ } | {
158
+ counterpartyAccountIndex?: number;
159
+ counterpartyAddress: string;
160
+ });
161
+ export type ActivityItem = DepositActivity | WithdrawalActivity | LiquidationActivity | FundingActivity | TransferActivity;
162
+ export interface ActivitiesResponse {
163
+ provider: string;
164
+ items: ActivityItem[];
73
165
  pagination: Pagination;
74
166
  }
167
+ /**
168
+ * Hyperliquid record describing one authorised agent wallet on the
169
+ * `userExtraAgents` response. Shape mirrors what the Hyperliquid info API
170
+ * returns; the backend forwards the entries verbatim. The widget renders the
171
+ * count / expiry on the `APPROVE_AGENT` setup descriptor.
172
+ */
173
+ export type HyperliquidAgent = Record<string, unknown>;
174
+ /**
175
+ * Hyperliquid builder-fee approval state. Surfaced by the backend after
176
+ * comparing the user's `maxBuilderFee` against the configured LI.FI builder
177
+ * fee for this dex. The widget uses `approved: false` to badge
178
+ * `APPROVE_BUILDER_FEE` as outstanding.
179
+ */
180
+ export interface HyperliquidBuilderFeeApproval {
181
+ builderAddress: string;
182
+ /** Maximum fee rate the user must approve, in basis points as a string. */
183
+ maxFeeRate: string;
184
+ approved: boolean;
185
+ }
186
+ /**
187
+ * Hyperliquid-specific account configuration state.
188
+ *
189
+ * `abstractionMode: null` means abstraction has never been set; consumers
190
+ * should fall back to the descriptor's `default` `ParamOption`.
191
+ *
192
+ * `builderFeeApproval` is absent when no builder is configured for this
193
+ * provider; when present, `approved` reports whether the user has signed the
194
+ * maximum builder fee.
195
+ */
196
+ export interface HyperliquidAccountConfig {
197
+ provider: 'hyperliquid';
198
+ abstractionMode: string | null;
199
+ agents: HyperliquidAgent[];
200
+ builderFeeApproval?: HyperliquidBuilderFeeApproval;
201
+ }
202
+ /**
203
+ * Lighter-specific account configuration state.
204
+ *
205
+ * `accountIndex` is the L2 integer account identifier.
206
+ *
207
+ * `apiKeyRegistered` reports whether a key is currently live in the
208
+ * `apiKeyIndex` slot; the `REGISTER_API_KEY` setup descriptor gates trading
209
+ * on this.
210
+ *
211
+ * `accountType` is the raw integer fee/latency tier from Lighter's
212
+ * `/api/v1/account.account_type` — decoding to a human label is left to the
213
+ * consumer.
214
+ *
215
+ * `readOnlyTokenApproved` mirrors `apiKeyRegistered`'s shape but for the
216
+ * long-lived read-only token. When `true`, `readOnlyTokenExpiry` and
217
+ * `readOnlyTokenScope` MUST be present; when `false`, both MUST be absent.
218
+ * The `APPROVE_READ_ONLY_TOKEN` setup descriptor gates query-only access on
219
+ * this flag.
220
+ */
221
+ export interface LighterAccountConfig {
222
+ provider: 'lighter';
223
+ accountIndex: number;
224
+ apiKeyIndex: number;
225
+ apiKeyRegistered: boolean;
226
+ accountType: number;
227
+ readOnlyTokenApproved: boolean;
228
+ /** Unix seconds. Present iff `readOnlyTokenApproved === true`. */
229
+ readOnlyTokenExpiry?: number;
230
+ /** Lighter's documented `single | all` scope. Present iff `readOnlyTokenApproved === true`. */
231
+ readOnlyTokenScope?: 'single' | 'all';
232
+ }
233
+ /**
234
+ * Discriminated union of per-provider account configuration state.
235
+ * Narrow with `config.provider === '<key>'` to access provider-specific
236
+ * fields. Adding a new provider means adding a new variant, NOT widening
237
+ * to a record-keyed shape.
238
+ */
239
+ export type AccountConfig = HyperliquidAccountConfig | LighterAccountConfig;
240
+ /**
241
+ * The current value of a single descriptor parameter, as projected by the
242
+ * SDK from the typed `AccountConfig` for widget consumption.
243
+ *
244
+ * `name` matches `Param.name` on the descriptor that produced it; `value`
245
+ * is the current state in the primitive shape the descriptor declared.
246
+ * `null` indicates "no current value" (the user has not made a selection
247
+ * yet, or the provider has not surfaced one), and the widget should fall
248
+ * back to the descriptor's `default` `ParamOption` (when present) or
249
+ * render the control with no highlight.
250
+ */
251
+ export interface AccountConfigValue {
252
+ name: string;
253
+ value: string | number | boolean | null;
254
+ }
255
+ /**
256
+ * SDK projection of `AccountConfig` against a single descriptor — one
257
+ * `AccountConfigSetting` per descriptor on `Provider.setup` /
258
+ * `Provider.options`. `values` carries the current state for each `Param`
259
+ * the descriptor declared.
260
+ *
261
+ * Consumers must NOT read `AccountConfig` directly — narrow through this
262
+ * projection so a new provider variant doesn't require widget changes.
263
+ */
264
+ export interface AccountConfigSetting {
265
+ type: ActionType;
266
+ values: AccountConfigValue[];
267
+ }
75
268
  //# sourceMappingURL=account.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"account.d.ts","sourceRoot":"","sources":["../account.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAC7C,OAAO,KAAK,EACV,iBAAiB,EACjB,UAAU,EACV,SAAS,EACT,SAAS,EACT,YAAY,EACb,MAAM,YAAY,CAAA;AAEnB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E,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAA;CACxC;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,UAAU,CAAA;IAChB,MAAM,EAAE,kBAAkB,EAAE,CAAA;CAC7B"}
@@ -0,0 +1,261 @@
1
+ import type { MarginMode, OrderType } from './enums.js';
2
+ import { type ActionType, type OrderSide, type OrderStatus, type TimeInForce, type TriggerCondition } from './enums.js';
3
+ import type { Address, Hex, PerpsTypedData } from './typedData.js';
4
+ import type { AssetIdentity, AssetDisplay } from './asset.js';
5
+ export interface Eip712ActionStep {
6
+ action: ActionType;
7
+ typedData: PerpsTypedData;
8
+ }
9
+ export interface WasmBlobActionStep {
10
+ action: ActionType;
11
+ wasmSignParams: Record<string, unknown>;
12
+ }
13
+ export interface EvmTxActionStep {
14
+ action: ActionType;
15
+ txParams: Record<string, unknown>;
16
+ }
17
+ export type ActionStep = Eip712ActionStep | WasmBlobActionStep | EvmTxActionStep;
18
+ export interface Eip712SignedActionStep {
19
+ action: ActionType;
20
+ typedData: PerpsTypedData;
21
+ signature: Hex;
22
+ }
23
+ export interface WasmBlobSignedActionStep {
24
+ action: ActionType;
25
+ wasmSignParams: Record<string, unknown>;
26
+ signedTx: {
27
+ txType: number;
28
+ txInfo: string;
29
+ txHash: string;
30
+ };
31
+ }
32
+ export interface EvmTxSignedActionStep {
33
+ action: ActionType;
34
+ txParams: Record<string, unknown>;
35
+ txHash: string;
36
+ }
37
+ export type SignedActionStep = Eip712SignedActionStep | WasmBlobSignedActionStep | EvmTxSignedActionStep;
38
+ export type ActionResult = {
39
+ action: ActionType;
40
+ success: true;
41
+ orderId?: string;
42
+ } | {
43
+ action: ActionType;
44
+ success: false;
45
+ error: string;
46
+ };
47
+ export interface TriggerOrderInput {
48
+ triggerPrice: string;
49
+ limitPrice?: string;
50
+ }
51
+ export interface ModifyOrderInput {
52
+ id: string;
53
+ price?: string;
54
+ size?: string;
55
+ triggerPrice?: string;
56
+ limitPrice?: string;
57
+ }
58
+ export interface Order {
59
+ orderId: string;
60
+ asset: AssetDisplay;
61
+ side: OrderSide;
62
+ type: OrderType;
63
+ price?: string;
64
+ originalSize: string;
65
+ remainingSize: string;
66
+ filledSize: string;
67
+ timeInForce?: TimeInForce;
68
+ expiresAt?: string;
69
+ reduceOnly?: boolean;
70
+ isTrigger?: boolean;
71
+ triggerPrice?: string;
72
+ triggerCondition?: TriggerCondition;
73
+ status: OrderStatus;
74
+ /**
75
+ * Human-readable English sentence describing *why* the order ended in a
76
+ * terminal non-FILLED state (e.g. slippage exceeded, reduce-only would
77
+ * not reduce, expiry). Populated only when the provider exposes a
78
+ * specific cancellation/rejection reason; `undefined` for non-terminal
79
+ * statuses, plain `filled`, and bare cancels/rejects with no actionable
80
+ * detail.
81
+ */
82
+ statusReason?: string;
83
+ averagePrice?: string;
84
+ createdAt: string;
85
+ updatedAt: string;
86
+ }
87
+ export interface PlaceOrderParams {
88
+ asset: AssetIdentity;
89
+ side: OrderSide;
90
+ type?: OrderType;
91
+ size: string;
92
+ price?: string;
93
+ leverage?: number;
94
+ /**
95
+ * Margin mode to use for the position. When omitted, the backend falls back
96
+ * to the provider's default (currently CROSS for both Hyperliquid and
97
+ * Lighter). Callers should set this explicitly when they need ISOLATED.
98
+ */
99
+ marginMode?: MarginMode;
100
+ reduceOnly?: boolean;
101
+ timeInForce?: TimeInForce;
102
+ expiresAt?: string;
103
+ takeProfit?: TriggerOrderInput;
104
+ stopLoss?: TriggerOrderInput;
105
+ }
106
+ export interface PlaceTriggerOrderParams {
107
+ asset: AssetIdentity;
108
+ side: OrderSide;
109
+ takeProfit?: TriggerOrderInput;
110
+ stopLoss?: TriggerOrderInput;
111
+ }
112
+ export interface CancelOrderParams {
113
+ ids: string[];
114
+ }
115
+ export interface ModifyOrderParams {
116
+ modifications: ModifyOrderInput[];
117
+ }
118
+ export interface UpdateLeverageParams {
119
+ asset: AssetIdentity;
120
+ leverage: number;
121
+ /**
122
+ * Margin mode to use for the position. When omitted, the backend falls back
123
+ * to the provider's default (currently CROSS for both Hyperliquid and
124
+ * Lighter). Callers should set this explicitly when they need ISOLATED.
125
+ */
126
+ marginMode?: MarginMode;
127
+ }
128
+ export interface UpdatePositionMarginParams {
129
+ asset: AssetIdentity;
130
+ action: 'add' | 'remove';
131
+ amount: string;
132
+ }
133
+ export interface WithdrawalParams {
134
+ destination: Address;
135
+ amount: string;
136
+ }
137
+ export interface DepositParams {
138
+ /** Amount of the token to deposit (human-readable, e.g. "100.5"). */
139
+ amount: string;
140
+ /** ERC-20 token address on the source chain. */
141
+ tokenAddress: Address;
142
+ /** Chain ID of the source chain (e.g. 1 for Ethereum, 42161 for Arbitrum). */
143
+ chainId: number;
144
+ }
145
+ export interface ApproveAgentParams {
146
+ agentAddress: string;
147
+ agentTtlMs?: number;
148
+ }
149
+ /**
150
+ * Params for `ActionType.ACCOUNT_MODE` — switch the account's operating
151
+ * mode (e.g. HL abstraction variant, Lighter UTA / Simple). The string
152
+ * is opaque per-provider; the authoritative enumeration of valid values
153
+ * lives on the descriptor's `Param.values` array (see
154
+ * `ProviderActionDescriptor` in `providers.ts`). The SDK and backend are
155
+ * responsible for validating `mode` against that array — `@lifi/perps-types`
156
+ * intentionally does not encode the per-provider value list here, so a
157
+ * provider can add a new mode without a types release.
158
+ */
159
+ export interface AccountModeParams {
160
+ mode: string;
161
+ }
162
+ /**
163
+ * Params for `ActionType.ACCOUNT_TYPE` — switch the account's fee/latency
164
+ * tier (e.g. Lighter standard / premium). Providers without tiering omit
165
+ * the action entirely; the descriptor's `Param.values` array enumerates
166
+ * the valid tiers for providers that do support it.
167
+ */
168
+ export interface AccountTypeParams {
169
+ tier: string;
170
+ }
171
+ export interface SendAssetParams {
172
+ collateral: string;
173
+ sourceDex: string;
174
+ destinationDex: string;
175
+ amount: string;
176
+ }
177
+ export interface CancelAllOrdersParams {
178
+ /** 0=immediate (cancel GTC), 1=scheduled, 2=abort scheduled */
179
+ timeInForce: number;
180
+ /** Unix timestamp in milliseconds (required for scheduled cancels) */
181
+ timestampMs?: number;
182
+ }
183
+ export interface RegisterApiKeyParams {
184
+ /** The API key slot index to register (0-255). Reusing a fixed slot overwrites the old key. */
185
+ apiKeyIndex: number;
186
+ }
187
+ /**
188
+ * Params for `ActionType.APPROVE_READ_ONLY_TOKEN` — mint a long-lived
189
+ * read-only token Lighter recognises for query-only access (positions,
190
+ * fills, balances). The token format on the wire is
191
+ * `ro:{accountIndex}:{scope}:{expiry}:{rand}`; this type carries only the
192
+ * inputs needed to construct that token, not the token itself.
193
+ *
194
+ * `expirySeconds` is the absolute unix-seconds expiry. Lighter constrains
195
+ * the lifetime to a minimum of 1 day and a maximum of 10 years from now;
196
+ * the SDK and backend are responsible for enforcing those bounds.
197
+ *
198
+ * `scope` mirrors Lighter's documented `single | all` literal:
199
+ * - `'single'` — token authorises read access to one account only.
200
+ * - `'all'` — token authorises read access to every account owned by the
201
+ * signer. Default for the perps stack today.
202
+ */
203
+ export interface ApproveReadOnlyTokenParams {
204
+ accountIndex: number;
205
+ expirySeconds: number;
206
+ scope: 'single' | 'all';
207
+ }
208
+ export interface ActionParamsMap {
209
+ [ActionType.APPROVE_AGENT]: ApproveAgentParams;
210
+ [ActionType.APPROVE_BUILDER_FEE]: Record<string, never>;
211
+ [ActionType.ACCOUNT_MODE]: AccountModeParams;
212
+ [ActionType.ACCOUNT_TYPE]: AccountTypeParams;
213
+ [ActionType.SEND_ASSET]: SendAssetParams;
214
+ [ActionType.WITHDRAWAL]: WithdrawalParams;
215
+ [ActionType.TRANSFER]: Record<string, never>;
216
+ [ActionType.PLACE_ORDER]: PlaceOrderParams;
217
+ [ActionType.PLACE_TRIGGER_ORDER]: PlaceTriggerOrderParams;
218
+ [ActionType.CANCEL_ORDER]: CancelOrderParams;
219
+ [ActionType.CANCEL_ALL_ORDERS]: CancelAllOrdersParams;
220
+ [ActionType.MODIFY_ORDER]: ModifyOrderParams;
221
+ [ActionType.UPDATE_LEVERAGE]: UpdateLeverageParams;
222
+ [ActionType.UPDATE_POSITION_MARGIN]: UpdatePositionMarginParams;
223
+ [ActionType.REGISTER_API_KEY]: RegisterApiKeyParams;
224
+ [ActionType.APPROVE_READ_ONLY_TOKEN]: ApproveReadOnlyTokenParams;
225
+ [ActionType.DEPOSIT]: DepositParams;
226
+ }
227
+ /**
228
+ * Distributed discriminated request shape: selecting an `action` literal
229
+ * narrows `params` to exactly the matching entry in `ActionParamsMap`.
230
+ * Mapped over `ActionType` so a new action automatically yields a new branch.
231
+ */
232
+ export type CreateActionRequest = {
233
+ [K in ActionType]: {
234
+ provider: string;
235
+ address: Address;
236
+ signerAddress?: Address;
237
+ action: K;
238
+ params: ActionParamsMap[K];
239
+ };
240
+ }[ActionType];
241
+ export interface CreateActionResponse {
242
+ actions: ActionStep[];
243
+ }
244
+ /**
245
+ * Distributed discriminated execute-request shape: narrowing on `action`
246
+ * pins the action kind to a single `ActionType`; `actions` is the
247
+ * already-discriminated `SignedActionStep[]` union above.
248
+ */
249
+ export type ExecuteActionRequest = {
250
+ [K in ActionType]: {
251
+ provider: string;
252
+ address: Address;
253
+ signerAddress?: Address;
254
+ action: K;
255
+ actions: SignedActionStep[];
256
+ };
257
+ }[ActionType];
258
+ export interface ExecuteActionResponse {
259
+ results: ActionResult[];
260
+ }
261
+ //# sourceMappingURL=action.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"action.d.ts","sourceRoot":"","sources":["../action.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AACvD,OAAO,EACL,KAAK,UAAU,EACf,KAAK,SAAS,EACd,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,gBAAgB,EACtB,MAAM,YAAY,CAAA;AACnB,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAClE,OAAO,K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: 'string' | 'number' | 'boolean';
4
- required: boolean;
5
- }
6
- export interface Authorization {
7
- key: string;
8
- name: string;
9
- params?: AuthorizationParam[];
10
- }
11
- export interface Dex {
12
- key: string;
13
- name: string;
14
- logoURI: string;
15
- authorizations: Authorization[];
16
- extraData?: Record<string, unknown>;
17
- wsUrl?: string;
18
- }
19
- export interface DexesResponse {
20
- dexes: Dex[];
21
- }
22
1
  export interface FundingInfo {
23
2
  rate: string;
24
3
  nextFundingTime: number;
25
4
  }
26
- export interface Market {
27
- symbol: string;
28
- name: string;
5
+ export interface AssetIdentity {
6
+ assetId: string;
7
+ market: string;
8
+ }
9
+ export interface Asset extends AssetIdentity {
10
+ displaySymbol: string;
11
+ displayQuote: string | null;
12
+ displayName?: string;
29
13
  logoURI: string;
30
- assetId: number;
31
- dex: string;
32
14
  szDecimals: number;
33
15
  maxLeverage: number;
34
16
  onlyIsolated: boolean;
17
+ isMarginCollateral?: boolean;
35
18
  funding: FundingInfo;
36
19
  openInterest?: string;
37
20
  volume24h?: string;
21
+ prevDayPrice?: string;
38
22
  markPrice: string;
39
23
  }
40
- export interface MarketsResponse {
41
- markets: Market[];
24
+ export type AssetDisplay = Pick<Asset, 'assetId' | 'market' | 'displaySymbol' | 'displayQuote'>;
25
+ export interface AssetPrice {
26
+ assetId: string;
27
+ price: string;
28
+ }
29
+ export interface AssetsResponse {
30
+ assets: Asset[];
42
31
  }
43
32
  export interface PricesResponse {
44
- prices: Record<string, string>;
33
+ prices: AssetPrice[];
45
34
  }
46
35
  export interface Candle {
47
36
  t: number;
@@ -52,8 +41,8 @@ export interface Candle {
52
41
  v: string;
53
42
  }
54
43
  export interface OhlcvResponse {
55
- dex: string;
56
- symbol: string;
44
+ provider: string;
45
+ assetId: string;
57
46
  interval: string;
58
47
  candles: Candle[];
59
48
  }
@@ -63,10 +52,10 @@ export interface OrderbookLevel {
63
52
  size: string;
64
53
  }
65
54
  export interface OrderbookResponse {
66
- dex: string;
67
- symbol: string;
55
+ provider: string;
56
+ assetId: string;
68
57
  bids: OrderbookLevel[];
69
58
  asks: OrderbookLevel[];
70
59
  timestamp: number;
71
60
  }
72
- //# sourceMappingURL=market.d.ts.map
61
+ //# sourceMappingURL=asset.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asset.d.ts","sourceRoot":"","sources":["../asset.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,eAAe,EAAE,MAAM,CAAA;CACxB;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,KAAM,SAAQ,aAAa;IAC1C,aAAa,EAAE,MAAM,CAAA;IACrB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,OAAO,EAAE,MAAM,CAAA;IACf,UAAU,EAAE,MAAM,CAAA;IAClB,WAAW,EAAE,MAAM,CAAA;IACnB,YAAY,EAAE,OAAO,CAAA;IACrB,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B,OAAO,EAAE,WAAW,CAAA;IACpB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,MAAM,YAAY,GAAG,IAAI,CAC7B,KAAK,EACL,SAAS,GAAG,QAAQ,GAAG,eAAe,GAAG,cAAc,CACxD,CAAA;AAED,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,EAAE,MAAM,CAAA;CACd;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,KAAK,EAAE,CAAA;CAChB;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,UAAU,EAAE,CAAA;CACrB;AAED,MAAM,WAAW,MAAM;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