A decentralized token launch platform built on MultiversX network, similar to PumpFun, allowing users to create and trade tokens with bonding curve mechanics.
- Token Creation: Create new tokens with custom metadata
- Advanced Bonding Curve Trading: Buy/sell tokens using improved AMM mechanics
- Fee System: Configurable trading and creator fees
- Admin Controls: Administrative functions for contract management
- Pause Functionality: Emergency pause/unpause capabilities
- Comprehensive Views: Extensive query functions for contract state
- Event Logging: Comprehensive event system for tracking interactions
- Input Validation: Robust validation and error handling
- Security Features: Admin-only functions and proper access controls
src/lib.rs- Main contract entry pointsrc/storage.rs- Storage mappers and state variablessrc/endpoints.rs- Contract functions and business logicsrc/events.rs- Event definitionssrc/types.rs- Custom data structuressrc/errors.rs- Error constants and messagessrc/pause.rs- Pause/unpause functionalitysrc/validation.rs- Input validation functionssrc/bonding_curve.rs- Advanced bonding curve calculationssrc/views.rs- Comprehensive view functionssrc/tests.rs- Comprehensive test suitescenarios/- Scenario test filesmeta/- Contract metadata generationwasm/- WASM compilation setup
createToken- Create a new token with metadatagetTokenInfo- Get detailed token informationgetTokenCount- Get total number of tokens created
buyTokens- Buy tokens using EGLDsellTokens- Sell tokens for EGLDgetUserBalance- Get user's token balance
setAdmin- Set new admin addresssetFeeCollector- Set fee collection addresssetTradingFee- Set trading fee percentagesetCreatorFee- Set creator fee percentagesetActive- Enable/disable contract
The contract uses a simplified bonding curve formula:
- Buy:
tokens = payment * k / (reserve + payment) - Sell:
egld = token_amount * reserve / (k + token_amount)
Where:
k= bonding curve constantreserve= EGLD reserve in the curvepayment= EGLD amount being spenttoken_amount= tokens being sold
- Rust 1.70+
- MultiversX CLI tools
multiversx-sc buildmultiversx-sc testmultiversx-sc deploy --proxy=https://testnet-gateway.multiversx.com --chain=T --init-function init --init-args "admin_address" "fee_collector_address"# Send 1 EGLD to create a token
multiversx-sc call <contract-address> createToken \
--args "MyToken" "MTK" 18 1000000000000000000 "My awesome token" \
"https://example.com/image.png" "https://example.com" \
"https://twitter.com/mytoken" "https://t.me/mytoken" \
--value 1000000000000000000# Buy tokens for token ID 1
multiversx-sc call <contract-address> buyTokens \
--args 1 \
--value 500000000000000000# Sell 100 tokens
multiversx-sc call <contract-address> sellTokens \
--args 1 100000000000000000000- Trading Fee: 1% (configurable by admin)
- Creator Fee: 0.5% (configurable by admin)
- Minimum Creation Payment: 1 EGLD
- Modular Design: Separated concerns into dedicated modules (validation, bonding curve, views, etc.)
- Error Handling: Comprehensive error constants and proper error messages
- Input Validation: Robust validation for all user inputs and parameters
- Pause Functionality: Emergency pause/unpause capabilities for contract maintenance
- Improved AMM Mechanics: More sophisticated bonding curve calculations
- Price Impact Calculation: Tools to calculate price impact and slippage
- Dynamic Pricing: Real-time price updates based on trading activity
- Liquidity Management: Better liquidity tracking and management
- Token Metadata: Complete token information including social links
- Trading Information: Real-time trading data, volume, and market cap
- User Positions: Detailed user position tracking with PnL calculations
- Contract Configuration: View all contract settings and parameters
- Top Tokens: Query tokens by volume and other metrics
- Admin Controls: Proper admin-only function protection
- Fee Validation: Fee percentage validation with maximum limits
- Address Validation: Proper address validation for all inputs
- State Validation: Contract state validation before operations
- Scenario Tests: Comprehensive scenario test files
- Unit Tests: Updated unit tests with proper initialization
- Meta Generation: Contract metadata generation setup
- WASM Compilation: Proper WASM compilation configuration
- Admin functions are protected and only callable by the contract admin
- Fee percentages are capped at 10% maximum
- Bonding curve calculations prevent division by zero
- Input validation on all user inputs
- Pause functionality for emergency situations
- Proper address validation and state checks
MIT License - see LICENSE file for details.