New Utility in Pyth EVM Contracts: Combine Price Feeds to derive Cross Rates

We just added a new helper to the pyth-sdk-solidityderiveCrossRate() — to make it easier to calculate synthetic prices or cross rates like ETH/EUR, SOL/BTC, etc., using existing Pyth feeds.

This is helpful when Pyth doesn’t directly publish a trading pair you’re interested in — but you can derive it using a ratio of two prices.

:package: What’s new

You can now compute a price like:
ETH/EUR = ETH/USD / EUR/USD

:gear: Onchain, using this:

int64 crossRate = PythUtils.deriveCrossRate(
    price1, expo1,
    price2, expo2,
    targetExponent
);

:open_book: Docs: Derive Cross Rates

:brain: Bonus: The SDK also includes overflow protection, rounding logic, and edge case handling.

You can see a full working example in our docs here.

What if I want to do combine prices on the front end, is there any way to do this?

If you want to combine price feeds on front end, you can just divide the two prices.
(ETH/USD) / (BTC/USD) = ETH/BTC.