All posts by B.Vinoth Raj

DeFi

DeFi : The Future of Finance

The application of blockchain technology in the world of finance has created a new landscape called DeFi or decentralized finance. DeFi has manifested an astonishing growth in the year 2021 and it is still burgeoning. It has unleashed a wave of innovation.

What exactly is DeFi?

There is no standard definition for Decentralized Finance. Some say it is an alternative financial infrastructure, some say it is an umbrella term for peer-to-peer financial systems, some say it is a competitive marketplace of decentralized financial applications, and so on.

Decentralized Finance is an ecosystem of financial applications and protocols that runs on blockchain technology. Blockchain technology is inherently decentralized in nature. DeFi financial applications leverage this aspect and run without relying on intermediaries like banks, brokers or exchanges. Moreover, the backbone of all DeFi protocols and applications is smart contracts.

What problems does DeFi solve?

The biggest and the fundamental problem that DeFi solves is the removal of intermediaries in the financial system. Harvey et al. in their book Defi and the Future of Finance describe that DeFi solves five key problems of the current financial system: centralized control, limited access, inefficiency, lack of interoperability, and opacity.

Harvey et al. in their book Defi and the Future of Finance describe that DeFi solves five key problems of the current financial system: centralized control, limited access, inefficiency, lack of interoperability, and opacity.

The DeFi Market:

DeFi has manifested tremendous growth in the year of 2021. As of January 15, 2022, the total value locked in the DeFi space was approx $237 billion, growing by a staggering 1,266% from the January 1, 2021 figure of $18.71 billion.

Figure 1: Total value locked (TVL) in DeFi as of Jan 15, 2022 (Source DeFi Llama)

How can DeFi solve your problems?

DeFi solves the problem of lack of transparency in the traditional finance system through the open and contractual nature of agreements. Smart contracts helps to encode the agreements. Anyone can read the smart contracts codes thereby ensuring transparency. Moreover, all transactions are publicly visible.

Traditional financial system is trust based and dependent on centralized institutions. DeFi replaces some of these trust requirements with smart contracts. The decentralized blockchain network stores the smart contracts.

Before we delve into each problem, let’s look at the different layers of the DeFi stack.

Figure 2: DeFi Stack

The settlement layer (Layer 1) consists of the native protocol of the blockchain network (e.g., ETH, BTC, MATIC). These native tokens are specific to their blockchain network, i.e, ETH is on Ethereum network, BTC is on Bitcoin network, and so on.

The asset layer (Layer 2) consists of all the assets issued on top of the settlement layer. These assets are usually referred to as tokens (e.g., ERC-20 based DAI token in Ethereum). Developing smart contracts that follow EIP standards like ERC-20, ERC721, ERC1155 helps to create tokens.

The protocol layer (Layer 3) contains the smart contract-based protocol implementation for different use cases such as decentralized exchanges (DEX), lending, derivatives, on-chain asset management, and so forth.

The application layer (Layer 4) consists of end-user applications which are accessible via web browsers or mobile apps.

Layer 5 is the aggregation layer that combines several protocols and applications and provides services like rate comparison, trading strategies, and so forth (e.g., 1inch, Zapper, Zerion).

DeFi solves the problem of limited access by allowing the creation of an open and accessible financial system. It enables direct access to financial services for the globally unbanked population. As a result,  it allows access to all users irrespective of their wealth or geographic location.

DeFi in the current world:

Trading today is extremely centralized in the traditional finance world. Five exchanges control 50% of the volume of all stocks. In a traditional exchange like the New York Stock Exchange buyers and sellers offer up different prices until they come to an agreement on a sale price. Only a small subset of the traditional finance world has access to the full order book of prices, limiting price discovery for everyday users. However, there is a limit on the liquidity for certain securities. DeFi solves these problems with an innovation called automated market makers (AMM).

Decentralized Exchanges use an automated market maker (AMM) for automated trading. AMMs is essentially an exchange which helps to swap one cryptocurrency for another. The liquidity pool maintains a particular exchange rate, for example 10 ETH to 1 BTC. This is a pool with a variable exchange rate between two currencies. The AMM facilitates a price for transactions based on the supply, demand and liquidity in a pool. The investors in the pool put money into it to earn a yield. Some of the popular decentralized exchanges are Curve Finance, Uniswap, PancakeSwap, and SushiSwap.

Traditional finance institutions tend to work in silos and maintain their own ledgers. Hence one financial service may not be interoperable with another. DeFi is built on public blockchains and open standards. This allows for interoperability across different decentralized apps (or dapps). However, there is a limit on the interoperability to the same blockchain network. As a result, there are lots of initiatives in progress that focus on enabling cross-chain communication across different blockchain networks.

Final Thoughts:

FinTech has been trending over the past few years. Many FinTech startups have been harnessing innovation and using technology to improve the delivery of financial services. Fintech companies use technology to create better financial services to customers and other businesses. They include big data, AI/ML, automated CRM, robo advising, personal finance, insuretech, payments, lending platforms, and so on. However, one main difference between FinTech and DeFi is that most of the FinTech solutions are centralized; however all DeFi platforms are decentralized.

Defi not only addresses the drawbacks of the centralized finance systems but also has paved the way to many innovative financial instruments such as atomic swaps, autonomous liquidity pools, decentralized stablecoins, flash loans, among others. In short, DeFi has a lot of potential and can play a pivotal role in the future of finance.

Like other businesses, if you too are looking to develop IT Solutions in Financial Services industry, Mindfire Solutions can be your partner of choice. We have gained significant experience over the years working with Fintech Companies. We have a team of highly skilled and certified software professionals, who have developed many custom solutions for our global clients over the years.

Here are a few interesting projects we have done. Click here to know more:

Case study on e-Wallet mobile application.

Test automation of digital payments.

Case study on Brokerage management system.

Spread the love
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  

How Bitcoin Solves the Double-Spending Problem?

Many of us probably already have heard of Bitcoin. We know what innovation it has brought into this world – the blockchain technology. As of this writing, it has been almost a decade since its inception and it has long thrived without any central control over the network.

Bitcoin, a peer-to-peer electronic cash system, has inspired many other projects and can be seen as a pioneer of the underpinning blockchain technology. That said, it would be worth exploring how Bitcoin solves the double-spending problem. Instead of delving into theoretical exposition we will experience a transaction process in this pioneering innovation. We will be making a transaction on a real network and analyzing what a Bitcoin transaction looks like. A transaction in the Bitcoin network is a bit complex than a conventional digital transaction.

……………………………………………………………………………………………………

Comparison with Fiat Currency Transaction

In a transaction that involves currency notes, we can easily envisage two parties exchanging some goods or services in exchange for the money. One party receives the goods/services and the party pays in currency notes. Let us say the transaction was costing $50 and the payer has $100 currency note. The payer would pay $100 and would receive in change $50 (as shown below). Both the currency notes are legal tender that is supplied by a central bank. A Bitcoin transaction also involves paying and may too involve receiving back change and in this respect is quite similar to our day-to-day transaction.


Comparison with Conventional Digital Transaction

A conventional digital transaction, say the online transfer of money, involves two parties and a mediator (the bank). So, there is a “From address” (A/C No.), a “To address” (A/C No.) and the amount (value transfer). There is no concept of change in a conventional digital transaction. If you want to transfer $1050 then you can transfer the exact amount and this is a mere process of debiting from sender’s account and crediting to the receiver’s account with the help of the mediator who validates the transaction. However, a Bitcoin transaction may involve multiple From addresses and multiple To addresses without any mediator. We will explore how this is possible.

As it is with any traditional transaction, ours will have the following attributes: a “From entity”, a “To entity” and the value to transfer. Let us send an amount of 0.1 BTC to a Bitcoin user as follows:

From: n2FSwa6DsMsbJgNknB64ThR3pHPUQ79bxL
To: msqdPeF7KeEqcWUNAFMm8JQijVB3cnLi4N

Amount: 0.1 BTC

The transaction has been done and the transaction details can be seen here

Bitcoin Transaction

Now, what looks legitimate is the From address (left) and the one of the To addresses with 0.1 BTC sent. However, two things look contradictory. Firstly, we sent 0.1 BTC but it says 1.0 BTC being transferred. Secondly, there is one more To address to which some amount has been sent.

Is something wrong with this transaction? Not really! You can check the above transaction in block explorer and verify yourself that it is indeed the same transaction. But this is the way Bitcoin works. Let us explore.

What is a Bitcoin Transaction made up of?

A transaction in Bitcoin consists of inputs and outputs. The input is like a “From address” which is in Bitcoin terms an unspent transaction output. When you want to make a transaction you will always spend an unspent transaction output as a whole. That said, you end up paying the entire amount. However, you receive the remaining amount in a different address called change address. This change address is your own address where you collect the change, which in turn is an unspent transaction output. This is quite common in Bitcoin transactions. For instance, someone sent you 1.0 BTC. Now you want to send 0.5 BTC to your friend. You cannot break the 1.0 BTC but you will spend the entire 1.0 BTC in a transaction and get the change in your change address.

Transaction Fee

Back to our transaction. Now, let us verify that the amount in input and outputs are balanced. So, 1 BTC – (0.1 BTC + 0.89432145 BTC) should be 0. But it turns out to be 0.00567855. So, where did this amount go?

Well, this is the transaction fee that is paid to the miner who helped you in validating the transaction, adding it into a block, mining the block, and broadcasting to the network. The miner is given this amount as a mining fee for the work he has done.

The mining fee is charged in satoshi per byte. Our transaction has a size of 225 bytes and we were charged 2523.8 satoshi per byte. So, 2523.8 x 225 = 0.00567855 BTC.

The Concept of UTXO

Note that the two outputs here are mentioned as “unspent”. This is how bitcoin keeps track of balances. The sum of all unspent transaction outputs is what constitutes your balance. Bitcoin network does not have any database or global state of balance amount rather it uses the concept of UTXO.

So, how is a UTXO represented in the bitcoin protocol? Perhaps in the bitcoin protocol, there is no concept of “From address”. Yes, there is no concept of From address in Bitcoin. The Bitcoin addresses are used to receive payments. A transaction in Bitcoin never encodes a From address but only has a reference to a previous unspent transaction output. That said, the input of a Bitcoin address is actually a previous unspent output. Bitcoin refers to a previous unspent transaction output using a combination of transaction ID (or transaction hash) and an index. Once an unspent transaction is spent you cannot spend it again and thus prevent the double spending.

A Transaction with Multiple Inputs

So, how will a Bitcoin user transact an amount for which he has no unspent transaction output equal to or above that value? Say, a user wants to transfer 5 bitcoins but none of his unspent transaction output has that much amount although the user has multiple unspent transactions that add up to a value greater than 5.  Bitcoin allows you to combine unspent transaction outputs. A transaction with multiple inputs would sound new to a person doing a conventional digital transaction. This is because a conventional digital transaction always has only one sender (or From address). Let us analyze a bitcoin transaction with multiple inputs. In this case, the Bitcoin user wants to send 1.02 bitcoins but he has no unspent transaction outputs of that value. So, the user combines two inputs and then transacts (see below).

Bitcoin Transaction

The above transaction (ac194c19201a20cdd26bbb8d696588370c06261148fd20a96b3330b0bcb03207 ) has two inputs and two outputs and it is absolutely a valid transaction in Bitcoin. The total amount of BTC of these two inputs, which is 1.04997424 BTC, is sufficient to send a transaction of 1.02 BTC. And the remaining value has been collected in a change address with 0.02997013 BTC.

……………………………………………………………………………………………………

How are transactions validated in Bitcoin?

Let us take an example of a transaction that involves one input and one output (as below). Here,  the input is a reference to a previous unspent transaction at index 0. The previous transaction is referred by a transaction hash: f5d8ee39a430901c91a5917b9f2dc19d6d1a0e9cea205b009ca73dd04470b9a6
The output sends 50 bitcoins to a bitcoin address. When the recipient wants to spend this 50 bitcoin he will reference output 0 of this transaction as an input of his own transaction.

Input:

Previous tx: f5d8ee39a430901c91a5917b9f2dc19d6d1a0e9cea205b009ca73dd04470b9a6
Index: 0
scriptSig: 304502206e21798a42fae0e854281abd38bacd1aeed3ee3738d9e1446618c4571d10

90db022100e2ac980643b0b82c0e88ffdfec6b64e3e6ba35e7ba5fdd7d5d6cc8d25c6b241501

Output:

Value: 5000000000

scriptPubKey: OP_DUP OP_HASH160 404371705fa9bd789a2fcd52d2c580b65d35549d

OP_EQUALVERIFY OP_CHECKSIG

Bitcoin uses a scripting system to verify a transaction. There are two script components that can be seen in the above transaction: scriptPubKey and scriptSig. So, the scriptSig refers to the sender’s signature and the public key. The scriptPubKey is the script that will be evaluated using bitcoin protocol and if the execution of the script returns true then the transaction is valid.

scriptSig: <sig> <pubKey>
scriptPubKey: OP_DUP OP_HASH160 <pubKeyHash> OP_EQUALVERIFY OP_CHECKSIG

Let us see how this script is executed on the stack:

Step 1: Combine scriptSig and scriptPubKey in that order
Step 2: Push <sig> and <pubKey> to stack
Step 3: Execute the operation OP_DUP which will duplicate top item, which is <pubKey>
Step 4: Execute the operation OP_HASH160 which will create hash of the <pubKey> and this hash will be pushed to the stack.
Step 5: Execute the operation OP_EQUALVERIFY to ensure the hash generated matches with the <pubKeyHash>
Step 6: Execute the operation OP_CHECKSIG for the two hashes on the stack.

In summary, a Bitcoin transaction involves one or more inputs and one or more outputs, has no concept of From addresses in its protocol, uses a concept of unspent transaction output, and verifies the transaction using a scripting architecture.

……………………………………………………………………………………………………

The views and opinions expressed in this article are those of the author. To know more about our company, please click on Mindfire Solutions. 

Spread the love
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •