SONEX V3 Contract Deployments and Liquidity Guide

Introduction

SONEX currently supports V3 contract deployments exclusively, offering advanced features to enable seamless pool creation, liquidity provisioning, and trading. This guide explains the deployed contracts, their functions, and how to interact with them for pool creation and liquidity management.

Contract Addresses

Below is the complete list of SONEX V3 contract addresses:

Type
Contract Address

FACTORY

0x3E4ff8662820E3dec3DACDb66ef1FFad5Dc5Ab83

FACTORY_MULTICALL

0x73348e34bE30A2275E78f88185542f986c4Fe6E9

PROXY_ADMIN

0x947391374Fe2d4ED1173F644049104993cF2AE00

TRANSPARENT_UPGRADABLE_PROXY

0xD5B959339E58f0A1dd2dD53412c32B0c8872F05c

TICK_LENS

0xf8369D9023657749521FB1Bef6F7A520ce898A13

SWAP_ROUTER

0xDEf357D505690F1b0032a74C3b581163c23d1535

SWAP_ROUTER_V2

0xd2DdF58Bcc188F335061e41C73ED2A8894c2dD98

NFT_DESCRIPTOR

0x80557c2EaE4A28E7101d6D7473f87f73Dfd07d71

POSITION_DESCRIPTOR

0x9C31f28b0f46CCa5D2CD64485936984C271382A1

POSITION_MANAGER

0x6f5F9d55f727928b644B04d987B1c0Cf50AF8C0B

QUOTER

0x12528928e792e6665d52d77c1F59d3e1adBD14DA

QUOTER_V2

0x715BE426a0c8E0A14aBc0130f08F06aa41B1f218

Key Functionalities

1. createPool

Creates a pool for the given two tokens and fee.

Note :

  • tokenA and tokenB may be passed in either order: token0/token1 or token1/token0. tickSpacing is retrieved from the fee. The call will revert if the pool already exists, the fee is invalid, or the token arguments are invalid.

Parameter :

  • tokenA:The contract address of either token0 or token1.

  • tokenB:The contract address of the other token.

  • fee:The fee collected upon every swap in the pool, denominated in hundredths of a bip.

Return :

  • pool:The pool address.

  function createPool(
    address tokenA,
    address tokenB,
    uint24 fee
  ) external returns (address pool)

2. Checking Pool Existence Function

Use the getPool function in the FACTORY contract to check if a pool already exists.

Parameter:

  • tokenA:The contract address of either token0 or token1.

  • tokenB:The contract address of the other token.

  • fee:The fee collected upon every swap in the pool, denominated in hundredths of a bip.

Return:

  • pool:The pool address.

  function getPool(
    address tokenA,
    address tokenB,
    uint24 fee
  ) external view returns (address pool)

3. Adding Liquidity

Adds liquidity to an ERC-20⇄ERC-20 pool.

Note:

  • To cover all possible scenarios, msg.sender should have already given the router an allowance of at least amountADesired/amountBDesired on tokenA/tokenB.

  • Always adds assets at the ideal ratio, according to the price when the transaction is executed.

  • If a pool for the passed tokens does not exists, one is created automatically, and exactly amountADesired/amountBDesired tokens are added.

Parameter:

  • tokenA:A pool token.

  • tokenB:A pool token.

  • amountADesired:The amount of tokenA to add as liquidity if the B/A price is <= amountBDesired/amountADesired (A depreciates).

  • amountBDesired:The amount of tokenB to add as liquidity if the A/B price is <= amountADesired/amountBDesired (B depreciates).

  • amountAMin:Bounds the extent to which the B/A price can go up before the transaction reverts. Must be <= amountADesired.

  • amountBMin:Bounds the extent to which the A/B price can go up before the transaction reverts. Must be <= amountBDesired.

  • to:Recipient of the liquidity tokens.

  • deadline: Unix timestamp after which the transaction will revert.

