keeper

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: Apache-2.0 Imports: 23 Imported by: 22

Documentation

Overview

nolint

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetInputPrice

func GetInputPrice(inputAmt, inputReserve, outputReserve sdkmath.Int, fee sdk.Dec) sdkmath.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 sdkmath.Int, fee sdk.Dec) sdkmath.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.

Types

type Keeper

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

Keeper of the coinswap store

func NewKeeper

func NewKeeper(
	cdc codec.BinaryCodec,
	key storetypes.StoreKey,
	bk types.BankKeeper,
	ak types.AccountKeeper,
	feeCollectorName string,
	authority 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

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

AddLiquidity adds liquidity to the specified pool

func (Keeper) AddUnilateralLiquidity added in v1.7.0

func (k Keeper) AddUnilateralLiquidity(
	ctx sdk.Context,
	msg *types.MsgAddUnilateralLiquidity,
) (sdk.Coin, error)

AddUnilateralLiquidity adds liquidity unilaterally to the specified pool

func (Keeper) CreatePool added in v1.5.0

func (k Keeper) CreatePool(ctx sdk.Context, counterpartyDenom string) types.Pool

CreatePool create a liquidity that saves relevant information about popular pool tokens

func (Keeper) DeductPoolCreationFee added in v1.5.2

func (k Keeper) DeductPoolCreationFee(ctx sdk.Context, creator sdk.AccAddress) error

DeductPoolCreationFee performs fee handling for creating liquidity pool

func (Keeper) ExportGenesis added in v1.5.0

func (k Keeper) ExportGenesis(ctx sdk.Context) types.GenesisState

ExportGenesis returns the coinswap module's genesis state.

func (Keeper) GetAllPools added in v1.5.0

func (k Keeper) GetAllPools(ctx sdk.Context) (pools []types.Pool)

GetAllPools return all the liquidity pools

func (Keeper) GetLptDenomFromDenoms added in v1.5.0

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

GetLptDenomFromDenoms returns the liquidity pool token denom for the provided denominations.

func (Keeper) GetParams

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

GetParams sets the coinswap module parameters.

func (Keeper) GetPool added in v1.5.0

func (k Keeper) GetPool(ctx sdk.Context, poolId string) (types.Pool, bool)

GetPool return the liquidity pool by the specified anotherCoinDenom

func (Keeper) GetPoolBalances added in v1.5.0

func (k Keeper) GetPoolBalances(
	ctx sdk.Context,
	escrowAddress string,
) (coins sdk.Coins, err error)

GetPoolBalances return the liquidity pool by the specified anotherCoinDenom

func (Keeper) GetPoolBalancesByLptDenom added in v1.5.0

func (k Keeper) GetPoolBalancesByLptDenom(
	ctx sdk.Context,
	lptDenom string,
) (coins sdk.Coins, err error)

func (Keeper) GetPoolByLptDenom added in v1.5.0

func (k Keeper) GetPoolByLptDenom(ctx sdk.Context, lptDenom string) (types.Pool, bool)

GetPoolByLptDenom return the liquidity pool by the specified anotherCoinDenom

func (Keeper) GetPoolBySequenceId added in v1.7.0

func (k Keeper) GetPoolBySequenceId(ctx sdk.Context, poolId uint64) (types.Pool, bool)

GetPoolBySequenceId return the pool by unique identifier

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) InitGenesis added in v1.5.0

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 added in v1.5.0

LiquidityPool returns the liquidity pool information of the denom

func (Keeper) LiquidityPools added in v1.5.0

func (Keeper) Logger

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

Logger returns a module-specific logger.

func (Keeper) Params added in v1.8.0

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) RemoveUnilateralLiquidity added in v1.7.0

func (k Keeper) RemoveUnilateralLiquidity(
	ctx sdk.Context,
	msg *types.MsgRemoveUnilateralLiquidity,
) (sdk.Coins, error)

RemoveUnilateralLiquidity removes liquidity unilaterally from the specified pool

func (Keeper) SetParams

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

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) (sdkmath.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) (sdkmath.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

func (Keeper) ValidatePool added in v1.5.0

func (k Keeper) ValidatePool(ctx sdk.Context, lptDenom string) error

ValidatePool Verify the legitimacy of the liquidity pool

type Migrator added in v1.5.0

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

Migrator is a struct for handling in-place store migrations.

func NewMigrator added in v1.5.0

func NewMigrator(k Keeper, legacySubspace exported.Subspace) Migrator

NewMigrator returns a new Migrator.

func (Migrator) Migrate1to2 added in v1.5.0

func (m Migrator) Migrate1to2(ctx sdk.Context) error

Migrate1to2 migrates from version 1 to 2.

func (Migrator) Migrate2to3 added in v1.5.2

func (m Migrator) Migrate2to3(ctx sdk.Context) error

Migrate1to2 migrates from version 2 to 3.

func (Migrator) Migrate3to4 added in v1.7.0

func (m Migrator) Migrate3to4(ctx sdk.Context) error

Migrate1to2 migrates from version 3 to 4.

func (Migrator) Migrate4to5 added in v1.8.0

func (m Migrator) Migrate4to5(ctx sdk.Context) error

Migrate1to2 migrates from version 4 to 5.

Jump to

Keyboard shortcuts

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