Last active
September 6, 2021 10:20
-
-
Save Pet3ris/db7f24696584a61c675436c10ee68e35 to your computer and use it in GitHub Desktop.
Buggy setCompSpeedInternal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @notice Set COMP speed for a single market | |
* @param cToken The market whose COMP speed to update | |
* @param compSpeed New COMP speed for market | |
*/ | |
function setCompSpeedInternal(CToken cToken, uint compSpeed) internal { | |
uint currentCompSpeed = compSpeeds[address(cToken)]; | |
if (currentCompSpeed != 0) { | |
// note that COMP speed could be set to 0 to halt liquidity rewards for a market | |
Exp memory borrowIndex = Exp({mantissa: cToken.borrowIndex()}); | |
updateCompSupplyIndex(address(cToken)); | |
updateCompBorrowIndex(address(cToken), borrowIndex); | |
} else if (compSpeed != 0) { | |
// Add the COMP market | |
Market storage market = markets[address(cToken)]; | |
require(market.isListed == true, "comp market is not listed"); | |
if (compSupplyState[address(cToken)].index == 0 && compSupplyState[address(cToken)].block == 0) { | |
compSupplyState[address(cToken)] = CompMarketState({ | |
index: compInitialIndex, | |
block: safe32(getBlockNumber(), "block number exceeds 32 bits") | |
}); | |
} | |
if (compBorrowState[address(cToken)].index == 0 && compBorrowState[address(cToken)].block == 0) { | |
compBorrowState[address(cToken)] = CompMarketState({ | |
index: compInitialIndex, | |
block: safe32(getBlockNumber(), "block number exceeds 32 bits") | |
}); | |
} | |
} | |
if (currentCompSpeed != compSpeed) { | |
compSpeeds[address(cToken)] = compSpeed; | |
emit CompSpeedUpdated(cToken, compSpeed); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment