On-chain derivatives: solving $500T problem and winning prize at Consensus 2018 Hackathon

On-chain derivatives: solving $500T problem and winning prize at Consensus 2018 Hackathon

In early May, a few of us from 8base, Evgeny Semushin, Gabe Kelly and myself, decided to take on the challenge of competing for the AlphaPoint prize at the Consensus 2018 Hackathon in New York City. There was a total of 33 participating teams at the hackathon, and there were some big-name sponsors such as CoinDesk, Microsoft, IBM, Hyperledger and Quorum.

Hackathon

The contenders in the AlphaPoint challenge had to build an application tied into a digital asset exchange and we thought that my hedge fund experience should give us an edge. We didn’t want to simply build a front-end to an existing blockchain solution. Instead, we wanted to focus on solving a real problem in a way that only blockchain architecture can enable, combining our expertise in smart contract development with knowledge of internal mechanics of finance.

hackathon
hzhfe

We built a set of smart contracts on the Ethereum network that allows creation of decentralized derivatives with on-chain collateral management. Our solution enables anyone to underwrite a put or call option contract on any ERC20 asset without a 3rd party managing the exercise and collateral requirements. We were honored to win first prize.

Below we’ll describe the implementation detail of this project.

Problem

Derivatives are a big deal. Global derivatives are estimated to have at least ~$500 trillion market capitalization. Compare this to ~$0.4T crypto at the time of writing, ~$40T liquid money and ~$70T global stock markets, and it becomes clear how significant the role derivatives play in the global economy. Nothing shows this better than this infographic. Derivatives, such as options, futures and swaps are useful tools employed by banks, funds and companies to manage risk.

📷Market cap of various asset classes

The key complexity of derivative agreements stems from the fact that they are usually leveraged — meaning that potential risks exceed the amount of funds counterparties to the agreement have in their accounts. This leads to a complex system of settlement, maintenance margin and margin calls designed for counterparties to keep a level of collateral, such that it is always more expensive to walk away from an agreement than to honor it.

This system failed in 2008. Entangled in a complex web of derivative agreements, Wall Street players couldn’t efficiently unwind or net them out. This triggered a domino effect of margin calls and subsequent defaults leading to the collapse of Lehman Brothers and other players. The US government had to step in and bail out Wall Street to help unwind staggering amounts of defaulted derivative agreements. We all know the rest…

Solution

BlockSigma is a set of smart contracts that enable creation and management of derivative agreements for crypto assets. The collateral management is done on-chain and doesn’t require an intermediary to ensure that the funds locked inside of a smart contract satisfy the maintenance margin requirements.

The core innovation is fully on-chain margin management that requires no central party or oracle price feed. We achieve this by integrating with Bancorprotocol. Bancor protocol is being adopted at a significant rate and already facilitating millions of dollars of daily trading activity. Bancor uses a deterministic price formula that is calculated based on supply and demand of an asset. As such, we can get the underlying token price directly on-chain, which allows us to calculate the maintenance margin requirement and trigger a margin call if necessary.

The smart contract logic is designed in a way that enables an option buyer to force-liquidate the position as soon as the collateral held inside of the smart contract drops below the mandatory margin requirement. The maintenance margin formula includes excess reserves, providing economic incentives for the option buyer to closely watch the position and grab the reserve (including the excess amount) by force-liquidating the position if the maintenance margin level is not satisfied. At the same time, it incentivizes the option seller (underwriter) to timely add more collateral if the trade goes against them, otherwise they risk losing the excess reserve.

Implementation

The full source code of the solution can be found in the GitHub repo.

There are three main solidity files: BlockSigmaBase.sol, BlockSigmaCall.sol, BlockSigmaPut.sol. BlockSigmaBase implements the common logic, while BlockSigmaCall and BlockSigmaPut inherit it and implement the logic specific to call or put contracts.

Let’s look at the contract’s interface:

