Uncategorized

Decentralized Liquidity Pools and Automated Market Making with Uniswap

How Uniswap Work

uniswap.org is a decentralized constant product liquidity protocol, which is secure and creates liquidlity pools of ERC-20 token. given the recencey of uniswap, the protocol almost has 2 billion dollars worth of ERC-20 tokens locked up and faciliates close to 400 million dollars of decentralized trade every day (sometimes even more).

How does it work? – The basics.

Automated market making is defined as a smart contract mechanism by which liquidity pools such as the one we will describe below, automatically execute trades on the ethereum blockchain. What this means is that both the ETH and DAI would have an equal $ worth of tokens in the system. As a example, consider 1 ETH = 346$. Consider an ERC token DAI which trades at 1 DAI = 1$.  In a liquidlity pool, one would ideally invest both tokens in the ratio of 1:1 to keep the product constant. This means that for every 500$ of ETH invested, the total DAI value should be 500$ worth. Now consider a system where a user would invest 1 ETH and 346 DAI since 1 ETH = 346 DAI.

A constant product curve would look like the following where we would have 1000 ETH and 34600000 DAI.

Curve x * y = K

Whom does UNISWAP.org facilitate help to:

  1. Arbitraguers: Due to the decentralized nature of these exchanges, a liquidity pool facilitates mass arbitrage opportunities. For example, on coinbase or on hitbtc if 1 ETH is trading for 380 DAI. An arbitrageur can quickly come to uniswap and purchase say 10 ETH paying 3460 DAI from his wallet.  This would incur a 0.3% fee to uniswap, which is distributed to all liquidity providers of the pool, and is accumulated over a period of time. Then, the arbitrageur can simultaneously trade these 10 ETH for 380 DAI on hitBTC.org for a total of $3800 making a cool 340$ profit – 0.3% commission of about 0.3X3460 = 10.38$.  This kind of simultaneous no risk swapping of ETH to DAI on public markets is an extremely robust mechanism.
  2. ERC-20 token purchases and ERC-20 listings: One the largest challenges with centralized exchanges is their lack of visibility into new token listings, ICOs or IEOs. It becomes almost impossible to purchase  these types of tokens especially when legal controls are in place.  uniswap pretty much allows anyone in the world to list their tokens and to set their own private pools using their User Interface.
  3. HODLErs : This community is responsible for adding and creating the Liquidity pools on the uniswap network. What is interesting here is that HODLers do not really need to identify themselves on the network or to create an account or to register with a bank or anyone here. They can directly login to the uniswap by authenticating or connecting to one of their wallets e.g., metamask or coinbase, and can participate in the uniswap.org economy.
  4. Pool creators: Individuals can also create pools for all kinds of tokens on uniswap. for example, WBTC is the wrapped version of BITCOIN. One can actually purchase or list any cryptocurrencies that they create onto these pools themselves.
  5. Ordinary traders: Globally the trader pool of users cannot access the cryptocurrency token if it were not for centralized exchanges or other secondary peer to peer markets. Uniswap facilitates ordinary traders access to cryptotokens.

In a future article I shall write about minting, and yeild farming in the context of uniswap.  I shall also write about some of the risks of investing in Liquidity providers.

references:

  1. uniswap whitepaper – https://uniswap.org/whitepaper.pdf

Unstoppable Blockchain DApps – via smart contracts on Ethereum – The true power of the blockchain

Unstoppable Blockchain DApps

This past week was a revelation after working for 3.5 years in the blockchain space, after listening to Dr. Stephan Karpischek’s Keynote speech on “Decentralizing Insurance” at the PreICIS SIGBPS 2020 workshop.

Stephan’s definition of a blockchain based software system appealed to me as the right way to create software systems and development ecosystems.

Software LIFE Cycle and Stoppable Software Systems

A software system has a life cycle which starts with a team building it. Often the team that builds this system is centralized heavily on three types of resources: i.e., (1) human capital provided by the management of the firm that owns the software (often licenses it and the source code), (2) the hardware needed to run the software( often single server systems installed and run on a set of nodes in single data-centers) and (3) software tools available to the developers and adopters (by means of developers invested in the system).

