Technical Reference
Contracts
Router

Because routers are stateless and do not hold token balances, they can be replaced safely and trustlessly, if necessary. This may happen if more efficient smart contract patterns are discovered, or if additional functionality is desired. For this reason, routers have release numbers, starting at 01. This is currently recommended release, 02.

Read-Only Functions

factory

function factory() external pure returns (address);

Returns factory address.

WAREA

function WAREA() external pure returns (address);

quote

See quote.

getAmountOut

See getAmountOut.

getAmountIn

See getAmountIn.

getAmountsOut

function getAmountsOut(uint amountIn, address[] memory path) public view returns (uint[] memory amounts);

See getAmountsOut.

getAmountsIn

function getAmountsIn(uint amountOut, address[] memory path) public view returns (uint[] memory amounts);

See getAmountsIn.

State-Changing Functions

addLiquidity

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

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

  • 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.
NameType
tokenAaddressA pool token.
tokenBaddressA pool token.
amountADesireduintThe amount of tokenA to add as liquidity if the B/A price is <= amountBDesired/amountADesired (A depreciates).
amountBDesireduintThe amount of tokenB to add as liquidity if the A/B price is <= amountADesired/amountBDesired (B depreciates).
amountAMinuintBounds the extent to which the B/A price can go up before the transaction reverts. Must be <= amountADesired.
amountBMinuintBounds the extent to which the A/B price can go up before the transaction reverts. Must be <= amountBDesired.
toaddressRecipient of the liquidity tokens.
deadlineuintUnix timestamp after which the transaction will revert.
amountAuintThe amount of tokenA sent to the pool.
amountBuintThe amount of tokenB sent to the pool.
liquidityuintThe amount of liquidity tokens minted.

addLiquidityAREA

function addLiquidityAREA(
  address token,
  uint amountTokenDesired,
  uint amountTokenMin,
  uint amountAREAMin,
  address to,
  uint deadline
) external payable returns (uint amountToken, uint amountAREA, uint liquidity);

Adds liquidity to an ARC-20⇄WAREA pool with AREA.

  • 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 amountAREADesired.
  • Leftover AREA, if any, is returned to msg.sender.
  • If a pool for the passed token and WAREA does not exists, one is created automatically, and exactly amountTokenDesired/msg.value tokens are added.
NameType
tokenaddressA pool token.
amountTokenDesireduintThe amount of token to add as liquidity if the WAREA/token price is <= msg.value/amountTokenDesired (token depreciates).
msg.value (amountAREADesired)uintThe amount of AREA to add as liquidity if the token/WAREA price is <= amountTokenDesired/msg.value (WAREA depreciates).
amountTokenMinuintBounds the extent to which the WAREA/token price can go up before the transaction reverts. Must be <= amountTokenDesired.
amountAREAMinuintBounds the extent to which the token/WAREA price can go up before the transaction reverts. Must be <= msg.value.
toaddressRecipient of the liquidity tokens.
deadlineuintUnix timestamp after which the transaction will revert.
amountTokenuintThe amount of token sent to the pool.
amountAREAuintThe amount of AREA converted to WAREA and sent to the pool.
liquidityuintThe amount of liquidity tokens minted.

removeLiquidity

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

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

  • msg.sender should have already given the router an allowance of at least liquidity on the pool.
NameType
tokenAaddressA pool token.
tokenBaddressA pool token.
liquidityuintThe amount of liquidity tokens to remove.
amountAMinuintThe minimum amount of tokenA that must be received for the transaction not to revert.
amountBMinuintThe minimum amount of tokenB that must be received for the transaction not to revert.
toaddressRecipient of the underlying assets.
deadlineuintUnix timestamp after which the transaction will revert.
amountAuintThe amount of tokenA received.
amountBuintThe amount of tokenB received.

removeLiquidityAREA

function removeLiquidityAREA(
  address token,
  uint liquidity,
  uint amountTokenMin,
  uint amountAREAMin,
  address to,
  uint deadline
) external returns (uint amountToken, uint amountAREA);

Removes liquidity from an ARC-20⇄WAREA pool and receive AREA.

  • msg.sender should have already given the router an allowance of at least liquidity on the pool.
NameType
tokenaddressA pool token.
liquidityuintThe amount of liquidity tokens to remove.
amountTokenMinuintThe minimum amount of token that must be received for the transaction not to revert.
amountAREAMinuintThe minimum amount of AREA that must be received for the transaction not to revert.
toaddressRecipient of the underlying assets.
deadlineuintUnix timestamp after which the transaction will revert.
amountTokenuintThe amount of token received.
amountAREAuintThe amount of AREA received.

removeLiquidityWithPermit

function removeLiquidityWithPermit(
  address tokenA,
  address tokenB,
  uint liquidity,
  uint amountAMin,
  uint amountBMin,
  address to,
  uint deadline,
  bool approveMax, uint8 v, bytes32 r, bytes32 s
) external returns (uint amountA, uint amountB);

Removes liquidity from an ARC-20⇄ARC-20 pool without pre-approval, thanks to permit.

NameType
tokenAaddressA pool token.
tokenBaddressA pool token.
liquidityuintThe amount of liquidity tokens to remove.
amountAMinuintThe minimum amount of tokenA that must be received for the transaction not to revert.
amountBMinuintThe minimum amount of tokenB that must be received for the transaction not to revert.
toaddressRecipient of the underlying assets.
deadlineuintUnix timestamp after which the transaction will revert.
approveMaxboolWhether or not the approval amount in the signature is for liquidity or uint(-1).
vuint8The v component of the permit signature.
rbytes32The r component of the permit signature.
sbytes32The s component of the permit signature.
amountAuintThe amount of tokenA received.
amountBuintThe amount of tokenB received.

removeLiquidityAREAWithPermit

function removeLiquidityAREAWithPermit(
  address token,
  uint liquidity,
  uint amountTokenMin,
  uint amountAREAMin,
  address to,
  uint deadline,
  bool approveMax, uint8 v, bytes32 r, bytes32 s
) external returns (uint amountToken, uint amountAREA);

Removes liquidity from an ARC-20⇄WETTH pool and receive AREA without pre-approval, thanks to permit.

NameType
tokenaddressA pool token.
liquidityuintThe amount of liquidity tokens to remove.
amountTokenMinuintThe minimum amount of token that must be received for the transaction not to revert.
amountAREAMinuintThe minimum amount of AREA that must be received for the transaction not to revert.
toaddressRecipient of the underlying assets.
deadlineuintUnix timestamp after which the transaction will revert.
approveMaxboolWhether or not the approval amount in the signature is for liquidity or uint(-1).
vuint8The v component of the permit signature.
rbytes32The r component of the permit signature.
sbytes32The s component of the permit signature.
amountTokenuintThe amount of token received.
amountAREAuintThe amount of AREA received.

removeLiquidityAREASupportingFeeOnTransferTokens

function removeLiquidityAREASupportingFeeOnTransferTokens(
  address token,
  uint liquidity,
  uint amountTokenMin,
  uint amountAREAMin,
  address to,
  uint deadline
) external returns (uint amountAREA);

Identical to removeLiquidityAREA, but succeeds for tokens that take a fee on transfer.

  • msg.sender should have already given the router an allowance of at least liquidity on the pool.
NameType
tokenaddressA pool token.
liquidityuintThe amount of liquidity tokens to remove.
amountTokenMinuintThe minimum amount of token that must be received for the transaction not to revert.
amountAREAMinuintThe minimum amount of AREA that must be received for the transaction not to revert.
toaddressRecipient of the underlying assets.
deadlineuintUnix timestamp after which the transaction will revert.
amountAREAuintThe amount of AREA received.

removeLiquidityAREAWithPermitSupportingFeeOnTransferTokens

function removeLiquidityAREAWithPermitSupportingFeeOnTransferTokens(
  address token,
  uint liquidity,
  uint amountTokenMin,
  uint amountAREAMin,
  address to,
  uint deadline,
  bool approveMax, uint8 v, bytes32 r, bytes32 s
) external returns (uint amountAREA);

Identical to removeLiquidityAREAWithPermit, but succeeds for tokens that take a fee on transfer.

NameType
tokenaddressA pool token.
liquidityuintThe amount of liquidity tokens to remove.
amountTokenMinuintThe minimum amount of token that must be received for the transaction not to revert.
amountAREAMinuintThe minimum amount of AREA that must be received for the transaction not to revert.
toaddressRecipient of the underlying assets.
deadlineuintUnix timestamp after which the transaction will revert.
approveMaxboolWhether or not the approval amount in the signature is for liquidity or uint(-1).
vuint8The v component of the permit signature.
rbytes32The r component of the permit signature.
sbytes32The s component of the permit signature.
amountAREAuintThe amount of AREA received.

swapExactTokensForTokens

function swapExactTokensForTokens(
  uint amountIn,
  uint amountOutMin,
  address[] calldata path,
  address to,
  uint deadline
) external returns (uint[] memory amounts);

Swaps an exact amount of input tokens for as many output tokens as possible, along the route determined by the path. The first element of path is the input token, the last is the output token, and any intermediate elements represent intermediate pairs to trade through (if, for example, a direct pair does not exist).

  • msg.sender should have already given the router an allowance of at least amountIn on the input token.
NameType
amountInuintThe amount of input tokens to send.
amountOutMinuintThe minimum amount of output tokens that must be received for the transaction not to revert.
pathaddress[] calldataAn array of token addresses. path.length must be >= 2. Pools for each consecutive pair of addresses must exist and have liquidity.
toaddressRecipient of the output tokens.
deadlineuintUnix timestamp after which the transaction will revert.
amountsuint[] memoryThe input token amount and all subsequent output token amounts.

