This repository has been archived by the owner on Dec 20, 2024. It is now read-only.
Fix volume cap for protocol fees for sell orders #67
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The cap for volume fees in the current code is based on the assumption that the protocol fee on surplus for sell orders is a fraction of the amount received by the user, i.e., a fraction of the total buy amount. The implementation in the driver is based on the cap being a fraction of the amount sent by the user, i.e., a fraction of the total sell amount. This resulted in an issue due to fees in sell tokens being implicitly converted to buy tokens via the uniform clearing price and not using effective directional prices.
This PR changes the cap for SELL orders to be consistent with the current driver implementation.
This requires re-syncing data to dune.
The code should be changed back in combination with a fix to the driver for rank by surplus since the concept of observed fee has no meaning there.