sherlock-audit / 2023-04-unitasprotocol-judging

4 stars 3 forks source link

PawelK - No `amountLimit` in `swap` function #99

Closed sherlock-admin closed 1 year ago

sherlock-admin commented 1 year ago

PawelK

medium

No amountLimit in swap function

Summary

No amountLimit parameter in swap function

Vulnerability Detail

Swap function doesn't contain an amountLimit, a user might end up receiving a different amount of assets than expected, or spending more than intended due to price changes during the transaction's execution.

Impact

Financial loss due to receiving execution of the transaction in a time not controlled by the user

Code Snippet

// amountLimit parameter missing
function swap(address tokenIn, address tokenOut, AmountType amountType, uint256 amount)

Tool used

Manual Review

Recommendation

Add amountLimit parameter to swap function, and revert the transaction if amountOut won't be greater or equal to amountLimit if the amountType is IN, or revert if amountIn will be greater than amountLimitif the amountType is OUT,

Duplicate of #88