Skip to content

The Lean planner

The Unlink Planner is a pure function written in Lean 4. Given an amount and a few preferences, it returns a schedule of withdrawals, or refuses. Its properties are stated as Lean propositions and proven by Lean's kernel. The full list, with sources, is on Proofs.

Input

FieldMeaning
amountlamports to unlink
denomsstandard withdrawal sizes, default 0.1, 0.5, 1, 5, 10 SOL
burnersnumber of burner wallets, 1 to 16
speedfast (6 h), balanced (24 h) or max (72 h)
minDelayearliest first withdrawal, seconds
minGapminimum time between two withdrawals, seconds
avoidAmountsother amounts that must not be echoed, such as recent deposits
feeFixed, feeBpsthe relayer's fee: fixed lamports plus basis points of the withdrawal
seed32 random bytes

Output

A list of steps, each with a gross amount (one of the denominations), the relayer fee, a delay in seconds and a burner index; plus leftShielded (what stays in the pool) and totalFees.

How it works

  1. A ChaCha20 stream, keyed with the seed, drives every random choice.
  2. The amount is split greedily into denominations, with a random choice between the largest two that fit, while reserving enough for every burner to get one withdrawal.
  3. The chunks are shuffled and assigned to burners: first one each, then uniformly.
  4. Delays are drawn inside the window, sorted, and spaced by at least minGap.
  5. The candidate is checked against every specification. If any check fails, it tries again with the next attempt counter, up to 16 times, then refuses with the reason.

Because the planner only returns plans that pass its checks, and the checks are proven to imply the specifications, every plan you get satisfies them.

The theorems

  • plan_total_exact: what burners receive, plus fees, plus what stays shielded, equals the amount.
  • standard_chunks: every withdrawal is a denomination, and its fee is exactly the relayer's.
  • no_amount_echo: no withdrawal and no burner's running balance lands within ±2% of the amount or any avoided amount, unless that value is itself a standard size.
  • delays_respect_min, gaps_respect_min, within_window: timing.
  • burners_in_range: every burner index exists; if the amount allows, every burner gets a withdrawal.
  • dust_bounded: what stays shielded is less than the smallest denomination.
  • deterministic: equal inputs give equal plans.

Lean and TypeScript

The browser and CLI run a TypeScript port, because the planner must run where your keys are. The port is tested against the Lean binary on 100,000 random inputs at every build and must produce byte-identical output. The count and result are published on Proofs.

cd planner && lake build && lake exe proofs
bun run difftest