Farseen0/scar-pairs huggingface dataset:
HIGH severity: Vulnerable function: ```\nfunction pauseCollateralType(\n    address _collateralAddress,\n    bytes32 _currencyKey\n    ). ```\nfunction pauseCollateralType(\n    address _collateralAddress,\n    bytes32 _currencyKey\n    ) external collateralExists(_collateralAddress) onlyAdmin {\n    require(_collateralAddress != address(0)); //this should get caught by the collateralExists check but just to be careful\n    //checks t

Vulnerable code:
```\nfunction pauseCollateralType(\n    address _collateralAddress,\n    bytes32 _currencyKey\n    ) external collateralExists(_collateralAddress) onlyAdmin {\n    require(_collateralAddress != address(0)); //this should get caught by the collateralExists check but just to be careful\n    //checks two inputs to help prevent input mistakes\n    require( _currencyKey == collateralProps[_collateralAddress].currencyKey, "Mismatched data");\n    collateralValid[_collateralAddress] = false;\n    collateralPaused[_collateralAddress] = true;\n}\n```\n
MEDIUM severity: Vulnerable function: ```\nuint32 timeElapsed = blockTimestamp - blockTimestampLast; // overflow is de. ```\nuint32 timeElapsed = blockTimestamp - blockTimestampLast; // overflow is desired\nif (timeElapsed > 0 && _reserve0 != 0 && _reserve1 != 0) {\n    // * never overflows, and + overflow is desired\n    price0CumulativeLast += uint256(UQ112x112.encode(_reserve1).uqdiv(_reserve0)) * timeElapsed;\n  

Vulnerable code:
```\nuint32 timeElapsed = blockTimestamp - blockTimestampLast; // overflow is desired\nif (timeElapsed > 0 && _reserve0 != 0 && _reserve1 != 0) {\n    // * never overflows, and + overflow is desired\n    price0CumulativeLast += uint256(UQ112x112.encode(_reserve1).uqdiv(_reserve0)) * timeElapsed;\n    price1CumulativeLast += uint256(UQ112x112.encode(_reserve0).uqdiv(_reserve1)) * timeElapsed;\n}\n```\n
MEDIUM severity: Vulnerable function: ```\nfunction liquidate(\n        address account,\n        IProduct product\n    ) external nonReen. ```\nfunction liquidate(\n        address account,\n        IProduct product\n    ) external nonReentrant notPaused isProduct(product) settleForAccount(account, product) {\n        if (product.isLiquidating(account)) revert CollateralAccountLiquidatingError(account);\n\n        UFixed18 totalMainten

Vulnerable code:
```\nfunction liquidate(\n        address account,\n        IProduct product\n    ) external nonReentrant notPaused isProduct(product) settleForAccount(account, product) {\n        if (product.isLiquidating(account)) revert CollateralAccountLiquidatingError(account);\n\n        UFixed18 totalMaintenance = product.maintenance(account); maintenance?\n        UFixed18 totalCollateral = collateral(account, product); \n\n        if (!totalMaintenance.gt(totalCollateral))\n            revert CollateralCantLiquidate(totalMaintenance, totalCollateral);\n\n        product.closeAll(account);\n\n        // claim fee\n        UFixed18 liquidationFee = controller().liquidationFee();\n      \n        UFixed18 collateralForFee = UFixed18Lib.max(totalMaintenance, controller().minCollateral()); \n        UFixed18 fee = UFixed18Lib.min(totalCollateral, collateralForFee.mul(liquidationFee)); \n\n        _products[product].debitAccount(account, fee); \n        token.push(msg.sender, fee);\n\n        emit Liquidation(account, product, msg.sender, fee);\n    }\n```\n
MEDIUM severity: Vulnerable function: ```\nif (BBTotSupply == 0) {\n  // if there are no BB holders, all gain to AA\n . ```\nif (BBTotSupply == 0) {\n  // if there are no BB holders, all gain to AA\n  AAGain = gain;\n} else if (AATotSupply == 0) {\n  // if there are no AA holders, all gain to BB\n  BBGain = gain;\n} else {\n  // split the gain between AA and BB holders according to trancheAPRSplitRatio\n  AAGain = ga

Vulnerable code:
```\nif (BBTotSupply == 0) {\n  // if there are no BB holders, all gain to AA\n  AAGain = gain;\n} else if (AATotSupply == 0) {\n  // if there are no AA holders, all gain to BB\n  BBGain = gain;\n} else {\n  // split the gain between AA and BB holders according to trancheAPRSplitRatio\n  AAGain = gain \* trancheAPRSplitRatio / FULL\_ALLOC;\n  BBGain = gain - AAGain;\n}\n```\n
MEDIUM severity: Vulnerable function: ```\n        for (uint i; i < _statuses.length; ) {\n             whitelistedRou. ```\n        for (uint i; i < _statuses.length; ) {\n             whitelistedRouters[_routers[i]] = _statuses[i];\n                 if (_statuses[i]) {\n                 routerTypes[_routers[i]] = _types[i];\n        emit SetRouterType(_routers[i], _types[i]);\n        }\n              emit SetWhite

Vulnerable code:
```\n        for (uint i; i < _statuses.length; ) {\n             whitelistedRouters[_routers[i]] = _statuses[i];\n                 if (_statuses[i]) {\n                 routerTypes[_routers[i]] = _types[i];\n        emit SetRouterType(_routers[i], _types[i]);\n        }\n              emit SetWhitelistedRouter(_routers[i], _statuses[i]);\n           unchecked {\n        ++i;\n        }\n        }\n```\n
MEDIUM severity: Vulnerable function: ```\nFile: SFrxETHAdapter.sol\n/// @title SFrxETHAdapter - esfrxETH\n/// @dev Im. ```\nFile: SFrxETHAdapter.sol\n/// @title SFrxETHAdapter - esfrxETH\n/// @dev Important security note:\n/// 1. The vault share price (esfrxETH / WETH) increases as sfrxETH accrues staking rewards.\n/// However, the share price decreases when frxETH (sfrxETH) is withdrawn.\n/// Withdrawals are proces

Vulnerable code:
```\nFile: SFrxETHAdapter.sol\n/// @title SFrxETHAdapter - esfrxETH\n/// @dev Important security note:\n/// 1. The vault share price (esfrxETH / WETH) increases as sfrxETH accrues staking rewards.\n/// However, the share price decreases when frxETH (sfrxETH) is withdrawn.\n/// Withdrawals are processed by the FraxEther redemption queue contract.\n/// Frax takes a fee at the time of withdrawal requests, which temporarily reduces the share price.\n/// This loss is pro-rated among all esfrxETH holders.\n/// As a mitigation measure, we allow only authorized rebalancers to request withdrawals.\n///\n/// 2. This contract doesn't independently keep track of the sfrxETH balance, so it is possible\n/// for an attacker to directly transfer sfrxETH to this contract, increase the share price.\ncontract SFrxETHAdapter is BaseLSTAdapter, IERC721Receiver {\n```\n
HIGH severity: Vulnerable function: ```\nfunction confiscate(uint validatorId, uint amount) external {\n    uint currentMonth = getCurre. ```\nfunction confiscate(uint validatorId, uint amount) external {\n    uint currentMonth = getCurrentMonth();\n    Fraction memory coefficient = reduce(\_delegatedToValidator[validatorId], amount, currentMonth);\n    reduce(\_effectiveDelegatedToValidator[validatorId], coefficient, currentMonth);\n

Vulnerable code:
```\nfunction confiscate(uint validatorId, uint amount) external {\n    uint currentMonth = getCurrentMonth();\n    Fraction memory coefficient = reduce(\_delegatedToValidator[validatorId], amount, currentMonth);\n    reduce(\_effectiveDelegatedToValidator[validatorId], coefficient, currentMonth);\n    putToSlashingLog(\_slashesOfValidator[validatorId], coefficient, currentMonth);\n    \_slashes.push(SlashingEvent({reducingCoefficient: coefficient, validatorId: validatorId, month: currentMonth}));\n}\n```\n
MEDIUM severity: Vulnerable function: ```\nif (block.timestamp < uint256(epochStart)) revert EpochNotStarted();\n```\n. ```\nif (block.timestamp < uint256(epochStart)) revert EpochNotStarted();\n```\n

Vulnerable code:
```\nif (block.timestamp < uint256(epochStart)) revert EpochNotStarted();\n```\n
MEDIUM severity: Vulnerable function: ```\nfunction deposit(address to) external override lock returns (uint256 amountBaseOut) {\n    requ. ```\nfunction deposit(address to) external override lock returns (uint256 amountBaseOut) {\n    require(msg.sender == router, 'DAOfiV1: FORBIDDEN\_DEPOSIT');\n```\n

Vulnerable code:
```\nfunction deposit(address to) external override lock returns (uint256 amountBaseOut) {\n    require(msg.sender == router, 'DAOfiV1: FORBIDDEN\_DEPOSIT');\n```\n
MEDIUM severity: Vulnerable function: ```\n    function unlock(ISetToken _setToken) external {\n        bool isRebalanceDurationElapsed = . ```\n    function unlock(ISetToken _setToken) external {\n        bool isRebalanceDurationElapsed = _isRebalanceDurationElapsed(_setToken);\n        bool canUnlockEarly = _canUnlockEarly(_setToken);\n\n        // Ensure that either the rebalance duration has elapsed or the conditions for early unloc

Vulnerable code:
```\n    function unlock(ISetToken _setToken) external {\n        bool isRebalanceDurationElapsed = _isRebalanceDurationElapsed(_setToken);\n        bool canUnlockEarly = _canUnlockEarly(_setToken);\n\n        // Ensure that either the rebalance duration has elapsed or the conditions for early unlock are met\n        require(isRebalanceDurationElapsed || canUnlockEarly, "Cannot unlock early unless all targets are met and raiseTargetPercentage is zero");\n\n        // If unlocking early, update the state\n        if (canUnlockEarly) {\n            delete rebalanceInfo[_setToken].rebalanceDuration;\n            emit LockedRebalanceEndedEarly(_setToken);\n        }\n\n        // Unlock the SetToken\n        _setToken.unlock();\n    }\n```\n
HIGH severity: Vulnerable function: ```\naddress public constant ETH = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;\n. ```\naddress public constant ETH = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;\n\n// rest of code\n\n// Only need ability to check for read-only reentrancy for pools containing native Eth.\nif (checkReentrancy) {\n    if (tokens[0] != ETH && tokens[1] != ETH) revert MustHaveEthForReentrancy();\n}\n`

Vulnerable code:
```\naddress public constant ETH = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;\n\n// rest of code\n\n// Only need ability to check for read-only reentrancy for pools containing native Eth.\nif (checkReentrancy) {\n    if (tokens[0] != ETH && tokens[1] != ETH) revert MustHaveEthForReentrancy();\n}\n```\n
MEDIUM severity: Vulnerable function: ```\nfunction pause() public onlyOwnerOrPauser {\n    _pause();\n}\n```\n. ```\nfunction pause() public onlyOwnerOrPauser {\n    _pause();\n}\n```\n

Vulnerable code:
```\nfunction pause() public onlyOwnerOrPauser {\n    _pause();\n}\n```\n
MEDIUM severity: Vulnerable function: ```\n            (\n                uint256[] memory minAmountsOut,\n           . ```\n            (\n                uint256[] memory minAmountsOut,\n                address[] memory tokens,\n                uint256 borrowTokenIndex\n            ) = _getExitPoolParams(param.borrowToken, lpToken);\n\n            wAuraPools.getVault(lpToken).exitPool(\n                IBalancerPoo

Vulnerable code:
```\n            (\n                uint256[] memory minAmountsOut,\n                address[] memory tokens,\n                uint256 borrowTokenIndex\n            ) = _getExitPoolParams(param.borrowToken, lpToken);\n\n            wAuraPools.getVault(lpToken).exitPool(\n                IBalancerPool(lpToken).getPoolId(),\n                address(this),\n                address(this),\n                IBalancerVault.ExitPoolRequest(\n                    tokens,\n                    minAmountsOut,\n                    abi.encode(0, amountPosRemove, borrowTokenIndex),\n                    false\n                )\n```\n
MEDIUM severity: Vulnerable function: ```\nif (maxLoanDur(fund) > 0) {\n    require(loanDur\_       <= maxLoanDur(fund. ```\nif (maxLoanDur(fund) > 0) {\n    require(loanDur\_       <= maxLoanDur(fund));\n} else {\n    require(now + loanDur\_ <= maxFundDur(fund));\n}\n```\n

Vulnerable code:
```\nif (maxLoanDur(fund) > 0) {\n    require(loanDur\_       <= maxLoanDur(fund));\n} else {\n    require(now + loanDur\_ <= maxFundDur(fund));\n}\n```\n
HIGH severity: Vulnerable function: ```\n constructor(address auctionHouse_) LinearVesting(auctionHouse_) BlastGas(a. ```\n constructor(address auctionHouse_) LinearVesting(auctionHouse_) BlastGas(auctionHouse_) {}\n```\n

Vulnerable code:
```\n constructor(address auctionHouse_) LinearVesting(auctionHouse_) BlastGas(auctionHouse_) {}\n```\n
MEDIUM severity: Vulnerable function: ```\n    2) Admin can configure new markets and epochs on those markets, Timeloc. ```\n    2) Admin can configure new markets and epochs on those markets, Timelock can make cirital changes like changing the oracle or whitelisitng controllers.\n```\n

Vulnerable code:
```\n    2) Admin can configure new markets and epochs on those markets, Timelock can make cirital changes like changing the oracle or whitelisitng controllers.\n```\n
HIGH severity: Vulnerable function: ```\n    function getPriceUSD() external view override returns (uint256) {\n        address[] memory. ```\n    function getPriceUSD() external view override returns (uint256) {\n        address[] memory pools = new address[](1);\n        pools[0] = 0x60594a405d53811d3BC4766596EFD80fd545A270;\n        uint256 DAIWethPrice = DAIEthOracle.quoteSpecificPoolsWithTimePeriod(\n            10000000000000000

Vulnerable code:
```\n    function getPriceUSD() external view override returns (uint256) {\n        address[] memory pools = new address[](1);\n        pools[0] = 0x60594a405d53811d3BC4766596EFD80fd545A270;\n        uint256 DAIWethPrice = DAIEthOracle.quoteSpecificPoolsWithTimePeriod(\n            1000000000000000000, // 1 Eth\n            0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2, // WETH (base token)\n            0x6B175474E89094C44Da98b954EedeAC495271d0F, // DAI (quote token)\n            pools, // DAI/WETH pool uni v3\n            600 // period\n        );\n\n        uint256 wethPriceUSD = ethOracle.getPriceUSD();\n\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        return (wethPriceUSD * 1e18) / ((DAIWethPrice + uint256(price) * 1e10) / 2);\n    }\n```\n
HIGH severity: Vulnerable function: ```\nuint oldValue = getAndUpdateDelegatedByHolderToValidator(holder, validatorI. ```\nuint oldValue = getAndUpdateDelegatedByHolderToValidator(holder, validatorId);\nif (oldValue > 0) {\n    uint month = \_slashes[index].month;\n    reduce(\n        \_delegatedByHolderToValidator[holder][validatorId],\n        \_delegatedByHolder[holder],\n        \_slashes[index].reducingCoeffi

Vulnerable code:
```\nuint oldValue = getAndUpdateDelegatedByHolderToValidator(holder, validatorId);\nif (oldValue > 0) {\n    uint month = \_slashes[index].month;\n    reduce(\n        \_delegatedByHolderToValidator[holder][validatorId],\n        \_delegatedByHolder[holder],\n        \_slashes[index].reducingCoefficient,\n        month);\n    slashingSignals[index.sub(begin)].holder = holder;\n    slashingSignals[index.sub(begin)].penalty = oldValue.sub(getAndUpdateDelegatedByHolderToValidator(holder, validatorId));\n}\n```\n
MEDIUM severity: Vulnerable function: ```\nfunction join(uint256 amount) external override joiningNotPaused {\n        uint256 fee = amoun. ```\nfunction join(uint256 amount) external override joiningNotPaused {\n        uint256 fee = amount.mul(joiningFee).div(BASIS_PRECISION);\n        uint256 mintedAmount = mint(amount.sub(fee));\n        claimableFees = claimableFees.add(fee);\n\n        // TODO: tx.origin will be deprecated in a fu

Vulnerable code:
```\nfunction join(uint256 amount) external override joiningNotPaused {\n        uint256 fee = amount.mul(joiningFee).div(BASIS_PRECISION);\n        uint256 mintedAmount = mint(amount.sub(fee));\n        claimableFees = claimableFees.add(fee);\n\n        // TODO: tx.origin will be deprecated in a future ethereum upgrade\n        latestJoinBlock[tx.origin] = block.number;\n        token.safeTransferFrom(msg.sender, address(this), amount);\n\n        emit Joined(msg.sender, amount, mintedAmount);\n    }\n```\n
HIGH severity: Vulnerable function: ```\n            if (rewardDebtDiff > userRewardDebts[msg.sender][rewardToken.to. ```\n            if (rewardDebtDiff > userRewardDebts[msg.sender][rewardToken.token]) {\n                userRewardDebts[msg.sender][rewardToken.token] = 0;\n                cachedUserRewards[msg.sender][rewardToken.token] +=\n                    rewardDebtDiff -\n                    userRewardDebts

Vulnerable code:
```\n            if (rewardDebtDiff > userRewardDebts[msg.sender][rewardToken.token]) {\n                userRewardDebts[msg.sender][rewardToken.token] = 0;\n                cachedUserRewards[msg.sender][rewardToken.token] +=\n                    rewardDebtDiff -\n                    userRewardDebts[msg.sender][rewardToken.token];\n            } else {\n                userRewardDebts[msg.sender][rewardToken.token] -= rewardDebtDiff;\n            }\n```\n
HIGH severity: Vulnerable function: ```\n function provideSecret(bytes32 sale, bytes32 secret\_) external {\n  require(sales[sale].set);. ```\n function provideSecret(bytes32 sale, bytes32 secret\_) external {\n  require(sales[sale].set);\n  if      (sha256(abi.encodePacked(secret\_)) == secretHashes[sale].secretHashA) { secretHashes[sale].secretA = secret\_; }\n        else if (sha256(abi.encodePacked(secret\_)) == secretHashes[sale]

Vulnerable code:
```\n function provideSecret(bytes32 sale, bytes32 secret\_) external {\n  require(sales[sale].set);\n  if      (sha256(abi.encodePacked(secret\_)) == secretHashes[sale].secretHashA) { secretHashes[sale].secretA = secret\_; }\n        else if (sha256(abi.encodePacked(secret\_)) == secretHashes[sale].secretHashB) { secretHashes[sale].secretB = secret\_; }\n        else if (sha256(abi.encodePacked(secret\_)) == secretHashes[sale].secretHashC) { secretHashes[sale].secretC = secret\_; }\n        else if (sha256(abi.encodePacked(secret\_)) == secretHashes[sale].secretHashD) { secretHashes[sale].secretD = secret\_; }\n        else                                                                          { revert(); }\n }\n```\n
MEDIUM severity: Vulnerable function: ```\nevent log(bytes32);\nevent log\_int(bytes32, int256);\nevent log\_ints(byte. ```\nevent log(bytes32);\nevent log\_int(bytes32, int256);\nevent log\_ints(bytes32, int256[]);\nevent log\_uint(bytes32, uint256);\nevent log\_uints(bytes32, uint256[]);\n```\n

Vulnerable code:
```\nevent log(bytes32);\nevent log\_int(bytes32, int256);\nevent log\_ints(bytes32, int256[]);\nevent log\_uint(bytes32, uint256);\nevent log\_uints(bytes32, uint256[]);\n```\n
HIGH severity: Vulnerable function: ```\n  function deposit(uint256 amount) external {\n    deposits[msg.sender] += amount; //@audit no . ```\n  function deposit(uint256 amount) external {\n    deposits[msg.sender] += amount; //@audit no need\n    _moveDelegates(address(0), delegates[msg.sender], amount);\n    SafeTransferLib.safeTransferFrom(locks, msg.sender, address(this), amount);\n    _mint(msg.sender, amount);\n  }\n\n  /// @not

Vulnerable code:
```\n  function deposit(uint256 amount) external {\n    deposits[msg.sender] += amount; //@audit no need\n    _moveDelegates(address(0), delegates[msg.sender], amount);\n    SafeTransferLib.safeTransferFrom(locks, msg.sender, address(this), amount);\n    _mint(msg.sender, amount);\n  }\n\n  /// @notice Withdraws Locks to burn Govlocks\n  /// @param amount Amount of Locks to withdraw\n  function withdraw(uint256 amount) external {\n    deposits[msg.sender] -= amount; //@audit no need\n    _moveDelegates(delegates[msg.sender], address(0), amount);\n    _burn(msg.sender, amount);\n    SafeTransferLib.safeTransfer(locks, msg.sender, amount);\n  }\n```\n
HIGH severity: Vulnerable function: ```\nuint256 constant g2\_srs\_0\_x\_0 = 115597320329863871079910040213922857839. ```\nuint256 constant g2\_srs\_0\_x\_0 = 11559732032986387107991004021392285783925812861821192530917403151452391805634;\nuint256 constant g2\_srs\_0\_x\_1 = 10857046999023057135944570762232829481370756359578518086990519993285655852781;\nuint256 constant g2\_srs\_0\_y\_0 = 408236787586343368133220340

Vulnerable code:
```\nuint256 constant g2\_srs\_0\_x\_0 = 11559732032986387107991004021392285783925812861821192530917403151452391805634;\nuint256 constant g2\_srs\_0\_x\_1 = 10857046999023057135944570762232829481370756359578518086990519993285655852781;\nuint256 constant g2\_srs\_0\_y\_0 = 4082367875863433681332203403145435568316851327593401208105741076214120093531;\nuint256 constant g2\_srs\_0\_y\_1 = 8495653923123431417604973247489272438418190587263600148770280649306958101930;\n\nuint256 constant g2\_srs\_1\_x\_0 = 18469474764091300207969441002824674761417641526767908873143851616926597782709;\nuint256 constant g2\_srs\_1\_x\_1 = 17691709543839494245591259280773972507311536864513996659348773884770927133474;\nuint256 constant g2\_srs\_1\_y\_0 = 2799122126101651639961126614695310298819570600001757598712033559848160757380;\nuint256 constant g2\_srs\_1\_y\_1 = 3054480525781015242495808388429905877188466478626784485318957932446534030175;\n```\n
HIGH severity: Vulnerable function: ```\n   if (block.timestamp <= lastProfitTime) {\n      revert NYProfitTakingVau. ```\n   if (block.timestamp <= lastProfitTime) {\n      revert NYProfitTakingVault__ProfitTimeOutOfBounds();\n      }\n```\n

Vulnerable code:
```\n   if (block.timestamp <= lastProfitTime) {\n      revert NYProfitTakingVault__ProfitTimeOutOfBounds();\n      }\n```\n
MEDIUM severity: Vulnerable function: ```\nFile: CrossCurrencyfCashVault.sol\n    /**\n     * @notice During settlement all of the fCash b. ```\nFile: CrossCurrencyfCashVault.sol\n    /**\n     * @notice During settlement all of the fCash balance in the lend currency will be redeemed to the\n     * underlying token and traded back to the borrow currency. All of the borrow currency will be deposited\n     * into the Notional contract as 

Vulnerable code:
```\nFile: CrossCurrencyfCashVault.sol\n    /**\n     * @notice During settlement all of the fCash balance in the lend currency will be redeemed to the\n     * underlying token and traded back to the borrow currency. All of the borrow currency will be deposited\n     * into the Notional contract as asset tokens and held for accounts to withdraw. Settlement can only\n     * be called after maturity.\n     * @param maturity the maturity to settle\n     * @param settlementTrade details for the settlement trade\n     */\n    function settleVault(uint256 maturity, uint256 strategyTokens, bytes calldata settlementTrade) external {\n        require(maturity <= block.timestamp, "Cannot Settle");\n        VaultState memory vaultState = NOTIONAL.getVaultState(address(this), maturity);\n        require(vaultState.isSettled == false);\n        require(vaultState.totalStrategyTokens >= strategyTokens);\n\n        RedeemParams memory params = abi.decode(settlementTrade, (RedeemParams));\n    \n        // The only way for underlying value to be negative would be if the vault has somehow ended up with a borrowing\n        // position in the lend underlying currency. This is explicitly prevented during redemption.\n        uint256 underlyingValue = convertStrategyToUnderlying(\n            address(0), vaultState.totalStrategyTokens, maturity\n        ).toUint();\n\n        // Authenticate the minimum purchase amount, all tokens will be sold given this slippage limit.\n        uint256 minAllowedPurchaseAmount = (underlyingValue * settlementSlippageLimit) / SETTLEMENT_SLIPPAGE_PRECISION;\n        require(params.minPurchaseAmount >= minAllowedPurchaseAmount, "Purchase Limit");\n\n        NOTIONAL.redeemStrategyTokensToCash(maturity, strategyTokens, settlementTrade);\n\n        // If there are no more strategy tokens left, then mark the vault as settled\n        vaultState = NOTIONAL.getVaultState(address(this), maturity);\n        if (vaultState.totalStrategyTokens == 0) {\n            NOTIONAL.settleVault(address(this), maturity);\n        }\n    }\n```\n