keeper

package
v19.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2023 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllInvariants

func AllInvariants(keeper Keeper) sdk.Invariant

AllInvariants runs all invariants of the gamm module.

func NewMsgServerImpl

func NewMsgServerImpl(keeper *Keeper) types.MsgServer

NewMsgServerImpl returns an instance of MsgServer.

func RegisterInvariants

func RegisterInvariants(ir sdk.InvariantRegistry, keeper Keeper)

RegisterInvariants registers all governance invariants.

func TotalSuperfluidDelegationInvariant

func TotalSuperfluidDelegationInvariant(keeper Keeper) sdk.Invariant

TotalSuperfluidDelegationInvariant checks the sum of intermediary account delegation is same as sum of individual lockup delegation.

func ValidatorAddressFromSyntheticDenom

func ValidatorAddressFromSyntheticDenom(syntheticDenom string) (string, error)

quick fix for getting the validator addresss from a synthetic denom.

Types

type Hooks

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

Hooks wrapper struct for incentives keeper.

func (Hooks) AfterAddTokensToLock

func (h Hooks) AfterAddTokensToLock(ctx sdk.Context, address sdk.AccAddress, lockID uint64, amount sdk.Coins)

lockup hooks if you add tokens to a lock that is superfluid unbonding, nothing happens superfluid side. This lock does as an edge case take on the slashing risk as well for historical slashes. This is deemed as fine, governance can re-pay if it occurs on mainnet.

func (Hooks) AfterDelegationModified

func (h Hooks) AfterDelegationModified(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress)

func (Hooks) AfterEpochEnd

func (h Hooks) AfterEpochEnd(ctx sdk.Context, epochIdentifier string, epochNumber int64) error

func (Hooks) AfterValidatorBeginUnbonding

func (h Hooks) AfterValidatorBeginUnbonding(ctx sdk.Context, consAddr sdk.ConsAddress, valAddr sdk.ValAddress)

func (Hooks) AfterValidatorBonded

func (h Hooks) AfterValidatorBonded(ctx sdk.Context, consAddr sdk.ConsAddress, valAddr sdk.ValAddress)

func (Hooks) AfterValidatorCreated

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

staking hooks.

func (Hooks) AfterValidatorRemoved

func (h Hooks) AfterValidatorRemoved(ctx sdk.Context, consAddr sdk.ConsAddress, valAddr sdk.ValAddress)

func (Hooks) AfterValidatorSlashed

func (h Hooks) AfterValidatorSlashed(ctx sdk.Context, valAddr sdk.ValAddress, infractionHeight int64, slashFactor osmomath.Dec, effectiveSlashFactor osmomath.Dec)

func (Hooks) BeforeDelegationCreated

func (h Hooks) BeforeDelegationCreated(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress)

func (Hooks) BeforeDelegationRemoved

func (h Hooks) BeforeDelegationRemoved(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress)

func (Hooks) BeforeDelegationSharesModified

func (h Hooks) BeforeDelegationSharesModified(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress)

func (Hooks) BeforeEpochStart

func (h Hooks) BeforeEpochStart(ctx sdk.Context, epochIdentifier string, epochNumber int64) error

epochs hooks Don't do anything pre epoch start.

func (Hooks) BeforeValidatorModified

func (h Hooks) BeforeValidatorModified(ctx sdk.Context, valAddr sdk.ValAddress)

func (Hooks) BeforeValidatorSlashed

func (h Hooks) BeforeValidatorSlashed(ctx sdk.Context, valAddr sdk.ValAddress, infractionHeight int64, slashFactor osmomath.Dec, effectiveSlashFactor osmomath.Dec)

func (Hooks) OnLockupExtend

func (h Hooks) OnLockupExtend(ctx sdk.Context, lockID uint64, oldDuration, newDuration time.Duration)

func (Hooks) OnStartUnlock

func (h Hooks) OnStartUnlock(ctx sdk.Context, address sdk.AccAddress, lockID uint64, amount sdk.Coins, lockDuration time.Duration, unlockTime time.Time)

func (Hooks) OnTokenLocked

func (h Hooks) OnTokenLocked(ctx sdk.Context, address sdk.AccAddress, lockID uint64, amount sdk.Coins, lockDuration time.Duration, unlockTime time.Time)

func (Hooks) OnTokenSlashed

func (h Hooks) OnTokenSlashed(ctx sdk.Context, lockID uint64, amount sdk.Coins)

func (Hooks) OnTokenUnlocked

func (h Hooks) OnTokenUnlocked(ctx sdk.Context, address sdk.AccAddress, lockID uint64, amount sdk.Coins, lockDuration time.Duration, unlockTime time.Time)

type Keeper

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

Keeper provides a way to manage module storage.

func (Keeper) AddNewSuperfluidAsset

func (k Keeper) AddNewSuperfluidAsset(ctx sdk.Context, asset types.SuperfluidAsset) error

func (Keeper) AfterEpochEnd

func (k Keeper) AfterEpochEnd(ctx sdk.Context, epochIdentifier string, _ int64) error

func (Keeper) AfterEpochStartBeginBlock

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

func (Keeper) BeginUnwindSuperfluidAsset

func (k Keeper) BeginUnwindSuperfluidAsset(ctx sdk.Context, epochNum int64, asset types.SuperfluidAsset)

BeginUnwindSuperfluidAsset starts the deletion process for a superfluid asset. This current method is a stub, but is called when: * Governance removes a superfluid asset * A severe error in gamm occurs

It should eventually begin unwinding all of the synthetic lockups for that asset and queue them for deletion. See https://github.com/osmosis-labs/osmosis/issues/864

func (Keeper) DeleteIntermediaryAccount

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

func (Keeper) DeleteLockIdIntermediaryAccountConnection

func (k Keeper) DeleteLockIdIntermediaryAccountConnection(ctx sdk.Context, lockId uint64)

func (Keeper) DeleteOsmoEquivalentMultiplier

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

func (Keeper) DeleteSuperfluidAsset

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

func (Keeper) ExportGenesis

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

ExportGenesis returns the capability module's exported genesis.

func (Keeper) GetAllIntermediaryAccounts

func (k Keeper) GetAllIntermediaryAccounts(ctx sdk.Context) []types.SuperfluidIntermediaryAccount

func (Keeper) GetAllLockIdIntermediaryAccountConnections

func (k Keeper) GetAllLockIdIntermediaryAccountConnections(ctx sdk.Context) []types.LockIdIntermediaryAccountConnection

func (Keeper) GetAllOsmoEquivalentMultipliers

func (k Keeper) GetAllOsmoEquivalentMultipliers(ctx sdk.Context) []types.OsmoEquivalentMultiplierRecord

func (Keeper) GetAllSuperfluidAssets

func (k Keeper) GetAllSuperfluidAssets(ctx sdk.Context) []types.SuperfluidAsset

func (Keeper) GetEpochIdentifier

func (k Keeper) GetEpochIdentifier(ctx sdk.Context) (epochIdentifier string)

GetParams returns the total set params.

func (Keeper) GetExpectedDelegationAmount

func (k Keeper) GetExpectedDelegationAmount(ctx sdk.Context, acc types.SuperfluidIntermediaryAccount) (osmomath.Int, error)

GetExpectedDelegationAmount returns the total number of osmo the intermediary account has delegated using the most recent osmo equivalent multiplier. This is labeled as expected because the way it calculates the amount can lead rounding errors from the true delegated amount.

func (Keeper) GetIntermediaryAccount

func (k Keeper) GetIntermediaryAccount(ctx sdk.Context, address sdk.AccAddress) types.SuperfluidIntermediaryAccount

func (Keeper) GetIntermediaryAccountFromLockId

func (k Keeper) GetIntermediaryAccountFromLockId(ctx sdk.Context, lockId uint64) (types.SuperfluidIntermediaryAccount, bool)

Returns Superfluid Intermediate Account and a bool if found / not found.

func (Keeper) GetIntermediaryAccountsForVal

func (k Keeper) GetIntermediaryAccountsForVal(ctx sdk.Context, valAddr sdk.ValAddress) []types.SuperfluidIntermediaryAccount

func (Keeper) GetLockIdIntermediaryAccountConnection

func (k Keeper) GetLockIdIntermediaryAccountConnection(ctx sdk.Context, lockId uint64) sdk.AccAddress

func (Keeper) GetOrCreateIntermediaryAccount

