From ac98019eeffca46afdec2dc02782fa004d0e1704 Mon Sep 17 00:00:00 2001 From: Samuel Reid <43227667+cranktakular@users.noreply.github.com> Date: Wed, 7 Aug 2024 12:26:51 +1000 Subject: [PATCH] Quick fixies --- exchanges/coinbasepro/coinbasepro_test.go | 6 ++---- exchanges/coinbasepro/coinbasepro_wrapper.go | 19 +++++-------------- 2 files changed, 7 insertions(+), 18 deletions(-) diff --git a/exchanges/coinbasepro/coinbasepro_test.go b/exchanges/coinbasepro/coinbasepro_test.go index d64e478087f..b689c428a09 100644 --- a/exchanges/coinbasepro/coinbasepro_test.go +++ b/exchanges/coinbasepro/coinbasepro_test.go @@ -69,7 +69,7 @@ const ( errExpectedNonEmpty = "expected non-empty response" errPortfolioNameDuplicate = `CoinbasePro unsuccessful HTTP status code: 409 raw response: {"error":"CONFLICT","error_details":"A portfolio with this name already exists.","message":"A portfolio with this name already exists."}, authenticated request failed` errPortTransferInsufFunds = `CoinbasePro unsuccessful HTTP status code: 429 raw response: {"error":"unknown","error_details":"[PORTFOLIO_ERROR_CODE_INSUFFICIENT_FUNDS] insufficient funds in source account","message":"[PORTFOLIO_ERROR_CODE_INSUFFICIENT_FUNDS] insufficient funds in source account"}, authenticated request failed` - errInvalidProductID = `CoinbasePro unsuccessful HTTP status code: 400 raw response: {"error":"INVALID_ARGUMENT","error_details":"valid product_id is required","message":"valid product_id is required"}` + errInvalidProductID = `CoinbasePro unsuccessful HTTP status code: 404 raw response: {"error":"NOT_FOUND","error_details":"valid product_id is required","message":"valid product_id is required"}` errExpectedFeeRange = "expected fee range of %v and %v, received %v" errOptionInvalid = `CoinbasePro unsuccessful HTTP status code: 400 raw response: {"error":"unknown","error_details":"parsing field \"product_type\": \"OPTION\" is not a valid value","message":"parsing field \"product_type\": \"OPTION\" is not a valid value"}` @@ -1382,7 +1382,6 @@ func TestGetLatestFundingRates(t *testing.T) { func TestGetFuturesContractDetails(t *testing.T) { t.Parallel() - c.Verbose = true _, err := c.GetFuturesContractDetails(context.Background(), asset.Empty) assert.ErrorIs(t, err, futures.ErrNotFuturesAsset) _, err = c.GetFuturesContractDetails(context.Background(), asset.UpsideProfitContract) @@ -1661,8 +1660,7 @@ func TestProcessSnapshotUpdate(t *testing.T) { func TestGenerateDefaultSubscriptions(t *testing.T) { comparison := subscription.List{{Channel: "heartbeats"}, {Channel: "status"}, {Channel: "ticker"}, - {Channel: "ticker_batch"}, {Channel: "candles"}, {Channel: "market_trades"}, {Channel: "level2"}, - {Channel: "user"}} + {Channel: "ticker_batch"}, {Channel: "candles"}, {Channel: "market_trades"}, {Channel: "level2"}} for i := range comparison { comparison[i].Pairs = currency.Pairs{ currency.NewPairWithDelimiter(testCrypto.String(), testFiat.String(), "-")} diff --git a/exchanges/coinbasepro/coinbasepro_wrapper.go b/exchanges/coinbasepro/coinbasepro_wrapper.go index 8433ac9a186..990cf434497 100644 --- a/exchanges/coinbasepro/coinbasepro_wrapper.go +++ b/exchanges/coinbasepro/coinbasepro_wrapper.go @@ -655,10 +655,7 @@ func (c *CoinbasePro) GetOrderInfo(ctx context.Context, orderID string, pair cur if err != nil { return nil, err } - response, err := c.getOrderRespToOrderDetail(genOrderDetail, pair, assetItem) - if err != nil { - return nil, err - } + response := c.getOrderRespToOrderDetail(genOrderDetail, pair, assetItem) fillData, err := c.GetFills(ctx, orderID, "", "", time.Time{}, time.Now(), 2<<15-1) if err != nil { return nil, err @@ -826,10 +823,7 @@ func (c *CoinbasePro) GetActiveOrders(ctx context.Context, req *order.MultiOrder } orders := make([]order.Detail, len(respOrders)) for i := range respOrders { - orderRec, err := c.getOrderRespToOrderDetail(&respOrders[i], req.Pairs[i], asset.Spot) - if err != nil { - return nil, err - } + orderRec := c.getOrderRespToOrderDetail(&respOrders[i], req.Pairs[i], asset.Spot) orders[i] = *orderRec } return req.Filter(c.Name, orders), nil @@ -874,10 +868,7 @@ func (c *CoinbasePro) GetOrderHistory(ctx context.Context, req *order.MultiOrder } orders := make([]order.Detail, len(ord)) for i := range ord { - singleOrder, err := c.getOrderRespToOrderDetail(&ord[i], req.Pairs[0], req.AssetType) - if err != nil { - return nil, err - } + singleOrder := c.getOrderRespToOrderDetail(&ord[i], req.Pairs[0], req.AssetType) orders[i] = *singleOrder } return req.Filter(c.Name, orders), nil @@ -1185,7 +1176,7 @@ func formatExchangeKlineIntervalV3(interval kline.Interval) string { // getOrderRespToOrderDetail is a helper function used in GetOrderInfo, GetActiveOrders, and GetOrderHistory // to convert data returned by the Coinbase API into a format suitable for the exchange package -func (c *CoinbasePro) getOrderRespToOrderDetail(genOrderDetail *GetOrderResponse, pair currency.Pair, assetItem asset.Item) (*order.Detail, error) { +func (c *CoinbasePro) getOrderRespToOrderDetail(genOrderDetail *GetOrderResponse, pair currency.Pair, assetItem asset.Item) *order.Detail { var amount float64 var quoteAmount float64 var orderType order.Type @@ -1280,7 +1271,7 @@ func (c *CoinbasePro) getOrderRespToOrderDetail(genOrderDetail *GetOrderResponse LastUpdated: lastUpdateTime, Pair: pair, } - return &response, nil + return &response } // VerificationCheck returns whether authentication support is enabled or not