pyth-price-feeds
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePyth Price Feeds (Hedera)
Pyth 价格馈送(Hedera)
Pull pattern: Pyth is not a fire-and-forget push feed. Fresh reads usually need a Hermes payload submitted on-chain (payable) before .
getPriceNoOlderThantext
Hermes → updatePriceFeeds{value: fee}(updateData) → getPriceNoOlderThan(priceId, maxAge)Consumers may wrap Pyth behind a local interface; that is optional. Do not assume a project-specific adapter name.
拉取模式: Pyth 不是“即发即弃”的推送式馈送。要读取最新价格,通常需要先在链上提交(需付费)Hermes payload,再调用。
getPriceNoOlderThantext
Hermes → updatePriceFeeds{value: fee}(updateData) → getPriceNoOlderThan(priceId, maxAge)调用方可将Pyth封装在本地接口之后,这是可选操作。请勿默认存在特定项目的适配器名称。
Quick Reference
快速参考
| Piece | Role |
|---|---|
| Pyth contract | Network |
| Price ID | |
| Update | Payable |
| Fee | |
| Read | |
| Confidence | Reject when |
| Scale | Signed |
Hedera chain IDs: testnet , mainnet .
296295See references/hedera-feeds.md for where to source the Pyth contract and price IDs. See references/examples.md for update / read / expo sketches.
| 组件 | 作用 |
|---|---|
| Pyth 合约 | 网络上的 |
| Price ID | |
| 更新 | 需付费的 |
| 费用 | 通过 |
| 读取 | 调用 |
| 置信度 | 当 |
| 数值缩放 | 带符号的 |
Hedera 链ID: 测试网 ,主网 。
296295关于Pyth合约和Price ID的获取方式,请参阅 references/hedera-feeds.md。关于更新、读取、expo处理的示例代码,请参阅 references/examples.md。
Critical: Update Before Fresh Reads
核心注意事项:读取最新价格前必须先更新
If the on-chain price is older than your staleness bound, fetch Hermes update data and submit it:
solidity
function updatePrice(bytes[] calldata updateData) external payable {
uint256 fee = PYTH.getUpdateFee(updateData);
if (msg.value < fee) revert UpdateFeeTooLow(msg.value, fee);
PYTH.updatePriceFeeds{ value: msg.value }(updateData);
}Hedera is tinybars via JSON-RPC — attach enough native value for the Pyth fee. Do not treat a stale as a valid trading price.
msg.valuegetPriceUnsafe如果链上价格的陈旧度超过你的容忍阈值,请获取Hermes更新数据并提交:
solidity
function updatePrice(bytes[] calldata updateData) external payable {
uint256 fee = PYTH.getUpdateFee(updateData);
if (msg.value < fee) revert UpdateFeeTooLow(msg.value, fee);
PYTH.updatePriceFeeds{ value: msg.value }(updateData);
}在Hedera上,通过JSON-RPC传递的单位为tinybars——请附加足够的原生代币以支付Pyth费用。请勿将过期的返回值作为有效交易价格使用。
msg.valuegetPriceUnsafeCritical: Confidence And Signed Expo
核心注意事项:置信度与带符号expo
After :
getPriceNoOlderThan| Check | Why |
|---|---|
| Incomplete |
| Invalid / non-positive |
| Confidence wider than the price |
Normalize | |
solidity
PythStructs.Price memory price = PYTH.getPriceNoOlderThan(priceId, maxStaleness);
if (price.publishTime == 0) revert IncompleteRound();
if (price.price <= 0) revert InvalidPrice();
if (price.conf > uint64(price.price)) revert InvalidConfidence();调用之后需检查:
getPriceNoOlderThan| 检查项 | 原因 |
|---|---|
| 数据不完整 |
| 价格无效/为非正值 |
| 置信区间宽度超过价格本身 |
标准化 | |
solidity
PythStructs.Price memory price = PYTH.getPriceNoOlderThan(priceId, maxStaleness);
if (price.publishTime == 0) revert IncompleteRound();
if (price.price <= 0) revert InvalidPrice();
if (price.conf > uint64(price.price)) revert InvalidConfidence();Checklist
检查清单
When implementing or reviewing Pyth on Hedera:
- Pyth contract + price IDs taken from Pyth Hedera / Hermes docs (not Ethereum defaults)
- Hermes payloads submitted with sufficient before relying on a fresh price
msg.value - Reads use (or equivalent max-age API), not unbounded unsafe prices for trading
getPriceNoOlderThan - Confidence wider than price reverts
- Signed normalized to the consumer scale
expo - Chain ID is or
295(or the project’s documented Hedera network)296
在Hedera上实现或审核Pyth集成时,请确认:
- Pyth 合约和Price ID取自Pyth Hedera / Hermes官方文档(而非Ethereum默认值)
- 在依赖最新价格之前,已提交Hermes payload并附带足额的
msg.value - 读取操作使用(或等效的带最大陈旧时间限制的API),而非用于交易的无限制不安全价格
getPriceNoOlderThan - 置信度超过价格时会触发回滚
- 带符号的已标准化为调用方所需的数值精度
expo - 链ID为或
295(或项目文档中指定的Hedera网络)296
References
参考资料
- references/examples.md — update, read, and expo sketches
- references/hedera-feeds.md — where to source Pyth contract and price IDs
- Pyth Price Feeds
- Pyth EVM contract addresses
- Hermes price feeds
- references/examples.md — 更新、读取与expo处理示例
- references/hedera-feeds.md — Pyth合约与Price ID获取方式
- Pyth Price Feeds
- Pyth EVM contract addresses — Pyth EVM合约地址
- Hermes price feeds — Hermes价格馈送