Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions contracts/contracts/vault/OETHVaultCore.sol
Original file line number Diff line number Diff line change
Expand Up @@ -397,15 +397,21 @@ contract OETHVaultCore is VaultCore {
override
returns (uint256 balance)
{
if (_asset != weth) {
return 0;
}

balance = super._checkBalance(_asset);

if (_asset == weth) {
WithdrawalQueueMetadata memory queue = withdrawalQueueMetadata;
// Need to remove WETH that is reserved for the withdrawal queue
if (balance + queue.claimed >= queue.queued) {
return balance + queue.claimed - queue.queued;
}
WithdrawalQueueMetadata memory queue = withdrawalQueueMetadata;
// If there is not enough WETH in the vault and strategies to cover the outstanding withdrawals.
// It can happen if more than half of the users have requested a withdrawal but have not claimed.
if (balance + queue.claimed < queue.queued) {
return 0;
}

// Need to remove WETH that is reserved for the withdrawal queue
return balance + queue.claimed - queue.queued;
}

/**
Expand Down
5 changes: 5 additions & 0 deletions contracts/test/vault/oeth-vault.js
Original file line number Diff line number Diff line change
Expand Up @@ -2149,6 +2149,11 @@ describe("OETH Vault", function () {
// 100 from mints - 99 outstanding withdrawals - 2 from slashing = -1 value which is rounder up to zero
expect(await fixture.oethVault.totalValue()).to.equal(0);
});
it("Should have check balance of zero", async () => {
const { oethVault, weth } = fixture;
// 100 from mints - 99 outstanding withdrawals - 2 from slashing = -1 value which is rounder up to zero
expect(await oethVault.checkBalance(weth.address)).to.equal(0);
});
it("Fail to allow user to create a new request due to too many outstanding requests", async () => {
const { oethVault, matt } = fixture;

Expand Down