Eidos

Formally verified perpetuals on Solana

The ideal perpetual exchange, proved.

Eidos is a small clearinghouse for perpetual futures, written in Lean 4 and compiled to Solana bytecode. Every promise to a trader is a theorem about the program that actually runs, checked by a machine and not by a person's reading.

3,134machine-checked theorems
0sorry placeholders
3standard axioms: propext, Classical.choice, Quot.sound
8certified sBPF programs

Why Platonic

Plato called the ideal form of a thing its eidos. A perpetual exchange has an ideal form too: one place where collateral goes in, one rule for each thing that can happen to it, and nothing else. No admin, no hidden path, nothing a trader has to take on trust beyond a short written list.

Eidos is that attempt. One clearinghouse, a single path for each of deposit, withdraw, open and reduce, mark, funding, margin, liquidation, insurance, bankruptcy socialisation and fees. Matchers, the oracle, the vault and rewards are separate programs reached by cross-program invocation.

What you can expect

1You only lose money when you bet the wrong way, plus the explicit, frozen costs of playing: trade fee, funding, and a capped liquidation fee if you fall below maintenance.

2Your profit is only cut when your own market lacks the losers to pay every winner, and then the cut is shared pro rata so nobody jumps the queue.

Read this first

Educational and research use. Not audited.

Eidos has had no independent security audit and is not meant for production or real user funds. A proof shows the program matches its statements. It cannot show the statements are the ones you needed.

What the proofs do not cover

The oracle's truth, transaction ordering by block leaders, and the upgrade key until it is burned. The trusted base is listed in full on the Gaps page.

No token

Eidos has no coin and no contract address. Anything claiming otherwise is not from this project.

Built on percolator-lean by Anatoly Yakovenko (aeyakovenko), Apache-2.0. Eidos is a proof-hardened fork. The architecture, the Lean-to-sBPF toolchain and the original proofs are his work.

DevnetEvery account, coin and trade here lives on Solana devnet. Test USDC has no value. Prices come from Pyth devnet feeds through the verified oracle adapter.

Trading desk

Trade the proved exchange

The centrepiece

What a trader can rely on

Each expectation in plain English, the theorem that backs it, and the file it lives in. A promise is marked Proven only if the theorem is checked in Lean today. Anything unfinished is shown as In progress, and the things we have to trust are marked Trusted base.

ExpectationTheorem and fileStatus
Deposit and balance

Your deposit is backed one to one

Every unit of collateral in the exchange is matched by tokens in a vault controlled by the program, not by a person. If you deposit and sit idle, nobody can touch or shrink your balance.

Theoremdeposit_credited_and_vault_solventFilePercolator/Verify/Promises.lean
Proven
Deposit and balance

You can always see exactly where your balance went

Every change to your total collateral breaks down into a list of typed, bounded events whose sum equals the change, to the last atom.

Theoremaccount_balance_ledger_exact_and_boundedFilePercolator/Verify/Promises.lean
Proven
Withdraw

You can withdraw in one transaction

Whenever your collateral minus the withdrawal still covers your initial margin, a single signed transaction withdraws it. Every withdrawal requires your signature.

Theoremwithdraw_above_im_in_one_txFilePercolator/Verify/Promises.lean
Proven
Control

Nobody moves your funds or trades for you without your signature

Changes to your positions without your signature come only from a matcher you opted into, a below-maintenance liquidation, settlement in your own market, or a post-outage wind-down.

Theoremonly_you_or_your_opted_in_matcher_can_tradeFilePercolator/Verify/Promises.lean
Proven
Trading

Trading cannot mint money

A trade cannot create value out of nothing.

Theoremnamed in USER_GUARANTEES.mdFileEidos round 1
Proven
Trading

The opening fee has a hard upper bound

The fee charged when you open a position has a proven upper bound.

Theoremnamed in USER_GUARANTEES.mdFileEidos round 1
Proven
Fees and funding

Fees and funding are fixed, bounded, and fully routed

Trade fee, reward recipient and funding cap are frozen at market creation. All of every trade fee goes to the rewards account: nothing to insurance, nothing to an admin.

Theoremtrade_fee_and_funding_boundedFilePercolator/Verify/Promises.lean
Proven
Fees and funding

The spread is zero-sum

Spread and funding move value between traders. They do not create or destroy it.

Theoremnamed in USER_GUARANTEES.mdFileEidos round 1
Proven
Holding a position

Prices can only move so fast

Each oracle update must advance the slot and is clamped to a maximum move. A position opened at initial margin survives clamped steps, including a four-slot blackout, without bad debt.

Theoremprice_speed_limit_and_survivalFilePercolator/Verify/Promises.lean
Proven
Cross-margin

Another market blowing up cannot hurt your healthy one

Even if a separate market wipes every shared free balance to zero, it cannot inject bad debt or auto-deleveraging into your market. Shortfalls are bounded by that market's own numbers.

