-
Notifications
You must be signed in to change notification settings - Fork 91
/
market.go
62 lines (59 loc) · 1.48 KB
/
market.go
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
package events
// NewMarketPriceUpdateEvent creates a MarketEvent representing an update in the priceWithExponent of a market.
func NewMarketPriceUpdateEvent(
marketId uint32,
priceWithExponent uint64,
) *MarketEventV1 {
priceUpdateEventProto := MarketPriceUpdateEventV1{
PriceWithExponent: priceWithExponent,
}
return &MarketEventV1{
MarketId: marketId,
Event: &MarketEventV1_PriceUpdate{
PriceUpdate: &priceUpdateEventProto,
},
}
}
// NewMarketModifyEvent creates a MarketEvent representing an update to a market.
func NewMarketModifyEvent(
marketId uint32,
pair string,
minPriceChangePpm uint32,
exponent int32,
) *MarketEventV1 {
marketModifyEventProto := MarketModifyEventV1{
Base: &MarketBaseEventV1{
Pair: pair,
MinPriceChangePpm: minPriceChangePpm,
},
Exponent: exponent,
}
marketEventProto := MarketEventV1{
MarketId: marketId,
Event: &MarketEventV1_MarketModify{
MarketModify: &marketModifyEventProto,
},
}
return &marketEventProto
}
// NewMarketCreateEvent creates a MarketEvent representing a new market.
func NewMarketCreateEvent(
marketId uint32,
pair string,
minPriceChangePpm uint32,
exponent int32,
) *MarketEventV1 {
marketCreateEventProto := MarketCreateEventV1{
Base: &MarketBaseEventV1{
Pair: pair,
MinPriceChangePpm: minPriceChangePpm,
},
Exponent: exponent,
}
return &MarketEventV1{
MarketId: marketId,
Event: &MarketEventV1_MarketCreate{
MarketCreate: &marketCreateEventProto,
},
}
}