|
| 1 | +# RiskStewardReceiver |
| 2 | +Contract that can read updates from the Chaos Labs Risk Oracle, validate them, and push them to the correct RiskSteward. |
| 3 | + |
| 4 | +# Solidity API |
| 5 | + |
| 6 | +### riskParameterConfigs |
| 7 | + |
| 8 | +Mapping of supported risk configurations and their validation parameters |
| 9 | + |
| 10 | +```solidity |
| 11 | +mapping(string => struct RiskParamConfig) riskParameterConfigs |
| 12 | +``` |
| 13 | + |
| 14 | +- - - |
| 15 | + |
| 16 | +### RISK_ORACLE |
| 17 | + |
| 18 | +Whitelisted oracle address to receive updates from |
| 19 | + |
| 20 | +```solidity |
| 21 | +contract IRiskOracle RISK_ORACLE |
| 22 | +``` |
| 23 | + |
| 24 | +- - - |
| 25 | + |
| 26 | +### lastProcessedTime |
| 27 | + |
| 28 | +Mapping of market and update type to last update timestamp. Used for debouncing updates. |
| 29 | + |
| 30 | +```solidity |
| 31 | +mapping(bytes => uint256) lastProcessedTime |
| 32 | +``` |
| 33 | + |
| 34 | +- - - |
| 35 | + |
| 36 | +### processedUpdates |
| 37 | + |
| 38 | +Mapping of processed updates. Used to prevent re-execution |
| 39 | + |
| 40 | +```solidity |
| 41 | +mapping(uint256 => bool) processedUpdates |
| 42 | +``` |
| 43 | + |
| 44 | +- - - |
| 45 | + |
| 46 | +### UPDATE_EXPIRATION_TIME |
| 47 | + |
| 48 | +Time before a submitted update is considered stale |
| 49 | + |
| 50 | +```solidity |
| 51 | +uint256 UPDATE_EXPIRATION_TIME |
| 52 | +``` |
| 53 | + |
| 54 | +- - - |
| 55 | + |
| 56 | +### initialize |
| 57 | + |
| 58 | +Initializes the contract as ownable, pausable, and access controlled |
| 59 | + |
| 60 | +```solidity |
| 61 | +function initialize(address accessControlManager_) external |
| 62 | +``` |
| 63 | + |
| 64 | +#### Parameters |
| 65 | +| Name | Type | Description | |
| 66 | +| ---- | ---- | ----------- | |
| 67 | +| accessControlManager_ | address | The address of the access control manager | |
| 68 | + |
| 69 | +- - - |
| 70 | + |
| 71 | +### pause |
| 72 | + |
| 73 | +Pauses processing of updates |
| 74 | + |
| 75 | +```solidity |
| 76 | +function pause() external |
| 77 | +``` |
| 78 | + |
| 79 | +#### ⛔️ Access Requirements |
| 80 | +* Controlled by AccessControlManager |
| 81 | + |
| 82 | +- - - |
| 83 | + |
| 84 | +### unpause |
| 85 | + |
| 86 | +Unpauses processing of updates |
| 87 | + |
| 88 | +```solidity |
| 89 | +function unpause() external |
| 90 | +``` |
| 91 | + |
| 92 | +#### ⛔️ Access Requirements |
| 93 | +* Controlled by AccessControlManager |
| 94 | + |
| 95 | +- - - |
| 96 | + |
| 97 | +### setRiskParameterConfig |
| 98 | + |
| 99 | +Sets the risk parameter config for a given update type |
| 100 | + |
| 101 | +```solidity |
| 102 | +function setRiskParameterConfig(string updateType, address riskSteward, uint256 debounce) external |
| 103 | +``` |
| 104 | + |
| 105 | +#### Parameters |
| 106 | +| Name | Type | Description | |
| 107 | +| ---- | ---- | ----------- | |
| 108 | +| updateType | string | The type of update to configure | |
| 109 | +| riskSteward | address | The address for the risk steward contract responsible for processing the update | |
| 110 | +| debounce | uint256 | The debounce period for the update | |
| 111 | + |
| 112 | +#### 📅 Events |
| 113 | +* Emits RiskParameterConfigSet with the update type, previous risk steward, new risk steward, previous debounce, |
| 114 | +* new debounce, previous active status, and new active status |
| 115 | + |
| 116 | +#### ⛔️ Access Requirements |
| 117 | +* Controlled by AccessControlManager |
| 118 | + |
| 119 | +#### ❌ Errors |
| 120 | +* Throws UnsupportedUpdateType if the update type is an empty string |
| 121 | +* Throws InvalidDebounce if the debounce is 0 |
| 122 | +* Throws ZeroAddressNotAllowed if the risk steward address is zero |
| 123 | + |
| 124 | +- - - |
| 125 | + |
| 126 | +### toggleConfigActive |
| 127 | + |
| 128 | +Toggles the active status of a risk parameter config |
| 129 | + |
| 130 | +```solidity |
| 131 | +function toggleConfigActive(string updateType) external |
| 132 | +``` |
| 133 | + |
| 134 | +#### Parameters |
| 135 | +| Name | Type | Description | |
| 136 | +| ---- | ---- | ----------- | |
| 137 | +| updateType | string | The type of update to toggle on or off | |
| 138 | + |
| 139 | +#### 📅 Events |
| 140 | +* Emits ToggleConfigActive with the update type and the new active status |
| 141 | + |
| 142 | +#### ⛔️ Access Requirements |
| 143 | +* Controlled by AccessControlManager |
| 144 | + |
| 145 | +#### ❌ Errors |
| 146 | +* Throws UnsupportedUpdateType if the update type is not supported |
| 147 | + |
| 148 | +- - - |
| 149 | + |
| 150 | +### processUpdateById |
| 151 | + |
| 152 | +Processes an update by its ID. Will validate that the update configuration is active, is not expired, unprocessed, and that the debounce period has passed. |
| 153 | +Validated updates will be processed by the associated risk steward contract which will perform update specific validations and apply validated updates. |
| 154 | + |
| 155 | +```solidity |
| 156 | +function processUpdateById(uint256 updateId) external |
| 157 | +``` |
| 158 | + |
| 159 | +#### Parameters |
| 160 | +| Name | Type | Description | |
| 161 | +| ---- | ---- | ----------- | |
| 162 | +| updateId | uint256 | The ID of the update to process | |
| 163 | + |
| 164 | +#### 📅 Events |
| 165 | +* Emits RiskParameterUpdated with the update ID |
| 166 | + |
| 167 | +#### ❌ Errors |
| 168 | +* Throws ConfigNotActive if the config is not active |
| 169 | +* Throws UpdateIsExpired if the update is expired |
| 170 | +* Throws ConfigAlreadyProcessed if the update has already been processed |
| 171 | +* Throws UpdateTooFrequent if the update is too frequent |
| 172 | + |
| 173 | +- - - |
| 174 | + |
| 175 | +### processUpdateByParameterAndMarket |
| 176 | + |
| 177 | +Processes the latest update for a given parameter and market. Will validate that the update configuration is active, is not expired, |
| 178 | +unprocessed, and that the debounce period has passed. |
| 179 | +Validated updates will be processed by the associated risk steward contract which will perform update specific validations and apply validated updates. |
| 180 | + |
| 181 | +```solidity |
| 182 | +function processUpdateByParameterAndMarket(string updateType, address market) external |
| 183 | +``` |
| 184 | + |
| 185 | +#### Parameters |
| 186 | +| Name | Type | Description | |
| 187 | +| ---- | ---- | ----------- | |
| 188 | +| updateType | string | The type of update to process | |
| 189 | +| market | address | The market to process the update for | |
| 190 | + |
| 191 | +#### 📅 Events |
| 192 | +* Emits RiskParameterUpdated with the update ID |
| 193 | + |
| 194 | +#### ❌ Errors |
| 195 | +* Throws ConfigNotActive if the config is not active |
| 196 | +* Throws UpdateIsExpired if the update is expired |
| 197 | +* Throws ConfigAlreadyProcessed if the update has already been processed |
| 198 | +* Throws UpdateTooFrequent if the update is too frequent |
| 199 | + |
| 200 | +- - - |
| 201 | + |
0 commit comments