function
stringlengths
12
63.3k
severity
stringclasses
4 values
```\nif (safe.getThreshold() != _getCorrectThreshold()) {\n revert SignersCannotChangeThreshold();\n}\n\nfunction _getCorrectThreshold() internal view returns (uint256 _threshold) {\n uint256 count = _countValidSigners(safe.getOwners());\n uint256 min = minThreshold;\n uint256 max = targetThreshold;\n if (count < min) _threshold = min;\n else if (count > max) _threshold = max;\n else _threshold = count;\n}\n```\n
high
```\nfunction _estimateWithdrawalLp(\n uint256 reserve0,\n uint256 reserve1,\n uint256 _totalSupply,\n uint256 amount0,\n uint256 amount1\n) private pure returns (uint256 shareAmount) {\n shareAmount =\n ((amount0 * _totalSupply) / reserve0 + (amount1 * _totalSupply) / reserve1) /\n 2;\n}\n```\n
high
```\nfunction _validateAccountAndPaymasterValidationData(uint256 opIndex, uint256 validationData, uint256 paymasterValidationData, address expectedAggregator) internal view {\n (address aggregator, bool outOfTimeRange) = _getValidationData(validationData);\n if (expectedAggregator != aggregator) {\n revert FailedOp(opIndex, "AA24 signature error");\n }\n if (outOfTimeRange) {\n revert FailedOp(opIndex, "AA22 expired or not due");\n }\n //pmAggregator is not a real signature aggregator: we don't have logic to handle it as address.\n // non-zero address means that the paymaster fails due to some signature check (which is ok only during estimation)\n address pmAggregator;\n (pmAggregator, outOfTimeRange) = _getValidationData(paymasterValidationData);\n if (pmAggregator != address(0)) {\n revert FailedOp(opIndex, "AA34 signature error");\n }\n if (outOfTimeRange) {\n revert FailedOp(opIndex, "AA32 paymaster expired or not due");\n }\n}\n```\n
none
```\n function JOJOFlashLoan(\n address asset,\n uint256 amount,\n address to,\n bytes calldata param\n ) external {\n (address approveTarget, address swapTarget, uint256 minReceive, bytes memory data) = abi\n .decode(param, (address, address, uint256, bytes));\n IERC20(asset).approve(approveTarget, amount);\n (bool success, ) = swapTarget.call(data);\n if (success == false) {\n assembly {\n let ptr := mload(0x40)\n let size := returndatasize()\n returndatacopy(ptr, 0, size)\n revert(ptr, size)\n }\n }\n uint256 USDCAmount = IERC20(USDC).balanceOf(address(this));\n require(USDCAmount >= minReceive, "receive amount is too small");\n// rest of code\n function repayJUSD(\n address asset,\n uint256 amount,\n address to,\n bytes memory param\n ) external {\n IERC20(asset).safeTransferFrom(msg.sender, address(this), amount);\n uint256 minReceive;\n if (asset != USDC) {\n (address approveTarget, address swapTarget, uint256 minAmount, bytes memory data) = abi\n .decode(param, (address, address, uint256, bytes));\n IERC20(asset).approve(approveTarget, amount);\n (bool success, ) = swapTarget.call(data);\n if (success == false) {\n assembly {\n let ptr := mload(0x40)\n let size := returndatasize()\n returndatacopy(ptr, 0, size)\n revert(ptr, size)\n }\n }\n minReceive = minAmount;\n }\n\n uint256 USDCAmount = IERC20(USDC).balanceOf(address(this));\n require(USDCAmount >= minReceive, "receive amount is too small");\n```\n
medium
```\nuint256 oldShare = pos.debtShareOf[debtToken];\n(uint256 amountPaid, uint256 share) = repayInternal(\n positionId,\n debtToken,\n amountCall\n);\n\nuint256 liqSize = (pos.collateralSize * share) / oldShare;\nuint256 uTokenSize = (pos.underlyingAmount * share) / oldShare;\nuint256 uVaultShare = (pos.underlyingVaultShare * share) / oldShare;\n\npos.collateralSize -= liqSize;\npos.underlyingAmount -= uTokenSize;\npos.underlyingVaultShare -= uVaultShare;\n\n// // rest of codetransfer liqSize wrapped LP Tokens and uVaultShare underlying vault shares to the liquidator\n}\n```\n
high
```\n return \n (votes * cpMultipliers.votes / PERCENT) + \n (proposalsCreated * cpMultipliers.proposalsCreated / PERCENT) + \n (proposalsPassed * cpMultipliers.proposalsPassed / PERCENT);\n```\n
medium
```\nfunction flashRebalance(\n DestinationInfo storage destInfoOut,\n DestinationInfo storage destInfoIn,\n IERC3156FlashBorrower receiver,\n IStrategy.RebalanceParams memory params,\n FlashRebalanceParams memory flashParams,\n bytes calldata data\n) external returns (uint256 idle, uint256 debt) {\n // rest of code\n\n // Handle increase (shares coming "In", getting underlying from the swapper and trading for new shares)\n if (params.amountIn > 0) {\n IDestinationVault dvIn = IDestinationVault(params.destinationIn);\n\n // get "before" counts\n uint256 tokenInBalanceBefore = IERC20(params.tokenIn).balanceOf(address(this));\n\n // Give control back to the solver so they can make use of the "out" assets\n // and get our "in" asset\n bytes32 flashResult = receiver.onFlashLoan(msg.sender, params.tokenIn, params.amountIn, 0, data);\n\n // We assume the solver will send us the assets\n uint256 tokenInBalanceAfter = IERC20(params.tokenIn).balanceOf(address(this));\n\n // Make sure the call was successful and verify we have at least the assets we think\n // we were getting\n if (\n flashResult != keccak256("ERC3156FlashBorrower.onFlashLoan")\n || tokenInBalanceAfter < tokenInBalanceBefore + params.amountIn\n ) {\n revert Errors.FlashLoanFailed(params.tokenIn, params.amountIn);\n }\n\n if (params.tokenIn != address(flashParams.baseAsset)) {\n // @audit should be `tokenInBalanceAfter - tokenInBalanceBefore` given to `_handleRebalanceIn`\n (uint256 debtDecreaseIn, uint256 debtIncreaseIn) =\n _handleRebalanceIn(destInfoIn, dvIn, params.tokenIn, tokenInBalanceAfter);\n idleDebtChange.debtDecrease += debtDecreaseIn;\n idleDebtChange.debtIncrease += debtIncreaseIn;\n } else {\n idleDebtChange.idleIncrease += tokenInBalanceAfter - tokenInBalanceBefore;\n }\n }\n // rest of code\n}\n```\n
medium
```\nfunction sub(uint256 a, uint256 b) internal pure returns (uint256) {\n return a - b;\n}\n```\n
none
```\n// rest of code\n if (token == address(measure) && from != address(0)) { //add && from != to\n drip();\n// rest of code\n```\n
low
```\nfunction updatedevelopmentWallet(address newWallet) external onlyOwner {\n emit developmentWalletUpdated(newWallet, developmentWallet);\n developmentWallet = newWallet;\n}\n```\n
none
```\nfunction functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, "Address: low-level static call failed");\n}\n```\n
none
```\n if (balance >= borrows) {\n collateral += min(balance - borrows, info.maxCollateralAmount).mul(info.collateralWeight).mul(price);\n } else {\n debt += (borrows - balance).mul(info.debtWeight).mul(price);\n }\n```\n
medium
```\nrequire(\n currentAllowance >= subtractedValue,\n "Silo: decreased allowance below zero"\n);\n```\n
low
```\nfunction incentivize(\n address sender,\n address receiver, \n address operator,\n uint amountIn\n) external override onlyFei {\n updateOracle();\n\n if (isPair(sender)) {\n incentivizeBuy(receiver, amountIn);\n }\n\n if (isPair(receiver)) {\n require(isSellAllowlisted(sender) || isSellAllowlisted(operator), "UniswapIncentive: Blocked Fei sender or operator");\n incentivizeSell(sender, amountIn);\n }\n}\n```\n
high
```\nfunction getPayoutToken() public view returns (address) {\n return dividendTracker.getPayoutToken();\n}\n```\n
none
```\n function _extractTokens(address _from, address _token, uint256 _amount) internal returns (uint256) {\n uint256 balanceBefore = IERC20(_token).balanceOf(address(this));\n // IERC20(_token).safeTransferFrom(_from, address(this), _amount);\n pearlmit.transferFromERC20(_from, address(this), address(_token), _amount);\n uint256 balanceAfter = IERC20(_token).balanceOf(address(this));\n if (balanceAfter <= balanceBefore) revert Magnetar_ExtractTokenFail();\n return balanceAfter - balanceBefore;\n }\n```\n
medium
```\nfunction safeApprove(address \_token, address \_spender, uint256 \_value) public onlyOwner {\n\n (bool success, bytes memory returndata) = \_token.call(abi.encodeWithSignature("approve(address,uint256)", \_spender, \_value));\n\n require(success, "SafeERC20: low-level call failed");\n\n}\n```\n
high
```\nfunction safeTransferFrom(\n IERC20 token,\n address from,\n address to,\n uint256 value\n) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n}\n```\n
none
```\n{\n // 2. Swap rewards tokens to debt token\n uint256 rewards = _doCutRewardsFee(CRV);\n _ensureApprove(CRV, address(swapRouter), rewards);\n swapRouter.swapExactTokensForTokens(\n rewards,\n 0,\n swapPath,\n address(this),\n type(uint256).max\n );\n}\n```\n
high
```\n /// @notice Roll into the next Series if there isn't an active series and the cooldown period has elapsed.\n function roll() external {\n if (maturity != MATURITY_NOT_SET) revert RollWindowNotOpen();\n\n if (lastSettle == 0) {\n // If this is the first roll, lock some shares in by minting them for the zero address.\n // This prevents the contract from reaching an empty state during future active periods.\n deposit(firstDeposit, address(0));\n } else if (lastSettle + cooldown > block.timestamp) {\n revert RollWindowNotOpen();\n }\n\n lastRoller = msg.sender;\n adapter.openSponsorWindow();\n }\n```\n
medium
```\n function _depositAsset(uint256 amount) private {\n netAssetDeposits += amount;\n\n\n IERC20(assetToken).approve(address(vault), amount);\n vault.deposit(assetToken, amount);\n }\n```\n
medium
```\nfunction \_beforeTokenTransfer(address from, address to, uint256 amount) internal override {\n uint256 balanceFrom = (from != address(0)) ? balanceOf(from) : 0;\n uint256 balanceTo = (from != address(0)) ? balanceOf(to) : 0;\n uint256 newTotalSupply = totalSupply()\n .add(from == address(0) ? amount : 0)\n .sub(to == address(0) ? amount : 0);\n\n ParamsHelper memory params = ParamsHelper({\n from: from,\n to: to,\n amount: amount,\n balanceFrom: balanceFrom,\n balanceTo: balanceTo,\n newTotalSupply: newTotalSupply\n });\n\n \_updateOnTransfer(params, mooniswapFactoryGovernance.defaultFee, \_emitFeeVoteUpdate, \_fee);\n \_updateOnTransfer(params, mooniswapFactoryGovernance.defaultSlippageFee, \_emitSlippageFeeVoteUpdate, \_slippageFee);\n \_updateOnTransfer(params, mooniswapFactoryGovernance.defaultDecayPeriod, \_emitDecayPeriodVoteUpdate, \_decayPeriod);\n}\n```\n
medium
```\nFile: D3Trading.sol\n roState.toTokenMMInfo.cumulativeBid =\n allFlag (toTokenIndex) & 1 == 0 ? 0 : tokenCumMap[toToken].cumulativeAsk;\n```\n
medium
```\n function _payment(\n uint256 collateralId,\n uint8 position,\n uint256 paymentAmount,\n address payer\n ) internal returns (uint256) {\n if (paymentAmount == uint256(0)) {\n return uint256(0);\n }\n\n\n uint256 lienId = liens[collateralId][position];\n Lien storage lien = lienData[lienId];\n uint256 end = (lien.start + lien.duration);\n require(\n block.timestamp < end || address(msg.sender) == address(AUCTION_HOUSE),\n "cannot pay off an expired lien"\n );\n\n\n address lienOwner = ownerOf(lienId);\n bool isPublicVault = IPublicVault(lienOwner).supportsInterface(\n type(IPublicVault).interfaceId\n );\n\n\n lien.amount = _getOwed(lien);\n\n\n address payee = getPayee(lienId);\n if (isPublicVault) {\n IPublicVault(lienOwner).beforePayment(lienId, paymentAmount);\n }\n if (lien.amount > paymentAmount) {\n lien.amount -= paymentAmount;\n lien.last = block.timestamp.safeCastTo32();\n // slope does not need to be updated if paying off the rest, since we neutralize slope in beforePayment()\n if (isPublicVault) {\n IPublicVault(lienOwner).afterPayment(lienId);\n }\n } else {\n if (isPublicVault && !AUCTION_HOUSE.auctionExists(collateralId)) {\n // since the openLiens count is only positive when there are liens that haven't been paid off\n // that should be liquidated, this lien should not be counted anymore\n IPublicVault(lienOwner).decreaseEpochLienCount(\n IPublicVault(lienOwner).getLienEpoch(end)\n );\n }\n //delete liens\n _deleteLienPosition(collateralId, position);\n delete lienData[lienId]; //full delete\n\n\n _burn(lienId);\n }\n\n\n TRANSFER_PROXY.tokenTransferFrom(WETH, payer, payee, paymentAmount);\n\n\n emit Payment(lienId, paymentAmount);\n return paymentAmount;\n }\n```\n
medium
```\nfunction beneficiaryWithdrawable(\n address recipient,\n address sender,\n uint256 agentID,\n uint256 proposedAmount\n) external returns (\n uint256 amount\n) {\n AgentBeneficiary memory beneficiary = \_agentBeneficiaries[agentID];\n address benneficiaryAddress = beneficiary.active.beneficiary;\n // If the sender is not the owner of the Agent or the beneficiary, revert\n if(\n !(benneficiaryAddress == sender || (IAuth(msg.sender).owner() == sender && recipient == benneficiaryAddress) )) {\n revert Unauthorized();\n }\n (\n beneficiary,\n amount\n ) = beneficiary.withdraw(proposedAmount);\n // update the beneficiary in storage\n \_agentBeneficiaries[agentID] = beneficiary;\n}\n```\n
high
```\nfunction _distributeERC20(\n address split,\n ERC20 token,\n address[] memory accounts,\n uint32[] memory percentAllocations,\n uint32 distributorFee,\n address distributorAddress\n) internal {\n uint256 amountToSplit;\n uint256 mainBalance = erc20Balances[token][split];\n uint256 proxyBalance = token.balanceOf(split);\n unchecked {\n // if mainBalance &/ proxyBalance are positive, leave 1 for gas efficiency\n // underflow should be impossible\n if (proxyBalance > 0) proxyBalance -= 1;\n // underflow should be impossible\n if (mainBalance > 0) {\n mainBalance -= 1;\n }\n // overflow should be impossible\n amountToSplit = mainBalance + proxyBalance;\n }\n if (mainBalance > 0) erc20Balances[token][split] = 1;\n // emit event with gross amountToSplit (before deducting distributorFee)\n emit DistributeERC20(split, token, amountToSplit, distributorAddress);\n if (distributorFee != 0) {\n // given `amountToSplit`, calculate keeper fee\n uint256 distributorFeeAmount = _scaleAmountByPercentage(\n amountToSplit,\n distributorFee\n );\n // overflow should be impossible with validated distributorFee\n unchecked {\n // credit keeper with fee\n erc20Balances[token][\n distributorAddress != address(0) ? distributorAddress : msg.sender\n ] += distributorFeeAmount;\n // given keeper fee, calculate how much to distribute to split recipients\n amountToSplit -= distributorFeeAmount;\n }\n }\n // distribute remaining balance\n // overflows should be impossible in for-loop with validated allocations\n unchecked {\n // cache accounts length to save gas\n uint256 accountsLength = accounts.length;\n for (uint256 i = 0; i < accountsLength; ++i) {\n erc20Balances[token][accounts[i]] += _scaleAmountByPercentage(\n amountToSplit,\n percentAllocations[i]\n );\n }\n }\n // split proxy should be guaranteed to exist at this address after validating splitHash\n // (attacker can't deploy own contract to address with high ERC20 balance & empty\n // sendERC20ToMain to drain ERC20 from SplitMain)\n // doesn't support rebasing or fee-on-transfer tokens\n // flush extra proxy ERC20 balance to SplitMain\n if (proxyBalance > 0)\n SplitWallet(split).sendERC20ToMain(token, proxyBalance);\n}\n```\n
none
```\n require(\_dripRatePerSecond > 0, "TokenFaucet/dripRate-gt-zero");\n asset = \_asset;\n measure = \_measure;\n setDripRatePerSecond(\_dripRatePerSecond);\n```\n
low
```\n /// @notice Minimum voting period\n uint32 public constant MIN_VOTING_PERIOD = 5760; // About 24 hours\n\n /// @notice Maximum voting period\n uint32 public constant MAX_VOTING_PERIOD = 80640; // About 2 weeks\n\n /// @notice Minimum voting delay\n uint32 public constant MIN_VOTING_DELAY = 1;\n\n /// @notice Maximum voting delay\n uint32 public constant MAX_VOTING_DELAY = 40320; // About 1 week\n```\n
medium
```\nIPeUSD public EUSD;\n```\n
low
```\n function priceFromAddress(address tokenAddress) public view returns(uint256) {\n if(Utils.\_isETH(address(globalConfig), tokenAddress)) {\n return 1e18;\n }\n return uint256(globalConfig.chainLink().getLatestAnswer(tokenAddress));\n }\n```\n
high
```\nfunction updatePixelMintMerkleRoot(bytes32 hash)\n external\n onlyOwner\n returns (bool)\n{\n merkleRootOfPixelMintWhitelistAddresses = hash;\n emit UpdatedMerkleRootOfPixelMint(hash, msg.sender);\n\n return true;\n}\n```\n
none
```\nfunction updateSwapTokensAtAmount(uint256 newAmount)\n external\n onlyOwner\n returns (bool)\n{\n require(\n newAmount >= (totalSupply() * 1) / 100000,\n "Swap amount cannot be lower than 0.001% total supply."\n );\n require(\n newAmount <= (totalSupply() * 5) / 1000,\n "Swap amount cannot be higher than 0.5% total supply."\n );\n swapTokensAtAmount = newAmount;\n return true;\n}\n```\n
none
```\nfunction tokenFromReflection(uint256 rAmount) public view returns(uint256) {\n require(rAmount <= _rTotal, "Amount must be less than total reflections");\n uint256 currentRate = _getRate();\n return rAmount / currentRate;\n}\n```\n
none
```\n/// @notice Implements bitcoin's hash256 (double sha2)\n/// @dev abi.encodePacked changes the return to bytes instead of bytes32\n/// @param \_b The pre-image\n/// @return The digest\nfunction hash256(bytes memory \_b) internal pure returns (bytes32) {\n return abi.encodePacked(sha256(abi.encodePacked(sha256(\_b)))).toBytes32();\n}\n```\n
low
```\nresult := mload(memPtr)\n```\n
high
```\nuint totalGenesisTribe = tribeBalance() - totalCommittedTribe;\n```\n
medium
```\nFile: TellerV2.sol\n 854 function calculateNextDueDate(uint256 _bidId)\n 855 public\n 856 view\n 857 returns (uint32 dueDate_)\n 858 {\n 859 Bid storage bid = bids[_bidId];\n 860 if (bids[_bidId].state != BidState.ACCEPTED) return dueDate_;\n 861\n 862 uint32 lastRepaidTimestamp = lastRepaidTimestamp(_bidId);\n 863\n 864 // Calculate due date if payment cycle is set to monthly\n 865 if (bidPaymentCycleType[_bidId] == PaymentCycleType.Monthly) {\n 866 // Calculate the cycle number the last repayment was made\n 867 uint256 lastPaymentCycle = BPBDTL.diffMonths(\n 868 bid.loanDetails.acceptedTimestamp,\n 869 \n```\n
medium
```\n if (inversed && balance < amountDesired) {\n // collat = 0\n uint256 transferAmount = amountDesired - balance;\n uint256 parentPoolBalance = \n ILiquidityPool(parentLiquidityPool).getBalance(address(token0));\n if (parentPoolBalance < transferAmount) { revert \n CustomErrors.WithdrawExceedsLiquidity(); \n }\n SafeTransferLib.safeTransferFrom(address(token0), msg.sender, \n address(this), transferAmount);\n } \n```\n
high
```\nfor (uint i = 0; i < contractKeys.length; i++) {\n // Delete the key from the array + mapping if it is present\n if (contractKeys[i] == name) {\n delete registry[contractKeys[i]];\n contractKeys[i] = contractKeys[contractKeys.length - 1];\n delete contractKeys[contractKeys.length - 1];\n contractKeys.length--;\n```\n
low
```\nfunction functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n}\n```\n
none
```\nfunction setCustomContract(\n address \_nativeToken,\n address \_targetContract\n) external onlyOwner isNewToken(\_nativeToken) {\n nativeToBridgedToken[\_nativeToken] = \_targetContract;\n bridgedToNativeToken[\_targetContract] = \_nativeToken;\n emit CustomContractSet(\_nativeToken, \_targetContract);\n}\n```\n
high
```\nfunction sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, "Address: insufficient balance");\n\n (bool success, ) = recipient.call{value: amount}("");\n require(success, "Address: unable to send value, recipient may have reverted");\n}\n```\n
none
```\nfunction _addTokenToOwnerEnumeration(address to, uint256 tokenId) private {\n uint256 length = ERC721.balanceOf(to);\n _ownedTokens[to][length] = tokenId;\n _ownedTokensIndex[tokenId] = length;\n}\n```\n
none
```\n // Transfer token to Aura protocol for boosted staking\n stakingContext.auraBooster.deposit(stakingContext.auraPoolId, bptMinted, true); // stake = true\n```\n
medium
```\nfunction setTheMaxWallet(uint256 newNum) external onlyOwner {\n require(newNum >= 5, "Cannot set maxWallet lower than 0.5%");\n maxWallet = (newNum * totalSupply()) / 1000;\n emit MaxWalletUpdated(maxWallet);\n}\n```\n
none
```\nrolloverQueue[index].assets = _assets;\n```\n
high
```\nfunction add(uint256 a, uint256 b) internal pure returns (uint256) {\n return a + b;\n}\n```\n
none
```\nfunction allowance(address owner, address spender) public view override returns (uint256) {\n return _allowances[owner][spender];\n}\n```\n
none
```\nreceive() external payable {}\n```\n
none
```\nfunction cancelVesting(uint256 categoryId, uint256 vestingId, address user, bool giveUnclaimed)\n external\n onlyOwner\n{\n UserVesting memory userVesting = userVestings[categoryId][vestingId][user];\n\n if (userVesting.amount == 0) {\n revert UserVestingDoesNotExists(categoryId, vestingId, user);\n }\n\n if (userVesting.startTime + vestingInfos[categoryId][vestingId].period <= block.timestamp) {\n revert AlreadyVested(categoryId, vestingId, user);\n }\n\n uint256 lockupId = lockupIds[categoryId][vestingId][user];\n\n if (lockupId != 0) {\n veTRUF.unstakeVesting(user, lockupId - 1, true);\n delete lockupIds[categoryId][vestingId][user];\n userVesting.locked = 0;\n }\n\n VestingCategory storage category = categories[categoryId];\n\n uint256 claimableAmount = claimable(categoryId, vestingId, user);\n if (giveUnclaimed && claimableAmount != 0) {\n trufToken.safeTransfer(user, claimableAmount);\n\n userVesting.claimed += claimableAmount;\n category.totalClaimed += claimableAmount;\n emit Claimed(categoryId, vestingId, user, claimableAmount);\n }\n\n uint256 unvested = userVesting.amount - userVesting.claimed;\n\n delete userVestings[categoryId][vestingId][user];\n\n category.allocated -= unvested;\n\n emit CancelVesting(categoryId, vestingId, user, giveUnclaimed);\n}\n```\n
high
```\n function repay (uint256 loanID, uint256 repaid) external {\n Loan storage loan = loans[loanID];\n// rest of code\n debt.transferFrom(msg.sender, loan.lender, repaid); //***<------- lender in debt token's blocklist will revert , example :debt = usdc\n collateral.transfer(owner, decollateralized);\n }\n```\n
high
```\n function fulfillDomainBid(\n uint256 parentId,\n uint256 bidAmount,\n uint256 royaltyAmount,\n string memory bidIPFSHash,\n string memory name,\n string memory metadata,\n bytes memory signature,\n bool lockOnCreation,\n address recipient\n) external {\n bytes32 recoveredBidHash = createBid(parentId, bidAmount, bidIPFSHash, name);\n address recoveredBidder = recover(recoveredBidHash, signature);\n require(recipient == recoveredBidder, "ZNS: bid info doesnt match/exist");\n bytes32 hashOfSig = keccak256(abi.encode(signature));\n require(approvedBids[hashOfSig] == true, "ZNS: has been fullfilled");\n infinity.safeTransferFrom(recoveredBidder, controller, bidAmount);\n uint256 id = registrar.registerDomain(parentId, name, controller, recoveredBidder);\n registrar.setDomainMetadataUri(id, metadata);\n registrar.setDomainRoyaltyAmount(id, royaltyAmount);\n registrar.transferFrom(controller, recoveredBidder, id);\n if (lockOnCreation) {\n registrar.lockDomainMetadataForOwner(id);\n }\n approvedBids[hashOfSig] = false;\n emit DomainBidFulfilled(\n metadata,\n name,\n recoveredBidder,\n id,\n parentId\n );\n}\n```\n
medium
```\nbool[6] flags; // [sponsored, processed, didPass, cancelled, whitelist, guildkick]\n```\n
low
```\nfunction feed(uint256 intoReserves, uint256 intoGrandPrize)\n external\n payable\n onlyOwner\n{\n require(\n msg.value > 0 && intoReserves.add(intoGrandPrize) == msg.value,\n "DCBW721: Balance-Value Mismatch"\n );\n _updateGrandPrizePool(_grandPrizePool.add(intoGrandPrize));\n _updateReserves(_reserves.add(intoReserves));\n}\n```\n
none
```\n function burnNFT(uint256 tokenId) internal {\n //@dev No need to check downcast tokenId because it is handled in function that calls burnNFT\n AppStorage storage s = appStorage();\n STypes.NFT storage nft = s.nftMapping[tokenId];\n if (nft.owner == address(0)) revert Errors.NotMinted();\n address asset = s.assetMapping[nft.assetId];\n STypes.ShortRecord storage short =\n s.shortRecords[asset][nft.owner][nft.shortRecordId];\n delete s.nftMapping[tokenId];\n delete s.getApproved[tokenId];\n delete short.tokenId;\n emit Events.Transfer(nft.owner, address(0), tokenId);\n }\n```\n
low
```\nfunction max(uint256 x, uint256 y) internal pure returns (uint256) {\n return x >= y ? x : y;\n}\n```\n
high
```\nconstructor(address \_depositFactory)\n ERC721Metadata("tBTC Deopsit Token", "TDT")\n DepositFactoryAuthority(\_depositFactory)\npublic {\n // solium-disable-previous-line no-empty-blocks\n}\n```\n
low
```\n function _onlyCalmPeriods() private view {\n int24 tick = currentTick();\n int56 twapTick = twap();\n\n if(\n twapTick - maxTickDeviationNegative > tick ||\n twapTick + maxTickDeviationPositive < tick) revert NotCalm();\n }\n```\n
low
```\nif (newURl != keccak256(bytes(node.url))) {\n\n // deleting the old entry\n delete urlIndex[keccak256(bytes(node.url))];\n\n // make sure the new url is not already in use\n require(!urlIndex[newURl].used, "url is already in use");\n\n UrlInformation memory ui;\n ui.used = true;\n ui.signer = msg.sender;\n urlIndex[newURl] = ui;\n node.url = \_url;\n}\n```\n
medium
```\n function _rebalanceNegativePnlWithSwap(\n uint256 amount,\n uint256 amountOutMinimum,\n uint160 sqrtPriceLimitX96,\n uint24 swapPoolFee,\n address account\n ) private returns (uint256, uint256) {\n uint256 normalizedAmount = amount.fromDecimalToDecimal(\n ERC20(quoteToken).decimals(),\n 18\n );\n _checkNegativePnl(normalizedAmount);\n bool isShort = false;\n bool amountIsInput = true;\n (uint256 baseAmount, uint256 quoteAmount) = _placePerpOrder(\n normalizedAmount,\n isShort,\n amountIsInput,\n sqrtPriceLimitX96\n );\n vault.withdraw(assetToken, baseAmount);\n SwapParams memory params = SwapParams({\n tokenIn: assetToken,\n tokenOut: quoteToken,\n amountIn: baseAmount,\n amountOutMinimum: amountOutMinimum,\n sqrtPriceLimitX96: sqrtPriceLimitX96, //@audit \n poolFee: swapPoolFee\n });\n uint256 quoteAmountOut = spotSwapper.swapExactInput(params);\n```\n
medium
```\n function _loadContext(\n Registration memory registration\n ) private view returns (MarketStrategyContext memory marketContext) {\n// rest of code\n // current position\n Order memory pendingGlobal = registration.market.pendings(address(this));\n marketContext.currentPosition = registration.market.position();\n marketContext.currentPosition.update(pendingGlobal);\n marketContext.minPosition = marketContext.currentAccountPosition.maker\n .unsafeSub(marketContext.currentPosition.maker\n .unsafeSub(marketContext.currentPosition.skew().abs()).min(marketContext.closable));\n marketContext.maxPosition = marketContext.currentAccountPosition.maker\n .add(marketContext.riskParameter.makerLimit.unsafeSub(marketContext.currentPosition.maker));\n }\n```\n
medium
```\nfunction DOMAIN_SEPARATOR() external view override returns (bytes32) {\n return _domainSeparatorV4();\n}\n```\n
none
```\nFile: MainRewarder.sol\n function _processRewards(address account, bool claimExtras) internal {\n _getReward(account);\n\n //also get rewards from linked rewards\n if (claimExtras) {\n for (uint256 i = 0; i < extraRewards.length; ++i) {\n IExtraRewarder(extraRewards[i]).getReward(account);\n }\n }\n }\n```\n
medium
```\n/\*\*\n \* @notice Used to convert an amount of underlying tokens to the equivalent amount of shares in this strategy.\n \* @notice In contrast to `underlyingToSharesView`, this function \*\*may\*\* make state modifications\n \* @param amountUnderlying is the amount of `underlyingToken` to calculate its conversion into strategy shares\n \* @dev Implementation for these functions in particular may vary signifcantly for different strategies\n \*/\nfunction underlyingToShares(uint256 amountUnderlying) external view returns (uint256);\n```\n
low
```\nFile: LibQuote.sol\n function closeQuote(Quote storage quote, uint256 filledAmount, uint256 closedPrice) internal {\n QuoteStorage.Layout storage quoteLayout = QuoteStorage.layout();\n AccountStorage.Layout storage accountLayout = AccountStorage.layout();\n\n quote.modifyTimestamp = block.timestamp;\n\n LockedValues memory lockedValues = LockedValues(\n quote.lockedValues.cva -\n ((quote.lockedValues.cva * filledAmount) / (LibQuote.quoteOpenAmount(quote))),\n quote.lockedValues.mm -\n ((quote.lockedValues.mm * filledAmount) / (LibQuote.quoteOpenAmount(quote))),\n quote.lockedValues.lf -\n ((quote.lockedValues.lf * filledAmount) / (LibQuote.quoteOpenAmount(quote)))\n );\n accountLayout.lockedBalances[quote.partyA].subQuote(quote).add(lockedValues);\n accountLayout.partyBLockedBalances[quote.partyB][quote.partyA].subQuote(quote).add(\n lockedValues\n );\n quote.lockedValues = lockedValues;\n\n (bool hasMadeProfit, uint256 pnl) = LibQuote.getValueOfQuoteForPartyA(\n closedPrice,\n filledAmount,\n quote\n );\n if (hasMadeProfit) {\n accountLayout.allocatedBalances[quote.partyA] += pnl;\n accountLayout.partyBAllocatedBalances[quote.partyB][quote.partyA] -= pnl;\n } else {\n accountLayout.allocatedBalances[quote.partyA] -= pnl;\n accountLayout.partyBAllocatedBalances[quote.partyB][quote.partyA] += pnl;\n }\n```\n
medium
```\nfunction \_getTokensIn(uint256 spentTokenBalance) internal view returns(uint256[] memory amountsIn) {\n amountsIn = new uint256[](2);\n\n uint256 receivedTokenBalance = readOracle().mul(spentTokenBalance).mul(ONE\_PERCENT).div(NINETY\_NINE\_PERCENT).asUint256();\n\n if (address(assets[0]) == tokenSpent) {\n amountsIn[0] = spentTokenBalance;\n amountsIn[1] = receivedTokenBalance;\n } else {\n amountsIn[0] = receivedTokenBalance;\n amountsIn[1] = spentTokenBalance;\n }\n}\n```\n
low
```\nfunction withdrawDeposit(\n address token\n)\n external\n{\n address owner = \_getContextAccount();\n uint256 lockedUntil = deposits[owner].withdrawalLockedUntil[token];\n\n /\* solhint-disable not-rely-on-time \*/\n\n if (lockedUntil != 0 && lockedUntil <= now) {\n deposits[owner].withdrawalLockedUntil[token] = 0;\n\n address depositAccount = deposits[owner].account;\n uint256 depositValue;\n\n if (token == address(0)) {\n depositValue = depositAccount.balance;\n } else {\n depositValue = ERC20Token(token).balanceOf(depositAccount);\n }\n\n \_transferFromDeposit(\n depositAccount,\n owner,\n token,\n depositValue\n );\n\n emit DepositWithdrawn(\n depositAccount,\n owner,\n token,\n depositValue\n );\n } else {\n \_deployDepositAccount(owner);\n\n lockedUntil = now.add(depositWithdrawalLockPeriod);\n\n deposits[owner].withdrawalLockedUntil[token] = lockedUntil;\n\n emit DepositWithdrawalRequested(\n deposits[owner].account,\n owner,\n token,\n lockedUntil\n );\n }\n /\* solhint-enable not-rely-on-time \*/\n}\n```\n
medium
```\n## Balancer.sol\n\n router.swap{value: msg.value}(\n _dstChainId,\n _srcPoolId,\n _dstPoolId,\n payable(this),\n _amount,\n _computeMinAmount(_amount, _slippage),\n IStargateRouterBase.lzTxObj({dstGasForCall: 0, dstNativeAmount: 0, dstNativeAddr: "0x0"}),\n _dst,\n "0x" => this is the payload that is being sent with the transaction\n );\n```\n
medium
```\nfunction isExcludedFromRewards(address wallet) external view returns (bool) {\n return isAddressExcluded[wallet];\n}\n```\n
none
```\n(address[] memory modules,) = safe.getModulesPaginated(SENTINEL_OWNERS, enabledModuleCount);\n_existingModulesHash = keccak256(abi.encode(modules));\n```\n
high
```\nfunction \_undelegate(\n address delegator,\n address delegatee,\n uint256 amount\n) internal virtual {\n uint256 newDelegates = \_delegatesVotesCount[delegator][delegatee] - amount;\n\n if (newDelegates == 0) {\n assert(\_delegates[delegator].remove(delegatee)); // Should never fail.\n }\n```\n
low
```\n// NOTE: amt after trimming must fit into uint64 (that's the point of\n// trimming, as Solana only supports uint64 for token amts)\nif (amountScaled > type(uint64).max) {\n revert AmountTooLarge(amt);\n}\n```\n
medium
```\nfunction includeInRewards(address wallet) external onlyOwner {\n require(isAddressExcluded[wallet], "Address is not excluded from rewards");\n for (uint i = 0; i < excludedFromRewards.length; i++) {\n if (excludedFromRewards[i] == wallet) {\n isAddressExcluded[wallet] = false;\n deleteExcluded(i);\n break;\n }\n }\n emit IncludeInRewards(wallet);\n}\n```\n
none
```\n function getProtocolOwnedLiquidityOhm() external view override returns (uint256) {\n\n uint256 len = bunniTokens.length;\n uint256 total;\n for (uint256 i; i < len; ) {\n TokenData storage tokenData = bunniTokens[i];\n BunniLens lens = tokenData.lens;\n BunniKey memory key = _getBunniKey(tokenData.token);\n\n // rest of code// rest of code// rest of code\n\n total += _getOhmReserves(key, lens);\n unchecked {\n ++i;\n }\n }\n\n\n return total;\n }\n```\n
high
```\nfunction addLiquidity(uint256 tokenAmount, uint256 ethAmount) private {\n // approve token transfer to cover all possible scenarios\n _approve(address(this), address(uniswapV2Router), tokenAmount);\n\n uint256 minToken = (tokenAmount * _slipPercent) / 100;\n uint256 minEth = (ethAmount * _slipPercent) / 100;\n\n // add the liquidity\n uniswapV2Router.addLiquidityETH{value: ethAmount}(\n address(this),\n tokenAmount,\n minToken,\n minEth,\n owner(),\n block.timestamp\n );\n}\n```\n
none
```\nfunction doTransfer(\n address sender,\n address recipient,\n uint amount\n) internal returns (bool) {\n if (!isAuthorized[sender] && !isAuthorized[recipient]) {\n require(launched, "VoxNET: transfers not allowed yet");\n }\n\n require(balanceOf[sender] >= amount, "VoxNET: insufficient balance");\n\n balanceOf[sender] = balanceOf[sender] - amount;\n\n uint amountAfterFee = amount;\n\n if (!distributingFee) {\n if ((isPool[sender] && !isFeeExempt[recipient]) || (isPool[recipient] && !isFeeExempt[sender])) {\n amountAfterFee = takeFee(sender, amount);\n } else {\n distributeFeeIfApplicable(amount);\n }\n }\n\n balanceOf[recipient] = balanceOf[recipient] + amountAfterFee;\n\n emit Transfer(sender, recipient, amountAfterFee);\n return true;\n}\n```\n
none
```\nfunction functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCall(target, data, "Address: low-level call failed");\n}\n```\n
none
```\nfunction beginGlobalSettlement(uint256 price) public onlyWhitelistAdmin {\n require(status != LibTypes.Status.SETTLED, "already settled");\n settlementPrice = price;\n status = LibTypes.Status.SETTLING;\n emit BeginGlobalSettlement(price);\n}\n```\n
medium
```\nfunction updateTokenPriceIfApplicable() internal {\n if (tokenPriceTimestamp != 0) {\n uint timeElapsed = block.timestamp - tokenPriceTimestamp;\n\n if (timeElapsed > priceUpdateTimeThreshold) {\n uint tokenPriceCumulative = getCumulativeTokenPrice();\n\n if (tokenPriceCumulativeLast != 0) {\n tokenPrice = uint224((tokenPriceCumulative - tokenPriceCumulativeLast) / timeElapsed);\n }\n\n tokenPriceCumulativeLast = tokenPriceCumulative;\n tokenPriceTimestamp = block.timestamp;\n }\n }\n}\n```\n
none
```\nrequire(msg.value == value, "GenesisGroup: value mismatch");\n```\n
low
```\nfunction isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize, which returns 0 for contracts in\n // construction, since the code is only stored at the end of the\n // constructor execution.\n\n uint256 size;\n assembly {\n size := extcodesize(account)\n }\n return size > 0;\n}\n```\n
none
```\nfunction _transferStandard(\n address sender,\n address recipient,\n uint256 tAmount\n) private {\n (\n uint256 tTransferAmount,\n uint256 tFee,\n uint256 tLiquidity,\n uint256 tWallet,\n uint256 tDonation\n ) = _getTValues(tAmount);\n (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(\n tAmount,\n tFee,\n tLiquidity,\n tWallet,\n tDonation,\n _getRate()\n );\n\n _rOwned[sender] = _rOwned[sender].sub(rAmount);\n _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);\n _takeLiquidity(tLiquidity);\n _takeWalletFee(tWallet);\n _takeDonationFee(tDonation);\n _reflectFee(rFee, tFee);\n emit Transfer(sender, recipient, tTransferAmount);\n}\n```\n
none
```\nfunction finalizeBlocks(\n BlockData[] calldata \_blocksData,\n bytes calldata \_proof,\n uint256 \_proofType,\n bytes32 \_parentStateRootHash\n)\n```\n
high
```\nfunction set(Map storage map, address key, uint256 val) internal {\n if (map.inserted[key]) {\n map.values[key] = val;\n } else {\n map.inserted[key] = true;\n map.values[key] = val;\n map.indexOf[key] = map.keys.length;\n map.keys.push(key);\n }\n}\n```\n
none
```\nfunction claim() external {\n dividendTracker.processAccount(payable(msg.sender), false);\n}\n```\n
none
```\nbalance = elapsedTime_ * (RATE_DECIMALS_MULTIPLIER * tokenAmount_ / duration) / RATE_DECIMALS_MULTIPLIER\n```\n
medium
```\nfunction setFeeCollector(address _feeCollector) external onlyRole(TOKEN_MANAGER) {\n feeCollector = _feeCollector;\n}\n```\n
none
```\ngtc = gtc\_;\n```\n
low
```\n function initializeDistributionRecord(\n uint32 _domain, // the domain of the beneficiary\n address _beneficiary, // the address that will receive tokens\n uint256 _amount, // the total claimable by this beneficiary\n bytes32[] calldata merkleProof\n ) external validMerkleProof(_getLeaf(_beneficiary, _amount, _domain), merkleProof) {\n _initializeDistributionRecord(_beneficiary, _amount);\n }\n```\n
high
```\nfunction convertFundsFromInput(address \_from, address \_to, uint256 \_inputAmount, uint256 \_minOutputAmount) external override returns (uint256 \_outputAmount)\n{\n address \_sender = msg.sender;\n Transfers.\_pullFunds(\_from, \_sender, \_inputAmount);\n \_inputAmount = Math.\_min(\_inputAmount, Transfers.\_getBalance(\_from)); // deals with potential transfer tax\n \_outputAmount = UniswapV2ExchangeAbstraction.\_convertFundsFromInput(router, \_from, \_to, \_inputAmount, \_minOutputAmount);\n \_outputAmount = Math.\_min(\_outputAmount, Transfers.\_getBalance(\_to)); // deals with potential transfer tax\n Transfers.\_pushFunds(\_to, \_sender, \_outputAmount);\n return \_outputAmount;\n}\n```\n
medium
```\nfunction pauseContract() external onlyOwner returns (bool) {\n _pause();\n return true;\n}\n```\n
none
```\n uint extraRewardsCount = IAuraRewarder(crvRewarder)\n .extraRewardsLength(); <- @audit-issue rewardTokenCount pulled fresh\n tokens = new address[](extraRewardsCount + 1);\n rewards = new uint256[](extraRewardsCount + 1);\n\n tokens[0] = IAuraRewarder(crvRewarder).rewardToken();\n rewards[0] = _getPendingReward(\n stCrvPerShare,\n crvRewarder,\n amount,\n lpDecimals\n );\n\n for (uint i = 0; i < extraRewardsCount; i++) {\n address rewarder = IAuraRewarder(crvRewarder).extraRewards(i);\n\n @audit-issue attempts to pull from array which will be too small if tokens are added\n uint256 stRewardPerShare = accExtPerShare[tokenId][i];\n tokens[i + 1] = IAuraRewarder(rewarder).rewardToken();\n rewards[i + 1] = _getPendingReward(\n stRewardPerShare,\n rewarder,\n amount,\n lpDecimals\n );\n }\n```\n
high
```\nfunction toString(uint256 value) internal pure returns (string memory) {\n // Inspired by OraclizeAPI's implementation - MIT licence\n // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\n\n if (value == 0) {\n return "0";\n }\n uint256 temp = value;\n uint256 digits;\n while (temp != 0) {\n digits++;\n temp /= 10;\n }\n bytes memory buffer = new bytes(digits);\n while (value != 0) {\n digits -= 1;\n buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\n value /= 10;\n }\n return string(buffer);\n}\n```\n
none
```\nfunction \_delayExecution(bytes \_evmCallScript) internal returns (uint256) {\n uint256 delayedScriptIndex = delayedScriptsNewIndex;\n delayedScriptsNewIndex++;\n\n delayedScripts[delayedScriptIndex] = DelayedScript(getTimestamp64().add(executionDelay), 0, \_evmCallScript);\n\n emit DelayedScriptStored(delayedScriptIndex);\n\n return delayedScriptIndex;\n}\n```\n
medium
```\nuint256[50] private \_\_gap;\n```\n
medium
```\nenum JoinKind { INIT, EXACT_TOKENS_IN_FOR_BPT_OUT, TOKEN_IN_FOR_EXACT_BPT_OUT }\n```\n
high
```\nfunction _grantRole(bytes32 role, address account) private {\n if (!hasRole(role, account)) {\n _roles[role].members[account] = true;\n emit RoleGranted(role, account, _msgSender());\n }\n}\n```\n
none
```\n/// @notice Ensures that the caller is the admin\nmodifier onlyActiveOperator(uint256 \_operatorIndex) {\n \_onlyActiveOperator(\_operatorIndex);\n \_;\n}\n```\n
low
```\naveragePrice = existing._initAcc * 1e18 / INIT_SAMPLE_COUNT;\naveragePrice = 36e18 * 1e18 / 18\naveragePrice = 36e36 / 18\naveragePrice = 2e36\n```\n
high
```\nFile: BondBaseSDA.sol\n function payoutFor(\n uint256 amount_,\n uint256 id_,\n address referrer_\n ) public view override returns (uint256) {\n // Calculate the payout for the given amount of tokens\n uint256 fee = amount_.mulDiv(_teller.getFee(referrer_), 1e5);\n uint256 payout = (amount_ - fee).mulDiv(markets[id_].scale, marketPrice(id_));\n\n // Check that the payout is less than or equal to the maximum payout,\n // Revert if not, otherwise return the payout\n if (payout > markets[id_].maxPayout) {\n revert Auctioneer_MaxPayoutExceeded();\n } else {\n return payout;\n }\n }\n```\n
medium

This dataset combines vulnerable functions (scraped from 5 auditting companies: Codehawks, ConsenSys, Cyfrin, Sherlock, Trust Security) and auddited functions with no vulnerabilities (scraped from Etherscan)

The purpose of the dataset is to enable training of classification models to discriminate between the 4 classes: none, low, medium and high.

Field Description
1. function Raw solidity code
2. severity Severity of vulnerability ('none', low, medium, high)

Data Analysis

Additional Info

  • The newline characters are escaped (i.e. \\n)
Downloads last month
63
Edit dataset card