-
Notifications
You must be signed in to change notification settings - Fork 179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: stricter typing for router query #548
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@@ -111,13 +111,13 @@ async function getQuote( | |||
const amount = CurrencyAmount.fromRawAmount(baseCurrency, JSBI.BigInt(amountRaw ?? '1')) // a null amountRaw should initialize the route | |||
const route = await router.route(amount, quoteCurrency, tradeType, /*swapConfig=*/ undefined, routerConfig) | |||
|
|||
if (!amountRaw) return INITIALIZED | |||
if (!route) return NO_ROUTE | |||
if (!amountRaw) return { state: QuoteState.INITIALIZED } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when does this case happen? shouldn't this be part of the skipToken case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the slow part of CSSOR is initialization - that first time a token pair is checked. but it's not even getting the quote, it's initializing the data to get the quote.
so as soon as we have a pair, we make a query with a null amount, signifying that it's just an initialization. the client-side code will replace null with 1 so that it fetches the necessary initializing data, and then return QuoteState.INITIALIZED.
then, when we make a real query, it's nearly instant!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤦♀️ oy VEY!
🎉 This PR is included in version 2.47.7 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Narrows typings for router queries, which avoids having to coerce types in useRouterTrade.
This will enable cleaner code for a planned perf event hook (see #549).
Also uncovers and fixes a bug for swaps with no quote (
QuoteState.NOT_FOUND
), which do not include ablockNumber
but should still be rendered.