keeper

package
v16.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2023 License: Apache-2.0 Imports: 50 Imported by: 0

Documentation

Index

Constants

View Source
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"
)
View Source
const (
	ICQCallbackID_WithdrawalBalance = "withdrawalbalance"
	ICQCallbackID_FeeBalance        = "feebalance"
	ICQCallbackID_Delegation        = "delegation"
	ICQCallbackID_Validator         = "validator"
	ICQCallbackID_Calibrate         = "calibrate"
)
View Source
const (
	MaxNumTokensUnbondableStr = "2500000000000000000000000" // 2,500,000e18
	EvmosHostZoneChainId      = "evmos_9001-2"
)
View Source
const RebalanceIcaBatchSize = 5
View Source
const StrideEpochsPerDayEpoch = uint64(4)
View Source
const (
	UndelegateICABatchSize = 32
)

Variables

View Source
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

func AllInvariants(k Keeper) sdk.Invariant

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:

  1. the validator's internal shares to tokens rate
  2. 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

func DelegatorSharesCallback(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:

  1. the validator's internal shares to tokens rate
  2. 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

func EmitUndelegationEvent(ctx sdk.Context, hostZone types.HostZone, totalUnbondAmount sdkmath.Int)

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

func FeeBalanceCallback(k Keeper, ctx sdk.Context, args []byte, query icqtypes.Query) error

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

func GetLSMTokenDepositId(blockHeight int64, chainId, stakerAddress, denom string) string

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

func NewMsgServerImpl(keeper Keeper) types.MsgServer

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:

  1. the validator's internal sharesToTokens rate
  2. 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

func WithdrawalBalanceCallback(k Keeper, ctx sdk.Context, args []byte, query icqtypes.Query) error

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

type ICQCallback func(Keeper, sdk.Context, []byte, icqtypes.Query) error

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 (c ICQCallbacks) CallICQCallback(ctx sdk.Context, id string, args []byte, query icqtypes.Query) error

func (ICQCallbacks) HasICQCallback

func (c ICQCallbacks) HasICQCallback(id string) bool

func (ICQCallbacks) RegisterICQCallbacks

func (c ICQCallbacks) RegisterICQCallbacks() icqtypes.QueryCallbacks

type IcaTx

type IcaTx struct {
	ConnectionId   string
	Msgs           []proto.Message
	ICAAccountType types.ICAAccountType
	Timeout        uint64
}

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 (k Keeper) AddValidatorsProposal(ctx sdk.Context, msg *types.AddValidatorsProposal) error

func (Keeper) AfterEpochEnd

func (k Keeper) AfterEpochEnd(ctx sdk.Context, epochInfo epochstypes.EpochInfo)

func (Keeper) AllocateHostZoneReward

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

(1) liquid stake reward collector balance, then (2) sweet stTokens from reward collector to fee collector

func (Keeper) AssertStrideAndDayEpochRelationship

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

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

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

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 (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

func (k Keeper) CheckIsStToken(ctx sdk.Context, denom string) bool

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

func (k Keeper) CleanupEpochUnbondingRecords(ctx sdk.Context, epochNumber uint64) bool

Deletes any epoch unbonding records that have had all unbondings claimed

func (Keeper) CreateDepositRecordsForEpoch

func (k Keeper) CreateDepositRecordsForEpoch(ctx sdk.Context, epochNumber uint64)

Create a new deposit record for each host zone for the given epoch

func (Keeper) CreateEpochUnbondingRecord

func (k Keeper) CreateEpochUnbondingRecord(ctx sdk.Context, epochNumber uint64) bool

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

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

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 (k Keeper) EndBlocker(ctx sdk.Context)

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

func (k Keeper) GetAllActiveHostZone(ctx sdk.Context) (list []types.HostZone)

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

func (k Keeper) GetAllHostZone(ctx sdk.Context) (list []types.HostZone)

GetAllHostZone returns all hostZone

func (Keeper) GetChainID

func (k Keeper) GetChainID(ctx sdk.Context, connectionID string) (string, error)

func (Keeper) GetClaimableRedemptionRecord

func (k Keeper) GetClaimableRedemptionRecord(ctx sdk.Context, msg *types.MsgClaimUndelegatedTokens) (*recordstypes.UserRedemptionRecord, error)

func (Keeper) GetConnectionId

func (k Keeper) GetConnectionId(ctx sdk.Context, portId string) (string, error)

func (Keeper) GetCounterpartyChainId

func (k Keeper) GetCounterpartyChainId(ctx sdk.Context, connectionID string) (string, error)

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

func (k Keeper) GetHostZone(ctx sdk.Context, chainId string) (val types.HostZone, found bool)

GetHostZone returns a hostZone from its id

func (Keeper) GetHostZoneFromHostDenom

func (k Keeper) GetHostZoneFromHostDenom(ctx sdk.Context, denom string) (*types.HostZone, error)

GetHostZoneFromHostDenom returns a HostZone from a HostDenom

func (Keeper) GetHostZoneFromIBCDenom

func (k Keeper) GetHostZoneFromIBCDenom(ctx sdk.Context, denom string) (*types.HostZone, error)

GetHostZoneFromIBCDenom returns a HostZone from a IBCDenom

func (Keeper) GetHostZoneFromLSMTokenPath

func (k Keeper) GetHostZoneFromLSMTokenPath(ctx sdk.Context, path string) (types.HostZone, error)

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 (k Keeper) GetICATimeoutNanos(ctx sdk.Context, epochType string) (uint64, error)

func (Keeper) GetInnerSafetyBounds

func (k Keeper) GetInnerSafetyBounds(ctx sdk.Context, zone types.HostZone) (sdk.Dec, sdk.Dec)

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

func (k Keeper) GetLatestCompletionTime(ctx sdk.Context, msgResponses [][]byte) (*time.Time, error)

Get the latest completion time across each MsgUndelegate in the ICA transaction The time is used to set the

func (Keeper) GetLightClientHeightSafely

func (k Keeper) GetLightClientHeightSafely(ctx sdk.Context, connectionID string) (uint64, error)

func (Keeper) GetLightClientTimeSafely

func (k Keeper) GetLightClientTimeSafely(ctx sdk.Context, connectionID string) (uint64, error)

func (Keeper) GetOuterSafetyBounds

func (k Keeper) GetOuterSafetyBounds(ctx sdk.Context, zone types.HostZone) (sdk.Dec, sdk.Dec)

func (*Keeper) GetParam

func (k *Keeper) GetParam(ctx sdk.Context, key []byte) uint64

func (Keeper) GetParams

func (k Keeper) GetParams(ctx sdk.Context) (params types.Params)

GetParams get all parameters as types.Params

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

func (k Keeper) GetStartTimeNextEpoch(ctx sdk.Context, epochType string) (uint64, error)

helper to get time at which next epoch begins, in unix nano units

func (Keeper) GetStrideEpochElapsedShare

func (k Keeper) GetStrideEpochElapsedShare(ctx sdk.Context) (sdk.Dec, error)

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

func (k Keeper) GetTotalTokenizedDelegations(ctx sdk.Context, hostZone types.HostZone) sdk.Dec

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

func (k Keeper) GetTotalValidatorWeight(validators []types.Validator) uint64

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) Hooks

func (k Keeper) Hooks() Hooks

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

func (k Keeper) InitiateAllHostZoneUnbondings(ctx sdk.Context, dayNumber uint64)

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

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 (k Keeper) IsUndelegateHostPrevented(ctx sdk.Context) bool

func (Keeper) IsWithinBufferWindow

func (k Keeper) IsWithinBufferWindow(ctx sdk.Context) (bool, error)

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

func (k Keeper) LiquidStakeRewardCollectorBalance(ctx sdk.Context, msgSvr types.MsgServer) bool

Liquid Stake Reward Collector Balance

func (Keeper) Logger

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

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) Params

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

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

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

