Staking
The staking module processes various messages for validator and delegation management. Each message type has specific security considerations and validation requirements.
Additionally, within the scope of this audit, unlike the existing Cosmos SDK staking module, the system enhances the utility of locked-up staked assets by tokenizing them, even while they remain staked.
The following section outlines the recent updates to the staking module.
States
Added
TotalLiquidStakedTokensTracks the total amount of liquid staked tokens to monitor progress against the
GlobalLiquidStakingCap.
PendingTokenizeShareAuthorizationsStores a queue of addresses undergoing reactivation/unlocking for tokenized shares.
Modified
Two items have been added to Validator.
ValidatorBondSharesRepresents the number of shares self-bonded by the validator.
LiquidSharesRepresents the number of shares either tokenized or owned by a liquid-staking provider.
BeginBlock
Added
RemoveExpiredTokenizeShareLocksFinds and releases all expired
TokenizeShareLocksup to the current block time.
Chain parameters
Added
ValidatorBondFactorDefines the factor for validator bonds.
GlobalLiquidStakingCapSets the global cap for liquid staking.
ValidatorLiquidStakingCapSets the liquid-staking cap for individual validators.
Messages
Added
MsgTokenizeSharesTokenizes a specified amount from an existing delegation.
Creates a new
TokenizeShareRecord.Unbonds the specified amount from the existing delegation.
Transfers the unbonded tokens to the
ModuleAddressspecified in theTokenizeShareRecord.Assigns tokenized shares to the delegator corresponding to the unbonded tokens.
Creates a new delegation between the
ModuleAddressin theTokenizeShareRecordand the validator.
MsgRedeemTokensForSharesRedeems tokenized shares to reclaim the originally delegated assets.
Unbonds the specified amount from the delegation between the
ModuleAddressand validator. Deletes the delegation data if the entire amount is unbonded.Transfers the share tokens to the
NotBondedPooland burns them.Transfers the corresponding original tokens to the delegator and updates delegation information between the validator and delegator.
MsgTransferTokenizeShareRecordTransfers ownership of tokenized delegation to another user.
Removes the relationship between the existing
TokenizeShareRecordand the current owner.Creates a new relationship between the
TokenizeShareRecordand the new owner.
MsgEnableTokenizeSharesInitiates reauthorization for tokenization for a delegator’s address.
Adds a lock to
PendingTokenizeShareAuthorizationsthat will be released after the unbonding period to allow tokenization.
MsgDisableTokenizeSharesDisables tokenization for a delegator’s address.
Removes expired locks from
PendingTokenizeShareAuthorizationsif they exist.Creates a new permanent lock and adds it to
PendingTokenizeShareAuthorizations.
MsgUnbondValidatorTransitions the validator from the
Bondedstate toUnbondingstate.Sets the validator to a jail state and prepares it for unbonding.
MsgValidatorBondDesignates a specific delegation as a validator bond, allowing the validator to receive additional liquid-staking delegations.
Marks a specific delegation as the validator’s
ValidatorBond.
Modified
MsgDelegateIncreases
TotalLiquidStakedTokensby the amount of tokens delegated, if the delegator is a liquid staker.Increases the validator’s
LiquidSharesby the number of shares delegated, if the delegator is a liquid staker.Increases the validator’s
ValidatorSharesby the newly delegated shares, if the existing delegation’sValidatorBondis true.
MsgBeginRedelegateDeducts the redelegated amount converted to validator shares from
ValidatorBondShares, if the source delegation’sValidatorBondis true.Adds the shares calculated by the destination validator for the redelegated amount to the destination validator’s
LiquidSharesand removes it from the source validator’sLiquidShares, if the delegator is a liquid staker.Increases the destination validator’s
ValidatorBondSharesby the redelegated amount converted to shares, if the destination delegation’sValidatorBondis true.
MsgUndelegateDeducts the undelegated amount converted to validator shares from
ValidatorBondShares, if the specified delegation’sValidatorBondis true.Decreases
TotalLiquidStakedTokensby the amount of tokens undelegated, if the delegator is a liquid staker.Decreases the validator’s
LiquidSharesby the number of shares undelegated, if the delegator is a liquid staker.
MsgCancelUnbondingDelegationIncreases
TotalLiquidStakedTokensby the amount of tokens for which unbonding is canceled, if the delegator is a liquid staker.Increases the validator’s
LiquidSharesby the number of shares for which unbonding is canceled, if the delegator is a liquid staker.Increases the validator’s
ValidatorSharesby the number of shares for which unbonding is canceled, if the existing delegation’sValidatorBondis true.
Invariants
This section describes new/removed invariants compared to the existing staking module.
Validator-management messages
MsgEditValidatorValidation for
msg.MinSelfDelegationhas been removed (as it was not actually used).
MsgUnbondValidatorThe
msg.ValidatorAddressmust have been registered through a priorMsgCreateValidator.The
msg.ValidatorAddressmust not already be in jail.
MsgValidatorBondThe
msg.ValidatorAddressmust have been registered through a priorMsgCreateValidator.The
msg.DelegatorAddressmust have delegated self-staked tokens to the validator in advance.The
msg.DelegatorAddressmust not be a liquid staker.The delegation between
msg.ValidatorAddressandmsg.DelegatorAddressmust not already be set as a validator bond.
Share-tokenization messages
MsgTokenizeSharesThe
msg.Amount.Amountmust be greater than zero and not nil.The
msg.Amount.Denommust match the regular expression[a-zA-Z][a-zA-Z0-9/:._-]{2,127}.The
msg.Amount.Amountcannot exceed the number of tokens owned by the delegator formsg.Amount.Denom.The tokenize-share lock for
msg.DelegatorAddressmust not be inTOKENIZE_SHARE_LOCK_STATUS_LOCKEDorTOKENIZE_SHARE_LOCK_STATUS_LOCK_EXPIRING.A delegation must exist between the validator specified by
msg.ValidatorAddressand the delegator specified bymsg.DelegatorAddress.The delegation’s
ValidatorBondmust not be true.The
msg.Amount.Denommust match the denom specified in the chain parameters.If the delegator specified by
msg.DelegatorAddressis a vesting account, the tokenized shares must not exceed the amount available for use after the vesting period.The delegator specified by
msg.DelegatorAddressmust not be in the middle of a redelegation process.The shares to be unbonded by the delegator specified by
msg.DelegatorAddressmust not exceed the delegation’s total shares.
MsgRedeemTokensForSharesThe
msg.Amount.Amountmust be greater than zero and not nil.The
msg.Amount.Denommust match the regular expression[a-zA-Z][a-zA-Z0-9/:._-]{2,127}.The
msg.Amount.Amountcannot exceed the number of tokens owned by the delegator formsg.Amount.Denom.A
TokenizeShareRecordrelated tomsg.Amount.Denommust exist.The validator in the
TokenizeShareRecordmust have been registered through a priorMsgCreateValidator.A delegation relationship must exist between the
Module Addressin theTokenizeShareRecordand the validator.The shares calculated for the
msg.Amount.Amountbased on the validator in theTokenizeShareRecordmust not be zero.The shares to be unbonded by the delegator specified by
msg.DelegatorAddressmust not exceed the delegation’s total shares.
MsgTransferTokenizeShareRecordThe
msg.Sendermust be therecord.Owner.
MsgEnableTokenizeSharesThe tokenize-share lock related to
msg.DelegatorAddressmust not be inTOKENIZE_SHARE_LOCK_STATUS_UNLOCKED.The tokenize-share lock related to
msg.DelegatorAddressmust not be inTOKENIZE_SHARE_LOCK_STATUS_LOCK_EXPIRING.
MsgDisableTokenizeSharesThe tokenize-share lock related to
msg.DelegatorAddressmust not be inTOKENIZE_SHARE_LOCK_STATUS_LOCKED.