Theoremcross_market_rug_isolationFilePercolator/Verify/Promises.lean
Proven
Liquidation

A healthy position cannot be liquidated

You can be liquidated on a leg only when you are below maintenance margin or already bankrupt. Fees are capped, your other legs are untouched, and loss is bounded by free collateral plus that leg's locked margin.

Theoremliquidation_only_below_mm_with_capped_feeFilePercolator/Verify/Promises.lean
Proven
Bankruptcy

Auto-deleveraging only fires on real bankruptcy in the same market

Across the whole life of a market, ADL can trigger only on a step with an actual shortfall in that exact market, and the total haircut is bounded by that market's own pool and shortfall.

Theoremadl_only_on_own_market_bankruptcy_and_value_boundedFilePercolator/Verify/Promises.lean
Proven
Winnings

Winnings are paid pro rata, with no queue jumping

If a market is in deficit, winner payouts are escrowed. Payouts round down pro rata, so early claimers cannot dilute later ones and the total never exceeds the pool.

Theoremwinnings_paid_prorata_no_queue_jumpingFilePercolator/Verify/Promises.lean
Proven
Outage

If the oracle goes stale, anyone can start a wind-down

Starting a wind-down on a stale oracle needs no permission. From there anyone can force-close, resolve, claim and withdraw within a bounded number of transactions.

Theoremop14_startWindDown_succeedsFilePercolator/Verify/Liveness.lean
Proven
Outage

You can exit a dead market in a bounded number of steps

Wind-down, forced close, resolution, claim and withdrawal complete in at most OIâ‚€ + 4 compiled transactions, and an unrelated dead market never blocks exits elsewhere.

Theoremoutage_exit_bounded_slots_and_txsFilePercolator/Verify/Promises.lean
Proven
Liquidity providers

Insurance and LP shares cannot be diluted or drained

LP share counts are exact, per-share value never falls, and redemption never decreases across the whole trace. Insurance never absorbs bad debt.

Theoremlp_no_dilution_or_self_trade_drainFilePercolator/Verify/Promises.lean
Proven
Rules

No admin, and the rules never change

Market and exchange parameters are immutable once created, closed accounts cannot be revived, and every deleted admin instruction fails unconditionally.

Theoremmarket_rules_frozen_no_adminFilePercolator/Verify/Promises.lean
Proven
Transactions

Everything holds inside real Solana transactions

The promises are lifted from single instructions to atomic, signed, multi-instruction transactions.

Theoremsanitized_multiIx_preserves_promisesFilePercolator/Verify/Promises.lean
Proven
Deployment

Frozen program bytes carry the same promises

Once the upgrade authority is burned, the promises are linked to the exact frozen ELF bytes loaded by the BPF loader.

Theoremmainnet_frozen_loaderLinked_promisesFilePercolator/Verify/Composition.lean
Proven
Trading

Each trade charges only that trader's own fee and collateral

The trade handler should be shown to debit exactly the fee and collateral of the trader involved, and nobody else.

Theoremper-trader fee and debit pinningFileEidos round 2
In progress
Settlement

Mark settlement is correct on the actual stored values

Mark settlement is proven at the math level. The remaining step is a postcondition on the stored kLong and kShort values themselves.

TheoremkLong / kShort settlement postconditionFileEidos round 2
In progress
Exit

You can close a position on your own

Today a position on a live, fresh market can need the other side to co-sign. The goal is a close you can always force unilaterally.

Theoremunilateral close livenessFileEidos round 2
In progress
Compiler

Lean compiles to the sBPF you run

The compiler from Lean to sBPF, and the equivalence of the produced ELF to the proved program, are trusted. Each binary is certified by a rewrite checker with no unverified rewrites.

Theoremlean-svm compiler and ELF equivalenceFilelean-svm
Trusted base
Runtime

Solana behaves as modelled

The proofs assume the Agave runtime and its syscalls behave as the verified world model says.

TheoremAgave runtime faithfulnessFileLeanSVM.Verify
Trusted base
Tokens and crypto

SPL Token and cryptography hold

SPL Token acts as specified, Ed25519 signatures cannot be forged, and SHA-256 second preimages cannot be found for the vault address.

TheoremSPL Token, Ed25519, SHA-256Fileassumption
Trusted base
Oracle

The oracle is honest

The proofs enforce a speed limit on price moves. They do not prove that a price authority reports the true external price.

Theoremoracle honestyFileassumption
Trusted base

Theorem names marked "named in USER_GUARANTEES.md" were added in Eidos round 1 and are listed in the repository's guarantee document. Names for the other rows are as they appear in the source. Upstream theorems are generic over the program and are instantiated for Solana mainnet in Composition.lean, each with a mainnet_ prefix.

How it fits together

