From 4969ed3fc210884728b6f71687f84a12586df428 Mon Sep 17 00:00:00 2001 From: kyriediculous Date: Mon, 28 Oct 2024 18:41:41 +0100 Subject: [PATCH] update 'available' calculation in withdraw --- src/lpETH/LpETH.sol | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/lpETH/LpETH.sol b/src/lpETH/LpETH.sol index c27e175..9328097 100644 --- a/src/lpETH/LpETH.sol +++ b/src/lpETH/LpETH.sol @@ -219,7 +219,10 @@ contract LpETH is } Data storage $ = _loadStorageSlot(); - uint256 available = ud(amount).mul(UNIT_60x18.sub(ud($.unlocking).div(ud($.liabilities)))).unwrap(); + uint256 available = $.liabilities - $.unlocking; + if (available > amount) available = amount; + + ud(amount).mul(UNIT_60x18.sub(ud($.unlocking).div(ud($.liabilities)))).unwrap(); if (available < amount && available > 0) { requestId = $.withdrawQueue.createRequest(uint128(amount - available), payable(msg.sender));