Coin Exchange

From ArdorDocs
Jump to: navigation, search
Other languages:

Cancel Coin Exchange

Cancel an existing coin exchange order. POST only.

Request: Refer to Create Transaction Request for common parameters.

  • requestType is cancelCoinExchange
  • chain the chain that will be used for the operation
  • order is the order ID or entity of the order being canceled

Response: Refer to Create Transaction Response.

Cancel Coin Exchange Example

http://localhost:27876/nxt?
  requestType=cancelCoinExchange&
  chain=1&
  secretPhrase=IWontTellYou&
  order=13300305836954486035&
  feeNQT=-1&
  deadline=60
{
    "minimumFeeFQT": "50000000",
    "signatureHash": "74fa50d20fbb6b0ab2ba69f73debba46fcd2893ad8a7d53e7fa31dbb2e3735c5",
    "transactionJSON": {
        "senderPublicKey": "df21142bd38c04bd5c5c342c6ca36802f9de89b75b2a0a8cbd32d29dca481e5c",
        "chain": 1,
        "signature": "3bd5113715c89dd3694fad21f723df540149f93b7b7e21de07f837123fcd1d0c977d205a086ae1158ca8557ae11b3b1950ce330f5565fac609843b3b2373f440",
        "feeNQT": "50000000",
        "type": -4,
        "fullHash": "8c7efba47df565cb02feb9f9fb0ef6cba0a0d8dba90436e50a55a2a024709d77",
        "version": 1,
        "phased": false,
        "ecBlockId": "12397878866807509033",
        "signatureHash": "74fa50d20fbb6b0ab2ba69f73debba46fcd2893ad8a7d53e7fa31dbb2e3735c5",
        "attachment": {
            "version.FxtCoinExchangeOrderCancel": 1,
            "orderHash": "1305bacfb02d94b81d5f3e22bfe5aaf3af44a7f08d8097ae7833b1a9043d79df"
        },
        "senderRS": "ARDOR-X8ZN-WUJ2-SXY3-FBUYC",
        "subtype": 1,
        "amountNQT": "0",
        "sender": "15382970207090678772",
        "ecBlockHeight": 392917,
        "deadline": 15,
        "transaction": "14656390482334809740",
        "timestamp": 23359885,
        "height": 2147483647
    },
    "unsignedTransactionBytes": "01000000fc01018d7164010f00df21142bd38c04bd5c5c342c6ca36802f9de89b75b2a0a8cbd32d29dca481e5c0000000000000000000000000000000080f0fa020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000d5fe050029506280241d0eac00000000011305bacfb02d94b81d5f3e22bfe5aaf3af44a7f08d8097ae7833b1a9043d79df",
    "broadcasted": true,
    "requestProcessingTime": 4,
    "transactionBytes": "01000000fc01018d7164010f00df21142bd38c04bd5c5c342c6ca36802f9de89b75b2a0a8cbd32d29dca481e5c0000000000000000000000000000000080f0fa02000000003bd5113715c89dd3694fad21f723df540149f93b7b7e21de07f837123fcd1d0c977d205a086ae1158ca8557ae11b3b1950ce330f5565fac609843b3b2373f440d5fe050029506280241d0eac00000000011305bacfb02d94b81d5f3e22bfe5aaf3af44a7f08d8097ae7833b1a9043d79df",
    "fullHash": "8c7efba47df565cb02feb9f9fb0ef6cba0a0d8dba90436e50a55a2a024709d77"
}


Exchange Coins

Place an asset order. POST only.

Request: Refer to Create Transaction Request for common parameters.

  • requestType is exchangeCoins
  • chain the chain related to the operation
  • exchange is the chain to exchange coins
  • quantityQNT is the amount (in QNT) of the coin being ordered
  • priceNQTPerCoin is the bid/ask price per coin (in NQT)

Response: Refer to Create Transaction Response. The transaction ID is also the order ID.

Exchange Coins Example

