keeper

package
v0.13.0-alpha.0 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2021 License: Apache-2.0 Imports: 19 Imported by: 1

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

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) sdk.Querier

NewQuerier is the module level router for state queries

Types

type Hooks added in v0.13.0

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

Hooks wrapper struct for hooks

func (Hooks) AfterBorrowCreated added in v0.13.0

func (h Hooks) AfterBorrowCreated(ctx sdk.Context, borrow hardtypes.Borrow)

AfterBorrowCreated function that runs after a borrow is created

func (Hooks) AfterBorrowModified added in v0.13.0

func (h Hooks) AfterBorrowModified(ctx sdk.Context, borrow hardtypes.Borrow)

AfterBorrowModified function that runs after a borrow is modified

func (Hooks) AfterCDPCreated added in v0.13.0

func (h Hooks) AfterCDPCreated(ctx sdk.Context, cdp cdptypes.CDP)

AfterCDPCreated function that runs after a cdp is created

func (Hooks) AfterDelegationModified added in v0.13.0

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

AfterDelegationModified runs after a delegation is modified

func (Hooks) AfterDepositCreated added in v0.13.0

func (h Hooks) AfterDepositCreated(ctx sdk.Context, deposit hardtypes.Deposit)

AfterDepositCreated function that runs after a deposit is created

func (Hooks) AfterDepositModified added in v0.13.0

func (h Hooks) AfterDepositModified(ctx sdk.Context, deposit hardtypes.Deposit)

AfterDepositModified function that runs after a deposit is modified

func (Hooks) AfterValidatorBeginUnbonding added in v0.13.0

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

AfterValidatorBeginUnbonding is called after a validator begins unbonding

func (Hooks) AfterValidatorBonded added in v0.13.0

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

AfterValidatorBonded is called after a validator is bonded

func (Hooks) AfterValidatorCreated added in v0.13.0

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

AfterValidatorCreated runs after a validator is created

func (Hooks) AfterValidatorRemoved added in v0.13.0

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

AfterValidatorRemoved runs after a validator is removed

func (Hooks) BeforeBorrowModified added in v0.13.0

func (h Hooks) BeforeBorrowModified(ctx sdk.Context, borrow hardtypes.Borrow)

BeforeBorrowModified function that runs before a borrow is modified

func (Hooks) BeforeCDPModified added in v0.13.0

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

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

BeforeDelegationCreated runs before a delegation is created

func (Hooks) BeforeDelegationRemoved added in v0.13.0

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

BeforeDelegationRemoved runs directly before a delegation is deleted

func (Hooks) BeforeDelegationSharesModified added in v0.13.0

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

BeforeDelegationSharesModified runs before an existing delegation is modified

func (Hooks) BeforeDepositModified added in v0.13.0

func (h Hooks) BeforeDepositModified(ctx sdk.Context, deposit hardtypes.Deposit)

BeforeDepositModified function that runs before a deposit is modified

func (Hooks) BeforeValidatorModified added in v0.13.0

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

BeforeValidatorModified runs before a validator is modified

func (Hooks) BeforeValidatorSlashed added in v0.13.0

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
}

Keeper keeper for the incentive module

func NewKeeper

NewKeeper creates a new keeper

func (Keeper) AccumulateHardBorrowRewards added in v0.13.0

func (k Keeper) AccumulateHardBorrowRewards(ctx sdk.Context, rewardPeriod types.MultiRewardPeriod) error

AccumulateHardBorrowRewards updates the rewards accumulated for the input reward period

func (Keeper) AccumulateHardDelegatorRewards added in v0.13.0

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

AccumulateHardDelegatorRewards updates the rewards accumulated for the input reward period

func (Keeper) AccumulateHardSupplyRewards added in v0.13.0

func (k Keeper) AccumulateHardSupplyRewards(ctx sdk.Context, rewardPeriod types.MultiRewardPeriod) error

AccumulateHardSupplyRewards updates the rewards accumulated for the input reward period

func (Keeper) AccumulateUSDXMintingRewards added in v0.13.0

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

AccumulateUSDXMintingRewards updates the rewards accumulated for the input reward period

