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
e0cbee79
Unverified
Commit
e0cbee79
authored
May 13, 2020
by
Noah Zinsmeister
Committed by
GitHub
May 13, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix bug for single-hop fees (#764)
fix incorrect feeTimesInputFormatted logic
parent
141e605c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
20 deletions
+19
-20
index.tsx
src/components/ExchangePage/index.tsx
+19
-20
No files found.
src/components/ExchangePage/index.tsx
View file @
e0cbee79
...
...
@@ -209,36 +209,37 @@ function ExchangePage({ sendingInput = false, history, params }: ExchangePagePro
JSBI
.
greaterThanOrEqual
(
inputApproval
.
raw
,
parsedAmounts
[
Field
.
INPUT
].
raw
))
const
pendingApprovalInput
=
useHasPendingApproval
(
tokens
[
Field
.
INPUT
]?.
address
)
const
feeAsPercent
=
new
Percent
(
JSBI
.
BigInt
(
3
),
JSBI
.
BigInt
(
1000
))
const
feeTimesInputRaw
=
parsedAmounts
[
Field
.
INPUT
]
&&
feeAsPercent
.
multiply
(
JSBI
.
BigInt
(
parsedAmounts
[
Field
.
INPUT
].
raw
))
const
feeTimesInputFormatted
=
feeTimesInputRaw
&&
new
TokenAmount
(
tokens
[
Field
.
INPUT
],
feeTimesInputRaw
?.
quotient
)
const
formattedAmounts
=
{
[
independentField
]:
typedValue
,
[
dependentField
]:
parsedAmounts
[
dependentField
]
?
parsedAmounts
[
dependentField
].
toSignificant
(
6
)
:
''
}
// for each hop in our trade, take away the
"innate"
price impact from 0.3% fees
// for each hop in our trade, take away the
x*y=k
price impact from 0.3% fees
// e.g. for 3 tokens/2 hops: 1 - ((1 - .03) * (1-.03))
const
baseFee
=
basisPointsToPercent
(
10000
-
30
)
const
realizedFee
=
!
trade
const
realized
LP
Fee
=
!
trade
?
undefined
:
trade
.
route
.
path
.
length
===
2
?
baseFee
:
basisPointsToPercent
(
10000
).
subtract
(
new
Array
(
trade
.
route
.
path
.
length
-
2
)
.
fill
(
0
)
.
reduce
<
Fraction
>
((
currentFee
:
Percent
|
Fraction
):
Fraction
=>
currentFee
.
multiply
(
baseFee
),
baseFee
)
trade
.
route
.
path
.
length
===
2
?
baseFee
:
new
Array
(
trade
.
route
.
path
.
length
-
2
)
.
fill
(
0
)
.
reduce
<
Fraction
>
((
currentFee
:
Percent
|
Fraction
):
Fraction
=>
currentFee
.
multiply
(
baseFee
),
baseFee
)
)
// the x*y=k impact
const
priceSlippage
=
slippageFromTrade
&&
realizedFee
slippageFromTrade
&&
realized
LP
Fee
?
new
Percent
(
slippageFromTrade
.
subtract
(
realizedFee
).
numerator
,
slippageFromTrade
.
subtract
(
realizedFee
).
denominator
slippageFromTrade
.
subtract
(
realized
LP
Fee
).
numerator
,
slippageFromTrade
.
subtract
(
realized
LP
Fee
).
denominator
)
:
undefined
// the amount of the input that accrues to LPs
const
realizedLPFeeAmount
=
realizedLPFee
&&
new
TokenAmount
(
tokens
[
Field
.
INPUT
],
realizedLPFee
.
multiply
(
parsedAmounts
[
Field
.
INPUT
].
raw
).
quotient
)
const
onTokenSelection
=
useCallback
(
(
field
:
Field
,
address
:
string
)
=>
{
dispatch
({
...
...
@@ -854,9 +855,7 @@ function ExchangePage({ sendingInput = false, history, params }: ExchangePagePro
<
QuestionHelper
text=
"A portion of each trade (0.3%) goes to liquidity providers to incentivize liquidity on the protocol."
/>
</
RowFixed
>
<
TYPE
.
black
fontSize=
{
14
}
>
{
feeTimesInputFormatted
?
feeTimesInputFormatted
?.
toSignificant
(
6
)
+
'
'
+
tokens
[
Field
.
INPUT
]?.
symbol
:
'
-
'
}
{
realizedLPFeeAmount
?
realizedLPFeeAmount
?.
toSignificant
(
6
)
+
'
'
+
tokens
[
Field
.
INPUT
]?.
symbol
:
'
-
'
}
</
TYPE
.
black
>
</
RowBetween
>
</
AutoColumn
>
...
...
@@ -1304,8 +1303,8 @@ function ExchangePage({ sendingInput = false, history, params }: ExchangePagePro
<QuestionHelper text="A portion of each trade (0.03%) goes to liquidity providers to incentivize liquidity on the protocol." />
</RowFixed>
<TYPE.black fontSize={14} color={theme.text1}>
{
feeTimesInputFormatted
?
feeTimesInputFormatted
?.toSignificant(6) + ' ' + tokens[Field.INPUT]?.symbol
{
realizedLPFeeAmount
?
realizedLPFeeAmount
?.toSignificant(6) + ' ' + tokens[Field.INPUT]?.symbol
: '-'}
</TYPE.black>
</RowBetween>
...
...
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