pool.gno

Defines the basic functionality of a liquidity pool such as adding and removing liquidity or performing swaps.

Mint

func Mint(
	token0Path string,
	token1Path string,
	fee uint32,
	recipient string,
	tickLower int32,
	tickUpper int32,
	_liquidityAmount string,
) (string, string)

Adds liquidity to a pool. This function can only be called by the Position contract, not by users.

Parameters

NameTypeDescription

token0Path

string

The path of token0 of the desired pool.

token1Path

string

The path of token1 of the desired pool.

fee

uint32

The fee tier of the desired pool.

recipient

string

The address that will receive the minted position.

tickLower

int32

The lower tick of the price range of the position.

tickUpper

int32

The upper tick of the price range of the position.

liquidityAmount

string

The amount of liquidity to add. This value is calculated by the Position contract based on the amounts of token0 & token1, and the price.

Return Values

NameTypeDescription

amount0

string

The amount of token0 that added to the liquidity pool to mint the position.

amount1

string

The amount of token1 that added to the liquidity pool to mint the position.

Burn

func Burn(
	token0Path string,
	token1Path string,
	fee uint32,
	tickLower int32,
	tickUpper int32,
	_liquidityAmount string,
) (string, string)

Removes liquidity from a pool. This function can only be called by the Position contract, not by users.

Parameters

NameTypeDescription

token0Path

string

The path of token0 of the desired pool.

token1Path

string

The path of token1 of the desired pool.

fee

uint32

The fee tier of the desired pool.

tickLower

int32

The lower tick of the price range of the position.

tickUpper

int32

The upper tick of the price range of the position.

liquidityAmount

string

The amount of liquidity to remove.

Return Values

NameTypeDescription

amount0

string

The amount of token0 that was removed from the pool by burning the position.

amount1

string

The amount of token1 that was removed from the pool by burning the position.

Collect

func Collect(
	token0Path string,
	token1Path string,
	fee uint32,
	recipient string,
	tickLower int32,
	tickUpper int32,
	amount0Requested string,
	amount1Requested string,
) (string, string)

Collects swap fees in token0 and token1 accrued to a position. This function can only be called by the Position contract, not by users.

Parameters

NameTypeDescription

token0Path

string

The path of token0 of the desired pool.

token1Path

string

The path of token1 of the desired pool.

fee

uint32

The fee tier of the desired pool.

recipient

string

The address that will receive the collected fees.

tickLower

int32

The lower tick of the price range of the position.

tickUpper

int32

The upper tick of the price range of the position.

amount0Requested

string

The maximum amount of tokens0 to collect from the pool.

amount1Requested

string

The maximum amount of tokens1 to collect from the pool.

Return Values

NameTypeDescription

amount0

string

The amount of token0 that was collected from the position.

amount1

string

The amount of token1 that was collected from the position.

Swap

func Swap(
	token0Path string,
	token1Path string,
	fee uint32,
	recipient string,
	zeroForOne bool,
	amountSpecified string,
	sqrtPriceLimitX96 string,
	payer string, // router
) (string, string)

Swaps tokens from a pool from token0 to token1, or vice versa. This function can only be called by the Router contract, not by users.

Parameters

NameTypeDescription

token0Path

string

The path of token0 of the desired pool.

token1Path

string

The path of token1 of the desired pool.

fee

uint32

The fee tier of the desired pool.

recipient

string

The address that will receive the output of the swap.

zeroForOne

bool

The direction of the swap. Set to true for swapping token0 to token1, and false for vice versa.

amountSpecified

string

The amount of tokens to swap. Set to a positive value for an exact input, and a negative value for an exact output.

sqrtPriceLimitX96

string

The maximum price to accept for the swap.

payer

string

The address from which to send the output tokens. (Relates to the Router contract)

Return Values

NameTypeDescription

amount0

string

The change in the amount of token0 as the result of the swap.

amount1

string

The change in the amount of token1 as the result of the swap.

SetFeeProtocol

func SetFeeProtocol(
	feeProtocol0 uint8,
	feeProtocol1 uint8,
)

Sets the Protocol Fee that is applied to all swaps.

Parameters

NameTypeDescription

feeProtocol0

uint8

The Protocol Fee for token0 of the desired pool.

feeProtocol1

uint8

The Protocol Fee for token1 of the desired pool.

CollectProtocol

func CollectProtocol(
	token0Path string,
	token1Path string,
	fee uint32,
	recipient string,
	amount0Requested string,
	amount1Requested string,
) (string, string)

Collects the Protocol Fee claimable from a pool.

Parameters

NameTypeDescription

token0Path

string

The path of token0 of the desired pool.

token1Path

string

The path of token1 of the desired pool.

fee

uint32

The fee tier of the desired pool.

recipient

string

The address that will receive the collected Protocol Fee.

amount0Requested

string

The maximum amount of token0 to collect from the pool.

amount1Requested

string

The maximum amount of tokens1 to collect from the pool.

Return Values

NameTypeDescription

amount0

string

The amount of token0 that was collected from the pool.

amount1

string

The amount of token1 that was collected from the pool.

Last updated