Skip to main content

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
Gas cost: ~200,000 gas (90% cheaper than full deployment) Time: ~15 seconds
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
Trading mechanics:
  • 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
Duration: Until target is reached (hours to weeks)
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
Post-migration:
  • Bonding curve permanently disabled
  • All trading via Uniswap v4
  • No admin controls remain
  • Full decentralization achieved
Gas cost: ~500,000 gas Time: ~30 seconds

System Components

Smart Contracts

Purpose: Deploys new bond tokens efficientlyKey Functions:
  • deployBondkitToken() - Creates new token clone
  • getImplementationAddress() - Returns template address
  • setAllowedQuoteAsset() - Admin function to whitelist assets
Gas Optimization:
  • Uses EIP-1167 minimal proxy pattern
  • Shares logic across all tokens
  • ~90% gas savings vs individual deployments
Purpose: Template for all bond tokensCore Features:
  • ERC20 standard compliance
  • Bonding curve mathematics
  • Migration logic to Uniswap v4
  • Fee distribution system
State Transitions:
  1. Uninitialized → Bonding Phase
  2. Bonding Phase → Migration Ready
  3. Migration Ready → DEX Phase
Purpose: Individual token instancesLifecycle:
  • Created via factory
  • Initialized with unique parameters
  • Manages its own bonding curve
  • Self-migrates to Uniswap v4
Storage:
  • Token metadata (name, symbol)
  • Supply and distribution
  • Bonding curve state
  • Migration parameters

Backend Services

Purpose: Captures all on-chain activityMonitors:
  • Token creations
  • Buy/sell transactions
  • Migration events
  • Transfer activities
Technology:
  • Real-time blockchain scanning
  • Event log processing
  • Database synchronization
Purpose: Processes raw data into insightsGenerates:
  • OHLCV candlestick data
  • Volume metrics
  • Liquidity tracking
  • Price history
  • User statistics
Updates: Every block (~2 seconds)
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
Format: JSON with pagination

User Roles

RoleResponsibilitiesPermissions
CreatorDeploy token, set parameters, initiate migrationFull control until migration
TradersBuy/sell during bonding, trade on DEXStandard trading rights
Fee RecipientReceive trading feesPassive income only
Migration AdminExecute migration when readyOne-time migration right
LP Providers(Post-migration) Add liquidity to UniswapStandard LP rights

Technical Deep Dive

Bonding Curve Mathematics

The bonding curve determines token price based on supply:
Price Formula:
S = S_final × (R / R_target)^exponent

Where:
- S = Current token supply
- S_final = Final token supply
- R = Raised amount (ETH/B3)
- R_target = Target amount
- exponent = 1 / (1 + aggressivenessFactor/100)
Example Calculations:
AggressivenessExponentPrice Behavior
01.00Linear (constant price)
250.80Gentle curve
500.67Moderate curve
750.57Steep curve
1000.50Very steep (square root)

Migration Price Calculation

When migrating to Uniswap v4, the contract:
  1. Calculates exit price from bonding curve
  2. Converts to sqrtPriceX96 format:
    sqrtPriceX96 = sqrt(price) × 2^96
    
  3. Initializes pool with this price
  4. 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

ParameterTypeRange/FormatImpact
namestring1-50 charsToken display name
symbolstring2-10 charsTrading symbol
finalTokenSupplyuint256> 0Total mintable tokens
aggressivenessFactoruint80-100Curve steepness
targetEthuint256> 0Migration threshold
feeRecipientaddressValid addressReceives fees
lpSplitRatioFeeRecipientBpsuint2560-10000LP fee share (basis points)
migrationAdminAddressaddressValid addressCan trigger migration

Runtime Parameters

ActionParametersValidation
BuyminTokensOut, ethAmountSlippage protection
SelltokenAmount, minEthOutBalance check, slippage
MigrateNoneTarget reached, admin only

System Constants

ConstantValueDescription
Trading Fee5%Applied to all trades
Decimals18Standard ERC20 decimals
Min Target0.1 ETHMinimum viable target
Max Aggressiveness100Maximum curve factor

Security Considerations

Important Security Features:
  1. Ownership Renouncement: Automatic after migration
  2. No Mint Function: Supply fixed at creation
  3. Immutable Parameters: Cannot be changed post-deployment
  4. Audited Contracts: Professionally reviewed code
  5. No Admin Backdoors: True decentralization
  6. Slippage Protection: Built into buy/sell functions
  7. Overflow Protection: Safe math throughout

Failure Scenarios & Handling

ScenarioSystem Response
Buy exceeds targetPartial fill, refund excess
Insufficient liquidity for sellTransaction reverts
Migration before targetTransaction reverts
Non-admin attempts migrationTransaction reverts
Double migration attemptTransaction reverts
Zero address operationsTransaction reverts

Next Steps

I