Sponsored:   [Largest VC Funded] TEMCO, millions sold out in seconds. Join TEMCO's last presale at CoinBene!
Contract Overview
Balance: 0.188777481865259371 Ether
Ether Value: $16.57 (@ $87.76/ETH)
Transactions: 26830 txns
Misc:
Address Watch: Add To Watch List
Contract Creator: 0x081b834147d44b0740b668942cd28ae2963f3b1dat txn 0x7e1759f9d76d1c56bab1442c29a2a43aca55ef27e29bea8b2dfc627f4b1237f6
Token Balance:
 Latest 25 transactions from a total of 26830 transactions
(+3 PendingTxns)

TxHash Age From To Value [TxFee]
0x348ceb0adb45351949e99088cfa2dd21d2aad4e581614f50f6d6097084864ec4(pending)0xb9a8ec567a53e27e09fabcffaf51b0300fc19238  IN  0xe17dbb844ba602e189889d941d1297184ce636640.04016 Ether(Pending)
0x0beaefc737eaf79eb6d0c7af71e0b71d9dfc75032ff42f9396c7f8687e37b72c(pending)0xfe1e68fd7a4d926061c3c073329953fc6eba0ed9  IN  0xe17dbb844ba602e189889d941d1297184ce636640.0018072 Ether(Pending)
0x85ca559d2498206f9dd77bd160f501836b27d71f578a763b82df60c67ded6c35(pending)0x3dff16dcb6fd9d871eab012513d73b095569b606  IN  0xe17dbb844ba602e189889d941d1297184ce636640.01657604 Ether(Pending)
0xdc7c4a7f7655c6545340538312b4adefc267fb3d9ee2cf842c0f9c904d185db225 mins ago0xd8925eed5440863f75ae7284c34585470a51dff4  IN   0xe17dbb844ba602e189889d941d1297184ce636640.0001104404016 Ether0.0003917568
0x53b07c85649fcba342d06a91ce5c1b4766edcfe0b1af38ea8b71453db812380246 mins ago0x508f51ba9e8163daad752cf5fbd939b9ac6e8512  IN   0xe17dbb844ba602e189889d941d1297184ce636640.19076 Ether0.00324444
0x8c9e55d2b04007a3e5200b4e622bdeec7dc609993a3699c369e9ef290caa7a441 hr 2 mins ago0x14013a4c2cda04b5f1b7f1fff9ee9d0d01b423f5  IN   0xe17dbb844ba602e189889d941d1297184ce636640.02048159915 Ether0.0000799416
0x6046b6ce7e416d9d4c8621b92718056423b9e32165fb8924deaa05ff9f06201f1 hr 9 mins ago0x4b59d5325a5b7d86eb81859c6cdbe8ea07c71df7  IN   0xe17dbb844ba602e189889d941d1297184ce636640.001104404016 Ether0.00074148
0x58e89f79b808e34ceaa8ba07b3a3b0c3dd83d4f953dd40e5e2e95ccd553e5dba1 hr 29 mins ago0x98975f3ef5f42f29ed8d604989cb6f9eb1fb1d5b  IN   0xe17dbb844ba602e189889d941d1297184ce636640.058232 Ether0.00082516
0x34ad186c4d0ca24bbcb8caaf7d845a00936617565a65eb08113fcad048b60d211 hr 34 mins ago0xb9a8ec567a53e27e09fabcffaf51b0300fc19238  IN   0xe17dbb844ba602e189889d941d1297184ce636640.04518 Ether0.00329936
0xb72aff59e07a79ef38891073a37d8858756707e2a8f46f671d5430c4d5e96e881 hr 34 mins ago0xb9a8ec567a53e27e09fabcffaf51b0300fc19238  IN   0xe17dbb844ba602e189889d941d1297184ce636640.0069276 Ether0.00360192
0x6f730ffb39a75370e298b71fe14c5536ec917301ee798df8f2f76070e8eb4c7f1 hr 38 mins ago0xee6a9ed20d8bf55c71730a981e4d2aa30fbf03d1  IN   0xe17dbb844ba602e189889d941d1297184ce636640 Ether0.00072078
0xae538a0909d58bfab28a8109945f767f3d9b3636778518323015a113c680e5941 hr 38 mins ago0xee6a9ed20d8bf55c71730a981e4d2aa30fbf03d1  IN   0xe17dbb844ba602e189889d941d1297184ce636640 Ether0.00072078
0x47a8a6d5ed1fb8af3bb9c967e768a9043611287a6a70d79916d12b89269e7ef11 hr 38 mins ago0xee6a9ed20d8bf55c71730a981e4d2aa30fbf03d1  IN   0xe17dbb844ba602e189889d941d1297184ce636640 Ether0.00072078
0xb9258a6c93413e1ff4b89ec3231bc25b517172968c26da8d569f289600091a7a1 hr 44 mins ago0xee6a9ed20d8bf55c71730a981e4d2aa30fbf03d1  IN   0xe17dbb844ba602e189889d941d1297184ce636640 Ether0.00072078
0xa10a320f91e5121cfda3d62199fb4ba756d764c0b5c01bcaced024958815a9881 hr 44 mins ago0xee6a9ed20d8bf55c71730a981e4d2aa30fbf03d1  IN   0xe17dbb844ba602e189889d941d1297184ce636640 Ether0.00072078
0x4b6daaef45e668b48ba5241491a63c38f762f91dd5aedab251d6b42f657a7dfa1 hr 44 mins ago0xee6a9ed20d8bf55c71730a981e4d2aa30fbf03d1  IN   0xe17dbb844ba602e189889d941d1297184ce636640 Ether0.00072078
0x49e8ba044ecf1972271169e1b9f4dabaf48c1bdfa48b4e3519493995b4a190c21 hr 44 mins ago0xee6a9ed20d8bf55c71730a981e4d2aa30fbf03d1  IN   0xe17dbb844ba602e189889d941d1297184ce636640 Ether0.00072078
0xe16858a1e4828d294df4647e07cde53afd751b6cb0fbe03cb2b6d4808eaf8a441 hr 44 mins ago0xee6a9ed20d8bf55c71730a981e4d2aa30fbf03d1  IN   0xe17dbb844ba602e189889d941d1297184ce636640 Ether0.00072078
0x54b61c59acf2a91eb98316e2b1f4bd940d333eaad0595f0b37dcb4f4931855fa1 hr 44 mins ago0xee6a9ed20d8bf55c71730a981e4d2aa30fbf03d1  IN   0xe17dbb844ba602e189889d941d1297184ce636640 Ether0.00072078
0xcbcf1b09fd1b3ad94d255f27a1a0ba0a6860858557eaf295720fde5b4152d7f41 hr 44 mins ago0xee6a9ed20d8bf55c71730a981e4d2aa30fbf03d1  IN   0xe17dbb844ba602e189889d941d1297184ce636640 Ether0.00384938
0x9475e3c1a3551ae2afe1717dbd2c34e44aeae45bb7b542763ff4182b2b53304a1 hr 45 mins ago0xb9ae9b5b931fb904fd7fa3777089aeab67fa06eb  IN   0xe17dbb844ba602e189889d941d1297184ce636640 Ether0.0004817583
0x00070710e1fb1f1f4998d0c2cf0e9aea598dc74e33874856b525b95f17b2eeda1 hr 56 mins ago0x6f92ef9c248ebde6df47781436aec60f1e73144c  IN   0xe17dbb844ba602e189889d941d1297184ce636640.0009538 Ether0.0003533328
0x10d70f7db0ada9f49fb93194ea6eba1da332caf14365363e711cb4109f3b07b32 hrs 6 mins ago0xb9a8ec567a53e27e09fabcffaf51b0300fc19238  IN   0xe17dbb844ba602e189889d941d1297184ce636640.04813176 Ether0.00330064
0x5c36eb482257f1755ace6d40cfedbec53f0fbecd436e55d67826cd6a9434ab972 hrs 6 mins ago0xb9a8ec567a53e27e09fabcffaf51b0300fc19238  IN   0xe17dbb844ba602e189889d941d1297184ce636640.04016 Ether0.00329552
0x7587c792f300052f2d1590f7bb06b8f635a18185d3b1fcb603985d14c7056ad82 hrs 6 mins ago0xb9a8ec567a53e27e09fabcffaf51b0300fc19238  IN   0xe17dbb844ba602e189889d941d1297184ce636640.0437744 Ether0.00330064
[ Download CSV Export  ] 
 Internal Transactions as a result of Contract Execution
 Latest 25 Internal Txns, Click here To View More View All
