Parallax is a LiteSVM-based oracle SDK for deterministic DeFi scenario simulation. It lets you model “market stress” events (crashes / volatility spikes) while warping slots and epochs deterministically, so tests are repeatable but still feel closer to real chain-time progression.
The repo includes:
- A Rust SDK (this crate) that wraps LiteSVM with a harness + time controls.
- An Anchor oracle program (local) used as the on-chain oracle inside the VM.
- Scenario-style tests showing how to use the SDK to simulate a price crash and assert downstream behavior (e.g. liquidation thresholds).
In a normal Rust test you:
- Create a
TestHarness(LiteSVM instance + payer). - Deploy the oracle program into LiteSVM.
- Derive / create an oracle PDA and initialize it with a starting price.
- Warp forward in slots (and/or epochs) deterministically.
- Update oracle price as your scenario requires (e.g. crash).
- Read oracle state back and assert your protocol logic.
src/litesvm/harness.rs:TestHarnesswrapper for deploying programs, funding accounts, sending txs, and warping slots.
oracle/behaviour.rs:OracleBehaviourhelper to initialize the oracle, set price, read oracle, and run scenario moves likeprice_crash(...).
timecontroller/controller.rs:TimeControllerfor deterministic slot/epoch warping.
tests/scenario_testing/: scenario tests demonstrating “how you might use it”.
oracle/- Anchor workspace
oracle/programs/oracle/: the Anchor oracle program crate used inside LiteSVM
The harness deploys the oracle program from local artifacts:
artifacts/oracle-keypair.jsonartifacts/oracle.so
So the usual workflow is:
- Build the oracle program (Anchor) to produce the
.soand program keypair. - Ensure those files exist under
artifacts/. - Run the Rust tests (
cargo test) to execute deterministic scenarios.
There’s a scenario test that simulates a price crash over a deterministic slot jump and verifies that a sample lending position becomes liquidatable after the crash.
-
Test file:
src/tests/scenario_testing/liquidation_scenario_testing.rs -
Scenario outline:
- Initialize oracle at
from_price - Read price + slot (baseline)
- Warp ahead by
slot_jump - Set oracle to
to_price - Assert slot advanced, price updated, and liquidation condition flips as expected
- Initialize oracle at
-
Anchor Program Example Demonstrating how to use it in a anchor program : Link
From repo root:
cargo testIf the program artifacts are missing, build the Anchor oracle program and place the resulting .so + keypair JSON under artifacts/ so the harness can deploy it.
From the repo root Cargo.toml:
anchor-lang = { version = "0.31.1", features = ["derive", "init-if-needed"] }litesvm = "0.6.1"litesvm-token = "0.6.1"solana-instruction = "2.2.1"solana-keypair = "2.2.1"solana-native-token = "2.2.1"solana-pubkey = "2.2.1"solana-signer = "2.2.1"solana-system-interface = "1.0.0"solana-transaction = "2.2.1"solana-message = "2.2.1"solana-sdk-ids = "2.2.1"solana-address = "1.0.0"solana-account = "2.2.1"solana-sdk = "2.2"solana-program-runtime = "=2.2.4"oracle = { path = "oracle/programs/oracle" }