Omniscia Native Audit

Router Code Style Findings

Router Code Style Findings

RRE-01C: Generic Typographic Mistake

TypeSeverityLocation
Code StyleRouter.sol:L27

Description:

The referenced line contains a typographical mistake (i.e. private variable without an underscore prefix) or generic documentational error (i.e. copy-paste) that should be corrected.

Example:

contracts/Router.sol
27event swapCalculations(uint256 amountIn, address recipient);

Recommendation:

We advise this to be done so to enhance the legibility of the codebase.

Alleviation:

The referenced event name was corrected to use the CapWords naming convention.

RRE-02C: Inexistent Support of Contract Payer

TypeSeverityLocation
Standard ConformityRouter.sol:L155, L175

Description:

The exactOutput-prefixed functions of the contract do not permit the user to have already deposited funds to satisfy the amountIn value that potentially arises.

Example:

contracts/Router.sol
146/// @inheritdoc ISwapRouter
147function exactOutputSingle(
148 ExactOutputSingleParams calldata params
149) external payable override nonReentrant returns (uint256 amountIn) {
150 require(tx.origin == msg.sender, "only EOA");
151 // avoid an SLOAD by using the swap return data
152 amountIn = exactOutputInternal(
153 params.amountOut,
154 params.recipient,
155 SwapCallbackData({orders: params.orders, payer: msg.sender})
156 );
157
158 require(amountIn <= params.amountInMaximum, "Too much requested");
159 // has to be reset even though we don't use it in the single hop case
160 amountInCached = DEFAULT_AMOUNT_IN_CACHED;
161
162 if (address(this).balance > 0)
163 TransferHelper.safeTransferETH(msg.sender, address(this).balance);
164
165}
166
167/// @inheritdoc ISwapRouter
168function exactOutput(
169 ExactOutputParams calldata params
170) external payable override nonReentrant returns (uint256 amountIn) {
171 require(tx.origin == msg.sender, "only EOA");
172 exactOutputInternal(
173 params.amountOut,
174 params.recipient,
175 SwapCallbackData({orders: params.orders, payer: msg.sender})
176 );
177
178 amountIn = amountInCached;
179 require(amountIn <= params.amountInMaximum, "Too much requested");
180 amountInCached = DEFAULT_AMOUNT_IN_CACHED;
181
182 if (address(this).balance > 0)
183 TransferHelper.safeTransferETH(msg.sender, address(this).balance);
184
185}

Recommendation:

We advise this functionality already present in the exactInput-prefixed functions to be incorporated to the exactOutput-prefixed functions streamlining the codebase's operation.

Alleviation:

The exactOutputSingle and exactOutput functions have been commented out of the codebase rendering this exhibit no longer applicable.

RRE-03C: Redundant Parenthesis Statements

TypeSeverityLocation
Code StyleRouter.sol:L205, L229, L235

Description:

The referenced statements are wrapped in parenthesis (()) redundantly as they do not affect the order of operations.

Example:

contracts/Router.sol
202(int256 amount0Delta, int256 amount1Delta) = IPool(order.buyer).swap(
203 abi.encode(order),
204 signature,
205 (amountIn).toInt256(),
206 recipient,
207 abi.encode(data)
208);

Recommendation:

We advise the parenthesis to be safely omitted, optimizing the legibility of the codebase.

Alleviation:

The redundant parenthesis have been removed from the statements that remain relevant in the codebase, alleviating this exhibit.