-
Notifications
You must be signed in to change notification settings - Fork 9
/
types.go
149 lines (128 loc) · 3.81 KB
/
types.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
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
package etherdelta
import (
"math/big"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/graarh/golang-socketio"
"github.com/shopspring/decimal"
)
// OrderBook Order Book struct
type OrderBook struct {
Buys []Order `json:"buys"`
Sells []Order `json:"sells"`
}
// Order Individual order struct
type Order struct {
Id string `json:"id"`
Amount string `json:"amount"`
Price string `json:"price"`
TokenGet string `json:"tokenGet"`
AmountGet string `json:"amountGet"`
TokenGive string `json:"tokenGive"`
AmountGive string `json:"amountGive"`
Expires string `json:"expires"`
Nonce string `json:"nonce"`
V int `json:"v"`
R string `json:"r"`
S string `json:"s"`
User string `json:"user"`
Updated string `json:"updated"`
AvailableVolume string `json:"availableVolume"`
EthAvailableVolume string `json:"ethAvailableVolume"`
AvailableVolumeBase string `json:"availableVolumeBase"`
AmountFilled string `json:"amountFilled"`
}
// OrderPost Order struct for posting a new order to EtherDelta
type OrderPost struct {
AmountGet string `json:"amountGet"`
AmountGive string `json:"amountGive"`
TokenGet string `json:"tokenGet"`
TokenGive string `json:"tokenGive"`
ContractAddress string `json:"contractAddr"`
Expires int `json:"expires"`
Nonce int `json:"nonce"`
User string `json:"user"`
V int `json:"v"`
R string `json:"r"`
S string `json:"s"`
}
// TokenTicker Ticker infor for token
type TokenTicker struct {
Ask *decimal.Decimal `json:"ask"`
BaseVolume *decimal.Decimal `json:"baseVolume"`
Bid *decimal.Decimal `json:"bid"`
Last *decimal.Decimal `json:"last"`
PercentChange *decimal.Decimal `json:"percentChange"`
QuoteVolume *decimal.Decimal `json:"quoteVolume"`
TokenAddress string `json:"tokenAddr"`
}
// GetOrderBookOpts Options for getting order book
type GetOrderBookOpts struct {
TokenAddress string
UserAddress string
}
// GetTokenTickerOpts Options for getting token ticker
type GetTokenTickerOpts struct {
TokenSymbol string
}
// GetTokenPriceOpts Options for getting token price
type GetTokenPriceOpts struct {
TokenSymbol string
}
// GetTokenBalanceOpts Options for getting token balance
type GetTokenBalanceOpts struct {
TokenAddress string
UserAddress string
}
// PostOrderOpts Options for posting an order
type PostOrderOpts struct {
Order *OrderPost
TokenAddress string
UserAddress string
}
// MakeOrderOpts Options for making an order
type MakeOrderOpts struct {
PrivateKey string
TokenAddress string
UserAddress string
Amount *decimal.Decimal
EthCost *decimal.Decimal
}
// CancelOrderOpts Options for cancelling an order
type CancelOrderOpts struct {
PrivateKey string
Order *OrderPost
}
// MakeTrade Options for making a trade
type MakeTradeOpts struct {
Auth *bind.TransactOpts
Order *OrderPost
EthCost *big.Int
}
// DepositEthOpts Options for depositing ETH
type DepositEthOpts struct {
Auth *bind.TransactOpts
}
// WithdrawTokenOpts Options for withdrawing token
type WithdrawTokenOpts struct {
Auth *bind.TransactOpts
TokenAddress string
TokenAmount *big.Int
}
type wsClient struct {
client *gosocketio.Client
}
type wsRequest struct {
EmitTopic string `json:"emitTopic"`
EmitBody *wsEmitBody `json:"emitBody"`
ListenTopic string `json:"listenTopic"`
}
type wsEmitBody struct {
Token string `json:"token"`
User string `json:"user"`
Order *OrderPost `json:"-"` // omit
}
type wsMessage interface{}
type wsResponse struct {
Message wsMessage
Error error
}