Skip to content
This repository was archived by the owner on Nov 28, 2025. It is now read-only.

Commit 41c0c96

Browse files
committed
fix review issues
Signed-off-by: master_jedy <[email protected]>
1 parent ce855c0 commit 41c0c96

File tree

1 file changed

+42
-40
lines changed
  • pages/price-feeds/use-real-time-data

1 file changed

+42
-40
lines changed

pages/price-feeds/use-real-time-data/ton.mdx

Lines changed: 42 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
description: Consume Pyth Network prices in TON applications
33
---
44

5-
import { Tabs } from "nextra/components";
5+
import { Tabs, Callout } from "nextra/components";
66

77
# How to Use Real-Time Data in TON Contracts
88

@@ -125,7 +125,7 @@ This code snippet does the following:
125125
5. Updates the price feeds on the TON contract.
126126

127127

128-
# Patterns for Providing Pyth Data to Your Contract
128+
## Patterns for Providing Pyth Data to Your Contract
129129

130130
There are typically two main scenarios: either you call a method supplying TON, or you transfer jettons.
131131

@@ -135,7 +135,9 @@ Use this method if you only need to send TON to your contract or simply call a c
135135
- **Jetton on-chain getter**: `User → Jetton Wallet → EVAA Master → Pyth → EVAA Master → ... (further processing)`
136136
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.
137137
This approach is useful when you want to transfer jettons to your contract while also providing price data.
138-
*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.*
138+
<Callout type="info" emoji="ℹ️">
139+
This data flow 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.
140+
</Callout>
139141

140142
They both are demonstrated in the [Pyth Connector example](https://github.com/pyth-network/pyth-examples/tree/main/price_feeds/ton/pyth-connector). <br/>
141143
These same patterns are also used in the [EVAA Protocol code](https://github.com/evaafi/contracts/tree/v8) for implementing following operations:
@@ -146,20 +148,20 @@ Choose the pattern that best fits your use case and how you want to handle asset
146148

147149
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.
148150

149-
## Pyth proxy: Success
151+
### Pyth proxy: Success
150152
In the EVAA protocol, the operations that implement the Pyth proxy pattern are <b>`liquidate (TON)`</b> and <b>`supply_withdraw (TON)`</b>. In these cases, the user sends a request to the Pyth contract using the native TON asset. As a result of the operation, the user may receive either TON or JETTON tokens back, depending on the outcome of the transaction.
151153

152154
```mermaid
153155
sequenceDiagram
154156
autonumber
155-
participant "U" as "User"
156-
participant "P" as "Pyth Contract"
157-
participant "M" as "EVAA Master"
158-
159-
note over "M": master.fc:121 — received from Pyth (op 5)
160-
"U"->>"P": request (0x3 liquidate_master or 0x4 supply_withdraw_master)
161-
"P"-->>"M": op 5 parse_price_feed_updates (prices)
162-
note over "M": Master accepts and processes the transaction
157+
participant U as User
158+
participant P as Pyth Contract
159+
participant M as EVAA Master
160+
161+
note over M: master.fc:121 — received from Pyth (op 5)
162+
U->>P: request (0x3 liquidate_master or 0x4 supply_withdraw_master)
163+
P-->>M: op 5 parse_price_feed_updates (prices)
164+
note over M: Master accepts and processes the transaction
163165
```
164166

165167
- Related code (GitHub):
@@ -168,36 +170,36 @@ sequenceDiagram
168170
- [Pyth proxy: liquidate (TON) in master.fc](https://github.com/evaafi/contracts/blob/d9138cb24f03b53522774351aceb38c51a047eee/contracts/master.fc#L171-L190)
169171

170172

171-
## Pyth proxy: Error handling
173+
### Pyth proxy: Error handling
172174
In the Pyth proxy pattern, when an error occurs (i.e., Pyth cannot process the request and sends a `response_error` with op 0x10002), the error report is sent directly back to the user who initiated the transaction, not to a contract. This is different from the on-chain getter pattern, where the error is returned to the EVAA Master contract for further handling and potential refund logic. In the proxy case, the user receives the error response from the Pyth contract, including the error code and the original query ID, allowing the user to identify and handle the failure on their side.
173175

174176
```mermaid
175177
sequenceDiagram
176178
autonumber
177-
participant "U" as "User"
178-
participant "P" as "Pyth Contract"
179+
participant U as User
180+
participant P as Pyth Contract
179181
180-
"U"->>"P": request
181-
"P"-->>"U": response_error (op 0x10002) with error_code and query_id
182+
U->>P: request
183+
P-->>U: response_error (op 0x10002) with error_code and query_id
182184
```
183185

184186

185-
## Pyth onchain-getter: Success
187+
### Pyth onchain-getter: Success
186188

187189
```mermaid
188190
sequenceDiagram
189191
autonumber
190-
participant "U" as "User"
191-
participant "JW" as "Jetton Wallet"
192-
participant "M" as "EVAA Master"
193-
participant "P" as "Pyth Contract"
194-
195-
"U"->>"JW": transfer with forward_payload
196-
note right of "U": op: liquidate_master or supply_withdraw_master_jetton
197-
"JW"->>"M": transfer_notification
198-
"M"->>"P": op 5 parse_price_feed_updates<br/>+ update_data + target_feeds<br/>+ op_payload(liquidate_master_jetton_process / supply_withdraw_master_jetton)
199-
"P"-->>"M": op 5 parse_price_feed_updates<br/>(prices, pyth_sender = M)
200-
note over "M": Master accepts and processes the transaction
192+
participant U as User
193+
participant JW as Jetton Wallet
194+
participant M as EVAA Master
195+
participant P as Pyth Contract
196+
197+
U->>JW: transfer with forward_payload
198+
note right of U: op: liquidate_master or supply_withdraw_master_jetton
199+
JW->>M: transfer_notification
200+
M->>P: op 5 parse_price_feed_updates<br/>+ update_data + target_feeds<br/>+ op_payload(liquidate_master_jetton_process / supply_withdraw_master_jetton)
201+
P-->>M: op 5 parse_price_feed_updates<br/>(prices, pyth_sender = M)
202+
note over M: Master accepts and processes the transaction
201203
```
202204

203205
- Related code (GitHub):
@@ -206,22 +208,22 @@ sequenceDiagram
206208
- [Request to Pyth (liquidate jetton)](https://github.com/evaafi/contracts/blob/d9138cb24f03b53522774351aceb38c51a047eee/contracts/core/master-liquidate.fc#L728-L742)
207209
- [Request to Pyth (supply_withdraw jetton)](https://github.com/evaafi/contracts/blob/d9138cb24f03b53522774351aceb38c51a047eee/contracts/core/master-supply-withdrawal.fc#L446-L461)
208210

209-
## Pyth onchain-getter: Pyth error
211+
### Pyth onchain-getter: Pyth error
210212
Pyth sends an error response (`response_error`, op 0x10002) when it cannot process the price feed update request. This can happen if the request is malformed, contains invalid or outdated feed data, or if the requested feeds are unavailable. In such cases, the error response includes an error code and the original operation payload, allowing the original sender (EVAA Master contract) to handle the failure and refund the user if necessary.
211213

212214
```mermaid
213215
sequenceDiagram
214216
autonumber
215-
participant "U" as "User"
216-
participant "JW" as "Jetton Wallet"
217-
participant "M" as "EVAA Master"
218-
participant "P" as "Pyth Contract"
219-
220-
"U"->>"JW": transfer with forward_payload
221-
"JW"->>"M": transfer_notification
222-
"M"->>"P": request (op 5 parse_price_feed_updates)
223-
"P"-->>"M": response_error (op 0x10002)
224-
"M"-->>"U": refund with error code
217+
participant U as User
218+
participant JW as Jetton Wallet
219+
participant M as EVAA Master
220+
participant P as Pyth Contract
221+
222+
U->>JW: transfer with forward_payload
223+
JW->>M: transfer_notification
224+
M->>P: request (op 5 parse_price_feed_updates)
225+
P-->>M: response_error (op 0x10002)
226+
M-->>U: refund with error code
225227
```
226228

227229
- Related code (GitHub):

0 commit comments

Comments
 (0)