@@ -118,6 +118,9 @@ module pyth::pyth {
118
118
119
119
// -----------------------------------------------------------------------------
120
120
// Update the cached prices
121
+ //
122
+ // Pyth uses an uses an on-demand update model, where consumers need to update the
123
+ /// cached prices before using them. Please read more about this at https://docs.pyth.network/consume-data/on-demand.
121
124
122
125
/// Update the cached price feeds with the data in the given VAAs. This is a
123
126
/// convenience wrapper around update_price_feeds(), which allows you to update the price feeds
@@ -131,6 +134,8 @@ module pyth::pyth {
131
134
/// from the given funder account to the Pyth contract. The amount of coins that will be transferred
132
135
/// to perform this update can be queried with get_update_fee(&vaas). The signer must have sufficient
133
136
/// account balance to pay this fee, otherwise the transaction will abort.
137
+ ///
138
+ /// Please read more information about the update fee here: https://docs.pyth.network/consume-data/on-demand#fees
134
139
public entry fun update_price_feeds_with_funder (account: &signer , vaas: vector <vector <u8 >>) {
135
140
let coins = coin::withdraw <AptosCoin >(account, get_update_fee (&vaas));
136
141
update_price_feeds (vaas, coins);
@@ -145,6 +150,8 @@ module pyth::pyth {
145
150
///
146
151
/// The given fee must contain a sufficient number of coins to pay the update fee for the given vaas.
147
152
/// The update fee amount can be queried by calling get_update_fee(&vaas).
153
+ ///
154
+ /// Please read more information about the update fee here: https://docs.pyth.network/consume-data/on-demand#fees
148
155
public fun update_price_feeds (vaas: vector <vector <u8 >>, fee: Coin <AptosCoin >) {
149
156
// Charge the message update fee
150
157
assert !(get_update_fee (&vaas) <= coin::value (&fee), error::insufficient_fee ());
@@ -279,9 +286,10 @@ module pyth::pyth {
279
286
/// Please refer to the documentation at https://docs.pyth.network/consumers/best-practices for
280
287
/// how to how this price safely.
281
288
///
282
- /// Important: it is recommended to call update_price_feeds() to update the cached price
283
- /// before calling this function, as get_price() will abort if the cached price is older
284
- /// than the stale price threshold.
289
+ /// Important: Pyth uses an on-demand update model, where consumers need to update the
290
+ /// cached prices before using them. Please read more about this at https://docs.pyth.network/consume-data/on-demand.
291
+ /// get_price() is likely to abort unless you call update_price_feeds() to update the cached price
292
+ /// beforehand, as the cached prices may be older than the stale price threshold.
285
293
///
286
294
/// Note that the price_identifier does not correspond to a seperate Aptos account:
287
295
/// all price feeds are stored in the single pyth account. The price identifier is an
@@ -334,9 +342,10 @@ module pyth::pyth {
334
342
/// Get the latest available exponentially moving average price cached for the given
335
343
/// price identifier, if that price is no older than the stale price threshold.
336
344
///
337
- /// Important: it is recommended to call update_price_feeds() to update the cached EMA price
338
- /// before calling this function, as get_ema_price() will abort if the cached EMA price is older
339
- /// than the stale price threshold.
345
+ /// Important: Pyth uses an on-demand update model, where consumers need to update the
346
+ /// cached prices before using them. Please read more about this at https://docs.pyth.network/consume-data/on-demand.
347
+ /// get_ema_price() is likely to abort unless you call update_price_feeds() to update the cached price
348
+ /// beforehand, as the cached prices may be older than the stale price threshold.
340
349
public fun get_ema_price (price_identifier: PriceIdentifier ): Price {
341
350
get_ema_price_no_older_than (price_identifier, state::get_stale_price_threshold_secs ())
342
351
}
@@ -364,6 +373,8 @@ module pyth::pyth {
364
373
}
365
374
366
375
/// Get the number of AptosCoin's required to perform the given price updates.
376
+ ///
377
+ /// Please read more information about the update fee here: https://docs.pyth.network/consume-data/on-demand#fees
367
378
public fun get_update_fee (update_data: &vector <vector <u8 >>): u64 {
368
379
state::get_base_update_fee () * vector ::length (update_data)
369
380
}
0 commit comments