keeper

package
v10.0.1-0...-246915f Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2022 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	HourDuration, _    = time.ParseDuration("1h")
	DayDuration, _     = time.ParseDuration("24h")
	WeekDuration, _    = time.ParseDuration("168h")
	TwoWeekDuration, _ = time.ParseDuration("336h")
	BaselineDurations  = []time.Duration{DayDuration, WeekDuration, TwoWeekDuration}
)

Functions

func AccumulationStoreInvariant

func AccumulationStoreInvariant(keeper Keeper) sdk.Invariant

AccumulationStoreInvariant ensures that the sum of all lockups at a given duration is equal to the value stored within the accumulation store.

func MergeLockupsForSimilarDurations

func MergeLockupsForSimilarDurations(
	ctx sdk.Context,
	k Keeper,
	ak types.AccountKeeper,
	baselineDurations []time.Duration,
	durationDiff time.Duration,
)

MergeLockupsForSimilarDurations iterates through every account. For each account, it combines all lockups it has at a similar duration (to be defined in a bit). It will delete every existing lockup for that account, and make at most, a single new lockup per "base duration", denom pair. If a lockup is far from any base duration, we don't change anything about it. We define a lockup length as a "Similar duration to base duration D", if: D <= lockup length <= D + durationDiff.

func NewMsgServerImpl

func NewMsgServerImpl(keeper *Keeper) types.MsgServer

NewMsgServerImpl returns an instance of MsgServer.

func RegisterInvariants

func RegisterInvariants(ir sdk.InvariantRegistry, keeper Keeper)

RegisterInvariants registers all governance invariants.

func SyntheticLockupInvariant

func SyntheticLockupInvariant(keeper Keeper) sdk.Invariant

Types

type AdminKeeper

type AdminKeeper struct {
	Keeper
}

AdminKeeper defines a god privilege keeper functions to remove tokens from locks and create new locks For the governance system of token pools, we want a "ragequit" feature So governance changes will take 1 week to go into effect During that time, people can choose to "ragequit" which means they would leave the original pool and form a new pool with the old parameters but if they still had 2 months of lockup left, their liquidity still needs to be 2 month lockup-ed, just in the new pool And we need to replace their pool1 LP tokens with pool2 LP tokens with the same lock duration and end time.

func (AdminKeeper) BreakLock

func (ak AdminKeeper) BreakLock(ctx sdk.Context, lockID uint64) error

BreakLock unlock a lockID without considering time with admin privilege.

func (AdminKeeper) Relock

func (ak AdminKeeper) Relock(ctx sdk.Context, lockID uint64, newCoins sdk.Coins) error

Relock unlock previous lockID and create a new lock with newCoins with same duration and endtime.

type Keeper

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

Keeper provides a way to manage module storage.

func NewKeeper

func NewKeeper(cdc codec.Codec, storeKey sdk.StoreKey, ak types.AccountKeeper, bk types.BankKeeper, dk types.DistrKeeper) *Keeper

NewKeeper returns an instance of Keeper.

func (Keeper) AccountLockIterator

func (k Keeper) AccountLockIterator(ctx sdk.Context, isUnlocking bool, addr sdk.AccAddress) sdk.Iterator

AccountLockIterator returns the iterator used for getting all locks by account.

func (Keeper) AccountLockIteratorAfterTime

func (k Keeper) AccountLockIteratorAfterTime(ctx sdk.Context, addr sdk.AccAddress, time time.Time) sdk.Iterator

AccountLockIteratorAfterTime returns the iterator to get locked coins by account.

func (Keeper) AccountLockIteratorAfterTimeDenom

func (k Keeper) AccountLockIteratorAfterTimeDenom(ctx sdk.Context, addr sdk.AccAddress, denom string, time time.Time) sdk.Iterator

AccountLockIteratorAfterTimeDenom returns the iterator to get locked coins by account and denom.

func (Keeper) AccountLockIteratorBeforeTime

func (k Keeper) AccountLockIteratorBeforeTime(ctx sdk.Context, addr sdk.AccAddress, time time.Time) sdk.Iterator

AccountLockIteratorBeforeTime returns the iterator to get unlockable coins by account.

func (Keeper) AccountLockIteratorBeforeTimeDenom

func (k Keeper) AccountLockIteratorBeforeTimeDenom(ctx sdk.Context, addr sdk.AccAddress, denom string, time time.Time) sdk.Iterator

AccountLockIteratorBeforeTimeDenom returns the iterator to get unlockable coins by account and denom.

func (Keeper) AccountLockIteratorDenom

