diff --git a/doc/src/SUMMARY.md b/doc/src/SUMMARY.md index 2e49080f3..911698789 100644 --- a/doc/src/SUMMARY.md +++ b/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) diff --git a/doc/src/arch/dex.md b/doc/src/arch/dex.md new file mode 100644 index 000000000..f34f23369 --- /dev/null +++ b/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. +