keeper

package
v1.0.0-beta.3.1 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2022 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// BeginningOfMonth harvest rewards that are claimed after the 15th at 14:00UTC of the month always vest on the first of the month
	BeginningOfMonth = 1
	// MidMonth harvest rewards that are claimed before the 15th at 14:00UTC of the month always vest on the 15 of the month
	MidMonth = 15
	// PaymentHour harvest rewards always vest at 14:00UTC
	PaymentHour = 14
)

Variables

This section is empty.

Functions

func CalculateTimeElapsed

func CalculateTimeElapsed(start, end, blockTime time.Time, previousAccrualTime time.Time) sdk.Int

CalculateTimeElapsed calculates the number of reward-eligible seconds that have passed since the previous time rewards were accrued, taking into account the end time of the reward period

func NewQuerier

func NewQuerier(k Keeper, legacyQuerierCdc *codec.LegacyAmino) sdk.Querier

Types

type Hooks

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

Hooks wrapper struct for hooks

func (Hooks) AfterCdpCreated

func (h Hooks) AfterCdpCreated(ctx sdk.Context, cdp cdptypes.Cdp)

AfterCdpCreated function that runs after a cdp is created

func (Hooks) AfterDelegationModified

func (h Hooks) AfterDelegationModified(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress)

AfterDelegationModified runs after a delegation is modified

func (Hooks) AfterValidatorBeginUnbonding

func (h Hooks) AfterValidatorBeginUnbonding(ctx sdk.Context, consAddr sdk.ConsAddress, valAddr sdk.ValAddress)

AfterValidatorBeginUnbonding is called after a validator begins unbonding

func (Hooks) AfterValidatorBonded

func (h Hooks) AfterValidatorBonded(ctx sdk.Context, consAddr sdk.ConsAddress, valAddr sdk.ValAddress)

AfterValidatorBonded is called after a validator is bonded

func (Hooks) AfterValidatorCreated

func (h Hooks) AfterValidatorCreated(ctx sdk.Context, valAddr sdk.ValAddress)

AfterValidatorCreated runs after a validator is created

func (Hooks) AfterValidatorRemoved

func (h Hooks) AfterValidatorRemoved(ctx sdk.Context, consAddr sdk.ConsAddress, valAddr sdk.ValAddress)

AfterValidatorRemoved runs after a validator is removed

func (Hooks) BeforeCdpModified

func (h Hooks) BeforeCdpModified(ctx sdk.Context, cdp cdptypes.Cdp)

BeforeCdpModified function that runs before a cdp is modified note that this is called immediately after interest is synchronized, and so could potentially be called AfterCdpInterestUpdated or something like that, if we we're to expand the scope of cdp hooks

func (Hooks) BeforeDelegationCreated

func (h Hooks) BeforeDelegationCreated(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress)

BeforeDelegationCreated runs before a delegation is created

func (Hooks) BeforeDelegationRemoved

func (h Hooks) BeforeDelegationRemoved(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress)

BeforeDelegationRemoved runs directly before a delegation is deleted

func (Hooks) BeforeDelegationSharesModified

func (h Hooks) BeforeDelegationSharesModified(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress)

BeforeDelegationSharesModified runs before an existing delegation is modified

func (Hooks) BeforeValidatorModified

func (h Hooks) BeforeValidatorModified(ctx sdk.Context, valAddr sdk.ValAddress)

BeforeValidatorModified runs before a validator is modified

func (Hooks) BeforeValidatorSlashed

func (h Hooks) BeforeValidatorSlashed(ctx sdk.Context, valAddr sdk.ValAddress, fraction sdk.Dec)

BeforeValidatorSlashed is called before a validator is slashed

type Keeper

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

func NewKeeper

func NewKeeper(cdc codec.Codec, storeKey, memKey sdk.StoreKey,
	paramSpace paramtypes.Subspace, accountKeeper types.AccountKeeper,
	bankKeeper types.BankKeeper,
	cdpKeeper types.CdpKeeper) Keeper

