ampleforth / token-geyser-v2

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

GEY-08: Unnecessarily Convoluted Logic

thegostep opened this issue · comments

type severity location
Gas Optimization Informational https://github.com/ampleforth/token-geyser-v2/blob/c970676aaecb08e942fe1088a4b1ddcb26655fe6/contracts/Geyser.sol%23L957-L978

Description:

The linked code segment executes the calculateRewardFromStakes function which truncates the stakes consumed to produce the reward and returns the truncated array. In the code segment linked, the truncated array is not utilized directly and only the last remaining element is used along with the array's length .

Recommendation:

We advise that the calculateRewardFromStakes function is refactored to return the last StakeData processed and the number of elements that should be removed from the end of the array via pop , greatly optimizing the gas cost of this code segment.