Commit 93ab10c9 authored by Hayden Adams's avatar Hayden Adams

add MKR, DAI, ZRX

parent e6ad0c58
...@@ -19,7 +19,7 @@ class Exchange extends Component { ...@@ -19,7 +19,7 @@ class Exchange extends Component {
this.props.setExchangeRate(0); this.props.setExchangeRate(0);
this.props.setExchangeFee(0); this.props.setExchangeFee(0);
this.props.setInteractionState('connected'); this.props.setInteractionState('connected');
// what the flip does this do // what the flip does this do
// this.setState({ firstRun: true }) // this.setState({ firstRun: true })
if (type === 'input') { if (type === 'input') {
...@@ -27,14 +27,14 @@ class Exchange extends Component { ...@@ -27,14 +27,14 @@ class Exchange extends Component {
} else if (type === 'output'){ } else if (type === 'output'){
await this.props.setOutputToken(selected); await this.props.setOutputToken(selected);
} }
await this.getMarketType(); await this.getMarketType();
// these two functions are actually being passed from the parent component, because they're used in multiple places // these two functions are actually being passed from the parent component, because they're used in multiple places
// eventually pull these out into HOC // eventually pull these out into HOC
this.props.getAccountInfo(); this.props.getAccountInfo();
this.props.getMarketInfo(); this.props.getMarketInfo();
} }
setExchangeOutput = () => { setExchangeOutput = () => {
var inputValue = this.props.exchange.inputValue; var inputValue = this.props.exchange.inputValue;
console.log(inputValue, 'from setExchangeOutput') console.log(inputValue, 'from setExchangeOutput')
...@@ -44,7 +44,7 @@ class Exchange extends Component { ...@@ -44,7 +44,7 @@ class Exchange extends Component {
this.props.setInteractionState('error1'); this.props.setInteractionState('error1');
} else if(inputValue && inputValue !== 0 && inputValue !== '0'){ } else if(inputValue && inputValue !== 0 && inputValue !== '0'){
this.props.setInteractionState('input'); this.props.setInteractionState('input');
// another function to be pulled out into HOC // another function to be pulled out into HOC
this.getExchangeRate(inputValue); this.getExchangeRate(inputValue);
} else { } else {
this.props.setExchangeOutputValue(0); this.props.setExchangeOutputValue(0);
...@@ -83,7 +83,7 @@ class Exchange extends Component { ...@@ -83,7 +83,7 @@ class Exchange extends Component {
this.tokenToTokenRate(input); this.tokenToTokenRate(input);
} }
} }
ethToTokenRate = (ethInput) => { ethToTokenRate = (ethInput) => {
var ethInMarket = +this.props.exchange.marketEth2; var ethInMarket = +this.props.exchange.marketEth2;
var tokensInMarket = +this.props.exchange.marketTokens2; var tokensInMarket = +this.props.exchange.marketTokens2;
...@@ -157,7 +157,7 @@ class Exchange extends Component { ...@@ -157,7 +157,7 @@ class Exchange extends Component {
<p></p> <p></p>
</div> </div>
<div className="value border pa2"> <div className="value border pa2">
<input type="number" readOnly={true} value={(this.props.exchange.outputValue/10**18).toFixed(5)} placeholder="0"/> <input type="number" readOnly={true} value={(this.props.exchange.outputValue/10**18).toFixed(6)} placeholder="0"/>
<SelectToken token={this.props.exchange.outputToken} onSelectToken={this.onSelectToken} type="output"/> <SelectToken token={this.props.exchange.outputToken} onSelectToken={this.onSelectToken} type="output"/>
<p className="dropdown">{'<'}</p> <p className="dropdown">{'<'}</p>
</div> </div>
...@@ -170,7 +170,7 @@ const mapStateToProps = state => ({ ...@@ -170,7 +170,7 @@ const mapStateToProps = state => ({
web3Store: state.web3Store, web3Store: state.web3Store,
exchange: state.exchange exchange: state.exchange
}) })
const mapDispatchToProps = (dispatch) => { const mapDispatchToProps = (dispatch) => {
return bindActionCreators({ return bindActionCreators({
setExchangeInputValue, setExchangeInputValue,
...@@ -187,4 +187,4 @@ const mapStateToProps = state => ({ ...@@ -187,4 +187,4 @@ const mapStateToProps = state => ({
}, dispatch); }, dispatch);
} }
export default connect(mapStateToProps, mapDispatchToProps)(Exchange); export default connect(mapStateToProps, mapDispatchToProps)(Exchange);
\ No newline at end of file
...@@ -27,7 +27,7 @@ class Purchase extends Component { ...@@ -27,7 +27,7 @@ class Purchase extends Component {
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) => {
// console.log('Transaction Hash created' // console.log('Transaction Hash created'
// let transactions = this.state.transactions // let transactions = this.state.transactions
// transactions.push(result); // transactions.push(result);
// transactions is cookie stuff, we'll keep that in state // transactions is cookie stuff, we'll keep that in state
...@@ -57,7 +57,7 @@ class Purchase extends Component { ...@@ -57,7 +57,7 @@ class Purchase extends Component {
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
exchange.methods.tokenToEthSwap(tokensSoldInt, minEthInt, timeout).send({from: this.props.web3Store.currentMaskAddress}) exchange.methods.tokenToEthSwap(tokensSoldInt, minEthInt, timeout).send({from: this.props.web3Store.currentMaskAddress})
.on('transactionHash', (result) => { .on('transactionHash', (result) => {
// console.log('Transaction Hash created') // console.log('Transaction Hash created')
...@@ -107,7 +107,7 @@ class Purchase extends Component { ...@@ -107,7 +107,7 @@ class Purchase extends Component {
if (this.props.web3Store.interaction === 'input') { if (this.props.web3Store.interaction === 'input') {
return ( return (
<a className="swap border pa2" role="button" onClick={() => {this.purchaseTokens()}}> <a className="swap border pa2" role="button" onClick={() => {this.purchaseTokens()}}>
<b>{"I want to swap " + this.props.exchange.inputValue + " " + this.props.exchange.inputToken.value + " for " + this.props.exchange.outputValue/10**18 + " " + this.props.exchange.outputToken.value}</b> <b>{"I want to swap " + this.props.exchange.inputValue + " " + this.props.exchange.inputToken.value + " for " + (this.props.exchange.outputValue/10**18).toFixed(6) + " " + this.props.exchange.outputToken.value}</b>
</a> </a>
) )
} else { } else {
......
...@@ -5,14 +5,14 @@ function RateAndFee ({ exchangeRate, outputTokenValue, inputTokenValue, exchange ...@@ -5,14 +5,14 @@ function RateAndFee ({ exchangeRate, outputTokenValue, inputTokenValue, exchange
<section className="rate border pa2"> <section className="rate border pa2">
<span className="rate-info"> <span className="rate-info">
<p>Rate</p> <p>Rate</p>
<p>{(exchangeRate).toFixed(5)} {outputTokenValue + "/" + inputTokenValue}</p> <p>{(exchangeRate).toFixed(6)} {outputTokenValue + "/" + inputTokenValue}</p>
</span> </span>
<span className="rate-info"> <span className="rate-info">
<p>Fee</p> <p>Fee</p>
<p>{(exchangeFee/10**18).toFixed(5)} {inputTokenValue}</p> <p>{(exchangeFee/10**18).toFixed(6)} {inputTokenValue}</p>
</span> </span>
</section> </section>
) )
} }
export default RateAndFee; export default RateAndFee;
\ No newline at end of file
...@@ -13,14 +13,20 @@ export default { ...@@ -13,14 +13,20 @@ export default {
exchangeType: 'ETH to Token', exchangeType: 'ETH to Token',
exchangeAddresses: { exchangeAddresses: {
addresses: [ addresses: [
['BAT','0x80f5C1beA2Ea4a9C21E4c6D7831ae2Dbce45674d'], ['BAT','0x80f5C1beA2Ea4a9C21E4c6D7831ae2Dbce45674d'],
['OMG','0x1033f09e293200de63AF16041e83000aFBBfF5c0'] ['DAI','0x9eb0461bcc20229bE61319372cCA84d782823FCb'],
['MKR','0x4c86a3b3cf926de3644f60658071ca604949609f'],
['OMG','0x1033f09e293200de63AF16041e83000aFBBfF5c0'],
['ZRX','0x42E109452F4055c82a513A527690F2D73251367e']
] ]
}, },
tokenAddresses: { tokenAddresses: {
addresses: [ addresses: [
['BAT','0xDA5B056Cfb861282B4b59d29c9B395bcC238D29B'], ['BAT','0xDA5B056Cfb861282B4b59d29c9B395bcC238D29B'],
['OMG','0x879884c3C46A24f56089f3bBbe4d5e38dB5788C0'] ['DAI','0x2448eE2641d78CC42D7AD76498917359D961A783'],
['MKR','0xf9ba5210f91d0474bd1e1dcdaec4c58e359aad85'],
['OMG','0x879884c3C46A24f56089f3bBbe4d5e38dB5788C0'],
['ZRX','0xF22e3F33768354c9805d046af3C0926f27741B43']
] ]
} }
}, },
...@@ -30,7 +36,7 @@ export default { ...@@ -30,7 +36,7 @@ export default {
inputBalance: 0, inputBalance: 0,
outputBalance: 0, outputBalance: 0,
inputToken: { value: 'ETH', label: 'ETH', clearableValue: false }, inputToken: { value: 'ETH', label: 'ETH', clearableValue: false },
outputToken: { value: 'OMG', label: 'OMG', clearableValue: false }, outputToken: { value: 'MKR', label: 'MKR', clearableValue: false },
invariant1: 0, invariant1: 0,
invariant2: 0, invariant2: 0,
marketEth1: 0, marketEth1: 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