Commit 9099c739 authored by Hayden Adams's avatar Hayden Adams

update web3

parent 18214411
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
"react-helmet": "^5.2.0", "react-helmet": "^5.2.0",
"react-scripts": "1.1.0", "react-scripts": "1.1.0",
"react-select": "^1.2.1", "react-select": "^1.2.1",
"react-web3": "^0.4.4",
"web3": "1.0.0-beta.18" "web3": "1.0.0-beta.18"
}, },
"scripts": { "scripts": {
......
...@@ -7,7 +7,8 @@ import HelperMessages from './components/HelperMessages' ...@@ -7,7 +7,8 @@ import HelperMessages from './components/HelperMessages'
import SelectToken from './components/SelectToken' import SelectToken from './components/SelectToken'
import './App.css'; import './App.css';
import {uniswapABI, tokenABI} from './helpers/abi.js' import {exchangeABI} from './helpers/exchangeABI.js'
import {tokenABI} from './helpers/tokenABI.js'
var localweb3; var localweb3;
...@@ -20,32 +21,27 @@ class App extends Component { ...@@ -20,32 +21,27 @@ class App extends Component {
localweb3 = null localweb3 = null
} }
const uniswapAddress = '0x60e5f3cd0381c501971b6fbbddaa49cfd58a4fa1'; const exchangeAddress = '0xcDc30C3b02c5776495298198377D2Fc0fd6B1F1C';
const uniContract = new localweb3.eth.Contract(uniswapABI, uniswapAddress); const uniContract = new localweb3.eth.Contract(exchangeABI, exchangeAddress);
const tokenAddress = '0xca9901076d02f89794262869aad1340bd45d8489'; const tokenAddress = '0x350E5DD084ecF271e8d3531D4324443952F47756';
const tokenContract = new localweb3.eth.Contract(tokenABI, tokenAddress); const tokenContract = new localweb3.eth.Contract(tokenABI, tokenAddress);
this.state = { this.state = {
uniswapAddress: '0x60e5f3cd0381c501971b6fbbddaa49cfd58a4fa1', exchangeAddress: '0xcDc30C3b02c5776495298198377D2Fc0fd6B1F1C',
tokenAddress: '0xca9901076d02f89794262869aad1340bd45d8489', tokenAddress: '0x350E5DD084ecF271e8d3531D4324443952F47756',
currentMaskAddress: '0x0000000000000000000000000000000000000000',
uniswapContract: uniContract, uniswapContract: uniContract,
tokenContract: tokenContract, tokenContract: tokenContract,
ethBalance: 0, ethBalance: 0,
tokenBalance: 0, tokenBalance: 0,
tokenAllowance: null, tokenAllowance: null,
currentMaskAddress: '0x0000000000000000000000000000000000000000',
minimumTokensPurchased: null,
minimumEthPurchased: null,
invariant: 0, invariant: 0,
marketEth: 0, marketEth: 0,
marketTokens: 0, marketTokens: 0,
tokenBuyRate: 0, rate: 0,
ethBuyRate: 0, fee: 0,
tokenCost: 0, //eth price of tokens cost: 0,
ethCost: 0, //token price of eth
tokenFee: 0,
ethFee: 0,
networkMessage: '', networkMessage: '',
locked: false, locked: false,
connected: false, connected: false,
...@@ -56,23 +52,19 @@ class App extends Component { ...@@ -56,23 +52,19 @@ class App extends Component {
outputToken: { value: 'OMG', label: 'OMG', clearableValue: false } outputToken: { value: 'OMG', label: 'OMG', clearableValue: false }
} }
this.onBuyEthInputChange = this.onBuyEthInputChange.bind(this); this.onInputChange = this.onInputChange.bind(this);
this.onBuyTokensInputChange = this.onBuyTokensInputChange.bind(this); this.ethToTokenRate = this.ethToTokenRate.bind(this);
this.tokenBuyRate = this.tokenBuyRate.bind(this); this.getMarketInfo = this.getMarketInfo.bind(this);
this.ethBuyRate = this.ethBuyRate.bind(this);
} }
componentWillMount(){ componentWillMount(){
this.getMetaMaskAddress(); this.getMetaMaskAddress();
this.checkNetwork(); this.checkNetwork();
this.getInvarient(); this.getMarketInfo();
this.getMarketEth();
this.getMarketTokens();
} }
componentDidMount(){ componentDidMount(){
this.getAccountInfo(); this.getAccountInfo();
this.getContractInfo();
} }
getAccountInfo(){ getAccountInfo(){
...@@ -83,11 +75,14 @@ class App extends Component { ...@@ -83,11 +75,14 @@ class App extends Component {
}, 1000); }, 1000);
} }
getContractInfo(){ getMarketInfo(){
setTimeout(() => { this.getInvarient();
this.ethBuyRate(1); this.getMarketEth();
this.tokenBuyRate(1); this.getMarketTokens();
}, 1000); }
getRate(){
this.ethToTokenRate(1);
} }
getMetaMaskAddress() { getMetaMaskAddress() {
...@@ -103,24 +98,22 @@ class App extends Component { ...@@ -103,24 +98,22 @@ class App extends Component {
getEthBalance() { getEthBalance() {
var self = this; var self = this;
localweb3.eth.getBalance(this.state.currentMaskAddress, function(error, balance) { localweb3.eth.getBalance(this.state.currentMaskAddress, function(error, balance) {
var ethValue = (balance/10**18); self.setState({ethBalance: balance});
var roundedValue=Math.round(ethValue*10000)/10000;
self.setState({ethBalance: roundedValue});
}); });
} }
getTokenBalance() { getTokenBalance() {
var self = this; var self = this;
this.state.tokenContract.methods.balanceOf(this.state.currentMaskAddress).call(function(error, balance) { this.state.tokenContract.methods.balanceOf(this.state.currentMaskAddress).call(function(error, balance) {
var amount = balance/10**6; var amount = balance;
self.setState({tokenBalance: amount}); self.setState({tokenBalance: amount});
}); });
} }
getAllowance() { getAllowance() {
var self = this; // var self = this;
// this.state.tokenContract.methods.allowance(this.state.currentMaskAddress, this.uniswapAddress).call().then(function(result, error){ // this.state.tokenContract.methods.allowance(this.state.currentMaskAddress, this.exchangeAddress).call().then(function(result, error){
// var amount = result/10**6 // var amount = result
// self.setState({tokenAllowance: amount}); // self.setState({tokenAllowance: amount});
// }) // })
} }
...@@ -129,7 +122,7 @@ class App extends Component { ...@@ -129,7 +122,7 @@ class App extends Component {
var self = this; var self = this;
localweb3.eth.net.getNetworkType((err, networkId) => { localweb3.eth.net.getNetworkType((err, networkId) => {
console.log(networkId) console.log("Connected to " + networkId)
switch (networkId) { switch (networkId) {
case "main": case "main":
self.setState({networkMessage: 'Ethereum Mainet', connected: false, interaction: 'disconnected'}); self.setState({networkMessage: 'Ethereum Mainet', connected: false, interaction: 'disconnected'});
...@@ -156,141 +149,121 @@ class App extends Component { ...@@ -156,141 +149,121 @@ class App extends Component {
var self = this; var self = this;
this.state.uniswapContract.methods.invariant().call().then(function(result, error){ this.state.uniswapContract.methods.invariant().call().then(function(result, error){
self.setState({invariant: result}); self.setState({invariant: result});
// console.log("invariant: " + result);
}) })
} }
getMarketEth() { getMarketEth() {
var self = this var self = this
this.state.uniswapContract.methods.totalEthQuantity().call().then(function(result, error){ this.state.uniswapContract.methods.ethInMarket().call().then(function(result, error){
self.setState({marketEth: result}); self.setState({marketEth: result});
// console.log("marketEth: " + result);
}) })
} }
getMarketTokens() { getMarketTokens() {
var self = this var self = this
this.state.uniswapContract.methods.totalTokenQuantity().call().then(function(result, error){ this.state.uniswapContract.methods.tokensInMarket().call().then(function(result, error){
self.setState({marketTokens: result}); self.setState({marketTokens: result});
// console.log("marketTokens: " + result);
}) })
} }
tokenBuyRate(buyTokensInput) { onSelectToken = (selected, type) => {
if(buyTokensInput >= this.state.marketTokens/10**6) { console.log(selected)
this.setState( console.log(type)
{tokenBuyRate: 0, if (type === 'input'){
tokenCost: 0, this.setState({inputToken: selected});
tokenFee: 0, // do something here to update invariants and values
tokenBuyError: 'Not enough tokens' } else if (type === 'output'){
}); this.setState({outputToken: selected});
} // do something here to update invariants and values
else{
var tokensPurchased = buyTokensInput;
var invar = this.state.invariant/10**24;
var totalTokens = this.state.marketTokens/10**6;
var totalEth = this.state.marketEth/10**18;
var newTotalEth = invar/(totalTokens-tokensPurchased);
var fee = (newTotalEth - totalEth)/500;
var ethRequired = newTotalEth - totalEth + fee;
var rate = tokensPurchased/ethRequired;
//add 1% to cost displayed, some people will get more tokens than purchased
//less TX's will fail the minTokens smart contract check
var adjustedTokenCost = ethRequired*1.01;
this.setState(
{tokenBuyRate: rate,
tokenCost: adjustedTokenCost,
tokenFee: fee
});
} }
} }
ethBuyRate(buyEthInput) { onInputChange = (event) => {
if(buyEthInput >= this.state.marketEth/10**18) { this.getMarketInfo();
this.setState( var inputValue = event.target.value;
{ethBuyRate: 0, if(inputValue && inputValue !== 0){
ethCost: 0, this.ethToTokenRate(inputValue);
ethFee: 0, this.setState({input: inputValue, interaction: 'input'});
ethBuyError: 'Not enough tokens' } else {
}); this.setState({input: inputValue, output: 0, interaction: 'connected'});
}
else{
var ethPurchased = buyEthInput;
var invar = this.state.invariant/10**24;
var totalEth = this.state.marketEth/10**18;
var totalTokens = this.state.marketTokens/10**6;
var newTotalTokens = invar/(totalEth-ethPurchased);
var fee = (newTotalTokens - totalTokens)/500;
var tokensRequired = newTotalTokens - totalTokens + fee;
var rate = ethPurchased/(tokensRequired);
//add 1% to cost displayed, some people will get more eth than purchased
//less TX's will fail the minEth smart contract check
var adjustedEthCost = tokensRequired*1.01;
this.setState(
{ethBuyRate: rate,
ethCost: adjustedEthCost,
ethFee: fee
});
} }
} }
buyTokens() { ethToTokenRate(ethInput) {
var self = this; var ethInMarket = +this.state.marketEth;
var minTokens = this.state.minimumTokensPurchased var tokensInMarket = +this.state.marketTokens;
var invar = +this.state.invariant;
localweb3.eth.getBlock('latest', function(error, blockInfo) { var ethIn = ethInput*10**18;
var time = blockInfo.timestamp; var exchangeFee = ethIn/500;
var maxTime = time + 300; //current block time + 5mins var ethSold = ethIn - exchangeFee;
var newEthInMarket = ethInMarket + ethSold;
self.state.uniswapContract.methods.ethToTokens(minTokens, maxTime).send( var newTokensInMarket = invar/newEthInMarket;
{from: self.state.currentMaskAddress, value: self.state.tokenCost*10**18}, var tokensOut = tokensInMarket - newTokensInMarket;
function(err, txHash) {}) var adjustedTokensOut = tokensOut * 0.99
}); var buyRate = adjustedTokensOut/ethIn;
this.setState({rate: buyRate,
fee: exchangeFee,
output: adjustedTokensOut
});
} }
buyEth() { ethToTokenPurchase() {
var self = this; var self = this;
var minEth = this.state.minimumEthPurchased; var minTokens = this.state.output/10**18;
var minWei = localweb3.utils.toWei(minEth); var minTokensInt = localweb3.utils.toWei(minTokens);
var tokensSold = this.state.ethCost*10**6; var ethSold = this.state.input;
var weiSold = localweb3.utils.toWei(ethSold);
localweb3.eth.getBlock('latest', function(error, blockInfo) { localweb3.eth.getBlock('latest', function(error, blockInfo) {
var time = blockInfo.timestamp; var time = blockInfo.timestamp;
var maxTime = time + 300; //current block time + 5mins var timeout = time + 300; //current block time + 5mins
self.state.uniswapContract.methods.tokenToEth(tokensSold, minWei, maxTime).send( self.state.uniswapContract.methods.ethToTokenSwap(minTokensInt, timeout).send(
{from: self.state.currentMaskAddress}, {from: self.state.currentMaskAddress, value: weiSold},
function(err, txHash) {}) function(err, txHash) {})
}); });
} }
onSelectToken = (selected, type) => { tokenToEthRate(tokenInput) {
console.log(selected) var ethInMarket = +this.state.marketEth;
console.log(type) var tokensInMarket = +this.state.marketTokens;
if (type === 'input'){ var invar = +this.state.invariant;
this.setState({inputToken: selected}); var tokensIn = tokenInput*10**18;
// do something here to update invariants and values var exchangeFee = tokensIn/500;
} else if (type === 'output'){ var tokensSold = tokensIn - exchangeFee;
this.setState({outputToken: selected}); var newTokensInMarket = tokensInMarket + tokensSold;
// do something here to update invariants and values var newEthInMarket = invar/newTokensInMarket;
} var ethOut = ethInMarket - newEthInMarket;
} var adjustedEthOut = ethOut * 0.99;
var buyRate = adjustedEthOut/tokensIn;
onBuyTokensInputChange = (event) => { this.setState({rate: buyRate,
var buyTokensInput = event.target.value; fee: exchangeFee,
if(buyTokensInput && buyTokensInput !== 0){ output: adjustedEthOut
this.setState({ minimumTokensPurchased: buyTokensInput }); });
this.tokenBuyRate(buyTokensInput);
}
} }
onBuyEthInputChange = (event) => { // tokenToTokenRate(tokenInput) {
var buyEthInput = event.target.value; // var ethInMarket = +this.state.marketEth;
if(buyEthInput && buyEthInput !== 0){ // var tokensInMarket = +this.state.marketTokens;
this.setState({ minimumEthPurchased: buyEthInput, input: buyEthInput, output: this.state.tokenBuyRate.toFixed(3)*buyEthInput, interaction: 'input'}); // var invar = +this.state.invariant;
this.ethBuyRate(buyEthInput); // var ethIn = tokenInput*10**18;
} else { // var exchangeFee = ethIn/500;
this.setState({input: buyEthInput, output: this.state.tokenBuyRate.toFixed(3)*buyEthInput, interaction: 'connected'}); // var ethSold = ethIn - exchangeFee;
} // var newEthInMarket = ethInMarket + ethSold;
} // var newTokensInMarket = invar/newEthInMarket;
// var tokensOut = tokensInMarket - newTokensInMarket;
// var buyRate = tokensOut/ethIn;
// this.setState({rate: buyRate,
// fee: exchangeFee,
// output: tokensOut
// });
// }
render() { render() {
console.log(localweb3) //console.log(localweb3)
return ( return (
<div className={this.state.connected ? "App" : "App dim"}> <div className={this.state.connected ? "App" : "App dim"}>
<Head /> <Head />
...@@ -303,7 +276,7 @@ class App extends Component { ...@@ -303,7 +276,7 @@ class App extends Component {
<HelperMessages interaction={this.state.interaction} inputToken={this.state.inputToken} outputToken={this.state.outputToken}/> <HelperMessages interaction={this.state.interaction} inputToken={this.state.inputToken} outputToken={this.state.outputToken}/>
<section className="order"> <section className="order">
<div className="value border pa2"> <div className="value border pa2">
<input type="number" value={this.state.input} placeholder="0" onChange={this.onBuyEthInputChange} onChange={this.onBuyEthInputChange} /> <input type="number" value={this.state.input} placeholder="0" onChange={this.onInputChange} />
<SelectToken token={this.state.inputToken} onSelectToken={this.onSelectToken} type="input" /> <SelectToken token={this.state.inputToken} onSelectToken={this.onSelectToken} type="input" />
<p className="dropdown">{'<'}</p> <p className="dropdown">{'<'}</p>
</div> </div>
...@@ -311,7 +284,7 @@ class App extends Component { ...@@ -311,7 +284,7 @@ class App extends Component {
<p></p> <p></p>
</div> </div>
<div className="value border pa2"> <div className="value border pa2">
<input type="number" value={this.state.output} placeholder="0" onChange={this.onBuyTokensInputChange}/> <input type="number" value={this.state.output/10**18} placeholder="0"/>
<SelectToken token={this.state.outputToken} onSelectToken={this.onSelectToken} type="output"/> <SelectToken token={this.state.outputToken} onSelectToken={this.onSelectToken} type="output"/>
<p className="dropdown">{'<'}</p> <p className="dropdown">{'<'}</p>
</div> </div>
...@@ -319,20 +292,18 @@ class App extends Component { ...@@ -319,20 +292,18 @@ class App extends Component {
<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>{this.state.tokenBuyRate.toFixed(3)} UNI/ETH</p> <p>{this.state.rate} UNI/ETH</p>
</span>
<span className="rate-info">
<p>Cost</p>
<p>{this.state.tokenCost.toFixed(5)} ETH</p>
</span> </span>
<span className="rate-info"> <span className="rate-info">
<p>Fee</p> <p>Fee</p>
<p>{this.state.tokenFee.toFixed(5)} ETH</p> <p>{this.state.fee/10**18} ETH</p>
</span> </span>
</section> </section>
{this.state.interaction === 'input' ? {this.state.interaction === 'input' ?
<section className="swap border pa2"> <section className="swap border pa2">
<a href="">{"I want to swap " + this.state.input + " " + this.state.inputToken.value + " for " + this.state.output + " " + this.state.outputToken.value}</a> <a href="#" role="button" onClick={() => {this.ethToTokenPurchase() }}>
{"I want to swap " + this.state.input + " " + this.state.inputToken.value + " for " + this.state.output/10**18 + " " + this.state.outputToken.value}
</a>
</section> </section>
: <section className="swap hidden border pa2"></section>} : <section className="swap hidden border pa2"></section>}
<section className="links"> <section className="links">
...@@ -344,7 +315,6 @@ class App extends Component { ...@@ -344,7 +315,6 @@ class App extends Component {
<p className="underline">Add a new token</p> <p className="underline">Add a new token</p>
<p>+</p> <p>+</p>
</a> </a>
</section> </section>
<section className="links"> <section className="links">
<a href="" className="link border pa2"> <a href="" className="link border pa2">
......
module.exports.uniswapABI = [{"constant":false,"inputs":[{"name":"tokenAmount","type":"uint256"}],"name":"ownerTokenWithdraw","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"tokenAmount","type":"uint256"}],"name":"ownerTokenDeposit","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"ethAmount","type":"uint256"}],"name":"ownerEthWithdraw","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"sellQuantity","type":"uint256"},{"name":"minimumEth","type":"uint256"},{"name":"timeout","type":"uint256"}],"name":"tokenToEth","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"totalTokenQuantity","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"minimumTokens","type":"uint256"},{"name":"timeout","type":"uint256"}],"name":"ethToTokens","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":false,"inputs":[{"name":"initialTokenQuantity","type":"uint256"}],"name":"initiateUniswap","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"totalEthQuantity","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"tokenAddress","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"invariant","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"ownerEthDeposit","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":false,"inputs":[{"name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"inputs":[{"name":"_tokenAddress","type":"address"}],"payable":true,"stateMutability":"payable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"buyer","type":"address"},{"indexed":false,"name":"tokensPurchased","type":"uint256"},{"indexed":false,"name":"ethSpent","type":"uint256"}],"name":"TokenPurchase","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"buyer","type":"address"},{"indexed":false,"name":"ethPurchased","type":"uint256"},{"indexed":false,"name":"tokensSpent","type":"uint256"}],"name":"EthPurchase","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"previousOwner","type":"address"},{"indexed":true,"name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"}]
module.exports.tokenABI = [{"constant":true,"inputs":[],"name":"mintingFinished","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_value","type":"uint256"}],"name":"approve","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transferFrom","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_amount","type":"uint256"}],"name":"mint","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_subtractedValue","type":"uint256"}],"name":"decreaseApproval","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"}],"name":"balanceOf","outputs":[{"name":"balance","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"finishMinting","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transfer","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_addedValue","type":"uint256"}],"name":"increaseApproval","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"},{"name":"_spender","type":"address"}],"name":"allowance","outputs":[{"name":"remaining","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"anonymous":false,"inputs":[{"indexed":true,"name":"to","type":"address"},{"indexed":false,"name":"amount","type":"uint256"}],"name":"Mint","type":"event"},{"anonymous":false,"inputs":[],"name":"MintFinished","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"previousOwner","type":"address"},{"indexed":true,"name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"owner","type":"address"},{"indexed":true,"name":"spender","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"address"},{"indexed":true,"name":"to","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Transfer","type":"event"}]
module.exports.exchangeABI =
[
{
"constant": true,
"inputs": [],
"name": "FEE_RATE",
"outputs": [
{
"name": "",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"name": "_buyTokenAddress",
"type": "address"
},
{
"name": "_tokensSold",
"type": "uint256"
},
{
"name": "_minTokensReceived",
"type": "uint256"
},
{
"name": "_timeout",
"type": "uint256"
}
],
"name": "tokenToTokenSwap",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": false,
"inputs": [],
"name": "addFeesToMarketPublic",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "totalShares",
"outputs": [
{
"name": "",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"name": "sharesBurned",
"type": "uint256"
}
],
"name": "divestLiquidity",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": false,
"inputs": [],
"name": "investLiquidity",
"outputs": [],
"payable": true,
"stateMutability": "payable",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"name": "buyer",
"type": "address"
},
{
"name": "_minTokens",
"type": "uint256"
}
],
"name": "tokenToTokenIn",
"outputs": [
{
"name": "",
"type": "bool"
}
],
"payable": true,
"stateMutability": "payable",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "ethFees",
"outputs": [
{
"name": "",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"name": "_minTokens",
"type": "uint256"
},
{
"name": "_timeout",
"type": "uint256"
}
],
"name": "ethToTokenSwap",
"outputs": [],
"payable": true,
"stateMutability": "payable",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "factoryAddress",
"outputs": [
{
"name": "",
"type": "address"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "tokenAddress",
"outputs": [
{
"name": "",
"type": "address"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"name": "_tokenAmount",
"type": "uint256"
},
{
"name": "_minEth",
"type": "uint256"
},
{
"name": "_timeout",
"type": "uint256"
}
],
"name": "tokenToEthSwap",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "tokenFees",
"outputs": [
{
"name": "",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "invariant",
"outputs": [
{
"name": "",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "tokensInMarket",
"outputs": [
{
"name": "",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "ethInMarket",
"outputs": [
{
"name": "",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"name": "provider",
"type": "address"
}
],
"name": "getShares",
"outputs": [
{
"name": "_shares",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"name": "tokenAmount",
"type": "uint256"
}
],
"name": "initializeExchange",
"outputs": [],
"payable": true,
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [
{
"name": "_tokenAddress",
"type": "address"
}
],
"payable": false,
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"payable": true,
"stateMutability": "payable",
"type": "fallback"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"name": "buyer",
"type": "address"
},
{
"indexed": false,
"name": "tokensPurchased",
"type": "uint256"
},
{
"indexed": false,
"name": "ethSpent",
"type": "uint256"
}
],
"name": "TokenPurchase",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"name": "buyer",
"type": "address"
},
{
"indexed": false,
"name": "ethPurchased",
"type": "uint256"
},
{
"indexed": false,
"name": "tokensSpent",
"type": "uint256"
}
],
"name": "EthPurchase",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"name": "liquidityProvider",
"type": "address"
},
{
"indexed": true,
"name": "sharesPurchased",
"type": "uint256"
}
],
"name": "Investment",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"name": "liquidityProvider",
"type": "address"
},
{
"indexed": true,
"name": "sharesBurned",
"type": "uint256"
}
],
"name": "Divestment",
"type": "event"
}
]
module.exports.tokenABI =
[
{
"constant": true,
"inputs": [],
"name": "name",
"outputs": [
{
"name": "",
"type": "string"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"name": "spender",
"type": "address"
},
{
"name": "value",
"type": "uint256"
}
],
"name": "approve",
"outputs": [
{
"name": "",
"type": "bool"
}
],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "totalSupply",
"outputs": [
{
"name": "",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"name": "from",
"type": "address"
},
{
"name": "to",
"type": "address"
},
{
"name": "value",
"type": "uint256"
}
],
"name": "transferFrom",
"outputs": [
{
"name": "",
"type": "bool"
}
],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "decimals",
"outputs": [
{
"name": "",
"type": "uint8"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"name": "who",
"type": "address"
}
],
"name": "balanceOf",
"outputs": [
{
"name": "",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "symbol",
"outputs": [
{
"name": "",
"type": "string"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"name": "to",
"type": "address"
},
{
"name": "value",
"type": "uint256"
}
],
"name": "transfer",
"outputs": [
{
"name": "",
"type": "bool"
}
],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"name": "owner",
"type": "address"
},
{
"name": "spender",
"type": "address"
}
],
"name": "allowance",
"outputs": [
{
"name": "",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"name": "owner",
"type": "address"
},
{
"indexed": true,
"name": "spender",
"type": "address"
},
{
"indexed": false,
"name": "value",
"type": "uint256"
}
],
"name": "Approval",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"name": "from",
"type": "address"
},
{
"indexed": true,
"name": "to",
"type": "address"
},
{
"indexed": false,
"name": "value",
"type": "uint256"
}
],
"name": "Transfer",
"type": "event"
}
]
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