Source-linked AI summary

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

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

arXiv:2609.11008v1cs.CRcs.AIcs.SE

TL;DR

Existing PMA detectors separately analyze transaction behavior or contract code, leaving the interaction between runtime manipulation sequences and exploited contract semantics under-modeled. DeFiFusion unifies manipulation-aware event encoding, LLM-derived contract semantics, and T5-RPE Transformer fusion, achieving state-of-the-art detection with 98.67% recall and 96.10% precision across real-world datasets.

  • Problem

    Transaction-centric PMA detectors lack contract-execution semantics, while static contract analyses ignore runtime behavior and may identify infeasible vulnerabilities.

  • Method

    DeFiFusion jointly models transaction events and smart contract semantics using manipulation-aware event encoding, LLM-based contract features, and a DPF-Transformer with T5-RPE.

  • Results

    98.67% recall and 96.10% precision were achieved across two real-world datasets, outperforming state-of-the-art methods across all metrics.

  • Takeaways & Limitations

    The unified framework captures cyclic and multi-stage execution patterns for detecting complex price manipulations that evade conventional unimodal approaches.

Abstract

from arXiv · show

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 paradigms suffer from fundamental limitations. Transaction-centric methods lack awareness of contract execution semantics, making them prone to false positives under legitimate market volatility, while static contract analyses ignore real transaction behaviors and frequently report vulnerabilities that are infeasible to exploit in practice. We present DeFiFusion, a dual-modal PMA detection framework that closes this gap by jointly modeling transaction events and smart contract semantics within a unified pipeline. Our core insight is that PMA maliciousness emerges only from the interaction between transaction behaviors and the contract logic they exploit; neither signal suffices in isolation. Accordingly, we derive price-manipulation-aware event encoding for extracting fine-grained temporal and economic features tailored to manipulation patterns. We further introduce LLM-based contract semantic extraction to supply the execution-logic context that prior behavioral methods lack. To fuse these modalities, we propose a Dual-Modal Projection-Fusion Transformer with T5-style relative positional encoding, capturing the cyclic multi-stage execution structures that distinguish PMAs from benign market activity. Extensive experiments demonstrate that DeFiFusion consistently achieves state-of-the-art detection performance, effectively recalling 222 of the 225 PMA cases while maintaining a precision of 96.10%.

I. INTRODUCTION

DeFiFusion addresses the limitations of transaction-only and contract-only PMA detection by jointly modeling transaction events and smart contract semantics. It combines manipulation-aware event encoding, contract-semantic extraction, and multimodal sequence modeling, achieving strong detection results on real-world incidents.

  • I. INTRODUCTION: Transaction-based detectors miss contract semantics, while static analyses ignore runtime behavior and may report vulnerabilities that cannot be triggered in practice.These limitations motivate modeling transaction behavior and contract execution logic together.
  • I. INTRODUCTION: 98.67% recall and 96.10% precision were achieved across two real-world datasets, including 225 verified PMA incidents, outperforming state-of-the-art methods across all metrics.The framework also achieved 100% recall on 18 real-world 2026 PMA events.
  • I. INTRODUCTION: DeFiFusion couples transaction events with smart contract semantics because PMA maliciousness emerges from their interaction rather than either signal alone.The unified pipeline connects dynamic event behavior with static contract analysis.
  • I. INTRODUCTION: The framework uses price-manipulation-aware event encoding to model fine-grained temporal and economic features tailored to manipulation patterns.Its design targets sequential dependencies that distinguish malicious price distortions from normal market fluctuations.
  • I. INTRODUCTION: The study releases a dataset of 225 verified PMA cases from 2020 to 2026 as a benchmark for practical detection research.The dataset is described as the largest and most up-to-date public collection of real-world PMA incidents.

B. Price Manipulation Attack

