diff --git a/packages/contracts/src/dollar/libraries/LibUbiquityPool.sol b/packages/contracts/src/dollar/libraries/LibUbiquityPool.sol index 3ca5ea12a..a9642ea11 100644 --- a/packages/contracts/src/dollar/libraries/LibUbiquityPool.sol +++ b/packages/contracts/src/dollar/libraries/LibUbiquityPool.sol @@ -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 diff --git a/packages/contracts/test/diamond/facets/UbiquityPoolFacet.t.sol b/packages/contracts/test/diamond/facets/UbiquityPoolFacet.t.sol index 18bd805c2..af455ffa4 100644 --- a/packages/contracts/test/diamond/facets/UbiquityPoolFacet.t.sol +++ b/packages/contracts/test/diamond/facets/UbiquityPoolFacet.t.sol @@ -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(