Conversation
|
Preview deployment for your docs. Learn more about Mintlify Previews.
|
📝 WalkthroughWalkthroughDocumentation update for the Oracle Precompile guide that restructures price-query approaches into three distinct strategies, adds availability clarifications via updated component blocks, expands content with new sections including supported feeds guidance, and improves overall narrative flow around oracle interactions. Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Signed-off-by: Brendan Graetz <bguiz@users.noreply.github.com>
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
.gitbook/developers-evm/oracle-precompile.mdx (2)
150-156:⚠️ Potential issue | 🟠 MajorUnsafe example should use the production-safe method instead.
Line 155 uses
getPriceUnsafewhile the warning at lines 173–177 recommendsgetPriceNoOlderThanfor production. The pattern of showing unsafe code first, then warning about it, creates unnecessary confusion. Replace the example with the recommended safe method:Suggested fix
- const price = await pyth.getPriceUnsafe(priceFeedId); + const maxAge = 60; // seconds + const price = await pyth.getPriceNoOlderThan(priceFeedId, maxAge);This aligns with Pyth's documented production pull-model flow and eliminates reader confusion.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.gitbook/developers-evm/oracle-precompile.mdx around lines 150 - 156, The example uses pyth.getPriceUnsafe (with priceFeedId) which conflicts with the later recommendation; replace the unsafe call with the production-safe pull method pyth.getPriceNoOlderThan using the same priceFeedId and passing an appropriate maxAge (e.g., a timestamp window or seconds) so the snippet demonstrates the recommended production flow—update the variable usage (price) and any downstream references to rely on pyth.getPriceNoOlderThan instead of getPriceUnsafe.
159-161:⚠️ Potential issue | 🟡 MinorFix inverted exponent scaling for positive Pyth exponents.
The code incorrectly handles positive exponents. Since
toHumanReadabledivides by 10^decimals, passingprice.expowhenexpo > 0producesprice / 10^expoinstead of the correctprice * 10^expo. The negative exponent branch (negating to(-price.expo)) is correct by coincidence. The positive branch requires a different approach to multiply by the exponent rather than divide.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.gitbook/developers-evm/oracle-precompile.mdx around lines 159 - 161, The positive-exponent branch is inverted: toHumanReadable(price.price.toString(), price.expo.toString()) divides by 10^expo but for expo>0 we need to multiply by 10^expo. Change the logic so when price.expo > 0 you pass the negated exponent to toHumanReadable (e.g., (-price.expo).toString()) and keep the current negation behavior for non-positive exponents; update the ternary so toHumanReadable is called with (-price.expo).toString() for the positive branch while preserving the .toFixed(2)/.toFixed(4) formatting choices.
🧹 Nitpick comments (1)
.gitbook/developers-evm/oracle-precompile.mdx (1)
50-68: Avoid duplicating volatile oracle metadata inline.Line 50 and Lines 58-68 hardcode values that can drift from upstream. Since you already link canonical sources, prefer framing these as examples and direct users to the source-of-truth pages to reduce doc rot.
Proposed doc tweak
-Currently, Pyth is deployed at `0x36825bf3Fbdf5a29E2d5148bfe7Dcf7B5639e320` on Injective's EVM mainnet. +At the time of writing, Pyth is deployed at `0x36825bf3Fbdf5a29E2d5148bfe7Dcf7B5639e320` on Injective's EVM mainnet. +Always verify the latest address from the official Pyth contract-addresses page above. ### Supported feeds @@ -| INJ/USD | `0x7a5bc1d2b56ad029048cd63964b3ad2776eadf812edc1a43a31406cb54bff592` | +| INJ/USD | `0x7a5bc1d2b56ad029048cd63964b3ad2776eadf812edc1a43a31406cb54bff592` (example; verify latest in Pyth feed registry) |Also applies to: 145-153
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.gitbook/developers-evm/oracle-precompile.mdx around lines 50 - 68, The document hardcodes the Pyth deployment address (0x36825bf3Fbdf5a29E2d5148bfe7Dcf7B5639e320) and a full table of price feed IDs under the "Price feed IDs" / "Supported feeds" sections, which risks doc rot; update these sections to present the address and feed IDs as illustrative examples (e.g., label them "example" or "as of <date>") and replace the full hardcoded table with a short example row (such as INJ/USD) plus a clear pointer to the canonical Pyth pages you already link (Pyth price feed IDs and network deployment docs) for the authoritative, up-to-date list; ensure similar changes are applied to the other repeated block elsewhere in the doc (the second feeds section).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In @.gitbook/developers-evm/oracle-precompile.mdx:
- Around line 150-156: The example uses pyth.getPriceUnsafe (with priceFeedId)
which conflicts with the later recommendation; replace the unsafe call with the
production-safe pull method pyth.getPriceNoOlderThan using the same priceFeedId
and passing an appropriate maxAge (e.g., a timestamp window or seconds) so the
snippet demonstrates the recommended production flow—update the variable usage
(price) and any downstream references to rely on pyth.getPriceNoOlderThan
instead of getPriceUnsafe.
- Around line 159-161: The positive-exponent branch is inverted:
toHumanReadable(price.price.toString(), price.expo.toString()) divides by
10^expo but for expo>0 we need to multiply by 10^expo. Change the logic so when
price.expo > 0 you pass the negated exponent to toHumanReadable (e.g.,
(-price.expo).toString()) and keep the current negation behavior for
non-positive exponents; update the ternary so toHumanReadable is called with
(-price.expo).toString() for the positive branch while preserving the
.toFixed(2)/.toFixed(4) formatting choices.
---
Nitpick comments:
In @.gitbook/developers-evm/oracle-precompile.mdx:
- Around line 50-68: The document hardcodes the Pyth deployment address
(0x36825bf3Fbdf5a29E2d5148bfe7Dcf7B5639e320) and a full table of price feed IDs
under the "Price feed IDs" / "Supported feeds" sections, which risks doc rot;
update these sections to present the address and feed IDs as illustrative
examples (e.g., label them "example" or "as of <date>") and replace the full
hardcoded table with a short example row (such as INJ/USD) plus a clear pointer
to the canonical Pyth pages you already link (Pyth price feed IDs and network
deployment docs) for the authoritative, up-to-date list; ensure similar changes
are applied to the other repeated block elsewhere in the doc (the second feeds
section).
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: d136de87-aa81-4c83-8497-20f443ed05b1
📒 Files selected for processing (1)
.gitbook/developers-evm/oracle-precompile.mdx
Summary by CodeRabbit