func (k Keeper) RebalanceDelegationsForHostZone(ctx sdk.Context, chainId string) error

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

func (k Keeper) RegisterStTokenDenomsToWhitelist(ctx sdk.Context, denoms []string) error

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 (k Keeper) ReinvestRewards(ctx sdk.Context)

func (Keeper) RemoveEpochTracker

func (k Keeper) RemoveEpochTracker(
	ctx sdk.Context,
	epochIdentifier string,
)

RemoveEpochTracker removes a epochTracker from the store

func (Keeper) RemoveHostZone

func (k Keeper) RemoveHostZone(ctx sdk.Context, chain_id string)

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

func (k Keeper) SetHostZone(ctx sdk.Context, hostZone types.HostZone)

SetHostZone set a specific hostZone in the store

func (Keeper) SetParams

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

SetParams set the params

func (Keeper) SetUndelegateHostPrevented

func (k Keeper) SetUndelegateHostPrevented(ctx sdk.Context) error

func (Keeper) SetWithdrawalAddress

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

Set the withdrawal account address for each host zone

func (Keeper) SetWithdrawalAddressOnHost

func (k Keeper) SetWithdrawalAddressOnHost(ctx sdk.Context, hostZone types.HostZone) error

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 (k Keeper) SubmitTxsDayEpoch(
	ctx sdk.Context,
	connectionId string,
	msgs []proto.Message,
	icaAccountType types.ICAAccountType,
	callbackId string,
	callbackArgs []byte,
) (uint64, error)

func (Keeper) SubmitTxsEpoch

func (k Keeper) SubmitTxsEpoch(
	ctx sdk.Context,
	connectionId string,
	msgs []proto.Message,
	icaAccountType types.ICAAccountType,
	epochType string,
	callbackId string,
	callbackArgs []byte,
) (uint64, error)

func (Keeper) SubmitTxsStrideEpoch

func (k Keeper) SubmitTxsStrideEpoch(
	ctx sdk.Context,
	connectionId string,
	msgs []proto.Message,
	icaAccountType types.ICAAccountType,
	callbackId string,
	callbackArgs []byte,
) (uint64, error)

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

func (k Keeper) SweepStTokensFromRewardCollToFeeColl(ctx sdk.Context) error

Sweep stTokens from Reward Collector to Fee Collector

func (Keeper) ToggleLSMProposal

func (k Keeper) ToggleLSMProposal(ctx sdk.Context, msg *types.ToggleLSMProposal) error

func (Keeper) TransferAllLSMDeposits

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

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

func (k Keeper) UnbondFromHostZone(ctx sdk.Context, hostZone types.HostZone) error

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

func (k Keeper) UndelegateHostEvmos(ctx sdk.Context, totalUnbondAmount math.Int) error

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:

  1. Update the time of each hostZoneUnbonding on each epochUnbondingRecord
  2. 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

func (k Keeper) UpdateWithdrawalBalance(ctx sdk.Context, hostZone types.HostZone) error

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

type RebalanceValidatorDelegationChange

type RebalanceValidatorDelegationChange struct {
	ValidatorAddress string
	Delta            sdkmath.Int
}

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

Jump to

Keyboard shortcuts

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