-
Notifications
You must be signed in to change notification settings - Fork 82
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
Exclude orders with low cost coverage #200
Conversation
Codecov Report
@@ Coverage Diff @@
## main #200 +/- ##
==========================================
- Coverage 64.75% 64.56% -0.19%
==========================================
Files 190 189 -1
Lines 39033 38926 -107
==========================================
- Hits 25275 25134 -141
- Misses 13758 13792 +34 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would be willing to push the PR over the finish line but it feels like I'm not getting the big picture. Silently ignoring orders only because they became inconvenient for us seems shady.
Should we maybe disallow very long order validity times instead if we are afraid of bad gas cost coverage (only for orders where we want to collect a fee)?
Or publicly announce that we might ignore valid orders in certain cases?
Or maybe cancel low gas cost coverage orders with a reasonable error message such that users know what's going on and can decide on their own whether they want to submit another order with a higher gas price?
(order.clone(), fees) | ||
}); | ||
let orders_with_fee_parameters: Vec<(Order, FeeParameters)> = | ||
futures::future::join_all(orders_with_fee_parameters).await; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be nicer to only make a single request to the database.
To do that the function fetching the data from the database would have to be adapted slightly:
async fn fees_of_orders(&self, uid: &Vec<OrderUid>) -> Result<HashMap<OrderUid, FeeParameters>>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mmhh, looks like implementing this is not trivial at the moment: sqlx faq
I tried to follow the example which led to following error which suggests this approach is probably not want we want.
"DATABASE_URL" must be set to use query macros
I believe the QueryBuilder
should also enable us to fetch multiple fees per query but that seems very verbose. Will keep it in the back of my head.
Edit: Looks like this also requires us to update from sqlx 0.5.11
to 0.5.13
🙄
Since I had some concerns about the this PR I did some research on how much of a difference this would make. While doing this investigation I stumbled across a problem with how we store fee infomation for liquidity orders. Currently all fee information entries for liquidity orders say that the order does not use any gas and it also does not record the gas price at the time of creation. This was an easy way to implement 0 fees for liquidity orders but decreases our accuracy of gas cost analyses. The analyzed time spans did not include any liquidity orders which would have been filtered out by the new PR so it wouldn't have skewed the results. I analyzed 2 time spans:
Total orders: 1359
Total orders: 1521 To get the total ETH spent in a time span I used the etherbalance graph. So to conclude: I still have concerns about the ethics of this PR given the fact that it wouldn't even significantly reduce our gas costs. Note that those 2 analyses were done for very volatile times and even those didn't show very promising results. |
Supersedes #200 This PR adds new restrictions for orders, they have a maximum valid `validTo` value. The default is for 3 hours in the future (the same maximum as we have in the CowSwap FE). This new restriction does not apply to liquidity orders (since they don't have the same issue with gas price quotes being WAY off). We also don't apply the restriction to pre-sign orders, since they are, arguably much riskier to abuse (because of the required transaction). ### Test Plan Added test cases testing new conditions for the order validity restrictions.
Superseded by #224. |
Hey guys
This is just a very quick handover of the current state for the task to exclude low cost coverage orders from the solvable order endpoint since I am on holiday.
I think the PR is in a reasonable state, hopefully it just needs some smoothening and polishing. It would be great if it would get a review and if then someone could actually push this PR over the finish line.
I left one todo in the code, but I am not sure it's even necessary. I think it would give a minor performance improvement that is bought with more complexity during order fetching.