hyperliquid

package module
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2025 License: MIT Imports: 21 Imported by: 14

README

go-hyperliquid

Go Reference Go Report Card CI Coverage Status Go Version

Unofficial Go client for the Hyperliquid exchange API. This implementation follows the same philosophy and patterns as the official Python SDK.

Installation

go get github.com/sonirico/go-hyperliquid

Features

This Go SDK provides full feature parity with the official Python SDK, including:

Trading Features
  • Order Management: Limit orders, market orders, trigger orders, order modifications
  • Position Management: Leverage updates, isolated margin, position closing
  • Bulk Operations: Bulk orders, bulk cancellations, bulk modifications
  • Advanced Trading: Market open/close with slippage protection, scheduled cancellations
  • Builder Support: Order routing through builders with fee structures
Account Management
  • Referral System: Set referral codes, track referral state
  • Sub-Accounts: Create and manage sub-accounts, transfer funds
  • Multi-Signature: Convert to multi-sig, execute multi-sig actions
  • Vault Operations: Vault deposits, withdrawals, and transfers
Asset Management
  • USD Transfers: Cross-chain USD transfers, spot transfers
  • Class Transfers: USD class transfers (perp ↔ spot), perp dex transfers
  • Bridge Operations: Withdraw from bridge with fee management
  • Token Delegation: Stake tokens with validators
  • Spot Trading: Full spot market support
Advanced Features
  • Agent Approval: Approve trading agents with permissions
  • Builder Fee Management: Approve and manage builder fees
  • Big Blocks: Enable/disable big block usage
Deployment Features (Advanced)
  • Spot Deployment: Token registration, genesis, freeze privileges
  • Perp Deployment: Asset registration, oracle management
  • Hyperliquidity: Register hyperliquidity assets
Consensus Layer (Validators)
  • Validator Operations: Register, unregister, profile management
  • Signer Operations: Jail/unjail self, inner actions
  • Consensus Actions: Full consensus layer interaction
WebSocket Features
  • Market Data: Real-time L2 book, trades, candles, mid prices
  • User Events: Order updates, fills, funding, ledger updates
  • Advanced Streams: BBO, active asset context, web data v2

Usage

package main

import (
    "context"
    "fmt"
    "log"
    
    "github.com/ethereum/go-ethereum/crypto"
    hyperliquid "github.com/sonirico/go-hyperliquid"
)

func main() {
    // Initialize client
    client := hyperliquid.NewClient(hyperliquid.MainnetAPIURL)
    
    // For trading, create an Exchange with your private key
    privateKey, _ := crypto.HexToECDSA("your-private-key")
    exchange := hyperliquid.NewExchange(
        privateKey,
        hyperliquid.MainnetAPIURL,
        nil,    // Meta will be fetched automatically
        "vault-address",
        "account-address",
        nil,    // SpotMeta will be fetched automatically
    )
    
    // Place a limit order
    order := hyperliquid.OrderRequest{
        Coin:    "BTC",
        IsBuy:   true,
        Size:    0.1,
        LimitPx: 40000.0,
        OrderType: hyperliquid.OrderType{
            Limit: &hyperliquid.LimitOrderType{
                Tif: "Gtc",
            },
        },
    }
    
    resp, err := exchange.Order(order, nil)
    if err != nil {
        log.Fatal(err)
    }
    
    // Subscribe to WebSocket updates
    ws := hyperliquid.NewWebsocketClient(hyperliquid.MainnetAPIURL)
    if err := ws.Connect(context.Background()); err != nil {
        log.Fatal(err)
    }
    defer ws.Close()
    
    // Subscribe to BTC trades
    _, err = ws.Subscribe(hyperliquid.Subscription{
        Type: "trades",
        Coin: "BTC",
    }, func(msg hyperliquid.WSMessage) {
        fmt.Printf("Trade: %+v\n", msg)
    })
}

Documentation

For detailed API documentation, please refer to:

Examples

Check the examples/ directory for more usage examples:

  • WebSocket subscriptions
  • Order management
  • Position handling
  • Market data retrieval

Contributing

We welcome contributions! Please see CONTRIBUTING.md for guidelines.

Quick Start for Contributors
# Clone the repository
git clone https://github.com/sonirico/go-hyperliquid.git
cd go-hyperliquid

# Install dependencies and tools
make deps install-tools

# Run all checks
make ci-full

# Run tests (excluding examples)
make ci-test

Roadmap

✅ Completed Features
  • Complete WebSocket API implementation
  • REST API client
  • All trading operations (orders, positions, leverage)
  • Market data (L2 book, trades, candles, all mids)
  • User account management
  • Referral system implementation
  • Sub-account management
  • Vault operations
  • USD and spot transfers
  • Bridge operations
  • Agent approval system
  • Builder fee management
  • Multi-signature support
  • Token delegation/staking
  • Spot deployment features
  • Perp deployment features
  • Consensus layer (validator operations)
  • Full feature parity with Python SDK
🚀 Future Enhancements
  • Enhanced documentation with more examples
  • Performance optimizations
  • Additional testing and edge case coverage
  • Rate limiting and retry mechanisms
  • Monitoring and observability features
  • Order management
  • User account operations
  • Advanced order types
  • Historical data API
  • Rate limiting improvements
  • Connection pooling

License

MIT License

Copyright (c) 2025

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Documentation

Overview

Package hyperliquid provides a Go client library for the Hyperliquid exchange API. It includes support for both REST API and WebSocket connections, allowing users to access market data, manage orders, and handle user account operations.

Index

Constants

View Source
const (
	MainnetAPIURL = "https://api.hyperliquid.xyz"
	TestnetAPIURL = "https://api.hyperliquid-testnet.xyz"
	LocalAPIURL   = "http://localhost:3001"
)
View Source
const (
	DefaultSlippage = 0.05 // 5%
)

Constants for default values

Variables

This section is empty.

Functions

func FloatToUsdInt added in v0.4.0

func FloatToUsdInt(value float64) int

Utility function to convert float to USD integer representation

func GetTimestampMs added in v0.4.0

func GetTimestampMs() int64

GetTimestampMs returns current timestamp in milliseconds

func SignAgent added in v0.4.0

func SignAgent(
	privateKey *ecdsa.PrivateKey,
	agentAddress, agentName string,
	timestamp int64,
	isMainnet bool,
) (string, error)

SignAgent signs agent approval action

func SignApproveBuilderFee added in v0.4.0

func SignApproveBuilderFee(
	privateKey *ecdsa.PrivateKey,
	builderAddress string,
	maxFeeRate float64,
	timestamp int64,
	isMainnet bool,
) (string, error)

SignApproveBuilderFee signs approve builder fee action

func SignConvertToMultiSigUserAction added in v0.4.0

func SignConvertToMultiSigUserAction(
	privateKey *ecdsa.PrivateKey,
	signers []string,
	threshold int,
	timestamp int64,
	isMainnet bool,
) (string, error)

SignConvertToMultiSigUserAction signs convert to multi-sig user action

func SignL1Action

func SignL1Action(
	privateKey *ecdsa.PrivateKey,
	action any,
	vaultAddress string,
	timestamp int64,
	isMainnet bool,
) (string, error)

