keeper

package
v0.53.0 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2024 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LiquidityRatioFromPriceDepth added in v0.12.0

func LiquidityRatioFromPriceDepth(depth sdkmath.LegacyDec) sdkmath.LegacyDec

func NewMsgServerImpl

func NewMsgServerImpl(keeper Keeper) types.MsgServer

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

func PortionCoins

func PortionCoins(coins sdk.Coins, portion sdkmath.LegacyDec) sdk.Coins

func Pow10 added in v0.53.0

func Pow10(decimal uint64) (value sdkmath.LegacyDec)

Types

type Keeper

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

func NewKeeper

func NewKeeper(
	cdc codec.BinaryCodec,
	storeService store.KVStoreService,
	transientStoreKey storetypes.StoreKey,
	authority string,

	parameterKeeper *pkeeper.Keeper,
	bankKeeper types.BankKeeper,
	accountKeeper types.AccountKeeper,
	oracleKeeper types.OracleKeeper,
	commitmentKeeper *commitmentkeeper.Keeper,
	assetProfileKeeper types.AssetProfileKeeper,
	accountedPoolKeeper types.AccountedPoolKeeper,
	tierKeeper *tierkeeper.Keeper,
) *Keeper

func (Keeper) AddToPoolBalance added in v0.48.0

func (k Keeper) AddToPoolBalance(ctx sdk.Context, pool *types.Pool, addShares sdkmath.Int, coins sdk.Coins) error

AddToPoolBalance Used in perpetual balance changes

func (Keeper) AllSlippageTracks added in v0.13.0

func (k Keeper) AllSlippageTracks(ctx sdk.Context) []types.OraclePoolSlippageTrack

func (Keeper) ApplyExitPoolStateChange added in v0.14.0

func (k Keeper) ApplyExitPoolStateChange(ctx sdk.Context, pool types.Pool, exiter sdk.AccAddress, numShares sdkmath.Int, exitCoins sdk.Coins, isLiquidation bool) error

func (Keeper) ApplyJoinPoolStateChange added in v0.49.0

func (k Keeper) ApplyJoinPoolStateChange(
	ctx sdk.Context,
	pool types.Pool,
	joiner sdk.AccAddress,
	numShares math.Int,
	joinCoins sdk.Coins,
	weightBalanceBonus math.LegacyDec,
) error

func (Keeper) ApplySwapRequest added in v0.11.0

func (k Keeper) ApplySwapRequest(ctx sdk.Context, msg sdk.Msg) error

func (Keeper) Balance added in v0.14.0

func (Keeper) BurnPoolShareFromAccount

func (k Keeper) BurnPoolShareFromAccount(ctx sdk.Context, pool types.Pool, addr sdk.AccAddress, amount math.Int) error

BurnPoolShareFromAccount burns `amount` of the given pool's shares held by `addr`.

func (Keeper) CalcAmmPrice added in v0.53.0

func (k Keeper) CalcAmmPrice(ctx sdk.Context, denom string, decimal uint64) sdkmath.LegacyDec

func (Keeper) CalcInAmtGivenOut added in v0.11.0

func (k Keeper) CalcInAmtGivenOut(
	ctx sdk.Context,
	poolId uint64,
	oracle types.OracleKeeper,
	snapshot *types.Pool,
	tokensOut sdk.Coins, tokenInDenom string, swapFee sdkmath.LegacyDec) (
	tokenIn sdk.Coin, slippage sdkmath.LegacyDec, err error,
)

CalcInAmtGivenOut calculates token to be provided, fee added, given the swapped out amount, using solveConstantFunctionInvariant.

func (Keeper) CalcInRouteByDenom added in v0.16.0

func (k Keeper) CalcInRouteByDenom(ctx sdk.Context, denomIn string, denomOut string, baseCurrency string) ([]*types.SwapAmountInRoute, error)

CalcInRouteByDenom calculates the in route by denom

func (Keeper) CalcInRouteSpotPrice added in v0.16.0

