concentrated_liquidity

package
v0.0.0-...-878d61a Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2023 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetMinAndMaxTicksFromExponentAtPriceOne

func GetMinAndMaxTicksFromExponentAtPriceOne(exponentAtPriceOne sdk.Int) (minTick, maxTick int64)

GetMinAndMaxTicksFromExponentAtPriceOne determines min and max ticks allowed for a given exponentAtPriceOne value This allows for a min spot price of 0.000000000000000001 and a max spot price of 100000000000000000000000000000000000000 for every exponentAtPriceOne value

func NewMsgCreatorServerImpl

func NewMsgCreatorServerImpl(keeper *Keeper) clmodel.MsgCreatorServer

func NewMsgServerImpl

func NewMsgServerImpl(keeper *Keeper) types.MsgServer

func ParseFullPositionFromBytes

func ParseFullPositionFromBytes(key, value []byte) (types.FullPositionByOwnerResult, error)

ParseFullPositionFromBytes parses a full position from key and value bytes. Returns a struct containing the pool id, lower tick, upper tick, frozen until, and liquidity associated with the position. Returns an error if the key or value is not found. Returns an error if fails to parse either.

func ParsePositionFromBz

func ParsePositionFromBz(bz []byte) (position model.Position, err error)

ParsePositionFromBz parses a position from a byte array. Returns a struct containing the liquidity associated with the position. Returns an error if the byte array is empty. Returns an error if fails to parse.

Types

type Keeper

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

func NewKeeper

func NewKeeper(cdc codec.BinaryCodec, storeKey sdk.StoreKey, bankKeeper types.BankKeeper, paramSpace paramtypes.Subspace) *Keeper

func (Keeper) CalcInAmtGivenOut

func (k Keeper) CalcInAmtGivenOut(
	ctx sdk.Context,
	poolI poolmanagertypes.PoolI,
	tokenOut sdk.Coin,
	tokenInDenom string,
	swapFee sdk.Dec,
) (tokenIn sdk.Coin, err error)

func (Keeper) CalcOutAmtGivenIn

func (k Keeper) CalcOutAmtGivenIn(
	ctx sdk.Context,
	poolI poolmanagertypes.PoolI,
	tokenIn sdk.Coin,
	tokenOutDenom string,
	swapFee sdk.Dec,
) (tokenOut sdk.Coin, err error)

func (Keeper) CreatePosition

func (k Keeper) CreatePosition(ctx sdk.Context, poolId uint64, owner sdk.AccAddress, amount0Desired, amount1Desired, amount0Min, amount1Min sdk.Int, lowerTick, upperTick int64, frozenUntil time.Time) (sdk.Int, sdk.Int, sdk.Dec, error)

