Open hrharder opened 5 years ago
High-level plan for services responsible for market-making logic:
Maker
Hedger
Market Watcher
Taker Profiler (?)
This comment attempts to outline the responsibility of each service in a typical user interaction.
quoteId
)quoteId
(and/or request body)maker
and taker
assets are supportedmakerAssetSize
or takerAssetSize
senderAddress
) based on quote parametersquoteId
quoteId
back to dealer over public JSONRPCquoteId
quoteId
quoteId
is valid and SHOULD be executedquoteId
is NOT valid and SHOULD NOT be executedtakerAsset
takerAsset
executeTransaction
on the 0x v3 exchange contractThanks for writing this up @hrharder, I don't have any significant issues with this high level definition.
I have do have one question though. It specifically relates to the following bullet but it does seem applicable at other points:
hot wallet reflects status change ("fill approved" to "fill submitted") and stores TX ID
How would Dealer
be made aware of a change to the status of the order so that they can respond correctly? Is the dealer essentially responsible for actively monitoring updates? It might make sense to make this more explicitly event driven (e.g. the second option that you referenced).
@L-Kov:
hot wallet reflects submission status to dealer over gRPC and dealer updates status in DB
As I understand it, the Hot Wallet notifies the dealer right afer updating the database
I made a small drawing to picture what's going on, some of the details are missing, but overall it helped me to understand, here are some observations:
Questions:
7.3:
indicates to dealer one of the following:
and 7.6:
maker indicates completed verification (either outcome) to dealer over gRPC
9:
Order watcher is alerted of submitted fill, and begins "watching"
I want to change the end stage of our order processing in v2. Since the Hedger will be operating over epochs, I'd rather store the filled orders in redis, which at epoch end will be accessed by the Hedger and cleared. This eliminates grpc dependency and also allows epoch status to be used in pricing, e.g. if we have a lot of sells on a given pair during an epoch that hasn't been handled yet, we could offer better prices on the other side so we could match against ourselves.
@L-Kov
How would Dealer be made aware of a change to the status of the order so that they can respond correctly?
@gchaincl is correct -- the idea is this would be a request/response pattern over gRPC where the hot-wallet (or whatever other service is taking action). Because most stateful data will be in a DB the messages can be very simple -- likely just including the relevant quote ID and a status code. We will certainly need some more clarity around this soon.
@gchaincl Not sure I understand what you're asking with regard to the difference between 7.3 and 7.6, can you clarify?
Who alerts the Order Watcher? I presume is the Dealer, can you confirm?
That is correct -- right now my thinking is the dealer will alert the order-watcher that a new transaction has been submitted and must be monitored. We could potentially make this the responsibility of whatever service actually submits the Tx.
What would be the implications of delegating all the DB access to the Dealer service?
I'm not sure -- this might be a good idea however. One thing I was not a huge fan of in the current system is how many services access the DB.
Personally I like the pattern of the dealer being this central service and orchestrator, in which case it seems to make sense for the dealer to do most of the (or all of) the DB interactions. What do you think?
@mtmuehl
Since the Hedger will be operating over epochs, I'd rather store the filled orders in redis.
This sounds fine -- however, I'm personally in the boat that we should move away from redis as a catch-all DB, and only use it as a cache.
I would like to keep one main table in something like SQL or similar where each entry is a "quote", but it stores all relevant information, including the hedge trade.
In your mind, is redis the key word here, or rather just storing the filled orders in /some/ DB (not necessarily redis)?
@hrharder
Yes although in this case the function is very 'cache-like' so I think redis might be the best choice. Since this is being accessed by the service we'd like to performance optimize the most whatever the fastest read option is should work
@mtmuehl
Sounds good -- as long as any relevant data from hedge trades eventually gets stored in the persistent DB I think that is okay.
For example, the timestamp, exchange order ID, size/price/side of the hedge trade should be associated with the quote ID after we're done with it. Would you agree?
Personally I like the pattern of the dealer being this central service and orchestrator, in which case it seems to make sense for the dealer to do most of the (or all of) the DB interactions. What do you think?
I agree. We can expose gRPC methods so that HotWallet and Maker can update the DB via Dealer
Perfect.
Overview
This issue will serve as a place to discuss and outline the high-level plans for the various services required to implement the Zaidan Dealer JSONRPC.
Description