Part of Hydro’s mission is to take blockchain beyond the proof-of-concept phase. To that end, this series will take a look at some examples of blockchain technology being used in the real world. There are a variety of blockchain projects out there with live, working products and services you can use today, and we want to highlight them here!

Background

The Kyber Network released its White Paper in August of 2017 and immediately became one of the most highly anticipated projects built on ethereum; decentralized exchanges have only recently begun to grow in popularity which is interesting because in their absence, acquiring tokens that have decentralized functionality requires complete trust in centralized exchanges. This unusual irony plagues the crypto-economy despite vivid memories of Mt. Gox and other exchange failures burned into the minds of blockchain enthusiasts.

Decentralized exchanges besides Kyber exist, such as forkdelta; however, they have not gained popularity over large exchanges, largely because they generally rely on traditional order book mechanisms that can’t be stored on-chain due to speed and scalability issues. This means funds have to be transferred out of a personal wallet and stored in a smart contract that sifts through off-chain orders before they can be exchanged. The Kyber network addresses this issue through the use of liquidity reserves maintained by third parties, called Reserve Managers. Of course, parties must be incentivized to provide liquidity reserves; this is why the Kyber Network has a token while forkdelta does not.

How The Network Works

The Kyber Network Token (KNC) is required to become a Reserve Manager in the Kyber Network. Reserve Managers use these tokens to manage the reserve, dispersing a fraction to third parties involved in maintaining the reserve, after which they are burned by an amount proportional to a percentage of the total supply of KNC tokens. This allows for inflation in the value of KNC tokens while making sure they will never run out.

Reserve managers use a dashboard to implement pricing strategies — they earn profit* from the spread on transactions, so they are incentivized to compete with one another and keep the spread small. In this way, reserve managers provide for an alternative to set prices besides the traditional order book structure. Other decentralized exchanges set prices using order books — storing these order books on-chain would be profoundly network-intensive since there is a constant stream of orders being placed, cancelled, and executed. Accordingly, most of these books are, in practice, stored off-chain and therefore exist as central points of failure.

The Kyber Whitepaper references another involved party as well, the Reserve Contributor; however, at this time, I don’t think it makes sense to separate out Reserve Managers and Reserve Contributors. Reserve Contributors are intended to provide liquidity to a Reserve Manger’s reserve for which the Reserve Manager dictates prices. This makes sense because just the subset of people willing to take the active role of Reserve Management probably won’t provide enough liquidity to support the entire network. Allowing Reserve Contributors to earn passive income by storing their tokens in a reserve is healthy to a more liquid ecosystem, which would drive down prices. However, there is no decentralized, incentive compatible process that Kyber plans on creating to allow Reserve Contributors to trustlessly provide liquidity. Instead, it is the responsibility of the Reserve Manager to determine what percentage of their own profit gets distributed to which contributors and to manage that dissemination. This could theoretically be achieved in a decentralized process through the use of decentralized asset management protocols such as Melonport; however, this is outside the scope of the Kyber team and has not yet been achieved in practice.

People who want to become Reserve Mangers require KYC. Currently, this KYC is done by Kyber itself; Kyber is playing the role of the only Kyber Network Operator. In time, the plan is to allow more Kyber Network Operators to exist — they would be chosen through a decentralized governance structure, though it is presently unclear as to what such a governance structure would look like.

Experience Using the Product

I’m sure many readers will have made transactions on various exchanges before; for these people, the user-facing UI of the Kyber Network is very easy to use. You can connect your wallet through several options — I chose MetaMask. You simply type in the quantity of one token you want to convert, it tells you how much of the other token you will receive, and you execute the transaction. I honestly think it’s even easier than using a centralized exchange.

While the completed UI for token swaps appeals to the broadest range of users, I wanted to dig a layer deeper. Kyber’s decentralized exchange is only possible when there are actual reserves being managed on the network; in practice, control over the network is distributed among the Reserve Managers who provide liquidity and set prices; if one Reserve Manager controls all the liquidity on the network, she would set monopoly prices. If only a few large Reserve Managers exist, there is potential for collusion to drive suboptimal exchange rates for end users. The vision of decentralization for the Kyber Network comes from the idea that many Reserve Managers can exist. As of now, this is tough since the Reserve Manager dashboard hasn’t yet been built out; however, it obviously must be possible, as the network is live. Accordingly, I set out to become a Reserve Manager on the Kyber Network.

Since this requires interacting directly with the Kyber Smart Contract, Kyber hasn’t yet put out any resources on becoming a Kyber Reserve Manager. Their priority is building out the dashboard UI; after all, even if the Network hasn’t achieved its intended level of decentralization, it is still no more centralized than a traditional exchange.

To get started, I simply sent a message in the Kyber Telegram group asking how to become a Reserve Manager. The admins initially told me that this process wasn’t yet available to the general public; however, I was persistent, and they directed me to Yaron Velner (@yaron_263), the CTO of Kyber, who offered to walk me through the process on the Kyber Testnet.

Since there currently isn’t much available content to help people become Reserve Managers, I’ll delineate the steps I took. I created a very basic reserve with a fixed exchange rate; however, in practice, a reserve manager would programmatically implement a dynamic pricing strategy. Since I was just manually calling a few functions, I completed the process through MyCrypto.

I provided Yaron my ethereum address, and he deployed the relevant contracts for me. Normally, a Reserve Manager would deploy these contracts himself, but to speed up the process, Yaron completed this for me.

He then gave me my reserve address of: 0x22c16781922Bf657AF2dE191e208628A3580de99

I already had some Testnet Ether, and I needed to acquire another testnet token in order to be able to provide a reserve. I decided to use the Kyber Network itself to do this — I visited their testnet website and used MetaMask to buy some testnet OMG and testnet KNC using my testnet Ether.

Now I was ready to begin the actual process of maintaining a reserve.

The first step was to set the exchange rate for my reserve. If I were completing this as a more sophisticated process, I would have needed to use web3 to programmatically interact with the Kyber contract address. I would set certain rules based on other observed exchange activity, and have my program keep setting a new base exchange rate depending on the rate that other trades were occurring. In this case, I just manually set a constant base rate by calling the setBaseRate function in MyCrypto.

The contract ABI can be found here.

