Comment on page
Depositing
Exploring how the deposit function works
Using IbAlluoUSD as an example, users can call the deposit function using one of the stablecoins in the list of supported tokens.
IbAlluo.sol
1
function getListSupportedTokens() public view returns (address[] memory) {
2
return supportedTokens.values();
3
}
4
5
6
function deposit(address _token, uint256 _amount) external {
7
if (supportedTokens.contains(_token) == false) {
8
///Case 2, read below
9
IERC20Upgradeable(_token).safeTransferFrom(_msgSender(), address(this), _amount);
10
(, address primaryToken) = ILiquidityHandler(liquidityHandler).getAdapterCoreTokensFromIbAlluo(address(this));
11
IERC20Upgradeable(_token).safeIncreaseAllowance(exchangeAddress, _amount);
12
_amount = IExchange(exchangeAddress).exchange(_token, primaryToken, _amount, 0);
13
_token = primaryToken;
14
IERC20Upgradeable(primaryToken).safeTransfer(address(liquidityHandler), _amount);
15
} else {
16
/// Case 1, read below
17
IERC20Upgradeable(_token).safeTransferFrom(_msgSender(),address(liquidityHandler),_amount);
18
}
19
updateRatio();
20
ILiquidityHandler(liquidityHandler).deposit(_token, _amount);
21
uint256 amountIn18 = _amount * 10**(18 - AlluoERC20Upgradable(_token).decimals());
22
uint256 adjustedAmount = (amountIn18 * multiplier) / growingRatio;
23
_mint(_msgSender(), adjustedAmount);
24
emit TransferAssetValue(address(0), _msgSender(), adjustedAmount, amountIn18, growingRatio);
25
emit Deposited(_msgSender(), _token, _amount);
26
}
If you deposit a supported token, it is sent to our liquidity handler and then the correct amount of IbAlluos are minted to the caller.
If you deposit a non-supported token, it is exchanged for the
primaryToken
for the IbAlluo through the Alluo Exchange and then the rest of the deposit process is completed.Case 3: If you deposit a non-supported token and it is not supported by the Alluo Exchange:
If the deposit token is not supported and it is not added to the Alluo Exchange, the function call will revert.