PMA detection requires identifying complex, cyclic transaction behavior and its relationship to contract logic. DeFiFusion constructs manipulation-aware event representations from temporal, semantic, payload, address, topic, and risk features before multimodal sequence classification.

  • B. Price Manipulation Attack: DeFiFusion extracts transaction and contract features, concatenates them, and classifies the resulting multimodal sequence with a DPF-Transformer equipped with T5-RPE.The pipeline has transaction event extraction, smart contract feature extraction, and multimodal sequence classification phases.
  • B. Price Manipulation Attack: PMA detection targets cyclic, multi-stage transaction patterns that distinguish malicious manipulation from normal market activity.Such patterns can involve flash-loan-driven token injections and contract vulnerabilities based on instantaneous rather than time-weighted prices.
  • B. Price Manipulation Attack: Its event encoding combines basic attributes, manipulation-risk indicators, and global features to represent transaction events involved in PMAs.The event log preserves ordered tuples containing event index, emitting address, event name, topics, and payload data.
  • B. Price Manipulation Attack: The risk model fuses weak indicators across attack patterns, numerical, address, temporal, and multi-source anomalies using fixed weights rather than standalone alarms.Joint consumption means weak signals contribute only when corroborated by magnitude evidence.
  • B. Price Manipulation Attack: Semantic features classify event names into business categories and add substring indicators for transfers, approvals, swaps, mints, burns, price, value, amount, and quantity.Exact matching supplies high-precision semantics, while substring matching handles protocol-specific naming variants.
  • B. Price Manipulation Attack: Topic features capture normalized topic count, multi-party activity, repeated topics, and hashed fingerprints of participating entities.Repeated topics expose circular transfer patterns.
  • B. Price Manipulation Attack: Payload features type values as numeric, address, boolean, string, or empty, then encode magnitudes, formats, lengths, keywords, and hashed addresses.Numeric values use clipping and a saturated logarithmic map to handle extreme ranges while preserving monotonic magnitude information.

2) Core price manipulation risk feature:

DeFiFusion constructs a manipulation-oriented risk feature by combining weak indicators across attack patterns, numerical anomalies, address interactions, temporal anomalies, and multi-source fusion. The design uses joint evidence and fixed weights to produce graded severity signals for complete incident logs.

  • Jointly combining weak indicators across five dimensions yields a graded manipulation-severity score rather than standalone alarms.The dimensions are attack pattern identification, numerical anomalies, address interaction anomalies, temporal anomalies, and multi-source risk fusion.
  • Attack pattern identification: Four magnitude indicators distinguish transfer, flash-loan, wash-trading, and boolean-flagged state-transition patterns.The indicators combine transaction semantics with anomalous magnitude and multi-party topics or state-transition flags.
  • Numerical anomalies: Srisk aggregates out-of-band scale, format, extreme-tail, and digit-repetition risks, with a separate round-number indicator for manually crafted amounts.Each component is binary, and the weighted score forms a convex combination.
  • Numerical anomalies: Within-incident amount volatility uses the absolute Z-score of each payload against the complete event-log history and maps it to [0, 1].The score is zero when fewer than two usable amounts exist, the standard deviation is zero, or the amount is zero.
  • Address interaction anomalies: Address interaction features flag suspicious extreme-volume trades, direct inter-contract flows, and payload-to-emitter self-referential routing.The suspicious-trade indicator requires both a honey-pot-flagged address and an extreme-volume payload.
  • Multi-source risk fusion: High- and medium-tier signals are fused with fixed a priori weights into bounded convex combinations, with the cap binding only when both tiers co-occur.The high-tier fusion includes address entropy and a legitimacy indicator supplies explicit negative evidence.

3) Global feature:

Global features complement local event features with macro-level measures of event structure and payload scale. These measures distinguish structured manipulations and expose execution depth that may be hidden in long transactions.

  • Field filling density separates highly structured malicious manipulations from rudimentary transfers.It measures the proportion of non-null values in an event tuple.
  • Structural payload scale reflects underlying contract-execution depth and exposes manipulation patterns concealed within protracted execution flows.It is based on normalized cumulative character lengths of address, name, and topic fields.
  • Behavioral event features alone cannot distinguish routine arbitrage from exploitation of pools that interrogate instantaneous spot prices.Contract logic supplies the context needed to interpret what happened during execution.

C. Phase 2: Smart Contract Feature Extraction

Phase 2 extracts fixed-dimensional semantic representations of smart contracts using a pretrained LLM. Attention-masked pooling converts context-aware code states into static contract signatures for machine learning.

  • A pretrained LLM encodes high-level contract semantics and long-range function dependencies that conventional graph- or rule-based features struggle to capture.The resulting representations target complex financial logic and sophisticated multi-step behavior.
  • The contract source is tokenized into a bounded sequence, processed with memory-efficient quantization and self-attention to produce context-aware hidden states.The backbone uses 4-bit NormalFloat, double quantization, and BFloat16 inference.
  • Masked average pooling produces a fixed-dimensional contract representation while excluding padding tokens from the semantic signature.Attention-mask weighting ensures that only valid code tokens contribute.

