Skip to main content

Overview

The BondingCurve contract is the heart of price discovery and trading for creator tokens. Each token gets its own isolated bonding curve instance, think of it as a dedicated trading venue with its own reserves, fees, and state management.
Key Insight: RektHub doesn’t use one global curve. Each creator token has a dedicated BondingCurve contract, ensuring isolated liquidity and independent price action.

Purpose & Design

What It Does

  • Price Discovery: Implements constant product (x*y=k) bonding curve math
  • Trading Engine: Handles all buy/sell transactions for one specific token
  • Fee Management: Accumulates creator fees (30% of trading fees, 60% of migration fees)
  • State Tracking: Manages reserves, bonding status, graduation state
  • Creator Compensation: Stores and distributes earnings to token creators

Why Isolation Matters

Each token having its own curve means:
  • Independent Markets: One token’s activity doesn’t affect another’s liquidity
  • Fair Launch: Every token starts with identical initial conditions
  • Predictable Economics: Creators know exactly how their token will behave
  • Security: A bug or exploit in one curve doesn’t cascade to others

Token Lifecycle States

A bonding curve progresses through three states:
1

Active

Normal trading state. Tokens can be bought and sold freely.
  • s_bonded = false
  • s_graduated = false
2

Bonded

All 850M tradeable tokens have been sold. Token is ready for graduation.
  • s_bonded = true
  • s_graduated = false
  • Trading is disabled
  • Waiting for migration to DEX
3

Graduated

Token has migrated to DEX. Curve is permanently closed.
  • s_graduated = true
  • All trading disabled
  • Reserves transferred to liquidity pool
  • Creator fees still claimable

Key Constants

Token Distribution: - Total Supply: 1,000,000,000 (1B tokens) - Tradeable Supply: 850,000,000 (850M tokens) - Reserved: 150,000,000 (150M tokens for graduation liquidity) - Virtual Reserves: 1,073,000,000 (1.073B for pricing math)

Core Functions

Trading Functions

buy

Purchase creator tokens from the bonding curve.
address
required
Address to receive the tokens
uint256
required
Minimum tokens expected (slippage protection)
Returns:
  • result: TradeResult struct with amounts and fees
  • newReserves: Updated reserve state
Events Emitted:
  • TokenPurchased
  • TokenBonded (if this purchase bonds the token)
Fee Structure:
  • Total fee: 1% of input amount
  • Creator gets: 30% of fee (0.3% of input)
  • Platform gets: 70% of fee (0.7% of input)
Example:
Bonding Trigger: When the last token is purchased, the curve automatically transitions to “bonded” state. All further trading is disabled until graduation.

sell

Sell creator tokens back to the bonding curve.
address
required
Address selling the tokens
uint256
required
Amount of tokens to sell
uint256
required
Minimum native tokens expected (slippage protection)
Returns:
  • result: TradeResult struct
  • newReserves: Updated reserve state
Events Emitted:
  • TokenSold
Fee Structure:
  • Total fee: 1% of output amount
  • Creator gets: 30% of fee
  • Platform gets: 70% of fee
Example:
Direct vs Factory: You can call sell() directly on the curve or through the Factory. Both work identically, but Factory is recommended for consistency.

sellPercentage

Sell a percentage of your token balance.
address
required
Address selling the tokens
uint256
required
Percentage in basis points (5000 = 50%)
uint256
required
Minimum native expected
Returns:
  • tokenAmount: Actual tokens sold
  • result: TradeResult struct
  • newReserves: Updated reserve state
Example:

Creator Functions

claimCreatorFees

Creator claims their accumulated trading and migration fees. Creator-only. Returns:
  • amountClaimed: Amount of fees claimed
Events Emitted:
  • CreatorFeesClaimed
Example:
Fee Accumulation: Fees accumulate in the curve contract over time. Creators can claim whenever they want, there’s no rush, and fees don’t expire.

transferCreator

Transfer creator role to a new address. Creator-only.
address
required
New creator address
Events Emitted:
  • CreatorTransferred
Example:
Irreversible: Once you transfer creator role, you cannot get it back unless the new creator transfers it to you. Use with caution!

Migration Function

migrate

Graduate the token to DEX. Factory-only function.
address
required
DEX migrator contract address (must implement IDEXMigrator)
Returns:
  • poolAddress: Address of created liquidity pool
  • platformName: Name of the DEX
  • nativeLiquidityAdded: Net native liquidity added to pool
  • tokenLiquidityAdded: Token liquidity added to pool
  • migrationFee: Total 12% fee
  • creatorFee: 60% of migration fee (7.2% of liquidity)
  • platformFee: 40% of migration fee (4.8% of liquidity)
Requirements:
  • Token must be bonded (all 850M tokens sold)
  • Token must not be graduated yet
  • Only Factory can call this function
Events Emitted:
  • TokenMigrated
Example:
For Creators: You don’t call this function directly. Once your token bonds, RektHub’s automated systems handle the graduation process after you select your preferred DEX. Your creator fees from the migration will be automatically accumulated.

View Functions

getCurveState

Get complete curve state information. Returns:
  • virtualNativeReserves: Current virtual native reserves
  • virtualTokenReserves: Current virtual token reserves
  • realNativeReserves: Actual native liquidity
  • realTokenReserves: Actual tokens available
  • bonded: Whether all tokens are sold
  • graduated: Whether token has migrated
Example:

getCreatorInfo

Get creator address and accumulated fees. Returns:
  • creatorAddress: Current creator
  • accumulatedFees: Claimable fees
Example:

getBuyPrice

Calculate quote for buying tokens.
uint256
required
Amount of native tokens to spend
Returns:
  • tokensOut: Expected tokens to receive
  • totalFee: Total fee amount
  • creatorFee: Creator’s portion
  • platformFee: Platform’s portion
Example:

getSellPrice

Calculate quote for selling tokens.
uint256
required
Amount of tokens to sell
Returns:
  • nativeOut: Expected native tokens to receive (after fees)
  • totalFee: Total fee amount
  • creatorFee: Creator’s portion
  • platformFee: Platform’s portion
Example:

Bonding Curve Math

RektHub uses a constant product formula: x * y = k Where:
  • x = virtual native reserves
  • y = virtual token reserves
  • k = constant product

Buy Formula

Sell Formula

Why Virtual Reserves? Virtual reserves create an initial price and prevent extreme slippage on early trades. Only real reserves represent actual liquidity.

Price Evolution

As tokens are bought:
  • Virtual native reserves ↑
  • Virtual token reserves ↓
  • Price per token ↑ (exponentially)
Example progression (using 1.5 ETH virtual reserves):
Price progression varies based on virtual native reserves per chain. Values shown are examples using 1.5 ETH. Chains with different native tokens will have equivalent pricing dynamics.

Events

TokenPurchased


TokenSold


TokenBonded

Emitted when the last token is sold and curve enters “bonded” state.

TokenMigrated


CreatorFeesClaimed


CreatorTransferred


Integration Patterns

Build a Trading Dashboard

Monitor Bonding Progress


Next Steps

Token Contract

Learn about the ERC20 token standard

Bonding Curves Explained

Understand the math behind pricing

Migration Process

Learn about token graduation