Actually when you talk about doing long-running averages, your market maker starts to look like the market maker described on this message thread some time ago.
This market maker collects deposits and trades at time 0:00. It is provably fair (everyone eventually gets the market exchange rate) and provably secure against front-running. In fact all participants during a particular day get the same exchange rate.
I really think that these types of on-chain exchanges are superior to “reserve-curve-based” exchanges and will end up being widely used
Here is a short description:
-
Intraday all market participants deposit funds and submit orders.
-
At time 0:00 an exchange happens , where the exchange rate is determined by a balance of deposits
-
Intraday (during a deposit) the party can get an intra-day loan from the market maker in the amount of 80% of the estimated exchange value as determined by the previous day exchange rate. The loan is repaid when the exchange happens at time 0:00
-
The market maker charges fees which increase if the market maker starts losing reserves. The market maker is mathematically guaranteed to never run out of reserves (the fees increase to infinity when the market maker starts losing reserves(
-
Due to arbirtrage and since the deposits are public, at time 0:00 the exchange rate will very much match external exchanges.
Here is a prototype implementation (it is opensource under GPL 2.0 license)