code-423n4 / 2024-04-revert-mitigation-findings

1 stars 1 forks source link

M-18 MitigationConfirmed #93

Open c4-bot-2 opened 2 months ago

c4-bot-2 commented 2 months ago

Lines of code

Vulnerability details

C4 issue

M-18: Users cannot stop loss in AutoRange and AutoExit

Comments

When a user delegates their positions to AutoRange or AutoExit, both Auto contracts (controlled by bots) will execute specific actions on these positions. In cases where no swapping is required, both AutoRange.execute() and AutoExit.execute() will call _validateSwap(). This function may revert when the price for tokens is drastically changing.

Considering that this revert occurs even if no swap takes place, both functions may unnecessarily fail. If a swap is not necessary, it should not be called.

Mitigation

PR #12

This mitigation fix revolves around wrapping all logic regarding swaps (both validations and the actual swap) around guard checks that ensure a swap should be executed.

Major changes include:

Minor changes include:

Based on these changes, _validateSwap() will no longer be called unless a swap is necessary. Any major swings in price will have no impact on AutoRange or AutoExit when a swap does not occur.

Conclusion

LGTM

c4-judge commented 2 months ago

jhsagd76 marked the issue as satisfactory