cfeminter

package
v1.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 20, 2024 License: Apache-2.0 Imports: 27 Imported by: 0

README

Chain4Energy minter module - cfeminter

Abstract

Chain4Energy minter module provides functionality of controlled token emissions. Tokens are emitted according to configuration.

Contents

  1. Concept
  2. Params
  3. State
  4. Messages
  5. Events
  6. Queries
  7. Genesis validations

Concepts

The purpose of cfeminter module is to provide token emission mechanism.

Token emission mechanism

Token emission mechanism mints calculated amount of tokens per each block. Token amount is calculated accordingly to cfeminter module configuration params. Tokens minting process is divided into separate minters where each minter has different minting configuration. Token emission mechanism rules are defined within cfeminter module configuration params. Simply, minting process configuration is a list of ordered minters, where each minter has its own start and end time. Last minter cannot have end time because it must be defined to work infinitely.

Periodic continous vesting account
Minters

Ordered list of minters defines whole token emission process. End time of one minter is a start time of the next minter in the minters list. Each minter has its own minting configuration assigned.

Minting configuration

Each minter has its specific minting configuration which defines general rules of token emission. Currently, cfeminter module supports following minting configs:

  • no minting
  • linear minting
  • exponential step minting

Each minting configuration has its own specific set of parameters modifying token emission.

No minting

No minting is a simple minting configuration that mints nothing. This minting configuration has no parameters.

Linear minting

Linear minting is block time based minting configuration. It mints predetermined amount of tokens within minter linearly. This minting configuration requires minter with end time since given amount of token needs to be minted in finite time period. So this minting configuration cannot be set in the last minter.

Linear minting configuration parameters:

  • amount - amount of tokens to mint within minter period
Exponential step minting

Exponential step minting is block time based minting configuration. It mints predetermined amount of tokens within minter, where it divides this minter into smaller subminters of equal length. Then within each subminter expected amount is minted, linearly. Expected amount of subminter minted tokens is equal to tokens minted by previous subminter multiplied by configured factor. For example initial minter amount is 40 million, multiplying factor set to 0.5 and step duration is four years, then:

  • 1st subminter (first 4 years) mints 40 millions linearly
  • 2nd subminter (second 4 years) mints 20 millions linearly
  • 3rd subminter (third 4 years) mints 10 millions linearly
  • 4th subminter (fourth 4 years) mints 5 millions linearly and so on.

This minter can mint infinitely.

Exponential step minting configuration parameters:

  • step duration - period of time mint amount is emitted
  • amount - amount to mint for the first period
  • amount multiplier - amount multiplying factor

Examples

Four years halving minting that starts with 40 million tokens and step duration set at 4 years

Minter configuration:

  • minting start: now
  • Amount of minter Minters: 1
  • Minter 1:
    • end time: null
    • config:
      • type: exponential step minting
      • step duration: 4 years
      • amount: 40 millions
      • amount multiplier: 0.5

Result:

  • first 4 years mints 40 millions
  • second 4 years mints 20 millions
  • third 4 years mints 10 millions and so on
Linear minting of 100 million of token during period of 10 years, next no emission

Minter configuration:

  • minting start: now
  • Amount of minter Minters: 2
  • Minter 1:
    • end time: 10 years from now
    • config:
      • type: linear minting
      • amount: 100 millions
  • Minter 2:
    • end time: null
    • config:
      • type: no minting

Result:

  • 10 millions yearly for 10 years

Parameters

The Chain4Energy minter module contains the following configurations parameters:

