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
c41926db
Commit
c41926db
authored
Jul 24, 2018
by
Hayden Adams
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix min value bug
parent
64710cae
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
7 deletions
+12
-7
Exchange.js
src/components/Exchange.js
+1
-0
Purchase.js
src/components/Purchase.js
+11
-7
No files found.
src/components/Exchange.js
View file @
c41926db
...
@@ -94,6 +94,7 @@ class Exchange extends Component {
...
@@ -94,6 +94,7 @@ class Exchange extends Component {
this
.
props
.
setExchangeRate
(
buyRate
);
this
.
props
.
setExchangeRate
(
buyRate
);
this
.
props
.
setExchangeFee
(
exchangeFee
);
this
.
props
.
setExchangeFee
(
exchangeFee
);
this
.
props
.
setExchangeOutputValue
(
tokensOut
);
this
.
props
.
setExchangeOutputValue
(
tokensOut
);
console
.
log
(
'
ethToTokenRate
'
,
buyRate
);
}
}
tokenToEthRate
=
(
tokenInput
)
=>
{
tokenToEthRate
=
(
tokenInput
)
=>
{
...
...
src/components/Purchase.js
View file @
c41926db
...
@@ -17,13 +17,17 @@ class Purchase extends Component {
...
@@ -17,13 +17,17 @@ class Purchase extends Component {
}
}
ethToTokenPurchase
=
()
=>
{
ethToTokenPurchase
=
()
=>
{
// console.log('symbol: ', this.props.exchange.outputToken.value);
var
exchange
=
this
.
props
.
symbolToExchangeContract
(
this
.
props
.
exchange
.
outputToken
.
value
);
var
exchange
=
this
.
props
.
symbolToExchangeContract
(
this
.
props
.
exchange
.
outputToken
.
value
);
var
minTokens
=
this
.
props
.
exchange
.
outputValue
.
toString
();
// console.log('exchange: ', exchange);
var
minTokensInt
=
parseInt
(
minTokens
,
10
).
toString
();
var
estimatedTokens
=
this
.
props
.
exchange
.
outputValue
var
minTokensInt
=
parseInt
((
estimatedTokens
*
0.9
),
10
).
toString
();
var
ethSold
=
this
.
props
.
exchange
.
inputValue
;
var
ethSold
=
this
.
props
.
exchange
.
inputValue
;
var
weiSold
=
this
.
props
.
web3Store
.
web3
.
utils
.
toWei
(
ethSold
);
var
weiSold
=
this
.
props
.
web3Store
.
web3
.
utils
.
toWei
(
ethSold
);
var
timeout
=
this
.
props
.
web3Store
.
blockTimestamp
+
300
;
//current block time + 5mins
var
timeout
=
this
.
props
.
web3Store
.
blockTimestamp
+
300
;
//current block time + 5mins
// console.log(minTokensInt, weiSold, timeout);
// console.log('minTokensInt: ', minTokensInt);
// console.log('weiSold: ', weiSold);
// console.log('timeout: ', timeout);
exchange
.
methods
.
ethToTokenSwap
(
minTokensInt
,
timeout
).
send
({
from
:
this
.
props
.
web3Store
.
currentMaskAddress
,
value
:
weiSold
})
exchange
.
methods
.
ethToTokenSwap
(
minTokensInt
,
timeout
).
send
({
from
:
this
.
props
.
web3Store
.
currentMaskAddress
,
value
:
weiSold
})
.
on
(
'
transactionHash
'
,
(
result
)
=>
{
.
on
(
'
transactionHash
'
,
(
result
)
=>
{
...
@@ -52,8 +56,8 @@ class Purchase extends Component {
...
@@ -52,8 +56,8 @@ class Purchase extends Component {
tokenToEthPurchase
=
()
=>
{
tokenToEthPurchase
=
()
=>
{
var
exchange
=
this
.
props
.
symbolToExchangeContract
(
this
.
props
.
exchange
.
inputToken
.
value
);
var
exchange
=
this
.
props
.
symbolToExchangeContract
(
this
.
props
.
exchange
.
inputToken
.
value
);
var
minEth
=
this
.
props
.
exchange
.
outputValue
.
toString
();
var
estimatedEth
=
this
.
props
.
exchange
.
outputValue
var
minEthInt
=
parseInt
(
minEth
,
10
).
toString
();
var
minEthInt
=
parseInt
(
(
estimatedEth
*
0.9
)
,
10
).
toString
();
var
tokensSold
=
this
.
props
.
exchange
.
inputValue
;
var
tokensSold
=
this
.
props
.
exchange
.
inputValue
;
// toWei needs to be replaced with *decimals
// toWei needs to be replaced with *decimals
var
tokensSoldInt
=
this
.
props
.
web3Store
.
web3
.
utils
.
toWei
(
tokensSold
);
var
tokensSoldInt
=
this
.
props
.
web3Store
.
web3
.
utils
.
toWei
(
tokensSold
);
...
@@ -78,8 +82,8 @@ class Purchase extends Component {
...
@@ -78,8 +82,8 @@ class Purchase extends Component {
tokenToTokenPurchase
=
()
=>
{
tokenToTokenPurchase
=
()
=>
{
var
exchange
=
this
.
props
.
symbolToExchangeContract
(
this
.
props
.
exchange
.
inputToken
.
value
);
var
exchange
=
this
.
props
.
symbolToExchangeContract
(
this
.
props
.
exchange
.
inputToken
.
value
);
var
tokenOutAddress
=
this
.
props
.
symbolToTokenAddress
(
this
.
props
.
exchange
.
outputToken
.
value
);
var
tokenOutAddress
=
this
.
props
.
symbolToTokenAddress
(
this
.
props
.
exchange
.
outputToken
.
value
);
var
minTokens
=
this
.
props
.
exchange
.
outputValue
.
toString
()
;
var
estimatedTokens
=
this
.
props
.
exchange
.
outputValue
;
var
minTokensInt
=
parseInt
(
minTokens
,
10
).
toString
();
var
minTokensInt
=
parseInt
(
(
estimatedTokens
*
0.9
)
,
10
).
toString
();
var
tokensSold
=
this
.
props
.
exchange
.
inputValue
;
var
tokensSold
=
this
.
props
.
exchange
.
inputValue
;
var
tokensSoldInt
=
this
.
props
.
web3Store
.
web3
.
utils
.
toWei
(
tokensSold
);
var
tokensSoldInt
=
this
.
props
.
web3Store
.
web3
.
utils
.
toWei
(
tokensSold
);
var
timeout
=
this
.
props
.
web3Store
.
blockTimestamp
+
300
;
//current block time + 5mins
var
timeout
=
this
.
props
.
web3Store
.
blockTimestamp
+
300
;
//current block time + 5mins
...
...
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