web
web copied to clipboard
feat: getTradeRate swapper endpoint
Description
This PR brings getTradeRate()
as en endpoint
- For ZRX, brings in the notion of a temporary "pseudo trade quote" so things are non-breaking for current
getTradeQuote
endpoints. The current implementation won't play nice with the split of trades and quotes, since our current endpoint is a mix of both (calls the inner/price
fetcher, but assumesquote
input, and does some gas calcs that assume wallet is present). - For Portals, CoW, Arb Bridge, Li.Fi and THOR we're talking a proper split between the two
- Gets rates instead of quotes if the
PublicTradeRoute
flag is on (which it will never be for the time being, including for dev, unless you explicitly set it totrue
)
Issue (if applicable)
- contributes to (but doesn't consume) https://github.com/shapeshift/web/issues/7941
- contributes to https://github.com/shapeshift/web/issues/7979
Risk
High Risk PRs Require 2 approvals
What protocols, transaction types, wallets or contract interactions might be affected by this PR?
Testing
Engineering
⚠️ Note: This inherently breaks execution with the PublicTradeRoute
flag on, which is expected. The flag has been disabled not to break dev until this is fully wired up.
Test all the below with the PublicTradeRoute
flag off
- Able to get quotes for (and execute) permit2 ZRX with permit2 flag
- Able to get quotes for (and execute) classic ZRX without permit2 flag
- Able to get quotes for (and execute) Portals (note, this is a non-breaking change, hence the super hacky "quote then maybe estimate then maybe another dummy quote" flow is still present, to be removed when we wire this up with rates instead of quotes, with "TBA" for network fees)
- Able to get quotes (and execute) for CoW
- Able to get quotes (and execute) for Li.Fi
- Able to get quotes (and execute) for THOR
Test all the below with the PublicTradeRoute
flag on.
How to confirm whether you're getting rates or quotes? Well, the easiest is to ensure that the newly added getTradeRate
swapper endpoint is hit, with a debugger breakpoint. Alternatively/additionally, you can also ensure that sell/receive addies are not passed upstream as params when getting rates, e.g:
- for ZRX classic without permit2 flag, able to get rates
- for ZRX permit2 with permit2 flag, able to get rates
- for Portals, able to get rates
- for Arb Bridge, able to get rates
- for Li.Fi, able to get rates
- for THOR, able to get rates
- for CoW, able to get rates
Operations
- [ ] :checkered_flag: My feature is behind a flag and doesn't require operations testing (yet)
- Able to get quotes for all swappers and execute them e2e. Do not try and test this with the
PublicTradeRoute
flag on yet, this is heavily WIP and for eng. only.
Screenshots (if applicable)
PublicTradeRoute
flag on
- for ZRX permit2 with permit2 flag, able to get rates
https://jam.dev/c/a7e4e489-5c61-4d70-a59f-ed7a9499d398
- for ZRX classic without permit2 flag, able to get rates
https://jam.dev/c/7a2cbb00-4b95-41e7-80cf-d90d274f0d00
- for Portals, able to get rates (note, network fee is TBD here)
https://jam.dev/c/2692f3d7-5634-4612-8e62-f49f1457aea6
- for Arb Bridge, able to get rates
https://jam.dev/c/e8ec9489-22d0-474a-9ad0-1925038e1bcc
- for Li.Fi, able to get rates
https://jam.dev/c/23a87d54-561e-4241-bbbe-21781cacc088
- for THOR, able to get rates
https://jam.dev/c/b5075a07-7556-4051-892c-158aab62bbde
Flag off
- Able to get (and execute) quotes for permit2 ZRX with permit2 flag
https://jam.dev/c/b70a050e-b8a0-49f2-8cf2-479596f98e9d
- Able to get (and execute) quotes for classic ZRX without permit2 flag
https://jam.dev/c/3fbf7210-fa66-4866-98a8-b4a581fcebcb
- Able to get (and execute) quotes for Portals
https://jam.dev/c/fcb4b5ae-fdd4-4c6b-be58-712af1f839dd
- Able to get quotes (and execute) for CoW
https://jam.dev/c/3293a6a6-f666-41ab-80d5-325ff34f5f21
- Able to get quotes (and execute) for Li.Fi
Unable to test because of current Li.Fi rate limits
- for THOR, able to get (and execute) quotes
https://jam.dev/c/608f187f-fa7e-492f-a47b-81df3d59d4c6