1
1
use {
2
- super :: {
3
- local:: PriceInfo ,
4
- oracle:: PricePublishingMetadata ,
5
- transactions:: Transactions ,
6
- State ,
7
- } ,
2
+ super :: { State , local:: PriceInfo , oracle:: PricePublishingMetadata , transactions:: Transactions } ,
8
3
crate :: agent:: {
9
4
services:: exporter:: NetworkState ,
10
5
solana:: network:: Network ,
11
- state:: {
12
- global:: GlobalStore ,
13
- keypairs:: Keypairs ,
14
- local:: LocalStore ,
15
- } ,
16
- } ,
17
- anyhow:: {
18
- anyhow,
19
- bail,
20
- Context ,
21
- Result ,
6
+ state:: { global:: GlobalStore , keypairs:: Keypairs , local:: LocalStore } ,
22
7
} ,
8
+ anyhow:: { Context , Result , anyhow, bail} ,
23
9
bincode:: Options ,
24
- bytemuck:: {
25
- bytes_of,
26
- cast_slice,
27
- } ,
10
+ bytemuck:: { bytes_of, cast_slice} ,
28
11
chrono:: Utc ,
29
12
futures_util:: future:: join_all,
30
13
pyth_price_store:: accounts:: buffer:: BufferedPrice ,
31
14
pyth_sdk:: Identifier ,
32
15
pyth_sdk_solana:: state:: PriceStatus ,
33
16
serde:: Serialize ,
34
- solana_client:: {
35
- nonblocking:: rpc_client:: RpcClient ,
36
- rpc_config:: RpcSendTransactionConfig ,
37
- } ,
17
+ solana_client:: { nonblocking:: rpc_client:: RpcClient , rpc_config:: RpcSendTransactionConfig } ,
38
18
solana_pubkey,
39
19
solana_sdk:: {
40
20
compute_budget:: ComputeBudgetInstruction ,
41
- instruction:: {
42
- AccountMeta ,
43
- Instruction ,
44
- } ,
21
+ instruction:: { AccountMeta , Instruction } ,
45
22
pubkey:: Pubkey ,
46
23
signature:: Keypair ,
47
24
signer:: Signer ,
48
25
sysvar:: clock,
49
26
transaction:: Transaction ,
50
27
} ,
51
28
std:: {
52
- collections:: {
53
- BTreeMap ,
54
- HashMap ,
55
- } ,
29
+ collections:: { BTreeMap , HashMap } ,
56
30
sync:: Arc ,
57
31
time:: Duration ,
58
32
} ,
59
- tokio:: sync:: {
60
- watch,
61
- RwLock ,
62
- } ,
33
+ tokio:: sync:: { RwLock , watch} ,
63
34
tracing:: instrument,
64
35
} ;
65
36
@@ -69,12 +40,12 @@ const UPDATE_PRICE_NO_FAIL_ON_ERROR: i32 = 13;
69
40
#[ repr( C ) ]
70
41
#[ derive( Serialize , PartialEq , Debug , Clone ) ]
71
42
struct UpdPriceCmd {
72
- version : u32 ,
73
- cmd : i32 ,
74
- status : PriceStatus ,
75
- unused_ : u32 ,
76
- price : i64 ,
77
- conf : u64 ,
43
+ version : u32 ,
44
+ cmd : i32 ,
45
+ status : PriceStatus ,
46
+ unused_ : u32 ,
47
+ price : i64 ,
48
+ conf : u64 ,
78
49
pub_slot : u64 ,
79
50
}
80
51
@@ -142,9 +113,9 @@ impl<'a> From<&'a State> for &'a ExporterState {
142
113
143
114
#[ derive( Debug , Clone ) ]
144
115
pub struct PermissionedUpdate {
145
- pub feed_id : pyth_sdk:: Identifier ,
116
+ pub feed_id : pyth_sdk:: Identifier ,
146
117
pub feed_index : u32 ,
147
- pub info : PriceInfo ,
118
+ pub info : PriceInfo ,
148
119
}
149
120
150
121
#[ async_trait:: async_trait]
@@ -693,7 +664,10 @@ where
693
664
account
694
665
. comp
695
666
. iter ( )
696
- . find ( |c| c. publisher == solana_pubkey:: Pubkey :: from ( publish_keypair. pubkey ( ) . to_bytes ( ) ) )
667
+ . find ( |c| {
668
+ c. publisher
669
+ == solana_pubkey:: Pubkey :: from ( publish_keypair. pubkey ( ) . to_bytes ( ) )
670
+ } )
697
671
. map ( |c| c. latest . pub_slot . max ( account. agg . pub_slot ) )
698
672
} )
699
673
. min ( ) ;
@@ -781,34 +755,34 @@ fn create_instruction_without_accumulator(
781
755
) -> Result < Instruction > {
782
756
Ok ( Instruction {
783
757
program_id : pyth_oracle_program_key,
784
- accounts : vec ! [
758
+ accounts : vec ! [
785
759
AccountMeta {
786
- pubkey: publish_pubkey,
787
- is_signer: true ,
760
+ pubkey: publish_pubkey,
761
+ is_signer: true ,
788
762
is_writable: true ,
789
763
} ,
790
764
AccountMeta {
791
- pubkey: price_id,
792
- is_signer: false ,
765
+ pubkey: price_id,
766
+ is_signer: false ,
793
767
is_writable: true ,
794
768
} ,
795
769
AccountMeta {
796
- pubkey: clock:: id( ) ,
797
- is_signer: false ,
770
+ pubkey: clock:: id( ) ,
771
+ is_signer: false ,
798
772
is_writable: false ,
799
773
} ,
800
774
] ,
801
- data : bincode:: DefaultOptions :: new ( )
775
+ data : bincode:: DefaultOptions :: new ( )
802
776
. with_little_endian ( )
803
777
. with_fixint_encoding ( )
804
778
. serialize (
805
779
& ( UpdPriceCmd {
806
- version : PYTH_ORACLE_VERSION ,
807
- cmd : UPDATE_PRICE_NO_FAIL_ON_ERROR ,
808
- status : price_info. status ,
809
- unused_ : 0 ,
810
- price : price_info. price ,
811
- conf : price_info. conf ,
780
+ version : PYTH_ORACLE_VERSION ,
781
+ cmd : UPDATE_PRICE_NO_FAIL_ON_ERROR ,
782
+ status : price_info. status ,
783
+ unused_ : 0 ,
784
+ price : price_info. price ,
785
+ conf : price_info. conf ,
812
786
pub_slot : current_slot,
813
787
} ) ,
814
788
) ?,
@@ -822,9 +796,7 @@ fn create_instruction_with_price_store_program(
822
796
prices : Vec < PermissionedUpdate > ,
823
797
) -> Result < Instruction > {
824
798
use pyth_price_store:: instruction:: {
825
- Instruction as PublishInstruction ,
826
- SubmitPricesArgsHeader ,
827
- PUBLISHER_CONFIG_SEED ,
799
+ Instruction as PublishInstruction , PUBLISHER_CONFIG_SEED , SubmitPricesArgsHeader ,
828
800
} ;
829
801
let ( publisher_config_key, publisher_config_bump) = Pubkey :: find_program_address (
830
802
& [ PUBLISHER_CONFIG_SEED . as_bytes ( ) , & publish_pubkey. to_bytes ( ) ] ,
@@ -853,18 +825,18 @@ fn create_instruction_with_price_store_program(
853
825
program_id : pyth_price_store_program_key,
854
826
accounts : vec ! [
855
827
AccountMeta {
856
- pubkey: publish_pubkey,
857
- is_signer: true ,
828
+ pubkey: publish_pubkey,
829
+ is_signer: true ,
858
830
is_writable: true ,
859
831
} ,
860
832
AccountMeta {
861
- pubkey: publisher_config_key,
862
- is_signer: false ,
833
+ pubkey: publisher_config_key,
834
+ is_signer: false ,
863
835
is_writable: false ,
864
836
} ,
865
837
AccountMeta {
866
- pubkey: publisher_buffer_key,
867
- is_signer: false ,
838
+ pubkey: publisher_buffer_key,
839
+ is_signer: false ,
868
840
is_writable: true ,
869
841
} ,
870
842
] ,
@@ -902,58 +874,58 @@ fn create_instruction_with_accumulator(
902
874
903
875
Ok ( Instruction {
904
876
program_id : pyth_oracle_program_key,
905
- accounts : vec ! [
877
+ accounts : vec ! [
906
878
AccountMeta {
907
- pubkey: publish_pubkey,
908
- is_signer: true ,
879
+ pubkey: publish_pubkey,
880
+ is_signer: true ,
909
881
is_writable: true ,
910
882
} ,
911
883
AccountMeta {
912
- pubkey: price_id,
913
- is_signer: false ,
884
+ pubkey: price_id,
885
+ is_signer: false ,
914
886
is_writable: true ,
915
887
} ,
916
888
AccountMeta {
917
- pubkey: clock:: id( ) ,
918
- is_signer: false ,
889
+ pubkey: clock:: id( ) ,
890
+ is_signer: false ,
919
891
is_writable: false ,
920
892
} ,
921
893
// accumulator program key
922
894
AccountMeta {
923
- pubkey: accumulator_program_key,
924
- is_signer: false ,
895
+ pubkey: accumulator_program_key,
896
+ is_signer: false ,
925
897
is_writable: false ,
926
898
} ,
927
899
// whitelist
928
900
AccountMeta {
929
- pubkey: whitelist_pubkey,
930
- is_signer: false ,
901
+ pubkey: whitelist_pubkey,
902
+ is_signer: false ,
931
903
is_writable: false ,
932
904
} ,
933
905
// oracle_auth_pda
934
906
AccountMeta {
935
- pubkey: oracle_auth_pda,
936
- is_signer: false ,
907
+ pubkey: oracle_auth_pda,
908
+ is_signer: false ,
937
909
is_writable: false ,
938
910
} ,
939
911
// accumulator_data
940
912
AccountMeta {
941
- pubkey: accumulator_data_pubkey,
942
- is_signer: false ,
913
+ pubkey: accumulator_data_pubkey,
914
+ is_signer: false ,
943
915
is_writable: true ,
944
916
} ,
945
917
] ,
946
- data : bincode:: DefaultOptions :: new ( )
918
+ data : bincode:: DefaultOptions :: new ( )
947
919
. with_little_endian ( )
948
920
. with_fixint_encoding ( )
949
921
. serialize (
950
922
& ( UpdPriceCmd {
951
- version : PYTH_ORACLE_VERSION ,
952
- cmd : UPDATE_PRICE_NO_FAIL_ON_ERROR ,
953
- status : price_info. status ,
954
- unused_ : 0 ,
955
- price : price_info. price ,
956
- conf : price_info. conf ,
923
+ version : PYTH_ORACLE_VERSION ,
924
+ cmd : UPDATE_PRICE_NO_FAIL_ON_ERROR ,
925
+ status : price_info. status ,
926
+ unused_ : 0 ,
927
+ price : price_info. price ,
928
+ conf : price_info. conf ,
957
929
pub_slot : current_slot,
958
930
} ) ,
959
931
) ?,
0 commit comments