# Incorrect `tokensClaimed` calculation in `EthenaCooldownHolder::_finalizeCooldown()` blocks withdrawals

When sUSDe cooldownDuration is 0, USDe is redeemed at request time, so _finalizeCooldown computes tokensClaimed as zero and users cannot withdraw.

- Payout: Audit contest
- Severity: medium
- Program: Notional
- Found by: 0xDeoGratias
- Disclosed: 2025-06-27
- Write-up quality: 6/10
- Original: https://github.com/sherlock-audit/2025-06-notional-exponent-judging/issues/263
- Library page: https://bugbountylibrary.com/r/sherlock%3A2025-06-notional-exponent%3AM-2
- Tags: area:web3 domain:web3 impact:funds-loss kind:contest platform:sherlock sev:medium tech:evm tech:solidity technique:source-review vuln:accounting-error vuln:business-logic

**Target:** EthenaCooldownHolder / EthenaWithdrawRequestManager withdrawal flow
**Root cause:** _startCooldown redeems sUSDe to USDe immediately when cooldownDuration==0, so at finalize time balanceBefore==balanceAfter and tokensClaimed is computed as 0.
**Steps:**
1. Set sUSDe.cooldownDuration() to 0
2. User initiates withdrawal via EthenaWithdrawRequestManager; _startCooldown calls `sUSDe.redeem(cooldownBalance, address(this), address(this))`, USDe lands in holder
3. User finalizes; _finalizeCooldown reads `balanceBefore = USDe.balanceOf(address(this))`, skips unstake since cooldownEnd==0, reads balanceAfter
4. `tokensClaimed = balanceAfter - balanceBefore` equals 0; `USDe.transfer(manager, 0)`; user receives nothing
**How found:** Code-reading of the two paths: noticed the immediate-redeem branch in _startCooldown moves USDe to the holder before finalize, making the balance-delta accounting in _finalizeCooldown always zero.
**Insight:** When a contract measures value via before/after balance deltas at finalize time, check whether any earlier code path already moved the asset into the contract; state-changing branches (like duration==0) often bypass the delta accounting.

## Proof of concept (copied exactly from the original report)

**EthenaCooldownHolder _startCooldown and _finalizeCooldown code**

```
function _startCooldown(uint256 cooldownBalance) internal override {
      uint24 duration = sUSDe.cooldownDuration();
      if (duration == 0) {
          // If the cooldown duration is set to zero, can redeem immediately
=>        sUSDe.redeem(cooldownBalance, address(this), address(this));
      } else {
         ...
      }
  }

If `cooldownDuration` is `0`, the `sUSDe` is immediately redeemed for `USDe`, and the `USDe` tokens are transferred to the `EthenaCooldownHolder` contract. Later, when the user finalizes their withdrawal, `EthenaCooldownHolder::_finalizeCooldown()` is called:

[EthenaCooldownHolder::_finalizeCooldown()](https://github.com/sherlock-audit/2025-06-notional-exponent/blob/82c87105f6b32bb362d7523356f235b5b07509f9/notional-v4/src/withdraws/Ethena.sol#L30) function:
function _finalizeCooldown() internal override returns (uint256 tokensClaimed, bool finalized) {
    uint24 duration = sUSDe.cooldownDuration();
    IsUSDe.UserCooldown memory userCooldown = sUSDe.cooldowns(address(this));

    if (block.timestamp < userCooldown.cooldownEnd && 0 < duration) {
        // Cooldown has not completed, return a false for finalized
        return (0, false);
    }

    uint256 balanceBefore = USDe.balanceOf(address(this));
    if (0 < userCooldown.cooldownEnd) sUSDe.unstake(address(this));
    uint256 balanceAfter = USDe.balanceOf(address(this));

=>  tokensClaimed = balanceAfter - balanceBefore;
    USDe.transfer(manager, tokensClaimed);
    finalized = true;
}
```

