I have this same question in my topic. Iâve personally tried to reach out to the RFI devs for answers to no avail.
I can understand that _rTotal has a very large number attached. I think itâs supposed to stand for âReflection Totalsâ
You can actually see it in one of the functions requirements
function tokenFromReflection(uint256 rAmount) public view returns (uint256){ // no idea what this does
require(rAmount <= _rTotal, "Amount must be less than total reflections");
uint256 currentRate = getReflectRate();
return rAmount.div(currentRate); // gets the amount of the reflection
}
I think what itâs doing is somehow calculating the total POSSIBLE reflections that can occur within the token.
However, in another function
function takeReflectFee(uint256 reflectFee, uint256 taxFee) private {
_rTotal = _rTotal.sub(reflectFee); // subtracts the fee from the reflect totals
totalFeeAmount = totalFeeAmount.add(taxFee); // adds to the toal fee amount
}
You can see that itâs reducing the rTotal amount. Which is odd to me. Is there a limited number of reflections that can happen per token? Why would that keep getting reduced? It doesnât make sense to me.
function deliverReflectTokens(uint256 tAmount) public {
address sender = _msgSender();
require(!isAccountExcludedFromReward[sender],"Excluded addresses cannot call this function");
(uint256 rAmount, , , , , ) = getTaxAndReflectionValues(tAmount);
reflectTokensOwned[sender] = reflectTokensOwned[sender].sub(rAmount);
_rTotal = _rTotal.sub(rAmount);
totalFeeAmount = totalFeeAmount.add(tAmount);
}
There is also this function, which isnât called from within itâs code, but instead itâs called manually from outside the contract.
This doesnât make a lot of sense to me, how does this all work? I have no clue, only that it âworksâ as shown from all the clones that use RFI.
If you figure it out I would appreciate you adding me on Discord (in my profile) to explain it to me haha.
Iâd also like to state that RFI code was written in a very smelly way. Iâve rewritten part of RFI to reduce the code base. You can reduce their nasty if/else. What Iâm trying to say is that if you had the time you could probably rewrite RFI to be way better and to make more logical sense. I will probably end up rewriting RFI in a future project.