Bonding Curve & Batch Clearing
The bonding-curve rules live permanently inside Genesis Inscription G. Every calculation uses deterministic BigInt integer arithmetic with no floating-point numbers, ensuring every browser reaches the exact same state.
Transaction Primitives
The v1 protocol defines six transaction types:
| Type | Fields | Purpose |
|---|---|---|
TRANSFER | to, tokenId, amount, fee | Send I0 (tokenId = 0) or any launched token |
LAUNCH | ticker, name, artId, initialBuy, fee | Launch a token, referencing any Bitcoin inscription ID for its permanent art |
BUY | tokenId, i0In, minTokOut, fee | Buy tokens from a bonding curve or graduated pool |
SELL | tokenId, tokIn, minI0Out, fee | Sell tokens back to a bonding curve or graduated pool |
HTLC_LOCK | recipient, amount, hashlock, timeoutHeight, fee | Lock I0 for an atomic Bitcoin swap |
HTLC_CLAIM / HTLC_REFUND | swapId, preimage | Claim locked I0 with a secret preimage, or refund after timeout |
Uniform Batch Clearing
In a sequential mempool, bots and miners can reorder transactions to front-run or sandwich traders. eyezero eliminates ordering MEV by clearing all buys and sells for a token within a block at a single uniform price.
Let a token’s virtual plus real reserves be:
\[ X = V_{I0} + R_{I0}, \qquad Y = V_{\text{tok}} + R_{\text{tok}} \]
For each token traded in a block:
-
Deduct the 1% trading fee from each order’s input and credit it to
B.miner. -
Sum all net buy inputs \( B = \sum b_i \) (in I0) and all net sell inputs \( S = \sum s_j \) (in token).
-
Compute total batch payouts using floor integer division:
\[ \text{out}_{\text{tok}} = \left\lfloor \frac{B \cdot (Y + S)}{X + B} \right\rfloor, \qquad \text{out}_{I0} = \left\lfloor \frac{S \cdot (X + B)}{Y + S} \right\rfloor \]
- Distribute payouts pro-rata to each buyer and seller:
\[ \text{buyer}_i \text{ receives } \left\lfloor \frac{b_i \cdot \text{out}_{\text{tok}}}{B} \right\rfloor, \qquad \text{seller}_j \text{ receives } \left\lfloor \frac{s_j \cdot \text{out}_{I0}}{S} \right\rfloor \]
- Update the reserves:
\[ X^{\prime} = X + B - \text{out}_{I0}, \qquad Y^{\prime} = Y + S - \text{out}_{\text{tok}} \]
Properties
-
Zero sandwiching: Every buyer and seller in the block receives the exact same effective price \( P = (X + B) / (Y + S) \), independent of transaction order.
-
Standard curve reduction: When only buys occur (\( S = 0 \)) or only sells occur (\( B = 0 \)), the formula reduces identically to standard constant-product \( x \cdot y = k \).
-
Guaranteed solvency: For any mix of buys and sells, \( X^{\prime} \cdot Y^{\prime} \ge X \cdot Y \) and \( R_{I0}^{\prime} \ge 0 \) always hold, with rounding dust staying in the pool.
-
Slippage protection: Every included order must satisfy
actualOut >= order.minOutat the block’s clearing price, or the entire block is rejected. -
Graduation: Once real reserve \( R_{I0} \) reaches
GRAD_TARGET, the bonding curve transitions seamlessly into a permanently locked AMM pool using the same batch-clearing formula.
Live Trading UX
When a trader clicks Buy, their browser signs an order with their next sequential nonce and gossips it over Entmoot (#i0-tx). Connected browsers receive the order in under a second, apply applyBlock() locally as a preview, and update charts and balances clearly labeled as Pending.
Traders may chain multiple pending orders within the same ten-minute window using incrementing nonces. Once the next 000000…i0 block confirms on Bitcoin, included pending balances flip to Final.
Sandbox Wallet Keys
Because ord serves inscriptions inside a strict sandboxed iframe where browser wallet extensions are normally unavailable, the Genesis Inscription manages a local BIP-340 Schnorr (secp256k1) trading keypair in IndexedDB. Users can back it up as a 12-word recovery phrase and only need their external Bitcoin wallet when mining blocks or executing L1 HTLC swaps.