When openPosition, we will charge a certain fee, the calculation formula is as follows:
((marginFrom + amountFromBorrowed) * FEE_FACTOR) / Base.BASIS_POINT
It will include marginFrom, which is mainly used to ensure enough collateralTo after swap(), and an extra part will be deposited as tokenFromPremium
But when addPremium(), no fee is charged.
In this way, we can just ensure enough collateralTo after swap in openPosition(), deliberately let tokenFromPremiumPortion == 0, and then use addPremium() to increase tokenFromPremiumPortion, thereby evading the fee generated by this part of marginFrom
Impact
Using addPremium() to evade the fees that should be paid from marginFrom during openPosition
Lines of code
https://github.com/code-423n4/2023-12-particle/blob/a3af40839b24aa13f5764d4f84933dbfa8bc8134/contracts/protocol/ParticlePositionManager.sol#L193 https://github.com/code-423n4/2023-12-particle/blob/a3af40839b24aa13f5764d4f84933dbfa8bc8134/contracts/protocol/ParticlePositionManager.sol#L501
Vulnerability details
Vulnerability details
When
openPosition
, we will charge a certain fee, the calculation formula is as follows:((marginFrom + amountFromBorrowed) * FEE_FACTOR) / Base.BASIS_POINT
It will include
marginFrom
, which is mainly used to ensure enoughcollateralTo
afterswap()
, and an extra part will be deposited astokenFromPremium
But when
addPremium()
, no fee is charged.In this way, we can just ensure enough
collateralTo
afterswap
inopenPosition()
, deliberately lettokenFromPremiumPortion == 0
, and then useaddPremium()
to increasetokenFromPremiumPortion
, thereby evading thefee
generated by this part ofmarginFrom
Impact
Using
addPremium()
to evade the fees that should be paid frommarginFrom
duringopenPosition
Recommended Mitigation
Charge fees for
addPremium()
Assessed type
Other