# DeFiFusion: Combining Transaction Events with Smart Contracts to Detect Price Manipulation Attacks

Crypto.world

> DeFi protocols are attacked by adversaries who artificially inflate or deflate token prices through crafted transaction sequences, and existing detectors handle this poorly because they look at only…

**arXiv**: 2609.11008

**Published**: 2026-09-10

**Authors**: Rui Cao, Shaojing Fan, Liming Fang, Yuchan Liu, Yingying Jiao, Zhenguang Liu

## AI summary

## Overview

- **Research area:** Blockchain and DeFi security, specifically the detection of Price Manipulation Attacks (PMAs) using dual-modal machine learning that combines on-chain transaction events with smart contract semantics.
- **Technical level:** Advanced. The paper assumes familiarity with transformer architectures, attention mechanisms, LLM-based code representation, and formal feature engineering for event logs.
- **Scope (one sentence):** The paper proposes DeFiFusion, a three-phase detection framework that fuses price-manipulation-aware event encodings with LLM-derived contract embeddings inside a Dual-Modal Projection-Fusion Transformer with T5-style relative positional encoding, and evaluates it on 225 verified real-world PMA incidents from 2020 to 2026.

## What This Paper Is About

DeFi protocols are attacked by adversaries who artificially inflate or deflate token prices through crafted transaction sequences, and existing detectors handle this poorly because they look at only half the picture: transaction-based monitors see behavior but not the contract logic being exploited, while static contract analyzers see code but not how it is actually exercised. DeFiFusion's goal is to close that gap by modeling both signals in one pipeline, on the premise that maliciousness only becomes visible in the interaction between an adversarial transaction sequence and the specific contract execution semantics it exploits.

## Key Contributions

1. **A framing claim plus a framework.** The authors argue that PMA maliciousness is manifested through the interaction between transaction behaviors and the smart contract semantics they exploit, and they build DeFiFusion to explicitly couple the two modalities in a unified detection pipeline, rather than treating dynamic event behavior and static code analysis as separate tools.
2. **Price-manipulation-aware event encoding.** A purpose-built feature scheme that deconstructs each transaction event into basic features (temporal index, address attributes, event semantics, topics, data payload), core price manipulation risk features (attack pattern identification, numerical anomalies, address interaction anomalies, temporal anomalies, and a fixed-weight multi-source risk fusion), and global features (field filling density, structural payload scale).
3. **The DPF-Transformer with T5-style relative positional encoding.** A Dual-Modal Projection-Fusion Transformer classifier that, for the first time in this domain per the authors, integrates T5-RPE to capture the sequential dependencies and cyclic multi-stage execution structures that distinguish PMAs from benign market activity.
4. **A released dataset of 225 verified PMA cases (2020–2026).** Described as the largest and most up-to-date public collection of real-world PMA incidents, spanning 6 blockchain networks and a cumulative financial loss of $804.3M, intended as a benchmark for the research community.

## Main Findings

- **Headline detection performance:** DeFiFusion reports precision of 96.10% and recall of 98.67%, which the authors describe as outperforming state-of-the-art methods across all metrics.
- **Recall in absolute counts:** The model correctly recalls 222 of the 225 PMA cases in the dataset.
- **Forward-looking evaluation:** On 2026 DeFi activity, DeFiFusion attains 100% recall on 18 real-world PMA incidents, which the authors present as evidence of practicality for real-world security monitoring.
- **Baselines compared:** The evaluation pits DeFiFusion against DeFiRanger (DR), DeFort (DF), and DeFiScope (DS). The per-protocol, per-case comparison table (Table II) is truncated in the supplied content, so the individual baseline scores are not reported here.
- **Dual-modality rationale:** Transaction-centric methods are characterized as semantically blind black-box monitors prone to false positives under legitimate market volatility, while static analyses are characterized as reporting theoretical vulnerabilities that are infeasible to exploit in practice.
- **Dataset composition:** The attack dataset contains 225 DeFi applications across 6 blockchain networks (Arbitrum, Avalanche, Base, BNB Chain, Ethereum, Polygon). The benign dataset starts from 428,523 high-value benign transactions across 435 DeFi applications and retains all 1,150 benign transactions whose event sequences exceed length 6, deliberately making evaluation near-balanced and preventing the model from using sequence length as a heuristic.
- **Deliberate rejection of augmentation:** The authors state they refused synthetic perturbation of manipulation traces because it can erase the precise execution patterns that define an attack, prioritizing label fidelity over sample quantity.
- **Default language model:** DeepSeek-Coder-7B-Instruct-v1.5, kept frozen during training.
- **Not reported in the available text:** The results of the hyperparameter/ablation study (RQ3) and the comparison across different LLM backbones (RQ4) are posed as research questions but their numerical outcomes fall in the truncated portion of the paper. The same applies to the per-protocol breakdown in Table II.

## Methodology in Plain English

The pipeline has three phases.

**Phase 1 — Reading the transaction trail.** The system takes an incident's ordered event log and turns each event into a rich numeric vector. Some features are simple bookkeeping: a normalized position in the log, fingerprints of addresses via two SHA-256 projections, the length of the address, an indicator that the address looks like a contract, and the Shannon entropy of the address's hex characters (used to separate vanity or honey-pot addresses with long repeated runs from ordinary ones). Events are sorted into 12 business-level categories by dictionary matching, with a redundant layer of substring matches for keywords like Transfer, Approval, Swap, Trade, Exchange, and mint/burn. Numeric payloads are clipped and log-compressed to tame roughly 60 orders of magnitude of raw token amounts.

