StateGuard is a deep learning-based framework designed to detect state derailment defects in decentralized exchange (DEX) smart contracts. These defects can lead to incorrect, incomplete, or unauthorized changes to the system state during contract execution, posing security risks. The framework constructs an Abstract Syntax Tree (AST) of the smart contract, extracting key features to generate a graph representation. It then uses a Graph Convolutional Network (GCN) to identify defects. Evaluations on 46 DEX projects with 5,671 smart contracts showed a precision of 92.24%. STATEGUARD was also used to audit real-world contracts, successfully identifying multiple novel CVEs. The framework's contributions include the first systematic study of state defects in DEX smart contracts, the proposal of STATEGUARD, and comprehensive evaluation with high F1-score and accuracy. STATEGUARD outperformed existing tools in detection metrics and successfully identified real-world defects. The framework converts smart contract code into an AST, extracts features, processes the data into a graph, and uses GCN for defect detection. The method demonstrated high precision and recall, with effective detection of state derailment defects in both public datasets and real-world contracts. The study highlights the importance of addressing state-related defects in DEX smart contracts to ensure security and reliability.StateGuard is a deep learning-based framework designed to detect state derailment defects in decentralized exchange (DEX) smart contracts. These defects can lead to incorrect, incomplete, or unauthorized changes to the system state during contract execution, posing security risks. The framework constructs an Abstract Syntax Tree (AST) of the smart contract, extracting key features to generate a graph representation. It then uses a Graph Convolutional Network (GCN) to identify defects. Evaluations on 46 DEX projects with 5,671 smart contracts showed a precision of 92.24%. STATEGUARD was also used to audit real-world contracts, successfully identifying multiple novel CVEs. The framework's contributions include the first systematic study of state defects in DEX smart contracts, the proposal of STATEGUARD, and comprehensive evaluation with high F1-score and accuracy. STATEGUARD outperformed existing tools in detection metrics and successfully identified real-world defects. The framework converts smart contract code into an AST, extracts features, processes the data into a graph, and uses GCN for defect detection. The method demonstrated high precision and recall, with effective detection of state derailment defects in both public datasets and real-world contracts. The study highlights the importance of addressing state-related defects in DEX smart contracts to ensure security and reliability.