Farseen0/scar-pairs huggingface dataset:
MEDIUM severity: A malicious user can exploit the `withdrawReserves` function by performing a sandwich attack, which . A malicious user can exploit the `withdrawReserves` function by performing a sandwich attack, which involves calling `userDeposit` before the `withdrawReserves` transaction and then `userWithdraw` after the `withdrawReserves` transaction. This attack is facilitated by the fact that the exchange rate...

Vulnerable code:
```\nexchange_rate = (cash + total_borrows - reserves) / d_token_supply\n```\n```\ndiff --git a/new-dodo-v3/test/DODOV3MM/D3Vault/D3Vault.t.sol b/new-dodo-v3/test/DODOV3MM/D3Vault/D3Vault.t.sol\nindex a699162..337d1f5 100644\n--- a/new-dodo-v3/test/DODOV3MM/D3Vault/D3Vault.t.sol\nb/new-dodo-v3/test/DODOV3MM/D3Vault/D3Vault.t.sol\n@@ -233,6 +233,47 @@\ncontract D3VaultTest is TestContext {\n    function testWithdrawReservesSandwichAttack() public {\n        // Get dToken\n        (address dToken2,,,,,,) = d3Vault.getAssetInfo(address(token2));\n\n        // Approve tokens\n        vm.prank(user1);\n        token2.approve(address(dodoApprove), type(uint256).max);\n        vm.prank(user2);\n        token2.approve(address(dodoApprove), type(uint256).max);\n        vm.prank(user2);\n        D3Token(dToken2).approve(address(dodoApprove), type(uint256).max);\n\n        // Set user quotas and mint tokens\n        mockUserQuota.setUserQuota(user1, address(token2), 1000 ether);\n        mockUserQuota.setUserQuota(user2, address(token2), 1000 ether);\n        token2.mint(user1, 1000 ether);\n        token2.mint(user2, 1000 ether);\n\n        // User 1 deposits to allow pool to borrow\n        vm.prank(user1);\n        d3Proxy.userDeposit(user1, address(token2), 500 ether);\n        token2.mint(address(d3MM), 100 ether);\n        poolBorrow(address(d3MM), address(token2), 100 ether);\n\n        vm.warp(365 days);\n\n        // Accrue interest from pool borrow\n        d3Vault.accrueInterest(address(token2));\n        uint256 reserves = d3Vault.getReservesInVault(address(token2));\n\n        // User 2 performs a sandwich attack on the withdrawReserves call to make a profit\n        vm.prank(user2);\n        d3Proxy.userDeposit(user2, address(token2), 100 ether);\n        vm.prank(vaultOwner);\n        d3Vault.withdrawReserves(address(token2), reserves);\n        uint256 dTokenBalance = D3Token(d\n```
MEDIUM severity: The vulnerability in the vault checkpoint's conversion from assets to shares calculation leads to a . The vulnerability in the vault checkpoint's conversion from assets to shares calculation leads to a slow loss of funds for long-time depositors. The issue arises from the incorrect handling of settlement fees in the formula used to calculate user shares. Specifically, the formula multiplies the resu...

Vulnerable code:
```\nfunction toSharesGlobal(Checkpoint memory self, UFixed6 assets) internal pure returns (UFixed6) {\n    if (self.shares.isZero()) {\n        return assets;\n    }\n\n    if (self.assets.lte(Fixed6Lib.ZERO)) {\n        return assets;\n    }\n\n    return _toShares(self, _withoutSettlementFeeGlobal(self, assets));\n}\n\nfunction _toShares(Checkpoint memory self, UFixed6 assets) private pure returns (UFixed6) {\n    UFixed6 selfAssets = UFixed6Lib.unsafeFrom(self.assets);\n    return _withSpread(self, assets.muldiv(self.shares, selfAssets));\n}\n\nfunction _withSpread(Checkpoint memory self, UFixed6 amount) private pure returns (UFixed6) {\n    UFixed6 selfAssets = UFixed6Lib.unsafeFrom(self.assets);\n    UFixed6 totalAmount = self.deposit.add(self.redemption.muldiv(selfAssets, self.shares));\n    UFixed6 totalAmountIncludingFee = UFixed6Lib.unsafeFrom(Fixed6Lib.from(totalAmount).sub(self.tradeFee));\n\n    return totalAmount.isZero()? amount : amount.muldiv(totalAmountIncludingFee, totalAmount);\n}\n\nfunction _withoutSettlementFeeGlobal(Checkpoint memory self, UFixed6 amount) private pure returns (UFixed6) {\n    return _withoutSettlementFee(amount, self.settlementFee);\n}\n\nfunction _withoutSettlementFee(UFixed6 amount, UFixed6 settlementFee) private pure returns (UFixed6) {\n    return amount.unsafeSub(settlementFee);\n}\n```
MEDIUM severity: The vulnerability arises when the amount of gas provided during the finalization of withdrawal trans. The vulnerability arises when the amount of gas provided during the finalization of withdrawal transactions on L1 is not accurately predicted due to the uncontrolled out-of-gas error. This can occur when the bridged message from L2 to L1 is excessively long, causing the predicted `baseGas` to be ins...

Vulnerable code:
```\nfunction checkGasV1(bytes calldata _message)\n    public\n    view\n    returns (uint256, uint256)\n{\n    uint256 gas1 = gasleft();\n    bytes32 versionedHash = \n        Hashing.hashCrossDomainMessageV1(\n            0,\n            address(this),\n            address(this),\n            0,\n            0,\n            _message\n        );\n    uint256 gas2 = gasleft();\n    return (_message.length, gas1 - gas2);\n}\n```\n```\nfunction checkGasV0(bytes calldata _message)\n    public\n    view\n    returns (\n        uint256,\n        uint256,\n        uint256\n    )\n{\n    uint256 gas1 = gasleft();\n    bytes32 versionedHash1 = Hashing.hashCrossDomainMessageV0(\n        address(this),\n        address(this),\n        _message,\n        0\n    );\n\n    uint256 gas2 = gasleft();\n    uint256 gas3 = gasleft();\n    bytes32 versionedHash2 = Hashing.hashCrossDomainMessageV1(\n        0,\n        address(this),\n        address(this),\n        0,\n        0,\n        _message\n    );\n\n    uint256 gas4 = gasleft();\n    return (\n        _message.length,\n        gas1 - gas2,\n        gas3 - gas4\n    );\n}\n```
MEDIUM severity: The `stakingContext.auraRewardPool.withdrawAndUnwrap` function is called within the `_unstakeAndExit. The `stakingContext.auraRewardPool.withdrawAndUnwrap` function is called within the `_unstakeAndExitPool` function in both `Boosted3TokenPoolUtils.sol` and `TwoTokenPoolUtils.sol` contracts. This function is responsible for withdrawing BPT tokens from the pool and redeeming them. However, the return...

Vulnerable code:
```\nstakingContext.auraRewardPool.withdrawAndUnwrap(\n    bptClaim,\n    false\n)\n```\n```\ninterface IAuraRewardPool {\n    function withdrawAndUnwrap(uint256 amount, bool claim) external returns (bool);\n```\n```\nfunction withdrawAndUnwrap(uint256 amount, bool claim) public updateReward(msg.sender) returns(bool) {\n```
MEDIUM severity: The `VaultValuation.getLiquidationFactors()` method in the Notional protocol has an incorrect implem. The `VaultValuation.getLiquidationFactors()` method in the Notional protocol has an incorrect implementation, which restricts the ability to partially liquidate a vault account's debt. This limitation arises from the `checkMinBorrow` flag being set to `true`, which ensures that the outstanding debt...

Vulnerable code:
```\nFile: VaultValuation.sol\n\nint256 maxLiquidatorDepositLocal = _calculateDeleverageAmount(\n    vaultConfig,\n    h.vaultShareValueUnderlying,\n    h.totalDebtOutstandingInPrimary.neg(),\n    h.debtOutstanding[currencyIndex].neg(),\n    minBorrowSize,\n    exchangeRate,\n    er.rateDecimals\n);\n\nif (depositUnderlyingInternal < maxLiquidatorDepositLocal) {\n    if (h.debtOutstanding[currencyIndex].sub(depositUnderlyingInternal) < minBorrowSize) {\n        require("Must Liquidate All Debt");\n    }\n} else {\n    depositUnderlyingInternal = maxLiquidatorDepositLocal;\n}\n```
MEDIUM severity: The `calculateRewards` function is intended to be executed only for non-whitelisted addresses, as it. The `calculateRewards` function is intended to be executed only for non-whitelisted addresses, as it is designed to distribute rewards to specific recipients. However, the current implementation allows whitelisted addresses to directly call this function, which can result in unintended consequences....

Vulnerable code:
```\nfunction calculateRewards(address to)\n    public\n    virtual\n    override\n    whenNotPaused\n    returns (bool success)\n{\n    require(to == _msgSender(), "ST5");\n    uint256 reward = _calculateRewards(to);\n    emit TriggeredCalculateRewards(to, reward, block.timestamp);\n    return true;\n}\n```
MEDIUM severity: The LSP0 ownership functions, `transferOwnership` and `renounceOwnership`, are defined in the LSP sp. The LSP0 ownership functions, `transferOwnership` and `renounceOwnership`, are defined in the LSP specifications as payable functions, allowing for the transfer of Ether along with the ownership change. However, their actual implementations in the LSP0 contract deviate from this specification, as th...

Vulnerable code:
```\nfunction transferOwnership(address newPendingOwner) external payable;\nfunction renounceOwnership() external payable;\n```\n```\nfunction transferOwnership(address newOwner) public virtual override(LSP14Ownable2Step, OwnableUnset) {\n```\n```\nfunction renounceOwnership() public virtual override {\n    address _owner = owner();\n```
MEDIUM severity: The vulnerability arises from a discrepancy in the calculation of `ysTotal` in two distinct scenario. The vulnerability arises from a discrepancy in the calculation of `ysTotal` in two distinct scenarios. In the first scenario, `ysTotal` is computed when adding to `totalSuppliesTracking`, whereas in the second scenario, it is calculated when determining `balanceOfYsCvgAt`. The difference in calculat...

Vulnerable code:
```\nuint256 cvgLockAmount = (amount * ysPercentage) / MAX_PERCENTAGE;\nuint256 ysTotal = (lockDuration * cvgLockAmount) / MAX_LOCK;\n```\n```\nuint256 ysTotal = (((endCycle - startCycle) * amount * ysPercentage) / MAX_PERCENTAGE) / MAX_LOCK;\n```\n```\nstartCycle 357\nendCycle 420\nlockDuration 63\namount 2\nysPercentage 80\n```\n```\nuint256 cvgLockAmount = (2 * 80) / 100;\nuint256 ysTotal = (63 * 1) / 96;\n```\n```\nuint256 ysTotal = ((63 * 2 * 80) / 100) / 96; \nuint256 ysTotal = (63 * 2 * 80) / (100 * 96);\n```
MEDIUM severity: The vulnerability allows a lender to manipulate the terms of a loan, effectively stealing the borrow. The vulnerability allows a lender to manipulate the terms of a loan, effectively stealing the borrower's collateral. This is achieved by calling the `provideNewTermsForRoll` function, which enables the lender to set arbitrary interest rates and loan-to-collateral ratios. The lender can then use this...

Vulnerable code:
```\nrequestLoan("1,000 debt tokens", "5% interest", "10 loan tokens for each collateral", "1 year")\n```\n```\nprovideNewTermsForRoll("loanID", "10000000% interest", "1000 loan tokens for each collateral", "1 year")\n```\n```\nfunction interestFor(uint256 amount_, uint256 rate_, uint256 duration_) public pure returns (uint256) {\n    uint256 interest = (rate_ * duration_) / 10000;  // Assuming 10000 as the number of days in a year\n    return (amount_ * interest) / DECIMALS_INTEREST;\n}\n```\n```\nfunction newCollateralFor(uint256 loanID_) public view returns (uint256) {\n    Loan memory loan = loans[loanID_];\n\n    uint256 neededCollateral = collateralFor(loan.amount, loan.request.loanToCollateral);\n    // Lender can force neededCollateral to always be less than loan.collateral\n\n    return neededCollateral > loan.collateral? neededCollateral - loan.collateral : 0;\n}\n```
MEDIUM severity: The `_executionOrder()` function is intended to be executed under specific circumstances, where the . The `_executionOrder()` function is intended to be executed under specific circumstances, where the `nextBoxNumber` variable is greater than 1 and also greater than the `nextExecuteBoxNumber` variable. However, a closer examination of the code reveals that the condition checks are not consistently d...

Vulnerable code:
```\nif (nextBoxNumber > 1 and nextBoxNumber > nextExecuteBoxNumber) {\n    // code here\n}\n```\n```\nif (nextBoxNumber > 1 and nextBoxNumber > nextExecuteBoxNumber) {\n    // code here\n}\n```\n```\nif (nextBoxNumber > 1 && nextBoxNumber >= nextExecuteBoxNumber) {\n    // Code here\n}\n```
MEDIUM severity: The `maxTrainingDeposit` mechanism can be bypassed by exploiting a vulnerability in the `deposit` fu. The `maxTrainingDeposit` mechanism can be bypassed by exploiting a vulnerability in the `deposit` function. Specifically, the function allows users to transfer their balance to another account, effectively circumventing the `maxTrainingDeposit` check.\n\nThe `deposit` function, as shown, checks if t...

Vulnerable code:
```\nfunction deposit(\n    uint256 _amount,\n    address _receiver\n) external nonReentrant onlyWhenVaultIsOn returns (uint256 shares) {\n    if (training) {\n        require(whitelist[msg.sender]);\n        uint256 balanceSender = (balanceOf(msg.sender) * exchangeRate) / (10 ** decimals());\n        require(_amount + balanceSender <= maxTrainingDeposit);\n    }\n    // rest of code\n```
MEDIUM severity: The vulnerability in the AsyncSynthVault contract's `_convertToAssets` and `_convertToShares` functi. The vulnerability in the AsyncSynthVault contract's `_convertToAssets` and `_convertToShares` functions can lead to incorrect exchange ratios when the vault is closed, resulting in accounting inconsistencies and potential fund theft. This occurs when the `totalAssetsSnapshotForDeposit`, `totalSupply...

Vulnerable code:
```\nuint256 totalAssetsSnapshotForDeposit = _lastSavedBalance + 1;\nuint256 totalSupplySnapshotForDeposit = totalSupply + 1;\n\nuint256 totalAssetsSnapshotForRedeem = _lastSavedBalance + pendingDeposit + 1;\nuint256 totalSupplySnapshotForRedeem = totalSupply + sharesToMint + 1;\n```\n```\nimport { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";\n```\n```\nfunction test_attackerProfitsViaRequestingDeposits() external {\n    address attacker = makeAddr("attacker");\n    address protocolUsers = makeAddr("alice");\n    address vaultOwner = vaultTested.owner();\n\n    uint256 donation = 1e18 - 1;\n    uint256 protocolUsersDeposit = 10e18 + 15e18;\n    uint256 protocolTeamBootstrapDeposit = 1e18;\n\n    IERC20 asset = IERC20(vaultTested.asset());\n    deal(address(asset), protocolUsers, protocolUsersDeposit);\n    deal(address(asset), attacker, donation);\n    deal(address(asset), vaultOwner, protocolTeamBootstrapDeposit);\n\n    vm.prank(vaultOwner);\n    asset.approve(address(vaultTested), type(uint256).max);\n\n    vm.prank(protocolUsers);\n    asset.approve(address(vaultTested), type(uint256).max);\n\n    vm.prank(attacker);\n    asset.approve(address(vaultTested), type(uint256).max);\n\n    vm.prank(attacker);\n    asset.transfer(address(vaultTested), donation);\n\n    vm.prank(vaultOwner);\n    vaultTested.deposit(protocolTeamBootstrapDeposit, vaultOwner);\n\n    vm.prank(protocolUsers);\n    vaultTested.deposit(10e18, protocolUsers);\n\n    vm.prank(vaultOwner);\n    vaultTested.close();\n\n    vm.prank(protocolUsers);\n    vaultTested.requestDeposit(15e18, protocolUsers, protocolUsers, "");\n\n    uint256 totalSupplyCachedOnOpen = vaultTested.totalSupply() + 1 + 1;\n    uint256 totalAssetsCachedOnOpen = vaultTested.lastSavedBalance() + 1 + 1;\n    uint256 minToDepositToGetOneShare = totalAssetsCachedOnOpen / totalSupplyCachedOnOpen;\n\n    uint256 totalDeposited = 0;\n    for (uint256 i = 0; i < 30; i++) {\n        address attackerEOA = address(uint160(i * 31000 + 49 * 49)); // Random address that does not conflict with existing ones\n        deal(address(asset), attackerEOA, minToDepositToGetOneShare);\n        vm.startPrank(attackerEOA);\n        asset.approve(address(vaultTested), type(uint256).max);\n        vaultTested.requestDeposit(minToDepositToGetOneShare, attackerEOA, attackerEOA, "");\n        vm.stopPrank();\n        totalDepos\n```
MEDIUM severity: The `TokenUtils.withdrawTokens` function, which is called within the `_borrow` function, returns the. The `TokenUtils.withdrawTokens` function, which is called within the `_borrow` function, returns the actual amount of tokens transferred, but this return value is not utilized anywhere in the repository. This might lead to inconsistencies, particularly when the original value of `_amount` is set to...

Vulnerable code:
```\nfunction _borrow(\n    address _market,\n    address _tokenAddr,\n    uint256 _amount,\n    uint256 _rateMode,\n    address _to,\n    address _onBehalf\n) internal returns (uint256) {\n    ILendingPoolV2 lendingPool = getLendingPool(_market);\n\n    if (_onBehalf == address(0)) {\n        _onBehalf = address(this);\n    }\n\n    lendingPool.borrow(_tokenAddr, _amount, _rateMode, AAVE_REFERRAL_CODE, _onBehalf);\n\n    _tokenAddr.withdrawTokens(_to, _amount);\n\n    logger.Log(\n        address(this),\n        msg.sender,\n        "AaveBorrow",\n        abi.encode(_market, _tokenAddr, _amount, _rateMode, _to, _onBehalf)\n    );\n\n    return _amount;\n}\n```\n```\nfunction withdrawTokens(\n    address _token,\n    address _to,\n    uint256 _amount\n) internal returns (uint256) {\n    if (_amount == type(uint256).max) {\n        _amount = getBalance(_token, address(this));\n    }\n```
MEDIUM severity: The `IchiLpOracle` function is susceptible to an arithmetic calculation error, resulting in an infla. The `IchiLpOracle` function is susceptible to an arithmetic calculation error, resulting in an inflated price being returned for the ICHI_USDC vault. This issue arises when the function processes the token price, which is expected to be in USD with 18 decimal places of precision.\n\nUpon examination...

Vulnerable code:
```\nSTATICCALL IchiLpOracle.getPrice(token=0xFCFE742e19790Dd67a627875ef8b45F17DB1DaC6) => (1101189125194558706411110851447)\n```
MEDIUM severity: The `interfaceFee.amount` field in the `TriggerOrder` struct is defined as a `uint48` data type, whi. The `interfaceFee.amount` field in the `TriggerOrder` struct is defined as a `uint48` data type, which allows for a maximum value of approximately 281 million. However, when storing the `TriggerOrder` data, the `interfaceFee.amount` value is incorrectly converted to a `uint40` data type using the `U...

Vulnerable code:
```\nstruct StoredTriggerOrder {\n    uint8 side;                // 0 = maker, 1 = long, 2 = short, 3 = collateral\n    int8 comparison;           // -2 = lt, -1 = lte, 0 = eq, 1 = gte, 2 = gt\n    uint64 fee;                // <= 18.44tb\n    int64 price;               // <= 9.22t\n    int64 delta;               // <= 9.22t\n    uint48 interfaceFeeAmount; // <= 281m\n\n    address interfaceFeeReceiver;\n    bool interfaceFeeUnwrap;\n    bytes11 __unallocated0__;\n}\n\nlibrary TriggerOrderLib {\n    function store(TriggerOrderStorage storage self, TriggerOrder memory newValue) internal {\n        if (newValue.side > uint8.type.max) revert TriggerOrderStorageInvalidError();\n        if (newValue.comparison > int8.type.max) revert TriggerOrderStorageInvalidError();\n        if (newValue.comparison < int8.type.min) revert TriggerOrderStorageInvalidError();\n        if (newValue.fee > UFixed6.wrap(uint64.type.max)) revert TriggerOrderStorageInvalidError();\n        if (newValue.price > Fixed6.wrap(int64.type.max)) revert TriggerOrderStorageInvalidError();\n        if (newValue.price < Fixed6.wrap(int64.type.min)) revert TriggerOrderStorageInvalidError();\n        if (newValue.delta > Fixed6.wrap(int64.type.max)) revert TriggerOrderStorageInvalidError();\n        if (newValue.delta < Fixed6.wrap(int64.type.min)) revert TriggerOrderStorageInvalidError();\n        if (newValue.interfaceFeeAmount > UFixed6.wrap(uint48.type.max)) revert TriggerOrderStorageInvalidError();\n\n        self.value = StoredTriggerOrder(\n            uint8(newValue.side),\n            int8(newValue.comparison),\n            UFixed6.unwrap(newValue.fee),\n            Fixed6.unwrap(newValue.price),\n            Fixed6.unwrap(newValue.delta),\n            UFixed6.unwrap(newValue.interfaceFeeAmount),\n            newValue.interfaceFee.receiver,\n            newValue.interfaceFee.unwrap,\n            bytes11(0)\n        );\n    }\n}\n```
MEDIUM severity: The `KeepRandomBeaconServiceImplV1` contract allows senders to specify an arbitrary method and contr. The `KeepRandomBeaconServiceImplV1` contract allows senders to specify an arbitrary method and contract that will receive a callback once the beacon generates a relay entry. This callback is executed by the `executeCallback` function, which calls the specified contract method with a single `uint256`...

Vulnerable code:
```\n/**\n * @dev Creates a request to generate a new relay entry, which will include\n * a random number (by signing the previous entry's random number).\n * \n * @param callbackContract Callback contract address.\n * @param callbackMethod Callback contract method signature. String representation of your method with a single\n * uint256 input parameter i.e. "relayEntryCallback(uint256)".\n * @param callbackGas Gas required for the callback.\n * The customer needs to ensure they provide a sufficient callback gas\n * to cover the gas fee of executing the callback. Any surplus is returned\n * to the customer. If the callback gas amount turns to be not enough to\n * execute the callback, callback execution is skipped.\n * \n * @return An uint256 representing uniquely generated relay request ID. It is also returned as part of the event.\n */\nfunction requestRelayEntry(\n    address callbackContract,\n    string memory callbackMethod,\n    uint256 callbackGas\n) public nonReentrant payable returns (uint256) {\n```\n```\n/**\n * @dev Executes customer specified callback for the relay entry request.\n * @param requestId Request id tracked internally by this contract.\n * @param entry The generated random number.\n * @return Address to receive callback surplus.\n */\nfunction executeCallback(uint256 requestId, uint256 entry) public returns (address payable surplusRecipient) {\n    require(\n        _operatorContracts.contains(msg.sender),\n        "Only authorized operator contract can call execute callback."\n    );\n\n    require(\n        _callbacks[requestId].callbackContract!= address(0),\n        "Callback contract not found"\n    );\n\n    _callbacks[requestId].callbackContract.call(abi.encodeWithSignature(_callbacks[requestId].callbackMethod, entry));\n\n    surplusRecipient = _callbacks[requestId].surplusRecipient;\n    delete _callbacks[requestId];\n}\n```\n```\nmodifier onlyServiceContract() {\n    require(\n        serviceContracts.contains(msg.sender),\n        "Caller is not an authorized contract"\n    );\n    _\n}\n```
MEDIUM severity: The `onlyStakingPoolOperatorOrMaker(poolId)` modifier is used to authorize actions taken on a specif. The `onlyStakingPoolOperatorOrMaker(poolId)` modifier is used to authorize actions taken on a specific staking pool. This authorization mechanism relies on the `getStakingPoolIdOfMaker(maker)` function to determine whether the sender is either the pool operator or a confirmed maker. However, this fu...

Vulnerable code:
```\nfunction getStakingPoolIdOfMaker(address makerAddress)\n    public\n    view\n    returns (bytes32)\n{\n    IStructs.MakerPoolJoinStatus memory poolJoinStatus = _poolJoinedByMakerAddress[makerAddress];\n    if (poolJoinStatus.confirmed) {\n        return poolJoinStatus.poolId;\n    } else {\n        return IStructs.NIL_POOL_ID;\n    }\n}\n```
MEDIUM severity: The vulnerability lies in the liquidation process of auctions, where the system fails to accurately . The vulnerability lies in the liquidation process of auctions, where the system fails to accurately determine the epoch in which an auction will conclude. Specifically, the `liquidate()` function relies on a simplistic check to determine if an auction will end in a future epoch, which does not accou...

Vulnerable code:
```\nif (PublicVault(owner).timeToEpochEnd() <= COLLATERAL_TOKEN.auctionWindow())\n```\n```\nif (firstBidTime + duration - block.timestamp < timeBuffer) {\n    uint64 newDuration = uint256(\n        duration + (block.timestamp + timeBuffer - firstBidTime)\n    ).safeCastTo64();\n    if (newDuration <= auctions[tokenId].maxDuration) {\n        auctions[tokenId].duration = newDuration;\n    } else {\n        auctions[tokenId].duration = \n            auctions[tokenId].maxDuration - firstBidTime;\n    }\n    extended = true;\n}\n```