Key Type Description
mint_denom string Denom of minting token
start_time Time Token emission start time
minters List of Minters list of minters
Minter type
Param Type Description
sequence_id uint32 Minter ordering id
end_time Time Minter end time
config MinterConfigI Minter configuration type that implements MinterConfigI interface. Allowed configuration types:
- NoMinting
- LinearMinting
- ExponentialStepMinting
NoMinting configuration
Param Type Description
type NoMinting Minter configuration type
LinearMinting configuration
Param Type Description
type LinearMinting Minter configuration type
amount math.Int An amount to mint linearly during the period
ExponentialStepMinting configuration
Param Type Description
type ExponentialStepMinting Minter configuration type
step_duration uint32 period of time of token emission
amount math.Int amount to mint during "stepDuration"
amount_multiplier sdk.Dec amount multiplying factor
Example params
  1. Four years halving minting that starts with 40 million tokens and step duration set at 4 years
{
  "params": {
    "mint_denom": "uc4e",
    "start_time": "2022-07-05T00:00:00Z",
    "minters": [
      {
        "sequenceId": 1,
        "end_time": null,
        "config": {
          "@type": "/chain4energy.c4echain.cfeminter.ExponentialStepMinting",
          "step_duration": "126144000s",
          "amount": 40000000000000,
          "amount_multiplier": "0.500000000000000000"
        }
      }
    ]
  }
}
  1. Linear minting of 100 million of token during period of 10 years, next no emission
{
  "params": {
    "mint_denom": "uc4e",
    "start_time": "2022-07-05T00:00:00Z",
    "minters": [
    {
      "sequenceId": 1,
      "end_time": "2023-07-05T00:00:00Z",
      "config": {
        "@type": "/chain4energy.c4echain.cfeminter.LinearMinting",
        "amount": 100000000000000
      }
    },
    {
      "sequenceId": 2,
      "end_time": null,
      "config": {
        "@type": "/chain4energy.c4echain.cfeminter.NoMinting"
      }
    }
    ]
  }
}

State

Chain4Energy minter module state contains information used by current minter. Module state contains following data:

Key Type Description
minter_state MinterState current minter state
state_history List of MinterState previous minters final states
MinterState
Key Type Description
sequence_id uint32 current minter sequenceId
amount_minted math.Int amount minted by current minter
remainder_to_mint sdk.Dec amount that should have been minted in previous block but was not
last_mint_block_time sdk.Time Time of last mint
remainder_from_previous_period sdk.Dec amount that should have been minted in previous minter but was not
Example state
{
  "minter_state": {
    "sequence_id": 1,
    "amount_minted": "13766330043442",
    "remainder_to_mint": "0.415017757483510908",
    "last_mint_block_time": "2022-11-07T14:49:34.606250Z",
    "remainder_from_previous_period": "0.000000000000000000"
  },
  "state_history": []
}

Messages

Burn Tokens

Burns a specified amount of tokens from the given address. This process permanently reduces the total supply of the tokens.

MsgBurn Message Represents a message to burn tokens from an account.

Structure
type MsgBurn struct {
Address string
Amount  sdk.Coins
}
Parameters
State Modifications
  • Validates if the Address is a valid bech32 account address.
  • Validates if the Amount is positive and not nil.
  • Ensures that the Address has a balance greater than or equal to the Amount.
  • Sends the Amount from the Address to the types.ModuleName module account.
  • Burns the Amount from the types.ModuleName module account, thereby reducing the total supply of those tokens.

Events

Chain4Energy minter module emits the following events:

BeginBlockers
EventMint
Type Attribute Key Attribute Value
EventMint bonded_ratio {tokens_boneded_ratio}
EventMint inflation {minting_block_inflation_level}
EventMint amount {amount_minted_in_block}
//: # (TODO remove bonded_ratio )
//: # (TODO add minter period id)
Handlers for MsgBurn
Type Attribute Key Attribute Value
burn burner {sender_address}
burn amount {amount}
message action /chain4energy.c4echain.cfeclaim.MsgBurn
message sender {sender_address}
transfer recipient {module_account}
transfer sender {creator}
transfer amount {amount}

Queries

Params query

Queries the module params.

See example response:

{
  "params": {
    "mint_denom": "uc4e",
    "start_time": "2022-07-05T00:00:00Z",
    "minters": [
      {
        "sequenceId": 1,
        "end_time": null,
        "config": {
          "@type": "/chain4energy.c4echain.cfeminter.ExponentialStepMinting",
          "step_duration": "126144000s",
          "amount": 40000000000000,
          "amount_multiplier": "0.500000000000000000"
        }
      }
    ]
  }
}
State query

Queries the module state.

See example response:

{
  "minter_state": {
    "sequence_id": 1,
    "amount_minted": "13766330043442",
    "remainder_to_mint": "0.415017757483510908",
    "last_mint_block_time": "2022-11-07T14:49:34.606250Z",
    "remainder_from_previous_period": "0.000000000000000000"
  },
  "state_history": []
}
Inflation query

Queries current inflation.

See example response:

{
  "inflation": "0.102489480201216908"
}

Genesis validations

Documentation

Index

Constants

View Source
const SecondsInYear = int32(3600 * 24 * 365)

Variables

This section is empty.

Functions

func BeginBlocker

func BeginBlocker(ctx sdk.Context, k keeper.Keeper)

BeginBlocker mints new tokens for the previous block.

func ExportGenesis

func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState

ExportGenesis returns the capability module's exported genesis.

