pyth-crosschain/target_chains/solana
guibescos 926aa55f75
fix: Make room for compute ixs (#1349)
* Make room for compute ixs

* Continue

* Fix syntax

* Fix contract manager

* Go

* Refacotr import
2024-03-11 18:58:11 +00:00
..
cli Move deps to the workspace level (#1332) 2024-03-01 13:24:41 +00:00
migrations [solana] Start to implement the solana receiver contract (#557) 2023-02-15 15:43:51 +00:00
program_simulator Move deps to the workspace level (#1332) 2024-03-01 13:24:41 +00:00
programs/pyth-solana-receiver fix: solana audit 3 (#1334) 2024-03-01 19:24:49 +00:00
pyth_solana_receiver_state feat(solana) : rust sdk (#1303) 2024-02-22 16:15:56 +00:00
scripts [solana] Fix idl (#1279) 2024-02-06 11:36:19 +00:00
sdk/js fix: Make room for compute ixs (#1349) 2024-03-11 18:58:11 +00:00
target/idl [solana] Fix idl (#1279) 2024-02-06 11:36:19 +00:00
.gitignore feat(solana): js sdk (#1307) 2024-02-28 20:45:48 +00:00
.prettierignore [solana] Start to implement the solana receiver contract (#557) 2023-02-15 15:43:51 +00:00
Anchor.toml [solana] Fix idl (#1279) 2024-02-06 11:36:19 +00:00
Cargo.lock Move deps to the workspace level (#1332) 2024-03-01 13:24:41 +00:00
Cargo.toml Move deps to the workspace level (#1332) 2024-03-01 13:24:41 +00:00
README.md [Solana] improve script (#1282) 2024-02-08 12:44:51 +00:00
rust-toolchain.toml Solana receiver decode vaa accumulator (#1145) 2023-11-30 16:04:41 -05:00

README.md

Pyth Solana Receiver

This folder contains:

  • A Pyth receiver program to receive Pythnet price feeds on Solana in programs/pyth-solana-receiver
  • A Cli that acts as a simple client to interact with the Pyth receiver program in cli/

Overview of the design

Receiving a price update from Pythnet involves two steps:

  • First, verifying the VAA i.e. verifying the Wormhole guardians' signatures on the accumulator root that contains all the price updates for a given Pythnet slot.
  • Second, verifying the price update by providing an inclusion proof that proves the price update is part of the accumulator root that was verified in the first step.

Implementation

This contract offers two ways to post a price update from Pythnet onto Solana:

  • post_update allows you to do it in 2 transactions and checks all the Wormhole guardian signatures (the quorum is currently 13 signatures). It relies on the Wormhole contract to verify the signatures.
  • post_update_atomic allows you to do it in 1 transaction but only partially checks the Wormhole guardian signatures (5 signatures seems like the best it can currently do). Therefore it is less secure. It relies on a guardian set account from the Wormhole contract to check the signatures against the guardian keys.

post_update is also a more efficient way to post updates if you're looking to post data for many different price feeds at a single point in time. This is because it persists a verified encoded VAA, so guardian signatures will only get checked once. Then that single posted VAA can be used to prove the price update for all price feeds for that given point in time.

Devnet deployment

The program is currently deployed on Devnet and Eclipse Testnet with addresses:

  • HDwcJBJXjL9FpJ7UBsYBtaDjsBUhuLCUYoz3zr8SWWaQ for the Wormhole receiver
  • rec5EKMGg6MxZYaMdyBfgwp4d5rB9T1VQH5pJv5LtFJ for the Pyth receiver

Example flow

The cli folder contains some useful client code to interact with both the Wormhole receiver and the Pyth receiver.

To run the full flow of posting a price update (on devnet) please follow the following steps:

Get a Hermes update from Hermes stable:

curl  "https://hermes.pyth.network/api/latest_vaas?ids[]=0xff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace"

Post it to devnet:

cargo run --package pyth-solana-receiver-cli -- --url https://api.devnet.solana.com --keypair ${PATH_TO_KEYPAIR} --wormhole HDwcJBJXjL9FpJ7UBsYBtaDjsBUhuLCUYoz3zr8SWWaQ post-price-update-atomic -p ${HERMES_UPDATE_IN_BASE_64}

or

cargo run --package pyth-solana-receiver-cli -- --url https://api.devnet.solana.com --keypair ${PATH_TO_KEYPAIR} --wormhole HDwcJBJXjL9FpJ7UBsYBtaDjsBUhuLCUYoz3zr8SWWaQ post-price-update -p ${HERMES_UPDATE_IN_BASE_64}