CalcInRouteSpotPrice calculates the spot price of the given token and in route

func (Keeper) CalcOutAmtGivenIn added in v0.11.0

func (k Keeper) CalcOutAmtGivenIn(
	ctx sdk.Context,
	poolId uint64,
	oracle types.OracleKeeper,
	snapshot *types.Pool,
	tokensIn sdk.Coins,
	tokenOutDenom string,
	swapFee sdkmath.LegacyDec,
) (sdk.Coin, sdkmath.LegacyDec, error)

CalcOutAmtGivenIn calculates tokens to be swapped out given the provided amount and fee deducted, using solveConstantFunctionInvariant.

func (Keeper) CalcOutRouteByDenom added in v0.16.0

func (k Keeper) CalcOutRouteByDenom(ctx sdk.Context, denomOut string, denomIn string, baseCurrency string) ([]*types.SwapAmountOutRoute, error)

CalcOutRouteByDenom calculates the out route by denom

func (Keeper) CalcOutRouteSpotPrice added in v0.16.0

CalcOutRouteSpotPrice calculates the spot price of the given token and out route

func (Keeper) CalcSwapEstimationByDenom added in v0.16.0

func (k Keeper) CalcSwapEstimationByDenom(
	ctx sdk.Context,
	amount sdk.Coin,
	denomIn string,
	denomOut string,
	baseCurrency string,
	address string,
	overrideSwapFee sdkmath.LegacyDec,
	decimals uint64,
) (
	inRoute []*types.SwapAmountInRoute,
	outRoute []*types.SwapAmountOutRoute,
	outAmount sdk.Coin,
	spotPrice sdkmath.LegacyDec,
	swapFeeOut sdkmath.LegacyDec,
	discountOut sdkmath.LegacyDec,
	availableLiquidity sdk.Coin,
	slippage sdkmath.LegacyDec,
	weightBonus sdkmath.LegacyDec,
	priceImpact sdkmath.LegacyDec,
	err error,
)

CalcSwapEstimationByDenom calculates the swap estimation by denom

func (Keeper) CalculateUSDValue added in v0.53.0

func (k Keeper) CalculateUSDValue(ctx sdk.Context, denom string, amount sdkmath.Int) sdkmath.LegacyDec

func (Keeper) CheckBaseAssetExist added in v0.52.0

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

func (Keeper) ClearOutdatedSlippageTrack added in v0.13.0

func (k Keeper) ClearOutdatedSlippageTrack(ctx sdk.Context)

func (Keeper) CreatePool

func (k Keeper) CreatePool(ctx sdk.Context, msg *types.MsgCreatePool) (uint64, error)

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) DecreaseDenomLiquidity

func (k Keeper) DecreaseDenomLiquidity(ctx sdk.Context, denom string, amount math.Int) error

DecreaseDenomLiquidity decreases the liquidity of a denom by a certain amount

func (Keeper) DeleteSlippageTrack added in v0.13.0

func (k Keeper) DeleteSlippageTrack(ctx sdk.Context, track types.OraclePoolSlippageTrack)

func (Keeper) DeleteSwapExactAmountInRequest added in v0.11.0

func (k Keeper) DeleteSwapExactAmountInRequest(ctx sdk.Context, msg *types.MsgSwapExactAmountIn, index uint64)

DeleteSwapExactAmountInRequest removes a swap exact amount in request

func (Keeper) DeleteSwapExactAmountOutRequest added in v0.11.0

func (k Keeper) DeleteSwapExactAmountOutRequest(ctx sdk.Context, msg *types.MsgSwapExactAmountOut, index uint64)

DeleteSwapExactAmountOutRequest deletes a swap exact amount out request

func (Keeper) DeleteSwapRequest added in v0.11.0

func (k Keeper) DeleteSwapRequest(ctx sdk.Context, msg sdk.Msg, index uint64)

func (Keeper) EndBlocker added in v0.11.0

func (k Keeper) EndBlocker(ctx sdk.Context)

EndBlocker of amm module

func (Keeper) EstimatePrice added in v0.29.31

func (k Keeper) EstimatePrice(ctx sdk.Context, tokenInDenom, baseCurrency string) math.LegacyDec

Estimate the price : eg, 1 Eden -> x usdc

func (Keeper) ExecuteSwapRequests added in v0.11.0

func (k Keeper) ExecuteSwapRequests(ctx sdk.Context) []sdk.Msg

func (Keeper) ExitPool

func (k Keeper) ExitPool(
	ctx sdk.Context,
	sender sdk.AccAddress,
	poolId uint64,
	shareInAmount math.Int,
	tokenOutMins sdk.Coins,
	tokenOutDenom string,
	isLiquidation bool,
) (exitCoins sdk.Coins, err error)

func (Keeper) ExitPoolEst added in v0.33.0

func (k Keeper) ExitPoolEst(
	ctx sdk.Context,
	poolId uint64,
	shareInAmount math.Int,
	tokenOutDenom string,
) (exitCoins sdk.Coins, weightBalanceBonus math.LegacyDec, err error)

func (Keeper) ExitPoolEstimation added in v0.29.22

func (Keeper) FirstPoolId added in v0.11.0

func (k Keeper) FirstPoolId(msg sdk.Msg) uint64

func (Keeper) GetAccountKeeper added in v0.52.0

func (k Keeper) GetAccountKeeper() types.AccountKeeper

func (Keeper) GetAccountedPoolSnapshotOrSet added in v0.49.4

func (k Keeper) GetAccountedPoolSnapshotOrSet(ctx sdk.Context, pool types.Pool) (val types.Pool)

Gets the pool snapshot and updates the pool balance with accounted pool balance

func (Keeper) GetAllDenomLiquidity

func (k Keeper) GetAllDenomLiquidity(ctx sdk.Context) (list []types.DenomLiquidity)

GetAllDenomLiquidity returns all denomLiquidity

func (Keeper) GetAllLegacyPool added in v0.49.0

func (k Keeper) GetAllLegacyPool(ctx sdk.Context) (list []types.LegacyPool)

GetAllLegacyPool returns all legacy pool

func (Keeper) GetAllPool

func (k Keeper) GetAllPool(ctx sdk.Context) (list []types.Pool)

GetAllPool returns all pool

func (Keeper) GetAllSwapExactAmountInRequests added in v0.11.0

func (k Keeper) GetAllSwapExactAmountInRequests(ctx sdk.Context) (list []types.MsgSwapExactAmountIn)

GetAllSwapExactAmountInRequests returns all SwapExactAmountIn requests

func (Keeper) GetAllSwapExactAmountOutRequests added in v0.11.0

func (k Keeper) GetAllSwapExactAmountOutRequests(ctx sdk.Context) (list []types.MsgSwapExactAmountOut)

GetAllSwapExactAmountOutRequests returns all SwapExactAmountOut requests

func (Keeper) GetAssetProfileKeeper added in v0.52.0

func (k Keeper) GetAssetProfileKeeper() types.AssetProfileKeeper

func (Keeper) GetBankKeeper added in v0.52.0

func (k Keeper) GetBankKeeper() types.BankKeeper

func (Keeper) GetBestPoolWithDenoms added in v0.29.0

func (k Keeper) GetBestPoolWithDenoms(ctx sdk.Context, denoms []string, usesOracle bool) (pool types.Pool, found bool)

GetBestPoolWithDenoms returns the first highest TVL pool id that contains all specified denominations

func (Keeper) GetDenomLiquidity

func (k Keeper) GetDenomLiquidity(ctx sdk.Context, denom string) (val types.DenomLiquidity, found bool)

GetDenomLiquidity returns a denomLiquidity from its index

func (Keeper) GetEdenDenomPrice added in v0.29.31

func (k Keeper) GetEdenDenomPrice(ctx sdk.Context, baseCurrency string) math.LegacyDec

