Alluo Explained
Search
⌃K

Automatic boosting with Alluo

How exactly does this looping process work?

Alluo stakes underlying LP deposits into the Vault and carries out all the looping of rewards:

Using the rewards from the underlying LP deposit in the Alluo Vault, on a regular interval, Alluo swaps these rewards to CVX then adds liquidity to the Curve Pool for CVX-ETH LP, then finally stakes these CVX-ETH LPs to boost your yield.
Alluo's gelato resolver calls these two functions regularly:

1. StakeUnderlying()

This function is called so that any accumulated LP deposits are staked often into Convex so that we do not have any idle capital.
This is lowers the gas costs / upfront costs to investment for users as they do not need to pay extra gas fees and it is economically optimal for the community as whether you stake 10 tokens or 100000 tokens costs almost the same gas.

2. farm() in the Alluo Boosting Pool

This function claims all rewards accumulated in the boosted rewards pool, all the rewards in each vault connected to it and then appropriately distributes CVX-ETH lp tokens amongst the vaults
This comes as the vault having 'shares' in the boosted pool so that users are distributed rewards correctly. As multiple vault rewards are simultaneously converted to CVX-ETH LP tokens and then staked into convex in one transaction, this creates massive gas savings so users can enjoy economies of scale.
AlluoVaultPool.sol
1
/// @notice Claims all rewards, exchange all rewards for LPs and stake them
2
/// @dev Exchanges all rewards (including those sent by the vault) for the entryToken, adds liquidity for LP tokens and then stakes them
3
/// This function is not to be called directly, but rather through the vault contract it is linked to.
4
function farm() onlyRole(DEFAULT_ADMIN_ROLE) external {
5
// 1. Claim all rewards accumulated by booster pool and convert to the entryToken
6
claimRewardsFromPool();
7
for (uint256 i; i < yieldTokens.length(); i++) {
8
address token = yieldTokens.at(i);
9
uint256 balance = IERC20MetadataUpgradeable(token).balanceOf(address(this));
10
if (token != address(entryToken) && balance > 0) {
11
IERC20MetadataUpgradeable(token).safeIncreaseAllowance(address(exchange), balance);
12
exchange.exchange(token, address(entryToken), balance, 0);
13
}
14
}
15
uint256 totalPoolEntryTokenYield = entryToken.balanceOf(address(this));
16
​
17
// 2. Get all the rewards from the different vaults and keep track of how much entryToken it is worth for each vault
18
uint256 totalVaultEntryTokenDeposits;
19
uint256[] memory entryTokenDeposits = new uint256[](vaults.length());
20
for (uint256 i; i < vaults.length(); i++) {
21
address _vault = vaults.at(i);
22
uint256 vaultEntryTokenBalance = IAlluoVault(_vault).claimAndConvertToPoolEntryToken(address(entryToken));
23
totalVaultEntryTokenDeposits += vaultEntryTokenBalance;
24
entryTokenDeposits[i] = vaultEntryTokenBalance;
25
}
26
// 3. Convert all entryToken balance (rewards by booster + rewards from vault) into reward tokens and then stake into convex
27
uint256 entryTokenBalance = entryToken.balanceOf(address(this));
28
uint256 newRewardTokens;
29
if (entryTokenBalance > 0) {
30
entryToken.safeIncreaseAllowance(address(exchange), entryTokenBalance);
31
newRewardTokens = exchange.exchange(address(entryToken), address(rewardToken), entryTokenBalance, 0);
32
rewardToken.safeIncreaseAllowance(address(cvxBooster), newRewardTokens);
33
}
34
​
35
// 4. Now give shares of the pool to the vaults which deposited entryToken by calculating how much of they own of the rewardToken LP amount that was created
36
// 5. Update all vault holder reward balances
37
​
38
uint256 totalVaultNewRewardTokens = newRewardTokens * totalVaultEntryTokenDeposits / entryTokenBalance;
39
uint256 totalPoolShareholdersNewRewardTokens = newRewardTokens * totalPoolEntryTokenYield / entryTokenBalance;
40
​
41
uint256 totalSharesBefore = totalBalances;
42
for (uint256 j; j < vaults.length(); j++) {
43
address _vault = vaults.at(j);
44
uint256 shareOfRewardTokens = totalVaultNewRewardTokens * entryTokenDeposits[j] / totalVaultEntryTokenDeposits;
45
uint256 additionalSharesOfVault = _convertToSharesAfterPoolRewards(shareOfRewardTokens, totalPoolShareholdersNewRewardTokens, totalSharesBefore);
46
balances[_vault] += additionalSharesOfVault;
47
totalBalances += additionalSharesOfVault;
48
// 5. Update all vault holder reward balances
49
}
50
cvxBooster.deposit(poolId, newRewardTokens, true);
51
for (uint256 j; j < vaults.length(); j++) {
52
address _vault = vaults.at(j);
53
IAlluoVault(_vault).loopRewards();
54
}
55
}
The farm function simply calls these two functions below where rewards are converted to a central entryToken (usually CVX), then correctly notes down vault rewards (which are calculated by the shares the vault has in the boosted pool) before and after so that they can be distributed between vault shareholders.
AlluoVaultUpgradeable.sol
1
/// @notice Loop called periodically to compound reward tokens into the respective alluo pool
2
/// @dev Claims rewards, transfers all rewards to the alluoPool. Then, the pool is farmed and rewards are credited accordingly per share.
3
function loopRewards() external onlyRole(DEFAULT_ADMIN_ROLE) {
4
// The vaultRewardsBefore is set in the same call right before the rewardToken balance is increased to allow for this calculation to work.
5
uint256 vaultRewardAfter = IAlluoPool(alluoPool).rewardTokenBalance();
6
uint256 totalRewards = vaultRewardAfter - vaultRewardsBefore;
7
if (totalRewards > 0) {
8
uint256 totalFees = totalRewards * adminFee / 10**4;
9
uint256 newRewards = totalRewards - totalFees;
10
rewards[gnosis] += totalFees;
11
rewardsPerShareAccumulated += newRewards * 10**18 / totalSupply();
12
}
13
}
14
​
15
function claimAndConvertToPoolEntryToken(address entryToken) external onlyRole(DEFAULT_ADMIN_ROLE) returns (uint256) {
16
claimRewardsFromPool();
17
for (uint256 i; i < yieldTokens.length(); i++) {
18
address token = yieldTokens.at(i);
19
uint256 balance = IERC20MetadataUpgradeable(token).balanceOf(address(this));
20
if (token != address(entryToken) && balance > 0) {
21
IERC20MetadataUpgradeable(token).safeIncreaseAllowance(address(exchange), balance);
22
exchange.exchange(token, address(entryToken), balance, 0);
23
}
24
}
25
vaultRewardsBefore = IAlluoPool(alluoPool).rewardTokenBalance();
26
uint256 amount = IERC20MetadataUpgradeable(entryToken).balanceOf(address(this));
27
IERC20MetadataUpgradeable(entryToken).safeTransfer(alluoPool, amount);
28
return amount;
29
}
30
​
The farm function is permissioned to only work with Gelato to prevent potential flashloan attacks where a malicious actor flash mints shares in the vault, claims all the rewards and then repays the loan.