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
4389c232
Commit
4389c232
authored
Apr 16, 2018
by
Hayden Adams
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
minor refactor
parent
1712e1ea
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
24 additions
and
24 deletions
+24
-24
App.js
src/App.js
+1
-1
AboutMessage.js
src/components/AboutMessage.js
+1
-1
ConnectionHelper.js
src/components/ConnectionHelper.js
+5
-5
Invest.js
src/components/Invest.js
+7
-7
Visualization.js
src/components/Visualization.js
+10
-10
No files found.
src/App.js
View file @
4389c232
...
@@ -14,7 +14,7 @@ import Purchase from './components/Purchase';
...
@@ -14,7 +14,7 @@ import Purchase from './components/Purchase';
import
About
from
'
./components/About
'
;
import
About
from
'
./components/About
'
;
import
Links
from
'
./components/Links
'
;
import
Links
from
'
./components/Links
'
;
import
SharePurchase
from
'
./components/SharePurchase
'
;
import
SharePurchase
from
'
./components/SharePurchase
'
;
import
Transactions
from
'
./components/Transactions
'
;
//
import Transactions from './components/Transactions';
// d3
// d3
import
Visualization
from
'
./components/Visualization
'
;
import
Visualization
from
'
./components/Visualization
'
;
// enter redux
// enter redux
...
...
src/components/AboutMessage.js
View file @
4389c232
...
@@ -4,7 +4,7 @@ function AboutMessage ({ toggled }) {
...
@@ -4,7 +4,7 @@ function AboutMessage ({ toggled }) {
if
(
toggled
===
true
)
{
if
(
toggled
===
true
)
{
return
(
return
(
<
section
className
=
"
expand grey-bg border pa2
"
>
<
section
className
=
"
expand grey-bg border pa2
"
>
<
p
>
Uniswap
is
an
automated
market
maker
exchange
capable
of
both
ETH
-
to
-
ERC20
and
ERC20
-
to
-
ERC20
trades
.
Anyone
can
become
a
liquidity
provider
,
and
invest
in
the
liquidity
pool
of
an
ERC20
token
.
This
allows
other
users
to
trade
that
token
for
any
other
token
with
liquidity
,
at
an
exchange
rate
based
on
their
relative
availibility
.
When
a
token
trade
is
executed
,
a
small
fee
is
payed
to
the
liquidity
providers
for
both
tokens
,
proportional
to
their
investment
.
<
/p
>
<
p
>
Uniswap
is
an
automated
market
maker
exchange
capable
of
both
ETH
-
to
-
ERC20
and
ERC20
-
to
-
ERC20
trades
.
Anyone
can
become
a
liquidity
provider
,
and
invest
in
the
liquidity
pool
of
an
ERC20
token
.
This
allows
other
users
to
trade
that
token
for
other
tokens
at
an
exchange
rate
based
on
their
relative
availibility
.
When
a
token
trade
is
executed
,
a
small
fee
is
payed
to
the
liquidity
providers
that
enabled
the
transaction
,
proportional
to
their
investment
.
<
/p
>
<
p
>
A
full
writeup
can
be
found
here
:
<
a
href
=
"
https://hackmd.io/Tlf08KuPTbqsHLKk5hzAvA
"
>
Uniswap
Project
Overview
<
/a></
p
>
<
p
>
A
full
writeup
can
be
found
here
:
<
a
href
=
"
https://hackmd.io/Tlf08KuPTbqsHLKk5hzAvA
"
>
Uniswap
Project
Overview
<
/a></
p
>
<
p
>
Please
reach
out
if
you
would
like
to
get
involved
or
support
the
project
.
<
/p
>
<
p
>
Please
reach
out
if
you
would
like
to
get
involved
or
support
the
project
.
<
/p
>
<
p
><
span
role
=
"
img
"
aria
-
label
=
"
GitHub
"
>
⟪⟫
<
/span> <a href="https:/
/
github
.
com
/
uniswap
"
>github.com/uniswap</a></p>
<
p
><
span
role
=
"
img
"
aria
-
label
=
"
GitHub
"
>
⟪⟫
<
/span> <a href="https:/
/
github
.
com
/
uniswap
"
>github.com/uniswap</a></p>
...
...
src/components/ConnectionHelper.js
View file @
4389c232
...
@@ -5,14 +5,14 @@ function ConnectionHelper(props) {
...
@@ -5,14 +5,14 @@ function ConnectionHelper(props) {
if
(
!
props
.
metamask
)
{
if
(
!
props
.
metamask
)
{
return
(
return
(
<
div
className
=
"
grey-bg connection border pa2
"
>
<
div
className
=
"
grey-bg connection border pa2
"
>
<
p
>
Welcome
!
Uniswap
is
a
decentralized
exhange
platform
for
ERC20
Tokens
.
<
a
onClick
=
{()
=>
{
props
.
toggleAbout
()}}
className
=
"
f-a
"
>
How
it
works
↘
<
/a><br /
><
br
/>
<
p
>
Welcome
!
Uniswap
is
a
decentralized
exhange
for
ETH
and
ERC20
Tokens
.
<
a
onClick
=
{()
=>
{
props
.
toggleAbout
()}}
className
=
"
f-a
"
>
How
it
works
↘
<
/a><br /
><
br
/>
<
b
>
To
get
started
,
please
install
<
a
href
=
"
https://metamask.io/
"
>
Metamask
<
/a>.</
b
><
/p
>
<
b
>
To
get
started
,
please
install
<
a
href
=
"
https://metamask.io/
"
>
Metamask
<
/a>.</
b
><
/p
>
<
/div
>
<
/div
>
)
)
}
else
if
(
props
.
web3Store
.
connected
&&
props
.
web3Store
.
interaction
===
'
disconnected
'
)
{
}
else
if
(
props
.
web3Store
.
connected
&&
props
.
web3Store
.
interaction
===
'
disconnected
'
)
{
return
(
return
(
<
div
className
=
"
grey-bg connection border pa2
"
>
<
div
className
=
"
grey-bg connection border pa2
"
>
<
p
>
Welcome
!
Uniswap
is
a
decentralized
ex
hange
platform
for
ERC20
Tokens
.
<
a
onClick
=
{()
=>
{
props
.
toggleAbout
()}}
className
=
"
f-a
"
>
How
it
works
↘
<
/a><br /
><
br
/>
<
p
>
Welcome
!
Uniswap
is
a
decentralized
ex
change
for
ETH
and
ERC20
Tokens
.
<
a
onClick
=
{()
=>
{
props
.
toggleAbout
()}}
className
=
"
f-a
"
>
How
it
works
↘
<
/a><br /
><
br
/>
Looks
like
you
aren
'
t connected. <b>Please switch to the correct network.</b></p>
Looks
like
you
aren
'
t connected. <b>Please switch to the correct network.</b></p>
</div>
</div>
)
)
...
@@ -32,7 +32,7 @@ function ConnectionHelper(props) {
...
@@ -32,7 +32,7 @@ function ConnectionHelper(props) {
} else if (props.web3Store.interaction === "submitted") {
} else if (props.web3Store.interaction === "submitted") {
return (
return (
<div className="grey-bg connection border pa2">
<div className="grey-bg connection border pa2">
<p>{"Transaction submitted!
Click on the transaction hash below to check its status?
"}</p>
<p>{"Transaction submitted!"}</p>
</div>
</div>
)
)
} else if (props.exchange.inputValue > props.exchange.inputBalance/10**18 && props.exchange.inputToken.value ===
'
ETH
'
) {
} else if (props.exchange.inputValue > props.exchange.inputBalance/10**18 && props.exchange.inputToken.value ===
'
ETH
'
) {
...
@@ -44,7 +44,7 @@ function ConnectionHelper(props) {
...
@@ -44,7 +44,7 @@ function ConnectionHelper(props) {
}
else
if
(
!
props
.
exchange
.
allowanceApproved
&&
props
.
web3Store
.
exchangeType
===
"
Token to Token
"
)
{
}
else
if
(
!
props
.
exchange
.
allowanceApproved
&&
props
.
web3Store
.
exchangeType
===
"
Token to Token
"
)
{
return
(
return
(
<
div
className
=
"
grey-bg connection border pa2
"
>
<
div
className
=
"
grey-bg connection border pa2
"
>
<
p
>
Our
smart
contract
has
to
be
approved
by
your
address
to
be
able
to
swap
this
token
for
other
tokens
.
<
br
/>
We
set
a
high
transfer
limit
for
the
demo
(
<
a
onClick
=
{()
=>
{
props
.
toggleAbout
()}}
className
=
"
f-a
"
>
Why
?
<
/a>
)
.</
p
>
<
p
>
Our
smart
contract
has
to
be
approved
by
your
address
to
be
able
to
swap
this
token
for
other
tokens
.
<
br
/>
We
set
a
high
transfer
limit
for
the
demo
(
<
a
onClick
=
{()
=>
{
props
.
toggleAbout
()}}
className
=
"
f-a
"
>
Why
?
<
/a>
)
.</
p
>
<
a
className
=
"
f-a
"
onClick
=
{()
=>
props
.
approveAllowance
()}
>
Approve
⭞
<
/a
>
<
a
className
=
"
f-a
"
onClick
=
{()
=>
props
.
approveAllowance
()}
>
Approve
⭞
<
/a
>
<
/div
>
<
/div
>
)
)
...
@@ -82,7 +82,7 @@ function ConnectionHelper(props) {
...
@@ -82,7 +82,7 @@ function ConnectionHelper(props) {
}
else
{
}
else
{
return
(
return
(
<
div
className
=
"
grey-bg connection border pa2
"
>
<
div
className
=
"
grey-bg connection border pa2
"
>
<
p
>
Welcome
!
Uniswap
is
a
decentralized
exhange
platform
for
ERC20
Tokens
.
<
a
onClick
=
{()
=>
{
props
.
toggleAbout
()}}
className
=
"
f-a
"
>
How
it
works
↘
<
/a><br /
><
br
/>
<
p
>
Welcome
!
Uniswap
is
a
decentralized
exhange
for
ETH
and
ERC20
Tokens
.
<
a
onClick
=
{()
=>
{
props
.
toggleAbout
()}}
className
=
"
f-a
"
>
How
it
works
↘
<
/a><br /
><
br
/>
You
'
re connected. Enter a value below to get started.</p>
You
'
re connected. Enter a value below to get started.</p>
<p>↓</p>
<p>↓</p>
</div>
</div>
...
...
src/components/Invest.js
View file @
4389c232
...
@@ -115,22 +115,22 @@ class Invest extends Component {
...
@@ -115,22 +115,22 @@ class Invest extends Component {
<
div
className
=
"
investValue border pa2
"
>
<
div
className
=
"
investValue border pa2
"
>
<
p
>
Total
Shares
:
{
this
.
props
.
exchange
.
investShares
}
<
/p
>
<
p
>
Total
Shares
:
{
this
.
props
.
exchange
.
investShares
}
<
/p
>
<
p
>
You
own
:
{
this
.
props
.
exchange
.
userShares
}
shares
<
/p
>
<
p
>
You
own
:
{
this
.
props
.
exchange
.
userShares
}
shares
<
/p
>
<
p
>
You
get
{((
this
.
props
.
exchange
.
userShares
*
100
)
/
this
.
props
.
exchange
.
investShares
).
toFixed
(
2
)}
%
of
fees
<
/p
>
<
p
>
You
get
{((
this
.
props
.
exchange
.
userShares
*
100
)
/
this
.
props
.
exchange
.
investShares
).
toFixed
(
2
)}
%
of
fees
<
/p
>
<
/div
>
<
/div
>
<
div
className
=
"
investValue border pa2
"
>
<
div
className
=
"
investValue border pa2
"
>
<
p
>
Total
Liquidity
<
/p
>
<
p
>
Total
Liquidity
<
/p
>
<
p
>
&
nbsp
;
&
nbsp
;
&
nbsp
;
&
nbsp
;
&
nbsp
;
&
nbsp
;
&
nbsp
;
&
nbsp
;
&
nbsp
;
&
nbsp
;
&
nbsp
;
&
nbsp
;{(
this
.
props
.
exchange
.
investEthPool
/
10
**
18
).
toFixed
(
4
)}
ETH
<
/p
>
<
p
>
&
nbsp
;
&
nbsp
;
&
nbsp
;
&
nbsp
;
&
nbsp
;
&
nbsp
;
&
nbsp
;
&
nbsp
;
&
nbsp
;
&
nbsp
;
&
nbsp
;
&
nbsp
;{(
this
.
props
.
exchange
.
investEthPool
/
10
**
18
).
toFixed
(
5
)}
ETH
<
/p
>
<
p
>
{(
this
.
props
.
exchange
.
investTokenPool
/
10
**
18
).
toFixed
(
4
)}
{
this
.
props
.
exchange
.
investToken
.
value
}
<
/p
>
<
p
>
{(
this
.
props
.
exchange
.
investTokenPool
/
10
**
18
).
toFixed
(
5
)}
{
this
.
props
.
exchange
.
investToken
.
value
}
<
/p
>
<
/div
>
<
/div
>
<
div
className
=
"
investValue border pa2
"
>
<
div
className
=
"
investValue border pa2
"
>
<
p
>
&
nbsp
;
Each
share
is
worth
:
<
/p
>
<
p
>
&
nbsp
;
Each
share
is
worth
:
<
/p
>
<
p
>
{((
this
.
props
.
exchange
.
investEthPool
/
10
**
18
)
/
this
.
props
.
exchange
.
investShares
).
toFixed
(
4
)}
ETH
&
nbsp
;
&
nbsp
;
&
nbsp
;
&
nbsp
;
&
nbsp
;
&
nbsp
;
<
/p
>
<
p
>
{((
this
.
props
.
exchange
.
investEthPool
/
10
**
18
)
/
this
.
props
.
exchange
.
investShares
).
toFixed
(
5
)}
ETH
&
nbsp
;
&
nbsp
;
&
nbsp
;
&
nbsp
;
&
nbsp
;
&
nbsp
;
<
/p
>
<
p
>
{((
this
.
props
.
exchange
.
investTokenPool
/
10
**
18
)
/
this
.
props
.
exchange
.
investShares
).
toFixed
(
4
)}
{
this
.
props
.
exchange
.
investToken
.
value
}
<
/p
>
<
p
>
{((
this
.
props
.
exchange
.
investTokenPool
/
10
**
18
)
/
this
.
props
.
exchange
.
investShares
).
toFixed
(
5
)}
{
this
.
props
.
exchange
.
investToken
.
value
}
<
/p
>
<
/div
>
<
/div
>
<
div
className
=
"
investValue border pa2
"
>
<
div
className
=
"
investValue border pa2
"
>
<
p
>
Account
Balance
:
<
/p
>
<
p
>
Account
Balance
:
<
/p
>
<
p
>
&
nbsp
;
&
nbsp
;
&
nbsp
;
&
nbsp
;
&
nbsp
;
&
nbsp
;
&
nbsp
;
&
nbsp
;{(
this
.
props
.
exchange
.
investEthBalance
/
10
**
18
).
toFixed
(
4
)}
ETH
<
/p
>
<
p
>
&
nbsp
;
&
nbsp
;
&
nbsp
;
&
nbsp
;
&
nbsp
;
&
nbsp
;
&
nbsp
;
&
nbsp
;{(
this
.
props
.
exchange
.
investEthBalance
/
10
**
18
).
toFixed
(
5
)}
ETH
<
/p
>
<
p
>
{(
this
.
props
.
exchange
.
investTokenBalance
/
10
**
18
).
toFixed
(
4
)}
{
this
.
props
.
exchange
.
investToken
.
value
}
<
/p
>
<
p
>
{(
this
.
props
.
exchange
.
investTokenBalance
/
10
**
18
).
toFixed
(
5
)}
{
this
.
props
.
exchange
.
investToken
.
value
}
<
/p
>
<
/div
>
<
/div
>
<
/section
>
<
/section
>
)
)
...
...
src/components/Visualization.js
View file @
4389c232
...
@@ -16,9 +16,9 @@ class Visualization extends Component {
...
@@ -16,9 +16,9 @@ class Visualization extends Component {
componentDidMount
()
{
componentDidMount
()
{
this
.
d3Graph
=
d3
.
select
(
ReactDOM
.
findDOMNode
(
this
.
refs
.
graph
));
this
.
d3Graph
=
d3
.
select
(
ReactDOM
.
findDOMNode
(
this
.
refs
.
graph
));
let
inputToken
=
this
.
props
.
exchange
.
inputToken
.
value
;
//
let inputToken = this.props.exchange.inputToken.value;
let
outputToken
=
this
.
props
.
exchange
.
outputToken
.
value
;
let
outputToken
=
this
.
props
.
exchange
.
outputToken
.
value
;
console
.
log
(
outputToken
,
'
output token
'
);
//
console.log(outputToken, 'output token');
let
query
=
`{
let
query
=
`{
Event(input:"
${
outputToken
}
"){
Event(input:"
${
outputToken
}
"){
...
@@ -27,9 +27,9 @@ class Visualization extends Component {
...
@@ -27,9 +27,9 @@ class Visualization extends Component {
}
}
}`
;
}`
;
console
.
log
(
query
,
'
query
'
)
//
console.log(query, 'query')
axios
.
get
(
'
http://ec2-34-
193-175-237
.compute-1.amazonaws.com:3000/graphql
'
,
{
params
:
{
query
:
query
}
})
axios
.
get
(
'
http://ec2-34-
205-17-195
.compute-1.amazonaws.com:3000/graphql
'
,
{
params
:
{
query
:
query
}
})
.
then
(
data
=>
this
.
setState
({
data
:
data
.
data
.
data
.
Event
}))
.
then
(
data
=>
this
.
setState
({
data
:
data
.
data
.
data
.
Event
}))
.
then
(()
=>
this
.
createLineGraph
())
.
then
(()
=>
this
.
createLineGraph
())
.
catch
(
err
=>
console
.
error
(
err
));
.
catch
(
err
=>
console
.
error
(
err
));
...
@@ -49,7 +49,7 @@ class Visualization extends Component {
...
@@ -49,7 +49,7 @@ class Visualization extends Component {
}
}
}`
;
}`
;
axios
.
get
(
'
http://ec2-34-
193-175-237
.compute-1.amazonaws.com:3000/graphql
'
,
{
params
:
{
query
:
query
}})
axios
.
get
(
'
http://ec2-34-
205-17-195
.compute-1.amazonaws.com:3000/graphql
'
,
{
params
:
{
query
:
query
}})
.
then
(
data
=>
this
.
setState
({
data
:
data
.
data
.
data
.
Event
}))
.
then
(
data
=>
this
.
setState
({
data
:
data
.
data
.
data
.
Event
}))
.
then
(()
=>
{
.
then
(()
=>
{
this
.
createNewLineGraph
()
this
.
createNewLineGraph
()
...
@@ -67,7 +67,7 @@ class Visualization extends Component {
...
@@ -67,7 +67,7 @@ class Visualization extends Component {
let
svg
=
this
.
d3Graph
let
svg
=
this
.
d3Graph
// first we want to see the min and max of our token prices
// first we want to see the min and max of our token prices
let
ethValueOfTokenExtent
=
d3
.
extent
(
this
.
state
.
data
,
element
=>
element
.
ethValueOfToken
);
let
ethValueOfTokenExtent
=
d3
.
extent
(
this
.
state
.
data
,
element
=>
element
.
ethValueOfToken
);
console
.
log
(
'
initial data visualized
'
,
this
.
state
.
data
,
'
extent of data
'
,
ethValueOfTokenExtent
)
//
console.log('initial data visualized', this.state.data, 'extent of data', ethValueOfTokenExtent)
// create a y scale, for the eth value of the token
// create a y scale, for the eth value of the token
let
yScale
=
d3
.
scaleLinear
()
let
yScale
=
d3
.
scaleLinear
()
.
domain
([
ethValueOfTokenExtent
[
1
],
ethValueOfTokenExtent
[
0
]])
.
domain
([
ethValueOfTokenExtent
[
1
],
ethValueOfTokenExtent
[
0
]])
...
@@ -77,7 +77,7 @@ class Visualization extends Component {
...
@@ -77,7 +77,7 @@ class Visualization extends Component {
let
yAxis
=
d3
.
axisLeft
()
let
yAxis
=
d3
.
axisLeft
()
.
scale
(
yScale
)
.
scale
(
yScale
)
.
ticks
(
8
)
.
ticks
(
8
)
// time to put this y axis on the page
// time to put this y axis on the page
svg
.
append
(
'
g
'
)
svg
.
append
(
'
g
'
)
.
attr
(
'
class
'
,
'
y axis
'
)
.
attr
(
'
class
'
,
'
y axis
'
)
...
@@ -88,7 +88,7 @@ class Visualization extends Component {
...
@@ -88,7 +88,7 @@ class Visualization extends Component {
this
.
state
.
data
.
map
(
e
=>
e
.
createdAt
=
new
Date
(
e
.
createdAt
));
this
.
state
.
data
.
map
(
e
=>
e
.
createdAt
=
new
Date
(
e
.
createdAt
));
// similarly, check the min and max of our times
// similarly, check the min and max of our times
let
timeExtent
=
d3
.
extent
(
this
.
state
.
data
,
element
=>
element
.
createdAt
)
let
timeExtent
=
d3
.
extent
(
this
.
state
.
data
,
element
=>
element
.
createdAt
)
console
.
log
(
'
previous time extent
'
,
timeExtent
)
//
console.log('previous time extent', timeExtent)
// with this extent, create a scale for the x axis
// with this extent, create a scale for the x axis
// BIG NOTE: for timeScales, you need to create new Date objects from the date string
// BIG NOTE: for timeScales, you need to create new Date objects from the date string
// also, domain needs to take in an array
// also, domain needs to take in an array
...
@@ -103,7 +103,7 @@ class Visualization extends Component {
...
@@ -103,7 +103,7 @@ class Visualization extends Component {
.
attr
(
'
class
'
,
'
x axis
'
)
.
attr
(
'
class
'
,
'
x axis
'
)
.
attr
(
'
transform
'
,
'
translate(80, 265)
'
)
.
attr
(
'
transform
'
,
'
translate(80, 265)
'
)
.
call
(
xAxis
);
.
call
(
xAxis
);
// this right here is the x-axis label
// this right here is the x-axis label
svg
.
append
(
"
text
"
)
svg
.
append
(
"
text
"
)
.
attr
(
"
transform
"
,
"
rotate(-90)
"
)
.
attr
(
"
transform
"
,
"
rotate(-90)
"
)
.
attr
(
"
y
"
,
20
)
.
attr
(
"
y
"
,
20
)
...
@@ -112,7 +112,7 @@ class Visualization extends Component {
...
@@ -112,7 +112,7 @@ class Visualization extends Component {
.
attr
(
'
font-size
'
,
'
15px
'
)
.
attr
(
'
font-size
'
,
'
15px
'
)
.
style
(
"
text-anchor
"
,
"
middle
"
)
.
style
(
"
text-anchor
"
,
"
middle
"
)
.
text
(
"
Price (ETH)
"
);
.
text
(
"
Price (ETH)
"
);
let
line
=
d3
.
line
()
let
line
=
d3
.
line
()
.
x
(
element
=>
xScale
(
element
.
createdAt
))
.
x
(
element
=>
xScale
(
element
.
createdAt
))
.
y
(
element
=>
yScale
(
element
.
ethValueOfToken
))
.
y
(
element
=>
yScale
(
element
.
ethValueOfToken
))
...
...
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