Omniscia Tokemak Network Audit

Pool Code Style Findings

Pool Code Style Findings

POO-01C: Unconditional Layer 2 Relay

TypeSeverityLocation
Gas OptimizationInformationalPool.sol:L182-L184, L198-L200

Description:

The linked relay operations should not be performed in case the transfer was performed to self as no balance update woudl be necessary.

Example:

contracts/pools/Pool.sol
171/// @dev Adjust withheldLiquidity and requestedWithdrawal if sender does not have sufficient unlocked balance for the transfer
172function transfer(address recipient, uint256 amount)
173 public
174 override
175 whenNotPaused
176 nonReentrant
177 returns (bool)
178{
179 preTransferAdjustWithheldLiquidity(msg.sender, amount);
180 (bool success) = super.transfer(recipient, amount);
181
182 bytes32 eventSig = "Transfer";
183 encodeAndSendData(eventSig, msg.sender);
184 encodeAndSendData(eventSig, recipient);
185
186 return success;
187}
188
189/// @dev Adjust withheldLiquidity and requestedWithdrawal if sender does not have sufficient unlocked balance for the transfer
190function transferFrom(
191 address sender,
192 address recipient,
193 uint256 amount
194) public override whenNotPaused nonReentrant returns (bool) {
195 preTransferAdjustWithheldLiquidity(sender, amount);
196 (bool success) = super.transferFrom(sender, recipient, amount);
197
198 bytes32 eventSig = "Transfer";
199 encodeAndSendData(eventSig, sender);
200 encodeAndSendData(eventSig, recipient);
201
202 return success;
203}

Recommendation:

We advise an if conditional to be introduced surrounding them and evaluating whether msg.sender == recipient or sender == recipient respectively.

Alleviation:

The Tokemak team has stated that based on their usage and code execution frequency introducing this check would increase the median gas cost of all calls and as such opted not to apply the optimization.