Skip to content
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

Limit order fees #690

Merged
merged 5 commits into from
Nov 2, 2022
Merged

Limit order fees #690

merged 5 commits into from
Nov 2, 2022

Conversation

sistemd
Copy link
Contributor

@sistemd sistemd commented Oct 31, 2022

Progress on #643.

Quotes limit orders whenever an auction is cut. The next PR will start caching the calculated fees to reduce the frequency of quoting, since quoting isn't cheap.

Note that the fee does not get stored anywhere in out database yet.

Refactored some interfaces to make things more explicit and to try to illustrate business logic a tiny bit more clearly.

Test Plan

Currently the change is not covered by tests. I will add an E2E test once it makes sense.

Release notes

Adds a new field to the Order type. This is a backwards-compatible change.

@sistemd sistemd force-pushed the limit_order_fees branch 2 times, most recently from 321744b to 31c587d Compare October 31, 2022 16:46
@sistemd sistemd marked this pull request as ready for review October 31, 2022 16:51
@sistemd sistemd requested a review from a team as a code owner October 31, 2022 16:51
crates/autopilot/src/solvable_orders.rs Outdated Show resolved Hide resolved
Comment on lines +376 to +385
let gas_price_estimator = Arc::new(InstrumentedGasEstimator::new(
shared::gas_price_estimation::create_priority_estimator(
&http_factory,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: The block instantiating the quoter could be moved right before the solvable_orders_cache. Then the solvable_orders_cache wouldn't need to be moved at all which shrinks the PR diff a bit.

crates/shared/src/order_quoting.rs Outdated Show resolved Hide resolved
crates/shared/src/order_quoting.rs Outdated Show resolved Hide resolved
Comment on lines +242 to +244
/// Quotes all limit orders and sets the fee_amount for each one to the fee returned by the
/// quoting process. If quoting fails, the corresponding order is filtered out.
async fn set_limit_order_fees(&self, orders: Vec<Order>) -> Vec<Order> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think even when caching gets introduced in a follow up PR time boxing the fee calculation might be needed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. In the same module we also have a time limit on native prices. Should do something similar for getting as many quotes as possible and run both tasks at the same time.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for letting me know @vkgnosis, that's good to know.

crates/autopilot/src/solvable_orders.rs Outdated Show resolved Hide resolved
@sistemd sistemd force-pushed the limit_order_fees branch 2 times, most recently from afc44e3 to 3a62da0 Compare November 1, 2022 19:36
crates/shared/src/order_quoting.rs Outdated Show resolved Hide resolved
@sistemd sistemd merged commit aba52e9 into main Nov 2, 2022
@sistemd sistemd deleted the limit_order_fees branch November 2, 2022 09:17
@github-actions github-actions bot locked and limited conversation to collaborators Nov 2, 2022
Comment on lines +65 to +68
self.optimal_quoter
.store_quote(quote)
.await
.map_err(CalculateQuoteError::Other)?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hoisting this up to the API level was a good choice.

Copy link
Contributor

@nlordell nlordell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the late review, but looks good!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants