keeper

package
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetCappedTargetEmissionPerUnitStakedToken added in v0.0.1337

func GetCappedTargetEmissionPerUnitStakedToken(
	targetRewardEmissionPerUnitStakedToken math.LegacyDec,
	maximumMonthlyEmissionPerUnitStakedToken math.LegacyDec,
) math.LegacyDec

Target Monthly Emission Per Unit Staked Token is the capped value of either the computed target for this timestep, or simply the maximum allowable emission per unit staked token ^e_i = min(^e_{target,i}, ^e_{max,i})

func GetExponentialMovingAverage added in v0.0.1337

func GetExponentialMovingAverage(
	targetRewardEmissionPerUnitStakedToken math.LegacyDec,
	alphaEmission math.LegacyDec,
	previousRewardEmissionPerUnitStakedToken math.LegacyDec,
) math.LegacyDec

Reward Emission Per Unit Staked Token is an exponential moving average over the Target Reward Emission Per Unit Staked Token e_i = α_e * ^e_i + (1 − α_e)*e_{i−1}

func GetLockedTokenSupply added in v0.2.6

func GetLockedTokenSupply(
	blocksPerMonth uint64,
	blockHeight math.Int,
	params types.Params,
) math.Int

return the uncirculating supply, i.e. tokens on a vesting schedule these tokens will be custodied by a centralized actor off chain. this function returns the circulating supply based off of what the agreements off chain say were supposed to happen for token lockup

func GetMaximumMonthlyEmissionPerUnitStakedToken added in v0.0.1337

func GetMaximumMonthlyEmissionPerUnitStakedToken(
	maximumMonthlyPercentageYield math.LegacyDec,
	reputersPercentOfTopicRewards math.LegacyDec,
	validatorsPercent math.LegacyDec,
) math.LegacyDec

maximum monthly emission per unit staked token given a maximum monthly percentage yield ^e_{max,i} = Xi_max / f_{stakers} where Xi_{max} is the maximum MPY, and f_{stakers} is the fraction of the total token emission during the previous epoch that was paid to reward staking network participants, i.e. reputers and network validators

func GetNumStakedTokens added in v0.0.1337

func GetNumStakedTokens(ctx context.Context, k Keeper) (math.Int, error)

helper function to get the number of staked tokens on the network includes both tokens staked by cosmos validators (cosmos staking) and tokens staked by reputers (allora staking)

func GetTargetRewardEmissionPerUnitStakedToken added in v0.0.1337

func GetTargetRewardEmissionPerUnitStakedToken(
	fEmission math.LegacyDec,
	ecosystemMintableRemaining math.Int,
	networkStaked math.Int,
	circulatingSupply math.Int,
	maxSupply math.Int,
) (math.LegacyDec, error)

Target Reward Emission Per Unit Staked Token controls the inflation rate of the token issuance

^e_i = ((f_e*T_{total,i}) / N_{staked,i}) * (N_{circ,i} / N_{total,i})

f_e is a global tuning constant, by default f_e = 0.015 month^{−1} represents the fraction of the ecosystem treasury that would ideally be emitted per unit time. T_{total,i} = number of tokens that the ecosystem bucket can still mint. The ecosystem bucket is capped to be able to mint by default 36.75% of the max supply, but as more tokens are minted the amount the ecosystem is permitted to mint decreases. N_{staked,i} is the total number of tokens staked on the network at timestep i N_{circ,i} is the number of tokens in circulation at timestep i N_{total,i} is the total number of tokens ever allowed to exist

func GetTotalEmissionPerMonth added in v0.0.1337

func GetTotalEmissionPerMonth(
	rewardEmissionPerUnitStakedToken math.LegacyDec,
	numStakedTokens math.Int,
) math.Int

The total amount of tokens emitted for a full month E_i = e_i*N_{staked,i} where e_i is the emission per unit staked token and N_{staked,i} is the total amount of tokens staked at timestep i THIS FUNCTION TRUNCATES THE RESULT DIVISION TO AN INTEGER

func NewMsgServerImpl

func NewMsgServerImpl(k Keeper) types.MsgServer

NewMsgServerImpl returns an implementation of the x/mint MsgServer interface.

func NewQueryServerImpl

func NewQueryServerImpl(k Keeper) types.QueryServer

Types

type Keeper

type Keeper struct {
	Schema                                   collections.Schema
	Params                                   collections.Item[types.Params]
	PreviousRewardEmissionPerUnitStakedToken collections.Item[math.LegacyDec]
	PreviousBlockEmission                    collections.Item[math.Int]
	EcosystemTokensMinted                    collections.Item[math.Int]
	// contains filtered or unexported fields
}

Keeper of the mint store

func NewKeeper

func NewKeeper(
	cdc codec.BinaryCodec,
	storeService storetypes.KVStoreService,
	sk types.StakingKeeper,
	ak types.AccountKeeper,
	bk types.BankKeeper,
	ek types.EmissionsKeeper,
	feeCollectorName string,
) Keeper

NewKeeper creates a new mint Keeper instance

func (Keeper) AddEcosystemTokensMinted added in v0.0.1337

func (k Keeper) AddEcosystemTokensMinted(ctx context.Context, minted math.Int) error

This function increases the ledger that tracks the total tokens minted by the ecosystem treasury over the life of the blockchain.

func (Keeper) CosmosValidatorStakedSupply added in v0.0.1337

func (k Keeper) CosmosValidatorStakedSupply(ctx context.Context) (math.Int, error)

StakingTokenSupply implements an alias call to the underlying staking keeper's StakingTokenSupply to be used in BeginBlocker.

func (Keeper) ExportGenesis

func (keeper Keeper) ExportGenesis(ctx context.Context) *types.GenesisState

ExportGenesis returns a GenesisState for a given context and keeper.

func (Keeper) GetEcosystemBalance added in v0.0.1337

func (k Keeper) GetEcosystemBalance(ctx context.Context, mintDenom string) (math.Int, error)

returns the quantity of tokens currenty stored in the "ecosystem" module account this module account is paid by inference requests and is drained by this mint module when forwarding rewards to fee collector and allorarewards accounts

func (Keeper) GetParams added in v0.0.1337

func (k Keeper) GetParams(ctx context.Context) (types.Params, error)

Params getter

func (Keeper) GetParamsBlocksPerMonth added in v0.0.1337

func (k Keeper) GetParamsBlocksPerMonth(ctx context.Context) (uint64, error)

wrapper around emissions keeper call to get the number of blocks expected in a month

func (Keeper) GetPreviousPercentageRewardToStakedReputers added in v0.0.1337

func (k Keeper) GetPreviousPercentageRewardToStakedReputers(ctx context.Context) (math.LegacyDec, error)

The last time we paid out rewards, what was the percentage of those rewards that went to staked reputers (as opposed to forecaster workers and inferrer workers)

func (Keeper) GetTotalCurrTokenSupply added in v0.0.1337

func (k Keeper) GetTotalCurrTokenSupply(ctx context.Context) sdk.Coin

GetTotalCurrTokenSupply implements an alias call to the underlying supply keeper's GetTotalCurrTokenSupply to be used in BeginBlocker.

func (Keeper) GetValidatorsVsAlloraPercentReward added in v0.0.1337

func (k Keeper) GetValidatorsVsAlloraPercentReward(ctx context.Context) (alloraMath.Dec, error)

What split of the rewards should be given to cosmos validators vs allora participants (reputers, forecaster workers, inferrer workers)

func (Keeper) InitGenesis

func (keeper Keeper) InitGenesis(ctx context.Context, ak types.AccountKeeper, data *types.GenesisState)

InitGenesis new mint genesis

func (Keeper) IsWhitelistAdmin added in v0.0.1337

func (k Keeper) IsWhitelistAdmin(ctx context.Context, admin string) (bool, error)

wrapper around emissions keeper call to get if whitelist admin

func (Keeper) Logger

func (k Keeper) Logger(ctx context.Context) log.Logger

Logger returns a module-specific logger.

func (Keeper) MintCoins

func (k Keeper) MintCoins(ctx context.Context, newCoins sdk.Coins) error

MintCoins implements an alias call to the underlying supply keeper's MintCoins to be used in BeginBlocker.

func (Keeper) MoveCoinsFromMintToEcosystem added in v0.0.1337

func (k Keeper) MoveCoinsFromMintToEcosystem(ctx context.Context, mintedCoins sdk.Coins) error

MoveCoinsFromMintToEcosystem moves freshly minted tokens from the mint module which has permissions to create new tokens, to the ecosystem account which only has permissions to hold tokens.

func (Keeper) PayAlloraRewardsFromEcosystem added in v0.0.1337

func (k Keeper) PayAlloraRewardsFromEcosystem(ctx context.Context, rewards sdk.Coins) error

PayAlloraRewardsFromEcosystem sends funds from the ecosystem treasury account to the allora reward payout account used in the emissions module PayAlloraRewardsFromEcosystem to be used in BeginBlocker.

func (Keeper) PayValidatorsFromEcosystem added in v0.0.1337

func (k Keeper) PayValidatorsFromEcosystem(ctx context.Context, rewards sdk.Coins) error

PayValidatorsFromEcosystem sends funds from the ecosystem treasury account to the cosmos network validators rewards account (fee collector) PayValidatorsFromEcosystem to be used in BeginBlocker.

type Migrator

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

Migrator is a struct for handling in-place state migrations.

func NewMigrator

func NewMigrator(k Keeper) Migrator

NewMigrator returns Migrator instance for the state migration.

func (Migrator) Migrate1to2

func (m Migrator) Migrate1to2(ctx sdk.Context) error

Migrate1to2 migrates the x/mint module state from the consensus version 1 to version 2. Specifically, it takes the parameters that are currently stored and managed by the x/params modules and stores them directly into the x/mint module state.

Jump to

Keyboard shortcuts

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