Now let’s walk through the key workflows of a put contract. For example, let’s consider a put contract on EOS token denominated in DAI, which effectively allows one to hedge his/her EOS holdings against the US dollar. The lifecycle of the contract is as follows:

  1. Anyone can deploy the BlockSigmaPut contract corresponding to a specificoption series. During the deployment we specify: (1) underlying token, (2) currency token, (3) expiration date, (4) strike, (5) address of an issuer that has the right to underwire contracts in this series and (6) the minimum reserve requirement per contract. Example: EOS put expiring Jul 1st 2018 at 10 DAI strike with a minimum reserve of 2 DAI. Such a contract gives the buyer the right to sell EOS to the underwriter for 10 DAI any time before July 1st 2018. The maintenance margin requirement per contract in this case will be calculated as 2 + max(0, 10 - current EOS price).
  2. A designated issuer underwrites a certain number of contracts by depositing the required reserve of the currency token. Continuing with the example above, if the current EOS market price is $12 the issuer will have to deposit 2 + max(0, 10 - 12) = 2 DAI in order to issue 1 option contract. Once issued, the contracts can be treated as regular ERC20 tokens and can be moved to an exchange and sold to buyers.
  3. Once the buyer wishes to exercise the contract they need to give an allowance to transfer EOS into the option smart contract and then call the ‘exercise’ method. Once the exercise is initiated the seller has 24 hours to deliver the payment in a form of the currency token. In our example, for each EOS token, the seller has to deliver 10 DAI.
  4. The issuer gives allowance to transfer DAI tokens from their account into the option smart contract and calls the ‘deliver’ method. Once done, the smart contract automatically settles the transaction by distributing DAI and EOS to the buyer and the seller(issuer) and returning the reserve to the seller.
  5. (Optional) If the seller doesn’t deliver within 24 hours the buyer can call the ‘forceLiquidate’ method to receive the deposited EOS back together with the reserve to cover the seller’s default.

Now let’s look at how the collateral management is done. In our example, the EOS price was at $12 at the time of option contract issuance. Let’s say now it went down to $9. The required reserve becomes 2 + max(0, 10 - 9) = 3. This means the seller needs to deposit additional 1 DAI for each contract they had underwritten. If the seller fails to do so, the buyer has an economic incentive to force the liquidation:

  • If the buyer simply exercises the option, they receive 10 - 9 = 1 DAI payoff per contract (acquiring EOS in the market for $9 and selling it to the issuer for $10).
  • If, on the other hand, the buyer forces a liquidation they receive the entire reserve, which in our example is 2 DAI per contract.

This motivates the buyer to force-liquidate as soon as they can as it produces an instant profit.

Challenges

This solution is by no means production ready. Its main purpose is to demonstrate the groundbreaking capabilities of blockchain and smart contracts in automating settlement and collateral management of option contracts. Traditionally these services are performed by an intermediary, require manual work and cost fees.

While our solution shows great promise, there are several potentially significant challenges that we see:

  • Bancor protocol is not battle tested. It uses a deterministic price formula that converges to exchange prices via arbitrage. It is not clear how this mechanism will work in times of great volatility and/or price gaps.
  • The collateral management mechanism is not immune to violent price gaps. It is theoretically possible that a writer’s liability can become greater than the reserve, in which case they can be motivated to default, and the buyer will not be fully compensated. This can be mitigated by increasing the minimum reserve. Alternatively, as it’s done in traditional finance, users of such a system can contribute to a shared “insurance pool” that is used to automatically cover reserve shortfalls under extreme scenarios.
  • Since Bancor uses a deterministic price formula it can be manipulated in order to provide a better payoff for one party in the option contract at the expense of the other. This is feasible only if the Bancor converter reserve is low (i.e. its price sensitivity is high) relative to the size of the options position. In this case the cost of manipulating the Bancor price can be lower than the payoff from options achieved by such a manipulation. However, this problem is not specific to crypto and exists in traditional markets (e.g. burning a house to collect insurance).
  • Regulatory uncertainty. We haven’t done any research into the regulatory side as we have no plans to pursue this other than as a research project as of now.

If you see other issues not listed here, please let us know in comments.

Summing it up

The described solution gives a preview into the scope of the fundamental change that blockchain will bring to finance industry in the coming years. Not only will it make settlement and collateral management more efficient, it can provide transparent, self-enforcing rules that are applied to all market participants in the same way.

At 8base we’re not focusing on specific niche solutions or protocols as described in this article. We anticipate an explosion of similar disruptive technologies in the coming years as we continue to ride the wave of digital transformation. Instead, we focus on building the next layer of infrastructure that gives business users easy access to these technologies and the ability to incorporate them in enterprise software to drive business results.

Comment