cowprotocol / cowprotocol/services
chore: Executed surplus fee in surplus token
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 318
- Forks
- 189
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 121
Description
Background
Both solver team and frontend team would like to have this field expressed over surplus token, instead of sell token. This would help a lot with showing complete breakdown of fees (network fee, protocol fee, total fee) as protocol fees are already calculated in surplus tokens.
Details
Steps:
- Add
executed_surplus_fee_tokento order_execution database table and populate historic entries with sell token of the order. - Expose the field
executed_surplus_fee_tokenover API wheneverexecuted_surplus_feeis exposed. - Switch to saving surplus fee in surplus token instead of sell token
So, bottom line, there will be a timestamp after which all fees will be in surplus token. For historic entries, executed surplus fee in sell token will remain.
Both solver and frontend team need to cope with this. I assume frontend will have to have a special IF to show things differently depending on if executed_surplus_fee is in sell token (for historic entries) or in surplus token (for new entries). There is also an alternative to try to convert executed_surplus_fee to surplus token for historic entries on the frontend side, where traded sell/buy amounts could be decent approximates (at least in most cases).
In the meantime, we decided to do a manual migration for historic entries, so that ALL fees will be expressed over SURPLUS token, so no special handling will be needed to support backward compatibility.
Acceptance criteria
Complete breakdown of taken fees is exposed on get_trades and get_order endpoints:
- network fee in surplus token
- protocol fees per fee policy, in surplus token
- total fee in surplus token (or maybe omitted since it can be calculated by summarizing (1) and (2))
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Review closed pull requests #3184 and #3224 first, then trace the order_execution database table and the get_trades and get_order endpoints. Verify how executed surplus fees and protocol fees are currently represented, and use the acceptance criteria to confirm that network, per-policy protocol, and total fees are exposed in surplus tokens.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- api, backend, database
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100