👨🔬
Tech deep dive: Interest Bearing {asset} token
An interest Bearing collateralised, streamable token earning yield via all Strategies involved in the Liquidity Direction Protocol of Alluo.
The Interest Bearing {asset} token is developed and used by Alluo to run deposit
farms
. Currently, there are 4 Interest Bearing tokens on Polygon and Ethereum: IbAlluoUSD, IbAlluoEUR, IbAlluoBTC and IbAlluoETH.
We have a value
growingRatio
that increases overtime at the interestPerSecond
rate that is set biweekly by the DAO through governance votes. This growingRatio is routinely called by a gelato resolver and updateRatio()
is also called before any movement of IbAlluo to ensure that users get the correct valuesIbAlluo.sol
1
/// @notice Updates the growingRatio
2
/// @dev If more than the updateTimeLimit has passed, call changeRatio from interestHelper to get correct index
3
/// Then update the index and set the lastInterestCompound date.
4
5
function updateRatio() public whenNotPaused {
6
if (block.timestamp >= lastInterestCompound + updateTimeLimit) {
7
growingRatio = changeRatio(
8
growingRatio,
9
interestPerSecond,
10
lastInterestCompound
11
);
12
lastInterestCompound = block.timestamp;
13
}
14
}
An example can be seen below, where if a user wants to transfer exactly $100 USD worth of IbAlluoUSD (keep in mind that 100 IbAlluoUSD is worth
100 * growingRatio > 1
), the function ensures that the ratio is up to date when transferring $100 worth.IbAlluo.sol
1
/**
2
* @dev See {IERC20-transfer} but it transfers amount of tokens
3
* which represents asset value
4
*/
5
function transferAssetValue(address to, uint256 amount)
6
public
7
whenNotPaused
8
returns (bool)
9
{
10
address owner = _msgSender();
11
updateRatio();
12
uint256 adjustedAmount = (amount * multiplier) / growingRatio;
13
_transfer(owner, to, adjustedAmount);
14
emit TransferAssetValue(owner, to, adjustedAmount, amount, growingRatio);
15
return true;
16
}
17
The next few subpages will touch upon some key functionalities in the IbAlluo contract, including:
Last modified 11mo ago