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:
- rename
getPremiumDelta to calculatePremiumDelta
- modify input parameters of
applyPremiumDelta so it only takes what's needed.