GnoSwap Docs
  • Welcome
  • Why GnoSwap?
  • Disclaimer
    • General Disclaimer
    • Risk and Security
  • User Guide
    • Getting Started
      • Create an Account
        • Adena Wallet
        • Social Login
      • Connect to GnoSwap
      • Quick Tour
    • Trading
      • Swap Tokens
      • Swap With Details
    • Providing Liquidity
      • Create a Pool
      • Create a Position
      • Remove a Position
      • Reposition
      • Increase Liquidity
      • Decrease Liquidity
    • Staking
      • Stake Positions
      • Claim Rewards
      • Unstake Positions
      • Add Incentives
    • Launchpad
      • Participate in Launches
    • Governance
      • Delegate
      • Undelegate
      • Create a Proposal
      • Vote
  • core concepts
    • AMM
      • Constant Product Market Maker
      • Problem: Lazy Liquidity
      • Concentrated Liquidity
    • Positions
    • Liquidity Mining
    • Fees
    • Governance
    • Launchpad
  • GnoSwap Token
    • What's GNS?
    • Genesis Supply
    • Emission
    • Release Schedule
    • xGNS
  • Contracts
    • Overview
    • Errors
      • Pool
      • Position
      • Router
      • Staker
      • Governance
      • Launchpad
    • Pool
      • pool.gno
      • pool_manager.gno
      • protocol_fee_pool_creation.gno
      • protocol_fee_withdrawal.gno
    • Position
      • position.gno
    • Router
      • exact_in.gno
      • exact_out.gno
      • protocol_fee_swap.gno
    • Staker
      • staker.gno
      • mint_stake.gno
      • protocol_fee_unstaking.gno
      • external_deposit_fee.gno
    • Governance
      • staker.gno
      • proposal.gno
      • vote.gno
      • execute.gno
    • Launchpad
      • launchpad.gno
      • deposit.gno
      • reward.gno
  • References
    • Onboarding Guide
    • Warm-up Periods
    • Leaderboard
    • VWAP
    • FAQ
  • urls
    • GitHub
    • X (Twitter)
    • Discord
    • Medium
Powered by GitBook
On this page
  • Mint
  • IncreaseLiquidity
  • DecreaseLiquidity
  • CollectFee
  • Reposition

Was this helpful?

  1. Contracts
  2. Position

position.gno

PreviousPositionNextRouter

Last updated 3 months ago

Was this helpful?

Adds or removes liquidity from pools. Includes minting and burning of positions.

Mint

func Mint(
	token0 string,
	token1 string,
	fee uint32,
	tickLower int32,
	tickUpper int32,
	amount0Desired string,
	amount1Desired string,
	amount0Min string,
	amount1Min string,
	deadline int64,
	mintTo std.Address,
	caller std.Address
) (uint64, string, string, string)

Adds liquidity to a pool. Internally calls the mint function of the pool contract.

Parameters

Name
Type
Description

token0

string

The path of the token0 of the desired pool.

token1

string

The path of the token1 of the desired pool.

fee

uint32

The fee tier of the 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.

amount0Desired

string

The maximum amount of token0 to add.

amount1Desired

string

The maximum amount of token1 to add.

amount0Min

string

The minimum amount of token0 to add.

amount1Min

string

The minimum amount of token1 to add.

deadline

int64

The deadline at which the transaction will expire.

mintTo

std.Address

The address to receive the minted position.

caller

std.Address

The caller address from staker (for one-click staking).

Return Values

Name
Type
Description

positionId

uint64

The ID of the position that was minted.

liquidity

string

The amount of liquidity added to the pool.

amount0

string

The amount of token0 added to the pool.

amount1

string

The amount of token1 added to the pool.

IncreaseLiquidity

func IncreaseLiquidity(
	positionId uint64,
	amount0Desired string,
	amount1Desired string,
	amount0Min string,
	amount1Min string,
	deadline int64,
) (uint64, string, string, string, string)

Adds additional liquidity to an existing position. Calling this function on a closed position will reopen it.

Parameters

Name
Type
Description

positionId

uint64

The ID of the position NFT in which to increase liquidity.

amount0Desired

string

The maximum amount of token0 to increase.

amount1Desired

string

The maximum amount of token1 to increase.

amount0Min

string

The minimum amount of token0 to increase.

amount1Min

string

The minimum amount of token1 to increase.

deadline

int64

The deadline at which the transaction will expire.

Return Values

Name
Type
Description

positionId

uint64

The ID of the position that the liquidity was increased.

liquidity

string

The amount of liquidity added to the position.

amount0

string

The amount of token0 added to the position.

amount1

string

The amount of token1 added to the position.

poolPath

string

The path of the pool from which the position exists.

DecreaseLiquidity

func DecreaseLiquidity(
	positionId uint64,
	liquidityStr uint64,
	amount0Min string,
	amount1Min string,
	deadline int64,
	unwrapResult bool,
) (uint64, string, string, string, string, string, string)

Decreases liquidity of an existing position.

Parameters

Name
Type
Description

positionId

uint64

The ID of the position to decrease liquidity from.

liquidityStr

string

The amount of liquidity to decrease.

amount0Min

string

The minimum amount of token0 to decrease.

amount1Min

string

The minimum amount of token1 to decrease.

deadline

int64

The deadline at which the transaction will expire.

unwrapResult

bool

Whether or not to receive tokens in native ugnot if either token0 or token1 is wugnot.

Return Values

Name
Type
Description

positionId

uint64

The ID of the position that the liquidity was decreased.

liquidity

string

The amount of liquidity decreased from the position.

fee0

string

The amount of token0 fees collected.

fee1

string

The amount of token1 fees collected.

amount0

string

The amount of token0 decreased from the position.

amount1

string

The amount of token1 decreased from the position.

poolPath

string

The path of the pool in which the position exists.

CollectFee

func CollectFee(
  positionId uint64, 
  unwrapResult bool
) (uint64, string, string, string, string, string)

Collects fee accrued to a position.

Parameters

Name
Type
Description

positionId

uint64

The ID of the position.

unwrapResult

bool

(if position has wugnot fee) whether to receive fee in ugnot or not.

Return Values

Name
Type
Description

positionId

uint64

The ID of the position.

afterFee0

string

The amount of token0 that was collected.

afterFee1

string

The amount of token1 that was collected.

poolPath

string

The path of the pool from which the position exists.

origFee0

string

The fee amount of token0 before taking protocol fee.

origFee1

string

The fee amount of token1 before taking protocol fee.

Reposition

func Reposition(
	positionId uint64,
	tickLower int32,
	tickUpper int32,
	amount0Desired string, 
	amount1Desired string, 
	amount0Min string, 
	amount1Min string,
) (uint64, string, int32, int32, string, string)

Modifies the price range of a closed position while maintaining the positionId.

Parameters

Name
Type
Description

positionId

uint64

The ID of the 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.

amount0Desired

string

The maximum amount of token0 to add.

amount1Desired

string

The maximum amount of token1 to add.

amount0Min

string

The minimum amount of token0 to add.

amount1Min

string

The minimum amount of token1 to add.

Return Values

Name
Type
Description

positionId

uint64

The ID of the position.

liquidity

string

The new liquidity amount.

tickLower

int32

The modified lower tick.

tickUpper

int32

The modified upper tick.

amount0

string

The amount of token0 added to the position.

amount1

string

The amount of token1 added to the position.

gnoswap/contract/r/gnoswap/position/position.gno at main · gnoswap-labs/gnoswapGitHub
Logo