Skip to content

Commit

Permalink
Add isOpen boolean gate
Browse files Browse the repository at this point in the history
  • Loading branch information
ckoopmann committed Dec 20, 2023
1 parent a8d67aa commit bdf2861
Show file tree
Hide file tree
Showing 3 changed files with 556 additions and 495 deletions.
19 changes: 19 additions & 0 deletions contracts/adapters/OptimisticAuctionRebalanceExtension.sol
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ contract OptimisticAuctionRebalanceExtension is AuctionRebalanceExtension, Asse
ProductSettings public productSettings; // Mapping of set token to ProductSettings
mapping(bytes32 => bytes32) public assertionIds; // Maps proposal hashes to assertionIds.
mapping(bytes32 => Proposal) public proposedProduct; // Maps assertionIds to a Proposal.
bool public isOpen; // Bool indicating whether the extension is open for proposing rebalances.

// Keys for assertion claim data.
bytes public constant PROPOSAL_HASH_KEY = "proposalHash";
Expand All @@ -124,6 +125,13 @@ contract OptimisticAuctionRebalanceExtension is AuctionRebalanceExtension, Asse

}

/* ============ Modifier ============ */

modifier onlyIfOpen() {
require(isOpen, "Must be open for rebalancing");
_;
}

/* ============ External Functions ============ */

/**
Expand Down Expand Up @@ -154,6 +162,16 @@ contract OptimisticAuctionRebalanceExtension is AuctionRebalanceExtension, Asse
_updateUseAssetAllowlist(_useAssetAllowlist);
}

/**
* ONLY OPERATOR: Toggle isOpen on and off. When false the extension is closed for proposing rebalances.
* when true it is open.
*
* @param _isOpen Bool indicating whether the extension is open for proposing rebalances.
*/
function updateIsOpen(bool _isOpen) external onlyOperator {
isOpen = _isOpen;
}



/**
Expand Down Expand Up @@ -198,6 +216,7 @@ contract OptimisticAuctionRebalanceExtension is AuctionRebalanceExtension, Asse
)
external
onlyAllowedAssets(_newComponents)
onlyIfOpen()
{
bytes32 proposalHash = keccak256(abi.encode(
setToken,
Expand Down
Loading

0 comments on commit bdf2861

Please sign in to comment.