How krishankshh/nofeeswap works
1. This repo is a three-runtime local protocol environment: a React dApp in frontend/, a Hardhat-based local chain in chain/, and a TypeScript mempool/sandwich bot in bot/. The core/ and operator/ directories are not the live app; they are reference protocol implementations with heavy test coverage.
2. The primary user-facing boundary is the frontend. It is a React 19 + TypeScript + Vite app that routes between Dashboard, Swap, Pool, and Liquidity pages. The UI is split into reusable layout, wallet, pool, and transaction components, with stateful behavior concentrated in custom hooks.
3. Frontend chain access is centralized through ethers.js v6 hooks and contract/config files. The app reads ABIs from frontend/src/abis/, contract addresses from src/config/contracts.ts, chain metadata from src/config/chains.ts, and token metadata from src/config/tokens.ts. This keeps UI components separate from Web3 plumbing.
4. Wallet integration is a distinct subsystem. useWallet and the wallet components manage MetaMask connect/disconnect, network detection, and chain switching. That wallet state feeds swap, pool, and liquidity flows, which then use transaction hooks for approve/submit/pending/confirmed/reverted lifecycle handling.
5. The local chain in chain/ is the execution backend for the dApp and bot. It is a Hardhat network deployment with a deployment script that initializes test ERC-20s, deploys a NofeeOperatorLike contract, seeds a default pool, and writes addresses to chain/deployments/localhost.json.
6. NofeeOperatorLike is the on-chain contract boundary the frontend targets. In this assignment it stands in for the real NoFeeSwap operator interface, exposing pool initialization, swap, and liquidity management entry points. The frontend’s swap/liquidity pages are built against that interface, not against the underlying protocol internals.
7. The bot in bot/ is a separate runtime that also targets the same local Hardhat chain. Its architecture is a pipeline: pending-transaction monitoring in index.ts, calldata parsing in decoder.ts, profitability estimation in profitability.ts, then front-run/back-run execution against the operator contract.
8. The bot and frontend share the same chain state but serve different roles. The frontend is an interactive client for a user with MetaMask, while the bot is an autonomous actor watching the mempool and submitting transactions based on decoded swap intent and estimated slippage/profit.
9. The core/ and operator/ directories are the protocol reference layer. They contain Solidity/Python test harnesses, Brownie/Hardhat configs, and Echidna fuzzing setups that validate the real NoFeeSwap logic. Architecturally, they inform the protocol model but are not part of the simplified local app runtime.
10. Data flow is therefore: user action in the React UI → wallet signature in MetaMask → ethers.js call through frontend hooks → Hardhat local contracts → updated on-chain state read back into the UI. In parallel, the bot consumes pending transactions from the same node, decodes them, and reacts before they are mined.
11. The most important diagram boundaries are: browser/UI, wallet provider, local blockchain node, deployed contracts, bot process, and reference protocol/test repos. A separate boundary worth noting is that several UI features, like the kernel editor and liquidity chart, are presentation-oriented and do not write the full NoFeeSwap kernel model on-chain in this simplified setup.
Main entry points: pages Pages · hooks Web3 Hooks · localhost.json Operator Contract · useWallet.tsx Wallet
Components 17
Frontend
React dApp and UI runtime
- App Shell · Top-level React 19 + TypeScript client entry and routing shell
frontend/src/App.tsx - Pages · Dashboard, Swap, Pool, and Liquidity screens
frontend/src/pages - Layout · Shared page chrome and navigation
frontend/src/components/layout - Wallet · Connect, network detection, and chain switching
frontend/src/hooks/useWallet.tsx - Web3 Hooks · Centralized contract, pool, balance, and transaction access
frontend/src/hooks - Chain Config · ABI, contract, chain, and token metadata used by the UI
frontend/src/config - UI Components · Wallet, pool, and transaction-facing interface components
frontend/src/components - Kernel Editor · Pool-oriented editing and visualization surface
frontend/src/components/pool/KernelEditor.tsx
Local Chain
Hardhat execution backend and deployments
- Deploy Script · Seeds tokens, deploys operator, initializes default pool, writes localhost addresses
chain/scripts/deploy.ts - Hardhat Node · Local execution environment and deployment target
chain/hardhat.config.ts - Operator Contract · NofeeOperatorLike entry point for pool, swap, and liquidity actions
chain/deployments/localhost.json
Bot
Autonomous mempool trading runtime
- Mempool Watcher · Monitors pending transactions and orchestrates the trading loop
bot/src/index.ts - Calldata Parser · Decodes pending swap intent into structured trade signals
bot/src/decoder.ts - Profit Model · Estimates slippage and execution profitability
bot/src/profitability.ts - Trade Executor · Submits reactions against the operator contract on the local chain
bot/src/index.ts
Reference Protocol
Protocol model and verification harnesses
- Core Reference · Protocol implementation and extensive verification harnesses
core - Operator Reference · Operator-side reference implementation and tests
operator
Connections 21
- App Shell → Pages: routes · App shell directs users to the main screens
- App Shell → Layout: wraps · Shared layout provides page chrome
- Pages → UI Components: uses · Pages compose reusable UI components
- Pages → Kernel Editor: renders · Pool page surfaces kernel editing and visualization
- UI Components → Wallet: consumes · Wallet UI reflects connect and network state
- Wallet → Web3 Hooks: drives · Wallet state feeds contract and transaction hooks
- Web3 Hooks → Chain Config: reads · Hooks resolve ABIs, addresses, chains, and tokens
- Web3 Hooks → Operator Contract: calls · ethers.js interactions target the deployed operator boundary
- Pages → Wallet: depends on · Swap, pool, and liquidity flows require active wallet state
- Pages → Web3 Hooks: reads state · UI reflects balances, pools, and transaction lifecycle
- Deploy Script → Hardhat Node: deploys to · Deployment script targets the local Hardhat chain
- Deploy Script → Operator Contract: writes · Deployment produces the local operator address record
- Mempool Watcher → Calldata Parser: pipes to · Watcher forwards pending transactions to decoder
- Calldata Parser → Profit Model: analyzes · Decoded trade data is scored for execution value
- Profit Model → Trade Executor: signals · Profitability output determines whether to trade
- Trade Executor → Operator Contract: targets · Execution leg submits transactions to the operator contract
- Mempool Watcher → Hardhat Node: observes · Bot watches the same local node as the frontend
- Web3 Hooks → Hardhat Node: connects to · UI reads and writes against the same local blockchain
- Core Reference → Operator Contract: informs · Core protocol model underlies the simplified operator boundary
- Operator Reference → Operator Contract: informs · Operator reference validates the contract behavior model
- Core Reference → Operator Reference: complements · The two reference trees cover protocol and operator perspectives