Skip to content
Crypto.world

Research

LiquiLM: Bridging the Semantic Gap in Liquidity Flaw Audit via DCN and LLMs

Smart contracts in DeFi and PoL systems manage staking, reward calculation, and value pegging, and mistakes in that logic can drain or destabilize liquidity.

LiquiLM: Bridging the Semantic Gap in Liquidity Flaw Audit via DCN and LLMs
arXiv
2604.03860
Published
2026-04-04
Authors
Zekai Liu, Xiaoqi Li, Wenkai Li, Zongwei Li

AI summary

Overview

Research area: Blockchain security / smart contract auditing, specifically detecting economic ("liquidity") logic flaws in Proof-of-Liquidity (PoL) and DeFi contracts, using a hybrid of deep learning (a Dynamic Co-Attention Network, DCN) and Large Language Models (LLMs).

Technical level: Advanced. The paper assumes familiarity with DeFi consensus mechanisms, Solidity, transformer-style attention architectures, and multi-label classification losses.

Scope: A single paper proposing and empirically evaluating LiquiLM, a three-module pipeline that pre-filters contract code slices with a DCN and then guides an LLM through a four-phase prompting protocol to produce auditable flaw reports.

What This Paper Is About

Smart contracts in DeFi and PoL systems manage staking, reward calculation, and value pegging, and mistakes in that logic can drain or destabilize liquidity. Unlike classic bugs such as reentrancy, these "liquidity flaws" have no fixed code signature — they are semantic mismatches between what the code does and what the protocol's liquidity intent is — so pattern-matching, fuzzing, and formal verification all struggle.

The paper's goal is to close that semantic gap by having a DCN first align code slices against written flaw descriptions (discarding most safe code), then having an LLM audit only the surviving candidates under a strictly constrained, multi-phase prompt system that produces interpretable reports rather than raw flags.

Key Contributions

  1. The LiquiLM framework itself — the authors state that, to their best knowledge, this is the first framework to combine LLMs with DCN technology specifically for analyzing and optimizing liquidity flaws in PoL smart contracts.

  2. A formal taxonomy of liquidity flaws split into endogenous flaws (Logic Implementation Flaws, Business Protocol Flaws, Governance Authority Risks) and exogenous flaws (Liquidity Valuation Distortion, Transient Liquidity Shock), each with a definition and mechanism in Table 1.

  3. A Four-Phase Collaborative Prompt System that walks the LLM through identification and dispatching, false-positive elimination, false-negative mining, and integration and arbitration, with a feedback loop between the arbitration and review phases.

  4. Empirical validation on 1,490 contracts (reported in the abstract), plus an in-the-wild audit of 1,380 PoL and Ethereum economic contracts that surfaced 238 high-risk contracts and assisted in discovering 10 vulnerabilities that received CVE certification.

Main Findings

  • DCN as a pre-filter: The paper reports the DCN "accurately identifies and filters out over 90% of safe slices," compressing the LLM's search space and mitigating cost and latency in large-scale auditing. Exact DCN precision/recall numbers from Exp.1 are not available in the provided text, which truncates mid-sentence in the Exp.1 discussion.

  • LLM audit performance (abstract): On 1,490 validation contracts, measured across precision, recall, specificity, and F1-score, LiquiLM achieves F1-scores above 90% with both Gemini 3 Pro and GPT-4o as backbone models.

  • Performance figures in the introduction: Powered by Gemini 3 Pro, LiquiLM is reported to achieve recall exceeding 86% and F1-score above 84% across both liquidity flaws and traditional vulnerabilities. (Note: this is a different figure from the "above 90% F1" in the abstract; the paper does not reconcile the two in the provided text.)

  • Real-world audit results: Across 1,380 real-world PoL (Berachain) and Ethereum Mainnet contracts, the framework identified 238 high-risk contracts and assisted in discovering 10 vulnerabilities that received CVE certification.

  • Dataset scale: 650 liquidity-flaw contracts (9 public sources including the OWASP Smart Contract Top 10) yielding 7,144 slices; 840 traditional-vulnerability contracts from SCV-1-2000 yielding 9,011 slices; 1,380 real-world contracts yielding 12,538 slices.

  • Data quality control: 290 contracts required repair during compilability verification and 30 during existence verification, with all 1,490 retained in the final set.

Methodology in Plain English

Step 1 — Clean the code up. Each Solidity contract is stripped of comments and blank lines, then cut into per-function "slices." A slice keeps only the function plus the state variables and modifiers it actually touches (dependency-aware slicing). Identifiers are then renamed to abstract placeholders so the model learns structure rather than being biased by variable names. Everything is encoded with the BGE-M3 encoder into vectors of sequence length 512 and dimension 1024. In parallel, a "semantic corpus" of written liquidity-flaw descriptions is encoded the same way.

Step 2 — Match code against flaw descriptions. A DCN shrinks both vectors to a 256-dimensional latent space and runs multi-layer attention where the code slice is the query and the flaw description is the key/value. Regions of code semantically close to a flaw description get amplified. Two pooling channels then summarize the result — max pooling to catch the sharpest flaw-triggering signal, average pooling to capture overall functional intent — and a small MLP outputs an independent probability per flaw type. Because flawed slices are rare, training uses a weighted binary cross-entropy loss with the penalty coefficient α set to 6.0 to punish missed flaws (false negatives) harder.

Step 3 — Decide what reaches the LLM. A two-stage confidence filter triages slices: probabilities at or above τ_high = 0.3 are kept outright; below τ_low = 0.001 they are discarded as noise; the ambiguous middle band gets a second test using a Peak-to-Noise Ratio that requires the slice's score to be at least 10× the background noise level (τ_pnr = 10). What survives becomes the Audit-Informed Manifest (AIM), carrying both the aligned slices and their predicted probabilities as credibility hints.

Step 4 — Make the LLM behave. The LLM never free-associates over raw code. It follows four phases: it parses the manifest and routes slices by confidence; one branch reviews flagged flaws to kill false positives while another scans broadly to catch false negatives; a final phase arbitrates disagreements and can send disputed items back for re-review. Outputs are structured JSON, and flaws are labeled [Confirmed] only after surviving review — otherwise [Suspicious].

Why This Matters

For research: The paper reframes smart contract auditing as a retrieval-then-reasoning problem. Rather than prompting an LLM with entire contracts (hallucination, cost) or relying on fixed bug signatures (blind to economic logic), it puts a trained, task-specific model in front of the LLM as a semantic router. The two named failure modes — information scarcity leading to off-topic answers, and information overload leading to hallucination — are a useful framing for anyone building LLM pipelines over code.

Real-world applications:

  • DeFi protocol pre-deployment audits: screening lending and trading contracts for incentive-logic errors before they hold user funds.
  • PoL and staking ecosystem monitoring: continuous audit of reward-calculation and staking-lifecycle contracts, the categories the paper groups as endogenous flaws.
  • Oracle and price-feed risk review: catching Liquidity Valuation Distortion, where on-chain value diverges from market price because of manipulated or delayed data.
  • Governance review: flagging Governance Authority Risks where compromised control could drain assets.
  • Bug-bounty triage: using the [Confirmed] / [Suspicious] labels to prioritize which reported issues humans investigate first.

Industry relevance: The 10 CVE-certified findings and 238 flagged high-risk contracts give the work a practical hook; audit firms and security teams care about reducing false positives and about getting a written rationale alongside each flag, which the JSON report format provides.

Future Directions

  • Reconciling and disclosing full evaluation numbers. The provided text stops during Exp.1, so DCN precision, recall, and the complete ablation of AIM and the Four-Phase Prompt System (Exp.2) and the head-to-head comparison with baseline tools (Exp.3) remain to be examined.

  • Generalizing beyond Berachain and Ethereum. Whether the semantic corpus and DCN transfer to other PoL implementations, Layer 2s, or non-EVM chains is untested in what is shown here.

  • Reducing dependence on curated flaw descriptions. The corpus I₂ is built by manual filtering plus AI-assisted generation; how sensitive detection is to gaps or bias in that corpus is an open question the paper raises but does not answer.

  • Cost and latency at scale. The paper claims DCN filtering mitigates cost and latency bottlenecks, but per-contract inference cost for the full pipeline is not reported in the provided content.

  • Adversarial robustness and drift. Liquidity flaws are economically motivated and evolve; whether the DCN's learned alignments stay valid as attack patterns shift is not addressed.

Target Audience

Smart contract security researchers and auditors, DeFi protocol engineers, and applied-ML researchers working on LLM-plus-retrieval pipelines for code analysis. It is also relevant to security tooling vendors who need automated triage with explainable output. Readers without background in Solidity and attention mechanisms will find the module descriptions dense, but the high-level retrieval-then-audit architecture is accessible to anyone familiar with LLM agent design.

Authors’ abstract

Traditional consensus mechanisms, such as Proof of Stake (PoS), increasingly reveal an excessive dependency on large liquidity providers. Although the Proof of Liquidity (PoL) mechanism serves as a critical paradigm for incentivizing sustained liquidity provision and ensuring market stability, its transition from asset staking to active liquidity management significantly increases the complexity of underlying smart contract economic models and interaction logic. This renders…

The full abstract on arXiv
Read the original paper