Burn WUSD
Burn WUSD
The action of burning WUSD allows you to get back the corresponding amount of collateralized stablecoins (or, if preferred, the corresponding amount of LP tokens).
To burn WUSD tokens, use the safeTransferFrom
or safeBatchTransferFrom
method directly from the WUSD token collection itself to the WUSDExtensionController, with the following inputs:
from
-> senderaddress
to
-> WUSDExtensionControlleraddress
objectId/s
-> WUSD object Idamount/s
-> WUSD amount to burn, or an array containing the amounts in case ofsafeBatchTransferFrom
data
Regarding the data
input:
The payload
must contain a value other than "1" to burn the WUSD token amount. If the value passed is 1, a Rebalance is called.
In addition, the payload
must contain a series of parameters useful for recovering tokens from the burn action. In particular, the payload
must contain:
ammPosition
-> position of the AMM you want to use (see here for more information)liquidityPoolPosition
-> position of the LP you want to use (see here for more information)liquidityPoolAmount
-> amount of tokens corresponding to the WUSD amount to be burned for that chosen pool. IfbyLiquidityPool
istrue
, this parameter represents an amount of LP tokens; iffalse
, this parameter represents an amount of pair tokenskeepLiquidityPool
-> a boolean value representing whether to get back LP tokens (true
) or the corresponding amount of pair tokens inside the LP token (false
)
The onERC1155Received/onERC1155BatchReceived
function takes care of burning the WUSD amount that arrives in the WUSDExtensionController contract. It calls the _onSingleReceived
function, and then, taking the payload
sent via safeTransferFrom/safeBatchTransferFrom
, distinguishes between two cases: If the payload is equal to 1, it will perform a rebalance; if different from 1, it will perform a burn:
At this point, to burn the desired amount of WUSD, the _burn
function is called. The function performs a decode of the payload to obtain the information needed to perform the burn.
A _safeApprove
is called on the extension and then the burn method of the extension itself, which burns the WUSD and returns the amount of LP tokens:
The payload must contain keepLiquidityPool
== true
in case the burner wants to receive the pair tokens inside the LP token back. In this case the _removeLiquidity
function is called via the AMM aggregator to remove the liquidity from the AMM, and returns the corresponding amount to the user:
Please refer to the WUSD Frontend Integration section for more details.
Last updated