• Stars
    star
    186
  • Rank 206,488 (Top 5 %)
  • Language
    Go
  • License
    Apache License 2.0
  • Created over 6 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

🌊 Ocean ONE is a decentralized exchange built on Mixin Network

Ocean ONE

Ocean ONE is a decentralized exchange built on Mixin Network, it's almost the first time that a decentralized exchange gain the same user experience as a centralized one.

Ocean ONE accepts all assets in Mixin Network as base currencies, and the only supported quote currencies are Mixin XIN (c94ac88f-4671-3976-b60a-09064f1811e8), Bitcoin BTC (c6d0c728-2624-429b-8e0d-d9d19b6592fa) and Omni USDT (815b0b1a-2764-3736-8faa-42d694fa620a).

All order and trade data are encoded in the Mixin snapshots' memo field, the memo is base64 encoded MessagePack.

Create Order

To sell 0.7 XIN with price 0.1 BTC/XIN, send a 0.7 XIN transfer to Ocean ONE with base64 encoded MessagePack data as the memo.

type OrderAction struct {
  S string    // side
  A uuid.UUID // asset
  P string    // price
  T string    // type
  O uuid.UUID // order
}

memo = base64.StdEncoding.EncodeToString(msgpack(OrderAction{
  T: "L",
  P: "0.1",
  S: "A",
  A: uuid.FromString("c6d0c728-2624-429b-8e0d-d9d19b6592fa"),
}))

To buy some XIN with price 0.1 BTC/XIN, send the desired amount of BTC transfer to Ocean ONE with base64 encoded MessagePack data as the memo.

memo = base64.StdEncoding.EncodeToString(msgpack(OrderAction{
  T: "L",
  P: "0.1",
  S: "B",
  A: uuid.FromString("c94ac88f-4671-3976-b60a-09064f1811e8"),
}))

It's recommended to set the trace_id field whenever you send a transfer to Ocean ONE, the trace_id will be used as the order id.

Cancel Order

Send any amount of any asset to Ocean ONE with base64 encoded MessagePack data as the memo.

memo = base64.StdEncoding.EncodeToString(msgpack(OrderAction{
  O: uuid.FromString("2497b2bb-4d67-49bf-b2bc-211b0543d7ac"),
}))

Bid Order Behavior

A bid order, despite a limit bid order or market bid order, will transfer some quote funds to the matching engine. Ocean ONE engine will match all the funds, this is a typical behavior for market order. However for a limit bid order, user may expect the order done whenever the desired bid size filled, in this situation, Ocean ONE engine still matches all the funds which may result in a larger order size filled.

Events

The order book and all matches are always available in the Mixin Network snapshots, and Ocean ONE offers a WebSocket layer to provide a convenient query interface.

The WebSocket endipoint is wss://events.ocean.one, and all messages sent and received should be gziped. The event message is in a standard format.

{
  "id": "a3fb2c7d-88ed-4605-977c-ebbb3f32ad71",
  "action": "EMIT_EVENT",
  "params": {},
  "data": {},
  "error": "description"
}

The params field is for the client sent message. The data or error is for the server message, and only one of them will be present in the message. If the message is the server response of a message from the client, the id and action fields will be identical to the sent one.

Whenever a client connects to the events server, it must send a SUBSCRIBE_BOOK message to the server, otherwise the client won't receive any events messages.

{
  "id": "a3fb2c7d-88ed-4605-977c-ebbb3f32ad71",
  "action": "SUBSCRIBE_BOOK",
  "params": {
    "market": "c94ac88f-4671-3976-b60a-09064f1811e8-c6d0c728-2624-429b-8e0d-d9d19b6592fa"
  }
}

This will subscibe the client to all the events of the specific market in the params. To unsubscribe, send a similar message but with the action UNSUBSCRIBE_BOOK. A client can always subscribe to many markets with many different SUBSCRIBE_BOOK messages.

BOOK-T0

This is the first event whenever a client subscribe to a specific market, the event contains the full order book of the market.

