Commit 1a73cdfa authored by Hayden Adams's avatar Hayden Adams

first deployment w/ visualization and investment

parent 994933f9
...@@ -306,3 +306,7 @@ input[type=number]::-webkit-outer-spin-button { ...@@ -306,3 +306,7 @@ input[type=number]::-webkit-outer-spin-button {
position: relative; position: relative;
left: -5px; left: -5px;
} }
.visualization {
font-family: "Inter UI", sans-serif;
}
...@@ -40,6 +40,7 @@ import { setInputBalance, ...@@ -40,6 +40,7 @@ import { setInputBalance,
setInvestEthPool, setInvestEthPool,
setInvestTokenPool, setInvestTokenPool,
setInvestShares, setInvestShares,
setUserShares,
setInvestTokenBalance, setInvestTokenBalance,
setInvestEthBalance } from './actions/exchange-actions'; setInvestEthBalance } from './actions/exchange-actions';
// enter d3 & misc. tools // enter d3 & misc. tools
...@@ -261,6 +262,10 @@ class App extends Component { ...@@ -261,6 +262,10 @@ class App extends Component {
this.props.setInvestShares(result); this.props.setInvestShares(result);
}); });
exchange.methods.getShares(this.props.web3Store.currentMaskAddress).call().then((result, error) => {
this.props.setUserShares(result);
});
token.methods.balanceOf(this.props.web3Store.currentMaskAddress).call((error, balance) => { token.methods.balanceOf(this.props.web3Store.currentMaskAddress).call((error, balance) => {
this.props.setInvestTokenBalance(balance); this.props.setInvestTokenBalance(balance);
}); });
...@@ -455,11 +460,11 @@ class App extends Component { ...@@ -455,11 +460,11 @@ class App extends Component {
inputTokenValue={this.props.exchange.inputToken.value} inputTokenValue={this.props.exchange.inputToken.value}
exchangeFee={this.props.exchange.fee} exchangeFee={this.props.exchange.fee}
/> />
<Visualization />
<Purchase <Purchase
symbolToExchangeContract={this.symbolToExchangeContract} symbolToExchangeContract={this.symbolToExchangeContract}
symbolToTokenAddress={this.symbolToTokenAddress} symbolToTokenAddress={this.symbolToTokenAddress}
/> />
<Visualization />
<Links <Links
toggleInvest={this.toggleInvest} toggleInvest={this.toggleInvest}
location={this} location={this}
...@@ -515,6 +520,7 @@ const mapDispatchToProps = (dispatch) => { ...@@ -515,6 +520,7 @@ const mapDispatchToProps = (dispatch) => {
setInvestTokenPool, setInvestTokenPool,
setInvestInvariant, setInvestInvariant,
setInvestShares, setInvestShares,
setUserShares,
setInvestTokenBalance, setInvestTokenBalance,
setInvestEthBalance setInvestEthBalance
}, dispatch) }, dispatch)
......
...@@ -19,6 +19,7 @@ import { ...@@ -19,6 +19,7 @@ import {
SET_INVEST_ETH_POOL, SET_INVEST_ETH_POOL,
SET_INVEST_TOKEN_POOL, SET_INVEST_TOKEN_POOL,
SET_INVEST_SHARES, SET_INVEST_SHARES,
SET_USER_SHARES,
SET_INVEST_TOKEN_BALANCE, SET_INVEST_TOKEN_BALANCE,
SET_INVEST_ETH_BALANCE, SET_INVEST_ETH_BALANCE,
SET_INVEST_SHARES_INPUT, SET_INVEST_SHARES_INPUT,
...@@ -126,6 +127,10 @@ export const setInvestShares = (investShares) => ({ ...@@ -126,6 +127,10 @@ export const setInvestShares = (investShares) => ({
investShares investShares
}); });
export const setUserShares = (userShares) => ({
type: SET_USER_SHARES,
userShares
});
export const setInvestTokenBalance = (investTokenBalance) => ({ export const setInvestTokenBalance = (investTokenBalance) => ({
type: SET_INVEST_TOKEN_BALANCE, type: SET_INVEST_TOKEN_BALANCE,
......
...@@ -3,7 +3,7 @@ import SelectToken from './SelectToken'; ...@@ -3,7 +3,7 @@ import SelectToken from './SelectToken';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { bindActionCreators } from 'redux'; import { bindActionCreators } from 'redux';
import { setInvestToken, setInvestInvariant, setInvestEthPool, setInvestTokenPool, setInvestShares, setInvestTokenBalance, setInvestEthBalance, setInvestSharesInput, setInvestEthRequired, setInvestTokensRequired} from '../actions/exchange-actions'; import { setInvestToken, setInvestInvariant, setInvestEthPool, setInvestTokenPool, setInvestShares, setInvestTokenBalance, setInvestEthBalance, setInvestSharesInput, setUserShares, setInvestEthRequired, setInvestTokensRequired} from '../actions/exchange-actions';
class Invest extends Component { class Invest extends Component {
...@@ -11,6 +11,7 @@ class Invest extends Component { ...@@ -11,6 +11,7 @@ class Invest extends Component {
if(selected.value !== 'ETH') { if(selected.value !== 'ETH') {
await this.props.setInvestToken(selected); await this.props.setInvestToken(selected);
this.getInvestExchangeState(); this.getInvestExchangeState();
this.getInvestBalance();
} else { } else {
this.props.setInvestInvariant(0); this.props.setInvestInvariant(0);
this.props.setInvestTokenPool(0); this.props.setInvestTokenPool(0);
...@@ -18,6 +19,7 @@ class Invest extends Component { ...@@ -18,6 +19,7 @@ class Invest extends Component {
this.props.setInvestTokenBalance(0); this.props.setInvestTokenBalance(0);
this.props.setInvestEthBalance(0); this.props.setInvestEthBalance(0);
this.props.setInvestShares(0); this.props.setInvestShares(0);
this.props.setUserShares(0);
} }
} }
...@@ -48,7 +50,9 @@ class Invest extends Component { ...@@ -48,7 +50,9 @@ class Invest extends Component {
} }
getInvestBalance = () => { getInvestBalance = () => {
console.log('yo');
var token = this.props.symbolToTokenContract(this.props.exchange.investToken.value); var token = this.props.symbolToTokenContract(this.props.exchange.investToken.value);
var exchange = this.props.symbolToExchangeContract(this.props.exchange.investToken.value);
this.props.web3Store.web3.eth.getBalance(this.props.web3Store.currentMaskAddress, (error, balance) => { this.props.web3Store.web3.eth.getBalance(this.props.web3Store.currentMaskAddress, (error, balance) => {
this.props.setInvestEthBalance(balance); this.props.setInvestEthBalance(balance);
...@@ -57,6 +61,11 @@ class Invest extends Component { ...@@ -57,6 +61,11 @@ class Invest extends Component {
token.methods.balanceOf(this.props.web3Store.currentMaskAddress).call((error, balance) => { token.methods.balanceOf(this.props.web3Store.currentMaskAddress).call((error, balance) => {
this.props.setInvestTokenBalance(balance); this.props.setInvestTokenBalance(balance);
}); });
exchange.methods.getShares(this.props.web3Store.currentMaskAddress).call().then((result, error) => {
this.props.setUserShares(result);
console.log(result);
});
} }
getInvestOutput = () => { getInvestOutput = () => {
...@@ -87,22 +96,22 @@ class Invest extends Component { ...@@ -87,22 +96,22 @@ class Invest extends Component {
</div> </div>
<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: 0 shares </p> <p> You own: {this.props.exchange.userShares} shares </p>
<p> You get 0% 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> {(this.props.exchange.investEthPool/10**18).toFixed(2)} ETH </p> <p> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{(this.props.exchange.investEthPool/10**18).toFixed(2)} ETH </p>
<p> {(this.props.exchange.investTokenPool/10**18).toFixed(2)} {this.props.exchange.investToken.value} </p> <p> {(this.props.exchange.investTokenPool/10**18).toFixed(2)} {this.props.exchange.investToken.value} </p>
</div> </div>
<div className="investValue border pa2"> <div className="investValue border pa2">
<p> Each share is worth: </p> <p> &nbsp;Each share is worth: </p>
<p> {((this.props.exchange.investEthPool/10**18)/this.props.exchange.investShares).toFixed(5)} ETH </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(5)} {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> {(this.props.exchange.investEthBalance/10**18).toFixed(5)} 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(5)} {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>
...@@ -129,7 +138,8 @@ const mapDispatchToProps = (dispatch) => { ...@@ -129,7 +138,8 @@ const mapDispatchToProps = (dispatch) => {
setInvestEthBalance, setInvestEthBalance,
setInvestSharesInput, setInvestSharesInput,
setInvestEthRequired, setInvestEthRequired,
setInvestTokensRequired setInvestTokensRequired,
setUserShares
}, dispatch); }, dispatch);
} }
......
...@@ -15,7 +15,7 @@ class Links extends Component { ...@@ -15,7 +15,7 @@ class Links extends Component {
<Invest <Invest
toggled={this.props.web3Store.investToggle} toggled={this.props.web3Store.investToggle}
token={this.props.exchange.investToken} token={this.props.exchange.investToken}
symbolToTokenContract={this.symbolToTokenContract} symbolToTokenContract={this.props.symbolToTokenContract}
symbolToExchangeContract={this.props.symbolToExchangeContract} symbolToExchangeContract={this.props.symbolToExchangeContract}
/> />
</div> </div>
......
...@@ -159,12 +159,14 @@ class Visualization extends Component { ...@@ -159,12 +159,14 @@ class Visualization extends Component {
} }
render () { render () {
const width = 1039; const width = 1000;
const height = 200; const height = 200;
return ( return (
<div className="visualization" align="center">
<svg width={width} height={height}> <svg width={width} height={height}>
<g ref="graph"/> <g ref="graph"/>
</svg> </svg>
</div>
) )
} }
} }
......
...@@ -54,6 +54,7 @@ export const SET_INVEST_INVARIANT = 'SET_INVEST_INVARIANT'; ...@@ -54,6 +54,7 @@ export const SET_INVEST_INVARIANT = 'SET_INVEST_INVARIANT';
export const SET_INVEST_ETH_POOL = 'SET_INVEST_ETH'; export const SET_INVEST_ETH_POOL = 'SET_INVEST_ETH';
export const SET_INVEST_TOKEN_POOL = 'SET_INVEST_TOKENS'; export const SET_INVEST_TOKEN_POOL = 'SET_INVEST_TOKENS';
export const SET_INVEST_SHARES = 'SET_INVEST_SHARES'; export const SET_INVEST_SHARES = 'SET_INVEST_SHARES';
export const SET_USER_SHARES = 'SET_USER_SHARES';
export const SET_INVEST_TOKEN_BALANCE = 'SET_INVEST_TOKEN_BALANCE'; export const SET_INVEST_TOKEN_BALANCE = 'SET_INVEST_TOKEN_BALANCE';
export const SET_INVEST_ETH_BALANCE = 'SET_INVEST_ETH_BALANCE'; export const SET_INVEST_ETH_BALANCE = 'SET_INVEST_ETH_BALANCE';
export const SET_INVEST_SHARES_INPUT = 'SET_INVEST_SHARES_INPUT'; export const SET_INVEST_SHARES_INPUT = 'SET_INVEST_SHARES_INPUT';
......
...@@ -19,6 +19,7 @@ import { ...@@ -19,6 +19,7 @@ import {
SET_INVEST_ETH_POOL, SET_INVEST_ETH_POOL,
SET_INVEST_TOKEN_POOL, SET_INVEST_TOKEN_POOL,
SET_INVEST_SHARES, SET_INVEST_SHARES,
SET_USER_SHARES,
SET_INVEST_ETH_BALANCE, SET_INVEST_ETH_BALANCE,
SET_INVEST_TOKEN_BALANCE, SET_INVEST_TOKEN_BALANCE,
SET_INVEST_SHARES_INPUT, SET_INVEST_SHARES_INPUT,
...@@ -48,6 +49,7 @@ export default (state = {}, action) => { ...@@ -48,6 +49,7 @@ export default (state = {}, action) => {
investEthPool, investEthPool,
investTokenPool, investTokenPool,
investShares, investShares,
userShares,
investEthBalance, investEthBalance,
investTokenBalance, investTokenBalance,
investSharesInput, investSharesInput,
...@@ -96,6 +98,8 @@ export default (state = {}, action) => { ...@@ -96,6 +98,8 @@ export default (state = {}, action) => {
return Object.assign({}, state, { investTokenPool: investTokenPool }); return Object.assign({}, state, { investTokenPool: investTokenPool });
case SET_INVEST_SHARES: case SET_INVEST_SHARES:
return Object.assign({}, state, { investShares: investShares }); return Object.assign({}, state, { investShares: investShares });
case SET_USER_SHARES:
return Object.assign({}, state, { userShares: userShares });
case SET_INVEST_ETH_BALANCE: case SET_INVEST_ETH_BALANCE:
return Object.assign({}, state, { investEthBalance: investEthBalance }); return Object.assign({}, state, { investEthBalance: investEthBalance });
case SET_INVEST_TOKEN_BALANCE: case SET_INVEST_TOKEN_BALANCE:
......
...@@ -54,6 +54,7 @@ export default { ...@@ -54,6 +54,7 @@ export default {
investEthPool: 0, investEthPool: 0,
investTokenPool: 0, investTokenPool: 0,
investShares: 0, investShares: 0,
userShares: 0,
investTokenBalance: 0, investTokenBalance: 0,
investEthBalance: 0, investEthBalance: 0,
investSharesInput: 0, investSharesInput: 0,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment