End-to-end examples for the Hadron AMM SDK on Solana in both TypeScript and Rust. Create a fully configured pool on devnet, inspect and update it, then simulate and visualize depth curves locally.
| Guide | Examples | |
|---|---|---|
| TypeScript | src-ts/README.md | Quickstart + LiteSVM simulations |
| Rust | src-rs/README.md | Quickstart (devnet reads & writes) |
Both languages share the same output/ directory — you can create a pool in TS and read it in Rust, or vice versa.
Hadron pools expose 6 levers for controlling pricing:
- Midprice: oracle price pushed by the authority via
updateMidprice - Base spread: symmetric bid/ask offset around midprice (e.g. 10 bps)
- Price curves: price degradation as a function of trade size (depth)
- Risk curves: price adjustment based on vault inventory imbalance
- Curve updates: real-time curve edits queued via
submitCurveUpdates, applied atomically on the next swap - Spread triggers: per-account spread overrides that automatically widen the bid/ask
solana-keygen new -o wallet.json
solana airdrop 5 --keypair wallet.json --url devnetcp .env.example .envDefaults work out of the box:
NETWORK=devnet
WALLET=./wallet.json
RPC_URL=https://api.devnet.solana.com
Set RPC_URL if you have a custom endpoint (Helius, Triton, etc).
Linux (Ubuntu/Debian):
sudo apt update && sudo apt install build-essential pkg-config libssl-dev -y
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source ~/.cargo/envmacOS: Install Xcode Command Line Tools (xcode-select --install) and Rust via rustup.
npm install # TypeScript
cargo build # Rust (optional, builds on first run)Run in order — each step builds on the previous one.
| Step | TypeScript | Rust |
|---|---|---|
| Create pool | npm run init |
cargo run --bin init |
| Read state | npm run read |
cargo run --bin read |
| Update & swap | npm run write |
cargo run --bin write |
| Spread triggers | npm run spread |
cargo run --bin spread-config |
| Delta staleness | npm run delta-staleness |
cargo run --bin delta-staleness |
| Depth curves | npm run depth-curves |
— |
| Interpolation modes | npm run interp |
— |
Point at a specific pool: POOL=<address> npm run read or POOL=<address> cargo run --bin read
All examples write to output/:
| File | Created by | Description |
|---|---|---|
pool-config.json |
init | Array of pool configs (address, authority, timestamp) |
authority-{addr}.json |
init | Authority keypair for each pool |
sim-cache.json |
depth-curves / interp | Cached pool + fee config from devnet |
depth-curves.html |
depth-curves | Interactive depth chart with inventory slider |
interp-comparison.html |
interp | Side-by-side interpolation mode comparison |
You can run init multiple times — each run appends a new pool. Subsequent commands always use the most recent pool.