-
Notifications
You must be signed in to change notification settings - Fork 302
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
dex: rework fill_route to ensure we always make progress #2513
Conversation
app/src/dex/router/fill_route2.rs
Outdated
|
||
frontier_position_ids.insert(next_position_id); | ||
frontier[constraining_index] = next_position; | ||
// TODO: should we remove the old position's ID from the ID set? |
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, but I'm not certain, that we are missing a break 'next_position
. AFAICT, it would make sense to have it here when we have a bona fide next_position
to roll with
app/src/dex/router/fill_route2.rs
Outdated
|
||
// We need to save these positions, because we mutated their state, even | ||
// if we didn't fully consume their reserves. | ||
for position in frontier { |
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 this should be in the filling loop, otherwise we might execute against stale orders on later fils?
Closes #2507 Co-Authored-By: Erwan Or <erwanor@penumbralabs.xyz>
There's a problem with how the way we currently do filling interacts with the way we check spill prices: we only get the effective price _after_ we execute along the frontier, at which point it's too late to bail out and not execute the price-limit-exceeding trades. We can fix this later, the only impact for now is that the price limit may be exceeded, giving a suboptimal route.
Closes #2507 , along the lines of the comments there.