Skip to content

Commit

Permalink
spec: Update admin.mediawiki (#2470)
Browse files Browse the repository at this point in the history
* spec: Update admin.mediawiki

 - Fix broken links
 - Add missing endpoints
 - spec: fix broken links in fundamentals and orders .mediawiki pages

Signed-off-by: Philemon Ukane <ukanephilemon@gmail.com>
  • Loading branch information
ukane-philemon authored Aug 28, 2023
1 parent f1d2919 commit 93ae8f5
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 50 deletions.
9 changes: 6 additions & 3 deletions server/admin/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ func (s *Server) apiConfig(w http.ResponseWriter, _ *http.Request) {
writeJSON(w, s.core.ConfigMsg())
}

// apiAsset is the handler for the '/asset/{assetID}' API request.
// apiAsset is the handler for the '/asset/{"assetSymbol"}' API request.
func (s *Server) apiAsset(w http.ResponseWriter, r *http.Request) {
assetSymbol := strings.ToLower(chi.URLParam(r, assetSymKey))
assetSymbol := strings.ToLower(chi.URLParam(r, assetSymbol))
assetID, found := dex.BipSymbolID(assetSymbol)
if !found {
http.Error(w, fmt.Sprintf("unknown asset %q", assetSymbol), http.StatusBadRequest)
Expand Down Expand Up @@ -104,8 +104,10 @@ func (s *Server) apiAsset(w http.ResponseWriter, r *http.Request) {
writeJSON(w, res)
}

// apiSetFeeScale is the handler for the
// '/asset/{"assetSymbol"}/setfeescale/{"scaleKey"}' API request.
func (s *Server) apiSetFeeScale(w http.ResponseWriter, r *http.Request) {
assetSymbol := strings.ToLower(chi.URLParam(r, assetSymKey))
assetSymbol := strings.ToLower(chi.URLParam(r, assetSymbol))
assetID, found := dex.BipSymbolID(assetSymbol)
if !found {
http.Error(w, fmt.Sprintf("unknown asset %q", assetSymbol), http.StatusBadRequest)
Expand All @@ -131,6 +133,7 @@ func (s *Server) apiSetFeeScale(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
}

// apiMarkets is the handler for the '/markets' API request.
func (s *Server) apiMarkets(w http.ResponseWriter, r *http.Request) {
statuses := s.core.MarketStatuses()
mktStatuses := make(map[string]*MarketStatus)
Expand Down
4 changes: 2 additions & 2 deletions server/admin/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const (
accountIDKey = "account"
yesKey = "yes"
matchIDKey = "match"
assetSymKey = "asset"
assetSymbol = "asset"
ruleKey = "rule"
scaleKey = "scale"
includeInactiveKey = "includeinactive"
Expand Down Expand Up @@ -147,7 +147,7 @@ func NewServer(cfg *SrvConfig) (*Server, error) {
rm.Get("/forgive_match/{"+matchIDKey+"}", s.apiForgiveMatchFail)
rm.Post("/notify", s.apiNotify)
})
r.Route("/asset/{"+assetSymKey+"}", func(rm chi.Router) {
r.Route("/asset/{"+assetSymbol+"}", func(rm chi.Router) {
rm.Get("/", s.apiAsset)
rm.Get("/setfeescale/{"+scaleKey+"}", s.apiSetFeeScale)
})
Expand Down
24 changes: 16 additions & 8 deletions spec/admin.mediawiki
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ possible.
{|
! variable !! relevant section !! units || default
|-
| epoch&nbsp;duration || [[fundamentals.mediawiki/#Epochbased_Order_Matching|Epoch-based Order Matching]] || milliseconds || 20,000
| epoch&nbsp;duration || [[fundamentals.mediawiki/#epoch-based-order-matching|Epoch-based Order Matching]] || milliseconds || 20,000
|-
| market&nbsp;buy&nbsp;buffer || [[orders.mediawiki/#Market_Buy_Orders|Market Buy Orders]] || unitless ratio || 1.25
| market&nbsp;buy&nbsp;buffer || [[orders.mediawiki/#market-buy-orders|Market Buy Orders]] || unitless ratio || 1.25
|-
| registration&nbsp;fees || [[fundamentals.mediawiki/#Fees|Fees]] || atoms || 1e8 (1 DCR)
| bonds || [[fundamentals.mediawiki/#bonds|Bonds]] || atoms || 2e8 (2 DCR)
|-
| cancellation&nbsp;threshold || [[community.mediawiki/#Rule_3_An_accounts_cancellation_rate_must_not_exceed_the_threshold|Rule 3]] || unitless ratio || 0.6
| cancellation&nbsp;threshold || [[community.mediawiki/#rule-3-an-accounts-cancellation-rate-must-not-exceed-the-threshold|Rule 3]] || unitless ratio || 0.6
|-
| broadcast&nbsp;timeout || [[fundamentals.mediawiki/#Exchange_Variables|Exchange Variables]] &amp; [[community.mediawiki/#rule-1-clients-must-respond-to-all-preimage-requests|Rule 1]] || milliseconds || 60,000
| broadcast&nbsp;timeout || [[fundamentals.mediawiki/#exchange-variables|Exchange Variables]] &amp; [[community.mediawiki/#rule-1-clients-must-respond-to-all-preimage-requests|Rule 1]] || milliseconds || 60,000
|}

==Per-asset Variables==
Expand All @@ -34,14 +34,14 @@ possible.
|-
| lot&nbsp;size || atoms || the minimum order quantity and the order quantity increment when an asset is the base asset
|-
| rate&nbsp;step || atoms || the minimum price rate and the price rate increment when an asset is the quote asset. [[orders.mediawiki/#Rate_Encoding|message-rate encoding]]
| rate&nbsp;step || atoms || the minimum price rate and the price rate increment when an asset is the quote asset. [[orders.mediawiki/#rate-encoding|message-rate encoding]]
|-
| fee&nbsp;rate || atoms/byte || the minimum fee rate for swap transactions
|-
| swap&nbsp;confirmations|| count || the Minimum confirmations before acting on a swap transaction
|}

See also [[fundamentals.mediawiki/#Exchange_Variables|Exchange Variables]].
See also [[fundamentals.mediawiki/#exchange-variables|Exchange Variables]].

==Administration API==

Expand All @@ -51,7 +51,15 @@ The server will provide an HTTP API for performing various adminstrative tasks.
{|
! path !! method !! description
|-
| /config || GET || the current DEX configuration. See [[fundamentals.mediawiki/#Configuration_Data_Request|Configuration Data Request]]
| /ping || GET || checks if admin server is alive. Returns `pong` if server is still alive
|-
| /config || GET || the current DEX configuration. See [[fundamentals.mediawiki/#configuration-data-request|Configuration Data Request]]
|-
| /enabledataapi/{yes} || GET || enable or disable the HTTP data API. "yes" must be a valid BOOL value (e.g, true, false)
|-
| /asset/{assetSymbol} || GET || display information about specified asset symbol (e.g dcr, btc)
|-
| /asset/{assetSymbol}/setfeescale/{scale} || GET || sets the fee rate scale factor for the specified asset. The scale factor must be a valid float(e.g 2.0). The default is 1.0.
|-
| /accounts || GET || lists information about all known accounts
|-
Expand Down
12 changes: 6 additions & 6 deletions spec/fundamentals.mediawiki
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ __NOTOC__
** [[#configuration-data-request|Configuration Data Request]]
* [[#bonds|Bonds]]
* [[#transaction-fees|Transaction Fees]]
* [[#epochbased-order-matching|Epoch-based Order Matching]]
* [[#epoch-based-order-matching|Epoch-based Order Matching]]
** [[#epoch-time|Epoch Time]]
** [[#pseudorandom-order-matching|Pseudorandom Order Matching]]
* [[#identities-based-on-public-key-infrastructure-pki-key-pairs|Identification]]
Expand Down Expand Up @@ -128,15 +128,15 @@ The '''epoch duration''' (<code>epochlen</code>) is the length of one [[#epoch-t


If the client connects shortly after a
[[orders.mediawiki/#Trade_Suspension|trade suspension]], it's possible that
[[orders.mediawiki/#trade-suspension|trade suspension]], it's possible that
trading will not commence until a future epoch. This information can be found in the config response's '''market status'''
(<code>status</code>) which inclues a few variables:

* If the market has been or will be susupended, the '''start epoch''' (<code>start epoch</code>) will be populated for each market and contains which epoch index trading did or will begin.
* A '''final epoch''' (<code>finalepoch</code>) may also be present if the dex is scheduled to go into trade suspension. If this variable is present, there may also be a '''persists''' (<code>persistbook</code>) boolean that is true when booked orders will not be purged after market suspension.
The [[orders.mediawiki/#Market_Buy_Orders|'''market buy buffer''']] (<code>buybuffer</code>)
The [[orders.mediawiki/#market-buy-orders|'''market buy buffer''']] (<code>buybuffer</code>)
defines the minimum order size for a market buy order.

===Bond Asset Variables===
Expand Down Expand Up @@ -168,7 +168,7 @@ respond with its current configuration.
|-
| btimeout || int || the broadcast timeout
|-
| apiver || int || the server's [[#API_Version|api version]]
| apiver || int || the server's [[#api-version|api version]]
|-
| pubkey || bytes || the server's public ecdsa key
|-
Expand Down Expand Up @@ -236,7 +236,7 @@ respond with its current configuration.
|-
| ratestep || int || the price rate increment (atoms)
|-
| epochlen || int || the [[#epochbased-order-matching|epoch duration]] (milliseconds)
| epochlen || int || the [[#epoch-based-order-matching|epoch duration]] (milliseconds)
|-
| buybuffer || float || the [[orders.mediawiki/#market-buy-orders|market buy buffer]]
|-
Expand Down Expand Up @@ -264,7 +264,7 @@ add considerable complexity to the swap process and incentivize DEX operators to
facilitate wash trading.
Instead, time locked bonds are considered during registration. <!-- TODO: Create and link to bond specifics. -->
Locked funds discourage certain spam attacks and enable punitive actions when
[[community.mediawiki/#Rules_of_Community_Conduct|conduct rules]] are violated.
[[community.mediawiki/#rules-of-community-conduct|conduct rules]] are violated.

==Transaction Fees==

Expand Down
62 changes: 31 additions & 31 deletions spec/orders.mediawiki
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,26 @@ overview of the settlement process.

There are three available types of order.

* [[#Limit_Order|Limit orders]] are used to buy or sell a specified amount of an asset at a rate no higher (buy) or lower (sell) than a specified price.
* [[#Market_Order|Market orders]] are used to buy or sell a specified amount of an asset at the best price available.
* [[#Cancel_Order|Cancel orders]] are used to remove standing limit orders from the order book.
* [[#limit-order|Limit orders]] are used to buy or sell a specified amount of an asset at a rate no higher (buy) or lower (sell) than a specified price.
* [[#market-order|Market orders]] are used to buy or sell a specified amount of an asset at the best price available.
* [[#cancel-order|Cancel orders]] are used to remove standing limit orders from the order book.
The order book holds only limit orders with time in force ''standing'' that have
not completely filled or been canceled. All other orders are only valid for one
[[fundamentals.mediawiki/#Epochbased_Order_Matching|epoch match cycle]].
[[fundamentals.mediawiki/#epoch-based-order-matching|epoch match cycle]].

==Connection Persistence==

Regardless of connection status, if a client does not respond to their
<code>preimage</code> request, they are in violation of
[[community.mediawiki/#Rule_1_Clients_must_respond_to_all_preimage_requests|rule 1]] and subject to
[[community.mediawiki/#rule-1-clients-must-respond-to-all-preimage-requests|rule 1]] and subject to
penalty.

If a client's connection is lost during match negotiation, the client is
expected to reconnect and complete settlement.
Once a match is made, a client is always subject to violation of
[[community.mediawiki/#Rule_2_Every_match_must_be_fully_settled|rule 2]] via the
[[fundamentals.mediawiki/#Exchange_Variables|broadcast timeout]].
[[community.mediawiki/#rule-2-every-match-must-be-fully-settled|rule 2]] via the
[[fundamentals.mediawiki/#global-variables|broadcast timeout]].

==Order Book Subscriptions==

Expand Down Expand Up @@ -83,7 +83,7 @@ re-subscribe to the market to synchronize the order book from scratch.
|-
| qty || int || order size (atoms) || epoch_order, book_order
|-
| rate || int || price rate. [[comm.mediawiki/#Rate_Encoding|message-rate encoding]] || only set on limit orders
| rate || int || price rate. [[comm.mediawiki/#rate-encoding|message-rate encoding]] || only set on limit orders
|-
| tif || string || time in force. one of "i" for ''immediate'' or "s" for ''standing'' || only set on limit orders
|-
Expand Down Expand Up @@ -132,8 +132,8 @@ on the book with a reduced matchable quantity.

At the beginning of the matching cycle, the DEX will publish a list of order
preimages, the seed hash used for
[[fundamentals.mediawiki/#Pseudorandom_Order_Matching|order sequencing]], and the
[[#Preimage_Reveal|commitment checksum]], which together can be used to
[[fundamentals.mediawiki/#pseudorandom-order-matching|order sequencing]], and the
[[#preimage-reveal|commitment checksum]], which together can be used to
independently verify matching.

'''Notification route:''' <code>match_proof</code>, '''originator: ''' DEX
Expand Down Expand Up @@ -173,7 +173,7 @@ WebSocket connection.

As part of the order, the client must demonstrate control of funds.
This is accomplished by supplying information and a signature for each
[[comm.mediawiki/#Coin_ID|coin]] that will be spent.
[[comm.mediawiki/#coin-id|coin]] that will be spent.
The client covers the ''backing fees'' associated with the inputs spending their
own coins.

Expand Down Expand Up @@ -220,7 +220,7 @@ The DEX will verify the coin sum before accepting the order.
With the exception of market buy orders, which are detailed below, for an order
of quantity '''''Q''''', the sum value of the selected coins, '''''V''''',
must satisfy the relation
(with [[#Calculating_Transaction_Fees|fees]])
(with [[#calculating-transaction-fees|fees]])

<!--V \ge Q + f_{base} + f_{coin}-->
[[File:images/coin-sum.png]]
Expand Down Expand Up @@ -277,10 +277,10 @@ The client responds with their preimage(s). If the client fails to respond to
their <code>preimage</code> requests, or if their <code>preimage</code> response
does not hash to their order commitment, the order is not matched and the client
is considered in violation of
[[community.mediawiki/#Rule_1_Clients_must_respond_to_all_preimage_requests|rule 1]].
[[community.mediawiki/#rule-1-clients-must-respond-to-all-preimage-requests|rule 1]].

The preimages are used as the inputs to
[[fundamentals.mediawiki/#Pseudorandom_Order_Matching|the shuffling algorithm]] to determine
[[fundamentals.mediawiki/#pseudorandom-order-matching|the shuffling algorithm]] to determine
matching order. Before matching commences, the preimages are broadcast
in the <code>match_proof</code> message.

Expand All @@ -290,7 +290,7 @@ All orders must be signed by the client and the server.
The basic signing procedure will involve serializing order data into a byte array
following a specific procedure that can be replicated on the server.
The serialized data is then signed using the client's
[[fundamentals.mediawiki/#Identities_based_on_Public_Key_Infrastructure_PKI_Key_Pairs|private account key]].
[[fundamentals.mediawiki/#identities-based-on-public-key-infrastructure-pki-key-pairs|private account key]].

All integer encoding for all serialized structures is big endian.

Expand Down Expand Up @@ -357,7 +357,7 @@ The client may specify the ''time in force'' of a limit order as one of: (a)
such, the ''immediate'' option is intended for limit orders with a price that
crosses the spread (i.e. a taker rather than a maker). The
<code>ordersize</code> must be an integer multiple of the asset's
[[fundamentals.mediawiki/#Exchange_Variables|lot size]].
[[fundamentals.mediawiki/#global-variabless|lot size]].

'''Request route:''' <code>limit</code>, '''originator:''' client

Expand All @@ -371,7 +371,7 @@ crosses the spread (i.e. a taker rather than a maker). The
|-
| ordersize || int || order size (atoms)
|-
| rate || int || price rate. [[comm.mediawiki/#Rate_Encoding|message-rate encoding]]
| rate || int || price rate. [[comm.mediawiki/#rate-encoding|message-rate encoding]]
|-
| timeinforce || int || standing = 1, immediate = 2
|-
Expand All @@ -387,17 +387,17 @@ crosses the spread (i.e. a taker rather than a maker). The
{|
! field !! size (bytes) !! description
|-
| prefix || 99 || [[#Order_Signing|the order prefix]]
| prefix || 99 || [[#order-signing|the order prefix]]
|-
| coin count || 1 || The number of funding coins
|-
| coin data || coin length x count || [[#Coin_Preparation|sequence of coin IDs]]
| coin data || coin length x count || [[#coin-preparation|sequence of coin IDs]]
|-
| side || 1 || 1 for buy, 2 for sell
|-
| quantity || 8 || quantity to buy or sell (atoms)
|-
| rate || 8 || price rate. [[comm.mediawiki/#Rate_Encoding|message-rate encoding]]
| rate || 8 || price rate. [[comm.mediawiki/#rate-encoding|message-rate encoding]]
|-
| time in force || 1 || 1 for ''standing'', 2 for ''immediate''
|-
Expand Down Expand Up @@ -435,7 +435,7 @@ the epoch match cycle) is left unfilled.
|-
| ordersize || int || order size (atoms)
|-
| coins || &#91;[[#Coin_Preparation|Coin]]&#93; || array of funding coins
| coins || &#91;[[#coin-preparation|Coin]]&#93; || array of funding coins
|-
| address || string || address where the matched client will send funds
|-
Expand All @@ -447,11 +447,11 @@ the epoch match cycle) is left unfilled.
{|
! field !! size (bytes) !! description
|-
| prefix || 99 || [[#Order_Signing|the order prefix]]
| prefix || 99 || [[#order-signing|the order prefix]]
|-
| coin count || 1 || The number of funding coins
|-
| coin data || coin length x count || [[#Coin_Preparation|sequence of coin IDs]]
| coin data || coin length x count || [[#coin-preparation|sequence of coin IDs]]
|-
| side || 1 || 1 for buy, 2 for sell
|-
Expand Down Expand Up @@ -506,7 +506,7 @@ If the ''market buy buffer'' is set too low or the market is particularly
volatile and the price exceeds '''''b<sub>m</sub> r''''', an order that was
accepted but is now too small to match is considered executed but unfilled and
there is no change to the account's
[[community.mediawiki/#Rules_of_Community_Conduct|cancellation statistics]].
[[community.mediawiki/#rules-of-community-conduct|cancellation statistics]].

===Cancel Order===

Expand Down Expand Up @@ -536,7 +536,7 @@ This is by design and discourages certain types of spoofing.
{|
! field !! size (bytes) !! description
|-
| prefix || 99 || [[#Order_Signing|the order prefix]]
| prefix || 99 || [[#order-signing|the order prefix]]
|-
| orderid || 32 || the order ID
|}
Expand Down Expand Up @@ -621,7 +621,7 @@ transaction and inform the server with an <code>init</code> notification
|-
| qty || int || the matched amount, in atoms of the base asset
|-
| rate || int || the matched price rate. [[comm.mediawiki/#Rate_Encoding|message-rate encoding]]
| rate || int || the matched price rate. [[comm.mediawiki/#rate-encoding|message-rate encoding]]
|-
| tserver || int || server's UNIX timestamp (milliseconds)
|-
Expand All @@ -645,7 +645,7 @@ transaction and inform the server with an <code>init</code> notification
|-
| quantity || 8 || the matched amount, in atoms of the base asset
|-
| rate || 8 || the matched price rate. [[comm.mediawiki/#Rate_Encoding|message-rate encoding]]
| rate || 8 || the matched price rate. [[comm.mediawiki/#rate-encoding|message-rate encoding]]
|-
| tserver || 8 || server's UNIX timestamp (milliseconds)
|-
Expand All @@ -670,7 +670,7 @@ relay to the matching party.
|-
| orderid || string || the order ID
|-
| matchid || string || the matchid, retrieved from the [[#Match_negotiation|match notification]]
| matchid || string || the matchid, retrieved from the [[#match-negotiation|match notification]]
|-
| coinid || string || hex-encoded coin ID
|-
Expand Down Expand Up @@ -889,7 +889,7 @@ records. No error is set in the case of unfound matches.
==Match Revocation==

A match can be revoked by the server if a client fails to act within the
[[fundamentals.mediawiki/#Exchange_Variables|broadcast timeout]]. A match revocation will result in
[[fundamentals.mediawiki/#global-variables|broadcast timeout]]. A match revocation will result in
penalties for the violating party only.
The revoked match quantity is not added back to the order book in any form.

Expand Down Expand Up @@ -941,7 +941,7 @@ This would be the case if the DEX needs to change an asset variable such as
the lot size or minimum transaction fee rate.

If standing limit orders are persisted, they will be auto-revoked if the client
does not reconnect before the next [[comm.mediawiki/#Session_Authentication|start epoch]].
does not reconnect before the next [[comm.mediawiki/#session-authentication|start epoch]].

'''Request route: ''' <code>suspension</code>, '''originator:''' DEX

Expand Down Expand Up @@ -969,5 +969,5 @@ Clients will also be informed when trading is resumed.
|-
| startepoch || uint64 || the epoch number at which trading did or will commence. May be in the future
|-
| epochlen || uint64 || the [[#Epochbased_Order_Matching|epoch duration]] (milliseconds)
| epochlen || uint64 || the [[#epoch-based-order-matching|epoch duration]] (milliseconds)
|}

0 comments on commit 93ae8f5

Please sign in to comment.