Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Short-cut expensive fee calculation when fees are zero; #47

Open
Ryanmtate opened this issue Mar 25, 2019 · 1 comment
Open

Short-cut expensive fee calculation when fees are zero; #47

Ryanmtate opened this issue Mar 25, 2019 · 1 comment

Comments

@Ryanmtate
Copy link
Contributor

In instances where the fees are calculated to equal 0, it would make sense to bypass the setting of the value for the fee contract, thereby saving 20k on the gas costs; It also allows us to simply the contract interface to a uniform erc20 interface without having a secondary interface when fees would not exist.

address feeContract = lib.getFeeContract(proxyInstance);
uint fees = calculateFees(feeContract, amount);

if (fees > 0) {
   // update the balance for the fee contract;
   // if this is not called, will not pay 20k gas for setting the same balance value (i.e. you didn't add any fees to the balance, so why set it again?)
}

// update sender, receiver balances;

https://github.com/tokenio/tokeninc-smart-contracts/blob/7346eb641930004853de791cbe650d9dd07e8285/contracts/TokenIOERC20FeesApply.sol#L198

@RostyslavBortmanAdoria
Copy link

Yes, you are right. Good point, thanks
I will create pool request soon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants