All works
Bulldex Finance
BlockchainDeFiNext.jsSolidityethers.js

Bulldex Finance

Wayan Phantom Megaditha

Wayan Phantom Megaditha

Fullstack Engineer & Smart Contract Developer

Live ↗GitHub ↗

The Problem

Most Web3 tutorials stop at smart contracts. Deploy a token, call a function, done. There was no clean open-source reference showing the full DeFi stack from Solidity to UI to wallet UX in a single coherent codebase. Builders who wanted to understand how a real DeFi product works had nowhere to start. Bulldex is that reference.


How It Works

  1. A set of Solidity smart contracts handles the core logic: token swap using a constant-product AMM formula, a faucet contract for Sepolia testnet token distribution, and an LP pool contract that tracks reserves and issues LP tokens.
  2. The Next.js frontend reads on-chain state via ethers.js v6 using read-only provider calls for data and signer-based calls for transactions.
  3. Wallet connection is handled by MetaMask and WalletConnect adapters. The UI shows price impact, slippage tolerance input, and expected output before any transaction is sent.
  4. Optimistic UI updates show expected outcomes immediately. The actual on-chain confirmation is reconciled in the background without blocking the interface.
  5. The LP dashboard polls reserve data at an interval and calculates impermanent loss in real time from current versus entry reserves.

Tech Stack

Next.jsApp Router with RSC and static export, consistent across the portfolio stack
SolidityOpenZeppelin standards reduce attack surface for a reference codebase
ethers.js v6Cleaner TypeScript API than v5, aligns with current industry practice
OpenZeppelinAudited contract library prevents common token and AMM vulnerabilities
Sepolia testnetPrimary Ethereum testnet with reliable public faucets for development

What I Would Improve

The price oracle is naive. A real AMM uses TWAPs to prevent flash loan manipulation. Adding a TWAP oracle would make this a more accurate reference for production patterns. The frontend polling is also inefficient. Replacing it with WebSocket event listeners from ethers.js would reduce RPC calls and improve responsiveness on slow connections. Finally, the test suite only covers the happy path. Property-based tests for the AMM invariant (k = x * y) would catch edge cases that deterministic unit tests miss.

Screenshots

Wayan Phantom Megaditha

Wayan Phantom Megaditha

Fullstack Engineer · AI & Web3

Next.jsSolidityethers.jsEthereumDeFi