func (Keeper) GetExternalLiquidityRatio added in v0.49.3

func (k Keeper) GetExternalLiquidityRatio(ctx sdk.Context, pool types.Pool, amountDepthInfo []types.AssetAmountDepth) ([]types.PoolAsset, error)

func (Keeper) GetFirstSlippageTrack added in v0.13.0

func (k Keeper) GetFirstSlippageTrack(ctx sdk.Context, poolId uint64) types.OraclePoolSlippageTrack

func (Keeper) GetFirstSwapExactAmountInRequest added in v0.11.0

func (k Keeper) GetFirstSwapExactAmountInRequest(ctx sdk.Context, sprefix []byte) (*types.MsgSwapExactAmountIn, uint64)

func (Keeper) GetFirstSwapExactAmountOutRequest added in v0.11.0

func (k Keeper) GetFirstSwapExactAmountOutRequest(ctx sdk.Context, sprefix []byte) (*types.MsgSwapExactAmountOut, uint64)

func (Keeper) GetLastSlippageTrack added in v0.13.0

func (k Keeper) GetLastSlippageTrack(ctx sdk.Context, poolId uint64) types.OraclePoolSlippageTrack

func (Keeper) GetLastSwapRequestIndex added in v0.11.0

func (k Keeper) GetLastSwapRequestIndex(ctx sdk.Context) uint64

func (Keeper) GetLatestPool

func (k Keeper) GetLatestPool(ctx sdk.Context) (val types.Pool, found bool)

GetLatestPool retrieves the latest pool item from the list of pools

func (Keeper) GetNextPoolId

func (k Keeper) GetNextPoolId(ctx sdk.Context) uint64

GetNextPoolId returns the next pool id.

func (Keeper) GetParams

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

func (Keeper) GetPool

func (k Keeper) GetPool(ctx sdk.Context, poolId uint64) (val types.Pool, found bool)

GetPool returns a pool from its index

func (Keeper) GetPoolSnapshotOrSet added in v0.11.0

func (k Keeper) GetPoolSnapshotOrSet(ctx sdk.Context, pool types.Pool) (val types.Pool)

GetPoolSnapshotOrSet returns a pool snapshot or set the snapshot

func (Keeper) GetSlippageTrack added in v0.13.0

func (k Keeper) GetSlippageTrack(ctx sdk.Context, poolId uint64, timestamp uint64) types.OraclePoolSlippageTrack

func (Keeper) GetStackedSlippage added in v0.11.0

func (k Keeper) GetStackedSlippage(ctx sdk.Context, poolId uint64) sdkmath.LegacyDec

func (*Keeper) GetTierKeeper added in v0.51.0

func (k *Keeper) GetTierKeeper() *tierkeeper.Keeper

func (Keeper) GetTokenPrice added in v0.31.0

func (k Keeper) GetTokenPrice(ctx sdk.Context, tokenInDenom, baseCurrency string) math.LegacyDec

func (Keeper) GetTrackedSlippageDiff added in v0.13.0

func (k Keeper) GetTrackedSlippageDiff(ctx sdk.Context, poolId uint64) sdk.Coins

func (Keeper) InRouteByDenom added in v0.16.0

func (Keeper) IncreaseDenomLiquidity

func (k Keeper) IncreaseDenomLiquidity(ctx sdk.Context, denom string, amount math.Int) error

IncreaseDenomLiquidity increases the liquidity of a denom by a certain amount

func (Keeper) InitializePool

func (k Keeper) InitializePool(ctx sdk.Context, pool *types.Pool, sender sdk.AccAddress) (err error)

This function: - saves the pool to state - Mints LP shares to the pool creator - Sets bank metadata for the LP denom - Records total liquidity increase - Calls the AfterPoolCreated hook

func (Keeper) InternalSwapExactAmountIn added in v0.46.0

