Let's say I have the following decoded transaction input data:


that's used in trade method of this smart contract.

In this invoke the sender is willing to buy ARC (0xac709fcb44a43c35f0da4e3163b117a17f3770f5) token by selling ETH.

What I'm trying to calculate is how much ETH will be send to feeAccount; This line of code:

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

My calculations are:

const web3 = require('web3');

const feeMake = '0';
const feeTake = '3000000000000000';

let feeMakeXfer = (100000000000000000 * feeMake) / web3.utils.toWei('1', 'ether'); // 0
let feeTakeXfer = (100000000000000000 * feeTake) / web3.utils.toWei('1', 'ether')); // 300000000000000
let feeRebateXfer = 0;

let accountFee = feeMakeXfer + feeTakeXfer - feeRebateXfer; // 0.0003 ETH

So based on my calculations account fee for this trade is 0.0003 ETH.

Is it correct?


Yes, your calculations look correct again.

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.