Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compliance modules fixes & improvements #228

Merged
merged 7 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
# Change Log
All notable changes to this project will be documented in this file.

## [4.1.6]

### Added

- Added **removeTimeTransferLimit** function to TimeTransferLimitsModule, allows removing time transfer limits for the given limitTime.
- Added **batchSetTimeTransferLimit** and **batchRemoveTimeTransferLimit** functions to TimeTransferLimitsModule, allows setting and removing multiple time transfer limits at once.
- Introduced **Token Listing Restrictions Module**: Investors can determine which tokens they can receive by whitelisting or blacklisting them
Token issuers can choose the listing type they prefer for their tokens:
WHITELISTING: investors must whitelist/allow the token address in order to receive it.
BLACKLISTING: investors can receive the token by default. If they do not want to receive it, they need to blacklist/disallow it.
- Added commercial licensing to all modules of compliance as they are part of Tokeny's IP.

### Update

- Updated the **moduleCheck** function of TransferRestrictModule to directly allow transfers when the _from or _to address is the null address, enabling mint and burn operations without additional restrictions.

## [4.1.5]

### Added
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// SPDX-License-Identifier: GPL-3.0
// This contract is also licensed under the Creative Commons Attribution-NonCommercial 4.0 International License.
//
// :+#####%%%%%%%%%%%%%%+
// .-*@@@%+.:+%@@@@@%%#***%@@%=
Expand Down Expand Up @@ -44,7 +45,7 @@
* T-REX is a suite of smart contracts implementing the ERC-3643 standard and
* developed by Tokeny to manage and transfer financial assets on EVM blockchains
*
* Copyright (C) 2023, Tokeny sàrl.
* Copyright (C) 2024, Tokeny sàrl.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -58,6 +59,11 @@
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* This specific smart contract is also licensed under the Creative Commons
* Attribution-NonCommercial 4.0 International License (CC-BY-NC-4.0),
* which prohibits commercial use. For commercial inquiries, please contact
* Tokeny sàrl for licensing options.
*/

pragma solidity 0.8.17;
Expand Down
8 changes: 7 additions & 1 deletion contracts/compliance/modular/modules/CountryAllowModule.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// SPDX-License-Identifier: GPL-3.0
// This contract is also licensed under the Creative Commons Attribution-NonCommercial 4.0 International License.
//
// :+#####%%%%%%%%%%%%%%+
// .-*@@@%+.:+%@@@@@%%#***%@@%=
Expand Down Expand Up @@ -44,7 +45,7 @@
* T-REX is a suite of smart contracts implementing the ERC-3643 standard and
* developed by Tokeny to manage and transfer financial assets on EVM blockchains
*
* Copyright (C) 2023, Tokeny sàrl.
* Copyright (C) 2024, Tokeny sàrl.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -58,6 +59,11 @@
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* This specific smart contract is also licensed under the Creative Commons
* Attribution-NonCommercial 4.0 International License (CC-BY-NC-4.0),
* which prohibits commercial use. For commercial inquiries, please contact
* Tokeny sàrl for licensing options.
*/

pragma solidity 0.8.17;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// SPDX-License-Identifier: GPL-3.0
// This contract is also licensed under the Creative Commons Attribution-NonCommercial 4.0 International License.
//
// :+#####%%%%%%%%%%%%%%+
// .-*@@@%+.:+%@@@@@%%#***%@@%=
Expand Down Expand Up @@ -44,7 +45,7 @@
* T-REX is a suite of smart contracts implementing the ERC-3643 standard and
* developed by Tokeny to manage and transfer financial assets on EVM blockchains
*
* Copyright (C) 2023, Tokeny sàrl.
* Copyright (C) 2024, Tokeny sàrl.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -58,6 +59,11 @@
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* This specific smart contract is also licensed under the Creative Commons
* Attribution-NonCommercial 4.0 International License (CC-BY-NC-4.0),
* which prohibits commercial use. For commercial inquiries, please contact
* Tokeny sàrl for licensing options.
*/

pragma solidity 0.8.17;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// SPDX-License-Identifier: GPL-3.0
// This contract is also licensed under the Creative Commons Attribution-NonCommercial 4.0 International License.
//
// :+#####%%%%%%%%%%%%%%+
// .-*@@@%+.:+%@@@@@%%#***%@@%=
Expand Down Expand Up @@ -44,7 +45,7 @@
* T-REX is a suite of smart contracts implementing the ERC-3643 standard and
* developed by Tokeny to manage and transfer financial assets on EVM blockchains
*
* Copyright (C) 2023, Tokeny sàrl.
* Copyright (C) 2024, Tokeny sàrl.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -58,6 +59,11 @@
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* This specific smart contract is also licensed under the Creative Commons
* Attribution-NonCommercial 4.0 International License (CC-BY-NC-4.0),
* which prohibits commercial use. For commercial inquiries, please contact
* Tokeny sàrl for licensing options.
*/

