decentralized finance defi dydx what is dydx

DeFi Deep Dive - What is dYdX?

Written By Ivan on Tech

Aug 23, 2020

Anyone keeping an eye on the DeFi sector will likely have come across the term “dYdX”. However, what is dYdX - and what is it used for? dYdX is a powerful, decentralized exchange (DEX) that supports spot, margin, and perpetuals trading. It is a permissionless platform powered by smart contracts on Ethereum that supports lending, borrowing, and most importantly, margin trading. 

In the true spirit of decentralized finance (DeFi), anyone can use dYdX without registering or handing over their assets to a central party. It is open, trustless, and non-custodial. Users can swap ETH, USDC, and DAI pairs as well as BTC and ETH on perpetual markets. We will touch on perpetual markets in a later article.

Trading Tools on the Blockchain

dYdX wants to bring trading tools from the traditional world of finance to the blockchain. Although it is decentralized, trading on dYdX is similar to trading on a centralized exchange (CEX). Options and margin trading are standard in traditional finance, but in crypto, these features were initially limited to CEXs. Now with the introduction of DeFi, these standard trading features are available on DEXs like dYdX.

When using dYdX, users deposit their collateral to off-chain order books. These are non-custodial, but they offer faster trade execution and users only have to pay gas fees when depositing or withdrawing assets from the platform. Also, security and transparency are essential to dYdX since hacks and scams can easily tarnish the fledgling space of DeFi.  

How dYdX Works

On dYdX, each asset has a lending pool that borrowers and lenders interact with. Smart contracts manage the assets so transactions occur instantly without having to wait for a match on the other side of the trade. Supply and demand for the asset determine its interest rate.

Borrowing and lending services already exist on many popular DeFi exchanges, but dYdX is more focused on building advanced trading tools. And it is the most popular decentralized margin trading platform. 

To use dYdX one just needs a crypto wallet like Metamask, some ETH for transaction fees, and the supported crypto assets DAI, ETH, or USDC. ETH is Ethereum’s native token and DAI and USDC are stablecoins that maintain a stable price around the $1 mark. 

Each of these three assets has a dynamic interest rate. “Dynamic” means that the interest rate changes based on the changes in supply and demand for the asset. 

Borrowing and Lending on dYdX

As mentioned earlier, there is one global lending pool per supported asset on dYdX. When depositing an asset, the user’s funds go into the asset’s corresponding lending pool. Borrowers can then borrow against the same asset. 

The supply and demand for each asset changes as borrowers and lenders hit the lending pools. This, as we’ve said, will affect interest rates. dYdX will display two rates for a given asset: The lending rate (or supply rate) and the borrowing rate. As you’d expect, the borrowing rate will always be higher than the supply rate. 

Borrowing on dYdX

To borrow on dYdX, go to the “Borrow” tab and choose the asset (ETH, DAI, or USDC). First, however, you will need to deposit collateral. In fact, with dYdX (and other DEXs) you will need to over-collateralize the loan. That is, you will deposit more than 100% of the loan amount. 

On dYdX, you must deposit 125% of the loan amount as collateral before borrowing. This is less than other DEXs since most require 150% collateral. Also, liquidations can occur if a 115% collateralization ratio isn’t maintained. These ratios aren’t chosen at random to be punitive. They exist to protect lenders from borrowers taking out risky loans. Once a loan drops into that danger zone, it is liquidated to protect the lenders in the pool.

Collateralization Ratio

To calculate the collateralization ratio on dYdX just take the collateral and divide it by the debt (collateral / debt) in US dollars. For example, let’s say you have 3 ETH that you want to use as collateral against a loan in DAI. DAI is a stablecoin that equals $1, and let’s say ETH is trading at $400. So we’d have the following equation:

ETH = $400
DAI = $1

Collateral:  3 ETH * $400 = $1200 and (1200 / 960) = 1.25 (125%)
Loan: 960 DAI

So, to meet the starting collateralization ratio of 125%, with 3 ETH as collateral, the most you could borrow would be 960 DAI tokens.  Now, here’s where you have to be careful as a borrower on any DeFi protocol. A borrower must maintain a 115% ratio to avoid being liquidated on dYdX. So, in the above example, you would need to maintain a collateral level of $1,104 to stay solvent.

What happens if the price of ETH drops to $390? Well, let’s do the math:

If $1,104 is the minimum amount of collateral
3 * 390 = $1,170

In this situation, the price drop wouldn’t hurt you. But what if ETH drops to $350?

$1,104 minimum
3 * 350 = $1,050

If ETH dropped to $350, you would be liquidated. The lesson being, if you’re a borrower, you have to keep an eye on your collateralization ratio which means keeping tabs of the price of the underlying asset (ETH in this case). It’s best to set up some kind of alert system and try not to cut it too close with the ratios to avoid these kinds of penalties. 

dYdX Dashboard 

Once you’ve selected an asset to borrow, the dashboard will display the annual percentage rate (APR) you will have to pay. And after you’ve entered a borrowed amount in the “Amount” field you will see the collateralization ratio. And remember, you can’t start for less than 125%, so the deposit field will have a “pre-fill amount” required. As you enter the data, other fields on the screen will change to reflect what your account balance will look like once the borrow transaction is complete.

Click on the Borrow button and dYdX withdraws the borrowed to your wallet. Under “Account Balance” you should be able to see the negative balance that corresponds to your borrowed amount. 