func SignMultiSigAction added in v0.4.0

func SignMultiSigAction(
	privateKey *ecdsa.PrivateKey,
	innerAction map[string]any,
	signers []string,
	signatures []string,
	timestamp int64,
	isMainnet bool,
) (string, error)

SignMultiSigAction signs multi-signature action

func SignPerpDexClassTransferAction added in v0.4.0

func SignPerpDexClassTransferAction(
	privateKey *ecdsa.PrivateKey,
	dex, token string,
	amount float64,
	toPerp bool,
	timestamp int64,
	isMainnet bool,
) (string, error)

SignPerpDexClassTransferAction signs perp dex class transfer action

func SignSpotTransferAction added in v0.4.0

func SignSpotTransferAction(
	privateKey *ecdsa.PrivateKey,
	amount float64,
	destination, token string,
	timestamp int64,
	isMainnet bool,
) (string, error)

SignSpotTransferAction signs spot transfer action

func SignTokenDelegateAction added in v0.4.0

func SignTokenDelegateAction(
	privateKey *ecdsa.PrivateKey,
	token string,
	amount float64,
	validatorAddress string,
	timestamp int64,
	isMainnet bool,
) (string, error)

SignTokenDelegateAction signs token delegate action

func SignUsdClassTransferAction added in v0.4.0

func SignUsdClassTransferAction(
	privateKey *ecdsa.PrivateKey,
	amount float64,
	toPerp bool,
	timestamp int64,
	isMainnet bool,
) (string, error)

SignUsdClassTransferAction signs USD class transfer action

func SignUsdTransferAction added in v0.4.0

func SignUsdTransferAction(
	privateKey *ecdsa.PrivateKey,
	amount float64,
	destination string,
	timestamp int64,
	isMainnet bool,
) (string, error)

SignUsdTransferAction signs USD transfer action

func SignWithdrawFromBridgeAction added in v0.4.0

func SignWithdrawFromBridgeAction(
	privateKey *ecdsa.PrivateKey,
	destination string,
	amount, fee float64,
	timestamp int64,
	isMainnet bool,
) (string, error)

SignWithdrawFromBridgeAction signs withdraw from bridge action

Types

type APIError

type APIError struct {
	Code    int    `json:"code"`
	Message string `json:"msg"`
	Data    any    `json:"data,omitempty"`
}

func (APIError) Error

func (e APIError) Error() string

type AssetInfo

type AssetInfo struct {
	Name       string `json:"name"`
	SzDecimals int    `json:"szDecimals"`
}

func (AssetInfo) MarshalEasyJSON added in v0.2.0

func (v AssetInfo) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (AssetInfo) MarshalJSON added in v0.2.0

func (v AssetInfo) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*AssetInfo) UnmarshalEasyJSON added in v0.2.0

func (v *AssetInfo) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*AssetInfo) UnmarshalJSON added in v0.2.0

func (v *AssetInfo) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type AssetPosition

type AssetPosition struct {
	Position Position `json:"position"`
	Type     string   `json:"type"`
}

func (AssetPosition) MarshalEasyJSON added in v0.2.0

func (v AssetPosition) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (AssetPosition) MarshalJSON added in v0.2.0

func (v AssetPosition) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*AssetPosition) UnmarshalEasyJSON added in v0.2.0

func (v *AssetPosition) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*AssetPosition) UnmarshalJSON added in v0.2.0

func (v *AssetPosition) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type BuilderInfo

type BuilderInfo struct {
	Builder string `json:"b"`
	Fee     int    `json:"f"`
}

func (BuilderInfo) MarshalEasyJSON added in v0.2.0

func (v BuilderInfo) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (BuilderInfo) MarshalJSON added in v0.2.0

func (v BuilderInfo) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*BuilderInfo) UnmarshalEasyJSON added in v0.2.0

func (v *BuilderInfo) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*BuilderInfo) UnmarshalJSON added in v0.2.0

func (v *BuilderInfo) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type CancelByCloidRequest added in v0.4.0

type CancelByCloidRequest struct {
	Coin  string `json:"coin"`
	Cloid string `json:"cloid"`
}

func (CancelByCloidRequest) MarshalEasyJSON added in v0.4.0

func (v CancelByCloidRequest) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (CancelByCloidRequest) MarshalJSON added in v0.4.0

func (v CancelByCloidRequest) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*CancelByCloidRequest) UnmarshalEasyJSON added in v0.4.0

func (v *CancelByCloidRequest) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*CancelByCloidRequest) UnmarshalJSON added in v0.4.0

func (v *CancelByCloidRequest) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type CancelRequest added in v0.4.0

type CancelRequest struct {
	Coin string `json:"coin"`
	Oid  int64  `json:"oid"`
}

func (CancelRequest) MarshalEasyJSON added in v0.4.0

func (v CancelRequest) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (CancelRequest) MarshalJSON added in v0.4.0

func (v CancelRequest) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*CancelRequest) UnmarshalEasyJSON added in v0.4.0

func (v *CancelRequest) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*CancelRequest) UnmarshalJSON added in v0.4.0

func (v *CancelRequest) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type Candle

type Candle struct {
	Timestamp int64  `json:"T"`
	Close     string `json:"c"`
	High      string `json:"h"`
	Interval  string `json:"i"`
	Low       string `json:"l"`
	Number    int    `json:"n"`
	Open      string `json:"o"`
	Symbol    string `json:"s"`
	Time      int64  `json:"t"`
	Volume    string `json:"v"`
}

func (Candle) MarshalEasyJSON added in v0.2.0

func (v Candle) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (Candle) MarshalJSON added in v0.2.0

func (v Candle) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*Candle) UnmarshalEasyJSON added in v0.2.0

func (v *Candle) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*Candle) UnmarshalJSON added in v0.2.0

func (v *Candle) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type Client

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

func NewClient

func NewClient(baseURL string) *Client

type Cloid added in v0.4.0

type Cloid struct {
	Value string
}

func (Cloid) MarshalEasyJSON added in v0.4.0

func (v Cloid) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (Cloid) MarshalJSON added in v0.4.0

func (v Cloid) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (Cloid) ToRaw added in v0.4.0

func (c Cloid) ToRaw() string

func (*Cloid) UnmarshalEasyJSON added in v0.4.0

func (v *Cloid) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*Cloid) UnmarshalJSON added in v0.4.0

func (v *Cloid) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type EvmContract added in v0.2.0

type EvmContract struct {
	Address             string `json:"address"`
	EvmExtraWeiDecimals int    `json:"evm_extra_wei_decimals"`
}

func (EvmContract) MarshalEasyJSON added in v0.2.0

func (v EvmContract) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (EvmContract) MarshalJSON added in v0.2.0

func (v EvmContract) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*EvmContract) UnmarshalEasyJSON added in v0.2.0

func (v *EvmContract) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*EvmContract) UnmarshalJSON added in v0.2.0

func (v *EvmContract) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type Exchange

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

func NewExchange

func NewExchange(
	privateKey *ecdsa.PrivateKey,
	baseURL string,
	meta *Meta,
	vaultAddr, accountAddr string,
	spotMeta *SpotMeta,
) *Exchange

