Node commands for work with exchange ORDERS: There is corresponding service provided by the node - Decentralized Exchange Service (DEX) Some of user scenarios - 2. DEX User Scenarios

Node Command - SRV_XCHANGE ORDER CREATE

Creates a new order with specified amount of Datoshi to exchange with specified rate (buy / sell)

CLI Example

Command syntax:

srv_xchange order create 
-net <net_name> 
-token_sell <token_ticker> 
-token_buy <token_ticker> 
-w <wallet_name> 
-value <value> 
-rate <value> 
-fee <value>

Options:

-net - name of the Cellframe Network. The list of networks can be found in the <Config_dir> \ etc \ network folder or received by The Cellframe-Node-CLI using command - net list
-token_sell - kind of token being sold
-token_buy - kind of token being bought
-w - name of the wallet
-value - amount of datoshi user wants to exchange
-rate - exchange rate (buy/sell)
-fee - comission in datoshi
 

Example:

Command:

cellframe-node-cli srv_xchange order create 
-net riemann 
-token_sell tKEL 
-token_buy mtKEL 
-w testwallet 
-value 2.0e+18 
-rate 1.0 
-fee 0.1e+18

Response:

Successfully created order 0x72FBB3ED3708074B229D7D8D46404E26347AEEFB3EC2F3B56A0CD4BE4AD1BBFB

JSON-RPC Example

Command:

curl -X POST http://rpc.cellframe.net/connect -d '{"method":"srv_xchange", "params":["srv_xchange;order;create;-net;riemann;-token_sell;tKEL;-token_buy;mtKEL;-w;testwallet;-value;2.0e+18;-rate;1.0;-fee;0.1e+18"], "id":"1"}'

Response:


"type": 0,
"result": "\nSuccessfully created order 0x7669D6ED5189F3E5E58F84B932CD18603B49048F0EBEC0ED02809C5C50AA6AF8",
"errors": null,
"id": 1
}
Link to original

Node Command - SRV_XCHANGE ORDER REMOVE

Invalidates (closes) opened or partially filled specified order in the specified network

CLI Example

Command syntax:

srv_xchange order remove 
-net <net_name> 
-order <order_hash> 
-w <wallet_name> 
-fee <value_datoshi>

Options:

-net - name of the Cellframe Network. The list of networks can be found in the <Config_dir> \ etc \ network folder or received by The Cellframe-Node-CLI using command - net list
-order - hash of the order
-w - name of the wallet
-fee - comission in datoshi

Example:

Command:

cellframe-node-cli srv_xchange order remove 
-net riemann 
-order 0x72FBB3ED3708074B229D7D8D46404E26347AEEFB3EC2F3B56A0CD4BE4AD1BBFB 
-w raidenwallet  
-fee 0.1e+18

Response:

Order successfully removed. Created inactivate tx with hash 0xDF15AA6D67EB0AF63BB246AA3D955B43D6E50543A2DA11D77A0AA32B088496E4

JSON-RPC Example

Command:

curl -X POST http://rpc.cellframe.net/connect -d '{"method":"srv_xchange", "params":["srv_xchange;order;remove;-net;riemann;-order;0x72FBB3ED3708074B229D7D8D46404E26347AEEFB3EC2F3B56A0CD4BE4AD1BBFB;-w;raidenwallet;-fee;0.1e+18"], "id":"1"}'

Response:


"type": 0,
"result": "Order successfully removed. Created inactivate tx with hash 0xA08783B1A3D3E74DBE536E82923D14D24D6B566ABBA467E94B6F5743EF4F2732",
"errors": null,
"id": 1
}
Link to original

Node Command - SRV_XCHANGE ORDER HISTORY

Shows transactions history for the selected order or wallet

CLI Example

Command syntax:

srv_xchange order history 
-net <net_name> 
{-order <order_hash> | -addr <wallet_addr>}

Options:

-net - name of the Cellframe Network. The list of networks can be found in the <Config_dir> \ etc \ network folder or received by The Cellframe-Node-CLI using command - net list
-order/-addr - hash of the order/ address of the wallet

Example:

Command:

cellframe-node-cli srv_xchange order history 
-net riemann 
-addr o9z3wUTSTicckJuozF3GcveoJK22eFmYXTZ4c8z7cwQ76VLMvgTXhBcULJ44E6X8paJiHbxvAyCZ2jbLhBj3tQuTdC769DZ6qMzEqizP

