@@ -44,6 +44,7 @@ import {
44
44
fetchSwapsSmartTransactionFees ,
45
45
getSmartTransactionFees ,
46
46
getCurrentSmartTransactionsEnabled ,
47
+ getIsEstimatedReturnLow ,
47
48
} from '../../../ducks/swaps/swaps' ;
48
49
import { getCurrentChainId } from '../../../../shared/modules/selectors/networks' ;
49
50
import {
@@ -97,7 +98,6 @@ import {
97
98
SLIPPAGE_HIGH_ERROR ,
98
99
SLIPPAGE_LOW_ERROR ,
99
100
MAX_ALLOWED_SLIPPAGE ,
100
- SWAPS_QUOTE_MAX_RETURN_DIFFERENCE_PERCENTAGE ,
101
101
} from '../../../../shared/constants/swaps' ;
102
102
import { GasRecommendations } from '../../../../shared/constants/gas' ;
103
103
import CountdownTimer from '../countdown-timer' ;
@@ -149,7 +149,6 @@ import { getTokenFiatAmount } from '../../../helpers/utils/token-util';
149
149
import { toChecksumHexAddress } from '../../../../shared/modules/hexstring-utils' ;
150
150
import { useAsyncResult } from '../../../hooks/useAsyncResult' ;
151
151
import { useGasFeeEstimates } from '../../../hooks/useGasFeeEstimates' ;
152
- import { useTokenFiatAmount } from '../../../hooks/useTokenFiatAmount' ;
153
152
import ViewQuotePriceDifference from './view-quote-price-difference' ;
154
153
import SlippageNotificationModal from './slippage-notification-modal' ;
155
154
@@ -1128,50 +1127,10 @@ export default function ReviewQuote({
1128
1127
currentCurrency ,
1129
1128
] ) ;
1130
1129
1131
- const sourceTokenAmount = calcTokenAmount (
1132
- usedQuote ?. sourceAmount ,
1133
- usedQuote ?. sourceTokenInfo ?. decimals ,
1134
- ) ;
1135
- const sourceTokenFiatAmount = useTokenFiatAmount (
1136
- usedQuote ?. sourceTokenInfo ?. address ,
1137
- sourceTokenAmount || 0 ,
1138
- usedQuote ?. sourceTokenInfo ?. symbol ,
1139
- {
1140
- showFiat : true ,
1141
- } ,
1142
- true ,
1143
- null ,
1144
- false ,
1145
- ) ;
1146
- const destinationTokenAmount = calcTokenAmount (
1147
- usedQuote ?. destinationAmount ,
1148
- usedQuote ?. destinationTokenInfo ?. decimals ,
1149
- ) ;
1150
- const destinationTokenFiatAmount = useTokenFiatAmount (
1151
- usedQuote ?. destinationTokenInfo ?. address ,
1152
- destinationTokenAmount || 0 ,
1153
- usedQuote ?. destinationTokenInfo ?. symbol ,
1154
- {
1155
- showFiat : true ,
1156
- } ,
1157
- true ,
1158
- null ,
1159
- false ,
1160
- ) ;
1161
- const adjustedReturnValue =
1162
- destinationTokenFiatAmount && rawNetworkFees
1163
- ? new BigNumber ( destinationTokenFiatAmount ) . minus (
1164
- new BigNumber ( rawNetworkFees ) ,
1165
- )
1166
- : null ;
1167
- const isEstimatedReturnLow =
1168
- sourceTokenFiatAmount && adjustedReturnValue
1169
- ? adjustedReturnValue . lt (
1170
- new BigNumber ( sourceTokenFiatAmount ) . times (
1171
- 1 - SWAPS_QUOTE_MAX_RETURN_DIFFERENCE_PERCENTAGE ,
1172
- ) ,
1173
- )
1174
- : false ;
1130
+ const isEstimatedReturnLow = getIsEstimatedReturnLow ( {
1131
+ usedQuote,
1132
+ rawNetworkFees,
1133
+ } ) ;
1175
1134
setIsEstimatedReturnLow ( isEstimatedReturnLow ) ;
1176
1135
1177
1136
return (
0 commit comments