func (k Keeper) GetOrCreateIntermediaryAccount(ctx sdk.Context, denom, valAddr string) (types.SuperfluidIntermediaryAccount, error)

func (Keeper) GetOsmoEquivalentMultiplier

func (k Keeper) GetOsmoEquivalentMultiplier(ctx sdk.Context, denom string) osmomath.Dec

func (Keeper) GetParams

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

GetParams returns the total set params.

func (Keeper) GetRiskAdjustedOsmoValue

func (k Keeper) GetRiskAdjustedOsmoValue(ctx sdk.Context, amount osmomath.Int) osmomath.Int

Returns amount * (1 - k.RiskFactor(asset)) Fow now, the risk factor is a global constant. It will move towards per pool functions.

func (Keeper) GetSuperfluidAsset

func (k Keeper) GetSuperfluidAsset(ctx sdk.Context, denom string) (types.SuperfluidAsset, error)

func (Keeper) GetSuperfluidOSMOTokens

func (k Keeper) GetSuperfluidOSMOTokens(ctx sdk.Context, denom string, amount osmomath.Int) (osmomath.Int, error)

func (Keeper) GetTotalSyntheticAssetsLocked

func (k Keeper) GetTotalSyntheticAssetsLocked(ctx sdk.Context, denom string) osmomath.Int

GetTotalSyntheticAssetsLocked returns the total amount of the given denom locked.

func (Keeper) GetUnpoolAllowedPools

func (k Keeper) GetUnpoolAllowedPools(ctx sdk.Context) []uint64

func (Keeper) Hooks

func (k Keeper) Hooks() Hooks

Return the wrapper struct.

func (Keeper) IncreaseSuperfluidDelegation

func (k Keeper) IncreaseSuperfluidDelegation(ctx sdk.Context, lockID uint64, amount sdk.Coins) error

IncreaseSuperfluidDelegation increases the amount of existing superfluid delegation. This method would return an error if the lock has not been superfluid delegated before.

func (Keeper) InitGenesis

func (k Keeper) InitGenesis(ctx sdk.Context, genState types.GenesisState)

InitGenesis initializes the capability module's state from a provided genesis state.

func (Keeper) IterateBondedValidatorsByPower

func (k Keeper) IterateBondedValidatorsByPower(ctx sdk.Context, fn func(int64, stakingtypes.ValidatorI) bool)

IterateBondedValidatorsByPower implements govtypes.StakingKeeper

func (Keeper) IterateDelegations

func (k Keeper) IterateDelegations(ctx sdk.Context, delegator sdk.AccAddress, fn func(int64, stakingtypes.DelegationI) bool)

IterateDelegations implements govtypes.StakingKeeper Iterates through staking keeper's delegations, and then all of the superfluid delegations.

func (Keeper) Logger

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

Logger returns a logger instance.

func (Keeper) MoveSuperfluidDelegationRewardToGauges

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

func (Keeper) RefreshIntermediaryDelegationAmounts

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

RefreshIntermediaryDelegationAmounts refreshes the amount of delegation for all intermediary accounts. This method includes minting new osmo if the refreshed delegation amount has increased, and instantly undelegating and burning if the refreshed delgation has decreased.

func (Keeper) RouteLockedBalancerToConcentratedMigration

func (k Keeper) RouteLockedBalancerToConcentratedMigration(ctx sdk.Context, sender sdk.AccAddress, providedLockId int64, sharesToMigrate sdk.Coin, tokenOutMins sdk.Coins) (positionData cltypes.CreateFullRangePositionData, migratedPoolIDs types.MigrationPoolIDs, concentratedLockId uint64, err error)

RouteLockedBalancerToConcentratedMigration routes the provided lock to the proper migration function based on the lock status. The testing conditions and scope for the different lock status are as follows: Lock Status = Superfluid delegated - cannot migrate partial shares - Instantly undelegate which will bypass unbonding time. - Create new CL Lock and Re-delegate it as a concentrated liquidity position.

Lock Status = Superfluid undelegating - cannot migrate partial shares - Continue undelegating as superfluid unbonding CL Position. - Lock the tokens and create an unlocking syntheticLock (to handle cases of slashing)

Lock Status = Locked or unlocking (no superfluid delegation/undelegation) - cannot migrate partial shares - Force unlock tokens from gamm shares. - Create new CL lock and starts unlocking or unlocking where it left off.