I didn’t want to set the exact rates as coinmarketcap because that wouldn’t be very interesting, so I set the baseBuy rate at 46482938205100000000 (bc tokens have 18 decimal places, this is actually ~0.465 ETH/OMG and the baseSell rate at 2151280000000000 (~21.5 OMG/ETH).

Buy, sell, and indeces are just optimization features, so I set those to 0, and blockNumber is just the current ropsten block number which can be found here.

Once I finished setting the exchange rate for my reserve, I sent some ETH and OMG to my reserve to create a liquidity supply, and my reserve was created. The next step was to give allowance to Kyber’s fee contract: 0x89B5c470559b80e541E53eF78244edD112c7C58A

I used the mainnet abi since the ropsten abi wasn’t verified, but it’s the same code.

I populated _value with something random since I didn’t really have an expected volume. Normally this should cover .25% of the expected volume. The last step to become a reserve on the Kyber Network was to be approved by a network operator. Kyber is currently the only network operator on the Kyber Network, so Yaron had to authorize me as an official reserve.

Once he completed that, my reserve was fully set up. Next, the fun part: testing it — exchanging ETH for OMG using my reserve, and accordingly receiving a (testnet) profit-share from the transaction. For simplicity, I exchanged exactly 1 wei (smallest denomination of Ether) to OMG. I wanted to get a better understanding of exactly how this transaction interacts with my reserve instead of anyone else’s, so I decided to transact directly with the smart contract through MyCrypto instead of using the kyber network website again for this transaction.

I got the ABI from the Ropsten Contract. The parameters are: src (source), srcAmount, dest, destAddress, maxDestAmount, minConversionRate, and walletID. The source is the token I am converting into something else. In this case, it would be Ether. Since ETH is not technically a token, Kyber uses the 0ee… address as a proxy; when 0ee… is passed in as a parameter, it is interpreted as Ether. I set srcAmount as 1 since I am only sending 1 wei. I set dest to the OMG contract address since that will be the destination of the transaction. For destAddress, I set my own address; this ensures that I receive a profit share from transactions conducted on my reserve. maxDestAmount is important when using the Kyber Network for payments, which I will describe in the next section of this article. Since I don’t have a payments API to plug into the contract, I just set maxDestAmount to a large number for now. I set minConversionRate to 1 for simplicity to make the exchange execute immediately at current market prices; varying this rate would be like creating a limit order. Finally, for walletID I set my own wallet again — this parameter just provides an option to send some of the fees to affiliated wallets.

Once I completed this process, I set the value to 1 wei (the quantity of the trade) and sent the transaction using MetaMask. Unlike the srcAmount variable, this value is in denominations of ether, so I had to set it to 1x10¹⁸ ETH, which is the same as 1 wei.

You can see the successful transaction here. You can see that I received a fee of 92 wei upon completion of the transaction. (The reason this value is so high is because I set absurd transaction rates which Yaron and I decided would be more interesting than just setting the coinmarketcap rates.

Interestingly, you can see the path of the transaction — it went from my wallet to the Kyber Network and from the network to my reserve, after which OMG left my reserve and went to the network, and then returned from the network to the user.

Feel free to conduct transactions on my reserve, but I recommend that you do them in small quantities since I don’t have much ETH or OMG in it. One day when I have more time, I’ll try to set up a small reserve on the main net, and add it to this article, so if you want to try it for yourselves, I can receive a real portion 😊

Using the Kyber Network for Payments

I used the Kyber Network to create a reserve, contribute to the reserve, and conduct a transaction on the reserve. However, another interesting use case is to enable merchants to receive payments with any token for their services. If a merchant were selling something, his customer could pay in OMG, it would swap into my preferred token through the reserve, and I would receive the end payment in ETH. This can be linked to any existing payment infrastructure through an API. To ensure that the correct amount of token is received, the merchant would set the maxDestAmount parameter to the exact amount of tokens the customer would need to pay. So if someone needed to pay him exactly 100 OMG, he would set maxDestAmount to 100, and then the reserve would only convert enough ETH to get 100 OMG. This is a prolific use-case that can broaden the Kyber Network much beyond the scope of just an exchange for traders into something that will impact the day-to-day lives of end-users, once reserve APIs are built out.

Strengths and Challenges of the Kyber Network as it Currently Stands

Kyber Network is a strong alternative to a centralized exchange and will only continue to grow as it is able to maintain the necessary reserves to support more tokens and coins. More interestingly, Kyber Network APIs allow for the network to support payments as well. A store can use the Kyber Network to intermediate transactions, so it can always be paid in a token of its choice, regardless of what token customers pay in. It creates a strong, practical use-case for blockchain technology and will only improve as more features are built on top of it.

I also want to commend the team on their responsiveness and technical support. I had to join the Kyber telegram to go through the process of writing this article, and I was happy to see that their admins are very active in helping people understand the protocol at a technical level. It was great to have been able to speak with Yaron on a detailed, technical level despite all of his responsibilities, and I was able to see first-hand his intricate knowledge of the contracts his team has built.

Unlike centralized exchanges, Kyber Network can’t support much high-frequency trading and hasn’t been tested at large volumes due to the scalability of Ethereum as a whole; however, trades are locked in at the price determined at the time of execution, and they are simple transactions that require relatively low gas costs, which is much more efficient than putting a traditional orderbook structure on-chain.

In terms of challenges, the most clear one is supporting decentralization at the protocol level. Kyber Network Operators select Reserve Managers who set the prices for the network. If these parties are not malicious, the network has enormous potential; however, we currently have to trust the Kyber Network completely, as it is the only Network Operator.

Another interesting challenge comes from the fact that opportunity costs must be low for Reserve Contributors to consider maintaining reserves. Many coins with dPOS consensus mechanisms provide wallet holders a passive income already, so reserve commissions must exceed this passive income. As the crypto-economy blossoms, other sources of interest rates, for example from lending platforms, could put upward pressure on the necessary fees Reserve Managers would need to set to maintain reserves within the Kyber Network. If those rates get too high, they get passed to end-users who would be likely to move to an order book-based exchange where reserves aren’t necessary and market-maker fees would be lower than Kyber Network fees. Ultimately, this creates a reliance on low-interest rate environments.

All-in-All

Kyber Network meets the functionality necessary for an exchange and is definitely a promising MVP; however, it also challenges the notion of what it is to be decentralized. Ultimately, anyone will be able to set up their own private or public reserves, and all sorts of Network Operators will endorse these various Reserve Managers; however, even then, Network Operators will always have skewed influence on the Network. Market principles and incentives can drive prices down, but from a purist perspective, there will always exist the possibility of collusion and network control. The closest the Kyber Network could get to remediating this challenge is implementing a decentralized governance structure which raises an interesting question: if we democratically vote for our senators, are each of the policies they implement reflective of the view of the democracy as a whole? Even if a voting mechanism is decentralized, any governance structure will always be subject to philosophical scrutiny, and the Kyber Network cannot be purely decentralized at the protocol level, but I personally don’t think that’s a problem. It sacrifices purist decentralization in favor or functional decentralization, much like many existing tokens do at the consensus level already. Finally, the Kyber Network works best when the opportunity cost for Reserve Contributors is low, so it makes sense for them to contribute to reserves and earn a passive income. From an incentive-compatibility stance, I don’t see anything in the Kyber protocol to address this challenge; however, the closest mitigator I can imagine is a future in which it is widely adopted and perceived as a low-risk investment to create and maintain a reserve.

*Reserve Mangers’ profit is currently set to 0.25% as a fixed percent of their volume. The Network Operator sets this rate; currently, it is set at .25% by Kyber — in the future, a decentralized governance structure would decide what the rate should be. It makes sense not to have a fixed rate because if interest rates are higher outside of the network, the Network Operator will need to increase this rate in order to prevent reserves from moving elsewhere.

Note: I do not currently hold any KNC or have any connection to Kyber Network as a project outside of my interest in the technology and speaking with Yaron within the scope of this article.