Rule engine
Bridge Protocol's rule engine is a library of rules that can be used by the token issuer to control how a token can be transferred or not.
The Rule Engine is a library of rules that can be used by the token issuer to control how a token can be transferred or not. As regulations evolve, new rules can be added to the Rule Engine and the token issuer will be able to enforce them to adapt its compliance.
Trivial rules like maximum transfers or minimum transfers will not need to have interactions with other contracts. For more complex rules that need information about the identity linked to an address or the history of transfers linked to an address, two contracts are currently provided: Compliance Registry and Price Oracle.
Each rule in the Rule Engine has to implement the IRule interface:
function isTransferValid(
address _token, address _from, address _to, uint256 _amount, uint256 _ruleParam)
external view returns (uint256 isValid, uint256 reason);
function beforeTransferHook(
address _token, address _from, address _to, uint256 _amount, uint256 _ruleParam)
external returns (uint256 isValid, address updatedTo, uint256 updatedAmount);
function afterTransferHook(
address _token, address _from, address _to, uint256 _amount, uint256 _ruleParam)
external returns (bool updateDone);
isValid allowed values
- TRANSFER_INVALID = 0 - Returned when the transfer is invalid
- TRANSFER_VALID_WITH_NO_HOOK = 1 - Returned when the transfer is valid and no further action is needed
- TRANSFER_VALID_WITH_BEFORE_HOOK = 2 - Returned when the transfer is valid and the
beforeTransferHook
function of the same rule has to be called - TRANSFER_VALID_WITH_AFTER_HOOK = 3 - Returned when the transfer is valid and the
afterTransferHook
function of the same rule has to be called
This rule is the big red button. It allows you to freeze all tokens in case of emergency.
This rule allows you to freeze all the tokens of specific addresses.
This rule allows you to submit a transaction to the condition that the transaction sender must have a minimum KYC level. Useful if your compliance framework works with multiple user KYC/AML levels or limits.
This rule allows you to submit a transaction to the condition that the transaction recipient must have a minimum KYC level. Useful if your compliance framework works with multiple user KYC/AML levels or limits.
This rule allows you to check whether a user address has been recorded on any whitelist.
This rule allows you to define a maximum value of tokens (in terms of its reference currency) that can be transferred by a user. It applies to all your tokens. If a user tries to make a transaction that will make him/her exceed that limit, the user will get an error message and will be prevented to initiate the transaction.
This rule allows you to define a maximum value of tokens (in terms of its reference currency) that can be transferred by a user. It applies to all your tokens. If a user makes a transaction that will make him/her exceed that limit, the transaction will go through but will be rerouted to one of your KYC providers. The KYC provider address will be able to perform any required KYC/AML check, and then approve or reject the transaction.
This rule allows you to define a maximum amount of tokens that can be transferred by a user.
This rule allows you to define a minimum amount of tokens that must be transferred by a user.
This rule allows you to submit a transaction to the condition that the both the transaction sender and recipient must have a minimum KYC level. Useful if your compliance framework works with multiple user KYC/AML levels or limits.
This rule allows you to lock tokens on an address, but only above a given threshold. Typically useful for shareholder agreements, vesting periods, etc.
This rule allows you to whitelist a given user for one or several specific tokens only.
You can add any rule you want to Bridge Protocol and its Rule registry, and then add it to your token by using the rule number. Please note that any rule that you add yourself will not automatically appear in the app interface. To have it listed in the interface dropdown menu, please contact us.
Last modified 2yr ago