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

Research: Unclaimed rewards and commissions design #668

Open
calvinaco opened this issue Jan 21, 2022 · 1 comment
Open

Research: Unclaimed rewards and commissions design #668

calvinaco opened this issue Jan 21, 2022 · 1 comment
Assignees

Comments

@calvinaco
Copy link
Collaborator

Task Details

  • Implement rewards (proposer rewards, block rewards) and commissions event
  • Include balance logic in account projection
  • Test if the balances matches with the gRPC with height call
  • If not, follow-up missing events

Definition of Done

  • Evaluate if account rewards and commissions from events is feasible
@davcrypto
Copy link
Contributor

davcrypto commented Feb 8, 2022

Staking

Staking Shares

  • validators will issue share to its delegators for every delegation
  • total shares : total tokens, this ratio is 1:1 at the beginning
  • if slash happened, the ratio will be change according to the tokens remaining on the validators

Issuing shares = delegator stake amount x (validator total shares / validator total tokens)

Staking Reward

  • All block rewards will go to a separated pool of a validator, which emitted a rewards event
  • If there is a proposer reward, an proposer_reward event will be emitted together. But the reward pool will be incremented once only (no double count issue).
  • amount value of those events are included the commission, need to be deduct by a commission rate
  • All rewards will be deducted from the reward pool when delegators withdraw reward
  • The withdraw amount would calculate according to the ratio of the delegator bonded tokens : total tokens on the validator

Delegator rewards = delegator bonded tokens x ( ( validator rewards / validator tokens ) [now] - ( validator rewards / validator tokens ) [at the beginning of the staking or at the last withdraw action] )

Events exmaple:

     {
        "type": "proposer_reward",
        "attributes": [
          {
            "key": "amount",
            "value": "241502067.800000000000000000basetcro",
            "index": true
          },
          {
            "key": "validator",
            "value": "tcrocncl14fzksz5h72et4ssjtqpwsmhz6ysk6r4na5tr63=",
            "index": true
          }
        ]
      },
      {
        "type": "rewards",
        "attributes": [
          {
            "key": "amount",
            "value": "241502067.800000000000000000basetcro",
            "index": true
          },
          {
            "key": "validator",
            "value": "tcrocncl14fzksz5h72et4ssjtqpwsmhz6ysk6r4na5tr63=",
            "index": true
          }
        ]
      }

Staking Commission

  • Every block commission will go to a separated pool of a validator, which emitted a commission event
  • Commission will be deducted from the commission pool when validator withdraw commission

commission = reward x commission rate

Events example:

      {
        "type": "commission",
        "attributes": [
          {
            "key": "amount",
            "value": "24150206.780000000000000000basetcro",
            "index": true
          },
          {
            "key": "validator",
            "value": "tcrocncl14fzksz5h72et4ssjtqpwsmhz6ysk6r4na5tr63=",
            "index": true
          }
        ]
      }

To conclude, by using the below Msg and events, the reward of validators and delegators, the commission of validators could indexed:

  • MsgDelegate
  • MsgUndelegate
  • MsgRedelegate
  • MsgWithdrawDelegatorReward
  • Event: complete_unbonding (from v0.32)
  • Event: complete_redelegation (from v0.32)
  • Event: rewards (from v0.32)
  • Event: commission (from v0.32)
  • Event: withdraw_rewards (from v0.32)
  • Event: withdraw_commission (from v0.32)

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

No branches or pull requests

2 participants