func (k Keeper) InternalSwapExactAmountIn(
	ctx sdk.Context,
	sender sdk.AccAddress,
	recipient sdk.AccAddress,
	pool types.Pool,
	tokenIn sdk.Coin,
	tokenOutDenom string,
	tokenOutMinAmount math.Int,
	swapFee math.LegacyDec,
) (tokenOutAmount math.Int, err error)

InternalSwapExactAmountIn is an internal method for swapping an exact amount of tokens as input to a pool, using the provided swapFee. This is intended to allow different swap fees as determined by multi-hops, or when recovering from chain liveness failures. TODO: investigate if swapFee can be unexported https://github.com/osmosis-labs/osmosis/issues/3130

func (Keeper) InternalSwapExactAmountOut added in v0.46.0

func (k Keeper) InternalSwapExactAmountOut(
	ctx sdk.Context,
	sender sdk.AccAddress,
	recipient sdk.AccAddress,
	pool types.Pool,
	tokenInDenom string,
	tokenInMaxAmount math.Int,
	tokenOut sdk.Coin,
	swapFee math.LegacyDec,
) (tokenInAmount math.Int, err error)

InternalSwapExactAmountOut is a method for swapping to get an exact number of tokens out of a pool, using the provided swapFee. This is intended to allow different swap fees as determined by multi-hops, or when recovering from chain liveness failures.

func (Keeper) IterateLiquidityPools

func (k Keeper) IterateLiquidityPools(ctx sdk.Context, handlerFn func(pool types.Pool) (stop bool))

IterateLiquidty iterates over all LiquidityPools and performs a callback.

func (Keeper) JoinPoolEst added in v0.33.0

func (k Keeper) JoinPoolEst(
	ctx sdk.Context,
	poolId uint64,
	tokenInMaxs sdk.Coins,
) (tokensIn sdk.Coins, sharesOut math.Int, slippage math.LegacyDec, weightBalanceBonus math.LegacyDec, err error)

func (Keeper) JoinPoolEstimation added in v0.29.22

func (Keeper) JoinPoolNoSwap

func (k Keeper) JoinPoolNoSwap(
	ctx sdk.Context,
	sender sdk.AccAddress,
	poolId uint64,
	shareOutAmount sdkmath.Int,
	tokenInMaxs sdk.Coins,
) (tokenIn sdk.Coins, sharesOut sdkmath.Int, err error)

JoinPoolNoSwap aims to LP exactly enough to pool #{poolId} to get shareOutAmount number of LP shares. If the required tokens is greater than tokenInMaxs, returns an error & the message reverts. Leftover tokens that weren't LP'd (due to being at inexact ratios) remain in the sender account.

JoinPoolNoSwap determines the maximum amount that can be LP'd without any swap, by looking at the ratio of the total LP'd assets. (e.g. 2 osmo : 1 atom) It then finds the maximal amount that can be LP'd.

func (Keeper) Logger

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

func (Keeper) MintPoolShareToAccount

func (k Keeper) MintPoolShareToAccount(ctx sdk.Context, pool types.Pool, addr sdk.AccAddress, amount math.Int) error

MintPoolShareToAccount attempts to mint shares of a AMM denomination to the specified address returning an error upon failure. Shares are minted using the x/amm module account.

func (Keeper) OnCollectFee

func (k Keeper) OnCollectFee(ctx sdk.Context, pool types.Pool, fee sdk.Coins) error

func (Keeper) OutRouteByDenom added in v0.16.0

func (Keeper) Params

func (Keeper) Pool

func (Keeper) PoolAll

func (Keeper) PoolExists

func (k Keeper) PoolExists(ctx sdk.Context, poolId uint64) bool

PoolExists checks if a pool with the given poolId exists in the list of pools

func (Keeper) PoolExtraInfo added in v0.29.31

func (k Keeper) PoolExtraInfo(ctx sdk.Context, pool types.Pool) types.PoolExtraInfo

func (Keeper) RecordTotalLiquidityDecrease

func (k Keeper) RecordTotalLiquidityDecrease(ctx sdk.Context, coins sdk.Coins) error

