June 30, 2023
Accurate asset pricing is the lifeblood of Mars. It forms the basis for all transactions including lending and borrowing. Since its inception, Mars Protocol has relied on Time-Weighted Average Price (TWAP)-based oracles to value assets. However, TWAP-based oracles, while reliable, have presented challenges that require Mars to evolve. Today, Martians embark on a new journey with the integration of Pyth Network’s advanced oracles. This radical change resets Mars’ reference assets from OSMO to USD and could ultimately usher in support for off-chain assets on Mars. Let’s explore how.
TWAP-based oracles function by taking the average price of an asset over a certain period of time. This price calculation mitigates the impact of short-term price volatility and provides a more stable pricing mechanism for assets. While resilient and completely on-chain, TWAP-based oracles also have several vulnerabilities, which are explored below.
Price Manipulation Attacks
Price manipulation attacks typically occur when malicious entities influence the market price of an asset to exploit the oracle’s price feed for their own gain, often resulting in bad debt for the protocol. TWAP-based oracles are particularly susceptible to manipulation. In scenarios where on-chain liquidity for a pool is insufficient, the cost for an attacker to manipulate the TWAP price becomes relatively low. By strategically placing trades, they can artificially inflate or deflate the price of an asset. This manipulation can create a discrepancy between the oracle's price feed and the actual market price, opening up opportunities for an attack.
Furthermore, since TWAP-based oracles cannot aggregate off-chain price sources, they can be relatively cheaper for an attacker to manipulate compared to alternatives. This combination of factors makes TWAP-based oracles a prime target for price manipulation attacks.
To mitigate price manipulation attacks, protocols using TWAP-based oracles often have to resort to more conservative parameters. This conservatism, while potentially effective in mitigating such risks, can come at the expense of capital efficiency. Higher amounts of liquidity are required to buffer against the expense and profitability of attacks. This constrains the protocol's scalability and efficiency.
Moreover, the capital inefficiency resulting from TWAP-based oracles can pose a barrier to protocol growth and adoption. Without the ability to price in-demand assets, which may not meet more conservative liquidity requirements, the protocol may struggle to attract liquidity and grow.
The integration of TWAP-based oracles with concentrated liquidity pools presents significant challenges. In contrast to traditional AMMs where liquidity is uniformly distributed across all prices, concentrated liquidity models are more dynamic with liquidity density changing based on the distribution of user-specified price ranges. Given that TWAP-based oracles average the asset price over a certain period, this dynamic and localized variation in liquidity can introduce a level of volatility and potential distortion into the TWAP. The fluctuation of the price within the oracle could therefore be out of sync with wider market movements, making it less reliable as a true reflection of an asset's value.
Furthermore, the potential for new price manipulation attacks increases as malicious actors could exploit the varying liquidity depths by placing trades that specifically target less liquid price ranges. As such, justifying the cost of potential attacks against these types of pools becomes increasingly difficult.
This is especially crucial for Mars given that its premier outpost on Osmosis is in the process of migrating its constant product pools to concentrated liquidity pools, emphasizing the need for more robust oracle solutions.
Embracing the future, the Martian Council has chosen Pythnet as its new oracle solution for pricing assets. Pyth is a sophisticated oracle network that supplies real-time, high-fidelity data feeds.
Multiple Price Feeds
Pyth stands out with its capacity to utilize multiple price sources. This enhances its robustness against price manipulation attacks by making it more expensive and less profitable to exploit.
A distinctive advantage of Pyth oracles is the ability to integrate a TWAP oracle as one of the price feeds, provided it satisfies the required standards. This allows Pyth to inherit the stability and resilience of TWAP-based oracles while also leveraging the benefits of a diversified data source.
Unlike TWAP-based oracles, Pyth's security doesn't rely on a single price source or high liquidity on-chain to ensure accurate price feeds. This feature allows for the listing of more 'long-tail' assets, which might not be available in a conservative lending market using TWAP-based oracles. In addition, Pyth's ability to utilize off-chain price feeds opens up the exciting possibility of integrating off-chain assets into Mars Protocol. This could dramatically broaden the Mars Protocol's scope and usher in an entirely new class of assets into its ecosystem.
TWAP-based oracles, in their efforts to ensure security and mitigate price manipulation risks, often necessitate the implementation of more conservative parameters on assets. One such parameter could be a lower loan-to-value (LTV) ratio, especially for assets with lower liquidity. While this conservatism effectively helps secure the protocol, it also requires more capital to grow and limits the protocol's flexibility to support a wider range of assets.
In contrast, Pyth's oracle solution is designed to reduce dependence on on-chain liquidity. Pyth can aggregate price data from multiple sources, both on-chain and off-chain, effectively diluting the influence of liquidity on any single market and reducing susceptibility to price manipulation. As a result, the protocol could allow higher LTV ratios or less conservative parameters.
Pyth Advanced Features
By default, Pyth incorporates a staleness check, which can cause a query for the current price to fail if too much time has elapsed since the last update. This mechanism is designed to help integrators avoid inadvertently using a stale price, serving as a significant safeguard against outdated price information.
In the future, Pyth could potentially utilize other advanced features such as confidence intervals and EMA/Spot divergence. These features could further enhance the robustness of the oracle system and help mitigate some common concerns associated with TWAP-based oracles.
The integration of Pyth into the protocol presents an opportunity for Mars to refine and strengthen its oracle mechanisms, thus ensuring greater accuracy and reliability in asset pricing. This integration involves two significant changes.
The first relates to Mars' base asset. Previously, Mars operated with OSMO as the reference asset, providing the base value against which all other assets were compared and valued. However, given that Pyth price feeds are denominated in USD, the normalization asset has been revised accordingly.
The second change relates to the specific oracle implementations for each asset. Note that as not all assets are supported by Pyth, a hybrid implementation (where a TWAP and a Pyth-based feed are used) is needed for some.
The following chart shows the new implementation for each asset currently listed on the Red Bank:
Some additional notes for specific assets:
With these changes, Mars can expect a significant enhancement in capital efficiency and scalability, opening the door to listing more diverse assets and increasing the resilience of the protocol against potential attacks. Notwithstanding, the adoption of this new oracle solution does come with certain challenges and adjustments, especially for specific assets.
A protocol’s success is intimately linked with its ability to innovate rapidly and often. Mars is engineered to create the best lending and leverage platform for Martians everywhere. Evolving the protocol’s oracle is merely the first step in exploring the untapped potential that lies ahead.
Mars is a novel interchain credit protocol primitive facilitating non-custodial borrowing and lending for the Cosmos ecosystem and beyond. Its hub and outpost architecture allows Mars to operate on any chain in the Cosmoverse, and enables a new primitive: the Rover. Rovers can give their pilots DeFi superpowers to engage in virtually every governance-approved activity they might encounter on a centralized exchange: spot trading, margin trading, lending and borrowing — all in a single decentralized credit account represented by a transferable NFT. Explore it now at marsprotocol.io or in the Mars v2 Whitepaper.
Engaging in leveraged transactions may be legally restricted in some jurisdictions–please consult your own legal counsel and adhere to your local laws/regulations. Remember, Cosmos, Osmosis, and Mars are experimental technologies. This article does not constitute investment advice and is subject to and limited by the disclaimers and other information contained or referenced in the Mars FUD Bible which you should review before interacting with the protocol.
Jump Crypto, which has interests in Pyth, is an investor in Delphi Labs, which contributes to Mars Protocol. Delphi Ventures shares certain managers & owners with Delphi Labs and is an investor in Pyth.
This message is qualified by the Mars Disclaimers/Disclosures.