swapTokensForExactTokens

function swapTokensForExactTokens(
  uint amountOut,
  uint amountInMax,
  address[] calldata path,
  address to,
  uint deadline
) external returns (uint[] memory amounts);

Receive an exact amount of output tokens for as few input tokens as possible, along the route determined by the path. The first element of path is the input token, the last is the output token, and any intermediate elements represent intermediate tokens to trade through (if, for example, a direct pair does not exist).

  • msg.sender should have already given the router an allowance of at least amountInMax on the input token.
NameType
amountOutuintThe amount of output tokens to receive.
amountInMaxuintThe maximum amount of input tokens that can be required before the transaction reverts.
pathaddress[] calldataAn array of token addresses. path.length must be >= 2. Pools for each consecutive pair of addresses must exist and have liquidity.
toaddressRecipient of the output tokens.
deadlineuintUnix timestamp after which the transaction will revert.
amountsuint[] memoryThe input token amount and all subsequent output token amounts.

swapExactAREAForTokens

function swapExactAREAForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)
  external
  payable
  returns (uint[] memory amounts);

Swaps an exact amount of AREA for as many output tokens as possible, along the route determined by the path. The first element of path must be WAREA, the last is the output token, and any intermediate elements represent intermediate pairs to trade through (if, for example, a direct pair does not exist).

NameType
msg.value (amountIn)uintThe amount of AREA to send.
amountOutMinuintThe minimum amount of output tokens that must be received for the transaction not to revert.
pathaddress[] calldataAn array of token addresses. path.length must be >= 2. Pools for each consecutive pair of addresses must exist and have liquidity.
toaddressRecipient of the output tokens.
deadlineuintUnix timestamp after which the transaction will revert.
amountsuint[] memoryThe input token amount and all subsequent output token amounts.

swapTokensForExactAREA

function swapTokensForExactAREA(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)
  external
  returns (uint[] memory amounts);

Receive an exact amount of AREA for as few input tokens as possible, along the route determined by the path. The first element of path is the input token, the last must be WAREA, and any intermediate elements represent intermediate pairs to trade through (if, for example, a direct pair does not exist).

  • msg.sender should have already given the router an allowance of at least amountInMax on the input token.
  • If the to address is a smart contract, it must have the ability to receive AREA.
NameType
amountOutuintThe amount of AREA to receive.
amountInMaxuintThe maximum amount of input tokens that can be required before the transaction reverts.
pathaddress[] calldataAn array of token addresses. path.length must be >= 2. Pools for each consecutive pair of addresses must exist and have liquidity.
toaddressRecipient of AREA.
deadlineuintUnix timestamp after which the transaction will revert.
amountsuint[] memoryThe input token amount and all subsequent output token amounts.

swapExactTokensForAREA

function swapExactTokensForAREA(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)
  external
  returns (uint[] memory amounts);

Swaps an exact amount of tokens for as much AREA as possible, along the route determined by the path. The first element of path is the input token, the last must be WAREA, and any intermediate elements represent intermediate pairs to trade through (if, for example, a direct pair does not exist).

  • If the to address is a smart contract, it must have the ability to receive AREA.
NameType
amountInuintThe amount of input tokens to send.
amountOutMinuintThe minimum amount of output tokens that must be received for the transaction not to revert.
pathaddress[] calldataAn array of token addresses. path.length must be >= 2. Pools for each consecutive pair of addresses must exist and have liquidity.
toaddressRecipient of the AREA.
deadlineuintUnix timestamp after which the transaction will revert.
amountsuint[] memoryThe input token amount and all subsequent output token amounts.

swapAREAForExactTokens

function swapAREAForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)
  external
  payable
  returns (uint[] memory amounts);

Receive an exact amount of tokens for as little AREA as possible, along the route determined by the path. The first element of path must be WAREA, the last is the output token and any intermediate elements represent intermediate pairs to trade through (if, for example, a direct pair does not exist).

  • Leftover AREA, if any, is returned to msg.sender.
NameType
amountOutuintThe amount of tokens to receive.
msg.value (amountInMax)uintThe maximum amount of AREA that can be required before the transaction reverts.
pathaddress[] calldataAn array of token addresses. path.length must be >= 2. Pools for each consecutive pair of addresses must exist and have liquidity.
toaddressRecipient of the output tokens.
deadlineuintUnix timestamp after which the transaction will revert.
amountsuint[] memoryThe input token amount and all subsequent output token amounts.

swapExactTokensForTokensSupportingFeeOnTransferTokens

function swapExactTokensForTokensSupportingFeeOnTransferTokens(
  uint amountIn,
  uint amountOutMin,
  address[] calldata path,
  address to,
  uint deadline
) external;

