Skip to content

Commit

Permalink
add a check for invalidate
Browse files Browse the repository at this point in the history
  • Loading branch information
dionchu committed Sep 6, 2024
1 parent 4d0cee9 commit 57fa41b
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion src/TermDiscountRateAdapter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,33 @@ contract TermDiscountRateAdapter is ITermDiscountRateAdapter, AccessControlUpgra
return auctionMetadata[0].auctionClearingRate;
}

function markRateInvalid(address repoToken, bytes32 termAuctionId) external onlyRole(ADMIN_ROLE) {
/**
* @notice Invalidates the result of a specific auction for a given repo token
* @dev This function is used to mark auction results as invalid, typically in cases of suspected manipulation
* @param repoToken The address of the repo token associated with the auction
* @param termAuctionId The unique identifier of the term auction to be invalidated
* @custom:access Restricted to accounts with the ADMIN_ROLE
*/
function invalidateAuctionResult(address repoToken, bytes32 termAuctionId) external onlyRole(ADMIN_ROLE) {
// Fetch the auction metadata for the given repo token
(AuctionMetadata[] memory auctionMetadata, ) = TERM_CONTROLLER.getTermAuctionResults(ITermRepoToken(repoToken).termRepoId());

// Check if the termAuctionId exists in the metadata
bool auctionExists = false;
for (uint256 i = 0; i < auctionMetadata.length; i++) {
if (auctionMetadata[i].termAuctionId == termAuctionId) {
auctionExists = true;
break;
}
}

// Revert if the auction doesn't exist
require(auctionExists, "Auction ID not found in metadata");

// Check if the rate is already invalidated
require(!rateInvalid[repoToken][termAuctionId], "Rate already invalidated");

// Invalidate the rate
rateInvalid[repoToken][termAuctionId] = true;
}
}

0 comments on commit 57fa41b

Please sign in to comment.