Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
interface
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
LuckySwap
interface
Commits
c3909bc1
Unverified
Commit
c3909bc1
authored
Apr 28, 2021
by
Moody Salem
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improve the better trade link logic
parent
b2528792
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
8 deletions
+15
-8
BetterTradeLink.tsx
src/components/swap/BetterTradeLink.tsx
+8
-2
useBestV3Trade.ts
src/hooks/useBestV3Trade.ts
+1
-1
index.tsx
src/pages/Swap/index.tsx
+6
-5
No files found.
src/components/swap/BetterTradeLink.tsx
View file @
c3909bc1
...
@@ -24,7 +24,13 @@ function VersionLinkContainer({ children }: { children: React.ReactNode }) {
...
@@ -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 }) {
...
@@ -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
>
...
...
src/hooks/useBestV3Trade.ts
View file @
c3909bc1
...
@@ -36,7 +36,7 @@ export function useBestV3TradeExactIn(
...
@@ -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
,
...
...
src/pages/Swap/index.tsx
View file @
c3909bc1
...
@@ -393,11 +393,12 @@ export default function Swap({ history }: RouteComponentProps) {
...
@@ -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
?
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment