For the complete documentation index, see llms.txt. This page is also available as Markdown.

Rust Reference

The simulator-client and simulator-api crates provide a native Rust interface to the Termina simulator, for teams who want to integrate backtesting directly into their Rust code rather than using the sim CLI.

  • simulator-client is the high-level async client. It wraps the WebSocket protocol with ergonomic builders for common workflows: creating sessions, advancing slots, injecting transactions, and reading account state.

  • simulator-api defines the raw protocol types (request/response structs, error variants, session parameters). Use it if you need direct access to the wire format or want to implement your own client.

For a complete set of end-to-end examples, see the starter code repository.

Installation

[dependencies]
simulator-client = "0.23"
simulator-api = "0.23" # Only if you require protocol types (e.g. to build a custom client)

Examples

Available Slots

Before creating a session, confirm the slot range you want to backtest is available.

use simulator_client::BacktestClient;

let client = BacktestClient::builder()
    .url("wss://simulator.termina.technology/backtest")
    .api_key(api_key)
    .build();

let ranges = client.available_ranges().await?;
for r in &ranges {
    println!(
        "slots {} – {}",
        r.bundle_start_slot,
        r.max_bundle_end_slot.unwrap_or(0)
    );
}

Session Initialization

Set the slot range and any optional fields in the session creation parameter, then create the session:

  • signer_filter: skip historical transactions signed by these addresses

  • actions: run a pre-scheduled action at every slot or triggered by specific transactions

  • extra_compute_units: bump the compute unit cap to prevent transaction failures

...and others in the full reference.

Reads + Writes

Each session supports standard Solana JSON-RPC methods and subscriptions at /backtest/<session_id>, including:

  • getAccountInfo, getBalance, getMultipleAccounts

  • accountSubscribe, programSubscribe, signatureSubscribe

See API Reference for the full list of supported Solana subscription methods.

Use the session's RPC client to send transactions and read accounts.

Or establish a websocket connection to the standard subscription methods.

Program Overrides

Test new program logic by compiling a new binary and overriding the existing one.

Rerouted Order Flow

Reroute historical swaps through Jupiter Metis to see how changes to parameters affect the flow a pool would've captured.

Update the session creation parameters to enable rerouting.

Summary + Measurements

To get a summary of the reroutes, ubscribe to replacementSubscribe notifications. Each rerouted swap includes:

  • the route the router chose, hop by hop, with the address of each pool used

  • amounts in and out for each hop

  • the original route and fill onchain, for comparison

The session summary also reports how many swaps were detected, rerouted, simulated and succeeded.

Last updated