CreatePosition creates a concentrated liquidity position in range between lowerTick and upperTick in a given `PoolId with the desired amount of each token. Since LPs are only allowed to provide liquidity proportional to the existing reserves, the actual amount of tokens used might differ from requested. As a result, LPs may also provide the minimum amount of each token to be used so that the system fails to create position if the desired amounts cannot be satisfied. On success, returns an actual amount of each token used and liquidity created. Returns error if: - the provided ticks are out of range / invalid - the pool provided does not exist - the liquidity delta is zero - the amount0 or amount1 returned from the position update is less than the given minimums - the pool or user does not have enough tokens to satisfy the requested amount

func (Keeper) ExportGenesis

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

ExportGenesis returns the concentrated-liquidity module's exported genesis state.

func (Keeper) GetAllPools

func (k Keeper) GetAllPools(ctx sdk.Context) ([]types.ConcentratedPoolExtension, error)

func (Keeper) GetParams

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

GetParams returns the total set of concentrated-liquidity module's parameters.

func (Keeper) GetPerTickLiquidityDepthFromRange

func (k Keeper) GetPerTickLiquidityDepthFromRange(ctx sdk.Context, poolId uint64, lowerTick, upperTick int64) ([]types.LiquidityDepth, error)

GetPerTickLiquidityDepthFromRange uses the given lower tick and upper tick, iterates over ticks, creates and returns LiquidityDepth array. LiquidityNet from the tick is used to indicate liquidity depths.

func (Keeper) GetPool

func (k Keeper) GetPool(ctx sdk.Context, poolId uint64) (poolmanagertypes.PoolI, error)

GetPool returns a pool with a given id.

func (Keeper) GetPosition

func (k Keeper) GetPosition(ctx sdk.Context, poolId uint64, owner sdk.AccAddress, lowerTick, upperTick int64, frozenUntil time.Time) (*model.Position, error)

GetPosition checks if a position exists at the provided upper and lower ticks and frozenUntil time for the given owner. Returns position if found.

func (Keeper) GetUserPositions

func (k Keeper) GetUserPositions(ctx sdk.Context, addr sdk.AccAddress) ([]types.FullPositionByOwnerResult, error)

GetUserPositions gets all the existing user positions across many pools.

func (Keeper) InitGenesis

func (k Keeper) InitGenesis(ctx sdk.Context, genState types.GenesisState)

InitGenesis initializes the concentrated-liquidity module with the provided genesis state.

func (Keeper) InitializePool

func (k Keeper) InitializePool(ctx sdk.Context, poolI poolmanagertypes.PoolI, creatorAddress sdk.AccAddress) error

InitializePool initializes a concentrated liquidity pool and sets it in state.

func (Keeper) SetParams

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

SetParams sets the concentrated-liquidity module's parameters with the provided parameters.

func (*Keeper) SetPoolManagerKeeper

func (k *Keeper) SetPoolManagerKeeper(poolmanagerKeeper types.PoolManagerKeeper)

Set the poolmanager keeper.

func (Keeper) SetTickInfo

func (k Keeper) SetTickInfo(ctx sdk.Context, poolId uint64, tickIndex int64, tickInfo model.TickInfo)

func (Keeper) SwapExactAmountIn

func (k Keeper) SwapExactAmountIn(
	ctx sdk.Context,
	sender sdk.AccAddress,
	poolI poolmanagertypes.PoolI,
	tokenIn sdk.Coin,
	tokenOutDenom string,
	tokenOutMinAmount sdk.Int,
	swapFee sdk.Dec,
) (tokenOutAmount sdk.Int, err error)

func (Keeper) SwapExactAmountOut

func (k Keeper) SwapExactAmountOut(
	ctx sdk.Context,
	sender sdk.AccAddress,
	poolI poolmanagertypes.PoolI,
	tokenInDenom string,
	tokenInMaxAmount sdk.Int,
	tokenOut sdk.Coin,
	swapFee sdk.Dec,
) (tokenInAmount sdk.Int, err error)

func (*Keeper) SwapInAmtGivenOut

func (k *Keeper) SwapInAmtGivenOut(
	ctx sdk.Context,
	desiredTokenOut sdk.Coin,
	tokenInDenom string,
	swapFee sdk.Dec,
	priceLimit sdk.Dec,
	poolId uint64,
) (calcTokenIn, calcTokenOut sdk.Coin, currentTick sdk.Int, liquidity, sqrtPrice sdk.Dec, err error)

func (Keeper) SwapOutAmtGivenIn

func (k Keeper) SwapOutAmtGivenIn(
	ctx sdk.Context,
	tokenIn sdk.Coin,
	tokenOutDenom string,
	swapFee sdk.Dec,
	priceLimit sdk.Dec,
	poolId uint64,
) (calcTokenIn, calcTokenOut sdk.Coin, currentTick sdk.Int, liquidity, sqrtPrice sdk.Dec, err error)

SwapOutAmtGivenIn is the internal mutative method for CalcOutAmtGivenIn. Utilizing CalcOutAmtGivenIn's output, this function applies the new tick, liquidity, and sqrtPrice to the respective pool

func (Keeper) WithdrawPosition

func (k Keeper) WithdrawPosition(ctx sdk.Context, poolId uint64, owner sdk.AccAddress, lowerTick, upperTick int64, frozenUntil time.Time, requestedLiquidityAmountToWithdraw sdk.Dec) (amtDenom0, amtDenom1 sdk.Int, err error)

WithdrawPosition attempts to withdraw liquidityAmount from a position with the given pool id in the given tick range. On success, returns a positive amount of each token withdrawn. Returns error if - there is no position in the given tick ranges - if tick ranges are invalid - if attempts to withdraw an amount higher than originally provided in createPosition for a given range.

type Querier

type Querier struct {
	Keeper
}

Querier defines a wrapper around the x/concentrated-liquidity keeper providing gRPC method handlers.

func NewQuerier

func NewQuerier(k Keeper) Querier

func (Querier) LiquidityDepthsForRange

LiquidityDepthsForRange returns liquidity depths for the given range.

func (Querier) Params

Params returns module params

func (Querier) Pool

Pool checks if a pool exists and returns the desired pool.

func (Querier) Pools

Pools returns all concentrated pools in existence.

func (Querier) UserPositions

UserPositions returns positions of a specified address

type SwapState

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

Directories

Path Synopsis
client
cli
internal
Package types is a reverse proxy.
Package types is a reverse proxy.

Jump to

Keyboard shortcuts

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