@@ -649,27 +649,41 @@ mod recommendations {
649649 ) ;
650650 return None ;
651651 }
652- Some ( rate)
652+ Some ( Uint :: from ( rate) )
653653 } ) ?;
654654
655+ // And this the amount of gas tokens a user is willing to
656+ // pay for the transfer
657+ let gas_amount: Uint = pending. gas_fee . amount . into ( ) ;
658+
659+ // Multiply both to acquire the amount of earned gwei,
660+ // after the relay operation completes
661+ let amt_of_earned_gwei = if let Some ( gwei) =
662+ gas_amount. checked_mul ( gas_token_to_gwei_conversion_rate)
663+ {
664+ gwei
665+ } else {
666+ return Some ( Err ( "Overflowing error while calculating \
667+ earned gwei amount"
668+ . into ( ) ) ) ;
669+ } ;
670+
655671 Some (
656- I256 :: try_from (
657- pending. gas_fee . amount
658- * gas_token_to_gwei_conversion_rate,
659- )
660- . map_err ( |err| err. to_string ( ) )
661- . and_then ( |amt_of_earned_gwei| {
662- transfer_fee ( )
663- . checked_sub ( & amt_of_earned_gwei)
664- . ok_or_else ( || {
665- "Underflowed calculating relaying cost" . into ( )
666- } )
667- } )
668- . map ( |cost| EligibleRecommendation {
669- cost,
670- pending_transfer : pending,
671- transfer_hash : pending_hash,
672- } ) ,
672+ I256 :: try_from ( amt_of_earned_gwei)
673+ . map_err ( |err| err. to_string ( ) )
674+ . and_then ( |amt_of_earned_gwei| {
675+ transfer_fee ( )
676+ . checked_sub ( & amt_of_earned_gwei)
677+ . ok_or_else ( || {
678+ "Underflowed calculating relaying cost"
679+ . into ( )
680+ } )
681+ } )
682+ . map ( |cost| EligibleRecommendation {
683+ cost,
684+ pending_transfer : pending,
685+ transfer_hash : pending_hash,
686+ } ) ,
673687 )
674688 } )
675689 . maybe_collect_result ( )
0 commit comments