Prerequisites
ANK is written in Rust and requires a Rust toolchain to build from source.Install Rust
If you don’t have Rust installed, use After installation completes, restart your terminal or run:Verify the installation:
rustup to install the latest stable toolchain:ANK requires Rust 1.70 or later. If you already have Rust installed, update to the latest stable version:
Build the project
Build all workspace members using Cargo:This compiles:
- Core libraries (
accounting,engine,exec,protocol,risk,oracle,math) - Protocol implementations (
aave-v3,lido,uniswap-v3,pendle,hyperliquid) - CLI binaries (
ank-cli,optimize) - API server (
ank-api)
Release builds are significantly faster at runtime but take longer to compile. Use release mode for production simulations and parameter sweeps.
Available binaries
ank-cli
Main simulation runner. Executes strategies from YAML config files and outputs risk metrics.
optimize
Parameter sweep optimizer. Runs grid searches over strategy parameters and scores results.
Running the binaries
Repository structure
The ANK workspace is organized into focused modules:core/
core/
Core engine and utilities:
accounting/— Balance tracking, token/user IDs, timestamp typesengine/— Orchestration, tick management, fee policiesexec/— Transaction execution with callback supportprotocol/— Protocol trait definition and action/event typesrisk/— Risk metrics calculation and CSV loggingoracle/— Price path overrides for stress testingmath/— Ray and wad math utilities (1e27 and 1e18 precision)replay/— Historical event replayagents/— Agent framework (WIP)opt/— Optimization scaffolding
protocols/
protocols/
Protocol implementations:
aave-v3/— Aave V3 multi-asset lending (deposit/borrow/repay/withdraw/liquidate)lido/— Lido wstETH staking with exchange rate growthuniswap-v3/— Toy Uniswap V3 pool for swapspendle/— Full Pendle PT/YT + SY wrapper + AMMhyperliquid/— Hyperliquid perpetuals (experimental)
apps/
apps/
Applications:
cli/— Containsank-cliandoptimizebinariesapi/— REST API server for running backtests via HTTP (experimental)
Development workflow
Running tests
Run the full test suite:Generating TypeScript bindings
ANK can export TypeScript type definitions for use in web frontends:.ts files in bindings/types/ for all types annotated with #[cfg_attr(feature = "ts-bindings", derive(TS))].
Code formatting and linting
Format code:Troubleshooting
Multiple binaries error
Multiple binaries error
Error:Solution:
Always specify the binary with
--bin:YAML integer parsing error
YAML integer parsing error
Error:Solution:
Remove underscores from integer values in YAML files:
Serde IndexMap errors
Serde IndexMap errors
Error:Solution:
Ensure the This is already configured in the workspace
serde feature is enabled for indexmap in Cargo.toml:Cargo.toml.Borrow checker errors in protocol code
Borrow checker errors in protocol code
Error:Solution:
When implementing protocols, avoid holding multiple mutable and immutable borrows simultaneously:
Health factor violations on withdraw
Health factor violations on withdraw
Error:Solution:
This is intentional behavior. Aave’s
withdraw enforces that the health factor remains ≥ 1.0 after the withdrawal. Either:- Reduce the withdrawal amount
- Repay some debt before withdrawing
- Deposit additional collateral
Next steps
Quick start
Run your first simulation with the Lido ↔ Aave leverage example
Configuration reference
Learn about all available config options for sim.yaml
Protocol APIs
Explore the action schemas for each protocol
Strategy development
Build custom strategies using the planner pattern