the curve, proven in Lean 4
LeanFun quotes every trade with a bonding curve written and proven in Lean 4, a proof assistant whose kernel checks every step. No step is skipped: the file has no sorry, and the only axioms used are Lean’s two standard ones.
Checked with Lean (version 4.36.0, x86_64-unknown-linux-gnu, commit 611c117bfaf7b7ae1cfcf246ce6fba31e8f509e9, Release) on 2026-12-02 01:24+02:00 (SAST). sha256 of LeanFun.lean: 25c6d0c92fbf6a6c616820639770ec05fe1aeb3517285e6beb4ba92f50b7f70e. [source] [checker output]
what is proven, and what is not
proven in Lean
The virtual-reserve constant-product curve: tokens out = ⌊vTok·dx / (vSol+dx)⌋, SOL out = ⌊vSol·dy / (vTok+dy)⌋, with floor division exactly like on-chain integer math. This is the curve behind every “lean model” quote on LeanFun, and the live checks on each coin page test the coin’s real reserves against these theorems.
not proven by LeanFun
Coins launch and trade on pump.fun’s own on-chain program. It uses the same virtual-reserve formula but adds trading fees and graduation, and its code is not proven here. So the amount you actually receive is pump.fun’s quote, which is a bit less than the fee-less model. LeanFun is not affiliated with pump.fun.
price only moves the right way
A buy can only raise the price and a sell can only lower it.
Price is vSol / vTok. After a buy it is at least as high: vSol·vTok' ≤ vSol'·vTok.
theorem buy_price_up (p : Pool) (dx : Nat) :
p.vSol * (buy p dx).vTok ≤ (buy p dx).vSol * p.vTokAfter a sell the price is at most as high.
theorem sell_price_down (p : Pool) (dy : Nat) :
(sell p dy).vSol * p.vTok ≤ p.vSol * (sell p dy).vTokBuying never shrinks the SOL side, selling never shrinks the token side.
theorem buy_vSol_up (p : Pool) (dx : Nat) : p.vSol ≤ (buy p dx).vSol
theorem sell_vTok_up (p : Pool) (dy : Nat) : p.vTok ≤ (sell p dy).vTok
theorem buy_k_ge (p : Pool) (dx : Nat) : k p ≤ k (buy p dx)
theorem sell_k_ge (p : Pool) (dy : Nat) : k p ≤ k (sell p dy)
no free money
Buying and then selling straight back never returns more SOL than you paid, and selling then re-buying never returns more tokens.
Buy with `dx` lamports, sell every token you got straight back: you get at most `dx`.
theorem round_trip_no_profit (p : Pool) (dx : Nat) : sellOut (buy p dx) (buyOut p dx) ≤ dx
The same holds against the other side: sell `dy` tokens and buy back with all the SOL, you get at most `dy` tokens.
theorem round_trip_no_profit_sell (p : Pool) (dy : Nat) : buyOut (sell p dy) (sellOut p dy) ≤ dy
reserves always cover every holder
From launch, after any sequence of buys and sells, if every holder sold everything the curve pays out no more than the SOL buyers put in.
theorem inv_init (L : Launch) : Inv L (init L)
theorem inv_buy (L : Launch) (p : Pool) (dx : Nat) (h : Inv L p) : Inv L (buy p dx)
theorem inv_sell (L : Launch) (p : Pool) (dy : Nat) (h : Inv L p) (hd : dy ≤ held L p) : Inv L (sell p dy)
theorem reach_inv (L : Launch) {p : Pool} (h : Reach L p) : Inv L pIf every holder sold everything at once, the pool's real SOL covers the payout.
theorem sell_all_covered (L : Launch) (p : Pool) (h : Inv L p) : sellOut p (held L p) ≤ realSol L p
Any single legal sell is paid from real SOL: it never touches the virtual reserve.
theorem sell_covered (L : Launch) (p : Pool) (dy : Nat) (h : Inv L p) (hd : dy ≤ held L p) :
sellOut p dy ≤ realSol L pEvery holder can exit, in any order and any split: the total paid out never exceeds the real SOL that was in the pool.
theorem exits_covered (L : Launch) : ∀ (ds : List Nat) (p : Pool), Inv L p → ds.sum ≤ held L p →
paidAll p ds ≤ realSol L p
| [], _, _, _ => Nat.zero_le _
| d :: ds, p, h, hsum => by
have hd : d ≤ held L pThe headline: from launch, after any history of trades, the pool can pay out every holder.
theorem always_solvent (L : Launch) {p : Pool} (h : Reach L p) : sellOut p (held L p) ≤ realSol L pAnd it never holds more tokens than it started with, nor less SOL.
theorem reach_bounds (L : Launch) {p : Pool} (h : Reach L p) : L.s0 ≤ p.vSol ∧ p.vTok ≤ L.t0no overflow within bounds
With reserves under 2⁶⁴ (u64), every intermediate product fits in u128, which is how a Solana program computes it. pump.fun-sized launches are inside the bound.
theorem u64_mul_fits_u128 {a b : Nat} (ha : a < U64) (hb : b < U64) : a * b < U128Every intermediate of a buy fits: the numerator in u128, the denominator and the result in u64, as long as the SOL side after the trade still fits in u64.
theorem buy_no_overflow (p : Pool) (dx : Nat) (ht : p.vTok < U64) (hs : p.vSol + dx < U64) :
p.vTok * dx < U128 ∧ p.vSol + dx < U64 ∧ buyOut p dx < U64 ∧ (buy p dx).vTok < U64 ∧ (buy p dx).vSol < U64theorem sell_no_overflow (p : Pool) (dy : Nat) (hs : p.vSol < U64) (ht : p.vTok + dy < U64) :
p.vSol * dy < U128 ∧ p.vTok + dy < U64 ∧ sellOut p dy < U64 ∧ (sell p dy).vSol < U64 ∧ (sell p dy).vTok < U64Reachable pools stay in u64: the token side never grows past launch, and the SOL side is bounded by launch SOL plus whatever was deposited.
theorem reach_vTok_fits (L : Launch) (hL : L.t0 < U64) {p : Pool} (h : Reach L p) : p.vTok < U64theorem pump_reserves_fit : pumpLaunch.s0 < U64 ∧ pumpLaunch.t0 < U64
theorem pump_k_fits : pumpLaunch.s0 * pumpLaunch.t0 < U128
basic bounds
A trade never pays out more than the pool holds, and zero in gives zero out.
A buy never hands out more tokens than the pool holds.
theorem buyOut_le_vTok (p : Pool) (dx : Nat) : buyOut p dx ≤ p.vTok
A sell never pays out more lamports than the virtual SOL reserve.
theorem sellOut_le_vSol (p : Pool) (dy : Nat) : sellOut p dy ≤ p.vSol
Zero in, zero out.
theorem buyOut_zero (p : Pool) : buyOut p 0 = 0
theorem sellOut_zero (p : Pool) : sellOut p 0 = 0
The rounding fact behind everything: out·(vSol+dx) ≤ vTok·dx.
theorem buyOut_mul_le (p : Pool) (dx : Nat) : buyOut p dx * (p.vSol + dx) ≤ p.vTok * dx
theorem sellOut_mul_le (p : Pool) (dy : Nat) : sellOut p dy * (p.vTok + dy) ≤ p.vSol * dy
how to check it yourself
- Install Lean with elan, pinned to the same version:
curl https://elan.lean-lang.org/elan-init.sh -sSf | sh -s -- -y --default-toolchain leanprover/lean4:v4.36.0
- Download the file and check its hash matches the one above:
curl -sO https://leanfun.online/LeanFun.lean sha256sum LeanFun.lean
- Compile it. No output and exit code 0 means every theorem checked:
lean LeanFun.lean && echo ok
- Confirm nothing was assumed. Add this line to the end of the file, run lean again, and you should see only propext and Quot.sound:
#print axioms LeanFun.always_solvent
- Search for skipped proofs. This should print nothing:
grep -n "sorry\|admit\|axiom " LeanFun.lean
is the site really using this curve?
The browser computes the lean model quotes with a line-for-line BigInt port of the Lean definitions. A differential test feeds 3,000 random pools and trades through Lean’s own evaluator and through the port, and compares every output. Latest run: 3,000 vectors, 0 mismatches.