DeFi and the Future of Finance – Part 2

DeFI

Today’s post is our second visit to a paper from 2021 on Decentralised Finance (DeFi).

Transactions

Chapter 4 of the paper looks at DeFi primitives – the underlying actions from which dApps are made.

The first primitive is a transaction, which sends data and/or a token (often ETH) from one address to another.

  • Externally owned accounts (EOAs – external addresses) can only move ETH.

Contract accounts (internal addresses) receive data to be run against the code in that contract.

  • There can also be an ETH payment for use in the contract.

A transaction can interact with any number of dApps or smart contracts before completing.

  • The initial contract in the transaction will detail all the subsequent steps.
  • If a later step fails, the whole transaction will be reversed.

Transactions have gas fees which vary with the complexity of the transaction.

  • Transactions that revert – or which run out of gas before completing – do not refund the gas used up to that point (in order to avoid miners losing out).

Gas prices are fixed by an auction for entry in the next ETH block.

  • Later transitions with higher gas fees will displace earlier transactions from the mempool (memory pool) for the next block.

Mempools can be queried via communication with mining nodes.

  • Miners can front-run transactions (leading to MEV, miner extractable value) and transactions are sometimes obfuscated to avoid this.
Fungible tokens

The ERC-20 interface includes six functions/methods:

  1. totalSupply()—read the token’s total supply;
  2. balanceOf(account)—read the balance of the token for a particular account;
  3. transfer(recipient address, amount)—send “amount” tokens from the transaction sender to “recipient address”;
  4. transferFrom(sender address, recipient address, amount)—send “amount” tokens from
    the balance of tokens held at “sender address” to “recipient address”;
  5. approve(spender, amount)—allows “spender” to spend “amount” tokens on behalf of the account owner;
  6. allowance(owner address, spender address)—returns the number of tokens the “spender address” can spend on behalf of the “owner address”.

The contract will reject transfers that are unauthorised or don’t reference a high enough token balance.

There are three main types of token, though a token can have more than one property:

  1. equity tokens that represent ownership of a pool of assets
    • It can also represent ownership of a share in the future growth of that pool, which would act as a dividend
  2. utility tokens “drive the economics of a system, creating scarcity or incentives”; examples include:
    • collateral (SNX)
    • reputation or stake (REP, LINK)
    • maintain stability to the underlying (DAI, Synthetix Synth)
    • pay fees (ZRX, DAI, LINK)
  3. governance tokens are like equity tokens but only control voting rights
    • many contracts allow for parameter changes or for additional functionality
    • governance tokens can have static supplies, inflationary supplies (rewards for use) or deflationary supplies (governance combined with utility to pay fees – tokens are then “burned”
Non-fungible tokens

A year ago, this section would have made little sense to me, but 2021 was in many ways the year of the NFT.

The ERC-721 standard is like ERC-20, but each token has a unique ID.

An additional method, ownerOf(id), returns a specific token, referenced by its ID, that the address owns.

NFTs are also known as deeds and could be used for loans or tickets, as well as collectables (including art).

NFTs can also represent scarce items in a game or other network and retain economic value in secondary markets for NFTs.

There is also a standard (ERC-1155) for fungible and non-fungible tokens.

  • This can save on gas fees through batching.
See also:  Libra
Custody

A contract can escrow or custody funds so that they can’t be transferred. This supports other functions:

  • Fees and incentives
  • Token swaps
  • Market making and bonding curves
  • Collateralized loans
  • Auctions
  • Insurance

Token transfers usually include safety checks that the tokens won’t become permanently custodied.

Supply adjustment

Contracts can mint (create) and burn (destroy) tokens.

  • Burning can mean sending the token to a non-owned (ETH) address or sending them to a contract that can’t spend them.

Burning can be used to:

  1. Redeem the underlying
  2. Increase scarcity and hence token price
  3. Penalise bad actors

Minting can be used for:

  1. Entering a pool and acquiring ownership
  2. Increase supply and reduce price (eg. seigniorage stablecoins)
  3. Reward good user behaviour

Acting to chase rewards is known as yield farming.

Bonding curves

A bonding curve shows the relationship between the token supply and its price (in terms of the asset used to purchase it – usually ETH).

  • The curve is defined in a contract for buying and selling the token.

The simplest “curve” is TKN=1*ETH, pegging the token to ETH.

Linear bonding curve

The next simplest bonding curve is a linear one, where price(TKN) = supply(TKN)*m + b

  • In the chart above, m=1 and b=0.

A monotonically increasing bonding curve rewards early investors, because any incremental demand beyond their purchase price would allow them to sell back against the curve at a higher price point.

Super linear bonding curve

A super-linear bonding curve would be even more rewarding to early adopters.

In practice, most projects would use a sublinear growth rate or a logistic function that converges on an upper bounded price.

Sigmoid bonding curve

You can also have different buy and sell prices.

The selling curve could have a lower growth rate or intercept than the buying curve. The spread between the curves would be the value (in this case ETH) accrued to the smart contract and could represent a fee for usage or used to finance more-complex functionality within the system.

Buy and sell curves

Incentives

The report only looks at token payments and fees – staked and direct incentives.

Staked incentives apply to a balance of tokens custodied in a smart contract.
Direct incentives apply to users within the system who do not have a custodied balance.

There are several flavours of staked reward:

  1. Minimum threshold or all holders
  2. Fixed payout or pro-rata
  3. Same token as the stake or a different token

Slashing is taking part of a balance because of an undesirable event (what we in TradFi might call a haircut). Again there are several flavours:

  1. Complete or partial slashing
  2. The cause – under collateralization or malicious behaviour or change in market conditions (eg. price stabilisation by reducing supply)

Direct rewards are often triggered by externally-owned (non-ETH) accounts (EOAs) known as keepers.

A keeper is a class of EOA incentivized to perform an action in a DeFi protocol or other dApp. A keeper is rewarded by receiving a fee, either flat or percentage of the incented action.

With sufficient incentivization, autonomous monitoring can be outsourced off chain, thus creating robust economies and new profit opportunities.

There is a drawback:

A side effect of direct rewards for keepers is that gas prices can inflate due to the competition for these rewards. That is, more keeper activity generates additional demand for transactions, which in turn increases the price of gas.

Fees are problematic due to ETH’s pseudonymous nature:

If the smart contract is open to any Ethereum account, the only way to guarantee off-chain enforcement or legal intervention is for all debts to be backed by staked collateral, which is transparent and enforceable.

DEXs

Swapping (of one token for another is done on platforms called Decentralised Exchanges (DEXs). There are two options for this:

  1. Order-book matching – requires willing counterparties and limits liquidity
  2. Automated Market Makers (AMMs) – these quote buy and sell prices (bid and ask)
See also:  Bitcoin and the blockchain - time to invest?

Automated market maker

AMMs suffer from the problem of impermanent loss (see diagram above):

Impermanent loss occurs for any shift in price and liquidity, because the contract is structured to sell the appreciating asset and to buy the depreciating asset. If the goal for liquidity held in the contract is profit, any fees charged must exceed the amount of the impermanent loss.

AMMs will have less of a problem trading pairs of stablecoins, which should have mean-reverting prices.

Loans

Loans of non-zero duration (more on this later) must be collateralised.

  • The prevents default and/or stealing funds.

There is still the risk that the collateral becomes less valuable than the debt, which should lead to foreclosure (as per a mortgage).

  • Volatile collateral will require a higher collateralisation ratio.

A foreclosure could mean an auction of the collateral or a direct sale on a DEX/AMM.

Positions in the Ethereum blockchain cannot be liquidated automatically, so an incentive is needed. The incentive often takes the form of a percentage fee allocated to an external keeper who is able to liquidate the position and collect the reward. Any remaining collateral is left to the original holder of the position.

Since penalties can be severe,  platforms usually allow borrowers to top-up their collateral (similar to a margin call in TradFi).

There are also flash loans, which are unique to DeFi:

A flash loan is an instantaneous loan paid back within the same transaction. A flash loan is similar to an overnight loan in traditional finance. If the loan is not repaid with required interest by the end of the transaction, the whole process reverts to the state before any money ever left the lender’s account.

This means flash loans have no counterparty or duration risk, though they do have “smart contract risk” (of a bug in the code).

They allow a user to take advantage of arbitrage opportunities or refinance loans without pledging collateral. This capability allows anyone in the world to have access to opportunities that typically require very large amounts of capital investment.

I’m not sure why this is such a great idea, but perhaps things will become clearer when we look at DeFi solutions in detail.


That’s it for today.

  • We’re about 40% of the way through the report, so unless things speed up, there could be a total of five articles in this series.

It’s been harder going than I expected, but also quite rewarding.

  • In the next post, we’ll look at the problems that DeFi solves, and perhaps some of the solutions themselves.

Until next time.

Mike is the owner of 7 Circles, and a private investor living in London. He has been managing his own money for 35 years, with some success.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

DeFi and the Future of Finance – Part 2

by Mike Rawson time to read: 5 min