singleLiquidityWrapper.sol
Last updated
Last updated
Primary Uses - Unique to uTrade, the Single Liquidity Wrapper allows BTT or any BRC-20 token on BTT to converted into a LP pool. For example, USDT can be added using the wrapper to supply liquidity for a USDT.t / WBTT 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.
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.
The convertSingleAssetToLiquidityETH
function converts BTT into a LP token. It does so by first converting the provided BTT 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 BTT value is sent as a msg.value parameter. One of the two assets can be WBTT.
The convertSingleAssetToOtherLiquidity
function converts any BRC-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.
The convertSingleAssetToOtherLiquidityETH
function converts BTT to an uTrade V2 LP token made up of two different tokens. In other words, BTT will be converted to the two tokens that make up a liquidity pair, and then the two tokens are added to the liquidity pool.
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.
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 BTT or any BRC-20 token available.
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)
Network
Address
BitTorrent Chain
0xb986284c89cc9ca5427582222f5e1af4ea0ef99c
(Link)
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.
Parameter
Type
Description
amountIn (msg.value)
uint
The amount of BTT 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.
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.
Parameter
Type
Description
amountIn (msg.value)
uint
The amount of BTT 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 AVAX 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 WBTT'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 AVAX must be converted to WBTT, 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 BTT 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 WBTT'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 BTT must be converted to WBTT, 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.
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 BTT. If true, the receiveToken address should be WBTT, as it will unwrap WBTT and send BTT.
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.
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 BTT. If true, the receiveToken address should be WBTT, as it will unwrap WBTT and send BTT.
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.