Omniscia Symbiosis Finance Audit
BridgeV2 Code Style Findings
BridgeV2 Code Style Findings
BV2-01C: Redundant Logical Block
| Type | Severity | Location |
|---|---|---|
| Gas Optimization | ![]() | BridgeV2.sol:L63-L69 |
Description:
The mpc function is meant to retrieve either the newMPC or oldMPC variable depending on the newMPCEffectiveTime, however, the variable's value is always set to block.timestamp across the contract rendering the check redundant.
Example:
contracts/synth-contracts/bridge-v2/BridgeV2.sol
49/// ** INITIALIZER **50
51function initialize(address _mpc) public virtual initializer {52 __Ownable_init();53
54 newMPC = _mpc;55 newMPCEffectiveTime = block.timestamp;56}57
58/// ** VIEW functions **59
60/**61 * @notice Returns MPC62 */63function mpc() public view returns (address) {64 if (block.timestamp >= newMPCEffectiveTime) {65 return newMPC;66 }67
68 return oldMPC;69}70
71/**72 * @notice Returns chain ID of block73 */74function currentChainId() public view returns (uint256) {75 return block.chainid;76}77
78/// ** MPC functions **79
80/**81 * @notice Changes MPC82 */83function changeMPC(address _newMPC) external onlyMPC returns (bool) {84 require(_newMPC != address(0), "BridgeV2: address(0x0)");85 oldMPC = mpc();86 newMPC = _newMPC;87 newMPCEffectiveTime = block.timestamp;88 emit LogChangeMPC(89 oldMPC,90 newMPC,91 newMPCEffectiveTime,92 currentChainId()93 );94 return true;95}96
97/**98* @notice Get commission by MPC99 */100function getCommissionByMPC(address token, address to, uint256 amount) external onlyMPC returns (bool) {101 TransferHelper.safeTransfer(token, to, amount);102 return true;103}104
105/**106 * @notice Changes MPC (onlyOwner)107 */108function changeMPCByOwner(address _newMPC) external onlyOwner returns (bool) {109 require(_newMPC != address(0), "BridgeV2: address(0x0)");110 oldMPC = mpc();111 newMPC = _newMPC;112 newMPCEffectiveTime = block.timestamp;113 emit LogChangeMPC(114 oldMPC,115 newMPC,116 newMPCEffectiveTime,117 currentChainId()118 );119 return true;120}Recommendation:
We advise the mpc function to retrieve newMPC directly, optimizing its gas cost.
Alleviation:
The Symbiosis Finance team considered this exhibit but opted not to apply a remediation for it in the current iteration.
