keeper

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2021 License: Apache-2.0 Imports: 14 Imported by: 21

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetInputPrice

func GetInputPrice(inputAmt, inputReserve, outputReserve sdk.Int, fee sdk.Dec) sdk.Int

GetInputPrice returns the amount of coins bought (calculated) given the input amount being sold (exact) The fee is included in the input coins being bought https://github.com/runtimeverification/verified-smart-contracts/blob/uniswap/uniswap/x-y-k.pdf

func GetOutputPrice

func GetOutputPrice(outputAmt, inputReserve, outputReserve sdk.Int, fee sdk.Dec) sdk.Int

GetOutputPrice returns the amount of coins sold (calculated) given the output amount being bought (exact) The fee is included in the output coins being bought

func NewMsgServerImpl added in v1.2.0

func NewMsgServerImpl(keeper Keeper) types.MsgServer

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

func NewQuerier

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

NewQuerier creates a querier for coinswap REST endpoints

Types

type Keeper

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

Keeper of the coinswap store

func NewKeeper

func NewKeeper(
	cdc codec.Marshaler,
	key sdk.StoreKey,
	paramSpace paramstypes.Subspace,
	bk types.BankKeeper,
	ak types.AccountKeeper,
	blockedAddrs map[string]bool,
) Keeper

NewKeeper returns a coinswap keeper. It handles: - creating new ModuleAccounts for each trading pair - burning and minting liquidity coins - sending to and from ModuleAccounts

func (Keeper) AddLiquidity

func (k Keeper) AddLiquidity(ctx sdk.Context, msg *types.MsgAddLiquidity) (sdk.Coin, error)

AddLiquidity adds liquidity to the specified pool

func (Keeper) GetParams

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

GetParams gets the parameters for the coinswap module.

func (Keeper) GetReservePool

func (k Keeper) GetReservePool(ctx sdk.Context, uniDenom string) (coins sdk.Coins, err error)

GetReservePool returns the total balance of the reserve pool at the provided denomination.

func (Keeper) GetStandardDenom added in v1.2.0

func (k Keeper) GetStandardDenom(ctx sdk.Context) string

GetStandardDenom returns the standard denom of the coinswap module.

func (Keeper) GetUniDenomFromDenoms

func (k Keeper) GetUniDenomFromDenoms(ctx sdk.Context, denom1, denom2 string) (string, error)

GetUniDenomFromDenoms returns the uni denom for the provided denominations.

func (Keeper) Liquidity

Liquidity returns the liquidity pool information of the denom

func (Keeper) Logger

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

Logger returns a module-specific logger.

func (Keeper) RemoveLiquidity

func (k Keeper) RemoveLiquidity(ctx sdk.Context, msg *types.MsgRemoveLiquidity) (sdk.Coins, error)

RemoveLiquidity removes liquidity from the specified pool

func (Keeper) SetParams

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

SetParams sets the parameters for the coinswap module.

func (Keeper) SetStandardDenom added in v1.2.0

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

SetStandardDenom sets the standard denom for the coinswap module.

func (Keeper) Swap

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

Swap execute swap order in specified pool

func (Keeper) TradeExactInputForOutput

func (k Keeper) TradeExactInputForOutput(ctx sdk.Context, input types.Input, output types.Output) (sdk.Int, error)

* Sell exact amount of a token for buying another, one of them must be standard token @param input: exact amount of the token to be sold @param output: min amount of the token to be bought @param sender: address of the sender @param receipt: address of the receiver @return: actual amount of the token to be bought

func (Keeper) TradeInputForExactOutput

func (k Keeper) TradeInputForExactOutput(ctx sdk.Context, input types.Input, output types.Output) (sdk.Int, error)

* Buy exact amount of a token by specifying the max amount of another token, one of them must be standard token @param input : max amount of the token to be paid @param output : exact amount of the token to be bought @param sender : address of the sender @param receipt : address of the receiver @return : actual amount of the token to be paid

Jump to

Keyboard shortcuts

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