Skip to content

Fix miles estimate reactivity to slippage changes#93

Merged
passandscore merged 3 commits intomainfrom
fix/miles-slippage-reactivity
Apr 1, 2026
Merged

Fix miles estimate reactivity to slippage changes#93
passandscore merged 3 commits intomainfrom
fix/miles-slippage-reactivity

Conversation

@passandscore
Copy link
Copy Markdown
Contributor

Summary

  • Miles estimation now recalculates when slippage changes (not just amountOut), since slippage directly determines the MEV opportunity window and resulting miles reward
  • Guards computedMinAmountOut against NaN reaching BigInt when the user types a partial decimal (e.g. "0.") in the slippage input

Test plan

  • Change slippage in settings popover — miles estimate should update immediately
  • Type "0." in slippage input — no runtime error
  • Verify miles increase with higher slippage and decrease with lower slippage

Miles estimation now recomputes when slippage changes, not just amountOut,
since slippage directly determines the MEV opportunity and resulting miles.

Also guards computedMinAmountOut against NaN reaching BigInt when the user
types a partial decimal (e.g. "0.") in the slippage input.
@vercel
Copy link
Copy Markdown

vercel bot commented Apr 1, 2026

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

Project Deployment Actions Updated (UTC)
fastprotocolapp Ready Ready Preview, Comment Apr 1, 2026 8:25pm

Request Review

…gas pricing

- Convert miles calculation from useEffect to useMemo for synchronous updates
  when slippage or amountOut changes (no more 1-frame delay)
- Use median of 5-block priority fee instead of single-block sample to smooth
  out gas price spikes that caused miles to drop to 0
- Snapshot gas data in refs so background 12s fee ticks don't trigger
  unnecessary recalculations — only user-driven changes do
- Guard against BigInt(NaN) crash by using validateSlippage() for all
  slippage→BigInt conversions in use-swap-quote
- Skip quote recalculation for transient/invalid slippage values ("", ".", "0")
- Validate amount is numeric before enabling quote fetch
- Guard displayQuote.amountOut type before BigInt arithmetic
@passandscore passandscore merged commit 71a79d0 into main Apr 1, 2026
2 of 3 checks passed
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