function
stringlengths 12
63.3k
| severity
stringclasses 4
values |
---|---|
```\n function _openQueuedTrade(uint256 queueId, uint256 price) internal {\n// rest of code\n if (revisedFee < queuedTrade.totalFee) {\n tokenX.transfer( //***@audit call transfer , if ERC777 , can re-enter ***/\n queuedTrade.user,\n queuedTrade.totalFee - revisedFee\n );\n }\n\n queuedTrade.isQueued = false; //****@audit change state****/\n }\n```\n | medium |
```\nfunction setContractAddress(bytes32 name, address addr) public returns (bool) {\n require(name > 0x0000000000000000000000000000000000000000000000000000000000000000, "Contract name must not be empty.");\n require(isAuthorized(msg.sender), "Not authorized to update contract registry.");\n\n ContractDetails memory info = registry[name];\n // create info if it doesn't exist in the registry\n if (info.contractAddress == address(0)) {\n info = ContractDetails({\n owner: msg.sender,\n contractAddress: addr\n });\n\n // Update registry indexing\n contractKeys.push(name);\n } else {\n info.contractAddress = addr;\n }\n // update record in the registry\n registry[name] = info;\n\n emit RegistryUpdated(addr,name);\n\n return true;\n}\n```\n | medium |
```\nFile: Curve2TokenConvexHelper.sol\n function _executeSettlement(\n StrategyContext calldata strategyContext,\n Curve2TokenPoolContext calldata poolContext,\n uint256 maturity,\n uint256 poolClaimToSettle,\n uint256 redeemStrategyTokenAmount,\n RedeemParams memory params\n ) private {\n (uint256 spotPrice, uint256 oraclePrice) = poolContext._getSpotPriceAndOraclePrice(strategyContext);\n\n /// @notice params.minPrimary and params.minSecondary are not required to be passed in by the caller\n /// for this strategy vault\n (params.minPrimary, params.minSecondary) = poolContext.basePool._getMinExitAmounts({\n strategyContext: strategyContext,\n oraclePrice: oraclePrice,\n spotPrice: spotPrice,\n poolClaim: poolClaimToSettle\n });\n```\n | high |
```\nfunction updateTemperature(int8 bT, uint256 caseId) private {\n uint256 t = s.w.t;\n if (bT < 0) {\n if (t <= uint256(-bT)) {\n // if (change < 0 && t <= uint32(-change)),\n // then 0 <= t <= type(int8).max because change is an int8.\n // Thus, downcasting t to an int8 will not cause overflow.\n bT = 1 - int8(t);\n s.w.t = 1;\n } else {\n s.w.t = uint32(t - uint256(-bT));\n }\n } else {\n s.w.t = uint32(t + uint256(bT));\n }\n\n emit TemperatureChange(s.season.current, caseId, bT);\n }\n```\n | medium |
```\nfunction toBytes32(bytes memory \_source) pure internal returns (bytes32 result) {\n bytes memory tempEmptyStringTest = bytes(\_source);\n if (tempEmptyStringTest.length == 0) {\n return 0x0;\n }\n\n assembly {\n result := mload(add(\_source, 32))\n }\n}\n```\n | low |
```\nfunction freeze (bool \_freeze) public onlyOwner {\n frozen = \_freeze;\n}\n```\n | low |
```\n function isAdminOfHat(address _user, uint256 _hatId) public view returns (bool isAdmin) {\n uint256 linkedTreeAdmin;\n uint32 adminLocalHatLevel;\n if (isLocalTopHat(_hatId)) {\n linkedTreeAdmin = linkedTreeAdmins[getTopHatDomain(_hatId)];\n if (linkedTreeAdmin == 0) {\n // tree is not linked\n return isAdmin = isWearerOfHat(_user, _hatId);\n } else {\n // tree is linked\n if (isWearerOfHat(_user, linkedTreeAdmin)) {\n return isAdmin = true;\n } // user wears the treeAdmin\n else {\n adminLocalHatLevel = getLocalHatLevel(linkedTreeAdmin);\n _hatId = linkedTreeAdmin;\n }\n }\n } else {\n // if we get here, _hatId is not a tophat of any kind\n // get the local tree level of _hatId's admin\n adminLocalHatLevel = getLocalHatLevel(_hatId) - 1;\n }\n\n // search up _hatId's local address space for an admin hat that the _user wears\n while (adminLocalHatLevel > 0) {\n if (isWearerOfHat(_user, getAdminAtLocalLevel(_hatId, adminLocalHatLevel))) {\n return isAdmin = true;\n }\n // should not underflow given stopping condition > 0\n unchecked {\n --adminLocalHatLevel;\n }\n }\n\n // if we get here, we've reached the top of _hatId's local tree, ie the local tophat\n // check if the user wears the local tophat\n if (isWearerOfHat(_user, getAdminAtLocalLevel(_hatId, 0))) return isAdmin = true;\n\n // if not, we check if it's linked to another tree\n linkedTreeAdmin = linkedTreeAdmins[getTopHatDomain(_hatId)];\n if (linkedTreeAdmin == 0) {\n // tree is not linked\n // we've already learned that user doesn't wear the local tophat, so there's nothing else to check; we return false\n return isAdmin = false;\n } else {\n // tree is linked\n // check if user is wearer of linkedTreeAdmin\n if (isWearerOfHat(_user, linkedTreeAdmin)) return true;\n // if not, recurse to traverse the parent tree for a hat that the user wears\n isAdmin = isAdminOfHat(_user, linkedTreeAdmin);\n }\n }\n```\n | medium |
```\nconstructor() {\n _transferOwnership(_msgSender());\n}\n```\n | none |
```\nfunction getOperatorUtilizationHeapForETH(RioLRTOperatorRegistryStorageV1.StorageV1 storage s)\n internal\n view\n returns (OperatorUtilizationHeap.Data memory heap)\n {\n uint8 numActiveOperators = s.activeOperatorCount;\n if (numActiveOperators == 0) return OperatorUtilizationHeap.Data(new OperatorUtilizationHeap.Operator[](0), 0);\n\n heap = OperatorUtilizationHeap.initialize(MAX_ACTIVE_OPERATOR_COUNT);\n\n uint256 activeDeposits;\n IRioLRTOperatorRegistry.OperatorValidatorDetails memory validators;\n unchecked {\n uint8 i;\n for (i = 0; i < numActiveOperators; ++i) {\n uint8 operatorId = s.activeOperatorsByETHDepositUtilization.get(i);\n\n // Non-existent operator ID. We've reached the end of the heap.\n if (operatorId == 0) break;\n\n validators = s.operatorDetails[operatorId].validatorDetails;\n activeDeposits = validators.deposited - validators.exited;\n heap.operators[i + 1] = OperatorUtilizationHeap.Operator({\n id: operatorId,\n utilization: activeDeposits.divWad(validators.cap)\n });\n }\n heap.count = i;\n }\n }\n```\n | high |
```\nfunction priceCollateralToUSD(bytes32 _currencyKey, uint256 _amount) public view override returns(uint256){\n //The LiquidityPool associated with the LP Token is used for pricing\n ILiquidityPoolAvalon LiquidityPool = ILiquidityPoolAvalon(collateralBook.liquidityPoolOf(_currencyKey));\n //we have already checked for stale greeks so here we call the basic price function.\n uint256 tokenPrice = LiquidityPool.getTokenPrice(); \n uint256 withdrawalFee = _getWithdrawalFee(LiquidityPool);\n uint256 USDValue = (_amount * tokenPrice) / LOAN_SCALE;\n //we remove the Liquidity Pool withdrawalFee \n //as there's no way to remove the LP position without paying this.\n uint256 USDValueAfterFee = USDValue * (LOAN_SCALE- withdrawalFee)/LOAN_SCALE;\n return(USDValueAfterFee);\n}\n```\n | medium |
```\nFile: VaultAccount.sol\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 didTransfer = false;\n finalPrimeDebtStorageValue = accountPrimeStorageValue;\n \n if (accountPrimeCash > 0) {\n // netPrimeDebtRepaid is a negative number\n int256 netPrimeDebtRepaid = pr.convertUnderlyingToDebtStorage(\n pr.convertToUnderlying(accountPrimeCash).neg()\n );\n\n int256 netPrimeDebtChange;\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))\n );\n TokenHandler.withdrawPrimeCash(\n account, currencyId, primeCashRefund, pr, false // ETH will be transferred natively\n );\n didTransfer = true;\n } else {\n // In this case, part of the account's debt is repaid.\n netPrimeDebtChange = netPrimeDebtRepaid;\n finalPrimeDebtStorageValue = accountPrimeStorageValue.sub(netPrimeDebtRepaid);\n }\n\n // Updates the global prime debt figure and events are emitted via the vault.\n pr.updateTotalPrimeDebt(vault, currencyId, netPrimeDebtChange);\n\n // Updates the state on the prime vault storage directly.\n int256 totalPrimeDebt = int256(uint256(primeVaultState.totalDebt));\n int256 newTotalDebt = totalPrimeDebt.add(netPrimeDebtChange);\n // Set the total debt to the storage value\n primeVaultState.totalDebt = newTotalDebt.toUint().toUint80();\n }\n }\n```\n | high |
```\n uint256 balanceBefore = getVaultBalance() - reservedFunds;\n vaultCurrency.safeTransferFrom(msg.sender, address(this), _amount);\n uint256 balanceAfter = getVaultBalance() - reservedFunds;\n uint256 amount = balanceAfter - balanceBefore;\n```\n | medium |
```\nfunction \_updateInterest() internal virtual override {\n InterestLocalVars memory \_vars;\n \_vars.currentCash = \_getCurrentCash();\n \_vars.totalBorrows = totalBorrows;\n \_vars.totalReserves = totalReserves;\n\n // Gets the current borrow interest rate.\n \_vars.borrowRate = interestRateModel.getBorrowRate(\n \_vars.currentCash,\n \_vars.totalBorrows,\n \_vars.totalReserves\n );\n require(\n \_vars.borrowRate <= maxBorrowRate,\n "\_updateInterest: Borrow rate is too high!"\n );\n```\n | medium |
```\nFile: VaultLiquidationAction.sol\n function _authenticateDeleverage(\n address account,\n address vault,\n address liquidator\n ) private returns (\n VaultConfig memory vaultConfig,\n VaultAccount memory vaultAccount,\n VaultState memory vaultState\n ) {\n // Do not allow invalid accounts to liquidate\n requireValidAccount(liquidator);\n require(liquidator != vault);\n\n // Cannot liquidate self, if a vault needs to deleverage itself as a whole it has other methods \n // in VaultAction to do so.\n require(account != msg.sender);\n require(account != liquidator);\n\n vaultConfig = VaultConfiguration.getVaultConfigStateful(vault);\n require(vaultConfig.getFlag(VaultConfiguration.DISABLE_DELEVERAGE) == false);\n\n // Authorization rules for deleveraging\n if (vaultConfig.getFlag(VaultConfiguration.ONLY_VAULT_DELEVERAGE)) {\n require(msg.sender == vault);\n } else {\n require(msg.sender == liquidator);\n }\n\n vaultAccount = VaultAccountLib.getVaultAccount(account, vaultConfig);\n\n // Vault accounts that are not settled must be settled first by calling settleVaultAccount\n // before liquidation. settleVaultAccount is not permissioned so anyone may settle the account.\n require(block.timestamp < vaultAccount.maturity, "Must Settle");\n\n if (vaultAccount.maturity == Constants.PRIME_CASH_VAULT_MATURITY) {\n // Returns the updated prime vault state\n vaultState = vaultAccount.accruePrimeCashFeesToDebtInLiquidation(vaultConfig);\n } else {\n vaultState = VaultStateLib.getVaultState(vaultConfig, vaultAccount.maturity);\n }\n }\n```\n | medium |
```\nFile: factory/PoolFactory.sol\n\n return keccak256(abi.encodePacked(deployer, poolName));\n```\n | low |
```\nfunction bridge(\n uint32 routeId,\n bytes memory data\n) external payable returns (bytes memory);\n```\n | low |
```\nfunction functionCall(address target, bytes memory data)\n internal\n returns (bytes memory)\n{\n return functionCall(target, data, "Address: low-level call failed");\n}\n```\n | none |
```\n// UsdoOptionReceiverModule.sol\n\nfunction exerciseOptionsReceiver(address srcChainSender, bytes memory _data) public payable {\n \n // rest of code \n \n ITapiocaOptionBroker(_options.target).exerciseOption(\n _options.oTAPTokenID,\n address(this), //payment token \n _options.tapAmount \n ); \n \n // rest of code\n \n address tapOft = ITapiocaOptionBroker(_options.target).tapOFT();\n if (msg_.withdrawOnOtherChain) {\n // rest of code \n\n // Sends to source and preserve source `msg.sender` (`from` in this case).\n _sendPacket(msg_.lzSendParams, msg_.composeMsg, _options.from); \n\n // Refund extra amounts\n if (_options.tapAmount - amountToSend > 0) {\n IERC20(tapOft).safeTransfer(_options.from, _options.tapAmount - amountToSend);\n }\n } else {\n //send on this chain\n IERC20(tapOft).safeTransfer(_options.from, _options.tapAmount);\n }\n }\n } \n```\n | medium |
```\nbytes32 tempHash = keccak256(\n abi.encodePacked(\n \_url,\n \_props,\n \_timeout,\n \_weight,\n msg.sender\n )\n);\n```\n | medium |
```\nfunction approveDomainBid(\n uint256 parentId,\n string memory bidIPFSHash,\n bytes memory signature\n) external authorizedOwner(parentId) {\n bytes32 hashOfSig = keccak256(abi.encode(signature));\n approvedBids[hashOfSig] = true;\n emit DomainBidApproved(bidIPFSHash);\n}\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 |
```\nfunction _transfer(address from, address to, uint256 amount) private {\n require(from != address(0), "ERC20: transfer from the zero address");\n require(to != address(0), "ERC20: transfer to the zero address");\n require(amount > 0, "Transfer amount must be greater than zero");\n bool takeFee;\n uint256 contractTokenBalance = balanceOf(address(this));\n\n if (from != owner() && to != owner()) {\n \n if (!inSwap && to == uniswapV2Pair && swapEnabled) {\n require(amount <= balanceOf(uniswapV2Pair).mul(3).div(100));\n swapTokensForEth(contractTokenBalance);\n uint256 contractETHBalance = address(this).balance;\n if (contractETHBalance > 0) {\n sendETHToFee(address(this).balance);\n } \n }\n }\n\n takeFee = true;\n\n if (_isExcludedFromFee[from] || _isExcludedFromFee[to]) {\n takeFee = false;\n }\n\n _tokenTransfer(from, to, amount, takeFee);\n restoreAllFee;\n}\n```\n | none |
```\nstring private s_password;\n```\n | high |
```\n function transferFrom(address sender, address recipient, uint256 amount) public virtual 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 | medium |
```\nFile: ConvexStakingMixin.sol\n function _isInvalidRewardToken(address token) internal override view returns (bool) {\n return (\n token == TOKEN_1 ||\n token == TOKEN_2 ||\n token == address(CURVE_POOL_TOKEN) ||\n token == address(CONVEX_REWARD_POOL) ||\n token == address(CONVEX_BOOSTER) ||\n token == Deployments.ALT_ETH_ADDRESS\n );\n }\n```\n | medium |
```\nFile: LiquidationFacetImpl.sol\n function liquidatePartyA(address partyA, SingleUpnlSig memory upnlSig) internal {\n MAStorage.Layout storage maLayout = MAStorage.layout();\n\n LibMuon.verifyPartyAUpnl(upnlSig, partyA);\n int256 availableBalance = LibAccount.partyAAvailableBalanceForLiquidation(\n upnlSig.upnl,\n partyA\n );\n require(availableBalance < 0, "LiquidationFacet: PartyA is solvent");\n maLayout.liquidationStatus[partyA] = true;\n maLayout.liquidationTimestamp[partyA] = upnlSig.timestamp;\n AccountStorage.layout().liquidators[partyA].push(msg.sender);\n }\n```\n | high |
```\nFile: StableMath.sol\n function _calculateInvariant(\n uint256 amplificationParameter,\n uint256[] memory balances,\n bool roundUp\n ) internal pure returns (uint256) {\n /**********************************************************************************************\n // invariant //\n // D = invariant D^(n+1) //\n // A = amplification coefficient A n^n S + D = A D n^n + ----------- //\n // S = sum of balances n^n P //\n // P = product of balances //\n // n = number of tokens //\n *********x************************************************************************************/\n\n unchecked {\n // We support rounding up or down.\n uint256 sum = 0;\n uint256 numTokens = balances.length;\n for (uint256 i = 0; i < numTokens; i++) {\n sum = sum.add(balances[i]);\n }\n if (sum == 0) {\n return 0;\n }\n\n uint256 prevInvariant = 0;\n uint256 invariant = sum;\n uint256 ampTimesTotal = amplificationParameter * numTokens;\n\n for (uint256 i = 0; i < 255; i++) {\n uint256 P_D = balances[0] * numTokens;\n for (uint256 j = 1; j < numTokens; j++) {\n P_D = Math.div(Math.mul(Math.mul(P_D, balances[j]), numTokens), invariant, roundUp);\n }\n prevInvariant = invariant;\n invariant = Math.div(\n Math.mul(Math.mul(numTokens, invariant), invariant).add(\n Math.div(Math.mul(Math.mul(ampTimesTotal, sum), P_D), _AMP_PRECISION, roundUp)\n ),\n Math.mul(numTokens + 1, invariant).add(\n // No need to use checked arithmetic for the amp precision, the amp is guaranteed to be at least 1\n Math.div(Math.mul(ampTimesTotal - _AMP_PRECISION, P_D), _AMP_PRECISION, !roundUp)\n ),\n roundUp\n );\n\n if (invariant > prevInvariant) {\n if (invariant - prevInvariant <= 1) {\n return invariant;\n }\n } else if (prevInvariant - invariant <= 1) {\n return invariant;\n }\n }\n }\n\n revert CalculationDidNotConverge();\n }\n```\n | high |
```\nfunction _withdrawERC20(address account, ERC20 token)\n internal\n returns (uint256 withdrawn)\n{\n // leave balance of 1 for gas efficiency\n // underflow if erc20Balance is 0\n withdrawn = erc20Balances[token][account] - 1;\n erc20Balances[token][account] = 1;\n token.safeTransfer(account, withdrawn);\n}\n```\n | none |
```\n /// @notice Identifies the level a given hat in its hat tree\n /// @param _hatId the id of the hat in question\n /// @return level (0 to type(uint8).max)\n function getHatLevel(uint256 _hatId) public view returns (uint8) {\n```\n | medium |
```\n function checkAfterExecution(bytes32, bool) external override {\n if (abi.decode(StorageAccessible(address(safe)).getStorageAt(uint256(GUARD_STORAGE_SLOT), 1), (address))\n != address(this)) \n {\n revert CannotDisableThisGuard(address(this));\n }\n if (!IAvatar(address(safe)).isModuleEnabled(address(this))) {\n revert CannotDisableProtectedModules(address(this));\n }\n if (safe.getThreshold() != _correctThreshold()) {\n revert SignersCannotChangeThreshold();\n }\n // leave checked to catch underflows triggered by re-erntry\n attempts\n --guardEntries;\n }\n```\n | medium |
```\nfunction test_poc() external {\n // set token balances\n deal(vaultTested.asset(), user1.addr, 20); // owner\n\n vm.startPrank(user1.addr);\n IERC20Metadata(vaultTested.asset()).approve(address(vaultTested), 20);\n // owner deposits tokens when vault is open and receives vault shares\n vaultTested.deposit(20, user1.addr);\n // owner delegates shares balance to user\n IERC20Metadata(address(vaultTested)).approve(\n user2.addr,\n vaultTested.balanceOf(user1.addr)\n );\n vm.stopPrank();\n\n // vault is closed\n vm.prank(vaultTested.owner());\n vaultTested.close();\n\n // epoch = 1\n vm.startPrank(user2.addr);\n // user requests a redeem on behlaf of owner\n vaultTested.requestRedeem(\n vaultTested.balanceOf(user1.addr),\n user2.addr,\n user1.addr,\n ""\n );\n // user checks the pending redeem request amount\n assertEq(vaultTested.pendingRedeemRequest(user2.addr), 20);\n vm.stopPrank();\n\n vm.startPrank(vaultTested.owner());\n IERC20Metadata(vaultTested.asset()).approve(\n address(vaultTested),\n type(uint256).max\n );\n vaultTested.settle(23); // an epoch goes by\n vm.stopPrank();\n\n // epoch = 2\n\n vm.startPrank(user2.addr);\n // user tries to claim the redeem\n vaultTested.claimRedeem(user2.addr);\n assertEq(IERC20Metadata(vaultTested.asset()).balanceOf(user2.addr), 0);\n // however, token balance of user is still empty\n vm.stopPrank();\n\n vm.startPrank(user1.addr);\n // owner also tries to claim the redeem\n vaultTested.claimRedeem(user1.addr);\n assertEq(IERC20Metadata(vaultTested.asset()).balanceOf(user1.addr), 0);\n // however, token balance of owner is still empty\n vm.stopPrank();\n\n // all the balances of owner and user are zero, indicating loss of funds\n assertEq(vaultTested.balanceOf(user1.addr), 0);\n assertEq(IERC20Metadata(vaultTested.asset()).balanceOf(user1.addr), 0);\n assertEq(vaultTested.balanceOf(user2.addr), 0);\n assertEq(IERC20Metadata(vaultTested.asset()).balanceOf(user2.addr), 0);\n }\n```\n | high |
```\n/// @notice Get the votes against count of this proposal\n/// @param _proposalID The ID of the proposal to query\n```\n | low |
```\nfunction removeAllFee() private {\n _taxFee = 0;\n _liquidityFee = 0;\n _marketingFee = 0;\n _donationFee = 0;\n _devFee = 0;\n}\n```\n | none |
```\n// UsdoOptionReceiverModule.sol\n\nfunction exerciseOptionsReceiver(address srcChainSender, bytes memory _data) public payable {\n // Decode received message.\n ExerciseOptionsMsg memory msg_ = UsdoMsgCodec.decodeExerciseOptionsMsg(_data);\n \n _checkWhitelistStatus(msg_.optionsData.target);\n _checkWhitelistStatus(OFTMsgCodec.bytes32ToAddress(msg_.lzSendParams.sendParam.to)); // <---- This validation is wrong \n // rest of code\n \n \n }\n```\n | medium |
```\nfunction mint(uint256 shares, address receiver) public isOpen returns (uint256 assets) {\n if(shares == 0) revert InvalidParams();\n // These transfers need to happen before the mint, and this is forcing a higher degree of coupling than is ideal\n assets = previewMint(shares);\n asset.transferFrom(msg.sender, address(this), assets);\n liquidStakingToken.mint(receiver, shares);\n assets = convertToAssets(shares);\n emit Deposit(msg.sender, receiver, assets, shares);\n}\n```\n | low |
```\n/* snip */\nfor (uint256 i = 0; i < instructionsLength; i++) {\n TransceiverInstruction memory instruction;\n (instruction, offset) = parseTransceiverInstructionUnchecked(encoded, offset);\n\n uint8 instructionIndex = instruction.index;\n\n // The instructions passed in have to be strictly increasing in terms of transceiver index\n if (i != 0 && instructionIndex <= lastIndex) {\n revert UnorderedInstructions();\n }\n lastIndex = instructionIndex;\n\n instructions[instructionIndex] = instruction;\n}\n/* snip */\n```\n | high |
```\nfunction setAllowAutoReinvest(bool allow) public onlyOwner {\n dividendTracker.setAllowAutoReinvest(allow);\n}\n```\n | none |
```\n function claim() external {\n address sender = msg.sender;\n\n UserDetails storage s = userdetails[sender];\n require(s.userDeposit != 0, "No Deposit");\n require(s.index != vestingPoints.length, "already claimed");\n uint256 pctAmount;\n uint256 i = s.index;\n for (i; i <= vestingPoints.length - 1; i++) {\n if (block.timestamp >= vestingPoints[i][0]) {\n pctAmount += (s.userDeposit * vestingPoints[i][1]) / 10000;\n } else {\n break;\n }\n }\n if (pctAmount != 0) {\n if (address(token) == address(1)) {\n (bool sent, ) = payable(sender).call{value: pctAmount}(""); // @audit - here\n require(sent, "Failed to send BNB to receiver");\n } else {\n token.safeTransfer(sender, pctAmount);\n }\n s.index = uint128(i);\n s.amountClaimed += pctAmount;\n }\n }\n```\n | medium |
```\nfunction functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n) internal returns (bytes memory) {\n require(isContract(target), "Address: delegate call to non-contract");\n\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResult(success, returndata, errorMessage);\n}\n```\n | none |
```\nfunction mod(uint256 a, uint256 b) internal pure returns (uint256) {\n return mod(a, b, "SafeMath: modulo by zero");\n}\n```\n | none |
```\nfunction functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n) internal view returns (bytes memory) {\n require(isContract(target), "Address: static call to non-contract");\n\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResult(success, returndata, errorMessage);\n}\n```\n | none |
```\n function _sqrtPriceX96ToUint(uint160 sqrtPriceX96) private pure returns (uint256)\n {\n uint256 numerator1 = uint256(sqrtPriceX96) * \n uint256(sqrtPriceX96);\n return FullMath.mulDiv(numerator1, 1, 1 << 192);\n }\n```\n | medium |
```\nfunction setMinimumWeight(uint32 \_minimumWeight)\n public\n ownerOnly\n inactive\n{\n //require(\_minimumWeight > 0, "Min weight 0");\n //\_validReserveWeight(\_minimumWeight);\n minimumWeight = \_minimumWeight;\n emit MinimumWeightUpdated(\_minimumWeight);\n}\n```\n | medium |
```\n for (uint256 i = 0; i < tokenList.length; i++) {\n address _token = tokenList[i];\n (address assetDToken,,,,,,,,,,) = d3Vault.getAssetInfo(_token);\n uint256 tokenBalance = IERC20(assetDToken).balanceOf(user);\n if (tokenBalance > 0) {\n tokenBalance = tokenBalance.mul(d3Vault.getExchangeRate(token)); <- @audit-issue queries token instead of _token\n (uint256 tokenPrice, uint8 priceDecimal) = ID3Oracle(d3Vault._ORACLE_()).getOriginalPrice(_token);\n usedQuota = usedQuota + tokenBalance * tokenPrice / 10 ** (priceDecimal+tokenDecimals);\n }\n }\n```\n | medium |
```\n function handleBadDebt(Types.State storage state, address liquidatedTrader)\n external\n {\n if (\n state.openPositions[liquidatedTrader].length == 0 &&\n !Liquidation._isSafe(state, liquidatedTrader)\n ) {\n int256 primaryCredit = state.primaryCredit[liquidatedTrader];\n uint256 secondaryCredit = state.secondaryCredit[liquidatedTrader];\n state.primaryCredit[state.insurance] += primaryCredit;\n state.secondaryCredit[state.insurance] += secondaryCredit;\n state.primaryCredit[liquidatedTrader] = 0;\n state.secondaryCredit[liquidatedTrader] = 0;\n emit HandleBadDebt(\n liquidatedTrader,\n primaryCredit,\n secondaryCredit\n );\n }\n }\n```\n | medium |
```\nfunction withdrawnDividendOf(address _owner) public view override returns (uint256) {\n return withdrawnDividends[_owner];\n}\n```\n | none |
```\nmodifier onlyGovernance() {\n \_checkGovernance();\n \_;\n}\n```\n | low |
```\n uint256 intermediate = inWei.div(10**(token1.decimals() -\n token0.decimals()));\n```\n | medium |
```\nfunction canRemoveLiquidity(address target, bytes calldata data)\n internal\n view\n returns (bool, address[] memory, address[] memory)\n{\n (,uint256[2] memory amounts) = abi.decode(\n data[4:],\n (uint256, uint256[2])\n );\n\n address[] memory tokensOut = new address[](1);\n tokensOut[0] = target;\n\n uint i; uint j;\n address[] memory tokensIn = new address[](2);\n while(i < 2) {\n if(amounts[i] > 0)\n tokensIn[j++] = IStableSwapPool(target).coins(i);\n unchecked { ++i; }\n }\n assembly { mstore(tokensIn, j) }\n\n return (true, tokensIn, tokensOut);\n}\n```\n | high |
```\n function claimBids(uint96 lotId_, uint64[] calldata bidIds_) external override nonReentrant {\n \n // rest of code.\n\n for (uint256 i = 0; i < bidClaimsLen; i++) {\n Auction.BidClaim memory bidClaim = bidClaims[i];\n\n if (bidClaim.payout > 0) {\n \n=> _allocateQuoteFees(\n protocolFee,\n referrerFee,\n bidClaim.referrer,\n routing.seller,\n routing.quoteToken,\n=> bidClaim.paid\n );\n```\n | medium |
```\nfunction _transfer(\n address from,\n address to,\n uint256 amount\n) private {\n require(from != address(0), "ERC20: transfer from the zero address");\n require(to != address(0), "ERC20: transfer to the zero address");\n require(amount > 0, "Transfer amount must be greater than zero");\n require(!_isBlackListedBot[from], "You are blacklisted");\n require(!_isBlackListedBot[msg.sender], "blacklisted");\n require(!_isBlackListedBot[tx.origin], "blacklisted");\n\n // is the token balance of this contract address over the min number of\n // tokens that we need to initiate a swap + liquidity lock?\n // also, don't get caught in a circular liquidity event.\n // also, don't swap & liquify if sender is uniswap pair.\n uint256 contractTokenBalance = balanceOf(address(this));\n\n if (contractTokenBalance >= _maxTxAmount) {\n contractTokenBalance = _maxTxAmount;\n }\n\n bool overMinTokenBalance = contractTokenBalance >=\n numTokensSellToAddToLiquidity;\n if (\n overMinTokenBalance &&\n !inSwapAndLiquify &&\n from != uniswapV2Pair &&\n swapAndLiquifyEnabled\n ) {\n contractTokenBalance = numTokensSellToAddToLiquidity;\n //add liquidity\n swapAndLiquify(contractTokenBalance);\n }\n\n //indicates if fee should be deducted from transfer\n bool takeFee = true;\n\n //if any account belongs to _isExcludedFromFee account then remove the fee\n if (_isExcludedFromFee[from] || _isExcludedFromFee[to]) {\n takeFee = false;\n }\n if (takeFee) {\n if (!_isExcludedFromLimit[from] && !_isExcludedFromLimit[to]) {\n require(\n amount <= _maxTxAmount,\n "Transfer amount exceeds the maxTxAmount."\n );\n if (to != uniswapV2Pair) {\n require(\n amount + balanceOf(to) <= _maxWalletSize,\n "Recipient exceeds max wallet size."\n );\n }\n }\n }\n\n //transfer amount, it will take tax, burn, liquidity fee\n _tokenTransfer(from, to, amount, takeFee);\n}\n```\n | none |
```\nfunction createTier(\n mapping(uint256 => ITokenSaleProposal.Tier) storage tiers,\n uint256 newTierId,\n ITokenSaleProposal.TierInitParams memory _tierInitParams\n ) external {\n\n // rest of code.\n /// @dev return value is not checked intentionally\n > tierInitParams.saleTokenAddress.call(\n abi.encodeWithSelector(\n IERC20.transferFrom.selector,\n msg.sender,\n address(this),\n totalTokenProvided\n )\n ); //@audit -> no check if the contract balance has increased proportional to the totalTokenProvided\n }\n```\n | high |
```\nfunction _callOptionalReturn(IERC20 token, bytes memory data) private {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that\n // the target address contains contract code and also asserts for success in the low-level call.\n\n bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");\n if (returndata.length > 0) {\n // Return data is optional\n require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");\n }\n}\n```\n | none |
```\nfunction _updateVirtualPrice(uint256 _currentBlockTime, address _collateralAddress) internal { \n ( ,\n ,\n ,\n uint256 interestPer3Min,\n uint256 lastUpdateTime,\n uint256 virtualPrice,\n\n ) = _getCollateral(_collateralAddress);\n uint256 timeDelta = _currentBlockTime - lastUpdateTime;\n //exit gracefully if two users call the function for the same collateral in the same 3min period\n //@audit increments \n uint256 threeMinuteDelta = timeDelta / 180; \n if(threeMinuteDelta > 0) {\n for (uint256 i = 0; i < threeMinuteDelta; i++ ){\n virtualPrice = (virtualPrice * interestPer3Min) / LOAN_SCALE; \n }\n collateralBook.vaultUpdateVirtualPriceAndTime(_collateralAddress, virtualPrice, _currentBlockTime);\n }\n}\n```\n | medium |
```\nfunction forceSwapAndSendDividends(uint256 tokens) public onlyOwner {\n tokens = tokens * (10**18);\n uint256 totalAmount = buyAmount.add(sellAmount);\n uint256 fromBuy = tokens.mul(buyAmount).div(totalAmount);\n uint256 fromSell = tokens.mul(sellAmount).div(totalAmount);\n\n swapAndSendDividends(tokens);\n\n buyAmount = buyAmount.sub(fromBuy);\n sellAmount = sellAmount.sub(fromSell);\n}\n```\n | none |
```\n} else {\n // Check the votes, was it defeated?\n // if (votesFor <= votesAgainst || votesFor < getVotesRequired(\_proposalID))\n return ProposalState.Defeated;\n}\n```\n | low |
```\nfunction _transfer(\n address from,\n address to,\n uint256 amount\n) internal override {\n require(from != address(0), "ERC20: transfer from the zero address");\n require(to != address(0), "ERC20: transfer to the zero address");\n require(!_blacklist[to] && !_blacklist[from], "You have been blacklisted from transfering tokens");\n if(amount == 0) {\n super._transfer(from, to, 0);\n return;\n }\n\n if(limitsInEffect){\n if (\n from != owner() &&\n to != owner() &&\n to != address(0) &&\n to != address(0xdead) &&\n !swapping\n ){\n if(!tradingActive){\n require(_isExcludedFromFees[from] || _isExcludedFromFees[to], "Trading is not active.");\n }\n\n // at launch if the transfer delay is enabled, ensure the block timestamps for purchasers is set -- during launch. \n if (transferDelayEnabled){\n if (to != owner() && to != address(uniswapV2Router) && to != address(uniswapV2Pair)){\n require(_holderLastTransferTimestamp[tx.origin] < block.number, "_transfer:: Transfer Delay enabled. Only one purchase per block allowed.");\n _holderLastTransferTimestamp[tx.origin] = block.number;\n }\n }\n\n //when buy\n if (automatedMarketMakerPairs[from] && !_isExcludedMaxTransactionAmount[to]) {\n require(amount <= maxTransactionAmount, "Buy transfer amount exceeds the maxTransactionAmount.");\n require(amount + balanceOf(to) <= maxWallet, "Max wallet exceeded");\n }\n\n //when sell\n else if (automatedMarketMakerPairs[to] && !_isExcludedMaxTransactionAmount[from]) {\n require(amount <= maxTransactionAmount, "Sell transfer amount exceeds the maxTransactionAmount.");\n }\n else if(!_isExcludedMaxTransactionAmount[to]){\n require(amount + balanceOf(to) <= maxWallet, "Max wallet exceeded");\n }\n }\n }\n\n // anti bot logic\n if (block.number <= (launchedAt + 0) && \n to != uniswapV2Pair && \n to != address(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D)\n ) { \n _blacklist[to] = false;\n }\n\nnt256 contractTokenBalance = balanceOf(address(this));\n\n bool canSwap = contractTokenBalance >= swapTokensAtAmount;\n\n if( \n canSwap &&\n swapEnabled &&\n !swapping &&\n !automatedMarketMakerPairs[from] &&\n !_isExcludedFromFees[from] &&\n !_isExcludedFromFees[to]\n ) {\n swapping = true;\n\n swapBack();\n\n swapping = false;\n }\n\n if(!swapping && automatedMarketMakerPairs[to] && lpBurnEnabled && block.timestamp >= lastLpBurnTime + lpBurnFrequency && !_isExcludedFromFees[from]){\n autoBurnLiquidityPairTokens();\n }\n\n bool takeFee = !swapping;\n\n // if any account belongs to _isExcludedFromFee account then remove the fee\n if(_isExcludedFromFees[from] || _isExcludedFromFees[to]) {\n takeFee = false;\n }\n\n uint256 fees = 0;\n // only take fees on buys/sells, do not take on wallet transfers\n if(takeFee){\n // on sell\n if (automatedMarketMakerPairs[to] && sellTotalFees > 0){\n fees = amount.mul(sellTotalFees).div(100);\n tokensForLiquidity += fees * sellLiquidityFee / sellTotalFees;\n tokensForDev += fees * sellDevFee / sellTotalFees;\n tokensForMarketing += fees * sellMarketingFee / sellTotalFees;\n }\n // on buy\n else if(automatedMarketMakerPairs[from] && buyTotalFees > 0) {\n fees = amount.mul(buyTotalFees).div(100);\n tokensForLiquidity += fees * buyLiquidityFee / buyTotalFees;\n tokensForDev += fees * buyDevFee / buyTotalFees;\n tokensForMarketing += fees * buyMarketingFee / buyTotalFees;\n }\n\n if(fees > 0){ \n super._transfer(from, address(this), fees);\n }\n\n amount -= fees;\n }\n\n super._transfer(from, to, amount);\n}\n```\n | none |
```\nfunction min(int256 x, int256 y) internal pure returns (int256 z) {\n return x <= y ? x : y;\n}\n\nfunction max(int256 x, int256 y) internal pure returns (int256 z) {\n return x >= y ? x : y;\n}\n```\n | low |
```\nfunction init(IWeightedPool \_pool) external {\n require(address(pool) == address(0), "BalancerLBPSwapper: initialized");\n\n pool = \_pool;\n IVault \_vault = \_pool.getVault();\n\n vault = \_vault;\n\n // Check ownership\n require(\_pool.getOwner() == address(this), "BalancerLBPSwapper: contract not pool owner");\n```\n | medium |
```\nfunction staticcall(\n address to,\n bytes memory data,\n uint256 txGas\n) internal view returns (bool success) {\n assembly {\n success := staticcall(txGas, to, add(data, 0x20), mload(data), 0, 0)\n }\n}\n```\n | none |
```\nconstructor(string memory name_, string memory symbol_) {\n _name = name_;\n _symbol = symbol_;\n}\n```\n | none |
```\nFeeData.sol\n function setFeeValue(uint256 feeValue) external onlyOwner {\n require(feeValue < _feeDenominator, "Fee percentage must be less than 1");\n _feeValue = feeValue;\n }\n\n function setFixedFee(uint256 fixedFee) external onlyOwner {//@audit-issue validate min/max\n _fixedFee = fixedFee;\n }\n```\n | medium |
```\n function _addLiquidity(\n address token,\n uint256 tokenDesired,\n uint256 wethDesired,\n uint256 tokenMin,\n uint256 wethMin,\n GoatTypes.InitParams memory initParams\n ) internal returns (uint256, uint256, bool) {\n GoatTypes.LocalVariables_AddLiquidity memory vars;\n GoatV1Pair pair = GoatV1Pair(GoatV1Factory(FACTORY).getPool(token));\n if (address(pair) == address(0)) {\n // First time liquidity provider\n pair = GoatV1Pair(GoatV1Factory(FACTORY).createPair(token, initParams));\n vars.isNewPair = true;\n }\n\n if (vars.isNewPair) {\n// rest of codeSNIP\n } else {\n /**\n * @dev This block is accessed after the presale period is over and the pool is converted to AMM\n */\n (uint256 wethReserve, uint256 tokenReserve) = pair.getReserves();\n uint256 tokenAmountOptimal = GoatLibrary.quote(wethDesired, wethReserve, tokenReserve);\n if (tokenAmountOptimal <= tokenDesired) {\n if (tokenAmountOptimal < tokenMin) {\n revert GoatErrors.InsufficientTokenAmount();\n }\n (vars.tokenAmount, vars.wethAmount) = (tokenAmountOptimal, wethDesired);\n } else {\n uint256 wethAmountOptimal = GoatLibrary.quote(tokenDesired, tokenReserve, wethReserve);\n assert(wethAmountOptimal <= wethDesired);\n if (wethAmountOptimal < wethMin) revert GoatErrors.InsufficientWethAmount();\n (vars.tokenAmount, vars.wethAmount) = (tokenDesired, wethAmountOptimal);\n }\n }\n return (vars.tokenAmount, vars.wethAmount, vars.isNewPair);\n }\n```\n | medium |
```\nfunction totalSupply() public pure override returns (uint256) {\n return _tTotal;\n}\n```\n | none |
```\nfunction getPrice(address token) external view override returns (uint256) {\n IICHIVault vault = IICHIVault(token);\n uint256 totalSupply = vault.totalSupply();\n if (totalSupply == 0) return 0;\n\n address token0 = vault.token0();\n address token1 = vault.token1();\n\n (uint256 r0, uint256 r1) = vault.getTotalAmounts();\n uint256 px0 = base.getPrice(address(token0));\n uint256 px1 = base.getPrice(address(token1));\n uint256 t0Decimal = IERC20Metadata(token0).decimals();\n uint256 t1Decimal = IERC20Metadata(token1).decimals();\n\n uint256 totalReserve = (r0 * px0) /\n 10**t0Decimal +\n (r1 * px1) /\n 10**t1Decimal;\n\n return (totalReserve * 1e18) / totalSupply;\n}\n```\n | medium |
```\n/// @notice Returns the total balance (in asset tokens). This includes the deposits and interest.\n/// @return The underlying balance of asset tokens\nfunction balanceOfToken(address addr) public override returns (uint256) {\n if (balances[addr] == 0) return 0;\n ISushiBar bar = ISushiBar(sushiBar);\n\n uint256 shares = bar.balanceOf(address(this));\n uint256 totalShares = bar.totalSupply();\n\n uint256 sushiBalance =\n shares.mul(ISushi(sushiAddr).balanceOf(address(sushiBar))).div(\n totalShares\n );\n uint256 sourceShares = bar.balanceOf(address(this));\n\n return (balances[addr].mul(sushiBalance).div(sourceShares));\n}\n```\n | medium |
```\nfunction _handlePostOp(uint256 opIndex, IPaymaster.PostOpMode mode, UserOpInfo memory opInfo, bytes memory context, uint256 actualGas) private returns (uint256 actualGasCost) {\n uint256 preGas = gasleft();\nunchecked {\n address refundAddress;\n MemoryUserOp memory mUserOp = opInfo.mUserOp;\n uint256 gasPrice = getUserOpGasPrice(mUserOp);\n\n address paymaster = mUserOp.paymaster;\n if (paymaster == address(0)) {\n refundAddress = mUserOp.sender;\n } else {\n refundAddress = paymaster;\n if (context.length > 0) {\n actualGasCost = actualGas * gasPrice;\n if (mode != IPaymaster.PostOpMode.postOpReverted) {\n IPaymaster(paymaster).postOp{gas : mUserOp.verificationGasLimit}(mode, context, actualGasCost);\n } else {\n // solhint-disable-next-line no-empty-blocks\n try IPaymaster(paymaster).postOp{gas : mUserOp.verificationGasLimit}(mode, context, actualGasCost) {}\n catch Error(string memory reason) {\n revert FailedOp(opIndex, string.concat("AA50 postOp reverted: ", reason));\n }\n catch {\n revert FailedOp(opIndex, "AA50 postOp revert");\n }\n }\n }\n }\n actualGas += preGas - gasleft();\n actualGasCost = actualGas * gasPrice;\n if (opInfo.prefund < actualGasCost) {\n revert FailedOp(opIndex, "AA51 prefund below actualGasCost");\n }\n uint256 refund = opInfo.prefund - actualGasCost;\n _incrementDeposit(refundAddress, refund);\n bool success = mode == IPaymaster.PostOpMode.opSucceeded;\n emit UserOperationEvent(opInfo.userOpHash, mUserOp.sender, mUserOp.paymaster, mUserOp.nonce, success, actualGasCost, actualGas);\n} // unchecked\n}\n```\n | none |
```\nFile: LiquidationFacetImpl.sol\n function setSymbolsPrice(address partyA, PriceSig memory priceSig) internal {\n..SNIP..\n if (accountLayout.liquidationDetails[partyA].liquidationType == LiquidationType.NONE) {\n accountLayout.liquidationDetails[partyA] = LiquidationDetail({\n liquidationType: LiquidationType.NONE,\n upnl: priceSig.upnl,\n totalUnrealizedLoss: priceSig.totalUnrealizedLoss,\n deficit: 0,\n liquidationFee: 0\n });\n..SNIP..\n AccountStorage.layout().liquidators[partyA].push(msg.sender);\n } else {\n require(\n accountLayout.liquidationDetails[partyA].upnl == priceSig.upnl &&\n accountLayout.liquidationDetails[partyA].totalUnrealizedLoss ==\n priceSig.totalUnrealizedLoss,\n "LiquidationFacet: Invalid upnl sig"\n );\n }\n }\n```\n | medium |
```\nfunction isReinvest(address account) external view returns (bool) {\n return dividendTracker.isReinvest(account);\n}\n```\n | none |
```\n function sendPacket(LZSendParam calldata _lzSendParam, bytes calldata _composeMsg)\n public\n payable\n whenNotPaused // @audit Pausing is not implemented yet.\n returns (MessagingReceipt memory msgReceipt, OFTReceipt memory oftReceipt)\n {\n (msgReceipt, oftReceipt) = abi.decode(\n _executeModule(\n uint8(ITOFT.Module.TOFTSender),\n abi.encodeCall(TapiocaOmnichainSender.sendPacket, (_lzSendParam, _composeMsg)),\n false\n ),\n (MessagingReceipt, OFTReceipt)\n );\n }\n```\n | medium |
```\nfunction calculateDonationFee(uint256 _amount)\n private\n view\n returns (uint256)\n{\n return _amount.mul(_donationFee).div(10**2);\n}\n```\n | none |
```\nfunction getTokenAmountOut(uint256 amountBNBIn)\n external\n view\n returns (uint256)\n{\n uint256 amountAfter = liqConst / (liquidity - amountBNBIn);\n uint256 amountBefore = liqConst / liquidity;\n return amountAfter - amountBefore;\n}\n```\n | none |
```\n function _mintVaultShares(uint256 lpTokens) internal returns (uint256 vaultShares) {\n StrategyVaultState memory state = VaultStorage.getStrategyVaultState();\n if (state.totalPoolClaim == 0) {\n // Vault Shares are in 8 decimal precision\n vaultShares = (lpTokens * uint256(Constants.INTERNAL_TOKEN_PRECISION)) / POOL_PRECISION();\n } else {\n vaultShares = (lpTokens * state.totalVaultSharesGlobal) / state.totalPoolClaim;\n }\n\n // Updates internal storage here\n state.totalPoolClaim += lpTokens;\n state.totalVaultSharesGlobal += vaultShares.toUint80();\n state.setStrategyVaultState();\n```\n | medium |
```\n require(\n _commitment.principalTokenAddress ==\n commitments[_commitmentId].principalTokenAddress,\n "Principal token address cannot be updated."\n );\n require(\n _commitment.marketId == commitments[_commitmentId].marketId,\n "Market Id cannot be updated."\n );\n\n commitments[_commitmentId] = _commitment;\n```\n | medium |
```\nfunction _removeTokenFromAllTokensEnumeration(uint256 tokenId) private {\n // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and\n // then delete the last slot (swap and pop).\n\n uint256 lastTokenIndex = _allTokens.length - 1;\n uint256 tokenIndex = _allTokensIndex[tokenId];\n\n // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so\n // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding\n // an 'if' statement (like in _removeTokenFromOwnerEnumeration)\n uint256 lastTokenId = _allTokens[lastTokenIndex];\n\n _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token\n _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index\n\n // This also deletes the contents at the last position of the array\n delete _allTokensIndex[tokenId];\n _allTokens.pop();\n}\n```\n | none |
```\n function rebalanceNeeded() public view returns (bool) {\n return (block.timestamp - lastTimeStamp) > rebalanceInterval || msg.sender == guardian;\n }\n```\n | medium |
```\nfunction isExcludedFromFees(address account) public view returns(bool) {\n return _isExcludedFromFees[account];\n}\n```\n | none |
```\nfunction \_afterMint() internal override {\n IPCVSwapper(target).swap();\n}\n```\n | medium |
```\nfunction setDividendsPaused(bool value) external onlyOwner {\n dividendTracker.setDividendsPaused(value);\n}\n```\n | none |
```\n if (self.delta == GMXTypes.Delta.Neutral) {\n (uint256 _tokenAWeight, ) = tokenWeights(self);\n\n\n uint256 _maxTokenALending = convertToUsdValue(\n self,\n address(self.tokenA),\n self.tokenALendingVault.totalAvailableAsset()\n ) * SAFE_MULTIPLIER\n / (self.leverage * _tokenAWeight / SAFE_MULTIPLIER);\n\n\n uint256 _maxTokenBLending = convertToUsdValue(\n self,\n address(self.tokenB),\n self.tokenBLendingVault.totalAvailableAsset()\n ) * SAFE_MULTIPLIER\n / (self.leverage * _tokenAWeight / SAFE_MULTIPLIER)\n - 1e18;\n```\n | medium |
```\nfunction safeIncreaseAllowance(\n IERC20 token,\n address spender,\n uint256 value\n) internal {\n uint256 newAllowance = token.allowance(address(this), spender) + value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n}\n```\n | none |
```\nLien storage lien = lienData[lienId];\nlien.amount = _getOwed(lien); // @audit current debt, including accrued interest; saved to storage!\n```\n | high |
```\nfunction _setAutomatedMarketMakerPair(address pair, bool value) private {\n automatedMarketMakerPairs[pair] = value;\n\n if (value) {\n dividendTracker.excludeFromDividends(pair);\n }\n\n emit SetAutomatedMarketMakerPair(pair, value);\n}\n```\n | none |
```\nfunction _setOwner(address newOwner) private {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n}\n```\n | none |
```\nfunction setLiquidityFeePercent(uint256 liquidityFee) external onlyOwner() {\n require(liquidityFee <= _maxLiquidityFee, "Liquidity fee must be less than or equal to _maxLiquidityFee");\n _liquidityFee = liquidityFee;\n emit LiquidityFeeUpdated(liquidityFee);\n}\n```\n | none |
```\nfunction renounceOwnership() external onlyOwner {\n _transferOwnership(address(0));\n}\n```\n | none |
```\n // This is called by the base ERC20 contract before all transfer, mint, and burns\n function _beforeTokenTransfer(address from, address, uint256) internal override {\n // Don't run check if this is a mint transaction\n if (from != address(0)) {\n // Check which block the user's last deposit was\n bytes32 key = keccak256(abi.encodePacked("user.deposit.block", from));\n uint256 lastDepositBlock = getUint(key);\n if (lastDepositBlock > 0) {\n // Ensure enough blocks have passed\n uint256 depositDelay = getUint(keccak256(abi.encodePacked(keccak256("dao.protocol.setting.network"), "network.reth.deposit.delay")));\n uint256 blocksPassed = block.number.sub(lastDepositBlock);\n require(blocksPassed > depositDelay, "Not enough time has passed since deposit");\n // Clear the state as it's no longer necessary to check this until another deposit is made\n deleteUint(key);\n }\n }\n }\n```\n | medium |
```\nif (ownerCount >= maxSigs) {\n bool swapped = _swapSigner(owners, ownerCount, maxSigs, currentSignerCount, msg.sender);\n if (!swapped) {\n // if there are no invalid owners, we can't add a new signer, so we revert\n revert NoInvalidSignersToReplace();\n }\n}\n```\n | medium |
```\nfunction getTokenVotingPower(uint _tokenId) public override view returns (uint) {\n if (ownerOf(_tokenId) == address(0)) revert NonExistentToken();\n\n // If tokenId < 10000, it's a FrankenPunk, so 100/100 = a multiplier of 1\n uint multiplier = _tokenId < 10_000 ? PERCENT : monsterMultiplier;\n \n // evilBonus will return 0 for all FrankenMonsters, as they are not eligible for the evil bonus\n return ((baseVotes * multiplier) / PERCENT) + stakedTimeBonus[_tokenId] + evilBonus(_tokenId);\n }\n```\n | medium |
```\nfunction withdrawFromGauge(uint256 _NFTId, address[] memory _tokens) public {\n uint256 amount = depositReceipt.pooledTokens(_NFTId);\n depositReceipt.burn(_NFTId);\n gauge.getReward(address(this), _tokens);\n gauge.withdraw(amount);\n //AMMToken adheres to ERC20 spec meaning it reverts on failure, no need to check return\n //slither-disable-next-line unchecked-transfer\n AMMToken.transfer(msg.sender, amount);\n}\n```\n | high |
```\nrequire(\n msg.sender == address(_getPool(tokenIn, tokenOut, fee)),\n 'Router: invalid callback sender'\n);\n```\n | medium |
```\nfunction adminMint(address to, uint256 _tokenId)\n external\n whenNotPaused\n ownerOrMinter\n requireState(DrawState.Closed)\n{\n require(to != address(0), "DCBW721: Address cannot be 0");\n\n validateTokenId(_tokenId);\n\n _safeMint(to, _tokenId);\n\n emit AdminMinted(to, _tokenId);\n}\n```\n | none |
```\nfunction _createSenderIfNeeded(uint256 opIndex, UserOpInfo memory opInfo, bytes calldata initCode) internal {\n if (initCode.length != 0) {\n address sender = opInfo.mUserOp.sender;\n if (sender.code.length != 0) revert FailedOp(opIndex, "AA10 sender already constructed");\n address sender1 = senderCreator.createSender{gas : opInfo.mUserOp.verificationGasLimit}(initCode);\n if (sender1 == address(0)) revert FailedOp(opIndex, "AA13 initCode failed or OOG");\n if (sender1 != sender) revert FailedOp(opIndex, "AA14 initCode must return sender");\n if (sender1.code.length == 0) revert FailedOp(opIndex, "AA15 initCode must create sender");\n address factory = address(bytes20(initCode[0 : 20]));\n emit AccountDeployed(opInfo.userOpHash, sender, factory, opInfo.mUserOp.paymaster);\n }\n}\n```\n | none |
```\nfunction tryRecover(\n bytes32 hash,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal pure returns (address, RecoverError) {\n // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\n // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\n // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most\n // signatures from current libraries generate a unique signature with an s-value in the lower half order.\n //\n // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value\n // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or\n // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept\n // these malleable signatures as well.\n if (\n uint256(s) >\n 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0\n ) {\n return (address(0), RecoverError.InvalidSignatureS);\n }\n\n // If the signature is valid (and not malleable), return the signer address\n address signer = ecrecover(hash, v, r, s);\n if (signer == address(0)) {\n return (address(0), RecoverError.InvalidSignature);\n }\n\n return (signer, RecoverError.NoError);\n }\n\n\n```\n | none |
```\nFile: SecondaryRewarder.sol\n function _claimRewards(address account, uint256 nTokenBalanceBefore, uint256 nTokenBalanceAfter) private { \n uint256 rewardToClaim = _calculateRewardToClaim(account, nTokenBalanceBefore, accumulatedRewardPerNToken); \n\n // Precision here is:\n // nTokenBalanceAfter (INTERNAL_TOKEN_PRECISION) \n // accumulatedRewardPerNToken (INCENTIVE_ACCUMULATION_PRECISION) \n // DIVIDE BY\n // INTERNAL_TOKEN_PRECISION \n // => INCENTIVE_ACCUMULATION_PRECISION (1e18) \n rewardDebtPerAccount[account] = nTokenBalanceAfter \n .mul(accumulatedRewardPerNToken)\n .div(uint256(Constants.INTERNAL_TOKEN_PRECISION))\n .toUint128(); \n\n if (0 < rewardToClaim) { \n GenericToken.safeTransferOut(REWARD_TOKEN, account, rewardToClaim); \n emit RewardTransfer(REWARD_TOKEN, account, rewardToClaim);\n }\n }\n```\n | medium |
```\nfunction _canLiquidate(MTypes.MarginCallPrimary memory m)\n private\n view\n returns (bool)\n{\n// rest of code // [// rest of code]\n uint256 timeDiff = LibOrders.getOffsetTimeHours() - m.short.updatedAt;\n uint256 resetLiquidationTime = LibAsset.resetLiquidationTime(m.asset);\n❌ if (timeDiff >= resetLiquidationTime) {\n return false;\n } else {\n uint256 secondLiquidationTime = LibAsset.secondLiquidationTime(m.asset);\n bool isBetweenFirstAndSecondLiquidationTime = timeDiff\n > LibAsset.firstLiquidationTime(m.asset) && timeDiff <= secondLiquidationTime\n && s.flagMapping[m.short.flaggerId] == msg.sender;\n bool isBetweenSecondAndResetLiquidationTime =\n timeDiff > secondLiquidationTime && timeDiff <= resetLiquidationTime;\n if (\n !(\n (isBetweenFirstAndSecondLiquidationTime)\n || (isBetweenSecondAndResetLiquidationTime)\n )\n ) {\n revert Errors.MarginCallIneligibleWindow();\n }\n return true;\n }\n}\n```\n | medium |
```\n modifier onlyEOAEx() {\n if (!allowContractCalls && !whitelistedContracts[msg.sender]) {\n if (msg.sender != tx.origin) revert NOT_EOA(msg.sender);\n }\n _;\n }\n```\n | medium |
```\nrequire(block.timestamp >= \_d.withdrawalRequestTime + TBTCConstants.getIncreaseFeeTimer(), "Fee increase not yet permitted");\n```\n | low |
```\nfunction mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {\n uint256 result = mulDiv(x, y, denominator);\n if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {\n result += 1;\n }\n return result;\n}\n```\n | none |
```\nfunction getZethTotal(uint256 vault) internal view returns (uint256 zethTotal) {\n AppStorage storage s = appStorage();\n address[] storage bridges = s.vaultBridges[vault];\n uint256 bridgeCount = bridges.length;\n\n for (uint256 i; i < bridgeCount;) {\n zethTotal += IBridge(bridges[i]).getZethValue(); \n unchecked {\n ++i;\n }\n }\n}\n```\n | low |