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: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountType

type AccountType = string
const (
	AccountTypeUnified AccountType = "UNIFIED"
	AccountTypeFund    AccountType = "FUND"
	AccountTypeSpot    AccountType = "SPOT"
	AccountTypeLinear  AccountType = "LINEAR"
	AccountTypeInverse AccountType = "INVERSE"
)

type Balance

type Balance struct {
	Coin            oc.SymbolId `json:"coin"`
	TransferBalance oc.Amount   `json:"transferBalance"`
	WalletBalance   oc.Amount   `json:"walletBalance"`
	Bonus           string      `json:"bonus"`
}

type Beneficiary

type Beneficiary struct {
}

type Chain

type Chain struct {
	ChainType             string `json:"chainType"`
	Confirmation          string `json:"confirmation"`
	WithdrawFee           string `json:"withdrawFee"`
	DepositMin            string `json:"depositMin"`
	WithdrawMin           string `json:"withdrawMin"`
	Chain                 string `json:"chain"`
	ChainDeposit          string `json:"chainDeposit"`
	ChainWithdraw         string `json:"chainWithdraw"`
	MinAccuracy           string `json:"minAccuracy"`
	WithdrawPercentageFee string `json:"withdrawPercentageFee"`
	ContractAddress       string `json:"contractAddress"`
}

type Client

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

func NewClient

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

NewClient creates a new OKX API client

func (*Client) CreateUniversalTransfer

func (c *Client) CreateUniversalTransfer(coin oc.SymbolId, amount oc.Amount, fromMemberId int, toMemberId int, fromAccountType oc.AccountType, toAccountType oc.AccountType) (*TransferResponse, error)

https://bybit-exchange.github.io/docs/v5/asset/transfer/unitransfer

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 CoinInfo

type CoinInfo struct {
	Name         string  `json:"name"`
	Coin         string  `json:"coin"`
	RemainAmount string  `json:"remainAmount"`
	Chains       []Chain `json:"chains"`
}

type DepositAddressChain

type DepositAddressChain struct {
	ChainType         string       `json:"chainType"`
	AddressDeposit    string       `json:"addressDeposit"`
	TagDeposit        string       `json:"tagDeposit"`
	Chain             oc.NetworkId `json:"chain"`
	BatchReleaseLimit string       `json:"batchReleaseLimit"`
	ContractAddress   string       `json:"contractAddress"`
}

type GetAllCoinsBalanceResponse

type GetAllCoinsBalanceResponse = Response[GetAllCoinsBalanceResult]

type GetAllCoinsBalanceResult

type GetAllCoinsBalanceResult struct {
	MemberID    string    `json:"memberId"`
	AccountType string    `json:"accountType"`
	Balance     []Balance `json:"balance"`
}

type GetCoinInfoResponse

type GetCoinInfoResponse = Response[GetCoinInfoResult]

type GetCoinInfoResult

type GetCoinInfoResult struct {
	Rows []CoinInfo `json:"rows"`
}

type GetDepositAddressResponse

type GetDepositAddressResponse = Response[GetDepositAddressResult]

type GetDepositAddressResult

type GetDepositAddressResult struct {
	Coin   string                `json:"coin"`
	Chains []DepositAddressChain `json:"chains"`
}

type Response

type Response[T any] struct {
	RetCode    RetCode                `json:"retCode"`
	RetMsg     string                 `json:"retMsg"`
	Result     T                      `json:"result"`
	RetExtInfo map[string]interface{} `json:"retExtInfo"`
	Time       int64                  `json:"time"`
}

type RetCode

type RetCode int

func (RetCode) String

func (r RetCode) String() string

type TransferRequest

type TransferRequest struct {
	TransferID      string         `json:"transferId"`      // UUID, must be manually generated
	Coin            oc.SymbolId    `json:"coin"`            // Coin symbol in uppercase
	Amount          string         `json:"amount"`          // Transfer amount
	FromAccountType oc.AccountType `json:"fromAccountType"` // Source account type
	ToAccountType   oc.AccountType `json:"toAccountType"`   // Destination account type
}

type TransferResponse

type TransferResponse = Response[TransferResult]

type TransferResult

type TransferResult struct {
	TransferID string         `json:"transferId"`
	Status     TransferStatus `json:"status"`
}

type TransferStatus

type TransferStatus string
const TransferStateSuccess TransferStatus = "SUCCESS"

type UniversalTransferRequest

