Git Source

Inherits: Context, RuleAdministratorOnly, IEconomicEvents, IInputErrors, ITagInputErrors, IZeroAddressError, IAppRuleInputErrors

Author: @ShaneDuncan602 @oscarsernarosero @TJ-Everett

This contract sets and gets the Rules for the protocol

setters and getters for non tagged token specific rules

State Variables

MAX_TOKEN_PERCENTAGE

uint16 constant MAX_TOKEN_PERCENTAGE = 9999;

MAX_PERCENTAGE

uint16 constant MAX_PERCENTAGE = 10000;

MAX_VOLUME_PERCENTAGE

uint24 constant MAX_VOLUME_PERCENTAGE = 100000;

Functions

addTokenMaxBuySellVolume

Note that no update method is implemented for rules. Since reutilization of rules is encouraged, it is preferred to add an extra rule to the set instead of modifying an existing one.

Function to add a Token Max Buy Sell Volume rule

function addTokenMaxBuySellVolume(
    address _appManagerAddr,
    uint16 _supplyPercentage,
    uint16 _period,
    uint256 _totalSupply,
    uint64 _startTime
) external ruleAdministratorOnly(_appManagerAddr) returns (uint32);

Parameters

NameTypeDescription
_appManagerAddraddressAddress of App Manager
_supplyPercentageuint16Percentage of Tokens allowed for transaction
_perioduint16Time period that transactions are accumulated (in hours)
_totalSupplyuint256total supply of tokens (0 if using total supply from the token contract)
_startTimeuint64start timestamp for the rule

Returns

NameTypeDescription
<none>uint32ruleId position of new rule in array

addPurchaseFeeByVolumeRule

Function to add a Token Purchase Fee By Volume rule

function addPurchaseFeeByVolumeRule(address _appManagerAddr, uint256 _volume, uint16 _rateIncreased)
    external
    ruleAdministratorOnly(_appManagerAddr)
    returns (uint32);

Parameters

NameTypeDescription
_appManagerAddraddressAddress of App Manager
_volumeuint256Maximum allowed volume
_rateIncreaseduint16Amount rate increased

Returns

NameTypeDescription
<none>uint32ruleId position of new rule in array

getPurchaseFeeByVolumeRule

Function get Token PurchaseFeeByVolume Rule by index

function getPurchaseFeeByVolumeRule(uint32 _index)
    external
    view
    returns (NonTaggedRules.TokenPurchaseFeeByVolume memory);

Parameters

NameTypeDescription
_indexuint32position of rule in array

Returns

NameTypeDescription
<none>NonTaggedRules.TokenPurchaseFeeByVolumeTokenPurchaseFeeByVolume rule at index position

getTotalTokenPurchaseFeeByVolumeRules

Function to get total Token Purchase Percentage

function getTotalTokenPurchaseFeeByVolumeRules() public view returns (uint32);

Returns

NameTypeDescription
<none>uint32Total length of array

addTokenMaxPriceVolatility

Function to add a Token Max Price Volatility rule

function addTokenMaxPriceVolatility(
    address _appManagerAddr,
    uint16 _max,
    uint16 _period,
    uint16 _hoursFrozen,
    uint256 _totalSupply
) external ruleAdministratorOnly(_appManagerAddr) returns (uint32);

Parameters

NameTypeDescription
_appManagerAddraddressAddress of App Manager
_maxuint16Maximum allowed volume
_perioduint16period in hours for the rule
_hoursFrozenuint16freeze period hours
_totalSupplyuint256

Returns

NameTypeDescription
<none>uint32ruleId position of new rule in array

getTokenMaxPriceVolatility

Function get Token Volatility Rule by index

function getTokenMaxPriceVolatility(uint32 _index)
    external
    view
    returns (NonTaggedRules.TokenMaxPriceVolatility memory);

Parameters

NameTypeDescription
_indexuint32position of rule in array

Returns

NameTypeDescription
<none>NonTaggedRules.TokenMaxPriceVolatilitytokenMaxPriceVolatilityRules rule at index position

getTotalTokenMaxPriceVolatility

Function to get total Volatility rules

function getTotalTokenMaxPriceVolatility() public view returns (uint32);

Returns

NameTypeDescription
<none>uint32Total length of array

addTokenMaxTradingVolume

Function to add a Token max trading Volume rules

function addTokenMaxTradingVolume(
    address _appManagerAddr,
    uint24 _maxPercentage,
    uint16 _hoursPerPeriod,
    uint64 _startTime,
    uint256 _totalSupply
) external ruleAdministratorOnly(_appManagerAddr) returns (uint32);

Parameters

NameTypeDescription
_appManagerAddraddressAddress of App Manager
_maxPercentageuint24Maximum allowed volume percentage (this is 4 digits to allow 2 decimal places)
_hoursPerPerioduint16hours that define a period
_startTimeuint64Timestamp to start the rule
_totalSupplyuint256Circulating supply value to use in calculations. If not specified, defaults to ERC20 totalSupply

Returns

NameTypeDescription
<none>uint32ruleId position of new rule in array

addTokenMinTxSize

Function to add Token Min Tx Size rules

function addTokenMinTxSize(address _appManagerAddr, uint256 _minSize)
    external
    ruleAdministratorOnly(_appManagerAddr)
    returns (uint32);

Parameters

NameTypeDescription
_appManagerAddraddressAddress of App Manager
_minSizeuint256Mimimum amount of tokens required for transfer

Returns

NameTypeDescription
<none>uint32ruleId position of new rule in array

addTokenMaxSupplyVolatility

Function Token Max Supply Volatility rules

function addTokenMaxSupplyVolatility(
    address _appManagerAddr,
    uint16 _maxPercentage,
    uint16 _period,
    uint64 _startTime,
    uint256 _totalSupply
) external ruleAdministratorOnly(_appManagerAddr) returns (uint32);

Parameters

NameTypeDescription
_appManagerAddraddressAddress of App Manager
_maxPercentageuint16Maximum amount of change allowed. This is not capped and will allow for values greater than 100%. Since there is no cap for _maxPercentage this could allow burning of full totalSupply() if over 100% (10000).
_perioduint16Allowed hours per period
_startTimeuint64Unix timestamp for the _period to start counting.
_totalSupplyuint256this is an optional parameter. If 0, the toalSupply will be calculated dyamically. If not zero, this is going to be the locked value to calculate the rule

Returns

NameTypeDescription
<none>uint32ruleId position of new rule in array

addAccountApproveDenyOracle

Function add an Account Approve/Deny Oracle rule

function addAccountApproveDenyOracle(address _appManagerAddr, uint8 _type, address _oracleAddress)
    external
    ruleAdministratorOnly(_appManagerAddr)
    returns (uint32);

Parameters

NameTypeDescription
_appManagerAddraddressAddress of App Manager
_typeuint8type of Oracle Rule —> 0 = restricted; 1 = allowed
_oracleAddressaddressAddress of Oracle

Returns

NameTypeDescription
<none>uint32ruleId position of rule in storage

addTokenMinHoldTime

Function add an Min Hold Time rule

function addTokenMinHoldTime(address _appManagerAddr, uint32 _minHoldtime)
    external
    ruleAdministratorOnly(_appManagerAddr)
    returns (uint32);

Parameters

NameTypeDescription
_appManagerAddraddressAddress of App Manager
_minHoldtimeuint32minimum number of full hours a token must be held.

Returns

NameTypeDescription
<none>uint32ruleId position of rule in storage