@@ -395,15 +395,24 @@ contract OETHVaultCore is VaultCore {
395395 override
396396 returns (uint256 balance )
397397 {
398+ if (_asset != weth) {
399+ return 0 ;
400+ }
401+
402+ // Get the WETH in the vault and the strategies
398403 balance = super ._checkBalance (_asset);
399404
400- if (_asset == weth) {
401- WithdrawalQueueMetadata memory queue = withdrawalQueueMetadata;
402- // Need to remove WETH that is reserved for the withdrawal queue
403- if (balance + queue.claimed >= queue.queued) {
404- return balance + queue.claimed - queue.queued;
405- }
405+ WithdrawalQueueMetadata memory queue = withdrawalQueueMetadata;
406+
407+ // If the vault becomes insolvent enough that the total value in the vault and all strategies
408+ // is less than the outstanding withdrawals.
409+ // For example, there was a mass slashing event and most users request a withdrawal.
410+ if (balance + queue.claimed < queue.queued) {
411+ return 0 ;
406412 }
413+
414+ // Need to remove WETH that is reserved for the withdrawal queue
415+ return balance + queue.claimed - queue.queued;
407416 }
408417
409418 /**
@@ -446,29 +455,14 @@ contract OETHVaultCore is VaultCore {
446455 emit AssetAllocated (weth, depositStrategyAddr, allocateAmount);
447456 }
448457
449- /// @dev The total value of all assets held by the vault and all its strategies
458+ /// @dev The total value of all WETH held by the vault and all its strategies
450459 /// less any WETH that is reserved for the withdrawal queue.
451- /// For OETH, this is just WETH in the vault and strategies.
452460 ///
453461 // If there is not enough WETH in the vault and all strategies to cover all outstanding
454462 // withdrawal requests then return a total value of 0.
455463 function _totalValue () internal view override returns (uint256 value ) {
456- value = _totalValueInVault () + _totalValueInStrategies ();
457-
458- // Need to remove WETH that is reserved for the withdrawal queue.
459- WithdrawalQueueMetadata memory queue = withdrawalQueueMetadata;
460- // reserved for the withdrawal queue = cumulative queued total - total claimed
461- uint256 reservedForQueue = queue.queued - queue.claimed;
462-
463- if (value < reservedForQueue) {
464- // This can happen if the vault becomes insolvent enough that the
465- // total value in the vault and all strategies is less than the outstanding withdrawals.
466- // For example, there was a mass slashing event and most users request a withdrawal.
467- return 0 ;
468- }
469-
470- // Adjust the total value by the amount reserved for the withdrawal queue
471- return value - reservedForQueue;
464+ // As WETH is the only asset, just return the WETH balance
465+ return _checkBalance (weth);
472466 }
473467
474468 /// @dev Only WETH is supported in the OETH Vault so return the WETH balance only
0 commit comments