-
Notifications
You must be signed in to change notification settings - Fork 50
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
Paris support - fix #703 #704
Conversation
Bare Minimum Barely tested code for now. * look at `delegatedBalance` instead of `balance` in the TzKT API query results * do not include bakers' fees as reward as discussed in issue
delegatedBalance is deprecated, need to sum up `own` and `external` instead also made a note that `currentDelegatedBalance` of delegators is also deprecated
Looks good! The tests currently fail because of KeyError: 'ownDelegatedBalance'.
|
Can you please try? |
@nicolasochem is there any real api calls possible right now with those keys? Or will it only possible after Paris release? Can you link the documentation where these keys are mentioned? Thanks! |
@vkresch yes, from what I can tell it's all available on tzkt ghostnet & mainnet today. API doc: https://api.tzkt.io/#operation/Rewards_GetRewardSplitDelegator |
No, I'm not sure why your delegator rewards would be higher. |
Hello there, I see you updated my previous comment. Thanks for your reply! I’ll elaborate since we tested this PR on one of our Ledger Bakers ( One of our delegators is Looking at calculation reports shows a significant decrease in Here's what our calculations CSV files look like - I'm afraid I had to redact a few columns. Let me know if you need anything else :) I'm not sure if the upgrade will change anything to the calculations, but I think we should handle pre-upgrade cycles as well? PS: please comment instead of updating my comment, it makes it easier to follow the conversation and sends me a GitHub notification. |
@TPXP I didn't mean to edit your comment instead of replying, my bad. This indeed looks like an important discrepancy.
Without AI, this makes sense as it counts equally towards rights and rewards. However, with AI, this substraction no longer makes sense, as only the free balance of the baker and the delegators is taken into account for reward distribution. To give an extreme example, if the baker stakes their entire balance, none of the delegation rewards are theirs and theirs alone; they only take delegation fees. This leads me to believe:
Therefore, your fix is valid before AI, but now, AI is active on mainnet, so it will not be accurate for next cycle. The issue is, I have never touched the payment calculation code. I am having difficulties defining what the |
TzKT offers own_delegated and external_delegated values. We pass them both to the reward calculation function. OWNER_PARENT is the baker's reward. It's named this way because it can split into children rewards when the bakery has several "owners" and "founders" (maybe we should also deprecate this functionality). Now, we populate this value straight from tzkt. We also use it to calculate the ratio. There is a sanity function that ensures that the sum of itemized balances and the total from tzkt are "almost equal". This apparently is still passing. With these changes, I see more realistic values in my caculations: values are lower than with main branch, which makes sense, because the stake has now increased. Also, for my baker, almost all balance is staked, so I only keep an amount of delegation rewards approx. equal to my delegation fee. In contrast, before AI, I would keep my fee plus my own rewards, which now go almost exclusively to the staking balance.
Update - 2024-06-26
The code may now be carefully used to pay rewards for cycle 749.
Do a dry-run first. Here is how to sanity-check your dry-run:
In the logs for your dry-run, you will see the following line:
This value is no longer the total rewards. This is only the part of rewards attributable to delegation. You will get more rewards from staking.
This is not the same value as the one you can see in tzkt "rewards" page, which sums up up delegation and staking rewards. You can however check this value in the API by querying the following:
(replace tz1xyz with your baker address)
A little below, in the logs, you will see the following:
This is what TRD will pay out.
As a public baker, most of your balance is probably staked (and if it is not, you should fix it by running the
stake
command). This has another effect: TRD no longer "carves out" some of the rewards for your own stake. Indeed, your own stake is paid for by the protocol, using the new mechanism.Under AI, most of what TRD pays you is delegation fees. You can sanity check with the 2 values above: if the rewards attributable to delegation are 100 tez, and your fee is 10%, then you should expect TRD to pay out about 90 tez. This is assuming a normal config without any "owners" or "founders" set (I have not tested this). If the values you are seeing in the dry run are significantly outside of this, please reach out on slack.
The amount you will pay out at every cycle will probably be less than what you are used to paying prior to Adaptive Issuance activation. It's normal: in the new model, delegators will earn less, stakers earn more.
How this PR was tested
This PR (commit
eaad513
) was used to pay out rewards for cycle 749 for 2 small-ish mainnet bakers with no issues. One of them is accepting third-party stakers and the other is not. The values are looking good according to the rule of thumb above.Caveat emptor:
What this PR does
delegatedBalance
instead ofbalance
of bakers and delegators, as numeratorblockRewardsDelegated
+endorsementRewardsDelegated
as denominatorDev: 25 hours