maxFundingVelocity
of a market can be freely updated by the admins, but the problem is that since funding rate and the elapsed time from last time that the funding was updated are also dependent on it, any update without calling PerpMarket::updateFunding
will lead to stepwise jumps in the rates and will either incentivize longs (shorts pay funding fees - funding rate -ve, skew +ve), or shorts (longs pay funding fees - funding rate +ve, skew -ve) because lastFundingTime
is not set to block.timestamp
:
Admin updates the maxFundingVelocity
to any reasonable amount, it’s important to note that admin has nothing to do in this situation.
maxFundingVelocity
is updated without invoking PerpMarket::updateFunding
.
Order is created and in order to get the latest funding rate, PerpMarket::getCurrentFundingRate
is invoked:
Let’s say the getProportionalElapsedSinceLastFunding
is 86400 seconds (1 day) and then we see that the maxFundingVelocity
directly influences the result from getCurrentFundingVelocity
, and assumes that this velocity is set at the beginning of the previous epoch, while it is recently updated and should be applied from current time.
As we saw the velocity is not what should be, which will either incentivize or disincentivize the trader depending on the sign of the new funding rate, but in all matters will not be the expected funding rate for this current period.
As stated by Zaros team, in the beginning these variables will be more frequently modified due to the early stage of the project and the off-chain calculation that are performed for maximising the profitability for given market. Another scenario which will require more frequent updates of the velocity is for memecoins - highly volatile tokens
Here is a POC, that first opens some positions and warp some time in order for the funding rates to be accumulated, then we update the maxFundingVelocity
with uint256.max
to demonstrate that numbers won’t be equal without even touching the system, but in reality it will be smaller amount, and lastly prints both old and new funding rates:
Stepwise jumps in the funding rates when maxFundingVelocity
is update, since updateFunding
is not called and system wrongly assumes that velocity is changed at time T = lastFundingTime
, while it should be from the time that updatePerpMarketConfiguration
is called.
Manual Review
add updateFunding
in GlobalConfigurationBranch::updatePerpMarketConfiguration
when maxFundingVelocity
is being modified.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.