Platform: Code4rena
Start Date: 24/03/2023
Pot Size: $49,200 USDC
Total HM: 20
Participants: 246
Period: 6 days
Judge: Picodes
Total Solo HM: 1
Id: 226
League: ETH
Rank: 192/246
Findings: 1
Award: $13.13
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: brgltd
Also found by: 0x3b, 0xAgro, 0xGusMcCrae, 0xNorman, 0xRajkumar, 0xSmartContract, 0xTraub, 0xWagmi, 0xWaitress, 0xffchain, 0xhacksmithh, 0xkazim, 0xnev, 3dgeville, ArbitraryExecution, Aymen0909, BRONZEDISC, Bason, Bloqarl, BlueAlder, Brenzee, CodeFoxInc, CodingNameKiki, Cryptor, DadeKuma, DevABDee, Diana, Dug, Englave, Gde, Haipls, HollaDieWaldfee, Ignite, Infect3d, Jerry0x, Josiah, Kaysoft, Koko1912, KrisApostolov, Lavishq, LeoGold, Madalad, PNS, Rappie, RaymondFam, RedTiger, Rickard, Rolezn, Sathish9098, SunSec, T1MOH, UdarTeam, Udsen, Viktor_Cortess, Wander, adriro, ak1, alejandrocovrr, alexzoid, arialblack14, ayden, bin2chen, brevis, btk, c3phas, carlitox477, catellatech, ch0bu, chaduke, ck, climber2002, codeslide, descharre, dingo2077, ernestognw, fatherOfBlocks, favelanky, georgits, helios, hl_, inmarelibero, juancito, ks__xxxxx, lopotras, lukris02, m_Rassska, mahdirostami, maxper, nadin, navinavu, nemveer, p_crypt0, peanuts, pipoca, pixpi, qpzm, rbserver, reassor, roelio, rotcivegaf, scokaf, siddhpurakaran, slvDev, smaul, tnevler, tsvetanovv, turvy_fuzz, vagrant, wen, yac, zzzitron
13.1298 USDC - $13.13
File: contracts/SafEth/derivatives/Reth.sol 58: function setMaxSlippage(uint256 _slippage) external onlyOwner { 59: maxSlippage = _slippage; 60: }
Similarly in SfrxEth.sol
and WstEth.sol
This method can be called directly on a derivative contract or via a SafETH.setMaxSlippage(uint, uint)
contract (where the event is emitted).
If called directly, there will be no event.
It's better to move the event to the derivative implementation, where we also have access to the changed value.
The event could look like this:
emit SetMaxSlippage(oldMaxSlippage, newMaxSlippage);
It is a good practice to give time for users to react and adjust to critical changes. A timelock provides more guarantees and reduces the level of trust required, thus decreasing risk for users.
Consider adding a timelock to:
File: contracts/SafEth/SafEth.sol 165: function adjustWeight( 166: uint256 _derivativeIndex, 167: uint256 _weight 168: ) external onlyOwner {
File: contracts/SafEth/SafEth.sol 182: function addDerivative( 183: address _contractAddress, 184: uint256 _weight 185: ) external onlyOwner {
File: contracts/SafEth/SafEth.sol 202: function setMaxSlippage( 203: uint _derivativeIndex, 204: uint _slippage 205: ) external onlyOwner {
It's a mechanism to avoid mistakes like this
File: contracts/SafEth/SafEth.sol 79: if (totalSupply == 0)
File: contracts/SafEth/SafEth.sol 87: if (weight == 0) continue;
File: contracts/SafEth/SafEth.sol 117: if (derivativeAmount == 0) continue; // if derivative empty ignore
File: contracts/SafEth/SafEth.sol 148: if (weights[i] == 0 || ethAmountToRebalance == 0) continue;
File: contracts/SafEth/SafEth.sol 64: require(pauseStaking == false, "staking is paused");
File: contracts/SafEth/SafEth.sol 109: require(pauseUnstaking == false, "unstaking is paused");
before:
File: contracts/SafEth/SafEth.sol 174: emit WeightChange(_derivativeIndex, _weight);
after:
File: contracts/SafEth/SafEth.sol 174: emit WeightChange(_derivativeIndex, oldWeight, newWeight);
File: contracts/SafEth/SafEth.sol 216: emit ChangeMinAmount(minAmount);
File: contracts/SafEth/SafEth.sol 225: emit ChangeMaxAmount(maxAmount);
Each derivative implementation will include the identical setMaxSlippage(uint256 slippage)
function. This can be extracted to the base contract and overridden in a specific implementation if needed. This will definitely affect the simplicity of the code and the maintenance of the project with the increasing number of derivatives.
File: contracts/SafEth/derivatives/Reth.sol 58: function setMaxSlippage(uint256 _slippage) external onlyOwner { 59: maxSlippage = _slippage; 60: }
abstract contract BaseDerivative is IDerivative{ uint256 public maxSlippage; function setMaxSlippage(uint256 _slippage) external virtual { maxSlippage = _slippage; } }
According to the Solidity style guide, functions should be laid out in the following order:
None of the contracts meet the guidelines.
#0 - c4-sponsor
2023-04-10T19:50:53Z
toshiSat marked the issue as sponsor acknowledged
#1 - c4-judge
2023-04-24T18:34:07Z
Picodes marked the issue as grade-b