-
Notifications
You must be signed in to change notification settings - Fork 0
/
market.go
51 lines (45 loc) · 1.34 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
package types
import (
sdk "github.com/cosmos/cosmos-sdk/types"
)
func NewMarket(
uid, creator string,
startTS, endTS uint64,
odds []*Odds,
betConstraints *MarketBetConstraints,
meta string,
bookUID string,
srContributionForHouse sdk.Int,
status MarketStatus,
) Market {
return Market{
UID: uid,
Creator: creator,
StartTS: startTS,
EndTS: endTS,
Odds: odds,
BetConstraints: betConstraints,
Meta: meta,
BookUID: bookUID,
SrContributionForHouse: srContributionForHouse,
Status: status,
}
}
// IsResolved returns true if the market is already resolved.
func (m *Market) IsResolved() bool {
return m.Status == MarketStatus_MARKET_STATUS_RESULT_DECLARED ||
m.Status == MarketStatus_MARKET_STATUS_CANCELED ||
m.Status == MarketStatus_MARKET_STATUS_ABORTED
}
// IsUpdateAllowed returns true if updating the market is allowed.
func (m *Market) IsUpdateAllowed() bool {
return m.isActiveOrInactive()
}
// IsResolveAllowed returns true if resolving the market is allowed.
func (m *Market) IsResolveAllowed() bool {
return m.isActiveOrInactive()
}
func (m *Market) isActiveOrInactive() bool {
return m.Status == MarketStatus_MARKET_STATUS_ACTIVE ||
m.Status == MarketStatus_MARKET_STATUS_INACTIVE
}