http://localhost:27876/nxt?
  requestType=exchangeCoins&
  secretPhrase=IWontTellYou&
  chain=1&
  exchange=2&
  quantityQNT=100000000&
  priceNQTPerCoin=100000000&
  feeNQT=-1&
  feeRateNQTPerFXT=-1
{  
   "minimumFeeFQT":"50000000",
   "transactionJSON":{  
      "senderPublicKey":"df21142bd38c04bd5c5c342c6ca36802f9de89b75b2a0a8cbd32d29dca481e5c",
      "chain":1,
      "feeNQT":"50000000",
      "type":-4,
      "version":1,
      "phased":false,
      "ecBlockId":"2329106975025976796",
      "attachment":{  
         "quantityQNT":"100000000",
         "version.FxtCoinExchangeOrderIssue":1,
         "chain":1,
         "priceNQTPerCoin":"100000000",
         "exchangeChain":2
      },
      "senderRS":"ARDOR-X8ZN-WUJ2-SXY3-FBUYC",
      "subtype":0,
      "amountNQT":"0",
      "sender":"15382970207090678772",
      "ecBlockHeight":230000,
      "deadline":15,
      "timestamp":23360280,
      "height":2147483647
   },
   "unsignedTransactionBytes":"01000000fc0001187364010f00df21142bd38c04bd5c5c342c6ca36802f9de89b75b2a0a8cbd32d29dca481e5c0000000000000000000000000000000080f0fa02000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000070820300dcd54e2274a652200000000001010000000200000000e1f5050000000000e1f50500000000",
   "broadcasted":true,
   "requestProcessingTime":1
}


Get Coin Exchange Order

Get a bid/ask coin exchange order given an order ID.

Request:

  • requestType is getCoinExchangeOrder
  • order is the Order ID
  • requireBlock is the block ID of a block that must be present in the blockchain during execution (optional)
  • requireLastBlock is the block ID of a block that must be last in the blockchain during execution (optional)

Response:

  • askNQTPerCoin (N) is the order price (in NQT) per coin to be exchanged
  • exchangeQNT (S) is the exchange quantity (in QNT)
  • quantityQNT (S) is the order quantity (in QNT)
  • chain (N) is the chain related to coin exchange operation
  • bidNQTPerCoin (S) is the bid ask (in NQT) per coin
  • orderFullHash (S) is the order full hash
  • accountRS (S) is the Reed-Solomon address of the account
  • exchange (S) is the chain to exchange
  • account (S) is the account number associated with the order
  • order (S) is the ID of the order

Get Coin Exchange Order

http://localhost:27876/nxt?
  requestType=getCoinExchangeOrder&
  order=12902733594079401676
{
    "askNQTPerCoin": "100000000",
    "exchangeQNT": "100000000",
    "quantityQNT": "100000000",
    "chain": 1,
    "bidNQTPerCoin": "100000000",
    "orderFullHash": "cc169a9ad7b70fb3ef89f284bf61a2ef0e3c2dc03737fc04e08a6171bd2b6240",
    "accountRS": "ARDOR-X8ZN-WUJ2-SXY3-FBUYC",
    "exchange": 2,
    "requestProcessingTime": 1,
    "account": "15382970207090678772",
    "order": "12902733594079401676"
}


Get Coin Exchange Order Ids

Get a bid/ask coin exchange order Ids given an exchange, in order of decreasing bid price or increasing ask price.

Request:

  • requestType is getCoinExchangeOrder
  • chain is the chain related to coin exchange operation
  • exchange is the chain to exchange coins
  • account is an account ID (optional), Mandatory if chain an exchange are not set
  • firstIndex is a zero-based index to the first order ID to retrieve (optional)
  • lastIndex is a zero-based index to the last order ID to retrieve (optional)
  • adminPassword is a string with the admin password (optional)
  • requireBlock is the block ID of a block that must be present in the blockchain during execution (optional)
  • requireLastBlock is the block ID of a block that must be last in the blockchain during execution (optional)

