DutchAuctionLiquidator.sol#triggerLiquidation()
Adding precondition check can save gas
#104
Labels
bug
Something isn't working
G (Gas Optimization)
sponsor confirmed
Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
Handle
WatchPug
Vulnerability details
When liquidators race to liquidate a position, all other besides the first liquidator will be handling an empty (liquidated) position.
https://github.com/code-423n4/2021-10-mochi/blob/8458209a52565875d8b2cefcb611c477cefb9253/projects/mochi-core/contracts/liquidator/DutchAuctionLiquidator.sol#L69-L81
In the current implementation, even if the position is liquidated, at L77 and L79, it still tries to get the details and call
vault.liquidate()
, until it reverts at L285-L288 onMochiVault.sol#liquidate()
. That's going to cost a decent amount of gas due to these unnecessary external calls and code executions.https://github.com/code-423n4/2021-10-mochi/blob/8458209a52565875d8b2cefcb611c477cefb9253/projects/mochi-core/contracts/vault/MochiVault.sol#L277-L288
Therefore, adding a precondition check can save gas.
Recommendation
Change to:
The text was updated successfully, but these errors were encountered: