keeper

package
v0.10.0-rc.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const MaxPageLimit = 200

Variables

This section is empty.

Functions

func CalcLiquidityFee

func CalcLiquidityFee(toRowan bool, normalizationFactor sdk.Dec, adjustExternalToken bool, X, x, Y sdk.Uint) (sdk.Uint, error)

func CalcSwapResult

func CalcSwapResult(toRowan bool, normalizationFactor sdk.Dec, adjustExternalToken bool, X, x, Y sdk.Uint) (sdk.Uint, error)

func CalculateAllAssetsForLP

func CalculateAllAssetsForLP(pool types.Pool, lp types.LiquidityProvider) (sdk.Uint, sdk.Uint, sdk.Uint, sdk.Uint)

func CalculatePoolUnits

func CalculatePoolUnits(oldPoolUnits, nativeAssetBalance, externalAssetBalance, nativeAssetAmount,
	externalAssetAmount sdk.Uint, normalizationFactor sdk.Dec, adjustExternalToken bool) (sdk.Uint, sdk.Uint, error)

func CalculateWithdrawal

func CalculateWithdrawal(poolUnits sdk.Uint, nativeAssetBalance string,
	externalAssetBalance string, lpUnits string, wBasisPoints string, asymmetry sdk.Int) (sdk.Uint, sdk.Uint, sdk.Uint, sdk.Uint)

More details on the formula https://github.com/Sifchain/sifnode/blob/develop/docs/1.Liquidity%20Pools%20Architecture.md

func GetMinLen

func GetMinLen(inputs []sdk.Uint) int64

func GetSwapFee

func GetSwapFee(sentAmount sdk.Uint, to types.Asset, pool types.Pool, normalizationFactor sdk.Dec, adjustExternalToken bool) sdk.Uint

func IncreasePrecision

func IncreasePrecision(dec sdk.Dec, po int64) sdk.Dec

func NewMsgServerImpl

func NewMsgServerImpl(keeper Keeper) types.MsgServer

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

func NewQuerier

func NewQuerier(keeper Keeper, legacyQuerierCdc *codec.LegacyAmino) sdk.Querier

NewQuerier is the module level router for state queries

func ReducePrecision

func ReducePrecision(dec sdk.Dec, po int64) sdk.Dec

func SetInputs

func SetInputs(sentAmount sdk.Uint, to types.Asset, pool types.Pool) (sdk.Uint, sdk.Uint, sdk.Uint, bool)

func SwapOne

func SwapOne(from types.Asset, sentAmount sdk.Uint, to types.Asset, pool types.Pool, normalizationFactor sdk.Dec, adjustExternalToken bool) (sdk.Uint, sdk.Uint, sdk.Uint, types.Pool, error)

------------------------------------------------------------------------------------------------------------------ More details on the formula https://github.com/Sifchain/sifnode/blob/develop/docs/1.Liquidity%20Pools%20Architecture.md

func ValidateZero

func ValidateZero(inputs []sdk.Uint) bool

Types

type Keeper

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

Keeper of the clp store

func NewKeeper

func NewKeeper(cdc codec.BinaryCodec, key sdk.StoreKey, bankkeeper types.BankKeeper, accountKeeper types.AuthKeeper, tokenRegistryKeeper tokenregistrytypes.Keeper, ps paramtypes.Subspace) Keeper

NewKeeper creates a clp keeper

func (Keeper) AddLiquidity

func (k Keeper) AddLiquidity(ctx sdk.Context, msg *types.MsgAddLiquidity, pool types.Pool, newPoolUnits sdk.Uint, lpUnits sdk.Uint) (*types.LiquidityProvider, error)

func (Keeper) Codec

func (k Keeper) Codec() codec.BinaryCodec

func (Keeper) CreateLiquidityProvider

func (k Keeper) CreateLiquidityProvider(ctx sdk.Context, asset *types.Asset, lpunits sdk.Uint, lpaddress sdk.AccAddress) types.LiquidityProvider

func (Keeper) CreatePool

func (k Keeper) CreatePool(ctx sdk.Context, poolUints sdk.Uint, msg *types.MsgCreatePool) (*types.Pool, error)

func (Keeper) DecommissionPool

func (k Keeper) DecommissionPool(ctx sdk.Context, pool types.Pool) error

func (Keeper) DestroyLiquidityProvider

func (k Keeper) DestroyLiquidityProvider(ctx sdk.Context, symbol string, lpAddress string)

func (Keeper) DestroyPool

func (k Keeper) DestroyPool(ctx sdk.Context, symbol string) error

func (Keeper) Exists

func (k Keeper) Exists(ctx sdk.Context, key []byte) bool

func (Keeper) ExistsClpWhiteList

func (k Keeper) ExistsClpWhiteList(ctx sdk.Context) bool

func (Keeper) ExistsPool

func (k Keeper) ExistsPool(ctx sdk.Context, symbol string) bool

func (Keeper) FinalizeSwap

func (k Keeper) FinalizeSwap(ctx sdk.Context, sentAmount string, finalPool types.Pool, msg types.MsgSwap) error

func (Keeper) GetAllLiquidityProvidersPaginated

