Skip to content

Commit

Permalink
fixed some minor issues
Browse files Browse the repository at this point in the history
  • Loading branch information
shivam-ef committed Feb 6, 2025
1 parent 64ab9a8 commit 84c6b18
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 18 deletions.
25 changes: 8 additions & 17 deletions src/LiquidityPool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ contract LiquidityPool is Initializable, OwnableUpgradeable, UUPSUpgradeable, IL
address public etherFiAdminContract;
bool public DEPRECATED_whitelistEnabled;
mapping(address => bool) public DEPRECATED_whitelisted;
mapping(address => BnftHoldersIndex) public validatorSpawner;
mapping(address => ValidatorSpawner) public validatorSpawner;

bool public restakeBnftDeposits;
uint128 public ethAmountLockedForWithdrawal;
Expand Down Expand Up @@ -194,23 +194,18 @@ contract LiquidityPool is Initializable, OwnableUpgradeable, UUPSUpgradeable, IL
/// it returns the amount of shares burned
function withdraw(address _recipient, uint256 _amount) external whenNotPaused returns (uint256) {
uint256 share = sharesForWithdrawalAmount(_amount);
require(msg.sender == address(withdrawRequestNFT) || msg.sender == address(membershipManager) || msg.sender == address(liquifier), "Incorrect Caller");
if (totalValueInLp < _amount || (msg.sender == address(withdrawRequestNFT) && ethAmountLockedForWithdrawal < _amount) || (msg.sender == address(liquifier) && eETH.balanceOf(msg.sender) < _amount)) revert InsufficientLiquidity();
require(msg.sender == address(withdrawRequestNFT) || msg.sender == address(membershipManager), "Incorrect Caller");
if (totalValueInLp < _amount || (msg.sender == address(withdrawRequestNFT) && ethAmountLockedForWithdrawal < _amount) || eETH.balanceOf(msg.sender) < _amount) revert InsufficientLiquidity();
if (_amount > type(uint128).max || _amount == 0 || share == 0) revert InvalidAmount();
if (msg.sender == address(liquifier)) {
totalValueOutOfLp -= uint128(_amount);
} else {

totalValueInLp -= uint128(_amount);
}
if (msg.sender == address(withdrawRequestNFT)) {
ethAmountLockedForWithdrawal -= uint128(_amount);
}

eETH.burnShares(msg.sender, share);

if (_recipient != address(this)) {
_sendFund(_recipient, _amount);
}
_sendFund(_recipient, _amount);

return share;
}
Expand Down Expand Up @@ -380,13 +375,9 @@ contract LiquidityPool is Initializable, OwnableUpgradeable, UUPSUpgradeable, IL
uint256 returnAmount = 0;

for (uint256 i = 0; i < _validatorIds.length; i++) {
if(nodesManager.phase(_validatorIds[i]) == IEtherFiNode.VALIDATOR_PHASE.WAITING_FOR_APPROVAL) {
if (bnftHolder != address(this)) returnAmount += 1 ether;
if(nodesManager.phase(_validatorIds[i]) == IEtherFiNode.VALIDATOR_PHASE.WAITING_FOR_APPROVAL)
emit ValidatorRegistrationCanceled(_validatorIds[i]);
} else {
if (bnftHolder != address(this)) returnAmount += 2 ether;
numPendingDeposits -= 1;
}
else numPendingDeposits -= 1;
}

stakingManager.batchCancelDeposit(_validatorIds);
Expand All @@ -400,7 +391,7 @@ contract LiquidityPool is Initializable, OwnableUpgradeable, UUPSUpgradeable, IL
if (!roleRegistry.hasRole(LIQUIDITY_POOL_ADMIN_ROLE, msg.sender)) revert IncorrectRole();
require(!validatorSpawner[_user].registered, "Already registered");

validatorSpawner[_user] = BnftHoldersIndex({registered: true});
validatorSpawner[_user] = ValidatorSpawner({registered: true});

emit BnftHolderRegistered(_user, 0);
}
Expand Down
3 changes: 3 additions & 0 deletions src/WeETH.sol
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ contract WeETH is ERC20Upgradeable, UUPSUpgradeable, OwnableUpgradeable, ERC20Pe
}

/// @notice Transfer weEth out of treasury to the owner
/// @dev The address 0x6329004E903B7F420245E7aF3f355186f2432466 is EtherFi's deprecated address
/// to receive the rewards. Since it doesn't have functionality to transfer out ERC20 tokens, we
/// need a function here to rescue those funds
function rescueTreasuryWeeth() public onlyOwner {
address treasury = 0x6329004E903B7F420245E7aF3f355186f2432466;
uint256 treasuryBal = balanceOf(treasury);
Expand Down
2 changes: 1 addition & 1 deletion src/interfaces/ILiquidityPool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ interface ILiquidityPool {
address holder;
}

struct BnftHoldersIndex {
struct ValidatorSpawner {
bool registered;
}

Expand Down

0 comments on commit 84c6b18

Please sign in to comment.