function
stringlengths
12
63.3k
severity
stringclasses
4 values
```\n function _accumulateExternalRewards() internal override returns (uint256[] memory) {\n uint256 numExternalRewards = externalRewardTokens.length;\n\n auraPool.rewardsPool.getReward(address(this), true);\n\n uint256[] memory rewards = new uint256[](numExternalRewards);\n for (uint256 i; i < numExternalRewards; ) {\n ExternalRewardToken storage rewardToken = externalRewardTokens[i];\n uint256 newBalance = ERC20(rewardToken.token).balanceOf(address(this));\n\n // This shouldn't happen but adding a sanity check in case\n if (newBalance < rewardToken.lastBalance) {\n emit LiquidityVault_ExternalAccumulationError(rewardToken.token);\n continue;\n }\n\n rewards[i] = newBalance - rewardToken.lastBalance;\n rewardToken.lastBalance = newBalance;\n\n unchecked {\n ++i;\n }\n }\n return rewards;\n }\n// rest of code\n function _updateExternalRewardState(uint256 id_, uint256 amountAccumulated_) internal {\n // This correctly uses 1e18 because the LP tokens of all major DEXs have 18 decimals\n if (totalLP != 0)\n externalRewardTokens[id_].accumulatedRewardsPerShare +=\n (amountAccumulated_ * 1e18) /\n totalLP;\n }\n```\n
medium
```\nif (block.timestamp >= lien.start + lien.duration) {\n delta_t = uint256(lien.start + lien.duration - lien.last);\n} \n```\n
medium
```\nfunction addLiquidity(uint256 tokenAmount, uint256 ethAmount) private {\n _approve(address(this), address(uniswapV2Router), tokenAmount);\n\n uniswapV2Router.addLiquidityETH{value: ethAmount}(\n address(this),\n tokenAmount,\n 0, // slippage is unavoidable\n 0, // slippage is unavoidable\n deadAddress,\n block.timestamp\n );\n}\n```\n
none
```\n/// @param \_preimage The sha256 preimage of the digest\nfunction provideECDSAFraudProof(\n DepositUtils.Deposit storage \_d,\n uint8 \_v,\n bytes32 \_r,\n bytes32 \_s,\n bytes32 \_signedDigest,\n bytes memory \_preimage\n) public {\n require(\n !\_d.inFunding() && !\_d.inFundingFailure(),\n "Use provideFundingECDSAFraudProof instead"\n );\n require(\n !\_d.inSignerLiquidation(),\n "Signer liquidation already in progress"\n );\n require(!\_d.inEndState(), "Contract has halted");\n require(submitSignatureFraud(\_d, \_v, \_r, \_s, \_signedDigest, \_preimage), "Signature is not fraud");\n startSignerFraudLiquidation(\_d);\n}\n```\n
high
```\nconstructor() ERC20("Andy", "ANDY") {\n IDexRouter _dexRouter = IDexRouter(\n 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D\n );\n\n exemptFromLimits(address(_dexRouter), true);\n dexRouter = _dexRouter;\n\n dexPair = IDexFactory(_dexRouter.factory()).createPair(\n address(this),\n _dexRouter.WETH()\n );\n exemptFromLimits(address(dexPair), true);\n _setAutomatedMarketMakerPair(address(dexPair), true);\n\n uint256 _buyMarketingTax = 20;\n uint256 _buyProjectTax = 0;\n\n uint256 _sellMarketingTax = 20;\n uint256 _sellProjectTax = 0;\n\n uint256 _totalSupply = 1_000_000_000_000 * 10 ** decimals();\n\n maxTx = (_totalSupply * 10) / 1000;\n maxWallet = (_totalSupply * 10) / 1000;\n\n swapBackValueMin = (_totalSupply * 1) / 1000;\n swapBackValueMax = (_totalSupply * 2) / 100;\n\n buyMarketingTax = _buyMarketingTax;\n buyProjectTax = _buyProjectTax;\n buyTaxTotal = buyMarketingTax + buyProjectTax;\n\n sellMarketingTax = _sellMarketingTax;\n sellProjectTax = _sellProjectTax;\n sellTaxTotal = sellMarketingTax + sellProjectTax;\n\n marketingWallet = address(0xb30Fa23184D080fa7631b9eC13C7F58eb5B00Ae0);\n projectWallet = address(msg.sender);\n\n // exclude from paying fees or having max transaction amount\n exemptFromFees(msg.sender, true);\n exemptFromFees(address(this), true);\n exemptFromFees(address(0xdead), true);\n exemptFromFees(marketingWallet, true);\n\n exemptFromLimits(msg.sender, true);\n exemptFromLimits(address(this), true);\n exemptFromLimits(address(0xdead), true);\n exemptFromLimits(marketingWallet, true);\n\n transferOwnership(msg.sender);\n\n /*\n _mint is an internal function in ERC20.sol that is only called here,\n and CANNOT be called ever again\n */\n _mint(msg.sender, _totalSupply);\n}\n```\n
none
```\nfunction updateYield(uint256 vault) internal {\n AppStorage storage s = appStorage();\n STypes.Vault storage Vault = s.vault[vault];\n STypes.VaultUser storage TAPP = s.vaultUser[vault][address(this)];\n // Retrieve vault variables\n uint88 zethTotalNew = uint88(getZethTotal(vault)); // @dev(safe-cast)\n uint88 zethTotal = Vault.zethTotal;\n uint88 zethCollateral = Vault.zethCollateral;\n uint88 zethTreasury = TAPP.ethEscrowed;\n // Calculate vault yield and overwrite previous total\n if (zethTotalNew <= zethTotal) return;\n uint88 yield = zethTotalNew - zethTotal;\n Vault.zethTotal = zethTotalNew;\n // If no short records, yield goes to treasury\n if (zethCollateral == 0) {\n TAPP.ethEscrowed += yield;\n return;\n }\n // Assign yield to zethTreasury\n uint88 zethTreasuryReward = yield.mul(zethTreasury).divU88(zethTotal);\n yield -= zethTreasuryReward;\n // Assign tithe of the remaining yield to treasuryF\n uint88 tithe = yield.mulU88(vault.zethTithePercent());\n yield -= tithe;\n // Realize assigned yields\n TAPP.ethEscrowed += zethTreasuryReward + tithe;\n❌ Vault.zethYieldRate += yield.divU80(zethCollateral);\n Vault.zethCollateralReward += yield;\n}\n```\n
low
```\n// If a user is delegating back to themselves, they regain their community voting power, so adjust totals up\nif (_delegator == _delegatee) {\n _updateTotalCommunityVotingPower(_delegator, true);\n\n// If a user delegates away their votes, they forfeit their community voting power, so adjust totals down\n} else if (currentDelegate == _delegator) {\n _updateTotalCommunityVotingPower(_delegator, false);\n}\n```\n
medium
```\n function getTradingFee(uint256 quoteId) internal view returns (uint256 fee) {\n QuoteStorage.Layout storage quoteLayout = QuoteStorage.layout();\n Quote storage quote = quoteLayout.quotes[quoteId];\n Symbol storage symbol = SymbolStorage.layout().symbols[quote.symbolId];\n if (quote.orderType == OrderType.LIMIT) {\n fee =\n (LibQuote.quoteOpenAmount(quote) * quote.requestedOpenPrice * symbol.tradingFee) /\n 1e36;\n } else {\n fee = (LibQuote.quoteOpenAmount(quote) * quote.marketPrice * symbol.tradingFee) / 1e36;\n }\n }\n```\n
medium
```\nfunction transfer(address recipient, uint256 amount) public override returns (bool) {\n _transfer(_msgSender(), recipient, amount);\n return true;\n}\n```\n
none
```\nfunction refund(\n uint256 policyIndex\_,\n uint256 week\_,\n address who\_\n) external noReenter {\n Coverage storage coverage = coverageMap[policyIndex\_][week\_][who\_];\n\n require(!coverage.refunded, "Already refunded");\n\n uint256 allCovered = coveredMap[policyIndex\_][week\_];\n uint256 amountToRefund = refundMap[policyIndex\_][week\_].mul(\n coverage.amount).div(allCovered);\n coverage.amount = coverage.amount.mul(\n coverage.premium.sub(amountToRefund)).div(coverage.premium);\n coverage.refunded = true;\n\n IERC20(baseToken).safeTransfer(who\_, amountToRefund);\n\n if (eventAggregator != address(0)) {\n IEventAggregator(eventAggregator).refund(\n policyIndex\_,\n week\_,\n who\_,\n amountToRefund\n );\n }\n}\n```\n
high
```\n func (evm *EVM) Call(caller ContractRef, addr common.Address, input []byte, gas uint64, value *big.Int) (ret []byte, leftOverGas uint64, err error) { \n if addr == dump.MessagePasserAddress { \n statedumper.WriteMessage(caller.Address(), input) \n } \n```\n
medium
```\n if (validSignerCount == currentSignerCount) {\n newSignerCount = currentSignerCount;\n } else {\n newSignerCount = currentSignerCount - 1;\n }\n```\n
medium
```\nfunction toEthSignedMessageHash(\n bytes32 hash\n) internal pure returns (bytes32 message) {\n // 32 is the length in bytes of hash,\n // enforced by the type signature above\n /// @solidity memory-safe-assembly\n assembly {\n mstore(0x00, "\x19Ethereum Signed Message:\n32")\n mstore(0x1c, hash)\n message := keccak256(0x00, 0x3c)\n }\n}\n```\n
none
```\n uint256 received;\n {\n // Get the starting balance of the principal token\n uint256 starting = token.balanceOf(address(this));\n\n // Swap those tokens for the principal tokens\n ISensePeriphery(x).swapUnderlyingForPTs(adapter, s, lent, r);\n\n // Calculate number of principal tokens received in the swap\n received = token.balanceOf(address(this)) - starting;\n\n // Verify that we received the principal tokens\n if (received < r) {\n revert Exception(11, 0, 0, address(0), address(0));\n }\n }\n\n // Mint the Illuminate tokens based on the returned amount\n IERC5095(principalToken(u, m)).authMint(msg.sender, received);\n```\n
high
```\n function createGauge4pool(\n address _4pool,\n address _dai,\n address _usdc,\n address _usdt,\n address _cash\n ) external returns (address) {\n```\n
medium
```\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 // make the swap\n uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(\n tokenAmount,\n 0, // accept any amount of ETH\n path,\n address(this),\n block.timestamp\n );\n}\n```\n
none
```\nfunction claim(address user) external returns (uint256) {\n drop();\n \_captureNewTokensForUser(user);\n uint256 balance = userStates[user].balance;\n userStates[user].balance = 0;\n totalUnclaimed = uint256(totalUnclaimed).sub(balance).toUint112();\n\n // Transfer asset/reward token to user\n asset.transfer(user, balance);\n\n // Emit Claimed\n emit Claimed(user, balance);\n\n return balance;\n}\n```\n
high
```\nrequire(\n amount <= instantMintLimit - currentInstantMintAmount,\n "RateLimit: Mint exceeds rate limit"\n);\n```\n
low
```\nfunction byteLengthWithFallback(ShortString value, string storage store) internal view returns (uint256) {\n if (ShortString.unwrap(value) != _FALLBACK_SENTINEL) {\n return byteLength(value);\n } else {\n return bytes(store).length;\n }\n}\n```\n
none
```\nfunction _transferStandard(address sender, address recipient, uint256 tAmount) private {\n (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount);\n _rOwned[sender] = _rOwned[sender] - rAmount;\n _rOwned[recipient] = _rOwned[recipient] + rTransferAmount;\n _takeLiquidity(tLiquidity);\n _reflectFee(rFee, tFee);\n emit Transfer(sender, recipient, tTransferAmount);\n}\n```\n
none
```\n/**\n * @title GeoEmaAndCumSmaPump\n * @author Publius\n * @notice Stores a geometric EMA and cumulative geometric SMA for each reserve.\n * @dev A Pump designed for use in Beanstalk with 2 tokens.\n *\n * This Pump has 3 main features:\n * 1. Multi-block MEV resistence reserves\n * 2. MEV-resistant Geometric EMA intended for instantaneous reserve queries\n * 3. MEV-resistant Cumulative Geometric intended for SMA reserve queries\n *\n * Note: If an `update` call is made with a reserve of 0, the Geometric mean oracles will be set to 0.\n * Each Well is responsible for ensuring that an `update` call cannot be made with a reserve of 0.\n */\n```\n
high
```\n /**\n * @notice @inheritdoc GMXVault\n * @param self GMXTypes.Store\n * @param isNative Boolean as to whether user is depositing native asset (e.g. ETH, AVAX, etc.)\n */\n function deposit(\n GMXTypes.Store storage self,\n GMXTypes.DepositParams memory dp,\n bool isNative\n ) external {\n // rest of code\n self.status = GMXTypes.Status.Deposit;\n\n self.vault.mintFee(); ///<----------------------- @audit\n // rest of code\n```\n
medium
```\nfunction getCurrentMintingCount() external view returns (uint256) {\n return _tokenIds;\n}\n```\n
none
```\nrequire(\_arguments.tokenPrice != 0, "\_tokenPrice needs to be a non-zero amount");\n```\n
low
```\n // rest of code\n pushFeedbackToVault(_chainId, _vault, _relayerFee);\n xTransfer(_asset, _amount, _vault, _chainId, _slippage, _relayerFee);\n // rest of code\n```\n
medium
```\n function repayAccountPrimeDebtAtSettlement(\n PrimeRate memory pr,\n VaultStateStorage storage primeVaultState,\n uint16 currencyId,\n address vault,\n address account,\n int256 accountPrimeCash,\n int256 accountPrimeStorageValue\n ) internal returns (int256 finalPrimeDebtStorageValue, bool didTransfer) {\n// rest of code\n\n if (netPrimeDebtRepaid < accountPrimeStorageValue) {\n // If the net debt change is greater than the debt held by the account, then only\n // decrease the total prime debt by what is held by the account. The residual amount\n // will be refunded to the account via a direct transfer.\n netPrimeDebtChange = accountPrimeStorageValue;\n finalPrimeDebtStorageValue = 0;\n\n int256 primeCashRefund = pr.convertFromUnderlying(\n pr.convertDebtStorageToUnderlying(netPrimeDebtChange.sub(accountPrimeStorageValue)) //<--------@audit always ==0\n );\n TokenHandler.withdrawPrimeCash(\n account, currencyId, primeCashRefund, pr, false // ETH will be transferred natively\n );\n didTransfer = true;\n } else {\n```\n
high
```\n function setDefaults(uint32[6] memory defaults_) external override requiresAuth {\n // Restricted to authorized addresses\n defaultTuneInterval = defaults_[0];\n defaultTuneAdjustment = defaults_[1];\n minDebtDecayInterval = defaults_[2];\n minDepositInterval = defaults_[3];\n minMarketDuration = defaults_[4];\n minDebtBuffer = defaults_[5];\n }\n```\n
medium
```\nFile: TwoTokenPoolUtils.sol\n function _getTimeWeightedPrimaryBalance(\n TwoTokenPoolContext memory poolContext,\n StrategyContext memory strategyContext,\n uint256 poolClaim,\n uint256 oraclePrice,\n uint256 spotPrice\n ) internal view returns (uint256 primaryAmount) {\n // Make sure spot price is within oracleDeviationLimit of pairPrice\n strategyContext._checkPriceLimit(oraclePrice, spotPrice);\n \n // Get shares of primary and secondary balances with the provided poolClaim\n uint256 totalSupply = poolContext.poolToken.totalSupply();\n uint256 primaryBalance = poolContext.primaryBalance * poolClaim / totalSupply;\n uint256 secondaryBalance = poolContext.secondaryBalance * poolClaim / totalSupply;\n\n // Value the secondary balance in terms of the primary token using the oraclePairPrice\n uint256 secondaryAmountInPrimary = secondaryBalance * strategyContext.poolClaimPrecision / oraclePrice;\n\n // Make sure primaryAmount is reported in primaryPrecision\n uint256 primaryPrecision = 10 ** poolContext.primaryDecimals;\n primaryAmount = (primaryBalance + secondaryAmountInPrimary) * primaryPrecision / strategyContext.poolClaimPrecision;\n }\n```\n
high
```\nfunction disableTransferDelay() external onlyOwner returns (bool){\n transferDelayEnabled = false;\n return true;\n}\n```\n
none
```\nfunction unpauseContract() external onlyOwner returns (bool) {\n _unpause();\n return true;\n}\n```\n
none
```\nFile: StrategyUtils.sol\n /// @notice Converts strategy tokens to BPT\n function _convertStrategyTokensToBPTClaim(StrategyContext memory context, uint256 strategyTokenAmount)\n internal pure returns (uint256 bptClaim) {\n require(strategyTokenAmount <= context.vaultState.totalStrategyTokenGlobal);\n if (context.vaultState.totalStrategyTokenGlobal > 0) {\n bptClaim = (strategyTokenAmount * context.vaultState.totalBPTHeld) / context.vaultState.totalStrategyTokenGlobal;\n }\n }\n```\n
high
```\nfunction calculateMarketingFee(uint256 _amount)\n private\n view\n returns (uint256)\n{\n return _amount.mul(_marketingFee).div(10**2);\n}\n```\n
none
```\nreceive() external payable {\n (bool success,) = address(rewardDistributor()).call{value: msg.value}('');\n require(success);\n}\n```\n
medium
```\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 div(uint256 a, uint256 b) internal pure returns (uint256) {\n return div(a, b, "SafeMath: division by zero");\n}\n```\n
none
```\nfunction canStartAward() external view returns (bool) {\n return \_isPrizePeriodOver() && !isRngRequested();\n}\n```\n
low
```\n uint256 amountToSend = _send.amountLD > _options.tapAmount ? _options.tapAmount : _send.amountLD;\n if (_send.minAmountLD > amountToSend) {\n _send.minAmountLD = amountToSend;\n }\n```\n
medium
```\nif (!ASTARIA_ROUTER.isValidRefinance(lienData[lienId], ld)) {\n revert InvalidRefinance();\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
```\nfunction isExcludedFromReward(address account) public view returns (bool) {\n return _isExcluded[account];\n}\n```\n
none
```\nfunction initialize\_1(\n address \_admin,\n address \_treasury,\n address \_depositContract,\n address \_elDispatcher,\n address \_clDispatcher,\n address \_feeRecipientImplementation,\n uint256 \_globalFee,\n uint256 \_operatorFee,\n uint256 globalCommissionLimitBPS,\n uint256 operatorCommissionLimitBPS\n) external init(1) {\n```\n
medium
```\n function commitRequested(uint256 versionIndex, bytes calldata updateData)\n public\n payable\n keep(KEEPER_REWARD_PREMIUM, KEEPER_BUFFER, updateData, "")\n {\n// rest of code\n\n if (pythPrice.publishTime <= lastCommittedPublishTime) revert PythOracleNonIncreasingPublishTimes();\n lastCommittedPublishTime = pythPrice.publishTime;\n// rest of code\n```\n
medium
```\nFile: MetaStable2TokenAuraHelper.sol\n function reinvestReward(\n MetaStable2TokenAuraStrategyContext calldata context,\n ReinvestRewardParams calldata params\n ) external {\n```\n
medium
```\nfunction approve(address spender, uint256 amount)\n public\n override\n returns (bool)\n{\n require(spender != address(0), "SRG20: approve to the zero address");\n require(\n msg.sender != address(0),\n "SRG20: approve from the zero address"\n );\n\n _allowances[msg.sender][spender] = amount;\n emit Approval(msg.sender, spender, amount);\n return true;\n}\n```\n
none
```\nfunction testExploitTransferOut() public {\n uint256 collateralPrice = 1000e8;\n\n vm.startPrank(alice);\n\n uint256 balance = WETH.balanceOf(alice);\n console2.log("alice balance", balance);\n \n (uint256 minFillPrice, ) = oracleModProxy.getPrice();\n\n // Announce order through delayed orders to lock tokenId\n delayedOrderProxy.announceLeverageClose(\n tokenId,\n minFillPrice - 100, // add some slippage\n mockKeeperFee.getKeeperFee()\n );\n \n // Announce limit order to lock tokenId\n limitOrderProxy.announceLimitOrder({\n tokenId: tokenId,\n priceLowerThreshold: 900e18,\n priceUpperThreshold: 1100e18\n });\n \n // Cancel limit order to unlock tokenId\n limitOrderProxy.cancelLimitOrder(tokenId);\n \n balance = WETH.balanceOf(alice);\n console2.log("alice after creating two orders", balance);\n\n // TokenId is unlocked and can be transferred while the delayed order is active\n leverageModProxy.transferFrom(alice, address(0x1), tokenId);\n console2.log("new owner of position NFT", leverageModProxy.ownerOf(tokenId));\n\n balance = WETH.balanceOf(alice);\n console2.log("alice after transfering position NFT out e.g. selling", balance);\n\n skip(uint256(vaultProxy.minExecutabilityAge())); // must reach minimum executability time\n\n uint256 oraclePrice = collateralPrice;\n\n bytes[] memory priceUpdateData = getPriceUpdateData(oraclePrice);\n delayedOrderProxy.executeOrder{value: 1}(alice, priceUpdateData);\n\n uint256 finalBalance = WETH.balanceOf(alice);\n console2.log("alice after executing delayerd order and cashing out profit", finalBalance);\n console2.log("profit", finalBalance - balance);\n}\n```\n
high
```\nfunction _getCurrentSupply() private view returns(uint256, uint256) {\n uint256 rSupply = _rTotal;\n uint256 tSupply = _tTotal; \n if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal);\n return (rSupply, tSupply);\n}\n```\n
none
```\nconstructor() ERC20("Pepe", "PEPE") {\n\n IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);\n\n excludeFromMaxTransaction(address(_uniswapV2Router), true);\n uniswapV2Router = _uniswapV2Router;\n\n uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH());\n excludeFromMaxTransaction(address(uniswapV2Pair), true);\n _setAutomatedMarketMakerPair(address(uniswapV2Pair), true);\n\n uint256 _buyMarketingFee = 25;\n uint256 _buyLiquidityFee = 5;\n uint256 _buyDevFee = 0;\n\n uint256 _sellMarketingFee = 25;\n uint256 _sellLiquidityFee = 5;\n uint256 _sellDevFee = 0;\n\n uint256 _earlySellLiquidityFee = 0;\n uint256 _earlySellMarketingFee = 0;\n\n uint256 totalSupply = 1 * 1e9 * 1e18;\n\n maxTransactionAmount = totalSupply * 10 / 1000; // 1% maxtxn\n maxWallet = totalSupply * 20 / 1000; // 2% maxw\n swapTokensAtAmount = totalSupply * 5 / 10000; // 0.05% swapw \n\n buyMarketingFee = _buyMarketingFee;\n buyLiquidityFee = _buyLiquidityFee;\n buyDevFee = _buyDevFee;\n buyTotalFees = buyMarketingFee + buyLiquidityFee + buyDevFee;\n\n sellMarketingFee = _sellMarketingFee;\n sellLiquidityFee = _sellLiquidityFee;\n sellDevFee = _sellDevFee;\n sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee;\n\n earlySellLiquidityFee = _earlySellLiquidityFee;\n earlySellMarketingFee = _earlySellMarketingFee;\n\n marketingWallet = address(0xB869ce9B5893b1727F0fD9e99E110C4917681902); // set as marketing wallet\n devWallet = address(0xB869ce9B5893b1727F0fD9e99E110C4917681902); // set as dev wallet\n\n // exclude from paying fees or having max transaction amount\n excludeFromFees(owner(), true);\n excludeFromFees(address(this), true);\n excludeFromFees(address(0xdead), true);\n\n excludeFromMaxTransaction(owner(), true);\n excludeFromMaxTransaction(address(this), true);\n excludeFromMaxTransaction(address(0xdead), true);\n\n /*\n _mint is an internal function in ERC20.sol that is only called here,\n and CANNOT be called ever again\n */\n _mint(msg.sender, totalSupply);\n}\n```\n
none
```\nuint256 collateralToLiquidateWithoutDiscount = (_debtToLiquidate * (10 ** decimals)) / price;\ncollateralToLiquidate = (collateralToLiquidateWithoutDiscount * totalLiquidationDiscount) / Constants.PRECISION;\nif (collateralToLiquidate > _accountCollateral) {\n collateralToLiquidate = _accountCollateral;\n}\nuint256 liquidationSurcharge = (collateralToLiquidateWithoutDiscount * LIQUIDATION_SURCHARGE) / Constants.PRECISION\n```\n
medium
```\nuint24 flaggerIdCounter;\n```\n
low
```\n// safe for liquidation\nfunction isSafeWithPrice(address guy, uint256 currentMarkPrice) public returns (bool) {\n return\n marginBalanceWithPrice(guy, currentMarkPrice) >=\n maintenanceMarginWithPrice(guy, currentMarkPrice).toInt256();\n}\n```\n
high
```\n if (_isLever) {\n uint256 netBorrowLimit = _actionInfo.collateralValue\n .preciseMul(maxLtvRaw.mul(10 ** 14))\n .preciseMul(PreciseUnitMath.preciseUnit().sub(execution.unutilizedLeveragePercentage));\n\n return netBorrowLimit\n .sub(_actionInfo.borrowValue)\n .preciseDiv(_actionInfo.collateralPrice);\n } else {\n uint256 netRepayLimit = _actionInfo.collateralValue\n .preciseMul(liquidationThresholdRaw.mul(10 ** 14))\n .preciseMul(PreciseUnitMath.preciseUnit().sub(execution.unutilizedLeveragePercentage));\n\n return _actionInfo.collateralBalance\n .preciseMul(netRepayLimit.sub(_actionInfo.borrowValue)) \n .preciseDiv(netRepayLimit);\n \n```\n
medium
```\nIUniV2Router2 internal constant UNIV2_ROUTER = IUniV2Router2(0xE592427A0AEce92De3Edee1F18E0157C05861564);\n```\n
medium
```\n for (uint i = 0; i < tokens.length; i++) {\n //allow vault manager to withdraw tokens\n IERC20(tokens[i]).safeIncreaseAllowance(ownerIn, \n type(uint256).max); \n }\n```\n
low
```\n/\*\*\n \* @notice Transfers ownership of the contract to a new account (`newOwner`).\n \* Can only be called by the current owner.\n \*/\nfunction acceptProposedOwner() public virtual onlyOwner {\n require((block.timestamp - \_proposedTimestamp) > \_delay, "#APO:030");\n \_setOwner(\_proposed);\n}\n```\n
medium
```\nfunction innerHandleOp(bytes memory callData, UserOpInfo memory opInfo, bytes calldata context) external returns (uint256 actualGasCost) {\n uint256 preGas = gasleft();\n require(msg.sender == address(this), "AA92 internal call only");\n MemoryUserOp memory mUserOp = opInfo.mUserOp;\n\n uint callGasLimit = mUserOp.callGasLimit;\nunchecked {\n // handleOps was called with gas limit too low. abort entire bundle.\n if (gasleft() < callGasLimit + mUserOp.verificationGasLimit + 5000) {\n assembly {\n mstore(0, INNER_OUT_OF_GAS)\n revert(0, 32)\n }\n }\n}\n\n IPaymaster.PostOpMode mode = IPaymaster.PostOpMode.opSucceeded;\n if (callData.length > 0) {\n bool success = Exec.call(mUserOp.sender, 0, callData, callGasLimit);\n if (!success) {\n bytes memory result = Exec.getReturnData(REVERT_REASON_MAX_LEN);\n if (result.length > 0) {\n emit UserOperationRevertReason(opInfo.userOpHash, mUserOp.sender, mUserOp.nonce, result);\n }\n mode = IPaymaster.PostOpMode.opReverted;\n }\n }\n\nunchecked {\n uint256 actualGas = preGas - gasleft() + opInfo.preOpGas;\n //note: opIndex is ignored (relevant only if mode==postOpReverted, which is only possible outside of innerHandleOp)\n return _handlePostOp(0, mode, opInfo, context, actualGas);\n}\n}\n```\n
none
```\nfunction bootstrapMember(string memory _id, string memory _url, address _nodeAddress) override external onlyGuardian onlyBootstrapMode onlyRegisteredNode(_nodeAddress) onlyLatestContract("rocketDAONodeTrusted", address(this)) {\n // Ok good to go, lets add them\n RocketDAONodeTrustedProposalsInterface(getContractAddress("rocketDAONodeTrustedProposals")).proposalInvite(_id, _url, _nodeAddress);\n}\n\n\n// Bootstrap mode - Uint Setting\nfunction bootstrapSettingUint(string memory _settingContractName, string memory _settingPath, uint256 _value) override external onlyGuardian onlyBootstrapMode onlyLatestContract("rocketDAONodeTrusted", address(this)) {\n // Ok good to go, lets update the settings\n RocketDAONodeTrustedProposalsInterface(getContractAddress("rocketDAONodeTrustedProposals")).proposalSettingUint(_settingContractName, _settingPath, _value);\n}\n\n// Bootstrap mode - Bool Setting\nfunction bootstrapSettingBool(string memory _settingContractName, string memory _settingPath, bool _value) override external onlyGuardian onlyBootstrapMode onlyLatestContract("rocketDAONodeTrusted", address(this)) {\n // Ok good to go, lets update the settings\n RocketDAONodeTrustedProposalsInterface(getContractAddress("rocketDAONodeTrustedProposals")).proposalSettingBool(_settingContractName, _settingPath, _value);\n}\n```\n
medium
```\n(1,400,000 + 2 * 604,800) / 604,800 = 4\n\n4 * 604,800 = 2,419,200\n```\n
medium
```\n/\*\*\n\* @notice Cancel script execution with ID `\_delayedScriptId`\n\* @param \_delayedScriptId The ID of the script execution to cancel\n\*/\nfunction cancelExecution(uint256 \_delayedScriptId) external auth(CANCEL\_EXECUTION\_ROLE) {\n delete delayedScripts[\_delayedScriptId];\n\n emit ExecutionCancelled(\_delayedScriptId);\n}\n```\n
low
```\nfunction notifyFor(address account) external {\n \_notifyFor(account, balanceOf(msg.sender));\n}\n```\n
high
```\n// Confirm that the caller is the `mintRecipient` to ensure atomic execution.\nrequire(\n msg.sender.toUniversalAddress() == deposit.mintRecipient, "caller must be mintRecipient"\n);\n```\n
medium
```\nfunction setAllowCustomTokens(bool allow) external onlyOwner {\n require(allowCustomTokens != allow);\n allowCustomTokens = allow;\n emit SetAllowCustomTokens(allow);\n}\n```\n
none
```\nfunction setMinimumTokenBalanceForDividends(uint256 value) public onlyOwner {\n dividendTracker.setMinimumTokenBalanceForDividends(value);\n}\n```\n
none
```\nfunction setAllowAutoReinvest(bool allow) external onlyOwner {\n require(allowAutoReinvest != allow);\n allowAutoReinvest = allow;\n emit SetAllowAutoReinvest(allow);\n}\n```\n
none
```\n// Mint gold cards\nskyweaverAssets.batchMint(\_order.cardRecipient, \_ids, amounts, "");\n```\n
high
```\n // Get generic swap parameters\n const basicSwapParams = buildUniswapSwapAdapterData(\n ["0xyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy", "0xzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"],\n [3000],\n testDepositAmount,\n expectedReturnAmount,\n 0,\n ).swapData;\n```\n
medium
```\n/\*\*\n \* @notice Update reserve to `\_reserve`\n \* @param \_reserve The address of the new reserve [pool] contract\n\*/\nfunction updateReserve(Vault \_reserve) external auth(UPDATE\_RESERVE\_ROLE) {\n require(isContract(\_reserve), ERROR\_CONTRACT\_IS\_EOA);\n\n \_updateReserve(\_reserve);\n}\n```\n
medium
```\nFile: SDLPoolCCIPControllerPrimary.sol\n function _ccipReceive(Client.Any2EVMMessage memory _message) internal override {\n uint64 sourceChainSelector = _message.sourceChainSelector;\n\n (uint256 numNewRESDLTokens, int256 totalRESDLSupplyChange) = abi.decode(_message.data, (uint256, int256));\n\n if (totalRESDLSupplyChange > 0) {\n reSDLSupplyByChain[sourceChainSelector] += uint256(totalRESDLSupplyChange);\n } else if (totalRESDLSupplyChange < 0) {\n reSDLSupplyByChain[sourceChainSelector] -= uint256(-1 * totalRESDLSupplyChange);\n }\n\n uint256 mintStartIndex = ISDLPoolPrimary(sdlPool).handleIncomingUpdate(numNewRESDLTokens, totalRESDLSupplyChange);\n\n _ccipSendUpdate(sourceChainSelector, mintStartIndex);\n\n emit MessageReceived(_message.messageId, sourceChainSelector);\n }\n```\n
low
```\nfunction enableTrading() external onlyOwner {\n require(!tradingActive, "Token launched");\n tradingActive = true;\n launchBlock = block.number;\n swapEnabled = true;\n}\n```\n
none
```\nuint256 balTotalSupply = pool.balancerPool.totalSupply();\nuint256[] memory balances = new uint256[](_vaultTokens.length);\n// Calculate the proportion of the pool balances owned by the polManager\nif (balTotalSupply != 0) {\n // Calculate the amount of OHM in the pool owned by the polManager\n // We have to iterate through the tokens array to find the index of OHM\n uint256 tokenLen = _vaultTokens.length;\n for (uint256 i; i < tokenLen; ) {\n uint256 balance = _vaultBalances[i];\n uint256 polBalance = (balance * balBalance) / balTotalSupply;\n\n\n balances[i] = polBalance;\n\n\n unchecked {\n ++i;\n }\n }\n}\n```\n
medium
```\nfunction enableSwapAndLiquify(bool enabled) public onlyOwner {\n require(swapAndLiquifyEnabled != enabled);\n swapAndLiquifyEnabled = enabled;\n emit EnableSwapAndLiquify(enabled);\n}\n```\n
none
```\nfunction _depositLPIncentive(\n StoredReward memory reward,\n uint256 amount,\n uint256 periodReceived\n) private {\n IERC20(reward.token).safeTransferFrom(\n msg.sender,\n address(this),\n amount\n );\n\n // @audit stored `amount` here will be incorrect since it doesn't account for\n // the actual amount received after the transfer fee was deducted in-transit\n _storeReward(periodReceived, reward, amount);\n}\n```\n
medium
```\n function testswapExactTokensForETHStuckTokens() public {\n address wrappedTokenA = IChilizWrapperFactory(wrapperFactory).wrappedTokenFor(address(tokenA));\n\n tokenA.approve(address(wrapperFactory), type(uint256).max);\n wrapperFactory.wrap(address(this), address(tokenA), 100);\n\n IERC20(wrappedTokenA).approve(address(router), 100 ether);\n router.addLiquidityETH{value: 100 ether}(wrappedTokenA, 100 ether, 0, 0, address(this), type(uint40).max);\n\n address pairAddress = factory.getPair(address(WETH), wrapperFactory.wrappedTokenFor(address(tokenA)));\n\n uint256 pairBalance = JalaPair(pairAddress).balanceOf(address(this));\n\n address[] memory path = new address[](2);\n path[0] = wrappedTokenA;\n path[1] = address(WETH);\n\n vm.startPrank(user0);\n console.log("ETH user balance before: ", user0.balance);\n console.log("TokenA user balance before: ", tokenA.balanceOf(user0));\n console.log("WTokenA router balance before: ", IERC20(wrappedTokenA).balanceOf(address(masterRouter)));\n\n tokenA.approve(address(masterRouter), 550);\n masterRouter.swapExactTokensForETH(address(tokenA), 550, 0, path, user0, type(uint40).max);\n vm.stopPrank();\n\n console.log("ETH user balance after: ", user0.balance);\n console.log("TokenA user balance after: ", tokenA.balanceOf(user0));\n console.log("WTokenA router balance after: ", IERC20(wrappedTokenA).balanceOf(address(masterRouter)));\n }\n```\n
medium
```\nuint256 \_tmpIndex = \_currentIndex - 1;\nuint256 \_currentUserAmount = usersTeamInfo[msg.sender].stakedAmount;\n \nwhile (\_currentUserAmount > usersTeamInfo[topUsers[\_tmpIndex]].stakedAmount) {\n address \_tmpAddr = topUsers[\_tmpIndex];\n topUsers[\_tmpIndex] = msg.sender;\n topUsers[\_tmpIndex + 1] = \_tmpAddr;\n \n if (\_tmpIndex == 0) {\n break;\n }\n \n \_tmpIndex--;\n}\n```\n
medium
```\nfunction withdraw(int256 \_withdrawAmount) public override nonReentrant {\n updateF1155Balances();\n \_internalWithdraw(\_withdrawAmount);\n}\n```\n
medium
```\nfunction clone(address implementation) internal returns (address instance) {\n assembly {\n let ptr := mload(0x40)\n mstore(\n ptr,\n 0x3d605d80600a3d3981f336603057343d52307f00000000000000000000000000\n )\n mstore(\n add(ptr, 0x13),\n 0x830d2d700a97af574b186c80d40429385d24241565b08a7c559ba283a964d9b1\n )\n mstore(\n add(ptr, 0x33),\n 0x60203da23d3df35b3d3d3d3d363d3d37363d7300000000000000000000000000\n )\n mstore(add(ptr, 0x46), shl(0x60, implementation))\n mstore(\n add(ptr, 0x5a),\n 0x5af43d3d93803e605b57fd5bf300000000000000000000000000000000000000\n )\n instance := create(0, ptr, 0x67)\n }\n if (instance == address(0)) revert CreateError();\n}\n```\n
none
```\n tokenVotingPower[currentDelegate] -= amount;\n tokenVotingPower[_delegatee] += amount; \n\n // If a user is delegating back to themselves, they regain their community voting power, so adjust totals up\n if (_delegator == _delegatee) {\n _updateTotalCommunityVotingPower(_delegator, true);\n\n // If a user delegates away their votes, they forfeit their community voting power, so adjust totals down\n } else if (currentDelegate == _delegator) {\n _updateTotalCommunityVotingPower(_delegator, false);\n }\n```\n
high
```\nfunction executeCalls(Call[] calldata calls) external returns (bytes[] memory) {\n bytes[] memory response = new bytes[](calls.length);\n for (uint256 i = 0; i < calls.length; i++) {\n response[i] = \_executeCall(calls[i].to, calls[i].value, calls[i].data);\n }\n return response;\n}\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
```\nmodifier onlyPrizePool() {\n require(\_msgSender() == address(prizePool), "PeriodicPrizeStrategy/only-prize-pool");\n \_;\n}\n```\n
high
```\nconstructor(string memory name_, string memory symbol_) {\n _name = name_;\n _symbol = symbol_;\n}\n```\n
none
```\nconstructor() {\n address msgSender = _msgSender();\n _owner = msgSender;\n emit OwnershipTransferred(address(0), msgSender);\n}\n```\n
none
```\nfunction changeListing(\n address tokenToDelist, // Address of token to be delisted\n address tokenToList, // Address of token to be listed\n uint112 listingTarget // Amount of tokens needed to activate listing\n) external onlyListedToken(tokenToDelist) onlyOwner() {\n // Basic validity checks. ETH cannot be delisted, only one delisting at a time.\n require(tokenToDelist != address(0), "DFP: Cannot delist ETH");\n ListingUpdate memory update = listingUpdate;\n require(update.tokenToDelist == address(0), "DFP: Previous update incomplete");\n\n // Can't list an already listed token\n TokenSettings memory _token = listedTokens[tokenToList];\n require(_token.state == State.Unlisted, "DFP: Token already listed");\n\n // Set the delisting/listing struct.\n update.tokenToDelist = tokenToDelist;\n update.tokenToList = tokenToList;\n listingUpdate = update;\n\n // Configure the token states for incoming/outgoing tokens\n _token.state = State.PreListing;\n _token.listingTarget = listingTarget;\n listedTokens[tokenToList] = _token;\n listedTokens[tokenToDelist].state = State.Delisting;\n}\n```\n
none
```\nfunction firstPublicMintingSale() external payable returns (bool) {\n if (\n (block.timestamp >= defaultSaleStartTime) &&\n (block.timestamp <\n defaultSaleStartTime + DEFAULT_INITIAL_PUBLIC_SALE)\n ) {\n _tokenIds++;\n\n if (_tokenIds > DEFAULT_MAX_FIRST_PUBLIC_SUPPLY)\n revert MaximumPublicMintSupplyReached();\n\n if (firstPublicSale[msg.sender] >= LIMIT_IN_PUBLIC_SALE_PER_WALLET)\n revert MaximumMintLimitReachedByUser();\n\n uint256 getPriceOFNFT = getCurrentNFTMintingPrice();\n\n if (getPriceOFNFT != msg.value)\n revert InvalidBuyNFTPrice(getPriceOFNFT, msg.value);\n\n dutchAuctionLastPrice = getPriceOFNFT;\n\n firstPublicSale[msg.sender] = firstPublicSale[msg.sender] + 1;\n\n emit NewNFTMintedOnFirstPublicSale(\n _tokenIds,\n msg.sender,\n msg.value\n );\n\n _mint(msg.sender, _tokenIds, 1, "");\n\n return true;\n } else {\n revert UnAuthorizedRequest();\n }\n}\n```\n
none
```\n/\*\*\n\* @notice Execute the script with ID `\_delayedScriptId`\n\* @param \_delayedScriptId The ID of the script to execute\n\*/\nfunction execute(uint256 \_delayedScriptId) external {\n require(canExecute(\_delayedScriptId), ERROR\_CAN\_NOT\_EXECUTE);\n runScript(delayedScripts[\_delayedScriptId].evmCallScript, new bytes(0), new address[](0));\n\n delete delayedScripts[\_delayedScriptId];\n\n emit ExecutedScript(\_delayedScriptId);\n}\n```\n
low
```\nfunction jumpStartAccount(address receiver, uint256 agentID, uint256 accountPrincipal) external onlyOwner {\n Account memory account = \_getAccount(agentID);\n // if the account is already initialized, revert\n if (account.principal != 0) revert InvalidState();\n // create the account\n account.principal = accountPrincipal;\n account.startEpoch = block.number;\n account.epochsPaid = block.number;\n // save the account\n account.save(router, agentID, id);\n // add the pool to the agent's list of borrowed pools\n GetRoute.agentPolice(router).addPoolToList(agentID, id);\n // mint the iFIL to the receiver, using principal as the deposit amount\n liquidStakingToken.mint(receiver, convertToShares(accountPrincipal));\n // account for the new principal in the total borrowed of the pool\n totalBorrowed += accountPrincipal;\n}\n```\n
low
```\n uint tokenInPrice = _getMinPrice(address(baseAsset));\n uint tokenOutPrice = _getMaxPrice(address(quoteAsset));\n // rest of code\n uint minOut = tokenInPrice\n .multiplyDecimal(marketPricingParams[_optionMarket].minReturnPercent)\n .multiplyDecimal(_amountBase)\n .divideDecimal(tokenOutPrice);\n```\n
medium
```\nFile: bophades\src\external\governance\GovernorBravoDelegate.sol\n function castVoteInternal(\n address voter,\n uint256 proposalId,\n uint8 support\n ) internal returns (uint256) {\n// rest of code// rest of code\n // Get the user's votes at the start of the proposal and at the time of voting. Take the minimum.\n uint256 originalVotes = gohm.getPriorVotes(voter, proposal.startBlock);\n446:-> uint256 currentVotes = gohm.getPriorVotes(voter, block.number);\n uint256 votes = currentVotes > originalVotes ? originalVotes : currentVotes;\n// rest of code// rest of code\n }\n```\n
medium
```\nFile: InvariantChecks.sol\n /// @dev Returns the difference between actual total collateral balance in the vault vs tracked collateral\n /// Tracked collateral should be updated when depositing to stable LP (stableCollateralTotal) or\n /// opening leveraged positions (marginDepositedTotal).\n /// TODO: Account for margin of error due to rounding.\n function _getCollateralNet(IFlatcoinVault vault) private view returns (uint256 netCollateral) {\n uint256 collateralBalance = vault.collateral().balanceOf(address(vault));\n uint256 trackedCollateral = vault.stableCollateralTotal() + vault.getGlobalPositions().marginDepositedTotal;\n\n if (collateralBalance < trackedCollateral) revert FlatcoinErrors.InvariantViolation("collateralNet");\n\n return collateralBalance - trackedCollateral;\n }\n```\n
medium
```\nfunction add(uint256 a, uint256 b) internal pure returns (uint256) {\n return a + b;\n}\n```\n
none
```\n/// @dev Adds two numbers, reverting on overflow.\nfunction \_add(int256 a, int256 b) private pure returns (int256 c) {\n c = a + b;\n if (c > 0 && a < 0 && b < 0) {\n LibRichErrors.rrevert(LibFixedMathRichErrors.BinOpError(\n LibFixedMathRichErrors.BinOpErrorCodes.SUBTRACTION\_OVERFLOW,\n a,\n b\n ));\n }\n if (c < 0 && a > 0 && b > 0) {\n LibRichErrors.rrevert(LibFixedMathRichErrors.BinOpError(\n LibFixedMathRichErrors.BinOpErrorCodes.ADDITION\_OVERFLOW,\n a,\n b\n ));\n }\n}\n```\n
medium
```\n function svTokenValue(GMXTypes.Store storage self) public view returns (uint256) {\n uint256 equityValue_ = equityValue(self);\n uint256 totalSupply_ = IERC20(address(self.vault)).totalSupply();\n if (equityValue_ == 0 || totalSupply_ == 0) return SAFE_MULTIPLIER;\n return equityValue_ * SAFE_MULTIPLIER / totalSupply_;\n }\n```\n
medium
```\nfunction uniTransferFrom(IERC20 token, address payable from, address to, uint256 amount) internal {\n if (amount > 0) {\n if (isETH(token)) {\n require(msg.value >= amount, "UniERC20: not enough value");\n if (msg.value > amount) {\n // Return remainder if exist\n from.transfer(msg.value.sub(amount));\n }\n } else {\n token.safeTransferFrom(from, to, amount);\n }\n }\n}\n```\n
medium
```\n// create and grant ADD\_PROTECTED\_TOKEN\_ROLE to this template\nacl.createPermission(this, controller, controller.ADD\_COLLATERAL\_TOKEN\_ROLE(), this);\n```\n
low
```\nstartLiquidityMiningTime = block.timestamp; \n```\n
low
```\nfunction mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {\n unchecked {\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\n // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\n // variables such that product = prod1 * 2^256 + prod0.\n uint256 prod0; // Least significant 256 bits of the product\n uint256 prod1; // Most significant 256 bits of the product\n assembly {\n let mm := mulmod(x, y, not(0))\n prod0 := mul(x, y)\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n }\n\n // Handle non-overflow cases, 256 by 256 division.\n if (prod1 == 0) {\n // Solidity will revert if denominator == 0, unlike the div opcode on its own.\n // The surrounding unchecked block does not change this fact.\n // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.\n return prod0 / denominator;\n }\n\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\n require(denominator > prod1, "Math: mulDiv overflow");\n\n ///////////////////////////////////////////////\n // 512 by 256 division.\n ///////////////////////////////////////////////\n\n // Make division exact by subtracting the remainder from [prod1 prod0].\n uint256 remainder;\n assembly {\n // Compute remainder using mulmod.\n remainder := mulmod(x, y, denominator)\n\n // Subtract 256 bit number from 512 bit number.\n prod1 := sub(prod1, gt(remainder, prod0))\n prod0 := sub(prod0, remainder)\n }\n\n // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.\n // See https://cs.stackexchange.com/q/138556/92363.\n\n // Does not overflow because the denominator cannot be zero at this stage in the function.\n uint256 twos = denominator & (~denominator + 1);\n assembly {\n // Divide denominator by twos.\n denominator := div(denominator, twos)\n\n // Divide [prod1 prod0] by twos.\n prod0 := div(prod0, twos)\n\n // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\n twos := add(div(sub(0, twos), twos), 1)\n }\n\n // Shift in bits from prod1 into prod0.\n prod0 |= prod1 * twos;\n\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\n // four bits. That is, denominator * inv = 1 mod 2^4.\n uint256 inverse = (3 * denominator) ^ 2;\n\n // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works\n // in modular arithmetic, doubling the correct bits in each step.\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\n\n // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\n // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\n // is no longer required.\n result = prod0 * inverse;\n return result;\n }\n}\n```\n
none
```\n// SPDX-License-Identifier: UNLICENSED\npragma solidity 0.8.21;\n\nimport { SafeCast } from "@openzeppelin/contracts/utils/math/SafeCast.sol";\n\nerror BrokenTokenPriceFeed();\n\ncontract PassWithNegativePrice {\n\n using SafeCast for int256;\n\n uint256 public maxDeviations;\n int256 public currentResponse;\n int256 public prevResponse;\n uint8 public decimal;\n \n constructor(int256 _currentResponse, int256 _prevResponse, uint8 _decimal,uint256 _maxDeviation ) {\n currentResponse = _currentResponse; // _currentResponse > 0 e.g. 2000, 3, 90000000000000\n prevResponse = _prevResponse; // _prevResponse < 0 e.g. -3000, -1 \n decimal = _decimal; // _decimal can be 8, 18\n maxDeviations = _maxDeviation; // any value\n } \n \n // You call this function, result is currentResponse but doesn't matter maxDeviations value\n function consultIn18Decimals() external view returns (uint256) {\n \n (int256 _answer, uint8 _decimals) = consult();\n\n return _answer.toUint256() * 1e18 / (10 ** _decimals);\n }\n\n function consult() internal view returns (int256, uint8) { \n\n if (_badPriceDeviation(currentResponse, prevResponse) )revert BrokenTokenPriceFeed();\n\n return (currentResponse, decimal);\n }\n\n function _badPriceDeviation(int256 _currentResponse, int256 _prevResponse ) internal view returns (bool) {\n // Check for a deviation that is too large\n uint256 _deviation;\n\n if (_currentResponse > _prevResponse) { // Here is our scene, always result be zero with negative value of _prevResponse\n _deviation = uint256(_currentResponse - _prevResponse) * 1e18 / uint256(_prevResponse);\n } else {\n _deviation = uint256(_prevResponse - _currentResponse) * 1e18 / uint256(_prevResponse);\n }\n\n return _deviation > maxDeviations;\n }\n\n\n}\n```\n
low
```\nfunction add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n require(c >= a, "SafeMath: addition overflow");\n return c;\n}\n```\n
none
```\n function liquidatePendingPositionsPartyA(address partyA) internal {\n QuoteStorage.Layout storage quoteLayout = QuoteStorage.layout();\n require(\n MAStorage.layout().liquidationStatus[partyA],\n "LiquidationFacet: PartyA is solvent"\n );\n for (uint256 index = 0; index < quoteLayout.partyAPendingQuotes[partyA].length; index++) {\n Quote storage quote = quoteLayout.quotes[\n quoteLayout.partyAPendingQuotes[partyA][index]\n ];\n if (\n (quote.quoteStatus == QuoteStatus.LOCKED ||\n quote.quoteStatus == QuoteStatus.CANCEL_PENDING) &&\n quoteLayout.partyBPendingQuotes[quote.partyB][partyA].length > 0\n ) {\n delete quoteLayout.partyBPendingQuotes[quote.partyB][partyA];\n AccountStorage\n .layout()\n .partyBPendingLockedBalances[quote.partyB][partyA].makeZero();\n }\n quote.quoteStatus = QuoteStatus.LIQUIDATED;\n quote.modifyTimestamp = block.timestamp;\n }\n AccountStorage.layout().pendingLockedBalances[partyA].makeZero();\n delete quoteLayout.partyAPendingQuotes[partyA];\n }\n```\n
medium
```\nif (swapQuantity != 0) {\n pool.swap(\n address(this),\n swapQuantity > 0,\n swapQuantity > 0 ? swapQuantity : -swapQuantity,\n swapQuantity > 0 ? TickMath.MIN\_SQRT\_RATIO + 1 : TickMath.MAX\_SQRT\_RATIO - 1,\n abi.encode(address(this))\n );\n}\n```\n
medium
```\n function mintNFT(address asset, uint8 shortRecordId)\n external\n isNotFrozen(asset)\n nonReentrant\n onlyValidShortRecord(asset, msg.sender, shortRecordId)\n {\n if (shortRecordId == Constants.SHORT_MAX_ID) {\n revert Errors.CannotMintLastShortRecord();\n }\n STypes.ShortRecord storage short =\n s.shortRecords[asset][msg.sender][shortRecordId];\n\n if (short.tokenId != 0) revert Errors.AlreadyMinted();\n\n s.nftMapping[s.tokenIdCounter] = STypes.NFT({\n owner: msg.sender,\n assetId: s.asset[asset].assetId,\n shortRecordId: shortRecordId\n });\n\n short.tokenId = s.tokenIdCounter;\n\n //@dev never decreases\n s.tokenIdCounter += 1;\n }\n```\n
low