Each of these three components necessary to create an maintain software applications have multiple points of failure, both technical, economical and human resource related leading to a process known as “End of Life” for the corresponding software.   For example, management of firms that create these software projects can often shut down these  projects and relegate them to obscurity. The hardware and software on these systems can become outdated often and frequently.

UNSTOPPABILITY – A PROPERTY OF BLOCKCHAIN DAPPS

When all the 3 aspects of a software system that are (often) centralized disappear, then we have a true software system that is unstoppable. Public decentralized blockchains widely adopted makes this happen. For example, on the Ethereum Blockchain which is a global network with nodes around the world and hosted by different individuals, decentralized applications have the requisite hardware and software to live on for ever. Similarly, when teams developing the software is distributed globally and there is no single organization determining what can/what can’t be done, and governance of software is accomplished through governance models that are public, transparent and open to all, such a system becomes unstoppable.

Such unstoppable systems cannot be regulated, pulled down or forced to abort unless the entire network of computing nodes are stopped. For example, when one country regulates access to these network of nodes, other countries which provide free access to computing resources will provide environments for this innovation to thrive. Similarly, when investors decide to impose regulations such as geographic blocking on the corresponding software, the entire source code of the software can suddenly be forked and start to execute on nodes without the geo-blocking feature.

Ethereum nodes distributed globally

Source – https://etherscan.io/nodetracker

This in my opinion is the most important and critical aspect of Decentralized applications that Software development firms have to pay attention to.

Such a one Blockchain DApps is  –Uniswap

Maker DAO – a Decentralized way of solving the volatility problem in cryptoeconomics

Maker Log with keyboard image

Maker DAO bring stability for the blockchain and solving the volatility problem in cryptoeconomics. 

Hard problems in cryptocurrency

One of the many hard problems   in cryptocurrency ecosystems is the price instability of  most direct to trade crypto-assets.  The lifecycles of these cryptoassets begin with the mining function, and the network effects that accompany the blockchain.

These network effects often accentuate the ability of different stakeholders such as market makers/takers/traders/miners/app-developers, etc. to strategize in order to maximize their own rent making ability in these markets. Due to multiple sides of the markets continuously contributing in the face of entries and exits, the underlying asset faces significant volatility. 

In such circumstances, despite the promise of decentralized-fungible equivalent cryptocurrency that can be transferred without an intermediary, these cryptocurrencies often become risky for trade which expects some amount of stability vis-a-vis the current stable fiat (USD or Euro).

A solution in the form of stablecoins has often been sought wherein each cryptocurrency has collaterlized to some asset (either money in the bank or something else). Nevertheless, each such stablecoin is controlled by a trust or a consortium which is responsible for auditing the assets and ensuring that the right supply-demand-balances exist in these markets.

DAI and the Collateralized Debt Position

DAI is a type of collateralized cryptocurrency that is pegged to 1 USD and  operates purely on the Ethereum smart contract platform. The decentralized governance makes this a unique stable coin which any user can  exchange to fiat currency. 

How is DAI generated?

The way DAI is generated is through CDPs where users deposit a certain quantity of Ethereum (usually more than the number of DAI needed), into a smart contract. The ratio of the value of the collateral to the DAI generated is known as the liquidity ratio, and this liquidity ratio is pre-set by the Maker Platform voters through a governance mechanism considering several factors.

Once the  collateral (i.e., a certain quantity of ethereum that is accepted) is  locked into the smart contract DAI is generated. The DAI is generated and the user is now free to use this DAI to do anything he wants to. Once the DAI is paid back to the smart contract, with the interest (labeled as the stability fee) into the Maker account, the collateral is released to the user.

Governance

The governance of the DAI token exchange values and several intervening conditions such as a flash crash in collateral prices, or an emergency price variation,etc.  are handled through a transparent and collateral system overall.

Why go through the trouble of creating  DAI?

Firstly, DAI is accepted on many crypto-fiat exchanges as a mechanism to trade on various markets due to its price stability of 1USD. This is almost equivalent to borrowing money against cryptocurrencies at the rate of the stability fee (i.e., approximately 5% per annum with the risk of liquidation).

Secondly, DAI due to its decentralized nature enables users to participate on several decentralized  finance platforms such as dydx or celsius.network. These platforms offer an interest rate on DAI between 5.5 % and 9%. This gives people the ability to use their cryptocurrencies as a means of earning interest directly. 

How to create and use DAI

Step 1.

You own 10 Ethereum. You create a smart contract on the Maker Platform and send your 10 ETH to it. This is the website to make this https://cdp.makerdao.com/

You now have a CDP created.

Step 2.

You send another small transaction to the smart contract, which then locks up the CDP, making the 10 ETH temporarily inaccessible, and generates Dai. The CDP must be 150% overcollateralized, so depending on the price of Ether, the amount of Dai received will change. If ETH = $300, then 10 ETH = $3000. Then, the CDP would generate 2,000 Dai.

Step 3.

You could then do whatever you wanted with the Dai. Many people use it to trade other crypto, while still being able to hold on their ETH. So, say you then use Dai to purchase another cryptocurrency, such as Bitcoin. After a period of time, which could be days or even years, you sell you your Bitcoin for a profit back into Dai. You now have 3000 Dai after BTC goes up 50%.

Step 4.

You then now send the original 2000 Dai plus the 5% Stability fee (50Dai) and unlock the CDP, receiving back your ETH. Now, you have $950 in profit and the original 10 ETH.

Risks

The whitepaper lists several risks.

  1. Mkr governance can choose to liquidate the collateral if the risk is too high at any point in time, holding 13% as a penalty.

Mechanisms of Design for Casper

Casper

Casper is the first in the many steps for the roll-out of a new eco-friendly block mining approach, which promises to incentivize mining for Ethereum. On one hand, his approach is very  powerful  because of the net positive utility to all participants in the ecosystem namely

  1. Miners with little or no effort earn an interest
  2. The eco-system is well off now that everyone has an incentive to participate in the network
  3. The environment because very little power is consumed, and mining is no more an ASIC play
  4. Application developers because they now have high-speed and fractional transaction support
  5. Token exchanges because they can significantly leverage large deposits of users to participate on networks.
  6. Speculators because new supply of tokens will be limited, and fewer tokens will be available to trade in the market. A complete rollout should immediately, remove 10-12% of the supply in this market.

On the other hand, this approach is susceptible to all the effects in an economic system that provides returns; e.g. no stake based supports to hard forks, collusion, erroneous voting, etc… Click here to link to the economic model and the whitepaper of Casper  Therefore, the designers of Casper have created incentive mechanisms  for the adopters that would significantly penalize bad behavior and incentivize good behavior for the miners. The above talk delves into the details of each of the design mechanisms put in place, to prevent different forms of attacks; Though it looks simple, the consequences could have far-ranging impacts, since these mechanisms directly impact behaviors of all participants in the ecosystem.

Blockchain and Artificial Intelligence

Robote

OpenMined Platform

OpenMined is a platform that integrates the Blockchain and Artificial Intelligence

Their mission is to enable users to earn rewards by improving learning models. These users contribute to improving deep-learning (or other learning) models without access to the actual data (that is hidden through homo-morphic encryption).

Their mission statement is  obvious:

“With OpenMined, AI can be trained on data that it never has access to.”

Podcast

This interesting shift in problem-solving would never have been possible without the blockchain.  A more detailed podcast from Andrew Trask on the Epicenter channel is given below:

Anyone who is interested in the intersection of these two domains should listen to this podcast.

Smart contract and explosive growth

Smart Contract

Smart contracts

Etherscan.io is a site that lists smart contract statistics, code and other interesting features of the ethereum blockchain network. It mostly lists applications running on the main-net.

As of date, there are about 17500 verified smart contract with source code listed. An example is here. As can be seen the source code written in the solidity programming language is complex and has logic that consists of loops and other constructs. Most of these smart contracts are for new token offers (ICOs). A few of them, however, are for unique applications – like that of Cryptokitties or game related apps.

That being said, it is not entirely surprising that the ICO market raised 4.5 Billion dollars last year compared to 1.5 billion dollars in VC, seed and angel financing for blockchain and smart contract related companies during 2017.

Smart Contracts – 1 Million+ and counting

However, not to discount the whole smart contract space, The 17000+ listed smart contracts in Solidity are not the only smart contracts that exist on the Ethereum Blockchain. Several of these smart contracts exist on the ethereum blockchain as byte-codes or executable versions of solidity code, that the authors chose not to release as open source. Since the ethereum blockchain is public and can be downloaded scholars have studied them in detail looking for vulnerabilities.

There are more than 1 million smart contracts that have been studied for vulnerabilities, and this number according to this paper has grown 100 fold in just 2017. The distribution of ether – i.e. 1% of the smart contracts locking in 99% of ether makes this network’s distribution very skewed.

Even if 1 smart contract were to be vulnerable – as is possible this would be a huge risk to the ecosystem. The team at NUS- computer science has created a tool, that can scan the bytecode of smart contracts from the ethereum blockchain, and test it for vulnerabilities. So far they have found about 34000 smart contracts to be vulnerable according to this paper.

Berlin allows Bitcoin as Legal Tender

One of the most important predictions if 2017 was that atleast one major economy in the developed world will give Bitcoin the status of the legal tender. Its close to being a legal tender.

Becoming Legal Tender vs. Legal Bitcoin

The following Wikipedia link shows the status of Bitcoin’s legality across the world. While holding Bitcoin as an asset and exchanging it for fiat currency is legal in many countries, this new  criterion of “legal tender”  removes the intermediary step of conversion to fiat currency for all practical purposes. This means, Bitcoin in itself will be accepted as an alternative to the Euro.

Tax implications

The challenges with this approach might be many folds. For example, how will the government tax the good or service that accepts bitcoin ( will that tax be levied using fiat exchange rate, or, will the taxed be in cryptocurrencies).

CryptoKitties, Price irrationality and scaling

Cryptokitties
Cryptokitties mother and board (owned by an early crypto-kitty enthusiast and collector)

 

CryptoKitties is the first game created on the Blockchain.  The game works when individuals purchase a digital cat by spending ethereum. Individual cat owners can combine one or more cats to produce a third cat that shares physical features of  it’s parent cats. Additionally, there is a marketplace where one cat owner could trade in digital cats. During the initial stages of the game, each digital cat, that released onto the network sold for 1$ worth of ethereum.

Irrationality in Prices of Cats.
Over a short period of time (past 2 weeks) the marketplace exploded with millions of dollars worth kitties trading hands. More recently, cats that were sold during the early stages of the game were being sold at prices more than 100000 USD. The processes of breeding, selling, and buying were all configured as smart contracts wherein trade was autimated when suitable buyers and sellers were matched. An exponential increase in trade of kitties was responsible for almost 15% of the most recent transactions (1500 blocks) on the ethereum network as per the ETH Gas station.

This backlog of transactions resulted in excessive delays on the Ethereum network, even holding up some ICO offers.

Price Irrationality

Off late,  crypto coins (bitcoin, litecoin, ethereum, etc..) and crypto assets (e.g. crypto kitties, ICOs, etc.) have seen extreme price irrationality combined with volatility. This has caused significant press and attention to these assets. In this case of crypto kitties, linking the ownership of a digital asset (crypto kittie) through a smart contract and allowing this contract to reside permanently on a globally distributed Blockchain is the main feature.  The same functionality can be accomplished for other types of assets, e.g. titles of cars, titles of houses, or titles of land, birth certificates of individuals, etc… and is much more potent at changing real-world product markets. With crypto kitties, price irrationalities are potentially related to the scarcity of supply, since, the rate of production of new kitties is significantly lower than the demand from blockchain enthusiasts.

Advantages

That being said, these technology demonstrator distributed apps and their problems have larger engineering and economic impacts.

  1. The large adoptions of the dapps surfaces infrastructure and engineering problems related to scalability that cannot be unearthed through any form of distributed software testing.  In the short term, the core engineering teams will have to increase their scalability efforts so as to support scale. Just a single successful app, can hold up transactions for hours from other applications on the network at the current rate. If the original goal of becoming a world computer that can theoretically execute any type of contract, has to be achieved, this scalability is imperative.
  2. This explosion of dapps, increases monetary gains for all segments of the crypto-ecosystem e.g. dapp writers, traders, and,  other owners of ether. Such a sudden increase in valuations for a tradeable digital asset has physical limitations, and is going to be corrected – hopefully by market conditions and not by regulation.

Important Computation problems in the ethereum blockchain

Important Computation Problems

Having the ability to process a large number of transactions has become the key focus area for many blockchain implementations.

In the following talk Vitalik talks about 4 categories problems that most blockchains have to handle.

  1. Privacy – a public ledger verifies data, but many nodes also access the data. This compromises the privacy of the user.  Many solutions such as a mixer, etc… are being worked on at this point in time.
  2. Consensus safety – the possibility of reducing the power consumed. (according to some estimates proof of work consumes more power than 1/2 the national power consumption of several small countries). Additionally achieving consensus has problems that arise from privacy violation, etc.
  3. Smart Contract bugs – loss of ethereum every year because of bugs in existing code bases of smart contracts. Therefore the proposal of Formal Verification (possibly automated) mechanism could reduce instances of these problems.

Scalability – the most interesting and complex problem to solve

Scalability – support for a large number of transactions. Many off-chain solutions similar to the lightning network, Raiden, plasma are possible- but their throughput is limited because of the main blockchain’s ability to handle attacks, etc… Therefore, the current proposed solution is to use “sharding” as a mechanism to scale the main chain solution. Sharding has its origins in large scale distributed databases and has been used to reduce query times from large databases, by partitioning data based on rules.

The following talk by Vitalik discusses the basics of the sharding approach for the Ethereum Blockchain. This approach suggested, is a hybrid approach wherein some part of the validation is done off-chain. The talk discusses the ability to target VISA scale validation for smart – contracts (not just pay and receive).

Ripple Effect and Price irrationality of Bitcoin

Irrationality in prices

Behavioral economists have tried to correlate and predict price movements in markets with behaviors of traders. Since most such analyzed markets were in stable economies that were efficient and usually upheld the rule of law, irrationality was quickly absorbed by markets. Irrational exuberance, as in the times of the dot-com boom quickly devolved and disappeared. All this was good, as long as the markets were local (geographically) and as long as traders were local firms that were under the purview of the law of the land.

With Bitcoin, things have changed.

With a 24X7 market and a globally available(distributable) asset, these behavioral inconsistencies can potentially last for a long long time. Off late, this irrationality and exuberance have meant arbitrage opportunities for other asset classes in nations where political and economic instability have taken place.

Such instability has had a tremendous spillover effect on the price of Bitcoin. Over the past 3 days, since the regime was toppled in Zimbabwe, citizens have – attempted to move their assets into Bitcoin. Exchanges for the local currency saw brisk trades giving it a rise of over 200%.

Ripple Effect

However, these prices are mostly local and do not spiral out to global markets, on account of low demand for such expensive assets. For example, the markets in Zimbabwe have had less than monthly transaction volume of USD 1 Million. Compare this with an average daily transaction volume of greater than 1.4 Billion USD for Bitcoin globally.

This clearly shows that though local markets can, at times, in the face of sudden economic uncertainty exhibit irrationality in prices; global markets will not be affected unless volumes are large.

You can consider this as similar to a ripple effect on a large pond of water. Unless and until the stone thrown into the pond is large enough the ripples will not reach the edge of the pond. In Physics and Economics, this is modeled as a Ripple Effect.

Question: How much of a volume is needed to move the price up irrationally for Bitcoin in a global market?