The Math Behind Bancor Token Exchange Smart Contract

in #bancor7 years ago

Bancor has a great pitch regarding instant smart-contract enabled token exchange. I'll approach this post from the point of view of token issuers, usually in the form of ICOs or even other methods (such as community-issued tokens).

So how does the math work? Say you have an ICO and raise 10,000 ETH. Now the idea behind Bancor is that you'll be able to put a fraction of it locked into a smart contract. Say you decide on 20%. This means 20% of 10,000 ETH which is 2,000 ETH will be locked away in a smart contract. The purpose of the smart contract is to provide a fixed price for each buy and sell of the token against the reserve, i.e. ETH. For example, if your ICO token is IXX and you've issued 1,000,000 (million) tokens, then based on the ICO price, it is valued at 100 IXX = 1 ETH or the price of each IXX token is 1,000,000/10,000 = 0.01 ETH. Now, you lock up 2,000 ETH in a smart contract. This is only to provide liquidity - it should NOT be subtracted from the project valuation. This 2,000 ETH in reserve are worth a total of 2,000 * 100 = 200,000 IXX tokens based on the ICO price.

Now that you have 2,000 ETH in a smart contract, you can start buying or selling IXX. Say you buy 100 ETH worth of IXX via this smart contract. This means the total smart contract balance is now 2,000 + 100 = 2100 ETH. 100 ETH, based on the current price, buys you 100 * 100 = 10,000 IXX.

Here comes the interesting part. Let's calculate the new price of IXX tokens in the smart contract. What's the fair price now, after the buy? Clearly, the smart contract needs to adjust the price each time, otherwise you can simply keep getting cheaper IXX tokens from the smart contract instead of the market, and there is no benefit whatesoever (in fact it is detrimental to your project).

Here's the formula now to calculate the price: Balance/(Supply*Reserve ratio). In our case, this is -
2100/(1000000 * 0.20) = 0.0105.

And viola! This is where the magic happens. The original price of IXX in ETH was 0.01 and now it is 0.0105. The price has increased after the buy. As expected, it should be more expensive now to buy IXX than it was before. The exact dynamic but in reverse happens when someone wants to sell IXX for ETH from the smart contract. This will reduce the price of IXX accordingly, and we can go through the exact same calculations above.

In this way, Bancor provides a continuously adjusted price for the smart contract. If many people are buying, the price increases and if many are selling, the price decreases. This is exactly like a traditional exchange dynamic of buyers and sellers setting price. However, in Bancor's case, everything is intermediated through smart contract and not central intermediaries and so there is no counterparty risk involved.

It will be very interesting to see projects issue new tokens using Bancor, and have an instant source of liquidity for their tokens irrespective of whether Poloniex or Bittrex or Liqui list them or not. Also interesting would be if multiple currencies are backing the token, not just ETH (any ERC20 token will do). Finally, it would be interesting to chart out how much percentage projects will choose to keep in reserve.

The Bancor ICO is soon if you're interested. Here's the whitepaper with more details.

Sort:  

Very good article. I was about to start a similair discussion. I strongly advice people to only buy in to cryptos that have a solid background: A solid team, product, advisors, preferably VC investors, etc. Sell all cryptos that don't have this solid background. It's a waiste of money. Personally I always use: https://www.coincheckup.com Supposingly they researched every crypto coin in the scene based on: the team, the product, advisors, community, the business and the business model. They even score the coins stengths. On: https://www.coincheckup.com/coins/Bancor#analysis For a complete Bancor Indepth analysis.

Coin Marketplace

STEEM 0.26
TRX 0.20
JST 0.038
BTC 96662.00
ETH 3660.13
USDT 1.00
SBD 3.84