Documentation ¶
Index ¶
- func NewMsgServerImpl(keeper *Keeper) types.MsgServer
- func NewPoolManagerProposalHandler(k Keeper) govtypes.Handler
- type Keeper
- func (k Keeper) AllPools(ctx sdk.Context) ([]types.PoolI, error)
- func (k Keeper) CreateConcentratedPoolAsPoolManager(ctx sdk.Context, msg types.CreatePoolMsg) (types.PoolI, error)
- func (k Keeper) CreatePool(ctx sdk.Context, msg types.CreatePoolMsg) (uint64, error)
- func (k Keeper) EstimateTradeBasedOnPriceImpactBalancerPool(ctx sdk.Context, req queryproto.EstimateTradeBasedOnPriceImpactRequest, ...) (*queryproto.EstimateTradeBasedOnPriceImpactResponse, error)
- func (k Keeper) EstimateTradeBasedOnPriceImpactConcentratedLiquidity(ctx sdk.Context, req queryproto.EstimateTradeBasedOnPriceImpactRequest, ...) (*queryproto.EstimateTradeBasedOnPriceImpactResponse, error)
- func (k Keeper) EstimateTradeBasedOnPriceImpactStableSwapPool(ctx sdk.Context, req queryproto.EstimateTradeBasedOnPriceImpactRequest, ...) (*queryproto.EstimateTradeBasedOnPriceImpactResponse, error)
- func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState
- func (k Keeper) GetNextPoolId(ctx sdk.Context) uint64
- func (k Keeper) GetOsmoVolumeForPool(ctx sdk.Context, poolId uint64) osmomath.Int
- func (k Keeper) GetParams(ctx sdk.Context) (params types.Params)
- func (k Keeper) GetPool(ctx sdk.Context, poolId uint64) (types.PoolI, error)
- func (k Keeper) GetPoolModule(ctx sdk.Context, poolId uint64) (types.PoolModuleI, error)
- func (k Keeper) GetTotalPoolLiquidity(ctx sdk.Context, poolId uint64) (sdk.Coins, error)
- func (k Keeper) GetTotalVolumeForPool(ctx sdk.Context, poolId uint64) sdk.Coins
- func (k Keeper) GetTradingPairTakerFee(ctx sdk.Context, denom0, denom1 string) (osmomath.Dec, error)
- func (k Keeper) HandleDenomPairTakerFeeProposal(ctx sdk.Context, p *types.DenomPairTakerFeeProposal) error
- func (k Keeper) InitGenesis(ctx sdk.Context, genState *types.GenesisState)
- func (k Keeper) MultihopEstimateInGivenExactAmountOut(ctx sdk.Context, route []types.SwapAmountOutRoute, tokenOut sdk.Coin) (tokenInAmount osmomath.Int, err error)
- func (k Keeper) MultihopEstimateOutGivenExactAmountIn(ctx sdk.Context, route []types.SwapAmountInRoute, tokenIn sdk.Coin) (tokenOutAmount osmomath.Int, err error)
- func (k Keeper) RouteCalculateSpotPrice(ctx sdk.Context, poolId uint64, quoteAssetDenom string, baseAssetDenom string) (price osmomath.BigDec, err error)
- func (k Keeper) RouteExactAmountIn(ctx sdk.Context, sender sdk.AccAddress, route []types.SwapAmountInRoute, ...) (tokenOutAmount osmomath.Int, err error)
- func (k Keeper) RouteExactAmountOut(ctx sdk.Context, sender sdk.AccAddress, route []types.SwapAmountOutRoute, ...) (tokenInAmount osmomath.Int, err error)
- func (k Keeper) RouteGetPoolDenoms(ctx sdk.Context, poolId uint64) (denoms []string, err error)
- func (k Keeper) SenderValidationSetDenomPairTakerFee(ctx sdk.Context, sender, denom0, denom1 string, takerFee osmomath.Dec) error
- func (k Keeper) SetDenomPairTakerFee(ctx sdk.Context, denom0, denom1 string, takerFee osmomath.Dec)
- func (k Keeper) SetNextPoolId(ctx sdk.Context, poolId uint64)
- func (k Keeper) SetParam(ctx sdk.Context, key []byte, value interface{})
- func (k Keeper) SetParams(ctx sdk.Context, params types.Params)
- func (k *Keeper) SetPoolIncentivesKeeper(poolIncentivesKeeper types.PoolIncentivesKeeperI)
- func (k Keeper) SetPoolRoute(ctx sdk.Context, poolId uint64, poolType types.PoolType)
- func (k *Keeper) SetProtorevKeeper(protorevKeeper types.ProtorevKeeper)
- func (k *Keeper) SetStakingKeeper(stakingKeeper types.StakingKeeper)
- func (k Keeper) SetVolume(ctx sdk.Context, poolId uint64, totalVolume sdk.Coins)
- func (k Keeper) SplitRouteExactAmountIn(ctx sdk.Context, sender sdk.AccAddress, routes []types.SwapAmountInSplitRoute, ...) (osmomath.Int, error)
- func (k Keeper) SplitRouteExactAmountOut(ctx sdk.Context, sender sdk.AccAddress, route []types.SwapAmountOutSplitRoute, ...) (osmomath.Int, error)
- func (k Keeper) SwapExactAmountIn(ctx sdk.Context, sender sdk.AccAddress, poolId uint64, tokenIn sdk.Coin, ...) (tokenOutAmount osmomath.Int, err error)
- func (k Keeper) SwapExactAmountInNoTakerFee(ctx sdk.Context, sender sdk.AccAddress, poolId uint64, tokenIn sdk.Coin, ...) (tokenOutAmount osmomath.Int, err error)
- func (k Keeper) TotalLiquidity(ctx sdk.Context) (sdk.Coins, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewMsgServerImpl ¶
Types ¶
type Keeper ¶
type Keeper struct {
// contains filtered or unexported fields
}
func NewKeeper ¶
func NewKeeper(storeKey sdk.StoreKey, paramSpace paramtypes.Subspace, gammKeeper types.PoolModuleI, concentratedKeeper types.PoolModuleI, cosmwasmpoolKeeper types.PoolModuleI, bankKeeper types.BankI, accountKeeper types.AccountI, communityPoolKeeper types.CommunityPoolI, stakingKeeper types.StakingKeeper, protorevKeeper types.ProtorevKeeper) *Keeper
func (Keeper) AllPools ¶
AllPools returns all pools sorted by their ids from every pool module registered in the pool manager keeper.
func (Keeper) CreateConcentratedPoolAsPoolManager ¶
func (k Keeper) CreateConcentratedPoolAsPoolManager(ctx sdk.Context, msg types.CreatePoolMsg) (types.PoolI, error)
CreateConcentratedPoolAsPoolManager creates a concentrated liquidity pool from given message without sending any initial liquidity to the pool and paying a creation fee. This is meant to be used for creating the pools internally (such as in the upgrade handler). The creator of the pool must be the poolmanager module account. Returns error if not. Otherwise, functions the same as the regular createPoolZeroLiquidityNoCreationFee.
func (Keeper) CreatePool ¶
CreatePool attempts to create a pool returning the newly created pool ID or an error upon failure. The pool creation fee is used to fund the community pool. It will create a dedicated module account for the pool and sends the initial liquidity to the created module account.
After the initial liquidity is sent to the pool's account, this function calls an InitializePool function from the source module. That module is responsible for: - saving the pool into its own state - Minting LP shares to pool creator - Setting metadata for the shares
func (Keeper) EstimateTradeBasedOnPriceImpactBalancerPool ¶
func (k Keeper) EstimateTradeBasedOnPriceImpactBalancerPool( ctx sdk.Context, req queryproto.EstimateTradeBasedOnPriceImpactRequest, spotPrice, adjustedMaxPriceImpact osmomath.Dec, swapModule types.PoolModuleI, poolI types.PoolI, ) (*queryproto.EstimateTradeBasedOnPriceImpactResponse, error)
EstimateTradeBasedOnPriceImpactBalancerPool estimates a trade based on price impact for a balancer pool type. For a balancer pool if an amount entered is greater than the total pool liquidity the trade estimated would be the full liquidity of the other token. If the amount is small it would return a close 1:1 trade of the smallest units.
func (Keeper) EstimateTradeBasedOnPriceImpactConcentratedLiquidity ¶
func (k Keeper) EstimateTradeBasedOnPriceImpactConcentratedLiquidity( ctx sdk.Context, req queryproto.EstimateTradeBasedOnPriceImpactRequest, spotPrice, adjustedMaxPriceImpact osmomath.Dec, swapModule types.PoolModuleI, poolI types.PoolI, ) (*queryproto.EstimateTradeBasedOnPriceImpactResponse, error)
EstimateTradeBasedOnPriceImpactConcentratedLiquidity estimates a trade based on price impact for a concentrated liquidity pool type. For a concentrated liquidity pool if an amount entered is greater than the total pool liquidity the trade estimated would error. If the amount is small it would return tokenOut to be 0 in which case we should return an empty trade. If the estimate returns an error we should ignore it and continue attempting to estimate by halving the input.
func (Keeper) EstimateTradeBasedOnPriceImpactStableSwapPool ¶
func (k Keeper) EstimateTradeBasedOnPriceImpactStableSwapPool( ctx sdk.Context, req queryproto.EstimateTradeBasedOnPriceImpactRequest, spotPrice, adjustedMaxPriceImpact osmomath.Dec, swapModule types.PoolModuleI, poolI types.PoolI, ) (*queryproto.EstimateTradeBasedOnPriceImpactResponse, error)
EstimateTradeBasedOnPriceImpactStableSwapPool estimates a trade based on price impact for a stableswap pool type. For a stableswap pool if an amount entered is greater than the total pool liquidity the trade estimated would `panic`. If the amount is small it would return an error, in the case of a `panic` we should ignore it and keep attempting lower input amounts while if it's a normal error we should return an empty trade.
func (Keeper) ExportGenesis ¶
func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState
ExportGenesis returns the poolmanager module's exported genesis.
func (Keeper) GetNextPoolId ¶
GetNextPoolId returns the next pool id.
func (Keeper) GetOsmoVolumeForPool ¶
GetOsmoVolumeForPool gets the total FURY-denominated historical volume for a given pool ID.
func (Keeper) GetPoolModule ¶
GetPoolModule returns the swap module for the given pool ID. Returns error if: - any database error occurs. - fails to find a pool with the given id. - the swap module of the type corresponding to the pool id is not registered in poolmanager's keeper constructor. TODO: unexport after concentrated-liqudity upgrade. Currently, it is exported for the upgrade handler logic and tests.
func (Keeper) GetTotalPoolLiquidity ¶
GetTotalPoolLiquidity gets the total liquidity for a given poolId.
func (Keeper) GetTotalVolumeForPool ¶
GetTotalVolumeForPool gets the total historical volume in all supported denominations for a given pool ID.
func (Keeper) GetTradingPairTakerFee ¶
func (k Keeper) GetTradingPairTakerFee(ctx sdk.Context, denom0, denom1 string) (osmomath.Dec, error)
GetTradingPairTakerFee returns the taker fee for the given trading pair. If the trading pair does not exist, it returns the default taker fee.
func (Keeper) HandleDenomPairTakerFeeProposal ¶
func (Keeper) InitGenesis ¶
func (k Keeper) InitGenesis(ctx sdk.Context, genState *types.GenesisState)
InitGenesis initializes the poolmanager module's state from a provided genesis state.
func (Keeper) MultihopEstimateInGivenExactAmountOut ¶
func (Keeper) MultihopEstimateOutGivenExactAmountIn ¶
func (Keeper) RouteCalculateSpotPrice ¶
func (Keeper) RouteExactAmountIn ¶
func (k Keeper) RouteExactAmountIn( ctx sdk.Context, sender sdk.AccAddress, route []types.SwapAmountInRoute, tokenIn sdk.Coin, tokenOutMinAmount osmomath.Int, ) (tokenOutAmount osmomath.Int, err error)
RouteExactAmountIn processes a swap along the given route using the swap function corresponding to poolID's pool type. It takes in the input denom and amount for the initial swap against the first pool and chains the output as the input for the next routed pool until the last pool is reached. Transaction succeeds if final amount out is greater than tokenOutMinAmount defined and no errors are encountered along the way.
func (Keeper) RouteExactAmountOut ¶
func (k Keeper) RouteExactAmountOut(ctx sdk.Context, sender sdk.AccAddress, route []types.SwapAmountOutRoute, tokenInMaxAmount osmomath.Int, tokenOut sdk.Coin, ) (tokenInAmount osmomath.Int, err error)
RouteExactAmountOut processes a swap along the given route using the swap function corresponding to poolID's pool type. This function is responsible for computing the optimal output amount for a given input amount when swapping tokens, taking into account the current price of the tokens in the pool and any slippage. Transaction succeeds if the calculated tokenInAmount of the first pool is less than the defined tokenInMaxAmount defined.
func (Keeper) RouteGetPoolDenoms ¶
func (Keeper) SenderValidationSetDenomPairTakerFee ¶
func (k Keeper) SenderValidationSetDenomPairTakerFee(ctx sdk.Context, sender, denom0, denom1 string, takerFee osmomath.Dec) error
SenderValidationSetDenomPairTakerFee sets the taker fee for the given trading pair iff the sender's address also exists in the pool manager taker fee admin address list.
func (Keeper) SetDenomPairTakerFee ¶
SetDenomPairTakerFee sets the taker fee for the given trading pair. If the taker fee for this denom pair matches the default taker fee, then it is deleted from state.
func (Keeper) SetNextPoolId ¶
SetNextPoolId sets next pool Id.
func (Keeper) SetParam ¶
SetParam sets a specific poolmanger module's parameter with the provided parameter.
func (*Keeper) SetPoolIncentivesKeeper ¶
func (k *Keeper) SetPoolIncentivesKeeper(poolIncentivesKeeper types.PoolIncentivesKeeperI)
SetPoolIncentivesKeeper sets pool incentives keeper
func (Keeper) SetPoolRoute ¶
func (*Keeper) SetProtorevKeeper ¶
func (k *Keeper) SetProtorevKeeper(protorevKeeper types.ProtorevKeeper)
SetProtorevKeeper sets protorev keeper
func (*Keeper) SetStakingKeeper ¶
func (k *Keeper) SetStakingKeeper(stakingKeeper types.StakingKeeper)
SetStakingKeeper sets staking keeper
func (Keeper) SetVolume ¶
SetVolume sets the given volume to the global tracked volume for the given pool ID. Note that this function is exported for cross-module testing purposes and should not be called directly from other modules.
func (Keeper) SplitRouteExactAmountIn ¶
func (k Keeper) SplitRouteExactAmountIn( ctx sdk.Context, sender sdk.AccAddress, routes []types.SwapAmountInSplitRoute, tokenInDenom string, tokenOutMinAmount osmomath.Int, ) (osmomath.Int, error)
SplitRouteExactAmountIn routes the swap across multiple multihop paths to get the desired token out. This is useful for achieving the most optimal execution. However, note that the responsibility of determining the optimal split is left to the client. This method simply route the swap across the given route. The route must end with the same token out and begin with the same token in.
It performs the price impact protection check on the combination of tokens out from all multihop paths. The given tokenOutMinAmount is used for comparison.
Returns error if:
- route are empty
- route contain duplicate multihop paths
- last token out denom is not the same for all multihop paths in routeStep
- one of the multihop swaps fails for internal reasons
- final token out computed is not positive
- final token out computed is smaller than tokenOutMinAmount
func (Keeper) SplitRouteExactAmountOut ¶
func (k Keeper) SplitRouteExactAmountOut( ctx sdk.Context, sender sdk.AccAddress, route []types.SwapAmountOutSplitRoute, tokenOutDenom string, tokenInMaxAmount osmomath.Int, ) (osmomath.Int, error)
SplitRouteExactAmountOut route the swap across multiple multihop paths to get the desired token in. This is useful for achieving the most optimal execution. However, note that the responsibility of determining the optimal split is left to the client. This method simply route the swap across the given route. The route must end with the same token out and begin with the same token in.
It performs the price impact protection check on the combination of tokens in from all multihop paths. The given tokenInMaxAmount is used for comparison.
Returns error if:
- route are empty
- route contain duplicate multihop paths
- last token out denom is not the same for all multihop paths in routeStep
- one of the multihop swaps fails for internal reasons
- final token out computed is not positive
- final token out computed is smaller than tokenInMaxAmount
func (Keeper) SwapExactAmountIn ¶
func (k Keeper) SwapExactAmountIn( ctx sdk.Context, sender sdk.AccAddress, poolId uint64, tokenIn sdk.Coin, tokenOutDenom string, tokenOutMinAmount osmomath.Int, ) (tokenOutAmount osmomath.Int, err error)
SwapExactAmountIn is an API for swapping an exact amount of tokens as input to a pool to get a minimum amount of the desired token out. The method succeeds when tokenOutAmount is greater than tokenOutMinAmount defined. Errors otherwise. Also, errors if the pool id is invalid, if tokens do not belong to the pool with given id or if sender does not have the swapped-in tokenIn.
func (Keeper) SwapExactAmountInNoTakerFee ¶
func (k Keeper) SwapExactAmountInNoTakerFee( ctx sdk.Context, sender sdk.AccAddress, poolId uint64, tokenIn sdk.Coin, tokenOutDenom string, tokenOutMinAmount osmomath.Int, ) (tokenOutAmount osmomath.Int, err error)
SwapExactAmountInNoTakerFee is an API for swapping an exact amount of tokens as input to a pool to get a minimum amount of the desired token out. This method does NOT charge a taker fee, and should only be used in txfees hooks when swapping taker fees. This prevents us from charging taker fees on top of taker fees.