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