func (*Exchange) ApproveAgent added in v0.4.0

func (e *Exchange) ApproveAgent(name *string) (any, string, error)

ApproveAgent approves an agent to trade on behalf of the user Returns the result and the generated agent private key

func (*Exchange) ApproveBuilderFee added in v0.4.0

func (e *Exchange) ApproveBuilderFee(builder string, maxFeeRate string) (any, error)

ApproveBuilderFee approves builder fee payment

func (*Exchange) BulkCancel added in v0.4.0

func (e *Exchange) BulkCancel(cancelRequests []CancelRequest) (any, error)

BulkCancel cancels multiple orders

func (*Exchange) BulkCancelByCloid added in v0.4.0

func (e *Exchange) BulkCancelByCloid(cancelRequests []CancelByCloidRequest) (any, error)

BulkCancelByCloid cancels multiple orders by cloid

func (*Exchange) BulkModifyOrders added in v0.4.0

func (e *Exchange) BulkModifyOrders(modifyRequests []ModifyRequest) (any, error)

BulkModifyOrders modifies multiple orders

func (*Exchange) BulkModifyOrdersNew added in v0.4.0

func (e *Exchange) BulkModifyOrdersNew(modifyRequests []ModifyRequest) (any, error)

BulkModifyOrdersNew is an alias for BulkModifyOrders to match Python SDK naming

func (*Exchange) BulkOrders

func (e *Exchange) BulkOrders(orders []OrderRequest, builder *BuilderInfo) ([]OpenOrder, error)

func (*Exchange) CSignerInner added in v0.4.0

func (e *Exchange) CSignerInner(innerAction map[string]any) (any, error)

CSignerInner executes inner consensus signer action

func (*Exchange) CSignerJailSelf added in v0.4.0

func (e *Exchange) CSignerJailSelf() (any, error)

CSignerJailSelf jails self as consensus signer

func (*Exchange) CSignerUnjailSelf added in v0.4.0

func (e *Exchange) CSignerUnjailSelf() (any, error)

CSignerUnjailSelf unjails self as consensus signer

func (*Exchange) CValidatorChangeProfile added in v0.4.0

func (e *Exchange) CValidatorChangeProfile(newProfile map[string]any) (any, error)

CValidatorChangeProfile changes validator profile

func (*Exchange) CValidatorRegister added in v0.4.0

func (e *Exchange) CValidatorRegister(validatorProfile map[string]any) (any, error)

CValidatorRegister registers as consensus validator

func (*Exchange) CValidatorUnregister added in v0.4.0

func (e *Exchange) CValidatorUnregister() (any, error)

CValidatorUnregister unregisters as consensus validator

func (*Exchange) Cancel

func (e *Exchange) Cancel(coin string, oid int64) (*OpenOrder, error)

func (*Exchange) CancelByCloid

func (e *Exchange) CancelByCloid(coin, cloid string) (*OpenOrder, error)

func (*Exchange) ConvertToMultiSigUser added in v0.4.0

func (e *Exchange) ConvertToMultiSigUser(authorizedUsers []string, threshold int) (any, error)

ConvertToMultiSigUser converts account to multi-signature user

func (*Exchange) CreateSubAccount added in v0.4.0

func (e *Exchange) CreateSubAccount(name string) (any, error)

CreateSubAccount creates a new sub-account

func (*Exchange) MarketClose added in v0.4.0

func (e *Exchange) MarketClose(
	coin string,
	sz *float64,
	px *float64,
	slippage float64,
	cloid *string,
	builder *BuilderInfo,
) (any, error)

MarketClose closes a position

func (*Exchange) MarketOpen added in v0.4.0

func (e *Exchange) MarketOpen(
	name string,
	isBuy bool,
	sz float64,
	px *float64,
	slippage float64,
	cloid *string,
	builder *BuilderInfo,
) (any, error)

MarketOpen opens a market position

func (*Exchange) ModifyOrder added in v0.4.0

func (e *Exchange) ModifyOrder(
	oid any,
	name string,
	isBuy bool,
	sz, limitPx float64,
	orderType OrderType,
	reduceOnly bool,
	cloid *string,
) (any, error)

ModifyOrder modifies an existing order

func (*Exchange) MultiSig added in v0.4.0

func (e *Exchange) MultiSig(
	action map[string]any,
	signers []string,
	signatures []string,
) (any, error)

MultiSig executes multi-signature action

func (*Exchange) Order

func (e *Exchange) Order(req OrderRequest, builder *BuilderInfo) (*OpenOrder, error)

func (*Exchange) PerpDeployRegisterAsset added in v0.4.0

func (e *Exchange) PerpDeployRegisterAsset(
	asset string,
	perpDexInput PerpDexSchemaInput,
) (any, error)

PerpDeployRegisterAsset registers a new perpetual asset

func (*Exchange) PerpDeploySetOracle added in v0.4.0

func (e *Exchange) PerpDeploySetOracle(asset string, oracleAddress string) (any, error)

PerpDeploySetOracle sets oracle for perpetual asset

func (*Exchange) PerpDexClassTransfer added in v0.4.0

func (e *Exchange) PerpDexClassTransfer(
	dex, token string,
	amount float64,
	toPerp bool,
) (any, error)

PerpDexClassTransfer transfers tokens between perp dex classes

func (*Exchange) ScheduleCancel added in v0.4.0

func (e *Exchange) ScheduleCancel(scheduleTime *int64) (any, error)

ScheduleCancel schedules cancellation of all open orders

func (*Exchange) SetExpiresAfter added in v0.4.0

func (e *Exchange) SetExpiresAfter(expiresAfter *int64)

SetExpiresAfter sets the expiration time for actions

func (*Exchange) SetReferrer added in v0.4.0

func (e *Exchange) SetReferrer(code string) (any, error)

SetReferrer sets a referral code

func (*Exchange) SlippagePrice added in v0.4.0

func (e *Exchange) SlippagePrice(
	name string,
	isBuy bool,
	slippage float64,
	px *float64,
) (float64, error)

SlippagePrice calculates the slippage price for market orders

func (*Exchange) SpotDeployEnableFreezePrivilege added in v0.4.0

func (e *Exchange) SpotDeployEnableFreezePrivilege() (any, error)

SpotDeployEnableFreezePrivilege enables freeze privilege for spot deployer

func (*Exchange) SpotDeployFreezeUser added in v0.4.0

func (e *Exchange) SpotDeployFreezeUser(userAddress string) (any, error)

SpotDeployFreezeUser freezes a user in spot trading

func (*Exchange) SpotDeployGenesis added in v0.4.0

func (e *Exchange) SpotDeployGenesis(deployer string, dexName string) (any, error)

SpotDeployGenesis initializes spot genesis

func (*Exchange) SpotDeployRegisterHyperliquidity added in v0.4.0

func (e *Exchange) SpotDeployRegisterHyperliquidity(name string, tokens []string) (any, error)

SpotDeployRegisterHyperliquidity registers hyperliquidity spot

func (*Exchange) SpotDeployRegisterSpot added in v0.4.0

func (e *Exchange) SpotDeployRegisterSpot(baseToken string, quoteToken string) (any, error)

