Help us shape the future of Go! Take the 2026 Go Developer Survey

lighter

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

README

go-lighter

Low-latency Go SDK for the Lighter exchange (zkLighter: a perpetuals DEX on its own zk-rollup with an on-chain order book and sequencer-side matching). Built for HFT / market-making desks; a sibling of go-okx, go-bybit and go-hyperliquid, consumed by the desk's trading core.

ci

Status

Milestone Status Verification
Signing & transactions (types 14, 15, 16, 17, 20, 28, 29) ✅ 19 vectors byte-identical to lighter-go v1.0.10
REST + WebSocket transports, rate-limit accounting ✅ unit tests, live frame shapes
perpetuals section: Trading / Account / MarketData / Stream ✅ contract tests on an in-process mock
Keyless live smoke (make smoke) ✅ mainnet, 2026-09-23
Live order path (examples/simple-trade) ⏳ run by the owner (real funds)
v2.0: TP/SL, TWAP, grouped orders, key pool, WS trading 📋 trigger types and grouped-order transactions already signed and vector-tested
v2.5: bridge, pools, account management, history, spot 📋

Dependencies

gorilla/websocket, json-iterator/go, shopspring/decimal, elliottech/poseidon_crypto (Poseidon2 + ECgFp5 Schnorr — the exact primitives of the official signer). Pure Go, builds with CGO_ENABLED=0. The official lighter-go is used only by the vector generator (scripts/gen-vectors, a separate module).

Structure

lighter        root: Client, Config, errors, logger, metrics, rate-limit events, TxTracker
types          Fixed / Precision, enums, requests, views (market, order, account, tx)
perpetuals     section "Perpetuals": Trading() Account() MarketData() Stream()
internal/      signing, tx, nonce, ratelimit, rest, ws, markets, orderbook, engine, domain
examples/      market-data (keyless), simple-trade (gated: real funds)
docs/          ToR (RU / EN), API-NOTES.md (verified facts and discrepancies), DEPLOY.md

Two-layer architecture: every request is implemented once in the common layer (internal/domain + internal/engine), each section adds only its specifics (market_type filter, market registry). Sections never import each other.

Quick start

package main

import (
    "context"
    "os"

    lighter "github.com/tonymontanov/go-lighter"
    "github.com/tonymontanov/go-lighter/perpetuals"
    "github.com/tonymontanov/go-lighter/types"
)

func main() {
    var cfg lighter.Config = lighter.DefaultConfig()
    cfg.AccountIndex = 123          // your account (or sub-account) index
    cfg.APIKeyIndex = 3             // index of the API key below (2..254)
    cfg.PrivateKey = os.Getenv("LIGHTER_PERPETUALS_SECRET_KEY")

    client, err := lighter.NewClient(cfg)
    if err != nil {
        panic(err)
    }
    defer client.Close()
    var perps *perpetuals.Client = perpetuals.NewClient(client)
    var ctx context.Context = context.Background()

    // Post-only buy: prices and sizes are types.Fixed on the market's grid.
    receipt, err := perps.Trading().CreateOrder(ctx, types.CreateOrderRequest{
        Symbol:           "ETH",
        ClientOrderIndex: 1001,
        IsAsk:            false,
        Price:            types.MustParseFixed("2000.00"),
        Size:             types.MustParseFixed("0.0100"),
        Type:             types.OrderTypeLimit,
        TimeInForce:      types.TimeInForcePostOnly,
    }, types.SendOptions{})
    _ = receipt // accepted by the API server; the sequencer confirms later
    _ = err
}
Two confirmation levels

sendTx answers with a types.TxReceipt: the API server accepted the transaction (syntax and signature fine, nonce consumed). Execution happens in the sequencer and is reported on the account_tx stream as a types.TxOutcome. lighter.TxTracker correlates the two:

