Bonding Curve Stage Trading

This guide covers Bonding Curve stage trading through the BFun Factory contract.

Trading behavior depends on the coin's collateral type:

  • Native collateral: tokenToCollateralToken(token) == address(0)

  • ERC20 collateral: tokenToCollateralToken(token) != address(0)

Buy Coins with Exact Collateral Value

Use buyExactInWithCollateral for multi-collateral exact-in buys.

function buyExactInWithCollateral(
    address _token,
    uint256 _collateralAmountIn,
    uint256 _amountOutMin
)
    external
    payable;

Payment notes:

  • Native collateral: msg.value == _collateralAmountIn

  • ERC20 collateral: msg.value == 0, and caller approves _collateralAmountIn


Buy Coins with Exact Collateral Value (Native-only Legacy Entry)

buyExactIn is the legacy native-collateral exact-in entrypoint.

For ERC20-collateral markets, use buyExactInWithCollateral.


Buy Exact Coin Amount

Use buyExactOut for exact-out buys.


Sell Exact Coin Amount

Use sellExactIn for exact-in sells.


Sell Coins for Exact Collateral Value

Use sellExactOut for exact-out sells.


Successful trades emit:

  • Buy

  • Sell

For routed calls (trusted caller flows), recipient tracking events may also be emitted:

  • BuyRecipient

  • SellRecipient

See ABI for complete event fields.

Last updated