fluidex / dingir-exchange

A high performance crypto trading engine
234 stars 62 forks source link

gateway: sign and relay orders #333

Open lispc opened 3 years ago

lispc commented 3 years ago

background

we may need to develop an exchange gateway to maker bots to integrate.

The rollup exchange is more complex than normal CEXs. eg nonce, eddsa signature.

The trading bots may include python/js/java/c++, it is unrealistic to implement to same logic ( encoding & sign ) in every language. So a rust gateway may be helpful.

The gateway is run by a trading team, the gateway can access their l2 seckey. Bots send raw orders to the gateway, gateway service fetchs nonce & order_id & order_pos and signs the order, and then send the signed order to the real FluiDex server.

TODO

  1. copy and modify client.ts into a grpc server process, which expose one grpc endpoint signOrder. signOrder shares most codes with createOrder function. input: order details, output: signature
  2. add a python client, which uses the js grpc signer to get order signature, then sends signed orders to the exchange
lispc commented 3 years ago

APIs of the gateway:

here is an example of APIs ( ccxt / freqtrade) : https://github.com/freqtrade/freqtrade/blob/develop/freqtrade/exchange/exchange.py