Response:

Wallet o9z3wUTSTicckJuozF3GcveoJK22eFmYXTZ4c8z7cwQ76VLMvgTXhBcULJ44E6X8paJiHbxvAyCZ2jbLhBj3tQuTdC769DZ6qMzEqizP hisrory:

Hash: 0xFBE8756C321C05B31A58A5AC271627363C81BEDBA3155B11AE9F3C40AA85E080

  Status: inactive,  proposed 1.0 (1000000000000000000) tKEL for exchange to mtKEL,  rate (mtKEL/tKEL): 1.0, net: riemann

Hash: 0xF7DC0EC97C712D83CDB876D92B2B63798E3217B094066B51D7A1479CD3BA988A

  Status: inactive,  proposed 2.0 (2000000000000000000) mtKEL for exchange to tKEL,  rate (tKEL/mtKEL): 2000.0, net: riemann

Hash: 0x27A5A7C8D01A68EBFA0D524D20BE01E58C183D5E750AF85658001A4AD4726C41

  Status: inactive,  changed 1.0 (1000000000000000000) mtKEL for 2000.0 (2000000000000000000000) tKEL,  rate (tKEL/mtKEL): 2000.0,  remain amount 1.0 (1000000000000000000) mtKEL, net: riemann

 ...
 
  Prev cond: 0xA66DEC0DF85EAFA9D7C1284DF1D5A5DA83195BB1EC734A6B9A0FF10DF7AC20BD

Hash: 0x8B4433B5D92CF80FD265843654D3650CF42FFFE0D5982354FEF249A137F21EBB

  Status: active,  proposed 1000.0 (1000000000000000000000) tKEL for exchange to mtKEL,  rate (mtKEL/tKEL): 1000.0, net: riemann

JSON-RPC Example

Command:

curl -X POST http://rpc.cellframe.net/connect -d '{"method":"srv_xchange", "params":["srv_xchange;order;history;-net;riemann;-addr;o9z3wUTSTicckJuozF3GcveoJK22eFmYXTZ4c8z7cwQ76VLMvgTXhBcULJ44E6X8paJiHbxvAyCZ2jbLhBj3tQuTdC769DZ6qMzEqizP"], "id":"1"}'

Response:


"type": 0,
"result": "same as cli response",
"errors": null,
"id": 1
}
Link to original

Node Command - SRV_XCHANGE ORDER STATUS

Shows current amount of unsold coins in the specified order and percentage of its completion

CLI Example

Command syntax:

srv_xchange order status 
-net <net_name> 
-order <order_hash>

Options:

-net - name of the Cellframe Network. The list of networks can be found in the <Config_dir> \ etc \ network folder or received by The Cellframe-Node-CLI using command - net list
-order - hash of the exchange order

Example:

Command:

cellframe-node-cli srv_xchange order status 
-net riemann 
-order 0x8B4433B5D92CF80FD265843654D3650CF42FFFE0D5982354FEF249A137F21EBB

Response:

orderHash: 0x8B4433B5D92CF80FD265843654D3650CF42FFFE0D5982354FEF249A137F21EBB

 ts_created: Fri Mar  8 13:37:30 2024 (1709905050)

 Status: OPENED, amount: 1000.0 (1000000000000000000000) tKEL, filled: 0.0%, rate (mtKEL/tKEL): 1000.0, net: riemann

JSON-RPC Example

Command:

curl -X POST http://rpc.cellframe.net/connect -d '{"method":"srv_xchange", "params":["srv_xchange;order;status;-net;riemann;-order;0x8B4433B5D92CF80FD265843654D3650CF42FFFE0D5982354FEF249A137F21EBB"], "id":"1"}'

Response:


"type": 0, "result": "orderHash: 0x8B4433B5D92CF80FD265843654D3650CF42FFFE0D5982354FEF249A137F21EBB\n ts_created: Fri Mar  8 13:37:30 2024 (1709905050)\n Status: OPENED, amount: 1000.0 (1000000000000000000000) tKEL, filled: 0.0%, rate (mtKEL\/tKEL): 1000.0, net: riemann\n\n",
"errors": null,
"id": 1
}
Link to original

Node Command - SRV_XCHANGE ORDERS

Lists exchange orders within specified network

CLI Example

Command syntax:

srv_xchange orders 
-net <net_name> 
[-status {opened|closed|all}] 
[-token_from <token_ticker>] 
[-token_to <token_ticker>]

Options:

-net - name of the Cellframe Network. The list of networks can be found in the <Config_dir> \ etc \ network folder or received by The Cellframe-Node-CLI using command - net list
-status - filtration by selected order status: opened/closed/all (optional)
-token_from - filtration by kind of token is being sold (optional)
-token_to - filtration by kind of token is being bought (optional)

Example:

Command:

cellframe-node-cli srv_xchange orders 
-net riemann 
-status opened

Response:

orderHash: 0x4AEF38DCE3C47953040E8FCB6C19ABD961AE6E0BB6AAE7AC6CDA5BC315E0E630
 ts_created: Fri Feb 16 16:45:44 2024 (1708130744)
 Status: OPENED, amount: 0.000000000000000001 (1) tKEL, filled: 0.0%, rate (mtKEL/tKEL): 1.1, net: riemann

orderHash: 0x918E3B988CB5B04DC415DC329DEA6C8C2E91859E975FC50D24433A8C1D33337B
 ts_created: Fri Feb 16 16:48:45 2024 (1708130925)
 Status: OPENED, amount: 0.000000000000000001 (1) tKEL, filled: 0.0%, rate (mtKEL/tKEL): 1.1, net: riemann

orderHash: 0x44AF014100898E1307E09570FCD9EC5FD633FE555A09A795948C88CAEA813885
 ts_created: Mon Feb 19 23:53:15 2024 (1708415595)
 Status: OPENED, amount: 0.000000000000000001 (1) tKEL, filled: 0.0%, rate (tKEL/tKEL): 1.0, net: riemann

orderHash: 0xE1BB55E0B8EBCFD2F654F0825EE64AE299AC661FB7BBE8377E1E5FFC508FC28C
 ts_created: Wed Feb 28 21:30:42 2024 (1709184642)
 Status: OPENED, amount: 0.5 (500000000000000000) mtKEL, filled: 50.0%, rate (tKEL/mtKEL): 2.0, net: riemann

orderHash: 0x72FBB3ED3708074B229D7D8D46404E26347AEEFB3EC2F3B56A0CD4BE4AD1BBFB
 ts_created: Fri Mar  8 02:54:39 2024 (1709895279)
 Status: OPENED, amount: 2.0 (2000000000000000000) tKEL, filled: 0.0%, rate (mtKEL/tKEL): 1.0, net: riemann

Found 5 orders

JSON-RPC Example

Command:

curl -X POST http://rpc.cellframe.net/connect -d '{"method":"srv_xchange", "params":["srv_xchange;orders;-net;riemann;-status;opened"], "id":"1"}'

Response:


"type": 0,
"result": "same as cli response",
"errors": null,
"id": 1
}
Link to original

Node Command - SRV_XCHANGE PURCHASE

Creates exchange transaction filling order fully or partially

CLI Example

Command syntax:

srv_xchange purchase 
-order <order hash> 
-net <net_name> 
-w <wallet_name> 
-value <value> 
-fee <value>

Options:

-net - name of the Cellframe Network. The list of networks can be found in the <Config_dir> \ etc \ network folder or received by The Cellframe-Node-CLI using command - net list
-w - name of the wallet
-value - amount of datoshi user wants to sell corresponding to rate specified in order
-fee - comission in datoshi

Example:

Command:

cellframe-node-cli srv_xchange purchase 
-order 0x72FBB3ED3708074B229D7D8D46404E26347AEEFB3EC2F3B56A0CD4BE4AD1BBFB 
-net riemann 
-w testwallet 
-value 1.0e+18 
-fee 0.01e+18

Response:

Exchange transaction has done. tx hash: 0xA66DEC0DF85EAFA9D7C1284DF1D5A5DA83195BB1EC734A6B9A0FF10DF7AC20BD

JSON-RPC Example

Command:

curl -X POST http://rpc.cellframe.net/connect -d '{"method":"srv_xchange", "params":["srv_xchange;purchase;-order;0x72FBB3ED3708074B229D7D8D46404E26347AEEFB3EC2F3B56A0CD4BE4AD1BBFB;-net;riemann;-w;testwallet;-value;1.0e+18;-fee;0.1e+18"], "id":"1"}'

Response:


