Omniscia Tokemak Network Audit

TokeMigrationPool Code Style Findings

TokeMigrationPool Code Style Findings

TMP-01C: Unconditional Layer 2 Relay

TypeSeverityLocation
Gas OptimizationInformationalTokeMigrationPool.sol:L215, L216, L231, L232

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/TokeMigrationPool.sol
203/// @dev Adjust withheldLiquidity and requestedWithdrawal if sender does not have sufficient unlocked balance for the transfer
204function transfer(address recipient, uint256 amount)
205 public
206 override
207 whenNotPaused
208 nonReentrant
209 returns (bool)
210{
211 preTransferAdjustWithheldLiquidity(msg.sender, amount);
212 (bool success) = super.transfer(recipient, amount);
213
214 bytes32 eventSig = "Transfer";
215 encodeAndSendData(eventSig, msg.sender);
216 encodeAndSendData(eventSig, recipient);
217
218 return success;
219}
220
221/// @dev Adjust withheldLiquidity and requestedWithdrawal if sender does not have sufficient unlocked balance for the transfer
222function transferFrom(
223 address sender,
224 address recipient,
225 uint256 amount
226) public override whenNotPaused nonReentrant returns (bool) {
227 preTransferAdjustWithheldLiquidity(sender, amount);
228 (bool success) = super.transferFrom(sender, recipient, amount);
229
230 bytes32 eventSig = "Transfer";
231 encodeAndSendData(eventSig, sender);
232 encodeAndSendData(eventSig, recipient);
233
234 return success;
235}

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.