Skip to content
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

feat: add autorouter API URL param #54

Merged
merged 49 commits into from
Jul 21, 2022
Merged

Conversation

kristiehuang
Copy link
Contributor

@kristiehuang kristiehuang commented Jul 5, 2022

The Swap Widget computes the optimal trade route by running the @uniswap/smart-order-router package locally in the browser. This can take a few seconds to load & is slow.

  • Allow an integrator to optionally provide a base url to their own hosted instance of the router-api.
  • If baseUrl provided, use routerAPI with fallback to clientside SOR package. Else, use clientside SOR.
  • Also, we deprecate usage of useV2/V3Quoters in favor of using the clientside SOR router.

Provider needs to support eth_feeHistory

@vercel
Copy link

vercel bot commented Jul 5, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
widgets ✅ Ready (Inspect) Visit Preview Jul 20, 2022 at 8:45PM (UTC)

@vercel vercel bot temporarily deployed to Preview July 5, 2022 23:46 Inactive
@vercel vercel bot temporarily deployed to Preview July 7, 2022 19:49 Inactive
@kristiehuang kristiehuang changed the title wip: feat: add autorouter param feat: [wip] add autorouter API URL param Jul 7, 2022
@vercel vercel bot temporarily deployed to Preview July 7, 2022 21:43 Inactive
@vercel vercel bot temporarily deployed to Preview July 7, 2022 22:23 Inactive
@vercel vercel bot temporarily deployed to Preview July 7, 2022 22:44 Inactive
@vercel vercel bot temporarily deployed to Preview July 7, 2022 22:51 Inactive
@vercel vercel bot temporarily deployed to Preview July 7, 2022 22:58 Inactive
@@ -23,6 +23,7 @@ const DEFAULT_GAS_QUOTE = 2_000_000
* @param amountSpecified the exact amount to swap in/out
* @param otherCurrency the desired output/payment currency
*/
// TODO: delete this function & deprecate it after swapping out USDC usage for SOR
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will do this in a separate PR

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

after swapping out USDC usage for SOR

What is this referring to?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

useUSDCPrice still uses useV2Quoter & useV3Quoter to calculate the price in USDC of the input currency - but now that we have a multichain SOR, we can deprecate those in favor of using SOR

Copy link
Contributor Author

@kristiehuang kristiehuang Jul 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#58 (edit: i've merged that into this branch)

@kristiehuang kristiehuang changed the title feat: [wip] add autorouter API URL param feat: add autorouter API URL param Jul 7, 2022
src/state/index.tsx Outdated Show resolved Hide resolved
amount: debouncedAmountSpecified,
tradeType,
routerUrl,
provider: library as JsonRpcProvider,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we somehow verify that library is in fact a jsonrpcprovider instead of casting?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and throw error if not

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

library is of type (JsonRpcProvider & { provider?: ExternalProvider }) | Web3Provider and Web3Provider extends JsonRpcProvider

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so we should be good

src/hooks/routing/useRouterTrade.ts Show resolved Hide resolved
src/hooks/routing/useRouterTrade.ts Outdated Show resolved Hide resolved
src/state/index.tsx Outdated Show resolved Hide resolved
src/state/routing/slice.ts Show resolved Hide resolved
@vercel vercel bot temporarily deployed to Preview July 15, 2022 14:36 Inactive
@vercel vercel bot temporarily deployed to Preview July 15, 2022 14:50 Inactive
@vercel vercel bot temporarily deployed to Preview July 20, 2022 15:33 Inactive
@vercel vercel bot temporarily deployed to Preview July 20, 2022 19:05 Inactive
Copy link
Member

@ianlapham ianlapham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good now good work!

@vercel vercel bot temporarily deployed to Preview July 20, 2022 20:01 Inactive
@vercel vercel bot temporarily deployed to Preview July 20, 2022 20:45 Inactive
@kristiehuang kristiehuang merged commit 1bba87a into main Jul 21, 2022
@kristiehuang kristiehuang deleted the feat/auto-router-params branch July 21, 2022 19:27
@github-actions
Copy link

github-actions bot commented Aug 9, 2022

🎉 This PR is included in version 2.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants