sherlock-audit / 2023-04-unitasprotocol-judging

4 stars 3 forks source link

circlelooper - `Swap` function exposes users to unlimited slippage #157

Closed sherlock-admin closed 1 year ago

sherlock-admin commented 1 year ago

circlelooper

medium

Swap function exposes users to unlimited slippage

Summary

Unitas swap provides no slippage protection, that will expose users to unlimited slippage.

Vulnerability Detail

The swap function in Unitas is used to swap tokens, however, users cannot specify the max token amount they are willing to spend or the min token amount they expect to get. There’s extreme situations when user's transaction stuck in pending and a large price fluctuation occurs before the transaction executes, this will exposes users to unlimited slippage.

Impact

Unitas swap provides no slippage protection, that will expose users to unlimited slippage.

Code Snippet

https://github.com/sherlock-audit/2023-04-unitasprotocol/blob/main/Unitas-Protocol/src/Unitas.sol#L208-L237

Tool used

Manual Review

Recommendation

When calls swap, It is recommeded to allow user to specify the max token amount they are willing to spend or the min token amount they expect to get.

Duplicate of #88