A decentralized token launchpad system built on Ethereum and compatible chains, enabling users to create and launch new tokens with automated liquidity provision using concentrated liquidity market makers (CLMM).
The Token Launchpad System is a comprehensive smart contract framework that allows users to:
- Create tokens using CREATE2 for deterministic addresses
- Launch tokens with automatic liquidity provision on CLMM pools
- Trade tokens immediately after launch
- Manage fees with configurable distribution
- Integrate with DEX aggregators (e.g., ODOS) for seamless swaps
The system uses an adapter pattern to support multiple CLMM protocols (currently Ramses on Linea) and can be extended to support additional DEXs.
- Token Creation: Deploy ERC20 tokens with deterministic addresses using CREATE2
- Automatic Liquidity: Automatically adds concentrated liquidity across multiple tick ranges
- NFT Ownership: Each launched token is represented as an NFT, granting ownership and fee claims
- Fee Distribution: Configurable fee distribution to referral system, treasury, and token owners
- Safe Approvals: Implements safe approval patterns to prevent unbounded approval vulnerabilities
- Upgradeable Contracts: Uses OpenZeppelin's upgradeable pattern for main contracts
- CLMM Integration: Supports concentrated liquidity market makers with multiple tick ranges
- Graduation System: Tokens launch with predefined liquidity amounts and can "graduate" when certain price levels are reached
- DEX Aggregator Support: UIHelper contract enables integration with aggregators like ODOS for multi-hop swaps
- Multi-Chain Ready: Designed to support multiple chains with chain-specific implementations
contracts/
├── launchpad/
│ ├── TokenLaunchpad.sol # Base launchpad contract (abstract)
│ ├── TokenLaunchpadLinea.sol # Linea-specific implementation
│ └── clmm/
│ ├── adapters/
│ │ ├── BaseV3Adapter.sol # Base adapter for CLMM protocols
│ │ └── RamsesAdapter.sol # Ramses-specific adapter implementation
│ └── UIHelper.sol # Helper contract for UI/DEX aggregator integration
├── SomeToken.sol # ERC20 token implementation for launched tokens
├── SomeMasterToken.sol # Funding token (SOME)
├── SomeProxy.sol # Custom proxy implementation
├── SomeTimelock.sol # Timelock controller for governance
├── interfaces/ # Contract interfaces
└── utils/
└── SafeApproval.sol # Safe approval utility library
The main launchpad contract that:
- Manages token creation and launches
- Mints NFTs for each launched token
- Handles fee claims and distribution
- Manages launch tick parameters
Adapter pattern implementation for CLMM protocols:
- BaseV3Adapter: Abstract base class with common functionality
- RamsesAdapter: Concrete implementation for Ramses DEX on Linea
Adapters handle:
- Pool creation
- Single-sided liquidity provision
- Fee collection
- Token swaps
Helper contract that enables:
- Integration with DEX aggregators (ODOS)
- Multi-hop swaps
- Wrapped ETH handling
- Simplified user interactions
-
Clone the repository
git clone <repository-url> cd Token_Launchpad_System
-
Install dependencies
# Install Foundry dependencies (submodules) git submodule update --init --recursive # Install Node.js dependencies yarn install
-
Set up environment variables
cp .env.example .env # Edit .env with your configuration
Using Foundry:
forge buildUsing Hardhat:
yarn compile
# or
npx hardhat compileUsing Foundry:
# Run all tests
forge test
# Run with gas reporting
forge test --gas-report
# Run specific test file
forge test --match-path test/TokenLaunchpadTest.solUsing Hardhat:
npx hardhat testFoundry's formatter:
forge fmtThe contracts are optimized with:
- Solidity compiler optimizations (10,000 runs)
- Efficient storage patterns
- Safe approval patterns to minimize gas
The test suite includes:
- TokenLaunchpadTest.sol: Main launchpad functionality tests
- TokenLaunchpadLineaTest.sol: Linea-specific implementation tests
- RamsesAdapterTest.sol: Ramses adapter tests
- SafeApprovalTest.sol: Safe approval utility tests
- SomeTokenTest.sol: Token contract tests
- SomeProxyTest.sol: Proxy contract tests
- SomeTimelockTest.sol: Timelock tests
- UIHelperTest.sol: UI helper contract tests
Run all tests:
forge test -vvv-
Configure networks in
hardhat.config.ts -
Set up deployment scripts in
deploy/directory -
Deploy contracts:
npx hardhat deploy --network linea
deploy/test.ts: Test deployment scriptdeploy/mainnet-template.ts: Mainnet deployment templatedeploy/utils.ts: Deployment utilities
- Deploy funding token (SomeMasterToken) or use existing
- Deploy CLMM adapter (e.g., RamsesAdapter)
- Deploy TokenLaunchpad implementation
- Deploy proxy (SomeProxy) pointing to implementation
- Initialize launchpad contract
- Set launch ticks (launchTick, graduationTick, upperMaxTick)
- Configure fee distribution addresses (for chain-specific implementations)
Main Functions:
initialize(): Initialize the launchpad with owner, funding token, and adaptercreateAndBuy(): Create a new token and optionally buy tokens at launchclaimFees(): Claim accumulated trading fees for a tokensetLaunchTicks(): Update launch tick parameters (owner/cron only)computeTokenAddress(): Compute deterministic token address before deployment
Constants:
GRADUATION_AMOUNT: 600,000,000 tokens (60% of supply)POST_GRADUATION_AMOUNT: 400,000,000 tokens (40% of supply)
Main Functions:
addSingleSidedLiquidity(): Add liquidity across three tick rangesswapWithExactInput(): Execute swap with exact input amountswapWithExactOutput(): Execute swap with exact output amountclaimFees(): Collect fees from liquidity positions
Tick Management:
TICK_SPACING: 200 (fixed for CLMM pools)- Validates tick ordering:
tick0 < tick1 < tick2 - Ensures ticks are aligned to tick spacing
- Validates ticks are within valid range (MIN_TICK < tick0, tick2 < MAX_TICK)
Simple ERC20 token with:
- 1 billion token supply (1,000,000,000 * 1e18)
- Ownable (but ownership is renounced in constructor)
- Standard ERC20 functionality
Chain-specific implementation that:
- Distributes fees: 15% to referral contract, 50% to treasury, 35% to token owner
- Configurable referral and treasury addresses
The system uses three tick parameters:
- launchTick: Initial price tick for token launch
- graduationTick: Price tick that represents graduation milestone
- upperMaxTick: Maximum price tick for liquidity range
All ticks must:
- Be aligned to
TICK_SPACING(200) - Follow ordering:
launchTick < graduationTick < upperMaxTick - Be within valid range:
MIN_TICK < launchTickandupperMaxTick < MAX_TICK
Fees are collected from trading activity and distributed according to chain-specific rules. For Linea:
- 15% to referral contract
- 50% to somETHing treasury
- 35% to token owner (NFT holder)
- Reentrancy Protection: All external calls are protected with reentrancy guards
- Safe Approvals: Uses SafeApproval library to prevent unbounded approvals
- Access Control: OpenZeppelin's Ownable and AccessControl patterns
- Upgradeable Pattern: Uses proxy pattern with initialization protection
- Input Validation: Comprehensive validation of tick parameters and addresses
- Always verify contract addresses before deployment
- Use deterministic addresses (CREATE2) for token creation
- Validate tick parameters carefully
- Test thoroughly on testnets before mainnet deployment
- Review fee distribution logic for your use case
Currently configured for:
- Linea: Mainnet and testnet
- Base: Mainnet
- BSC: Binance Smart Chain
- Hardhat: Local development and forking
Additional networks can be added in hardhat.config.ts and foundry.toml.
@uniswap/v4-core: Uniswap V4 core libraries@uniswap/v4-periphery: Uniswap V4 periphery contracts@openzeppelin/contracts: OpenZeppelin contracts@openzeppelin/contracts-upgradeable: OpenZeppelin upgradeable contracts
- Hardhat: Development environment
- Ethers.js: Ethereum library
- TypeScript: Type safety
- Various Hardhat plugins for testing, deployment, and verification
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Follow Solidity style guide
- Use Foundry's formatter:
forge fmt - Write comprehensive tests for new features
- Document complex logic with NatSpec comments
This project is licensed under AGPL-3.0-or-later - see the LICENSE file for details.
For questions, issues, or contributions, please open an issue on GitHub.