func (k Keeper) AccountLockIteratorDenom(ctx sdk.Context, isUnlocking bool, addr sdk.AccAddress, denom string) sdk.Iterator

AccountLockIteratorDenom returns the iterator used for getting all locks by account and denom.

func (Keeper) AccountLockIteratorDuration

func (k Keeper) AccountLockIteratorDuration(ctx sdk.Context, isUnlocking bool, addr sdk.AccAddress, duration time.Duration) sdk.Iterator

AccountLockIteratorDuration returns an iterator used for getting all locks for a given account, isUnlocking, and specific duration.

func (Keeper) AccountLockIteratorDurationDenom

func (k Keeper) AccountLockIteratorDurationDenom(ctx sdk.Context, isUnlocking bool, addr sdk.AccAddress, denom string, duration time.Duration) sdk.Iterator

AccountLockIteratorDurationDenom returns iterator used for getting all locks by account and denom with specific duration.

func (Keeper) AccountLockIteratorLongerDuration

func (k Keeper) AccountLockIteratorLongerDuration(ctx sdk.Context, isUnlocking bool, addr sdk.AccAddress, duration time.Duration) sdk.Iterator

AccountLockIteratorLongerDuration returns iterator used for getting all locks by account longer than duration.

func (Keeper) AccountLockIteratorLongerDurationDenom

func (k Keeper) AccountLockIteratorLongerDurationDenom(ctx sdk.Context, isUnlocking bool, addr sdk.AccAddress, denom string, duration time.Duration) sdk.Iterator

AccountLockIteratorLongerDurationDenom returns iterator used for getting all locks by account and denom longer than duration.

func (Keeper) AccountLockIteratorShorterThanDuration

func (k Keeper) AccountLockIteratorShorterThanDuration(ctx sdk.Context, isUnlocking bool, addr sdk.AccAddress, duration time.Duration) sdk.Iterator

AccountLockIteratorShorterThanDuration returns an iterator used for getting all locks by account shorter than the specified duration.

func (Keeper) AddToExistingLock

func (k Keeper) AddToExistingLock(ctx sdk.Context, owner sdk.AccAddress, coin sdk.Coin, duration time.Duration) ([]types.PeriodLock, error)

func (Keeper) AddTokensToLockByID

func (k Keeper) AddTokensToLockByID(ctx sdk.Context, lockID uint64, owner sdk.AccAddress, coin sdk.Coin) (*types.PeriodLock, error)

AddTokensToLock locks more tokens into a lockup This also saves the lock to the store.

func (Keeper) BeginForceUnlock

func (k Keeper) BeginForceUnlock(ctx sdk.Context, lockID uint64, coins sdk.Coins) error

func (Keeper) BeginForceUnlockWithEndTime

func (k Keeper) BeginForceUnlockWithEndTime(ctx sdk.Context, lockID uint64, endTime time.Time) error

func (Keeper) BeginUnlock

func (k Keeper) BeginUnlock(ctx sdk.Context, lockID uint64, coins sdk.Coins) error

BeginUnlock is a utility to start unlocking coins from NotUnlocking queue.

func (Keeper) BeginUnlockAllNotUnlockings

func (k Keeper) BeginUnlockAllNotUnlockings(ctx sdk.Context, account sdk.AccAddress) ([]types.PeriodLock, error)

BeginUnlockAllNotUnlockings begins unlock for all not unlocking coins.

func (Keeper) BreakAllSyntheticLocks

func (k Keeper) BreakAllSyntheticLocks(ctx sdk.Context, lock types.PeriodLock, synthLocks []types.SyntheticLock) error

func (Keeper) ClearAccumulationStores

func (k Keeper) ClearAccumulationStores(ctx sdk.Context)

func (Keeper) ClearAllAccumulationStores

func (k Keeper) ClearAllAccumulationStores(ctx sdk.Context)

func (Keeper) ClearAllLockRefKeys

func (k Keeper) ClearAllLockRefKeys(ctx sdk.Context)

func (Keeper) CreateLock

func (k Keeper) CreateLock(ctx sdk.Context, owner sdk.AccAddress, coins sdk.Coins, duration time.Duration) (types.PeriodLock, error)

LockTokens lock tokens from an account for specified duration.

func (Keeper) CreateSyntheticLockup

func (k Keeper) CreateSyntheticLockup(ctx sdk.Context, lockID uint64, synthDenom string, unlockDuration time.Duration, isUnlocking bool) error

CreateSyntheticLockup create synthetic lockup with lock id and synthdenom.

func (Keeper) DeleteAllMaturedSyntheticLocks

func (k Keeper) DeleteAllMaturedSyntheticLocks(ctx sdk.Context)

