Omniscia Tokemak Network Audit

EthPool Code Style Findings

EthPool Code Style Findings

EPL-01C: Unconditional Layer 2 Relay

TypeSeverityLocation
Gas OptimizationInformationalEthPool.sol:L188-L190, L204-L206

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/EthPool.sol
183/// @dev Adjust withheldLiquidity and requestedWithdrawal if sender does not have sufficient unlocked balance for the transfer
184function transfer(address recipient, uint256 amount) public override whenNotPaused nonReentrant returns (bool) {
185 preTransferAdjustWithheldLiquidity(msg.sender, amount);
186 (bool success) = super.transfer(recipient, amount);
187
188 bytes32 eventSig = "Transfer";
189 encodeAndSendData(eventSig, msg.sender);
190 encodeAndSendData(eventSig, recipient);
191
192 return success;
193}
194
195/// @dev Adjust withheldLiquidity and requestedWithdrawal if sender does not have sufficient unlocked balance for the transfer
196function transferFrom(
197 address sender,
198 address recipient,
199 uint256 amount
200) public override whenNotPaused nonReentrant returns (bool) {
201 preTransferAdjustWithheldLiquidity(sender, amount);
202 (bool success) = super.transferFrom(sender, recipient, amount);
203
204 bytes32 eventSig = "Transfer";
205 encodeAndSendData(eventSig, sender);
206 encodeAndSendData(eventSig, recipient);
207
208 return success;
209}

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.