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;
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.
https://github.com/tokenio/tokeninc-smart-contracts/blob/7346eb641930004853de791cbe650d9dd07e8285/contracts/TokenIOERC20FeesApply.sol#L198