Oracle for Perpetual Futures

Building
Perpetual Futures

This guide offers a high-level overview of perpetual futures and how perpetual protocols leverage price oracles.

What are Perpetual Futures?

Perpetual futures or “perps” are a popular derivative product in cryptocurrency trading. They are unique in that they do not have an expiration date like traditional futures contracts. Instead, they are designed to track the price of an underlying asset, typically a cryptocurrency, in perpetuity. Perpetual futures offer flexible trading options, increased liquidity, and efficient risk management, attracting seasoned and novice traders.

Perpetual futures enable traders to speculate on the price movements of an underlying asset without the need for ownership or physical delivery. These contracts offer leverage, allowing traders to amplify their exposure to potential gains or losses. Furthermore, the perpetual nature of these contracts allow for uninterrupted trading and eliminates the need for contract roll-overs.

Perpetual Futures in Practice

Perpetual futures are typically settled using a funding mechanism to maintain a balance between the market price and the underlying reference price, often based on an index. This mechanism involves regular funding payments between long and short positions to maintain balance and prevent the futures price from deviating significantly from the spot price. This mechanism makes use of price oracles to track the underlying.

By using a funding mechanism, perpetual futures discourage market manipulation and promote fair price discovery. Traders are motivated to engage in arbitrage activities to capture the funding payments and help align the contract's price with the spot price. This mechanism also encourages efficient trading strategies and discourages the creation of artificial imbalances between long and short positions.

You can start building perpetual futures and request real-time oracle price updates right away with Pyth Price Feeds.

Explore our docs to get started.

Perpetual Futures: How Do They Work?

Perpetual futures involve a number of mechanisms for enabling sustainable leverage, timely payouts, and accurate settlements.

Leverage

Perpetual futures offer traders the ability to amplify their exposure to price movements through leverage. Leverage allows traders to control a larger position size with a smaller amount of capital. Higher leverage magnifies potential gains but also increases the risk of losses.

Margin Requirements

Perpetual futures require traders to provide collateral, known as margin, to enter into trading positions. Margin requirement is expressed as a percentage of the notional value of the position.

Margin serves as a form of security and ensures that traders have sufficient funds to cover potential losses. Traders must maintain a minimum margin level to keep their positions open. Margin requirements vary depending on the platform, asset, and leverage chosen.

Initial Margin

Initial margin refers to the minimum collateral amount required to open a perpetual futures position, expressed as a percentage of the notional value of the position. The initial margin amount is determined based on factors such as the asset's volatility, liquidity, and leverage chosen. Higher leverage often requires a larger initial margin.

Maintenance Margin

Maintenance margin refers to the minimum margin level that traders must maintain in their trading accounts to avoid liquidation of their positions. If the margin falls below the maintenance margin level, it triggers a margin call, prompting the trader to either add more collateral or reduce their position size to meet the requirement.

Maintaining the maintenance margin is crucial to prevent the automatic liquidation of positions, which occurs when the margin balance is insufficient to cover potential losses.

Liquidation

Liquidation is a risk management mechanism implemented to safeguard traders' capital. When a liquidation event is triggered, the trader's position is automatically closed by the platform, and their collateral is used to repay the debt incurred.

The liquidation process typically involves auctioning off the trader's collateral to other participants, ensuring the orderly settlement of the position. By enforcing liquidations, perpetual futures platforms can maintain the solvency of the system and prevent the accumulation of unmanageable losses.

Funding Rate

Decentralized perpetual futures utilize a funding mechanism to maintain the contract's price alignment with the underlying asset's spot price. Funding rates are periodic payments exchanged between long and short positions in the contract. If the perpetual futures price deviates from the spot price, the funding rate adjusts to incentivize traders to bring the price back in line.

Mark Price

The mark price represents the fair valuation of the perpetual futures contract at any time. It is typically calculated using a combination of the underlying spot price and an index price.

By incorporating the mark price, decentralized perpetual futures platforms ensure that the funding mechanism and liquidation calculations are based on a reliable, objective price reference, mitigating the impact of market volatility and potential manipulation.

How Perpetual Futures Use Oracles

This section explains the importance of oracles for perpetual futures as they track the prices of underlying assets without expiry.

Tracking Underlying Assets

Perpetual futures contracts need to closely track the spot price of the underlying asset. Price oracles provide the current market price, allowing the perpetual contract to adjust its price accordingly. By continuously fetching spot price data from price oracles, the contract can maintain a price that mirrors the real-time value of the underlying asset.

Oracles provide this essential price information by acting as trusted data sources. Pyth oracles, for example, will publish a secure and verified price that is aggregated from the real-time inputs by various exchanges and liquidity pools for that underlying asset.

Determining Funding Rates

Funding rates in perpetual futures contracts help ensure that the contract's price aligns with the prevailing market price of the underlying asset. Price oracles play a role in determining the funding rate. The funding rate calculation often includes a comparison between the contract's price and the spot price reported by the oracle. The funding rate is used to adjust the contract's price periodically, ensuring its correlation with the underlying asset.

An oracle specializing in low-latency price updates is crucial for this function. Pyth provides both real-time price feeds and historical prices via Pyth Benchmarks to facilitate delayed settlement or backfilling of orders in response to latency arbitrage.

Determining Settlement Price

When a trader exits their position in a perpetual futures contract, the settlement price is used to determine the final payout. The settlement price is typically based on the spot price of the underlying asset at a specific reference time.

Price oracles provide the necessary spot price data for this reference time, allowing the contract to calculate the settlement price accurately. By aggregating multiple price feeds from reliable sources, oracles like Pyth can derive a precise settlement price that is resistant to manipulation and ensures transparency in the contract's valuation.

Pyth is also the only oracle which provides confidence intervals—confidence bands around the reported price that reflect the level of volatility and price divergence between market venues. A wider confidence band (e.g. ETH/USD at $2,000 ± $20 instead of ± $2) indicates greater “uncertainty” and divergence between liquidity venues. Developers can design their perpetual trading platform to respond to significant changes in confidence interval data to protect users and platform funds.

Perpetual Futures Glossary

This glossary provides the most common terms in the perpetuals space.

Arbitrage

Exploiting price discrepancies to profit from simultaneous trades on different platforms.

Decentralized Exchange (DEX)

Platforms allowing peer-to-peer trading without central authority.

Decentralized Finance (DeFi)

Financial services built on blockchain technology, accessible to anyone without intermediaries.

Funding Rate

A periodic rate exchanged between long and short positions to maintain contract price alignment with the underlying asset's spot price.

Hedging

Reducing risk exposure by taking offsetting positions in different markets.

Index Price

Refers to the calculated average value of an underlying asset's price across multiple trading platforms or exchanges, often determined through a weighted or arithmetic methodology.

Initial Margin

The minimum collateral required to open a perpetual futures position.

Leverage

Allows traders to control larger positions with a fraction of the total value by using borrowed funds.

Limit Order

Execution of a trade at a specific price or better.

Liquidation

Automatic position closure when the collateral falls below the maintenance margin, avoiding negative balances.

Long Position

Traders betting on asset price increase.

Maker Fee

Charged to traders providing liquidity to the order book.

Maintenance Margin

The minimum required collateral to keep a perpetual futures position open.

Mark Price

Used to calculate PnL and trigger liquidation, often based on an average of spot and contract prices.

Market Order

Immediate execution of a trade at the best available price.

Open Interest

Total value of active positions in a perpetual futures contract.

Perpetual Future

A type of derivative contract that tracks the price of an underlying asset with no set expiry, often used for trading and hedging.

Perpetual Swaps

Another term for perpetual futures contracts.

Short Position

Traders speculating on asset price decrease.

Spot Price

Current market price of the underlying asset.

Stop Order

Becomes a market order when a certain price is reached, limiting losses or locking profits.

Synthetic Assets

Derivatives mirroring asset prices without direct ownership.

Take-Profit Order

Closes a position at a specific profit target.

Taker Fee

Charged to traders taking liquidity from the order book.

Discover More Guides

Our guides cover popular DeFi solutions and how developers can leverage price oracles to create a unique, compelling product.

Lending

Borrowing and Lending

DEXs

Perpetual Futures

Derivatives

Options and Structured Product Vaults

Stablecoins

Stablecoins

integratingbg

Integrate Seamlessly

Pyth’s comprehensive suite of APIs solves all your financial data needs. Access to Pyth prices is permissionless and easy—no subscription necessary.

Developers can get started with our documentation, integration resources, and best practice guides. Watch along to learn how Pyth can super-charge your decentralized app.