api

package
v1.3.18 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2026 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Overview

Package api provides the RPC API for the DEX VM proxy. The proxy holds NO canonical DEX state, so this service is a THIN PASS-THROUGH: order reads and writes are forwarded to the d-chain over ZAP via the relay client. There are NO local orderbook / pool / position / perpetuals / MEV / ADL endpoints — those concerns live ONLY on the d-chain.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotBootstrapped   = errors.New("DEX proxy not bootstrapped")
	ErrInvalidRequest    = errors.New("invalid request")
	ErrRelayNotAvailable = errors.New("d-chain relay not configured")
)

Functions

This section is empty.

Types

type PingArgs

type PingArgs struct{}

PingArgs is the argument for the Ping API.

type PingReply

type PingReply struct {
	Success bool `json:"success"`
}

PingReply is the reply for the Ping API.

type RelayArgs added in v1.3.8

type RelayArgs struct {
	Method  string `json:"method"`
	Payload string `json:"payload"` // hex-encoded ZAP frame
}

RelayArgs forwards an opaque, hex-encoded clob_* frame to the d-chain. The proxy does not interpret the payload — the d-chain matcher is the single source of truth. Method MUST be one of the frozen clob_* names.

type RelayReply added in v1.3.8

type RelayReply struct {
	Response string `json:"response"`
}

RelayReply returns the d-chain's raw response (hex-encoded).

type Relayer added in v1.3.8

type Relayer interface {
	Configured() bool
	Relay(ctx context.Context, method string, payload []byte) ([]byte, error)
}

Relayer is the relay surface the proxy VM exposes to the API: forward an opaque clob_* frame to the d-chain and return the raw response. It is the ONLY DEX capability the proxy has — pure transport to the matcher.

type Service

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

Service provides the RPC API for the DEX VM proxy.

func NewService

func NewService(vm VM) *Service

NewService creates a new API service.

func (*Service) Ping

func (s *Service) Ping(_ *http.Request, _ *PingArgs, reply *PingReply) error

Ping returns a simple health check response.

func (*Service) Relay added in v1.3.8

func (s *Service) Relay(r *http.Request, args *RelayArgs, reply *RelayReply) error

Relay forwards a clob_* frame to the d-chain and returns its response. This is the proxy's entire DEX API: it neither matches nor reads a local book.

func (*Service) Status

func (s *Service) Status(_ *http.Request, _ *StatusArgs, reply *StatusReply) error

Status returns the proxy status.

type StatusArgs

type StatusArgs struct{}

StatusArgs is the argument for the Status API.

type StatusReply

type StatusReply struct {
	Bootstrapped    bool   `json:"bootstrapped"`
	RelayConfigured bool   `json:"relayConfigured"`
	Version         string `json:"version"`
}

StatusReply is the reply for the Status API.

type VM

type VM interface {
	IsBootstrapped() bool
	Relay() Relayer
}

VM is the minimal surface the API service needs from the proxy VM.

Jump to

Keyboard shortcuts

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