Skip to content

Commit

Permalink
Merge pull request #10 from Augmint/exchange-cleanup
Browse files Browse the repository at this point in the history
Exchange cleanup
  • Loading branch information
Peter Petrovics authored Feb 14, 2018
2 parents 5487395 + 4bc2f20 commit fc44d95
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
14 changes: 7 additions & 7 deletions contracts/Exchange.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@
- uint32 for addedTime?
*/
pragma solidity 0.4.19;

import "./generic/SafeMath.sol";
import "./generic/Restricted.sol";
import "./interfaces/AugmintTokenInterface.sol";


contract Exchange is Restricted {
contract Exchange {
using SafeMath for uint256;
AugmintTokenInterface public augmintToken;

Expand All @@ -24,11 +23,11 @@ contract Exchange is Restricted {
address maker;
uint addedTime;

// tokens per ether (4 decimals)
// tokens per ether
uint price;

// buy order: amount in wei
// sell order: token amount (4 decimals)
// sell order: token amount
uint amount;
}

Expand All @@ -40,7 +39,7 @@ contract Exchange is Restricted {

/* used to stop executing matchMultiple when running out of gas.
actual is much less, just leaving enough matchMultipleOrders() to finish TODO: fine tune & test it*/
uint32 public constant ORDER_MATCH_WORST_GAS = 200000;
uint32 private constant ORDER_MATCH_WORST_GAS = 100000;

event NewOrder(uint indexed orderId, address indexed maker, uint price, uint tokenAmount,
uint weiAmount);
Expand Down Expand Up @@ -77,6 +76,7 @@ contract Exchange is Restricted {
uint amount = order.amount;
order.amount = 0;
_removeBuyOrder(order);

msg.sender.transfer(amount);

CancelledOrder(buyTokenId, msg.sender, 0, amount);
Expand Down Expand Up @@ -180,8 +180,8 @@ contract Exchange is Restricted {
_removeSellOrder(sell);
}

sell.maker.transfer(tradedWei);
augmintToken.transferWithNarrative(buy.maker, tradedTokens, "Buy token order fill");
sell.maker.transfer(tradedWei);

OrderFill(buy.maker, sell.maker, buyTokenId,
sellTokenId, price, tradedWei, tradedTokens);
Expand Down
1 change: 0 additions & 1 deletion migrations/11_deploy_Exchange.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ module.exports = function(deployer, network, accounts) {
deployer.deploy(Exchange, TokenAEur.address);
deployer.then(async () => {
const exchange = Exchange.at(Exchange.address);
await exchange.grantMultiplePermissions(accounts[0], ["MonetaryBoard"]);

const tokenAEur = TokenAEur.at(TokenAEur.address);
await tokenAEur.grantMultiplePermissions(Exchange.address, ["NoFeeTransferContracts"]);
Expand Down
1 change: 0 additions & 1 deletion test/helpers/exchangeTestHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ let exchange, tokenAce;
async function newExchangeMock(_tokenAce) {
tokenAce = _tokenAce;
exchange = await Exchange.new(tokenAce.address);
await exchange.grantMultiplePermissions(web3.eth.accounts[0], ["MonetaryBoard"]);
await tokenAce.grantMultiplePermissions(exchange.address, ["NoFeeTransferContracts"]);
return exchange;
}
Expand Down

0 comments on commit fc44d95

Please sign in to comment.