func (Keeper) DeleteSyntheticLockup

func (k Keeper) DeleteSyntheticLockup(ctx sdk.Context, lockID uint64, synthdenom string) error

DeleteSyntheticLockup delete synthetic lockup with lock id and synthdenom.

func (Keeper) ExtendLockup

func (k Keeper) ExtendLockup(ctx sdk.Context, lock types.PeriodLock, newDuration time.Duration) error

func (Keeper) ForceUnlock

func (k Keeper) ForceUnlock(ctx sdk.Context, lock types.PeriodLock) error

ForceUnlock ignores unlock duration and immediately unlocks the lock and refunds tokens to lock owner..

func (Keeper) GetAccountLockedCoins

func (k Keeper) GetAccountLockedCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins

GetAccountLockedCoins Returns a locked coins that can't be withdrawn.

func (Keeper) GetAccountLockedDuration

func (k Keeper) GetAccountLockedDuration(ctx sdk.Context, addr sdk.AccAddress, duration time.Duration) []types.PeriodLock

GetAccountLockedDuration returns locks with a specific duration for a given account.

func (Keeper) GetAccountLockedDurationNotUnlockingOnly

func (k Keeper) GetAccountLockedDurationNotUnlockingOnly(ctx sdk.Context, addr sdk.AccAddress, denom string, duration time.Duration) []types.PeriodLock

GetAccountLockedDurationNotUnlockingOnly Returns account locked with specific duration within not unlockings.

func (Keeper) GetAccountLockedLongerDuration

func (k Keeper) GetAccountLockedLongerDuration(ctx sdk.Context, addr sdk.AccAddress, duration time.Duration) []types.PeriodLock

GetAccountLockedLongerDuration Returns account locked with duration longer than specified.

func (Keeper) GetAccountLockedLongerDurationDenom

func (k Keeper) GetAccountLockedLongerDurationDenom(ctx sdk.Context, addr sdk.AccAddress, denom string, duration time.Duration) []types.PeriodLock

GetAccountLockedLongerDurationDenom Returns account locked with duration longer than specified with specific denom.

func (Keeper) GetAccountLockedLongerDurationDenomNotUnlockingOnly

func (k Keeper) GetAccountLockedLongerDurationDenomNotUnlockingOnly(ctx sdk.Context, addr sdk.AccAddress, denom string, duration time.Duration) []types.PeriodLock

GetAccountLockedLongerDurationDenom Returns account locked with duration longer than specified with specific denom.

func (Keeper) GetAccountLockedLongerDurationNotUnlockingOnly

func (k Keeper) GetAccountLockedLongerDurationNotUnlockingOnly(ctx sdk.Context, addr sdk.AccAddress, duration time.Duration) []types.PeriodLock

GetAccountLockedLongerDurationNotUnlockingOnly Returns account locked with duration longer than specified

func (Keeper) GetAccountLockedPastTime

func (k Keeper) GetAccountLockedPastTime(ctx sdk.Context, addr sdk.AccAddress, timestamp time.Time) []types.PeriodLock

GetAccountLockedPastTime Returns the total locks of an account whose unlock time is beyond timestamp.

func (Keeper) GetAccountLockedPastTimeDenom

func (k Keeper) GetAccountLockedPastTimeDenom(ctx sdk.Context, addr sdk.AccAddress, denom string, timestamp time.Time) []types.PeriodLock

GetAccountLockedPastTimeDenom is equal to GetAccountLockedPastTime but denom specific.

func (Keeper) GetAccountLockedPastTimeNotUnlockingOnly

func (k Keeper) GetAccountLockedPastTimeNotUnlockingOnly(ctx sdk.Context, addr sdk.AccAddress, timestamp time.Time) []types.PeriodLock

GetAccountLockedPastTimeNotUnlockingOnly Returns the total locks of an account whose unlock time is beyond timestamp.

func (Keeper) GetAccountPeriodLocks

func (k Keeper) GetAccountPeriodLocks(ctx sdk.Context, addr sdk.AccAddress) []types.PeriodLock

GetAccountPeriodLocks Returns the period locks associated to an account.

func (Keeper) GetAccountUnlockableCoins

func (k Keeper) GetAccountUnlockableCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins

GetAccountUnlockableCoins Returns whole unlockable coins which are not withdrawn yet.

func (Keeper) GetAccountUnlockedBeforeTime

func (k Keeper) GetAccountUnlockedBeforeTime(ctx sdk.Context, addr sdk.AccAddress, timestamp time.Time) []types.PeriodLock

GetAccountUnlockedBeforeTime Returns the total unlocks of an account whose unlock time is before timestamp.