func (Keeper) AccumulateCdpMintingRewards

func (k Keeper) AccumulateCdpMintingRewards(ctx sdk.Context, rewardPeriod types.RewardPeriod) error

AccumulateCdpMintingRewards updates the rewards accumulated for the input reward period

func (Keeper) ClaimCdpMintingReward

func (k Keeper) ClaimCdpMintingReward(ctx sdk.Context, addr sdk.AccAddress, multiplierName string) error

ClaimCdpMintingReward sends the reward amount to the input address and zero's out the claim in the store

func (Keeper) DeleteCdpMintingClaim

func (k Keeper) DeleteCdpMintingClaim(ctx sdk.Context, owner sdk.AccAddress)

DeleteCdpMintingClaim deletes the claim in the store corresponding to the input address, collateral type, and id

func (Keeper) GetAllCdpMintingClaims

func (k Keeper) GetAllCdpMintingClaims(ctx sdk.Context) types.CdpMintingClaims

GetAllCdpMintingClaims returns all Claim objects in the store

func (Keeper) GetCdpMintingClaim

func (k Keeper) GetCdpMintingClaim(ctx sdk.Context, addr sdk.AccAddress) (types.CdpMintingClaim, bool)

GetCdpMintingClaim returns the claim in the store corresponding the the input address collateral type and id and a boolean for if the claim was found

func (Keeper) GetCdpMintingRewardFactor

func (k Keeper) GetCdpMintingRewardFactor(ctx sdk.Context, ctype string) (factor sdk.Dec, found bool)

GetCdpMintingRewardFactor returns the current reward factor for an individual collateral type

func (Keeper) GetCdpMintingRewardPeriod

func (k Keeper) GetCdpMintingRewardPeriod(ctx sdk.Context, collateralType string) (types.RewardPeriod, bool)

GetCdpMintingRewardPeriod returns the reward period with the specified collateral type if it's found in the params

func (Keeper) GetClaimEnd

func (k Keeper) GetClaimEnd(ctx sdk.Context) time.Time

GetClaimEnd returns the claim end time for the params

func (Keeper) GetGenesisDenoms

func (k Keeper) GetGenesisDenoms(ctx sdk.Context) (_ *types.GenesisDenoms, found bool)

func (Keeper) GetMultiplier

func (k Keeper) GetMultiplier(ctx sdk.Context, name string) (types.Multiplier, bool)

GetMultiplier returns the multiplier with the specified name if it's found in the params

func (Keeper) GetParams

func (k Keeper) GetParams(ctx sdk.Context) (params types.Params)

func (Keeper) GetPeriodLength

func (k Keeper) GetPeriodLength(ctx sdk.Context, multiplier types.Multiplier) (int64, error)

GetPeriodLength returns the length of the period based on the input blocktime and multiplier note that pay dates are always the 1st or 15th of the month at 14:00UTC.

func (Keeper) GetPreviousCdpMintingAccrualTime

func (k Keeper) GetPreviousCdpMintingAccrualTime(ctx sdk.Context, ctype string) (blockTime time.Time, found bool)

GetPreviousCdpMintingAccrualTime returns the last time a collateral type accrued Cdp minting rewards

func (Keeper) Hooks

func (k Keeper) Hooks() Hooks

Hooks create new incentive hooks

func (Keeper) InitializeCdpMintingClaim

func (k Keeper) InitializeCdpMintingClaim(ctx sdk.Context, cdp cdptypes.Cdp)

InitializeCdpMintingClaim creates or updates a claim such that no new rewards are accrued, but any existing rewards are not lost. this function should be called after a cdp is created. If a user previously had a cdp, then closed it, they shouldn't accrue rewards during the period the cdp was closed. By setting the reward factor to the current global reward factor, any unclaimed rewards are preserved, but no new rewards are added.

func (Keeper) IterateCdpMintingAccrualTimes

