gateio

package
v0.9.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 19, 2025 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GateTimestamp = "Timestamp"
	GateKey       = "KEY"
	GateSign      = "SIGN"
)

Variables

This section is empty.

Functions

func S2M

func S2M(i interface{}) map[string]string

Types

type AccountClient

type AccountClient struct {
	// contains filtered or unexported fields
}

func NewAccountClient

func NewAccountClient(opt *ClientOptions, store limiter.Store, opts ...ClientOption) *AccountClient

func (*AccountClient) GetAccountDetail

func (o *AccountClient) GetAccountDetail(ctx context.Context) (*GetAccountDetailResponse, error)

type AccountDetail

type AccountDetail struct {
	IPWhitelist   []string `json:"ip_whitelist"`
	CurrencyPairs []string `json:"currency_pairs"`
	UserID        int64    `json:"user_id"`
	Tier          int64    `json:"tier"`
	Key           struct {
		Mode            int32 `json:"mode"`
		CopyTradingRole int32 `json:"copy_trading_role"`
	}
}

type AddressVerification

type AddressVerification string
const (
	AddressVerificationNone AddressVerification = "0"
	AddressVerificationDone AddressVerification = "1"
)

func (AddressVerification) IsVerified

func (o AddressVerification) IsVerified() bool

func (AddressVerification) String

func (o AddressVerification) String() string

type BaseClient

type BaseClient struct {
	// contains filtered or unexported fields
}

func NewBaseClient

func NewBaseClient(opt *ClientOptions, store limiter.Store, opts ...ClientOption) (*BaseClient, error)

func (*BaseClient) Account

func (o *BaseClient) Account() IGateAccount

func (*BaseClient) Spot

func (o *BaseClient) Spot() IGateSpot

func (*BaseClient) Wallet

func (o *BaseClient) Wallet() IGateWallet

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(opt *ClientOptions, store limiter.Store, opts ...ClientOption) *Client

func (*Client) Do

func (o *Client) Do(ctx context.Context, method, endpoint string, private bool, dest interface{}, params ...map[string]string) error

func (*Client) DoPlain

func (o *Client) DoPlain(ctx context.Context, method, path string, private bool, dest interface{}, params ...map[string]string) error

type ClientOption added in v0.9.9

type ClientOption func(c *Client)

func WithLogger added in v0.9.9

func WithLogger(log logger.Logger) ClientOption

type ClientOptions

type ClientOptions struct {
	AccessKey string
	SecretKey string
	BaseURL   *url.URL
}

type CreateSpotOrderRequest

type CreateSpotOrderRequest struct {
	CurrencyPair string `json:"currency_pair"`
	Type         string `json:"type"`   // "limit", "market", etc.
	Side         string `json:"side"`   // "buy" or "sell"
	Amount       string `json:"amount"` // Amount to buy/sell
	TimeInForce  string `json:"time_in_force"`
}

buy means quote currency, BTC_USDT means USDT sell means base currency,BTC_USDT means BTC

type CreateSpotOrderResponse

type CreateSpotOrderResponse struct {
	Data *SpotOrder `json:"data"`
}

type CreateWithdrawalRequest

type CreateWithdrawalRequest struct {
	Amount   string `json:"amount"`
	Currency string `json:"currency"`
	Address  string `json:"address"`
	Chain    string `json:"chain"`
}

type CreateWithdrawalResponse

type CreateWithdrawalResponse struct {
	Data *Withdrawal `json:"data"`
}

type CurrencyChain

type CurrencyChain struct {
	Chain              string `json:"chain"`
	NameEn             string `json:"name_en"`
	ContractAddress    string `json:"contract_address,omitempty"`
	IsDisabled         int    `json:"is_disabled"`
	IsDepositDisabled  int    `json:"is_deposit_disabled"`
	IsWithdrawDisabled int    `json:"is_withdraw_disabled"`
	Decimal            int64  `json:"decimal,string"`
}

type CurrencyDetails

