Rebalance WUSD
In the event that the pooled stablecoin supply collateralizing WUSD deviates from the WUSD supply, it is possible to rebalance the WUSD supply to restore equilibrium.
collateral supply > WUSD supply -> credit rebalancing situation
collateral supply < WUSD supply -> possible debit rebalancing situation
The differences
function of the WUSDExtensionController contract is responsible for checking and quantifying the difference between the collateral supply and WUSD supply:
It retrieves the WUSD supply by calling the totalSupply
function on the native WUSD collection. Then, for every pool of every AMM supported by the WUSD protocol, it retrieves the amount of stablecoins pooled as collateral:
Then we may be faced with either of the two possible rebalancing situations described above:
Rebalance by Credit
To perform a credit rebalancing, it is necessary to use the rebalanceByCredit
public function of the WUSDExtensionController contract.
If the rebalance can be performed, the WUSD extension's mintForRebalanceByCredit
function is called to mint the required amount of WUSD:
The mintForRebalanceByCredit
function automatically mints the amount of WUSD equal to the difference between the collateral supply and the WUSD supply, and sends it to the WUSDExtensionController contract.
Then, the newly minted WUSD is distributed as follows:
2% to the executor of the rebalancing (as a reward)
8% to the Covenants treasury, owned and ruled exclusively by $UniFi holders
60% to the FARM treasury, dedicated to rewarding $WUSD farming.
20% to the $2XUSD treasury, reserved for Debit Rebalancing
10% to the $5XUSD treasury, also reserved for Debit Rebalancing
Rebalance by Debit
For debit rebalancing, the difference between the WUSD supply and the collateral supply must be equal to or greater than the minimumRebalanceByDebtAmount
amount set up in the contract.
To perform a debit rebalance, use the safeTransferFrom
or safeBatchTransferFrom
method directly from the WUSD token collection itself, as follows:
from
-> addresssender
to
-> WUSDExtensionControlleraddress
objectId/s
-> WUSD object Idamount/s
-> WUSD amount to rebalance, or an array containing the amounts in the case ofsafeBatchTransferFrom
data
Regarding the data
input:
The payload
must contain a value equal to "1" to rebalance the WUSD token amount. If the value passed is other than 1, a burn is called. In addition, the payload
must contain the value "2" or "5" depending on the credit note (x2 or x5) to be obtained from the rebalance.
The onERC1155Received/onERC1155BatchReceived
function rebalances the WUSD amount that arrives in theWUSDExtensionController contract by calling internally the _onSingleReceived
function. It takes the payload sent via safeTransferFrom/safeBatchTransferFrom
and distinguishes between two cases: if the payload
value is equal to 1, it will perform a rebalance; if different from 1, it will perform a burn:
The _rebalanceByDebt
function calculates the amount to rebalance using the differences function and checks that this amount is at least equal to the minimumRebalanceByDebtAmount
:
Then the payload
is decoded to retrieve the information about the desired credit note (x2/x5)
Subsequently, the safeApprove
function is called to allow the extension to use the amount of WUSD to be rebalanced, and to allow the extension _burnFor
function, passing the objectId
of either the x2 or the x5 credit note as requested:
So, the _burnFor
method of the extension contract takes the WUSD amount from the WUSDExtensionController via _safeTransferFrom
and burns that amount by calling burn
Finally, the proportionate amount of requested credit notes (x2 or x5) are minted and sent to the user who called the rebalance by debit operation.
Please refer to the WUSD Frontend Integration section for more details.
Last updated