pragma solidity 0.8.17;
Expand Down
8 changes: 7 additions & 1 deletion contracts/compliance/modular/modules/MaxBalanceModule.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// SPDX-License-Identifier: GPL-3.0
// This contract is also licensed under the Creative Commons Attribution-NonCommercial 4.0 International License.
//
// :+#####%%%%%%%%%%%%%%+
// .-*@@@%+.:+%@@@@@%%#***%@@%=
Expand Down Expand Up @@ -44,7 +45,7 @@
* T-REX is a suite of smart contracts implementing the ERC-3643 standard and
* developed by Tokeny to manage and transfer financial assets on EVM blockchains
*
* Copyright (C) 2023, Tokeny sàrl.
* Copyright (C) 2024, Tokeny sàrl.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -58,6 +59,11 @@
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* This specific smart contract is also licensed under the Creative Commons
* Attribution-NonCommercial 4.0 International License (CC-BY-NC-4.0),
* which prohibits commercial use. For commercial inquiries, please contact
* Tokeny sàrl for licensing options.
*/

pragma solidity 0.8.17;
Expand Down
8 changes: 7 additions & 1 deletion contracts/compliance/modular/modules/SupplyLimitModule.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// SPDX-License-Identifier: GPL-3.0
// This contract is also licensed under the Creative Commons Attribution-NonCommercial 4.0 International License.
//
// :+#####%%%%%%%%%%%%%%+
// .-*@@@%+.:+%@@@@@%%#***%@@%=
Expand Down Expand Up @@ -44,7 +45,7 @@
* T-REX is a suite of smart contracts implementing the ERC-3643 standard and
* developed by Tokeny to manage and transfer financial assets on EVM blockchains
*
* Copyright (C) 2023, Tokeny sàrl.
* Copyright (C) 2024, Tokeny sàrl.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -58,6 +59,11 @@
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* This specific smart contract is also licensed under the Creative Commons
* Attribution-NonCommercial 4.0 International License (CC-BY-NC-4.0),
* which prohibits commercial use. For commercial inquiries, please contact
* Tokeny sàrl for licensing options.
*/

pragma solidity ^0.8.17;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// SPDX-License-Identifier: GPL-3.0
// This contract is also licensed under the Creative Commons Attribution-NonCommercial 4.0 International License.
//
// :+#####%%%%%%%%%%%%%%+
// .-*@@@%+.:+%@@@@@%%#***%@@%=
Expand Down Expand Up @@ -44,7 +45,7 @@
* T-REX is a suite of smart contracts implementing the ERC-3643 standard and
* developed by Tokeny to manage and transfer financial assets on EVM blockchains
*
* Copyright (C) 2023, Tokeny sàrl.
* Copyright (C) 2024, Tokeny sàrl.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -58,6 +59,11 @@
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* This specific smart contract is also licensed under the Creative Commons
* Attribution-NonCommercial 4.0 International License (CC-BY-NC-4.0),
* which prohibits commercial use. For commercial inquiries, please contact
* Tokeny sàrl for licensing options.
*/

pragma solidity 0.8.17;
Expand Down
99 changes: 83 additions & 16 deletions contracts/compliance/modular/modules/TimeTransfersLimitsModule.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// SPDX-License-Identifier: GPL-3.0
// This contract is also licensed under the Creative Commons Attribution-NonCommercial 4.0 International License.
//
// :+#####%%%%%%%%%%%%%%+
// .-*@@@%+.:+%@@@@@%%#***%@@%=
Expand Down Expand Up @@ -44,7 +45,7 @@
* T-REX is a suite of smart contracts implementing the ERC-3643 standard and
* developed by Tokeny to manage and transfer financial assets on EVM blockchains
*
* Copyright (C) 2023, Tokeny sàrl.
* Copyright (C) 2024, Tokeny sàrl.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -58,6 +59,11 @@
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* This specific smart contract is also licensed under the Creative Commons
* Attribution-NonCommercial 4.0 International License (CC-BY-NC-4.0),
* which prohibits commercial use. For commercial inquiries, please contact
* Tokeny sàrl for licensing options.
*/

pragma solidity 0.8.17;
Expand Down Expand Up @@ -96,14 +102,24 @@ contract TimeTransfersLimitsModule is AbstractModuleUpgradeable {
/**
* this event is emitted whenever a transfer limit is updated for the given compliance address and limit time
* the event is emitted by 'setTimeTransferLimit'.
* compliance`is the compliance contract address
* compliance is the compliance contract address
* _limitValue is the new limit value for the given limit time
* _limitTime is the period of time of the limit
*/
event TimeTransferLimitUpdated(address indexed compliance, uint32 limitTime, uint256 limitValue);

/**
* this event is emitted whenever a transfer limit is removed for the given compliance address and limit time
* the event is emitted by 'removeTimeTransferLimit'.
* compliance is the compliance contract address
* _limitTime is the period of time of the limit
*/
event TimeTransferLimitRemoved(address indexed compliance, uint32 limitTime);

error LimitsArraySizeExceeded(address compliance, uint arraySize);

error LimitTimeNotFound(address compliance, uint limitTime);

/**
* @dev initializes the contract and sets the initial state.
* @notice This function should only be called once during the contract deployment.
Expand All @@ -113,24 +129,25 @@ contract TimeTransfersLimitsModule is AbstractModuleUpgradeable {
}

/**
* @dev Sets the limit of tokens allowed to be transferred in the given time frame.
* @param _limit The limit time and value
* @dev Sets multiple limit of tokens allowed to be transferred in the given time frame.
* @param _limits The array of limit time and values
* Only the owner of the Compliance smart contract can call this function
*/
function setTimeTransferLimit(Limit calldata _limit) external onlyComplianceCall {
bool limitIsAttributed = limitValues[msg.sender][_limit.limitTime].attributedLimit;
uint8 limitCount = uint8(transferLimits[msg.sender].length);
if (!limitIsAttributed && limitCount >= 4) {
revert LimitsArraySizeExceeded(msg.sender, limitCount);
}
if (!limitIsAttributed && limitCount < 4) {
transferLimits[msg.sender].push(_limit);
limitValues[msg.sender][_limit.limitTime] = IndexLimit(true, limitCount);
} else {
transferLimits[msg.sender][limitValues[msg.sender][_limit.limitTime].limitIndex] = _limit;
function batchSetTimeTransferLimit(Limit[] calldata _limits) external {
for (uint256 i = 0; i < _limits.length; i++) {
setTimeTransferLimit(_limits[i]);
}
}

emit TimeTransferLimitUpdated(msg.sender, _limit.limitTime, _limit.limitValue);
/**
* @dev Removes multiple limits for the given limit time values.
* @param _limitTimes The array of limit times
* Only the owner of the Compliance smart contract can call this function
**/
function batchRemoveTimeTransferLimit(uint32[] calldata _limitTimes) external {
for (uint256 i = 0; i < _limitTimes.length; i++) {
removeTimeTransferLimit(_limitTimes[i]);
}
}

/**
Expand Down Expand Up @@ -208,6 +225,56 @@ contract TimeTransfersLimitsModule is AbstractModuleUpgradeable {
return true;
}

/**
* @dev Sets the limit of tokens allowed to be transferred in the given time frame.
* @param _limit The limit time and value
* Only the owner of the Compliance smart contract can call this function
*/
function setTimeTransferLimit(Limit calldata _limit) public onlyComplianceCall {
bool limitIsAttributed = limitValues[msg.sender][_limit.limitTime].attributedLimit;
uint8 limitCount = uint8(transferLimits[msg.sender].length);
if (!limitIsAttributed && limitCount >= 4) {
revert LimitsArraySizeExceeded(msg.sender, limitCount);
}
if (!limitIsAttributed && limitCount < 4) {
transferLimits[msg.sender].push(_limit);
limitValues[msg.sender][_limit.limitTime] = IndexLimit(true, limitCount);
} else {
transferLimits[msg.sender][limitValues[msg.sender][_limit.limitTime].limitIndex] = _limit;
}

emit TimeTransferLimitUpdated(msg.sender, _limit.limitTime, _limit.limitValue);
}

/**
* @dev Removes the limit for the given limit time value.
* @param _limitTime The limit time
* Only the owner of the Compliance smart contract can call this function
*/
function removeTimeTransferLimit(uint32 _limitTime) public onlyComplianceCall {
bool limitFound = false;
uint256 index;
for (uint256 i = 0; i < transferLimits[msg.sender].length; i++) {
if (transferLimits[msg.sender][i].limitTime == _limitTime) {
limitFound = true;
index = i;
break;
}
}

if (!limitFound) {
revert LimitTimeNotFound(msg.sender, _limitTime);
}

if (transferLimits[msg.sender].length > 1 && index != transferLimits[msg.sender].length - 1) {
transferLimits[msg.sender][index] = transferLimits[msg.sender][transferLimits[msg.sender].length - 1];
}

transferLimits[msg.sender].pop();
delete limitValues[msg.sender][_limitTime];
emit TimeTransferLimitRemoved(msg.sender, _limitTime);
}

/**
* @dev See {IModule-name}.
*/
Expand Down
Loading
Loading