func InitGenesis

func InitGenesis(ctx sdk.Context, k keeper.Keeper, ak types.AccountKeeper, genState types.GenesisState)

InitGenesis initializes the capability module's state from a provided genesis state.

Types

type AppModule

type AppModule struct {
	AppModuleBasic
	// contains filtered or unexported fields
}

AppModule implements the AppModule interface for the capability module.

func NewAppModule

func NewAppModule(
	cdc codec.Codec,
	keeper keeper.Keeper,
	accountKeeper types.AccountKeeper,
	bankKeeper types.BankKeeper,
	ls subspace.Subspace,
) AppModule

func (AppModule) BeginBlock

func (am AppModule) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock)

BeginBlock executes all ABCI BeginBlock logic respective to the capability module.

func (AppModule) ConsensusVersion

func (AppModule) ConsensusVersion() uint64

ConsensusVersion implements ConsensusVersion.

func (AppModule) EndBlock

EndBlock executes all ABCI EndBlock logic respective to the capability module. It returns no validator updates.

func (AppModule) ExportGenesis

func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage

ExportGenesis returns the capability module's exported genesis state as raw JSON bytes.

func (AppModule) GenerateGenesisState

func (AppModule) GenerateGenesisState(simState *module.SimulationState)

GenerateGenesisState creates a randomized GenState of the module

func (AppModule) InitGenesis

func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, gs json.RawMessage) []abci.ValidatorUpdate

InitGenesis performs the capability module's genesis initialization It returns no validator updates.

func (AppModule) LegacyQuerierHandler

func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sdk.Querier

LegacyQuerierHandler returns the capability module's Querier.

func (AppModule) Name

func (am AppModule) Name() string

Name returns the capability module's name.

func (AppModule) ProposalContents

ProposalContents doesn't return any content functions for governance proposals

func (AppModule) QuerierRoute

func (AppModule) QuerierRoute() string

QuerierRoute returns the capability module's query routing key.

func (AppModule) RandomizedParams

func (am AppModule) RandomizedParams(_ *rand.Rand) []simtypes.ParamChange

RandomizedParams creates randomized param changes for the simulator

func (AppModule) RegisterInvariants

func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry)

RegisterInvariants registers the capability module's invariants.

func (AppModule) RegisterServices

func (am AppModule) RegisterServices(cfg module.Configurator)

RegisterServices registers a GRPC query service to respond to the module-specific GRPC queries.

func (AppModule) RegisterStoreDecoder

func (am AppModule) RegisterStoreDecoder(_ sdk.StoreDecoderRegistry)

RegisterStoreDecoder registers a decoder

func (AppModule) Route

func (am AppModule) Route() sdk.Route

Route returns the capability module's message routing key.

func (AppModule) WeightedOperations

func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation

WeightedOperations returns the all the gov module operations with their respective weights.

type AppModuleBasic

type AppModuleBasic struct {
	// contains filtered or unexported fields
}

AppModuleBasic implements the AppModuleBasic interface for the capability module.

func NewAppModuleBasic

func NewAppModuleBasic(cdc codec.BinaryCodec) AppModuleBasic

func (AppModuleBasic) DefaultGenesis

func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage

DefaultGenesis returns the capability module's default genesis state.

func (AppModuleBasic) GetQueryCmd

func (AppModuleBasic) GetQueryCmd() *cobra.Command

GetQueryCmd returns the capability module's root query command.

func (AppModuleBasic) GetTxCmd

func (a AppModuleBasic) GetTxCmd() *cobra.Command

GetTxCmd returns the capability module's root tx command.

func (AppModuleBasic) Name

func (AppModuleBasic) Name() string

Name returns the capability module's name.

func (AppModuleBasic) RegisterGRPCGatewayRoutes

func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux)

RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module.

func (AppModuleBasic) RegisterInterfaces

func (a AppModuleBasic) RegisterInterfaces(reg cdctypes.InterfaceRegistry)

RegisterInterfaces registers the module's interface types

func (AppModuleBasic) RegisterLegacyAminoCodec

func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino)

func (AppModuleBasic) RegisterRESTRoutes

func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router)

RegisterRESTRoutes registers the capability module's REST service handlers.

func (AppModuleBasic) ValidateGenesis

func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingConfig, bz json.RawMessage) error

ValidateGenesis performs genesis state validation for the capability module.

Directories

Path Synopsis
client
cli
migrations
v1
v2
v3
Package types is a reverse proxy.
Package types is a reverse proxy.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL