From bcfdf09f2ab2d17106303fcdce823b01ae1c8685 Mon Sep 17 00:00:00 2001 From: johnnyonline Date: Thu, 7 Nov 2024 13:37:29 +0900 Subject: [PATCH] feat: add maxShares so we can rebalance --- src/ynEIGEN/withdrawalsProcessor.sol | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/src/ynEIGEN/withdrawalsProcessor.sol b/src/ynEIGEN/withdrawalsProcessor.sol index 2f93dd4bc..0d0f52e2b 100644 --- a/src/ynEIGEN/withdrawalsProcessor.sol +++ b/src/ynEIGEN/withdrawalsProcessor.sol @@ -124,15 +124,29 @@ contract WithdrawalsProcessor is Ownable { uint256 _withdrawnShares; address _node = address(_nodes[j]); uint256 _nodeShares = _strategy.shares(_node); - if (_nodeShares > _pendingWithdrawalRequestsInShares) { - _withdrawnShares = + // if (_nodeShares > _pendingWithdrawalRequestsInShares) { + // _withdrawnShares = + // (_nodeShares - _pendingWithdrawalRequestsInShares) < MIN_DELTA + // ? _nodeShares + // : _pendingWithdrawalRequestsInShares; + // _pendingWithdrawalRequestsInShares = 0; + // } else if (_nodeShares > _minNodeShares) { + // _withdrawnShares = _nodeShares; + // _pendingWithdrawalRequestsInShares -= _nodeShares; + // } + + if (_nodeShares > _minNodeShares) { + _nodeShares = (_nodeShares > _maxNodesShares) ? _maxNodesShares : _nodeShares; + if (_nodeShares > _pendingWithdrawalRequestsInShares) { + _withdrawnShares = (_nodeShares - _pendingWithdrawalRequestsInShares) < MIN_DELTA ? _nodeShares : _pendingWithdrawalRequestsInShares; - _pendingWithdrawalRequestsInShares = 0; - } else if (_nodeShares > _minNodeShares) { - _withdrawnShares = _nodeShares; - _pendingWithdrawalRequestsInShares -= _nodeShares; + _pendingWithdrawalRequestsInShares = 0; + } else { + _withdrawnShares = _nodeShares; + _pendingWithdrawalRequestsInShares -= _nodeShares; + } } if (_withdrawnShares > 0) {