Tuesday, March 10, 2020

OracleSwap: An Open-Source Derivative Contract Suite


A couple of years ago, I thought it would be good to create a crypto fund. I soon discovered that as a registered US firm my options were severely limited. I could go long or short a handful of crypto names over-the-counter, but they had excessive funding rates for going long and short (eg, >12%), and required 100% margin; I could short bitcoin at the CBOE, but I had to put up five times the notional as collateral. No reasonable estimate of alpha can overcome such costs. To use popular exchanges like Deribit or BitMEX would require lying about my domicile which would violate US regulations related to investment advisors, and also diminishes my legal rights if such an exchange decided to simply not give me my money back.

So I thought, why not create my own derivatives contract? Ethereum gives users the ability to create simple contracts, and nothing is more straightforward than a futures contract. I figured I could create a contract where the money at risk would be small relative to the notional, and its oracle would be honest because of the present value of this repeated game. The basic idea was simple enough, but the details are important and difficult, which turned this into a 2-year trip (I have sincere empathy for Ethereum's development pace).

Many initial crypto enthusiasts were motivated by the belief that our traditional financial system was corrupted by bailouts and greed. Ironically, the standard floundering blockchain dapp is constrained by their earlier short-sighted greed. Enterprising capitalists discovered that if you sell tokens, you can propose a vague blockchain business model and people will think it will be just like bitcoin, only it would offer insurance, porn, or dentistryThis required corporate structures because even in 2017 no one was gullible enough to invest in a token that funded an individual. Supposedly, the token is for use and decentralized governance, the latter implying all of the desirable bitcoin properties: transparency, immutability, pseudonymity, confiscation-proof, and permissionless access. Yet consensus algorithms are much easier to apply to blockchains than cases where essential information exists off the blockchain; non-blockchain consensus mechanisms do not generate all of those desirable bitcoin properties because they are much easier to game. 


Decentralization is a good thing, but like democracy, not at every level. A nation of purely independent contractors would never have developed the technology we have today, as things like computer chips and airplanes require hierarchal organization, and hierarchies need centralization. To relegate a market to atomistic, anonymous participants implies either an intolerable base level of fraud or costly adjudication mechanisms that jeopardize security and delay payments. A free market is built on a decentralized economy, which is based on free entry by firms and free choice by consumers. The degree of centralization within those firms is particular to a market, some of which should be large (e.g., banks).

The Coase Theorem highlights that the optimal amount of vertical integration depended on transaction costs related to information, bargaining, and enforcement. This is why firm size varies depending on the product. Naïve types think that we should just have small businesses because then we would have no oppression from businesses wielding market power. Given our current level of technology, that implies mass starvation. The naïve extension is that we should have large firms, but they should be zealously regulated by selfless technocrats. This ignores the universal nature of regulators, who protect existing firms under the pretext of protecting the consumer. This latter point is especially relevant as most protocols have some ability to permission access, and regulators will hold them accountable. Large institutions do not like competition, and governments do not like complete independence among their subjects, resulting in either KYC or curiosities like trading CryptoKitties.


The alternative I present is based on the idea that decentralization is basically competition, and that dapps can simply inherit the essential bitcoin properties by being on the blockchain without tokens and avoid convoluted consensus algorithms. That makes it cheaper and easier to design a viable product. A pseudonymous ethereum account allows oracles to develop a reputation because its actions are transparent and immutable; outsiders cannot censor it. Lower costs, crypto-security, and pemissionless access, provides a valuable way for people to lever, short, and hedge various assets: the initial contract has derivatives on ETHUSD, BTCUSD, and the S&P500.

The result is OracleSwap, an ethereum derivatives contract suite. I have a working version on the web, at oracleswap.co. While it is live on the Ethereum Main Network, it is restricted to margins of 1 or 2 szabo, which even with leverage is well under $0.01 in notional value. It is meant to provide an example. I would be an oracle and liquidity provider myself, but as a middle-aged American, that is not practical. I have fingerprints all over this thing and my friends tend to have good jobs in the highly regulated financial sector, and we would have a lot to lose by violating US regulations (e.g., CFTC SEF regulations within Dodd-Frank, FinCEN, BSA). Yet there are many who can and do invest in exchanges prohibited to US investors, and such investors need better choices.

Many competent programmers have the ability and resources to modify and administer such a contract (you can rent server space for $10/month). The oracle is honest because the present value of oracle revenue is an order of magnitude greater than a cheat. Further, the oracle has economies of scale, so those who are disciplined can create a working product, and by the time they graduate, they will have generated a couple-year track record supplying timely and accurate data. 

Several innovations make this work, all focused on radical simplicity. This lowers costs and reduces direct and indirect costs. The most important innovations are the following:  

·         Forward-starting prices

Trades are transacted at the next-business-day closing price. As this contract targets long-term investors, the standard errors generated by differences in various 4 PM ET prices are minimal and unbiased (the median of several sources over different intervals within a 5-minute window for crypto, the SPX uses the close price). As an institutional investor, I always used next-day VWAP prices. Limit order books generate many complications, and provide nothing of interest to long term investors; day trading blockchain assets is predicated on delusion. 

·         LP netting

The key to market-making capital efficiency is allowing the liquidity provider to net trades. Without a token, this had to be done through netting exposures at the weekly settlement. The LP's are basically mini-exchanges, in that long and short positions are netted. Weekly settlement can handle 200 positions in a single function call, but this can be broken up into 200-unit chunks, allowing an almost unlimited set of positions for any LP. They balance long and short demand by adjusting their long and short funding rates. The Law of Large Numbers implies larger LPs will have more balanced books, allowing them to generate a higher gross-to-net asset ratio, which implies higher returns for a given level of risk and capital; LPs are incented by economies of scale, not delusional token appreciation. 

·         The oracle


This contract is designed for those who want to stay off the grid, and so its pseudonymous oracle can maintain its anonymity and avoid censorship. Its main costs are fixed, as once the contract, front-end, and automated scripts for updating prices are created, maintenance is trivial. The oracle is kept honest via the repeated game it is playing, and the ability and incentive for users to burn their PNL rather than submit to a fraudulent PNL at settlement. A centralized oracle is much easier to incentivize because it is all-in on the brand value of its oracle contract, as a cheat should eliminate future users.


the only way to cheat involves colluding with an oracle that posts fraudulent prices, so the contract focuses on minimizing a cheat payoff while concentrating the cheat cost on the oracle. An oracle's reputation is black or white, as its history of reported prices is easy to monitor, and no rational person would ever use an oracle that cheated once. All of an oracle's brand value is in the contract due to its pseudonymous nature, so there is less incentive to sell-out to seize or protect some traditional brand value (e.g., Steem). While explaining the incentive structure requires more space than I have here, the crucial issues are that players have the ability and the will to decimate a cheat. 

Not only are the ethereum contracts open source, but the web3.js front end is as well. By downloading the web front-end users can eliminate the risk that someone is watching their interactions with the identical front-end hosted at oracleswap.co. Yet, it is mainly a template for developers. I hired people to create the basic structures as I am not a hard-core programmer, but I have modified them endlessly and in the process had to learn a lot about Drizzle/React, JavaScript, Python, and Solidity.

Python is for the APIs that pull prices from data providers and post them to the contract. This has to be automated with error-checking processes and redundancies. You can send questions related to this contract to ericf@efalken.com. I can't promise I'll respond, but I'll try.

Links:

This site is not encrypted--http as opposed to https--but as this contract is denominated in szabo, and the website and contract do not ask for no user information such as emails, etc, users can interact via MetaMask or MyCrypto.com without worry. Users can also download the front-end from GitHub and run a local version with all the same functionality (it's open source). It is fully functional.



Technical Document


Excel Worksheet of Technical Document Examples