@lifi/perps-types 0.1.1-alpha.1 → 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 +9 -2
- package/providers/hyperliquid/package.json +5 -0
- package/src/_cjs/index.js +1 -0
- package/src/_cjs/index.js.map +1 -1
- package/src/_cjs/providers/hyperliquid/assetId.js +19 -0
- package/src/_cjs/providers/hyperliquid/assetId.js.map +1 -0
- package/src/_cjs/providers/hyperliquid/index.js +20 -0
- package/src/_cjs/providers/hyperliquid/index.js.map +1 -0
- package/src/_cjs/providers/hyperliquid/mappers/history.js +22 -0
- package/src/_cjs/providers/hyperliquid/mappers/history.js.map +1 -0
- package/src/_cjs/providers/hyperliquid/mappers/index.js +15 -0
- package/src/_cjs/providers/hyperliquid/mappers/index.js.map +1 -0
- package/src/_cjs/providers/hyperliquid/mappers/market.js +28 -0
- package/src/_cjs/providers/hyperliquid/mappers/market.js.map +1 -0
- package/src/_cjs/providers/hyperliquid/mappers/order.js +77 -0
- package/src/_cjs/providers/hyperliquid/mappers/order.js.map +1 -0
- package/src/_cjs/providers/hyperliquid/mappers/position.js +29 -0
- package/src/_cjs/providers/hyperliquid/mappers/position.js.map +1 -0
- package/src/_cjs/providers/hyperliquid/mappers/shared.js +12 -0
- package/src/_cjs/providers/hyperliquid/mappers/shared.js.map +1 -0
- package/src/_cjs/providers/hyperliquid/types.js +181 -0
- package/src/_cjs/providers/hyperliquid/types.js.map +1 -0
- package/src/_cjs/subscriptions.js +3 -0
- package/src/_cjs/subscriptions.js.map +1 -0
- package/src/_esm/index.js +1 -0
- package/src/_esm/index.js.map +1 -1
- package/src/_esm/providers/hyperliquid/assetId.js +23 -0
- package/src/_esm/providers/hyperliquid/assetId.js.map +1 -0
- package/src/_esm/providers/hyperliquid/index.js +4 -0
- package/src/_esm/providers/hyperliquid/index.js.map +1 -0
- package/src/_esm/providers/hyperliquid/mappers/history.js +18 -0
- package/src/_esm/providers/hyperliquid/mappers/history.js.map +1 -0
- package/src/_esm/providers/hyperliquid/mappers/index.js +6 -0
- package/src/_esm/providers/hyperliquid/mappers/index.js.map +1 -0
- package/src/_esm/providers/hyperliquid/mappers/market.js +24 -0
- package/src/_esm/providers/hyperliquid/mappers/market.js.map +1 -0
- package/src/_esm/providers/hyperliquid/mappers/order.js +72 -0
- package/src/_esm/providers/hyperliquid/mappers/order.js.map +1 -0
- package/src/_esm/providers/hyperliquid/mappers/position.js +25 -0
- package/src/_esm/providers/hyperliquid/mappers/position.js.map +1 -0
- package/src/_esm/providers/hyperliquid/mappers/shared.js +13 -0
- package/src/_esm/providers/hyperliquid/mappers/shared.js.map +1 -0
- package/src/_esm/providers/hyperliquid/types.js +203 -0
- package/src/_esm/providers/hyperliquid/types.js.map +1 -0
- package/src/_esm/subscriptions.js +2 -0
- package/src/_esm/subscriptions.js.map +1 -0
- package/src/_types/index.d.ts +1 -0
- package/src/_types/index.d.ts.map +1 -1
- package/src/_types/market.d.ts +1 -0
- package/src/_types/market.d.ts.map +1 -1
- package/src/_types/providers/hyperliquid/assetId.d.ts +12 -0
- package/src/_types/providers/hyperliquid/assetId.d.ts.map +1 -0
- package/src/_types/providers/hyperliquid/index.d.ts +4 -0
- package/src/_types/providers/hyperliquid/index.d.ts.map +1 -0
- package/src/_types/providers/hyperliquid/mappers/history.d.ts +4 -0
- package/src/_types/providers/hyperliquid/mappers/history.d.ts.map +1 -0
- package/src/_types/providers/hyperliquid/mappers/index.d.ts +6 -0
- package/src/_types/providers/hyperliquid/mappers/index.d.ts.map +1 -0
- package/src/_types/providers/hyperliquid/mappers/market.d.ts +4 -0
- package/src/_types/providers/hyperliquid/mappers/market.d.ts.map +1 -0
- package/src/_types/providers/hyperliquid/mappers/order.d.ts +6 -0
- package/src/_types/providers/hyperliquid/mappers/order.d.ts.map +1 -0
- package/src/_types/providers/hyperliquid/mappers/position.d.ts +4 -0
- package/src/_types/providers/hyperliquid/mappers/position.d.ts.map +1 -0
- package/src/_types/providers/hyperliquid/mappers/shared.d.ts +7 -0
- package/src/_types/providers/hyperliquid/mappers/shared.d.ts.map +1 -0
- package/src/_types/providers/hyperliquid/types.d.ts +340 -0
- package/src/_types/providers/hyperliquid/types.d.ts.map +1 -0
- package/src/_types/subscriptions.d.ts +70 -0
- package/src/_types/subscriptions.d.ts.map +1 -0
- package/src/index.ts +1 -0
- package/src/market.ts +1 -0
- package/src/providers/hyperliquid/assetId.ts +26 -0
- package/src/providers/hyperliquid/index.ts +3 -0
- package/src/providers/hyperliquid/mappers/history.ts +25 -0
- package/src/providers/hyperliquid/mappers/index.ts +5 -0
- package/src/providers/hyperliquid/mappers/market.ts +35 -0
- package/src/providers/hyperliquid/mappers/order.ts +89 -0
- package/src/providers/hyperliquid/mappers/position.ts +35 -0
- package/src/providers/hyperliquid/mappers/shared.ts +15 -0
- package/src/providers/hyperliquid/types.ts +290 -0
- package/src/subscriptions.ts +72 -0
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
import { type Static } from '@sinclair/typebox';
|
|
2
|
+
export declare const HlUniverseItemSchema: import("@sinclair/typebox").TObject<{
|
|
3
|
+
name: import("@sinclair/typebox").TString;
|
|
4
|
+
szDecimals: import("@sinclair/typebox").TNumber;
|
|
5
|
+
maxLeverage: import("@sinclair/typebox").TNumber;
|
|
6
|
+
onlyIsolated: import("@sinclair/typebox").TBoolean;
|
|
7
|
+
isDelisted: import("@sinclair/typebox").TBoolean;
|
|
8
|
+
}>;
|
|
9
|
+
export type HlUniverseItem = Static<typeof HlUniverseItemSchema>;
|
|
10
|
+
export declare const HlMetaSchema: import("@sinclair/typebox").TObject<{
|
|
11
|
+
universe: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
12
|
+
name: import("@sinclair/typebox").TString;
|
|
13
|
+
szDecimals: import("@sinclair/typebox").TNumber;
|
|
14
|
+
maxLeverage: import("@sinclair/typebox").TNumber;
|
|
15
|
+
onlyIsolated: import("@sinclair/typebox").TBoolean;
|
|
16
|
+
isDelisted: import("@sinclair/typebox").TBoolean;
|
|
17
|
+
}>>;
|
|
18
|
+
}>;
|
|
19
|
+
export type HlMeta = Static<typeof HlMetaSchema>;
|
|
20
|
+
export declare const HlAssetCtxSchema: import("@sinclair/typebox").TObject<{
|
|
21
|
+
funding: import("@sinclair/typebox").TString;
|
|
22
|
+
openInterest: import("@sinclair/typebox").TString;
|
|
23
|
+
dayNtlVlm: import("@sinclair/typebox").TString;
|
|
24
|
+
markPx: import("@sinclair/typebox").TString;
|
|
25
|
+
}>;
|
|
26
|
+
export type HlAssetCtx = Static<typeof HlAssetCtxSchema>;
|
|
27
|
+
export declare const HlMetaAndAssetCtxsSchema: import("@sinclair/typebox").TTuple<[import("@sinclair/typebox").TObject<{
|
|
28
|
+
universe: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
29
|
+
name: import("@sinclair/typebox").TString;
|
|
30
|
+
szDecimals: import("@sinclair/typebox").TNumber;
|
|
31
|
+
maxLeverage: import("@sinclair/typebox").TNumber;
|
|
32
|
+
onlyIsolated: import("@sinclair/typebox").TBoolean;
|
|
33
|
+
isDelisted: import("@sinclair/typebox").TBoolean;
|
|
34
|
+
}>>;
|
|
35
|
+
}>, import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
36
|
+
funding: import("@sinclair/typebox").TString;
|
|
37
|
+
openInterest: import("@sinclair/typebox").TString;
|
|
38
|
+
dayNtlVlm: import("@sinclair/typebox").TString;
|
|
39
|
+
markPx: import("@sinclair/typebox").TString;
|
|
40
|
+
}>>]>;
|
|
41
|
+
export type HlMetaAndAssetCtxs = Static<typeof HlMetaAndAssetCtxsSchema>;
|
|
42
|
+
export type HlUniverse = HlMeta['universe'];
|
|
43
|
+
export declare const HlAllMidsSchema: import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TString>;
|
|
44
|
+
export type HlAllMids = Static<typeof HlAllMidsSchema>;
|
|
45
|
+
export declare const HlCandleSchema: import("@sinclair/typebox").TObject<{
|
|
46
|
+
t: import("@sinclair/typebox").TNumber;
|
|
47
|
+
o: import("@sinclair/typebox").TString;
|
|
48
|
+
h: import("@sinclair/typebox").TString;
|
|
49
|
+
l: import("@sinclair/typebox").TString;
|
|
50
|
+
c: import("@sinclair/typebox").TString;
|
|
51
|
+
v: import("@sinclair/typebox").TString;
|
|
52
|
+
}>;
|
|
53
|
+
export type HlCandle = Static<typeof HlCandleSchema>;
|
|
54
|
+
export declare const HlCandleSnapshotSchema: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
55
|
+
t: import("@sinclair/typebox").TNumber;
|
|
56
|
+
o: import("@sinclair/typebox").TString;
|
|
57
|
+
h: import("@sinclair/typebox").TString;
|
|
58
|
+
l: import("@sinclair/typebox").TString;
|
|
59
|
+
c: import("@sinclair/typebox").TString;
|
|
60
|
+
v: import("@sinclair/typebox").TString;
|
|
61
|
+
}>>;
|
|
62
|
+
export type HlCandleSnapshot = Static<typeof HlCandleSnapshotSchema>;
|
|
63
|
+
export declare const HlLevelSchema: import("@sinclair/typebox").TObject<{
|
|
64
|
+
px: import("@sinclair/typebox").TString;
|
|
65
|
+
sz: import("@sinclair/typebox").TString;
|
|
66
|
+
n: import("@sinclair/typebox").TNumber;
|
|
67
|
+
}>;
|
|
68
|
+
export type HlLevel = Static<typeof HlLevelSchema>;
|
|
69
|
+
export declare const HlL2BookSchema: import("@sinclair/typebox").TObject<{
|
|
70
|
+
levels: import("@sinclair/typebox").TTuple<[import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
71
|
+
px: import("@sinclair/typebox").TString;
|
|
72
|
+
sz: import("@sinclair/typebox").TString;
|
|
73
|
+
n: import("@sinclair/typebox").TNumber;
|
|
74
|
+
}>>, import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
75
|
+
px: import("@sinclair/typebox").TString;
|
|
76
|
+
sz: import("@sinclair/typebox").TString;
|
|
77
|
+
n: import("@sinclair/typebox").TNumber;
|
|
78
|
+
}>>]>;
|
|
79
|
+
time: import("@sinclair/typebox").TNumber;
|
|
80
|
+
}>;
|
|
81
|
+
export type HlL2Book = Static<typeof HlL2BookSchema>;
|
|
82
|
+
export declare const HlPositionSchema: import("@sinclair/typebox").TObject<{
|
|
83
|
+
coin: import("@sinclair/typebox").TString;
|
|
84
|
+
szi: import("@sinclair/typebox").TString;
|
|
85
|
+
entryPx: import("@sinclair/typebox").TString;
|
|
86
|
+
positionValue: import("@sinclair/typebox").TString;
|
|
87
|
+
liquidationPx: import("@sinclair/typebox").TString;
|
|
88
|
+
unrealizedPnl: import("@sinclair/typebox").TString;
|
|
89
|
+
marginUsed: import("@sinclair/typebox").TString;
|
|
90
|
+
leverage: import("@sinclair/typebox").TObject<{
|
|
91
|
+
type: import("@sinclair/typebox").TString;
|
|
92
|
+
value: import("@sinclair/typebox").TNumber;
|
|
93
|
+
}>;
|
|
94
|
+
}>;
|
|
95
|
+
export type HlPosition = Static<typeof HlPositionSchema>;
|
|
96
|
+
export declare const HlAssetPositionSchema: import("@sinclair/typebox").TObject<{
|
|
97
|
+
position: import("@sinclair/typebox").TObject<{
|
|
98
|
+
coin: import("@sinclair/typebox").TString;
|
|
99
|
+
szi: import("@sinclair/typebox").TString;
|
|
100
|
+
entryPx: import("@sinclair/typebox").TString;
|
|
101
|
+
positionValue: import("@sinclair/typebox").TString;
|
|
102
|
+
liquidationPx: import("@sinclair/typebox").TString;
|
|
103
|
+
unrealizedPnl: import("@sinclair/typebox").TString;
|
|
104
|
+
marginUsed: import("@sinclair/typebox").TString;
|
|
105
|
+
leverage: import("@sinclair/typebox").TObject<{
|
|
106
|
+
type: import("@sinclair/typebox").TString;
|
|
107
|
+
value: import("@sinclair/typebox").TNumber;
|
|
108
|
+
}>;
|
|
109
|
+
}>;
|
|
110
|
+
}>;
|
|
111
|
+
export type HlAssetPosition = Static<typeof HlAssetPositionSchema>;
|
|
112
|
+
export declare const HlClearinghouseStateSchema: import("@sinclair/typebox").TObject<{
|
|
113
|
+
assetPositions: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
114
|
+
position: import("@sinclair/typebox").TObject<{
|
|
115
|
+
coin: import("@sinclair/typebox").TString;
|
|
116
|
+
szi: import("@sinclair/typebox").TString;
|
|
117
|
+
entryPx: import("@sinclair/typebox").TString;
|
|
118
|
+
positionValue: import("@sinclair/typebox").TString;
|
|
119
|
+
liquidationPx: import("@sinclair/typebox").TString;
|
|
120
|
+
unrealizedPnl: import("@sinclair/typebox").TString;
|
|
121
|
+
marginUsed: import("@sinclair/typebox").TString;
|
|
122
|
+
leverage: import("@sinclair/typebox").TObject<{
|
|
123
|
+
type: import("@sinclair/typebox").TString;
|
|
124
|
+
value: import("@sinclair/typebox").TNumber;
|
|
125
|
+
}>;
|
|
126
|
+
}>;
|
|
127
|
+
}>>;
|
|
128
|
+
marginSummary: import("@sinclair/typebox").TObject<{
|
|
129
|
+
accountValue: import("@sinclair/typebox").TString;
|
|
130
|
+
totalMarginUsed: import("@sinclair/typebox").TString;
|
|
131
|
+
}>;
|
|
132
|
+
crossMarginSummary: import("@sinclair/typebox").TObject<{
|
|
133
|
+
accountValue: import("@sinclair/typebox").TString;
|
|
134
|
+
totalMarginUsed: import("@sinclair/typebox").TString;
|
|
135
|
+
}>;
|
|
136
|
+
}>;
|
|
137
|
+
export type HlClearinghouseState = Static<typeof HlClearinghouseStateSchema>;
|
|
138
|
+
export declare const HlSpotBalanceSchema: import("@sinclair/typebox").TObject<{
|
|
139
|
+
coin: import("@sinclair/typebox").TString;
|
|
140
|
+
token: import("@sinclair/typebox").TNumber;
|
|
141
|
+
total: import("@sinclair/typebox").TString;
|
|
142
|
+
hold: import("@sinclair/typebox").TString;
|
|
143
|
+
entryNtl: import("@sinclair/typebox").TString;
|
|
144
|
+
}>;
|
|
145
|
+
export type HlSpotBalance = Static<typeof HlSpotBalanceSchema>;
|
|
146
|
+
export declare const HlSpotClearinghouseStateSchema: import("@sinclair/typebox").TObject<{
|
|
147
|
+
balances: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
148
|
+
coin: import("@sinclair/typebox").TString;
|
|
149
|
+
token: import("@sinclair/typebox").TNumber;
|
|
150
|
+
total: import("@sinclair/typebox").TString;
|
|
151
|
+
hold: import("@sinclair/typebox").TString;
|
|
152
|
+
entryNtl: import("@sinclair/typebox").TString;
|
|
153
|
+
}>>;
|
|
154
|
+
}>;
|
|
155
|
+
export type HlSpotClearinghouseState = Static<typeof HlSpotClearinghouseStateSchema>;
|
|
156
|
+
export declare const HlUserFeesSchema: import("@sinclair/typebox").TObject<{
|
|
157
|
+
userAddRate: import("@sinclair/typebox").TString;
|
|
158
|
+
userCrossRate: import("@sinclair/typebox").TString;
|
|
159
|
+
activeReferralDiscount: import("@sinclair/typebox").TString;
|
|
160
|
+
}>;
|
|
161
|
+
export type HlUserFees = Static<typeof HlUserFeesSchema>;
|
|
162
|
+
export declare const HlFrontendOpenOrderSchema: import("@sinclair/typebox").TObject<{
|
|
163
|
+
oid: import("@sinclair/typebox").TNumber;
|
|
164
|
+
coin: import("@sinclair/typebox").TString;
|
|
165
|
+
side: import("@sinclair/typebox").TString;
|
|
166
|
+
sz: import("@sinclair/typebox").TString;
|
|
167
|
+
limitPx: import("@sinclair/typebox").TString;
|
|
168
|
+
orderType: import("@sinclair/typebox").TString;
|
|
169
|
+
origSz: import("@sinclair/typebox").TString;
|
|
170
|
+
reduceOnly: import("@sinclair/typebox").TBoolean;
|
|
171
|
+
timestamp: import("@sinclair/typebox").TNumber;
|
|
172
|
+
}>;
|
|
173
|
+
export type HlFrontendOpenOrder = Static<typeof HlFrontendOpenOrderSchema>;
|
|
174
|
+
export declare const HlFrontendOpenOrdersSchema: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
175
|
+
oid: import("@sinclair/typebox").TNumber;
|
|
176
|
+
coin: import("@sinclair/typebox").TString;
|
|
177
|
+
side: import("@sinclair/typebox").TString;
|
|
178
|
+
sz: import("@sinclair/typebox").TString;
|
|
179
|
+
limitPx: import("@sinclair/typebox").TString;
|
|
180
|
+
orderType: import("@sinclair/typebox").TString;
|
|
181
|
+
origSz: import("@sinclair/typebox").TString;
|
|
182
|
+
reduceOnly: import("@sinclair/typebox").TBoolean;
|
|
183
|
+
timestamp: import("@sinclair/typebox").TNumber;
|
|
184
|
+
}>>;
|
|
185
|
+
export type HlFrontendOpenOrders = Static<typeof HlFrontendOpenOrdersSchema>;
|
|
186
|
+
export declare const HlExtraAgentsSchema: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TUnknown>>;
|
|
187
|
+
export type HlExtraAgents = Static<typeof HlExtraAgentsSchema>;
|
|
188
|
+
export declare const HlUserFillSchema: import("@sinclair/typebox").TObject<{
|
|
189
|
+
tid: import("@sinclair/typebox").TNumber;
|
|
190
|
+
coin: import("@sinclair/typebox").TString;
|
|
191
|
+
side: import("@sinclair/typebox").TString;
|
|
192
|
+
sz: import("@sinclair/typebox").TString;
|
|
193
|
+
px: import("@sinclair/typebox").TString;
|
|
194
|
+
dir: import("@sinclair/typebox").TString;
|
|
195
|
+
fee: import("@sinclair/typebox").TString;
|
|
196
|
+
closedPnl: import("@sinclair/typebox").TString;
|
|
197
|
+
time: import("@sinclair/typebox").TNumber;
|
|
198
|
+
}>;
|
|
199
|
+
export type HlUserFill = Static<typeof HlUserFillSchema>;
|
|
200
|
+
export declare const HlUserFillsSchema: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
201
|
+
tid: import("@sinclair/typebox").TNumber;
|
|
202
|
+
coin: import("@sinclair/typebox").TString;
|
|
203
|
+
side: import("@sinclair/typebox").TString;
|
|
204
|
+
sz: import("@sinclair/typebox").TString;
|
|
205
|
+
px: import("@sinclair/typebox").TString;
|
|
206
|
+
dir: import("@sinclair/typebox").TString;
|
|
207
|
+
fee: import("@sinclair/typebox").TString;
|
|
208
|
+
closedPnl: import("@sinclair/typebox").TString;
|
|
209
|
+
time: import("@sinclair/typebox").TNumber;
|
|
210
|
+
}>>;
|
|
211
|
+
export type HlUserFills = Static<typeof HlUserFillsSchema>;
|
|
212
|
+
export declare const HlUserFillsByTimeSchema: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
213
|
+
tid: import("@sinclair/typebox").TNumber;
|
|
214
|
+
coin: import("@sinclair/typebox").TString;
|
|
215
|
+
side: import("@sinclair/typebox").TString;
|
|
216
|
+
sz: import("@sinclair/typebox").TString;
|
|
217
|
+
px: import("@sinclair/typebox").TString;
|
|
218
|
+
dir: import("@sinclair/typebox").TString;
|
|
219
|
+
fee: import("@sinclair/typebox").TString;
|
|
220
|
+
closedPnl: import("@sinclair/typebox").TString;
|
|
221
|
+
time: import("@sinclair/typebox").TNumber;
|
|
222
|
+
}>>;
|
|
223
|
+
export type HlUserFillsByTime = Static<typeof HlUserFillsByTimeSchema>;
|
|
224
|
+
export declare const HlOrderDetailSchema: import("@sinclair/typebox").TObject<{
|
|
225
|
+
order: import("@sinclair/typebox").TObject<{
|
|
226
|
+
oid: import("@sinclair/typebox").TNumber;
|
|
227
|
+
coin: import("@sinclair/typebox").TString;
|
|
228
|
+
side: import("@sinclair/typebox").TString;
|
|
229
|
+
sz: import("@sinclair/typebox").TString;
|
|
230
|
+
limitPx: import("@sinclair/typebox").TString;
|
|
231
|
+
orderType: import("@sinclair/typebox").TString;
|
|
232
|
+
origSz: import("@sinclair/typebox").TString;
|
|
233
|
+
reduceOnly: import("@sinclair/typebox").TBoolean;
|
|
234
|
+
timestamp: import("@sinclair/typebox").TNumber;
|
|
235
|
+
tif: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
|
|
236
|
+
cloid: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
|
|
237
|
+
triggerCondition: import("@sinclair/typebox").TString;
|
|
238
|
+
triggerPx: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
|
|
239
|
+
}>;
|
|
240
|
+
status: import("@sinclair/typebox").TString;
|
|
241
|
+
statusTimestamp: import("@sinclair/typebox").TNumber;
|
|
242
|
+
}>;
|
|
243
|
+
export type HlOrderDetail = Static<typeof HlOrderDetailSchema>;
|
|
244
|
+
export declare const HlOrderStatusFoundSchema: import("@sinclair/typebox").TObject<{
|
|
245
|
+
status: import("@sinclair/typebox").TLiteral<"order">;
|
|
246
|
+
order: import("@sinclair/typebox").TObject<{
|
|
247
|
+
order: import("@sinclair/typebox").TObject<{
|
|
248
|
+
oid: import("@sinclair/typebox").TNumber;
|
|
249
|
+
coin: import("@sinclair/typebox").TString;
|
|
250
|
+
side: import("@sinclair/typebox").TString;
|
|
251
|
+
sz: import("@sinclair/typebox").TString;
|
|
252
|
+
limitPx: import("@sinclair/typebox").TString;
|
|
253
|
+
orderType: import("@sinclair/typebox").TString;
|
|
254
|
+
origSz: import("@sinclair/typebox").TString;
|
|
255
|
+
reduceOnly: import("@sinclair/typebox").TBoolean;
|
|
256
|
+
timestamp: import("@sinclair/typebox").TNumber;
|
|
257
|
+
tif: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
|
|
258
|
+
cloid: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
|
|
259
|
+
triggerCondition: import("@sinclair/typebox").TString;
|
|
260
|
+
triggerPx: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
|
|
261
|
+
}>;
|
|
262
|
+
status: import("@sinclair/typebox").TString;
|
|
263
|
+
statusTimestamp: import("@sinclair/typebox").TNumber;
|
|
264
|
+
}>;
|
|
265
|
+
}>;
|
|
266
|
+
export type HlOrderStatusFound = Static<typeof HlOrderStatusFoundSchema>;
|
|
267
|
+
export declare const HlOrderStatusResponseSchema: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
|
|
268
|
+
status: import("@sinclair/typebox").TLiteral<"order">;
|
|
269
|
+
order: import("@sinclair/typebox").TObject<{
|
|
270
|
+
order: import("@sinclair/typebox").TObject<{
|
|
271
|
+
oid: import("@sinclair/typebox").TNumber;
|
|
272
|
+
coin: import("@sinclair/typebox").TString;
|
|
273
|
+
side: import("@sinclair/typebox").TString;
|
|
274
|
+
sz: import("@sinclair/typebox").TString;
|
|
275
|
+
limitPx: import("@sinclair/typebox").TString;
|
|
276
|
+
orderType: import("@sinclair/typebox").TString;
|
|
277
|
+
origSz: import("@sinclair/typebox").TString;
|
|
278
|
+
reduceOnly: import("@sinclair/typebox").TBoolean;
|
|
279
|
+
timestamp: import("@sinclair/typebox").TNumber;
|
|
280
|
+
tif: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
|
|
281
|
+
cloid: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
|
|
282
|
+
triggerCondition: import("@sinclair/typebox").TString;
|
|
283
|
+
triggerPx: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
|
|
284
|
+
}>;
|
|
285
|
+
status: import("@sinclair/typebox").TString;
|
|
286
|
+
statusTimestamp: import("@sinclair/typebox").TNumber;
|
|
287
|
+
}>;
|
|
288
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
289
|
+
status: import("@sinclair/typebox").TLiteral<"unknownOid">;
|
|
290
|
+
}>]>;
|
|
291
|
+
export type HlOrderStatusResponse = Static<typeof HlOrderStatusResponseSchema>;
|
|
292
|
+
export declare const HlPerpDexsSchema: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TNull, import("@sinclair/typebox").TObject<{
|
|
293
|
+
name: import("@sinclair/typebox").TString;
|
|
294
|
+
}>]>>;
|
|
295
|
+
export type HlPerpDexs = Static<typeof HlPerpDexsSchema>;
|
|
296
|
+
export declare const HlExchangeRequestSchema: import("@sinclair/typebox").TObject<{
|
|
297
|
+
action: import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TUnknown>;
|
|
298
|
+
signature: import("@sinclair/typebox").TObject<{
|
|
299
|
+
r: import("@sinclair/typebox").TString;
|
|
300
|
+
s: import("@sinclair/typebox").TString;
|
|
301
|
+
v: import("@sinclair/typebox").TNumber;
|
|
302
|
+
}>;
|
|
303
|
+
nonce: import("@sinclair/typebox").TNumber;
|
|
304
|
+
vaultAddress: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>>;
|
|
305
|
+
}>;
|
|
306
|
+
export type HlExchangeRequest = Static<typeof HlExchangeRequestSchema>;
|
|
307
|
+
export declare const HlExchangeResponseSchema: import("@sinclair/typebox").TObject<{
|
|
308
|
+
status: import("@sinclair/typebox").TString;
|
|
309
|
+
response: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TObject<{
|
|
310
|
+
type: import("@sinclair/typebox").TString;
|
|
311
|
+
data: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
|
|
312
|
+
statuses: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TObject<{
|
|
313
|
+
filled: import("@sinclair/typebox").TObject<{
|
|
314
|
+
totalSz: import("@sinclair/typebox").TString;
|
|
315
|
+
avgPx: import("@sinclair/typebox").TString;
|
|
316
|
+
oid: import("@sinclair/typebox").TNumber;
|
|
317
|
+
}>;
|
|
318
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
319
|
+
resting: import("@sinclair/typebox").TObject<{
|
|
320
|
+
oid: import("@sinclair/typebox").TNumber;
|
|
321
|
+
}>;
|
|
322
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
323
|
+
waitingForFill: import("@sinclair/typebox").TObject<{
|
|
324
|
+
oid: import("@sinclair/typebox").TNumber;
|
|
325
|
+
}>;
|
|
326
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
327
|
+
waitingForTrigger: import("@sinclair/typebox").TObject<{
|
|
328
|
+
oid: import("@sinclair/typebox").TNumber;
|
|
329
|
+
}>;
|
|
330
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
331
|
+
success: import("@sinclair/typebox").TLiteral<true>;
|
|
332
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
333
|
+
error: import("@sinclair/typebox").TString;
|
|
334
|
+
}>]>>>;
|
|
335
|
+
status: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnknown>;
|
|
336
|
+
}>>;
|
|
337
|
+
}>]>>;
|
|
338
|
+
}>;
|
|
339
|
+
export type HlExchangeResponse = Static<typeof HlExchangeResponseSchema>;
|
|
340
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../providers/hyperliquid/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAerD,eAAO,MAAM,oBAAoB;;;;;;EAM/B,CAAA;AACF,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,OAAO,oBAAoB,CAAC,CAAA;AAEhE,eAAO,MAAM,YAAY;;;;;;;;EAEvB,CAAA;AACF,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,YAAY,CAAC,CAAA;AAEhD,eAAO,MAAM,gBAAgB;;;;;EAK3B,CAAA;AACF,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,gBAAgB,CAAC,CAAA;AAExD,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;KAGnC,CAAA;AACF,MAAM,MAAM,kBAAkB,GAAG,MAAM,CAAC,OAAO,wBAAwB,CAAC,CA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ID,eAAO,MAAM,gBAAgB;;KAE5B,CAAA;AACD,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,gBAAgB,CAAC,CAAA;AAMxD,eAAO,MAAM,uBAAuB;;;;;;;;;EASlC,CAAA;AACF,MAAM,MAAM,iBAAiB,GAAG,MAAM,CAAC,OAAO,uBAAuB,CAAC,CAAA;AAEtE,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAsCnC,CAAA;AACF,MAAM,MAAM,kBAAkB,GAAG,MAAM,CAAC,OAAO,wBAAwB,CAAC,CAAA"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { Address } from './typedData.js';
|
|
2
|
+
import type { Candle, OhlcvInterval, OrderbookResponse, PricesResponse } from './market.js';
|
|
3
|
+
import type { HistoryItem, Position } from './account.js';
|
|
4
|
+
import type { Order } from './trading.js';
|
|
5
|
+
export type PricesSubscription = {
|
|
6
|
+
channel: 'prices';
|
|
7
|
+
dex: string;
|
|
8
|
+
};
|
|
9
|
+
export type OrderbookSubscription = {
|
|
10
|
+
channel: 'orderbook';
|
|
11
|
+
dex: string;
|
|
12
|
+
symbol: string;
|
|
13
|
+
};
|
|
14
|
+
export type TradesSubscription = {
|
|
15
|
+
channel: 'trades';
|
|
16
|
+
dex: string;
|
|
17
|
+
symbol: string;
|
|
18
|
+
};
|
|
19
|
+
export type CandleSubscription = {
|
|
20
|
+
channel: 'candle';
|
|
21
|
+
dex: string;
|
|
22
|
+
symbol: string;
|
|
23
|
+
interval: OhlcvInterval;
|
|
24
|
+
};
|
|
25
|
+
export type OrderUpdatesSubscription = {
|
|
26
|
+
channel: 'orderUpdates';
|
|
27
|
+
dex: string;
|
|
28
|
+
address: Address;
|
|
29
|
+
};
|
|
30
|
+
export type FillsSubscription = {
|
|
31
|
+
channel: 'fills';
|
|
32
|
+
dex: string;
|
|
33
|
+
address: Address;
|
|
34
|
+
};
|
|
35
|
+
export type PositionsSubscription = {
|
|
36
|
+
channel: 'positions';
|
|
37
|
+
dex: string;
|
|
38
|
+
address: Address;
|
|
39
|
+
};
|
|
40
|
+
export type Subscription = PricesSubscription | OrderbookSubscription | TradesSubscription | CandleSubscription | OrderUpdatesSubscription | FillsSubscription | PositionsSubscription;
|
|
41
|
+
export type PricesEvent = {
|
|
42
|
+
channel: 'prices';
|
|
43
|
+
data: PricesResponse;
|
|
44
|
+
};
|
|
45
|
+
export type OrderbookEvent = {
|
|
46
|
+
channel: 'orderbook';
|
|
47
|
+
data: OrderbookResponse;
|
|
48
|
+
};
|
|
49
|
+
export type TradesEvent = {
|
|
50
|
+
channel: 'trades';
|
|
51
|
+
data: HistoryItem[];
|
|
52
|
+
};
|
|
53
|
+
export type CandleEvent = {
|
|
54
|
+
channel: 'candle';
|
|
55
|
+
data: Candle;
|
|
56
|
+
};
|
|
57
|
+
export type OrderUpdatesEvent = {
|
|
58
|
+
channel: 'orderUpdates';
|
|
59
|
+
data: Order[];
|
|
60
|
+
};
|
|
61
|
+
export type FillsEvent = {
|
|
62
|
+
channel: 'fills';
|
|
63
|
+
data: HistoryItem[];
|
|
64
|
+
};
|
|
65
|
+
export type PositionsEvent = {
|
|
66
|
+
channel: 'positions';
|
|
67
|
+
data: Position[];
|
|
68
|
+
};
|
|
69
|
+
export type SubscriptionEvent = PricesEvent | OrderbookEvent | TradesEvent | CandleEvent | OrderUpdatesEvent | FillsEvent | PositionsEvent;
|
|
70
|
+
//# sourceMappingURL=subscriptions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subscriptions.d.ts","sourceRoot":"","sources":["../subscriptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAC7C,OAAO,KAAK,EACV,MAAM,EACN,aAAa,EACb,iBAAiB,EACjB,cAAc,EACf,MAAM,aAAa,CAAA;AACpB,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,cAAc,C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rE,MAAM,MAAM,cAAc,GAAG;IAAE,OAAO,EAAE,WAAW,CAAC;IAAC,IAAI,EAAE,iBAAiB,CAAA;CAAE,CAAA;AAC9E,MAAM,MAAM,WAAW,GAAG;IAAE,OAAO,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,WAAW,EAAE,CAAA;CAAE,CAAA;AACpE,MAAM,MAAM,WAAW,GAAG;IAAE,OAAO,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAA;AAC7D,MAAM,MAAM,iBAAiB,GAAG;IAAE,OAAO,EAAE,cAAc,CAAC;IAAC,IAAI,EAAE,KAAK,EAAE,CAAA;CAAE,CAAA;AAC1E,MAAM,MAAM,UAAU,GAAG;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,WAAW,EAAE,CAAA;CAAE,CAAA;AAClE,MAAM,MAAM,cAAc,GAAG;IAAE,OAAO,EAAE,WAAW,CAAC;IAAC,IAAI,EAAE,QAAQ,EAAE,CAAA;CAAE,CAAA;AAEvE,MAAM,MAAM,iBAAiB,GACzB,WAAW,GACX,cAAc,GACd,WAAW,GACX,WAAW,GACX,iBAAiB,GACjB,UAAU,GACV,cAAc,CAAA"}
|
package/src/index.ts
CHANGED
package/src/market.ts
CHANGED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calculate the asset ID for a given DEX index and asset index.
|
|
3
|
+
*
|
|
4
|
+
* Main DEX (dex = ''): assetId = indexInDex
|
|
5
|
+
* HIP-3 DEXes (dex = 'xyz'): assetId = 100_000 + perpDexIndex * 10_000 + indexInDex
|
|
6
|
+
*/
|
|
7
|
+
export const calculateAssetId = (
|
|
8
|
+
dexIndex: number,
|
|
9
|
+
indexInDex: number
|
|
10
|
+
): number => {
|
|
11
|
+
if (dexIndex === 0) {
|
|
12
|
+
return indexInDex
|
|
13
|
+
}
|
|
14
|
+
return 100_000 + dexIndex * 10_000 + indexInDex
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Get the DEX index from the given list of dex names.
|
|
19
|
+
*/
|
|
20
|
+
export const getDexIndex = (dex: string, dexNames: string[]): number => {
|
|
21
|
+
const index = dexNames.indexOf(dex)
|
|
22
|
+
if (index === -1) {
|
|
23
|
+
throw new Error(`Unknown sub-dex: ${dex}`)
|
|
24
|
+
}
|
|
25
|
+
return index
|
|
26
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { HistoryItemStatus, OrderSide, OrderType } from '../../../enums.js'
|
|
2
|
+
import type { HistoryItem } from '../../../account.js'
|
|
3
|
+
import type { HlUserFill } from '../types.js'
|
|
4
|
+
|
|
5
|
+
import { resolveAssetIdFromLookup } from './shared.js'
|
|
6
|
+
|
|
7
|
+
export const mapHistoryItem = (
|
|
8
|
+
fill: HlUserFill,
|
|
9
|
+
dexKey: string,
|
|
10
|
+
assetIdLookup: Map<string, number>
|
|
11
|
+
): HistoryItem => ({
|
|
12
|
+
id: String(fill.tid),
|
|
13
|
+
symbol: fill.coin,
|
|
14
|
+
assetId: resolveAssetIdFromLookup(assetIdLookup, fill.coin),
|
|
15
|
+
dex: dexKey,
|
|
16
|
+
side: fill.side === 'B' ? OrderSide.BUY : OrderSide.SELL,
|
|
17
|
+
type: fill.dir?.includes('Limit') ? OrderType.LIMIT : OrderType.MARKET,
|
|
18
|
+
size: fill.sz,
|
|
19
|
+
price: fill.px,
|
|
20
|
+
status: HistoryItemStatus.FILLED,
|
|
21
|
+
filledSize: fill.sz,
|
|
22
|
+
fee: fill.fee,
|
|
23
|
+
realizedPnl: fill.closedPnl === '0' ? null : fill.closedPnl,
|
|
24
|
+
createdAt: new Date(fill.time).toISOString(),
|
|
25
|
+
})
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { Market } from '../../../market.js'
|
|
2
|
+
import { calculateAssetId } from '../assetId.js'
|
|
3
|
+
import type { HlAssetCtx, HlUniverseItem } from '../types.js'
|
|
4
|
+
|
|
5
|
+
const NEXT_FUNDING_INTERVAL_MS = 60 * 60 * 1000 // 1 hour
|
|
6
|
+
|
|
7
|
+
export const mapMarket = (
|
|
8
|
+
universe: HlUniverseItem,
|
|
9
|
+
assetCtx: HlAssetCtx,
|
|
10
|
+
dexIndex: number,
|
|
11
|
+
indexInDex: number,
|
|
12
|
+
dexKey: string
|
|
13
|
+
): Market => {
|
|
14
|
+
const now = Date.now()
|
|
15
|
+
const nextFundingTime =
|
|
16
|
+
Math.ceil(now / NEXT_FUNDING_INTERVAL_MS) * NEXT_FUNDING_INTERVAL_MS
|
|
17
|
+
|
|
18
|
+
return {
|
|
19
|
+
symbol: universe.name,
|
|
20
|
+
name: universe.name,
|
|
21
|
+
logoURI: `https://app.hyperliquid.xyz/coins/${universe.name}.svg`,
|
|
22
|
+
assetId: calculateAssetId(dexIndex, indexInDex),
|
|
23
|
+
dex: dexKey,
|
|
24
|
+
szDecimals: universe.szDecimals,
|
|
25
|
+
maxLeverage: universe.maxLeverage,
|
|
26
|
+
onlyIsolated: universe.onlyIsolated === true,
|
|
27
|
+
funding: {
|
|
28
|
+
rate: assetCtx.funding,
|
|
29
|
+
nextFundingTime,
|
|
30
|
+
},
|
|
31
|
+
openInterest: assetCtx.openInterest,
|
|
32
|
+
volume24h: assetCtx.dayNtlVlm,
|
|
33
|
+
markPrice: assetCtx.markPx,
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import {
|
|
2
|
+
OrderSide,
|
|
3
|
+
OrderStatus,
|
|
4
|
+
OrderType,
|
|
5
|
+
TimeInForce,
|
|
6
|
+
} from '../../../enums.js'
|
|
7
|
+
import type { OpenOrder } from '../../../account.js'
|
|
8
|
+
import type { Order } from '../../../trading.js'
|
|
9
|
+
import type { HlFrontendOpenOrder, HlOrderDetail } from '../types.js'
|
|
10
|
+
|
|
11
|
+
import { resolveAssetIdFromLookup } from './shared.js'
|
|
12
|
+
|
|
13
|
+
export const mapOpenOrder = (
|
|
14
|
+
o: HlFrontendOpenOrder,
|
|
15
|
+
dexKey: string,
|
|
16
|
+
assetIdLookup: Map<string, number>
|
|
17
|
+
): OpenOrder => ({
|
|
18
|
+
id: String(o.oid),
|
|
19
|
+
symbol: o.coin,
|
|
20
|
+
assetId: resolveAssetIdFromLookup(assetIdLookup, o.coin),
|
|
21
|
+
dex: dexKey,
|
|
22
|
+
side: o.side === 'B' ? OrderSide.BUY : OrderSide.SELL,
|
|
23
|
+
type: o.orderType === 'Limit' ? OrderType.LIMIT : OrderType.MARKET,
|
|
24
|
+
size: o.sz,
|
|
25
|
+
price: o.limitPx,
|
|
26
|
+
filledSize: o.origSz
|
|
27
|
+
? (parseFloat(o.origSz) - parseFloat(o.sz)).toString()
|
|
28
|
+
: '0',
|
|
29
|
+
reduceOnly: o.reduceOnly ?? false,
|
|
30
|
+
createdAt: new Date(o.timestamp).toISOString(),
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
const mapOrderStatus = (status: string): OrderStatus => {
|
|
34
|
+
switch (status) {
|
|
35
|
+
case 'open':
|
|
36
|
+
case 'resting':
|
|
37
|
+
return OrderStatus.OPEN
|
|
38
|
+
case 'filled':
|
|
39
|
+
return OrderStatus.FILLED
|
|
40
|
+
case 'canceled':
|
|
41
|
+
case 'cancelled':
|
|
42
|
+
return OrderStatus.CANCELLED
|
|
43
|
+
case 'rejected':
|
|
44
|
+
return OrderStatus.REJECTED
|
|
45
|
+
case 'triggered':
|
|
46
|
+
return OrderStatus.TRIGGERED
|
|
47
|
+
case 'marginCanceled':
|
|
48
|
+
return OrderStatus.CANCELLED
|
|
49
|
+
default:
|
|
50
|
+
return OrderStatus.PENDING
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const mapTimeInForce = (tif: string | undefined): TimeInForce | undefined => {
|
|
55
|
+
switch (tif) {
|
|
56
|
+
case 'Gtc':
|
|
57
|
+
return TimeInForce.GTC
|
|
58
|
+
case 'Ioc':
|
|
59
|
+
return TimeInForce.IOC
|
|
60
|
+
case 'Alo':
|
|
61
|
+
return TimeInForce.POST_ONLY
|
|
62
|
+
default:
|
|
63
|
+
return undefined
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export const mapOrder = (detail: HlOrderDetail): Order => {
|
|
68
|
+
const o = detail.order
|
|
69
|
+
const filled = parseFloat(o.origSz) - parseFloat(o.sz)
|
|
70
|
+
|
|
71
|
+
return {
|
|
72
|
+
orderId: String(o.oid),
|
|
73
|
+
clientOrderId: o.cloid ?? undefined,
|
|
74
|
+
symbol: o.coin,
|
|
75
|
+
side: o.side === 'B' ? OrderSide.BUY : OrderSide.SELL,
|
|
76
|
+
type: o.orderType === 'Limit' ? OrderType.LIMIT : OrderType.MARKET,
|
|
77
|
+
price: o.limitPx,
|
|
78
|
+
originalSize: o.origSz,
|
|
79
|
+
remainingSize: o.sz,
|
|
80
|
+
filledSize: filled.toString(),
|
|
81
|
+
timeInForce: mapTimeInForce(o.tif ?? undefined),
|
|
82
|
+
reduceOnly: o.reduceOnly ?? undefined,
|
|
83
|
+
isTrigger: o.triggerCondition !== undefined && o.triggerCondition !== 'N/A',
|
|
84
|
+
triggerPrice: o.triggerPx ?? undefined,
|
|
85
|
+
status: mapOrderStatus(detail.status),
|
|
86
|
+
createdAt: new Date(o.timestamp).toISOString(),
|
|
87
|
+
updatedAt: new Date(detail.statusTimestamp).toISOString(),
|
|
88
|
+
}
|
|
89
|
+
}
|