improve the better trade link logic
This commit is contained in:
parent
b25287923c
commit
c3909bc1d0
@ -24,7 +24,13 @@ function VersionLinkContainer({ children }: { children: React.ReactNode }) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function BetterTradeLink({ version }: { version: Version }) {
|
export default function BetterTradeLink({
|
||||||
|
version,
|
||||||
|
otherTradeNonexistent = false,
|
||||||
|
}: {
|
||||||
|
version: Version
|
||||||
|
otherTradeNonexistent: boolean
|
||||||
|
}) {
|
||||||
const location = useLocation()
|
const location = useLocation()
|
||||||
const search = useParsedQueryString()
|
const search = useParsedQueryString()
|
||||||
|
|
||||||
@ -40,7 +46,7 @@ export default function BetterTradeLink({ version }: { version: Version }) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<VersionLinkContainer>
|
<VersionLinkContainer>
|
||||||
There is a better price for this trade on{' '}
|
{otherTradeNonexistent ? 'This trade can be executed on ' : 'There is a better price for this trade on '}
|
||||||
<StyledInternalLink to={linkDestination}>
|
<StyledInternalLink to={linkDestination}>
|
||||||
<b>Uniswap {version.toUpperCase()} ↗</b>
|
<b>Uniswap {version.toUpperCase()} ↗</b>
|
||||||
</StyledInternalLink>
|
</StyledInternalLink>
|
||||||
|
@ -36,7 +36,7 @@ export function useBestV3TradeExactIn(
|
|||||||
const quotesResults = useSingleContractMultipleData(quoter, 'quoteExactInput', quoteExactInInputs)
|
const quotesResults = useSingleContractMultipleData(quoter, 'quoteExactInput', quoteExactInInputs)
|
||||||
|
|
||||||
return useMemo(() => {
|
return useMemo(() => {
|
||||||
if (!amountIn || !currencyOut || quotesResults.some(({ valid }) => !valid)) {
|
if (!amountIn || !currencyOut) {
|
||||||
return {
|
return {
|
||||||
state: V3TradeState.INVALID,
|
state: V3TradeState.INVALID,
|
||||||
trade: null,
|
trade: null,
|
||||||
|
@ -393,11 +393,12 @@ export default function Swap({ history }: RouteComponentProps) {
|
|||||||
setShowInverted={setShowInverted}
|
setShowInverted={setShowInverted}
|
||||||
/>
|
/>
|
||||||
) : null}
|
) : null}
|
||||||
{![V3TradeState.VALID, V3TradeState.SYNCING].includes(v3TradeState) ? null : toggledVersion ===
|
{[V3TradeState.VALID, V3TradeState.SYNCING, V3TradeState.NO_ROUTE_FOUND].includes(v3TradeState) ? (
|
||||||
Version.v3 && isTradeBetter(v3Trade, v2Trade) ? (
|
toggledVersion === Version.v3 && isTradeBetter(v3Trade, v2Trade) ? (
|
||||||
<BetterTradeLink version={Version.v2} />
|
<BetterTradeLink version={Version.v2} otherTradeNonexistent={!v3Trade} />
|
||||||
) : toggledVersion === Version.v2 && isTradeBetter(v2Trade, v3Trade) ? (
|
) : toggledVersion === Version.v2 && isTradeBetter(v2Trade, v3Trade) ? (
|
||||||
<BetterTradeLink version={Version.v3} />
|
<BetterTradeLink version={Version.v3} otherTradeNonexistent={!v2Trade} />
|
||||||
|
) : null
|
||||||
) : null}
|
) : null}
|
||||||
<BottomGrouping>
|
<BottomGrouping>
|
||||||
{swapIsUnsupported ? (
|
{swapIsUnsupported ? (
|
||||||
|
Loading…
Reference in New Issue
Block a user