Git Source

Inherits: IInputErrors, IRuleProcessorErrors, IERC20Errors

Author: @ShaneDuncan602 @oscarsernarosero @TJ-Everett

Implements Token Fee Rules on Accounts.

Facet in charge of the logic to check token rules compliance

State Variables

_VOLUME_MULTIPLIER

uint256 constant _VOLUME_MULTIPLIER = 10 ** 8;

_BASIS_POINT

uint256 constant _BASIS_POINT = 10000;

Functions

checkTokenMinTxSize

Check if transaction passes Token Min Tx Size rule.

function checkTokenMinTxSize(uint32 _ruleId, uint256 amountToTransfer) external view;

Parameters

NameTypeDescription
_ruleIduint32Rule Identifier for rule arguments
amountToTransferuint256total number of tokens to be transferred

getTokenMinTxSize

Function to get Token Min Tx Size rules by index

function getTokenMinTxSize(uint32 _index) public view returns (NonTaggedRules.TokenMinTxSize memory);

Parameters

NameTypeDescription
_indexuint32position of rule in array

Returns

NameTypeDescription
<none>NonTaggedRules.TokenMinTxSizeRule at index

getTotalTokenMinTxSize

Function to get total Token Min Tx Size rules

function getTotalTokenMinTxSize() public view returns (uint32);

Returns

NameTypeDescription
<none>uint32Total length of array

checkAccountApproveDenyOracles

This function receives an array of rule ids, which it uses to get the oracle details, then calls the oracle to determine permissions.

function checkAccountApproveDenyOracles(Rule[] memory _rules, address _address) external view;

Parameters

NameTypeDescription
_rulesRule[]Rule Id Array
_addressaddressuser address to be checked

checkAccountApproveDenyOracle

This function receives a rule id, which it uses to get the oracle details, then calls the oracle to determine permissions.

function checkAccountApproveDenyOracle(uint32 _ruleId, address _address) internal view;

Parameters

NameTypeDescription
_ruleIduint32Rule Id
_addressaddressuser address to be checked

getAccountApproveDenyOracle

If Approve List Oracle rule active, address(0) is exempt to allow for burning

Function get Account Approve Deny Oracle Rule by index

function getAccountApproveDenyOracle(uint32 _index)
    public
    view
    returns (NonTaggedRules.AccountApproveDenyOracle memory);

Parameters

NameTypeDescription
_indexuint32Position of rule in storage

Returns

NameTypeDescription
<none>NonTaggedRules.AccountApproveDenyOracleAccountApproveDenyOracle at index

getTotalAccountApproveDenyOracle

Function get total Account Approve Deny Oracle rules

function getTotalAccountApproveDenyOracle() public view returns (uint32);

Returns

NameTypeDescription
<none>uint32total accountApproveDenyOracleRules array length

checkTokenMaxTradingVolume

If the totalSupply value is set in the rule, it is set as the circulating supply. Otherwise, this function uses the ERC20 totalSupply sent from handler.

Rule checks if the Token Max Trading Volume rule will be violated.

function checkTokenMaxTradingVolume(
    uint32 _ruleId,
    uint256 _volume,
    uint256 _supply,
    uint256 _amount,
    uint64 _lastTransferTime
) external view returns (uint256);

Parameters

NameTypeDescription
_ruleIduint32Rule identifier for rule arguments
_volumeuint256token’s trading volume thus far
_supplyuint256Number of tokens in supply
_amountuint256Number of tokens to be transferred from this account
_lastTransferTimeuint64the time of the last transfer

Returns

NameTypeDescription
<none>uint256_volume new accumulated volume

getTokenMaxTradingVolume

if the totalSupply value is set in the rule, use that as the circulating supply. Otherwise, use the ERC20 totalSupply(sent from handler)

Function get Token Max Trading Volume by index

function getTokenMaxTradingVolume(uint32 _index) public view returns (NonTaggedRules.TokenMaxTradingVolume memory);

Parameters