On top of this, the authors build a hand-designed risk model across five dimensions. Rather than firing alarms on single weak signals, it combines them: a manipulation-pattern indicator requires transfer semantics together with an extreme magnitude and multi-party topics; a flash-loan indicator requires swap semantics with extreme-tail volume; a wash-trading indicator requires ordinary-sized multi-party transfers; amount volatility is scored as a 3σ-style Z-score against the incident's own history; address-interaction anomalies cover honey-pot-flagged extreme transfers, contract-to-contract flows, and self-referential payload routing; temporal density captures high-frequency probing. These are merged with fixed a priori weights, so no labeled attack data is needed to construct the risk feature. A legitimacy indicator gives the model an explicit negative-evidence channel.

**Phase 2 — Reading the contract.** Contract source code is tokenized and fed through a frozen pretrained LLM (DeepSeek-Coder-7B-Instruct-v1.5 by default), compressed with 4-bit NormalFloat and double quantization and run in BFloat16. Because padding tokens would dilute a naive average, the authors use attention-masked average pooling to produce a fixed-size contract signature from only the real code tokens.

**Phase 3 — Fusing and classifying.** Event vectors (80 dimensions) are concatenated with a learnable projection of the contract embedding into 1024 dimensions, giving a fused width of 1104. Because cyclic patterns like recursive funding or cyclic arbitrage care about relative offsets rather than absolute positions, the transformer uses T5-style relative positional encoding: a learnable per-head bias table indexed by bucketed offsets, with 16 buckets per direction, exact resolution within 8 steps, logarithmic growth up to 128, and saturation beyond that. The whole table is only 32 × 8 = 256 scalars, independent of sequence length and model width. Eight attention heads are used, and a padding mask keeps batch padding out of both attention and readout. An encoder-only classifier aggregates the sequence with a masked mean, passes it through a bottleneck head (halving the representation, with dropout) as an overfitting guard given the scarcity of verified incidents, and outputs a manipulation probability; an incident is flagged when the probability crosses a threshold θ. Only the projection, bias tables, encoder, and head are trained.

## Why This Matters

**Impact on research.** The paper reframes PMA detection as a multimodal fusion problem and supplies a benchmark of 225 verified incidents spanning 2020 to 2026, which is the kind of resource that lets competing methods be compared on real rather than synthetic traces. The use of frozen-LLM contract embeddings as a semantic channel is also a template for other smart-contract vulnerability classes.

**Real-world applications:**

- **Protocol security triage:** DeFiFusion supports 6 mainstream networks (Arbitrum, Avalanche, Base, BNB Chain, Ethereum, Polygon), so a protocol team can score incidents across its deployments rather than building chain-specific rules.
- **Post-incident forensics:** Because the model classifies complete event logs rather than streaming partial state, it fits post-hoc analysis of a suspected exploit.
- **Exchange and custodian monitoring:** A 96.10% precision operating point with 222 of 225 attacks recalled is the kind of trade-off relevant to teams that cannot afford to chase large volumes of false alarms.
- **Risk scoring and insurance:** A per-incident probability output with fixed, label-free risk features can feed underwriting or exposure scoring even where labeled attack data is scarce.

**Industry relevance.** With DeFi Total Value Locked consistently exceeding $120 billion as of early 2026 and PMA losses measured in billions of dollars, the paper's core practical claim is that reducing false positives relative to behavior-only monitors, while filtering out the infeasible findings that plague static analysis, makes automated monitoring deployable rather than advisory.

## Future Directions

- **Streaming and real-time detection.** The authors explicitly frame the current design as post-hoc forensic analysis rather than streaming monitoring; adapting the temporal-density and sequence-modeling components to live traffic is the natural next step.
- **Scaling the labeled corpus.** The 225-case dataset is attributed to the scarcity of publicly reported PMAs rather than collection effort, and the authors reject synthetic augmentation; growing the set with verified incidents, and extending coverage beyond 2020–2026, would strengthen generalization claims.
- **Systematic LLM backbone comparison.** RQ4 asks how the choice of LLM for contract feature extraction affects performance, leaving open how alternatives to DeepSeek-Coder-7B-Instruct-v1.5 compare on accuracy, memory, and latency.
- **Generalization to unseen attack families and protocols.** The forward-looking result of 100% recall on 18 incidents from 2026 suggests temporal robustness, but whether the cyclic-pattern inductive bias transfers to genuinely new manipulation archetypes remains an open question.

## Target Audience

Researchers and graduate students working on blockchain security, smart contract vulnerability detection, or multimodal sequence modeling; security engineers and auditors at DeFi protocols, exchanges, and custodial firms who need automated incident triage; and risk or data teams at insurance and compliance organizations who must score DeFi exposure. Readers without a background in transformer attention mechanics or event-log semantics will find the methodology section dense, so the paper is best suited to those with intermediate-to-advanced familiarity with machine learning for code and on-chain data.

## Authors’ abstract

Decentralized Finance (DeFi) has emerged as a rapidly growing blockchain-based financial service, where market transaction dynamics and underlying smart contract logic are intricately intertwined. This autonomous interplay, while eliminating centralized intermediaries, significantly expands the vulnerability surface of DeFi protocols to Price Manipulation Attacks (PMAs), which have already inflicted catastrophic financial losses. Despite their gravity, existing detection…

[The full abstract on arXiv](https://arxiv.org/abs/2609.11008)

[Read the original paper](https://arxiv.org/abs/2609.11008)

---

Canonical: https://crypto.world/paper/defifusion-combining-transaction-events-with-smart-contracts-to-detect-2609.11008
