Skip to content

UserPositionDebt.applyPremiumDelta function only uses part of the PremiumDelta struct passed as input parameter #1077

@miguelmtzinf

Description

@miguelmtzinf

This suggestion comes from @StErMi.

When doing changes in the premium, the function UserPositionDebt.getPremiumDelta is used to calculate the current premium data to apply. The restored amount is kept in a separated raw value (e.g. restoredPremiumRay) because it's later passed to the Hub, but this value is already included in offsetRayDelta.

  • It's a bit confusing the whole struct is passed userPosition.applyPremiumDelta but restoredPremiumRay value is never used because it has been already included in the premiumDelta.offsetRayDelta.
  • UserPositionDebt.getPremiumDelta it's not only a getter but fetches the delta and apply changes from restoredPremiumRay.

We can consider:

  1. rename getPremiumDelta to calculatePremiumDelta
  2. modify input parameters of applyPremiumDelta so it only takes what's needed.

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