Submitted by joestakey, also found by 0xkazim, nirlin, VAD37 and ladboy233.
The interests that need to be paid upon closing a position are computed as follows:
The interest rate is computed using the block delta, between block.number and the starting block.
The issue is that the block production on Optimism is currently not fixed:
Run the following command several times in the repo, using an optimism rpc url:
You will see that the blocks are not produced at a constant rate.
Interest rates are currently manipulable and will result in users having to repay more interest than expected upon closing positions.
Use block.timestamp instead of block.number for interest calculation. It will involve a lot of refactoring as the Compound contracts bathToken currently inherits from using a per block system.
daoio (Rubicon) acknowledged via duplicate issue #1212
HickupHH3 (judge) commented via duplicate issue #1212:
