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: Implement rank by surplus for price improvement #2466

Closed
sunce86 opened this issue Mar 4, 2024 · 0 comments · Fixed by #2520
Closed

feat: Implement rank by surplus for price improvement #2466

sunce86 opened this issue Mar 4, 2024 · 0 comments · Fixed by #2520
Assignees

Comments

@sunce86
Copy link
Contributor

sunce86 commented Mar 4, 2024

Problem

For rank by surplus, we added a function for calculating protocol fees based on the trades as seen onchain.

We miss the implementation for price improvement type:
https://github.com/cowprotocol/services/pull/2448/files#diff-808128d3e1821263540033959417d656a85a317e6e640ec294d271030f88c3cbR200

@sunce86 sunce86 self-assigned this Mar 4, 2024
@squadgazzz squadgazzz assigned squadgazzz and unassigned sunce86 Mar 14, 2024
squadgazzz added a commit that referenced this issue Mar 18, 2024
# Description
Rank by surplus implementation for the Price Improvement fee policy.

# Changes
To properly calculate both `native_surplus ` and `native_protocol_fee`,
the `surplus` function was refactored into `surplus_over_limit_price`
where limit sel/buy amounts should be provided explicitly.
`fee::adjust_quote_to_order_limits` function is used to adjust the limit
amounts in case of the Price Improvement fee policy.

# Current limitations

Either my understanding is incorrect or `fee_from_volume` function
doesn't work correctly for the `max_volume_factor=1.0`. For the sell
order kind, it returns `inf` and for the buy, the factor is adjusted
into `0.5`, which is not really expected.

## How to test
I tested it by adding some logs and running protocol fee driver tests.

## Related Issues

Fixes #2466
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants