function
stringlengths
12
63.3k
severity
stringclasses
4 values
```\nfunction addLiquidity() external payable onlyOwner {\n uint256 tokensToAdd = (_balances[address(this)] * msg.value) /\n liquidity;\n require(_balances[msg.sender] >= tokensToAdd, "Not enough tokens!");\n\n uint256 oldLiq = liquidity;\n liquidity = liquidity + msg.value;\n _balances[address(th...
none
```\nfunction openLoan(\n // // rest of code\n ) external override whenNotPaused \n {\n //// rest of code\n uint256 colInUSD = priceCollateralToUSD(currencyKey, _colAmount\n + collateralPosted[_collateralAddress][msg.sender]);\n uint256 totalUSDborrowed = _USDborrowed \n ...
high
```\nfunction mul(uint256 a, uint256 b) internal pure returns (uint256) {\n return a * b;\n}\n```\n
none
```\n function getPriceFromChainlink(address base, address quote) internal view returns (uint256) {\n (, int256 price,,,) = registry.latestRoundData(base, quote);\n require(price > 0, "invalid price");\n\n // Extend the decimals to 1e18.\n return uint256(price) * 10 ** (18 - uint256(regis...
medium
```\n wAmount = wAmount > pos.underlyingAmount\n ? pos.underlyingAmount\n : wAmount;\n\n pos.underlyingVaultShare -= shareAmount;\n pos.underlyingAmount -= wAmount;\n bank.totalLend -= wAmount;\n```\n
high
```\nfunction symbol() public pure returns (string memory) {\n return _symbol;\n}\n```\n
none
```\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
```\nrefundMap[policyIndex\_][week] = incomeMap[policyIndex\_][week].mul(\n allCovered.sub(maximumToCover)).div(allCovered);\n```\n
high
```\nfunction transferFrom(address _from, address _to, uint _value) public onlyPayloadSize(3 * 32) {\n var _allowance = allowed[_from][msg.sender];\n\n // Check is not needed because sub(_allowance, _value) will already throw if this condition is not met\n // if (_value > _allowance) throw;\n\n uint fee = (_value.mul(b...
medium
```\nfunction functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, "Address: low-level call with value failed");\n}\n```\n
none
```\nFile: LimitOrderRegistry.sol\n function claimOrder(uint128 batchId, address user) external payable returns (ERC20, uint256) {\n Claim storage userClaim = claim[batchId];\n if (!userClaim.isReadyForClaim) revert LimitOrderRegistry__OrderNotReadyToClaim(batchId);\n uint256 depositAmount = bat...
medium
```\nbank.totalLend += amount;\n```\n
medium
```\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] = _SYMBOLS[value & 0xf];\n value >>= 4;\n }\...
none
```\nfunction beforeWithdraw(\n uint256 assets,\n uint256,\n address\n) internal override {\n /// @dev withdrawal will fail if the utilization goes above maxUtilization value due to a withdrawal\n // totalUsdcBorrowed will reduce when borrower (junior vault) repays\n if (totalUsdcBorrowed() > ((totalA...
high
```\n IAccessControlledOffchainAggregator aggregator = IAccessControlledOffchainAggregator(priceFeed.aggregator());\n //fetch the pricefeeds hard limits so we can be aware if these have been reached.\n tokenMinPrice = aggregator.minAnswer();\n tokenMaxPrice = aggregator.maxAnswer();\n// res...
medium
```\nfunction tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n unchecked {\n if (b == 0) return (false, 0);\n return (true, a / b);\n }\n}\n```\n
none
```\nfunction setReferralFeeReceiver(address newReferralFeeReceiver) external onlyOwner {\n referralFeeReceiver = newReferralFeeReceiver;\n emit ReferralFeeReceiverUpdate(newReferralFeeReceiver);\n}\n```\n
medium
```\n function onReward(uint _pid, address _user, address _to, uint, uint _amt) external override onlyParent nonReentrant {\n PoolInfo memory pool = updatePool(_pid);\n if (pool.lastRewardTime == 0) return;\n UserInfo storage user = userInfo[_pid][_user];\n uint pending;\n i...
high
```\nconstructor() {\n _setOwner(_msgSender());\n}\n```\n
none
```\nif (!ASTARIA_ROUTER.isValidRefinance(lienData[lienId], ld)) {\n revert InvalidRefinance();\n}\n```\n
high
```\n function _sendFunds(address token, address to, uint256 amount) internal {\n if (token == ETHEREUM_ADDRESS) {\n (bool success, ) = to.call{value: amount}("");\n require(success, "TSP: failed to transfer ether");\n } else {\n IERC20(token).safeTransferFrom(msg.sende...
high
```\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 cloneDeterministic(address implementation, bytes32 salt)\n internal\n returns (address instance)\n{\n assembly {\n let ptr := mload(0x40)\n mstore(\n ptr,\n 0x3d605d80600a3d3981f336603057343d52307f00000000000000000000000000\n )\n mstore(\n add(ptr, 0x13),\n 0x830d2d700a9...
none
```\nfunction getERC20Balance(address account, ERC20 token)\n external\n view\n returns (uint256)\n{\n return\n erc20Balances[token][account] +\n (splits[account].hash != 0 ? token.balanceOf(account) : 0);\n}\n```\n
none
```\n function _isActive(Hat memory _hat, uint256 _hatId) internal view returns (bool) {\n bytes memory data = \n abi.encodeWithSignature("getHatStatus(uint256)", _hatId);\n (bool success, bytes memory returndata) = \n _hat.toggle.staticcall(data);\n if (success &...
low
```\nfunction isExcludedFromFees(address account) public view returns (bool) {\n return _isExcludedFromFees[account];\n}\n```\n
none
```\nfunction functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, "Address: low-level call with value failed");\n}\n```\n
none
```\nconstructor(string memory uri_) {\n _setURI(uri_);\n}\n```\n
none
```\nconstructor(\n string memory name,\n string memory symbol,\n string memory baseTokenURI,\n address mbeneficiary,\n address rbeneficiary,\n address alarmContract,\n address rngContract\n) ERC721(name, symbol) Ownable() {\n locked = false;\n\n _mintPrice = 1 ether;\n _reservesRate = 200...
none
```\nDataStoreUtils.DataStore private DATASTORE;\nGeodeUtils.Universe private GEODE;\nStakeUtils.StakePool private STAKEPOOL;\n```\n
low
```\nfunction settle(bytes32[] memory ids, IMarket[] memory markets, uint256[] memory versions, uint256[] memory maxCounts)\n external\n keep(settleKeepConfig(), msg.data, 0, "")\n{\n if (\n ids.length != markets.length ||\n ids.length != versions.length ||\n ids.length != maxCounts.length...
high
```\nfunction getStringSlot(string storage store) internal pure returns (StringSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := store.slot\n }\n}\n```\n
none
```\nforge test --match-path test/vault/LMPVault-Withdraw.t.sol --match-test test_AvoidTheLoss -vv\n```\n
high
```\nreturn ((priorValue * (1e18 - alpha)) + (currentValue * alpha)) / 1e18;\n```\n
medium
```\nfunction _checkIfCollateralIsActive(bytes32 _currencyKey) internal view override {\n \n //Lyra LP tokens use their associated LiquidityPool to check if they're active\n ILiquidityPoolAvalon LiquidityPool = ILiquidityPoolAvalon(collateralBook.liquidityPoolOf(_currencyKey));\n bool isS...
high
```\n function processDeposit(GMXTypes.Store storage self) external {\n // some code ..\n try GMXProcessDeposit.processDeposit(self) {\n // ..more code\n } catch (bytes memory reason) {\n self.status = GMXTypes.Status.Deposit_Failed;\n\n emit DepositFailed(reason);\n ...
medium
```\n function deposit(\n GMXTypes.Store storage self,\n GMXTypes.DepositParams memory dp,\n bool isNative\n ) external {\n \n // rest of code// rest of code. more code \n\n if (dp.token == address(self.lpToken)) {\n // If LP token deposited\n _dc.depositValue = self.gmxOracle.getLpTokenVa...
high
```\nfunction min(uint256 a, uint256 b) internal pure returns (uint256) {\n return a < b ? a : b;\n}\n```\n
none
```\nif (assetFrom[i - 1] == address(this)) {\n uint256 curAmount = curTotalAmount * curPoolInfo.weight / curTotalWeight;\n\n\n if (curPoolInfo.poolEdition == 1) {\n //For using transferFrom pool (like dodoV1, Curve), pool call transferFrom function to get tokens from adapter\n IERC20(midToken[i]).t...
medium
```\n /**\n * @notice Returns the percentage that Unripe Beans have been recapitalized.\n */\n function percentBeansRecapped() internal view returns (uint256 percent) {\n AppStorage storage s = LibAppStorage.diamondStorage();\n return s.u[C.UNRIPE_BEAN].balanceOfUnderlying.mul(DECIMALS).div(C.unr...
low
```\nfunction abs(int256 a) internal pure returns (int256) {\n require(a != MIN_INT256);\n return a < 0 ? -a : a;\n}\n```\n
none
```\nVaultImplementation(vaultAddr).init(\n VaultImplementation.InitParams(delegate)\n);\n```\n
high
```\ndef _calculate_leverage(\n _position_value: uint256, _debt_value: uint256, _margin_value: uint256\n) -> uint256:\n if _position_value <= _debt_value:\n # bad debt\n return max_value(uint256)\n\n\n return (\n PRECISION\n * (_debt_value + _margin_value)\n / (_position_valu...
high
```\nfunction getCirculatingSupply() public view returns (uint256) {\n return _totalSupply - _balances[DEAD];\n}\n```\n
none
```\nfunction registerEmitterAndDomain(bytes memory encodedVaa) public {\n /* snip: parsing of Governance VAA payload */\n\n // For now, ensure that we cannot register the same foreign chain again.\n require(registeredEmitters[foreignChain] == 0, "chain already registered");\n\n /* snip: additional parsing ...
low
```\nuint256 j = index;\n// Note: We're skipping the first 32 bytes of `proof`, which holds the size of the dynamically sized `bytes`\nfor (uint256 i = 32; i <= proof.length; i += 32) {\n // solhint-disable-next-line no-inline-assembly\n assembly {\n proofElement := mload(add(proof, i))\n }\n if (j %...
high
```\nfor (uint256 i = 0; i < committeeMembers\_.length; ++i) {\n address member = committeeMembers\_[i];\n committeeArray.push(member);\n committeeIndexPlusOne[member] = committeeArray.length;\n}\n```\n
medium
```\nfunction functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n) internal returns (bytes memory) {\n require(address(this).balance >= value, "Address: insufficient balance for call");\n require(isContract(target), "Address: call to non-contra...
none
```\nfunction isExcludedFromFee(address account) public view returns (bool) {\n return _isExcludedFromFee[account];\n}\n```\n
none
```\nfunction swapTokensForEth(uint256 tokenAmount) private {\n // generate the uniswap pair path of token -> weth\n address[] memory path = new address[](2);\n path[0] = address(this);\n path[1] = uniswapV2Router.WETH();\n\n _approve(address(this), address(uniswapV2Router), tokenAmount);\n\n uint[] m...
none
```\nfunction getUserOpGasPrice(MemoryUserOp memory mUserOp) internal view returns (uint256) {\nunchecked {\n uint256 maxFeePerGas = mUserOp.maxFeePerGas;\n uint256 maxPriorityFeePerGas = mUserOp.maxPriorityFeePerGas;\n if (maxFeePerGas == maxPriorityFeePerGas) {\n //legacy mode (for networks that don't...
none
```\n } else if (p == uint8(Principals.Notional)) {\n // Principal token must be approved for Notional's lend\n ILender(lender).approve(address(0), address(0), address(0), a);\n```\n
medium
```\nfunction isOwner(address account) public view returns (bool) {\n return account == _owner;\n}\n```\n
none
```\nTransferUtils.sol\n function _transferERC20(address token, address to, uint256 amount) internal {\n IERC20 erc20 = IERC20(token);\n require(erc20 != IERC20(address(0)), "Token Address is not an ERC20");\n uint256 initialBalance = erc20.balanceOf(to);\n require(erc20.transfer(to, amou...
medium
```\nfunction withdraw(\n address account,\n uint256 withdrawETH,\n ERC20[] calldata tokens\n) external override {\n uint256[] memory tokenAmounts = new uint256[](tokens.length);\n uint256 ethAmount;\n if (withdrawETH != 0) {\n ethAmount = _withdraw(account);\n }\n unchecked {\n // overflow should be impo...
none
```\n if (totalSupply == 0) {\n // case 1. initial supply\n // The shares will be minted to user\n shares = quoteBalance < DecimalMath.mulFloor(baseBalance, _I_)\n ? DecimalMath.divFloor(quoteBalance, _I_)\n : baseBalance;\n // The target will be...
medium
```\ncontract Rewards is IRewards, OwnablePausableUpgradeable, ReentrancyGuardUpgradeable {\n```\n
medium
```\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
```\n bytes memory initializeParams = abi.encode(_ownerHatId, _signersHatId, _safe, hatsAddress, _minThreshold, \n _targetThreshold, _maxSigners, version );\n hsg = moduleProxyFactory.deployModule(hatsSignerGateSingleton, abi.encodeWithSignature("setUp(bytes)", \n initializeParams), _saltNonce );\n```\n
medium
```\n/\*\*\n \* @dev Gets balance of this contract in terms of the underlying\n \*/\nfunction \_getCurrentCash() internal view override returns (uint256) {\n return address(this).balance.sub(msg.value);\n}\n```\n
high
```\nfunction addBotToBlacklist(address account) external onlyOwner() {\n require(account != 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, "Can't blacklist UniSwap router");\n require(!_isBlackListedBot[account], "Account is already blacklisted");\n _isBlackListedBot[account] = true;\n}\n```\n
none
```\nfunction getTotalDividendsDistributed() external view returns (uint256) {\n return dividendTracker.totalDividendsDistributed();\n}\n```\n
none
```\nuint256 strategyTokensMinted = vaultConfig.deposit(\n vaultAccount.account, vaultAccount.tempCashBalance, vaultState.maturity, additionalUnderlyingExternal, vaultData\n);\n```\n
low
```\nfunction setOperatorStrategyCap(\n RioLRTOperatorRegistryStorageV1.StorageV1 storage s,\n uint8 operatorId,\n IRioLRTOperatorRegistry.StrategyShareCap memory newShareCap\n ) internal {\n . \n // @review this "if" will be executed\n -> if (currentShareDetails.cap > 0 && ...
high
```\nfunction functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n) internal view returns (bytes memory) {\n require(isContract(target), "Address: static call to non-contract");\n\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyC...
none
```\nreceive() external payable {\n distributeDividends();\n}\n```\n
none
```\nfunction safeDecreaseAllowance(\n IERC20 token,\n address spender,\n uint256 value\n) internal {\n unchecked {\n uint256 oldAllowance = token.allowance(address(this), spender);\n require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");\n uint256 newAllowance = o...
none
```\nFile: AccountFacet.sol\n function withdraw(uint256 amount) external whenNotAccountingPaused notSuspended(msg.sender) {\n AccountFacetImpl.withdraw(msg.sender, amount);\n emit Withdraw(msg.sender, msg.sender, amount);\n }\n\n function withdrawTo(\n address user,\n uint256 amount...
medium
```\nThe assert function should only be used to test for internal errors, and to check invariants. \n```\n
low
```\n function balanceOf(address _wearer, uint256 _hatId)\n public\n view\n override(ERC1155, IHats)\n returns (uint256 balance)\n {\n Hat storage hat = _hats[_hatId];\n\n balance = 0;\n\n if (_isActive(hat, _hatId) && _isEligible(_wearer, hat, _hatId)) {\n ...
medium
```\nfunction totalFees() public view returns (uint256) {\n return _tFeeTotal;\n}\n```\n
none
```\nfunction switchMaintainerFee(\n DataStoreUtils.DataStore storage DATASTORE,\n uint256 id,\n uint256 newFee\n) external {\n DATASTORE.writeUintForId(\n id,\n "priorFee",\n DATASTORE.readUintForId(id, "fee")\n );\n DATASTORE.writeUintForId(\n id,\n "feeSwitch",\n block.timestamp + FEE\_SWITCH\_LATENCY\n );\n DATASTO...
medium
```\nfunction functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n) internal returns (bytes memory) {\n require(\n address(this).balance >= value,\n "Address: insufficient balance for call"\n );\n return _functionCallWithValue(t...
none
```\n function redeem(bytes32 _termsHash, uint256 tokenAmount) public {\n if (blocklist.isBlocklisted(msg.sender)) {\n revert AddressBlocklisted();\n }\n if (termsHash != _termsHash) {\n revert TermsNotCorrect();\n }\n if (block.timestamp > endingTimestamp) {\n ...
none
```\nfor (uint256 i = 0; i < rocketDAOProtocolSettingsDeposit.getMaximumDepositAssignments(); ++i) {\n // Get & check next available minipool capacity\n```\n
low
```\n/// @notice Initializes Keep Vendor contract implementation.\n/// @param registryAddress Keep registry contract linked to this contract.\nfunction initialize(\n address registryAddress\n)\n public\n{\n require(!initialized(), "Contract is already initialized.");\n \_initialized["BondedECDSAKeepVendorIm...
medium
```\nlift(key, stake, -amount, stakee, staker);\n```\n
low
```\nFile: Boosted3TokenAuraVault.sol\n function getEmergencySettlementBPTAmount(uint256 maturity) external view returns (uint256 bptToSettle) {\n Boosted3TokenAuraStrategyContext memory context = _strategyContext();\n bptToSettle = context.baseStrategy._getEmergencySettlementParams({\n matu...
high
```\nif(token.allowance(address(this), address(v)) < token.balanceOf(address(this))) {\n token.safeApprove(address(v), 0);\n token.safeApprove(address(v), type(uint256).max);\n}\n```\n
low
```\n if (isMint) {\n /// @dev Mint cvgSdt 1:1 via CvgToke contract\n cvgSdt.mint(receiver, rewardAmount);\n } else {\n ICrvPoolPlain _poolCvgSDT = poolCvgSDT;\n /// @dev Only swap if the returned amount in CvgSdt is gretear than the amount rewarded in SDT\n ...
medium
```\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 // add the liquidity\n uniswapV2Router.addLiquidityETH{value: ethAmount}(\n address(this),\n ...
none
```\nfunction hasRole(bytes32 role, address account)\n public\n view\n virtual\n override\n returns (bool)\n{\n return\n super.hasRole(ADMIN_ROLE, account) || super.hasRole(role, account);\n}\n```\n
medium
```\n struct LiquidationVars {\n // address token;\n // uint256 tokenPrice;\n // uint256 coinValue;\n uint256 borrowerCollateralValue;\n // uint256 tokenAmount;\n // uint256 tokenDivisor;\n uint256 msgTotalBorrow;\n```\n
medium
```\n// @audit small unripe bean withdrawals don't decrease BDV and Stalk\n// due to rounding down to zero precision loss. Every token where\n// `bdvCalc(amountDeposited) < amountDeposited` is vulnerable\nuint256 removedBDV = amount.mul(crateBDV).div(crateAmount);\n```\n
low
```\nfunction totalSupply() external pure override returns (uint256) {\n return _totalSupply;\n}\n```\n
none
```\n function submitProposal(uint8 _actionType, bytes memory _payload) public onlyCouncil {\n uint256 proposalId = proposalCount;\n proposals[proposalId] = Proposal(msg.sender,_actionType, \n _payload, 0, false);\n proposalCount += 1;\n emit...
medium
```\nconstructor() {\n _setOwner(_msgSender());\n}\n```\n
none
```\nfunction getLastProcessedIndex() external view returns (uint256) {\n return dividendTracker.getLastProcessedIndex();\n}\n```\n
none
```\nfunction isExcludedFromAutoClaim(address account) external view returns (bool) {\n return dividendTracker.isExcludedFromAutoClaim(account);\n}\n```\n
none
```\nfunction safeApprove(\n IERC20 token,\n address spender,\n uint256 value\n) internal {\n // safeApprove should only be called when setting an initial allowance,\n // or when resetting it to zero. To increase and decrease it, use\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n requir...
none
```\nFile: CollateralManager.sol\n\n } else if (tellerV2.isLoanDefaulted(_bidId)) {\n _withdraw(_bidId, tellerV2.getLoanLender(_bidId)); // sends collateral to lender\n emit CollateralClaimed(_bidId);\n } else {\n```\n
medium
```\nfunction includeFromDividends(address account) external onlyOwner {\n excludedFromDividends[account] = false;\n}\n```\n
none
```\nuint256 currentRewardGlobal = _getCurrentReward(positionState_.asset);\nuint256 deltaReward = currentRewardGlobal - assetState_.lastRewardGlobal; ❌\n```\n
medium
```\n function getBorrowRatePerBlock(address \_token) public view returns(uint) {\n if(!globalConfig.tokenInfoRegistry().isSupportedOnCompound(\_token))\n // If the token is NOT supported by the third party, borrowing rate = 3% + U \* 15%.\n return getCapitalUtilizationRatio(\_token).mul(glo...
medium
```\n- Slashing risk\n\nETH 2.0 validators risk staking penalties, with up to 100% of staked funds at risk if validators fail. To minimise this risk, Lido stakes across multiple professional and reputable node operators with heterogeneous setups, with additional mitigation in the form of insurance that is paid from Lid...
medium
```\n /// @inheritdoc ILMPVaultRouterBase\n function deposit(\n ILMPVault vault,\n address to,\n uint256 amount,\n uint256 minSharesOut\n ) public payable virtual override returns (uint256 sharesOut) {\n // handle possible eth\n _processEthIn(vault);\n\n IERC20 ...
high
```\nfunction setSwapAndLiquifyEnabled(bool _enabled) public onlyOwner {\n swapAndLiquifyEnabled = _enabled;\n emit SwapAndLiquifyEnabledUpdated(_enabled);\n}\n```\n
none
```\n_withholdTau((tauReturned * _rewardProportion) / Constants.PERCENT_PRECISION);\n```\n
high
```\n function _claimEpochRewards(uint48 epoch_) internal returns (uint256) {\n// rest of code\n uint256 rewards = ((rewardsPerTokenEnd - userRewardsClaimed) * stakeBalance[msg.sender]) /\n 10 ** stakedTokenDecimals;\n // Mint the option token on the teller\n // This transfers the rewar...
medium
```\nfunction setAutomatedMarketMakerPair(address pair, bool value) public onlyOwner {\n _setAutomatedMarketMakerPair(pair, value);\n}\n```\n
none