# Reflect finance variables?

**URL:** <https://forum.openzeppelin.com/t/reflect-finance-variables/6888>\
**Category:** Support\
**Created:** [April 10, 2021, 6:16pm UTC](https://forum.openzeppelin.com/t/reflect-finance-variables/6888 "2021-04-10T18:16:15Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![Yoshiko](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/yoshiko/32/6858_2.png) [@Yoshiko](https://forum.openzeppelin.com/u/Yoshiko)\
**Post date:** [April 11, 2021, 2:27am UTC](https://forum.openzeppelin.com/t/reflect-finance-variables/6888/3 "2021-04-11T02:27:53Z")

</div>

I have this same question in my [topic](https://forum.openzeppelin.com/t/what-does-reflect-finance-code-do-rtotal-max-max-totalsupplyoftoken/6572/5). 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

```auto
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

```auto
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.

```auto
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.

---

_[View the full topic](https://forum.openzeppelin.com/t/reflect-finance-variables/6888)._
