DDEX FAQ: Margin Trading

Scott Winges
Jul 22, 2019 · 6 min read

We just announced that a vastly improved DDEX with Margin Trading and Lending is coming soon. This FAQ dives into some of the key details and logic behind the new platform.

Image for post
Image for post

Getting Started

When will the new DDEX launch?

Towards the end of July we will release a testnet version for users to play around with. Our closed alpha will follow shortly after.

What all can I do on the new DDEX?

  • Margin trade
  • Spot trade
  • Lend to earn interest

Is it secure?

From the ground up we’ve designed DDEX to be as robust as possible: from price oracles, to liquidation mechanisms, to the underlying smart contracts.

Who can use DDEX?

Lending and Borrowing

How are interest rates set?

If the pool has a large amount of assets deposited with little borrowing, the interest rates will be low. As borrowing demand increases, the interest rates will increase: both the cost for borrowers and the return for lenders.

Can I use my borrowed assets outside of DDEX?

Although we don’t support an external withdrawal on a product level, we actually do support this on a contract level. The Hydro Protocol smart contracts actually do support the ability to move some borrowed assets outside of DDEX. A user could manually construct a transaction to move borrowed assets outside of DDEX, but they would only be able to withdraw a small portion of their maximum available borrowed assets.

What does DDEX use to determine prices?

With that being said, other platforms have already demonstrated some of the complications that can occur when a price oracle fails. While we have extra safety mechanisms in place to help the oracles be as robust as possible, we also want to make sure that there is a reliable backup option.

Price oracles and liquidation methodology together provide a strong metric for platform security. As both a lender and borrower, it’s imperative that these function properly.

How do liquidations work on DDEX?

DDEX uses a form of dutch auctions for liquidation events. The dutch auction attempts to sell the borrower’s collateral to repay their debt. However, it doesn’t just start with selling the entire collateral — initially, only a small percentage of the collateral is offered up for auction. As time passes, each subsequent block offers a bit more of the collateral.

Eventually the value of the percentage of collateral offered will make a profitable trade for outsiders. If the auction is completed before 100% of the collateral is used, the remaining collateral will be returned to the borrower, with a small amount going to the initiator as a reward.

By performing liquidations in this method, even if a price oracle were to fail and a position got liquidated prematurely, the losses for the borrower would be minimized. The borrower effectively has an additional layer of protection from price oracle failures through our dutch auction liquidation method.

Is lending risk free?

We researched existing decentralized lending platforms extensively in coming up with robust lending solution on DDEX. Because of the liquidation method described above, liquidations are triggered when the collateral is still worth more than the borrowed amount. As such, the losses for the lending pool could only occur if the price of the collateral dropped below the borrowed amount so quickly that in the time it took to increment the auction, the price of the collateral was now less than the borrowed amount. This is a super rare event that we don’t expect to happen, but just in case we have another line of defense.

A percentage of interest gets sent to an insurance pool, to help avoid losses for the lending pool. In the case where the borrowed amount became less than the collateral, the auction could increment the collateral beyond 100% and tap into the insurance pool to provide additional incentive for this collateral to be purchased in the auction.

Spot Trading and Margin Trading

What’s the max leverage rate DDEX supports?

In general, the practical leverage rate depends on the liquidity of the market. More liquidity = higher potential leverage.

How do you determine the liquidation price?

Let’s run through a quick example. Let’s say I opened a:
4x long on ETH-DAI with 1 ETH of collateral;
Open price of 300DAI/ETH;
This yields a 4 ETH position with 900 DAI of debt.

My collateral rate is my total amount divided by my borrowed amount.
So initially CR=(4ETH*300DAI/ETH)/900DAI=133%.
If our minimum allowable collateral rate was 110%, we could calculate the price at which this rate would trigger (the liquidation price).
Liquidation price = 110%*900/4 → 247.50 DAI

Can I adjust my position once it is open?

At a product level we generally try to optimize for the most common scenario: we make it super easy to simply open and close your entire position. However, the contracts are extremely flexible so we decided to allow users to make arbitrary adjustments to their position if desired.

You can close part of an open position, add collateral, and add additional leverage as desired.

What types of collateral can I use to open a position on a market?

Can I make Limit Orders on Margin?

The standard Margin order is set as a market order, but you can change this to limit orders as desired.

Can I make stop-loss orders?

This is one awesome advantage we have by using our own DEX instead of a third party one: we can naturally incorporate stop-loss orders into DDEX.

Is DDEX fully on-chain?

This is a more friendly structure for market makers, and is designed to promote excellent liquidity.

Hydro Protocol

Hydro Protocol is an open-source framework for building…

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store