Assessment reports>Wasabi Perps>Low findings>Zero interest automatically changed to maximum interest
Category: Coding Mistakes

Zero interest automatically changed to maximum interest

Low Severity
Informational Impact
Low Likelihood

Description

When closing a position, the pools compute the amount of interest owed by the user with the _computeInterest function.

function _computeInterest(Position calldata _position, uint256 _interest) internal view returns (uint256) {
    uint256 maxInterest = addressProvider.getDebtController()
        .computeMaxInterest(_position.currency, _position.principal, _position.lastFundingTimestamp);
    if (_interest == 0 || _interest > maxInterest) {
        _interest = maxInterest;
    }
    return _interest;
}

We note that due to how the function is programmed, it would be impossible to offer zero interest, as an interest of zero is automatically converted into the maximum possible interest.

Impact

This design renders it impossible to offer zero rates. Additionally, using zero as the special value signalling that maximum interest should be used is arguably more error prone than other alternatives, such as using a separate variable or a value of uint256.max (which would automatically be capped to the maximum possible value).

Recommendations

Consider changing the behavior of the function to use uint256.max as the special value that signals the maximum possible interest should be applied.

Remediation

Zellic © 2024Back to top ↑