Lock Status = Unlocked - can migrate partial shares - For ex: LP shares - Create new CL lock and starts unlocking or unlocking where it left off.

Errors if the lock is not found, if the lock is not a balancer pool lock, or if the lock is not owned by the sender.

func (Keeper) SetIntermediaryAccount

func (k Keeper) SetIntermediaryAccount(ctx sdk.Context, acc types.SuperfluidIntermediaryAccount)

func (Keeper) SetLockIdIntermediaryAccountConnection

func (k Keeper) SetLockIdIntermediaryAccountConnection(ctx sdk.Context, lockId uint64, acc types.SuperfluidIntermediaryAccount)

func (Keeper) SetOsmoEquivalentMultiplier

func (k Keeper) SetOsmoEquivalentMultiplier(ctx sdk.Context, epoch int64, denom string, multiplier osmomath.Dec)

func (Keeper) SetParams

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

SetParams sets the total set of params.

func (Keeper) SetSuperfluidAsset

func (k Keeper) SetSuperfluidAsset(ctx sdk.Context, asset types.SuperfluidAsset)

func (Keeper) SetUnpoolAllowedPools

func (k Keeper) SetUnpoolAllowedPools(ctx sdk.Context, poolIds []uint64)

func (Keeper) SlashLockupsForValidatorSlash

func (k Keeper) SlashLockupsForValidatorSlash(ctx sdk.Context, valAddr sdk.ValAddress, infractionHeight int64, slashFactor osmomath.Dec)

SlashLockupsForValidatorSlash should be called before the validator at valAddr is slashed. This function is responsible for inspecting every intermediate account to valAddr. For each intermediate account IA, it slashes every constituent delegation behind IA. Furthermore, if the infraction height is sufficiently old, slashes unbondings Note: Based on sdk.staking.Slash function review, slashed tokens are burnt not sent to community pool we ignore that, and send the underliyng tokens to the community pool anyway.

func (Keeper) SuperfluidDelegate

func (k Keeper) SuperfluidDelegate(ctx sdk.Context, sender string, lockID uint64, valAddr string) error

SuperfluidDelegate superfluid delegates osmo equivalent amount the given lock holds. The actual delegation is done by using/creating an intermediary account for the (denom, validator) pair and having the intermediary account delegate to the designated validator, not by the sender themselves. A state entry of IntermediaryAccountConnection is stored to store the connection between the lock ID and the intermediary account, as an intermediary account does not serve for delegations from a single delegator. The actual amount of delegation is not equal to the equivalent amount of osmo the lock has. That is, the actual amount of delegation is amount * osmo equivalent multiplier * (1 - k.RiskFactor(asset)).

func (Keeper) SuperfluidUnbondLock

func (k Keeper) SuperfluidUnbondLock(ctx sdk.Context, underlyingLockId uint64, sender string) error

SuperfluidUnbondLock unbonds the lock that has been used for superfluid staking. This method would return an error if the underlying lock is not superfluid undelegating.

func (Keeper) SuperfluidUndelegate

func (k Keeper) SuperfluidUndelegate(ctx sdk.Context, sender string, lockID uint64) error

SuperfluidUndelegate starts undelegating superfluid delegated position for the given lock. Undelegation is done instantly and the equivalent amount is sent to the module account where it is burnt. Note that this method does not include unbonding the lock itself.

func (Keeper) SuperfluidUndelegateAndUnbondLock

func (k Keeper) SuperfluidUndelegateAndUnbondLock(ctx sdk.Context, lockID uint64, sender string, amount osmomath.Int) (uint64, error)

SuperfluidUndelegateAndUnbondLock unbonds given amount from the underlying lock that has been used for superfluid staking. This method returns the lock id, same lock id if unlock amount is equal to the underlying lock amount. Otherwise it returns the newly created lock id. Note that we can either partially or fully undelegate and unbond lock using this method.

func (Keeper) SuperfluidUndelegateToConcentratedPosition

func (k Keeper) SuperfluidUndelegateToConcentratedPosition(ctx sdk.Context, sender string, gammLockID uint64) (types.SuperfluidIntermediaryAccount, error)

