DDEX FAQ: Margin Trading
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.
When will the new DDEX launch?
We will officially launch the new DDEX on mainnet by the second week of August.
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?
There are three primary things you can do on DDEX:
- Margin trade
- Spot trade
- Lend to earn interest
Is it secure?
We work extremely hard to secure all aspects of DDEX. We also have all of our smart contracts professionally audited.
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?
When we launch next month, DDEX will be available for everyone. There is no account creation process, nor are there any planned restrictions to our users at this time.
Lending and Borrowing
How are interest rates set?
The interest rates on DDEX are set algorithmically based on supply and demand. Lending and borrowing is done through the use of decentralized lending pools, where lenders pool assets into a smart contract and borrowers take loans from this pool (secured by collateral). As such, these interest rates are dynamic, and fluctuate when supply and demand changes. Each asset will have a unique interest rate for lending and borrowing.
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?
The quick answer is no. The borrowing on DDEX is primarily designed to support margin trading done internally on DDEX. Because we keep the borrowed assets within DDEX, the potential leverage rates on DDEX are higher than if you were to try and manually take a loan on one platform and use those borrowed assets on another.
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?
DDEX uses on-chain price oracles to determine real-time USD prices, which are critical for determining the value of collateral for a given account. These price oracles are different for each market (example: the ETH-DAI market will use the MakerDAO ETH-USD price oracle), chosen based on stability. Additionally, we have several safety mechanisms built into the price determination process to guard against oracle failures: both on a contract level and algorithmically.
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?
Liquidations on DDEX are triggered by a 3rd party initiator. When initiated, our smart contracts will check to see if the flagged address is qualified for liquidation (i.e. their collateral rate is below the respective threshold for that market). If it is not below the threshold, nothing happens. If it is, a liquidation event is triggered.
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?
One concern with lending is the potential scenario where the borrower’s collateral becomes less valuable than their borrowed assets. This scenario could result in a loss for the lending pool, depending on how the liquidation process works.
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?
For the initial release we have conservatively capped the maximum leverage rate at 5x. However, our decentralized margin trading architecture supports leverage rates over 10x.
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?
The liquidation price is calculated from the minimum allowable collateral rate for each market. This minimum allowable collateral rate is specified by market in our smart contracts. Initially, we will have a minimum collateral rate of approximately 110% for our starting markets.
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?
Yes you can adjust existing positions!
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?
You can use either the base or quote token of that market as collateral for opening a position. So if I wanted to open a position on ETH-DAI, I could use either ETH or DAI for the position.
Can I make Limit Orders on Margin?
Yes, you can make leveraged limit orders on DDEX!
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?
Yes, you can make stop-loss orders on DDEX!
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?
DDEX uses a hybrid model decentralized exchange, with off-chain matching and on-chain settlement. It does not require gas to create or cancel orders, but all token transfers are still processed on-chain.
This is a more friendly structure for market makers, and is designed to promote excellent liquidity.