type CurrencyDetails struct {
	Currency         string `json:"currency"`
	Name             string `json:"name"`
	Delisted         bool   `json:"delisted"`
	WithdrawDisabled bool   `json:"withdraw_disabled"`
	WithdrawDelayed  bool   `json:"withdraw_delayed"`
	DepositDisabled  bool   `json:"deposit_disabled"`
	TradeDisabled    bool   `json:"trade_disabled"`
	Chain            string `json:"chain"`
	Chains           []struct {
		Name             string `json:"name"`
		Addr             string `json:"addr,omitempty"`
		WithdrawDisabled bool   `json:"withdraw_disabled"`
		WithdrawDelayed  bool   `json:"withdraw_delayed"`
		DepositDisabled  bool   `json:"deposit_disabled"`
	} `json:"chains"`
}

type CurrencyPair

type CurrencyPair struct {
	ID              string `json:"id"`
	Base            string `json:"base"`
	BaseName        string `json:"base_name"`
	Quote           string `json:"quote"`
	QuoteName       string `json:"quote_name"`
	Fee             string `json:"fee"`
	MinBaseAmount   string `json:"min_base_amount"`
	MinQuoteAmount  string `json:"min_quote_amount"`
	MaxBaseAmount   string `json:"max_base_amount"`
	MaxQuoteAmount  string `json:"max_quote_amount"`
	AmountPrecision int    `json:"amount_precision"`
	Precision       int    `json:"precision"`
	TradeStatus     string `json:"trade_status"`
	SellStart       int    `json:"sell_start"`
	BuyStart        int    `json:"buy_start"`
	DelistingTime   int    `json:"delisting_time"`
	TradeURL        string `json:"trade_url"`
}

type DepositAddress

type DepositAddress struct {
	Currency            string `json:"currency"`
	Address             string `json:"address"`
	MultichainAddresses []struct {
		Chain        string `json:"chain"`
		Address      string `json:"address"`
		PaymentID    string `json:"payment_id"`
		PaymentName  string `json:"payment_name"`
		ObtainFailed int    `json:"obtain_failed"`
	} `json:"multichain_addresses"`
}

type ErrorResponse

type ErrorResponse struct {
	Label   string `json:"label"`   // Error code
	Message string `json:"message"` // Error message
}

ErrorResponse represents gate.io API error response

type GetAccountDetailResponse

type GetAccountDetailResponse struct {
	Data *AccountDetail `json:"data"`
}

type GetCurrencyChainsSupportedRequest

type GetCurrencyChainsSupportedRequest struct {
	Currency string `json:"currency"`
}

type GetCurrencySupportedChainResponse

type GetCurrencySupportedChainResponse struct {
	Data []*CurrencyChain `json:"data"`
}

type GetDepositAddressRequest

type GetDepositAddressRequest struct {
	Currency string `json:"currency"`
}

type GetDepositAddressResponse

type GetDepositAddressResponse struct {
	Data *DepositAddress `json:"data"`
}

type GetSpotAccountBalancesRequest

type GetSpotAccountBalancesRequest struct {
	Currency string `json:"currency,omitempty"`
}

type GetSpotAccountBalancesResponse

type GetSpotAccountBalancesResponse struct {
	Data []*SpotAccountBalance `json:"data"`
}

type GetSpotCurrenciesResponse

type GetSpotCurrenciesResponse struct {
	Data []*CurrencyDetails `json:"data"`
}

type GetSpotCurrencyResponse

type GetSpotCurrencyResponse struct {
	Data *CurrencyDetails `json:"data"`
}

type GetSpotOrderResponse

type GetSpotOrderResponse struct {
	Data *SpotOrder `json:"data"`
}

type GetSpotSupportedCurrencyPairResponse

type GetSpotSupportedCurrencyPairResponse struct {
	Data *CurrencyPair `json:"data"`
}

type GetSpotSupportedCurrencyPairsResponse

type GetSpotSupportedCurrencyPairsResponse struct {
	Data []*CurrencyPair `json:"data"`
}

type GetTickersInfoRequest

type GetTickersInfoRequest struct {
	CurrencyPair string `json:"currency_pair,omitempty"`
}

type GetTickersInfoResponse

type GetTickersInfoResponse struct {
	Data []*TickerInfo `json:"data"`
}

type GetWalletSavedAddressesRequest

