Closed sherlock-admin closed 1 year ago
The reason the other fees require a settlement is due to account issues that would arise if settlement did not happen - because the fee is charged on pre-positions rather than settled positions. In the case of funding, there is not accounting issues that would arise if settlement happens or not, because funding is charged on settled positions.
Closing issue due to sponsor comment and low impact.
rvierdiiev
medium
fundingFee should be updated in same way as makerFee, takeFee, positioFee
Summary
fundingFee
can be changed by product coordinator. It usessettleProduct
modifier, which callssettle
function for a product that will settle product aslatestVersion -> settleVersion -> currentVersion
. WhilemakerFee, takeFee, positioFee
can be changed only when previous position is settled. They are changed like latestVersion -> settleVersion -> fee change -> currentVersion.Vulnerability Detail
Inside
settle
function there is_settleFeeUpdates
call, which is done just after previous period is settled. This is done to not affect previous traders, that agreed on previous fees, when they did trade. So when transition is done fromlatestVersion to settleVersion
, then this fees are applied. And only then transition is done fromsettleVersion to currentVersion
which already uses new fees.So when owner wants to change takerFee for example, then in case if position is not settled yet, then this update will be queued.
However, there is one more fee, that coordinator can provide and that can affect traders. It's
fundingFee
and it can be updated only aftersettle
function. That means that transition will be done from latestVersion to settleVersion and to currentVersion adn only then fees will be applied.This is incorrect and should be done in same way as
makerFee, takeFee, positioFee
.Impact
Fees are changed later then needed
Code Snippet
Provided above
Tool used
Manual Review
Recommendation
Change
fundingFee
in same way asmakerFee, takeFee, positioFee
. In case ifpre
is not empty, then queue update.