Zaidan & Paradigm Labs’ Trade Portal

Liam Kovatch
Paradigm
6 min readNov 6, 2019

--

This post will familiarize the reader with Zaidan — a non-custodial dealer-based trading system built on 0x — and the required user interactions for trading through the hosted web portal.

What is Zaidan?

Zaidan is a non-custodial trading solution developed by Paradigm Labs that provides an extremely price-competitive alternative to existing DEX and relayer models. Zaidan’s primary innovation is its application of 0x’s ZEIP-18 to a unique interaction model wherein the maker, which we designate the dealer, is responsible for both order creation and execution.

Dealers and takers communicate directly via a request for quotation scheme. Upon solicitation from the taker, dealers provide cryptographically-restricted, signed maker orders that represent soft-commitments to trades. If the requesting party agrees with the provided quote, they can (quickly) generate and respond with the signed 0x transaction message. The dealer, prior to submitting the transaction for execution, verifies the validity of the 0x transaction message which includes enforcing previously provided “soft-parameterization” constraints. In effect, this unique model (akin to “last look” in forex trading) removes taker optionality present in other DEX models resulting in significantly improved pricing.

Portal Tutorial

https://trade.paradigm.market/

Zaidan is ultimately designed as an API-based liquidity solution intended to provide public, high quality trading infrastructure to a variety of projects. The current iteration of Zaidan follows a conventional client-server architecture. The client is open-source and can be found on the Paradigm Labs GitHub.

In order to demonstrate the power of Zaidan, we have developed a simple portal that allows users to swap tokens. This section will walk through the user flow of the trading portal and give some insight into the system’s internal mechanics at each step of the process.

1. Navigate to the portal and connect to Metamask

Once navigated to the portal (via the link above), the user will need to sign into Metamask and confirm they are connected to the Ethereum mainnet. Then, the user can click the text “Click to Connect Metamask” in the top right of the screen. This will trigger a Metamask popup with the option to “connect” which the user must accept to continue. This step provides the necessary connection to the user’s wallet. During trading, the Zaidan client will prompt the use of Metamask when signing order messages.

2. Gain access (if prompted)

In order to participate in the beta of the trade portal a user’s address must be whitelisted. To get their address whitelisted the user has two options. First they can tweet (as prompted). Depending on the capacity of the whitelist, this action will either add a user’s address to the whitelist or to a waitlist. Status updates will then be provided as replies to the user’s original tweet.

If a user would rather not make a public tweet, they can instead DM their address (Ethereum public key) to the Paradigm Labs twitter account along with a short message. You will then be manually added to the waitlist/whitelist.

It is worth noting that the current requirement for users to have a whitelisted address is intended to allow for a smooth and controlled rollout of Zaidan. Eventually the trade portal will be publicly available and the system will instead define a blacklist (of user’s deemed “malicious”).

3. Set allowances (if not already set)

When Metamask is connected, the portal will check to see if the current account has the necessary token allowances for trading. If not, the portal will not allow any action other than setting allowances via the “Set XXX Allowance” button on the bottom right of the screen. Allowances are provided to the 0x ERC-20 asset proxy contract which allows the 0x Exchange contract to make transfers when an address (user) has cryptographically committed to a trade.

4. Get a quote

After connecting to Metamask and setting the necessary allowances, the user is ready to solicit a quote. To do so, they simply select the tokens they would like to swap (currently only WETH, ZRX and DAI are supported) and enter a quantity to swap. The entry action will fetch a quote from the Zaidan server and populate the value to the right.

When a quote is fetched, a countdown timer will appear to the left of the “Swap” button. This countdown represents “soft-cancellation” parameters under which the dealer will honor the provided quotation. Once the countdown expires a new quote is automatically fetched and any attempts to fill the previous quotation will fail.*

More explicitly, if a user solicits a quote to swap 10 ETH for DAI, the dealer will return a signed 0x maker order (with the senderAddress restricted) and a unix expiration time that will be enforced by the dealer upon execution. This unix expiration is what is used to populate the countdown timer.

*It is important to note that an order transaction must be signed via metamask before the countdown expires.

5. Trade

If a user agrees with the provided quote and wishes to make the trade, they can click the “Swap” button at the bottom right of the screen. This action will launch a summary pop-up for the trader to review trade details once again. Having reviewed the trade details, the trader can agree to the trade by clicking “Confirm”. The user will then be prompted, via a Metamask pop-up, to provide a signature. Once the user signs the order (which they must do so relatively quickly so the order doesn’t expire), the prepared 0x transaction will be sent to Zaidan for execution and a transaction hash will be returned.

Users will notice a field labeled “Total with execution fee” in the summary pop-up. Though, the value tabulated here may not be entirely intuitive as it is larger than the intended swap amount, the reasoning for the premium inclusion is simple. Since users aren’t responsible for order execution, they pay no gas. This premium is thus a reflection of the gas costs the dealer will incur upon submitting the order. This fee can be compared to the ethereum transaction cost a user would directly pay when taking an order off an open order book relayer except that it is collected by the dealer in the base asset (rather than always ETH).

Support

While we are excited to get people using Zaidan and the trading portal, we want to stress that this is an early version of the system. As such, we anticipate the system will have small bugs and quirks. If you encounter any issues or have any feedback please reach out in our Discord community’s #support channel.

Acknowledgements

We’d like to thank the 0x team, particularly Peter Zeitz and Fabio Berger, for their considered input at various points in Zaidan’s development.

--

--

Liam Kovatch
Paradigm

Co-Founder and CEO of @ParadigmFdn. Previously Applied Mathematics and Computer Science @Columbia