Liquidations where the user has multiple collaterals and/or positions in multiple markets will cost the liquidator more to execute. However, the compensation for liquidation is constant, meaning that liquidating an account with multiple collaterals and/or multiple positions can be more costly for the liquidator. This static liquidation fee can become insufficient and potentially put the liquidator at a loss, depending on network conditions and configurations.
Unlike other perpetual markets, Zaros allows for cross-margin positions. This means a user can have multiple collaterals supporting one long or short position, and multiple positions can be supported by one or more collaterals. The reason multiple collaterals and positions will cost the liquidator more is that the liquidation process needs to iterate through each collateral, performing checks, calculations, and transfers, and similarly, iterate through each market to calculate the positions' value. This additional processing consumes significantly more gas than handling a single position or collateral.
The following loop increases the gas cost for each position a user has open:
Similarly, the following loop increases the gas cost for each collateral:
Additionally, there are loops in deductAccountMargin and at the end of the liquidateAccounts function, further adding to the cost:
With a high likelihood and medium impact, this issue is rated as high severity. The high likelihood comes from the natural and frequent occurrence of users having multiple positions and collaterals. The impact is medium because there is a significant difference between the cost of liquidating an account with a single position versus one with multiple positions and collaterals.
Loss of yield for the liquidator.
Manual analysis.
Prior to deployment, calculate the cost of each additional position and collateral when liquidating. Adjust the liquidation fee to account for these additional costs, ensuring that liquidators are compensated correctly and are not at a loss.
A suggested approach:
This calculation ensures that the liquidator is adequately compensated for the additional work involved in liquidating accounts with multiple positions and collaterals.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.