Commit 3aaa3fef authored by Moody Salem's avatar Moody Salem

fix: wrap/unwrap should not show computed trade details

parent bc243e1c
...@@ -33,11 +33,13 @@ export default function useWrapCallback( ...@@ -33,11 +33,13 @@ export default function useWrapCallback(
return useMemo(() => { return useMemo(() => {
if (!wethContract || !chainId || !inputCurrency || !outputCurrency) return NOT_APPLICABLE if (!wethContract || !chainId || !inputCurrency || !outputCurrency) return NOT_APPLICABLE
const weth = WETH9[chainId]
if (!weth) return NOT_APPLICABLE
const hasInputAmount = Boolean(inputAmount?.greaterThan('0')) const hasInputAmount = Boolean(inputAmount?.greaterThan('0'))
const sufficientBalance = inputAmount && balance && !balance.lessThan(inputAmount) const sufficientBalance = inputAmount && balance && !balance.lessThan(inputAmount)
if (inputCurrency.isNative && outputCurrency.equals(WETH9[chainId])) { if (inputCurrency.isNative && weth.equals(outputCurrency)) {
return { return {
wrapType: WrapType.WRAP, wrapType: WrapType.WRAP,
execute: execute:
...@@ -53,7 +55,7 @@ export default function useWrapCallback( ...@@ -53,7 +55,7 @@ export default function useWrapCallback(
: undefined, : undefined,
inputError: sufficientBalance ? undefined : hasInputAmount ? 'Insufficient ETH balance' : 'Enter ETH amount', inputError: sufficientBalance ? undefined : hasInputAmount ? 'Insufficient ETH balance' : 'Enter ETH amount',
} }
} else if (WETH9[chainId].equals(inputCurrency) && outputCurrency.isNative) { } else if (weth.equals(inputCurrency) && outputCurrency.isNative) {
return { return {
wrapType: WrapType.UNWRAP, wrapType: WrapType.UNWRAP,
execute: execute:
......
...@@ -122,6 +122,7 @@ export default function Swap({ history }: RouteComponentProps) { ...@@ -122,6 +122,7 @@ export default function Swap({ history }: RouteComponentProps) {
inputError: wrapInputError, inputError: wrapInputError,
} = useWrapCallback(currencies[Field.INPUT], currencies[Field.OUTPUT], typedValue) } = useWrapCallback(currencies[Field.INPUT], currencies[Field.OUTPUT], typedValue)
const showWrap: boolean = wrapType !== WrapType.NOT_APPLICABLE const showWrap: boolean = wrapType !== WrapType.NOT_APPLICABLE
console.log(showWrap)
const { address: recipientAddress } = useENSAddress(recipient) const { address: recipientAddress } = useENSAddress(recipient)
const parsedAmounts = useMemo( const parsedAmounts = useMemo(
...@@ -428,70 +429,72 @@ export default function Swap({ history }: RouteComponentProps) { ...@@ -428,70 +429,72 @@ export default function Swap({ history }: RouteComponentProps) {
</> </>
) : null} ) : null}
<Row style={{ justifyContent: !trade ? 'center' : 'space-between' }}> {showWrap ? null : (
<RowFixed> <Row style={{ justifyContent: !trade ? 'center' : 'space-between' }}>
{[V3TradeState.VALID, V3TradeState.SYNCING, V3TradeState.NO_ROUTE_FOUND].includes(v3TradeState) &&
(toggledVersion === Version.v3 && isTradeBetter(v3Trade, v2Trade) ? (
<BetterTradeLink version={Version.v2} otherTradeNonexistent={!v3Trade} />
) : toggledVersion === Version.v2 && isTradeBetter(v2Trade, v3Trade) ? (
<BetterTradeLink version={Version.v3} otherTradeNonexistent={!v2Trade} />
) : (
toggledVersion === Version.v2 && (
<ButtonGray
width="fit-content"
padding="0.1rem 0.5rem 0.1rem 0.35rem"
as={Link}
to="/swap"
style={{
display: 'flex',
justifyContent: 'space-between',
alignItems: 'center',
height: '24px',
opacity: 0.8,
lineHeight: '120%',
marginLeft: '0.75rem',
}}
>
<ArrowLeft color={theme.text3} size={12} /> &nbsp;
<TYPE.main style={{ lineHeight: '120%' }} fontSize={12}>
<HideSmall>Back to </HideSmall>V3
</TYPE.main>
</ButtonGray>
)
))}
{toggledVersion === Version.v3 && trade && isTradeBetter(v2Trade, v3Trade) && (
<ButtonGray
width="fit-content"
padding="0.1rem 0.5rem"
disabled
style={{
display: 'flex',
justifyContent: 'space-between',
height: '24px',
opacity: 0.4,
marginLeft: '0.25rem',
}}
>
<TYPE.black fontSize={12}>V3</TYPE.black>
</ButtonGray>
)}
</RowFixed>
{trade ? (
<RowFixed> <RowFixed>
<TradePrice {[V3TradeState.VALID, V3TradeState.SYNCING, V3TradeState.NO_ROUTE_FOUND].includes(v3TradeState) &&
price={trade.executionPrice} (toggledVersion === Version.v3 && isTradeBetter(v3Trade, v2Trade) ? (
showInverted={showInverted} <BetterTradeLink version={Version.v2} otherTradeNonexistent={!v3Trade} />
setShowInverted={setShowInverted} ) : toggledVersion === Version.v2 && isTradeBetter(v2Trade, v3Trade) ? (
/> <BetterTradeLink version={Version.v3} otherTradeNonexistent={!v2Trade} />
<MouseoverTooltipContent ) : (
content={<AdvancedSwapDetails trade={trade} allowedSlippage={allowedSlippage} />} toggledVersion === Version.v2 && (
> <ButtonGray
<StyledInfo /> width="fit-content"
</MouseoverTooltipContent> padding="0.1rem 0.5rem 0.1rem 0.35rem"
as={Link}
to="/swap"
style={{
display: 'flex',
justifyContent: 'space-between',
alignItems: 'center',
height: '24px',
opacity: 0.8,
lineHeight: '120%',
marginLeft: '0.75rem',
}}
>
<ArrowLeft color={theme.text3} size={12} /> &nbsp;
<TYPE.main style={{ lineHeight: '120%' }} fontSize={12}>
<HideSmall>Back to </HideSmall>V3
</TYPE.main>
</ButtonGray>
)
))}
{toggledVersion === Version.v3 && trade && isTradeBetter(v2Trade, v3Trade) && (
<ButtonGray
width="fit-content"
padding="0.1rem 0.5rem"
disabled
style={{
display: 'flex',
justifyContent: 'space-between',
height: '24px',
opacity: 0.4,
marginLeft: '0.25rem',
}}
>
<TYPE.black fontSize={12}>V3</TYPE.black>
</ButtonGray>
)}
</RowFixed> </RowFixed>
) : null} {trade ? (
</Row> <RowFixed>
<TradePrice
price={trade.executionPrice}
showInverted={showInverted}
setShowInverted={setShowInverted}
/>
<MouseoverTooltipContent
content={<AdvancedSwapDetails trade={trade} allowedSlippage={allowedSlippage} />}
>
<StyledInfo />
</MouseoverTooltipContent>
</RowFixed>
) : null}
</Row>
)}
<BottomGrouping> <BottomGrouping>
{swapIsUnsupported ? ( {swapIsUnsupported ? (
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment