How does margin trading work?

Good to know: Leverage is fairly synonymous with the concept of debt. In our system, traders take on leverage every time they borrow funds from the liquidity pool to increase the size of their position.

Going Long

Going long represents the concept of betting the price of an asset will go up.

To create a leveraged position, traders must provide collateral. Collateral represents the base amount from which a trader uses leverage to multiply the size of their position by borrowing assets deposited into TLP.

In TsunamiX, users can deposit any TLP whitelisted asset as collateral for Longs. Then the trader specifies the amount of leverage they wish to take, and that amount of leverage becomes reserved in TLP.

Until that trader's position is closed, the reserved amount in the Liquidity Pool is occupied and cannot be swapped for nor reserved by any other traders.

Additionally, LPs cannot redeem any quantity of reserved assets. When a trader opens a position on TsunamiX, they can have full confidence that their position is backed by the number of specified assets they have reserved.

Assets are fully transparent and verifiable on the Mantle blockchain.

When a trader wishes to close their position, the position is settled in kind, meaning they receive their payout in the asset they longed.

If the trader closes a position in profit, they will receive any excess profit denominated in their longed token. If they are at a loss, the protocol will harvest the appropriate amount of the collateral from the trader.

The moment the position is closed, the funds are available again to be reserved by any other trader on the platform.

Ex: If the price of the longed asset, BTC, starts at $100 and the trader uses 10x leverage, their position is worth $1100. The Trader is long for 11 BTC and has an obligation to pay back $1000 to the pool when they close their position. Thus, the trader has 1 BTC worth of collateral and 10 BTC of leverage, which is reserved BTC from the LP.

If the price of BTC decreases to $95, then the position is now worth $1045, but the trader has an obligation of $1000 to pay back, meaning that they have a loss on their position of $55. If the trader now decides to close their position, they can do so and leave with their remaining $55 worth of BTC from their position.

If the price of BTC increases to $105, then the position is now worth $1155, but the trader has an obligation of $1000 to pay back, meaning that they have a profit on their position of $55. If the trader now decides to close their position, they can do so and leave with their $155 worth of BTC from their position.

In both cases, the profit for the trader is a loss for the LPs, and the profit for the LPs is a loss for the trader.

  • If traders on average break even, TLP will lose none of its value relative to its target weight basket composition, in fact, it would actually gain value from the fees being paid from traders being compounded back into TLP.

  • If traders are at a loss, TLP gains additional value based on market-making profits.

Going Short

TsunamiX only accepts stable coins as collateral for opening a Short position.

This is equivalent to going long with a stable coin (USDC/USDT) against a separate asset.

When a trader chooses to go short, they providing stable coins as collateral in order to borrow more of that stable. The borrowed funds are measured against the price of the asset the trader is shorting.

Ex: A trader wants to short BTC which starts at a price of $100. They deposit enough collateral and use enough leverage such that the starting value of their position is $1000. The Trader is long $1000 USDC against BTC.

Let's say this trader has $100 worth of collateral and $900 of leverage, which is reserved USDC from the LP. If the price of BTC decreases to $50, then the position is still worth $1000, but the obligation that the trader has of 9 BTC is now worth $450, meaning that they have a profit on their position of $450. If the trader now decides to close their position, they can do so and capture $450 in USDC of profit from the pool.

Liquidations

Third parties run liquidators to liquidate unhealthy positions. It costs no capital to liquidate a position as the liquidator just needs to pay for the gas of the transaction.

To manage their positions, traders have the ability to reduce their position size or add more collateral to reduce the likelihood of liquidation.

As a position gets liquidated, the liquidator receives a fee of $5 from the pool. If there is excess capital over $5, the pool LPs may receive this amount as an additional fee.

This value is subject to change but is intended to be enough for liquidators to run bots but not so high as to extract an unfairly large quantity of capital from the system.

Funding Rates

Unlike most other perpetual exchanges, both longs and shorts pay funding rates to the LP. The funding rate a trader pays to keep a position open is determined by the utilization of the particular asset in the pool.

Funding rates are calculated as (Assets borrowed)/(Total Assets in Pool) * 0.01% per hour

Protecting LPs

Most blockchains have a lag between even the most accurate price oracles and the actual market price of assets.

Each chain's block times vary but generally range from block times of 1-6 seconds. This creates an issue that the price from price oracles will have a staleness of six seconds. This staleness could potentially create opportunities for hostile order flow from outsized capital looking to make a risk-free trade at the expense of LPs.

Because of this, we implemented the following protection as traders are opening or closing orders to protect the LPs from such a hostile scenario:

Permissioned Entry Guard

Every order that is made by traders is not filled immediately by a TsunamiX contract. Instead, the order will be filled by a permissioned keeper. If and once the keeper determines that the price the oracle has quoted for an order is fair, the keeper will execute the order on behalf of the trader.

If the quoted price is determined to not be fair (e.g surprise wick), the order will not be filled.

This protection will ensure that LPs are quoting fair market prices, but has the tradeoff of slower and non-guaranteed execution of trades.

Last updated