Skip to content
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

fix: check collateral exists on chainlink set #917

Merged
merged 1 commit into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/contracts/src/dollar/libraries/LibUbiquityPool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,11 @@ library LibUbiquityPool {
address chainLinkPriceFeedAddress,
uint256 stalenessThreshold
) internal {
require(
collateralExists(collateralAddress),
"Collateral does not exist"
);

UbiquityPoolStorage storage poolStorage = ubiquityPoolStorage();

uint256 collateralIndex = poolStorage.collateralIndex[
Expand Down
15 changes: 15 additions & 0 deletions packages/contracts/test/diamond/facets/UbiquityPoolFacet.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,21 @@ contract UbiquityPoolFacetTest is DiamondTestSetup {
vm.stopPrank();
}

function testSetCollateralChainLinkPriceFeed_ShouldRevertIfCollateralDoesNotExist()
public
{
vm.prank(admin);
vm.expectRevert("Collateral does not exist");
address invalidCollateralAddress = address(0);
address newPriceFeedAddress = address(1);
uint256 newStalenessThreshold = 1 days;
ubiquityPoolFacet.setCollateralChainLinkPriceFeed(
invalidCollateralAddress,
newPriceFeedAddress,
newStalenessThreshold
);
}

function testSetCollateralChainLinkPriceFeed_ShouldSetPriceFeed() public {
vm.startPrank(admin);

Expand Down
Loading