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
0dcd5743
Unverified
Commit
0dcd5743
authored
May 03, 2021
by
Moody Salem
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix price impact handling/coloring
parent
9fec8dbe
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
6 deletions
+7
-6
index.tsx
src/components/CurrencyInputPanel/index.tsx
+2
-2
index.tsx
src/pages/Swap/index.tsx
+3
-2
reducer.test.ts
src/state/application/reducer.test.ts
+2
-2
No files found.
src/components/CurrencyInputPanel/index.tsx
View file @
0dcd5743
...
...
@@ -201,7 +201,7 @@ export default function CurrencyInputPanel({
if
(
priceImpact
.
lessThan
(
'
0
'
))
return
theme
.
green1
const
severity
=
warningSeverity
(
priceImpact
)
if
(
severity
<
1
)
return
undefined
if
(
severity
<
2
)
return
theme
.
yellow1
if
(
severity
<
3
)
return
theme
.
yellow1
return
theme
.
red1
},
[
priceImpact
,
theme
.
green1
,
theme
.
red1
,
theme
.
yellow1
])
...
...
@@ -300,7 +300,7 @@ export default function CurrencyInputPanel({
<
TYPE
.
body
fontSize=
{
14
}
color=
{
fiatValue
?
theme
.
text2
:
theme
.
text4
}
>
{
fiatValue
?
'
~
'
:
''
}
$
{
fiatValue
?
Number
(
fiatValue
?.
toSignificant
(
6
)).
toLocaleString
(
'
en
'
)
:
'
-
'
}
{
priceImpact
?
(
<
span
style=
{
{
color
:
priceImpactColor
}
}
>
(
{
priceImpact
.
multiply
(
-
1
).
toSignificant
(
3
)
}
%)
</
span
>
<
span
style=
{
{
color
:
priceImpactColor
}
}
>
(
{
priceImpact
.
multiply
(
-
1
00
).
toSignificant
(
3
)
}
%)
</
span
>
)
:
null
}
</
TYPE
.
body
>
</
RowBetween
>
...
...
src/pages/Swap/index.tsx
View file @
0dcd5743
...
...
@@ -25,6 +25,7 @@ import ConfirmSwapModal from '../../components/swap/ConfirmSwapModal'
import
{
ArrowWrapper
,
BottomGrouping
,
Dots
,
SwapCallbackError
,
Wrapper
}
from
'
../../components/swap/styleds
'
import
TradePrice
from
'
../../components/swap/TradePrice
'
import
TokenWarningModal
from
'
../../components/TokenWarningModal
'
import
{
ONE_HUNDRED_PERCENT
}
from
'
../../constants
'
import
{
useActiveWeb3React
}
from
'
../../hooks
'
import
{
useAllTokens
,
useCurrency
}
from
'
../../hooks/Tokens
'
import
{
ApprovalState
,
useApproveCallbackFromTrade
}
from
'
../../hooks/useApproveCallback
'
...
...
@@ -56,7 +57,6 @@ import { isTradeBetter } from '../../utils/isTradeBetter'
import
BetterTradeLink
from
'
../../components/swap/BetterTradeLink
'
import
SwapHeader
from
'
../../components/swap/SwapHeader
'
const
ONE_HUNDRED_PERCENT
=
new
Percent
(
100
,
100
)
function
computeFiatValuePriceImpact
(
fiatValueInput
:
CurrencyAmount
|
undefined
|
null
,
fiatValueOutput
:
CurrencyAmount
|
undefined
|
null
...
...
@@ -64,7 +64,8 @@ function computeFiatValuePriceImpact(
if
(
!
fiatValueOutput
||
!
fiatValueInput
)
return
undefined
if
(
!
currencyEquals
(
fiatValueInput
.
currency
,
fiatValueOutput
.
currency
))
return
undefined
if
(
JSBI
.
equal
(
fiatValueInput
.
raw
,
JSBI
.
BigInt
(
0
)))
return
undefined
return
ONE_HUNDRED_PERCENT
.
subtract
(
fiatValueOutput
.
divide
(
fiatValueInput
)).
multiply
(
100
)
const
pct
=
ONE_HUNDRED_PERCENT
.
subtract
(
fiatValueOutput
.
divide
(
fiatValueInput
))
return
new
Percent
(
pct
.
numerator
,
pct
.
denominator
)
}
export
default
function
Swap
({
history
}:
RouteComponentProps
)
{
...
...
src/state/application/reducer.test.ts
View file @
0dcd5743
...
...
@@ -24,7 +24,7 @@ describe('application reducer', () => {
expect
(
typeof
list
[
0
].
key
).
toEqual
(
'
string
'
)
expect
(
list
[
0
].
show
).
toEqual
(
true
)
expect
(
list
[
0
].
content
).
toEqual
({
txn
:
{
hash
:
'
abc
'
,
summary
:
'
test
'
,
success
:
true
}
})
expect
(
list
[
0
].
removeAfterMs
).
toEqual
(
1
5000
)
expect
(
list
[
0
].
removeAfterMs
).
toEqual
(
2
5000
)
})
it
(
'
replaces any existing popups with the same key
'
,
()
=>
{
...
...
@@ -35,7 +35,7 @@ describe('application reducer', () => {
expect
(
list
[
0
].
key
).
toEqual
(
'
abc
'
)
expect
(
list
[
0
].
show
).
toEqual
(
true
)
expect
(
list
[
0
].
content
).
toEqual
({
txn
:
{
hash
:
'
def
'
,
summary
:
'
test2
'
,
success
:
false
}
})
expect
(
list
[
0
].
removeAfterMs
).
toEqual
(
1
5000
)
expect
(
list
[
0
].
removeAfterMs
).
toEqual
(
2
5000
)
})
})
...
...
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