Architecture Overview
Product Flow in Detail
1
Phase 1: Token Creation
What happens:
- User calls
deployBondkitToken()
on the Factory contract - Factory clones the Implementation contract using minimal proxy pattern
- New token is initialized with custom parameters
- Token enters bonding phase automatically
2
Phase 2: Bonding Curve Trading
What happens:
- Users buy/sell tokens directly from the contract
- Price follows algorithmic bonding curve:
S = S_final × (R/R_target)^exponent
- 5% fee on all trades goes to fee recipient
- Contract accumulates quote assets (ETH/B3) toward target
- Backend indexes all transactions for analytics
- Buy: Send ETH/B3, receive tokens at current curve price
- Sell: Send tokens, receive ETH/B3 minus fees
- Automatic refunds if purchase would exceed target
3
Phase 3: DEX Migration
What happens:
- Admin calls
migrateToDex()
when target is reached - Contract calculates fair market price as
sqrtPriceX96
- Creates and initializes Uniswap v4 pool
- Transfers accumulated liquidity to pool
- Renounces ownership to zero address
- Token becomes standard ERC20 with DEX trading
- Bonding curve permanently disabled
- All trading via Uniswap v4
- No admin controls remain
- Full decentralization achieved
System Components
Smart Contracts
🏭 Factory Contract
🏭 Factory Contract
Purpose: Deploys new bond tokens efficientlyKey Functions:
deployBondkitToken()
- Creates new token clonegetImplementationAddress()
- Returns template addresssetAllowedQuoteAsset()
- Admin function to whitelist assets
- Uses EIP-1167 minimal proxy pattern
- Shares logic across all tokens
- ~90% gas savings vs individual deployments
📜 Implementation Contract
📜 Implementation Contract
Purpose: Template for all bond tokensCore Features:
- ERC20 standard compliance
- Bonding curve mathematics
- Migration logic to Uniswap v4
- Fee distribution system
- Uninitialized → Bonding Phase
- Bonding Phase → Migration Ready
- Migration Ready → DEX Phase
🪙 Token Clones
🪙 Token Clones
Purpose: Individual token instancesLifecycle:
- Created via factory
- Initialized with unique parameters
- Manages its own bonding curve
- Self-migrates to Uniswap v4
- Token metadata (name, symbol)
- Supply and distribution
- Bonding curve state
- Migration parameters
Backend Services
🔍 Event Indexer
🔍 Event Indexer
Purpose: Captures all on-chain activityMonitors:
- Token creations
- Buy/sell transactions
- Migration events
- Transfer activities
- Real-time blockchain scanning
- Event log processing
- Database synchronization
📊 Analytics Engine
📊 Analytics Engine
Purpose: Processes raw data into insightsGenerates:
- OHLCV candlestick data
- Volume metrics
- Liquidity tracking
- Price history
- User statistics
🌐 REST API
🌐 REST API
Purpose: Serves data to frontendsEndpoints:
/tokens
- List all tokens/tokens/{address}
- Token details/tokens/{address}/transactions
- Trade history/tokens/{address}/ohlcv
- Chart data/users/{address}/portfolio
- User holdings
User Roles
Role | Responsibilities | Permissions |
---|---|---|
Creator | Deploy token, set parameters, initiate migration | Full control until migration |
Traders | Buy/sell during bonding, trade on DEX | Standard trading rights |
Fee Recipient | Receive trading fees | Passive income only |
Migration Admin | Execute migration when ready | One-time migration right |
LP Providers | (Post-migration) Add liquidity to Uniswap | Standard LP rights |
Technical Deep Dive
Bonding Curve Mathematics
The bonding curve determines token price based on supply:Aggressiveness | Exponent | Price Behavior |
---|---|---|
0 | 1.00 | Linear (constant price) |
25 | 0.80 | Gentle curve |
50 | 0.67 | Moderate curve |
75 | 0.57 | Steep curve |
100 | 0.50 | Very steep (square root) |
Migration Price Calculation
When migrating to Uniswap v4, the contract:- Calculates exit price from bonding curve
- Converts to sqrtPriceX96 format:
- Initializes pool with this price
- Adds liquidity using accumulated funds
Gas Optimization Techniques
Minimal Proxy Pattern (EIP-1167)Instead of deploying full contract code for each token:
- Deploy one implementation contract (600KB)
- Deploy tiny proxy contracts (45 bytes each)
- Proxies delegate all calls to implementation
- Result: 90% gas savings per deployment
Configuration Parameters
Token Creation Parameters
Parameter | Type | Range/Format | Impact |
---|---|---|---|
name | string | 1-50 chars | Token display name |
symbol | string | 2-10 chars | Trading symbol |
finalTokenSupply | uint256 | > 0 | Total mintable tokens |
aggressivenessFactor | uint8 | 0-100 | Curve steepness |
targetEth | uint256 | > 0 | Migration threshold |
feeRecipient | address | Valid address | Receives fees |
lpSplitRatioFeeRecipientBps | uint256 | 0-10000 | LP fee share (basis points) |
migrationAdminAddress | address | Valid address | Can trigger migration |
Runtime Parameters
Action | Parameters | Validation |
---|---|---|
Buy | minTokensOut , ethAmount | Slippage protection |
Sell | tokenAmount , minEthOut | Balance check, slippage |
Migrate | None | Target reached, admin only |
System Constants
Constant | Value | Description |
---|---|---|
Trading Fee | 5% | Applied to all trades |
Decimals | 18 | Standard ERC20 decimals |
Min Target | 0.1 ETH | Minimum viable target |
Max Aggressiveness | 100 | Maximum curve factor |
Security Considerations
Important Security Features:
- Ownership Renouncement: Automatic after migration
- No Mint Function: Supply fixed at creation
- Immutable Parameters: Cannot be changed post-deployment
- Audited Contracts: Professionally reviewed code
- No Admin Backdoors: True decentralization
- Slippage Protection: Built into buy/sell functions
- Overflow Protection: Safe math throughout
Failure Scenarios & Handling
Scenario | System Response |
---|---|
Buy exceeds target | Partial fill, refund excess |
Insufficient liquidity for sell | Transaction reverts |
Migration before target | Transaction reverts |
Non-admin attempts migration | Transaction reverts |
Double migration attempt | Transaction reverts |
Zero address operations | Transaction reverts |