back03 May 20234 min read
blog post image

Econia Labs and Pyth Empower Developers with Orderbook and Oracle Tooling

DeFi has emerged as one of the most transformative and challenging movements in the financial world. The potential to democratize access to financial services and create more inclusive markets continues to capture the imagination of ambitious developers.

In this spirit, today brings exciting news to those developers. Builders on Aptos can now compose with Econia’s hyper-parallelized on-chain order book while leveraging live and historical data from the Pyth Network financial oracle. The implications for margin trading and derivatives settlement are groundbreaking.

Building on Aptos with Pyth and Econia

Pyth Network is a financial oracle delivering 200+ price feeds across crypto, forex pairs, equities, and commodities. Pyth introduces unique design choices in data sourcing and delivery to empower builders with ultra low-latency and high-fidelity price data.

In terms of sourcing, Pyth harnesses real-time, and often guarded, market data from financial institutions who actively participate in price discovery, and delivers this data to more than 18 blockchains including Aptos. Pyth also introduces a unique pull oracle, which enables Pyth to scale to thousands of feeds and update its prices more than once per second, faster than the block time of most blockchains.

The permissionless and liberating ethos of Pyth, reminiscent of Econia’s mission to innovate outdated market designs, provides a strong foundation for delivering institutional-quality services in the decentralized finance space. In anticipation of MOVE Monday by Aptos (coming up this May 8), this article offers a deep dive into two powerful primitives offered by Pyth Network and Econia–low-latency pull oracles and the Econia order book–which enable Defi developers to achieve the latencies, security, and accuracies expected in the CeFi world.

“We are excited by Pyth’s pioneering vision of on-chain financial data for any asset under the sun, and see tremendous potential for Aptos ecosystem developers to make use of this revolutionary public good,” said Alex, CTO and Co-Founder of Econia Labs.


Building a Perpetual Exchange

One example includes Aptos-based perpetual exchanges. A perpetuals DEX can utilize the Econia order book as a matching and settlement layer while using Pyth oracle data to determine the fair and historical value of underlying assets to calculate:

Funding Rates: Funding rates are the periodic fees charged to traders to maintain their positions.

  • The funding rate is calculated based on the difference between the perpetual contract's price and the underlying asset's index price.
  • A perpetuals exchange can use Pyth's low-latency price feeds to obtain the most up-to-date index prices and calculate the funding rates accordingly.

Margin Requirements: Margin requirements are the minimum amount of collateral required to open and maintain a position.

  • An exchange can use Pyth's price feeds to calculate the current market value of the collateral and the underlying asset, and apply a margin requirement based on the desired level of leverage.
  • This calculation can be done in real-time to ensure that margin requirements are always up-to-date.
  • Pyth also provides Confidence Intervals to inform protocols about price uncertainty or divergences across market venues. This data empowers lending platforms to respond to market volatility and uncertainty accordingly when determining when to liquidate.

Liquidation Prices: Liquidation prices are the prices at which a trader's position will be automatically liquidated if the market moves against them.

  • An exchange can use Pyth prices to monitor the current market price of the underlying asset and calculate the liquidation price based on the trader's leverage and margin requirements.
  • This calculation can be done in real-time to ensure that liquidation prices accurately track the markets.

Building Borrow-Lending

Another exciting integration idea which utilizes Econia's order book engine and Pyth data feeds is borrowing and lending. As of today, successful money markets protocols are pool-based and not order-book based due to architectural complexity. However, the latter approach does provide significant benefits:

Better price discovery: In order book-based protocols, borrowers and lenders can set their own interest rates, which means that the market can accurately reflect the supply and demand for the asset being borrowed or lent.

Greater liquidity: Order book-based protocols tend to have greater liquidity than pool-based protocols. This is because in a pool-based protocol, liquidity is determined by the size of the pool, which can be limited.

Better risk management: Order book-based protocols can offer more robust risk management tools than pool-based protocols.

Now that Pyth has provided a groundbreaking on-chain oracle solution, there is a path forward for the broader Aptos DeFi ecosystem to build out perpetual futures exchanges on top of Econia’s lightning-fast order book infrastructure. With its source code audited and published on testnet, the Econia Labs team is building out assorted SDKs and developer tooling as well as a reference front-end. Now is the time for projects to start integrating at the contract level and work their way up the dependency stack alongside Econia Labs, so everyone can go live together.

Many developers have undoubtedly seen the explosive growth of perpetual exchange volume over the first quarter of 2023. We hope these recent trends may inspire builders looking to build on the Econia order book while leveraging Pyth’s low-latency market data.

That team can be you!

Integrating with Pyth data is seamless and straightforward. You can consult this guide for how to get started with Pyth on Aptos or jump straight into the Pyth documentation section available on the Econia docs site.

Get Started


We can’t wait to hear what you think! You can join the Pyth Discord and Telegram, follow us on Twitter, and be the first to hear about what’s new in the Pyth ecosystem through our newsletter. You can also learn more about Pyth here.

Stay Updated with Pyth

Stay informed about Pyth network's development and upcoming events!

Recommended For You

all posts