Omniscia vfat Audit

UniswapV3Connector Code Style Findings

UniswapV3Connector Code Style Findings

UVR-01C: Code Redundancy

Description:

The UniswapV3Connector::_claim_fees function implements the same statements as the UniswapV3Connector::_collect function albeit with one extra conditional.

Example:

contracts/connectors/UniswapV3Connector.sol
95function claim(
96 NftPosition calldata position,
97 address[] memory, // rewardTokens
98 uint128 amount0Max,
99 uint128 amount1Max,
100 bytes calldata // extraData
101) external payable virtual override {
102 _claim_fees(position, amount0Max, amount1Max);
103}
104
105function _claim_fees(
106 NftPosition calldata position,
107 uint128 amount0Max,
108 uint128 amount1Max
109) internal virtual {
110 if (amount0Max > 0 || amount1Max > 0) {
111 INonfungiblePositionManager.CollectParams memory params =
112 INonfungiblePositionManager.CollectParams({
113 tokenId: position.tokenId,
114 recipient: address(this),
115 amount0Max: amount0Max,
116 amount1Max: amount1Max
117 });
118 INonfungiblePositionManager(address(position.nft)).collect(params);
119 }
120}

Recommendation:

We advise the UniswapV3Connector::_collect function to be utilized by the UniswapV3Connector::claim function and the conditional of the UniswapV3Connector::_claim_fees function to be relocated to the UniswapV3Connector::claim function implementation itself, optimizing the code's layout.

Alleviation (6ab7af3bb495b817ffec469255ea679b1813eecb):

The code structure was optimized as advised, rendering the UniswapV3Connector::_claim_fees function no longer necessary.

UVR-02C: Redundant Increment of Deadlines

TypeSeverityLocation
Gas OptimizationUniswapV3Connector.sol:
I-1: L78
I-2: L137
I-3: L152
I-4: L166

Description:

The deadline parameter of a Uniswap V3 swap or NFT position manager interaction can be the block.timestamp itself.

Example:

contracts/connectors/UniswapV3Connector.sol
74ISwapRouter(swap.router).exactInput(
75 ISwapRouter.ExactInputParams({
76 path: extraData.path,
77 recipient: address(this),
78 deadline: block.timestamp + 1,
79 amountIn: swap.amountIn,
80 amountOutMinimum: swap.minAmountOut
81 })
82);

Recommendation:

We advise this to be set so, omitting the addition by one in each instance and thus optimizing the code's gas cost.

Alleviation (6ab7af3bb495b817ffec469255ea679b1813eecb):

The redundant deadline increments highlighted have been omitted as advised.