Assessment reports>GTE -- Perp>Medium findings>Inflated funding rate during first settlement
Category: Coding Mistakes

Inflated funding rate during first settlement

Medium Severity
Low Impact
Low Likelihood

Description

During the first call to the settleFunding() function, the self.lastFundingTime storage variable is zero. As a result, the calculation currentTime - self.lastFundingTime assigns the current block.timestamp value to the timeSinceLastFunding variable. This results in an inflated value for traders who were active before the initial funding settlement.

function settleFunding(
    FundingRateEngine storage self,
    uint256 markTwap,
    uint256 indexTwap,
    uint256 fundingInterval,
    uint256 maxFundingRate
) internal returns (int256 funding) {
    uint256 currentTime = block.timestamp;
    uint256 timeSinceLastFunding = currentTime - self.lastFundingTime;

    if (timeSinceLastFunding < fundingInterval) revert FundingIntervalNotElapsed();

    funding = _getUpdatedFunding({
        markTwap: markTwap,
        indexTwap: indexTwap,
        timeSinceLastFunding: timeSinceLastFunding,
        maxFundingRate: maxFundingRate
    });

    self.cumulativeFunding += funding;
    self.lastFundingTime = currentTime;
}

Impact

Traders who are active before the first funding settlement may be charged an inflated funding rate.

Recommendations

We recommend initializing the lastFundingTime storage variable for each market when it is created.

Remediation

This issue has been acknowledged by Liquid Labs, Inc., and a fix was implemented in commit 6036436e.

Zellic © 2025Back to top ↑