Skip to content

Commit

Permalink
feat: add maxShares so we can rebalance
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnyonline committed Nov 7, 2024
1 parent 9ae9f52 commit bcfdf09
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions src/ynEIGEN/withdrawalsProcessor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit bcfdf09

Please sign in to comment.