How to build your own exchange based on OceanONE Powered by Mixin Network

Mixin Evangelist
Mixin Network
Published in
4 min readNov 21, 2018

Introduction

OceanONE is a decentralized crypto asset exchange which provides user experience comparable to that of centralized exchanges

  • Security: exchange codes are open-sourced, asset automatically gets returned to the wallet after transaction
  • Transparent: all transactions are recorded on the blockchain, all checkable and traceable
  • Lightning speed: real-time pending orders, buy orders and cancel orders, instant transfer when recharge account within Mixin Network
  • Depth: shared depth and liquidity
  • Full-currency: Support all cryptocurrencies available on Mixin Network (13 main public chains and over 50000 cryptocurrencies) trading pairs with Mixin(XIN), Bitcoin(BTC) and Omni(USDT)
  • Low fees: 0 fees for maker orders, 0.1% handling fee for taker orders, waiver of transfer fees for pending orders, buy orders and cancel orders
  • Expansion: it is easy to open one’s own exchange based on OceanONE’s API

Access

Register to be a Mixin’s Developer

1.Download Mixin Messenger, scan the code to login

https://developers.mixin.one (click right top corner)

2. Create a Mixin App for your exchange

Click “Create New App” key and follow instructions. All users created on this App would belong to you. Subsequently, you can monitor the recharge, withdrawal and transfer information of users you created and you can get refund of the withdrawal fees and transaction handling fees. Choose “ Click to generate a new secret” to form a Client Secret,choose “Click to generate a new session” to form a Client Session. You should record down these two pieces of information for usage later (please note that if you click again, new information would be created)

3. Integrated wallet

Register as Mixin Network user

Register as a Mixin Network user to use functions such as transfer, withdrawal and transaction. Refer to documents https://developers.mixin.one/api#app_apicreate_user and https://developers.mixin.one/api#documentationauthentication_token you will need Client Secret and Client Session information mentioned in step 2

Set PIN code

If the project is capable of storing PIN securely for users, then it can implement a centralized wallet based on product requirements (Ocean.ONE uses this solution, PIN is not required for each transaction, the user experience is better); another solution would be to not store user’s PIN but save the PIN locally on client’s end like what Mixin Messenger does.

Refer to document https://developers.mixin.one/api#apicreate_pin for setting up network user’s PIN.

Check Order

4. Transaction

  • Limit: matching engine has a limit for pending order price and units. For example, for USDT limit orders, the minumum price is 0.0001 UST, the maximum order unit is 500,000. Orders which exceed limits are considered as malicious orders, matching engine will charge handling fee on such orders and reject the orders accordingly. Please refer to validateOrder method from example js code at https://github.com/MixinNetwork/ocean.one/blob/master/example/web/src/market/index.js
  • Order rejection: as OceanONE’s order pending, order fulfillment and order rejection are all done through transfer, order rejection would require a transfer. OceanONE’s solution is to issue one trillion OOO (Ocean ONE Object) erc-20 tokens. Each new user is given 1000 OOO tokens which cannot be recharged or withdrawn, every order rejection would cost 0.00000001 OOO. You can also use other tokens such as CNB/CANDY to initiate a order rejection transfer, there is no such limit for the matching engine.

5. Statistics

Note that the matching engine is not responsible for data statistics. Tickets and Candles require front-end calculation based on trades. Data related to the 13 trading pairs displayed by Ocean.ONE can be fetched directly from example.ocean.one Other trading pairs require the development team to refer to codes in example and calculate by themselves

6. Front-end Interface

You can use codes from example directly or develop your own interface, bind Network users by registering with mobile phone number and email.

In order to handle large number of new user registration in a short period of time, Ocean.ONE registered a number of Network and Ocean accounts in advance and assigned one associated account to each newly registered user accordingly. Refer to GeneratePoolKey method in pool_key.go.

Example

FAQ

  • Why OceanONE does not display other trading pairs?

API supports all trading pairs but the website only lists some of them

  • How to obtain asset id ?

https://developers.mixin.one/api#apiread_assets can return your asset list, if it doesn’t shown your asset, you can charge the account a little and see it here

  • How is new token traded at OceanONE?

OceanONE do not list tokens or charge any fees for listing tokens. You can directly charge the tokens to Mixin Network and start trading them. For example, you can charge Mixin Messenger wallet and trade through Mixcoin, or other front-end transactions based on OceanONE matching engine, you can also use existing open-sourced code to develop the front-end trading interface yourself.

  • Transfer is slow

For security measures, Mixin Network’s confirmation number is more than twice of usual wallets or exchanges. When you wait patiently, you can also check the block sync height and status at Mixin Blockchain browser https://mixin.one/snapshots

The independent matching engine and wallet ensures secure asset isolation. The entire process of oder pending, order fulfillment and order rejection are recorded on blockchain through transfers. Open-sourced matching engine ensures secure, fair and convenient asset transactions for users. Come join OceanONE and earn handling fees!

--

--