The curve
A constant-product curve, like the ones you know, with one difference: its starting point is set by the creator in the units of the pair.
Constants
| Name | Value | Meaning |
|---|---|---|
SUPPLY | 1,000,000,000e18 | Total coins, minted once |
SELLABLE (S) | 800,000,000e18 | Sold along the curve |
LIQ (L) | 200,000,000e18 | Held for the pool |
VT | S² / (S − L) = 1.0667e27 | Virtual coin reserve |
FEE_BPS | 100 | 1% on every curve trade |
State and the invariant
Each coin stores vPair (the virtual pair reserve), raised (pair tokens held, net of fees) and sold (coins sold). With
x = vPair + raised // pair side y = VT - sold // coin side k = vPair * VT // the curve: x * y = k
every trade keeps x * y ≥ k, rounding in the curve's favour.
From the opening cap to the curve
vPair = startCap * VT / SUPPLY
startCap is the market cap you want at the start, in raw pair units. That one number fixes everything else:
| Quantity | Formula | Example: 5,000 USDG |
|---|---|---|
| Amount raised at graduation | 3 × vPair | 16,000 USDG |
| Buyers pay (with the 1% fee) | raise / 0.99 | 16,162 USDG |
| Market cap at graduation | 16 × startCap | 80,000 USDG |
Why 800M / 200M and VT
The pool must open at the price the curve ended on, using everything that was raised and the 200M coins that were kept. Writing the curve's closing price and the pool's opening price as the same number gives VT = S² / (S − L). With S = 800M and L = 200M that is 1.0667e27, close to the virtual reserve other bonding-curve launchpads use. The result: no gap between the last curve price and the first pool price, and no pair left over.
Buying
fee = gross * 100 / 10000 net = gross - fee out = y - ceil(k / (x + net))
If sold + out would pass 800M, the buy is capped: out = S - sold, the contract recomputes the net it needs, takes the matching fee, and refunds the rest.
Selling
grossOut = x - ceil(k / (y + tokensIn)) fee = grossOut * 100 / 10000 userOut = grossOut - fee
A worked example
These are numbers printed by the real contract on a fork of Robinhood Chain: a coin opened at 5,000 USDG (vPair = 5,333,333,333 raw), then four buys. USDG is only an example here: the same arithmetic holds for any pair, in that pair's units.
| Buy | Coins received | Raised after | Sold after |
|---|---|---|---|
| 100 USDG | 19,439,160 | 99 USDG | 19.4M |
| 1,000 USDG | 161,429,682 | 1,089 USDG | 180.9M |
| 5,000 USDG | 385,558,451 | 6,039 USDG | 566.4M |
| 40,000 USDG | 233,572,705 (the rest of the 800M) | 16,000 USDG | 800M, curve full |
The last buyer offered 40,000 USDG and spent 10,061.62. The rest was refunded. The site's engine (engine.js) reproduces every one of these numbers exactly, and a test in the repository checks it against the contract's output.