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: Rank by Surplus Tracker #2382

Closed
2 of 5 tasks
sunce86 opened this issue Feb 7, 2024 · 5 comments
Closed
2 of 5 tasks

feat: Rank by Surplus Tracker #2382

sunce86 opened this issue Feb 7, 2024 · 5 comments
Assignees

Comments

@sunce86
Copy link
Contributor

sunce86 commented Feb 7, 2024

Problem

Issue tracker for rank by surplus implementation.
Solutions ranking needs to be changed from rank by score to rank by surplus.

Here is how surplus is defined in the driver:
surplus- raw surplus that is defined by original clearing prices provided by solvers
surplus' = surplus - surplus_fee
surplus'' = surplus' - protocol_fee

So, we want to rank by surplus'.

Tasks:

Nice to have:

@fleupold
Copy link
Contributor

fleupold commented Feb 7, 2024

Change the way the autopilot ranks the solutions

Currently the autopilot just accepts the score from the driver as true. Do we want to change this and have the autopilot compute surplus and fees?

@sunce86
Copy link
Contributor Author

sunce86 commented Feb 7, 2024

Change the way the autopilot ranks the solutions

Currently the autopilot just accepts the score from the driver as true. Do we want to change this and have the autopilot compute surplus and fees?

I would prefer so. If autopilot can calculate the surplus (or any other value we use for ranking) from the solution itself, then there is no need for additional field as part of the /solve response.

@sunce86
Copy link
Contributor Author

sunce86 commented Feb 7, 2024

This is somewhat aligned with the idea explained here: #2225

@fleupold
Copy link
Contributor

fleupold commented Feb 7, 2024

there is no need for additional field as part of the /solve response.

Well, instead (at least as outlined in #2225) there is need for the entire encoded settlement (which is much more than the score). I think if the value can be computed by what we already send then sure let the autopilot verify it, but if not, I think it's fine to trust the driver with this (at the end of the day the driver could also "lie" about their encoded settlement)

@sunce86 sunce86 self-assigned this Feb 19, 2024
@sunce86 sunce86 changed the title feat: Rank by Surplus feat: Rank by Surplus Tracker Mar 3, 2024
sunce86 added a commit that referenced this issue Mar 6, 2024
Replacement for #2406 and
#2421

Implements task 1 from
#2382

Fixes #1494

# Description
Implements surplus and protocol fees calculation, **based on the
solution (received from solvers) trades, which are in a settlement smart
contract format**. This ensures that these values are calculated after
the protocol fee is already applied and the whole settlement is prepared
for settling. This is important because the autopilot (and reward
script) will use the same math so we are aligned 1:1.

The main calculation is in
`crates/driver/src/domain/competition/settled/mod.rs`.

CIP38 scoring is currently called in a read only mode. The score is
calculated but not used.

## How to test
Tested locally with e2e tests. Surplus + protocol fee is always equal to
legacy `quality` - `surplus_fee` which is expected.
@sunce86
Copy link
Contributor Author

sunce86 commented Mar 7, 2024

All tasks covered with individual issues so closing this one.

@sunce86 sunce86 closed this as completed Mar 7, 2024
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

No branches or pull requests

2 participants