"type": 0,
"result": "Exchange transaction has done. tx hash: 0xE9332879DD8402BC29E49483A26994F1ED9E85106DC723256BBAA592D6A80E37",
"errors": null,
"id": 1
}
Link to original

Node Command - SRV_XCHANGE TX_LIST

Lists all exchange transactions. Optionally there can be applied filtration by time or address of the wallet.

All times are in RFC822. For example, “7 Dec 2023 21:18:04

CLI Example

Command syntax:

srv_xchange tx_list 
-net <net_name> 
[-time_from <From time>] 
[-time_to <To time>]
[[-addr <wallet_addr>  [-status {inactive|active|all}] ]

Options:

-net - name of the Cellframe Network. The list of networks can be found in the <Config_dir> \ etc \ network folder or received by The Cellframe-Node-CLI using command - net list
 
filtration options:
-time_from - filtration by time since specified value (optional)
-time_to - filtration by time until specified value (optional)
-addr - filtration by specified wallet address (optional)
-status - transactions status: inactive/active/all(optinal, used if filtration by wallet address was chosen )

Example:

Command:

cellframe-node-cli srv_xchange tx_list 
-net riemann 
-addr o9z3wUTSTicckJuozF3GcveoJK22eFmYXTZ4c8z7cwQ76VLMvgTXhBcULJ44E6X8paJiHbxvAyCZ2jbLhBj3tQuTdC769DZ6qMzEqizP

Response:

Hash: 0xE0F5065487E75C8BC7C78BB23498ECE955A221EAFFB1F9414EFCC433AE989F48
  Status: inactive,  changed 2.0 (2000000000000000000) mtKEL for 0.002 (2000000000000000) tKEL,  rate (tKEL/mtKEL): 0.001,  remain amount 0.0 (0) mtKEL, net: riemann

Hash: 0xF7DC0EC97C712D83CDB876D92B2B63798E3217B094066B51D7A1479CD3BA988A
  Status: inactive,  proposed 2.0 (2000000000000000000) mtKEL for exchange to tKEL,  rate (tKEL/mtKEL): 2000.0, net: riemann

Hash: 0x27A5A7C8D01A68EBFA0D524D20BE01E58C183D5E750AF85658001A4AD4726C41
  Status: inactive,  changed 1.0 (1000000000000000000) mtKEL for 2000.0 (2000000000000000000000) tKEL,  rate (tKEL/mtKEL): 2000.0,  remain amount 1.0 (1000000000000000000) mtKEL, net: riemann

Hash: 0x31FC67FBF72AD7251F229D017B6B03E6E8D9E6ABB0178D6587E7BDFC6452C216
  Status: active,  changed 1.0 (1000000000000000000) mtKEL for 2000.0 (2000000000000000000000) tKEL,  rate (tKEL/mtKEL): 2000.0,  remain amount 0.0 (0) mtKEL, net: riemann

Hash: 0x72FBB3ED3708074B229D7D8D46404E26347AEEFB3EC2F3B56A0CD4BE4AD1BBFB
  Status: active,  proposed 2.0 (2000000000000000000) tKEL for exchange to mtKEL,  rate (mtKEL/tKEL): 1.0, net: riemann

JSON-RPC Example

Command:

curl -X POST http://rpc.cellframe.net/connect -d '{"method":"srv_xchange", "params":["srv_xchange;tx_list;-net;riemann;-addr;o9z3wUTSTicckJuozF3GcveoJK22eFmYXTZ4c8z7cwQ76VLMvgTXhBcULJ44E6X8paJiHbxvAyCZ2jbLhBj3tQuTdC769DZ6qMzEqizP"], "id":"1"}'

Response:


"type": 0,
"result": "same as cli response",
"errors": null,
"id": 1
}
Link to original

Node Command - SRV_XCHANGE TOKEN_PAIR LIST

Lists all token pairs

CLI Example

Command syntax:

srv_xchange token_pair list all  
-net <net_name> 

Options:

-net - name of the Cellframe Network. The list of networks can be found in the <Config_dir> \ etc \ network folder or received by The Cellframe-Node-CLI using command - net list
 

Example:

Command:

cellframe-node-cli srv_xchange token_pair list all
-net KelVPN 

Response:

Tokens count pair: 6

KEL:mKEL KEL:CELL KEL:mCELL mKEL:CELL mKEL:mCELL CELL:mCELL

