@@ -3,7 +3,7 @@ use anchor_lang::prelude::*;
3
3
use solana_program:: account_info:: AccountInfo ;
4
4
use pyth_sdk_solana:: load_price_feed_from_account_info;
5
5
6
- declare_id ! ( "Fwn1fCmbjd8d95hxY9NUUr5Xa7D13khveMnmCUFdd3ah " ) ;
6
+ declare_id ! ( "9azQ2ePzPvMPQgHric53kdSNmwjVM5KijDE4ANFCE9D4 " ) ;
7
7
8
8
#[ account]
9
9
pub struct AdminConfig {
@@ -54,7 +54,9 @@ pub mod example_sol_anchor_contract {
54
54
// https://docs.pyth.network/consume-data/best-practices
55
55
let feed1 = load_price_feed_from_account_info ( pyth_loan_account)
56
56
. map_err ( |_x| error ! ( ErrorCode :: PythError ) ) ?;
57
- let result1 = feed1. get_current_price ( )
57
+ let current_timestamp1 = Clock :: get ( ) ?. unix_timestamp ;
58
+ let result1 = feed1
59
+ . get_price_no_older_than ( current_timestamp1, 60 )
58
60
. ok_or ( ErrorCode :: PythOffline ) ?;
59
61
let loan_max_price = result1
60
62
. price
@@ -75,7 +77,9 @@ pub mod example_sol_anchor_contract {
75
77
// https://docs.pyth.network/consume-data/best-practices
76
78
let feed2 = load_price_feed_from_account_info ( pyth_collateral_account)
77
79
. map_err ( |_x| error ! ( ErrorCode :: PythError ) ) ?;
78
- let result2 = feed2. get_current_price ( )
80
+ let current_timestamp2 = Clock :: get ( ) ?. unix_timestamp ;
81
+ let result2 = feed2
82
+ . get_price_no_older_than ( current_timestamp2, 60 )
79
83
. ok_or ( ErrorCode :: PythOffline ) ?;
80
84
let collateral_min_price = result2
81
85
. price
0 commit comments