web3go-xyz / web3go.xyz

Discovery data value of Web3
Apache License 2.0
11 stars 4 forks source link

Moonbeam Dashboard: Inflation breakout #100

Closed bianyunjian closed 1 year ago

bianyunjian commented 2 years ago

Gross Inflation breakout:

actually the gross inflation is used by staking reward, we can get these data from staking database. we can calculate the inflation by the reward and distribution formula.

how the staking reward be distributed? refer to: https://docs.moonbeam.network/learn/features/staking/#reward-distribution

bianyunjian commented 2 years ago

● Gross Inflation breakout: ○ Proportion (quantity) of gross inflation to collators ○ Proportion (quantity) of gross inflation to stakers ○ Proportion (quantity) of gross inflation to parachain bond reserve

以时间作为查询条件

  1. 查询该时间点处的blockNumber

  2. 查询该blockNumber的 hash

  3. 查询在该blockNumber处的 totalIssuance
    balances.totalIssuance() image

  4. 得到inflation = totalIssuance - 10亿

  5. 根据分配比例和公式得出 inflation to parachain bond reserve = 30% * inflation

  6. 这两个需要处理 (inflation to collators ,inflation to stakers ), 因为收集人的奖励比例是两部分构成: 固定的20% + 浮动的奖励池比例。 我们可以通过Staking的数据库计算得到 Staking发的奖励 ( Collators 总奖励, Delegators总奖励 )(在指定的blockNumber之前的) Delegators总奖励 ==> inflation to stakers

  7. inflation to collators = inflation - ( inflation to parachain bond reserve ) - ( inflation to stakers )

  8. 注意,通过这种方式计算出, 会有一定的误差,因为 Staking的奖励是 延迟两个round发的( 12 小时 ), 但应该差不离,在可接受范围内.

bianyunjian commented 2 years ago

1.时间是查询条件, 输入的一个时间点, 比如 2022-05-01

  1. 数据链比较长, 而且要用http rest api做,sql是做不了. metabase的 http rest driver 就是为了这个支持上的 https://www.notion.so/litentry/HTTP-For-Metabase-Dashboard-3d934fff4346437997bc99b57a48c1a6
bianyunjian commented 2 years ago

开发环境 Staking 数据库 dev-moonbeam-staking, 从线上克隆下来的

bianyunjian commented 2 years ago

nflation info:

For Moonriver, inflation is (https://github.com/PureStake/moonbeam/blob/c39a717e2501a3470ae589c52daaa51786189cce/node/service/src/chain_spec/moonriver.rs#L186-L196): 4% for a min staked MOVR of 100_000 5% for an ideal staked MOVR of 200_000 5% for a max staked MOVR of 200_000

For Moonbeam, inflation is (https://github.com/PureStake/moonbeam/blob/c39a717e2501a3470ae589c52daaa51786189cce/node/service/src/chain_spec/moonbeam.rs#L184-L198): 4% for a min staked GLMR of 1_000_000 5% for an ideal staked GLMR of 2_000_000 5% for a max staked GLMR of 2_000_000

bianyunjian commented 2 years ago
  1. 得到每天的第一个BlockNumber hash
  2. 得到每天的 totalIssuance => totalIssuance_Day
  3. 得到每天的 gas => gas_Day
  4. 当天的net inflation = ( totalIssuance_Day_A - totalIssuance_Day_B ) - gas_Day