ParentTxHash Block Age From To Value
0xdc7c4a7f7655c6545340538312b4adefc267fb3d9ee2cf842c0f9c904d185db2689509825 mins ago0xe17dbb844ba602e189889d941d1297184ce636640x1ce7ae555139c5ef5a57cc8d814a867ee6ee33d80.0001104404016 Ether
0x53b07c85649fcba342d06a91ce5c1b4766edcfe0b1af38ea8b71453db8123802689501646 mins ago0xe17dbb844ba602e189889d941d1297184ce636640x1ce7ae555139c5ef5a57cc8d814a867ee6ee33d80.19076 Ether
0x6046b6ce7e416d9d4c8621b92718056423b9e32165fb8924deaa05ff9f06201f68949181 hr 9 mins ago0xe17dbb844ba602e189889d941d1297184ce636640x1ce7ae555139c5ef5a57cc8d814a867ee6ee33d80.001104404016 Ether
0x58e89f79b808e34ceaa8ba07b3a3b0c3dd83d4f953dd40e5e2e95ccd553e5dba68948371 hr 29 mins ago0xe17dbb844ba602e189889d941d1297184ce636640x1ce7ae555139c5ef5a57cc8d814a867ee6ee33d80.058232 Ether
0x34ad186c4d0ca24bbcb8caaf7d845a00936617565a65eb08113fcad048b60d2168948151 hr 34 mins ago0xe17dbb844ba602e189889d941d1297184ce636640x1ce7ae555139c5ef5a57cc8d814a867ee6ee33d80.04518 Ether
0xb72aff59e07a79ef38891073a37d8858756707e2a8f46f671d5430c4d5e96e8868948151 hr 34 mins ago0xe17dbb844ba602e189889d941d1297184ce636640x1ce7ae555139c5ef5a57cc8d814a867ee6ee33d80.0069276 Ether
0xcbcf1b09fd1b3ad94d255f27a1a0ba0a6860858557eaf295720fde5b4152d7f468947711 hr 44 mins ago0xe17dbb844ba602e189889d941d1297184ce636640xee6a9ed20d8bf55c71730a981e4d2aa30fbf03d10.01095603983981287 Ether
0xcbcf1b09fd1b3ad94d255f27a1a0ba0a6860858557eaf295720fde5b4152d7f468947711 hr 44 mins ago0x1ce7ae555139c5ef5a57cc8d814a867ee6ee33d80xe17dbb844ba602e189889d941d1297184ce636640.01095603983981287 Ether
0x9475e3c1a3551ae2afe1717dbd2c34e44aeae45bb7b542763ff4182b2b53304a68947671 hr 45 mins ago0xe17dbb844ba602e189889d941d1297184ce636640xb9ae9b5b931fb904fd7fa3777089aeab67fa06eb0.007949691190822564 Ether
0x9475e3c1a3551ae2afe1717dbd2c34e44aeae45bb7b542763ff4182b2b53304a68947671 hr 45 mins ago0x1ce7ae555139c5ef5a57cc8d814a867ee6ee33d80xe17dbb844ba602e189889d941d1297184ce636640.008082181190822564 Ether
0x00070710e1fb1f1f4998d0c2cf0e9aea598dc74e33874856b525b95f17b2eeda68947271 hr 56 mins ago0xe17dbb844ba602e189889d941d1297184ce636640x1ce7ae555139c5ef5a57cc8d814a867ee6ee33d80.0009538 Ether
0x10d70f7db0ada9f49fb93194ea6eba1da332caf14365363e711cb4109f3b07b368946802 hrs 6 mins ago0xe17dbb844ba602e189889d941d1297184ce636640x1ce7ae555139c5ef5a57cc8d814a867ee6ee33d80.04813176 Ether
0x5c36eb482257f1755ace6d40cfedbec53f0fbecd436e55d67826cd6a9434ab9768946802 hrs 6 mins ago0xe17dbb844ba602e189889d941d1297184ce636640x1ce7ae555139c5ef5a57cc8d814a867ee6ee33d80.04016 Ether
0x7587c792f300052f2d1590f7bb06b8f635a18185d3b1fcb603985d14c7056ad868946802 hrs 6 mins ago0xe17dbb844ba602e189889d941d1297184ce636640x1ce7ae555139c5ef5a57cc8d814a867ee6ee33d80.0437744 Ether
0x55332d97ba56fa76d693d5b63279ec9c8761b04311e08b482e1e9604bafd7c8a68946522 hrs 12 mins ago0xe17dbb844ba602e189889d941d1297184ce636640x14013a4c2cda04b5f1b7f1fff9ee9d0d01b423f50.05 Ether
0x55332d97ba56fa76d693d5b63279ec9c8761b04311e08b482e1e9604bafd7c8a68946522 hrs 12 mins ago0x1ce7ae555139c5ef5a57cc8d814a867ee6ee33d80xe17dbb844ba602e189889d941d1297184ce636640.05 Ether
0xc0520fdeb23e150d0956220b5aab476e23284ae062863be15f527c9ae3c0200068946472 hrs 14 mins ago0xe17dbb844ba602e189889d941d1297184ce636640x14013a4c2cda04b5f1b7f1fff9ee9d0d01b423f50.0405442671796 Ether
0xc0520fdeb23e150d0956220b5aab476e23284ae062863be15f527c9ae3c0200068946472 hrs 14 mins ago0x1ce7ae555139c5ef5a57cc8d814a867ee6ee33d80xe17dbb844ba602e189889d941d1297184ce636640.0406435791096 Ether
0xc953b71775cf54df33bd6780438d99fbb4316ef2c1e95bc53eb2c2a2b7f37e6a68946372 hrs 16 mins ago0xe17dbb844ba602e189889d941d1297184ce636640x1ce7ae555139c5ef5a57cc8d814a867ee6ee33d80.0048090596 Ether
0x0a10554b5a311cf1d403321f1bc772469a9f6e1f67c8cd44f9a51914aee2a05768946072 hrs 24 mins ago0xe17dbb844ba602e189889d941d1297184ce636640x1ce7ae555139c5ef5a57cc8d814a867ee6ee33d80.0196784 Ether
0x3e627127c6cebe668c5cd56d93b427468b005f763d14f34a21d495baa795edf768945572 hrs 36 mins ago0xe17dbb844ba602e189889d941d1297184ce636640x1ce7ae555139c5ef5a57cc8d814a867ee6ee33d80.0004518 Ether
0x7b2384fad85445c12a6f02b8adcf5da0563b680201881ba87de4b53f97def50868945062 hrs 48 mins ago0xe17dbb844ba602e189889d941d1297184ce636640x1ce7ae555139c5ef5a57cc8d814a867ee6ee33d80.0317264 Ether
0x8d3e40681afc4cd630b7d30ce55c72b99aac123d75e7430c3acc9cf847f7b49e68944133 hrs 9 mins ago0xe17dbb844ba602e189889d941d1297184ce636640x1ce7ae555139c5ef5a57cc8d814a867ee6ee33d80.009538 Ether
0x4f99a7ffba2bfad67d969737815cc83aabf77fb07907c82c7b0d58a1e5a668f468943983 hrs 12 mins ago0xe17dbb844ba602e189889d941d1297184ce636640x1ce7ae555139c5ef5a57cc8d814a867ee6ee33d80.0019076 Ether
0x2404af09f8463c040318ceb45de57fe7e46283e615b9ea030252f9bedd662d2168943533 hrs 22 mins ago0xe17dbb844ba602e189889d941d1297184ce636640x1ce7ae555139c5ef5a57cc8d814a867ee6ee33d80.007028 Ether
[ Download CSV Export  ] 
Warning: The Compiled Contract might be susceptible to ExpExponentCleanup (medium/high-severity), EventStructWrongData (very low-severity) SolidityCompiler Bugs.

