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
8bf95ebf
Commit
8bf95ebf
authored
Dec 10, 2019
by
Kirill Goncharov
Committed by
Noah Zinsmeister
Dec 10, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow to set custom deadline (#543)
parent
38625d24
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
5 deletions
+44
-5
index.jsx
src/components/ExchangePage/index.jsx
+8
-4
index.js
src/components/TransactionDetails/index.js
+36
-1
No files found.
src/components/ExchangePage/index.jsx
View file @
8bf95ebf
...
...
@@ -32,7 +32,7 @@ const ALLOWED_SLIPPAGE_DEFAULT = 100
const
TOKEN_ALLOWED_SLIPPAGE_DEFAULT
=
100
// 15 minutes, denominated in seconds
const
DEADLINE_FROM_NOW
=
60
*
15
const
DE
FAULT_DE
ADLINE_FROM_NOW
=
60
*
15
// % above the calculated gas cost that we actually send, denominated in bips
const
GAS_MARGIN
=
ethers
.
utils
.
bigNumberify
(
1000
)
...
...
@@ -266,6 +266,8 @@ export default function ExchangePage({ initialCurrency, sending = false, params
return
''
}
const
[
deadlineFromNow
,
setDeadlineFromNow
]
=
useState
(
DEFAULT_DEADLINE_FROM_NOW
)
const
[
rawSlippage
,
setRawSlippage
]
=
useState
(()
=>
initialSlippage
())
const
[
rawTokenSlippage
,
setRawTokenSlippage
]
=
useState
(()
=>
initialSlippage
(
true
))
...
...
@@ -553,8 +555,8 @@ export default function ExchangePage({ initialCurrency, sending = false, params
const
highSlippageWarning
=
percentSlippage
&&
percentSlippage
.
gte
(
ethers
.
utils
.
parseEther
(
'
.2
'
))
// [20+%
const
isValid
=
sending
?
exchangeRate
&&
inputError
===
null
&&
independentError
===
null
&&
recipientError
===
null
:
exchangeRate
&&
inputError
===
null
&&
independentError
===
null
?
exchangeRate
&&
inputError
===
null
&&
independentError
===
null
&&
recipientError
===
null
&&
deadlineFromNow
:
exchangeRate
&&
inputError
===
null
&&
independentError
===
null
&&
deadlineFromNow
const
estimatedText
=
`(
${
t
(
'
estimated
'
)}
)`
function
formatBalance
(
value
)
{
...
...
@@ -562,7 +564,7 @@ export default function ExchangePage({ initialCurrency, sending = false, params
}
async
function
onSwap
()
{
const
deadline
=
Math
.
ceil
(
Date
.
now
()
/
1000
)
+
DEADLINE_FROM_NOW
const
deadline
=
Math
.
ceil
(
Date
.
now
()
/
1000
)
+
deadlineFromNow
let
estimate
,
method
,
args
,
value
if
(
independentField
===
INPUT
)
{
...
...
@@ -759,6 +761,8 @@ export default function ExchangePage({ initialCurrency, sending = false, params
rawSlippage=
{
rawSlippage
}
slippageWarning=
{
slippageWarning
}
highSlippageWarning=
{
highSlippageWarning
}
setDeadline=
{
setDeadlineFromNow
}
deadline=
{
deadlineFromNow
}
inputError=
{
inputError
}
independentError=
{
independentError
}
inputCurrency=
{
inputCurrency
}
...
...
src/components/TransactionDetails/index.js
View file @
8bf95ebf
...
...
@@ -260,7 +260,7 @@ const LastSummaryText = styled.div`
const
SlippageSelector
=
styled
.
div
`
background-color:
${({
theme
})
=>
darken
(
0.04
,
theme
.
concreteGray
)}
;
padding: 1rem 1.25rem 1rem 1.25rem;
border-radius: 12px;
border-radius: 12px
12px 0 0
;
`
const
Percent
=
styled
.
div
`
...
...
@@ -294,6 +294,14 @@ const ValueWrapper = styled.span`
font-variant: tabular-nums;
`
const
DeadlineSelector
=
styled
.
div
`
background-color:
${({
theme
})
=>
darken
(
0.04
,
theme
.
concreteGray
)}
;
padding: 1rem 1.25rem 1rem 1.25rem;
border-radius: 0 0 12px 12px;
`
const
DeadlineRow
=
SlippageRow
const
DeadlineInput
=
OptionCustom
export
default
function
TransactionDetails
(
props
)
{
const
{
t
}
=
useTranslation
()
...
...
@@ -314,6 +322,8 @@ export default function TransactionDetails(props) {
}
})
const
[
deadlineInput
,
setDeadlineInput
]
=
useState
(
''
)
function
renderSummary
()
{
let
contextualInfo
=
''
let
isError
=
false
...
...
@@ -492,6 +502,14 @@ export default function TransactionDetails(props) {
<
/BottomError
>
<
/SlippageRow
>
<
/SlippageSelector
>
<
DeadlineSelector
>
Set
swap
deadline
(
minutes
from
now
)
<
DeadlineRow
wrap
>
<
DeadlineInput
>
<
Input
placeholder
=
{
'
Deadline
'
}
value
=
{
deadlineInput
}
onChange
=
{
parseDeadlineInput
}
/
>
<
/DeadlineInput
>
<
/DeadlineRow
>
<
/DeadlineSelector
>
<
/
>
)
}
...
...
@@ -507,6 +525,7 @@ export default function TransactionDetails(props) {
const
setRawSlippage
=
props
.
setRawSlippage
const
setRawTokenSlippage
=
props
.
setRawTokenSlippage
const
setcustomSlippageError
=
props
.
setcustomSlippageError
const
setDeadline
=
props
.
setDeadline
const
updateSlippage
=
useCallback
(
newSlippage
=>
{
...
...
@@ -604,6 +623,22 @@ export default function TransactionDetails(props) {
}
}
const
[
initialDeadline
]
=
useState
(
props
.
deadline
)
useEffect
(()
=>
{
setDeadlineInput
(
initialDeadline
/
60
)
},
[
initialDeadline
])
const
parseDeadlineInput
=
e
=>
{
const
input
=
e
.
target
.
value
const
acceptableValues
=
[
/^$/
,
/^
\d
+$/
]
if
(
acceptableValues
.
some
(
re
=>
re
.
test
(
input
)))
{
setDeadlineInput
(
input
)
setDeadline
(
parseInt
(
input
)
*
60
)
}
}
const
b
=
text
=>
<
Bold
>
{
text
}
<
/Bold
>
const
renderTransactionDetails
=
()
=>
{
...
...
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