daifoundation / maker-otc

The OasisDEX protocol - Simple on-chain market for ERC20 tokens
GNU Affero General Public License v3.0
101 stars 39 forks source link

Event sourcing via more expressive events #135

Closed rainbreak closed 6 years ago

rainbreak commented 8 years ago

Currently there is a single event - ItemUpdate.

When a frontend constructs the order book it scans through the event history of the market and uses getOffer to determine offer status following an ItemUpdate. More expressive events would allow the order book to be entirely event sourced.

Existing events:

Proposed new events (replacing ItemUpdate):

Then each market function is associated with a single event type.

rainbreak commented 8 years ago

@jorisbontje: what are your thoughts on this from frontend perspective?

jorisbontje commented 8 years ago

1) I think the Offer event would also need to have an id attribute, so the offer can be bought or cancelled. 2) This would require clients to always sync the entire eventlog before they can do trading; otherwise partial trades would mess up the orderbook. I have some mixed feelings about this.

rainbreak commented 8 years ago

1) Agreed, edited OP.

2) Good point. Frontend would still be able to operate as it is now (with modified event names), so not really event sourcing.

I think one benefit would be for always-on bots: they can listen to the market and trade purely on events, although they'd still need some on chain proxy for risk free arbitrage.

jorisbontje commented 8 years ago

Extend Trade event with buyer and seller property. This would allow you to do reporting on your trading history. We can't have them indexed, as this would exceed the maximum number of indexed attributes (3 + 1 for the event signature).

jorisbontje commented 8 years ago

While we are at renaming events, I suggest to prefix the events with Log as per Peter's security audit recommendations.