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

feat: apply filter policy before adding an order #176

Merged
merged 1 commit into from
Dec 19, 2024

Conversation

anxolin
Copy link
Contributor

@anxolin anxolin commented Dec 10, 2024

Description

We are not respecting the filter policy in order to add or not add orders from events.

Context

I noticed how staging indexed this an order of an owner that shouldn't have. However, in the next block got dropped because we apply the filtering using the policies at the beginning of processing a block.

This explain this increment + decreement:
image

You can also see this in the logs:
image

Chages

This pr applies the filter policy before adding an order, so we don't add it in the first place.

Test

You can create one TWAP using any account and see how now we don't get this increment and decrement in Grafana.


// Apply the filter policy, in case this order should be dropped
if (filterPolicy) {
const filterResult = filterPolicy.preFilter({
Copy link
Contributor Author

Choose a reason for hiding this comment

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

key part of this PR. We apply the filtering.

conditionalOrderParams,
});

if (filterResult === policy.FilterAction.DROP) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

we only handle DROP, because for SKIP we should add the order

@anxolin anxolin requested a review from a team December 10, 2024 20:22
Comment on lines +210 to +211
blockNumber: number,
context: ChainContext
Copy link
Contributor

Choose a reason for hiding this comment

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

Please update the docstring as well

@anxolin anxolin merged commit 6370028 into main Dec 19, 2024
4 checks passed
@anxolin anxolin deleted the drop-orders-using-policies branch December 19, 2024 20:03
@github-actions github-actions bot locked and limited conversation to collaborators Dec 19, 2024
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.

2 participants