tendermint / spn

A blockchain to launch blockchains.
Other
112 stars 43 forks source link

Making `mint` module universal #895

Closed lumtis closed 2 years ago

lumtis commented 2 years ago

Many self-sovereign blockchains have their own tokenomics that can influence the block rewards:

The current methodology for a project is to fork one of these customized mint module and change it for the logic of the chain since the SDK mint module doesn't allow for flexibility. As opened here https://github.com/tendermint/spn/issues/852, customized open sourced mint found in the space also include very few tests for such an important and sensitive component.

The same as the claim module, the idea of this issue is to make mint module under this repo universal and reusable for any other project with minimal changes. Developers can integrate the module with extensive test and plug it into other module for usage of rewards.

Proposed solution

Include as part of the module params:

{
  StakingWeight sdk.Int
  CommunityPoolWeight sdk.Int
  FundedAddressesWeight sdk.Int
  PipesWeight sdk.Int
}
FundedAddresses []{
  Address string
  Description string
  Weight sdk.Int
}
Pipes []{
  PipeID uint64
  Description string
  Weight sdk.Int
}

The pipe is a generic way to represent a redirection of the block rewards.

In app.go modules can register for a pipe with the following method:

func (MintKeeper) SubscribePipe(pipeID uint64, func (blockRewards sdk.Coins)) error

The method panic is a pipe is subscribed twice.

Example: usage:

// keeper initialization....
//...

app.MintKeeper.SubscribePipe(LiquidityIncentivePipeID, app.LiquidityKeeper.ProvideLiquidityIncentives)
...