Skip to content

Commit

Permalink
fix: check collateral exists on chainlink set (#917)
Browse files Browse the repository at this point in the history
  • Loading branch information
rndquu authored Mar 20, 2024
1 parent 898d45c commit f1144a8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
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

0 comments on commit f1144a8

Please sign in to comment.