Matching Offers

For the use cases of issuing limit orders or market orders, an API is provided to obtain the offers that will fill the desired amount to matched. These offers ultimately exist in contract storage on the blockchain; however, in order that clients do not have to run full nodes to be able to index the offer information themselves a rest API is provided to aid in matching. The rest API has a decentralized architecture that can support multiple matching servers.

Obtaining matching offers via (Aphelion REST API)

Matching offers can be obtained by issuing an http GET:

https://mainnet.aphelion-neo.com/api/book/match/NEO-APH?side=buy&quantity=2000.1

URL Encoded Parameters

  • side (required) - buy or sell
    • The name of this parameter may be misleading and would be better named as operation rather than side, because it actually refers to the operation desired to be performed to match the offers.
    • Example to obtain matching offers to buy APH, set side=buy.
  • quantity (required) - quantity to match
  • limit (optional) - limit price
    • Only offers that meet the given limit price will be returned form the call.

Example Response

{
  "quantityToTake": 50000,
  "minTakerFees": 0,
  "maxTakerFees": 0,
  "offersToTake": [
    {
      "offerId": "0xaac43a348d236e32a1b35171fb3d6101e9af71049219e21e31b0ddb19c945273",
      "quantity": 44827.5,
      "price": 0.001399,
      "fee": 0,
      "isBackupOffer": false
    },
    {
      "offerId": "0x3723c1cc26760a2d68ce3391f41802ef7916c802572cea9e78a6400292a3d135",
      "quantity": 331.1,
      "price": 0.001399,
      "fee": 0,
      "isBackupOffer": false
    },
    {
      "offerId": "0x5e4b3e260458af5ebb7d6f9d2d61ed3cffcf2230f1dfc7b3acb94669306cfdf2",
      "quantity": 3510,
      "price": 0.001399,
      "fee": 0,
      "isBackupOffer": false
    },
    {
      "offerId": "0x20d608c26d55aecd890410b31fcc342547efc9d697fb7eea93f6863fc33a5187",
      "quantity": 1331.4,
      "price": 0.0013996,
      "fee": 0,
      "isBackupOffer": false
    }
  ],
  "offerSequenceNumber": 2139,
  "timestamp": 1552000359,
  "result": false
}

The offers returned in the response can be accepted by creating an invocation transaction on the blockchain for each offer to be accepted. The details for accepting the offers are found in the next section on Accepting Offers.