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
309bd109
Commit
309bd109
authored
May 18, 2018
by
Hayden Adams
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove invariants
parent
5e7ae40c
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
97 additions
and
192 deletions
+97
-192
App.js
src/App.js
+20
-49
exchange-actions.js
src/actions/exchange-actions.js
+16
-34
Exchange.js
src/components/Exchange.js
+25
-28
Invest.js
src/components/Invest.js
+0
-7
constants.js
src/constants.js
+11
-25
exchange-reducer.js
src/reducers/exchange-reducer.js
+16
-25
exchangeContract-reducer.js
src/reducers/exchangeContract-reducer.js
+2
-8
tokenContract-reducer.js
src/reducers/tokenContract-reducer.js
+3
-9
initial-state.js
src/store/initial-state.js
+4
-7
No files found.
src/App.js
View file @
309bd109
...
...
@@ -33,15 +33,12 @@ import { initializeGlobalWeb3,
toggleInvest
}
from
'
./actions/web3-actions
'
;
import
{
setInputBalance
,
setOutputBalance
,
setInvariant1
,
setInvariant2
,
setMarketEth1
,
setMarketEth2
,
setMarketTokens1
,
setMarketTokens2
,
setEthPool1
,
setEthPool2
,
setTokenPool1
,
setTokenPool2
,
setAllowanceApprovalState
,
setInvestToken
,
setInvestInvariant
,
setInvestEthPool
,
setInvestTokenPool
,
setInvestTokenAllowance
,
...
...
@@ -75,13 +72,6 @@ class App extends Component {
if
(
web3
===
'
undefined
'
)
{
this
.
props
.
setWeb3ConnectionStatus
(
false
);
}
else
{
this
.
setState
({
firstRun
:
cookie
.
load
(
'
firstRun
'
)
||
true
,
swapAdded
:
cookie
.
load
(
'
swapAdded
'
)
||
false
,
uniAdded
:
cookie
.
load
(
'
uniAdded
'
)
||
false
,
transactions
:
cookie
.
load
(
'
transactions
'
)
||
[],
})
// we're working with asynchronous redux
this
.
props
.
initializeGlobalWeb3
(
web3
)
this
.
getInfoFirstTime
();
}
...
...
@@ -92,9 +82,8 @@ class App extends Component {
// eslint-disable-next-line no-unused-vars
const
web3Subscriber
=
subscribe
(
'
web3Store.connected
'
,
state
=>
{
if
(
state
.
web3Store
.
connected
===
true
&&
!
state
.
web3Store
.
metamaskLocked
)
{
//console.log('successfully connected to metamask', state.web3Store.currentMaskAddress);
this
.
marketInterval
=
setInterval
(
this
.
getMarketInfo
,
15000
);
this
.
accountInterval
=
setInterval
(
this
.
getAccountInfo
,
15000
);
this
.
marketInterval
=
setInterval
(
this
.
getMarketInfo
,
10000
);
this
.
accountInterval
=
setInterval
(
this
.
getAccountInfo
,
10000
);
this
.
userInterval
=
setInterval
(
this
.
getUserAddress
,
500
);
}
else
{
console
.
log
(
'
web3 not connected, getting user address
'
)
...
...
@@ -107,8 +96,7 @@ class App extends Component {
componentWillReceiveProps
(
nextProps
)
{
//console.log('nextProps', nextProps)
}
// TODO: getInfoFirstTime and getUserAddress are WET af
// lets do something about it
// TODO: improve getInfoFirstTime and getUserAddress
getInfoFirstTime
=
()
=>
{
web3
.
eth
.
getAccounts
(
async
(
error
,
result
)
=>
{
if
(
result
.
length
>
0
){
...
...
@@ -164,9 +152,6 @@ class App extends Component {
// send the token contract to redux store
await
this
.
props
.
tokenContractReady
(
tokenAddress
[
0
],
tokenContract
);
})
// this.getAccountInfo();
// this.getMarketInfo();
}
symbolToTokenAddress
=
(
symbol
)
=>
{
...
...
@@ -211,7 +196,7 @@ class App extends Component {
}
}
// this quadruplet of functions will end up being shared amongst multiple components
// will need to bring this out into a higher order component
(we'll put that to the side for now)
// will need to bring this out into a higher order component
// TODO: multiple components currently need this function, we will pass it to them via props
getAccountInfo
=
()
=>
{
switch
(
this
.
props
.
web3Store
.
exchangeType
)
{
...
...
@@ -243,13 +228,10 @@ class App extends Component {
}
getInvestInfo
=
()
=>
{
var
exchange
=
this
.
symbolToExchangeContract
(
this
.
props
.
exchange
.
investToken
.
value
);
var
token
=
this
.
symbolToTokenContract
(
this
.
props
.
exchange
.
investToken
.
value
);
var
exchangeAddress
=
this
.
symbolToExchangeAddress
(
this
.
props
.
exchange
.
investToken
.
value
)
exchange
.
methods
.
invariant
().
call
().
then
((
result
,
error
)
=>
{
this
.
props
.
setInvestInvariant
(
result
);
});
var
symbol
=
this
.
props
.
exchange
.
investToken
.
value
;
var
exchange
=
this
.
symbolToExchangeContract
(
symbol
);
var
token
=
this
.
symbolToTokenContract
(
symbol
);
var
exchangeAddress
=
this
.
symbolToExchangeAddress
(
symbol
);
exchange
.
methods
.
ethPool
().
call
().
then
((
result
,
error
)
=>
{
this
.
props
.
setInvestEthPool
(
result
);
...
...
@@ -284,35 +266,27 @@ class App extends Component {
var
exchange
;
if
(
type
===
'
input
'
)
{
exchange
=
this
.
symbolToExchangeContract
(
this
.
props
.
exchange
.
inputToken
.
value
);
exchange
.
methods
.
invariant
().
call
().
then
((
result
,
error
)
=>
{
this
.
props
.
setInvariant1
(
result
);
// console.log('Input Invariant: ' + result);
});
exchange
.
methods
.
ethPool
().
call
().
then
((
result
,
error
)
=>
{
this
.
props
.
set
MarketEth
1
(
result
);
this
.
props
.
set
EthPool
1
(
result
);
// console.log('Input Market ETH: ' + result);
});
exchange
.
methods
.
tokenPool
().
call
().
then
((
result
,
error
)
=>
{
this
.
props
.
set
MarketTokens
1
(
result
);
this
.
props
.
set
TokenPool
1
(
result
);
// console.log('Input Market Tokens: ' + result);
});
}
else
if
(
type
===
'
output
'
)
{
exchange
=
this
.
symbolToExchangeContract
(
this
.
props
.
exchange
.
outputToken
.
value
);
exchange
.
methods
.
invariant
().
call
().
then
((
result
,
error
)
=>
{
this
.
props
.
setInvariant2
(
result
);
// console.log('Output Invariant: ' + result);
});
exchange
.
methods
.
ethPool
().
call
().
then
((
result
,
error
)
=>
{
this
.
props
.
set
MarketEth
2
(
result
);
this
.
props
.
set
EthPool
2
(
result
);
// console.log('Output Market ETH: ' + result);
});
exchange
.
methods
.
tokenPool
().
call
().
then
((
result
,
error
)
=>
{
this
.
props
.
set
MarketTokens
2
(
result
);
this
.
props
.
set
TokenPool
2
(
result
);
// console.log('Output Market Tokens: ' + result);
});
}
...
...
@@ -486,12 +460,10 @@ const mapDispatchToProps = (dispatch) => {
factoryContractReady
,
setInputBalance
,
setOutputBalance
,
setInvariant1
,
setInvariant2
,
setMarketEth1
,
setMarketEth2
,
setMarketTokens1
,
setMarketTokens2
,
setEthPool1
,
setEthPool2
,
setTokenPool1
,
setTokenPool2
,
setAllowanceApprovalState
,
initializeGlobalWeb3
,
toggleAbout
,
...
...
@@ -502,7 +474,6 @@ const mapDispatchToProps = (dispatch) => {
setInvestEthPool
,
setInvestTokenPool
,
setInvestTokenAllowance
,
setInvestInvariant
,
setInvestShares
,
setUserShares
,
setInvestTokenBalance
,
...
...
src/actions/exchange-actions.js
View file @
309bd109
...
...
@@ -3,19 +3,16 @@ import {
SET_OUTPUT_BALANCE
,
SET_INPUT_TOKEN
,
SET_OUTPUT_TOKEN
,
SET_INVARIANT_1
,
SET_INVARIANT_2
,
SET_MARKET_ETH_1
,
SET_MARKET_ETH_2
,
SET_MARKET_TOKENS_1
,
SET_MARKET_TOKENS_2
,
SET_ETH_POOL_1
,
SET_ETH_POOL_2
,
SET_TOKEN_POOL_1
,
SET_TOKEN_POOL_2
,
SET_ALLOWANCE_APPROVAL_STATE
,
SET_EXCHANGE_INPUT_VALUE
,
SET_EXCHANGE_OUTPUT_VALUE
,
SET_EXCHANGE_RATE
,
SET_EXCHANGE_FEE
,
SET_INVEST_TOKEN
,
SET_INVEST_INVARIANT
,
SET_INVEST_ETH_POOL
,
SET_INVEST_TOKEN_POOL
,
SET_INVEST_SHARES
,
...
...
@@ -49,34 +46,24 @@ export const setOutputToken = (outputToken) => ({
outputToken
});
export
const
set
Invariant1
=
(
invariant
1
)
=>
({
type
:
SET_
INVARIANT
_1
,
invariant
1
export
const
set
EthPool1
=
(
ethPool
1
)
=>
({
type
:
SET_
ETH_POOL
_1
,
ethPool
1
});
export
const
set
Invariant2
=
(
invariant
2
)
=>
({
type
:
SET_
INVARIANT
_2
,
invariant
2
export
const
set
EthPool2
=
(
ethPool
2
)
=>
({
type
:
SET_
ETH_POOL
_2
,
ethPool
2
});
export
const
set
MarketEth1
=
(
marketEth
1
)
=>
({
type
:
SET_
MARKET_ETH_1
,
marketEth
1
export
const
set
TokenPool1
=
(
tokenPool
1
)
=>
({
type
:
SET_
TOKEN_POOL_2
,
tokenPool
1
});
export
const
setMarketEth2
=
(
marketEth2
)
=>
({
type
:
SET_MARKET_ETH_2
,
marketEth2
});
export
const
setMarketTokens1
=
(
marketTokens1
)
=>
({
type
:
SET_MARKET_TOKENS_1
,
marketTokens1
});
export
const
setMarketTokens2
=
(
marketTokens2
)
=>
({
type
:
SET_MARKET_TOKENS_2
,
marketTokens2
export
const
setTokenPool2
=
(
tokenPool2
)
=>
({
type
:
SET_TOKEN_POOL_2
,
tokenPool2
});
export
const
setAllowanceApprovalState
=
(
allowanceApproved
)
=>
({
...
...
@@ -109,11 +96,6 @@ export const setInvestToken = (investToken) => ({
investToken
});
export
const
setInvestInvariant
=
(
investInvariant
)
=>
({
type
:
SET_INVEST_INVARIANT
,
investInvariant
});
export
const
setInvestEthPool
=
(
investEthPool
)
=>
({
type
:
SET_INVEST_ETH_POOL
,
investEthPool
...
...
src/components/Exchange.js
View file @
309bd109
...
...
@@ -49,22 +49,22 @@ class Exchange extends Component {
// TODO: change this to use the redux-subscribe pattern
getMarketType
=
()
=>
{
var
marketType
=
''
;
if
(
this
.
props
.
exchange
.
inputToken
.
value
===
'
ETH
'
&&
this
.
props
.
exchange
.
outputToken
.
value
===
'
ETH
'
)
{
var
inputSymbol
=
this
.
props
.
exchange
.
inputToken
.
value
;
var
outputSymbol
=
this
.
props
.
exchange
.
outputToken
.
value
;
if
(
inputSymbol
===
'
ETH
'
&&
outputSymbol
===
'
ETH
'
)
{
marketType
=
'
ETH to ETH
'
;
this
.
props
.
setInteractionState
(
'
error1
'
);
}
else
if
(
this
.
props
.
exchange
.
inputToken
.
value
===
this
.
props
.
exchange
.
outputToken
.
value
){
}
else
if
(
inputSymbol
===
outputSymbol
){
marketType
=
'
Token to itself
'
;
}
else
if
(
this
.
props
.
exchange
.
inputToken
.
value
===
'
ETH
'
){
}
else
if
(
inputSymbol
===
'
ETH
'
){
marketType
=
'
ETH to Token
'
;
}
else
if
(
this
.
props
.
exchange
.
outputToken
.
value
===
'
ETH
'
){
}
else
if
(
outputSymbol
===
'
ETH
'
){
marketType
=
'
Token to ETH
'
;
}
else
{
marketType
=
'
Token to Token
'
;
}
this
.
props
.
setExchangeType
(
marketType
);
console
.
log
(
'
type:
'
,
marketType
);
console
.
log
(
'
input:
'
,
this
.
props
.
exchange
.
inputToken
.
value
);
console
.
log
(
'
output:
'
,
this
.
props
.
exchange
.
outputToken
.
value
);
console
.
log
(
'
type:
'
,
marketType
,
'
input:
'
,
inputSymbol
,
'
output:
'
,
outputSymbol
);
}
getExchangeRate
=
(
input
)
=>
{
...
...
@@ -81,44 +81,42 @@ class Exchange extends Component {
}
ethToTokenRate
=
(
ethInput
)
=>
{
var
ethInMarket
=
+
this
.
props
.
exchange
.
marketEth
2
;
var
tokensInMarket
=
+
this
.
props
.
exchange
.
marketTokens
2
;
var
invar
=
+
this
.
props
.
exchange
.
invariant2
;
var
ethInMarket
=
+
this
.
props
.
exchange
.
ethPool
2
;
var
tokensInMarket
=
+
this
.
props
.
exchange
.
tokenPool
2
;
var
invar
=
ethInMarket
*
tokensInMarket
var
ethIn
=
ethInput
*
10
**
18
;
var
exchangeFee
=
ethIn
/
500
;
var
ethSold
=
ethIn
-
exchangeFee
;
var
newEthInMarket
=
ethInMarket
+
ethSold
;
var
newTokensInMarket
=
invar
/
newEthInMarket
;
var
tokensOut
=
tokensInMarket
-
newTokensInMarket
;
var
adjustedTokensOut
=
tokensOut
*
0.98
;
var
buyRate
=
adjustedTokensOut
/
ethIn
;
var
buyRate
=
tokensOut
/
ethIn
;
this
.
props
.
setExchangeRate
(
buyRate
);
this
.
props
.
setExchangeFee
(
exchangeFee
);
this
.
props
.
setExchangeOutputValue
(
adjustedT
okensOut
);
this
.
props
.
setExchangeOutputValue
(
t
okensOut
);
}
tokenToEthRate
=
(
tokenInput
)
=>
{
var
ethInMarket
=
+
this
.
props
.
exchange
.
marketEth
1
;
var
tokensInMarket
=
+
this
.
props
.
exchange
.
marketTokens
1
;
var
invar
=
+
this
.
props
.
exchange
.
invariant1
;
var
ethInMarket
=
+
this
.
props
.
exchange
.
ethPool
1
;
var
tokensInMarket
=
+
this
.
props
.
exchange
.
tokenPool
1
;
var
invar
=
ethInMarket
*
tokensInMarket
;
var
tokensIn
=
tokenInput
*
10
**
18
;
var
exchangeFee
=
tokensIn
/
500
;
var
tokensSold
=
tokensIn
-
exchangeFee
;
var
newTokensInMarket
=
tokensInMarket
+
tokensSold
;
var
newEthInMarket
=
invar
/
newTokensInMarket
;
var
ethOut
=
ethInMarket
-
newEthInMarket
;
var
adjustedEthOut
=
ethOut
*
0.98
;
var
buyRate
=
adjustedEthOut
/
tokensIn
;
var
buyRate
=
ethOut
/
tokensIn
;
this
.
props
.
setExchangeRate
(
buyRate
);
this
.
props
.
setExchangeFee
(
exchangeFee
);
this
.
props
.
setExchangeOutputValue
(
adjustedE
thOut
);
this
.
props
.
setExchangeOutputValue
(
e
thOut
);
}
tokenToTokenRate
=
(
tokenInput
)
=>
{
// Token to ETH on Exchange 1
var
ethInMarket1
=
+
this
.
props
.
exchange
.
marketEth
1
;
var
tokensInMarket1
=
+
this
.
props
.
exchange
.
marketTokens
1
;
var
invar1
=
+
this
.
props
.
exchange
.
invarian
t1
;
var
ethInMarket1
=
+
this
.
props
.
exchange
.
ethPool
1
;
var
tokensInMarket1
=
+
this
.
props
.
exchange
.
tokenPool
1
;
var
invar1
=
ethInMarket1
*
tokensInMarke
t1
;
var
tokensIn
=
tokenInput
*
10
**
18
;
var
exchangeFee1
=
tokensIn
/
500
;
var
tokensSold
=
tokensIn
-
exchangeFee1
;
...
...
@@ -126,19 +124,18 @@ class Exchange extends Component {
var
newEthInMarket1
=
invar1
/
newTokensInMarket1
;
var
ethToExchange2
=
ethInMarket1
-
newEthInMarket1
;
// ETH to Token on Exchange 2
var
ethInMarket2
=
+
this
.
props
.
exchange
.
marketEth
2
;
var
tokensInMarket2
=
+
this
.
props
.
exchange
.
marketTokens
2
;
var
invar2
=
+
this
.
props
.
exchange
.
invarian
t2
;
var
ethInMarket2
=
+
this
.
props
.
exchange
.
ethPool
2
;
var
tokensInMarket2
=
+
this
.
props
.
exchange
.
tokenPool
2
;
var
invar2
=
ethInMarket2
*
tokensInMarke
t2
;
var
exchangeFee2
=
ethToExchange2
/
500
;
var
ethSold
=
ethToExchange2
-
exchangeFee2
;
var
newEthInMarket2
=
ethInMarket2
+
ethSold
;
var
newTokensInMarket2
=
invar2
/
newEthInMarket2
;
var
tokensOut
=
tokensInMarket2
-
newTokensInMarket2
;
var
adjustedTokensOut
=
tokensOut
*
0.98
;
var
buyRate
=
adjustedTokensOut
/
tokensIn
;
var
buyRate
=
tokensOut
/
tokensIn
;
this
.
props
.
setExchangeRate
(
buyRate
);
this
.
props
.
setExchangeFee
(
exchangeFee1
);
this
.
props
.
setExchangeOutputValue
(
adjustedT
okensOut
);
this
.
props
.
setExchangeOutputValue
(
t
okensOut
);
}
render
()
{
...
...
src/components/Invest.js
View file @
309bd109
...
...
@@ -4,7 +4,6 @@ import { connect } from 'react-redux';
import
{
bindActionCreators
}
from
'
redux
'
;
import
{
setInvestToken
,
setInvestInvariant
,
setInvestEthPool
,
setInvestTokenPool
,
setInvestShares
,
...
...
@@ -25,7 +24,6 @@ class Invest extends Component {
this
.
getInvestExchangeState
();
this
.
getInvestBalance
();
}
else
{
this
.
props
.
setInvestInvariant
(
0
);
this
.
props
.
setInvestTokenPool
(
0
);
this
.
props
.
setInvestEthPool
(
0
);
this
.
props
.
setInvestTokenBalance
(
0
);
...
...
@@ -49,10 +47,6 @@ class Invest extends Component {
getInvestExchangeState
=
()
=>
{
var
exchange
=
this
.
props
.
symbolToExchangeContract
(
this
.
props
.
exchange
.
investToken
.
value
);
exchange
.
methods
.
invariant
().
call
().
then
((
result
,
error
)
=>
{
this
.
props
.
setInvestInvariant
(
result
);
});
exchange
.
methods
.
ethPool
().
call
().
then
((
result
,
error
)
=>
{
this
.
props
.
setInvestEthPool
(
result
);
});
...
...
@@ -181,7 +175,6 @@ const mapStateToProps = state => ({
const
mapDispatchToProps
=
(
dispatch
)
=>
{
return
bindActionCreators
({
setInvestToken
,
setInvestInvariant
,
setInvestEthPool
,
setInvestTokenPool
,
setInvestShares
,
...
...
src/constants.js
View file @
309bd109
// here is where we put the string literals for the actions
// string literals for actions
// set global web3 object
export
const
INITIALIZE_GLOBAL_WEB3
=
'
INITIALIZE_GLOBAL_WEB3
'
;
// web3 actions, all set from action creator to reducer to app
export
const
SET_WEB3_CONNECTION_STATUS
=
'
WEB3_CONNECTION_STATUS
'
;
...
...
@@ -13,43 +16,30 @@ export const SET_NETWORK_MESSAGE = 'SET_NETWORK_MESSAGE';
export
const
SET_BLOCK_TIMESTAMP
=
'
SET_BLOCK_TIMESTAMP
'
;
export
const
SET_EXCHANGE_TYPE
=
'
SET_EXCHANGE_TYPE
'
;
// action
to toggle the 'about' div
// action
s to toggle divs
export
const
TOGGLE_ABOUT
=
'
TOGGLE_ABOUT
'
;
// action to toggle the 'invest' div
export
const
TOGGLE_INVEST
=
'
TOGGLE_INVEST
'
;
//
factory contract action, also set
//
CONTRACT actions in actions, action creator, reducer
export
const
FACTORY_CONTRACT_READY
=
'
FACTORY_CONTRACT_READY
'
;
// token EXCHANGE contract actions, in action creator, reducer, and app
export
const
UNI_EXCHANGE_CONTRACT_READY
=
'
UNI_EXCHANGE_CONTRACT_READY
'
;
export
const
SWT_EXCHANGE_CONTRACT_READY
=
'
SWT_EXCHANGE_CONTRACT_READY
'
;
export
const
EXCHANGE_CONTRACT_READY
=
'
EXCHANGE_CONTRACT_READY
'
;
// token CONTRACT actions in actions, action creator, reducer
export
const
UNI_TOKEN_CONTRACT_READY
=
'
UNI_TOKEN_CONTRACT_READY
'
;
export
const
SWT_TOKEN_CONTRACT_READY
=
'
SWT_TOKEN_CONTRACT_READY
'
;
export
const
TOKEN_CONTRACT_READY
=
'
TOKEN_CONTRACT_READY
'
;
// actions for the exchange
, all in one place
// actions for the exchange
export
const
SET_INPUT_BALANCE
=
'
SET_INPUT_BALANCE
'
;
export
const
SET_OUTPUT_BALANCE
=
'
SET_OUTPUT_BALANCE
'
;
export
const
SET_INPUT_TOKEN
=
'
SET_INPUT_TOKEN
'
;
export
const
SET_OUTPUT_TOKEN
=
'
SET_OUTPUT_TOKEN
'
;
export
const
SET_INVARIANT_1
=
'
SET_INVARIANT_1
'
;
export
const
SET_INVARIANT_2
=
'
SET_INVARIANT_2
'
;
export
const
SET_MARKET_ETH_1
=
'
SET_MARKET_ETH_1
'
;
export
const
SET_MARKET_ETH_2
=
'
SET_MARKET_ETH_2
'
;
export
const
SET_MARKET_TOKENS_1
=
'
SET_MARKET_TOKENS_1
'
;
export
const
SET_MARKET_TOKENS_2
=
'
SET_MARKET_TOKENS_2
'
;
export
const
SET_ETH_POOL_1
=
'
SET_ETH_POOL_1
'
;
export
const
SET_ETH_POOL_2
=
'
SET_ETH_POOL_2
'
;
export
const
SET_TOKEN_POOL_1
=
'
SET_TOKEN_POOL_1
'
;
export
const
SET_TOKEN_POOL_2
=
'
SET_TOKEN_POOL_2
'
;
export
const
SET_ALLOWANCE_APPROVAL_STATE
=
'
SET_ALLOWANCE_APPROVAL_STATE
'
;
export
const
SET_EXCHANGE_INPUT_VALUE
=
'
SET_EXCHANGE_INPUT_VALUE
'
;
export
const
SET_EXCHANGE_OUTPUT_VALUE
=
'
SET_EXCHANGE_OUTPUT_VALUE
'
;
export
const
SET_EXCHANGE_RATE
=
'
SET_EXCHANGE_RATE
'
;
export
const
SET_EXCHANGE_FEE
=
'
SET_EXCHANGE_FEE
'
;
export
const
SET_INVEST_TOKEN
=
'
SET_INVEST_TOKEN
'
;
export
const
SET_INVEST_INVARIANT
=
'
SET_INVEST_INVARIANT
'
;
export
const
SET_INVEST_ETH_POOL
=
'
SET_INVEST_ETH
'
;
export
const
SET_INVEST_TOKEN_POOL
=
'
SET_INVEST_TOKENS
'
;
export
const
SET_INVEST_TOKEN_ALLOWANCE
=
'
SET_INVEST_TOKEN_ALLOWANCE
'
;
...
...
@@ -61,7 +51,3 @@ export const SET_INVEST_SHARES_INPUT = 'SET_INVEST_SHARES_INPUT';
export
const
SET_INVEST_ETH_REQUIRED
=
'
SET_INVEST_ETH_REQUIRED
'
;
export
const
SET_INVEST_TOKENS_REQUIRED
=
'
SET_INVEST_TOKENS_REQUIRED
'
;
export
const
SET_INVEST_CHECKED
=
'
SET_INVEST_CHECKED
'
;
// test setInteractionState
export
const
INITIALIZE_GLOBAL_WEB3
=
'
INITIALIZE_GLOBAL_WEB3
'
;
src/reducers/exchange-reducer.js
View file @
309bd109
...
...
@@ -3,19 +3,16 @@ import {
SET_OUTPUT_BALANCE
,
SET_INPUT_TOKEN
,
SET_OUTPUT_TOKEN
,
SET_INVARIANT_1
,
SET_INVARIANT_2
,
SET_MARKET_ETH_1
,
SET_MARKET_ETH_2
,
SET_MARKET_TOKENS_1
,
SET_MARKET_TOKENS_2
,
SET_ETH_POOL_1
,
SET_ETH_POOL_2
,
SET_TOKEN_POOL_1
,
SET_TOKEN_POOL_2
,
SET_ALLOWANCE_APPROVAL_STATE
,
SET_EXCHANGE_INPUT_VALUE
,
SET_EXCHANGE_OUTPUT_VALUE
,
SET_EXCHANGE_RATE
,
SET_EXCHANGE_FEE
,
SET_INVEST_TOKEN
,
SET_INVEST_INVARIANT
,
SET_INVEST_ETH_POOL
,
SET_INVEST_TOKEN_POOL
,
SET_INVEST_TOKEN_ALLOWANCE
,
...
...
@@ -37,10 +34,10 @@ export default (state = {}, action) => {
outputToken
,
invariant1
,
invariant2
,
marketEth
1
,
marketEth
2
,
marketTokens
1
,
marketTokens
2
,
ethPool
1
,
ethPool
2
,
tokenPool
1
,
tokenPool
2
,
allowanceApproved
,
inputValue
,
outputValue
,
...
...
@@ -70,18 +67,14 @@ export default (state = {}, action) => {
return
Object
.
assign
({},
state
,
{
inputToken
:
inputToken
});
case
SET_OUTPUT_TOKEN
:
return
Object
.
assign
({},
state
,
{
outputToken
:
outputToken
});
case
SET_INVARIANT_1
:
return
Object
.
assign
({},
state
,
{
invariant1
:
invariant1
});
case
SET_INVARIANT_2
:
return
Object
.
assign
({},
state
,
{
invariant2
:
invariant2
});
case
SET_MARKET_ETH_1
:
return
Object
.
assign
({},
state
,
{
marketEth1
:
marketEth1
});
case
SET_MARKET_ETH_2
:
return
Object
.
assign
({},
state
,
{
marketEth2
:
marketEth2
});
case
SET_MARKET_TOKENS_1
:
return
Object
.
assign
({},
state
,
{
marketTokens1
:
marketTokens1
});
case
SET_MARKET_TOKENS_2
:
return
Object
.
assign
({},
state
,
{
marketTokens2
:
marketTokens2
});
case
SET_ETH_POOL_1
:
return
Object
.
assign
({},
state
,
{
ethPool1
:
ethPool1
});
case
SET_ETH_POOL_2
:
return
Object
.
assign
({},
state
,
{
ethPool2
:
ethPool2
});
case
SET_TOKEN_POOL_1
:
return
Object
.
assign
({},
state
,
{
tokenPool1
:
tokenPool1
});
case
SET_TOKEN_POOL_2
:
return
Object
.
assign
({},
state
,
{
tokenPool2
:
tokenPool2
});
case
SET_ALLOWANCE_APPROVAL_STATE
:
return
Object
.
assign
({},
state
,
{
allowanceApproved
:
allowanceApproved
});
case
SET_EXCHANGE_INPUT_VALUE
:
...
...
@@ -94,8 +87,6 @@ export default (state = {}, action) => {
return
Object
.
assign
({},
state
,
{
fee
:
fee
});
case
SET_INVEST_TOKEN
:
return
Object
.
assign
({},
state
,
{
investToken
:
investToken
});
case
SET_INVEST_INVARIANT
:
return
Object
.
assign
({},
state
,
{
investInvariant
:
investInvariant
});
case
SET_INVEST_ETH_POOL
:
return
Object
.
assign
({},
state
,
{
investEthPool
:
investEthPool
});
case
SET_INVEST_TOKEN_POOL
:
...
...
src/reducers/exchangeContract-reducer.js
View file @
309bd109
import
{
UNI_EXCHANGE_CONTRACT_READY
,
SWT_EXCHANGE_CONTRACT_READY
,
EXCHANGE_CONTRACT_READY
}
from
'
../constants
'
export
default
(
state
=
{},
action
)
=>
{
const
{
contract
,
payload
}
=
action
;
switch
(
action
.
type
)
{
case
UNI_EXCHANGE_CONTRACT_READY
:
return
Object
.
assign
({},
state
,
{
UNI
:
contract
});
case
SWT_EXCHANGE_CONTRACT_READY
:
return
Object
.
assign
({},
state
,
{
SWT
:
contract
});
case
EXCHANGE_CONTRACT_READY
:
case
EXCHANGE_CONTRACT_READY
:
return
Object
.
assign
({},
state
,
payload
)
default
:
return
state
;
}
}
\ No newline at end of file
}
src/reducers/tokenContract-reducer.js
View file @
309bd109
import
{
UNI_TOKEN_CONTRACT_READY
,
SWT_TOKEN_CONTRACT_READY
,
import
{
TOKEN_CONTRACT_READY
}
from
'
../constants
'
;
export
default
(
state
=
{},
action
)
=>
{
const
{
contract
,
payload
}
=
action
;
switch
(
action
.
type
)
{
case
UNI_TOKEN_CONTRACT_READY
:
return
Object
.
assign
({},
state
,
{
UNI
:
contract
});
case
SWT_TOKEN_CONTRACT_READY
:
return
Object
.
assign
({},
state
,
{
SWT
:
contract
});
case
TOKEN_CONTRACT_READY
:
case
TOKEN_CONTRACT_READY
:
return
Object
.
assign
({},
state
,
payload
)
default
:
return
state
;
}
}
\ No newline at end of file
}
src/store/initial-state.js
View file @
309bd109
...
...
@@ -39,18 +39,15 @@ export default {
inputToken
:
{
value
:
'
ETH
'
,
label
:
'
ETH
'
,
clearableValue
:
false
},
outputToken
:
{
value
:
'
BAT
'
,
label
:
'
BAT
'
,
clearableValue
:
false
},
investToken
:
{
value
:
'
BAT
'
,
label
:
'
BAT
'
,
clearableValue
:
false
},
invariant1
:
0
,
invariant2
:
0
,
marketEth1
:
0
,
marketEth2
:
0
,
marketTokens1
:
0
,
marketTokens2
:
0
,
ethPool1
:
0
,
ethPool2
:
0
,
tokenPool1
:
0
,
tokenPool2
:
0
,
allowanceApproved
:
true
,
inputValue
:
0
,
outputValue
:
0
,
rate
:
0
,
fee
:
0
,
investInvariant
:
0
,
investEthPool
:
0
,
investTokenPool
:
0
,
investShares
:
0
,
...
...
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