Skip to main content

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.
Behavior:
  1. Computes the current curve price as the clearing price
  2. Determines which intents fill at that price
  3. Deducts settlement fees from inputs
  4. Computes internal match amounts
  5. Calculates curveDispensed (net buy residual → tokens from hook) and curveAbsorbed (net sell residual → tokens back to hook)
  6. 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.
Asymptotic pricing: When Vt = totalSupply, the price approaches infinity as 100% of tokens are distributed. When Vt > totalSupply, the curve has a finite maximum price at full distribution.

Source

ConstantProductCurveLib.sol

View the full source code on GitHub (~269 lines).