Unnecessary Matching in Unstake Process
Function `unstakeProcessed` in `StakedLyxToken` contract, when `unstakeAmount > totalPendingUnstake`, all the unstake requests should be able to be processed, thus no need to go through the matching, as a result, extra gas in the matching can be saved.\\n```\\nif (unstakeAmount > totalPendingUnstake) {\\n pool.receiveWithoutActivation{value: unstakeAmount - totalPendingUnstake}();\\n unstakeAmount = totalPendingUnstake;\\n}\\n\\ntotalPendingUnstake -= unstakeAmount;\\ntotalUnstaked += unstakeAmount;\\nuint256 amountToFill = unstakeAmount;\\n\\nfor (uint256 i = unstakeRequestCurrentIndex; i <= unstakeRequestCount; i++) {\\n UnstakeRequest storage request = \\_unstakeRequests[i];\\n if (amountToFill > (request.amount - request.amountFilled)) {\\n amountToFill -= (request.amount - request.amountFilled);\\n continue;\\n } else {\\n if (amountToFill == (request.amount - request.amountFilled) && i < unstakeRequestCount) {\\n unstakeRequestCurrentIndex = i + 1;\\n } else {\\n request.amountFilled += uint128(amountToFill);\\n unstakeRequestCurrentIndex = i;\\n }\\n break;\\n }\\n}\\n```\\n
Put the matching part (line 393-411) into else branch of `if unstakeAmount > totalPendingUnstake`, change the if branch into following:\\n```\\nif (unstakeAmount > totalPendingUnstake) {\\n            pool.receiveWithoutActivation{value: unstakeAmount - totalPendingUnstake}();\\n            unstakeAmount = totalPendingUnstake;\\n            totalPendingUnstake = 0;\\n            unstakeRequestCurrentIndex = unstakeRequestCount;\\n            _unstakeRequests[unstakeRequestCount].amountFilled = _unstakeRequests[unstakeRequestCount].amount;\\n } \\n```\\n
```\\nif (unstakeAmount > totalPendingUnstake) {\\n pool.receiveWithoutActivation{value: unstakeAmount - totalPendingUnstake}();\\n unstakeAmount = totalPendingUnstake;\\n}\\n\\ntotalPendingUnstake -= unstakeAmount;\\ntotalUnstaked += unstakeAmount;\\nuint256 amountToFill = unstakeAmount;\\n\\nfor (uint256 i = unstakeRequestCurrentIndex; i <= unstakeRequestCount; i++) {\\n UnstakeRequest storage request = \\_unstakeRequests[i];\\n if (amountToFill > (request.amount - request.amountFilled)) {\\n amountToFill -= (request.amount - request.amountFilled);\\n continue;\\n } else {\\n if (amountToFill == (request.amount - request.amountFilled) && i < unstakeRequestCount) {\\n unstakeRequestCurrentIndex = i + 1;\\n } else {\\n request.amountFilled += uint128(amountToFill);\\n unstakeRequestCurrentIndex = i;\\n }\\n break;\\n }\\n}\\n```\\n