Platform: Code4rena
Start Date: 18/05/2023
Pot Size: $24,500 USDC
Total HM: 3
Participants: 72
Period: 4 days
Judge: LSDan
Id: 237
League: ETH
Rank: 22/72
Findings: 2
Award: $44.17
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: ABA
Also found by: 0x4non, 0xHati, 0xMosh, 0xSmartContract, 0xWaitress, 0xhacksmithh, 0xnev, 0xprinc, Arabadzhiev, BLACK-PANDA-REACH, Deekshith99, Dimagu, KKat7531, Kose, LosPollosHermanos, MohammedRizwan, QiuhaoLi, RaymondFam, Rickard, Rolezn, SAAJ, Sathish9098, Shubham, SmartGooofy, Tripathi, Udsen, V1235816, adriro, arpit, ayden, bigtone, codeVolcan, d3e4, dwward3n, fatherOfBlocks, favelanky, jovemjeune, kutugu, lfzkoala, lukris02, matrix_0wl, minhquanym, ni8mare, parsely, pxng0lin, radev_sw, ravikiranweb3, rbserver, sces60107, souilos, tnevler, turvy_fuzz, yellowBirdy
16.1907 USDC - $16.19
We should check projectToken, pool, and jbxTerminal are not zeros for sanity.
Even further, we can call relative read functions like totalSupply()>0
for _weth
and supportsInterface
for _jbxTerminal
.
JBXBuybackDelegate inherits openzepplin's Ownable module, but there are no onlyOwner modifiers in the code. We should remove this module.
#0 - c4-judge
2023-06-02T11:02:28Z
dmvt marked the issue as grade-b
27.9811 USDC - $27.98
_nonReservedTokenInContract
is calculated as:
// 3) Burn the non-reserve token which are now left in this address (can be 0) -> result: 0 here, reservedToken in reserve uint256 _nonReservedTokenInContract = _amountReceived - _reservedToken;
Which is exactly _nonReservedToken
:
// The amount to add to the reserved token uint256 _reservedToken = _amountReceived - _nonReservedToken; // Send the non-reserved token to the beneficiary (if any / reserved rate is not max) if (_nonReservedToken != 0) projectToken.transfer(_data.beneficiary, _nonReservedToken);
Use _nonReservedToken can save like ~100 gas: didpay
Before:
| contracts/JBXBuybackDelegate.sol:JBXBuybackDelegate contract | | | | | | |--------------------------------------------------------------|-----------------|--------|--------|--------|---------| | Deployment Cost | Deployment Size | | | | | | 1310928 | 6825 | | | | | | Function Name | min | avg | median | max | # calls | | didPay | 54376 | 163964 | 148968 | 244808 | 7 |
Afer:
| contracts/JBXBuybackDelegate.sol:JBXBuybackDelegate contract | | | | | | |--------------------------------------------------------------|-----------------|--------|--------|--------|---------| | Deployment Cost | Deployment Size | | | | | | 1307928 | 6810 | | | | | | Function Name | min | avg | median | max | # calls | | didPay | 54308 | 163925 | 148900 | 244740 | 7 |
#0 - c4-judge
2023-06-02T10:53:22Z
dmvt marked the issue as grade-b