StealThis .dev
Pages Hard

Web3 — Token Swap (from/to · slippage · route)

A glassy DEX swap card for the fictional NovaSwap aggregator on Lumen Chain, built in HTML, CSS, and vanilla JS. From and To panels each carry a monospace amount input, live fiat estimate, balance with a MAX button, and a searchable token-select modal across eight made-up assets. A flip button reverses direction, while a live rate, animated price-impact, minimum-received, and a slippage popover update as you type. The big Swap action opens a confirm step with risk callouts, a mock signing and submitted flow, a fake tx hash, and toast feedback.

Open in Lab
html css vanilla-js
Targets: JS HTML

Code

Token Swap (from/to · slippage · route)

A self-contained decentralized-exchange swap card for the fictional NovaSwap aggregator on Lumen Chain. Two glassy panels — You pay and You receive — each pair a monospace amount input with a token selector, a live USD estimate, and a balance line; the From side adds a MAX button that leaves a little native gas behind. A floating flip button sits between the panels and reverses the trade direction with a rotating micro-interaction, carrying the entered values across.

Typing into either side instantly computes the other from a mock rate (1 ETH = 2,806.40 USDC), and an expandable details block surfaces the live rate, a size-scaled price impact that shifts from green to amber to red, the minimum received after slippage, the network fee, and a NovaSwap V3 route preview. A slippage popover offers 0.1 / 0.5 / 1% presets plus a custom field and deadline, warning when tolerance gets risky. The token picker is a searchable modal over eight fictional assets (NOVA, LUM, WBTC, ARC, GLOW and more) with common-token chips, balances, and truncated 0x… addresses.

The primary Swap button validates balance and impact — turning into an “Insufficient balance” or high-impact danger state when needed — then opens a confirm sheet that restates the legs, fee, and a minimum-received risk note. Confirming runs a simulated waiting for signature → submitted → complete sequence with a spinner, a mock transaction hash, updated balances, and toast notifications at each step. Everything is keyboard-usable, focus-ringed, responsive down to ~360px, and respects prefers-reduced-motion.

UI-only simulation — no real wallet, RPC, or on-chain calls. Mock data, fictional tokens.