Skip to content

Commit

Permalink
fixup! GateIO: Split asset.Futures into CoinM and USDT
Browse files Browse the repository at this point in the history
  • Loading branch information
gbjk committed Feb 13, 2025
1 parent d0b5d44 commit 60e7e49
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
8 changes: 4 additions & 4 deletions exchanges/gateio/gateio.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ var (
errInvalidOrderSize = errors.New("invalid order size")
errInvalidOrderID = errors.New("invalid order id")
errInvalidAmount = errors.New("invalid amount")
errInvalidOrEmptySubaccount = errors.New("invalid or empty subaccount")
errInvalidSubAccount = errors.New("invalid or empty subaccount")
errInvalidTransferDirection = errors.New("invalid transfer direction")
errInvalidOrderSide = errors.New("invalid order side")
errDifferentAccount = errors.New("account type must be identical for all orders")
Expand Down Expand Up @@ -1184,7 +1184,7 @@ func (g *Gateio) SubAccountTransfer(ctx context.Context, arg SubAccountTransferP
return currency.ErrCurrencyCodeEmpty
}
if arg.SubAccount == "" {
return errInvalidOrEmptySubaccount
return errInvalidSubAccount
}
arg.Direction = strings.ToLower(arg.Direction)
if arg.Direction != "to" && arg.Direction != "from" {
Expand All @@ -1194,9 +1194,9 @@ func (g *Gateio) SubAccountTransfer(ctx context.Context, arg SubAccountTransferP
return errInvalidAmount
}
switch arg.SubAccountType {
case "", "spot", "futures", "delivery":
case asset.Empty, asset.Spot, asset.Futures, asset.DeliveryFutures:
default:
return fmt.Errorf("%v; only spot, futures and delivery are allowed", asset.ErrNotSupported)
return fmt.Errorf("%w: `%s`", asset.ErrNotSupported, arg.SubAccountType)
}
return g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, walletSubAccountTransferEPL, http.MethodPost, walletSubAccountTransfer, nil, &arg, nil)
}
Expand Down
20 changes: 12 additions & 8 deletions exchanges/gateio/gateio_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -744,15 +744,19 @@ func TestTransferCurrency(t *testing.T) {

func TestSubAccountTransfer(t *testing.T) {
t.Parallel()
ctx := context.Background()
req := SubAccountTransferParam{SubAccountType: asset.Index}
require.ErrorIs(t, g.SubAccountTransfer(ctx, req), currency.ErrCurrencyCodeEmpty)
req.Currency = currency.BTC
require.ErrorIs(t, g.SubAccountTransfer(ctx, req), errInvalidSubAccount)
req.SubAccount = "1337"
require.ErrorIs(t, g.SubAccountTransfer(ctx, req), errInvalidTransferDirection)
req.Direction = "to"
require.ErrorIs(t, g.SubAccountTransfer(ctx, req), errInvalidAmount)
req.Amount = 1.337
require.ErrorIs(t, g.SubAccountTransfer(ctx, req), asset.ErrNotSupported)
sharedtestvalues.SkipTestIfCredentialsUnset(t, g, canManipulateRealOrders)
if err := g.SubAccountTransfer(context.Background(), SubAccountTransferParam{
Currency: currency.BTC,
SubAccount: "12222",
Direction: "to",
Amount: 1,
}); err != nil {
t.Errorf("%s SubAccountTransfer() error %v", g.Name, err)
}
require.NoError(t, g.SubAccountTransfer(ctx, req))
}

func TestGetSubAccountTransferHistory(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion exchanges/gateio/gateio_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -1110,7 +1110,7 @@ type SubAccountTransferParam struct {
SubAccount string `json:"sub_account"`
Direction string `json:"direction"`
Amount types.Number `json:"amount"`
SubAccountType string `json:"sub_account_type"`
SubAccountType asset.Item `json:"sub_account_type"`
}

// SubAccountTransferResponse represents transfer records between main and sub accounts
Expand Down

0 comments on commit 60e7e49

Please sign in to comment.