{
  "id": "a3fb2c7d-88ed-4605-977c-ebbb3f32ad71",
  "action": "EMIT_EVENT",
  "data": {
    "market": "c94ac88f-4671-3976-b60a-09064f1811e8-c6d0c728-2624-429b-8e0d-d9d19b6592fa",
    "sequence": 1531142594,
    "event": "BOOK-T0",
    "data": {
      "asks": [],
      "bids": []
    }
  }
}

ORDER-OPEN

The order is now open on the order book. This message will only be sent for orders which are not fully filled immediately. amount will indicate how much of the order is unfilled and going on the book.

ORDER-MATCH

A trade occurred between two orders. The taker order is the one executing immediately after being received and the maker order is a resting order on the book. The side field indicates the maker order side. If the side is ask this indicates the maker was a sell order and the match is considered an up-tick. A bid side match is a down-tick.

ORDER-CANCEL

The order is cancelled and no longer on the order book, amount indicates how much of the order went unfilled.

List Orders

List orders of the authenticated user. The authentication is ECDSA JWT based, and the user needs to register a ECDSA public key to Ocean ONE with base64 encoded MessagePack data as the memo.

memo = base64.StdEncoding.EncodeToString(msgpack(OrderAction{
  U: RAW BYTES OF THE ECDSA PUBLIC KEY,
}))

To authenticate, create the JWT payload with user id as uid and sign it with the ECDSA private key. Then pass the token as a HTTP Bearer Authorization header.

Make a HTTP GET request to https://events.ocean.one/orders to retrieve orders, and the available query params are market, state, limit and offset.

Market Data

The market data API is an unauthenticated set of endpoints for retrieving market data. These endpoints provide snapshots of market data.

Ticker

Snapshot information about the last trade (tick), best bid/ask.

GET https://events.ocean.one/markets/:id/ticker

{
  "trade_id": "bf1bf64b-9ba6-4961-9ca8-38ea8358b9f3"
  "amount": "0.001",
  "price": "0.2",
  "ask": "0.2",
  "bid": "0.1",
  "sequence": 1531305918,
  "timestamp": "2018-07-12T05:51:30.757002284Z",
}

Order Book

Get the full list of open orders for a market, the list is not udpated in real time, for the most up-to-date data, consider using the websocket stream.

GET https://events.ocean.one/markets/:id/book

{
  "market": "c94ac88f-4671-3976-b60a-09064f1811e8-c6d0c728-2624-429b-8e0d-d9d19b6592fa",
  "event": "BOOK-T0",
  "sequence": 1531305926,
  "data": {
    "asks": [
      {
        "amount": "0.999",
        "funds": "0.1998",
        "price": "0.2",
        "side": "ASK"
      }
    ],
    "bids": [
      {
        "amount": "0.52",
        "funds": "0.052",
        "price": "0.1",
        "side": "BID"
      }
    ]
  },
  "timestamp": "2018-07-12T05:55:44.757025182Z"
}

Trades

List the trades history for a market. Available query params are market, state, limit and offset.

GET https://events.ocean.one/markets/:id/trades

[
  {
    "amount": "0.001",
    "base": "c94ac88f-4671-3976-b60a-09064f1811e8",
    "created_at": "2018-07-11T08:02:44.094160294Z",
    "price": "0.2",
    "quote": "c6d0c728-2624-429b-8e0d-d9d19b6592fa",
    "side": "ASK",
    "trade_id": "bf1bf64b-9ba6-4961-9ca8-38ea8358b9f3"
  }
]

Fee

  • Taker: 0.1%
  • Maker: 0.0%

References

Join the Team

Please contact Mixin 25566

More Repositories

1

mixin

🚀 The Mixin TEE-BFT-DAG network reference implementation.
Go
508
star
2

ios-app

📱iOS private messenger, crypto wallet and light node to Mixin Network
Swift
497
star
3

android-app

