How Does TimeFlow's Pre-Market Work?
Let’s assume there is a pre-market for trading the Pharos project’s PTT token, with the ID set to 0. Alice knows that at the end of the T1 market, she will receive 10,000 PTT tokens, and Bob is a buyer very interested in acquiring PTT tokens:
Alice's transactions:
OrderId = 0, Price = 1 DUST, Amount = 2000 PTT, State = Selling, Alice Collateral = 2000 DUST.
OrderId = 2, Price = 2 DUST, Amount = 2000 PTT, State = Selling, Alice Collateral = 4000 DUST.
OrderId = 4, Price = 2 DUST, Amount = 2000 PTT, State = Completed, Unpledged PTT, Alice Collateral = 4000 DUST, Bob Collateral = 4000 DUST.
OrderId = 5, Price = 3 DUST, Amount = 2000 PTT, State = Completed, Pledged PTT, Alice Collateral = 6000 DUST, Alice Pledged = 2000 PTT, Bob Collateral = 6000 DUST.
Bob's transactions:
OrderId = 1, Price = 0.9 DUST, Amount = 2000 PTT, State = Buying, Bob Collateral = 1800 DUST.
OrderId = 3, Price = 1 DUST, Amount = 2000 PTT, State = Completed, Pledged PTT, Bob Collateral = 2000 DUST, Alice Collateral = 2000 DUST, Alice Pledged = 2000 PTT.
If the current time is T2:
If T2 < T1 - 12h, Alice can cancel orderId = 0 and orderId = 2, and Bob can cancel orderId = 1.
If T2 < T1, orderId = 5 sees Alice pledge 2000 PTT, and orderId = 3 sees Alice pledge another 2000 PTT.
If T2 >= T1, and if orderId = 0, orderId = 1, and orderId = 2 are not canceled, a refund can be executed.
OrderId = 4 results in a breach of contract: Alice loses the collateral, and Bob receives orderId = 4’s collateral minus the fee in DUST.
OrderId = 3, Alice receives 4000 DUST minus the fee, and Bob receives 2000 PTT.
OrderId = 5, Alice receives 12000 DUST minus the fee, and Bob receives 2000 PTT.