api

package
v0.0.0-...-8eea3e4 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountTransferRequest

type AccountTransferRequest struct {
	Currency   oc.SymbolId         `json:"ccy"`
	Amount     oc.Amount           `json:"amt"`
	From       oc.AccountType      `json:"from"`
	To         oc.AccountType      `json:"to"`
	Type       AccountTransferType `json:"type"`
	SubAccount *oc.AccountId       `json:"subAcct,omitempty"`
}

type AccountTransferResponse

type AccountTransferResponse Response[[]AccountTransferResult]

type AccountTransferResult

type AccountTransferResult struct {
	TransferID string `json:"transId,omitempty"`
	Currency   string `json:"ccy,omitempty"`
	Amount     string `json:"amt,omitempty"`
	From       string `json:"from,omitempty"`
	To         string `json:"to,omitempty"`
}

type AccountTransferType

type AccountTransferType string
const (
	SameAccount        AccountTransferType = "0"
	MainToSub          AccountTransferType = "1"
	SubToMainUsingMain AccountTransferType = "2"
	SubToMainUsingSub  AccountTransferType = "3"
	SubToSubUsingSub   AccountTransferType = "4"
)

type AddressExtras

type AddressExtras map[string]string

type BalanceInfo

type BalanceInfo struct {
	AvailableBalance oc.Amount   `json:"availBal"`
	Balance          oc.Amount   `json:"bal"`
	Currency         oc.SymbolId `json:"ccy"`
	FrozenBalance    oc.Amount   `json:"frozenBal"`
}

type BalanceResponse

type BalanceResponse = Response[[]BalanceInfo]

type Client

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

func NewClient

func NewClient(apiKey, secretKey, passphrase string) (*Client, error)

NewClient creates a new OKX API client

func (*Client) Request

func (c *Client) Request(method, path string, input interface{}, output interface{}, query url.Values) ([]byte, error)

Request makes an authenticated HTTP request to the OKX API

func (*Client) SetBaseURL

func (c *Client) SetBaseURL(baseURL string)

type CurrencyInfo

type CurrencyInfo struct {
	BurningFeeRate       string                `json:"burningFeeRate"`
	CanDep               bool                  `json:"canDep"`
	CanInternal          bool                  `json:"canInternal"`
	CanWd                bool                  `json:"canWd"`
	Currency             oc.SymbolId           `json:"ccy"`
	Chain                SymbolAndChain        `json:"chain"`
	ContractAddress      rebal.ContractAddress `json:"ctAddr"`
	DepEstOpenTime       string                `json:"depEstOpenTime"`
	DepQuotaFixed        string                `json:"depQuotaFixed"`
	DepQuoteDailyLayer2  string                `json:"depQuoteDailyLayer2"`
	Fee                  string                `json:"fee"`
	LogoLink             string                `json:"logoLink"`
	MainNet              bool                  `json:"mainNet"`
	MaxFee               string                `json:"maxFee"`
	MaxFeeForCtAddr      string                `json:"maxFeeForCtAddr"`
	MaxWithdraw          string                `json:"maxWd"`
	MinDeposit           string                `json:"minDep"`
	MinDepArrivalConfirm string                `json:"minDepArrivalConfirm"`
	MinFee               string                `json:"minFee"`
	MinFeeForCtAddr      string                `json:"minFeeForCtAddr"`
	MinInternal          string                `json:"minInternal"`
	MinWithdraw          string                `json:"minWd"`
	MinWdUnlockConfirm   string                `json:"minWdUnlockConfirm"`
	Name                 string                `json:"name"`
	NeedTag              bool                  `json:"needTag"`
	UsedDepQuotaFixed    string                `json:"usedDepQuotaFixed"`
	UsedWdQuota          string                `json:"usedWdQuota"`
	WdEstOpenTime        string                `json:"wdEstOpenTime"`
	WithdrawQuota        string                `json:"wdQuota"`
	WithdrawTickSize     string                `json:"wdTickSz"`
}

type DepositAddressData

type DepositAddressData struct {
	// E.g.  "BTC-Bitcoin", "SOL-Solana"
	SymbolAndChain SymbolAndChain `json:"chain"`

	ContractAddr string `json:"ctAddr"`
	Currency     string `json:"ccy"`
	To           string `json:"to"`
	Address      string `json:"addr"`
	VerifiedName string `json:"verifiedName"`
	Selected     bool   `json:"selected"`
}

type GetCurrenciesResponse

type GetCurrenciesResponse = Response[[]CurrencyInfo]

type GetDepositAddressResponse

type GetDepositAddressResponse = Response[[]DepositAddressData]

type Response

