From /tech/ Wiki
Jump to navigationJump to search

Bancor is a protocol for creating currencies with automatic and continuous liquidity. Automatic means the currency can be bought as sold on demand without a counterparty. Continuous liquidity means prices changes continuously. Mathematically this is like breaking up an order into consecutively executed infinitesimal micro-orders. After each micro-order the price increases by a micro amount and the next order is executed at the new price.

The core concept of Bancor is a smart token. A smart token is a cryptocurrency that uses a smart contract called a token relay to facilitate automatic exchange at a formulaic price without a counterparty.

When a buyer sends funds to the token relay, tokens are automatically minted and relayed to the buyer. The funds remain in the relay as reserve. Likewise, a seller can convert the tokens into the reserve currency, at which point the tokens are destroyed.

The smart token sidesteps the double coincidence of wants problem as its token relay will always buy and always sell. In this sense, the relay is not an exchange but an automatic liquidity provider. On each purchase or sale, the next price is automatically recalculated. At any given time, the relay offers the same price to both buyer and seller. There is no spread and no order book. Token Relays are therefore not subject to order spoofing. They are also resilient to pump and dump schemes as the perpetrator(s) are unable to trade between each-other and the high liquidity can pose significant risk.

Exchange rates are calculated mathematically. The formula takes into account the supply outstanding, the reserve or connector balance, and a third factor called the connector weight.


The weight controls the magnitude and direction of price slippage. The weight is a percentage greater than zero and is fixed upon the creation of the relay. Weights closer to 100% create greater liquidity, i.e. less slippage.

A weight of 100% represents a state of perfect liquidity, or a market so liquid that no amount of buying or selling can change the exchange rate. This is analogous to a gold backed currency in which every new dollar is backed by a fixed amount of gold. Other weights create in essence a fractional reserve system, where each successive seller is entitled to a little less of the reserve. A weight of 50% is linear, prices will grow and shrink with demand at the same rate in both directions. A weight exceeding 100% represents a token which decreases in price with increased demand and increases with increased supply.

Price Calculation

The given price or exchange rate is the last calculated price from the previous execution.

[math]\text{price} = \frac{\text{reserve}}{\text{supply} \times \text{weight}}[/math].

It is possible to predetermine an effective price based on the magnitude of an order. Larger orders result in greater slippage and therefore a higher price per unit. The effective price is simply the ratio between payment and return. When taking into accounting slippage on a purchase order, return can be calculated as:

[math]\text{tokens issued} = \text{supply} \times \left(\left(1+\frac{\text{reserve paid}}{\text{reserve}}\right)^{weight}-1\right)[/math].

The effective price is then:

[math]\text{effective price} = \frac{\text{reserve paid}}{\text{tokens issued}}[/math].

These calculations are run on behalf of users when they enter their orders. A token may also be traded over-the-counter (OTC) or on a traditional exchange with market based price determination. These prices may diverge from the token relay price, but in practice arbitrage bots create price convergence.

Relay Tokens

A smart token with two connected reserve tokens each at 50% weight is known as a relay token. The reserve tokens can exchanged using the relay token as an intermediary. You can think of this as a system of two buckets (abstracting away the relay token). Each bucket contains some amount of a reserve token. If one bucket contains 100 feathers and the other contains 25 rocks then the exchange rate is 1 feather to 4 rocks. If there is only one feather and rock in each respective bucket then the exchange rate is 1 to 1. Despite how it may at first appear, it is impossible for either bucket to run out because as the supply approaches 0 the exchange rate approaches infinity. In the 1 to 1 example, if you spend one rock to buy the 1 feather the exchange rate changes. Now each feather is worth two rocks and you only spent one! Likewise, a million rocks could not be used to purchase one whole feather as the influx of those rocks would make the feather worth a million and one.