Escrow record not cleared on cancellation and order fill
In `DirectBuyIssuer.sol`, a market buy requires the operator to take the payment token as escrow prior to filling the order. Checks are in place so that the math works out in terms of how much escrow has been taken vs the order's remaining fill amount. However, if the user cancels the order or fill the order, the escrow record is not cleared.\\nThe escrow record will exists as a positive amount which can lead to accounting issues.\\nTake the following example:\\nOperator broadcasts a `takeEscrow()` transaction around the same time that the user calls `requestCancel()` for the order\\nOperator also broadcasts a `cancelOrder()` transaction\\nIf the `cancelOrder()` transaction is mined before the `takeEscrow()` transaction, then the contract will transfer out token when it should not be able to.\\n`takeEscrow()` simply checks that the `getOrderEscrow[orderId]` is less than or equal to the requested amount:\\n```\\n        bytes32 orderId = getOrderIdFromOrderRequest(orderRequest, salt);\\n        uint256 escrow = getOrderEscrow[orderId];\\n        if (amount > escrow) revert AmountTooLarge();\\n\\n\\n        // Update escrow tracking\\n        getOrderEscrow[orderId] = escrow - amount;\\n        // Notify escrow taken\\n        emit EscrowTaken(orderId, orderRequest.recipient, amount);\\n\\n\\n        // Take escrowed payment\\n        IERC20(orderRequest.paymentToken).safeTransfer(msg.sender, amount);\\n```\\n\\nCancelling the order does not clear the `getOrderEscrow` record:\\n```\\n    function _cancelOrderAccounting(OrderRequest calldata order, bytes32 orderId, OrderState memory orderState)\\n        internal\\n        virtual\\n        override\\n    {\\n        // Prohibit cancel if escrowed payment has been taken and not returned or filled\\n        uint256 escrow = getOrderEscrow[orderId];\\n        if (orderState.remainingOrder != escrow) revert UnreturnedEscrow();\\n\\n\\n        // Standard buy order accounting\\n        super._cancelOrderAccounting(order, orderId, orderState);\\n    }\\n}\\n```\\n\\nThis can lead to an good-faith and trusted operator accidentally taking funds from the contract that should not be able to leave.\\ncoming up with the fact that the transaction does not have deadline or expiration date:\\nconsider the case below:\\na good-faith operator send a transaction, takeEscrow\\nthe transaction is pending in the mempool for a long long long time\\nthen user fire a cancel order request\\nthe operator help user cancel the order\\nthe operator send a transcation cancel order\\ncancel order transaction land first\\nthe takeEscrow transaction lands\\nbecause escrow state is not clear up, the fund (other user's fund) is taken\\nIt's also worth noting that the operator would not be able to call `returnEscrow()` because the order state has already been cleared by the cancellation. `getRemainingOrder()` would return 0.\\n```\\n    function returnEscrow(OrderRequest calldata orderRequest, bytes32 salt, uint256 amount)\\n        external\\n        onlyRole(OPERATOR_ROLE)\\n    {\\n        // No nonsense\\n        if (amount == 0) revert ZeroValue();\\n        // Can only return unused amount\\n        bytes32 orderId = getOrderIdFromOrderRequest(orderRequest, salt);\\n        uint256 remainingOrder = getRemainingOrder(orderId);\\n        uint256 escrow = getOrderEscrow[orderId];\\n        // Unused amount = remaining order - remaining escrow\\n        if (escrow + amount > remainingOrder) revert AmountTooLarge();\\n```\\n
Clear the escrow record upon canceling the order.
Issue Escrow record not cleared on cancellation and order fill\\nInsolvency due to pulling escrow that should not be allowed to be taken
```\\n        bytes32 orderId = getOrderIdFromOrderRequest(orderRequest, salt);\\n        uint256 escrow = getOrderEscrow[orderId];\\n        if (amount > escrow) revert AmountTooLarge();\\n\\n\\n        // Update escrow tracking\\n        getOrderEscrow[orderId] = escrow - amount;\\n        // Notify escrow taken\\n        emit EscrowTaken(orderId, orderRequest.recipient, amount);\\n\\n\\n        // Take escrowed payment\\n        IERC20(orderRequest.paymentToken).safeTransfer(msg.sender, amount);\\n```\\n