Hashes are a cryptographic tool used in blockchain technology. They originated with the work of two IBM scientists attempting to deter "spam mail" but came into prominence through the work of Adam Back. They are one way functions. "Hashing" takes any input value, for example a single plaintext message like "I see the sun" or an entire novel like "Les Miserables" and generates a random but deterministic string of letters and numbers. A commonly used Hash function is SHA-256. This function always produces a distinct value of 256 characters for any input. Taking the example "I see the sun", SHA-256 produces a unique 256 character set. Likewise, if the input is the entire text of "Les Miserables", SHA-256 produces a unique 256 character set.
The virtue of "hashing" is that it is easy to enter any input to generate a unique output - a character set, but virtually impossible to go backwards, that is, to take the randomly generated output and reproduce the input. This is why "hashing" is referred to as a one way function. Blockchain technology relies upon hashing to secure data in the block, but more importantly, it is the hash of the entire block that links it to its successor block thereby constituting the "chain". In short, the hash of a block "points" to the next block as in a linked list.Miners
Miners are persons/entities running sufficiently powerful computers to solve mathematical puzzles generated by Bitcoin protocols to create a new block. Miners are rewarded with Tx fees and BTC. As of January 2022, the reward for creating a new block is 6.25 BTC. A new block is created approximately every ten minutes. A typical block contains about 4,000 Tx. Nakamoto set the total amount of BTC at 21 million. When that maximum is reached, miners then would be rewarded with Tx fees. It is expected that the entire supply of BTC will be mined by 2140. The concept of the maximum cap was to create scarcity to incentivise increasing value. However, it is unlikely that Nakamoto intended users to treat BTC like an investment vehicle seeking capital gains. Nakamoto and his precursors wanted to create and private system of money to pay for goods and services.
[to be continued] Decentralised FinancePreliminary Note: The following narrative is based on Fabian Schar's article entitled "Decentralised Finance: On-Blockchain - and Smart Contract-Based Financial Markets, 2nd Q 2021, Federal Reserve Bank of St. Louis Review, and the Pitchbook DeFi Primer 22 August 2021.Definition
Decentralised finance, to be understood, must be contrasted with "centralised finance". The latter term refers to Central Bank production of money and exercise of control over the money supply to control its dual mandates: price stability and economic growth, including near full employment. Borrowing and lending are conducted through commercial banks. Insurance companies, pension funds, investment funds and any other firm aggregating funds for investment fit the definition of centralised finance. In other words, centralised finance refers both to central banks issuing fiat money to the myriad of financial firms aggregating funds to channel to various entities and investments. Since derivatives are the largest class of financial instruments worldwide, we must assume that a substantial percentage of the "pooled money" transiting through financial intermediaries end up in derivatives. Nevertheless, it is not that simple. The flow fo funds is, to a certain extent, circular as the sources of funds must be paid the price of the funds lent.
Decentralised finance [DeFi] stands in contrast with this system.This definition of "DeFi" is lifted entirely from the Pitch Primer, as it requires no improvement.
"Decentralised finance (DeFi) refers to a new system of financial services that runs on public, open-sourced, and permissionless blockchains. ... DeFi services are built on blockchain platforms such as Ethereum and are accessed via decentralised applications (dApps) that connect the user to myriad financial services including paying, lending, borrowing, trading, and insuring. Unlike the digital services offered by traditional banks, dApps are built using public, open-source code, with development often occurring in the open and transactions ledgers viewable and verifiable by anyone". [Pitchbook 2021].
As Schar states slightly differently: “Decentralised Finance [DeFi] uses distributed ledger technology to construct a financial infrastructure that is open, permission-less, and independent of trusted third-parties.” DeFi uses smart contracts and tokenised assets to permit users to conduct a myriad of financial transactions. [Smart contracts are explained in Chapter 8 of this website]. While DeFi is a niche market, the value of DeFi related smart contracts exceeded 10 billion USD in 2021. The value refers to assets locked in smart contracts. DeFi generally is built upon the Ethereum Virtual Machine.
Unlike FinTech that is built on traditional banking services, DeFi is genuinely revolutionary adhering to the original intent of Satoshi Nakamoto to create a financial system absent existing banks and governments. It is the most innovative "new era" development in financial services. Note that DefI is not for the novice as it requires knowledge of sophisticated programme languages, an arcane vocabulary, and not so friendly user interfaces.The Architecture of DeFi
Following Schar's typology, "DeFi uses a multi-layered architecture." [Schar 2021] The DeFi stack comprises five layers:  the settlement layer,  the asset layer,  the protocol layer,  the application layer, and  the aggregation layer. The layers are hierarchical in that the security of an individual layer depends on the security of the layer below.
The Settlement Layer
[SL] is the foundation layer built on the distributed ledger and its native protocol asset, e.g. Bitcoin (BTC) on the Bitcoin blockchain or ETH on the Ethereum blockchain. The SL stores ownership of assets information; the native protocol controls "state changes" initiated by transactions. The SL also clears and settles transactions executed by users. Further, it is the layer where disputes are resolved, and sets the level of security for layers built above.
The Asset Layer
consists of assets issued on top of the settlement layer, including the native protocol asset.
The Protocol Layer
[PL] sets the standards by which "specific use cases", such as decentralised exchanges, debt markets, and derivatives. The protocols are contained in smart contracts that can be accessed by DeFi applications or users.
The Application Layer
[AL] contains the applications users access to conduct transactions between themselves without the intervention of third parties. Users access the smart contracts through web browsers to make protocols easier to use.
The Aggregation Layer
interfaces with the AL by enabling users to access different platforms and use different applications. the AL lets users see data.
[The coin market cap website contains information about cryptocurrency prices, platforms, tokens, and other useful information: see, https://coinmarketcap.com/
"The process of adding new assets to a blockchain is called tokenisation". [Schar 2021] The representation of the asset on the blockchain is called a "token". The vast majority of tokens are issued on the Ethereum network. The technical procedure for adding an asset on Ethereum is to use a smart contract template called the ERC-20 token standard. As of October 2021, more than 200,000 ERC-20 tokens existed on Ethereum's main network.
Tokens can represent anything on Ethereum. For example, tokens can represent "reputation points", financial assets, fiat currencies, and gold. [see Ethereum at https://ethereum.org/en/developers
/docs/standards/tokens/erc-20/]. Developers build applications for tokens based on the common standard - ERC-20.
The value of tokens depends on the issuer's ability to deliver its promises. Hence, tokens often are collateralised to instil user confidence and mitigate counter-party risk. There are two types of collateral: off-chain collateral and on-chain collateral. Alternatively, tokens that have no collateral pose the greatest risk as trust is purely reposed in the issuer.
Off-chain collateral conventionally is held in an escrow account thereby involving a third-party institution, like a bank, and conventionally consists of fiat currency thereby involving central party issued money. On-chain collateral means collateral, that is, assets, locked on the blockchain usually in a smart contract. On-chain collateral is transparent and can be executed automatically. According to Schar, the disadvantage is that the collateral is held in a native asset, like ETH or Bitcoin that fluctuates in price and makes a poor candidate to transfer assets.
Two motivations dominate the use of "tokens" First, tokens enable transactions in assets to take place on a distributed ledger. Second, financial transactions require low volatility in value. Hence, many tokens are "stablecoins", coins whose value is tethered to an off-chain asset.Stablecoins
A "stablecoin" is a token whose value is kept steady with some given reference point. In many instances, that reference point is the United States dollar, but logically it may refer to any asset like the EURO or Index. Three types or classes of stablecoins have emerged to implement this concept:  IOU,  Seignorage Shares, and  Collateralised.
The IOU organisation simply swaps 1 USD for 1 token. The asset is held with a centralised custodian and may be redeemed by swapping back the token for USD. Trust is placed in the custodian.
Second, Seignorage Shares are algorithm-based stablecoins where users transfer their assets to the organisation running the algorithm. If the price of the token is too high relative to its pegged value, the system automatically increases the supply of the token thereby reducing demand. By contrast, if the price of the token is too low relative to the peg, the system automatically reduces supply and increase demand. Trust is placed in the algorithm.
Third, collateralised organisations ask users to place trust in the value created by the blockchain. The economy of the blockchain determines the success of the token. Collateralised tokens implies using a protocol that generates tokens back by pledged collateral. Trust is place in the blockchain.The DAI Stablecoin
In 2014, a Danish entrepreneur founded MakerDOA, a decentralised autonomous organisation with the objective of creating a global currency. DAI, a stablecoin, is a product of MakerDAO, an open source project on the Ethereum blockchain. MakerDAO is managed by persons around the world that hold MKR, the governance token of MakerDAO. According to the Maker White Paper, the governance system is "scientific" involving Executive Voting and Governance Polling" by MKR holders for the purpose of managing financial risk and ensuring stability, transparency, and efficiency". [White Paper]
The Dai stablecoin is a "decentralised, unbiased, collateral-backed cryptocurrency soft-pegged to the US Dollar". [WP]. It also is an ECR-20 token and therefore can function as a stable Ethereum token. Unlike Bitcoin and ETH, DAI is a "stablecoin" whose value is "softly" tied to a fiat currency, that is, the USD. The objective of the "peg" is to inspire the use of DAI as a form of money, not a capital asset. DAI uses ETH or other approved cryptocurrency as its on-chain collateral to create a decentralised and trustless DAI token. A native token such as ETH is not pegged to the US dollar nor are the large majority of other cryptocurrencies. Therefore, DAI tokens must be over-collateralised to make certain that its soft peg, that is, 1 DAI = 1 USD consistently may be maintained.
DAI is held in cryptocurrency wallets or within platforms. MakerDAO uses "collateralised debt positions [CDP] to generate DAI stablecoins to the Ethereum blockchain economy. DAI is generated to the Ethereum blockchain economy by a lending mechanism under which a "user borrows DAI and increases supply through on-chain transactions" in a smart contract. DAI is debt.
The "Collateralised Debt Position" [CDP] smart contract allows users to pledge collateral for a loan, that is, to borrow a specific quantity of DAI, a programmable money, from the DAI credit facility. The CDP mitigates credit risk by having recourse to the posted collateral. Initially, Maker accepted only ETH as collateral but now accepts as collateral any cryptocurrency trading on the Ethereum blockchain. The pledged assets must be unencumbered and accessible to the lender. In a CDP, users hold collateral in Maker Vaults. When DAI is generated, it may be used as any other cryptocurrency: sent to others, used as payment for goods and services, or held as savings through the DAI Savings Rate [DSR].
Maker uses the collectively pooled collateral to make investments. MakerDAO founder, Rune Christensen, has stated that the funds are invested in sustainable real world assets "through senior credit positions in projects that build “solar farms, wind turbines, batteries, recharging stations and other cost-efficient renewable energy solutions, as well as their supply chains, sustainable resource extraction and recycling.” Properties of DAI Similar to Money
Money has four functions:
1. A store of value
2. A medium of exchange
3. A unit of account
4. A standard of deferred payment
The DAI stablecoin satisfies the four criteria of money. First, DAI is an asset that keeps its value over time, that is, does not depreciate, because of its soft peg to the US dollar, its given reference. Second, DAI is a medium of exchange because the currency can facilitate the sale and purchase of goods and services, subject to the qualification of counter-party acceptance. Third, DAI is a unit of account within the Maker Protocol. Accounting and pricing for the Maker Protocol and dapps is in DAI, not a fiat currency, like the USD. Fourth, DAI is used to settle debts, specifically redemption of collateral and payment of stability fees and closure of user vaults.
The Mechanics of DAIAssume you want to acquire DAI, what is the procedure. First, you need a ‘wallet’ to hold cryptocurrency that is recognised by DAI as collateral. You may obtain a wallet by downloading an app from Coinbase or Metamask. There are three main wallet types: hosted, non-custodial, and hardware. In a hosted wallet, your assets are held by a third-party, like Coinbase. The advantage is: no need to remember your private key. In a non-custodial wallet, users have control over their assets, but must remember the private key. A hardware wallet is a physical device that holds your keys and assets off-line.
Second, fund the wallet from a bank account or bank card. Third, buy a cryptocurrency recognised as collateral for the purpose of entering into a loan agreement to borrow DAI. Fourth, create a Maker Vault by using interfaces such as Oasis Borrow. Fifth, purchase DAI by using a recognised cryptocurrency collateral and creating a ‘collateralised debt position’ with Maker. For example, assume ETH trades at 1 ETH to $150, you can buy/borrow 100 DAI. Note, however, that this is the minimum required collateral percentage. Since the price of ETH is volatile, it is recommended to give yourself a cushion, assume 300%. Therefore, set the collateral at 300 ETH for 100 DAI.
DAI is a loan. The annual interest rate paid is called the Stability Fee, subject to change based on market conditions, and MKR votes. In addition, if the value of the Vault collateral falls below the 150% ratio "automated Maker Protocol" auctions take place. In effect, the collateral is sold "using an internal market-based mechanism". The DAI received from the auction is used to cover the Vault's outstanding obligations plus the liquidation fee set by MKR voters.
If, during the auction, enough DAI is bid to cover the vault's obligations, including payment of the liquidation fee (a set percentage), the auction converts to a Reverse Collateral Auction to sell as little collateral as possible, any leftover returned to the vault. If the auction fails to raise DAI sufficient to cover the debt, then the deficit is converted to Protocol debt. Protocol debt is covered in the Maker Buffer, where DAI generated from stability fees is kept. The "buffer" has a maximum limit, at which point DAI is sold for MKR. The MKR purchased, then is destroyed thereby reducing the total MKR supply.
The DAI Savings Rate functions as a monetary tool to maintain the peg to the US dollar. If the value of DAI rises above the peg, then MKR holders lower the DSR to encourage DAI users to withdraw DAI from their savings account. The effect is the supply of DAI in circulation increases thereby reducing its value. To the contrary, if the value of DAI falls beneath the peg, then MKR holders raise the DSR to encourage DAI users to deposit more DAI in their savings account thereby reducing the supply of DAI and increasing its value. Maker holders act as a central bank by raising or lowering interest rates to maintain the stability of DAI.
Oracles are used to feed off-chain data to the smart contracts on the Ethereum chain. That data is the market value of approved collateral with respect to the US dollar. This information is used to adjust the percentage of collateral required to meet the minimum over-collateralization of 150%.The Maker Protocol
"Current elements of the Maker Protocol are the DAI stablecoin, Maker Collateral Vaults, Oracles, and Voting". [WP] The Maker DOA governs the Maker Protocol by setting parameters through the voting power of MKR holders. The Maker Protocol was the first decentralised finance (DeFi) application to earn substantial adoption and is one of the "largest decentralised applications (dapps) on the Ethereum blockchain. Oracles transpose off-chain information, such as the exchange rate of ETH/USD to on-chain smart contracts.DeFi Exchange Markets
Before describing DeFi exchange markets, it is valuable to describe conventional financial instrument markets. Markets are places where financial instruments are exchanged/traded between users of the markets. Conventional markets often set listing requirements that financial instruments meet to qualify for trading. Conventional markets also bring together diverse participants performing various functions.Conventional Exchanges
First, conventional exchanges are companies with owners running the exchanges for profit. Second, professionals act as intermediaries to match participants, in the simplest scenario buyers and sellers of financial assets. Third, following from the second point, access to the exchange is not open to individuals directly, but requires the services of institutional entities. Fourth, the exchange owns or contracts with additional institutions to clear and settle trades and to keep a record of ownership; e.g. depository institutions.
The execution of a trade binds the buyer and seller to the transaction based on their agreement and results in a legal obligation. The buyer agrees to purchase a financial instrument and the seller agrees to sell that instrument.
Clearing refers to the procedure of updating the "statement accounts" of the buyer and seller and recording the new owner of the financial instrument. Clearing may be done on one of two ways: bi-lateral and multi-lateral or central clearing. Bi-lateral clearing involves only parties to the transaction. Central or multi-lateral clearing involves a third-party, a clearinghouse. Clearinghouses are owned by members, generally broker-dealers. Non-members access the clearinghouse by having accounts with members.
In central clearing, members of the clearing house aggregate "the trades from each of its members and nets out the transactions for the trading day". This reduces the number of payments and securities that must be transferred among members. Take the simplest example of payment netting. Suppose A owes B 100 EUR and B owes A 110 EUR. B pays A only the difference between their obligations, that is, B pays A 10 EUR. The same rationale applies to financial instruments.
Settlement refers to the transfer of the financial instrument and money. Although intangible objects are physical, financial instruments are dematerialised, that is, they are digital assets. Transfers take place by adjusting ledgers. Payment is made by a series of debits and credits to bank accounts. Settlement for trades in securities takes T+2, that is, the date the trade was executed plus two additional days. BY contrast, government bonds and options are settled T+1.
Concepts encountered in this process are: immobilisation and dematerialisation [already noted]. Immobilisation means that the underlying certificate representing either equity or debt is held by a depository institution. The "certificate" does not move. Rather who owns the particular financial instruments arsing from this certificate is done by book-keeping accounting entries. "Dematerialisation" simply means no paper.
Since exchanges are human constructs, the question legitimately may be asked is this matrix of various institutions and individuals necessary to effect trading of financial instruments. DeFi says "no".DeFi Exchanges
Numerous and different crypto assets are listed on exchanges. Decentralised exchange protocols are responsible for the distinction between centralised exchanges and DeFi exchanges. DeFi users retain control of their assets held in a wallet, unlike centralised exchanges that require owners of assets to forfeit control to the exchange. Second, trade execution happens automatically through a smart contract. Both sides of the trade are performed in an indivisible transaction. Third, the smart contract obviates the roles of third-party intermediaries to clear and settle the trade. Fourth, the trend toward open exchange protocols allows for cooperation among exchanges permitting shared liquidity pools and liquidation of tokens when needed. [Schar]Note
: In many circumstances, use of a centralised cryptocurrency exchange to trade tokens may be unavoidable, particularly if the tokens exist on different and independent distributed ledgers. The problem is one of transferring tokens from one distributed ledger to another to make trades possible. The existence of independent and decentralised ledger systems obviates financial intermediaries - the essence of decentralised platforms, but involves technical challenges yet to be solved with easy to use interfaces thereby leading to the rise of centralised "crypto-asset" exchanges, the unexpected intermediary institution in the non-intermediary financial ecosystem. Decentralised Lending Platforms
Individuals may borrow and lend 'cryptoassets' on decentralised ledgers in three principal ways. First, as noted earlier, there are collateralised debt positions, such as MakerDAO, whereby the borrower locks approved collateral in a smart contract in exchange for a designated supply of DAI based on the collateral ratio set by the Maker community.
Second, there are collateralised debt markets to borrow and lend 'cryptoassets'. These markets require a match between lender and borrower, that is, the loan is made in the same cryptoasset, and also require the borrower to post adequate collateral to repay the loan plus interest. These markets fall into two categories: P2P and "pooled".
In P2P lending, individuals per se make a match and agree on all issues, such as time, interest rate, and collateral, themselves. In "pooled" lending, the "pool" uses variable interest rates. These rates vary depending upon supply and demand. When demand for loans is high, interest rates rise becoming more expensive; the reverse is true when demand for loans fall, then interest rates fall and become less expensive.