@lifi/perps-types 0.1.1-alpha.3 → 0.1.1-alpha.4
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/package.json +8 -2
- package/src/_cjs/providers/hyperliquid/types.js +0 -178
- package/src/_cjs/providers/hyperliquid/types.js.map +1 -1
- package/src/_esm/providers/hyperliquid/types.js +2 -200
- package/src/_esm/providers/hyperliquid/types.js.map +1 -1
- package/src/_types/providers/hyperliquid/types.d.ts +175 -338
- package/src/_types/providers/hyperliquid/types.d.ts.map +1 -1
- package/src/providers/hyperliquid/types.ts +175 -244
|
@@ -1,290 +1,221 @@
|
|
|
1
|
-
import { Type, type Static } from '@sinclair/typebox'
|
|
2
|
-
|
|
3
1
|
// ---------------------------------------------------------------------------
|
|
4
|
-
// Hyperliquid /info response
|
|
5
|
-
//
|
|
6
|
-
// Each schema produces both a JSON Schema object (for AJV validation) and a
|
|
7
|
-
// TypeScript type via Static<>. The derived types are structurally identical
|
|
8
|
-
// to the hand-written ones they replace.
|
|
9
|
-
//
|
|
10
|
-
// All schemas use additionalProperties: true (TypeBox default) so that new
|
|
11
|
-
// fields added by Hyperliquid pass through without breaking validation.
|
|
2
|
+
// Hyperliquid /info response types
|
|
12
3
|
// ---------------------------------------------------------------------------
|
|
13
4
|
|
|
14
5
|
// -- metaAndAssetCtxs -------------------------------------------------------
|
|
15
6
|
|
|
16
|
-
export
|
|
17
|
-
name:
|
|
18
|
-
szDecimals:
|
|
19
|
-
maxLeverage:
|
|
20
|
-
onlyIsolated:
|
|
21
|
-
isDelisted:
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
export type
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
export type HlAssetCtx = Static<typeof HlAssetCtxSchema>
|
|
37
|
-
|
|
38
|
-
export const HlMetaAndAssetCtxsSchema = Type.Tuple([
|
|
39
|
-
HlMetaSchema,
|
|
40
|
-
Type.Array(HlAssetCtxSchema),
|
|
41
|
-
])
|
|
42
|
-
export type HlMetaAndAssetCtxs = Static<typeof HlMetaAndAssetCtxsSchema>
|
|
7
|
+
export type HlUniverseItem = {
|
|
8
|
+
name: string
|
|
9
|
+
szDecimals: number
|
|
10
|
+
maxLeverage: number
|
|
11
|
+
onlyIsolated: boolean
|
|
12
|
+
isDelisted: boolean
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export type HlMeta = {
|
|
16
|
+
universe: HlUniverseItem[]
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export type HlAssetCtx = {
|
|
20
|
+
funding: string
|
|
21
|
+
openInterest: string
|
|
22
|
+
dayNtlVlm: string
|
|
23
|
+
markPx: string
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export type HlMetaAndAssetCtxs = [HlMeta, HlAssetCtx[]]
|
|
43
27
|
|
|
44
28
|
export type HlUniverse = HlMeta['universe']
|
|
45
29
|
|
|
46
30
|
// -- allMids ----------------------------------------------------------------
|
|
47
31
|
|
|
48
|
-
export
|
|
49
|
-
export type HlAllMids = Static<typeof HlAllMidsSchema>
|
|
32
|
+
export type HlAllMids = Record<string, string>
|
|
50
33
|
|
|
51
34
|
// -- candleSnapshot ---------------------------------------------------------
|
|
52
35
|
|
|
53
|
-
export
|
|
54
|
-
t:
|
|
55
|
-
o:
|
|
56
|
-
h:
|
|
57
|
-
l:
|
|
58
|
-
c:
|
|
59
|
-
v:
|
|
60
|
-
}
|
|
61
|
-
export type HlCandle = Static<typeof HlCandleSchema>
|
|
36
|
+
export type HlCandle = {
|
|
37
|
+
t: number
|
|
38
|
+
o: string
|
|
39
|
+
h: string
|
|
40
|
+
l: string
|
|
41
|
+
c: string
|
|
42
|
+
v: string
|
|
43
|
+
}
|
|
62
44
|
|
|
63
|
-
export
|
|
64
|
-
export type HlCandleSnapshot = Static<typeof HlCandleSnapshotSchema>
|
|
45
|
+
export type HlCandleSnapshot = HlCandle[]
|
|
65
46
|
|
|
66
47
|
// -- l2Book -----------------------------------------------------------------
|
|
67
48
|
|
|
68
|
-
export
|
|
69
|
-
px:
|
|
70
|
-
sz:
|
|
71
|
-
n:
|
|
72
|
-
}
|
|
73
|
-
export type HlLevel = Static<typeof HlLevelSchema>
|
|
49
|
+
export type HlLevel = {
|
|
50
|
+
px: string
|
|
51
|
+
sz: string
|
|
52
|
+
n: number
|
|
53
|
+
}
|
|
74
54
|
|
|
75
|
-
export
|
|
76
|
-
levels:
|
|
77
|
-
time:
|
|
78
|
-
}
|
|
79
|
-
export type HlL2Book = Static<typeof HlL2BookSchema>
|
|
55
|
+
export type HlL2Book = {
|
|
56
|
+
levels: [HlLevel[], HlLevel[]]
|
|
57
|
+
time: number
|
|
58
|
+
}
|
|
80
59
|
|
|
81
60
|
// -- clearinghouseState -----------------------------------------------------
|
|
82
61
|
|
|
83
|
-
export
|
|
84
|
-
coin:
|
|
85
|
-
szi:
|
|
86
|
-
entryPx:
|
|
87
|
-
positionValue:
|
|
88
|
-
liquidationPx:
|
|
89
|
-
unrealizedPnl:
|
|
90
|
-
marginUsed:
|
|
91
|
-
leverage:
|
|
92
|
-
type:
|
|
93
|
-
value:
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
export type
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
}),
|
|
113
|
-
})
|
|
114
|
-
export type HlClearinghouseState = Static<typeof HlClearinghouseStateSchema>
|
|
62
|
+
export type HlPosition = {
|
|
63
|
+
coin: string
|
|
64
|
+
szi: string
|
|
65
|
+
entryPx: string
|
|
66
|
+
positionValue: string
|
|
67
|
+
liquidationPx: string
|
|
68
|
+
unrealizedPnl: string
|
|
69
|
+
marginUsed: string
|
|
70
|
+
leverage: {
|
|
71
|
+
type: string
|
|
72
|
+
value: number
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export type HlAssetPosition = {
|
|
77
|
+
position: HlPosition
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export type HlClearinghouseState = {
|
|
81
|
+
assetPositions: HlAssetPosition[]
|
|
82
|
+
marginSummary: {
|
|
83
|
+
accountValue: string
|
|
84
|
+
totalMarginUsed: string
|
|
85
|
+
}
|
|
86
|
+
crossMarginSummary: {
|
|
87
|
+
accountValue: string
|
|
88
|
+
totalMarginUsed: string
|
|
89
|
+
}
|
|
90
|
+
}
|
|
115
91
|
|
|
116
92
|
// -- spotClearinghouseState -------------------------------------------------
|
|
117
93
|
|
|
118
|
-
export
|
|
119
|
-
coin:
|
|
120
|
-
token:
|
|
121
|
-
total:
|
|
122
|
-
hold:
|
|
123
|
-
entryNtl:
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
})
|
|
130
|
-
export type HlSpotClearinghouseState = Static<
|
|
131
|
-
typeof HlSpotClearinghouseStateSchema
|
|
132
|
-
>
|
|
94
|
+
export type HlSpotBalance = {
|
|
95
|
+
coin: string
|
|
96
|
+
token: number
|
|
97
|
+
total: string
|
|
98
|
+
hold: string
|
|
99
|
+
entryNtl: string
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export type HlSpotClearinghouseState = {
|
|
103
|
+
balances: HlSpotBalance[]
|
|
104
|
+
}
|
|
133
105
|
|
|
134
106
|
// -- userFees ---------------------------------------------------------------
|
|
135
107
|
|
|
136
|
-
export
|
|
137
|
-
userAddRate:
|
|
138
|
-
userCrossRate:
|
|
139
|
-
activeReferralDiscount:
|
|
140
|
-
}
|
|
141
|
-
export type HlUserFees = Static<typeof HlUserFeesSchema>
|
|
108
|
+
export type HlUserFees = {
|
|
109
|
+
userAddRate: string
|
|
110
|
+
userCrossRate: string
|
|
111
|
+
activeReferralDiscount: string
|
|
112
|
+
}
|
|
142
113
|
|
|
143
114
|
// -- frontendOpenOrders -----------------------------------------------------
|
|
144
115
|
|
|
145
|
-
export
|
|
146
|
-
oid:
|
|
147
|
-
coin:
|
|
148
|
-
side:
|
|
149
|
-
sz:
|
|
150
|
-
limitPx:
|
|
151
|
-
orderType:
|
|
152
|
-
origSz:
|
|
153
|
-
reduceOnly:
|
|
154
|
-
timestamp:
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
export const HlFrontendOpenOrdersSchema = Type.Array(
|
|
159
|
-
HlFrontendOpenOrderSchema
|
|
160
|
-
)
|
|
161
|
-
export type HlFrontendOpenOrders = Static<typeof HlFrontendOpenOrdersSchema>
|
|
116
|
+
export type HlFrontendOpenOrder = {
|
|
117
|
+
oid: number
|
|
118
|
+
coin: string
|
|
119
|
+
side: string
|
|
120
|
+
sz: string
|
|
121
|
+
limitPx: string
|
|
122
|
+
orderType: string
|
|
123
|
+
origSz: string
|
|
124
|
+
reduceOnly: boolean
|
|
125
|
+
timestamp: number
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export type HlFrontendOpenOrders = HlFrontendOpenOrder[]
|
|
162
129
|
|
|
163
130
|
// -- extraAgents ------------------------------------------------------------
|
|
164
131
|
|
|
165
|
-
export
|
|
166
|
-
Type.Record(Type.String(), Type.Unknown())
|
|
167
|
-
)
|
|
168
|
-
export type HlExtraAgents = Static<typeof HlExtraAgentsSchema>
|
|
132
|
+
export type HlExtraAgents = Record<string, unknown>[]
|
|
169
133
|
|
|
170
134
|
// -- userFills / userFillsByTime --------------------------------------------
|
|
171
135
|
|
|
172
|
-
export
|
|
173
|
-
tid:
|
|
174
|
-
coin:
|
|
175
|
-
side:
|
|
176
|
-
sz:
|
|
177
|
-
px:
|
|
178
|
-
dir:
|
|
179
|
-
fee:
|
|
180
|
-
closedPnl:
|
|
181
|
-
time:
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
export type
|
|
187
|
-
|
|
188
|
-
export const HlUserFillsByTimeSchema = Type.Array(HlUserFillSchema)
|
|
189
|
-
export type HlUserFillsByTime = Static<typeof HlUserFillsByTimeSchema>
|
|
136
|
+
export type HlUserFill = {
|
|
137
|
+
tid: number
|
|
138
|
+
coin: string
|
|
139
|
+
side: string
|
|
140
|
+
sz: string
|
|
141
|
+
px: string
|
|
142
|
+
dir: string
|
|
143
|
+
fee: string
|
|
144
|
+
closedPnl: string
|
|
145
|
+
time: number
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export type HlUserFills = HlUserFill[]
|
|
149
|
+
|
|
150
|
+
export type HlUserFillsByTime = HlUserFill[]
|
|
190
151
|
|
|
191
152
|
// -- orderStatus ------------------------------------------------------------
|
|
192
153
|
|
|
193
|
-
export
|
|
194
|
-
order:
|
|
195
|
-
oid:
|
|
196
|
-
coin:
|
|
197
|
-
side:
|
|
198
|
-
sz:
|
|
199
|
-
limitPx:
|
|
200
|
-
orderType:
|
|
201
|
-
origSz:
|
|
202
|
-
reduceOnly:
|
|
203
|
-
timestamp:
|
|
204
|
-
tif:
|
|
205
|
-
cloid:
|
|
206
|
-
triggerCondition:
|
|
207
|
-
triggerPx:
|
|
208
|
-
}
|
|
209
|
-
status:
|
|
210
|
-
statusTimestamp:
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
export type
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
HlOrderStatusFoundSchema,
|
|
222
|
-
Type.Object({ status: Type.Literal('unknownOid') }),
|
|
223
|
-
])
|
|
224
|
-
export type HlOrderStatusResponse = Static<
|
|
225
|
-
typeof HlOrderStatusResponseSchema
|
|
226
|
-
>
|
|
154
|
+
export type HlOrderDetail = {
|
|
155
|
+
order: {
|
|
156
|
+
oid: number
|
|
157
|
+
coin: string
|
|
158
|
+
side: string
|
|
159
|
+
sz: string
|
|
160
|
+
limitPx: string
|
|
161
|
+
orderType: string
|
|
162
|
+
origSz: string
|
|
163
|
+
reduceOnly: boolean
|
|
164
|
+
timestamp: number
|
|
165
|
+
tif: string | null
|
|
166
|
+
cloid: string | null
|
|
167
|
+
triggerCondition: string
|
|
168
|
+
triggerPx: string | null
|
|
169
|
+
}
|
|
170
|
+
status: string
|
|
171
|
+
statusTimestamp: number
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export type HlOrderStatusFound = {
|
|
175
|
+
status: 'order'
|
|
176
|
+
order: HlOrderDetail
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export type HlOrderStatusResponse =
|
|
180
|
+
| HlOrderStatusFound
|
|
181
|
+
| { status: 'unknownOid' }
|
|
227
182
|
|
|
228
183
|
// -- perpDexs ---------------------------------------------------------------
|
|
229
184
|
|
|
230
|
-
export
|
|
231
|
-
Type.Union([Type.Null(), Type.Object({ name: Type.String() })])
|
|
232
|
-
)
|
|
233
|
-
export type HlPerpDexs = Static<typeof HlPerpDexsSchema>
|
|
185
|
+
export type HlPerpDexs = (null | { name: string })[]
|
|
234
186
|
|
|
235
187
|
// ---------------------------------------------------------------------------
|
|
236
|
-
// Exchange request / response
|
|
188
|
+
// Exchange request / response types
|
|
237
189
|
// ---------------------------------------------------------------------------
|
|
238
190
|
|
|
239
|
-
export
|
|
240
|
-
action:
|
|
241
|
-
signature:
|
|
242
|
-
r:
|
|
243
|
-
s:
|
|
244
|
-
v:
|
|
245
|
-
}
|
|
246
|
-
nonce:
|
|
247
|
-
vaultAddress
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
}),
|
|
271
|
-
Type.Object({ resting: Type.Object({ oid: Type.Number() }) }),
|
|
272
|
-
Type.Object({
|
|
273
|
-
waitingForFill: Type.Object({ oid: Type.Number() }),
|
|
274
|
-
}),
|
|
275
|
-
Type.Object({
|
|
276
|
-
waitingForTrigger: Type.Object({ oid: Type.Number() }),
|
|
277
|
-
}),
|
|
278
|
-
Type.Object({ success: Type.Literal(true) }),
|
|
279
|
-
Type.Object({ error: Type.String() }),
|
|
280
|
-
])
|
|
281
|
-
)
|
|
282
|
-
),
|
|
283
|
-
status: Type.Optional(Type.Unknown()),
|
|
284
|
-
})
|
|
285
|
-
),
|
|
286
|
-
}),
|
|
287
|
-
])
|
|
288
|
-
),
|
|
289
|
-
})
|
|
290
|
-
export type HlExchangeResponse = Static<typeof HlExchangeResponseSchema>
|
|
191
|
+
export type HlExchangeRequest = {
|
|
192
|
+
action: Record<string, unknown>
|
|
193
|
+
signature: {
|
|
194
|
+
r: string
|
|
195
|
+
s: string
|
|
196
|
+
v: number
|
|
197
|
+
}
|
|
198
|
+
nonce: number
|
|
199
|
+
vaultAddress?: string | null
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export type HlExchangeResponse = {
|
|
203
|
+
status: string
|
|
204
|
+
response?:
|
|
205
|
+
| string
|
|
206
|
+
| {
|
|
207
|
+
type: string
|
|
208
|
+
data?: {
|
|
209
|
+
statuses?: (
|
|
210
|
+
| string
|
|
211
|
+
| { filled: { totalSz: string; avgPx: string; oid: number } }
|
|
212
|
+
| { resting: { oid: number } }
|
|
213
|
+
| { waitingForFill: { oid: number } }
|
|
214
|
+
| { waitingForTrigger: { oid: number } }
|
|
215
|
+
| { success: true }
|
|
216
|
+
| { error: string }
|
|
217
|
+
)[]
|
|
218
|
+
status?: unknown
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|