-
Notifications
You must be signed in to change notification settings - Fork 54
🎶 ABA Test: Sell and buy back to calculate slippage #1495
Comments
As we discussed in the sync, @W3stside this could be implemented after #1689 Also, we mentioned about writing down an example for buy sell orders. As I see it, the ABA test will have different parts. The most important will be a function that receives the original amount of FROM tokens, and the estimated FROM tokens you get back after trading forth-and-back. What forth-and-back means for:
|
So, if this method is correct, the generalised formula should be:
Note that depending how u define Pba u might need to divide instead of multiply inside the square root. In the formula is supposed to be the price expressed in the same quote, this way is multiply, but if it’s just the inverse should be a division For a practical example, we could use the original:
|
Hey @anxolin , will we explain somehow to a user that calculation of the price impact has changed? |
Good question. In principle we would avoid adding it to FAQ, ideally should be easy to understand the number (it should give reasonable numbers). If users ask a lot, we could give more context |
Description
Xdai, has many USD estimations missing. This is because, ther USD oracles are for mainnet.
This ABA test (A->B->A test) cosist on simulate doing a trade back and forth the asset, and see how much you get back from your original.
In a naive implementation we could say that slippage is half of that.
i.e.
10 DAI gives me 9 USDC
9 USDC gives me 8 DAI
100 * (10-8)/10/2 ----> 10%
However, dividing by two wouldn't give us the estimated slippage.
The idea is to solve it in the following way:
Context:
https://gnosisinc.slack.com/archives/CPZA1AGKY/p1632220484032000?thread_ts=1632210034.021000&cid=CPZA1AGKY
The text was updated successfully, but these errors were encountered: