KDEX Core is an enhanced fork of Uniswap V2 Core with Infinite Liquidity Pool (ILP) functionality. This protocol introduces an innovative fee structure designed to mitigate impermanent loss for liquidity providers while maintaining full compatibility with the Uniswap V2 ecosystem.
- Dual Fee Structure: 0.36% LP fees + configurable ILP fees per token
- Automated Fee Collection: ILP fees are collected and managed automatically
- Threshold-Based Distribution: Accumulated fees are distributed when thresholds are met
- Per-Token Configuration: Different ILP fee rates can be set for each token
- UniswapV2Factory: Extended with ILP functionality and admin controls
- UniswapV2Pair: Modified with ILP fee collection and advanced fee calculations
- ILPManager: New contract for managing accumulated ILP fees and distributions
- Full Compatibility: Maintains interface compatibility with Uniswap V2
- Comprehensive Test Suite: 43 passing tests covering all functionality
- Gas Optimized: Compiled with 999,999 optimizer runs
- Deployment Ready: Complete deployment system for Base Sepolia and Mainnet
- Contract Verification: Automated BaseScan verification
For detailed technical information, see KDEX Core_ Technical Specifications.md.
- LP Fee: 36 basis points (0.36%) to liquidity providers
- ILP Fee: Configurable per token (e.g., 10 basis points = 0.1%)
- Total Fee: LP Fee + ILP Fee (e.g., 0.46% total with 0.1% ILP fee)
After deployment, contract addresses will be available here and in the deployment records.
- Node.js >= 16
- npm >= 8
# Clone the repository
git clone https://github.com/krain/kdex.git
cd kdex
# Install dependencies
npm install
# Copy environment template (for deployment)
cp env.example .env# Compile contracts
npm run compile
# or
npx hardhat compile
# Run test suite (43 tests)
npm test
# or
npx hardhat test
# Generate gas reports
REPORT_GAS=true npm test
# Type generation
npx hardhat typechain-
Setup Environment
cp env.example .env # Edit .env with your private key and BaseScan API key -
Deploy with Verification
npx hardhat deploy-kdex --network baseSepolia --verify --save
-
Check Deployment
npx hardhat check-deployment --network baseSepolia \ --factory <FACTORY_ADDRESS> --ilpmanager <ILP_MANAGER_ADDRESS>
For detailed deployment instructions, see DEPLOYMENT.md.
- baseSepolia: Base Sepolia testnet
- baseMainnet: Base mainnet
- hardhat: Local development network
# Deploy KDEX Core
npx hardhat deploy-kdex --network <NETWORK> --verify --save
# Verify contracts
npx hardhat verify-kdex --network <NETWORK> \
--factory <ADDRESS> --ilpmanager <ADDRESS> --deployer <ADDRESS>
# Check deployment status
npx hardhat check-deployment --network <NETWORK> \
--factory <ADDRESS> --ilpmanager <ADDRESS>The test suite has been fully modernized and covers all functionality:
# Run all tests
npm test
# Run specific test files
npx hardhat test test/UniswapV2Factory.spec.ts
npx hardhat test test/UniswapV2Pair.spec.ts
npx hardhat test test/ILPManager.spec.ts
# Test with gas reporting
REPORT_GAS=true npm test- β 43 tests passing (0 failing)
- β Full coverage of ILP functionality
- β Gas optimization verified (~5.3M gas total deployment)
- β Production ready with comprehensive testing
- Purpose: Creates and manages trading pairs with ILP functionality
- New Features: ILP manager integration, admin controls
- Interface: Extended IUniswapV2Factory with ILP methods
- Purpose: Handles swaps, liquidity, and fee collection
- New Features: ILP fee calculation, dual fee structure
- Fee Calculation: Optimized for 0.36% LP + variable ILP fees
- Purpose: Manages accumulated ILP fees and distributions
- Features: Threshold-based distribution, per-token configuration
- Access Control: Owner-based administration
KDEX Core maintains full interface compatibility with Uniswap V2, allowing existing tools and frontends to work without modification.
// Set ILP fee rate (10 basis points = 0.1%)
await ilpManager.setIlpFeeRate(tokenAddress, 10);
// Enable/disable ILP fees for a pair
await pair.setIlpFeesEnabled(true);
// Deposit accumulated fees
await ilpManager.depositFee(tokenAddress, amount);// Set fee recipient
await factory.setFeeTo(feeRecipient);
// Update ILP manager
await factory.setIlpManagerAddress(newIlpManager);- Audited Codebase: Based on battle-tested Uniswap V2 Core
- Comprehensive Testing: 43 tests covering all functionality
- Gas Optimization: Maximum optimization with 999,999 runs
- Hierarchical Authorization: Role-based access control with granular permissions
- Access Controls: Proper admin controls for ILP management
KDEX Core implements a comprehensive role-based authorization system with the following key roles:
- Factory Owner: System-wide administration and role assignment
- ILP Manager Admin: Configuration of ILP operational parameters
- Pair ILP Fee Admin: Per-pair ILP fee activation control
- Pair ILP Fee Manager: Per-pair ILP fee rate configuration
- Upkeep Caller: Automated liquidity provisioning execution
For detailed information about roles, permissions, and security architecture, see AUTHORIZATION.md.
This project is licensed under the GNU General Public License v3.0.
- Fork the repository
- Create a feature branch
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
- Documentation:
KDEX Core_ Technical Specifications.md - Deployment Guide:
DEPLOYMENT.md - Issues: GitHub Issues
- Base Documentation: docs.base.org
- Core ILP functionality implementation
- Comprehensive test suite (43 tests passing)
- Deployment infrastructure for Base
- Contract verification system
- Frontend SDK integration
- Advanced analytics dashboard
- Governance token integration
- Cross-chain bridge support
Built with β€οΈ for the Base ecosystem