SpotDeployRegisterSpot registers spot market

func (*Exchange) SpotDeployRegisterToken added in v0.4.0

func (e *Exchange) SpotDeployRegisterToken(
	tokenName string,
	szDecimals int,
	weiDecimals int,
	maxGas int,
	fullName string,
) (any, error)

SpotDeployRegisterToken registers a new spot token

func (*Exchange) SpotDeployRevokeFreezePrivilege added in v0.4.0

func (e *Exchange) SpotDeployRevokeFreezePrivilege() (any, error)

SpotDeployRevokeFreezePrivilege revokes freeze privilege for spot deployer

func (*Exchange) SpotDeploySetDeployerTradingFeeShare added in v0.4.0

func (e *Exchange) SpotDeploySetDeployerTradingFeeShare(feeShare float64) (any, error)

SpotDeploySetDeployerTradingFeeShare sets deployer trading fee share

func (*Exchange) SpotDeployUserGenesis added in v0.4.0

func (e *Exchange) SpotDeployUserGenesis(balances map[string]float64) (any, error)

SpotDeployUserGenesis initializes user genesis for spot trading

func (*Exchange) SpotTransfer added in v0.4.0

func (e *Exchange) SpotTransfer(amount float64, destination, token string) (any, error)

SpotTransfer transfers spot tokens to another address

func (*Exchange) SubAccountSpotTransfer added in v0.4.0

func (e *Exchange) SubAccountSpotTransfer(
	subAccountUser string,
	isDeposit bool,
	token string,
	amount float64,
) (any, error)

SubAccountSpotTransfer transfers spot tokens to/from sub-account

func (*Exchange) SubAccountTransfer added in v0.4.0

func (e *Exchange) SubAccountTransfer(subAccountUser string, isDeposit bool, usd int) (any, error)

SubAccountTransfer transfers funds to/from sub-account

func (*Exchange) TokenDelegate added in v0.4.0

func (e *Exchange) TokenDelegate(validator string, wei int, isUndelegate bool) (any, error)

TokenDelegate delegates tokens for staking

func (*Exchange) UpdateIsolatedMargin

func (e *Exchange) UpdateIsolatedMargin(amount float64, name string) (*UserState, error)

func (*Exchange) UpdateLeverage

func (e *Exchange) UpdateLeverage(leverage int, name string, isCross bool) (*UserState, error)

func (*Exchange) UsdClassTransfer added in v0.4.0

func (e *Exchange) UsdClassTransfer(amount float64, toPerp bool) (any, error)

UsdClassTransfer transfers between USD classes

func (*Exchange) UsdTransfer added in v0.4.0

func (e *Exchange) UsdTransfer(amount float64, destination string) (any, error)

UsdTransfer transfers USD to another address

func (*Exchange) UseBigBlocks added in v0.4.0

func (e *Exchange) UseBigBlocks(enable bool) (any, error)

UseBigBlocks enables or disables big blocks

func (*Exchange) VaultUsdTransfer added in v0.4.0

func (e *Exchange) VaultUsdTransfer(vaultAddress string, isDeposit bool, usd int) (any, error)

VaultUsdTransfer transfers to/from vault

func (*Exchange) WithdrawFromBridge added in v0.4.0

func (e *Exchange) WithdrawFromBridge(amount float64, destination string) (any, error)

WithdrawFromBridge withdraws tokens from bridge

type FeeSchedule

type FeeSchedule struct {
	Add              string `json:"add"`
	Cross            string `json:"cross"`
	ReferralDiscount string `json:"referralDiscount"`
	Tiers            Tiers  `json:"tiers"`
}

func (FeeSchedule) MarshalEasyJSON added in v0.2.0

func (v FeeSchedule) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (FeeSchedule) MarshalJSON added in v0.2.0

func (v FeeSchedule) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*FeeSchedule) UnmarshalEasyJSON added in v0.2.0

func (v *FeeSchedule) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*FeeSchedule) UnmarshalJSON added in v0.2.0

func (v *FeeSchedule) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type Fill

type Fill struct {
	ClosedPnl     string `json:"closedPnl"`
	Coin          string `json:"coin"`
	Crossed       bool   `json:"crossed"`
	Dir           string `json:"dir"`
	Hash          string `json:"hash"`
	Oid           int64  `json:"oid"`
	Price         string `json:"px"`
	Side          string `json:"side"`
	StartPosition string `json:"startPosition"`
	Size          string `json:"sz"`
	Time          int64  `json:"time"`
}

func (Fill) MarshalEasyJSON added in v0.2.0

func (v Fill) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (Fill) MarshalJSON added in v0.2.0

func (v Fill) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*Fill) UnmarshalEasyJSON added in v0.2.0

func (v *Fill) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*Fill) UnmarshalJSON added in v0.2.0

func (v *Fill) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type FundingHistory

type FundingHistory struct {
	Coin        string `json:"coin"`
	FundingRate string `json:"fundingRate"`
	Premium     string `json:"premium"`
	Time        int64  `json:"time"`
}

func (FundingHistory) MarshalEasyJSON added in v0.2.0

func (v FundingHistory) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (FundingHistory) MarshalJSON added in v0.2.0

func (v FundingHistory) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*FundingHistory) UnmarshalEasyJSON added in v0.2.0

func (v *FundingHistory) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*FundingHistory) UnmarshalJSON added in v0.2.0

func (v *FundingHistory) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type Info

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

func NewInfo

func NewInfo(baseURL string, skipWS bool, meta *Meta, spotMeta *SpotMeta) *Info

func (*Info) AllMids

func (i *Info) AllMids() (map[string]string, error)

func (*Info) CandlesSnapshot

func (i *Info) CandlesSnapshot(name, interval string, startTime, endTime int64) ([]Candle, error)

func (*Info) FrontendOpenOrders

func (i *Info) FrontendOpenOrders(address string) ([]OpenOrder, error)

func (*Info) FundingHistory

func (i *Info) FundingHistory(
	name string,
	startTime int64,
	endTime *int64,
) ([]FundingHistory, error)

func (*Info) L2Snapshot

func (i *Info) L2Snapshot(name string) (*L2Book, error)

func (*Info) Meta

func (i *Info) Meta() (*Meta, error)

func (*Info) MetaAndAssetCtxs

func (i *Info) MetaAndAssetCtxs() (map[string]any, error)

func (*Info) NameToAsset

func (i *Info) NameToAsset(name string) int

func (*Info) OpenOrders

func (i *Info) OpenOrders(address string) ([]OpenOrder, error)

func (*Info) PerpDexs added in v0.4.0

func (i *Info) PerpDexs() ([]string, error)

PerpDexs returns the list of available perpetual dexes

func (*Info) QueryOrderByCloid

func (i *Info) QueryOrderByCloid(user, cloid string) (*OpenOrder, error)

func (*Info) QueryOrderByOid

func (i *Info) QueryOrderByOid(user string, oid int64) (*OpenOrder, error)

func (*Info) QueryReferralState

func (i *Info) QueryReferralState(user string) (*ReferralState, error)

func (*Info) QuerySubAccounts

func (i *Info) QuerySubAccounts(user string) ([]SubAccount, error)

