crypto-com / chain-indexing

Other
35 stars 28 forks source link

Research: Unclaimed rewards and commissions design #668

Open calvinaco opened 2 years ago

calvinaco commented 2 years ago

Task Details

Definition of Done

davcrypto commented 2 years ago

Staking

Staking Shares

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

Staking Reward

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

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: