Overview
ETH Balance
0 ETH
Eth Value
$0.00More Info
Private Name Tags
ContractCreator
Latest 1 from a total of 1 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Init | 21765983 | 15 days ago | IN | 0 ETH | 0.00128217 |
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.
Similar Match Source Code This contract matches the deployed Bytecode of the Source Code for Contract 0xB36aAB33...98108E075 The constructor portion of the code might be different and could alter the actual behaviour of the contract
Contract Name:
FrictionlessFXSwap
Compiler Version
v0.8.17+commit.8df45f5f
Optimization Enabled:
Yes with 1000 runs
Other Settings:
london EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT /** * Copyright © 2024 Frictionless Group Holdings S.à.r.l * * Permission is hereby granted, free of charge, to any person obtaining a copy of the Frictionless protocol smart contracts * (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, * modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies * or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL FRICTIONLESS GROUP * HOLDINGS S.à.r.l OR AN OF ITS SUBSIDIARIES BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ pragma solidity ^0.8.16; import { IERC20 } from "@openzeppelin/contracts/interfaces/IERC20.sol"; import { Math } from "@openzeppelin/contracts/utils/math/Math.sol"; import { UUPSUpgradeable } from "@openzeppelin/contracts/proxy/utils/UUPSUpgradeable.sol"; import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import { OwnableUpgradeable } from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import { IFrictionlessTreasuryManager } from "@interface/IFrictionlessTreasuryManager.sol"; import { IFrictionlessPermissionsManager } from "@interface/IFrictionlessPermissionsManager.sol"; import { IFrictionlessFXSwap } from "@interface/IFrictionlessFXSwap.sol"; import { AbstractFeeModule } from "@abstract/AbstractFeeModule.sol"; /** * @title FrictionlessFXSwap - Implementation of the `IFrictionlessFXSwap` * @author Frictionless Group Holdings S.à.r.l * @notice See {IFrictionlessFXSwap} */ contract FrictionlessFXSwap is IFrictionlessFXSwap, OwnableUpgradeable, AbstractFeeModule, UUPSUpgradeable { uint256 public constant EXCHANGE_RATE_PRECISION = 10 ** 18; /// @inheritdoc IFrictionlessFXSwap address public override fxDeskFeeAddr; /// @inheritdoc IFrictionlessFXSwap IFrictionlessTreasuryManager public override treasuryManager; /// @inheritdoc IFrictionlessFXSwap IFrictionlessPermissionsManager public override permissionManager; /// @dev maintains the maximum set fee on a token FX SWap mapping(bytes32 => uint256) private _maxAbsoluteFeesInfo; modifier onlyTreasury() { _onlyTreasury(); _; } function init(address treasuryManager_, address permissionManager_, address fxDeskFeeAddr_) external initializer { __Ownable_init(); treasuryManager = IFrictionlessTreasuryManager(treasuryManager_); permissionManager = IFrictionlessPermissionsManager(permissionManager_); fxDeskFeeAddr = fxDeskFeeAddr_; } /// @inheritdoc IFrictionlessFXSwap function setFXDeskFeeAddr(address newFXDeskFeeAddr_) external override onlyOwner { fxDeskFeeAddr = newFXDeskFeeAddr_; } /// @inheritdoc IFrictionlessFXSwap function setSwapFees( FrictionlessTokenFXFeeInfo calldata token0FeeInfo_, FrictionlessTokenFXFeeInfo calldata token1FeeInfo_ ) external override onlyOwner { (bytes32 tokenFeeKey0_, bytes32 tokenFeeKey1_) = getSwapFeeKeys( token0FeeInfo_.tokenAddr, token1FeeInfo_.tokenAddr ); if (tokenFeeKey0_ == tokenFeeKey1_) { revert FrictionlessFXSwapInvalidTokenAddresses(token0FeeInfo_.tokenAddr, token1FeeInfo_.tokenAddr); } _maxAbsoluteFeesInfo[tokenFeeKey0_] = token0FeeInfo_.feeAbsoluteLimit; _maxAbsoluteFeesInfo[tokenFeeKey1_] = token1FeeInfo_.feeAbsoluteLimit; _setTokenFee(tokenFeeKey0_, token0FeeInfo_.feeInfo); _setTokenFee(tokenFeeKey1_, token1FeeInfo_.feeInfo); } /// @inheritdoc IFrictionlessFXSwap function setTokenFee( bytes32 tokenFeeKey_, FrictionlessTokenFXFeeInfo calldata tokenFeeInfo_ ) external override onlyOwner { _maxAbsoluteFeesInfo[tokenFeeKey_] = tokenFeeInfo_.feeAbsoluteLimit; _setTokenFee(tokenFeeKey_, tokenFeeInfo_.feeInfo); } /// @inheritdoc IFrictionlessFXSwap function swapTokens( address sellingTokenAddr_, address buyingTokenAddr_, address tokenSender_, address tokenRecipient_, uint256 buyingTokensAmount_, uint256 buyingTokenExchangeRate_ ) external override onlyTreasury { uint256 sellingTokensAmount_ = getSellingTokensAmount(buyingTokensAmount_, buyingTokenExchangeRate_); bytes32 tokenFeeKey0_ = getTokenFeeKey(sellingTokenAddr_, buyingTokenAddr_); FeeInfo memory tokenFeeInfo_ = getFeeInfo(tokenFeeKey0_); uint256 feeAmount_ = calculateFeeAmount(sellingTokensAmount_, tokenFeeInfo_.feeInBps); uint256 maxFeeAmount_ = _maxAbsoluteFeesInfo[tokenFeeKey0_]; if (maxFeeAmount_ > 0) { feeAmount_ = Math.min(feeAmount_, maxFeeAmount_); } if (feeAmount_ > 0) { _validateFeeRecipientAddr(tokenFeeInfo_); treasuryManager.transferToken(sellingTokenAddr_, tokenSender_, tokenFeeInfo_.feeRecipientAddr, feeAmount_); } treasuryManager.burnToken(sellingTokenAddr_, tokenSender_, sellingTokensAmount_ - feeAmount_); treasuryManager.mintTokenForUser(buyingTokenAddr_, tokenRecipient_, buyingTokensAmount_); emit FrictionlessFXTokensSwapped( sellingTokenAddr_, buyingTokenAddr_, tokenSender_, tokenRecipient_, sellingTokensAmount_, buyingTokensAmount_, buyingTokenExchangeRate_ ); } /// @inheritdoc IFrictionlessFXSwap function getSwapFeesInfo( address token0_, address token1_ ) external view override returns (FeeInfo memory, FeeInfo memory) { (bytes32 tokenFeeKey0_, bytes32 tokenFeeKey1_) = getSwapFeeKeys(token0_, token1_); return (getFeeInfo(tokenFeeKey0_), getFeeInfo(tokenFeeKey1_)); } /// @inheritdoc IFrictionlessFXSwap function getSwapFeeKeys(address token0_, address token1_) public pure override returns (bytes32, bytes32) { return (getTokenFeeKey(token0_, token1_), getTokenFeeKey(token1_, token0_)); } /// @inheritdoc IFrictionlessFXSwap function getTokenFeeKey(address token0_, address token1_) public pure override returns (bytes32) { return keccak256(abi.encodePacked(token0_, token1_)); } /// @inheritdoc IFrictionlessFXSwap function getSellingTokensAmount( uint256 buyingTokensAmount_, uint256 buyingTokenExchangeRate_ ) public pure returns (uint256) { return (buyingTokensAmount_ * buyingTokenExchangeRate_) / EXCHANGE_RATE_PRECISION; } function _setTokenFee(bytes32 feeKey_, FeeInfo memory feeInfo_) internal virtual override { _validateFeeRecipientAddr(feeInfo_); super._setTokenFee(feeKey_, feeInfo_); } // solhint-disable-next-line no-empty-blocks function _authorizeUpgrade(address) internal virtual override onlyOwner {} function _onlyTreasury() internal view { if ( !permissionManager.hasClaim( msg.sender, IFrictionlessPermissionsManager.FrictionlessPermissionedUser.PROTOCOL_TREASURY ) ) { revert FrictionlessFXSwapNotEnoughPermissions(); } } function _validateFeeRecipientAddr(FeeInfo memory feeInfo_) internal view { if (feeInfo_.feeRecipientAddr != fxDeskFeeAddr) { revert FrictionlessFXSwapInvalidFeeRecipientAddr(feeInfo_.feeRecipientAddr); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (interfaces/IERC20.sol) pragma solidity ^0.8.0; import "../token/ERC20/IERC20.sol";
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol) pragma solidity ^0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { enum Rounding { Down, // Toward negative infinity Up, // Toward infinity Zero // Toward zero } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a > b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds up instead * of rounding down. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b - 1) / b can overflow on addition, so we distribute. return a == 0 ? 0 : (a - 1) / b + 1; } /** * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) * with further edits by Uniswap Labs also under MIT license. */ function mulDiv( uint256 x, uint256 y, uint256 denominator ) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2^256 + prod0. uint256 prod0; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod0 := mul(x, y) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division. if (prod1 == 0) { return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. require(denominator > prod1); /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0]. uint256 remainder; assembly { // Compute remainder using mulmod. remainder := mulmod(x, y, denominator) // Subtract 256 bit number from 512 bit number. prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1. // See https://cs.stackexchange.com/q/138556/92363. // Does not overflow because the denominator cannot be zero at this stage in the function. uint256 twos = denominator & (~denominator + 1); assembly { // Divide denominator by twos. denominator := div(denominator, twos) // Divide [prod1 prod0] by twos. prod0 := div(prod0, twos) // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one. twos := add(div(sub(0, twos), twos), 1) } // Shift in bits from prod1 into prod0. prod0 |= prod1 * twos; // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for // four bits. That is, denominator * inv = 1 mod 2^4. uint256 inverse = (3 * denominator) ^ 2; // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works // in modular arithmetic, doubling the correct bits in each step. inverse *= 2 - denominator * inverse; // inverse mod 2^8 inverse *= 2 - denominator * inverse; // inverse mod 2^16 inverse *= 2 - denominator * inverse; // inverse mod 2^32 inverse *= 2 - denominator * inverse; // inverse mod 2^64 inverse *= 2 - denominator * inverse; // inverse mod 2^128 inverse *= 2 - denominator * inverse; // inverse mod 2^256 // Because the division is now exact we can divide by multiplying with the modular inverse of denominator. // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inverse; return result; } } /** * @notice Calculates x * y / denominator with full precision, following the selected rounding direction. */ function mulDiv( uint256 x, uint256 y, uint256 denominator, Rounding rounding ) internal pure returns (uint256) { uint256 result = mulDiv(x, y, denominator); if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) { result += 1; } return result; } /** * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down. * * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11). */ function sqrt(uint256 a) internal pure returns (uint256) { if (a == 0) { return 0; } // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target. // // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`. // // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)` // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))` // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)` // // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit. uint256 result = 1 << (log2(a) >> 1); // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128, // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision // into the expected uint128 result. unchecked { result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; return min(result, a / result); } } /** * @notice Calculates sqrt(a), following the selected rounding direction. */ function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = sqrt(a); return result + (rounding == Rounding.Up && result * result < a ? 1 : 0); } } /** * @dev Return the log in base 2, rounded down, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 128; } if (value >> 64 > 0) { value >>= 64; result += 64; } if (value >> 32 > 0) { value >>= 32; result += 32; } if (value >> 16 > 0) { value >>= 16; result += 16; } if (value >> 8 > 0) { value >>= 8; result += 8; } if (value >> 4 > 0) { value >>= 4; result += 4; } if (value >> 2 > 0) { value >>= 2; result += 2; } if (value >> 1 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 2, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log2(value); return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0); } } /** * @dev Return the log in base 10, rounded down, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >= 10**64) { value /= 10**64; result += 64; } if (value >= 10**32) { value /= 10**32; result += 32; } if (value >= 10**16) { value /= 10**16; result += 16; } if (value >= 10**8) { value /= 10**8; result += 8; } if (value >= 10**4) { value /= 10**4; result += 4; } if (value >= 10**2) { value /= 10**2; result += 2; } if (value >= 10**1) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log10(value); return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0); } } /** * @dev Return the log in base 256, rounded down, of a positive value. * Returns 0 if given 0. * * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string. */ function log256(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 16; } if (value >> 64 > 0) { value >>= 64; result += 8; } if (value >> 32 > 0) { value >>= 32; result += 4; } if (value >> 16 > 0) { value >>= 16; result += 2; } if (value >> 8 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log256(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log256(value); return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (proxy/utils/UUPSUpgradeable.sol) pragma solidity ^0.8.0; import "../../interfaces/draft-IERC1822.sol"; import "../ERC1967/ERC1967Upgrade.sol"; /** * @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an * {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy. * * A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is * reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing * `UUPSUpgradeable` with a custom implementation of upgrades. * * The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism. * * _Available since v4.1._ */ abstract contract UUPSUpgradeable is IERC1822Proxiable, ERC1967Upgrade { /// @custom:oz-upgrades-unsafe-allow state-variable-immutable state-variable-assignment address private immutable __self = address(this); /** * @dev Check that the execution is being performed through a delegatecall call and that the execution context is * a proxy contract with an implementation (as defined in ERC1967) pointing to self. This should only be the case * for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a * function through ERC1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to * fail. */ modifier onlyProxy() { require(address(this) != __self, "Function must be called through delegatecall"); require(_getImplementation() == __self, "Function must be called through active proxy"); _; } /** * @dev Check that the execution is not being performed through a delegate call. This allows a function to be * callable on the implementing contract but not through proxies. */ modifier notDelegated() { require(address(this) == __self, "UUPSUpgradeable: must not be called through delegatecall"); _; } /** * @dev Implementation of the ERC1822 {proxiableUUID} function. This returns the storage slot used by the * implementation. It is used to validate the implementation's compatibility when performing an upgrade. * * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this * function revert if invoked through a proxy. This is guaranteed by the `notDelegated` modifier. */ function proxiableUUID() external view virtual override notDelegated returns (bytes32) { return _IMPLEMENTATION_SLOT; } /** * @dev Upgrade the implementation of the proxy to `newImplementation`. * * Calls {_authorizeUpgrade}. * * Emits an {Upgraded} event. */ function upgradeTo(address newImplementation) external virtual onlyProxy { _authorizeUpgrade(newImplementation); _upgradeToAndCallUUPS(newImplementation, new bytes(0), false); } /** * @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call * encoded in `data`. * * Calls {_authorizeUpgrade}. * * Emits an {Upgraded} event. */ function upgradeToAndCall(address newImplementation, bytes memory data) external payable virtual onlyProxy { _authorizeUpgrade(newImplementation); _upgradeToAndCallUUPS(newImplementation, data, true); } /** * @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by * {upgradeTo} and {upgradeToAndCall}. * * Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}. * * ```solidity * function _authorizeUpgrade(address) internal override onlyOwner {} * ``` */ function _authorizeUpgrade(address newImplementation) internal virtual; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.0; import "../IERC20.sol"; import "../extensions/draft-IERC20Permit.sol"; import "../../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using Address for address; function safeTransfer( IERC20 token, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom( IERC20 token, address from, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove( IERC20 token, address spender, uint256 value ) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance( IERC20 token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance( IERC20 token, address spender, uint256 value ) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); uint256 newAllowance = oldAllowance - value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } } function safePermit( IERC20Permit token, address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) internal { uint256 nonceBefore = token.nonces(owner); token.permit(owner, spender, value, deadline, v, r, s); uint256 nonceAfter = token.nonces(owner); require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed"); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/ContextUpgradeable.sol"; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ function __Ownable_init() internal onlyInitializing { __Ownable_init_unchained(); } function __Ownable_init_unchained() internal onlyInitializing { _transferOwnership(_msgSender()); } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { _checkOwner(); _; } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if the sender is not the owner. */ function _checkOwner() internal view virtual { require(owner() == _msgSender(), "Ownable: caller is not the owner"); } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby disabling any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; }
// SPDX-License-Identifier: MIT /** * Copyright © 2024 Frictionless Group Holdings S.à.r.l * * Permission is hereby granted, free of charge, to any person obtaining a copy of the Frictionless protocol smart contracts * (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, * modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies * or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL FRICTIONLESS GROUP * HOLDINGS S.à.r.l OR AN OF ITS SUBSIDIARIES BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ pragma solidity ^0.8.16; import { IBasicFrictionlessToken } from "@interface/IBasicFrictionlessToken.sol"; import { IFrictionlessDigitalSecurityToken } from "@interface/IFrictionlessDigitalSecurityToken.sol"; import { IFrictionlessFundDepositToken } from "@interface/IFrictionlessFundDepositToken.sol"; import { IFrictionlessOnChainAssetToken } from "@interface/IFrictionlessOnChainAssetToken.sol"; /** * @title IFrictionlessTreasuryManager - Manages the minting, transfer and burning of all tokens in the Frictionless protocol * @author Frictionless Group Holdings S.à.r.l * @notice The IFrictionlessTreasuryManager is responsible for all token operations, minting, transferring and burning in * the Frictionless protocol. The tokens and their lifecycles are defined in the public README for the Frictionless protocol at * https://gitlab.com/dfyclabs/protocol/dfyclabs-tokens/-/tree/main?ref_type=heads#tokens-overview */ interface IFrictionlessTreasuryManager { /** * @dev Structure that encapsulates both the implAuthority and the compliance for the specific token. * @param implAuthority the contract address for the implementation authority associated with the specific Frictionless token type. * @param tokenType the Frictionless token type as specified by the enumeration `IBasicFrictionlessToken.FrictionlessTokenTypes` */ struct FrictionlessTokenInitData { address implAuthority; IBasicFrictionlessToken.FrictionlessTokenTypes tokenType; } /// @dev throws if specific address is zero. error FrictionlessIsZeroAddress(string); /** * @dev Event emitted when a `FrictionlessFundDeposit`, `FrictionlessDigitalSecurity` or `FrictionlessOnChainAsset` is minted. * @param token the address of the token minted * @param tokenName the name of the token * @param tokenSymbol the token symbol * @param amount the amount of the token minted * @param toAddress the address the token was minted to */ event FrictionlessTokenMinted( IBasicFrictionlessToken.FrictionlessTokenTypes tokenType, address token, string tokenName, string tokenSymbol, uint256 amount, address toAddress ); /** * @dev Event emitted when a `FrictionlessFundDeposit`, `FrictionlessDigitalSecurity` or `FrictionlessOnChainAsset` is transferred. * @param token the address of the token transferred * @param amount the amount of the token transferred * @param fromAddress the address the token was transferred from * @param toAddress the address the token was transferred to */ event FrictionlessTokenTransferred( IBasicFrictionlessToken.FrictionlessTokenTypes tokenType, address token, uint256 amount, address fromAddress, address toAddress ); /** * @dev Event emitted when a `FrictionlessFundDeposit`, `FrictionlessDigitalSecurity` or `FrictionlessOnChainAsset` is burned. * @param token the address of the token burned * @param amount the amount of the token burned * @param fromAddress the address the token was burned from */ event FrictionlessTokenBurned( IBasicFrictionlessToken.FrictionlessTokenTypes tokenType, address token, uint256 amount, address fromAddress ); /// @dev error throw if the function caller is not a PROTOCOL_TREASURY address. Thrown during the `mintFundDepositForTreasury` error FrictionlessTreasuryManagerNotAProtocolTreasury(address); /// @dev error throw if the FundDepositToken for specified currency and fundIBAN already exists error FrictionlessTreasuryManagerFundDepositTokenAlreadyExists(string currency, string fundIBAN); /// @dev error throw if the data for the token init data `FrictionlessTokenInitData` is invalid. Thrown during the `_setTokensInitData` error FrictionlessTreasuryManagerInvalidTokenInitData(FrictionlessTokenInitData); /// @dev error throw if the data for the token init data `FrictionlessTokenInitData` is already set. Thrown during the `_setTokensInitData` error FrictionlessTreasuryManagerUnableToUpdateTokenInitData(IBasicFrictionlessToken.FrictionlessTokenTypes); /// @dev error throw if the data for the IFrictionlessFundDepositToken is invalid. Thrown during the `mintFundDepositForTreasury` error FrictionlessTreasuryManagerInvalidDepositData(IFrictionlessFundDepositToken.FFDImmutableData); /// @dev error throw if the data for the IFrictionlessDigitalSecurityToken is invalid. Thrown during the `mintDigitalSecurity` error FrictionlessTreasuryManagerInvalidFDSImmutableData(IFrictionlessDigitalSecurityToken.FDSImmutableData); /// @dev error throw if the data for the IFrictionlessDigitalSecurityToken is invalid. Thrown during the `mintOnChainAsset` error FrictionlessTreasuryManagerInvalidFOCASpecData(IFrictionlessOnChainAssetToken.FOCASpecData); /// @dev error throw if the data for the IFrictionlessDigitalSecurityToken is invalid. Thrown during the `mintOnChainAsset` error FrictionlessTreasuryManagerInvalidFOCAIssuanceData(IFrictionlessOnChainAssetToken.FOCAIssuanceData); /** * @dev See {PausableUpgradeable-_pause} */ function pause() external; /** * @dev See {PausableUpgradeable-_unpause} */ function unpause() external; /** * @dev Sets and associates the implementation authority with the associated token type * @param initDataArr_ the `FrictionlessTokenInitData` configuration associating the implementation authority with the associated token type. */ function setTokensInitData(FrictionlessTokenInitData[] calldata initDataArr_) external; /** * @dev Mints a Fund Deposit Token in the specified currency/IBAN pair. This function is invoked to create the genesis mint of the * deposit token in the PROTOCOL_TREASURY. * @param depositData the immutable deposit data for the token * @param treasuryAddress the address of the treasury, which receives the deposit tokens * @param amount the amount of tokens * @return address of the token minted * emits `FrictionlessTokenMinted` event * throws error `FrictionlessTreasuryManagerInvalidDepositData` if the deposit data is invalid. * requires the depositData.currency to be a 3 letter currency code * requires the depositData.description to be not empty * requires the depositData.IBAN to be not empty */ function mintFundDepositForTreasury( IFrictionlessFundDepositToken.FFDImmutableData calldata depositData, address treasuryAddress, uint256 amount ) external returns (address); /** * @dev Mints a FrictionlessDigitalSecurityToken as the future dated cash distribution from the underlying FrictionlessOnChainAssetToken. * This function is invoked to create the genesis mint of the deposit token in the PROTOCOL_TREASURY. * @param initData the immutable data for the token * @param updateData the mutable data for the token * @param amount the amount of tokens * @param userAddress the address of the protocol user, which receives the digital security tokens * @return address of the token minted * emits `FrictionlessTokenMinted` event * throws error `FrictionlessTreasuryManagerInvalidFDSImmutableData` if the initData is invalid. * requires the initData.currency to be a 3 letter currency code * requires the initData.onChainAssetAddress to be non 0 address */ function mintDigitalSecurity( IFrictionlessDigitalSecurityToken.FDSImmutableData memory initData, IFrictionlessDigitalSecurityToken.FDSMutableData memory updateData, uint256 amount, address userAddress ) external returns (address); /** * @dev Mints a FrictionlessOnChainAssetToken as the representation of the asset to be securitized, fractionalized & sold. * This function is invoked to create the genesis mint of the deposit token to the PERMISSIONED_CUSTODIAN. * @param specData the immutable data for the token * @param issuanceData the issuance data for the token * @param updateData the update data for the token * @param custodianAddress the address of the protocol custodian, which receives the `FrictionlessOnChainAssetToken` * @return address of the token minted * emits `FrictionlessTokenMinted` event * throws error `FrictionlessTreasuryManagerInvalidFOCASpecData` or `FrictionlessTreasuryManagerInvalidFOCAIssuanceData` if the specData or issuanceData is invalid. */ function mintOnChainAsset( IFrictionlessOnChainAssetToken.FOCASpecData memory specData, IFrictionlessOnChainAssetToken.FOCAIssuanceData memory issuanceData, IFrictionlessOnChainAssetToken.FOCAUpdateData memory updateData, address custodianAddress ) external returns (address); /** * @dev Used to increase the mint of a Frictionless token which already exists. * @param token the address of the token * @param userAddress the address to min the token to * @param amount the amount of tokens to mint * emits `FrictionlessTokenMinted` event */ function mintTokenForUser(address token, address userAddress, uint256 amount) external; /** * @dev Used to increase the mint of a Frictionless token which already exists. * @param token the address of the token * @param userAddressFrom the address to transfer the tokens from * @param userAddressTo the address to transfer the tokens to * @param amount the amount of tokens to mint * emits `FrictionlessTokenTransferred` event */ function transferToken(address token, address userAddressFrom, address userAddressTo, uint256 amount) external; /** * @dev Used to burn an amount of Frictionless token which already exists. * @param token the address of the token * @param userAddress the address to burn the tokens from * @param amount the amount of tokens to burn * emits `FrictionlessTokenBurned` event */ function burnToken(address token, address userAddress, uint256 amount) external; /** * @dev returns the address of the fund deposit token by currency and fundIBAN * @param currency_ the currency of the fund deposit token * @param fundIBAN_ the fundIBAN of the fund deposit token * @return the address of the fund deposit token for specified currency and fundIBAN */ function getFundDepositToken(string calldata currency_, string calldata fundIBAN_) external view returns (address); /** * @dev returns fund deposit token key by currency and fundIBAN * @param currency_ the currency of the fund deposit token you need * @param fundIBAN_ the fundIBAN of the fund deposit token you need * @return the fund deposit token key */ function getFundDepositTokenKey(string memory currency_, string memory fundIBAN_) external pure returns (bytes32); }
// SPDX-License-Identifier: MIT /** * Copyright © 2024 Frictionless Group Holdings S.à.r.l * * Permission is hereby granted, free of charge, to any person obtaining a copy of the Frictionless protocol smart contracts * (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, * modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies * or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL FRICTIONLESS GROUP * HOLDINGS S.à.r.l OR AN OF ITS SUBSIDIARIES BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ pragma solidity ^0.8.16; /** * @title IFrictionlessPermissionsManager - Manages the permission of participants in the Frictionless protocol * @author Frictionless Group Holdings S.à.r.l * @notice The IFrictionlessPermissionsManager is responsible for the management of permission of the various participants in * the Frictionless protocol. The roles and responsibilities are defined in the public README for the Frictionless protocol at * https://gitlab.com/dfyclabs/protocol/dfyclabs-tokens/-/blob/main/README.md?ref_type=heads#roles-responsibilities */ interface IFrictionlessPermissionsManager { /// @dev Enum of the Frictionless protocol participants. enum FrictionlessPermissionedUser { PROTOCOL_TREASURY, PERMISSIONED_CUSTODIAN, PERMISSIONED_INVESTOR, PERMISSIONED_MANAGER, PERMISSIONED_CALCULATING_AGENT, PERMISSIONED_TRANSFER_AGENT, PERMISSIONED_FUND_ACCOUNTANT } /// @dev throws if specific address is zero. error FrictionlessIsZeroAddress(string); /// @dev throws if treasury tries to add or remove treasury. error FrictionlessInvalidPermissionForTreasury(); /// @dev throws if user is not a permissioned investor error FrictionlessUserIsNotPermssionedInvestor(); /** * @dev Emitted when a user is added to the Frictionless protocol. This event is emitted by the `addUser` function. * @param userIdentity the address of the user's OnChainId (Identity) * @param userType the type of the user as per the enum * @param claimURI the URI of the off-chain claim for the user. i.e. The Frictionless Markets graphQL endpoint */ event FrictionlessPermissionedUserAdded(address userIdentity, uint256 userType, string claimURI); /** * @dev Emitted when a user is registered in the Frictionless protocol. This event is emitted by the `registerIdentity` function. * @param userAddress the address of the user's wallet to register * @param userISOCountry the ISO 3166-1 numeric code of the user, can be the place of residence or the location KYC/AML onboarding was undertaken. */ event FrictionlessPermissionedUserRegistered(address userAddress, uint16 userISOCountry); /** * @dev Emitted when a user is removed in the Frictionless protocol. This event is emitted by the `removeUser` function. * @param userAddress the address of the user's wallet to register */ event FrictionlessPermissionedUserRemoved(address userAddress); /// @dev the internal struct defining a Claim for a PERMISSIONED_USER in the protocol. Used to submit claims for the OnChainId by the ClaimIssuer. struct Claim { address issuer; uint256 topic; uint8 scheme; address identity; bytes signature; bytes data; } /** * @dev Validates if a wallet address is permissioned in the Frictionless protocol * @param userAddress the wallet address to verify * @return true if the address is permissioned in the Frictionless Protocol. */ function isPermissioned(address userAddress) external view returns (bool); /** * @dev Registers a users wallet address as an OnChainId (Identity) to the Frictionless protocol. * This Identity is used when permissioning a user to the protocol by invoking the addUser function later. * @param userAddress the address of the user's wallet to register * @param userISOCountry the ISO 3166-1 numeric code of the user, can be the place of residence or the location KYC/AML onboarding was undertaken. * requires The msg.sender to have the TREX Agent permissions (PROTOCOL_TREASURY or PROTOCOL_ADMIN) * @return address the address of the user's OnChainId (Identity) with the associated claims. */ function registerIdentity(address userAddress, uint16 userISOCountry) external returns (address); /** * @dev Gets a users OnChainId (Identity) in the Frictionless protocol. * @param userAddress the address of the user's wallet to register * requires The msg.sender to have the TREX Agent permissions (PROTOCOL_TREASURY or PROTOCOL_ADMIN) * @return address the address of the user's OnChainId (Identity) with the associated claims. */ function getIdentity(address userAddress) external returns (address); /** * @dev Get the signed claimData message to be used in the addUser function. * The message must be signed using the PK of the ClaimIssuer (PROTOCOL_ADMIN) * @param userIdentity the address of the user's OnChainId (Identity) * @param userType the type of the user as per the enum * @return signed claimData message to be used in the addUser unction once signed by the ClaimIssuer PK. */ function getClaimMsgHash( address userIdentity, IFrictionlessPermissionsManager.FrictionlessPermissionedUser userType ) external view returns (bytes32); /** * @dev verify if the userAddress is permissioned in the Frictionless protocol and has a valid claim * @param userAddress the address of the user's wallet to verify * @param userType the type of the user as per the enum * @return true if a valid permissioned user and has a valid claim, otherwise false. */ function hasClaim(address userAddress, FrictionlessPermissionedUser userType) external view returns (bool); /** * @dev Adds a user's OnChainId (Identity) to the Frictionless protocol along with its associated claim data. * The Identity is created by invoking the registerIdentity function first. * @param userIdentity the address of the user's OnChainId (Identity) * @param userType the type of the user as per the enum * @param claimSignature the signed claimData by the ClaimIssuer * @param claimURI the URI of the off-chain claim for the user. i.e. The Frictionless Markets graphQL endpoint * requires The msg.sender to be the Owner if the userType is the PROTOCOL_TREASURY * requires The msg.sender to have the TREX Agent permissions (PROTOCOL_TREASURY or PROTOCOL_ADMIN) to add any user * @return address the address of the user's OnChainId (Identity) with the associated claims. */ function addUser( address userIdentity, FrictionlessPermissionedUser userType, bytes memory claimSignature, string memory claimURI ) external returns (address); /** * @dev Removes a user from the Frictionless protocol along with its associated claim data. * @param userAddress the address of the user's wallet * requires The msg.sender to have the TREX Agent permissions (PROTOCOL_TREASURY or PROTOCOL_ADMIN) to remove any user * @return true if the user is removed from the Frictionless protocol along with its associated claim data, otherwise false. */ function removeUser(address userAddress) external returns (bool); }
// SPDX-License-Identifier: MIT /** * Copyright © 2024 Frictionless Group Holdings S.à.r.l * * Permission is hereby granted, free of charge, to any person obtaining a copy of the Frictionless protocol smart contracts * (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, * modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies * or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL FRICTIONLESS GROUP * HOLDINGS S.à.r.l OR AN OF ITS SUBSIDIARIES BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ pragma solidity ^0.8.16; import { IAbstractFeeModule } from "@interface/abstract/IAbstractFeeModule.sol"; import { IFrictionlessTreasuryManager } from "@interface/IFrictionlessTreasuryManager.sol"; import { IFrictionlessPermissionsManager } from "@interface/IFrictionlessPermissionsManager.sol"; /** * @title IFrictionlessFXSwap - Interface defining the frictionless conversion and atomic swapping of any `FrictionlessFundDepositToken` currency pair on the Frictionless protocol. * @author Frictionless Group Holdings S.à.r.l * @notice Interface defining the frictionless conversion and atomic swapping of any `FrictionlessFundDepositToken` currency pair on the Frictionless protocol. * The FX rates are set from the live spot & forward FX partners on the protocol. */ interface IFrictionlessFXSwap is IAbstractFeeModule { /** * @dev Structure representing token fee information including the token address and fee information * @param tokenAddr The address of the token * @param feeAbsoluteLimit The absolute limit of fees to be paid in the FX * @param feeInfo The fee information associated with the token */ struct FrictionlessTokenFXFeeInfo { address tokenAddr; uint256 feeAbsoluteLimit; FeeInfo feeInfo; } /** * @dev Event emitted upon successful token swaps * @param sellingTokenAddr The address of the token being sold * @param buyingTokenAddr The address of the token being bought * @param tokenSender The address of the sender initiating the swap * @param tokenRecipient The address of the recipient receiving the bought tokens * @param sellingTokensAmount The amount of tokens being sold * @param buyingTokensAmount The amount of tokens being bought * @param buyingTokenExchangeRate The exchange rate of the token being bought to the token being sold */ event FrictionlessFXTokensSwapped( address sellingTokenAddr, address buyingTokenAddr, address tokenSender, address tokenRecipient, uint256 sellingTokensAmount, uint256 buyingTokensAmount, uint256 buyingTokenExchangeRate ); /// @dev error thrown during `setSwapFees` if token adresses are invalid (zero addresses, equals addresses and etc.). error FrictionlessFXSwapInvalidTokenAddresses(address token0, address token1); /// @dev error thrown during `setSwapFees`, `setTokenFee` and `swapTokens` if the fxDeskFeeRecipient doesn't equal to the stored `fxDeskFeeAddr` error FrictionlessFXSwapInvalidFeeRecipientAddr(address newFeeRecipient); /// @dev error thrown during `swapTokens` if the msg.sender is not a PROTOCOL_TREASURY. error FrictionlessFXSwapNotEnoughPermissions(); /** * @dev Sets the address of the FXDesk fee recipient * Only Owner (PROTOCOL_ADMIN) can call this function * @param newFXDeskFeeAddr_ The new address of the FXDesk fee recipient */ function setFXDeskFeeAddr(address newFXDeskFeeAddr_) external; /** * @dev Set the swap fees for the swaps of a token pair. The fees can be any combination of zero (0%) or upto 10000 bps (100%) on any directional transfer. * Fees can only be set by the Owner (PROTOCOL_ADMIN). * @param token0FeeInfo_ The fees associated with the token0 (first token) in the token pair during the swap. * @param token1FeeInfo_ The fees associated with the token1 (second token) in the token pair during the swap. * throws `FrictionlessFXSwapInvalidTokenAddresses` if the token addresses are invalid. * throws `FrictionlessFXSwapInvalidFeeRecipientAddr` if the feeRecipientAddr doesn't equal to the `fxDeskFeeAddr`. * throws `AbstractFeeModuleInvalidFeeRecipient` if the feeRecipientAddr is a zero address * throws `AbstractFeeModuleInvalidFee` if the feeInBps is not in the valid range (ZERO_FEES_IN_BPS to MAX_FEES_IN_BPS) * emits `FrictionlessFeeSet` upon completion of the setting of the fee info for the token in either set of fees */ function setSwapFees( FrictionlessTokenFXFeeInfo calldata token0FeeInfo_, FrictionlessTokenFXFeeInfo calldata token1FeeInfo_ ) external; /** * @dev Set the fee associated with the swap of a Token and manages the mapping of the key to this set of Fees. * Can only be set by the Owner (PROTOCOL_ADMIN). * @param tokenFeeKey_ The key, generated by the function `getTokenFeeKey`, which is used to map a specific swap polarity for tokens. * @param tokenFeeInfo_ The fees associated with the swap of token, used in the calculation and disbursement of fees during swap of a token pair. * throws `FrictionlessFXSwapInvalidTokenAddresses` if the token addresses are invalid. * throws `FrictionlessFXSwapInvalidFeeRecipientAddr` if the feeRecipientAddr doesn't equal to the `fxDeskFeeAddr`. * throws `AbstractFeeModuleInvalidFeeRecipient` if the feeRecipientAddr is a zero address * throws `AbstractFeeModuleInvalidFee` if the feeInBps is not in the valid range (ZERO_FEES_IN_BPS to MAX_FEES_IN_BPS) * emits `FrictionlessTokenFeeSet` upon completion of the setting of the fee info for the token */ function setTokenFee(bytes32 tokenFeeKey_, FrictionlessTokenFXFeeInfo calldata tokenFeeInfo_) external; /** * @dev Swaps tokens between addresses at a specified exchange rate * Only PROTOCOL_TREASURY can call this function * @param sellingTokenAddr_ The address of the token to be sold * @param buyingTokenAddr_ The address of the token to be bought * @param tokenSender_ The address of the sender initiating the swap * @param tokenRecipient_ The address where the bought tokens will be sent * @param buyingTokensAmount_ The amount of tokens being bought * @param buyingTokenExchangeRate_ The exchange rate of the token being bought to the token being sold */ function swapTokens( address sellingTokenAddr_, address buyingTokenAddr_, address tokenSender_, address tokenRecipient_, uint256 buyingTokensAmount_, uint256 buyingTokenExchangeRate_ ) external; /** * @dev Retrieves the address of the FXDesk fee recipient * @return The address of the FXDesk fee recipient */ function fxDeskFeeAddr() external view returns (address); /** * @dev Retrieves the Frictionless Treasury Manager contract * @return The address of the Frictionless Treasury Manager contract */ function treasuryManager() external view returns (IFrictionlessTreasuryManager); /** * @dev Retrieves the Frictionless Permissions Manager contract * @return The address of the Frictionless Permissions Manager contract */ function permissionManager() external view returns (IFrictionlessPermissionsManager); /** * @dev get the tokenFeeInfo set for the fees associated per token in an exchange. * @param token0_ the address of the first token in an exchange * @param token1_ the address of the second token in an exchange * @return FeeInfo set for the fees associated per token in an exchange. */ function getSwapFeesInfo(address token0_, address token1_) external view returns (FeeInfo memory, FeeInfo memory); /** * @dev Generates keys based on the packed encoding of the addresses of sets of tokens using the keccak256 hashing function. Used to store tokenFees in mappings. * @param token0_ the address of the token 0 in a transfer fee calculation * @param token1_ the address of the token 1 in a transfer fee calculation * @return keys based on the packed encoding of the addresses of sets of tokens using the keccak256 hashing function. */ function getSwapFeeKeys(address token0_, address token1_) external view returns (bytes32, bytes32); /** * @dev Generates a key based on the packed encoding of the addresses of both tokens using the keccak256 hashing function. Used to store tokenFees in mappings. * @param token0_ the address of the token 0 in a transfer fee calculation * @param token1_ the address of the token 1 in a transfer fee calculation * @return generates a key based on the packed encoding of the addresses of both tokens using the keccak256 hashing function. */ function getTokenFeeKey(address token0_, address token1_) external view returns (bytes32); /** * @dev Calculates the amount of selling tokens based on the buying amount and exchange rate * @param buyingTokensAmount_ The amount of tokens being bought * @param buyingTokenExchangeRate_ The exchange rate of the token being bought to the token being sold * @return The amount of selling tokens */ function getSellingTokensAmount( uint256 buyingTokensAmount_, uint256 buyingTokenExchangeRate_ ) external view returns (uint256); }
// SPDX-License-Identifier: MIT /** * Copyright © 2024 Frictionless Group Holdings S.à.r.l * * Permission is hereby granted, free of charge, to any person obtaining a copy of the Frictionless protocol smart contracts * (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, * modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies * or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL FRICTIONLESS GROUP * HOLDINGS S.à.r.l OR AN OF ITS SUBSIDIARIES BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ pragma solidity ^0.8.16; import { IERC20 } from "@openzeppelin/contracts/interfaces/IERC20.sol"; import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import { IAbstractFeeModule } from "@interface/abstract/IAbstractFeeModule.sol"; abstract contract AbstractFeeModule is IAbstractFeeModule { /// @dev Use `SafeERC20` for any ERC20 token in the conversion using SafeERC20 for IERC20; /// @dev represents 0 bps in fees (the minima of fees or 0%) uint256 public constant ZERO_FEES_IN_BPS = 0; /// @dev represents 10000 bps in fees (the maxima of fees or 100%) uint256 public constant MAX_FEES_IN_BPS = 10000; mapping(bytes32 => FeeInfo) private _feesInfo; function getFeeInfo(bytes32 tokenFeeKey_) public view override returns (FeeInfo memory) { return _feesInfo[tokenFeeKey_]; } function getFeeInBps(bytes32 tokenFeeKey_) public view override returns (uint256) { return _feesInfo[tokenFeeKey_].feeInBps; } function getFeeRecipient(bytes32 tokenFeeKey_) public view override returns (address) { return _feesInfo[tokenFeeKey_].feeRecipientAddr; } function calculateFeeAmount( uint256 tokensAmount_, uint256 feeInBps_ ) public pure override returns (uint256 feeAmount_) { if (feeInBps_ > ZERO_FEES_IN_BPS) { feeAmount_ = ((tokensAmount_ * feeInBps_) / MAX_FEES_IN_BPS); } /// @dev Shouldnt arrise due to validation, but being doubly sure, we can't compute incorrect fees. if (feeInBps_ > MAX_FEES_IN_BPS) { feeAmount_ = ZERO_FEES_IN_BPS; } } function _setTokenFee(bytes32 feeKey_, FeeInfo memory feeInfo_) internal virtual { _validateFeeInfo(feeInfo_); _feesInfo[feeKey_] = feeInfo_; emit FrictionlessFeeSet(feeKey_, feeInfo_); } function _transferFees( bytes32 feeKey_, IERC20 token_, address tokenSender_, uint256 tokensAmount_ ) internal returns (uint256) { FeeInfo memory tokenFeeInfo_ = getFeeInfo(feeKey_); uint256 feeAmount_ = calculateFeeAmount(tokensAmount_, tokenFeeInfo_.feeInBps); if (feeAmount_ > 0) { token_.safeTransferFrom(tokenSender_, tokenFeeInfo_.feeRecipientAddr, feeAmount_); } return feeAmount_; } /** * @dev Validates the FeeInfo, specifically validates the non zero address of the feeRecipientAddr and the range for the feeInBps (0 to MAX_FEES_IN_BPS). * @param feeInfo_ the FeeInfo to validate. * throws `AbstractFeeModuleInvalidFeeRecipient` if the feeRecipientAddr is a zero address * throws `AbstractFeeModuleInvalidFee` if the feeInBps is not in the valid range (ZERO_FEES_IN_BPS to MAX_FEES_IN_BPS) */ function _validateFeeInfo(FeeInfo memory feeInfo_) internal pure { if (feeInfo_.feeInBps > ZERO_FEES_IN_BPS && feeInfo_.feeRecipientAddr == address(0)) { revert AbstractFeeModuleInvalidFeeRecipient(); } if (feeInfo_.feeInBps > MAX_FEES_IN_BPS) { revert AbstractFeeModuleInvalidFee(feeInfo_.feeInBps); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 amount ) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol) pragma solidity ^0.8.0; /** * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified * proxy whose upgrades are fully controlled by the current implementation. */ interface IERC1822Proxiable { /** * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation * address. * * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this * function revert if invoked through a proxy. */ function proxiableUUID() external view returns (bytes32); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol) pragma solidity ^0.8.2; import "../beacon/IBeacon.sol"; import "../../interfaces/draft-IERC1822.sol"; import "../../utils/Address.sol"; import "../../utils/StorageSlot.sol"; /** * @dev This abstract contract provides getters and event emitting update functions for * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots. * * _Available since v4.1._ * * @custom:oz-upgrades-unsafe-allow delegatecall */ abstract contract ERC1967Upgrade { // This is the keccak-256 hash of "eip1967.proxy.rollback" subtracted by 1 bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143; /** * @dev Storage slot with the address of the current implementation. * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; /** * @dev Emitted when the implementation is upgraded. */ event Upgraded(address indexed implementation); /** * @dev Returns the current implementation address. */ function _getImplementation() internal view returns (address) { return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; } /** * @dev Stores a new address in the EIP1967 implementation slot. */ function _setImplementation(address newImplementation) private { require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; } /** * @dev Perform implementation upgrade * * Emits an {Upgraded} event. */ function _upgradeTo(address newImplementation) internal { _setImplementation(newImplementation); emit Upgraded(newImplementation); } /** * @dev Perform implementation upgrade with additional setup call. * * Emits an {Upgraded} event. */ function _upgradeToAndCall( address newImplementation, bytes memory data, bool forceCall ) internal { _upgradeTo(newImplementation); if (data.length > 0 || forceCall) { Address.functionDelegateCall(newImplementation, data); } } /** * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call. * * Emits an {Upgraded} event. */ function _upgradeToAndCallUUPS( address newImplementation, bytes memory data, bool forceCall ) internal { // Upgrades from old implementations will perform a rollback test. This test requires the new // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing // this special case will break upgrade paths from old UUPS implementation to new ones. if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) { _setImplementation(newImplementation); } else { try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) { require(slot == _IMPLEMENTATION_SLOT, "ERC1967Upgrade: unsupported proxiableUUID"); } catch { revert("ERC1967Upgrade: new implementation is not UUPS"); } _upgradeToAndCall(newImplementation, data, forceCall); } } /** * @dev Storage slot with the admin of the contract. * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103; /** * @dev Emitted when the admin account has changed. */ event AdminChanged(address previousAdmin, address newAdmin); /** * @dev Returns the current admin. */ function _getAdmin() internal view returns (address) { return StorageSlot.getAddressSlot(_ADMIN_SLOT).value; } /** * @dev Stores a new address in the EIP1967 admin slot. */ function _setAdmin(address newAdmin) private { require(newAdmin != address(0), "ERC1967: new admin is the zero address"); StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin; } /** * @dev Changes the admin of the proxy. * * Emits an {AdminChanged} event. */ function _changeAdmin(address newAdmin) internal { emit AdminChanged(_getAdmin(), newAdmin); _setAdmin(newAdmin); } /** * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy. * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor. */ bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50; /** * @dev Emitted when the beacon is upgraded. */ event BeaconUpgraded(address indexed beacon); /** * @dev Returns the current beacon. */ function _getBeacon() internal view returns (address) { return StorageSlot.getAddressSlot(_BEACON_SLOT).value; } /** * @dev Stores a new beacon in the EIP1967 beacon slot. */ function _setBeacon(address newBeacon) private { require(Address.isContract(newBeacon), "ERC1967: new beacon is not a contract"); require( Address.isContract(IBeacon(newBeacon).implementation()), "ERC1967: beacon implementation is not a contract" ); StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon; } /** * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that). * * Emits a {BeaconUpgraded} event. */ function _upgradeBeaconToAndCall( address newBeacon, bytes memory data, bool forceCall ) internal { _setBeacon(newBeacon); emit BeaconUpgraded(newBeacon); if (data.length > 0 || forceCall) { Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. */ interface IERC20Permit { /** * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens, * given ``owner``'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; /** * @dev Returns the current nonce for `owner`. This value must be * included whenever a signature is generated for {permit}. * * Every successful call to {permit} increases ``owner``'s nonce by one. This * prevents a signature from being used multiple times. */ function nonces(address owner) external view returns (uint256); /** * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view returns (bytes32); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract. * * _Available since v4.8._ */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata, string memory errorMessage ) internal view returns (bytes memory) { if (success) { if (returndata.length == 0) { // only check isContract if the call was successful and the return data is empty // otherwise we already know that it was a contract require(isContract(target), "Address: call to non-contract"); } return returndata; } else { _revert(returndata, errorMessage); } } /** * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason or using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { _revert(returndata, errorMessage); } } function _revert(bytes memory returndata, string memory errorMessage) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; import "../proxy/utils/Initializable.sol"; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract ContextUpgradeable is Initializable { function __Context_init() internal onlyInitializing { } function __Context_init_unchained() internal onlyInitializing { } function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/Initializable.sol) pragma solidity ^0.8.2; import "../../utils/AddressUpgradeable.sol"; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in * case an upgrade adds a module that needs to be initialized. * * For example: * * [.hljs-theme-light.nopadding] * ```solidity * contract MyToken is ERC20Upgradeable { * function initialize() initializer public { * __ERC20_init("MyToken", "MTK"); * } * } * * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable { * function initializeV2() reinitializer(2) public { * __ERC20Permit_init("MyToken"); * } * } * ``` * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. * * [CAUTION] * ==== * Avoid leaving a contract uninitialized. * * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed: * * [.hljs-theme-light.nopadding] * ``` * /// @custom:oz-upgrades-unsafe-allow constructor * constructor() { * _disableInitializers(); * } * ``` * ==== */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. * @custom:oz-retyped-from bool */ uint8 private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Triggered when the contract has been initialized or reinitialized. */ event Initialized(uint8 version); /** * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope, * `onlyInitializing` functions can be used to initialize parent contracts. * * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a * constructor. * * Emits an {Initialized} event. */ modifier initializer() { bool isTopLevelCall = !_initializing; require( (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1), "Initializable: contract is already initialized" ); _initialized = 1; if (isTopLevelCall) { _initializing = true; } _; if (isTopLevelCall) { _initializing = false; emit Initialized(1); } } /** * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be * used to initialize parent contracts. * * A reinitializer may be used after the original initialization step. This is essential to configure modules that * are added through upgrades and that require initialization. * * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer` * cannot be nested. If one is invoked in the context of another, execution will revert. * * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in * a contract, executing them in the right order is up to the developer or operator. * * WARNING: setting the version to 255 will prevent any future reinitialization. * * Emits an {Initialized} event. */ modifier reinitializer(uint8 version) { require(!_initializing && _initialized < version, "Initializable: contract is already initialized"); _initialized = version; _initializing = true; _; _initializing = false; emit Initialized(version); } /** * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the * {initializer} and {reinitializer} modifiers, directly or indirectly. */ modifier onlyInitializing() { require(_initializing, "Initializable: contract is not initializing"); _; } /** * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call. * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized * to any version. It is recommended to use this to lock implementation contracts that are designed to be called * through proxies. * * Emits an {Initialized} event the first time it is successfully executed. */ function _disableInitializers() internal virtual { require(!_initializing, "Initializable: contract is initializing"); if (_initialized != type(uint8).max) { _initialized = type(uint8).max; emit Initialized(type(uint8).max); } } /** * @dev Returns the highest version that has been initialized. See {reinitializer}. */ function _getInitializedVersion() internal view returns (uint8) { return _initialized; } /** * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}. */ function _isInitializing() internal view returns (bool) { return _initializing; } }
// SPDX-License-Identifier: MIT /** * Copyright © 2024 Frictionless Group Holdings S.à.r.l * * Permission is hereby granted, free of charge, to any person obtaining a copy of the Frictionless protocol smart contracts * (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, * modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies * or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL FRICTIONLESS GROUP * HOLDINGS S.à.r.l OR AN OF ITS SUBSIDIARIES BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ pragma solidity ^0.8.16; import { IToken } from "@ERC-3643/token/IToken.sol"; /** * @title IBasicFrictionlessToken - Represents the base interface for Frictionless protocol tokens. * @author Frictionless Group Holdings S.à.r.l * @notice The IBasicFrictionlessToken Represents the base interface for Frictionless protocol tokens, this interface is used to determine a token type. */ interface IBasicFrictionlessToken is IToken { /** * @dev Enumeration to represent each of the tokens in the Frictionless protocol. */ enum FrictionlessTokenTypes { NONE, FUND_DEPOSIT_TOKEN, // IFrictionlessFundDepositToken DIGITAL_SECURITY_TOKEN, // IFrictionlessDigitalSecurityToken ON_CHAIN_ASSET_TOKEN // IFrictionlessOnChainAssetToken } /// @dev error thrown if an attempt to set an invalid token type during function `setFrictionlessTokenType` error BasicFrictionlessTokenUnableToUpdateFrictionlessTokenType(); /** * @dev Sets the token type according to the specified enumeration * @param newTokenType_ the token type to set */ function setFrictionlessTokenType(FrictionlessTokenTypes newTokenType_) external; /** * @dev Returns the token type according to the specified enumeration * @return FrictionlessTokenTypes the token type according to the specified enumeration */ function getFrictionlessTokenType() external view returns (FrictionlessTokenTypes); }
// SPDX-License-Identifier: MIT /** * Copyright © 2024 Frictionless Group Holdings S.à.r.l * * Permission is hereby granted, free of charge, to any person obtaining a copy of the Frictionless protocol smart contracts * (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, * modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies * or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL FRICTIONLESS * GROUP HOLDINGS S.à.r.l OR ANY OF ITS SUBSIDIARIES BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. * */ pragma solidity ^0.8.16; import { IBasicFrictionlessToken } from "@interface/IBasicFrictionlessToken.sol"; /** * @title IFrictionlessDigitalSecurityToken - The permissioned & transferable digital security which represents the future cash flow from the `FrictionlessOnChainAssetToken`. * @author Frictionless Group Holdings S.à.r.l * @notice This is the permissioned & transferable digital security which represents the future cash flow from the `FrictionlessOnChainAssetToken` and is purchased by * the Investor using `FrictionlessFundDepositTokens`. These digital securities are permissioned and transferable between permissioned Investors in a permissioned secondary market. * This token is linked to the `FrictionlessOnChainAssetToken` and denominated in a FIAT currency at a future date for settlement. */ interface IFrictionlessDigitalSecurityToken is IBasicFrictionlessToken { // @dev Enumeration to represent the type of the digital security, either a coupon (yield) or strip (principal) enum FrictionlessDigitalSecurityTokenType { COUPON, STRIP } /** * @dev Struct which represents the immutable data in the Token. Once set it cannot be modified. * @param baseCurrency the baseCurrency is the FIAT denomination of the digital security, this is the currency the `FrictionlessOnChainAssetToken` is issued in. * @param tokenType the type of the token as defined in the enum * @param onChainAssetAddress the address of the `FrictionlessOnChainAssetToken` for which this token is a future cash distribution. */ struct FDSImmutableData { string baseCurrency; FrictionlessDigitalSecurityTokenType tokenType; address onChainAssetAddress; } /** * @dev Struct which represents the updatable data in the Token. This data can be modified by the Agent only. * @param maturesOn the maturity date of the digital security, it can be updated if there are delays in payment or at the request of the calculating agent. */ struct FDSMutableData { uint256 maturesOn; } /// @dev error throw if there is an attempt to modify the immutable data. error FrictionlessDigitalSecurityTokenInitDataHasAlreadyBeenSet(); /// @dev error throw if there is an attempt to set zero decimals. error FrictionlessDigitalSecurityTokenZeroDecimals(); /** * @dev Sets the immutable data for the `FrictionlessDigitalSecurityToken` * @param initData the immutable data for the `FrictionlessDigitalSecurityToken` */ function setInitData(FDSImmutableData calldata initData) external; /** * @dev Sets the updatable data for the `FrictionlessDigitalSecurityToken` * @param mutableData the updatable data for the `FrictionlessDigitalSecurityToken` */ function setUpdateData(FDSMutableData calldata mutableData) external; /** * @dev Sets the custodian URI for the token * @param custodianURI the custodian URI for the token */ function setCustodianURI(string calldata custodianURI) external; /** * @dev Sets the decimals value for the token * @param decimals the decimals value for the token */ function setDecimals(uint8 decimals) external; /** * @dev Get the baseCurrency is the FIAT denomination of the digital security, this is the currency the `FrictionlessOnChainAssetToken` is issued in. * @return the baseCurrency is the FIAT denomination of the digital security, this is the currency the `FrictionlessOnChainAssetToken` is issued in. */ function getCurrency() external view returns (string memory); /** * @dev Get the type of the token as defined in the enum `FrictionlessDigitalSecurityTokenType`. * @return the type of the token as defined in the enum. */ function getTokenType() external view returns (FrictionlessDigitalSecurityTokenType); /** * @dev Get the onChainAssetAddress the address of the `FrictionlessOnChainAssetToken` for which this token is a future cash distribution. * @return onChainAssetAddress the address of the `FrictionlessOnChainAssetToken` for which this token is a future cash distribution. */ function getOnChainAssetAddress() external view returns (address); /** * @dev Get the maturity date of the digital security. * @return the maturity date of the digital security. */ function getMaturesOn() external view returns (uint256); /** * @dev Returns the custodian URI of the token */ function custodianURI() external view returns (string memory); }
// SPDX-License-Identifier: MIT /** * Copyright © 2024 Frictionless Group Holdings S.à.r.l * * Permission is hereby granted, free of charge, to any person obtaining a copy of the Frictionless protocol smart contracts * (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, * modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies * or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL FRICTIONLESS GROUP * HOLDINGS S.à.r.l OR AN OF ITS SUBSIDIARIES BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ pragma solidity ^0.8.16; import { IBasicFrictionlessToken } from "@interface/IBasicFrictionlessToken.sol"; /** * @title FrictionlessFundDepositToken - A Fund Deposit Token represents a permissioned Investors FIAT contribution to a specific fund IBAN in a denominated FIAT currency. * @author Frictionless Group Holdings S.à.r.l * @notice A Fund Deposit Token represents a permissioned Investors FIAT contribution to a specific fund IBAN in a denominated FIAT currency. * The Fund Deposit Token is used as a means of payment and settlement. The Fund Deposit Token can only be transferred between permissioned Investors in the fund. * A daily attestation of the fund IBAN serves to prove the 1:1 backing with FIAT. * Exclusively under Frictionless Markets S.à.r.l issuance terms Investors holding a `FrictionlessFundDepositToken` have the legal right to the FIAT value held in the fund IBAN account. */ interface IFrictionlessFundDepositToken is IBasicFrictionlessToken { /** * @dev Struct which represents the immutable data in the Token. Once set it cannot be modified. * @param currency the FIAT denomination of the deposit token. * @param description the description of the deposit token * @param fundIBAN the IBAN which Frictionless Markets S.à.r.l holds a matching FIAT currency ledger with a G-SIB for this currency, attestations are provided on this IBAN. */ struct FFDImmutableData { string currency; string description; string fundIBAN; } /// @dev error throw if there is an attempt to modify the immutable data. error FrictionlessFundDepositTokenUnableToUpdateInitData(); /** * @dev Sets the immutable data for the `FrictionlessFundDepositToken` * @param initData the immutable data for the `FrictionlessFundDepositToken` */ function setInitData(FFDImmutableData calldata initData) external; /** * @dev Get the currency the FIAT denomination of the deposit token. * @return the currency the FIAT denomination of the deposit token. */ function getCurrency() external view returns (string memory); /** * @dev Get the description the description of the deposit token. * @return the description the description of the deposit token */ function getDescription() external view returns (string memory); /** * @dev Get the IBAN which Frictionless Markets S.à.r.l holds a matching FIAT currency ledger with a G-SIB for this currency, attestations are provided on this IBAN. * This is restricted to onlyAgent roles. * @return the IBAN which Frictionless Markets S.à.r.l holds a matching FIAT currency ledger with a G-SIB for this currency, attestations are provided on this IBAN. */ function getFundIBAN() external returns (string memory); }
// SPDX-License-Identifier: MIT /** * Copyright © 2024 Frictionless Group Holdings S.à.r.l * * Permission is hereby granted, free of charge, to any person obtaining a copy of the Frictionless protocol smart contracts * (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, * modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies * or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL FRICTIONLESS GROUP * HOLDINGS S.à.r.l OR AN OF ITS SUBSIDIARIES BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ pragma solidity ^0.8.16; import { IBasicFrictionlessToken } from "@interface/IBasicFrictionlessToken.sol"; /** * @title FrictionlessOnChainAssetToken is the extension of the ERC-3643 Token to represent OnChain Assets * @author Frictionless Group Holdings S.à.r.l * @notice Implementation of the storage of the underlying OnChain Asset and it's data. */ interface IFrictionlessOnChainAssetToken is IBasicFrictionlessToken { /// @dev Enum for the schedule of the payments by the Manager, either pro_rat or coupon/bullet style. enum FrictionlessOnChainAssetSchedule { // The Manager will make payments for the `FrictionlessOnChainAssetToken` on an coupon_only basis, with a bullet payment for the principal investment. SCHEDULE_COUPON_ONLY, // The Manager will make pro-rata payments for the `FrictionlessOnChainAssetToken` for both the principal investment and the coupon. SCHEDULE_PRO_RATA } /// @dev Enum for the periodicity of payments by the Manager enum FrictionlessOnChainAssetPaymentFrequency { // Payments from the Manager for the `FrictionlessOnChainAssetToken` are made daily PAYMENT_FREQUENCY_DAILY, // Payments from the Manager for the `FrictionlessOnChainAssetToken` are made weekly PAYMENT_FREQUENCY_WEEKLY, // Payments from the Manager for the `FrictionlessOnChainAssetToken` are made monthly PAYMENT_FREQUENCY_MONTHLY, // Payments from the Manager for the `FrictionlessOnChainAssetToken` are made quarterly PAYMENT_FREQUENCY_QUARTERLY, // Payments from the Manager for the `FrictionlessOnChainAssetToken` are made semi-annually PAYMENT_FREQUENCY_SEMI_ANNUALLY, // Payments from the Manager for the `FrictionlessOnChainAssetToken` are made annually PAYMENT_FREQUENCY_ANNUALLY, // Payments from the Manager for the `FrictionlessOnChainAssetToken` are made once PAYMENT_FREQUENCY_SINGLE } /// @dev Enum for the yield for this `FrictionlessOnChainAssetToken` is a fixed/floating rate enum FrictionlessOnChainAssetYieldType { // The yield for this `FrictionlessOnChainAssetToken` is a fixed rate YIELD_FIXED, // The yield for this `FrictionlessOnChainAssetToken` is a floating rate YIELD_FLOATING } /// @dev Enum for the price quote status obtained at auction enum FrictionlessOnChainAssetPriceStatus { // The `FrictionlessOnChainAssetToken` did not receive enough offers at the offer price PRICE_QUOTE_STATUS_UNDER_SUBSCRIBED, // The aggregate bid at auction matched the offer PRICE_QUOTE_STATUS_PRICED_AT_PAR, // The aggregate bid at auction is lower than the offer PRICE_QUOTE_STATUS_PRICED_AT_DISCOUNT, // The aggregate bid at auction is higher than the offer PRICE_QUOTE_STATUS_PRICED_AT_PREMIUM } /// @dev Enum for the current status of the `FrictionlessOnChainAssetToken`. Updated over time by the Treasury enum FrictionlessOnChainAssetStatus { // Status reserved for `FrictionlessOnChainAssetToken` that are MINTED onChain STATUS_MINTED, // Status reserved for `FrictionlessOnChainAssetToken` that are fully purchased, which means they have minted the digital securities. STATUS_PURCHASED, // Status reserved for `FrictionlessOnChainAssetToken` that have reached their maturity event STATUS_MATURED, // Status reserved for `FrictionlessOnChainAssetToken` that are in an impaired state. The parValue may be affected. STATUS_IMPAIRED, // Status reserved for `FrictionlessOnChainAssetToken` that are fully matured and have been fully redeemed. STATUS_REDEEMED } /// @dev Enum for the current S&P style riskGrade of the `FrictionlessOnChainAssetToken`. Updated over time by the Manager/Treasury/Risk Oracle. enum FrictionlessOnChainAssetRiskGrade { BER_AAA, BER_AA, BER_A, BER_BBB, BER_BB, BER_B, BER_CCC, BER_CC, BER_C, BER_D, BER_UNRATED } /** * @dev The specification data for the `FrictionlessOnChainAssetToken`, this is an immutable data struct. * @param issuedOn the date this `FrictionlessOnChainAssetToken` is issued by the legal Issuer, Frictionless Markets S.à.r.l * @param maturityDays the number of days to maturity for this `FrictionlessOnChainAssetToken` * @param schedule the schedule of the payments by the Manager, either pro_rat or coupon/bullet style. * @param paymentFrequency the periodicity of payments by the Manager * @param yieldType the yield for this `FrictionlessOnChainAssetToken` is a fixed/floating rate * @param baseCurrency the currrency the `FrictionlessOnChainAssetToken` is issued in. * @param stripTotal the principal amount for the `FrictionlessOnChainAssetToken` * @param name the name for the `FrictionlessOnChainAssetToken` * @param symbol the ticker symbol for the `FrictionlessOnChainAssetToken` */ struct FOCASpecData { uint256 issuedOn; uint256 maturityDays; FrictionlessOnChainAssetSchedule schedule; FrictionlessOnChainAssetPaymentFrequency paymentFrequency; FrictionlessOnChainAssetYieldType yieldType; string baseCurrency; uint256 stripTotal; string name; string symbol; } /** * @dev The issuance data for the `FrictionlessOnChainAssetToken`, this is an immutable data struct. * @param auctionedOn the date this `FrictionlessOnChainAssetToken` is auctioned by the legal Issuer, Frictionless Markets S.à.r.l * @param priceQuoteStatus the price quote status obtained at auction * @param onChainAssetUUID the off-chain UUID in the graphQL for the token * @param issuerUUID the off-chain UUID in the graphQL for the Manager issuing via the legal Issuer, Frictionless Markets S.à.r.l * @param isin the ISIN numbre or equivalent for the `FrictionlessOnChainAssetToken` * @param issuanceDocs the location of the issuance docs accessible via URI or the hash of the issuance docs. * @param assetClass the Managers/Issuers definition of the underlying asset class for the `FrictionlessOnChainAssetToken` */ struct FOCAIssuanceData { uint256 auctionedOn; FrictionlessOnChainAssetPriceStatus priceQuoteStatus; string onChainAssetUUID; string issuerUUID; string isin; string issuanceDocs; string assetClass; } /** * @dev The uopdatable data for the `FrictionlessOnChainAssetToken`. * @param maturesOn the date this `FrictionlessOnChainAssetToken` fully matures. Updatable if the underlying fund is extended. * @param total the total value of the `FrictionlessOnChainAssetToken` (strip + yield over time). Updatable based on Manager IRRs, totalReturn, etc. * @param status the current status of the `FrictionlessOnChainAssetToken`. Updated over time by the Treasury * @param yield the current yield being paid on the `FrictionlessOnChainAssetToken`. Updated over time by the Manager/Calculating Agent. * @param riskGrade the current riskGrade of the `FrictionlessOnChainAssetToken`. Updated over time by the Manager/Treasury/Risk Oracle. * @param pullToParValue the calculation of the pullToPar value of this `FrictionlessOnChainAssetToken`. Updated over time by the Manager/Calculating Agent * @param custodianAddress the address of the custodian for the `FrictionlessOnChainAssetToken` */ struct FOCAUpdateData { uint256 maturesOn; uint256 total; FrictionlessOnChainAssetStatus status; uint256 yield; FrictionlessOnChainAssetRiskGrade riskGrade; uint256 pullToParValue; address custodianAddress; } /// @dev error throw if there is an attempt to modify the immutable data. error FrictionlessOnChainAssetTokenUnableToUpdateData(); /** * @dev Sets the specData data for the `FrictionlessOnChainAssetToken`. * throws `FrictionlessOnChainAssetTokenUnableToUpdateData` This data is immutable, an attempt to modify will generate the error `FrictionlessOnChainAssetTokenUnableToUpdateData` * @param specData the specData data for the `FrictionlessOnChainAssetToken` */ function setSpecificationData(FOCASpecData calldata specData) external; /** * @dev Sets the issuanceData data for the `FrictionlessOnChainAssetToken` * throws `FrictionlessOnChainAssetTokenUnableToUpdateData` This data is immutable, an attempt to modify will generate the error `FrictionlessOnChainAssetTokenUnableToUpdateData` * @param issuanceData the updatable data for the `FrictionlessOnChainAssetToken` */ function setIssuanceData(FOCAIssuanceData calldata issuanceData) external; /** * @dev Sets the updatable data for the `FrictionlessOnChainAssetToken` * @param updateData the updatable data for the `FrictionlessOnChainAssetToken` */ function setUpdateData(FOCAUpdateData calldata updateData) external; /** * @dev Get the specData data for the `FrictionlessOnChainAssetToken`. * @return the specData data for the `FrictionlessOnChainAssetToken` */ function getSpecificationData() external view returns (FOCASpecData memory); /** * @dev Get the issuanceData data for the `FrictionlessOnChainAssetToken`. * @return the issuanceData data for the `FrictionlessOnChainAssetToken` */ function getIssuanceData() external view returns (FOCAIssuanceData memory); /** * @dev Get the updateData data for the `FrictionlessOnChainAssetToken`. * @return the updateData data for the `FrictionlessOnChainAssetToken` */ function getUpdateData() external view returns (FOCAUpdateData memory); /** * @dev Get the currency the `FrictionlessOnChainAssetToken` is issued in. * @return the currency the `FrictionlessOnChainAssetToken` is issued in. */ function getCurrency() external view returns (string memory); }
// SPDX-License-Identifier: MIT /** * Copyright © 2024 Frictionless Group Holdings S.à.r.l * * Permission is hereby granted, free of charge, to any person obtaining a copy of the Frictionless protocol smart contracts * (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, * modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies * or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL FRICTIONLESS GROUP * HOLDINGS S.à.r.l OR AN OF ITS SUBSIDIARIES BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ pragma solidity ^0.8.16; /** * @title IAbstractFeeModule - Interface for the calculation of fees and getting the fee info for conversion and transfers. * @author Frictionless Group Holdings S.à.r.l */ interface IAbstractFeeModule { /** * @dev Struct which defines the FeeInfo, representing the fee in basis points and the recipient of the fees on-chain. * @param feeInBps the fee in basis points for the transaction. * @param feeRecipientAddr the address of the reciever of the fees in the transaction. */ struct FeeInfo { uint256 feeInBps; address feeRecipientAddr; } /// @dev Event emitted during `_setTokenFee` event FrictionlessFeeSet(bytes32 indexed feeKey, FeeInfo feeInfo); /// @dev error thrown if the recipient is a zero address error AbstractFeeModuleInvalidFeeRecipient(); /// @dev error thrown if the feesInBps is outside the valid range error AbstractFeeModuleInvalidFee(uint256 feeInBps); /** * @dev get the FeeInfo for a given key. * @param feeKey_ the key as generated by the function `getTokenFeeKey` * @return FeeInfo the fees associated with a token transfer. */ function getFeeInfo(bytes32 feeKey_) external view returns (FeeInfo memory); /** * @dev get the feeInBps value for a given key * @param tokenFeeKey_ the key as generated by the function `getTokenFeeKey` * @return the feeInBps value */ function getFeeInBps(bytes32 tokenFeeKey_) external view returns (uint256); /** * @dev get the feeRecipientAddr value for a given key * @param tokenFeeKey_ the key as generated by the function `getTokenFeeKey` * @return the feeRecipientAddr value */ function getFeeRecipient(bytes32 tokenFeeKey_) external view returns (address); /** * @dev Calculates the actual fee in absolute terms for a given fee in basis points. * @param tokensAmount_ the amount of tokens used to determine the base calculation. * @param feeInBps_ the fee in basis points for calculation. * @return feeAmount_ the actual fee in absolute terms for a given fee in basis points. */ function calculateFeeAmount(uint256 tokensAmount_, uint256 feeInBps_) external pure returns (uint256 feeAmount_); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol) pragma solidity ^0.8.0; /** * @dev This is the interface that {BeaconProxy} expects of its beacon. */ interface IBeacon { /** * @dev Must return an address that can be used as a delegate call target. * * {BeaconProxy} will check that this address is a contract. */ function implementation() external view returns (address); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol) pragma solidity ^0.8.0; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC1967 implementation slot: * ``` * contract ERC1967 { * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` * * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._ */ library StorageSlot { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library AddressUpgradeable { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * * Furthermore, `isContract` will also return true if the target contract within * the same transaction is already scheduled for destruction by `SELFDESTRUCT`, * which only has an effect at the end of a transaction. * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract. * * _Available since v4.8._ */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata, string memory errorMessage ) internal view returns (bytes memory) { if (success) { if (returndata.length == 0) { // only check isContract if the call was successful and the return data is empty // otherwise we already know that it was a contract require(isContract(target), "Address: call to non-contract"); } return returndata; } else { _revert(returndata, errorMessage); } } /** * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason or using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { _revert(returndata, errorMessage); } } function _revert(bytes memory returndata, string memory errorMessage) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } }
// SPDX-License-Identifier: GPL-3.0 // // :+#####%%%%%%%%%%%%%%+ // .-*@@@%+.:+%@@@@@%%#***%@@%= // :=*%@@@#=. :#@@% *@@@%= // .-+*%@%*-.:+%@@@@@@+. -*+: .=#. :%@@@%- // :=*@@@@%%@@@@@@@@@%@@@- .=#@@@%@%= =@@@@#. // -=+#%@@%#*=:. :%@@@@%. -*@@#*@@@@@@@#=:- *@@@@+ // =@@%=:. :=: *@@@@@%#- =%*%@@@@#+-. =+ :%@@@%- // -@@%. .+@@@ =+=-. @@#- +@@@%- =@@@@%: // :@@@. .+@@#%: : .=*=-::.-%@@@+*@@= +@@@@#. // %@@: +@%%* =%@@@@@@@@@@@#. .*@%- +@@@@*. // #@@= .+@@@@%:=*@@@@@- :%@%: .*@@@@+ // *@@* +@@@#-@@%-:%@@* +@@#. :%@@@@- // -@@% .:-=++*##%%%@@@@@@@@@@@@*. :@+.@@@%: .#@@+ =@@@@#: // .@@@*-+*#%%%@@@@@@@@@@@@@@@@%%#**@@%@@@. *@=*@@# :#@%= .#@@@@#- // -%@@@@@@@@@@@@@@@*+==-:-@@@= *@# .#@*-=*@@@@%= -%@@@* =@@@@@%- // -+%@@@#. %@%%= -@@:+@: -@@* *@@*-:: -%@@%=. .*@@@@@# // *@@@* +@* *@@##@@- #@*@@+ -@@= . :+@@@#: .-+@@@%+- // +@@@%*@@:..=@@@@* .@@@* .#@#. .=+- .=%@@@*. :+#@@@@*=: // =@@@@%@@@@@@@@@@@@@@@@@@@@@@%- :+#*. :*@@@%=. .=#@@@@%+: // .%@@= ..... .=#@@+. .#@@@*: -*%@@@@%+. // +@@#+===---:::... .=%@@*- +@@@+. -*@@@@@%+. // -@@@@@@@@@@@@@@@@@@@@@@%@@@@= -@@@+ -#@@@@@#=. // ..:::---===+++***###%%%@@@#- .#@@+ -*@@@@@#=. // @@@@@@+. +@@*. .+@@@@@%=. // -@@@@@= =@@%: -#@@@@%+. // +@@@@@. =@@@= .+@@@@@*: // #@@@@#:%@@#. :*@@@@#- // @@@@@%@@@= :#@@@@+. // :@@@@@@@#.:#@@@%- // +@@@@@@-.*@@@*: // #@@@@#.=@@@+. // @@@@+-%@%= // :@@@#%@%= // +@@@@%- // :#%%= // /** * NOTICE * * The T-REX software is licensed under a proprietary license or the GPL v.3. * If you choose to receive it under the GPL v.3 license, the following applies: * 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. * * 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 * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. */ pragma solidity 0.8.17; import "../registry/interface/IIdentityRegistry.sol"; import "../compliance/modular/IModularCompliance.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; /// @dev interface interface IToken is IERC20 { /// events /** * this event is emitted when the token information is updated. * the event is emitted by the token init function and by the setTokenInformation function * `_newName` is the name of the token * `_newSymbol` is the symbol of the token * `_newDecimals` is the decimals of the token * `_newVersion` is the version of the token, current version is 3.0 * `_newOnchainID` is the address of the onchainID of the token */ event UpdatedTokenInformation(string indexed _newName, string indexed _newSymbol, uint8 _newDecimals, string _newVersion, address indexed _newOnchainID); /** * this event is emitted when the IdentityRegistry has been set for the token * the event is emitted by the token constructor and by the setIdentityRegistry function * `_identityRegistry` is the address of the Identity Registry of the token */ event IdentityRegistryAdded(address indexed _identityRegistry); /** * this event is emitted when the Compliance has been set for the token * the event is emitted by the token constructor and by the setCompliance function * `_compliance` is the address of the Compliance contract of the token */ event ComplianceAdded(address indexed _compliance); /** * this event is emitted when an investor successfully recovers his tokens * the event is emitted by the recoveryAddress function * `_lostWallet` is the address of the wallet that the investor lost access to * `_newWallet` is the address of the wallet that the investor provided for the recovery * `_investorOnchainID` is the address of the onchainID of the investor who asked for a recovery */ event RecoverySuccess(address indexed _lostWallet, address indexed _newWallet, address indexed _investorOnchainID); /** * this event is emitted when the wallet of an investor is frozen or unfrozen * the event is emitted by setAddressFrozen and batchSetAddressFrozen functions * `_userAddress` is the wallet of the investor that is concerned by the freezing status * `_isFrozen` is the freezing status of the wallet * if `_isFrozen` equals `true` the wallet is frozen after emission of the event * if `_isFrozen` equals `false` the wallet is unfrozen after emission of the event * `_owner` is the address of the agent who called the function to freeze the wallet */ event AddressFrozen(address indexed _userAddress, bool indexed _isFrozen, address indexed _owner); /** * this event is emitted when a certain amount of tokens is frozen on a wallet * the event is emitted by freezePartialTokens and batchFreezePartialTokens functions * `_userAddress` is the wallet of the investor that is concerned by the freezing status * `_amount` is the amount of tokens that are frozen */ event TokensFrozen(address indexed _userAddress, uint256 _amount); /** * this event is emitted when a certain amount of tokens is unfrozen on a wallet * the event is emitted by unfreezePartialTokens and batchUnfreezePartialTokens functions * `_userAddress` is the wallet of the investor that is concerned by the freezing status * `_amount` is the amount of tokens that are unfrozen */ event TokensUnfrozen(address indexed _userAddress, uint256 _amount); /** * this event is emitted when the token is paused * the event is emitted by the pause function * `_userAddress` is the address of the wallet that called the pause function */ event Paused(address _userAddress); /** * this event is emitted when the token is unpaused * the event is emitted by the unpause function * `_userAddress` is the address of the wallet that called the unpause function */ event Unpaused(address _userAddress); /// functions /** * @dev sets the token name * @param _name the name of token to set * Only the owner of the token smart contract can call this function * emits a `UpdatedTokenInformation` event */ function setName(string calldata _name) external; /** * @dev sets the token symbol * @param _symbol the token symbol to set * Only the owner of the token smart contract can call this function * emits a `UpdatedTokenInformation` event */ function setSymbol(string calldata _symbol) external; /** * @dev sets the onchain ID of the token * @param _onchainID the address of the onchain ID to set * Only the owner of the token smart contract can call this function * emits a `UpdatedTokenInformation` event */ function setOnchainID(address _onchainID) external; /** * @dev pauses the token contract, when contract is paused investors cannot transfer tokens anymore * This function can only be called by a wallet set as agent of the token * emits a `Paused` event */ function pause() external; /** * @dev unpauses the token contract, when contract is unpaused investors can transfer tokens * if their wallet is not blocked & if the amount to transfer is <= to the amount of free tokens * This function can only be called by a wallet set as agent of the token * emits an `Unpaused` event */ function unpause() external; /** * @dev sets an address frozen status for this token. * @param _userAddress The address for which to update frozen status * @param _freeze Frozen status of the address * This function can only be called by a wallet set as agent of the token * emits an `AddressFrozen` event */ function setAddressFrozen(address _userAddress, bool _freeze) external; /** * @dev freezes token amount specified for given address. * @param _userAddress The address for which to update frozen tokens * @param _amount Amount of Tokens to be frozen * This function can only be called by a wallet set as agent of the token * emits a `TokensFrozen` event */ function freezePartialTokens(address _userAddress, uint256 _amount) external; /** * @dev unfreezes token amount specified for given address * @param _userAddress The address for which to update frozen tokens * @param _amount Amount of Tokens to be unfrozen * This function can only be called by a wallet set as agent of the token * emits a `TokensUnfrozen` event */ function unfreezePartialTokens(address _userAddress, uint256 _amount) external; /** * @dev sets the Identity Registry for the token * @param _identityRegistry the address of the Identity Registry to set * Only the owner of the token smart contract can call this function * emits an `IdentityRegistryAdded` event */ function setIdentityRegistry(address _identityRegistry) external; /** * @dev sets the compliance contract of the token * @param _compliance the address of the compliance contract to set * Only the owner of the token smart contract can call this function * calls bindToken on the compliance contract * emits a `ComplianceAdded` event */ function setCompliance(address _compliance) external; /** * @dev force a transfer of tokens between 2 whitelisted wallets * In case the `from` address has not enough free tokens (unfrozen tokens) * but has a total balance higher or equal to the `amount` * the amount of frozen tokens is reduced in order to have enough free tokens * to proceed the transfer, in such a case, the remaining balance on the `from` * account is 100% composed of frozen tokens post-transfer. * Require that the `to` address is a verified address, * @param _from The address of the sender * @param _to The address of the receiver * @param _amount The number of tokens to transfer * @return `true` if successful and revert if unsuccessful * This function can only be called by a wallet set as agent of the token * emits a `TokensUnfrozen` event if `_amount` is higher than the free balance of `_from` * emits a `Transfer` event */ function forcedTransfer( address _from, address _to, uint256 _amount ) external returns (bool); /** * @dev mint tokens on a wallet * Improved version of default mint method. Tokens can be minted * to an address if only it is a verified address as per the security token. * @param _to Address to mint the tokens to. * @param _amount Amount of tokens to mint. * This function can only be called by a wallet set as agent of the token * emits a `Transfer` event */ function mint(address _to, uint256 _amount) external; /** * @dev burn tokens on a wallet * In case the `account` address has not enough free tokens (unfrozen tokens) * but has a total balance higher or equal to the `value` amount * the amount of frozen tokens is reduced in order to have enough free tokens * to proceed the burn, in such a case, the remaining balance on the `account` * is 100% composed of frozen tokens post-transaction. * @param _userAddress Address to burn the tokens from. * @param _amount Amount of tokens to burn. * This function can only be called by a wallet set as agent of the token * emits a `TokensUnfrozen` event if `_amount` is higher than the free balance of `_userAddress` * emits a `Transfer` event */ function burn(address _userAddress, uint256 _amount) external; /** * @dev recovery function used to force transfer tokens from a * lost wallet to a new wallet for an investor. * @param _lostWallet the wallet that the investor lost * @param _newWallet the newly provided wallet on which tokens have to be transferred * @param _investorOnchainID the onchainID of the investor asking for a recovery * This function can only be called by a wallet set as agent of the token * emits a `TokensUnfrozen` event if there is some frozen tokens on the lost wallet if the recovery process is successful * emits a `Transfer` event if the recovery process is successful * emits a `RecoverySuccess` event if the recovery process is successful * emits a `RecoveryFails` event if the recovery process fails */ function recoveryAddress( address _lostWallet, address _newWallet, address _investorOnchainID ) external returns (bool); /** * @dev function allowing to issue transfers in batch * Require that the msg.sender and `to` addresses are not frozen. * Require that the total value should not exceed available balance. * Require that the `to` addresses are all verified addresses, * IMPORTANT : THIS TRANSACTION COULD EXCEED GAS LIMIT IF `_toList.length` IS TOO HIGH, * USE WITH CARE OR YOU COULD LOSE TX FEES WITH AN "OUT OF GAS" TRANSACTION * @param _toList The addresses of the receivers * @param _amounts The number of tokens to transfer to the corresponding receiver * emits _toList.length `Transfer` events */ function batchTransfer(address[] calldata _toList, uint256[] calldata _amounts) external; /** * @dev function allowing to issue forced transfers in batch * Require that `_amounts[i]` should not exceed available balance of `_fromList[i]`. * Require that the `_toList` addresses are all verified addresses * IMPORTANT : THIS TRANSACTION COULD EXCEED GAS LIMIT IF `_fromList.length` IS TOO HIGH, * USE WITH CARE OR YOU COULD LOSE TX FEES WITH AN "OUT OF GAS" TRANSACTION * @param _fromList The addresses of the senders * @param _toList The addresses of the receivers * @param _amounts The number of tokens to transfer to the corresponding receiver * This function can only be called by a wallet set as agent of the token * emits `TokensUnfrozen` events if `_amounts[i]` is higher than the free balance of `_fromList[i]` * emits _fromList.length `Transfer` events */ function batchForcedTransfer( address[] calldata _fromList, address[] calldata _toList, uint256[] calldata _amounts ) external; /** * @dev function allowing to mint tokens in batch * Require that the `_toList` addresses are all verified addresses * IMPORTANT : THIS TRANSACTION COULD EXCEED GAS LIMIT IF `_toList.length` IS TOO HIGH, * USE WITH CARE OR YOU COULD LOSE TX FEES WITH AN "OUT OF GAS" TRANSACTION * @param _toList The addresses of the receivers * @param _amounts The number of tokens to mint to the corresponding receiver * This function can only be called by a wallet set as agent of the token * emits _toList.length `Transfer` events */ function batchMint(address[] calldata _toList, uint256[] calldata _amounts) external; /** * @dev function allowing to burn tokens in batch * Require that the `_userAddresses` addresses are all verified addresses * IMPORTANT : THIS TRANSACTION COULD EXCEED GAS LIMIT IF `_userAddresses.length` IS TOO HIGH, * USE WITH CARE OR YOU COULD LOSE TX FEES WITH AN "OUT OF GAS" TRANSACTION * @param _userAddresses The addresses of the wallets concerned by the burn * @param _amounts The number of tokens to burn from the corresponding wallets * This function can only be called by a wallet set as agent of the token * emits _userAddresses.length `Transfer` events */ function batchBurn(address[] calldata _userAddresses, uint256[] calldata _amounts) external; /** * @dev function allowing to set frozen addresses in batch * IMPORTANT : THIS TRANSACTION COULD EXCEED GAS LIMIT IF `_userAddresses.length` IS TOO HIGH, * USE WITH CARE OR YOU COULD LOSE TX FEES WITH AN "OUT OF GAS" TRANSACTION * @param _userAddresses The addresses for which to update frozen status * @param _freeze Frozen status of the corresponding address * This function can only be called by a wallet set as agent of the token * emits _userAddresses.length `AddressFrozen` events */ function batchSetAddressFrozen(address[] calldata _userAddresses, bool[] calldata _freeze) external; /** * @dev function allowing to freeze tokens partially in batch * IMPORTANT : THIS TRANSACTION COULD EXCEED GAS LIMIT IF `_userAddresses.length` IS TOO HIGH, * USE WITH CARE OR YOU COULD LOSE TX FEES WITH AN "OUT OF GAS" TRANSACTION * @param _userAddresses The addresses on which tokens need to be frozen * @param _amounts the amount of tokens to freeze on the corresponding address * This function can only be called by a wallet set as agent of the token * emits _userAddresses.length `TokensFrozen` events */ function batchFreezePartialTokens(address[] calldata _userAddresses, uint256[] calldata _amounts) external; /** * @dev function allowing to unfreeze tokens partially in batch * IMPORTANT : THIS TRANSACTION COULD EXCEED GAS LIMIT IF `_userAddresses.length` IS TOO HIGH, * USE WITH CARE OR YOU COULD LOSE TX FEES WITH AN "OUT OF GAS" TRANSACTION * @param _userAddresses The addresses on which tokens need to be unfrozen * @param _amounts the amount of tokens to unfreeze on the corresponding address * This function can only be called by a wallet set as agent of the token * emits _userAddresses.length `TokensUnfrozen` events */ function batchUnfreezePartialTokens(address[] calldata _userAddresses, uint256[] calldata _amounts) external; /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 1 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * balanceOf() and transfer(). */ function decimals() external view returns (uint8); /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the address of the onchainID of the token. * the onchainID of the token gives all the information available * about the token and is managed by the token issuer or his agent. */ function onchainID() external view returns (address); /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() external view returns (string memory); /** * @dev Returns the TREX version of the token. * current version is 3.0.0 */ function version() external view returns (string memory); /** * @dev Returns the Identity Registry linked to the token */ function identityRegistry() external view returns (IIdentityRegistry); /** * @dev Returns the Compliance contract linked to the token */ function compliance() external view returns (IModularCompliance); /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() external view returns (bool); /** * @dev Returns the freezing status of a wallet * if isFrozen returns `true` the wallet is frozen * if isFrozen returns `false` the wallet is not frozen * isFrozen returning `true` doesn't mean that the balance is free, tokens could be blocked by * a partial freeze or the whole token could be blocked by pause * @param _userAddress the address of the wallet on which isFrozen is called */ function isFrozen(address _userAddress) external view returns (bool); /** * @dev Returns the amount of tokens that are partially frozen on a wallet * the amount of frozen tokens is always <= to the total balance of the wallet * @param _userAddress the address of the wallet on which getFrozenTokens is called */ function getFrozenTokens(address _userAddress) external view returns (uint256); }
// SPDX-License-Identifier: GPL-3.0 // // :+#####%%%%%%%%%%%%%%+ // .-*@@@%+.:+%@@@@@%%#***%@@%= // :=*%@@@#=. :#@@% *@@@%= // .-+*%@%*-.:+%@@@@@@+. -*+: .=#. :%@@@%- // :=*@@@@%%@@@@@@@@@%@@@- .=#@@@%@%= =@@@@#. // -=+#%@@%#*=:. :%@@@@%. -*@@#*@@@@@@@#=:- *@@@@+ // =@@%=:. :=: *@@@@@%#- =%*%@@@@#+-. =+ :%@@@%- // -@@%. .+@@@ =+=-. @@#- +@@@%- =@@@@%: // :@@@. .+@@#%: : .=*=-::.-%@@@+*@@= +@@@@#. // %@@: +@%%* =%@@@@@@@@@@@#. .*@%- +@@@@*. // #@@= .+@@@@%:=*@@@@@- :%@%: .*@@@@+ // *@@* +@@@#-@@%-:%@@* +@@#. :%@@@@- // -@@% .:-=++*##%%%@@@@@@@@@@@@*. :@+.@@@%: .#@@+ =@@@@#: // .@@@*-+*#%%%@@@@@@@@@@@@@@@@%%#**@@%@@@. *@=*@@# :#@%= .#@@@@#- // -%@@@@@@@@@@@@@@@*+==-:-@@@= *@# .#@*-=*@@@@%= -%@@@* =@@@@@%- // -+%@@@#. %@%%= -@@:+@: -@@* *@@*-:: -%@@%=. .*@@@@@# // *@@@* +@* *@@##@@- #@*@@+ -@@= . :+@@@#: .-+@@@%+- // +@@@%*@@:..=@@@@* .@@@* .#@#. .=+- .=%@@@*. :+#@@@@*=: // =@@@@%@@@@@@@@@@@@@@@@@@@@@@%- :+#*. :*@@@%=. .=#@@@@%+: // .%@@= ..... .=#@@+. .#@@@*: -*%@@@@%+. // +@@#+===---:::... .=%@@*- +@@@+. -*@@@@@%+. // -@@@@@@@@@@@@@@@@@@@@@@%@@@@= -@@@+ -#@@@@@#=. // ..:::---===+++***###%%%@@@#- .#@@+ -*@@@@@#=. // @@@@@@+. +@@*. .+@@@@@%=. // -@@@@@= =@@%: -#@@@@%+. // +@@@@@. =@@@= .+@@@@@*: // #@@@@#:%@@#. :*@@@@#- // @@@@@%@@@= :#@@@@+. // :@@@@@@@#.:#@@@%- // +@@@@@@-.*@@@*: // #@@@@#.=@@@+. // @@@@+-%@%= // :@@@#%@%= // +@@@@%- // :#%%= // /** * NOTICE * * The T-REX software is licensed under a proprietary license or the GPL v.3. * If you choose to receive it under the GPL v.3 license, the following applies: * 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. * * 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 * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. */ pragma solidity 0.8.17; import "./ITrustedIssuersRegistry.sol"; import "./IClaimTopicsRegistry.sol"; import "./IIdentityRegistryStorage.sol"; import "@onchain-id/solidity/contracts/interface/IClaimIssuer.sol"; import "@onchain-id/solidity/contracts/interface/IIdentity.sol"; interface IIdentityRegistry { /** * this event is emitted when the ClaimTopicsRegistry has been set for the IdentityRegistry * the event is emitted by the IdentityRegistry constructor * `claimTopicsRegistry` is the address of the Claim Topics Registry contract */ event ClaimTopicsRegistrySet(address indexed claimTopicsRegistry); /** * this event is emitted when the IdentityRegistryStorage has been set for the IdentityRegistry * the event is emitted by the IdentityRegistry constructor * `identityStorage` is the address of the Identity Registry Storage contract */ event IdentityStorageSet(address indexed identityStorage); /** * this event is emitted when the TrustedIssuersRegistry has been set for the IdentityRegistry * the event is emitted by the IdentityRegistry constructor * `trustedIssuersRegistry` is the address of the Trusted Issuers Registry contract */ event TrustedIssuersRegistrySet(address indexed trustedIssuersRegistry); /** * this event is emitted when an Identity is registered into the Identity Registry. * the event is emitted by the 'registerIdentity' function * `investorAddress` is the address of the investor's wallet * `identity` is the address of the Identity smart contract (onchainID) */ event IdentityRegistered(address indexed investorAddress, IIdentity indexed identity); /** * this event is emitted when an Identity is removed from the Identity Registry. * the event is emitted by the 'deleteIdentity' function * `investorAddress` is the address of the investor's wallet * `identity` is the address of the Identity smart contract (onchainID) */ event IdentityRemoved(address indexed investorAddress, IIdentity indexed identity); /** * this event is emitted when an Identity has been updated * the event is emitted by the 'updateIdentity' function * `oldIdentity` is the old Identity contract's address to update * `newIdentity` is the new Identity contract's */ event IdentityUpdated(IIdentity indexed oldIdentity, IIdentity indexed newIdentity); /** * this event is emitted when an Identity's country has been updated * the event is emitted by the 'updateCountry' function * `investorAddress` is the address on which the country has been updated * `country` is the numeric code (ISO 3166-1) of the new country */ event CountryUpdated(address indexed investorAddress, uint16 indexed country); /** * @dev Register an identity contract corresponding to a user address. * Requires that the user doesn't have an identity contract already registered. * This function can only be called by a wallet set as agent of the smart contract * @param _userAddress The address of the user * @param _identity The address of the user's identity contract * @param _country The country of the investor * emits `IdentityRegistered` event */ function registerIdentity( address _userAddress, IIdentity _identity, uint16 _country ) external; /** * @dev Removes an user from the identity registry. * Requires that the user have an identity contract already deployed that will be deleted. * This function can only be called by a wallet set as agent of the smart contract * @param _userAddress The address of the user to be removed * emits `IdentityRemoved` event */ function deleteIdentity(address _userAddress) external; /** * @dev Replace the actual identityRegistryStorage contract with a new one. * This function can only be called by the wallet set as owner of the smart contract * @param _identityRegistryStorage The address of the new Identity Registry Storage * emits `IdentityStorageSet` event */ function setIdentityRegistryStorage(address _identityRegistryStorage) external; /** * @dev Replace the actual claimTopicsRegistry contract with a new one. * This function can only be called by the wallet set as owner of the smart contract * @param _claimTopicsRegistry The address of the new claim Topics Registry * emits `ClaimTopicsRegistrySet` event */ function setClaimTopicsRegistry(address _claimTopicsRegistry) external; /** * @dev Replace the actual trustedIssuersRegistry contract with a new one. * This function can only be called by the wallet set as owner of the smart contract * @param _trustedIssuersRegistry The address of the new Trusted Issuers Registry * emits `TrustedIssuersRegistrySet` event */ function setTrustedIssuersRegistry(address _trustedIssuersRegistry) external; /** * @dev Updates the country corresponding to a user address. * Requires that the user should have an identity contract already deployed that will be replaced. * This function can only be called by a wallet set as agent of the smart contract * @param _userAddress The address of the user * @param _country The new country of the user * emits `CountryUpdated` event */ function updateCountry(address _userAddress, uint16 _country) external; /** * @dev Updates an identity contract corresponding to a user address. * Requires that the user address should be the owner of the identity contract. * Requires that the user should have an identity contract already deployed that will be replaced. * This function can only be called by a wallet set as agent of the smart contract * @param _userAddress The address of the user * @param _identity The address of the user's new identity contract * emits `IdentityUpdated` event */ function updateIdentity(address _userAddress, IIdentity _identity) external; /** * @dev function allowing to register identities in batch * This function can only be called by a wallet set as agent of the smart contract * Requires that none of the users has an identity contract already registered. * IMPORTANT : THIS TRANSACTION COULD EXCEED GAS LIMIT IF `_userAddresses.length` IS TOO HIGH, * USE WITH CARE OR YOU COULD LOSE TX FEES WITH AN "OUT OF GAS" TRANSACTION * @param _userAddresses The addresses of the users * @param _identities The addresses of the corresponding identity contracts * @param _countries The countries of the corresponding investors * emits _userAddresses.length `IdentityRegistered` events */ function batchRegisterIdentity( address[] calldata _userAddresses, IIdentity[] calldata _identities, uint16[] calldata _countries ) external; /** * @dev This functions checks whether a wallet has its Identity registered or not * in the Identity Registry. * @param _userAddress The address of the user to be checked. * @return 'True' if the address is contained in the Identity Registry, 'false' if not. */ function contains(address _userAddress) external view returns (bool); /** * @dev This functions checks whether an identity contract * corresponding to the provided user address has the required claims or not based * on the data fetched from trusted issuers registry and from the claim topics registry * @param _userAddress The address of the user to be verified. * @return 'True' if the address is verified, 'false' if not. */ function isVerified(address _userAddress) external view returns (bool); /** * @dev Returns the onchainID of an investor. * @param _userAddress The wallet of the investor */ function identity(address _userAddress) external view returns (IIdentity); /** * @dev Returns the country code of an investor. * @param _userAddress The wallet of the investor */ function investorCountry(address _userAddress) external view returns (uint16); /** * @dev Returns the IdentityRegistryStorage linked to the current IdentityRegistry. */ function identityStorage() external view returns (IIdentityRegistryStorage); /** * @dev Returns the TrustedIssuersRegistry linked to the current IdentityRegistry. */ function issuersRegistry() external view returns (ITrustedIssuersRegistry); /** * @dev Returns the ClaimTopicsRegistry linked to the current IdentityRegistry. */ function topicsRegistry() external view returns (IClaimTopicsRegistry); }
// SPDX-License-Identifier: GPL-3.0 // // :+#####%%%%%%%%%%%%%%+ // .-*@@@%+.:+%@@@@@%%#***%@@%= // :=*%@@@#=. :#@@% *@@@%= // .-+*%@%*-.:+%@@@@@@+. -*+: .=#. :%@@@%- // :=*@@@@%%@@@@@@@@@%@@@- .=#@@@%@%= =@@@@#. // -=+#%@@%#*=:. :%@@@@%. -*@@#*@@@@@@@#=:- *@@@@+ // =@@%=:. :=: *@@@@@%#- =%*%@@@@#+-. =+ :%@@@%- // -@@%. .+@@@ =+=-. @@#- +@@@%- =@@@@%: // :@@@. .+@@#%: : .=*=-::.-%@@@+*@@= +@@@@#. // %@@: +@%%* =%@@@@@@@@@@@#. .*@%- +@@@@*. // #@@= .+@@@@%:=*@@@@@- :%@%: .*@@@@+ // *@@* +@@@#-@@%-:%@@* +@@#. :%@@@@- // -@@% .:-=++*##%%%@@@@@@@@@@@@*. :@+.@@@%: .#@@+ =@@@@#: // .@@@*-+*#%%%@@@@@@@@@@@@@@@@%%#**@@%@@@. *@=*@@# :#@%= .#@@@@#- // -%@@@@@@@@@@@@@@@*+==-:-@@@= *@# .#@*-=*@@@@%= -%@@@* =@@@@@%- // -+%@@@#. %@%%= -@@:+@: -@@* *@@*-:: -%@@%=. .*@@@@@# // *@@@* +@* *@@##@@- #@*@@+ -@@= . :+@@@#: .-+@@@%+- // +@@@%*@@:..=@@@@* .@@@* .#@#. .=+- .=%@@@*. :+#@@@@*=: // =@@@@%@@@@@@@@@@@@@@@@@@@@@@%- :+#*. :*@@@%=. .=#@@@@%+: // .%@@= ..... .=#@@+. .#@@@*: -*%@@@@%+. // +@@#+===---:::... .=%@@*- +@@@+. -*@@@@@%+. // -@@@@@@@@@@@@@@@@@@@@@@%@@@@= -@@@+ -#@@@@@#=. // ..:::---===+++***###%%%@@@#- .#@@+ -*@@@@@#=. // @@@@@@+. +@@*. .+@@@@@%=. // -@@@@@= =@@%: -#@@@@%+. // +@@@@@. =@@@= .+@@@@@*: // #@@@@#:%@@#. :*@@@@#- // @@@@@%@@@= :#@@@@+. // :@@@@@@@#.:#@@@%- // +@@@@@@-.*@@@*: // #@@@@#.=@@@+. // @@@@+-%@%= // :@@@#%@%= // +@@@@%- // :#%%= // /** * NOTICE * * The T-REX software is licensed under a proprietary license or the GPL v.3. * If you choose to receive it under the GPL v.3 license, the following applies: * 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. * * 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 * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. */ pragma solidity 0.8.17; interface IModularCompliance { /// events /** * @dev Event emitted for each executed interaction with a module contract. * For gas efficiency, only the interaction calldata selector (first 4 * bytes) is included in the event. For interactions without calldata or * whose calldata is shorter than 4 bytes, the selector will be `0`. */ event ModuleInteraction(address indexed target, bytes4 selector); /** * this event is emitted when a token has been bound to the compliance contract * the event is emitted by the bindToken function * `_token` is the address of the token to bind */ event TokenBound(address _token); /** * this event is emitted when a token has been unbound from the compliance contract * the event is emitted by the unbindToken function * `_token` is the address of the token to unbind */ event TokenUnbound(address _token); /** * this event is emitted when a module has been added to the list of modules bound to the compliance contract * the event is emitted by the addModule function * `_module` is the address of the compliance module */ event ModuleAdded(address indexed _module); /** * this event is emitted when a module has been removed from the list of modules bound to the compliance contract * the event is emitted by the removeModule function * `_module` is the address of the compliance module */ event ModuleRemoved(address indexed _module); /// functions /** * @dev binds a token to the compliance contract * @param _token address of the token to bind * This function can be called ONLY by the owner of the compliance contract * Emits a TokenBound event */ function bindToken(address _token) external; /** * @dev unbinds a token from the compliance contract * @param _token address of the token to unbind * This function can be called ONLY by the owner of the compliance contract * Emits a TokenUnbound event */ function unbindToken(address _token) external; /** * @dev adds a module to the list of compliance modules * @param _module address of the module to add * there cannot be more than 25 modules bound to the modular compliance for gas cost reasons * This function can be called ONLY by the owner of the compliance contract * Emits a ModuleAdded event */ function addModule(address _module) external; /** * @dev removes a module from the list of compliance modules * @param _module address of the module to remove * This function can be called ONLY by the owner of the compliance contract * Emits a ModuleRemoved event */ function removeModule(address _module) external; /** * @dev calls any function on bound modules * can be called only on bound modules * @param callData the bytecode for interaction with the module, abi encoded * @param _module The address of the module * This function can be called only by the modular compliance owner * emits a `ModuleInteraction` event */ function callModuleFunction(bytes calldata callData, address _module) external; /** * @dev function called whenever tokens are transferred * from one wallet to another * this function can update state variables in the modules bound to the compliance * these state variables being used by the module checks to decide if a transfer * is compliant or not depending on the values stored in these state variables and on * the parameters of the modules * This function can be called ONLY by the token contract bound to the compliance * @param _from The address of the sender * @param _to The address of the receiver * @param _amount The amount of tokens involved in the transfer * This function calls moduleTransferAction() on each module bound to the compliance contract */ function transferred( address _from, address _to, uint256 _amount ) external; /** * @dev function called whenever tokens are created on a wallet * this function can update state variables in the modules bound to the compliance * these state variables being used by the module checks to decide if a transfer * is compliant or not depending on the values stored in these state variables and on * the parameters of the modules * This function can be called ONLY by the token contract bound to the compliance * @param _to The address of the receiver * @param _amount The amount of tokens involved in the minting * This function calls moduleMintAction() on each module bound to the compliance contract */ function created(address _to, uint256 _amount) external; /** * @dev function called whenever tokens are destroyed from a wallet * this function can update state variables in the modules bound to the compliance * these state variables being used by the module checks to decide if a transfer * is compliant or not depending on the values stored in these state variables and on * the parameters of the modules * This function can be called ONLY by the token contract bound to the compliance * @param _from The address on which tokens are burnt * @param _amount The amount of tokens involved in the burn * This function calls moduleBurnAction() on each module bound to the compliance contract */ function destroyed(address _from, uint256 _amount) external; /** * @dev checks that the transfer is compliant. * default compliance always returns true * READ ONLY FUNCTION, this function cannot be used to increment * counters, emit events, ... * @param _from The address of the sender * @param _to The address of the receiver * @param _amount The amount of tokens involved in the transfer * This function will call moduleCheck() on every module bound to the compliance * If each of the module checks return TRUE, this function will return TRUE as well * returns FALSE otherwise */ function canTransfer( address _from, address _to, uint256 _amount ) external view returns (bool); /** * @dev getter for the modules bound to the compliance contract * returns address array of module contracts bound to the compliance */ function getModules() external view returns (address[] memory); /** * @dev getter for the address of the token bound * returns the address of the token */ function getTokenBound() external view returns (address); /** * @dev checks if a module is bound to the compliance contract * returns true if module is bound, false otherwise */ function isModuleBound(address _module) external view returns (bool); }
// SPDX-License-Identifier: GPL-3.0 // // :+#####%%%%%%%%%%%%%%+ // .-*@@@%+.:+%@@@@@%%#***%@@%= // :=*%@@@#=. :#@@% *@@@%= // .-+*%@%*-.:+%@@@@@@+. -*+: .=#. :%@@@%- // :=*@@@@%%@@@@@@@@@%@@@- .=#@@@%@%= =@@@@#. // -=+#%@@%#*=:. :%@@@@%. -*@@#*@@@@@@@#=:- *@@@@+ // =@@%=:. :=: *@@@@@%#- =%*%@@@@#+-. =+ :%@@@%- // -@@%. .+@@@ =+=-. @@#- +@@@%- =@@@@%: // :@@@. .+@@#%: : .=*=-::.-%@@@+*@@= +@@@@#. // %@@: +@%%* =%@@@@@@@@@@@#. .*@%- +@@@@*. // #@@= .+@@@@%:=*@@@@@- :%@%: .*@@@@+ // *@@* +@@@#-@@%-:%@@* +@@#. :%@@@@- // -@@% .:-=++*##%%%@@@@@@@@@@@@*. :@+.@@@%: .#@@+ =@@@@#: // .@@@*-+*#%%%@@@@@@@@@@@@@@@@%%#**@@%@@@. *@=*@@# :#@%= .#@@@@#- // -%@@@@@@@@@@@@@@@*+==-:-@@@= *@# .#@*-=*@@@@%= -%@@@* =@@@@@%- // -+%@@@#. %@%%= -@@:+@: -@@* *@@*-:: -%@@%=. .*@@@@@# // *@@@* +@* *@@##@@- #@*@@+ -@@= . :+@@@#: .-+@@@%+- // +@@@%*@@:..=@@@@* .@@@* .#@#. .=+- .=%@@@*. :+#@@@@*=: // =@@@@%@@@@@@@@@@@@@@@@@@@@@@%- :+#*. :*@@@%=. .=#@@@@%+: // .%@@= ..... .=#@@+. .#@@@*: -*%@@@@%+. // +@@#+===---:::... .=%@@*- +@@@+. -*@@@@@%+. // -@@@@@@@@@@@@@@@@@@@@@@%@@@@= -@@@+ -#@@@@@#=. // ..:::---===+++***###%%%@@@#- .#@@+ -*@@@@@#=. // @@@@@@+. +@@*. .+@@@@@%=. // -@@@@@= =@@%: -#@@@@%+. // +@@@@@. =@@@= .+@@@@@*: // #@@@@#:%@@#. :*@@@@#- // @@@@@%@@@= :#@@@@+. // :@@@@@@@#.:#@@@%- // +@@@@@@-.*@@@*: // #@@@@#.=@@@+. // @@@@+-%@%= // :@@@#%@%= // +@@@@%- // :#%%= // /** * NOTICE * * The T-REX software is licensed under a proprietary license or the GPL v.3. * If you choose to receive it under the GPL v.3 license, the following applies: * 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. * * 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 * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. */ pragma solidity 0.8.17; import "@onchain-id/solidity/contracts/interface/IClaimIssuer.sol"; interface ITrustedIssuersRegistry { /** * this event is emitted when a trusted issuer is added in the registry. * the event is emitted by the addTrustedIssuer function * `trustedIssuer` is the address of the trusted issuer's ClaimIssuer contract * `claimTopics` is the set of claims that the trusted issuer is allowed to emit */ event TrustedIssuerAdded(IClaimIssuer indexed trustedIssuer, uint256[] claimTopics); /** * this event is emitted when a trusted issuer is removed from the registry. * the event is emitted by the removeTrustedIssuer function * `trustedIssuer` is the address of the trusted issuer's ClaimIssuer contract */ event TrustedIssuerRemoved(IClaimIssuer indexed trustedIssuer); /** * this event is emitted when the set of claim topics is changed for a given trusted issuer. * the event is emitted by the updateIssuerClaimTopics function * `trustedIssuer` is the address of the trusted issuer's ClaimIssuer contract * `claimTopics` is the set of claims that the trusted issuer is allowed to emit */ event ClaimTopicsUpdated(IClaimIssuer indexed trustedIssuer, uint256[] claimTopics); /** * @dev registers a ClaimIssuer contract as trusted claim issuer. * Requires that a ClaimIssuer contract doesn't already exist * Requires that the claimTopics set is not empty * Requires that there is no more than 15 claimTopics * Requires that there is no more than 50 Trusted issuers * @param _trustedIssuer The ClaimIssuer contract address of the trusted claim issuer. * @param _claimTopics the set of claim topics that the trusted issuer is allowed to emit * This function can only be called by the owner of the Trusted Issuers Registry contract * emits a `TrustedIssuerAdded` event */ function addTrustedIssuer(IClaimIssuer _trustedIssuer, uint256[] calldata _claimTopics) external; /** * @dev Removes the ClaimIssuer contract of a trusted claim issuer. * Requires that the claim issuer contract to be registered first * @param _trustedIssuer the claim issuer to remove. * This function can only be called by the owner of the Trusted Issuers Registry contract * emits a `TrustedIssuerRemoved` event */ function removeTrustedIssuer(IClaimIssuer _trustedIssuer) external; /** * @dev Updates the set of claim topics that a trusted issuer is allowed to emit. * Requires that this ClaimIssuer contract already exists in the registry * Requires that the provided claimTopics set is not empty * Requires that there is no more than 15 claimTopics * @param _trustedIssuer the claim issuer to update. * @param _claimTopics the set of claim topics that the trusted issuer is allowed to emit * This function can only be called by the owner of the Trusted Issuers Registry contract * emits a `ClaimTopicsUpdated` event */ function updateIssuerClaimTopics(IClaimIssuer _trustedIssuer, uint256[] calldata _claimTopics) external; /** * @dev Function for getting all the trusted claim issuers stored. * @return array of all claim issuers registered. */ function getTrustedIssuers() external view returns (IClaimIssuer[] memory); /** * @dev Function for getting all the trusted issuer allowed for a given claim topic. * @param claimTopic the claim topic to get the trusted issuers for. * @return array of all claim issuer addresses that are allowed for the given claim topic. */ function getTrustedIssuersForClaimTopic(uint256 claimTopic) external view returns (IClaimIssuer[] memory); /** * @dev Checks if the ClaimIssuer contract is trusted * @param _issuer the address of the ClaimIssuer contract * @return true if the issuer is trusted, false otherwise. */ function isTrustedIssuer(address _issuer) external view returns (bool); /** * @dev Function for getting all the claim topic of trusted claim issuer * Requires the provided ClaimIssuer contract to be registered in the trusted issuers registry. * @param _trustedIssuer the trusted issuer concerned. * @return The set of claim topics that the trusted issuer is allowed to emit */ function getTrustedIssuerClaimTopics(IClaimIssuer _trustedIssuer) external view returns (uint256[] memory); /** * @dev Function for checking if the trusted claim issuer is allowed * to emit a certain claim topic * @param _issuer the address of the trusted issuer's ClaimIssuer contract * @param _claimTopic the Claim Topic that has to be checked to know if the `issuer` is allowed to emit it * @return true if the issuer is trusted for this claim topic. */ function hasClaimTopic(address _issuer, uint256 _claimTopic) external view returns (bool); }
// SPDX-License-Identifier: GPL-3.0 // // :+#####%%%%%%%%%%%%%%+ // .-*@@@%+.:+%@@@@@%%#***%@@%= // :=*%@@@#=. :#@@% *@@@%= // .-+*%@%*-.:+%@@@@@@+. -*+: .=#. :%@@@%- // :=*@@@@%%@@@@@@@@@%@@@- .=#@@@%@%= =@@@@#. // -=+#%@@%#*=:. :%@@@@%. -*@@#*@@@@@@@#=:- *@@@@+ // =@@%=:. :=: *@@@@@%#- =%*%@@@@#+-. =+ :%@@@%- // -@@%. .+@@@ =+=-. @@#- +@@@%- =@@@@%: // :@@@. .+@@#%: : .=*=-::.-%@@@+*@@= +@@@@#. // %@@: +@%%* =%@@@@@@@@@@@#. .*@%- +@@@@*. // #@@= .+@@@@%:=*@@@@@- :%@%: .*@@@@+ // *@@* +@@@#-@@%-:%@@* +@@#. :%@@@@- // -@@% .:-=++*##%%%@@@@@@@@@@@@*. :@+.@@@%: .#@@+ =@@@@#: // .@@@*-+*#%%%@@@@@@@@@@@@@@@@%%#**@@%@@@. *@=*@@# :#@%= .#@@@@#- // -%@@@@@@@@@@@@@@@*+==-:-@@@= *@# .#@*-=*@@@@%= -%@@@* =@@@@@%- // -+%@@@#. %@%%= -@@:+@: -@@* *@@*-:: -%@@%=. .*@@@@@# // *@@@* +@* *@@##@@- #@*@@+ -@@= . :+@@@#: .-+@@@%+- // +@@@%*@@:..=@@@@* .@@@* .#@#. .=+- .=%@@@*. :+#@@@@*=: // =@@@@%@@@@@@@@@@@@@@@@@@@@@@%- :+#*. :*@@@%=. .=#@@@@%+: // .%@@= ..... .=#@@+. .#@@@*: -*%@@@@%+. // +@@#+===---:::... .=%@@*- +@@@+. -*@@@@@%+. // -@@@@@@@@@@@@@@@@@@@@@@%@@@@= -@@@+ -#@@@@@#=. // ..:::---===+++***###%%%@@@#- .#@@+ -*@@@@@#=. // @@@@@@+. +@@*. .+@@@@@%=. // -@@@@@= =@@%: -#@@@@%+. // +@@@@@. =@@@= .+@@@@@*: // #@@@@#:%@@#. :*@@@@#- // @@@@@%@@@= :#@@@@+. // :@@@@@@@#.:#@@@%- // +@@@@@@-.*@@@*: // #@@@@#.=@@@+. // @@@@+-%@%= // :@@@#%@%= // +@@@@%- // :#%%= // /** * NOTICE * * The T-REX software is licensed under a proprietary license or the GPL v.3. * If you choose to receive it under the GPL v.3 license, the following applies: * 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. * * 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 * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. */ pragma solidity 0.8.17; interface IClaimTopicsRegistry { /** * this event is emitted when a claim topic has been added to the ClaimTopicsRegistry * the event is emitted by the 'addClaimTopic' function * `claimTopic` is the required claim added to the Claim Topics Registry */ event ClaimTopicAdded(uint256 indexed claimTopic); /** * this event is emitted when a claim topic has been removed from the ClaimTopicsRegistry * the event is emitted by the 'removeClaimTopic' function * `claimTopic` is the required claim removed from the Claim Topics Registry */ event ClaimTopicRemoved(uint256 indexed claimTopic); /** * @dev Add a trusted claim topic (For example: KYC=1, AML=2). * Only owner can call. * emits `ClaimTopicAdded` event * cannot add more than 15 topics for 1 token as adding more could create gas issues * @param _claimTopic The claim topic index */ function addClaimTopic(uint256 _claimTopic) external; /** * @dev Remove a trusted claim topic (For example: KYC=1, AML=2). * Only owner can call. * emits `ClaimTopicRemoved` event * @param _claimTopic The claim topic index */ function removeClaimTopic(uint256 _claimTopic) external; /** * @dev Get the trusted claim topics for the security token * @return Array of trusted claim topics */ function getClaimTopics() external view returns (uint256[] memory); }
// SPDX-License-Identifier: GPL-3.0 // // :+#####%%%%%%%%%%%%%%+ // .-*@@@%+.:+%@@@@@%%#***%@@%= // :=*%@@@#=. :#@@% *@@@%= // .-+*%@%*-.:+%@@@@@@+. -*+: .=#. :%@@@%- // :=*@@@@%%@@@@@@@@@%@@@- .=#@@@%@%= =@@@@#. // -=+#%@@%#*=:. :%@@@@%. -*@@#*@@@@@@@#=:- *@@@@+ // =@@%=:. :=: *@@@@@%#- =%*%@@@@#+-. =+ :%@@@%- // -@@%. .+@@@ =+=-. @@#- +@@@%- =@@@@%: // :@@@. .+@@#%: : .=*=-::.-%@@@+*@@= +@@@@#. // %@@: +@%%* =%@@@@@@@@@@@#. .*@%- +@@@@*. // #@@= .+@@@@%:=*@@@@@- :%@%: .*@@@@+ // *@@* +@@@#-@@%-:%@@* +@@#. :%@@@@- // -@@% .:-=++*##%%%@@@@@@@@@@@@*. :@+.@@@%: .#@@+ =@@@@#: // .@@@*-+*#%%%@@@@@@@@@@@@@@@@%%#**@@%@@@. *@=*@@# :#@%= .#@@@@#- // -%@@@@@@@@@@@@@@@*+==-:-@@@= *@# .#@*-=*@@@@%= -%@@@* =@@@@@%- // -+%@@@#. %@%%= -@@:+@: -@@* *@@*-:: -%@@%=. .*@@@@@# // *@@@* +@* *@@##@@- #@*@@+ -@@= . :+@@@#: .-+@@@%+- // +@@@%*@@:..=@@@@* .@@@* .#@#. .=+- .=%@@@*. :+#@@@@*=: // =@@@@%@@@@@@@@@@@@@@@@@@@@@@%- :+#*. :*@@@%=. .=#@@@@%+: // .%@@= ..... .=#@@+. .#@@@*: -*%@@@@%+. // +@@#+===---:::... .=%@@*- +@@@+. -*@@@@@%+. // -@@@@@@@@@@@@@@@@@@@@@@%@@@@= -@@@+ -#@@@@@#=. // ..:::---===+++***###%%%@@@#- .#@@+ -*@@@@@#=. // @@@@@@+. +@@*. .+@@@@@%=. // -@@@@@= =@@%: -#@@@@%+. // +@@@@@. =@@@= .+@@@@@*: // #@@@@#:%@@#. :*@@@@#- // @@@@@%@@@= :#@@@@+. // :@@@@@@@#.:#@@@%- // +@@@@@@-.*@@@*: // #@@@@#.=@@@+. // @@@@+-%@%= // :@@@#%@%= // +@@@@%- // :#%%= // /** * NOTICE * * The T-REX software is licensed under a proprietary license or the GPL v.3. * If you choose to receive it under the GPL v.3 license, the following applies: * 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. * * 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 * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. */ pragma solidity 0.8.17; import "@onchain-id/solidity/contracts/interface/IIdentity.sol"; interface IIdentityRegistryStorage { /// events /** * this event is emitted when an Identity is registered into the storage contract. * the event is emitted by the 'registerIdentity' function * `investorAddress` is the address of the investor's wallet * `identity` is the address of the Identity smart contract (onchainID) */ event IdentityStored(address indexed investorAddress, IIdentity indexed identity); /** * this event is emitted when an Identity is removed from the storage contract. * the event is emitted by the 'deleteIdentity' function * `investorAddress` is the address of the investor's wallet * `identity` is the address of the Identity smart contract (onchainID) */ event IdentityUnstored(address indexed investorAddress, IIdentity indexed identity); /** * this event is emitted when an Identity has been updated * the event is emitted by the 'updateIdentity' function * `oldIdentity` is the old Identity contract's address to update * `newIdentity` is the new Identity contract's */ event IdentityModified(IIdentity indexed oldIdentity, IIdentity indexed newIdentity); /** * this event is emitted when an Identity's country has been updated * the event is emitted by the 'updateCountry' function * `investorAddress` is the address on which the country has been updated * `country` is the numeric code (ISO 3166-1) of the new country */ event CountryModified(address indexed investorAddress, uint16 indexed country); /** * this event is emitted when an Identity Registry is bound to the storage contract * the event is emitted by the 'addIdentityRegistry' function * `identityRegistry` is the address of the identity registry added */ event IdentityRegistryBound(address indexed identityRegistry); /** * this event is emitted when an Identity Registry is unbound from the storage contract * the event is emitted by the 'removeIdentityRegistry' function * `identityRegistry` is the address of the identity registry removed */ event IdentityRegistryUnbound(address indexed identityRegistry); /// functions /** * @dev adds an identity contract corresponding to a user address in the storage. * Requires that the user doesn't have an identity contract already registered. * This function can only be called by an address set as agent of the smart contract * @param _userAddress The address of the user * @param _identity The address of the user's identity contract * @param _country The country of the investor * emits `IdentityStored` event */ function addIdentityToStorage( address _userAddress, IIdentity _identity, uint16 _country ) external; /** * @dev Removes an user from the storage. * Requires that the user have an identity contract already deployed that will be deleted. * This function can only be called by an address set as agent of the smart contract * @param _userAddress The address of the user to be removed * emits `IdentityUnstored` event */ function removeIdentityFromStorage(address _userAddress) external; /** * @dev Updates the country corresponding to a user address. * Requires that the user should have an identity contract already deployed that will be replaced. * This function can only be called by an address set as agent of the smart contract * @param _userAddress The address of the user * @param _country The new country of the user * emits `CountryModified` event */ function modifyStoredInvestorCountry(address _userAddress, uint16 _country) external; /** * @dev Updates an identity contract corresponding to a user address. * Requires that the user address should be the owner of the identity contract. * Requires that the user should have an identity contract already deployed that will be replaced. * This function can only be called by an address set as agent of the smart contract * @param _userAddress The address of the user * @param _identity The address of the user's new identity contract * emits `IdentityModified` event */ function modifyStoredIdentity(address _userAddress, IIdentity _identity) external; /** * @notice Adds an identity registry as agent of the Identity Registry Storage Contract. * This function can only be called by the wallet set as owner of the smart contract * This function adds the identity registry to the list of identityRegistries linked to the storage contract * cannot bind more than 300 IR to 1 IRS * @param _identityRegistry The identity registry address to add. */ function bindIdentityRegistry(address _identityRegistry) external; /** * @notice Removes an identity registry from being agent of the Identity Registry Storage Contract. * This function can only be called by the wallet set as owner of the smart contract * This function removes the identity registry from the list of identityRegistries linked to the storage contract * @param _identityRegistry The identity registry address to remove. */ function unbindIdentityRegistry(address _identityRegistry) external; /** * @dev Returns the identity registries linked to the storage contract */ function linkedIdentityRegistries() external view returns (address[] memory); /** * @dev Returns the onchainID of an investor. * @param _userAddress The wallet of the investor */ function storedIdentity(address _userAddress) external view returns (IIdentity); /** * @dev Returns the country code of an investor. * @param _userAddress The wallet of the investor */ function storedInvestorCountry(address _userAddress) external view returns (uint16); }
// SPDX-License-Identifier: GPL-3.0 pragma solidity 0.8.17; import "./IIdentity.sol"; interface IClaimIssuer is IIdentity { /** * @dev Emitted when a claim is revoked. * * Specification: MUST be triggered when revoking a claim. */ event ClaimRevoked(bytes indexed signature); /** * @dev Revoke a claim previously issued, the claim is no longer considered as valid after revocation. * @notice will fetch the claim from the identity contract (unsafe). * @param _claimId the id of the claim * @param _identity the address of the identity contract * @return isRevoked true when the claim is revoked */ function revokeClaim(bytes32 _claimId, address _identity) external returns(bool); /** * @dev Revoke a claim previously issued, the claim is no longer considered as valid after revocation. * @param signature the signature of the claim */ function revokeClaimBySignature(bytes calldata signature) external; /** * @dev Returns revocation status of a claim. * @param _sig the signature of the claim * @return isRevoked true if the claim is revoked and false otherwise */ function isClaimRevoked(bytes calldata _sig) external view returns (bool); /** * @dev Checks if a claim is valid. * @param _identity the identity contract related to the claim * @param claimTopic the claim topic of the claim * @param sig the signature of the claim * @param data the data field of the claim * @return claimValid true if the claim is valid, false otherwise */ function isClaimValid( IIdentity _identity, uint256 claimTopic, bytes calldata sig, bytes calldata data) external view returns (bool); /** * @dev returns the address that signed the given data * @param sig the signature of the data * @param dataHash the data that was signed * returns the address that signed dataHash and created the signature sig */ function getRecoveredAddress(bytes calldata sig, bytes32 dataHash) external pure returns (address); }
// SPDX-License-Identifier: GPL-3.0 pragma solidity 0.8.17; import "./IERC734.sol"; import "./IERC735.sol"; // solhint-disable-next-line no-empty-blocks interface IIdentity is IERC734, IERC735 {}
// SPDX-License-Identifier: GPL-3.0 pragma solidity 0.8.17; /** * @dev interface of the ERC734 (Key Holder) standard as defined in the EIP. */ interface IERC734 { /** * @dev Emitted when an execution request was approved. * * Specification: MUST be triggered when approve was successfully called. */ event Approved(uint256 indexed executionId, bool approved); /** * @dev Emitted when an execute operation was approved and successfully performed. * * Specification: MUST be triggered when approve was called and the execution was successfully approved. */ event Executed(uint256 indexed executionId, address indexed to, uint256 indexed value, bytes data); /** * @dev Emitted when an execution request was performed via `execute`. * * Specification: MUST be triggered when execute was successfully called. */ event ExecutionRequested(uint256 indexed executionId, address indexed to, uint256 indexed value, bytes data); /** * @dev Emitted when an execute operation was called and failed * * Specification: MUST be triggered when execute call failed */ event ExecutionFailed(uint256 indexed executionId, address indexed to, uint256 indexed value, bytes data); /** * @dev Emitted when a key was added to the Identity. * * Specification: MUST be triggered when addKey was successfully called. */ event KeyAdded(bytes32 indexed key, uint256 indexed purpose, uint256 indexed keyType); /** * @dev Emitted when a key was removed from the Identity. * * Specification: MUST be triggered when removeKey was successfully called. */ event KeyRemoved(bytes32 indexed key, uint256 indexed purpose, uint256 indexed keyType); /** * @dev Adds a _key to the identity. The _purpose specifies the purpose of the key. * * Triggers Event: `KeyAdded` * * Specification: MUST only be done by keys of purpose 1, or the identity * itself. If it's the identity itself, the approval process will determine its approval. */ function addKey(bytes32 _key, uint256 _purpose, uint256 _keyType) external returns (bool success); /** * @dev Approves an execution. * * Triggers Event: `Approved` * Triggers on execution successful Event: `Executed` * Triggers on execution failure Event: `ExecutionFailed` */ function approve(uint256 _id, bool _approve) external returns (bool success); /** * @dev Removes _purpose for _key from the identity. * * Triggers Event: `KeyRemoved` * * Specification: MUST only be done by keys of purpose 1, or the identity itself. * If it's the identity itself, the approval process will determine its approval. */ function removeKey(bytes32 _key, uint256 _purpose) external returns (bool success); /** * @dev Passes an execution instruction to an ERC734 identity. * How the execution is handled is up to the identity implementation: * An execution COULD be requested and require `approve` to be called with one or more keys of purpose 1 or 2 to * approve this execution. * Execute COULD be used as the only accessor for `addKey` and `removeKey`. * * Triggers Event: ExecutionRequested * Triggers on direct execution Event: Executed */ function execute(address _to, uint256 _value, bytes calldata _data) external payable returns (uint256 executionId); /** * @dev Returns the full key data, if present in the identity. */ function getKey(bytes32 _key) external view returns (uint256[] memory purposes, uint256 keyType, bytes32 key); /** * @dev Returns the list of purposes associated with a key. */ function getKeyPurposes(bytes32 _key) external view returns(uint256[] memory _purposes); /** * @dev Returns an array of public key bytes32 held by this identity. */ function getKeysByPurpose(uint256 _purpose) external view returns (bytes32[] memory keys); /** * @dev Returns TRUE if a key is present and has the given purpose. If the key is not present it returns FALSE. */ function keyHasPurpose(bytes32 _key, uint256 _purpose) external view returns (bool exists); }
// SPDX-License-Identifier: GPL-3.0 pragma solidity 0.8.17; /** * @dev interface of the ERC735 (Claim Holder) standard as defined in the EIP. */ interface IERC735 { /** * @dev Emitted when a claim was added. * * Specification: MUST be triggered when a claim was successfully added. */ event ClaimAdded( bytes32 indexed claimId, uint256 indexed topic, uint256 scheme, address indexed issuer, bytes signature, bytes data, string uri); /** * @dev Emitted when a claim was removed. * * Specification: MUST be triggered when removeClaim was successfully called. */ event ClaimRemoved( bytes32 indexed claimId, uint256 indexed topic, uint256 scheme, address indexed issuer, bytes signature, bytes data, string uri); /** * @dev Emitted when a claim was changed. * * Specification: MUST be triggered when addClaim was successfully called on an existing claimId. */ event ClaimChanged( bytes32 indexed claimId, uint256 indexed topic, uint256 scheme, address indexed issuer, bytes signature, bytes data, string uri); /** * @dev Add or update a claim. * * Triggers Event: `ClaimAdded`, `ClaimChanged` * * Specification: Add or update a claim from an issuer. * * _signature is a signed message of the following structure: * `keccak256(abi.encode(address identityHolder_address, uint256 topic, bytes data))`. * Claim IDs are generated using `keccak256(abi.encode(address issuer_address + uint256 topic))`. */ function addClaim( uint256 _topic, uint256 _scheme, address issuer, bytes calldata _signature, bytes calldata _data, string calldata _uri) external returns (bytes32 claimRequestId); /** * @dev Removes a claim. * * Triggers Event: `ClaimRemoved` * * Claim IDs are generated using `keccak256(abi.encode(address issuer_address, uint256 topic))`. */ function removeClaim(bytes32 _claimId) external returns (bool success); /** * @dev Get a claim by its ID. * * Claim IDs are generated using `keccak256(abi.encode(address issuer_address, uint256 topic))`. */ function getClaim(bytes32 _claimId) external view returns( uint256 topic, uint256 scheme, address issuer, bytes memory signature, bytes memory data, string memory uri); /** * @dev Returns an array of claim IDs by topic. */ function getClaimIdsByTopic(uint256 _topic) external view returns(bytes32[] memory claimIds); }
{ "remappings": [ "@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/", "@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/", "@solady/=lib/solady/src/", "@solidity-lib/=lib/solidity-lib/contracts/", "@forge-std/=lib/forge-std/src/", "@onchain-id/solidity/=lib/solidity/", "@ERC-3643/=lib/ERC-3643/contracts/", "@core/=contracts/core/", "@modules/=contracts/modules/", "@rules/=contracts/rules/", "@interface/=contracts/interface/", "@abstract/=contracts/abstract/", "@mock/=tests/mock/", "@chainlink/=node_modules/@chainlink/", "@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/", "@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/", "@onchain-id/solidity/=lib/solidity/", "@core/=contracts/core/", "@modules/=contracts/modules/", "@rules/=contracts/rules/", "@interface/=contracts/interface/", "@abstract/=contracts/abstract/", "@mock/=tests/mock/", "ERC-3643/=lib/ERC-3643/contracts/", "ds-test/=lib/forge-std/lib/ds-test/src/", "erc4626-tests/=lib/openzeppelin-contracts-upgradeable/lib/erc4626-tests/", "forge-std/=lib/forge-std/src/", "openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/", "openzeppelin-contracts/=lib/openzeppelin-contracts/", "openzeppelin/=lib/openzeppelin-contracts-upgradeable/contracts/", "solady/=lib/solady/src/", "solidity-lib/=lib/solidity-lib/contracts/", "solidity/=lib/solidity/contracts/", "solmate/=lib/solady/lib/solmate/src/" ], "optimizer": { "enabled": true, "runs": 1000 }, "metadata": { "useLiteralContent": false, "bytecodeHash": "ipfs" }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "evmVersion": "london", "viaIR": false, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"uint256","name":"feeInBps","type":"uint256"}],"name":"AbstractFeeModuleInvalidFee","type":"error"},{"inputs":[],"name":"AbstractFeeModuleInvalidFeeRecipient","type":"error"},{"inputs":[{"internalType":"address","name":"newFeeRecipient","type":"address"}],"name":"FrictionlessFXSwapInvalidFeeRecipientAddr","type":"error"},{"inputs":[{"internalType":"address","name":"token0","type":"address"},{"internalType":"address","name":"token1","type":"address"}],"name":"FrictionlessFXSwapInvalidTokenAddresses","type":"error"},{"inputs":[],"name":"FrictionlessFXSwapNotEnoughPermissions","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"previousAdmin","type":"address"},{"indexed":false,"internalType":"address","name":"newAdmin","type":"address"}],"name":"AdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"beacon","type":"address"}],"name":"BeaconUpgraded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"sellingTokenAddr","type":"address"},{"indexed":false,"internalType":"address","name":"buyingTokenAddr","type":"address"},{"indexed":false,"internalType":"address","name":"tokenSender","type":"address"},{"indexed":false,"internalType":"address","name":"tokenRecipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"sellingTokensAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"buyingTokensAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"buyingTokenExchangeRate","type":"uint256"}],"name":"FrictionlessFXTokensSwapped","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"feeKey","type":"bytes32"},{"components":[{"internalType":"uint256","name":"feeInBps","type":"uint256"},{"internalType":"address","name":"feeRecipientAddr","type":"address"}],"indexed":false,"internalType":"struct IAbstractFeeModule.FeeInfo","name":"feeInfo","type":"tuple"}],"name":"FrictionlessFeeSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"implementation","type":"address"}],"name":"Upgraded","type":"event"},{"inputs":[],"name":"EXCHANGE_RATE_PRECISION","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_FEES_IN_BPS","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ZERO_FEES_IN_BPS","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokensAmount_","type":"uint256"},{"internalType":"uint256","name":"feeInBps_","type":"uint256"}],"name":"calculateFeeAmount","outputs":[{"internalType":"uint256","name":"feeAmount_","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"fxDeskFeeAddr","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"tokenFeeKey_","type":"bytes32"}],"name":"getFeeInBps","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"tokenFeeKey_","type":"bytes32"}],"name":"getFeeInfo","outputs":[{"components":[{"internalType":"uint256","name":"feeInBps","type":"uint256"},{"internalType":"address","name":"feeRecipientAddr","type":"address"}],"internalType":"struct IAbstractFeeModule.FeeInfo","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"tokenFeeKey_","type":"bytes32"}],"name":"getFeeRecipient","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"buyingTokensAmount_","type":"uint256"},{"internalType":"uint256","name":"buyingTokenExchangeRate_","type":"uint256"}],"name":"getSellingTokensAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"token0_","type":"address"},{"internalType":"address","name":"token1_","type":"address"}],"name":"getSwapFeeKeys","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"},{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"token0_","type":"address"},{"internalType":"address","name":"token1_","type":"address"}],"name":"getSwapFeesInfo","outputs":[{"components":[{"internalType":"uint256","name":"feeInBps","type":"uint256"},{"internalType":"address","name":"feeRecipientAddr","type":"address"}],"internalType":"struct IAbstractFeeModule.FeeInfo","name":"","type":"tuple"},{"components":[{"internalType":"uint256","name":"feeInBps","type":"uint256"},{"internalType":"address","name":"feeRecipientAddr","type":"address"}],"internalType":"struct IAbstractFeeModule.FeeInfo","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token0_","type":"address"},{"internalType":"address","name":"token1_","type":"address"}],"name":"getTokenFeeKey","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"treasuryManager_","type":"address"},{"internalType":"address","name":"permissionManager_","type":"address"},{"internalType":"address","name":"fxDeskFeeAddr_","type":"address"}],"name":"init","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"permissionManager","outputs":[{"internalType":"contract IFrictionlessPermissionsManager","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"proxiableUUID","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newFXDeskFeeAddr_","type":"address"}],"name":"setFXDeskFeeAddr","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"tokenAddr","type":"address"},{"internalType":"uint256","name":"feeAbsoluteLimit","type":"uint256"},{"components":[{"internalType":"uint256","name":"feeInBps","type":"uint256"},{"internalType":"address","name":"feeRecipientAddr","type":"address"}],"internalType":"struct IAbstractFeeModule.FeeInfo","name":"feeInfo","type":"tuple"}],"internalType":"struct IFrictionlessFXSwap.FrictionlessTokenFXFeeInfo","name":"token0FeeInfo_","type":"tuple"},{"components":[{"internalType":"address","name":"tokenAddr","type":"address"},{"internalType":"uint256","name":"feeAbsoluteLimit","type":"uint256"},{"components":[{"internalType":"uint256","name":"feeInBps","type":"uint256"},{"internalType":"address","name":"feeRecipientAddr","type":"address"}],"internalType":"struct IAbstractFeeModule.FeeInfo","name":"feeInfo","type":"tuple"}],"internalType":"struct IFrictionlessFXSwap.FrictionlessTokenFXFeeInfo","name":"token1FeeInfo_","type":"tuple"}],"name":"setSwapFees","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"tokenFeeKey_","type":"bytes32"},{"components":[{"internalType":"address","name":"tokenAddr","type":"address"},{"internalType":"uint256","name":"feeAbsoluteLimit","type":"uint256"},{"components":[{"internalType":"uint256","name":"feeInBps","type":"uint256"},{"internalType":"address","name":"feeRecipientAddr","type":"address"}],"internalType":"struct IAbstractFeeModule.FeeInfo","name":"feeInfo","type":"tuple"}],"internalType":"struct IFrictionlessFXSwap.FrictionlessTokenFXFeeInfo","name":"tokenFeeInfo_","type":"tuple"}],"name":"setTokenFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sellingTokenAddr_","type":"address"},{"internalType":"address","name":"buyingTokenAddr_","type":"address"},{"internalType":"address","name":"tokenSender_","type":"address"},{"internalType":"address","name":"tokenRecipient_","type":"address"},{"internalType":"uint256","name":"buyingTokensAmount_","type":"uint256"},{"internalType":"uint256","name":"buyingTokenExchangeRate_","type":"uint256"}],"name":"swapTokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"treasuryManager","outputs":[{"internalType":"contract IFrictionlessTreasuryManager","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"}],"name":"upgradeTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"upgradeToAndCall","outputs":[],"stateMutability":"payable","type":"function"}]
Deployed Bytecode
0x6080604052600436106101965760003560e01c806376e246e3116100e1578063ce3dac1b1161008a578063df56f9ee11610064578063df56f9ee146104c2578063e69d606a146104e2578063f2fde38b14610551578063f44fe2321461057157600080fd5b8063ce3dac1b14610432578063cee42d441461045f578063d36586171461048d57600080fd5b8063965a7afe116100bb578063965a7afe14610398578063c84d874a146103fd578063cc7a20491461041257600080fd5b806376e246e3146103215780638da5cb5b1461035a5780638e47e47e1461037857600080fd5b80633a01b9641161014357806352d1902d1161011d57806352d1902d146102d75780636f1352af146102ec578063715018a61461030c57600080fd5b80633a01b964146102705780633cea70d91461028c5780634f1ef286146102c457600080fd5b8063184b955911610174578063184b9559146102105780632b542c5e146102305780633659cfe61461025057600080fd5b80630826c2491461019b5780630d068ec1146101ce5780630e547c50146101ee575b600080fd5b3480156101a757600080fd5b506101bb6101b636600461197d565b610587565b6040519081526020015b60405180910390f35b3480156101da57600080fd5b506101bb6101e936600461197d565b6105bd565b3480156101fa57600080fd5b5061020e6102093660046119b7565b6105e3565b005b34801561021c57600080fd5b5061020e61022b366004611a00565b610624565b34801561023c57600080fd5b5061020e61024b366004611a43565b610789565b34801561025c57600080fd5b5061020e61026b366004611aa9565b610abf565b34801561027c57600080fd5b506101bb670de0b6b3a764000081565b34801561029857600080fd5b506067546102ac906001600160a01b031681565b6040516001600160a01b0390911681526020016101c5565b61020e6102d2366004611b0b565b610c3a565b3480156102e357600080fd5b506101bb610da2565b3480156102f857600080fd5b506066546102ac906001600160a01b031681565b34801561031857600080fd5b5061020e610e67565b34801561032d57600080fd5b506102ac61033c366004611bb1565b6000908152606560205260409020600101546001600160a01b031690565b34801561036657600080fd5b506033546001600160a01b03166102ac565b34801561038457600080fd5b5061020e610393366004611bca565b610e7b565b3480156103a457600080fd5b506101bb6103b3366004611bf7565b6040516bffffffffffffffffffffffff19606084811b8216602084015283901b16603482015260009060480160405160208183030381529060405280519060200120905092915050565b34801561040957600080fd5b506101bb600081565b34801561041e57600080fd5b506068546102ac906001600160a01b031681565b34801561043e57600080fd5b506101bb61044d366004611bb1565b60009081526065602052604090205490565b34801561046b57600080fd5b5061047f61047a366004611bf7565b610f5f565b6040516101c5929190611c21565b34801561049957600080fd5b506104ad6104a8366004611bf7565b611020565b604080519283526020830191909152016101c5565b3480156104ce57600080fd5b5061020e6104dd366004611aa9565b6110c1565b3480156104ee57600080fd5b506105446104fd366004611bb1565b604080518082019091526000808252602082015250600090815260656020908152604091829020825180840190935280548352600101546001600160a01b03169082015290565b6040516101c59190611c5b565b34801561055d57600080fd5b5061020e61056c366004611aa9565b6110eb565b34801561057d57600080fd5b506101bb61271081565b600081156105a95761271061059c8385611c91565b6105a69190611ca8565b90505b6127108211156105b7575060005b92915050565b6000670de0b6b3a76400006105d28385611c91565b6105dc9190611ca8565b9392505050565b6105eb611178565b60008281526069602090815260409182902090830135905561062090839061061b90368590038501908501611cca565b6111d2565b5050565b600054610100900460ff16158080156106445750600054600160ff909116105b8061065e5750303b15801561065e575060005460ff166001145b6106d55760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a656400000000000000000000000000000000000060648201526084015b60405180910390fd5b6000805460ff1916600117905580156106f8576000805461ff0019166101001790555b6107006111e5565b606780546001600160a01b038087166001600160a01b0319928316179092556068805486841690831617905560668054928516929091169190911790558015610783576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50505050565b610791611258565b600061079d83836105bd565b905060006107f088886040516bffffffffffffffffffffffff19606084811b8216602084015283901b16603482015260009060480160405160208183030381529060405280519060200120905092915050565b6040805180820182526000808252602091820181905283815260658252828120835180850190945280548452600101546001600160a01b03169183019190915291925090506000610845848360000151610587565b600084815260696020526040902054909150801561086a57610867828261131b565b91505b811561090d5761087983611331565b60675460208401516040517f2c54de4f0000000000000000000000000000000000000000000000000000000081526001600160a01b038e811660048301528c81166024830152918216604482015260648101859052911690632c54de4f90608401600060405180830381600087803b1580156108f457600080fd5b505af1158015610908573d6000803e3d6000fd5b505050505b6067546001600160a01b0316633416794d8c8b61092a868a611d1e565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e086901b1681526001600160a01b0393841660048201529290911660248301526044820152606401600060405180830381600087803b15801561099157600080fd5b505af11580156109a5573d6000803e3d6000fd5b50506067546040517fd7db6cba0000000000000000000000000000000000000000000000000000000081526001600160a01b038e811660048301528c81166024830152604482018c9052909116925063d7db6cba9150606401600060405180830381600087803b158015610a1857600080fd5b505af1158015610a2c573d6000803e3d6000fd5b505050507fb2f6af2e1af7bbf9bb4457869799c6b961116e8cf69a0215cfc3ec52dc294dc48b8b8b8b898c8c604051610aaa97969594939291906001600160a01b03978816815295871660208701529386166040860152919094166060840152608083019390935260a082019290925260c081019190915260e00190565b60405180910390a15050505050505050505050565b6001600160a01b037f00000000000000000000000032b78b918f9397914ba72f4e0a5410567a949dfe163003610b4c5760405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201526b19195b1959d85d1958d85b1b60a21b60648201526084016106cc565b7f00000000000000000000000032b78b918f9397914ba72f4e0a5410567a949dfe6001600160a01b0316610ba77f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b6001600160a01b031614610c125760405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201526b6163746976652070726f787960a01b60648201526084016106cc565b610c1b8161138e565b60408051600080825260208201909252610c3791839190611396565b50565b6001600160a01b037f00000000000000000000000032b78b918f9397914ba72f4e0a5410567a949dfe163003610cc75760405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201526b19195b1959d85d1958d85b1b60a21b60648201526084016106cc565b7f00000000000000000000000032b78b918f9397914ba72f4e0a5410567a949dfe6001600160a01b0316610d227f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b6001600160a01b031614610d8d5760405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201526b6163746976652070726f787960a01b60648201526084016106cc565b610d968261138e565b61062082826001611396565b6000306001600160a01b037f00000000000000000000000032b78b918f9397914ba72f4e0a5410567a949dfe1614610e425760405162461bcd60e51b815260206004820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c60448201527f6c6564207468726f7567682064656c656761746563616c6c000000000000000060648201526084016106cc565b507f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc90565b610e6f611178565b610e79600061153b565b565b610e83611178565b600080610ea3610e966020860186611aa9565b6104a86020860186611aa9565b91509150808203610f0d57610ebb6020850185611aa9565b610ec86020850185611aa9565b6040517fdd9ba0310000000000000000000000000000000000000000000000000000000081526001600160a01b039283166004820152911660248201526044016106cc565b600082815260696020908152604080832082880135905583835291829020908501359055610f4990839061061b90368890038801908801611cca565b6107838161061b36869003860160408701611cca565b60408051808201909152600080825260208201526040805180820190915260008082526020820152600080610f948686611020565b6040805180820182526000808252602091820181905284815260658252829020825180840190935280548352600101546001600160a01b03169082015291935091506040805180820182526000808252602091820181905284815260658252829020825180840190935280548352600101546001600160a01b0316908201529350935050509250929050565b60008061107284846040516bffffffffffffffffffffffff19606084811b8216602084015283901b16603482015260009060480160405160208183030381529060405280519060200120905092915050565b60408051606086811b6bffffffffffffffffffffffff199081166020808501919091529189901b1660348301528251602881840301815260489092019092528051910120915091509250929050565b6110c9611178565b606680546001600160a01b0319166001600160a01b0392909216919091179055565b6110f3611178565b6001600160a01b03811661116f5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016106cc565b610c378161153b565b6033546001600160a01b03163314610e795760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016106cc565b6111db81611331565b610620828261158d565b600054610100900460ff166112505760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b60648201526084016106cc565b610e7961160e565b6068546040517f93c81dd60000000000000000000000000000000000000000000000000000000081526001600160a01b03909116906393c81dd6906112a4903390600090600401611d31565b602060405180830381865afa1580156112c1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112e59190611d6c565b610e79576040517f415bd53400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600081831061132a57816105dc565b5090919050565b60665460208201516001600160a01b03908116911614610c375760208101516040517f725a19f00000000000000000000000000000000000000000000000000000000081526001600160a01b0390911660048201526024016106cc565b610c37611178565b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff16156113ce576113c983611682565b505050565b826001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa925050508015611428575060408051601f3d908101601f1916820190925261142591810190611d8e565b60015b61149a5760405162461bcd60e51b815260206004820152602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201527f6f6e206973206e6f74205555505300000000000000000000000000000000000060648201526084016106cc565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc811461152f5760405162461bcd60e51b815260206004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f7860448201527f6961626c6555554944000000000000000000000000000000000000000000000060648201526084016106cc565b506113c9838383611740565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b61159681611765565b6000828152606560209081526040918290208351815590830151600190910180546001600160a01b0319166001600160a01b039092169190911790555182907f8d727ef8529439b0ecd416610591044d3c65936c504fca35b423154d64e6395590611602908490611c5b565b60405180910390a25050565b600054610100900460ff166116795760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b60648201526084016106cc565b610e793361153b565b6001600160a01b0381163b6116ff5760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e74726163740000000000000000000000000000000000000060648201526084016106cc565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80546001600160a01b0319166001600160a01b0392909216919091179055565b611749836117fa565b6000825111806117565750805b156113c957610783838361183a565b805115801590611780575060208101516001600160a01b0316155b156117b7576040517f028e581900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80516127101015610c375780516040517f3d60ffb500000000000000000000000000000000000000000000000000000000815260048101919091526024016106cc565b61180381611682565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606105dc8383604051806060016040528060278152602001611e1b602791396060600080856001600160a01b0316856040516118779190611dcb565b600060405180830381855af49150503d80600081146118b2576040519150601f19603f3d011682016040523d82523d6000602084013e6118b7565b606091505b50915091506118c8868383876118d2565b9695505050505050565b6060831561194157825160000361193a576001600160a01b0385163b61193a5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016106cc565b508161194b565b61194b8383611953565b949350505050565b8151156119635781518083602001fd5b8060405162461bcd60e51b81526004016106cc9190611de7565b6000806040838503121561199057600080fd5b50508035926020909101359150565b6000608082840312156119b157600080fd5b50919050565b60008060a083850312156119ca57600080fd5b823591506119db846020850161199f565b90509250929050565b80356001600160a01b03811681146119fb57600080fd5b919050565b600080600060608486031215611a1557600080fd5b611a1e846119e4565b9250611a2c602085016119e4565b9150611a3a604085016119e4565b90509250925092565b60008060008060008060c08789031215611a5c57600080fd5b611a65876119e4565b9550611a73602088016119e4565b9450611a81604088016119e4565b9350611a8f606088016119e4565b92506080870135915060a087013590509295509295509295565b600060208284031215611abb57600080fd5b6105dc826119e4565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff81118282101715611b0357611b03611ac4565b604052919050565b60008060408385031215611b1e57600080fd5b611b27836119e4565b915060208084013567ffffffffffffffff80821115611b4557600080fd5b818601915086601f830112611b5957600080fd5b813581811115611b6b57611b6b611ac4565b611b7d601f8201601f19168501611ada565b91508082528784828501011115611b9357600080fd5b80848401858401376000848284010152508093505050509250929050565b600060208284031215611bc357600080fd5b5035919050565b6000806101008385031215611bde57600080fd5b611be8848461199f565b91506119db846080850161199f565b60008060408385031215611c0a57600080fd5b611c13836119e4565b91506119db602084016119e4565b825181526020808401516001600160a01b031690820152608081018251604083015260208301516001600160a01b031660608301526105dc565b815181526020808301516001600160a01b031690820152604081016105b7565b634e487b7160e01b600052601160045260246000fd5b80820281158282048414176105b7576105b7611c7b565b600082611cc557634e487b7160e01b600052601260045260246000fd5b500490565b600060408284031215611cdc57600080fd5b6040516040810181811067ffffffffffffffff82111715611cff57611cff611ac4565b60405282358152611d12602084016119e4565b60208201529392505050565b818103818111156105b7576105b7611c7b565b6001600160a01b03831681526040810160078310611d5f57634e487b7160e01b600052602160045260246000fd5b8260208301529392505050565b600060208284031215611d7e57600080fd5b815180151581146105dc57600080fd5b600060208284031215611da057600080fd5b5051919050565b60005b83811015611dc2578181015183820152602001611daa565b50506000910152565b60008251611ddd818460208701611da7565b9190910192915050565b6020815260008251806020840152611e06816040850160208701611da7565b601f01601f1916919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212208900247695f0826679441cb36cb0d4d63a76c02cc9d83b7b00345b18ea7a005164736f6c63430008110033
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 31 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
Loading...
Loading
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.