func (*Info) QueryUserToMultiSigSigners

func (i *Info) QueryUserToMultiSigSigners(multiSigUser string) ([]MultiSigSigner, error)

func (*Info) SpotMeta

func (i *Info) SpotMeta() (*SpotMeta, error)

func (*Info) SpotMetaAndAssetCtxs

func (i *Info) SpotMetaAndAssetCtxs() (map[string]any, error)

func (*Info) SpotUserState

func (i *Info) SpotUserState(address string) (*UserState, error)

func (*Info) UserFees

func (i *Info) UserFees(address string) (*UserFees, error)

func (*Info) UserFills

func (i *Info) UserFills(address string) ([]Fill, error)

func (*Info) UserFillsByTime

func (i *Info) UserFillsByTime(address string, startTime int64, endTime *int64) ([]Fill, error)

func (*Info) UserFundingHistory

func (i *Info) UserFundingHistory(
	user string,
	startTime int64,
	endTime *int64,
) ([]UserFundingHistory, error)

func (*Info) UserStakingDelegations

func (i *Info) UserStakingDelegations(address string) ([]StakingDelegation, error)

func (*Info) UserStakingRewards

func (i *Info) UserStakingRewards(address string) ([]StakingReward, error)

func (*Info) UserStakingSummary

func (i *Info) UserStakingSummary(address string) (*StakingSummary, error)

func (*Info) UserState

func (i *Info) UserState(address string) (*UserState, error)

type L2Book

type L2Book struct {
	Coin   string    `json:"coin"`
	Levels [][]Level `json:"levels"`
	Time   int64     `json:"time"`
}

func (L2Book) MarshalEasyJSON added in v0.2.0

func (v L2Book) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (L2Book) MarshalJSON added in v0.2.0

func (v L2Book) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*L2Book) UnmarshalEasyJSON added in v0.2.0

func (v *L2Book) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*L2Book) UnmarshalJSON added in v0.2.0

func (v *L2Book) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type Level

type Level struct {
	N  int     `json:"n"`
	Px float64 `json:"px,string"`
	Sz float64 `json:"sz,string"`
}

func (Level) MarshalEasyJSON added in v0.2.0

func (v Level) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (Level) MarshalJSON added in v0.2.0

func (v Level) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*Level) UnmarshalEasyJSON added in v0.2.0

func (v *Level) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*Level) UnmarshalJSON added in v0.2.0

func (v *Level) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type Leverage

type Leverage struct {
	Type   string  `json:"type"`
	Value  int     `json:"value"`
	RawUsd *string `json:"rawUsd,omitempty"`
}

func (Leverage) MarshalEasyJSON added in v0.2.0

func (v Leverage) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (Leverage) MarshalJSON added in v0.2.0

func (v Leverage) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*Leverage) UnmarshalEasyJSON added in v0.2.0

func (v *Leverage) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*Leverage) UnmarshalJSON added in v0.2.0

func (v *Leverage) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type LimitOrderType

type LimitOrderType struct {
	Tif string `json:"tif"` // "Alo", "Ioc", "Gtc"
}

func (LimitOrderType) MarshalEasyJSON added in v0.2.0

func (v LimitOrderType) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (LimitOrderType) MarshalJSON added in v0.2.0

func (v LimitOrderType) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*LimitOrderType) UnmarshalEasyJSON added in v0.2.0

func (v *LimitOrderType) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*LimitOrderType) UnmarshalJSON added in v0.2.0

func (v *LimitOrderType) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type MMTier

type MMTier struct {
	Add                 string `json:"add"`
	MakerFractionCutoff string `json:"makerFractionCutoff"`
}

func (MMTier) MarshalEasyJSON added in v0.2.0

func (v MMTier) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (MMTier) MarshalJSON added in v0.2.0

func (v MMTier) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*MMTier) UnmarshalEasyJSON added in v0.2.0

func (v *MMTier) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*MMTier) UnmarshalJSON added in v0.2.0

func (v *MMTier) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type MarginSummary

type MarginSummary struct {
	AccountValue    string `json:"accountValue"`
	TotalMarginUsed string `json:"totalMarginUsed"`
	TotalNtlPos     string `json:"totalNtlPos"`
	TotalRawUsd     string `json:"totalRawUsd"`
}

func (MarginSummary) MarshalEasyJSON added in v0.2.0

func (v MarginSummary) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (MarginSummary) MarshalJSON added in v0.2.0

func (v MarginSummary) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*MarginSummary) UnmarshalEasyJSON added in v0.2.0

func (v *MarginSummary) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*MarginSummary) UnmarshalJSON added in v0.2.0

func (v *MarginSummary) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type Meta

type Meta struct {
	Universe []AssetInfo `json:"universe"`
}

func (Meta) MarshalEasyJSON added in v0.2.0

func (v Meta) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (Meta) MarshalJSON added in v0.2.0

func (v Meta) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*Meta) UnmarshalEasyJSON added in v0.2.0

func (v *Meta) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*Meta) UnmarshalJSON added in v0.2.0

func (v *Meta) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type ModifyRequest added in v0.4.0

type ModifyRequest struct {
	Oid   any          `json:"oid"` // can be int64 or Cloid
	Order OrderRequest `json:"order"`
}

func (ModifyRequest) MarshalEasyJSON added in v0.4.0

func (v ModifyRequest) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (ModifyRequest) MarshalJSON added in v0.4.0

func (v ModifyRequest) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*ModifyRequest) UnmarshalEasyJSON added in v0.4.0

func (v *ModifyRequest) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*ModifyRequest) UnmarshalJSON added in v0.4.0

func (v *ModifyRequest) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type MultiSigSigner

type MultiSigSigner struct {
	User      string `json:"user"`
	Threshold int    `json:"threshold"`
}

func (MultiSigSigner) MarshalEasyJSON added in v0.2.0

func (v MultiSigSigner) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (MultiSigSigner) MarshalJSON added in v0.2.0

func (v MultiSigSigner) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*MultiSigSigner) UnmarshalEasyJSON added in v0.2.0

func (v *MultiSigSigner) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*MultiSigSigner) UnmarshalJSON added in v0.2.0

func (v *MultiSigSigner) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type OpenOrder

type OpenOrder struct {
	Coin      string  `json:"coin"`
	LimitPx   float64 `json:"limitPx,string"`
	Oid       int64   `json:"oid"`
	Side      string  `json:"side"`
	Size      float64 `json:"sz,string"`
	Timestamp int64   `json:"timestamp"`
}

func (OpenOrder) MarshalEasyJSON added in v0.2.0

func (v OpenOrder) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (OpenOrder) MarshalJSON added in v0.2.0

func (v OpenOrder) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*OpenOrder) UnmarshalEasyJSON added in v0.2.0

func (v *OpenOrder) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*OpenOrder) UnmarshalJSON added in v0.2.0

func (v *OpenOrder) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type OrderRequest

type OrderRequest struct {
	Coin       string    `json:"coin"`
	IsBuy      bool      `json:"is_buy"`
	Size       float64   `json:"sz"`
	LimitPx    float64   `json:"limit_px"`
	OrderType  OrderType `json:"order_type"`
	ReduceOnly bool      `json:"reduce_only"`
	Cloid      *string   `json:"cloid,omitempty"`
}

