-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# Description The computation of surplus fees for partially fillable limit orders happens delayed in the co-located world. This is because at the time of solution ranking, the autopilot doesn't have access to the executed amounts for each order (something that #1949 will hopefully address). We therefore wait to populate the surplus fee until the settlement (and thus the different order specific clearing prices which incorporate the fee) has been observed on-chain. The logic that then computes the fee loads and updates the existing executions from the DB. However, it simply assumes there is no surplus fee computation if a "solver fee" is set: https://github.com/cowprotocol/services/blob/efa7c756ff9e58b8ae3258d5715f86e2ee04185f/crates/autopilot/src/decoded_settlement.rs#L336-L338 If we look at the code that is writing this value we see that currently this fee is always set to 0! Therefore we also assume that the surplus fee is zero and are not reporting it for limit orders (e.g. [this one](https://explorer.cow.fi/orders/0xf61a074c198e0b8556eb07784a137f664023822ab05f3ff368883f1ed7e7eb5dffab14b181409170378471b13ff2bff5be012c64654f6e8a?tab=overview)). The fix is to set a NULL instead of 0 solver fee when writing the original order execution. Alternatively, we could also fix the fee computation in `decode_settlement` to always add a potential solver fee and the discrepancy between uniform and order specific clearing prices (if any) as those are effectively fees. This would be necessary if we ever allowed both type of fees (fixed + surplus fees). I'm not sure if this is necessary though. # Changes - [x] Make solver fee optional on save order_executions - [x] Set it to None for orders where fee is set from surplus ## How to test - [x] e2e test ## Related Issues Fixes #1959
- Loading branch information
Showing
5 changed files
with
33 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters