Dmex Explained in Detail
https://bit.ly/2qGRWer
DMEX is comprised of three smart contracts running on the Ethereum Blockchain:
Custody Contract — this contract holds users funds and balance details (reserved and available balances). Link to GitHub.
Trading Contract — performs the trades between users and holds the Assets, Futures Contract, Positions, and order fills. Link to GitHub.
Oracle Contract — is the interface to the Provable.xyz decentralized Oracle service that brings in the settlement price for the futures contract when it expires or the price limit is breached. Link to GitHub.
In order to trade, the user first needs to deposit funds to the Custody contract. All withdrawals are performed from the Custody contract as well.
Once a user places an order and the order is matched with an order from another user, the DMEX servers will send both orders to the Trading contract that will create 2 opposite positions, one long and one short.
Once the contract expires or the price limit is breached, the DMEX server calls the closeFuturesContract() function on the Oracle Contract, providing the futuresContactHash as a parameter. This function verifies if the Futures Contract is not already closed and requests the price from the Oracle.
In reality, the Oracle is asked to return the output of the priceUrl (discussed in Part 1), the Oracle is not aware of the sort of information it is providing, it just returns the contents of the URL along with the proof that the snapshot was taken by their “black box” machine. The contents of the URL are returned through a callback function that can only be called by the Oracle.
When the price is received by the callback function, it checks if the price is outside the Futures Contract range, and if so it uses the Floor or Cap price as the Closing Price and sets the contract as closed.
Once the contract is closed, the DMEX server initiates the settlement of the positions on the closed Futures Contract through batchSettlePositions() function on the Trading Contract. Note that this step can be performed by the user directly, it is performed by DMEX for convenience only.
No kyc, use your own eth extension, all on the blockchain.