Skip to content

Commit

Permalink
fix: fix the_same_as price feeds test deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
Van0k committed Sep 11, 2024
1 parent 7c014fe commit 62d03a9
Showing 1 changed file with 18 additions and 24 deletions.
42 changes: 18 additions & 24 deletions contracts/test/suites/PriceFeedDeployer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -556,30 +556,6 @@ contract PriceFeedDeployer is Test, PriceFeedDataLive {
}
}

// THE SAME PRICEFEEDS
TheSamePriceFeedData[] memory theSamePriceFeeds = theSamePriceFeedsByNetwork[chainId];
len = theSamePriceFeeds.length;
unchecked {
for (uint256 i; i < len; ++i) {
address token = tokenTestSuite.addressOf(theSamePriceFeeds[i].token);

if (token != address(0)) {
address tokenHasSamePriceFeed = tokenTestSuite.addressOf(theSamePriceFeeds[i].tokenHasSamePriceFeed);
address pf = _getDeployedFeed(tokenHasSamePriceFeed, theSamePriceFeeds[i].reserve);
if (pf != address(0)) {
setPriceFeed(
token,
pf,
_getDeployedStalenessPeriod(tokenHasSamePriceFeed, theSamePriceFeeds[i].reserve),
theSamePriceFeeds[i].reserve
);
} else {
console.log("WARNING: Price feed for ", ERC20(token).symbol(), " not found");
}
}
}
}

// YEARN PRICE FEEDS
SingeTokenPriceFeedData[] memory yearnPriceFeeds = yearnPriceFeedsByNetwork[chainId];
len = yearnPriceFeeds.length;
Expand Down Expand Up @@ -701,6 +677,24 @@ contract PriceFeedDeployer is Test, PriceFeedDataLive {
PriceFeedConfig({token: token, priceFeed: priceFeed, stalenessPeriod: stalenessPeriod})
);
}

_setTheSameAsPFs(token, priceFeed, stalenessPeriod, reserve);
}

function _setTheSameAsPFs(address refToken, address priceFeed, uint32 stalenessPeriod, bool reserve) internal {
TheSamePriceFeedData[] memory theSamePriceFeeds = theSamePriceFeedsByNetwork[chainId];
uint256 len = theSamePriceFeeds.length;
unchecked {
for (uint256 i; i < len; ++i) {
address token = tokenTestSuite.addressOf(theSamePriceFeeds[i].token);
address tokenHasSamePriceFeed = tokenTestSuite.addressOf(theSamePriceFeeds[i].tokenHasSamePriceFeed);

if (refToken == tokenHasSamePriceFeed && reserve == theSamePriceFeeds[i].reserve && token != address(0))
{
setPriceFeed(token, priceFeed, stalenessPeriod, theSamePriceFeeds[i].reserve);
}
}
}
}

function _getDeployedFeed(address token, bool reserve) internal view returns (address) {
Expand Down

0 comments on commit 62d03a9

Please sign in to comment.