Decentralized Finance, also known as DeFi, is a quickly evolving and increasingly integral part of the blockchain space, especially on the Ethereum protocol. If proponents are correct, the technology could lead to greater financial autonomy among users while undercutting financial rent-seekers and reducing costs. During a time of unprecedented monetary policy and limitless quantitative easing, such an accomplishment has implications far beyond Ethereum and the DeFi space.
Nevertheless, as the financial system is re-engineered on-chain, several innovations are still required to establish ease and security of use as well as financial stability. The Kyber Liquidity Protocol is one such link in the chain, aiming to create a more fluid and user-friendly financial experience. Focused on creating a decentralized source of liquidity, this liquidity pool, market maker-like blockchain project is gaining traction as an increasingly integral part of the DeFi system.
Correlating The Kyber Network to Equities: Buying and Selling
There are a few terms to be familiar with as we work to understand the Kyber Network and the world of on-chain liquidity pools and market making. They are:
A resource with economic value
The degree to which an asset can be converted without effecting price
Price movement and the range in which an asset’s price swings. Also can be thought of as risk
Market participants who buy and sell assets and provide buy-side and sell-side quotes
Difference between the expected trade price and the realized trade price
The overall process of setting the true price of an asset
The price a seller is willing to accept for an asset
The price a buyer is willing to pay for an asset
An order to buy or sell an asset at a predetermined value or better
A price-arranged list of buy and sell orders for an asset
Don’t worry if these terms aren’t entirely clear yet. We’ll be explaining them further as we dive into the Kyber Network and its application to the cryptocurrency space.
As opposed to DeFi, which deals with cryptoassets, in the conventional financial system, investors often wish to buy and trade stocks. Part of the appeal of owning stocks is their ease of use. Unlike illiquid assets, for example, real estate, stocks can be bought and sold quickly and with relatively certain and real-time pricing. Investors can find a seller at a publicly known price quickly and with little difficulty.
A house, on the other hand, may take months to sell and can be difficult to price accurately. Before going to market, realtors may claim to value my Malibu mansion at $100 million. Yet, when I attempt to sell the asset, I may find that the highest any buyer is willing to pay is $80 million, significantly lower than the expected price. If I have debt to pay and am hit with this unexpected value loss, that could be a real problem.
Let’s say Alice has money to invest, but may need to have access to her money quickly. She decides to buy a stock. Perhaps she buys one share of ABC stock and pays 100 dollars. Later, ABC stock increases in price to $105. About that time, her mortgage comes due, and she decides to sell.
She hopes to make a profit, or at least break even, but at the time of selling can only find one buyer, Bob. Bob is very cheap and only offers her $95. Common sense dictates that she could eventually find Steve, a buyer at $105 if she looks long enough. Unfortunately, Alice is in a rush. She sells the stock to Bob, pockets the loss, and decides never to invest again.
The Role Of A Market Maker
In an alternate world, Alice seeks out a broker, an online trading platform that acts as/is associated with a market maker. Market makers hold reserves of assets, including ABC stock. At any given moment, XYZ market maker is prepared to sell to buyers and buy from sellers. When ABC stock rises to a market price of $105, XYZ market maker is buying the stock from investors at $103 (XYZ’s bid price) and selling at $107 (XYZ’s ask price). Alice is happy to sell at $103 and pocket a small profit—she’s in a rush, after all. Steve thinks the price of ABC will continue to rise in the near future and is willing to pay the somewhat high price of $107 to XYZ to make profits later on.
The difference in the bid ($103) and ask ($107) prices offered by the market maker is the spread. Market makers pocket this price difference as profit. While it may seem disingenuous to offer two prices, market makers do assume financial risk. For example, if they buy ABC stock from Alice, and suddenly horrible news about the stock hits the wire, the price could easily plummet to $95 by the time Steve shows up. At $95, Steve will lose interest as the stock is now decreasing in value, and only Bob the cheap-skate will buy. The market maker will assume a loss in this situation, so there is a need to offset this risk by charging a premium when trading goes well.
In this way, market makers help buyers and sellers transact. They are both willing to buy and sell, thereby adding liquidity, buy-side and sell-side demand, to the market while assuming marginal risk. Liquidity is obviously very useful, allowing Alice to get out of the market quickly to pay her mortgage while allowing Steve to act promptly to buy before the price rises further. Both actors receive a reasonable price, while their actions have little effect on the overall price of the stock.
Competition, Order Books, and Volatility
However, XYZ market maker has a spread of $4. They have overcharged Steve and ripped off Alice. Another market maker, ZYX, feels it can be more competitive by offering a tighter spread (i.e., a smaller difference between the bid and ask prices). ZYX offers a bid price of $104 and an ask price of $106, which in turn, more correctly reflects the true market price of $105. The more market makers competing, the tighter the spread becomes.
As time progresses, a stock’s price fluctuates. It may rise or fall in response to news, market conditions, investor demand, geopolitics, and numerous other market forces. This change in price is known as a stock’s volatility. During normal market conditions, the price of most assets does not fluctuate wildly, and market volatility is usually low. Nevertheless, asset prices tend to drift in one direction or another.
Traders may wish to take advantage of stock volatility by taking profits (selling at an overbought price) or buying the dip (buying at an oversold price). In so doing, they may set limit orders. Limit orders are instructions to execute a buy or sell order at a specific price or better. Bob, for example, might set a limit order with a market maker to buy ABC stock if it ever falls in price to $95. If the price of ABC is still at $100, Alice may set a sell limit order at $105 to take profits. Numerous traders set orders at different prices around the true market value of the stock, and create an order book. An order book is pictured below:
So far, we have dealt with purchases of a single share of stock, but this is rare. Multiples of 100 shares are much more common. If Alice is well-to-do and heavily optimistic about the future of ABC stock, she may place an order for 1000 shares of ABC stock at $100. Image an order book with shares available at a mid-market price of $100 (100 shares available) as well as $101 (300 shares), $102 (300 shares), and $103 (500 shares). In this scenario, there are only 100 shares available at her bid price of $100. To fill her order, she will have to buy 100 shares at $100, all 300 shares at $101, all 300 shares at $102, and the remaining 300 shares of her order at $103. By executing this order, Alice is moving the price and driving ABC stock upwards. The average price she pays is much closer to $102, more expensive than her expected price of $100. This unfavorable change in price is known as slippage.
Slippage can also occur during periods of extreme price volatility. If there is suddenly an excessive amount of orders for a stock, say following a positive earnings report, the price will move quickly. If this price movement occurs during the period between when Alice places her order and when her order is filled, the price moves against her, and again she experiences negative slippage. In general, illiquid assets are more prone to intense price fluctuations and thereby more prone to slippage. Liquidity, on the other hand, helps to limit slippage.
Slippage can be particularly detrimental without the presence of market makers. As information about the price change spreads throughout the market, the ask price will increase. The bid price will be slower to adjust, creating a wider spread. This spread will move the realized price of the stock upwards, sometimes violently.
Market makers help prevent this choppy price action by providing liquidity and facilitating trades at price levels in between the current price and soon-to-be-realized increased price. Furthermore, more competition among market makers as well as deeper order books helps the spread more closely track the true market value of a stock as its price fluctuates. In this way, market makers help markets achieve efficient price discovery as they help transactions between buyers and sellers more closely track the true market value of an asset.
Kyber Network: An On-chain Liquidity Protocol
The Kyber on-chain liquidity protocol, AKA Kyber Network, is an Ethereum-based liquidity aggregator that collects reserves of cryptocurrencies and cryptoassets’ tokens. Similar to a market maker, it allows users to swap tokens securely and easily and at the best available rate, while limiting the negative effects of illiquid markets. Kyber is:
Kyber’s smart-contract protocol and rates are publicly verifiable
Permissioned and permissionless
Depending on the use case, anonymous transactions are possible
Users are not required to store funds with Kyber and not exposed to hacks
Swaps on Kyber draw from large pools of tokens known as liquidity pools
Token swaps occur at the best available rate
Kyber offers a user interface that can be integrated into trading platforms and other applications. Like a market maker, it employs a smart-contract protocol to provide liquidity to users wishing to trade or swap different Ethereum-based tokens (ERC20 tokens). Kyber’s matching algorithm provides the best exchange rate available while ensuring that trades are executed for the full amount requested by the user. As a project based upon a public blockchain, token exchange rates are verifiable.
If that all sounds like a mouth-full, don’t worry. We’ll break it down below.
Back to Alice
Alice hears from Steve that cryptocurrencies like bitcoin and Ethereum are the next big thing. She decides to invest in Ethereum, and in so doing, signs up for a centralized, privately-operated, cryptocurrency exchange. This trading platform effectively functions like her stockbroker and allows her to buy and sell tokens easily. Liquidity is good, order books are deep, and trading tokens is relatively straightforward with little value loss in the form of slippage.
There are, however, some drawbacks. The trading platform charges significant fees as she transacts, and requires her to submit thorough identifying documents, a process known as KYC. Alice lives in a jurisdiction with uncertain policies towards cryptocurrency usage and is anxious about identifying herself. She is also aware that she exposes herself to third-party risk. If the exchange is hacked, her tokens and identifying information could be stolen.
Soon after acquiring Ethereum, she hears about another coin, the Basic Attention Token. Tired of paying hefty fees, KYC, and third-party risk, she seeks out a decentralized exchange. Decentralized trading platforms are not owned and operated by a central company, but rather a distributed network of computing resources. Similar to shareholders, token holders in the network, people supporting the network with hardware, as well as users decide how the exchange operates.
However, there have historically been issues. Decentralized exchanges often connect users directly, but may require users to be online to execute a trade. Some require that, like centralized exchanges, funds be deposited beforehand. Finally, many suffer from a lack of liquidity, which can lead to suboptimal trading and extreme value loss in the form of slippage.
The Kyber Network attempts to solve several of the issues inherent in centralized and decentralized exchanges.
Players in the Kyber Network
The actors in the Kyber Network are:
- The Protocol Implementation
The protocol implementation is the brains of the Kyber network. It consists of an interface that allows users to interact with the functionality of the smart contract system. It is the gateway controlling how actors interact with the network and the actions (programmatic function calls) that they can execute. The capabilities to check token exchange rates, execute a swap, and other quintessential actions are hard-coded here.
Takers are the individuals or entities seeking to use the network. They can be an end-user, an exchange, or any smart contract system. Takers hope to exchange their token for another. They effectively call the trade function and rely on the network to provide a reasonable swap of tokens. Kyber can be easily integrated into other systems, so a taker can be a DApp, vendor, or any other payment gateway.
Nevertheless, takers essentially rely on the liquidity provided by pools of tokens known as reserves. Reserves are independent sources of token inventories that control the exchange rate at which they are willing to trade those tokens. Together, they power the Kyber Network by providing an integrated source of liquidity from which takers can draw. Reserves can be manually operated, automated market makers, or on-chain token supplies. They can be run by individuals, by professionals, or by developers who have aggregated novel sources of liquidity. Reserves can also be formed by order books consisting of limit orders placed permissionlessly by community members.
Maintainers, as their name suggests, are charged with maintaining the network and liquidity protocol during the initial stages of development of the Kyber Network. Essentially, they are developers deciding how the network will operate as it matures. They add and remove reserves, add and remove token pairs, determine system governance, control the token supply, determine the path of development, and a host of other custodial functions until Kyber Network reaches a fully mature state. At that point, on-chain governance will allow token holders as well as maintainers to determine the future state and development of the protocol.
Alice Makes a Swap
At this point, Alice has a certain amount of Ethereum but is also interested in acquiring the Basic Attention Token. She heads over to kyberswap.com (or opens an application interfaced with the Kyber Network). As she is accessing a permissionless service, she needn’t submit to KYC, but only connect her cryptocurrency wallet holding her Ethereum. She selects the token she wants to swap for (Basic Attention Token), accepts the exchange rate, and determines the amount of slippage she is willing to accept. She must also choose a gas fee, a fee that determines how quickly her swap will execute (higher gas price=higher priority and faster execution).
At this point, Alice is essentially done. She need only wait until the transaction completes, and she will be able to find the Basic Attention Tokens she acquired waiting in her wallet.
The Kyber Network, on the other hand, has just begun processing her request. With the slippage parameter in memory, the Kyber main smart contract starts iterating through reserves looking for the best possible exchange rate. When it identifies a reserve supporting Alice’s desired token pain (Ethereum – Basic Attention Token) with an appropriate rate, a basic token trade occurs in a single smart contract transaction on the blockchain.
As you can see, in a basic token trade, the taker sends a trade request to the Kyber core smart contract. The smart contract, in turn, queries reserves about the rate at which they will exchange Ethereum for the Basic Attention Token. Reserves return their current exchange rate, and the protocol conducts the exchange at the most favorable rate (in this case, one Ethereum token for 820 Basic Attention Tokens). In the case of an irredeemable exchange rate or excessive slippage, the trade will not execute, and the protocol returns Alice’s Ethereum tokens. All in all, it’s a pretty straightforward swap.
Yet, Ethereum is a commonly traded token, and several reserves support Ethereum-Basic Attention Token swaps. What happens when Alice wants to trade in an unusual token pair?
At some point, Alice’s friend Steve suggests she acquire Dai stablecoin, another Ethereum DeFi token. Alice decides to use a portion of her recently acquired Basic Attention Tokens. Although this is an unusual trade pair, The Kyber Network can still help Alice swap to Dai by performing a token to token trade.
In a token to token trade, the taker, Alice, sends her Basic Attention Token to the smart contract, which then queries reserves for the best Basic Attention Token-Ethereum exchange rate. After trading with reserve 1, it repeats the process for the best Ethereum-Dai exchange rate, and finally returns 30 Dai to Alice’s wallet. Once again, pretty straightforward for Alice.
Onwards and Forwards
Alice has come pretty far in her short time investing. She has moved beyond stocks and found ways to invest in cryptoassets that suit her particular situation. Furthermore, she is beginning to see some of the many advantages of decentralized finance. As she transacts and moves in and out of tokens, she can use decentralized services like the Kyber Network to trade securely and, in most cases, without submitting to KYC. As she accumulates more assets, she may choose to participate in liquidity pools and to operate a reserve on the Kyber Network. Furthermore, she may invest in the Kyber token, KNC, and become more tied to the future on the project and its governance moving forward. More on that next time.