Documentation
¶
Overview ¶
Package dexvm implements a high-performance decentralized exchange VM for the Lux blockchain network.
The DEX VM provides:
- Central Limit Order Book (CLOB) trading with nanosecond price updates
- Automated Market Maker (AMM) liquidity pools
- Cross-chain atomic swaps via Warp messaging
- 200ms block times for high-frequency trading
- LX-First arbitrage strategy support
Architecture:
- Uses Quasar consensus (BLS + Corona + ML-DSA) for finality
- Integrates with Warp 1.5 for cross-chain messaging
- Supports both spot and perpetual trading
- Designed for institutional-grade performance
Index ¶
- Constants
- Variables
- func AMMSwap(reserves []LuxAmmReservePair, amounts []uint64) ([]uint64, error)
- func ArenaDestroy(a *CLOBArena) error
- func CLOBMatch(a *CLOBArena, calldata []byte) (out [LuxCLOBOutLen]byte, numFills uint32, err error)
- func GPUPluginPath() string
- type Block
- func (b *Block) Accept(ctx context.Context) error
- func (b *Block) Bytes() []byte
- func (b *Block) Height() uint64
- func (b *Block) ID() ids.ID
- func (b *Block) Parent() ids.ID
- func (b *Block) ParentID() ids.ID
- func (b *Block) Reject(ctx context.Context) error
- func (b *Block) Status() uint8
- func (b *Block) Timestamp() time.Time
- func (b *Block) Verify(ctx context.Context) error
- type BlockResult
- type CLOBArena
- type ChainVM
- func (cvm *ChainVM) BuildBlock(ctx context.Context) (chain.Block, error)
- func (cvm *ChainVM) BuildVertex(ctx context.Context) (vertex.Vertex, error)
- func (cvm *ChainVM) Connected(ctx context.Context, nodeID ids.NodeID, v *chain.VersionInfo) error
- func (cvm *ChainVM) CreateHandlers(ctx context.Context) (map[string]http.Handler, error)
- func (cvm *ChainVM) Disconnected(ctx context.Context, nodeID ids.NodeID) error
- func (cvm *ChainVM) FeePolicy() fee.Policy
- func (cvm *ChainVM) GetBlock(ctx context.Context, blkID ids.ID) (chain.Block, error)
- func (cvm *ChainVM) GetBlockIDAtHeight(ctx context.Context, height uint64) (ids.ID, error)
- func (cvm *ChainVM) GetInnerVM() *VM
- func (cvm *ChainVM) GetLiquidityManager() interface{}
- func (cvm *ChainVM) GetOrderbook(symbol string) (*orderbook.Orderbook, error)
- func (cvm *ChainVM) GetPerpetualsEngine() interface{}
- func (cvm *ChainVM) Gossip(ctx context.Context, nodeID ids.NodeID, msg []byte) error
- func (cvm *ChainVM) HealthCheck(ctx context.Context) (chain.HealthResult, error)
- func (cvm *ChainVM) Initialize(ctx context.Context, vmInit vm.Init) error
- func (cvm *ChainVM) LastAccepted(ctx context.Context) (ids.ID, error)
- func (cvm *ChainVM) NewHTTPHandler(ctx context.Context) (http.Handler, error)
- func (cvm *ChainVM) ParseBlock(ctx context.Context, data []byte) (chain.Block, error)
- func (cvm *ChainVM) ParseVertex(ctx context.Context, b []byte) (vertex.Vertex, error)
- func (cvm *ChainVM) Request(ctx context.Context, nodeID ids.NodeID, requestID uint32, deadline time.Time, ...) error
- func (cvm *ChainVM) Response(ctx context.Context, nodeID ids.NodeID, requestID uint32, response []byte) error
- func (cvm *ChainVM) SetPreference(ctx context.Context, blkID ids.ID) error
- func (cvm *ChainVM) SetState(ctx context.Context, state uint32) error
- func (cvm *ChainVM) Shutdown(ctx context.Context) error
- func (cvm *ChainVM) SubmitTx(tx []byte) error
- func (cvm *ChainVM) Version(ctx context.Context) (string, error)
- func (cvm *ChainVM) WaitForEvent(ctx context.Context) (vm.Message, error)
- type DexVertex
- func (v *DexVertex) Accept(ctx context.Context) error
- func (v *DexVertex) Bytes() []byte
- func (v *DexVertex) Conflicts(other *DexVertex) bool
- func (v *DexVertex) ConflictsVertex(other vertex.Vertex) bool
- func (v *DexVertex) Epoch() uint32
- func (v *DexVertex) Height() uint64
- func (v *DexVertex) ID() ids.ID
- func (v *DexVertex) Parents() []ids.ID
- func (v *DexVertex) Reject(ctx context.Context) error
- func (v *DexVertex) Status() choices.Status
- func (v *DexVertex) Txs() []ids.ID
- func (v *DexVertex) Verify(ctx context.Context) error
- type Factory
- type GPUBackend
- type Genesis
- type GenesisBalance
- type GenesisFeeConfig
- type GenesisPerpMarket
- type GenesisPool
- type GenesisTradingPair
- type LuxAmmReservePair
- type OrderKey
- type Status
- type VM
- func (vm *VM) Connected(ctx context.Context, nodeID ids.NodeID, v *version.Application) error
- func (vm *VM) CreateHandlers(ctx context.Context) (map[string]http.Handler, error)
- func (vm *VM) CrossChainRequest(ctx context.Context, sourceChainID ids.ID, requestID uint32, ...) error
- func (vm *VM) CrossChainRequestFailed(ctx context.Context, chainID ids.ID, requestID uint32, ...) error
- func (vm *VM) CrossChainResponse(ctx context.Context, chainID ids.ID, requestID uint32, response []byte) error
- func (vm *VM) Disconnected(ctx context.Context, nodeID ids.NodeID) error
- func (vm *VM) GetADLEngine() api.ADLEngine
- func (vm *VM) GetBlockHeight() uint64
- func (vm *VM) GetCommitmentStore() api.CommitmentStore
- func (vm *VM) GetLastBlockTime() time.Time
- func (vm *VM) GetLiquidityManager() *liquidity.Manager
- func (vm *VM) GetOrCreateOrderbook(symbol string) *orderbook.Orderbook
- func (vm *VM) GetOrderbook(symbol string) (*orderbook.Orderbook, error)
- func (vm *VM) GetPerpetualsEngine() api.PerpetualsEngine
- func (vm *VM) Gossip(ctx context.Context, nodeID ids.NodeID, msg []byte) error
- func (vm *VM) HealthCheck(ctx context.Context) (chain.HealthResult, error)
- func (vm *VM) Initialize(ctx context.Context, vmInit vmcore.Init) error
- func (vm *VM) IsBootstrapped() bool
- func (vm *VM) ProcessBlock(ctx context.Context, blockHeight uint64, blockTime time.Time, txs [][]byte) (*BlockResult, error)
- func (vm *VM) Request(ctx context.Context, nodeID ids.NodeID, requestID uint32, deadline time.Time, ...) error
- func (vm *VM) RequestFailed(ctx context.Context, nodeID ids.NodeID, requestID uint32, ...) error
- func (vm *VM) Response(ctx context.Context, nodeID ids.NodeID, requestID uint32, response []byte) error
- func (vm *VM) SetState(ctx context.Context, stateNum uint32) error
- func (vm *VM) Shutdown(ctx context.Context) error
- func (vm *VM) Version(ctx context.Context) (string, error)
- type WSMessage
- type WSSubscription
Constants ¶
const ( // LuxCLOBCalldataLen is the on-wire calldata for EVM precompile 0x100: // side(1) | price(32 BE) | qty(32 BE) | user(20) | book_id(32) = 117. LuxCLOBCalldataLen = 117 // LuxCLOBOutLen is the output: filled(32 BE) | avg_price(32 BE) | num_fills(4 BE) = 68. LuxCLOBOutLen = 68 // LuxCLOBMaxLevels caps the per-side resting-level depth (bid_*/ask_* arrays). LuxCLOBMaxLevels = 1024 // LuxCLOBBookIDOffset is where book_id starts inside calldata. LuxCLOBBookIDOffset = 85 // LuxCLOBBookIDLen is the book_id width. LuxCLOBBookIDLen = 32 )
CLOB ABI byte sizes from include/lux/gpu/dex.h.
Variables ¶
var ErrGPUNotAvailable = errors.New("dexvm: GPU plugin not available")
ErrGPUNotAvailable is returned by every GPU method on the nocgo build, and by the cgo build when init() failed to bind any plugin. Consumers treat this as "fall back to the CPU path" rather than as a hard failure.
var ( // VMID is the unique identifier for the DEX VM VMID = ids.ID{'d', 'e', 'x', 'v', 'm'} )
Functions ¶
func AMMSwap ¶ added in v1.3.0
func AMMSwap(reserves []LuxAmmReservePair, amounts []uint64) ([]uint64, error)
AMMSwap runs the constant-product (xy=k) swap kernel over `n` pools in one batched dispatch. `reserves[i]` is the (ReserveX, ReserveY) pair for pool i and `amounts[i]` is the input amount. The output `outs[i]` is the receive-side amount:
outs[i] = (amounts[i] * reserves[i].ReserveY)
/ (reserves[i].ReserveX + amounts[i])
Byte-equal across all five GPU backends and to the CPU oracle at ~/work/lux/dex/pkg/lx::ConstantProductOut. Slices must be the same length; a length mismatch is a caller bug (returns an error rather than panicking).
Memory safety: every passed Go slice is pinned with runtime.Pinner for the duration of the C call. The pinner is unpinned via defer on every return path including the error path. runtime.KeepAlive keeps the slices reachable until C returns even if the compiler sees no further Go-side reference.
func ArenaDestroy ¶ added in v1.3.0
ArenaDestroy releases the device-resident BookArena. Calling it on a nil arena is a no-op (matches the C-side symmetry). Calling it twice on the same arena is UB at the plugin level — don't.
func CLOBMatch ¶ added in v1.3.0
CLOBMatch runs one matcher step against the arena. calldata is the 117-byte EVM precompile 0x100 input — see backend.go for the byte layout. Output is a fixed-size 68-byte buffer (filled + avg_price + num_fills) plus a num_fills uint32 mirror for callers that want it without re-parsing the 68 bytes.
Single matcher pass per call; concurrency is across book_ids — each book gets its own arena, and independent arenas can be matched in parallel on different goroutines without serialization.
func GPUPluginPath ¶ added in v1.3.0
func GPUPluginPath() string
GPUPluginPath returns the dylib path the active backend was loaded from, useful for diagnostic logging at node startup. Empty string when no plugin loaded.
Types ¶
type Block ¶
type Block struct {
// contains filtered or unexported fields
}
Block represents a DEX VM block that wraps the functional ProcessBlock results. It implements the chain.Block interface required for the ChainVM.
type BlockResult ¶
type BlockResult struct {
// BlockHeight is the height of the processed block
BlockHeight uint64
// Timestamp is when this block was processed
Timestamp time.Time
// MatchedTrades from order matching in this block
MatchedTrades []orderbook.Trade
// FundingPayments processed in this block (if any)
FundingPayments []*perpetuals.FundingPayment
// Liquidations executed in this block (if any)
Liquidations []*perpetuals.LiquidationEvent
// StateRoot is the merkle root of state after this block
StateRoot ids.ID
}
BlockResult represents the deterministic result of processing a block. All state changes are captured here for verifiability.
type CLOBArena ¶ added in v1.3.0
type CLOBArena struct {
// contains filtered or unexported fields
}
CLOBArena is the opaque handle to a device-resident BookArena. The pointer crosses the cgo boundary as void* — Go never dereferences it, only passes it to ArenaDestroy or CLOBMatch.
ArenaCreate hands ownership to the Go caller; ArenaDestroy releases it. The arena lives across many CLOBMatch calls — that's the entire reason it's device-resident: the BookArena holds the resting bids/asks for a single book, and successive CLOBMatch calls on the same book MUST share state.
func ArenaCreate ¶ added in v1.3.0
ArenaCreate allocates a fresh device-resident BookArena (zero initialized). The returned handle is owned by the caller; call ArenaDestroy to free it. Concurrent ArenaCreate is safe.
type ChainVM ¶
type ChainVM struct {
// contains filtered or unexported fields
}
ChainVM wraps the functional DEX VM to implement the chain.ChainVM interface required for running as an L2 chain plugin.
func NewChainVM ¶
NewChainVM creates a new ChainVM that wraps a functional DEX VM
func (*ChainVM) BuildBlock ¶
BuildBlock implements the chain.ChainVM interface. It builds a new block from pending transactions.
func (*ChainVM) BuildVertex ¶
BuildVertex drains pending txs and batches non-conflicting ones.
func (*ChainVM) CreateHandlers ¶
CreateHandlers implements the interface expected by chain manager for HTTP registration
func (*ChainVM) Disconnected ¶
Disconnected implements the VM interface
func (*ChainVM) FeePolicy ¶ added in v1.2.6
FeePolicy exposes the chain's declared fee policy for diagnostics and the boot-time Validate gate.
func (*ChainVM) GetBlock ¶
GetBlock implements the chain.ChainVM interface. It returns a block by its ID.
func (*ChainVM) GetBlockIDAtHeight ¶
GetBlockIDAtHeight returns the block ID at the given height
func (*ChainVM) GetInnerVM ¶
GetInnerVM returns the inner functional VM for direct access
func (*ChainVM) GetLiquidityManager ¶
func (cvm *ChainVM) GetLiquidityManager() interface{}
GetLiquidityManager returns the liquidity manager
func (*ChainVM) GetOrderbook ¶
GetOrderbook returns an orderbook by symbol
func (*ChainVM) GetPerpetualsEngine ¶
func (cvm *ChainVM) GetPerpetualsEngine() interface{}
GetPerpetualsEngine returns the perpetuals engine
func (*ChainVM) HealthCheck ¶
HealthCheck implements the VM interface
func (*ChainVM) Initialize ¶
Initialize implements the VM interface
func (*ChainVM) LastAccepted ¶
LastAccepted implements the chain.ChainVM interface. It returns the ID of the last accepted chain.
func (*ChainVM) NewHTTPHandler ¶
NewHTTPHandler implements the chain.ChainVM interface
func (*ChainVM) ParseBlock ¶
ParseBlock implements the chain.ChainVM interface. It parses a block from bytes.
func (*ChainVM) ParseVertex ¶
ParseVertex deserializes a vertex from bytes.
func (*ChainVM) Request ¶
func (cvm *ChainVM) Request(ctx context.Context, nodeID ids.NodeID, requestID uint32, deadline time.Time, request []byte) error
Request implements the VM interface
func (*ChainVM) Response ¶
func (cvm *ChainVM) Response(ctx context.Context, nodeID ids.NodeID, requestID uint32, response []byte) error
Response implements the VM interface
func (*ChainVM) SetPreference ¶
SetPreference implements the chain.ChainVM interface. It sets the preferred block for building new blocks.
func (*ChainVM) SubmitTx ¶
SubmitTx adds a transaction to the pending pool. This is the canonical user-mempool entry on D-Chain — every public submission funnels through here. The FeePolicy gate refuses zero-fee tx before the bytes touch pendingTxs.
Internal callers (consensus engine -> VM, replay) feed pendingTxs directly via BuildBlock; they do NOT route through SubmitTx, so the fee gate stays out of the consensus-internal path.
type DexVertex ¶
type DexVertex struct {
// contains filtered or unexported fields
}
DexVertex represents a DAG vertex in the DEX chain.
func (*DexVertex) Conflicts ¶
Conflicts returns true if this vertex and other share any (symbol, side, orderID) tuple.
func (*DexVertex) ConflictsVertex ¶
ConflictsVertex performs the same check against the vertex.Vertex interface.
type Factory ¶
Factory creates new DEX VM instances.
func (*Factory) New ¶
New implements vms.Factory interface. It creates a new DEX ChainVM instance with the factory's configuration. The ChainVM wrapper implements block.ChainVM for integration with the chains manager. Allocates a per-VM GPU session at PriorityHigh because the DEX hot path is latency-critical (1ms block times).
type GPUBackend ¶ added in v1.3.0
type GPUBackend uint8
GPUBackend names the GPU backend the plugin loader bound. The numeric values match the dlopen probe order used by init() — callers can rely on (GPUBackendCUDA < GPUBackendHIP < GPUBackendMetal < GPUBackendVulkan < GPUBackendWebGPU) as a stable ordering of preference.
const ( // GPUBackendNone means no plugin was loaded (or build was !cgo). GPUBackendNone GPUBackend = iota // GPUBackendCUDA is the NVIDIA CUDA plugin (libluxgpu_backend_cuda.so). GPUBackendCUDA // GPUBackendHIP is the AMD ROCm/HIP plugin (libluxgpu_backend_hip.so). GPUBackendHIP // GPUBackendMetal is the Apple Metal plugin (libluxgpu_backend_metal.dylib). GPUBackendMetal // GPUBackendVulkan is the Vulkan plugin (libluxgpu_backend_vulkan.{so,dylib,dll}). GPUBackendVulkan // GPUBackendWebGPU is the wgpu/Dawn plugin (libluxgpu_backend_webgpu.{so,dylib,dll}). GPUBackendWebGPU )
func AutoBackend ¶ added in v1.3.0
func AutoBackend() GPUBackend
AutoBackend returns the GPU backend bound at init(), or GPUBackendNone if no plugin loaded. Callers branch on this to decide between the GPU path and the CPU fallback.
func (GPUBackend) String ¶ added in v1.3.0
func (b GPUBackend) String() string
String returns the human-readable lowercase backend name used in the host launcher symbol prefix (e.g. "metal" → "lux_metal_amm_xyk_batch").
type Genesis ¶
type Genesis struct {
// TradingPairs defines the initial trading pairs (order book markets)
TradingPairs []GenesisTradingPair `json:"tradingPairs"`
// LiquidityPools defines the initial AMM liquidity pools
LiquidityPools []GenesisPool `json:"liquidityPools"`
// PerpetualMarkets defines the initial perpetual futures markets
PerpetualMarkets []GenesisPerpMarket `json:"perpetualMarkets"`
// FeeConfig contains global fee configuration
FeeConfig GenesisFeeConfig `json:"feeConfig"`
// TrustedChains are chain IDs trusted for cross-chain operations
TrustedChains []string `json:"trustedChains"`
// InitialBalances are pre-funded accounts (for testing/airdrops)
InitialBalances []GenesisBalance `json:"initialBalances,omitempty"`
}
Genesis represents the DEX VM genesis configuration.
type GenesisBalance ¶
type GenesisBalance struct {
Address string `json:"address"` // Hex-encoded address
Token string `json:"token"` // Token ID
Amount uint64 `json:"amount"`
}
GenesisBalance defines a pre-funded account balance.
type GenesisFeeConfig ¶
type GenesisFeeConfig struct {
DefaultSwapFeeBps uint16 `json:"defaultSwapFeeBps"`
ProtocolFeeBps uint16 `json:"protocolFeeBps"`
MaxSlippageBps uint16 `json:"maxSlippageBps"`
}
GenesisFeeConfig contains global fee configuration.
type GenesisPerpMarket ¶
type GenesisPerpMarket struct {
Symbol string `json:"symbol"` // e.g., "BTC-PERP"
BaseAsset string `json:"baseAsset"` // e.g., BTC
QuoteAsset string `json:"quoteAsset"` // e.g., USDC
MaxLeverage uint16 `json:"maxLeverage"`
MaintenanceMargin uint16 `json:"maintenanceMarginBps"` // in basis points
InitialMargin uint16 `json:"initialMarginBps"` // in basis points
MakerFee uint16 `json:"makerFeeBps"`
TakerFee uint16 `json:"takerFeeBps"`
}
GenesisPerpMarket defines an initial perpetual futures market.
type GenesisPool ¶
type GenesisPool struct {
Token0 string `json:"token0"`
Token1 string `json:"token1"`
InitialToken0 uint64 `json:"initialToken0"`
InitialToken1 uint64 `json:"initialToken1"`
PoolType uint8 `json:"poolType"` // 0=ConstantProduct, 1=StableSwap, 2=Concentrated
FeeBps uint16 `json:"feeBps"`
}
GenesisPool defines an initial liquidity pool.
type GenesisTradingPair ¶
type GenesisTradingPair struct {
Symbol string `json:"symbol"` // e.g., "LUX/USDC"
BaseAsset string `json:"baseAsset"` // Base asset ID
QuoteAsset string `json:"quoteAsset"` // Quote asset ID
}
GenesisTradingPair defines a trading pair for the order book.
type LuxAmmReservePair ¶ added in v1.3.0
LuxAmmReservePair mirrors include/lux/gpu/dex.h::LuxAmmReservePair. 16 bytes, packed (no padding), little-endian uint64 fields. MUST match:
~/work/lux-private/gpu-kernels/include/lux/gpu/dex.h::LuxAmmReservePair
~/work/lux/dex/pkg/lx/amm.go::ReservePair
~/work/lux-private/gpu-kernels/ops/dex/{cuda,metal,wgsl}/amm_xyk*
type OrderKey ¶
OrderKey is the conflict key for the DEX: (base, quote, side, orderID). Two vertices conflict iff their OrderKey sets intersect.
type VM ¶
VM implements the DEX Virtual Machine using a pure functional architecture. Native decentralized exchange — Hyperliquid-class on-chain CLOB. All state transitions happen deterministically within block processing:
- Central Limit Order Book (CLOB) — native, not EVM-based
- Perpetual futures with auto-deleveraging
- Cross-chain atomic swaps via Warp messaging
- 1ms block times for ultra-low latency trading
DESIGN: No background goroutines. All operations are block-driven and deterministic. This ensures:
- Every node produces identical state from identical inputs
- No race conditions or non-deterministic behavior
- Easy to test and verify
- Replay-safe for auditing
func NewVMForTest ¶
NewVMForTest creates a new VM instance for testing purposes. This allows external test packages to create VM instances without needing to access internal fields directly.
func (*VM) CreateHandlers ¶
CreateHandlers implements consensuscore.VM interface. It creates HTTP handlers for the DEX API.
func (*VM) CrossChainRequest ¶
func (vm *VM) CrossChainRequest( ctx context.Context, sourceChainID ids.ID, requestID uint32, deadline time.Time, request []byte, ) error
CrossChainRequest implements consensuscore.VM interface. It handles cross-chain requests via Warp messaging.
func (*VM) CrossChainRequestFailed ¶
func (vm *VM) CrossChainRequestFailed(ctx context.Context, chainID ids.ID, requestID uint32, appErr *consensuscore.AppError) error
CrossChainRequestFailed implements consensuscore.VM interface.
func (*VM) CrossChainResponse ¶
func (vm *VM) CrossChainResponse(ctx context.Context, chainID ids.ID, requestID uint32, response []byte) error
CrossChainResponse implements consensuscore.VM interface.
func (*VM) Disconnected ¶
Disconnected implements consensuscore.VM interface.
func (*VM) GetADLEngine ¶
GetADLEngine returns the auto-deleveraging engine.
func (*VM) GetBlockHeight ¶
GetBlockHeight returns the current block height.
func (*VM) GetCommitmentStore ¶
func (vm *VM) GetCommitmentStore() api.CommitmentStore
GetCommitmentStore returns the MEV protection commitment store.
func (*VM) GetLastBlockTime ¶
GetLastBlockTime returns the timestamp of the last processed block.
func (*VM) GetLiquidityManager ¶
GetLiquidityManager returns the liquidity pool manager.
func (*VM) GetOrCreateOrderbook ¶
GetOrCreateOrderbook returns or creates an orderbook for a symbol.
func (*VM) GetOrderbook ¶
GetOrderbook returns the orderbook for a symbol.
func (*VM) GetPerpetualsEngine ¶
func (vm *VM) GetPerpetualsEngine() api.PerpetualsEngine
GetPerpetualsEngine returns the perpetual futures engine.
func (*VM) Gossip ¶
Gossip implements consensuscore.VM interface. It handles gossiped messages from peers (orders and trades).
func (*VM) HealthCheck ¶
HealthCheck implements consensuscore.VM interface.
func (*VM) Initialize ¶
Initialize implements consensuscore.VM interface. It sets up the VM with the provided context, database, and genesis data.
func (*VM) IsBootstrapped ¶
IsBootstrapped returns true if the VM is fully bootstrapped.
func (*VM) ProcessBlock ¶
func (vm *VM) ProcessBlock(ctx context.Context, blockHeight uint64, blockTime time.Time, txs [][]byte) (*BlockResult, error)
ProcessBlock is the core function that processes all DEX operations deterministically. This is called by the consensus engine for each new block. All state changes happen here in a deterministic, reproducible manner.
Operations performed per block:
- Order matching for all orderbooks
- Funding rate processing (every 8 hours)
- Liquidation checks
- State commitment
func (*VM) Request ¶
func (vm *VM) Request( ctx context.Context, nodeID ids.NodeID, requestID uint32, deadline time.Time, request []byte, ) error
Request implements consensuscore.VM interface. It handles direct requests from peers (e.g., orderbook sync).
func (*VM) RequestFailed ¶
func (vm *VM) RequestFailed(ctx context.Context, nodeID ids.NodeID, requestID uint32, appErr *consensuscore.AppError) error
RequestFailed implements consensuscore.VM interface.
func (*VM) Response ¶
func (vm *VM) Response(ctx context.Context, nodeID ids.NodeID, requestID uint32, response []byte) error
Response implements consensuscore.VM interface.
func (*VM) SetState ¶
SetState implements consensuscore.VM interface. It transitions the VM between bootstrapping and normal operation states. NOTE: No background goroutines are started - all operations are block-driven.
type WSMessage ¶
type WSMessage struct {
Type string `json:"type"`
Channel string `json:"channel"`
Data json.RawMessage `json:"data,omitempty"`
}
WSMessage represents a WebSocket message.
type WSSubscription ¶
type WSSubscription struct {
Channel string `json:"channel"`
Symbol string `json:"symbol,omitempty"`
}
WSSubscription represents a client subscription.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package api provides RPC and REST API handlers for the DEX VM.
|
Package api provides RPC and REST API handlers for the DEX VM. |
|
Package block implements block structure for the DEX VM.
|
Package block implements block structure for the DEX VM. |
|
cmd
|
|
|
plugin
command
|
|
|
Package config defines configuration types for the DEX VM.
|
Package config defines configuration types for the DEX VM. |
|
Package lending provides a DeFi lending protocol for the DEX VM.
|
Package lending provides a DeFi lending protocol for the DEX VM. |
|
Package liquidity implements AMM liquidity pools for the DEX VM.
|
Package liquidity implements AMM liquidity pools for the DEX VM. |
|
Package mev implements MEV protection via commit-reveal scheme.
|
Package mev implements MEV protection via commit-reveal scheme. |
|
Package network provides peer-to-peer networking and Warp messaging for the DEX VM.
|
Package network provides peer-to-peer networking and Warp messaging for the DEX VM. |
|
Package oracle provides price oracle implementations for the DEX VM.
|
Package oracle provides price oracle implementations for the DEX VM. |
|
Package orderbook implements a high-performance order book for the DEX VM.
|
Package orderbook implements a high-performance order book for the DEX VM. |
|
Package perpetuals provides perpetual futures trading functionality for the DEX VM.
|
Package perpetuals provides perpetual futures trading functionality for the DEX VM. |
|
Package state manages persistent state for the DEX VM.
|
Package state manages persistent state for the DEX VM. |
|
Package txs defines transaction types for the DEX VM.
|
Package txs defines transaction types for the DEX VM. |