function
stringlengths 12
63.3k
| severity
stringclasses 4
values |
---|---|
```\nfunction setBuyFee(\n uint16 tax,\n uint16 liquidity,\n uint16 marketing,\n uint16 dev,\n uint16 donation\n) external onlyOwner {\n buyFee.tax = tax;\n buyFee.marketing = marketing;\n buyFee.liquidity = liquidity;\n buyFee.dev = dev;\n buyFee.donation = donation;\n}\n```\n | none |
```\nif (\_globalFee > BASIS\_POINTS) {\n revert InvalidFee();\n}\nStakingContractStorageLib.setGlobalFee(\_globalFee);\nif (\_operatorFee > BASIS\_POINTS) {\n revert InvalidFee();\n}\nStakingContractStorageLib.setOperatorFee(\_operatorFee);\n```\n | low |
```\nrequestLoan("1,000 debt tokens", "5% interest", "10 loan tokens for each collateral", "1 year")\n```\n | medium |
```\nfunction toString(ShortString sstr) internal pure returns (string memory) {\n uint256 len = byteLength(sstr);\n // using `new string(len)` would work locally but is not memory safe.\n string memory str = new string(32);\n /// @solidity memory-safe-assembly\n assembly {\n mstore(str, len)\n mstore(add(str, 0x20), sstr)\n }\n return str;\n}\n```\n | none |
```\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 | low |
```\nreceive() external payable {}\n```\n | none |
```\nfunction mint(uint256 pid, uint256 amount)\n external\n nonReentrant\n returns (uint256)\n{\n address lpToken = ichiFarm.lpToken(pid);\n IERC20Upgradeable(lpToken).safeTransferFrom(\n msg.sender,\n address(this),\n amount\n );\n if (\n IERC20Upgradeable(lpToken).allowance(\n address(this),\n address(ichiFarm)\n ) != type(uint256).max\n ) {\n // We only need to do this once per pool, as LP token's allowance won't decrease if it's -1.\n IERC20Upgradeable(lpToken).safeApprove(\n address(ichiFarm),\n type(uint256).max\n );\n }\n ichiFarm.deposit(pid, amount, address(this));\n // @ok if accIchiPerShare is always changing, so how does this work?\n // it's basically just saving the accIchiPerShare at staking time, so when you unstake, it can calculate the difference\n // really fucking smart actually\n (uint256 ichiPerShare, , ) = ichiFarm.poolInfo(pid);\n uint256 id = encodeId(pid, ichiPerShare);\n _mint(msg.sender, id, amount, "");\n return id;\n}\n```\n | high |
```\nfunction toHexString(uint256 value) internal pure returns (string memory) {\n if (value == 0) {\n return "0x00";\n }\n uint256 temp = value;\n uint256 length = 0;\n while (temp != 0) {\n length++;\n temp >>= 8;\n }\n return toHexString(value, length);\n}\n```\n | none |
```\n\_settleRedemption(\_recipient, \_mAssetQuantity, props.bAssets, bAssetQuantities, props.indexes, props.integrators, false);\n```\n | high |
```\nfunction _simulationOnlyValidations(UserOperation calldata userOp) internal view {\n // solhint-disable-next-line no-empty-blocks\n try this._validateSenderAndPaymaster(userOp.initCode, userOp.sender, userOp.paymasterAndData) {}\n catch Error(string memory revertReason) {\n if (bytes(revertReason).length != 0) {\n revert FailedOp(0, revertReason);\n }\n }\n}\n```\n | none |
```\nfunction swap(\n address inputToken,\n address outputToken,\n uint256 inputAmount,\n uint256 minOutputAmount\n)\n external\n payable\n onlyListedToken(inputToken)\n onlyListedToken(outputToken)\n override\n returns (uint256 outputAmount)\n{\n // Check that the exchange is unlocked and thus open for business\n Config memory _config = DFPconfig;\n require(_config.unlocked, "DFP: Locked");\n\n // Pull in input token and check the exchange balance for that token\n uint256 initialInputBalance;\n if (inputToken == address(0)) {\n require(msg.value == inputAmount, "DFP: bad ETH amount");\n initialInputBalance = address(this).balance - inputAmount;\n } else {\n initialInputBalance = IERC20(inputToken).balanceOf(address(this));\n IERC20(inputToken).safeTransferFrom(msg.sender, address(this), inputAmount);\n }\n\n // Check dex balance of the output token\n uint256 initialOutputBalance;\n if (outputToken == address(0)) {\n initialOutputBalance = address(this).balance;\n } else {\n initialOutputBalance = IERC20(outputToken).balanceOf(address(this));\n }\n\n // Calculate the output amount through the x*y=k invariant\n // Can skip overflow/underflow checks on this calculation as they will always work against an attacker anyway.\n uint256 netInputAmount = inputAmount * _config.oneMinusTradingFee;\n outputAmount = netInputAmount * initialOutputBalance / ((initialInputBalance << 64) + netInputAmount);\n require(outputAmount > minOutputAmount, "DFP: No deal");\n\n // Send output tokens to whoever invoked the swap function\n if (outputToken == address(0)) {\n address payable sender = payable(msg.sender);\n sender.transfer(outputAmount);\n } else {\n IERC20(outputToken).safeTransfer(msg.sender, outputAmount);\n }\n\n // Emit swap event to enable better governance decision making\n emit Swapped(msg.sender, inputToken, outputToken, inputAmount, outputAmount);\n}\n```\n | none |
```\nfunction setPayoutScheduleFixed(\n uint256[] calldata _payoutSchedule,\n address _payoutTokenAddress\n ) external onlyOpenQ {\n require(\n bountyType == OpenQDefinitions.TIERED_FIXED,\n Errors.NOT_A_FIXED_TIERED_BOUNTY\n );\n payoutSchedule = _payoutSchedule;\n payoutTokenAddress = _payoutTokenAddress;\n\n // Resize metadata arrays and copy current members to new array\n // NOTE: If resizing to fewer tiers than previously, the final indexes will be removed\n string[] memory newTierWinners = new string[](payoutSchedule.length);\n bool[] memory newInvoiceComplete = new bool[](payoutSchedule.length);\n bool[] memory newSupportingDocumentsCompleted = new bool[](\n payoutSchedule.length\n );\n\n for (uint256 i = 0; i < tierWinners.length; i++) { <=====================================================\n newTierWinners[i] = tierWinners[i];\n }\n tierWinners = newTierWinners;\n\n for (uint256 i = 0; i < invoiceComplete.length; i++) { <=====================================================\n newInvoiceComplete[i] = invoiceComplete[i];\n }\n invoiceComplete = newInvoiceComplete;\n\n for (uint256 i = 0; i < supportingDocumentsComplete.length; i++) { <=====================================================\n newSupportingDocumentsCompleted[i] = supportingDocumentsComplete[i];\n }\n supportingDocumentsComplete = newSupportingDocumentsCompleted;\n }\n```\n | medium |
```\nreceive() external payable {}\n```\n | none |
```\nfunction transferTokens(\n address token,\n address from,\n address to,\n uint256 amount\n) internal {\n uint256 priorBalance = IERC20(token).balanceOf(address(to));\n require(IERC20(token).balanceOf(msg.sender) >= amount, 'THL01');\n```\n | low |
```\n IERC20(USDC).approve(jusdExchange, borrowBalance);\n IJUSDExchange(jusdExchange).buyJUSD(borrowBalance, address(this));\n IERC20(USDC).safeTransfer(to, USDCAmount - borrowBalance);\n JUSDAmount = borrowBalance;\n }\n```\n | medium |
```\nfunction getLiquidity() public view returns (uint256) {\n return liquidity;\n}\n```\n | none |
```\nfunction withdraw(uint256 _share) public {\n // Gets the amount of xABR in existence\n uint256 totalShares = totalSupply();\n // Calculates the amount of ABR the xABR is worth\n uint256 what = _share * ABR.balanceOf(address(this)) / totalShares;\n _burn(msg.sender, _share);\n ABR.transfer(msg.sender, what);\n}\n```\n | none |
```\nfunction release(address beneficiary) public {\n uint256 unreleased = getReleasableAmount(beneficiary);\n require(unreleased > 0, "Nothing to release");\n\n TokenAward storage award = getTokenAwardStorage(beneficiary);\n award.released += unreleased;\n\n targetToken.safeTransfer(beneficiary, unreleased);\n\n emit Released(beneficiary, unreleased);\n}\n\n/\*\*\n \* @notice Allows the owner to revoke the vesting. Tokens already vested\n \* are transfered to the beneficiary, the rest are returned to the owner.\n \* @param beneficiary Who the tokens are being released to\n \*/\nfunction revoke(address beneficiary) public onlyOwner {\n TokenAward storage award = getTokenAwardStorage(beneficiary);\n\n require(award.revocable, "Cannot be revoked");\n require(!award.revoked, "Already revoked");\n\n // Figure out how many tokens were owed up until revocation\n uint256 unreleased = getReleasableAmount(beneficiary);\n award.released += unreleased;\n\n uint256 refund = award.amount - award.released;\n\n // Mark award as revoked\n award.revoked = true;\n award.amount = award.released;\n\n // Transfer owed vested tokens to beneficiary\n targetToken.safeTransfer(beneficiary, unreleased);\n // Transfer unvested tokens to owner (revoked amount)\n targetToken.safeTransfer(owner(), refund);\n\n emit Released(beneficiary, unreleased);\n emit Revoked(beneficiary, refund);\n}\n```\n | low |
```\nrequire(\_measurementMultiple >= 1e6 && \_measurementMultiple <= 1e10, "MM out of range");\n```\n | low |
```\nfunction supplyNativeToken(address user) internal nonReentrant {\n WethInterface(weth).deposit{value: msg.value}();\n IERC20(weth).safeIncreaseAllowance(address(ironBank), msg.value);\n ironBank.supply(address(this), user, weth, msg.value);\n}\n```\n | high |
```\nuint256 tradeFee = ILeverageModule(vault.moduleAddress(FlatcoinModuleKeys._LEVERAGE_MODULE_KEY)).getTradeFee(\n vault.getPosition(tokenId).additionalSize\n);\n```\n | high |
```\nburnFrom(from, amountFGEN);\ncommittedFGEN[from] = 0;\n\npayable(to).transfer(total);\n```\n | medium |
```\nfunction _transferToExcluded(\n address sender,\n address recipient,\n uint256 tAmount\n) private {\n (\n uint256 tTransferAmount,\n uint256 tFee,\n uint256 tLiquidity,\n uint256 tWallet,\n uint256 tDonation\n ) = _getTValues(tAmount);\n (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(\n tAmount,\n tFee,\n tLiquidity,\n tWallet,\n tDonation,\n _getRate()\n );\n\n _rOwned[sender] = _rOwned[sender].sub(rAmount);\n _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount);\n _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);\n _takeLiquidity(tLiquidity);\n _takeWalletFee(tWallet);\n _takeDonationFee(tDonation);\n _reflectFee(rFee, tFee);\n emit Transfer(sender, recipient, tTransferAmount);\n}\n```\n | none |
```\nfunction _buy(uint256 minTokenOut, uint256 deadline)\n public\n payable\n nonReentrant\n returns (bool)\n{\n // deadline requirement\n require(deadline >= block.timestamp, "Deadline EXPIRED");\n\n // Frontrun Guard\n _lastBuyBlock[msg.sender] = block.number;\n\n // liquidity is set\n require(liquidity > 0, "The token has no liquidity");\n\n // check if trading is open or whether the buying wallet is the migration one\n require(\n block.timestamp >= TRADE_OPEN_TIME ||\n msg.sender == MIGRATION_WALLET,\n "Trading is not Open"\n );\n\n //remove the buy tax\n uint256 bnbAmount = isFeeExempt[msg.sender]\n ? msg.value\n : (msg.value * buyMul) / DIVISOR;\n\n // how much they should purchase?\n uint256 tokensToSend = _balances[address(this)] -\n (liqConst / (bnbAmount + liquidity));\n\n //revert for max bag\n require(\n _balances[msg.sender] + tokensToSend <= maxBag ||\n isTxLimitExempt[msg.sender],\n "Max wallet exceeded"\n );\n\n // revert if under 1\n require(tokensToSend > 1, "Must Buy more than 1 decimal of Surge");\n\n // revert for slippage\n require(tokensToSend >= minTokenOut, "INSUFFICIENT OUTPUT AMOUNT");\n\n // transfer the tokens from CA to the buyer\n buy(msg.sender, tokensToSend);\n\n //update available tax to extract and Liquidity\n uint256 taxAmount = msg.value - bnbAmount;\n taxBalance = taxBalance + taxAmount;\n liquidity = liquidity + bnbAmount;\n\n //update volume\n uint256 cTime = block.timestamp;\n uint256 dollarBuy = msg.value * getBNBPrice();\n totalVolume += dollarBuy;\n indVol[msg.sender] += dollarBuy;\n tVol[cTime] += dollarBuy;\n\n //update candleStickData\n totalTx += 1;\n txTimeStamp[totalTx] = cTime;\n uint256 cPrice = calculatePrice() * getBNBPrice();\n candleStickData[cTime].time = cTime;\n if (candleStickData[cTime].open == 0) {\n if (totalTx == 1) {\n candleStickData[cTime].open =\n ((liquidity - bnbAmount) / (_totalSupply)) *\n getBNBPrice();\n } else {\n candleStickData[cTime].open = candleStickData[\n txTimeStamp[totalTx - 1]\n ].close;\n }\n }\n candleStickData[cTime].close = cPrice;\n\n if (\n candleStickData[cTime].high < cPrice ||\n candleStickData[cTime].high == 0\n ) {\n candleStickData[cTime].high = cPrice;\n }\n\n if (\n candleStickData[cTime].low > cPrice ||\n candleStickData[cTime].low == 0\n ) {\n candleStickData[cTime].low = cPrice;\n }\n\n //emit transfer and buy events\n emit Transfer(address(this), msg.sender, tokensToSend);\n emit Bought(\n msg.sender,\n address(this),\n tokensToSend,\n msg.value,\n bnbAmount * getBNBPrice()\n );\n return true;\n}\n```\n | none |
```\n function SetZauction(address zauctionaddress) external onlyAdmin{\n zauction = zauctionaddress;\n emit ZauctionSet(zauctionaddress);\n }\n\n function SetAdmin(address newadmin) external onlyAdmin{\n admin = newadmin;\n emit AdminSet(msg.sender, newadmin);\n }\n```\n | high |
```\nfunction add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n require(c >= a, "SafeMath: addition overflow");\n return c;\n}\n```\n | none |
```\n/// @notice Constructor method allowing us to prevent calls to initCLFR by setting the appropriate version\nconstructor(uint256 \_version) {\n VERSION\_SLOT.setUint256(\_version);\n}\n```\n | low |
```\nfunction supplyTokenTo(uint256 \_amount, address to) override external {\n uint256 shares = \_tokenToShares(\_amount);\n\n \_mint(to, shares);\n\n // NOTE: we have to deposit after calculating shares to mint\n token.safeTransferFrom(msg.sender, address(this), \_amount);\n\n \_depositInVault();\n\n emit SuppliedTokenTo(msg.sender, shares, \_amount, to);\n}\n```\n | high |
```\nfunction setTaxFeePercent(uint256 taxFee) external onlyOwner() {\n require(taxFee <= _maxTaxFee, "Tax fee must be less than or equal to _maxTaxFee");\n _taxFee = taxFee;\n emit TaxFeeUpdated(taxFee);\n}\n```\n | none |
```\nfunction _validateMaxLTV(uint256 strategyId) internal view {\n uint256 debtValue = bank.getDebtValue(bank.POSITION_ID());\n (, address collToken, uint256 collAmount, , , , , ) = bank\n .getCurrentPositionInfo();\n uint256 collPrice = bank.oracle().getPrice(collToken);\n uint256 collValue = (collPrice * collAmount) /\n 10**IERC20Metadata(collToken).decimals();\n\n if (\n debtValue >\n (collValue * maxLTV[strategyId][collToken]) / DENOMINATOR\n ) revert EXCEED_MAX_LTV();\n}\n```\n | high |
```\nfunction swapAndLiquify(uint256 amount) private lockTheSwap {\n\n // get portion for marketing/liquidity\n uint256 marketingAmt = (amount * 67) / (10**2);\n uint256 liquidityAmt = amount - marketingAmt;\n \n // send eth to marketing\n uint256 marketingBalance = swapTokensGetBalance(marketingAmt);\n _marketingWallet.transfer(marketingBalance);\n\n // split the liquidity amount into halves\n uint256 half = liquidityAmt/2;\n uint256 otherHalf = liquidityAmt - half;\n\n uint256 newBalance = swapTokensGetBalance(half);\n\n // add liquidity to uniswap\n addLiquidity(otherHalf, newBalance);\n \n emit SwapAndLiquify(half, newBalance, otherHalf);\n}\n```\n | none |
```\nfunction callFunction(\n address sender,\n Account.Info calldata account,\n bytes calldata data\n) external override {\n require(msg.sender == \_dydxSoloMargin && sender == address(this), Errors.VL\_NOT\_AUTHORIZED);\n account;\n\n FlashLoan.Info memory info = abi.decode(data, (FlashLoan.Info));\n\n uint256 \_value;\n if (info.asset == \_ETH) {\n // Convert WETH to ETH and assign amount to be set as msg.value\n \_convertWethToEth(info.amount);\n \_value = info.amount;\n } else {\n // Transfer to Vault the flashloan Amount\n // \_value is 0\n IERC20(info.asset).univTransfer(payable(info.vault), info.amount);\n }\n```\n | low |
```\nfunction totalSupply() public view override returns (uint256) {\n return _tTotal;\n}\n```\n | none |
```\nconstructor(string memory name_, string memory symbol_) {\n _name = name_;\n _symbol = symbol_;\n}\n```\n | none |
```\nfunction safeDecreaseAllowance(\n IERC20 token,\n address spender,\n uint256 value\n) internal {\n unchecked {\n uint256 oldAllowance = token.allowance(address(this), spender);\n require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");\n uint256 newAllowance = oldAllowance - value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n}\n```\n | none |
```\n/\*\*\n \* @title Extremely simple implementation of `IStrategy` interface.\n \* @author Layr Labs, Inc.\n \* @notice Simple, basic, "do-nothing" Strategy that holds a single underlying token and returns it on withdrawals.\n \* Assumes shares are always 1-to-1 with the underlyingToken.\n \* @dev Unlike `StrategyBase`, this contract is \*not\* designed to be inherited from.\n \* @dev This contract is expressly \*not\* intended for use with 'fee-on-transfer'-type tokens.\n \* Setting the `underlyingToken` to be a fee-on-transfer token may result in improper accounting.\n \*/\ncontract StrategyWrapper is IStrategy {\n```\n | low |
```\n// TapiocaOmnichainReceiver.sol\nfunction lzCompose( \n address _from,\n bytes32 _guid,\n bytes calldata _message,\n address, //executor\n bytes calldata //extra Data\n ) external payable override {\n // rest of code\n \n // Decode LZ compose message.\n (address srcChainSender_, bytes memory oftComposeMsg_) =\n TapiocaOmnichainEngineCodec.decodeLzComposeMsg(_message);\n\n // Execute the composed message. \n _lzCompose(srcChainSender_, _guid, oftComposeMsg_); \n }\n```\n | high |
```\nfunction claim(\n uint256 policyIndex\_,\n uint256 amount\_,\n address receipient\_\n) external onlyPoolManager {\n```\n | high |
```\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 |
```\nIAccount(account).updateActionTimestampByCreditor();\n\nasset.safeTransfer(actionTarget, amountBorrowed);\n\n{\n uint256 accountVersion = IAccount(account).flashActionByCreditor(actionTarget, actionData);\n if (!isValidVersion[accountVersion]) revert LendingPoolErrors.InvalidVersion();\n}\n```\n | medium |
```\nassert(\_blockNumber > \_blockheaders.length);\n```\n | medium |
```\nfunction verify(\n bytes calldata inputTxBytes,\n uint16 outputIndex,\n uint256 inputTxPos,\n bytes calldata spendingTxBytes,\n uint16 inputIndex,\n bytes calldata signature,\n bytes calldata /\*optionalArgs\*/\n)\n external\n view\n returns (bool)\n{\n PaymentTransactionModel.Transaction memory inputTx = PaymentTransactionModel.decode(inputTxBytes);\n require(inputTx.txType == supportInputTxType, "Input tx is an unsupported payment tx type");\n\n PaymentTransactionModel.Transaction memory spendingTx = PaymentTransactionModel.decode(spendingTxBytes);\n require(spendingTx.txType == supportSpendingTxType, "The spending tx is an unsupported payment tx type");\n\n UtxoPosLib.UtxoPos memory utxoPos = UtxoPosLib.build(TxPosLib.TxPos(inputTxPos), outputIndex);\n require(\n spendingTx.inputs[inputIndex] == bytes32(utxoPos.value),\n "Spending tx points to the incorrect output UTXO position"\n );\n\n address payable owner = inputTx.outputs[outputIndex].owner();\n require(owner == ECDSA.recover(eip712.hashTx(spendingTx), signature), "Tx in not signed correctly");\n\n return true;\n}\n```\n | high |
```\nfunction isContract(address account) internal view returns (bool) {\n // According to EIP-1052, 0x0 is the value returned for not-yet created accounts\n // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned\n // for accounts without code, i.e. `keccak256('')`\n bytes32 codehash;\n bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;\n // solhint-disable-next-line no-inline-assembly\n assembly {\n codehash := extcodehash(account)\n }\n return (codehash != accountHash && codehash != 0x0);\n}\n```\n | none |
```\nfunction sub(uint256 a, uint256 b) internal pure returns (uint256) {\n return sub(a, b, "SafeMath: subtraction overflow");\n}\n```\n | none |
```\nFile: Stable2TokenOracleMath.sol\n function _validateSpotPriceAndPairPrice(\n StableOracleContext calldata oracleContext,\n TwoTokenPoolContext calldata poolContext,\n StrategyContext memory strategyContext,\n uint256 oraclePrice,\n uint256 primaryAmount, \n uint256 secondaryAmount\n ) internal view {\n // Oracle price is always specified in terms of primary, so tokenIndex == 0 for primary\n uint256 spotPrice = _getSpotPrice({\n oracleContext: oracleContext,\n poolContext: poolContext,\n primaryBalance: poolContext.primaryBalance,\n secondaryBalance: poolContext.secondaryBalance,\n tokenIndex: 0\n });\n\n /// @notice Check spotPrice against oracle price to make sure that \n /// the pool is not being manipulated\n _checkPriceLimit(strategyContext, oraclePrice, spotPrice);\n\n /// @notice Balancer math functions expect all amounts to be in BALANCER_PRECISION\n uint256 primaryPrecision = 10 ** poolContext.primaryDecimals;\n uint256 secondaryPrecision = 10 ** poolContext.secondaryDecimals;\n primaryAmount = primaryAmount * BalancerConstants.BALANCER_PRECISION / primaryPrecision;\n secondaryAmount = secondaryAmount * BalancerConstants.BALANCER_PRECISION / secondaryPrecision;\n\n uint256 calculatedPairPrice = _getSpotPrice({\n oracleContext: oracleContext,\n poolContext: poolContext,\n primaryBalance: primaryAmount,\n secondaryBalance: secondaryAmount,\n tokenIndex: 0\n });\n```\n | high |
```\n function _revertIfLotConcluded(uint96 lotId_) internal view virtual {\n // Beyond the conclusion time\n if (lotData[lotId_].conclusion < uint48(block.timestamp)) {\n revert Auction_MarketNotActive(lotId_);\n }\n\n // Capacity is sold-out, or cancelled\n if (lotData[lotId_].capacity == 0) revert Auction_MarketNotActive(lotId_);\n }\n```\n | medium |
```\nif (!instance.transfer(getSendAddress(), forwarderBalance)) {\n revert('Could not gather ERC20');\n}\n```\n | high |
```\n/// @dev pause the transceiver.\nfunction _pauseTransceiver() internal {\n _pause();\n}\n```\n | low |
```\nfunction setAutoClaim(bool value) external {\n dividendTracker.setAutoClaim(msg.sender, value);\n}\n```\n | none |
```\nfunction depositSwap(\n int256 swapAmount, // (-) token1, (+) token0 for token1; amount to swap\n uint256 deposit0,\n uint256 deposit1,\n address to,\n address from,\n bytes memory path,\n address pos,\n address \_router\n) external returns (uint256 shares) {\n```\n | high |
```\nFile: VaultConfiguration.sol\n if (vaultAccount.tempCashBalance < 0) {\n int256 x = vaultConfig.primeRate.convertToUnderlying(vaultAccount.tempCashBalance).neg();\n underlyingExternalToRepay = underlyingToken.convertToUnderlyingExternalWithAdjustment(x).toUint();\n } else {\n // Otherwise require that cash balance is zero. Cannot have a positive cash balance in this method\n require(vaultAccount.tempCashBalance == 0);\n }\n```\n | medium |
```\nFile: TreasuryAction.sol\n function _executeRebalance(uint16 currencyId) private {\n IPrimeCashHoldingsOracle oracle = PrimeCashExchangeRate.getPrimeCashHoldingsOracle(currencyId);\n uint8[] memory rebalancingTargets = _getRebalancingTargets(currencyId, oracle.holdings());\n (RebalancingData memory data) = REBALANCING_STRATEGY.calculateRebalance(oracle, rebalancingTargets);\n\n (/* */, uint256 totalUnderlyingValueBefore) = oracle.getTotalUnderlyingValueStateful();\n\n // Process redemptions first\n Token memory underlyingToken = TokenHandler.getUnderlyingToken(currencyId);\n TokenHandler.executeMoneyMarketRedemptions(underlyingToken, data.redeemData);\n\n // Process deposits\n _executeDeposits(underlyingToken, data.depositData);\n\n (/* */, uint256 totalUnderlyingValueAfter) = oracle.getTotalUnderlyingValueStateful();\n\n int256 underlyingDelta = totalUnderlyingValueBefore.toInt().sub(totalUnderlyingValueAfter.toInt());\n require(underlyingDelta.abs() < Constants.REBALANCING_UNDERLYING_DELTA);\n }\n```\n | medium |
```\n // due to sqrt computation error, sideTokens to sell may be very few more than available\n if (SignedMath.abs(tokensToSwap) > params.sideTokensAmount) {\n if (SignedMath.abs(tokensToSwap) - params.sideTokensAmount < params.sideTokensAmount / 10000) {\n tokensToSwap = SignedMath.revabs(params.sideTokensAmount, true);\n }\n }\n```\n | high |
```\n// @audit `price` is derived from `pool.slot0`\nshares = _amount1 + (_amount0 * price / PRECISION);\n```\n | low |
```\n/// constructor\n priceFeedDAIETH = AggregatorV3Interface(\n 0x773616E4d11A78F511299002da57A0a94577F1f4\n );\n\n/// getPrice()\n // chainlink price data is 8 decimals for WETH/USD, so multiply by 10 decimals to get 18 decimal fractional\n //(uint80 roundID, int256 price, uint256 startedAt, uint256 timeStamp, uint80 answeredInRound) = priceFeedDAIETH.latestRoundData();\n (, int256 price, , , ) = priceFeedDAIETH.latestRoundData();\n```\n | high |
```\nfunction sendERC20ToMain(ERC20 token, uint256 amount)\n external\n payable\n onlySplitMain()\n{\n token.safeTransfer(address(splitMain), amount);\n}\n```\n | none |
```\nfunction sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, "Address: insufficient balance");\n\n (bool success, ) = recipient.call{value: amount}("");\n require(success, "Address: unable to send value, recipient may have reverted");\n}\n```\n | none |
```\nfunction owner() public view returns (address) {\n return _owner;\n}\n```\n | none |
```\nfunction swapTokensForEth(uint256 tokenAmount) private lockTheSwap {\n address[] memory path = new address[](2);\n path[0] = address(this);\n path[1] = uniswapV2Router.WETH();\n _approve(address(this), address(uniswapV2Router), tokenAmount);\n uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(\n tokenAmount,\n 0,\n path,\n address(this),\n block.timestamp\n );\n}\n```\n | none |
```\nfunction symbol() public view returns (string memory) {\n return _symbol;\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 |
```\nif (operatorFee > 0) {\n (status, data) = operator.call{value: operatorFee}("");\n if (status == false) {\n revert FeeRecipientReceiveError(data);\n }\n}\n```\n | medium |
```\nfunction convertToShares(uint256 assets) public view virtual returns (uint256) {\n uint256 supply = totalSupply(); // Saves an extra SLOAD if totalSupply is non-zero.\n\n return supply == 0 ? assets : assets.mulDivDown(supply, totalAssets());\n}\n```\n | medium |
```\n _exitBalancerPool(lpAmount_, minTokenAmounts_);\n\n // Calculate OHM and wstETH amounts received\n uint256 ohmAmountOut = ohm.balanceOf(address(this)) - ohmBefore;\n uint256 wstethAmountOut = wsteth.balanceOf(address(this)) - wstethBefore;\n\n // Calculate oracle expected wstETH received amount\n // getTknOhmPrice returns the amount of wstETH per 1 OHM based on the oracle price\n uint256 wstethOhmPrice = manager.getTknOhmPrice();\n uint256 expectedWstethAmountOut = (ohmAmountOut * wstethOhmPrice) / _OHM_DECIMALS;\n\n // Take any arbs relative to the oracle price for the Treasury and return the rest to the owner\n uint256 wstethToReturn = wstethAmountOut > expectedWstethAmountOut\n ? expectedWstethAmountOut\n : wstethAmountOut;\n if (wstethAmountOut > wstethToReturn)\n wsteth.safeTransfer(TRSRY(), wstethAmountOut - wstethToReturn);\n\n // Burn OHM\n ohm.increaseAllowance(MINTR(), ohmAmountOut);\n manager.burnOhmFromVault(ohmAmountOut);\n\n // Return wstETH to owner\n wsteth.safeTransfer(msg.sender, wstethToReturn);\n```\n | high |
```\nreceive() external payable {}\n```\n | none |
```\nfunction setExcludeFees(address account, bool excluded) public onlyOwner {\n _isExcludedFromFees[account] = excluded;\n emit ExcludeFromFees(account, excluded);\n}\n```\n | none |
```\n// Check block\nrequire(\_block > getPricesBlock(), "Network prices for an equal or higher block are set");\n```\n | low |
```\nfile: QVBaseStrategy.sol\n function reviewRecipients(address[] calldata _recipientIds, Status[] calldata _recipientStatuses)\n external\n virtual\n onlyPoolManager(msg.sender)\n onlyActiveRegistration\n {\n // make sure the arrays are the same length\n uint256 recipientLength = _recipientIds.length;\n if (recipientLength != _recipientStatuses.length) revert INVALID();\n\n for (uint256 i; i < recipientLength;) {\n Status recipientStatus = _recipientStatuses[i];\n address recipientId = _recipientIds[i];\n\n // if the status is none or appealed then revert\n if (recipientStatus == Status.None || recipientStatus == Status.Appealed) { //@audit these are the input parameter statuse not the recipient's status.\n revert RECIPIENT_ERROR(recipientId);\n }\n\n reviewsByStatus[recipientId][recipientStatus]++;\n\n --> if (reviewsByStatus[recipientId][recipientStatus] >= reviewThreshold) { //@audit recipientStatus is updated right after the threshold is reached. It can overwrite if the status is already set.\n Recipient storage recipient = recipients[recipientId];\n recipient.recipientStatus = recipientStatus;\n\n emit RecipientStatusUpdated(recipientId, recipientStatus, address(0));\n }\n\n emit Reviewed(recipientId, recipientStatus, msg.sender);\n\n unchecked {\n ++i;\n }\n }\n }\n```\n | medium |
```\nfunction setNumberOfWinners(uint256 count) external onlyOwner {\n \_\_numberOfWinners = count;\n\n emit NumberOfWinnersSet(count);\n}\n```\n | high |
```\nFile: contracts\OperatorTokenomics\Operator.sol\n // transfer creates a new delegator: check if the delegation policy allows this "delegation"\n if (balanceOf(to) == 0) {\n if (address(delegationPolicy) != address(0)) {\n moduleCall(address(delegationPolicy), abi.encodeWithSelector(delegationPolicy.onDelegate.selector, to)); //@audit\nshould be called after _transfer()\n }\n }\n super._transfer(from, to, amount);\n```\n | medium |
```\n function _createHat(\n uint256 _id,\n string calldata _details,\n uint32 _maxSupply,\n address _eligibility,\n address _toggle,\n bool _mutable,\n string calldata _imageURI\n ) internal returns (Hat memory hat) {\n hat.details = _details;\n hat.maxSupply = _maxSupply;\n hat.eligibility = _eligibility;\n hat.toggle = _toggle;\n hat.imageURI = _imageURI;\n hat.config = _mutable ? uint96(3 << 94) : uint96(1 << 95);\n _hats[_id] = hat;\n\n\n emit HatCreated(_id, _details, _maxSupply, _eligibility, _toggle, _mutable, _imageURI);\n }\n```\n | medium |
```\nswapToken.transferFrom(\_from, swapTokenGraveyard, amount);\n```\n | high |
```\n/\*\*\n \* @dev Function used to inform about the fact the currently ongoing\n \* new relay entry generation operation timed out. As a result, the group\n \* which was supposed to produce a new relay entry is immediately\n \* terminated and a new group is selected to produce a new relay entry.\n \* All members of the group are punished by seizing minimum stake of\n \* their tokens. The submitter of the transaction is rewarded with a\n \* tattletale reward which is limited to min(1, 20 / group\_size) of the\n \* maximum tattletale reward.\n \*/\nfunction reportRelayEntryTimeout() public {\n require(hasEntryTimedOut(), "Entry did not time out");\n groups.reportRelayEntryTimeout(signingRequest.groupIndex, groupSize, minimumStake);\n\n // We could terminate the last active group. If that's the case,\n // do not try to execute signing again because there is no group\n // which can handle it.\n if (numberOfGroups() > 0) {\n signRelayEntry(\n signingRequest.relayRequestId,\n signingRequest.previousEntry,\n signingRequest.serviceContract,\n signingRequest.entryVerificationAndProfitFee,\n signingRequest.callbackFee\n );\n }\n}\n```\n | high |
```\nfunction \_withdrawReserves(address \_token, uint256 \_amount)\n external\n onlyOwner\n onlyMSD(\_token)\n{\n (uint256 \_equity, ) = calcEquity(\_token);\n\n require(\_equity >= \_amount, "Token do not have enough reserve");\n\n // Increase the token debt\n msdTokenData[\_token].debt = msdTokenData[\_token].debt.add(\_amount);\n\n // Directly mint the token to owner\n MSD(\_token).mint(owner, \_amount);\n```\n | medium |
```\n// `token.allowance()``\nmstore(0xB00, ALLOWANCE\_CALL\_SELECTOR\_32)\nmstore(0xB04, caller())\nmstore(0xB24, address())\nlet success := call(gas(), token, 0, 0xB00, 0x44, 0xC00, 0x20)\n```\n | low |
```\nconstructor(\n address \_core,\n address \_target,\n uint256 \_incentive,\n uint256 \_frequency,\n uint256 \_initialMintAmount\n)\n CoreRef(\_core)\n Timed(\_frequency)\n Incentivized(\_incentive)\n RateLimitedMinter((\_initialMintAmount + \_incentive) / \_frequency, (\_initialMintAmount + \_incentive), true)\n{\n \_initTimed();\n\n \_setTarget(\_target);\n \_setMintAmount(\_initialMintAmount);\n}\n```\n | low |
```\nfunction updateTransferFee(uint256 newTransferFee) public onlyOwner {\n require (newTransferFee <= 5, "transfer fee cannot exceed 5%");\n transferFee = newTransferFee;\n emit UpdateTransferFee(transferFee);\n}\n```\n | none |
```\n function lockCapital(address _lendingPoolAddress)\n external\n payable\n override\n onlyDefaultStateManager\n whenNotPaused\n returns (uint256 _lockedAmount, uint256 _snapshotId)\n {\n// rest of code.\n uint256 _length = activeProtectionIndexes.length();\n for (uint256 i; i < _length; ) {\n// rest of code\n uint256 _remainingPrincipal = poolInfo\n .referenceLendingPools\n .calculateRemainingPrincipal( //<----------- calculate Remaining Principal\n _lendingPoolAddress,\n protectionInfo.buyer,\n protectionInfo.purchaseParams.nftLpTokenId\n );\n```\n | high |
```\n function _setInitialMargin(address asset, uint16 value) private {\n require(value > 100, "below 1.0"); // @audit a value of 100 is 1x, so this should be > 101\n s.asset[asset].initialMargin = value;\n require(LibAsset.initialMargin(asset) < Constants.CRATIO_MAX, "above max CR");\n }\n\n function _setPrimaryLiquidationCR(address asset, uint16 value) private {\n require(value > 100, "below 1.0"); // @audit a value of 100 is 1x, so this should be > 101\n require(value <= 500, "above 5.0");\n require(value < s.asset[asset].initialMargin, "above initial margin");\n s.asset[asset].primaryLiquidationCR = value;\n }\n\n function _setSecondaryLiquidationCR(address asset, uint16 value) private {\n require(value > 100, "below 1.0"); // @audit a value of 100 is 1x, so this should be > 101\n require(value <= 500, "above 5.0");\n require(value < s.asset[asset].primaryLiquidationCR, "above primary liquidation");\n s.asset[asset].secondaryLiquidationCR = value;\n }\n```\n | low |
```\n function emergencyClose(GMXTypes.Store storage self, uint256 deadline) external {\n // Revert if the status is Paused.\n GMXChecks.beforeEmergencyCloseChecks(self);\n\n // Repay all borrowed assets; 1e18 == 100% shareRatio to repay\n GMXTypes.RepayParams memory _rp;\n (_rp.repayTokenAAmt, _rp.repayTokenBAmt) = GMXManager.calcRepay(self, 1e18);\n\n (bool _swapNeeded, address _tokenFrom, address _tokenTo, uint256 _tokenToAmt) =\n GMXManager.calcSwapForRepay(self, _rp);\n\n if (_swapNeeded) {\n ISwap.SwapParams memory _sp;\n\n _sp.tokenIn = _tokenFrom;\n _sp.tokenOut = _tokenTo;\n _sp.amountIn = IERC20(_tokenFrom).balanceOf(address(this));\n _sp.amountOut = _tokenToAmt;\n _sp.slippage = self.minSlippage;\n _sp.deadline = deadline;\n\n GMXManager.swapTokensForExactTokens(self, _sp);\n }\n GMXManager.repay(self, _rp.repayTokenAAmt, _rp.repayTokenBAmt);\n\n self.status = GMXTypes.Status.Closed;\n\n emit EmergencyClose(_rp.repayTokenAAmt, _rp.repayTokenBAmt);\n }\n }\n```\n | medium |
```\n function _allowedBorrow(address from, uint256 share) internal virtual override {\n if (from != msg.sender) {\n // TODO review risk of using this\n (uint256 pearlmitAllowed,) = penrose.pearlmit().allowance(from, msg.sender, address(yieldBox), collateralId);\n require(allowanceBorrow[from][msg.sender] >= share || pearlmitAllowed >= share, "Market: not approved");\n if (allowanceBorrow[from][msg.sender] != type(uint256).max) {\n allowanceBorrow[from][msg.sender] -= share;\n }\n }\n }\n```\n | medium |
```\nFile: VaultAccountAction.sol\n function settleVaultAccount(address account, address vault) external override nonReentrant {\n requireValidAccount(account);\n require(account != vault);\n\n VaultConfig memory vaultConfig = VaultConfiguration.getVaultConfigStateful(vault);\n VaultAccount memory vaultAccount = VaultAccountLib.getVaultAccount(account, vaultConfig);\n \n // Require that the account settled, otherwise we may leave the account in an unintended\n // state in this method because we allow it to skip the min borrow check in the next line.\n (bool didSettle, bool didTransfer) = vaultAccount.settleVaultAccount(vaultConfig);\n require(didSettle, "No Settle");\n\n vaultAccount.accruePrimeCashFeesToDebt(vaultConfig);\n\n // Skip Min Borrow Check so that accounts can always be settled\n vaultAccount.setVaultAccount({vaultConfig: vaultConfig, checkMinBorrow: false});\n\n if (didTransfer) {\n // If the vault did a transfer (i.e. withdrew cash) we have to check their collateral ratio. There\n // is an edge condition where a vault with secondary borrows has an emergency exit. During that process\n // an account will be left some cash balance in both currencies. It may have excess cash in one and\n // insufficient cash in the other. A withdraw of the excess in one side will cause the vault account to\n // be insolvent if we do not run this check. If this scenario indeed does occur, the vault itself must\n // be upgraded in order to facilitate orderly exits for all of the accounts since they will be prevented\n // from settling.\n IVaultAccountHealth(address(this)).checkVaultAccountCollateralRatio(vault, account);\n }\n }\n```\n | high |
```\nreceive() external payable {\n revert("DCBW721: Please use Mint or Admin calls");\n}\n```\n | none |
```\nmapping(uint256 => mapping(address => uint256)) private \_balances;\n```\n | medium |
```\nfunction processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) {\n bytes32 computedHash = leaf;\n for (uint256 i = 0; i < proof.length; i++) {\n bytes32 proofElement = proof[i];\n if (computedHash <= proofElement) {\n // Hash(current computed hash + current element of the proof)\n computedHash = _efficientHash(computedHash, proofElement);\n } else {\n // Hash(current element of the proof + current computed hash)\n computedHash = _efficientHash(proofElement, computedHash);\n }\n }\n return computedHash;\n}\n```\n | none |
```\n params.minPrimary = poolContext._getTimeWeightedPrimaryBalance(\n oracleContext, strategyContext, bptToSettle\n );\n\n params.minPrimary = params.minPrimary * strategyContext.vaultSettings.balancerPoolSlippageLimitPercent / \n uint256(BalancerConstants.VAULT_PERCENT_BASIS);\n```\n | high |
```\n// signals to Beanstalk functions that they should not refund Eth\n// at the end of the function because the function is wrapped in a Farm function\nmodifier withEth() {\n if (msg.value > 0) s.isFarm = 2;\n _;\n if (msg.value > 0) {\n s.isFarm = 1;\n LibEth.refundEth();\n }\n}\n```\n | high |
```\n function addWithdrawRequest(uint256 _amountMLP, address _token) external {\n require(isAcceptingToken(_token), "ERROR: Invalid token");\n require(_amountMLP != 0, "ERROR: Invalid amount");\n \n address _withdrawer = msg.sender;\n // Get the pending buffer and staged buffer.\n RequestBuffer storage _pendingBuffer = _requests(false);\n RequestBuffer storage _stagedBuffer = _requests(true);\n // Check if the withdrawer have enough balance to withdraw.\n uint256 _bookedAmountMLP = _stagedBuffer.withdrawAmountPerUser[_withdrawer] + \n _pendingBuffer.withdrawAmountPerUser[_withdrawer];\n require(_bookedAmountMLP + _amountMLP <= \n MozaicLP(mozLP).balanceOf(_withdrawer), "Withdraw amount > amount MLP");\n …\n emit WithdrawRequestAdded(_withdrawer, _token, chainId, _amountMLP);\n }\n```\n | high |
```\nthe oracle process:\n\n1. the oracle node checks the latest price from reference exchanges and stores it with the oracle node's timestamp, e.g. time: 1000\n2. the oracle node checks the latest block of the blockchain, e.g. block 100, it stores this with the oracle node's timestamp as well\n3. the oracle node signs minOracleBlockNumber: 100, maxOracleBlockNumber: 100, timestamp: 1000, price: <price>\n4. the next time the loop runs is at time 1001, if the latest block of the blockchain is block 105, e.g. if 5 blocks were produced in that one second, then the oracle would sign\nminOracleBlockNumber: 101, maxOracleBlockNumber: 105, timestamp: 1001, price: <price>\n```\n | high |
```\nfunction _createLock(\n uint128 lockId,\n address tokenAddress,\n uint256 amount,\n bytes32 recipient,\n bytes4 destination\n) private returns (uint256, uint256, TokenInfo memory) {\n require(amount > 0, "Bridge: amount is 0");\n TokenInfo memory tokenInfo = tokenInfos[tokenAddress];\n require(\n tokenInfo.tokenSourceAddress != bytes32(0),\n "Bridge: unsupported token"\n );\n\n uint256 fee = FeeOracle(feeOracle).fee(tokenAddress, msg.sender, amount, destination);\n\n require(amount > fee, "Bridge: amount too small");\n\n // Amount to lock is amount without fee\n uint256 amountToLock = amount - fee;\n\n // Create and add lock structure to the locks list\n IValidator(validator).createLock(\n lockId,\n msg.sender,\n recipient,\n toSystemPrecision(amountToLock, tokenInfo.precision),\n destination,\n tokenInfo.tokenSource,\n tokenInfo.tokenSourceAddress\n );\n\n emit Sent(\n tokenInfo.tokenSource,\n tokenInfo.tokenSourceAddress,\n msg.sender,\n recipient,\n amountToLock,\n lockId,\n destination\n );\n return (amountToLock, fee, tokenInfo);\n}\n```\n | none |
```\n// x ^ n\n// NOTE: n is a normal integer, do not shift 18 decimals\n// solium-disable-next-line security/no-assign-params\nfunction wpowi(int256 x, int256 n) internal pure returns (int256 z) {\n z = n % 2 != 0 ? x : \_WAD;\n\n for (n /= 2; n != 0; n /= 2) {\n x = wmul(x, x);\n\n if (n % 2 != 0) {\n z = wmul(z, x);\n }\n }\n}\n```\n | medium |
```\nfor (uint256 i = 0; i < \_teamsNumber; i++) {\n```\n | medium |
```\nfunction checkCollateralRatio(\n VaultConfig memory vaultConfig,\n VaultState memory vaultState,\n VaultAccount memory vaultAccount\n) internal view {\n (int256 collateralRatio, /\* \*/) = calculateCollateralRatio(\n vaultConfig, vaultState, vaultAccount.account, vaultAccount.vaultShares, vaultAccount.fCash\n```\n | low |
```\nfunction registerEmitterAndDomain(bytes memory encodedVaa) public {\n /* snip: parsing of Governance VAA payload */\n\n // Set the registeredEmitters state variable.\n registeredEmitters[foreignChain] = foreignAddress;\n\n // update the chainId to domain (and domain to chainId) mappings\n getChainToDomain()[foreignChain] = cctpDomain;\n getDomainToChain()[cctpDomain] = foreignChain;\n}\n```\n | low |
```\nif (validSignerCount <= target && validSignerCount != currentThreshold) {\n newThreshold = validSignerCount;\n} else if (validSignerCount > target && currentThreshold < target) {\n newThreshold = target;\n}\n```\n | high |
```\n function test_audit_frontrunFlagShort() public {\n address alice = makeAddr("Alice"); //Alice will front-run Bob's attempt to flag her short\n address aliceSecondAddr = makeAddr("AliceSecondAddr");\n address bob = makeAddr("Bob"); //Bob will try to flag Alice's short \n address randomUser = makeAddr("randomUser"); //regular user who created a bid order\n \n //A random user create a bid, Alice create a short, which will match with the user's bid\n fundLimitBidOpt(DEFAULT_PRICE, DEFAULT_AMOUNT, randomUser);\n fundLimitShortOpt(DEFAULT_PRICE, DEFAULT_AMOUNT, alice);\n //Alice then mint the NFT associated to the SR so that it can be transfered\n vm.prank(alice);\n diamond.mintNFT(asset, Constants.SHORT_STARTING_ID);\n\n //ETH price drops from 4000 to 2666, making Alice's short flaggable because its < LibAsset.primaryLiquidationCR(asset)\n setETH(2666 ether);\n \n // Alice saw Bob attempt to flag her short, so she front-run him and transfer the SR\n vm.prank(alice);\n diamond.transferFrom(alice, aliceSecondAddr, 1);\n \n //Bob's attempt revert because the transfer of the short by Alice change the short status to SR.Cancelled\n vm.prank(bob);\n vm.expectRevert(Errors.InvalidShortId.selector);\n diamond.flagShort(asset, alice, Constants.SHORT_STARTING_ID, Constants.HEAD);\n } \n```\n | high |
```\nfunction numberDrawn(bytes32 _requestId, uint256 _randomness)\n external\n whenNotPaused\n requireAccount(_rngContract)\n nonReentrant\n{\n DrawData storage current = draws[_drawsToDate];\n require(\n current.randomNumberRequestId == _requestId,\n "DCBW721: Request ID mismatch"\n );\n\n current.winningEdition = uint64(uint256(_randomness % _maxTokenId).add(1));\n\n if (_exists(current.winningEdition)) {\n current.winner = ownerOf(current.winningEdition);\n current.prizePoolWon = current.isGrandPrize == uint96(1)\n ? uint96(_grandPrizePool)\n : uint96(_reserves);\n _payout(current);\n }\n\n emit DrawFinished(current.winner, current.winningEdition);\n\n /// @notice update state\n _drawsToDate++;\n _state = DrawState.Closed;\n\n /// @notice update draw record\n current.state = _state;\n}\n```\n | none |
```\n function handleOutgoingRESDL(\n address _sender,\n uint256 _lockId,\n address _sdlReceiver\n )\n external\n onlyCCIPController\n onlyLockOwner(_lockId, _sender)\n updateRewards(_sender)\n updateRewards(ccipController)\n returns (Lock memory)\n {\n Lock memory lock = locks[_lockId];\n\n delete locks[_lockId].amount;\n delete lockOwners[_lockId];\n balances[_sender] -= 1;\n\n uint256 totalAmount = lock.amount + lock.boostAmount;\n effectiveBalances[_sender] -= totalAmount;\n effectiveBalances[ccipController] += totalAmount;\n\n sdlToken.safeTransfer(_sdlReceiver, lock.amount);\n\n emit OutgoingRESDL(_sender, _lockId);\n\n return lock;\n }\n```\n | high |
```\nfunction sub(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 setBots(address[] memory bots_) public onlyOwner {\n for (uint i = 0; i < bots_.length; i++) {\n bots[bots_[i]] = true;\n }\n}\n```\n | none |
Subsets and Splits