Everything you need to know about using the DEX Dashboard — from claiming tokens to understanding the smart contracts.
The DEX Dashboard is a full-stack educational Web3 platform that simulates a decentralized exchange experience. It lets you mint mock tokens, trade them on a simulated DEX, and track live market analytics — all without risking real funds.
It's built for developers, students, and crypto enthusiasts who want to understand how DeFi protocols work by interacting with one directly.
No real cryptocurrency or fiat money is involved. All tokens are mock ERC20 tokens deployed on test networks or a local Anvil node.
The DEX Dashboard works with two networks:
http://127.0.0.1:8545 and gives you instant transactions with no gas costs.💡 Tip: Start with Anvil for local development, then deploy to Sepolia for public testing.
Before deploying to Sepolia, make sure you have test ETH. You can get it from the Sepolia Faucet (sepoliafaucet.com).
This dashboard is designed for:
The project is divided into two main parts:
Solidity ^0.8.27 + Foundry + OpenZeppelinNext.js 16 (App Router) + TypeScript (strict) + shadcn/ui + Tailwind CSS v4 + wagmi + viemRecharts for candlestick charts, CoinGecko API for market dataFoundry (forge) — 182+ Solidity tests including fuzz and invariant tests; Vitest + Testing Library — frontend component testsFollow these steps:
git clone https://github.com/Men6d656e/DEX.gitmake installmake build-contractsmake anvil (Terminal 1)make deploy-anvil (Terminal 2)make devhttp://localhost:3000 and connect your wallet💡 New to Foundry? The
makecommands automate everything. Just runmake devand the frontend will start with hot reload enabled.
Make sure you have Node.js >= 18, Foundry, and Git installed before starting.
The repository is organized into these main directories:
update-addresses.sh for auto-capturing deployed contract addresses.The root Makefile provides automation for install, build, test, deploy, and dev commands.
The Faucet is a smart contract that distributes mock tokens to users for testing and learning purposes. It's like a water faucet for tokens — turn it on and get free tokens to play with.
Each user can claim a fixed amount of tokens once per cooldown period (24 hours), tracked independently for each token type. The faucet ensures fair distribution while preventing abuse.
The Faucet contract uses a checks-effects-interactions pattern for security. Your claim is recorded on-chain before tokens are minted.
The Faucet supports 3 mock tokens:
MockERC20("Mock ETH", "mETH", faucetAddress)MockERC20("Mock BTC", "mBTC", faucetAddress)MockERC20("Mock USDC", "mUSDC", faucetAddress)Each token is a full ERC20 implementation from OpenZeppelin with faucet-restricted minting. The faucet is the only address that can mint new tokens.
When you select a token in the Faucet page, its contract address is displayed in the section below the claim button. To import a token into MetaMask (or any wallet):
✅ After importing, you'll see your balance update in real-time as you claim more tokens.
Token addresses are unique per deployment. Always use the address shown on the Faucet page — they change when contracts are redeployed.
Each token has an independent 24-hour cooldown per wallet address. Here's the breakdown:
HH:MM:SS countdown until your next claim is available.lastClaim mapping and cooldown variable are stored in the Faucet contract. Even if you reload the page, the state persists.The cooldown is based on block timestamps, not your local clock. If there's a discrepancy, trust the on-chain countdown displayed in the UI.
You can claim 10 tokens (with 18 decimal places, so 10 × 10¹⁸ wei) per token per 24-hour period.
Example:
The claim amount and cooldown duration can be adjusted by the contract owner (the deployer) using the setClaimAmount() and setCooldown() admin functions.
The Faucet page shows detailed analytics for each token:
All this data comes from the Faucet contract's on-chain state (lastClaim and lifetimeClaimed mappings). It persists across sessions and browser restarts.
Lifetime claimed data is stored on-chain per wallet address. If you switch wallets, the history for the new wallet starts from zero.
The DEX supports 6 swap paths across 3 token pairs:
The cross-rate is calculated by routing through mUSDC internally: ethAmount → USDC value (via ethSwapRate) → BTC output (via btcSwapRate)
The Swap interface shows all available pairs in a dropdown. Select your input and output tokens, and the rate will be calculated automatically.
The DEX uses a fixed-ratio pricing model — not an AMM (Automated Market Maker) like Uniswap.
ethSwapRate and btcSwapRate on deployment.output = input × rate. Cross-rate swaps calculate through the USDC value.This is NOT a real-time AMM. Prices don't change based on trade size or pool ratio — they're fixed by the contract owner. This is intentional for educational simplicity.
There is no swap fee in this educational DEX. The full swap amount goes to the user without any deduction.
Since there are no fees, the full input amount is converted to output at the configured rate. What you see is what you get.
The DEX contract owner is the sole liquidity provider. They call the addLiquidity() function to deposit mETH, mBTC, and mUSDC tokens into the DEX.
The current liquidity is visible on the Swap page in the Reserves panel.
In production DEXes like Uniswap, anyone can be a liquidity provider by depositing equal values of two tokens into a pool. Here, it's simplified to owner-only for educational clarity.
Slippage is the difference between the expected price of a trade and the price at which it's actually executed. Even though this DEX uses fixed rates, slippage protection is implemented as a safety mechanism (minOutput). If the calculated output is less than your minOutput, the transaction reverts.
You can set the slippage tolerance in the Swap page via the ⚙️ Settings button (gear icon). Default is 0.5%.
Setting slippage too low (e.g., 0.1%) may cause transactions to fail if reserves change slightly. Setting it too high (e.g., 10%) defeats the purpose. 0.5% is a good starting point.
Before you can swap, the DEX contract needs permission to spend your tokens via the ERC20 approve() function.
Approval is per-token and persists across swaps.
The approval sets type(uint256).max (infinite approval) so you don't need to re-approve for subsequent swaps. You can revoke this at any time by approving 0.
This DEX uses a simplified reserve-based model, not a constant product AMM. Reserves track exactly how many tokens the DEX holds (ethReserve, btcReserve, usdcReserve).
It does NOT use the x × y = k formula, have automated price discovery, or LP tokens.
The reserve invariants are tested in Foundry with randomized sequences (256 runs × 15 depth) — reserves always match the DEX balance exactly.
The Analytics page shows:
Market data is powered by the CoinGecko API (Free Tier). The frontend fetches candlestick data, prices, and market metrics.
CoinGecko's free tier has rate limits. If you see stale data, you may have exceeded the request limit. Consider adding a delay or using the API key for higher limits.
Each candle shows 4 data points for a period: Open, Close, High, and Low. Green means the price increased (Close > Open), Red means it decreased (Close < Open). The wicks show the high/low range, and the body shows open/close.
Hover over any candle to see the exact Open, High, Low, Close values for that period. Use the timeframe selector (1D, 1W, 1M, 1Y) to zoom in and out.
All include trend indicators (↑ or ↓) vs. yesterday.
It displays your token balances (mETH, mBTC, mUSDC), USD values, and an allocation pie chart. It uses balanceOf() calls to fetch data directly from the blockchain via wagmi/viem.
The portfolio only shows tokens held by your connected wallet. If you switch wallets or disconnect, the data resets for the new address.
It displays a chronological list of transactions, including Time, Swap Type, Amount In, Amount Out, and the User address.
You can click any trade to see more details. The table automatically updates when new swaps occur on the connected network.
Price, 24h Change, Market Cap, 24h Volume, and Circulating Supply.
For mock tokens (mETH, mBTC, mUSDC), the supply shown is the total minted by the Faucet. Real market data (price, volume) comes from CoinGecko.
They use a modular architecture:
faucet address.Uses custom errors and the checks-effects-interactions pattern for security.
182+ Solidity tests across all contracts:
Run make test-contracts or forge test -vvv to run all 182+ Solidity tests. Fuzz runs + invariant tests take ~30 seconds.
🔍 No matching questions found.
Try a different search term or clear the filter.