Skip to content

Commit

Permalink
fix: post audit fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
MishaShWoof committed Jul 9, 2024
1 parent 2c33985 commit 80f08d1
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
14 changes: 12 additions & 2 deletions contracts/pricefeeds/RateBasedScalingPriceFeed.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ import "../IRateProvider.sol";
contract RateBasedScalingPriceFeed is IPriceFeed {
/** Custom errors **/
error InvalidInt256();
error BadDecimals();

/// @notice Version of the price feed
uint public constant override version = 1;
uint public constant VERSION = 1;

/// @notice Description of the price feed
string public description;
Expand All @@ -39,6 +40,7 @@ contract RateBasedScalingPriceFeed is IPriceFeed {
**/
constructor(address underlyingPriceFeed_, uint8 decimals_, uint8 underlyingDecimals_, string memory description_) {
underlyingPriceFeed = underlyingPriceFeed_;
if (decimals_ > 18) revert BadDecimals();
decimals = decimals_;
description = description_;

Expand Down Expand Up @@ -67,7 +69,7 @@ contract RateBasedScalingPriceFeed is IPriceFeed {
uint80 answeredInRound
) {
uint256 rate = IRateProvider(underlyingPriceFeed).getRate();

Check warning

Code scanning / Semgrep OSS

IRateProvider(underlyingPriceFeed).getRate() call on a Balancer pool is not protected from the read-only reentrancy. Warning

IRateProvider(underlyingPriceFeed).getRate() call on a Balancer pool is not protected from the read-only reentrancy.
return (roundId, scalePrice(int256(rate)), startedAt, updatedAt, answeredInRound);
return (1, scalePrice(signed256(rate)), block.timestamp, block.timestamp, 1);
}

function signed256(uint256 n) internal pure returns (int256) {
Expand All @@ -84,4 +86,12 @@ contract RateBasedScalingPriceFeed is IPriceFeed {
}
return scaledPrice;
}

/**
* @notice Contract version
* @return The version of the price feed contract
**/
function version() external pure returns (uint256) {
return VERSION;
}
}
16 changes: 13 additions & 3 deletions contracts/pricefeeds/RsETHScalingPriceFeed.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ import "../IPriceFeed.sol";
contract rsETHScalingPriceFeed is IPriceFeed {

Check warning on line 13 in contracts/pricefeeds/RsETHScalingPriceFeed.sol

View workflow job for this annotation

GitHub Actions / Contract linter

Contract name must be in CamelCase
/** Custom errors **/
error InvalidInt256();
error BadDecimals();

/// @notice Version of the price feed
uint public constant override version = 1;
uint public constant VERSION = 1;

/// @notice Description of the price feed
string public description;
Expand All @@ -39,6 +40,7 @@ contract rsETHScalingPriceFeed is IPriceFeed {
**/
constructor(address underlyingPriceFeed_, uint8 decimals_, string memory description_) {
underlyingPriceFeed = underlyingPriceFeed_;
if (decimals_ > 18) revert BadDecimals();
decimals = decimals_;
description = description_;

Expand Down Expand Up @@ -66,8 +68,8 @@ contract rsETHScalingPriceFeed is IPriceFeed {
uint256 updatedAt,
uint80 answeredInRound
) {
int256 price = int256(ILRTOracle(underlyingPriceFeed).rsETHPrice());
return (roundId, scalePrice(price), startedAt, updatedAt, answeredInRound);
int256 price = signed256(ILRTOracle(underlyingPriceFeed).rsETHPrice());
return (1, scalePrice(price), block.timestamp, block.timestamp, 1);
}

function signed256(uint256 n) internal pure returns (int256) {
Expand All @@ -84,4 +86,12 @@ contract rsETHScalingPriceFeed is IPriceFeed {
}
return scaledPrice;
}

/**
* @notice Contract version
* @return The version of the price feed contract
**/
function version() external pure returns (uint256) {
return VERSION;
}
}

0 comments on commit 80f08d1

Please sign in to comment.