func (k Keeper) IterateCdpMintingAccrualTimes(ctx sdk.Context, cb func(string, time.Time) (stop bool))

IterateCdpMintingAccrualTimes iterates over all previous Cdp minting accrual times and preforms a callback function

func (Keeper) IterateCdpMintingClaims

func (k Keeper) IterateCdpMintingClaims(ctx sdk.Context, cb func(c types.CdpMintingClaim) (stop bool))

IterateCdpMintingClaims iterates over all claim objects in the store and preforms a callback function

func (Keeper) Logger

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

func (Keeper) Params

func (Keeper) SendTimeLockedCoinsToAccount

func (k Keeper) SendTimeLockedCoinsToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins, length int64) error

SendTimeLockedCoinsToAccount sends time-locked coins from the input module account to the recipient. If the recipients account is not a vesting account and the input length is greater than zero, the recipient account is converted to a periodic vesting account and the coins are added to the vesting balance as a vesting period with the input length.

func (Keeper) SendTimeLockedCoinsToBaseAccount

func (k Keeper) SendTimeLockedCoinsToBaseAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins, length int64) error

SendTimeLockedCoinsToBaseAccount sends time-locked coins from the input module account to the recipient, converting the recipient account to a vesting account

func (Keeper) SendTimeLockedCoinsToPeriodicVestingAccount

func (k Keeper) SendTimeLockedCoinsToPeriodicVestingAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins, length int64) error

SendTimeLockedCoinsToPeriodicVestingAccount sends time-locked coins from the input module account to the recipient

func (Keeper) SetCdpMintingClaim

func (k Keeper) SetCdpMintingClaim(ctx sdk.Context, c types.CdpMintingClaim)

SetCdpMintingClaim sets the claim in the store corresponding to the input address, collateral type, and id

func (Keeper) SetCdpMintingRewardFactor

func (k Keeper) SetCdpMintingRewardFactor(ctx sdk.Context, ctype string, factor sdk.Dec)

SetCdpMintingRewardFactor sets the current reward factor for an individual collateral type

func (Keeper) SetGenesisDenoms

func (k Keeper) SetGenesisDenoms(ctx sdk.Context, denoms *types.GenesisDenoms)

func (Keeper) SetParams

func (k Keeper) SetParams(ctx sdk.Context, params types.Params)

func (Keeper) SetPreviousCdpMintingAccrualTime

func (k Keeper) SetPreviousCdpMintingAccrualTime(ctx sdk.Context, ctype string, blockTime time.Time)

SetPreviousCdpMintingAccrualTime sets the last time a collateral type accrued Cdp minting rewards

func (Keeper) SimulateCdpMintingSynchronization

func (k Keeper) SimulateCdpMintingSynchronization(ctx sdk.Context, claim types.CdpMintingClaim) types.CdpMintingClaim

SimulateCdpMintingSynchronization calculates a user's outstanding Cdp minting rewards by simulating reward synchronization

func (Keeper) SynchronizeCdpMintingClaim

func (k Keeper) SynchronizeCdpMintingClaim(ctx sdk.Context, claim types.CdpMintingClaim) (types.CdpMintingClaim, error)

SynchronizeCdpMintingClaim updates the claim object by adding any rewards that have accumulated. Returns the updated claim object

func (Keeper) SynchronizeCdpMintingReward

func (k Keeper) SynchronizeCdpMintingReward(ctx sdk.Context, cdp cdptypes.Cdp)

SynchronizeCdpMintingReward updates the claim object by adding any accumulated rewards and updating the reward index value. this should be called before a cdp is modified, immediately after the 'SynchronizeInterest' method is called in the cdp module

func (Keeper) ZeroCdpMintingClaim

func (k Keeper) ZeroCdpMintingClaim(ctx sdk.Context, claim types.CdpMintingClaim) types.CdpMintingClaim

ZeroCdpMintingClaim zeroes out the claim object's rewards and returns the updated claim object

Jump to

Keyboard shortcuts

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