-
-
Notifications
You must be signed in to change notification settings - Fork 283
/
withdraw.go
67 lines (53 loc) · 1.78 KB
/
withdraw.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
package types
import (
"fmt"
"time"
"github.com/c9s/bbgo/pkg/fixedpoint"
)
type Withdraw struct {
GID int64 `json:"gid" db:"gid"`
Exchange ExchangeName `json:"exchange" db:"exchange"`
Asset string `json:"asset" db:"asset"`
Amount fixedpoint.Value `json:"amount" db:"amount"`
Address string `json:"address" db:"address"`
AddressTag string `json:"addressTag"`
Status string `json:"status"`
TransactionID string `json:"transactionID" db:"txn_id"`
TransactionFee fixedpoint.Value `json:"transactionFee" db:"txn_fee"`
TransactionFeeCurrency string `json:"transactionFeeCurrency" db:"txn_fee_currency"`
WithdrawOrderID string `json:"withdrawOrderId"`
ApplyTime Time `json:"applyTime" db:"time"`
Network string `json:"network" db:"network"`
}
func cutstr(s string, maxLen, head, tail int) string {
if len(s) > maxLen {
l := len(s)
return s[0:head] + "..." + s[l-tail:]
}
return s
}
func (w Withdraw) String() (o string) {
o = fmt.Sprintf("%s WITHDRAW %8f %s -> ", w.Exchange, w.Amount.Float64(), w.Asset)
if len(w.Network) > 0 && w.Network != w.Asset {
o += w.Network + ":"
}
o += fmt.Sprintf("%s @ %s", w.Address, w.ApplyTime.Time())
if !w.TransactionFee.IsZero() {
feeCurrency := w.TransactionFeeCurrency
if feeCurrency == "" {
feeCurrency = w.Asset
}
o += fmt.Sprintf(" FEE %4f %5s", w.TransactionFee.Float64(), feeCurrency)
}
if len(w.TransactionID) > 0 {
o += fmt.Sprintf(" TxID: %s", cutstr(w.TransactionID, 12, 4, 4))
}
return o
}
func (w Withdraw) EffectiveTime() time.Time {
return w.ApplyTime.Time()
}
type WithdrawalOptions struct {
Network string
AddressTag string
}