Documentation ¶
Overview ¶
nolint
Index ¶
- func GetInputPrice(inputAmt, inputReserve, outputReserve sdk.Int, fee sdk.Dec) sdk.Int
- func GetOutputPrice(outputAmt, inputReserve, outputReserve sdk.Int, fee sdk.Dec) sdk.Int
- func NewMsgServerImpl(keeper Keeper) types.MsgServer
- type Keeper
- func (k Keeper) AddLiquidity(ctx sdk.Context, msg *types.MsgAddLiquidity) (sdk.Coin, error)
- func (k Keeper) CreatePool(ctx sdk.Context, counterpartyDenom string) types.Pool
- func (k Keeper) DeductPoolCreationFee(ctx sdk.Context, creator sdk.AccAddress) error
- func (k Keeper) ExportGenesis(ctx sdk.Context) types.GenesisState
- func (k Keeper) GetAllPools(ctx sdk.Context) (pools []types.Pool)
- func (k Keeper) GetLptDenomFromDenoms(ctx sdk.Context, denom1, denom2 string) (string, error)
- func (k Keeper) GetMaximumSwapAmount(ctx sdk.Context, denom string) (sdk.Coin, error)
- func (k Keeper) GetParams(ctx sdk.Context) types.Params
- func (k Keeper) GetPool(ctx sdk.Context, poolId string) (types.Pool, bool)
- func (k Keeper) GetPoolBalances(ctx sdk.Context, escrowAddress string) (coins sdk.Coins, err error)
- func (k Keeper) GetPoolBalancesByLptDenom(ctx sdk.Context, lptDenom string) (coins sdk.Coins, err error)
- func (k Keeper) GetPoolByLptDenom(ctx sdk.Context, lptDenom string) (types.Pool, bool)
- func (k Keeper) GetStandardDenom(ctx sdk.Context) string
- func (k Keeper) InitGenesis(ctx sdk.Context, genState types.GenesisState)
- func (k Keeper) LiquidityPool(c context.Context, req *types.QueryLiquidityPoolRequest) (*types.QueryLiquidityPoolResponse, error)
- func (k Keeper) LiquidityPools(c context.Context, req *types.QueryLiquidityPoolsRequest) (*types.QueryLiquidityPoolsResponse, error)
- func (k Keeper) Logger(ctx sdk.Context) log.Logger
- func (k Keeper) Params(c context.Context, _ *types.QueryParamsRequest) (*types.QueryParamsResponse, error)
- func (k Keeper) RemoveLiquidity(ctx sdk.Context, msg *types.MsgRemoveLiquidity) (sdk.Coins, error)
- func (k Keeper) SetParams(ctx sdk.Context, params types.Params)
- func (k Keeper) SetStandardDenom(ctx sdk.Context, denom string)
- func (k Keeper) Swap(ctx sdk.Context, msg *types.MsgSwapOrder) error
- func (k Keeper) TradeExactInputForOutput(ctx sdk.Context, input types.Input, output types.Output) (sdk.Int, error)
- func (k Keeper) TradeInputForExactOutput(ctx sdk.Context, input types.Input, output types.Output) (sdk.Int, error)
- func (k Keeper) ValidatePool(ctx sdk.Context, lptDenom string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetInputPrice ¶
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 ¶
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 ¶
NewMsgServerImpl returns an implementation of the coinswap MsgServer interface for the provided Keeper.
Types ¶
type Keeper ¶
type Keeper struct {
// contains filtered or unexported fields
}
Keeper of the coinswap store
func NewKeeper ¶
func NewKeeper( cdc codec.BinaryCodec, key sdk.StoreKey, paramSpace paramstypes.Subspace, bk types.BankKeeper, ak types.AccountKeeper, blockedAddrs map[string]bool, feeCollectorName string, ) 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 ¶
AddLiquidity adds liquidity to the specified pool
func (Keeper) CreatePool ¶
CreatePool create a liquidity that saves relevant information about popular pool tokens
func (Keeper) DeductPoolCreationFee ¶
DeductPoolCreationFee performs fee handling for creating liquidity pool
func (Keeper) ExportGenesis ¶
func (k Keeper) ExportGenesis(ctx sdk.Context) types.GenesisState
ExportGenesis returns the coinswap module's genesis state.
func (Keeper) GetAllPools ¶
GetAllPools return all the liquidity pools
func (Keeper) GetLptDenomFromDenoms ¶
GetLptDenomFromDenoms returns the liquidity pool token denom for the provided denominations.
func (Keeper) GetMaximumSwapAmount ¶
func (Keeper) GetPoolBalances ¶
GetPoolBalances return the liquidity pool by the specified anotherCoinDenom
func (Keeper) GetPoolBalancesByLptDenom ¶
func (Keeper) GetPoolByLptDenom ¶
GetPoolByLptDenom return the liquidity pool by the specified anotherCoinDenom
func (Keeper) GetStandardDenom ¶
GetStandardDenom returns the standard denom of the coinswap module.
func (Keeper) InitGenesis ¶
func (k Keeper) InitGenesis(ctx sdk.Context, genState types.GenesisState)
InitGenesis initializes the coinswap module's state from a given genesis state.
func (Keeper) LiquidityPool ¶
func (k Keeper) LiquidityPool(c context.Context, req *types.QueryLiquidityPoolRequest) (*types.QueryLiquidityPoolResponse, error)
LiquidityPool returns the liquidity pool information of the denom
func (Keeper) LiquidityPools ¶
func (k Keeper) LiquidityPools(c context.Context, req *types.QueryLiquidityPoolsRequest) (*types.QueryLiquidityPoolsResponse, error)
func (Keeper) Params ¶
func (k Keeper) Params(c context.Context, _ *types.QueryParamsRequest) (*types.QueryParamsResponse, error)
Params queries the parameters of the liquidity module.
func (Keeper) RemoveLiquidity ¶
RemoveLiquidity removes liquidity from the specified pool
func (Keeper) SetStandardDenom ¶
SetStandardDenom sets the standard denom for the coinswap module.
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