Skip to content

Commit 2c8efdb

Browse files
authored
Add link to on-demand and update fee docs (#347)
* Add link to update fees section * Add link to on-demand docs * Tweak wording
1 parent f7958e3 commit 2c8efdb

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

aptos/contracts/sources/pyth.move

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@ module pyth::pyth {
118118

119119
// -----------------------------------------------------------------------------
120120
// 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.
121124

122125
/// Update the cached price feeds with the data in the given VAAs. This is a
123126
/// convenience wrapper around update_price_feeds(), which allows you to update the price feeds
@@ -131,6 +134,8 @@ module pyth::pyth {
131134
/// from the given funder account to the Pyth contract. The amount of coins that will be transferred
132135
/// to perform this update can be queried with get_update_fee(&vaas). The signer must have sufficient
133136
/// 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
134139
public entry fun update_price_feeds_with_funder(account: &signer, vaas: vector<vector<u8>>) {
135140
let coins = coin::withdraw<AptosCoin>(account, get_update_fee(&vaas));
136141
update_price_feeds(vaas, coins);
@@ -145,6 +150,8 @@ module pyth::pyth {
145150
///
146151
/// The given fee must contain a sufficient number of coins to pay the update fee for the given vaas.
147152
/// 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
148155
public fun update_price_feeds(vaas: vector<vector<u8>>, fee: Coin<AptosCoin>) {
149156
// Charge the message update fee
150157
assert!(get_update_fee(&vaas) <= coin::value(&fee), error::insufficient_fee());
@@ -279,9 +286,10 @@ module pyth::pyth {
279286
/// Please refer to the documentation at https://docs.pyth.network/consumers/best-practices for
280287
/// how to how this price safely.
281288
///
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.
285293
///
286294
/// Note that the price_identifier does not correspond to a seperate Aptos account:
287295
/// all price feeds are stored in the single pyth account. The price identifier is an
@@ -334,9 +342,10 @@ module pyth::pyth {
334342
/// Get the latest available exponentially moving average price cached for the given
335343
/// price identifier, if that price is no older than the stale price threshold.
336344
///
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.
340349
public fun get_ema_price(price_identifier: PriceIdentifier): Price {
341350
get_ema_price_no_older_than(price_identifier, state::get_stale_price_threshold_secs())
342351
}
@@ -364,6 +373,8 @@ module pyth::pyth {
364373
}
365374

366375
/// 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
367378
public fun get_update_fee(update_data: &vector<vector<u8>>): u64 {
368379
state::get_base_update_fee() * vector::length(update_data)
369380
}

0 commit comments

Comments
 (0)