Closed gomesalexandre closed 3 months ago
Note - this directly related to Portals, as without implement this, we won't be able to get network fees at quote time if the Tx simulation fails upstream (i.e for the cases mentioned above)
@gomesalexandre just came across this. We are implementing improved simulations which will return accurate estimates/gas even if the sender doesn't have the tokens or approvals in place. Should be about 2-3 weeks and will use the same /estimate endpoint with no changes needed.
That sound sperfect @suhailgme! Let us know when that's implemented, we may even revert this guy to leverage only upstream estimates again.
Also: closed by https://github.com/shapeshift/web/pull/7439
Overview
Currently upstream, some swappers do have some magic to do fees estimation for Txs with:
They usually expose this as an optional
validate
option, see e.g ZRX enforcing validation at trade execution with thepriceOrQuote
optionhttps://github.com/shapeshift/web/blob/c3bac3d447f8aff54f9257002aca62aaab9a2153/packages/swapper/src/swappers/ZrxSwapper/endpoints.ts#L45-L47
but ditching validation and letting ZRX do its magic at
quote
time:https://github.com/shapeshift/web/blob/c3bac3d447f8aff54f9257002aca62aaab9a2153/packages/swapper/src/swappers/ZrxSwapper/getZrxTradeQuote/getZrxTradeQuote.ts#L74-L75
Arbitrum Bridge is an example of a swapper which does not support such magic, and the WIP Portals swapper will be another one.
We should implement the samg magic as upstream to allow fees estimates in this case.
References and additional details
This could be implemented with something like this (pseudo-ish code):
i.e the naive implementation is:
vitalik.eth
's addyOnce you get those dummy params, make a second, dummy request upstream in case the first one fails simulation with those params, and voila 🎉 you get a new quote/Tx data can succesfully be simulated!
Obviously, we may want to have an address per chain if
vitalik.eth
. doesn't work for all of our EVM chains, as well as possibly changing the dummy token per chain, but the high-level idea is hereAcceptance Criteria
Need By Date
No response
Screenshots/Mockups
No response
Estimated effort
No response