You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Sep 24, 2023. It is now read-only.
Orders with single-sided deposits that are auto-adjusted, always revert
Summary
Deposits of only the long collateral token, when doing so results in an auto-adjustment of the order to minimize price impact, results in the order always reverting.
Vulnerability Detail
The code that determines which order to subtract the two amounts in order to get a positive difference value, has the wrong equality condition, which means the difference operation reverts due to underflow.
Impact
Single sided deposits as a feature are completely broken when the deposit doesn't solely push the swap impact towards a lower value.
Code Snippet
Since the variables are uint256s, if poolLongTokenAmount is less than poolShortTokenAmount, subtracting the latter from the former will always revert. The else condition has the same issue:
IllIllI
medium
Orders with single-sided deposits that are auto-adjusted, always revert
Summary
Deposits of only the long collateral token, when doing so results in an auto-adjustment of the order to minimize price impact, results in the order always reverting.
Vulnerability Detail
The code that determines which order to subtract the two amounts in order to get a positive difference value, has the wrong equality condition, which means the difference operation reverts due to underflow.
Impact
Single sided deposits as a feature are completely broken when the deposit doesn't solely push the swap impact towards a lower value.
Code Snippet
Since the variables are
uint256
s, ifpoolLongTokenAmount
is less thanpoolShortTokenAmount
, subtracting the latter from the former will always revert. The else condition has the same issue:https://github.com/sherlock-audit/2023-02-gmx/blob/main/gmx-synthetics/contracts/deposit/ExecuteDepositUtils.sol#L382-L402
Tool used
Manual Review
Recommendation
The text was updated successfully, but these errors were encountered: