Balance Accounting

Balance Accounting

A baseBalances mapping stores the time-discounted cumulative yield earned at the latest transfer, mint or burn for an address. When multiplied by the cumulative yield, this baseBalances mapping returns the accrued rewards. To avoid any rounding errors caused by storing this intermediate state between balanceOf reads, baseBalances is stored in 27 decimals. This gives high enough accuracy so that the 18 decimal values returned by balanceOf are always accurate when formatted to 18 decimals. WadRayMath is used to convert and operate on and 27 and 18 decimal values.

Last updated