Identical to swapExactTokensForTokens, but succeeds for tokens that take a fee on transfer.

  • msg.sender should have already given the router an allowance of at least amountIn on the input token.
NameType
amountInuintThe amount of input tokens to send.
amountOutMinuintThe minimum amount of output tokens that must be received for the transaction not to revert.
pathaddress[] calldataAn array of token addresses. path.length must be >= 2. Pools for each consecutive pair of addresses must exist and have liquidity.
toaddressRecipient of the output tokens.
deadlineuintUnix timestamp after which the transaction will revert.

swapExactAREAForTokensSupportingFeeOnTransferTokens

function swapExactAREAForTokensSupportingFeeOnTransferTokens(
  uint amountOutMin,
  address[] calldata path,
  address to,
  uint deadline
) external payable;

Identical to swapExactAREAForTokens, but succeeds for tokens that take a fee on transfer.

NameType
msg.value (amountIn)uintThe amount of AREA to send.
amountOutMinuintThe minimum amount of output tokens that must be received for the transaction not to revert.
pathaddress[] calldataAn array of token addresses. path.length must be >= 2. Pools for each consecutive pair of addresses must exist and have liquidity.
toaddressRecipient of the output tokens.
deadlineuintUnix timestamp after which the transaction will revert.

swapExactTokensForAREASupportingFeeOnTransferTokens

function swapExactTokensForAREASupportingFeeOnTransferTokens(
  uint amountIn,
  uint amountOutMin,
  address[] calldata path,
  address to,
  uint deadline
) external;

Identical to swapExactTokensForAREA, but succeeds for tokens that take a fee on transfer.

  • If the to address is a smart contract, it must have the ability to receive AREA.
NameType
amountInuintThe amount of input tokens to send.
amountOutMinuintThe minimum amount of output tokens that must be received for the transaction not to revert.
pathaddress[] calldataAn array of token addresses. path.length must be >= 2. Pools for each consecutive pair of addresses must exist and have liquidity.
toaddressRecipient of the AREA.
deadlineuintUnix timestamp after which the transaction will revert.

Interface

pragma solidity >=0.6.2;
 
interface IHyperswapV2Router01 {
    function factory() external pure returns (address);
    function WAREA() external pure returns (address);
 
    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);
    function addLiquidityAREA(
        address token,
        uint amountTokenDesired,
        uint amountTokenMin,
        uint amountAREAMin,
        address to,
        uint deadline
    ) external payable returns (uint amountToken, uint amountAREA, uint liquidity);
    function removeLiquidity(
        address tokenA,
        address tokenB,
        uint liquidity,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline
    ) external returns (uint amountA, uint amountB);
    function removeLiquidityAREA(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountAREAMin,
        address to,
        uint deadline
    ) external returns (uint amountToken, uint amountAREA);
    function removeLiquidityWithPermit(
        address tokenA,
        address tokenB,
        uint liquidity,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline,
        bool approveMax, uint8 v, bytes32 r, bytes32 s
    ) external returns (uint amountA, uint amountB);
    function removeLiquidityAREAWithPermit(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountAREAMin,
        address to,
        uint deadline,
        bool approveMax, uint8 v, bytes32 r, bytes32 s
    ) external returns (uint amountToken, uint amountAREA);
    function swapExactTokensForTokens(
        uint amountIn,
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external returns (uint[] memory amounts);
    function swapTokensForExactTokens(
        uint amountOut,
        uint amountInMax,
        address[] calldata path,
        address to,
        uint deadline
    ) external returns (uint[] memory amounts);
    function swapExactAREAForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)
        external
        payable
        returns (uint[] memory amounts);
    function swapTokensForExactAREA(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)
        external
        returns (uint[] memory amounts);
    function swapExactTokensForAREA(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)
        external
        returns (uint[] memory amounts);
    function swapAREAForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)
        external
        payable
        returns (uint[] memory amounts);
 
    function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB);
    function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut);
    function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn);
    function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts);
    function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts);
}
 
interface IHyperswapV2Router02 is IHyperswapV2Router01 {
    function removeLiquidityAREASupportingFeeOnTransferTokens(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountAREAMin,
        address to,
        uint deadline
    ) external returns (uint amountAREA);
    function removeLiquidityAREAWithPermitSupportingFeeOnTransferTokens(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountAREAMin,
        address to,
        uint deadline,
        bool approveMax, uint8 v, bytes32 r, bytes32 s
    ) external returns (uint amountAREA);
 
    function swapExactTokensForTokensSupportingFeeOnTransferTokens(
        uint amountIn,
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external;
    function swapExactAREAForTokensSupportingFeeOnTransferTokens(
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external payable;
    function swapExactTokensForAREASupportingFeeOnTransferTokens(
        uint amountIn,
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external;
}