Platform: Code4rena
Start Date: 21/11/2022
Pot Size: $90,500 USDC
Total HM: 18
Participants: 101
Period: 7 days
Judge: Picodes
Total Solo HM: 4
Id: 183
League: ETH
Rank: 72/101
Findings: 1
Award: $53.49
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: 0xSmartContract
Also found by: 0xAgro, 0xNazgul, 0xPanda, 0xbepresent, 0xfuje, Awesome, B2, Bnke0x0, Deivitto, Diana, Funen, Jeiwan, JohnSmith, Josiah, R2, RaymondFam, Rolezn, Sathish9098, Waze, adriro, aphak5010, brgltd, btk, carrotsmuggler, ch0bu, chaduke, codeislight, codexploder, cryptostellar5, csanuragjain, danyams, datapunk, delfin454000, deliriusz, eierina, erictee, fatherOfBlocks, gz627, gzeon, hansfriese, hihen, jadezti, joestakey, keccak123, martin, nameruse, oyc_109, pedr02b2, perseverancesuccess, rbserver, rotcivegaf, rvierdiiev, sakshamguruji, shark, simon135, subtle77, unforgiven, xiaoming90, yixxas
53.4851 USDC - $53.49
2022-11-redactedcartel/src/PirexGmx.sol::225 => assert(feeAmount + postFeeAmount == assets);
address(0x0)
when assigning values to address
state variables2022-11-redactedcartel/src/PirexFees.sol::54 => treasury = _treasury; 2022-11-redactedcartel/src/PirexFees.sol::55 => contributors = _contributors; 2022-11-redactedcartel/src/PirexFees.sol::91 => treasuryFeePercent = _treasuryFeePercent; 2022-11-redactedcartel/src/PirexGmx.sol::196 => pirexRewards = _pirexRewards; 2022-11-redactedcartel/src/vaults/AutoPxGlp.sol::83 => platform = _platform; 2022-11-redactedcartel/src/vaults/AutoPxGlp.sol::84 => rewardsModule = _rewardsModule; 2022-11-redactedcartel/src/vaults/AutoPxGlp.sol::133 => platform = _platform; 2022-11-redactedcartel/src/vaults/AutoPxGmx.sol::92 => platform = _platform; 2022-11-redactedcartel/src/vaults/AutoPxGmx.sol::93 => rewardsModule = _rewardsModule; 2022-11-redactedcartel/src/vaults/AutoPxGmx.sol::107 => poolFee = _poolFee; 2022-11-redactedcartel/src/vaults/AutoPxGmx.sol::155 => platform = _platform; 2022-11-redactedcartel/src/vaults/PirexERC4626.sol::53 => asset = _asset;
initialize
functions can be front-runSee this finding from a prior badger-dao contest for details
2022-11-redactedcartel/src/PirexRewards.sol::85 => function initialize() public initializer {
safeApprove()
is deprecatedDeprecated in favor of safeIncreaseAllowance() and safeDecreaseAllowance()
2022-11-redactedcartel/src/PirexGmx.sol::292 => gmx.safeApprove(address(stakedGmx), type(uint256).max); 2022-11-redactedcartel/src/PirexGmx.sol::348 => gmx.safeApprove(address(stakedGmx), 0); 2022-11-redactedcartel/src/PirexGmx.sol::353 => gmx.safeApprove(contractAddress, type(uint256).max); 2022-11-redactedcartel/src/PirexGmx.sol::507 => t.safeApprove(glpManager, tokenAmount); 2022-11-redactedcartel/src/vaults/AutoPxGlp.sol::87 => gmxBaseReward.safeApprove(address(_platform), type(uint256).max); 2022-11-redactedcartel/src/vaults/AutoPxGlp.sol::347 => stakedGlp.safeApprove(platform, amount); 2022-11-redactedcartel/src/vaults/AutoPxGlp.sol::391 => erc20Token.safeApprove(platform, tokenAmount); 2022-11-redactedcartel/src/vaults/AutoPxGmx.sol::96 => gmxBaseReward.safeApprove(address(SWAP_ROUTER), type(uint256).max); 2022-11-redactedcartel/src/vaults/AutoPxGmx.sol::97 => gmx.safeApprove(_platform, type(uint256).max);
__gap[50]
storage variable to allow for new storage variables in later versionsSee this link for a description of this storage variable. While some contracts may not currently be sub-classed, adding the variable now protects against forgetting to add it in the future.
2022-11-redactedcartel/src/PirexRewards.sol::15 => contract PirexRewards is OwnableUpgradeable {
transfer()
/transferFrom()
not checkedNot all IERC20 implementations revert() when there’s a failure in transfer()/transferFrom(). The function signature has a boolean return value and they indicate errors that way instead. By not checking the return value, operations that should have been marked as failed may potentially go through without actually making a payment
2022-11-redactedcartel/src/PirexGmx.sol::436 => stakedGlp.transferFrom(msg.sender, address(this), amount);
2022-11-redactedcartel/src/vaults/PirexERC4626.sol::247 => return status; 2022-11-redactedcartel/src/vaults/PirexERC4626.sol::265 => return status;
2022-11-redactedcartel/src/PxGmx.sol::11 => PxERC20(_pirexRewards, "Pirex GMX", "pxGMX", 18) 2022-11-redactedcartel/src/vaults/AutoPxGlp.sol::18 => uint256 public constant MAX_WITHDRAWAL_PENALTY = 500; 2022-11-redactedcartel/src/vaults/AutoPxGlp.sol::20 => uint256 public constant FEE_DENOMINATOR = 10000; 2022-11-redactedcartel/src/vaults/AutoPxGlp.sol::21 => uint256 public constant MAX_COMPOUND_INCENTIVE = 5000; 2022-11-redactedcartel/src/vaults/AutoPxGmx.sol::20 => uint256 public constant MAX_WITHDRAWAL_PENALTY = 500; 2022-11-redactedcartel/src/vaults/AutoPxGmx.sol::22 => uint256 public constant FEE_DENOMINATOR = 10000; 2022-11-redactedcartel/src/vaults/AutoPxGmx.sol::23 => uint256 public constant MAX_COMPOUND_INCENTIVE = 5000;
indexed
fieldsEach event should use three indexed fields if there are three or more fields
2022-11-redactedcartel/src/PirexFees.sol::34 => event SetFeeRecipient(FeeRecipient f, address recipient); 2022-11-redactedcartel/src/PirexGmx.sol::142 => event SetDelegationSpace(string delegationSpace, bool shouldClear); 2022-11-redactedcartel/src/vaults/PxGmxReward.sol::21 => event GlobalAccrue(uint256 lastUpdate, uint256 lastSupply, uint256 rewards);
2022-11-redactedcartel/src/Common.sol::1 => // SPDX-License-Identifier: MIT 2022-11-redactedcartel/src/PirexFees.sol::1 => // SPDX-License-Identifier: MIT 2022-11-redactedcartel/src/PirexGmx.sol::1 => // SPDX-License-Identifier: MIT 2022-11-redactedcartel/src/PirexRewards.sol::1 => // SPDX-License-Identifier: MIT 2022-11-redactedcartel/src/PxERC20.sol::1 => // SPDX-License-Identifier: MIT 2022-11-redactedcartel/src/PxGmx.sol::1 => // SPDX-License-Identifier: MIT 2022-11-redactedcartel/src/interfaces/IAutoPxGlp.sol::1 => // SPDX-License-Identifier: MIT 2022-11-redactedcartel/src/interfaces/IPirexRewards.sol::1 => // SPDX-License-Identifier: MIT 2022-11-redactedcartel/src/interfaces/IProducer.sol::1 => // SPDX-License-Identifier: MIT 2022-11-redactedcartel/src/vaults/AutoPxGlp.sol::1 => // SPDX-License-Identifier: MIT 2022-11-redactedcartel/src/vaults/AutoPxGmx.sol::1 => // SPDX-License-Identifier: MIT 2022-11-redactedcartel/src/vaults/PxGmxReward.sol::1 => // SPDX-License-Identifier: MIT
public
functions not called by the contract should be declared external
insteadContracts are allowed to override their parents’ functions and change the visibility from public to external .
2022-11-redactedcartel/src/PirexGmx.sol::895 => function clearVoteDelegate() public onlyOwner { 2022-11-redactedcartel/src/PirexRewards.sol::85 => function initialize() public initializer { 2022-11-redactedcartel/src/PirexRewards.sol::281 => function userAccrue(ERC20 producerToken, address user) public { 2022-11-redactedcartel/src/PxERC20.sol::113 => ) public override returns (bool) { 2022-11-redactedcartel/src/vaults/AutoPxGlp.sol::142 => function totalAssets() public view override returns (uint256) { 2022-11-redactedcartel/src/vaults/AutoPxGlp.sol::440 => ) public override returns (uint256 shares) { 2022-11-redactedcartel/src/vaults/AutoPxGlp.sol::453 => ) public override returns (uint256 assets) { 2022-11-redactedcartel/src/vaults/AutoPxGmx.sol::164 => function totalAssets() public view override returns (uint256) { 2022-11-redactedcartel/src/vaults/AutoPxGmx.sol::319 => ) public override returns (uint256 shares) { 2022-11-redactedcartel/src/vaults/AutoPxGmx.sol::343 => ) public override returns (uint256 assets) { 2022-11-redactedcartel/src/vaults/PirexERC4626.sol::103 => ) public virtual returns (uint256 shares) { 2022-11-redactedcartel/src/vaults/PirexERC4626.sol::128 => ) public virtual returns (uint256 assets) { 2022-11-redactedcartel/src/vaults/PirexERC4626.sol::154 => function totalAssets() public view virtual returns (uint256); 2022-11-redactedcartel/src/vaults/PirexERC4626.sol::187 => function previewMint(uint256 shares) public view virtual returns (uint256) { 2022-11-redactedcartel/src/vaults/PirexERC4626.sol::217 => function maxDeposit(address) public view virtual returns (uint256) { 2022-11-redactedcartel/src/vaults/PirexERC4626.sol::221 => function maxMint(address) public view virtual returns (uint256) { 2022-11-redactedcartel/src/vaults/PirexERC4626.sol::225 => function maxWithdraw(address owner) public view virtual returns (uint256) { 2022-11-redactedcartel/src/vaults/PirexERC4626.sol::229 => function maxRedeem(address owner) public view virtual returns (uint256) { 2022-11-redactedcartel/src/vaults/PirexERC4626.sol::260 => ) public override returns (bool) {
There are units for seconds, minutes, hours, days, and weeks
2022-11-redactedcartel/src/PirexRewards.sol::312 => // Calculate rewards, the product of seconds elapsed and last supply 2022-11-redactedcartel/src/vaults/PxGmxReward.sol::52 => // Calculate rewards, the product of seconds elapsed and last supply
#0 - c4-judge
2022-12-05T10:08:23Z
Picodes marked the issue as grade-b