Uniswap / v2-periphery

🎚 Peripheral smart contracts for interacting with Uniswap V2
https://uniswap.org/docs
GNU General Public License v3.0
1.14k stars 1.69k forks source link

v3 can pull in less than amountIn, can uni v2? #164

Open NatPDeveloper opened 1 year ago

NatPDeveloper commented 1 year ago

So it came to my attention recently that uni v3 can pull in less than the amount in specified for a swap if there's insufficient liquidity.

I'm curious if uniswap v2 can do this as well. It looks like no but it would be great to be sure as the scenario I mentioned above is not in the docs. https://github.com/Uniswap/v2-periphery/blob/master/contracts/libraries/UniswapV2Library.sol#L65

UniV3 https://github.com/Uniswap/v3-core/blob/d8b1c635c275d2a9450bd6a78f3fa2484fef73eb/contracts/UniswapV3Pool.sol#L563 https://github.com/Uniswap/v3-core/blob/main/contracts/UniswapV3Pool.sol#L767

I would suggest adding the above scenario to the docs for those developing smart contracts on top of the protocol this can lead to forever locked funds.