-
Notifications
You must be signed in to change notification settings - Fork 15
Conversation
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 like that this will give us full control to implement arbitrary fee logic based on the order data (without requiring more updates in the frontends). We just need to make sure we consolidate/clean up our various fee endpoints.
We can add a |
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 like this api and also think we should remove the other fee related endpoints then. Would like to hear from frontend too what they think about this api.
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.
@anxolin What we ultimately want though, is to have custom logic for determining fees based on the full order parameters and not just the app ID. So in this case, the header is not enough. For example, we may want to check what the So the idea of the API is to pass as much of the order data as possible to the price/fee computation end point. This way we are more "future proof" and don't need to keep adding new header parameters as we consider different order parameters for determining the fee subsidy. I hope this makes sense 😄. |
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.
Love this. Happy to implement the test once this has landed!
If this is essentially considered set in stone, then I would start implementing this feature on top of this branch. Will wait, however, on the go ahead. |
Sure it does 👌 |
orderbook/openapi.yml
Outdated
responses: | ||
200: | ||
description: Quoted order. | ||
content: | ||
application/json: | ||
schema: | ||
$ref: "#/components/schemas/OrderQuote" | ||
400: | ||
description: Error quoting order. | ||
content: | ||
application/json: | ||
schema: | ||
$ref: "#/components/schemas/FeeAndQuoteError" | ||
403: | ||
description: Forbidden, your account is deny-listed | ||
429: | ||
description: Too many order placements | ||
500: | ||
description: Error quoting an order |
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 can't see the difference here between 400 and 500 errors - both are "Error quoting order".
Also, is the pattern for #/components/schemas/FeeAndQuoteError
defined here, because it doesn't appear to be.
I think we may also be missing some possibilities here. For example;
- UnsupportedToken(H160),
- TransferEthToContract,
- SameBuyAndSellToken,
- UnsupportedBuyTokenDestination(BuyTokenDestination),
- UnsupportedSellTokenSource(SellTokenSource),
- ZeroAmount,
I can't really see the reason for the 429 here, unless we mean to change this to "RateLimited" too many quotes? but this could easily be worked around.
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.
Might be cute to encapsulate all these different specifics into the single FeeAndQuoteError which i imagine is the intention here. Something like
pub enum PostQuoteResult {
QuoteConstructed(OrderQuote),
FeeAndQuoteError(FeeError),
Forbidden,
}
pub enum FeeError {
UnsupportedToken(H160),
TransferEthToContract,
SameBuyAndSellToken,
UnsupportedBuyTokenDestination(BuyTokenDestination),
UnsupportedSellTokenSource(SellTokenSource),
ZeroAmount,
}
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.
#/components/schemas/FeeAndQuoteError
already exists (ans is used by the feeAndQuote
route). Since the errors are the same, I just reused the error name for now.
Additionally, we would probably reuse the error type from the existing feeAndQuote
route.
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.
That sounds reasonable, but what about all these other responses that seem out of place
403:
description: Forbidden, your account is deny-listed
429:
description: Too many order placements
500:
description: Error quoting an order
as I see it, the only things we will need here are
#[derive(Serialize)]
pub enum OrderQuoteResult {
QuoteConstructed(OrderQuote),
FeeAndQuoteError(FeeAndQuoteError),
}
along with some possible rate limiting...
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.
along with some possible rate limiting...
That is what the 429 is for AFIAU:
429:
description: Too many order placements # i.e you quoted too many orders and are being rate limited. We should `s/placements/quotes/` to make the error a bit clearer.
Additionally, 500
is used as a catch all "internal server error" - i.e. something unexpected went wrong.
Finally:
403:
description: Forbidden, your account is deny-listed
Since the from
is passed in, we can also check that the owner is forbidden by address (we have an "owner deny list" already).
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.
Fixed 429 description and added "unexpected" to 500 description.
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.
There appears to be something missing in the description of 429 here in your comment...
We should `s/placements/quotes/` to make the error a bit clearer.
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.
It was changed to:
429:
description: Too many order quotes
I have opened a draft PR #1155 based on this branch which essentially fills in the unimplemented code routes with the existing fee calculation logic. I know there is an issue listing some of the requirements for the new fee logic, but can't seem to find it. |
I will do some final fix ups and merge this then. |
@nlordell let us know when we this hits production, or when u want us to start using the new endpoint Also, we should let Balancer know too, right? |
Its still a little off from being implemented (probably ~ 2 weeks away). |
This PR proposes a new API enpoint for quoting fees and prices for orders in a way that more complete order data is specified. This allows the fee quoting mechanism to take app ID as well as balance sources (i.e. Vault balances for example) to be taken into account. In the future, things like the order owner can also be checked to see if they are staking some GP tokens in order to give them better fees as well.
Test Plan
This PR just introduces a new end point and the OpenAPI specification for it. The implementation will come in a future PR.
ALso, you can test that the new route returns a 500 error with message "not implemented":