func (OrderRequest) MarshalEasyJSON added in v0.2.0

func (v OrderRequest) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (OrderRequest) MarshalJSON added in v0.2.0

func (v OrderRequest) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*OrderRequest) UnmarshalEasyJSON added in v0.2.0

func (v *OrderRequest) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*OrderRequest) UnmarshalJSON added in v0.2.0

func (v *OrderRequest) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type OrderStatus added in v0.4.0

type OrderStatus struct {
	Order  *OpenOrder `json:"order"`
	Status string     `json:"status"`
}

func (OrderStatus) MarshalEasyJSON added in v0.4.0

func (v OrderStatus) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (OrderStatus) MarshalJSON added in v0.4.0

func (v OrderStatus) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*OrderStatus) UnmarshalEasyJSON added in v0.4.0

func (v *OrderStatus) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*OrderStatus) UnmarshalJSON added in v0.4.0

func (v *OrderStatus) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type OrderType

type OrderType struct {
	Limit   *LimitOrderType   `json:"limit,omitempty"`
	Trigger *TriggerOrderType `json:"trigger,omitempty"`
}

func (OrderType) MarshalEasyJSON added in v0.2.0

func (v OrderType) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (OrderType) MarshalJSON added in v0.2.0

func (v OrderType) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*OrderType) UnmarshalEasyJSON added in v0.2.0

func (v *OrderType) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*OrderType) UnmarshalJSON added in v0.2.0

func (v *OrderType) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type OrderWire

type OrderWire struct {
	Asset      int     `json:"a"`
	IsBuy      bool    `json:"b"`
	OrderType  string  `json:"t,omitempty"`
	LimitPx    float64 `json:"p"`
	Size       float64 `json:"s"`
	ReduceOnly bool    `json:"r"`
	TriggerPx  float64 `json:"tp,omitempty"`
	IsMarket   bool    `json:"im,omitempty"`
	Tpsl       string  `json:"tpsl,omitempty"`
	Tif        string  `json:"tif,omitempty"`
	Cloid      string  `json:"c,omitempty"`
}

func OrderRequestToWire

func OrderRequestToWire(req OrderRequest, asset int) OrderWire

func (OrderWire) MarshalEasyJSON added in v0.2.0

func (v OrderWire) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (OrderWire) MarshalJSON added in v0.2.0

func (v OrderWire) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*OrderWire) UnmarshalEasyJSON added in v0.2.0

func (v *OrderWire) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*OrderWire) UnmarshalJSON added in v0.2.0

func (v *OrderWire) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type PerpDexSchemaInput added in v0.4.0

type PerpDexSchemaInput struct {
	FullName        string  `json:"fullName"`
	CollateralToken int     `json:"collateralToken"`
	OracleUpdater   *string `json:"oracleUpdater"`
}

func (PerpDexSchemaInput) MarshalEasyJSON added in v0.4.0

func (v PerpDexSchemaInput) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (PerpDexSchemaInput) MarshalJSON added in v0.4.0

func (v PerpDexSchemaInput) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*PerpDexSchemaInput) UnmarshalEasyJSON added in v0.4.0

func (v *PerpDexSchemaInput) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*PerpDexSchemaInput) UnmarshalJSON added in v0.4.0

func (v *PerpDexSchemaInput) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type Position

type Position struct {
	Coin           string   `json:"coin"`
	EntryPx        *string  `json:"entryPx"`
	Leverage       Leverage `json:"leverage"`
	LiquidationPx  *string  `json:"liquidationPx"`
	MarginUsed     string   `json:"marginUsed"`
	PositionValue  string   `json:"positionValue"`
	ReturnOnEquity string   `json:"returnOnEquity"`
	Szi            string   `json:"szi"`
	UnrealizedPnl  string   `json:"unrealizedPnl"`
}

func (Position) MarshalEasyJSON added in v0.2.0

func (v Position) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (Position) MarshalJSON added in v0.2.0

func (v Position) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*Position) UnmarshalEasyJSON added in v0.2.0

func (v *Position) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*Position) UnmarshalJSON added in v0.2.0

func (v *Position) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type ReferralState

type ReferralState struct {
	ReferralCode string   `json:"referralCode"`
	Referrer     string   `json:"referrer"`
	Referred     []string `json:"referred"`
}

func (ReferralState) MarshalEasyJSON added in v0.2.0

func (v ReferralState) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (ReferralState) MarshalJSON added in v0.2.0

func (v ReferralState) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*ReferralState) UnmarshalEasyJSON added in v0.2.0

func (v *ReferralState) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*ReferralState) UnmarshalJSON added in v0.2.0

func (v *ReferralState) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type ScheduleCancelAction added in v0.4.0

type ScheduleCancelAction struct {
	Type string `json:"type"`
	Time *int64 `json:"time,omitempty"`
}

func (ScheduleCancelAction) MarshalEasyJSON added in v0.4.0

func (v ScheduleCancelAction) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (ScheduleCancelAction) MarshalJSON added in v0.4.0

func (v ScheduleCancelAction) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*ScheduleCancelAction) UnmarshalEasyJSON added in v0.4.0

func (v *ScheduleCancelAction) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*ScheduleCancelAction) UnmarshalJSON added in v0.4.0

func (v *ScheduleCancelAction) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type Side

type Side string
const (
	SideAsk Side = "A"
	SideBid Side = "B"
)

type SpotAssetCtx

type SpotAssetCtx struct {
	DayNtlVlm         string  `json:"dayNtlVlm"`
	MarkPx            string  `json:"markPx"`
	MidPx             *string `json:"midPx"`
	PrevDayPx         string  `json:"prevDayPx"`
	CirculatingSupply string  `json:"circulatingSupply"`
	Coin              string  `json:"coin"`
}

func (SpotAssetCtx) MarshalEasyJSON added in v0.2.0

func (v SpotAssetCtx) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (SpotAssetCtx) MarshalJSON added in v0.2.0

func (v SpotAssetCtx) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*SpotAssetCtx) UnmarshalEasyJSON added in v0.2.0

func (v *SpotAssetCtx) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*SpotAssetCtx) UnmarshalJSON added in v0.2.0

func (v *SpotAssetCtx) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type SpotAssetInfo

type SpotAssetInfo struct {
	Name        string `json:"name"`
	Tokens      []int  `json:"tokens"`
	Index       int    `json:"index"`
	IsCanonical bool   `json:"isCanonical"`
}

func (SpotAssetInfo) MarshalEasyJSON added in v0.2.0

func (v SpotAssetInfo) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (SpotAssetInfo) MarshalJSON added in v0.2.0

func (v SpotAssetInfo) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*SpotAssetInfo) UnmarshalEasyJSON added in v0.2.0

func (v *SpotAssetInfo) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*SpotAssetInfo) UnmarshalJSON added in v0.2.0

func (v *SpotAssetInfo) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type SpotMeta

type SpotMeta struct {
	Universe []SpotAssetInfo `json:"universe"`
	Tokens   []SpotTokenInfo `json:"tokens"`
}