func (Keeper) RecordTotalLiquidityIncrease

func (k Keeper) RecordTotalLiquidityIncrease(ctx sdk.Context, coins sdk.Coins) error

func (Keeper) RemoveDenomLiquidity

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

RemoveDenomLiquidity removes a denomLiquidity from the store

func (Keeper) RemoveFromPoolBalance added in v0.48.0

func (k Keeper) RemoveFromPoolBalance(ctx sdk.Context, pool *types.Pool, removeShares sdkmath.Int, coins sdk.Coins) error

RemoveFromPoolBalance Used in perpetual balance changes

func (Keeper) RemovePool

func (k Keeper) RemovePool(ctx sdk.Context, poolId uint64)

RemovePool removes a pool from the store

func (Keeper) RouteExactAmountIn

func (k Keeper) RouteExactAmountIn(
	ctx sdk.Context,
	sender sdk.AccAddress,
	recipient sdk.AccAddress,
	routes []types.SwapAmountInRoute,
	tokenIn sdk.Coin,
	tokenOutMinAmount math.Int,
) (tokenOutAmount math.Int, totalDiscountedSwapFee math.LegacyDec, discountOut math.LegacyDec, err error)

RouteExactAmountIn defines the input denom and input amount for the first pool, the output of the first pool is chained as the input for the next routed pool transaction succeeds when final amount out is greater than tokenOutMinAmount defined.

func (Keeper) RouteExactAmountOut

func (k Keeper) RouteExactAmountOut(ctx sdk.Context,
	sender sdk.AccAddress,
	recipient sdk.AccAddress,
	routes []types.SwapAmountOutRoute,
	tokenInMaxAmount math.Int,
	tokenOut sdk.Coin,
) (tokenInAmount math.Int, totalDiscountedSwapFee math.LegacyDec, discountOut math.LegacyDec, err error)

MultihopSwapExactAmountOut defines the output denom and output amount for the last pool. Calculation starts by providing the tokenOutAmount of the final pool to calculate the required tokenInAmount the calculated tokenInAmount is used as defined tokenOutAmount of the previous pool, calculating in reverse order of the swap Transaction succeeds if the calculated tokenInAmount of the first pool is less than the defined tokenInMaxAmount defined.

func (Keeper) SelectOneSwapRequest added in v0.11.0

func (k Keeper) SelectOneSwapRequest(ctx sdk.Context, sprefix []byte) (sdk.Msg, uint64)

func (Keeper) SelectReverseSwapRequest added in v0.11.0

func (k Keeper) SelectReverseSwapRequest(ctx sdk.Context, msg sdk.Msg) (sdk.Msg, uint64)

func (Keeper) SetDenomLiquidity

func (k Keeper) SetDenomLiquidity(ctx sdk.Context, denomLiquidity types.DenomLiquidity)

SetDenomLiquidity sets a specific denomLiquidity in the store from its index

func (*Keeper) SetHooks

func (k *Keeper) SetHooks(gh types.AmmHooks) *Keeper

Set the amm hooks.

func (Keeper) SetLastSwapRequestIndex added in v0.11.0

func (k Keeper) SetLastSwapRequestIndex(ctx sdk.Context, index uint64)

func (Keeper) SetLegacyPool added in v0.52.0

func (k Keeper) SetLegacyPool(ctx sdk.Context, pool types.LegacyPool)

func (Keeper) SetParams

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

SetParams set the params

func (Keeper) SetPool

func (k Keeper) SetPool(ctx sdk.Context, pool types.Pool)

SetPool set a specific pool in the store from its index

func (Keeper) SetSlippageTrack added in v0.13.0

func (k Keeper) SetSlippageTrack(ctx sdk.Context, track types.OraclePoolSlippageTrack)

func (Keeper) SetSwapExactAmountInRequests added in v0.11.0

func (k Keeper) SetSwapExactAmountInRequests(ctx sdk.Context, msg *types.MsgSwapExactAmountIn, index uint64)

