Skip to main content

What is ANK?

ANK is a deterministic on-chain simulator designed for building and backtesting execution strategies across multiple DeFi protocols. It provides a focused testing environment where you can validate complex cross-protocol strategies before deploying them on-chain. The framework is built around three core concepts:
  • Engine: A small orchestrator that advances time (ticks), routes transaction bundles to protocols, and tracks wallet balances
  • Protocols: Pluggable protocol implementations (Aave V3, Lido, Uniswap V3, Pendle) that share a common trait interface
  • Strategies: Code that inspects market/user state each tick and emits actions
ANK is a research and backtesting tool. It does not simulate all production risks including MEV, oracle latency, gas costs, slippage nuances, or liquidation bonuses across chains. Protocol models are simplified—use cautiously for decision-making.

Key features

Multi-protocol support

Simulate strategies across Aave V3, Lido wstETH, Uniswap V3, and Pendle with accurate state modeling and cross-protocol interactions.

Deterministic execution

Advance time tick by tick with reproducible results. Each protocol accrues interest, fees, and rewards independently.

Risk analytics

Per-tick CSV exports with wallet/deposits/debt/net value, LTV, health factor, drawdown, and volatility metrics.

Strategy optimization

Parameter sweep scaffolding with configurable objectives to find optimal strategy parameters.

Supported protocols

Multi-asset lending with deposit/borrow/repay/withdraw operations, dynamic pricing, per-tick variable debt accrual, and fractional liquidation support.
Stake/unstake ETH with exchange rate growth per tick. wstETH can be used as Aave collateral with automatic price synchronization.
Toy fixed-fee pool implementation for simple swap flows and price impact testing.
Full PT/YT implementation with SY wrapper, mint/claim/redeem operations, PT↔SY AMM with LP shares and fees, and admin rate/maturity controls.

Example use cases

Cross-protocol leverage

Borrow ETH from Aave, stake in Lido for wstETH, deposit wstETH back to Aave as collateral, and loop.

Yield farming strategies

Test PT/YT minting strategies in Pendle while managing collateral positions in Aave.

Liquidation resistance

Stress test strategies under price shocks using oracle CSV overrides to validate health factor management.

Parameter optimization

Sweep target LTV, rebalancing bands, and position sizes to maximize risk-adjusted returns.

Get started

Quick start

Run your first Lido ↔ Aave leverage simulation in minutes

Installation

Install Rust and build the ANK CLI tools

API reference

Explore the protocol trait and action schemas

Architecture overview

The ANK repository is organized into focused modules:
core/
  accounting/    # Balance tracking, token/user IDs
  engine/        # Orchestration, tick management, fee policies
  exec/          # Transaction execution with callbacks
  protocol/      # Protocol trait definition
  risk/          # Risk metrics and CSV logging
  oracle/        # Price path overrides
  math/          # Ray/wad math utilities
  
protocols/
  aave-v3/       # Aave V3 simulation
  lido/          # Lido wstETH
  uniswap-v3/    # Uniswap V3 pool
  pendle/        # Pendle PT/YT + AMM
  
apps/
  cli/           # ank-cli and optimize binaries
  api/           # REST API server (experimental)

Token conventions

By convention, ANK uses numeric token IDs:
  • 1 = ETH
  • 2 = USDC
  • 3 = wstETH
  • 4-7 = Pendle tokens (SY, PT, YT, LP)
You can extend this mapping for your own simulations.

Build docs developers (and LLMs) love