D. Phase 3: Multimodal Feature Sequence Classification

Phase 3 fuses transaction-event and contract representations into a multimodal sequence for PMA classification. A DPF-Transformer with T5-style relative positional encoding models cyclic execution patterns and outputs an incident-level PMA probability.

  • The fused sequence Hm = [He | Hc] lets transaction behaviors be interpreted in the context of underlying contract logic.The model jointly organizes event and contract representations rather than modeling either modality in isolation.
  • The DPF-Transformer uses T5-style relative positional encoding to preserve cyclic execution structure and output the probability that an incident is a PMA.

1) T5-RPE:

T5-RPE replaces absolute position dependence with offset-aware biases that preserve local cyclic execution patterns in fused event-contract sequences. The DPF-Transformer then contextualizes these sequences and produces a single manipulation probability.

  • 1) T5-RPE:: T5-RPE uses relative offsets to capture cyclic execution patterns while remaining invariant to where those patterns occur in the sequence.Offsets within 8 steps are exact, longer offsets are logarithmically bucketed, and large offsets saturate into the final bucket.
  • 1) T5-RPE:: Each fused position concatenates an 80-dimensional event vector with a projected contract embedding, producing a multimodal sequence of width 1104 by default.The event and contract sequences are paired index-wise, with zero-padding applied to the shorter sequence.
  • 2) DPF-Transformer:: The DPF-Transformer applies offset-aware attention to the fused sequence and aggregates contextualized representations into one manipulation probability.It is an encoder-only classifier whose masked readout feeds a bottleneck classification head.
  • 2) DPF-Transformer:: The masked mean excludes padding, while dropout and a bottleneck reduce readout capacity to limit overfitting on scarce verified incidents.Only the projection, bias tables, encoder, and classification head are trained; the LLM backbone remains frozen.
  • 2) DPF-Transformer:: The resulting alignment strategy couples local recurring patterns with global transactional intentions in variable-length event sequences.

IV. EVALUATION

The evaluation compares DeFiFusion with existing detection methods, tests feasibility across real-world PMA datasets, and studies component, hyperparameter, and LLM effects. The study uses verified incidents and carefully selected benign transactions to assess detection and false positives.

  • IV. EVALUATION:: The evaluation addresses SOTA detection, real-world PMA feasibility, hyperparameter and component contributions, and LLM selection.
  • IV. EVALUATION:: D1 contains 225 PMA cases across 6 blockchain networks from 2020–2026, involving $804.3M in cumulative losses.The collection is described as the largest verified public set, reflecting the scarcity of publicly reported PMAs.
  • IV. EVALUATION:: The evaluation therefore combines verified attacks with deliberately selected long benign traces to examine detection performance and false-positive behavior.
  • IV. EVALUATION:: The study retains only real, manually verified incidents because synthetic perturbations could erase attack-specific execution patterns and corrupt labels.This choice prioritizes label fidelity over sample quantity.
  • IV. EVALUATION:: D2 retains 1,150 benign transactions with event sequences longer than six from an initial pool of 428,523 high-value transactions.The selection reduces the opportunity for the model to use sequence length as a shortcut and creates a more rigorous near-balanced evaluation.

B. Implementation

DeFiFusion is implemented and evaluated across six blockchain networks using chronological cross-validation, multiple baselines, and repeated runs. It identifies 222 of 225 PMA cases, while its remaining misses share a concentrated similarity to benign high-value activity.

  • B. Implementation: The experiments use chronological five-fold cross-validation for 225 attacks, with the latest remaining fold used for validation, and ten prediction runs.Benign data are randomly divided into five folds, while an attack is counted as a false negative if missed in any run.
  • B. Implementation: The three false negatives all involve attack traces whose event composition closely resembles benign high-value activity.Majority voting recovers two cases and probability averaging recovers all three, indicating seed-dependent rather than systematic failures.
  • B. Implementation: Every false positive comes from a cluster of nine near-duplicate benign transactions sharing three contracts and elevated swap-event proportions.Seven cluster members produce all false-positive occurrences, while none of the other 1,141 benign samples does.
  • B. Implementation: On 95 attacks benchmarked by DeFiScope, DeFiFusion recalls 93 cases versus 34 for DeFiTainter.On 194 evaluable cases with victim contracts, the contract-side comparison is reported separately.