SuperfluidUndelegateToConcentratedPosition starts undelegating superfluid delegated position for the given lock. It behaves similarly to SuperfluidUndelegate, however it does not create a new synthetic lockup representing the unstaking side. This is because after the time this function is called, we might want to perform more operations prior to creating a lock. Once the actual lock is created, the synthetic lockup representing the unstaking side should eventually be created as well. Use this function with caution to avoid accidentally missing synthetic lock creation.

func (Keeper) TotalBondedTokens

func (k Keeper) TotalBondedTokens(ctx sdk.Context) osmomath.Int

TotalBondedTokens implements govtypes.StakingKeeper

func (Keeper) UnbondConvertAndStake

func (k Keeper) UnbondConvertAndStake(ctx sdk.Context, lockID uint64, sender, valAddr string,
	minAmtToStake osmomath.Int, sharesToConvert sdk.Coin) (totalAmtConverted osmomath.Int, err error)

UnbondConvertAndStake converts given lock to osmo and stakes it to given validator. Supports conversion of 1)superfluid bonded 2)superfluid undelegating 3)vanilla unlocking. Liquid gamm shares will not be supported for conversion. Delegation is done in the following logic: - If valAddr provided, single delegate. - If valAddr not provided and valset exists, valsetpref.Delegate - If valAddr not provided and valset delegation is not possible, refer back to original lock's superfluid validator if it was a superfluid lock - Else: error

func (Keeper) UnpoolAllowedPools

func (k Keeper) UnpoolAllowedPools(ctx sdk.Context, sender sdk.AccAddress, poolId uint64, lockId uint64) ([]uint64, error)

Returns a list of newly created lockIDs, or an error.

func (Keeper) UnriskAdjustOsmoValue

func (k Keeper) UnriskAdjustOsmoValue(ctx sdk.Context, amount osmomath.Dec) osmomath.Dec

func (Keeper) UpdateOsmoEquivalentMultipliers

func (k Keeper) UpdateOsmoEquivalentMultipliers(ctx sdk.Context, asset types.SuperfluidAsset, newEpochNumber int64) error

type MigrationType

type MigrationType int
const (
	SuperfluidBonded MigrationType = iota
	SuperfluidUnbonding
	NonSuperfluid
	Unlocked
	Unsupported
)

type Querier

type Querier struct {
	Keeper
}

Querier defines a wrapper around the x/superfluid keeper providing gRPC method handlers.

func NewQuerier

func NewQuerier(k Keeper) Querier

func (Querier) AllAssets

AllAssets Returns all superfluid assets info.

func (Querier) AllIntermediaryAccounts

AllIntermediaryAccounts returns all superfluid intermediary accounts.

func (Querier) AssetMultiplier

AssetMultiplier returns superfluid asset multiplier.

func (Querier) AssetType

AssetType Returns superfluid asset type.

func (Querier) ConnectedIntermediaryAccount

ConnectedIntermediaryAccount returns intermediary account connected to a superfluid staked lock by id.

func (Querier) EstimateSuperfluidDelegatedAmountByValidatorDenom

EstimateSuperfluidDelegatedAmountByValidatorDenom returns the amount of a specific denom delegated to a specific validator This is labeled an estimate, because the way it calculates the amount can lead rounding errors from the true delegated amount.

func (Querier) Params

Params returns the superfluid module params.

func (Querier) SuperfluidDelegationsByDelegator

SuperfluidDelegationsByDelegator returns all the superfluid poistions for a specific delegator.

func (Querier) SuperfluidDelegationsByValidatorDenom

SuperfluidDelegationsByValidatorDenom returns all the superfluid positions of a specific denom delegated to one validator.

func (Querier) SuperfluidUndelegationsByDelegator

SuperfluidUndelegationsByDelegator returns total amount undelegating by delegator.

func (Querier) TotalSuperfluidDelegations

TotalSuperfluidDelegations returns total amount of osmo delegated via superfluid staking.

func (Querier) UserConcentratedSuperfluidPositionsDelegated

UserConcentratedSuperfluidPositionsDelegated returns all the cl superfluid positions for the specified delegator across all concentrated pools that are bonded.

func (Querier) UserConcentratedSuperfluidPositionsUndelegating

UserConcentratedSuperfluidPositionsUndelegating returns all the cl superfluid positions for the specified delegator across all concentrated pools that are unbonding.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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