Skip to content
This repository was archived by the owner on Dec 18, 2025. It is now read-only.
This repository was archived by the owner on Dec 18, 2025. It is now read-only.

[Lens] virtual rate uses outdated p2p amount #1673

@QGarchery

Description

@QGarchery

When the Lens computes the virtual rate that you would get from entering a position, the p2p amount is not updated. This leads to a rare case where there is an error on the rate.
Here is a small recap on Aave-v2:

  • the function getNextUserBorrowRatePerYear is supposed to return the rate that you would get if you did only one loop of matching, resulting in a given matched amount. To do that it calls the function _getRatesPerYear with that matched amount. This should be the same as calling borrow, doing only one loop of matching and returning the rate as per the testNextRateShouldMatchRateAfterInteraction.
  • the function _getRatesPerYear takes into account the matched amount to compute the pool rates, because those depend on the utilization, so they depend on the amount supplied on pool and borrowed on pool.
  • the function _getRatesPerYear does not take into account the matched amount to compute the p2p rate when calling computeP2PBorrowRatePerYear. This is the reason of the bug. The p2p amount should be updated with the matched amount, because it is used to compute the share of the delta.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions