What are DeFi Protocols?

A Step-by-Step Guide to How These Crucial Projects Work

By: Rahul Nambiampurath Loading...

What are DeFi Protocols?

DeFi protocol is a set of codes that govern how digital assets are used on a blockchain network. Tapping smart contracts and virtual machines (VMs), DeFi protocols manage exchanges, enable users to lend and borrow, and run decentralized autonomous organizations (DAOs).

Given that Ethereum is the largest programmable blockchain network for decentralized finance (DeFi), the virtual machine is typically an EVM. Nonetheless, DeFi protocols, or decentralized applications (dApps), refer to all programmable blockchain networks outside of Bitcoin.

Why Do We Not Associate Bitcoin With dApps?

Bitcoin is the largest cryptocurrency but is not associated with DeFi protocols. How is that possible?

All open-source and public blockchains employ smart contracts on some level to generate cryptocurrencies. In the case of the Bitcoin network, it generates BTC. Bitcoin’s embedded smart contract governs how many BTC there are (21M), its halving mechanism, and how BTC is trustlessly sent between parties.

Computer programs run smart contracts on an automated basis. When these predefined events occur, smart contracts execute actions without the need for third-party arbitrage. This is how we get decentralized applications — dApps — because their code is on a decentralized blockchain, which is essentially a distributed database.

Bitcoin was intentionally limited in its scripting functionality. In essence, Bitcoin is itself a dApp, as sound peer-to-peer money focused on being a store of value. (Bitcoin has yet to demonstrate it can serve as an alternative payment system).

As a result, the entire network has to be added on top of Bitcoin to make it possible to create DeFi protocols, such as Stacks. In contrast, other blockchains were inherently designed to be programmable networks for DeFi protocol deployment.

What Are DeFi Protocols: Rulesets and Algorithms

In computer networking, protocols run processing and formatting data between network nodes. Blockchain networks add an extra twist with smart contracts, which govern the conditions under which data is processed and executed.

While protocols set the rules of engagement, algorithms execute them. Algorithms run through instructions that enforce the protocol ruleset. This is typically done through decision trees.

Source: Toolbox

Translated into the world of DeFi protocols, such algorithms would conduct the following actions:

  • A user deposits funds into a smart contract holding token pair liquidity — USDT/ETH
  • Another user borrows USDT from that token pair liquidity pool.
  • The smart contract’s preset rule is that the borrower must deposit a collateral to borrow USDT.
  • The algorithm notes whether a proper collateral is deposited. Likewise, the algorithm notes whether the loan’s value exceeds the collateral.

For instance, if the loan-to-value (LTV) is 95%, one would have to deposit $10,500 USDT to receive a $10,000 USDT loan. If it happens that USDT value goes down, the algorithm would then liquidate the collateral, so the depositor (liquidity provider) remains undamaged.

What is DeFi Borrowing?

What is DeFi Borrowing?

A Primer for One of the Most Popular Practices in DeFi

The Defiant The Defiant

So, DeFi protocols take advantage of both smart contracts (rules) and algorithms (active enforcement) to create decentralized finance — DeFi. Another component critical to DeFi are virtual machines.

Virtual Machines Power Algorithms

Smart contracts set the rules of DeFi engagement, while algorithms enact them. But how do algorithms run?

Otherwise called run-time environment, virtual machine (VM) is the DeFi engine. Consider video games for a moment. How do they run?

Video games use engines to combine all the gaming assets — audio, video, text, textures, animations, physics — and deliver an interactive, playable experience. In the same way, virtual machines run smart contracts, i.e., algorithms that execute smart contracts.

What Is Maker?

What Is Maker?

A Step-by-Step Guide to One of DeFi Most Influential Lending Protocols

The Defiant The Defiant

Ethereum has its Ethereum Virtual Machine (EVM), a software layer on top of the Ethereum blockchain executing smart contract code. Whenever you interact with a decentralized exchange like Uniswap or a DeFi lending protocol like Aave, EVM executes scripts (smart contracts) based on user inputs.

On Ethereum, all smart contracts are built using the Solidity programming language. This code is then compiled into the EVM to be executed. Likewise, when programmers develop video games, they use C++ to compile scripts, executed by the Unreal Engine 5.

DeFi Protocols: Programmability, Transmutability, and Security

Unlike Bitcoin’s lack of scripting flexibility, Solidity, alongside other programming languages, makes smart contracts highly programmable. This is exceedingly important because the difficulty in deploying smart contracts is often the difference between mainstream adoption vs. the network remaining on the fringe.

For example, the Solana blockchain is often noted as developer-friendly due to its comprehensive documentation on Solana Programs (smart contracts). This applies from the DeFi protocol’s conceptual vision to implementation using the Rust programming language.

Next to programmability ease, DeFi protocols are valued for their transmutability. Also called composability, this means that smart contracts can work together between DeFi protocols to create a new service.

For example, Alchemix lending protocol uses another DeFi protocol — Yearn Finance — to create yield-generating strategies to auto-repay loans.

When it comes to security of DeFi protocols, the story takes a more risky turn. In 2022, hackers drained $3B from smart contract exploits. You may wonder, how is it possible to hack DeFi protocols if they are hosted on a purportedly immutable ledger?

The War On Code: Investigating the Tornado Cash Sanctions and the Arrest of Alexey Pertsev

The War On Code: Investigating the Tornado Cash Sanctions and the Arrest of Alexey Pertsev

In August, just a few months ago on these very streets in Amsterdam, armed agents from the Fiscal Information and Investigation service (FIOD) suddenly arrested a man by the name of Alexey Pertsev…much to his own surprise. We do not yet know all the details surrounding his arrest, but what we do know is that…

The Defiant The Defiant

Blockchains act as immutable ledgers because each data block is chronologically chained. This data is then synced with hundreds of thousands of other network nodes and verified as true, making one giant distributed database. To tamper with one block would then mean to create a falsified block that would be dismissed by the entire network.

As blocks contain smart contracts that store information, this decentralized structure makes DeFi protocols tamper-proof. Nevertheless, this level of security applies to already stored data (transactions), not active smart contracts.

If a smart contract is poorly written and not audited by third parties, they are not free from potential exploits.

From dApps to DeFi Protocols

You may have noticed that “dApps” and “DeFi protocols” are often used interchangeably. There is some important differentiation to keep in mind.

dApps are web-side user interfaces that connect the user’s browser with the DeFi protocol, its smart contracts, and algorithms hosted on a blockchain network. In other words, the DeFi protocol can exist without a web interface.

While technically, it would be true that such DeFi protocols could be usable, they would have to demand very advanced knowledge. But this doesn’t matter in the end because DeFi innately relies on being user-friendly.

What is zkSync?

What is zkSync?

A Step-by-Step Guide to the High-Capacity Blockchain Network

The Defiant The Defiant

For example, let’s say a lending protocol like Aave doesn’t have a web interface. Its liquidity would be gone in an instance, because the vast majority of people would not bother learning a programming language to access it.

In fact, this is precisely what happened with Tornado Cash when OFAC sanctioned it. The smart contracts that created this financial privacy protocol were left intact on Ethereum blockchain. But because Web3 companies like Infura and Consensys (MetaMask wallet) had to comply with the sanction, the link between Tornado Cash (the protocol) and Tornado Cash (the web interface) was severed.

For all intents and purposes, this means that dApps and DeFi protocols are one and the same.

Series Disclaimer:

This series article is intended for general guidance and information purposes only for beginners participating in cryptocurrencies and DeFi. The contents of this article are not to be construed as legal, business, investment, or tax advice. You should consult with your advisors for all legal, business, investment, and tax implications and advice. The Defiant is not responsible for any lost funds. Please use your best judgment and practice due diligence before interacting with smart contracts.