Response:

  • orderIds (A) is an array containing all orderIds
  • requestProcessingTime (N) is the API request processing time (in millisec)

Get Coin Exchange Order Ids Example

http://localhost:27876/nxt?
  requestType=getCoinExchangeOrderIds&
  chain=1&
  exchange=2
{
    "orderIds": [
        "11389333452894623327",
        "10388276168745405207",
        "5121927806759675242",
        "15079689952294500482",
        "1378482742321196609"
    ],
    "requestProcessingTime": 0
}


Get Coin Exchange Orders

Get bid/ask order IDs given an account or a chain/exchange pair.

Request:

  • requestType is getCoinExchangeOrders
  • chain is the chain related to coin exchange operation
  • exchange is the chain to exchange coins
  • account is an account ID (optional), Mandatory if chain an exchange are not set
  • firstIndex is a zero-based index to the first order ID to retrieve (optional)
  • showExpectedCancellations: is whether to show or not the expected cancellations (optional)
  • lastIndex is a zero-based index to the last order ID to retrieve (optional)
  • adminPassword is a string with the admin password (optional)
  • requireBlock is the block ID of a block that must be present in the blockchain during execution (optional)
  • requireLastBlock is the block ID of a block that must be last in the blockchain during execution (optional)

Response:

  • orders (A) is an array containing all orderIds
    • askNQTPerCoin (N) is the order price (in NQT) per coin to be exchanged
    • exchangeQNT (S) is the exchange quantity (in QNT)
    • quantityQNT (S) is the order quantity (in QNT)
    • chain (N) is the chain related to coin exchange operation
    • bidNQTPerCoin (S) is the bid ask (in NQT) per coin
    • orderFullHash (S) is the order full hash
    • accountRS (S) is the Reed-Solomon address of the account
    • exchange (S) is the chain to exchange
    • account (S) is the account number associated with the order
    • order (S) is the ID of the order
  • requestProcessingTime (N) is the API request processing time (in millisec)

Get Coin Exchange Orders Example

http://localhost:27876/nxt?
  requestType=getCoinExchangeOrders&
  chain=2&
  exchange=1
{
    "orders": [
        {
            "askNQTPerCoin": "5000000000000000",
            "exchangeQNT": "99983160",
            "quantityQNT": "4999158000000000",
            "chain": 2,
            "bidNQTPerCoin": "2",
            "orderFullHash": "5fd641a06e0a0f9eda9dda0319e6edc9c3539bc4187e0b460dbf9bdcef8ccf51",
            "accountRS": "ARDOR-RLF8-475F-LRFS-E2XBS",
            "exchange": 1,
            "account": "14710902703892711846",
            "order": "11389333452894623327"
        },
        {
            "askNQTPerCoin": "10000000000000000",
            "exchangeQNT": "2",
            "quantityQNT": "250000000",
            "chain": 2,
            "bidNQTPerCoin": "1",
            "orderFullHash": "41ae0f29c05a21137798ced4f3569b4ab57367121bc7f8451713301e042183c8",
            "accountRS": "ARDOR-XK4R-7VJU-6EQG-7R335",
            "exchange": 1,
            "account": "5873880488492319831",
            "order": "1378482742321196609"
        },
        {
            "askNQTPerCoin": "10000000000000000",
            "exchangeQNT": "123435297",
            "quantityQNT": "12343529700000000",
            "chain": 2,
            "bidNQTPerCoin": "1",
            "orderFullHash": "17cbb9d222922a906752278fb567db4f58e53e2c50923c8cb262d860dfdb0555",
            "accountRS": "ARDOR-Q2UC-AWMQ-SZW4-3YM8C",
            "exchange": 1,
            "account": "1520666668260066122",
            "order": "10388276168745405207"
        },
        {
            "askNQTPerCoin": "10000000000000000",
            "exchangeQNT": "123456789",
            "quantityQNT": "12345678900000000",
            "chain": 2,
            "bidNQTPerCoin": "1",
            "orderFullHash": "82788ab11dd245d10df179a34955d13605229c243e9c00da5e291cd207b1e50f",
            "accountRS": "ARDOR-Q2UC-AWMQ-SZW4-3YM8C",
            "exchange": 1,
            "account": "1520666668260066122",
            "order": "15079689952294500482"
        },
        {
            "askNQTPerCoin": "10000000000000000",
            "exchangeQNT": "999999999",
            "quantityQNT": "99999999900000000",
            "chain": 2,
            "bidNQTPerCoin": "1",
            "orderFullHash": "6a251bff33be1447fcc336fdf4e66fb6204a768fff863b58d09c367b27de82b6",
            "accountRS": "ARDOR-Q2UC-AWMQ-SZW4-3YM8C",
            "exchange": 1,
            "account": "1520666668260066122",
            "order": "5121927806759675242"
        }
    ],
    "requestProcessingTime": 1
}


