function
stringlengths 12
63.3k
| severity
stringclasses 4
values |
---|---|
```\nfunction includeInFee(address account) public onlyOwner {\n _isExcludedFromFee[account] = false;\n}\n```\n | none |
```\nfunction owner() public view returns (address) {\n return _owner;\n}\n```\n | none |
```\nFile: FraxEtherRedemptionQueue.sol\n /// @notice Sets the fee for redeeming\n /// @param _newFee New redemption fee given in percentage terms, using 1e6 precision\n function setRedemptionFee(uint64 _newFee) external {\n _requireSenderIsTimelock();\n if (_newFee > FEE_PRECISION) revert ExceedsMaxRedemptionFee(_newFee, FEE_PRECISION);\n\n emit SetRedemptionFee({ oldRedemptionFee: redemptionQueueState.redemptionFee, newRedemptionFee: _newFee });\n\n redemptionQueueState.redemptionFee = _newFee;\n }\n```\n | medium |
```\nfunction transfer(address recipient, uint256 amount)\n public\n override\n returns (bool)\n{\n _transfer(_msgSender(), recipient, amount);\n return true;\n}\n```\n | none |
```\nmodifier onlyTest() {\n```\n | low |
```\nfunction _approve(address owner, address spender, uint256 amount) private {\n require(owner != address(0), "ERC20: approve from the zero address");\n require(spender != address(0), "ERC20: approve to the zero address");\n _allowances[owner][spender] = amount;\n emit Approval(owner, spender, amount);\n}\n```\n | none |
```\ntry IERC721(order.collection).safeTransferFrom(bear, bull, tokenId) {}\ncatch (bytes memory) {\n // Transfer NFT to BvbProtocol\n IERC721(order.collection).safeTransferFrom(bear, address(this), tokenId);\n // Store that the bull has to retrieve it\n withdrawableCollectionTokenId[order.collection][tokenId] = bull;\n}\n\nuint bearAssetAmount = order.premium + order.collateral;\nif (bearAssetAmount > 0) {\n // Transfer payment tokens to the Bear\n IERC20(order.asset).safeTransfer(bear, bearAssetAmount);\n}\n```\n | medium |
```\nFile: StableMath.sol\n function _calculateInvariant(\n uint256 amplificationParameter,\n uint256[] memory balances,\n bool roundUp\n ) internal pure returns (uint256) {\n /**********************************************************************************************\n // invariant //\n // D = invariant D^(n+1) //\n // A = amplification coefficient A n^n S + D = A D n^n + ----------- //\n // S = sum of balances n^n P //\n // P = product of balances //\n // n = number of tokens //\n *********x************************************************************************************/\n\n unchecked {\n // We support rounding up or down.\n uint256 sum = 0;\n uint256 numTokens = balances.length;\n for (uint256 i = 0; i < numTokens; i++) {\n sum = sum.add(balances[i]);\n }\n if (sum == 0) {\n return 0;\n }\n\n uint256 prevInvariant = 0;\n uint256 invariant = sum;\n uint256 ampTimesTotal = amplificationParameter * numTokens;\n\n for (uint256 i = 0; i < 255; i++) {\n uint256 P_D = balances[0] * numTokens;\n for (uint256 j = 1; j < numTokens; j++) {\n P_D = Math.div(Math.mul(Math.mul(P_D, balances[j]), numTokens), invariant, roundUp);\n }\n prevInvariant = invariant;\n invariant = Math.div(\n Math.mul(Math.mul(numTokens, invariant), invariant).add(\n Math.div(Math.mul(Math.mul(ampTimesTotal, sum), P_D), _AMP_PRECISION, roundUp)\n ),\n Math.mul(numTokens + 1, invariant).add(\n // No need to use checked arithmetic for the amp precision, the amp is guaranteed to be at least 1\n Math.div(Math.mul(ampTimesTotal - _AMP_PRECISION, P_D), _AMP_PRECISION, !roundUp)\n ),\n roundUp\n );\n\n if (invariant > prevInvariant) {\n if (invariant - prevInvariant <= 1) {\n return invariant;\n }\n } else if (prevInvariant - invariant <= 1) {\n return invariant;\n }\n }\n }\n\n revert CalculationDidNotConverge();\n }\n```\n | high |
```\n uint256 validSigCount = countValidSignatures(txHash, signatures, signatures.length / 65);\n // revert if there aren't enough valid signatures\n if (validSigCount < safe.getThreshold()) {\n revert InvalidSigners();\n }\n```\n | high |
```\ndiff --git a/test/spell/ichivault.spell.test.ts b/test/spell/ichivault.spell.test.ts\nindex 258d653..551a6eb 100644\n--- a/test/spell/ichivault.spell.test.ts\n// Add the line below\n// Add the line below\n// Add the line below\n b/test/spell/ichivault.spell.test.ts\n@@ -163,6 // Add the line below\n163,26 @@ describe('ICHI Angel Vaults Spell', () => {\n afterTreasuryBalance.sub(beforeTreasuryBalance)\n ).to.be.equal(depositAmount.mul(50).div(10000))\n })\n// Add the line below\n it("should revert when exceeds max pos size due to increasing position", async () => {\n// Add the line below\n await ichi.approve(bank.address, ethers.constants.MaxUint256);\n// Add the line below\n await bank.execute(\n// Add the line below\n 0,\n// Add the line below\n spell.address,\n// Add the line below\n iface.encodeFunctionData("openPosition", [\n// Add the line below\n 0, ICHI, USDC, depositAmount.mul(4), borrowAmount.mul(6) // Borrow 1.800e6 USDC\n// Add the line below\n ])\n// Add the line below\n );\n// Add the line below\n\n// Add the line below\n await expect(\n// Add the line below\n bank.execute(\n// Add the line below\n 0,\n// Add the line below\n spell.address,\n// Add the line below\n iface.encodeFunctionData("openPosition", [\n// Add the line below\n 0, ICHI, USDC, depositAmount.mul(1), borrowAmount.mul(2) // Borrow 300e6 USDC\n// Add the line below\n ])\n// Add the line below\n )\n// Add the line below\n ).to.be.revertedWith("EXCEED_MAX_POS_SIZE"); // 1_800e6 // Add the line below\n 300e6 = 2_100e6 > 2_000e6 strategy max position size limit\n// Add the line below\n })\n it("should be able to return position risk ratio", async () => {\n let risk = await bank.getPositionRisk(1);\n console.log('Prev Position Risk', utils.formatUnits(risk, 2), '%');\n```\n | medium |
```\nif (ownerToRollOverQueueIndex[_receiver] != 0) {\n // if so, update the queue\n uint256 index = getRolloverIndex(_receiver);\n rolloverQueue[index].assets = _assets;\n rolloverQueue[index].epochId = _epochId;\n```\n | high |
```\nfunction _getRate() private view returns(uint256) {\n (uint256 rSupply, uint256 tSupply) = _getCurrentSupply();\n return rSupply / tSupply;\n}\n```\n | none |
```\nFile: SingleSidedLPVaultBase.sol\n /// @notice Allows the emergency exit role to trigger an emergency exit on the vault.\n /// In this situation, the `claimToExit` is withdrawn proportionally to the underlying\n /// tokens and held on the vault. The vault is locked so that no entries, exits or\n /// valuations of vaultShares can be performed.\n /// @param claimToExit if this is set to zero, the entire pool claim is withdrawn\n function emergencyExit(\n uint256 claimToExit, bytes calldata /* data */\n ) external override onlyRole(EMERGENCY_EXIT_ROLE) {\n StrategyVaultState memory state = VaultStorage.getStrategyVaultState();\n if (claimToExit == 0) claimToExit = state.totalPoolClaim;\n\n // By setting min amounts to zero, we will accept whatever tokens come from the pool\n // in a proportional exit. Front running will not have an effect since no trading will\n // occur during a proportional exit.\n _unstakeAndExitPool(claimToExit, new uint256[](NUM_TOKENS()), true);\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 |
```\nFile: contracts\OperatorTokenomics\StreamrConfig.sol\n /**\n * Minimum amount to pay reviewers+flagger\n * That is: minimumStakeWei >= (flaggerRewardWei + flagReviewerCount * flagReviewerRewardWei) / slashingFraction\n */\n function minimumStakeWei() public view returns (uint) {\n return (flaggerRewardWei + flagReviewerCount * flagReviewerRewardWei) * 1 ether / slashingFraction;\n }\n```\n | high |
```\nfunction mul(uint256 a, uint256 b) internal pure returns (uint256) {\n // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\n // benefit is lost if 'b' is also tested.\n // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\n if (a == 0) {\n return 0;\n }\n\n uint256 c = a * b;\n require(c / a == b, "SafeMath: multiplication overflow");\n\n return c;\n}\n```\n | none |
```\nFile: AuraSpell.sol\n function openPositionFarm(\n OpenPosParam calldata param,\n uint256 minimumBPT\n )\n// rest of code\n {\n// rest of code\n /// 3. Add liquidity to the Balancer pool and receive BPT in return.\n {\n// rest of code\n if (poolAmountOut != 0) {\n vault.joinPool(\n wAuraPools.getBPTPoolId(lpToken),\n address(this),\n address(this),\n IBalancerVault.JoinPoolRequest({\n assets: tokens,\n maxAmountsIn: maxAmountsIn,\n userData: abi.encode(1, amountsIn, _minimumBPT),\n fromInternalBalance: false\n })\n );\n }\n }\n// rest of code\n }\n// rest of code\n function _getJoinPoolParamsAndApprove(\n address vault,\n address[] memory tokens,\n uint256[] memory balances,\n address lpToken\n ) internal returns (uint256[] memory, uint256[] memory, uint256) {\n// rest of code\n uint256 length = tokens.length;\n uint256[] memory maxAmountsIn = new uint256[](length);\n uint256[] memory amountsIn = new uint256[](length);\n bool isLPIncluded;\n for (i; i != length; ) {\n if (tokens[i] != lpToken) {\n amountsIn[j] = IERC20(tokens[i]).balanceOf(address(this));\n if (amountsIn[j] > 0) {\n _ensureApprove(tokens[i], vault, amountsIn[j]);\n }\n ++j;\n } else isLPIncluded = true;\n maxAmountsIn[i] = IERC20(tokens[i]).balanceOf(address(this));\n unchecked {\n ++i;\n }\n }\n if (isLPIncluded) {\n assembly {\n mstore(amountsIn, sub(mload(amountsIn), 1))\n }\n }\n// rest of code\n return (maxAmountsIn, amountsIn, poolAmountOut);\n }\n```\n | medium |
```\nfunction _tokenTransfer(\n address sender,\n address recipient,\n uint256 amount,\n bool takeFee\n) private {\n if (takeFee) {\n removeAllFee();\n if (sender == uniswapV2Pair) {\n setBuy();\n }\n if (recipient == uniswapV2Pair) {\n setSell();\n }\n }\n\n if (_isExcluded[sender] && !_isExcluded[recipient]) {\n _transferFromExcluded(sender, recipient, amount);\n } else if (!_isExcluded[sender] && _isExcluded[recipient]) {\n _transferToExcluded(sender, recipient, amount);\n } else if (!_isExcluded[sender] && !_isExcluded[recipient]) {\n _transferStandard(sender, recipient, amount);\n } else if (_isExcluded[sender] && _isExcluded[recipient]) {\n _transferBothExcluded(sender, recipient, amount);\n } else {\n _transferStandard(sender, recipient, amount);\n }\n removeAllFee();\n}\n```\n | none |
```\nuint256 activeAgents = gameInfo.activeAgents;\n if (activeAgents == 1) {\n revert GameOver();\n }\n```\n | high |
```\nfunction setAutomatedMarketMakerPair(\n address pair,\n bool value\n) public onlyOwner {\n require(\n pair != dexPair,\n "The pair cannot be removed from automatedMarketMakerPairs"\n );\n\n _setAutomatedMarketMakerPair(pair, value);\n}\n```\n | none |
```\nfunction _queueLockUpdate(\n address _owner,\n uint256 _lockId,\n uint256 _amount,\n uint64 _lockingDuration\n) internal onlyLockOwner(_lockId, _owner) {\n Lock memory lock = _getQueuedLockState(_lockId);\n LockUpdate memory lockUpdate = LockUpdate(updateBatchIndex, _updateLock(lock, _amount, _lockingDuration));\n queuedLockUpdates[_lockId].push(lockUpdate);\n queuedRESDLSupplyChange +=\n int256(lockUpdate.lock.amount + lockUpdate.lock.boostAmount) -\n int256(lock.amount + lock.boostAmount);\n // rest of code\n}\n```\n | medium |
```\nuint256 _maturity = utils.getFutureMaturity(targetDuration);\n\nfunction getFutureMaturity(uint256 monthsForward) public view returns (uint256) {\n (uint256 year, uint256 month, ) = DateTime.timestampToDate(DateTime.addMonths(block.timestamp, monthsForward));\n return DateTime.timestampFromDateTime(year, month, 1 /* top of the month */, 0, 0, 0);\n}\n```\n | high |
```\n function _liquidateUser(\n address user,\n uint256 maxBorrowPart,\n IMarketLiquidatorReceiver _liquidatorReceiver,\n bytes calldata _liquidatorReceiverData,\n uint256 _exchangeRate,\n uint256 minLiquidationBonus\n ) private {\n uint256 callerReward = _getCallerReward(user, _exchangeRate);\n\n (uint256 borrowAmount,, uint256 collateralShare) =\n _updateBorrowAndCollateralShare(user, maxBorrowPart, minLiquidationBonus, _exchangeRate);\n totalCollateralShare = totalCollateralShare > collateralShare ? totalCollateralShare - collateralShare : 0;\n uint256 borrowShare = yieldBox.toShare(assetId, borrowAmount, true);\n\n (uint256 returnedShare,) =\n _swapCollateralWithAsset(collateralShare, _liquidatorReceiver, _liquidatorReceiverData);\n if (returnedShare < borrowShare) revert AmountNotValid();\n\n (uint256 feeShare, uint256 callerShare) = _extractLiquidationFees(returnedShare, borrowShare, callerReward);\n\n IUsdo(address(asset)).burn(address(this), borrowAmount);\n\n address[] memory _users = new address[](1);\n _users[0] = user;\n emit Liquidated(msg.sender, _users, callerShare, feeShare, borrowAmount, collateralShare);\n }\n\n function _updateBorrowAndCollateralShare(\n address user,\n uint256 maxBorrowPart,\n uint256 minLiquidationBonus, // min liquidation bonus to accept (default 0)\n uint256 _exchangeRate\n ) private returns (uint256 borrowAmount, uint256 borrowPart, uint256 collateralShare) {\n if (_exchangeRate == 0) revert ExchangeRateNotValid();\n\n // get collateral amount in asset's value\n uint256 collateralPartInAsset = (\n yieldBox.toAmount(collateralId, userCollateralShare[user], false) * EXCHANGE_RATE_PRECISION\n ) / _exchangeRate;\n\n // compute closing factor (liquidatable amount)\n uint256 borrowPartWithBonus =\n computeClosingFactor(userBorrowPart[user], collateralPartInAsset, FEE_PRECISION_DECIMALS);\n\n // limit liquidable amount before bonus to the current debt\n uint256 userTotalBorrowAmount = totalBorrow.toElastic(userBorrowPart[user], true);\n borrowPartWithBonus = borrowPartWithBonus > userTotalBorrowAmount ? userTotalBorrowAmount : borrowPartWithBonus;\n\n // check the amount to be repaid versus liquidator supplied limit\n borrowPartWithBonus = borrowPartWithBonus > maxBorrowPart ? maxBorrowPart : borrowPartWithBonus;\n borrowAmount = borrowPartWithBonus;\n\n // compute part units, preventing rounding dust when liquidation is full\n borrowPart = borrowAmount == userTotalBorrowAmount\n ? userBorrowPart[user]\n : totalBorrow.toBase(borrowPartWithBonus, false);\n if (borrowPart == 0) revert Solvent();\n\n if (liquidationBonusAmount > 0) {\n borrowPartWithBonus = borrowPartWithBonus + (borrowPartWithBonus * liquidationBonusAmount) / FEE_PRECISION;\n }\n\n if (collateralPartInAsset < borrowPartWithBonus) {\n if (collateralPartInAsset <= userTotalBorrowAmount) {\n revert BadDebt();\n }\n // If current debt is covered by collateral fully\n // then there is some liquidation bonus,\n // so liquidation can proceed if liquidator's minimum is met\n if (minLiquidationBonus > 0) {\n // `collateralPartInAsset > borrowAmount` as `borrowAmount <= userTotalBorrowAmount`\n uint256 effectiveBonus = ((collateralPartInAsset - borrowAmount) * FEE_PRECISION) / borrowAmount;\n if (effectiveBonus < minLiquidationBonus) {\n revert InsufficientLiquidationBonus();\n }\n collateralShare = userCollateralShare[user];\n } else {\n revert InsufficientLiquidationBonus();\n }\n } else {\n collateralShare =\n yieldBox.toShare(collateralId, (borrowPartWithBonus * _exchangeRate) / EXCHANGE_RATE_PRECISION, false);\n if (collateralShare > userCollateralShare[user]) {\n revert NotEnoughCollateral();\n }\n }\n\n userBorrowPart[user] -= borrowPart;\n userCollateralShare[user] -= collateralShare;\n }\n```\n | high |
```\n int256 rawCollateralPrice = strategy.collateralPriceOracle.latestAnswer();\n rebalanceInfo.collateralPrice = rawCollateralPrice.toUint256().mul(10 ** strategy.collateralDecimalAdjustment);\n int256 rawBorrowPrice = strategy.borrowPriceOracle.latestAnswer();\n rebalanceInfo.borrowPrice = rawBorrowPrice.toUint256().mul(10 ** strategy.borrowDecimalAdjustment);\n```\n | medium |
```\nfunction taxValues()\n external\n view\n returns (\n uint256 _buyTaxTotal,\n uint256 _buyMarketingTax,\n uint256 _buyProjectTax,\n uint256 _sellTaxTotal,\n uint256 _sellMarketingTax,\n uint256 _sellProjectTax\n )\n{\n _buyTaxTotal = buyTaxTotal;\n _buyMarketingTax = buyMarketingTax;\n _buyProjectTax = buyProjectTax;\n _sellTaxTotal = sellTaxTotal;\n _sellMarketingTax = sellMarketingTax;\n _sellProjectTax = sellProjectTax;\n}\n```\n | none |
```\nIPlatformIntegration(\_integration).checkBalance(\_bAsset);\n```\n | low |
```\n(address[] memory modules,) = safe.getModulesPaginated(SENTINEL_OWNERS, enabledModuleCount);\n_existingModulesHash = keccak256(abi.encode(modules));\n```\n | high |
```\nfunction toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n bytes memory buffer = new bytes(2 * length + 2);\n buffer[0] = "0";\n buffer[1] = "x";\n for (uint256 i = 2 * length + 1; i > 1; --i) {\n buffer[i] = _HEX_SYMBOLS[value & 0xf];\n value >>= 4;\n }\n require(value == 0, "Strings: hex length insufficient");\n return string(buffer);\n}\n```\n | none |
```\nThe feeMultiplier enables the admin to subsidize or upcharge for the automation service.\n/**\n⦁ @notice feeMultiplier represents the total fee to be charged on the transaction\n⦁ Is set to 100% by default\n⦁ @dev In case feeMultiplier is less than BASE_BPS, fees charged will be less than 100%,\n⦁ subsidizing the transaction\n⦁ In case feeMultiplier is greater than BASE_BPS, fees charged will be greater than 100%,\n⦁ charging the user for the transaction\n*/ \n uint16 public feeMultiplier = 10_000;\n // The normal fee is calculated and then processed by the multiplier.\n if (feeToken == ETH) {\n uint256 totalFee = (gasUsed + GAS_OVERHEAD_NATIVE) * tx.gasprice; \n totalFee = _applyMultiplier(totalFee);\n return (totalFee, recipient, TokenTransfer._nativeTransferExec(recipient, totalFee));\n } else {\n```\n | medium |
```\nfunction add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n require(c >= a, "SafeMath: addition overflow");\n\n return c;\n}\n```\n | none |
```\nSLeverageSwapData memory swapData = abi.decode(data, (SLeverageSwapData));\nuint256 daiAmount =\n _swapAndTransferToSender(false, assetAddress, daiAddress, assetAmountIn, swapData.swapperData);\n```\n | medium |
```\nfunction updateMaxTransaction(uint256 newNum) external onlyOwner {\n require(\n newNum >= ((totalSupply() * 1) / 1000) / 1e18,\n "Cannot set maxTransaction lower than 0.1%"\n );\n maxTransaction = newNum * (10**18);\n}\n```\n | none |
```\nfunction eject(\n uint256 shares,\n address receiver,\n address owner\n) public returns (uint256 assets, uint256 excessBal, bool isExcessPTs) {\n\n // rest of code\n\n //@audit call of interest\n (excessBal, isExcessPTs) = _exitAndCombine(shares);\n\n _burn(owner, shares); // Burn after percent ownership is determined in _exitAndCombine.\n\n if (isExcessPTs) {\n pt.transfer(receiver, excessBal);\n } else {\n yt.transfer(receiver, excessBal);\n }\n\n //@audit entire asset (adapter.target) balance transferred to caller, which includes collected YT yield and combined\n asset.transfer(receiver, assets = asset.balanceOf(address(this)));\n\n emit Ejected(msg.sender, receiver, owner, assets, shares,\n isExcessPTs ? excessBal : 0,\n isExcessPTs ? 0 : excessBal\n );\n}\n\nfunction _exitAndCombine(uint256 shares) internal returns (uint256, bool) {\n uint256 supply = totalSupply; // Save extra SLOAD.\n\n uint256 lpBal = shares.mulDivDown(space.balanceOf(address(this)), supply);\n uint256 totalPTBal = pt.balanceOf(address(this));\n uint256 ptShare = shares.mulDivDown(totalPTBal, supply);\n\n // rest of code\n\n uint256 ytBal = shares.mulDivDown(yt.balanceOf(address(this)), supply);\n ptShare += pt.balanceOf(address(this)) - totalPTBal;\n\n unchecked {\n // Safety: an inequality check is done before subtraction.\n if (ptShare > ytBal) {\n\n //@audit call of interest\n divider.combine(address(adapter), maturity, ytBal);\n return (ptShare - ytBal, true);\n } else { // Set excess PTs to false if the balances are exactly equal.\n divider.combine(address(adapter), maturity, ptShare);\n return (ytBal - ptShare, false);\n }\n }\n}\n```\n | high |
```\ntry IDepositCallbackReceiver(deposit.callbackContract()).afterDepositExecution{ gas: deposit.callbackGasLimit() }(key, deposit) {\n } catch (bytes memory reasonBytes) {\n (string memory reason, /* bool hasRevertMessage */) = ErrorUtils.getRevertMessage(reasonBytes);\n emit AfterDepositExecutionError(key, deposit, reason, reasonBytes);\n }\n```\n | high |
```\nfunction _payout(DrawData memory current) private {\n require(current.winner != address(0), "DCBW721: Address cannot be 0");\n require(current.prizePoolWon > 0, "DCBW721: Prize pool is empty");\n\n /// @notice updating reserve pool & grand prize pool\n if (current.isGrandPrize == 1) {\n _updateGrandPrizePool(0);\n } else {\n _updateReserves(0);\n }\n\n /// @notice forward prize to winner wallet using CALL to avoid 2300 stipend limit\n (bool success, ) = payable(current.winner).call{value: current.prizePoolWon}("");\n require(success, "DCBW721: Failed to forward prize");\n}\n```\n | none |
```\nfunction getSavedOrSpotOraclePrice(address asset) internal view returns (uint256) {\n if (LibOrders.getOffsetTime() - getTime(asset) < 15 minutes) {\n return getPrice(asset);\n } else {\n return getOraclePrice(asset);\n }\n}\n```\n | medium |
```\nfunction mod(uint256 a, uint256 b) internal pure returns (uint256) {\n return a % b;\n}\n```\n | none |
```\n/// @dev Refunds up to `msg.value` leftover ETH at the end of the call.\nmodifier refundsAttachedEth() {\n \_;\n uint256 remainingBalance =\n LibSafeMathV06.min256(msg.value, address(this).balance);\n if (remainingBalance > 0) {\n msg.sender.transfer(remainingBalance);\n }\n}\n```\n | high |
```\nfunction removeToken(\n bytes4 tokenSource, \n bytes32 tokenSourceAddress, \n address newAuthority) external onlyRole(TOKEN_MANAGER) {\n require(newAuthority != address(0), "Bridge: zero address authority");\n address tokenAddress = tokenSourceMap[tokenSource][tokenSourceAddress];\n require(tokenAddress != address(0), "Bridge: token not found");\n TokenInfo memory tokenInfo = tokenInfos[tokenAddress];\n\n if (tokenInfo.tokenType == TokenType.Base && address(this).balance > 0) {\n payable(newAuthority).transfer(address(this).balance);\n }\n\n uint256 tokenBalance = IERC20(tokenAddress).balanceOf(address(this));\n if (tokenBalance > 0) {\n IERC20(tokenAddress).safeTransfer(newAuthority, tokenBalance);\n }\n\n if (tokenInfo.tokenType == TokenType.Wrapped) {\n WrappedToken(tokenAddress).transferOwnership(newAuthority);\n } else if (tokenInfo.tokenType == TokenType.WrappedV0) {\n IWrappedTokenV0(tokenAddress).changeAuthority(newAuthority);\n }\n\n delete tokenInfos[tokenAddress];\n delete tokenSourceMap[tokenSource][tokenSourceAddress];\n}\n```\n | none |
```\n/// @notice we poll the Keep contract to retrieve our pubkey\n/// @dev We store the pubkey as 2 bytestrings, X and Y.\n/// @param \_d deposit storage pointer\n/// @return True if successful, otherwise revert\nfunction retrieveSignerPubkey(DepositUtils.Deposit storage \_d) public {\n require(\_d.inAwaitingSignerSetup(), "Not currently awaiting signer setup");\n\n bytes memory \_publicKey = IBondedECDSAKeep(\_d.keepAddress).getPublicKey();\n require(\_publicKey.length == 64, "public key not set or not 64-bytes long");\n```\n | high |
```\nconstructor(IERC20 xABR_, uint256 baseFeeRateBP_, uint256 feeMultiplier_) {\n xABR = xABR_;\n baseFeeRateBP = baseFeeRateBP_;\n feeMultiplier = feeMultiplier_;\n}\n```\n | none |
```\nfunction tryRecover(\n bytes32 hash,\n bytes memory signature\n) internal pure returns (address, RecoverError) {\n if (signature.length == 65) {\n bytes32 r;\n bytes32 s;\n uint8 v;\n // ecrecover takes the signature parameters, and the only way to get them\n // currently is to use assembly.\n /// @solidity memory-safe-assembly\n assembly {\n r := mload(add(signature, 0x20))\n s := mload(add(signature, 0x40))\n v := byte(0, mload(add(signature, 0x60)))\n }\n return tryRecover(hash, v, r, s);\n } else {\n return (address(0), RecoverError.InvalidSignatureLength);\n }\n}\n```\n | none |
```\nfunction manualsend() external {\n require(_msgSender() == _feeAddrWallet1);\n uint256 contractETHBalance = address(this).balance;\n sendETHToFee(contractETHBalance);\n}\n```\n | none |
```\nfunction getAccountAtIndex(uint256 index) public view returns (address, int256, int256, uint256,\n uint256, uint256) {\n if (index >= tokenHoldersMap.size()) {\n return (0x0000000000000000000000000000000000000000, -1, -1, 0, 0, 0);\n }\n\n address account = tokenHoldersMap.getKeyAtIndex(index);\n\n return getAccount(account);\n}\n```\n | none |
```\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 |
```\n} else {\n // Deduct the external swap fee\n uint256 fee = (bridgedAmount * dstExternalFeeRate) / FEE_BASE;\n bridgedAmount -= fee; // @@audit: fee should not be applied to internal swap \n\n TransferHelper.safeApprove(bridgedToken, address(wooRouter), bridgedAmount);\n if (dst1inch.swapRouter != address(0)) {\n try\n wooRouter.externalSwap(\n```\n | medium |
```\nfunction sendPaymentForReimbursement() external payable returns (bool) {\n if (msg.sender != defaultPlatformAddress) revert UnAuthorizedRequest();\n\n if (msg.value == 0) revert UnAuthorizedRequest();\n\n emit PaymentSentInContractForReimbursements(msg.value, msg.sender);\n return true;\n}\n```\n | none |
```\nif (unstakeAmount > totalPendingUnstake) {\n pool.receiveWithoutActivation{value: unstakeAmount - totalPendingUnstake}();\n unstakeAmount = totalPendingUnstake;\n}\n\ntotalPendingUnstake -= unstakeAmount;\ntotalUnstaked += unstakeAmount;\nuint256 amountToFill = unstakeAmount;\n\nfor (uint256 i = unstakeRequestCurrentIndex; i <= unstakeRequestCount; i++) {\n UnstakeRequest storage request = \_unstakeRequests[i];\n if (amountToFill > (request.amount - request.amountFilled)) {\n amountToFill -= (request.amount - request.amountFilled);\n continue;\n } else {\n if (amountToFill == (request.amount - request.amountFilled) && i < unstakeRequestCount) {\n unstakeRequestCurrentIndex = i + 1;\n } else {\n request.amountFilled += uint128(amountToFill);\n unstakeRequestCurrentIndex = i;\n }\n break;\n }\n}\n```\n | low |
```\nfunction \_startRotation(bytes32 schainIndex, uint nodeIndex) private {\n ConstantsHolder constants = ConstantsHolder(contractManager.getContract("ConstantsHolder"));\n rotations[schainIndex].nodeIndex = nodeIndex;\n rotations[schainIndex].newNodeIndex = nodeIndex;\n rotations[schainIndex].freezeUntil = now.add(constants.rotationDelay());\n waitForNewNode[schainIndex] = true;\n}\n```\n | medium |
```\nmapping(uint256 => bool) public liquidated;\n\n/// @notice `\_poolIDs` maps agentID to the pools they have actively borrowed from\nmapping(uint256 => uint256[]) private \_poolIDs;\n\n/// @notice `\_credentialUseBlock` maps signature bytes to when a credential was used\nmapping(bytes32 => uint256) private \_credentialUseBlock;\n\n/// @notice `\_agentBeneficiaries` maps an Agent ID to its Beneficiary struct\nmapping(uint256 => AgentBeneficiary) private \_agentBeneficiaries;\n```\n | low |
```\nfunction drawDebt(\n address borrowerAddress_,\n uint256 amountToBorrow_,\n uint256 limitIndex_,\n uint256 collateralToPledge_\n) external nonReentrant {\n PoolState memory poolState = _accruePoolInterest();\n\n // rest of code\n\n DrawDebtResult memory result = BorrowerActions.drawDebt(\n auctions,\n deposits,\n loans,\n poolState,\n _availableQuoteToken(),\n borrowerAddress_,\n amountToBorrow_,\n limitIndex_,\n collateralToPledge_\n );\n\n // rest of code\n\n // update pool interest rate state\n _updateInterestState(poolState, result.newLup);\n\n // rest of code\n}\n```\n | medium |
```\n/// @dev Target is a 256 bit number encoded as a 3-byte mantissa and 1 byte exponent\n/// @param \_header The header\n/// @return The target threshold\nfunction extractTarget(bytes memory \_header) internal pure returns (uint256) {\n bytes memory \_m = \_header.slice(72, 3);\n uint8 \_e = uint8(\_header[75]);\n uint256 \_mantissa = bytesToUint(reverseEndianness(\_m));\n uint \_exponent = \_e - 3;\n\n return \_mantissa \* (256 \*\* \_exponent);\n}\n```\n | high |
```\n /**\n * @dev Hook override to forbid transfers except from whitelisted \n addresses and minting\n */\n function _beforeTokenTransfer(address from, address to, uint256 \n /*amount*/) internal view override {\n require(from == address(0) || _transferWhitelist.contains(from) \n || _transferWhitelist.contains(to), "transfer: not allowed");\n }\n```\n | low |
```\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 |
```\nwAuraPools.getVault(lpToken).exitPool(\n IBalancerPool(lpToken).getPoolId(),\n address(this),\n address(this),\n IBalancerVault.ExitPoolRequest(tokens, minAmountsOut, "", false)\n);\n```\n | high |
```\nfunction getNftPower(uint256 tokenId) public view override returns (uint256) {\n if (block.timestamp <= powerCalcStartTimestamp) {\n return 0;\n }\n\n // @audit 0 for non-existent tokenId\n uint256 collateral = nftInfos[tokenId].currentCollateral;\n\n // Calculate the minimum possible power based on the collateral of the nft\n // @audit returns default maxPower for non-existent tokenId\n uint256 maxNftPower = getMaxPowerForNft(tokenId);\n uint256 minNftPower = maxNftPower.ratio(collateral, getRequiredCollateralForNft(tokenId));\n minNftPower = maxNftPower.min(minNftPower);\n\n // Get last update and current power. Or set them to default if it is first iteration\n // @audit both 0 for non-existent tokenId\n uint64 lastUpdate = nftInfos[tokenId].lastUpdate;\n uint256 currentPower = nftInfos[tokenId].currentPower;\n\n if (lastUpdate == 0) {\n lastUpdate = powerCalcStartTimestamp;\n // @audit currentPower set to maxNftPower which\n // is just the default maxPower even for non-existent tokenId!\n currentPower = maxNftPower;\n }\n\n // Calculate reduction amount\n uint256 powerReductionPercent = reductionPercent * (block.timestamp - lastUpdate);\n uint256 powerReduction = currentPower.min(maxNftPower.percentage(powerReductionPercent));\n uint256 newPotentialPower = currentPower - powerReduction;\n\n // @audit returns newPotentialPower slightly reduced\n // from maxPower for non-existent tokenId\n if (minNftPower <= newPotentialPower) {\n return newPotentialPower;\n }\n\n if (minNftPower <= currentPower) {\n return minNftPower;\n }\n\n return currentPower;\n}\n\nfunction recalculateNftPower(uint256 tokenId) public override returns (uint256 newPower) {\n if (block.timestamp < powerCalcStartTimestamp) {\n return 0;\n }\n\n // @audit newPower > 0 for non-existent tokenId\n newPower = getNftPower(tokenId);\n\n NftInfo storage nftInfo = nftInfos[tokenId];\n\n // @audit as this is the first update since\n // tokenId doesn't exist, totalPower will be\n // subtracted by nft's max power\n totalPower -= nftInfo.lastUpdate != 0 ? nftInfo.currentPower : getMaxPowerForNft(tokenId);\n // @audit then totalPower is increased by newPower where:\n // 0 < newPower < maxPower hence net decrease to totalPower\n totalPower += newPower;\n\n nftInfo.lastUpdate = uint64(block.timestamp);\n nftInfo.currentPower = newPower;\n}\n```\n | high |
```\ngaugeQueuedRewards[gauge] = QueuedRewards({\n priorCycleRewards: queuedRewards.priorCycleRewards + completedRewards,\n cycleRewards: uint112(nextRewards),\n storedCycle: currentCycle\n});\n```\n | high |
```\nfunction pauseByType(bytes32 \_pauseType) external onlyRole(PAUSE\_MANAGER\_ROLE) {\n pauseTypeStatuses[\_pauseType] = true;\n emit Paused(\_msgSender(), \_pauseType);\n}\n```\n | low |
```\n function baseOracleCircuitBreaker(\n uint256 protocolPrice,\n uint80 roundId,\n int256 chainlinkPrice,\n uint256 timeStamp,\n uint256 chainlinkPriceInEth\n ) private view returns (uint256 _protocolPrice) {\n \n // more code\n\n if (invalidFetchData || priceDeviation) {\n uint256 twapPrice = IDiamond(payable(address(this))).estimateWETHInUSDC(\n Constants.UNISWAP_WETH_BASE_AMT, 30 minutes\n );\n uint256 twapPriceInEther = (twapPrice / Constants.DECIMAL_USDC) * 1 ether;\n```\n | low |
```\nif (!emergencyProcessing) {\n require(\n proposal.tributeToken.transfer(proposal.proposer, proposal.tributeOffered),\n "failing vote token transfer failed"\n );\n```\n | high |
```\nfunction getMemberAt(uint256 \_index) override public view returns (address) {\n AddressSetStorageInterface addressSetStorage = AddressSetStorageInterface(getContractAddress("addressSetStorage"));\n return addressSetStorage.getItem(keccak256(abi.encodePacked(daoNameSpace, "member.index")), \_index);\n}\n```\n | low |
```\nFile: PoolMath.sol\n int256 internal constant N_COINS = 3;\n..SNIP..\n function swapExactBaseLpTokenForUnderlying(PoolState memory pool, uint256 exactBaseLptIn)\n internal\n..SNIP..\n // Note: Here we are multiplying by N_COINS because the swap formula is defined in terms of the amount of PT being swapped.\n // BaseLpt is equivalent to 3 times the amount of PT due to the initial deposit of 1:1:1:1=pt1:pt2:pt3:Lp share in Curve pool.\n exactBaseLptIn.neg() * N_COINS\n..SNIP..\n function swapUnderlyingForExactBaseLpToken(PoolState memory pool, uint256 exactBaseLptOut)\n..SNIP..\n (int256 _netUnderlyingToAccount18, int256 _netUnderlyingFee18, int256 _netUnderlyingToProtocol18) = executeSwap(\n pool,\n // Note: sign is defined from the perspective of the swapper.\n // positive because the swapper is buying pt\n exactBaseLptOut.toInt256() * N_COINS\n```\n | high |
```\nfunction average(uint256 a, uint256 b) internal pure returns (uint256) {\n // (a + b) / 2 can overflow.\n return (a & b) + (a ^ b) / 2;\n}\n```\n | none |
```\nmapping(uint256 => bool) public liquidated;\n\n/// @notice `\_poolIDs` maps agentID to the pools they have actively borrowed from\nmapping(uint256 => uint256[]) private \_poolIDs;\n\n/// @notice `\_credentialUseBlock` maps signature bytes to when a credential was used\nmapping(bytes32 => uint256) private \_credentialUseBlock;\n\n/// @notice `\_agentBeneficiaries` maps an Agent ID to its Beneficiary struct\nmapping(uint256 => AgentBeneficiary) private \_agentBeneficiaries;\n```\n | low |
```\nfunction functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n) internal returns (bytes memory) {\n return\n functionCallWithValue(\n target,\n data,\n value,\n "Address: low-level call with value failed"\n );\n}\n```\n | none |
```\nuint256 deployerPrivateKey = vm.envUint("PRIVATE\_KEY");\n```\n | high |
```\nfunction _updateReserves(uint256 reserves) internal {\n require(\n reserves <= address(this).balance.sub(_grandPrizePool),\n "DCBW721: Reserve-Balance Mismatch"\n );\n _reserves = reserves;\n}\n```\n | none |
```\n function _decreaseCurrentMinted(address account, uint256 amount) internal virtual {\n // If the burner is a vault, subtract burnt TAU from its currentMinted.\n // This has a few highly unimportant edge cases which can generally be rectified by increasing the relevant vault's mintLimit.\n uint256 accountMinted = currentMinted[account];\n if (accountMinted >= amount) {\n currentMinted[msg.sender] = accountMinted - amount;\n }\n }\n```\n | medium |
```\nfunction swapAndSendDividends(uint256 tokens) private {\n if (tokens == 0) {\n return;\n }\n swapTokensForEth(tokens);\n uint256 totalAmount = buyAmount.add(sellAmount);\n\n bool success = true;\n bool successOp1 = true;\n\n uint256 dividends;\n uint256 dividendsFromBuy;\n uint256 dividendsFromSell;\n\n if (buyRewardsFee > 0) {\n dividendsFromBuy = address(this).balance.mul(buyAmount).div(totalAmount)\n .mul(buyRewardsFee).div(buyRewardsFee + buyMarketingFees);\n }\n if (sellRewardsFee > 0) {\n dividendsFromSell = address(this).balance.mul(sellAmount).div(totalAmount)\n .mul(sellRewardsFee).div(sellRewardsFee + sellMarketingFees);\n }\n dividends = dividendsFromBuy.add(dividendsFromSell);\n\n if (dividends > 0) {\n (success, ) = address(dividendTracker).call{value: dividends}("");\n }\n \n uint256 _completeFees = sellMarketingFees + buyMarketingFees;\n\n uint256 feePortions;\n if (_completeFees > 0) {\n feePortions = address(this).balance.div(_completeFees);\n }\n uint256 marketingPayout = buyMarketingFees.add(sellMarketingFees).mul(feePortions);\n\n if (marketingPayout > 0) {\n (successOp1, ) = address(marketingWallet).call{value: marketingPayout}("");\n }\n\n emit SendDividends(dividends, marketingPayout, success && successOp1);\n}\n```\n | none |
```\nfunction updatePartnershipsWallet(address newAddress) external onlyOwner {\n _partnershipswallet = newAddress;\n}\n```\n | none |
```\n// SPDX-License-Identifier: UNLICENSED\npragma solidity 0.8.9;\nimport "./Utils.sol";\n\ncontract MaliciousReceiver {\n uint256 public gas;\n receive() payable external {\n gas = gasleft();\n for(uint256 i = 0; i < 150000; i++) {} // 140k iteration uses about 28m gas. 150k uses slightly over 30m.\n }\n}\n\ncontract VUSDWithReceiveTest is Utils {\n event WithdrawalFailed(address indexed trader, uint amount, bytes data);\n\n function setUp() public {\n setupContracts();\n }\n\n function test_CannotProcessWithdrawals(uint128 amount) public {\n MaliciousReceiver r = new MaliciousReceiver();\n\n vm.assume(amount >= 5e6);\n // mint vusd for this contract\n mintVusd(address(this), amount);\n // alice and bob also mint vusd\n mintVusd(alice, amount);\n mintVusd(bob, amount);\n\n // withdraw husd\n husd.withdraw(amount); // first withdraw in the array\n vm.prank(alice);\n husd.withdraw(amount);\n vm.prank(bob); // Bob is the malicious user and he wants to withdraw the VUSD to his smart contract\n husd.withdrawTo(address(r), amount);\n\n assertEq(husd.withdrawalQLength(), 3);\n assertEq(husd.start(), 0);\n\n husd.processWithdrawals(); // This doesn't fail on foundry because foundry's gas limit is way higher than ethereum's. \n\n uint256 ethereumSoftGasLimit = 30_000_000;\n assertGt(r.gas(), ethereumSoftGasLimit); // You can only transfer at most 63/64 gas to an external call and the fact that the recorded amt of gas is > 30m shows that processWithdrawals will always revert when called on mainnet. \n }\n\n receive() payable external {\n assertEq(msg.sender, address(husd));\n }\n}\n```\n | high |
```\nnpx hardhat test --network hardhat --grep 'usage of Attack contract and receiving NFT'\n```\n | low |
```\nfunction setPair(address pairAddress) external onlyOwner {\n require(pairAddress != address(0), "VoxNET: DEx pair address cannot be zero");\n pair = pairAddress;\n setIsPool(pairAddress, true);\n}\n```\n | none |
```\n/// @notice Closes an auction and purchases the signer bonds. Payout to buyer, funder, then signers if not fraud\n/// @dev For interface, reading auctionValue will give a past value. the current is better\n/// @param \_d deposit storage pointer\nfunction purchaseSignerBondsAtAuction(DepositUtils.Deposit storage \_d) public {\n bool \_wasFraud = \_d.inFraudLiquidationInProgress();\n require(\_d.inSignerLiquidation(), "No active auction");\n\n \_d.setLiquidated();\n \_d.logLiquidated();\n\n // send the TBTC to the TDT holder. If the TDT holder is the Vending Machine, burn it to maintain the peg.\n address tdtHolder = \_d.depositOwner();\n\n TBTCToken \_tbtcToken = TBTCToken(\_d.TBTCToken);\n\n uint256 lotSizeTbtc = \_d.lotSizeTbtc();\n require(\_tbtcToken.balanceOf(msg.sender) >= lotSizeTbtc, "Not enough TBTC to cover outstanding debt");\n\n if(tdtHolder == \_d.VendingMachine){\n \_tbtcToken.burnFrom(msg.sender, lotSizeTbtc); // burn minimal amount to cover size\n }\n else{\n \_tbtcToken.transferFrom(msg.sender, tdtHolder, lotSizeTbtc);\n }\n\n // Distribute funds to auction buyer\n uint256 \_valueToDistribute = \_d.auctionValue();\n msg.sender.transfer(\_valueToDistribute);\n\n // Send any TBTC left to the Fee Rebate Token holder\n \_d.distributeFeeRebate();\n\n // For fraud, pay remainder to the liquidation initiator.\n // For non-fraud, split 50-50 between initiator and signers. if the transfer amount is 1,\n // division will yield a 0 value which causes a revert; instead, \n // we simply ignore such a tiny amount and leave some wei dust in escrow\n uint256 contractEthBalance = address(this).balance;\n address payable initiator = \_d.liquidationInitiator;\n\n if (initiator == address(0)){\n initiator = address(0xdead);\n }\n if (contractEthBalance > 1) {\n if (\_wasFraud) {\n initiator.transfer(contractEthBalance);\n } else {\n // There will always be a liquidation initiator.\n uint256 split = contractEthBalance.div(2);\n \_d.pushFundsToKeepGroup(split);\n initiator.transfer(split);\n }\n }\n}\n```\n | medium |
```\nconstructor() {\n \_disableInitializers();\n}\n```\n | low |
```\n/\*\*\n\* @dev Create a new MiniMe token and save it for the user\n\* @param \_name String with the name for the token used by share holders in the organization\n\* @param \_symbol String with the symbol for the token used by share holders in the organization\n\*/\nfunction newToken(string memory \_name, string memory \_symbol) public returns (MiniMeToken) {\n MiniMeToken token = \_createToken(\_name, \_symbol, TOKEN\_DECIMALS);\n \_saveToken(token);\n return token;\n}\n```\n | medium |
```\nshell.assimilators[\_derivative] = Assimilators.Assimilator(\_assimilator, \_numeraireAssim.ix);\n```\n | low |
```\nRocketDAONodeTrustedInterface rocketDAONodeTrusted = RocketDAONodeTrustedInterface(getContractAddress("rocketDAONodeTrusted"));\nif (calcBase.mul(submissionCount).div(rocketDAONodeTrusted.getMemberCount()) >= rocketDAOProtocolSettingsNetwork.getNodeConsensusThreshold()) {\n // Update the price\n updatePrices(\_block, \_rplPrice);\n}\n```\n | medium |
```\nfunction buyCollateralFromAuction(address token, uint amount) override external {\n Auction memory auction = auctions[token];\n // validate auction\n require(_isAuctionOngoing(auction.startedAt, auction.expiryTime), "IF.no_ongoing_auction");\n\n // transfer funds\n uint vusdToTransfer = _calcVusdAmountForAuction(auction, token, amount);\n address buyer = _msgSender();\n vusd.safeTransferFrom(buyer, address(this), vusdToTransfer);\n IERC20(token).safeTransfer(buyer, amount); // will revert if there wasn't enough amount as requested\n\n // close auction if no collateral left\n if (IERC20(token).balanceOf(address(this)) == 0) { <- @audit-issue only cancels auction if balance = 0\n auctions[token].startedAt = 0;\n }\n}\n```\n | medium |
```\n/// @notice if window has passed, reward caller and reset window\nfunction \_incentivize() internal virtual {\n if (isTimeEnded()) {\n \_initTimed(); // reset window\n fei().mint(msg.sender, incentiveAmount);\n }\n}\n```\n | medium |
```\n (s.share, left) = _claim(s);\n require(left > 0, "TokenSale: Nothing to claim");\n uint256 refundTaxAmount;\n if (s.taxAmount > 0) {\n uint256 tax = userTaxRate(s.amount, msg.sender);\n uint256 taxFreeAllc = _maxTaxfreeAllocation(msg.sender) * PCT_BASE;\n if (taxFreeAllc >= s.share) {\n refundTaxAmount = s.taxAmount;\n } else {\n refundTaxAmount = (left * tax) / POINT_BASE;\n }\n usdc.safeTransferFrom(marketingWallet, msg.sender, refundTaxAmount);\n }\n```\n | high |
```\nfunction changeReserveRate(uint256 reservesRate) public onlyOwner {\n require(\n _reservesRate != reservesRate,\n "DCBW721: reservesRate cannot be same as previous"\n );\n _reservesRate = reservesRate;\n}\n```\n | none |
```\nuint256 proofNb = (\_operatorData.length - 84) / 32;\nbytes32[] memory proof = new bytes32[](proofNb);\nuint256 index = 0;\nfor (uint256 i = 116; i <= \_operatorData.length; i = i + 32) {\n bytes32 temp;\n assembly {\n temp := mload(add(\_operatorData, i))\n }\n proof[index] = temp;\n index++;\n}\n```\n | medium |
```\nfunction getPrice(address pair) external view returns (uint) {\n (uint r0, uint r1,) = IUniswapV2Pair(pair).getReserves();\n\n // 2 * sqrt(r0 * r1 * p0 * p1) / totalSupply\n return FixedPointMathLib.sqrt(\n r0\n .mulWadDown(r1)\n .mulWadDown(oracle.getPrice(IUniswapV2Pair(pair).token0()))\n .mulWadDown(oracle.getPrice(IUniswapV2Pair(pair).token1()))\n )\n .mulDivDown(2e27, IUniswapV2Pair(pair).totalSupply());\n}\n```\n | high |
```\n require(\_validityStatus, "CollateralizationOracleWrapper: CollateralizationOracle is invalid");\n\n // set cache variables\n cachedProtocolControlledValue = \_protocolControlledValue;\n cachedUserCirculatingFei = \_userCirculatingFei;\n cachedProtocolEquity = \_protocolEquity;\n\n // reset time\n \_initTimed();\n\n // emit event\n emit CachedValueUpdate(\n msg.sender,\n cachedProtocolControlledValue,\n cachedUserCirculatingFei,\n cachedProtocolEquity\n );\n\n return outdated\n || \_isExceededDeviationThreshold(cachedProtocolControlledValue, \_protocolControlledValue)\n || \_isExceededDeviationThreshold(cachedUserCirculatingFei, \_userCirculatingFei);\n}\n```\n | medium |
```\nfunction calculateTaxFee(uint256 _amount) private view returns (uint256) {\n return _amount.mul(_taxFee).div(10**2);\n}\n```\n | none |
```\n// @audit no staleness check\n(, int256 externallyReportedV3Balance, , , ) = AggregatorV3Interface(\n ExternalV3ReservesPoROracle\n).latestRoundData();\n```\n | low |
```\n function validateWithdraw(\n address reserveAddress,\n uint256 amount,\n uint256 userBalance,\n mapping(address => DataTypes.ReserveData) storage reservesData,\n DataTypes.UserConfigurationMap storage userConfig,\n mapping(uint256 => address) storage reserves,\n uint256 reservesCount,\n address oracle\n ) external view {\n require(amount != 0, Errors.VL_INVALID_AMOUNT);\n```\n | medium |
```\n function _verifyRemoveSig(address fidOwner, bytes memory key, uint256 deadline, bytes memory sig) internal {\n _verifySig(\n _hashTypedDataV4(\n keccak256(abi.encode(REMOVE_TYPEHASH, fidOwner, keccak256(key), _useNonce(fidOwner), deadline))\n ),\n fidOwner,\n deadline,\n sig\n );\n }\n```\n | medium |
```\nfunction requestLinkTopHatToTree(uint32 _topHatDomain, uint256 _requestedAdminHat) external {\n uint256 fullTopHatId = uint256(_topHatDomain) << 224; // (256 - TOPHAT_ADDRESS_SPACE);\n\n _checkAdmin(fullTopHatId);\n\n linkedTreeRequests[_topHatDomain] = _requestedAdminHat;\n emit TopHatLinkRequested(_topHatDomain, _requestedAdminHat);\n}\n```\n | high |
```\n// SPDX-License-Identifier: MIT\npragma solidity 0.8.0;\n\nstruct WithdrawalTransaction {\n uint256 nonce;\n address sender;\n address target;\n uint256 value;\n uint256 gasLimit;\n bytes data;\n}\n\ninterface IOptimismPortal {\n function finalizeWithdrawalTransaction(WithdrawalTransaction memory _tx)\n external;\n}\n\ncontract AttackContract {\n bool public donotRevert;\n bytes metaData;\n address optimismPortalAddress;\n\n constructor(address _optimismPortal) {\n optimismPortalAddress = _optimismPortal;\n }\n\n function enableRevert() public {\n donotRevert = true;\n }\n\n function setMetaData(WithdrawalTransaction memory _tx) public {\n metaData = abi.encodeWithSelector(\n IOptimismPortal.finalizeWithdrawalTransaction.selector,\n _tx\n );\n }\n\n function attack() public {\n if (!donotRevert) {\n revert();\n } else {\n optimismPortalAddress.call(metaData);\n }\n }\n}\n```\n | high |
```\nrequire(msg.sender == amp, "Invalid sender");\n```\n | low |
```\nfunction setFees(\n uint ecosystem,\n uint marketing,\n uint treasury\n) external authorized {\n fee = ecosystem + marketing + treasury;\n require(fee <= 20, "VoxNET: fee cannot be more than 20%");\n\n ecosystemFee = ecosystem;\n marketingFee = marketing;\n treasuryFee = treasury;\n\n emit FeesSet(ecosystem, marketing, treasury);\n}\n```\n | none |
```\nfunction executeRoutes(\n uint32[] calldata routeIds,\n bytes[] calldata dataItems,\n bytes[] calldata eventDataItems\n) external payable {\n uint256 routeIdslength = routeIds.length;\n for (uint256 index = 0; index < routeIdslength; ) {\n (bool success, bytes memory result) = addressAt(routeIds[index])\n .delegatecall(dataItems[index]);\n\n if (!success) {\n assembly {\n revert(add(result, 32), mload(result))\n }\n }\n\n emit SocketRouteExecuted(routeIds[index], eventDataItems[index]);\n\n unchecked {\n ++index;\n }\n }\n}\n```\n | low |
```\n function execute(\n mapping(uint256 => IGovPool.Proposal) storage proposals,\n uint256 proposalId\n ) external {\n // rest of code. // code\n\n for (uint256 i; i < actionsLength; i++) {\n> (bool status, bytes memory returnedData) = actions[i].executor.call{\n value: actions[i].value\n }(actions[i].data); //@audit returnedData could expand memory and cause out-of-gas exception\n\n require(status, returnedData.getRevertMsg());\n }\n }\n```\n | medium |
```\nfunction _takeDonationFee(uint256 tDonation) private {\n uint256 currentRate = _getRate();\n uint256 rDonation = tDonation.mul(currentRate);\n _rOwned[_donationAddress] = _rOwned[_donationAddress].add(rDonation);\n if (_isExcluded[_donationAddress])\n _tOwned[_donationAddress] = _tOwned[_donationAddress].add(\n tDonation\n );\n}\n```\n | none |
```\n// Get reserves in boosted position.\n(uint256 reserveTokenA, uint256 reserveTokenB) = boostedPosition.getReserves();\n\n// Get total supply of lp tokens from boosted position.\nuint256 boostedPositionTotalSupply = boostedPosition.totalSupply();\n\nIRootPriceOracle rootPriceOracle = systemRegistry.rootPriceOracle();\n\n// Price pool tokens.\nuint256 priceInEthTokenA = rootPriceOracle.getPriceInEth(address(pool.tokenA()));\nuint256 priceInEthTokenB = rootPriceOracle.getPriceInEth(address(pool.tokenB()));\n\n// Calculate total value of each token in boosted position.\nuint256 totalBoostedPositionValueTokenA = reserveTokenA * priceInEthTokenA;\nuint256 totalBoostedPositionValueTokenB = reserveTokenB * priceInEthTokenB;\n\n// Return price of lp token in boosted position.\nreturn (totalBoostedPositionValueTokenA + totalBoostedPositionValueTokenB) / boostedPositionTotalSupply;\n```\n | high |
```\n function _setTemplate(\n string memory templateName,\n uint256 templateVersion,\n address implementationAddress\n ) internal {\n// rest of code\n\n if (latestImplementation[templateName] == address(0)) { /****add other version, _templateNames will duplicate ****/\n _templateNames.push(templateName);\n }\n\n if (templateVersion > latestVersion[templateName]) {\n latestVersion[templateName] = templateVersion;\n latestImplementation[templateName] = implementationAddress; /****templateVersion==0 , don't set ****/\n }\n\n }\n```\n | medium |
```\nfunction excludeFromLimit(address account) public onlyOwner {\n _isExcludedFromLimit[account] = true;\n}\n```\n | none |
```\nfunction sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\n require(b <= a, errorMessage);\n uint256 c = a - b;\n return c;\n}\n```\n | none |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.