-
Notifications
You must be signed in to change notification settings - Fork 31
Add Solana TWAP documentation #650
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-Authored-By: Tejas Badadare <[email protected]>
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Co-Authored-By: Tejas Badadare <[email protected]>
Co-Authored-By: Tejas Badadare <[email protected]>
Co-Authored-By: Tejas Badadare <[email protected]>
<Callout type="warning" emoji="⚠️"> | ||
The TWAP window is currently limited to a maximum of 10 minutes (600 seconds). | ||
</Callout> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't make this a callout, just add the sentence to the previous block
use pyth_solana_receiver_sdk::price_update::{TwapUpdate}; | ||
|
||
#[derive(Accounts)] | ||
#[instruction(amount_in_usd : u64, twap_window_seconds: u64)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
amount_in_usd
is unused in this example, remove it.
|
||
### Using TWAP in Solana Programs | ||
|
||
To use TWAP in your Solana program, import the `TwapUpdate` struct from the Pyth Solana receiver SDK: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mention that this process is the same as pulling a regular price update from hermes and posting it on chain
…nused parameter, mention similarity to regular price updates Co-Authored-By: Tejas Badadare <[email protected]>
The [Solana TWAP example](https://github.com/pyth-network/pyth-examples/tree/main/price_feeds/solana/send_usd) demonstrates how to fetch TWAP data from Hermes, post it to Solana, and consume it from a smart contract. The example includes: | ||
|
||
- A React frontend for interacting with the contract | ||
- A Solana program that consumes TWAP updates | ||
- Complete transaction building for posting and consuming TWAP data | ||
|
||
The example allows users to send a USD-denominated amount of SOL using either spot prices or TWAP prices, demonstrating how TWAP can be used to reduce the impact of price volatility. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I might clarify the wording here since I believe this is an existing demo app to which you've added TWAP functionality.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice.
…unctionality Co-Authored-By: Tejas Badadare <[email protected]>
Add user-facing documentation for the new Solana TWAP feature as requested by Tejas Badadare ([email protected]).
Link to Devin run: https://app.devin.ai/sessions/8fc45da0232549e5a9f87dbc5d54495d