type GetWalletSavedAddressesRequest struct {
	Currency string `json:"currency" url:"currency"`
	Chain    string `json:"chain,omitempty" url:"chain,omitempty"`
}

type GetWalletSavedAddressesResponse

type GetWalletSavedAddressesResponse struct {
	Data []*SavedAddress `json:"data"`
}

type GetWithdrawalHistoryRequest

type GetWithdrawalHistoryRequest struct {
	Currency        string `json:"currency,omitempty" url:"currency,omitempty"`
	WithdrawalID    string `json:"withdrawal_id,omitempty" url:"withdrawal_id,omitempty"`
	AssetClass      string `json:"asset_class,omitempty" url:"asset_class,omitempty"`
	WithdrawOrderID string `json:"withdraw_order_id,omitempty" url:"withdraw_order_id,omitempty"`
	From            string `json:"from,omitempty" url:"from,omitempty"`
	To              string `json:"to,omitempty" url:"to,omitempty"`
	Limit           string `json:"limit,omitempty" url:"limit,omitempty"`
	Offset          string `json:"offset,omitempty" url:"offset,omitempty"`
}

type GetWithdrawalHistoryResponse

type GetWithdrawalHistoryResponse struct {
	Data []*WithdrawalHistory `json:"data"`
}

type GetWithdrawalRulesRequest

type GetWithdrawalRulesRequest struct {
	Currency string `json:"currency,omitempty" url:"currency,omitempty"`
}

type GetWithdrawalRulesResponse

type GetWithdrawalRulesResponse struct {
	Data []*WithdrawalRule `json:"data"`
}

type IGateAccount

type IGateAccount interface {
	GetAccountDetail(context.Context) (*GetAccountDetailResponse, error)
}

type IGateClient

type IGateClient interface {
	Wallet() IGateWallet
}

type IGateSpot

type IGateSpot interface {
	GetSpotCurrencies(ctx context.Context) (*GetSpotCurrenciesResponse, error)
	GetSpotCurrency(ctx context.Context, currency string) (*GetSpotCurrencyResponse, error)
	GetSpotSupportedCurrencyPairs(ctx context.Context) (*GetSpotSupportedCurrencyPairsResponse, error)
	GetSpotSupportedCurrencyPair(ctx context.Context, currencyPair string) (*GetSpotSupportedCurrencyPairResponse, error)
	GetTickersInfo(ctx context.Context, dto *GetTickersInfoRequest) (*GetTickersInfoResponse, error)
	GetSpotAccountBalances(ctx context.Context, dto *GetSpotAccountBalancesRequest) (*GetSpotAccountBalancesResponse, error)
	CreateSpotOrder(ctx context.Context, dto *CreateSpotOrderRequest) (*CreateSpotOrderResponse, error)
	GetSpotOrder(ctx context.Context, orderID string) (*GetSpotOrderResponse, error)
}

type ISigner

type ISigner interface {
	AddHeaders(req *http.Request) *http.Request
	SignRequest(ctx context.Context, req *http.Request) (*http.Request, error)
	GetTimestamp() string
}

func NewSigner

func NewSigner(accessKey, secretKey string) ISigner

type OrderFinishedAs

type OrderFinishedAs string
const (
	OrderFinishedAsOpen               OrderFinishedAs = "open"
	OrderFinishedAsFilled             OrderFinishedAs = "filled"
	OrderFinishedAsCancelled          OrderFinishedAs = "cancelled"
	OrderFinishedAsLiquidateCancelled OrderFinishedAs = "liquidate_cancelled"
	OrderFinishedAsSmall              OrderFinishedAs = "small"
	OrderFinishedAsDepthNotEnough     OrderFinishedAs = "depth_not_enough"
	OrderFinishedAsTraderNotEnough    OrderFinishedAs = "trader_not_enough"
	OrderFinishedAsIOC                OrderFinishedAs = "ioc"
	OrderFinishedAsPOC                OrderFinishedAs = "poc"
	OrderFinishedAsFOK                OrderFinishedAs = "fok"
	OrderFinishedAsSTP                OrderFinishedAs = "stp"
	OrderFinishedAsUnknown            OrderFinishedAs = "unknown"
)

