keeper

package
v0.7.1-rc-1 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 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 GetCirculatingSupply added in v0.0.1337

func GetCirculatingSupply(
	ctx context.Context,
	k types.MintKeeper,
	params types.Params,
	blockHeight uint64,
	blocksPerMonth uint64,
	monthsAlreadyUnlocked math.Int,
) (
	circulatingSupply,
	totalSupply,
	lockedVestingTokens,
	ecosystemLocked math.Int,
	updatedMonthsUnlocked math.Int,
	err error,
)

return the circulating supply of tokens

func GetEmissionPerMonth added in v0.0.1337

func GetEmissionPerMonth(
	ctx sdk.Context,
	k Keeper,
	blockHeight uint64,
	blocksPerMonth uint64,
	params types.Params,
	ecosystemBalance math.Int,
	ecosystemMintSupplyRemaining math.Int,
	validatorsPercent math.LegacyDec,
	monthsAlreadyUnlocked math.Int,
) (
	emissionPerMonth math.Int,
	emissionPerUnitStakedToken math.LegacyDec,
	updatedMonthsUnlocked math.Int,
	err error,
)

GetEmissionPerMonth calculates the emission per month for the network

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 GetLockedVestingTokens added in v0.0.1337

func GetLockedVestingTokens(
	blocksPerMonth uint64,
	blockHeight math.Int,
	params types.Params,
	monthsAlreadyUnlocked math.LegacyDec,
) (total, preseedInvestors, investors, team math.Int, updatedMonthsUnlocked 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 types.MintKeeper) (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,
	ecosystemLocked 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 PLUS the current balance of the bucket. 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 \cal 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.MsgServiceServer

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

func NewQueryServerImpl

func NewQueryServerImpl(k Keeper) types.QueryServiceServer

func RecalculateTargetEmission added in v0.0.1337

func RecalculateTargetEmission(
	ctx sdk.Context,
	k Keeper,
	blockHeight uint64,
	blocksPerMonth uint64,
	moduleParams types.Params,
	ecosystemBalance math.Int,
	ecosystemMintSupplyRemaining math.Int,
	validatorsPercent math.LegacyDec,
) (
	blockEmission math.Int,
	emissionPerUnitStakedToke math.LegacyDec,
	err error,
)

RecalculateTargetEmission recalculates the target emission for the network It writes the old emission rates to the store for PreviousRewardEmissionPerUnitStakedToken and PreviousBlockEmission Then it calculates the new target emission rate returns that, and the block emission we should mint/send for this block it also updates the months unlocked if it has changed into the store

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]
	MonthsUnlocked                           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 (k Keeper) ExportGenesis(ctx context.Context) *types.GenesisState

ExportGenesis returns a GenesisState for a given context and keeper.

func (Keeper) GetBinaryCodec added in v0.0.1337

func (k Keeper) GetBinaryCodec() codec.BinaryCodec

getter for the binary codec

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 currently 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) GetEcosystemMintSupplyRemaining added in v0.0.1337

func (k Keeper) GetEcosystemMintSupplyRemaining(
	ctx context.Context,
	params types.Params,
) (math.Int, error)

How many tokens are left that the ecosystem bucket is allowed to mint?

func (Keeper) GetEmissionsKeeperTotalStake added in v0.0.1337

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

wrapper for interface compatibility for unit testing

func (Keeper) GetMonthsAlreadyUnlocked added in v0.0.1337

func (k Keeper) GetMonthsAlreadyUnlocked(ctx context.Context) math.Int

Getter for the number of months unlocked this Getter coerces values to be between 0 and 36 rather than throwing errors for invalid values stored in the keeper

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) GetPreviousRewardEmissionPerUnitStakedToken added in v0.0.1337

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

wrapper for interface compatibility for unit testing

func (Keeper) GetStorageService added in v0.0.1337

func (k Keeper) GetStorageService() storetypes.KVStoreService

getter for the storage service

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 (k 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.

func (Keeper) SetEmissionsParamsBlocksPerMonth added in v0.0.1337

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

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

func (Keeper) SetMonthsAlreadyUnlocked added in v0.0.1337

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

Setter for the number of months unlocked this function coerces values to be between 0 and 36

func (Keeper) SetRewardCurrentBlockEmission added in v0.0.1337

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

wrapper for interface compatibility for unit testing

Jump to

Keyboard shortcuts

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