5️⃣Perpetual Trading Details

RogueX distinguishes itself in the crowded DeFi landscape by introducing a set of innovative features that address key pain points while enhancing the overall trading experience for its users. Roguex's trading model draws inspiration from leveraged perpetual trading, creating a sophisticated and innovative environment for traders.

5.1. Positions

Users on Roguex can open and manage trading positions. Each position consists of a principal amount, which represents:

  • Collateral cc: Collateral represents the value that a user deposits in the form of tokens when they initiate a trading position. Collateral serves as a form of security or commitment from the user, ensuring that they can meet any potential obligations or losses that may arise during the course of their trading activities. This collateral is held as a safeguard by the trading platform and is used to cover potential losses or fulfill margin requirements associated with leveraged positions.

  • Position Size ss: Position size $s$ is determined by multiplying the collateral by the leverage $l$ used in a trading position. This calculation helps define the scale or magnitude of the trading position, reflecting the amount of exposure to the market. Importantly, all profits and fees associated with the trading position are calculated based on the position size. This means that the potential gains and costs, including trading fees, are directly tied to the size of the position.

  • Leverage ll: The use of leverage, which allows traders to control a larger position than their initial collateral, can significantly magnify both profits and potential losses, making the position size an essential factor in trading. It is essential for traders to understand the relationship between collateral, leverage, and position size to manage risk effectively and maximize potential returns in their trading activities.

  • Reserve Asset for Leverage While the collateral is provided in the form of the long position token, the user can still leverage their position by using additional assets as reserve assets. These reserve assets help manage the risk associated with leveraged trading. To avoid the risk of piercing the collateral's warehouse, Roguex employs a strategy where the collateral and reserve assets for a long position are set to be the same as the asset that the user is longing (i.e., the long position token). This approach simplifies the trading process and reduces the risk of unexpected losses due to price volatility or other factors.

The profit of a user who opens a leveraged long position with collateral cc, taking leverage l to acquire a position size s at an open price PoP_o and closes the position at a closing price PcP_c is:

profit π=s(PclosePopen)popens(γf+γp+γr)\text{profit } \pi = s \cdot \frac{(P_\text{close} - P_\text{open} ) }{p_\text{open}} - s \cdot (\gamma_f + \gamma_p + \gamma_r) (5)

where

gammaf+γp+γr\\gamma_f + \gamma_p + \gamma_rdenotes funding fee, position fee and premium fee respectively, and pnl is

pnl=πc×100%\text{pnl} = \frac{\pi}{c} \times 100\% (6)

5.2.Spread in Open Price and Close Price

Spread plays a crucial role in RogueX's perpetual trading system, affecting both the opening and closing phases of trading positions. This concept is central to the platform's design as it replicates spread dynamics seen in traditional spot trading, contributing to the overall stability and reliability of the entire system.

Opening Position Slippage When a user initiates a position in RogueX's perpetual trading system, they submit an order at a specific price. However, the execution price can vary due to market volatility and the nature of liquidity pool. The difference between the intended entry price and the actual execution price is what we refer to as opening position spread. This inherent spread mirrors the behavior found in spot trading, adding a sense of realism to the trading process.

Closing Position Slippage Slippage is also pertinent when closing positions. As traders decide to exit their positions, they place orders to sell (for long positions) or buy (for short positions). Just like in opening position spread, the execution price at the time of closing may not precisely match the expected price due to market dynamics. This closing position spread has implications for the final realized profit or loss of the trader.

Dynamic Slippage Factor In RogueX's perpetual trading system, a unique feature has been implemented to address price manipulation concerns during the closing of positions. This feature is known as "dynamic spread factor", and its primary purpose is to safeguard the integrity of the platform's pricing mechanism. Dynamic spread is employed in the context of spread during the closing of positions. This mechanism is integral to optimizing the precision and fairness of the closing process in a trading platform.

In RogueX's perpetual trading system, spread is a critical aspect. By simulating spread patterns similar to those observed in spot trading, the platform enhances the authenticity of the trading experience. Moreover, this approach contributes to the overall stability of the system by reflecting real-world market conditions. Traders benefit from a trading environment that more accurately replicates the challenges and opportunities they would encounter in traditional markets. Understanding and effectively managing spread is essential for traders to navigate RogueX's perpetual trading system successfully.

5.3. Time-Weighted Average Price Integration

Using Time-Weighted Average Price (TWAP) in RogueX serves two critical purposes: preventing flash loan attacks and leaving less room for market manipulation attacks. Here's a more detailed description of these two reasons:

5.3.1. Preventing Flash Loan Attacks. Flash loan attacks are sophisticated strategies where a malicious actor borrows a substantial amount of assets via a flash loan, manipulates the price of an asset within a single transaction block, and profits from this manipulation. TWAP helps mitigate this risk in the following ways:

Time Averaging: With TWAP, RogueX calculates the average price over a set period, taking multiple price data points into account. This approach doesn't solely rely on a single, potentially manipulated price point, making it less susceptible to rapid, block-to-block price fluctuations manipulated by flash loan attacks.

Reduces Vulnerability: By considering an average price, RogueX reduces the vulnerability to flash loan attackers trying to exploit price discrepancies within a single block. The averaging mechanism creates a smoother and more stable pricing process that discourages attackers from targeting the platform.

5.3.2. Leaving Less Room for Market Manipulation Attacks. Market manipulation attacks involve strategically influencing the price of an asset to trigger specific trades and take advantage of vulnerabilities in the system. RogueX's use of TWAP addresses this concern through the following measures:

  • Price Averaging Over Time: TWAP considers prices over a specified time period, eliminating the impact of sudden price spikes or drops. Market manipulators often exploit price gaps for their own gain, but TWAP significantly reduces these opportunities.

  • Market Stability: By using TWAP, RogueX promotes market stability and discourages market manipulation. It ensures that traders can execute orders at prices that are more representative of the broader market, rather than at manipulated prices that create unfair advantages for malicious actors.

  • Transparency and Fairness: RogueX's focus on TWAP enhances the overall transparency and fairness of the trading environment. Traders can be more confident that their orders are executed at prices that align with the broader market conditions, thus reducing the potential impact of manipulation attacks.

In summary, TWAP in RogueX's pricing mechanism serves a dual purpose: safeguarding against flash loan attacks by smoothing out price data and providing a robust line of defense against market manipulation attacks. It enhances market stability and ensures a fair and transparent trading environment for all users.

5.4. Open Price Calculation

Po=TWAP(λo)(1+δ(sOI+sposition2)) P_o = \text{TWAP} ( \lambda_o ) \cdot ( 1 + \delta(\frac{s_\text{OI} + s_\text{position} }{2})) (7)

Where TWAP(λo)\text{TWAP}(\lambda_o) represents the time-weighted average price with a time latency of λo\lambda_o, and δ(n)\delta(n) denotes the price spread influenced by size nn at the current price and liquidity. sOIs_\text{OI} is the global open interest and spositions_\text{position} is the position size.

5.5.Close price calculation

Pc=TWAP(λc)(1+kdδ(sΣ(λt)+sposition2) P_c = \text{TWAP} ( \lambda_c ) \cdot ( 1 + k_d \delta(\frac{s_{\Sigma(\lambda_t)} + s_\text{position} }{2}) (8)

Where sΣ(λt)s_{\Sigma(\lambda_t)} represents the accumulated closing size within the latest λt\lambda_t time, and spositions_\text{position} denotes the closing position size. kdk_d is the dynamic spread factor.

Last updated