Contract Source Code Verified (Exact Match)
Contract Name: InstantTrade
Compiler Text: v0.4.24+commit.e67f0147
Optimization Enabled: No
Runs (Optimiser):  200



  Contract Source Code   Find Similiar Contracts

pragma solidity ^0.4.19;

// ERC20 token protocol, see more details at
// https://theethereum.wiki/w/index.php/ERC20_Token_Standard
// And also https://github.com/ethereum/eips/issues/20

contract Token {

  string public name;
  string public symbol;
  uint8 public decimals;

  function totalSupply() constant returns (uint256 supply);
  function balanceOf(address _owner) constant returns (uint256 balance);
  function transfer(address _to, uint256 _value) returns (bool success);
  function transferFrom(address _from, address _to, uint256 _value) returns (bool success);
  function approve(address _spender, uint256 _value) returns (bool success);
  function allowance(address _owner, address _spender) constant returns (uint256 remaining);

  event Transfer(address indexed _from, address indexed _to, uint256 _value);
  event Approval(address indexed _owner, address indexed _spender, uint256 _value);
}

// Safe mathematics to make the code more readable

contract SafeMath {
  function safeMul(uint a, uint b) internal returns (uint) {
    uint c = a * b;
    assert(a == 0 || c / a == b);
    return c;
  }

  function safeSub(uint a, uint b) internal returns (uint) {
    assert(b <= a);
    return a - b;
  }

  function safeAdd(uint a, uint b) internal returns (uint) {
    uint c = a + b;
    assert(c>=a && c>=b);
    return c;
  }
}

// Ownable interface to simplify owner checks

contract Ownable {
  address public owner;

  function Ownable() {
    owner = msg.sender;
  }

  modifier onlyOwner() {
    require(msg.sender == owner);
    _;
  }

  function transferOwnership(address _newOwner) onlyOwner {
    require(_newOwner != address(0));
    owner = _newOwner;
  }
}

// Interface for trading discounts and rebates for specific accounts

contract AccountModifiersInterface {
  function accountModifiers(address _user) constant returns(uint takeFeeDiscount, uint rebatePercentage);
  function tradeModifiers(address _maker, address _taker) constant returns(uint takeFeeDiscount, uint rebatePercentage);
}

// Interface for trade tacker

contract TradeTrackerInterface {
  function tradeComplete(address _tokenGet, uint _amountGet, address _tokenGive, uint _amountGive, address _get, address _give, uint _takerFee, uint _makerRebate);
}

// Exchange contract

contract TokenStore is SafeMath, Ownable {

  // The account that will receive fees
  address feeAccount;

  // The account that stores fee discounts/rebates
  address accountModifiers;

  // Trade tracker account
  address tradeTracker;

  // We charge only the takers and this is the fee, percentage times 1 ether
  uint public fee;

  // Mapping of token addresses to mapping of account balances (token 0 means Ether)
  mapping (address => mapping (address => uint)) public tokens;

  // Mapping of user accounts to mapping of order hashes to uints (amount of order that has been filled)
  mapping (address => mapping (bytes32 => uint)) public orderFills;

  // Address of a next and previous versions of the contract, also status of the contract
  // can be used for user-triggered fund migrations
  address public successor;
  address public predecessor;
  bool public deprecated;
  uint16 public version;

  // Logging events
  // Note: Order creation is handled off-chain, see explanation further below
  event Cancel(address tokenGet, uint amountGet, address tokenGive, uint amountGive, uint expires, uint nonce, address user, uint8 v, bytes32 r, bytes32 s);
  event Trade(address tokenGet, uint amountGet, address tokenGive, uint amountGive, address get, address give, uint nonce);
  event Deposit(address token, address user, uint amount, uint balance);
  event Withdraw(address token, address user, uint amount, uint balance);
  event FundsMigrated(address user);

  function TokenStore(uint _fee, address _predecessor) {
    feeAccount = owner;
    fee = _fee;
    predecessor = _predecessor;
    deprecated = false;
    if (predecessor != address(0)) {
      version = TokenStore(predecessor).version() + 1;
    } else {
      version = 1;
    }
  }

  // Throw on default handler to prevent direct transactions of Ether
  function() {
    revert();
  }

  modifier deprecable() {
    require(!deprecated);
    _;
  }

  function deprecate(bool _deprecated, address _successor) onlyOwner {
    deprecated = _deprecated;
    successor = _successor;
  }

  function changeFeeAccount(address _feeAccount) onlyOwner {
    require(_feeAccount != address(0));
    feeAccount = _feeAccount;
  }

  function changeAccountModifiers(address _accountModifiers) onlyOwner {
    accountModifiers = _accountModifiers;
  }

  function changeTradeTracker(address _tradeTracker) onlyOwner {
    tradeTracker = _tradeTracker;
  }

  // Fee can only be decreased!
  function changeFee(uint _fee) onlyOwner {
    require(_fee <= fee);
    fee = _fee;
  }

  // Allows a user to get her current discount/rebate
  function getAccountModifiers() constant returns(uint takeFeeDiscount, uint rebatePercentage) {
    if (accountModifiers != address(0)) {
      return AccountModifiersInterface(accountModifiers).accountModifiers(msg.sender);
    } else {
      return (0, 0);
    }
  }

  ////////////////////////////////////////////////////////////////////////////////
  // Deposits, withdrawals, balances
  ////////////////////////////////////////////////////////////////////////////////

  function deposit() payable deprecable {
    tokens[0][msg.sender] = safeAdd(tokens[0][msg.sender], msg.value);
    Deposit(0, msg.sender, msg.value, tokens[0][msg.sender]);
  }

  function withdraw(uint _amount) {
    require(tokens[0][msg.sender] >= _amount);
    tokens[0][msg.sender] = safeSub(tokens[0][msg.sender], _amount);
    if (!msg.sender.call.value(_amount)()) {
      revert();
    }
    Withdraw(0, msg.sender, _amount, tokens[0][msg.sender]);
  }

  function depositToken(address _token, uint _amount) deprecable {
    // Note that Token(_token).approve(this, _amount) needs to be called
    // first or this contract will not be able to do the transfer.
    require(_token != 0);
    if (!Token(_token).transferFrom(msg.sender, this, _amount)) {
      revert();
    }
    tokens[_token][msg.sender] = safeAdd(tokens[_token][msg.sender], _amount);
    Deposit(_token, msg.sender, _amount, tokens[_token][msg.sender]);
  }

  function withdrawToken(address _token, uint _amount) {
    require(_token != 0);
    require(tokens[_token][msg.sender] >= _amount);
    tokens[_token][msg.sender] = safeSub(tokens[_token][msg.sender], _amount);
    if (!Token(_token).transfer(msg.sender, _amount)) {
      revert();
    }
    Withdraw(_token, msg.sender, _amount, tokens[_token][msg.sender]);
  }

  function balanceOf(address _token, address _user) constant returns (uint) {
    return tokens[_token][_user];
  }

  ////////////////////////////////////////////////////////////////////////////////
  // Trading
  ////////////////////////////////////////////////////////////////////////////////

  // Note: Order creation happens off-chain but the orders are signed by creators,
  // we validate the contents and the creator address in the logic below

  function trade(address _tokenGet, uint _amountGet, address _tokenGive, uint _amountGive,
      uint _expires, uint _nonce, address _user, uint8 _v, bytes32 _r, bytes32 _s, uint _amount) {
    bytes32 hash = sha256(this, _tokenGet, _amountGet, _tokenGive, _amountGive, _expires, _nonce);
    // Check order signatures and expiration, also check if not fulfilled yet
		if (ecrecover(sha3("\x19Ethereum Signed Message:\n32", hash), _v, _r, _s) != _user ||
      block.number > _expires ||
      safeAdd(orderFills[_user][hash], _amount) > _amountGet) {
      revert();
    }
    tradeBalances(_tokenGet, _amountGet, _tokenGive, _amountGive, _user, msg.sender, _amount);
    orderFills[_user][hash] = safeAdd(orderFills[_user][hash], _amount);
    Trade(_tokenGet, _amount, _tokenGive, _amountGive * _amount / _amountGet, _user, msg.sender, _nonce);
  }

  function tradeBalances(address _tokenGet, uint _amountGet, address _tokenGive, uint _amountGive,
      address _user, address _caller, uint _amount) private {

    uint feeTakeValue = safeMul(_amount, fee) / (1 ether);
    uint rebateValue = 0;
    uint tokenGiveValue = safeMul(_amountGive, _amount) / _amountGet; // Proportionate to request ratio

    // Apply modifiers
    if (accountModifiers != address(0)) {
      var (feeTakeDiscount, rebatePercentage) = AccountModifiersInterface(accountModifiers).tradeModifiers(_user, _caller);
      // Check that the discounts/rebates are never higher then 100%
      if (feeTakeDiscount > 100) {
        feeTakeDiscount = 0;
      }
      if (rebatePercentage > 100) {
        rebatePercentage = 0;
      }
      feeTakeValue = safeMul(feeTakeValue, 100 - feeTakeDiscount) / 100;  // discounted fee
      rebateValue = safeMul(rebatePercentage, feeTakeValue) / 100;        // % of actual taker fee
    }

    tokens[_tokenGet][_user] = safeAdd(tokens[_tokenGet][_user], safeAdd(_amount, rebateValue));
    tokens[_tokenGet][_caller] = safeSub(tokens[_tokenGet][_caller], safeAdd(_amount, feeTakeValue));
    tokens[_tokenGive][_user] = safeSub(tokens[_tokenGive][_user], tokenGiveValue);
    tokens[_tokenGive][_caller] = safeAdd(tokens[_tokenGive][_caller], tokenGiveValue);
    tokens[_tokenGet][feeAccount] = safeAdd(tokens[_tokenGet][feeAccount], safeSub(feeTakeValue, rebateValue));

    if (tradeTracker != address(0)) {
      TradeTrackerInterface(tradeTracker).tradeComplete(_tokenGet, _amount, _tokenGive, tokenGiveValue, _user, _caller, feeTakeValue, rebateValue);
    }
  }

  function testTrade(address _tokenGet, uint _amountGet, address _tokenGive, uint _amountGive, uint _expires,
      uint _nonce, address _user, uint8 _v, bytes32 _r, bytes32 _s, uint _amount, address _sender) constant returns(bool) {
    if (tokens[_tokenGet][_sender] < _amount ||
      availableVolume(_tokenGet, _amountGet, _tokenGive, _amountGive, _expires, _nonce, _user, _v, _r, _s) < _amount) {
      return false;
    }
    return true;
  }

  function availableVolume(address _tokenGet, uint _amountGet, address _tokenGive, uint _amountGive, uint _expires,
      uint _nonce, address _user, uint8 _v, bytes32 _r, bytes32 _s) constant returns(uint) {
    bytes32 hash = sha256(this, _tokenGet, _amountGet, _tokenGive, _amountGive, _expires, _nonce);
    if (ecrecover(sha3("\x19Ethereum Signed Message:\n32", hash), _v, _r, _s) != _user ||
      block.number > _expires) {
      return 0;
    }
    uint available1 = safeSub(_amountGet, orderFills[_user][hash]);
    uint available2 = safeMul(tokens[_tokenGive][_user], _amountGet) / _amountGive;
    if (available1 < available2) return available1;
    return available2;
  }

  function amountFilled(address _tokenGet, uint _amountGet, address _tokenGive, uint _amountGive, uint _expires,
      uint _nonce, address _user) constant returns(uint) {
    bytes32 hash = sha256(this, _tokenGet, _amountGet, _tokenGive, _amountGive, _expires, _nonce);
    return orderFills[_user][hash];
  }

  function cancelOrder(address _tokenGet, uint _amountGet, address _tokenGive, uint _amountGive, uint _expires,
      uint _nonce, uint8 _v, bytes32 _r, bytes32 _s) {
    bytes32 hash = sha256(this, _tokenGet, _amountGet, _tokenGive, _amountGive, _expires, _nonce);
    if (!(ecrecover(sha3("\x19Ethereum Signed Message:\n32", hash), _v, _r, _s) == msg.sender)) {
      revert();
    }
    orderFills[msg.sender][hash] = _amountGet;
    Cancel(_tokenGet, _amountGet, _tokenGive, _amountGive, _expires, _nonce, msg.sender, _v, _r, _s);
  }

  ////////////////////////////////////////////////////////////////////////////////
  // Migrations
  ////////////////////////////////////////////////////////////////////////////////

  // User-triggered (!) fund migrations in case contract got updated
  // Similar to withdraw but we use a successor account instead
  // As we don't store user tokens list on chain, it has to be passed from the outside
  function migrateFunds(address[] _tokens) {

    // Get the latest successor in the chain
    require(successor != address(0));
    TokenStore newExchange = TokenStore(successor);
    for (uint16 n = 0; n < 20; n++) {  // We will look past 20 contracts in the future
      address nextSuccessor = newExchange.successor();
      if (nextSuccessor == address(this)) {  // Circular succession
        revert();
      }
      if (nextSuccessor == address(0)) { // We reached the newest, stop
        break;
      }
      newExchange = TokenStore(nextSuccessor);
    }

    // Ether
    uint etherAmount = tokens[0][msg.sender];
    if (etherAmount > 0) {
      tokens[0][msg.sender] = 0;
      newExchange.depositForUser.value(etherAmount)(msg.sender);
    }

    // Tokens
    for (n = 0; n < _tokens.length; n++) {
      address token = _tokens[n];
      require(token != address(0)); // 0 = Ether, we handle it above
      uint tokenAmount = tokens[token][msg.sender];
      if (tokenAmount == 0) {
        continue;
      }
      if (!Token(token).approve(newExchange, tokenAmount)) {
        revert();
      }
      tokens[token][msg.sender] = 0;
      newExchange.depositTokenForUser(token, tokenAmount, msg.sender);
    }

    FundsMigrated(msg.sender);
  }

  // This is used for migrations only. To be called by previous exchange only,
  // user-triggered, on behalf of the user called the migrateFunds method.
  // Note that it does exactly the same as depositToken, but as this is called
  // by a previous generation of exchange itself, we credit internally not the
  // previous exchange, but the user it was called for.
  function depositForUser(address _user) payable deprecable {
    require(_user != address(0));
    require(msg.value > 0);
    TokenStore caller = TokenStore(msg.sender);
    require(caller.version() > 0); // Make sure it's an exchange account
    tokens[0][_user] = safeAdd(tokens[0][_user], msg.value);
  }

  function depositTokenForUser(address _token, uint _amount, address _user) deprecable {
    require(_token != address(0));
    require(_user != address(0));
    require(_amount > 0);
    TokenStore caller = TokenStore(msg.sender);
    require(caller.version() > 0); // Make sure it's an exchange account
    if (!Token(_token).transferFrom(msg.sender, this, _amount)) {
      revert();
    }
    tokens[_token][_user] = safeAdd(tokens[_token][_user], _amount);
  }
}

