chore(scripts): quote-compare diagnostic for amount-too-small gate#135
Closed
passandscore wants to merge 2 commits into
Closed
chore(scripts): quote-compare diagnostic for amount-too-small gate#135passandscore wants to merge 2 commits into
passandscore wants to merge 2 commits into
Conversation
Adds scripts/quote-compare.ts, a CLI that fetches Uniswap V3 QuoterV2 and Barter /route quotes side-by-side and compares them against a CoinGecko reference so on-call can attribute which side is responsible when the swap button shows "Amount too small to swap" (>2% Uniswap/Barter disagreement). Output prints inputs, quotes, the gate check, a CoinGecko-anchored attribution verdict, and tailored developer options that only surface when the gate actually fires and only for the determined outlier.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
quote-compare.ts hit a viem readContract overload resolution bug in the Next.js build where authorizationList was incorrectly required. Scripts run via tsx and aren't part of the app bundle, so excluding them from tsc's include keeps the main build green. Also swapped erc20Abi for a minimal inline ABI in quote-compare.ts (decimals + symbol only) for self-containment.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
scripts/quote-compare.ts, an on-demand CLI that fetches Uniswap V3 QuoterV2 and Barter/routequotes side-by-side for a given pair and sell amount, then compares both against a CoinGecko reference price.Why
The swap UI's "Amount too small to swap" copy actually fires on a >2% disagreement between Uniswap and Barter quotes (
MAX_SLIPPAGE_PCTinsrc/hooks/use-barter-validation.ts:10), not on the sell amount being literally small. Without this tool we had no way to quickly attribute which router was the outlier when a user reports the message.Usage
Env vars required:
ALCHEMY_API_KEY,BARTER_API_KEY(already present for the app). Optional:COINGECKO_API_KEYfor higher rate limits on the reference price.Test plan
COINGECKO_API_KEYand confirm the script still runs, skipping the attribution section gracefully.