Author's note: DeFi marches through the crypto world. Republic and Byzantine Solutions continue the introductory series to convey everything an investor needs to know about decentralized finance. The series covers individual instrument groups, supplementing a recently issued report Redefine 2020: A Primer. In this article we will look at the instruments for lending and borrowing, and talk about the segment of yield farming covered by loans. This article is supplemental reading for those that have attended our Blockchain 101 and Intro to Defi webinar.
As was noted in the opening article and Part 1 of the series, one of the pillars of decentralized finance is the lending ecosystem — products that facilitate the ability to draw debt to increase one’s capital. The uses are numerous: procuring liquidity to fund operations while keeping a long-term investment in an underlying asset, borrowing capital to enter short-term long and short speculative positions, margin trading with leverage, taking flash loans to perform risk-free arbitrage. The list goes on.
In the early days of the DeFi ecosystem, borrowing was split between collateralized loans and peer-to-peer lending. These days, peer-to-peer lending is all but gone: there are ultimately too many barriers to enforcing loan repayment in a decentralized ecosystem, it boils down to central agents and reputation systems, which have their limits.
Collateralized borrowing, on the other hand, flourished. Lending in DeFi most often uses tokenized pools to aggregate liquidity, which streamlines the business process for borrowing. One does not have to source potential lenders or negotiate the interest rate since there is a single entry point for all loans, and the interest rate is determined algorithmically from market conditions.
In the current landscape loans come in several shapes, and mostly differ in the way they are collateralized and liquidated: there are “ordinary” collateralized loans, borrowing pools attached to specific trading instruments, and flash loans. We will go into each, but first we will elaborate on the three important concepts from Part 1 (overcollateralization and liquidation by market agents, liquidity pools, and tokenization of participation) and how they are used together for lending.
Collateral and liquidation
The quest to eliminate centralization bottlenecks often calls for elaborate solutions for most mundane mechanics. Lending markets without reputation and collectors use collateral in excess of the value of the borrowed assets. It works like this.
The borrower puts up some collateral that covers the value of the borrowed assets, plus a safety margin. The loan is given out. Everything is governed through smart contracts that enforce the initial ratio of collateralization, take custody of the collateral, and relinquish custody of the funds. Same is done, in reverse order, upon repayment. Valuation is done on an asset basis by introducing price feeds from decentralized exchanges or off-chain exchanges via oracles (special committees that try and agree on a current price of a particular asset). The smart contract instance representing one particular loan position is usually called a CDP (collateralized debt position) or a Vault, terms introduced by Maker.DAO versions 1 and 2 respectively.
The subtle problem is brought by shifts in asset values. If the collateral asset depreciates or the borrowed asset appreciates, the ratio of collateralization for the loan may fall below the target. The borrower is ought to take action and add collateral or partially repay the loan, but may also fail to intervene. Since smart contracts cannot act on their own, a third party must, having monitored the market and the state of the loan, interject and perform a liquidation by selling the collateral and repaying the loan with accumulated interest.
For the reasons of decentralization (to prevent potential foul play on behalf of the platform), a common approach is to outsource this task to arbitrary market agents. If a loan is under the desired collateralization ratio, anyone is allowed to, depending on the implementation, either buy out the collateral directly under some rules, or start an auction for the collateral. Both options incentivize market agents by offering the collateral at a discount to its market value.
Tokenized liquidity pooling
The decentralized approach to capital provision makes full use of the perfect accounting capabilities of blockchains. A pool of a particular asset (or assets) is associated with a list of users that own a particular share of that pool. This is tracked with a separate token that represents share ownership: whenever a user adds some value to the pool, pool tokens (often also called “liquidity tokens”) are minted and assigned to this user in a way that the minted amount represents the same share of the token mass as the added liquidity in the whole liquidity in the pool. When the user exits, the pool tokens are burned, and the corresponding share of total liquidity is sent to the user. Entry and exit are usually at will.
Aside from liquidity deposits and withdrawals, usually some additional operations are allowed on the pool with a requirement that the total value of the liquidity in the pool (or other assets the system otherwise has custody of) is never decreased. For lending pools the additional operation is lending, with collateral being placed somewhere else into the system and liquidation mechanisms enforcing solvency of that collateral.
Tokenized pools often have an incentivization mechanic included — if the system based on the tokenized pool generates revenue, this revenue can be paid to pool owners by simply adding it to the pool. As no new pool tokens are generated with that operation, the value of each individual token increases proportionally. Consider a scenario where Alice deposits some ETH into a lending pool for a period of time.
Initially, there is 100 ETH in the pool, and the total amount of liquidity tokens lETH in existence is 100.
Alice deposits another 100 ETH. At this time 100 lETH are minted and assigned to Alice, representing her share of the pool.
Jill borrows 120 ETH from the pool, then returns it after some time, paying 5 ETH in fees.
The total amount of ETH in the pool is now 200 + 5, while total supply of lETH remains at 200.
Alice decides to withdraw her deposit. She sends her 100 lETH into the system, which are burned, and Alice receives x from the equation: 100/200 = x / 205, which stands for 102.5 ETH, giving her a profit of 2.5 ETH.
The overcollateralized loan protocols in DeFi employ the two above patterns with some variations. They pool together depositor funds and give out loans in form of CDPs, adding the fees back into the pools. Specialized lending solutions usually cross-pollinate their pools, adding the collateral of the loans into the respective liquidity pools where they can be also borrowed. Since collateralization ratio is always bigger than 100%, the properly functioning system is always solvent: even if a pool of a particular asset may be currently depleted (i.e. all the liquidity has been lent out), the system holds somewhere collateral in excess of the value of everything given out.
The rates, both on lender and borrow sides, are variable, and are dependent on the fraction of funds in the pool that are utilized, i.e. borrowed. Variable rates are an effective instrument of balancing loan supply and demand. When the demand for an asset is high (i.e. the pool is highly utilized), the lenders are incentivized to add funds to the pool and earn large interest rates, while borrowers will want to close their loans early during the periods of high interest. Conversely, a pool with low demand and high supply (i.e., low utilization) will incentivize borrowers to borrow more with reduced interest rates, while lenders will likely distribute their capital to more profitable instruments.
To protect lenders against losing their funds or interest, loans can be liquidated by third parties when the value of collateral depreciates below a certain maintenance threshold. Any market agent can repay a loan in this case and get a premium on collateral, while the lenders get their due. This means that the borrowers are effectively penalized by the liquidation premium, which incentivizes them to maintain the health of their debt positions.
Collateralized loans are represented by protocols such as Compound or Aave. Protocols of this kind do not differ much in terms of the mechanism itself, but their pricing policy (i.e., the relation between utilization and interest) may vary quite significantly.
Instrument-specific borrowing pools
Recently, a number of protocols for margin trading, such as bZx or dYdX, emerged. These protocols rely on borrowed assets to generate leveraged positions. However, they do not use standard borrowing protocols, and instead keep their own pools.
Margin trading protocols use the same general patterns, and liquidate leveraged positions when they go below or above a certain threshold. However, the collateralization requirements are more relaxed, as long as the maintenance margin is upheld. This makes compatibility with collateralized borrowing protocol a challenge — as the instrument would not be able to satisfy their collateralization requirements — and the simpler solution is having a separate pool that operates under its own set of rules.
Typically, pools attached to instruments have higher interest rates, because the usage of funds is immediately ensured by speculators’ demand of marginal trading. At the same time, lending in instrument-based pools can be riskier, because the safety margins are generally smaller compared to overcollateralization, e.g., with a leverage of 10 a sudden price drop of 10% (considering that the network may already be congested from liquidations in other protocols, it may not be liquidated in time) will burn all of the trader’s money, leading to the system being unable to repay lenders in full.
Flash loans are a very recent mechanism that can be arguably considered one of the most important developments in DeFi, and they rely heavily on atomicity of transactions. Atomicity is the guarantee of the underlying blockchain protocol (in our case, Ethereum) that a transaction of any complexity, which may include multiple interactions with smart contracts and transfers, is either performed in its entirety, or completely undone as if it was never started. For example, if a complex transaction starts with sending out some ETH, and then tries to send some tokens in excess of what is owned by the actor, the second part fails, but the first part is reverted as if nothing ever happened.
Using that property, flash loans do not require collateralization or maintaining a margin, but only that the full sum of the loan (plus small interest) is returned by the end of the transaction. If the sum is not returned, the transaction simply reverts entirely, undoing all the changes that the transaction tried to make. This property allows the loan provider to guarantee that the funds are always returned (in essence, they are not given out unless they are returned ‘later’).
Flash loans demonstrate how powerful DeFi can truly be — purely through algorithmic enforcement flash loans do not require loan negotiation or any kind of collateral. Capital essentially comes at zero cost as long as the operation it was used in is at least a bit profitable, and if a borrower miscalculated or got unlucky, everything is rolled back, barring network fees. This is a kind of a mechanism that is hard to imagine in traditional finance, because after giving out a loan (even a very short-lived one) repayment can only be enforced institutionally.
Flash loans solve in DeFi a long-standing inequality in traditional finance that leads to path dependency and general inefficiency of capital use — that is, capital prerequirements. To engage with the markets and earn, one has to either seek a counterparty to borrow funds from, or be fortunate enough to receive windfall. A huge part of the world’s population is barred from both of those opportunities.
Flash loans do not have capital pre-requirements, and only demand a level of expertise to use them, thus being a large step towards making finance more meritocratic. Due to the atomicity requirement, however, the number of use cases for flash loans is currently limited. Flash loans do not allow one to enter positions — however, they can be used to engage with risk-free transactions, such as arbitrage, liquidations, or staking. Even when one starts off with no capital, they have multiple ways to build their starting capital that can then be used in other transactions.
There are also several important convenience and capital efficiency functions of flash loans, such as collateral or protocol swapping in collateralized loans. Flash loans allow one to atomically take a flash loan to repay a collateralized loan, take out collateral, swap it or move it to another debt position, and then re-borrow the funds and repay the flash loan. This allows for much more flexibility in optimizing interest rates than was previously possible.
Flash loans were also used in several prominent attacks on DeFi protocols, although this fact only reinforces their usefulness — all of the attacks could be performed without flash loans, by simply using pre-existing capital, but it was much more convenient to use flash loans instead of sourcing funds.
There are no specific flash loan protocols, but rather, multiple existing protocols that naturally have pooled liquidity in their possession due to their main business model also give out flash loans. Two examples of that are Aave and dYdX.
Loans in DeFi feed into all kinds of useful activities. Individual users can earn interest on their holdings without dealing with banks or any actual counterparties. Traders can borrow and lend actively, making the exchange markets and capital provision markets more efficient. Companies can combine having long-term speculative positions with short-term usage of borrowed liquidity. In traditional finance, all of these are separate markets, with sometimes quite long chains of intermediaries and aggregators standing between lenders and borrowers. Decentralized finance has the potential to sidestep that separation by capital pooling that requires zero human or contractual interaction, as the rules and mechanics of the contracts are baked into the smart contract layer.
Flash loans are a unique addition on top of that, potentially even further democratizing finance by eliminating capital requirements for operations that can be completed within one atomic blockchain transaction. They also have several rather technical utility usages, such as in repaying part of a CDP by selling off some of the collateral, which is more constrained without flash loan usage.
This article was written by Alexander Bokhenek, tech lead at Republic Advisory Service and co-founder of Byzantine Solutions. It is a part of the ``How to think about DeFi?`` introductory series. An in-depth report on DeFi co-authored by Byzantine Solutions and Cointelegraph Consulting can be found here:
This educational article is provided by Republic to help its users understand this area of the market, it should not be construed as investment advice as it is impersonal, disinterested and was produced by Republic for Republic’s users, without remuneration received or expected.
Republic's latest funding round
Republic has announced a $150M Series B round led by Valor Equity Partners. Valor, known for early investments in SpaceX and Tesla, is adding Republic to its portfolio as a bet on the future of private investing and digital assets.
Amber Lewis, The Good Kitchen
If you want to change how people eat: Work hard. Play hard. And never compromise your vision.