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 = falses_graduated = false
2
Bonded
All 850M tradeable tokens have been sold. Token is ready for graduation.
s_bonded = trues_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)
result: TradeResult struct with amounts and feesnewReserves: Updated reserve state
TokenPurchasedTokenBonded(if this purchase bonds the token)
- Total fee: 1% of input amount
- Creator gets: 30% of fee (0.3% of input)
- Platform gets: 70% of fee (0.7% of input)
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)
result: TradeResult structnewReserves: Updated reserve state
TokenSold
- Total fee: 1% of output amount
- Creator gets: 30% of fee
- Platform gets: 70% of fee
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
tokenAmount: Actual tokens soldresult: TradeResult structnewReserves: Updated reserve state
Creator Functions
claimCreatorFees
Creator claims their accumulated trading and migration fees. Creator-only.
Returns:
amountClaimed: Amount of fees claimed
CreatorFeesClaimed
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
CreatorTransferred
Migration Function
migrate
Graduate the token to DEX. Factory-only function.
address
required
DEX migrator contract address (must implement IDEXMigrator)
poolAddress: Address of created liquidity poolplatformName: Name of the DEXnativeLiquidityAdded: Net native liquidity added to pooltokenLiquidityAdded: Token liquidity added to poolmigrationFee: Total 12% feecreatorFee: 60% of migration fee (7.2% of liquidity)platformFee: 40% of migration fee (4.8% of liquidity)
- Token must be bonded (all 850M tokens sold)
- Token must not be graduated yet
- Only Factory can call this function
TokenMigrated
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 reservesvirtualTokenReserves: Current virtual token reservesrealNativeReserves: Actual native liquidityrealTokenReserves: Actual tokens availablebonded: Whether all tokens are soldgraduated: Whether token has migrated
getCreatorInfo
Get creator address and accumulated fees.
Returns:
creatorAddress: Current creatoraccumulatedFees: Claimable fees
getBuyPrice
Calculate quote for buying tokens.
uint256
required
Amount of native tokens to spend
tokensOut: Expected tokens to receivetotalFee: Total fee amountcreatorFee: Creator’s portionplatformFee: Platform’s portion
getSellPrice
Calculate quote for selling tokens.
uint256
required
Amount of tokens to sell
nativeOut: Expected native tokens to receive (after fees)totalFee: Total fee amountcreatorFee: Creator’s portionplatformFee: Platform’s portion
Bonding Curve Math
RektHub uses a constant product formula:x * y = k
Where:
x= virtual native reservesy= virtual token reservesk= constant product
Buy Formula
Sell Formula
Price Evolution
As tokens are bought:- Virtual native reserves ↑
- Virtual token reserves ↓
- Price per token ↑ (exponentially)
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
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