Submitted by hl_, also found by mahdikarimi, OMEN, DedOhWale, Toshii, Kenshin, RedOneN, kenta, Iurii3, mahdikarimi, cccz, gs8nrv, 0xRobocop, hl_, pep7siup, lanrebayode77, bytes032, Co0nan, SpicyMeatball, CrypticShepherd, Musaka, Vagner, Vagner, peanuts, 0xRobocop, peanuts, peanuts, and max10afternoon
Incorrect accounting of poolTotalPeUSDCirculation, results in an understatement of poolTotalPeUSDCirculation amounts. This causes inaccurate bookkeeping and in turn affects any other functions dependent on the use of poolTotalPeUSDCirculation.
We look at function _repay of LybraPeUSDVaultBase.sol as follows:
In particular, note the accounting of poolTotalPeUSDCirculation after repayment as follows:
Consider a scenario per below for user Alice, where:
Based on the accounting flow of the function, the fees incurred are transferred to address(configurator).
The amount burned is amount - totalFee. However, we see that poolTotalPeUSDCirculation reduces the entire amount where it should be amount - totalFee reduced.
This results in an understatement of poolTotalPeUSDCirculation amounts.
Manual review
Correct the accounting as follows:
Error
LybraFinance confirmed
