Closed brenzi closed 3 years ago
A minimal functionality includes:
mng_create_order
mng_cancel_order
mng_trade
order
Remarks:
The management websocket authenticate use standard JWT - RS256
JWT=$(barong-jwt --uid IDBD12DEB15B) wscat --connect 'ws://localhost:8080/api/v2/finex/ws' -H "Authorization: Bearer ${JWT}"
Example of JWT:
eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOlsicGVhdGlvIiwiYmFyb25nIl0sImVtYWlsIjoiYWRtaW5AYmFyb25nLmlvIiwiZXhwIjoxNjE3OTU2MjU3LCJpYXQiOjE2MTc5NTI2NTcsImlzcyI6ImJhcm9uZyIsImp0aSI6IjE2MTc5NTI2NTciLCJsZXZlbCI6MywicmVmZXJyYWxfaWQiOm51bGwsInJvbGUiOiJhZG1pbiIsInN0YXRlIjoiYWN0aXZlIiwic3ViIjoic2Vzc2lvbiIsInVpZCI6IlU0ODcyMDU4NjMifQ.ROjIs7OhcsX86ZxxVy5vnBCNheEtOENpI9g7eN4BgbGlz5U3XLg7D9cILw8FEsmfzTf5pSzMRrx59_rD9sI4abim7Nn7eJ8gay7E-vQdFfeu6720ZQkbM3w5hIpq2x6pubzUu88ZCVZA2mLEw2XuQFVtDBCEBT5yWCPIOFSsuVN6wSuANvR2ZpJytJHvzSpeGv_9BxZC0ZtAR4PaP2f_iyX1Zw-71QxB4-BxdZeCUp17ic82DQ7TQU_GgYoQNTQFVBHc_oouj_3XB_B1PIYvbSAoPkS1JalqrwJRIw0nFQfTe09OazACyjGyQpsQqsVBN6WlEjYViV30cGquDRATYg
Resources:
Method: mng_create_order
Arguments:
Example:
[1,42,"mng_create_order",["14dQ6XGcrk4njhYB7ihcjHyyKbFKUVCXt5vffTV9yAWcgrbu", "btcusd", "trusted", "l", "buy", "0.250000", "9120.00"]]
Response:
[2,42,"mng_create_order",["1245-2345-6798-123123"]]
Error example:
[2,42,"error",["Message describing the error"]]
Method: mng_cancel_order_bulk
mng_cancel_order_bulk
[1,42,"mng_cancel_order",["btcusd", ["1245-2345-6798-123123", "1245-2345-6798-123124"]]]
TODO
[4,"order",["btcusd", 2, "7acbbc84-939d-11ea-a827-1831bf9834b0", "buy", "bid", "done", "limit", "1", "1", "0", "1", "1", 1, 1589211516]]
[4,"mng_trade",["btcusd", 1, "1", "1", "1", 2, "55d78eee-939e-11ea-945f-1831bf9834b0", 3, "55d78eee-939e-11ea-945f-1831bf9834as", "buy", 1589211884]]
The following functions are not strictly needed but it may help debugging if we let OpenFinex know about deposit and withdrawal events:
Method: mng_deposit
mng_deposit
[1,42,"mng_deposit",["14dQ6XGcrk4njhYB7ihcjHyyKbFKUVCXt5vffTV9yAWcgrbu", "usd", "1500.000000000000", "0x1234657890123456789"]
[2,42,"mng_deposit",[124]]
Method: mng_withdraw
mng_withdraw
[1,43,"mng_withdraw",["14dQ6XGcrk4njhYB7ihcjHyyKbFKUVCXt5vffTV9yAWcgrbu", "usd", "1500", "0x1234657890123456789"]
[2,43,"mng_withdraw",[124]]
[2,43,"error",["Message describing the error"]]
Finally tested it, and a trade event successfully modified the free balances of accounts, hence closing this issue.
A minimal functionality includes:
mng_create_order
mng_cancel_order
mng_trade
events and trigger the verification and settlement of matchesorder
events and update the enclave's orderbook mirror (because orders may only be partly executed by a trade / match)Remarks:
Finex engine management (S2S) websocket protocol
Authentication
The management websocket authenticate use standard JWT - RS256
Example of JWT:
Resources:
Create orders
Method:
mng_create_order
Arguments:
- limit: "l"
- Post only (Must not fill at all or is canceled): "p"
- Fill or kill (Must fully match at a given price or is canceled): "f"
Example:
Response:
Error example:
Cancel orders
Method:
mng_cancel_order_bulk
Arguments:
Example:
Events
Subscription to events
TODO
Order update events
Trades events
Debug helpers
The following functions are not strictly needed but it may help debugging if we let OpenFinex know about deposit and withdrawal events:
Deposit funds
Method:
mng_deposit
Arguments:
Example:
Response:
Error example:
Withdraw funds
Method:
mng_withdraw
Arguments:
Example:
Response:
Error example: