I'm exploring method trade of this smart contract that looks like the following:

  function trade(address tokenGet, uint amountGet, address tokenGive, uint amountGive, uint expires, uint nonce, address user, uint8 v, bytes32 r, bytes32 s, uint amount) {
      //amount is in amountGet terms
      bytes32 hash = sha256(this, tokenGet, amountGet, tokenGive, amountGive, expires, nonce);
      if (!(
              (orders[user][hash] || ecrecover(sha3("\x19Ethereum Signed Message:\n32", hash), v, r, s) == user) &&
              block.number <= expires &&
              safeAdd(orderFills[user][hash], amount) <= amountGet
          )) throw;
      tradeBalances(tokenGet, amountGet, tokenGive, amountGive, user, amount);
      orderFills[user][hash] = safeAdd(orderFills[user][hash], amount);
      Trade(tokenGet, amount, tokenGive, amountGive * amount / amountGet, user, msg.sender);

Could you please answer the following questions:

  1. What's difference between amountGet and amount arguments?
  2. How can I eventually know how many ETH user got when selling ARC token in this transaction ? Does amountGive give me this value?

Decoded input of this transaction is:

  inputs: [

Thanks for your answers in advance!

  1. amountGet is how much the maker of the order is willing to buy. amount is how much the taker of the order is willing to sell.

  2. amount is the amount that gets traded. amountGet is only used to locate the order by its hash. The amount of tokenGive (ETH in this case) that the transaction sender gets is amount * amountGive / amountGet.

  • thanks for the quick reply, But still is the questions about how much eth the maker got after this trade? How to calculate it based on transaction input data in my question? – Erik Feb 16 '18 at 10:48
  • it should be amount * amountGive / amountGet. You can match the corresponding input values to those arguments. – medvedev1088 Feb 16 '18 at 10:55
  • Are you sure that amount * amountGive / amountGet gives me ETH ? – Erik Feb 16 '18 at 10:57
  • As far as I know yes. You have any doubts? – medvedev1088 Feb 16 '18 at 11:03
  • Normally it should give you the amount of tokenGive. In this particular example it's 0x0 which is ETH. – medvedev1088 Feb 16 '18 at 11:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.