diff --git a/.prettierignore b/.prettierignore index e36c044020..c1cd4f7413 100644 --- a/.prettierignore +++ b/.prettierignore @@ -82,4 +82,5 @@ lib /packages/asset-swapper/test/generated-wrappers package.json packages/*/docs +docs/ *.sol diff --git a/docs/.gitignore b/docs/.gitignore new file mode 100644 index 0000000000..06aa0e522f --- /dev/null +++ b/docs/.gitignore @@ -0,0 +1 @@ +_build* \ No newline at end of file diff --git a/docs/Makefile b/docs/Makefile new file mode 100644 index 0000000000..c04268ff1d --- /dev/null +++ b/docs/Makefile @@ -0,0 +1,177 @@ +# Makefile for Sphinx documentation +# + +# You can set these variables from the command line. +SPHINXOPTS = +SPHINXBUILD = sphinx-build +PAPER = +BUILDDIR = _build + +# User-friendly check for sphinx-build +ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1) +$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/) +endif + +# Internal variables. +PAPEROPT_a4 = -D latex_paper_size=a4 +PAPEROPT_letter = -D latex_paper_size=letter +ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . +# the i18n builder cannot share the environment and doctrees with the others +I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . + +.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext + +help: + @echo "Please use \`make ' where is one of" + @echo " html to make standalone HTML files" + @echo " dirhtml to make HTML files named index.html in directories" + @echo " singlehtml to make a single large HTML file" + @echo " pickle to make pickle files" + @echo " json to make JSON files" + @echo " htmlhelp to make HTML files and a HTML help project" + @echo " qthelp to make HTML files and a qthelp project" + @echo " devhelp to make HTML files and a Devhelp project" + @echo " epub to make an epub" + @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" + @echo " latexpdf to make LaTeX files and run them through pdflatex" + @echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx" + @echo " text to make text files" + @echo " man to make manual pages" + @echo " texinfo to make Texinfo files" + @echo " info to make Texinfo files and run them through makeinfo" + @echo " gettext to make PO message catalogs" + @echo " changes to make an overview of all changed/added/deprecated items" + @echo " xml to make Docutils-native XML files" + @echo " pseudoxml to make pseudoxml-XML files for display purposes" + @echo " linkcheck to check all external links for integrity" + @echo " doctest to run all doctests embedded in the documentation (if enabled)" + +clean: + rm -rf $(BUILDDIR)/* + +html: + $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html + @echo + @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." + +dirhtml: + $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml + @echo + @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." + +singlehtml: + $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml + @echo + @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." + +pickle: + $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle + @echo + @echo "Build finished; now you can process the pickle files." + +json: + $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json + @echo + @echo "Build finished; now you can process the JSON files." + +htmlhelp: + $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp + @echo + @echo "Build finished; now you can run HTML Help Workshop with the" \ + ".hhp project file in $(BUILDDIR)/htmlhelp." + +qthelp: + $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp + @echo + @echo "Build finished; now you can run "qcollectiongenerator" with the" \ + ".qhcp project file in $(BUILDDIR)/qthelp, like this:" + @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/ReadtheDocsTemplate.qhcp" + @echo "To view the help file:" + @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/ReadtheDocsTemplate.qhc" + +devhelp: + $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp + @echo + @echo "Build finished." + @echo "To view the help file:" + @echo "# mkdir -p $$HOME/.local/share/devhelp/ReadtheDocsTemplate" + @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/ReadtheDocsTemplate" + @echo "# devhelp" + +epub: + $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub + @echo + @echo "Build finished. The epub file is in $(BUILDDIR)/epub." + +latex: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo + @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." + @echo "Run \`make' in that directory to run these through (pdf)latex" \ + "(use \`make latexpdf' here to do that automatically)." + +latexpdf: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo "Running LaTeX files through pdflatex..." + $(MAKE) -C $(BUILDDIR)/latex all-pdf + @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." + +latexpdfja: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo "Running LaTeX files through platex and dvipdfmx..." + $(MAKE) -C $(BUILDDIR)/latex all-pdf-ja + @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." + +text: + $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text + @echo + @echo "Build finished. The text files are in $(BUILDDIR)/text." + +man: + $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man + @echo + @echo "Build finished. The manual pages are in $(BUILDDIR)/man." + +texinfo: + $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo + @echo + @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." + @echo "Run \`make' in that directory to run these through makeinfo" \ + "(use \`make info' here to do that automatically)." + +info: + $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo + @echo "Running Texinfo files through makeinfo..." + make -C $(BUILDDIR)/texinfo info + @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." + +gettext: + $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale + @echo + @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." + +changes: + $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes + @echo + @echo "The overview file is in $(BUILDDIR)/changes." + +linkcheck: + $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck + @echo + @echo "Link check complete; look for any errors in the above output " \ + "or in $(BUILDDIR)/linkcheck/output.txt." + +doctest: + $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest + @echo "Testing of doctests in the sources finished, look at the " \ + "results in $(BUILDDIR)/doctest/output.txt." + +xml: + $(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml + @echo + @echo "Build finished. The XML files are in $(BUILDDIR)/xml." + +pseudoxml: + $(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml + @echo + @echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml." diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 0000000000..0aa8b4dcf5 --- /dev/null +++ b/docs/README.md @@ -0,0 +1,18 @@ +### Dependencies +```bash + pip3 install sphinx recommonmark +``` + +### Syntax +Documentation can be written in [Markdown](https://en.wikipedia.org/wiki/Markdown) (.md) or [Restructured Text](https://en.wikipedia.org/wiki/ReStructuredText) (.rst). + +### Build and Test +```bash +cd docs +make html +open _build/html/index.html +``` + +### Tips +* Generate RST tables [here](https://www.tablesgenerator.com/text_tables#). +* Set your editor's ruler to `100` characters. diff --git a/docs/_static/theme_overrides.css b/docs/_static/theme_overrides.css new file mode 100644 index 0000000000..b48b97d863 --- /dev/null +++ b/docs/_static/theme_overrides.css @@ -0,0 +1,13 @@ +/* override table width restrictions */ +@media screen and (min-width: 767px) { + + .wy-table-responsive table td { + /* !important prevents the common CSS stylesheets from overriding + this as on RTD they are loaded after this stylesheet */ + white-space: normal !important; + } + + .wy-table-responsive { + overflow: visible !important; + } + } \ No newline at end of file diff --git a/docs/additional/audits.rst b/docs/additional/audits.rst new file mode 100644 index 0000000000..472df02b06 --- /dev/null +++ b/docs/additional/audits.rst @@ -0,0 +1,3 @@ +############################### +Audits +############################### \ No newline at end of file diff --git a/docs/additional/bounties.rst b/docs/additional/bounties.rst new file mode 100644 index 0000000000..256c0bdf3f --- /dev/null +++ b/docs/additional/bounties.rst @@ -0,0 +1,3 @@ +############################### +Bounties +############################### \ No newline at end of file diff --git a/docs/additional/contributing.rst b/docs/additional/contributing.rst new file mode 100644 index 0000000000..f31cad546a --- /dev/null +++ b/docs/additional/contributing.rst @@ -0,0 +1,3 @@ +############################### +Contributing +############################### \ No newline at end of file diff --git a/docs/advanced/aggregation.rst b/docs/advanced/aggregation.rst new file mode 100644 index 0000000000..98f1abd9d9 --- /dev/null +++ b/docs/advanced/aggregation.rst @@ -0,0 +1,3 @@ +############################### +Aggregation +############################### \ No newline at end of file diff --git a/docs/advanced/erc20_transformations.rst b/docs/advanced/erc20_transformations.rst new file mode 100644 index 0000000000..6459556b91 --- /dev/null +++ b/docs/advanced/erc20_transformations.rst @@ -0,0 +1,3 @@ +############################### +ERC20 Transformations +############################### \ No newline at end of file diff --git a/docs/advanced/private_liquidity_pools.rst b/docs/advanced/private_liquidity_pools.rst new file mode 100644 index 0000000000..1254ee4bf6 --- /dev/null +++ b/docs/advanced/private_liquidity_pools.rst @@ -0,0 +1,3 @@ +############################### +Private Liquidity Poools +############################### \ No newline at end of file diff --git a/docs/advanced/request_for_quote.rst b/docs/advanced/request_for_quote.rst new file mode 100644 index 0000000000..d433caf4c5 --- /dev/null +++ b/docs/advanced/request_for_quote.rst @@ -0,0 +1,3 @@ +############################### +Request for Quote +############################### \ No newline at end of file diff --git a/docs/advanced/vip_paths.rst b/docs/advanced/vip_paths.rst new file mode 100644 index 0000000000..afdcdf5230 --- /dev/null +++ b/docs/advanced/vip_paths.rst @@ -0,0 +1,3 @@ +############################### +VIP Paths +############################### \ No newline at end of file diff --git a/docs/advanced/weth_wrapping.rst b/docs/advanced/weth_wrapping.rst new file mode 100644 index 0000000000..867d312281 --- /dev/null +++ b/docs/advanced/weth_wrapping.rst @@ -0,0 +1,3 @@ +############################### +WETH Wrapping +############################### \ No newline at end of file diff --git a/docs/architecture/features.rst b/docs/architecture/features.rst new file mode 100644 index 0000000000..943eb253a8 --- /dev/null +++ b/docs/architecture/features.rst @@ -0,0 +1,3 @@ +############################### +Features +############################### \ No newline at end of file diff --git a/docs/architecture/flash_wallet.rst b/docs/architecture/flash_wallet.rst new file mode 100644 index 0000000000..cbe627195a --- /dev/null +++ b/docs/architecture/flash_wallet.rst @@ -0,0 +1,3 @@ +############################### +Flash Wallet +############################### \ No newline at end of file diff --git a/docs/architecture/overview.rst b/docs/architecture/overview.rst new file mode 100644 index 0000000000..94353cd53f --- /dev/null +++ b/docs/architecture/overview.rst @@ -0,0 +1,3 @@ +############################### +Overview +############################### \ No newline at end of file diff --git a/docs/architecture/proxy.rst b/docs/architecture/proxy.rst new file mode 100644 index 0000000000..0ad5f7434b --- /dev/null +++ b/docs/architecture/proxy.rst @@ -0,0 +1,3 @@ +############################### +Proxy +############################### \ No newline at end of file diff --git a/docs/architecture/transformers.rst b/docs/architecture/transformers.rst new file mode 100644 index 0000000000..3cc92562f0 --- /dev/null +++ b/docs/architecture/transformers.rst @@ -0,0 +1,3 @@ +############################### +Transformers +############################### \ No newline at end of file diff --git a/docs/basics/allowances.rst b/docs/basics/allowances.rst new file mode 100644 index 0000000000..93ea7261a7 --- /dev/null +++ b/docs/basics/allowances.rst @@ -0,0 +1,12 @@ +############################### +Allowances +############################### + +.. _Allowance Target Address: https://github.com/0xProject/protocol/blob/development/packages/contract-addresses/addresses.json#L40 + +After the official release, allowances will be set directly on the Exchange V4 Proxy contract. +Presently, while we are in beta, allowances should be set on the `Allowance Target Address`_. + +The motivation for eliminating the separate Allowance Target in the official release is +to reduce transaction costs. Depending on the operational overhead for our integrators, +we may support allowances on both the Exchange V4 & the Allowance Target after the officual relase. \ No newline at end of file diff --git a/docs/basics/events.rst b/docs/basics/events.rst new file mode 100644 index 0000000000..129950b0cd --- /dev/null +++ b/docs/basics/events.rst @@ -0,0 +1,3 @@ +############################### +Events +############################### \ No newline at end of file diff --git a/docs/basics/functions.rst b/docs/basics/functions.rst new file mode 100644 index 0000000000..2141f99d9b --- /dev/null +++ b/docs/basics/functions.rst @@ -0,0 +1,3 @@ +############################### +Functions +############################### \ No newline at end of file diff --git a/docs/basics/orders.rst b/docs/basics/orders.rst new file mode 100644 index 0000000000..5c1d3535b3 --- /dev/null +++ b/docs/basics/orders.rst @@ -0,0 +1,522 @@ +###### +Orders +###### + +An order is a message passed into the 0x Protocol to facilitate an ERC20->ERC20 trade. There are currently two types of orders in 0x V4: Limit, RFQ. + + +.. note:: + As of v4 of the protocol, the maker address is no longer explicitly defined in limit orders. The maker is instead recovered from the signature of the order's EIP712 hash. + +.. note:: + 0x Orders currently support the exchange of ERC20 Tokens. Other asset classes, like ERC721, + will be added in the future based on community demand. + +Limit Orders +============== + +Limit orders are the standard 0x Order, which encodes a possible trade between a maker and taker at a fixed price. These orders are typically distributed via Mesh/SRA (open orderbook) or OTC, and can be filled through the ``fillOrder()`` function on the Exchange Proxy. + +Structure +--------- + +The ``LimitOrder`` struct has the following fields: + ++------------------+-------------+-----------------------------------------------------------------------------+ +| Field | Type | Description | ++==================+=============+=============================================================================+ +| ``makerToken`` | ``address`` | The ERC20 token the maker is selling and the maker is selling to the taker. | ++------------------+-------------+-----------------------------------------------------------------------------+ +| ``takerToken`` | ``address`` | The ERC20 token the taker is selling and the taker is selling to the maker. | ++------------------+-------------+-----------------------------------------------------------------------------+ +| ``makerAmount`` | ``uint128`` | The amount of makerToken being sold by the maker. | ++------------------+-------------+-----------------------------------------------------------------------------+ +| ``takerAmount`` | ``uint128`` | The amount of takerToken being sold by the taker. | ++------------------+-------------+-----------------------------------------------------------------------------+ +| ``feeRecipient`` | ``address`` | Recipient of maker token or taker token fees (if non-zero). | ++------------------+-------------+-----------------------------------------------------------------------------+ +| ``feeAmount`` | ``uint128`` | Amount of takerToken paid by the taker to the feeRecipient. | ++------------------+-------------+-----------------------------------------------------------------------------+ +| ``taker`` | ``address`` | Allowed taker address. Set to zero to allow any taker. | ++------------------+-------------+-----------------------------------------------------------------------------+ +| ``sender`` | ``address`` | Allowed address to directly call ``fillLimitOrder()`` (``msg.sender``). | +| | | This is distinct from ``taker`` in meta-transactions. | +| | | Set to zero to allow any caller. | ++------------------+-------------+-----------------------------------------------------------------------------+ +| ``pool`` | ``uint256`` | The staking pool to attribute the 0x protocol fee from this order. | +| | | Set to zero to attribute to the default pool, not owned by anyone. | ++------------------+-------------+-----------------------------------------------------------------------------+ +| ``expiry`` | ``uint64`` | The Unix timestamp in seconds when this order expires. | ++------------------+-------------+-----------------------------------------------------------------------------+ +| ``salt`` | ``uint256`` | Arbitrary number to enforce uniqueness of the order's hash. | ++------------------+-------------+-----------------------------------------------------------------------------+ + +Hashing limit orders +-------------------- + +There are two hashes associated with limit orders: the signature hash and the fill hash. The signature hash is what gets signed during the signing step. The fill hash is the hash used to uniquely identify an order inside the protocol and can be considered the "canonical" hash of the order. + +Computing the signature hash +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The signature hash is the hash of the order struct, following the `EIP712 spec `_. In solidity, the signature hash is computed as: + +.. code-block:: solidity + + bytes32 signatureHash = keccak256(abi.encodePacked( + '\x19\x01', + // The domain separator. + keccak256(abi.encode( + // The EIP712 domain separator type hash. + keccak256(abi.encodePacked( + 'EIP712Domain(', + 'string name,', + 'string version,', + 'uint256 chainId,', + 'address verifyingContract)' + )), + // The EIP712 domain separator values. + 'ZeroEx', + '1.0.0', + 1, // For mainnet + 0xDef1C0ded9bec7F1a1670819833240f027b25EfF, // Address of the Exchange Proxy + )), + // The struct hash. + keccak256(abi.encode( + // The EIP712 type hash. + keccak256(abi.encodePacked( + 'LimitOrder(', + 'address makerToken,', + 'address takerToken,', + 'uint128 makerAmount,', + 'uint128 takerAmount,', + 'address feeRecipient,', + 'uint128 feeAmount,', + 'address taker,', + 'address sender,', + 'uint256 pool,', + 'uint64 expiry,', + 'uint256 salt)' + )), + // The struct values. + order.makerToken, + order.takerToken, + order.makerAmount, + order.takerAmount, + order.feeRecipient, + order.feeAmount, + order.taker, + order.sender, + order.pool, + order.expiry, + order.salt + )) + )); + +Computing the fill hash +^^^^^^^^^^^^^^^^^^^^^^^^^ + +The fill hash simply hashes the previous signature hash with the maker's address, which can be recovered from the order's signature if not already known. + +.. code-block:: solidity + + // For EthSign signatures, the signatureHash would need to be replaced with + // keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", signatureHash)) + address makerAddress = ecrecover(signatureHash, signature.v, signature.r, signature.s); + bytes32 fillHash = keccak256(abi.encode(signatureHash, makerAddress)); + +Alternatively, the Exchange Proxy contract can be used to retrieve these hashes given an order and signature. + +.. code-block:: solidity + + bytes32 signatureHash = IZeroEx(0xDef1C0ded9bec7F1a1670819833240f027b25EfF).getLimitOrderSignatureHash(order); + bytes32 fillHash = IZeroEx(0xDef1C0ded9bec7F1a1670819833240f027b25EfF).getLimitOrderFillHash(order, signature); + +Signing limit orders +-------------------- + +Limit orders must be signed by the maker of the order. This signature must be passed into the fill function by the taker in order to fill the order. + +The protocol accepts signatures defined by the following struct: + +.. code-block:: solidity + + struct { + uint8 signatureType; // Either 2 or 3 + uint8 v; // Signature data. + bytes32 r; // Signature data. + bytes32 s; // Signature data. + } + +There are two types of signatures supported: ``EIP712`` and ``EthSign``. + +* The ``EIP712`` signature type is best for web frontends that present an order to be signed through Metamask in a human-readable format. It relies on the `eth_signTypedData `_ JSON-RPC method exposed by MetaMask. This signature has the ``signatureType`` of ``2``. +* The ``EthSign`` signature is best for use with headless providers, such as when using a geth node. This relies on the ``eth_sign`` JSON-RPC method common to all nodes. This signature has the ``signatureType`` of ``3``. + +In both cases, the ``@0x/order-utils`` package simplifies generating these signatures. + +.. code-block:: javascript + :linenos: + + const orderUtils = require('@0x/order-utils'); + const order = new orderUtils.LimitOrder({ + makerToken: '0x6B175474E89094C44Da98b954EedeAC495271d0F', // DAI + takerToken: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', // WETH + ... // Other fields + }); + // Generate an EIP712 signature + const signature = await order.signTypedDataAsync(web3.currentProvider, makerAddress); + // Generate an EthSign signature + const signature = await order.sign(web3.currentProvider, makerAddress); + +Filling limit orders +-------------------- + +Limit orders can be filled with the ``fillLimitOrder()`` or ``fillOrKillLimitOrder()`` functions on the Exchange Proxy. The address calling these function will be considered the "taker" of the order. + + +``fillLimitOrder()`` fills a single limit order for **up to** ``takerTokenFillAmount``: + +.. code-block:: solidity + + function fillLimitOrder( + // The order + LimitOrder calldata order, + // The signature + Signature calldata signature, + // How much taker token to fill the order with + uint256 takerTokenFillAmount + ) + external + payable + // How much maker token from the order the taker received. + returns (uint256 makerTokenFillAmount); + +``fillOrKillLimitOrder()`` fills a single limit order for **exactly** ``takerTokenFillAmount``: + +.. code-block:: solidity + + function fillOrKillLimitOrder( + // The order + LimitOrder calldata order, + // The signature + Signature calldata signature, + // How much taker token to fill the order with + uint256 takerTokenFillAmount + ) + external + payable + // How much maker token from the order the taker received. + returns (uint256 makerTokenFillAmount); + +Cancelling a limit order +------------------------ + +Because there is no way to un-sign an order that has been distributed, limit orders must be cancelled on-chain through ``cancelLimitOrder()``, ``batchCancelLimitOrders()`` or ``cancelLimitOrdersUpTo()`` functions. They can only be called by the order's maker. + +``cancelLimitOrder()`` cancels a single limit order created by the caller: + +.. code-block:: solidity + + function cancelLimitOrder( + // The order + LimitOrder calldata order + ) + external; + +``batchCancelLimitOrders()`` cancels multiple limit orders created by the caller: + +.. code-block:: solidity + + function batchCancelLimitOrders( + // The orders + LimitOrder[] calldata orders + ) + external; + +``cancelLimitOrdersUpTo()`` will cancel limit orders created by the caller with a ``salt`` field <= the value provided. Subsequent calls to this function must provide a ``salt`` >= the last call to succeed. + +.. code-block:: solidity + + function cancelLimitOrdersUpTo( + uint256 salt; + ) + external; + +Getting the status of a limit order +----------------------------------- + +The Exchange Proxy exposes a function ``getLimitOrderInfo()`` to query information about a limit order, such as its fillable state and how much it has been filled by. + +.. code-block:: solidity + + enum OrderState { + INVALID, + CANCELLED, + FILLABLE, + FILLED + } + + struct OrderInfo { + // The fill hash. + bytes32 fillHash; + // Current state of the order. + OrderState state; + // How much taker token has been filled in the order. + uint256 takerTokenFilledAmount; + } + + function getLimitOrderInfo( + // The order + LimitOrder calldata order, + // The signature + Signature calldata signature + ) + external + view + returns (OrderInfo memory status); + +RFQ Orders +========== + +RFQ orders are a stripped down version of standard limit orders, supporting fewer fields and a leaner settlement process. These orders are fielded just-in-time, directly from market makers, during the construction of a swap quote on 0x API, and can be filled through the ``fillRfqOrder()`` function on the Exchange Proxy. + +Some notable differences from regular limit orders are: + +* RFQ orders can only be filled once. Even a partial fill will mark the order as ``FILLED``. +* The only fill restrictions that can be placed on an RFQ order is on the ``tx.origin`` of the transaction. +* There are no taker token fees. + +Structure +---------- + +The ``RFQOrder`` struct has the following fields: + ++-----------------+-------------+-----------------------------------------------------------------------------+ +| Field | Type | Description | ++=================+=============+=============================================================================+ +| ``makerToken`` | ``address`` | The ERC20 token the maker is selling and the maker is selling to the taker. | ++-----------------+-------------+-----------------------------------------------------------------------------+ +| ``takerToken`` | ``address`` | The ERC20 token the taker is selling and the taker is selling to the maker. | ++-----------------+-------------+-----------------------------------------------------------------------------+ +| ``makerAmount`` | ``uint128`` | The amount of makerToken being sold by the maker. | ++-----------------+-------------+-----------------------------------------------------------------------------+ +| ``takerAmount`` | ``uint128`` | The amount of takerToken being sold by the taker. | ++-----------------+-------------+-----------------------------------------------------------------------------+ +| ``txOrigin`` | ``address`` | The allowed address of the EOA that submitted the Ethereum transaction. | ++-----------------+-------------+-----------------------------------------------------------------------------+ +| ``pool`` | ``uint256`` | The staking pool to attribute the 0x protocol fee from this order. | +| | | Set to zero to attribute to the default pool, not owned by anyone. | ++-----------------+-------------+-----------------------------------------------------------------------------+ +| ``expiry`` | ``uint64`` | The Unix timestamp in seconds when this order expires. | ++-----------------+-------------+-----------------------------------------------------------------------------+ +| ``salt`` | ``uint256`` | Arbitrary number to enforce uniqueness of the order's hash. | ++-----------------+-------------+-----------------------------------------------------------------------------+ + +Hashing RFQ orders +------------------ + +There are two hashes associated with RFQ orders: the signature hash and the fill hash. The signature hash is what gets signed during the signing step. The fill hash is the hash used to uniquely identify an order inside the protocol and can be considered the "canonical" hash of the order. + +Computing the signature hash +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The signature hash is the hash of the order struct, following the `EIP712 spec `_. In solidity, the signature hash is computed as: + +.. code-block:: solidity + + bytes32 signatureHash = keccak256(abi.encodePacked( + '\x19\x01', + // The domain separator. + keccak256(abi.encode( + // The EIP712 domain separator type hash. + keccak256(abi.encodePacked( + 'EIP712Domain(', + 'string name,', + 'string version,', + 'uint256 chainId,', + 'address verifyingContract)' + )), + // The EIP712 domain separator values. + 'ZeroEx', + '1.0.0', + 1, // For mainnet + 0xDef1C0ded9bec7F1a1670819833240f027b25EfF, // Address of the Exchange Proxy + )), + // The struct hash. + keccak256(abi.encode( + // The EIP712 type hash. + keccak256(abi.encodePacked( + 'RfqOrder(', + 'address makerToken,', + 'address takerToken,', + 'uint128 makerAmount,', + 'uint128 takerAmount,', + 'address txOrigin,' + 'uint256 pool,', + 'uint64 expiry,', + 'uint256 salt)' + )), + // The struct values. + order.makerToken, + order.takerToken, + order.makerAmount, + order.takerAmount, + order.txOrigin, + order.pool, + order.expiry, + order.salt + )) + )); + +Computing the fill hash +^^^^^^^^^^^^^^^^^^^^^^^ + +The fill hash simply hashes the previous signature hash with the maker's address, which can be recovered from the order's signature if not already known. + +.. code-block:: solidity + + // For EthSign signatures, the signatureHash would need to be replaced with + // keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", signatureHash)) + address makerAddress = ecrecover( + keccak256(abi.encodePacked( + '\x19Ethereum Signed Message:\n32', + signatureHash + )), + signature.v, + signature.r, + signature.s + ); + bytes32 fillHash = keccak256(abi.encode(signatureHash, makerAddress)); + +Alternatively, the Exchange Proxy contract can be used to retrieve these hashes given an order and signature. + +.. code-block:: solidity + + bytes32 signatureHash = IZeroEx(0xDef1C0ded9bec7F1a1670819833240f027b25EfF).getRfqOrderSignatureHash(order); + bytes32 fillHash = IZeroEx(0xDef1C0ded9bec7F1a1670819833240f027b25EfF).getRfqOrderFillHash(order, signature); + +Signing RFQ orders +------------------ + +RFQ orders must be signed by the maker of the order. This signature must be passed into the fill function by the taker in order to fill the order. + +The protocol accepts signatures defined by the following struct: + +.. code-block:: solidity + + struct { + uint8 v; // Signature data. + bytes32 r; // Signature data. + bytes32 s; // Signature data. + } + +The ``@0x/order-utils`` node package simplifies the process of creating a valid signature object. + +.. code-block:: javascript + :linenos: + + const orderUtils = require('@0x/order-utils'); + const order = new orderUtils.RfqOrder({ + makerToken: '0x6B175474E89094C44Da98b954EedeAC495271d0F', // DAI + takerToken: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', // WETH + ... // Other fields + }); + const signature = await order.sign(web3.currentProvider, makerAddress); + +Filling RFQ Orders +------------------ + +RFQ orders can be filled with the ``fillRfqOrder()`` or ``fillOrKillRfqOrder()`` functions on the Exchange Proxy. The address calling this function will be considered the "taker" of the order. + +``fillRfqOrder()`` fills a single RFQ order for **up to** ``takerTokenFillAmount``: + +.. code-block:: solidity + + function fillRfqOrder( + // The order + RfqOrder calldata order, + // The signature + Signature calldata signature, + // How much taker token to fill the order with + uint256 takerTokenFillAmount + ) + external + payable + // How much maker token from the order the taker received. + returns (uint256 makerTokenFillAmount); + +``fillOrKillRfqOrder()`` fills a single RFQ order for **exactly** ``takerTokenFillAmount``: + +.. code-block:: solidity + + function fillOrKillRfqOrder( + // The order + RfqOrder calldata order, + // The signature + Signature calldata signature, + // How much taker token to fill the order with + uint256 takerTokenFillAmount + ) + external + payable + // How much maker token from the order the taker received. + returns (uint256 makerTokenFillAmount); + +Cancelling an RFQ order +----------------------- + +Similar to limit orders, RFQ orders can be cancelled on-chain through ``cancelRfqOrder()`` or ``batchCancelRfqOrders()`` (but there is no ``...UpTo()`` variant). Both can only be called by the order's maker. + +``cancelRfqOrder()`` cancels a single RFQ order created by the caller: + +.. code-block:: solidity + + function cancelRfqOrder( + // The order + RfqOrder calldata order + ) + external; + +``batchCancelRfqOrders()`` cancels multiple RFQ orders created by the caller: + +.. code-block:: solidity + + function batchCancelRfqOrders( + // The orders + RfqOrder[] calldata orders + ) + external; + +Getting the status of an RFQ order +---------------------------------- + +The Exchange Proxy exposes a function ``getRfqOrderInfo()`` to query information about an RFQ order, such as its fillable state and how much it has been filled by. + +.. code-block:: solidity + + enum OrderState { + INVALID, + CANCELLED, + FILLABLE, + FILLED + } + + struct OrderInfo { + // The fill hash. + bytes32 fillHash; + // Current state of the order. + OrderState state; + // How much taker token has been filled in the order. + uint256 takerTokenFilledAmount; + } + + function getRfqOrderInfo( + // The order + RfqOrder calldata order, + // The signature + Signature calldata signature + ) + external + view + returns (OrderInfo memory status); diff --git a/docs/conf.py b/docs/conf.py new file mode 100644 index 0000000000..3c5c1c6bd3 --- /dev/null +++ b/docs/conf.py @@ -0,0 +1,268 @@ +# -*- coding: utf-8 -*- +# +# Read the Docs Template documentation build configuration file, created by +# sphinx-quickstart on Tue Aug 26 14:19:49 2014. +# +# This file is execfile()d with the current directory set to its +# containing dir. +# +# Note that not all possible configuration values are present in this +# autogenerated file. +# +# All configuration values have a default; values that are commented out +# serve to show the default. + +import sys +import os + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +#sys.path.insert(0, os.path.abspath('.')) + +# -- General configuration ------------------------------------------------ + +# If your documentation needs a minimal Sphinx version, state it here. +#needs_sphinx = '1.0' + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. +extensions = ['recommonmark'] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# The suffix of source filenames. +source_suffix = { + '.rst': 'restructuredtext', + '.txt': 'markdown', + '.md': 'markdown', +} + +# The encoding of source files. +#source_encoding = 'utf-8-sig' + +# The master toctree document. +master_doc = 'index' + +# General information about the project. +project = u'0x Protocol' +copyright = u'2016, ZeroEx Inc' + +# The version info for the project you're documenting, acts as replacement for +# |version| and |release|, also used in various other places throughout the +# built documents. +# +# The short X.Y version. +version = '1.0' +# The full version, including alpha/beta/rc tags. +release = '1.0' + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +#language = None + +# There are two options for replacing |today|: either, you set today to some +# non-false value, then it is used: +#today = '' +# Else, today_fmt is used as the format for a strftime call. +#today_fmt = '%B %d, %Y' + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +exclude_patterns = ['_build'] + +# The reST default role (used for this markup: `text`) to use for all +# documents. +#default_role = None + +# If true, '()' will be appended to :func: etc. cross-reference text. +#add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +#add_module_names = True + +# If true, sectionauthor and moduleauthor directives will be shown in the +# output. They are ignored by default. +#show_authors = False + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'sphinx' + +# A list of ignored prefixes for module index sorting. +#modindex_common_prefix = [] + +# If true, keep warnings as "system message" paragraphs in the built documents. +#keep_warnings = False + + +# -- Options for HTML output ---------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +html_theme = 'default' + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +#html_theme_options = {} + +# Add any paths that contain custom themes here, relative to this directory. +#html_theme_path = [] + +# The name for this set of Sphinx documents. If None, it defaults to +# " v documentation". +#html_title = None + +# A shorter title for the navigation bar. Default is the same as html_title. +#html_short_title = None + +# The name of an image file (relative to this directory) to place at the top +# of the sidebar. +#html_logo = None + +# The name of an image file (within the static path) to use as favicon of the +# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 +# pixels large. +#html_favicon = None + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ['_static'] + +html_context = { + 'css_files': [ + '_static/theme_overrides.css', # override wide tables in RTD theme + ], + } + +# Add any extra paths that contain custom files (such as robots.txt or +# .htaccess) here, relative to this directory. These files are copied +# directly to the root of the documentation. +#html_extra_path = [] + +# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, +# using the given strftime format. +#html_last_updated_fmt = '%b %d, %Y' + +# If true, SmartyPants will be used to convert quotes and dashes to +# typographically correct entities. +#html_use_smartypants = True + +# Custom sidebar templates, maps document names to template names. +#html_sidebars = {} + +# Additional templates that should be rendered to pages, maps page names to +# template names. +#html_additional_pages = {} + +# If false, no module index is generated. +#html_domain_indices = True + +# If false, no index is generated. +#html_use_index = True + +# If true, the index is split into individual pages for each letter. +#html_split_index = False + +# If true, links to the reST sources are added to the pages. +#html_show_sourcelink = True + +# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. +#html_show_sphinx = True + +# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. +#html_show_copyright = True + +# If true, an OpenSearch description file will be output, and all pages will +# contain a tag referring to it. The value of this option must be the +# base URL from which the finished HTML is served. +#html_use_opensearch = '' + +# This is the file name suffix for HTML files (e.g. ".xhtml"). +#html_file_suffix = None + +# Output file base name for HTML help builder. +htmlhelp_basename = 'ReadtheDocsTemplatedoc' + + +# -- Options for LaTeX output --------------------------------------------- + +latex_elements = { +# The paper size ('letterpaper' or 'a4paper'). +#'papersize': 'letterpaper', + +# The font size ('10pt', '11pt' or '12pt'). +#'pointsize': '10pt', + +# Additional stuff for the LaTeX preamble. +#'preamble': '', +} + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, +# author, documentclass [howto, manual, or own class]). +latex_documents = [ + ('index', 'ReadtheDocsTemplate.tex', u'Read the Docs Template Documentation', + u'Read the Docs', 'manual'), +] + +# The name of an image file (relative to this directory) to place at the top of +# the title page. +#latex_logo = None + +# For "manual" documents, if this is true, then toplevel headings are parts, +# not chapters. +#latex_use_parts = False + +# If true, show page references after internal links. +#latex_show_pagerefs = False + +# If true, show URL addresses after external links. +#latex_show_urls = False + +# Documents to append as an appendix to all manuals. +#latex_appendices = [] + +# If false, no module index is generated. +#latex_domain_indices = True + + +# -- Options for manual page output --------------------------------------- + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [ + ('index', 'readthedocstemplate', u'Read the Docs Template Documentation', + [u'Read the Docs'], 1) +] + +# If true, show URL addresses after external links. +#man_show_urls = False + + +# -- Options for Texinfo output ------------------------------------------- + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +texinfo_documents = [ + ('index', 'ReadtheDocsTemplate', u'Read the Docs Template Documentation', + u'Read the Docs', 'ReadtheDocsTemplate', 'One line description of project.', + 'Miscellaneous'), +] + +# Documents to append as an appendix to all manuals. +#texinfo_appendices = [] + +# If false, no module index is generated. +#texinfo_domain_indices = True + +# How to display URL addresses: 'footnote', 'no', or 'inline'. +#texinfo_show_urls = 'footnote' + +# If true, do not generate a @detailmenu in the "Top" node's menu. +#texinfo_no_detailmenu = False diff --git a/docs/contributing.rst b/docs/contributing.rst new file mode 100644 index 0000000000..e582053ea0 --- /dev/null +++ b/docs/contributing.rst @@ -0,0 +1 @@ +.. include:: ../CONTRIBUTING.rst diff --git a/docs/dummy.rst b/docs/dummy.rst new file mode 100644 index 0000000000..78c815da4c --- /dev/null +++ b/docs/dummy.rst @@ -0,0 +1,3 @@ +############################### +Dummy +############################### \ No newline at end of file diff --git a/docs/history.rst b/docs/history.rst new file mode 100644 index 0000000000..250649964b --- /dev/null +++ b/docs/history.rst @@ -0,0 +1 @@ +.. include:: ../HISTORY.rst diff --git a/docs/index.rst b/docs/index.rst new file mode 100644 index 0000000000..ea7a0903c6 --- /dev/null +++ b/docs/index.rst @@ -0,0 +1,68 @@ +0x Protocol +=========== + +.. image:: logo.svg + :width: 120px + :alt: 0x Protocol logo + :align: center + + +Contents +======== + +:ref:`Keyword Index `, :ref:`Search Page ` + +.. toctree:: + :maxdepth: 2 + :caption: Basics + + basics/orders.rst + basics/functions.rst + basics/events.rst + basics/allowances.rst + +.. toctree:: + :maxdepth: 2 + :caption: Advanced + + advanced/erc20_transformations.rst + advanced/aggregation.rst + advanced/weth_wrapping.rst + advanced/private_liquidity_pools.rst + advanced/request_for_quote.rst + +.. toctree:: + :maxdepth: 2 + :caption: Architecture + + architecture/overview.rst + architecture/proxy.rst + architecture/features.rst + architecture/flash_wallet.rst + architecture/transformers.rst + +.. toctree:: + :maxdepth: 2 + :caption: ZRX Tokenomics + + tokenomics/protocol_fees.rst + tokenomics/staking.rst + tokenomics/governance.rst + tokenomics/voting.rst + +.. toctree:: + :maxdepth: 2 + :caption: Additional Material + + additional/audits.rst + additional/bounties.rst + additional/contributing.rst + + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` + diff --git a/docs/installation.rst b/docs/installation.rst new file mode 100644 index 0000000000..9667188bd8 --- /dev/null +++ b/docs/installation.rst @@ -0,0 +1,7 @@ +============ +Installation +============ + +Install the package with pip:: + + $ pip install read-the-docs-template diff --git a/docs/logo.svg b/docs/logo.svg new file mode 100644 index 0000000000..d288659ba2 --- /dev/null +++ b/docs/logo.svg @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/docs/make.bat b/docs/make.bat new file mode 100644 index 0000000000..fec43bb8cb --- /dev/null +++ b/docs/make.bat @@ -0,0 +1,242 @@ +@ECHO OFF + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=sphinx-build +) +set BUILDDIR=_build +set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% . +set I18NSPHINXOPTS=%SPHINXOPTS% . +if NOT "%PAPER%" == "" ( + set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% + set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS% +) + +if "%1" == "" goto help + +if "%1" == "help" ( + :help + echo.Please use `make ^` where ^ is one of + echo. html to make standalone HTML files + echo. dirhtml to make HTML files named index.html in directories + echo. singlehtml to make a single large HTML file + echo. pickle to make pickle files + echo. json to make JSON files + echo. htmlhelp to make HTML files and a HTML help project + echo. qthelp to make HTML files and a qthelp project + echo. devhelp to make HTML files and a Devhelp project + echo. epub to make an epub + echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter + echo. text to make text files + echo. man to make manual pages + echo. texinfo to make Texinfo files + echo. gettext to make PO message catalogs + echo. changes to make an overview over all changed/added/deprecated items + echo. xml to make Docutils-native XML files + echo. pseudoxml to make pseudoxml-XML files for display purposes + echo. linkcheck to check all external links for integrity + echo. doctest to run all doctests embedded in the documentation if enabled + goto end +) + +if "%1" == "clean" ( + for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i + del /q /s %BUILDDIR%\* + goto end +) + + +%SPHINXBUILD% 2> nul +if errorlevel 9009 ( + echo. + echo.The 'sphinx-build' command was not found. Make sure you have Sphinx + echo.installed, then set the SPHINXBUILD environment variable to point + echo.to the full path of the 'sphinx-build' executable. Alternatively you + echo.may add the Sphinx directory to PATH. + echo. + echo.If you don't have Sphinx installed, grab it from + echo.http://sphinx-doc.org/ + exit /b 1 +) + +if "%1" == "html" ( + %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The HTML pages are in %BUILDDIR%/html. + goto end +) + +if "%1" == "dirhtml" ( + %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. + goto end +) + +if "%1" == "singlehtml" ( + %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml. + goto end +) + +if "%1" == "pickle" ( + %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; now you can process the pickle files. + goto end +) + +if "%1" == "json" ( + %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; now you can process the JSON files. + goto end +) + +if "%1" == "htmlhelp" ( + %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; now you can run HTML Help Workshop with the ^ +.hhp project file in %BUILDDIR%/htmlhelp. + goto end +) + +if "%1" == "qthelp" ( + %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; now you can run "qcollectiongenerator" with the ^ +.qhcp project file in %BUILDDIR%/qthelp, like this: + echo.^> qcollectiongenerator %BUILDDIR%\qthelp\complexity.qhcp + echo.To view the help file: + echo.^> assistant -collectionFile %BUILDDIR%\qthelp\complexity.ghc + goto end +) + +if "%1" == "devhelp" ( + %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. + goto end +) + +if "%1" == "epub" ( + %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The epub file is in %BUILDDIR%/epub. + goto end +) + +if "%1" == "latex" ( + %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. + goto end +) + +if "%1" == "latexpdf" ( + %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex + cd %BUILDDIR%/latex + make all-pdf + cd %BUILDDIR%/.. + echo. + echo.Build finished; the PDF files are in %BUILDDIR%/latex. + goto end +) + +if "%1" == "latexpdfja" ( + %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex + cd %BUILDDIR%/latex + make all-pdf-ja + cd %BUILDDIR%/.. + echo. + echo.Build finished; the PDF files are in %BUILDDIR%/latex. + goto end +) + +if "%1" == "text" ( + %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The text files are in %BUILDDIR%/text. + goto end +) + +if "%1" == "man" ( + %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The manual pages are in %BUILDDIR%/man. + goto end +) + +if "%1" == "texinfo" ( + %SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo. + goto end +) + +if "%1" == "gettext" ( + %SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The message catalogs are in %BUILDDIR%/locale. + goto end +) + +if "%1" == "changes" ( + %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes + if errorlevel 1 exit /b 1 + echo. + echo.The overview file is in %BUILDDIR%/changes. + goto end +) + +if "%1" == "linkcheck" ( + %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck + if errorlevel 1 exit /b 1 + echo. + echo.Link check complete; look for any errors in the above output ^ +or in %BUILDDIR%/linkcheck/output.txt. + goto end +) + +if "%1" == "doctest" ( + %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest + if errorlevel 1 exit /b 1 + echo. + echo.Testing of doctests in the sources finished, look at the ^ +results in %BUILDDIR%/doctest/output.txt. + goto end +) + +if "%1" == "xml" ( + %SPHINXBUILD% -b xml %ALLSPHINXOPTS% %BUILDDIR%/xml + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The XML files are in %BUILDDIR%/xml. + goto end +) + +if "%1" == "pseudoxml" ( + %SPHINXBUILD% -b pseudoxml %ALLSPHINXOPTS% %BUILDDIR%/pseudoxml + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The pseudo-XML files are in %BUILDDIR%/pseudoxml. + goto end +) + +:end diff --git a/docs/readme.rst b/docs/readme.rst new file mode 100644 index 0000000000..72a3355815 --- /dev/null +++ b/docs/readme.rst @@ -0,0 +1 @@ +.. include:: ../README.rst diff --git a/docs/tokenomics/governance.rst b/docs/tokenomics/governance.rst new file mode 100644 index 0000000000..8616542eeb --- /dev/null +++ b/docs/tokenomics/governance.rst @@ -0,0 +1,3 @@ +############################### +Governance +############################### \ No newline at end of file diff --git a/docs/tokenomics/protocol_fees.rst b/docs/tokenomics/protocol_fees.rst new file mode 100644 index 0000000000..9c9a8d9deb --- /dev/null +++ b/docs/tokenomics/protocol_fees.rst @@ -0,0 +1,3 @@ +############################### +Protocol Fees +############################### \ No newline at end of file diff --git a/docs/tokenomics/staking.rst b/docs/tokenomics/staking.rst new file mode 100644 index 0000000000..a401b33ba9 --- /dev/null +++ b/docs/tokenomics/staking.rst @@ -0,0 +1,3 @@ +############################### +Staking +############################### \ No newline at end of file diff --git a/docs/tokenomics/voting.rst b/docs/tokenomics/voting.rst new file mode 100644 index 0000000000..a3c24b2ba6 --- /dev/null +++ b/docs/tokenomics/voting.rst @@ -0,0 +1,3 @@ +############################### +Voting +############################### \ No newline at end of file diff --git a/docs/usage.rst b/docs/usage.rst new file mode 100644 index 0000000000..fb9b1ec7e9 --- /dev/null +++ b/docs/usage.rst @@ -0,0 +1,7 @@ +======== +Usage +======== + +To use this template, simply update it:: + + import read-the-docs-template