func (SpotMeta) MarshalEasyJSON added in v0.2.0

func (v SpotMeta) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (SpotMeta) MarshalJSON added in v0.2.0

func (v SpotMeta) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*SpotMeta) UnmarshalEasyJSON added in v0.2.0

func (v *SpotMeta) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*SpotMeta) UnmarshalJSON added in v0.2.0

func (v *SpotMeta) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type SpotTokenInfo

type SpotTokenInfo struct {
	Name        string       `json:"name"`
	SzDecimals  int          `json:"szDecimals"`
	WeiDecimals int          `json:"weiDecimals"`
	Index       int          `json:"index"`
	TokenID     string       `json:"tokenId"`
	IsCanonical bool         `json:"isCanonical"`
	EvmContract *EvmContract `json:"evmContract"`
	FullName    *string      `json:"fullName"`
}

func (SpotTokenInfo) MarshalEasyJSON added in v0.2.0

func (v SpotTokenInfo) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (SpotTokenInfo) MarshalJSON added in v0.2.0

func (v SpotTokenInfo) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*SpotTokenInfo) UnmarshalEasyJSON added in v0.2.0

func (v *SpotTokenInfo) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*SpotTokenInfo) UnmarshalJSON added in v0.2.0

func (v *SpotTokenInfo) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type StakingDelegation

type StakingDelegation struct {
	Validator            string `json:"validator"`
	Amount               string `json:"amount"`
	LockedUntilTimestamp int64  `json:"lockedUntilTimestamp"`
}

func (StakingDelegation) MarshalEasyJSON added in v0.2.0

func (v StakingDelegation) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (StakingDelegation) MarshalJSON added in v0.2.0

func (v StakingDelegation) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*StakingDelegation) UnmarshalEasyJSON added in v0.2.0

func (v *StakingDelegation) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*StakingDelegation) UnmarshalJSON added in v0.2.0

func (v *StakingDelegation) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type StakingReward

type StakingReward struct {
	Time        int64  `json:"time"`
	Source      string `json:"source"`
	TotalAmount string `json:"totalAmount"`
}

func (StakingReward) MarshalEasyJSON added in v0.2.0

func (v StakingReward) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (StakingReward) MarshalJSON added in v0.2.0

func (v StakingReward) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*StakingReward) UnmarshalEasyJSON added in v0.2.0

func (v *StakingReward) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*StakingReward) UnmarshalJSON added in v0.2.0

func (v *StakingReward) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type StakingSummary

type StakingSummary struct {
	Delegated              string `json:"delegated"`
	Undelegated            string `json:"undelegated"`
	TotalPendingWithdrawal string `json:"totalPendingWithdrawal"`
	NPendingWithdrawals    int    `json:"nPendingWithdrawals"`
}

func (StakingSummary) MarshalEasyJSON added in v0.2.0

func (v StakingSummary) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (StakingSummary) MarshalJSON added in v0.2.0

func (v StakingSummary) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*StakingSummary) UnmarshalEasyJSON added in v0.2.0

func (v *StakingSummary) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*StakingSummary) UnmarshalJSON added in v0.2.0

func (v *StakingSummary) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type SubAccount

type SubAccount struct {
	Name        string   `json:"name"`
	User        string   `json:"user"`
	Permissions []string `json:"permissions"`
}

func (SubAccount) MarshalEasyJSON added in v0.2.0

func (v SubAccount) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (SubAccount) MarshalJSON added in v0.2.0

func (v SubAccount) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*SubAccount) UnmarshalEasyJSON added in v0.2.0

func (v *SubAccount) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*SubAccount) UnmarshalJSON added in v0.2.0

func (v *SubAccount) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type Subscription

type Subscription struct {
	Type     string `json:"type"`
	Coin     string `json:"coin,omitempty"`
	User     string `json:"user,omitempty"`
	Interval string `json:"interval,omitempty"`
}

func (Subscription) MarshalEasyJSON added in v0.2.0

func (v Subscription) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (Subscription) MarshalJSON added in v0.2.0

func (v Subscription) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*Subscription) UnmarshalEasyJSON added in v0.2.0

func (v *Subscription) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*Subscription) UnmarshalJSON added in v0.2.0

func (v *Subscription) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type Tiers

type Tiers struct {
	MM  []MMTier  `json:"mm"`
	VIP []VIPTier `json:"vip"`
}

func (Tiers) MarshalEasyJSON added in v0.2.0

func (v Tiers) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (Tiers) MarshalJSON added in v0.2.0

func (v Tiers) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*Tiers) UnmarshalEasyJSON added in v0.2.0

func (v *Tiers) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*Tiers) UnmarshalJSON added in v0.2.0

func (v *Tiers) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type Trade

type Trade struct {
	Coin  string   `json:"coin"`
	Side  string   `json:"side"`
	Px    string   `json:"px"`
	Sz    string   `json:"sz"`
	Time  int64    `json:"time"`
	Hash  string   `json:"hash"`
	Tid   int64    `json:"tid"`
	Users []string `json:"users"`
}

func (Trade) MarshalEasyJSON added in v0.2.0

func (v Trade) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (Trade) MarshalJSON added in v0.2.0

func (v Trade) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*Trade) UnmarshalEasyJSON added in v0.2.0

func (v *Trade) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*Trade) UnmarshalJSON added in v0.2.0

func (v *Trade) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type TriggerOrderType

type TriggerOrderType struct {
	TriggerPx float64 `json:"triggerPx"`
	IsMarket  bool    `json:"isMarket"`
	Tpsl      string  `json:"tpsl"` // "tp" or "sl"
}

func (TriggerOrderType) MarshalEasyJSON added in v0.2.0

func (v TriggerOrderType) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (TriggerOrderType) MarshalJSON added in v0.2.0

func (v TriggerOrderType) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*TriggerOrderType) UnmarshalEasyJSON added in v0.2.0

func (v *TriggerOrderType) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*TriggerOrderType) UnmarshalJSON added in v0.2.0

func (v *TriggerOrderType) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type UserFees

type UserFees struct {
	ActiveReferralDiscount string       `json:"activeReferralDiscount"`
	DailyUserVolume        []UserVolume `json:"dailyUserVlm"`
	FeeSchedule            FeeSchedule  `json:"feeSchedule"`
	UserAddRate            string       `json:"userAddRate"`
	UserCrossRate          string       `json:"userCrossRate"`
}

func (UserFees) MarshalEasyJSON added in v0.2.0

func (v UserFees) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (UserFees) MarshalJSON added in v0.2.0

func (v UserFees) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*UserFees) UnmarshalEasyJSON added in v0.2.0

func (v *UserFees) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*UserFees) UnmarshalJSON added in v0.2.0

func (v *UserFees) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type UserFundingHistory

type UserFundingHistory struct {
	User      string `json:"user"`
	Type      string `json:"type"`
	StartTime int64  `json:"startTime"`
	EndTime   int64  `json:"endTime"`
}

func (UserFundingHistory) MarshalEasyJSON added in v0.2.0

func (v UserFundingHistory) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (UserFundingHistory) MarshalJSON added in v0.2.0

