Skip to content

feat: Pro mode — top 10% block placement#124

Open
passandscore wants to merge 3 commits intomainfrom
top-of-block
Open

feat: Pro mode — top 10% block placement#124
passandscore wants to merge 3 commits intomainfrom
top-of-block

Conversation

@passandscore
Copy link
Copy Markdown
Contributor

Summary

  • Adds Pro mode to the swap interface — when active, the /fastswap POST body includes topPercentile: 10, requesting top-of-block placement from mev-commit providers
  • Auto-engages at ≥$250 sell-side USD on permit-path (ERC20) swaps; user can manually toggle off
  • ETH-path swaps are not eligible (MetaMask broadcasts via its own RPC — no constraint can be attached)
  • Gated by feature flag pro_mode: true in feature-flags.ts

UI

  • ⚡ Pro toggle pill in the header row with rotating blue border highlight when active
  • Title changes from "Swap" → "Pro Swap"
  • CTA label changes from "Swap" → "Swap (Pro)"
  • Switch button between cards becomes a branded ⚡ PRO ↓ pill
  • SellCard gets a pink gradient top-edge highlight
  • Particle burst celebration + level-up sound on auto-engage
  • Confirmation modal shows "Execution: Pro — Top 10%" InfoRow with tooltip + learn link
  • Tooltips explain the feature with $250 threshold and link to /learn/pro-swaps

Backend integration

  • Adds topPercentile: 10 to the /fastswap POST body when Pro is active (Owen's backend change)
  • No URL routing changes — same endpoint, additive optional field
  • Constants in src/lib/pro-mode.ts: PRO_MODE_MIN_USD = 250, TOP_OF_BLOCK_PERCENTILE = 10

Bug fix

  • Fixes stale token price in useTokenPrice — previously, switching tokens (e.g., ETH → PEPE) kept the old token's USD price during the fetch window, causing false Pro triggers and incorrect USD displays

Test plan

  • Select an ERC20 sell token, type amount worth ≥$250 → Pro pill lights up with celebration + sound, title says "Pro Swap", CTA says "Swap (Pro)"
  • Click Pro pill to toggle off → reverts to standard
  • Type amount worth <$250 → Pro pill is visible but not clickable
  • Select ETH as sell token → Pro pill hides entirely (ETH path not eligible)
  • Open confirmation modal with Pro active → "Execution: Pro — Top 10%" row visible with tooltip
  • Submit ERC20 swap with Pro active → verify topPercentile: 10 in network tab POST body
  • Switch from ETH to PEPE → USD display clears momentarily (no stale price flash)
  • Set pro_mode: false in feature-flags → all Pro UI completely hidden

Adds a "Pro" execution mode that sends a `topPercentile: 10` field
on the /fastswap intent path, requesting top-of-block placement from
mev-commit providers. Auto-engages at ≥$250 sell-side USD on permit-path
swaps; user can toggle off. ETH-path swaps are not eligible.

UI: Pro toggle pill with rotating border highlight in the header row,
"Pro Swap" title, "Swap (Pro)" CTA label, Pro-branded switch button,
SellCard top-edge gradient, celebration particle burst + sound on
auto-engage, and "Execution: Pro — Top 10%" row in the confirmation modal.

Also fixes a stale-price bug in useTokenPrice where switching tokens
kept the previous token's USD price during the fetch window, causing
false Pro triggers and incorrect USD displays.
@vercel
Copy link
Copy Markdown

vercel bot commented Apr 17, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
fastprotocolapp Ready Ready Preview, Comment Apr 17, 2026 4:03pm

Request Review

Add edge config key `pro_mode_min_usd` (default 250) so the Pro mode
threshold can be tuned in prod without a deploy. New API route at
/api/config/pro-threshold, client hook useProThreshold(), and docs
covering all edge config keys.
Token prices from the API can be slightly below $1 (e.g., USDC at
$0.9998), causing the sell USD value to land just under the threshold
(19.996 < 20). Round to the nearest dollar before comparing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant