Uniswap / v3-periphery

🦄 🦄 🦄 Peripheral smart contracts for interacting with Uniswap v3
https://uniswap.org
GNU General Public License v2.0
1.17k stars 1.09k forks source link

Removing redundant checks #228

Closed tanliwei closed 2 years ago

tanliwei commented 2 years ago

The two internal functions,getLiquidityForAmount0 and getLiquidityForAmount1, are only called in the below getLiquidityForAmounts function. https://github.com/Uniswap/v3-periphery/blob/main/contracts/libraries/LiquidityAmounts.sol#L56-L75

The if-else branch of the getLiquidityForAmounts function already done the validation of the parameters passed into the getLiquidityForAmount0 function and getLiquidityForAmount1 function. I.e., make the first parameter passed into the getLiquidityForAmount0 function less than the second parameter. Same validation done to the parameter passed into the getLiquidityForAmount1 function.

So, there is no need to repeatedly do the same validations in the getLiquidityForAmount0 function and the getLiquidityForAmount1 function.

tanliwei commented 2 years ago

There are callings to the getLiquidityForAmount1 function and the getLiquidityForAmount0 function in the testing contract LiquidityAmountsTest. However, it is still ok.

tanliwei commented 2 years ago

it is closed since it turns out this pr does not raise the interest of anyone.