diff --git a/src/Strategy.sol b/src/Strategy.sol index ae2a2877..c9dac147 100644 --- a/src/Strategy.sol +++ b/src/Strategy.sol @@ -801,15 +801,14 @@ contract Strategy is BaseStrategy, Pausable, ReentrancyGuard { // Sweep assets, redeem matured repoTokens and ensure liquid balances up to date _redeemRepoTokens(0); - bytes32 offerId = _generateOfferId(idHash, address(offerLocker)); uint256 newOfferAmount = purchaseTokenAmount; uint256 currentOfferAmount = termAuctionListData - .offers[offerId] + .offers[idHash] .offerAmount; // Submit the offer and lock it in the auction ITermAuctionOfferLocker.TermAuctionOfferSubmission memory offer; - offer.id = currentOfferAmount > 0 ? offerId : idHash; + offer.id = idHash; offer.offeror = address(this); offer.offerPriceHash = offerPriceHash; offer.amount = purchaseTokenAmount; @@ -966,19 +965,6 @@ contract Strategy is BaseStrategy, Pausable, ReentrancyGuard { _redeemRepoTokens(0); } - /** - * @dev Generate a term offer ID - * @param id The term offer ID hash - * @param offerLocker The address of the term offer locker - * @return The generated term offer ID - */ - function _generateOfferId( - bytes32 id, - address offerLocker - ) internal view returns (bytes32) { - return keccak256(abi.encodePacked(id, address(this), offerLocker)); - } - /** * @notice Required for post-processing after auction clos */ diff --git a/src/TermAuctionList.sol b/src/TermAuctionList.sol index 333af754..97801c90 100644 --- a/src/TermAuctionList.sol +++ b/src/TermAuctionList.sol @@ -179,7 +179,11 @@ library TermAuctionList { if (offer.termAuction.auctionCompleted()) { // If auction is completed and closed, mark for removal and prepare to insert repo token removeNode = true; - insertRepoToken = true; + ITermRepoToken repoToken = ITermRepoToken(offer.repoToken); + (uint256 redemptionTimestamp , , ,) = repoToken.config(); + if (redemptionTimestamp > block.timestamp) { + insertRepoToken = true; + } } else { if (offerAmount == 0) { // If offer amount is zero, it indicates the auction was canceled or deleted @@ -215,7 +219,7 @@ library TermAuctionList { // Auction completed but not closed => include offer.offerAmount in totalValue // because the offerLocker will have already removed the offer. // This applies if the repoToken hasn't been added to the repoTokenList - // (only for new auctions, not reopenings). + // (only for new auctions, not reopenings). repoTokenListData.validateAndInsertRepoToken( ITermRepoToken(offer.repoToken), discountRateAdapter, asset ); @@ -377,4 +381,4 @@ library TermAuctionList { current = _getNext(listData, current); } } -} +} diff --git a/src/test/TestUSDCOffers.t.sol b/src/test/TestUSDCOffers.t.sol index 88818b64..282a0355 100644 --- a/src/test/TestUSDCOffers.t.sol +++ b/src/test/TestUSDCOffers.t.sol @@ -83,11 +83,13 @@ contract TestUSDCSubmitOffer is Setup { vm.prank(management); bytes32[] memory offerIds = termStrategy.submitAuctionOffer( repoToken1WeekAuction, address(repoToken1Week), idHash1, bytes32("test price"), offerAmount - ); + ); + + uint256 offerDiff = offerAmount - 1e6; - assertEq(termStrategy.totalLiquidBalance(), initialState.totalLiquidBalance - offerAmount); + assertEq(termStrategy.totalLiquidBalance(), initialState.totalLiquidBalance - offerDiff); // test: totalAssetValue = total liquid balance + pending offer amount - assertEq(termStrategy.totalAssetValue(), termStrategy.totalLiquidBalance() + offerAmount); + assertEq(termStrategy.totalAssetValue(), termStrategy.totalLiquidBalance() + offerDiff); } function testDeleteOffers() public {