-
Notifications
You must be signed in to change notification settings - Fork 83
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
bug: Driver creates non-settleable cow amm orders #3102
Comments
AFAICS the |
What happens in our example from above: Pool has 0.5WETH and 5 USDC reserve, we properly create cow amm template order with sell_amount = 0.25 WETH and buy_amount = 4.5 USDC. This is the core issue. If we created template order with sell_amount = 0.25 WETH and buy_amount = 2.5 USDC (so that is passes the |
Yes, I think the core issue is in the helper contract (it should only return orders that also pass the verify function later). Let's close this once #3110 is working |
# Description Signature verification is now part of order creation for cow amm orders. # Changes <!-- List of detailed changes (how the change is accomplished) --> - [ ] isValidSignature call is executed as part of creating the cow amm order ## How to test Cow amm e2e test should confirm no new issues are introduced. Fixes # #3102 --------- Co-authored-by: MartinquaXD <[email protected]>
Problem
On Sepolia,
driver
created a cow amm order with somesell_amount
andbuy_amount
.Baseline and Quasimodo solvers solved this order successfully.
But, both solutions reverted when simulated.
The reason is a check in the BCowPool:
This code checks if the cow amm order's
buy_amount
is too large, to prevent big price impacts when rebalanced. If thebuy_amount
is too large, and since cow amm orders are SELL orders that need to be executed with AT LEASTbuy_amount
of buy token, then buy tokens inserted into the BCowPool would move the price too much, and that should be prevented with this check, which is fine.However, this check is not good for partially fillable orders, which have the same order's
sell_amount
andbuy_amount
, but are executed partially (with let's say 1% of full amount), so they wouldn't move the price as the full order'sbuy_amount
would (but this can't be fixed as BCowPool implementsisValidSignature
and that is the only place where pool constraints are checked and only the signed order data is available there).Anyway, the BCowPool is deployed, so the only workaround is to adjust the
CowAmmLegacyHelper
contract, which defines the created order'ssell_amount
andbuy amount
, to consider the BCowPool's check and lower thebuy_amount
, otherwise thebuy_amount
is so high that it would require solutions that move the price too much and all solutions would revert always.Impact
Solver properly solves cow amm order but the order always fails the simulation because the order
buy_amount
never passes the check.Expected behaviour
Order's sell and buy amounts should be defined in such a way to always pass these basic checks, and then the solvers would propose another solutions, where some of those solutions would not cause too much price impact and would have a chance to pass simulation.
The text was updated successfully, but these errors were encountered: