Skip to content

Instantly share code, notes, and snippets.

@bayological
Created July 27, 2023 00:50
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/db0ba1471f2a59c860a0f9bf3a6fe97e to your computer and use it in GitHub Desktop.
Save bayological/db0ba1471f2a59c860a0f9bf3a6fe97e to your computer and use it in GitHub Desktop.
/**
* @title BreakerBox
* @notice The BreakerBox checks the criteria defined in separate breaker contracts
* to determine whether or not buying or selling should be allowed for a
* specified rateFeedIDs. The contract stores references to all breakers
* that hold criteria to be checked, rateFeedIDs that
* can make use of the BreakerBox & their current trading.
*/
contract BreakerBox is IBreakerBox, Ownable {
using SafeMath for uint256;
/* ==================== State Variables ==================== */
address[] public rateFeedIDs;
// Maps a rate feed to a boolean indicating whether it has been added to the BreakerBox.
mapping(address => bool) public rateFeedStatus;
// Maps a rate feed to its breakers and their breaker status. (rateFeedID => (breaker => BreakerStatus)
mapping(address => mapping(address => BreakerStatus)) public rateFeedBreakerStatus;
// Maps a rate feed to the associated trading mode.
mapping(address => uint8) public rateFeedTradingMode;
// Maps a rate feed to its dependent rate feeds.
mapping(address => address[]) public rateFeedDependencies;
// Maps a breaker to the associated trading mode it should activate when triggered.
mapping(address => uint8) public breakerTradingMode;
// List of breakers to be checked.
address[] public breakers;
// Address of the Mento SortedOracles contract
ISortedOracles public sortedOracles;
// -- Code omitted for brevity -- //
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment