Farseen0/scar-pairs huggingface dataset:
MEDIUM severity: The vulnerability allows users to repeatedly borrow and deposit funds denominated in various assets,. The vulnerability allows users to repeatedly borrow and deposit funds denominated in various assets, earning FIN tokens in the process. This behavior enables users to create positions across multiple tokens, increasing their borrow power and allowing them to borrow even more assets. The collateral f...

Vulnerable code:
```\n/**\n * Calculate an account's borrow power based on token's LTV\n */\n\nfunction getBorrowPower(address _borrower) public view returns (uint256 power) {\n    for (uint8 i = 0; i < globalConfig.tokenInfoRegistry().getCoinLength(); i++) {\n        if (isUserHasDeposits(_borrower, i)) {\n            address token = globalConfig.tokenInfoRegistry().addressFromIndex(i);\n            uint divisor = INT_UNIT;\n            if (token!= ETH_ADDR) {\n                divisor = 10 ** uint256(globalConfig.tokenInfoRegistry().getTokenDecimals(token));\n            }\n            power = power.add(getDepositBalanceCurrent(token, _borrower)\n               .mul(globalConfig.tokenInfoRegistry().priceFromIndex(i))\n               .mul(globalConfig.tokenInfoRegistry().getBorrowLTV(token)).div(100)\n               .div(divisor)\n            );\n        }\n    }\n    return power;\n}\n```
MEDIUM severity: The `earned()` function in the ExternalBribe contract is responsible for calculating the rewards owe. The `earned()` function in the ExternalBribe contract is responsible for calculating the rewards owed to a specific token ID. This calculation involves iterating over a loop and performing various operations. The function always executes the following critical section of code:\n\n`Checkpoint memory...

Vulnerable code:
```\ncheckpoint memory cp = checkpoints[tokenId][_endIndex];\nuint _lastEpochStart = _bribeStart(cp.timestamp);\nuint _lastEpochEnd = _lastEpochStart + DURATION;\n\nif (block.timestamp > _lastEpochEnd) {\n    reward += (cp.balanceOf * \n    tokenRewardsPerEpoch[token][_lastEpochStart]) / \n    supplyCheckpoints[getPriorSupplyIndex(_lastEpochEnd)].supply;\n```
MEDIUM severity: The Lybra Protocol's liquidation mechanism allows any address with a non-zero allowance for a vault . The Lybra Protocol's liquidation mechanism allows any address with a non-zero allowance for a vault to become a debt provider for other liquidations. This means that an address can automatically become a provider for other users' liquidations, without any explicit agreement or permission from the or...

Vulnerable code:
```\nfunction liquidation(address provider, address onBehalfOf, uint256 assetAmount) external virtual {\n    uint256 assetPrice = getAssetPrice();\n    uint256 onBehalfOfCollateralRatio = (depositedAsset[onBehalfOf] * assetPrice * 100) / borrowed[onBehalfOf];\n    require(onBehalfOfCollateralRatio < badCollateralRatio, "Borrowers collateral ratio should be below badCollateralRatio");\n\n    require(assetAmount * 2 <= depositedAsset[onBehalfOf], "A max of 50% collateral can be liquidated");\n    require(EUSD.allowance(provider, address(this))!= 0, "Provider should authorize to provide liquidation EUSD");\n\n    uint256 eusdAmount = (assetAmount * assetPrice) / 1e18;\n\n    _repay(provider, onBehalfOf, eusdAmount);\n    uint256 reducedAsset = assetAmount * 11 / 10;\n    totalDepositedAsset -= reducedAsset;\n    depositedAsset[onBehalfOf] -= reducedAsset;\n\n    uint256 reward2keeper;\n    if (provider == msg.sender) {\n        collateralAsset.safeTransfer(msg.sender, reducedAsset);\n    } else {\n        reward2keeper = (reducedAsset * configurator.vaultKeeperRatio(address(this))) / 110;\n        collateralAsset.safeTransfer(provider, reducedAsset - reward2keeper);\n        collateralAsset.safeTransfer(msg.sender, reward2keeper);\n    }\n\n    emit LiquidationRecord(provider, msg.sender, onBehalfOf, eusdAmount, reducedAsset, reward2keeper, false, block.timestamp);\n}\n```\n```\nrequire(EUSD.allowance(provider, address(this))!= 0, "provider should authorize to provide liquidation EUSD");\n```\n```\nrequire(EUSD.allowance(provider, address(this)) >= eusdAmount, "provider should authorize to provide liquidation EUSD");\n```\n```\nif (provider == msg.sender) {\n    collateralAsset.safeTransfer(msg.sender, reducedAsset);\n} else {\n    reward2keeper = (reducedAsset * configurator.vaultKeeperRatio(address(this))) / 110;\n    collateralAsset.safeTransfer(provider, reducedAsset - reward2keeper);\n    collateralAsset.safeTransfer(msg.sender, reward2keeper);\n}\n```
MEDIUM severity: This vulnerability allows an attacker to exploit the re-entrancy feature in the token burning mechan. This vulnerability allows an attacker to exploit the re-entrancy feature in the token burning mechanism, enabling them to burn delegated tokens without being detected. The issue arises from the placement of the `_callTokensToSend` function, which is called after the check for unlocked tokens but bef...

Vulnerable code:
```\nuint locked = _getAndUpdateLockedAmount(from);\nif (locked > 0) {\n    require(_balances[from] >= locked.add(amount), "Token should be unlocked for burning");\n}\n\n_getCallTokensToSend(\n    operator,\n    from,\n    address(0),\n    amount,\n    data,\n    operatorData\n);\n\n_totalSupply = _totalSupply.sub(amount);\n_balances[from] = _balances[from].sub(amount);\n```
MEDIUM severity: The `swETH::_deposit` function contains a vulnerability due to an unnecessary hidden division operat. The `swETH::_deposit` function contains a vulnerability due to an unnecessary hidden division operation before multiplication. Specifically, the `_ethToSwETHRate` function is called, which performs a division operation, and the result is then multiplied by the `msg.value`. This division operation is...

Vulnerable code:
```\nuint256 swETHAmount = wrap(msg.value).mul(_ethToSwETHRate()).unwrap();\n\n// expanding this out\nswETHAmount = wrap(msg.value).mul(wrap(1 ether).div(_swETHToETHRate())).unwrap();\n```
MEDIUM severity: The vulnerability "Did Not Approve To Zero First" occurs when the allowance is not set to zero befor. The vulnerability "Did Not Approve To Zero First" occurs when the allowance is not set to zero before changing it, which can lead to unexpected behavior or reverts when interacting with certain ERC20 tokens, such as USDT. This is because some ERC20 tokens, like USDT, do not allow changing the allowa...

Vulnerable code:
```\nfunction checkApprove(IERC20 token, address spender, uint256 amount) internal {\n    if (address(token) == address(0)) return;\n\n    IEIP20NonStandard(address(token)).approve(spender, amount);\n    _checkReturnCode();\n}\n```\n```\nFile: TwoTokenPoolUtils.sol\n\nfunction _approveBalancerTokens(TwoTokenPoolContext memory poolContext, address bptSpender) internal {\n    IERC20(poolContext.primaryToken).checkApprove(address(Deployments.BALANCER_VAULT), type(uint256).max);\n    IERC20(poolContext.secondaryToken).checkApprove(address(Deployments.BALANCER_VAULT), type(uint256).max);\n    IERC20(address(poolContext.basePool.pool)).checkApprove(bptSpender, type(uint256).max);\n}\n```\n```\nFile: Boosted3TokenPoolUtils.sol\n\nfunction _approveBalancerTokens(ThreeTokenPoolContext memory poolContext, address bptSpender) internal {\n    poolContext.basePool._approveBalancerTokens(bptSpender);\n\n    IERC20(poolContext.tertiaryToken).checkApprove(address(Deployments.BALANCER_VAULT), type(uint256).max);\n\n    IBoostedPool underlyingPool = IBoostedPool(poolContext.basePool.primaryToken);\n    address primaryUnderlyingAddress = BalancerUtils.getTokenAddress(underlyingPool.getMainToken());\n    IERC20(primaryUnderlyingAddress).checkApprove(address(Deployments.BALANCER_VAULT), type(uint256).max);\n}\n```\n```\nFile: TradingUtils.sol\n\nfunction _approve(Trade memory trade, address spender) private {\n    uint256 allowance = _isExactIn(trade)? trade.amount : trade.limit;\n    IERC20(trade.sellToken).approve(spender, allowance);\n}\n```\n```\nFile: StrategyUtils.sol\n\n    IERC20(buyToken).checkApprove(address(Deployments.WRAPPED_STETH), amountBought);\n\n    uint256 wrappedAmount = Deployments.WRAPPED_STETH.balanceOf(address(this));\n\n    Deployments.WRAPPED_STETH.wrap(amountBought);\n\n    amountBought = Deployments.WRAPPED_STETH.balanceOf(address(this)) - wrappedAmount;\n```
MEDIUM severity: The Oracle will not failover as expected during liquidation, which can lead to underwater positions . The Oracle will not failover as expected during liquidation, which can lead to underwater positions and bad debt accumulating in the protocol, threatening its solvency. This is due to the inability to update the Pyth price during liquidation, as the liquidators have the option to bypass the `updateP...

Vulnerable code:
```\nFile: LiquidationModule.sol\n\nfunction liquidate(\n    uint256 tokenID,\n    bytes[] calldata priceUpdateData\n) external payable whenNotPaused updatePythPrice(vault, msg.sender, priceUpdateData) {\n    liquidate(tokenID);\n}\n\n/// @notice Function to liquidate a position.\nfunction liquidate(uint256 tokenId) public nonReentrant whenNotPaused liquidationInvariantChecks(vault, tokenId) {\n    FlatcoinStructs.Position memory position = vault.getPosition(tokenId);\n```\n```\nFile: OracleModule.sol\n\nfunction _getPrice(uint32 maxAge) internal view returns (uint256 price, uint256 timestamp) {\n    (uint256 onchainPrice, uint256 onchainTime) = _getOnchainPrice(); // will revert if invalid\n    (uint256 offchainPrice, uint256 offchainTime, bool offchainInvalid) = _getOffchainPrice();\n    bool offchain;\n\n    uint256 priceDiff = (int256(onchainPrice) - int256(offchainPrice)).abs();\n    uint256 diffPercent = (priceDiff * 1e18) / onchainPrice;\n    if (diffPercent > maxDiffPercent) {\n        revert FlatcoinErrors.PriceMismatch(diffPercent);\n    }\n\n    if (offchainInvalid == false) {\n        // return the freshest price\n        if (offchainTime >= onchainTime) {\n            price = offchainPrice;\n            timestamp = offchainTime;\n            offchain = true;\n        } else {\n            price = onchainPrice;\n            timestamp = onchainTime;\n        }\n    } else {\n        price = onchainPrice;\n        timestamp = onchainTime;\n    }\n\n    // Check that the timestamp is within the required age\n    if (maxAge < type(uint32).max && timestamp + maxAge < block.timestamp) {\n        revert FlatcoinErrors.PriceStale(offchain? FlatcoinErrors.PriceSource.OffChain : FlatcoinErrors.PriceSource.OnChain);\n    }\n}\n```
MEDIUM severity: The vulnerability lies in the design of the Transceiver upgrade mechanism, which allows integrators . The vulnerability lies in the design of the Transceiver upgrade mechanism, which allows integrators to bypass the checks that ensure the integrity of the NTT Manager's ownership and immutables during an upgrade. Specifically, the `Transceiver::_checkImmutables` function, which verifies that the NTT...

Vulnerable code:
```\nfunction _initialize() internal virtual override {\n    if (msg.sender!= deployer) {\n        revert UnexpectedDeployer(deployer, msg.sender);\n    }\n\n    __ReentrancyGuard_init();\n    __PausedOwnable_init(msg.sender, getNttManagerOwner());\n}\n```\n```\nfunction transferTransceiverOwnership(address newOwner) external onlyNttManager {\n    _transferOwnership(newOwner);\n}\n```\n```\nfunction transferOwnership(address newOwner) public override onlyOwner {\n    super.transferOwnership(newOwner);\n    address[] storage _registeredTransceivers = _getRegisteredTransceiversStorage();\n    _checkRegisteredTransceiversInvariants();\n\n    for (uint256 i = 0; i < _registeredTransceivers.length; i++) {\n        ITransceiver(_registeredTransceivers[i]).transferTransceiverOwnership(newOwner);\n    }\n}\n```
MEDIUM severity: The `beginGlobalSettlement` function, intended to initiate a global settlement process, can be invok. The `beginGlobalSettlement` function, intended to initiate a global settlement process, can be invoked multiple times by an authorized admin, allowing them to adjust the settlement price. This functionality is problematic because it can be called even when the contract is already in the `SETTLING` p...

Vulnerable code:
```\nfunction beginGlobalSettlement(uint256 price) public onlyWhitelistAdmin {\n    require(status!= LibTypes.Status.SETTLED, "already settled");\n    settlementPrice = price;\n    status = LibTypes.Status.SETTLING;\n    emit BeginGlobalSettlement(price);\n}\n```
MEDIUM severity: The ProtocolOwnedLiquidityOhm calculation in Bunni incorrectly includes the liquidity deposited by o. The ProtocolOwnedLiquidityOhm calculation in Bunni incorrectly includes the liquidity deposited by other users, which is not owned by the protocol. This is because the deposit function is publicly callable, allowing any user to add liquidity to a token. As a result, the returned reserve will contain...

Vulnerable code:
```\nfunction getProtocolOwnedLiquidityOhm() external view override returns (uint256) {\n    uint256 len = bunniTokens.length;\n    uint256 total;\n    for (uint256 i = 0; i < len; ) {\n        TokenData storage tokenData = bunniTokens[i];\n        BunniLens lens = tokenData.lens;\n        BunniKey memory key = _getBunniKey(tokenData.token);\n\n        total += _getOhmReserves(key, lens);\n        unchecked {\n            i++;\n        }\n    }\n    return total;\n}\n```\n```\nfunction deposit(\n    DepositParams calldata params\n)\n    external\n    payable\n    virtual\n    override\n    checkDeadline(params.deadline)\n    returns (uint256 shares, uint128 addedLiquidity, uint256 amount0, uint256 amount1)\n{\n}\n```
MEDIUM severity: The `emergencyClose()` function in the contract is responsible for repaying outstanding debts when t. The `emergencyClose()` function in the contract is responsible for repaying outstanding debts when the contract is paused due to various reasons, such as bad debts, hacking, or high volatility. The function assumes that the withdrawn amounts from GMX are always sufficient to cover the entire debt. H...

Vulnerable code:
```\nfunction emergencyClose(GMXTypes.Store storage self, uint256 deadline) external {\n    GMXChecks.beforeEmergencyCloseChecks(self);\n\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        _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```\nfunction calcSwapForRepay(GMXTypes.Store storage self, GMXTypes.RepayParams memory rp)\n    external\n    view\n    returns (bool, address, address, uint256)\n{\n    address _tokenFrom;\n    address _tokenTo;\n    uint256 _tokenToAmt;\n\n    if (rp.repayTokenAAmt > self.tokenA.balanceOf(address(this))) {\n        // If more tokenA is needed for repayment\n        _tokenToAmt = rp.repayTokenAAmt - self.tokenA.balanceOf(address(this));\n        _tokenFrom = address(self.tokenB);\n        _tokenTo = address(self.tokenA);\n\n        return (true, _tokenFrom, _tokenTo, _tokenToAmt);\n    } else if (rp.repayTokenBAmt > self.tokenB.balanceOf(address(this))) {\n        // If more tokenB is needed for repayment\n        _tokenToAmt = rp.repayTokenBAmt - self.tokenB.balanceOf(address(this));\n        _tokenFrom = address(self.tokenA);\n        _tokenTo = address(self.tokenB);\n\n        return (true, _tokenFrom, _tokenTo, _tokenToAmt);\n    } else {\n        // If there is enough to repay both tokens\n        return (false, address(0), address(0), 0);\n    }\n}\n```
MEDIUM severity: The `BalancedVault` implementation does not account for the possibility of catastrophic failure in o. The `BalancedVault` implementation does not account for the possibility of catastrophic failure in one of the underlying markets, which could result in permanent loss of funds deposited to the vault, including funds deposited to other markets. This is a critical issue, as the vault's design is inten...

Vulnerable code:
```\nif (shares.gt(_maxRedeemAtEpoch(context, accountContext, account))) {\n    revert BalancedVaultRedemptionLimitExceeded();\n```
MEDIUM severity: The zAuction contract contains a vulnerability that allows a seller to accept their own bid, which i. The zAuction contract contains a vulnerability that allows a seller to accept their own bid, which is an ineffective action that triggers an event. This is because the `acceptBid` and `acceptWethBid` functions do not properly validate the bidder's identity. Specifically, the `require` statement chec...

Vulnerable code:
```\nfunction acceptBid(bytes memory signature, uint256 rand, address bidder, uint256 bid, address nftaddress, uint256 tokenid) external {\n    address recoveredbidder = recover(toEthSignedMessageHash(keccak256(abi.encodePacked(rand, address(this), block.chainid, bid, nftaddress, tokenid))), signature);\n    require(bidder == recoveredbidder, 'zAuction: incorrect bidder');\n    require(!randUsed[rand], 'Random nonce already used');\n    randUsed[rand] = true;\n    IERC721 nftcontract = IERC721(nftaddress);\n    accountant.Exchange(bidder, msg.sender, bid);\n    nftcontract.transferFrom(msg.sender, bidder, tokenid);\n    emit BidAccepted(bidder, msg.sender, bid, nftaddress, tokenid);\n}\n\nfunction acceptWethBid(bytes memory signature, uint256 rand, address bidder, uint256 bid, address nftaddress, uint256 tokenid) external {\n    address recoveredbidder = recover(toEthSignedMessageHash(keccak256(abi.encodePacked(rand, address(this), block.chainid, bid, nftaddress, tokenid, true))), signature);\n    require(bidder == recoveredbidder, 'zAuction: incorrect bidder');\n    require(!randUsed[rand], 'Random nonce already used');\n    randUsed[rand] = true;\n    IERC721 nftcontract = IERC721(nftaddress);\n    weth.transferFrom(bidder, msg.sender, bid);\n    nftcontract.transferFrom(msg.sender, bidder, tokenid);\n    emit WethBidAccepted(bidder, msg.sender, bid, nftaddress, tokenid);\n}\n```
MEDIUM severity: The constant `ONE_WAD_U` is defined as a `uint256` with a value of `10**18`, but it is not utilized . The constant `ONE_WAD_U` is defined as a `uint256` with a value of `10**18`, but it is not utilized anywhere in the code. This is considered a potential issue because it can lead to maintenance difficulties if the same constant is re-declared in multiple source units or unit-test cases.

Vulnerable code:
```\nuint256 private constant ONE_WAD_U = 10**18;\n```
MEDIUM severity: When a node is removed from the network, the owner is responsible for redistributing all the schains. When a node is removed from the network, the owner is responsible for redistributing all the schains currently stored on that node to other nodes. To accomplish this, the validator must invoke the `nodeExit` function of the `SkaleManager` contract. This function only removes a single schain from the...

Vulnerable code:
```\nfunction _startRotation(bytes32 schainIndex, uint nodeIndex) private {\n    ConstantsHolder constants = ConstantsHolder(contractManager.getContract("ConstantsHolder"));\n    rotations[schainIndex].nodeIndex = nodeIndex;\n    rotations[schainIndex].newNodeIndex = nodeIndex;\n    rotations[schainIndex].freezeUntil = now.add(constants.rotationDelay());\n    waitForNewNode[schainIndex] = true;\n}\n```
MEDIUM severity: The Oracle Price mismatch vulnerability occurs when the E-mode category is set to use a single oracl. The Oracle Price mismatch vulnerability occurs when the E-mode category is set to use a single oracle price, which can lead to incorrect valuation of collateral and borrowed assets. This is because the AaveLeverageStrategyExtension does not account for the single oracle use, causing the prices used...

Vulnerable code:
```\nif (_isLever) {\n    uint256 netBorrowLimit = _actionInfo.collateralValue\n       .preciseMul(maxLtvRaw.mul(10 ** 14))\n       .preciseMul(PreciseUnitMath.preciseUnit().sub(execution.unutilizedLeveragePercentage));\n\n    return netBorrowLimit\n       .sub(_actionInfo.borrowValue)\n       .preciseDiv(_actionInfo.collateralPrice);\n} else {\n    uint256 netRepayLimit = _actionInfo.collateralValue\n       .preciseMul(liquidationThresholdRaw.mul(10 ** 14))\n       .preciseMul(PreciseUnitMath.preciseUnit().sub(execution.unutilizedLeveragePercentage));\n\n    return _actionInfo.collateralBalance\n       .preciseMul(netRepayLimit.sub(_actionInfo.borrowValue))\n       .preciseDiv(netRepayLimit);\n}\n```
MEDIUM severity: The `Funds.maxFundDur` property is intended to specify the maximum duration for which a fund should . The `Funds.maxFundDur` property is intended to specify the maximum duration for which a fund should remain active. However, this restriction is bypassed when the `maxLoanDur` property is set, which allows for a loan duration exceeding the maximum fund duration. This is because the check `now + loanD...

Vulnerable code:
```\nif (maxLoanDur(fund) > 0) {\n    require(loanDur <= maxLoanDur(fund));\n} else {\n    require(now + loanDur <= maxFundDur(fund));\n}\n```
MEDIUM severity: The `Ingress` contract, which is designed to mimic the behavior of a set, has not been implemented c. The `Ingress` contract, which is designed to mimic the behavior of a set, has not been implemented consistently with the recent changes to the `AdminList`, `AccountRulesList`, and `NodeRulesList` contracts, which now utilize sets. This inconsistency leads to suboptimal performance in certain operati...

Vulnerable code:
```\nfor (uint i = 0; i < contractKeys.length; i++) {\n    if (contractKeys[i] == name) {\n        delete registry[contractKeys[i]];\n        contractKeys[i] = contractKeys[contractKeys.length - 1];\n        delete contractKeys[contractKeys.length - 1];\n        contractKeys.length--;\n    }\n}\n```
MEDIUM severity: The StableOracleWBTC contract relies on a BTC/USD Chainlink oracle to determine the price of WBTC, w. The StableOracleWBTC contract relies on a BTC/USD Chainlink oracle to determine the price of WBTC, which can lead to significant issues if WBTC were to depeg from BTC. This is because the protocol continues to value WBTC based on the BTC/USD price, even if the bridge connecting WBTC to BTC becomes c...

Vulnerable code:
```\ncontract StableOracleWBTC is IStableOracle {\n    AggregatorV3Interface priceFeed;\n\n    constructor() {\n        priceFeed = AggregatorV3Interface(\n            0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419\n        );\n    }\n\n    function getPriceUSD() external view override returns (uint256) {\n        (\n           ,\n            int256 price,\n           ,\n           ,\n            ) = priceFeed.latestRoundData();\n        return uint256(price) * 1e10;\n    }\n}\n```