Skip to content

Commit

Permalink
Merge pull request #70 from term-finance/runtime-fv
Browse files Browse the repository at this point in the history
Runtime fv
  • Loading branch information
aazhou1 authored Oct 10, 2024
2 parents 5db248f + 85efc8b commit 811316d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Strategy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
11 changes: 11 additions & 0 deletions src/test/TestUSDCOffers.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 811316d

Please sign in to comment.