A comprehensive decentralized ex#### π‘ Interact with Contracts
# Set network for all commands
export NETWORK=monadTestnet
# Initialize DEX with liquidity
npm run setup:dex -- --network $NETWORK
# Add liquidity to pools
npm run liquidity:add -- --network $NETWORK
# Execute token swaps
npm run trading:swap -- --network $NETWORK
# Create and manage portfolios
npm run portfolio:create -- --network $NETWORKβ Deployed and Verified on Etherscan
- Test DAI:
0xAd22b4EC8cdd8A803d0052632566F6334A04F1F3 - Test USDC:
0xcF9884827F587Cd9a0bDce33995B2333eE7e8285 - Test USDT:
0x1861BB06286aAb0fDA903620844b4Aef4894b719 - Test WBTC:
0x4267652AF61B4bE50A39e700ee2a160f42371f54
- PortfolioFactory:
0x49C17A91672c629543a14782809E246296317bA3
Uses existing Sepolia Uniswap V2 contracts:
- UniswapV2Factory:
0xF62c03E08ada871A0bEb309762E260a7a6a880E6 - UniswapV2Router02:
0xeE567Fe1712Faf6149d80dA1E6934E354124CfE3
- Network: Ethereum Sepolia Testnet
- RPC URL: Alchemy (configured via
ALCHEMY_SEPOLIA_RPC_URL) - Block Explorer: sepolia.etherscan.io
- Faucet: Sepolia Faucet
To deploy your own contracts on Sepolia:
# Deploy only test tokens and portfolio (uses existing Sepolia DEX)
npx hardhat ignition deploy ignition/modules/features/sepolia-deployment.ts --network sepolia
# Verify all deployed contracts automatically
npx hardhat ignition verify chain-11155111 --network sepoliaRequirements for verification:
- Ensure
dotenvis installed:npm install dotenv - Set
PRIVATE_KEYin your.envfile - Set
ETHERSCAN_API_KEYin your.envfile (for Etherscan verification) - Set
ALCHEMY_SEPOLIA_RPC_URLin your.envfile (Alchemy RPC endpoint)
# Set network for all commands
export NETWORK=sepolia
# Add liquidity using deployed test tokens
npx hardhat run scripts/03-liquidity/add-liquidity-sepolia.ts --network sepolia
# Add custom amounts or tokens
npx hardhat run scripts/03-liquidity/add-liquidity-sepolia.ts --network sepolia -- --tokenA 0xAd22... --tokenB 0xcF98... --amountA 100 --amountB 50
# Create and manage portfolios (uses existing Sepolia DEX)
npm run portfolio:create -- --network $NETWORK
# Portfolio operations
npm run portfolio:view -- --network $NETWORK
npm run portfolio:rebalance -- --network $NETWORK
```smart portfolio management system built on Ethereum. This project provides a complete DeFi infrastructure including token swapping, liquidity management, and automated portfolio rebalancing.
## π Project Overview
MetaSmartPort consists of several key components:
### ποΈ Core Contracts
- **WMON**: Wrapped native token for trading
- **Test Tokens**: DAI, USDC, USDT, WBTC for development
- **DEX System**: Uniswap V2 compatible factory and router
- **Portfolio Management**: Smart portfolio factory and implementation
### π― Key Features
- **Decentralized Trading**: Full Uniswap V2 compatible DEX
- **Liquidity Management**: Add/remove liquidity with automated pair creation
- **Portfolio Management**: Create and manage diversified portfolios
- **Automated Rebalancing**: Smart contract-based portfolio rebalancing
- **Multi-Environment**: Localhost, testnet, and mainnet configurations
## οΏ½ Live Deployments
### Monad Testnet (Chain ID: 10143)
β
**Deployed and Verified on MonadScan**
#### π§ DEX Infrastructure
- **UniswapV2Factory**: [`0x7Bf4523bA76772F7Ed499aba5eb4Ea83168594b6`](https://testnet.monadscan.com/address/0x7Bf4523bA76772F7Ed499aba5eb4Ea83168594b6#code)
- **UniswapV2Router02**: [`0xcF9884827F587Cd9a0bDce33995B2333eE7e8285`](https://testnet.monadscan.com/address/0xcF9884827F587Cd9a0bDce33995B2333eE7e8285#code)
#### πͺ Token Contracts
- **WMON (Wrapped MON)**: [`0xAd22b4EC8cdd8A803d0052632566F6334A04F1F3`](https://testnet.monadscan.com/address/0xAd22b4EC8cdd8A803d0052632566F6334A04F1F3#code)
- **Test DAI**: [`0x8A2F5094992835Cc6C2c83e515FbdA4270182fE9`](https://testnet.monadscan.com/address/0x8A2F5094992835Cc6C2c83e515FbdA4270182fE9#code)
- **Test USDC**: [`0x065A0af7bfF900deB2Bcb7Ae3fc6e1dD52579aC7`](https://testnet.monadscan.com/address/0x065A0af7bfF900deB2Bcb7Ae3fc6e1dD52579aC7#code)
- **Test USDT**: [`0x8a1515Bce4Fb424343E8187959dF197cB33Fc1b9`](https://testnet.monadscan.com/address/0x8a1515Bce4Fb424343E8187959dF197cB33Fc1b9#code)
- **Test WBTC**: [`0x49C17A91672c629543a14782809E246296317bA3`](https://testnet.monadscan.com/address/0x49C17A91672c629543a14782809E246296317bA3#code)
#### π Portfolio Management
- **PortfolioFactory**: [`0x1861BB06286aAb0fDA903620844b4Aef4894b719`](https://testnet.monadscan.com/address/0x1861BB06286aAb0fDA903620844b4Aef4894b719#code)
#### π Quick Links
- **Network**: Monad Testnet
- **RPC URL**: `https://testnet-rpc.monad.xyz`
- **Block Explorer**: [testnet.monadscan.com](https://testnet.monadscan.com)
- **Faucet**: Available in Monad Discord
#### οΏ½ Contract Verification
To verify your own deployment on Monad testnet:
```bash
# Deploy contracts using Hardhat Ignition
npx hardhat ignition deploy ignition/modules/features/full-deployment.ts --network monadTestnet
# Verify all deployed contracts automatically
npx hardhat ignition verify chain-10143 --network monadTestnetRequirements for verification:
- Ensure
dotenvis installed:npm install dotenv - Set
PRIVATE_KEYin your.envfile - Set
ETHERSCAN_API_KEYin your.envfile (for MonadScan verification)
# Set network for all commands
export NETWORK=monadTestnet
# Initialize DEX with liquidity
npm run setup:dex -- --network $NETWORK
# Add liquidity to pools
npm run liquidity:add -- --network $NETWORK
# Execute token swaps
npm run trading:swap -- --network $NETWORK
# Create and manage portfolios
npm run portfolio:create -- --network $NETWORKβββ contracts/ # Smart contracts
β βββ core/ # Portfolio management contracts
β βββ dex/ # DEX contracts (Factory, Router, Pair)
β βββ tokens/ # ERC-20 test tokens
β βββ utils/ # Utility contracts
β
βββ scripts/ # Deployment and interaction scripts
β βββ 01-deploy/ # Contract deployment
β βββ 02-setup/ # DEX initialization
β βββ 03-liquidity/ # Liquidity management
β βββ 04-trading/ # Token swapping
β βββ 05-utilities/ # Token utilities (WMON deposit/withdraw)
β βββ 06-portfolio/ # Portfolio management
β βββ 07-queries/ # Data queries
β βββ 08-helpers/ # Utility functions
β βββ 09-workflows/ # Complete automation
β
βββ ignition/ # Hardhat Ignition deployment
β βββ modules/
β βββ shared/ # Core deployment modules
β βββ features/ # Complete deployment scenarios
β βββ environments/ # Environment-specific configurations
β
βββ test/ # Test files
βββ artifacts/ # Compiled contracts
- Hardhat 3 Beta: Development framework
- Solidity 0.8.28: Smart contract language
- Viem: Ethereum interaction library
- TypeScript: Type-safe scripting
- Hardhat Ignition: Declarative deployment system
- OpenZeppelin: Secure contract libraries
- Node.js 18+
- npm or yarn
- Git
git clone https://github.com/jerrygeorge360/metasmartportcontracts
cd metasmartportcontracts
npm installStart a local Hardhat node:
npm run dev:nodeAutomated deployment with scripts:
# Complete setup in one command
npm run workflow:full-setupDeclarative deployment with Ignition:
# Deploy complete ecosystem
npx hardhat ignition deploy ignition/modules/features/full-deployment.ts --network localhostStep-by-step deployment using organized scripts:
# 1. Deploy all contracts
npm run deploy:all
# 2. Initialize DEX with liquidity
npm run setup:initialize-dex
# 3. Verify setup
npm run query:reservesChoose from different deployment scenarios:
# Complete ecosystem (WMON + Tokens + DEX + Portfolio)
npx hardhat ignition deploy ignition/modules/features/full-deployment.ts --network localhost
# DEX only (trading without portfolio)
npx hardhat ignition deploy ignition/modules/features/dex-only.ts --network localhost
# Portfolio only (assumes DEX exists)
npx hardhat ignition deploy ignition/modules/features/portfolio-only.ts --network localhost
# Minimal setup (just tokens for testing)
npx hardhat ignition deploy ignition/modules/features/minimal.ts --network localhostnpm run deploy:all # Deploy all contractsnpm run setup:init-hash # Calculate init code hash
npm run setup:initialize-dex # Initialize DEX with liquiditynpm run liquidity:add # Add liquidity to pairs
npm run liquidity:remove # Remove liquiditynpm run trade:swap # Swap tokensnpm run utility:wmon-deposit # Convert ETH to WMON
npm run utility:wmon-withdraw # Convert WMON to ETH
npm run utility:approve-tokens # Approve tokens for tradingnpm run portfolio:create # Create new portfolio
npm run portfolio:view # View portfolio details
npm run portfolio:rebalance # Rebalance portfolionpm run query:reserves # Check pair reserves
npm run query:wmon # WMON contract info
npm run query:pair # Get pair addressesnpm run workflow:full-setup # Complete automated setupnpm run dev:node # Start local Hardhat node
npm run dev:console # Open Hardhat console
npm run compile # Compile contracts
npm run test # Run tests
npm run clean # Clean artifactsThe project supports different deployment environments with tailored configurations:
- High token supplies (1M+ tokens)
- Large liquidity pools
- Fast deployment settings
- Moderate token supplies (100K tokens)
- Reasonable liquidity pools
- Production-like settings
- Conservative token supplies (10K tokens)
- Minimal initial liquidity
- Security-focused configurations
- UniswapV2Factory: Creates and manages trading pairs
- UniswapV2Router02: Handles swaps and liquidity operations
- UniswapV2Pair: Individual trading pair contracts
- SmartPortfolioFactory: Creates portfolio instances
- SmartPortfolio: Manages individual portfolios with automated rebalancing
- WMON: Wrapped native token for trading pairs
- Test Tokens: DAI, USDC, USDT, WBTC with realistic decimals
Run the test suite:
# All tests
npm test
# Solidity tests only
npx hardhat test solidity
# TypeScript tests only
npx hardhat test nodejsnpm run query:reserves # View all pair reserves and prices
npm run query:pair # Get specific pair addressesnpm run portfolio:view # View portfolio details and performancenpm run query:wmon # Check WMON contract details- SETUP.md: Detailed setup guide with both scripts and Ignition
- Architecture Overview: System design and components
- API Reference: Complete script and command reference
- Multi-signature wallets for admin functions
- Timelock delays for critical operations
- Audit smart contracts before mainnet deployment
- Test thoroughly on testnets first
- Monitor initial liquidity amounts carefully
- OpenZeppelin battle-tested libraries
- Reentrancy protection
- Access control mechanisms
- Emergency pause functionality
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
For questions, issues, or contributions:
- Open an Issue
- Submit a Pull Request
- Join our community discussions
Built with β€οΈ using Hardhat 3 Beta, Viem, and TypeScript.