Deposit process with the Liquidity Handler
Example: A walkthrough of a USDC deposit into IbAlluoUSD
Step 1: User calls deposit with 100 USDC and the funds are sent to the voteExecutor and IbAlluo calls the deposit function.
function deposit(address _token, uint256 _amount) external {
if (supportedTokens.contains(_token) == false) {
IERC20Upgradeable(_token).safeTransferFrom(_msgSender(), address(this), _amount);
(, address primaryToken) = ILiquidityHandler(liquidityHandler).getAdapterCoreTokensFromIbAlluo(address(this));
IERC20Upgradeable(_token).safeIncreaseAllowance(exchangeAddress, _amount);
_amount = IExchange(exchangeAddress).exchange(_token, primaryToken, _amount, 0);
_token = primaryToken;
//Funds are sent to the liquidity Handler
IERC20Upgradeable(primaryToken).safeTransfer(address(liquidityHandler), _amount);
} else {
//Funds are sent to the liquidity Handler
IERC20Upgradeable(_token).safeTransferFrom(_msgSender(),address(liquidityHandler),_amount);
}
updateRatio();
ILiquidityHandler(liquidityHandler).deposit(_token, _amount);
uint256 amountIn18 = _amount * 10**(18 - AlluoERC20Upgradable(_token).decimals());
uint256 adjustedAmount = (amountIn18 * multiplier) / growingRatio;
_mint(_msgSender(), adjustedAmount);
emit TransferAssetValue(address(0), _msgSender(), adjustedAmount, amountIn18, growingRatio);
emit Deposited(_msgSender(), _token, _amount);
}Step 2: Now the 100 USDC are in the liquidityHandler and the deposit function is called, either two of the following occur
If the expectedAdapterAmount (minimum buffer requirement) is not met, the 100 USDC is deposited into the adapter until the buffer is met and any surplus is sent to the treasury.
If the buffer requirement is already met, the funds are sent directly to the treasury.
Here is the logic that occurs in the actual adapter. The funds are either kept in the contract as a buffer for withdrawals, or they are sent to the treasury.
Step 3: If this new deposit allows preexisting withdrawal requests to be met, turn on a flag that allows our gelato resolver to execute the pending withdrawal
Last updated