var tracker *lighter.TxTracker = lighter.NewTxTracker(4096)
_ = perps.Stream().WatchTransactions(ctx, tracker.Observe, nil, errHandler)
receipt, _ := perps.Trading().CreateOrder(ctx, req, types.SendOptions{})
outcome, _ := tracker.Await(ctx, receipt.TxHash)   // outcome.Executed() / outcome.Failed()
Nonces and keys

Nonces are tracked per API key. In the default sequential mode the SDK serialises the round trip per key (the strategy of the official SDKs) and rolls back / resynchronises on rejections; several keys (Config.ExtraKeys, SendOptions.APIKeyIndex) give independent nonce lanes. NonceModeSkip uses monotonic millisecond nonces with the SkipNonce attribute.

Streams
_ = perps.Stream().WatchOrderBook(ctx, "ETH", 20, func(b *types.OrderBook) {
    // full book after every applied delta; gaps trigger an automatic resubscribe
}, nil, errHandler)
_ = perps.Stream().WatchTicker(ctx, "ETH", func(t *types.Ticker) { /* best bid / ask */ }, errHandler)
_ = perps.Stream().WatchOrders(ctx, "", func(p *perpetuals.OrdersPush) { /* order updates */ }, nil, errHandler)
_ = perps.Stream().WatchAccountTrades(ctx, func(p *perpetuals.AccountTradesPush) { /* own executions: trade id, maker side, fees */ }, nil, errHandler)

Handlers run on the connection goroutine and receive reused values: copy what must outlive the call, never block.

Examples

make smoke                                   # keyless market data, mainnet
cp .env.example .env                         # fill in the credentials
LIGHTER_ALLOW_LIVE=1 ./scripts/run.sh ./examples/simple-trade   # REAL FUNDS

Development

make check      # gofmt, vet, race tests
make bench      # hot-path benchmarks (allocs/op must not grow)
make vectors    # regenerate signing vectors with lighter-go

Hot-path numbers on Apple M4 Pro: Poseidon2 transaction hash 3.3 µs / 0 allocs, tx_info JSON 120 ns / 0 allocs, sendTx form 430 ns / 0 allocs, order book delta 64 ns / 0 allocs; the Schnorr signature of the crypto library is ~200 µs / 69 allocs (an allocation-free scalar multiplication is a roadmap item).

Code style

English comments everywhere; file header FILE / DESCRIPTION / MAIN FUNCTIONS / DEPENDENCIES; explicit var x T = ... declarations; camelCase locals; kebab-case file names; zero allocations on hot paths; validation before network; no invented API fields (see docs/API-NOTES.md).

License

Apache 2.0 — see LICENSE.

Documentation

Overview

Package lighter is a low-latency Go SDK for the Lighter exchange (zkLighter: a perpetuals DEX on its own zk-rollup with an on-chain order book and sequencer-side matching).

Architecture

The SDK follows the two-layer principle shared by the sibling SDKs (go-okx, go-bybit, go-hyperliquid): ONE common layer implements every request, and each exchange section is a thin specialisation that contributes only its own specifics. Sections never import each other.

lighter (root)     public face of the common layer: Client, Config, errors,
                   logger, metrics, rate-limit events, TxTracker
types              layer-1 public types: Fixed, Precision, enums, requests,
                   market / order / account / transaction views
perpetuals         section "Perpetuals" (market_type "perp"):
                   Trading / Account / MarketData / Stream

Two confirmation levels

Every write is a signed L2 transaction sent with sendTx / sendTxBatch. The API server answers with a receipt (types.TxReceipt) that only means the transaction was accepted and forwarded; the sequencer executes it later and reports the outcome on the account_tx WebSocket channel (types.TxOutcome). TxTracker correlates the two.

Quick start

var cfg lighter.Config = lighter.DefaultConfig()
cfg.AccountIndex = 123
cfg.APIKeyIndex = 3
cfg.PrivateKey = os.Getenv("LIGHTER_PERPETUALS_SECRET_KEY")

client, err := lighter.NewClient(cfg)
perps := perpetuals.NewClient(client)
receipt, err := perps.Trading().CreateOrder(ctx, types.CreateOrderRequest{
	Symbol: "ETH", ClientOrderIndex: 1, IsAsk: false,
	Price: types.MustParseFixed("2000.00"), Size: types.MustParseFixed("0.01"),
	Type: types.OrderTypeLimit, TimeInForce: types.TimeInForcePostOnly,
}, types.SendOptions{})

Prices and sizes are types.Fixed (int64 with 8 decimals) and must lie on the market's grid (types.Precision, from orderBookDetails); the SDK never rounds silently.

Index

Constants

View Source
const (
	// MainnetChainID — 304.
	MainnetChainID uint32 = 304
	// TestnetChainID — 300.
	TestnetChainID uint32 = 300
)

Chain ids signed into every transaction.

View Source
const (
	CodeInvalidNonce           int = lterr.CodeInvalidNonce
	CodeNonIncreasingNonce     int = lterr.CodeNonIncreasingNonce
	CodeInvalidSignature       int = lterr.CodeInvalidSignature
	CodeAPIKeyNotFound         int = lterr.CodeAPIKeyNotFound
	CodeInactiveCancel         int = lterr.CodeInactiveCancel
	CodeInactiveOrder          int = lterr.CodeInactiveOrder
	CodeInvalidOrderIndex      int = lterr.CodeInvalidOrderIndex
	CodeClientOrderIndexExists int = lterr.CodeClientOrderIndexExists
	CodeNotEnoughOrderMargin   int = lterr.CodeNotEnoughOrderMargin
	CodeTooManyRequests        int = lterr.CodeTooManyRequests
)

Exchange error codes the SDK reacts to (see internal/lterr for the list).

View Source
const (
	RateLimitCategoryPlace  string = ratelimit.CategoryPlace
	RateLimitCategoryAmend  string = ratelimit.CategoryAmend
	RateLimitCategoryCancel string = ratelimit.CategoryCancel
	RateLimitCategoryQuery  string = ratelimit.CategoryQuery
	RateLimitCategoryMarket string = ratelimit.CategoryMarket
	RateLimitCategoryOther  string = ratelimit.CategoryOther
)

Rate-limit categories (RateLimitEvent.Category).

Variables

View Source
var (
	// MainnetRestURL — production REST base URL (scheme + host).
	MainnetRestURL string = "https://mainnet.zklighter.elliot.ai"
	// MainnetWsURL — production WebSocket URL.
	MainnetWsURL string = "wss://mainnet.zklighter.elliot.ai/stream"
	// TestnetRestURL — testnet REST base URL.
	TestnetRestURL string = "https://testnet.zklighter.elliot.ai"
	// TestnetWsURL — testnet WebSocket URL.
	TestnetWsURL string = "wss://testnet.zklighter.elliot.ai/stream"
)

Lighter endpoints. Declared as vars rather than const so tests can override them (e.g. to point at a mock server).

Functions

func CodeOf

func CodeOf(err error) int

CodeOf returns the exchange code of err, or 0.

func EndpointWeight

func EndpointWeight(endpoint string) int64

EndpointWeight returns the documented REST weight of an endpoint name (path without /api/v1/), 300 for unlisted endpoints.

func IsAuth

func IsAuth(err error) bool

IsAuth reports whether err is an authentication / key / signature error.

func IsCode

func IsCode(err error, code int) bool

IsCode reports whether err carries the given exchange code.

func IsExchange

func IsExchange(err error) bool

IsExchange reports whether err is a state-dependent exchange rejection.

func IsInvalidRequest

func IsInvalidRequest(err error) bool

IsInvalidRequest reports whether err is a request-validation error.

func IsMissingOrder

func IsMissingOrder(err error) bool

IsMissingOrder reports whether a cancel / modify failed because the order is not active any more or does not belong to the account.

func IsNetwork

