keeper

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMsgServerImpl

func NewMsgServerImpl(keeper Keeper) types.MsgServer

NewMsgServerImpl returns an implementation of the liquid MsgServer interface for the provided Keeper.

func NewQueryServerImpl

func NewQueryServerImpl(k Keeper) types.QueryServer

NewQueryServerImpl creates a new server for handling gRPC queries.

Types

type Keeper

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

Keeper struct for the liquid module.

func NewDefaultKeeper

NewDefaultKeeper returns a new keeper for the liquid module with default values.

func NewKeeper

func NewKeeper(
	cdc codec.Codec,
	ak types.AccountKeeper, bk types.BankKeeper, sk types.StakingKeeper, dk types.DistributionKeeper,
	derivativeDenom string,
) Keeper

NewKeeper returns a new keeper for the liquid module.

func (Keeper) BurnDerivative

func (k Keeper) BurnDerivative(ctx sdk.Context, delegatorAddr sdk.AccAddress, valAddr sdk.ValAddress, amount sdk.Coin) (sdk.Dec, error)

BurnDerivative burns an user's staking derivative coins and returns them an equivalent staking delegation.

The derivative coins are burned, and an equivalent number of shares in the module's staking delegation are transferred back to the user.

func (Keeper) CalculateDerivativeSharesFromTokens

func (k Keeper) CalculateDerivativeSharesFromTokens(ctx sdk.Context, delegator sdk.AccAddress, validator sdk.ValAddress, tokens sdkmath.Int) (sdkmath.Int, sdk.Dec, error)

CalculateDerivativeSharesFromTokens converts a staking token amount into its equivalent delegation shares, and staking derivative amount. This combines the code for calculating the shares to be transferred, and the derivative coins to be minted.

func (Keeper) CollectStakingRewards

func (k Keeper) CollectStakingRewards(
	ctx sdk.Context,
	validator sdk.ValAddress,
	destinationModAccount string,
) (sdk.Coins, error)

func (Keeper) CollectStakingRewardsByDenom

func (k Keeper) CollectStakingRewardsByDenom(
	ctx sdk.Context,
	derivativeDenom string,
	destinationModAccount string,
) (sdk.Coins, error)

func (Keeper) DerivativeFromTokens

func (k Keeper) DerivativeFromTokens(ctx sdk.Context, valAddr sdk.ValAddress, tokens sdk.Coin) (sdk.Coin, error)

DerivativeFromTokens calculates the approximate amount of derivative coins that would be minted for a given amount of staking tokens.

func (Keeper) GetDerivativeValue

func (k Keeper) GetDerivativeValue(ctx sdk.Context, denom string) (sdk.Coin, error)

GetDerivativeValue returns the total underlying value of the provided derivative denominated by the bond token (ufury).

func (Keeper) GetLiquidStakingTokenDenom

func (k Keeper) GetLiquidStakingTokenDenom(valAddr sdk.ValAddress) string

func (Keeper) GetStakedTokensForDerivatives

func (k Keeper) GetStakedTokensForDerivatives(ctx sdk.Context, coins sdk.Coins) (sdk.Coin, error)

GetStakedTokensForDerivatives returns the total value of the provided derivatives in staked tokens, accounting for the specific share prices.

func (Keeper) GetTotalDerivativeValue

func (k Keeper) GetTotalDerivativeValue(ctx sdk.Context) (sdk.Coin, error)

GetTotalDerivativeValue returns the total sum value of all derivative coins for all validators denominated by the bond token (ufury).

func (Keeper) IsDerivativeDenom

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

IsDerivativeDenom returns true if the denom is a valid derivative denom and corresponds to a valid validator.

func (Keeper) Logger

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

Logger returns a module-specific logger.

func (Keeper) MintDerivative

func (k Keeper) MintDerivative(ctx sdk.Context, delegatorAddr sdk.AccAddress, valAddr sdk.ValAddress, amount sdk.Coin) (sdk.Coin, error)

MintDerivative removes a user's staking delegation and mints them equivalent staking derivative coins.

The input staking token amount is used to calculate shares in the user's delegation, which are transferred to a delegation owned by the module. Derivative coins are them minted and transferred to the user.

func (Keeper) TransferDelegation

func (k Keeper) TransferDelegation(ctx sdk.Context, valAddr sdk.ValAddress, fromDelegator, toDelegator sdk.AccAddress, shares sdk.Dec) (sdk.Dec, error)

TransferDelegation moves some delegation shares between addresses, while keeping the same validator.

Internally shares are unbonded, tokens moved then bonded again. This limits only vested tokens from being transferred. The sending delegation must not have any active redelegations. A validator cannot reduce self delegated shares below its min self delegation. Attempting to transfer zero shares will error.

Jump to

Keyboard shortcuts

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