Documentation ¶
Index ¶
- Constants
- Variables
- func AllInvariants(k Keeper) sdk.Invariant
- func CalibrateDelegationCallback(k Keeper, ctx sdk.Context, args []byte, query icqtypes.Query) error
- func CommunityPoolIcaBalanceCallback(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 EmitRedemptionSweepEvent(ctx sdk.Context, hostZone types.HostZone, sweptAmount sdkmath.Int)
- func EmitSuccessfulLSMLiquidStakeEvent(ctx sdk.Context, hostZone types.HostZone, ...)
- func EmitSuccessfulLiquidStakeEvent(ctx sdk.Context, msg *types.MsgLiquidStake, hostZone types.HostZone, ...)
- func EmitSuccessfulRedeemStakeEvent(ctx sdk.Context, msg *types.MsgRedeemStake, 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 TradeConvertedBalanceCallback(k Keeper, ctx sdk.Context, args []byte, query icqtypes.Query) error
- func ValidatorSharesToTokensRateCallback(k Keeper, ctx sdk.Context, args []byte, query icqtypes.Query) error
- func WithdrawalHostBalanceCallback(k Keeper, ctx sdk.Context, args []byte, query icqtypes.Query) error
- func WithdrawalRewardBalanceCallback(k Keeper, ctx sdk.Context, args []byte, query icqtypes.Query) error
- type ForwardMetadata
- 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) AllTradeRoutes(c context.Context, req *types.QueryAllTradeRoutes) (*types.QueryAllTradeRoutesResponse, error)
- func (k Keeper) AllocateHostZoneReward(ctx sdk.Context)
- func (k Keeper) AssertStrideAndDayEpochRelationship(ctx sdk.Context)
- func (k Keeper) BatchSubmitDelegationICAMessages(ctx sdk.Context, hostZone types.HostZone, ...) (numTxsSubmitted uint64, err error)
- func (k Keeper) BatchSubmitUndelegateICAMessages(ctx sdk.Context, hostZone types.HostZone, epochUnbondingRecordIds []uint64, ...) (numTxsSubmitted uint64, err error)
- func (k Keeper) BeforeEpochStart(ctx sdk.Context, epochInfo epochstypes.EpochInfo)
- func (k Keeper) BeginBlocker(ctx sdk.Context)
- func (k Keeper) BuildFundCommunityPoolMsg(ctx sdk.Context, hostZone types.HostZone, tokens sdk.Coins, ...) (fundMsg []proto.Message, err error)
- func (k Keeper) BuildHostToTradeTransferMsg(ctx sdk.Context, amount sdkmath.Int, route types.TradeRoute) (msg transfertypes.MsgTransfer, err error)
- func (k Keeper) BuildTradeAuthzMsg(ctx sdk.Context, tradeRoute types.TradeRoute, ...) (authzMsg []proto.Message, err error)
- func (k Keeper) BurnStTokensAfterUndelegation(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) CalculateRewardsSplit(ctx sdk.Context, hostZone types.HostZone, rewardsAmount sdkmath.Int) (rewardSplit RewardsSplit, err error)
- func (k Keeper) CalculateTotalUnbondedInBatch(undelegations []*types.SplitUndelegation) (nativeTokens sdkmath.Int)
- 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) CheckValidatorWeightsBelowCap(ctx sdk.Context, chainId string) error
- func (k Keeper) ClaimAccruedStakingRewards(ctx sdk.Context)
- func (k Keeper) ClaimAccruedStakingRewardsOnHost(ctx sdk.Context, hostZone types.HostZone) error
- func (k Keeper) ClaimCallback(ctx sdk.Context, packet channeltypes.Packet, ...) error
- func (k Keeper) CleanupEpochUnbondingRecords(ctx sdk.Context, epochNumber uint64)
- 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) 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) DisableHubTokenization(ctx sdk.Context)
- func (k Keeper) EnableRedemptions(ctx sdk.Context, chainId string) 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) FundCommunityPool(ctx sdk.Context, hostZone types.HostZone, token sdk.Coin, ...) error
- func (k Keeper) GetActiveHostZone(ctx sdk.Context, chainId string) (hostZone types.HostZone, err 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) GetAllTradeRoutes(ctx sdk.Context) (list []types.TradeRoute)
- func (k Keeper) GetAuthority() string
- func (k Keeper) GetChainIdFromConnectionId(ctx sdk.Context, connectionID string) (string, error)
- func (k Keeper) GetClaimableRedemptionRecord(ctx sdk.Context, msg *types.MsgClaimUndelegatedTokens) (*recordstypes.UserRedemptionRecord, error)
- func (k Keeper) GetDelegationICAMessages(ctx sdk.Context, hostZone types.HostZone, ...) (msgs []proto.Message, delegations []*types.SplitDelegation, err 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) GetLatestUnbondingCompletionTime(ctx sdk.Context, msgResponses [][]byte) (latestCompletionTime uint64, err error)
- func (k Keeper) GetLightClientHeight(ctx sdk.Context, connectionID string) (height uint64, err error)
- func (k Keeper) GetLightClientTime(ctx sdk.Context, connectionID string) (clientTime uint64, err 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) GetQueuedHostZoneUnbondingRecords(ctx sdk.Context, chainId string) (epochNumbers []uint64, ...)
- 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) GetStIbcDenomOnHostZone(ctx sdk.Context, hostZone types.HostZone) (ibcStakedDenom string, err 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) GetTotalRedemptionSweepAmountAndRecordIds(ctx sdk.Context, chainId string, hostBlockTime uint64) (totalSweepAmount sdkmath.Int, unbondingRecordIds []uint64)
- func (k Keeper) GetTotalTokenizedDelegations(ctx sdk.Context, hostZone types.HostZone) sdk.Dec
- func (k Keeper) GetTotalUnbondAmount(hostZoneUnbondingRecords map[uint64]recordstypes.HostZoneUnbonding) sdkmath.Int
- func (k Keeper) GetTotalValidatorWeight(validators []types.Validator) uint64
- func (k Keeper) GetTradeRoute(ctx sdk.Context, rewardDenom string, hostDenom string) (val types.TradeRoute, found bool)
- func (k Keeper) GetTradeRouteFromTradeAccountChainId(ctx sdk.Context, chainId string) (tradeRoute types.TradeRoute, found bool)
- func (k Keeper) GetUnbondingICAMessages(hostZone types.HostZone, totalUnbondAmount sdkmath.Int, ...) (msgs []proto.Message, unbondings []*types.SplitUndelegation, 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) HandleFailedUndelegation(ctx sdk.Context, chainId string, epochNumbers []uint64) error
- 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) 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) LiquidStakeCommunityPoolTokens(ctx sdk.Context, hostZone types.HostZone) error
- func (k Keeper) LiquidStakeRewardCollectorBalance(ctx sdk.Context, msgSvr types.MsgServer) bool
- func (k Keeper) Logger(ctx sdk.Context) log.Logger
- func (k Keeper) MarkUndelegationAckReceived(ctx sdk.Context, hostZone types.HostZone, ...) error
- func (k Keeper) MarshalClaimCallbackArgs(ctx sdk.Context, claimCallback types.ClaimCallback) ([]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) OnChanOpenAck(ctx sdk.Context, portID, channelID string) 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) ProcessAllCommunityPoolTokens(ctx sdk.Context)
- func (k Keeper) QueryCommunityPoolIcaBalance(ctx sdk.Context, hostZone types.HostZone, icaType types.ICAAccountType, ...) 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) RedeemCommunityPoolTokens(ctx sdk.Context, hostZone types.HostZone) error
- func (k Keeper) RedeemStake(ctx sdk.Context, msg *types.MsgRedeemStake) (*types.MsgRedeemStakeResponse, error)
- func (k Keeper) RedemptionCallback(ctx sdk.Context, packet channeltypes.Packet, ...) error
- func (k Keeper) RefreshHostZoneUnbondingNativeTokenAmount(ctx sdk.Context, epochNumber uint64, ...) error
- func (k Keeper) RefreshUnbondingNativeTokenAmounts(ctx sdk.Context, chainId string, ...) (refreshedHostZoneUnbondings map[uint64]recordstypes.HostZoneUnbonding, ...)
- func (k Keeper) RefreshUserRedemptionRecordNativeAmounts(ctx sdk.Context, chainId string, userRedemptionRecordIds []string, ...) (totalNativeAmount sdkmath.Int)
- func (k Keeper) RegisterHostZone(ctx sdk.Context, msg *types.MsgRegisterHostZone) (*types.MsgRegisterHostZoneResponse, error)
- func (k Keeper) RegisterStTokenDenomsToWhitelist(ctx sdk.Context, denoms []string) error
- func (k Keeper) RegisterTradeRouteICAAccount(ctx sdk.Context, tradeRouteId string, connectionId string, ...) (account types.ICAAccount, err 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, chainId string)
- func (k Keeper) RemoveTradeRoute(ctx sdk.Context, rewardDenom string, hostDenom 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) SetTradeRoute(ctx sdk.Context, tradeRoute types.TradeRoute)
- 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) StoreHostZoneIcaAddress(ctx sdk.Context, chainId, portId, address string) error
- func (k Keeper) StoreTradeRouteIcaAddress(ctx sdk.Context, callbackChainId, callbackPortId, address string) 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) SubmitICATxWithoutCallback(ctx sdk.Context, connectionId string, icaAccountOwner 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) SubmitWithdrawalHostBalanceICQ(ctx sdk.Context, hostZone types.HostZone) error
- func (k Keeper) SweepStTokensFromRewardCollToFeeColl(ctx sdk.Context) error
- func (k Keeper) SweepUnbondedTokensAllHostZones(ctx sdk.Context)
- func (k Keeper) SweepUnbondedTokensForHostZone(ctx sdk.Context, hostZone types.HostZone) error
- func (k Keeper) ToggleLSMProposal(ctx sdk.Context, msg *types.ToggleLSMProposal) error
- func (k Keeper) TradeConvertedBalanceQuery(ctx sdk.Context, route types.TradeRoute) error
- func (k Keeper) TransferAllLSMDeposits(ctx sdk.Context)
- func (k Keeper) TransferAllRewardTokens(ctx sdk.Context)
- func (k Keeper) TransferCommunityPoolDepositToHolding(ctx sdk.Context, hostZone types.HostZone, token sdk.Coin) error
- func (k Keeper) TransferConvertedTokensTradeToHost(ctx sdk.Context, amount sdkmath.Int, route types.TradeRoute) error
- func (k Keeper) TransferExistingDepositsToHostZones(ctx sdk.Context, epochNumber uint64, ...)
- func (k Keeper) TransferHoldingToCommunityPoolReturn(ctx sdk.Context, hostZone types.HostZone, coin sdk.Coin) error
- func (k Keeper) TransferRewardTokensHostToTrade(ctx sdk.Context, amount sdkmath.Int, route types.TradeRoute) error
- func (k Keeper) UnbondFromHostZone(ctx sdk.Context, hostZone types.HostZone) (err error)
- func (k Keeper) UndelegateCallback(ctx sdk.Context, packet channeltypes.Packet, ...) error
- func (k Keeper) UnmarshalClaimCallbackArgs(ctx sdk.Context, claimCallback []byte) (*types.ClaimCallback, 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) UnregisterHostZone(ctx sdk.Context, chainId string) error
- func (k Keeper) UpdateDelegationBalances(ctx sdk.Context, hostZone types.HostZone, ...) error
- func (k Keeper) UpdateEpochTracker(ctx sdk.Context, epochInfo epochstypes.EpochInfo) (epochNumber uint64, err error)
- func (k Keeper) UpdateHostZoneUnbondingsAfterUndelegation(ctx sdk.Context, chainId string, epochUnbondingRecordIds []uint64, ...) (totalStTokensToBurn 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) ValidateLSMLiquidStake(ctx sdk.Context, msg types.MsgLSMLiquidStake) (types.LSMLiquidStake, error)
- func (k Keeper) Validators(c context.Context, req *types.QueryGetValidatorsRequest) (*types.QueryGetValidatorsResponse, error)
- func (k Keeper) WithdrawalRewardBalanceQuery(ctx sdk.Context, route types.TradeRoute) error
- type PacketForwardMetadata
- type RebalanceValidatorDelegationChange
- type RewardsSplit
- type ValidatorUnbondCapacity
Constants ¶
const ( ICACallbackID_Delegate = "delegate" ICACallbackID_Claim = "claim" ICACallbackID_Undelegate = "undelegate" ICACallbackID_Reinvest = "reinvest" ICACallbackID_Redemption = "redemption" ICACallbackID_Rebalance = "rebalance" ICACallbackID_Detokenize = "detokenize" )
const ( ICQCallbackID_WithdrawalHostBalance = "withdrawalbalance" ICQCallbackID_FeeBalance = "feebalance" ICQCallbackID_Delegation = "delegation" ICQCallbackID_Validator = "validator" ICQCallbackID_Calibrate = "calibrate" ICQCallbackID_CommunityPoolIcaBalance = "communitypoolicabalance" ICQCallbackID_WithdrawalRewardBalance = "withdrawalrewardbalance" ICQCallbackID_TradeConvertedBalance = "tradeconvertedbalance" )
const ( OsmosisSwapTypeUrl = "/osmosis.poolmanager.v1beta1.MsgSwapExactAmountIn" LegacyOsmosisSwapTypeUrl = "/osmosis.gamm.v1beta1.MsgSwapExactAmountIn" )
const (
ClaimRewardsICABatchSize = 10
)
const (
MinValidatorsBeforeWeightCapCheck = 10
)
const RebalanceIcaBatchSize = 5
const StrideEpochsPerDayEpoch = uint64(4)
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 )
var ( CommunityPoolStakeHoldingAddressKey = "community-pool-stake" CommunityPoolRedeemHoldingAddressKey = "community-pool-redeem" DefaultMaxMessagesPerIcaTx = uint64(32) )
var CalibrationThreshold = sdk.NewInt(5000)
CalibrationThreshold is the max amount of tokens by which a calibration can alter internal record keeping of delegations
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 CommunityPoolIcaBalanceCallback ¶
func CommunityPoolIcaBalanceCallback(k Keeper, ctx sdk.Context, args []byte, query icqtypes.Query) error
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 EmitRedemptionSweepEvent ¶
Emits an event if an redemption sweep ICA was submitted for a host zone
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 EmitSuccessfulRedeemStakeEvent ¶
func EmitSuccessfulRedeemStakeEvent(ctx sdk.Context, msg *types.MsgRedeemStake, hostZone types.HostZone, nativeAmount, stAmount sdkmath.Int)
Emits a successful redeem stake event, and displays metadata such as the native 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 TradeConvertedBalanceCallback ¶
func TradeConvertedBalanceCallback(k Keeper, ctx sdk.Context, args []byte, query icqtypes.Query) error
TradeConvertedBalanceCallback is a callback handler for TradeConvertedBalance queries. The query response will return the trade account balance for a converted (foreign ibc) denom If the balance is non-zero, ICA MsgSends are submitted to transfer the discovered balance back to hostZone
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 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 WithdrawalHostBalanceCallback ¶
func WithdrawalHostBalanceCallback(k Keeper, ctx sdk.Context, args []byte, query icqtypes.Query) error
WithdrawalHostBalanceCallback is a callback handler for WithdrawalBalance queries. The query response will return the withdrawal account balance for the native denom (i.e. "host denom") 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"
func WithdrawalRewardBalanceCallback ¶
func WithdrawalRewardBalanceCallback(k Keeper, ctx sdk.Context, args []byte, query icqtypes.Query) error
WithdrawalRewardBalanceCallback is a callback handler for WithdrawalRewardBalance queries. The query response will return the withdrawal account balance for the reward denom in the case of a host zone with a trade route (e.g. USDC in the case of the dYdX trade route) If the balance is non-zero, ICA MsgSends are submitted to transfer the discovered balance to the tradeZone
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 ForwardMetadata ¶
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, authority string, 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) AllTradeRoutes ¶
func (k Keeper) AllTradeRoutes(c context.Context, req *types.QueryAllTradeRoutes) (*types.QueryAllTradeRoutesResponse, error)
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) BatchSubmitDelegationICAMessages ¶
func (k Keeper) BatchSubmitDelegationICAMessages( ctx sdk.Context, hostZone types.HostZone, depositRecord recordstypes.DepositRecord, msgs []proto.Message, delegations []*types.SplitDelegation, batchSize int, ) (numTxsSubmitted uint64, err error)
Submit undelegate ICA messages in small batches to reduce the gas size per tx
func (Keeper) BatchSubmitUndelegateICAMessages ¶
func (k Keeper) BatchSubmitUndelegateICAMessages( ctx sdk.Context, hostZone types.HostZone, epochUnbondingRecordIds []uint64, msgs []proto.Message, unbondings []*types.SplitUndelegation, batchSize int, ) (numTxsSubmitted uint64, err error)
Submit undelegate ICA messages in small batches to reduce the gas size per tx
func (Keeper) BeforeEpochStart ¶
func (k Keeper) BeforeEpochStart(ctx sdk.Context, epochInfo epochstypes.EpochInfo)
func (Keeper) BeginBlocker ¶
BeginBlocker of stakeibc module
func (Keeper) BuildFundCommunityPoolMsg ¶
func (k Keeper) BuildFundCommunityPoolMsg( ctx sdk.Context, hostZone types.HostZone, tokens sdk.Coins, senderAccountType types.ICAAccountType, ) (fundMsg []proto.Message, err error)
Builds a msg to send funds to a community pool If the community pool treasury address is specified on the host zone, the tokens are bank sent there Otherwise, a MsgFundCommunityPool is used to send tokens to the default community pool address
func (Keeper) BuildHostToTradeTransferMsg ¶
func (k Keeper) BuildHostToTradeTransferMsg( ctx sdk.Context, amount sdkmath.Int, route types.TradeRoute, ) (msg transfertypes.MsgTransfer, err error)
Builds a PFM transfer message to send reward tokens from the host zone, through the reward zone (to unwind) and finally to the trade zone
func (Keeper) BuildTradeAuthzMsg ¶
func (k Keeper) BuildTradeAuthzMsg( ctx sdk.Context, tradeRoute types.TradeRoute, permissionChange types.AuthzPermissionChange, grantee string, legacy bool, ) (authzMsg []proto.Message, err error)
Builds an authz MsgGrant or MsgRevoke to grant an account trade capabilties on behalf of the trade ICA
func (Keeper) BurnStTokensAfterUndelegation ¶
func (k Keeper) BurnStTokensAfterUndelegation(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) CalculateRewardsSplit ¶
func (k Keeper) CalculateRewardsSplit( ctx sdk.Context, hostZone types.HostZone, rewardsAmount sdkmath.Int, ) (rewardSplit RewardsSplit, err error)
Breaks down the split of native rewards into the portions intended for (a) a rebate, (b) stride commission, and (c) reinvestment For most host zones, the rewards here were generated from normal staking rewards, but in the case of dYdX, this is called on the rewards that were converted from USDC to DYDX during the trade route
The rebate percentage is determined by: (% of total TVL contributed by commuity pool) * (rebate percentage)
E.g. Community pool liquid staked 1M, TVL is 10M, rebate is 20% Total rewards this epoch are 1000, and the stride fee is 10% => Then the rebate is 1000 rewards * 10% stride fee * (1M / 10M) * 20% rebate = 2 tokens => Stride fee is 1000 rewards * 10% stride fee - 2 rebate = 98 tokens => Reinvestment is 1000 rewards * (100% - 10% stride fee) = 900 tokens
func (Keeper) CalculateTotalUnbondedInBatch ¶
func (k Keeper) CalculateTotalUnbondedInBatch(undelegations []*types.SplitUndelegation) (nativeTokens sdkmath.Int)
Calculates the tokens unbonded for this batch by summing from each validator
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) CheckValidatorWeightsBelowCap ¶
Checks if any validator's portion of the weight is greater than the cap
func (Keeper) ClaimAccruedStakingRewards ¶
Claim staking rewards for each host zone
func (Keeper) ClaimAccruedStakingRewardsOnHost ¶
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) 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) DisableHubTokenization ¶
TODO [cleanup]: Remove after v17 upgrade
func (Keeper) EnableRedemptions ¶
Enables redemptions by setting the parameter on the host zone to true This is used during the staketia/stakedym migrations
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) FundCommunityPool ¶
func (k Keeper) FundCommunityPool( ctx sdk.Context, hostZone types.HostZone, token sdk.Coin, senderAccountType types.ICAAccountType, ) error
Using tokens in the CommunityPoolReturnIcaAddress, trigger ICA tx to fund community pool Note: The denom of the passed in token has to be the denom which exists on the hostZone not Stride
func (Keeper) GetActiveHostZone ¶
func (k Keeper) GetActiveHostZone(ctx sdk.Context, chainId string) (hostZone types.HostZone, err error)
GetActiveHostZone returns an error if the host zone is not found or if it's found, but is halted
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) GetAllTradeRoutes ¶
func (k Keeper) GetAllTradeRoutes(ctx sdk.Context) (list []types.TradeRoute)
GetAllTradeRoute returns all tradeRoutes
func (Keeper) GetAuthority ¶
GetAuthority returns the x/stakeibc module's authority.
func (Keeper) GetChainIdFromConnectionId ¶
Lookup a chain ID from a connection ID by looking up the client state
func (Keeper) GetClaimableRedemptionRecord ¶
func (k Keeper) GetClaimableRedemptionRecord(ctx sdk.Context, msg *types.MsgClaimUndelegatedTokens) (*recordstypes.UserRedemptionRecord, error)
func (Keeper) GetDelegationICAMessages ¶
func (k Keeper) GetDelegationICAMessages( ctx sdk.Context, hostZone types.HostZone, depositRecord recordstypes.DepositRecord, ) (msgs []proto.Message, delegations []*types.SplitDelegation, err error)
Builds the delegation ICA messages for a given deposit record Each validator has a portion of the total amount on the record based on their weight
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) GetLatestUnbondingCompletionTime ¶
func (k Keeper) GetLatestUnbondingCompletionTime(ctx sdk.Context, msgResponses [][]byte) (latestCompletionTime uint64, err error)
Get the latest completion time across each MsgUndelegate in the ICA transaction The time is later stored on the unbonding record
func (Keeper) GetLightClientHeight ¶
func (k Keeper) GetLightClientHeight(ctx sdk.Context, connectionID string) (height uint64, err error)
Given a connection ID, returns the light client height
func (Keeper) GetLightClientTime ¶
func (k Keeper) GetLightClientTime(ctx sdk.Context, connectionID string) (clientTime uint64, err error)
Given a connection ID, returns the light client time
func (Keeper) GetOuterSafetyBounds ¶
func (Keeper) GetQueuedHostZoneUnbondingRecords ¶
func (k Keeper) GetQueuedHostZoneUnbondingRecords( ctx sdk.Context, chainId string, ) (epochNumbers []uint64, epochToHostZoneUnbondingMap map[uint64]recordstypes.HostZoneUnbonding)
Returns all the host zone unbonding records that should unbond this epoch Records are returned as a mapping of epoch unbonding record ID to host zone unbonding record Records ready to be unbonded are identified by status UNBONDING_QUEUE or UNBONDING_RETRY_QUEUE and a non-zero native amount
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) GetStIbcDenomOnHostZone ¶
func (k Keeper) GetStIbcDenomOnHostZone(ctx sdk.Context, hostZone types.HostZone) (ibcStakedDenom string, err error)
given a hostZone with native denom, returns the ibc denom on the zone for the staked stDenom
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) GetTotalRedemptionSweepAmountAndRecordIds ¶
func (k Keeper) GetTotalRedemptionSweepAmountAndRecordIds( ctx sdk.Context, chainId string, hostBlockTime uint64, ) (totalSweepAmount sdkmath.Int, unbondingRecordIds []uint64)
Gets the total unbonded amount for the host zone that has finished unbonding
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) GetTotalUnbondAmount ¶
func (k Keeper) GetTotalUnbondAmount(hostZoneUnbondingRecords map[uint64]recordstypes.HostZoneUnbonding) sdkmath.Int
Loops through each epoch unbonding record and returns the total number of native tokens that should be unbonded
func (Keeper) GetTotalValidatorWeight ¶
Sum the total weights across each validator for a host zone
func (Keeper) GetTradeRoute ¶
func (k Keeper) GetTradeRoute(ctx sdk.Context, rewardDenom string, hostDenom string) (val types.TradeRoute, found bool)
GetTradeRoute returns a tradeRoute from its start and end denoms The start and end denom's are in their native format (e.g. uusdc and udydx)
func (Keeper) GetTradeRouteFromTradeAccountChainId ¶
func (k Keeper) GetTradeRouteFromTradeAccountChainId(ctx sdk.Context, chainId string) (tradeRoute types.TradeRoute, found bool)
Searches for a trade route by the trade account chain ID
func (Keeper) GetUnbondingICAMessages ¶
func (k Keeper) GetUnbondingICAMessages( hostZone types.HostZone, totalUnbondAmount sdkmath.Int, prioritizedUnbondCapacity []ValidatorUnbondCapacity, ) (msgs []proto.Message, unbondings []*types.SplitUndelegation, 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) HandleFailedUndelegation ¶
func (k Keeper) HandleFailedUndelegation(ctx sdk.Context, chainId string, epochNumbers []uint64) error
If the undelegation failed, set the unbonding status to RETRY_QUEUE, but only for records that are currently in status UNBONDING_IN_PROGRESS There may be some epoch numbers in this batch from records that have already had a full unbonding and have moved onto status EXIT_TRANSFER_QUEUE
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)
TODO [cleanup]: Update to be CheckRedemptionRateWithinSafetyBound and only throw an error (instead of a bool) safety check: ensure the redemption rate is NOT below our min safety threshold && NOT above our max safety threshold on host zone
func (Keeper) IterateHostZones ¶
func (k Keeper) IterateHostZones(ctx sdk.Context, fn func(ctx sdk.Context, index int64, zoneInfo types.HostZone) error)
IterateHostZones iterates zones TODO [cleanup]: Remove this in favor of GetAllHostZones
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) LiquidStakeCommunityPoolTokens ¶
Liquid stake all native tokens in the stake holding address
func (Keeper) LiquidStakeRewardCollectorBalance ¶
Liquid Stake Reward Collector Balance
func (Keeper) MarkUndelegationAckReceived ¶
func (k Keeper) MarkUndelegationAckReceived(ctx sdk.Context, hostZone types.HostZone, undelegateCallback types.UndelegateCallback) error
Regardless of failure/success/timeout, indicate that this ICA has completed on each validator on the host zone, and on the epoch unbonding record
func (Keeper) MarshalClaimCallbackArgs ¶
func (k Keeper) MarshalClaimCallbackArgs(ctx sdk.Context, claimCallback types.ClaimCallback) ([]byte, error)
Marshal claim callback args
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) OnChanOpenAck ¶
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) ProcessAllCommunityPoolTokens ¶
For each hostZone with a valid community pool, trigger the ICQs and ICAs to transfer tokens from DepositICA or back to ReturnICA Since ICQs and ICAs take time to complete, it is almost certain tokens swept in and processed will be swept out in a later epoch
func (Keeper) QueryCommunityPoolIcaBalance ¶
func (k Keeper) QueryCommunityPoolIcaBalance( ctx sdk.Context, hostZone types.HostZone, icaType types.ICAAccountType, denom string, ) error
ICQ specific denom for balance in the deposit ICA or return ICA on the community pool host zone Depending on account type and denom, discovered tokens are transferred to Stride or funded to the pool
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) RedeemCommunityPoolTokens ¶
Redeem all the stTokens in the redeem holding address
func (Keeper) RedeemStake ¶
func (k Keeper) RedeemStake(ctx sdk.Context, msg *types.MsgRedeemStake) (*types.MsgRedeemStakeResponse, error)
TODO [cleanup]: Cleanup this function (errors, logs, comments, whitespace, operation ordering) Exchanges a user's stTokens for native tokens using the current redemption rate
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) RefreshHostZoneUnbondingNativeTokenAmount ¶
func (k Keeper) RefreshHostZoneUnbondingNativeTokenAmount( ctx sdk.Context, epochNumber uint64, hostZoneUnbondingRecord recordstypes.HostZoneUnbonding, ) error
Sets the native token amount unbonded on the host zone unbonding record and the associated user redemption records
func (Keeper) RefreshUnbondingNativeTokenAmounts ¶
func (k Keeper) RefreshUnbondingNativeTokenAmounts( ctx sdk.Context, chainId string, hostZoneUnbondings map[uint64]recordstypes.HostZoneUnbonding, ) (refreshedHostZoneUnbondings map[uint64]recordstypes.HostZoneUnbonding, err error)
Given a mapping of epoch unbonding record IDs to host zone unbonding records, sets the native token amount across all epoch unbonding records, host zone unbonding records, and user redemption records, using the most updated redemption rate Returns an updated mapping with the refreshed amounts
func (Keeper) RefreshUserRedemptionRecordNativeAmounts ¶
func (k Keeper) RefreshUserRedemptionRecordNativeAmounts( ctx sdk.Context, chainId string, userRedemptionRecordIds []string, redemptionRate sdk.Dec, ) (totalNativeAmount sdkmath.Int)
Given a list of user redemption record IDs and a redemption rate, sets the native token amount on each record, calculated from the stAmount and redemption rate, and returns the sum of all native token amounts across all user redemption records
func (Keeper) RegisterHostZone ¶
func (k Keeper) RegisterHostZone(ctx sdk.Context, msg *types.MsgRegisterHostZone) (*types.MsgRegisterHostZoneResponse, error)
func (Keeper) RegisterStTokenDenomsToWhitelist ¶
Register new stTokens to the consumer reward denom whitelist
func (Keeper) RegisterTradeRouteICAAccount ¶
func (k Keeper) RegisterTradeRouteICAAccount( ctx sdk.Context, tradeRouteId string, connectionId string, icaAccountType types.ICAAccountType, ) (account types.ICAAccount, err error)
Registers a new TradeRoute ICAAccount, given the type Stores down the connection and chainId now, and the address upon callback
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 ¶
Delegates accrued staking rewards for reinvestment
func (Keeper) RemoveEpochTracker ¶
RemoveEpochTracker removes a epochTracker from the store
func (Keeper) RemoveHostZone ¶
RemoveHostZone removes a hostZone from the store
func (Keeper) RemoveTradeRoute ¶
RemoveTradeRoute removes a tradeRoute from the store The start and end denom's are in their native format (e.g. uusdc and udydx)
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) SetTradeRoute ¶
func (k Keeper) SetTradeRoute(ctx sdk.Context, tradeRoute types.TradeRoute)
SetTradeRoute set a specific tradeRoute in the store
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) StoreHostZoneIcaAddress ¶
Checks if the chainId matches a given host zone, and the address matches a relevant ICA account If so, stores the ICA address on the host zone struct Also whitelists ICA addresses from rate limiting
func (Keeper) StoreTradeRouteIcaAddress ¶
func (k Keeper) StoreTradeRouteIcaAddress(ctx sdk.Context, callbackChainId, callbackPortId, address string) error
Checks if the port matches an ICA account on the trade route, and if so, stores the relevant ICA address on the trade route
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) SubmitICATxWithoutCallback ¶
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 This function only supports messages to ICAs on the host zone
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) SubmitWithdrawalHostBalanceICQ ¶
Submits an ICQ for the withdrawal account balance
func (Keeper) SweepStTokensFromRewardCollToFeeColl ¶
Sweep stTokens from Reward Collector to Fee Collector
func (Keeper) SweepUnbondedTokensAllHostZones ¶
Sends all unbonded tokens that have finished unbonding to the redemption account Each host zone acts atomically - if an error is thrown, the state changes are discarded
func (Keeper) SweepUnbondedTokensForHostZone ¶
Batch transfers any unbonded tokens from the delegation account to the redemption account
func (Keeper) ToggleLSMProposal ¶
func (Keeper) TradeConvertedBalanceQuery ¶
Kick off ICQ for how many converted tokens are in the trade ICA associated with this host zone
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) TransferAllRewardTokens ¶
Main epochly trigger for the trade route tokens swap
The current design assumes foreign reward tokens start and end in the hostZone withdrawal address Step 1: transfer reward tokens to trade chain Step 2: (off-chain) perform the swap in small batches Step 3: return the swapped tokens to the withdrawal ICA on hostZone
func (Keeper) TransferCommunityPoolDepositToHolding ¶
func (k Keeper) TransferCommunityPoolDepositToHolding(ctx sdk.Context, hostZone types.HostZone, token sdk.Coin) error
Transfers tokens from the community pool deposit ICA account to the host zone stake holding module address for that pool
func (Keeper) TransferConvertedTokensTradeToHost ¶
func (k Keeper) TransferConvertedTokensTradeToHost(ctx sdk.Context, amount sdkmath.Int, route types.TradeRoute) error
ICA tx to kick off transfering the converted tokens back from tradeZone to the hostZone withdrawal ICA
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) TransferHoldingToCommunityPoolReturn ¶
func (k Keeper) TransferHoldingToCommunityPoolReturn(ctx sdk.Context, hostZone types.HostZone, coin sdk.Coin) error
Transfers a recently minted stToken from the stride-side stake holding address to the return ICA address on the host zone
func (Keeper) TransferRewardTokensHostToTrade ¶
func (k Keeper) TransferRewardTokensHostToTrade(ctx sdk.Context, amount sdkmath.Int, route types.TradeRoute) error
ICA tx will kick off transfering the reward tokens from the hostZone withdrawl ICA to the tradeZone trade ICA This will be two hops to unwind the ibc denom through the rewardZone using pfm in the transfer memo
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: * Sets epoch unbonding record status to RETRY
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) 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) UnregisterHostZone ¶
Unregisters a host zone, including removing the module accounts and records
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) 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) UpdateHostZoneUnbondingsAfterUndelegation ¶
func (k Keeper) UpdateHostZoneUnbondingsAfterUndelegation( ctx sdk.Context, chainId string, epochUnbondingRecordIds []uint64, totalNativeTokensUnbonded sdkmath.Int, unbondingTime uint64, ) (totalStTokensToBurn sdkmath.Int, err error)
Updates the host zone unbonding records after a successful undelegation batch The StTokensToBurn and the NativeTokensToUnbond amounts on the records are decremented in a cascading fashion starting from the earliest record The latest completion times is also set on each record if the time from the batch is later than what's currently on the record
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) 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)
func (Keeper) WithdrawalRewardBalanceQuery ¶
Kick off ICQ for the reward denom balance in the withdrawal address
type PacketForwardMetadata ¶
type PacketForwardMetadata struct {
Forward *ForwardMetadata `json:"forward"`
}
JSON Memo for PFM transfers
type RewardsSplit ¶
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
- claim.go
- community_pool.go
- consumer.go
- delegation.go
- epoch_tracker.go
- events.go
- gov.go
- grpc_query.go
- hooks.go
- host_zone.go
- ibc.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_community_pool_ica_balance.go
- icqcallbacks_delegator_shares.go
- icqcallbacks_fee_balance.go
- icqcallbacks_trade_converted_balance.go
- icqcallbacks_validator_exchange_rate.go
- icqcallbacks_withdrawal_host_balance.go
- icqcallbacks_withdrawal_reward_balance.go
- interchainaccounts.go
- interchainqueries.go
- invariants.go
- keeper.go
- lsm.go
- msg_server.go
- params.go
- rebalance.go
- records.go
- redeem_stake.go
- redemption_rate.go
- redemption_sweep.go
- registration.go
- reward_allocation.go
- reward_converter.go
- trade_route.go
- transfer.go
- unbonding.go
- validator.go