JSON-RPC Example

Command:

curl -X POST http://rpc.cellframe.net/connect -d '{"method":"srv_xchange", "params":["srv_xchange;token_pair;-net;KelVPN;list;all"], "id":"1"}'

Response:


"type": 0,
"result": "Tokens count pair: 6\nKEL:mKEL KEL:CELL KEL:mCELL mKEL:CELL mKEL:mCELL CELL:mCELL ",
"errors": null,
"id": 1
}
Link to original

Node Command - SRV_XCHANGE TOKEN_PAIR RATE

Shows average rate for token pair

srv_xchange token_pair rate average 
-net <net_name>  
-token_from <token_ticker> 
-token_to <token_ticker>

CLI Example

Command syntax:

srv_xchange token_pair rate average 
-net <net_name>  
-token_from <token_ticker> 
-token_to <token_ticker>

Options:

-net - name of the Cellframe Network. The list of networks can be found in the <Config_dir> \ etc \ network folder or received by The Cellframe-Node-CLI using command - net list
-token_from - kind of token is being sold 
-token_to - kind of token is being bought 

Example:

Command:

cellframe-node-cli srv_xchange token_pair rate average
-net KelVPN 
-token_from KEL 
-token_to CELL

Response:

Average rate: 0.762800000000000001

Last rate: 1.0 Last rate time: Wed Feb 28 09:55:46 2024 (1709114146)

JSON-RPC Example

Command:

curl -X POST http://rpc.cellframe.net/connect -d '{"method":"srv_xchange", "params":["srv_xchange;token_pair;-net;KelVPN;rate;average;-token_from;KEL;-token_to;CELL"], "id":"1"}'

Response:


"type": 0,
"result": "Average rate: 0.762800000000000001   \n\rLast rate: 1.0 Last rate time: Wed Feb 28 09:55:46 2024 (1709114146)",
"errors": null,
"id": 1
}
Link to original

Node Command - SRV_XCHANGE TOKEN_PAIR HISTORY

Prints token pairs history (or only filtrated by time)

All times are in RFC822. For example, “7 Dec 2023 21:18:04

CLI Example

Command syntax:

srv_xchange token_pair rate history 
-net <net_name>  
-token_from <token_ticker> 
-token_to <token_ticker> 
[-time_from <From time>] [-time_to <To time>]

Options:

-net - name of the Cellframe Network. The list of networks can be found in the <Config_dir> \ etc \ network folder or received by The Cellframe-Node-CLI using command - net list
-token_from - kind of token is being sold 
-token_to - kind of token is being bought 
-time_from - filtration by time since specified value (optional)
-time_to - filtration by time until specified value (optional)

Example:

Command:

cellframe-node-cli srv_xchange token_pair rate history
-net riemann  
-token_from mtKEL 
-token_to tKEL

Response:

Hash: 0xE1BB55E0B8EBCFD2F654F0825EE64AE299AC661FB7BBE8377E1E5FFC508FC28C
  ts_created: Thu Feb 29 05:30:42 2024
  proposed 1.0 (1000000000000000000) mtKEL for exchange to tKEL,  rate (tKEL/mtKEL): 2.0, net: riemann

Hash: 0x5A8BEE67D15A10480DAA18FE797F5435CDB16435B9235F9DFF3015E7AA5CA700
  ts_created: Tue Mar  5 11:59:50 2024
  proposed 2.0 (2000000000000000000) mtKEL for exchange to tKEL,  rate (tKEL/mtKEL): 0.001, net: riemann

...


Hash: 0x31FC67FBF72AD7251F229D017B6B03E6E8D9E6ABB0178D6587E7BDFC6452C216

  ts_created: Fri Mar  8 09:22:54 2024

  changed 1.0 (1000000000000000000) mtKEL for 2000.0 (2000000000000000000000) tKEL,  rate (tKEL/mtKEL): 2000.0,  remain amount 0.0 (0) mtKEL, net: riemann

JSON-RPC Example

Command:

curl -X POST http://rpc.cellframe.net/connect -d '{"method":"srv_xchange", "params":["srv_xchange;token_pair;-net;riemann;rate;history;-token_from;mtKEL;-token_to;tKEL"], "id":"1"}'

Response:


"type": 0,
"result": "same as cli response",
"errors": null,
"id": 1
}
Link to original