A full-featured dApp for interacting with the DynamicFeeHook on Uniswap V4. Features real contract interactions, pool creation, liquidity management, and swapping with dynamic fee protection.
- Dynamic Fees: Fees automatically adjust from 0.30% to 1.00% based on market volatility
- LP Protection: Higher fees during high volatility protect liquidity providers
- Multi-Chain: Deployed on Base and Celo mainnets
- Real Contract Interactions: Actual on-chain transactions, not simulated
- Modern UI: Built with Next.js 14, Tailwind CSS, and RainbowKit
| Contract | Address |
|---|---|
| DynamicFeeHook | 0x2c80c5cd9fecc3e32dfaa654e022738480a4909a |
| PoolManager | 0x498581ff718922c3f8e6a244956af099b2652b2b |
| PositionManager | 0x7c5f5a4bbd8fd63184577525326123b519429bdc |
| Contract | Address |
|---|---|
| DynamicFeeHook | 0xe96B2C7416596fE707ba40379B909F42F18d7FC0 |
| PoolManager | 0x288dc841A52FCA2707c6947B3A777c5E56cd87BC |
| PositionManager | 0xf7965f3981e4d5bc383bfbcb61501763e9068ca9 |
- Node.js 18+
- npm or yarn
- MetaMask or another Web3 wallet
# Clone/download the project
cd dynamicswap-prod
# Install dependencies
npm install
# Copy environment file
cp .env.example .env
# Add your WalletConnect Project ID (optional but recommended)
# Get one at https://cloud.walletconnect.com/
# Edit .env and add: NEXT_PUBLIC_WALLET_CONNECT_ID=your_id
# Start development server
npm run devOpen http://localhost:3000 in your browser.
- Connect your wallet (Base or Celo network)
- Go to the "Create Pool" tab
- Select two tokens (e.g., WETH/USDC on Base)
- Set the initial price
- Choose tick spacing (60 recommended for most pairs)
- Click "Create Pool" and confirm in your wallet
Estimated costs:
- Base: ~$3-5 in ETH
- Celo: ~$0.10 in CELO
- Go to the "Liquidity" tab
- Select the token pair (pool must exist)
- Enter amounts for both tokens
- Approve tokens if needed (first time only)
- Click "Add Liquidity" and confirm
- Go to the "Swap" tab
- Select input and output tokens
- Enter amount to swap
- Review the dynamic fee (updates in real-time)
- Click "Swap" and confirm
For advanced users, CLI scripts are provided for pool creation and liquidity:
# Create .env file with your private key
echo "PRIVATE_KEY=0x..." > .env
# Create pool on Base
npm run create-pool:base
# Create pool on Celo
npm run create-pool:celo# Add liquidity on Base (0.01 WETH + 25 USDC)
npm run add-liquidity:base -- --amount0 0.01 --amount1 25
# Add liquidity on Celo (10 CELO + 5 cUSD)
npm run add-liquidity:celo -- --amount0 10 --amount1 5dynamicswap-prod/
βββ src/
β βββ app/ # Next.js app router
β β βββ layout.tsx # Root layout with providers
β β βββ page.tsx # Main page with tabs
β β βββ globals.css # Global styles
β βββ components/ # React components
β β βββ Header.tsx # Wallet connection header
β β βββ SwapPanel.tsx # Swap interface
β β βββ LiquidityPanel.tsx # Add liquidity interface
β β βββ CreatePoolPanel.tsx # Pool creation interface
β β βββ TokenSelector.tsx # Token dropdown
β β βββ Providers.tsx # Wagmi/RainbowKit providers
β βββ contracts/ # Contract ABIs and addresses
β β βββ abis.ts # Contract ABIs
β β βββ addresses.ts # Deployed addresses
β βββ hooks/ # Custom React hooks
β β βββ usePoolData.ts # Pool data fetching
β β βββ useTransactions.ts # Transaction hooks
β βββ lib/ # Utilities
β βββ wagmi.ts # Wagmi configuration
β βββ pool-utils.ts # Pool calculations
βββ scripts/ # CLI scripts
β βββ createPool.ts # Pool creation script
β βββ addLiquidity.ts # Add liquidity script
βββ package.json
βββ tsconfig.json
βββ tailwind.config.js
βββ next.config.js
The DynamicFeeHook adjusts trading fees based on recent price volatility:
| Volatility | Fee |
|---|---|
| Low (stable) | 0.30% |
| Medium | 0.50% |
| High | 0.80% |
| Very High | 1.00% |
Benefits:
- LPs are protected during volatile periods (higher fees compensate for impermanent loss risk)
- Traders get lower fees during stable periods
- More sustainable LP returns over time
| Variable | Description | Required |
|---|---|---|
NEXT_PUBLIC_WALLET_CONNECT_ID |
WalletConnect Cloud project ID | Recommended |
PRIVATE_KEY |
Wallet private key (CLI scripts only) | For scripts |
Edit src/contracts/addresses.ts to add new tokens:
TOKENS: {
[chainId]: {
YOUR_TOKEN: {
address: '0x...',
symbol: 'TOKEN',
name: 'Your Token',
decimals: 18,
},
},
}# Install Vercel CLI
npm i -g vercel
# Deploy
vercelOr connect your GitHub repo to Vercel for automatic deployments.
npm run build
npm run startContributions are welcome! Please feel free to submit issues and pull requests.
MIT License - see LICENSE file for details.
Built with β€οΈ for the DeFi community