diff --git a/src/Strategy.sol b/src/Strategy.sol index 057eb274..7bced9fe 100644 --- a/src/Strategy.sol +++ b/src/Strategy.sol @@ -752,11 +752,15 @@ contract Strategy is BaseStrategy, Pausable, ReentrancyGuard { require(termAuction.termRepoId() == ITermRepoToken(repoToken).termRepoId(), "repoToken does not match term repo ID"); // Validate purchase token, min collateral ratio and insert the repoToken if necessary - repoTokenListData.validateRepoToken( + (bool isValid, ) = repoTokenListData.validateRepoToken( ITermRepoToken(repoToken), address(asset) ); + if (!isValid) { + revert RepoTokenList.InvalidRepoToken(repoToken); + } + // Prepare and submit the offer ITermAuctionOfferLocker offerLocker = ITermAuctionOfferLocker( termAuction.termAuctionOfferLocker() diff --git a/src/test/TestUSDCOffers.t.sol b/src/test/TestUSDCOffers.t.sol index 282a0355..c4ca22cf 100644 --- a/src/test/TestUSDCOffers.t.sol +++ b/src/test/TestUSDCOffers.t.sol @@ -7,6 +7,7 @@ import {MockTermAuction} from "./mocks/MockTermAuction.sol"; import {MockUSDC} from "./mocks/MockUSDC.sol"; import {Setup, ERC20, IStrategyInterface} from "./utils/Setup.sol"; import {Strategy} from "../Strategy.sol"; +import {RepoTokenList} from "../RepoTokenList.sol"; contract TestUSDCSubmitOffer is Setup { uint256 internal constant TEST_REPO_TOKEN_RATE = 0.05e18; @@ -73,6 +74,16 @@ contract TestUSDCSubmitOffer is Setup { assertEq(termStrategy.totalAssetValue(), termStrategy.totalLiquidBalance() + 1e6); } + function testSubmitOfferFailsIfMinCollatRatioisZero() public { + vm.startPrank(management); + termStrategy.setCollateralTokenParams(address(mockCollateral), 0); + + vm.expectRevert(abi.encodeWithSelector(RepoTokenList.InvalidRepoToken.selector, address(repoToken1Week))); + termStrategy.submitAuctionOffer( + repoToken1WeekAuction, address(repoToken1Week), bytes32("offer id hash 1"), bytes32("test price"), 1e6 + ); + } + function testEditOffer() public { bytes32 idHash1 = bytes32("offer id hash 1"); bytes32 offerId1 = _submitOffer(idHash1, 1e6);