Liquidity withdrawal can be blocked
The main problem in that issue is that the liquidity provider may face many potential issues when withdrawing the liquidity. Under some circumstances, a normal user will never be able to withdraw the liquidity. This issue consists of multiple factors that are interconnected and share the same solution.\\nThere are no partial withdrawals when in the queue. When the withdrawal request is added to the queue, it can only be processed fully:\\n```\\naddress \\_currentAddr = withdrawalQueue.head();\\nuint256 \\_tokensToWithdraw = withdrawalsInfo[\\_currentAddr].withdrawalAmount;\\n \\nuint256 \\_amountInDAI = convertDAIXtoDAI(\\_tokensToWithdraw);\\n \\nif (\\_availableLiquidity < \\_amountInDAI) {\\n  break;\\n}\\n```\\n\\nBut when the request is not in the queue, it can still be processed partially, and the rest of the locked tokens will wait in the queue.\\n```\\n} else if (\\_availableLiquidity < convertDAIXtoDAI(\\_tokensToWithdraw)) {\\n  uint256 \\_availableDAIxTokens = convertDAIToDAIx(\\_availableLiquidity);\\n  uint256 \\_currentWithdrawalAmount = \\_tokensToWithdraw.sub(\\_availableDAIxTokens);\\n  withdrawalsInfo[\\_msgSender()].withdrawalAmount = \\_currentWithdrawalAmount;\\n \\n  aggregatedQueueAmount = aggregatedQueueAmount.add(\\_currentWithdrawalAmount);\\n  withdrawalQueue.push(\\_msgSender());\\n \\n  \\_withdrawLiquidity(\\_msgSender(), \\_availableDAIxTokens);\\n} else {\\n```\\n\\nIf there's a huge request in the queue, it can become a bottleneck that does not allow others to withdraw even if there is enough free liquidity.\\nWithdrawals can be blocked forever by the bots.\\nThe withdrawal can only be requested if there are enough free funds in the contract. But once these funds appear, the bots can instantly buy a policy, and for the normal users, it will be impossible to request the withdrawal. Even when a withdrawal is requested and then in the queue, the same problem appears at that stage.\\nThe policy can be bought even if there are pending withdrawals in the queue.
One of the solutions would be to implement the following changes, but the team should thoroughly consider them:\\nAllow people to request the withdrawal even if there is not enough liquidity at the moment.\\nDo not allow people to buy policies if there are pending withdrawals in the queue and cannot be executed.\\n(Optional) Even when the queue is empty, do not allow people to buy policies if there is not enough liquidity for the pending requests (that are not yet in the queue).\\n(Optional if the points above are implemented) Allow partial executions of the withdrawals in the queue.
```\\naddress \\_currentAddr = withdrawalQueue.head();\\nuint256 \\_tokensToWithdraw = withdrawalsInfo[\\_currentAddr].withdrawalAmount;\\n \\nuint256 \\_amountInDAI = convertDAIXtoDAI(\\_tokensToWithdraw);\\n \\nif (\\_availableLiquidity < \\_amountInDAI) {\\n  break;\\n}\\n```\\n