@@ -19,8 +19,10 @@ use parser::{
1919use solana_metrics:: datapoint_info;
2020use solana_rpc_client:: nonblocking:: rpc_client:: RpcClient ;
2121use solana_sdk:: {
22- clock:: DEFAULT_SLOTS_PER_EPOCH , commitment_config:: CommitmentConfig , pubkey:: Pubkey ,
22+ clock:: DEFAULT_SLOTS_PER_EPOCH , commitment_config:: CommitmentConfig , program_pack:: Pack ,
23+ pubkey:: Pubkey ,
2324} ;
25+ use spl_token:: state:: Mint ;
2426use subscribe_option:: SubscribeOption ;
2527use threshold_config:: ThresholdConfig ;
2628use tonic:: transport:: channel:: ClientTlsConfig ;
@@ -91,6 +93,21 @@ impl JitoBellHandler {
9193 sorted_thresholds
9294 }
9395
96+ /// Get divisor
97+ ///
98+ /// - Fetch Mint account to get decimals value, if fails return default 9
99+ pub async fn divisor ( & self , vrt : & Pubkey ) -> f64 {
100+ let decimals = match self . rpc_client . get_account ( vrt) . await {
101+ Ok ( mint_acc) => match Mint :: unpack ( & mint_acc. data ) {
102+ Ok ( acc) => acc. decimals ,
103+ Err ( _) => 9 ,
104+ } ,
105+ Err ( _e) => 9 ,
106+ } ;
107+
108+ 10_f64 . powi ( decimals as i32 )
109+ }
110+
94111 /// Start heart beating
95112 pub async fn heart_beat (
96113 & mut self ,
@@ -546,8 +563,10 @@ impl JitoBellHandler {
546563 let _vault_fee_token_account = & ix. accounts [ 7 ] ;
547564
548565 if vrt_mint_info. pubkey . eq ( & vrt) {
566+ let divisor = self . divisor ( & vrt) . await ;
567+
549568 for threshold in self . sorted_thresholds ( instruction) . iter ( ) {
550- let min_amount_out = * min_amount_out as f64 / 1_000_000_000_f64 ;
569+ let min_amount_out = * min_amount_out as f64 / divisor ;
551570 if min_amount_out >= threshold. value {
552571 self . dispatch_platform_notifications (
553572 & threshold. notification . destinations ,
@@ -576,8 +595,10 @@ impl JitoBellHandler {
576595
577596 // VRT amount
578597 if vault. vrt_mint . eq ( & vrt) {
598+ let divisor = self . divisor ( & vrt) . await ;
599+
579600 for threshold in self . sorted_thresholds ( instruction) . iter ( ) {
580- let amount = * amount as f64 / 1_000_000_000_f64 ;
601+ let amount = * amount as f64 / divisor ;
581602 if amount >= threshold. value {
582603 self . dispatch_platform_notifications (
583604 & threshold. notification . destinations ,
0 commit comments