Skip to content

Commit 4506245

Browse files
committed
requested updates
1 parent 0928e43 commit 4506245

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

pages/price-feeds/_meta.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"use-real-time-data": "Use Real-Time Price Data",
2727
"fetch-price-updates": "Fetch Price Updates",
2828
"schedule-price-updates": "Schedule Price Updates",
29-
"combine-two-price-feeds": "Combine Two Price Feeds / Derive a Cross Rate",
29+
"derive-cross-rate": "Derive Cross Rate",
3030
"migrate-an-app-to-pyth": "Migrate an App to Pyth",
3131
"use-pyth-for-morpho": "Use Pyth for Morpho Markets",
3232
"publish-data": "Publish Data",

pages/price-feeds/combine-two-price-feeds.mdx renamed to pages/price-feeds/derive-cross-rate.mdx

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Callout } from "nextra/components";
22

3-
# Combine Two Price Feeds / Derive a Cross Rate
3+
# Derive Cross Rate
44

55
This guide shows how to combine two price feeds to derive a cross rate. These are also known as "synthetic" price feeds.
66
Cross rates or Synthetic Price feeds are useful for trading pairs that are not directly supported by Pyth.
@@ -20,7 +20,7 @@ $$
2020

2121
## Derive a cross rate
2222

23-
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.
23+
The Pyth Solidity SDKprovides [`deriveCrossRate`](https://github.com/pyth-network/pyth-crosschain/blob/main/target_chains/ethereum/sdk/solidity/PythUtils.sol#L77) function to combine two price feeds.
2424
This method is available in [Pyth solidity SDK](https://github.com/pyth-network/pyth-crosschain/tree/main/target_chains/ethereum/sdk/solidity).
2525

2626
This method takes the following parameters:
@@ -35,13 +35,6 @@ Returns:
3535

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

38-
### ⚠️ Things to Keep in Mind
39-
40-
- The function reverts if either price is **negative**, or if any exponent is **less than -255**.
41-
- The result is rounded down. If the result is smaller than 1 in the given `targetExponent{:jsx}`, it will return 0.
42-
- Confidence intervals are not derived in this function. If needed, you have to derive them manually.
43-
- Reverts with `PythErrors.ExponentOverflow{:jsx}` if `targetExponent + expo1 - expo2{:jsx}` is outside the range **[-58, 58]**.
44-
4538
## Example
4639

4740
```solidity copy
@@ -72,7 +65,7 @@ contract ExampleCrossRate {
7265
PythStructs.Price memory ethUsd = pyth.getPriceNoOlderThan(ethUsdId, 60);
7366
PythStructs.Price memory eurUsd = pyth.getPriceNoOlderThan(eurUsdId, 60);
7467
75-
// Derive ETH/EUR = ETH/USD ÷ EUR/USD
68+
// Derive ETH/EUR = ETH/USD / EUR/USD
7669
int32 targetExpo = -8;
7770
int64 ethPerEur = PythUtils.deriveCrossRate(
7871
ethUsd.price,
@@ -85,9 +78,17 @@ contract ExampleCrossRate {
8578
return (ethPerEur, targetExpo);
8679
}
8780
}
88-
8981
```
9082

83+
84+
### ⚠️ Things to Keep in Mind
85+
86+
- The function reverts if either price is **negative**, or if any exponent is **less than -255**.
87+
- The result is rounded down. If the result is smaller than 1 in the given `targetExponent{:jsx}`, it will return 0.
88+
- Confidence intervals are not derived in this function. If needed, you have to derive them manually.
89+
- Reverts with `PythErrors.ExponentOverflow{:jsx}` if `targetExponent + expo1 - expo2{:jsx}` is outside the range **[-58, 58]**.
90+
91+
9192
## Additional Resources
9293

9394
You may find these additional resources helpful.

0 commit comments

Comments
 (0)