Press "Enter" to skip to content

Building and Managing a Cryptocurrency exchange in India  and the  Challenges

A lot of stress is going around in the Indian crypto space lately, mainly due to lack of proper communication from the government. Also, due to negative news about the possible ban. Before jumping directly on to the technical part of building and managing a crypto currency exchange in India, one must understand the actual regulatory stress for the founders of such a business.

We must not forget that in the last budget speech, the Finance Minister clearly emphasised his unhappiness around crypto currencies. Even though he clearly mentioned “Illicit use” and not crypto currency as a whole, we cannot completely rule out the possibility of the ban.

From the perspective of an average investor or a complete outsider, one may argue that it is a possibility and not actually happening. An exchange should be responsible towards their users. That’s true. But from exchange’s perspective, there’s a lot more at stake.

For those who may not know, we were the first (Coinrecoil) to file the writ petition against the RBI circular. We included GST council, RBI, and the Union of Indian in our petition. From our last call with our lawyers, it was decided to not go ahead with the launch. In clear words, even if we close down operation after proposed ban is introduced, we may be scrutinised by ED, FEMA, or other government authorities. That may be a complete torture.

We weren’t afraid of that, because if we were, we wouldn’t file the writ petition in the first place. My point is, Koinex also filed a petition in the Supreme Court, they too aren’t afraid, but in the end, it’s the entire career at stake; not just money. Now that you have the bigger picture of what’s actually happening, and why exchanges are shutting down, let’s check the technical complexity of the business.

Technical Challenges

Order-book

You may be fascinated to see those order-books flashing every nanosecond. But actually there are hundreds, if not thousands, of process going at the same time on the back-end. These algorithms are complex and extremely hard to design. The real-time streaming works on the web socket.

To non-technical, web socket is like an open door. You can move in and out quickly without pulling or pushing the door. In an application, web socket is like a door between front-end and back-end, which is kept open through secure tunnel to stream data in real-time.

There are web sockets available from open source library. But Koinex decided to develop that entire thing in-house, because they wanted to keep control of the system and make changes as per their needs depending on the trading volumes. They had a long-term vision.

Having developed our own exchange, I can tell you that no company will develop something like this, unless they have a clear vision of why they need it. The reason I am mentioning this is because I watched many tweets from users using “exit scam” word.

The definition of exit-scam is when someone closes the business and runs away without informing.

For minimum order amount, I won’t go into much detail. Just imagine if there is no minimum limit, people may place an order of just one satoshi. The cost on exchange is the same whether you buy/sell 1 satoshi or 1 BTC. But 1 BTC will generate them better revenue which will ultimately invested to enhance the exchange.

Order Matching

Most of you may already know what order matching is. When a buy order is matched with a sell order, it is called order matching. But this tiny little logic is the real headache when developing an exchange.

One must keep track of time of placing the order, order-book sequence, handling partial orders, handling full orders, etc. On successful execution, the buyer wallet is credited and sellers wallet it debited. Sounds simple. Imagine this with millions of orders placed, matched, executed, debiting wallets, and crediting wallets at the same time.

Crypto Deposits

This is the most important part which most of you may be interested in knowing. An exchange has thousands of wallets from thousands of users. Out of them, hundreds of users may be depositing BTC at the same time. Do you know how the exchange knows which deposit belongs to whom ?

BTC blockchain has a notification feature called walletnotify. This feature sends a notification with transaction ID to the URL provided by exchange application. Now using this transaction ID, the application will make another call to bitcoin node to find the wallet address and deposit amount. Getting the wallet address, the application will then check in the database for corresponding user and then save the deposit amount in that user.

This was just to get the deposit address and amount, not the confirmation. Calculating confirmations is altogether a different story. You may now understand why your deposits sometimes take longer time to reflect on your account. Because if there are hundreds of deposits made at the same time, BTC node itself may not send the notification, and someone from the exchange team will have to personally log in to the node and manually check transactions.

Crypto Withdrawals

Withdrawals seems pretty straight forward, also from technical perspective. But from compliance view, this is the hardest part. As one wrong withdrawal bug may bring down an entire exchange. Imagine when you have just 1 BTC on an exchange, and you place withdrawal of 100 BTC. There are a lot of validations, automatic and manual to make sure you are withdrawing only what you have.

For withdrawal fees, BTC offers a fee estimation API called estimatesmartfee. Now fees depend on how fast you want your transaction to get included in a block For e.g. if you want your transaction to be included in the next block itself, fees will be higher.

As an exchange, asking so many technical things may spoil user experience. So ideally, exchanges charge a higher withdrawal fees, so the transaction doesn’t stay in the memory pool for a long time. Because if that happens, users will raise support tickets, which will reduce the productivity and increase the cost for the exchange. So if you see an exchange charging nominally higher withdrawal fees, then they aren’t looting you. They are doing it to reduce your as well as their headache.

This practice is not universal and differs from case-to-case. For e.g. if an exchange was charging 0.0001 BTC as withdrawal fees, but after announcing shutdown of operation, if they start charging 0.001 BTC, then that’s cheating.

Another possible reason for charging slightly higher fees is to avoid spam. Bitfinex did this in the past. Many users make multiple withdrawal in extremely small amounts putting undue load on the servers.

Why Koinex is not processing withdrawals quickly

This is my wild guess and should be treated with a pinch of salt. Koinex might have a completely different reason from what I am mentioning here.

Remember memory pool talked above? Every exchange runs its own BTC node and every node has specific memory pool size. You can increase the memory pool size, but sometimes thousands of transaction can fill entire memory pool and transactions after that situation may not go through. This is very unlikely to happen though.

Also, every withdrawal request is generally processed manually by the exchange staff to double check the user’s balance. As Koinex is shutting down, thousands of users are making withdrawal request and that puts a lot of workload on the team.

Withdrawal limits

At this point, I wouldn’t actually advocate in favor of Koinex. Every exchange in the world supports 8 decimal for BTC. Why should one limit that to 5 decimals and disturb the balance? I am assuming that this is a mistake and not an intention.

Update: Koinex has now increased the decimal limit to 8 digits.

Because Koinex can control the withdrawals as per their terms, but they cannot control the deposits. A user can deposit 1.12345678 from Binance to Koinex just to know that now he can withdraw only 1.12345. This should have been considered before.

But I guess they may settle this as the deadline approaches.

Financial stress

It is a general perception around the world that crypto currency exchanges makes millions of dollars every month. But that’s not the case with India.

I’ll give you a brief about the cost. An expert developer with 4–5 years of experience in Ahmedabad demands at least 80,000/- (bare minimum) a month. We need at least 2 of them to guide the juniors. The junior developers range from 30–50K / month.

Calculate a team size of just 15 developers, add customer support staff, devOps (server expert), at least 4 servers on AWS, other operational expenses, etc. Ahmedabad is not an IT hub, yet salary standards are quite high. Imagine having an office in Mumbai, Pune, Delhi, or Bangalore.

My personal opinion:

I noticed that when Zebpay announced their closure, Indian users literally abused them on Twitter calling them thieves, and whatnot. People don’t understand the cost of running this business. Even if there are zero trades, it costs lacs of rupees every month. No one can sustain that. Even if they can, it doesn’t make sense when the future is completely greyed out. So it’s a request to support these exchanges when they are fighting all the odds just to keep their services up and running. I won’t be wrong if I say that none of the Indian exchanges are in profits. Yet they are fighting. Appreciate that.

As the founder of CoinRecoil exchange, which I guess may not even see the light of day, I have received a lot of criticism from many people that we are afraid to launch. I smile and let it go. Startup is not easy, and crypto startup that too in India, is incredibly tough.

Business to a man, is like a child to a mother. — My Father’s last words.

Let’s try to help Koinex and other operational exchanges and not increase their burden. They are already going through a lot. The challenges mentioned are not even the tip of the iceberg.

Please Note: Information mentioned here are based on experience, assumptions, and personal opinion. Please let me know if anything offends anyone. I don’t promise I’ll help, but I may try.

The article was originally published on author’s medium blog and has been republished here with permission.

Disclaimer: The author Kunal Barchha is the founder and CEO of CoinRecoil exchange. The opinions expressed in the article are his personal opinions and Coin Crunch may or may not agree with the same.

Latest Posts
Send this to a friend