func (Keeper) ClaimHardReward added in v0.13.0

func (k Keeper) ClaimHardReward(ctx sdk.Context, addr sdk.AccAddress, multiplierName types.MultiplierName) error

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

func (Keeper) ClaimUSDXMintingReward added in v0.13.0

func (k Keeper) ClaimUSDXMintingReward(ctx sdk.Context, addr sdk.AccAddress, multiplierName types.MultiplierName) error

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

func (Keeper) DeleteHardLiquidityProviderClaim added in v0.13.0

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

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

func (Keeper) DeleteUSDXMintingClaim added in v0.13.0

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

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

func (Keeper) GetAllHardLiquidityProviderClaims added in v0.13.0

func (k Keeper) GetAllHardLiquidityProviderClaims(ctx sdk.Context) types.HardLiquidityProviderClaims

GetAllHardLiquidityProviderClaims returns all Claim objects in the store

func (Keeper) GetAllUSDXMintingClaims added in v0.13.0

func (k Keeper) GetAllUSDXMintingClaims(ctx sdk.Context) types.USDXMintingClaims

GetAllUSDXMintingClaims returns all Claim objects in the store

func (Keeper) GetClaimEnd added in v0.13.0

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

GetClaimEnd returns the claim end time for the params

func (Keeper) GetHardBorrowRewardIndexes added in v0.13.0

func (k Keeper) GetHardBorrowRewardIndexes(ctx sdk.Context, denom string) (types.RewardIndexes, bool)

GetHardBorrowRewardIndexes gets the current reward indexes for an individual denom

func (Keeper) GetHardBorrowRewardPeriods added in v0.13.0

func (k Keeper) GetHardBorrowRewardPeriods(ctx sdk.Context, denom string) (types.MultiRewardPeriod, bool)

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

func (Keeper) GetHardDelegatorRewardFactor added in v0.13.0

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

GetHardDelegatorRewardFactor returns the current reward factor for an individual collateral type

func (Keeper) GetHardDelegatorRewardPeriod added in v0.13.0

func (k Keeper) GetHardDelegatorRewardPeriod(ctx sdk.Context, denom string) (types.RewardPeriod, bool)

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

func (Keeper) GetHardLiquidityProviderClaim added in v0.13.0

func (k Keeper) GetHardLiquidityProviderClaim(ctx sdk.Context, addr sdk.AccAddress) (types.HardLiquidityProviderClaim, bool)

GetHardLiquidityProviderClaim 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) GetHardSupplyRewardIndexes added in v0.13.0

func (k Keeper) GetHardSupplyRewardIndexes(ctx sdk.Context, denom string) (types.RewardIndexes, bool)

GetHardSupplyRewardIndexes gets the current reward indexes for an individual denom

func (Keeper) GetHardSupplyRewardPeriods added in v0.13.0

func (k Keeper) GetHardSupplyRewardPeriods(ctx sdk.Context, denom string) (types.MultiRewardPeriod, bool)

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

func (Keeper) GetMultiplier added in v0.13.0

func (k Keeper) GetMultiplier(ctx sdk.Context, name types.MultiplierName) (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) types.Params

GetParams returns the params from the store

func (Keeper) GetPeriodLength added in v0.13.0

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) GetPreviousHardBorrowRewardAccrualTime added in v0.13.0

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

GetPreviousHardBorrowRewardAccrualTime returns the last time a denom accrued Hard protocol borrow-side rewards

func (Keeper) GetPreviousHardDelegatorRewardAccrualTime added in v0.13.0

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

GetPreviousHardDelegatorRewardAccrualTime returns the last time a denom accrued Hard protocol delegator rewards

func (Keeper) GetPreviousHardSupplyRewardAccrualTime added in v0.13.0

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

GetPreviousHardSupplyRewardAccrualTime returns the last time a denom accrued Hard protocol supply-side rewards

func (Keeper) GetPreviousUSDXMintingAccrualTime added in v0.13.0

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

GetPreviousUSDXMintingAccrualTime returns the last time a collateral type accrued USDX minting rewards

func (Keeper) GetUSDXMintingClaim added in v0.13.0

func (k Keeper) GetUSDXMintingClaim(ctx sdk.Context, addr sdk.AccAddress) (types.USDXMintingClaim, bool)

GetUSDXMintingClaim 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) GetUSDXMintingRewardFactor added in v0.13.0

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

GetUSDXMintingRewardFactor returns the current reward factor for an individual collateral type

func (Keeper) GetUSDXMintingRewardPeriod added in v0.13.0

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

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

func (Keeper) Hooks added in v0.13.0

func (k Keeper) Hooks() Hooks

Hooks create new incentive hooks

func (Keeper) InitializeHardBorrowReward added in v0.13.0

func (k Keeper) InitializeHardBorrowReward(ctx sdk.Context, borrow hardtypes.Borrow)

InitializeHardBorrowReward initializes the borrow-side of a hard liquidity provider claim by creating the claim and setting the borrow reward factor index

func (Keeper) InitializeHardDelegatorReward added in v0.13.0

func (k Keeper) InitializeHardDelegatorReward(ctx sdk.Context, delegator sdk.AccAddress)

InitializeHardDelegatorReward initializes the delegator reward index of a hard claim

func (Keeper) InitializeHardSupplyReward added in v0.13.0

func (k Keeper) InitializeHardSupplyReward(ctx sdk.Context, deposit hardtypes.Deposit)

InitializeHardSupplyReward initializes the supply-side of a hard liquidity provider claim by creating the claim and setting the supply reward factor index

func (Keeper) InitializeUSDXMintingClaim added in v0.13.0

func (k Keeper) InitializeUSDXMintingClaim(ctx sdk.Context, cdp cdptypes.CDP)

InitializeUSDXMintingClaim 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) IterateHardLiquidityProviderClaims added in v0.13.0

func (k Keeper) IterateHardLiquidityProviderClaims(ctx sdk.Context, cb func(c types.HardLiquidityProviderClaim) (stop bool))

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

func (Keeper) IterateUSDXMintingAccrualTimes added in v0.13.0

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

IterateUSDXMintingAccrualTimes iterates over all previous USDX minting accrual times and preforms a callback function

func (Keeper) IterateUSDXMintingClaims added in v0.13.0

func (k Keeper) IterateUSDXMintingClaims(ctx sdk.Context, cb func(c types.USDXMintingClaim) (stop bool))

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

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) SetHardBorrowRewardIndexes added in v0.13.0

func (k Keeper) SetHardBorrowRewardIndexes(ctx sdk.Context, denom string, indexes types.RewardIndexes)

SetHardBorrowRewardIndexes sets the current reward indexes for an individual denom

func (Keeper) SetHardDelegatorRewardFactor added in v0.13.0

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

SetHardDelegatorRewardFactor sets the current reward factor for an individual collateral type

func (Keeper) SetHardLiquidityProviderClaim added in v0.13.0

func (k Keeper) SetHardLiquidityProviderClaim(ctx sdk.Context, c types.HardLiquidityProviderClaim)

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

func (Keeper) SetHardSupplyRewardIndexes added in v0.13.0

func (k Keeper) SetHardSupplyRewardIndexes(ctx sdk.Context, denom string, indexes types.RewardIndexes)

SetHardSupplyRewardIndexes sets the current reward indexes for an individual denom

func (Keeper) SetParams

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

SetParams sets params on the store

func (Keeper) SetPreviousHardBorrowRewardAccrualTime added in v0.13.0

func (k Keeper) SetPreviousHardBorrowRewardAccrualTime(ctx sdk.Context, denom string, blockTime time.Time)

SetPreviousHardBorrowRewardAccrualTime sets the last time a denom accrued Hard protocol borrow-side rewards

func (Keeper) SetPreviousHardDelegatorRewardAccrualTime added in v0.13.0

func (k Keeper) SetPreviousHardDelegatorRewardAccrualTime(ctx sdk.Context, denom string, blockTime time.Time)

SetPreviousHardDelegatorRewardAccrualTime sets the last time a denom accrued Hard protocol delegator rewards

func (Keeper) SetPreviousHardSupplyRewardAccrualTime added in v0.13.0

