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

Add 1 ppm fee to univ3 cal calculator #590

Merged

Conversation

barakman
Copy link
Collaborator

@barakman barakman commented May 1, 2024

No description provided.

@barakman barakman requested review from NIXBNT and sklbancor May 1, 2024 10:14
Copy link
Collaborator

@sklbancor sklbancor left a comment

Choose a reason for hiding this comment

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

to be converted to issue -- current solution OK to fix problem at hand

Situation

The way we are dealing with this is for historical reasons, and it is somewhat bad. To provide context: in Uniswap v3 like AMMs there is a parameter called tick-spacing that determines the size of their atomic ranges, and the original authors linked the tick-spacing to the the transaction fee. Whilst this is economically directionally sensible there is no natural relationship between tick size and fees, therefore Uniswap 3 style exchange could make changes to this relationship, including

  1. they respect the Uv3 relationship between fees and tick size, but introduce additional fee tiers with their associated tick sizes that then become canon
  2. they maintain a relationship between fees and tick size, but they do not respect Uv3 choices (or canonic choices introduced by others before them)
  3. they do not maintain a relationship between fees and tick size

At the moment we seem to be in situation (1) which is lucky because our approach of parameterization only works for situation (1). As soon as we get to (2) or (3) we will need to find another approach, and I suggest scheduling this rather than doing it last minute.

Also at the moment we use floats as keys for a dict which I really really do not like, even if it is legal

Proposal

What I propose is the following:

  1. We get rid of the fee constants; instead we agree that we always denominate fees in 1/100s of basis points or something and so they are ALWAYS ints
  2. We then have a two-stage dict that associates the tick size to the fee level
TICKSIZE = {
  "<exchange>": {
      <fee>: <ticksize>,
    ...
    }
  }

This allows as to operate in scenario (2), and it also allows us to catch fee levels that are illegal for that exchange.

if we want to support scenario (3) we also need to allow for free choice of fee and tick size

Copy link
Collaborator

Choose a reason for hiding this comment

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

OK to remove

@barakman barakman merged commit d5b53f2 into update-data-files-24-april May 1, 2024
1 check passed
@barakman barakman deleted the add-1-ppm-fee-to-univ3-cal-calculator branch May 1, 2024 10:42
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 this pull request may close these issues.

3 participants