Closed anxolin closed 10 months ago
The latest updates on your projects. Learn more about Vercel for Git ↗︎
Name | Status | Preview | Updated (UTC) |
---|---|---|---|
explorer-dev | ✅ Ready (Inspect) | Visit Preview | Dec 21, 2023 11:59am |
Totals | |
---|---|
Change from base Build 7248021046: | 0.0% |
Covered Lines: | 878 |
Relevant Lines: | 1237 |
This change requires fixes on the CoW Swap side as well: surplus percentages should match on Explorer and on order receipt
Thanks for adding sell orders. I was not 100% sure we want this formula for them as its discussed in https://cowservices.slack.com/archives/C035N0YEB6J/p1703098943291339
however, probably I also lean to this implementation of surplus
Summary
Surplus for buy orders is broken.
Look at this example. The numbers match to me on how we define the order:
50% slippage, it means in this example we need to add to the sell amount half of the sell amount in this case
0.049 * 0.5 = 0.0245
Our buy order max sell amount is
0.0735
So far so good 😊
Imagine we execute the order, and we get exactly the quote (
0.049
)The surplus sould be 50%, right?
However the explorer does this:
(0.049-0.0735)/0.0735
So we think surplus is
33.33%
❌What is the mistake in the explorer?? I believe we need to divide by the received price, not by the limit price in this case.
But Order Surplus = How much less I spent / How much I received
Take this order as an example: 0x1f9b14a849a1a903eab355ae6240cebb7174f4168064014cb46641f02e2d90f779063d9173c09887d536924e2f6eadbabac099f5658318db
https://explorer.cow.fi/gc/orders/0x1f9b14a849a1a903eab355ae6240cebb7174f4168064014cb46641f02e2d90f779063d9173c09887d536924e2f6eadbabac099f5658318db?tab=overview
This PR: https://explorer-dev-git-fix-surplus-buy-orders-cowswap.vercel.app/gc/orders/0x1f9b14a849a1a903eab355ae6240cebb7174f4168064014cb46641f02e2d90f779063d9173c09887d536924e2f6eadbabac099f5658318db?tab=overview
context
https://cowservices.slack.com/archives/C0361CDD1FZ/p1703089134101259
Test
sell/buy orders should work same as before