resolveQueuedTrades() ERC777 re-enter to steal funds
_openQueuedTrade() does not follow the “Checks Effects Interactions” principle and may lead to re-entry to steal the funds\\nThe prerequisite is that tokenX is ERC777 e.g. “sushi”\\nresolveQueuedTrades() call _openQueuedTrade()\\nin _openQueuedTrade() call "tokenX.transfer(queuedTrade.user)" if (revisedFee < queuedTrade.totalFee) before set queuedTrade.isQueued = false;\\n```\\n    function _openQueuedTrade(uint256 queueId, uint256 price) internal {\\n// rest of code\\n        if (revisedFee < queuedTrade.totalFee) {\\n            tokenX.transfer( //***@audit call transfer , if ERC777 , can re-enter ***/\\n                queuedTrade.user,\\n                queuedTrade.totalFee - revisedFee\\n            );\\n        }\\n\\n        queuedTrade.isQueued = false;  //****@audit  change state****/\\n    }\\n```\\n\\n3.if ERC777 re-enter to #cancelQueuedTrade() to get tokenX back,it can close, because queuedTrade.isQueued still equal true 4. back to _openQueuedTrade() set queuedTrade.isQueued = false 5.so steal tokenX
follow “Checks Effects Interactions”\\n```\\n    function _openQueuedTrade(uint256 queueId, uint256 price) internal {\\n// rest of code\\n+      queuedTrade.isQueued = false; \\n        // Transfer the fee to the target options contract\\n        IERC20 tokenX = IERC20(optionsContract.tokenX());\\n        tokenX.transfer(queuedTrade.targetContract, revisedFee);\\n\\n-       queuedTrade.isQueued = false; \\n        emit OpenTrade(queuedTrade.user, queueId, optionId);\\n    }\\n```\\n
if tokenX equal ERC777 can steal token
```\\n    function _openQueuedTrade(uint256 queueId, uint256 price) internal {\\n// rest of code\\n        if (revisedFee < queuedTrade.totalFee) {\\n            tokenX.transfer( //***@audit call transfer , if ERC777 , can re-enter ***/\\n                queuedTrade.user,\\n                queuedTrade.totalFee - revisedFee\\n            );\\n        }\\n\\n        queuedTrade.isQueued = false;  //****@audit  change state****/\\n    }\\n```\\n