Bläddra i källkod

doc: arch/dex design doc

darkfi 1 år sedan
förälder
incheckning
da211d27ec
2 ändrade filer med 30 tillägg och 0 borttagningar
  1. 1 0
      doc/src/SUMMARY.md
  2. 29 0
      doc/src/arch/dex.md

+ 1 - 0
doc/src/SUMMARY.md

@@ -45,6 +45,7 @@
   - [Smart Contracts](arch/sc/sc.md)
     - [Transaction lifetime](arch/sc/tx-lifetime.md)
   - [DAO](arch/dao.md)
+  - [DEX](arch/dex.md)
   - [Wallet](arch/wallet.md)
 - [zkas](zkas/index.md)
   - [Writing ZK Proofs](zkas/writing-zk-proofs.md)

+ 29 - 0
doc/src/arch/dex.md

@@ -0,0 +1,29 @@
+# DEX
+
+With cross-chain bridging and darkpool DEX then DarkFi would be a very
+attractive trading tool.
+
+We currently have OTC swaps which are an efficient way to settle trades
+on-chain. But there needs to be an orderbook for matching counterparties.
+
+We propose that this job can be performed by an order-matching bot which
+maintains an orderbook. Later this role can be split with MPC.
+
+The order-matching party needs to be able to construct the swap trade,
+even when the LP is offline.
+
+We propose to do this using the spend hook and a special `auth_otc` function.
+The `auth_otc` basically says:
+
+* The sender of the funds has the right at any time to withdraw liquidity and
+  cancel the LP.
+* The funds are delegated to the order-matching party but with restrictions:
+    * Can only make an OTC swap tx using the funds.
+    * The trade parameters are completely specified such as the price and
+      currencies.
+
+The funds are therefore delegated to the order-matching party, who finds
+counterparty offers and executes the trades settling them on-chain. Both parties
+receive their funds in a trustless anonymous manner. At any time the LP can be
+canceled and funds withdrawn.
+