Lissy: Experimenting with On-Chain Order Books

Financial regulators have long-standing concerns about fully decentralized exchanges that run ‘on-chain’ without any obvious regulatory hooks. The popularity of Uniswap, an automated market makers (AMM), made these concerns a reality. AMMs implement a lightweight dealer-based trading system, but they are unlike anything on Wall Street, require fees intrinsically, and are susceptible to front-running attacks. This leaves the following research questions we address in this paper: (1) are conventional (i.e., order books), secure (i.e., resistant to front-running and price manipulation) and fully decentralized exchanges feasible on a public blockchain like Ethereum, (2) what is the performance profile, and (3) how much do Layer 2 techniques (e.g., Arbitrum) increase performance? To answer these questions, we implement, benchmark, and experiment with an Ethereum-based call market exchange called Lissy. We confirm the functionality is too heavy for Ethereum today (you cannot expect to exceed a few hundred trade executions per block) but show it scales dramatically (99.88% gas cost reduction) on Arbitrum. 1 Introductory Remarks There are three main approaches to arranging a trade [19]. In a quote-driven market, a dealer uses its own inventory to offer a price for buying or selling an asset. In a brokered exchange, a broker finds a buyer and seller. In an order-driven market, offers to buy (bids) and sell (offers/asks) from many traders are placed as orders in an order book. Order-driven markets can be continuous, with buyers/sellers at any time adding orders to the order book (makers) or executing against an existing order (takers); or they can be called, where all traders submit orders within a window of time and orders are matched in a batch (like an auction). Conventional financial markets (e.g., NYSE, NASDAQ) use both continuous time trading during open hours, and a call market before and during open hours to establish an opening price and a closing price. After early experiments at implementing continuous time trading on Ethereum (e.g., EtherDelta, OasisDEX), it was generally accepted that conventional trading is infeasible on Ethereum for performance reasons. Centralized exchanges continued their predominance, while slowly some exchanges moved partial functionality on-chain (e.g., custody of assets) while executing trades off-chain. A clever quote-driven alternative, called an automatic market maker (AMM), was developed that only requires data structures and traversals with low gas complexity. This approach has undesirable price dynamics (e.g., market impact of a trade, slippage between the best bid/ask and actual average execution price, etc.) which explains why there is no Wall Street equivalent, however, it is efficient on Ethereum and works ‘good enough’ to attract trading. First generation AMMs provide makers (called liquidity providers) with no ability to act on price information—they are uninformed traders that can only lose (called impermanent loss) on trades but make money on fees. Current generation AMMs (e.g., Uniswap v3) provided informed makers with a limited ability (called concentrated liquidity) to act on proprietary information [31] without breaking Ethereum’s performance limitations. Ironically, the logical extension of this is a move back to where it all started—a full-fledged order-driven exchange that allows informed makers the fullest ability to trade strategically. Contributions. In this paper, we experiment with on-chain markets to understand in detail if they remain infeasible on Ethereum and what the limiting factors are. Some highlights from our research include answering the following questions: • What type of exchange has the fairest price execution on balance? (A call market.) • How many orders can be processed on-chain? (Upper-bounded by 152 per block.) ar X iv :2 10 1. 06 29 1v 3 [ cs .C R ] 6 O ct 2 02 1 • How much efficiency can be squeezed from diligently choosing the best data structures? (Somewhat limited; turn 38 trades into 152.) • To what extent can we mitigate front-running attacks? (Almost entirely.) • Can we stop the exchange’s storage footprint on Ethereum from bloating? (Yes, but it is so expensive that it is not worth it.) • Are on-chain order books feasible on layer 2? (Yes! Optimistic roll-ups reduce gas costs by 99.88%.) • Which aspects of Ethereum were encountered that required deeper than surface-level knowledge to navigate? (Optimizing gas refunds, Solidity is not truly object-oriented, miner extractable value (MEV) can be leveraged for good, and bridging assets for layer 2.) • How hard is an on-chain exchange to regulate? (The design leaves almost no regulatory hooks beyond miners (and sequencers on layer 2).)

[1]  Ari Juels,et al.  Flash Boys 2.0: Frontrunning, Transaction Reordering, and Consensus Instability in Decentralized Exchanges , 2019, ArXiv.

[2]  Aaas News,et al.  Book Reviews , 1893, Buffalo Medical and Surgical Journal.

[3]  Michael Hamburg,et al.  Spectre Attacks: Exploiting Speculative Execution , 2018, 2019 IEEE Symposium on Security and Privacy (SP).