NameTypeDescription
_indexuint32position of rule in array

Returns

NameTypeDescription
<none>NonTaggedRules.TokenMaxTradingVolumeTokenMaxTradingVolume rule at index position

getTotalTokenMaxTradingVolume

Function to get total Token Max Trading Volume rules

function getTotalTokenMaxTradingVolume() public view returns (uint32);

Returns

NameTypeDescription
<none>uint32Total length of array

checkTokenMaxSupplyVolatility

If the totalSupply value is set in the rule, it is set as the circulating supply. Otherwise, this function uses the ERC20 totalSupply sent from handler.

Rule checks if the Token Max Supply Volatility rule will be violated.

function checkTokenMaxSupplyVolatility(
    uint32 _ruleId,
    int256 _volumeTotalForPeriod,
    uint256 _tokenTotalSupply,
    uint256 _supply,
    int256 _amount,
    uint64 _lastSupplyUpdateTime
) external view returns (int256, uint256);

Parameters

NameTypeDescription
_ruleIduint32Rule identifier for rule arguments
_volumeTotalForPeriodint256token’s trading volume for the period
_tokenTotalSupplyuint256the total supply from token tallies
_supplyuint256token total supply value
_amountint256amount in the current transfer
_lastSupplyUpdateTimeuint64the last timestamp the supply was updated

Returns

NameTypeDescription
<none>int256_volumeTotalForPeriod properly adjusted total for the current period
<none>uint256_tokenTotalSupply properly adjusted token total supply. This is necessary because if the token’s total supply is used it skews results within the period

getTokenMaxSupplyVolatility

Account for the very first period The _tokenTotalSupply is not modified during the rule period. It needs to stay the same value as what it was at the beginning of the period to keep consistent results since mints/burns change totalSupply in the token. Update total supply of token when outside of rule period

Function to get Token Max Supply Volatility rule by index

function getTokenMaxSupplyVolatility(uint32 _index)
    public
    view
    returns (NonTaggedRules.TokenMaxSupplyVolatility memory);

Parameters

NameTypeDescription
_indexuint32position of rule in array

Returns

NameTypeDescription
<none>NonTaggedRules.TokenMaxSupplyVolatilitytokenMaxSupplyVolatility Rule

getTotalTokenMaxSupplyVolatility

Function to get total Token Max Supply Volatility rules

function getTotalTokenMaxSupplyVolatility() public view returns (uint32);

Returns

NameTypeDescription
<none>uint32tokenMaxSupplyVolatility Rules total length of array

checkTokenMaxBuySellVolume

Function receives a rule id, retrieves the rule data and checks if the Token Max Buy Sell Volume Rule passes

function checkTokenMaxBuySellVolume(
    uint32 ruleId,
    uint256 currentTotalSupply,
    uint256 amountToTransfer,
    uint64 lastTransactionTime,
    uint256 totalWithinPeriod
) external view returns (uint256);

Parameters

NameTypeDescription
ruleIduint32id of the rule to be checked
currentTotalSupplyuint256total supply value passed in by the handler. This is for ERC20 tokens with a fixed total supply.
amountToTransferuint256total number of tokens to be transferred in transaction.
lastTransactionTimeuint64time of the most recent purchase from AMM. This starts the check if current transaction is within a purchase window.
totalWithinPerioduint256total amount of tokens sold within current period

getTokenMaxBuySellVolume

Function get Token Max Buy Sell Volume by index

function getTokenMaxBuySellVolume(uint32 _index) public view returns (NonTaggedRules.TokenMaxBuySellVolume memory);

Parameters

NameTypeDescription
_indexuint32position of rule in array

Returns

NameTypeDescription
<none>NonTaggedRules.TokenMaxBuySellVolumetokenMaxSellVolumeRules rule at index position

getTotalTokenMaxBuySellVolume

Function to get total Token Max Buy Sell Volume rules

function getTotalTokenMaxBuySellVolume() public view returns (uint32);

Returns

NameTypeDescription
<none>uint32Total length of array