Engineer your edge

Almanak is an open-source agent harness for DeFi. Describe a strategy and Almanak Code writes it. The harness checks it, backtests it, rehearses it on a fork and runs it, with your funds in your own Safe.

Get started
uv tool install almanak

One install. Then run almanak.

Open source · Apache-2.0 · Python 3.12+

Backed by
NEAR Foundation
Delphi Labs
HashKey
Bankless Ventures
RockawayX
AppWorks
Matrix Partners China
Sparkle Ventures
01How it works

From a sentence to a running strategy

Almanak Code writes the strategy, and the harness runs the same code in every mode, from a backtest to mainnet.

01

Describe

Tell Almanak Code what you want. It writes strategy.py and config.yaml and checks its own work with almanak check.

02

Backtest

Replay the strategy on historical data, offline. Any run can be reproduced exactly.

03

Rehearse

Run it on a mainnet fork with simulated funds and generated Safe permissions.

04

Run

Go live from your own Safe. Pause, resume or tear it down whenever you choose.

02The harness

The agent writes the code. The harness decides what it can touch.

Strategy code never holds a key, whoever wrote it. It runs in a sandbox with no network and no secrets. Every action it proposes passes a gateway that checks it against the permissions on your Safe.

Safe custody. Zodiac-enforced permissions.
  1. AuthorAlmanak Code, or youstrategy.py + config.yamlchecked by almanak check
  2. SandboxStrategy hooks propose actionsno network · no secrets · can't signruns the strategy code
  3. GatewayChecks every action against your permissionsproviders · operator key · gassends only what is allowed
  4. Your SafeSafe + Zodiac Rolesfunds and positions stay hererevoke access at any time
Same code inbacktestforkproduction
Pause, resume or tear down at any time

Sandboxed

Strategy code runs with no network, no secrets and no way to sign.

Checked at the gateway

Every action is checked against your Safe's Zodiac Roles before anything is sent.

Your Safe

Funds and positions stay in your Safe. Almanak never takes custody.

Built to survive restarts

Pending transactions, accounting and outcomes are recorded, so a run picks up where it left off.

03Almanak Code

An agent that knows DeFi, built in

Run almanak and Almanak Code starts in your terminal. It ships inside the SDK, works from the SDK's own docs, source and reference strategies, and checks every strategy with the same almanak check the harness runs.

Nothing extra to install - every SDK release includes it for macOS, Linux and Windows.

Starts from working code - it builds on the SDK's reference strategies.

Prefer your own agent? - point it at the docs and llms.txt. The harness checks its work the same way.

Almanak Code
# Install the harness, Almanak Code included
uv tool install almanak
# Start Almanak Code in your terminal
almanak
# Or hand it a task directly
almanak code -p "supply WETH to Aave on Ethereum"
# Check what it wrote, exactly as the harness will
almanak check my_strategy
Almanak Code - ships with the SDK
04Backtest

Backtest the real strategy, then prove it on a fork

Backtests run your actual strategy code against prepared historical data, offline, with the window, costs and inventory you choose. Then rehearse it on a disposable mainnet fork: real contracts, simulated funds.

  • Runs your actual strategy code, not a formula approximation
  • One YAML file sets the window, inventory, cadence and costs
  • Reusable prepared datasets, and runs you can reproduce exactly
  • Missing measurements stay visible instead of being guessed
  • Fork rehearsals use real contracts, simulated funds and generated Safe permissions
  • An HTML report for every run
Almanak - backtest
# Replay the strategy on historical data, offline
almanak backtest run my_strategy --backtest-config backtest.yaml …
# Reproduce the run exactly, then read the report
almanak backtest reproduce --run runs/test
almanak report --run runs/test --format html --output backtest.html
# Then rehearse it on a mainnet fork
almanak run my_strategy --fork …
05What you can build

Start from a strategy that already runs

40+ reference strategies ship with the SDK, to fork, study or hand to Almanak Code.

Lending & leverage loops

Supply, borrow and loop on Aave, Compound, Morpho and Spark, with the unwind written into the strategy.

Liquidity in a price band

Open, recentre and close concentrated positions on Uniswap, PancakeSwap and Aerodrome inside a band you approve.

Indicator strategies

Act on RSI, moving averages or ATR breakouts computed from the price series the strategy declares.

Borrow-and-trade compositions

Borrow on one protocol and trade or provide liquidity on another, all from one fund.

GMX perpetuals

Open, manage and close GMX V2 positions, with stop-loss and take-profit exits.

Browse the reference strategiesor list them with almanak support --references
06Coverage

Built on the protocols that matter

Aave, Compound, Morpho, Spark, Uniswap, Curve, Aerodrome, PancakeSwap and GMX across 9 chains, taken straight from the SDK's support list.

Protocols //
Aave
Compound
Morpho
Spark
Uniswap
Curve
Aerodrome
PancakeSwap
GMX
Chains //
Ethereum
Base
Arbitrum
Optimism
Polygon
BNB Chain
Avalanche
HyperEVM
Robinhood Chain
// Ready when you are

Your first strategy is one sentence away

Install the harness, run almanak and describe what you want.

Get started
uv tool install almanak