Submitted by cmichel, also found by WatchPug and leastwood
When depositing into Aave through the AaveYield.lockTokens contract strategy, one receives the sharesReceived amount corresponding to the diff of aToken balance, which is just always the deposited amount as aave is a rebasing token and 1.0 aToken = 1.0 underlying at each deposit / withdrawal.
Note that this sharesReceived (the underlying deposit amount) is cached in a balanceInShares map in SavingsAccount.deposit which makes this share static and not dynamically rebasing anymore:
However, the getTokensForShares function uses a rebasing total share supply of IERC20(aToken).balanceOf(this).
Interest is not paid out to users.
Pool collateral is measured without the interest accrued as it uses getTokensForShares which will lead to early liquidations and further loss.
If the user shares are not rebasing, you cannot have the total shares supply (the shares in the contract) be rebasing as in getTokensForShares. Also withdrawing the share amount directly from Aave as in _withdrawERC does not withdraw the yield.
A fix could be to create a non-rebasing wrapper LP token that is paid out to the user proportional to the current strategy TVL at time of user deposit.
ritik99 (Sublime) acknowledged:
0xean (judge) commented:
