Manuscript Offprint

arXiv:2609.11504

DeFiFlowBench: Benchmarking and Improving Safe Executability in Natural-Language DeFi Workflow Synthesis

Abhinav Rajeev Kumar, Harshit Arora, Varun Singh, Manikandan Nanjappan

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abhinav Rajeev Kumar, Harshit Arora*, Varun Singh*, Manikandan Nanjappan†

SRM Institute of Science and Technology

{ak0929, ha8052, vs6320, manikann6}@srmist.edu.in

Abstract—A structurally valid DeFi workflow can still authorize a costly trade. We introduce DEFiFLOWBENCH, a benchmark of 207 team-authored prompts for natural-language DeFi workflow synthesis. It measures graph coverage, configuration completeness, and declared safety predicates, then tests supported trade configurations on a local EVM. Direct, constrained, and few-shot prompting produce 14–19 unsafe held-out executions per configuration under a fixed 5% price-impact cap. A slippage bound derived from a quote does not prevent the price impact of the order itself. We propose Koan-Safe, which combines a prompt-only intent parser, a replaceable generator, and structural repair with default safety parameters. On 75 held-out workflow prompts, its hybrid variant scores 0.67 on the static safety proxy, compared with 0.33 for the best baseline. Koan-Safe records no unsafe executions on the saved benchmark outputs. A matched-candidate ablation produces 14–17 unsafe executions when enforcement is disabled. Additional tests expose the limits of default injection: permissive existing thresholds can still authorize unsafe trades. A separately evaluated policy cap addresses this failure on a 36-case diagnostic grid. These results support explicit trade protections and execution-based evaluation, while distinguishing declared safety from a general guarantee.

Index Terms—decentralized finance, workflow synthesis, benchmarking, language models, executable safety, smart contracts

I. INTRODUCTION

Natural-language DeFi requests require a system to choose protocol operations and bind trade parameters. They also raise a separate safety question. A minimum output computed from a quote can enforce a slippage tolerance while allowing a large loss from the order's own price impact. The graph can contain the expected calls and still authorize a costly trade.

Research on natural-language workflow generation [1]-[3] examines structural correctness and executable workflows. Execution-aware transaction evaluation also tests whether generated calls achieve intended state changes [4]. We study a narrower question: do generated DeFi workflows include the protections needed to control trade risk, and what happens when those protections are missing?

Separating a generator from an external checker is well established in planning and agent safety [5], [6]. The question here is domain-specific: how much can fixed workflow repairs improve declared DeFi protections, and which failures remain in numeric policy settings?

We introduce DEFiFLOWBENCH, with 120 development prompts and 87 held-out prompts covering swaps, limit orders, cross-chain transfers, and compositional tasks. Three nested static scores measure required graph coverage, configuration completeness, and declared safety predicates. A separate execution check interprets supported trade configurations against a local constant-product AMM. It does not execute the complete generated DAG. We use safe-executability for the static proxy throughout; passing this score does not guarantee that a workflow fulfills the user's intent or is safe on a deployed protocol.

On the 75 held-out workflow prompts, the best baseline scores 0.33 on this proxy. Templates omit concrete trade parameters, while direct, constrained, and few-shot LLM prompting often omits price-impact gates. Each of these LLM configurations produces 14–19 unsafe high-impact executions in the local checker. These observations motivate Koan-Safe, which separates prompt-only intent parsing, candidate generation, and the addition of structural requirements and default safety parameters.

Koan-Safe’s hybrid variant reaches 0.67 on the static proxy. The rule-based and LLM variants reach 0.43 and 0.64. The method was frozen before the team authored the held-out split, which includes structures outside its presets. An enforcement-on/off comparison and a 34-pair metamorphic suite examine where the improvement comes from and how it responds to rewritten requests. The on/off comparison reconstructs both conditions from the same saved candidate, controlling model-output variation without additional API calls.

The contribution is a benchmark and an empirical evaluation of a workflow-repair method under explicit, limited execution semantics. The corrected execution checker applies a fixed impact cap regardless of gate declaration. A separate stress grid tests existing permissive thresholds and a post-hoc policy-cap extension. Together, these experiments show where structural repair helps and where it must be supplemented by numeric policy validation. Neither a high static score nor zero observed unsafe trades establishes a general safety guarantee.

∗^{*}Equal contribution.

†^{\dagger}Advisor.

github.com/Varun-2538/Koan

II. PROBLEM STATEMENT AND THE SAFETY LADDER

References (31)