Get Coin Exchange Trade

Get an executed trade given the full hash of the bid/ask coin exchange.

Request:

  • requestType is getCoinExchangeTrade
  • orderFullHash is the full hash of the bid exchange order
  • matchFullHash is the full hash of the ask exchange order
  • requireLastBlock is the block ID of a block that must be last in the blockchain during execution (optional)

Response:

  • quantityQNT (S) is the order quantity (in QNT)
  • chain (N) is the chain related to coin exchange operation
  • requestProcessingTime (N) is the API request processing time (in millisec)
  • priceNQTPerCoin (N) is the order price (in NQT) per coin exchanged
  • orderFullHash (S) is the order full hash
  • exchangeRate (S) is the exchange rate
  • accountRS (S) is the Reed-Solomon address of the account
  • exchange (S) is the chain coin to exchange
  • block (S) is the block id
  • matchFullHash is the full hash of the ask exchange order
  • account (S) is the account number associated with the order
  • height (N) is the block height of the order match transaction
  • timestamp is the timestamp (in seconds since the genesis block)

Get Coin Exchange Trade Example

http://localhost:27876/nxt?
  requestType=getCoinExchangeTrade&
  orderFullHash=514eea666beadb1b04ab7d32658c5701851aca7195612e968128d7e01617abdf&
  matchFullHash=962076f848d67c13825b33b0a569f8f8b18e12f49da7f95553f0442e66dd5f91
{
    "quantityQNT": "100000000",
    "chain": 2,
    "requestProcessingTime": 0,
    "priceNQTPerCoin": "100000",
    "orderFullHash": "514eea666beadb1b04ab7d32658c5701851aca7195612e968128d7e01617abdf",
    "exchangeRate": "0.00100000",
    "accountRS": "ARDOR-XK4R-7VJU-6EQG-7R335",
    "exchange": 1,
    "block": "18261861240184495732",
    "matchFullHash": "962076f848d67c13825b33b0a569f8f8b18e12f49da7f95553f0442e66dd5f91",
    "account": "5873880488492319831",
    "height": 384444,
    "timestamp": 22817693
}


Get Coin Exchange Trades

Get all coin exchange trades already executed given an account, a chain/exchange or an order full hash.

Request:

  • requestType is getCoinExchangeTrades
  • chain is the chain related to coin exchange operation
  • exchange is the chain to exchange coins
  • account is an account ID (optional), Mandatory if chain an exchange are not set
  • firstIndex is a zero-based index to the first order ID to retrieve (optional)
  • orderFullHash: if chain/exchange is not set, the order full hash can determines it (optional)
  • lastIndex is a zero-based index to the last order ID to retrieve (optional)
  • adminPassword is a string with the admin password (optional)
  • requireBlock is the block ID of a block that must be present in the blockchain during execution (optional)
  • requireLastBlock is the block ID of a block that must be last in the blockchain during execution (optional)