D. RQ2: PMA Detection Feasibility

A simulated zero-day evaluation tests DeFiFusion on future PMA incidents using temporal separation and component ablations. The fused T5-RPE model recalls all 18 2026 incidents and operates at second-level latency.

  • D. RQ2: PMA Detection Feasibility: The temporal split trains on 2020–2024 incidents, validates on 2025 cases, and tests on 18 authenticated 2026 incidents.This design prevents future-data patterns from entering training and distributes negative samples across the three sets.
  • D. RQ2: PMA Detection Feasibility: 100% recall identifies all 18 authenticated 2026 PMA events across Ethereum, BSC, and Arbitrum in the simulated zero-day setting.The events range from a $3.5K loss to the $1.78M Moonwell2 exploit.
  • D. RQ2: PMA Detection Feasibility: Only the fused model with T5-RPE recalls every incident; event-only, contract-only, and absolute-position variants each miss cases.The two unimodal miss sets are disjoint, while the APE variant misses three incidents recalled by both unimodal models.
  • D. RQ2: PMA Detection Feasibility: Adding feature families progressively separates benign and attack probabilities, with fused event-contract features producing a near-complete bimodal separation.The ablation compares Fbasic, Fbasic + Fcpmr, complete event features He, and fused He + Hc.
  • D. RQ2: PMA Detection Feasibility: Contract semantics are precomputed offline, leaving live monitoring to event-feature extraction and sequence classification with second-level prediction latency.The reported latency falls within modern blockchain confirmation and finalization windows.

1) Incremental Contribution of Feature Families:

The experiments show that richer event features, T5-RPE, and suitable semantic projection improve or preserve DeFiFusion’s detection performance while supporting efficient model choices.

  • Feature-family contribution: Near-complete separation emerges when all three event feature families are fused with contract features.The fused He + Hc configuration produces a clearly bimodal prediction pattern, while separation improves as feature families are added.
  • Positional encoding fitting: T5-RPE yields a smoother optimization landscape and a more direct trajectory to lower final loss than sinusoidal APE.The observed geometry is consistent with T5-RPE’s generalization advantage.
  • LLM backbone sensitivity: All nine LLM backbones achieve comparable detection performance, although larger models produce more concentrated results across seeds.Wilcoxon signed-rank tests indicate lower variability for larger backbones, while overall performance remains relatively insensitive to backbone choice.
  • Projection dimensionality: 1024-dimensional projection preserves all four detection metrics relative to 4096 dimensions, whereas 768 or 512 degrades precision and F1.Projection to 2048 or 1024 shows no significant difference across accuracy, precision, recall, and F1, while smaller projections degrade performance.
  • Pre-computation cost: The default LLM requires 2.04 seconds per protocol for semantic extraction, supporting offline batch processing.Smaller models are generally faster but achieve lower detection performance, and CodeLlama-7B has a wider inference-time range.

V. DISCUSSION

DeFiFusion supports real-time defense through offline contract-semantic extraction but remains constrained by source-code availability and has a specific false-negative failure mode.

  • Operational efficiency: Second-level prediction latency fits within blockchain confirmation and finalization windows, enabling emergency governance actions during attack propagation.Contract features are pre-computed offline, leaving live monitoring to event-feature extraction and sequence classification.
  • Source-code dependence: Unverified or closed-source contracts limit DeFiFusion to unimodal detection because contract semantic features cannot be extracted from disclosed bytecode alone.The paper identifies decompilation and bytecode-based semantic modeling as future directions for mitigating this dependency.
  • Discussion: DeFiFusion bridges transaction behavior and contract logic by jointly modeling their dynamic coupling for price-manipulation detection.Transaction-centric methods miss code-level causes, while contract-centric methods overlook runtime triggers.
  • Discussion: The framework consistently surpasses state-of-the-art methods across accuracy, robustness, and practical effectiveness on two datasets.The evaluation includes 225 newly collected real-world PMA incidents and 1,150 benign transactions.
Loading 2609.11008v1…