One clearinghouse. Everything else is a program it calls.

The core owns collateral and risk. Pricing, matching, liquidity and rewards live in separate programs, each small enough to read and each proved on its own.

WriteLean 4

Programs and their proofs live in one language and one kernel.

Compilelean-svm

Compiles to sBPF v3 with no heap and no read-only data section.

Certify8 ELFs

A rewrite checker certifies each binary with no unverified rewrites.

RunSolana

Frozen on-chain bytes linked back to the promises.

The clearinghouse

One program, Program.lean, owns every state change to collateral and positions. Each thing that can happen has exactly one code path, so there is exactly one place to prove it.

  1. 01
    DepositOne path to credit collateral
  2. 02
    WithdrawOne path, owner-signed
  3. 03
    Open and reduceSingle tradeCore for every fill
  4. 04
    MarkOracle price clamp and settlement
  5. 05
    FundingBounded, birth-capped rate
  6. 06
    MarginInitial and maintenance checks
  7. 07
    LiquidationSolvent takeover or bankruptcy
  8. 08
    InsuranceIsolated per market, share-based
  9. 09
    SocialisationPro-rata, own-market only
  10. 10
    FeesAll routed to rewards

The program suite

Compiled sizes of the eight production binaries.

percolator.soClearinghouse
100,536 B
percolator_vaultLP vault
29,640 B
oracle_amm_matcherOracle AMM
23,672 B
ewma_oracleEWMA oracle
21,984 B
reward_moduleRewards
21,856 B
oracle_adapterOracle adapter
18,656 B
limit_matcherLimit matcher
14,832 B
matcherMatcher
6,416 B

Around the core

Matchers

Reached by CPI. Traders opt in by binding a matcher to their portfolio, and the core still enforces fill, spread and margin limits on whatever a matcher returns, even an adversarial one.

Oracle

Price updates must advance the slot and are clamped to a maximum move per slot. The core enforces the speed limit, not the truth of the price.

Vault and rewards

The vault holds LP shares with an anti-inflation floor. The reward module receives all trade fees and distributes them as its own rules say.

Stated plainly

What is not proved yet

A verified system is only as honest as its list of gaps. Round 1 produced the table on the previous page. These three items are being closed now, and the core is still being trimmed.

Open proof gaps

In progress

Per-trader fee and debit pinning

We have bounds on fees overall. We do not yet have a theorem saying a trade debits only that trader's own fee and collateral and no one else's.

In progress

kLong and kShort settlement postcondition

Mark settlement is proved on the underlying arithmetic. The missing piece is a statement about the values actually written to storage.

In progress

Unilateral close liveness

Closing a position early on a live market can still need the counterparty's signature. The goal is a close you can always trigger yourself.

The trusted base

These are assumed, not proved. Eidos cannot be more trustworthy than they are.

  • lean-svmThe Lean-to-sBPF compiler, and equivalence between the produced ELF and the verified program.
  • Agave runtimeThe Solana runtime and syscalls behave as the verified world model says.
  • SPL TokenThe token program behaves as specified.
  • Ed25519 and SHA-256Signatures cannot be forged and second preimages for the vault address cannot be found.
  • Oracle honestyPrices are rate limited by proof. Whether they are true is a trust question.

Honest exceptions

  • Frozen costsTrade fees, funding on the crowded side, and capped liquidation fees are real costs, even though they are bounded.
  • Opted-in matchersIf you bind a matcher to your portfolio, it can fill you within the core's spread and margin checks.
  • OrderingLiveness theorems assume block inclusion and do not prevent a leader from ordering transactions against you.
  • Upgrade keyRules can never change only once the upgrade authority is burned. Until then the key is part of the trusted base.

Not audited

This project is for education and research. Do not run it with real funds before independent review and end-to-end verification.

Credit and code

Built on Toly's percolator-lean

Eidos would not exist without Anatoly Yakovenko's percolator-lean: the exchange design, the zero-operator-key approach, the Lean 4 programs, and the first thirteen headline promises. Eidos starts from his latest main and works to close the remaining proof gaps and make the core smaller.

The Lean-to-sBPF compiler and the Solana verification library are his lean-svm.

Reproduce upstream

# check every proof, certify the binaries, run the suites
./scripts/build-and-test.sh

# run the standalone Rust tests
cargo test --manifest-path svm-runner/Cargo.toml --release

Where to look in the source

  • Percolator/Program.leanThe clearinghouse.
  • Percolator/Verify/Promises.leanThe headline guarantees, stated generically.
  • Percolator/Verify/Composition.leanInstantiation for Solana mainnet.
  • Percolator/Verify/Liveness.leanWind-down and exit proofs.
  • Percolator/Verify/MainnetFacts.leanChecks on the compiled ELFs.

License

Apache License 2.0, as upstream. Provided as is, without warranty. Educational and research purposes only, not audited.