Opium V2: your out-of-the-box derivative protocol

Riccardo Biosas
Opium
Published in
6 min readFeb 10, 2022

DeFi and CeFi: a tale of two worlds

One of the many lenses through which we can assess the maturity of the current state of DeFi is by ranking the volume of its financial instruments and then compare the findings to their CeFi counterparts.

As other analysts have already pointed out, the most significant disparity between traditional financial markets and the cryptocurrency market lies in the difference between the size of the derivative market and market share of spot assets.

While, in the traditional financial markets, derivative volume dwarfs equities and other spot assets by a multiple greater than 30, in the cryptocurrency market options are only a relatively thin slice of the pie.

The DeFi ecosystem has been so far a retail market largely dominated by spot exchanges. In hindsight, it was a logical trajectory as the mechanics underlying the financial primitives of spot exchanges are inherently more easy to implement than the financial wizardry required to concoct a derivative market.

However, as the rate of institutional adoption keeps increasing, the DeFi instrument volume ratio will start to mirror CeFi: this means a potential growth for the DeFi derivative market that could be many orders of magnitude.

The bottlenecks that have prevented the growth of the DeFi derivative market can be summed up in two main categories: technical and demographics.

If it is in large part true that the cryptocurrency market first started and then flourished thanks to its strong, diverse grass-root retail user-base, it’s also true that the same user-base has increased their financial literacy over time. In what has been a collective learning experience, it is likely that many of its zealous users — a.k.a. the degens — have become traders and, similarly, developers have become financial engineers. At the same time, the rate of adoption among institutional investors — hedge funds, corporations adding crypto-assets to their balance sheets etc.- has consistently increased over the past year.

To further prove the case, the volume of Deribit and other centralized cryptocurrency options platforms has witnessed an exponential growth in 2021: still not as high as their CeFi counterparts, but much higher than decentralized derivative exchanges.

So if the appetite for options of both users and investors is finally there and outmatches the current supply of financial products, then the only remaining reason for the current bottleneck in the DeFi derivatives market must be technical.

And if the bottleneck to a large extent is technical, how can we solve it?

This is the question that we, in the Opium community, wanted to solve with the design of Opium V2 and the new pool products that will soon be released on top of it.

The design dilemmas of a derivative protocol

Two of the top factors that determine the success of a DeFi derivative protocol are liquidity and flexibility.

Liquidity is essential for traders to ensure that there’s a market where they can exchange their assets. Flexibility is essential for financial engineers to ensure that a protocol allows them to seamlessly encode the financial requirements of their products: in other words, flexibility can be regarded as a good developer experience (DX).

Some protocol architectures, however beautiful and efficient for a specific use-case, tend to over-engineer their foundational layers, which ends up imposing constraints down the road in the breadth of products and financial requirements that they can support natively. One of the side effects of that is that the developers building on top of such an architecture will face implementation obstacles which will decrease the reach of third-party integrations.

Especially in an ecosystem such as DeFi, rooted in open-source development and governed by network effects, a software is only as strong as it is its adoption rate in the developer community.

The Opium protocol v2 is meant to be asset-agnostic, both in terms of supported underlyings and in terms of oracles.

It is intentionally minimalist in its set of assumptions about what a financial product traded on it should look like.

As such, the Opium Protocol v2 acts as a trustless settlement layer with escrow functionalities. Any kind of sophisticated business logic (options strategies, vaults, peer-to-pool with different AMM models, different types of products -call/put options, CDS, interest rate swaps-) is something that can be easily supported atop the protocol, but it is not explicitly encoded in its core contracts.

The responsibility of the protocol layer should be only to mitigate counterparty risk in a trustless fashion and ensure the internal consistency of its balance-tracking operations and other primitives, without any further assumptions on who and what assets ought to be involved in its transactions.

What’s new with V2?

At its core, Opium V2 uses a factory pattern to mint ERC20 tokens — representing SHORT and LONG positions- upon the creation of a derivative. Their creation is delegated to a factory contract that uses the create2 opcode to deterministically calculate the deployment address of a position based on their derivative hash as a salt.

The derivative hash acts as a unique identifier across the protocol that distinguishes each and every financial product deployed on top of Opium v2. It partially borrows inspiration from the design of the Bloomberg tickers and ISIN, where the uniqueness of their identifiers provides a guarantee that a trader is dealing with the desired product.

Gas Optimizations

As bytes manipulation — let alone string manipulation- can be unforgivably costly in Solidity, some niceties that have been implemented in the factory contract to optimize its gas consumption include the implementation of the EIP 1167 standard (Minimal Proxy Contract).

More customization for synthetic authors

Alongside its derivative hash, Opium v2 allows synthetic authors to assign a custom name to their derivative product. It is a purely cosmetic feature which, unlike the derivative hash, does not provide any guarantee of uniqueness and should not be relied upon for any critical business logic. However, should a derivative author create a series of financial products featuring many different synthetics, the possibility of customizing their positions’ names would improve their recognition in third-party derivative explorers.

More efficiency for arbitrageurs

Some of the other user-facing features featured in Opium v2 include the ability to redeem market neutral positions for their originally allocated collateral. The ability to be able to easily swap market neutral positions should make the user-experience of arbitrageurs and other market makers more smooth. Furthermore, they will be able to trade fractions of their positions — both market neutral and not.

Gasless permits for position holders

The EIP-2612 has been implemented in the Opium position ERC20 contracts to decrease the costs associated with changing allowances and transfers in secondary markets.

A more decentralized governance system and flexible oracle design

Lastly, a more granular governance system has been implemented that favors decentralization and ensures a single-responsibility separation of roles. Alongside that, Opium V2 now supports an even more flexible oracle design since, as of the new release, it does not enforce the synthetic oracles to comply with a specific interface.

About Opium

Opium Protocol is a universal and robust DeFi protocol that allows for creating, settling, and trading decentralised analogues of derivatives.

Explore Opium Protocol or try out Opium Finance

Stay informed and follow Opium.Team on Twitter.

Did you know that you can subscribe to our News Channel to get more exciting news delivered to your morning coffee?

--

--

Riccardo Biosas
Opium
Writer for

Principal Security Engineer @Procore | Founder @AgorApp | prev. Protocol Engineer@LivepeerOrg & Fullstack/Lead Smart Contract Dev @Opium_Network