Platform: Code4rena
Start Date: 11/01/2023
Pot Size: $60,500 USDC
Total HM: 6
Participants: 69
Period: 6 days
Judge: Trust
Total Solo HM: 2
Id: 204
League: ETH
Rank: 66/69
Findings: 1
Award: $32.36
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: c3phas
Also found by: 0x1f8b, 0xSmartContract, Aymen0909, Bnke0x0, Diana, IllIllI, RaymondFam, Rolezn, Sathish9098, SleepingBugs, Viktor_Cortess, adriro, arialblack14, chaduke, cryptostellar5, cygaar, descharre, dharma09, eyexploit, halden, pavankv, saneryee, tsvetanovv
32.3616 USDC - $32.36
File CashManager.sol: 141, 144, 147, 150, 150
File KYCRegistryClient.sol: 40
File CashKYCSender.sol: 68
File CashKYCSenderReceiver.sol: 68, 76
File KYCRegistryClient.sol: 40
The code can be optimized by minimising the number of SLOADs. Storage value should get cached in memory if they occur more than once.
_epochDuration
instead of epochDuration
176
Recommended:(block.timestamp % _epochDuration);
epochToExchangeRate[epochToClaim]
in memory. If the check for equal to zero is false we can save 2 SLOAD. One in line 266 and another in 492. 249
Recommended:uint256 rate = epochToExchangeRate[epochToClaim]; if (rate == 0) { // line 249 revert ExchangeRateNotSet(); } emit MintCompleted( user, cashOwed, collateralDeposited, rate // line 266 epochToClaim ); function _getMintAmountForEpoch( uint256 collateralAmountIn, uint256 rate // line 489 ) private view returns (uint256 cashAmountOut) { uint256 amountE24 = _scaleUp(collateralAmountIn) * 1e6; cashAmountOut = amountE24 / rate; // line 492 }
currentEpoch
in memory. 678
Recommended:uint256 epoch = currentEpoch; redemptionInfoPerEpoch[epoch].addressToBurnAmt[ // line 678 msg.sender ] += amountCashToRedeem; redemptionInfoPerEpoch[epoch].totalBurned += amountCashToRedeem; // line 681 emit RedemptionRequested(msg.sender, amountCashToRedeem, epoch); // line 685
feeRecipient
in memory. 725
Recommended:address recipient = feeRecipient; collateral.safeTransferFrom(assetSender, recipient, fees); // line 725 emit RedemptionFeesCollected(recipient, fees, epochToService); // line 726
emit MinimumRedeemAmountSet(oldRedeemMin, newRedeemMinimum);
fTokenToUnderlyingPrice[fToken]
in memory
Recomended:uint256 underlyingPrice = fTokenToUnderlyingPrice[fToken]; if (underlyingPrice != 0) { // Line 64 return underlyingPrice; // Line 65 } else { address cTokenAddress = underlyingPrice; // Line 69
210 feesInCollateral
every time will be less than collateralAmountIn
.
296-300
626
645
722 refundedAmt
can be equal to redemptionInfoPerEpoch[epochToService].totalBurned
or less
723 In the comment above function we know that collateralAmountToDist
include total amount to distribute for redemptions and fees to accrue to Ondo. Based on the comment, the variable fees
will be less than collateralAmountToDist
. So we can add unchecked {} block because operands can not underflow. Also I will recomend to be added additional check collateralAmountToDist
> ``fees` as a require in the start of function. If this conditional is false the function should revert.
865
867
File CashManager.sol: 750, 786, 933, 961
File CashFactory.sol: 127
File CashKYCSenderFactory.sol: 137
File CashKYCSenderReceiverFactory.sol: 137
File OndoPriceOracleV2.sol: 293
File Cash.sol: 37
File CCashDelegate.sol: 31, 46
File CTokenDelegate.sol: 31, 46
File OndoPriceOracle.sol 121
File CashKYCSenderReceiver.sol: 64, 71, 79
File KYCRegistry.sol 89
File Cash.sol: 37
File CCashDelegate.sol: 32, 47 )
File CTokenDelegate.sol: 32, 47
File OndoPriceOracle.sol 122
File CashKYCSenderReceiver.sol: 65, 72, 80
File CashFactory.sol: 152
File KYCRegistry.sol 90
File CashKYCSender.sol: 47-48
File CashKYCSenderReceiver.sol: 47-48
#0 - c4-judge
2023-01-23T14:40:18Z
trust1995 marked the issue as grade-b