The swap when closing a position does not consider shareProfitAmts
When closing a position, token swap is performed to ensure that the closer can repay the debt, for example, when operation == EXACT_IN, tokens of borrowAmt are required to be excluded from the swap, and when operation == EXACT_OUT, tokens of borrowAmt are required to be swapped. The issue here is that the closer needs to pay not only the borrowAmt but also the shareProfitAmts, which causes the closure to fail when percentSwapE18 = 100% due to insufficient tokens. Although the closer can adjust the percentSwapE18 to make the closure successful, it greatly increases the complexity.\\n```\\n        for (uint i; i < swapParams.length; ) {\\n        // find excess amount after repay\\n        uint swapAmt = swapParams[i].operation == SwapOperation.EXACT_IN\\n          ? IERC20(swapParams[i].tokenIn).balanceOf(address(this)) - openTokenInfos[i].borrowAmt\\n             : openTokenInfos[i].borrowAmt - IERC20(swapParams[i].tokenOut).balanceOf(address(this));\\n                 swapAmt = (swapAmt * swapParams[i].percentSwapE18) / ONE_E18\\n                 if (swapAmt == 0) {\\n              revert SwapZeroAmount();\\n             }\\n```\\n
Consider taking shareProfitAmts into account when calculating swapAmt
```\\n        for (uint i; i < swapParams.length; ) {\\n        // find excess amount after repay\\n        uint swapAmt = swapParams[i].operation == SwapOperation.EXACT_IN\\n          ? IERC20(swapParams[i].tokenIn).balanceOf(address(this)) - openTokenInfos[i].borrowAmt\\n             : openTokenInfos[i].borrowAmt - IERC20(swapParams[i].tokenOut).balanceOf(address(this));\\n                 swapAmt = (swapAmt * swapParams[i].percentSwapE18) / ONE_E18\\n                 if (swapAmt == 0) {\\n              revert SwapZeroAmount();\\n             }\\n```\\n