The withdrawUnstakedTokens may run out of gas
The `withdrawUnstakedTokens` is iterating over all batches of unstaked tokens. One user, if unstaked many times, could get their tokens stuck in the contract.\\n```\\nfunction withdrawUnstakedTokens(address staker)\\n public\\n virtual\\n override\\n whenNotPaused\\n{\\n require(staker == \\_msgSender(), "LQ20");\\n uint256 \\_withdrawBalance;\\n uint256 \\_unstakingExpirationLength = \\_unstakingExpiration[staker]\\n  .length;\\n uint256 \\_counter = \\_withdrawCounters[staker];\\n for (\\n  uint256 i = \\_counter;\\n  i < \\_unstakingExpirationLength;\\n  i = i.add(1)\\n ) {\\n  //get getUnstakeTime and compare it with current timestamp to check if 21 days + epoch difference has passed\\n  (uint256 \\_getUnstakeTime, , ) = getUnstakeTime(\\n   \\_unstakingExpiration[staker][i]\\n  );\\n  if (block.timestamp >= \\_getUnstakeTime) {\\n   //if 21 days + epoch difference has passed, then add the balance and then mint uTokens\\n   \\_withdrawBalance = \\_withdrawBalance.add(\\n    \\_unstakingAmount[staker][i]\\n   );\\n   \\_unstakingExpiration[staker][i] = 0;\\n   \\_unstakingAmount[staker][i] = 0;\\n   \\_withdrawCounters[staker] = \\_withdrawCounters[staker].add(1);\\n  }\\n }\\n\\n require(\\_withdrawBalance > 0, "LQ21");\\n emit WithdrawUnstakeTokens(staker, \\_withdrawBalance, block.timestamp);\\n \\_uTokens.mint(staker, \\_withdrawBalance);\\n}\\n```\\n
Resolution\\nComment from pSTAKE Finance team:\\nHave implemented a batchingLimit variable which enforces a definite number of iterations during withdrawal of unstaked tokens, instead of indefinite iterations.\\nLimit the number of processed unstaked batches, and possibly add pagination.
```\\nfunction withdrawUnstakedTokens(address staker)\\n public\\n virtual\\n override\\n whenNotPaused\\n{\\n require(staker == \\_msgSender(), "LQ20");\\n uint256 \\_withdrawBalance;\\n uint256 \\_unstakingExpirationLength = \\_unstakingExpiration[staker]\\n  .length;\\n uint256 \\_counter = \\_withdrawCounters[staker];\\n for (\\n  uint256 i = \\_counter;\\n  i < \\_unstakingExpirationLength;\\n  i = i.add(1)\\n ) {\\n  //get getUnstakeTime and compare it with current timestamp to check if 21 days + epoch difference has passed\\n  (uint256 \\_getUnstakeTime, , ) = getUnstakeTime(\\n   \\_unstakingExpiration[staker][i]\\n  );\\n  if (block.timestamp >= \\_getUnstakeTime) {\\n   //if 21 days + epoch difference has passed, then add the balance and then mint uTokens\\n   \\_withdrawBalance = \\_withdrawBalance.add(\\n    \\_unstakingAmount[staker][i]\\n   );\\n   \\_unstakingExpiration[staker][i] = 0;\\n   \\_unstakingAmount[staker][i] = 0;\\n   \\_withdrawCounters[staker] = \\_withdrawCounters[staker].add(1);\\n  }\\n }\\n\\n require(\\_withdrawBalance > 0, "LQ21");\\n emit WithdrawUnstakeTokens(staker, \\_withdrawBalance, block.timestamp);\\n \\_uTokens.mint(staker, \\_withdrawBalance);\\n}\\n```\\n