Farseen0/scar-pairs huggingface dataset:
MEDIUM severity: Vulnerable function: ```\nfunction setSettingRewardsClaimer(string memory \_contractName, uint256 \_perc) override public. ```\nfunction setSettingRewardsClaimer(string memory \_contractName, uint256 \_perc) override public onlyDAOProtocolProposal {\n    // Get the total perc set, can't be more than 100\n    uint256 percTotal = getRewardsClaimersPercTotal();\n    // If this group already exists, it will update the perc\

Vulnerable code:
```\nfunction setSettingRewardsClaimer(string memory \_contractName, uint256 \_perc) override public onlyDAOProtocolProposal {\n    // Get the total perc set, can't be more than 100\n    uint256 percTotal = getRewardsClaimersPercTotal();\n    // If this group already exists, it will update the perc\n    uint256 percTotalUpdate = percTotal.add(\_perc).sub(getRewardsClaimerPerc(\_contractName));\n    // Can't be more than a total claim amount of 100%\n    require(percTotalUpdate <= 1 ether, "Claimers cannot total more than 100%");\n    // Update the total\n    setUint(keccak256(abi.encodePacked(settingNameSpace,"rewards.claims", "group.totalPerc")), percTotalUpdate);\n    // Update/Add the claimer amount\n    setUint(keccak256(abi.encodePacked(settingNameSpace, "rewards.claims", "group.amount", \_contractName)), \_perc);\n    // Set the time it was updated at\n    setUint(keccak256(abi.encodePacked(settingNameSpace, "rewards.claims", "group.amount.updated.time", \_contractName)), block.timestamp);\n}\n```\n
MEDIUM severity: Vulnerable function: ```\n    function _getInitialVotingRewards(\n        IGovPool.ProposalCore storage core,\n        IG. ```\n    function _getInitialVotingRewards(\n        IGovPool.ProposalCore storage core,\n        IGovPool.VoteInfo storage voteInfo\n    ) internal view returns (uint256) {\n        (uint256 coreVotes, uint256 coreRawVotes) = voteInfo.isVoteFor\n            ? (core.votesFor, core.rawVotesFor)\n    

Vulnerable code:
```\n    function _getInitialVotingRewards(\n        IGovPool.ProposalCore storage core,\n        IGovPool.VoteInfo storage voteInfo\n    ) internal view returns (uint256) {\n        (uint256 coreVotes, uint256 coreRawVotes) = voteInfo.isVoteFor\n            ? (core.votesFor, core.rawVotesFor)\n            : (core.votesAgainst, core.rawVotesAgainst);\n\n        return\n            coreRawVotes.ratio(core.settings.rewardsInfo.voteRewardsCoefficient, PRECISION).ratio(\n                voteInfo.totalVoted,\n                coreVotes\n            ); //@audit -> initial rewards are calculated proportionate to the vote rewards coefficient\n    }\n```\n
MEDIUM severity: Vulnerable function: ```\n    function isLiquidatable(uint256 positionId) public view returns (bool) {\n        return\n . ```\n    function isLiquidatable(uint256 positionId) public view returns (bool) {\n        return\n            getPositionRisk(positionId) >=\n            banks[positions[positionId].underlyingToken].liqThreshold;\n    }\n```\n

Vulnerable code:
```\n    function isLiquidatable(uint256 positionId) public view returns (bool) {\n        return\n            getPositionRisk(positionId) >=\n            banks[positions[positionId].underlyingToken].liqThreshold;\n    }\n```\n
MEDIUM severity: Vulnerable function: ```\nrequire((value == 0) || (token.allowance(address(this), spender) == 0), \n". ```\nrequire((value == 0) || (token.allowance(address(this), spender) == 0), \n"SafeERC20: approve from non-zero to non-zero allowance");\n```\n

Vulnerable code:
```\nrequire((value == 0) || (token.allowance(address(this), spender) == 0), \n"SafeERC20: approve from non-zero to non-zero allowance");\n```\n
MEDIUM severity: Vulnerable function: ```\n    function getTRate() public view returns (uint256) {\n        uint256 timeDifference = block. ```\n    function getTRate() public view returns (uint256) {\n        uint256 timeDifference = block.timestamp - uint256(lastUpdateTimestamp);\n        return\n            t0Rate +\n            (borrowFeeRate * timeDifference) /\n            JOJOConstant.SECONDS_PER_YEAR;\n    }\n```\n

Vulnerable code:
```\n    function getTRate() public view returns (uint256) {\n        uint256 timeDifference = block.timestamp - uint256(lastUpdateTimestamp);\n        return\n            t0Rate +\n            (borrowFeeRate * timeDifference) /\n            JOJOConstant.SECONDS_PER_YEAR;\n    }\n```\n
MEDIUM severity: Vulnerable function: ```\nuint256 payFromToken = d3Proxy.buyTokens(\n            address(d3MM),\n    . ```\nuint256 payFromToken = d3Proxy.buyTokens(\n            address(d3MM),\n            user1,\n            address(token1),\n            address(token2),\n            10000000,\n            0,\n            abi.encode(swapData),\n            block.timestamp + 1000\n        );\nassertEq(payFromToken,

Vulnerable code:
```\nuint256 payFromToken = d3Proxy.buyTokens(\n            address(d3MM),\n            user1,\n            address(token1),\n            address(token2),\n            10000000,\n            0,\n            abi.encode(swapData),\n            block.timestamp + 1000\n        );\nassertEq(payFromToken, 0);\n```\n
MEDIUM severity: Vulnerable function: ```\nif (LibQuote.quoteOpenAmount(quote) != quote.quantityToClose) {\n    requir. ```\nif (LibQuote.quoteOpenAmount(quote) != quote.quantityToClose) {\n    require(quote.lockedValues.total() >= symbolLayout.symbols[quote.symbolId].minAcceptableQuoteValue,\n        "LibQuote: Remaining quote value is low");\n}\n```\n

Vulnerable code:
```\nif (LibQuote.quoteOpenAmount(quote) != quote.quantityToClose) {\n    require(quote.lockedValues.total() >= symbolLayout.symbols[quote.symbolId].minAcceptableQuoteValue,\n        "LibQuote: Remaining quote value is low");\n}\n```\n
HIGH severity: Vulnerable function: ```\nstruct Observation {\n    // the block timestamp of the observation\n    ui. ```\nstruct Observation {\n    // the block timestamp of the observation\n    uint32 blockTimestamp;\n    // the tick accumulator, i.e. tick * time elapsed since the pool was first initialized\n    int56 tickCumulative;\n    // the seconds per liquidity, i.e. seconds elapsed / max(1, liquidity) sinc

Vulnerable code:
```\nstruct Observation {\n    // the block timestamp of the observation\n    uint32 blockTimestamp;\n    // the tick accumulator, i.e. tick * time elapsed since the pool was first initialized\n    int56 tickCumulative;\n    // the seconds per liquidity, i.e. seconds elapsed / max(1, liquidity) since the pool was first initialized\n    uint160 secondsPerLiquidityCumulativeX128;\n    // whether or not the observation is initialized\n    bool initialized;\n}\n```\n
HIGH severity: Vulnerable function: ```\nfunction cancelOrder(LibOrder.Order memory order) public {\n    require(msg.sender == order.tra. ```\nfunction cancelOrder(LibOrder.Order memory order) public {\n    require(msg.sender == order.trader || msg.sender == order.broker, "invalid caller");\n\n    bytes32 orderHash = order.getOrderHash();\n    cancelled[orderHash] = true;\n\n    emit Cancel(orderHash);\n}\n```\n

Vulnerable code:
```\nfunction cancelOrder(LibOrder.Order memory order) public {\n    require(msg.sender == order.trader || msg.sender == order.broker, "invalid caller");\n\n    bytes32 orderHash = order.getOrderHash();\n    cancelled[orderHash] = true;\n\n    emit Cancel(orderHash);\n}\n```\n
MEDIUM severity: Vulnerable function: ```\n    function mint(\n        IPositionManager.MintParams calldata params\n    ) external overrid. ```\n    function mint(\n        IPositionManager.MintParams calldata params\n    ) external override returns (uint256 tokenId, uint256 premium) {\n        IDVP dvp = IDVP(params.dvpAddr);\n\n        if (params.tokenId != 0) {\n            tokenId = params.tokenId;\n            ManagedPosition stora

Vulnerable code:
```\n    function mint(\n        IPositionManager.MintParams calldata params\n    ) external override returns (uint256 tokenId, uint256 premium) {\n        IDVP dvp = IDVP(params.dvpAddr);\n\n        if (params.tokenId != 0) {\n            tokenId = params.tokenId;\n            ManagedPosition storage position = _positions[tokenId];\n\n            if (ownerOf(tokenId) != msg.sender) {\n                revert NotOwner();\n            }\n            // Check token compatibility:\n            if (position.dvpAddr != params.dvpAddr || position.strike != params.strike) {\n                revert InvalidTokenID();\n            }\n            Epoch memory epoch = dvp.getEpoch();\n            if (position.expiry != epoch.current) {\n                revert PositionExpired();\n            }\n        }\n        if ((params.notionalUp > 0 && params.notionalDown > 0) && (params.notionalUp != params.notionalDown)) {\n            // If amount is a smile, it must be balanced:\n            revert AsymmetricAmount();\n        }\n\n        uint256 obtainedPremium;\n        uint256 fee;\n        (obtainedPremium, fee) = dvp.premium(params.strike, params.notionalUp, params.notionalDown);\n\n        // Transfer premium:\n        // NOTE: The PositionManager is just a middleman between the user and the DVP\n        IERC20 baseToken = IERC20(dvp.baseToken());\n        baseToken.safeTransferFrom(msg.sender, address(this), obtainedPremium);\n\n        // Premium already include fee\n        baseToken.safeApprove(params.dvpAddr, obtainedPremium);\n\n==>     premium = dvp.mint(\n            address(this),\n            params.strike,\n            params.notionalUp,\n            params.notionalDown,\n            params.expectedPremium,\n            params.maxSlippage,\n            params.nftAccessTokenId\n        );\n\n        // // rest of code.\n    }\n```\n
MEDIUM severity: Vulnerable function: ```\n/\*\*\n \* @notice Update controller to `\_controller`\n \* @param \_controller The address of . ```\n/\*\*\n \* @notice Update controller to `\_controller`\n \* @param \_controller The address of the new controller contract\n\*/\nfunction updateController(IAragonFundraisingController \_controller) external auth(UPDATE\_CONTROLLER\_ROLE) {\n    require(isContract(\_controller), ERROR\_CONTRACT\

Vulnerable code:
```\n/\*\*\n \* @notice Update controller to `\_controller`\n \* @param \_controller The address of the new controller contract\n\*/\nfunction updateController(IAragonFundraisingController \_controller) external auth(UPDATE\_CONTROLLER\_ROLE) {\n    require(isContract(\_controller), ERROR\_CONTRACT\_IS\_EOA);\n\n    \_updateController(\_controller);\n}\n```\n
HIGH severity: Vulnerable function: ```\nfunction \_commit(uint256 \_weaveAmount, GoldOrder memory \_order)\n  internal\n{\n  // Check i. ```\nfunction \_commit(uint256 \_weaveAmount, GoldOrder memory \_order)\n  internal\n{\n  // Check if weave sent is sufficient for order\n  uint256 total\_cost = \_order.cardAmount.mul(goldPrice).add(\_order.feeAmount);\n  uint256 refund\_amount = \_weaveAmount.sub(total\_cost); // Will throw if ins

Vulnerable code:
```\nfunction \_commit(uint256 \_weaveAmount, GoldOrder memory \_order)\n  internal\n{\n  // Check if weave sent is sufficient for order\n  uint256 total\_cost = \_order.cardAmount.mul(goldPrice).add(\_order.feeAmount);\n  uint256 refund\_amount = \_weaveAmount.sub(total\_cost); // Will throw if insufficient amount received\n```\n
MEDIUM severity: Vulnerable function: ```\nfunction converterType() public pure returns (uint16) {\n    return 3;\n}\n```\n. ```\nfunction converterType() public pure returns (uint16) {\n    return 3;\n}\n```\n

Vulnerable code:
```\nfunction converterType() public pure returns (uint16) {\n    return 3;\n}\n```\n
MEDIUM severity: Vulnerable function: ```\nFile: InterestRateCurve.sol\n    function _getNetCashAmountsUnderlying(\n        InterestRatePa. ```\nFile: InterestRateCurve.sol\n    function _getNetCashAmountsUnderlying(\n        InterestRateParameters memory irParams,\n        MarketParameters memory market,\n        CashGroupParameters memory cashGroup,\n        int256 totalCashUnderlying,\n        int256 fCashToAccount,\n        uint256 

Vulnerable code:
```\nFile: InterestRateCurve.sol\n    function _getNetCashAmountsUnderlying(\n        InterestRateParameters memory irParams,\n        MarketParameters memory market,\n        CashGroupParameters memory cashGroup,\n        int256 totalCashUnderlying,\n        int256 fCashToAccount,\n        uint256 timeToMaturity\n    ) private pure returns (int256 postFeeCashToAccount, int256 netUnderlyingToMarket, int256 cashToReserve) {\n        uint256 utilization = getfCashUtilization(fCashToAccount, market.totalfCash, totalCashUnderlying);\n        // Do not allow utilization to go above 100 on trading\n        if (utilization > uint256(Constants.RATE_PRECISION)) return (0, 0, 0);\n        uint256 preFeeInterestRate = getInterestRate(irParams, utilization);\n\n        int256 preFeeCashToAccount = fCashToAccount.divInRatePrecision(\n            getfCashExchangeRate(preFeeInterestRate, timeToMaturity)\n        ).neg();\n\n        uint256 postFeeInterestRate = getPostFeeInterestRate(irParams, preFeeInterestRate, fCashToAccount < 0);\n        postFeeCashToAccount = fCashToAccount.divInRatePrecision(\n            getfCashExchangeRate(postFeeInterestRate, timeToMaturity)\n        ).neg();\n```\n
HIGH severity: Vulnerable function: ```\nfunction commitCollateral(\n    uint256 _bidId,\n    Collateral[] calldata _collateralInfo\n) p. ```\nfunction commitCollateral(\n    uint256 _bidId,\n    Collateral[] calldata _collateralInfo\n) public returns (bool validation_) {\n    address borrower = tellerV2.getLoanBorrower(_bidId);\n    (validation_, ) = checkBalances(borrower, _collateralInfo); <- @audit-issue never checks that loan isn

Vulnerable code:
```\nfunction commitCollateral(\n    uint256 _bidId,\n    Collateral[] calldata _collateralInfo\n) public returns (bool validation_) {\n    address borrower = tellerV2.getLoanBorrower(_bidId);\n    (validation_, ) = checkBalances(borrower, _collateralInfo); <- @audit-issue never checks that loan isn't active\n\n    if (validation_) {\n        for (uint256 i; i < _collateralInfo.length; i++) {\n            Collateral memory info = _collateralInfo[i];\n            _commitCollateral(_bidId, info);\n        }\n    }\n}\n```\n
MEDIUM severity: Vulnerable function: ```\nfunction getAvailableForWithdraw(address account) public view returns (uint96) {\n    uint96 va. ```\nfunction getAvailableForWithdraw(address account) public view returns (uint96) {\n    uint96 value = accounts[account].amount;\n    if (!stopped) {\n      uint32 currentBlock = getBlockNumber();\n      uint32 time = roundTimestamp(currentBlock);\n      uint96 bias = accounts[account].locked.act

Vulnerable code:
```\nfunction getAvailableForWithdraw(address account) public view returns (uint96) {\n    uint96 value = accounts[account].amount;\n    if (!stopped) {\n      uint32 currentBlock = getBlockNumber();\n      uint32 time = roundTimestamp(currentBlock);\n      uint96 bias = accounts[account].locked.actualValue(time, currentBlock);\n      value = value - (bias);\n    }\n    return value;\n```\n
HIGH severity: Vulnerable function: ```\nif (path[0].isETH()) {\n    tx.origin.transfer(availableBalance);  // solhi. ```\nif (path[0].isETH()) {\n    tx.origin.transfer(availableBalance);  // solhint-disable-line avoid-tx-origin\n} else {\n    path[0].safeTransfer(address(mooniswap), availableBalance);\n}\n```\n

Vulnerable code:
```\nif (path[0].isETH()) {\n    tx.origin.transfer(availableBalance);  // solhint-disable-line avoid-tx-origin\n} else {\n    path[0].safeTransfer(address(mooniswap), availableBalance);\n}\n```\n
MEDIUM severity: Vulnerable function: ```\nfunction addOperator(address \_operatorAddress, address \_feeRecipientAddress) external onlyAdm. ```\nfunction addOperator(address \_operatorAddress, address \_feeRecipientAddress) external onlyAdmin returns (uint256) {\n StakingContractStorageLib.OperatorsSlot storage operators = StakingContractStorageLib.getOperators();\n StakingContractStorageLib.OperatorInfo memory newOperator;\n\n if (oper

Vulnerable code:
```\nfunction addOperator(address \_operatorAddress, address \_feeRecipientAddress) external onlyAdmin returns (uint256) {\n StakingContractStorageLib.OperatorsSlot storage operators = StakingContractStorageLib.getOperators();\n StakingContractStorageLib.OperatorInfo memory newOperator;\n\n if (operators.value.length == 1) {\n revert MaximumOperatorCountAlreadyReached();\n }\n```\n
MEDIUM severity: Vulnerable function: ```\n    /**\n        Δ_bull = (1 / θ) * F\n        F = {\n@@@         * 0                     if (S. ```\n    /**\n        Δ_bull = (1 / θ) * F\n        F = {\n@@@         * 0                     if (S < K)\n            * (1 - √(K / Kb)) / K   if (S > Kb)\n            * 1 / K - 1 / √(S * K)  if (K < S < Kb)\n        }\n    */\n    function bullDelta(uint256 k, uint256 kB, uint256 s, uint256 theta) 

Vulnerable code:
```\n    /**\n        Δ_bull = (1 / θ) * F\n        F = {\n@@@         * 0                     if (S < K)\n            * (1 - √(K / Kb)) / K   if (S > Kb)\n            * 1 / K - 1 / √(S * K)  if (K < S < Kb)\n        }\n    */\n    function bullDelta(uint256 k, uint256 kB, uint256 s, uint256 theta) internal pure returns (int256) {\n        SD59x18 delta;\n        if (s <= k) {\n@@@         return 0;\n        }\n```\n
MEDIUM severity: Vulnerable function: ```\nif (\n    !PositionLib.margined(\n        context.latestPosition.local.magn. ```\nif (\n    !PositionLib.margined(\n        context.latestPosition.local.magnitude().add(context.pending.local.pos()),\n        context.latestOracleVersion,\n        context.riskParameter,\n        context.local.collateral\n    )\n) revert IMarket.MarketInsufficientMarginError();\n```\n

Vulnerable code:
```\nif (\n    !PositionLib.margined(\n        context.latestPosition.local.magnitude().add(context.pending.local.pos()),\n        context.latestOracleVersion,\n        context.riskParameter,\n        context.local.collateral\n    )\n) revert IMarket.MarketInsufficientMarginError();\n```\n
HIGH severity: Vulnerable function: ```\nFile: VaultSecondaryBorrow.sol\n    function _setAccountMaturity(\n        VaultAccountSecondar. ```\nFile: VaultSecondaryBorrow.sol\n    function _setAccountMaturity(\n        VaultAccountSecondaryDebtShareStorage storage accountStorage,\n        int256 accountDebtOne,\n        int256 accountDebtTwo,\n        uint40 maturity\n    ) private {\n        if (accountDebtOne == 0 && accountDebtTwo =

Vulnerable code:
```\nFile: VaultSecondaryBorrow.sol\n    function _setAccountMaturity(\n        VaultAccountSecondaryDebtShareStorage storage accountStorage,\n        int256 accountDebtOne,\n        int256 accountDebtTwo,\n        uint40 maturity\n    ) private {\n        if (accountDebtOne == 0 && accountDebtTwo == 0) {\n            // If both debt shares are cleared to zero, clear the maturity as well.\n            accountStorage.maturity = 0;\n        } else {\n            // In all other cases, set the account to the designated maturity\n            accountStorage.maturity = maturity;\n        }\n    }\n```\n
HIGH severity: Vulnerable function: ```\nFile: TokenHandler.sol\n    function _redeemMoneyMarketIfRequired(\n        uint16 currencyId,\. ```\nFile: TokenHandler.sol\n    function _redeemMoneyMarketIfRequired(\n        uint16 currencyId,\n        Token memory underlying,\n        uint256 withdrawAmountExternal\n    ) private {\n        // If there is sufficient balance of the underlying to withdraw from the contract\n        // immedi

Vulnerable code:
```\nFile: TokenHandler.sol\n    function _redeemMoneyMarketIfRequired(\n        uint16 currencyId,\n        Token memory underlying,\n        uint256 withdrawAmountExternal\n    ) private {\n        // If there is sufficient balance of the underlying to withdraw from the contract\n        // immediately, just return.\n        mapping(address => uint256) storage store = LibStorage.getStoredTokenBalances();\n        uint256 currentBalance = store[underlying.tokenAddress];\n        if (withdrawAmountExternal <= currentBalance) return;\n\n        IPrimeCashHoldingsOracle oracle = PrimeCashExchangeRate.getPrimeCashHoldingsOracle(currencyId);\n        // Redemption data returns an array of contract calls to make from the Notional proxy (which\n        // is holding all of the money market tokens).\n        (RedeemData[] memory data) = oracle.getRedemptionCalldata(withdrawAmountExternal);\n\n        // This is the total expected underlying that we should redeem after all redemption calls\n        // are executed.\n        uint256 totalUnderlyingRedeemed = executeMoneyMarketRedemptions(underlying, data);\n\n        // Ensure that we have sufficient funds before we exit\n        require(withdrawAmountExternal <= currentBalance.add(totalUnderlyingRedeemed)); // dev: insufficient redeem\n    }\n```\n
MEDIUM severity: Vulnerable function: ```\nfunction \_upgradeContract(string memory \_name, address \_contractAddress, string memory \_con. ```\nfunction \_upgradeContract(string memory \_name, address \_contractAddress, string memory \_contractAbi) internal {\n    // Check contract being upgraded\n    bytes32 nameHash = keccak256(abi.encodePacked(\_name));\n    require(nameHash != keccak256(abi.encodePacked("rocketVault")),        "Can

Vulnerable code:
```\nfunction \_upgradeContract(string memory \_name, address \_contractAddress, string memory \_contractAbi) internal {\n    // Check contract being upgraded\n    bytes32 nameHash = keccak256(abi.encodePacked(\_name));\n    require(nameHash != keccak256(abi.encodePacked("rocketVault")),        "Cannot upgrade the vault");\n    require(nameHash != keccak256(abi.encodePacked("rocketPoolToken")),    "Cannot upgrade token contracts");\n    require(nameHash != keccak256(abi.encodePacked("rocketTokenRETH")),     "Cannot upgrade token contracts");\n    require(nameHash != keccak256(abi.encodePacked("rocketTokenNETH")), "Cannot upgrade token contracts");\n    require(nameHash != keccak256(abi.encodePacked("casperDeposit")),      "Cannot upgrade the casper deposit contract");\n    // Get old contract address & check contract exists\n```\n