Skip to content

Commit

Permalink
Fix bug: block number needs to be updated when setting reward speed a…
Browse files Browse the repository at this point in the history
…gain after it has been unset

Bug Rari-Capital#2 described in this post: https://www.comp.xyz/t/comptroller-compspeed-bug/2111
  • Loading branch information
davidlucid committed Sep 23, 2021
1 parent 7276d2d commit 335cd82
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions contracts/RewardsDistributor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,9 @@ contract RewardsDistributor is ExponentialNoError {
if (compBorrowState[address(cToken)].index == 0) {
allMarkets.push(cToken);
}
} else {
// Update block number to ensure extra interest is not accrued during the prior period
compSupplyState[address(cToken)].block = safe32(getBlockNumber(), "block number exceeds 32 bits");
}
}

Expand Down Expand Up @@ -214,6 +217,9 @@ contract RewardsDistributor is ExponentialNoError {
if (compSupplyState[address(cToken)].index == 0) {
allMarkets.push(cToken);
}
} else {
// Update block number to ensure extra interest is not accrued during the prior period
compBorrowState[address(cToken)].block = safe32(getBlockNumber(), "block number exceeds 32 bits");
}
}

Expand Down

0 comments on commit 335cd82

Please sign in to comment.