Documentation Index
Fetch the complete documentation index at: https://docs.geode.ag/llms.txt
Use this file to discover all available pages before exploring further.
Overview
ConstantProductCurveLib implements the Geocurve bonding curve math. It uses a virtual constant-product formula — the same x × y = k as Uniswap, but with virtual reserves that anchor the starting price.
This library handles all launch-mode settlement: computing the clearing price from the curve, determining fills, and calculating how many tokens to dispense or absorb.
Curve Formula
| Variable | Meaning |
|---|---|
| Vt | Virtual token reserve (immutable, ≥ totalSupply) |
| Ve | Virtual ETH reserve (immutable) |
| S | Cumulative tokens distributed |
| E | Cumulative real ETH raised |
| K | Invariant constant |
Core Functions
computeLaunchSettlement()
Main entry point for launch-mode batch settlement. Replaces ClearingPriceLib.computeClearingPrice() during the Active phase.
- Computes the current curve price as the clearing price
- Determines which intents fill at that price
- Deducts settlement fees from inputs
- Computes internal match amounts
- Calculates
curveDispensed(net buy residual → tokens from hook) andcurveAbsorbed(net sell residual → tokens back to hook) - Computes deployer royalty
curvePrice()
Returns the current marginal price on the curve:
ethCostToBuy()
How much ETH to buy deltaTokens from the current state:
tokensForEth()
How many tokens for spending ethIn ETH:
ethReturnOnSell()
How much ETH returned for selling deltaTokens:
Price Behavior
| Action | S | E | Price |
|---|---|---|---|
| Buy | ↑ increases | ↑ increases | ↑ rises |
| Sell | ↓ decreases | ↓ decreases | ↓ falls |
| Nothing | unchanged | unchanged | unchanged |
Source
ConstantProductCurveLib.sol
View the full source code on GitHub (~269 lines).