func (Keeper) GetAccountUnlockingCoins

func (k Keeper) GetAccountUnlockingCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins

GetAccountUnlockingCoins Returns whole unlocking coins.

func (Keeper) GetAllSyntheticLockups

func (k Keeper) GetAllSyntheticLockups(ctx sdk.Context) []types.SyntheticLock

func (Keeper) GetAllSyntheticLockupsByAddr

func (k Keeper) GetAllSyntheticLockupsByAddr(ctx sdk.Context, owner sdk.AccAddress) []types.SyntheticLock

func (Keeper) GetAllSyntheticLockupsByLockup

func (k Keeper) GetAllSyntheticLockupsByLockup(ctx sdk.Context, lockID uint64) []types.SyntheticLock

func (Keeper) GetLastLockID

func (k Keeper) GetLastLockID(ctx sdk.Context) uint64

GetLastLockID returns ID used last time.

func (Keeper) GetLockByID

func (k Keeper) GetLockByID(ctx sdk.Context, lockID uint64) (*types.PeriodLock, error)

GetLockByID Returns lock from lockID.

func (Keeper) GetLockedDenom

func (k Keeper) GetLockedDenom(ctx sdk.Context, denom string, duration time.Duration) sdk.Int

GetLockedDenom Returns the total amount of denom that are locked.

func (Keeper) GetLocksDenom

func (k Keeper) GetLocksDenom(ctx sdk.Context, denom string) []types.PeriodLock

func (Keeper) GetLocksLongerThanDurationDenom

func (k Keeper) GetLocksLongerThanDurationDenom(ctx sdk.Context, denom string, duration time.Duration) []types.PeriodLock

GetLocksLongerThanDurationDenom Returns the locks whose unlock duration is longer than duration.

func (Keeper) GetLocksPastTimeDenom

func (k Keeper) GetLocksPastTimeDenom(ctx sdk.Context, denom string, timestamp time.Time) []types.PeriodLock

GetLocksPastTimeDenom Returns the locks whose unlock time is beyond timestamp.

func (Keeper) GetModuleBalance

func (k Keeper) GetModuleBalance(ctx sdk.Context) sdk.Coins

GetModuleBalance Returns full balance of the module.

func (Keeper) GetModuleLockedCoins

func (k Keeper) GetModuleLockedCoins(ctx sdk.Context) sdk.Coins

GetModuleLockedCoins Returns locked balance of the module.

func (Keeper) GetPeriodLocks

func (k Keeper) GetPeriodLocks(ctx sdk.Context) ([]types.PeriodLock, error)

GetPeriodLocks Returns the period locks on pool.

func (Keeper) GetPeriodLocksAccumulation

func (k Keeper) GetPeriodLocksAccumulation(ctx sdk.Context, query types.QueryCondition) sdk.Int

GetPeriodLocksByDuration returns the total amount of query.Denom tokens locked for longer than query.Duration.

func (Keeper) GetSyntheticLockup

func (k Keeper) GetSyntheticLockup(ctx sdk.Context, lockID uint64, synthdenom string) (*types.SyntheticLock, error)

func (Keeper) GetUnderlyingLock

func (k Keeper) GetUnderlyingLock(ctx sdk.Context, synthlock types.SyntheticLock) types.PeriodLock

func (Keeper) HasAnySyntheticLockups

func (k Keeper) HasAnySyntheticLockups(ctx sdk.Context, lockID uint64) bool

func (Keeper) Lock

func (k Keeper) Lock(ctx sdk.Context, lock types.PeriodLock) error

Lock is a utility to lock coins into module account.

func (Keeper) LockIterator

func (k Keeper) LockIterator(ctx sdk.Context, isUnlocking bool) sdk.Iterator

LockIterator returns the iterator used for getting all locks.

func (Keeper) LockIteratorAfterTime

func (k Keeper) LockIteratorAfterTime(ctx sdk.Context, time time.Time) sdk.Iterator

LockIteratorAfterTime returns the iterator to get locked coins.

func (Keeper) LockIteratorAfterTimeDenom

func (k Keeper) LockIteratorAfterTimeDenom(ctx sdk.Context, denom string, time time.Time) sdk.Iterator

LockIteratorAfterTimeDenom returns the iterator to get locked coins by denom.

func (Keeper) LockIteratorBeforeTime

func (k Keeper) LockIteratorBeforeTime(ctx sdk.Context, time time.Time) sdk.Iterator

LockIteratorBeforeTime returns the iterator to get unlockable coins.

func (Keeper) LockIteratorBeforeTimeDenom

