singleLiquidityWrapper.sol
Primary Uses - Unique to uTrade, the Single Liquidity Wrapper allows BNB or any BEP-20 token to converted into a LP pool. For example, USDT can be added using the wrapper to supply liquidity for a BUSD / WBNB 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
Type | Link |
uTrade V2 Single Liquidity Wrapper (Solidity) | |
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 |
BSC Main Net |
|
BSC Test Net |
|
convertSingleAssetToLiquidity
The convertSingleAssetToLiquidity
function 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
The convertSingleAssetToLiquidityETH
function converts BNB into a LP token. It does so by first converting the provided BNB 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 BNB value is sent as a msg.value parameter. One of the two assets can be WBNB.
Parameter Breakdown
Parameter | Type | Description |
amountIn (msg.value) | uint | The amount of BNB 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
The convertSingleAssetToOtherLiquidity
function converts any BEP-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
The convertSingleAssetToOtherLiquidityETH
function converts BNB to an uTrade V2 LP token made up of two different tokens. In other words, BNB 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 BNB 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 BNB 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 WBNB'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 BNB must be converted to WBNB, 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 BNB 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 WBNB'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 BNB must be converted to WBNB, 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
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 BNB. If true, the receiveToken address should be WBNB, as it will unwrap WBNB and send BNB. |
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
The withdrawSupplyAsOtherSingleAsset
function 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 BNB or any BEP-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 BNB. If true, the receiveToken address should be WBNB, as it will unwrap WBNB and send BNB. |
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
Last updated