forked from sonirico/go-hyperliquid
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathws_utils.go
More file actions
92 lines (75 loc) · 2.48 KB
/
ws_utils.go
File metadata and controls
92 lines (75 loc) · 2.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
package hyperliquid
import (
"strings"
"github.com/sonirico/vago/fp"
)
func key(args ...string) string {
return strings.Join(args, ":")
}
func keyTrades(coin string) string {
return key(ChannelTrades, coin)
}
func keyActiveAssetCtx(coin string) string {
return key(ChannelActiveAssetCtx, coin)
}
func keyCandles(symbol, interval string) string {
return key(ChannelCandle, symbol, interval)
}
func keyL2Book(coin string) string {
return key(ChannelL2Book, coin)
}
func keyAllMids(_ fp.Option[string]) string {
// Unfortunately, "dex" parameter is not returned neither in subscription ACK nor in the
// allMids message, no we are rendered unable to distinguish between different DEXes from
// subscriber's standpoint.
// if dex.IsNone() {
// return key(ChannelAllMids)
// }
// return key(ChannelAllMids, dex.UnwrapUnsafe())
return key(ChannelAllMids)
}
func keyNotification(_ string) string {
// Notification messages are user-specific but don't contain user info in the message itself.
// The dispatching is handled by the subscription system based on the subscription key.
return key(ChannelNotification)
}
func keyOrderUpdates(_ string) string {
// Order updates are user-specific but don't contain user info in the message itself.
// The dispatching is handled by the subscription system based on the subscription key.
return key(ChannelOrderUpdates)
}
func keyUserFills(user string) string {
return key(ChannelUserFills, user)
}
func keyWebData2(_ string) string {
// WebData2 messages are user-specific but don't contain user info in the message itself.
// The dispatching is handled by the subscription system based on the subscription key.
return key(ChannelWebData2)
}
func keyBbo(coin string) string {
return key(ChannelBbo, coin)
}
func keyClearinghouseState(user string, dex fp.Option[string]) string {
if dex.IsNone() {
return key(ChannelClearinghouseState, user)
}
return key(ChannelClearinghouseState, user, dex.UnwrapUnsafe())
}
func keyOpenOrders(user string, dex fp.Option[string]) string {
if dex.IsNone() {
return key(ChannelOpenOrders, user)
}
return key(ChannelOpenOrders, user, dex.UnwrapUnsafe())
}
func keyTwapStates(user string, dex fp.Option[string]) string {
if dex.IsNone() {
return key(ChannelTwapStates, user)
}
return key(ChannelTwapStates, user, dex.UnwrapUnsafe())
}
func keyWebData3(user string, dex fp.Option[string]) string {
if dex.IsNone() {
return key(ChannelWebData3, user)
}
return key(ChannelWebData3, user, dex.UnwrapUnsafe())
}