AI Engine Architecture

The AI engine in SafeFi serves as the core intelligence layer that enables real-time risk evaluation, anomaly detection, and autonomous mitigation. It is designed to be modular, self-adaptive, and interpretable by the community.

Model Stack

  • Transformer x BERT for Solidity: Custom fine-tuned language models extract the logic and intent from smart contract source code or bytecode. These models help the AI assess function structures, detect unusual permissions, and predict exploit vectors.

  • Temporal GNNs (Graph Neural Networks): Used to model the temporal flow of transactions and function calls across multiple blocks. Helps uncover long-tail exploit sequences or time-based logic flaws (e.g., delayed withdrawal traps).

  • Isolation Forest: A classical unsupervised anomaly detection algorithm that isolates rare events from normal behavior. Deployed on live user wallet activities to detect suspicious interaction patterns.

  • Autoencoder Clusters: Unsupervised models trained to detect novel threats not seen in historical exploit data. When deviations from compressed baseline behavior are observed, the AI flags potential zero-day exploits.

  • Ensemble Layer: Combines outputs from all models and assigns a confidence score using logistic regression, with weighted voting adapted based on protocol context (e.g., lending vs AMM).

Threat Intelligence Sources

  • GitHub CVEs (Exploit database)

  • Cyfrin Base audits

  • Runtime attacker simulations (fuzzing + symbolic exec)

AI Feedback Loop

  • User responses on flagged alerts improve precision (human-in-the-loop model)

  • Governance votes can adjust model weightings & thresholds

Last updated