Skip to content

Commit

Permalink
GateIO: Rename GetSingleContract and GetSingleDeliveryContracts
Browse files Browse the repository at this point in the history
Especially fixes GetSingleContract, which seems misleading to not say
Futures.
There's a load of `GetSingle*` here that should probably also be fixed,
but these two justified a dyno
  • Loading branch information
gbjk committed Jan 5, 2025
1 parent 1b00b99 commit dcf0c6c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions exchanges/gateio/gateio.go
Original file line number Diff line number Diff line change
Expand Up @@ -1842,8 +1842,8 @@ func (g *Gateio) GetAllFutureContracts(ctx context.Context, settle currency.Code
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)
func (g *Gateio) GetSingleContract(ctx context.Context, settle currency.Code, contract string) (*FuturesContract, error) {
// GetFuturesContract returns a single futures contract info for the specified settle and Currency Pair (contract << in this case)
func (g *Gateio) GetFuturesContract(ctx context.Context, settle currency.Code, contract string) (*FuturesContract, error) {
if contract == "" {
return nil, currency.ErrCurrencyPairEmpty
}
Expand Down Expand Up @@ -2623,8 +2623,8 @@ func (g *Gateio) GetAllDeliveryContracts(ctx context.Context, settle currency.Co
return contracts, g.SendHTTPRequest(ctx, exchange.RestSpot, publicDeliveryContractsEPL, deliveryPath+settle.Item.Lower+"/contracts", &contracts)
}

// GetSingleDeliveryContracts retrieves a single delivery contract instance.
func (g *Gateio) GetSingleDeliveryContracts(ctx context.Context, settle currency.Code, contract currency.Pair) (*DeliveryContract, error) {
// GetDeliveryContract retrieves a single delivery contract instance
func (g *Gateio) GetDeliveryContract(ctx context.Context, settle currency.Code, contract currency.Pair) (*DeliveryContract, error) {
if settle.IsEmpty() {
return nil, errEmptyOrInvalidSettlementCurrency
}
Expand Down
10 changes: 5 additions & 5 deletions exchanges/gateio/gateio_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -968,11 +968,11 @@ func TestGetAllFutureContracts(t *testing.T) {
}
}

func TestGetSingleContract(t *testing.T) {
func TestGetFuturesContract(t *testing.T) {
t.Parallel()
settle, err := getSettlementFromCurrency(getPair(t, asset.Futures))
require.NoError(t, err, "getSettlementFromCurrency must not error")
_, err = g.GetSingleContract(context.Background(), settle, getPair(t, asset.Futures).String())
_, err = g.GetFuturesContract(context.Background(), settle, getPair(t, asset.Futures).String())
assert.NoError(t, err, "GetSingleContract should not error")
}

Expand Down Expand Up @@ -1457,12 +1457,12 @@ func TestGetAllDeliveryContracts(t *testing.T) {
}
}

func TestGetSingleDeliveryContracts(t *testing.T) {
func TestGetDeliveryContract(t *testing.T) {
t.Parallel()
settle, err := getSettlementFromCurrency(getPair(t, asset.DeliveryFutures))
require.NoError(t, err, "getSettlementFromCurrency must not error")
_, err = g.GetSingleDeliveryContracts(context.Background(), settle, getPair(t, asset.DeliveryFutures))
assert.NoError(t, err, "GetSingleDeliveryContracts should not error")
_, err = g.GetDeliveryContract(context.Background(), settle, getPair(t, asset.DeliveryFutures))
assert.NoError(t, err, "GetDeliveryContract should not error")
}

func TestGetDeliveryOrderbook(t *testing.T) {
Expand Down
6 changes: 3 additions & 3 deletions exchanges/gateio/gateio_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -2333,7 +2333,7 @@ func (g *Gateio) GetLatestFundingRates(ctx context.Context, r *fundingrate.Lates
if err != nil {
return nil, err
}
contract, err := g.GetSingleContract(ctx, settle, fPair.String())
contract, err := g.GetFuturesContract(ctx, settle, fPair.String())
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -2423,7 +2423,7 @@ func (g *Gateio) GetOpenInterest(ctx context.Context, k ...key.PairAsset) ([]fut
}
switch k[0].Asset {
case asset.DeliveryFutures:
contractResp, err := g.GetSingleDeliveryContracts(ctx, currency.USDT, p)
contractResp, err := g.GetDeliveryContract(ctx, currency.USDT, p)
if err != nil {
return nil, err
}
Expand All @@ -2441,7 +2441,7 @@ func (g *Gateio) GetOpenInterest(ctx context.Context, k ...key.PairAsset) ([]fut
}, nil
case asset.Futures:
for _, s := range settlementCurrencies {
contractResp, err := g.GetSingleContract(ctx, s, p.String())
contractResp, err := g.GetFuturesContract(ctx, s, p.String())
if err != nil {
continue
}
Expand Down

0 comments on commit dcf0c6c

Please sign in to comment.