build/linters: Bump Go to v1.25 and golangci-lint to v2.4.0 (#2005)

* build/linters: Bump Go to v1.25 and golangci-lint to v2.4.0

* refactor: Update TODO comments for net.Listen and net.DialTimeout; improve variable naming in websocket and exchange methods

* refactor: Rename massageMissingData to backfillMissingData for clarity and update references in RSI and MFI calculations

* fix: Correct typo in TODO comment for net.Listen in RPC server
This commit is contained in:
Adrian Gallagher
2025-08-20 11:55:15 +10:00
committed by GitHub
parent 7879633c4a
commit 7ebc392532
63 changed files with 498 additions and 647 deletions

View File

@@ -1033,9 +1033,9 @@ func (e *Exchange) WithdrawHistory(ctx context.Context, c currency.Code, status
}
// GetDepositAddressForCurrency retrieves the wallet address for a given currency
func (e *Exchange) GetDepositAddressForCurrency(ctx context.Context, currency, chain string) (*DepositAddress, error) {
func (e *Exchange) GetDepositAddressForCurrency(ctx context.Context, coin, chain string) (*DepositAddress, error) {
params := url.Values{}
params.Set("coin", currency)
params.Set("coin", coin)
if chain != "" {
params.Set("network", chain)
}

View File

@@ -2256,7 +2256,7 @@ func TestWsOCO(t *testing.T) {
}
func TestGetWsAuthStreamKey(t *testing.T) {
key, err := e.GetWsAuthStreamKey(t.Context())
authKey, err := e.GetWsAuthStreamKey(t.Context())
switch {
case mockTests && err != nil,
!mockTests && sharedtestvalues.AreAPICredentialsSet(e) && err != nil:
@@ -2265,7 +2265,7 @@ func TestGetWsAuthStreamKey(t *testing.T) {
t.Fatal("Expected error")
}
if key == "" && (sharedtestvalues.AreAPICredentialsSet(e) || mockTests) {
if authKey == "" && (sharedtestvalues.AreAPICredentialsSet(e) || mockTests) {
t.Error("Expected key")
}
}

View File

@@ -663,7 +663,7 @@ func (e *Exchange) GetTradeFee(ctx context.Context, recvWindow uint64, symbol st
//
// INPUTS:
// asset: string , startTime & endTime unix time in Milli seconds, recvWindow(duration in milli seconds > 2000 to < 6000)
func (e *Exchange) GetAssetDistributionHistory(ctx context.Context, asset string, startTime, endTime int64, recvWindow uint64) (*AssetDistributionHistories, error) {
func (e *Exchange) GetAssetDistributionHistory(ctx context.Context, a string, startTime, endTime int64, recvWindow uint64) (*AssetDistributionHistories, error) {
params := url.Values{}
timestamp := time.Now().UnixMilli()
var resp AssetDistributionHistories
@@ -683,8 +683,8 @@ func (e *Exchange) GetAssetDistributionHistory(ctx context.Context, asset string
params.Set("recvWindow", strconv.FormatUint(recvWindow, 10))
}
if asset != "" {
params.Set("asset", asset)
if a != "" {
params.Set("asset", a)
}
return &resp, e.SendAuthHTTPRequest(ctx,
exchange.RestSpotSupplementary,
@@ -1498,12 +1498,12 @@ func (e *Exchange) WithdrawFiat(ctx context.Context, arg *WithdrawFiatRequestPar
*/
// GetDepositAddressForCurrency retrieves the wallet address for a given currency
func (e *Exchange) GetDepositAddressForCurrency(ctx context.Context, currency, chain string) (*DepositAddress, error) {
func (e *Exchange) GetDepositAddressForCurrency(ctx context.Context, coin, chain string) (*DepositAddress, error) {
params := url.Values{}
if currency == "" {
if coin == "" {
return nil, errMissingRequiredArgumentCoin
}
params.Set("coin", currency)
params.Set("coin", coin)
if chain != "" {
params.Set("network", chain)
}
@@ -1515,11 +1515,11 @@ func (e *Exchange) GetDepositAddressForCurrency(ctx context.Context, currency, c
// DepositHistory returns the deposit history based on the supplied params
// status `param` used as string to prevent default value 0 (for int) interpreting as EmailSent status
func (e *Exchange) DepositHistory(ctx context.Context, c currency.Code, status uint8, startTime, endTime time.Time, offset, limit int) ([]DepositHistory, error) {
func (e *Exchange) DepositHistory(ctx context.Context, coin currency.Code, status uint8, startTime, endTime time.Time, offset, limit int) ([]DepositHistory, error) {
var response []DepositHistory
params := url.Values{}
if !c.IsEmpty() {
params.Set("coin", c.String())
if !coin.IsEmpty() {
params.Set("coin", coin.String())
}
if status > 0 {

View File

@@ -402,7 +402,7 @@ func (e *Exchange) GetV2Balances(ctx context.Context) ([]WalletDataV2, error) {
if !ok {
return resp, common.GetTypeAssertError("string", data[x][0], "Wallets.WalletType")
}
currency, ok := data[x][1].(string)
ccy, ok := data[x][1].(string)
if !ok {
return resp, common.GetTypeAssertError("string", data[x][1], "Wallets.Currency")
}
@@ -416,7 +416,7 @@ func (e *Exchange) GetV2Balances(ctx context.Context) ([]WalletDataV2, error) {
}
resp[x] = WalletDataV2{
WalletType: walletType,
Currency: currency,
Currency: ccy,
Balance: balance,
UnsettledInterest: unsettledInterest,
}
@@ -500,10 +500,9 @@ func (e *Exchange) GetSiteInfoConfigData(ctx context.Context, assetType asset.It
default:
return nil, fmt.Errorf("invalid asset type for GetSiteInfoConfigData: %s", assetType)
}
url := bitfinexAPIVersion2 + path
var resp [][][]any
err := e.SendHTTPRequest(ctx, exchange.RestSpot, url, &resp, status)
var resp [][][]any
err := e.SendHTTPRequest(ctx, exchange.RestSpot, bitfinexAPIVersion2+path, &resp, status)
if err != nil {
return nil, err
}
@@ -1231,11 +1230,11 @@ func (e *Exchange) GetAccountBalance(ctx context.Context) ([]Balance, error) {
// Currency - example "BTC"
// WalletFrom - example "exchange"
// WalletTo - example "deposit"
func (e *Exchange) WalletTransfer(ctx context.Context, amount float64, currency, walletFrom, walletTo string) (WalletTransfer, error) {
func (e *Exchange) WalletTransfer(ctx context.Context, amount float64, ccy, walletFrom, walletTo string) (WalletTransfer, error) {
var response []WalletTransfer
req := make(map[string]any)
req["amount"] = strconv.FormatFloat(amount, 'f', -1, 64)
req["currency"] = currency
req["currency"] = ccy
req["walletfrom"] = walletFrom
req["walletto"] = walletTo

View File

@@ -412,15 +412,15 @@ func (e *Exchange) PlaceTrade(ctx context.Context, orderCurrency, transactionTyp
//
// orderID: Order number registered for purchase/sales
// transactionType: Transaction type(bid : purchase, ask : sales)
// currency: BTC, ETH, DASH, LTC, ETC, XRP, BCH, XMR, ZEC, QTUM, BTG, EOS
// ccy: BTC, ETH, DASH, LTC, ETC, XRP, BCH, XMR, ZEC, QTUM, BTG, EOS
// (default value: BTC)
func (e *Exchange) GetOrderDetails(ctx context.Context, orderID, transactionType, currency string) (OrderDetails, error) {
func (e *Exchange) GetOrderDetails(ctx context.Context, orderID, transactionType, ccy string) (OrderDetails, error) {
response := OrderDetails{}
params := url.Values{}
params.Set("order_id", strings.ToUpper(orderID))
params.Set("type", transactionType)
params.Set("currency", strings.ToUpper(currency))
params.Set("currency", strings.ToUpper(ccy))
return response,
e.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, privateOrderDetail, params, &response)
@@ -429,15 +429,15 @@ func (e *Exchange) GetOrderDetails(ctx context.Context, orderID, transactionType
// CancelTrade cancels a customer purchase/sales transaction
// transactionType: Transaction type(bid : purchase, ask : sales)
// orderID: Order number registered for purchase/sales
// currency: BTC, ETH, DASH, LTC, ETC, XRP, BCH, XMR, ZEC, QTUM, BTG, EOS
// ccy: BTC, ETH, DASH, LTC, ETC, XRP, BCH, XMR, ZEC, QTUM, BTG, EOS
// (default value: BTC)
func (e *Exchange) CancelTrade(ctx context.Context, transactionType, orderID, currency string) (ActionStatus, error) {
func (e *Exchange) CancelTrade(ctx context.Context, transactionType, orderID, ccy string) (ActionStatus, error) {
response := ActionStatus{}
params := url.Values{}
params.Set("order_id", strings.ToUpper(orderID))
params.Set("type", strings.ToUpper(transactionType))
params.Set("currency", strings.ToUpper(currency))
params.Set("currency", strings.ToUpper(ccy))
return response,
e.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, privateCancelTrade, nil, &response)
@@ -451,7 +451,7 @@ func (e *Exchange) CancelTrade(ctx context.Context, transactionType, orderID, cu
// currency: BTC, ETH, DASH, LTC, ETC, XRP, BCH, XMR, ZEC, QTUM
// (default value: BTC)
// units: Quantity to withdraw currency
func (e *Exchange) WithdrawCrypto(ctx context.Context, address, destination, currency string, units float64) (ActionStatus, error) {
func (e *Exchange) WithdrawCrypto(ctx context.Context, address, destination, ccy string, units float64) (ActionStatus, error) {
response := ActionStatus{}
params := url.Values{}
@@ -459,7 +459,7 @@ func (e *Exchange) WithdrawCrypto(ctx context.Context, address, destination, cur
if destination != "" {
params.Set("destination", destination)
}
params.Set("currency", strings.ToUpper(currency))
params.Set("currency", strings.ToUpper(ccy))
params.Set("units", strconv.FormatFloat(units, 'f', -1, 64))
return response,

View File

@@ -735,13 +735,10 @@ func (e *Exchange) UserLogOutAll(ctx context.Context) (int64, error) {
}
// GetUserMargin returns user margin information
func (e *Exchange) GetUserMargin(ctx context.Context, currency string) (UserMargin, error) {
func (e *Exchange) GetUserMargin(ctx context.Context, ccy string) (UserMargin, error) {
var info UserMargin
return info, e.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, http.MethodGet,
bitmexEndpointUserMargin,
UserCurrencyParams{Currency: currency},
&info)
params := UserCurrencyParams{Currency: ccy}
return info, e.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, http.MethodGet, bitmexEndpointUserMargin, params, &info)
}
// GetAllUserMargin returns user margin information
@@ -755,13 +752,10 @@ func (e *Exchange) GetAllUserMargin(ctx context.Context) ([]UserMargin, error) {
}
// GetMinimumWithdrawalFee returns minimum withdrawal fee information
func (e *Exchange) GetMinimumWithdrawalFee(ctx context.Context, currency string) (MinWithdrawalFee, error) {
func (e *Exchange) GetMinimumWithdrawalFee(ctx context.Context, ccy string) (MinWithdrawalFee, error) {
var fee MinWithdrawalFee
return fee, e.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, http.MethodGet,
bitmexEndpointUserMinWithdrawalFee,
UserCurrencyParams{Currency: currency},
&fee)
params := UserCurrencyParams{Currency: ccy}
return fee, e.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, http.MethodGet, bitmexEndpointUserMinWithdrawalFee, params, &fee)
}
// GetUserPreferences returns user preferences
@@ -797,13 +791,10 @@ func (e *Exchange) UserRequestWithdrawal(ctx context.Context, params UserRequest
}
// GetWalletInfo returns user wallet information
func (e *Exchange) GetWalletInfo(ctx context.Context, currency string) (WalletInfo, error) {
func (e *Exchange) GetWalletInfo(ctx context.Context, ccy string) (WalletInfo, error) {
var info WalletInfo
if err := e.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, http.MethodGet,
bitmexEndpointUserWallet,
UserCurrencyParams{Currency: currency},
&info); err != nil {
params := UserCurrencyParams{Currency: ccy}
if err := e.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, http.MethodGet, bitmexEndpointUserWallet, params, &info); err != nil {
return info, err
}
@@ -818,23 +809,17 @@ func (e *Exchange) GetWalletInfo(ctx context.Context, currency string) (WalletIn
}
// GetWalletHistory returns user wallet history transaction data
func (e *Exchange) GetWalletHistory(ctx context.Context, currency string) ([]TransactionInfo, error) {
func (e *Exchange) GetWalletHistory(ctx context.Context, ccy string) ([]TransactionInfo, error) {
var info []TransactionInfo
return info, e.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, http.MethodGet,
bitmexEndpointUserWalletHistory,
UserCurrencyParams{Currency: currency},
&info)
params := UserCurrencyParams{Currency: ccy}
return info, e.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, http.MethodGet, bitmexEndpointUserWalletHistory, params, &info)
}
// GetWalletSummary returns user wallet summary
func (e *Exchange) GetWalletSummary(ctx context.Context, currency string) ([]TransactionInfo, error) {
func (e *Exchange) GetWalletSummary(ctx context.Context, ccy string) ([]TransactionInfo, error) {
var info []TransactionInfo
return info, e.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, http.MethodGet,
bitmexEndpointUserWalletSummary,
UserCurrencyParams{Currency: currency},
&info)
params := UserCurrencyParams{Currency: ccy}
return info, e.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, http.MethodGet, bitmexEndpointUserWalletSummary, params, &info)
}
// SendHTTPRequest sends an unauthenticated HTTP request

View File

@@ -155,28 +155,27 @@ func getInternationalBankDepositFee(amount float64) float64 {
}
// GetTicker returns ticker information
func (e *Exchange) GetTicker(ctx context.Context, currency string, hourly bool) (*Ticker, error) {
func (e *Exchange) GetTicker(ctx context.Context, symbol string, hourly bool) (*Ticker, error) {
response := Ticker{}
tickerEndpoint := bitstampAPITicker
if hourly {
tickerEndpoint = bitstampAPITickerHourly
}
path := "/v" + bitstampAPIVersion + "/" + tickerEndpoint + "/" + strings.ToLower(currency) + "/"
path := "/v" + bitstampAPIVersion + "/" + tickerEndpoint + "/" + strings.ToLower(symbol) + "/"
return &response, e.SendHTTPRequest(ctx, exchange.RestSpot, path, &response)
}
// GetOrderbook Returns a JSON dictionary with "bids" and "asks". Each is a list
// of open orders and each order is represented as a list holding the price and
// the amount.
func (e *Exchange) GetOrderbook(ctx context.Context, currency string) (*Orderbook, error) {
func (e *Exchange) GetOrderbook(ctx context.Context, symbol string) (*Orderbook, error) {
type response struct {
Timestamp types.Time `json:"timestamp"`
Bids [][2]types.Number `json:"bids"`
Asks [][2]types.Number `json:"asks"`
}
path := "/v" + bitstampAPIVersion + "/" + bitstampAPIOrderbook + "/" + strings.ToLower(currency) + "/"
path := "/v" + bitstampAPIVersion + "/" + bitstampAPIOrderbook + "/" + strings.ToLower(symbol) + "/"
var resp response
err := e.SendHTTPRequest(ctx, exchange.RestSpot, path, &resp)
if err != nil {
@@ -379,60 +378,51 @@ func (e *Exchange) CryptoWithdrawal(ctx context.Context, amount float64, address
}
// OpenBankWithdrawal Opens a bank withdrawal request (SEPA or international)
func (e *Exchange) OpenBankWithdrawal(ctx context.Context, amount float64, currency,
name, iban, bic, address, postalCode, city, country,
comment, withdrawalType string,
) (FIATWithdrawalResponse, error) {
req := url.Values{}
req.Add("amount", strconv.FormatFloat(amount, 'f', -1, 64))
req.Add("account_currency", currency)
req.Add("name", name)
req.Add("iban", iban)
req.Add("bic", bic)
req.Add("address", address)
req.Add("postal_code", postalCode)
req.Add("city", city)
req.Add("country", country)
req.Add("type", withdrawalType)
req.Add("comment", comment)
func (e *Exchange) OpenBankWithdrawal(ctx context.Context, req *OpenBankWithdrawalRequest) (FIATWithdrawalResponse, error) {
v := url.Values{}
v.Add("amount", strconv.FormatFloat(req.Amount, 'f', -1, 64))
v.Add("account_currency", req.Currency.String())
v.Add("name", req.Name)
v.Add("iban", req.IBAN)
v.Add("bic", req.BIC)
v.Add("address", req.Address)
v.Add("postal_code", req.PostalCode)
v.Add("city", req.City)
v.Add("country", req.Country)
v.Add("type", req.WithdrawalType)
v.Add("comment", req.Comment)
resp := FIATWithdrawalResponse{}
return resp, e.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, bitstampAPIOpenWithdrawal, true, req, &resp)
return resp, e.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, bitstampAPIOpenWithdrawal, true, v, &resp)
}
// OpenInternationalBankWithdrawal Opens a bank withdrawal request (international)
func (e *Exchange) OpenInternationalBankWithdrawal(ctx context.Context, amount float64, currency,
name, iban, bic, address, postalCode, city, country,
bankName, bankAddress, bankPostCode, bankCity, bankCountry, internationalCurrency,
comment, withdrawalType string,
) (FIATWithdrawalResponse, error) {
req := url.Values{}
req.Add("amount", strconv.FormatFloat(amount, 'f', -1, 64))
req.Add("account_currency", currency)
req.Add("name", name)
req.Add("iban", iban)
req.Add("bic", bic)
req.Add("address", address)
req.Add("postal_code", postalCode)
req.Add("city", city)
req.Add("country", country)
req.Add("type", withdrawalType)
req.Add("comment", comment)
req.Add("currency", internationalCurrency)
req.Add("bank_name", bankName)
req.Add("bank_address", bankAddress)
req.Add("bank_postal_code", bankPostCode)
req.Add("bank_city", bankCity)
req.Add("bank_country", bankCountry)
func (e *Exchange) OpenInternationalBankWithdrawal(ctx context.Context, req *OpenBankWithdrawalRequest) (FIATWithdrawalResponse, error) {
v := url.Values{}
v.Add("amount", strconv.FormatFloat(req.Amount, 'f', -1, 64))
v.Add("account_currency", req.Currency.String())
v.Add("name", req.Name)
v.Add("iban", req.IBAN)
v.Add("bic", req.BIC)
v.Add("address", req.Address)
v.Add("postal_code", req.PostalCode)
v.Add("city", req.City)
v.Add("country", req.Country)
v.Add("type", req.WithdrawalType)
v.Add("comment", req.Comment)
v.Add("currency", req.InternationalCurrency)
v.Add("bank_name", req.BankName)
v.Add("bank_address", req.BankAddress)
v.Add("bank_postal_code", req.BankPostalCode)
v.Add("bank_city", req.BankCity)
v.Add("bank_country", req.BankCountry)
resp := FIATWithdrawalResponse{}
return resp, e.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, bitstampAPIOpenWithdrawal, true, req, &resp)
return resp, e.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, bitstampAPIOpenWithdrawal, true, v, &resp)
}
// GetCryptoDepositAddress returns a depositing address by crypto.
// crypto - example "btc", "ltc", "eth", "xrp" or "bch"
func (e *Exchange) GetCryptoDepositAddress(ctx context.Context, crypto currency.Code) (*DepositAddress, error) {
path := crypto.Lower().String() + "_address"
// c - example "btc", "ltc", "eth", "xrp" or "bch"
func (e *Exchange) GetCryptoDepositAddress(ctx context.Context, c currency.Code) (*DepositAddress, error) {
path := c.Lower().String() + "_address"
var resp DepositAddress
return &resp, e.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, path, true, nil, &resp)
}
@@ -446,7 +436,7 @@ func (e *Exchange) GetUnconfirmedBitcoinDeposits(ctx context.Context) ([]Unconfi
}
// OHLC returns OHLCV data for step (interval)
func (e *Exchange) OHLC(ctx context.Context, currency string, start, end time.Time, step, limit string) (resp OHLCResponse, err error) {
func (e *Exchange) OHLC(ctx context.Context, symbol string, start, end time.Time, step, limit string) (resp OHLCResponse, err error) {
v := url.Values{}
v.Add("limit", limit)
v.Add("step", step)
@@ -460,7 +450,7 @@ func (e *Exchange) OHLC(ctx context.Context, currency string, start, end time.Ti
if !end.IsZero() {
v.Add("end", strconv.FormatInt(end.Unix(), 10))
}
return resp, e.SendHTTPRequest(ctx, exchange.RestSpot, common.EncodeURLValues("/v"+bitstampAPIVersion+"/"+bitstampAPIOHLC+"/"+currency, v), &resp)
return resp, e.SendHTTPRequest(ctx, exchange.RestSpot, common.EncodeURLValues("/v"+bitstampAPIVersion+"/"+bitstampAPIOHLC+"/"+symbol, v), &resp)
}
// TransferAccountBalance transfers funds from either a main or sub account
@@ -468,10 +458,10 @@ func (e *Exchange) OHLC(ctx context.Context, currency string, start, end time.Ti
// currency - which currency to transfer
// subaccount - name of account
// toMain - bool either to or from account
func (e *Exchange) TransferAccountBalance(ctx context.Context, amount float64, currency, subAccount string, toMain bool) error {
func (e *Exchange) TransferAccountBalance(ctx context.Context, amount float64, ccy, subAccount string, toMain bool) error {
req := url.Values{}
req.Add("amount", strconv.FormatFloat(amount, 'f', -1, 64))
req.Add("currency", currency)
req.Add("currency", ccy)
if subAccount == "" {
return errors.New("missing subAccount parameter")

View File

@@ -180,6 +180,29 @@ type CryptoWithdrawalResponse struct {
ID int64 `json:"withdrawal_id"`
}
// OpenBankWithdrawalRequest holds the request information for sending a bank withdrawal request
type OpenBankWithdrawalRequest struct {
Amount float64
Currency currency.Code
Name string
IBAN string
BIC string
Address string
PostalCode string
City string
Country string
WithdrawalType string
Comment string
// International bank account details
InternationalCurrency string
BankName string
BankAddress string
BankPostalCode string
BankCity string
BankCountry string
}
// FIATWithdrawalResponse response from a fiat withdrawal request
type FIATWithdrawalResponse struct {
ID int64 `json:"withdrawal_id"`

View File

@@ -583,18 +583,20 @@ func (e *Exchange) WithdrawFiatFunds(ctx context.Context, withdrawRequest *withd
if err := withdrawRequest.Validate(); err != nil {
return nil, err
}
resp, err := e.OpenBankWithdrawal(ctx,
withdrawRequest.Amount,
withdrawRequest.Currency.String(),
withdrawRequest.Fiat.Bank.AccountName,
withdrawRequest.Fiat.Bank.IBAN,
withdrawRequest.Fiat.Bank.SWIFTCode,
withdrawRequest.Fiat.Bank.BankAddress,
withdrawRequest.Fiat.Bank.BankPostalCode,
withdrawRequest.Fiat.Bank.BankPostalCity,
withdrawRequest.Fiat.Bank.BankCountry,
withdrawRequest.Description,
sepaWithdrawal)
resp, err := e.OpenBankWithdrawal(ctx, &OpenBankWithdrawalRequest{
Amount: withdrawRequest.Amount,
Currency: withdrawRequest.Currency,
Name: withdrawRequest.Fiat.Bank.AccountName,
IBAN: withdrawRequest.Fiat.Bank.IBAN,
BIC: withdrawRequest.Fiat.Bank.SWIFTCode,
Address: withdrawRequest.Fiat.Bank.BankAddress,
PostalCode: withdrawRequest.Fiat.Bank.BankPostalCode,
City: withdrawRequest.Fiat.Bank.BankPostalCity,
Country: withdrawRequest.Fiat.Bank.BankCountry,
Comment: withdrawRequest.Description,
WithdrawalType: sepaWithdrawal,
})
if err != nil {
return nil, err
}
@@ -610,24 +612,25 @@ func (e *Exchange) WithdrawFiatFundsToInternationalBank(ctx context.Context, wit
if err := withdrawRequest.Validate(); err != nil {
return nil, err
}
resp, err := e.OpenInternationalBankWithdrawal(ctx,
withdrawRequest.Amount,
withdrawRequest.Currency.String(),
withdrawRequest.Fiat.Bank.AccountName,
withdrawRequest.Fiat.Bank.IBAN,
withdrawRequest.Fiat.Bank.SWIFTCode,
withdrawRequest.Fiat.Bank.BankAddress,
withdrawRequest.Fiat.Bank.BankPostalCode,
withdrawRequest.Fiat.Bank.BankPostalCity,
withdrawRequest.Fiat.Bank.BankCountry,
withdrawRequest.Fiat.IntermediaryBankName,
withdrawRequest.Fiat.IntermediaryBankAddress,
withdrawRequest.Fiat.IntermediaryBankPostalCode,
withdrawRequest.Fiat.IntermediaryBankCity,
withdrawRequest.Fiat.IntermediaryBankCountry,
withdrawRequest.Fiat.WireCurrency,
withdrawRequest.Description,
internationalWithdrawal)
resp, err := e.OpenInternationalBankWithdrawal(ctx, &OpenBankWithdrawalRequest{
Amount: withdrawRequest.Amount,
Currency: withdrawRequest.Currency,
Name: withdrawRequest.Fiat.Bank.AccountName,
IBAN: withdrawRequest.Fiat.Bank.IBAN,
BIC: withdrawRequest.Fiat.Bank.SWIFTCode,
Address: withdrawRequest.Fiat.Bank.BankAddress,
PostalCode: withdrawRequest.Fiat.Bank.BankPostalCode,
City: withdrawRequest.Fiat.Bank.BankPostalCity,
Country: withdrawRequest.Fiat.Bank.BankCountry,
BankName: withdrawRequest.Fiat.IntermediaryBankName,
BankAddress: withdrawRequest.Fiat.IntermediaryBankAddress,
BankPostalCode: withdrawRequest.Fiat.IntermediaryBankPostalCode,
BankCity: withdrawRequest.Fiat.IntermediaryBankCity,
BankCountry: withdrawRequest.Fiat.IntermediaryBankCountry,
InternationalCurrency: withdrawRequest.Fiat.WireCurrency,
Comment: withdrawRequest.Description,
WithdrawalType: internationalWithdrawal,
})
if err != nil {
return nil, err
}

View File

@@ -212,22 +212,20 @@ func (e *Exchange) GetWalletHistory(ctx context.Context, symbol string, start, e
}
// GetWalletAddress returns the users account balance
func (e *Exchange) GetWalletAddress(ctx context.Context, currency string) (WalletAddress, error) {
func (e *Exchange) GetWalletAddress(ctx context.Context, ccy string) (WalletAddress, error) {
var resp WalletAddress
urlValues := url.Values{}
if currency != "" {
urlValues.Add("currency", currency)
if ccy != "" {
urlValues.Add("currency", ccy)
}
return resp, e.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, http.MethodGet, btseWalletAddress, true, urlValues, nil, &resp, queryFunc)
}
// CreateWalletAddress create new deposit address for requested currency
func (e *Exchange) CreateWalletAddress(ctx context.Context, currency string) (WalletAddress, error) {
func (e *Exchange) CreateWalletAddress(ctx context.Context, ccy string) (WalletAddress, error) {
var resp WalletAddress
req := make(map[string]any, 1)
req["currency"] = currency
req["currency"] = ccy
err := e.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, http.MethodPost, btseWalletAddress, true, nil, req, &resp, queryFunc)
if err != nil {
errResp := ErrorResponse{}
@@ -251,10 +249,10 @@ func (e *Exchange) CreateWalletAddress(ctx context.Context, currency string) (Wa
}
// WalletWithdrawal submit request to withdraw crypto currency
func (e *Exchange) WalletWithdrawal(ctx context.Context, currency, address, tag, amount string) (WithdrawalResponse, error) {
func (e *Exchange) WalletWithdrawal(ctx context.Context, ccy, address, tag, amount string) (WithdrawalResponse, error) {
var resp WithdrawalResponse
req := make(map[string]any, 4)
req["currency"] = currency
req["currency"] = ccy
req["address"] = address
req["tag"] = tag
req["amount"] = amount

View File

@@ -1245,10 +1245,10 @@ func (e *Exchange) UpgradeToUnifiedAccount(ctx context.Context) (*UnifiedAccount
}
// GetBorrowHistory retrieves interest records, sorted in reverse order of creation time.
func (e *Exchange) GetBorrowHistory(ctx context.Context, currency, cursor string, startTime, endTime time.Time, limit int64) (*BorrowHistory, error) {
func (e *Exchange) GetBorrowHistory(ctx context.Context, ccy, cursor string, startTime, endTime time.Time, limit int64) (*BorrowHistory, error) {
params := url.Values{}
if currency != "" {
params.Set("currency", currency)
if ccy != "" {
params.Set("currency", ccy)
}
if cursor != "" {
params.Set("cursor", cursor)
@@ -1286,10 +1286,10 @@ func (e *Exchange) SetCollateralCoin(ctx context.Context, coin currency.Code, co
// GetCollateralInfo retrieves the collateral information of the current unified margin account,
// including loan interest rate, loanable amount, collateral conversion rate,
// whether it can be mortgaged as margin, etc.
func (e *Exchange) GetCollateralInfo(ctx context.Context, currency string) (*CollateralInfo, error) {
func (e *Exchange) GetCollateralInfo(ctx context.Context, ccy string) (*CollateralInfo, error) {
params := url.Values{}
if currency != "" {
params.Set("currency", currency)
if ccy != "" {
params.Set("currency", ccy)
}
var resp *CollateralInfo
return resp, e.SendAuthHTTPRequestV5(ctx, exchange.RestSpot, http.MethodGet, "/v5/account/collateral-info", params, nil, &resp, defaultEPL)
@@ -2157,13 +2157,13 @@ func (e *Exchange) SetSpotMarginTradeLeverage(ctx context.Context, leverage floa
}
// GetVIPMarginData retrieves public VIP Margin data
func (e *Exchange) GetVIPMarginData(ctx context.Context, vipLevel, currency string) (*VIPMarginData, error) {
func (e *Exchange) GetVIPMarginData(ctx context.Context, vipLevel, ccy string) (*VIPMarginData, error) {
params := url.Values{}
if vipLevel != "" {
params.Set("vipLevel", vipLevel)
}
if currency != "" {
params.Set("currency", currency)
if ccy != "" {
params.Set("currency", ccy)
}
var resp *VIPMarginData
return resp, e.SendHTTPRequest(ctx, exchange.RestSpot, "spot-cross-margin-trade/data", defaultEPL, &resp)

View File

@@ -442,12 +442,12 @@ func (e *Exchange) GetFills(ctx context.Context, orderID, currencyPair string) (
// transferType - either "deposit" or "withdraw"
// profileID - The id of the margin profile to deposit or withdraw from
// currency - currency to transfer, currently on "BTC" or "USD"
func (e *Exchange) MarginTransfer(ctx context.Context, amount float64, transferType, profileID, currency string) (MarginTransfer, error) {
func (e *Exchange) MarginTransfer(ctx context.Context, amount float64, transferType, profileID, ccy string) (MarginTransfer, error) {
resp := MarginTransfer{}
req := make(map[string]any)
req["type"] = transferType
req["amount"] = strconv.FormatFloat(amount, 'f', -1, 64)
req["currency"] = currency
req["currency"] = ccy
req["margin_profile_id"] = profileID
return resp,
@@ -487,11 +487,11 @@ func (e *Exchange) GetPayMethods(ctx context.Context) ([]PaymentMethod, error) {
// amount - The amount to deposit
// currency - The type of currency
// paymentID - ID of the payment method
func (e *Exchange) DepositViaPaymentMethod(ctx context.Context, amount float64, currency, paymentID string) (DepositWithdrawalInfo, error) {
func (e *Exchange) DepositViaPaymentMethod(ctx context.Context, amount float64, ccy, paymentID string) (DepositWithdrawalInfo, error) {
resp := DepositWithdrawalInfo{}
req := make(map[string]any)
req["amount"] = amount
req["currency"] = currency
req["currency"] = ccy
req["payment_method_id"] = paymentID
return resp,
@@ -506,11 +506,11 @@ func (e *Exchange) DepositViaPaymentMethod(ctx context.Context, amount float64,
// amount - The amount to deposit
// currency - The type of currency
// accountID - ID of the coinbase account
func (e *Exchange) DepositViaCoinbase(ctx context.Context, amount float64, currency, accountID string) (DepositWithdrawalInfo, error) {
func (e *Exchange) DepositViaCoinbase(ctx context.Context, amount float64, ccy, accountID string) (DepositWithdrawalInfo, error) {
resp := DepositWithdrawalInfo{}
req := make(map[string]any)
req["amount"] = amount
req["currency"] = currency
req["currency"] = ccy
req["coinbase_account_id"] = accountID
return resp,
@@ -522,11 +522,11 @@ func (e *Exchange) DepositViaCoinbase(ctx context.Context, amount float64, curre
// amount - The amount to withdraw
// currency - The type of currency
// paymentID - ID of the payment method
func (e *Exchange) WithdrawViaPaymentMethod(ctx context.Context, amount float64, currency, paymentID string) (DepositWithdrawalInfo, error) {
func (e *Exchange) WithdrawViaPaymentMethod(ctx context.Context, amount float64, ccy, paymentID string) (DepositWithdrawalInfo, error) {
resp := DepositWithdrawalInfo{}
req := make(map[string]any)
req["amount"] = amount
req["currency"] = currency
req["currency"] = ccy
req["payment_method_id"] = paymentID
return resp,
@@ -555,11 +555,11 @@ func (e *Exchange) WithdrawViaPaymentMethod(ctx context.Context, amount float64,
// amount - The amount to withdraw
// currency - The type of currency
// cryptoAddress - A crypto address of the recipient
func (e *Exchange) WithdrawCrypto(ctx context.Context, amount float64, currency, cryptoAddress string) (DepositWithdrawalInfo, error) {
func (e *Exchange) WithdrawCrypto(ctx context.Context, amount float64, ccy, cryptoAddress string) (DepositWithdrawalInfo, error) {
resp := DepositWithdrawalInfo{}
req := make(map[string]any)
req["amount"] = amount
req["currency"] = currency
req["currency"] = ccy
req["crypto_address"] = cryptoAddress
return resp,

View File

@@ -196,11 +196,10 @@ func (e *Exchange) GetTradeHistory(ctx context.Context, instrumentID, start, lim
}
// GetIndexTicker returns the index ticker for an asset
func (e *Exchange) GetIndexTicker(ctx context.Context, asset string) (IndexTicker, error) {
func (e *Exchange) GetIndexTicker(ctx context.Context, a string) (IndexTicker, error) {
var result IndexTicker
params := make(map[string]any)
params["asset"] = asset
params["asset"] = a
return result, e.SendHTTPRequest(ctx, exchange.RestSpot, coinutIndexTicker, params, false, &result)
}
@@ -214,12 +213,11 @@ func (e *Exchange) GetDerivativeInstruments(ctx context.Context, secType string)
}
// GetOptionChain returns option chain
func (e *Exchange) GetOptionChain(ctx context.Context, asset, secType string) (OptionChainResponse, error) {
func (e *Exchange) GetOptionChain(ctx context.Context, a, secType string) (OptionChainResponse, error) {
var result OptionChainResponse
params := make(map[string]any)
params["asset"] = asset
params["asset"] = a
params["sec_type"] = secType
return result, e.SendHTTPRequest(ctx, exchange.RestSpot, coinutOptionChain, params, false, &result)
}

View File

@@ -2326,8 +2326,8 @@ func (e *Exchange) CreateCombo(ctx context.Context, args []ComboParam) (*ComboDe
// ExecuteBlockTrade executes a block trade request
// The whole request have to be exact the same as in private/verify_block_trade, only role field should be set appropriately - it basically means that both sides have to agree on the same timestamp, nonce, trades fields and server will assure that role field is different between sides (each party accepted own role).
// Using the same timestamp and nonce by both sides in private/verify_block_trade assures that even if unintentionally both sides execute given block trade with valid counterparty_signature, the given block trade will be executed only once
func (e *Exchange) ExecuteBlockTrade(ctx context.Context, timestampMS time.Time, nonce, role string, ccy currency.Code, trades []BlockTradeParam) ([]BlockTradeResponse, error) {
if nonce == "" {
func (e *Exchange) ExecuteBlockTrade(ctx context.Context, timestampMS time.Time, tradeNonce, role string, ccy currency.Code, trades []BlockTradeParam) ([]BlockTradeResponse, error) {
if tradeNonce == "" {
return nil, errMissingNonce
}
if role != roleMaker && role != roleTaker {
@@ -2351,7 +2351,7 @@ func (e *Exchange) ExecuteBlockTrade(ctx context.Context, timestampMS time.Time,
return nil, fmt.Errorf("%w, trade price can't be negative", errInvalidPrice)
}
}
signature, err := e.VerifyBlockTrade(ctx, timestampMS, nonce, role, ccy, trades)
signature, err := e.VerifyBlockTrade(ctx, timestampMS, tradeNonce, role, ccy, trades)
if err != nil {
return nil, err
}
@@ -2364,7 +2364,7 @@ func (e *Exchange) ExecuteBlockTrade(ctx context.Context, timestampMS time.Time,
params.Set("currency", ccy.String())
}
params.Set("trades", string(values))
params.Set("nonce", nonce)
params.Set("nonce", tradeNonce)
params.Set("role", role)
params.Set("counterparty_signature", signature)
params.Set("timestamp", strconv.FormatInt(timestampMS.UnixMilli(), 10))
@@ -2373,8 +2373,8 @@ func (e *Exchange) ExecuteBlockTrade(ctx context.Context, timestampMS time.Time,
}
// VerifyBlockTrade verifies and creates block trade signature
func (e *Exchange) VerifyBlockTrade(ctx context.Context, timestampMS time.Time, nonce, role string, ccy currency.Code, trades []BlockTradeParam) (string, error) {
if nonce == "" {
func (e *Exchange) VerifyBlockTrade(ctx context.Context, timestampMS time.Time, tradeNonce, role string, ccy currency.Code, trades []BlockTradeParam) (string, error) {
if tradeNonce == "" {
return "", errMissingNonce
}
if role != roleMaker && role != roleTaker {
@@ -2410,7 +2410,7 @@ func (e *Exchange) VerifyBlockTrade(ctx context.Context, timestampMS time.Time,
if !ccy.IsEmpty() {
params.Set("currency", ccy.String())
}
params.Set("nonce", nonce)
params.Set("nonce", tradeNonce)
params.Set("role", role)
params.Set("trades", string(values))
resp := &struct {

View File

@@ -62,6 +62,7 @@ var (
errConfigPairFormatRequiresDelimiter = errors.New("config pair format requires delimiter")
errSetDefaultsNotCalled = errors.New("set defaults not called")
errExchangeIsNil = errors.New("exchange is nil")
errInvalidEndpointKey = errors.New("invalid endpoint key")
)
// SetRequester sets the instance of the requester
@@ -1009,12 +1010,12 @@ func (b *Base) SetAssetPairStore(a asset.Item, f currency.PairStore) error {
}
// SetGlobalPairsManager sets defined asset and pairs management system with global formatting
func (b *Base) SetGlobalPairsManager(request, config *currency.PairFormat, assets ...asset.Item) error {
if request == nil {
func (b *Base) SetGlobalPairsManager(reqFmt, cfgFmt *currency.PairFormat, assets ...asset.Item) error {
if reqFmt == nil {
return fmt.Errorf("%s cannot set pairs manager, request pair format not provided", b.Name)
}
if config == nil {
if cfgFmt == nil {
return fmt.Errorf("%s cannot set pairs manager, config pair format not provided",
b.Name)
}
@@ -1024,14 +1025,14 @@ func (b *Base) SetGlobalPairsManager(request, config *currency.PairFormat, asset
b.Name)
}
if config.Delimiter == "" {
if cfgFmt.Delimiter == "" {
return fmt.Errorf("exchange %s cannot set global pairs manager %w for assets %s",
b.Name, errConfigPairFormatRequiresDelimiter, assets)
}
b.CurrencyPairs.UseGlobalFormat = true
b.CurrencyPairs.RequestFormat = request
b.CurrencyPairs.ConfigFormat = config
b.CurrencyPairs.RequestFormat = reqFmt
b.CurrencyPairs.ConfigFormat = cfgFmt
if b.CurrencyPairs.Pairs != nil {
return fmt.Errorf("%s cannot set pairs manager, pairs already set",
@@ -1047,8 +1048,8 @@ func (b *Base) SetGlobalPairsManager(request, config *currency.PairFormat, asset
}
b.CurrencyPairs.Pairs[assets[i]] = new(currency.PairStore)
b.CurrencyPairs.Pairs[assets[i]].AssetEnabled = true
b.CurrencyPairs.Pairs[assets[i]].ConfigFormat = config
b.CurrencyPairs.Pairs[assets[i]].RequestFormat = request
b.CurrencyPairs.Pairs[assets[i]].ConfigFormat = cfgFmt
b.CurrencyPairs.Pairs[assets[i]].RequestFormat = reqFmt
}
return nil
@@ -1250,23 +1251,16 @@ func (e *Endpoints) SetDefaultEndpoints(m map[URL]string) error {
}
// SetRunningURL populates running URLs map
func (e *Endpoints) SetRunningURL(key, val string) error {
func (e *Endpoints) SetRunningURL(endpoint, val string) error {
e.mu.Lock()
defer e.mu.Unlock()
err := validateKey(key)
if err != nil {
if err := validateKey(endpoint); err != nil {
return err
}
_, err = url.ParseRequestURI(val)
if err != nil {
log.Warnf(log.ExchangeSys,
"Could not set custom URL for %s to %s for exchange %s. invalid URI for request.",
key,
val,
e.Exchange)
return nil
if _, err := url.ParseRequestURI(val); err != nil {
return fmt.Errorf("parse request URI for %s=%q (exchange %s): %w", endpoint, val, e.Exchange, err)
}
e.defaults[key] = val
e.defaults[endpoint] = val
return nil
}
@@ -1276,16 +1270,16 @@ func validateKey(keyVal string) error {
return nil
}
}
return errors.New("keyVal invalid")
return errInvalidEndpointKey
}
// GetURL gets default url from URLs map
func (e *Endpoints) GetURL(key URL) (string, error) {
func (e *Endpoints) GetURL(endpoint URL) (string, error) {
e.mu.RLock()
defer e.mu.RUnlock()
val, ok := e.defaults[key.String()]
val, ok := e.defaults[endpoint.String()]
if !ok {
return "", fmt.Errorf("no endpoint path found for the given key: %v", key)
return "", fmt.Errorf("no endpoint path found for the given key: %v", endpoint)
}
return val, nil
}

View File

@@ -59,53 +59,26 @@ func TestSupportsRESTTickerBatchUpdates(t *testing.T) {
}
}
func TestCreateMap(t *testing.T) {
func TestSetRunningURL(t *testing.T) {
t.Parallel()
b := Base{
Name: "HELOOOOOOOO",
}
b := Base{Name: "HELOOOOOOOO"}
b.API.Endpoints = b.NewEndpoints()
err := b.API.Endpoints.SetDefaultEndpoints(map[URL]string{
EdgeCase1: "http://test1url.com/",
EdgeCase2: "http://test2url.com/",
})
if err != nil {
t.Error(err)
}
val, ok := b.API.Endpoints.defaults[EdgeCase1.String()]
if !ok || val != "http://test1url.com/" {
t.Errorf("CreateMap failed, incorrect value received for the given key")
}
}
assert.ErrorIs(t, b.API.Endpoints.SetRunningURL("meep", "http://google.com/"), errInvalidEndpointKey)
func TestSet(t *testing.T) {
t.Parallel()
b := Base{
Name: "HELOOOOOOOO",
}
b.API.Endpoints = b.NewEndpoints()
err := b.API.Endpoints.SetDefaultEndpoints(map[URL]string{
EdgeCase1: "http://test1url.com/",
EdgeCase2: "http://test2url.com/",
})
if err != nil {
t.Error(err)
}
assert.NoError(t, err, "SetDefaultEndpoints should not error")
err = b.API.Endpoints.SetRunningURL(EdgeCase2.String(), "http://google.com/")
if err != nil {
t.Error(err)
}
assert.NoError(t, err, "SetRunningURL should not error")
val, ok := b.API.Endpoints.defaults[EdgeCase2.String()]
if !ok {
t.Error("set method or createmap failed")
}
if val != "http://google.com/" {
t.Errorf("vals didn't match. expecting: %s, got: %s\n", "http://google.com/", val)
}
assert.True(t, ok, "SetRunningURL should have set the value in defaults")
assert.Equal(t, "http://google.com/", val)
err = b.API.Endpoints.SetRunningURL(EdgeCase3.String(), "Added Edgecase3")
if err != nil {
t.Errorf("not expecting an error since invalid url val err should be logged but received: %v", err)
}
assert.ErrorContains(t, err, "invalid URI for request", "SetRunningURL should error on invalid endpoint key")
}
func TestGetURL(t *testing.T) {
@@ -166,30 +139,22 @@ func TestGetAll(t *testing.T) {
func TestSetDefaultEndpoints(t *testing.T) {
t.Parallel()
b := Base{
Name: "HELLLLLLO",
}
b := Base{Name: "HELLLLLLO"}
b.API.Endpoints = b.NewEndpoints()
err := b.API.Endpoints.SetDefaultEndpoints(map[URL]string{
EdgeCase1: "http://test1.com.au/",
EdgeCase2: "http://test2.com.au/",
})
if err != nil {
t.Error(err)
}
assert.NoError(t, err, "SetDefaultEndpoints should not error")
b.API.Endpoints = b.NewEndpoints()
err = b.API.Endpoints.SetDefaultEndpoints(map[URL]string{
URL(1337): "http://test2.com.au/",
})
if err == nil {
t.Error("expecting an error due to invalid url key")
}
assert.ErrorIs(t, err, errInvalidEndpointKey, "SetDefaultEndpoints should error on invalid endpoint key")
err = b.API.Endpoints.SetDefaultEndpoints(map[URL]string{
EdgeCase1: "",
})
if err != nil {
t.Errorf("expecting a warning due to invalid url value but got an error: %v", err)
}
assert.ErrorContains(t, err, "empty url")
}
func TestSetClientProxyAddress(t *testing.T) {
@@ -475,13 +440,9 @@ func TestSetCurrencyPairFormat(t *testing.T) {
if spot.Delimiter != "~" {
t.Error("incorrect pair format delimiter")
}
futures, err := b.GetPairFormat(asset.Futures, false)
if err != nil {
t.Fatal(err)
}
if futures.Delimiter != ":)" {
t.Error("incorrect pair format delimiter")
}
f, err := b.GetPairFormat(asset.Futures, false)
require.NoError(t, err, "GetPairFormat must not error")
assert.Equal(t, ":)", f.Delimiter, "Delimiter should be set correctly")
}
func TestLoadConfigPairs(t *testing.T) {
@@ -1785,10 +1746,8 @@ func TestSetAPIURL(t *testing.T) {
mappy.Mappymap["RestSpotURL"] = "http://google.com/"
b.API.Endpoints = b.NewEndpoints()
b.Config.API.OldEndPoints.URL = "heloo"
err = b.SetAPIURL()
if err != nil {
t.Errorf("expecting a warning since invalid oldendpoints url but got an error: %v", err)
}
assert.ErrorContains(t, b.SetAPIURL(), "invalid URI for request")
mappy.Mappymap = make(map[string]string)
b.Config.API.OldEndPoints = &config.APIEndpointsConfig{}
b.Config.API.Endpoints = mappy.Mappymap
@@ -1816,17 +1775,6 @@ func TestSetAPIURL(t *testing.T) {
}
}
func TestSetRunningURL(t *testing.T) {
b := Base{
Name: "HELOOOOOOOO",
}
b.API.Endpoints = b.NewEndpoints()
err := b.API.Endpoints.SetRunningURL(EdgeCase1.String(), "http://google.com/")
if err != nil {
t.Error(err)
}
}
func TestAssetWebsocketFunctionality(t *testing.T) {
b := Base{}
if !b.IsAssetWebsocketSupported(asset.Spot) {

View File

@@ -218,7 +218,7 @@ func (e *Exchange) GetCryptoDepositAddress(ctx context.Context) (map[string]stri
// WithdrawCryptocurrency withdraws a cryptocurrency from the exchange to the desired address
// NOTE: This API function is available only after request to their tech support team
func (e *Exchange) WithdrawCryptocurrency(ctx context.Context, currency, address, invoice, transport string, amount float64) (int64, error) {
func (e *Exchange) WithdrawCryptocurrency(ctx context.Context, ccy, address, invoice, transport string, amount float64) (int64, error) {
type response struct {
TaskID int64 `json:"task_id,string"`
Result bool `json:"result"`
@@ -227,7 +227,7 @@ func (e *Exchange) WithdrawCryptocurrency(ctx context.Context, currency, address
}
v := url.Values{}
v.Set("currency", currency)
v.Set("currency", ccy)
v.Set("address", address)
if invoice != "" {
@@ -258,9 +258,9 @@ func (e *Exchange) GetWithdrawTXID(ctx context.Context, taskID int64) (string, e
}
// ExcodeCreate creates an EXMO coupon
func (e *Exchange) ExcodeCreate(ctx context.Context, currency string, amount float64) (ExcodeCreate, error) {
func (e *Exchange) ExcodeCreate(ctx context.Context, ccy string, amount float64) (ExcodeCreate, error) {
v := url.Values{}
v.Set("currency", currency)
v.Set("currency", ccy)
v.Set("amount", strconv.FormatFloat(amount, 'f', -1, 64))
var result ExcodeCreate

View File

@@ -2470,95 +2470,6 @@ func TestUnlockSubAccount(t *testing.T) {
}
}
func TestParseGateioMilliSecTimeUnmarshal(t *testing.T) {
t.Parallel()
var timeWhenTesting int64 = 1684981731098
timeWhenTestingString := `"1684981731098"` // Normal string
integerJSON := `{"number": 1684981731098}`
float64JSON := `{"number": 1684981731.098}`
time := time.UnixMilli(timeWhenTesting)
var in types.Time
err := json.Unmarshal([]byte(timeWhenTestingString), &in)
if err != nil {
t.Fatal(err)
}
if !in.Time().Equal(time) {
t.Fatalf("found %v, but expected %v", in.Time(), time)
}
inInteger := struct {
Number types.Time `json:"number"`
}{}
err = json.Unmarshal([]byte(integerJSON), &inInteger)
if err != nil {
t.Fatal(err)
}
if !inInteger.Number.Time().Equal(time) {
t.Fatalf("found %v, but expected %v", inInteger.Number.Time(), time)
}
inFloat64 := struct {
Number types.Time `json:"number"`
}{}
err = json.Unmarshal([]byte(float64JSON), &inFloat64)
if err != nil {
t.Fatal(err)
}
if !inFloat64.Number.Time().Equal(time) {
t.Fatalf("found %v, but expected %v", inFloat64.Number.Time(), time)
}
}
func TestParseTimeUnmarshal(t *testing.T) {
t.Parallel()
var timeWhenTesting int64 = 1684981731
timeWhenTestingString := `"1684981731"`
integerJSON := `{"number": 1684981731}`
float64JSON := `{"number": 1684981731.234}`
timeWhenTestingStringMicroSecond := `"1691122380942.173000"`
whenTime := time.Unix(timeWhenTesting, 0)
var in types.Time
err := json.Unmarshal([]byte(timeWhenTestingString), &in)
if err != nil {
t.Fatal(err)
}
if !in.Time().Equal(whenTime) {
t.Fatalf("found %v, but expected %v", in.Time(), whenTime)
}
inInteger := struct {
Number types.Time `json:"number"`
}{}
err = json.Unmarshal([]byte(integerJSON), &inInteger)
if err != nil {
t.Fatal(err)
}
if !inInteger.Number.Time().Equal(whenTime) {
t.Fatalf("found %v, but expected %v", inInteger.Number.Time(), whenTime)
}
inFloat64 := struct {
Number types.Time `json:"number"`
}{}
err = json.Unmarshal([]byte(float64JSON), &inFloat64)
if err != nil {
t.Fatal(err)
}
msTime := time.UnixMilli(1684981731234)
if !inFloat64.Number.Time().Equal(time.UnixMilli(1684981731234)) {
t.Fatalf("found %v, but expected %v", inFloat64.Number.Time(), msTime)
}
var microSeconds types.Time
err = json.Unmarshal([]byte(timeWhenTestingStringMicroSecond), &microSeconds)
if err != nil {
t.Fatal(err)
}
if !microSeconds.Time().Equal(time.UnixMicro(1691122380942173)) {
t.Fatalf("found %v, but expected %v", microSeconds.Time(), time.UnixMicro(1691122380942173))
}
}
func TestUpdateOrderExecutionLimits(t *testing.T) {
t.Parallel()
testexch.UpdatePairsOnce(t, e)

View File

@@ -23,8 +23,8 @@ func (e *Exchange) authenticateFutures(ctx context.Context, conn websocket.Conne
}
// WebsocketFuturesSubmitOrder submits an order via the websocket connection
func (e *Exchange) WebsocketFuturesSubmitOrder(ctx context.Context, a asset.Item, order *ContractOrderCreateParams) (*WebsocketFuturesOrderResponse, error) {
resps, err := e.WebsocketFuturesSubmitOrders(ctx, a, order)
func (e *Exchange) WebsocketFuturesSubmitOrder(ctx context.Context, a asset.Item, o *ContractOrderCreateParams) (*WebsocketFuturesOrderResponse, error) {
resps, err := e.WebsocketFuturesSubmitOrders(ctx, a, o)
if err != nil {
return nil, err
}

View File

@@ -25,8 +25,8 @@ func (e *Exchange) authenticateSpot(ctx context.Context, conn websocket.Connecti
}
// WebsocketSpotSubmitOrder submits an order via the websocket connection
func (e *Exchange) WebsocketSpotSubmitOrder(ctx context.Context, order *CreateOrderRequest) (*WebsocketOrderResponse, error) {
resps, err := e.WebsocketSpotSubmitOrders(ctx, order)
func (e *Exchange) WebsocketSpotSubmitOrder(ctx context.Context, o *CreateOrderRequest) (*WebsocketOrderResponse, error) {
resps, err := e.WebsocketSpotSubmitOrders(ctx, o)
if err != nil {
return nil, err
}

View File

@@ -335,15 +335,15 @@ func (e *Exchange) GetBalances(ctx context.Context) ([]Balance, error) {
}
// GetCryptoDepositAddress returns a deposit address
func (e *Exchange) GetCryptoDepositAddress(ctx context.Context, depositAddlabel, currency string) (DepositAddress, error) {
func (e *Exchange) GetCryptoDepositAddress(ctx context.Context, depositAddLabel, ccy string) (DepositAddress, error) {
response := DepositAddress{}
req := make(map[string]any)
if depositAddlabel != "" {
req["label"] = depositAddlabel
if depositAddLabel != "" {
req["label"] = depositAddLabel
}
err := e.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, http.MethodPost, geminiDeposit+"/"+currency+"/"+geminiNewAddress, req, &response)
err := e.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, http.MethodPost, geminiDeposit+"/"+ccy+"/"+geminiNewAddress, req, &response)
if err != nil {
return response, err
}
@@ -354,13 +354,13 @@ func (e *Exchange) GetCryptoDepositAddress(ctx context.Context, depositAddlabel,
}
// WithdrawCrypto withdraws crypto currency to a whitelisted address
func (e *Exchange) WithdrawCrypto(ctx context.Context, address, currency string, amount float64) (WithdrawalAddress, error) {
func (e *Exchange) WithdrawCrypto(ctx context.Context, address, ccy string, amount float64) (WithdrawalAddress, error) {
response := WithdrawalAddress{}
req := make(map[string]any)
req["address"] = address
req["amount"] = strconv.FormatFloat(amount, 'f', -1, 64)
err := e.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, http.MethodPost, geminiWithdraw+strings.ToLower(currency), req, &response)
err := e.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, http.MethodPost, geminiWithdraw+strings.ToLower(ccy), req, &response)
if err != nil {
return response, err
}

View File

@@ -70,12 +70,12 @@ func (e *Exchange) GetCurrencies(ctx context.Context) (map[string]Currencies, er
// GetCurrency returns the actual list of available currencies, tokens, ICO
// etc.
func (e *Exchange) GetCurrency(ctx context.Context, currency string) (Currencies, error) {
func (e *Exchange) GetCurrency(ctx context.Context, symbol string) (Currencies, error) {
type Response struct {
Data Currencies
}
resp := Response{}
path := apiV2Currency + "/" + currency
path := apiV2Currency + "/" + symbol
return resp.Data, e.SendHTTPRequest(ctx, exchange.RestSpot, path, &resp.Data)
}
@@ -225,22 +225,22 @@ func (e *Exchange) GetBalances(ctx context.Context) (map[string]Balance, error)
}
// GetDepositAddresses returns a deposit address for a specific currency
func (e *Exchange) GetDepositAddresses(ctx context.Context, currency string) (DepositCryptoAddresses, error) {
func (e *Exchange) GetDepositAddresses(ctx context.Context, ccy string) (DepositCryptoAddresses, error) {
var resp DepositCryptoAddresses
return resp,
e.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, http.MethodGet,
apiV2CryptoAddress+"/"+currency,
apiV2CryptoAddress+"/"+ccy,
url.Values{},
otherRequests,
&resp)
}
// GenerateNewAddress generates a new deposit address for a currency
func (e *Exchange) GenerateNewAddress(ctx context.Context, currency string) (DepositCryptoAddresses, error) {
func (e *Exchange) GenerateNewAddress(ctx context.Context, ccy string) (DepositCryptoAddresses, error) {
resp := DepositCryptoAddresses{}
err := e.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, http.MethodPost,
apiV2CryptoAddress+"/"+currency,
apiV2CryptoAddress+"/"+ccy,
url.Values{},
otherRequests,
&resp)
@@ -249,7 +249,7 @@ func (e *Exchange) GenerateNewAddress(ctx context.Context, currency string) (Dep
}
// GetTradeHistoryForCurrency returns your trade history
func (e *Exchange) GetTradeHistoryForCurrency(ctx context.Context, currency, start, end string) (AuthenticatedTradeHistoryResponse, error) {
func (e *Exchange) GetTradeHistoryForCurrency(ctx context.Context, ccyPair, start, end string) (AuthenticatedTradeHistoryResponse, error) {
values := url.Values{}
if start != "" {
@@ -260,7 +260,7 @@ func (e *Exchange) GetTradeHistoryForCurrency(ctx context.Context, currency, sta
values.Set("end", end)
}
values.Set("currencyPair", currency)
values.Set("currencyPair", ccyPair)
result := AuthenticatedTradeHistoryResponse{}
return result, e.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, http.MethodPost,
@@ -293,9 +293,9 @@ func (e *Exchange) GetTradeHistoryForAllCurrencies(ctx context.Context, start, e
}
// GetOrders List of your order history.
func (e *Exchange) GetOrders(ctx context.Context, currency string) ([]OrderHistoryResponse, error) {
func (e *Exchange) GetOrders(ctx context.Context, symbol string) ([]OrderHistoryResponse, error) {
values := url.Values{}
values.Set("symbol", currency)
values.Set("symbol", symbol)
var result []OrderHistoryResponse
return result, e.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, http.MethodGet,
@@ -306,9 +306,9 @@ func (e *Exchange) GetOrders(ctx context.Context, currency string) ([]OrderHisto
}
// GetOpenOrders List of your currently open orders.
func (e *Exchange) GetOpenOrders(ctx context.Context, currency string) ([]OrderHistoryResponse, error) {
func (e *Exchange) GetOpenOrders(ctx context.Context, symbol string) ([]OrderHistoryResponse, error) {
values := url.Values{}
values.Set("symbol", currency)
values.Set("symbol", symbol)
var result []OrderHistoryResponse
return result, e.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, http.MethodGet,
@@ -330,11 +330,11 @@ func (e *Exchange) GetActiveOrderByClientOrderID(ctx context.Context, clientOrde
}
// PlaceOrder places an order on the exchange
func (e *Exchange) PlaceOrder(ctx context.Context, currency string, rate, amount float64, orderType, side string) (OrderResponse, error) {
func (e *Exchange) PlaceOrder(ctx context.Context, symbol string, rate, amount float64, orderType, side string) (OrderResponse, error) {
var result OrderResponse
values := url.Values{}
values.Set("symbol", currency)
values.Set("symbol", symbol)
values.Set("rate", strconv.FormatFloat(rate, 'f', -1, 64))
values.Set("quantity", strconv.FormatFloat(amount, 'f', -1, 64))
values.Set("side", side)
@@ -381,11 +381,11 @@ func (e *Exchange) CancelAllExistingOrders(ctx context.Context) ([]Order, error)
}
// Withdraw allows for the withdrawal to a specific address
func (e *Exchange) Withdraw(ctx context.Context, currency, address string, amount float64) (bool, error) {
func (e *Exchange) Withdraw(ctx context.Context, ccy, address string, amount float64) (bool, error) {
result := Withdraw{}
values := url.Values{}
values.Set("currency", currency)
values.Set("currency", ccy)
values.Set("amount", strconv.FormatFloat(amount, 'f', -1, 64))
values.Set("address", address)

View File

@@ -566,8 +566,8 @@ func (e *Exchange) GetOrderInfo(ctx context.Context, orderID string, pair curren
}
// GetDepositAddress returns a deposit address for a specified currency
func (e *Exchange) GetDepositAddress(ctx context.Context, currency currency.Code, _, _ string) (*deposit.Address, error) {
resp, err := e.GetDepositAddresses(ctx, currency.String())
func (e *Exchange) GetDepositAddress(ctx context.Context, ccy currency.Code, _, _ string) (*deposit.Address, error) {
resp, err := e.GetDepositAddresses(ctx, ccy.String())
if err != nil {
return nil, err
}

View File

@@ -537,7 +537,7 @@ func (e *Exchange) GetOrderMatchResults(ctx context.Context, orderID int64) ([]O
}
// GetOrders returns a list of orders
func (e *Exchange) GetOrders(ctx context.Context, symbol currency.Pair, types, start, end, states, from, direct, size string) ([]OrderInfo, error) {
func (e *Exchange) GetOrders(ctx context.Context, symbol currency.Pair, orderTypes, start, end, states, from, direct, size string) ([]OrderInfo, error) {
resp := struct {
Orders []OrderInfo `json:"data"`
}{}
@@ -550,8 +550,8 @@ func (e *Exchange) GetOrders(ctx context.Context, symbol currency.Pair, types, s
vals.Set("symbol", symbolValue)
vals.Set("states", states)
if types != "" {
vals.Set("types", types)
if orderTypes != "" {
vals.Set("types", orderTypes)
}
if start != "" {
@@ -601,7 +601,7 @@ func (e *Exchange) GetOpenOrders(ctx context.Context, symbol currency.Pair, acco
}
// GetOrdersMatch returns a list of matched orders
func (e *Exchange) GetOrdersMatch(ctx context.Context, symbol currency.Pair, types, start, end, from, direct, size string) ([]OrderMatchInfo, error) {
func (e *Exchange) GetOrdersMatch(ctx context.Context, symbol currency.Pair, orderTypes, start, end, from, direct, size string) ([]OrderMatchInfo, error) {
resp := struct {
Orders []OrderMatchInfo `json:"data"`
}{}
@@ -613,8 +613,8 @@ func (e *Exchange) GetOrdersMatch(ctx context.Context, symbol currency.Pair, typ
}
vals.Set("symbol", symbolValue)
if types != "" {
vals.Set("types", types)
if orderTypes != "" {
vals.Set("types", orderTypes)
}
if start != "" {
@@ -642,7 +642,7 @@ func (e *Exchange) GetOrdersMatch(ctx context.Context, symbol currency.Pair, typ
}
// MarginTransfer transfers assets into or out of the margin account
func (e *Exchange) MarginTransfer(ctx context.Context, symbol currency.Pair, currency string, amount float64, in bool) (int64, error) {
func (e *Exchange) MarginTransfer(ctx context.Context, symbol currency.Pair, ccy string, amount float64, in bool) (int64, error) {
symbolValue, err := e.FormatSymbol(symbol, asset.Spot)
if err != nil {
return 0, err
@@ -653,7 +653,7 @@ func (e *Exchange) MarginTransfer(ctx context.Context, symbol currency.Pair, cur
Amount string `json:"amount"`
}{
Symbol: symbolValue,
Currency: currency,
Currency: ccy,
Amount: strconv.FormatFloat(amount, 'f', -1, 64),
}
@@ -670,7 +670,7 @@ func (e *Exchange) MarginTransfer(ctx context.Context, symbol currency.Pair, cur
}
// MarginOrder submits a margin order application
func (e *Exchange) MarginOrder(ctx context.Context, symbol currency.Pair, currency string, amount float64) (int64, error) {
func (e *Exchange) MarginOrder(ctx context.Context, symbol currency.Pair, ccy string, amount float64) (int64, error) {
symbolValue, err := e.FormatSymbol(symbol, asset.Spot)
if err != nil {
return 0, err
@@ -681,7 +681,7 @@ func (e *Exchange) MarginOrder(ctx context.Context, symbol currency.Pair, curren
Amount string `json:"amount"`
}{
Symbol: symbolValue,
Currency: currency,
Currency: ccy,
Amount: strconv.FormatFloat(amount, 'f', -1, 64),
}
@@ -710,14 +710,14 @@ func (e *Exchange) MarginRepayment(ctx context.Context, orderID int64, amount fl
}
// GetMarginLoanOrders returns the margin loan orders
func (e *Exchange) GetMarginLoanOrders(ctx context.Context, symbol currency.Pair, currency, start, end, states, from, direct, size string) ([]MarginOrder, error) {
func (e *Exchange) GetMarginLoanOrders(ctx context.Context, symbol currency.Pair, ccy, start, end, states, from, direct, size string) ([]MarginOrder, error) {
vals := url.Values{}
symbolValue, err := e.FormatSymbol(symbol, asset.Spot)
if err != nil {
return nil, err
}
vals.Set("symbol", symbolValue)
vals.Set("currency", currency)
vals.Set("currency", ccy)
if start != "" {
vals.Set("start-date", start)

View File

@@ -18,16 +18,14 @@ import (
)
// LoadFromDatabase returns Item from database seeded data
func LoadFromDatabase(exchange string, pair currency.Pair, a asset.Item, interval Interval, start, end time.Time) (*Item, error) {
retCandle, err := candle.Series(exchange,
pair.Base.String(), pair.Quote.String(),
int64(interval.Duration().Seconds()), a.String(), start, end)
func LoadFromDatabase(exch string, pair currency.Pair, a asset.Item, interval Interval, start, end time.Time) (*Item, error) {
retCandle, err := candle.Series(exch, pair.Base.String(), pair.Quote.String(), int64(interval.Duration().Seconds()), a.String(), start, end)
if err != nil {
return nil, err
}
ret := Item{
Exchange: exchange,
Exchange: exch,
Pair: pair,
Interval: interval,
Asset: a,

View File

@@ -338,26 +338,22 @@ func (e *Exchange) GetBalance(ctx context.Context) (map[string]Balance, error) {
}
// GetWithdrawInfo gets withdrawal fees
func (e *Exchange) GetWithdrawInfo(ctx context.Context, currency string, amount float64) (*WithdrawInformation, error) {
func (e *Exchange) GetWithdrawInfo(ctx context.Context, withdrawalAsset, withdrawalKey string, amount float64) (*WithdrawInformation, error) {
params := url.Values{}
params.Set("asset", currency)
params.Set("key", "")
params.Set("asset", withdrawalAsset)
params.Set("key", withdrawalKey)
params.Set("amount", strconv.FormatFloat(amount, 'f', -1, 64))
var result WithdrawInformation
if err := e.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, krakenWithdrawInfo, params, &result); err != nil {
return nil, err
}
return &result, nil
var result *WithdrawInformation
return result, e.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, krakenWithdrawInfo, params, &result)
}
// Withdraw withdraws funds
func (e *Exchange) Withdraw(ctx context.Context, asset, key string, amount float64) (string, error) {
func (e *Exchange) Withdraw(ctx context.Context, withdrawalAsset, withdrawalKey string, amount float64) (string, error) {
params := url.Values{}
params.Set("asset", asset)
params.Set("key", key)
params.Set("amount", fmt.Sprintf("%f", amount))
params.Set("asset", withdrawalAsset)
params.Set("key", withdrawalKey)
params.Set("amount", strconv.FormatFloat(amount, 'f', -1, 64))
var referenceID string
if err := e.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, krakenWithdraw, params, &referenceID); err != nil {
@@ -367,10 +363,10 @@ func (e *Exchange) Withdraw(ctx context.Context, asset, key string, amount float
return referenceID, nil
}
// GetDepositMethods gets withdrawal fees
func (e *Exchange) GetDepositMethods(ctx context.Context, currency string) ([]DepositMethods, error) {
// GetDepositMethods gets withdrawal fees for a specific asset
func (e *Exchange) GetDepositMethods(ctx context.Context, a string) ([]DepositMethods, error) {
params := url.Values{}
params.Set("asset", currency)
params.Set("asset", a)
var result []DepositMethods
err := e.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, krakenDepositMethods, params, &result)
@@ -899,8 +895,8 @@ func getCryptocurrencyDepositFee(c currency.Code) float64 {
return DepositFees[c]
}
func calculateTradingFee(currency string, feePair map[string]TradeVolumeFee, purchasePrice, amount float64) float64 {
return (feePair[currency].Fee / 100) * purchasePrice * amount
func calculateTradingFee(ccy string, feePair map[string]TradeVolumeFee, purchasePrice, amount float64) float64 {
return (feePair[ccy].Fee / 100) * purchasePrice * amount
}
// GetCryptoDepositAddress returns a deposit address for a cryptocurrency

View File

@@ -295,10 +295,10 @@ func (e *Exchange) FuturesRecentOrders(ctx context.Context, symbol currency.Pair
}
// FuturesWithdrawToSpotWallet withdraws currencies from futures wallet to spot wallet
func (e *Exchange) FuturesWithdrawToSpotWallet(ctx context.Context, currency string, amount float64) (GenericResponse, error) {
func (e *Exchange) FuturesWithdrawToSpotWallet(ctx context.Context, ccy string, amount float64) (GenericResponse, error) {
var resp GenericResponse
params := url.Values{}
params.Set("currency", currency)
params.Set("currency", ccy)
params.Set("amount", strconv.FormatFloat(amount, 'f', -1, 64))
return resp, e.SendFuturesAuthRequest(ctx, http.MethodPost, futuresWithdraw, params, &resp)
}

View File

@@ -314,23 +314,23 @@ func (e *Exchange) wsProcessOwnTrades(ownOrdersRaw json.RawMessage) error {
Err: err,
}
}
trade := order.TradeHistory{
Price: val.Price,
Amount: val.Vol,
Fee: val.Fee,
Exchange: e.Name,
TID: key,
Type: oType,
Side: oSide,
Timestamp: val.Time.Time(),
}
e.Websocket.DataHandler <- &order.Detail{
Exchange: e.Name,
OrderID: val.OrderTransactionID,
Trades: []order.TradeHistory{trade},
Trades: []order.TradeHistory{
{
Price: val.Price,
Amount: val.Vol,
Fee: val.Fee,
Exchange: e.Name,
TID: key,
Type: oType,
Side: oSide,
Timestamp: val.Time.Time(),
},
},
}
}
return nil
}

View File

@@ -449,7 +449,7 @@ func GetExcludedItems() (Exclusion, error) {
m.Lock()
defer m.Unlock()
if !set {
file, err := os.ReadFile(exclusionFile)
f, err := os.ReadFile(exclusionFile)
if err != nil {
if !strings.Contains(err.Error(), "no such file or directory") {
return excludedList, err
@@ -468,7 +468,7 @@ func GetExcludedItems() (Exclusion, error) {
return excludedList, mErr
}
} else {
err = json.Unmarshal(file, &excludedList)
err = json.Unmarshal(f, &excludedList)
if err != nil {
return excludedList, err
}

View File

@@ -1360,9 +1360,9 @@ func (e *Exchange) GetDepositWithdrawalStatus(ctx context.Context, ccy currency.
}
// SmallAssetsConvert Convert small assets in funding account to OKB. Only one convert is allowed within 24 hours
func (e *Exchange) SmallAssetsConvert(ctx context.Context, currency []string) (*SmallAssetConvertResponse, error) {
func (e *Exchange) SmallAssetsConvert(ctx context.Context, currencies []string) (*SmallAssetConvertResponse, error) {
var resp *SmallAssetConvertResponse
return resp, e.SendHTTPRequest(ctx, exchange.RestSpot, smallAssetsConvertEPL, http.MethodPost, "asset/convert-dust-assets", map[string][]string{"ccy": currency}, &resp, request.AuthenticatedRequest)
return resp, e.SendHTTPRequest(ctx, exchange.RestSpot, smallAssetsConvertEPL, http.MethodPost, "asset/convert-dust-assets", map[string][]string{"ccy": currencies}, &resp, request.AuthenticatedRequest)
}
// GetPublicExchangeList retrieves exchanges

View File

@@ -295,13 +295,13 @@ func TestGetBlockTrade(t *testing.T) {
trades, err := e.GetPublicBlockTrades(contextGenerate(), mainPair.String())
require.NoError(t, err)
if assert.NotEmpty(t, trades, "Should get some block trades") {
trade := trades[0]
assert.Equal(t, mainPair.String(), trade.InstrumentID, "InstrumentID should have correct value")
assert.NotEmpty(t, trade.TradeID, "TradeID should not be empty")
assert.Positive(t, trade.Price.Float64(), "Price should have a positive value")
assert.Positive(t, trade.Size.Float64(), "Size should have a positive value")
assert.Contains(t, []order.Side{order.Buy, order.Sell}, trade.Side, "Side should be a side")
assert.WithinRange(t, trade.Timestamp.Time(), time.Now().Add(time.Hour*-24*90), time.Now(), "Timestamp should be within last 90 days")
blockTrade := trades[0]
assert.Equal(t, mainPair.String(), blockTrade.InstrumentID, "InstrumentID should have correct value")
assert.NotEmpty(t, blockTrade.TradeID, "TradeID should not be empty")
assert.Positive(t, blockTrade.Price.Float64(), "Price should have a positive value")
assert.Positive(t, blockTrade.Size.Float64(), "Size should have a positive value")
assert.Contains(t, []order.Side{order.Buy, order.Sell}, blockTrade.Side, "Side should be a side")
assert.WithinRange(t, blockTrade.Timestamp.Time(), time.Now().Add(time.Hour*-24*90), time.Now(), "Timestamp should be within last 90 days")
}
testexch.UpdatePairsOnce(t, e)

View File

@@ -244,9 +244,9 @@ func (e *Exchange) GetTimestamp(ctx context.Context) (time.Time, error) {
// GetLoanOrders returns the list of loan offers and demands for a given
// currency, specified by the "currency" GET parameter.
func (e *Exchange) GetLoanOrders(ctx context.Context, currency string) (LoanOrders, error) {
func (e *Exchange) GetLoanOrders(ctx context.Context, ccy string) (LoanOrders, error) {
resp := LoanOrders{}
path := "/public?command=returnLoanOrders&currency=" + currency
path := "/public?command=returnLoanOrders&currency=" + ccy
return resp, e.SendHTTPRequest(ctx, exchange.RestSpot, path, &resp)
}
@@ -365,9 +365,9 @@ func (e *Exchange) GetDepositsWithdrawals(ctx context.Context, start, end string
}
// GetOpenOrders returns current unfilled opened orders
func (e *Exchange) GetOpenOrders(ctx context.Context, currency string) (OpenOrdersResponse, error) {
func (e *Exchange) GetOpenOrders(ctx context.Context, ccy string) (OpenOrdersResponse, error) {
values := url.Values{}
values.Set("currencyPair", currency)
values.Set("currencyPair", ccy)
result := OpenOrdersResponse{}
return result, e.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, http.MethodPost, poloniexOrders, values, &result.Data)
}
@@ -381,7 +381,7 @@ func (e *Exchange) GetOpenOrdersForAllCurrencies(ctx context.Context) (OpenOrder
}
// GetAuthenticatedTradeHistoryForCurrency returns account trade history
func (e *Exchange) GetAuthenticatedTradeHistoryForCurrency(ctx context.Context, currency string, start, end, limit int64) (AuthenticatedTradeHistoryResponse, error) {
func (e *Exchange) GetAuthenticatedTradeHistoryForCurrency(ctx context.Context, currencyPair string, start, end, limit int64) (AuthenticatedTradeHistoryResponse, error) {
values := url.Values{}
if start > 0 {
@@ -396,7 +396,7 @@ func (e *Exchange) GetAuthenticatedTradeHistoryForCurrency(ctx context.Context,
values.Set("end", strconv.FormatInt(end, 10))
}
values.Set("currencyPair", currency)
values.Set("currencyPair", currencyPair)
result := AuthenticatedTradeHistoryResponse{}
return result, e.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, http.MethodPost, poloniexTradeHistory, values, &result.Data)
}
@@ -512,7 +512,7 @@ func (e *Exchange) GetAuthenticatedOrderTrades(ctx context.Context, orderID stri
}
// PlaceOrder places a new order on the exchange
func (e *Exchange) PlaceOrder(ctx context.Context, currency string, rate, amount float64, immediate, fillOrKill, buy bool) (OrderResponse, error) {
func (e *Exchange) PlaceOrder(ctx context.Context, currencyPair string, rate, amount float64, immediate, fillOrKill, buy bool) (OrderResponse, error) {
result := OrderResponse{}
values := url.Values{}
@@ -523,7 +523,7 @@ func (e *Exchange) PlaceOrder(ctx context.Context, currency string, rate, amount
orderType = order.Sell.Lower()
}
values.Set("currencyPair", currency)
values.Set("currencyPair", currencyPair)
values.Set("rate", strconv.FormatFloat(rate, 'f', -1, 64))
values.Set("amount", strconv.FormatFloat(amount, 'f', -1, 64))
@@ -603,11 +603,11 @@ func (e *Exchange) MoveOrder(ctx context.Context, orderID int64, rate, amount fl
// For currencies where there are multiple networks to choose from (like USDT or BTC),
// you can specify the chain by setting the "currency" parameter to be a multiChain currency
// name, like USDTTRON, USDTETH, or BTCTRON
func (e *Exchange) Withdraw(ctx context.Context, currency, address string, amount float64) (*Withdraw, error) {
func (e *Exchange) Withdraw(ctx context.Context, ccy, address string, amount float64) (*Withdraw, error) {
result := &Withdraw{}
values := url.Values{}
values.Set("currency", strings.ToUpper(currency))
values.Set("currency", strings.ToUpper(ccy))
values.Set("amount", strconv.FormatFloat(amount, 'f', -1, 64))
values.Set("address", address)
@@ -662,11 +662,11 @@ func (e *Exchange) GetTradableBalances(ctx context.Context) (map[string]map[stri
}
// TransferBalance transfers balances between your accounts
func (e *Exchange) TransferBalance(ctx context.Context, currency, from, to string, amount float64) (bool, error) {
func (e *Exchange) TransferBalance(ctx context.Context, ccy, from, to string, amount float64) (bool, error) {
values := url.Values{}
result := GenericResponse{}
values.Set("currency", currency)
values.Set("currency", ccy)
values.Set("amount", strconv.FormatFloat(amount, 'f', -1, 64))
values.Set("fromAccount", from)
values.Set("toAccount", to)
@@ -690,7 +690,7 @@ func (e *Exchange) GetMarginAccountSummary(ctx context.Context) (Margin, error)
}
// PlaceMarginOrder places a margin order
func (e *Exchange) PlaceMarginOrder(ctx context.Context, currency string, rate, amount, lendingRate float64, buy bool) (OrderResponse, error) {
func (e *Exchange) PlaceMarginOrder(ctx context.Context, currencyPair string, rate, amount, lendingRate float64, buy bool) (OrderResponse, error) {
result := OrderResponse{}
values := url.Values{}
@@ -701,7 +701,7 @@ func (e *Exchange) PlaceMarginOrder(ctx context.Context, currency string, rate,
orderType = poloniexMarginSell
}
values.Set("currencyPair", currency)
values.Set("currencyPair", currencyPair)
values.Set("rate", strconv.FormatFloat(rate, 'f', -1, 64))
values.Set("amount", strconv.FormatFloat(amount, 'f', -1, 64))
@@ -713,11 +713,11 @@ func (e *Exchange) PlaceMarginOrder(ctx context.Context, currency string, rate,
}
// GetMarginPosition returns a position on a margin order
func (e *Exchange) GetMarginPosition(ctx context.Context, currency string) (any, error) {
func (e *Exchange) GetMarginPosition(ctx context.Context, currencyPair string) (any, error) {
values := url.Values{}
if currency != "" && currency != "all" {
values.Set("currencyPair", currency)
if currencyPair != "" && currencyPair != "all" {
values.Set("currencyPair", currencyPair)
result := MarginPosition{}
return result, e.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, http.MethodPost, poloniexMarginPosition, values, &result)
}
@@ -731,9 +731,9 @@ func (e *Exchange) GetMarginPosition(ctx context.Context, currency string) (any,
}
// CloseMarginPosition closes a current margin position
func (e *Exchange) CloseMarginPosition(ctx context.Context, currency string) (bool, error) {
func (e *Exchange) CloseMarginPosition(ctx context.Context, currencyPair string) (bool, error) {
values := url.Values{}
values.Set("currencyPair", currency)
values.Set("currencyPair", currencyPair)
result := GenericResponse{}
err := e.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, http.MethodPost, poloniexMarginPositionClose, values, &result)
@@ -749,9 +749,9 @@ func (e *Exchange) CloseMarginPosition(ctx context.Context, currency string) (bo
}
// CreateLoanOffer places a loan offer on the exchange
func (e *Exchange) CreateLoanOffer(ctx context.Context, currency string, amount, rate float64, duration int, autoRenew bool) (int64, error) {
func (e *Exchange) CreateLoanOffer(ctx context.Context, ccy string, amount, rate float64, duration int, autoRenew bool) (int64, error) {
values := url.Values{}
values.Set("currency", currency)
values.Set("currency", ccy)
values.Set("amount", strconv.FormatFloat(amount, 'f', -1, 64))
values.Set("duration", strconv.Itoa(duration))

View File

@@ -235,9 +235,9 @@ func (e *Exchange) WithdrawCoinsToAddress(ctx context.Context, coin string, amou
}
// CreateCoupon creates an exchange coupon for a specific currency
func (e *Exchange) CreateCoupon(ctx context.Context, currency string, amount float64) (CreateCoupon, error) {
func (e *Exchange) CreateCoupon(ctx context.Context, ccy string, amount float64) (CreateCoupon, error) {
req := url.Values{}
req.Add("currency", currency)
req.Add("currency", ccy)
req.Add("amount", strconv.FormatFloat(amount, 'f', -1, 64))
var result CreateCoupon