forked from denkhaus/go-bitshares
/
bitassetdata.go
62 lines (50 loc) · 2.17 KB
/
bitassetdata.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 types
import (
"github.com/iuouiyiuty/bitshares/util"
"github.com/juju/errors"
)
//go:generate ffjson $GOFILE
type BitassetOptions struct {
FeedLifetimeSec UInt32 `json:"feed_lifetime_sec"`
MinimumFeeds UInt8 `json:"minimum_feeds"`
ForceSettlementDelaySec UInt32 `json:"force_settlement_delay_sec"`
ForceSettlementOffsetPercent UInt16 `json:"force_settlement_offset_percent"`
MaximumForceSettlementVolume UInt16 `json:"maximum_force_settlement_volume"`
ShortBackingAsset GrapheneID `json:"short_backing_asset"`
Extensions Extensions `json:"extensions"`
}
func (p BitassetOptions) Marshal(enc *util.TypeEncoder) error {
if err := enc.Encode(p.FeedLifetimeSec); err != nil {
return errors.Annotate(err, "encode FeedLifetimeSec")
}
if err := enc.Encode(p.MinimumFeeds); err != nil {
return errors.Annotate(err, "encode MinimumFeeds")
}
if err := enc.Encode(p.ForceSettlementDelaySec); err != nil {
return errors.Annotate(err, "encode ForceSettlementDelaySec")
}
if err := enc.Encode(p.ForceSettlementOffsetPercent); err != nil {
return errors.Annotate(err, "encode ForceSettlementOffsetPercent")
}
if err := enc.Encode(p.MaximumForceSettlementVolume); err != nil {
return errors.Annotate(err, "encode MaximumForceSettlementVolume")
}
if err := enc.Encode(p.ShortBackingAsset); err != nil {
return errors.Annotate(err, "encode ShortBackingAsset")
}
if err := enc.Encode(p.Extensions); err != nil {
return errors.Annotate(err, "encode Extensions")
}
return nil
}
type BitAssetData struct {
ID GrapheneID `json:"id"`
MembershipExpirationDate Time `json:"current_feed_publication_time"`
IsPredictionMarket bool `json:"is_prediction_market"`
SettlementPrice Price `json:"settlement_price"`
Feeds AssetFeeds `json:"feeds"`
Options BitassetOptions `json:"options"`
CurrentFeed PriceFeed `json:"current_feed"`
ForcedSettledVolume UInt64 `json:"force_settled_volume"`
SettlementFund UInt64 `json:"settlement_fund"`
}