Withdrawals
Explore the withdraw function
By calling withdrawTo, the user burns IbAlluo in return for tokens of their choice. This happens in the opposite way as depositing:
Burn the correct amount of IbAlluos
If the token the user wants to receive is in the list of supported tokens, withdraw this from the handler to the user
If the token the user wants to receive is NOT in the list of supported tokens, the handler converts the amount in asset value to the target token and sends it to the user.
Using IbAlluoUSD as an example, if you called withdrawTo("Bob's Address", "USDC address", "$100"):
Burn $100 worth of IbAlluos
As USDC is supported in IbAlluoUSD, send $100 USD to the user.
Using IbAlluoUSD as an example, if you called withdrawTo("Bob's Address", "EURS address", "$100"):
Burn $100 worth of IbAlluos
As EURS is not supported in IbAlluoUSD, the handler converts $100 into EURS tokens and sends that amount to the user
/// @notice Withdraws accuratel
/// @dev When called, immediately check for new interest index. Then find the adjusted amount in IbAlluo tokens
/// Then burn appropriate amount of IbAlluo tokens to receive asset token
/// @param _targetToken Asset token
/// @param _amount Amount (parsed 10**18) in asset value
function withdrawTo(
address _recipient,
address _targetToken,
uint256 _amount
) public {
updateRatio();
uint256 adjustedAmount = (_amount * multiplier) / growingRatio;
_burn(_msgSender(), adjustedAmount);
ILiquidityHandler handler = ILiquidityHandler(liquidityHandler);
if (supportedTokens.contains(_targetToken) == false) {
(address liquidToken,) = ILiquidityHandler(liquidityHandler).getAdapterCoreTokensFromIbAlluo(address(this));
// This just is used to revert if there is no active route.
require(IExchange(exchangeAddress).buildRoute(liquidToken, _targetToken).length > 0, "!Supported");
handler.withdraw(
_recipient,
liquidToken,
_amount,
_targetToken
);
} else {
handler.withdraw(
_recipient,
_targetToken,
_amount
);
}
emit TransferAssetValue(_msgSender(), address(0), adjustedAmount, _amount, growingRatio);
emit BurnedForWithdraw(_msgSender(), adjustedAmount);
}
For more information about how the liquidity handler works, explore the LiquidityHandler and adapters page
Last updated