contract InstantTrade is SafeMath, Ownable {

  // This is needed so we can withdraw funds from other smart contracts
  function() payable {
  }
  
  // End to end trading in a single call
  function instantTrade(address _tokenGet, uint _amountGet, address _tokenGive, uint _amountGive,
      uint _expires, uint _nonce, address _user, uint8 _v, bytes32 _r, bytes32 _s, uint _amount, address _store) payable {
    
    // Fix max fee (0.4%) and always reserve it
    uint totalValue = safeMul(_amount, 1004) / 1000;
    
    // Paying with Ethereum or token? Deposit to the actual store
    if (_tokenGet == address(0)) {
      // Check amount of ether sent to make sure it's correct
      if (msg.value != totalValue) {
        revert();
      }
      TokenStore(_store).deposit.value(totalValue)();
    } else {
      // Assuming user already approved transfer, transfer first to this contract
      if (!Token(_tokenGet).transferFrom(msg.sender, this, totalValue)) {
        revert();
      }
      // Allow now actual store to deposit
      if (!Token(_tokenGet).approve(_store, totalValue)) {
        revert();
      }
      TokenStore(_store).depositToken(_tokenGet, totalValue);
    }
    
    // Trade
    TokenStore(_store).trade(_tokenGet, _amountGet, _tokenGive, _amountGive,
      _expires, _nonce, _user, _v, _r, _s, _amount);
    
    // Check how much did we get and how much should we send back
    totalValue = TokenStore(_store).balanceOf(_tokenGive, this);
    uint customerValue = safeMul(_amountGive, _amount) / _amountGet;
    
    // Now withdraw all the funds into this contract and then pass to the user
    if (_tokenGive == address(0)) {
      TokenStore(_store).withdraw(totalValue);
      msg.sender.transfer(customerValue);
    } else {
      TokenStore(_store).withdrawToken(_tokenGive, totalValue);
      if (!Token(_tokenGive).transfer(msg.sender, customerValue)) {
        revert();
      }
    }
  }
  
  function withdrawFees(address _token) onlyOwner {
    if (_token == address(0)) {
      msg.sender.transfer(this.balance);
    } else {
      uint amount = Token(_token).balanceOf(this);
      if (!Token(_token).transfer(msg.sender, amount)) {
        revert();
      }
    }
  }  
}

    Contract ABI  
