We just added a new helper to the pyth-sdk-solidity — deriveCrossRate() — 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.
What’s new
You can now compute a price like:
ETH/EUR = ETH/USD / EUR/USD
Onchain, using this:
int64 crossRate = PythUtils.deriveCrossRate(
price1, expo1,
price2, expo2,
targetExponent
);
Docs: Derive Cross Rates
Bonus: The SDK also includes overflow protection, rounding logic, and edge case handling.
You can see a full working example in our docs here.