Transaction Hash:
Block:
21505131 at Dec-29-2024 02:26:23 AM +UTC
Transaction Fee:
0.000220828727146649 ETH
$0.55
Gas Used:
66,749 Gas / 3.308345101 Gwei
Emitted Events:
638 |
SKRBridged.Transfer( _from=[Sender] 0xb1a3fe6b1e07c33b7c06724a245a031d23dc4df8, _to=0xFd0D8b38dff4dD5aBf656b752FbE996E360CDc1E, _value=17229740000000000000000 )
|
Account State Difference:
Address | Before | After | State Difference | ||
---|---|---|---|---|---|
0x4838B106...B0BAD5f97
Miner
| (Titan Builder) | 8.983643929735212399 Eth | 8.983691728894359399 Eth | 0.000047799159147 | |
0xb1A3fe6B...D23DC4DF8 |
0.014886914140389943 Eth
Nonce: 237
|
0.014666085413243294 Eth
Nonce: 238
| 0.000220828727146649 | ||
0xe2dCA969...337ba130a |
Execution Trace
SKRBridged.transfer( recipient=0xFd0D8b38dff4dD5aBf656b752FbE996E360CDc1E, amount=17229740000000000000000 ) => ( True )

TransparentUpgradeableProxy.1ffb811f( )
-
LosslessControllerV3.beforeTransfer( _sender=0xb1A3fe6B1e07C33B7C06724a245a031D23DC4DF8, _recipient=0xFd0D8b38dff4dD5aBf656b752FbE996E360CDc1E, _amount=17229740000000000000000 )
-
transfer[LERC20 (ln:1091)]
_transfer[LERC20 (ln:1092)]
Transfer[LERC20 (ln:1127)]
_msgSender[LERC20 (ln:1092)]
File 1 of 3: SKRBridged
File 2 of 3: TransparentUpgradeableProxy
File 3 of 3: LosslessControllerV3
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (access/AccessControl.sol) pragma solidity ^0.8.0; import "./IAccessControl.sol"; import "../utils/Context.sol"; import "../utils/Strings.sol"; import "../utils/introspection/ERC165.sol"; /** * @dev Contract module that allows children to implement role-based access * control mechanisms. This is a lightweight version that doesn't allow enumerating role * members except through off-chain means by accessing the contract event logs. Some * applications may benefit from on-chain enumerability, for those cases see * {AccessControlEnumerable}. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ```solidity * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ```solidity * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules} * to enforce additional security measures for this role. */ abstract contract AccessControl is Context, IAccessControl, ERC165 { struct RoleData { mapping(address => bool) members; bytes32 adminRole; } mapping(bytes32 => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Modifier that checks that an account has a specific role. Reverts * with a standardized message including the required role. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ * * _Available since v4.1._ */ modifier onlyRole(bytes32 role) { _checkRole(role); _; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view virtual override returns (bool) { return _roles[role].members[account]; } /** * @dev Revert with a standard message if `_msgSender()` is missing `role`. * Overriding this function changes the behavior of the {onlyRole} modifier. * * Format of the revert message is described in {_checkRole}. * * _Available since v4.6._ */ function _checkRole(bytes32 role) internal view virtual { _checkRole(role, _msgSender()); } /** * @dev Revert with a standard message if `account` is missing `role`. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ */ function _checkRole(bytes32 role, address account) internal view virtual { if (!hasRole(role, account)) { revert( string( abi.encodePacked( "AccessControl: account ", Strings.toHexString(account), " is missing role ", Strings.toHexString(uint256(role), 32) ) ) ); } } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) { return _roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. * * May emit a {RoleGranted} event. */ function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. * * May emit a {RoleRevoked} event. */ function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been revoked `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. * * May emit a {RoleRevoked} event. */ function renounceRole(bytes32 role, address account) public virtual override { require(account == _msgSender(), "AccessControl: can only renounce roles for self"); _revokeRole(role, account); } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. Note that unlike {grantRole}, this function doesn't perform any * checks on the calling account. * * May emit a {RoleGranted} event. * * [WARNING] * ==== * This function should only be called from the constructor when setting * up the initial roles for the system. * * Using this function in any other way is effectively circumventing the admin * system imposed by {AccessControl}. * ==== * * NOTE: This function is deprecated in favor of {_grantRole}. */ function _setupRole(bytes32 role, address account) internal virtual { _grantRole(role, account); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { bytes32 previousAdminRole = getRoleAdmin(role); _roles[role].adminRole = adminRole; emit RoleAdminChanged(role, previousAdminRole, adminRole); } /** * @dev Grants `role` to `account`. * * Internal function without access restriction. * * May emit a {RoleGranted} event. */ function _grantRole(bytes32 role, address account) internal virtual { if (!hasRole(role, account)) { _roles[role].members[account] = true; emit RoleGranted(role, account, _msgSender()); } } /** * @dev Revokes `role` from `account`. * * Internal function without access restriction. * * May emit a {RoleRevoked} event. */ function _revokeRole(bytes32 role, address account) internal virtual { if (hasRole(role, account)) { _roles[role].members[account] = false; emit RoleRevoked(role, account, _msgSender()); } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol) pragma solidity ^0.8.0; /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControl { /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {AccessControl-_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) external view returns (bool); /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {AccessControl-_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) external view returns (bytes32); /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) external; /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) external; /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) external; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/Context.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 Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _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); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.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.9.4) (utils/Context.sol) pragma solidity ^0.8.0; /** * @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 Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } function _contextSuffixLength() internal view virtual returns (uint256) { return 0; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.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) { // Solidity will revert if denominator == 0, unlike the div opcode on its own. // The surrounding unchecked block does not change this fact. // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic. return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. require(denominator > prod1, "Math: mulDiv overflow"); /////////////////////////////////////////////// // 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 256, 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 << 3) < value ? 1 : 0); } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol) pragma solidity ^0.8.0; /** * @dev Standard signed math utilities missing in the Solidity language. */ library SignedMath { /** * @dev Returns the largest of two signed numbers. */ function max(int256 a, int256 b) internal pure returns (int256) { return a > b ? a : b; } /** * @dev Returns the smallest of two signed numbers. */ function min(int256 a, int256 b) internal pure returns (int256) { return a < b ? a : b; } /** * @dev Returns the average of two signed numbers without overflow. * The result is rounded towards zero. */ function average(int256 a, int256 b) internal pure returns (int256) { // Formula from the book "Hacker's Delight" int256 x = (a & b) + ((a ^ b) >> 1); return x + (int256(uint256(x) >> 255) & (a ^ b)); } /** * @dev Returns the absolute unsigned value of a signed value. */ function abs(int256 n) internal pure returns (uint256) { unchecked { // must be unchecked in order to support `n = type(int256).min` return uint256(n >= 0 ? n : -n); } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol) pragma solidity ^0.8.0; import "./math/Math.sol"; import "./math/SignedMath.sol"; /** * @dev String operations. */ library Strings { bytes16 private constant _SYMBOLS = "0123456789abcdef"; uint8 private constant _ADDRESS_LENGTH = 20; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { unchecked { uint256 length = Math.log10(value) + 1; string memory buffer = new string(length); uint256 ptr; /// @solidity memory-safe-assembly assembly { ptr := add(buffer, add(32, length)) } while (true) { ptr--; /// @solidity memory-safe-assembly assembly { mstore8(ptr, byte(mod(value, 10), _SYMBOLS)) } value /= 10; if (value == 0) break; } return buffer; } } /** * @dev Converts a `int256` to its ASCII `string` decimal representation. */ function toString(int256 value) internal pure returns (string memory) { return string(abi.encodePacked(value < 0 ? "-" : "", toString(SignedMath.abs(value)))); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { unchecked { return toHexString(value, Math.log256(value) + 1); } } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } /** * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation. */ function toHexString(address addr) internal pure returns (string memory) { return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH); } /** * @dev Returns true if the two strings are equal. */ function equal(string memory a, string memory b) internal pure returns (bool) { return keccak256(bytes(a)) == keccak256(bytes(b)); } } //SPDX-License-Identifier: Unlicense pragma solidity ^0.8.0; import "@openzeppelin/contracts/utils/Context.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "../interfaces/ILosslessERC20.sol"; import "../interfaces/ILosslessController.sol"; contract LERC20 is Context, ILERC20 { mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; address public recoveryAdmin; address private recoveryAdminCandidate; bytes32 private recoveryAdminKeyHash; address override public admin; uint256 public timelockPeriod; uint256 public losslessTurnOffTimestamp; bool public isLosslessOn = true; ILssController public lossless; constructor(string memory name_, string memory symbol_, address admin_, address recoveryAdmin_, uint256 timelockPeriod_, address lossless_) { require(recoveryAdmin_ != address(0), "LERC20: Recovery admin cannot be zero address"); require(admin_ != address(0), "LERC20: Recovery admin cannot be zero address"); _name = name_; _symbol = symbol_; admin = admin_; recoveryAdmin = recoveryAdmin_; recoveryAdminCandidate = address(0); recoveryAdminKeyHash = ""; require(timelockPeriod_ > 2 hours, "LERC20: Timelock period must be greater than 0"); require(timelockPeriod_ < 2 days, "LERC20: Timelock period must be less than 2 days"); // Note: should not be changed after deployment, due to potential security risk in case of loss of owner private key timelockPeriod = timelockPeriod_; losslessTurnOffTimestamp = 0; require(lossless_ != address(0), "LERC20: Lossless cannot be zero address"); lossless = ILssController(lossless_); } // --- LOSSLESS modifiers --- modifier lssAprove(address spender, uint256 amount) { if (isLosslessOn) { lossless.beforeApprove(_msgSender(), spender, amount); } _; } modifier lssTransfer(address recipient, uint256 amount) { if (isLosslessOn) { lossless.beforeTransfer(_msgSender(), recipient, amount); } _; } modifier lssTransferFrom(address sender, address recipient, uint256 amount) { if (isLosslessOn) { lossless.beforeTransferFrom(_msgSender(),sender, recipient, amount); } _; } modifier lssIncreaseAllowance(address spender, uint256 addedValue) { if (isLosslessOn) { lossless.beforeIncreaseAllowance(_msgSender(), spender, addedValue); } _; } modifier lssDecreaseAllowance(address spender, uint256 subtractedValue) { if (isLosslessOn) { lossless.beforeDecreaseAllowance(_msgSender(), spender, subtractedValue); } _; } modifier onlyRecoveryAdmin() { require(_msgSender() == recoveryAdmin, "LERC20: Must be recovery admin"); _; } // --- LOSSLESS management --- function transferOutBlacklistedFunds(address[] calldata from) override external { require(_msgSender() == address(lossless), "LERC20: Only lossless contract"); require(isLosslessOn, "LERC20: Lossless is off"); uint256 fromLength = from.length; uint256 totalAmount = 0; for (uint256 i = 0; i < fromLength; i++) { address fromAddress = from[i]; uint256 fromBalance = _balances[fromAddress]; _balances[fromAddress] = 0; totalAmount += fromBalance; emit Transfer(fromAddress, address(lossless), fromBalance); } _balances[address(lossless)] += totalAmount; } function setLosslessAdmin(address newAdmin) override external onlyRecoveryAdmin { require(newAdmin != admin, "LERC20: Cannot set same address"); emit NewAdmin(newAdmin); admin = newAdmin; } function transferRecoveryAdminOwnership(address candidate, bytes32 keyHash) override external onlyRecoveryAdmin { require(candidate != address(0), "LERC20: Candidate cannot be zero address"); recoveryAdminCandidate = candidate; recoveryAdminKeyHash = keyHash; emit NewRecoveryAdminProposal(candidate); } function acceptRecoveryAdminOwnership(bytes memory key) override external { require(_msgSender() == recoveryAdminCandidate, "LERC20: Must be canditate"); require(keccak256(key) == recoveryAdminKeyHash, "LERC20: Invalid key"); emit NewRecoveryAdmin(recoveryAdminCandidate); require(recoveryAdminCandidate != address(0), "LERC20: Candidate cannot be zero address"); recoveryAdmin = recoveryAdminCandidate; recoveryAdminCandidate = address(0); recoveryAdminKeyHash = ""; } function proposeLosslessTurnOff() override external onlyRecoveryAdmin { require(losslessTurnOffTimestamp == 0, "LERC20: TurnOff already proposed"); require(isLosslessOn, "LERC20: Lossless already off"); losslessTurnOffTimestamp = block.timestamp + timelockPeriod; emit LosslessTurnOffProposal(losslessTurnOffTimestamp); } function executeLosslessTurnOff() override external onlyRecoveryAdmin { require(losslessTurnOffTimestamp != 0, "ERC20: TurnOff not proposed"); require(losslessTurnOffTimestamp <= block.timestamp, "ERC20: Time lock in progress"); isLosslessOn = false; losslessTurnOffTimestamp = 0; emit LosslessOff(); } function executeLosslessTurnOn() override external onlyRecoveryAdmin { require(!isLosslessOn, "LERC20: Lossless already on"); losslessTurnOffTimestamp = 0; isLosslessOn = true; emit LosslessOn(); } function getAdmin() override public view virtual returns (address) { return admin; } // --- ERC20 methods --- function name() override public view virtual returns (string memory) { return _name; } function symbol() override public view virtual returns (string memory) { return _symbol; } function decimals() override public view virtual returns (uint8) { return 18; } function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } function transfer(address recipient, uint256 amount) public virtual override lssTransfer(recipient, amount) returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public virtual override lssAprove(spender, amount) returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public virtual override lssTransferFrom(sender, recipient, amount) returns (bool) { uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); _transfer(sender, recipient, amount); _approve(sender, _msgSender(), currentAllowance - amount); return true; } function increaseAllowance(address spender, uint256 addedValue) override public virtual lssIncreaseAllowance(spender, addedValue) returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) override public virtual lssDecreaseAllowance(spender, subtractedValue) returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); _approve(_msgSender(), spender, currentAllowance - subtractedValue); return true; } function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); _balances[sender] = senderBalance - amount; _balances[recipient] += amount; emit Transfer(sender, recipient, amount); } function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply += amount; // Cannot overflow because the sum of all user // balances can't exceed the max uint256 value. unchecked { _balances[account] += amount; } emit Transfer(address(0), account, amount); } function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); unchecked { _balances[account] = accountBalance - amount; } _totalSupply -= amount; emit Transfer(account, address(0), amount); } function _approve(address owner, address spender, uint256 amount) internal virtual { _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) { return interfaceId == type(IERC20).interfaceId || interfaceId == type(ILERC20).interfaceId; } }// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./ILosslessERC20.sol"; import "./ILosslessGovernance.sol"; import "./ILosslessStaking.sol"; import "./ILosslessReporting.sol"; import "./IProtectionStrategy.sol"; interface ILssController { // function getLockedAmount(ILERC20 _token, address _account) returns (uint256); // function getAvailableAmount(ILERC20 _token, address _account) external view returns (uint256 amount); function retrieveBlacklistedFunds(address[] calldata _addresses, ILERC20 _token, uint256 _reportId) external returns(uint256); function whitelist(address _adr) external view returns (bool); function dexList(address _dexAddress) external returns (bool); function blacklist(address _adr) external view returns (bool); function admin() external view returns (address); function pauseAdmin() external view returns (address); function recoveryAdmin() external view returns (address); function guardian() external view returns (address); function losslessStaking() external view returns (ILssStaking); function losslessReporting() external view returns (ILssReporting); function losslessGovernance() external view returns (ILssGovernance); function dexTranferThreshold() external view returns (uint256); function settlementTimeLock() external view returns (uint256); function extraordinaryRetrievalProposalPeriod() external view returns (uint256); function pause() external; function unpause() external; function setAdmin(address _newAdmin) external; function setRecoveryAdmin(address _newRecoveryAdmin) external; function setPauseAdmin(address _newPauseAdmin) external; function setSettlementTimeLock(uint256 _newTimelock) external; function setDexTransferThreshold(uint256 _newThreshold) external; function setDexList(address[] calldata _dexList, bool _value) external; function setWhitelist(address[] calldata _addrList, bool _value) external; function addToBlacklist(address _adr) external; function resolvedNegatively(address _adr) external; function setStakingContractAddress(ILssStaking _adr) external; function setReportingContractAddress(ILssReporting _adr) external; function setGovernanceContractAddress(ILssGovernance _adr) external; function setTokenMintLimit(ILERC20 _token, uint256 limit) external; function setTokenMintPeriod(ILERC20 _token, uint256 _period) external; function setTokenBurnLimit(ILERC20 _token, uint256 _limit) external; function setTokenBurnPeriod(ILERC20 _token, uint256 _period) external; function proposeNewSettlementPeriod(ILERC20 _token, uint256 _seconds) external; function executeNewSettlementPeriod(ILERC20 _token) external; function activateEmergency(ILERC20 _token) external; function deactivateEmergency(ILERC20 _token) external; function setGuardian(address _newGuardian) external; function removeProtectedAddress(ILERC20 _token, address _protectedAddresss) external; function beforeTransfer(address _sender, address _recipient, uint256 _amount) external; function beforeTransferFrom(address _msgSender, address _sender, address _recipient, uint256 _amount) external; function beforeApprove(address _sender, address _spender, uint256 _amount) external; function beforeIncreaseAllowance(address _msgSender, address _spender, uint256 _addedValue) external; function beforeDecreaseAllowance(address _msgSender, address _spender, uint256 _subtractedValue) external; function beforeMint(address _to, uint256 _amount) external; function beforeBurn(address _account, uint256 _amount) external; function afterTransfer(address _sender, address _recipient, uint256 _amount) external; function setProtectedAddress(ILERC20 _token, address _protectedAddress, ProtectionStrategy _strategy) external; function setExtraordinaryRetrievalPeriod(uint256 _newPEriod) external; function extraordinaryRetrieval(ILERC20 _token, address[] calldata addresses, uint256 fundsToRetrieve) external; event AdminChange(address indexed _newAdmin); event RecoveryAdminChange(address indexed _newAdmin); event PauseAdminChange(address indexed _newAdmin); event GuardianSet(address indexed _oldGuardian, address indexed _newGuardian); event NewProtectedAddress(ILERC20 indexed _token, address indexed _protectedAddress, address indexed _strategy); event RemovedProtectedAddress(ILERC20 indexed _token, address indexed _protectedAddress); event NewSettlementPeriodProposal(ILERC20 indexed _token, uint256 _seconds); event SettlementPeriodChange(ILERC20 indexed _token, uint256 _proposedTokenLockTimeframe); event NewSettlementTimelock(uint256 indexed _timelock); event NewDexThreshold(uint256 indexed _newThreshold); event NewDex(address indexed _dexAddress); event DexRemoval(address indexed _dexAddress); event NewWhitelistedAddress(address indexed _whitelistAdr); event WhitelistedAddressRemoval(address indexed _whitelistAdr); event NewBlacklistedAddress(address indexed _blacklistedAddres); event AccountBlacklistRemoval(address indexed _adr); event NewStakingContract(ILssStaking indexed _newAdr); event NewReportingContract(ILssReporting indexed _newAdr); event NewGovernanceContract(ILssGovernance indexed _newAdr); event EmergencyActive(ILERC20 indexed _token); event EmergencyDeactivation(ILERC20 indexed _token); event NewMint(ILERC20 indexed token, address indexed account, uint256 indexed amount); event NewMintLimit(ILERC20 indexed token, uint256 indexed limit); event NewMintPeriod(ILERC20 indexed token, uint256 indexed period); event NewBurn(ILERC20 indexed token, address indexed account, uint256 indexed amount); event NewBurnLimit(ILERC20 indexed token, uint256 indexed limit); event NewBurnPeriod(ILERC20 indexed token, uint256 indexed period); event NewExtraordinaryPeriod(uint256 indexed extraordinaryRetrievalProposalPeriod); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface ILERC20 { function name() external view returns (string memory); function admin() external view returns (address); function getAdmin() external view returns (address); function symbol() external view returns (string memory); function decimals() external view returns (uint8); function totalSupply() external view returns (uint256); function balanceOf(address _account) external view returns (uint256); function transfer(address _recipient, uint256 _amount) external returns (bool); function allowance(address _owner, address _spender) external view returns (uint256); function approve(address _spender, uint256 _amount) external returns (bool); function transferFrom(address _sender, address _recipient, uint256 _amount) external returns (bool); function increaseAllowance(address _spender, uint256 _addedValue) external returns (bool); function decreaseAllowance(address _spender, uint256 _subtractedValue) external returns (bool); function transferOutBlacklistedFunds(address[] calldata _from) external; function setLosslessAdmin(address _newAdmin) external; function transferRecoveryAdminOwnership(address _candidate, bytes32 _keyHash) external; function acceptRecoveryAdminOwnership(bytes memory _key) external; function proposeLosslessTurnOff() external; function executeLosslessTurnOff() external; function executeLosslessTurnOn() external; event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); event NewAdmin(address indexed _newAdmin); event NewRecoveryAdminProposal(address indexed _candidate); event NewRecoveryAdmin(address indexed _newAdmin); event LosslessTurnOffProposal(uint256 _turnOffDate); event LosslessOff(); event LosslessOn(); }// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./ILosslessERC20.sol"; import "./ILosslessStaking.sol"; import "./ILosslessReporting.sol"; import "./ILosslessController.sol"; interface ILssGovernance { function LSS_TEAM_INDEX() external view returns(uint256); function TOKEN_OWNER_INDEX() external view returns(uint256); function COMMITEE_INDEX() external view returns(uint256); function committeeMembersCount() external view returns(uint256); function walletDisputePeriod() external view returns(uint256); function losslessStaking() external view returns (ILssStaking); function losslessReporting() external view returns (ILssReporting); function losslessController() external view returns (ILssController); function isCommitteeMember(address _account) external view returns(bool); function getIsVoted(uint256 _reportId, uint256 _voterIndex) external view returns(bool); function getVote(uint256 _reportId, uint256 _voterIndex) external view returns(bool); function isReportSolved(uint256 _reportId) external view returns(bool); function reportResolution(uint256 _reportId) external view returns(bool); function getAmountReported(uint256 _reportId) external view returns(uint256); function setDisputePeriod(uint256 _timeFrame) external; function addCommitteeMembers(address[] memory _members) external; function removeCommitteeMembers(address[] memory _members) external; function losslessVote(uint256 _reportId, bool _vote) external; function tokenOwnersVote(uint256 _reportId, bool _vote) external; function committeeMemberVote(uint256 _reportId, bool _vote) external; function resolveReport(uint256 _reportId) external; function proposeWallet(uint256 _reportId, address wallet) external; function rejectWallet(uint256 _reportId) external; function retrieveFunds(uint256 _reportId) external; function retrieveCompensation() external; function claimCommitteeReward(uint256 _reportId) external; function setCompensationAmount(uint256 _amount) external; function losslessClaim(uint256 _reportId) external; function extaordinaryRetrieval(address[] calldata _address, ILERC20 _token) external; event NewCommitteeMembers(address[] _members); event CommitteeMembersRemoval(address[] _members); event LosslessTeamPositiveVote(uint256 indexed _reportId); event LosslessTeamNegativeVote(uint256 indexed _reportId); event TokenOwnersPositiveVote(uint256 indexed _reportId); event TokenOwnersNegativeVote(uint256 indexed _reportId); event CommitteeMemberPositiveVote(uint256 indexed _reportId, address indexed _member); event CommitteeMemberNegativeVote(uint256 indexed _reportId, address indexed _member); event ReportResolve(uint256 indexed _reportId, bool indexed _resolution); event WalletProposal(uint256 indexed _reportId, address indexed _wallet); event CommitteeMemberClaim(uint256 indexed _reportId, address indexed _member, uint256 indexed _amount); event CommitteeMajorityReach(uint256 indexed _reportId, bool indexed _result); event NewDisputePeriod(uint256 indexed _newPeriod); event WalletRejection(uint256 indexed _reportId); event FundsRetrieval(uint256 indexed _reportId, uint256 indexed _amount); event CompensationRetrieval(address indexed _wallet, uint256 indexed _amount); event LosslessClaim(ILERC20 indexed _token, uint256 indexed _reportID, uint256 indexed _amount); event ExtraordinaryProposalAccept(ILERC20 indexed _token); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./ILosslessERC20.sol"; import "./ILosslessGovernance.sol"; import "./ILosslessStaking.sol"; import "./ILosslessController.sol"; interface ILssReporting { function reporterReward() external returns(uint256); function losslessReward() external returns(uint256); function stakersReward() external returns(uint256); function committeeReward() external returns(uint256); function reportLifetime() external view returns(uint256); function reportingAmount() external returns(uint256); function reportCount() external returns(uint256); function stakingToken() external returns(ILERC20); function losslessController() external returns(ILssController); function losslessGovernance() external returns(ILssGovernance); function getVersion() external pure returns (uint256); function getRewards() external view returns (uint256 _reporter, uint256 _lossless, uint256 _committee, uint256 _stakers); function report(ILERC20 _token, address _account) external returns (uint256); function reporterClaimableAmount(uint256 _reportId) external view returns (uint256); function getReportInfo(uint256 _reportId) external view returns(address _reporter, address _reportedAddress, address _secondReportedAddress, uint256 _reportTimestamps, ILERC20 _reportTokens, bool _secondReports, bool _reporterClaimStatus); function pause() external; function unpause() external; function setStakingToken(ILERC20 _stakingToken) external; function setLosslessGovernance(ILssGovernance _losslessGovernance) external; function setReportingAmount(uint256 _reportingAmount) external; function setReporterReward(uint256 _reward) external; function setLosslessReward(uint256 _reward) external; function setStakersReward(uint256 _reward) external; function setCommitteeReward(uint256 _reward) external; function setReportLifetime(uint256 _lifetime) external; function secondReport(uint256 _reportId, address _account) external; function reporterClaim(uint256 _reportId) external; function retrieveCompensation(address _adr, uint256 _amount) external; event ReportSubmission(ILERC20 indexed _token, address indexed _account, uint256 indexed _reportId); event SecondReportSubmission(ILERC20 indexed _token, address indexed _account, uint256 indexed _reportId); event NewReportingAmount(uint256 indexed _newAmount); event NewStakingToken(ILERC20 indexed _token); event NewGovernanceContract(ILssGovernance indexed _adr); event NewReporterReward(uint256 indexed _newValue); event NewLosslessReward(uint256 indexed _newValue); event NewStakersReward(uint256 indexed _newValue); event NewCommitteeReward(uint256 indexed _newValue); event NewReportLifetime(uint256 indexed _newValue); event ReporterClaim(address indexed _reporter, uint256 indexed _reportId, uint256 indexed _amount); event CompensationRetrieve(address indexed _adr, uint256 indexed _amount); }// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./ILosslessERC20.sol"; import "./ILosslessGovernance.sol"; import "./ILosslessReporting.sol"; import "./ILosslessController.sol"; interface ILssStaking { function stakingToken() external returns(ILERC20); function losslessReporting() external returns(ILssReporting); function losslessController() external returns(ILssController); function losslessGovernance() external returns(ILssGovernance); function stakingAmount() external returns(uint256); function getVersion() external pure returns (uint256); function getIsAccountStaked(uint256 _reportId, address _account) external view returns(bool); function getStakerCoefficient(uint256 _reportId, address _address) external view returns (uint256); function stakerClaimableAmount(uint256 _reportId) external view returns (uint256); function reportCoefficient(uint256 _reportId) external view returns (uint256); function pause() external; function unpause() external; function setLssReporting(ILssReporting _losslessReporting) external; function setStakingToken(ILERC20 _stakingToken) external; function setLosslessGovernance(ILssGovernance _losslessGovernance) external; function setStakingAmount(uint256 _stakingAmount) external; function stake(uint256 _reportId) external; function stakerClaim(uint256 _reportId) external; event NewStake(ILERC20 indexed _token, address indexed _account, uint256 indexed _reportId); event StakerClaim(address indexed _staker, ILERC20 indexed _token, uint256 indexed _reportID, uint256 _amount); event NewStakingAmount(uint256 indexed _newAmount); event NewStakingToken(ILERC20 indexed _newToken); event NewReportingContract(ILssReporting indexed _newContract); event NewGovernanceContract(ILssGovernance indexed _newContract); }pragma solidity ^0.8.0; interface ProtectionStrategy { function isTransferAllowed(address token, address sender, address recipient, uint256 amount) external; }// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./core/LERC20.sol"; import "@openzeppelin/contracts/utils/Context.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/access/AccessControl.sol"; contract SKRBridged is Context, LERC20, AccessControl { constructor( address admin_, address recoveryAdmin_, uint256 timelockPeriod_, address lossless_, address minter_ ) LERC20( "Saakuru", "SKR", admin_, recoveryAdmin_, timelockPeriod_, lossless_ ) { require(minter_ != address(0), "SKRBridged: initial owner is the zero address"); _grantRole(DEFAULT_ADMIN_ROLE, admin_); _grantRole(keccak256("MINTER_ROLE"), minter_); } modifier lssBurn(address account, uint256 amount) { if (isLosslessOn) { lossless.beforeBurn(account, amount); } _; } function burn(uint256 amount) public virtual lssBurn(_msgSender(), amount) { _burn(_msgSender(), amount); } function burnFrom(address account, uint256 amount) public virtual lssBurn(account, amount) { uint256 currentAllowance = allowance(account, _msgSender()); require(currentAllowance >= amount, "ERC20: burn amount exceeds allowance"); unchecked { _approve(account, _msgSender(), currentAllowance - amount); } _burn(account, amount); } function mint(address to, uint256 amount) public onlyRole(keccak256("MINTER_ROLE")) { _mint(to, amount); } function supportsInterface(bytes4 interfaceId) public view virtual override(AccessControl, LERC20) returns (bool) { return super.supportsInterface(interfaceId); } }
File 2 of 3: TransparentUpgradeableProxy
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol"; import "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; import "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol"; // Kept for backwards compatibility with older versions of Hardhat and Truffle plugins. contract AdminUpgradeabilityProxy is TransparentUpgradeableProxy { constructor(address logic, address admin, bytes memory data) payable TransparentUpgradeableProxy(logic, admin, data) {} } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../Proxy.sol"; import "./ERC1967Upgrade.sol"; /** * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an * implementation address that can be changed. This address is stored in storage in the location specified by * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the * implementation behind the proxy. */ contract ERC1967Proxy is Proxy, ERC1967Upgrade { /** * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`. * * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded * function call, and allows initializating the storage of the proxy like a Solidity constructor. */ constructor(address _logic, bytes memory _data) payable { assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1)); _upgradeToAndCall(_logic, _data, false); } /** * @dev Returns the current implementation address. */ function _implementation() internal view virtual override returns (address impl) { return ERC1967Upgrade._getImplementation(); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../ERC1967/ERC1967Proxy.sol"; /** * @dev This contract implements a proxy that is upgradeable by an admin. * * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector * clashing], which can potentially be used in an attack, this contract uses the * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two * things that go hand in hand: * * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if * that call matches one of the admin functions exposed by the proxy itself. * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the * implementation. If the admin tries to call a function on the implementation it will fail with an error that says * "admin cannot fallback to proxy target". * * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due * to sudden errors when trying to call a function from the proxy implementation. * * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy. */ contract TransparentUpgradeableProxy is ERC1967Proxy { /** * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}. */ constructor(address _logic, address admin_, bytes memory _data) payable ERC1967Proxy(_logic, _data) { assert(_ADMIN_SLOT == bytes32(uint256(keccak256("eip1967.proxy.admin")) - 1)); _changeAdmin(admin_); } /** * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin. */ modifier ifAdmin() { if (msg.sender == _getAdmin()) { _; } else { _fallback(); } } /** * @dev Returns the current admin. * * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. * * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103` */ function admin() external ifAdmin returns (address admin_) { admin_ = _getAdmin(); } /** * @dev Returns the current implementation. * * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. * * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc` */ function implementation() external ifAdmin returns (address implementation_) { implementation_ = _implementation(); } /** * @dev Changes the admin of the proxy. * * Emits an {AdminChanged} event. * * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}. */ function changeAdmin(address newAdmin) external virtual ifAdmin { _changeAdmin(newAdmin); } /** * @dev Upgrade the implementation of the proxy. * * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}. */ function upgradeTo(address newImplementation) external ifAdmin { _upgradeToAndCall(newImplementation, bytes(""), false); } /** * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the * proxied contract. * * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}. */ function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin { _upgradeToAndCall(newImplementation, data, true); } /** * @dev Returns the current admin. */ function _admin() internal view virtual returns (address) { return _getAdmin(); } /** * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}. */ function _beforeFallback() internal virtual override { require(msg.sender != _getAdmin(), "TransparentUpgradeableProxy: admin cannot fallback to proxy target"); super._beforeFallback(); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./TransparentUpgradeableProxy.sol"; import "../../access/Ownable.sol"; /** * @dev This is an auxiliary contract meant to be assigned as the admin of a {TransparentUpgradeableProxy}. For an * explanation of why you would want to use this see the documentation for {TransparentUpgradeableProxy}. */ contract ProxyAdmin is Ownable { /** * @dev Returns the current implementation of `proxy`. * * Requirements: * * - This contract must be the admin of `proxy`. */ function getProxyImplementation(TransparentUpgradeableProxy proxy) public view virtual returns (address) { // We need to manually run the static call since the getter cannot be flagged as view // bytes4(keccak256("implementation()")) == 0x5c60da1b (bool success, bytes memory returndata) = address(proxy).staticcall(hex"5c60da1b"); require(success); return abi.decode(returndata, (address)); } /** * @dev Returns the current admin of `proxy`. * * Requirements: * * - This contract must be the admin of `proxy`. */ function getProxyAdmin(TransparentUpgradeableProxy proxy) public view virtual returns (address) { // We need to manually run the static call since the getter cannot be flagged as view // bytes4(keccak256("admin()")) == 0xf851a440 (bool success, bytes memory returndata) = address(proxy).staticcall(hex"f851a440"); require(success); return abi.decode(returndata, (address)); } /** * @dev Changes the admin of `proxy` to `newAdmin`. * * Requirements: * * - This contract must be the current admin of `proxy`. */ function changeProxyAdmin(TransparentUpgradeableProxy proxy, address newAdmin) public virtual onlyOwner { proxy.changeAdmin(newAdmin); } /** * @dev Upgrades `proxy` to `implementation`. See {TransparentUpgradeableProxy-upgradeTo}. * * Requirements: * * - This contract must be the admin of `proxy`. */ function upgrade(TransparentUpgradeableProxy proxy, address implementation) public virtual onlyOwner { proxy.upgradeTo(implementation); } /** * @dev Upgrades `proxy` to `implementation` and calls a function on the new implementation. See * {TransparentUpgradeableProxy-upgradeToAndCall}. * * Requirements: * * - This contract must be the admin of `proxy`. */ function upgradeAndCall(TransparentUpgradeableProxy proxy, address implementation, bytes memory data) public payable virtual onlyOwner { proxy.upgradeToAndCall{value: msg.value}(implementation, data); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to * be specified by overriding the virtual {_implementation} function. * * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a * different contract through the {_delegate} function. * * The success and return data of the delegated call will be returned back to the caller of the proxy. */ abstract contract Proxy { /** * @dev Delegates the current call to `implementation`. * * This function does not return to its internall call site, it will return directly to the external caller. */ function _delegate(address implementation) internal virtual { // solhint-disable-next-line no-inline-assembly assembly { // Copy msg.data. We take full control of memory in this inline assembly // block because it will not return to Solidity code. We overwrite the // Solidity scratch pad at memory position 0. calldatacopy(0, 0, calldatasize()) // Call the implementation. // out and outsize are 0 because we don't know the size yet. let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0) // Copy the returned data. returndatacopy(0, 0, returndatasize()) switch result // delegatecall returns 0 on error. case 0 { revert(0, returndatasize()) } default { return(0, returndatasize()) } } } /** * @dev This is a virtual function that should be overriden so it returns the address to which the fallback function * and {_fallback} should delegate. */ function _implementation() internal view virtual returns (address); /** * @dev Delegates the current call to the address returned by `_implementation()`. * * This function does not return to its internall call site, it will return directly to the external caller. */ function _fallback() internal virtual { _beforeFallback(); _delegate(_implementation()); } /** * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other * function in the contract matches the call data. */ fallback () external payable virtual { _fallback(); } /** * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data * is empty. */ receive () external payable virtual { _fallback(); } /** * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback` * call, or as part of the Solidity `fallback` or `receive` functions. * * If overriden should call `super._beforeFallback()`. */ function _beforeFallback() internal virtual { } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.2; import "../beacon/IBeacon.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 { _setImplementation(newImplementation); emit Upgraded(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 _upgradeToAndCallSecure(address newImplementation, bytes memory data, bool forceCall) internal { address oldImplementation = _getImplementation(); // Initial upgrade and setup call _setImplementation(newImplementation); if (data.length > 0 || forceCall) { Address.functionDelegateCall(newImplementation, data); } // Perform rollback test if not already in progress StorageSlot.BooleanSlot storage rollbackTesting = StorageSlot.getBooleanSlot(_ROLLBACK_SLOT); if (!rollbackTesting.value) { // Trigger rollback using upgradeTo from the new implementation rollbackTesting.value = true; Address.functionDelegateCall( newImplementation, abi.encodeWithSignature( "upgradeTo(address)", oldImplementation ) ); rollbackTesting.value = false; // Check rollback was effective require(oldImplementation == _getImplementation(), "ERC1967Upgrade: upgrade breaks further upgrades"); // Finally reset to the new implementation and log the upgrade _setImplementation(newImplementation); emit Upgraded(newImplementation); } } /** * @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); } } /** * @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; } } // SPDX-License-Identifier: MIT 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 pragma solidity ^0.8.0; /** * @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 * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 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"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (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 functionCall(target, data, "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"); require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: value }(data); return _verifyCallResult(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) { require(isContract(target), "Address: static call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(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) { require(isContract(target), "Address: delegate call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { if (success) { return returndata; } else { // 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 // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT 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) { assembly { r.slot := slot } } /** * @dev Returns an `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { assembly { r.slot := slot } } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../utils/Context.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 Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = 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"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /* * @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 Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../ERC1967/ERC1967Upgrade.sol"; /** * @dev Base contract for building openzeppelin-upgrades compatible implementations for the {ERC1967Proxy}. It includes * publicly available upgrade functions that are called by the plugin and by the secure upgrade mechanism to verify * continuation of the upgradability. * * The {_authorizeUpgrade} function MUST be overridden to include access restriction to the upgrade mechanism. * * _Available since v4.1._ */ abstract contract UUPSUpgradeable is ERC1967Upgrade { function upgradeTo(address newImplementation) external virtual { _authorizeUpgrade(newImplementation); _upgradeToAndCallSecure(newImplementation, bytes(""), false); } function upgradeToAndCall(address newImplementation, bytes memory data) external payable virtual { _authorizeUpgrade(newImplementation); _upgradeToAndCallSecure(newImplementation, data, true); } function _authorizeUpgrade(address newImplementation) internal virtual; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.2; import "@openzeppelin/contracts/proxy/utils/UUPSUpgradeable.sol"; abstract contract Proxiable is UUPSUpgradeable { function _authorizeUpgrade(address newImplementation) internal override { _beforeUpgrade(newImplementation); } function _beforeUpgrade(address newImplementation) internal virtual; } contract ChildOfProxiable is Proxiable { function _beforeUpgrade(address newImplementation) internal virtual override {} }
File 3 of 3: LosslessControllerV3
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import "./Interfaces/ILosslessERC20.sol"; import "./Interfaces/ILosslessGovernance.sol"; import "./Interfaces/ILosslessStaking.sol"; import "./Interfaces/ILosslessReporting.sol"; import "./Interfaces/IProtectionStrategy.sol"; /// @title Lossless Controller Contract /// @notice The controller contract is in charge of the communication and senstive data among all Lossless Environment Smart Contracts contract LosslessControllerV3 is ILssController, Initializable, ContextUpgradeable, PausableUpgradeable { // IMPORTANT!: For future reference, when adding new variables for following versions of the controller. // All the previous ones should be kept in place and not change locations, types or names. // If thye're modified this would cause issues with the memory slots. address override public pauseAdmin; address override public admin; address override public recoveryAdmin; // --- V2 VARIABLES --- address override public guardian; mapping(ILERC20 => Protections) private tokenProtections; struct Protection { bool isProtected; ProtectionStrategy strategy; } struct Protections { mapping(address => Protection) protections; } // --- V3 VARIABLES --- ILssStaking override public losslessStaking; ILssReporting override public losslessReporting; ILssGovernance override public losslessGovernance; struct LocksQueue { mapping(uint256 => ReceiveCheckpoint) lockedFunds; uint256 touchedTimestamp; uint256 first; uint256 last; } struct TokenLockedFunds { mapping(address => LocksQueue) queue; } mapping(ILERC20 => TokenLockedFunds) private tokenScopedLockedFunds; struct ReceiveCheckpoint { uint256 amount; uint256 timestamp; uint256 cummulativeAmount; } uint256 public constant HUNDRED = 1e2; uint256 override public dexTranferThreshold; uint256 override public settlementTimeLock; mapping(address => bool) override public dexList; mapping(address => bool) override public whitelist; mapping(address => bool) override public blacklist; struct TokenConfig { uint256 tokenLockTimeframe; uint256 proposedTokenLockTimeframe; uint256 changeSettlementTimelock; uint256 emergencyMode; } mapping(ILERC20 => TokenConfig) tokenConfig; // --- MODIFIERS --- /// @notice Avoids execution from other than the Recovery Admin modifier onlyLosslessRecoveryAdmin() { require(msg.sender == recoveryAdmin, "LSS: Must be recoveryAdmin"); _; } /// @notice Avoids execution from other than the Lossless Admin modifier onlyLosslessAdmin() { require(msg.sender == admin, "LSS: Must be admin"); _; } /// @notice Avoids execution from other than the Pause Admin modifier onlyPauseAdmin() { require(msg.sender == pauseAdmin, "LSS: Must be pauseAdmin"); _; } // --- V2 MODIFIERS --- modifier onlyGuardian() { require(msg.sender == guardian, "LOSSLESS: Must be Guardian"); _; } // --- V3 MODIFIERS --- /// @notice Avoids execution from other than the Lossless Admin or Lossless Environment modifier onlyLosslessEnv { require(msg.sender == address(losslessStaking) || msg.sender == address(losslessReporting) || msg.sender == address(losslessGovernance), "LSS: Lss SC only"); _; } // --- VIEWS --- /// @notice This function will return the contract version function getVersion() external pure returns (uint256) { return 3; } // --- V2 VIEWS --- function isAddressProtected(ILERC20 _token, address _protectedAddress) public view returns (bool) { return tokenProtections[_token].protections[_protectedAddress].isProtected; } function getProtectedAddressStrategy(ILERC20 _token, address _protectedAddress) external view returns (address) { require(isAddressProtected(_token, _protectedAddress), "LSS: Address not protected"); return address(tokenProtections[_token].protections[_protectedAddress].strategy); } // --- ADMINISTRATION --- function pause() override public onlyPauseAdmin { _pause(); } function unpause() override public onlyPauseAdmin { _unpause(); } /// @notice This function sets a new admin /// @dev Only can be called by the Recovery admin /// @param _newAdmin Address corresponding to the new Lossless Admin function setAdmin(address _newAdmin) override public onlyLosslessRecoveryAdmin { require(_newAdmin != admin, "LERC20: Cannot set same address"); emit AdminChange(_newAdmin); admin = _newAdmin; } /// @notice This function sets a new recovery admin /// @dev Only can be called by the previous Recovery admin /// @param _newRecoveryAdmin Address corresponding to the new Lossless Recovery Admin function setRecoveryAdmin(address _newRecoveryAdmin) override public onlyLosslessRecoveryAdmin { require(_newRecoveryAdmin != recoveryAdmin, "LERC20: Cannot set same address"); emit RecoveryAdminChange(_newRecoveryAdmin); recoveryAdmin = _newRecoveryAdmin; } /// @notice This function sets a new pause admin /// @dev Only can be called by the Recovery admin /// @param _newPauseAdmin Address corresponding to the new Lossless Recovery Admin function setPauseAdmin(address _newPauseAdmin) override public onlyLosslessRecoveryAdmin { require(_newPauseAdmin != pauseAdmin, "LERC20: Cannot set same address"); emit PauseAdminChange(_newPauseAdmin); pauseAdmin = _newPauseAdmin; } // --- V3 SETTERS --- /// @notice This function sets the timelock for tokens to change the settlement period /// @dev Only can be called by the Lossless Admin /// @param _newTimelock Timelock in seconds function setSettlementTimeLock(uint256 _newTimelock) override public onlyLosslessAdmin { require(_newTimelock != settlementTimeLock, "LSS: Cannot set same value"); settlementTimeLock = _newTimelock; emit NewSettlementTimelock(settlementTimeLock); } /// @notice This function sets the transfer threshold for Dexes /// @dev Only can be called by the Lossless Admin /// @param _newThreshold Timelock in seconds function setDexTransferThreshold(uint256 _newThreshold) override public onlyLosslessAdmin { require(_newThreshold != dexTranferThreshold, "LSS: Cannot set same value"); dexTranferThreshold = _newThreshold; emit NewDexThreshold(dexTranferThreshold); } /// @notice This function removes or adds an array of dex addresses from the whitelst /// @dev Only can be called by the Lossless Admin, only Lossless addresses /// @param _dexList List of dex addresses to add or remove /// @param _value True if the addresses are bieng added, false if removed function setDexList(address[] calldata _dexList, bool _value) override public onlyLosslessAdmin { for(uint256 i = 0; i < _dexList.length;) { address adr = _dexList[i]; require(!blacklist[adr], "LSS: An address is blacklisted"); dexList[adr] = _value; if (_value) { emit NewDex(adr); } else { emit DexRemoval(adr); } unchecked{i++;} } } /// @notice This function removes or adds an array of addresses from the whitelst /// @dev Only can be called by the Lossless Admin, only Lossless addresses /// @param _addrList List of addresses to add or remove /// @param _value True if the addresses are bieng added, false if removed function setWhitelist(address[] calldata _addrList, bool _value) override public onlyLosslessAdmin { for(uint256 i = 0; i < _addrList.length;) { address adr = _addrList[i]; require(!blacklist[adr], "LSS: An address is blacklisted"); whitelist[adr] = _value; if (_value) { emit NewWhitelistedAddress(adr); } else { emit WhitelistedAddressRemoval(adr); } unchecked{i++;} } } /// @notice This function adds an address to the blacklist /// @dev Only can be called by the Lossless Admin, and from other Lossless Contracts /// The address gets blacklisted whenever a report is created on them. /// @param _adr Address corresponding to be added to the blacklist mapping function addToBlacklist(address _adr) override public onlyLosslessEnv { blacklist[_adr] = true; emit NewBlacklistedAddress(_adr); } /// @notice This function removes an address from the blacklist /// @dev Can only be called from other Lossless Contracts, used mainly in Lossless Governance /// @param _adr Address corresponding to be removed from the blacklist mapping function resolvedNegatively(address _adr) override public onlyLosslessEnv { blacklist[_adr] = false; emit AccountBlacklistRemoval(_adr); } /// @notice This function sets the address of the Lossless Staking contract /// @param _adr Address corresponding to the Lossless Staking contract function setStakingContractAddress(ILssStaking _adr) override public onlyLosslessAdmin { require(address(_adr) != address(0), "LERC20: Cannot be zero address"); require(_adr != losslessStaking, "LSS: Cannot set same value"); losslessStaking = _adr; emit NewStakingContract(_adr); } /// @notice This function sets the address of the Lossless Reporting contract /// @param _adr Address corresponding to the Lossless Reporting contract function setReportingContractAddress(ILssReporting _adr) override public onlyLosslessAdmin { require(address(_adr) != address(0), "LERC20: Cannot be zero address"); require(_adr != losslessReporting, "LSS: Cannot set same value"); losslessReporting = _adr; emit NewReportingContract(_adr); } /// @notice This function sets the address of the Lossless Governance contract /// @param _adr Address corresponding to the Lossless Governance contract function setGovernanceContractAddress(ILssGovernance _adr) override public onlyLosslessAdmin { require(address(_adr) != address(0), "LERC20: Cannot be zero address"); require(_adr != losslessGovernance, "LSS: Cannot set same value"); losslessGovernance = _adr; emit NewGovernanceContract(_adr); } /// @notice This function starts a new proposal to change the SettlementPeriod /// @param _token to propose the settlement change period on /// @param _seconds Time frame that the recieved funds will be locked function proposeNewSettlementPeriod(ILERC20 _token, uint256 _seconds) override public { TokenConfig storage config = tokenConfig[_token]; require(msg.sender == _token.admin(), "LSS: Must be Token Admin"); require(config.changeSettlementTimelock <= block.timestamp, "LSS: Time lock in progress"); config.changeSettlementTimelock = block.timestamp + settlementTimeLock; config.proposedTokenLockTimeframe = _seconds; emit NewSettlementPeriodProposal(_token, _seconds); } /// @notice This function executes the new settlement period after the timelock /// @param _token to set time settlement period on function executeNewSettlementPeriod(ILERC20 _token) override public { TokenConfig storage config = tokenConfig[_token]; require(msg.sender == _token.admin(), "LSS: Must be Token Admin"); require(config.proposedTokenLockTimeframe != 0, "LSS: New Settlement not proposed"); require(config.changeSettlementTimelock <= block.timestamp, "LSS: Time lock in progress"); config.tokenLockTimeframe = config.proposedTokenLockTimeframe; config.proposedTokenLockTimeframe = 0; emit SettlementPeriodChange(_token, config.tokenLockTimeframe); } /// @notice This function activates the emergency mode /// @dev When a report gets generated for a token, it enters an emergency state globally. /// The emergency period will be active for one settlement period. /// During this time users can only transfer settled tokens /// @param _token Token on which the emergency mode must get activated function activateEmergency(ILERC20 _token) override external onlyLosslessEnv { tokenConfig[_token].emergencyMode = block.timestamp; emit EmergencyActive(_token); } /// @notice This function deactivates the emergency mode /// @param _token Token on which the emergency mode will be deactivated function deactivateEmergency(ILERC20 _token) override external onlyLosslessEnv { tokenConfig[_token].emergencyMode = 0; emit EmergencyDeactivation(_token); } // --- GUARD --- // @notice Set a guardian contract. // @dev Guardian contract must be trusted as it has some access rights and can modify controller's state. function setGuardian(address _newGuardian) override external onlyLosslessAdmin whenNotPaused { require(_newGuardian != address(0), "LSS: Cannot be zero address"); emit GuardianSet(guardian, _newGuardian); guardian = _newGuardian; } // @notice Sets protection for an address with the choosen strategy. // @dev Strategies are verified in the guardian contract. // @dev This call is initiated from a strategy, but guardian proxies it. function setProtectedAddress(ILERC20 _token, address _protectedAddress, ProtectionStrategy _strategy) override external onlyGuardian whenNotPaused { Protection storage protection = tokenProtections[_token].protections[_protectedAddress]; protection.isProtected = true; protection.strategy = _strategy; emit NewProtectedAddress(_token, _protectedAddress, address(_strategy)); } // @notice Remove the protection from the address. // @dev Strategies are verified in the guardian contract. // @dev This call is initiated from a strategy, but guardian proxies it. function removeProtectedAddress(ILERC20 _token, address _protectedAddress) override external onlyGuardian whenNotPaused { require(isAddressProtected(_token, _protectedAddress), "LSS: Address not protected"); delete tokenProtections[_token].protections[_protectedAddress]; emit RemovedProtectedAddress(_token, _protectedAddress); } function _getLatestOudatedCheckpoint(LocksQueue storage queue) private view returns (uint256, uint256) { uint256 lower = queue.first; uint256 upper = queue.last; uint256 currentTimestamp = block.timestamp; uint256 center = queue.first; ReceiveCheckpoint memory cp = queue.lockedFunds[queue.last]; ReceiveCheckpoint memory lowestCp = queue.lockedFunds[queue.first]; while (upper > lower) { center = upper - ((upper - lower) >> 1); // ceil, avoiding overflow cp = queue.lockedFunds[center]; if (cp.timestamp == currentTimestamp) { return (cp.cummulativeAmount, center + 1); } else if (cp.timestamp < currentTimestamp) { lowestCp = cp; lower = center; } else { upper = center - 1; center = upper; } } if (lowestCp.timestamp < currentTimestamp) { if (cp.timestamp < lowestCp.timestamp) { return (cp.cummulativeAmount, center); } else { return (lowestCp.cummulativeAmount, lower); } } else { return (0, center); } } /// @notice This function will calculate the available amount that an address has to transfer. /// @param _token Address corresponding to the token being held /// @param account Address to get the available amount function _getAvailableAmount(ILERC20 _token, address account) private returns (uint256 amount) { LocksQueue storage queue = tokenScopedLockedFunds[_token].queue[account]; ReceiveCheckpoint storage cp = queue.lockedFunds[queue.last]; (uint256 outdatedCummulative, uint256 newFirst) = _getLatestOudatedCheckpoint(queue); queue.first = newFirst; require(cp.cummulativeAmount >= outdatedCummulative, "LSS: Transfers limit reached"); cp.cummulativeAmount = cp.cummulativeAmount - outdatedCummulative; return _token.balanceOf(account) - cp.cummulativeAmount; } // LOCKs & QUEUES /// @notice This function add transfers to the lock queues /// @param _checkpoint timestamp of the transfer /// @param _recipient Address to add the locks function _enqueueLockedFunds(ReceiveCheckpoint memory _checkpoint, address _recipient) private { LocksQueue storage queue; queue = tokenScopedLockedFunds[ILERC20(msg.sender)].queue[_recipient]; uint256 lastItem = queue.last; ReceiveCheckpoint storage lastCheckpoint = queue.lockedFunds[lastItem]; if (lastCheckpoint.timestamp < _checkpoint.timestamp) { // Most common scenario where the item goes at the end of the queue _checkpoint.cummulativeAmount = _checkpoint.amount + lastCheckpoint.cummulativeAmount; queue.lockedFunds[lastItem + 1] = _checkpoint; queue.last += 1; } else { // Second most common scenario where the timestamps are the same // or new one is smaller than the latest one. // So the amount adds up. lastCheckpoint.amount += _checkpoint.amount; lastCheckpoint.cummulativeAmount += _checkpoint.amount; } if (queue.first == 0) { queue.first += 1; } } // --- REPORT RESOLUTION --- /// @notice This function retrieves the funds of the reported account /// @param _addresses Array of addreses to retrieve the locked funds /// @param _token Token to retrieve the funds from /// @param _reportId Report Id related to the incident function retrieveBlacklistedFunds(address[] calldata _addresses, ILERC20 _token, uint256 _reportId) override public onlyLosslessEnv returns(uint256){ uint256 totalAmount = losslessGovernance.getAmountReported(_reportId); _token.transferOutBlacklistedFunds(_addresses); (uint256 reporterReward, uint256 losslessReward, uint256 committeeReward, uint256 stakersReward) = losslessReporting.getRewards(); uint256 toLssStaking = totalAmount * stakersReward / HUNDRED; uint256 toLssReporting = totalAmount * reporterReward / HUNDRED; uint256 toLssGovernance = totalAmount - toLssStaking - toLssReporting; require(_token.transfer(address(losslessStaking), toLssStaking), "LSS: Staking retrieval failed"); require(_token.transfer(address(losslessReporting), toLssReporting), "LSS: Reporting retrieval failed"); require(_token.transfer(address(losslessGovernance), toLssGovernance), "LSS: Governance retrieval failed"); return totalAmount - toLssStaking - toLssReporting - (totalAmount * (committeeReward + losslessReward) / HUNDRED); } /// @notice This function will lift the locks after a certain amount /// @dev The condition to lift the locks is that their checkpoint should be greater than the set amount /// @param _availableAmount Unlocked Amount /// @param _account Address to lift the locks /// @param _amount Amount to lift function _removeUsedUpLocks (uint256 _availableAmount, address _account, uint256 _amount) private { LocksQueue storage queue; ILERC20 token = ILERC20(msg.sender); queue = tokenScopedLockedFunds[token].queue[_account]; require(queue.touchedTimestamp + tokenConfig[token].tokenLockTimeframe <= block.timestamp, "LSS: Transfers limit reached"); uint256 amountLeft = _amount - _availableAmount; ReceiveCheckpoint storage cp = queue.lockedFunds[queue.last]; cp.cummulativeAmount -= amountLeft; queue.touchedTimestamp = block.timestamp; ReceiveCheckpoint storage firstCp = queue.lockedFunds[queue.first]; // Consume all used up settled tokens if (firstCp.timestamp < block.timestamp) { firstCp.cummulativeAmount = 0; } } // --- BEFORE HOOKS --- /// @notice This function evaluates if the transfer can be made /// @param _sender Address sending the funds /// @param _recipient Address recieving the funds /// @param _amount Amount to be transfered function _evaluateTransfer(address _sender, address _recipient, uint256 _amount) private returns (bool) { ILERC20 token = ILERC20(msg.sender); uint256 settledAmount = _getAvailableAmount(token, _sender); TokenConfig storage config = tokenConfig[token]; if (_amount > settledAmount) { require(config.emergencyMode + config.tokenLockTimeframe < block.timestamp, "LSS: Emergency mode active, cannot transfer unsettled tokens"); if (dexList[_recipient]) { require(_amount - settledAmount <= dexTranferThreshold, "LSS: Cannot transfer over the dex threshold"); } else { _removeUsedUpLocks(settledAmount, _sender, _amount); } } ReceiveCheckpoint memory newCheckpoint = ReceiveCheckpoint(_amount, block.timestamp + config.tokenLockTimeframe, 0); _enqueueLockedFunds(newCheckpoint, _recipient); return true; } /// @notice If address is protected, transfer validation rules have to be run inside the strategy. /// @dev isTransferAllowed reverts in case transfer can not be done by the defined rules. function beforeTransfer(address _sender, address _recipient, uint256 _amount) override external { ILERC20 token = ILERC20(msg.sender); if (tokenProtections[token].protections[_sender].isProtected) { tokenProtections[token].protections[_sender].strategy.isTransferAllowed(msg.sender, _sender, _recipient, _amount); } require(!blacklist[_sender], "LSS: You cannot operate"); if (tokenConfig[token].tokenLockTimeframe != 0) { _evaluateTransfer(_sender, _recipient, _amount); } } /// @notice If address is protected, transfer validation rules have to be run inside the strategy. /// @dev isTransferAllowed reverts in case transfer can not be done by the defined rules. function beforeTransferFrom(address _msgSender, address _sender, address _recipient, uint256 _amount) override external { ILERC20 token = ILERC20(msg.sender); if (tokenProtections[token].protections[_sender].isProtected) { tokenProtections[token].protections[_sender].strategy.isTransferAllowed(msg.sender, _sender, _recipient, _amount); } require(!blacklist[_msgSender], "LSS: You cannot operate"); require(!blacklist[_sender], "LSS: Sender is blacklisted"); if (tokenConfig[token].tokenLockTimeframe != 0) { _evaluateTransfer(_sender, _recipient, _amount); } } // The following before hooks are in place as a placeholder for future products. // Also to preserve legacy LERC20 compatibility function beforeMint(address _to, uint256 _amount) override external {} function beforeApprove(address _sender, address _spender, uint256 _amount) override external {} function beforeBurn(address _account, uint256 _amount) override external {} function beforeIncreaseAllowance(address _msgSender, address _spender, uint256 _addedValue) override external {} function beforeDecreaseAllowance(address _msgSender, address _spender, uint256 _subtractedValue) override external {} // --- AFTER HOOKS --- // * After hooks are deprecated in LERC20 but we have to keep them // here in order to support legacy LERC20. function afterMint(address _to, uint256 _amount) external {} function afterApprove(address _sender, address _spender, uint256 _amount) external {} function afterBurn(address _account, uint256 _amount) external {} function afterTransfer(address _sender, address _recipient, uint256 _amount) external {} function afterTransferFrom(address _msgSender, address _sender, address _recipient, uint256 _amount) external {} function afterIncreaseAllowance(address _sender, address _spender, uint256 _addedValue) external {} function afterDecreaseAllowance(address _sender, address _spender, uint256 _subtractedValue) external {} } // 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 { __Context_init_unchained(); } 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; } uint256[50] private __gap; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (security/Pausable.sol) pragma solidity ^0.8.0; import "../utils/ContextUpgradeable.sol"; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ abstract contract PausableUpgradeable is Initializable, ContextUpgradeable { /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. */ function __Pausable_init() internal onlyInitializing { __Context_init_unchained(); __Pausable_init_unchained(); } function __Pausable_init_unchained() internal onlyInitializing { _paused = false; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { return _paused; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { require(!paused(), "Pausable: paused"); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { require(paused(), "Pausable: not paused"); _; } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } uint256[49] private __gap; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (proxy/utils/Initializable.sol) pragma solidity ^0.8.0; 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 a proxied contract can't have 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. * * 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 initialize the implementation contract, you can either invoke the * initializer manually, or you can include a constructor to automatically mark it as initialized when it is deployed: * * [.hljs-theme-light.nopadding] * ``` * /// @custom:oz-upgrades-unsafe-allow constructor * constructor() initializer {} * ``` * ==== */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. */ bool private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Modifier to protect an initializer function from being invoked twice. */ modifier initializer() { // If the contract is initializing we ignore whether _initialized is set in order to support multiple // inheritance patterns, but we only do this in the context of a constructor, because in other contexts the // contract may have been reentered. require(_initializing ? _isConstructor() : !_initialized, "Initializable: contract is already initialized"); bool isTopLevelCall = !_initializing; if (isTopLevelCall) { _initializing = true; _initialized = true; } _; if (isTopLevelCall) { _initializing = false; } } /** * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the * {initializer} modifier, directly or indirectly. */ modifier onlyInitializing() { require(_initializing, "Initializable: contract is not initializing"); _; } function _isConstructor() private view returns (bool) { return !AddressUpgradeable.isContract(address(this)); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface ILERC20 { function name() external view returns (string memory); function admin() external view returns (address); function getAdmin() external view returns (address); function symbol() external view returns (string memory); function decimals() external view returns (uint8); function totalSupply() external view returns (uint256); function balanceOf(address _account) external view returns (uint256); function transfer(address _recipient, uint256 _amount) external returns (bool); function allowance(address _owner, address _spender) external view returns (uint256); function approve(address _spender, uint256 _amount) external returns (bool); function transferFrom(address _sender, address _recipient, uint256 _amount) external returns (bool); function increaseAllowance(address _spender, uint256 _addedValue) external returns (bool); function decreaseAllowance(address _spender, uint256 _subtractedValue) external returns (bool); function transferOutBlacklistedFunds(address[] calldata _from) external; function setLosslessAdmin(address _newAdmin) external; function transferRecoveryAdminOwnership(address _candidate, bytes32 _keyHash) external; function acceptRecoveryAdminOwnership(bytes memory _key) external; function proposeLosslessTurnOff() external; function executeLosslessTurnOff() external; function executeLosslessTurnOn() external; event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); event NewAdmin(address indexed _newAdmin); event NewRecoveryAdminProposal(address indexed _candidate); event NewRecoveryAdmin(address indexed _newAdmin); event LosslessTurnOffProposal(uint256 _turnOffDate); event LosslessOff(); event LosslessOn(); }// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./ILosslessERC20.sol"; import "./ILosslessStaking.sol"; import "./ILosslessReporting.sol"; import "./ILosslessController.sol"; interface ILssGovernance { function LSS_TEAM_INDEX() external view returns(uint256); function TOKEN_OWNER_INDEX() external view returns(uint256); function COMMITEE_INDEX() external view returns(uint256); function committeeMembersCount() external view returns(uint256); function walletDisputePeriod() external view returns(uint256); function losslessStaking() external view returns (ILssStaking); function losslessReporting() external view returns (ILssReporting); function losslessController() external view returns (ILssController); function isCommitteeMember(address _account) external view returns(bool); function getIsVoted(uint256 _reportId, uint256 _voterIndex) external view returns(bool); function getVote(uint256 _reportId, uint256 _voterIndex) external view returns(bool); function isReportSolved(uint256 _reportId) external view returns(bool); function reportResolution(uint256 _reportId) external view returns(bool); function getAmountReported(uint256 _reportId) external view returns(uint256); function setDisputePeriod(uint256 _timeFrame) external; function addCommitteeMembers(address[] memory _members) external; function removeCommitteeMembers(address[] memory _members) external; function losslessVote(uint256 _reportId, bool _vote) external; function tokenOwnersVote(uint256 _reportId, bool _vote) external; function committeeMemberVote(uint256 _reportId, bool _vote) external; function resolveReport(uint256 _reportId) external; function proposeWallet(uint256 _reportId, address wallet) external; function rejectWallet(uint256 _reportId) external; function retrieveFunds(uint256 _reportId) external; function retrieveCompensation() external; function claimCommitteeReward(uint256 _reportId) external; function setCompensationAmount(uint256 _amount) external; function losslessClaim(uint256 _reportId) external; event NewCommitteeMembers(address[] _members); event CommitteeMembersRemoval(address[] _members); event LosslessTeamPositiveVote(uint256 indexed _reportId); event LosslessTeamNegativeVote(uint256 indexed _reportId); event TokenOwnersPositiveVote(uint256 indexed _reportId); event TokenOwnersNegativeVote(uint256 indexed _reportId); event CommitteeMemberPositiveVote(uint256 indexed _reportId, address indexed _member); event CommitteeMemberNegativeVote(uint256 indexed _reportId, address indexed _member); event ReportResolve(uint256 indexed _reportId, bool indexed _resolution); event WalletProposal(uint256 indexed _reportId, address indexed _wallet); event CommitteeMemberClaim(uint256 indexed _reportId, address indexed _member, uint256 indexed _amount); event CommitteeMajorityReach(uint256 indexed _reportId, bool indexed _result); event NewDisputePeriod(uint256 indexed _newPeriod); event WalletRejection(uint256 indexed _reportId); event FundsRetrieval(uint256 indexed _reportId, uint256 indexed _amount); event CompensationRetrieval(address indexed _wallet, uint256 indexed _amount); event LosslessClaim(ILERC20 indexed _token, uint256 indexed _reportID, uint256 indexed _amount); event NewCompensationPercentage(uint256 indexed _compensationPercentage); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./ILosslessERC20.sol"; import "./ILosslessGovernance.sol"; import "./ILosslessReporting.sol"; import "./ILosslessController.sol"; interface ILssStaking { function stakingToken() external returns(ILERC20); function losslessReporting() external returns(ILssReporting); function losslessController() external returns(ILssController); function losslessGovernance() external returns(ILssGovernance); function stakingAmount() external returns(uint256); function getVersion() external pure returns (uint256); function getIsAccountStaked(uint256 _reportId, address _account) external view returns(bool); function getStakerCoefficient(uint256 _reportId, address _address) external view returns (uint256); function stakerClaimableAmount(uint256 _reportId) external view returns (uint256); function pause() external; function unpause() external; function setLssReporting(ILssReporting _losslessReporting) external; function setStakingToken(ILERC20 _stakingToken) external; function setLosslessGovernance(ILssGovernance _losslessGovernance) external; function setStakingAmount(uint256 _stakingAmount) external; function stake(uint256 _reportId) external; function stakerClaim(uint256 _reportId) external; event NewStake(ILERC20 indexed _token, address indexed _account, uint256 indexed _reportId, uint256 _amount); event StakerClaim(address indexed _staker, ILERC20 indexed _token, uint256 indexed _reportID, uint256 _amount); event NewStakingAmount(uint256 indexed _newAmount); event NewStakingToken(ILERC20 indexed _newToken); event NewReportingContract(ILssReporting indexed _newContract); event NewGovernanceContract(ILssGovernance indexed _newContract); }// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./ILosslessERC20.sol"; import "./ILosslessGovernance.sol"; import "./ILosslessStaking.sol"; import "./ILosslessController.sol"; interface ILssReporting { function reporterReward() external returns(uint256); function losslessReward() external returns(uint256); function stakersReward() external returns(uint256); function committeeReward() external returns(uint256); function reportLifetime() external view returns(uint256); function reportingAmount() external returns(uint256); function reportCount() external returns(uint256); function stakingToken() external returns(ILERC20); function losslessController() external returns(ILssController); function losslessGovernance() external returns(ILssGovernance); function getVersion() external pure returns (uint256); function getRewards() external view returns (uint256 _reporter, uint256 _lossless, uint256 _committee, uint256 _stakers); function report(ILERC20 _token, address _account) external returns (uint256); function reporterClaimableAmount(uint256 _reportId) external view returns (uint256); function getReportInfo(uint256 _reportId) external view returns(address _reporter, address _reportedAddress, address _secondReportedAddress, uint256 _reportTimestamps, ILERC20 _reportTokens, bool _secondReports, bool _reporterClaimStatus); function pause() external; function unpause() external; function setStakingToken(ILERC20 _stakingToken) external; function setLosslessGovernance(ILssGovernance _losslessGovernance) external; function setReportingAmount(uint256 _reportingAmount) external; function setReporterReward(uint256 _reward) external; function setLosslessReward(uint256 _reward) external; function setStakersReward(uint256 _reward) external; function setCommitteeReward(uint256 _reward) external; function setReportLifetime(uint256 _lifetime) external; function secondReport(uint256 _reportId, address _account) external; function reporterClaim(uint256 _reportId) external; function retrieveCompensation(address _adr, uint256 _amount) external; event ReportSubmission(ILERC20 indexed _token, address indexed _account, uint256 indexed _reportId, uint256 _amount); event SecondReportSubmission(ILERC20 indexed _token, address indexed _account, uint256 indexed _reportId); event NewReportingAmount(uint256 indexed _newAmount); event NewStakingToken(ILERC20 indexed _token); event NewGovernanceContract(ILssGovernance indexed _adr); event NewReporterReward(uint256 indexed _newValue); event NewLosslessReward(uint256 indexed _newValue); event NewStakersReward(uint256 indexed _newValue); event NewCommitteeReward(uint256 indexed _newValue); event NewReportLifetime(uint256 indexed _newValue); event ReporterClaim(address indexed _reporter, uint256 indexed _reportId, uint256 indexed _amount); event CompensationRetrieve(address indexed _adr, uint256 indexed _amount); }pragma solidity ^0.8.0; interface ProtectionStrategy { function isTransferAllowed(address token, address sender, address recipient, uint256 amount) external; }// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Address.sol) pragma solidity ^0.8.0; /** * @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 * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 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 functionCall(target, data, "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"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(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) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason 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 { // 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 assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./ILosslessERC20.sol"; import "./ILosslessGovernance.sol"; import "./ILosslessStaking.sol"; import "./ILosslessReporting.sol"; import "./IProtectionStrategy.sol"; interface ILssController { // function getLockedAmount(ILERC20 _token, address _account) returns (uint256); // function getAvailableAmount(ILERC20 _token, address _account) external view returns (uint256 amount); function retrieveBlacklistedFunds(address[] calldata _addresses, ILERC20 _token, uint256 _reportId) external returns(uint256); function whitelist(address _adr) external view returns (bool); function dexList(address _dexAddress) external returns (bool); function blacklist(address _adr) external view returns (bool); function admin() external view returns (address); function pauseAdmin() external view returns (address); function recoveryAdmin() external view returns (address); function guardian() external view returns (address); function losslessStaking() external view returns (ILssStaking); function losslessReporting() external view returns (ILssReporting); function losslessGovernance() external view returns (ILssGovernance); function dexTranferThreshold() external view returns (uint256); function settlementTimeLock() external view returns (uint256); function pause() external; function unpause() external; function setAdmin(address _newAdmin) external; function setRecoveryAdmin(address _newRecoveryAdmin) external; function setPauseAdmin(address _newPauseAdmin) external; function setSettlementTimeLock(uint256 _newTimelock) external; function setDexTransferThreshold(uint256 _newThreshold) external; function setDexList(address[] calldata _dexList, bool _value) external; function setWhitelist(address[] calldata _addrList, bool _value) external; function addToBlacklist(address _adr) external; function resolvedNegatively(address _adr) external; function setStakingContractAddress(ILssStaking _adr) external; function setReportingContractAddress(ILssReporting _adr) external; function setGovernanceContractAddress(ILssGovernance _adr) external; function proposeNewSettlementPeriod(ILERC20 _token, uint256 _seconds) external; function executeNewSettlementPeriod(ILERC20 _token) external; function activateEmergency(ILERC20 _token) external; function deactivateEmergency(ILERC20 _token) external; function setGuardian(address _newGuardian) external; function removeProtectedAddress(ILERC20 _token, address _protectedAddresss) external; function beforeTransfer(address _sender, address _recipient, uint256 _amount) external; function beforeTransferFrom(address _msgSender, address _sender, address _recipient, uint256 _amount) external; function beforeApprove(address _sender, address _spender, uint256 _amount) external; function beforeIncreaseAllowance(address _msgSender, address _spender, uint256 _addedValue) external; function beforeDecreaseAllowance(address _msgSender, address _spender, uint256 _subtractedValue) external; function beforeMint(address _to, uint256 _amount) external; function beforeBurn(address _account, uint256 _amount) external; function setProtectedAddress(ILERC20 _token, address _protectedAddress, ProtectionStrategy _strategy) external; event AdminChange(address indexed _newAdmin); event RecoveryAdminChange(address indexed _newAdmin); event PauseAdminChange(address indexed _newAdmin); event GuardianSet(address indexed _oldGuardian, address indexed _newGuardian); event NewProtectedAddress(ILERC20 indexed _token, address indexed _protectedAddress, address indexed _strategy); event RemovedProtectedAddress(ILERC20 indexed _token, address indexed _protectedAddress); event NewSettlementPeriodProposal(ILERC20 indexed _token, uint256 _seconds); event SettlementPeriodChange(ILERC20 indexed _token, uint256 _proposedTokenLockTimeframe); event NewSettlementTimelock(uint256 indexed _timelock); event NewDexThreshold(uint256 indexed _newThreshold); event NewDex(address indexed _dexAddress); event DexRemoval(address indexed _dexAddress); event NewWhitelistedAddress(address indexed _whitelistAdr); event WhitelistedAddressRemoval(address indexed _whitelistAdr); event NewBlacklistedAddress(address indexed _blacklistedAddres); event AccountBlacklistRemoval(address indexed _adr); event NewStakingContract(ILssStaking indexed _newAdr); event NewReportingContract(ILssReporting indexed _newAdr); event NewGovernanceContract(ILssGovernance indexed _newAdr); event EmergencyActive(ILERC20 indexed _token); event EmergencyDeactivation(ILERC20 indexed _token); }