Commit 0e328ad
committed
feat(oracles/pyth): add pinocchio example
Adds a Pinocchio implementation of the Pyth oracle example, the first pinocchio
example under oracles/. The single read_price instruction reads a Pyth pull
oracle PriceUpdateV2 account and logs its price fields.
There is no Pyth SDK for Pinocchio, so the account is parsed by hand: the
program checks the account's owner (the Pyth receiver program) and the anchor
account discriminator before trusting the data, then reads the price, confidence,
exponent, and publish time by byte offset. The account's VerificationLevel is a
variable-size Borsh enum, so the price message offset is computed from it.
The litesvm test injects a mock PriceUpdateV2 account with known values via
setAccount and asserts the program logs the parsed fields, plus a second case
that a non-Pyth-owned account is rejected.1 parent 4823810 commit 0e328ad
12 files changed
Lines changed: 3221 additions & 0 deletions
File tree
- oracles/pyth/pinocchio
- program
- src
- instructions
- tests
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
| 76 | + | |
76 | 77 | | |
77 | 78 | | |
78 | 79 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
0 commit comments