-
Notifications
You must be signed in to change notification settings - Fork 37
add pyth patterns info in the pyth-connector example #828
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
base: main
Are you sure you want to change the base?
add pyth patterns info in the pyth-connector example #828
Conversation
Signed-off-by: master_jedy <yura.zarudny@gmail.com>
The latest updates on your projects. Learn more about Vercel for GitHub.
|
@masterjedy is attempting to deploy a commit to the Pyth Network Team on Vercel. A member of the Team first needs to authorize it. |
Signed-off-by: master_jedy <yura.zarudny@gmail.com>
@@ -124,6 +124,28 @@ This code snippet does the following: | |||
4. Prepares the update data and calculates the update fee. | |||
5. Updates the price feeds on the TON contract. | |||
|
|||
When providing Pyth data to your contract, there are typically two main scenarios: either you call a method supplying TON, or you transfer jettons. | |||
|
|||
They both are demonstrated in the [Pyth Connector example](https://github.com/pyth-network/pyth-examples/tree/main/price_feeds/ton/pyth-connector). |
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.
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.
Yes, it's not merged yet.
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.
since the example is not merged yet I can't add links to the code, so I only described the same patterns using EVAA code samples and diagrams
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 feel we should add links to Pyth-connector as well, that would be useful.
@@ -124,6 +124,28 @@ This code snippet does the following: | |||
4. Prepares the update data and calculates the update fee. | |||
5. Updates the price feeds on the TON contract. | |||
|
|||
When providing Pyth data to your contract, there are typically two main scenarios: either you call a method supplying TON, or you transfer jettons. |
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.
Can we refer to the exact connector code block that shows these two scenarios ? That would help folks in better understanding.
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.
connector is not merged yet, I used EVAA code for describing, pls take a look if it's ok.
Signed-off-by: master_jedy <yura.zarudny@gmail.com>
participant "U" as "User" | ||
participant "P" as "Pyth Contract" | ||
|
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.
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.
done
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.
done
participant "U" as "User" | ||
participant "JW" as "Jetton Wallet" | ||
participant "M" as "EVAA Master" | ||
participant "P" as "Pyth Contract" |
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.
remove double quotes
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.
done
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.
done
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.
pre-commit is failing, please fix it.
participant "U" as "User" | ||
participant "JW" as "Jetton Wallet" | ||
participant "M" as "EVAA Master" | ||
participant "P" as "Pyth Contract" |
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.
remove double quotes
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.
done
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.
done
- **Jetton on-chain getter**: `User → Jetton Wallet → EVAA Master → Pyth → EVAA Master → ... (further processing)` | ||
In this pattern, your contract first receives the Pyth data, then forwards it to the Pyth contract for validation, and finally gets the validated prices back. | ||
This approach is useful when you want to transfer jettons to your contract while also providing price data. | ||
*Note: This diagram is simplified. In reality, the "Jetton Wallet" step consists of a sequence of transactions: User's jetton wallet → EVAA jetton wallet → EVAA master. These internal details are omitted here to highlight the main flow and the interaction with Pyth.* |
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.
nit: Can say the data flow instead of diagram
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.
ok
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.
ok, replaced
This approach is useful when you want to transfer jettons to your contract while also providing price data. | ||
*Note: This diagram is simplified. In reality, the "Jetton Wallet" step consists of a sequence of transactions: User's jetton wallet → EVAA jetton wallet → EVAA master. These internal details are omitted here to highlight the main flow and the interaction with Pyth.* |
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.
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.
ok, will try it
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.
replaced with Callout, it looks better.
@@ -124,6 +124,112 @@ This code snippet does the following: | |||
4. Prepares the update data and calculates the update fee. | |||
5. Updates the price feeds on the TON contract. | |||
|
|||
|
|||
# Patterns for Providing Pyth Data to Your Contract |
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.
make it ## as it one level below How to Use Real-Time Data in TON Contracts
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.
ok
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.
fixed
|
||
Each operation described above can result in either a successful outcome or an error. It is important to consider and handle both scenarios for every pattern. | ||
|
||
## Pyth proxy: Success |
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.
make it ### as all these are coming in the navigation bar.
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.
ok
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.
fixed
- [Pyth proxy: liquidate (TON) in master.fc](https://github.com/evaafi/contracts/blob/d9138cb24f03b53522774351aceb38c51a047eee/contracts/master.fc#L171-L190) | ||
|
||
|
||
## Pyth proxy: Error handling |
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.
make it ### as all these are coming in the navigation bar.
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.
ok
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.
fixed
``` | ||
|
||
|
||
## Pyth onchain-getter: Success |
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.
make it ### as all these are coming in the navigation bar.
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.
ok
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.
fixed
- [Request to Pyth (liquidate jetton)](https://github.com/evaafi/contracts/blob/d9138cb24f03b53522774351aceb38c51a047eee/contracts/core/master-liquidate.fc#L728-L742) | ||
- [Request to Pyth (supply_withdraw jetton)](https://github.com/evaafi/contracts/blob/d9138cb24f03b53522774351aceb38c51a047eee/contracts/core/master-supply-withdrawal.fc#L446-L461) | ||
|
||
## Pyth onchain-getter: Pyth error |
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.
make it ### as all these are coming in the navigation bar.
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.
ok
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.
fixed
Thanks @masterjedy for these diagrams. they look great! |
Signed-off-by: master_jedy <yura.zarudny@gmail.com>
Signed-off-by: master_jedy <yura.zarudny@gmail.com>
Description
Provides short description of pyth data flow patterns used in pyth connector example and EVAA code.
Type of Change
documentation
Areas Affected
price_feeds / use-real-time-data / ton.mdx
Checklist
pre-commit run --all-files
to check for linting errorsRelated Issues
Closes #
Additional Notes
Contributor Information
Evaa protocol employee
Screenshots