func (OrderFinishedAs) IsFailed

func (o OrderFinishedAs) IsFailed() bool

TODO: Does not take into account IOC, POC, FOK, STP

func (OrderFinishedAs) String

func (o OrderFinishedAs) String() string

type OrderSide

type OrderSide string
const (
	OrderSideBuy  OrderSide = "buy"
	OrderSideSell OrderSide = "sell"
)

func (OrderSide) String

func (o OrderSide) String() string

type OrderStatus

type OrderStatus string
const (
	OrderStatusOpen     OrderStatus = "open"
	OrderStatusClosed   OrderStatus = "closed"
	OrderStatusCanceled OrderStatus = "cancelled"
)

func (OrderStatus) String

func (o OrderStatus) String() string

type OrderType

type OrderType string
const (
	OrderTypeMarket OrderType = "market"
	OrderTypeLimit  OrderType = "limit"
)

func (OrderType) String

func (o OrderType) String() string

type PairTradeStatus

type PairTradeStatus string
const (
	PairTradeStatusUntradable PairTradeStatus = "untradable"
	PairTradeStatusTradable   PairTradeStatus = "tradable"
	PairTradeStatusBuyable    PairTradeStatus = "buyable"
	PairTradeStatusSellable   PairTradeStatus = "sellable"
)

func (PairTradeStatus) IsTradable

func (o PairTradeStatus) IsTradable() bool

func (PairTradeStatus) String

func (o PairTradeStatus) String() string

type SavedAddress

type SavedAddress struct {
	Currency string              `json:"currency"`
	Chain    string              `json:"chain"`
	Address  string              `json:"address"`
	Name     string              `json:"name,omitempty"`
	Tag      string              `json:"tag,omitempty"`
	Verified AddressVerification `json:"verified"`
}

type Signer

type Signer struct {
	// contains filtered or unexported fields
}

func (*Signer) AddHeaders

func (s *Signer) AddHeaders(req *http.Request) *http.Request

func (*Signer) GetTimestamp

func (s *Signer) GetTimestamp() string

func (*Signer) SignRequest

func (s *Signer) SignRequest(_ context.Context, req *http.Request) (*http.Request, error)

type SpotAccountBalance

type SpotAccountBalance struct {
	Currency  string          `json:"currency"`
	Available decimal.Decimal `json:"available"`
	Locked    decimal.Decimal `json:"locked"`
}

type SpotClient

type SpotClient struct {
	// contains filtered or unexported fields
}

func NewSpotClient

func NewSpotClient(opt *ClientOptions, store limiter.Store, opts ...ClientOption) *SpotClient

func (*SpotClient) CreateSpotOrder

func (*SpotClient) GetSpotAccountBalances

func (*SpotClient) GetSpotCurrencies

func (o *SpotClient) GetSpotCurrencies(ctx context.Context) (*GetSpotCurrenciesResponse, error)

func (*SpotClient) GetSpotCurrency

func (o *SpotClient) GetSpotCurrency(ctx context.Context, currency string) (*GetSpotCurrencyResponse, error)

func (*SpotClient) GetSpotOrder

func (o *SpotClient) GetSpotOrder(ctx context.Context, orderID string) (*GetSpotOrderResponse, error)

func (*SpotClient) GetSpotSupportedCurrencyPair

func (o *SpotClient) GetSpotSupportedCurrencyPair(ctx context.Context, currencyPair string) (*GetSpotSupportedCurrencyPairResponse, error)

func (*SpotClient) GetSpotSupportedCurrencyPairs

func (o *SpotClient) GetSpotSupportedCurrencyPairs(ctx context.Context) (*GetSpotSupportedCurrencyPairsResponse, error)

func (*SpotClient) GetTickersInfo

type SpotOrder

type SpotOrder struct {
	ID           string          `json:"id"`
	Text         string          `json:"text,omitempty"`
	AmendText    string          `json:"amend_text,omitempty"`
	CreateTimeMs int64           `json:"create_time_ms"`
	UpdateTimeMs int64           `json:"update_time_ms"`
	Status       OrderStatus     `json:"status"`
	CurrencyPair string          `json:"currency_pair"`
	Type         OrderType       `json:"type"`
	Account      string          `json:"account"`
	Side         OrderSide       `json:"side"`
	Amount       string          `json:"amount"`
	Fee          string          `json:"fee"`
	FeeCurrency  string          `json:"fee_currency"`
	FinishAs     OrderFinishedAs `json:"finish_as"`
}

type TickerInfo

type TickerInfo struct {
	CurrencyPair string          `json:"currency_pair"`
	Last         decimal.Decimal `json:"last"`
}

type WalletClient

type WalletClient struct {
	// contains filtered or unexported fields
}

func NewWalletClient

func NewWalletClient(opt *ClientOptions, store limiter.Store, opts ...ClientOption) *WalletClient

func (*WalletClient) CreateWithdrawal

func (*WalletClient) GetDepositAddress

func (*WalletClient) GetWalletSavedAddresses

func (*WalletClient) GetWithdrawalHistory

func (*WalletClient) GetWithdrawalRules

type Withdrawal

type Withdrawal struct {
	ID              string           `json:"id"`
	Timestamp       string           `json:"timestamp"`
	WithdrawOrderID string           `json:"withdraw_order_id"`
	Currency        string           `json:"currency"`
	Address         string           `json:"address"`
	Txid            string           `json:"txid"`
	Amount          string           `json:"amount"`
	Memo            string           `json:"memo,omitempty"`
	Status          WithdrawalStatus `json:"status"`
	Chain           string           `json:"chain"`
}

type WithdrawalHistory

type WithdrawalHistory struct {
	ID              string           `json:"id"`
	Currency        string           `json:"currency"`
	Address         string           `json:"address"`
	Amount          decimal.Decimal  `json:"amount"`
	Fee             decimal.Decimal  `json:"fee"`
	Txid            string           `json:"txid"`
	Chain           string           `json:"chain"`
	Status          WithdrawalStatus `json:"status"`
	WithdrawOrderID string           `json:"withdraw_order_id,omitempty"`
	BlockNumber     string           `json:"block_number"`
	FailReason      string           `json:"fail_reason,omitempty"`
}

type WithdrawalRule

type WithdrawalRule struct {
	Currency               string                     `json:"currency"`
	Deposit                decimal.Decimal            `json:"deposit"`
	WithdrawPercent        string                     `json:"withdraw_percent"`
	WithdrawFix            decimal.Decimal            `json:"withdraw_fix"`
	WithdrawDayLimit       decimal.Decimal            `json:"withdraw_day_limit"`
	WithdrawDayLimitRemain decimal.Decimal            `json:"withdraw_day_limit_remain"`
	WithdrawAmountMini     decimal.Decimal            `json:"withdraw_amount_mini"`
	WithdrawEachtimeLimit  decimal.Decimal            `json:"withdraw_eachtime_limit"`
	WithdrawFixOnChains    map[string]decimal.Decimal `json:"withdraw_fix_on_chains"`
}

type WithdrawalStatus

type WithdrawalStatus string
const (
	WithdrawalStatusDone    WithdrawalStatus = "DONE"
	WithdrawalStatusCancel  WithdrawalStatus = "CANCEL"
	WithdrawalStatusRequest WithdrawalStatus = "REQUEST"
	WithdrawalStatusManual  WithdrawalStatus = "MANUAL"
	WithdrawalStatusBcode   WithdrawalStatus = "BCODE"
	WithdrawalStatusExtpend WithdrawalStatus = "EXTPEND"
	WithdrawalStatusFail    WithdrawalStatus = "FAIL"
	WithdrawalStatusInvalid WithdrawalStatus = "INVALID"
	WithdrawalStatusVerify  WithdrawalStatus = "VERIFY"
	WithdrawalStatusProces  WithdrawalStatus = "PROCES" //nolint:misspell
	WithdrawalStatusPend    WithdrawalStatus = "PEND"
	WithdrawalStatusDmove   WithdrawalStatus = "DMOVE"
	WithdrawalStatusReview  WithdrawalStatus = "REVIEW"
)

func (WithdrawalStatus) String

func (o WithdrawalStatus) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL