diff --git a/exchanges/gateio/gateio.go b/exchanges/gateio/gateio.go index 11d0dcd34c8..e4187d606fa 100644 --- a/exchanges/gateio/gateio.go +++ b/exchanges/gateio/gateio.go @@ -186,13 +186,13 @@ func (g *Gateio) CreateNewSubAccount(ctx context.Context, arg SubAccountParams) return nil, errors.New("login name can not be empty") } var response *SubAccount - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, spotDefaultEPL, http.MethodPost, subAccounts, nil, &arg, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, subAccountEPL, http.MethodPost, subAccounts, nil, &arg, &response) } // GetSubAccounts retrieves list of sub-accounts for given account func (g *Gateio) GetSubAccounts(ctx context.Context) ([]SubAccount, error) { var response []SubAccount - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, spotDefaultEPL, http.MethodGet, subAccounts, nil, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, subAccountEPL, http.MethodGet, subAccounts, nil, nil, &response) } // GetSingleSubAccount retrieves a single sub-account for given account @@ -201,8 +201,7 @@ func (g *Gateio) GetSingleSubAccount(ctx context.Context, userID string) (*SubAc return nil, errors.New("user ID can not be empty") } var response *SubAccount - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, spotDefaultEPL, http.MethodGet, - subAccounts+"/"+userID, nil, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, subAccountEPL, http.MethodGet, subAccounts+"/"+userID, nil, nil, &response) } // CreateAPIKeysOfSubAccount creates a sub-account for the sub-account @@ -217,18 +216,18 @@ func (g *Gateio) CreateAPIKeysOfSubAccount(ctx context.Context, arg CreateAPIKey return nil, errors.New("sub-account key information is required") } var resp *CreateAPIKeyResponse - return resp, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, spotPlaceOrdersEPL, http.MethodPost, subAccountsPath+strconv.FormatInt(arg.SubAccountUserID, 10)+"/keys", nil, &arg, &resp) + return resp, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, subAccountEPL, http.MethodPost, subAccountsPath+strconv.FormatInt(arg.SubAccountUserID, 10)+"/keys", nil, &arg, &resp) } // GetAllAPIKeyOfSubAccount list all API Key of the sub-account func (g *Gateio) GetAllAPIKeyOfSubAccount(ctx context.Context, userID int64) ([]CreateAPIKeyResponse, error) { var resp []CreateAPIKeyResponse - return resp, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, spotPrivateEPL, http.MethodGet, subAccountsPath+strconv.FormatInt(userID, 10)+"/keys", nil, nil, &resp) + return resp, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, subAccountEPL, http.MethodGet, subAccountsPath+strconv.FormatInt(userID, 10)+"/keys", nil, nil, &resp) } // UpdateAPIKeyOfSubAccount update API key of the sub-account func (g *Gateio) UpdateAPIKeyOfSubAccount(ctx context.Context, subAccountAPIKey string, arg CreateAPIKeySubAccountParams) error { - return g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, spotPlaceOrdersEPL, http.MethodPut, subAccountsPath+strconv.FormatInt(arg.SubAccountUserID, 10)+"/keys/"+subAccountAPIKey, nil, &arg, nil) + return g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, subAccountEPL, http.MethodPut, subAccountsPath+strconv.FormatInt(arg.SubAccountUserID, 10)+"/keys/"+subAccountAPIKey, nil, &arg, nil) } // GetAPIKeyOfSubAccount retrieves the API Key of the sub-account @@ -240,7 +239,7 @@ func (g *Gateio) GetAPIKeyOfSubAccount(ctx context.Context, subAccountUserID int return nil, errMissingAPIKey } var resp *CreateAPIKeyResponse - return resp, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, spotPrivateEPL, http.MethodGet, subAccountsPath+strconv.FormatInt(subAccountUserID, 10)+"/keys/"+apiKey, nil, nil, &resp) + return resp, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, subAccountEPL, http.MethodGet, subAccountsPath+strconv.FormatInt(subAccountUserID, 10)+"/keys/"+apiKey, nil, nil, &resp) } // LockSubAccount locks the sub-account @@ -248,7 +247,7 @@ func (g *Gateio) LockSubAccount(ctx context.Context, subAccountUserID int64) err if subAccountUserID == 0 { return errInvalidSubAccountUserID } - return g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, spotPrivateEPL, http.MethodPost, subAccountsPath+strconv.FormatInt(subAccountUserID, 10)+"/lock", nil, nil, nil) + return g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, subAccountEPL, http.MethodPost, subAccountsPath+strconv.FormatInt(subAccountUserID, 10)+"/lock", nil, nil, nil) } // UnlockSubAccount locks the sub-account @@ -256,7 +255,7 @@ func (g *Gateio) UnlockSubAccount(ctx context.Context, subAccountUserID int64) e if subAccountUserID == 0 { return errInvalidSubAccountUserID } - return g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, spotPrivateEPL, http.MethodPost, subAccountsPath+strconv.FormatInt(subAccountUserID, 10)+"/unlock", nil, nil, nil) + return g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, subAccountEPL, http.MethodPost, subAccountsPath+strconv.FormatInt(subAccountUserID, 10)+"/unlock", nil, nil, nil) } // ***************************************** Spot ************************************** @@ -264,7 +263,7 @@ func (g *Gateio) UnlockSubAccount(ctx context.Context, subAccountUserID int64) e // ListSpotCurrencies to retrieve detailed list of each currency. func (g *Gateio) ListSpotCurrencies(ctx context.Context) ([]CurrencyInfo, error) { var resp []CurrencyInfo - return resp, g.SendHTTPRequest(ctx, exchange.RestSpot, spotDefaultEPL, gateioSpotCurrencies, &resp) + return resp, g.SendHTTPRequest(ctx, exchange.RestSpot, publicCurrenciesSpotEPL, gateioSpotCurrencies, &resp) } // GetCurrencyDetail details of a specific currency. @@ -273,14 +272,13 @@ func (g *Gateio) GetCurrencyDetail(ctx context.Context, ccy currency.Code) (*Cur return nil, currency.ErrCurrencyCodeEmpty } var resp *CurrencyInfo - return resp, g.SendHTTPRequest(ctx, exchange.RestSpot, spotDefaultEPL, - gateioSpotCurrencies+"/"+ccy.String(), &resp) + return resp, g.SendHTTPRequest(ctx, exchange.RestSpot, publicCurrenciesSpotEPL, gateioSpotCurrencies+"/"+ccy.String(), &resp) } // ListSpotCurrencyPairs retrieve all currency pairs supported by the exchange. func (g *Gateio) ListSpotCurrencyPairs(ctx context.Context) ([]CurrencyPairDetail, error) { var resp []CurrencyPairDetail - return resp, g.SendHTTPRequest(ctx, exchange.RestSpot, spotDefaultEPL, gateioSpotCurrencyPairs, &resp) + return resp, g.SendHTTPRequest(ctx, exchange.RestSpot, publicListCurrencyPairsSpotEPL, gateioSpotCurrencyPairs, &resp) } // GetCurrencyPairDetail to get details of a specific order for spot/margin accounts. @@ -289,8 +287,7 @@ func (g *Gateio) GetCurrencyPairDetail(ctx context.Context, currencyPair string) return nil, currency.ErrCurrencyPairEmpty } var resp *CurrencyPairDetail - return resp, g.SendHTTPRequest(ctx, exchange.RestSpot, spotDefaultEPL, - gateioSpotCurrencyPairs+"/"+currencyPair, &resp) + return resp, g.SendHTTPRequest(ctx, exchange.RestSpot, publicCurrencyPairDetailSpotEPL, gateioSpotCurrencyPairs+"/"+currencyPair, &resp) } // GetTickers retrieve ticker information @@ -306,7 +303,7 @@ func (g *Gateio) GetTickers(ctx context.Context, currencyPair, timezone string) params.Set("timezone", timezone) } var tickers []Ticker - return tickers, g.SendHTTPRequest(ctx, exchange.RestSpot, spotDefaultEPL, common.EncodeURLValues(gateioSpotTickers, params), &tickers) + return tickers, g.SendHTTPRequest(ctx, exchange.RestSpot, publicTickersSpotEPL, common.EncodeURLValues(gateioSpotTickers, params), &tickers) } // GetTicker retrieves a single ticker information for a currency pair. @@ -419,7 +416,7 @@ func (g *Gateio) GetOrderbook(ctx context.Context, pairString, interval string, } params.Set("with_id", strconv.FormatBool(withOrderbookID)) var response *OrderbookData - err := g.SendHTTPRequest(ctx, exchange.RestSpot, spotDefaultEPL, common.EncodeURLValues(gateioSpotOrderbook, params), &response) + err := g.SendHTTPRequest(ctx, exchange.RestSpot, publicOrderbookSpotEPL, common.EncodeURLValues(gateioSpotOrderbook, params), &response) if err != nil { return nil, err } @@ -452,8 +449,7 @@ func (g *Gateio) GetMarketTrades(ctx context.Context, pairString currency.Pair, params.Set("page", strconv.FormatUint(page, 10)) } var response []Trade - return response, g.SendHTTPRequest(ctx, exchange.RestSpot, spotDefaultEPL, - common.EncodeURLValues(gateioSpotMarketTrades, params), &response) + return response, g.SendHTTPRequest(ctx, exchange.RestSpot, publicMarketTradesSpotEPL, common.EncodeURLValues(gateioSpotMarketTrades, params), &response) } // GetCandlesticks retrieves market candlesticks. @@ -482,7 +478,7 @@ func (g *Gateio) GetCandlesticks(ctx context.Context, currencyPair currency.Pair params.Set("to", strconv.FormatInt(to.Unix(), 10)) } var candles [][7]string - err = g.SendHTTPRequest(ctx, exchange.RestSpot, spotDefaultEPL, common.EncodeURLValues(gateioSpotCandlesticks, params), &candles) + err = g.SendHTTPRequest(ctx, exchange.RestSpot, publicCandleStickSpotEPL, common.EncodeURLValues(gateioSpotCandlesticks, params), &candles) if err != nil { return nil, err } @@ -540,8 +536,7 @@ func (g *Gateio) GetTradingFeeRatio(ctx context.Context, currencyPair currency.P params.Set("currency_pair", currencyPair.String()) } var response *SpotTradingFeeRate - return response, g.SendAuthenticatedHTTPRequest(ctx, - exchange.RestSpot, spotPrivateEPL, http.MethodGet, gateioSpotFeeRate, params, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, spotTradingFeeEPL, http.MethodGet, gateioSpotFeeRate, params, nil, &response) } // GetSpotAccounts retrieves spot account. @@ -551,8 +546,7 @@ func (g *Gateio) GetSpotAccounts(ctx context.Context, ccy currency.Code) ([]Spot params.Set("currency", ccy.String()) } var response []SpotAccount - return response, g.SendAuthenticatedHTTPRequest(ctx, - exchange.RestSpot, spotPrivateEPL, http.MethodGet, gateioSpotAccounts, params, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, spotAccountsEPL, http.MethodGet, gateioSpotAccounts, params, nil, &response) } // GetUnifiedAccount retrieves unified account. @@ -562,7 +556,7 @@ func (g *Gateio) GetUnifiedAccount(ctx context.Context, ccy currency.Code) (*Uni params.Set("currency", ccy.String()) } var response UnifiedUserAccount - return &response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, spotPrivateEPL, http.MethodGet, gateioUnifiedAccounts, params, nil, &response) + return &response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, privateUnifiedSpotEPL, http.MethodGet, gateioUnifiedAccounts, params, nil, &response) } // CreateBatchOrders Create a batch of orders Batch orders requirements: custom order field text is required At most 4 currency pairs, @@ -598,14 +592,14 @@ func (g *Gateio) CreateBatchOrders(ctx context.Context, args []CreateOrderReques } } var response []SpotOrder - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, spotPlaceOrdersEPL, http.MethodPost, gateioSpotBatchOrders, nil, &args, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, spotBatchOrdersEPL, http.MethodPost, gateioSpotBatchOrders, nil, &args, &response) } -// GateioSpotOpenOrders retrieves all open orders +// GetSpotOpenOrders retrieves all open orders // List open orders in all currency pairs. // Note that pagination parameters affect record number in each currency pair's open order list. No pagination is applied to the number of currency pairs returned. All currency pairs with open orders will be returned. // Spot and margin orders are returned by default. To list cross margin orders, account must be set to cross_margin -func (g *Gateio) GateioSpotOpenOrders(ctx context.Context, page, limit uint64, isCrossMargin bool) ([]SpotOrdersDetail, error) { +func (g *Gateio) GetSpotOpenOrders(ctx context.Context, page, limit uint64, isCrossMargin bool) ([]SpotOrdersDetail, error) { params := url.Values{} if page > 0 { params.Set("page", strconv.FormatUint(page, 10)) @@ -617,7 +611,7 @@ func (g *Gateio) GateioSpotOpenOrders(ctx context.Context, page, limit uint64, i params.Set("account", asset.CrossMargin.String()) } var response []SpotOrdersDetail - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, spotPrivateEPL, http.MethodGet, gateioSpotOpenOrders, params, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, spotGetOpenOrdersEPL, http.MethodGet, gateioSpotOpenOrders, params, nil, &response) } // SpotClosePositionWhenCrossCurrencyDisabled set close position when cross-currency is disabled @@ -635,8 +629,7 @@ func (g *Gateio) SpotClosePositionWhenCrossCurrencyDisabled(ctx context.Context, return nil, errInvalidPrice } var response *SpotOrder - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, spotPrivateEPL, - http.MethodPost, gateioSpotClosePositionWhenCrossCurrencyDisabledPath, nil, &arg, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, spotClosePositionEPL, http.MethodPost, gateioSpotClosePositionWhenCrossCurrencyDisabledPath, nil, &arg, &response) } // PlaceSpotOrder creates a spot order you can place orders with spot, margin or cross margin account through setting the accountfield. @@ -664,7 +657,7 @@ func (g *Gateio) PlaceSpotOrder(ctx context.Context, arg *CreateOrderRequestData return nil, errInvalidPrice } var response *SpotOrder - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, spotPlaceOrdersEPL, http.MethodPost, gateioSpotOrders, nil, &arg, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, spotPlaceOrderEPL, http.MethodPost, gateioSpotOrders, nil, &arg, &response) } // GetSpotOrders retrieves spot orders. @@ -684,7 +677,7 @@ func (g *Gateio) GetSpotOrders(ctx context.Context, currencyPair currency.Pair, params.Set("limit", strconv.FormatUint(limit, 10)) } var response []SpotOrder - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, spotPlaceOrdersEPL, http.MethodGet, gateioSpotOrders, params, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, spotGetOrdersEPL, http.MethodGet, gateioSpotOrders, params, nil, &response) } // CancelAllOpenOrdersSpecifiedCurrencyPair cancel all open orders in specified currency pair @@ -701,8 +694,7 @@ func (g *Gateio) CancelAllOpenOrdersSpecifiedCurrencyPair(ctx context.Context, c params.Set("account", account.String()) } var response []SpotOrder - return response, g.SendAuthenticatedHTTPRequest(ctx, - exchange.RestSpot, spotCancelOrdersEPL, http.MethodDelete, gateioSpotOrders, params, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, spotCancelAllOpenOrdersEPL, http.MethodDelete, gateioSpotOrders, params, nil, &response) } // CancelBatchOrdersWithIDList cancels batch orders specifying the order ID and currency pair information @@ -719,7 +711,7 @@ func (g *Gateio) CancelBatchOrdersWithIDList(ctx context.Context, args []CancelO return nil, errors.New("currency pair and order ID are required") } } - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, spotCancelOrdersEPL, http.MethodPost, gateioSpotCancelBatchOrders, nil, &args, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, spotCancelBatchOrdersEPL, http.MethodPost, gateioSpotCancelBatchOrders, nil, &args, &response) } // GetSpotOrder retrieves a single spot order using the order id and currency pair information. @@ -736,8 +728,7 @@ func (g *Gateio) GetSpotOrder(ctx context.Context, orderID string, currencyPair params.Set("account", accountType) } var response *SpotOrder - return response, g.SendAuthenticatedHTTPRequest(ctx, - exchange.RestSpot, spotPrivateEPL, http.MethodGet, gateioSpotOrders+"/"+orderID, params, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, spotGetOrderEPL, http.MethodGet, gateioSpotOrders+"/"+orderID, params, nil, &response) } // AmendSpotOrder amend an order @@ -763,7 +754,7 @@ func (g *Gateio) AmendSpotOrder(ctx context.Context, orderID string, currencyPai return nil, errors.New("only can chose one of amount or price") } var resp *SpotOrder - return resp, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, spotPlaceOrdersEPL, http.MethodPatch, gateioSpotOrders+"/"+orderID, params, arg, &resp) + return resp, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, spotAmendOrderEPL, http.MethodPatch, gateioSpotOrders+"/"+orderID, params, arg, &resp) } // CancelSingleSpotOrder cancels a single order @@ -782,8 +773,7 @@ func (g *Gateio) CancelSingleSpotOrder(ctx context.Context, orderID, currencyPai params.Set("account", asset.CrossMargin.String()) } var response *SpotOrder - return response, g.SendAuthenticatedHTTPRequest(ctx, - exchange.RestSpot, spotCancelOrdersEPL, http.MethodDelete, gateioSpotOrders+"/"+orderID, params, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, spotCancelSingleOrderEPL, http.MethodDelete, gateioSpotOrders+"/"+orderID, params, nil, &response) } // GateIOGetPersonalTradingHistory retrieves personal trading history @@ -812,7 +802,7 @@ func (g *Gateio) GateIOGetPersonalTradingHistory(ctx context.Context, currencyPa params.Set("to", strconv.FormatInt(to.Unix(), 10)) } var response []SpotPersonalTradeHistory - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, spotPrivateEPL, http.MethodGet, gateioSpotMyTrades, params, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, spotTradingHistoryEPL, http.MethodGet, gateioSpotMyTrades, params, nil, &response) } // GetServerTime retrieves current server time @@ -820,7 +810,7 @@ func (g *Gateio) GetServerTime(ctx context.Context, _ asset.Item) (time.Time, er resp := struct { ServerTime int64 `json:"server_time"` }{} - err := g.SendHTTPRequest(ctx, exchange.RestSpot, spotDefaultEPL, gateioSpotServerTime, &resp) + err := g.SendHTTPRequest(ctx, exchange.RestSpot, publicGetServerTimeEPL, gateioSpotServerTime, &resp) if err != nil { return time.Time{}, err } @@ -835,7 +825,7 @@ func (g *Gateio) CountdownCancelorders(ctx context.Context, arg CountdownCancelO return nil, errInvalidCountdown } var response *TriggerTimeResponse - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, spotCancelOrdersEPL, http.MethodPost, gateioSpotAllCountdown, nil, &arg, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, spotCountdownCancelEPL, http.MethodPost, gateioSpotAllCountdown, nil, &arg, &response) } // CreatePriceTriggeredOrder create a price-triggered order @@ -877,7 +867,7 @@ func (g *Gateio) CreatePriceTriggeredOrder(ctx context.Context, arg *PriceTrigge arg.Put.Account = "normal" } var response *OrderID - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, spotPlaceOrdersEPL, http.MethodPost, gateioSpotPriceOrders, nil, &arg, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, spotCreateTriggerOrderEPL, http.MethodPost, gateioSpotPriceOrders, nil, &arg, &response) } // GetPriceTriggeredOrderList retrieves price orders created with an order detail and trigger price information. @@ -900,7 +890,7 @@ func (g *Gateio) GetPriceTriggeredOrderList(ctx context.Context, status string, params.Set("offset", strconv.FormatUint(offset, 10)) } var response []SpotPriceTriggeredOrder - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, spotPrivateEPL, http.MethodGet, gateioSpotPriceOrders, params, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, spotGetTriggerOrderListEPL, http.MethodGet, gateioSpotPriceOrders, params, nil, &response) } // CancelMultipleSpotOpenOrders deletes price triggered orders. @@ -918,7 +908,7 @@ func (g *Gateio) CancelMultipleSpotOpenOrders(ctx context.Context, currencyPair params.Set("account", account.String()) } var response []SpotPriceTriggeredOrder - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, spotCancelOrdersEPL, http.MethodDelete, gateioSpotPriceOrders, params, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, spotCancelTriggerOrdersEPL, http.MethodDelete, gateioSpotPriceOrders, params, nil, &response) } // GetSinglePriceTriggeredOrder get a single order @@ -927,7 +917,7 @@ func (g *Gateio) GetSinglePriceTriggeredOrder(ctx context.Context, orderID strin return nil, errInvalidOrderID } var response *SpotPriceTriggeredOrder - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, spotPrivateEPL, http.MethodGet, gateioSpotPriceOrders+"/"+orderID, nil, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, spotGetTriggerOrderEPL, http.MethodGet, gateioSpotPriceOrders+"/"+orderID, nil, nil, &response) } // CancelPriceTriggeredOrder cancel a price-triggered order @@ -936,7 +926,7 @@ func (g *Gateio) CancelPriceTriggeredOrder(ctx context.Context, orderID string) return nil, errInvalidOrderID } var response *SpotPriceTriggeredOrder - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, spotCancelOrdersEPL, http.MethodGet, gateioSpotPriceOrders+"/"+orderID, nil, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, spotCancelTriggerOrderEPL, http.MethodGet, gateioSpotPriceOrders+"/"+orderID, nil, nil, &response) } // GenerateSignature returns hash for authenticated requests @@ -1070,7 +1060,7 @@ func (g *Gateio) WithdrawCurrency(ctx context.Context, arg WithdrawalRequestPara return nil, errors.New("name of the chain used for withdrawal must be specified") } var response *WithdrawalResponse - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, withdrawalEPL, http.MethodPost, withdrawal, nil, &arg, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, walletWithdrawEPL, http.MethodPost, withdrawal, nil, &arg, &response) } // CancelWithdrawalWithSpecifiedID cancels withdrawal with specified ID. @@ -1079,7 +1069,7 @@ func (g *Gateio) CancelWithdrawalWithSpecifiedID(ctx context.Context, withdrawal return nil, errMissingWithdrawalID } var response *WithdrawalResponse - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, withdrawalEPL, http.MethodDelete, withdrawal+"/"+withdrawalID, nil, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, walletCancelWithdrawEPL, http.MethodDelete, withdrawal+"/"+withdrawalID, nil, nil, &response) } // *********************************** Wallet *********************************** @@ -1092,7 +1082,7 @@ func (g *Gateio) ListCurrencyChain(ctx context.Context, ccy currency.Code) ([]Cu params := url.Values{} params.Set("currency", ccy.String()) var resp []CurrencyChain - return resp, g.SendHTTPRequest(ctx, exchange.RestSpot, walletEPL, common.EncodeURLValues(walletCurrencyChain, params), &resp) + return resp, g.SendHTTPRequest(ctx, exchange.RestSpot, publicListCurrencyChainEPL, common.EncodeURLValues(walletCurrencyChain, params), &resp) } // GenerateCurrencyDepositAddress generate currency deposit address @@ -1103,8 +1093,7 @@ func (g *Gateio) GenerateCurrencyDepositAddress(ctx context.Context, ccy currenc params := url.Values{} params.Set("currency", ccy.String()) var response *CurrencyDepositAddressInfo - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, walletEPL, - http.MethodGet, walletDepositAddress, params, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, walletDepositAddressEPL, http.MethodGet, walletDepositAddress, params, nil, &response) } // GetWithdrawalRecords retrieves withdrawal records. Record time range cannot exceed 30 days @@ -1128,8 +1117,7 @@ func (g *Gateio) GetWithdrawalRecords(ctx context.Context, ccy currency.Code, fr } } var withdrawals []WithdrawalResponse - return withdrawals, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, walletEPL, - http.MethodGet, walletWithdrawals, params, nil, &withdrawals) + return withdrawals, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, walletWithdrawalRecordsEPL, http.MethodGet, walletWithdrawals, params, nil, &withdrawals) } // GetDepositRecords retrieves deposit records. Record time range cannot exceed 30 days @@ -1151,8 +1139,7 @@ func (g *Gateio) GetDepositRecords(ctx context.Context, ccy currency.Code, from, } } var depositHistories []DepositRecord - return depositHistories, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, walletEPL, - http.MethodGet, walletDeposits, params, nil, &depositHistories) + return depositHistories, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, walletDepositRecordsEPL, http.MethodGet, walletDeposits, params, nil, &depositHistories) } // TransferCurrency Transfer between different accounts. Currently support transfers between the following: @@ -1184,7 +1171,7 @@ func (g *Gateio) TransferCurrency(ctx context.Context, arg *TransferCurrencyPara return nil, errInvalidAmount } var response *TransactionIDResponse - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, walletEPL, http.MethodPost, walletTransfer, nil, &arg, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, walletTransferCurrencyEPL, http.MethodPost, walletTransfer, nil, &arg, &response) } func (g *Gateio) assetTypeToString(acc asset.Item) string { @@ -1213,7 +1200,7 @@ func (g *Gateio) SubAccountTransfer(ctx context.Context, arg SubAccountTransferP if arg.SubAccountType != "" && arg.SubAccountType != asset.Spot.String() && arg.SubAccountType != asset.Futures.String() && arg.SubAccountType != asset.CrossMargin.String() { return fmt.Errorf("%v; only %v,%v, and %v are allowed", asset.ErrNotSupported, asset.Spot, asset.Futures, asset.CrossMargin) } - return g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, walletEPL, http.MethodPost, walletSubAccountTransfer, nil, &arg, nil) + return g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, walletSubAccountTransferEPL, http.MethodPost, walletSubAccountTransfer, nil, &arg, nil) } // GetSubAccountTransferHistory retrieve transfer records between main and sub accounts. @@ -1241,8 +1228,7 @@ func (g *Gateio) GetSubAccountTransferHistory(ctx context.Context, subAccountUse params.Set("limit", strconv.FormatUint(limit, 10)) } var response []SubAccountTransferResponse - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, walletEPL, - http.MethodGet, walletSubAccountTransfer, params, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, walletSubAccountTransferHistoryEPL, http.MethodGet, walletSubAccountTransfer, params, nil, &response) } // SubAccountTransferToSubAccount performs sub-account transfers to sub-account @@ -1265,7 +1251,7 @@ func (g *Gateio) SubAccountTransferToSubAccount(ctx context.Context, arg *InterS if arg.Amount <= 0 { return errInvalidAmount } - return g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, walletEPL, http.MethodPost, walletInterSubAccountTransfer, nil, &arg, nil) + return g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, walletSubAccountToSubAccountTransferEPL, http.MethodPost, walletInterSubAccountTransfer, nil, &arg, nil) } // GetWithdrawalStatus retrieves withdrawal status @@ -1275,7 +1261,7 @@ func (g *Gateio) GetWithdrawalStatus(ctx context.Context, ccy currency.Code) ([] params.Set("currency", ccy.String()) } var response []WithdrawalStatus - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, walletEPL, http.MethodGet, walletWithdrawStatus, params, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, walletWithdrawStatusEPL, http.MethodGet, walletWithdrawStatus, params, nil, &response) } // GetSubAccountBalances retrieve sub account balances @@ -1285,7 +1271,7 @@ func (g *Gateio) GetSubAccountBalances(ctx context.Context, subAccountUserID str params.Set("sub_uid", subAccountUserID) } var response []FuturesSubAccountBalance - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, walletEPL, http.MethodGet, walletSubAccountBalance, params, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, walletSubAccountBalancesEPL, http.MethodGet, walletSubAccountBalance, params, nil, &response) } // GetSubAccountMarginBalances query sub accounts' margin balances @@ -1295,7 +1281,7 @@ func (g *Gateio) GetSubAccountMarginBalances(ctx context.Context, subAccountUser params.Set("sub_uid", subAccountUserID) } var response []SubAccountMarginBalance - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, walletEPL, http.MethodGet, walletSubAccountMarginBalance, params, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, walletSubAccountMarginBalancesEPL, http.MethodGet, walletSubAccountMarginBalance, params, nil, &response) } // GetSubAccountFuturesBalances retrieves sub accounts' futures account balances @@ -1308,7 +1294,7 @@ func (g *Gateio) GetSubAccountFuturesBalances(ctx context.Context, subAccountUse params.Set("settle", settle.Item.Lower) } var response []FuturesSubAccountBalance - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, walletEPL, http.MethodGet, walletSubAccountFuturesBalance, params, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, walletSubAccountFuturesBalancesEPL, http.MethodGet, walletSubAccountFuturesBalance, params, nil, &response) } // GetSubAccountCrossMarginBalances query subaccount's cross_margin account info @@ -1318,7 +1304,7 @@ func (g *Gateio) GetSubAccountCrossMarginBalances(ctx context.Context, subAccoun params.Set("sub_uid", subAccountUserID) } var response []SubAccountCrossMarginInfo - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, walletEPL, http.MethodGet, walletSubAccountCrossMarginBalances, params, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, walletSubAccountCrossMarginBalancesEPL, http.MethodGet, walletSubAccountCrossMarginBalances, params, nil, &response) } // GetSavedAddresses retrieves saved currency address info and related details. @@ -1335,7 +1321,7 @@ func (g *Gateio) GetSavedAddresses(ctx context.Context, ccy currency.Code, chain params.Set("limit", strconv.FormatUint(limit, 10)) } var response []WalletSavedAddress - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, walletEPL, http.MethodGet, walletSavedAddress, params, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, walletSavedAddressesEPL, http.MethodGet, walletSavedAddress, params, nil, &response) } // GetPersonalTradingFee retrieves personal trading fee @@ -1349,7 +1335,7 @@ func (g *Gateio) GetPersonalTradingFee(ctx context.Context, currencyPair currenc params.Set("settle", settle.Item.Lower) } var response *PersonalTradingFee - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, walletEPL, http.MethodGet, walletTradingFee, params, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, walletTradingFeeEPL, http.MethodGet, walletTradingFee, params, nil, &response) } // GetUsersTotalBalance retrieves user's total balances @@ -1359,7 +1345,7 @@ func (g *Gateio) GetUsersTotalBalance(ctx context.Context, ccy currency.Code) (* params.Set("currency", ccy.String()) } var response *UsersAllAccountBalance - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, walletEPL, http.MethodGet, walletTotalBalance, params, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, walletTotalBalanceEPL, http.MethodGet, walletTotalBalance, params, nil, &response) } // ********************************* Margin ******************************************* @@ -1367,7 +1353,7 @@ func (g *Gateio) GetUsersTotalBalance(ctx context.Context, ccy currency.Code) (* // GetMarginSupportedCurrencyPairs retrieves margin supported currency pairs. func (g *Gateio) GetMarginSupportedCurrencyPairs(ctx context.Context) ([]MarginCurrencyPairInfo, error) { var currenciePairsInfo []MarginCurrencyPairInfo - return currenciePairsInfo, g.SendHTTPRequest(ctx, exchange.RestSpot, spotDefaultEPL, gateioMarginCurrencyPairs, ¤ciePairsInfo) + return currenciePairsInfo, g.SendHTTPRequest(ctx, exchange.RestSpot, publicCurrencyPairsMarginEPL, gateioMarginCurrencyPairs, ¤ciePairsInfo) } // GetSingleMarginSupportedCurrencyPair retrieves margin supported currency pair detail given the currency pair. @@ -1376,7 +1362,7 @@ func (g *Gateio) GetSingleMarginSupportedCurrencyPair(ctx context.Context, marke return nil, currency.ErrCurrencyPairEmpty } var currencyPairInfo *MarginCurrencyPairInfo - return currencyPairInfo, g.SendHTTPRequest(ctx, exchange.RestSpot, spotDefaultEPL, gateioMarginCurrencyPairs+"/"+market.String(), ¤cyPairInfo) + return currencyPairInfo, g.SendHTTPRequest(ctx, exchange.RestSpot, publicCurrencyPairsMarginEPL, gateioMarginCurrencyPairs+"/"+market.String(), ¤cyPairInfo) } // GetOrderbookOfLendingLoans retrieves order book of lending loans for specific currency @@ -1385,8 +1371,7 @@ func (g *Gateio) GetOrderbookOfLendingLoans(ctx context.Context, ccy currency.Co return nil, currency.ErrCurrencyCodeEmpty } var lendingLoans []OrderbookOfLendingLoan - return lendingLoans, g.SendHTTPRequest(ctx, exchange.RestSpot, spotDefaultEPL, - gateioMarginFundingBook+"?currency="+ccy.String(), &lendingLoans) + return lendingLoans, g.SendHTTPRequest(ctx, exchange.RestSpot, publicOrderbookMarginEPL, gateioMarginFundingBook+"?currency="+ccy.String(), &lendingLoans) } // GetMarginAccountList margin account list @@ -1396,7 +1381,7 @@ func (g *Gateio) GetMarginAccountList(ctx context.Context, currencyPair currency params.Set("currency_pair", currencyPair.String()) } var response []MarginAccountItem - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, spotPrivateEPL, http.MethodGet, gateioMarginAccount, params, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, marginAccountListEPL, http.MethodGet, gateioMarginAccount, params, nil, &response) } // ListMarginAccountBalanceChangeHistory retrieves margin account balance change history @@ -1422,7 +1407,7 @@ func (g *Gateio) ListMarginAccountBalanceChangeHistory(ctx context.Context, ccy params.Set("limit", strconv.FormatUint(limit, 10)) } var response []MarginAccountBalanceChangeInfo - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, spotPrivateEPL, http.MethodGet, gateioMarginAccountBook, params, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, marginAccountBalanceEPL, http.MethodGet, gateioMarginAccountBook, params, nil, &response) } // GetMarginFundingAccountList retrieves funding account list @@ -1432,7 +1417,7 @@ func (g *Gateio) GetMarginFundingAccountList(ctx context.Context, ccy currency.C params.Set("currency", ccy.String()) } var response []MarginFundingAccountItem - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, spotPrivateEPL, http.MethodGet, gateioMarginFundingAccounts, params, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, marginFundingAccountListEPL, http.MethodGet, gateioMarginFundingAccounts, params, nil, &response) } // MarginLoan represents lend or borrow request @@ -1456,7 +1441,7 @@ func (g *Gateio) MarginLoan(ctx context.Context, arg *MarginLoanRequestParam) (* return nil, errors.New("invalid loan rate, rate must be between 0.0002 and 0.002") } var response *MarginLoanResponse - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, spotPlaceOrdersEPL, http.MethodPost, gateioMarginLoans, nil, &arg, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, marginLendBorrowEPL, http.MethodPost, gateioMarginLoans, nil, &arg, &response) } // GetMarginAllLoans retrieves all loans (borrow and lending) orders. @@ -1490,7 +1475,7 @@ func (g *Gateio) GetMarginAllLoans(ctx context.Context, status, side, sortBy str params.Set("limit", strconv.FormatUint(limit, 10)) } var response []MarginLoanResponse - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, spotPrivateEPL, http.MethodGet, gateioMarginLoans, params, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, marginAllLoansEPL, http.MethodGet, gateioMarginLoans, params, nil, &response) } // MergeMultipleLendingLoans merge multiple lending loans @@ -1505,7 +1490,7 @@ func (g *Gateio) MergeMultipleLendingLoans(ctx context.Context, ccy currency.Cod params.Set("currency", ccy.String()) params.Set("ids", strings.Join(ids, ",")) var response *MarginLoanResponse - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, spotPlaceOrdersEPL, http.MethodPost, gateioMarginMergedLoans, params, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, marginMergeLendingLoansEPL, http.MethodPost, gateioMarginMergedLoans, params, nil, &response) } // RetriveOneSingleLoanDetail retrieve one single loan detail @@ -1520,7 +1505,7 @@ func (g *Gateio) RetriveOneSingleLoanDetail(ctx context.Context, side, loanID st params := url.Values{} params.Set("side", side) var response *MarginLoanResponse - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, spotPrivateEPL, http.MethodGet, gateioMarginLoans+"/"+loanID+"/", params, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, marginGetLoanEPL, http.MethodGet, gateioMarginLoans+"/"+loanID+"/", params, nil, &response) } // ModifyALoan Modify a loan @@ -1542,7 +1527,7 @@ func (g *Gateio) ModifyALoan(ctx context.Context, loanID string, arg *ModifyLoan return nil, currency.ErrCurrencyPairEmpty } var response *MarginLoanResponse - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, spotPlaceOrdersEPL, http.MethodPatch, gateioMarginLoans+"/"+loanID, nil, &arg, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, marginModifyLoanEPL, http.MethodPatch, gateioMarginLoans+"/"+loanID, nil, &arg, &response) } // CancelLendingLoan cancels lending loans. only lent loans can be canceled. @@ -1556,7 +1541,7 @@ func (g *Gateio) CancelLendingLoan(ctx context.Context, ccy currency.Code, loanI params := url.Values{} params.Set("currency", ccy.String()) var response *MarginLoanResponse - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, spotPlaceOrdersEPL, http.MethodDelete, gateioMarginLoans+"/"+loanID, params, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, marginCancelLoanEPL, http.MethodDelete, gateioMarginLoans+"/"+loanID, params, nil, &response) } // RepayALoan execute a loan repay. @@ -1580,7 +1565,7 @@ func (g *Gateio) RepayALoan(ctx context.Context, loanID string, arg *RepayLoanRe return nil, fmt.Errorf("%w, repay amount for partial repay mode must be greater than 0", errInvalidAmount) } var response *MarginLoanResponse - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, spotPlaceOrdersEPL, http.MethodPost, gateioMarginLoans+"/"+loanID+"/repayment", nil, &arg, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, marginRepayLoanEPL, http.MethodPost, gateioMarginLoans+"/"+loanID+"/repayment", nil, &arg, &response) } // ListLoanRepaymentRecords retrieves loan repayment records for specified loan ID @@ -1589,7 +1574,7 @@ func (g *Gateio) ListLoanRepaymentRecords(ctx context.Context, loanID string) ([ return nil, fmt.Errorf("%w, %v", errInvalidLoanID, " loan_id is required") } var response []LoanRepaymentRecord - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, spotPrivateEPL, http.MethodGet, gateioMarginLoans+"/"+loanID+"/repayment", nil, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, marginListLoansEPL, http.MethodGet, gateioMarginLoans+"/"+loanID+"/repayment", nil, nil, &response) } // ListRepaymentRecordsOfSpecificLoan retrieves repayment records of specific loan @@ -1609,7 +1594,7 @@ func (g *Gateio) ListRepaymentRecordsOfSpecificLoan(ctx context.Context, loanID, params.Set("limit", strconv.FormatUint(limit, 10)) } var response []LoanRecord - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, spotPrivateEPL, http.MethodGet, gateioMarginLoanRecords, params, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, marginRepaymentRecordEPL, http.MethodGet, gateioMarginLoanRecords, params, nil, &response) } // GetOneSingleLoanRecord get one single loan record @@ -1623,7 +1608,7 @@ func (g *Gateio) GetOneSingleLoanRecord(ctx context.Context, loanID, loanRecordI params := url.Values{} params.Set("loan_id", loanID) var response *LoanRecord - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, spotPrivateEPL, http.MethodGet, gateioMarginLoanRecords+"/"+loanRecordID, params, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, marginSingleRecordEPL, http.MethodGet, gateioMarginLoanRecords+"/"+loanRecordID, params, nil, &response) } // ModifyALoanRecord modify a loan record @@ -1645,7 +1630,7 @@ func (g *Gateio) ModifyALoanRecord(ctx context.Context, loanRecordID string, arg return nil, errInvalidLoanSide } var response *LoanRecord - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, spotPlaceOrdersEPL, http.MethodPatch, gateioMarginLoanRecords+"/"+loanRecordID, nil, &arg, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, marginModifyLoanRecordEPL, http.MethodPatch, gateioMarginLoanRecords+"/"+loanRecordID, nil, &arg, &response) } // UpdateUsersAutoRepaymentSetting represents update user's auto repayment setting @@ -1659,13 +1644,13 @@ func (g *Gateio) UpdateUsersAutoRepaymentSetting(ctx context.Context, statusOn b params := url.Values{} params.Set("status", statusStr) var response *OnOffStatus - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, spotPlaceOrdersEPL, http.MethodPost, gateioMarginAutoRepay, params, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, marginAutoRepayEPL, http.MethodPost, gateioMarginAutoRepay, params, nil, &response) } // GetUserAutoRepaymentSetting retrieve user auto repayment setting func (g *Gateio) GetUserAutoRepaymentSetting(ctx context.Context) (*OnOffStatus, error) { var response *OnOffStatus - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, spotPrivateEPL, http.MethodGet, gateioMarginAutoRepay, nil, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, marginGetAutoRepaySettingsEPL, http.MethodGet, gateioMarginAutoRepay, nil, nil, &response) } // GetMaxTransferableAmountForSpecificMarginCurrency get the max transferable amount for a specific margin currency. @@ -1679,7 +1664,7 @@ func (g *Gateio) GetMaxTransferableAmountForSpecificMarginCurrency(ctx context.C } params.Set("currency", ccy.String()) var response *MaxTransferAndLoanAmount - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, spotPrivateEPL, http.MethodGet, gateioMarginTransfer, params, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, marginGetMaxTransferEPL, http.MethodGet, gateioMarginTransfer, params, nil, &response) } // GetMaxBorrowableAmountForSpecificMarginCurrency retrieves the max borrowble amount for specific currency @@ -1693,13 +1678,13 @@ func (g *Gateio) GetMaxBorrowableAmountForSpecificMarginCurrency(ctx context.Con } params.Set("currency", ccy.String()) var response *MaxTransferAndLoanAmount - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, spotPrivateEPL, http.MethodGet, gateioMarginBorrowable, params, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, marginGetMaxBorrowEPL, http.MethodGet, gateioMarginBorrowable, params, nil, &response) } // CurrencySupportedByCrossMargin currencies supported by cross margin. func (g *Gateio) CurrencySupportedByCrossMargin(ctx context.Context) ([]CrossMarginCurrencies, error) { var response []CrossMarginCurrencies - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, spotPrivateEPL, http.MethodGet, gateioCrossMarginCurrencies, nil, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, marginSupportedCurrencyCrossListEPL, http.MethodGet, gateioCrossMarginCurrencies, nil, nil, &response) } // GetCrossMarginSupportedCurrencyDetail retrieve detail of one single currency supported by cross margin @@ -1708,13 +1693,13 @@ func (g *Gateio) GetCrossMarginSupportedCurrencyDetail(ctx context.Context, ccy return nil, currency.ErrCurrencyCodeEmpty } var response *CrossMarginCurrencies - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, spotPrivateEPL, http.MethodGet, gateioCrossMarginCurrencies+"/"+ccy.String(), nil, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, marginSupportedCurrencyCrossEPL, http.MethodGet, gateioCrossMarginCurrencies+"/"+ccy.String(), nil, nil, &response) } // GetCrossMarginAccounts retrieve cross margin account func (g *Gateio) GetCrossMarginAccounts(ctx context.Context) (*CrossMarginAccount, error) { var response *CrossMarginAccount - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, spotPrivateEPL, http.MethodGet, gateioCrossMarginAccounts, nil, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, marginAccountsEPL, http.MethodGet, gateioCrossMarginAccounts, nil, nil, &response) } // GetCrossMarginAccountChangeHistory retrieve cross margin account change history @@ -1740,7 +1725,7 @@ func (g *Gateio) GetCrossMarginAccountChangeHistory(ctx context.Context, ccy cur params.Set("type", accountChangeType) } var response []CrossMarginAccountHistoryItem - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, spotPrivateEPL, http.MethodGet, gateioCrossMarginAccountBook, params, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, marginAccountHistoryEPL, http.MethodGet, gateioCrossMarginAccountBook, params, nil, &response) } // CreateCrossMarginBorrowLoan create a cross margin borrow loan @@ -1753,7 +1738,7 @@ func (g *Gateio) CreateCrossMarginBorrowLoan(ctx context.Context, arg CrossMargi return nil, fmt.Errorf("%w, borrow amount must be greater than 0", errInvalidAmount) } var response CrossMarginLoanResponse - return &response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, spotPlaceOrdersEPL, http.MethodPost, gateioCrossMarginLoans, nil, &arg, &response) + return &response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, marginCreateCrossBorrowLoanEPL, http.MethodPost, gateioCrossMarginLoans, nil, &arg, &response) } // ExecuteRepayment when the liquidity of the currency is insufficient and the transaction risk is high, the currency will be disabled, @@ -1767,7 +1752,7 @@ func (g *Gateio) ExecuteRepayment(ctx context.Context, arg CurrencyAndAmount) ([ return nil, fmt.Errorf("%w, repay amount must be greater than 0", errInvalidAmount) } var response []CrossMarginLoanResponse - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, spotPlaceOrdersEPL, http.MethodPost, gateioCrossMarginRepayments, nil, &arg, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, marginExecuteRepaymentsEPL, http.MethodPost, gateioCrossMarginRepayments, nil, &arg, &response) } // GetCrossMarginRepayments retrieves list of cross margin repayments @@ -1789,7 +1774,7 @@ func (g *Gateio) GetCrossMarginRepayments(ctx context.Context, ccy currency.Code params.Set("reverse", "true") } var response []CrossMarginLoanResponse - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, spotPrivateEPL, http.MethodGet, gateioCrossMarginRepayments, params, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, marginGetCrossMarginRepaymentsEPL, http.MethodGet, gateioCrossMarginRepayments, params, nil, &response) } // GetMaxTransferableAmountForSpecificCrossMarginCurrency get the max transferable amount for a specific cross margin currency @@ -1800,7 +1785,7 @@ func (g *Gateio) GetMaxTransferableAmountForSpecificCrossMarginCurrency(ctx cont params := url.Values{} var response *CurrencyAndAmount params.Set("currency", ccy.String()) - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, spotPrivateEPL, http.MethodGet, gateioCrossMarginTransferable, params, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, marginGetMaxTransferCrossEPL, http.MethodGet, gateioCrossMarginTransferable, params, nil, &response) } // GetMaxBorrowableAmountForSpecificCrossMarginCurrency returns the max borrowable amount for a specific cross margin currency @@ -1811,7 +1796,7 @@ func (g *Gateio) GetMaxBorrowableAmountForSpecificCrossMarginCurrency(ctx contex params := url.Values{} params.Set("currency", ccy.String()) var response *CurrencyAndAmount - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, spotPrivateEPL, http.MethodGet, gateioCrossMarginBorrowable, params, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, marginGetMaxBorrowCrossEPL, http.MethodGet, gateioCrossMarginBorrowable, params, nil, &response) } // GetCrossMarginBorrowHistory retrieves cross margin borrow history sorted by creation time in descending order by default. @@ -1835,7 +1820,7 @@ func (g *Gateio) GetCrossMarginBorrowHistory(ctx context.Context, status uint64, params.Set("reverse", strconv.FormatBool(reverse)) } var response []CrossMarginLoanResponse - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, spotPrivateEPL, http.MethodGet, gateioCrossMarginLoans, params, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, marginGetCrossBorrowHistoryEPL, http.MethodGet, gateioCrossMarginLoans, params, nil, &response) } // GetSingleBorrowLoanDetail retrieve single borrow loan detail @@ -1844,18 +1829,18 @@ func (g *Gateio) GetSingleBorrowLoanDetail(ctx context.Context, loanID string) ( return nil, errInvalidLoanID } var response *CrossMarginLoanResponse - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, spotPrivateEPL, http.MethodGet, gateioCrossMarginLoans+"/"+loanID, nil, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, marginGetBorrowEPL, http.MethodGet, gateioCrossMarginLoans+"/"+loanID, nil, nil, &response) } // *********************************Futures*************************************** -// GetAllFutureContracts retrieves list all futures contracts +// GetAllFutureContracts retrieves list all futures contracts func (g *Gateio) GetAllFutureContracts(ctx context.Context, settle currency.Code) ([]FuturesContract, error) { if settle.IsEmpty() { return nil, errEmptyOrInvalidSettlementCurrency } var contracts []FuturesContract - return contracts, g.SendHTTPRequest(ctx, exchange.RestSpot, perpetualSwapDefaultEPL, futuresPath+settle.Item.Lower+"/contracts", &contracts) + return contracts, g.SendHTTPRequest(ctx, exchange.RestSpot, publicFuturesContractsEPL, futuresPath+settle.Item.Lower+"/contracts", &contracts) } // GetSingleContract returns a single contract info for the specified settle and Currency Pair (contract << in this case) @@ -1867,7 +1852,7 @@ func (g *Gateio) GetSingleContract(ctx context.Context, settle currency.Code, co return nil, errEmptyOrInvalidSettlementCurrency } var futureContract *FuturesContract - return futureContract, g.SendHTTPRequest(ctx, exchange.RestSpot, perpetualSwapDefaultEPL, futuresPath+settle.Item.Lower+"/contracts/"+contract, &futureContract) + return futureContract, g.SendHTTPRequest(ctx, exchange.RestSpot, publicFuturesContractsEPL, futuresPath+settle.Item.Lower+"/contracts/"+contract, &futureContract) } // GetFuturesOrderbook retrieves futures order book data @@ -1890,7 +1875,7 @@ func (g *Gateio) GetFuturesOrderbook(ctx context.Context, settle currency.Code, params.Set("with_id", "true") } var response *Orderbook - return response, g.SendHTTPRequest(ctx, exchange.RestSpot, perpetualSwapDefaultEPL, common.EncodeURLValues(futuresPath+settle.Item.Lower+"/order_book", params), &response) + return response, g.SendHTTPRequest(ctx, exchange.RestSpot, publicOrderbookFuturesEPL, common.EncodeURLValues(futuresPath+settle.Item.Lower+"/order_book", params), &response) } // GetFuturesTradingHistory retrieves futures trading history @@ -1919,8 +1904,7 @@ func (g *Gateio) GetFuturesTradingHistory(ctx context.Context, settle currency.C params.Set("to", strconv.FormatInt(to.Unix(), 10)) } var response []TradingHistoryItem - return response, g.SendHTTPRequest(ctx, exchange.RestSpot, perpetualSwapDefaultEPL, - common.EncodeURLValues(futuresPath+settle.Item.Lower+"/trades", params), &response) + return response, g.SendHTTPRequest(ctx, exchange.RestSpot, publicTradingHistoryFuturesEPL, common.EncodeURLValues(futuresPath+settle.Item.Lower+"/trades", params), &response) } // GetFuturesCandlesticks retrieves specified contract candlesticks. @@ -1950,9 +1934,7 @@ func (g *Gateio) GetFuturesCandlesticks(ctx context.Context, settle currency.Cod params.Set("interval", intervalString) } var candlesticks []FuturesCandlestick - return candlesticks, g.SendHTTPRequest(ctx, exchange.RestFutures, perpetualSwapDefaultEPL, - common.EncodeURLValues(futuresPath+settle.Item.Lower+"/candlesticks", params), - &candlesticks) + return candlesticks, g.SendHTTPRequest(ctx, exchange.RestFutures, publicCandleSticksFuturesEPL, common.EncodeURLValues(futuresPath+settle.Item.Lower+"/candlesticks", params), &candlesticks) } // PremiumIndexKLine retrieves premium Index K-Line @@ -1981,7 +1963,7 @@ func (g *Gateio) PremiumIndexKLine(ctx context.Context, settleCurrency currency. } params.Set("interval", intervalString) var resp []FuturesPremiumIndexKLineResponse - return resp, g.SendHTTPRequest(ctx, exchange.RestSpot, perpetualSwapDefaultEPL, common.EncodeURLValues(futuresPath+settleCurrency.Item.Lower+"/premium_index", params), &resp) + return resp, g.SendHTTPRequest(ctx, exchange.RestSpot, publicPremiumIndexEPL, common.EncodeURLValues(futuresPath+settleCurrency.Item.Lower+"/premium_index", params), &resp) } // GetFuturesTickers retrieves futures ticker information for a specific settle and contract info. @@ -1994,7 +1976,7 @@ func (g *Gateio) GetFuturesTickers(ctx context.Context, settle currency.Code, co params.Set("contract", contract.String()) } var tickers []FuturesTicker - return tickers, g.SendHTTPRequest(ctx, exchange.RestSpot, perpetualSwapDefaultEPL, common.EncodeURLValues(futuresPath+settle.Item.Lower+"/tickers", params), &tickers) + return tickers, g.SendHTTPRequest(ctx, exchange.RestSpot, publicTickersFuturesEPL, common.EncodeURLValues(futuresPath+settle.Item.Lower+"/tickers", params), &tickers) } // GetFutureFundingRates retrieves funding rate information. @@ -2011,7 +1993,7 @@ func (g *Gateio) GetFutureFundingRates(ctx context.Context, settle currency.Code params.Set("limit", strconv.FormatUint(limit, 10)) } var rates []FuturesFundingRate - return rates, g.SendHTTPRequest(ctx, exchange.RestSpot, perpetualSwapDefaultEPL, common.EncodeURLValues(futuresPath+settle.Item.Lower+"/funding_rate", params), &rates) + return rates, g.SendHTTPRequest(ctx, exchange.RestSpot, publicFundingRatesEPL, common.EncodeURLValues(futuresPath+settle.Item.Lower+"/funding_rate", params), &rates) } // GetFuturesInsuranceBalanceHistory retrieves futures insurance balance history @@ -2024,10 +2006,7 @@ func (g *Gateio) GetFuturesInsuranceBalanceHistory(ctx context.Context, settle c params.Set("limit", strconv.FormatUint(limit, 10)) } var balances []InsuranceBalance - return balances, g.SendHTTPRequest(ctx, - exchange.RestSpot, perpetualSwapDefaultEPL, - common.EncodeURLValues(futuresPath+settle.Item.Lower+"/insurance", params), - &balances) + return balances, g.SendHTTPRequest(ctx, exchange.RestSpot, publicInsuranceFuturesEPL, common.EncodeURLValues(futuresPath+settle.Item.Lower+"/insurance", params), &balances) } // GetFutureStats retrieves futures stats @@ -2054,10 +2033,7 @@ func (g *Gateio) GetFutureStats(ctx context.Context, settle currency.Code, contr params.Set("limit", strconv.FormatUint(limit, 10)) } var stats []ContractStat - return stats, g.SendHTTPRequest(ctx, - exchange.RestSpot, perpetualSwapDefaultEPL, - common.EncodeURLValues(futuresPath+settle.Item.Lower+"/contract_stats", params), - &stats) + return stats, g.SendHTTPRequest(ctx, exchange.RestSpot, publicStatsFuturesEPL, common.EncodeURLValues(futuresPath+settle.Item.Lower+"/contract_stats", params), &stats) } // GetIndexConstituent retrieves index constituents @@ -2070,10 +2046,7 @@ func (g *Gateio) GetIndexConstituent(ctx context.Context, settle currency.Code, } indexString := strings.ToUpper(index) var constituents *IndexConstituent - return constituents, g.SendHTTPRequest(ctx, - exchange.RestSpot, perpetualSwapDefaultEPL, - futuresPath+settle.Item.Lower+"/index_constituents/"+indexString, - &constituents) + return constituents, g.SendHTTPRequest(ctx, exchange.RestSpot, publicIndexConstituentsEPL, futuresPath+settle.Item.Lower+"/index_constituents/"+indexString, &constituents) } // GetLiquidationHistory retrieves liqudiation history @@ -2096,10 +2069,7 @@ func (g *Gateio) GetLiquidationHistory(ctx context.Context, settle currency.Code params.Set("limit", strconv.FormatUint(limit, 10)) } var histories []LiquidationHistory - return histories, g.SendHTTPRequest(ctx, - exchange.RestSpot, perpetualSwapDefaultEPL, - common.EncodeURLValues(futuresPath+settle.Item.Lower+"/liq_orders", params), - &histories) + return histories, g.SendHTTPRequest(ctx, exchange.RestSpot, publicLiquidationHistoryEPL, common.EncodeURLValues(futuresPath+settle.Item.Lower+"/liq_orders", params), &histories) } // QueryFuturesAccount retrieves futures account @@ -2108,7 +2078,7 @@ func (g *Gateio) QueryFuturesAccount(ctx context.Context, settle currency.Code) return nil, errEmptyOrInvalidSettlementCurrency } var response *FuturesAccount - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, perpetualSwapPrivateEPL, http.MethodGet, futuresPath+settle.Item.Lower+"/accounts", nil, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, perpetualAccountEPL, http.MethodGet, futuresPath+settle.Item.Lower+"/accounts", nil, nil, &response) } // GetFuturesAccountBooks retrieves account books @@ -2130,11 +2100,7 @@ func (g *Gateio) GetFuturesAccountBooks(ctx context.Context, settle currency.Cod params.Set("type", changingType) } var response []AccountBookItem - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, perpetualSwapPrivateEPL, - http.MethodGet, futuresPath+settle.Item.Lower+"/account_book", - params, - nil, - &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, perpetualAccountBooksEPL, http.MethodGet, futuresPath+settle.Item.Lower+"/account_book", params, nil, &response) } // GetAllFuturesPositionsOfUsers list all positions of users. @@ -2147,7 +2113,7 @@ func (g *Gateio) GetAllFuturesPositionsOfUsers(ctx context.Context, settle curre params.Set("holding", "true") } var response []Position - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, perpetualSwapPrivateEPL, http.MethodGet, futuresPath+settle.Item.Lower+"/positions", params, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, perpetualPositionsEPL, http.MethodGet, futuresPath+settle.Item.Lower+"/positions", params, nil, &response) } // GetSinglePosition returns a single position @@ -2159,9 +2125,7 @@ func (g *Gateio) GetSinglePosition(ctx context.Context, settle currency.Code, co return nil, fmt.Errorf("%w, currency pair for contract must not be empty", errInvalidOrMissingContractParam) } var response *Position - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, perpetualSwapPrivateEPL, - http.MethodPost, futuresPath+settle.Item.Lower+positionsPath+contract.String(), - nil, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, perpetualPositionEPL, http.MethodPost, futuresPath+settle.Item.Lower+positionsPath+contract.String(), nil, nil, &response) } // UpdateFuturesPositionMargin represents account position margin for a futures contract. @@ -2178,10 +2142,7 @@ func (g *Gateio) UpdateFuturesPositionMargin(ctx context.Context, settle currenc params := url.Values{} params.Set("change", strconv.FormatFloat(change, 'f', -1, 64)) var response *Position - return response, g.SendAuthenticatedHTTPRequest(ctx, - exchange.RestSpot, perpetualSwapPlaceOrdersEPL, - http.MethodPost, futuresPath+settle.Item.Lower+positionsPath+contract.String()+"/margin", - params, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, perpetualUpdateMarginEPL, http.MethodPost, futuresPath+settle.Item.Lower+positionsPath+contract.String()+"/margin", params, nil, &response) } // UpdateFuturesPositionLeverage update position leverage @@ -2201,9 +2162,7 @@ func (g *Gateio) UpdateFuturesPositionLeverage(ctx context.Context, settle curre params.Set("cross_leverage_limit", strconv.FormatFloat(crossLeverageLimit, 'f', -1, 64)) } var response *Position - return response, g.SendAuthenticatedHTTPRequest(ctx, - exchange.RestSpot, perpetualSwapPlaceOrdersEPL, http.MethodPost, - futuresPath+settle.Item.Lower+positionsPath+contract.String()+"/leverage", params, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, perpetualUpdateLeverageEPL, http.MethodPost, futuresPath+settle.Item.Lower+positionsPath+contract.String()+"/leverage", params, nil, &response) } // UpdateFuturesPositionRiskLimit updates the position risk limit @@ -2217,8 +2176,7 @@ func (g *Gateio) UpdateFuturesPositionRiskLimit(ctx context.Context, settle curr params := url.Values{} params.Set("risk_limit", strconv.FormatUint(riskLimit, 10)) var response *Position - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, perpetualSwapPlaceOrdersEPL, - http.MethodPost, futuresPath+settle.Item.Lower+positionsPath+contract.String()+"/risk_limit", params, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, perpetualUpdateRiskEPL, http.MethodPost, futuresPath+settle.Item.Lower+positionsPath+contract.String()+"/risk_limit", params, nil, &response) } // EnableOrDisableDualMode enable or disable dual mode @@ -2230,9 +2188,7 @@ func (g *Gateio) EnableOrDisableDualMode(ctx context.Context, settle currency.Co params := url.Values{} params.Set("dual_mode", strconv.FormatBool(dualMode)) var response *DualModeResponse - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, perpetualSwapPrivateEPL, - http.MethodGet, futuresPath+settle.Item.Lower+"/dual_mode", - params, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, perpetualToggleDualModeEPL, http.MethodGet, futuresPath+settle.Item.Lower+"/dual_mode", params, nil, &response) } // RetrivePositionDetailInDualMode retrieve position detail in dual mode @@ -2244,10 +2200,7 @@ func (g *Gateio) RetrivePositionDetailInDualMode(ctx context.Context, settle cur return nil, fmt.Errorf("%w, currency pair for contract must not be empty", errInvalidOrMissingContractParam) } var response []Position - return response, g.SendAuthenticatedHTTPRequest(ctx, - exchange.RestSpot, perpetualSwapPrivateEPL, http.MethodGet, - futuresPath+settle.Item.Lower+"/dual_comp/positions/"+contract.String(), - nil, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, perpetualPositionsDualModeEPL, http.MethodGet, futuresPath+settle.Item.Lower+"/dual_comp/positions/"+contract.String(), nil, nil, &response) } // UpdatePositionMarginInDualMode update position margin in dual mode @@ -2265,10 +2218,7 @@ func (g *Gateio) UpdatePositionMarginInDualMode(ctx context.Context, settle curr } params.Set("dual_side", dualSide) var response []Position - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, perpetualSwapPlaceOrdersEPL, - http.MethodPost, - futuresPath+settle.Item.Lower+"/dual_comp/positions/"+contract.String()+"/margin", - params, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, perpetualUpdateMarginDualModeEPL, http.MethodPost, futuresPath+settle.Item.Lower+"/dual_comp/positions/"+contract.String()+"/margin", params, nil, &response) } // UpdatePositionLeverageInDualMode update position leverage in dual mode @@ -2288,7 +2238,7 @@ func (g *Gateio) UpdatePositionLeverageInDualMode(ctx context.Context, settle cu params.Set("cross_leverage_limit", strconv.FormatFloat(crossLeverageLimit, 'f', -1, 64)) } var response *Position - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, perpetualSwapPlaceOrdersEPL, http.MethodPost, futuresPath+settle.Item.Lower+"/dual_comp/positions/"+contract.String()+"/leverage", params, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, perpetualUpdateLeverageDualModeEPL, http.MethodPost, futuresPath+settle.Item.Lower+"/dual_comp/positions/"+contract.String()+"/leverage", params, nil, &response) } // UpdatePositionRiskLimitInDualMode update position risk limit in dual mode @@ -2305,10 +2255,7 @@ func (g *Gateio) UpdatePositionRiskLimitInDualMode(ctx context.Context, settle c params := url.Values{} params.Set("risk_limit", strconv.FormatFloat(riskLimit, 'f', -1, 64)) var response []Position - return response, g.SendAuthenticatedHTTPRequest(ctx, - exchange.RestSpot, perpetualSwapPlaceOrdersEPL, http.MethodPost, - futuresPath+settle.Item.Lower+"/dual_comp/positions/"+contract.String()+"/risk_limit", params, - nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, perpetualUpdateRiskDualModeEPL, http.MethodPost, futuresPath+settle.Item.Lower+"/dual_comp/positions/"+contract.String()+"/risk_limit", params, nil, &response) } // PlaceFuturesOrder creates futures order @@ -2345,14 +2292,7 @@ func (g *Gateio) PlaceFuturesOrder(ctx context.Context, arg *OrderCreateParams) } var response *Order - return response, g.SendAuthenticatedHTTPRequest(ctx, - exchange.RestSpot, - perpetualSwapPlaceOrdersEPL, - http.MethodPost, - futuresPath+arg.Settle.Item.Lower+ordersPath, - nil, - &arg, - &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, perpetualSubmitOrderEPL, http.MethodPost, futuresPath+arg.Settle.Item.Lower+ordersPath, nil, &arg, &response) } // GetFuturesOrders retrieves list of futures orders @@ -2384,9 +2324,7 @@ func (g *Gateio) GetFuturesOrders(ctx context.Context, contract currency.Pair, s return nil, errInvalidCountTotalValue } var response []Order - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, perpetualSwapPrivateEPL, - http.MethodGet, futuresPath+settle.Item.Lower+ordersPath, - params, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, perpetualGetOrdersEPL, http.MethodGet, futuresPath+settle.Item.Lower+ordersPath, params, nil, &response) } // CancelMultipleFuturesOpenOrders ancel all open orders @@ -2404,8 +2342,7 @@ func (g *Gateio) CancelMultipleFuturesOpenOrders(ctx context.Context, contract c } params.Set("contract", contract.String()) var response []Order - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, perpetualSwapCancelOrdersEPL, - http.MethodDelete, futuresPath+settle.Item.Lower+ordersPath, params, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, perpetualGetOrdersEPL, http.MethodDelete, futuresPath+settle.Item.Lower+ordersPath, params, nil, &response) } // PlaceBatchFuturesOrders creates a list of futures orders @@ -2450,9 +2387,7 @@ func (g *Gateio) PlaceBatchFuturesOrders(ctx context.Context, settle currency.Co } } var response []Order - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, perpetualSwapPrivateEPL, - http.MethodPost, futuresPath+settle.Item.Lower+"/batch_orders", - nil, &args, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, perpetualSubmitBatchOrdersEPL, http.MethodPost, futuresPath+settle.Item.Lower+"/batch_orders", nil, &args, &response) } // GetSingleFuturesOrder retrieves a single order by its identifier @@ -2464,10 +2399,7 @@ func (g *Gateio) GetSingleFuturesOrder(ctx context.Context, settle currency.Code return nil, fmt.Errorf("%w, 'order_id' cannot be empty", errInvalidOrderID) } var response *Order - return response, g.SendAuthenticatedHTTPRequest(ctx, - exchange.RestSpot, perpetualSwapPrivateEPL, - http.MethodGet, futuresPath+settle.Item.Lower+"/orders/"+orderID, - nil, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, perpetualFetchOrderEPL, http.MethodGet, futuresPath+settle.Item.Lower+"/orders/"+orderID, nil, nil, &response) } // CancelSingleFuturesOrder cancel a single order @@ -2479,8 +2411,7 @@ func (g *Gateio) CancelSingleFuturesOrder(ctx context.Context, settle currency.C return nil, fmt.Errorf("%w, 'order_id' cannot be empty", errInvalidOrderID) } var response *Order - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, perpetualSwapCancelOrdersEPL, http.MethodDelete, - futuresPath+settle.Item.Lower+"/orders/"+orderID, nil, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, perpetualCancelOrderEPL, http.MethodDelete, futuresPath+settle.Item.Lower+"/orders/"+orderID, nil, nil, &response) } // AmendFuturesOrder amends an existing futures order @@ -2495,8 +2426,7 @@ func (g *Gateio) AmendFuturesOrder(ctx context.Context, settle currency.Code, or return nil, errors.New("missing update 'size' or 'price', please specify 'size' or 'price' or both information") } var response *Order - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, perpetualSwapPlaceOrdersEPL, http.MethodPut, - futuresPath+settle.Item.Lower+"/orders/"+orderID, nil, &arg, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, perpetualAmendOrderEPL, http.MethodPut, futuresPath+settle.Item.Lower+"/orders/"+orderID, nil, &arg, &response) } // GetMyPersonalTradingHistory retrieves my personal trading history @@ -2524,8 +2454,7 @@ func (g *Gateio) GetMyPersonalTradingHistory(ctx context.Context, settle currenc params.Set("count_total", strconv.FormatUint(countTotal, 10)) } var response []TradingHistoryItem - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, perpetualSwapPrivateEPL, http.MethodGet, - futuresPath+settle.Item.Lower+"/my_trades", params, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, perpetualTradingHistoryEPL, http.MethodGet, futuresPath+settle.Item.Lower+"/my_trades", params, nil, &response) } // GetFuturesPositionCloseHistory lists position close history @@ -2550,8 +2479,7 @@ func (g *Gateio) GetFuturesPositionCloseHistory(ctx context.Context, settle curr params.Set("to", strconv.FormatInt(to.Unix(), 10)) } var response []PositionCloseHistoryResponse - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, perpetualSwapPrivateEPL, http.MethodGet, - futuresPath+settle.Item.Lower+"/position_close", params, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, perpetualClosePositionEPL, http.MethodGet, futuresPath+settle.Item.Lower+"/position_close", params, nil, &response) } // GetFuturesLiquidationHistory list liquidation history @@ -2570,9 +2498,7 @@ func (g *Gateio) GetFuturesLiquidationHistory(ctx context.Context, settle curren params.Set("at", strconv.FormatInt(at.Unix(), 10)) } var response []LiquidationHistoryItem - return response, g.SendAuthenticatedHTTPRequest(ctx, - exchange.RestSpot, perpetualSwapPrivateEPL, http.MethodGet, - futuresPath+settle.Item.Lower+"/liquidates", params, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, perpetualLiquidationHistoryEPL, http.MethodGet, futuresPath+settle.Item.Lower+"/liquidates", params, nil, &response) } // CountdownCancelOrders represents a trigger time response @@ -2584,9 +2510,7 @@ func (g *Gateio) CountdownCancelOrders(ctx context.Context, settle currency.Code return nil, errInvalidTimeout } var response *TriggerTimeResponse - return response, g.SendAuthenticatedHTTPRequest(ctx, - exchange.RestSpot, perpetualSwapPlaceOrdersEPL, http.MethodPost, - futuresPath+settle.Item.Lower+"/countdown_cancel_all", nil, &arg, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, perpetualCancelTriggerOrdersEPL, http.MethodPost, futuresPath+settle.Item.Lower+"/countdown_cancel_all", nil, &arg, &response) } // CreatePriceTriggeredFuturesOrder create a price-triggered order @@ -2625,8 +2549,7 @@ func (g *Gateio) CreatePriceTriggeredFuturesOrder(ctx context.Context, settle cu return nil, errors.New("invalid order type, only 'close-long-order', 'close-short-order', 'close-long-position', 'close-short-position', 'plan-close-long-position', and 'plan-close-short-position'") } var response *OrderID - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, perpetualSwapPlaceOrdersEPL, http.MethodPost, - futuresPath+settle.Item.Lower+priceOrdersPaths, nil, &arg, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, perpetualSubmitTriggerOrderEPL, http.MethodPost, futuresPath+settle.Item.Lower+priceOrdersPaths, nil, &arg, &response) } // ListAllFuturesAutoOrders lists all open orders @@ -2649,10 +2572,7 @@ func (g *Gateio) ListAllFuturesAutoOrders(ctx context.Context, status string, se params.Set("contract", contract.String()) } var response []PriceTriggeredOrder - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, perpetualSwapPrivateEPL, - http.MethodGet, - futuresPath+settle.Item.Lower+priceOrdersPaths, - params, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, perpetualListOpenOrdersEPL, http.MethodGet, futuresPath+settle.Item.Lower+priceOrdersPaths, params, nil, &response) } // CancelAllFuturesOpenOrders cancels all futures open orders @@ -2666,8 +2586,7 @@ func (g *Gateio) CancelAllFuturesOpenOrders(ctx context.Context, settle currency params := url.Values{} params.Set("contract", contract.String()) var response []PriceTriggeredOrder - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, perpetualSwapCancelOrdersEPL, http.MethodDelete, - futuresPath+settle.Item.Lower+priceOrdersPaths, params, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, perpetualCancelOpenOrdersEPL, http.MethodDelete, futuresPath+settle.Item.Lower+priceOrdersPaths, params, nil, &response) } // GetSingleFuturesPriceTriggeredOrder retrieves a single price triggered order @@ -2679,9 +2598,7 @@ func (g *Gateio) GetSingleFuturesPriceTriggeredOrder(ctx context.Context, settle return nil, errInvalidOrderID } var response *PriceTriggeredOrder - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, perpetualSwapPrivateEPL, - http.MethodGet, - futuresPath+settle.Item.Lower+"/price_orders/"+orderID, nil, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, perpetualGetTriggerOrderEPL, http.MethodGet, futuresPath+settle.Item.Lower+"/price_orders/"+orderID, nil, nil, &response) } // CancelFuturesPriceTriggeredOrder cancel a price-triggered order @@ -2693,8 +2610,7 @@ func (g *Gateio) CancelFuturesPriceTriggeredOrder(ctx context.Context, settle cu return nil, errInvalidOrderID } var response *PriceTriggeredOrder - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, perpetualSwapCancelOrdersEPL, http.MethodDelete, - futuresPath+settle.Item.Lower+"/price_orders/"+orderID, nil, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, perpetualCancelTriggerOrderEPL, http.MethodDelete, futuresPath+settle.Item.Lower+"/price_orders/"+orderID, nil, nil, &response) } // *************************************** Delivery *************************************** @@ -2705,8 +2621,7 @@ func (g *Gateio) GetAllDeliveryContracts(ctx context.Context, settle currency.Co return nil, errEmptyOrInvalidSettlementCurrency } var contracts []DeliveryContract - return contracts, g.SendHTTPRequest(ctx, exchange.RestSpot, perpetualSwapDefaultEPL, - deliveryPath+settle.Item.Lower+"/contracts", &contracts) + return contracts, g.SendHTTPRequest(ctx, exchange.RestSpot, publicDeliveryContractsEPL, deliveryPath+settle.Item.Lower+"/contracts", &contracts) } // GetSingleDeliveryContracts retrieves a single delivery contract instance. @@ -2715,8 +2630,7 @@ func (g *Gateio) GetSingleDeliveryContracts(ctx context.Context, settle currency return nil, errEmptyOrInvalidSettlementCurrency } var deliveryContract *DeliveryContract - return deliveryContract, g.SendHTTPRequest(ctx, exchange.RestSpot, perpetualSwapDefaultEPL, - deliveryPath+settle.Item.Lower+"/contracts/"+contract.String(), &deliveryContract) + return deliveryContract, g.SendHTTPRequest(ctx, exchange.RestSpot, publicDeliveryContractsEPL, deliveryPath+settle.Item.Lower+"/contracts/"+contract.String(), &deliveryContract) } // GetDeliveryOrderbook delivery orderbook @@ -2739,7 +2653,7 @@ func (g *Gateio) GetDeliveryOrderbook(ctx context.Context, settle currency.Code, params.Set("with_id", strconv.FormatBool(withOrderbookID)) } var orderbook *Orderbook - return orderbook, g.SendHTTPRequest(ctx, exchange.RestSpot, perpetualSwapDefaultEPL, common.EncodeURLValues(deliveryPath+settle.Item.Lower+"/order_book", params), &orderbook) + return orderbook, g.SendHTTPRequest(ctx, exchange.RestSpot, publicOrderbookDeliveryEPL, common.EncodeURLValues(deliveryPath+settle.Item.Lower+"/order_book", params), &orderbook) } // GetDeliveryTradingHistory retrieves futures trading history @@ -2765,8 +2679,7 @@ func (g *Gateio) GetDeliveryTradingHistory(ctx context.Context, settle currency. params.Set("last_id", lastID) } var histories []DeliveryTradingHistory - return histories, g.SendHTTPRequest(ctx, exchange.RestSpot, perpetualSwapDefaultEPL, - common.EncodeURLValues(deliveryPath+settle.Item.Lower+"/trades", params), &histories) + return histories, g.SendHTTPRequest(ctx, exchange.RestSpot, publicTradingHistoryDeliveryEPL, common.EncodeURLValues(deliveryPath+settle.Item.Lower+"/trades", params), &histories) } // GetDeliveryFuturesCandlesticks retrieves specified contract candlesticks @@ -2796,10 +2709,7 @@ func (g *Gateio) GetDeliveryFuturesCandlesticks(ctx context.Context, settle curr params.Set("interval", intervalString) } var candlesticks []FuturesCandlestick - return candlesticks, g.SendHTTPRequest(ctx, - exchange.RestSpot, perpetualSwapDefaultEPL, - common.EncodeURLValues(deliveryPath+settle.Item.Lower+"/candlesticks", params), - &candlesticks) + return candlesticks, g.SendHTTPRequest(ctx, exchange.RestSpot, publicCandleSticksDeliveryEPL, common.EncodeURLValues(deliveryPath+settle.Item.Lower+"/candlesticks", params), &candlesticks) } // GetDeliveryFutureTickers retrieves futures ticker information for a specific settle and contract info. @@ -2812,7 +2722,7 @@ func (g *Gateio) GetDeliveryFutureTickers(ctx context.Context, settle currency.C params.Set("contract", contract.String()) } var tickers []FuturesTicker - return tickers, g.SendHTTPRequest(ctx, exchange.RestSpot, perpetualSwapDefaultEPL, common.EncodeURLValues(deliveryPath+settle.Item.Lower+"/tickers", params), &tickers) + return tickers, g.SendHTTPRequest(ctx, exchange.RestSpot, publicTickersDeliveryEPL, common.EncodeURLValues(deliveryPath+settle.Item.Lower+"/tickers", params), &tickers) } // GetDeliveryInsuranceBalanceHistory retrieves delivery futures insurance balance history @@ -2825,9 +2735,7 @@ func (g *Gateio) GetDeliveryInsuranceBalanceHistory(ctx context.Context, settle params.Set("limit", strconv.FormatUint(limit, 10)) } var balances []InsuranceBalance - return balances, g.SendHTTPRequest(ctx, exchange.RestSpot, spotDefaultEPL, - common.EncodeURLValues(deliveryPath+settle.Item.Lower+"/insurance", params), - &balances) + return balances, g.SendHTTPRequest(ctx, exchange.RestSpot, publicInsuranceDeliveryEPL, common.EncodeURLValues(deliveryPath+settle.Item.Lower+"/insurance", params), &balances) } // GetDeliveryFuturesAccounts retrieves futures account @@ -2836,7 +2744,7 @@ func (g *Gateio) GetDeliveryFuturesAccounts(ctx context.Context, settle currency return nil, errEmptyOrInvalidSettlementCurrency } var response *FuturesAccount - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, perpetualSwapPrivateEPL, http.MethodGet, deliveryPath+settle.Item.Lower+"/accounts", nil, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, deliveryAccountEPL, http.MethodGet, deliveryPath+settle.Item.Lower+"/accounts", nil, nil, &response) } // GetDeliveryAccountBooks retrieves account books @@ -2858,10 +2766,7 @@ func (g *Gateio) GetDeliveryAccountBooks(ctx context.Context, settle currency.Co params.Set("type", changingType) } var response []AccountBookItem - return response, g.SendAuthenticatedHTTPRequest(ctx, - exchange.RestSpot, perpetualSwapPrivateEPL, http.MethodGet, - deliveryPath+settle.Item.Lower+"/account_book", - params, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, deliveryAccountBooksEPL, http.MethodGet, deliveryPath+settle.Item.Lower+"/account_book", params, nil, &response) } // GetAllDeliveryPositionsOfUser retrieves all positions of user @@ -2870,8 +2775,7 @@ func (g *Gateio) GetAllDeliveryPositionsOfUser(ctx context.Context, settle curre return nil, errEmptyOrInvalidSettlementCurrency } var response *Position - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, perpetualSwapPrivateEPL, http.MethodGet, - deliveryPath+settle.Item.Lower+"/positions", nil, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, deliveryPositionsEPL, http.MethodGet, deliveryPath+settle.Item.Lower+"/positions", nil, nil, &response) } // GetSingleDeliveryPosition get single position @@ -2883,9 +2787,7 @@ func (g *Gateio) GetSingleDeliveryPosition(ctx context.Context, settle currency. return nil, fmt.Errorf("%w, currency pair for contract must not be empty", errInvalidOrMissingContractParam) } var response *Position - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, perpetualSwapPrivateEPL, http.MethodGet, - deliveryPath+settle.Item.Lower+positionsPath+contract.String(), - nil, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, deliveryPositionsEPL, http.MethodGet, deliveryPath+settle.Item.Lower+positionsPath+contract.String(), nil, nil, &response) } // UpdateDeliveryPositionMargin updates position margin @@ -2902,8 +2804,7 @@ func (g *Gateio) UpdateDeliveryPositionMargin(ctx context.Context, settle curren params := url.Values{} params.Set("change", strconv.FormatFloat(change, 'f', -1, 64)) var response *Position - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, perpetualSwapPlaceOrdersEPL, http.MethodPost, - deliveryPath+settle.Item.Lower+positionsPath+contract.String()+"/margin", params, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, deliveryUpdateMarginEPL, http.MethodPost, deliveryPath+settle.Item.Lower+positionsPath+contract.String()+"/margin", params, nil, &response) } // UpdateDeliveryPositionLeverage updates position leverage @@ -2921,9 +2822,7 @@ func (g *Gateio) UpdateDeliveryPositionLeverage(ctx context.Context, settle curr params.Set("leverage", strconv.FormatFloat(leverage, 'f', -1, 64)) var response *Position return response, g.SendAuthenticatedHTTPRequest(ctx, - exchange.RestSpot, perpetualSwapPlaceOrdersEPL, http.MethodPost, - deliveryPath+settle.Item.Lower+positionsPath+contract.String()+"/leverage", - params, nil, &response) + exchange.RestSpot, deliveryUpdateLeverageEPL, http.MethodPost, deliveryPath+settle.Item.Lower+positionsPath+contract.String()+"/leverage", params, nil, &response) } // UpdateDeliveryPositionRiskLimit update position risk limit @@ -2937,8 +2836,7 @@ func (g *Gateio) UpdateDeliveryPositionRiskLimit(ctx context.Context, settle cur params := url.Values{} params.Set("risk_limit", strconv.FormatUint(riskLimit, 10)) var response *Position - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, perpetualSwapPlaceOrdersEPL, http.MethodPost, - deliveryPath+settle.Item.Lower+positionsPath+contract.String()+"/risk_limit", params, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, deliveryUpdateRiskLimitEPL, http.MethodPost, deliveryPath+settle.Item.Lower+positionsPath+contract.String()+"/risk_limit", params, nil, &response) } // PlaceDeliveryOrder create a futures order @@ -2966,8 +2864,7 @@ func (g *Gateio) PlaceDeliveryOrder(ctx context.Context, arg *OrderCreateParams) return nil, errEmptyOrInvalidSettlementCurrency } var response *Order - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, perpetualSwapPlaceOrdersEPL, http.MethodPost, - deliveryPath+arg.Settle.Item.Lower+ordersPath, nil, &arg, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, deliverySubmitOrderEPL, http.MethodPost, deliveryPath+arg.Settle.Item.Lower+ordersPath, nil, &arg, &response) } // GetDeliveryOrders list futures orders @@ -2999,8 +2896,7 @@ func (g *Gateio) GetDeliveryOrders(ctx context.Context, contract currency.Pair, return nil, errInvalidCountTotalValue } var response []Order - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, perpetualSwapPrivateEPL, http.MethodGet, - deliveryPath+settle.Item.Lower+ordersPath, params, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, deliveryGetOrdersEPL, http.MethodGet, deliveryPath+settle.Item.Lower+ordersPath, params, nil, &response) } // CancelMultipleDeliveryOrders cancel all open orders matched @@ -3018,8 +2914,7 @@ func (g *Gateio) CancelMultipleDeliveryOrders(ctx context.Context, contract curr } params.Set("contract", contract.String()) var response []Order - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, perpetualSwapCancelOrdersEPL, http.MethodDelete, - deliveryPath+settle.Item.Lower+ordersPath, params, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, deliveryCancelOrdersEPL, http.MethodDelete, deliveryPath+settle.Item.Lower+ordersPath, params, nil, &response) } // GetSingleDeliveryOrder Get a single order @@ -3032,8 +2927,7 @@ func (g *Gateio) GetSingleDeliveryOrder(ctx context.Context, settle currency.Cod return nil, fmt.Errorf("%w, 'order_id' cannot be empty", errInvalidOrderID) } var response *Order - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, perpetualSwapPrivateEPL, http.MethodGet, - deliveryPath+settle.Item.Lower+"/orders/"+orderID, nil, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, deliveryGetOrderEPL, http.MethodGet, deliveryPath+settle.Item.Lower+"/orders/"+orderID, nil, nil, &response) } // CancelSingleDeliveryOrder cancel a single order @@ -3045,8 +2939,7 @@ func (g *Gateio) CancelSingleDeliveryOrder(ctx context.Context, settle currency. return nil, fmt.Errorf("%w, 'order_id' cannot be empty", errInvalidOrderID) } var response *Order - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, perpetualSwapCancelOrdersEPL, http.MethodDelete, - deliveryPath+settle.Item.Lower+"/orders/"+orderID, nil, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, deliveryCancelOrderEPL, http.MethodDelete, deliveryPath+settle.Item.Lower+"/orders/"+orderID, nil, nil, &response) } // GetDeliveryPersonalTradingHistory retrieves personal trading history @@ -3074,8 +2967,7 @@ func (g *Gateio) GetDeliveryPersonalTradingHistory(ctx context.Context, settle c params.Set("count_total", strconv.FormatUint(countTotal, 10)) } var response []TradingHistoryItem - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, perpetualSwapPrivateEPL, http.MethodGet, - deliveryPath+settle.Item.Lower+"/my_trades", params, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, deliveryTradingHistoryEPL, http.MethodGet, deliveryPath+settle.Item.Lower+"/my_trades", params, nil, &response) } // GetDeliveryPositionCloseHistory retrieves position history @@ -3100,8 +2992,7 @@ func (g *Gateio) GetDeliveryPositionCloseHistory(ctx context.Context, settle cur params.Set("to", strconv.FormatInt(to.Unix(), 10)) } var response []PositionCloseHistoryResponse - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, perpetualSwapPrivateEPL, http.MethodGet, - deliveryPath+settle.Item.Lower+"/position_close", params, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, deliveryCloseHistoryEPL, http.MethodGet, deliveryPath+settle.Item.Lower+"/position_close", params, nil, &response) } // GetDeliveryLiquidationHistory lists liquidation history @@ -3120,8 +3011,7 @@ func (g *Gateio) GetDeliveryLiquidationHistory(ctx context.Context, settle curre params.Set("at", strconv.FormatInt(at.Unix(), 10)) } var response []LiquidationHistoryItem - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, perpetualSwapPrivateEPL, http.MethodGet, - deliveryPath+settle.Item.Lower+"/liquidates", params, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, deliveryLiquidationHistoryEPL, http.MethodGet, deliveryPath+settle.Item.Lower+"/liquidates", params, nil, &response) } // GetDeliverySettlementHistory retrieves settlement history @@ -3140,8 +3030,7 @@ func (g *Gateio) GetDeliverySettlementHistory(ctx context.Context, settle curren params.Set("at", strconv.FormatInt(at.Unix(), 10)) } var response []SettlementHistoryItem - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, perpetualSwapPrivateEPL, http.MethodGet, - deliveryPath+settle.Item.Lower+"/settlements", params, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, deliverySettlementHistoryEPL, http.MethodGet, deliveryPath+settle.Item.Lower+"/settlements", params, nil, &response) } // GetDeliveryPriceTriggeredOrder creates a price-triggered order @@ -3187,8 +3076,7 @@ func (g *Gateio) GetDeliveryPriceTriggeredOrder(ctx context.Context, settle curr return nil, errors.New("invalid order type, only 'close-long-order', 'close-short-order', 'close-long-position', 'close-short-position', 'plan-close-long-position', and 'plan-close-short-position'") } var response *OrderID - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, perpetualSwapPrivateEPL, http.MethodPost, - deliveryPath+settle.Item.Lower+priceOrdersPaths, nil, &arg, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, deliveryGetTriggerOrderEPL, http.MethodPost, deliveryPath+settle.Item.Lower+priceOrdersPaths, nil, &arg, &response) } // GetDeliveryAllAutoOrder retrieves all auto orders @@ -3211,8 +3099,7 @@ func (g *Gateio) GetDeliveryAllAutoOrder(ctx context.Context, status string, set params.Set("contract", contract.String()) } var response []PriceTriggeredOrder - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, perpetualSwapPrivateEPL, http.MethodGet, - deliveryPath+settle.Item.Lower+priceOrdersPaths, params, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, deliveryAutoOrdersEPL, http.MethodGet, deliveryPath+settle.Item.Lower+priceOrdersPaths, params, nil, &response) } // CancelAllDeliveryPriceTriggeredOrder cancels all delivery price triggered orders @@ -3226,8 +3113,7 @@ func (g *Gateio) CancelAllDeliveryPriceTriggeredOrder(ctx context.Context, settl params := url.Values{} params.Set("contract", contract.String()) var response []PriceTriggeredOrder - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, perpetualSwapCancelOrdersEPL, http.MethodDelete, - deliveryPath+settle.Item.Lower+priceOrdersPaths, params, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, deliveryCancelTriggerOrdersEPL, http.MethodDelete, deliveryPath+settle.Item.Lower+priceOrdersPaths, params, nil, &response) } // GetSingleDeliveryPriceTriggeredOrder retrieves a single price triggered order @@ -3239,8 +3125,7 @@ func (g *Gateio) GetSingleDeliveryPriceTriggeredOrder(ctx context.Context, settl return nil, errInvalidOrderID } var response *PriceTriggeredOrder - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, perpetualSwapPrivateEPL, http.MethodGet, - deliveryPath+settle.Item.Lower+"/price_orders/"+orderID, nil, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, deliveryGetTriggerOrderEPL, http.MethodGet, deliveryPath+settle.Item.Lower+"/price_orders/"+orderID, nil, nil, &response) } // CancelDeliveryPriceTriggeredOrder cancel a price-triggered order @@ -3252,8 +3137,7 @@ func (g *Gateio) CancelDeliveryPriceTriggeredOrder(ctx context.Context, settle c return nil, errInvalidOrderID } var response *PriceTriggeredOrder - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, perpetualSwapCancelOrdersEPL, http.MethodDelete, - deliveryPath+settle.Item.Lower+"/price_orders/"+orderID, nil, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, deliveryCancelTriggerOrderEPL, http.MethodDelete, deliveryPath+settle.Item.Lower+"/price_orders/"+orderID, nil, nil, &response) } // ********************************** Options *************************************************** @@ -3261,13 +3145,13 @@ func (g *Gateio) CancelDeliveryPriceTriggeredOrder(ctx context.Context, settle c // GetAllOptionsUnderlyings retrieves all option underlyings func (g *Gateio) GetAllOptionsUnderlyings(ctx context.Context) ([]OptionUnderlying, error) { var response []OptionUnderlying - return response, g.SendHTTPRequest(ctx, exchange.RestSpot, perpetualSwapDefaultEPL, gateioOptionUnderlyings, &response) + return response, g.SendHTTPRequest(ctx, exchange.RestSpot, publicUnderlyingOptionsEPL, gateioOptionUnderlyings, &response) } // GetExpirationTime return the expiration time for the provided underlying. func (g *Gateio) GetExpirationTime(ctx context.Context, underlying string) (time.Time, error) { var timestamp []float64 - err := g.SendHTTPRequest(ctx, exchange.RestSpot, perpetualSwapDefaultEPL, gateioOptionExpiration+"?underlying="+underlying, ×tamp) + err := g.SendHTTPRequest(ctx, exchange.RestSpot, publicExpirationOptionsEPL, gateioOptionExpiration+"?underlying="+underlying, ×tamp) if err != nil { return time.Time{}, err } @@ -3288,7 +3172,7 @@ func (g *Gateio) GetAllContractOfUnderlyingWithinExpiryDate(ctx context.Context, params.Set("expires", strconv.FormatInt(expTime.Unix(), 10)) } var contracts []OptionContract - return contracts, g.SendHTTPRequest(ctx, exchange.RestSpot, perpetualSwapDefaultEPL, common.EncodeURLValues(gateioOptionContracts, params), &contracts) + return contracts, g.SendHTTPRequest(ctx, exchange.RestSpot, publicContractsOptionsEPL, common.EncodeURLValues(gateioOptionContracts, params), &contracts) } // GetOptionsSpecifiedContractDetail query specified contract detail @@ -3297,8 +3181,7 @@ func (g *Gateio) GetOptionsSpecifiedContractDetail(ctx context.Context, contract return nil, errInvalidOrMissingContractParam } var contr *OptionContract - return contr, g.SendHTTPRequest(ctx, exchange.RestSpot, perpetualSwapDefaultEPL, - gateioOptionContracts+"/"+contract.String(), &contr) + return contr, g.SendHTTPRequest(ctx, exchange.RestSpot, publicContractsOptionsEPL, gateioOptionContracts+"/"+contract.String(), &contr) } // GetSettlementHistory retrieves list of settlement history @@ -3321,8 +3204,7 @@ func (g *Gateio) GetSettlementHistory(ctx context.Context, underlying string, of params.Set("to", strconv.FormatInt(to.Unix(), 10)) } var settlements []OptionSettlement - return settlements, g.SendHTTPRequest(ctx, exchange.RestSpot, perpetualSwapDefaultEPL, - common.EncodeURLValues(gateioOptionSettlement, params), &settlements) + return settlements, g.SendHTTPRequest(ctx, exchange.RestSpot, publicSettlementOptionsEPL, common.EncodeURLValues(gateioOptionSettlement, params), &settlements) } // GetOptionsSpecifiedContractsSettlement retrieve a single contract settlement detail passing the underlying and contract name @@ -3337,7 +3219,7 @@ func (g *Gateio) GetOptionsSpecifiedContractsSettlement(ctx context.Context, con params.Set("underlying", underlying) params.Set("at", strconv.FormatInt(at, 10)) var settlement *OptionSettlement - return settlement, g.SendHTTPRequest(ctx, exchange.RestSpot, perpetualSwapDefaultEPL, common.EncodeURLValues(gateioOptionSettlement+"/"+contract.String(), params), &settlement) + return settlement, g.SendHTTPRequest(ctx, exchange.RestSpot, publicSettlementOptionsEPL, common.EncodeURLValues(gateioOptionSettlement+"/"+contract.String(), params), &settlement) } // GetMyOptionsSettlements retrieves accounts option settlements. @@ -3360,7 +3242,7 @@ func (g *Gateio) GetMyOptionsSettlements(ctx context.Context, underlying string, params.Set("limit", strconv.Itoa(int(limit))) } var settlements []MyOptionSettlement - return settlements, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, perpetualSwapPrivateEPL, http.MethodGet, gateioOptionMySettlements, params, nil, &settlements) + return settlements, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, optionsSettlementsEPL, http.MethodGet, gateioOptionMySettlements, params, nil, &settlements) } // GetOptionsOrderbook returns the orderbook data for the given contract. @@ -3378,13 +3260,13 @@ func (g *Gateio) GetOptionsOrderbook(ctx context.Context, contract currency.Pair } params.Set("with_id", strconv.FormatBool(withOrderbookID)) var response *Orderbook - return response, g.SendHTTPRequest(ctx, exchange.RestSpot, perpetualSwapDefaultEPL, common.EncodeURLValues(gateioOptionsOrderbook, params), &response) + return response, g.SendHTTPRequest(ctx, exchange.RestSpot, publicOrderbookOptionsEPL, common.EncodeURLValues(gateioOptionsOrderbook, params), &response) } // GetOptionAccounts lists option accounts func (g *Gateio) GetOptionAccounts(ctx context.Context) (*OptionAccount, error) { var resp *OptionAccount - return resp, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, perpetualSwapPrivateEPL, http.MethodGet, gateioOptionAccounts, nil, nil, &resp) + return resp, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, optionsAccountsEPL, http.MethodGet, gateioOptionAccounts, nil, nil, &resp) } // GetAccountChangingHistory retrieves list of account changing history @@ -3406,7 +3288,7 @@ func (g *Gateio) GetAccountChangingHistory(ctx context.Context, offset, limit ui params.Set("to", strconv.FormatInt(to.Unix(), 10)) } var accountBook []AccountBook - return accountBook, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, perpetualSwapPrivateEPL, http.MethodGet, gateioOptionsAccountbook, params, nil, &accountBook) + return accountBook, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, optionsAccountBooksEPL, http.MethodGet, gateioOptionsAccountbook, params, nil, &accountBook) } // GetUsersPositionSpecifiedUnderlying lists user's positions of specified underlying @@ -3416,7 +3298,7 @@ func (g *Gateio) GetUsersPositionSpecifiedUnderlying(ctx context.Context, underl params.Set("underlying", underlying) } var response []UsersPositionForUnderlying - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, perpetualSwapPrivateEPL, http.MethodGet, gateioOptionsPosition, params, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, optionsPositions, http.MethodGet, gateioOptionsPosition, params, nil, &response) } // GetSpecifiedContractPosition retrieves specified contract position @@ -3425,8 +3307,7 @@ func (g *Gateio) GetSpecifiedContractPosition(ctx context.Context, contract curr return nil, errInvalidOrMissingContractParam } var response *UsersPositionForUnderlying - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, perpetualSwapPrivateEPL, http.MethodGet, - gateioOptionsPosition+"/"+contract.String(), nil, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, optionsPositions, http.MethodGet, gateioOptionsPosition+"/"+contract.String(), nil, nil, &response) } // GetUsersLiquidationHistoryForSpecifiedUnderlying retrieves user's liquidation history of specified underlying @@ -3440,7 +3321,7 @@ func (g *Gateio) GetUsersLiquidationHistoryForSpecifiedUnderlying(ctx context.Co params.Set("contract", contract.String()) } var response []ContractClosePosition - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, perpetualSwapPrivateEPL, http.MethodGet, gateioOptionsPositionClose, params, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, optionsLiquidationHistoryEPL, http.MethodGet, gateioOptionsPositionClose, params, nil, &response) } // PlaceOptionOrder creates an options order @@ -3461,8 +3342,7 @@ func (g *Gateio) PlaceOptionOrder(ctx context.Context, arg *OptionOrderParam) (* arg.Price = 0 } var response *OptionOrderResponse - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, perpetualSwapPlaceOrdersEPL, http.MethodPost, - gateioOptionsOrders, nil, &arg, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, optionsSubmitOrderEPL, http.MethodPost, gateioOptionsOrders, nil, &arg, &response) } // GetOptionFuturesOrders retrieves futures orders @@ -3491,8 +3371,7 @@ func (g *Gateio) GetOptionFuturesOrders(ctx context.Context, contract currency.P params.Set("to", strconv.FormatInt(to.Unix(), 10)) } var response []OptionOrderResponse - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, perpetualSwapPrivateEPL, - http.MethodGet, gateioOptionsOrders, params, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, optionsOrdersEPL, http.MethodGet, gateioOptionsOrders, params, nil, &response) } // CancelMultipleOptionOpenOrders cancels all open orders matched @@ -3508,8 +3387,7 @@ func (g *Gateio) CancelMultipleOptionOpenOrders(ctx context.Context, contract cu params.Set("side", side) } var response []OptionOrderResponse - return response, g.SendAuthenticatedHTTPRequest(ctx, - exchange.RestSpot, perpetualSwapCancelOrdersEPL, http.MethodDelete, gateioOptionsOrders, params, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, optionsCancelOrdersEPL, http.MethodDelete, gateioOptionsOrders, params, nil, &response) } // GetSingleOptionOrder retrieves a single option order @@ -3518,7 +3396,7 @@ func (g *Gateio) GetSingleOptionOrder(ctx context.Context, orderID string) (*Opt return nil, errInvalidOrderID } var o *OptionOrderResponse - return o, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, perpetualSwapPrivateEPL, http.MethodGet, gateioOptionsOrders+"/"+orderID, nil, nil, &o) + return o, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, optionsOrderEPL, http.MethodGet, gateioOptionsOrders+"/"+orderID, nil, nil, &o) } // CancelOptionSingleOrder cancel a single order. @@ -3527,8 +3405,7 @@ func (g *Gateio) CancelOptionSingleOrder(ctx context.Context, orderID string) (* return nil, errInvalidOrderID } var response *OptionOrderResponse - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, perpetualSwapCancelOrdersEPL, http.MethodDelete, - "options/orders/"+orderID, nil, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, optionsCancelOrderEPL, http.MethodDelete, "options/orders/"+orderID, nil, nil, &response) } // GetOptionsPersonalTradingHistory retrieves personal tradign histories given the underlying{Required}, contract, and other pagination params. @@ -3554,7 +3431,7 @@ func (g *Gateio) GetOptionsPersonalTradingHistory(ctx context.Context, underlyin params.Set("to", strconv.FormatInt(to.Unix(), 10)) } var resp []OptionTradingHistory - return resp, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, perpetualSwapPrivateEPL, http.MethodGet, gateioOptionsMyTrades, params, nil, &resp) + return resp, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, optionsTradingHistoryEPL, http.MethodGet, gateioOptionsMyTrades, params, nil, &resp) } // GetOptionsTickers lists tickers of options contracts @@ -3564,8 +3441,7 @@ func (g *Gateio) GetOptionsTickers(ctx context.Context, underlying string) ([]Op } underlying = strings.ToUpper(underlying) var response []OptionsTicker - return response, g.SendHTTPRequest(ctx, exchange.RestSpot, perpetualSwapDefaultEPL, - gateioOptionsTickers+"?underlying="+underlying, &response) + return response, g.SendHTTPRequest(ctx, exchange.RestSpot, publicTickerOptionsEPL, gateioOptionsTickers+"?underlying="+underlying, &response) } // GetOptionUnderlyingTickers retrieves options underlying ticker @@ -3574,8 +3450,7 @@ func (g *Gateio) GetOptionUnderlyingTickers(ctx context.Context, underlying stri return nil, errInvalidUnderlying } var respos *OptionsUnderlyingTicker - return respos, g.SendHTTPRequest(ctx, exchange.RestSpot, perpetualSwapDefaultEPL, - "options/underlying/tickers/"+underlying, &respos) + return respos, g.SendHTTPRequest(ctx, exchange.RestSpot, publicUnderlyingTickerOptionsEPL, "options/underlying/tickers/"+underlying, &respos) } // GetOptionFuturesCandlesticks retrieves option futures candlesticks @@ -3600,8 +3475,7 @@ func (g *Gateio) GetOptionFuturesCandlesticks(ctx context.Context, contract curr } params.Set("interval", intervalString) var candles []FuturesCandlestick - return candles, g.SendHTTPRequest(ctx, exchange.RestSpot, perpetualSwapDefaultEPL, - common.EncodeURLValues(gateioOptionCandlesticks, params), &candles) + return candles, g.SendHTTPRequest(ctx, exchange.RestSpot, publicCandleSticksOptionsEPL, common.EncodeURLValues(gateioOptionCandlesticks, params), &candles) } // GetOptionFuturesMarkPriceCandlesticks retrieves mark price candlesticks of an underlying @@ -3628,12 +3502,11 @@ func (g *Gateio) GetOptionFuturesMarkPriceCandlesticks(ctx context.Context, unde params.Set("interval", intervalString) } var candles []FuturesCandlestick - return candles, g.SendHTTPRequest(ctx, exchange.RestSpot, perpetualSwapDefaultEPL, - common.EncodeURLValues(gateioOptionUnderlyingCandlesticks, params), &candles) + return candles, g.SendHTTPRequest(ctx, exchange.RestSpot, publicMarkpriceCandleSticksOptionsEPL, common.EncodeURLValues(gateioOptionUnderlyingCandlesticks, params), &candles) } // GetOptionsTradeHistory retrieves options trade history -func (g *Gateio) GetOptionsTradeHistory(ctx context.Context, contract /*C is call, while P is put*/ currency.Pair, callType string, offset, limit uint64, from, to time.Time) ([]TradingHistoryItem, error) { +func (g *Gateio) GetOptionsTradeHistory(ctx context.Context, contract currency.Pair, callType string, offset, limit uint64, from, to time.Time) ([]TradingHistoryItem, error) { params := url.Values{} callType = strings.ToUpper(callType) if callType == "C" || callType == "P" { @@ -3655,7 +3528,7 @@ func (g *Gateio) GetOptionsTradeHistory(ctx context.Context, contract /*C is cal params.Set("to", strconv.FormatInt(to.Unix(), 10)) } var trades []TradingHistoryItem - return trades, g.SendHTTPRequest(ctx, exchange.RestSpot, perpetualSwapDefaultEPL, common.EncodeURLValues(gateioOptionsTrades, params), &trades) + return trades, g.SendHTTPRequest(ctx, exchange.RestSpot, publicTradeHistoryOptionsEPL, common.EncodeURLValues(gateioOptionsTrades, params), &trades) } // ********************************** Flash_SWAP ************************* @@ -3663,7 +3536,7 @@ func (g *Gateio) GetOptionsTradeHistory(ctx context.Context, contract /*C is cal // GetSupportedFlashSwapCurrencies retrieves all supported currencies in flash swap func (g *Gateio) GetSupportedFlashSwapCurrencies(ctx context.Context) ([]SwapCurrencies, error) { var currencies []SwapCurrencies - return currencies, g.SendHTTPRequest(ctx, exchange.RestSpot, spotDefaultEPL, gateioFlashSwapCurrencies, ¤cies) + return currencies, g.SendHTTPRequest(ctx, exchange.RestSpot, publicFlashSwapEPL, gateioFlashSwapCurrencies, ¤cies) } // CreateFlashSwapOrder creates a new flash swap order @@ -3685,7 +3558,7 @@ func (g *Gateio) CreateFlashSwapOrder(ctx context.Context, arg FlashSwapOrderPar return nil, fmt.Errorf("%w, buy_amount amount can not be less than or equal to 0", errInvalidAmount) } var response *FlashSwapOrderResponse - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, spotDefaultEPL, http.MethodPost, gateioFlashSwapOrders, nil, &arg, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, flashSwapOrderEPL, http.MethodPost, gateioFlashSwapOrders, nil, &arg, &response) } // GetAllFlashSwapOrders retrieves list of flash swap orders filtered by the params @@ -3708,7 +3581,7 @@ func (g *Gateio) GetAllFlashSwapOrders(ctx context.Context, status int, sellCurr params.Set("limit", strconv.FormatUint(limit, 10)) } var response []FlashSwapOrderResponse - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, spotPrivateEPL, http.MethodGet, gateioFlashSwapOrders, params, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, flashGetOrdersEPL, http.MethodGet, gateioFlashSwapOrders, params, nil, &response) } // GetSingleFlashSwapOrder get a single flash swap order's detail @@ -3717,8 +3590,7 @@ func (g *Gateio) GetSingleFlashSwapOrder(ctx context.Context, orderID string) (* return nil, fmt.Errorf("%w, flash order order_id must not be empty", errInvalidOrderID) } var response *FlashSwapOrderResponse - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, spotPrivateEPL, http.MethodGet, - gateioFlashSwapOrders+"/"+orderID, nil, nil, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, flashGetOrderEPL, http.MethodGet, gateioFlashSwapOrders+"/"+orderID, nil, nil, &response) } // InitiateFlashSwapOrderReview initiate a flash swap order preview @@ -3733,7 +3605,7 @@ func (g *Gateio) InitiateFlashSwapOrderReview(ctx context.Context, arg FlashSwap return nil, fmt.Errorf("%w, sell currency can not empty", currency.ErrCurrencyCodeEmpty) } var response *InitFlashSwapOrderPreviewResponse - return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, spotPrivateEPL, http.MethodPost, gateioFlashSwapOrdersPreview, nil, &arg, &response) + return response, g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, flashOrderReviewEPL, http.MethodPost, gateioFlashSwapOrdersPreview, nil, &arg, &response) } // IsValidPairString returns true if the string represents a valid currency pair diff --git a/exchanges/gateio/gateio_test.go b/exchanges/gateio/gateio_test.go index e7e119ec49d..96dd3eb954e 100644 --- a/exchanges/gateio/gateio_test.go +++ b/exchanges/gateio/gateio_test.go @@ -333,7 +333,7 @@ func TestCreateBatchOrders(t *testing.T) { func TestGetSpotOpenOrders(t *testing.T) { t.Parallel() sharedtestvalues.SkipTestIfCredentialsUnset(t, g) - if _, err := g.GateioSpotOpenOrders(context.Background(), 0, 0, false); err != nil { + if _, err := g.GetSpotOpenOrders(context.Background(), 0, 0, false); err != nil { t.Errorf("%s GetSpotOpenOrders() error %v", g.Name, err) } } @@ -3014,11 +3014,11 @@ func TestGetSettlementFromCurrency(t *testing.T) { for _, assetType := range []asset.Item{asset.Futures, asset.DeliveryFutures, asset.Options} { availPairs, err := g.GetAvailablePairs(assetType) require.NoErrorf(t, err, "GetAvailablePairs for asset %s must not error", assetType) - for x := range availPairs { - t.Run(strconv.Itoa(x), func(t *testing.T) { + for i, pair := range availPairs { + t.Run(strconv.Itoa(i)+":"+assetType.String(), func(t *testing.T) { t.Parallel() - _, err = getSettlementFromCurrency(availPairs[x]) - assert.NoErrorf(t, err, "getSettlementFromCurrency should not error for pair %s and asset %s", availPairs[x], assetType) + _, err := getSettlementFromCurrency(pair) + assert.NoErrorf(t, err, "getSettlementFromCurrency should not error for pair %s and asset %s", pair, assetType) }) } } diff --git a/exchanges/gateio/gateio_websocket.go b/exchanges/gateio/gateio_websocket.go index 1711dcc501f..932768ec2a6 100644 --- a/exchanges/gateio/gateio_websocket.go +++ b/exchanges/gateio/gateio_websocket.go @@ -24,7 +24,6 @@ import ( "github.com/thrasher-corp/gocryptotrader/exchanges/kline" "github.com/thrasher-corp/gocryptotrader/exchanges/order" "github.com/thrasher-corp/gocryptotrader/exchanges/orderbook" - "github.com/thrasher-corp/gocryptotrader/exchanges/request" "github.com/thrasher-corp/gocryptotrader/exchanges/stream" "github.com/thrasher-corp/gocryptotrader/exchanges/subscription" "github.com/thrasher-corp/gocryptotrader/exchanges/ticker" @@ -32,8 +31,7 @@ import ( ) const ( - gateioWebsocketEndpoint = "wss://api.gateio.ws/ws/v4/" - gateioWebsocketRateLimit = 120 * time.Millisecond + gateioWebsocketEndpoint = "wss://api.gateio.ws/ws/v4/" spotPingChannel = "spot.ping" spotPongChannel = "spot.pong" @@ -90,7 +88,7 @@ func (g *Gateio) WsConnectSpot(ctx context.Context, conn stream.Connection) erro if err != nil { return err } - conn.SetupPingHandler(request.Unset, stream.PingHandler{ + conn.SetupPingHandler(websocketRateLimitNotNeededEPL, stream.PingHandler{ Websocket: true, Delay: time.Second * 15, Message: pingMessage, @@ -587,7 +585,7 @@ func (g *Gateio) manageSubs(ctx context.Context, event string, conn stream.Conne if err != nil { return err } - result, err := conn.SendMessageReturnResponse(ctx, request.Unset, msg.ID, msg) + result, err := conn.SendMessageReturnResponse(ctx, websocketRateLimitNotNeededEPL, msg.ID, msg) if err != nil { return err } @@ -698,7 +696,7 @@ func (g *Gateio) handleSubscription(ctx context.Context, conn stream.Connection, } var errs error for k := range payloads { - result, err := conn.SendMessageReturnResponse(ctx, request.Unset, payloads[k].ID, payloads[k]) + result, err := conn.SendMessageReturnResponse(ctx, websocketRateLimitNotNeededEPL, payloads[k].ID, payloads[k]) if err != nil { errs = common.AppendError(errs, err) continue diff --git a/exchanges/gateio/gateio_wrapper.go b/exchanges/gateio/gateio_wrapper.go index 02d2b760fa6..bb28b848ea7 100644 --- a/exchanges/gateio/gateio_wrapper.go +++ b/exchanges/gateio/gateio_wrapper.go @@ -151,7 +151,7 @@ func (g *Gateio) SetDefaults() { } g.Requester, err = request.New(g.Name, common.NewHTTPClientWithTimeout(exchange.DefaultHTTPTimeout), - request.WithLimiter(GetRateLimit()), + request.WithLimiter(packageRateLimits), ) if err != nil { log.Errorln(log.ExchangeSys, err) @@ -203,6 +203,7 @@ func (g *Gateio) Setup(exch *config.Exchange) error { FillsFeed: g.Features.Enabled.FillsFeed, TradeFeed: g.Features.Enabled.TradeFeed, UseMultiConnectionManagement: true, + RateLimitDefinitions: packageRateLimits, }) if err != nil { return err @@ -210,7 +211,6 @@ func (g *Gateio) Setup(exch *config.Exchange) error { // Spot connection err = g.Websocket.SetupNewConnection(&stream.ConnectionSetup{ URL: gateioWebsocketEndpoint, - RateLimit: request.NewWeightedRateLimitByDuration(gateioWebsocketRateLimit), ResponseCheckTimeout: exch.WebsocketResponseCheckTimeout, ResponseMaxLimit: exch.WebsocketResponseMaxLimit, Handler: g.WsHandleSpotData, @@ -226,7 +226,6 @@ func (g *Gateio) Setup(exch *config.Exchange) error { // Futures connection - USDT margined err = g.Websocket.SetupNewConnection(&stream.ConnectionSetup{ URL: futuresWebsocketUsdtURL, - RateLimit: request.NewWeightedRateLimitByDuration(gateioWebsocketRateLimit), ResponseCheckTimeout: exch.WebsocketResponseCheckTimeout, ResponseMaxLimit: exch.WebsocketResponseMaxLimit, Handler: func(ctx context.Context, incoming []byte) error { @@ -245,7 +244,6 @@ func (g *Gateio) Setup(exch *config.Exchange) error { // Futures connection - BTC margined err = g.Websocket.SetupNewConnection(&stream.ConnectionSetup{ URL: futuresWebsocketBtcURL, - RateLimit: request.NewWeightedRateLimitByDuration(gateioWebsocketRateLimit), ResponseCheckTimeout: exch.WebsocketResponseCheckTimeout, ResponseMaxLimit: exch.WebsocketResponseMaxLimit, Handler: func(ctx context.Context, incoming []byte) error { @@ -265,7 +263,6 @@ func (g *Gateio) Setup(exch *config.Exchange) error { // Futures connection - Delivery - USDT margined err = g.Websocket.SetupNewConnection(&stream.ConnectionSetup{ URL: deliveryRealUSDTTradingURL, - RateLimit: request.NewWeightedRateLimitByDuration(gateioWebsocketRateLimit), ResponseCheckTimeout: exch.WebsocketResponseCheckTimeout, ResponseMaxLimit: exch.WebsocketResponseMaxLimit, Handler: func(ctx context.Context, incoming []byte) error { @@ -284,7 +281,6 @@ func (g *Gateio) Setup(exch *config.Exchange) error { // Futures connection - Options return g.Websocket.SetupNewConnection(&stream.ConnectionSetup{ URL: optionsWebsocketURL, - RateLimit: request.NewWeightedRateLimitByDuration(gateioWebsocketRateLimit), ResponseCheckTimeout: exch.WebsocketResponseCheckTimeout, ResponseMaxLimit: exch.WebsocketResponseMaxLimit, Handler: g.WsHandleOptionsData, @@ -1658,7 +1654,7 @@ func (g *Gateio) GetActiveOrders(ctx context.Context, req *order.MultiOrderReque switch req.AssetType { case asset.Spot, asset.Margin, asset.CrossMargin: var spotOrders []SpotOrdersDetail - spotOrders, err = g.GateioSpotOpenOrders(ctx, 0, 0, req.AssetType == asset.CrossMargin) + spotOrders, err = g.GetSpotOpenOrders(ctx, 0, 0, req.AssetType == asset.CrossMargin) if err != nil { return nil, err } diff --git a/exchanges/gateio/ratelimiter.go b/exchanges/gateio/ratelimiter.go index 2c554b38e5d..870b4d9bc1a 100644 --- a/exchanges/gateio/ratelimiter.go +++ b/exchanges/gateio/ratelimiter.go @@ -6,49 +6,414 @@ import ( "github.com/thrasher-corp/gocryptotrader/exchanges/request" ) -// GateIO endpoints limits. +// GateIO endpoints limits. See: https://www.gate.io/docs/developers/apiv4/en/#frequency-limit-rule const ( - spotDefaultEPL request.EndpointLimit = iota - spotPrivateEPL - spotPlaceOrdersEPL - spotCancelOrdersEPL - perpetualSwapDefaultEPL - perpetualSwapPlaceOrdersEPL - perpetualSwapPrivateEPL - perpetualSwapCancelOrdersEPL - walletEPL - withdrawalEPL - - // Request rates per interval - - spotPublicRate = 900 - spotPrivateRate = 900 - spotPlaceOrdersRate = 10 - spotCancelOrdersRate = 500 - perpetualSwapPublicRate = 300 - perpetualSwapPlaceOrdersRate = 100 - perpetualSwapPrivateRate = 400 - perpetualSwapCancelOrdersRate = 400 - walletRate = 200 - withdrawalRate = 1 - - // interval - oneSecondInterval = time.Second - threeSecondsInterval = time.Second * 3 + publicTickersSpotEPL request.EndpointLimit = iota + 1 + publicOrderbookSpotEPL + publicMarketTradesSpotEPL + publicCandleStickSpotEPL + publicCurrencyPairDetailSpotEPL + publicListCurrencyPairsSpotEPL + publicCurrenciesSpotEPL + + publicCurrencyPairsMarginEPL + publicOrderbookMarginEPL + + publicInsuranceDeliveryEPL + publicDeliveryContractsEPL + publicOrderbookDeliveryEPL + publicTradingHistoryDeliveryEPL + publicCandleSticksDeliveryEPL + publicTickersDeliveryEPL + + publicFuturesContractsEPL + publicOrderbookFuturesEPL + publicTradingHistoryFuturesEPL + publicCandleSticksFuturesEPL + publicPremiumIndexEPL + publicTickersFuturesEPL + publicFundingRatesEPL + publicInsuranceFuturesEPL + publicStatsFuturesEPL + publicIndexConstituentsEPL + publicLiquidationHistoryEPL + + publicUnderlyingOptionsEPL + publicExpirationOptionsEPL + publicContractsOptionsEPL + publicSettlementOptionsEPL + publicOrderbookOptionsEPL + publicTickerOptionsEPL + publicUnderlyingTickerOptionsEPL + publicCandleSticksOptionsEPL + publicMarkpriceCandleSticksOptionsEPL + publicTradeHistoryOptionsEPL + + publicGetServerTimeEPL + publicFlashSwapEPL + publicListCurrencyChainEPL + + walletDepositAddressEPL + walletWithdrawalRecordsEPL + walletDepositRecordsEPL + walletTransferCurrencyEPL + walletSubAccountTransferEPL + walletSubAccountTransferHistoryEPL + walletSubAccountToSubAccountTransferEPL + walletWithdrawStatusEPL + walletSubAccountBalancesEPL + walletSubAccountMarginBalancesEPL + walletSubAccountFuturesBalancesEPL + walletSubAccountCrossMarginBalancesEPL + walletSavedAddressesEPL + walletTradingFeeEPL + walletTotalBalanceEPL + walletWithdrawEPL + walletCancelWithdrawEPL + + subAccountEPL + + spotTradingFeeEPL + spotAccountsEPL + spotGetOpenOrdersEPL + spotClosePositionEPL + spotBatchOrdersEPL + spotPlaceOrderEPL + spotGetOrdersEPL + spotCancelAllOpenOrdersEPL + spotCancelBatchOrdersEPL + spotGetOrderEPL + spotAmendOrderEPL + spotCancelSingleOrderEPL + spotTradingHistoryEPL + spotCountdownCancelEPL + spotCreateTriggerOrderEPL + spotGetTriggerOrderListEPL + spotCancelTriggerOrdersEPL + spotGetTriggerOrderEPL + spotCancelTriggerOrderEPL + + marginAccountListEPL + marginAccountBalanceEPL + marginFundingAccountListEPL + marginLendBorrowEPL + marginAllLoansEPL + marginMergeLendingLoansEPL + marginGetLoanEPL + marginModifyLoanEPL + marginCancelLoanEPL + marginRepayLoanEPL + marginListLoansEPL + marginRepaymentRecordEPL + marginSingleRecordEPL + marginModifyLoanRecordEPL + marginAutoRepayEPL + marginGetAutoRepaySettingsEPL + marginGetMaxTransferEPL + marginGetMaxBorrowEPL + marginSupportedCurrencyCrossListEPL + marginSupportedCurrencyCrossEPL + marginAccountsEPL + marginAccountHistoryEPL + marginCreateCrossBorrowLoanEPL + marginExecuteRepaymentsEPL + marginGetCrossMarginRepaymentsEPL + marginGetMaxTransferCrossEPL + marginGetMaxBorrowCrossEPL + marginGetCrossBorrowHistoryEPL + marginGetBorrowEPL + + flashSwapOrderEPL + flashGetOrdersEPL + flashGetOrderEPL + flashOrderReviewEPL + + privateUnifiedSpotEPL + + perpetualAccountEPL + perpetualAccountBooksEPL + perpetualPositionsEPL + perpetualPositionEPL + perpetualUpdateMarginEPL + perpetualUpdateLeverageEPL + perpetualUpdateRiskEPL + perpetualToggleDualModeEPL + perpetualPositionsDualModeEPL + perpetualUpdateMarginDualModeEPL + perpetualUpdateLeverageDualModeEPL + perpetualUpdateRiskDualModeEPL + perpetualSubmitOrderEPL + perpetualGetOrdersEPL + perpetualSubmitBatchOrdersEPL + perpetualFetchOrderEPL + perpetualCancelOrderEPL + perpetualAmendOrderEPL + perpetualTradingHistoryEPL + perpetualClosePositionEPL + perpetualLiquidationHistoryEPL + perpetualCancelTriggerOrdersEPL + perpetualSubmitTriggerOrderEPL + perpetualListOpenOrdersEPL + perpetualCancelOpenOrdersEPL + perpetualGetTriggerOrderEPL + perpetualCancelTriggerOrderEPL + + deliveryAccountEPL + deliveryAccountBooksEPL + deliveryPositionsEPL + deliveryUpdateMarginEPL + deliveryUpdateLeverageEPL + deliveryUpdateRiskLimitEPL + deliverySubmitOrderEPL + deliveryGetOrdersEPL + deliveryCancelOrdersEPL + deliveryGetOrderEPL + deliveryCancelOrderEPL + deliveryTradingHistoryEPL + deliveryCloseHistoryEPL + deliveryLiquidationHistoryEPL + deliverySettlementHistoryEPL + deliveryGetTriggerOrdersEPL + deliveryAutoOrdersEPL + deliveryCancelTriggerOrdersEPL + deliveryGetTriggerOrderEPL + deliveryCancelTriggerOrderEPL + + optionsSettlementsEPL + optionsAccountsEPL + optionsAccountBooksEPL + optionsPositions + optionsLiquidationHistoryEPL + optionsSubmitOrderEPL + optionsOrdersEPL + optionsCancelOrdersEPL + optionsOrderEPL + optionsCancelOrderEPL + optionsTradingHistoryEPL + + websocketRateLimitNotNeededEPL ) -// GetRateLimit returns the rate limiter for the exchange -func GetRateLimit() request.RateLimitDefinitions { - return request.RateLimitDefinitions{ - spotDefaultEPL: request.NewRateLimitWithWeight(oneSecondInterval, spotPublicRate, 1), - spotPrivateEPL: request.NewRateLimitWithWeight(oneSecondInterval, spotPrivateRate, 1), - spotPlaceOrdersEPL: request.NewRateLimitWithWeight(oneSecondInterval, spotPlaceOrdersRate, 1), - spotCancelOrdersEPL: request.NewRateLimitWithWeight(oneSecondInterval, spotCancelOrdersRate, 1), - perpetualSwapDefaultEPL: request.NewRateLimitWithWeight(oneSecondInterval, perpetualSwapPublicRate, 1), - perpetualSwapPlaceOrdersEPL: request.NewRateLimitWithWeight(oneSecondInterval, perpetualSwapPlaceOrdersRate, 1), - perpetualSwapPrivateEPL: request.NewRateLimitWithWeight(oneSecondInterval, perpetualSwapPrivateRate, 1), - perpetualSwapCancelOrdersEPL: request.NewRateLimitWithWeight(oneSecondInterval, perpetualSwapCancelOrdersRate, 1), - walletEPL: request.NewRateLimitWithWeight(oneSecondInterval, walletRate, 1), - withdrawalEPL: request.NewRateLimitWithWeight(threeSecondsInterval, withdrawalRate, 1), - } +// package level rate limits for REST API +var packageRateLimits = request.RateLimitDefinitions{ + publicOrderbookSpotEPL: standardRateLimit(), + publicMarketTradesSpotEPL: standardRateLimit(), + publicCandleStickSpotEPL: standardRateLimit(), + publicTickersSpotEPL: standardRateLimit(), + publicCurrencyPairDetailSpotEPL: standardRateLimit(), + publicListCurrencyPairsSpotEPL: standardRateLimit(), + publicCurrenciesSpotEPL: standardRateLimit(), + + publicCurrencyPairsMarginEPL: standardRateLimit(), + publicOrderbookMarginEPL: standardRateLimit(), + + publicInsuranceDeliveryEPL: standardRateLimit(), + publicDeliveryContractsEPL: standardRateLimit(), + publicOrderbookDeliveryEPL: standardRateLimit(), + publicTradingHistoryDeliveryEPL: standardRateLimit(), + publicCandleSticksDeliveryEPL: standardRateLimit(), + publicTickersDeliveryEPL: standardRateLimit(), + + publicFuturesContractsEPL: standardRateLimit(), + publicOrderbookFuturesEPL: standardRateLimit(), + publicTradingHistoryFuturesEPL: standardRateLimit(), + publicCandleSticksFuturesEPL: standardRateLimit(), + publicPremiumIndexEPL: standardRateLimit(), + publicTickersFuturesEPL: standardRateLimit(), + publicFundingRatesEPL: standardRateLimit(), + publicInsuranceFuturesEPL: standardRateLimit(), + publicStatsFuturesEPL: standardRateLimit(), + publicIndexConstituentsEPL: standardRateLimit(), + publicLiquidationHistoryEPL: standardRateLimit(), + + publicUnderlyingOptionsEPL: standardRateLimit(), + publicExpirationOptionsEPL: standardRateLimit(), + publicContractsOptionsEPL: standardRateLimit(), + publicSettlementOptionsEPL: standardRateLimit(), + publicOrderbookOptionsEPL: standardRateLimit(), + publicTickerOptionsEPL: standardRateLimit(), + publicUnderlyingTickerOptionsEPL: standardRateLimit(), + publicCandleSticksOptionsEPL: standardRateLimit(), + publicMarkpriceCandleSticksOptionsEPL: standardRateLimit(), + publicTradeHistoryOptionsEPL: standardRateLimit(), + + publicGetServerTimeEPL: standardRateLimit(), + publicFlashSwapEPL: standardRateLimit(), + publicListCurrencyChainEPL: standardRateLimit(), + + walletDepositAddressEPL: standardRateLimit(), + walletWithdrawalRecordsEPL: standardRateLimit(), + walletDepositRecordsEPL: standardRateLimit(), + walletTransferCurrencyEPL: personalAccountRateLimit(), + walletSubAccountTransferEPL: personalAccountRateLimit(), + walletSubAccountTransferHistoryEPL: standardRateLimit(), + walletSubAccountToSubAccountTransferEPL: personalAccountRateLimit(), + walletWithdrawStatusEPL: standardRateLimit(), + walletSubAccountBalancesEPL: personalAccountRateLimit(), + walletSubAccountMarginBalancesEPL: personalAccountRateLimit(), + walletSubAccountFuturesBalancesEPL: personalAccountRateLimit(), + walletSubAccountCrossMarginBalancesEPL: personalAccountRateLimit(), + walletSavedAddressesEPL: standardRateLimit(), + walletTradingFeeEPL: standardRateLimit(), + walletTotalBalanceEPL: personalAccountRateLimit(), + walletWithdrawEPL: withdrawFromWalletRateLimit(), + walletCancelWithdrawEPL: standardRateLimit(), + + subAccountEPL: personalAccountRateLimit(), + + spotTradingFeeEPL: standardRateLimit(), + spotAccountsEPL: standardRateLimit(), + spotGetOpenOrdersEPL: standardRateLimit(), + spotClosePositionEPL: orderCloseRateLimit(), + spotBatchOrdersEPL: spotOrderPlacementRateLimit(), + spotPlaceOrderEPL: spotOrderPlacementRateLimit(), + spotGetOrdersEPL: standardRateLimit(), + spotCancelAllOpenOrdersEPL: orderCloseRateLimit(), + spotCancelBatchOrdersEPL: orderCloseRateLimit(), + spotGetOrderEPL: standardRateLimit(), + spotAmendOrderEPL: spotOrderPlacementRateLimit(), + spotCancelSingleOrderEPL: orderCloseRateLimit(), + spotTradingHistoryEPL: standardRateLimit(), + spotCountdownCancelEPL: orderCloseRateLimit(), + spotCreateTriggerOrderEPL: spotOrderPlacementRateLimit(), + spotGetTriggerOrderListEPL: standardRateLimit(), + spotCancelTriggerOrdersEPL: orderCloseRateLimit(), + spotGetTriggerOrderEPL: standardRateLimit(), + spotCancelTriggerOrderEPL: orderCloseRateLimit(), + + marginAccountListEPL: otherPrivateEndpointRateLimit(), + marginAccountBalanceEPL: otherPrivateEndpointRateLimit(), + marginFundingAccountListEPL: otherPrivateEndpointRateLimit(), + marginLendBorrowEPL: otherPrivateEndpointRateLimit(), + marginAllLoansEPL: otherPrivateEndpointRateLimit(), + marginMergeLendingLoansEPL: otherPrivateEndpointRateLimit(), + marginGetLoanEPL: otherPrivateEndpointRateLimit(), + marginModifyLoanEPL: otherPrivateEndpointRateLimit(), + marginCancelLoanEPL: otherPrivateEndpointRateLimit(), + marginRepayLoanEPL: otherPrivateEndpointRateLimit(), + marginListLoansEPL: otherPrivateEndpointRateLimit(), + marginRepaymentRecordEPL: otherPrivateEndpointRateLimit(), + marginSingleRecordEPL: otherPrivateEndpointRateLimit(), + marginModifyLoanRecordEPL: otherPrivateEndpointRateLimit(), + marginAutoRepayEPL: otherPrivateEndpointRateLimit(), + marginGetAutoRepaySettingsEPL: otherPrivateEndpointRateLimit(), + marginGetMaxTransferEPL: otherPrivateEndpointRateLimit(), + marginGetMaxBorrowEPL: otherPrivateEndpointRateLimit(), + marginSupportedCurrencyCrossListEPL: otherPrivateEndpointRateLimit(), + marginSupportedCurrencyCrossEPL: otherPrivateEndpointRateLimit(), + marginAccountsEPL: otherPrivateEndpointRateLimit(), + marginAccountHistoryEPL: otherPrivateEndpointRateLimit(), + marginCreateCrossBorrowLoanEPL: otherPrivateEndpointRateLimit(), + marginExecuteRepaymentsEPL: otherPrivateEndpointRateLimit(), + marginGetCrossMarginRepaymentsEPL: otherPrivateEndpointRateLimit(), + marginGetMaxTransferCrossEPL: otherPrivateEndpointRateLimit(), + marginGetMaxBorrowCrossEPL: otherPrivateEndpointRateLimit(), + marginGetCrossBorrowHistoryEPL: otherPrivateEndpointRateLimit(), + marginGetBorrowEPL: otherPrivateEndpointRateLimit(), + + flashSwapOrderEPL: otherPrivateEndpointRateLimit(), + flashGetOrdersEPL: otherPrivateEndpointRateLimit(), + flashGetOrderEPL: otherPrivateEndpointRateLimit(), + flashOrderReviewEPL: otherPrivateEndpointRateLimit(), + + perpetualAccountEPL: standardRateLimit(), + perpetualAccountBooksEPL: standardRateLimit(), + perpetualPositionsEPL: standardRateLimit(), + perpetualPositionEPL: standardRateLimit(), + perpetualUpdateMarginEPL: standardRateLimit(), + perpetualUpdateLeverageEPL: standardRateLimit(), + perpetualUpdateRiskEPL: standardRateLimit(), + perpetualToggleDualModeEPL: standardRateLimit(), + perpetualPositionsDualModeEPL: standardRateLimit(), + perpetualUpdateMarginDualModeEPL: standardRateLimit(), + perpetualUpdateLeverageDualModeEPL: standardRateLimit(), + perpetualUpdateRiskDualModeEPL: standardRateLimit(), + perpetualSubmitOrderEPL: perpetualOrderplacementRateLimit(), + perpetualGetOrdersEPL: standardRateLimit(), + perpetualSubmitBatchOrdersEPL: perpetualOrderplacementRateLimit(), + perpetualFetchOrderEPL: standardRateLimit(), + perpetualCancelOrderEPL: orderCloseRateLimit(), + perpetualAmendOrderEPL: perpetualOrderplacementRateLimit(), + perpetualTradingHistoryEPL: standardRateLimit(), + perpetualClosePositionEPL: orderCloseRateLimit(), + perpetualLiquidationHistoryEPL: standardRateLimit(), + perpetualCancelTriggerOrdersEPL: orderCloseRateLimit(), + perpetualSubmitTriggerOrderEPL: perpetualOrderplacementRateLimit(), + perpetualListOpenOrdersEPL: standardRateLimit(), + perpetualCancelOpenOrdersEPL: orderCloseRateLimit(), + perpetualGetTriggerOrderEPL: standardRateLimit(), + perpetualCancelTriggerOrderEPL: orderCloseRateLimit(), + + deliveryAccountEPL: standardRateLimit(), + deliveryAccountBooksEPL: standardRateLimit(), + deliveryPositionsEPL: standardRateLimit(), + deliveryUpdateMarginEPL: standardRateLimit(), + deliveryUpdateLeverageEPL: standardRateLimit(), + deliveryUpdateRiskLimitEPL: standardRateLimit(), + deliverySubmitOrderEPL: deliverySubmitCancelAmendRateLimit(), + deliveryGetOrdersEPL: standardRateLimit(), + deliveryCancelOrdersEPL: deliverySubmitCancelAmendRateLimit(), + deliveryGetOrderEPL: standardRateLimit(), + deliveryCancelOrderEPL: deliverySubmitCancelAmendRateLimit(), + deliveryTradingHistoryEPL: standardRateLimit(), + deliveryCloseHistoryEPL: standardRateLimit(), + deliveryLiquidationHistoryEPL: standardRateLimit(), + deliverySettlementHistoryEPL: standardRateLimit(), + deliveryGetTriggerOrdersEPL: standardRateLimit(), + deliveryAutoOrdersEPL: standardRateLimit(), + deliveryCancelTriggerOrdersEPL: deliverySubmitCancelAmendRateLimit(), + deliveryGetTriggerOrderEPL: standardRateLimit(), + deliveryCancelTriggerOrderEPL: deliverySubmitCancelAmendRateLimit(), + + optionsSettlementsEPL: standardRateLimit(), + optionsAccountsEPL: standardRateLimit(), + optionsAccountBooksEPL: standardRateLimit(), + optionsPositions: standardRateLimit(), + optionsLiquidationHistoryEPL: standardRateLimit(), + optionsSubmitOrderEPL: optionsSubmitCancelAmendRateLimit(), + optionsOrdersEPL: standardRateLimit(), + optionsCancelOrdersEPL: optionsSubmitCancelAmendRateLimit(), + optionsOrderEPL: standardRateLimit(), + optionsCancelOrderEPL: optionsSubmitCancelAmendRateLimit(), + optionsTradingHistoryEPL: standardRateLimit(), + + privateUnifiedSpotEPL: standardRateLimit(), + + websocketRateLimitNotNeededEPL: nil, // no rate limit for certain websocket functions +} + +func standardRateLimit() *request.RateLimiterWithWeight { + return request.NewRateLimitWithWeight(time.Second*10, 200, 1) +} + +func personalAccountRateLimit() *request.RateLimiterWithWeight { + return request.NewRateLimitWithWeight(time.Second*10, 80, 1) +} + +func orderCloseRateLimit() *request.RateLimiterWithWeight { + return request.NewRateLimitWithWeight(time.Second, 200, 1) +} + +func spotOrderPlacementRateLimit() *request.RateLimiterWithWeight { + return request.NewRateLimitWithWeight(time.Second, 10, 1) +} + +func otherPrivateEndpointRateLimit() *request.RateLimiterWithWeight { + return request.NewRateLimitWithWeight(time.Second*10, 150, 1) +} + +func perpetualOrderplacementRateLimit() *request.RateLimiterWithWeight { + return request.NewRateLimitWithWeight(time.Second, 100, 1) +} + +func deliverySubmitCancelAmendRateLimit() *request.RateLimiterWithWeight { + return request.NewRateLimitWithWeight(time.Second*10, 500, 1) +} + +func optionsSubmitCancelAmendRateLimit() *request.RateLimiterWithWeight { + return request.NewRateLimitWithWeight(time.Second, 200, 1) +} + +func withdrawFromWalletRateLimit() *request.RateLimiterWithWeight { + return request.NewRateLimitWithWeight(time.Second*3, 1, 1) } diff --git a/exchanges/gateio/ratelimiter_test.go b/exchanges/gateio/ratelimiter_test.go new file mode 100644 index 00000000000..926c815284d --- /dev/null +++ b/exchanges/gateio/ratelimiter_test.go @@ -0,0 +1,16 @@ +package gateio + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestRateLimits(t *testing.T) { + for epl := range optionsTradingHistoryEPL { + if epl == 0 { + continue + } + assert.NotEmptyf(t, packageRateLimits[epl], "Empty rate limit not found for const %v", epl) + } +}