From /tech/ Wiki
Jump to navigationJump to search
Tip: This article was submitted as a draft on Wikipedia and within minutes was flagged under "articles for speedy deletion" and deleted by an administrator citing "more crypto spam", bypassing any formal deletion discussion. By a unanimous vote the admin was found to be in error, and an early version of this article has been restored as a draft article, but there is little reason to believe the editors will ever agree to publish it.

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.

Connector Weight

The weight controls the rate 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, in other words a market so liquid that no amount of buying or selling can change the exchange rate. This is analagous 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

Prices in Bancor are recalculated during execution so there is never one price. The current exchange rate on a Bancor market is simply the last calculated price from an earlier execution.

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

It is still possible to precalculate an effective price based on the magnitude of an order. Larger orders cause 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].

The Bancor exchange runs the calculations on behalf of users when they enter their orders. A smart 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.

Bancor and UniSwap

The Bancor idea has since been interated on with UniSwap. The concept of a smart token has been abstracted into the math itself.

Bernard Lietar

In the last few years of his life Belgian economist Bernard Lietar became fascinated with Bancor and joined the project as an advisor. Bernard was a lifelong advocate of complimentary currencies and declared the Bancor solution to liquidity a "breakthrough".