The output amount validation is not correct in Vault.liquidate(), so the method might accept invalid output amount and refuse valid output amount.
In Vault.liquidate(), there is a validation about the output share amount should be less than or equal to the liquidatable yield.
uint256 _liquidableYield = _liquidatableBalanceOf(_tokenOut);
if (_amountOut > _liquidableYield)
revert LiquidationAmountOutGTYield(_amountOut, _liquidableYield);
The liquidatable yield amount is in underlying asset token. So the comparison between the share amount and the underlying asset amount is not appropriate.
We could get share tokens from asset tokens via exchange rate. The vault gets _liquidableYield and mints _amountOut, so the correct asset amount equivalent to _amountOut of the share token will be _amountOut * exchange rate. The correct validation should use the asset amount and the current implementation is not correct when the exchange rate is not 1.
Manual Review
We should use the underlying equivalent with the exchange rate for the validation.
Error
The text was updated successfully, but these errors were encountered:
All reactions