Giter Club home page Giter Club logo

contracts's Introduction

Bancor Protocol Contracts v0.6 (alpha)

Bancor is a smart-contract-based token conversion protocol, which enables a single party to convert any token to another, without requiring a second party to exchange with. It achieves this through the use of reserve-tokens, which provide liquidity through autonomous algorithmic price discovery, regardless of trade volume.

Overview

The Bancor protocol represents the first technological solution for the classic problem in economics known as the “Double Coincidence of Wants”, in the domain of asset exchange. For barter, the coincidence of wants problem was solved through money. For money, exchanges still rely on labor, via bid/ask orders and trade between external agents, to make markets and supply liquidity.

Through the use of smart-contracts, Smart Tokens can be created that hold one or more other tokens in their reserve. Tokens may represent existing national currencies or other types of assets. By using a reserve token model and algorithmically-calculated conversion rates, the Bancor Protocol creates a new type of ecosystem for asset exchange, with no central control. This decentralized hierarchical monetary system lays the foundation for an autonomous decentralized global exchange with numerous and substantial advantages.

Warning

Bancor is a work in progress. Make sure you understand the risks before using it.

The Bancor Standards

Bancor protocol is implemented using multiple contracts. The main ones are SmartToken and BancorChanger. BancorChanger implements the token changer standard (See ethereum/EIPs#228) and is responsible for converting between a token and its reserves. SmartToken represents a changer aware ERC-20 compliant token.

The Smart Token Standard

Motivation

Those will allow creating a Bancor compliant token while keeping dependencies at a minimum. In addition, it allows an owning contract to extend its functionality by giving the owner full control.

Specification

SmartToken

First and foremost, a Smart Token is also an ERC-20 compliant token. As such, it implements both the standard token methods and the standard token events.

Methods

Note that these methods can only be executed by the token owner.

issue

function issue(address _to, uint256 _amount)

Increases the token supply and sends the new tokens to an account.


destroy

function destroy(address _from, uint256 _amount)

Removes tokens from an account and decreases the token supply.


disableTransfers

function disableTransfers(bool _disable)

Disables transfer/transferFrom functionality.


Events

NewSmartToken

event NewSmartToken(address _token)

Triggered when a smart token is deployed.


Issuance

event Issuance(uint256 _amount)

Triggered when the total supply is increased.


Destruction

event Destruction(uint256 _amount)

Triggered when the total supply is decreased.


The Bancor Changer Standard

The following section describes standard functions a bancor changer can implement.

Motivation

Those will allow dapps and wallets to buy and sell the token.

The most important here is change.

Specification

BancorToken

First and foremost, a Bancor Changer is also an EIP-228 compliant changer. As such, it implements both the standard changer methods and the standard changer events.

Methods

reserveTokenCount

function reserveTokenCount() public constant returns (uint16 count)

Gets the number of reserve tokens defined for the token.


reserveTokens

function reserveTokens() public constant returns (address[] reserveTokens)

Gets an array of the reserve token contract addresses.


reserves

function reserves(address _reserveToken) public constant

Gets the reserve token details.


change

function change(address _fromToken, address _toToken, uint256 _amount, uint256 _minReturn)

changes a specific amount of _fromToken to _toToken The change will only take place if it returns a value greater or equal to _minReturn.


Events

Change

event Change(address indexed _fromToken, address indexed _toToken, address indexed _trader, uint256 _amount, uint256 _return);

Triggered when a change between one of the changeable tokens takes place.

Testing

Tests are included and can be run using truffle.

Prerequisites

  • Node.js v7.6.0+
  • truffle v3.2.2+
  • testrpc v3.0.5+

To run the test, execute the following commands from the project's root folder -

  • npm start testrpc
  • npm test

Collaborators

License

Bancor Protocol is open source and distributed under the Apache License v2.0

contracts's People

Contributors

arachnid avatar asaflocal avatar barakman avatar holiman avatar yudilevi avatar yudilevi2 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.