type UniversalTransferRequest struct {
	TransferID      string         `json:"transferId"`      // UUID, must be manually generated
	Coin            oc.SymbolId    `json:"coin"`            // Coin symbol in uppercase
	Amount          string         `json:"amount"`          // Transfer amount
	FromMemberId    int            `json:"fromMemberId"`    // From UID
	ToMemberId      int            `json:"toMemberId"`      // To UID
	FromAccountType oc.AccountType `json:"fromAccountType"` // Source account type
	ToAccountType   oc.AccountType `json:"toAccountType"`   // Destination account type
}

type WithdrawRequest

type WithdrawRequest struct {
	Coin        oc.SymbolId  `json:"coin"`                  // Required, uppercase only
	Chain       oc.NetworkId `json:"chain,omitempty"`       // Optional, depends on forceChain
	Address     oc.Address   `json:"address"`               // Required, wallet address or Bybit UID
	Tag         string       `json:"tag,omitempty"`         // Optional, required if tag exists in address book
	Amount      oc.Amount    `json:"amount"`                // Required, withdrawal amount
	Timestamp   int64        `json:"timestamp"`             // Required, current timestamp in ms
	ForceChain  *int         `json:"forceChain,omitempty"`  // Optional, 0=default, 1=force on-chain, 2=UID withdraw
	AccountType AccountType  `json:"accountType,omitempty"` // Optional, SPOT(default) or FUND
	FeeType     *int         `json:"feeType,omitempty"`     // Optional, 0=manual fee calc, 1=auto deduct
	RequestID   string       `json:"requestId,omitempty"`   // Optional, unique ID for idempotency
	Beneficiary *Beneficiary `json:"beneficiary,omitempty"` // Optional, travel rule info
}

type WithdrawResponse

type WithdrawResponse = Response[WithdrawResult]

type WithdrawResult

type WithdrawResult struct {
	ID string `json:"id"` // Withdrawal ID
}

type WithdrawalRecord

type WithdrawalRecord struct {
	WithdrawId   string               `json:"withdrawId"`
	TxID         client.TransactionId `json:"txID"`
	WithdrawType int                  `json:"withdrawType"`
	Coin         oc.SymbolId          `json:"coin"`
	Chain        oc.NetworkId         `json:"chain"`
	Amount       oc.Amount            `json:"amount"`
	WithdrawFee  oc.Amount            `json:"withdrawFee"`
	Status       WithdrawalStatus     `json:"status"`
	ToAddress    oc.Address           `json:"toAddress"`
	Tag          string               `json:"tag"`
	CreateTime   string               `json:"createTime"`
	UpdateTime   string               `json:"updateTime"`
}

type WithdrawalRecordsRequest

type WithdrawalRecordsRequest struct {
	WithdrawID   string               `json:"withdrawID,omitempty"`
	TxID         client.TransactionId `json:"txID,omitempty"`
	Coin         *oc.SymbolId         `json:"coin,omitempty"`
	WithdrawType *int                 `json:"withdrawType,omitempty"`
	StartTime    *int64               `json:"startTime,omitempty"`
	EndTime      *int64               `json:"endTime,omitempty"`
	Limit        *int                 `json:"limit,omitempty"`
	Cursor       string               `json:"cursor,omitempty"`
}

type WithdrawalRecordsResponse

type WithdrawalRecordsResponse = Response[WithdrawalRecordsResult]

type WithdrawalRecordsResult

type WithdrawalRecordsResult struct {
	Rows           []WithdrawalRecord `json:"rows"`
	NextPageCursor string             `json:"nextPageCursor"`
}

type WithdrawalStatus

type WithdrawalStatus string

WithdrawalStatus represents the status of a withdrawal

const (
	WithdrawalStatusSecurityCheck           WithdrawalStatus = "SecurityCheck"
	WithdrawalStatusPending                 WithdrawalStatus = "Pending"
	WithdrawalStatusSuccess                 WithdrawalStatus = "success"
	WithdrawalStatusCancelByUser            WithdrawalStatus = "CancelByUser"
	WithdrawalStatusReject                  WithdrawalStatus = "Reject"
	WithdrawalStatusFail                    WithdrawalStatus = "Fail"
	WithdrawalStatusBlockchainConfirmed     WithdrawalStatus = "BlockchainConfirmed"
	WithdrawalStatusMoreInformationRequired WithdrawalStatus = "MoreInformationRequired"
	WithdrawalStatusUnknown                 WithdrawalStatus = "Unknown"
)

Jump to

Keyboard shortcuts

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