Bonding Curve Stage Trading

This guide covers coin trading during the Bonding Curve stage which is executed through the Basememe Factory contract.

Coins can be configured with different collateral pairs on Base (ETH / USDC / SOL). The trading flow depends on whether a coin uses native ETH collateral (tokenToCollateralToken(token) == address(0)) or an ERC20 collateral token.

Buy Coins with Exact Collateral Value

The buyExactInWithCollateral method accepts a specified collateral amount and buys the maximum possible number of coins for that input.

Method Interface

// solidity interface 

/// @notice Buy maximum coin with specified collateral amount
///
/// @param _token The token contract address
/// @param _collateralAmountIn The amount of collateral to spend on buying token
/// @param _amountOutMin The minimum amount of token expected to receive for collateral amount sending in
/// @param _tradeReferrer The Trade Referrer address to receive reward
function buyExactInWithCollateral(
    address _token,
    uint256 _collateralAmountIn,
    uint256 _amountOutMin,
    address _tradeReferrer
)
    external
    payable;

Payment notes

  • For ETH-collateral coins, send msg.value == _collateralAmountIn.

  • For ERC20-collateral coins (e.g. USDC / SOL), msg.value must be 0 and the caller must approve the Factory to spend _collateralAmountIn of the collateral token.

Events

A Buy event will be emitted upon successful coin purchase.


Buy Coins with Exact Collateral Value (ETH Pair Only)

The buyExactIn method is the legacy ETH-only exact-in entrypoint. It only works for coins whose collateral pair is native ETH and will revert for coins that use ERC20 collateral (e.g. USDC / SOL). For multi-collateral support, use buyExactInWithCollateral.

Method Interface

Events

A Buy event will be emitted upon successful coin purchase.


Buy Exact Coin Amount

The buyExactOut method allows the buyer to specify the exact number of coins to purchase, while setting a maximum collateral amount willing to spend.

Payment notes

  • For ETH-collateral coins, send your max as msg.value and set _maxCollateralAmount accordingly.

  • For ERC20-collateral coins (e.g. USDC / SOL), do not send ETH (msg.value should be 0) and approve the Factory to spend up to _maxCollateralAmount of the collateral token.

Method Interface

Events

A Buy event will be emitted upon successful coin purchase.


Sell Exact Coin Amount

The sellExactIn method accepts the exact number of coins to sell and receives at least the minimum expected collateral amount in return. The collateral received depends on the coin's selected collateral pair (ETH / USDC / SOL).

Events

A Sell event will be emitted upon successful coin sale.


Sell Coins for Exact Collateral Value

The sellExactOut method accepts the exact collateral amount to receive upon coin sale, with the required coin amount (up to a maximum) specified. The collateral received depends on the coin's selected collateral pair (ETH / USDC / SOL).

Events

A Sell event will be emitted upon successful coin sale.

Last updated