decred.org/dcrdex@v1.0.5/docs/release-notes/release-notes-0.1.0.md (about)

     1  # DCRDEX v0.1.0 (beta)
     2  
     3  Oct 20, 2020
     4  
     5  ## Important Notices
     6  
     7  - Ensure your nodes (and wallets) are fully **synchronized with the blockchain
     8    network before placing orders**. The software will verify this for you in the
     9    next patch release.
    10  - **Never shutdown your wallets with dexc running**. When shutting down, always
    11    stop dexc before stopping your wallets.
    12  - If you have to restart dexc with active orders or swaps, you must
    13    **immediately login again with your app password when dexc starts up**. The
    14    next patch release wil inform you on startup if this is required.
    15  - There is a ~10 minute "inaction timeout" when it becomes your client's turn to
    16    broadcast a transaction, so be sure not to stop dexc or lose connectivity for
    17    longer than that or you risk having your active orders and swaps/matches
    18    revoked. If you do have to restart dexc, remember to login as soon as you
    19    start it up again.
    20  - Only one dexc process should be running for a given user account at any time.
    21    For example, if you have identical dexc configurations on two computers and
    22    you run dexc and login on both, neither dexc instance will be adequately
    23    connected to successfully negotiate swaps. Also note that order history is not
    24    synchronized between different installations at this time.
    25  - Your DEX server accounts exist inside the dexc.db file, the location of which
    26    depends on operating system, but is typically in ~/.dexc/mainnet/dexc.db or
    27    %HOMEPATH%\Local\Dexc\mainnet\dexc.db.  Do not delete this account or you will
    28    need to register again at whatever server was configured in it.
    29  - If you use a non-default bitcoin wallet name, don't forget to set it in
    30    bitcoin.conf with a `wallet={insert wallet name here}` line so that bitcoind
    31    will load it each time it starts.  Otherwise dexc will give you a "wallet not
    32    found" error on startup and login.
    33  - bitcoind's "smart" fee estimation needs plenty of time to warm up or it is not
    34    so smart, potentially leading to you creating redeem transactions with low
    35    fees that can make the transaction take a very long time to mine (get
    36    confirmed).  Either keep your bitcoind running for a couple hours after
    37    starting it up after it had been stopped for a long time (any more than ~1hr)
    38    prior to starting it, or ensure that the value returned from a bitcoin-cli
    39    call to `estimatesmartfee 1` returns a `"feerate"` close to what
    40    <https://mempool.space/> reports as "High priority".
    41  
    42  ## Overview
    43  
    44  This release of DCRDEX includes a client program called dexc and a server called
    45  dcrdex. Users run their own wallets (e.g. dcrwallet or bitcoind), which dexc
    46  works with to perform trades via atomic swaps. dcrdex facilitates price
    47  discovery by maintaining an order book for one or more markets, and coordinates
    48  atomic swaps directly between pairs of traders that are matched according to
    49  their orders. The server is generally run on a remote system, but anyone may
    50  operate a dcrdex server.
    51  
    52  This release supports Decred, Bitcoin, and Litecoin.
    53  
    54  ### Client (dexc)
    55  
    56  - Provides a browser-based interface, which is self-hosted by the dexc program,
    57    for configuring wallets, displaying market data such as order books, and
    58    placing and monitoring orders.
    59  - Communicates with any user-specified dcrdex server.
    60  - Funds orders and executes atomic swaps by controlling the external wallets
    61    (dcrwallet, etc.).
    62  
    63  ### Server (dcrdex)
    64  
    65  - Accepts orders from clients who prove ownership of on-chain coins to fund the
    66    order.
    67  - Books and matches orders with an epoch-based matching algorithm.
    68  - Relays swap data between matched parties, allowing the clients to perform the
    69    transactions themselves directly on the assets' blockchains.
    70  - Has a one-time nominal (e.g. 1 DCR) registration fee, which acts as an
    71    anti-spam measure and to incentivize completing swaps.
    72  - Enforces the code of community conduct by suspending accounts that repeatedly
    73    violate the rules.
    74  
    75  ## Features
    76  
    77  ### Markets and Orders
    78  
    79  The server maintains a familiar market of buy and sell orders, each with a
    80  quantity and a rate. A market is defined by a pair of assets, where one asset is
    81  referred to as the **base asset**. For example, in the "DCR-BTC" market, DCR is
    82  the base asset and BTC is known as the **quote asset**. A market is also
    83  specified by a **lot size**, which is a quantity of the base asset. Order
    84  quantity must be a multiple of lot size, with the exception of market buy orders
    85  that are necessarily specified in units of the quote asset that is offered in
    86  the trade. The intent of a client to execute an atomic swap of one asset for
    87  another is communicated by submitting orders to a specific market on a dcrdex
    88  server.
    89  
    90  The two types of trade orders are market orders, which have a quantity but no
    91  rate, and limit orders, which also specify a rate. Limit orders also have a
    92  **time-in-force** that specifies if the order should be allowed to become booked
    93  or if it should only be allowed to match with other orders when it is initially
    94  processed. The time-in-force options are referred to as "standing" or
    95  "immediate", where standing indicates the order is allowed to become booked
    96  while immediate restricts that order to being a taker order by only allowing a
    97  match when it is initially processed.
    98  
    99  The following image is an example order submission dialog from a testnet DCR-BTC
   100  market with a 40 DCR lot size that demonstrates limit order buying 2 lots (80
   101  DCR) at a rate of 0.001207 BTC/DCR using a standing time-in-force to allow the
   102  order to become booked if it is not filled:
   103  
   104  ![submit order dialog](https://user-images.githubusercontent.com/9373513/97030709-c8fd9500-1524-11eb-8bd0-3eb4cf95e8c8.png)
   105  
   106  Checking the "Match for one epoch only" box above specifies that the limit
   107  order's time-in-force should be immediate, while unchecking it allows the order
   108  to be booked if it does not match with another order at first. The concept of
   109  epochs is described in the [Epoch](#epochs) section.
   110  
   111  ### Order Funding
   112  
   113  Since orders must be funded by coins from the user's wallets, placing an order
   114  "locks" an amount in the relevant wallet. For example, a buy order on the
   115  DCR-BTC market marks a certain quantity of BTC as locked with the user's wallet.
   116  (This involves no transactions or movement of funds.) This amount will be shown
   117  in the "locked" row of the Balances table.
   118  
   119  It is important to note that the amount that is locked by the order may be
   120  **larger than the order quantity** since the "locked" amount is dependent on the
   121  size of the UTXO (for UTXO-based assets like Bitcoin and Decred) that is
   122  reserved for use as an input to the swap transaction, where the amount that does
   123  not enter the contract goes in a change address. This is no different from when
   124  you make a regular transaction, however because the input UTXOs are locked in
   125  advance of broadcasting the actual transaction that spends them, you will see
   126  the amount locked in the wallet until the swap actually takes place.
   127  
   128  Depending on the asset, there may be a wallet setting on the Wallets page to
   129  pre-size funding UTXOs to avoid this over-locking, but (1) it involves an extra
   130  transaction that pays to yourself before placing the order, which has on-chain
   131  transaction fees that may be undesirable on chains like BTC, and (2) it is only
   132  applied for limit orders with standing time-in-force since the the UTXOs are
   133  only locked until the swap transaction is broadcasted, which is relatively brief
   134  for taker-only orders that are never booked.
   135  
   136  ### Epochs
   137  
   138  An important concept with DCRDEX is that newly submitted orders are processed in
   139  short windows of time called **epochs**, the length of which is part of the
   140  server's market configuration, but is typically on the order of 10 seconds. When
   141  a valid order is received by the server, it enters into the pool of epoch orders
   142  before it is matched and/or booked. The motivation for this approach is
   143  described in detail in the [DCRDEX specification](../../spec/README.mediawiki).
   144  The Your Orders table will show the status of such orders as "epoch" until they
   145  are matched at the end of the epoch, as described in the next section.
   146  
   147  Order cancellation requests are also processed in the epoch with trade
   148  (market/limit) orders since a cancellation is actually a type of order. However,
   149  from the user's perspective, cancelling an order is simply a matter of clicking
   150  the cancel icon for one of their booked orders.
   151  
   152  ### Matching
   153  
   154  When the end of an epoch is reached, the orders it includes are then matched
   155  with the orders that are already on the book. A key concept of DCRDEX order
   156  matching is a deterministic algorithm for shuffling the epoch orders so that it
   157  is difficult for a user to game the system. To perform the shuffling of the
   158  closed epoch prior to matching, clients with orders in the epoch must provide to
   159  the server a special value for each of their orders called a **preimage**, which
   160  must correspond to another value that was provided when the order was initially
   161  submitted called the **commitment**. This is done automatically by dexc,
   162  requiring no action from the user.
   163  
   164  If an order fails to match with another order, it will become either **booked**
   165  or **executed** with no part of the order filled. The Your Orders table displays
   166  the current status and remaining quantity of each of a user's orders. If an
   167  order does match with another trade order, the order status will become
   168  **settling**, and atomic swap negotiation begins. A cancel order may also fail
   169  to match if another trade matches with the targeted order first, or it may match
   170  after the targeted order is partially filled in the same epoch.
   171  
   172  ### Settlement
   173  
   174  When maker orders (on the book) are matched with taker orders (from an epoch),
   175  the atomic swap sequence begins. No action is required from either user during
   176  the process.
   177  
   178  In the current atomic swap protocol, the **maker initiates** by broadcasting a
   179  transaction with a swap contract on the relevant asset network, and informing
   180  the server of the transaction and the full contract. The server audits the
   181  contract, and if it is successfully validated, the information is relayed to the
   182  taker, who independently audits the contract to ensure it meets their
   183  expectations. The transaction containing the maker's swap contract must then be
   184  mined and reach the **swap confirmation requirement**, which is also a market
   185  setting. For example, Bitcoin might require 3 confirmations while other chains
   186  like Litecoin might be considerably more. When the required number of
   187  confirmations is reached, the **taker participates** by broadcasting a
   188  transaction with their swap contract and informing the server. Again, the server
   189  and the counterparty audit the contract and wait for that asset's swap
   190  confirmation requirement. When the required confirmations are reached, the
   191  **maker redeems** the taker's contract and informs the server of the redemption
   192  transaction. This is the end of the process for the maker, as the redemption
   193  spends the taker's contract, paying to an address controlled by the maker. The
   194  server relays the maker's redeem data to the taker, and the **taker redeems**
   195  immediately, ending the swap.
   196  
   197  The Order Details page shows each match associated with an order. For example, a
   198  match where the user was the taker is shown below with links to block explorers
   199  for each of the transactions described above. The maker will have their
   200  redemption listed, but not the taker's.
   201  
   202  ![match details](https://user-images.githubusercontent.com/9373513/97028559-eda43d80-1521-11eb-9ab6-2e0b21df584d.png)
   203  
   204  Orders may be partially filled in increments of the lot size. Hence a single
   205  order may have more than one match (and thus swap) associated with it, each of
   206  which will be shown on the Order Details page.
   207  
   208  Wallet balances will change during swap negotiation. When the client broadcasts
   209  their swap contract, the amount locked in that contract will go into the
   210  "locked" row for the asset that funded the order. When the counterparty redeems
   211  their contract, that amount will be reduced by the contract amount, and the user
   212  will redeem the counterparty contract, thus adding to the balance of the other
   213  asset. This is the essence of the atomic swap. Note that until the redemption
   214  transactions are confirmed, the redeemed amount may remain in the wallet's
   215  "immature" balance category, but this depends on the asset.
   216  
   217  ### Revoked Matches
   218  
   219  While the atomic swap process requires no party to trust the other, a swap may
   220  be forced into an alternate path ending in one or both users refunding
   221  themselves by spending their own contract after the lock time expires. This
   222  happens when one of the parties fails to act in the expected time frame, an
   223  **inaction timeout**. When an inaction timeout occurs the following happens:
   224  
   225  - The match is revoked, and both parties are notified.
   226  - The at-fault user has their order revoked (if it was partially filled and
   227    still booked) and is notified.
   228  - The at-fault user has their score adjusted according to type of match failure.
   229    See below for descriptions of each type and the associated user score
   230    adjustments.
   231  
   232  The general categories of match failures are:
   233  
   234  - `NoMakerSwap`: A match is made, but the maker does not initiate the swap. No
   235    transactions are created in this case.
   236  - `NoTakerSwap`: The maker (initiator) broadcasts their swap contract
   237    transaction and informs the server, but the taker (participant) fails to
   238    broadcast their swap contract and inform the server. The maker will
   239    automatically refund their contract when it expires after 20 hrs.
   240  - `NoMakerRedeem`: The taker broadcasts their swap and informs the server, but
   241    the maker does not redeem it. The taker will refund when their contract
   242    expires after 8 hrs. Note that the taker's client begins watching for an
   243    unannounced redeem of their contract by the maker, which reveals the secret
   244    and permits the taker to redeem as well, completing the swap although in a
   245    potentially extended time frame.
   246  - `NoTakerRedeem`: The maker redeems the taker's contract and informs the
   247    server, but the taker fails to redeem the maker's contract even though they
   248    can do so at any time. This case is not disruptive to the counterparty, and is
   249    only detrimental to the takers, so it is of minimal concern.
   250  
   251  NOTE: The *order* remaining amounts are still reduced at match time although
   252  they did not settle that portion of the order.
   253  
   254  ### User Scoring
   255  
   256  Users have an incentive to respond with their preimage for their submitted
   257  orders and to complete swaps as the match negotiation protocol specifies, and if
   258  they repeatedly fail to act as required, their account may be suspended. This
   259  may require either communicating an excusable reason for the issue to the server
   260  operator, or registering a new account. However, a reasonable scoring system is
   261  established to balance the need to deter intentional disruptions with the
   262  reality of unreliable consumer networks and other such technical issues.
   263  
   264  In this release, there are two primary inaction violations that adjust a users
   265  score: (1) failure to respond with a preimage for an order when the epoch for
   266  that order is closed (preimage miss), and (2) swap negotiation resulting in
   267  match revocation as described in the [previous section](#revoked-matches).
   268  
   269  The score threshold at which an account becomes suspended (penalty threshold) is
   270  an operator set variable, but the default is 20.
   271  
   272  The adjustment to the at-fault user's score depends on the match failure:
   273  
   274  | Match Outcome   | Points | Notes                                              |
   275  |-----------------|-------:|----------------------------------------------------|
   276  | `NoMakerSwap`   |      4 | book spoof, taker needs new order, no locked funds |
   277  | `NoTakerSwap`   |     11 | maker has contract stuck for 20 hrs                |
   278  | `NoMakerRedeem` |      7 | taker has contract stuck for 8 hrs                 |
   279  | `NoTakerRedeem` |      1 | counterparty not inconvenienced, only self         |
   280  | `Success`       |     -1 | offsets violations                                 |
   281  
   282  A preimage miss adds 2 points to the users score.
   283  
   284  The above scoring system should be considered tentative while it is evaluated in
   285  the wild.
   286  
   287  ### Order Size Limits
   288  
   289  This release uses an experimental system to set the maximum order quantity based
   290  on their swap history. It is likely to change, but it is described in [PR #750](https://github.com/decred/dcrdex/pull/750).
   291  
   292  ## Code summary
   293  
   294  This release consists of 473 pull requests comprising 506 commits from 12
   295  contributors.
   296  
   297  Contributors (alphabetical order):
   298  
   299  - Brian Stafford (@buck54321)
   300  - David Hill (@dajohi)
   301  - @degeri
   302  - Donald Adu-Poku (@dnldd)
   303  - Fernando Abolafio (@fernandoabolafio)
   304  - Joe Gruffins (@JoeGruffins)
   305  - Jonathan Chappelow (@chappjc)
   306  - Kevin Wilde (@kevinstl)
   307  - @song50119
   308  - Victor Oliveira (@vctt94)
   309  - Wisdom Arerosuoghene (@itswisdomagain)
   310  - @zeoio
   311  
   312  (there is no previous release to which a diff can be made)