[4]  Eli Ben-Sasson,et al.  SNARKs for C: Verifying Program Executions Succinctly and in Zero Knowledge , 2013, CRYPTO.

[5]  Kaveh Razavi,et al.  CrossTalk: Speculative Data Leaks Across Cores Are Real , 2021, 2021 IEEE Symposium on Security and Privacy (SP).

[6]  Craig Gentry,et al.  Quadratic Span Programs and Succinct NIZKs without PCPs , 2013, IACR Cryptol. ePrint Arch..

[7]  Joshua A. Kroll,et al.  On Decentralizing Prediction Markets and Order Books , 2014 .

[8]  Jeremy Clark,et al.  One-Time Programs made Practical , 2019, Financial Cryptography.

[9]  Fan Zhang,et al.  Ekiden: A Platform for Confidentiality-Preserving, Trustworthy, and Performant Smart Contracts , 2018, 2019 IEEE European Symposium on Security and Privacy (EuroS&P).

[10]  L. Harris Trading and Exchanges: Market Microstructure for Practitioners , 2002 .

[11]  Pedro Moreno-Sanchez,et al.  SoK: Layer-Two Blockchain Protocols , 2020, Financial Cryptography.

[12]  Joseph Bonneau,et al.  Proofs-of-delay and randomness beacons in Ethereum , 2017 .

[13]  Andreas Park,et al.  The Conceptual Flaws of Constant Product Automated Market Making , 2021 .

[14]  Hayden Melton,et al.  Libra: Fair Order-Matching for Electronic Financial Exchanges , 2019, AFT.

[15]  Eli Ben-Sasson,et al.  Scalable Zero Knowledge with No Trusted Setup , 2019, CRYPTO.

[16]  Thomas F. Wenisch,et al.  Foreshadow: Extracting the Keys to the Intel SGX Kingdom with Transient Out-of-Order Execution , 2018, USENIX Security Symposium.

[17]  Eric Budish,et al.  The High-Frequency Trading Arms Race: Frequent Batch Auctions as a Market Design Response , 2015 .

[18]  Arthur Gervais,et al.  TEX - A Securely Scalable Trustless Exchange , 2019, IACR Cryptol. ePrint Arch..

[19]  Nigel P. Smart,et al.  MPC Joins The Dark Side , 2019, IACR Cryptol. ePrint Arch..

[20]  Klaus Kursawe,et al.  Wendy, the Good Little Fairness Widget: Achieving Order Fairness for Blockchains , 2020, AFT.

[21]  Michael Hamburg,et al.  Meltdown: Reading Kernel Memory from User Space , 2018, USENIX Security Symposium.

[22]  Jeremy Clark,et al.  SoK: Transparent Dishonesty: Front-Running Attacks on Blockchain , 2019, Financial Cryptography Workshops.

[23]  Amr M. Youssef,et al.  Publicly Verifiable and Secrecy Preserving Periodic Auctions , 2021, Financial Cryptography Workshops.

[24]  Björn Hagströmer,et al.  Do Volatility Extensions Improve the Quality of Closing Call Auctions? , 2021, Financial Review.

[25]  S. Matthew Weinberg,et al.  Arbitrum: Scalable, private smart contracts , 2018, USENIX Security Symposium.

[26]  Julian Williams,et al.  FuturesMEX: Secure, Distributed Futures Market Exchange , 2018, 2018 IEEE Symposium on Security and Privacy (SP).

[27]  Michael S. Pagano,et al.  A Closing Call's Impact on Market Quality at Euronext Paris , 2003 .

[28]  Arthur Gervais,et al.  High-Frequency Trading on Decentralized On-Chain Exchanges , 2020, 2021 IEEE Symposium on Security and Privacy (SP).

[29]  Jeremy Clark,et al.  On Bitcoin as a public randomness source , 2015, IACR Cryptol. ePrint Arch..

[30]  C. Signer Gas Cost Analysis for Ethereum Smart Contracts , 2018 .

[31]  Ari Juels,et al.  Order-Fairness for Byzantine Consensus , 2020, IACR Cryptol. ePrint Arch..

[32]  Dan Boneh,et al.  Verifiable Delay Functions , 2018, IACR Cryptol. ePrint Arch..

[33]  Zhenming Liu,et al.  Intention-Disguised Algorithmic Trading , 2010, Financial Cryptography.

[34]  Eric Budish,et al.  Quantifying the High-Frequency Trading "Arms Race" , 2020, SSRN Electronic Journal.

[35]  David C. Parkes,et al.  Cryptographic Securities Exchanges , 2007, Financial Cryptography.

[36]  Pierre Hillion,et al.  The manipulation of closing prices , 2004 .