dex-contracts icon indicating copy to clipboard operation
dex-contracts copied to clipboard

There should be a `SolutionReversion` event

Open e00E opened this issue 5 years ago • 1 comments
trafficstars

I noticed this when implementing an orderbook based only on events.

We emit a SolutionSubmission event when a solution is accepted. This event allows us to update the solution submitter's fee token balance based on solution fee reward (their OWL balance increases). Handling this properly is needed in the orderbook because we need to know accurate balances for all users. This includes the solution submitter in case they decide to participate in trading, too.

When a solution is reverted we correctly emit a TradeReversion event for each trade but we silently decrease the previously granted solution free reward. This goes unnoticed in the orderbook.

There is a workaround: We can keep track of the latest solution submitter and granted reward. When we notice any TradeReversion we know the solution must have been reverted and deduct the reward again and delete our record of the latest solution (so that we don't deduct it multiple times). I think this works in every case but it doesn't feel intended.

e00E avatar Mar 26 '20 12:03 e00E

We can keep track of the latest solution submitter and granted reward. When we notice any TradeReversion we know the solution must have been reverted and deduct the reward again and delete our record of the latest solution (so that we don't deduct it multiple times).

If I understand everything correctly, shouldn't a new SolutionSubmission for the same batch just revert the fee transfer to the solution submitter in case there was a previous solution submission? I think that feels less hacky than using TradeReversion events.

nlordell avatar Apr 05 '20 09:04 nlordell