Documentation ¶
Index ¶
- Constants
- Variables
- func AllInvariants(k Keeper) sdk.Invariant
- func CalibrateDelegationCallback(k Keeper, ctx sdk.Context, args []byte, query icqtypes.Query) error
- func DelegatorSharesCallback(k Keeper, ctx sdk.Context, args []byte, query icqtypes.Query) error
- func EmitFailedLSMLiquidStakeEvent(ctx sdk.Context, hostZone types.HostZone, ...)
- func EmitPendingLSMLiquidStakeEvent(ctx sdk.Context, hostZone types.HostZone, ...)
- func EmitSuccessfulLSMLiquidStakeEvent(ctx sdk.Context, hostZone types.HostZone, ...)
- func EmitSuccessfulLiquidStakeEvent(ctx sdk.Context, msg *types.MsgLiquidStake, hostZone types.HostZone, ...)
- func EmitUndelegationEvent(ctx sdk.Context, hostZone types.HostZone, totalUnbondAmount sdkmath.Int)
- func EmitValidatorSharesToTokensRateChangeEvent(ctx sdk.Context, chainId string, validatorAddress string, ...)
- func EmitValidatorSlashEvent(ctx sdk.Context, hostZone types.HostZone, validatorAddress string, ...)
- func FeeBalanceCallback(k Keeper, ctx sdk.Context, args []byte, query icqtypes.Query) error
- func GetLSMTokenDepositId(blockHeight int64, chainId, stakerAddress, denom string) string
- func GetValidatorFromAddress(validators []*types.Validator, address string) (val types.Validator, index int64, found bool)
- func NewMsgServerImpl(keeper Keeper) types.MsgServer
- func RegisterInvariants(ir sdk.InvariantRegistry, k Keeper)
- func ValidatorSharesToTokensRateCallback(k Keeper, ctx sdk.Context, args []byte, query icqtypes.Query) error
- func WithdrawalBalanceCallback(k Keeper, ctx sdk.Context, args []byte, query icqtypes.Query) error
- type Hooks
- type ICQCallback
- type ICQCallbacks
- func (c ICQCallbacks) AddICQCallback(id string, fn interface{}) icqtypes.QueryCallbacks
- func (c ICQCallbacks) CallICQCallback(ctx sdk.Context, id string, args []byte, query icqtypes.Query) error
- func (c ICQCallbacks) HasICQCallback(id string) bool
- func (c ICQCallbacks) RegisterICQCallbacks() icqtypes.QueryCallbacks
- type IcaTx
- type Keeper
- func (k Keeper) AddDelegationToValidator(ctx sdk.Context, hostZone *types.HostZone, validatorAddress string, ...) error
- func (k Keeper) AddValidatorToHostZone(ctx sdk.Context, chainId string, validator types.Validator, ...) error
- func (k Keeper) AddValidatorsProposal(ctx sdk.Context, msg *types.AddValidatorsProposal) error
- func (k Keeper) AddressUnbondings(c context.Context, req *types.QueryAddressUnbondings) (*types.QueryAddressUnbondingsResponse, error)
- func (k Keeper) AfterEpochEnd(ctx sdk.Context, epochInfo epochstypes.EpochInfo)
- func (k Keeper) AllocateHostZoneReward(ctx sdk.Context)
- func (k Keeper) AssertStrideAndDayEpochRelationship(ctx sdk.Context)
- func (k Keeper) BeforeEpochStart(ctx sdk.Context, epochInfo epochstypes.EpochInfo)
- func (k Keeper) BeginBlocker(ctx sdk.Context)
- func (k Keeper) BurnTokens(ctx sdk.Context, hostZone types.HostZone, stTokenBurnAmount sdkmath.Int) error
- func (k Keeper) CalculateLSMStToken(liquidStakedShares sdkmath.Int, lsmLiquidStake types.LSMLiquidStake) sdk.Coin
- func (k Keeper) Callbacks() icacallbackstypes.ModuleCallbacks
- func (k Keeper) CheckDelegationChangedDuringQuery(ctx sdk.Context, validator types.Validator, ...) (overlapped bool, err error)
- func (k Keeper) CheckForSlash(ctx sdk.Context, hostZone types.HostZone, valIndex int64, ...) (validatorWasSlashed bool, delegatedTokens sdkmath.Int, err error)
- func (k Keeper) CheckIfValidatorWasSlashed(ctx sdk.Context, hostZone types.HostZone, ...) (validatorWasSlashed bool, err error)
- func (k Keeper) CheckIsStToken(ctx sdk.Context, denom string) bool
- func (k Keeper) ClaimCallback(ctx sdk.Context, packet channeltypes.Packet, ...) error
- func (k Keeper) CleanupEpochUnbondingRecords(ctx sdk.Context, epochNumber uint64) bool
- func (k Keeper) CreateDepositRecordsForEpoch(ctx sdk.Context, epochNumber uint64)
- func (k Keeper) CreateEpochUnbondingRecord(ctx sdk.Context, epochNumber uint64) bool
- func (k Keeper) DecrementHostZoneUnbonding(ctx sdk.Context, userRedemptionRecord recordstypes.UserRedemptionRecord, ...) error
- func (k Keeper) DecrementValidatorDelegationChangesInProgress(hostZone *types.HostZone, validatorAddress string) error
- func (k Keeper) DelegateCallback(ctx sdk.Context, packet channeltypes.Packet, ...) error
- func (k Keeper) DelegateOnHost(ctx sdk.Context, hostZone types.HostZone, amt sdk.Coin, ...) error
- func (k Keeper) DetokenizeAllLSMDeposits(ctx sdk.Context)
- func (k Keeper) DetokenizeCallback(ctx sdk.Context, packet channeltypes.Packet, ...) error
- func (k Keeper) DetokenizeLSMDeposit(ctx sdk.Context, hostZone types.HostZone, deposit recordstypes.LSMTokenDeposit) error
- func (k Keeper) EndBlocker(ctx sdk.Context)
- func (k Keeper) EpochTracker(c context.Context, req *types.QueryGetEpochTrackerRequest) (*types.QueryGetEpochTrackerResponse, error)
- func (k Keeper) EpochTrackerAll(c context.Context, req *types.QueryAllEpochTrackerRequest) (*types.QueryAllEpochTrackerResponse, error)
- func (k Keeper) FailLSMLiquidStake(ctx sdk.Context, hostZone types.HostZone, lsmLiquidStake types.LSMLiquidStake, ...)
- func (k Keeper) FinishLSMLiquidStake(ctx sdk.Context, lsmLiquidStake types.LSMLiquidStake, async bool) error
- func (k Keeper) GetAllActiveHostZone(ctx sdk.Context) (list []types.HostZone)
- func (k Keeper) GetAllEpochTracker(ctx sdk.Context) (list []types.EpochTracker)
- func (k Keeper) GetAllHostZone(ctx sdk.Context) (list []types.HostZone)
- func (k Keeper) GetChainID(ctx sdk.Context, connectionID string) (string, error)
- func (k Keeper) GetClaimableRedemptionRecord(ctx sdk.Context, msg *types.MsgClaimUndelegatedTokens) (*recordstypes.UserRedemptionRecord, error)
- func (k Keeper) GetConnectionId(ctx sdk.Context, portId string) (string, error)
- func (k Keeper) GetCounterpartyChainId(ctx sdk.Context, connectionID string) (string, error)
- func (k Keeper) GetDepositAccountBalance(chainId string, depositRecords []recordstypes.DepositRecord) sdk.Dec
- func (k Keeper) GetEpochTracker(ctx sdk.Context, epochIdentifier string) (val types.EpochTracker, found bool)
- func (k Keeper) GetHostZone(ctx sdk.Context, chainId string) (val types.HostZone, found bool)
- func (k Keeper) GetHostZoneFromHostDenom(ctx sdk.Context, denom string) (*types.HostZone, error)
- func (k Keeper) GetHostZoneFromIBCDenom(ctx sdk.Context, denom string) (*types.HostZone, error)
- func (k Keeper) GetHostZoneFromLSMTokenPath(ctx sdk.Context, path string) (types.HostZone, error)
- func (k Keeper) GetHostZoneFromTransferChannelID(ctx sdk.Context, channelID string) (hostZone types.HostZone, found bool)
- func (k Keeper) GetICATimeoutNanos(ctx sdk.Context, epochType string) (uint64, error)
- func (k Keeper) GetInnerSafetyBounds(ctx sdk.Context, zone types.HostZone) (sdk.Dec, sdk.Dec)
- func (k Keeper) GetLSMTokenDenomTrace(ctx sdk.Context, denom string) (transfertypes.DenomTrace, error)
- func (k Keeper) GetLatestCompletionTime(ctx sdk.Context, msgResponses [][]byte) (*time.Time, error)
- func (k Keeper) GetLightClientHeightSafely(ctx sdk.Context, connectionID string) (uint64, error)
- func (k Keeper) GetLightClientTimeSafely(ctx sdk.Context, connectionID string) (uint64, error)
- func (k Keeper) GetOuterSafetyBounds(ctx sdk.Context, zone types.HostZone) (sdk.Dec, sdk.Dec)
- func (k *Keeper) GetParam(ctx sdk.Context, key []byte) uint64
- func (k Keeper) GetParams(ctx sdk.Context) (params types.Params)
- func (k Keeper) GetRebalanceICAMessages(hostZone types.HostZone, validatorDeltas []RebalanceValidatorDelegationChange) (msgs []proto.Message, rebalancings []*types.Rebalancing)
- func (k Keeper) GetRedemptionTransferMsg(ctx sdk.Context, userRedemptionRecord *recordstypes.UserRedemptionRecord, ...) (*IcaTx, error)
- func (k Keeper) GetStartTimeNextEpoch(ctx sdk.Context, epochType string) (uint64, error)
- func (k Keeper) GetStrideEpochElapsedShare(ctx sdk.Context) (sdk.Dec, error)
- func (k Keeper) GetTargetValAmtsForHostZone(ctx sdk.Context, hostZone types.HostZone, totalDelegation sdkmath.Int) (map[string]sdkmath.Int, error)
- func (k Keeper) GetTotalTokenizedDelegations(ctx sdk.Context, hostZone types.HostZone) sdk.Dec
- func (k Keeper) GetTotalUnbondAmountAndRecordsIds(ctx sdk.Context, chainId string) (totalUnbonded sdkmath.Int, unbondingRecordIds []uint64)
- func (k Keeper) GetTotalValidatorWeight(validators []types.Validator) uint64
- func (k Keeper) GetUnbondingICAMessages(hostZone types.HostZone, totalUnbondAmount sdkmath.Int, ...) (msgs []proto.Message, unbondings []*types.SplitDelegation, err error)
- func (k Keeper) GetUndelegatedBalance(chainId string, depositRecords []recordstypes.DepositRecord) sdk.Dec
- func (k Keeper) GetUpdatedSlashQueryCheckpoint(ctx sdk.Context, totalDelegations sdkmath.Int) sdkmath.Int
- func (k Keeper) GetValidatorDelegationDifferences(ctx sdk.Context, hostZone types.HostZone) ([]RebalanceValidatorDelegationChange, error)
- func (k Keeper) GetValidatorFromLSMTokenDenom(denom string, validators []*types.Validator) (types.Validator, error)
- func (k Keeper) GetValidatorUnbondCapacity(ctx sdk.Context, validators []*types.Validator, ...) (validatorCapacities []ValidatorUnbondCapacity)
- func (k Keeper) Hooks() Hooks
- func (k Keeper) HostZone(c context.Context, req *types.QueryGetHostZoneRequest) (*types.QueryGetHostZoneResponse, error)
- func (k Keeper) HostZoneAll(c context.Context, req *types.QueryAllHostZoneRequest) (*types.QueryAllHostZoneResponse, error)
- func (k Keeper) ICQCallbackHandler() ICQCallbacks
- func (k Keeper) IncrementValidatorDelegationChangesInProgress(hostZone *types.HostZone, validatorAddress string) error
- func (k Keeper) IncrementValidatorSlashQueryProgress(ctx sdk.Context, chainId string, validatorAddress string, amount sdkmath.Int) error
- func (k Keeper) InitiateAllHostZoneUnbondings(ctx sdk.Context, dayNumber uint64)
- func (k Keeper) InterchainAccountFromAddress(goCtx context.Context, req *types.QueryInterchainAccountFromAddressRequest) (*types.QueryInterchainAccountFromAddressResponse, error)
- func (k Keeper) IsRedemptionRateWithinSafetyBounds(ctx sdk.Context, zone types.HostZone) (bool, error)
- func (k Keeper) IsUndelegateHostPrevented(ctx sdk.Context) bool
- func (k Keeper) IsWithinBufferWindow(ctx sdk.Context) (bool, error)
- func (k Keeper) IterateHostZones(ctx sdk.Context, ...)
- func (k Keeper) LSMSlashQueryCallback(ctx sdk.Context, hostZone types.HostZone, query icqtypes.Query, ...) error
- func (k Keeper) LSMSlashQueryTimeout(ctx sdk.Context, hostZone types.HostZone, query icqtypes.Query) error
- func (k Keeper) LiquidStakeRewardCollectorBalance(ctx sdk.Context, msgSvr types.MsgServer) bool
- func (k Keeper) Logger(ctx sdk.Context) log.Logger
- func (k Keeper) MarshalClaimCallbackArgs(ctx sdk.Context, claimCallback types.ClaimCallback) ([]byte, error)
- func (k Keeper) MarshalDelegateCallbackArgs(ctx sdk.Context, delegateCallback types.DelegateCallback) ([]byte, error)
- func (k Keeper) MarshalRebalanceCallbackArgs(ctx sdk.Context, rebalanceCallback types.RebalanceCallback) ([]byte, error)
- func (k Keeper) MarshalRedemptionCallbackArgs(ctx sdk.Context, redemptionCallback types.RedemptionCallback) ([]byte, error)
- func (k Keeper) MarshalReinvestCallbackArgs(ctx sdk.Context, reinvestCallback types.ReinvestCallback) ([]byte, error)
- func (k Keeper) ModuleAddress(goCtx context.Context, req *types.QueryModuleAddressRequest) (*types.QueryModuleAddressResponse, error)
- func (k Keeper) NextPacketSequence(c context.Context, req *types.QueryGetNextPacketSequenceRequest) (*types.QueryGetNextPacketSequenceResponse, error)
- func (k Keeper) Params(c context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error)
- func (k Keeper) PostRedemptionRateToOracles(ctx sdk.Context, hostDenom string, redemptionRate sdk.Dec) error
- func (k Keeper) QueryValidatorSharesToTokensRate(ctx sdk.Context, chainId string, validatorAddress string) error
- func (k Keeper) RebalanceAllHostZones(ctx sdk.Context)
- func (k Keeper) RebalanceCallback(ctx sdk.Context, packet channeltypes.Packet, ...) error
- func (k Keeper) RebalanceDelegationsForHostZone(ctx sdk.Context, chainId string) error
- func (k Keeper) RedemptionCallback(ctx sdk.Context, packet channeltypes.Packet, ...) error
- func (k Keeper) RegisterStTokenDenomsToWhitelist(ctx sdk.Context, denoms []string) error
- func (k Keeper) ReinvestCallback(ctx sdk.Context, packet channeltypes.Packet, ...) error
- func (k Keeper) ReinvestRewards(ctx sdk.Context)
- func (k Keeper) RemoveEpochTracker(ctx sdk.Context, epochIdentifier string)
- func (k Keeper) RemoveHostZone(ctx sdk.Context, chain_id string)
- func (k Keeper) RemoveValidatorFromHostZone(ctx sdk.Context, chainId string, validatorAddress string) error
- func (k Keeper) SetEpochTracker(ctx sdk.Context, epochTracker types.EpochTracker)
- func (k *Keeper) SetHooks(gh types.StakeIBCHooks) *Keeper
- func (k Keeper) SetHostZone(ctx sdk.Context, hostZone types.HostZone)
- func (k Keeper) SetParams(ctx sdk.Context, params types.Params)
- func (k Keeper) SetUndelegateHostPrevented(ctx sdk.Context) error
- func (k Keeper) SetWithdrawalAddress(ctx sdk.Context)
- func (k Keeper) SetWithdrawalAddressOnHost(ctx sdk.Context, hostZone types.HostZone) error
- func (k Keeper) ShouldCheckIfValidatorWasSlashed(ctx sdk.Context, validator types.Validator, transactionStakeAmount sdkmath.Int) bool
- func (k Keeper) SlashValidatorOnHostZone(ctx sdk.Context, hostZone types.HostZone, valIndex int64, ...) error
- func (k Keeper) StakeExistingDepositsOnHostZones(ctx sdk.Context, epochNumber uint64, ...)
- func (k Keeper) StartLSMLiquidStake(ctx sdk.Context, msg types.MsgLSMLiquidStake) (types.LSMLiquidStake, error)
- func (k Keeper) SubmitCalibrationICQ(ctx sdk.Context, hostZone types.HostZone, validatorAddress string) error
- func (k Keeper) SubmitDelegationICQ(ctx sdk.Context, hostZone types.HostZone, validatorAddress string) error
- func (k Keeper) SubmitTxs(ctx sdk.Context, connectionId string, msgs []proto.Message, ...) (uint64, error)
- func (k Keeper) SubmitTxsDayEpoch(ctx sdk.Context, connectionId string, msgs []proto.Message, ...) (uint64, error)
- func (k Keeper) SubmitTxsEpoch(ctx sdk.Context, connectionId string, msgs []proto.Message, ...) (uint64, error)
- func (k Keeper) SubmitTxsStrideEpoch(ctx sdk.Context, connectionId string, msgs []proto.Message, ...) (uint64, error)
- func (k Keeper) SubmitValidatorSharesToTokensRateICQ(ctx sdk.Context, chainId string, validatorAddress string, ...) error
- func (k Keeper) SubmitValidatorSlashQuery(ctx sdk.Context, lsmLiquidStake types.LSMLiquidStake) error
- func (k Keeper) SweepAllUnbondedTokens(ctx sdk.Context) (success bool, successfulSweeps []string, sweepAmounts []sdkmath.Int, ...)
- func (k Keeper) SweepAllUnbondedTokensForHostZone(ctx sdk.Context, hostZone types.HostZone, ...) (success bool, sweepAmount sdkmath.Int)
- func (k Keeper) SweepStTokensFromRewardCollToFeeColl(ctx sdk.Context) error
- func (k Keeper) ToggleLSMProposal(ctx sdk.Context, msg *types.ToggleLSMProposal) error
- func (k Keeper) TransferAllLSMDeposits(ctx sdk.Context)
- func (k Keeper) TransferExistingDepositsToHostZones(ctx sdk.Context, epochNumber uint64, ...)
- func (k Keeper) UnbondFromHostZone(ctx sdk.Context, hostZone types.HostZone) error
- func (k Keeper) UndelegateCallback(ctx sdk.Context, packet channeltypes.Packet, ...) error
- func (k Keeper) UndelegateHostCallback(ctx sdk.Context, packet channeltypes.Packet, ...) error
- func (k Keeper) UndelegateHostEvmos(ctx sdk.Context, totalUnbondAmount math.Int) error
- func (k Keeper) UnmarshalClaimCallbackArgs(ctx sdk.Context, claimCallback []byte) (*types.ClaimCallback, error)
- func (k Keeper) UnmarshalDelegateCallbackArgs(ctx sdk.Context, delegateCallback []byte) (*types.DelegateCallback, error)
- func (k Keeper) UnmarshalRebalanceCallbackArgs(ctx sdk.Context, rebalanceCallback []byte) (*types.RebalanceCallback, error)
- func (k Keeper) UnmarshalRedemptionCallbackArgs(ctx sdk.Context, redemptionCallback []byte) (types.RedemptionCallback, error)
- func (k Keeper) UnmarshalReinvestCallbackArgs(ctx sdk.Context, reinvestCallback []byte) (*types.ReinvestCallback, error)
- func (k Keeper) UpdateDelegationBalances(ctx sdk.Context, hostZone types.HostZone, ...) error
- func (k Keeper) UpdateDelegationBalancesHost(ctx sdk.Context, hostZone types.HostZone, ...) error
- func (k Keeper) UpdateEpochTracker(ctx sdk.Context, epochInfo epochstypes.EpochInfo) (epochNumber uint64, err error)
- func (k Keeper) UpdateHostZoneUnbondings(ctx sdk.Context, latestCompletionTime time.Time, chainId string, ...) (stTokenBurnAmount sdkmath.Int, err error)
- func (k Keeper) UpdateRedemptionRateForHostZone(ctx sdk.Context, hostZone types.HostZone, ...)
- func (k Keeper) UpdateRedemptionRates(ctx sdk.Context, depositRecords []recordstypes.DepositRecord)
- func (k Keeper) UpdateWithdrawalBalance(ctx sdk.Context, hostZone types.HostZone) error
- func (k Keeper) ValidateLSMLiquidStake(ctx sdk.Context, msg types.MsgLSMLiquidStake) (types.LSMLiquidStake, error)
- func (k Keeper) Validators(c context.Context, req *types.QueryGetValidatorsRequest) (*types.QueryGetValidatorsResponse, error)
- type RebalanceValidatorDelegationChange
- type ValidatorUnbondCapacity
Constants ¶
const ( ICACallbackID_Delegate = "delegate" ICACallbackID_Claim = "claim" ICACallbackID_Undelegate = "undelegate" ICACallbackID_UndelegateHost = "undelegatehost" ICACallbackID_Reinvest = "reinvest" ICACallbackID_Redemption = "redemption" ICACallbackID_Rebalance = "rebalance" ICACallbackID_Detokenize = "detokenize" )
const ( ICQCallbackID_WithdrawalBalance = "withdrawalbalance" ICQCallbackID_FeeBalance = "feebalance" ICQCallbackID_Delegation = "delegation" ICQCallbackID_Validator = "validator" ICQCallbackID_Calibrate = "calibrate" )
const ( MaxNumTokensUnbondableStr = "2500000000000000000000000" // 2,500,000e18 EvmosHostZoneChainId = "evmos_9001-2" )
const RebalanceIcaBatchSize = 5
const StrideEpochsPerDayEpoch = uint64(4)
const (
UndelegateICABatchSize = 32
)
Variables ¶
var ( // A valid IBC path for the LSM token must only consist of 1 channel hop along a transfer channel // (e.g. "transfer/channel-0") IsValidIBCPath = regexp.MustCompile(fmt.Sprintf(`^%s/(%s[0-9]{1,20})$`, transfertypes.PortID, channeltypes.ChannelPrefix)).MatchString // Timeout for the validator slash query that occurs at periodic deposit intervals LSMSlashQueryTimeout = time.Minute * 5 // 5 minutes // Time for the detokenization ICA DetokenizationTimeout = time.Hour * 24 // 1 day )
Functions ¶
func AllInvariants ¶
AllInvariants runs all invariants of the stakeibc module
func CalibrateDelegationCallback ¶
func CalibrateDelegationCallback(k Keeper, ctx sdk.Context, args []byte, query icqtypes.Query) error
DelegatorSharesCallback is a callback handler for UpdateValidatorSharesExchRate queries.
In an attempt to get the ICA's delegation amount on a given validator, we have to query:
- the validator's internal shares to tokens rate
- the Delegation ICA's delegated shares And apply the following equation: numTokens = numShares * sharesToTokensRate
This is the callback from query #2
Note: for now, to get proofs in your ICQs, you need to query the entire store on the host zone! e.g. "store/bank/key"
func DelegatorSharesCallback ¶
DelegatorSharesCallback is a callback handler for UpdateValidatorSharesExchRate queries.
In an attempt to get the ICA's delegation amount on a given validator, we have to query:
- the validator's internal shares to tokens rate
- the Delegation ICA's delegated shares And apply the following equation: numTokens = numShares * sharesToTokensRate
This is the callback from query #2
Note: for now, to get proofs in your ICQs, you need to query the entire store on the host zone! e.g. "store/bank/key"
func EmitFailedLSMLiquidStakeEvent ¶
func EmitFailedLSMLiquidStakeEvent(ctx sdk.Context, hostZone types.HostZone, lsmTokenDeposit recordstypes.LSMTokenDeposit, errorMessage string)
Emits a failed LSM liquid stake event, and displays the error
func EmitPendingLSMLiquidStakeEvent ¶
func EmitPendingLSMLiquidStakeEvent(ctx sdk.Context, hostZone types.HostZone, lsmTokenDeposit recordstypes.LSMTokenDeposit)
Emits a pending LSM liquid stake event, meaning a slash query was submitted
func EmitSuccessfulLSMLiquidStakeEvent ¶
func EmitSuccessfulLSMLiquidStakeEvent(ctx sdk.Context, hostZone types.HostZone, lsmTokenDeposit recordstypes.LSMTokenDeposit)
Emits a successful LSM liquid stake event, and displays metadata such as the stToken amount
func EmitSuccessfulLiquidStakeEvent ¶
func EmitSuccessfulLiquidStakeEvent(ctx sdk.Context, msg *types.MsgLiquidStake, hostZone types.HostZone, stAmount sdkmath.Int)
Emits a successful liquid stake event, and displays metadata such as the stToken amount
func EmitUndelegationEvent ¶
Emits an event if an undelegation ICA was submitted for a host zone
func EmitValidatorSharesToTokensRateChangeEvent ¶
func EmitValidatorSharesToTokensRateChangeEvent( ctx sdk.Context, chainId string, validatorAddress string, previousSharesToTokensRate, currentSharesToTokensRate sdk.Dec, )
Emits an event if a validator's shares to tokens rate changed
func EmitValidatorSlashEvent ¶
func EmitValidatorSlashEvent( ctx sdk.Context, hostZone types.HostZone, validatorAddress string, slashPercent sdk.Dec, slashAmount sdkmath.Int, currentDelegation sdkmath.Int, )
Emits an event if a validator was slashed
func FeeBalanceCallback ¶
FeeBalanceCallback is a callback handler for FeeBalnce queries. The query response will return the fee account balance If the balance is non-zero, an ICA MsgTransfer is initated to the RewardsCollector account Note: for now, to get proofs in your ICQs, you need to query the entire store on the host zone! e.g. "store/bank/key"
func GetLSMTokenDepositId ¶
Generates a unique ID for the LSM token deposit so that, if a slash query is issued, the query callback can be joined back with this tx The key in the store for an LSMTokenDeposit is chainId + denom (meaning, there can only be 1 LSMLiquidStake in progress per tokenization)
func GetValidatorFromAddress ¶
func GetValidatorFromAddress(validators []*types.Validator, address string) (val types.Validator, index int64, found bool)
Get a validator and its index from a list of validators, by address
func NewMsgServerImpl ¶
NewMsgServerImpl returns an implementation of the MsgServer interface for the provided Keeper.
func RegisterInvariants ¶
func RegisterInvariants(ir sdk.InvariantRegistry, k Keeper)
RegisterInvariants registers all governance invariants.
func ValidatorSharesToTokensRateCallback ¶
func ValidatorSharesToTokensRateCallback(k Keeper, ctx sdk.Context, args []byte, query icqtypes.Query) error
ValidatorCallback is a callback handler for validator queries.
In an attempt to get the ICA's delegation amount on a given validator, we have to query:
- the validator's internal sharesToTokens rate
- the Delegation ICA's delegated shares And apply the following equation: numTokens = numShares * sharesToTokensRate
This is the callback from query #1 We only issue query #2 if the validator sharesToTokens rate from #1 has changed (indicating a slash)
func WithdrawalBalanceCallback ¶
WithdrawalBalanceCallback is a callback handler for WithdrawalBalance queries. The query response will return the withdrawal account balance If the balance is non-zero, ICA MsgSends are submitted to transfer from the withdrawal account to the delegation account (for reinvestment) and fee account (for commission)
Note: for now, to get proofs in your ICQs, you need to query the entire store on the host zone! e.g. "store/bank/key"
Types ¶
type Hooks ¶
type Hooks struct {
// contains filtered or unexported fields
}
Hooks wrapper struct for incentives keeper
func (Hooks) AfterEpochEnd ¶
func (h Hooks) AfterEpochEnd(ctx sdk.Context, epochInfo epochstypes.EpochInfo)
func (Hooks) BeforeEpochStart ¶
func (h Hooks) BeforeEpochStart(ctx sdk.Context, epochInfo epochstypes.EpochInfo)
epochs hooks
type ICQCallback ¶
ICQCallbacks wrapper struct for stakeibc keeper
type ICQCallbacks ¶
type ICQCallbacks struct {
// contains filtered or unexported fields
}
func (ICQCallbacks) AddICQCallback ¶
func (c ICQCallbacks) AddICQCallback(id string, fn interface{}) icqtypes.QueryCallbacks
func (ICQCallbacks) CallICQCallback ¶
func (ICQCallbacks) HasICQCallback ¶
func (c ICQCallbacks) HasICQCallback(id string) bool
func (ICQCallbacks) RegisterICQCallbacks ¶
func (c ICQCallbacks) RegisterICQCallbacks() icqtypes.QueryCallbacks
type Keeper ¶
type Keeper struct { ICAControllerKeeper icacontrollerkeeper.Keeper IBCKeeper ibckeeper.Keeper AccountKeeper types.AccountKeeper InterchainQueryKeeper icqkeeper.Keeper RecordsKeeper recordsmodulekeeper.Keeper StakingKeeper stakingkeeper.Keeper ICACallbacksKeeper icacallbackskeeper.Keeper RatelimitKeeper types.RatelimitKeeper ICAOracleKeeper types.ICAOracleKeeper ConsumerKeeper types.ConsumerKeeper // contains filtered or unexported fields }
func NewKeeper ¶
func NewKeeper( cdc codec.BinaryCodec, storeKey, memKey storetypes.StoreKey, ps paramtypes.Subspace, accountKeeper types.AccountKeeper, bankKeeper bankkeeper.Keeper, icacontrollerkeeper icacontrollerkeeper.Keeper, ibcKeeper ibckeeper.Keeper, interchainQueryKeeper icqkeeper.Keeper, RecordsKeeper recordsmodulekeeper.Keeper, StakingKeeper stakingkeeper.Keeper, ICACallbacksKeeper icacallbackskeeper.Keeper, RatelimitKeeper types.RatelimitKeeper, icaOracleKeeper types.ICAOracleKeeper, ConsumerKeeper types.ConsumerKeeper, ) Keeper
func (Keeper) AddDelegationToValidator ¶
func (k Keeper) AddDelegationToValidator( ctx sdk.Context, hostZone *types.HostZone, validatorAddress string, amount sdkmath.Int, callbackId string, ) error
Updates a validator's individual delegation, and the corresponding total delegation on the host zone Note: This modifies the original host zone struct. The calling function must Set this host zone for changes to persist
func (Keeper) AddValidatorToHostZone ¶
func (k Keeper) AddValidatorToHostZone(ctx sdk.Context, chainId string, validator types.Validator, fromGovernance bool) error
Appends a validator to host zone (if the host zone is not already at capacity) If the validator is added through governance, the weight is equal to the minimum weight across the set If the validator is added through an admin transactions, the weight is specified in the message
func (Keeper) AddValidatorsProposal ¶
func (Keeper) AddressUnbondings ¶
func (k Keeper) AddressUnbondings(c context.Context, req *types.QueryAddressUnbondings) (*types.QueryAddressUnbondingsResponse, error)
func (Keeper) AfterEpochEnd ¶
func (k Keeper) AfterEpochEnd(ctx sdk.Context, epochInfo epochstypes.EpochInfo)
func (Keeper) AllocateHostZoneReward ¶
(1) liquid stake reward collector balance, then (2) sweet stTokens from reward collector to fee collector
func (Keeper) AssertStrideAndDayEpochRelationship ¶
TODO: Consider removing stride and day epochs completely and using a single hourly epoch Confirm the number of stride epochs in 1 day epoch
func (Keeper) BeforeEpochStart ¶
func (k Keeper) BeforeEpochStart(ctx sdk.Context, epochInfo epochstypes.EpochInfo)
func (Keeper) BeginBlocker ¶
BeginBlocker of stakeibc module
func (Keeper) BurnTokens ¶
func (k Keeper) BurnTokens(ctx sdk.Context, hostZone types.HostZone, stTokenBurnAmount sdkmath.Int) error
Burn stTokens after they've been unbonded
func (Keeper) CalculateLSMStToken ¶
func (k Keeper) CalculateLSMStToken(liquidStakedShares sdkmath.Int, lsmLiquidStake types.LSMLiquidStake) sdk.Coin
Given an LSMToken representing a number of delegator shares, returns the stToken coin using the validator's sharesToTokens rate and the host zone redemption rate
StTokens = LSMTokenShares * Validator SharesToTokens Rate / Redemption Rate
Note: in the event of a slash query, these tokens will be minted only if the validator's sharesToTokens rate did not change
func (Keeper) Callbacks ¶
func (k Keeper) Callbacks() icacallbackstypes.ModuleCallbacks
func (Keeper) CheckDelegationChangedDuringQuery ¶
func (k Keeper) CheckDelegationChangedDuringQuery( ctx sdk.Context, validator types.Validator, previousInternalDelegation sdkmath.Int, currentInternalDelegation sdkmath.Int, ) (overlapped bool, err error)
The number of tokens returned from the query must be consistent with the tokens stored in our internal record keeping during this callback, otherwise the comparision between the two is invalidated
As a result, we must avoid a race condition between the ICQ and a delegate, undelegate, redelegate, or detokenization ICA
More specifically, we must avoid the following cases:
Case 1) ICQ Lands on Host ICQ Ack on Stride ICA Lands on Host ICA Ack on Stride Case 2) ICA Lands on Host ICA Ack on Stride ICQ Lands on Host ICQ Ack on Stride
We can prevent Case #1 by checking if the delegation total on the validator has changed while the query was in flight
We can prevent Case #2 by checking if the validator has a delegation change in progress
func (Keeper) CheckForSlash ¶
func (k Keeper) CheckForSlash( ctx sdk.Context, hostZone types.HostZone, valIndex int64, queriedDelegation stakingtypes.Delegation, ) (validatorWasSlashed bool, delegatedTokens sdkmath.Int, err error)
Check if a slash occured by comparing the validator's sharesToTokens rate and delegator shares from the query responses (tokens = shares * sharesToTokensRate)
If the change in delegation only differs by a small precision error, it was likely due to an decimal -> int truncation that occurs during unbonding. In this case, still update the validator
If the change in delegation was an increase, the response can't be trusted so an error is thrown
func (Keeper) CheckIfValidatorWasSlashed ¶
func (k Keeper) CheckIfValidatorWasSlashed( ctx sdk.Context, hostZone types.HostZone, queriedValidator stakingtypes.Validator, ) (validatorWasSlashed bool, err error)
Determines if the validator was slashed by comparing the validator sharesToTokens rate from the query response with the sharesToTokens rate stored on the validator
func (Keeper) CheckIsStToken ¶
Validate whether a denom is a supported liquid staking token
func (Keeper) ClaimCallback ¶
func (k Keeper) ClaimCallback(ctx sdk.Context, packet channeltypes.Packet, ackResponse *icacallbackstypes.AcknowledgementResponse, args []byte) error
ICA Callback after claiming unbonded tokens * If successful: Removes the user redemption record * If timeout/failure: Reverts pending flag in the user redemption record so the claim can be re-tried
func (Keeper) CleanupEpochUnbondingRecords ¶
Deletes any epoch unbonding records that have had all unbondings claimed
func (Keeper) CreateDepositRecordsForEpoch ¶
Create a new deposit record for each host zone for the given epoch
func (Keeper) CreateEpochUnbondingRecord ¶
Creates a new epoch unbonding record for the epoch
func (Keeper) DecrementHostZoneUnbonding ¶
func (k Keeper) DecrementHostZoneUnbonding(ctx sdk.Context, userRedemptionRecord recordstypes.UserRedemptionRecord, callbackArgs types.ClaimCallback) error
After a user claims their unbonded tokens, the claim amount is decremented from the corresponding host zone unbonding record
func (Keeper) DecrementValidatorDelegationChangesInProgress ¶
func (k Keeper) DecrementValidatorDelegationChangesInProgress(hostZone *types.HostZone, validatorAddress string) error
Decrements the number of validator delegation changes in progress by 1 Note: This modifies the original host zone struct. The calling function must Set this host zone for changes to persist
func (Keeper) DelegateCallback ¶
func (k Keeper) DelegateCallback(ctx sdk.Context, packet channeltypes.Packet, ackResponse *icacallbackstypes.AcknowledgementResponse, args []byte) error
ICA Callback after delegating deposit records * If successful: Updates deposit record status and records delegation changes on the host zone and validators * If timeout: Does nothing * If failure: Reverts deposit record status
func (Keeper) DelegateOnHost ¶
func (k Keeper) DelegateOnHost(ctx sdk.Context, hostZone types.HostZone, amt sdk.Coin, depositRecord recordstypes.DepositRecord) error
func (Keeper) DetokenizeAllLSMDeposits ¶
Loops through all active host zones, grabs the queued LSMTokenDeposits for that host that are in status DETOKENIZATION_QUEUE, and submits the detokenization ICA for each
func (Keeper) DetokenizeCallback ¶
func (k Keeper) DetokenizeCallback(ctx sdk.Context, packet channeltypes.Packet, ackResponse *icacallbackstypes.AcknowledgementResponse, args []byte) error
ICACallback after an LSM token is detokenized into native stake
If successful: Remove the token deposit from the store and incremenet the validator delegation If failure: flag the deposit as DETOKENIZATION_FAILED If timeout: do nothing - A timeout will force the channel closed, and once the channel is restored, the ICA will get resubmitted
func (Keeper) DetokenizeLSMDeposit ¶
func (k Keeper) DetokenizeLSMDeposit(ctx sdk.Context, hostZone types.HostZone, deposit recordstypes.LSMTokenDeposit) error
Submits an ICA to "Redeem" an LSM Token - meaning converting the token into native stake This function is called in the EndBlocker which means if the ICA submission fails, any modified state is not reverted
The deposit Status is intentionally updated before the ICA is submitted even though it will NOT be reverted if the ICA fails to send. This is because a failure is likely caused by a closed ICA channel, and the status update will prevent the ICA from being continuously re-submitted. When the ICA channel is restored, the deposit status will get reset, and the ICA will be attempted again.
func (Keeper) EndBlocker ¶
func (Keeper) EpochTracker ¶
func (k Keeper) EpochTracker(c context.Context, req *types.QueryGetEpochTrackerRequest) (*types.QueryGetEpochTrackerResponse, error)
func (Keeper) EpochTrackerAll ¶
func (k Keeper) EpochTrackerAll(c context.Context, req *types.QueryAllEpochTrackerRequest) (*types.QueryAllEpochTrackerResponse, error)
func (Keeper) FailLSMLiquidStake ¶
func (k Keeper) FailLSMLiquidStake(ctx sdk.Context, hostZone types.HostZone, lsmLiquidStake types.LSMLiquidStake, errorMessage string)
Fail an LSMLiquidStake transaction by emitting an event and removing the LSMTokenDeposit record
func (Keeper) FinishLSMLiquidStake ¶
func (k Keeper) FinishLSMLiquidStake(ctx sdk.Context, lsmLiquidStake types.LSMLiquidStake, async bool) error
FinishLSMLiquidStake finishes the liquid staking flow by escrowing the LSM token, sending a user their stToken, and then IBC transfering the LSM Token to the host zone
If the slash query interrupted the transaction, this function is called asynchronously after the query callback
If no slash query was needed, this is called synchronously after StartLSMLiquidStake If this is run asynchronously, we need to re-validate the transaction info (e.g. staker's balance)
func (Keeper) GetAllActiveHostZone ¶
GetAllActiveHostZone returns all hostZones that are active (halted = false)
func (Keeper) GetAllEpochTracker ¶
func (k Keeper) GetAllEpochTracker(ctx sdk.Context) (list []types.EpochTracker)
GetAllEpochTracker returns all epochTracker
func (Keeper) GetAllHostZone ¶
GetAllHostZone returns all hostZone
func (Keeper) GetChainID ¶
func (Keeper) GetClaimableRedemptionRecord ¶
func (k Keeper) GetClaimableRedemptionRecord(ctx sdk.Context, msg *types.MsgClaimUndelegatedTokens) (*recordstypes.UserRedemptionRecord, error)
func (Keeper) GetConnectionId ¶
func (Keeper) GetCounterpartyChainId ¶
func (Keeper) GetDepositAccountBalance ¶
func (k Keeper) GetDepositAccountBalance(chainId string, depositRecords []recordstypes.DepositRecord) sdk.Dec
Determine the deposit account balance, representing native tokens that have been deposited from liquid stakes, but have not yet been transferred to the host
func (Keeper) GetEpochTracker ¶
func (k Keeper) GetEpochTracker( ctx sdk.Context, epochIdentifier string, ) (val types.EpochTracker, found bool)
GetEpochTracker returns a epochTracker from its index
func (Keeper) GetHostZone ¶
GetHostZone returns a hostZone from its id
func (Keeper) GetHostZoneFromHostDenom ¶
GetHostZoneFromHostDenom returns a HostZone from a HostDenom
func (Keeper) GetHostZoneFromIBCDenom ¶
GetHostZoneFromIBCDenom returns a HostZone from a IBCDenom
func (Keeper) GetHostZoneFromLSMTokenPath ¶
Parses the LSM token's IBC path (e.g. transfer/channel-0) and confirms the channel ID matches the transfer channel of a supported host zone
func (Keeper) GetHostZoneFromTransferChannelID ¶
func (k Keeper) GetHostZoneFromTransferChannelID(ctx sdk.Context, channelID string) (hostZone types.HostZone, found bool)
GetHostZoneFromTransferChannelID returns a HostZone from a transfer channel ID
func (Keeper) GetICATimeoutNanos ¶
func (Keeper) GetInnerSafetyBounds ¶
func (Keeper) GetLSMTokenDenomTrace ¶
func (k Keeper) GetLSMTokenDenomTrace(ctx sdk.Context, denom string) (transfertypes.DenomTrace, error)
Parse the LSM Token's IBC denom hash into a DenomTrace object that contains the path and base denom
func (Keeper) GetLatestCompletionTime ¶
Get the latest completion time across each MsgUndelegate in the ICA transaction The time is used to set the
func (Keeper) GetLightClientHeightSafely ¶
func (Keeper) GetLightClientTimeSafely ¶
func (Keeper) GetOuterSafetyBounds ¶
func (Keeper) GetRebalanceICAMessages ¶
func (k Keeper) GetRebalanceICAMessages( hostZone types.HostZone, validatorDeltas []RebalanceValidatorDelegationChange, ) (msgs []proto.Message, rebalancings []*types.Rebalancing)
Given a list of target delegation changes, builds the individual re-delegation messages by redelegating from surplus validators to deficit validators Returns the list of messages and the callback data for the ICA
func (Keeper) GetRedemptionTransferMsg ¶
func (k Keeper) GetRedemptionTransferMsg(ctx sdk.Context, userRedemptionRecord *recordstypes.UserRedemptionRecord, hostZoneId string) (*IcaTx, error)
func (Keeper) GetStartTimeNextEpoch ¶
helper to get time at which next epoch begins, in unix nano units
func (Keeper) GetStrideEpochElapsedShare ¶
helper to get what share of the curr epoch we're through
func (Keeper) GetTargetValAmtsForHostZone ¶
func (k Keeper) GetTargetValAmtsForHostZone(ctx sdk.Context, hostZone types.HostZone, totalDelegation sdkmath.Int) (map[string]sdkmath.Int, error)
This will split a total delegation amount across validators, according to weights It returns a map of each portion, key'd on validator address Validator's with a slash query in progress are excluded
func (Keeper) GetTotalTokenizedDelegations ¶
Returns the total delegated balance that's stored in LSM tokens This is used for the redemption rate calculation
The relevant tokens are identified by the deposit records in status "DEPOSIT_PENDING" "DEPOSIT_PENDING" means the liquid staker's tokens have not been sent to Stride yet so they should *not* be included in the redemption rate. All other statuses indicate the LSM tokens have been deposited and should be included in the final calculation
Each LSM token represents a delegator share so the validator's shares to tokens rate must be used to denominate it's value in native tokens
func (Keeper) GetTotalUnbondAmountAndRecordsIds ¶
func (k Keeper) GetTotalUnbondAmountAndRecordsIds(ctx sdk.Context, chainId string) (totalUnbonded sdkmath.Int, unbondingRecordIds []uint64)
Gets the total unbonded amount for a host zone by looping through the epoch unbonding records Also returns the epoch unbonding record ids
func (Keeper) GetTotalValidatorWeight ¶
Sum the total weights across each validator for a host zone
func (Keeper) GetUnbondingICAMessages ¶
func (k Keeper) GetUnbondingICAMessages( hostZone types.HostZone, totalUnbondAmount sdkmath.Int, prioritizedUnbondCapacity []ValidatorUnbondCapacity, ) (msgs []proto.Message, unbondings []*types.SplitDelegation, err error)
Given a total unbond amount and list of unbond capacity for each validator, sorted by unbond priority Iterates through the list and unbonds as much as possible from each validator until all the unbonding has been accounted for
Returns the list of messages and the callback data for the ICA
func (Keeper) GetUndelegatedBalance ¶
func (k Keeper) GetUndelegatedBalance(chainId string, depositRecords []recordstypes.DepositRecord) sdk.Dec
Determine the undelegated balance from the deposit records queued for staking
func (Keeper) GetUpdatedSlashQueryCheckpoint ¶
func (k Keeper) GetUpdatedSlashQueryCheckpoint(ctx sdk.Context, totalDelegations sdkmath.Int) sdkmath.Int
Determines the new slash query checkpoint, by mulitplying the query threshold percent by the current TVL
func (Keeper) GetValidatorDelegationDifferences ¶
func (k Keeper) GetValidatorDelegationDifferences(ctx sdk.Context, hostZone types.HostZone) ([]RebalanceValidatorDelegationChange, error)
This function returns a list with the number of extra tokens that should be sent to each validator
- Positive delta implies the validator has a surplus (and should lose stake)
- Negative delta implies the validator has a deficit (and should gain stake)
func (Keeper) GetValidatorFromLSMTokenDenom ¶
func (k Keeper) GetValidatorFromLSMTokenDenom(denom string, validators []*types.Validator) (types.Validator, error)
Parses the LSM token's denom (of the form {validatorAddress}/{recordId}) and confirms that the validator is in the Stride validator set and does not have an active slash query
func (Keeper) GetValidatorUnbondCapacity ¶
func (k Keeper) GetValidatorUnbondCapacity( ctx sdk.Context, validators []*types.Validator, balancedDelegation map[string]sdkmath.Int, ) (validatorCapacities []ValidatorUnbondCapacity)
Determine the unbonding capacity that each validator has The capacity is determined by the difference between their current delegation and their fair portion of the total stake based on their weights (i.e. their balanced delegation)
Validators with a balanced delegation less than their current delegation are already at a deficit, are not included in the returned list, and thus, will not incur any unbonding
func (Keeper) HostZone ¶
func (k Keeper) HostZone(c context.Context, req *types.QueryGetHostZoneRequest) (*types.QueryGetHostZoneResponse, error)
func (Keeper) HostZoneAll ¶
func (k Keeper) HostZoneAll(c context.Context, req *types.QueryAllHostZoneRequest) (*types.QueryAllHostZoneResponse, error)
func (Keeper) ICQCallbackHandler ¶
func (k Keeper) ICQCallbackHandler() ICQCallbacks
func (Keeper) IncrementValidatorDelegationChangesInProgress ¶
func (k Keeper) IncrementValidatorDelegationChangesInProgress(hostZone *types.HostZone, validatorAddress string) error
Increments the number of validator delegation changes in progress by 1 Note: This modifies the original host zone struct. The calling function must Set this host zone for changes to persist
func (Keeper) IncrementValidatorSlashQueryProgress ¶
func (k Keeper) IncrementValidatorSlashQueryProgress( ctx sdk.Context, chainId string, validatorAddress string, amount sdkmath.Int, ) error
Increments the validators slash query progress tracker
func (Keeper) InitiateAllHostZoneUnbondings ¶
this function iterates each host zone, and if it's the right time to initiate an unbonding, it attempts to unbond all outstanding records
func (Keeper) InterchainAccountFromAddress ¶
func (k Keeper) InterchainAccountFromAddress(goCtx context.Context, req *types.QueryInterchainAccountFromAddressRequest) (*types.QueryInterchainAccountFromAddressResponse, error)
InterchainAccountFromAddress implements the Query/InterchainAccountFromAddress gRPC method
func (Keeper) IsRedemptionRateWithinSafetyBounds ¶
func (k Keeper) IsRedemptionRateWithinSafetyBounds(ctx sdk.Context, zone types.HostZone) (bool, error)
safety check: ensure the redemption rate is NOT below our min safety threshold && NOT above our max safety threshold on host zone
func (Keeper) IsUndelegateHostPrevented ¶
func (Keeper) IsWithinBufferWindow ¶
helper to check whether ICQs are valid in this portion of the epoch
func (Keeper) IterateHostZones ¶
func (k Keeper) IterateHostZones(ctx sdk.Context, fn func(ctx sdk.Context, index int64, zoneInfo types.HostZone) error)
IterateHostZones iterates zones
func (Keeper) LSMSlashQueryCallback ¶
func (k Keeper) LSMSlashQueryCallback( ctx sdk.Context, hostZone types.HostZone, query icqtypes.Query, validatorWasSlashed bool, ) error
Callback handler for if the slash query was initiated by an LSMLiquidStake transaction If the validator was slashed, the LSMLiquidStake should be rejected If the validator was not slashed, the LSMLiquidStake should finish to mint the user stTokens
func (Keeper) LSMSlashQueryTimeout ¶
func (k Keeper) LSMSlashQueryTimeout(ctx sdk.Context, hostZone types.HostZone, query icqtypes.Query) error
Fails the LSM Liquid Stake if the query timed out
func (Keeper) LiquidStakeRewardCollectorBalance ¶
Liquid Stake Reward Collector Balance
func (Keeper) MarshalClaimCallbackArgs ¶
func (k Keeper) MarshalClaimCallbackArgs(ctx sdk.Context, claimCallback types.ClaimCallback) ([]byte, error)
Marshal claim callback args
func (Keeper) MarshalDelegateCallbackArgs ¶
func (k Keeper) MarshalDelegateCallbackArgs(ctx sdk.Context, delegateCallback types.DelegateCallback) ([]byte, error)
Marshalls delegate callback arguments
func (Keeper) MarshalRebalanceCallbackArgs ¶
func (k Keeper) MarshalRebalanceCallbackArgs(ctx sdk.Context, rebalanceCallback types.RebalanceCallback) ([]byte, error)
Marshalls rebalance callback arguments
func (Keeper) MarshalRedemptionCallbackArgs ¶
func (k Keeper) MarshalRedemptionCallbackArgs(ctx sdk.Context, redemptionCallback types.RedemptionCallback) ([]byte, error)
Marshalls redemption callback arguments
func (Keeper) MarshalReinvestCallbackArgs ¶
func (k Keeper) MarshalReinvestCallbackArgs(ctx sdk.Context, reinvestCallback types.ReinvestCallback) ([]byte, error)
Marshalls reinvest callback arguments
func (Keeper) ModuleAddress ¶
func (k Keeper) ModuleAddress(goCtx context.Context, req *types.QueryModuleAddressRequest) (*types.QueryModuleAddressResponse, error)
func (Keeper) NextPacketSequence ¶
func (k Keeper) NextPacketSequence(c context.Context, req *types.QueryGetNextPacketSequenceRequest) (*types.QueryGetNextPacketSequenceResponse, error)
func (Keeper) Params ¶
func (k Keeper) Params(c context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error)
func (Keeper) PostRedemptionRateToOracles ¶
func (k Keeper) PostRedemptionRateToOracles(ctx sdk.Context, hostDenom string, redemptionRate sdk.Dec) error
Pushes a redemption rate update to the ICA oracle
func (Keeper) QueryValidatorSharesToTokensRate ¶
func (k Keeper) QueryValidatorSharesToTokensRate(ctx sdk.Context, chainId string, validatorAddress string) error
Submit a validator sharesToTokens rate ICQ as triggered either manually or epochly with a conservative timeout
func (Keeper) RebalanceAllHostZones ¶
Iterate each active host zone and issues redelegation messages to rebalance each validator's stake according to their weights
This is required when accepting LSM LiquidStakes as the distribution of stake from the LSM Tokens will be inconsistend with the host zone's validator set
Note: this cannot be run more than once in a single unbonding period
func (Keeper) RebalanceCallback ¶
func (k Keeper) RebalanceCallback(ctx sdk.Context, packet channeltypes.Packet, ackResponse *icacallbackstypes.AcknowledgementResponse, args []byte) error
ICA Callback after rebalance validators on a host zone * If successful: Updates relevant validator delegations on the host zone struct * If timeout/failure: Does nothing
func (Keeper) RebalanceDelegationsForHostZone ¶
Rebalance validators according to their validator weights for a specific host zone
func (Keeper) RedemptionCallback ¶
func (k Keeper) RedemptionCallback(ctx sdk.Context, packet channeltypes.Packet, ackResponse *icacallbackstypes.AcknowledgementResponse, args []byte) error
ICA Callback after undelegating * If successful: Updates epoch unbonding record status * If timeout: Does nothing * If failure: Reverts epoch unbonding record status
func (Keeper) RegisterStTokenDenomsToWhitelist ¶
Register new stTokens to the consumer reward denom whitelist
func (Keeper) ReinvestCallback ¶
func (k Keeper) ReinvestCallback(ctx sdk.Context, packet channeltypes.Packet, ackResponse *icacallbackstypes.AcknowledgementResponse, args []byte) error
ICA Callback after reinvestment
If successful: * Creates a new DepositRecord with the reinvestment amount * Issues an ICQ to query the rewards balance If timeout/failure: * Does nothing
func (Keeper) ReinvestRewards ¶
func (Keeper) RemoveEpochTracker ¶
RemoveEpochTracker removes a epochTracker from the store
func (Keeper) RemoveHostZone ¶
RemoveHostZone removes a hostZone from the store
func (Keeper) RemoveValidatorFromHostZone ¶
func (k Keeper) RemoveValidatorFromHostZone(ctx sdk.Context, chainId string, validatorAddress string) error
Removes a validator from a host zone The validator must be zero-weight and have no delegations in order to be removed There must also be no LSMTokenDeposits in progress since this would update the delegation on completion
func (Keeper) SetEpochTracker ¶
func (k Keeper) SetEpochTracker(ctx sdk.Context, epochTracker types.EpochTracker)
SetEpochTracker set a specific epochTracker in the store from its index
func (*Keeper) SetHooks ¶
func (k *Keeper) SetHooks(gh types.StakeIBCHooks) *Keeper
SetHooks sets the hooks for ibc staking
func (Keeper) SetHostZone ¶
SetHostZone set a specific hostZone in the store
func (Keeper) SetUndelegateHostPrevented ¶
func (Keeper) SetWithdrawalAddress ¶
Set the withdrawal account address for each host zone
func (Keeper) SetWithdrawalAddressOnHost ¶
func (Keeper) ShouldCheckIfValidatorWasSlashed ¶
func (k Keeper) ShouldCheckIfValidatorWasSlashed( ctx sdk.Context, validator types.Validator, transactionStakeAmount sdkmath.Int, ) bool
Checks if we need to issue an ICQ to check if a validator was slashed The query runs at periodic intervals defined by the ValidatorSlashQueryInterval The interval is represented as percent of TVL (e.g. 1% means every LS that causes the progress to breach 1% of TVL triggers the query)
func (Keeper) SlashValidatorOnHostZone ¶
func (k Keeper) SlashValidatorOnHostZone(ctx sdk.Context, hostZone types.HostZone, valIndex int64, delegatedTokens sdkmath.Int) error
Update the accounting on the host zone and validator to record the slash NOTE: we assume any decrease in delegation amt that's not tracked via records is a slash
func (Keeper) StakeExistingDepositsOnHostZones ¶
func (k Keeper) StakeExistingDepositsOnHostZones(ctx sdk.Context, epochNumber uint64, depositRecords []recordstypes.DepositRecord)
Iterate each deposit record marked DELEGATION_QUEUE and use the delegation ICA to delegate on the host zone
func (Keeper) StartLSMLiquidStake ¶
func (k Keeper) StartLSMLiquidStake(ctx sdk.Context, msg types.MsgLSMLiquidStake) (types.LSMLiquidStake, error)
StartLSMLiquidStake runs the transactional logic that occurs before the optional query This includes validation on the LSM Token and the stToken amount calculation
func (Keeper) SubmitCalibrationICQ ¶
func (k Keeper) SubmitCalibrationICQ(ctx sdk.Context, hostZone types.HostZone, validatorAddress string) error
Submits an ICQ to get a validator's delegations This is called after the validator's sharesToTokens rate is determined The timeoutDuration parameter represents the length of the timeout (not to be confused with an actual timestamp)
func (Keeper) SubmitDelegationICQ ¶
func (k Keeper) SubmitDelegationICQ(ctx sdk.Context, hostZone types.HostZone, validatorAddress string) error
Submits an ICQ to get a validator's delegations This is called after the validator's sharesToTokens rate is determined The timeoutDuration parameter represents the length of the timeout (not to be confused with an actual timestamp)
func (Keeper) SubmitTxs ¶
func (k Keeper) SubmitTxs( ctx sdk.Context, connectionId string, msgs []proto.Message, icaAccountType types.ICAAccountType, timeoutTimestamp uint64, callbackId string, callbackArgs []byte, ) (uint64, error)
SubmitTxs submits an ICA transaction containing multiple messages
func (Keeper) SubmitTxsDayEpoch ¶
func (Keeper) SubmitTxsEpoch ¶
func (Keeper) SubmitTxsStrideEpoch ¶
func (Keeper) SubmitValidatorSharesToTokensRateICQ ¶
func (k Keeper) SubmitValidatorSharesToTokensRateICQ( ctx sdk.Context, chainId string, validatorAddress string, callbackDataBz []byte, timeoutDuration time.Duration, timeoutPolicy icqtypes.TimeoutPolicy, ) error
Submits an ICQ to get a validator's shares to tokens rate
func (Keeper) SubmitValidatorSlashQuery ¶
func (k Keeper) SubmitValidatorSlashQuery(ctx sdk.Context, lsmLiquidStake types.LSMLiquidStake) error
SubmitValidatorSlashQuery submits an interchain query for the validator's sharesToTokens rate This is done periodically at checkpoints denominated in native tokens (e.g. every 100k ATOM that's LSM liquid staked with validator X)
func (Keeper) SweepAllUnbondedTokens ¶
func (k Keeper) SweepAllUnbondedTokens(ctx sdk.Context) (success bool, successfulSweeps []string, sweepAmounts []sdkmath.Int, failedSweeps []string)
Sends all unbonded tokens to the redemption account returns:
- success indicator if all chains succeeded
- list of successful chains
- list of tokens swept
- list of failed chains
func (Keeper) SweepAllUnbondedTokensForHostZone ¶
func (k Keeper) SweepAllUnbondedTokensForHostZone(ctx sdk.Context, hostZone types.HostZone, epochUnbondingRecords []recordstypes.EpochUnbondingRecord) (success bool, sweepAmount sdkmath.Int)
Batch transfers any unbonded tokens from the delegation account to the redemption account
func (Keeper) SweepStTokensFromRewardCollToFeeColl ¶
Sweep stTokens from Reward Collector to Fee Collector
func (Keeper) ToggleLSMProposal ¶
func (Keeper) TransferAllLSMDeposits ¶
Loops through all active host zones, grabs queued LSMTokenDeposits for that host that are in status TRANSFER_QUEUE, and submits the IBC Transfer to the host
func (Keeper) TransferExistingDepositsToHostZones ¶
func (k Keeper) TransferExistingDepositsToHostZones(ctx sdk.Context, epochNumber uint64, depositRecords []recordstypes.DepositRecord)
Iterate each deposit record marked TRANSFER_QUEUE and IBC transfer tokens from the Stride controller account to the delegation ICAs on each host zone
func (Keeper) UnbondFromHostZone ¶
Submits undelegation ICA messages for a given host zone
First, the total unbond amount is determined from the epoch unbonding records Then that unbond amount is allowed to cascade across the validators in order of how proportionally different their current delegations are from the weight implied target delegation, until their capacities have consumed the full amount As a result, unbondings lead to a more balanced distribution of stake across validators
Context: Over time, as LSM Liquid stakes are accepted, the total stake managed by the protocol becomes unbalanced as liquid stakes are not aligned with the validator weights. This is only rebalanced once per unbonding period
func (Keeper) UndelegateCallback ¶
func (k Keeper) UndelegateCallback(ctx sdk.Context, packet channeltypes.Packet, ackResponse *icacallbackstypes.AcknowledgementResponse, args []byte) error
ICA Callback after undelegating
If successful: * Updates epoch unbonding record status * Records delegation changes on the host zone and validators, * Burns stTokens If timeout: * Does nothing If failure: * Reverts epoch unbonding record status
func (Keeper) UndelegateHostCallback ¶
func (k Keeper) UndelegateHostCallback(ctx sdk.Context, packet channeltypes.Packet, ackResponse *icacallbackstypes.AcknowledgementResponse, args []byte) error
ICA Callback after undelegating host
If successful: * sets SetUndelegateHostPrevented If timeout: * Does nothing If failure: * Does nothing
func (Keeper) UndelegateHostEvmos ¶
Submits undelegation ICA message for Evmos The total unbond amount is input, capped at MaxNumTokensUnbondable.
func (Keeper) UnmarshalClaimCallbackArgs ¶
func (k Keeper) UnmarshalClaimCallbackArgs(ctx sdk.Context, claimCallback []byte) (*types.ClaimCallback, error)
Unmarshalls claim callback arguments into a ClaimCallback struct
func (Keeper) UnmarshalDelegateCallbackArgs ¶
func (k Keeper) UnmarshalDelegateCallbackArgs(ctx sdk.Context, delegateCallback []byte) (*types.DelegateCallback, error)
Unmarshalls delegate callback arguments into a DelegateCallback struct
func (Keeper) UnmarshalRebalanceCallbackArgs ¶
func (k Keeper) UnmarshalRebalanceCallbackArgs(ctx sdk.Context, rebalanceCallback []byte) (*types.RebalanceCallback, error)
Unmarshalls rebalance callback arguments into a RebalanceCallback struct
func (Keeper) UnmarshalRedemptionCallbackArgs ¶
func (k Keeper) UnmarshalRedemptionCallbackArgs(ctx sdk.Context, redemptionCallback []byte) (types.RedemptionCallback, error)
Unmarshalls redemption callback arguments into a RedemptionCallback struct
func (Keeper) UnmarshalReinvestCallbackArgs ¶
func (k Keeper) UnmarshalReinvestCallbackArgs(ctx sdk.Context, reinvestCallback []byte) (*types.ReinvestCallback, error)
Unmarshalls reinvest callback arguments into a ReinvestCallback struct
func (Keeper) UpdateDelegationBalances ¶
func (k Keeper) UpdateDelegationBalances(ctx sdk.Context, hostZone types.HostZone, undelegateCallback types.UndelegateCallback) error
Decrement the delegation field on the host zone and each validator's delegations after a successful unbonding ICA
func (Keeper) UpdateDelegationBalancesHost ¶
func (k Keeper) UpdateDelegationBalancesHost(ctx sdk.Context, hostZone types.HostZone, undelegateHostCallback types.UndelegateHostCallback) error
Decrement the delegation field on host and each validator's delegations after a successful unbonding ICA
func (Keeper) UpdateEpochTracker ¶
func (k Keeper) UpdateEpochTracker(ctx sdk.Context, epochInfo epochstypes.EpochInfo) (epochNumber uint64, err error)
Update the epoch information in the stakeibc epoch tracker
func (Keeper) UpdateHostZoneUnbondings ¶
func (k Keeper) UpdateHostZoneUnbondings( ctx sdk.Context, latestCompletionTime time.Time, chainId string, undelegateCallback types.UndelegateCallback, ) (stTokenBurnAmount sdkmath.Int, err error)
UpdateHostZoneUnbondings does two things:
- Update the time of each hostZoneUnbonding on each epochUnbondingRecord
- Return the number of stTokens that need to be burned
func (Keeper) UpdateRedemptionRateForHostZone ¶
func (k Keeper) UpdateRedemptionRateForHostZone(ctx sdk.Context, hostZone types.HostZone, depositRecords []recordstypes.DepositRecord)
func (Keeper) UpdateRedemptionRates ¶
func (k Keeper) UpdateRedemptionRates(ctx sdk.Context, depositRecords []recordstypes.DepositRecord)
Updates the redemption rate for each host zone At a high level, the redemption rate is equal to the amount of native tokens locked divided by the stTokens in existence. The equation is broken down further into the following sub-components:
Native Tokens Locked: 1. Deposit Account Balance: native tokens deposited from liquid stakes, that are still living on Stride 2. Undelegated Balance: native tokens that have been transferred to the host zone, but have not been delegated yet 3. Tokenized Delegations: Delegations inherent in LSM Tokens that have not yet been converted to native stake 4. Native Delegations: Delegations either from native tokens, or LSM Tokens that have been detokenized StToken Amount: 1. Total Supply of the stToken Redemption Rate = (Deposit Account Balance + Undelegated Balance + Tokenized Delegation + Native Delegation) / (stToken Supply)
func (Keeper) UpdateWithdrawalBalance ¶
Submits an ICQ for the withdrawal account balance
func (Keeper) ValidateLSMLiquidStake ¶
func (k Keeper) ValidateLSMLiquidStake(ctx sdk.Context, msg types.MsgLSMLiquidStake) (types.LSMLiquidStake, error)
Validates the parameters supplied with this LSMLiquidStake, including that the denom corresponds with a valid LSM Token and that the user has sufficient balance
This is called once at the beginning of the liquid stake, and is, potentially, called again at the end (if the transaction was asynchronous due to an intermediate slash query)
This function returns the associated host zone and validator along with the initial deposit record
func (Keeper) Validators ¶
func (k Keeper) Validators(c context.Context, req *types.QueryGetValidatorsRequest) (*types.QueryGetValidatorsResponse, error)
type ValidatorUnbondCapacity ¶
type ValidatorUnbondCapacity struct { ValidatorAddress string CurrentDelegation sdkmath.Int BalancedDelegation sdkmath.Int Capacity sdkmath.Int }
func SortUnbondingCapacityByPriority ¶
func SortUnbondingCapacityByPriority(validatorUnbondCapacity []ValidatorUnbondCapacity) ([]ValidatorUnbondCapacity, error)
Sort validators by the ratio of the ideal balanced delegation to their current delegation This will sort the validator's by how proportionally unbalanced they are
Ex:
Val1: Ideal Balanced Delegation 80, Current Delegation 100 (surplus of 20), Ratio: 0.8 Val2: Ideal Balanced Delegation 480, Current Delegation 500 (surplus of 20), Ratio: 0.96
While both validators have the same net unbalanced delegation, Val2 is proportionally more balanced since the surplus is a smaller percentage of it's overall delegation
This will also sort such that 0-weight validator's will come first as their ideal balanced delegation will always be 0, and thus their ratio will always be 0 If the ratio's are equal, the validator with the larger delegation/capacity will come first
func (*ValidatorUnbondCapacity) GetBalanceRatio ¶
func (c *ValidatorUnbondCapacity) GetBalanceRatio() (sdk.Dec, error)
The ratio of ideal balanced delegation to the current delegation This represents how proportionally unbalanced each validator is The smaller number means their current delegation is much larger then their fair portion of the current total stake
Source Files ¶
- abci.go
- consumer.go
- deposit_records.go
- epoch_tracker.go
- events.go
- gov.go
- grpc_query.go
- grpc_query_address_unbondings.go
- grpc_query_epoch_tracker.go
- grpc_query_host_zone.go
- grpc_query_module_address.go
- grpc_query_next_packet_sequence.go
- grpc_query_params.go
- grpc_query_register_ica.go
- grpc_query_validator.go
- hooks.go
- host_zone.go
- icacallbacks.go
- icacallbacks_claim.go
- icacallbacks_delegate.go
- icacallbacks_detokenize.go
- icacallbacks_rebalance.go
- icacallbacks_redemption.go
- icacallbacks_reinvest.go
- icacallbacks_undelegate.go
- icqcallbacks.go
- icqcallbacks_callibrate_delegation.go
- icqcallbacks_delegator_shares.go
- icqcallbacks_fee_balance.go
- icqcallbacks_validator_exchange_rate.go
- icqcallbacks_withdrawal_balance.go
- invariants.go
- keeper.go
- lsm.go
- msg_server.go
- msg_server_add_validators.go
- msg_server_calibrate_delegation.go
- msg_server_change_validator_weight.go
- msg_server_claim_undelegated_tokens.go
- msg_server_clear_balance.go
- msg_server_delete_validator.go
- msg_server_liquid_stake.go
- msg_server_lsm_liquid_stake.go
- msg_server_rebalance_validators.go
- msg_server_redeem_stake.go
- msg_server_register_host_zone.go
- msg_server_restore_interchain_account.go
- msg_server_resume_host_zone.go
- msg_server_submit_tx.go
- msg_server_update_inner_redemption_rate_bounds.go
- msg_server_update_validator_shares_exch_rate.go
- msg_undelegate_host.go
- params.go
- reward_allocation.go
- unbonding_records.go
- undelegate_host.go
- validator_selection.go