The purpose of this rule is to provide limits on the amount of tokens received from a source address for accounts at the application level based on an application defined segment of users. The segments are defined as the access levels of the accounts. This rule may be used to provide gated accumulation of assets from the source address to ensure accounts cannot accumulate more assets without performing other actions defined by the application.NOTE: access levels are restricted from 0 to 4.
A account-max-received-by-access-level rule is composed of a single component:
accountMaxReceivedLimits (mapping(uint8 =>uint48)): the maximum USD worth of application assets that accounts can receive from the source address per access level.
NOTE: access levels are restricted from 0 to 4.These rules are stored in a mapping indexed by ruleId(uint32) in order of creation:
Copy
Ask AI
/// Account Max Received By Access Level struct AccountMaxReceivedByAccessLevelS { mapping(uint32 => IApplicationRules.AccountMaxReceivedByAccessLevel) accountMaxReceivedByAccessLevelRules; uint32 accountMaxReceivedByAccessLevelIndex; /// increments every time someone adds a rule }
The rule will be evaluated with the following logic:
The handler determines if the rule is active from the supplied action. If not, processing does not continue past this step.
The application manager sends to the protocol’s rule processor the dollar value of application assets received from the source address, the access level of the account, the ruleId, and the dollar amount to be transferred in the transaction.
The processor retrieves the maximum amount allowed for the rule with the ruleId passed, and for the access level of the account. If the transfer amount plus received exceeds the maximum allowed by the rule in the case of a successful transactions, then the transaction reverts.
This rule doesn’t apply when a treasuryAccount address is in either the from or the to side of the transaction. This doesn’t necessarily mean that if an treasury account is the one executing the transaction it will bypass the rule, unless the aforementioned condition is true.
_appManagerAddr (address): the address of the application manager to verify that the caller has rule administrator privileges.
_receivedAmounts (uint48[]): array of max value limits for each 5 levels (levels 0 to 4) in whole USD amounts (1 -> 1 USD; 1000 -> 1000 USD). Note that the position within the array matters. Position 0 represents access level 0, and position 4 represents level 4.