func IsNetwork(err error) bool

IsNetwork reports whether err is a network-class error.

func IsNonceError

func IsNonceError(err error) bool

IsNonceError reports whether the API server rejected the nonce; the SDK has already scheduled a resynchronisation of the key's nonce.

func IsRateLimit

func IsRateLimit(err error) bool

IsRateLimit reports whether err is a rate-limit error.

Types

type APIKeyConfig

type APIKeyConfig struct {
	// Index — API key index (2..254).
	Index uint8
	// PrivateKey — 40-byte hex private key, optional 0x prefix.
	PrivateKey string
}

APIKeyConfig — one additional API key of the account.

type Client

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

Client — root SDK object. Safe for concurrent use.

func NewClient

func NewClient(cfg Config) (*Client, error)

NewClient creates the root SDK client. cfg goes through withDefaults + validate. When PrivateKey is set the client can sign transactions and read private data; otherwise it can only access public endpoints.

func (*Client) APIKeyIndexes

func (c *Client) APIKeyIndexes() []uint8

APIKeyIndexes returns the indexes of the configured signing keys (the first one is the default).

func (*Client) AccountIndex

func (c *Client) AccountIndex() int64

AccountIndex returns the configured account index.

func (*Client) AuthToken

func (c *Client) AuthToken() (string, error)

AuthToken returns a cached authentication token of the default key (for callers that talk to the exchange outside the SDK).

func (*Client) CanSign

func (c *Client) CanSign() bool

CanSign reports whether the client holds a signing key.

func (*Client) Close

func (c *Client) Close() error

Close stops the background work (WebSocket connections, metadata refresh) and zeroes the signing keys. Safe to call multiple times.

func (*Client) Config

func (c *Client) Config() Config

Config returns a copy of the effective configuration (defaults applied, key material removed).

func (*Client) Engine

func (c *Client) Engine() *engine.Engine

Engine returns the unified request layer. Sections use it; applications normally do not need it.

func (*Client) IsTestnet

func (c *Client) IsTestnet() bool

IsTestnet reports whether the client targets the testnet chain.

func (*Client) LifeContext

func (c *Client) LifeContext() context.Context

LifeContext returns the context that is cancelled by Close. Background work of sections (metadata refresh, streams) is bound to it.

func (*Client) Logger

func (c *Client) Logger() Logger

Logger returns the configured logger.

func (*Client) Metrics

func (c *Client) Metrics() CounterFactory

Metrics returns the configured counter factory.

func (*Client) PostConn

func (c *Client) PostConn() *ws.Conn

PostConn returns the connection used for jsonapi transactions, starting it on first use. Kept separate from StreamConn so market-data bursts never delay a transaction reply.

func (*Client) PublicKeyHex

func (c *Client) PublicKeyHex(apiKeyIndex uint8) string

PublicKeyHex returns the public key of a configured signing key, in the form the apikeys endpoint prints ("" when the index is not configured).

func (*Client) RateLimits

func (c *Client) RateLimits() RateLimitSnapshot

RateLimits returns the current SDK-side budgets.

func (*Client) StreamConn

func (c *Client) StreamConn() *ws.Conn

StreamConn returns the shared subscription connection, starting it on first use. It reconnects until Close.

func (*Client) StreamConnected

func (c *Client) StreamConnected() bool

StreamConnected reports whether the subscription socket is live right now.

func (*Client) WarmUpPost

func (c *Client) WarmUpPost(ctx context.Context) error

WarmUpPost connects the transaction socket and waits until it is live, so the first WebSocket transaction does not pay for the handshake.

func (*Client) WarmUpStream

func (c *Client) WarmUpStream(ctx context.Context) error

WarmUpStream connects the subscription socket and waits until it is live.

type Config

