Submitted by kenzo, also found by cccz, Metatron, unforgiven, and WatchPug
The Tempus lend method calculates the amount of tokens to mint as amountReturnedFromTempus - lenderBalanceOfMetaPrincipalToken.
This seems wrong as theres no connection between the two items. Tempus has no relation to the iPT token.
Wrong amount of iPT will be minted to the user.
If the Lender contract has iPT balance, the function will revert, otherwise, user will get minted 0 iPT tokes.
This is how the lend method calculates the amount of iPT tokens to mint:
The Tempus depositAndFix method does not return anything.
Therefore this calculation will revert if illuminateToken.balanceOf(address(this)) > 0, or will return 0 if the balance is 0.
[Note: theres another issue here where the depositAndFix sends wrong parameters - I will submit it in another issue.]
I believe that what you intended to do is to check how many Tempus principal tokens the contract received.
So you need to check Lenders x.tempusPool().principalShare() before and after the swap, and the delta is the amount received.
sourabhmarathe (Illuminate) confirmed
