Created
July 27, 2023 16:53
-
-
Save bayological/b6af744a1939ffc4e258a94ab92b6091 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @title Breaker With Cooldown | |
* @notice Utility portion of a Breaker contract which deals with the | |
* cooldown component. | |
*/ | |
contract WithCooldown { | |
/* ==================== Events ==================== */ | |
/** | |
* @notice Emitted after the cooldownTime has been updated. | |
* @param newCooldownTime The new cooldownTime of the breaker. | |
*/ | |
event DefaultCooldownTimeUpdated(uint256 newCooldownTime); | |
/** | |
* @notice Emitted after the cooldownTime has been updated. | |
* @param rateFeedID The rateFeedID targeted. | |
* @param newCooldownTime The new cooldownTime of the breaker. | |
*/ | |
event RateFeedCooldownTimeUpdated(address rateFeedID, uint256 newCooldownTime); | |
/* ==================== State Variables ==================== */ | |
// The amount of time that must pass before the breaker can be reset for a rate feed. | |
// Should be set to 0 to force a manual reset. | |
uint256 public defaultCooldownTime; | |
mapping(address => uint256) public rateFeedCooldownTime; | |
/* ==================== View Functions ==================== */ | |
/** | |
* @notice Get the cooldown time for a rateFeedID | |
* @param rateFeedID the targeted rate feed. | |
* @return the rate specific or default cooldown | |
*/ | |
function getCooldown(address rateFeedID) public view returns (uint256) { | |
uint256 _rateFeedCooldownTime = rateFeedCooldownTime[rateFeedID]; | |
if (_rateFeedCooldownTime == 0) { | |
return defaultCooldownTime; | |
} | |
return _rateFeedCooldownTime; | |
} | |
// -- Code omitted for brevity -- // | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment