Farseen0/scar-pairs huggingface dataset:
MEDIUM severity: Vulnerable function: ```\n        uint256 balanceBefore = asset.getSelfBalance();\n\n        address[. ```\n        uint256 balanceBefore = asset.getSelfBalance();\n\n        address[] memory assets = asset.toArray();\n        bytes32[] memory roots = new bytes32[](queuedWithdrawalCount);\n\n        IDelegationManager.Withdrawal memory queuedWithdrawal;\n        for (uint256 i; i < queuedWithdrawalCo

Vulnerable code:
```\n        uint256 balanceBefore = asset.getSelfBalance();\n\n        address[] memory assets = asset.toArray();\n        bytes32[] memory roots = new bytes32[](queuedWithdrawalCount);\n\n        IDelegationManager.Withdrawal memory queuedWithdrawal;\n        for (uint256 i; i < queuedWithdrawalCount; ++i) {\n            queuedWithdrawal = queuedWithdrawals[i];\n\n            roots[i] = _computeWithdrawalRoot(queuedWithdrawal);\n            delegationManager.completeQueuedWithdrawal(queuedWithdrawal, assets, middlewareTimesIndexes[i], true);\n\n            // Decrease the amount of ETH queued for withdrawal. We do not need to validate the staker as\n            // the aggregate root will be validated below.\n            if (asset == ETH_ADDRESS) {\n                IRioLRTOperatorDelegator(queuedWithdrawal.staker).decreaseETHQueuedForUserSettlement(\n                    queuedWithdrawal.shares[0]\n                );\n            }\n        }\n        if (epochWithdrawals.aggregateRoot != keccak256(abi.encode(roots))) {\n            revert INVALID_AGGREGATE_WITHDRAWAL_ROOT();\n        }\n        epochWithdrawals.shareValueOfAssetsReceived = SafeCast.toUint120(epochWithdrawals.sharesOwed);\n\n        uint256 assetsReceived = asset.getSelfBalance() - balanceBefore;\n        epochWithdrawals.assetsReceived += SafeCast.toUint120(assetsReceived);\n```\n
MEDIUM severity: Vulnerable function: ```\nvars.fromReserveAToken.burn(\n msg.sender,\n receiverAddress,\n amountToSwa. ```\nvars.fromReserveAToken.burn(\n msg.sender,\n receiverAddress,\n amountToSwap,\n fromReserve.liquidityIndex\n);\n// Notifies the receiver to proceed, sending as param the underlying already transferred\nISwapAdapter(receiverAddress).executeOperation(\n fromAsset,\n toAsset,\n amountToSwap,\n add

Vulnerable code:
```\nvars.fromReserveAToken.burn(\n msg.sender,\n receiverAddress,\n amountToSwap,\n fromReserve.liquidityIndex\n);\n// Notifies the receiver to proceed, sending as param the underlying already transferred\nISwapAdapter(receiverAddress).executeOperation(\n fromAsset,\n toAsset,\n amountToSwap,\n address(this),\n params\n);\n\nvars.amountToReceive = IERC20(toAsset).balanceOf(receiverAddress);\nif (vars.amountToReceive != 0) {\n IERC20(toAsset).transferFrom(\n receiverAddress,\n address(vars.toReserveAToken),\n vars.amountToReceive\n );\n\n if (vars.toReserveAToken.balanceOf(msg.sender) == 0) {\n \_usersConfig[msg.sender].setUsingAsCollateral(toReserve.id, true);\n }\n\n vars.toReserveAToken.mint(msg.sender, vars.amountToReceive, toReserve.liquidityIndex);\n```\n
MEDIUM severity: Vulnerable function: ```\n  function fulfillDomainBid(\n  uint256 parentId,\n  uint256 bidAmount,\n  uint256 royaltyAmoun. ```\n  function fulfillDomainBid(\n  uint256 parentId,\n  uint256 bidAmount,\n  uint256 royaltyAmount,\n  string memory bidIPFSHash,\n  string memory name,\n  string memory metadata,\n  bytes memory signature,\n  bool lockOnCreation,\n  address recipient\n) external {\n  bytes32 recoveredBidHash = c

Vulnerable code:
```\n  function fulfillDomainBid(\n  uint256 parentId,\n  uint256 bidAmount,\n  uint256 royaltyAmount,\n  string memory bidIPFSHash,\n  string memory name,\n  string memory metadata,\n  bytes memory signature,\n  bool lockOnCreation,\n  address recipient\n) external {\n  bytes32 recoveredBidHash = createBid(parentId, bidAmount, bidIPFSHash, name);\n  address recoveredBidder = recover(recoveredBidHash, signature);\n  require(recipient == recoveredBidder, "ZNS: bid info doesnt match/exist");\n  bytes32 hashOfSig = keccak256(abi.encode(signature));\n  require(approvedBids[hashOfSig] == true, "ZNS: has been fullfilled");\n  infinity.safeTransferFrom(recoveredBidder, controller, bidAmount);\n  uint256 id = registrar.registerDomain(parentId, name, controller, recoveredBidder);\n  registrar.setDomainMetadataUri(id, metadata);\n  registrar.setDomainRoyaltyAmount(id, royaltyAmount);\n  registrar.transferFrom(controller, recoveredBidder, id);\n  if (lockOnCreation) {\n    registrar.lockDomainMetadataForOwner(id);\n  }\n```\n
MEDIUM severity: Vulnerable function: ```\n  function _getProposalState(uint256 proposalId) internal view returns (ProposalState) {\n    P. ```\n  function _getProposalState(uint256 proposalId) internal view returns (ProposalState) {\n    Proposal storage proposal = proposals[proposalId];\n    if (proposal.cancelled) return ProposalState.Canceled;\n    else if (block.number <= proposal.startBlock) return ProposalState.Pending;\n    else

Vulnerable code:
```\n  function _getProposalState(uint256 proposalId) internal view returns (ProposalState) {\n    Proposal storage proposal = proposals[proposalId];\n    if (proposal.cancelled) return ProposalState.Canceled;\n    else if (block.number <= proposal.startBlock) return ProposalState.Pending;\n    else if (block.number <= proposal.endBlock) return ProposalState.Active;\n    else if (proposal.eta == 0) return ProposalState.Succeeded;\n    else if (proposal.executed) return ProposalState.Executed;\n    else if (proposal.forVotes <= proposal.againstVotes || proposal.forVotes < Goldiswap(goldiswap).totalSupply() / 20) { //@audit shouldn't use totalSupply\n      return ProposalState.Defeated;\n    }\n    else if (block.timestamp >= proposal.eta + Timelock(timelock).GRACE_PERIOD()) {\n      return ProposalState.Expired;\n    }\n    else {\n      return ProposalState.Queued;\n    }\n  }\n```\n
MEDIUM severity: Vulnerable function: ```\nint256 settledVaultValue = settlementRate.convertToUnderlying(residualAsset. ```\nint256 settledVaultValue = settlementRate.convertToUnderlying(residualAssetCashBalance)\n    .add(totalStrategyTokenValueAtSettlement);\n\n// If the vault is insolvent (meaning residualAssetCashBalance < 0), it is necessarily\n// true that totalStrategyTokens == 0 (meaning all tokens were sold 

Vulnerable code:
```\nint256 settledVaultValue = settlementRate.convertToUnderlying(residualAssetCashBalance)\n    .add(totalStrategyTokenValueAtSettlement);\n\n// If the vault is insolvent (meaning residualAssetCashBalance < 0), it is necessarily\n// true that totalStrategyTokens == 0 (meaning all tokens were sold in an attempt to\n// repay the debt). That means settledVaultValue == residualAssetCashBalance, strategyTokenClaim == 0\n// and assetCashClaim == totalAccountValue. Accounts that are still solvent will be paid from the\n// reserve, accounts that are insolvent will have a totalAccountValue == 0.\nstrategyTokenClaim = totalAccountValue.mul(vaultState.totalStrategyTokens.toInt())\n    .div(settledVaultValue).toUint();\n\nassetCashClaim = totalAccountValue.mul(residualAssetCashBalance)\n    .div(settledVaultValue);\n```\n
MEDIUM severity: Vulnerable function: ```\nFile: Tranche.sol\n    function issue(\n        address to,\n        uint256 underlyingAmount\n. ```\nFile: Tranche.sol\n    function issue(\n        address to,\n        uint256 underlyingAmount\n    ) external nonReentrant whenNotPaused notExpired returns (uint256 issued) {\n..SNIP..\n        lscales[to] = _maxscale;\n        delete unclaimedYields[to];\n\n        uint256 yBal = _yt.balanceOf

Vulnerable code:
```\nFile: Tranche.sol\n    function issue(\n        address to,\n        uint256 underlyingAmount\n    ) external nonReentrant whenNotPaused notExpired returns (uint256 issued) {\n..SNIP..\n        lscales[to] = _maxscale;\n        delete unclaimedYields[to];\n\n        uint256 yBal = _yt.balanceOf(to);\n        // If recipient has unclaimed interest, claim it and then reinvest it to issue more PT and YT.\n        // Reminder: lscale is the last scale when the YT balance of the user was updated.\n        if (_lscale != 0) {\n            accruedInTarget += _computeAccruedInterestInTarget(_maxscale, _lscale, yBal);\n        }\n..SNIP..\n        uint256 sharesUsed = sharesMinted + accruedInTarget;\n        uint256 fee = sharesUsed.mulDivUp(issuanceFeeBps, MAX_BPS);\n        issued = (sharesUsed - fee).mulWadDown(_maxscale);\n\n        // Accumulate issueance fee in units of target token\n        issuanceFees += fee;\n        // Mint PT and YT to user\n        _mint(to, issued);\n        _yt.mint(to, issued);\n```\n
MEDIUM severity: Vulnerable function: ```\nfunction mintOpenInterestDebt(address twTap) external onlyOwner { \n        uint256 usdoSupply . ```\nfunction mintOpenInterestDebt(address twTap) external onlyOwner { \n        uint256 usdoSupply = usdoToken.totalSupply();\n\n        // nothing to mint when there's no activity\n        if (usdoSupply > 0) {  \n            // re-compute latest debt\n            uint256 totalUsdoDebt = computeTo

Vulnerable code:
```\nfunction mintOpenInterestDebt(address twTap) external onlyOwner { \n        uint256 usdoSupply = usdoToken.totalSupply();\n\n        // nothing to mint when there's no activity\n        if (usdoSupply > 0) {  \n            // re-compute latest debt\n            uint256 totalUsdoDebt = computeTotalDebt();  \n   \n            //add Origins debt \n            //Origins market doesn't accrue in time but increases totalSupply\n            //and needs to be taken into account here\n            uint256 len = allOriginsMarkets.length;\n            for (uint256 i; i < len; i++) {\n                IMarket market = IMarket(allOriginsMarkets[i]);\n                if (isOriginRegistered[address(market)]) {\n                    (uint256 elastic,) = market.totalBorrow();\n                    totalUsdoDebt += elastic;\n                }\n            }\n \n            //debt should always be > USDO supply\n            if (totalUsdoDebt > usdoSupply) { \n                uint256 _amount = totalUsdoDebt - usdoSupply;\n\n                //mint against the open interest; supply should be fully minted now\n                IUsdo(address(usdoToken)).mint(address(this), _amount);\n\n                //send it to twTap\n                uint256 rewardTokenId = ITwTap(twTap).rewardTokenIndex(address(usdoToken));\n                _distributeOnTwTap(_amount, rewardTokenId, address(usdoToken), ITwTap(twTap));\n            }\n        } \n    }\n```\n
HIGH severity: Vulnerable function: ```\n            return SoladyMath.sqrt((4e24 * volumeGamma0Gamma1 * scale) / (b. ```\n            return SoladyMath.sqrt((4e24 * volumeGamma0Gamma1 * scale) / (b.timestamp - a.timestamp) / tickTvl);\n```\n

Vulnerable code:
```\n            return SoladyMath.sqrt((4e24 * volumeGamma0Gamma1 * scale) / (b.timestamp - a.timestamp) / tickTvl);\n```\n
MEDIUM severity: Vulnerable function: ```\nfunction setMessageService(address \_messageService) public onlyOwner {\n messageService = IMes. ```\nfunction setMessageService(address \_messageService) public onlyOwner {\n messageService = IMessageService(\_messageService);\n}\n```\n

Vulnerable code:
```\nfunction setMessageService(address \_messageService) public onlyOwner {\n messageService = IMessageService(\_messageService);\n}\n```\n
HIGH severity: Vulnerable function: ```\n(bool success, bytes memory returnData) = \_to.call{ value: \_value }(\_cal. ```\n(bool success, bytes memory returnData) = \_to.call{ value: \_value }(\_calldata);\nif (!success) {\n if (returnData.length > 0) {\n assembly {\n let data\_size := mload(returnData)\n revert(add(32, returnData), data\_size)\n }\n } else {\n revert MessageSendingFailed(\_to);\n }\n}\n```\n

Vulnerable code:
```\n(bool success, bytes memory returnData) = \_to.call{ value: \_value }(\_calldata);\nif (!success) {\n if (returnData.length > 0) {\n assembly {\n let data\_size := mload(returnData)\n revert(add(32, returnData), data\_size)\n }\n } else {\n revert MessageSendingFailed(\_to);\n }\n}\n```\n
MEDIUM severity: Vulnerable function: ```\nint256 priceDiff = int256(currentPrice - lastPrices[_protocolId]);\n```\n. ```\nint256 priceDiff = int256(currentPrice - lastPrices[_protocolId]);\n```\n

Vulnerable code:
```\nint256 priceDiff = int256(currentPrice - lastPrices[_protocolId]);\n```\n
HIGH severity: Vulnerable function: ```\n  price = uint(sqrtPriceX96)*(uint(sqrtPriceX96))/(1e6)  (96 * 2);\n```\n. ```\n  price = uint(sqrtPriceX96)*(uint(sqrtPriceX96))/(1e6)  (96 * 2);\n```\n

Vulnerable code:
```\n  price = uint(sqrtPriceX96)*(uint(sqrtPriceX96))/(1e6)  (96 * 2);\n```\n
MEDIUM severity: Vulnerable function: ```\nfunction _collectFees(uint256 idle, uint256 debt, uint256 totalSupply) internal {\n    address . ```\nfunction _collectFees(uint256 idle, uint256 debt, uint256 totalSupply) internal {\n    address sink = feeSink;\n    // rest of code.\n    if (fees > 0 && sink != address(0)) {\n        // Calculated separate from other mints as normal share mint is round down\n        shares = _convertToShares(

Vulnerable code:
```\nfunction _collectFees(uint256 idle, uint256 debt, uint256 totalSupply) internal {\n    address sink = feeSink;\n    // rest of code.\n    if (fees > 0 && sink != address(0)) {\n        // Calculated separate from other mints as normal share mint is round down\n        shares = _convertToShares(fees, Math.Rounding.Up);\n        _mint(sink, shares);\n        emit Deposit(address(this), sink, fees, shares);\n    }\n    // rest of code.\n}\n```\n
HIGH severity: Vulnerable function: ```\ncontract LiquidityMining is ILiquidityMining, ERC1155Receiver, Ownable {\n`. ```\ncontract LiquidityMining is ILiquidityMining, ERC1155Receiver, Ownable {\n```\n

Vulnerable code:
```\ncontract LiquidityMining is ILiquidityMining, ERC1155Receiver, Ownable {\n```\n
MEDIUM severity: Vulnerable function: ```\n    function _tokensToShares(\n        uint128 amount,\n        uint128 rate\n    ) internal vi. ```\n    function _tokensToShares(\n        uint128 amount,\n        uint128 rate\n    ) internal view returns (uint128) {\n        return uint128((uint256(amount) * DIVIDER) / uint256(rate));\n    }\n```\n

Vulnerable code:
```\n    function _tokensToShares(\n        uint128 amount,\n        uint128 rate\n    ) internal view returns (uint128) {\n        return uint128((uint256(amount) * DIVIDER) / uint256(rate));\n    }\n```\n
MEDIUM severity: Vulnerable function: ```\nFile: JUSDBank.sol\n    function _withdraw(\n        uint256 amount,\n        address collatera. ```\nFile: JUSDBank.sol\n    function _withdraw(\n        uint256 amount,\n        address collateral,\n        address to,\n        address from,\n        bool isInternal\n    ) internal {\n// rest of code\n// rest of code\n        if (isInternal) {\n            DataTypes.UserInfo storage toAccount

Vulnerable code:
```\nFile: JUSDBank.sol\n    function _withdraw(\n        uint256 amount,\n        address collateral,\n        address to,\n        address from,\n        bool isInternal\n    ) internal {\n// rest of code\n// rest of code\n        if (isInternal) {\n            DataTypes.UserInfo storage toAccount = userInfo[to];\n            _addCollateralIfNotExists(toAccount, collateral);\n            toAccount.depositBalance[collateral] += amount;\n            require(\n                toAccount.depositBalance[collateral] <=\n                    reserve.maxDepositAmountPerAccount,\n                JUSDErrors.EXCEED_THE_MAX_DEPOSIT_AMOUNT_PER_ACCOUNT\n            );\n// rest of code\n// rest of code\n```\n
MEDIUM severity: Vulnerable function: ```\nPerpDepository.sol\n    function rebalanceLite(\n        uint256 amount,\n        int8 polarity. ```\nPerpDepository.sol\n    function rebalanceLite(\n        uint256 amount,\n        int8 polarity,\n        uint160 sqrtPriceLimitX96,\n        address account\n    ) external nonReentrant returns (uint256, uint256) {\n        if (polarity == -1) {\n            return\n                _rebalanceN

Vulnerable code:
```\nPerpDepository.sol\n    function rebalanceLite(\n        uint256 amount,\n        int8 polarity,\n        uint160 sqrtPriceLimitX96,\n        address account\n    ) external nonReentrant returns (uint256, uint256) {\n        if (polarity == -1) {\n            return\n                _rebalanceNegativePnlLite(amount, sqrtPriceLimitX96, account);\n        } else if (polarity == 1) {\n            // disable rebalancing positive PnL\n            revert PositivePnlRebalanceDisabled(msg.sender);\n            // return _rebalancePositivePnlLite(amount, sqrtPriceLimitX96, account);\n        } else {\n            revert InvalidRebalance(polarity);\n        }\n    }\n    function _rebalanceNegativePnlLite(\n        uint256 amount,\n        uint160 sqrtPriceLimitX96,\n        address account\n    ) private returns (uint256, uint256) {\n        uint256 normalizedAmount = amount.fromDecimalToDecimal(\n            ERC20(quoteToken).decimals(),\n            18\n        );\n        _checkNegativePnl(normalizedAmount);\n        IERC20(quoteToken).transferFrom(account, address(this), amount);\n        IERC20(quoteToken).approve(address(vault), amount);\n        vault.deposit(quoteToken, amount);\n        bool isShort = false;\n        bool amountIsInput = true;\n        (uint256 baseAmount, uint256 quoteAmount) = _placePerpOrder(\n            normalizedAmount,\n            isShort,\n            amountIsInput,\n            sqrtPriceLimitX96\n        );\n        vault.withdraw(assetToken, baseAmount);\n        IERC20(assetToken).transfer(account, baseAmount);\n        emit Rebalanced(baseAmount, quoteAmount, 0);\n        return (baseAmount, quoteAmount);\n    }\n```\n
MEDIUM severity: Vulnerable function: ```\n        } else if (p == uint8(Principals.Apwine)) {\n            address fu. ```\n        } else if (p == uint8(Principals.Apwine)) {\n            address futureVault = IAPWineToken(a).futureVault();\n            address interestBearingToken = IAPWineFutureVault(futureVault)\n                .getIBTAddress();\n            IRedeemer(redeemer).approve(interestBearingToken);\n 

Vulnerable code:
```\n        } else if (p == uint8(Principals.Apwine)) {\n            address futureVault = IAPWineToken(a).futureVault();\n            address interestBearingToken = IAPWineFutureVault(futureVault)\n                .getIBTAddress();\n            IRedeemer(redeemer).approve(interestBearingToken);\n        } else if (p == uint8(Principals.Notional)) {\n```\n
HIGH severity: Vulnerable function: ```\nLiquidationAccountant(accountant).handleNewLiquidation(\n  lien.amount,\n  . ```\nLiquidationAccountant(accountant).handleNewLiquidation(\n  lien.amount,\n  COLLATERAL_TOKEN.auctionWindow() + 1 days\n);\n```\n

Vulnerable code:
```\nLiquidationAccountant(accountant).handleNewLiquidation(\n  lien.amount,\n  COLLATERAL_TOKEN.auctionWindow() + 1 days\n);\n```\n
MEDIUM severity: Vulnerable function: ```\n  if (_seniorVaultWethRewards > state.wethConversionThreshold) {\n      // . ```\n  if (_seniorVaultWethRewards > state.wethConversionThreshold) {\n      // converts senior tranche share of weth into usdc and deposit into AAVE\n      // Deposit aave vault share to AAVE in usdc\n      uint256 minUsdcAmount = _getTokenPriceInUsdc(state, state.weth).mulDivDown(\n          _seni

Vulnerable code:
```\n  if (_seniorVaultWethRewards > state.wethConversionThreshold) {\n      // converts senior tranche share of weth into usdc and deposit into AAVE\n      // Deposit aave vault share to AAVE in usdc\n      uint256 minUsdcAmount = _getTokenPriceInUsdc(state, state.weth).mulDivDown(\n          _seniorVaultWethRewards * (MAX_BPS - state.slippageThresholdSwapEthBps),\n          MAX_BPS * PRICE_PRECISION\n      );\n      // swaps weth into usdc\n      (uint256 aaveUsdcAmount, ) = state._swapToken(\n          address(state.weth),\n          _seniorVaultWethRewards,\n          minUsdcAmount\n      );\n\n      // supplies usdc into AAVE\n      state._executeSupply(address(state.usdc), aaveUsdcAmount);\n\n      // resets senior tranche rewards\n      state.seniorVaultWethRewards = 0;\n```\n
MEDIUM severity: Vulnerable function: ```\nfunction \_getAaveProvider() internal pure returns (IAaveLendingPoolProvider) {\n return IAaveL. ```\nfunction \_getAaveProvider() internal pure returns (IAaveLendingPoolProvider) {\n return IAaveLendingPoolProvider(0xB53C1a33016B2DC2fF3653530bfF1848a515c8c5);\n}\n```\n

Vulnerable code:
```\nfunction \_getAaveProvider() internal pure returns (IAaveLendingPoolProvider) {\n return IAaveLendingPoolProvider(0xB53C1a33016B2DC2fF3653530bfF1848a515c8c5);\n}\n```\n
MEDIUM severity: Vulnerable function: ```\n * WARNING: You should avoid using leaf values that are 64 bytes long prior to\n * hashing, or . ```\n * WARNING: You should avoid using leaf values that are 64 bytes long prior to\n * hashing, or use a hash function other than keccak256 for hashing leaves.\n * This is because the concatenation of a sorted pair of internal nodes in\n * the merkle tree could be reinterpreted as a leaf value.\n``

Vulnerable code:
```\n * WARNING: You should avoid using leaf values that are 64 bytes long prior to\n * hashing, or use a hash function other than keccak256 for hashing leaves.\n * This is because the concatenation of a sorted pair of internal nodes in\n * the merkle tree could be reinterpreted as a leaf value.\n```\n