Protocol Risk Score Structure
Purpose
Application developers may wish to assign risk scores to addresses that they determine have a higher potential for behavior that is detrimental to their economy. These scores can range from 0-99. Risk administrators are the only admins that can assign risk scores to addresses.
Rule administrators can add and activate RISK-RULES via the application handler contract. These rules are applied at the application level, meaning all assets within the application will be subjected to these rules.
Scope
Risk scores can be applied to individual accounts or addresses of contracts. Risk scores are used to facilitate risk rule checks throughout the protocol. When an account (user) is given a risk score, they will be subject to any risk rules that are active. When a risk rule is added and activated every user with a risk score will be subjected to this risk rule. This means if the Account Max Tx Value by Risk Score is active and a has the following rule values:
The max values per period will be as follows:
risk score | balance | resultant logic |
---|---|---|
Implied* | Implied* | 0-24 -> NO LIMIT |
25 | $500 | 25-49 -> $500 max |
50 | $250 | 50-74 -> $250 max |
75 | $50 | 75-100 -> $50 max |
see RISK-RULES
Data Structure
Risk scores are a uint8 value stored in a mapping inside the RiskScores data contract.
see RiskScores
Enabling/Disabling
- Risk scores can only be added in the app manager by an risk administrator.
- Risk scores can only be removed in the app manager by an risk administrator.
Revert Messages
The transaction will revert with the following error if the risk score assigned is out of range when assigning risck scores:
The selector for this error is 0xb3cbc6f3
.
Add Functions
Adding a risk score is done through the function:
Adding multiple risk scores to a single account or address is done through the function:
Adding multiple risk scores to multiple addresses is done through the function:
Remove Function
Removing a risk score from an address is done through the function:
see App Manager
Parameters:
- _score (uint8): risk score for an account.
- _scores (uint8): array of risk scores for an account.
- _account (address): address of the account for the risk score
- _accounts (address[]): array of addresses to for the risk scores
Parameter Optionality:
There are no options for the parameters for the add functions.
Parameter Validation:
The following validation will be carried out by the addRiskScore function in order to ensure that these parameters are valid and make sense:
_score
is within the 0-99 score range._account
is not the zero address.
see RiskScores
Other Functions:
- In App Manager:
- Function to check the score of an address:
- Function to deploy new data contracts:
- Function to retrieve risk scores data contract address:
- Function to propose data contract migration to new handler:
- Function to confirm migration of data contracts to new handler:
- Function to check the score of an address:
Events
- AD1467_RiskScoreAdded(address indexed _address, uint8 _score): emitted when:
- A risk score has been added.
- AD1467_RiskScoreRemoved(address indexed _address): emitted when:
- A risk score is removed.
- AD1467_RiskProviderSet(address indexed _address): emitted when:
- A risk score data contract has been migrated to the app manager address