-
Notifications
You must be signed in to change notification settings - Fork 15
Conversation
I'm not a fan of having this logic be in shared and on the price estimation trait. Price estimation is specialized component that shouldn't care about about requests are handled, it shouldn't know about warp. If we want to have more code reuse (we don't have to) I'd like that to be a in the api module only. |
Totally fair point. The issue I ran into when trying to implement to_warp_reply for this in the correct place was that I wasn't allowed to implement logic outside the module where the struct was declared. Do you have some suggestion on how this can be more appropriately done? |
You can implement a function |
Another option is to implement
I'm also a fan of just a floating function in this case (I think trait might be a tad overkill here). |
Cool folks thank for the comments. I will go with the free floating function (for now). One the bigger PR has the trait, I can adjust it then. |
Fixed this - now includes only relevant changes to the Missing Price Estimation Error. |
Codecov Report
@@ Coverage Diff @@
## main #1188 +/- ##
==========================================
+ Coverage 67.15% 67.26% +0.10%
==========================================
Files 135 135
Lines 27210 27189 -21
==========================================
+ Hits 18273 18288 +15
+ Misses 8937 8901 -36 |
@@ -77,6 +77,7 @@ impl From<PriceEstimationError> for Error { | |||
match other { |
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.
Maybe Error
type should be:
enum Error {
SellAmountDoesNotCoverFee,
PriceEstimate(PriceEstimationError),
}
This would avoid duplicated error messages as well as error variants.
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.
Looks good. Tiny nit.
While working on the new Fee & Quote endpoint, I noticed that our markets endpoint was returning an internal server error on something that would have been "BAD REQUEST"
Particularly,
https://protocol-mainnet.gnosis.io/api/v1/markets/0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48-0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2/buy/0
and
https://protocol-mainnet.gnosis.io/api/v1/markets/0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48-0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2/sell/0
Which should fail with a
ZeroAmount
error.Test Plan
No logic changes, existing CI.