- IF Anyone Wishes to support the development of this project and others, and incourge more open source projects - you can do so by donating via this link http://bit.ly/2JKZ8xd
Decentralized exchange built on Ethereum.
This repository contains the source code that runs the exchange on Ethereum as a set of contracts, along with the UI, tests, tools and documentation.
Start by cloning this repository.
git clone https://github.com/deltatoken/TokenEther.git
This will install pyethereum
and ethereum-serpent
if you don't already have those installed.
pip install -r dev_requirements.txt
py.test -vvrs
Refer to Serpent and pyethereum for their respective usage.
You will need a working node.js setup (instructions) and globally installed grunt-cli
(instructions).
cd frontend
npm install -g
grunt
And open http://localhost:8089/
in your browser.
Requires a local client (Go or C++) with JSONRPC, Serpent and PyEPM
cd contracts
pyepm TokenEther.yaml
- The API is the format of the data field for the Ethereum transactions.
- Subcurrencies need to support the Subcurrency API.
- You only need an Ethereum client to use the API.
Methods (with serpent type definitions):
[
price:[int256]:int256,
buy:[int256,int256,int256]:int256,
sell:[int256,int256,int256]:int256,
trade:[int256,int256[]]:int256,
cancel:[int256]:int256,
deposit:[int256,int256]:int256,
withdraw:[int256,int256]:int256,
add_market:[int256,int256,int256,int256,int256,int256]:int256,
get_market_id:[int256]:int256,
get_market_id_by_name:[int256]:int256,
get_last_market_id:[]:int256,
get_market:[int256]:int256[],
get_trade:[int256]:int256[],
get_trade_ids:[int256]:int256[],
get_sub_balance:[int256,int256]:int256[]
]
price(market_id)
buy(amount, price, market_id)
sell(amount, price, market_id)
trade(max_amount, trade_ids)
deposit(amount, market_id)
withdraw(amount, market_id)
cancel(trade_id)
add_market(currency_name, contract_address, decimal_precision, price_denominator, minimum_total, category)
get_market_id(contract_address)
get_market_id_by_name(name)
Market names follow the "/ETH" convention. When registering a new market, submit the currency name as a three or four letter uppercase identifier, ex.: "BOB" for BobCoin.
The subcurrency contract address.
The subcurrency's decimal precision as an integer.
- Denominator for price precision, ex. 10000 (10000 => 1 / 10000 => 0.0001)
When adding a subcurrency, set the minimum trade total high enough to make economic sense. A minimum of 10 ETH (1000000000000000000000 wei) is recommended.
1 = Subcurrencies
2 = Crypto-currencies
3 = Real-world assets
4 = Fiat currencies
EtherEx allows you to categorize your subcurrency into four main categories. Since everything is represented as subcurrencies, those categories are simply for convenience. If you have a DApp that has its own token, that would go in the regular subcurrency section 1
. If your token represents a fiat currency redeemable at a gateway, add it to 4
. If your token represents a real-world asset like gold or a car, add it to 3
. For other crypto-currencies like BTC, also redeemable at a gateway, add it to 2
.
1 = ETX/ETH
New market IDs will be created as DAO creators add their subcurrency to the exchange.
Subcurrency contracts need to support the Standardized Contract APIs (see current Draft), more specifically the approve
, transferFrom
and allowance
methods for deposits, the transfer
method for withdrawals and the balanceOf
method for the UI to display the user's balance.
See the example ETX contract for a Serpent implementation, or a Standard Token in Solidity.
After registering the subcurrency using the add_market
ABI call, the subcurrency will receive a market_id
. You can retrieve the market ID with a call to get_market_id(contract_address)
.
IMPORTANT: The original deposit
technique has been deprecated in favor of the Standardized Contract APIs
To support deposits to EtherEx, your subcurrency needs to implement the approve
and transferFrom
methods. The former allows a one-time transfer from the user's address by the exchange's contract, while the latter is called from the contract to effectively make that transfer when the user calls the exchange's new deposit
method. This allows to securely send a subcurrency's tokens to the exchange's contract while updating the user's available balance at the exchange.
If your subcurrency's default method for transferring funds is also named transfer
like the standard examples above, with the _to
and _value
parameters (in that order), then there is nothing else you need to do to support withdrawals from EtherEx to a user's address. Otherwise, you'll need to implement that same transfer
method with those two parameters, and "translate" that method call to yours, calling your other method with those parameters, in the order they're expected. You may also have to use tx.origin
instead of msg.sender
in your method as the latter will return your contract's address.
def transfer(_to, _value):
return(self.invertedtransfer(_value, _to))
Subcurrency contracts also need to implement a balanceOf
method for the UI to display the user's balance in that contract (also called the subcurrency's wallet).
def balanceOf(_addr):
return(self.balances[_addr].balance)
- Your Ethereum address is used as your identity
- Document error codes of return values
- Implement Wallet section (transactions, balances, etc.) (in progress)
- Re-implement NameReg support and integration
- Start the Tools section, find and list ideas
- subcurrency registration (in progress)
- subcurrency creation tools/wizard
- raw transact (?)
- trading tools (...)
- ...
- Use NatSpec
- Look into how Whisper and Swarm could be used and integrated
- Start working on X-Chain
- Update this TODO more frequently
- Start using GitHub issues instead
- Better, rock solid tests, and way more of them
- Total unilateral world takeover
-
Graphs, beautiful graphs
-
Advanced trading features (stoploss, etc.)
-
Animations/transitions
-
Check/clear buttons
-
Wallet design and theming
-
More/new mockups / wireframes
-
More/new design elements
-
Implement new mockups / design elements
-
IF Anyone Wishes to support the development of this project and others, and incourge more open source projects - you can do so by donating via this link http://bit.ly/2JKZ8xd
Released under the Apache License, see LICENSE file.