Omniscia Tangible Audit

TNGBLV3Oracle Code Style Findings

TNGBLV3Oracle Code Style Findings

TNG-01C: Generic Typographic Mistakes

Description:

The referenced lines contain typographical mistakes (i.e. private variable without an underscore prefix) or generic documentational errors (i.e. copy-paste) that should be corrected.

Example:

contracts/TNGBLV3Oracle.sol
13address public constant uniV3Factory = 0x1F98431c8aD98523631AE4a59f267346ea31F984;
14uint24 public constant poolFeeDefault = 3000;

Recommendation:

We advise them to be corrected enhancing the legibility of the codebase.

Alleviation (2ad448279d9e8e4b6edd94bcd2eb22129b6f7357):

The variables have been appropriately renamed based on whether they are declared as constant or not in the latest implementation, rendering this exhibit addressed.

TNG-02C: Redundant Code Duplication

Description:

The TNGBLV3Oracle::consult function contains the same statements as TNGBLV3Oracle::consultWithFee with the absent argument being replaced by the poolFeeDefault value.

Example:

contracts/TNGBLV3Oracle.sol
16function consult(
17 address tokenIn,
18 uint128 amountIn,
19 address tokenOut,
20 uint24 secondsAgo
21) external view override returns (uint256 amountOut) {
22 address _pool = _fetchPool(tokenIn, tokenOut, poolFeeDefault);
23 require(_pool != address(0), "pool doesn't exist");
24 amountOut = _estimateAmountOut(tokenIn, tokenOut, _pool, amountIn, secondsAgo);
25}
26
27function consultWithFee(
28 address tokenIn,
29 uint128 amountIn,
30 address tokenOut,
31 uint32 secondsAgo,
32 uint24 fee
33) external view override returns (uint256 amountOut) {
34 address _pool = _fetchPool(tokenIn, tokenOut, fee);
35 require(_pool != address(0), "pool doesn't exist");
36
37 amountOut = _estimateAmountOut(tokenIn, tokenOut, _pool, amountIn, secondsAgo);
38}

Recommendation:

We advise the TNGBLV3Oracle::consult function to invoke the TNGBLV3Oracle::consultWithFee function, passing in the poolFeeDefault argument as the last one thus optimizing the bytecode size of the contract.

Alleviation (2ad448279d9e8e4b6edd94bcd2eb22129b6f7357):

The code was refactored to ensure that the _ppol related checks and amountOut calculations are performed in a single internal function that is re-used, optimizing the code's bytecode.