keeper

package
v25.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2025 License: Apache-2.0 Imports: 23 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckVestedDelegationInVestingAccount

func CheckVestedDelegationInVestingAccount(account vesting.VestingAccount, blockTime time.Time, coin sdk.Coin) bool

CheckVestedDelegationInVestingAccount verifies whether the provided vesting account holds a vested delegation for an equal or greater amount of the specified coin at the given block time.

Note that this function facilitates a specific use-case in the LSM module for tokenizing vested delegations. For more details, see https://github.com/cosmos/gaia/issues/2877.

func NewMsgServerImpl

func NewMsgServerImpl(keeper *Keeper) types.MsgServer

NewMsgServerImpl returns an implementation of the staking MsgServer interface for the provided Keeper.

Types

type Hooks

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

Wrapper struct

func (Hooks) AfterDelegationModified

func (h Hooks) AfterDelegationModified(_ context.Context, _ sdk.AccAddress, _ sdk.ValAddress) error

func (Hooks) AfterUnbondingInitiated

func (h Hooks) AfterUnbondingInitiated(_ context.Context, _ uint64) error

func (Hooks) AfterValidatorBeginUnbonding

func (h Hooks) AfterValidatorBeginUnbonding(_ context.Context, _ sdk.ConsAddress, _ sdk.ValAddress) error

func (Hooks) AfterValidatorBonded

func (h Hooks) AfterValidatorBonded(_ context.Context, _ sdk.ConsAddress, _ sdk.ValAddress) error

func (Hooks) AfterValidatorCreated

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

initialize liquid validator record

func (Hooks) AfterValidatorRemoved

func (h Hooks) AfterValidatorRemoved(ctx context.Context, _ sdk.ConsAddress, valAddr sdk.ValAddress) error

func (Hooks) BeforeDelegationCreated

func (h Hooks) BeforeDelegationCreated(_ context.Context, _ sdk.AccAddress, _ sdk.ValAddress) error

func (Hooks) BeforeDelegationRemoved

func (h Hooks) BeforeDelegationRemoved(_ context.Context, _ sdk.AccAddress, _ sdk.ValAddress) error

func (Hooks) BeforeDelegationSharesModified

func (h Hooks) BeforeDelegationSharesModified(_ context.Context, _ sdk.AccAddress, _ sdk.ValAddress) error

func (Hooks) BeforeTokenizeShareRecordRemoved

func (h Hooks) BeforeTokenizeShareRecordRemoved(_ context.Context, _ uint64) error

func (Hooks) BeforeValidatorModified

func (h Hooks) BeforeValidatorModified(_ context.Context, _ sdk.ValAddress) error

func (Hooks) BeforeValidatorSlashed

func (h Hooks) BeforeValidatorSlashed(ctx context.Context, valAddr sdk.ValAddress, fraction sdkmath.LegacyDec) error

type Keeper

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

Keeper of the x/liquid store

func NewKeeper

NewKeeper creates a new liquid Keeper instance

func (Keeper) AddTokenizeShareRecord

func (k Keeper) AddTokenizeShareRecord(ctx context.Context, tokenizeShareRecord types.TokenizeShareRecord) error

func (Keeper) AddTokenizeSharesLock

func (k Keeper) AddTokenizeSharesLock(ctx context.Context, address sdk.AccAddress)

Adds a lock that prevents tokenizing shares for an account The tokenize share lock store is implemented by keying on the account address and storing a timestamp as the value. The timestamp is empty when the lock is set and gets populated with the unlock completion time once the unlock has started

func (*Keeper) BeginBlocker

func (k *Keeper) BeginBlocker(ctx context.Context) error

BeginBlocker removes expired tokenize share locks

func (Keeper) CancelTokenizeShareLockExpiration

func (k Keeper) CancelTokenizeShareLockExpiration(ctx context.Context, address sdk.AccAddress, completionTime time.Time)

Cancels a pending tokenize share authorization by removing the lock from the queue

