Verified contractExactBUSL-1.1
WorldLibertyFinancialRegistry
Address0x69bb029b64e71cde7cf6feebfe68323f2d4d0e02
- Balance
0 ETH
- Transactions
0
- Compiler
solc 0.8.24
- Same code
Only this contract
Details
- Compiler
- solc 0.8.24+commit.e11b9ed9
- Language
- solidity
- Optimization
- Yes, 200 runs
- EVM version
- paris
- License
- BUSL-1.1
- Match
- Exactcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 25,043,335
- Creation transaction
- 0x752238a8f4…a53cdb3bad
9 files
- contracts/wlfi/WorldLibertyFinancialRegistry.solmain8.92 KB
- @openzeppelin/contracts/access/Ownable.sol2.62 KB
- @openzeppelin/contracts/token/ERC20/IERC20.sol2.74 KB
- @openzeppelin/contracts/utils/Context.sol962 B
- contracts/WhitelistAgent.sol3.88 KB
- contracts/WorldLibertyOwnable.sol1.97 KB
- contracts/interfaces/IWLFI.sol382 B
- contracts/libraries/oz-v5/upgradeable/proxy/utils/Initializable.sol8.91 KB
- contracts/wlfi/interfaces/IWorldLibertyFinancialRegistry.sol6.87 KB
contracts/wlfi/WorldLibertyFinancialRegistry.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.24;
import {Initializable} from "../libraries/oz-v5/upgradeable/proxy/utils/Initializable.sol";
import {IWorldLibertyFinancialRegistry} from "./interfaces/IWorldLibertyFinancialRegistry.sol";
import {WhitelistAgent} from "../WhitelistAgent.sol";
contract WorldLibertyFinancialRegistry is IWorldLibertyFinancialRegistry, WhitelistAgent, Initializable {
// ==================================================
// =================== Constants ====================
// ==================================================
bytes32 private constant RegistryStorageLocation = keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Registry")) - 1)) & ~bytes32(uint256(0xff));
address private constant InitialWhitelistAgent = 0x51C83B1e82f2d98D77A8694a2A8b553F6eDa1125;
// ===================================================
// ===================== Modifiers ===================
// ===================================================
modifier onlyWLFI(address _sender) {
_checkOnlyWLFI(_sender);
_;
}
// ==================================================
// ================== Initializers ==================
// ==================================================
constructor() {
_disableInitializers();
}
function initialize() external initializer {
_ownerSetUserWhitelist(InitialWhitelistAgent, true);
}
// ===================================================
// =============== External Functions ================
// ===================================================
function wlfiActivateAccount(address _user) external onlyWLFI(msg.sender) {
_activateAccount(_user);
}
function wlfiBurnAllocation(address _user, uint256 _amount) external onlyWLFI(msg.sender) {
RegistryStorage storage $ = _getStorage();
LegacyUser storage userInfo = $.legacyUserMap[_user];
if (userInfo.amount == 0) {
revert InvalidUser(_user);
}
uint112 newAmount = userInfo.amount - uint112(_amount); // safe cast
if (newAmount == 0) {
delete $.legacyUserMap[_user];
emit LegacyUserRemoved(_user);
} else {
userInfo.amount = newAmount; // safe cast
emit LegacyUserUpdated(_user, userInfo.amount, userInfo.category, userInfo.isActivated);
}
}
function wlfiReallocateFrom(address _from, address _to) external onlyWLFI(msg.sender) {
if (_from == address(0)) {
revert InvalidUser(_from);
}
if (_to == address(0)) {
revert InvalidUser(_to);
}
if (!isLegacyUser(_from)) {
revert InvalidUser(_from);
}
if (isLegacyUser(_to)) {
revert InvalidUser(_to);
}
RegistryStorage storage $ = _getStorage();
LegacyUser memory userInfo = $.legacyUserMap[_from];
$.legacyUserMap[_to] = userInfo;
delete $.legacyUserMap[_from];
emit LegacyUserTransferred(_from, _to);
}
function wlfiSetCategory(address _user, uint8 _category) external onlyWLFI(msg.sender) {
RegistryStorage storage $ = _getStorage();
LegacyUser storage userInfo = $.legacyUserMap[_user];
userInfo.category = _category;
emit LegacyUserUpdated(_user, userInfo.amount, _category, userInfo.isActivated);
}
function agentBulkInsertLegacyUsers(
uint256 _expectedNonce,
address[] calldata _users,
uint256[] calldata _amounts,
uint8[] calldata _categories
) external onlyWorldLibertyOwnerOrWhitelist(msg.sender) {
if (_users.length == 0 || _users.length != _amounts.length || _amounts.length != _categories.length) {
revert InvalidBulkInsertLegacyUsersParams();
}
RegistryStorage storage $ = _getStorage();
if (_expectedNonce != $.nonce) {
revert InvalidNonce();
}
for (uint256 i; i < _users.length; ++i) {
if (_users[i] == address(0) || _amounts[i] == 0) {
revert InvalidBulkInsertLegacyUserAtIndex(i);
}
if (_categories[i] == 45 || _categories[i] == 47) {
// These are terminal categories and must be moved into via election
revert InvalidBulkInsertLegacyUserAtIndex(i);
}
if ($.legacyUserMap[_users[i]].amount != 0) {
revert InvalidBulkInsertLegacyUserAtIndex(i);
}
if (WLFI.balanceOf(_users[i]) != _amounts[i]) {
revert InvalidBulkInsertLegacyUserBalance(_users[i]);
}
$.legacyUserMap[_users[i]] = LegacyUser({
amount: uint112(_amounts[i]), // safe cast. There is never more than max uint112 ever assigned for WLFI
category: _categories[i],
isActivated: false
});
emit LegacyUserUpdated(_users[i], _amounts[i], _categories[i], false);
}
$.nonce = _expectedNonce + 1;
emit NonceUpdated(_expectedNonce + 1);
}
function agentBulkRemoveLegacyUsers(
address[] calldata _users
) external onlyWorldLibertyOwnerOrWhitelist(msg.sender) {
if (_users.length == 0) {
revert InvalidBulkInsertLegacyUsersParams();
}
RegistryStorage storage $ = _getStorage();
for (uint256 i; i < _users.length; ++i) {
if (_users[i] == address(0)) {
revert InvalidBulkInsertLegacyUserAtIndex(i);
}
if (!isLegacyUser(_users[i])) {
revert InvalidUser(_users[i]);
}
delete $.legacyUserMap[_users[i]];
emit LegacyUserRemoved(_users[i]);
}
}
// ===================================================
// ================= Public Functions ================
// ===================================================
function nonce() external view returns (uint256) {
return _getStorage().nonce;
}
function isLegacyUserAndIsActivated(address _user) external view returns (bool) {
if (_user == address(0)) {
return false;
}
LegacyUser storage userInfo = _getStorage().legacyUserMap[_user];
return userInfo.amount != 0 && userInfo.isActivated;
}
function isLegacyUserAndIsNotActivated(address _user) external view returns (bool) {
if (_user == address(0)) {
return false;
}
LegacyUser storage userInfo = _getStorage().legacyUserMap[_user];
return userInfo.amount != 0 && !userInfo.isActivated;
}
function getLegacyUserInfo(address _user) external view returns (LegacyUser memory) {
return _validateUserAndReturn(_user);
}
function getLegacyUserCategory(address _user) external view returns (uint8) {
return _validateUserAndReturn(_user).category;
}
function getLegacyUserAllocation(address _user) external view returns (uint112) {
return _validateUserAndReturn(_user).amount;
}
function isLegacyUser(address _user) public view returns (bool) {
if (_user == address(0)) {
return false;
}
return _getStorage().legacyUserMap[_user].amount != 0;
}
// ===================================================
// ================ Internal Functions ===============
// ===================================================
function _activateAccount(address _user) internal {
LegacyUser storage userInfo = _getStorage().legacyUserMap[_user];
uint256 actualAmount = userInfo.amount;
if (actualAmount == 0) {
revert InvalidUser(_user);
}
if (userInfo.isActivated) {
revert AlreadyInitialized(_user);
}
userInfo.isActivated = true;
emit LegacyUserUpdated(_user, actualAmount, userInfo.category, true);
}
function _checkOnlyWLFI(address _sender) internal pure {
if (_sender != address(WLFI)) {
revert Unauthorized();
}
}
function _validateUserAndReturn(address _user) internal view returns (LegacyUser memory) {
if (_user == address(0)) {
revert InvalidUser(_user);
}
LegacyUser memory legacyUser = _getStorage().legacyUserMap[_user];
if (legacyUser.amount == 0) {
revert InvalidUser(_user);
}
return legacyUser;
}
// ===================================================
// ================ Private Functions ================
// ===================================================
function _getStorage() private pure returns (RegistryStorage storage $) {
bytes32 location = RegistryStorageLocation;
assembly {
$.slot := location
}
}
}
@openzeppelin/contracts/access/Ownable.sol
// 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);
}
}
@openzeppelin/contracts/token/ERC20/IERC20.sol
// 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);
}
@openzeppelin/contracts/utils/Context.sol
// 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;
}
}
contracts/WhitelistAgent.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import {WorldLibertyOwnable} from "./WorldLibertyOwnable.sol";
abstract contract WhitelistAgent is WorldLibertyOwnable {
// ==================================================
// ==================== Structs =====================
// ==================================================
struct WhitelistAgentStorage {
mapping (address => bool) whitelistStatus;
}
// ==================================================
// =================== Constants ====================
// ==================================================
bytes32 private constant _WHITELIST_AGENT_STORAGE_LOCATION =
keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.WhitelistAgent")) - 1)) & ~bytes32(uint256(0xff)); // solhint-disable-line max-line-length
// ==================================================
// ===================== Events =====================
// ==================================================
event SetWhitelistStatus(address indexed _user, bool _isEnabled);
// ==================================================
// ===================== Errors =====================
// ==================================================
error NotWhitelisted(address _user);
// ==================================================
// =================== Modifiers ====================
// ==================================================
modifier onlyWorldLibertyOwnerOrWhitelist(address _user) {
_checkIsOwnerOrWhitelist(_user);
_;
}
// ==================================================
// =============== External Functions ===============
// ==================================================
/**
* @notice Sets a user's whitelist status for transferring while this contract is disabled. Can only be invoked
* once by `owner()`.
*
* @param _user The address whose whitelist status will change
* @param _isWhitelisted True if the `_user` is whitelisted or false if not.
*/
function ownerSetWhitelistStatus(
address _user,
bool _isWhitelisted
) external onlyWorldLibertyOwner(msg.sender) {
_ownerSetUserWhitelist(_user, _isWhitelisted);
}
// ==================================================
// ================ Public Functions ================
// ==================================================
/**
* @notice Checks if the provider `_user` can perform a whitelisted action.
*
* @param _user The user whose initial whitelist status should be checked
*/
function getWhitelistStatus(address _user) public view returns (bool) {
return _getWhitelistAgentStorage().whitelistStatus[_user];
}
// ==================================================
// =============== Internal Functions ===============
// ==================================================
function _ownerSetUserWhitelist(address _user, bool _isWhitelisted) internal {
_getWhitelistAgentStorage().whitelistStatus[_user] = _isWhitelisted;
emit SetWhitelistStatus(_user, _isWhitelisted);
}
function _checkIsOwnerOrWhitelist(address _user) internal view {
if (_user != owner() && !getWhitelistStatus(_user)) {
revert NotWhitelisted(_user);
}
}
// ==================================================
// ================ Private Functions ===============
// ==================================================
function _getWhitelistAgentStorage() private pure returns (WhitelistAgentStorage storage $) {
bytes32 location = _WHITELIST_AGENT_STORAGE_LOCATION;
//solhint-disable-next-line no-inline-assembly
assembly {
$.slot := location
}
}
}
contracts/WorldLibertyOwnable.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import {IWLFI} from "./interfaces/IWLFI.sol";
abstract contract WorldLibertyOwnable {
// ==================================================
// ===================== Fields =====================
// ==================================================
IWLFI public constant WLFI = IWLFI(0xdA5e1988097297dCdc1f90D4dFE7909e847CBeF6);
// ==================================================
// ===================== Errors =====================
// ==================================================
error OwnableUnauthorizedAccount(address _account);
error GuardianUnauthorizedAccount(address _account);
// ==================================================
// =================== Modifiers ====================
// ==================================================
modifier onlyWorldLibertyGuardian(address _sender) {
_checkGuardian(_sender);
_;
}
modifier onlyWorldLibertyOwner(address _sender) {
_checkOwner(_sender);
_;
}
// ==================================================
// ================ Public Functions ================
// ==================================================
constructor() {
// WLFI is only available on Ethereum
assert(block.chainid == 1);
}
function owner() public view returns (address) {
return WLFI.owner();
}
// ==================================================
// =============== Internal Functions ===============
// ==================================================
function _checkGuardian(address _sender) internal view {
if (!WLFI.isGuardian(_sender)) {
revert GuardianUnauthorizedAccount(_sender);
}
}
function _checkOwner(address _sender) internal view {
if (_sender != owner()) {
revert OwnableUnauthorizedAccount(_sender);
}
}
}
contracts/interfaces/IWLFI.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
abstract contract IWLFI is IERC20, Ownable {
function burn(uint256 _amount) external virtual;
function isGuardian(address _account) external virtual view returns (bool);
}
contracts/libraries/oz-v5/upgradeable/proxy/utils/Initializable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/Initializable.sol)
pragma solidity ^0.8.20;
/**
* @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
* behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
* external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
* function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
*
* The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
* reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
* case an upgrade adds a module that needs to be initialized.
*
* For example:
*
* [.hljs-theme-light.nopadding]
* ```solidity
* contract MyToken is ERC20Upgradeable {
* function initialize() initializer public {
* __ERC20_init("MyToken", "MTK");
* }
* }
*
* contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
* function initializeV2() reinitializer(2) public {
* __ERC20Permit_init("MyToken");
* }
* }
* ```
*
* TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
* possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
*
* CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
* that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
*
* [CAUTION]
* ====
* Avoid leaving a contract uninitialized.
*
* An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
* contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
* the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
*
* [.hljs-theme-light.nopadding]
* ```
* /// @custom:oz-upgrades-unsafe-allow constructor
* constructor() {
* _disableInitializers();
* }
* ```
* ====
*/
abstract contract Initializable {
/**
* @dev Storage of the initializable contract.
*
* It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions
* when using with upgradeable contracts.
*
* @custom:storage-location erc7201:openzeppelin.storage.Initializable
*/
struct InitializableStorage {
/**
* @dev Indicates that the contract has been initialized.
*/
uint64 _initialized;
/**
* @dev Indicates that the contract is in the process of being initialized.
*/
bool _initializing;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Initializable")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00;
/**
* @dev The contract is already initialized.
*/
error InvalidInitialization();
/**
* @dev The contract is not initializing.
*/
error NotInitializing();
/**
* @dev Triggered when the contract has been initialized or reinitialized.
*/
event Initialized(uint64 version);
/**
* @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
* `onlyInitializing` functions can be used to initialize parent contracts.
*
* Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any
* number of times. This behavior in the constructor can be useful during testing and is not expected to be used in
* production.
*
* Emits an {Initialized} event.
*/
modifier initializer() {
// solhint-disable-next-line var-name-mixedcase
InitializableStorage storage $ = _getInitializableStorage();
// Cache values to avoid duplicated sloads
bool isTopLevelCall = !$._initializing;
uint64 initialized = $._initialized;
// Allowed calls:
// - initialSetup: the contract is not in the initializing state and no previous version was
// initialized
// - construction: the contract is initialized at version 1 (no reininitialization) and the
// current contract is just being deployed
bool initialSetup = initialized == 0 && isTopLevelCall;
bool construction = initialized == 1 && address(this).code.length == 0;
if (!initialSetup && !construction) {
revert InvalidInitialization();
}
$._initialized = 1;
if (isTopLevelCall) {
$._initializing = true;
}
_;
if (isTopLevelCall) {
$._initializing = false;
emit Initialized(1);
}
}
/**
* @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
* contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
* used to initialize parent contracts.
*
* A reinitializer may be used after the original initialization step. This is essential to configure modules that
* are added through upgrades and that require initialization.
*
* When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
* cannot be nested. If one is invoked in the context of another, execution will revert.
*
* Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
* a contract, executing them in the right order is up to the developer or operator.
*
* WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization.
*
* Emits an {Initialized} event.
*/
modifier reinitializer(uint64 version) {
// solhint-disable-next-line var-name-mixedcase
InitializableStorage storage $ = _getInitializableStorage();
if ($._initializing || $._initialized >= version) {
revert InvalidInitialization();
}
$._initialized = version;
$._initializing = true;
_;
$._initializing = false;
emit Initialized(version);
}
/**
* @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
* {initializer} and {reinitializer} modifiers, directly or indirectly.
*/
modifier onlyInitializing() {
_checkInitializing();
_;
}
/**
* @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}.
*/
function _checkInitializing() internal view virtual {
if (!_isInitializing()) {
revert NotInitializing();
}
}
/**
* @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
* Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
* to any version. It is recommended to use this to lock implementation contracts that are designed to be called
* through proxies.
*
* Emits an {Initialized} event the first time it is successfully executed.
*/
function _disableInitializers() internal virtual {
// solhint-disable-next-line var-name-mixedcase
InitializableStorage storage $ = _getInitializableStorage();
if ($._initializing) {
revert InvalidInitialization();
}
if ($._initialized != type(uint64).max) {
$._initialized = type(uint64).max;
emit Initialized(type(uint64).max);
}
}
/**
* @dev Returns the highest version that has been initialized. See {reinitializer}.
*/
function _getInitializedVersion() internal view returns (uint64) {
return _getInitializableStorage()._initialized;
}
/**
* @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.
*/
function _isInitializing() internal view returns (bool) {
return _getInitializableStorage()._initializing;
}
/**
* @dev Returns a pointer to the storage namespace.
*/
// solhint-disable-next-line var-name-mixedcase
function _getInitializableStorage() private pure returns (InitializableStorage storage $) {
assembly {
$.slot := INITIALIZABLE_STORAGE
}
}
}
contracts/wlfi/interfaces/IWorldLibertyFinancialRegistry.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.24;
interface IWorldLibertyFinancialRegistry {
// ==================================================
// ==================== Structs =====================
// ==================================================
/// @dev The entirety of this struct should compact down into one storage slot
struct LegacyUser {
/// @dev This is data type is big enough to fit the whole WLFI supply
uint112 amount;
/// @dev Incremental categories, where 0 represents NONE and should be considered unset
uint8 category;
/// @dev True if the user has "activated" their account by transferring their funds into the vester
bool isActivated;
}
struct RegistryStorage {
uint256 nonce;
mapping(address => LegacyUser) legacyUserMap;
}
// ==================================================
// ===================== Events =====================
// ==================================================
event NonceUpdated(uint256 nonce);
event LegacyUserUpdated(address indexed user, uint256 amount, uint8 category, bool isActivated);
event LegacyUserRemoved(address indexed user);
event LegacyUserTransferred(address indexed from, address indexed to);
// ==================================================
// ===================== Errors =====================
// ==================================================
error AlreadyInitialized(address user);
error AlreadyLegacyUser(address user);
error InvalidBulkInsertLegacyUserAtIndex(uint256 index);
error InvalidBulkInsertLegacyUserBalance(address user);
error InvalidBulkInsertLegacyUsersParams();
error InvalidNonce();
error InvalidUser(address user);
error Unauthorized();
// ==================================================
// ================== Initializers ==================
// ==================================================
function initialize() external;
// ===================================================
// =============== External Functions ================
// ===================================================
/**
* @notice Allows the WLFI token to activate a legacy user. This is the typical flow most Legacy Users will follow
* to initialize their vesting account.
*
* @param _user The address of the user whose account will be activated
*/
function wlfiActivateAccount(address _user) external;
/**
* @notice Allows the WLFI token to reduce a user's allocation of locked tokens. Emits `LegacyUserUpdated`
*
* @param _user The address of the user whose allocation will be reduced
* @param _amount The amount to reduce the allocation by
*/
function wlfiBurnAllocation(address _user, uint256 _amount) external;
/**
* @notice Transfers the registration of `_from` account to the `_to` account. Reverts if `_to` is already
* registered. `_to` account must be a fresh wallet. Reverts if `_from` is not a legacy user
*
* @param _from The from account whose registration is being transferred.
* @param _to The to account whose registration is being received by `_from`.
*/
function wlfiReallocateFrom(address _from, address _to) external;
/**
* @notice Allows the WLFI token to change a user's vesting category. Emits `LegacyUserUpdated`
*
* @param _user The user whose vesting category should change
* @param _category The user's new vesting category
*/
function wlfiSetCategory(address _user, uint8 _category) external;
/**
* @notice Allows the whitelist agent or owner to add Legacy Users to this registry. Each user is assigned an
* amount of WLFI they have and a category. Categories are useful for partitioning users (between founders,
* public sale recipient, OTC sale recipient, etc.). The lengths of these arrays must match and be > 0.
*
* @param _expectedNonce The nonce that is expected be set in storage at the time of this call. Used for
* coordination with the offchain script.
* @param _users The Legacy Users that will be added to the registry
* @param _amounts The amount of WLFI that each Legacy User has. Must be equal to the Legacy User's balance
* @param _categories The category in which each Legacy User resides
*/
function agentBulkInsertLegacyUsers(
uint256 _expectedNonce,
address[] calldata _users,
uint256[] calldata _amounts,
uint8[] calldata _categories
) external;
/**
* @notice Allows the whitelist agent or owner to remove Legacy Users from this registry. The length of this array
* must be > 0.
*
* @param _users The Legacy Users that will be removed from the registry
*/
function agentBulkRemoveLegacyUsers(
address[] calldata _users
) external;
/**
*
* @return The nonce of the latest insertion from calling {agentBulkInsertLegacyUsers}
*/
function nonce() external view returns (uint256);
/**
*
* @param _user The user to check if they are considered a Legacy User or not
* @return True if the user is considered a Legacy User or false otherwise
*/
function isLegacyUser(address _user) external view returns (bool);
/**
*
* @param _user The user to check if they are considered a Legacy User and if their status is activated yet
* @return True if the user is considered a Legacy User and they have been activated or false otherwise
*/
function isLegacyUserAndIsActivated(address _user) external view returns (bool);
/**
*
* @param _user The user to check if they are considered a Legacy User and if their status is not activated yet
* @return True if the user is considered a Legacy User and they have not been activated yet. False otherwise
*/
function isLegacyUserAndIsNotActivated(address _user) external view returns (bool);
/**
*
* @param _user The user whose Legacy User info should be retrieved
* @return The user's Legacy User info
*/
function getLegacyUserInfo(address _user) external view returns (LegacyUser memory);
/**
*
* @param _user The user whose category should be retrieved
* @return The user's assigned category
*/
function getLegacyUserCategory(address _user) external view returns (uint8);
/**
*
* @param _user The user whose allocation should be retrieved
* @return The user's assigned WLFI allocation
*/
function getLegacyUserAllocation(address _user) external view returns (uint112);
}
Compiler settingsShow
{
"optimizer": {
"runs": 200,
"details": {
"yul": false
},
"enabled": true
},
"evmVersion": "paris"
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.