βββ contracts/
β βββ token/
β β βββ ERC20.sol # ERC20 token implementation
β βββ swap/
β β βββ Swap.sol # Liquidity pool and swap contract
β βββ staking/
β β βββ Staking.sol # Staking rewards contract
β βββ buy/
β β βββ BuyContract.sol # Token purchase contract
β βββ bridge/
β βββ Bridge.sol # Cross-chain bridge contract
βββ scripts/
β βββ swap/
β β βββ script/
β β β βββ hyperion/ # Hyperion deployment scripts
β β β βββ mantle/ # Mantle deployment scripts
β β βββ pairs/ # Trading pair scripts
β βββ stake/
β β βββ deploy-staking-contract.ts
β βββ buy/
β β βββ deploy-buy-contract.ts
β βββ verify/ # Contract verification scripts
βββ test/
β βββ DeFiSystem.test.ts # Comprehensive test suite
βββ README.md
- USDT: Tether USD (6 decimals, 40M supply)
- USDC: USD Coin (6 decimals, 40M supply)
- DAI: Dai Stablecoin (18 decimals, 40M supply)
- WETH: Wrapped Ether (18 decimals, 40M supply)
- Automated Market Maker with constant product formula
- Liquidity Provision and removal
- Token Swapping between pairs
- Trading Fee: 0.3% (configurable)
- Emergency Controls: Pause/unpause functionality
- USDT staking for USDC rewards
- Dynamic reward rate (0.3 USDC per second)
- Flexible staking/unstaking
- Direct purchase with native currency
- Fixed pricing for USDC and USDT
- Slippage protection
- USDT/USDC
- USDT/DAI
- USDT/WETH
- USDC/DAI
- USDC/WETH
- DAI/WETH
- Node.js (v16 or higher)
- npm or yarn
- Hardhat
- MetaMask or similar wallet
-
Clone the repository
git clone https://github.com/HyperionKit/smc
-
Install dependencies
npm install
-
Compile contracts
npx hardhat compile
Run the comprehensive test suite:
npx hardhat testDeployed Contracts:
- USDT:
0x9b52D326D4866055F6c23297656002992e4293FC - USDC:
0x31424DB0B7a929283C394b4DA412253Ab6D61682 - DAI:
0xdE896235F5897EC6D13Aa5b43964F9d2d34D82Fb - WETH:
0xc8BB7DB0a07d2146437cc20e1f3a133474546dD4 - LiquidityPool:
0x91C39DAA7617C5188d0427Fc82e4006803772B74 - BuyVault:
0x0adFd197aAbbC194e8790041290Be57F18d576a3 - StakingRewards:
0xB94d264074571A5099C458f74b526d1e4EE0314B
Deployment Commands:
# Deploy tokens
npx hardhat run scripts/swap/script/hyperion/deploy-tokens.ts --network metis-hyperion-testnet
# Deploy liquidity pool
npx hardhat run scripts/swap/script/hyperion/deploy-liquidity-pool.ts --network metis-hyperion-testnet
# Setup liquidity pools
npx hardhat run scripts/swap/script/hyperion/setup-liquidity-pools.ts --network metis-hyperion-testnet
# Deploy staking contract
npx hardhat run scripts/stake/deploy-staking-contract.ts --network metis-hyperion-testnet
# Deploy buy contract
npx hardhat run scripts/buy/deploy-buy-contract.ts --network metis-hyperion-testnetDeployed Contracts:
- USDT:
0x6aE086fB835D53D7fae1B57Cc8A55FEEaEC6ba5b - USDC:
0x76837E513b3e6E6eFc828757764Ed5d0Fd24f2dE - DAI:
0xd6Ff774460085767e2c6b3DabcA5AE3D5a57e27a - WETH:
0xCa7b49d1C243a9289aE2316051eb15146125914d - LiquidityPool:
0x93c714601b8bc0C9A9d605CEc99786847654598e - BuyVault:
0x1E0B86323fdFFa099AAEeE9B3C8B2f8C6E20fFa5 - StakingRewards:
0x1a80Db4cf9E26BafCf672c534Ab219630fFE1A5E
Deployment Commands:
# Deploy tokens
npx hardhat run scripts/swap/script/mantle/deploy-tokens.ts --network mantle-testnet
# Deploy liquidity pool
npx hardhat run scripts/swap/script/mantle/deploy-liquidity-pool.ts --network mantle-testnet
# Setup liquidity pools
npx hardhat run scripts/swap/script/mantle/setup-liquidity-pools.ts --network mantle-testnet
# Deploy buy contract
npx hardhat run scripts/buy/deploy-buy-contract.ts --network mantle-testnet
# Deploy staking contract
npx hardhat run scripts/stake/deploy-staking-contract.ts --network mantle-testnetCreate a .env file:
PRIVATE_KEY=your_private_key_here
HYPERION_RPC_URL=your_hyperion_rpc_url
MANTLE_TESTNET_RPC_URL=https://rpc.sepolia.mantle.xyzcreatePair(tokenA, tokenB): Create a new trading pairaddLiquidity(tokenA, tokenB, amountADesired, amountBDesired, amountAMin, amountBMin): Add liquidityremoveLiquidity(tokenA, tokenB, liquidity, amountAMin, amountBMin): Remove liquidityswap(tokenIn, tokenOut, amountIn, amountOutMin): Swap tokens
getAmountOut(amountIn, tokenIn, tokenOut): Calculate output amountgetPairInfo(tokenA, tokenB): Get pair reserves and liquidity
setTradingFee(fee): Update trading fee (max 10%)pause()/unpause(): Emergency controls
stake(amount): Stake USDT tokensunstake(amount): Unstake and claim USDC rewards
getStakedBalance(user): Get user's staked balancegetPendingReward(user): Get user's pending rewards
buyUSDC(minTokenAmount): Buy USDC with native currencybuyUSDT(minTokenAmount): Buy USDT with native currency
getUSDCAmount(metisAmount): Calculate USDC amountgetUSDTAmount(metisAmount): Calculate USDT amount
- Reentrancy Protection: All critical functions protected
- Ownable Access Control: Admin functions restricted to owner
- Emergency Pause: Ability to pause all operations
- Fee Limits: Maximum 10% trading fee
- Slippage Protection: Minimum amount guarantees
- Safe Math: Built-in overflow protection (Solidity 0.8.28)
await usdt.approve(liquidityPool.address, amount);
await usdc.approve(liquidityPool.address, amount);
await liquidityPool.addLiquidity(
usdt.address,
usdc.address,
amount,
amount,
0, // amountAMin
0 // amountBMin
);await usdt.approve(liquidityPool.address, swapAmount);
const amountOut = await liquidityPool.getAmountOut(swapAmount, usdt.address, usdc.address);
await liquidityPool.swap(
usdt.address,
usdc.address,
swapAmount,
amountOut * 95n / 100n // 5% slippage tolerance
);await usdt.approve(stakingRewards.address, stakeAmount);
await stakingRewards.stake(stakeAmount);
const pendingReward = await stakingRewards.getPendingReward(user.address);
await stakingRewards.unstake(stakedAmount);- Insufficient Balance: Ensure you have enough tokens and native currency for gas
- Approval Required: Always approve tokens before operations
- Slippage Protection: Set appropriate minimum amounts
- Network Issues: Verify RPC URLs and network configurations
# Test staking functionality
npx hardhat run scripts/stake/test-staking.ts --network metis-hyperion-testnet
# Buy USDC with METIS
npx hardhat run scripts/buy/buy-usdc-with-metis.ts --network metis-hyperion-testnet
# Test trading pairs
npx hardhat run scripts/swap/pairs/swap-usdt-usdc.ts --network metis-hyperion-testnet# Test trading pairs
npx hardhat run scripts/swap/pairs/swap-usdt-usdc.ts --network mantle-testnetMIT License - see LICENSE file for details
- β All Contracts Verified: On blockchain explorer
- β Liquidity Pool: 6 trading pairs operational
- β Staking System: USDT β USDC rewards working
- β BuyVault: Native currency β USDC/USDT conversion working
- β Core Contracts Deployed: Tokens, LiquidityPool, BuyVault, StakingRewards
- β Trading Pairs: 6 pairs with liquidity initialized