Skip to content

Commit

Permalink
GateIO: Fix GetOpenInterest returning asset.ErrNotEnabled
Browse files Browse the repository at this point in the history
Using wrong error for pair not enabled
  • Loading branch information
gbjk committed Jan 4, 2025
1 parent fef54d5 commit 8f662b1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
9 changes: 5 additions & 4 deletions currency/pairs.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ import (
"strings"
)

// Public Errors
var (
ErrPairDuplication = errors.New("currency pair duplication")
)

var (
errSymbolEmpty = errors.New("symbol is empty")
errNoDelimiter = errors.New("no delimiter was supplied")
errPairFormattingInconsistent = errors.New("pair formatting is inconsistent")

// ErrPairDuplication defines an error when there is multiple of the same
// currency pairs found.
ErrPairDuplication = errors.New("currency pair duplication")
)

// NewPairsFromStrings takes in currency pair strings and returns a currency
Expand Down
5 changes: 2 additions & 3 deletions engine/rpcserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ var (
errGRPCShutdownSignalIsNil = errors.New("cannot shutdown, gRPC shutdown channel is nil")
errInvalidStrategy = errors.New("invalid strategy")
errSpecificPairNotEnabled = errors.New("specified pair is not enabled")
errPairNotEnabled = errors.New("pair is not enabled")
)

// RPCServer struct
Expand Down Expand Up @@ -4723,7 +4722,7 @@ func (s *RPCServer) GetFundingRates(ctx context.Context, r *gctrpc.GetFundingRat
}

if !pairs.Contains(cp, true) {
return nil, fmt.Errorf("%w %v", errPairNotEnabled, cp)
return nil, fmt.Errorf("%w %v", currency.ErrPairNotEnabled, cp)
}

funding, err := exch.GetHistoricalFundingRates(ctx, &fundingrate.HistoricalRatesRequest{
Expand Down Expand Up @@ -4821,7 +4820,7 @@ func (s *RPCServer) GetLatestFundingRate(ctx context.Context, r *gctrpc.GetLates
}

if !pairs.Contains(cp, true) {
return nil, fmt.Errorf("%w %v", errPairNotEnabled, cp)
return nil, fmt.Errorf("%w %v", currency.ErrPairNotEnabled, cp)
}

fundingRates, err := exch.GetLatestFundingRates(ctx, &fundingrate.LatestRateRequest{
Expand Down
2 changes: 1 addition & 1 deletion exchanges/gateio/gateio_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -2215,7 +2215,7 @@ func (g *Gateio) GetOpenInterest(ctx context.Context, k ...key.PairAsset) ([]fut
return nil, err
}
if !isEnabled {
return nil, fmt.Errorf("%w %v", asset.ErrNotEnabled, k[0].Pair())
return nil, fmt.Errorf("%w: %v", currency.ErrPairNotEnabled, k[0].Pair())
}
switch k[0].Asset {
case asset.DeliveryFutures:
Expand Down

0 comments on commit 8f662b1

Please sign in to comment.