-
Notifications
You must be signed in to change notification settings - Fork 75
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
Fix bug when introducing prices for liquidity orders #848
Comments
A bit more context can be found in the slack thread. It also contains logs with concrete examples for the bug. |
Linking #849 as it appears to have the same underlying cause (making liquidity order prices part of |
Added the |
Adding here also that the correct solution should be to recompute from scratch new prices specific to each liquidity order, for both the sell and the buy token. This is because it has been observed that solvers that might be compressing their prices a bit to save on gas have had issues with the execution of liquidity orders, as rounding problems show up that can distort the amounts traded by the liquidity order. One extreme example is the following, where this was no fault of the solver. |
In order for the smart contract to execute an order, it requires prices for both the sell and the buy token. This applies to liquidity orders as well.
It was observed that due to this part of the code (thanks to @MartinquaXD for identifying the line with the bug)
https://github.com/cowprotocol/services/blob/main/crates/solver/src/settlement/settlement_encoder.rs#L392-L398
the driver sometimes introduces a price for the sell token of a liquidity order that is equal to the buy amount, even if there is already a price computed for the buy token. This leads to a very wrong clearing price vector.
The text was updated successfully, but these errors were encountered: