hats-finance / Tokemak-0x4a2d708ea6b0c04186ecb774cfad1e50fb5efc0b

0 stars 0 forks source link

30-60-90 NAV Test deviates from documentation #4

Open hats-bug-reporter[bot] opened 5 months ago

hats-bug-reporter[bot] commented 5 months ago

Github username: -- Twitter username: -- Submission hash (on-chain): 0x06dcae6f0d5d43ca9a8e07ce8e96f13927d7615128c34c91b2a4f6e197d963e0 Severity: low

Description: In provided documentation states that

  1. If all of the three delta values are negative, pause pool swaps until
    1. the NAV reaches the highest NAV recorded (of the 3 values - 30, 60, 90 days in the past)
    2. 90 days have lapsed since the test was conducted

But 2.1 is never checked

Here is code for updating NAV

    function navUpdate(uint navPerShare) external onlyLMPVault {
        uint40 blockTime = uint40(block.timestamp);
        navTrackingState.insert(navPerShare, blockTime);

        clearExpiredPause();

        if (navTrackingState.len > navLookback3InDays && !paused()) {
            uint nav1 = navTrackingState.getDaysAgo(navLookback1InDays);
            uint nav2 = navTrackingState.getDaysAgo(navLookback2InDays);
            uint nav3 = navTrackingState.getDaysAgo(navLookback3InDays);

            if (navPerShare < nav1 && navPerShare < nav2 && navPerShare < nav3) {
                lastPausedTimestamp = blockTime;
            }
        }
    }

And here when pause is reset

    function clearExpiredPause() internal returns (bool) {
        if (!expiredPauseState()) return false;
        lastPausedTimestamp = 0;
        _swapCostOffsetPeriod = swapCostOffsetMinInDays;
        return true;
    }

As you can see there's no check for past NAV.

Impact: Bbehavior of the contracts differs from the intended behavior (as described in the docs).