singleLiquidityWrapper.sol

Primary Uses - Unique to uTrade, the Single Liquidity Wrapper allows ONE or any HRC-20 token to converted into a LP pool. For example, USDT can be added using the wrapper to supply liquidity for a BUSD / WONE pair. The wrapper allows LP tokens to exit in a similar fashion. The functionality from this wrapper simplifies applications such as compounding or fee-on-transfer additions to liquidity pools.

uTrade V2 Single Liquidity Wrapper Code / Interfaces

uTrade V2 Single Liquidity Wrapper (Solidity)

Link Here

uTrade V2 Single Liquidity Wrapper Interface as JSON

uTrade V2 Single Liquidity Wrapper as Typescript

Import statement codeblock (when available)

uTrade V2 Single Liquidity Wrapper Contract Addresses

Network

Address

Harmony Main Net

0x: 0xa529de1949ddb797de0d7f2b3fcf8b17a94af51d One:one1555aux2fmkme0hsd0u4nlnutz7554agasnuyuf (Link)

convertSingleAssetToLiquidity

function convertSingleAssetToLiquidity(address tokenA, address requireToken, uint amount, address to, uint minOut) external ;

The convertSingleAssetToLiquidityfunction converts one of the assets that a liquidity pool contains into a LP token. It does so by first converting the exact amount of one token required for an equal amount of the other asset that makes up the pool. Next, the two equal values of tokens are added to the liquidity pool. And lastly, the LP tokens are sent to the address provided.

Parameter

Type

Description

tokenA

address

The contract address of the provided token to be converted into the LP token.

requireToken

address

The contract address of the other token in the liquidity pool. In other words, the asset that half of tokenA will be converted to that will be added to the liquidity pool.

amount

uint

The amount of tokenA to be sent to the liquidity pool.

to

address

The recipient of the LP tokens.

minOut

uint

The minimum amount of the received LP tokens that is acceptable. If the amount to be received is below this number, this transaction will revert.

convertSingleAssetToLiquidityEth

function convertSingleAssetToLiquidityEth(address requireToken, address to, uint minOut) payable external ;

The convertSingleAssetToLiquidityETHfunction converts ONE into a LP token. It does so by first converting the provided ONE into equal amounts of the two tokens that make up the liquidity pool. Next, the two equal values of tokens are added to the liquidity pool. And lastly, the LP tokens are sent to the address provided. The ONE value is sent as a msg.value parameter. One of the two assets can be WONE.

Parameter Breakdown

Parameter

Type

Description

amountIn (msg.value)

uint

The amount of ONE to be converted to the two tokens that make up a liquidity pool. Sent as the message value.

requireToken

address

The address of the LP token token contract that is being supplied.

to

address

The recipient of the LP tokens.

minOut

uint

The minimum amount of the received LP tokens that is acceptable. If the amount to be received is below this number, this transaction will revert.

convertSingleAssetToOtherLiquidity

function convertSingleAssetToOtherLiquidity(address depositToken, address requireTokenA, address requireTokenB, uint amount, address to, address[] calldata path1, address[] calldata path2, uint minOut) external ;

The convertSingleAssetToOtherLiquidityfunction converts any HRC-20 token available on uTrade V2 to a uTrade V2 LP token made up of two different tokens. In other words, a token that is not included in a liquidity pair will be converted to the two tokens that do make up the liquidity pair, and added to the liquidity pool.

Parameter

Type

Description

depositToken

address

The contract address of the provided token to be converted into the LP token.

requireTokenA

address

The contract address of tokenA in the desired liquidity pair.

requireTokenB

address

The contract address of tokenB in the desired liquidity pair.

amount

uint

The amount of the depositToken to be converted to the two liquidity pool tokens.

to

address

The recipient of the LP tokens.

path1

address

The pathway to change depositToken into requireTokenA, consisting of an array of token addresses. Each token must have an existing liquidity pool, as well as have liquidity.

In other words, the path represents the pathway from the token you are providing to the first token that makes up the liquidity pool you are adding to. If there is no direct pair, multiple addresses will be required. The last token contract address in path1 will be the first token in the liquidity pair.

path2

address

The pathway to change the depositToken into requireTokenB, consisting of an array of token addresses. Each token must have an existing liquidity pool, as well as have liquidity.

In other words, the path represents the pathway from the token you are providing to the first token that makes up the liquidity pool you are adding to. If there is no direct pair, multiple addresses will be required. The last token contract address in path2 will be the second token in the liquidity pair.

minOut

uint

The minimum amount of the received LP tokens that is acceptable. If the amount to be received is below this number, this transaction will revert.

convertSingleAssetToOtherLiquidityETH

function convertSingleAssetToOtherLiquidityETH(address requireTokenA, address requireTokenB, address to, address[] calldata path1, address[] calldata path2, uint minOut) payable external ;

The convertSingleAssetToOtherLiquidityETHfunction converts ONE to an uTrade V2 LP token made up of two different tokens. In other words, ONE will be converted to the two tokens that make up a liquidity pair, and then the two tokens are added to the liquidity pool.

Parameter

Type

Description

amountIn (msg.value)

uint

The amount of ONE to be converted to the two tokens that make up a liquidity pool. Sent as the message value.

requireTokenA

address

The contract address of tokenA in the desired liquidity pair.

requireTokenB

address

The contract address of tokenB in the desired liquidity pair.

to

address

The recipient of the LP tokens.

path1

address

The pathway to change ONE into requireTokenA, consisting of an array of token addresses. Each token must have an existing liquidity pool, as well as have liquidity. The first address must be WONE's contract address.

In other words, the path represents the pathway from the token you are providing to the first token that makes up the liquidity pool you are adding to. As ONE must be converted to WONE multiple addresses will be required. The last token contract address in path1 will be the first token in the liquidity pair.

path2

address

The pathway to change ONE into requireTokenB, consisting of an array of token addresses. Each token must have an existing liquidity pool, as well as have liquidity. The first address in the array must be WONE's contract address.

In other words, the path represents the pathway from the token you are providing to the first token that makes up the liquidity pool you are adding to. As ONE must be converted to WONE, multiple addresses will be required. The last token contract address in path2 will be the second token in the liquidity pair.

minOut

uint

The minimum amount of the received LP tokens that is acceptable. If the amount to be received is below this number, this transaction will revert.

withdrawSupplyAsSingleAsset

function withdrawSupplyAsSingleAsset( address receiveToken, address liquidityToken, address tokenA, address tokenB, address payable to, uint amount, bool toReceiveWNative, uint minOut) external ;

The withdrawSupplyAsSingleAsset function withdraws a user's liquidity from a pool, and converts it to one of the two tokens that makes up the liquidity pool. In other words, it redeems an LP token for one of the two assets that make up an LP token.

Parameter Breakdown

Parameter

Type

Description

receiveToken

address

The address of the token contract of the preferred token to be withdrawn. This determines which of the two tokens the LP will be converted to.

liquidityToken

address

The address of the token contract for the LP token to be converted.

tokenA

address

The address of the token contract for the first token in the liquidity pool.

tokenB

address

The address of the token contract for the second token in the liquidity pool.

to

address

The address to where the single asset will be sent.

amount

uint

The amount of LP tokens to be removed.

toReceiveWNative

bool

A true/false value if one of the assets to be received is native ONE. If true, the receiveToken address should be WONE, as it will unwrap WONE and send ONE.

minOut

uint

The minimum amount of the received asset that is acceptable. If the amount to be received is below this number, this transaction will revert.

withdrawSupplyAsOtherSingleAsset

function withdrawSupplyAsOtherSingleAsset(address receiveToken, address liquidityToken, address tokenA, address tokenB, address payable to, uint amount, address[] calldata path1, address[] calldata path2, bool toReceiveWNative, uint minOut) external ;

The withdrawSupplyAsOtherSingleAssetfunction withdraws a user's liquidity from a pool, and converts it to any other asset that is available on uTrade V2. In other words, it redeems an LP token for ONE or any HRC-20 token available.

Parameter Breakdown

Parameter

Type

Description

receiveToken

address

The address of the token contract of the preferred token to be withdrawn. This determines which of the two tokens the LP will be converted to.

liquidityToken

address

The address of the token contract for the LP token to be converted.

tokenA

address

The address of the token contract for the first token in the liquidity pool.

tokenB

address

The address of the token contract for the second token in the liquidity pool.

to

address

The address to where the single asset will be sent.

amount

uint

The amount of LP tokens to be removed.

path1

address

The pathway to change tokenA into the desired asset, consisting of an array of token addresses. Each token must have an existing liquidity pool, as well as have liquidity.

In other words, the path represents the pathway from tokenA to the withdraw token. If there is no direct pair, multiple addresses will be required. The last token contract address in path1 must be the same as the last token contract address in path2.

path2

address

The pathway to change tokenB into the desired asset, consisting of an array of addresses. Each token must have an existing liquidity pool, as well as have liquidity.

In other words, the path represents the pathway from tokenB to the withdraw token. If there is no direct pair, multiple addresses will be required. The last token contract address in path2 must be the same as the last token contract address in path1.

toReceiveWNative

bool

A true/false value if one of the assets to be received is native ONE. If true, the receiveToken address should be WONE, as it will unwrap WONE and send ONE.

minOut

uint

The minimum amount of the received asset that is acceptable. If the amount to be received is below this number, this transaction will revert.

Interface Code

interface IUnifiSingleLiquidity {
    function convertSingleAssetToLiquidity(address tokenA, address requireToken, uint amount, address to, uint minOut) external ;
    function convertSingleAssetToLiquidityEth(address requireToken, address to, uint minOut) payable external ;
    function convertSingleAssetToOtherLiquidity(address depositToken, address requireTokenA, address requireTokenB, uint amount, address to, address[] calldata path1, address[] calldata path2, uint minOut) external ;
    function convertSingleAssetToOtherLiquidityETH(address requireTokenA, address requireTokenB, address to, address[] calldata path1, address[] calldata path2, uint minOut) payable external ;
    function withdrawSupplyAsSingleAsset(address receiveToken, address liquidityToken, address tokenA, address tokenB, address payable to, uint amount, bool toReceiveWNative, uint minOut) external ;
    function withdrawSupplyAsOtherSingleAsset(address receiveToken, address liquidityToken, address tokenA, address tokenB, address payable to, uint amount, address[] calldata path1, address[] calldata path2, bool toReceiveWNative, uint minOut) external ;
}

Last updated