func (k Keeper) SetPreviousHardSupplyRewardAccrualTime(ctx sdk.Context, denom string, blockTime time.Time)

SetPreviousHardSupplyRewardAccrualTime sets the last time a denom accrued Hard protocol supply-side rewards

func (Keeper) SetPreviousUSDXMintingAccrualTime added in v0.13.0

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

SetPreviousUSDXMintingAccrualTime sets the last time a collateral type accrued USDX minting rewards

func (Keeper) SetUSDXMintingClaim added in v0.13.0

func (k Keeper) SetUSDXMintingClaim(ctx sdk.Context, c types.USDXMintingClaim)

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

func (Keeper) SetUSDXMintingRewardFactor added in v0.13.0

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

SetUSDXMintingRewardFactor sets the current reward factor for an individual collateral type

func (Keeper) SimulateHardSynchronization added in v0.13.0

func (k Keeper) SimulateHardSynchronization(ctx sdk.Context, claim types.HardLiquidityProviderClaim) types.HardLiquidityProviderClaim

SimulateHardSynchronization calculates a user's outstanding hard rewards by simulating reward synchronization

func (Keeper) SimulateUSDXMintingSynchronization added in v0.13.0

func (k Keeper) SimulateUSDXMintingSynchronization(ctx sdk.Context, claim types.USDXMintingClaim) types.USDXMintingClaim

SimulateUSDXMintingSynchronization calculates a user's outstanding USDX minting rewards by simulating reward synchronization

func (Keeper) SynchronizeHardBorrowReward added in v0.13.0

func (k Keeper) SynchronizeHardBorrowReward(ctx sdk.Context, borrow hardtypes.Borrow)

SynchronizeHardBorrowReward updates the claim object by adding any accumulated rewards and updating the reward index value

func (Keeper) SynchronizeHardDelegatorRewards added in v0.13.0

func (k Keeper) SynchronizeHardDelegatorRewards(ctx sdk.Context, delegator sdk.AccAddress)

SynchronizeHardDelegatorRewards updates the claim object by adding any accumulated rewards

func (Keeper) SynchronizeHardLiquidityProviderClaim added in v0.13.0

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

SynchronizeHardLiquidityProviderClaim adds any accumulated rewards

func (Keeper) SynchronizeHardSupplyReward added in v0.13.0

func (k Keeper) SynchronizeHardSupplyReward(ctx sdk.Context, deposit hardtypes.Deposit)

SynchronizeHardSupplyReward updates the claim object by adding any accumulated rewards and updating the reward index value

func (Keeper) SynchronizeUSDXMintingClaim added in v0.13.0

func (k Keeper) SynchronizeUSDXMintingClaim(ctx sdk.Context, claim types.USDXMintingClaim) (types.USDXMintingClaim, error)

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

func (Keeper) SynchronizeUSDXMintingReward added in v0.13.0

func (k Keeper) SynchronizeUSDXMintingReward(ctx sdk.Context, cdp cdptypes.CDP)

SynchronizeUSDXMintingReward 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) UpdateHardBorrowIndexDenoms added in v0.13.0

func (k Keeper) UpdateHardBorrowIndexDenoms(ctx sdk.Context, borrow hardtypes.Borrow)

UpdateHardBorrowIndexDenoms adds any new borrow denoms to the claim's supply reward index

func (Keeper) UpdateHardSupplyIndexDenoms added in v0.13.0

func (k Keeper) UpdateHardSupplyIndexDenoms(ctx sdk.Context, deposit hardtypes.Deposit)

UpdateHardSupplyIndexDenoms adds any new deposit denoms to the claim's supply reward index

func (Keeper) ZeroHardLiquidityProviderClaim added in v0.13.0

func (k Keeper) ZeroHardLiquidityProviderClaim(ctx sdk.Context, claim types.HardLiquidityProviderClaim) types.HardLiquidityProviderClaim

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

func (Keeper) ZeroUSDXMintingClaim added in v0.13.0

func (k Keeper) ZeroUSDXMintingClaim(ctx sdk.Context, claim types.USDXMintingClaim) types.USDXMintingClaim

ZeroUSDXMintingClaim 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