type Response[T any] struct {
	Code string `json:"code"`
	Msg  string `json:"msg"`
	Data T      `json:"data"`
}

type SubaccountTransferRequest

type SubaccountTransferRequest struct {
	Currency       oc.SymbolId    `json:"ccy"`
	Amount         oc.Amount      `json:"amt"`
	From           oc.AccountType `json:"from"`
	To             oc.AccountType `json:"to"`
	FromSubAccount oc.AccountId   `json:"fromSubAccount"`
	ToSubAccount   oc.AccountId   `json:"toSubAccount"`
	LoanTrans      *bool          `json:"loanTrans,omitempty"`
	OmitPosRisk    *string        `json:"omitPosRisk,omitempty"`
}

type SubaccountTransferResponse

type SubaccountTransferResponse Response[[]SubaccountTransferResult]

type SubaccountTransferResult

type SubaccountTransferResult struct {
	TransferID string `json:"transId,omitempty"`
}

type SymbolAndChain

type SymbolAndChain string

func NewSymbolAndChain

func NewSymbolAndChain(symbol oc.SymbolId, network oc.NetworkId) SymbolAndChain

func (SymbolAndChain) NetworkId

func (s SymbolAndChain) NetworkId() oc.NetworkId

func (SymbolAndChain) Split

func (s SymbolAndChain) Split() (oc.SymbolId, oc.NetworkId)

OKX reports the chain with the symbol included, e.g. "BTC-Bitcoin", or "ETH-Ethereum"

func (SymbolAndChain) SymbolId

func (s SymbolAndChain) SymbolId() oc.SymbolId

type WithdrawalHistoryRequest

type WithdrawalHistoryRequest struct {
	Currency *oc.SymbolId `json:"ccy,omitempty"`
	WdId     string       `json:"wdId,omitempty"`
	ClientId string       `json:"clientId,omitempty"`
	TxId     string       `json:"txId,omitempty"`
	Type     string       `json:"type,omitempty"`
	State    string       `json:"state,omitempty"`
	After    int64        `json:"after,omitempty"`
	Before   int64        `json:"before,omitempty"`
	Limit    int          `json:"limit,omitempty"`
}

type WithdrawalHistoryResponse

type WithdrawalHistoryResponse = Response[[]WithdrawalRecord]

type WithdrawalRecord

type WithdrawalRecord struct {
	Currency         oc.SymbolId          `json:"ccy"`
	Chain            SymbolAndChain       `json:"chain"`
	NonTradableAsset bool                 `json:"nonTradableAsset"`
	Amount           oc.Amount            `json:"amt"`
	Timestamp        string               `json:"ts"`
	From             string               `json:"from"`
	AreaCodeFrom     string               `json:"areaCodeFrom"`
	To               string               `json:"to"`
	AreaCodeTo       string               `json:"areaCodeTo"`
	Tag              string               `json:"tag,omitempty"`
	PaymentId        string               `json:"pmtId,omitempty"`
	Memo             string               `json:"memo,omitempty"`
	AddressExtras    AddressExtras        `json:"addrEx,omitempty"`
	TxId             client.TransactionId `json:"txId"`
	Fee              oc.Amount            `json:"fee"`
	FeeCurrency      oc.SymbolId          `json:"feeCcy"`
	State            WithdrawalState      `json:"state"`
	WithdrawalId     string               `json:"wdId"`
	ClientId         string               `json:"clientId"`
	Note             string               `json:"note"`
}

type WithdrawalRequest

type WithdrawalRequest struct {
	Amount         string         `json:"amt"`
	Destination    string         `json:"dest"`
	Currency       oc.SymbolId    `json:"ccy"`
	SymbolAndChain SymbolAndChain `json:"chain"`
	ToAddress      oc.Address     `json:"toAddr"`
}

type WithdrawalResponse

type WithdrawalResponse Response[[]WithdrawalResult]

type WithdrawalResult

type WithdrawalResult struct {
	WithdrawalID string `json:"wdId,omitempty"`
	Currency     string `json:"ccy,omitempty"`
	Chain        string `json:"chain,omitempty"`
	Amount       string `json:"amt,omitempty"`
	ToAddress    string `json:"toAddr,omitempty"`
	TxID         string `json:"txId,omitempty"`
	State        string `json:"state,omitempty"`
}

type WithdrawalState

type WithdrawalState string
const (
	WithdrawalStateCanceled          WithdrawalState = "-2"
	WithdrawalStateFailed            WithdrawalState = "-1"
	WithdrawalStateWaitingWithdrawal WithdrawalState = "0"
	WithdrawalStateBroadcasting      WithdrawalState = "1"
	WithdrawalStateSuccess           WithdrawalState = "2"
)

Jump to

Keyboard shortcuts

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