Skip to content

Commit

Permalink
test(lido): getDepositableEther
Browse files Browse the repository at this point in the history
  • Loading branch information
mymphe committed Mar 6, 2024
1 parent 155e72b commit a2412b7
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
5 changes: 5 additions & 0 deletions test/0.4.24/contracts/WithdrawalQueue__MockForLidoMisc.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@ pragma solidity 0.4.24;

contract WithdrawalQueue__MockForLidoMisc {
bool public isBunkerModeActive;
uint256 public unfinalizedStETH;

// test helpers

function mock__bunkerMode(bool active) external {
isBunkerModeActive = active;
}

function mock__unfinalizedStETH(uint256 amount) external {
unfinalizedStETH = amount;
}
}
37 changes: 37 additions & 0 deletions test/0.4.24/lido/lido.misc.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,4 +223,41 @@ describe("Lido:misc", () => {
expect(await lido.getFeeDistribution()).to.deep.equal([treasuryFee, insuranceFee, modulesFee]);
});
});

context("getDepositableEther", () => {
it("Returns the amount of ether eligible for deposits", async () => {
await lido.resume();

const bufferedEtherBefore = await lido.getBufferedEther();

// top up buffer
const deposit = ether("10.0");
await lido.submit(ZeroAddress, { value: deposit });

expect(await lido.getDepositableEther()).to.equal(bufferedEtherBefore + deposit);
});

it("Returns 0 if reserved by the buffered ether is fully reserved for withdrawals", async () => {
await lido.resume();

const bufferedEther = await lido.getBufferedEther();

// reserve all buffered ether for withdrawals
await withdrawalQueue.mock__unfinalizedStETH(bufferedEther);

expect(await lido.getDepositableEther()).to.equal(0);
});

it("Returns the difference if the buffered ether is partially reserved", async () => {
await lido.resume();

const bufferedEther = await lido.getBufferedEther();

// reserve half of buffered ether for withdrawals
const reservedForWithdrawals = bufferedEther / 2n;
await withdrawalQueue.mock__unfinalizedStETH(reservedForWithdrawals);

expect(await lido.getDepositableEther()).to.equal(bufferedEther - reservedForWithdrawals);
});
});
});

0 comments on commit a2412b7

Please sign in to comment.