1
1
use {
2
2
async_trait:: async_trait,
3
3
carbon_core:: {
4
+ borsh:: BorshDeserialize ,
4
5
error:: CarbonResult ,
5
6
instruction:: { DecodedInstruction , InstructionMetadata , NestedInstructions } ,
6
7
metrics:: MetricsCollection ,
7
8
processor:: Processor ,
8
9
} ,
9
- carbon_jupiter_swap_decoder:: {
10
- instructions:: JupiterSwapInstruction , JupiterSwapDecoder ,
11
- PROGRAM_ID as JUPITER_SWAP_PROGRAM_ID ,
12
- } ,
13
10
carbon_log_metrics:: LogMetrics ,
11
+ carbon_raydium_cpmm_decoder:: {
12
+ instructions:: RaydiumCpmmInstruction , types:: SwapEvent , RaydiumCpmmDecoder ,
13
+ PROGRAM_ID as RAYDIUM_CPMM_PROGRAM_ID ,
14
+ } ,
14
15
carbon_yellowstone_grpc_datasource:: {
15
16
YellowstoneGrpcClientConfig , YellowstoneGrpcGeyserClient ,
16
17
} ,
@@ -39,7 +40,7 @@ pub async fn main() -> CarbonResult<()> {
39
40
failed : Some ( false ) ,
40
41
account_include : vec ! [ ] ,
41
42
account_exclude : vec ! [ ] ,
42
- account_required : vec ! [ JUPITER_SWAP_PROGRAM_ID . to_string( ) . clone( ) ] ,
43
+ account_required : vec ! [ RAYDIUM_CPMM_PROGRAM_ID . to_string( ) . clone( ) ] ,
43
44
signature : None ,
44
45
} ;
45
46
@@ -75,7 +76,7 @@ pub async fn main() -> CarbonResult<()> {
75
76
. datasource ( yellowstone_grpc)
76
77
. metrics ( Arc :: new ( LogMetrics :: new ( ) ) )
77
78
. metrics_flush_interval ( 3 )
78
- . instruction ( JupiterSwapDecoder , JupiterSwapInstructionProcessor )
79
+ . instruction ( RaydiumCpmmDecoder , RaydiumCpmmInstructionProcessor )
79
80
. shutdown_strategy ( carbon_core:: pipeline:: ShutdownStrategy :: Immediate )
80
81
. build ( ) ?
81
82
. run ( )
@@ -84,13 +85,13 @@ pub async fn main() -> CarbonResult<()> {
84
85
Ok ( ( ) )
85
86
}
86
87
87
- pub struct JupiterSwapInstructionProcessor ;
88
+ pub struct RaydiumCpmmInstructionProcessor ;
88
89
89
90
#[ async_trait]
90
- impl Processor for JupiterSwapInstructionProcessor {
91
+ impl Processor for RaydiumCpmmInstructionProcessor {
91
92
type InputType = (
92
93
InstructionMetadata ,
93
- DecodedInstruction < JupiterSwapInstruction > ,
94
+ DecodedInstruction < RaydiumCpmmInstruction > ,
94
95
NestedInstructions ,
95
96
solana_instruction:: Instruction ,
96
97
) ;
@@ -107,9 +108,12 @@ impl Processor for JupiterSwapInstructionProcessor {
107
108
"Processing instruction - Index: {}, Stack Height: {}, Path: {:?}" ,
108
109
metadata. index, metadata. stack_height, metadata. absolute_path
109
110
) ;
110
- println ! ( "Extracted {} logs:" , logs. len( ) ) ;
111
- for ( i, log) in logs. iter ( ) . enumerate ( ) {
112
- println ! ( " {}: {}" , i, log) ;
111
+ for log in logs {
112
+ if log. len ( ) > 8 {
113
+ if let Ok ( swap_event) = SwapEvent :: deserialize ( & mut & log[ 8 ..] ) {
114
+ println ! ( "SwapEvent: {:?}" , swap_event) ;
115
+ }
116
+ }
113
117
}
114
118
println ! ( "--------------------------------" ) ;
115
119
}
0 commit comments