type Config struct {
	// AccountIndex — account (or sub-account) index. Required for private
	// endpoints and transactions.
	AccountIndex int64
	// APIKeyIndex — index of the default signing key (2..254).
	APIKeyIndex uint8
	// PrivateKey — private key of the default signing key. Empty → read-only
	// client. Never logged, never echoed in errors.
	PrivateKey string
	// ExtraKeys — additional signing keys (v2.0 key pool).
	ExtraKeys []APIKeyConfig

	// Testnet — selects testnet endpoints and the testnet chain id.
	Testnet bool
	// ChainID — explicit chain id; 0 → derived from Testnet.
	ChainID uint32

	// REST — REST transport settings. Empty fields take DefaultConfig().REST.
	REST RestConfig
	// WS — WebSocket transport settings. Empty fields take DefaultConfig().WS.
	WS WsConfig
	// RateLimit — SDK-side rate-limit accounting.
	RateLimit RateLimitConfig

	// NonceMode — sequential (default) or skip.
	NonceMode NonceMode
	// TxExpiry — lifetime of a transaction (ExpiredAt = now + TxExpiry).
	// Default: 10 minutes minus one second (the official SDK default).
	TxExpiry time.Duration
	// AuthTokenLifetime — validity of generated auth tokens, at most 8 hours
	// (exchange limit). Default: 7h.
	AuthTokenLifetime time.Duration

	// MarketRefreshInterval — how often sections refresh market metadata
	// (market ids, decimals). Default: 5m. Negative disables the background
	// refresh (metadata is then loaded once, on first use).
	MarketRefreshInterval time.Duration

	// Logger — optional logger. If nil, NoopLogger() is used.
	Logger Logger
	// Metrics — optional counter factory. If nil, NoopMetrics() is used.
	Metrics CounterFactory
	// UserAgent — User-Agent of REST requests. Default: "go-lighter/v1".
	UserAgent string

	// RateLimitEventObserver — optional hook called SYNCHRONOUSLY after every
	// request with the SDK-side rate-limit accounting (see rate-limit-event.go
	// for the contract). If nil — no-op, zero overhead.
	RateLimitEventObserver func(RateLimitEvent)
}

Config — public SDK configuration. Passed to NewClient.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns a Config with all sensible defaults (mainnet endpoints + production timeouts).

type Counter

type Counter = ltmet.Counter

Counter — a single monotonically increasing counter.

type CounterFactory

type CounterFactory = ltmet.CounterFactory

CounterFactory — counter factory (name + label pairs).

func NoopMetrics

func NoopMetrics() CounterFactory

NoopMetrics returns the no-op counter factory.

type Error

type Error = lterr.Error

Error — unified SDK error type.

func NewError

func NewError(kind ErrorKind, msg string, cause error) *Error

NewError creates an SDK error without an exchange code.

type ErrorKind

type ErrorKind = lterr.ErrorKind

ErrorKind — SDK error category.

const (
	ErrorKindUnknown        ErrorKind = lterr.ErrorKindUnknown
	ErrorKindNetwork        ErrorKind = lterr.ErrorKindNetwork
	ErrorKindRateLimit      ErrorKind = lterr.ErrorKindRateLimit
	ErrorKindAuth           ErrorKind = lterr.ErrorKindAuth
	ErrorKindInvalidRequest ErrorKind = lterr.ErrorKindInvalidRequest
	ErrorKindExchange       ErrorKind = lterr.ErrorKindExchange
)

Error categories.

type Field

type Field = ltlog.Field

Field — typed key-value log field.

func Bool

func Bool(key string, value bool) Field

Bool creates a boolean Field.

func Err

func Err(err error) Field

Err creates an error Field.

func Float

func Float(key string, value float64) Field

Float creates a float Field.

func Int

func Int(key string, value int64) Field

Int creates an integer Field.

func Str

func Str(key, value string) Field

Str creates a string Field.

type FieldKind

type FieldKind = ltlog.FieldKind

FieldKind — Field discriminator.

const (
	FieldKindString FieldKind = ltlog.FieldKindString
	FieldKindInt    FieldKind = ltlog.FieldKindInt
	FieldKindFloat  FieldKind = ltlog.FieldKindFloat
	FieldKindBool   FieldKind = ltlog.FieldKindBool
	FieldKindError  FieldKind = ltlog.FieldKindError
)

Field kinds.

type Logger

type Logger = ltlog.Logger

Logger — minimal SDK logging contract.

func NoopLogger

func NoopLogger() Logger

NoopLogger returns the no-op logger.

type NonceMode

type NonceMode = nonce.Mode

NonceMode — nonce assignment strategy (see internal/nonce).

const (
	// NonceModeSequential — old+1 nonces, one round trip at a time per key
	// (default; the strategy of the official SDKs).
	NonceModeSequential NonceMode = nonce.ModeSequential
	// NonceModeSkip — monotonic millisecond nonces with the SkipNonce
	// attribute; sends on one key need not be serialised.
	NonceModeSkip NonceMode = nonce.ModeSkip
)

type RateLimitBudget

type RateLimitBudget struct {
	// WeightedPerMinute — weighted REST window (24 000; Builder 240 000).
	WeightedPerMinute int64
	// RequestsPerMinute — unweighted request window (Standard: 60, sendTx
	// included); 0 for the other tiers.
	RequestsPerMinute int64
	// SendTxPerMinute — sendTx / sendTxBatch bucket of Premium (by staked LIT)
	// and Plus (4000) accounts; 0 for Standard and Builder.
	SendTxPerMinute int64
}

RateLimitBudget — documented per-minute budgets of an account tier. A zero field means the tier has no such window.

func TierBudget

func TierBudget(tier RateLimitTier, stakedLIT int64) RateLimitBudget

TierBudget returns the documented per-minute budgets of a tier; stakedLIT (whole tokens) sizes the Premium sendTx bucket.

type RateLimitConfig

type RateLimitConfig struct {
	// Tier — "standard" (default), "premium", "plus" or "builder".
	Tier string
	// StakedLIT — whole LIT tokens staked; sizes the Premium sendTx bucket.
	StakedLIT int64
	// DefaultTxTypeLimit — per-minute limit applied to transaction types
	// without a documented bucket (order transactions); 0 disables.
	DefaultTxTypeLimit int64
	// RejectWhenRateLimited — when true, a request that does not fit into the
	// SDK-side budgets (or arrives during a cooldown) fails locally with
	// ErrorKindRateLimit instead of being sent. Default: false (the desk's
	// own rate limiter decides).
	RejectWhenRateLimited bool
}

RateLimitConfig — SDK-side rate-limit accounting (see rate-limit-event.go).

type RateLimitEvent

type RateLimitEvent = ratelimit.Event

RateLimitEvent — accounting event emitted after every request.

type RateLimitSnapshot

type RateLimitSnapshot = ratelimit.Snapshot

RateLimitSnapshot — point-in-time view of the SDK-side budgets.

type RateLimitTier

type RateLimitTier = ratelimit.Tier

RateLimitTier — account tier of the rate-limit policy.

const (
	RateLimitTierStandard RateLimitTier = ratelimit.TierStandard
	RateLimitTierPremium  RateLimitTier = ratelimit.TierPremium
	RateLimitTierPlus     RateLimitTier = ratelimit.TierPlus
	RateLimitTierBuilder  RateLimitTier = ratelimit.TierBuilder
)

Account tiers.

func TierFromName

func TierFromName(name string) (RateLimitTier, bool)

TierFromName maps a tier name as the exchange or an operator spells it ("standard", "Premium", "PLUS", "builder"; case-insensitive) to a RateLimitTier. ok == false when the name is empty or unknown — the caller keeps its current tier instead of silently falling back to Standard.

type RestConfig

