Since we announced the dYdX Margin Tokens in our previous post, we’ve been thrilled with the level of interest. As a follow up, we wanted to provide a more thorough overview of how they work. We have broken up this post into two sections — first, to explain how Margin Tokens can be used easily to go short or gain leverage, and secondly to outline the decentralized mechanisms underpinning the Tokens.

This post covers these mechanisms at a high level. If technical details interest you, the Margin Token whitepaper is your best resource and we’ll be releasing additional technical posts in the future.

Simplicity of Margin Tokens

dYdX Margin Token: A freely tradable, fungible and transferable ownership interest in a dYdX Short or Leveraged Long Position based upon the ERC20 standard

dYdX Margin Position: A short sell or leveraged long position on the dYdX Protocol

Can be owned by a user or a smart contract

Margin Positions back Margin Tokens

The beauty of the Margin Token — and why we’re so excited — is that it enables traders to get short or leveraged long exposure incredibly simply. All traders have to do is buy/sell an ERC20 token, which many wallets and exchanges (centralized and decentralized) already support. Traders will not have to deal with the complexity of borrowing and buying/selling an underlying crypto asset in order to short or gain leverage.

Let’s now walk through an example of how a Margin Token, Short ETH, could be used to short Ether.

Let’s introduce Brendan. Brendan is a Bitcoin maximalist and wants to Short 1 ETH. To do this ordinarily, he would need to:

Find an ETH lender Put up a margin deposit Sell the borrowed ETH on the spot market

To close his position (assuming the price of ETH has fallen $10) he would need to:

Buy-back the ETH on the spot market Repay the lender

In this scenario — his profit is $10 (assuming no fees or other costs).

With dYdX Margin Tokens, this process is significantly simpler. All Brendan needs to do is buy 1 Short ETH (sETH). This purchase provides the equivalent amount of short exposure as in the above example.

As the price of ETH decreases by $1, the price of sETH increases by $1.

After a week, the price of ETH goes down $10 and Brendan decides that he’s sufficiently in-the-money. He sells his sETH and makes a $10 profit to fund more Bitcoin projects.

Trading a token is the only interaction needed to get margin exposure through dYdX.

The following section outlines more information about the decentralized mechanisms that underpin these Tokens. These mechanisms happen behind the scenes and require no interaction from Margin Token traders.

Margin Tokens, behind the scenes

Creating & Minting Margin Tokens

Each Margin Token is its own smart contract and has unique terms. It is created by assigning ownership of a Margin Position to the smart contract. This contract generates Tokens in proportion to the position size. Ownership of Margin Tokens grants ownership of a portion of the backing position.

Anyone can create a new Margin Token by opening a Margin Position and transferring ownership to a new token smart contract.

Once a Margin Token is created, anyone can increase the token supply by increasing the size of the backing Margin Position. The newly minted Tokens conform to exactly the same specs as the original Margin Token (e.g. interest rate, expiration).

Closing Margin Tokens

Margin Tokens are closed in the following scenarios:

When the token holder decides to close If the position is margin called If the position hits maximum duration (expiration)

Each Token holder can decide to close his or her position at any time. Closing sends the payout to the Margin Token holder, and causes his or her Margin Tokens to be burned.

In the case of a margin call or expiration, token holders can either sell their tokens via an exchange, close their tokens (per above process), or wait for an auction closing mechanism (see dutch auction mechanism in the Whitepaper) to automatically close their tokens.

Margin Token Value

Margin Tokens have a defined price at which they should trade. This price is defined by parameters such as the interest rate, amount of collateral, and price of the underlying cryptoasset. The price of a Short Token is negatively correlated with the price of the underlying token, while the price of a Leveraged Long Token changes by the same amount as the base token (but with a higher ratio).

Because Margin Tokens can be freely minted and closed:

The lower-bound of the price is the payout from closing the Margin Tokens’ portion of the underlying position

The upper-bound of the price is the cost of minting new tokens

Both the payout from closing and the cost to mint are equal to the value of what’s in the position minus the value of what’s being lent. Therefore, the price of the token is also equal to what’s in the position minus the value of what’s being lent per unit.

If the price deviates from this value, there would be an arbitrage opportunity. For example, if the price were less than the payout from closing, arbitrageurs would buy tokens and immediately close them for a risk free profit. In the opposite case, where price is greater than the minting cost, arbitrageurs would mint new tokens and immediately sell them on the open market.

There are two caveats here:

There are some fees for closing or increasing a position. These could include buy/sell fees, loan relayer fees, and gas costs. Therefore, we expect the token price to be stable within a small spread dictated by these fees The upper bound of the price breaks down whenever lending liquidity dries up; there is no way to mint new tokens without loan offerings. However, the lower bound will always hold

Summary

dYdX Margin Tokens:

Provide traders with a very simple way to get short and leveraged long exposure to crypto assets

Can be easily integrated into existing exchanges, wallets and dApps

Have a specified interest rate and expiration date

Have a defined price relative to the price of an underlying cryptoasset

Use decentralized mechanisms to achieve price stability due to economic incentives to mint (add to a position) or burn (close a position) Tokens

We will be making further announcements soon on the specific user experience and applications that support taking these positions.

We’re excited by what we’re building around the dYdX Protocol. If you are too, please get in touch. You can reach us on our Slack, Twitter or join us at jobs@dydx.exchange!