[{"constant":false,"inputs":[{"name":"_tokenGet","type":"address"},{"name":"_amountGet","type":"uint256"},{"name":"_tokenGive","type":"address"},{"name":"_amountGive","type":"uint256"},{"name":"_expires","type":"uint256"},{"name":"_nonce","type":"uint256"},{"name":"_user","type":"address"},{"name":"_v","type":"uint8"},{"name":"_r","type":"bytes32"},{"name":"_s","type":"bytes32"},{"name":"_amount","type":"uint256"},{"name":"_store","type":"address"}],"name":"instantTrade","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":false,"inputs":[{"name":"_token","type":"address"}],"name":"withdrawFees","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"payable":true,"stateMutability":"payable","type":"fallback"}]

  Contract Creation Code Switch To Opcodes View
6080604052336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550610f41806100536000396000f300608060405260043610610062576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806308e05b8514610064578063164e68de146101555780638da5cb5b14610198578063f2fde38b146101ef575b005b610153600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291908035906020019092919080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803560ff1690602001909291908035600019169060200190929190803560001916906020019092919080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610232565b005b34801561016157600080fd5b50610196600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610b28565b005b3480156101a457600080fd5b506101ad610de3565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156101fb57600080fd5b50610230600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610e08565b005b6000806103e8610244856103ec610ee2565b81151561024d57fe5b049150600073ffffffffffffffffffffffffffffffffffffffff168e73ffffffffffffffffffffffffffffffffffffffff16141561031557813414151561029357600080fd5b8273ffffffffffffffffffffffffffffffffffffffff1663d0e30db0836040518263ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004016000604051808303818588803b1580156102f757600080fd5b505af115801561030b573d6000803e3d6000fd5b50505050506105d7565b8d73ffffffffffffffffffffffffffffffffffffffff166323b872dd3330856040518463ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050602060405180830381600087803b1580156103ec57600080fd5b505af1158015610400573d6000803e3d6000fd5b505050506040513d602081101561041657600080fd5b8101908080519060200190929190505050151561043257600080fd5b8d73ffffffffffffffffffffffffffffffffffffffff1663095ea7b384846040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b1580156104d557600080fd5b505af11580156104e9573d6000803e3d6000fd5b505050506040513d60208110156104ff57600080fd5b8101908080519060200190929190505050151561051b57600080fd5b8273ffffffffffffffffffffffffffffffffffffffff1663338b5dea8f846040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050600060405180830381600087803b1580156105be57600080fd5b505af11580156105d2573d6000803e3d6000fd5b505050505b8273ffffffffffffffffffffffffffffffffffffffff16630a19b14a8f8f8f8f8f8f8f8f8f8f8f6040518c63ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018b81526020018a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018981526020018881526020018781526020018673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018560ff1660ff168152602001846000191660001916815260200183600019166000191681526020018281526020019b505050505050505050505050600060405180830381600087803b15801561073057600080fd5b505af1158015610744573d6000803e3d6000fd5b505050508273ffffffffffffffffffffffffffffffffffffffff1663f7888aec8d306040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200192505050602060405180830381600087803b15801561081757600080fd5b505af115801561082b573d6000803e3d6000fd5b505050506040513d602081101561084157600080fd5b810190808051906020019092919050505091508c61085f8c86610ee2565b81151561086857fe5b049050600073ffffffffffffffffffffffffffffffffffffffff168c73ffffffffffffffffffffffffffffffffffffffff161415610973578273ffffffffffffffffffffffffffffffffffffffff16632e1a7d4d836040518263ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180828152602001915050600060405180830381600087803b15801561090f57600080fd5b505af1158015610923573d6000803e3d6000fd5b505050503373ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f1935050505015801561096d573d6000803e3d6000fd5b50610b18565b8273ffffffffffffffffffffffffffffffffffffffff16639e281a988d846040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050600060405180830381600087803b158015610a1657600080fd5b505af1158015610a2a573d6000803e3d6000fd5b505050508b73ffffffffffffffffffffffffffffffffffffffff1663a9059cbb33836040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b158015610ad157600080fd5b505af1158015610ae5573d6000803e3d6000fd5b505050506040513d6020811015610afb57600080fd5b81019080805190602001909291905050501515610b1757600080fd5b5b5050505050505050505050505050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610b8557600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610c1d573373ffffffffffffffffffffffffffffffffffffffff166108fc3073ffffffffffffffffffffffffffffffffffffffff16319081150290604051600060405180830381858888f19350505050158015610c17573d6000803e3d6000fd5b50610ddf565b8173ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b158015610cb857600080fd5b505af1158015610ccc573d6000803e3d6000fd5b505050506040513d6020811015610ce257600080fd5b810190808051906020019092919050505090508173ffffffffffffffffffffffffffffffffffffffff1663a9059cbb33836040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b158015610d9857600080fd5b505af1158015610dac573d6000803e3d6000fd5b505050506040513d6020811015610dc257600080fd5b81019080805190602001909291905050501515610dde57600080fd5b5b5050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610e6357600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614151515610e9f57600080fd5b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60008082840290506000841480610f035750828482811515610f0057fe5b04145b1515610f0b57fe5b80915050929150505600a165627a7a7230582081a354272428a9b8d3f961d3793825f26e08c07debe709d8815e1c110f5698c20029

   Swarm Source:
bzzr://81a354272428a9b8d3f961d3793825f26e08c07debe709d8815e1c110f5698c2

 

View All
Block Age transaction Difficulty GasUsed Reward
View All
Block Age UncleNumber Difficulty GasUsed Reward
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.