SetSwapExactAmountInRequests stores swap exact amount in request

func (Keeper) SetSwapExactAmountOutRequests added in v0.11.0

func (k Keeper) SetSwapExactAmountOutRequests(ctx sdk.Context, msg *types.MsgSwapExactAmountOut, index uint64)

SetSwapExactAmountInRequests stores swap exact amount out request

func (*Keeper) SetTierKeeper added in v0.51.0

func (k *Keeper) SetTierKeeper(tk *tierkeeper.Keeper)

func (Keeper) SlippageTrack added in v0.13.0

func (Keeper) SlippageTrackAll added in v0.13.0

func (Keeper) SwapByDenom added in v0.46.0

func (k Keeper) SwapByDenom(ctx sdk.Context, msg *types.MsgSwapByDenom) (*types.MsgSwapByDenomResponse, error)

func (Keeper) SwapEstimation added in v0.13.0

func (Keeper) SwapEstimationByDenom added in v0.16.0

func (Keeper) SwapExactAmountIn

func (Keeper) SwapExactAmountOut

func (Keeper) SwapFeesToRevenueToken

func (k Keeper) SwapFeesToRevenueToken(ctx sdk.Context, pool types.Pool, fee sdk.Coins) error

No fee management required when doing swap from fees to revenue token

func (Keeper) SwapInAmtGivenOut added in v0.11.0

func (k Keeper) SwapInAmtGivenOut(
	ctx sdk.Context, poolId uint64, oracleKeeper types.OracleKeeper, snapshot *types.Pool,
	tokensOut sdk.Coins, tokenInDenom string, swapFee math.LegacyDec, weightBreakingFeePerpetualFactor math.LegacyDec) (
	tokenIn sdk.Coin, slippage, slippageAmount math.LegacyDec, weightBalanceBonus math.LegacyDec, err error,
)

SwapInAmtGivenOut is a mutative method for CalcOutAmtGivenIn, which includes the actual swap. weightBreakingFeePerpetualFactor should be 1 if perpetual is not the one calling this function

func (Keeper) SwapOutAmtGivenIn added in v0.11.0

func (k Keeper) SwapOutAmtGivenIn(
	ctx sdk.Context, poolId uint64,
	oracleKeeper types.OracleKeeper,
	snapshot *types.Pool,
	tokensIn sdk.Coins,
	tokenOutDenom string,
	swapFee sdkmath.LegacyDec,
	weightBreakingFeePerpetualFactor sdkmath.LegacyDec,
) (tokenOut sdk.Coin, slippage sdkmath.LegacyDec, slippageAmount sdkmath.LegacyDec, weightBalanceBonus sdkmath.LegacyDec, err error)

SwapOutAmtGivenIn is a mutative method for CalcOutAmtGivenIn, which includes the actual swap.

func (Keeper) TrackSlippage added in v0.13.0

func (k Keeper) TrackSlippage(ctx sdk.Context, poolId uint64, amount sdk.Coin)

func (Keeper) UpdatePoolForSwap

func (k Keeper) UpdatePoolForSwap(
	ctx sdk.Context,
	pool types.Pool,
	sender sdk.AccAddress,
	recipient sdk.AccAddress,
	tokenIn sdk.Coin,
	tokenOut sdk.Coin,
	swapFeeIn sdkmath.LegacyDec,
	swapFeeOut sdkmath.LegacyDec,
	weightBalanceBonus sdkmath.LegacyDec,
) (sdkmath.Int, error)

func (Keeper) UpdatePoolParams added in v0.18.0

func (k Keeper) UpdatePoolParams(ctx sdk.Context, poolId uint64, poolParams types.PoolParams) (uint64, types.PoolParams, error)

UpdatePoolParams updates the pool params

func (Keeper) V8Migrate added in v0.52.0

func (k Keeper) V8Migrate(ctx sdk.Context) error

Jump to

Keyboard shortcuts

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