ECONOMIC SECURITY OF SMART CONTRACTS AND BLOCKCHAINS
Blockchains and Smart Contracts have ushered in a new era of decentralized applications, most prominently the ecosystem of Decentralized Finance (DeFi). The ideals of permissionless participation, open-source execution, and decentralization bring formidable security challenges. Due to the inherent financial nature of these systems, there is a need to study the security of these systems with an economic perspective. In this thesis, I build three systems to study and ensure the economic security of smart contracts and blockchains. The first system is Clockwork Finance Framework (CFF): CFF automatically reasons about the extent of economic security of composed smart contracts using formal methods, and proves bounds on economic security. The second one is Lanturn, which scales up the analysis of economic security in CFF by forgoing program analysis and treating economic security as an optimization problem. As a result, Lanturn automatically discovers novel attack strategies without encoding any contract-specific heuristics. The third system is PROF (PRotected Order Flow), which protects ordinary users from economic exploitation while accounting for the rational behaviour of blockchain validators. PROF bridges two parallel strands in the community, which were earlier believed to be incompatible with each other: protecting users and maximizing value for rational validators. The results from this thesis show that there is an urgent need to address economic security challenges. CFF and Lanturn have uncovered more than $50 million of extractable value per month in the recent past. The community is looking to productionize PROF in order to mitigate some of the most pernicious forms of value extraction.