Skip to content

Commit

Permalink
unlock eth
Browse files Browse the repository at this point in the history
  • Loading branch information
bulbozaur committed Feb 15, 2024
1 parent 5e3b16a commit f287ad0
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion contracts/Escrow.sol
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ contract Escrow {
error RequestIsNotFromBatch(uint256 id);
error RequestFromBatch(uint256 id);

event RageQuitAccumulationStarted();
event RageQuitStarted();
event WithdrawalsBatchRequested(
uint256 indexed firstRequestId, uint256 indexed lastRequestId, uint256 stEthLeftToRequest
Expand Down Expand Up @@ -313,6 +312,24 @@ contract Escrow {
_activateNextGovernanceState();
}

function unlockEth() public {
_activateNextGovernanceState();
if (_state != State.Signalling) {
revert InvalidState();
}

address sender = msg.sender;
uint256 ethToUnlock = _balances[sender].eth;

if (ethToUnlock > 0) {
_balances[sender].eth = 0;
_totalClaimedEthLocked -= ethToUnlock;
IERC20(WST_ETH).transfer(sender, ethToUnlock);

_activateNextGovernanceState();
}
}

function claimETH() external {
if (_state != State.RageQuit) {
revert InvalidState();
Expand Down Expand Up @@ -512,10 +529,20 @@ contract Escrow {
for (uint256 i = 0; i < requestIds.length; ++i) {
uint256 id = requestIds[i];
address owner = _wqRequests[id].owner;

if (owner != address(this)) {
revert RequestIsNotFromBatch(id);
}
_claimedWQRequestsAmount += wqRequestStatuses[i].amountOfStETH;

for (uint256 idx = 0; i < _balances[owner].wqRequestIds.length; i++) {
if (_balances[owner].wqRequestIds[idx] == requestIds[i]) {
_balances[owner].wqRequestIds[idx] =
_balances[owner].wqRequestIds[_balances[owner].wqRequestIds.length - 1];
_balances[owner].wqRequestIds.pop();
break;
}
}
}
}

Expand Down

0 comments on commit f287ad0

Please sign in to comment.