Submitted by said, also found by ether_sky, zhaojohnson, Honour, samuraii77, inzinko, trachev, alix40, hyh, and KupiaSec
When executeBuyCreditMarket is called and returns the cash amount, it will return the cash amount without deducting the fee. This results in overestimating the value that needs to be validated by validateVariablePoolHasEnoughLiquidity.
When executeBuyCreditMarket is called, it will transfer cashAmountIn - fees to the borrower. This means the amount that needs to be available for withdrawal in the variable pool is cashAmountIn - fees.
https://github.com/code-423n4/2024-06-size/blob/main/src/libraries/actions/BuyCreditMarket.sol#L195
However, executeBuyCreditMarket will return cashAmountIn, and provide it to validateVariablePoolHasEnoughLiquidity and check if the variable pool have cashAmountIn amount of token.
https://github.com/code-423n4/2024-06-size/blob/main/src/Size.sol#L178-L185
https://github.com/code-423n4/2024-06-size/blob/main/src/libraries/CapsLibrary.sol#L67-L72
This will overestimate the amount of liquidity that needs to be available in the variable pool and could cause the call to unnecessarily revert.
Update the returned cashAmountIn to cashAmountIn - fees at the end of executeBuyCreditMarket.
Invalid Validation
aviggiano (Size) confirmed and commented:
hansfriese (judge) commented:
Note: For full discussion, see here.
