forked from goroumaru/gocryptotrader
/
withdraw_types.go
117 lines (101 loc) · 3.87 KB
/
withdraw_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
package withdraw
import (
"errors"
"time"
"github.com/gofrs/uuid"
"github.com/yurulab/gocryptotrader/common/cache"
"github.com/yurulab/gocryptotrader/currency"
"github.com/yurulab/gocryptotrader/portfolio/banking"
)
// RequestType used for easy matching of int type to Word
type RequestType uint8
const (
// Crypto request type
Crypto RequestType = iota
// Fiat request type
Fiat
// Unknown request type
Unknown
)
const (
// ErrStrAmountMustBeGreaterThanZero message to return when requested amount is less than 0
ErrStrAmountMustBeGreaterThanZero = "amount must be greater than 0"
// ErrStrAddressisInvalid message to return when address is invalid for crypto request
ErrStrAddressisInvalid = "address is not valid"
// ErrStrAddressNotSet message to return when address is empty
ErrStrAddressNotSet = "address cannot be empty"
// ErrStrNoCurrencySet message to return when no currency is set
ErrStrNoCurrencySet = "currency not set"
// ErrStrCurrencyNotCrypto message to return when requested currency is not crypto
ErrStrCurrencyNotCrypto = "requested currency is not a cryptocurrency"
// ErrStrCurrencyNotFiat message to return when requested currency is not fiat
ErrStrCurrencyNotFiat = "requested currency is not fiat"
// ErrStrFeeCannotBeNegative message to return when fee amount is negative
ErrStrFeeCannotBeNegative = "fee amount cannot be negative"
// ErrStrAddressNotWhiteListed message to return when attempting to withdraw to non-whitelisted address
ErrStrAddressNotWhiteListed = "address is not whitelisted for withdrawals"
// ErrStrExchangeNotSupportedByAddress message to return when attemptign to withdraw to an unsupported exchange
ErrStrExchangeNotSupportedByAddress = "address is not supported by exchange"
)
var (
// ErrRequestCannotBeNil message to return when a request is nil
ErrRequestCannotBeNil = errors.New("request cannot be nil")
// ErrInvalidRequest message to return when a request type is invalid
ErrInvalidRequest = errors.New("invalid request type")
// CacheSize cache size to use for withdrawal request history
CacheSize uint64 = 25
// Cache LRU cache for recent requests
Cache = cache.New(CacheSize)
// DryRunID uuid to use for dryruns
DryRunID, _ = uuid.FromString("3e7e2c25-5a0b-429b-95a1-0960079dce56")
)
// CryptoRequest stores the info required for a crypto withdrawal request
type CryptoRequest struct {
Address string
AddressTag string
FeeAmount float64
}
// FiatRequest used for fiat withdrawal requests
type FiatRequest struct {
Bank *banking.Account
IsExpressWire bool
// Intermediary bank information
RequiresIntermediaryBank bool
IntermediaryBankAccountNumber float64
IntermediaryBankName string
IntermediaryBankAddress string
IntermediaryBankCity string
IntermediaryBankCountry string
IntermediaryBankPostalCode string
IntermediarySwiftCode string
IntermediaryBankCode float64
IntermediaryIBAN string
WireCurrency string
}
// Request holds complete details for request
type Request struct {
Exchange string `json:"exchange"`
Currency currency.Code `json:"currency"`
Description string `json:"description"`
Amount float64 `json:"amount"`
Type RequestType `json:"type"`
TradePassword string
OneTimePassword int64
PIN int64
Crypto *CryptoRequest `json:",omitempty"`
Fiat *FiatRequest `json:",omitempty"`
}
// Response holds complete details for Response
type Response struct {
ID uuid.UUID `json:"id"`
Exchange *ExchangeResponse `json:"exchange"`
RequestDetails *Request `json:"request_details"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
// ExchangeResponse holds information returned from an exchange
type ExchangeResponse struct {
Name string `json:"name"`
ID string `json:"id"`
Status string `json:"status"`
}