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 curve-mode settlement: computing the clearing price from the curve, determining fills, and calculating how many tokens to dispense or absorb.
Curve Formula
Core Functions
computeLaunchSettlement()
Main entry point for curve-mode batch settlement. Replaces ClearingPriceLib.computeClearingPrice() for curve pools.
- 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
The curve is fully reversible — tokens can be bought and sold at any time. The curve is permanent; there is no graduation or migration.
Source
ConstantProductCurveLib.sol
View the full source code on GitHub (~269 lines).