-
-
Notifications
You must be signed in to change notification settings - Fork 58
Expand file tree
/
Copy pathws_types_subscriptable.go
More file actions
90 lines (72 loc) · 2.51 KB
/
ws_types_subscriptable.go
File metadata and controls
90 lines (72 loc) · 2.51 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
package hyperliquid
import "github.com/sonirico/vago/fp"
type subscriptable interface {
Key() string
}
type (
Trades []Trade
WsOrders []WsOrder
)
func (t Trades) Key() string {
if len(t) == 0 {
return ""
}
return keyTrades(t[0].Coin)
}
func (a ActiveAssetCtx) Key() string {
return keyActiveAssetCtx(a.Coin)
}
func (c Candle) Key() string {
return keyCandles(c.Symbol, c.Interval)
}
func (c L2Book) Key() string {
return keyL2Book(c.Coin)
}
func (a AllMids) Key() string {
return keyAllMids(fp.None[string]())
}
func (n Notification) Key() 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 ChannelNotification
}
func (w WsOrders) Key() string {
// WsOrder 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 ChannelOrderUpdates
}
func (w WebData2) Key() 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 ChannelWebData2
}
func (w Bbo) Key() string { return keyBbo(w.Coin) }
func (w WsOrderFills) Key() string {
return keyUserFills(w.User)
}
func (c ClearinghouseState) Key() string {
// ClearinghouseState messages are user-specific but don't contain user/dex info in the message itself.
// The dispatching is handled by the subscription system based on the subscription key.
return ChannelClearinghouseState
}
func (c ClearinghouseStateMessage) Key() string {
if c.Dex == "" {
return key(ChannelClearinghouseState, c.User)
}
return key(ChannelClearinghouseState, c.User, c.Dex)
}
func (o OpenOrders) Key() string {
// OpenOrders messages contain user and dex info, but we use the subscription key for dispatching
// The subscription key already includes dex, so we just return a generic key
return ChannelOpenOrders
}
func (t TwapStates) Key() string {
// TwapStates messages contain user and dex info, but we use the subscription key for dispatching
// The subscription key already includes dex, so we just return a generic key
return ChannelTwapStates
}
func (w WebData3) Key() string {
// WebData3 messages are user-specific but don't contain user/dex info in the message itself.
// The dispatching is handled by the subscription system based on the subscription key.
return ChannelWebData3
}