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

Fix: quote provider has the enable fot flag awareness #399

Merged
merged 11 commits into from
Sep 15, 2023

Conversation

jsy1218
Copy link
Member

@jsy1218 jsy1218 commented Sep 14, 2023

  • What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
    Big fix

  • What is the current behavior? (You can also link to an open issue here)
    There's a bug in the FOT quote and routes calculation path, so that it would cause interface to double quote FOT tax immediately, if we ship Feature: Routing-api support for FOT quote routing-api#362 today.

Let's use BULLET => WETH as an example. Hypothetically interface will issue two requests:

  1. BULLET => WETH exact in with enableFeeOnTransferFeeFetching = true. Then it will writes the routes DB with the cached routes with the pool reserves with the buyFeeBps and sellFeeBps . Interface issued this request as part of their QA/testing.
  2. Degen uses interface issue a BULLET => WETH exact in quote. Since interface has not enabled to pass in enableFeeOnTransferFeeFetching , routing-api will have useCachedRoutes = true, and read from cached routes with the pool reserves with the buyFeeBps and sellFeeBps . Then in sor, it will calculate the routes and quotes with the buyFeeBps and sellFeeBps .

The problem is in (2), interface has no awareness that the quote and routes are from cached routes, and they have the hardcoded FOT tax logic in prod today https://github.com/Uniswap/interface/blob/main/src/hooks/useSwapTaxes.ts. Since smart-order-router also quoted with FOT tax in quote-provider, this is effectively double FOT taxation in prod, before we enable FOT backend support to 100%. And since cached routes hit rate is over +80%, this bug is considered a blocker before we ship Uniswap/routing-api#362.

  • What is the new behavior (if this is a feature change)?
    Quote provider doesn't calculate FOT tax. As such because it also doesn't pass the FOT tax to the outputAmount/inputAmount, the routes returned from routing-api will not include the FOT tax in both token construct as well as the outputAmount/inputAmount.

  • Other information:

@jsy1218 jsy1218 added the bug Something isn't working label Sep 14, 2023
@jsy1218 jsy1218 self-assigned this Sep 14, 2023
@jsy1218 jsy1218 force-pushed the jsy1218/quote-provider-have-enable-fot-flag branch from e9f3fd7 to 8c89735 Compare September 14, 2023 23:32
@jsy1218 jsy1218 changed the title Quote provider has the enable fot flag awareness Fix: quote provider has the enable fot flag awareness Sep 15, 2023
@jsy1218 jsy1218 merged commit 17d6310 into main Sep 15, 2023
6 of 7 checks passed
@jsy1218 jsy1218 deleted the jsy1218/quote-provider-have-enable-fot-flag branch September 15, 2023 15:45
@jsy1218 jsy1218 mentioned this pull request Sep 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants