Skip to content

Latest commit

 

History

History
50 lines (44 loc) · 3.25 KB

066.md

File metadata and controls

50 lines (44 loc) · 3.25 KB

Orbiting Sangria Porpoise

High

Protocol ignores debt rewards when checking if rewards are above threshold

Summary

The following check inside extractRewardsNoRequire() should be modified as follows to include the debt reward while comparing with rwd_threshold. Identical logic exists inside lstToNuma() and numaToLst():

    function extractRewardsNoRequire() internal {
        if (block.timestamp >= (last_extracttimestamp + 24 hours)) {
            (
                uint256 rwd,
                uint256 currentvalueWei,
                uint256 rwdDebt
            ) = rewardsValue();
-           if (rwd > rwd_threshold) {
+           if (rwd + rwdDebt > rwd_threshold) {
                extractInternal(rwd, currentvalueWei, rwdDebt);
            }
        }
    }

Description

Consider the following flow:

  • rwd_threshold is set as 1 ether. Note that currently it's set at 0 but can be readily changed by the owner calling setRewardsThreshold()
  • Inside vault, total rEth value in ETH is 8 ETH (for ease of calculation, let's say 1 rEth = 8 ETH)
  • A 25% rebase occurs pushing rEth value to 10 ETH. Vault can be updated via updateVault() which internally calls extractRewardsNoRequire() if 24 hours have passed since the last update. We'll assume it has been more than 24 hours.
  • Case 1:
    • No debts.
    • updateVault() --> extractRewardsNoRequire() --> rewardsValue() is called.
    • rwd is evaluated as 2 ether and debtRwd = 0.
    • Since rwd > rwd_threshold is true, extractInternal() will be called, rewards distributed and last_lsttokenvalueWei will be updated to the new price of 10 ETH
  • Case 2:
    • Debt value = 6 ETH.
    • updateVault() --> extractRewardsNoRequire() --> rewardsValue() is called.
    • rwd is evaluated as 0.8 ether and debtRwd = 1.2 ether.
    • Since rwd > rwd_threshold is false, extractInternal() will be not be called, rewardsFromDebt is not incremented on L358, rewards not distributed, and last_lsttokenvalueWei not updated to the new price of 10 ETH

Impact

Stale values used if vault has debt, leading to incorrect accounting across the protocol.

Mitigation

Add rwdDebt to rwd whenever comparing with rwd_threshold:

-           if (rwd > rwd_threshold) {
+           if (rwd + rwdDebt > rwd_threshold) {