Introduction to Decentralised Finance

In this article we present an overview of the different decentralised finance (DeFi) products, with a particular focus on loans which are arguably the most popular application. By the end of the article the reader should have an idea of what is meant by DeFi and the different strategies for profit that people are using to make money with decentralised lending platforms, as well as the risks associated.

What is Decentralised Finance (DeFi)

DeFi is an approach that is primarily focused on decentralising the power dynamic over money, helping people have better relationships with their money and avoiding being exploited as well as increasing access to financial services by disintermediating all the gatekeepers (banks).

On Ethereum, you can write smart contracts that interact with money and can represent products such as loans, collateralised debt, etc. In other words, smart contracts become the intermediaries on the Ethereum platform instead of banks in the centralized world.

DeFi involves taking existing financial products and porting them over to the blockchain. Similar to Lego, individual parts of DeFi can be pieced together to make something new. For example, ETH is used as collateral into the MakerDAO protocol to mint DAI tokens (a stablecoin pegged to USD), DAI can then be supplied to Compound (a lending platform) to earn interest in a token called cDAI, cDAI tokens can be used in other DApps.

DeFi products can be categorised as follows:

  • Loans
  • decentralised Exchanges (DEXes)
  • Derivatives
  • Payments
  • Assets


Maker and Compound are examples of collateralised lending platforms. MakerDAO is one of the most popular lending DApps, it allows you to lock in ETH for DAI, a stablecoin pegged to the USD. DAI provides a way for token holders to access liquidity at the cost of an annual interest rate. Often the collateral position is higher than the loan amount.

There are a few websites which help users look for the best interest rates across all major lending platforms and for different cryptocurrencies or stablecsoins available. Two such platforms are and

A major attraction of decentralised finance is that it allows investors to earn competitive interest rates, much more competitive than traditional finance without the need for KYC or to be an accredited investor, and this fact by itself could drive the adoption of blockchain. DeFi loans allows investors to get passive income from cryptocurrency markets without speculating on cryptocurrency prices.

Compound is currently the most popular lending platform due to its usability, although other competitors such as Aave and dYdX are making their way to the top quickly as they are becoming popular flashloan liquidity providers.


Decentralised Exchanges

DEXes allow you to quickly exchange different cryptocurrencies and stablecoins, and may be used as part of flash loan strategies in order to acquire the assets needed. The website allows users to find the best exchange rates across all decentralised exchanges, as seen below.




Set Protocol ( in particular is gaining a lot of popularity over the past months.

Tokensets allows you to use automate asset management strategies that calculate when to buy and sell crypto in order to rebalance your portfolio. You can also follow professional traders by following their strategies at the click of a button.


Arbitrage using flashloans

You don’t need to hold any cryptocurrency in order to trade it. The trades can’t fail and if they fail you don’t lose any money (you don’t make any either though).

Arbitrage Strategies

Arbitrage Sequence

For example, in a flashloan you could get a loan in order to borrow Dai, sell it for Ether on the Kyber network decentralised exchange, then sell Ether for Dai on Uniswap, the goal being to have more Dai then you started with.

Basic Requirements and considerations

  • Gas fees, which depend on the complexity of the flash loan contract, the number of contract calls, etc.
  • Flash loan fees which are decided by the flash loan provider
  • You will need to transact with multiple decentralized exchanges for exchange arbitrage
  • There could also be opportunities for arbitrage across multiple trading pairs

If there are abitrage opportunities involving a currency pair that is not offered by one exchange, say ZRX/OMG. In this case you can still borrow DAI and swap it for ZRX, then swap ZRX for OMG, and finally go back to DAI by doing this process in reverse. This process is called triangular arbitrage. Triangular arbitrage is a specific strategy, where you draw your layout currencies on a triangle, they don’t have a common currency, and then you trade currencies from an angle of the triangle to the next until you get back to where you started.

Yield Farming

What is the return on investment?

  • Transaction fee income
  • Token rewards
  • Capital growth

Transaction fee income

Token rewards

Capital growth

What to Consider Before Yield Farming

Misleading APY

Liquidity provision can be fickle; users are able to move their liquidity from one place to another, hunting out the best possible return at the time. This means that the APY of a certain strategy can shift dramatically day to day.

Price volatility

DeFi Risks

  • Smart contract risks
  • Oracle risks
  • Exchange rate risks
  • Black swan events

DeFi is an immature area, being only about one year old and yet over the past few months we have seen its various components being exploited multiple times, a non comprehensive list of exploits is:

  • Jun 2019: Synthetix sETH $37m
  • Feb 2020: bZx $900k
  • Mar 2020: iEarn $280k
  • Mar 2020: MakerDAO Black Thursday $9M
  • Apr 2020: LendfMe $25m
  • Apr 2020: imBTC Uniswap Pool $300k
  • Jun 2020: Balancer $500k ETH
  • Jul 2020: Liquid $16m BTC (avoided)

One likely reason for this recent explosion in the number of hacks is due to the rise of flashloans; most of these exploits would not have been possible without flashloans as they require large amounts of capital which attackers need in advance, for example, in order to manipulate price oracles of pump and dump the value of a cryptocurrency.

Smart contract risks

Oracle risk

Synthetix Hack

bZx second hack

With the flashloan, the exploit swaps 900 ETH in two batches for sUSD through Kyber. The sell-off of these two batches effectively drives the price of sUSD to around 2.5x higher when compared to the average ETH/sUSD market price.

The attacker this time takes the approach of first collateralizing the collected sUSD back into bZx and then borrowing from it 6,796 ETH. As bZx relies on Kyber for the price feed, with the spiked sUSD/ETH price, the collection of sUSD allows for the borrow of 6796 ETH, which indicates that this loan is now underwater with insufficient collateralization.

With the borrowed 6,796 ETH (3,082 ETH leftover), the attacker is able to repay the 7,500 ETH flashloan back to bZx with the profit of 2,378 ETH.

Exchange rate and liquidation risk

Exchange rates can also impact the viability of a position in DeFi. For instance, in the borrowing and lending platform, Compound, a user farming COMP may find that their position is liquidated as the value of their collateral falls below the required amount due to an unfavourable exchange rate movement.

Black swan events

In normal circumstances the response would be that through automated systems as well as manual intervention, users would add DAI back into the system in order to re-collateralize their loans, or put ETH as additional collateral in order to refund or re-collateralize their loans. However, during the time when the value of ETH dropped 55%, the gas price increased and it became difficult to get transactions accepted. The situation was compounded by a bug in the auction system that allowed some users to buy some of these loans for close to zero and liquidate them. In the end the damage was only about 5 million dollars, and most accounts affected were reimbursed.

Although this was a black swan event, it shows how a cascade failure of multiple problems all occurring at the same time can happen and therefore is a risk that should be taken into account.


This article is the first of a series, in the next articles we will cover flash loans in depth and yield farming individually, including strategies, flash loans code examples and trading bots that are ready for testing on the Ethereum Mainnet.

Oxford-based blockchain and zero knowledge consultancy and auditing firm