Sui.

Post

Share your knowledge.

harry phan.
Jul 23, 2025
Expert Q&A

what is pyth oracle?

I know Pyth is an a oracle that gives price feeds. but does anybody here worked with Pyth in Move contracts?

  • Sui
  • Architecture
2
8
Share
Comments
.

Answers

8
0xduckmove.
Jul 23 2025, 03:37

pyth hasn't deployed the contract to sui testnet/devnet yet. omnibtc's omnilending is a omnichain lending product with sui as the settlement center. Only Oracle on sui can be used to clear debts, and as many Oracle as possible is needed to avoid single point risk. omnibtc's omnilending has already been developed, except for the Oracle integration piece. Oracle deployed in sui test network has not been found. Therefore, Oracle that can be used on devnet is sought to debug the lending business of omnibtc

But if you want reference:

#[test_only]
module protocol_test::oracle_t {
    use sui::math;
    use sui::test_scenario::{Self, Scenario};
    use x_oracle::x_oracle::{Self, XOracle, XOraclePolicyCap};

    public fun init_t(scenario: &mut Scenario): (XOracle, XOraclePolicyCap) {
        x_oracle::init_t(test_scenario::ctx(scenario));
        let sender = test_scenario::sender(scenario);
        test_scenario::next_tx(scenario, sender);

        (test_scenario::take_shared<XOracle>(scenario), test_scenario::take_from_address<XOraclePolicyCap>(scenario, sender))
    }

    public fun calc_scaled_price(scaled_price: u64, decimals: u8): u64 {
        assert!(decimals <= 9, 1);
        // the oracle price_feed need a scaled price with 9 decimals
        scaled_price * math::pow(10, 9 - decimals)
    }
}
5
Best Answer
Comments
.
HaGiang.
Jul 26 2025, 13:02

Pyth Oracle is a decentralized system that delivers real-time, accurate price data for assets like cryptocurrencies, stocks, forex, and commodities to smart contracts across over 100 blockchains. You can think of it as a bridge connecting real-world market data from trusted sources, like major exchanges and financial firms, to blockchain applications. It uses a pull-based model, meaning you request the latest price when needed, which keeps costs low and data fresh. This makes it ideal for DeFi apps needing reliable, up-to-date pricing for trading, lending, or other financial operations. Read more

10
Comments
.
Morgan.
Sep 7 2025, 22:21

Yeah, definitely! Pyth has a native integration for Sui, which is great. You'd work with the pyth Move package to fetch and verify price feeds directly in your contracts, usually by consuming PriceFeed objects. It's pretty well-supported.

8
Comments
.
shamueely.
Jul 23 2025, 04:22

Pyth is a blockchain oracle that delivers real-time price feeds, especially for assets like cryptocurrencies, stocks, and commodities. When using Pyth in Sui Move contracts, you're accessing externally sourced pricing data that has been aggregated and verified before being pushed on-chain. If you're building a DeFi protocol or any application that relies on external asset prices, you can use Pyth's price feed module to fetch values during your transaction execution. While Pyth isn't deeply integrated into Move by default, Sui provides support for Pyth through custom modules published to mainnet/testnet, like 0x2::pyth, and you’ll often need to interact with those by referencing the price feed’s object ID and ensuring proper module imports. You should be cautious of stale data or missing updates if you're not verifying the freshness of the feed during execution. To explore how to integrate Pyth in your Move contracts and access sample code, check out the docs: https://docs.pyth.network/documentation/pythnet-price-feeds/consuming-price-feeds/using-pyth-on-sui.

3
Comments
.
SuiLover.
Jul 29 2025, 15:21

No.. Not yet, I don't work with pyth racle

1
Comments
.
BigSneh.
Jul 29 2025, 22:37

Pyth Oracle is a decentralized price oracle that delivers real-time market data (like crypto, stocks, FX, commodities) directly on-chain from first-party sources (exchanges, market makers). It's known for high-frequency, low-latency updates and is widely used in DeFi protocols for price accuracy and reliability.

On Sui, Pyth is integrated via its own smart contract modules, allowing developers to fetch verified price data directly in Move. Unlike off-chain oracles like Chainlink (which rely on pushing data into chains), Pyth typically follows a "pull + attest" model, where:

  1. Price publishers submit prices to a Pythnet off-chain.

  2. Consumers (e.g., a front end or keeper) submit those updates to the chain using a price update payload.

  3. Your Move contract verifies the payload using the on-chain Pyth contract module.

Key Concepts When Working with Pyth in Move:

  1. Price Feed IDs: Each asset has a unique ID (a hex identifier) used to fetch its price.

  2. Update Price Data: Clients post price updates (payloads) to the Sui blockchain.

  3. Verification Logic: The Pyth module verifies signatures and validity inside your contract call.

  4. Pull-and-Verify Flow:

Off-chain service fetches the latest price data and sends a signed update.

The update is included in the transaction calling your contract.

Your Move contract uses the pyth::price_feed module to verify and extract the price.

Example Integration Steps:

  1. Import Pyth module in your Move package:

use 0xYourPythAddress::price_feed;

  1. Use a function to read a verified price:

public fun get_price(update: &PythPriceUpdate, clock: &Clock): u64 { let price = price_feed::read_price(update, clock); price.price }

Where PythPriceUpdate is the verified payload passed during the transaction.

CLI Use

You often use the Pyth SDK (Python/TS) to generate the update payload:

pyth-client get-update --price-id 0x... --output update.json

Then use Sui CLI to call your smart contract with the update.

Common Pitfalls

Outdated Prices: Always check the timestamp and confidence interval.

Missing Publisher Signatures: Payloads must be signed by quorum of data publishers.

Clock Object: You need to pass a Sui Clock object to verify freshness.

Storage Costs: Large payloads might inflate gas if not optimized.

Use Cases

Liquidations in Perp DEXs

NFT floor price feeds

Governance-controlled rebalancing

On-chain margining and LP pricing

Let me know if you want a template contract that integrates Pyth on Sui or need testnet Price Feed IDs.

0
Comments
.

Do you know the answer?

Please log in and share it.