You can repay your borrowed funds any time you like. And when you want to close out your loan balance, just hover over the “Outstanding Borrows” row. Click the “Repay” button to pay back part or all of the borrowed assets plus interest. When finished, you can withdraw your collateral back to your wallet. 

Lending on dYdX

If you’re less risk-tolerant but want to earn passive interest income, then lending might be more up your alley. The good news is, there is no minimum loan period and interest starts accruing immediately each time a new block is mined on dYdX. In other words, your funds are not locked up for periods of time. You can deposit or withdraw them at any time.

So, if you’re “hodling” some of these tokens like DAI, and they’re sitting around collecting crypto dust, you might want to put them to work on a dYdX pool. This is not financial advice, as undertaking any sort of trade on a DEX involves risk.

DAI

When you lend on dYdX your assets go into a pool and the interest you earn is coming from others who are borrowing the same asset. The collateralization ratios and liquidations we talked about earlier ensures there is enough collateral on hand to repay any outstanding loans. This is especially good for lenders and why it’s lower risk than borrowing. 

Like other DeFi lending protocols, you’ll just need the tokens you’re going to lend, a crypto wallet, and a small amount of ETH to pay transaction fees. 

Navigate to the “Balances” tab and you’ll see the different rates for the supported tokens. When you click “Deposit,” you will see the expected APR and you can select the amount you want to lend. You’ll have to accept the transaction in your wallet and interest will start accruing immediately. You can view the Balances tab any time you want to check your accrued interest.   

Margin and Leverage on dYdX

Traditionally, margin trading is borrowing from the house to make bigger bets. If you’re not familiar with margin trading, think of it as an “old school,” Vegas gambler who has a hunch on a bet. Let’s say he only has $1,000 in his pocket but he wants to bet more. Depending on his reputation, he might be able to borrow $4,000 from the casino. If he wins the $5,000 bet, he repays the casino their $4,000 plus some “juice” and pockets the rest. If he loses? Well, in the old days, characters like Robert De Niro and Joe Pesci would apply some gentle persuasion to get the house’s money back.

Margin trading in traditional finance boils down to borrowing money from the exchange to increase profits when placing a trade. Of course, it also offers traders the chance to lose much more money when they bet on the wrong stock. 

But the advantage of margin trading is that it creates leverage. The more leverage a trader utilizes, the more they can make (or lose). On dYdX, a trader can leverage up to 5x. That means they can increase their gains or losses 5x on a trade.

Margin trading and derivatives are important because they empower traders to better allocate capital and manage their risk. That’s why these services are essential to onboarding more traders to the DeFi space. 

dYdX may seem limited as a trading platform since it simply offers basic trading between three assets, ETH, DAI, and USDC, but it is a big move forward for DeFi. And margin trading is what sets dYdX apart from other DEXs

Margin Trading on dYdX

dYdX utilizes two types of margin trading: isolated margin and cross-margin trading. Isolated margin allows the user to leverage one asset, whilst cross margin lets them use all the assets in their account to take a position. In other words, cross margin utilizes all the assets in the account. This allows traders to take unique positions to further leverage interest.  

When taking out an isolated long position, the trade will be paid in ETH. DAI will be paid out for isolated short positions. Margin trading is risky and losses can rapidly multiply so only experienced traders should attempt. 

Margin Trading Example

dYdX currently offers three margin trading pairs:

  • ETH - DAI
  • ETH - USDC
  • USDC - DAI

We’ll use 1 ETH priced at $400 again as an example. So, let’s say you think ETH is going up in price but you only have $400. You buy 1 ETH on dYdX because you know you can trade on margin. So, you decide to go long 4x on ETH. With 1 ETH and you’re able to buy $1,600 worth of ETH ($400 x 4) on margin. Remember, your 3 ETH loan will have interest costs depending on how long you hold it. 

Now, if the price of ETH goes up, you can leverage your profits. Let’s say ETH goes to $450 and you close your position. Just holding, or “hodling” 1 ETH would have made you $50. However, leveraging with margin in the example above would have made $200 (4 ETH * $50 profit = $200 minus interest). 

If you were going to trade the above example, you would load up your Metamask wallet with enough to buy one ETH with some extra to cover the margin deposit. On the dYdX exchange, you would navigate to the “Margin” tab. Select “Long” then choose 4x. Then you would see your liquidation price. Notice it will change as you click around between 2x and 5x. After you’ve placed a margin order, you can track it under “Positions.”

So, the main thing is to avoid liquidation. If the price of ETH drops dangerously low, your collateralization ratio can get so low that your position will be liquidated. At that point, your collateral will be sold off until your negative balances are zero and you’ll get hit with a 5% liquidation fee as well. 

The Future of dYdX

dYdX is on track to offer increasingly advanced trading features that one would expect to find coming from the traditional world of finance. Derivatives, options, margin trading, and even stop-loss options are all at play and there’s talk of adding new crypto assets and more complexity to their platform in the future. DeFi is an ever-maturing market with developers adding new Lego blocks every day it seems. And dYdX is currently one of the most liquid DEXs with high trading volumes relative to other platforms in DeFi space. 

To learn more about DEXs like dYdX, and DeFi in general, make sure to visit the leading blockchain academy Ivan on Tech Academy and kickstart your crypto, blockchain technology and DeFi education today!

Like what you're reading?

Get to work in a fast growing industry. Start learning blockchain together with our 20,000+ students today.
Use coupon code BLOG20 for 20% off.

Become Blockchain Certified Today No Prior Knowledge Needed!
Close

Get our Free Ebook

Enter your email and we will send it to you!