The aim of the batch clearing dex is to enable users to deposit tokens with the aim of being swapped at a fair price with bounded slippage and almost no impermanent loss.
once we know the clearing level (which has been coded) we can progress to the settlement of the orders. Any orders at or below the clearing price can be settled pro-rata (first come first serve), this could include partial fills. All others are not executed.
We need a mechanism to match off orders either completely or partially (this would mean leaving the remaining un-filled part of the order until it expires or is itself filled or partially filled).
When we deposit a swap in the testnet contract, this should be reflected in the wallet amount. I.e. a swap deposit should remove an equal amount of token from the trader/user's wallet and that token should be in the contract's treasury.
We need to test that this is actually happening on the testnet.
Based on the new doc we should create the clearing price calculator to support the design doc.
It should receive a batch (i.e. a number of swap orders at different levels and sides) and an Oracle price. From this we need to calculate the clearing price level.
we have to decide and find how do we want to deal with the math file and prices calculation, and write tests (maybe implementing the sheet Jason made in excel but with tests)
Because of the automatic swapping process, we need a treasury address for supporting this. This treasury address needs to support XTZ and other tokens in Tezos.
The separate components like treasury and matching won't be individual contracts for the POC so we should remove the contract entrypoints and switch to method calls from the main slip contract
For the PoC we need to be able to deploy to a testnet easily (this has mostly been done) but we need to test after merging the components and then fix any deployment issues.