Skip to content

Commit

Permalink
Merge pull request #892 from gitcoindev/do-not-allowed-to-mint-dollar…
Browse files Browse the repository at this point in the history
…-when-collateral-is-equal-to-zero

Do not allow to mint dollar when collateral is equal to zero
  • Loading branch information
rndquu authored Feb 3, 2024
2 parents aa55dad + 8efd07f commit 7035b0a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ library LibUbiquityPool {

// get amount of collateral for minting Dollars
collateralNeeded = getDollarInCollateral(collateralIndex, dollarAmount);
require(collateralNeeded > 0, "Cannot mint with zero collateral");

// subtract the minting fee
totalDollarMint = dollarAmount
Expand Down
21 changes: 21 additions & 0 deletions packages/contracts/test/diamond/facets/UbiquityPoolFacet.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,27 @@ contract UbiquityPoolFacetTest is DiamondTestSetup {
);
}

function testMintDollar_ShouldRevert_IfZeroCollateralAvailable() public {
vm.prank(admin);
ubiquityPoolFacet.setPriceThresholds(
1000000, // mint threshold
1000000 // redeem threshold
);
// reset collateral fees to 0
vm.prank(admin);
ubiquityPoolFacet.setFees(0, 0, 0);

// user tries to mint with zero collateral
vm.prank(user);
vm.expectRevert("Cannot mint with zero collateral");
ubiquityPoolFacet.mintDollar(
0, // collateral index
0, // Dollar amount
100e18, // min amount of Dollars to mint
0 // max collateral to send
);
}

function testMintDollar_ShouldRevert_OnDollarAmountSlippage() public {
vm.prank(admin);
ubiquityPoolFacet.setPriceThresholds(
Expand Down

0 comments on commit 7035b0a

Please sign in to comment.