Setting the foundations for the DEFI economy

Nikolaos Kostopoulos
Harmony
Published in
13 min readNov 7, 2019

--

During the Q3 2019, we have announced in a celebratory post our focus on becoming the powering infrastructure for the fast-growing decentralized finance ecosystem.

Since then, we have experienced tremendous interest and approached by numerous developers and entrepreneurs from all over the world who already build the first DEFI d-applications on Harmony.

This medium article shares our reflection on the different types of financial assets and tools that exist on blockchain today and what it would take for a protocol such as Harmony to get traction in the ecosystem. As a result, this article is to be considered from the view of Harmony, which is a:

  • Proof of Stake protocol
  • Use a BFT mechanism to reach consensus (like Cosmos or EOS, unlike Eth 2.0 and Tezos which under the “follow the longest chain” consensus)
  • Sharded protocol, with homogenous shards

The ingredients of a successful DeFi platform

First, let’s define the DeFi “actors”. At this early stage it’s fair to assume that there are currently 3 groups:

  • Dapp developer, most likely with some financial background
  • Market makers and arbitrageurs, integral and necessary actors of protocols like Uniswap (liquidity pool) and Maker (CDP keeper).
  • And more loosely defined, crypto enthusiasts that use the protocols

DeFi Dapp developers are currently looking at is:

  • A stable platform. Track record is helpful as it’s the best way to assess the stability of a platform.
  • Stable coins for use cases that are not speculative
  • A set of smart contract to interact with, so that a new DeFi team doesn’t have to start from scratch. Looking to build a margin-enabled trading exchange? Use compound for lending/borrowing, 0x for the settlement, and you already have half of the infrastructure!
    This is the magic effect of “compounding” layer 2 protocols that make DeFi so disruptive.

What is working today? What is not?

Once a protocol is launched, traction is measured mostly with money at stake (eg: DefiPulse)

DefiPulse give a clear sense that lending is the #1 use case. Lending doesn’t need a fast chain, so where Eth 1.0 is currently at is a good fit. Also, the KPI used by DefiPulse, ranking by “locked” value, works for Uniswap where liquidity is locked, but not for more “traditional” trading platform like 0x. Looking at the volume, we still see that Uniswap has 2x the volume 0x has.

Now if we look at centralized crypto exchanges, volumes are in the 10+ $billion/day. And the reason we are not there yet on DEX is that the on-chain throughput is not there. A 15 second block time and often ~50 cts+ to initiate or cancel a transaction is too slow and expensive, especially to attract the necessary market maker that create liquidity to the market. This might be a very relevant use case for scalable blockchain like Harmony.

Answering the most 🔥🔥🔥towards getting #DEFI on Harmony!

1/ Can Dai-like collateralized based protocol can be deployed on proof of stake protocol?

A stable token is one of the first assets a protocol would need. A volatile asset (like $ETH or $ONE) would barely enable use cases that need a stable medium of exchange, which is everything that can afford the volatility of those assets)

There are 3 main types of stables coins:

  • Fiat collateralized, they are fairly well understood, the main challenge with them currently is on compliance, with a layer of trust for audits
  • Crypto collateralized, where Maker is leading the way
  • Algorithmic, like the now-defunct Basis, or Ampleforth, where the stability comes from parameters embedded in the protocol that arbitrageur would use and that is supposed to maintain a stable price. But unlike for crypto collateral protocol… there is no collateral. It’s similar to how a fiat money work, except there, is no government/country behind it, and the rules are set in stone. This category has not got meaningful adoption yet.

While Harmony and developers building on our infrastructure are considering all three categories- in this article we will focus on the second category.

While Maker has been very successful for Ethereum, would it work for a proof of stake protocol? The same questions are covering what’s the future of MakerDAO with the much-anticipated release of ETH.2.0- which is sharing many common aspects with Harmony.

Is it possible to generate a syntactic dollar like DAI on a proof of stake protocol?

On proof of work protocol like ETH 1.0, long ETH holders are incentivized to loan their token to generate yield, whether it’s custodial lending on Genesis Mining or BlockFi, or non-custodial lending like Compound or Dharma. With a Maker CDP, an ETH hodler can mint DAI tokens backed by their ETH holdings. This provides leverage similar to other lending solutions, although the role of the lender has been replaced by Maker CDP smart contracts.

The inflation tokens minted by ETH 1.0, a PoW protocol, are given to miners who don’t need to hold any token and doesn’t give any yield on the token being hold. Miners still need to invest in hardware, but this is an off-chain resource.

The economics are different from Proof of Stake protocol. Holding tokens is mandatory to get part of the protocol inflation through “staking”. Long tokens holder has a natural option to generate yield: staking.

Lending would still be an option, as lending and staking have different benefits.

Staking is used to secure the protocol. Lending is matched with borrowers, who could take their native token, buy DAI, convert it to fiat and spend it on the “real world”, or go leverage long by buying native tokens.

But overall, long token holders would be to seek the highest risk-adjusted return, which will be determined by market forces.

Assuming yield will be driven by market forces, it is interesting to think about how the yield might evolve between staking and lending.

In a bull market, we can expect lending to be competitive with staking, as we saw with recent MakerDao and the interest rate (stability fees) had increased up to 19.5% to keep the peg for DAI. This is more than what staking protocol yield typically nowadays (average of 13.3% on https://stakingrewards.com/)

Now if we look at how Maker would work in a bearish environment, last year the interest rate was at 0.5% during most of 2018. This was enough to keep DAI pegged to $1 because there was low sell pressure on DAI.

But what would have happened if ETH holder had a way to earn 5% — 10% with staking? Would the supply of DAI dry up? Leading to an increase in volatility, a lost peg and ultimately building on top of DAI, with the assumption of a stable coin, would not be a viable option?

Another way to look at it is to assume that staking is the “risk-free rate” of return, like what we would have with a traditional finance system.

It’s not completely risk-free as there are odds of being slashed, but with a good validator, the risk should be limited. Also, in the case of a bug at the layer 1 with a “systemic failure” (eg: a bug leading to a printing an infinite number of tokens, like Bitcoin in 2010), the bug would be fixed and transactions would probably be reverted, because it affects the whole protocol.

With lending, the risks are bugs in the code (smart contract risk) and counterparty risks (minimized for over collateralized contract, especially with pool investment). The reason the risk for lending is higher is the fact that a bug in the code, somewhat likely for protocols without formal verification, would be unlikely to be reverted (parity hack is a good example).

Assuming lending risk would be higher than staking risk, the market would demand a higher reward for lending.

I’m mixing interest rate that ETH holder can borrow for Maker, with the interest rate that ETH 2.0 owner can lend with their token.

An important caveat: for MakerDAO, the interest rate lenders generate doesn’t go back to ETH holder but MKR holder via token burning. This is the main reason MKR exist so that MKR holder can govern on the most important part of the protocol, the interest rate. If MKR holder doesn’t set the rate properly, they will be diluted by the creation of new MKR, so their MKR holding creates an incentive to correctly adjust the rate.

2/ Moving assets on-chain from other chains. Relying on BFT / instant finality to facilitate the transfer.

A protocol will only be successful as a DeFi platform if there is a substantial number of assets on this platform.

The ideal scenario is to have primary issuance of token directly on the platform. This is possible for pure digital assets, but otherwise, the token would be a representation of another asset that either exists on another chain, or in the physical world (eg: real estate).

Attracting new token on a new platform is notoriously a hard sell for a new platform. Ethereum did it very successfully as the de-facto platform to run an ICO in 2017. Nowadays, Binance.org is getting significant traction, but Binance has an “unfair” advantage, Binance.com is the largest crypto spot exchange.

So how can a new protocol get many new assets?

Federation is one way, like wBTC, but it’s permissioned and requires custody, so it would take time to pull off. It’s pretty much like having a fiat-based currency.

Another way that could be easier to pull off is by doing permissionless cross-chain contracts.

For instance, bringing ATOM token from the Cosmos hub would be a good way to start this. Cosmos has been thinking about this a lot and already published a reference guide on how to exchange messages between protocol with ICS.

Also, this is where the detail of the consensus mechanism matters.

For “follow the longest chain” consensus (Eth 2.0, Tezos), cross-chain transactions are more challenging because of the probabilistic property of this consensus mechanism, and the need to wait for “enough” blocks to be considered final. This is a significant attack vector if there is a need to have low latency.

As a side note, exchanges also integrates this difference of timing in regards to consensus protocols with the time they take to credit tokens. Taking Kraken as an example, Cosmos get credited “near-instantly”, unlike other “follow the longest chain” where it’s taking a lot more time/blocks to be confirmed.

3/ Most DeFi contract should be funded by the layer 1 protocol

In 2017, the ICO crazes led to flourishing experiments. This was tremendously beneficial for the ecosystem, as we saw what works, and what didn’t.

One clear hindsight is that, for many projects, a token is creating friction, with sometimes no clear benefits. The most obvious example is probably Bancor. On one side, Bancor invented a very beneficial liquidity pool that is working tremendously well for exchange tokens, especially with low throughput platform. It has also nice property like composability, that allows atomic transaction with other smart contracts.

But Bancor had integrated a token, acting as an intermediary for every transaction, that was key to the $143m fundraising round. It now seems clear to the community that this token add friction and the same protocol without token would probably be better.

But also let’s see the example of Uniswap:

Project sponsored by the Ethereum Foundation. With only a $100k grant or less than 3 order of magnitude (!) less funding than what Bancor raised, the project has now twice the liquidity.

What is the lesson here?

We should not dismiss the value created by Bancor. But it’s clear that when there is no use for a token, a fork version without a token will be created.

But if there are no financial incentives, who would create such protocol in the first place?

Actually, there is a financial incentive. Uniswap benefits Ethereum, and therefore the ETH holder. So it’s clear to us that such initiative will be led by Foundations, or community-driven DAO, but not by team privately funded by token sales.

This initiative should lead to the creation of a set of building blocks. Uniswap is just an example. Lending protocols like Compound, settlement layer like 0x, are all examples of building blocks that Dapp developer will expect on any protocol intended for DeFi. And it would be expected that those protocols will be rent-free.

4/ What sharding means for DeFi

The main impact of sharding for DeFi is on the liquidity side. On Ethereum, every assets and protocol lay on the same ground and can interact with any other part of the protocol instantly. It is possible to create an atomic transaction, that, for instance, will sell a CDP position and buy a cDai token, which is what InstaDapp Bridge has been built for. This otherwise would take many individual transactions to complete (sell CDP, sell pETH, sell wETH, buy cDAI).

The atomicity of a transaction is what is being challenged in a sharded protocol, and where more research is needed. The reason atomicity is not really an option for sharded protocol is by the asynchronous nature of cross-shard transactions, known as the “train-and-hotel problem”.

Still, what would be the different initial steps to get DeFi on a sharded protocol?

A token standard

The first step is a new standard for cross-shard tokens, a “sharded-ERC20”. The way tokens would be transferred from one shard to another one would be with a burn function on one shard (the source), and a mint function on another shard (the destination), which would take a “proof of burn” as an input. The first question that arises is how to account for the token supply? A way would be that the first shard the token has been initially deployed is the “master”, and the other shards have a lightweight “slave” implementation, that can only burn/mint tokens, such that the supply doesn’t increase.

Even with a token standard, we can expect, like for ERC20, that tokens would have their subtlety in their implementation. Eg: Is one set of signature enough to accept a proof of burn and mint new tokens? Does “slave” token also have an additional function like staking/locking?

Tokens that seeks cross-shard capabilities would need to have a smart contract being deployed on every shard.

Concentrated liquidity?

For exchanges, liquidity begets liquidity. So there would likely be an incentive to have a concentration of assets for trading related activity. We think that would make a lot of sense that shard take the lead in certain pairs. Shard #1 for ONE denominated quote tokens (eg: wBTC/ONE, ETH/ONE, … ), shard #2 for DAI denominated tokens, etc.

By separating trading on different shards, it’s possible to get full benefits of sharding. And this probably makes sense for order book exchange model but what about for the constant product marker model like Uniswap?

If you think of one of the key properties of Uniswap is composability. And in an asynchronous cross-shard transaction world, composability can only be done in a single shard. So a relevant model for Uniswap would be to be deployed on every shard and incentivizes market makers to have even balance on every shard. This would work well for price-insensitive usage. An investor looking to take a large position would not use this type of exchange, but if the goal is to acquire a very small portion of a token because fees related to a protocol needs to be paid in this particular token (like MKR), then this is a great solution.

A smart routing order processing would also have some benefits. This would be similar to how Kyber is built today, but instead of looking at the price of some assets in different contract, the goal would be to look at the price of an asset across every shard.

By combining an Uniswap on every shard, plus a Kyber-like approach for the cross-shard liquidity, this would mean that, if you want to have a lower price, you may have to reach to do many cross-shard transactions, and this would take some time. If you want your transaction to be executed right away, you’ll take the liquidity in your current shard, which would likely not be at the best price.

In practice, this would similarly to transaction cost as it is today. If you want your transaction to be processed immediately, you pay a higher gas price, otherwise, you benefit from the lower gas price but have to wait for some time.

5/ Sharding is a solution to the Oracle problem?

Reducing the latency and increasing the throughput would enable more efficient on-chain exchange, maybe to an inflection point where “real” volume would happen. Combining with some smart cryptographic zero-knowledge primitive, like what Starkware and 0x are doing, could be the path to have significant on-chain trading.

Beyond the inherent security benefits of on-chain trading becoming a viable solution, this could also resolve many of the Oracles problems. This idea came to light with Delfi, a hackathon project done at ETHDenver — and granted the “most innovative” award.

The idea is the following: We need oracle for many DeFi smart contracts because there is no price available on-chain, or the price is too easy to manipulate. But as more volume happens on-chain, it becomes a viable option to rely on on-chain oracle versus off-chain oracle.

The benefits are that there is no trust required for an on-chain oracle. The drawback is that today, the volume is low so the price feed given by an on-chain oracle would be easily manipulated, but with more volume, this would become more and more expensive. And lack of scalability is a key factor preventing more on-chain transactions.

Also, most order book system does not save the price on chain as a state, because storage is expensive (instead, 0x use event to reduce cost), but as another benefit of sharded protocol is that gas prices would be a fraction compare to Eth 1.0, such that it might be doable for those protocols (like 0x) to save on-chain the last price such that this data is available on-chain for other protocol to look at.

It is no secret that DeFi is the use case in blockchain getting most traction today. Especially if we assume that the tools for speculating on the future value of an asset (ie: exchange) represents a financial product, and are just waiting to be decentralized!

The article is a synopsis of research work conducted by Harmony collaborator Nicolas Burtey.

Data are given for educational reasons and do not represent advise for the success/OR failure of a digital asset.

Let us know your opinion about #DEFI in our Telegram Community or Discuss directly with our team on Discord

--

--

Nikolaos Kostopoulos
Harmony

Advising governments & interest groups on cryptocurrency & FinTech regulation in the European Union.