func (Keeper) CheckExceedsGlobalLiquidStakingCap

func (k Keeper) CheckExceedsGlobalLiquidStakingCap(ctx context.Context, tokens math.Int, sharesAlreadyBonded bool) (bool, error)

CheckExceedsGlobalLiquidStakingCap checks if a liquid delegation would cause the global liquid staking cap to be exceeded A liquid delegation is defined as tokenized shares The total stake is determined by the balance of the bonded pool If the delegation's shares are already bonded (e.g. in the event of a tokenized share) the tokens are already included in the bonded pool If the delegation's shares are not bonded (e.g. normal delegation), we need to add the tokens to the current bonded pool balance to get the total staked

func (Keeper) CheckExceedsValidatorLiquidStakingCap

func (k Keeper) CheckExceedsValidatorLiquidStakingCap(ctx context.Context, validator types.LiquidValidator,
	shares math.LegacyDec, sharesAlreadyBonded bool,
) (bool, error)

CheckExceedsValidatorLiquidStakingCap checks if a liquid delegation could cause the total liquid shares to exceed the liquid staking cap A liquid delegation is defined as tokenized shares If the liquid delegation's shares are already bonded (e.g. in the event of a tokenized share) the tokens are already included in the validator's delegator shares If the liquid delegation's shares are not bonded (e.g. normal delegation), we need to add the shares to the current validator's delegator shares to get the total shares Returns true if the cap is exceeded

func (Keeper) DecreaseTotalLiquidStakedTokens

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

DecreaseTotalLiquidStakedTokens decrements the total liquid staked tokens

func (Keeper) DecreaseValidatorLiquidShares

func (k Keeper) DecreaseValidatorLiquidShares(ctx context.Context, valAddress sdk.ValAddress,
	shares math.LegacyDec,
) (types.LiquidValidator, error)

DecreaseValidatorLiquidShares decrements the liquid shares on a validator

func (Keeper) DelegatorIsLiquidStaker

func (k Keeper) DelegatorIsLiquidStaker(delegatorAddress sdk.AccAddress) bool

Checks if an account associated with a given delegation is related to liquid staking

This is determined by checking if the account has a 32-length address which will identify the following scenarios:

  • An account has tokenized their shares, and thus the delegation is owned by the tokenize share record module account
  • A liquid staking provider is delegating through an ICA account

Both ICA accounts and tokenize share record module accounts have 32-length addresses NOTE: This will have to be refactored before adapting it to chains beyond gaia as other chains may have 32-length addresses that are not related to the above scenarios

func (Keeper) DeleteTokenizeShareRecord

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

func (Keeper) ExportGenesis

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

func (Keeper) GetAllTokenizeShareRecords

func (k Keeper) GetAllTokenizeShareRecords(ctx context.Context) (tokenizeShareRecords []types.TokenizeShareRecord)

func (Keeper) GetAllTokenizeSharesLocks

func (k Keeper) GetAllTokenizeSharesLocks(ctx context.Context) (tokenizeShareLocks []types.TokenizeShareLock)

Returns all tokenize share locks

func (Keeper) GetAuthority

func (k Keeper) GetAuthority() string

GetAuthority returns the x/liquid module's authority.

func (Keeper) GetLastTokenizeShareRecordID

func (k Keeper) GetLastTokenizeShareRecordID(ctx context.Context) uint64

func (Keeper) GetLiquidValidator

func (k Keeper) GetLiquidValidator(ctx context.Context, addr sdk.ValAddress) (validator types.LiquidValidator,
	err error,
)

GetLiquidValidator gets a liquid validator record

func (Keeper) GetParams

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

GetParams gets the x/liquid module parameters.

func (Keeper) GetPendingTokenizeShareAuthorizations

func (k Keeper) GetPendingTokenizeShareAuthorizations(ctx context.Context, completionTime time.Time) types.PendingTokenizeShareAuthorizations

Returns a list of addresses pending tokenize share unlocking at the same time

func (Keeper) GetTokenizeShareRecord

func (k Keeper) GetTokenizeShareRecord(ctx context.Context, id uint64) (tokenizeShareRecord types.TokenizeShareRecord, err error)

func (Keeper) GetTokenizeShareRecordByDenom

func (k Keeper) GetTokenizeShareRecordByDenom(ctx context.Context, denom string) (types.TokenizeShareRecord, error)

func (Keeper) GetTokenizeShareRecordsByOwner

func (k Keeper) GetTokenizeShareRecordsByOwner(ctx context.Context, owner sdk.AccAddress) (tokenizeShareRecords []types.TokenizeShareRecord)

func (Keeper) GetTokenizeSharesLock

func (k Keeper) GetTokenizeSharesLock(ctx context.Context, address sdk.AccAddress) (status types.TokenizeShareLockStatus, unlockTime time.Time)

Checks if there is currently a tokenize share lock for a given account Returns the status indicating whether the account is locked, unlocked, or as a lock expiring. If the lock is expiring, the expiration time is returned

func (Keeper) GetTotalLiquidStakedTokens

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

GetTotalLiquidStakedTokens returns the total outstanding tokens owned by a liquid staking provider Returns zero if the total liquid stake amount has not been initialized

func (Keeper) GlobalLiquidStakingCap

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

Global liquid staking cap across all liquid staking providers

func (Keeper) Hooks

func (k Keeper) Hooks() Hooks

Create new liquid hooks

func (Keeper) InitGenesis

func (k Keeper) InitGenesis(ctx context.Context, data *types.GenesisState)

InitGenesis sets liquid information for genesis

func (Keeper) Logger

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

Logger returns a module-specific logger.

func (Keeper) QueueTokenizeSharesAuthorization

func (k Keeper) QueueTokenizeSharesAuthorization(ctx context.Context, address sdk.AccAddress) (time.Time, error)

Inserts the address into a queue where it will sit for 1 unbonding period before the tokenize share lock is removed Returns the completion time

func (Keeper) RemoveExpiredTokenizeShareLocks

func (k Keeper) RemoveExpiredTokenizeShareLocks(ctx context.Context, blockTime time.Time) ([]string, error)

Unlocks all queued tokenize share authorizations that have matured (i.e. have waited the full unbonding period)

func (Keeper) RemoveLiquidValidator

func (k Keeper) RemoveLiquidValidator(ctx context.Context, addr sdk.ValAddress) error

RemoveLiquidValidator delete the LiquidValidator record

func (Keeper) RemoveTokenizeSharesLock

func (k Keeper) RemoveTokenizeSharesLock(ctx context.Context, address sdk.AccAddress)

Removes the tokenize share lock for an account to enable tokenizing shares

func (Keeper) SafelyIncreaseTotalLiquidStakedTokens

func (k Keeper) SafelyIncreaseTotalLiquidStakedTokens(ctx context.Context, amount math.Int, sharesAlreadyBonded bool) error

SafelyIncreaseTotalLiquidStakedTokens increments the total liquid staked tokens if the global cap is not surpassed by this delegation

The percentage of liquid staked tokens must be less than the GlobalLiquidStakingCap: (TotalLiquidStakedTokens / TotalStakedTokens) <= GlobalLiquidStakingCap

func (Keeper) SafelyIncreaseValidatorLiquidShares

func (k Keeper) SafelyIncreaseValidatorLiquidShares(
	ctx context.Context,
	valAddress sdk.ValAddress,
	shares math.LegacyDec,
	sharesAlreadyBonded bool,
) (types.LiquidValidator, error)

SafelyIncreaseValidatorLiquidShares increments the liquid shares on a validator, if: the validator liquid staking cap will not be exceeded by this delegation

The percentage of validator liquid shares must be less than the ValidatorLiquidStakingCap: (TotalLiquidStakedTokens / TotalStakedTokens) <= ValidatorLiquidStakingCap

