Skip to content

chore(pricefeed) Add docs for cross rate #729

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 23, 2025

Conversation

aditya520
Copy link
Member

Description

Type of Change

  • New Page
  • Page update/improvement
  • Fix typo/grammar
  • Restructure/reorganize content
  • Update links/references
  • Other (please describe):

Areas Affected

Checklist

  • I ran pre-commit run --all-files to check for linting errors
  • I have reviewed my changes for clarity and accuracy
  • All links are valid and working
  • Images (if any) are properly formatted and include alt text
  • Code examples (if any) are complete and functional
  • Content follows the established style guide
  • Changes are properly formatted in Markdown
  • Preview renders correctly in development environment

Related Issues

Closes #

Additional Notes

Contributor Information

  • Name:
  • Email:

Screenshots

Copy link

vercel bot commented Jun 23, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 23, 2025 6:17pm
documentation ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 23, 2025 6:17pm

@@ -26,6 +26,7 @@
"use-real-time-data": "Use Real-Time Price Data",
"fetch-price-updates": "Fetch Price Updates",
"schedule-price-updates": "Schedule Price Updates",
"combine-two-price-feeds": "Combine Two Price Feeds / Derive a Cross Rate",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just pick one of these titles -- this is too long.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

imo "derive cross rate" is better than the other one


# Combine Two Price Feeds / Derive a Cross Rate

This guide shows how to combine two price feeds to derive a cross rate. These are also known as "synthetic" price feeds.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this called a synthetic feed? no need for new terminology here imo

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alot of folks asked us if we support synthetic feeds. It helps us with SEO and docs internal search as well.


## Derive a cross rate

Pyth provides [`deriveCrossRate`](https://github.com/pyth-network/pyth-crosschain/blob/main/target_chains/ethereum/sdk/solidity/PythUtils.sol#L77) function to combine two price feeds.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pyth here is imprecise. this should say

The Pyth Solidity SDK provides ...

PythStructs.Price memory ethUsd = pyth.getPriceNoOlderThan(ethUsdId, 60);
PythStructs.Price memory eurUsd = pyth.getPriceNoOlderThan(eurUsdId, 60);

// Derive ETH/EUR = ETH/USD ÷ EUR/USD
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/ not +


- `crossRate`: The computed cross rate (a / c), scaled to targetExponent.

### ⚠️ Things to Keep in Mind
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

imo this should go after the example

@aditya520 aditya520 merged commit 2d2c731 into main Jun 23, 2025
4 of 5 checks passed
@aditya520 aditya520 deleted the chore(pricefeed)-add-combine-pricefeed-docs branch June 23, 2025 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants