Primitive Finance — An attempt at eliminating oracle centralization risks in DeFi
Primitive finance is an ambitious project seeking to solve the oracle problem threatening the decentralized ethos DeFi should embody. The oracle problem is the dilemma that arises when trustless smart contracts depend on centralized third parties for information that significantly influences the decision of the smart contract. However, Oracles are fundamental to the present-day design and functionality of most DeFi products, given the challenges of running a traditional order book on the blockchain. To understand the noble aspirations of Primitive Finance, it is essential to take a look at the solutions that exist in traditional finance and compare them with the current prevalent solutions that exist in decentralized finance.
Traditional Finance: Order Books, Matchmaking, and Cheap Compute Power
A typical trade in traditional finance markets involves an auction process where a buyer posts a bid and a seller posts an ask price. The trade comes to finality when the ask equates to the bid price. Alternatively, market makers facilitate transactions by providing an order book with bids, asks, and the size/depth of each price point. Market makers provide liquidity and hold the underlying assets during a transfer of ownership from the buyer to the seller. Market makers are rewarded for this risk primarily by taking advantage of the bid-ask spreads. In traditional finance, orders are represented and updated on an order book at high speeds efficiently and cheaply. Traditional finance and the order book system are relatively straightforward, easy to replicate, scale, and maintain because of the cheap compute power that is available. At the advent of Bitcoin and cryptocurrency trading, centralized exchanges like Binance, Coinbase, etc., easily replicated the existing order book systems available in TradFi, often also taking on the role of a market maker.
Figure 1
Source: Binance
The order book system fails to be feasible in DeFi for several reasons; the most prominent reasons include the slow speed and incredibly high expenses that users would incur by implementing the order book architecture on a smart contract & blockchain like ethereum. There would be fees associated with constantly making calls to the smart contract and updating the order book. Also, several delays would occur as the blockchain tries to reach a consensus on the prices and depths contained in the order book. Since the order book architecture is not scalable in DeFi, AMMs - Automated Market Makers became the prevailing architecture.
Automated Market Maker (AMMs): A suitable solution for DeFi
Automated market makers are self-acting systems that provide the prices of assets at any given point. While AMMs are increasingly popular due to their role in DeFi, the system has been used and studied extensively by academics and implemented in prediction markets several years before. Logarithmic Market Scoring Rules and Bayesian Market Makers are popular AMMs architecture models used before DeFi became mainstream. AMMs and their varying unique designs serve as the bedrock of several DeFi projects like Uniswap, Balancer, Curve, etc. Underneath the hood, it is essential to recognize that AMMs vary depending on the mathematical models they are based on. Constant Function Market Makers(CFMMs) are the most popular variation of AMMs that have been adapted for use in Decentralised Finance. Liquidity providers can supply token pairs to the CFMM; these token pairs are then provided to end-users to trade according to the asset prices set by the CFMM and based on the underlying mathematical model. For example, Uniswap, one of the most prominent CFMMs and Decentralized Exchange(DEXs), uses a Constant Product Formula. The formula is given as X * Y = K where X and Y represent the liquidity reserves supplied by a liquidity provider and K the constant product that must remain unchanged. Constant Function Market Makers like Uniswap based on the Constant Product Formula are called Constant Product Market Makers.
Figure 2
Source: Uniswap V2 documentation
Asides from the end-users(traders), there are two main parties relevant in the implementation of CFMMs for DeFi, and DEXs — liquidity providers and arbitrageurs. Liquidity providers supply token pairs to the reserves of the CFMMs and gain a share of the swap fees charged by the CFMMs. These swap fees serve as the incentives for liquidity providers to keep supplying token pairs to the pool. While arbitrageurs take advantage of pool reserve imbalance, returning the reserves to the original state by taking the reverse side of the end-users trade - more on this later on. Other Constant Function Market Maker variations include Constant Sum Market Makers, Constant Mean Market Makers introduced by Balancer, and Hybrid Constant Function Market Makers used by Curve with primary swap routes between stablecoins, etc.
Oracles and their usefulness in Decentralised Finance
Now that we have examined AMMs and varying implementations, we should study the role oracles play in all of these. Oracles are simply third-party data providers to smart contracts designed on the blockchain. Since smart contracts exist in isolation and cannot interact with the external environment, there is a need for data to be constantly provided to validate the decisions to be made by the smart contract. It is essential to state that oracles do not directly influence the decision-making process of AMMs or smart contracts and only serve to validate decisions.
The failure of an oracle that is vital to the design of a DeX or DeFi protocol can lead to financial exploits or outright protocol failure. Decentralized oracle providers like Chainlink try to combat exploits by decentralizing the data source and involving several data providers & participants. Still, malfunctions in the oracle network, nodes, or smart contract would directly lead to the failure of several DeFi protocols that rely on the oracle. For example, Rari Capital suffered the drainage of one of its liquidity pools due to attackers manipulating the supporting oracle. Given the vulnerability and centralization risks that oracles create in DeFi, there is a need for an innovative approach to asset pricing.
Introducing Primitive’s Replicating Market Makers
The Replicating Market Maker(RMM) designed by the Primitive Finance team is simply a variation of AMMs that allow a portfolio to be rebalanced to suit a desired outcome. Primitive seeks to become the base infrastructure for oracle independent DeFi and the future of on-chain derivatives markets. Primitive’s RMM is designed such that arbitrageurs must move the portfolio close to the desired outcome to realize a profit. In the first variation of the Primitive’s RMM - which is loosely named RMM-01, the desired outcome implemented is a covered call. Thus, liquidity pools held by the RMM would be made up of one unit of the underlying asset if it is below the strike price or the stablecoin equivalent if the price is above the strike price.
Figure 4
Source: Investopedia
The RMM-01 has three main participants:
End-users(Traders): Who conduct buying and selling activities, swapping between tokens and liquidity pools. The RMM charges these participants a swap fee, and the swap fees are shared with all liquidity providers as incentives.
Liquidity providers: These participants provide liquidity to the RMM. The RMM supports two types of liquidity creation — new token pairs referred to as “engines” by primitive finance and new pools referred to as “pools” by primitive finance. While the RMM-01 is designed to support any token pair, the covered call payoff pricing system encourages the pairing of risky assets and a stable value asset like USDC. Primitive defines a risky asset as all assets that are not stable in value, like USDC. Liquidity providers earn yields generated from swap fees generated during trades.
Arbitrageurs: These participants are incentivized to rebalance the protocols reserves to match the desired payoffs. Profit-making occurs when arbitrageurs closely match the desired payoffs. Per the RMM-01 design, arbitrageurs serve as the final price validators. The RMM-01 abandons oracles as final price validators and instead relies on arbitrageurs to validate prices during rebalancing based on prices obtainable on other RMM DEXs.
The RMM-01 finds practical applications in spot exchanges and on-chain derivatives trading. The primitive protocol allows for participants to carry out the following actions:
Provide liquidity and earn swap fees.
Build structured products utilizing the composable liquidity pools tokens.
Swap between tokens held in the underlying pool.
Create liquidity pools for any token pair.
According to primitive, the protocol would be launching in January 2021 on Ethereum L1 mainnet, Arbitrum L2, and Optimism L2. At launch, the key available features would be — concentrated fungible liquidity and liquidity pool tokens that replicate covered call options.
Primitive is currently available on Rinkeby Test Network for users to explore and experiment. Primitive also actively encourages developers to review their technical documentation and use the RMM SDK to develop DeFi projects.
Constraints: Some potential bottlenecks of Primitive’s RMM
The design of RMMs by Primitive is brilliant; however, it is still largely untested by market participants. One constraint that can arise during the implementation of the RMM is described in the Primitive whitepaper, effectively highlighting price divergence between the theoretical and effective values of Liquidity Provider(LP) assets contained in the pool.
Figure 5 - Value divergence of the LP assets given the inability of the RMM to capture theta from swap fees.
Source: Primitive Finance Whitepaper
Figure 6 - Value divergence of the LP assets when the RMM captures theta from swap fees.
Source: Primitive Finance Whitepaper
Asides from the price differences between the theoretical and effective value of the LP assets, the reliance on Arbitrageurs can be risky if they do not see an economic incentive to continue rebalancing the portfolio to match the desired payoffs. Also, when the end-users carry out very few or no swaps, liquidity providers would have fewer financial incentives to continue providing liquidity.
Final Words
I have been excited about Primitive Finance since I discovered it in 2021. I believe they are offering a bold, innovative and necessary solution to the oracle problem in DeFi and hope to see them succeed. Traditional markets have derivative markets estimated to be as large as $640 trillion to $1 quadrillion. I believe Primitive can play a significant role in creating an on-chain derivatives market of a similar scale relative to the total market cap of cryptocurrencies. The goal of decentralization is to eliminate any form of centralization and adjoining risks, and I believe Primitive would play an essential role in achieving true decentralization.
Reach out to Primitive
Also, If you have found this piece helpful or if you wish to have conversations/debates about this piece you can reach out to me on Twitter.