func (Keeper) SetLastTokenizeShareRecordID

func (k Keeper) SetLastTokenizeShareRecordID(ctx context.Context, id uint64)

func (Keeper) SetLiquidValidator

func (k Keeper) SetLiquidValidator(ctx context.Context, validator types.LiquidValidator) error

SetLiquidValidator sets the main record holding liquid validator details

func (Keeper) SetParams

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

SetParams sets the x/liquid module parameters. CONTRACT: This method performs no validation of the parameters.

func (Keeper) SetPendingTokenizeShareAuthorizations

func (k Keeper) SetPendingTokenizeShareAuthorizations(ctx context.Context, completionTime time.Time, authorizations types.PendingTokenizeShareAuthorizations)

Stores a list of addresses pending tokenize share unlocking at the same time

func (Keeper) SetTokenizeShareLocks

func (k Keeper) SetTokenizeShareLocks(ctx context.Context, tokenizeShareLocks []types.TokenizeShareLock)

func (Keeper) SetTokenizeSharesUnlockTime

func (k Keeper) SetTokenizeSharesUnlockTime(ctx context.Context, address sdk.AccAddress, completionTime time.Time)

Updates the timestamp associated with a lock to the time at which the lock expires

func (Keeper) SetTotalLiquidStakedTokens

func (k Keeper) SetTotalLiquidStakedTokens(ctx context.Context, tokens math.Int)

SetTotalLiquidStakedTokens stores the total outstanding tokens owned by a liquid staking provider

func (Keeper) TokenizeShareRecordReward

TokenizeShareRecordReward returns estimated amount of reward from tokenize share record ownership

func (Keeper) ValidatorLiquidStakingCap

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

Liquid staking cap for each validator

func (Keeper) WithdrawAllTokenizeShareRecordReward

func (k Keeper) WithdrawAllTokenizeShareRecordReward(ctx sdk.Context, ownerAddr sdk.AccAddress) (sdk.Coins, error)

withdraw reward for all owning TokenizeShareRecord

func (Keeper) WithdrawSingleShareRecordReward

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

func (Keeper) WithdrawTokenizeShareRecordReward

func (k Keeper) WithdrawTokenizeShareRecordReward(ctx context.Context, ownerAddr sdk.AccAddress,
	recordID uint64,
) (sdk.Coins, error)

WithdrawTokenizeShareRecordReward withdraws rewards for owning a TokenizeShareRecord

type Querier

type Querier struct {
	*Keeper
}

Querier is used as Keeper will have duplicate methods if used directly, and gRPC names take precedence over keeper

func NewQuerier

func NewQuerier(keeper *Keeper) Querier

func (Querier) AllTokenizeShareRecords

AllTokenizeShareRecords queries for all tokenize share records

func (Querier) LastTokenizeShareRecordId

LastTokenizeShareRecordId queries for last tokenize share record id

func (Querier) LiquidValidator

LiquidValidator queries for a LiquidValidator record by validator address

func (Querier) LiquidValidators

LiquidValidators queries for all LiquidValidator records

func (Querier) Params

Params queries the staking parameters

func (Querier) TokenizeShareLockInfo

TokenizeShareLockInfo queries status of an account's tokenize share lock

func (Querier) TokenizeShareRecordByDenom

TokenizeShareRecordByDenom queries for individual tokenize share record information by share denom

func (Querier) TokenizeShareRecordById

TokenizeShareRecordById queries for individual tokenize share record information by share by id

func (Querier) TokenizeShareRecordsOwned

TokenizeShareRecordsOwned queries tokenize share records by address

func (Querier) TotalLiquidStaked

TotalLiquidStaked queries for total tokenized staked tokens Liquid staked tokens are either tokenized delegations or delegations owned by a module account

func (Querier) TotalTokenizeSharedAssets

TotalTokenizeSharedAssets queries for total tokenized staked assets

Jump to

Keyboard shortcuts

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