Return:

  • amountA:The amount of tokenA sent to the pool.

  • amountB:The amount of tokenB sent to the pool.

  • liquidity:The amount of liquidity tokens minted.

function addLiquidity(
  address tokenA,
  address tokenB,
  uint amountADesired,
  uint amountBDesired,
  uint amountAMin,
  uint amountBMin,
  address to,
  uint deadline
) external returns (uint amountA, uint amountB, uint liquidity)

4. addLiquidityETH

Adds liquidity to an ERC-20⇄WETH pool with ETH.

Note:

  • To cover all possible scenarios, msg.sender should have already given the router an allowance of at least amountTokenDesired on token.

  • Always adds assets at the ideal ratio, according to the price when the transaction is executed.

  • msg.value is treated as a amountETHDesired.

  • Leftover ETH, if any, is returned to msg.sender.

  • If a pool for the passed token and WETH does not exists, one is created automatically, and exactly amountTokenDesired/msg.value tokens are added.

Parameter:

  • token:A pool token.

  • amountTokenDesired:The amount of token to add as liquidity if the WETH/token price is <= msg.value/amountTokenDesired (token depreciates).

  • msg.value (amountETHDesired):The amount of ETH to add as liquidity if the token/WETH price is <= amountTokenDesired/msg.value (WETH depreciates).

  • amountTokenMin:Bounds the extent to which the WETH/token price can go up before the transaction reverts. Must be <= amountTokenDesired.

  • amountETHMin:Bounds the extent to which the token/WETH price can go up before the transaction reverts. Must be <= msg.value.

  • to:Recipient of the liquidity tokens.

  • deadline:Unix timestamp after which the transaction will revert.

Return:

  • amountToken:The amount of token sent to the pool.

  • amountETH:The amount of ETH converted to WETH and sent to the pool.

  • liquidity:The amount of liquidity tokens minted.

function addLiquidityETH(
  address token,
  uint amountTokenDesired,
  uint amountTokenMin,
  uint amountETHMin,
  address to,
  uint deadline
) external payable returns (uint amountToken, uint amountETH, uint liquidity);

5. removeLiquidity

Removes liquidity from an ERC-20⇄ERC-20 pool.

Note :

  • msg.sender should have already given the router an allowance of at least liquidity on the pool.

Parameter:

  • tokenA:A pool token.

  • tokenB:A pool token.

  • liquidity:The amount of liquidity tokens to remove.

  • amountAMin: Bounds the extent to which the B/A price can go up before the transaction reverts. Must be <= amountADesired.

  • amountBMin: Bounds the extent to which the A/B price can go up before the transaction reverts. Must be <= amountBDesired.

  • to:Recipient of the liquidity tokens.

  • deadline: Unix timestamp after which the transaction will revert.

Return :

  • amountA: The amount of tokenA sent to the pool.

  • amountB :The amount of tokenB sent to the pool.

function removeLiquidity(
  address tokenA,
  address tokenB,
  uint liquidity,
  uint amountAMin,
  uint amountBMin,
  address to,
  uint deadline
) external returns (uint amountA, uint amountB);

6. removeLiquidityETH

Removes liquidity from an ERC-20⇄WETH pool and receive ETH.

Note:

  • msg.sender should have already given the router an allowance of at least liquidity on the pool.

Parameter :

  • token: A pool token.

  • liquidity:The amount of liquidity tokens to remove.

  • amountTokenMin:Bounds the extent to which the WETH/token price can go up before the transaction reverts. Must be <= amountTokenDesired.

  • amountETHMin:Bounds the extent to which the token/WETH price can go up before the transaction reverts. Must be <= msg.value.

  • to: Recipient of the liquidity tokens.

  • deadline:Unix timestamp after which the transaction will revert.

Return:

  • amountToken:The amount of token received.

  • amountETH:The amount of ETH received.

function removeLiquidityETH(
  address token,
  uint liquidity,
  uint amountTokenMin,
  uint amountETHMin,
  address to,
  uint deadline
) external returns (uint amountToken, uint amountETH);

Last updated