📱 Android private messenger, crypto wallet and light node to Mixin Network
Kotlin
456
star
4

flutter-plugins

🧱 Flutter plugins used in Mixin Messenger.
C
436
star
5

kraken

🐙 High performance WebRTC SFU implemented with pure Go.
Go
330
star
6

flutter-app

💻 Mixin Messenger desktop app for macOS, iPadOS, Linux, and Windows powered by Flutter/Dart.
Dart
281
star
7

libsignal_protocol_dart

Signal Protocol library for Dart/Flutter
Dart
157
star
8

developers.mixin.one

📒 The Mixin Developers dashboard and docs.
JavaScript
128
star
9

desktop-app

[DEPRECATED]💻 Mixin Messenger desktop app for Windows, macOS, and Linux powered by Electron.
JavaScript
88
star
10

bot-api-go-client

🤖️ Mixin API for Go
Go
71
star
11

tip

🔑 A decentralized key derivation protocol for simple passphrase.
Go
51
star
12

mixin.one

ℹ️ The website of Mixin core team and Mixin Network explorer
TypeScript
49
star
13

kraken.fm

Kraken is an instant and anonymous audio conferencing service
JavaScript
42
star
14

supergroup.mixin.one

🐚 Mixin Super Group Source Code
Go
32
star
15

mixin-wallet

👛 An open-source cryptocurrency wallet bot based on Mixin API, which supports almost all popular cryptocurrencies.
Dart
30
star
16

trusted-group

🪐 Mixin Trusted Group makes decentralized applications on Mixin Messenger and Kernel.
Go
28
star
17

logs

updates and announcements
Shell
25
star
18

donate.cafe

☕️ Accept bitcoin donations now
Vue
19
star
19

multisig-bot

A client only bot to demonstrate the multisig feature of Mixin Messenger.
Go
18
star
20

nfo

🏆 A decentralized layer to support NFT on Mixin Messenger and Kernel.
Go
17
star
21

asset-profile

asset icon and price in Mixin Messenger
16
star
22

bot-api-nodejs-client

Mixin API for JavaScript & Node.js
TypeScript
14
star
23

bot-api-js-client

Mixin bot API for Javascript
JavaScript
13
star
24

safe

🏦 A multiplex cold wallet with multisig and MPC.
Go
12
star
25

bot-manager

Vue
11
star
26

supergroup-bot

Go
9
star
27

mixin_bot_sdk_dart

Dart/Flutter SDK for Mixin
Dart
6
star
28

mobilecoin-go

MobileCoin utilities in Golang
Go
5
star
29

audits

🚨 Security audits for all the repositories.
5
star
30

mvm-contracts

Solidity
4
star
31

mixin.network

The website to showcase the ecosystem of Mixin Network
4
star
32

mvm.app

The website of Mixin Virtual Machine.
TypeScript
4
star
33

flutter_pasteboard

Dart
4
star
34

bot-api-kotlin-client

Mixin bot SDK for Java/Kotlin
Kotlin
4
star
35

near-sdk-go

Go
4
star
36

developer-competition

3
star
37

mixswap_sdk_dart

MixSwap Dart SDK
Dart
3
star
38

safe-go-sdk

Go
2
star
39

mips

Messenger Improvement Proposals
2
star
40

tink-eddsa

Kotlin
2
star
41

governance

Go
2
star
42

mixin-testnet-setup

Mixin Testnet Faucet
2
star
43

bridge.mvm.app

TypeScript
2
star
44

mvm.dev

MVM (Mixin Virtual Machine) document
JavaScript
2
star
45

mixin-rust-sdk

🦀️
Rust
2
star
46

githook-bot

A Mixin Messenger bot for GitHub Webhooks
JavaScript
2
star
47

bot-api-swift-client

Swift
1
star
48

go-number

A golang number library
Go
1
star
49

monero-core

C++
1
star
50

shop

JavaScript
1
star
51

handsaw

A tool for generating i18n strings for multiple platforms.
Kotlin
1
star