Response:

  • trade (A) is an array containing all the trades
    • quantityQNT (S) is the order quantity (in QNT)
    • chain (N) is the chain related to coin exchange operation
    • orderFullHash (S) is the order full hash
    • exchange (S) is the chain traded
    • block (S) is the block id of the trade
    • matchFullHash is the full hash of the ask exchange order
    • priceNQTPerCoin (S) is the price of the trade (in NQT) per coin
    • account (S) is the account number associated with the order
    • timestamp is the timestamp (in seconds since the genesis block)
    • height is the height of the blockchain to determine the account count (optional, default is last block)

Get Coin Exchange Trades Example

http://localhost:27876/nxt?
  requestType=getCoinExchangeTrades&
  chain=1&
  exchange=2
{
    "trades": [
        {
            "quantityQNT": "500000000",
            "chain": 2,
            "orderFullHash": "5fd641a06e0a0f9eda9dda0319e6edc9c3539bc4187e0b460dbf9bdcef8ccf51",
            "exchangeRate": "0.00000002",
            "accountRS": "ARDOR-RLF8-475F-LRFS-E2XBS",
            "exchange": 1,
            "block": "6225310266086012511",
            "matchFullHash": "01a940447c4e5700b4eaad265f8c8dc5b0f72dbcbf1426ed330881f5e755ce31",
            "priceNQTPerCoin": "2",
            "account": "14710902703892711846",
            "height": 384435,
            "timestamp": 22817002
        },
        {
            "quantityQNT": "50000000000",
            "chain": 2,
            "orderFullHash": "5fd641a06e0a0f9eda9dda0319e6edc9c3539bc4187e0b460dbf9bdcef8ccf51",
            "exchangeRate": "0.00000002",
            "accountRS": "ARDOR-RLF8-475F-LRFS-E2XBS",
            "exchange": 1,
            "block": "6544764621382228458",
            "matchFullHash": "1247555e021482c05bb9b1f7b39e17a13e752e48be0e8fc496cee05ac59f8c4d",
            "priceNQTPerCoin": "2",
            "account": "14710902703892711846",
            "height": 212578,
            "timestamp": 12591953
        },
        {
            "quantityQNT": "5000000000",
            "chain": 2,
            "orderFullHash": "5fd641a06e0a0f9eda9dda0319e6edc9c3539bc4187e0b460dbf9bdcef8ccf51",
            "exchangeRate": "0.00000002",
            "accountRS": "ARDOR-RLF8-475F-LRFS-E2XBS",
            "exchange": 1,
            "block": "15534100015442644652",
            "matchFullHash": "b21984231ab9c5848991753305315df0df90d5d46c95a7071b5f448b7e0e9ec8",
            "priceNQTPerCoin": "2",
            "account": "14710902703892711846",
            "height": 212574,
            "timestamp": 12591554
        },
        {
            "quantityQNT": "112250000000",
            "chain": 2,
            "orderFullHash": "5fd641a06e0a0f9eda9dda0319e6edc9c3539bc4187e0b460dbf9bdcef8ccf51",
            "exchangeRate": "0.00000002",
            "accountRS": "ARDOR-RLF8-475F-LRFS-E2XBS",
            "exchange": 1,
            "block": "1120029333253034383",
            "matchFullHash": "ed67d0823a77cc32eeb65048f3237fa38c5461581b7efafb6ab766bf372f4357",
            "priceNQTPerCoin": "2",
            "account": "14710902703892711846",
            "height": 129920,
            "timestamp": 7689219
        },
        {
            "quantityQNT": "224500000000",
            "chain": 2,
            "orderFullHash": "5fd641a06e0a0f9eda9dda0319e6edc9c3539bc4187e0b460dbf9bdcef8ccf51",
            "exchangeRate": "0.00000002",
            "accountRS": "ARDOR-RLF8-475F-LRFS-E2XBS",
            "exchange": 1,
            "block": "18332751000499777406",
            "matchFullHash": "7bcc31ec1e7bde0090bf34b32f6a78b4ccd183302eb748f0b4e2146a6342b3b9",
            "priceNQTPerCoin": "2",
            "account": "14710902703892711846",
            "height": 129913,
            "timestamp": 7688812
        },
        {
            "quantityQNT": "449250000000",
            "chain": 2,
            "orderFullHash": "5fd641a06e0a0f9eda9dda0319e6edc9c3539bc4187e0b460dbf9bdcef8ccf51",
            "exchangeRate": "0.00000002",
            "accountRS": "ARDOR-RLF8-475F-LRFS-E2XBS",
            "exchange": 1,
            "block": "15085435575516264052",
            "matchFullHash": "a0293a1f9888f040abeefcf1b3688be4729325cdc850c22ceaded8851cbdf0cb",
            "priceNQTPerCoin": "2",
            "account": "14710902703892711846",
            "height": 129909,
            "timestamp": 7688590
        },
        {
            "quantityQNT": "500000000",
            "chain": 2,
            "orderFullHash": "5fd641a06e0a0f9eda9dda0319e6edc9c3539bc4187e0b460dbf9bdcef8ccf51",
            "exchangeRate": "0.00000002",
            "accountRS": "ARDOR-RLF8-475F-LRFS-E2XBS",
            "exchange": 1,
            "block": "11215960407448332493",
            "matchFullHash": "8441d7d0297ff0fb15cd32dc71e98550cde462d763f4c7f3b720267f01b43e46",
            "priceNQTPerCoin": "2",
            "account": "14710902703892711846",
            "height": 106425,
            "timestamp": 6299678
        }
    ],
    "requestProcessingTime": 1
}


Get Expected Coin Exchange Order Cancellations

Get the expected coin exchange order cancellations for a specific chain. Since version 2.3.0e it returns both bundled and non-bundled transactions.

Request:

  • requestType is getExpectedCoinExchangeOrderCancellations
  • chain the chain related to the operation
  • requireBlock is the block ID of a block that must be present in the blockchain during execution (optional)
  • requireLastBlock is the block ID of a block that must be last in the blockchain during execution (optional)

Response:

Get Expected Coin Exchange Order Cancellations Example

http://localhost:27876/nxt?
  requestType=getExpectedCoinExchangeOrderCancellations&
  chain=2&
{
    "orderCancellations": [],
    "requestProcessingTime": 0
}


Get Expected Coin Exchange Orders

Get the expected coin exchange orders to be completed for a specific chain/exchange or an account. Since version 2.3.0e it returns both bundled and non-bundled transactions.

Request:

  • requestType is getExpectedCoinExchangeOrders
  • chain is the chain related to coin exchange operation
  • exchange is the chain to exchange coins
  • account is an account ID (optional), Mandatory if chain an exchange are not set

Response:

Get Expected Coin Exchange Orders Example

http://localhost:27876/nxt?
  requestType=getExpectedCoinExchangeOrders&
  chain=2&
  exchange=1
{
    "orders": [],
    "requestProcessingTime": 0
}


Simulate Coin Exchange

Simulate a coin exchange given a chain, exchange, quantity and a price per coin.

Request:

  • requestType is simulateCoinExchange
  • chain the chain related to the operation
  • exchange is the chain to exchange coins
  • quantityQNT is the amount (in QNT) of the coin being ordered
  • priceNQTPerCoin is the bid/ask price per coin (in NQT)
  • bidNQTPerCoin (S) is the bid ask (in NQT) per coin

Response:

  • askNQTPerCoin (N) is the order price (in NQT) per coin to be exchanged
  • quantityQNT (S) is the order quantity (in QNT)
  • requestProcessingTime (N) is the API request processing time (in millisec)

Simulate Coin Exchange Example

http://localhost:27876/nxt?
  requestType=simulateCoinExchange&
  chain=1&
  exchange=2&
  quantityQNT=1000000&
  priceNQTPerCoin=2000000
{
    "askNQTPerCoin": 5000000000,
    "quantityQNT": 1000000,
    "bidNQTPerCoin": 2000000,
    "requestProcessingTime": 1
}