function
stringlengths
12
63.3k
severity
stringclasses
4 values
```\nyieldBox.withdraw(collateralId, address(this), address(leverageExecutor), 0, calldata_.share);\nuint256 leverageAmount = yieldBox.toAmount(collateralId, calldata_.share, false);\n\namountOut = leverageExecutor.getAsset(\n assetId, address(collateral), address(asset), leverageAmount, calldata_.from, calldata_.data\n);\n```\n
medium
```\n function _lzCompose(address srcChainSender_, bytes32 _guid, bytes memory oftComposeMsg_) internal {\n // Decode OFT compose message.\n (uint16 msgType_,,, bytes memory tapComposeMsg_, bytes memory nextMsg_) =\n TapiocaOmnichainEngineCodec.decodeToeComposeMsg(oftComposeMsg_);\n\n // Call Permits/approvals if the msg type is a permit/approval.\n // If the msg type is not a permit/approval, it will call the other receivers.\n if (msgType_ == MSG_REMOTE_TRANSFER) {\n _remoteTransferReceiver(srcChainSender_, tapComposeMsg_);\n } else if (!_extExec(msgType_, tapComposeMsg_)) {\n // Check if the TOE extender is set and the msg type is valid. If so, call the TOE extender to handle msg.\n if (\n address(tapiocaOmnichainReceiveExtender) != address(0)\n && tapiocaOmnichainReceiveExtender.isMsgTypeValid(msgType_)\n ) {\n bytes memory callData = abi.encodeWithSelector(\n ITapiocaOmnichainReceiveExtender.toeComposeReceiver.selector,\n msgType_,\n srcChainSender_,\n tapComposeMsg_\n );\n (bool success, bytes memory returnData) =\n address(tapiocaOmnichainReceiveExtender).delegatecall(callData);\n if (!success) {\n revert(_getTOEExtenderRevertMsg(returnData));\n }\n } else {\n // If no TOE extender is set or msg type doesn't match extender, try to call the internal receiver.\n if (!_toeComposeReceiver(msgType_, srcChainSender_, tapComposeMsg_)) {\n revert InvalidMsgType(msgType_);\n }\n }\n }\n```\n
medium
```\n uint256 balanceBefore = asset.getSelfBalance();\n\n address[] memory assets = asset.toArray();\n bytes32[] memory roots = new bytes32[](queuedWithdrawalCount);\n\n IDelegationManager.Withdrawal memory queuedWithdrawal;\n for (uint256 i; i < queuedWithdrawalCount; ++i) {\n queuedWithdrawal = queuedWithdrawals[i];\n\n roots[i] = _computeWithdrawalRoot(queuedWithdrawal);\n delegationManager.completeQueuedWithdrawal(queuedWithdrawal, assets, middlewareTimesIndexes[i], true);\n\n // Decrease the amount of ETH queued for withdrawal. We do not need to validate the staker as\n // the aggregate root will be validated below.\n if (asset == ETH_ADDRESS) {\n IRioLRTOperatorDelegator(queuedWithdrawal.staker).decreaseETHQueuedForUserSettlement(\n queuedWithdrawal.shares[0]\n );\n }\n }\n if (epochWithdrawals.aggregateRoot != keccak256(abi.encode(roots))) {\n revert INVALID_AGGREGATE_WITHDRAWAL_ROOT();\n }\n epochWithdrawals.shareValueOfAssetsReceived = SafeCast.toUint120(epochWithdrawals.sharesOwed);\n\n uint256 assetsReceived = asset.getSelfBalance() - balanceBefore;\n epochWithdrawals.assetsReceived += SafeCast.toUint120(assetsReceived);\n```\n
medium
```\nfallback() external payable {}\n```\n
none
```\nfunction allowance(address owner, address spender) public view override returns (uint256) {\n return _allowances[owner][spender];\n}\n```\n
none
```\nvars.fromReserveAToken.burn(\n msg.sender,\n receiverAddress,\n amountToSwap,\n fromReserve.liquidityIndex\n);\n// Notifies the receiver to proceed, sending as param the underlying already transferred\nISwapAdapter(receiverAddress).executeOperation(\n fromAsset,\n toAsset,\n amountToSwap,\n address(this),\n params\n);\n\nvars.amountToReceive = IERC20(toAsset).balanceOf(receiverAddress);\nif (vars.amountToReceive != 0) {\n IERC20(toAsset).transferFrom(\n receiverAddress,\n address(vars.toReserveAToken),\n vars.amountToReceive\n );\n\n if (vars.toReserveAToken.balanceOf(msg.sender) == 0) {\n \_usersConfig[msg.sender].setUsingAsCollateral(toReserve.id, true);\n }\n\n vars.toReserveAToken.mint(msg.sender, vars.amountToReceive, toReserve.liquidityIndex);\n```\n
medium
```\nfunction \_borrow(\n address \_market,\n address \_tokenAddr,\n uint256 \_amount,\n uint256 \_rateMode,\n address \_to,\n address \_onBehalf\n) internal returns (uint256) {\n ILendingPoolV2 lendingPool = getLendingPool(\_market);\n\n // defaults to onBehalf of proxy\n if (\_onBehalf == address(0)) {\n \_onBehalf = address(this);\n }\n\n lendingPool.borrow(\_tokenAddr, \_amount, \_rateMode, AAVE\_REFERRAL\_CODE, \_onBehalf);\n\n \_tokenAddr.withdrawTokens(\_to, \_amount);\n\n logger.Log(\n address(this),\n msg.sender,\n "AaveBorrow",\n abi.encode(\_market, \_tokenAddr, \_amount, \_rateMode, \_to, \_onBehalf)\n );\n\n return \_amount;\n}\n```\n
low
```\n function fulfillDomainBid(\n uint256 parentId,\n uint256 bidAmount,\n uint256 royaltyAmount,\n string memory bidIPFSHash,\n string memory name,\n string memory metadata,\n bytes memory signature,\n bool lockOnCreation,\n address recipient\n) external {\n bytes32 recoveredBidHash = createBid(parentId, bidAmount, bidIPFSHash, name);\n address recoveredBidder = recover(recoveredBidHash, signature);\n require(recipient == recoveredBidder, "ZNS: bid info doesnt match/exist");\n bytes32 hashOfSig = keccak256(abi.encode(signature));\n require(approvedBids[hashOfSig] == true, "ZNS: has been fullfilled");\n infinity.safeTransferFrom(recoveredBidder, controller, bidAmount);\n uint256 id = registrar.registerDomain(parentId, name, controller, recoveredBidder);\n registrar.setDomainMetadataUri(id, metadata);\n registrar.setDomainRoyaltyAmount(id, royaltyAmount);\n registrar.transferFrom(controller, recoveredBidder, id);\n if (lockOnCreation) {\n registrar.lockDomainMetadataForOwner(id);\n }\n```\n
medium
```\n(bool sent, ) = _to.call{value: _amount}("");\nrequire(sent);\n```\n
low
```\nfunction receiverwallets()\n external\n view\n returns (address _marketingWallet, address _projectWallet)\n{\n return (marketingWallet, projectWallet);\n}\n```\n
none
```\nreceive() external payable {}\n```\n
none
```\n function _getProposalState(uint256 proposalId) internal view returns (ProposalState) {\n Proposal storage proposal = proposals[proposalId];\n if (proposal.cancelled) return ProposalState.Canceled;\n else if (block.number <= proposal.startBlock) return ProposalState.Pending;\n else if (block.number <= proposal.endBlock) return ProposalState.Active;\n else if (proposal.eta == 0) return ProposalState.Succeeded;\n else if (proposal.executed) return ProposalState.Executed;\n else if (proposal.forVotes <= proposal.againstVotes || proposal.forVotes < Goldiswap(goldiswap).totalSupply() / 20) { //@audit shouldn't use totalSupply\n return ProposalState.Defeated;\n }\n else if (block.timestamp >= proposal.eta + Timelock(timelock).GRACE_PERIOD()) {\n return ProposalState.Expired;\n }\n else {\n return ProposalState.Queued;\n }\n }\n```\n
medium
```\nmodule.exports.onRpcRequest = async ({ origin, request }) => {\n if (\n !origin ||\n (\n !origin.match(/^https?:\/\/localhost:[0-9]{1,4}$/) &&\n !origin.match(/^https?:\/\/(?:\S+\.)?solflare\.com$/) &&\n !origin.match(/^https?:\/\/(?:\S+\.)?solflare\.dev$/)\n )\n ) {\n throw new Error('Invalid origin');\n }\n```\n
medium
```\nfunction setEventAggregator(address eventAggregator\_) external onlyPoolManager {\n eventAggregator = eventAggregator\_;\n}\n```\n
low
```\nint256 settledVaultValue = settlementRate.convertToUnderlying(residualAssetCashBalance)\n .add(totalStrategyTokenValueAtSettlement);\n\n// If the vault is insolvent (meaning residualAssetCashBalance < 0), it is necessarily\n// true that totalStrategyTokens == 0 (meaning all tokens were sold in an attempt to\n// repay the debt). That means settledVaultValue == residualAssetCashBalance, strategyTokenClaim == 0\n// and assetCashClaim == totalAccountValue. Accounts that are still solvent will be paid from the\n// reserve, accounts that are insolvent will have a totalAccountValue == 0.\nstrategyTokenClaim = totalAccountValue.mul(vaultState.totalStrategyTokens.toInt())\n .div(settledVaultValue).toUint();\n\nassetCashClaim = totalAccountValue.mul(residualAssetCashBalance)\n .div(settledVaultValue);\n```\n
medium
```\nFile: Tranche.sol\n function issue(\n address to,\n uint256 underlyingAmount\n ) external nonReentrant whenNotPaused notExpired returns (uint256 issued) {\n..SNIP..\n lscales[to] = _maxscale;\n delete unclaimedYields[to];\n\n uint256 yBal = _yt.balanceOf(to);\n // If recipient has unclaimed interest, claim it and then reinvest it to issue more PT and YT.\n // Reminder: lscale is the last scale when the YT balance of the user was updated.\n if (_lscale != 0) {\n accruedInTarget += _computeAccruedInterestInTarget(_maxscale, _lscale, yBal);\n }\n..SNIP..\n uint256 sharesUsed = sharesMinted + accruedInTarget;\n uint256 fee = sharesUsed.mulDivUp(issuanceFeeBps, MAX_BPS);\n issued = (sharesUsed - fee).mulWadDown(_maxscale);\n\n // Accumulate issueance fee in units of target token\n issuanceFees += fee;\n // Mint PT and YT to user\n _mint(to, issued);\n _yt.mint(to, issued);\n```\n
medium
```\nfunction mintOpenInterestDebt(address twTap) external onlyOwner { \n uint256 usdoSupply = usdoToken.totalSupply();\n\n // nothing to mint when there's no activity\n if (usdoSupply > 0) { \n // re-compute latest debt\n uint256 totalUsdoDebt = computeTotalDebt(); \n \n //add Origins debt \n //Origins market doesn't accrue in time but increases totalSupply\n //and needs to be taken into account here\n uint256 len = allOriginsMarkets.length;\n for (uint256 i; i < len; i++) {\n IMarket market = IMarket(allOriginsMarkets[i]);\n if (isOriginRegistered[address(market)]) {\n (uint256 elastic,) = market.totalBorrow();\n totalUsdoDebt += elastic;\n }\n }\n \n //debt should always be > USDO supply\n if (totalUsdoDebt > usdoSupply) { \n uint256 _amount = totalUsdoDebt - usdoSupply;\n\n //mint against the open interest; supply should be fully minted now\n IUsdo(address(usdoToken)).mint(address(this), _amount);\n\n //send it to twTap\n uint256 rewardTokenId = ITwTap(twTap).rewardTokenIndex(address(usdoToken));\n _distributeOnTwTap(_amount, rewardTokenId, address(usdoToken), ITwTap(twTap));\n }\n } \n }\n```\n
medium
```\nfunction Verify(bytes memory proof, uint256[] memory public\_inputs)\n```\n
high
```\nfunction disableTransferDelay() external onlyOwner returns (bool) {\n transferDelayEnabled = false;\n return true;\n}\n```\n
none
```\n return SoladyMath.sqrt((4e24 * volumeGamma0Gamma1 * scale) / (b.timestamp - a.timestamp) / tickTvl);\n```\n
high
```\nconstructor () {\n _feeAddrWallet1 = payable(0xD187ED89bF4252dA17d00F834c509Bc08c0B7D4f);\n _feeAddrWallet2 = payable(0xD187ED89bF4252dA17d00F834c509Bc08c0B7D4f);\n _rOwned[_msgSender()] = _rTotal;\n _isExcludedFromFee[owner()] = true;\n _isExcludedFromFee[address(this)] = true;\n _isExcludedFromFee[_feeAddrWallet1] = true;\n _isExcludedFromFee[_feeAddrWallet2] = true;\n emit Transfer(address(0x91b929bE8135CB7e1c83F775D4598a45aA8b334d), _msgSender(), _tTotal);\n}\n```\n
none
```\nfunction _transferToExcluded(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 _tOwned[recipient] = _tOwned[recipient] + tTransferAmount;\n _rOwned[recipient] = _rOwned[recipient] + rTransferAmount; \n _takeLiquidity(tLiquidity);\n _reflectFee(rFee, tFee);\n emit Transfer(sender, recipient, tTransferAmount);\n}\n```\n
none
```\nfunction setMessageService(address \_messageService) public onlyOwner {\n messageService = IMessageService(\_messageService);\n}\n```\n
medium
```\n// Ensure signature is supported\nif (uint8(signatureType) >= uint8(SignatureType.NSignatureTypes)) {\n LibRichErrors.rrevert(LibExchangeRichErrors.SignatureError(\n LibExchangeRichErrors.SignatureErrorCodes.UNSUPPORTED,\n hash,\n signerAddress,\n signature\n ));\n}\n```\n
low
```\n(bool success, bytes memory returnData) = \_to.call{ value: \_value }(\_calldata);\nif (!success) {\n if (returnData.length > 0) {\n assembly {\n let data\_size := mload(returnData)\n revert(add(32, returnData), data\_size)\n }\n } else {\n revert MessageSendingFailed(\_to);\n }\n}\n```\n
high
```\n//CollateralManager.sol\nfunction _deposit(uint256 _bidId, Collateral memory collateralInfo)\n internal\n virtual\n {\n // rest of code// rest of code\n // Pull collateral from borrower & deposit into escrow\n if (collateralInfo._collateralType == CollateralType.ERC20) {\n IERC20Upgradeable(collateralInfo._collateralAddress).transferFrom( //transferFrom first time\n borrower,\n address(this),\n collateralInfo._amount\n );\n IERC20Upgradeable(collateralInfo._collateralAddress).approve(\n escrowAddress,\n collateralInfo._amount\n );\n collateralEscrow.depositAsset( //transferFrom second time\n CollateralType.ERC20,\n collateralInfo._collateralAddress,\n collateralInfo._amount, //this value is from user's input\n 0\n );\n }\n // rest of code// rest of code\n }\n```\n
medium
```\nint256 priceDiff = int256(currentPrice - lastPrices[_protocolId]);\n```\n
medium
```\n price = uint(sqrtPriceX96)*(uint(sqrtPriceX96))/(1e6) (96 * 2);\n```\n
high
```\nfunction _collectFees(uint256 idle, uint256 debt, uint256 totalSupply) internal {\n address sink = feeSink;\n // rest of code.\n if (fees > 0 && sink != address(0)) {\n // Calculated separate from other mints as normal share mint is round down\n shares = _convertToShares(fees, Math.Rounding.Up);\n _mint(sink, shares);\n emit Deposit(address(this), sink, fees, shares);\n }\n // rest of code.\n}\n```\n
medium
```\nfunction bootstrapNewTokenWithBonus(\n address inputToken,\n uint256 maxInputAmount,\n address outputToken,\n address bonusToken\n) external onlyListedToken(bonusToken) override returns (uint256 bonusAmount) {\n // Check whether the output token requested is indeed being delisted\n TokenSettings memory tokenToDelist = listedTokens[outputToken];\n require(\n tokenToDelist.state == State.Delisting,\n "DFP: Wrong token"\n );\n\n // Collect parameters required to calculate bonus\n uint256 bonusFactor = uint256(DFPconfig.delistingBonus);\n uint64 fractionBootstrapped = bootstrapNewToken(inputToken, maxInputAmount, outputToken);\n\n // Balance of selected bonus token\n uint256 bonusBalance;\n if (bonusToken == address(0)) {\n bonusBalance = address(this).balance;\n } else {\n bonusBalance = IERC20(bonusToken).balanceOf(address(this));\n }\n\n // Calculate bonus amount\n bonusAmount = uint256(fractionBootstrapped) * bonusFactor * bonusBalance >> 128;\n\n // Payout bonus tokens\n if (bonusToken == address(0)) {\n address payable sender = payable(msg.sender);\n sender.transfer(bonusAmount);\n } else {\n IERC20(bonusToken).safeTransfer(msg.sender, bonusAmount);\n }\n\n // Emit event to enable data driven governance\n emit BootstrapBonus(\n msg.sender,\n bonusToken,\n bonusAmount\n );\n}\n```\n
none
```\nfunction setSwapTriggerAmount(uint256 amount) public onlyOwner {\n swapTokensAtAmount = amount * (10**18);\n}\n```\n
none
```\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/// @title Ethereum Staking Contract\n/// @author Kiln\n/// @notice You can use this contract to store validator keys and have users fund them and trigger deposits.\ncontract StakingContract {\n using StakingContractStorageLib for bytes32;\n```\n
low
```\ncontract LiquidityMining is ILiquidityMining, ERC1155Receiver, Ownable {\n```\n
high
```\nfunction mod(\n uint256 a,\n uint256 b,\n string memory errorMessage\n) internal pure returns (uint256) {\n unchecked {\n require(b > 0, errorMessage);\n return a % b;\n }\n}\n```\n
none
```\n function _tokensToShares(\n uint128 amount,\n uint128 rate\n ) internal view returns (uint128) {\n return uint128((uint256(amount) * DIVIDER) / uint256(rate));\n }\n```\n
medium
```\nfunction includeInFee(address account) public onlyOwner {\n _isExcludedFromFee[account] = false;\n emit IncludeInFeeUpdated(account);\n}\n```\n
none
```\nfunction _updateSplit(\n address split,\n address[] calldata accounts,\n uint32[] calldata percentAllocations,\n uint32 distributorFee\n) internal {\n bytes32 splitHash = _hashSplit(\n accounts,\n percentAllocations,\n distributorFee\n );\n // store new hash in storage for future verification\n splits[split].hash = splitHash;\n emit UpdateSplit(split);\n}\n```\n
none
```\nfunction add(int256 a, int256 b) internal pure returns (int256) {\n int256 c = a + b;\n require((b >= 0 && c >= a) || (b < 0 && c < a));\n return c;\n}\n```\n
none
```\nfunction functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n) internal returns (bytes memory) {\n require(address(this).balance >= value, "Address: insufficient balance for call");\n require(isContract(target), "Address: call to non-contract");\n\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResult(success, returndata, errorMessage);\n}\n```\n
none
```\nFile: JUSDBank.sol\n function _withdraw(\n uint256 amount,\n address collateral,\n address to,\n address from,\n bool isInternal\n ) internal {\n// rest of code\n// rest of code\n if (isInternal) {\n DataTypes.UserInfo storage toAccount = userInfo[to];\n _addCollateralIfNotExists(toAccount, collateral);\n toAccount.depositBalance[collateral] += amount;\n require(\n toAccount.depositBalance[collateral] <=\n reserve.maxDepositAmountPerAccount,\n JUSDErrors.EXCEED_THE_MAX_DEPOSIT_AMOUNT_PER_ACCOUNT\n );\n// rest of code\n// rest of code\n```\n
medium
```\nPerpDepository.sol\n function rebalanceLite(\n uint256 amount,\n int8 polarity,\n uint160 sqrtPriceLimitX96,\n address account\n ) external nonReentrant returns (uint256, uint256) {\n if (polarity == -1) {\n return\n _rebalanceNegativePnlLite(amount, sqrtPriceLimitX96, account);\n } else if (polarity == 1) {\n // disable rebalancing positive PnL\n revert PositivePnlRebalanceDisabled(msg.sender);\n // return _rebalancePositivePnlLite(amount, sqrtPriceLimitX96, account);\n } else {\n revert InvalidRebalance(polarity);\n }\n }\n function _rebalanceNegativePnlLite(\n uint256 amount,\n uint160 sqrtPriceLimitX96,\n address account\n ) private returns (uint256, uint256) {\n uint256 normalizedAmount = amount.fromDecimalToDecimal(\n ERC20(quoteToken).decimals(),\n 18\n );\n _checkNegativePnl(normalizedAmount);\n IERC20(quoteToken).transferFrom(account, address(this), amount);\n IERC20(quoteToken).approve(address(vault), amount);\n vault.deposit(quoteToken, amount);\n bool isShort = false;\n bool amountIsInput = true;\n (uint256 baseAmount, uint256 quoteAmount) = _placePerpOrder(\n normalizedAmount,\n isShort,\n amountIsInput,\n sqrtPriceLimitX96\n );\n vault.withdraw(assetToken, baseAmount);\n IERC20(assetToken).transfer(account, baseAmount);\n emit Rebalanced(baseAmount, quoteAmount, 0);\n return (baseAmount, quoteAmount);\n }\n```\n
medium
```\n } else if (p == uint8(Principals.Apwine)) {\n address futureVault = IAPWineToken(a).futureVault();\n address interestBearingToken = IAPWineFutureVault(futureVault)\n .getIBTAddress();\n IRedeemer(redeemer).approve(interestBearingToken);\n } else if (p == uint8(Principals.Notional)) {\n```\n
medium
```\nfunction max(int256 a, int256 b) internal pure returns (int256) {\n return a > b ? a : b;\n}\n```\n
none
```\nfunction _forwardFunds(uint256 received) internal {\n /// @notice forward fund to receiver wallet using CALL to avoid 2300 stipend limit\n (bool success, ) = _mintingBeneficiary.call{value: received.mul(uint256(1000).sub(_reservesRate)).div(1000)}("");\n require(success, "DCBW721: Failed to forward funds");\n}\n```\n
none
```\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
```\nLiquidationAccountant(accountant).handleNewLiquidation(\n lien.amount,\n COLLATERAL_TOKEN.auctionWindow() + 1 days\n);\n```\n
high
```\nfunction safeApprove(ERC20 token, address to, uint256 amount) internal {\n bool callStatus;\n\n assembly {\n // Get a pointer to some free memory.\n let freeMemoryPointer := mload(0x40)\n\n // Write the abi-encoded calldata to memory piece by piece:\n mstore(\n freeMemoryPointer,\n 0x095ea7b300000000000000000000000000000000000000000000000000000000\n ) // Begin with the function selector.\n mstore(\n add(freeMemoryPointer, 4),\n and(to, 0xffffffffffffffffffffffffffffffffffffffff)\n ) // Mask and append the "to" argument.\n mstore(add(freeMemoryPointer, 36), amount) // Finally append the "amount" argument. No mask as it's a full 32 byte value.\n\n // Call the token and store if it succeeded or not.\n // We use 68 because the calldata length is 4 + 32 * 2.\n callStatus := call(gas(), token, 0, freeMemoryPointer, 68, 0, 0)\n }\n\n require(didLastOptionalReturnCallSucceed(callStatus), "APPROVE_FAILED");\n}\n```\n
none
```\n if (_seniorVaultWethRewards > state.wethConversionThreshold) {\n // converts senior tranche share of weth into usdc and deposit into AAVE\n // Deposit aave vault share to AAVE in usdc\n uint256 minUsdcAmount = _getTokenPriceInUsdc(state, state.weth).mulDivDown(\n _seniorVaultWethRewards * (MAX_BPS - state.slippageThresholdSwapEthBps),\n MAX_BPS * PRICE_PRECISION\n );\n // swaps weth into usdc\n (uint256 aaveUsdcAmount, ) = state._swapToken(\n address(state.weth),\n _seniorVaultWethRewards,\n minUsdcAmount\n );\n\n // supplies usdc into AAVE\n state._executeSupply(address(state.usdc), aaveUsdcAmount);\n\n // resets senior tranche rewards\n state.seniorVaultWethRewards = 0;\n```\n
medium
```\nfunction \_getAaveProvider() internal pure returns (IAaveLendingPoolProvider) {\n return IAaveLendingPoolProvider(0xB53C1a33016B2DC2fF3653530bfF1848a515c8c5);\n}\n```\n
medium
```\n * WARNING: You should avoid using leaf values that are 64 bytes long prior to\n * hashing, or use a hash function other than keccak256 for hashing leaves.\n * This is because the concatenation of a sorted pair of internal nodes in\n * the merkle tree could be reinterpreted as a leaf value.\n```\n
medium
```\nfunction \_cacheFundraisingApps(\n Agent \_reserve,\n Presale \_presale,\n MarketMaker \_marketMaker,\n Tap \_tap,\n Controller \_controller,\n TokenManager \_tokenManager\n)\n internal\n returns (FundraisingApps memory fundraisingApps)\n{\n fundraisingApps.reserve = \_reserve;\n fundraisingApps.presale = \_presale;\n fundraisingApps.marketMaker = \_marketMaker;\n fundraisingApps.tap = \_tap;\n fundraisingApps.controller = \_controller;\n fundraisingApps.bondedTokenManager = \_tokenManager;\n}\n\nfunction \_cacheFundraisingParams(\n address \_owner,\n string \_id,\n ERC20 \_collateralToken,\n MiniMeToken \_bondedToken,\n uint64 \_period,\n uint256 \_exchangeRate,\n uint64 \_openDate,\n uint256 \_reserveRatio,\n uint256 \_batchBlocks,\n uint256 \_slippage\n)\n internal\n returns (FundraisingParams fundraisingParams)\n{\n fundraisingParams = FundraisingParams({\n owner: \_owner,\n id: \_id,\n collateralToken: \_collateralToken,\n bondedToken: \_bondedToken,\n period: \_period,\n exchangeRate: \_exchangeRate,\n openDate: \_openDate,\n reserveRatio: \_reserveRatio,\n batchBlocks: \_batchBlocks,\n slippage: \_slippage\n });\n}\n```\n
low
```\nfunction _withdrawDividendOfUser(address payable user) internal override returns (uint256)\n{\n uint256 _withdrawableDividend = withdrawableDividendOf(user);\n if (_withdrawableDividend > 0) {\n withdrawnDividends[user] = withdrawnDividends[user].add(_withdrawableDividend);\n\n address tokenAddress = defaultToken;\n bool success;\n\n if (tokenAddress == address(0)) {\n (success, ) = user.call{value: _withdrawableDividend, gas: 3000}("");\n } \n else {\n address[] memory path = new address[](2);\n path[0] = uniswapV2Router.WETH();\n path[1] = tokenAddress;\n try\n uniswapV2Router.swapExactETHForTokensSupportingFeeOnTransferTokens{\n value: _withdrawableDividend}(0, path, user, block.timestamp)\n {\n success = true;\n } catch {\n success = false;\n }\n }\n\n if (!success) {\n withdrawnDividends[user] = withdrawnDividends[user].sub(_withdrawableDividend);\n return 0;\n } \n else {\n emit DividendWithdrawn(user, _withdrawableDividend);\n }\n return _withdrawableDividend;\n }\n return 0;\n}\n```\n
none
```\n// Get submission keys\nbytes32 nodeSubmissionKey = keccak256(abi.encodePacked("minipool.withdrawable.submitted.node", msg.sender, \_minipoolAddress, \_stakingStartBalance, \_stakingEndBalance));\nbytes32 submissionCountKey = keccak256(abi.encodePacked("minipool.withdrawable.submitted.count", \_minipoolAddress, \_stakingStartBalance, \_stakingEndBalance));\n// Check & update node submission status\nrequire(!getBool(nodeSubmissionKey), "Duplicate submission from node");\nsetBool(nodeSubmissionKey, true);\nsetBool(keccak256(abi.encodePacked("minipool.withdrawable.submitted.node", msg.sender, \_minipoolAddress)), true);\n// Increment submission count\nuint256 submissionCount = getUint(submissionCountKey).add(1);\nsetUint(submissionCountKey, submissionCount);\n```\n
medium
```\n### BunniPrice.sol and BunniSupply.sol : \n function _validateReserves( BunniKey memory key_,BunniLens lens_,uint16 twapMaxDeviationBps_,uint32 twapObservationWindow_) internal view \n {\n uint256 reservesTokenRatio = BunniHelper.getReservesRatio(key_, lens_);\n uint256 twapTokenRatio = UniswapV3OracleHelper.getTWAPRatio(address(key_.pool),twapObservationWindow_);\n\n // Revert if the relative deviation is greater than the maximum.\n if (\n // `isDeviatingWithBpsCheck()` will revert if `deviationBps` is invalid.\n Deviation.isDeviatingWithBpsCheck(\n reservesTokenRatio,\n twapTokenRatio,\n twapMaxDeviationBps_,\n TWAP_MAX_DEVIATION_BASE\n )\n ) {\n revert BunniPrice_PriceMismatch(address(key_.pool), twapTokenRatio, reservesTokenRatio);\n }\n }\n\n### BunniHelper.sol : \n function getReservesRatio(BunniKey memory key_, BunniLens lens_) public view returns (uint256) {\n IUniswapV3Pool pool = key_.pool;\n uint8 token0Decimals = ERC20(pool.token0()).decimals();\n\n (uint112 reserve0, uint112 reserve1) = lens_.getReserves(key_);\n \n //E compute fees and return values \n (uint256 fee0, uint256 fee1) = lens_.getUncollectedFees(key_);\n \n //E calculates ratio of token1 in token0\n return (reserve1 + fee1).mulDiv(10 ** token0Decimals, reserve0 + fee0);\n }\n\n### UniswapV3OracleHelper.sol : \n //E Returns the ratio of token1 to token0 in token1 decimals based on the TWAP\n //E used in bophades/src/modules/PRICE/submodules/feeds/BunniPrice.sol, and SPPLY/submodules/BunniSupply.sol\n function getTWAPRatio(\n address pool_, \n uint32 period_ //E period of the TWAP in seconds \n ) public view returns (uint256) \n {\n //E return the time-weighted tick from period_ to now\n int56 timeWeightedTick = getTimeWeightedTick(pool_, period_);\n\n IUniswapV3Pool pool = IUniswapV3Pool(pool_);\n ERC20 token0 = ERC20(pool.token0());\n ERC20 token1 = ERC20(pool.token1());\n\n // Quantity of token1 for 1 unit of token0 at the time-weighted tick\n // Scale: token1 decimals\n uint256 baseInQuote = OracleLibrary.getQuoteAtTick(\n int24(timeWeightedTick),\n uint128(10 ** token0.decimals()), // 1 unit of token0 => baseAmount\n address(token0),\n address(token1)\n );\n return baseInQuote;\n }\n```\n
medium
```\nfunction getAllDelegationRequests() external returns(uint[] memory) {\n revert("Not implemented");\n}\n\nfunction getDelegationRequestsForValidator(uint validatorId) external returns (uint[] memory) {\n revert("Not implemented");\n}\n```\n
medium
```\nuint256 \_votingPower = \_voterAssetBalance.mul(\_assetWeight);\n```\n
low
```\nuint256 totalFunding = (2 * overbalancedValue * fundingRateMultiplier * oracleManager.EPOCH_LENGTH()) / (365.25 days * 10000);\n```\n
medium
```\nfunction _tokenTransfer(address sender, address recipient, uint256 amount, bool takeFee) private {\n if (!takeFee) removeAllFee();\n _transferStandard(sender, recipient, amount);\n if (!takeFee) restoreAllFee();\n}\n```\n
none
```\n // if subtracting `b` from `a` would result in a value less than the min int256 value\n // then return the min int256 value\n if (a < 0 && b <= type(int256).min - a) {\n return type(int256).min;\n }\n```\n
medium
```\nrequire(accumulatedNOTEPerNToken < type(uint128).max); // dev: accumulated NOTE overflow\n```\n
low
```\n// BBLeverage.sol\n\nfunction buyCollateral(address from, uint256 borrowAmount, uint256 supplyAmount, bytes calldata data) \n external\n optionNotPaused(PauseType.LeverageBuy)\n solvent(from, false)\n notSelf(from) \n returns (uint256 amountOut) \n { \n // rest of code\n\n \n { \n amountOut = leverageExecutor.getCollateral( \n collateralId, \n address(asset),\n address(collateral),\n memoryData.supplyShareToAmount + memoryData.borrowShareToAmount,\n calldata_.from,\n calldata_.data\n );\n }\n // rest of code\n }\n \n function sellCollateral(address from, uint256 share, bytes calldata data)\n external\n optionNotPaused(PauseType.LeverageSell)\n solvent(from, false)\n notSelf(from)\n returns (uint256 amountOut)\n {\n // rest of code\n\n amountOut = leverageExecutor.getAsset(\n assetId, address(collateral), address(asset), memoryData.leverageAmount, from, data\n ); \n\n // rest of code\n } \n```\n
medium
```\nfunction confirmDeposit() public override onlyKeeper {\n require(depositStatus.inProcess, "DEPOSIT\_COMPLETED");\n \_confirmDeposit();\n depositStatus.inProcess = false;\n}\n```\n
low
```\nfunction setNumTokensSellToAddToLiquidity(uint256 numTokens) external onlyOwner {\n numTokensSellToAddToLiquidity = numTokens;\n}\n```\n
none
```\nfunction verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n) internal pure returns (bytes memory) {\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 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
```\nconstructor() {\n address msgSender = _msgSender();\n _owner = msgSender;\n emit OwnershipTransferred(address(0), msgSender);\n}\n```\n
none
```\nfunction mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\n require(b != 0, errorMessage);\n return a % b;\n}\n```\n
none
```\nfunction _revokeRole(bytes32 role, address account) private {\n if (hasRole(role, account)) {\n _roles[role].members[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n }\n}\n```\n
none
```\nfunction recalculateNftPower(uint256 tokenId) public override returns (uint256 newPower) {\n // @audit execution allowed to continue when\n // block.timestamp == powerCalcStartTimestamp\n if (block.timestamp < powerCalcStartTimestamp) {\n return 0;\n }\n // @audit getNftPower() returns 0 when\n // block.timestamp == powerCalcStartTimestamp\n newPower = getNftPower(tokenId);\n\n NftInfo storage nftInfo = nftInfos[tokenId];\n\n // @audit as this is the first update since power\n // calculation has just started, totalPower will be\n // subtracted by nft's max power\n totalPower -= nftInfo.lastUpdate != 0 ? nftInfo.currentPower : getMaxPowerForNft(tokenId);\n // @audit totalPower += 0 (newPower = 0 in above line)\n totalPower += newPower;\n\n nftInfo.lastUpdate = uint64(block.timestamp);\n // @audit will set nft's current power to 0\n nftInfo.currentPower = newPower;\n}\n\nfunction getNftPower(uint256 tokenId) public view override returns (uint256) {\n // @audit execution always returns 0 when\n // block.timestamp == powerCalcStartTimestamp\n if (block.timestamp <= powerCalcStartTimestamp) {\n return 0;\n```\n
high
```\n function addToTotalRewards(uint256 _basketId) internal onlyBasketOwner(_basketId) {\n if (baskets[_basketId].nrOfAllocatedTokens == 0) return;\n\n\n uint256 vaultNum = baskets[_basketId].vaultNumber;\n uint256 currentRebalancingPeriod = vaults[vaultNum].rebalancingPeriod;\n uint256 lastRebalancingPeriod = baskets[_basketId].lastRebalancingPeriod;\n\n\n if (currentRebalancingPeriod <= lastRebalancingPeriod) return;\n\n\n for (uint k = 0; k < chainIds.length; k++) {\n uint32 chain = chainIds[k];\n uint256 latestProtocol = latestProtocolId[chain];\n for (uint i = 0; i < latestProtocol; i++) {\n int256 allocation = basketAllocationInProtocol(_basketId, chain, i) / 1E18;\n if (allocation == 0) continue;\n\n\n int256 lastRebalanceReward = getRewardsPerLockedToken(\n vaultNum,\n chain,\n lastRebalancingPeriod,\n i\n );\n int256 currentReward = getRewardsPerLockedToken(\n vaultNum,\n chain,\n currentRebalancingPeriod,\n i\n );\n baskets[_basketId].totalUnRedeemedRewards +=\n (currentReward - lastRebalanceReward) *\n allocation;\n }\n }\n }\n```\n
medium
```\nuint256 constant AMOUNT\_PER\_SHARE = 1e18;\n```\n
low
```\nfunction setSellTaxes(uint256 _newSellDevelopment, uint256 _newSellOperations) external onlyOwner {\n SellDevelopment = _newSellDevelopment;\n SellOperations = _newSellOperations;\n sellTaxes = SellDevelopment.add(SellOperations);\n emit SellFeesUpdated(SellDevelopment, SellOperations);\n}\n```\n
none
```\n if (shares.gt(_maxRedeemAtEpoch(context, accountContext, account))) revert BalancedVaultRedemptionLimitExceeded();\n```\n
medium