# How to properly calculate amount of fee in this smart contract?

I'm exploring `tradeBalances` method of this smart contract and trying to investigate how does fee actually calculate for this transaction with the following decoded input data:

``````‌[
"0xac709fcb44a43c35f0da4e3163b117a17f3770f5",
"2500000000000000000000",
"0x0000000000000000000000000000000000000000",
"13775000000000000000",
"3156959",
"3696351802",
"0xd8eeda4ee2657bb267bc35c1d60babdc5aedd269",
"28",
"b4bf0dcd37ca73bd5abce9532b033dcc6427be160683de113efca41320c27f3e",
"78799d84040e5c245828b1b531ef97e1af124946f4dc1db5a20cf28a7073b269",
"726181804936299500000"
]
``````

As far I see from the calculation of fee:

``````tokens[tokenGet][feeAccount] = safeAdd(tokens[tokenGet][feeAccount], safeSub(safeAdd(feeMakeXfer, feeTakeXfer), feeRebateXfer));
``````

I get:

``````// fee constants
const feeMake = '0';
const feeTake = '3000000000000000';

// amout fee calculation
let feeMakeXfer = (726181804936299500000 * 0) / (1 ether); // 0 ETH
let feeTakeXfer = (726181804936299500000 * 3000000000000000) / (1 ether); // 2.1785... ETH

// fee calculation
let fee = (feeMakeXfer + feeTakeXfer) - feeRebateXfer; // 2.1785... ETH
``````

As result of calculations above I get `fee` as `2.1785... ETH` which I believe is very big in this case because amount of ETH he is buying according to formula is:

``````let amount = (13775000000000000000 * 726181804936299500000) / 2500000000000000000000; // 4.001261... ETH
``````

What I'm doing wrong? Please point to my mistake. Thanks in advance.

`feeMake` and `feeTake` are denominated in the same currency as `amount`. `amount` in this case is denominated in `0xac709fcb44a43c35f0da4e3163b117a17f3770f5` which is a token not ether. Thus 2.1785 is the fee in tokens.
When calculating the fee they divide by `1 ether` however it doesn't mean that the fee itself is in ether, they just do it to avoid rounding errors.
• thanks for the reply. Is it possible to get `fee` in ether?
• @Erik you mean to convert the fee into ether? I think it will be `feeTakeXfer * priceOfTokenInEther` where `priceOfTokenInEther = amountGive / amountGet` Commented Feb 16, 2018 at 18:06