Documentation ¶
Overview ¶
This file implements the poolmanagertypes.PoolModule interface
Index ¶
- func NewCosmWasmPoolProposalHandler(k Keeper) govtypes.Handler
- func NewMsgCreatorServerImpl(keeper *Keeper) model.MsgCreatorServer
- func NewMsgServerImpl(keeper *Keeper) types.MsgServer
- type Keeper
- func (k Keeper) CalcInAmtGivenOut(ctx sdk.Context, poolI poolmanagertypes.PoolI, tokenOut sdk.Coin, ...) (tokenIn sdk.Coin, err error)
- func (k Keeper) CalcOutAmtGivenIn(ctx sdk.Context, poolI poolmanagertypes.PoolI, tokenIn sdk.Coin, ...) (tokenOut sdk.Coin, err error)
- func (k Keeper) CalculateSpotPrice(ctx sdk.Context, poolId uint64, quoteAssetDenom string, baseAssetDenom string) (price osmomath.BigDec, err error)
- func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState
- func (k Keeper) GetCodeIdByPoolId(ctx sdk.Context, poolId uint64) (sdk.AccAddress, uint64, error)
- func (k Keeper) GetParams(ctx sdk.Context) (params types.Params)
- func (k Keeper) GetPool(ctx sdk.Context, poolId uint64) (poolmanagertypes.PoolI, error)
- func (k Keeper) GetPoolById(ctx sdk.Context, poolId uint64) (types.CosmWasmExtension, error)
- func (k Keeper) GetPoolDenoms(ctx sdk.Context, poolId uint64) (denoms []string, err error)
- func (k Keeper) GetPools(ctx sdk.Context) ([]poolmanagertypes.PoolI, error)
- func (k Keeper) GetPoolsSerializable(ctx sdk.Context) ([]poolmanagertypes.PoolI, error)
- func (k Keeper) GetPoolsWithWasmKeeper(ctx sdk.Context) ([]poolmanagertypes.PoolI, error)
- func (k Keeper) GetSerializedPools(ctx sdk.Context, pagination *query.PageRequest) ([]*codectypes.Any, *query.PageResponse, error)
- func (k Keeper) GetTotalLiquidity(ctx sdk.Context) (sdk.Coins, error)
- func (k Keeper) GetTotalPoolLiquidity(ctx sdk.Context, poolId uint64) (sdk.Coins, error)
- func (k *Keeper) InitGenesis(ctx sdk.Context, gen *types.GenesisState, unpacker codectypes.AnyUnpacker)
- func (k Keeper) InitializePool(ctx sdk.Context, pool poolmanagertypes.PoolI, creatorAddress sdk.AccAddress) error
- func (k *Keeper) SetContractKeeper(contractKeeper types.ContractKeeper)
- func (k Keeper) SetParam(ctx sdk.Context, key []byte, value interface{})
- func (k Keeper) SetParams(ctx sdk.Context, params types.Params)
- func (k Keeper) SetPool(ctx sdk.Context, pool types.CosmWasmExtension)
- func (k *Keeper) SetPoolManagerKeeper(poolmanagerKeeper types.PoolManagerKeeper)
- func (k *Keeper) SetWasmKeeper(wasmKeeper types.WasmKeeper)
- func (k Keeper) SwapExactAmountIn(ctx sdk.Context, sender sdk.AccAddress, pool poolmanagertypes.PoolI, ...) (osmomath.Int, error)
- func (k Keeper) SwapExactAmountOut(ctx sdk.Context, sender sdk.AccAddress, pool poolmanagertypes.PoolI, ...) (tokenInAmount osmomath.Int, err error)
- func (k Keeper) WhitelistCodeId(ctx sdk.Context, codeId uint64)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewMsgCreatorServerImpl ¶
func NewMsgCreatorServerImpl(keeper *Keeper) model.MsgCreatorServer
func NewMsgServerImpl ¶
Types ¶
type Keeper ¶
type Keeper struct {
// contains filtered or unexported fields
}
func NewKeeper ¶
func NewKeeper(cdc codec.BinaryCodec, storeKey sdk.StoreKey, paramSpace paramtypes.Subspace, accountKeeper types.AccountKeeper, bankKeeper types.BankKeeper) *Keeper
func (Keeper) CalcInAmtGivenOut ¶
func (k Keeper) CalcInAmtGivenOut( ctx sdk.Context, poolI poolmanagertypes.PoolI, tokenOut sdk.Coin, tokenInDenom string, swapFee osmomath.Dec, ) (tokenIn sdk.Coin, err error)
CalcInAmtGivenOut calculates the input amount of a token required to get the desired output token amount in a CosmWasm-based liquidity pool.
Parameters: - ctx: The context of the operation. - poolI: The liquidity pool to perform the calculation on. - tokenOut: The desired output token (asset) amount. - tokenInDenom: The denom of the input token (asset) to be used in the calculation. - swapFee: The fee associated with the swap operation.
Returns: - sdk.Coin: The calculated input token amount. - error: An error if the calculation fails or if the pool conversion fails.
func (Keeper) CalcOutAmtGivenIn ¶
func (k Keeper) CalcOutAmtGivenIn( ctx sdk.Context, poolI poolmanagertypes.PoolI, tokenIn sdk.Coin, tokenOutDenom string, swapFee osmomath.Dec, ) (tokenOut sdk.Coin, err error)
CalcOutAmtGivenIn calculates the output amount of a token given the input token amount in a CosmWasm-based liquidity pool.
Parameters: - ctx: The context of the operation. - poolI: The liquidity pool to perform the calculation on. - tokenIn: The input token (asset) to be used in the calculation. - tokenOutDenom: The denom of the output token (asset) to be received. - swapFee: The fee associated with the swap operation.
Returns: - sdk.Coin: The calculated output token amount. - error: An error if the calculation fails or if the pool conversion fails.
func (Keeper) CalculateSpotPrice ¶
func (k Keeper) CalculateSpotPrice( ctx sdk.Context, poolId uint64, quoteAssetDenom string, baseAssetDenom string, ) (price osmomath.BigDec, err error)
CalculateSpotPrice calculates the spot price of a pair of assets in a CosmWasm-based liquidity pool.
Parameters: - ctx: The context of the query request. - poolId: The unique identifier of the CosmWasm-based liquidity pool. - quoteAssetDenom: The denom of the quote asset in the trading pair. - baseAssetDenom: The denom of the base asset in the trading pair.
Returns: - price: The spot price of the trading pair in the specified liquidity pool. - err: An error if the pool cannot be found or if the spot price calculation fails.
func (Keeper) ExportGenesis ¶
func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState
ExportGenesis returns the cosmwasm pool's exported genesis.
func (Keeper) GetCodeIdByPoolId ¶
GetCodeIdByPoolId returns the contract address and code id associated with the given pool.
func (Keeper) GetPool ¶
GetPool retrieves a pool model with the specified pool ID from the store. The method returns the pool interface of the corresponding pool model if found, and an error if not found.
Parameters: - ctx: The SDK context. - poolId: The unique identifier of the pool.
Returns: - poolmanagertypes.PoolI: The pool interface of the corresponding pool model, if found. - error: An error if the pool model is not found; otherwise, nil.
func (Keeper) GetPoolById ¶
GetPoolById returns a CosmWasmExtension that corresponds to the requested pool id. Returns error if pool id is not found.
func (Keeper) GetPoolDenoms ¶
GetPoolDenoms retrieves the list of asset denoms in a CosmWasm-based liquidity pool given its ID.
Parameters: - ctx: The context of the query request. - poolId: The unique identifier of the CosmWasm-based liquidity pool.
Returns: - denoms: A slice of strings representing the asset denoms in the liquidity pool. - err: An error if the pool cannot be found or if the CosmWasm query fails.
func (Keeper) GetPools ¶
GetPools retrieves all pool objects stored in the keeper.
It fetches values from the store associated with the PoolsKey prefix. For each value retrieved, it attempts to unmarshal the value into a Pool object. If this operation succeeds, the Pool object is added to the returned slice. If an error occurs during unmarshalling, the function will return immediately with the encountered error.
Parameters: - ctx: The current SDK Context used to access the store.
Returns:
- A slice of PoolI interfaces if the operation is successful. Each element in the slice represents a pool that was stored in the keeper.
- An error if unmarshalling fails for any of the values fetched from the store. In this case, the slice of PoolI interfaces will be nil.
func (Keeper) GetPoolsSerializable ¶
GetPoolsSerializable retrieves all pool objects stored in the keeper. Because the Pool struct has a non-serializable wasmKeeper field, this method utilizes the CosmWasmPool struct directly instead, which allows it to be serialized in import/export genesis.
func (Keeper) GetPoolsWithWasmKeeper ¶
GetPoolsWithWasmKeeper behaves the same as GetPools, but it also sets the WasmKeeper field of the pool.
func (Keeper) GetSerializedPools ¶
func (k Keeper) GetSerializedPools(ctx sdk.Context, pagination *query.PageRequest) ([]*codectypes.Any, *query.PageResponse, error)
GetSerializedPools retrieves all pool objects stored in the keeper. Returns them as a slice of codectypes.Any for use as a response to pools queries and CLI
func (Keeper) GetTotalLiquidity ¶
GetTotalLiquidity retrieves the total liquidity of all cw pools.
func (Keeper) GetTotalPoolLiquidity ¶
GetTotalPoolLiquidity retrieves the total liquidity of a specific pool identified by poolId.
Parameters: - ctx: The current SDK Context used for executing store operations. - poolId: The unique identifier of the pool whose total liquidity is to be fetched.
Returns:
- the total liquidity of the specified pool, if the operations are successful.
- An error if the pool retrieval operation fails. In this case, an empty sdk.Coins object will be returned.
func (*Keeper) InitGenesis ¶
func (k *Keeper) InitGenesis(ctx sdk.Context, gen *types.GenesisState, unpacker codectypes.AnyUnpacker)
InitGenesis initializes the store state from a genesis state.
func (Keeper) InitializePool ¶
func (k Keeper) InitializePool(ctx sdk.Context, pool poolmanagertypes.PoolI, creatorAddress sdk.AccAddress) error
It converts the given pool to a CosmWasmPool, instantiates the Wasm contract using the contract keeper, and then sets the contract address in the CosmWasmPool model before storing it. The method returns an error if the pool conversion, contract instantiation, or storage process fails.
Parameters: - ctx: The SDK context. - pool: The pool interface to be initialized. - creatorAddress: The address of the creator of the pool.
Returns: - error: * if the pool conversion, contract instantiation, or storage process fails. * if the code id is not whitelisted by governance. - otherwise, nil.
func (*Keeper) SetContractKeeper ¶
func (k *Keeper) SetContractKeeper(contractKeeper types.ContractKeeper)
Set the contract keeper.
func (Keeper) SetParam ¶
SetParam sets a specific cosmwasmpool module's parameter with the provided parameter.
func (Keeper) SetPool ¶
func (k Keeper) SetPool(ctx sdk.Context, pool types.CosmWasmExtension)
SetPool stores the given pool in state.
func (*Keeper) SetPoolManagerKeeper ¶
func (k *Keeper) SetPoolManagerKeeper(poolmanagerKeeper types.PoolManagerKeeper)
Set the poolmanager keeper.
func (*Keeper) SetWasmKeeper ¶
func (k *Keeper) SetWasmKeeper(wasmKeeper types.WasmKeeper)
Set the wasm keeper.
func (Keeper) SwapExactAmountIn ¶
func (k Keeper) SwapExactAmountIn( ctx sdk.Context, sender sdk.AccAddress, pool poolmanagertypes.PoolI, tokenIn sdk.Coin, tokenOutDenom string, tokenOutMinAmount osmomath.Int, swapFee osmomath.Dec, ) (osmomath.Int, error)
SwapExactAmountIn performs a swap operation with a specified input amount in a CosmWasm-based liquidity pool.
Parameters: - ctx: The context of the operation. - sender: The address of the account initiating the swap. - pool: The liquidity pool in which the swap occurs. - tokenIn: The input token (asset) to be swapped. - tokenOutDenom: The denom of the output token (asset) to be received. - tokenOutMinAmount: The minimum amount of the output token to be received. - swapFee: The fee associated with the swap operation.
Returns: - osmomath.Int: The actual amount of the output token received after the swap. - error: An error if the swap operation fails or if the pool conversion fails.
func (Keeper) SwapExactAmountOut ¶
func (k Keeper) SwapExactAmountOut( ctx sdk.Context, sender sdk.AccAddress, pool poolmanagertypes.PoolI, tokenInDenom string, tokenInMaxAmount osmomath.Int, tokenOut sdk.Coin, swapFee osmomath.Dec, ) (tokenInAmount osmomath.Int, err error)
SwapExactAmountOut performs a swap operation with a specified output amount in a CosmWasm-based liquidity pool.
Parameters: - ctx: The context of the operation. - sender: The address of the account initiating the swap. - pool: The liquidity pool in which the swap occurs. - tokenInDenom: The denom of the input token (asset) to be swapped. - tokenInMaxAmount: The maximum amount of the input token allowed to be swapped. - tokenOut: The output token (asset) to be received. - swapFee: The fee associated with the swap operation.
Returns: - osmomath.Int: The actual amount of the input token used in the swap. - error: An error if the swap operation fails or if the pool conversion fails.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
queryproto
Package queryproto is a reverse proxy.
|
Package queryproto is a reverse proxy. |
cosmwasm
|
|
msg
This file defines helpers for querying the cosmwasm pool contract from the cosmwasm pool module.
|
This file defines helpers for querying the cosmwasm pool contract from the cosmwasm pool module. |