elesto-dao / elesto

The ElestoDAO node
Apache License 2.0
4 stars 1 forks source link

chore(mint): update mint calculation aglo to calculate per block #141

Closed PaddyMc closed 2 years ago

PaddyMc commented 2 years ago

Description

Issue 1

The current minting algorithm is minting nothing the for the first year as

int(math.Floor(float64(ctx.BlockHeight()) / float64(blocksPerYear))) == 0

The fix is just checking if we're in year 1 or not

Issue 2

After fixing Issue 1, the mint algo was minting the full inflation rewards every block as

mintedCoin := sdk.NewCoin(params.MintDenom, sdk.NewInt(inflationAmount))

The fix is (inflation amount / number of blocks per year)

How to test

First, get the validator operation address:

At each height

{
  "supply": [
    {
      "denom": "stake",
      "amount": "200000535"
    }
  ],
}

{
  "supply": [
    {
      "denom": "stake",
      "amount": "200000540"
    }
  ],
{
  "pool": [
    {
      "denom": "stake",
      "amount": "7.000000000000000000"
    }
  ]
}

{
  "pool": [
    {
      "denom": "stake",
      "amount": "7.100000000000000000"
    }
  ]
}
{
  "rewards": [
    {
      "denom": "stake",
      "amount": "646.800000000000000000"
    }
  ]
}

{
  "rewards": [
    {
      "denom": "stake",
      "amount": "651.700000000000000000"
    }
  ]
}
gsora commented 2 years ago

Hey! Thanks for the PR.

As I mentioned in a comment in #104, we're already dealing with microtokens, and the numerical outcome in terms of supply matches the simulations we ran.

But! We actually introduced a bug when dealing with year 0, so thank you for letting us know! It's now fixed in #104.