Time Based Exchange Limits Module
This module enforces restrictions on the volume of tokens a holder can transfer to centralized exchanges (CEXs) within a specified timeframe. The timeframe is customizable, allowing issuers to set daily, weekly, monthly, or any custom period limits. This flexibility ensures adaptability to a wide range of regulatory and policy requirements.
How Does It Work?
- ExchangeIDs are global and can be added/removed by the contract owner.
- Compliance contracts set the limits that will apply to exchangeIDs. There can be more than one limit definition for an exchange in the
TimeExchangeLimitsModule
(a maximum of 4). Each limit contains time (in seconds) and value. (for example, 1000 tokens can be transferred monthly -2592000 seconds-). - There are transfer counters for each investor. When an investor transfers tokens to an exchange, the total transferred amounts in the counters are updated.
TimeExchangeLimitsModule
has separate investor counters for all limits defined for the exchange, and all counters are updated during the transfer. - Investor counters are reset when their period ends.
- The transfer transaction is blocked if the investor's counter value exceeds the limit defined for the exchange.
Integration Guide
To integrate the TimeExchangeLimitsModule
into your ERC-3643 token's compliance system:
- call
addModule
on yourModularCompliance
contract with the address of theTimeExchangeLimitsModule
. - Call setExchangeLimit with the desired limit through
callModuleFunction
. - Token holders can now send tokens to exchanges respecting maximum deposit limits on a time basis.
Events
ComplianceBound
This event is emitted when the compliance contract is bound to the module
the event is emitted by 'bindCompliance'
_compliance
is the address of the compliance contract being bound
event ComplianceBound(
address indexed _compliance
);
ComplianceUnbound
This event is emitted when the compliance contract is unbound from the module
the event is emitted by 'unbindCompliance'
_compliance
is the address of the compliance contract being unbound
event ComplianceUnbound(
address indexed _compliance
);
ExchangeLimitUpdated
This event is emitted whenever an exchange limit is updated for the given compliance address and the limit time
the event is emitted by 'setExchangeLimit'
compliance
is the compliance contract address
_exchangeID
is the ONCHAINID of the exchange
_limitValue
is the new limit value for the given limit time
_limitTime
is the time of the limit
event ExchangeLimitUpdated(
address indexed compliance,
address _exchangeID,
uint _limitValue,
uint32 _limitTime
);
ExchangeIDAdded
This event is emitted whenever an ONCHAINID is tagged as an exchange ID
the event is emitted by 'addExchangeID'
_newExchangeID
is the ONCHAINID address of the exchange to add
event ExchangeIDAdded(
address _newExchangeID
);
ExchangeIDRemoved
This event is emitted whenever an ONCHAINID is untagged as belonging to an exchange
the event is emitted by 'removeExchangeID'
_exchangeID
is the ONCHAINID being untagged as an exchange ID
event ExchangeIDRemoved(
address _exchangeID
);
Functions
bindCompliance
Binds the module to a compliance contract. Once the module is bound, the compliance contract can interact with the module.
parameter 1: _compliance
the address of the compliance contract
emits a ComplianceBound
event
This function can be called ONLY by the compliance contract itself (_compliance), through the addModule function, which calls bindCompliance the module cannot be already bound to the compliance.
function bindCompliance(
address _compliance
) external;
unbindCompliance
Unbinds the module from a compliance contract. Once the module is unbound, the compliance contract cannot interact with the module anymore.
parameter 1: _compliance
the address of the compliance contract.
emits a ComplianceUnbound
event
This function can be called ONLY by the compliance contract itself (_compliance), removeModule function, which calls unbindCompliance.
function unbindCompliance(
address _compliance
) external;
isComplianceBound
Getter for compliance binding status on module
parameter 1: _compliance
the address of the compliance contract.
returns TRUE if the compliance is bound to the module, FALSE otherwise
function isComplianceBound(
address _compliance
) external view returns (bool);
setExchangeLimit
Sets the limit of tokens allowed to be transferred to the given exchange in a given period of time
This function can only be called by a compliance smart contract
parameter 1: _exchangeID
The ONCHAINID of the exchange
parameter 2: _limit
Limit time and value
emits an ExchangeLimitUpdated
event
function setExchangeLimit(
address _exchangeID,
Limit memory _limit
) external;
addExchangeID
Tags the ONCHAINID as being an exchange ID
Cannot be called on an address already tagged as being an exchange
This function can only be called by the owner of this module
parameter 1: _exchangeID
The ONCHAINID of the exchange
emits an ExchangeIDAdded
event
function addExchangeID(
address _exchangeID
) external;
removeExchangeID
Untags the ONCHAINID as being an exchange ID
Cannot be called on an address not tagged as being an exchange
This function can only be called by the owner of this module
parameter 1: _exchangeID
The ONCHAINID of the exchange
emits an ExchangeIDRemoved
event
function removeExchangeID(
address _exchangeID
) external;
getExchangeCounter
Function for getting exchange counter for the given exchange ID, investorID, and limit time.
parameter 1: compliance
the compliance smart contract address
parameter 2: _exchangeID
the ONCHAINID of the exchange
parameter 3: _investorID
the ONCHAINID of the investor
parameter 4: _limitTime
the limit time frame
Returns the counter of the given _limitTime
, _investorID
, and exchangeID
function getExchangeCounter(
address compliance,
address _exchangeID,
address _investorID,
uint32 _limitTime
) external view returns (ExchangeTransferCounter memory);
getExchangeLimits
Function for getting exchange limits for the given exchange ID.
parameter 1: compliance
the compliance smart contract address
parameter 2: _exchangeID
the ONCHAINID of the exchange
Returns the array of limits set for that exchange.
function getExchangeLimits(
address compliance,
address _exchangeID
) external view returns (Limit[] memory);
isExchangeID
Function for checking if an ONCHAIN id address is tagged as an exchange.
parameter 1: _exchangeID
the ONCHAINID of the exchange
returns TRUE if the address corresponds to an exchange, FALSE otherwise
function isExchangeID(
address _exchangeID
) public view returns (bool);
moduleCheck
The compliance check on the module for a specific transaction on a specific compliance contract. This function is used to check if the transfer is allowed by the module.
parameter 1: _from
the address of the transfer sender
parameter 2: _to
the address of the transfer receiver
parameter 3: _value
the amount of tokens sent
parameter 4: _compliance
the address of the compliance contract concerned by the transfer action
Returns TRUE if the module allows the transfer, FALSE otherwise
function moduleCheck(
address _from,
address _to,
uint256 _value,
address _compliance
) external view;
moduleTransferAction
The action performed on the module during a transfer action. It increases the monthly counter value if the _to
is being tagged as an exchange.
parameter 1: _from
the address of the transfer sender
parameter 2: _to
the address of the transfer receiver
parameter 3: _value
the amount of tokens sent
This function can be called only on a compliance contract that is bound to the module
function moduleTransferAction(
address _from,
address _to,
uint256 _value
) external;
moduleMintAction
The action performed on the module during a mint action. This function is used to update variables of the module upon minting if it is required. This function is not implemented in this contract.
parameter 1: _to
the address used for minting
parameter 2: _value
the amount of tokens minted
This function can be called only on a compliance contract that is bound to the module
function moduleMintAction(
address _to,
uint256 _value
) external;
moduleBurnAction
The action performed on the module during a burn action. This function is used to update variables of the module upon burning if it is required. This function is not implemented in this contract.
parameter 1: _from
the address on which tokens are burnt
parameter 2: _value
the amount of tokens burnt
This function can be called only on a compliance contract that is bound to the module
function moduleBurnAction(
address _from,
uint256 _value
) external;
upgradeTo (UUPS)
Upgrade the implementation of the proxy to newImplementation
parameter 1: newImplementation
the address of the new implementation contract.
This function can only be called by the proxy contract.
function upgradeTo(address newImplementation) public;
Updated 4 months ago