Skip to main content

Overview

The RektHubFactory is the central hub of the RektHub protocol. It’s your single entry point for creating creator tokens, trading, and managing the entire token lifecycle. Think of it as the conductor of an orchestra, coordinating token creation, routing trades, and managing graduations across the creator economy.
For Integrators: Always use the Factory as your primary interface. It ensures consistency, proper fee distribution, and seamless cross-contract interactions.

Purpose & Architecture

What It Does

  • Token Creation: Deploys new creator tokens with bonding curves
  • Trade Routing: Routes buy/sell orders to the correct bonding curve
  • Fee Management: Collects platform fees
  • Graduation Control: Manages token migration to DEX (owner-only)
  • Address Discovery: Maps tokens to their bonding curves

Why It Matters

The Factory pattern provides:
  • Gas Efficiency: Uses minimal proxies (EIP-1167) to clone implementations
  • Isolation: Each token gets its own bonding curve with isolated state
  • Upgradeability: New features can be added without affecting existing tokens (not an upgradeable contract though)
  • Single Source of Truth: All critical operations go through one audited contract

Key Functions

Token Creation

createToken

string
required
Token name (e.g., “Creator Coin”)
string
required
Token symbol (e.g., “CRTR”)
string
required
URI pointing to token metadata JSON
Returns:
  • tokenAddress: Address of the deployed token
  • curveAddress: Address of the bonding curve
Events Emitted:
  • TokenCreated
Example:
Metadata Best Practices: Host your tokenURI on IPFS or Arweave for permanence. Include name, description, image, and social links. See Token Contract for JSON format.

createTokenDeterministic

Create a token with a vanity address using CREATE2.
string
required
Token name
string
required
Token symbol
string
required
Metadata URI
bytes32
required
CREATE2 salt (pre-mined for vanity address)
Returns:
  • tokenAddress: Deterministic token address
  • curveAddress: Deterministic curve address
Events Emitted:
  • TokenCreated
Example:
Address Collision: Always check if the predicted address is available before calling createTokenDeterministic. The transaction will revert if the address is occupied.

predictAddresses

Preview the addresses that will be created with a given salt.
bytes32
required
CREATE2 salt
Returns:
  • predictedToken: Token address that will be created
  • predictedCurve: Curve address that will be created
Example:

Trading Functions

buy

Purchase creator tokens from any deployed curve.
address
required
Address of the token to buy
uint256
required
Minimum tokens expected (slippage protection)
Returns:
  • tokensReceived: Actual amount of tokens received
Events Emitted:
  • TokenPurchased
Example:
Always get a quote before buying. Prices move based on bonding curve math, protect users with minTokensOut.

sell

Sell creator tokens back to the bonding curve.
address
required
Address of the token to sell
uint256
required
Amount of tokens to sell
uint256
required
Minimum native tokens expected (slippage protection)
Returns:
  • nativeReceived: Amount of native tokens received
Events Emitted:
  • TokenSold
Example:

sellPercentage

Sell a percentage of your token balance, perfect for “Sell 25%” buttons.
address
required
Address of the token to sell
uint256
required
Percentage in basis points (5000 = 50%, 10000 = 100%)
uint256
required
Minimum native tokens expected
Returns:
  • nativeReceived: Amount of native tokens received
Events Emitted:
  • TokenSold
Example:
Basis Points: 100 basis points = 1%. So 2500 = 25%, 5000 = 50%, 10000 = 100%.

Admin Functions

migrate

Graduate a bonded token to DEX. Owner-only function.
address
required
Address of the token to migrate
address
required
Address of the DEX migrator contract
Returns:
  • poolAddress: Address of the created liquidity pool
  • platformName: Name of the DEX platform
Events Emitted:
  • TokenMigrated
Requirements:
  • Token must be bonded (all 850M tradeable tokens sold)
  • Token must not already be graduated
  • Caller must be contract owner
  • Migrator must implement IDEXMigrator interface
Example:
For Creators: You cannot manually trigger migration. Graduation is handled by RektHub’s automated systems after your token bonds and you select your preferred DEX.

withdrawFees

Withdraw accumulated platform fees. Owner-only function. Example:

View Functions

getCurve

Get the bonding curve address for a token.
address
required
Token address
Returns:
  • address: Bonding curve address
Example:

getCreationFee

Get the current token creation fee. Returns:
  • uint256: Creation fee in native tokens
Example:

Events

TokenCreated

Emitted when a new token is deployed.
Use Cases:
  • Track new token launches
  • Build trending token feeds
  • Creator analytics dashboards

TokenPurchased

Emitted when tokens are bought through the factory.
Use Cases:
  • Real-time trade feeds
  • Price charts and volume tracking
  • Creator earnings dashboards

TokenSold

Emitted when tokens are sold through the factory.

TokenMigrated

Emitted when a token graduates to DEX.

FeesWithdrawn

Emitted when platform fees are withdrawn.

Integration Tips

Always Use Factory for Consistency

Handle Events Efficiently

Multi-Chain Setup


Next Steps

Bonding Curve Contract

Learn about the trading engine

Token Contract

Understand creator token standards

Buying Guide

Deep dive into buying patterns

Events Reference

Complete events documentation