Farseen0/scar-pairs huggingface dataset:
MEDIUM severity: Vulnerable function: ```\n  function testBasicPublicVaultLoan() public {\n\n  IAstariaRouter.LienDetails memory standardL. ```\n  function testBasicPublicVaultLoan() public {\n\n  IAstariaRouter.LienDetails memory standardLien2 =\n    IAstariaRouter.LienDetails({\n      maxAmount: 50 ether,\n      rate: (uint256(1e16) * 150) / (365 days),\n      duration: 50 days,  /****** more then 14 * 2 *******/\n      maxPotentialDe

Vulnerable code:
```\n  function testBasicPublicVaultLoan() public {\n\n  IAstariaRouter.LienDetails memory standardLien2 =\n    IAstariaRouter.LienDetails({\n      maxAmount: 50 ether,\n      rate: (uint256(1e16) * 150) / (365 days),\n      duration: 50 days,  /****** more then 14 * 2 *******/\n      maxPotentialDebt: 50 ether\n    });    \n\n    _commitToLien({\n      vault: publicVault,\n      strategist: strategistOne,\n      strategistPK: strategistOnePK,\n      tokenContract: tokenContract,\n      tokenId: tokenId,\n      lienDetails: standardLien2, /**** use standardLien2 ****/\n      amount: 10 ether,\n      isFirstLien: true\n    });\n  }\n```\n
MEDIUM severity: Vulnerable function: ```\n_tradeAmounts[i] = IERC20(_tradeAssets[i]).balanceOf(address(this)); \n_len. ```\n_tradeAmounts[i] = IERC20(_tradeAssets[i]).balanceOf(address(this)); \n_lendingPoolDeposit(_tradeAssets[i], _tradeAmounts[i], 1); \n```\n

Vulnerable code:
```\n_tradeAmounts[i] = IERC20(_tradeAssets[i]).balanceOf(address(this)); \n_lendingPoolDeposit(_tradeAssets[i], _tradeAmounts[i], 1); \n```\n
MEDIUM severity: Vulnerable function: ```\npartyAAvailableBalance = freeBalance + upnl + unlockedAmount = -5\n```\n. ```\npartyAAvailableBalance = freeBalance + upnl + unlockedAmount = -5\n```\n

Vulnerable code:
```\npartyAAvailableBalance = freeBalance + upnl + unlockedAmount = -5\n```\n
MEDIUM severity: Vulnerable function: ```\n    function _transferTokenInAndApprove(\n        address router,\n        IERC20 tokenIn,\n   . ```\n    function _transferTokenInAndApprove(\n        address router,\n        IERC20 tokenIn,\n        uint256 amount\n    )\n        internal\n    {\n        tokenIn.safeTransferFrom(_msgSender(), address(this), amount);\n//@ The check of allowance is useless, we should check the allowance from a

Vulnerable code:
```\n    function _transferTokenInAndApprove(\n        address router,\n        IERC20 tokenIn,\n        uint256 amount\n    )\n        internal\n    {\n        tokenIn.safeTransferFrom(_msgSender(), address(this), amount);\n//@ The check of allowance is useless, we should check the allowance from address(this) rather than the msgSender\n        if (tokenIn.allowance(_msgSender(), router) < amount) {\n            tokenIn.forceApprove(router, amount);\n        }\n    }\n```\n
HIGH severity: Vulnerable function: ```\nfunction _deleteLienPosition(uint256 collateralId, uint256 position) public {\n  uint256[] stor. ```\nfunction _deleteLienPosition(uint256 collateralId, uint256 position) public {\n  uint256[] storage stack = liens[collateralId];\n  require(position < stack.length, "index out of bounds");\n\n  emit RemoveLien(\n    stack[position],\n    lienData[stack[position]].collateralId,\n    lienData[stac

Vulnerable code:
```\nfunction _deleteLienPosition(uint256 collateralId, uint256 position) public {\n  uint256[] storage stack = liens[collateralId];\n  require(position < stack.length, "index out of bounds");\n\n  emit RemoveLien(\n    stack[position],\n    lienData[stack[position]].collateralId,\n    lienData[stack[position]].position\n  );\n  for (uint256 i = position; i < stack.length - 1; i++) {\n    stack[i] = stack[i + 1];\n  }\n  stack.pop();\n}\n```\n
HIGH severity: Vulnerable function: ```\nfunction depositTo(address to, uint256 tokenAmount)\n    external\n    override\n    returns (u. ```\nfunction depositTo(address to, uint256 tokenAmount)\n    external\n    override\n    returns (uint256)\n{\n    require(tokenAmount > 0, "Pod:invalid-amount");\n\n    // Allocate Shares from Deposit To Amount\n    uint256 shares = \_deposit(to, tokenAmount);\n\n    // Transfer Token Transfer Mes

Vulnerable code:
```\nfunction depositTo(address to, uint256 tokenAmount)\n    external\n    override\n    returns (uint256)\n{\n    require(tokenAmount > 0, "Pod:invalid-amount");\n\n    // Allocate Shares from Deposit To Amount\n    uint256 shares = \_deposit(to, tokenAmount);\n\n    // Transfer Token Transfer Message Sender\n    IERC20Upgradeable(token).transferFrom(\n        msg.sender,\n        address(this),\n        tokenAmount\n    );\n\n    // Emit Deposited\n    emit Deposited(to, tokenAmount, shares);\n\n    // Return Shares Minted\n    return shares;\n}\n```\n
HIGH severity: Vulnerable function: ```\nif (fee > 0) {\n    reserve.transfer(\_collateral, beneficiary, fee);\n}\n`. ```\nif (fee > 0) {\n    reserve.transfer(\_collateral, beneficiary, fee);\n}\n```\n

Vulnerable code:
```\nif (fee > 0) {\n    reserve.transfer(\_collateral, beneficiary, fee);\n}\n```\n
HIGH severity: Vulnerable function: ```\nconstructor () public {\n  lootBoxActionInstance = new LootBox();\n  lootBo. ```\nconstructor () public {\n  lootBoxActionInstance = new LootBox();\n  lootBoxActionBytecode = MinimalProxyLibrary.minimalProxy(address(lootBoxActionInstance));\n}\n```\n

Vulnerable code:
```\nconstructor () public {\n  lootBoxActionInstance = new LootBox();\n  lootBoxActionBytecode = MinimalProxyLibrary.minimalProxy(address(lootBoxActionInstance));\n}\n```\n
MEDIUM severity: Vulnerable function: ```\nif (amount > currentBalance) {\n    // Calculate Withdrawl Amount\n    uint. ```\nif (amount > currentBalance) {\n    // Calculate Withdrawl Amount\n    uint256 \_withdraw = amount.sub(currentBalance);\n\n    // Withdraw from Prize Pool\n    uint256 exitFee = \_withdrawFromPool(\_withdraw);\n\n    // Add Exit Fee to Withdrawl Amount\n    amount = amount.sub(exitFee);\n}\n```

Vulnerable code:
```\nif (amount > currentBalance) {\n    // Calculate Withdrawl Amount\n    uint256 \_withdraw = amount.sub(currentBalance);\n\n    // Withdraw from Prize Pool\n    uint256 exitFee = \_withdrawFromPool(\_withdraw);\n\n    // Add Exit Fee to Withdrawl Amount\n    amount = amount.sub(exitFee);\n}\n```\n
HIGH severity: Vulnerable function: ```\n    function claimable(uint256 categoryId, uint256 vestingId, address user)\n        public\n  . ```\n    function claimable(uint256 categoryId, uint256 vestingId, address user)\n        public\n        view\n        returns (uint256 claimableAmount)\n    {\n        UserVesting memory userVesting = userVestings[categoryId][vestingId][user];\n\n        VestingInfo memory info = vestingInfos[cate

Vulnerable code:
```\n    function claimable(uint256 categoryId, uint256 vestingId, address user)\n        public\n        view\n        returns (uint256 claimableAmount)\n    {\n        UserVesting memory userVesting = userVestings[categoryId][vestingId][user];\n\n        VestingInfo memory info = vestingInfos[categoryId][vestingId];\n\n        uint64 startTime = userVesting.startTime + info.initialReleasePeriod;\n\n        if (startTime > block.timestamp) {\n            return 0;\n        }\n\n        uint256 totalAmount = userVesting.amount;\n\n        uint256 initialRelease = (totalAmount * info.initialReleasePct) / DENOMINATOR;\n\n        startTime += info.cliff;\n\n        if (startTime > block.timestamp) {\n            return initialRelease;\n        }\n```\n
MEDIUM severity: Vulnerable function: ```\nfunction test_Adjusting_I_CanBeFrontrunned() external {\n        vm.startPrank(tapir);\n\n     . ```\nfunction test_Adjusting_I_CanBeFrontrunned() external {\n        vm.startPrank(tapir);\n\n        //  Buy shares with tapir, 10 - 10\n        dai.safeTransfer(address(gsp), 10 * 1e18);\n        usdc.transfer(address(gsp), 10 * 1e6);\n        gsp.buyShares(tapir);\n\n        // print some stuff\

Vulnerable code:
```\nfunction test_Adjusting_I_CanBeFrontrunned() external {\n        vm.startPrank(tapir);\n\n        //  Buy shares with tapir, 10 - 10\n        dai.safeTransfer(address(gsp), 10 * 1e18);\n        usdc.transfer(address(gsp), 10 * 1e6);\n        gsp.buyShares(tapir);\n\n        // print some stuff\n        console.log("Base target initial", gsp._BASE_TARGET_());\n        console.log("Quote target initial", gsp._QUOTE_TARGET_());\n        console.log("Base reserve initial", gsp._BASE_RESERVE_());\n        console.log("Quote reserve initial", gsp._QUOTE_RESERVE_());\n        \n        // we know the price will decrease so lets sell the base token before that\n        uint256 initialBaseTokensSwapped = 5 * 1e18;\n\n        // sell the base tokens before adjustPrice\n        dai.safeTransfer(address(gsp), initialBaseTokensSwapped);\n        uint256 receivedQuoteTokens = gsp.sellBase(tapir);\n        vm.stopPrank();\n\n        // this is the tx will be sandwiched by the MEV trader\n        vm.prank(MAINTAINER);\n        gsp.adjustPrice(999000);\n\n        // quickly resell whatever gained by the price update\n        vm.startPrank(tapir);\n        usdc.safeTransfer(address(gsp), receivedQuoteTokens);\n        uint256 receivedBaseTokens = gsp.sellQuote(tapir);\n        console.log("Base target", gsp._BASE_TARGET_());\n        console.log("Quote target", gsp._QUOTE_TARGET_());\n        console.log("Base reserve", gsp._BASE_RESERVE_());\n        console.log("Quote reserve", gsp._QUOTE_RESERVE_());\n        console.log("Received base tokens", receivedBaseTokens);\n\n        // NOTE: the LP fee and MT FEE is set for this example, so this is not an rough assumption\n        // where fees are 0. Here the fees set for both of the values (default values):\n        // uint256 constant LP_FEE_RATE = 10000000000000;\n        // uint256 constant MT_FEE_RATE = 10000000000000;\n\n        // whatever we get is more than we started, in this example\n        // MEV trader started 5 DAI and we have more than 5 DAI!!\n        assertGe(receivedBaseTokens, initialBaseTokensSwapped);\n    }\n```\n
MEDIUM severity: Vulnerable function: ```\nfunction verifyCallback(SwapperFactory factory_, SwapperImpl swapper_) internal view returns (b. ```\nfunction verifyCallback(SwapperFactory factory_, SwapperImpl swapper_) internal view returns (bool valid) {\n    return factory_.isSwapper(swapper_);\n}\n```\n

Vulnerable code:
```\nfunction verifyCallback(SwapperFactory factory_, SwapperImpl swapper_) internal view returns (bool valid) {\n    return factory_.isSwapper(swapper_);\n}\n```\n
HIGH severity: Vulnerable function: ```\n  function redeemFutureEpoch(\n    uint256 shares,\n    address receiver,\n    address owner,\n. ```\n  function redeemFutureEpoch(\n    uint256 shares,\n    address receiver,\n    address owner,\n    uint64 epoch\n  ) public virtual returns (uint256 assets) {\n    // check to ensure that the requested epoch is not the current epoch or in the past\n    require(epoch >= currentEpoch, "Exit epoch

Vulnerable code:
```\n  function redeemFutureEpoch(\n    uint256 shares,\n    address receiver,\n    address owner,\n    uint64 epoch\n  ) public virtual returns (uint256 assets) {\n    // check to ensure that the requested epoch is not the current epoch or in the past\n    require(epoch >= currentEpoch, "Exit epoch too low");\n\n\n    require(msg.sender == owner, "Only the owner can redeem");\n    // check for rounding error since we round down in previewRedeem.\n\n\n    ERC20(address(this)).safeTransferFrom(owner, address(this), shares);\n\n\n    // Deploy WithdrawProxy if no WithdrawProxy exists for the specified epoch\n    _deployWithdrawProxyIfNotDeployed(epoch);\n\n\n    emit Withdraw(msg.sender, receiver, owner, assets, shares);\n\n\n    // WithdrawProxy shares are minted 1:1 with PublicVault shares\n    WithdrawProxy(withdrawProxies[epoch]).mint(receiver, shares); // was withdrawProxies[withdrawEpoch]\n  }\n```\n
MEDIUM severity: Vulnerable function: ```\n        if (userTier == 0 && giftedTierAllc == 0) {\n            return 0;\. ```\n        if (userTier == 0 && giftedTierAllc == 0) {\n            return 0;\n        }\n```\n

Vulnerable code:
```\n        if (userTier == 0 && giftedTierAllc == 0) {\n            return 0;\n        }\n```\n
HIGH severity: Vulnerable function: ```\naddress \_currentAddr = withdrawalQueue.head();\nuint256 \_tokensToWithdraw. ```\naddress \_currentAddr = withdrawalQueue.head();\nuint256 \_tokensToWithdraw = withdrawalsInfo[\_currentAddr].withdrawalAmount;\n \nuint256 \_amountInDAI = convertDAIXtoDAI(\_tokensToWithdraw);\n \nif (\_availableLiquidity < \_amountInDAI) {\n  break;\n}\n```\n

Vulnerable code:
```\naddress \_currentAddr = withdrawalQueue.head();\nuint256 \_tokensToWithdraw = withdrawalsInfo[\_currentAddr].withdrawalAmount;\n \nuint256 \_amountInDAI = convertDAIXtoDAI(\_tokensToWithdraw);\n \nif (\_availableLiquidity < \_amountInDAI) {\n  break;\n}\n```\n
HIGH severity: Vulnerable function: ```\nuint256 refundAmount = \_arcAmount.sub(total\_cost);\nif (refundAmount > 0). ```\nuint256 refundAmount = \_arcAmount.sub(total\_cost);\nif (refundAmount > 0) {\n  arcadeumCoin.safeTransferFrom(address(this), \_recipient, arcadeumCoinID, refundAmount, "");\n}\n\n// Mint tokens to recipient\nfactoryManager.batchMint(\_recipient, \_ids, amounts\_to\_mint, "");\n```\n

Vulnerable code:
```\nuint256 refundAmount = \_arcAmount.sub(total\_cost);\nif (refundAmount > 0) {\n  arcadeumCoin.safeTransferFrom(address(this), \_recipient, arcadeumCoinID, refundAmount, "");\n}\n\n// Mint tokens to recipient\nfactoryManager.batchMint(\_recipient, \_ids, amounts\_to\_mint, "");\n```\n
HIGH severity: Vulnerable function: ```\nuint amountOperatorTokens = moduleCall(address(exchangeRatePolicy), abi.enc. ```\nuint amountOperatorTokens = moduleCall(address(exchangeRatePolicy), abi.encodeWithSelector(exchangeRatePolicy.operatorTokenToDataInverse.selector, amountDataWei));\n```\n

Vulnerable code:
```\nuint amountOperatorTokens = moduleCall(address(exchangeRatePolicy), abi.encodeWithSelector(exchangeRatePolicy.operatorTokenToDataInverse.selector, amountDataWei));\n```\n
MEDIUM severity: Vulnerable function: ```\nfunction commitClaim(address claimer, uint256 claimAmount)\n  external \n  override\n  onlyClai. ```\nfunction commitClaim(address claimer, uint256 claimAmount)\n  external \n  override\n  onlyClaimVoting\n  updateBMIDAIXStakingReward\n{\n  PolicyHolder storage holder = policyHolders[claimer];\n\n  epochAmounts[holder.endEpochNumber] = epochAmounts[holder.endEpochNumber].sub(holder.coverTokens)

Vulnerable code:
```\nfunction commitClaim(address claimer, uint256 claimAmount)\n  external \n  override\n  onlyClaimVoting\n  updateBMIDAIXStakingReward\n{\n  PolicyHolder storage holder = policyHolders[claimer];\n\n  epochAmounts[holder.endEpochNumber] = epochAmounts[holder.endEpochNumber].sub(holder.coverTokens);\n  totalLiquidity = totalLiquidity.sub(claimAmount);\n \n  daiToken.transfer(claimer, claimAmount);\n                 \n  delete policyHolders[claimer];\n  policyRegistry.removePolicy(claimer);\n}\n```\n
HIGH severity: Vulnerable function: ```\n    function getTokenVotingPower(uint _tokenId) public override view returns (uint) {\n      if. ```\n    function getTokenVotingPower(uint _tokenId) public override view returns (uint) {\n      if (ownerOf(_tokenId) == address(0)) revert NonExistentToken();\n\n      // If tokenId < 10000, it's a FrankenPunk, so 100/100 = a multiplier of 1\n      uint multiplier = _tokenId < 10_000 ? PERCENT : 

Vulnerable code:
```\n    function getTokenVotingPower(uint _tokenId) public override view returns (uint) {\n      if (ownerOf(_tokenId) == address(0)) revert NonExistentToken();\n\n      // If tokenId < 10000, it's a FrankenPunk, so 100/100 = a multiplier of 1\n      uint multiplier = _tokenId < 10_000 ? PERCENT : monsterMultiplier;\n      \n      // evilBonus will return 0 for all FrankenMonsters, as they are not eligible for the evil bonus\n      return ((baseVotes * multiplier) / PERCENT) + stakedTimeBonus[_tokenId] + evilBonus(_tokenId);\n    }\n```\n
HIGH severity: Vulnerable function: ```\nuint256 maxPrice = curPrice +\n ((curPrice \*\n self.PERIOD\_PRICE\_INCREAS. ```\nuint256 maxPrice = curPrice +\n ((curPrice \*\n self.PERIOD\_PRICE\_INCREASE\_LIMIT \*\n \_periodsSinceUpdate) / PERCENTAGE\_DENOMINATOR);\n\nuint256 minPrice = curPrice -\n ((curPrice \*\n self.PERIOD\_PRICE\_DECREASE\_LIMIT \*\n \_periodsSinceUpdate) / PERCENTAGE\_DENOMINATOR);\n\nrequire(\n 

Vulnerable code:
```\nuint256 maxPrice = curPrice +\n ((curPrice \*\n self.PERIOD\_PRICE\_INCREASE\_LIMIT \*\n \_periodsSinceUpdate) / PERCENTAGE\_DENOMINATOR);\n\nuint256 minPrice = curPrice -\n ((curPrice \*\n self.PERIOD\_PRICE\_DECREASE\_LIMIT \*\n \_periodsSinceUpdate) / PERCENTAGE\_DENOMINATOR);\n\nrequire(\n \_newPrice >= minPrice && \_newPrice <= maxPrice,\n "OracleUtils: price is insane"\n```\n
HIGH severity: Vulnerable function: ```\nfunction _mintShares(\n    address to,\n    uint256 id,\n    uint256 amount\n) internal {\n    . ```\nfunction _mintShares(\n    address to,\n    uint256 id,\n    uint256 amount\n) internal {\n    _mint(to, id, amount, EMPTY);\n    _mintEmissions(to, id, amount);\n}\n```\n

Vulnerable code:
```\nfunction _mintShares(\n    address to,\n    uint256 id,\n    uint256 amount\n) internal {\n    _mint(to, id, amount, EMPTY);\n    _mintEmissions(to, id, amount);\n}\n```\n
HIGH severity: Vulnerable function: ```\naddress sender = \_hashPrimaryTypedData(\n \_hashTypedData(\n nonce,\n to,\. ```\naddress sender = \_hashPrimaryTypedData(\n \_hashTypedData(\n nonce,\n to,\n data\n )\n).recoverAddress(senderSignature);\n```\n

Vulnerable code:
```\naddress sender = \_hashPrimaryTypedData(\n \_hashTypedData(\n nonce,\n to,\n data\n )\n).recoverAddress(senderSignature);\n```\n
MEDIUM severity: Vulnerable function: ```\n    marketCollateral = marketContext.margin\n        .add(collateral.sub(to. ```\n    marketCollateral = marketContext.margin\n        .add(collateral.sub(totalMargin).mul(marketContext.registration.weight));\n\n    UFixed6 marketAssets = assets\n        .mul(marketContext.registration.weight)\n        .min(marketCollateral.mul(LEVERAGE_BUFFER));\n```\n

Vulnerable code:
```\n    marketCollateral = marketContext.margin\n        .add(collateral.sub(totalMargin).mul(marketContext.registration.weight));\n\n    UFixed6 marketAssets = assets\n        .mul(marketContext.registration.weight)\n        .min(marketCollateral.mul(LEVERAGE_BUFFER));\n```\n
MEDIUM severity: Vulnerable function: ```\n    function doCutRewardsFee(address token) internal {\n        if (bank.config().treasury() ==. ```\n    function doCutRewardsFee(address token) internal {\n        if (bank.config().treasury() == address(0)) revert NO_TREASURY_SET();\n\n\n        uint256 balance = IERC20Upgradeable(token).balanceOf(address(this));\n        if (balance > 0) {\n            uint256 fee = (balance * bank.config()

Vulnerable code:
```\n    function doCutRewardsFee(address token) internal {\n        if (bank.config().treasury() == address(0)) revert NO_TREASURY_SET();\n\n\n        uint256 balance = IERC20Upgradeable(token).balanceOf(address(this));\n        if (balance > 0) {\n            uint256 fee = (balance * bank.config().depositFee()) / DENOMINATOR;\n            IERC20Upgradeable(token).safeTransfer(\n                bank.config().treasury(),\n                fee\n            );\n\n\n            balance -= fee;\n            IERC20Upgradeable(token).safeTransfer(bank.EXECUTOR(), balance);\n        }\n    }\n```\n
MEDIUM severity: Vulnerable function: ```\nfunction claim(\n    address beneficiary // the address that will receive tokens\n  ) external . ```\nfunction claim(\n    address beneficiary // the address that will receive tokens\n  ) external validSaleParticipant(beneficiary) nonReentrant {\n    uint256 claimableAmount = getClaimableAmount(beneficiary);\n    uint256 purchasedAmount = getPurchasedAmount(beneficiary);\n\n    // effects\n    

Vulnerable code:
```\nfunction claim(\n    address beneficiary // the address that will receive tokens\n  ) external validSaleParticipant(beneficiary) nonReentrant {\n    uint256 claimableAmount = getClaimableAmount(beneficiary);\n    uint256 purchasedAmount = getPurchasedAmount(beneficiary);\n\n    // effects\n    uint256 claimedAmount = super._executeClaim(beneficiary, purchasedAmount);\n\n    // interactions\n    super._settleClaim(beneficiary, claimedAmount);\n  }\n```\n
HIGH severity: Vulnerable function: ```\nFile: LMPVault.sol\n    function totalAssets() public view override returns (uint256) {\n      . ```\nFile: LMPVault.sol\n    function totalAssets() public view override returns (uint256) {\n        return totalIdle + totalDebt;\n    }\n```\n

Vulnerable code:
```\nFile: LMPVault.sol\n    function totalAssets() public view override returns (uint256) {\n        return totalIdle + totalDebt;\n    }\n```\n
MEDIUM severity: Vulnerable function: ```\n      id = connext.xcall(            // <------ relayer fee should be payed. ```\n      id = connext.xcall(            // <------ relayer fee should be payed here\n        _recipientDomain, // destination domain\n        _recipient, // to\n        address(token), // asset\n        _recipient, // delegate, only required for self-execution + slippage\n        _amount, // amoun

Vulnerable code:
```\n      id = connext.xcall(            // <------ relayer fee should be payed here\n        _recipientDomain, // destination domain\n        _recipient, // to\n        address(token), // asset\n        _recipient, // delegate, only required for self-execution + slippage\n        _amount, // amount\n        0, // slippage -- assumes no pools on connext\n        bytes('') // calldata\n      );\n```\n
MEDIUM severity: Vulnerable function: ```\n  modifier whenNotPaused() {\n    _whenNotPaused();\n    _;\n  }\n```\n. ```\n  modifier whenNotPaused() {\n    _whenNotPaused();\n    _;\n  }\n```\n

Vulnerable code:
```\n  modifier whenNotPaused() {\n    _whenNotPaused();\n    _;\n  }\n```\n
HIGH severity: Vulnerable function: ```\nFile: Stable2TokenOracleMath.sol\nlibrary Stable2TokenOracleMath {\n    using TypeConvert for i. ```\nFile: Stable2TokenOracleMath.sol\nlibrary Stable2TokenOracleMath {\n    using TypeConvert for int256;\n    using Stable2TokenOracleMath for StableOracleContext;\n\n    function _getSpotPrice(\n        StableOracleContext memory oracleContext, \n        TwoTokenPoolContext memory poolContext, \n

Vulnerable code:
```\nFile: Stable2TokenOracleMath.sol\nlibrary Stable2TokenOracleMath {\n    using TypeConvert for int256;\n    using Stable2TokenOracleMath for StableOracleContext;\n\n    function _getSpotPrice(\n        StableOracleContext memory oracleContext, \n        TwoTokenPoolContext memory poolContext, \n        uint256 primaryBalance,\n        uint256 secondaryBalance,\n        uint256 tokenIndex\n    ) internal view returns (uint256 spotPrice) {\n        require(tokenIndex < 2); /// @dev invalid token index\n\n        /// Apply scale factors\n        uint256 scaledPrimaryBalance = primaryBalance * poolContext.primaryScaleFactor \n            / BalancerConstants.BALANCER_PRECISION;\n        uint256 scaledSecondaryBalance = secondaryBalance * poolContext.secondaryScaleFactor \n            / BalancerConstants.BALANCER_PRECISION;\n\n        /// @notice poolContext balances are always in BALANCER_PRECISION (1e18)\n        (uint256 balanceX, uint256 balanceY) = tokenIndex == 0 ?\n            (scaledPrimaryBalance, scaledSecondaryBalance) :\n            (scaledSecondaryBalance, scaledPrimaryBalance);\n\n        uint256 invariant = StableMath._calculateInvariant(\n            oracleContext.ampParam, StableMath._balances(balanceX, balanceY), true // round up\n        );\n\n        spotPrice = StableMath._calcSpotPrice({\n            amplificationParameter: oracleContext.ampParam,\n            invariant: invariant,\n            balanceX: balanceX, \n            balanceY: balanceY\n        });\n\n        /// Apply secondary scale factor in reverse\n        uint256 scaleFactor = tokenIndex == 0 ?\n            poolContext.secondaryScaleFactor * BalancerConstants.BALANCER_PRECISION / poolContext.primaryScaleFactor :\n            poolContext.primaryScaleFactor * BalancerConstants.BALANCER_PRECISION / poolContext.secondaryScaleFactor;\n        spotPrice = spotPrice * BalancerConstants.BALANCER_PRECISION / scaleFactor;\n    }\n```\n