func (k Keeper) LockIteratorBeforeTimeDenom(ctx sdk.Context, denom string, time time.Time) sdk.Iterator

LockIteratorBeforeTimeDenom returns the iterator to get unlockable coins by denom.

func (Keeper) LockIteratorDenom

func (k Keeper) LockIteratorDenom(ctx sdk.Context, isUnlocking bool, denom string) sdk.Iterator

LockIteratorDenom returns the iterator used for getting all locks by denom.

func (Keeper) LockIteratorLongerThanDurationDenom

func (k Keeper) LockIteratorLongerThanDurationDenom(ctx sdk.Context, isUnlocking bool, denom string, duration time.Duration) sdk.Iterator

LockIteratorLongerThanDurationDenom returns the iterator to get locked locks by denom.

func (Keeper) Logger

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

Logger returns a logger instance.

func (Keeper) ResetAllLocks

func (k Keeper) ResetAllLocks(ctx sdk.Context, locks []types.PeriodLock) error

ResetAllLocks takes a set of locks, and initializes state to be storing them all correctly. This utilizes batch optimizations to improve efficiency, as this becomes a bottleneck at chain initialization & upgrades.

func (Keeper) ResetAllSyntheticLocks

func (k Keeper) ResetAllSyntheticLocks(ctx sdk.Context, syntheticLocks []types.SyntheticLock) error

func (*Keeper) SetHooks

func (k *Keeper) SetHooks(lh types.LockupHooks) *Keeper

Set the lockup hooks.

func (Keeper) SetLastLockID

func (k Keeper) SetLastLockID(ctx sdk.Context, ID uint64)

SetLastLockID save ID used by last lock.

func (Keeper) SlashTokensFromLockByID

func (k Keeper) SlashTokensFromLockByID(ctx sdk.Context, lockID uint64, coins sdk.Coins) (*types.PeriodLock, error)

SlashTokensFromLockByID send slashed tokens to community pool - called by superfluid module only.

func (Keeper) Unlock

func (k Keeper) Unlock(ctx sdk.Context, lockID uint64) error

Unlock is a utility to unlock coins from module account.

func (Keeper) WithdrawAllMaturedLocks

func (k Keeper) WithdrawAllMaturedLocks(ctx sdk.Context)

WithdrawAllMaturedLocks withdraws every lock thats in the process of unlocking, and has finished unlocking by the current block time.

type Querier

type Querier struct {
	Keeper
}

Querier defines a wrapper around the x/lockup keeper providing gRPC method handlers.

func NewQuerier

func NewQuerier(k Keeper) Querier

func (Querier) AccountLockedCoins

AccountLockedCoins Returns a locked coins that can't be withdrawn.

func (Querier) AccountLockedDuration

AccountLockedDuration returns the account locked with the specified duration.

func (Querier) AccountLockedLongerDuration

AccountLockedLongerDuration Returns account locked with duration longer than specified.

func (Querier) AccountLockedLongerDurationDenom

AccountLockedLongerDurationDenom Returns account locked with duration longer than specified with specific denom.

func (Querier) AccountLockedLongerDurationNotUnlockingOnly

AccountLockedLongerDurationNotUnlockingOnly Returns account locked records with longer duration excluding tokens started unlocking.

func (Querier) AccountLockedPastTime

AccountLockedPastTime Returns the total locks of an account whose unlock time is beyond timestamp.

func (Querier) AccountLockedPastTimeDenom

AccountLockedPastTimeDenom is equal to GetAccountLockedPastTime but denom specific.

func (Querier) AccountLockedPastTimeNotUnlockingOnly

AccountLockedPastTimeNotUnlockingOnly Returns locked records of an account with unlock time beyond timestamp excluding tokens started unlocking.

func (Querier) AccountUnlockableCoins

AccountUnlockableCoins returns unlockable coins which are not withdrawn yet.

func (Querier) AccountUnlockedBeforeTime

AccountUnlockedBeforeTime Returns the total unlocks of an account whose unlock time is before timestamp.

func (Querier) AccountUnlockingCoins

AccountUnlockingCoins returns whole unlocking coins.

func (Querier) LockedByID

func (q Querier) LockedByID(goCtx context.Context, req *types.LockedRequest) (*types.LockedResponse, error)

LockedByID Returns lock by lock ID.

func (Querier) LockedDenom

func (Querier) ModuleBalance

ModuleBalance Return full balance of the module.

func (Querier) ModuleLockedAmount

ModuleLockedAmount Returns locked balance of the module.

func (Querier) SyntheticLockupsByLockupID

SyntheticLockupsByLockupID returns synthetic lockups by native lockup id.

Jump to

Keyboard shortcuts

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