Contract
0xca68e6be9cfd49c7c48c112ed8cffcd708d90069
1
Contract Overview
Balance:
0 MATIC
My Name Tag:
Not Available
Txn Hash |
Method
|
Block
|
From
|
To
|
Value | [Txn Fee] | |||
---|---|---|---|---|---|---|---|---|---|
0xf24338e9ead216fe838649335283d8f8c0513a51cd59353689fa65a1977b4d9d | 0x60a06040 | 30803782 | 147 days 8 mins ago | 0x7a34b2f0da5ea35b5117cac735e99ba0e2aceecd | IN | Create: BufferManager | 0 MATIC | 0.005297787056 |
[ Download CSV Export ]
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.
Contract Name:
BufferManager
Compiler Version
v0.8.11+commit.d7f03943
Optimization Enabled:
Yes with 0 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (access/AccessControl.sol) pragma solidity ^0.8.0; import "./IAccessControlUpgradeable.sol"; import "../utils/ContextUpgradeable.sol"; import "../utils/StringsUpgradeable.sol"; import "../utils/introspection/ERC165Upgradeable.sol"; import "../proxy/utils/Initializable.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: * * ``` * 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}: * * ``` * 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. */ abstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControlUpgradeable, ERC165Upgradeable { function __AccessControl_init() internal onlyInitializing { } function __AccessControl_init_unchained() internal onlyInitializing { } 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(IAccessControlUpgradeable).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 ", StringsUpgradeable.toHexString(uint160(account), 20), " is missing role ", StringsUpgradeable.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. */ 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. */ 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`. */ 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. * * [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. */ 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. */ function _revokeRole(bytes32 role, address account) internal virtual { if (hasRole(role, account)) { _roles[role].members[account] = false; emit RoleRevoked(role, account, _msgSender()); } } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol) pragma solidity ^0.8.0; /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControlUpgradeable { /** * @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.5.0) (interfaces/draft-IERC1822.sol) pragma solidity ^0.8.0; /** * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified * proxy whose upgrades are fully controlled by the current implementation. */ interface IERC1822ProxiableUpgradeable { /** * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation * address. * * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this * function revert if invoked through a proxy. */ function proxiableUUID() external view returns (bytes32); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (interfaces/IERC20Metadata.sol) pragma solidity ^0.8.0; import "../token/ERC20/extensions/IERC20MetadataUpgradeable.sol";
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol) pragma solidity ^0.8.0; /** * @dev This is the interface that {BeaconProxy} expects of its beacon. */ interface IBeaconUpgradeable { /** * @dev Must return an address that can be used as a delegate call target. * * {BeaconProxy} will check that this address is a contract. */ function implementation() external view returns (address); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol) pragma solidity ^0.8.2; import "../beacon/IBeaconUpgradeable.sol"; import "../../interfaces/draft-IERC1822Upgradeable.sol"; import "../../utils/AddressUpgradeable.sol"; import "../../utils/StorageSlotUpgradeable.sol"; import "../utils/Initializable.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 ERC1967UpgradeUpgradeable is Initializable { function __ERC1967Upgrade_init() internal onlyInitializing { } function __ERC1967Upgrade_init_unchained() internal onlyInitializing { } // 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 StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value; } /** * @dev Stores a new address in the EIP1967 implementation slot. */ function _setImplementation(address newImplementation) private { require(AddressUpgradeable.isContract(newImplementation), "ERC1967: new implementation is not a contract"); StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; } /** * @dev Perform implementation upgrade * * Emits an {Upgraded} event. */ function _upgradeTo(address newImplementation) internal { _setImplementation(newImplementation); emit Upgraded(newImplementation); } /** * @dev Perform implementation upgrade with additional setup call. * * Emits an {Upgraded} event. */ function _upgradeToAndCall( address newImplementation, bytes memory data, bool forceCall ) internal { _upgradeTo(newImplementation); if (data.length > 0 || forceCall) { _functionDelegateCall(newImplementation, data); } } /** * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call. * * Emits an {Upgraded} event. */ function _upgradeToAndCallUUPS( address newImplementation, bytes memory data, bool forceCall ) internal { // Upgrades from old implementations will perform a rollback test. This test requires the new // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing // this special case will break upgrade paths from old UUPS implementation to new ones. if (StorageSlotUpgradeable.getBooleanSlot(_ROLLBACK_SLOT).value) { _setImplementation(newImplementation); } else { try IERC1822ProxiableUpgradeable(newImplementation).proxiableUUID() returns (bytes32 slot) { require(slot == _IMPLEMENTATION_SLOT, "ERC1967Upgrade: unsupported proxiableUUID"); } catch { revert("ERC1967Upgrade: new implementation is not UUPS"); } _upgradeToAndCall(newImplementation, data, forceCall); } } /** * @dev Storage slot with the admin of the contract. * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103; /** * @dev Emitted when the admin account has changed. */ event AdminChanged(address previousAdmin, address newAdmin); /** * @dev Returns the current admin. */ function _getAdmin() internal view returns (address) { return StorageSlotUpgradeable.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"); StorageSlotUpgradeable.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 StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value; } /** * @dev Stores a new beacon in the EIP1967 beacon slot. */ function _setBeacon(address newBeacon) private { require(AddressUpgradeable.isContract(newBeacon), "ERC1967: new beacon is not a contract"); require( AddressUpgradeable.isContract(IBeaconUpgradeable(newBeacon).implementation()), "ERC1967: beacon implementation is not a contract" ); StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value = newBeacon; } /** * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that). * * Emits a {BeaconUpgraded} event. */ function _upgradeBeaconToAndCall( address newBeacon, bytes memory data, bool forceCall ) internal { _setBeacon(newBeacon); emit BeaconUpgraded(newBeacon); if (data.length > 0 || forceCall) { _functionDelegateCall(IBeaconUpgradeable(newBeacon).implementation(), data); } } /** * @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) private returns (bytes memory) { require(AddressUpgradeable.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 AddressUpgradeable.verifyCallResult(success, returndata, "Address: low-level delegate call failed"); } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (proxy/utils/Initializable.sol) pragma solidity ^0.8.2; import "../../utils/AddressUpgradeable.sol"; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in * case an upgrade adds a module that needs to be initialized. * * For example: * * [.hljs-theme-light.nopadding] * ``` * contract MyToken is ERC20Upgradeable { * function initialize() initializer public { * __ERC20_init("MyToken", "MTK"); * } * } * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable { * function initializeV2() reinitializer(2) public { * __ERC20Permit_init("MyToken"); * } * } * ``` * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. * * [CAUTION] * ==== * Avoid leaving a contract uninitialized. * * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed: * * [.hljs-theme-light.nopadding] * ``` * /// @custom:oz-upgrades-unsafe-allow constructor * constructor() { * _disableInitializers(); * } * ``` * ==== */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. * @custom:oz-retyped-from bool */ uint8 private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Triggered when the contract has been initialized or reinitialized. */ event Initialized(uint8 version); /** * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope, * `onlyInitializing` functions can be used to initialize parent contracts. Equivalent to `reinitializer(1)`. */ modifier initializer() { bool isTopLevelCall = _setInitializedVersion(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. * * `initializer` is equivalent to `reinitializer(1)`, so 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. * * 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. */ modifier reinitializer(uint8 version) { bool isTopLevelCall = _setInitializedVersion(version); if (isTopLevelCall) { _initializing = true; } _; if (isTopLevelCall) { _initializing = false; emit Initialized(version); } } /** * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the * {initializer} and {reinitializer} modifiers, directly or indirectly. */ modifier onlyInitializing() { require(_initializing, "Initializable: contract is not initializing"); _; } /** * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call. * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized * to any version. It is recommended to use this to lock implementation contracts that are designed to be called * through proxies. */ function _disableInitializers() internal virtual { _setInitializedVersion(type(uint8).max); } function _setInitializedVersion(uint8 version) private returns (bool) { // 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, and for the lowest level // of initializers, because in other contexts the contract may have been reentered. if (_initializing) { require( version == 1 && !AddressUpgradeable.isContract(address(this)), "Initializable: contract is already initialized" ); return false; } else { require(_initialized < version, "Initializable: contract is already initialized"); _initialized = version; return true; } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (proxy/utils/UUPSUpgradeable.sol) pragma solidity ^0.8.0; import "../../interfaces/draft-IERC1822Upgradeable.sol"; import "../ERC1967/ERC1967UpgradeUpgradeable.sol"; import "./Initializable.sol"; /** * @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an * {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy. * * A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is * reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing * `UUPSUpgradeable` with a custom implementation of upgrades. * * The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism. * * _Available since v4.1._ */ abstract contract UUPSUpgradeable is Initializable, IERC1822ProxiableUpgradeable, ERC1967UpgradeUpgradeable { function __UUPSUpgradeable_init() internal onlyInitializing { } function __UUPSUpgradeable_init_unchained() internal onlyInitializing { } /// @custom:oz-upgrades-unsafe-allow state-variable-immutable state-variable-assignment address private immutable __self = address(this); /** * @dev Check that the execution is being performed through a delegatecall call and that the execution context is * a proxy contract with an implementation (as defined in ERC1967) pointing to self. This should only be the case * for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a * function through ERC1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to * fail. */ modifier onlyProxy() { require(address(this) != __self, "Function must be called through delegatecall"); require(_getImplementation() == __self, "Function must be called through active proxy"); _; } /** * @dev Check that the execution is not being performed through a delegate call. This allows a function to be * callable on the implementing contract but not through proxies. */ modifier notDelegated() { require(address(this) == __self, "UUPSUpgradeable: must not be called through delegatecall"); _; } /** * @dev Implementation of the ERC1822 {proxiableUUID} function. This returns the storage slot used by the * implementation. It is used to validate that the this implementation remains valid after an upgrade. * * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this * function revert if invoked through a proxy. This is guaranteed by the `notDelegated` modifier. */ function proxiableUUID() external view virtual override notDelegated returns (bytes32) { return _IMPLEMENTATION_SLOT; } /** * @dev Upgrade the implementation of the proxy to `newImplementation`. * * Calls {_authorizeUpgrade}. * * Emits an {Upgraded} event. */ function upgradeTo(address newImplementation) external virtual onlyProxy { _authorizeUpgrade(newImplementation); _upgradeToAndCallUUPS(newImplementation, new bytes(0), false); } /** * @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call * encoded in `data`. * * Calls {_authorizeUpgrade}. * * Emits an {Upgraded} event. */ function upgradeToAndCall(address newImplementation, bytes memory data) external payable virtual onlyProxy { _authorizeUpgrade(newImplementation); _upgradeToAndCallUUPS(newImplementation, data, true); } /** * @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by * {upgradeTo} and {upgradeToAndCall}. * * Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}. * * ```solidity * function _authorizeUpgrade(address) internal override onlyOwner {} * ``` */ function _authorizeUpgrade(address newImplementation) internal virtual; /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts 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 { __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()); } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol) pragma solidity ^0.8.0; import "../IERC20Upgradeable.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20MetadataUpgradeable is IERC20Upgradeable { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20Upgradeable { /** * @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 v4.4.1 (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.0; import "../IERC20Upgradeable.sol"; import "../../../utils/AddressUpgradeable.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20Upgradeable { using AddressUpgradeable for address; function safeTransfer( IERC20Upgradeable token, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom( IERC20Upgradeable token, address from, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove( IERC20Upgradeable token, address spender, uint256 value ) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance( IERC20Upgradeable token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance( IERC20Upgradeable token, address spender, uint256 value ) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); uint256 newAllowance = oldAllowance - value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20Upgradeable token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library AddressUpgradeable { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return 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 // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; import "../proxy/utils/Initializable.sol"; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract ContextUpgradeable is Initializable { function __Context_init() internal onlyInitializing { } function __Context_init_unchained() internal onlyInitializing { } function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165Upgradeable.sol"; import "../../proxy/utils/Initializable.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 ERC165Upgradeable is Initializable, IERC165Upgradeable { function __ERC165_init() internal onlyInitializing { } function __ERC165_init_unchained() internal onlyInitializing { } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165Upgradeable).interfaceId; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts 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 IERC165Upgradeable { /** * @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 v4.4.1 (utils/StorageSlot.sol) pragma solidity ^0.8.0; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC1967 implementation slot: * ``` * contract ERC1967 { * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` * * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._ */ library StorageSlotUpgradeable { 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 // OpenZeppelin Contracts v4.4.1 (utils/Strings.sol) pragma solidity ^0.8.0; /** * @dev String operations. */ library StringsUpgradeable { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @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] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (utils/structs/EnumerableMap.sol) pragma solidity ^0.8.0; import "./EnumerableSetUpgradeable.sol"; /** * @dev Library for managing an enumerable variant of Solidity's * https://solidity.readthedocs.io/en/latest/types.html#mapping-types[`mapping`] * type. * * Maps have the following properties: * * - Entries are added, removed, and checked for existence in constant time * (O(1)). * - Entries are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableMap for EnumerableMap.UintToAddressMap; * * // Declare a set state variable * EnumerableMap.UintToAddressMap private myMap; * } * ``` * * The following map types are supported: * * - `uint256 -> address` (`UintToAddressMap`) since v3.0.0 * - `address -> uint256` (`AddressToUintMap`) since v4.6.0 * - `bytes32 -> bytes32` (`Bytes32ToBytes32`) since v4.6.0 */ library EnumerableMapUpgradeable { using EnumerableSetUpgradeable for EnumerableSetUpgradeable.Bytes32Set; // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Map type with // bytes32 keys and values. // The Map implementation uses private functions, and user-facing // implementations (such as Uint256ToAddressMap) are just wrappers around // the underlying Map. // This means that we can only create new EnumerableMaps for types that fit // in bytes32. struct Bytes32ToBytes32Map { // Storage of keys EnumerableSetUpgradeable.Bytes32Set _keys; mapping(bytes32 => bytes32) _values; } /** * @dev Adds a key-value pair to a map, or updates the value for an existing * key. O(1). * * Returns true if the key was added to the map, that is if it was not * already present. */ function set( Bytes32ToBytes32Map storage map, bytes32 key, bytes32 value ) internal returns (bool) { map._values[key] = value; return map._keys.add(key); } /** * @dev Removes a key-value pair from a map. O(1). * * Returns true if the key was removed from the map, that is if it was present. */ function remove(Bytes32ToBytes32Map storage map, bytes32 key) internal returns (bool) { delete map._values[key]; return map._keys.remove(key); } /** * @dev Returns true if the key is in the map. O(1). */ function contains(Bytes32ToBytes32Map storage map, bytes32 key) internal view returns (bool) { return map._keys.contains(key); } /** * @dev Returns the number of key-value pairs in the map. O(1). */ function length(Bytes32ToBytes32Map storage map) internal view returns (uint256) { return map._keys.length(); } /** * @dev Returns the key-value pair stored at position `index` in the map. O(1). * * Note that there are no guarantees on the ordering of entries inside the * array, and it may change when more entries are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32ToBytes32Map storage map, uint256 index) internal view returns (bytes32, bytes32) { bytes32 key = map._keys.at(index); return (key, map._values[key]); } /** * @dev Tries to returns the value associated with `key`. O(1). * Does not revert if `key` is not in the map. */ function tryGet(Bytes32ToBytes32Map storage map, bytes32 key) internal view returns (bool, bytes32) { bytes32 value = map._values[key]; if (value == bytes32(0)) { return (contains(map, key), bytes32(0)); } else { return (true, value); } } /** * @dev Returns the value associated with `key`. O(1). * * Requirements: * * - `key` must be in the map. */ function get(Bytes32ToBytes32Map storage map, bytes32 key) internal view returns (bytes32) { bytes32 value = map._values[key]; require(value != 0 || contains(map, key), "EnumerableMap: nonexistent key"); return value; } /** * @dev Same as {_get}, with a custom error message when `key` is not in the map. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {_tryGet}. */ function get( Bytes32ToBytes32Map storage map, bytes32 key, string memory errorMessage ) internal view returns (bytes32) { bytes32 value = map._values[key]; require(value != 0 || contains(map, key), errorMessage); return value; } // UintToAddressMap struct UintToAddressMap { Bytes32ToBytes32Map _inner; } /** * @dev Adds a key-value pair to a map, or updates the value for an existing * key. O(1). * * Returns true if the key was added to the map, that is if it was not * already present. */ function set( UintToAddressMap storage map, uint256 key, address value ) internal returns (bool) { return set(map._inner, bytes32(key), bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the key was removed from the map, that is if it was present. */ function remove(UintToAddressMap storage map, uint256 key) internal returns (bool) { return remove(map._inner, bytes32(key)); } /** * @dev Returns true if the key is in the map. O(1). */ function contains(UintToAddressMap storage map, uint256 key) internal view returns (bool) { return contains(map._inner, bytes32(key)); } /** * @dev Returns the number of elements in the map. O(1). */ function length(UintToAddressMap storage map) internal view returns (uint256) { return length(map._inner); } /** * @dev Returns the element stored at position `index` in the set. O(1). * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintToAddressMap storage map, uint256 index) internal view returns (uint256, address) { (bytes32 key, bytes32 value) = at(map._inner, index); return (uint256(key), address(uint160(uint256(value)))); } /** * @dev Tries to returns the value associated with `key`. O(1). * Does not revert if `key` is not in the map. * * _Available since v3.4._ */ function tryGet(UintToAddressMap storage map, uint256 key) internal view returns (bool, address) { (bool success, bytes32 value) = tryGet(map._inner, bytes32(key)); return (success, address(uint160(uint256(value)))); } /** * @dev Returns the value associated with `key`. O(1). * * Requirements: * * - `key` must be in the map. */ function get(UintToAddressMap storage map, uint256 key) internal view returns (address) { return address(uint160(uint256(get(map._inner, bytes32(key))))); } /** * @dev Same as {get}, with a custom error message when `key` is not in the map. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryGet}. */ function get( UintToAddressMap storage map, uint256 key, string memory errorMessage ) internal view returns (address) { return address(uint160(uint256(get(map._inner, bytes32(key), errorMessage)))); } // AddressToUintMap struct AddressToUintMap { Bytes32ToBytes32Map _inner; } /** * @dev Adds a key-value pair to a map, or updates the value for an existing * key. O(1). * * Returns true if the key was added to the map, that is if it was not * already present. */ function set( AddressToUintMap storage map, address key, uint256 value ) internal returns (bool) { return set(map._inner, bytes32(uint256(uint160(key))), bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the key was removed from the map, that is if it was present. */ function remove(AddressToUintMap storage map, address key) internal returns (bool) { return remove(map._inner, bytes32(uint256(uint160(key)))); } /** * @dev Returns true if the key is in the map. O(1). */ function contains(AddressToUintMap storage map, address key) internal view returns (bool) { return contains(map._inner, bytes32(uint256(uint160(key)))); } /** * @dev Returns the number of elements in the map. O(1). */ function length(AddressToUintMap storage map) internal view returns (uint256) { return length(map._inner); } /** * @dev Returns the element stored at position `index` in the set. O(1). * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressToUintMap storage map, uint256 index) internal view returns (address, uint256) { (bytes32 key, bytes32 value) = at(map._inner, index); return (address(uint160(uint256(key))), uint256(value)); } /** * @dev Tries to returns the value associated with `key`. O(1). * Does not revert if `key` is not in the map. * * _Available since v3.4._ */ function tryGet(AddressToUintMap storage map, address key) internal view returns (bool, uint256) { (bool success, bytes32 value) = tryGet(map._inner, bytes32(uint256(uint160(key)))); return (success, uint256(value)); } /** * @dev Returns the value associated with `key`. O(1). * * Requirements: * * - `key` must be in the map. */ function get(AddressToUintMap storage map, address key) internal view returns (uint256) { return uint256(get(map._inner, bytes32(uint256(uint160(key))))); } /** * @dev Same as {get}, with a custom error message when `key` is not in the map. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryGet}. */ function get( AddressToUintMap storage map, address key, string memory errorMessage ) internal view returns (uint256) { return uint256(get(map._inner, bytes32(uint256(uint160(key))), errorMessage)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (utils/structs/EnumerableSet.sol) pragma solidity ^0.8.0; /** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. */ library EnumerableSetUpgradeable { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping(bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; if (lastIndex != toDeleteIndex) { bytes32 lastValue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastValue; // Update the index for the moved value set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex } // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { return set._values[index]; } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function _values(Set storage set) private view returns (bytes32[] memory) { return set._values; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(Bytes32Set storage set) internal view returns (bytes32[] memory) { return _values(set._inner); } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(AddressSet storage set) internal view returns (address[] memory) { bytes32[] memory store = _values(set._inner); address[] memory result; assembly { result := store } return result; } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values on the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(UintSet storage set) internal view returns (uint256[] memory) { bytes32[] memory store = _values(set._inner); uint256[] memory result; assembly { result := store } return result; } }
// 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 pragma solidity ^0.8.11; import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/interfaces/IERC20MetadataUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/structs/EnumerableMapUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/structs/EnumerableSetUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol"; import "../../../interfaces/ILiquidityHandler.sol"; import "../../../interfaces/IHandlerAdapter.sol"; import "../../../interfaces/IVoteExecutorSlave.sol"; import "../../../interfaces/ISpokePool.sol"; import "../../../interfaces/ICallProxy.sol"; contract BufferManager is Initializable, PausableUpgradeable, AccessControlUpgradeable, UUPSUpgradeable { using AddressUpgradeable for address; using SafeERC20Upgradeable for IERC20Upgradeable; using EnumerableSetUpgradeable for EnumerableSetUpgradeable.UintSet; using EnumerableSetUpgradeable for EnumerableSetUpgradeable.AddressSet; event Bridge( address distributor, address originToken, address ethToken, uint256 amount, uint64 relayerFeePct, uint256[] directions, uint256[] percentage ); bool public upgradeStatus; // address of the DepositDistributor on mainnet address public distributor; address public slave; // address of the anycall contract on polygon address public anycall; // adress of the Across bridge contract to initiate the swap address public spokepool; // address of the gnosis multisig address public gnosis; uint256 public epochDuration; // bridge settings uint256 public lastExecuted; uint256 public bridgeInterval; uint64 public relayerFeePct; bytes32 public constant UPGRADER_ROLE = keccak256("UPGRADER_ROLE"); bytes32 public constant GELATO = keccak256("GELATO"); bytes32 public constant SWAPPER = keccak256("SWAPPER"); // liquidity handler ILiquidityHandler public handler; mapping(address => Epoch[]) public ibAlluoToEpoch; mapping(address => address) public ibAlluoToAdapter; mapping(address => uint256) public ibAlluoToMaxRefillPerEpoch; mapping(address => address) public tokenToEth; mapping(address => uint256) public tokenToMinBridge; // EnumerableSet of currently supported IBAlluo EnumerableSetUpgradeable.AddressSet private activeIbAlluos; // Data used to prevent draining the gnosis by setting a relevant limit to be used struct Epoch { uint256 startTime; uint256 refilledPerEpoch; } uint256 public bridgeCap; uint256 public bridgeRefilled; /// @custom:oz-upgrades-unsafe-allow constructor constructor() initializer {} /** * @dev * param _epochDuration Value for refill function to work properly * param _bridgeGenesis Unix timestamp declaring a starting point for counter * param _bridgeInterval Min time to pass between bridging (Unix timestamp) * param _gnosis Gnosis Multisig * param _spokepool Address of the SpokePool Polygon contract of Accross Protocol Bridge * param _anycall Address of the Multichain Anycall contract * param _distributor Address of the DepositDistritor contract on mainnet, which receives the bridged funds */ function initialize( uint256 _epochDuration, uint256 _brigeGenesis, uint256 _bridgeInterval, address _gnosis, address _spokepool, address _anycall, address _distributor ) public initializer { __Pausable_init(); __AccessControl_init(); __UUPSUpgradeable_init(); epochDuration = _epochDuration; distributor = _distributor; lastExecuted = _brigeGenesis; bridgeInterval = _bridgeInterval; spokepool = _spokepool; anycall = _anycall; gnosis = _gnosis; _grantRole(DEFAULT_ADMIN_ROLE, _gnosis); _grantRole(UPGRADER_ROLE, _gnosis); _grantRole(GELATO, _gnosis); _grantRole(SWAPPER, _gnosis); } /** * @notice Initiates transfer only if adapter is filled, there are no queued withdrawals and * balance of this contract exceeds the minimum required mark * @dev Function checker for gelato, after the balance crosses the threshold initates the swap function * @dev Checks minimumBridging amout, attempts to reffil the adapters * @return canExec Bool, if true - initiates the call by gelato * @return execPayload Data to be called by gelato */ function checkerBridge() external view returns (bool canExec, bytes memory execPayload) { for (uint256 i; i < activeIbAlluos.length(); i++) { (address iballuo, address token, uint256 amount) = getValues(i); if (adapterRequiredRefill(iballuo) == 0 && canBridge(token, amount)) { canExec = true; execPayload = abi.encodeWithSelector( BufferManager.swap.selector, amount, token, iballuo ); break; } } return (canExec, execPayload); } /** * @dev Triggers GELATO to refill buffer * @dev Checks buffer balance, balance of the gnosis and compares if he can execute the refill * @return canExec bool, serves as a flag for gelato * @return execPayload encoded call to refillBuffer with correct values */ function checkerRefill() external view returns (bool canExec, bytes memory execPayload) { for (uint256 i; i < activeIbAlluos.length(); i++) { (address iballuo, address token,) = getValues(i); if (canRefill(iballuo, token)) { canExec = true; execPayload = abi.encodeWithSelector( BufferManager.refillBuffer.selector, iballuo ); break; } } return (canExec, execPayload); } /** * @notice Function is called by gelato when checker flags it. Can only be called by * either Gelato or Multisig * @dev Bridges assets using Across Bridge by UMA Protocol (Source: https://across.to/) * @dev Bridges data for liquidity direction using Multichain AnyCallV6 * @param amount Amount of the funds to be transferred * @param originToken Address of the token to be bridged */ function swap( uint256 amount, address originToken ) external onlyRole(SWAPPER) { require( canBridge(originToken, amount), "Buffer: <minAmount or <bridgeInterval" ); if(block.timestamp > lastExecuted + bridgeInterval) { bridgeRefilled = 0; } lastExecuted = block.timestamp; IERC20Upgradeable(originToken).approve(spokepool, amount); ISpokePool(spokepool).deposit( distributor, originToken, amount, 1, relayerFeePct, uint32(block.timestamp) ); address tokenEth = tokenToEth[originToken]; ( uint256[] memory direction, uint256[] memory percentage ) = IVoteExecutorSlave(slave).getEntries(); ICallProxy(anycall).anyCall( // address of the collector contract on mainnet distributor, abi.encode(direction, percentage, tokenEth, amount), address(0), 1, // 0 flag to pay fee on destination chain 0 ); emit Bridge( distributor, originToken, tokenEth, amount, relayerFeePct, direction, percentage ); } /** * @dev Function checks if IBAlluos respective adapter has queued withdrawals * @param _ibAlluo Address of the IBAlluo pool * @return isAdapterPendingWithdrawal bool - true if there is a pending withdrawal on correspoding to an IBAlluo pool adapter */ function isAdapterPendingWithdrawal( address _ibAlluo ) public view returns (bool) { (, , uint256 totalWithdrawalAmount, ) = handler .ibAlluoToWithdrawalSystems(_ibAlluo); if (totalWithdrawalAmount > 0) { return true; } return false; } /** * @notice Function checks the amount of asset that needs to be transferred for an adapter to be filled * @param _ibAlluo Address of an IBAlluo contract, which corresponding adapter is to be filled * @return requiredRefill Amount to be refilled with 18 decimals */ function adapterRequiredRefill( address _ibAlluo ) public view returns (uint256) { uint256 expectedAmount = handler.getExpectedAdapterAmount(_ibAlluo, 0); uint256 actualAmount = handler.getAdapterAmount(_ibAlluo); if (actualAmount >= expectedAmount) { return 0; } uint256 difference = expectedAmount - actualAmount; if ((difference * 10000) / expectedAmount <= 500) { return 0; } return difference; } /** * @dev Function returns relevant refill settings by IBAlluo address * @param _ibAlluo address of the IBAlluo * @return Epoch struct with settings */ function _confirmEpoch(address _ibAlluo) internal returns (Epoch storage) { Epoch[] storage relevantEpochs = ibAlluoToEpoch[_ibAlluo]; Epoch storage lastEpoch = relevantEpochs[relevantEpochs.length - 1]; uint256 deadline = lastEpoch.startTime + epochDuration; if (block.timestamp > deadline) { uint256 cycles = (block.timestamp - deadline) / epochDuration; if (cycles != 0) { uint256 newStartTime = lastEpoch.startTime + (cycles * epochDuration); Epoch memory newEpoch = Epoch(newStartTime, 0); ibAlluoToEpoch[_ibAlluo].push(newEpoch); } } Epoch storage finalEpoch = relevantEpochs[relevantEpochs.length - 1]; return finalEpoch; } /** * @notice adapterRequiredRefill() and deposit() operate with 18 decimals, so balances need to be adjusted * @dev Refills corresponding IBAlluo adapter with prior checks and triggers executing queued withdrawals on the adapter * @dev First checks if buffer has enough funds to refill adapter. If not - checks if funds on buffer and gnosis multisig * together are enough to satisfy adapters. Uses all the available funds in buffer, takes rest from gnosis. * @dev After successful refill calls deposit() on corresponding adapter, instructing to leave all the funds in pool. * If there are any queued withdrawals on adapter - satisfies them * @param _ibAlluo address of corresponding IBAlluo */ function refillBuffer( address _ibAlluo ) external onlyRole(GELATO) returns (bool) { uint256 totalAmount = adapterRequiredRefill(_ibAlluo); require(totalAmount > 0, "No refill required"); address adapterAddress = ibAlluoToAdapter[_ibAlluo]; address bufferToken = IHandlerAdapter(adapterAddress).getCoreTokens(); uint256 decDif = 18 - IERC20MetadataUpgradeable(bufferToken).decimals(); uint256 bufferBalance = IERC20Upgradeable(bufferToken).balanceOf( address(this) ); uint256 gnosisBalance = IERC20Upgradeable(bufferToken).balanceOf( gnosis ); bufferBalance = bufferBalance * 10 ** decDif; gnosisBalance = gnosisBalance * 10 ** decDif; // 2 percent on top to be safe against pricefeed and lp slippage totalAmount += totalAmount * 200 / 10000; if (bufferBalance < totalAmount) { if (totalAmount < bufferBalance + gnosisBalance) { refillGnosis(totalAmount, bufferBalance, bufferToken, _ibAlluo, adapterAddress, decDif); return true; } else { return false; } } else { IERC20Upgradeable(bufferToken).transfer(adapterAddress, totalAmount / 10 ** decDif); IHandlerAdapter(adapterAddress).deposit(bufferToken, totalAmount, totalAmount); bridgeRefilled += totalAmount; if (isAdapterPendingWithdrawal(_ibAlluo)) { handler.satisfyAdapterWithdrawals(_ibAlluo); } return true; } } /** * @notice All the amounts are 18 decimals * @dev Internal function called by refillBuffer() in a scenario of using gnosis funds to execute the refill * @param totalAmount Required amount to fully refill the adapter * @param bufferBalance Amount of the asset on buffer * @param bufferToken Address of the token used to refill * @param ibAlluo Address of the ibAlluo binded to the adapter * @param adapterAddress Address of the adapter to be refilled * @param decDif Decimal difference, see notice in refillBuffer() for details */ function refillGnosis( uint256 totalAmount, uint256 bufferBalance, address bufferToken, address ibAlluo, address adapterAddress, uint256 decDif) internal { uint256 gnosisAmount = totalAmount - bufferBalance; Epoch storage currentEpoch = _confirmEpoch(ibAlluo); require( ibAlluoToMaxRefillPerEpoch[ibAlluo] >= currentEpoch.refilledPerEpoch + gnosisAmount, "Cumulative refills exceeds limit" ); currentEpoch.refilledPerEpoch += totalAmount; IERC20Upgradeable(bufferToken).transferFrom( gnosis, adapterAddress, gnosisAmount / 10 ** decDif ); if (gnosisAmount != totalAmount) { bridgeRefilled += totalAmount; IERC20Upgradeable(bufferToken).transfer( adapterAddress, bufferBalance / 10 ** decDif ); } IHandlerAdapter(adapterAddress).deposit( bufferToken, totalAmount, totalAmount ); if (isAdapterPendingWithdrawal(ibAlluo)) { handler.satisfyAdapterWithdrawals(ibAlluo); } } /** * @dev View function to trigger bridging * @param token Token to bridge * @param amount Amount to bridge */ function canBridge( address token, uint256 amount ) public view returns (bool) { uint256 amount18 = amount * 10 ** (18-IERC20MetadataUpgradeable(token).decimals()); if (amount >= tokenToMinBridge[token] && block.timestamp >= lastExecuted + bridgeInterval && bridgeRefilled + amount18 <= bridgeCap ) { return true; } return false; } /** * @dev View function to trigger refillBuffer * @param _iballuo Address of the IBAlluo * @param token Address of the correspondin primary token of the pool */ function canRefill( address _iballuo, address token ) public view returns (bool) { uint256 balance = IERC20Upgradeable(token).balanceOf(address(this)); uint256 decDif = 18 - IERC20MetadataUpgradeable(token).decimals(); uint256 gnosisBalance = IERC20Upgradeable(token).balanceOf(gnosis); balance = balance * 10 ** decDif; gnosisBalance = gnosisBalance * 10 ** decDif; uint256 refill = adapterRequiredRefill(_iballuo); if (refill > 0 && refill < gnosisBalance + balance) { return true; } return false; } /** * @dev Internal function for readabilty of checker functions * @param i Index in a loop in checkerRefill and checkerBridge */ function getValues(uint256 i) internal view returns(address, address, uint256) { address iballuo = activeIbAlluos.at(i); address token = IHandlerAdapter(ibAlluoToAdapter[iballuo]).getCoreTokens(); uint256 amount = IERC20Upgradeable(token).balanceOf(address(this)); return(iballuo, token, amount); } /** * @notice Initialize function faces stack too deep error, due to too many arguments. Used to safely set-up/upgrage * iballuos and corresponding settings * @param _activeIbAlluos Array of IBAlluo contract supported for bridging * @param _ibAlluoAdapters Array of corresponding Adapters * @param _tokensEth Addresses of the same tokens on mainnet * @param _minBridgeAmount Min amount of asset to trigget bridging for each of the iballuo * @param _maxRefillPerEpoch Max value of asset for an adapter to be filled in span of a predefined interval */ function initializeValues( address _handler, address[] memory _activeIbAlluos, address[] memory _ibAlluoAdapters, address[] memory _tokensEth, uint256[] memory _minBridgeAmount, uint256[] memory _maxRefillPerEpoch, uint256 _epochDuration ) public onlyRole(DEFAULT_ADMIN_ROLE) { handler = ILiquidityHandler(_handler); for (uint256 i; i < _activeIbAlluos.length; i++) { activeIbAlluos.add(_activeIbAlluos[i]); ibAlluoToAdapter[_activeIbAlluos[i]] = _ibAlluoAdapters[i]; address token = IHandlerAdapter(_ibAlluoAdapters[i]).getCoreTokens(); tokenToMinBridge[token] = _minBridgeAmount[i]; tokenToEth[token] = _tokensEth[i]; ibAlluoToMaxRefillPerEpoch[_activeIbAlluos[i]] = _maxRefillPerEpoch[ i ]; epochDuration = _epochDuration; Epoch memory newEpoch = Epoch(block.timestamp, 0); ibAlluoToEpoch[_activeIbAlluos[i]].push(newEpoch); } } /* ========== ADMIN CONFIGURATION ========== */ /** * @dev Admin function to change bridge interval * @param _bridgeInterval interval in seconds, to put limitations for an amount to be bridged */ function changeBridgeInterval(uint256 _bridgeInterval) external onlyRole(DEFAULT_ADMIN_ROLE) { bridgeInterval = _bridgeInterval; } /** * @dev Admin function to set minimum amount for each token that will serve as threshold to trigger bridging * @param _token Address of the token * @param _minAmount Minimum amount to allow bridging */ function setMinBridgeAmount(address _token, uint256 _minAmount) external onlyRole(DEFAULT_ADMIN_ROLE) { tokenToMinBridge[_token] = _minAmount; } /** * @dev Admin function to set bridge cap */ function setBridgeCap(uint256 _cap) external onlyRole(DEFAULT_ADMIN_ROLE) { bridgeCap = _cap; } /** * @dev Admin function to manually set relayersFeePct for bridging * @param _relayerFeePct relayerFeePct in uint64 */ function setRelayerFeePct(uint64 _relayerFeePct) external onlyRole(DEFAULT_ADMIN_ROLE) { relayerFeePct = _relayerFeePct; } /** * @dev Admin function to change the address of VoteExecutorSlave contract * @param _slave Address of the VoteExecutorSlave contract */ function setVoteExecutorSlave(address _slave) external onlyRole(DEFAULT_ADMIN_ROLE) { slave = _slave; } /** * @dev Admin function to set anycall contract address * @param _anycall Address of the anycall contract */ function setAnycall(address _anycall) external onlyRole(DEFAULT_ADMIN_ROLE) { anycall = _anycall; } /** * @dev Admin function to set Distributor contract address * @param _distributor Address of the Distributor contract on ETH mainnet */ function setDistributor(address _distributor) external onlyRole(DEFAULT_ADMIN_ROLE) { distributor = _distributor; } /** * @notice Needed for bridging * @dev Admin function to change the address of the respective token on Mainnet * @param _token address of the token on Polygon * @param _tokenEth address of the same token on Mainnet */ function setEthToken( address _token, address _tokenEth ) external onlyRole(DEFAULT_ADMIN_ROLE) { tokenToEth[_token] = _tokenEth; } /** * @dev Admin function for setting max amount an adapter can be refilled per interval * @param _ibAlluo address of the IBAlluo of the respective adapter * @param _maxRefillPerEpoch max amount to be refilled */ function setMaxRefillPerEpoch( address _ibAlluo, uint256 _maxRefillPerEpoch ) external onlyRole(DEFAULT_ADMIN_ROLE) { ibAlluoToMaxRefillPerEpoch[_ibAlluo] = _maxRefillPerEpoch; } /** * @dev Admin function for setting the aforementioned interval * @param _epochDuration time of the epoch in seconds */ function setEpochDuration( uint256 _epochDuration ) external onlyRole(DEFAULT_ADMIN_ROLE) { epochDuration = _epochDuration; } /** * @notice Function is called by gnosis * @dev Adds IBAlluo pool to the list of active pools * @param ibAlluo Address of the IBAlluo pool to be added */ function addIBAlluoPool( address ibAlluo, address adapter ) external onlyRole(DEFAULT_ADMIN_ROLE) { require(!activeIbAlluos.contains(ibAlluo), "Already active"); activeIbAlluos.add(ibAlluo); ibAlluoToAdapter[ibAlluo] = adapter; } /** * @notice Funtion is called by gnosis * @dev Removes IBAlluo pool from the list of active pools * @param ibAlluo Address of the IBAlluo pool to be removed */ function removeIBAlluoPool( address ibAlluo ) external onlyRole(DEFAULT_ADMIN_ROLE) returns (bool) { bool removed; for (uint256 i = 0; i < activeIbAlluos.length(); i++) { if (activeIbAlluos.at(i) == ibAlluo) { activeIbAlluos.remove(activeIbAlluos.at(i)); ibAlluoToAdapter[ibAlluo] = address(0); removed = true; } } return removed; } function changeUpgradeStatus( bool _status ) external onlyRole(DEFAULT_ADMIN_ROLE) { upgradeStatus = _status; } function _authorizeUpgrade( address newImplementation ) internal override onlyRole(UPGRADER_ROLE) { require(upgradeStatus, "Manager: Upgrade not allowed"); upgradeStatus = false; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.11; interface ICallProxy { function anyCall( address _to, bytes calldata _data, address _fallback, uint256 _toChainID, uint256 _flags ) external; }
// SPDX-License-Identifier: MIT pragma solidity 0.8.11; interface IHandlerAdapter { function deposit( address _token, uint256 fullAmount, uint256 leaveInPool ) external; function withdraw(address _user, address _token, uint256 _amount) external; function getAdapterAmount() external view returns (uint256); function getCoreTokens() external view returns (address primaryToken); function setSlippage(uint64 _newSlippage) external; function setWallet(address _newWallet) external; }
// SPDX-License-Identifier: MIT pragma solidity 0.8.11; import "@openzeppelin/contracts/access/IAccessControl.sol"; interface ILiquidityHandler is IAccessControl { function adapterIdsToAdapterInfo( uint256 ) external view returns ( string memory name, uint256 percentage, address adapterAddress, bool status ); function changeAdapterStatus(uint256 _id, bool _status) external; function changeUpgradeStatus(bool _status) external; function deposit(address _token, uint256 _amount) external; function deposit( address _token, uint256 _amount, address _targetToken ) external; function getActiveAdapters() external view returns ( ILiquidityHandlerStructs.AdapterInfo[] memory, address[] memory ); function getAdapterAmount(address _ibAlluo) external view returns (uint256); function getAdapterId(address _ibAlluo) external view returns (uint256); function getAllAdapters() external view returns ( ILiquidityHandlerStructs.AdapterInfo[] memory, address[] memory ); function getExpectedAdapterAmount( address _ibAlluo, uint256 _newAmount ) external view returns (uint256); function getIbAlluoByAdapterId( uint256 _adapterId ) external view returns (address); function getLastAdapterIndex() external view returns (uint256); function getListOfIbAlluos() external view returns (address[] memory); function getWithdrawal( address _ibAlluo, uint256 _id ) external view returns (ILiquidityHandlerStructs.Withdrawal memory); function ibAlluoToWithdrawalSystems( address ) external view returns ( uint256 lastWithdrawalRequest, uint256 lastSatisfiedWithdrawal, uint256 totalWithdrawalAmount, bool resolverTrigger ); function isUserWaiting( address _ibAlluo, address _user ) external view returns (bool); function pause() external; function paused() external view returns (bool); function removeTokenByAddress( address _address, address _to, uint256 _amount ) external; function satisfyAdapterWithdrawals(address _ibAlluo) external; function satisfyAllWithdrawals() external; function setAdapter( uint256 _id, string memory _name, uint256 _percentage, address _adapterAddress, bool _status ) external; function setIbAlluoToAdapterId( address _ibAlluo, uint256 _adapterId ) external; function supportsInterface(bytes4 interfaceId) external view returns (bool); function upgradeStatus() external view returns (bool); function withdraw(address _user, address _token, uint256 _amount) external; function withdraw( address _user, address _token, uint256 _amount, address _outputToken ) external; function getAdapterCoreTokensFromIbAlluo( address _ibAlluo ) external view returns (address); } interface ILiquidityHandlerStructs { struct AdapterInfo { string name; uint256 percentage; address adapterAddress; bool status; } struct Withdrawal { address user; address token; uint256 amount; uint256 time; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.11; interface ISpokePool { function deposit( address recipient, address originToken, uint256 amount, uint256 destinationChainId, uint64 relayerFeePct, uint32 quoteTimestamp ) external payable; function speedUpDeposit( address depositor, uint64 newRelayerFeePct, uint32 depositId, bytes memory depositorSignature ) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.11; interface IVoteExecutorSlave { struct Entry { uint256 directionId; uint256 percent; } function getEntries() external returns (uint256[] memory, uint256[] memory); }
{ "optimizer": { "enabled": true, "runs": 0 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"previousAdmin","type":"address"},{"indexed":false,"internalType":"address","name":"newAdmin","type":"address"}],"name":"AdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"beacon","type":"address"}],"name":"BeaconUpgraded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"distributor","type":"address"},{"indexed":false,"internalType":"address","name":"originToken","type":"address"},{"indexed":false,"internalType":"address","name":"ethToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint64","name":"relayerFeePct","type":"uint64"},{"indexed":false,"internalType":"uint256[]","name":"directions","type":"uint256[]"},{"indexed":false,"internalType":"uint256[]","name":"percentage","type":"uint256[]"}],"name":"Bridge","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"implementation","type":"address"}],"name":"Upgraded","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"GELATO","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SWAPPER","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"UPGRADER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_ibAlluo","type":"address"}],"name":"adapterRequiredRefill","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"ibAlluo","type":"address"},{"internalType":"address","name":"adapter","type":"address"}],"name":"addIBAlluoPool","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"anycall","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"bridgeCap","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"bridgeInterval","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"bridgeRefilled","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"canBridge","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_iballuo","type":"address"},{"internalType":"address","name":"token","type":"address"}],"name":"canRefill","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_bridgeInterval","type":"uint256"}],"name":"changeBridgeInterval","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_status","type":"bool"}],"name":"changeUpgradeStatus","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"checkerBridge","outputs":[{"internalType":"bool","name":"canExec","type":"bool"},{"internalType":"bytes","name":"execPayload","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"checkerRefill","outputs":[{"internalType":"bool","name":"canExec","type":"bool"},{"internalType":"bytes","name":"execPayload","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"distributor","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"epochDuration","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"gnosis","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"handler","outputs":[{"internalType":"contract ILiquidityHandler","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"ibAlluoToAdapter","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"ibAlluoToEpoch","outputs":[{"internalType":"uint256","name":"startTime","type":"uint256"},{"internalType":"uint256","name":"refilledPerEpoch","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"ibAlluoToMaxRefillPerEpoch","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_epochDuration","type":"uint256"},{"internalType":"uint256","name":"_brigeGenesis","type":"uint256"},{"internalType":"uint256","name":"_bridgeInterval","type":"uint256"},{"internalType":"address","name":"_gnosis","type":"address"},{"internalType":"address","name":"_spokepool","type":"address"},{"internalType":"address","name":"_anycall","type":"address"},{"internalType":"address","name":"_distributor","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_handler","type":"address"},{"internalType":"address[]","name":"_activeIbAlluos","type":"address[]"},{"internalType":"address[]","name":"_ibAlluoAdapters","type":"address[]"},{"internalType":"address[]","name":"_tokensEth","type":"address[]"},{"internalType":"uint256[]","name":"_minBridgeAmount","type":"uint256[]"},{"internalType":"uint256[]","name":"_maxRefillPerEpoch","type":"uint256[]"},{"internalType":"uint256","name":"_epochDuration","type":"uint256"}],"name":"initializeValues","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_ibAlluo","type":"address"}],"name":"isAdapterPendingWithdrawal","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastExecuted","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"proxiableUUID","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_ibAlluo","type":"address"}],"name":"refillBuffer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"relayerFeePct","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"ibAlluo","type":"address"}],"name":"removeIBAlluoPool","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_anycall","type":"address"}],"name":"setAnycall","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_cap","type":"uint256"}],"name":"setBridgeCap","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_distributor","type":"address"}],"name":"setDistributor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_epochDuration","type":"uint256"}],"name":"setEpochDuration","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"address","name":"_tokenEth","type":"address"}],"name":"setEthToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_ibAlluo","type":"address"},{"internalType":"uint256","name":"_maxRefillPerEpoch","type":"uint256"}],"name":"setMaxRefillPerEpoch","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"_minAmount","type":"uint256"}],"name":"setMinBridgeAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint64","name":"_relayerFeePct","type":"uint64"}],"name":"setRelayerFeePct","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_slave","type":"address"}],"name":"setVoteExecutorSlave","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"slave","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"spokepool","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"originToken","type":"address"}],"name":"swap","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"tokenToEth","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"tokenToMinBridge","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"upgradeStatus","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"}],"name":"upgradeTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"upgradeToAndCall","outputs":[],"stateMutability":"payable","type":"function"}]
Contract Creation Code
60a0604052306080523480156200001557600080fd5b5060006200002460016200008b565b905080156200003d576000805461ff0019166101001790555b801562000084576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5062000195565b60008054610100900460ff1615620000f4578160ff166001148015620000c45750620000c2306200013860201b6200226e1760201c565b155b620000ec5760405162461bcd60e51b8152600401620000e39062000147565b60405180910390fd5b506000919050565b60005460ff8084169116106200011e5760405162461bcd60e51b8152600401620000e39062000147565b506000805460ff191660ff92909216919091179055600190565b6001600160a01b03163b151590565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b608051613e6b620001cd60003960008181610f9901528181610fd901528181611091015281816110d101526111490152613e6b6000f3fe6080604052600436106102705760003560e01c806301ffc9a7146102755780630810cf22146102aa57806309077c09146102cc5780630a971d81146102f15780630e8ff1e7146103115780630fc6540714610328578063163e691c146103485780631c15ff77146103815780631f8bd1441461039857806320412d72146103b85780632143d033146103e6578063238c8aad146103fd578063248a9ca31461042b5780632f2ff15d1461044b57806330024dfe1461046b5780633095634a1461048b57806331b36b3d146104ab578063324e9293146104ce57806336568abe146105035780633659cfe614610523578063365ba6ce146105435780633d5302ae1461057a5780633fcdc0d71461059a578063430a5df7146105d15780634f1ef286146105f25780634ff0876a1461060557806352d1902d1461061c578063547cde5e146106315780635ac3a79f146106515780635c975abb14610671578063700d85ae1461068957806375619ab5146106ab5780637895876f146106cb578063877721af146106e05780638d18138c1461070057806391d1485414610720578063a217fddf14610740578063b8e637e314610755578063bc7a629114610776578063bfe1092814610796578063c80916d4146107bc578063cb1a4da3146107e4578063cbcfeb0a14610804578063cc5e8fe814610824578063d3986f0814610852578063d4c7161f14610872578063d4d543c514610892578063d547741f146108ad578063d701f523146108cd578063d9043056146108ed578063e15066951461090d578063ec3475941461092d578063eff557a71461094e578063f101c98314610970578063f72c0d8b14610990575b600080fd5b34801561028157600080fd5b506102956102903660046131bf565b6109b2565b60405190151581526020015b60405180910390f35b3480156102b657600080fd5b506102ca6102c5366004613209565b6109e9565b005b3480156102d857600080fd5b506102e361013d5481565b6040519081526020016102a1565b3480156102fd57600080fd5b506102ca61030c366004613235565b610a12565b34801561031d57600080fd5b506102e361013e5481565b34801561033457600080fd5b506102ca61034336600461325e565b610a41565b34801561035457600080fd5b5061013554610369906001600160401b031681565b6040516001600160401b0390911681526020016102a1565b34801561038d57600080fd5b506102e36101335481565b3480156103a457600080fd5b506102e36103b33660046132d9565b610b91565b3480156103c457600080fd5b506102e36103d33660046132d9565b61013a6020526000908152604090205481565b3480156103f257600080fd5b506102e36101345481565b34801561040957600080fd5b506101315461041e906001600160a01b031681565b6040516102a191906132f6565b34801561043757600080fd5b506102e361044636600461330a565b610ce1565b34801561045757600080fd5b506102ca610466366004613323565b610cf6565b34801561047757600080fd5b506102ca61048636600461330a565b610d17565b34801561049757600080fd5b506102956104a6366004613209565b610d29565b3480156104b757600080fd5b506104c0610e21565b6040516102a19291906133ab565b3480156104da57600080fd5b506104ee6104e9366004613209565b610ece565b604080519283526020830191909152016102a1565b34801561050f57600080fd5b506102ca61051e366004613323565b610f0b565b34801561052f57600080fd5b506102ca61053e3660046132d9565b610f8e565b34801561054f57600080fd5b5061041e61055e3660046132d9565b610137602052600090815260409020546001600160a01b031681565b34801561058657600080fd5b506102ca6105953660046132d9565b611057565b3480156105a657600080fd5b5061041e6105b53660046132d9565b610139602052600090815260409020546001600160a01b031681565b3480156105dd57600080fd5b506101305461041e906001600160a01b031681565b6102ca61060036600461340c565b611086565b34801561061157600080fd5b506102e36101325481565b34801561062857600080fd5b506102e361113c565b34801561063d57600080fd5b506102ca61064c3660046134b3565b6111ea565b34801561065d57600080fd5b506102ca61066c3660046135d3565b611225565b34801561067d57600080fd5b5060335460ff16610295565b34801561069557600080fd5b506102e3600080516020613e1683398151915281565b3480156106b757600080fd5b506102ca6106c63660046132d9565b611531565b3480156106d757600080fd5b506104c0611566565b3480156106ec57600080fd5b506102956106fb3660046132d9565b611629565b34801561070c57600080fd5b506102ca61071b3660046132d9565b611a91565b34801561072c57600080fd5b5061029561073b366004613323565b611ac0565b34801561074c57600080fd5b506102e3600081565b34801561076157600080fd5b5061012f5461041e906001600160a01b031681565b34801561078257600080fd5b506102ca61079136600461330a565b611aeb565b3480156107a257600080fd5b5061012d5461041e9061010090046001600160a01b031681565b3480156107c857600080fd5b506101355461041e90600160401b90046001600160a01b031681565b3480156107f057600080fd5b506102ca6107ff36600461330a565b611afd565b34801561081057600080fd5b506102ca61081f3660046134b3565b611b0f565b34801561083057600080fd5b506102e361083f3660046132d9565b6101386020526000908152604090205481565b34801561085e57600080fd5b506102ca61086d366004613323565b611ba1565b34801561087e57600080fd5b5061029561088d3660046132d9565b611ef4565b34801561089e57600080fd5b5061012d546102959060ff1681565b3480156108b957600080fd5b506102ca6108c8366004613323565b611f9a565b3480156108d957600080fd5b506102ca6108e83660046136cc565b611fb6565b3480156108f957600080fd5b506102956109083660046132d9565b611fd6565b34801561091957600080fd5b506102956109283660046134b3565b612071565b34801561093957600080fd5b5061012e5461041e906001600160a01b031681565b34801561095a57600080fd5b506102e3600080516020613daf83398151915281565b34801561097c57600080fd5b506102ca61098b366004613209565b612245565b34801561099c57600080fd5b506102e3600080516020613d8f83398151915281565b60006001600160e01b03198216637965db0b60e01b14806109e357506301ffc9a760e01b6001600160e01b03198316145b92915050565b60006109f48161227d565b506001600160a01b03909116600090815261013a6020526040902055565b6000610a1d8161227d565b5061013580546001600160401b0319166001600160401b0392909216919091179055565b6000610a4d6001612287565b90508015610a65576000805461ff0019166101001790555b610a6d61231b565b610a7561234c565b610a7d61234c565b61013288905561012d8054610100600160a81b0319166101006001600160a01b03858116919091029190911790915561013388905561013487905561013080546001600160a01b03199081168784161790915561012f805482168684161790556101318054909116918716919091179055610af9600086612373565b610b11600080516020613d8f83398151915286612373565b610b29600080516020613daf83398151915286612373565b610b41600080516020613e1683398151915286612373565b8015610b87576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5050505050505050565b61013554604051637971bae560e11b81526000918291600160401b9091046001600160a01b03169063f2e375ca90610bcf90869085906004016136e9565b602060405180830381865afa158015610bec573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c109190613702565b610135546040516337491c4f60e11b8152919250600091600160401b9091046001600160a01b031690636e92389e90610c4d9087906004016132f6565b602060405180830381865afa158015610c6a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c8e9190613702565b9050818110610ca1575060009392505050565b6000610cad8284613731565b90506101f483610cbf83612710613748565b610cc99190613767565b11610cd957506000949350505050565b949350505050565b60009081526097602052604090206001015490565b610cff82610ce1565b610d088161227d565b610d128383612373565b505050565b6000610d228161227d565b5061013255565b600080836001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015610d6a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d8e9190613789565b610d999060126137ac565b610da490600a6138b3565b610dae9084613748565b6001600160a01b038516600090815261013a60205260409020549091508310801590610deb57506101345461013354610de791906138c2565b4210155b8015610e08575061013d548161013e54610e0591906138c2565b11155b15610e175760019150506109e3565b5060009392505050565b6000606060005b610e3361013b6123f9565b811015610ec957600080610e4683612403565b5091509150610e558282612071565b15610eb4576040516001955063877721af60e01b90610e789084906024016132f6565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b0319909316929092179091529350610ec9915050565b50508080610ec1906138da565b915050610e28565b509091565b6101366020528160005260406000208181548110610eeb57600080fd5b600091825260209091206002909102018054600190910154909250905082565b6001600160a01b0381163314610f805760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b60648201526084015b60405180910390fd5b610f8a8282612513565b5050565b306001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161415610fd75760405162461bcd60e51b8152600401610f77906138f5565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031661100961257a565b6001600160a01b03161461102f5760405162461bcd60e51b8152600401610f779061392f565b61103881612596565b604080516000808252602082019092526110549183919061260f565b50565b60006110628161227d565b5061012f80546001600160a01b0319166001600160a01b0392909216919091179055565b306001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614156110cf5760405162461bcd60e51b8152600401610f77906138f5565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031661110161257a565b6001600160a01b0316146111275760405162461bcd60e51b8152600401610f779061392f565b61113082612596565b610f8a8282600161260f565b6000306001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146111d75760405162461bcd60e51b815260206004820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c6044820152771b1959081d1a1c9bdd59da0819195b1959d85d1958d85b1b60421b6064820152608401610f77565b50600080516020613dcf83398151915290565b60006111f58161227d565b506001600160a01b0391821660009081526101396020526040902080546001600160a01b03191691909216179055565b60006112308161227d565b6101358054600160401b600160e01b031916600160401b6001600160a01b038b160217905560005b87518110156115265761128f88828151811061127657611276613969565b602002602001015161013b61277a90919063ffffffff16565b508681815181106112a2576112a2613969565b602002602001015161013760008a84815181106112c1576112c1613969565b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060006101000a8154816001600160a01b0302191690836001600160a01b03160217905550600087828151811061132157611321613969565b60200260200101516001600160a01b0316636157eb966040518163ffffffff1660e01b8152600401602060405180830381865afa158015611366573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061138a919061397f565b905085828151811061139e5761139e613969565b602002602001015161013a6000836001600160a01b03166001600160a01b03168152602001908152602001600020819055508682815181106113e2576113e2613969565b60200260200101516101396000836001600160a01b03166001600160a01b0316815260200190815260200160002060006101000a8154816001600160a01b0302191690836001600160a01b0316021790555084828151811061144657611446613969565b602002602001015161013860008b858151811061146557611465613969565b60200260200101516001600160a01b03166001600160a01b03168152602001908152602001600020819055508361013281905550600060405180604001604052804281526020016000815250905061013660008b85815181106114ca576114ca613969565b6020908102919091018101516001600160a01b031682528181019290925260400160009081208054600181810183559183529183902084516002909302019182559290910151910155508061151e816138da565b915050611258565b505050505050505050565b600061153c8161227d565b5061012d80546001600160a01b0390921661010002610100600160a81b0319909216919091179055565b6000606060005b61157861013b6123f9565b811015610ec957600080600061158d84612403565b92509250925061159c83610b91565b1580156115ae57506115ae8282610d29565b15611613576040805160248101929092526001600160a01b039283166044830152929091166064808301919091528251808303909101815260849091019091526020810180516001600160e01b0316631a730de160e31b179052600193509150509091565b5050508080611621906138da565b91505061156d565b6000600080516020613daf8339815191526116438161227d565b600061164e84610b91565b9050600081116116955760405162461bcd60e51b8152602060048201526012602482015271139bc81c99599a5b1b081c995c5d5a5c995960721b6044820152606401610f77565b6001600160a01b038085166000908152610137602090815260408083205481516330abf5cb60e11b815291519416938492636157eb9692600480820193918290030181865afa1580156116ec573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611710919061397f565b90506000816001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015611752573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117769190613789565b6117819060126137ac565b60ff1690506000826001600160a01b03166370a08231306040518263ffffffff1660e01b81526004016117b491906132f6565b602060405180830381865afa1580156117d1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117f59190613702565b610131546040516370a0823160e01b81529192506000916001600160a01b03868116926370a082319261182e92909116906004016132f6565b602060405180830381865afa15801561184b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061186f9190613702565b905061187c83600a61399c565b6118869083613748565b915061189383600a61399c565b61189d9082613748565b90506127106118ad8760c8613748565b6118b79190613767565b6118c190876138c2565b955085821015611908576118d581836138c2565b8610156118f9576118ea8683868c8988612796565b60019750505050505050611a8b565b60009750505050505050611a8b565b6001600160a01b03841663a9059cbb8661192386600a61399c565b61192d908a613767565b6040518363ffffffff1660e01b815260040161194a9291906136e9565b6020604051808303816000875af1158015611969573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061198d91906139a8565b50604051630efe6a8b60e01b81526001600160a01b03861690630efe6a8b906119be9087908a9081906004016139c5565b600060405180830381600087803b1580156119d857600080fd5b505af11580156119ec573d6000803e3d6000fd5b505050508561013e6000828254611a0391906138c2565b90915550611a12905089611fd6565b156118ea57610135546040516396f1382160e01b8152600160401b9091046001600160a01b0316906396f1382190611a4e908c906004016132f6565b600060405180830381600087803b158015611a6857600080fd5b505af1158015611a7c573d6000803e3d6000fd5b50505050600197505050505050505b50919050565b6000611a9c8161227d565b5061012e80546001600160a01b0319166001600160a01b0392909216919091179055565b60009182526097602090815260408084206001600160a01b0393909316845291905290205460ff1690565b6000611af68161227d565b5061013d55565b6000611b088161227d565b5061013455565b6000611b1a8161227d565b611b2661013b84612a71565b15611b645760405162461bcd60e51b815260206004820152600e60248201526d416c72656164792061637469766560901b6044820152606401610f77565b611b7061013b8461277a565b50506001600160a01b0391821660009081526101376020526040902080546001600160a01b03191691909216179055565b600080516020613e16833981519152611bb98161227d565b611bc38284610d29565b611c1d5760405162461bcd60e51b815260206004820152602560248201527f4275666665723a203c6d696e416d6f756e74206f72203c627269646765496e74604482015264195c9d985b60da1b6064820152608401610f77565b6101345461013354611c2f91906138c2565b421115611c3d57600061013e555b42610133556101305460405163095ea7b360e01b81526001600160a01b038481169263095ea7b392611c77929091169087906004016136e9565b6020604051808303816000875af1158015611c96573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cba91906139a8565b506101305461012d5461013554604051630924512f60e31b81526001600160a01b0361010090930483166004820152858316602482015260448101879052600160648201526001600160401b0390911660848201524263ffffffff1660a482015291169063492289789060c401600060405180830381600087803b158015611d4157600080fd5b505af1158015611d55573d6000803e3d6000fd5b5050506001600160a01b03808416600090815261013960205260408082205461012e5482516317be85c360e01b8152925191851695509293849316916317be85c39160048083019286929190829003018183875af1158015611dbb573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611de39190810190613a41565b61012f5461012d546040519395509193506001600160a01b039081169263bd45c4e792610100900490911690611e23908690869089908d90602001613adf565b6040516020818303038152906040526000600160006040518663ffffffff1660e01b8152600401611e58959493929190613b21565b600060405180830381600087803b158015611e7257600080fd5b505af1158015611e86573d6000803e3d6000fd5b505061012d54610135546040517f8cd19855172f79b649919cafcdeb37d17aa75198b4f4a4415796a64690e24f299450611ee493506101009092046001600160a01b031691899188918c916001600160401b03169089908990613b5f565b60405180910390a1505050505050565b600080611f008161227d565b6000805b611f0f61013b6123f9565b811015611f92576001600160a01b038516611f2c61013b83612a86565b6001600160a01b03161415611f8057611f53611f4a61013b83612a86565b61013b90612a92565b506001600160a01b03851660009081526101376020526040902080546001600160a01b0319169055600191505b80611f8a816138da565b915050611f04565b509392505050565b611fa382610ce1565b611fac8161227d565b610d128383612513565b6000611fc18161227d565b5061012d805460ff1916911515919091179055565b610135546040516305ff325160e01b81526000918291600160401b9091046001600160a01b0316906305ff3251906120129086906004016132f6565b608060405180830381865afa15801561202f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120539190613bc9565b50925050811590506120685750600192915050565b50600092915050565b600080826001600160a01b03166370a08231306040518263ffffffff1660e01b81526004016120a091906132f6565b602060405180830381865afa1580156120bd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120e19190613702565b90506000836001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015612123573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121479190613789565b6121529060126137ac565b610131546040516370a0823160e01b815260ff9290921692506000916001600160a01b03878116926370a082319261219092909116906004016132f6565b602060405180830381865afa1580156121ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121d19190613702565b90506121de82600a61399c565b6121e89084613748565b92506121f582600a61399c565b6121ff9082613748565b9050600061220c87610b91565b9050600081118015612226575061222384836138c2565b81105b156122385760019450505050506109e3565b5060009695505050505050565b60006122508161227d565b506001600160a01b0390911660009081526101386020526040902055565b6001600160a01b03163b151590565b6110548133612aa7565b60008054610100900460ff16156122d5578160ff1660011480156122b157506122af3061226e565b155b6122cd5760405162461bcd60e51b8152600401610f7790613c0a565b506000919050565b60005460ff8084169116106122fc5760405162461bcd60e51b8152600401610f7790613c0a565b506000805460ff191660ff92909216919091179055600190565b919050565b600054610100900460ff166123425760405162461bcd60e51b8152600401610f7790613c58565b61234a612b0b565b565b600054610100900460ff1661234a5760405162461bcd60e51b8152600401610f7790613c58565b61237d8282611ac0565b610f8a5760008281526097602090815260408083206001600160a01b03851684529091529020805460ff191660011790556123b53390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b60006109e3825490565b600080808061241461013b86612a86565b6001600160a01b038082166000908152610137602090815260408083205481516330abf5cb60e11b8152915195965092949290931692636157eb9692600480830193928290030181865afa158015612470573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612494919061397f565b90506000816001600160a01b03166370a08231306040518263ffffffff1660e01b81526004016124c491906132f6565b602060405180830381865afa1580156124e1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125059190613702565b929791965091945092505050565b61251d8282611ac0565b15610f8a5760008281526097602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b600080516020613dcf833981519152546001600160a01b031690565b600080516020613d8f8339815191526125ae8161227d565b61012d5460ff166126005760405162461bcd60e51b815260206004820152601c60248201527b13585b9859d95c8e88155c19dc985919481b9bdd08185b1b1bddd95960221b6044820152606401610f77565b505061012d805460ff19169055565b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff161561264257610d1283612b3e565b826001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa92505050801561269c575060408051601f3d908101601f1916820190925261269991810190613702565b60015b6126ff5760405162461bcd60e51b815260206004820152602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201526d6f6e206973206e6f74205555505360901b6064820152608401610f77565b600080516020613dcf833981519152811461276e5760405162461bcd60e51b815260206004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f786044820152681a58589b195555525160ba1b6064820152608401610f77565b50610d12838383612bd8565b600061278f836001600160a01b038416612c03565b9392505050565b60006127a28688613731565b905060006127af85612c4d565b90508181600101546127c191906138c2565b6001600160a01b0386166000908152610138602052604090205410156128295760405162461bcd60e51b815260206004820181905260248201527f43756d756c617469766520726566696c6c732065786365656473206c696d69746044820152606401610f77565b8781600101600082825461283d91906138c2565b9091555050610131546001600160a01b03808816916323b872dd91168661286587600a61399c565b61286f9087613767565b6040516001600160e01b031960e086901b1681526001600160a01b03938416600482015292909116602483015260448201526064016020604051808303816000875af11580156128c3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128e791906139a8565b5087821461298e578761013e600082825461290291906138c2565b90915550506001600160a01b03861663a9059cbb8561292286600a61399c565b61292c908b613767565b6040518363ffffffff1660e01b81526004016129499291906136e9565b6020604051808303816000875af1158015612968573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061298c91906139a8565b505b604051630efe6a8b60e01b81526001600160a01b03851690630efe6a8b906129be9089908c9081906004016139c5565b600060405180830381600087803b1580156129d857600080fd5b505af11580156129ec573d6000803e3d6000fd5b505050506129f985611fd6565b15610b8757610135546040516396f1382160e01b8152600160401b9091046001600160a01b0316906396f1382190612a359088906004016132f6565b600060405180830381600087803b158015612a4f57600080fd5b505af1158015612a63573d6000803e3d6000fd5b505050505050505050505050565b600061278f836001600160a01b038416612d84565b600061278f8383612d9c565b600061278f836001600160a01b038416612dc6565b612ab18282611ac0565b610f8a57612ac9816001600160a01b03166014612eb9565b612ad4836020612eb9565b604051602001612ae5929190613ca3565b60408051601f198184030181529082905262461bcd60e51b8252610f7791600401613d12565b600054610100900460ff16612b325760405162461bcd60e51b8152600401610f7790613c58565b6033805460ff19169055565b612b478161226e565b612ba95760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b6064820152608401610f77565b600080516020613dcf83398151915280546001600160a01b0319166001600160a01b0392909216919091179055565b612be183613054565b600082511180612bee5750805b15610d1257612bfd8383613094565b50505050565b6000612c0f8383612d84565b612c45575081546001818101845560008481526020808220909301849055845484825282860190935260409020919091556109e3565b5060006109e3565b6001600160a01b038116600090815261013660205260408120805482908290612c7890600190613731565b81548110612c8857612c88613969565b906000526020600020906002020190506000610132548260000154612cad91906138c2565b905080421115612d475761013254600090612cc88342613731565b612cd29190613767565b90508015612d455760006101325482612ceb9190613748565b8454612cf791906138c2565b604080518082018252918252600060208084018281526001600160a01b038c168352610136825292822080546001818101835591845291909220935160029091029093019283559051910155505b505b82546000908490612d5a90600190613731565b81548110612d6a57612d6a613969565b600091825260209091206002909102019695505050505050565b60009081526001919091016020526040902054151590565b6000826000018281548110612db357612db3613969565b9060005260206000200154905092915050565b60008181526001830160205260408120548015612eaf576000612dea600183613731565b8554909150600090612dfe90600190613731565b9050818114612e63576000866000018281548110612e1e57612e1e613969565b9060005260206000200154905080876000018481548110612e4157612e41613969565b6000918252602080832090910192909255918252600188019052604090208390555b8554869080612e7457612e74613d25565b6001900381819060005260206000200160009055905585600101600086815260200190815260200160002060009055600193505050506109e3565b60009150506109e3565b60606000612ec8836002613748565b612ed39060026138c2565b6001600160401b03811115612eea57612eea6133c6565b6040519080825280601f01601f191660200182016040528015612f14576020820181803683370190505b509050600360fc1b81600081518110612f2f57612f2f613969565b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110612f5e57612f5e613969565b60200101906001600160f81b031916908160001a9053506000612f82846002613748565b612f8d9060016138c2565b90505b6001811115613005576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110612fc157612fc1613969565b1a60f81b828281518110612fd757612fd7613969565b60200101906001600160f81b031916908160001a90535060049490941c93612ffe81613d3b565b9050612f90565b50831561278f5760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610f77565b61305d81612b3e565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b606061309f8361226e565b6130fa5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b6064820152608401610f77565b600080846001600160a01b0316846040516131159190613d52565b600060405180830381855af49150503d8060008114613150576040519150601f19603f3d011682016040523d82523d6000602084013e613155565b606091505b509150915061317d8282604051806060016040528060278152602001613def60279139613186565b95945050505050565b6060831561319557508161278f565b8251156131a55782518084602001fd5b8160405162461bcd60e51b8152600401610f779190613d12565b6000602082840312156131d157600080fd5b81356001600160e01b03198116811461278f57600080fd5b6001600160a01b038116811461105457600080fd5b8035612316816131e9565b6000806040838503121561321c57600080fd5b8235613227816131e9565b946020939093013593505050565b60006020828403121561324757600080fd5b81356001600160401b038116811461278f57600080fd5b600080600080600080600060e0888a03121561327957600080fd5b8735965060208801359550604088013594506060880135613299816131e9565b935060808801356132a9816131e9565b925060a08801356132b9816131e9565b915060c08801356132c9816131e9565b8091505092959891949750929550565b6000602082840312156132eb57600080fd5b813561278f816131e9565b6001600160a01b0391909116815260200190565b60006020828403121561331c57600080fd5b5035919050565b6000806040838503121561333657600080fd5b823591506020830135613348816131e9565b809150509250929050565b60005b8381101561336e578181015183820152602001613356565b83811115612bfd5750506000910152565b60008151808452613397816020860160208601613353565b601f01601f19169290920160200192915050565b8215158152604060208201526000610cd9604083018461337f565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b0381118282101715613404576134046133c6565b604052919050565b6000806040838503121561341f57600080fd5b823561342a816131e9565b91506020838101356001600160401b038082111561344757600080fd5b818601915086601f83011261345b57600080fd5b81358181111561346d5761346d6133c6565b61347f601f8201601f191685016133dc565b9150808252878482850101111561349557600080fd5b80848401858401376000848284010152508093505050509250929050565b600080604083850312156134c657600080fd5b82356134d1816131e9565b91506020830135613348816131e9565b60006001600160401b038211156134fa576134fa6133c6565b5060051b60200190565b600082601f83011261351557600080fd5b8135602061352a613525836134e1565b6133dc565b82815260059290921b8401810191818101908684111561354957600080fd5b8286015b8481101561356d578035613560816131e9565b835291830191830161354d565b509695505050505050565b600082601f83011261358957600080fd5b81356020613599613525836134e1565b82815260059290921b840181019181810190868411156135b857600080fd5b8286015b8481101561356d57803583529183019183016135bc565b600080600080600080600060e0888a0312156135ee57600080fd5b6135f7886131fe565b965060208801356001600160401b038082111561361357600080fd5b61361f8b838c01613504565b975060408a013591508082111561363557600080fd5b6136418b838c01613504565b965060608a013591508082111561365757600080fd5b6136638b838c01613504565b955060808a013591508082111561367957600080fd5b6136858b838c01613578565b945060a08a013591508082111561369b57600080fd5b506136a88a828b01613578565b92505060c0880135905092959891949750929550565b801515811461105457600080fd5b6000602082840312156136de57600080fd5b813561278f816136be565b6001600160a01b03929092168252602082015260400190565b60006020828403121561371457600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b6000828210156137435761374361371b565b500390565b60008160001904831182151516156137625761376261371b565b500290565b60008261378457634e487b7160e01b600052601260045260246000fd5b500490565b60006020828403121561379b57600080fd5b815160ff8116811461278f57600080fd5b600060ff821660ff8416808210156137c6576137c661371b565b90039392505050565b600181815b8085111561380a5781600019048211156137f0576137f061371b565b808516156137fd57918102915b93841c93908002906137d4565b509250929050565b600082613821575060016109e3565b8161382e575060006109e3565b8160018114613844576002811461384e5761386a565b60019150506109e3565b60ff84111561385f5761385f61371b565b50506001821b6109e3565b5060208310610133831016604e8410600b841016171561388d575081810a6109e3565b61389783836137cf565b80600019048211156138ab576138ab61371b565b029392505050565b600061278f60ff841683613812565b600082198211156138d5576138d561371b565b500190565b60006000198214156138ee576138ee61371b565b5060010190565b6020808252602c90820152600080516020613d6f83398151915260408201526b19195b1959d85d1958d85b1b60a21b606082015260800190565b6020808252602c90820152600080516020613d6f83398151915260408201526b6163746976652070726f787960a01b606082015260800190565b634e487b7160e01b600052603260045260246000fd5b60006020828403121561399157600080fd5b815161278f816131e9565b600061278f8383613812565b6000602082840312156139ba57600080fd5b815161278f816136be565b6001600160a01b039390931683526020830191909152604082015260600190565b600082601f8301126139f757600080fd5b81516020613a07613525836134e1565b82815260059290921b84018101918181019086841115613a2657600080fd5b8286015b8481101561356d5780518352918301918301613a2a565b60008060408385031215613a5457600080fd5b82516001600160401b0380821115613a6b57600080fd5b613a77868387016139e6565b93506020850151915080821115613a8d57600080fd5b50613a9a858286016139e6565b9150509250929050565b600081518084526020808501945080840160005b83811015613ad457815187529582019590820190600101613ab8565b509495945050505050565b608081526000613af26080830187613aa4565b8281036020840152613b048187613aa4565b6001600160a01b0395909516604084015250506060015292915050565b600060018060a01b03808816835260a06020840152613b4360a084018861337f565b9516604083015250606081019290925260809091015292915050565b6001600160a01b038881168252878116602083015286166040820152606081018590526001600160401b038416608082015260e060a08201819052600090613ba990830185613aa4565b82810360c0840152613bbb8185613aa4565b9a9950505050505050505050565b60008060008060808587031215613bdf57600080fd5b8451935060208501519250604085015191506060850151613bff816136be565b939692955090935050565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b76020b1b1b2b9b9a1b7b73a3937b61d1030b1b1b7bab73a1604d1b815260008351613cd5816017850160208801613353565b7001034b99036b4b9b9b4b733903937b6329607d1b6017918401918201528351613d06816028840160208801613353565b01602801949350505050565b60208152600061278f602083018461337f565b634e487b7160e01b600052603160045260246000fd5b600081613d4a57613d4a61371b565b506000190190565b60008251613d64818460208701613353565b919091019291505056fe46756e6374696f6e206d7573742062652063616c6c6564207468726f75676820189ab7a9244df0848122154315af71fe140f3db0fe014031783b0946b8c9d2e38e81cee32eed7d8f4f15cd1d324edf5fe36cbe57fae18180879d4bdc265ceb30360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564d2761b102bda9831f4af400cc824b8cecb9cc5c1c85c51acb1479db9735fbfc6a2646970667358221220a69aaf30601e0c9e67db1567be8d85997841399a19b861ea1c1d6caa145cf11e64736f6c634300080b0033
Age | Block | Fee Address | BC Fee Address | Voting Power | Jailed | Incoming |
---|