The simplest case where one LP deposit and then want to redeem will fail.
2. The protocol should never lose liquidity provider deposits, it should always go up
function testDepositMintsAssetAndWithdraw() public setAllowedToken {
tokenA.mint(liquidityProvider, AMOUNT);
tokenA.mint(liquidityProvider2, AMOUNT);
vm.startPrank(liquidityProvider);
tokenA.approve(address(thunderLoan), AMOUNT);
thunderLoan.deposit(tokenA, AMOUNT);
vm.stopPrank();
vm.startPrank(liquidityProvider2);
tokenA.approve(address(thunderLoan), AMOUNT);
thunderLoan.deposit(tokenA, AMOUNT);
vm.stopPrank();
vm.startPrank(liquidityProvider);
thunderLoan.redeem(tokenA, type(uint256).max);
vm.stopPrank();
assertGe(tokenA.balanceOf(address(liquidityProvider)), AMOUNT);
AssetToken asset = thunderLoan.getAssetFromToken(tokenA);
assertGe(tokenA.balanceOf(address(asset)), AMOUNT);
}
[FAIL. Reason: Assertion failed.] testDepositMintsAssetAndWithdraw() (gas: 1239547)
Logs:
Error: a >= b not satisfied [uint]
Value a: 9954932466300549180
Value b: 10000000000000000000
huge because LP are loosing underlying token.