Skip to content

Instantly share code, notes, and snippets.

@bayological
Created July 27, 2023 16:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bayological/b6af744a1939ffc4e258a94ab92b6091 to your computer and use it in GitHub Desktop.
Save bayological/b6af744a1939ffc4e258a94ab92b6091 to your computer and use it in GitHub Desktop.
/**
* @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