Purpose
There are several updates that need to take place in order to add a new applicaiton level rule. In this document we’ll be covering the steps required to update the protocol rule processor diamond including: updating the code for the appropriate facets and upgrading the diamond. This document will walk through the process step by step. (We will be using an existing rule, Max Value By Risk Score, as our example)Creating The Rule
Updating Diamond Storage
The first step is to update the diamond storage to account for the new rule. We’ll need to update RuleStoragePositionLib. For our example we would first add the following constant to the top of the contract to define the storage position for our Account Max Value By Risk Score rule:Facet Updates
The next step is to update the AppRuleDataFacet contract to include a function that can be used to create an instance of our new rule and register it with the diamond. For our example we would add the following function:ProtocolApplicationHandler
to include a check for our new rule. For our example we’ll be updating the _checkRiskRules
function.