We introduce the Clockwork Finance Framework (CFF), a general purpose, formal verification framework for mechanized reasoning about the economic security properties of composed decentralized-finance (DeFi) smart contracts. CFF features three key properties. It is contract complete, meaning that it can model any smart contract platform and all its contracts -- Turing complete or otherwise. It does so with asymptotically optimal model size. It is also attack-exhaustive by construction, meaning that it can automatically and mechanically extract all possible economic attacks on users' cryptocurrency across modeled contracts. Thanks to these properties, CFF can support multiple goals: economic security analysis of contracts by developers, analysis of DeFi trading risks by users, and optimization of arbitrage opportunities by bots or miners. Because CFF offers composability, it can support these goals with reasoning over any desired set of potentially interacting smart contract models. We instantiate CFF as an executable model for Ethereum contracts that incorporates a state-of-the-art deductive verifier. Building on previous work, we introduce extractable value (EV), a new formal notion of economic security in composed DeFi contracts that is both a basis for CFF analyses and of general interest. We construct modular, human-readable, composable CFF models of four popular, deployed DeFi protocols in Ethereum: Uniswap, Uniswap V2, Sushiswap, and MakerDAO, representing a combined 17 billion USD in value as of August 2021. We uses these models to show experimentally that CFF is practical and can drive useful, data-based EV-based insights from real world transaction activity. Without any explicitly programmed attack strategies, CFF uncovers on average an expected \$56 million of EV per month in the recent past.
翻译:我们引入了Clockwork金融框架(CFF),这是一个通用目的,正式的核查框架,用于对由分散金融(DeFi)组成的智能合同的经济安全特性进行机械化推理。CFF具有三大关键属性。它是合同完成的,意味着它可以模拟任何智能合同平台及其所有合同 -- -- 图式完整或其它合同。它可以以无干扰的最佳模式大小来这样做。它也可以通过建筑进行彻底攻击,意味着它可以自动和机械地提取对用户的加密货币跨模拟合同的所有可能的经济攻击。由于这些属性,CFF可以支持多项目标:开发商对合同的经济安全分析,用户对DeFi交易风险的分析,以及优化机器人或矿工的仲裁机会。由于CFF提供可折现性,它可以支持这些目标,对任何理想的、可能相互作用的智能合同模式进行推理。我们立即将CFF作为EEFO合同的一个可执行模型,其中含有20亿美元的联合计算模型,我们可以直接进行计算。在以往的工作基础上,我们引入了可提取的价值(EVE),一个新的正式概念,在CFIFF Eloveal Alial laimal imal imal imal deal deal deal laction acurrup the the the the laut thes acuildal laus accudational lapsebus acuildal lap laps a laps.