How Decentralized is DeFi? – Part 3/3

Published by Mario Oettler on

If you have missed the previous parts, you can find part 1 here and part 2 here.

In this part, we will take a look at some selected DeFi services like NFTs and decentralized exchanges.

NFTs

First, we need to understand what an NFT is. An NFT (nonfungible token) is basically a smart contract that has a mapping between a token id and an address. In Solidity this looks as follows:

The code snippet is taken from the ERC721 implementation by OpenZeppelin.
https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC721/ERC721.sol

A mapping is like a table where in the left column, the token ID is written and in the right column, the address of the token holder is written.

If a user buys an NFT, he buys this entry in a table. That’s all. But how is this table entry linked to all those nice little pictures popping up everywhere? There is another part in the contract that makes the link:

As you can see in line 96, there is a base URI given. This URI points to some server (or IPFS). Then, in line 97, the token id is added to this base URI. It points to the image on the server.

What does this mean for decentralization? On the one hand, the smart contract runs on a decentralized network like Ethereum. But the visual representation of the information is stored on a central server. In the case of IPFS, this is not central but has its own downsides.

If the image file is stored on a central server, it can be changed or deleted at any time. (Of course, it is possible to create a hash of the image and use this hash as token id. In this case, it could at least be checked if the picture was altered.)

Market Places

Another aspect of NFTs is marketplaces. NFT marketplaces are services (websites or apps) that allow users to create, sell and buy NFTs without worrying too much about the technology. They also provide a way to display the images of the NFT collection.

Decentralized Exchanges

There are plenty of decentralized exchanges. The following image shows just a fraction of them.

List of decentralized exchanges. Source https://www.dapp.com/dapps/defi.

At first glance, this looks like a very diverse market with lots of choices for the clients. But on closer inspection, it turns out the be a very concentrated market. If we look at the funds managed by these exchanges, we see that Uniswap V3 holds almost ¾ of all funds.

Source: https://www.dapp.com/

While coding and deploying a DEX smart contract is not too difficult (but don’t think it is easy to write a secure contract), the difficulty lies in operation. Most decentralized exchanges try to work without external information. Instead, they rely on a function that determines the price of an asset pair. In its simplest form, it is a constant product function like:

K = a * b

The price is determined by the exchange ratio of tokens a and b. The idea is to keep the k always constant across all trades. The downside of this formula is that with larger trades, the price slip is larger. This could deter traders. One fix is to increase the constant k. However, this requires a larger liquidity pool for token a and b.

Liquidity providers are attracted by the fees they earn if someone uses a DEX. So, if more users use a DEX, the more attractive the DEX is for liquidity providers. And in turn, it becomes more attractive for users. This makes it harder for new DEXs to gain a foothold which can lead to a monopoly in the DEX space.

Uniswap is a DeFi protocol that anyone can operate. The smart contract’s source code is open source and doesn’t show any mechanisms that block certain addresses. While DEXes like Uniswap themselves are central services (= one smart contract), they run on a decentralized network.

User Interfaces

Now, let’s look at the user interfaces of DeFi services. In general, smart contracts can be used directly by sending a transaction to the blockchain network. But creating this transaction manually is difficult for most people. They need a convenient user interface that displays the balances, provides a form for entering data, and takes care of building the transaction and letting it sign by a wallet (like MetaMask). This fosters the adoption of DeFi services. But it also creates a dependency on these user interfaces. Typically, user interfaces are hosted centralized. This means that the operator has some degree of power. It could for example, ban certain addresses or customers from using this user interface, as the following examples show.

Wallets

Here, we think of wallets as user interface. Wallets allow users to manage their private and public keys, create transaction, sign transactions, and monitor the balance of the user’s address. Some wallets provide even more services like monitoring tokens, signing of messages, interaction with smart contracts, etc.

Hence, wallets are an important access point for users to the blockchain network.

Both Bitcoin and Ethereum boast many different wallets. That’s a good thing because if one wallet should stop working, it is possible to switch to another wallet by exporting/importing the private keys or using the mnemonic.

But where there is light, there is also shadow. In order to display the balance of each address or to send transactions, (SPV) wallets need to connect to full nodes. The node is usually set in the default configuration and users don’t need to care about this – as long as it works.

Both full nodes or wallets could censor certain addresses making it harder for the user to send coins, interact with smart contracts, or monitor the balance.

Connection between wallets and full nodes.

If we have a situation like in the figure above, it could look to a user like a diverse ecosystem. But in reality, only two full nodes provide information and relay transactions to and from the wallets.

MetaMask, a popular Ethereum browser plugin wallet, uses Infura as default full node (both are controlled by the same company). But it also allows users to set an individual full node URI as RPC-URL.

When talking about publicly available full nodes, the picture for Ethereum doesn’t look that good. There are basically two full nodes available: Infura and Alchemy.

General Considerations/Conclusion

We can say that DeFi runs on a decentralized layer and it uses smart contracts that are accessible by everyone. But in the whole tech and organizational stack, there are centralized elements. There are different reasons ranging from convenience (people don’t want to run serves) to market inherent developments (network effects).

Categories: Blog