This repository has been archived by the owner on Dec 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 76
/
Copy pathcurrency.go
130 lines (116 loc) · 4.6 KB
/
currency.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
package kucoin
import (
"context"
"encoding/json"
"net/http"
)
// A CurrencyModel represents a model of known currency.
type CurrencyModel struct {
Name string `json:"name"`
Currency string `json:"currency"`
FullName string `json:"fullName"`
Precision uint8 `json:"precision"`
Confirms int64 `json:"confirms"`
ContractAddress string `json:"contractAddress"`
WithdrawalMinSize string `json:"withdrawalMinSize"`
WithdrawalMinFee string `json:"withdrawalMinFee"`
IsWithdrawEnabled bool `json:"isWithdrawEnabled"`
IsDepositEnabled bool `json:"isDepositEnabled"`
IsMarginEnabled bool `json:"isMarginEnabled"`
IsDebitEnabled bool `json:"isDebitEnabled"`
}
// A CurrenciesModel is the set of *CurrencyModel.
type CurrenciesModel []*CurrencyModel
// Currencies returns a list of known currencies.
func (as *ApiService) Currencies(ctx context.Context) (*ApiResponse, error) {
req := NewRequest(http.MethodGet, "/api/v1/currencies", nil)
return as.Call(ctx, req)
}
// Currency returns the details of the currency.
// Deprecated: Use CurrencyV2 instead.
func (as *ApiService) Currency(ctx context.Context, currency string, chain string) (*ApiResponse, error) {
params := map[string]string{}
if chain != "" {
params["chain"] = chain
}
req := NewRequest(http.MethodGet, "/api/v1/currencies/"+currency, params)
return as.Call(ctx, req)
}
// ChainsModel Chains Model
type ChainsModel struct {
ChainName string `json:"chainName"`
WithdrawalMinSize string `json:"withdrawalMinSize"`
WithdrawalMinFee string `json:"withdrawalMinFee"`
IsWithdrawEnabled bool `json:"isWithdrawEnabled"`
IsDepositEnabled bool `json:"isDepositEnabled"`
Confirms int64 `json:"confirms"`
ContractAddress string `json:"contractAddress"`
ChainId string `json:"chainId"`
}
// CurrencyV2Model CurrencyV2 Model
type CurrencyV2Model struct {
Name string `json:"name"`
Currency string `json:"currency"`
FullName string `json:"fullName"`
Precision uint8 `json:"precision"`
Confirms int64 `json:"confirms"`
ContractAddress string `json:"contractAddress"`
IsMarginEnabled bool `json:"isMarginEnabled"`
IsDebitEnabled bool `json:"isDebitEnabled"`
Chains []*ChainsModel `json:"chains"`
}
// CurrencyV2 returns the details of the currency.
func (as *ApiService) CurrencyV2(ctx context.Context, currency string, chain string) (*ApiResponse, error) {
params := map[string]string{}
if chain != "" {
params["chain"] = chain
}
req := NewRequest(http.MethodGet, "/api/v2/currencies/"+currency, params)
return as.Call(ctx, req)
}
type PricesModel map[string]string
// Prices returns the fiat prices for currency.
func (as *ApiService) Prices(ctx context.Context, base, currencies string) (*ApiResponse, error) {
params := map[string]string{}
if base != "" {
params["base"] = base
}
if currencies != "" {
params["currencies"] = currencies
}
req := NewRequest(http.MethodGet, "/api/v1/prices", params)
return as.Call(ctx, req)
}
type CurrenciesV3Model []*CurrencyV3Model
type CurrencyV3Model struct {
Currency string `json:"currency"`
Name string `json:"name"`
FullName string `json:"fullName"`
Precision int32 `json:"precision"`
Confirms int32 `json:"confirms"`
ContractAddress string `json:"contractAddress"`
IsMarginEnabled bool `json:"isMarginEnabled"`
IsDebitEnabled bool `json:"isDebitEnabled"`
Chains []struct {
ChainName string `json:"chainName"`
WithdrawalMinFee json.Number `json:"withdrawalMinFee"`
WithdrawalMinSize json.Number `json:"withdrawalMinSize"`
WithdrawFeeRate json.Number `json:"withdrawFeeRate"`
DepositMinSize json.Number `json:"depositMinSize"`
IsWithdrawEnabled bool `json:"isWithdrawEnabled"`
IsDepositEnabled bool `json:"isDepositEnabled"`
PreConfirms int32 `json:"preConfirms"`
ContractAddress string `json:"contractAddress"`
ChainId string `json:"chainId"`
Confirms int32 `json:"confirms"`
} `json:"chains"`
}
func (as *ApiService) CurrenciesV3(ctx context.Context) (*ApiResponse, error) {
req := NewRequest(http.MethodGet, "/api/v3/currencies/", nil)
return as.Call(ctx, req)
}
// CurrencyInfoV3 Request via this endpoint to get the currency details of a specified currency
func (as *ApiService) CurrencyInfoV3(ctx context.Context, currency string) (*ApiResponse, error) {
req := NewRequest(http.MethodGet, "/api/v3/currencies/"+currency, nil)
return as.Call(ctx, req)
}