type RestConfig struct {
	// BaseURL — REST base URL (scheme + host). Default: MainnetRestURL
	// (TestnetRestURL when Config.Testnet).
	BaseURL string
	// RequestTimeout — timeout of a single REST request. Default: 10s. For
	// latency-critical calls pass a ctx with its own deadline.
	RequestTimeout time.Duration
	// MaxIdleConns — idle connection pool size. Default: 100.
	MaxIdleConns int
	// MaxIdleConnsPerHost — pool size per host. Default: 100.
	MaxIdleConnsPerHost int
	// IdleConnTimeout — keep-alive idle timeout. Default: 90s.
	IdleConnTimeout time.Duration
	// Proxy — optional proxy selector. Default: http.ProxyFromEnvironment.
	Proxy func(*http.Request) (*url.URL, error)
	// HTTPClient — optional fully custom *http.Client (own TLS config, dialer,
	// transport). When set, the pool / proxy / timeout fields are ignored.
	HTTPClient *http.Client
}

RestConfig — HTTP transport settings.

type Transport

type Transport = ratelimit.Transport

Transport — how a request travelled to the exchange.

const (
	// TransportREST — HTTP (default).
	TransportREST Transport = ratelimit.TransportREST
	// TransportWS — WebSocket jsonapi request.
	TransportWS Transport = ratelimit.TransportWS
)

Transports.

type TxTracker

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

TxTracker — receipt ↔ outcome correlation. Safe for concurrent use.

func NewTxTracker

func NewTxTracker(maxEntries int) *TxTracker

NewTxTracker creates a tracker that remembers at most maxEntries outcomes (default 4096 when <= 0).

func (*TxTracker) Await

func (t *TxTracker) Await(ctx context.Context, hash string) (types.TxOutcome, error)

Await blocks until the outcome of hash is known or ctx is done.

func (*TxTracker) Lookup

func (t *TxTracker) Lookup(hash string) (types.TxOutcome, bool)

Lookup returns a recorded outcome.

func (*TxTracker) Observe

func (t *TxTracker) Observe(outcome *types.TxOutcome)

Observe records an outcome (handler of Stream().WatchTransactions). Pending transactions are not recorded: only executed / failed states.

type WsConfig

type WsConfig struct {
	// URL — WebSocket URL. Default: MainnetWsURL (TestnetWsURL when Testnet).
	URL string
	// HandshakeTimeout — connection handshake timeout. Default: 10s.
	HandshakeTimeout time.Duration
	// ReadTimeout — read deadline of a single frame; refreshed by every frame
	// including pong. Must exceed PingInterval. Default: 75s.
	ReadTimeout time.Duration
	// WriteTimeout — write timeout of a single frame. Default: 5s.
	WriteTimeout time.Duration
	// PingInterval — client keepalive period. The server closes a connection
	// silent for 2 minutes. Default: 30s.
	PingInterval time.Duration
	// ReconnectInitialBackoff — initial delay between reconnects. Default: 200ms.
	ReconnectInitialBackoff time.Duration
	// ReconnectMaxBackoff — upper bound of the backoff. Default: 10s.
	ReconnectMaxBackoff time.Duration
	// ReconnectJitter — relative jitter [0..1] applied to the backoff. Default: 0.2.
	ReconnectJitter float64
	// ReadBufferSize — gorilla/websocket read buffer size. Default: 64KB.
	ReadBufferSize int
	// WriteBufferSize — gorilla/websocket write buffer size. Default: 16KB.
	WriteBufferSize int
	// EnableCompression — negotiate permessage-deflate. Default: false.
	EnableCompression bool
	// PostTimeout — how long a WS jsonapi request waits for its reply. Default: 10s.
	PostTimeout time.Duration
	// Proxy — optional proxy selector. Default: http.ProxyFromEnvironment.
	Proxy func(*http.Request) (*url.URL, error)
}

WsConfig — WebSocket transport settings.

Directories

Path Synopsis
examples
market-data command
simple-trade command
internal
tx
ws

Jump to

Keyboard shortcuts

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