func (v UserFundingHistory) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*UserFundingHistory) UnmarshalEasyJSON added in v0.2.0

func (v *UserFundingHistory) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*UserFundingHistory) UnmarshalJSON added in v0.2.0

func (v *UserFundingHistory) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type UserState

type UserState struct {
	AssetPositions     []AssetPosition `json:"assetPositions"`
	CrossMarginSummary MarginSummary   `json:"crossMarginSummary"`
	MarginSummary      MarginSummary   `json:"marginSummary"`
	Withdrawable       string          `json:"withdrawable"`
}

func (UserState) MarshalEasyJSON added in v0.2.0

func (v UserState) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (UserState) MarshalJSON added in v0.2.0

func (v UserState) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*UserState) UnmarshalEasyJSON added in v0.2.0

func (v *UserState) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*UserState) UnmarshalJSON added in v0.2.0

func (v *UserState) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type UserVolume

type UserVolume struct {
	Date      string `json:"date"`
	Exchange  string `json:"exchange"`
	UserAdd   string `json:"userAdd"`
	UserCross string `json:"userCross"`
}

func (UserVolume) MarshalEasyJSON added in v0.2.0

func (v UserVolume) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (UserVolume) MarshalJSON added in v0.2.0

func (v UserVolume) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*UserVolume) UnmarshalEasyJSON added in v0.2.0

func (v *UserVolume) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*UserVolume) UnmarshalJSON added in v0.2.0

func (v *UserVolume) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type VIPTier

type VIPTier struct {
	Add       string `json:"add"`
	Cross     string `json:"cross"`
	NtlCutoff string `json:"ntlCutoff"`
}

func (VIPTier) MarshalEasyJSON added in v0.2.0

func (v VIPTier) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (VIPTier) MarshalJSON added in v0.2.0

func (v VIPTier) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*VIPTier) UnmarshalEasyJSON added in v0.2.0

func (v *VIPTier) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*VIPTier) UnmarshalJSON added in v0.2.0

func (v *VIPTier) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type ValidationError

type ValidationError struct {
	Field   string
	Message string
}

func (ValidationError) Error

func (e ValidationError) Error() string

type WSMessage

type WSMessage struct {
	Channel string          `json:"channel"`
	Data    json.RawMessage `json:"data"`
}

func (WSMessage) MarshalEasyJSON added in v0.2.0

func (v WSMessage) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (WSMessage) MarshalJSON added in v0.2.0

func (v WSMessage) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*WSMessage) UnmarshalEasyJSON added in v0.2.0

func (v *WSMessage) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*WSMessage) UnmarshalJSON added in v0.2.0

func (v *WSMessage) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type WebsocketClient

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

func NewWebsocketClient

func NewWebsocketClient(baseURL string) *WebsocketClient

func (*WebsocketClient) Close

func (w *WebsocketClient) Close() error

func (*WebsocketClient) Connect

func (w *WebsocketClient) Connect(ctx context.Context) error

func (*WebsocketClient) Subscribe

func (w *WebsocketClient) Subscribe(sub Subscription, callback func(WSMessage)) (int, error)

func (*WebsocketClient) SubscribeToActiveAssetCtx added in v0.4.0

func (w *WebsocketClient) SubscribeToActiveAssetCtx(
	coin string,
	callback func(WSMessage),
) (int, error)

SubscribeToActiveAssetCtx subscribes to active asset context

func (*WebsocketClient) SubscribeToAllMids added in v0.4.0

func (w *WebsocketClient) SubscribeToAllMids(callback func(WSMessage)) (int, error)

SubscribeToAllMids subscribes to all mid prices

func (*WebsocketClient) SubscribeToBBO added in v0.4.0

func (w *WebsocketClient) SubscribeToBBO(coin string, callback func(WSMessage)) (int, error)

SubscribeToBBO subscribes to best bid/offer data

func (*WebsocketClient) SubscribeToCandles added in v0.4.0

func (w *WebsocketClient) SubscribeToCandles(
	coin, interval string,
	callback func(WSMessage),
) (int, error)

SubscribeToCandles subscribes to candle data

func (*WebsocketClient) SubscribeToOrderUpdates added in v0.4.0

func (w *WebsocketClient) SubscribeToOrderUpdates(callback func(WSMessage)) (int, error)

SubscribeToOrderUpdates subscribes to order updates

func (*WebsocketClient) SubscribeToOrderbook

func (w *WebsocketClient) SubscribeToOrderbook(coin string, callback func(WSMessage)) (int, error)

func (*WebsocketClient) SubscribeToTrades

func (w *WebsocketClient) SubscribeToTrades(coin string, callback func(WSMessage)) (int, error)

func (*WebsocketClient) SubscribeToUserEvents added in v0.4.0

func (w *WebsocketClient) SubscribeToUserEvents(
	user string,
	callback func(WSMessage),
) (int, error)

SubscribeToUserEvents subscribes to user events

func (*WebsocketClient) SubscribeToUserFills added in v0.4.0

func (w *WebsocketClient) SubscribeToUserFills(user string, callback func(WSMessage)) (int, error)

SubscribeToUserFills subscribes to user fills

func (*WebsocketClient) SubscribeToUserFundings added in v0.4.0

func (w *WebsocketClient) SubscribeToUserFundings(
	user string,
	callback func(WSMessage),
) (int, error)

SubscribeToUserFundings subscribes to user funding updates

func (*WebsocketClient) SubscribeToUserNonFundingLedgerUpdates added in v0.4.0

func (w *WebsocketClient) SubscribeToUserNonFundingLedgerUpdates(
	user string,
	callback func(WSMessage),
) (int, error)

SubscribeToUserNonFundingLedgerUpdates subscribes to user non-funding ledger updates

func (*WebsocketClient) SubscribeToWebData2 added in v0.4.0

func (w *WebsocketClient) SubscribeToWebData2(user string, callback func(WSMessage)) (int, error)

SubscribeToWebData2 subscribes to web data v2

func (*WebsocketClient) Unsubscribe

func (w *WebsocketClient) Unsubscribe(sub Subscription, id int) error

type WsCommand added in v0.1.2

type WsCommand struct {
	Method       string        `json:"method"`
	Subscription *Subscription `json:"subscription,omitempty"`
}

func (WsCommand) MarshalEasyJSON added in v0.2.0

func (v WsCommand) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (WsCommand) MarshalJSON added in v0.2.0

func (v WsCommand) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*WsCommand) UnmarshalEasyJSON added in v0.2.0

func (v *WsCommand) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*WsCommand) UnmarshalJSON added in v0.2.0

func (v *WsCommand) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type WsMsg

type WsMsg struct {
	Channel string         `json:"channel"`
	Data    map[string]any `json:"data"`
}

WsMsg represents a WebSocket message with a channel and data payload.

func (WsMsg) MarshalEasyJSON added in v0.2.0

func (v WsMsg) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (WsMsg) MarshalJSON added in v0.2.0

func (v WsMsg) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*WsMsg) UnmarshalEasyJSON added in v0.2.0

func (v *WsMsg) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*WsMsg) UnmarshalJSON added in v0.2.0

func (v *WsMsg) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

Jump to

Keyboard shortcuts

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