keeper

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2021 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllInvariants

func AllInvariants(keeper Keeper, bk types.BankKeeper) sdk.Invariant

AllInvariants runs all invariants of the gamm module

func NewMsgServerImpl

func NewMsgServerImpl(keeper Keeper) types.MsgServer

func PoolAccountInvariant

func PoolAccountInvariant(keeper Keeper, bk types.BankKeeper) sdk.Invariant

PoolAccountInvariant checks that the pool account balance reflects the sum of pool assets

func PoolProductConstantInvariant

func PoolProductConstantInvariant(keeper Keeper) sdk.Invariant

PoolProductContantInvariant chekcs that the pool constant invariant V where V = product([asset_balance_n^asset_weight_n]) holds. The invariant increases with positive swap fee, and decresed upon liquidity removal.

func PoolTotalWeightInvariant

func PoolTotalWeightInvariant(keeper Keeper, bk types.BankKeeper) sdk.Invariant

PoolTotalWeightInvariant checks that the pool total weight reflect the sum of pool weights

func RegisterInvariants

func RegisterInvariants(ir sdk.InvariantRegistry, keeper Keeper, bk types.BankKeeper)

RegisterInvariants registers all governance invariants

Types

type Keeper

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

func NewKeeper

func NewKeeper(cdc codec.BinaryMarshaler, storeKey sdk.StoreKey, accountKeeper types.AccountKeeper, bankKeeper types.BankKeeper) Keeper

func (Keeper) BurnPoolShareFromAccount

func (k Keeper) BurnPoolShareFromAccount(ctx sdk.Context, pool types.PoolI, addr sdk.AccAddress, amount sdk.Int) error

BurnPoolShareFromAccount burns `amount` of the given pools shares held by `addr`.

func (Keeper) CalculateSpotPrice

func (k Keeper) CalculateSpotPrice(ctx sdk.Context, poolId uint64, tokenInDenom, tokenOutDenom string) (sdk.Dec, error)

func (Keeper) CalculateSpotPriceWithSwapFee

func (k Keeper) CalculateSpotPriceWithSwapFee(ctx sdk.Context, poolId uint64, tokenInDenom, tokenOutDenom string) (sdk.Dec, error)

func (Keeper) CreatePool

func (k Keeper) CreatePool(
	ctx sdk.Context,
	sender sdk.AccAddress,
	poolParams types.PoolParams,
	poolAssets []types.PoolAsset,
	futurePoolGovernor string,
) (uint64, error)

func (Keeper) ExitPool

func (k Keeper) ExitPool(
	ctx sdk.Context,
	sender sdk.AccAddress,
	poolId uint64,
	shareInAmount sdk.Int,
	tokenOutMins sdk.Coins,
) (err error)

func (Keeper) ExitSwapExternAmountOut

func (k Keeper) ExitSwapExternAmountOut(
	ctx sdk.Context,
	sender sdk.AccAddress,
	poolId uint64,
	tokenOut sdk.Coin,
	shareInMaxAmount sdk.Int,
) (shareInAmount sdk.Int, err error)

func (Keeper) ExitSwapShareAmountIn

func (k Keeper) ExitSwapShareAmountIn(
	ctx sdk.Context,
	sender sdk.AccAddress,
	poolId uint64,
	tokenOutDenom string,
	shareInAmount sdk.Int,
	tokenOutMinAmount sdk.Int,
) (tokenOutAmount sdk.Int, err error)

func (Keeper) GetNextPoolNumber added in v1.0.4

func (k Keeper) GetNextPoolNumber(ctx sdk.Context) uint64

GetNextPoolNumber returns the next pool number

func (Keeper) GetPool

func (k Keeper) GetPool(ctx sdk.Context, poolId uint64) (types.PoolI, error)

func (Keeper) GetPools

func (k Keeper) GetPools(ctx sdk.Context) (res []types.PoolI, err error)

func (Keeper) GetTotalLiquidity

func (k Keeper) GetTotalLiquidity(ctx sdk.Context) sdk.Coins

func (Keeper) JoinPool

func (k Keeper) JoinPool(
	ctx sdk.Context,
	sender sdk.AccAddress,
	poolId uint64,
	shareOutAmount sdk.Int,
	tokenInMaxs sdk.Coins,
) (err error)

func (Keeper) JoinSwapExternAmountIn

func (k Keeper) JoinSwapExternAmountIn(
	ctx sdk.Context,
	sender sdk.AccAddress,
	poolId uint64,
	tokenIn sdk.Coin,
	shareOutMinAmount sdk.Int,
) (shareOutAmount sdk.Int, err error)

func (Keeper) JoinSwapShareAmountOut

func (k Keeper) JoinSwapShareAmountOut(
	ctx sdk.Context,
	sender sdk.AccAddress,
	poolId uint64,
	tokenInDenom string,
	shareOutAmount sdk.Int,
	tokenInMaxAmount sdk.Int,
) (tokenInAmount sdk.Int, err error)

func (Keeper) MarshalPool

func (k Keeper) MarshalPool(pool types.PoolI) ([]byte, error)

func (Keeper) MintPoolShareToAccount

func (k Keeper) MintPoolShareToAccount(ctx sdk.Context, pool types.PoolI, addr sdk.AccAddress, amount sdk.Int) error

func (Keeper) MultihopSwapExactAmountIn

func (k Keeper) MultihopSwapExactAmountIn(
	ctx sdk.Context,
	sender sdk.AccAddress,
	routes []types.SwapAmountInRoute,
	tokenIn sdk.Coin,
	tokenOutMinAmount sdk.Int,
) (tokenOutAmount sdk.Int, err error)

MultihopSwapExactAmountIn defines the input denom and input amount for the first pool, the output of the first pool is chained as the input for the next routed pool transaction succeeds when final amount out is greater than tokenOutMinAmount defined

func (Keeper) MultihopSwapExactAmountOut

func (k Keeper) MultihopSwapExactAmountOut(
	ctx sdk.Context,
	sender sdk.AccAddress,
	routes []types.SwapAmountOutRoute,
	tokenInMaxAmount sdk.Int,
	tokenOut sdk.Coin,
) (tokenInAmount sdk.Int, err error)

MultihopSwapExactAmountOut defines the output denom and output amount for the last pool. Calculation starts by providing the tokenOutAmount of the final pool to calculate the required tokenInAmount the calculated tokenInAmount is used as defined tokenOutAmount of the previous pool, calculating in reverse order of the swap Transaction succeeds if the calculated tokenInAmount of the first pool is less than the defined tokenInMaxAmount defined.

func (Keeper) NumPools

func (Keeper) Pool

func (Keeper) Pools

func (Keeper) RecordTotalLiquidityDecrease

func (k Keeper) RecordTotalLiquidityDecrease(ctx sdk.Context, coins sdk.Coins)

func (Keeper) RecordTotalLiquidityIncrease

func (k Keeper) RecordTotalLiquidityIncrease(ctx sdk.Context, coins sdk.Coins)

func (*Keeper) SetHooks

func (k *Keeper) SetHooks(gh types.GammHooks) *Keeper

Set the gamm hooks

func (Keeper) SetNextPoolNumber added in v1.0.4

func (k Keeper) SetNextPoolNumber(ctx sdk.Context, poolNumber uint64)

SetNextPoolNumber sets next pool number

func (Keeper) SetPool

func (k Keeper) SetPool(ctx sdk.Context, pool types.PoolI) error

func (Keeper) SetTotalLiquidity

func (k Keeper) SetTotalLiquidity(ctx sdk.Context, coins sdk.Coins)

func (Keeper) SwapExactAmountIn

func (k Keeper) SwapExactAmountIn(
	ctx sdk.Context,
	sender sdk.AccAddress,
	poolId uint64,
	tokenIn sdk.Coin,
	tokenOutDenom string,
	tokenOutMinAmount sdk.Int,
) (tokenOutAmount sdk.Int, spotPriceAfter sdk.Dec, err error)

func (Keeper) SwapExactAmountOut

func (k Keeper) SwapExactAmountOut(
	ctx sdk.Context,
	sender sdk.AccAddress,
	poolId uint64,
	tokenInDenom string,
	tokenInMaxAmount sdk.Int,
	tokenOut sdk.Coin,
) (tokenInAmount sdk.Int, spotPriceAfter sdk.Dec, err error)

func (Keeper) UnmarshalPool

func (k Keeper) UnmarshalPool(bz []byte) (types.PoolI, error)

Jump to

Keyboard shortcuts

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