Omniscia Tokemak Network Audit

TokeVotePool Code Style Findings

TokeVotePool Code Style Findings

TVP-01C: Unconditional Layer 2 Relay

TypeSeverityLocation
Gas OptimizationInformationalTokeVotePool.sol:L203-L205, L219-L221

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/TokeVotePool.sol
192/// @dev Adjust withheldLiquidity and requestedWithdrawal if sender does not have sufficient unlocked balance for the transfer
193function transfer(address recipient, uint256 amount)
194 public
195 override
196 whenNotPaused
197 nonReentrant
198 returns (bool)
199{
200 preTransferAdjustWithheldLiquidity(msg.sender, amount);
201 (bool success) = super.transfer(recipient, amount);
202
203 bytes32 eventSig = "Transfer";
204 encodeAndSendData(eventSig, msg.sender);
205 encodeAndSendData(eventSig, recipient);
206
207 return success;
208}
209
210/// @dev Adjust withheldLiquidity and requestedWithdrawal if sender does not have sufficient unlocked balance for the transfer
211function transferFrom(
212 address sender,
213 address recipient,
214 uint256 amount
215) public override whenNotPaused nonReentrant returns (bool) {
216 preTransferAdjustWithheldLiquidity(sender, amount);
217 (bool success) = super.transferFrom(sender, recipient, amount);
218
219 bytes32 eventSig = "Transfer";
220 encodeAndSendData(eventSig, sender);
221 encodeAndSendData(eventSig, recipient);
222
223 return success;
224}

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.