Redeem x2/x5 WUSD Notes

Redeeming (burning) a note allows you to mint the amount of WUSD denoted by the note's ticker.

To redeem WUSD note tokens (x2/x5), use the safeTransferFrom or safeBatchTransferFrom method directly from the WUSD Token Collection itself to the WUSDNoteController x2 and WUSDNoteController x5 contracts, as follows:

  • from -> sender address

  • to -> WUSDNoteController x2 address or x5 address

  • objectId/s -> WUSD note x2 object Id or x5 object Id

  • amount/s -> WUSD note amount to redeem, or an array containing the amounts in case of safeBatchTransferFrom

  • data -> 0, no payload is needed

The onERC1155Received/onERC1155BatchReceived function takes care of burning the WUSD note amount that arrives to the WUSDNoteController contract, calling the native collection's burn method:

collection.burn(id, value);

burnBatch in case of safeBatchTransferFrom and so onERC1155BatchReceived

collection.burnBatch(ids, values);

and then transfers the amount of WUSD minted via the redeeming of the WUSD notes to the receiver. The amount to send is calculated as value * multiplier , where value is the amount of WUSD notes sent through the safeTransferFrom or safeBatchTransferFrom to the WUSDNoteController, and multiplier is equal to "2" in the case of WUSD note x2, or "5" in the case of WUSD note x5.

collection.safeTransferFrom(address(this), from, wusdObjectId, value * multiplier, data); 
collection.safeBatchTransferFrom(address(this), from, usdIds, usdValues, data);

Last updated