You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 28, 2025. It is now read-only.
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.
137
137
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
+
<Callouttype="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>
139
141
140
142
They both are demonstrated in the [Pyth Connector example](https://github.com/pyth-network/pyth-examples/tree/main/price_feeds/ton/pyth-connector). <br/>
141
143
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
146
148
147
149
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.
148
150
149
-
## Pyth proxy: Success
151
+
###Pyth proxy: Success
150
152
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.
151
153
152
154
```mermaid
153
155
sequenceDiagram
154
156
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
163
165
```
164
166
165
167
- Related code (GitHub):
@@ -168,36 +170,36 @@ sequenceDiagram
168
170
-[Pyth proxy: liquidate (TON) in master.fc](https://github.com/evaafi/contracts/blob/d9138cb24f03b53522774351aceb38c51a047eee/contracts/master.fc#L171-L190)
169
171
170
172
171
-
## Pyth proxy: Error handling
173
+
###Pyth proxy: Error handling
172
174
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.
173
175
174
176
```mermaid
175
177
sequenceDiagram
176
178
autonumber
177
-
participant "U" as "User"
178
-
participant "P" as "Pyth Contract"
179
+
participant U as User
180
+
participant P as Pyth Contract
179
181
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
182
184
```
183
185
184
186
185
-
## Pyth onchain-getter: Success
187
+
###Pyth onchain-getter: Success
186
188
187
189
```mermaid
188
190
sequenceDiagram
189
191
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
201
203
```
202
204
203
205
- Related code (GitHub):
@@ -206,22 +208,22 @@ sequenceDiagram
206
208
-[Request to Pyth (liquidate jetton)](https://github.com/evaafi/contracts/blob/d9138cb24f03b53522774351aceb38c51a047eee/contracts/core/master-liquidate.fc#L728-L742)
207
209
-[Request to Pyth (supply_withdraw jetton)](https://github.com/evaafi/contracts/blob/d9138cb24f03b53522774351aceb38c51a047eee/contracts/core/master-supply-withdrawal.fc#L446-L461)
208
210
209
-
## Pyth onchain-getter: Pyth error
211
+
###Pyth onchain-getter: Pyth error
210
212
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.
0 commit comments