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

partyDiscountStats API is returning some interesting numbers #11679

Closed
JonRay15 opened this issue Sep 12, 2024 · 0 comments · Fixed by #11680
Closed

partyDiscountStats API is returning some interesting numbers #11679

JonRay15 opened this issue Sep 12, 2024 · 0 comments · Fixed by #11680

Comments

@JonRay15
Copy link

JonRay15 commented Sep 12, 2024

I found a party that is quite a big player on testnet so has a rebate

query volumeRebateStats {
  volumeRebateStats(partyId:"00b07e02bd56f84f3fcef3635f6a6a1d1cadd66665dbf7f12090e8787ef26571",epoch:532){
    edges{
      node{
        atEpoch
        partyId
        additionalMakerRebate
        makerVolumeFraction
        makerFeeReceived
      }
    }
  }

Then I queried its partyDiscountStats

query partyDiscountStats {
  partyDiscountStats(partyId:"00b07e02bd56f84f3fcef3635f6a6a1d1cadd66665dbf7f12090e8787ef26571"){
    volumeDiscountTier
    volumeRebateTier
    referralDiscountTier
    partyMarketFees{
      marketId
      undiscountedTakerFee
      discountedTakerFee
      baseMakerFee
      userMakerRebate
    }
  }
}

The rebate looks good ... you can see the jump from 0.0002 to 0.0007 which is the expected 0.0005 jump.

BUT .... what in gods name is going on with discounted taker fee!?

  1. It should surely not be negative ... it is meant to be the fee AFTER discount, not the discount amount
  2. Charlie also thinks the UNdiscounted taker fee is missing the treasury and buyback components
{
  "data": {
    "partyDiscountStats": {
      "volumeDiscountTier": 3,
      "volumeRebateTier": 2,
      "referralDiscountTier": 0,
      "partyMarketFees": [
        {
          "marketId": "07d83b233cc0c43b8e46b5384bbbb52bd23d27502c20ba180cfb9c690e0ba6be",
          "undiscountedTakerFee": "0.00071",
          "discountedTakerFee": "-0.09229",
          "baseMakerFee": "0.0002",
          "userMakerRebate": "0.0007"
        },
        {
          "marketId": "0cb6c0893348878cb1d1db0400d094325d6ca7f82fa7ebe7d38fdb3e4a0a1706",
          "undiscountedTakerFee": "0.00071",
          "discountedTakerFee": "-0.09229",
          "baseMakerFee": "0.0002",
          "userMakerRebate": "0.0007"
        },
        {
          "marketId": "90360cb6312346f8a5380cc7d6a7df30583135e743246d68ffd1a51effe7394e",
          "undiscountedTakerFee": "0.00071",
          "discountedTakerFee": "-0.09229",
          "baseMakerFee": "0.0002",
          "userMakerRebate": "0.0007"
        }
      ]
    }
  }
}

Code looks wrong

// undiscounted
base := num.DecimalZero().Add(maker).Add(infra).Add(liquidity)

So its missing buyback and treasury components on the undiscounted

And you cant simply subtract discount factors here....are discounting a proportion of the fees, not directly reducing the free

discounted := num.DecimalZero().Add(maker.Sub(factors.maker)).
	Add(infra.Sub(factors.infra)).
	Add(liquidity.Sub(factors.liquidity))

Also userMakerRebate needs to reflect the possibility that it is being capped by the treasury plus buyback.

ie. userMakerRebate = MAX(userMakerRebate, treasuryFee+buybackFee)

Ideally you would include BOTH the theoretical userMakerRebate from the program AND the actual so that we can tell if it has been capped.

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

Successfully merging a pull request may close this issue.

1 participant