func (k Keeper) GetAllLiquidityProvidersPaginated(ctx sdk.Context,
	pagination *query.PageRequest) ([]*types.LiquidityProvider, *query.PageResponse, error)

func (Keeper) GetAssetsForLiquidityProviderPaginated

func (k Keeper) GetAssetsForLiquidityProviderPaginated(ctx sdk.Context, lpAddress sdk.AccAddress,
	pagination *query.PageRequest) ([]*types.Asset, *query.PageResponse, error)

func (Keeper) GetAuthKeeper

func (k Keeper) GetAuthKeeper() types.AuthKeeper

func (Keeper) GetBankKeeper

func (k Keeper) GetBankKeeper() types.BankKeeper

func (Keeper) GetClpWhiteList

func (k Keeper) GetClpWhiteList(ctx sdk.Context) []sdk.AccAddress

func (Keeper) GetLiquidityProvider

func (k Keeper) GetLiquidityProvider(ctx sdk.Context, symbol string, lpAddress string) (types.LiquidityProvider, error)

func (Keeper) GetLiquidityProviderIterator

func (k Keeper) GetLiquidityProviderIterator(ctx sdk.Context) sdk.Iterator

func (Keeper) GetLiquidityProvidersForAssetPaginated

func (k Keeper) GetLiquidityProvidersForAssetPaginated(ctx sdk.Context, asset types.Asset,
	pagination *query.PageRequest) ([]*types.LiquidityProvider, *query.PageResponse, error)

func (Keeper) GetMinCreatePoolThreshold

func (k Keeper) GetMinCreatePoolThreshold(ctx sdk.Context) (res uint64)

func (Keeper) GetNormalizationFactor

func (k Keeper) GetNormalizationFactor(decimals int64) (sdk.Dec, bool)

func (Keeper) GetParams

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

func (Keeper) GetPool

func (k Keeper) GetPool(ctx sdk.Context, symbol string) (types.Pool, error)

func (Keeper) GetPools deprecated

func (k Keeper) GetPools(ctx sdk.Context) []*types.Pool

Deprecated: GetPools use GetPoolsPaginated

func (Keeper) GetPoolsIterator

func (k Keeper) GetPoolsIterator(ctx sdk.Context) sdk.Iterator

func (Keeper) GetPoolsPaginated

func (k Keeper) GetPoolsPaginated(ctx sdk.Context, pagination *query.PageRequest) ([]*types.Pool, *query.PageResponse, error)

func (Keeper) HasBalance

func (k Keeper) HasBalance(ctx sdk.Context, addr sdk.AccAddress, coin sdk.Coin) bool

func (Keeper) InitiateSwap

func (k Keeper) InitiateSwap(ctx sdk.Context, sentCoin sdk.Coin, swapper sdk.AccAddress) error

func (Keeper) Logger

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

Logger returns a module-specific logger.

func (Keeper) ParseToInt

func (k Keeper) ParseToInt(nu string) (sdk.Int, bool)

Use strings instead of Unit/Int in between conventions

func (Keeper) RemoveLiquidity

func (k Keeper) RemoveLiquidity(ctx sdk.Context, pool types.Pool, externalAssetCoin sdk.Coin,
	nativeAssetCoin sdk.Coin, lp types.LiquidityProvider, lpUnitsLeft, poolOriginalEB, poolOriginalNB sdk.Uint) error

func (Keeper) RemoveLiquidityProvider

func (k Keeper) RemoveLiquidityProvider(ctx sdk.Context, coins sdk.Coins, lp types.LiquidityProvider) error

func (Keeper) SendCoins

func (k Keeper) SendCoins(ctx sdk.Context, from sdk.AccAddress, to sdk.AccAddress, coins sdk.Coins) error

func (Keeper) SetClpWhiteList

func (k Keeper) SetClpWhiteList(ctx sdk.Context, validatorList []sdk.AccAddress)

func (Keeper) SetLiquidityProvider

func (k Keeper) SetLiquidityProvider(ctx sdk.Context, lp *types.LiquidityProvider)

func (Keeper) SetParams

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

set the params

func (Keeper) SetPool

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

func (Keeper) ValidateAddress

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

func (Keeper) ValidatePool

func (k Keeper) ValidatePool(pool types.Pool) bool

type Querier

type Querier struct {
	Keeper Keeper
}

Querier is used as Keeper will have duplicate methods if used directly, and gRPC names take precedence over keeper

func (Querier) GetAssetList

func (k Querier) GetAssetList(c context.Context, req *types.AssetListReq) (*types.AssetListRes, error)

func (Querier) GetLiquidityProvider

func (k Querier) GetLiquidityProvider(c context.Context, req *types.LiquidityProviderReq) (*types.LiquidityProviderRes, error)

func (Querier) GetLiquidityProviders

func (k Querier) GetLiquidityProviders(c context.Context, req *types.LiquidityProvidersReq) (*types.LiquidityProvidersRes, error)

func (Querier) GetPool

func (k Querier) GetPool(c context.Context, req *types.PoolReq) (*types.PoolRes, error)

func (Querier) GetPools

func (k Querier) GetPools(c context.Context, req *types.PoolsReq) (*types.PoolsRes, error)

Jump to

Keyboard shortcuts

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