-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dev #9
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Semgrep found more than 10 potential problems in the proposed changes. Check the Files changed tab for more details.
if (msg.sender != governor && msg.sender != pauseGuardian) | ||
revert Unauthorized(); |
Check notice
Code scanning / Semgrep
Semgrep Finding: rules.solidity.performance.use-nested-if Note
There are more advantages, such as easier to read code and better coverage reports.
if (initialUserBalance == 0 && finalUserBalance != 0) { | ||
// set bit for asset | ||
userBasic[account].assetsIn |= (uint16(1) << assetInfo.offset); | ||
} else if (initialUserBalance != 0 && finalUserBalance == 0) { | ||
// clear bit for asset | ||
userBasic[account].assetsIn &= ~(uint16(1) << assetInfo.offset); | ||
} |
Check notice
Code scanning / Semgrep
Semgrep Finding: rules.solidity.performance.use-nested-if Note
There are more advantages, such as easier to read code and better coverage reports.
} else if (initialUserBalance != 0 && finalUserBalance == 0) { | ||
// clear bit for asset | ||
userBasic[account].assetsIn &= ~(uint16(1) << assetInfo.offset); | ||
} |
Check notice
Code scanning / Semgrep
Semgrep Finding: rules.solidity.performance.use-nested-if Note
There are more advantages, such as easier to read code and better coverage reports.
if (reserves >= 0 && uint(reserves) >= targetReserves) | ||
revert NotForSale(); |
Check notice
Code scanning / Semgrep
Semgrep Finding: rules.solidity.performance.use-nested-if Note
There are more advantages, such as easier to read code and better coverage reports.
constructor(Configuration memory config) { | ||
// Sanity checks | ||
uint8 decimals_ = ERC20(config.baseToken).decimals(); | ||
if (decimals_ > MAX_BASE_DECIMALS) revert BadDecimals(); | ||
if (config.storeFrontPriceFactor > FACTOR_SCALE) revert BadDiscount(); | ||
if (config.assetConfigs.length > MAX_ASSETS) revert TooManyAssets(); | ||
if (config.baseMinForRewards == 0) revert BadMinimum(); | ||
if ( | ||
IPriceFeed(config.baseTokenPriceFeed).decimals() != | ||
PRICE_FEED_DECIMALS | ||
) revert BadDecimals(); | ||
|
||
// Copy configuration | ||
unchecked { | ||
governor = config.governor; | ||
pauseGuardian = config.pauseGuardian; | ||
baseToken = config.baseToken; | ||
baseTokenPriceFeed = config.baseTokenPriceFeed; | ||
extensionDelegate = config.extensionDelegate; | ||
storeFrontPriceFactor = config.storeFrontPriceFactor; | ||
|
||
decimals = decimals_; | ||
baseScale = uint64(10 ** decimals_); | ||
trackingIndexScale = config.trackingIndexScale; | ||
if (baseScale < BASE_ACCRUAL_SCALE) revert BadDecimals(); | ||
accrualDescaleFactor = baseScale / BASE_ACCRUAL_SCALE; | ||
|
||
baseMinForRewards = config.baseMinForRewards; | ||
rewardKink = config.rewardKink; | ||
baseTrackingRewardSpeed = config.baseTrackingRewardSpeed; | ||
|
||
baseBorrowMin = config.baseBorrowMin; | ||
targetReserves = config.targetReserves; | ||
} | ||
|
||
// Set interest rate model configs | ||
unchecked { | ||
supplyKink = config.supplyKink; | ||
supplyPerSecondInterestRateSlopeLow = | ||
config.supplyPerYearInterestRateSlopeLow / | ||
SECONDS_PER_YEAR; | ||
supplyPerSecondInterestRateSlopeHigh = | ||
config.supplyPerYearInterestRateSlopeHigh / | ||
SECONDS_PER_YEAR; | ||
supplyPerSecondInterestRateBase = | ||
config.supplyPerYearInterestRateBase / | ||
SECONDS_PER_YEAR; | ||
borrowKink = config.borrowKink; | ||
borrowPerSecondInterestRateSlopeLow = | ||
config.borrowPerYearInterestRateSlopeLow / | ||
SECONDS_PER_YEAR; | ||
borrowPerSecondInterestRateSlopeHigh = | ||
config.borrowPerYearInterestRateSlopeHigh / | ||
SECONDS_PER_YEAR; | ||
borrowPerSecondInterestRateBase = | ||
config.borrowPerYearInterestRateBase / | ||
SECONDS_PER_YEAR; | ||
} | ||
|
||
// Set asset info | ||
numAssets = uint8(config.assetConfigs.length); | ||
|
||
(asset00_a, asset00_b) = getPackedAssetInternal(config.assetConfigs, 0); | ||
(asset01_a, asset01_b) = getPackedAssetInternal(config.assetConfigs, 1); | ||
(asset02_a, asset02_b) = getPackedAssetInternal(config.assetConfigs, 2); | ||
(asset03_a, asset03_b) = getPackedAssetInternal(config.assetConfigs, 3); | ||
(asset04_a, asset04_b) = getPackedAssetInternal(config.assetConfigs, 4); | ||
(asset05_a, asset05_b) = getPackedAssetInternal(config.assetConfigs, 5); | ||
(asset06_a, asset06_b) = getPackedAssetInternal(config.assetConfigs, 6); | ||
(asset07_a, asset07_b) = getPackedAssetInternal(config.assetConfigs, 7); | ||
(asset08_a, asset08_b) = getPackedAssetInternal(config.assetConfigs, 8); | ||
(asset09_a, asset09_b) = getPackedAssetInternal(config.assetConfigs, 9); | ||
(asset10_a, asset10_b) = getPackedAssetInternal( | ||
config.assetConfigs, | ||
10 | ||
); | ||
(asset11_a, asset11_b) = getPackedAssetInternal( | ||
config.assetConfigs, | ||
11 | ||
); | ||
(asset12_a, asset12_b) = getPackedAssetInternal( | ||
config.assetConfigs, | ||
12 | ||
); | ||
(asset13_a, asset13_b) = getPackedAssetInternal( | ||
config.assetConfigs, | ||
13 | ||
); | ||
(asset14_a, asset14_b) = getPackedAssetInternal( | ||
config.assetConfigs, | ||
14 | ||
); | ||
} |
Check notice
Code scanning / Semgrep
Semgrep Finding: rules.solidity.performance.non-payable-constructor Note
); | ||
} | ||
unchecked { | ||
i++; |
Check notice
Code scanning / Semgrep
Semgrep Finding: rules.solidity.performance.use-prefix-increment-not-postfix Note
The prefix increment expression is cheaper in terms of gas.
constructor( | ||
address priceFeedUniswap_, | ||
address uniswapUnderlying_, | ||
address priceFeedChainlink_, | ||
uint8 decimals_, | ||
string memory description_ | ||
) { | ||
priceFeedUniswap = priceFeedUniswap_; | ||
uniswapUnderlying = uniswapUnderlying_; | ||
priceFeedChainlink = priceFeedChainlink_; | ||
uint8 priceFeedUniswapDecimals = 18; | ||
uint8 priceFeedChainlinkDecimals = AggregatorV3Interface( | ||
priceFeedChainlink_ | ||
).decimals(); | ||
combinedScale = signed256( | ||
10 ** (priceFeedUniswapDecimals + priceFeedChainlinkDecimals) | ||
); | ||
|
||
if (decimals_ > 18) revert BadDecimals(); | ||
decimals = decimals_; | ||
description = description_; | ||
priceFeedScale = int256(10 ** decimals); | ||
} |
Check warning
Code scanning / Semgrep
Semgrep Finding: compound.solidity.missing-constructor-sanity-checks Warning
constructor( | ||
address priceFeedUniswap_, | ||
address uniswapUnderlying_, | ||
address priceFeedChainlink_, | ||
uint8 decimals_, | ||
string memory description_ | ||
) { | ||
priceFeedUniswap = priceFeedUniswap_; | ||
uniswapUnderlying = uniswapUnderlying_; | ||
priceFeedChainlink = priceFeedChainlink_; | ||
uint8 priceFeedUniswapDecimals = 18; | ||
uint8 priceFeedChainlinkDecimals = AggregatorV3Interface( | ||
priceFeedChainlink_ | ||
).decimals(); | ||
combinedScale = signed256( | ||
10 ** (priceFeedUniswapDecimals + priceFeedChainlinkDecimals) | ||
); | ||
|
||
if (decimals_ > 18) revert BadDecimals(); | ||
decimals = decimals_; | ||
description = description_; | ||
priceFeedScale = int256(10 ** decimals); | ||
} |
Check warning
Code scanning / Semgrep
Semgrep Finding: compound.solidity.missing-constructor-sanity-checks Warning
constructor( | ||
address priceFeedUniswap_, | ||
address uniswapUnderlying_, | ||
address priceFeedChainlink_, | ||
uint8 decimals_, | ||
string memory description_ | ||
) { | ||
priceFeedUniswap = priceFeedUniswap_; | ||
uniswapUnderlying = uniswapUnderlying_; | ||
priceFeedChainlink = priceFeedChainlink_; | ||
uint8 priceFeedUniswapDecimals = 18; | ||
uint8 priceFeedChainlinkDecimals = AggregatorV3Interface( | ||
priceFeedChainlink_ | ||
).decimals(); | ||
combinedScale = signed256( | ||
10 ** (priceFeedUniswapDecimals + priceFeedChainlinkDecimals) | ||
); | ||
|
||
if (decimals_ > 18) revert BadDecimals(); | ||
decimals = decimals_; | ||
description = description_; | ||
priceFeedScale = int256(10 ** decimals); | ||
} |
Check warning
Code scanning / Semgrep
Semgrep Finding: compound.solidity.missing-constructor-sanity-checks Warning
constructor( | ||
address priceFeedUniswap_, | ||
address uniswapUnderlying_, | ||
address priceFeedChainlink_, | ||
uint8 decimals_, | ||
string memory description_ | ||
) { | ||
priceFeedUniswap = priceFeedUniswap_; | ||
uniswapUnderlying = uniswapUnderlying_; | ||
priceFeedChainlink = priceFeedChainlink_; | ||
uint8 priceFeedUniswapDecimals = 18; | ||
uint8 priceFeedChainlinkDecimals = AggregatorV3Interface( | ||
priceFeedChainlink_ | ||
).decimals(); | ||
combinedScale = signed256( | ||
10 ** (priceFeedUniswapDecimals + priceFeedChainlinkDecimals) | ||
); | ||
|
||
if (decimals_ > 18) revert BadDecimals(); | ||
decimals = decimals_; | ||
description = description_; | ||
priceFeedScale = int256(10 ** decimals); | ||
} |
Check warning
Code scanning / Semgrep
Semgrep Finding: compound.solidity.missing-constructor-sanity-checks Warning
Param update1
add enacted state
No description provided.