11import {
2- ArrowUpIcon ,
32 Button ,
43 Column ,
54 dollarValueFormatterWithDecimals ,
98 Inline ,
109 styled ,
1110 Text ,
12- Tooltip ,
1311} from 'junoblocks'
1412import React , { useState } from 'react'
1513import { useRecoilValue } from 'recoil'
@@ -38,19 +36,14 @@ export const TransactionTips = ({
3836 tokenAmount : tokenA ?. amount || 1 ,
3937 } )
4038
41- const {
42- isShowing,
43- conversionRate,
44- conversionRateInDollar,
45- tokenASwapValueUSD,
46- tokenBSwapValueUSD,
47- } = useTxRates ( {
48- tokenASymbol : tokenA ?. tokenSymbol ,
49- tokenBSymbol : tokenB ?. tokenSymbol ,
50- tokenAAmount : tokenA ?. amount || 1 ,
51- tokenToTokenPrice,
52- isLoading : isPriceLoading ,
53- } )
39+ const { isShowing, conversionRate, conversionRateInDollar, dollarValue } =
40+ useTxRates ( {
41+ tokenASymbol : tokenA ?. tokenSymbol ,
42+ tokenBSymbol : tokenB ?. tokenSymbol ,
43+ tokenAAmount : tokenA ?. amount || 1 ,
44+ tokenToTokenPrice,
45+ isLoading : isPriceLoading ,
46+ } )
5447
5548 const switchTokensButton = (
5649 < Button
@@ -79,23 +72,9 @@ export const TransactionTips = ({
7972 </ >
8073 )
8174
82- const priceImpact =
83- ( tokenBSwapValueUSD - tokenASwapValueUSD ) / tokenASwapValueUSD
84- const formattedPriceImpact = Math . abs ( Math . round ( priceImpact * 10000 ) / 100 )
85- const errorThreshold = priceImpact < - 0.05
86-
87- const tokenAFormattedSwapValue = dollarValueFormatterWithDecimals (
88- tokenASwapValueUSD ,
89- {
90- includeCommaSeparation : true ,
91- }
92- )
93- const tokenBFormattedSwapValue = dollarValueFormatterWithDecimals (
94- tokenBSwapValueUSD ,
95- {
96- includeCommaSeparation : true ,
97- }
98- )
75+ const formattedDollarValue = dollarValueFormatterWithDecimals ( dollarValue , {
76+ includeCommaSeparation : true ,
77+ } )
9978
10079 if ( size === 'small' ) {
10180 return (
@@ -114,7 +93,7 @@ export const TransactionTips = ({
11493 { transactionRates }
11594 </ Text >
11695 < Text variant = "caption" color = "disabled" wrap = { false } >
117- Swap estimate: ${ tokenBFormattedSwapValue }
96+ Swap estimate: ${ formattedDollarValue }
11897 </ Text >
11998 </ Column >
12099 ) }
@@ -133,44 +112,8 @@ export const TransactionTips = ({
133112 </ Text >
134113 ) }
135114 </ StyledDivForRateWrapper >
136- < Inline justifyContent = { 'flex-end' } gap = { 8 } css = { { cursor : 'pointer' } } >
137- { tokenB ?. tokenSymbol && (
138- < Tooltip label = "Price impact due to the amount of liquity available in the pool." >
139- < Inline
140- css = { {
141- backgroundColor : errorThreshold
142- ? '$backgroundColors$error'
143- : '$backgroundColors$secondary' ,
144- padding : '$2 $4 $2 $2' ,
145- borderRadius : 4 ,
146- } }
147- >
148- < ArrowUpIcon
149- color = { errorThreshold ? 'error' : 'secondary' }
150- css = { {
151- transform : priceImpact < 0 ? 'rotate(180deg)' : undefined ,
152- } }
153- size = "medium"
154- />
155- < Text
156- variant = "legend"
157- wrap = { false }
158- css = { {
159- color : errorThreshold
160- ? '$textColors$error'
161- : '$textColors$secondary' ,
162- } }
163- >
164- { formattedPriceImpact } %
165- </ Text >
166- </ Inline >
167- </ Tooltip >
168- ) }
169- < Column gap = { 4 } >
170- < Text variant = "legend" > ${ tokenAFormattedSwapValue } </ Text >
171- < Text variant = "legend" > ${ tokenBFormattedSwapValue } </ Text >
172- </ Column >
173- </ Inline >
115+
116+ < Text variant = "legend" > ${ formattedDollarValue } </ Text >
174117 </ StyledDivForWrapper >
175118 )
176119}
0 commit comments