# Contract scan report

> **Automated scan, not an audit. Findings may be false positives; absence of findings does not mean the code is safe.**

- Scan id: `a682bcad-c40a-4034-8837-6f75723d8b8e`
- Status: **ok**
- Contract: `0x2626664c2603336E57B271c5C0b26F421741e481` on base (contracts/SwapRouter02.sol:SwapRouter02)
- Input: address, 236 file(s), 8282 nSLOC, sha256 `8dcc22df7b2df327...`
- Compiler: solc 0.7.6
- Duration: 25.4 s

## Summary

| High | Medium | Low | Info |
|---|---|---|---|
| 0 | 0 | 14 | 0 |

## Findings

### F-001 [LOW] Dangerous strict equalities

`incorrect-equality` (slither) · confidence high · `contracts/V3SwapRouter.sol:91`

```solidity
        (int256 amount0, int256 amount1) =
            getPool(tokenIn, tokenOut, fee).swap(
                recipient,
                zeroForOne,
                amountIn.toInt256(),
                sqrtPriceLimitX96 == 0
```

V3SwapRouter.exactInputInternal(uint256,address,uint160,V3SwapRouter.SwapCallbackData) (contracts/V3SwapRouter.sol#77-103) uses a dangerous strict equality:
	- sqrtPriceLimitX96 == 0 (contracts/V3SwapRouter.sol#91-100)

**Why it matters:** Use of strict equalities that can be easily manipulated by an attacker.

**Fix:** Don't use strict equality to determine if an account has enough Ether or tokens.

### F-002 [LOW] Dangerous strict equalities

`incorrect-equality` (slither) · confidence high · `contracts/V3SwapRouter.sol:202`

```solidity
        if (sqrtPriceLimitX96 == 0) require(amountOutReceived == amountOut);
```

V3SwapRouter.exactOutputInternal(uint256,address,uint160,V3SwapRouter.SwapCallbackData) (contracts/V3SwapRouter.sol#171-203) uses a dangerous strict equality:
	- require(bool)(amountOutReceived == amountOut) (contracts/V3SwapRouter.sol#202)

**Why it matters:** Use of strict equalities that can be easily manipulated by an attacker.

**Fix:** Don't use strict equality to determine if an account has enough Ether or tokens.

### F-003 [LOW] Dangerous strict equalities

`incorrect-equality` (slither) · confidence high · `contracts/base/PeripheryValidationExtended.sol:8`

```solidity
        require(blockhash(block.number - 1) == previousBlockhash, 'Blockhash');
```

PeripheryValidationExtended.checkPreviousBlockhash(bytes32) (contracts/base/PeripheryValidationExtended.sol#7-10) uses a dangerous strict equality:
	- require(bool,string)(blockhash(uint256)(block.number - 1) == previousBlockhash,Blockhash) (contracts/base/PeripheryValidationExtended.sol#8)

**Why it matters:** Use of strict equalities that can be easily manipulated by an attacker.

**Fix:** Don't use strict equality to determine if an account has enough Ether or tokens.

### F-004 [LOW] Calls inside a loop

`calls-loop` (slither) · confidence medium · `contracts/V2SwapRouter.sol:30`

```solidity
                (uint256 reserve0, uint256 reserve1, ) = pair.getReserves();
```

V2SwapRouter._swap(address[],address) (contracts/V2SwapRouter.sol#21-41) has external calls inside a loop: (reserve0,reserve1,None) = pair.getReserves() (contracts/V2SwapRouter.sol#30)
	Calls stack containing the loop:
		V2SwapRouter.swapExactTokensForTokens(uint256,uint256,address[],address)

**Why it matters:** Calls inside a loop might lead to a denial-of-service attack.

**Fix:** Favor [pull over push](https://consensysdiligence.github.io/smart-contract-best-practices/development-recommendations/general/external-calls/#favor-pull-over-push-for-external-calls) strategy for external calls.

### F-005 [LOW] Calls inside a loop

`calls-loop` (slither) · confidence medium · `contracts/V2SwapRouter.sol:33`

```solidity
                amountInput = IERC20(input).balanceOf(address(pair)).sub(reserveInput);
```

V2SwapRouter._swap(address[],address) (contracts/V2SwapRouter.sol#21-41) has external calls inside a loop: amountInput = IERC20(input).balanceOf(address(pair)).sub(reserveInput) (contracts/V2SwapRouter.sol#33)
	Calls stack containing the loop:
		V2SwapRouter.swapExactTokensForTokens(uint256,uint256,address[],address)

**Why it matters:** Calls inside a loop might lead to a denial-of-service attack.

**Fix:** Favor [pull over push](https://consensysdiligence.github.io/smart-contract-best-practices/development-recommendations/general/external-calls/#favor-pull-over-push-for-external-calls) strategy for external calls.

### F-006 [LOW] Calls inside a loop

`calls-loop` (slither) · confidence medium · `contracts/V2SwapRouter.sol:39`

```solidity
            pair.swap(amount0Out, amount1Out, to, new bytes(0));
```

V2SwapRouter._swap(address[],address) (contracts/V2SwapRouter.sol#21-41) has external calls inside a loop: pair.swap(amount0Out,amount1Out,to,new bytes(0)) (contracts/V2SwapRouter.sol#39)
	Calls stack containing the loop:
		V2SwapRouter.swapExactTokensForTokens(uint256,uint256,address[],address)

**Why it matters:** Calls inside a loop might lead to a denial-of-service attack.

**Fix:** Favor [pull over push](https://consensysdiligence.github.io/smart-contract-best-practices/development-recommendations/general/external-calls/#favor-pull-over-push-for-external-calls) strategy for external calls.

### F-007 [LOW] Reentrancy vulnerabilities

`reentrancy-balance` (slither) · confidence medium · `contracts/V2SwapRouter.sol:70`

```solidity
        _swap(path, to);
```

Reentrancy in V2SwapRouter.swapExactTokensForTokens(uint256,uint256,address[],address) (contracts/V2SwapRouter.sol#44-74):
	External call allowing reentrancy:
	- _swap(path,to) (contracts/V2SwapRouter.sol#70)
		- pair.swap(amount0Out,amount1Out,to,new bytes(0)) (contracts/V2SwapRouter.sol#39)
	Balance read before the call:
	- balanceBefore = IERC20(path[path.length - 1]).balanceOf(to) (contracts/V2SwapRouter.sol#68)
	Possible stale balance used after the call in a condition:
	- require(bool,string)(amountOut &gt;= amountOutMin,Too little received) (contracts/V2SwapRouter.sol#73)
		- stale variable `amountOut`

**Why it matters:** 
Detects reentrancy vulnerabilities where a balance is saved (e.g., `balanceOf`) before an external call,
and the same balance is checked again after the call. An attacker could manipulate the balance during the reentrant call,
causing the post-call check to use an outdated value.

**Fix:** Use `transferFrom` to transfer funds of a standard ERC20 token, or use reentrancy guards to prevent reentering the function.

### F-008 [LOW] Unused return

`unused-return` (slither) · confidence medium · `contracts/V3SwapRouter.sol:54`

```solidity
        CallbackValidation.verifyCallback(factory, tokenIn, tokenOut, fee);
```

V3SwapRouter.uniswapV3SwapCallback(int256,int256,bytes) (contracts/V3SwapRouter.sol#46-74) ignores return value by CallbackValidation.verifyCallback(factory,tokenIn,tokenOut,fee) (contracts/V3SwapRouter.sol#54)

**Why it matters:** The return value of an external call is not stored in a local or state variable.

**Fix:** Ensure that all the return values of the function calls are used.

### F-009 [LOW] Calls inside a loop

`calls-loop` (slither) · confidence medium · `contracts/V3SwapRouter.sol:91`

```solidity
        (int256 amount0, int256 amount1) =
            getPool(tokenIn, tokenOut, fee).swap(
                recipient,
                zeroForOne,
                amountIn.toInt256(),
                sqrtPriceLimitX96 == 0
```

V3SwapRouter.exactInputInternal(uint256,address,uint160,V3SwapRouter.SwapCallbackData) (contracts/V3SwapRouter.sol#77-103) has external calls inside a loop: (amount0,amount1) = getPool(tokenIn,tokenOut,fee).swap(recipient,zeroForOne,amountIn.toInt256(),TickMath.MAX_SQRT_RATIO - 1,abi.encode(data)) (contracts/V3SwapRouter.sol#91-100)
	Calls stack containing the loop:
		V3SwapRouter.exactInput(IV3SwapRouter.ExactInputParams)

**Why it matters:** Calls inside a loop might lead to a denial-of-service attack.

**Fix:** Favor [pull over push](https://consensysdiligence.github.io/smart-contract-best-practices/development-recommendations/general/external-calls/#favor-pull-over-push-for-external-calls) strategy for external calls.

### F-010 [LOW] Reentrancy vulnerabilities

`reentrancy-balance` (slither) · confidence medium · `contracts/V3SwapRouter.sol:119`

```solidity
        amountOut = exactInputInternal(
            params.amountIn,
            params.recipient,
            params.sqrtPriceLimitX96,
            SwapCallbackData({
                path: abi.encodePacked(params.tokenIn, params.fee, params.tokenOut),
```

Reentrancy in V3SwapRouter.exactInputSingle(IV3SwapRouter.ExactInputSingleParams) (contracts/V3SwapRouter.sol#106-129):
	External call allowing reentrancy:
	- amountOut = exactInputInternal(params.amountIn,params.recipient,params.sqrtPriceLimitX96,SwapCallbackData({path:abi.encodePacked(params.tokenIn,params.fee,params.tokenOut),payer:address(this)})) (contracts/V3SwapRouter.sol#119-127)
		- (amount0,amount1) = getPool(tokenIn,tokenOut,fee).swap(recipient,zeroForOne,amountIn.toInt256(),sqrtPriceLimitX96,abi.encode(data)) (contracts/V3SwapRouter.sol#91-100)
		- (amount0,amount1) = getPool(tokenIn,tokenOut,fee).swap(recipient,zeroForOne,amountIn.toInt256(),TickMath.MIN_SQRT_RATIO + 1,abi.encode(data)) (contracts/V3SwapRouter.sol#91-100)
		- (amount0,amount1) = getPool(tokenIn,tokenOut,fee).swap(recipient,zeroForOne,amountIn.toInt256(),TickMath.MAX_SQRT_RATIO - 1,abi.encode(data)) (contracts/V3SwapRouter.sol#91-100)
	Balance read before the call:
	- params.amountIn = IERC20(params.tokenIn).balanceOf(address(this)) (contracts/V3SwapRouter.sol#116)
	Possible stale balance used after the call in a condition:
	- require(bool,string)(amountOut &gt;= params.amountOutMinimum,Too little received) (contracts/V3SwapRouter.sol#128)
		- stale variable `amountOut`

**Why it matters:** 
Detects reentrancy vulnerabilities where a balance is saved (e.g., `balanceOf`) before an external call,
and the same balance is checked again after the call. An attacker could manipulate the balance during the reentrant call,
causing the post-call check to use an outdated value.

**Fix:** Use `transferFrom` to transfer funds of a standard ERC20 token, or use reentrancy guards to prevent reentering the function.

### F-011 [LOW] Calls inside a loop

`calls-loop` (slither) · confidence medium · `contracts/base/OracleSlippage.sol:25`

```solidity
        (, currentTick, observationIndex, observationCardinality, , , ) = pool.slot0();
```

OracleSlippage.getBlockStartingAndCurrentTick(IUniswapV3Pool) (contracts/base/OracleSlippage.sol#18-46) has external calls inside a loop: (None,currentTick,observationIndex,observationCardinality,None,None,None) = pool.slot0() (contracts/base/OracleSlippage.sol#25)
	Calls stack containing the loop:
		OracleSlippage.checkOracleSlippage(bytes,uint24,uint32)
		OracleSlippage.getSyntheticTicks(bytes,uint32)

**Why it matters:** Calls inside a loop might lead to a denial-of-service attack.

**Fix:** Favor [pull over push](https://consensysdiligence.github.io/smart-contract-best-practices/development-recommendations/general/external-calls/#favor-pull-over-push-for-external-calls) strategy for external calls.

### F-012 [LOW] Calls inside a loop

`calls-loop` (slither) · confidence medium · `contracts/base/OracleSlippage.sol:33`

```solidity
        (uint32 observationTimestamp, int56 tickCumulative, , ) = pool.observations(observationIndex);
```

OracleSlippage.getBlockStartingAndCurrentTick(IUniswapV3Pool) (contracts/base/OracleSlippage.sol#18-46) has external calls inside a loop: (observationTimestamp,tickCumulative,None,None) = pool.observations(observationIndex) (contracts/base/OracleSlippage.sol#33)
	Calls stack containing the loop:
		OracleSlippage.checkOracleSlippage(bytes,uint24,uint32)
		OracleSlippage.getSyntheticTicks(bytes,uint32)

**Why it matters:** Calls inside a loop might lead to a denial-of-service attack.

**Fix:** Favor [pull over push](https://consensysdiligence.github.io/smart-contract-best-practices/development-recommendations/general/external-calls/#favor-pull-over-push-for-external-calls) strategy for external calls.

### F-013 [LOW] Calls inside a loop

`calls-loop` (slither) · confidence medium · `contracts/base/OracleSlippage.sol:38`

```solidity
            (uint32 prevObservationTimestamp, int56 prevTickCumulative, , bool prevInitialized) =
                pool.observations(prevIndex);
```

OracleSlippage.getBlockStartingAndCurrentTick(IUniswapV3Pool) (contracts/base/OracleSlippage.sol#18-46) has external calls inside a loop: (prevObservationTimestamp,prevTickCumulative,None,prevInitialized) = pool.observations(prevIndex) (contracts/base/OracleSlippage.sol#38-39)
	Calls stack containing the loop:
		OracleSlippage.checkOracleSlippage(bytes,uint24,uint32)
		OracleSlippage.getSyntheticTicks(bytes,uint32)

**Why it matters:** Calls inside a loop might lead to a denial-of-service attack.

**Fix:** Favor [pull over push](https://consensysdiligence.github.io/smart-contract-best-practices/development-recommendations/general/external-calls/#favor-pull-over-push-for-external-calls) strategy for external calls.

### F-014 [LOW] Calls inside a loop

`calls-loop` (slither) · confidence medium · `contracts/base/OracleSlippage.sol:82`

```solidity
                (, currentTick, , , , , ) = IUniswapV3Pool(pool).slot0();
```

OracleSlippage.getSyntheticTicks(bytes,uint32) (contracts/base/OracleSlippage.sol#60-114) has external calls inside a loop: (None,currentTick,None,None,None,None,None) = IUniswapV3Pool(pool).slot0() (contracts/base/OracleSlippage.sol#82)
	Calls stack containing the loop:
		OracleSlippage.checkOracleSlippage(bytes,uint24,uint32)

**Why it matters:** Calls inside a loop might lead to a denial-of-service attack.

**Fix:** Favor [pull over push](https://consensysdiligence.github.io/smart-contract-best-practices/development-recommendations/general/external-calls/#favor-pull-over-push-for-external-calls) strategy for external calls.
