Source Code
Overview
ETH Balance
0 ETH
More Info
ContractCreator
Multichain Info
N/A
| Transaction Hash |
Method
|
Block
|
From
|
To
|
Amount
|
||||
|---|---|---|---|---|---|---|---|---|---|
Latest 1 internal transaction
| Parent Transaction Hash | Block | From | To | Amount | ||
|---|---|---|---|---|---|---|
| 133358734 | 234 days ago | Contract Creation | 0 ETH |
Loading...
Loading
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.
Contract Source Code Verified (Exact Match)
Contract Name:
FundsManagerLogic
Compiler Version
v0.8.28+commit.7893614a
Optimization Enabled:
Yes with 10000 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: UNLICENSED
// Copyright 2023 Immersve
pragma solidity ^0.8.28;
import { IFundsStorageFactory } from "./interfaces/IFundsStorageFactory.sol";
import { IFundsAdmin } from "./interfaces/IFundsAdmin.sol";
import { IFundsStorage } from "./interfaces/IFundsStorage.sol";
import { FundsStorageLogic } from "./FundsStorageLogic.sol";
import { BeaconProxy } from "@openzeppelin/contracts/proxy/beacon/BeaconProxy.sol";
import { UpgradeableBeacon } from "@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol";
import { ERC1967Utils } from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";
import { UUPSUpgradeable } from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
import { AccessControlUpgradeable } from "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";
import { IAccessControl } from "@openzeppelin/contracts/access/IAccessControl.sol";
import { PausableUpgradeable } from "@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol";
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
contract FundsManagerLogic is AccessControlUpgradeable, UUPSUpgradeable, PausableUpgradeable, IFundsStorageFactory, IFundsAdmin {
/**
* The FundsStorageLogic beacon.
*/
UpgradeableBeacon internal _fundsStorageBeacon;
/**
* The FundsStorageLogic implementation contract.
* This storage slot will NOT be initialized on a proxy.
*/
address internal _storageLogicAddress;
/**
* The FundsAdminLogic implementation contract.
* This storage slot will NOT be initialized on a proxy.
*/
address internal _adminLogicAddress;
/**
* A build number supplied when (re)initializing.
*/
string internal _buildNumber;
/**
* A VCS commit id supplied when (re)initializing.
*/
string internal _commitId;
struct FundStorageConfig {
bool isInstance;
}
/**
* Addresses of FundsStorage beacon proxies that have been created by this factory.
*/
mapping (address => FundStorageConfig) internal _fundsStorageInstances;
/// @inheritdoc IFundsAdmin
bytes32 public constant WITHDRAWAL_SIGNER_ROLE = keccak256("WITHDRAWAL_AUTHORIZER_ROLE");
/// @inheritdoc IFundsAdmin
bytes32 public constant SETTLER_ROLE = keccak256("SETTLER_ROLE");
/**
* Mapping of token address to funds settlement address. The settlement
* address is the only address to which funds storage instance token deposits
* can be transfered as part of the settlement process. When a settlement
* address is not set (ie. `address(0)`) then the token is NOT supported.
*/
mapping(address => address) internal _tokenSettlementAddress;
/**
* Mapping of funds storage address to settlement nonce.
*/
mapping(address => uint256) internal _fundsStorageSettlementNonce;
/**
* @notice This field is DEPRECATED. Refunder address will be dynamic
* from now on. We are not removing this field from the contract to keep
* storage layout compatibility
*/
address internal _refunderAddress;
/**
* Indicates if Direct Spend funding mode is enabled
*/
bool internal _directSpendEnabled;
/**
* @dev indicates the amount of seconds after which a
* direct spend transaction is expired in case a reversal
* is being executed against it
*/
uint256 internal _directSpendReversalCutoffSeconds;
/// @custom:oz-upgrades-unsafe-allow constructor
constructor() {
// invoked in the context of the contract being deployed
_disableInitializers();
_storageLogicAddress = address(new FundsStorageLogic());
_adminLogicAddress = address(this);
}
/**
* @dev This initializer will be run after every upgrade.
* @param commitId A reference to the VCS commit that this contract is initialized from.
* @param buildNumber A reference to the build number for this contract initialization.
*/
function initialize(string calldata commitId, string calldata buildNumber) public onlyProxy onlyRole(DEFAULT_ADMIN_ROLE) {
/*
* Warning: this initializer must guard against reinitialization!
*
* The initializer acts like a constructor for initializing state on a
* delegating proxy. Normally the "initializer" modifier is used to prevent
* it being invoked multiple times. We have removed the guard in order to
* simplify our contract upgrade process; we always call "initialize" when
* performing a proxy upgrade.
*
* It is the duty of this initializer to do nothing when the proxy state is
* already initialized.
*/
bool _proxiesInitialized = address(_fundsStorageBeacon) != address(0);
if(!_proxiesInitialized) {
_initialize();
}
_buildNumber = buildNumber;
_commitId = commitId;
_directSpendEnabled = false; // defaults to disabled
_directSpendReversalCutoffSeconds = 7 days;
}
function _initialize() internal reinitializer(2) onlyProxy {
address implAddress = ERC1967Utils.getImplementation();
FundsManagerLogic impl = FundsManagerLogic(implAddress);
_fundsStorageBeacon = new UpgradeableBeacon(impl.getStorageLogicAddress(), address(this));
PausableUpgradeable.__Pausable_init();
}
/// @inheritdoc IFundsStorageFactory
function getStorageBeaconAddress() public view returns(address) {
return address(_fundsStorageBeacon);
}
function getStorageLogicAddress() public view returns(address) {
return _storageLogicAddress;
}
/// @inheritdoc IFundsStorageFactory
function getAdminAddress() public view returns(address) {
return address(this);
}
function getAdminLogicAddress() public view returns(address) {
return _adminLogicAddress;
}
function _authorizeUpgrade(address newImplementation) internal view override onlyRole(DEFAULT_ADMIN_ROLE) {
}
/// @inheritdoc UUPSUpgradeable
function upgradeToAndCall(address newImplAddress, bytes memory data) public payable override onlyProxy {
super.upgradeToAndCall(newImplAddress, data);
FundsManagerLogic newImpl = FundsManagerLogic(newImplAddress);
_fundsStorageBeacon.upgradeTo(newImpl.getStorageLogicAddress());
}
/// @inheritdoc IFundsStorageFactory
function getVersion() external pure returns(uint256) {
return 1;
}
/// @inheritdoc IFundsStorageFactory
function getCommitId() external view returns(string memory) {
return _commitId;
}
/// @inheritdoc IFundsStorageFactory
function getBuildNumber() external view returns(string memory) {
return _buildNumber;
}
/// @inheritdoc IFundsStorageFactory
function createFundsStorage(address token, string calldata name, FundingMode fundingMode) external onlyProxy returns(address) {
_requireTokenSupported(token);
/*
* Salt for create2 will be sender address padded with first 96 bits of hash(name)
* Bitmask is equal to: ethers.toBeHex(((1n << 96n) - 1n) << 160n)
*/
uint256 bitmask = 0xffffffffffffffffffffffff0000000000000000000000000000000000000000;
uint256 nameHash = uint256(keccak256(bytes(name)));
uint256 salt = (nameHash & bitmask) + uint160(msg.sender);
/*
* Beacon proxy is created without providing encoded initializer data,
* making constructor bytes always the same. This simplifies counterfactual address
* calculation.
*/
BeaconProxy proxy = new BeaconProxy{ salt: bytes32(salt) }( address(_fundsStorageBeacon), new bytes(0));
FundsStorageLogic(address(proxy)).initialize(address(this), token, name, fundingMode);
_fundsStorageInstances[address(proxy)].isInstance = true;
emit FundsStorageCreated(token, address(proxy), name);
return address(proxy);
}
/// @inheritdoc IFundsStorageFactory
function isFundsStorage(address addr) public view returns(bool) {
return _fundsStorageInstances[addr].isInstance;
}
/// @inheritdoc IFundsAdmin
function getSettlementNonce(address fundsStorage) public view returns(uint256) {
return _fundsStorageSettlementNonce[fundsStorage];
}
/// @inheritdoc IFundsAdmin
function settle(
address from,
uint256 amount,
uint256 nonce,
bytes32 merkleRoot
) external onlyRole(SETTLER_ROLE) whenNotPaused {
/*
* The bytes32(0) is required for forwards compatibility. In future, when
* merkle withdraw is implemented, the bytes32(0) merkle root will be
* disallowed.
*/
if(merkleRoot != bytes32(0)) revert MerkleRootInvalid();
IFundsStorage fundsStorage = _requireFundsStorage(from);
if(nonce != _fundsStorageSettlementNonce[from] + 1) revert NonceOutOfSequence();
fundsStorage.transferToSettlementAddress(amount);
_fundsStorageSettlementNonce[from] = nonce;
emit Settlement(from, amount, nonce);
}
/// @inheritdoc IFundsAdmin
function addStorageLiquidity(
address refundee,
address sourceAddress,
uint256 amount,
uint256 nonce,
bytes32 merkleRoot
) external onlyRole(SETTLER_ROLE) whenNotPaused {
if(merkleRoot != bytes32(0)) revert MerkleRootInvalid();
if(nonce != _fundsStorageSettlementNonce[refundee] + 1) revert NonceOutOfSequence();
IFundsStorage fundsStorage = _requireFundsStorage(refundee);
address tokenAddress = fundsStorage.getToken();
_requireTokenSupported(tokenAddress);
fundsStorage.addStorageLiquidity(sourceAddress, amount);
_fundsStorageSettlementNonce[refundee] = nonce;
emit StorageLiquidityAdded(refundee, sourceAddress, amount, nonce);
}
/// @inheritdoc IFundsAdmin
function directSpendDebit(
address storageAddress,
address spender,
uint256 amount,
bytes32 idempotencyKey
) external onlyRole(SETTLER_ROLE) whenNotPaused {
_requireDirectSpendEnabled();
IFundsStorage fundsStorage = _requireFundsStorage(storageAddress);
fundsStorage.directSpendDebit(spender, amount, idempotencyKey);
}
/// @inheritdoc IFundsAdmin
function directSpendGetTransaction(address storageAddress, bytes32 idempotencyKey) external view returns(DirectSpendTransaction memory) {
IFundsStorage fundsStorage = _requireFundsStorage(storageAddress);
return fundsStorage.directSpendGetTransaction(idempotencyKey);
}
/// @inheritdoc IFundsAdmin
function directSpendRefund(
address storageAddress,
address destinationAddress,
address sourceAddress,
uint256 amount,
bytes32 idempotencyKey
) external onlyRole(SETTLER_ROLE) whenNotPaused {
_requireDirectSpendEnabled();
IFundsStorage fundsStorage = _requireFundsStorage(storageAddress);
fundsStorage.directSpendRefund(destinationAddress, sourceAddress, amount, idempotencyKey);
IERC20 erc20 = IERC20(fundsStorage.getToken());
SafeERC20.safeTransferFrom(erc20, sourceAddress, destinationAddress, amount);
}
/// @inheritdoc IFundsAdmin
function directSpendReverse(
address storageAddress,
bytes32 originalIdempotencyKey,
uint256 amount,
bytes32 idempotencyKey
) external onlyRole(SETTLER_ROLE) whenNotPaused {
_requireDirectSpendEnabled();
IFundsStorage fundsStorage = _requireFundsStorage(storageAddress);
fundsStorage.directSpendReverse(originalIdempotencyKey, amount, idempotencyKey);
}
/**
* @notice Verifies that the token is supported by the admin contract.
* To be able to support a token, it's settlement address needs to be set
* by {setSettlementAddress}
* @param token The ERC-20 token to verify
*/
function _requireTokenSupported(address token) internal view {
if (_tokenSettlementAddress[token] == address(0)) revert TokenNotSupported({ token: token });
}
function _requireDirectSpendEnabled() internal view {
if (!_directSpendEnabled) revert DirectSpendDisabled();
}
function _requireFundsStorage(address storageAddress) internal view returns (IFundsStorage) {
if(!isFundsStorage(storageAddress)) revert StorageAccountInvalid(storageAddress);
return IFundsStorage(storageAddress);
}
/// @inheritdoc IFundsAdmin
function setSettlementAddress(address token, address settlementAddress) external onlyRole(DEFAULT_ADMIN_ROLE) {
_tokenSettlementAddress[token] = settlementAddress;
}
/// @inheritdoc IFundsAdmin
function getSettlementAddress(address token) external view returns(address) {
return _tokenSettlementAddress[token];
}
/// @inheritdoc IFundsAdmin
function transferDefaultAdminRole(address adminAccount) external onlyRole(DEFAULT_ADMIN_ROLE) {
_grantRole(DEFAULT_ADMIN_ROLE, adminAccount);
_revokeRole(DEFAULT_ADMIN_ROLE, msg.sender);
}
/**
* @dev Prevents direct role assignment. Use specific grant functions instead
*/
function grantRole(bytes32 /*role*/, address /*account*/) public pure override(AccessControlUpgradeable, IAccessControl) {
revert OperationUnsupported();
}
/**
* @dev Prevents direct role revocation. Use specific revoke functions instead
*/
function revokeRole(bytes32 /*role*/, address /*account*/) public pure override(AccessControlUpgradeable, IAccessControl) {
revert OperationUnsupported();
}
/// @inheritdoc IFundsAdmin
function grantWithdrawalSignerRole(address withdrawalSigner) external onlyRole(DEFAULT_ADMIN_ROLE) {
_grantRole(WITHDRAWAL_SIGNER_ROLE, withdrawalSigner);
}
/// @inheritdoc IFundsAdmin
function revokeWithdrawalSignerRole(address withdrawalSigner) external onlyRole(DEFAULT_ADMIN_ROLE) {
_revokeRole(WITHDRAWAL_SIGNER_ROLE, withdrawalSigner);
}
/// @inheritdoc IFundsAdmin
function grantSettlerRole(address settlerAddress) external onlyRole(DEFAULT_ADMIN_ROLE) {
_grantRole(SETTLER_ROLE, settlerAddress);
}
/// @inheritdoc IFundsAdmin
function revokeSettlerRole(address settlerAddress) external onlyRole(DEFAULT_ADMIN_ROLE) {
_revokeRole(SETTLER_ROLE, settlerAddress);
}
/// @inheritdoc IFundsAdmin
// solhint-disable-next-line private-vars-leading-underscore
function _requireWithdrawalSignerAuthorized(address signerAuthorizer) external view whenNotPaused {
if (!hasRole(WITHDRAWAL_SIGNER_ROLE, signerAuthorizer)) revert SignatureUnauthorized();
}
/// @inheritdoc IFundsAdmin
function pause() external onlyRole(DEFAULT_ADMIN_ROLE) {
_pause();
}
/// @inheritdoc IFundsAdmin
function unpause() external onlyRole(DEFAULT_ADMIN_ROLE) {
_unpause();
}
/// @inheritdoc IFundsAdmin
function enableDirectSpend() external onlyRole(DEFAULT_ADMIN_ROLE) {
_directSpendEnabled = true;
}
/// @inheritdoc IFundsAdmin
function disableDirectSpend() external onlyRole(DEFAULT_ADMIN_ROLE) {
_directSpendEnabled = false;
}
function setDirectSpendReversalCutoffSeconds(uint256 expiry) external onlyRole(DEFAULT_ADMIN_ROLE) {
_directSpendReversalCutoffSeconds = expiry;
}
function getDirectSpendReversalCutoffSeconds() external view returns(uint256) {
return _directSpendReversalCutoffSeconds;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)
pragma solidity ^0.8.20;
import {IAccessControl} from "@openzeppelin/contracts/access/IAccessControl.sol";
import {ContextUpgradeable} from "../utils/ContextUpgradeable.sol";
import {ERC165Upgradeable} from "../utils/introspection/ERC165Upgradeable.sol";
import {Initializable} from "../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:
*
* ```solidity
* bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
* ```
*
* Roles can be used to represent a set of permissions. To restrict access to a
* function call, use {hasRole}:
*
* ```solidity
* function foo() public {
* require(hasRole(MY_ROLE, msg.sender));
* ...
* }
* ```
*
* Roles can be granted and revoked dynamically via the {grantRole} and
* {revokeRole} functions. Each role has an associated admin role, and only
* accounts that have a role's admin role can call {grantRole} and {revokeRole}.
*
* By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
* that only accounts with this role will be able to grant or revoke other
* roles. More complex role relationships can be created by using
* {_setRoleAdmin}.
*
* WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
* grant and revoke this role. Extra precautions should be taken to secure
* accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}
* to enforce additional security measures for this role.
*/
abstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControl, ERC165Upgradeable {
struct RoleData {
mapping(address account => bool) hasRole;
bytes32 adminRole;
}
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
/// @custom:storage-location erc7201:openzeppelin.storage.AccessControl
struct AccessControlStorage {
mapping(bytes32 role => RoleData) _roles;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.AccessControl")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant AccessControlStorageLocation = 0x02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800;
function _getAccessControlStorage() private pure returns (AccessControlStorage storage $) {
assembly {
$.slot := AccessControlStorageLocation
}
}
/**
* @dev Modifier that checks that an account has a specific role. Reverts
* with an {AccessControlUnauthorizedAccount} error including the required role.
*/
modifier onlyRole(bytes32 role) {
_checkRole(role);
_;
}
function __AccessControl_init() internal onlyInitializing {
}
function __AccessControl_init_unchained() internal onlyInitializing {
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) public view virtual returns (bool) {
AccessControlStorage storage $ = _getAccessControlStorage();
return $._roles[role].hasRole[account];
}
/**
* @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`
* is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.
*/
function _checkRole(bytes32 role) internal view virtual {
_checkRole(role, _msgSender());
}
/**
* @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`
* is missing `role`.
*/
function _checkRole(bytes32 role, address account) internal view virtual {
if (!hasRole(role, account)) {
revert AccessControlUnauthorizedAccount(account, role);
}
}
/**
* @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 returns (bytes32) {
AccessControlStorage storage $ = _getAccessControlStorage();
return $._roles[role].adminRole;
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*
* May emit a {RoleGranted} event.
*/
function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {
_grantRole(role, account);
}
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*
* May emit a {RoleRevoked} event.
*/
function revokeRole(bytes32 role, address account) public virtual 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 `callerConfirmation`.
*
* May emit a {RoleRevoked} event.
*/
function renounceRole(bytes32 role, address callerConfirmation) public virtual {
if (callerConfirmation != _msgSender()) {
revert AccessControlBadConfirmation();
}
_revokeRole(role, callerConfirmation);
}
/**
* @dev Sets `adminRole` as ``role``'s admin role.
*
* Emits a {RoleAdminChanged} event.
*/
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
AccessControlStorage storage $ = _getAccessControlStorage();
bytes32 previousAdminRole = getRoleAdmin(role);
$._roles[role].adminRole = adminRole;
emit RoleAdminChanged(role, previousAdminRole, adminRole);
}
/**
* @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.
*
* Internal function without access restriction.
*
* May emit a {RoleGranted} event.
*/
function _grantRole(bytes32 role, address account) internal virtual returns (bool) {
AccessControlStorage storage $ = _getAccessControlStorage();
if (!hasRole(role, account)) {
$._roles[role].hasRole[account] = true;
emit RoleGranted(role, account, _msgSender());
return true;
} else {
return false;
}
}
/**
* @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.
*
* Internal function without access restriction.
*
* May emit a {RoleRevoked} event.
*/
function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {
AccessControlStorage storage $ = _getAccessControlStorage();
if (hasRole(role, account)) {
$._roles[role].hasRole[account] = false;
emit RoleRevoked(role, account, _msgSender());
return true;
} else {
return false;
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/Initializable.sol)
pragma solidity ^0.8.20;
/**
* @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
* behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
* external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
* function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
*
* The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
* reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
* case an upgrade adds a module that needs to be initialized.
*
* For example:
*
* [.hljs-theme-light.nopadding]
* ```solidity
* contract MyToken is ERC20Upgradeable {
* function initialize() initializer public {
* __ERC20_init("MyToken", "MTK");
* }
* }
*
* contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
* function initializeV2() reinitializer(2) public {
* __ERC20Permit_init("MyToken");
* }
* }
* ```
*
* TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
* possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
*
* CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
* that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
*
* [CAUTION]
* ====
* Avoid leaving a contract uninitialized.
*
* An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
* contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
* the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
*
* [.hljs-theme-light.nopadding]
* ```
* /// @custom:oz-upgrades-unsafe-allow constructor
* constructor() {
* _disableInitializers();
* }
* ```
* ====
*/
abstract contract Initializable {
/**
* @dev Storage of the initializable contract.
*
* It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions
* when using with upgradeable contracts.
*
* @custom:storage-location erc7201:openzeppelin.storage.Initializable
*/
struct InitializableStorage {
/**
* @dev Indicates that the contract has been initialized.
*/
uint64 _initialized;
/**
* @dev Indicates that the contract is in the process of being initialized.
*/
bool _initializing;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Initializable")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00;
/**
* @dev The contract is already initialized.
*/
error InvalidInitialization();
/**
* @dev The contract is not initializing.
*/
error NotInitializing();
/**
* @dev Triggered when the contract has been initialized or reinitialized.
*/
event Initialized(uint64 version);
/**
* @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
* `onlyInitializing` functions can be used to initialize parent contracts.
*
* Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any
* number of times. This behavior in the constructor can be useful during testing and is not expected to be used in
* production.
*
* Emits an {Initialized} event.
*/
modifier initializer() {
// solhint-disable-next-line var-name-mixedcase
InitializableStorage storage $ = _getInitializableStorage();
// Cache values to avoid duplicated sloads
bool isTopLevelCall = !$._initializing;
uint64 initialized = $._initialized;
// Allowed calls:
// - initialSetup: the contract is not in the initializing state and no previous version was
// initialized
// - construction: the contract is initialized at version 1 (no reininitialization) and the
// current contract is just being deployed
bool initialSetup = initialized == 0 && isTopLevelCall;
bool construction = initialized == 1 && address(this).code.length == 0;
if (!initialSetup && !construction) {
revert InvalidInitialization();
}
$._initialized = 1;
if (isTopLevelCall) {
$._initializing = true;
}
_;
if (isTopLevelCall) {
$._initializing = false;
emit Initialized(1);
}
}
/**
* @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
* contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
* used to initialize parent contracts.
*
* A reinitializer may be used after the original initialization step. This is essential to configure modules that
* are added through upgrades and that require initialization.
*
* When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
* cannot be nested. If one is invoked in the context of another, execution will revert.
*
* Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
* a contract, executing them in the right order is up to the developer or operator.
*
* WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization.
*
* Emits an {Initialized} event.
*/
modifier reinitializer(uint64 version) {
// solhint-disable-next-line var-name-mixedcase
InitializableStorage storage $ = _getInitializableStorage();
if ($._initializing || $._initialized >= version) {
revert InvalidInitialization();
}
$._initialized = version;
$._initializing = true;
_;
$._initializing = false;
emit Initialized(version);
}
/**
* @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
* {initializer} and {reinitializer} modifiers, directly or indirectly.
*/
modifier onlyInitializing() {
_checkInitializing();
_;
}
/**
* @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}.
*/
function _checkInitializing() internal view virtual {
if (!_isInitializing()) {
revert NotInitializing();
}
}
/**
* @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
* Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
* to any version. It is recommended to use this to lock implementation contracts that are designed to be called
* through proxies.
*
* Emits an {Initialized} event the first time it is successfully executed.
*/
function _disableInitializers() internal virtual {
// solhint-disable-next-line var-name-mixedcase
InitializableStorage storage $ = _getInitializableStorage();
if ($._initializing) {
revert InvalidInitialization();
}
if ($._initialized != type(uint64).max) {
$._initialized = type(uint64).max;
emit Initialized(type(uint64).max);
}
}
/**
* @dev Returns the highest version that has been initialized. See {reinitializer}.
*/
function _getInitializedVersion() internal view returns (uint64) {
return _getInitializableStorage()._initialized;
}
/**
* @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.
*/
function _isInitializing() internal view returns (bool) {
return _getInitializableStorage()._initializing;
}
/**
* @dev Returns a pointer to the storage namespace.
*/
// solhint-disable-next-line var-name-mixedcase
function _getInitializableStorage() private pure returns (InitializableStorage storage $) {
assembly {
$.slot := INITIALIZABLE_STORAGE
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/UUPSUpgradeable.sol)
pragma solidity ^0.8.20;
import {IERC1822Proxiable} from "@openzeppelin/contracts/interfaces/draft-IERC1822.sol";
import {ERC1967Utils} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Utils.sol";
import {Initializable} from "./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.
*/
abstract contract UUPSUpgradeable is Initializable, IERC1822Proxiable {
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable
address private immutable __self = address(this);
/**
* @dev The version of the upgrade interface of the contract. If this getter is missing, both `upgradeTo(address)`
* and `upgradeToAndCall(address,bytes)` are present, and `upgradeTo` must be used if no function should be called,
* while `upgradeToAndCall` will invoke the `receive` function if the second argument is the empty byte string.
* If the getter returns `"5.0.0"`, only `upgradeToAndCall(address,bytes)` is present, and the second argument must
* be the empty byte string if no function should be called, making it impossible to invoke the `receive` function
* during an upgrade.
*/
string public constant UPGRADE_INTERFACE_VERSION = "5.0.0";
/**
* @dev The call is from an unauthorized context.
*/
error UUPSUnauthorizedCallContext();
/**
* @dev The storage `slot` is unsupported as a UUID.
*/
error UUPSUnsupportedProxiableUUID(bytes32 slot);
/**
* @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() {
_checkProxy();
_;
}
/**
* @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() {
_checkNotDelegated();
_;
}
function __UUPSUpgradeable_init() internal onlyInitializing {
}
function __UUPSUpgradeable_init_unchained() internal onlyInitializing {
}
/**
* @dev Implementation of the ERC1822 {proxiableUUID} function. This returns the storage slot used by the
* implementation. It is used to validate the implementation's compatibility when performing an upgrade.
*
* IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
* bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
* function revert if invoked through a proxy. This is guaranteed by the `notDelegated` modifier.
*/
function proxiableUUID() external view virtual notDelegated returns (bytes32) {
return ERC1967Utils.IMPLEMENTATION_SLOT;
}
/**
* @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call
* encoded in `data`.
*
* Calls {_authorizeUpgrade}.
*
* Emits an {Upgraded} event.
*
* @custom:oz-upgrades-unsafe-allow-reachable delegatecall
*/
function upgradeToAndCall(address newImplementation, bytes memory data) public payable virtual onlyProxy {
_authorizeUpgrade(newImplementation);
_upgradeToAndCallUUPS(newImplementation, data);
}
/**
* @dev Reverts if the execution is not performed via delegatecall or the execution
* context is not of a proxy with an ERC1967-compliant implementation pointing to self.
* See {_onlyProxy}.
*/
function _checkProxy() internal view virtual {
if (
address(this) == __self || // Must be called through delegatecall
ERC1967Utils.getImplementation() != __self // Must be called through an active proxy
) {
revert UUPSUnauthorizedCallContext();
}
}
/**
* @dev Reverts if the execution is performed via delegatecall.
* See {notDelegated}.
*/
function _checkNotDelegated() internal view virtual {
if (address(this) != __self) {
// Must not be called through delegatecall
revert UUPSUnauthorizedCallContext();
}
}
/**
* @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by
* {upgradeToAndCall}.
*
* Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}.
*
* ```solidity
* function _authorizeUpgrade(address) internal onlyOwner {}
* ```
*/
function _authorizeUpgrade(address newImplementation) internal virtual;
/**
* @dev Performs an implementation upgrade with a security check for UUPS proxies, and additional setup call.
*
* As a security check, {proxiableUUID} is invoked in the new implementation, and the return value
* is expected to be the implementation slot in ERC1967.
*
* Emits an {IERC1967-Upgraded} event.
*/
function _upgradeToAndCallUUPS(address newImplementation, bytes memory data) private {
try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {
if (slot != ERC1967Utils.IMPLEMENTATION_SLOT) {
revert UUPSUnsupportedProxiableUUID(slot);
}
ERC1967Utils.upgradeToAndCall(newImplementation, data);
} catch {
// The implementation is not UUPS
revert ERC1967Utils.ERC1967InvalidImplementation(newImplementation);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)
pragma solidity ^0.8.20;
import {Initializable} from "../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;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/EIP712.sol)
pragma solidity ^0.8.20;
import {MessageHashUtils} from "@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol";
import {IERC5267} from "@openzeppelin/contracts/interfaces/IERC5267.sol";
import {Initializable} from "../../proxy/utils/Initializable.sol";
/**
* @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data.
*
* The encoding scheme specified in the EIP requires a domain separator and a hash of the typed structured data, whose
* encoding is very generic and therefore its implementation in Solidity is not feasible, thus this contract
* does not implement the encoding itself. Protocols need to implement the type-specific encoding they need in order to
* produce the hash of their typed data using a combination of `abi.encode` and `keccak256`.
*
* This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding
* scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA
* ({_hashTypedDataV4}).
*
* The implementation of the domain separator was designed to be as efficient as possible while still properly updating
* the chain id to protect against replay attacks on an eventual fork of the chain.
*
* NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method
* https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].
*
* NOTE: In the upgradeable version of this contract, the cached values will correspond to the address, and the domain
* separator of the implementation contract. This will cause the {_domainSeparatorV4} function to always rebuild the
* separator from the immutable values, which is cheaper than accessing a cached version in cold storage.
*/
abstract contract EIP712Upgradeable is Initializable, IERC5267 {
bytes32 private constant TYPE_HASH =
keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)");
/// @custom:storage-location erc7201:openzeppelin.storage.EIP712
struct EIP712Storage {
/// @custom:oz-renamed-from _HASHED_NAME
bytes32 _hashedName;
/// @custom:oz-renamed-from _HASHED_VERSION
bytes32 _hashedVersion;
string _name;
string _version;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.EIP712")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant EIP712StorageLocation = 0xa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d100;
function _getEIP712Storage() private pure returns (EIP712Storage storage $) {
assembly {
$.slot := EIP712StorageLocation
}
}
/**
* @dev Initializes the domain separator and parameter caches.
*
* The meaning of `name` and `version` is specified in
* https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]:
*
* - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.
* - `version`: the current major version of the signing domain.
*
* NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart
* contract upgrade].
*/
function __EIP712_init(string memory name, string memory version) internal onlyInitializing {
__EIP712_init_unchained(name, version);
}
function __EIP712_init_unchained(string memory name, string memory version) internal onlyInitializing {
EIP712Storage storage $ = _getEIP712Storage();
$._name = name;
$._version = version;
// Reset prior values in storage if upgrading
$._hashedName = 0;
$._hashedVersion = 0;
}
/**
* @dev Returns the domain separator for the current chain.
*/
function _domainSeparatorV4() internal view returns (bytes32) {
return _buildDomainSeparator();
}
function _buildDomainSeparator() private view returns (bytes32) {
return keccak256(abi.encode(TYPE_HASH, _EIP712NameHash(), _EIP712VersionHash(), block.chainid, address(this)));
}
/**
* @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this
* function returns the hash of the fully encoded EIP712 message for this domain.
*
* This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:
*
* ```solidity
* bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(
* keccak256("Mail(address to,string contents)"),
* mailTo,
* keccak256(bytes(mailContents))
* )));
* address signer = ECDSA.recover(digest, signature);
* ```
*/
function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {
return MessageHashUtils.toTypedDataHash(_domainSeparatorV4(), structHash);
}
/**
* @dev See {IERC-5267}.
*/
function eip712Domain()
public
view
virtual
returns (
bytes1 fields,
string memory name,
string memory version,
uint256 chainId,
address verifyingContract,
bytes32 salt,
uint256[] memory extensions
)
{
EIP712Storage storage $ = _getEIP712Storage();
// If the hashed name and version in storage are non-zero, the contract hasn't been properly initialized
// and the EIP712 domain is not reliable, as it will be missing name and version.
require($._hashedName == 0 && $._hashedVersion == 0, "EIP712: Uninitialized");
return (
hex"0f", // 01111
_EIP712Name(),
_EIP712Version(),
block.chainid,
address(this),
bytes32(0),
new uint256[](0)
);
}
/**
* @dev The name parameter for the EIP712 domain.
*
* NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs
* are a concern.
*/
function _EIP712Name() internal view virtual returns (string memory) {
EIP712Storage storage $ = _getEIP712Storage();
return $._name;
}
/**
* @dev The version parameter for the EIP712 domain.
*
* NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs
* are a concern.
*/
function _EIP712Version() internal view virtual returns (string memory) {
EIP712Storage storage $ = _getEIP712Storage();
return $._version;
}
/**
* @dev The hash of the name parameter for the EIP712 domain.
*
* NOTE: In previous versions this function was virtual. In this version you should override `_EIP712Name` instead.
*/
function _EIP712NameHash() internal view returns (bytes32) {
EIP712Storage storage $ = _getEIP712Storage();
string memory name = _EIP712Name();
if (bytes(name).length > 0) {
return keccak256(bytes(name));
} else {
// If the name is empty, the contract may have been upgraded without initializing the new storage.
// We return the name hash in storage if non-zero, otherwise we assume the name is empty by design.
bytes32 hashedName = $._hashedName;
if (hashedName != 0) {
return hashedName;
} else {
return keccak256("");
}
}
}
/**
* @dev The hash of the version parameter for the EIP712 domain.
*
* NOTE: In previous versions this function was virtual. In this version you should override `_EIP712Version` instead.
*/
function _EIP712VersionHash() internal view returns (bytes32) {
EIP712Storage storage $ = _getEIP712Storage();
string memory version = _EIP712Version();
if (bytes(version).length > 0) {
return keccak256(bytes(version));
} else {
// If the version is empty, the contract may have been upgraded without initializing the new storage.
// We return the version hash in storage if non-zero, otherwise we assume the version is empty by design.
bytes32 hashedVersion = $._hashedVersion;
if (hashedVersion != 0) {
return hashedVersion;
} else {
return keccak256("");
}
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)
pragma solidity ^0.8.20;
import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
import {Initializable} from "../../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);
* }
* ```
*/
abstract contract ERC165Upgradeable is Initializable, IERC165 {
function __ERC165_init() internal onlyInitializing {
}
function __ERC165_init_unchained() internal onlyInitializing {
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Pausable.sol)
pragma solidity ^0.8.20;
import {ContextUpgradeable} from "../utils/ContextUpgradeable.sol";
import {Initializable} from "../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 {
/// @custom:storage-location erc7201:openzeppelin.storage.Pausable
struct PausableStorage {
bool _paused;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Pausable")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant PausableStorageLocation = 0xcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f03300;
function _getPausableStorage() private pure returns (PausableStorage storage $) {
assembly {
$.slot := PausableStorageLocation
}
}
/**
* @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);
/**
* @dev The operation failed because the contract is paused.
*/
error EnforcedPause();
/**
* @dev The operation failed because the contract is not paused.
*/
error ExpectedPause();
/**
* @dev Initializes the contract in unpaused state.
*/
function __Pausable_init() internal onlyInitializing {
__Pausable_init_unchained();
}
function __Pausable_init_unchained() internal onlyInitializing {
PausableStorage storage $ = _getPausableStorage();
$._paused = false;
}
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*
* Requirements:
*
* - The contract must not be paused.
*/
modifier whenNotPaused() {
_requireNotPaused();
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*
* Requirements:
*
* - The contract must be paused.
*/
modifier whenPaused() {
_requirePaused();
_;
}
/**
* @dev Returns true if the contract is paused, and false otherwise.
*/
function paused() public view virtual returns (bool) {
PausableStorage storage $ = _getPausableStorage();
return $._paused;
}
/**
* @dev Throws if the contract is paused.
*/
function _requireNotPaused() internal view virtual {
if (paused()) {
revert EnforcedPause();
}
}
/**
* @dev Throws if the contract is not paused.
*/
function _requirePaused() internal view virtual {
if (!paused()) {
revert ExpectedPause();
}
}
/**
* @dev Triggers stopped state.
*
* Requirements:
*
* - The contract must not be paused.
*/
function _pause() internal virtual whenNotPaused {
PausableStorage storage $ = _getPausableStorage();
$._paused = true;
emit Paused(_msgSender());
}
/**
* @dev Returns to normal state.
*
* Requirements:
*
* - The contract must be paused.
*/
function _unpause() internal virtual whenPaused {
PausableStorage storage $ = _getPausableStorage();
$._paused = false;
emit Unpaused(_msgSender());
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/ReentrancyGuard.sol)
pragma solidity ^0.8.20;
import {Initializable} from "../proxy/utils/Initializable.sol";
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuardUpgradeable is Initializable {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant NOT_ENTERED = 1;
uint256 private constant ENTERED = 2;
/// @custom:storage-location erc7201:openzeppelin.storage.ReentrancyGuard
struct ReentrancyGuardStorage {
uint256 _status;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.ReentrancyGuard")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant ReentrancyGuardStorageLocation = 0x9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00;
function _getReentrancyGuardStorage() private pure returns (ReentrancyGuardStorage storage $) {
assembly {
$.slot := ReentrancyGuardStorageLocation
}
}
/**
* @dev Unauthorized reentrant call.
*/
error ReentrancyGuardReentrantCall();
function __ReentrancyGuard_init() internal onlyInitializing {
__ReentrancyGuard_init_unchained();
}
function __ReentrancyGuard_init_unchained() internal onlyInitializing {
ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage();
$._status = NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage();
// On the first call to nonReentrant, _status will be NOT_ENTERED
if ($._status == ENTERED) {
revert ReentrancyGuardReentrantCall();
}
// Any calls to nonReentrant after this point will fail
$._status = ENTERED;
}
function _nonReentrantAfter() private {
ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage();
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
$._status = NOT_ENTERED;
}
/**
* @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
* `nonReentrant` function in the call stack.
*/
function _reentrancyGuardEntered() internal view returns (bool) {
ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage();
return $._status == ENTERED;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)
pragma solidity ^0.8.20;
/**
* @dev External interface of AccessControl declared to support ERC165 detection.
*/
interface IAccessControl {
/**
* @dev The `account` is missing a role.
*/
error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);
/**
* @dev The caller of a function is not the expected one.
*
* NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.
*/
error AccessControlBadConfirmation();
/**
* @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.
*/
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 `callerConfirmation`.
*/
function renounceRole(bytes32 role, address callerConfirmation) external;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)
pragma solidity ^0.8.20;
import {Context} from "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* The initial owner is set to the address provided by the deployer. This can
* later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
/**
* @dev The caller account is not authorized to perform an operation.
*/
error OwnableUnauthorizedAccount(address account);
/**
* @dev The owner is not a valid owner account. (eg. `address(0)`)
*/
error OwnableInvalidOwner(address owner);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the address provided by the deployer as the initial owner.
*/
constructor(address initialOwner) {
if (initialOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(initialOwner);
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
if (owner() != _msgSender()) {
revert OwnableUnauthorizedAccount(_msgSender());
}
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
if (newOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/draft-IERC1822.sol)
pragma solidity ^0.8.20;
/**
* @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified
* proxy whose upgrades are fully controlled by the current implementation.
*/
interface IERC1822Proxiable {
/**
* @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation
* address.
*
* IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
* bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
* function revert if invoked through a proxy.
*/
function proxiableUUID() external view returns (bytes32);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC5267.sol)
pragma solidity ^0.8.20;
interface IERC5267 {
/**
* @dev MAY be emitted to signal that the domain could have changed.
*/
event EIP712DomainChanged();
/**
* @dev returns the fields and values that describe the domain separator used by this contract for EIP-712
* signature.
*/
function eip712Domain()
external
view
returns (
bytes1 fields,
string memory name,
string memory version,
uint256 chainId,
address verifyingContract,
bytes32 salt,
uint256[] memory extensions
);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (proxy/beacon/BeaconProxy.sol)
pragma solidity ^0.8.20;
import {IBeacon} from "./IBeacon.sol";
import {Proxy} from "../Proxy.sol";
import {ERC1967Utils} from "../ERC1967/ERC1967Utils.sol";
/**
* @dev This contract implements a proxy that gets the implementation address for each call from an {UpgradeableBeacon}.
*
* The beacon address can only be set once during construction, and cannot be changed afterwards. It is stored in an
* immutable variable to avoid unnecessary storage reads, and also in the beacon storage slot specified by
* https://eips.ethereum.org/EIPS/eip-1967[EIP1967] so that it can be accessed externally.
*
* CAUTION: Since the beacon address can never be changed, you must ensure that you either control the beacon, or trust
* the beacon to not upgrade the implementation maliciously.
*
* IMPORTANT: Do not use the implementation logic to modify the beacon storage slot. Doing so would leave the proxy in
* an inconsistent state where the beacon storage slot does not match the beacon address.
*/
contract BeaconProxy is Proxy {
// An immutable address for the beacon to avoid unnecessary SLOADs before each delegate call.
address private immutable _beacon;
/**
* @dev Initializes the proxy with `beacon`.
*
* If `data` is nonempty, it's used as data in a delegate call to the implementation returned by the beacon. This
* will typically be an encoded function call, and allows initializing the storage of the proxy like a Solidity
* constructor.
*
* Requirements:
*
* - `beacon` must be a contract with the interface {IBeacon}.
* - If `data` is empty, `msg.value` must be zero.
*/
constructor(address beacon, bytes memory data) payable {
ERC1967Utils.upgradeBeaconToAndCall(beacon, data);
_beacon = beacon;
}
/**
* @dev Returns the current implementation address of the associated beacon.
*/
function _implementation() internal view virtual override returns (address) {
return IBeacon(_getBeacon()).implementation();
}
/**
* @dev Returns the beacon.
*/
function _getBeacon() internal view virtual returns (address) {
return _beacon;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (proxy/beacon/IBeacon.sol)
pragma solidity ^0.8.20;
/**
* @dev This is the interface that {BeaconProxy} expects of its beacon.
*/
interface IBeacon {
/**
* @dev Must return an address that can be used as a delegate call target.
*
* {UpgradeableBeacon} will check that this address is a contract.
*/
function implementation() external view returns (address);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (proxy/beacon/UpgradeableBeacon.sol)
pragma solidity ^0.8.20;
import {IBeacon} from "./IBeacon.sol";
import {Ownable} from "../../access/Ownable.sol";
/**
* @dev This contract is used in conjunction with one or more instances of {BeaconProxy} to determine their
* implementation contract, which is where they will delegate all function calls.
*
* An owner is able to change the implementation the beacon points to, thus upgrading the proxies that use this beacon.
*/
contract UpgradeableBeacon is IBeacon, Ownable {
address private _implementation;
/**
* @dev The `implementation` of the beacon is invalid.
*/
error BeaconInvalidImplementation(address implementation);
/**
* @dev Emitted when the implementation returned by the beacon is changed.
*/
event Upgraded(address indexed implementation);
/**
* @dev Sets the address of the initial implementation, and the initial owner who can upgrade the beacon.
*/
constructor(address implementation_, address initialOwner) Ownable(initialOwner) {
_setImplementation(implementation_);
}
/**
* @dev Returns the current implementation address.
*/
function implementation() public view virtual returns (address) {
return _implementation;
}
/**
* @dev Upgrades the beacon to a new implementation.
*
* Emits an {Upgraded} event.
*
* Requirements:
*
* - msg.sender must be the owner of the contract.
* - `newImplementation` must be a contract.
*/
function upgradeTo(address newImplementation) public virtual onlyOwner {
_setImplementation(newImplementation);
}
/**
* @dev Sets the implementation contract address for this beacon
*
* Requirements:
*
* - `newImplementation` must be a contract.
*/
function _setImplementation(address newImplementation) private {
if (newImplementation.code.length == 0) {
revert BeaconInvalidImplementation(newImplementation);
}
_implementation = newImplementation;
emit Upgraded(newImplementation);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (proxy/ERC1967/ERC1967Proxy.sol)
pragma solidity ^0.8.20;
import {Proxy} from "../Proxy.sol";
import {ERC1967Utils} from "./ERC1967Utils.sol";
/**
* @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an
* implementation address that can be changed. This address is stored in storage in the location specified by
* https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the
* implementation behind the proxy.
*/
contract ERC1967Proxy is Proxy {
/**
* @dev Initializes the upgradeable proxy with an initial implementation specified by `implementation`.
*
* If `_data` is nonempty, it's used as data in a delegate call to `implementation`. This will typically be an
* encoded function call, and allows initializing the storage of the proxy like a Solidity constructor.
*
* Requirements:
*
* - If `data` is empty, `msg.value` must be zero.
*/
constructor(address implementation, bytes memory _data) payable {
ERC1967Utils.upgradeToAndCall(implementation, _data);
}
/**
* @dev Returns the current implementation address.
*
* TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using
* the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.
* `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`
*/
function _implementation() internal view virtual override returns (address) {
return ERC1967Utils.getImplementation();
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (proxy/ERC1967/ERC1967Utils.sol)
pragma solidity ^0.8.20;
import {IBeacon} from "../beacon/IBeacon.sol";
import {Address} from "../../utils/Address.sol";
import {StorageSlot} from "../../utils/StorageSlot.sol";
/**
* @dev This abstract contract provides getters and event emitting update functions for
* https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.
*/
library ERC1967Utils {
// We re-declare ERC-1967 events here because they can't be used directly from IERC1967.
// This will be fixed in Solidity 0.8.21. At that point we should remove these events.
/**
* @dev Emitted when the implementation is upgraded.
*/
event Upgraded(address indexed implementation);
/**
* @dev Emitted when the admin account has changed.
*/
event AdminChanged(address previousAdmin, address newAdmin);
/**
* @dev Emitted when the beacon is changed.
*/
event BeaconUpgraded(address indexed beacon);
/**
* @dev Storage slot with the address of the current implementation.
* This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1.
*/
// solhint-disable-next-line private-vars-leading-underscore
bytes32 internal constant IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
/**
* @dev The `implementation` of the proxy is invalid.
*/
error ERC1967InvalidImplementation(address implementation);
/**
* @dev The `admin` of the proxy is invalid.
*/
error ERC1967InvalidAdmin(address admin);
/**
* @dev The `beacon` of the proxy is invalid.
*/
error ERC1967InvalidBeacon(address beacon);
/**
* @dev An upgrade function sees `msg.value > 0` that may be lost.
*/
error ERC1967NonPayable();
/**
* @dev Returns the current implementation address.
*/
function getImplementation() internal view returns (address) {
return StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value;
}
/**
* @dev Stores a new address in the EIP1967 implementation slot.
*/
function _setImplementation(address newImplementation) private {
if (newImplementation.code.length == 0) {
revert ERC1967InvalidImplementation(newImplementation);
}
StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value = newImplementation;
}
/**
* @dev Performs implementation upgrade with additional setup call if data is nonempty.
* This function is payable only if the setup call is performed, otherwise `msg.value` is rejected
* to avoid stuck value in the contract.
*
* Emits an {IERC1967-Upgraded} event.
*/
function upgradeToAndCall(address newImplementation, bytes memory data) internal {
_setImplementation(newImplementation);
emit Upgraded(newImplementation);
if (data.length > 0) {
Address.functionDelegateCall(newImplementation, data);
} else {
_checkNonPayable();
}
}
/**
* @dev Storage slot with the admin of the contract.
* This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1.
*/
// solhint-disable-next-line private-vars-leading-underscore
bytes32 internal constant ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
/**
* @dev Returns the current admin.
*
* TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using
* the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.
* `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`
*/
function getAdmin() internal view returns (address) {
return StorageSlot.getAddressSlot(ADMIN_SLOT).value;
}
/**
* @dev Stores a new address in the EIP1967 admin slot.
*/
function _setAdmin(address newAdmin) private {
if (newAdmin == address(0)) {
revert ERC1967InvalidAdmin(address(0));
}
StorageSlot.getAddressSlot(ADMIN_SLOT).value = newAdmin;
}
/**
* @dev Changes the admin of the proxy.
*
* Emits an {IERC1967-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 the keccak-256 hash of "eip1967.proxy.beacon" subtracted by 1.
*/
// solhint-disable-next-line private-vars-leading-underscore
bytes32 internal constant BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;
/**
* @dev Returns the current beacon.
*/
function getBeacon() internal view returns (address) {
return StorageSlot.getAddressSlot(BEACON_SLOT).value;
}
/**
* @dev Stores a new beacon in the EIP1967 beacon slot.
*/
function _setBeacon(address newBeacon) private {
if (newBeacon.code.length == 0) {
revert ERC1967InvalidBeacon(newBeacon);
}
StorageSlot.getAddressSlot(BEACON_SLOT).value = newBeacon;
address beaconImplementation = IBeacon(newBeacon).implementation();
if (beaconImplementation.code.length == 0) {
revert ERC1967InvalidImplementation(beaconImplementation);
}
}
/**
* @dev Change the beacon and trigger a setup call if data is nonempty.
* This function is payable only if the setup call is performed, otherwise `msg.value` is rejected
* to avoid stuck value in the contract.
*
* Emits an {IERC1967-BeaconUpgraded} event.
*
* CAUTION: Invoking this function has no effect on an instance of {BeaconProxy} since v5, since
* it uses an immutable beacon without looking at the value of the ERC-1967 beacon slot for
* efficiency.
*/
function upgradeBeaconToAndCall(address newBeacon, bytes memory data) internal {
_setBeacon(newBeacon);
emit BeaconUpgraded(newBeacon);
if (data.length > 0) {
Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);
} else {
_checkNonPayable();
}
}
/**
* @dev Reverts if `msg.value` is not zero. It can be used to avoid `msg.value` stuck in the contract
* if an upgrade doesn't perform an initialization call.
*/
function _checkNonPayable() private {
if (msg.value > 0) {
revert ERC1967NonPayable();
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (proxy/Proxy.sol)
pragma solidity ^0.8.20;
/**
* @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM
* instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to
* be specified by overriding the virtual {_implementation} function.
*
* Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a
* different contract through the {_delegate} function.
*
* The success and return data of the delegated call will be returned back to the caller of the proxy.
*/
abstract contract Proxy {
/**
* @dev Delegates the current call to `implementation`.
*
* This function does not return to its internal call site, it will return directly to the external caller.
*/
function _delegate(address implementation) internal virtual {
assembly {
// Copy msg.data. We take full control of memory in this inline assembly
// block because it will not return to Solidity code. We overwrite the
// Solidity scratch pad at memory position 0.
calldatacopy(0, 0, calldatasize())
// Call the implementation.
// out and outsize are 0 because we don't know the size yet.
let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)
// Copy the returned data.
returndatacopy(0, 0, returndatasize())
switch result
// delegatecall returns 0 on error.
case 0 {
revert(0, returndatasize())
}
default {
return(0, returndatasize())
}
}
}
/**
* @dev This is a virtual function that should be overridden so it returns the address to which the fallback
* function and {_fallback} should delegate.
*/
function _implementation() internal view virtual returns (address);
/**
* @dev Delegates the current call to the address returned by `_implementation()`.
*
* This function does not return to its internal call site, it will return directly to the external caller.
*/
function _fallback() internal virtual {
_delegate(_implementation());
}
/**
* @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other
* function in the contract matches the call data.
*/
fallback() external payable virtual {
_fallback();
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Permit.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
* https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
*
* Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
* presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
* need to send a transaction, and thus is not required to hold Ether at all.
*
* ==== Security Considerations
*
* There are two important considerations concerning the use of `permit`. The first is that a valid permit signature
* expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be
* considered as an intention to spend the allowance in any specific way. The second is that because permits have
* built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should
* take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be
* generally recommended is:
*
* ```solidity
* function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {
* try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}
* doThing(..., value);
* }
*
* function doThing(..., uint256 value) public {
* token.safeTransferFrom(msg.sender, address(this), value);
* ...
* }
* ```
*
* Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of
* `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also
* {SafeERC20-safeTransferFrom}).
*
* Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so
* contracts should have entry points that don't rely on permit.
*/
interface IERC20Permit {
/**
* @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
* given ``owner``'s signed approval.
*
* IMPORTANT: The same issues {IERC20-approve} has related to transaction
* ordering also apply here.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `deadline` must be a timestamp in the future.
* - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
* over the EIP712-formatted function arguments.
* - the signature must use ``owner``'s current nonce (see {nonces}).
*
* For more information on the signature format, see the
* https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
* section].
*
* CAUTION: See Security Considerations above.
*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
/**
* @dev Returns the current nonce for `owner`. This value must be
* included whenever a signature is generated for {permit}.
*
* Every successful call to {permit} increases ``owner``'s nonce by one. This
* prevents a signature from being used multiple times.
*/
function nonces(address owner) external view returns (uint256);
/**
* @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view returns (bytes32);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the value of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the value of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves a `value` amount of 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 value) 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 a `value` amount of tokens 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 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the
* allowance mechanism. `value` 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 value) external returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../IERC20.sol";
import {IERC20Permit} from "../extensions/IERC20Permit.sol";
import {Address} from "../../../utils/Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using Address for address;
/**
* @dev An operation with an ERC20 token failed.
*/
error SafeERC20FailedOperation(address token);
/**
* @dev Indicates a failed `decreaseAllowance` request.
*/
error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);
/**
* @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));
}
/**
* @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
* calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
*/
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));
}
/**
* @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 oldAllowance = token.allowance(address(this), spender);
forceApprove(token, spender, oldAllowance + value);
}
/**
* @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
* value, non-reverting calls are assumed to be successful.
*/
function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
unchecked {
uint256 currentAllowance = token.allowance(address(this), spender);
if (currentAllowance < requestedDecrease) {
revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
}
forceApprove(token, spender, currentAllowance - requestedDecrease);
}
}
/**
* @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
* to be set to zero before setting it to a non-zero value, such as USDT.
*/
function forceApprove(IERC20 token, address spender, uint256 value) internal {
bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));
if (!_callOptionalReturnBool(token, approvalCall)) {
_callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));
_callOptionalReturn(token, approvalCall);
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data);
if (returndata.length != 0 && !abi.decode(returndata, (bool))) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @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).
*
* This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
*/
function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
// 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 cannot use {Address-functionCall} here since this should return false
// and not revert is the subcall reverts.
(bool success, bytes memory returndata) = address(token).call(data);
return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && address(token).code.length > 0;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)
pragma solidity ^0.8.20;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev The ETH balance of the account is not enough to perform the operation.
*/
error AddressInsufficientBalance(address account);
/**
* @dev There's no code at `target` (it is not a contract).
*/
error AddressEmptyCode(address target);
/**
* @dev A call to an address target failed. The target may have reverted.
*/
error FailedInnerCall();
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
if (address(this).balance < amount) {
revert AddressInsufficientBalance(address(this));
}
(bool success, ) = recipient.call{value: amount}("");
if (!success) {
revert FailedInnerCall();
}
}
/**
* @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 or custom error, it is bubbled
* up by this function (like regular Solidity function calls). However, if
* the call reverted with no returned reason, this function reverts with a
* {FailedInnerCall} error.
*
* 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.
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0);
}
/**
* @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`.
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
if (address(this).balance < value) {
revert AddressInsufficientBalance(address(this));
}
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target
* was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an
* unsuccessful call.
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata
) internal view returns (bytes memory) {
if (!success) {
_revert(returndata);
} else {
// only check if target is a contract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
if (returndata.length == 0 && target.code.length == 0) {
revert AddressEmptyCode(target);
}
return returndata;
}
}
/**
* @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the
* revert reason or with a default {FailedInnerCall} error.
*/
function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {
if (!success) {
_revert(returndata);
} else {
return returndata;
}
}
/**
* @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.
*/
function _revert(bytes memory returndata) private pure {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert FailedInnerCall();
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)
pragma solidity ^0.8.20;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/ECDSA.sol)
pragma solidity ^0.8.20;
/**
* @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
*
* These functions can be used to verify that a message was signed by the holder
* of the private keys of a given address.
*/
library ECDSA {
enum RecoverError {
NoError,
InvalidSignature,
InvalidSignatureLength,
InvalidSignatureS
}
/**
* @dev The signature derives the `address(0)`.
*/
error ECDSAInvalidSignature();
/**
* @dev The signature has an invalid length.
*/
error ECDSAInvalidSignatureLength(uint256 length);
/**
* @dev The signature has an S value that is in the upper half order.
*/
error ECDSAInvalidSignatureS(bytes32 s);
/**
* @dev Returns the address that signed a hashed message (`hash`) with `signature` or an error. This will not
* return address(0) without also returning an error description. Errors are documented using an enum (error type)
* and a bytes32 providing additional information about the error.
*
* If no error is returned, then the address can be used for verification purposes.
*
* The `ecrecover` EVM precompile allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it.
*
* Documentation for signature generation:
* - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]
* - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]
*/
function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError, bytes32) {
if (signature.length == 65) {
bytes32 r;
bytes32 s;
uint8 v;
// ecrecover takes the signature parameters, and the only way to get them
// currently is to use assembly.
/// @solidity memory-safe-assembly
assembly {
r := mload(add(signature, 0x20))
s := mload(add(signature, 0x40))
v := byte(0, mload(add(signature, 0x60)))
}
return tryRecover(hash, v, r, s);
} else {
return (address(0), RecoverError.InvalidSignatureLength, bytes32(signature.length));
}
}
/**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature`. This address can then be used for verification purposes.
*
* The `ecrecover` EVM precompile allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it.
*/
function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
(address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, signature);
_throwError(error, errorArg);
return recovered;
}
/**
* @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.
*
* See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]
*/
function tryRecover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address, RecoverError, bytes32) {
unchecked {
bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);
// We do not check for an overflow here since the shift operation results in 0 or 1.
uint8 v = uint8((uint256(vs) >> 255) + 27);
return tryRecover(hash, v, r, s);
}
}
/**
* @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.
*/
function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address) {
(address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, r, vs);
_throwError(error, errorArg);
return recovered;
}
/**
* @dev Overload of {ECDSA-tryRecover} that receives the `v`,
* `r` and `s` signature fields separately.
*/
function tryRecover(
bytes32 hash,
uint8 v,
bytes32 r,
bytes32 s
) internal pure returns (address, RecoverError, bytes32) {
// EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
// unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
// the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most
// signatures from current libraries generate a unique signature with an s-value in the lower half order.
//
// If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
// with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
// vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
// these malleable signatures as well.
if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
return (address(0), RecoverError.InvalidSignatureS, s);
}
// If the signature is valid (and not malleable), return the signer address
address signer = ecrecover(hash, v, r, s);
if (signer == address(0)) {
return (address(0), RecoverError.InvalidSignature, bytes32(0));
}
return (signer, RecoverError.NoError, bytes32(0));
}
/**
* @dev Overload of {ECDSA-recover} that receives the `v`,
* `r` and `s` signature fields separately.
*/
function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) {
(address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, v, r, s);
_throwError(error, errorArg);
return recovered;
}
/**
* @dev Optionally reverts with the corresponding custom error according to the `error` argument provided.
*/
function _throwError(RecoverError error, bytes32 errorArg) private pure {
if (error == RecoverError.NoError) {
return; // no error: do nothing
} else if (error == RecoverError.InvalidSignature) {
revert ECDSAInvalidSignature();
} else if (error == RecoverError.InvalidSignatureLength) {
revert ECDSAInvalidSignatureLength(uint256(errorArg));
} else if (error == RecoverError.InvalidSignatureS) {
revert ECDSAInvalidSignatureS(errorArg);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/MessageHashUtils.sol)
pragma solidity ^0.8.20;
import {Strings} from "../Strings.sol";
/**
* @dev Signature message hash utilities for producing digests to be consumed by {ECDSA} recovery or signing.
*
* The library provides methods for generating a hash of a message that conforms to the
* https://eips.ethereum.org/EIPS/eip-191[EIP 191] and https://eips.ethereum.org/EIPS/eip-712[EIP 712]
* specifications.
*/
library MessageHashUtils {
/**
* @dev Returns the keccak256 digest of an EIP-191 signed data with version
* `0x45` (`personal_sign` messages).
*
* The digest is calculated by prefixing a bytes32 `messageHash` with
* `"\x19Ethereum Signed Message:\n32"` and hashing the result. It corresponds with the
* hash signed when using the https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] JSON-RPC method.
*
* NOTE: The `messageHash` parameter is intended to be the result of hashing a raw message with
* keccak256, although any bytes32 value can be safely used because the final digest will
* be re-hashed.
*
* See {ECDSA-recover}.
*/
function toEthSignedMessageHash(bytes32 messageHash) internal pure returns (bytes32 digest) {
/// @solidity memory-safe-assembly
assembly {
mstore(0x00, "\x19Ethereum Signed Message:\n32") // 32 is the bytes-length of messageHash
mstore(0x1c, messageHash) // 0x1c (28) is the length of the prefix
digest := keccak256(0x00, 0x3c) // 0x3c is the length of the prefix (0x1c) + messageHash (0x20)
}
}
/**
* @dev Returns the keccak256 digest of an EIP-191 signed data with version
* `0x45` (`personal_sign` messages).
*
* The digest is calculated by prefixing an arbitrary `message` with
* `"\x19Ethereum Signed Message:\n" + len(message)` and hashing the result. It corresponds with the
* hash signed when using the https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] JSON-RPC method.
*
* See {ECDSA-recover}.
*/
function toEthSignedMessageHash(bytes memory message) internal pure returns (bytes32) {
return
keccak256(bytes.concat("\x19Ethereum Signed Message:\n", bytes(Strings.toString(message.length)), message));
}
/**
* @dev Returns the keccak256 digest of an EIP-191 signed data with version
* `0x00` (data with intended validator).
*
* The digest is calculated by prefixing an arbitrary `data` with `"\x19\x00"` and the intended
* `validator` address. Then hashing the result.
*
* See {ECDSA-recover}.
*/
function toDataWithIntendedValidatorHash(address validator, bytes memory data) internal pure returns (bytes32) {
return keccak256(abi.encodePacked(hex"19_00", validator, data));
}
/**
* @dev Returns the keccak256 digest of an EIP-712 typed data (EIP-191 version `0x01`).
*
* The digest is calculated from a `domainSeparator` and a `structHash`, by prefixing them with
* `\x19\x01` and hashing the result. It corresponds to the hash signed by the
* https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] JSON-RPC method as part of EIP-712.
*
* See {ECDSA-recover}.
*/
function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32 digest) {
/// @solidity memory-safe-assembly
assembly {
let ptr := mload(0x40)
mstore(ptr, hex"19_01")
mstore(add(ptr, 0x02), domainSeparator)
mstore(add(ptr, 0x22), structHash)
digest := keccak256(ptr, 0x42)
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/Math.sol)
pragma solidity ^0.8.20;
/**
* @dev Standard math utilities missing in the Solidity language.
*/
library Math {
/**
* @dev Muldiv operation overflow.
*/
error MathOverflowedMulDiv();
enum Rounding {
Floor, // Toward negative infinity
Ceil, // Toward positive infinity
Trunc, // Toward zero
Expand // Away from zero
}
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the subtraction of two unsigned integers, with an overflow flag.
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
/**
* @dev Returns the largest of two numbers.
*/
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a > b ? a : b;
}
/**
* @dev Returns the smallest of two numbers.
*/
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two numbers. The result is rounded towards
* zero.
*/
function average(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b) / 2 can overflow.
return (a & b) + (a ^ b) / 2;
}
/**
* @dev Returns the ceiling of the division of two numbers.
*
* This differs from standard division with `/` in that it rounds towards infinity instead
* of rounding towards zero.
*/
function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
if (b == 0) {
// Guarantee the same behavior as in a regular Solidity division.
return a / b;
}
// (a + b - 1) / b can overflow on addition, so we distribute.
return a == 0 ? 0 : (a - 1) / b + 1;
}
/**
* @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or
* denominator == 0.
* @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by
* Uniswap Labs also under MIT license.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {
unchecked {
// 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
// use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
// variables such that product = prod1 * 2^256 + prod0.
uint256 prod0 = x * y; // Least significant 256 bits of the product
uint256 prod1; // Most significant 256 bits of the product
assembly {
let mm := mulmod(x, y, not(0))
prod1 := sub(sub(mm, prod0), lt(mm, prod0))
}
// Handle non-overflow cases, 256 by 256 division.
if (prod1 == 0) {
// Solidity will revert if denominator == 0, unlike the div opcode on its own.
// The surrounding unchecked block does not change this fact.
// See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
return prod0 / denominator;
}
// Make sure the result is less than 2^256. Also prevents denominator == 0.
if (denominator <= prod1) {
revert MathOverflowedMulDiv();
}
///////////////////////////////////////////////
// 512 by 256 division.
///////////////////////////////////////////////
// Make division exact by subtracting the remainder from [prod1 prod0].
uint256 remainder;
assembly {
// Compute remainder using mulmod.
remainder := mulmod(x, y, denominator)
// Subtract 256 bit number from 512 bit number.
prod1 := sub(prod1, gt(remainder, prod0))
prod0 := sub(prod0, remainder)
}
// Factor powers of two out of denominator and compute largest power of two divisor of denominator.
// Always >= 1. See https://cs.stackexchange.com/q/138556/92363.
uint256 twos = denominator & (0 - denominator);
assembly {
// Divide denominator by twos.
denominator := div(denominator, twos)
// Divide [prod1 prod0] by twos.
prod0 := div(prod0, twos)
// Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
twos := add(div(sub(0, twos), twos), 1)
}
// Shift in bits from prod1 into prod0.
prod0 |= prod1 * twos;
// Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
// that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
// four bits. That is, denominator * inv = 1 mod 2^4.
uint256 inverse = (3 * denominator) ^ 2;
// Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also
// works in modular arithmetic, doubling the correct bits in each step.
inverse *= 2 - denominator * inverse; // inverse mod 2^8
inverse *= 2 - denominator * inverse; // inverse mod 2^16
inverse *= 2 - denominator * inverse; // inverse mod 2^32
inverse *= 2 - denominator * inverse; // inverse mod 2^64
inverse *= 2 - denominator * inverse; // inverse mod 2^128
inverse *= 2 - denominator * inverse; // inverse mod 2^256
// Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
// This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
// less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
// is no longer required.
result = prod0 * inverse;
return result;
}
}
/**
* @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {
uint256 result = mulDiv(x, y, denominator);
if (unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0) {
result += 1;
}
return result;
}
/**
* @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded
* towards zero.
*
* Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
*/
function sqrt(uint256 a) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
// For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
//
// We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
// `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
//
// This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
// → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
// → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
//
// Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
uint256 result = 1 << (log2(a) >> 1);
// At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
// since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
// every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
// into the expected uint128 result.
unchecked {
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
return min(result, a / result);
}
}
/**
* @notice Calculates sqrt(a), following the selected rounding direction.
*/
function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = sqrt(a);
return result + (unsignedRoundsUp(rounding) && result * result < a ? 1 : 0);
}
}
/**
* @dev Return the log in base 2 of a positive value rounded towards zero.
* Returns 0 if given 0.
*/
function log2(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 128;
}
if (value >> 64 > 0) {
value >>= 64;
result += 64;
}
if (value >> 32 > 0) {
value >>= 32;
result += 32;
}
if (value >> 16 > 0) {
value >>= 16;
result += 16;
}
if (value >> 8 > 0) {
value >>= 8;
result += 8;
}
if (value >> 4 > 0) {
value >>= 4;
result += 4;
}
if (value >> 2 > 0) {
value >>= 2;
result += 2;
}
if (value >> 1 > 0) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 2, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log2(value);
return result + (unsignedRoundsUp(rounding) && 1 << result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 10 of a positive value rounded towards zero.
* Returns 0 if given 0.
*/
function log10(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >= 10 ** 64) {
value /= 10 ** 64;
result += 64;
}
if (value >= 10 ** 32) {
value /= 10 ** 32;
result += 32;
}
if (value >= 10 ** 16) {
value /= 10 ** 16;
result += 16;
}
if (value >= 10 ** 8) {
value /= 10 ** 8;
result += 8;
}
if (value >= 10 ** 4) {
value /= 10 ** 4;
result += 4;
}
if (value >= 10 ** 2) {
value /= 10 ** 2;
result += 2;
}
if (value >= 10 ** 1) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 10, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log10(value);
return result + (unsignedRoundsUp(rounding) && 10 ** result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 256 of a positive value rounded towards zero.
* Returns 0 if given 0.
*
* Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
*/
function log256(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 16;
}
if (value >> 64 > 0) {
value >>= 64;
result += 8;
}
if (value >> 32 > 0) {
value >>= 32;
result += 4;
}
if (value >> 16 > 0) {
value >>= 16;
result += 2;
}
if (value >> 8 > 0) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 256, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log256(value);
return result + (unsignedRoundsUp(rounding) && 1 << (result << 3) < value ? 1 : 0);
}
}
/**
* @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers.
*/
function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {
return uint8(rounding) % 2 == 1;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/SignedMath.sol)
pragma solidity ^0.8.20;
/**
* @dev Standard signed math utilities missing in the Solidity language.
*/
library SignedMath {
/**
* @dev Returns the largest of two signed numbers.
*/
function max(int256 a, int256 b) internal pure returns (int256) {
return a > b ? a : b;
}
/**
* @dev Returns the smallest of two signed numbers.
*/
function min(int256 a, int256 b) internal pure returns (int256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two signed numbers without overflow.
* The result is rounded towards zero.
*/
function average(int256 a, int256 b) internal pure returns (int256) {
// Formula from the book "Hacker's Delight"
int256 x = (a & b) + ((a ^ b) >> 1);
return x + (int256(uint256(x) >> 255) & (a ^ b));
}
/**
* @dev Returns the absolute unsigned value of a signed value.
*/
function abs(int256 n) internal pure returns (uint256) {
unchecked {
// must be unchecked in order to support `n = type(int256).min`
return uint256(n >= 0 ? n : -n);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/StorageSlot.sol)
// This file was procedurally generated from scripts/generate/templates/StorageSlot.js.
pragma solidity ^0.8.20;
/**
* @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:
* ```solidity
* 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(newImplementation.code.length > 0);
* StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
* }
* }
* ```
*/
library StorageSlot {
struct AddressSlot {
address value;
}
struct BooleanSlot {
bool value;
}
struct Bytes32Slot {
bytes32 value;
}
struct Uint256Slot {
uint256 value;
}
struct StringSlot {
string value;
}
struct BytesSlot {
bytes value;
}
/**
* @dev Returns an `AddressSlot` with member `value` located at `slot`.
*/
function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `BooleanSlot` with member `value` located at `slot`.
*/
function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `Bytes32Slot` with member `value` located at `slot`.
*/
function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `Uint256Slot` with member `value` located at `slot`.
*/
function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `StringSlot` with member `value` located at `slot`.
*/
function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `StringSlot` representation of the string storage pointer `store`.
*/
function getStringSlot(string storage store) internal pure returns (StringSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := store.slot
}
}
/**
* @dev Returns an `BytesSlot` with member `value` located at `slot`.
*/
function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`.
*/
function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := store.slot
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Strings.sol)
pragma solidity ^0.8.20;
import {Math} from "./math/Math.sol";
import {SignedMath} from "./math/SignedMath.sol";
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant HEX_DIGITS = "0123456789abcdef";
uint8 private constant ADDRESS_LENGTH = 20;
/**
* @dev The `value` string doesn't fit in the specified `length`.
*/
error StringsInsufficientHexLength(uint256 value, uint256 length);
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
unchecked {
uint256 length = Math.log10(value) + 1;
string memory buffer = new string(length);
uint256 ptr;
/// @solidity memory-safe-assembly
assembly {
ptr := add(buffer, add(32, length))
}
while (true) {
ptr--;
/// @solidity memory-safe-assembly
assembly {
mstore8(ptr, byte(mod(value, 10), HEX_DIGITS))
}
value /= 10;
if (value == 0) break;
}
return buffer;
}
}
/**
* @dev Converts a `int256` to its ASCII `string` decimal representation.
*/
function toStringSigned(int256 value) internal pure returns (string memory) {
return string.concat(value < 0 ? "-" : "", toString(SignedMath.abs(value)));
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
unchecked {
return toHexString(value, Math.log256(value) + 1);
}
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
uint256 localValue = value;
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_DIGITS[localValue & 0xf];
localValue >>= 4;
}
if (localValue != 0) {
revert StringsInsufficientHexLength(value, length);
}
return string(buffer);
}
/**
* @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal
* representation.
*/
function toHexString(address addr) internal pure returns (string memory) {
return toHexString(uint256(uint160(addr)), ADDRESS_LENGTH);
}
/**
* @dev Returns true if the two strings are equal.
*/
function equal(string memory a, string memory b) internal pure returns (bool) {
return bytes(a).length == bytes(b).length && keccak256(bytes(a)) == keccak256(bytes(b));
}
}// SPDX-License-Identifier: UNLICENSED
// Copyright 2023 Immersve
pragma solidity ^0.8.28;
import { IFundsStorage } from "./interfaces/IFundsStorage.sol";
import { IFundsAdmin } from "./interfaces/IFundsAdmin.sol";
import { ReentrancyGuardUpgradeable } from "@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol";
import { ECDSA } from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import { EIP712Upgradeable } from "@openzeppelin/contracts-upgradeable/utils/cryptography/EIP712Upgradeable.sol";
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
contract FundsStorageLogic is IFundsStorage, ReentrancyGuardUpgradeable, EIP712Upgradeable {
/**
* The FundsAdmin proxy which provides configurations for any FundsStorage
* operations.
*/
IFundsAdmin internal _fundsAdmin;
/**
* The user-supplied name of the FundsStorage, useful for aiding with
* auditing deployed contracts.
*/
string internal _name;
/**
* The token supported by this FundsStorage. Token transfers into this
* contract which are not from this token are not able to be withdrawn and
* will be trapped forever.
*/
IERC20 internal _token;
/**
* Mapping of depositor address to withdrawal nonce.
*/
mapping(address => uint256) internal _usedNonces;
/**
* @dev Keep track of already used idempotency keys for debit and refund operations
*/
mapping(bytes32 => DirectSpendTransaction) internal _directSpendTransactions;
FundingMode internal _fundingMode;
/**
* @dev This initializer will be invoked once for each BeaconProxy created by
* the FundsStorageFactory.
* @param adminAddress The address of the FundsAdmin which supplies
* configurations to this FundsStorage.
* @param token The ERC-20 token to be supported by this funds storage.
* @param name The name of the funds storage.
*/
function initialize(address adminAddress, address token, string calldata name, FundingMode fundingMode) public initializer {
_fundsAdmin = IFundsAdmin(adminAddress);
_token = IERC20(token);
_name = name;
_fundingMode = fundingMode;
/*
* Initialize the EIP-712 domain separator used when verifying withdraw signatures.
*/
__EIP712_init("Immersve.FundsStorageLogic", "1");
}
/// @inheritdoc IFundsStorage
function getName() external view returns(string memory name) {
return _name;
}
/// @inheritdoc IFundsStorage
function getToken() external view returns(address) {
return address(_token);
}
/// @inheritdoc IFundsStorage
function getWithdrawalNonce(address depositor) public view returns(uint256) {
return _usedNonces[depositor];
}
/// @inheritdoc IFundsStorage
function getFundingMode() external view returns(FundingMode) {
return _fundingMode;
}
/// @inheritdoc IFundsStorage
function withdraw(
uint256 amount,
uint256 expiryDate,
uint256 nonce,
bytes memory _signature
) external nonReentrant {
_requireFundingMode(FundingMode.DEPOSIT);
if(block.timestamp > expiryDate) revert ExpiryDatePassed();
// check if the funds were already withdrawn with this nonce
if(nonce != _usedNonces[msg.sender] + 1) revert NonceOutOfSequence();
bytes32 digest = _hashTypedDataV4(
keccak256(abi.encode(keccak256("WithdrawalIntent(address depositorAddress,uint256 amount,uint256 expiryDate,uint256 nonce)"), msg.sender, amount, expiryDate, nonce))
);
_verifySignature(digest, _signature);
_usedNonces[msg.sender] = nonce;
if (amount > 0) {
SafeERC20.safeTransfer(_token, msg.sender, amount);
}
emit Withdrawal(msg.sender, amount, expiryDate, nonce, WithdrawalType.ONLINE_SIGNATURE);
}
/**
* @dev Verify that the hash has been signed by an account with WITHDRAWAL_AUTHORIZER role
**/
function _verifySignature(bytes32 digest, bytes memory signature) internal view {
address signer = ECDSA.recover(digest, signature);
_fundsAdmin._requireWithdrawalSignerAuthorized(signer);
}
/// @inheritdoc IFundsStorage
function transferToSettlementAddress(uint256 amount) external {
_requireFundsAdmin(msg.sender);
address settlementAddress = _fundsAdmin.getSettlementAddress(address(_token));
if(settlementAddress == address(0)) revert TokenNotSupported({ token: address(_token) });
SafeERC20.safeTransfer(_token, settlementAddress, amount);
}
/// @inheritdoc IFundsStorage
function directSpendDebit(address spender, uint256 amount, bytes32 idempotencyKey) external {
_requireFundingMode(FundingMode.APPROVAL);
_requireFundsAdmin(msg.sender);
_requireUniqueDirectSpendIdempotencyKey(idempotencyKey);
SafeERC20.safeTransferFrom(_token, spender, address(this), amount);
_directSpendTransactions[idempotencyKey] = DirectSpendTransaction(
amount,
block.timestamp,
spender,
DirectSpendOperationType.DEBIT, // operation
true, // exists?
0
);
emit DirectSpendDebit(spender, amount, idempotencyKey);
}
/// @inheritdoc IFundsStorage
function directSpendGetTransaction(bytes32 idempotencyKey) external view returns(DirectSpendTransaction memory) {
return _directSpendTransactions[idempotencyKey];
}
/// @inheritdoc IFundsStorage
function directSpendRefund(
address destinationAddress,
address sourceAddress,
uint256 amount,
bytes32 idempotencyKey
) external {
_requireFundingMode(FundingMode.APPROVAL);
_requireFundsAdmin(msg.sender);
_requireUniqueDirectSpendIdempotencyKey(idempotencyKey);
_directSpendTransactions[idempotencyKey] = DirectSpendTransaction(
amount,
block.timestamp,
destinationAddress,
DirectSpendOperationType.REFUND, // operation
true, // exists?
0
);
emit DirectSpendRefund(destinationAddress, sourceAddress, amount, idempotencyKey);
}
/// @inheritdoc IFundsStorage
function directSpendReverse(
bytes32 originalIdempotencyKey,
uint256 amount,
bytes32 idempotencyKey
) external {
_requireFundingMode(FundingMode.APPROVAL);
_requireFundsAdmin(msg.sender);
_requireUniqueDirectSpendIdempotencyKey(idempotencyKey);
DirectSpendTransaction memory directSpendTransaction = _directSpendTransactions[originalIdempotencyKey];
if(!directSpendTransaction.exists) revert DirectSpendTransactionNotFound();
if(directSpendTransaction.operationType != DirectSpendOperationType.DEBIT) revert OperationUnsupported();
_requireUnexpiredDirectSpendTransaction(directSpendTransaction);
uint256 availableReversalAmount = directSpendTransaction.amount - directSpendTransaction.reversedAmount;
if(amount > availableReversalAmount) revert DirectSpendReversalInsufficientFunds();
address destinationAddress = directSpendTransaction.fundingAddress;
SafeERC20.safeTransfer(_token, destinationAddress, amount);
_directSpendTransactions[originalIdempotencyKey].reversedAmount = directSpendTransaction.reversedAmount + amount;
_directSpendTransactions[idempotencyKey] = DirectSpendTransaction(
amount,
block.timestamp,
destinationAddress,
DirectSpendOperationType.REVERSAL, // operation
true, // exists?
amount
);
emit DirectSpendReversal(originalIdempotencyKey, destinationAddress, amount, idempotencyKey);
}
/// @inheritdoc IFundsStorage
function addStorageLiquidity(
address sourceAddress,
uint256 amount
) external {
_requireFundsAdmin(msg.sender);
IERC20 token = IERC20(_token);
SafeERC20.safeTransferFrom(token, sourceAddress, address(this), amount);
}
function _requireFundingMode(FundingMode expectedFundingMode) internal view {
FundingMode currentFundingMode = _fundingMode;
if(currentFundingMode != expectedFundingMode) revert FundingModeInvalid(currentFundingMode, expectedFundingMode);
}
function _requireFundsAdmin(address sender) internal view {
if(address(_fundsAdmin) != sender) revert SenderAccountNotAuthorized(sender);
}
function _requireUniqueDirectSpendIdempotencyKey(bytes32 idempotencyKey) internal view {
DirectSpendTransaction memory directSpendTransaction = _directSpendTransactions[idempotencyKey];
if(directSpendTransaction.exists) revert IdempotencyKeyAlreadyUsed();
}
function _requireUnexpiredDirectSpendTransaction(DirectSpendTransaction memory transaction) internal {
uint256 transactionExpiryDate = transaction.timestamp + _fundsAdmin.getDirectSpendReversalCutoffSeconds();
if(block.timestamp > transactionExpiryDate) revert DirectSpendTransactionExpired();
}
}// SPDX-License-Identifier: UNLICENSED
// Copyright 2023 Immersve
pragma solidity ^0.8.28;
import { ITypes } from "./ITypes.sol";
interface IErrors is ITypes {
/**
* @notice Operation needs to be processed in a specific order.
* Nonce makes sure that the order is correct. Otherwise the
* nonce is out of sequence and there is a problem with the order
* of this operation
*/
error NonceOutOfSequence();
/**
* @notice In order to execute this operation, a specific signature
* is required, and the provided signature is not valid
*/
error SignatureUnauthorized();
/**
* @notice Provided Merkle Root has an invalid value or format
*/
error MerkleRootInvalid();
/**
* @notice Tokens are enabled at the FundsManagerLogic level.
* Operations trying to use unsupported tokens will fail unless
* token is manually enabled for support
*/
error TokenNotSupported(address token);
/**
* @notice Operations requires to be ran before the expiry date
*/
error ExpiryDatePassed();
/**
* @notice The sender of the transaction is not authorized
* to perform this action
*/
error SenderAccountNotAuthorized(address account);
/**
* @notice The provided account address is not an Storage contract
*/
error StorageAccountInvalid(address source);
/**
* @notice The executed operation is not supported by this version
* of the protocol
*/
error OperationUnsupported();
/**
* @notice Operations are idempotent. If the key is already used it
* means that the operation was already executed
*/
error IdempotencyKeyAlreadyUsed();
/**
* @notice There is no record of a DirectSpendTransaction for the
* provided params
*/
error DirectSpendTransactionNotFound();
/**
* @notice Direct Spend is disabled at the FundsManagerLogic level.
* This feature is disabled by default and must be manually enabled.
* Direct spend feature should only be enabled for fast EVM chains
* like ARB or BASE
*/
error DirectSpendDisabled();
/**
* @notice Reversal operation failed because there is not enough
* liquidity on the storage contract
*/
error DirectSpendReversalInsufficientFunds();
/**
* @notice The Direct Spend Transaction is already expired
*/
error DirectSpendTransactionExpired();
/**
* @notice Operation requires a specific FundingMode. Storage instance
* funding mode differs from the expected mode for the current operation
*/
error FundingModeInvalid(FundingMode current, FundingMode expected);
}// SPDX-License-Identifier: UNLICENSED
// Copyright 2023 Immersve
pragma solidity ^0.8.28;
import { IErrors } from "./IErrors.sol";
import { IAccessControl } from "@openzeppelin/contracts/access/IAccessControl.sol";
/**
* @notice Administrative management for funds storage.
*/
interface IFundsAdmin is IErrors, IAccessControl {
/**
* Role for authorizing withdrawal signatures.
*/
//solhint-disable-next-line func-name-mixedcase
function WITHDRAWAL_SIGNER_ROLE() external pure returns(bytes32);
/**
* Role for authorizing settlement and refund.
*/
//solhint-disable-next-line func-name-mixedcase
function SETTLER_ROLE() external pure returns(bytes32);
/**
* @notice Event logged when a settlement is executed.
* @param from The address of the FundsStorage that is settling.
* @param amount The amount being settled.
* @param nonce The settlement nonce.
*/
event Settlement(address from, uint256 amount, uint256 nonce);
/**
* @notice Event logged when a refund is executed.
* @param refundee The address of the FundsStorage receiving the refund.
* @param sourceAddress The address of the FundsStorage receiving the refund.
* @param amount The amount being refunded.
* @param nonce The settlement nonce.
*/
event StorageLiquidityAdded(address refundee, address sourceAddress, uint256 amount, uint256 nonce);
/**
* @notice Get the current withdrawal nonce for a FundsStorage. The next
* settlement or refund transaction for the FundsStorage must be one more
* than this value.
* @param fundsStorage A FundsStorage address.
*/
function getSettlementNonce(address fundsStorage) external view returns(uint256);
/**
* @notice Settle cleared funds by triggering a token transfer. Only the
* settler role can settle.
* @param from The FundsStorage address to settle from.
* @param amount The amount to settle.
* @param nonce The Funds Storage's settlement nonce. The settlement nonce
* must be one more than the Funds Storage's current settlement nonce.
*/
function settle(
address from,
uint256 amount,
uint256 nonce,
bytes32 merkleRoot
) external;
/**
* @notice Add storage liquidity to a FundsStorage address. A token tranfer
* will be issued from the sourceAddress. Only the settler
* role can do this.
* @param refundee The FundsStorage address to refund to
* @param sourceAddress The source of funds for the liquidity addition
* @param amount The liquidity amount to add.
* @param nonce The settlement nonce. The settlement nonce must be one more than
* the Funds Storage's current settlement nonce.
*/
function addStorageLiquidity(
address refundee,
address sourceAddress,
uint256 amount,
uint256 nonce,
bytes32 merkleRoot
) external;
/**
* @notice Trigger a debit function call to the FundsStorage contract.
* Storage contract will check for available balance and allowance to try
* or reject the actual transfer
*
* @param storageAddress The Funds Storage address
* @param spender The account spending assets with Immersve
* @param amount The amount being spent by the spender
* @param idempotencyKey An idempotent key to avoid doing the same operation twice
*/
function directSpendDebit(
address storageAddress,
address spender,
uint256 amount,
bytes32 idempotencyKey
) external;
/**
* @notice Trigger a directSpendRefund function call to the FundsStorage contract.
* Storage contract will trigger an erc-20 transfer from the source address into
* the destinationAddress
*
* @param storageAddress The Funds Storage address
* @param destinationAddress The account receiving the refund
* @param sourceAddress The account providing liquidity for the refund
* @param amount The amount being spent by the spender
* @param idempotencyKey An idempotent key to avoid doing the same operation twice
*/
function directSpendRefund(
address storageAddress,
address destinationAddress,
address sourceAddress,
uint256 amount,
bytes32 idempotencyKey
) external;
/**
* @notice Trigger a directSpendReverse function call to the FundsStorage contract.
* Executes a payment reversal. Reversals are always linked to existing payments
* and cannot be higher than the original amount
*
* @param storageAddress The Funds Storage address
* @param originalIdempotencyKey The idempotency key of the original direct spend transaction
* @param amount The amount being reversed to the destination address
* @param idempotencyKey An idempotent key to avoid doing the same operation twice
*/
function directSpendReverse(
address storageAddress,
bytes32 originalIdempotencyKey,
uint256 amount,
bytes32 idempotencyKey
) external;
/**
* @notice Retrieves a direct spend transaction from a storage
* contract by it's idempotency key
*
* @param storageAddress The Partner FundsStorage contract address
* @param idempotencyKey The unique idempotency key
*/
function directSpendGetTransaction(
address storageAddress,
bytes32 idempotencyKey
) external view returns(DirectSpendTransaction memory);
/**
* @notice Update settlement addresses to include the given settlementAddress.
* @param token The token address to configure.
* @param settlementAddress The settlement address to allow. Setting settlementAddress
* to zero means that the token is not supported anymore.
*/
function setSettlementAddress(address token, address settlementAddress) external;
/**
* @notice Get the settlement address for the specified token.
* @param token The token for which to get the settlement address.
*/
function getSettlementAddress(address token) external view returns(address);
/**
* @notice Transfer the DEFAULT_ADMIN_ROLE to a new account/
* @param adminAccount The new account that can invoke all admin functions.
*/
function transferDefaultAdminRole(address adminAccount) external;
/**
* @notice Grant the WITHDRAWAL_SIGNER_ROLE.
* @param withdrawalSigner The address that can authorize withdrawals.
*/
function grantWithdrawalSignerRole(address withdrawalSigner) external;
/**
* @notice Revoke the WITHDRAWAL_SIGNER_ROLE.
* @param withdrawalSigner The address that can authorize withdrawals.
*/
function revokeWithdrawalSignerRole(address withdrawalSigner) external;
/**
* @notice Grant the SETTLER_ROLE.
* @param settlerAddress The address that can perform settle and refund.
*/
function grantSettlerRole(address settlerAddress) external;
/**
* @notice Revoke the SETTLER_ROLE.
* @param settlerAddress The address that can perform settle and refund.
*/
function revokeSettlerRole(address settlerAddress) external;
/**
* @notice Check if the provided address is authorized to do withdrawals
* @param signerAuthorizer The address to verify.
*/
// solhint-disable-next-line private-vars-leading-underscore
function _requireWithdrawalSignerAuthorized(address signerAuthorizer) external view;
/**
* @notice Pause all token transfer operations
*/
function pause() external;
/**
* @notice Resume all token transfer operations
*/
function unpause() external;
/**
* @notice Enables direct spend funding mode
*/
function enableDirectSpend() external;
/**
* @notice Disable direct spend funding mode
*/
function disableDirectSpend() external;
function setDirectSpendReversalCutoffSeconds(uint256 expiry) external;
function getDirectSpendReversalCutoffSeconds() external returns(uint256);
}// SPDX-License-Identifier: UNLICENSED
// Copyright 2023 Immersve
pragma solidity ^0.8.28;
import { IErrors } from "./IErrors.sol";
/**
* @notice Holder of deposits for an Immersve Funding Channel. Deposits are
* made via ERC-20 transfer. Withdrawals are made by getting a signed message
* from Immersve Funding Source APIs. To guarantee correct deposit addresses are
* used, the Immersve Funding Source APIs can be used to generate the required
* deposit transaction parameters.
* Approvals are made via ERC-20 approval transactions.
*/
interface IFundsStorage is IErrors {
/**
* Type indicator for a withdrawal event.
*/
enum WithdrawalType{ ONLINE_SIGNATURE, MERKLE_PROOF }
/**
* @notice Event logged when a withdrawal is executed.
* @param depositor The address of the depositor that is withdrawing.
* @param amount The amount withdrawn.
* @param expiryDate The withdrawal expiry timestamp.
* @param nonce The withdrawal nonce.
* @param withdrawalType The WithdrawalType that was performed.
*/
event Withdrawal(address depositor, uint256 amount, uint256 expiryDate, uint256 nonce, WithdrawalType withdrawalType);
/**
* @notice Event logged when a direct spend debit operation is executed.
* This will be called when funding source associated to the funding address
* is authorized to spend with an associated Immersve card.
*
* @param fundingAddress The address to take funds from
* @param amount The amount being debited from the funding address
* @param idempotencyKey A unique key to make operation idempotent
*/
event DirectSpendDebit(address fundingAddress, uint256 amount, bytes32 idempotencyKey);
/**
* @notice Event logged when a direct spend refund operation is executed.
* This will be called when a payment is refunded by the card network
*
* @param fundingAddress The address to transfer the refund to
* @param sourceAddress The address of the refund pool
* @param amount The amount being refunded to the funding address
* @param idempotencyKey A unique key to make operation idempotent
*/
event DirectSpendRefund(address fundingAddress, address sourceAddress, uint256 amount, bytes32 idempotencyKey);
/**
* @notice Event logged when a direct spend reversal operation is executed.
* This will be called when a payment is reversed by the card network
*
* @param originalIdempotencyKey The idempotency key of the original direct spend transaction
* @param fundingAddress The address to transfer the reversal to
* @param amount The amount being reversed to the funding address
* @param idempotencyKey A unique key to make operation idempotent
*/
event DirectSpendReversal(bytes32 originalIdempotencyKey, address fundingAddress, uint256 amount, bytes32 idempotencyKey);
/**
* @notice Get the name of the funds storage.
*/
function getName() external view returns(string memory name);
/**
* @notice Get the token supported by the funds storage. The supported token
* is defined when the FundsStorage is deployed and cannot change. Token
* deposits into a FundsStorage from other tokens cannot be withdrawn and will
* be stuck forever.
*/
function getToken() external view returns(address);
/**
* @notice Get the current withdrawal nonce for a depositor. The next
* withdrawal transaction must be one more that this value.
* @param depositor The depositor address.
*/
function getWithdrawalNonce(address depositor) external view returns(uint256);
/**
* @notice Withdraw funds using a signed withdrawal approval. The withdrawal
* approval is issued by Immersve Funding Source APIs. The message sender
* must be the same address connected to the Immersve Funding Source which
* the signed withdrawal approval relates to. A zero-amount withdrawal may
* be used to invalidate signed withdrawal approvals without triggering a
* token transfer.
* @param amount The amount being withdrawn.
* @param expiryDate The timestamp when the signature expires.
* @param nonce The withdrawal nonce. The withdrawal nonce must be one more
* than the the depositor's current withdrawal nonce.
* @param signature The signed withdrawal appoval.
*/
function withdraw(
uint256 amount,
uint256 expiryDate,
uint256 nonce,
bytes memory signature
) external;
/**
* @notice Perform a settlement transfer. Settlement can only be initiated
* by the FundsAdmin contract.
* @param amount The amount being settled.
*/
function transferToSettlementAddress(uint256 amount) external;
/**
* @notice Perform a debit directly from the spender wallet. Wallet must have
* granted the approval amount beforehand to the FundsStorage address
*
* @param spender The account spending assets with Immersve
* @param amount The amount being spent by the spender
* @param idempotencyKey An idempotent key to avoid doing the same operation twice
*/
function directSpendDebit(address spender, uint256 amount, bytes32 idempotencyKey) external;
/**
* @notice Retrieves a direct spend transaction from it's idempotency key
* @param idempotencyKey The idempotency key of an existing transaction
*/
function directSpendGetTransaction(bytes32 idempotencyKey) external view returns(DirectSpendTransaction memory);
/**
* @notice Storage contract will trigger an erc-20 transfer from the source address into
* the refundAddress
*
* @param destinationAddress The account receiving the refund
* @param sourceAddress The account providing liquidity for the refund
* @param amount The amount being refund to the destination address
* @param idempotencyKey An idempotent key to avoid doing the same operation twice
*/
function directSpendRefund(
address destinationAddress,
address sourceAddress,
uint256 amount,
bytes32 idempotencyKey
) external;
/**
* @notice Executes a payment reversal. Reversals are always linked to
* existing payments and cannot be higher than the original amount
*
* @param originalIdempotencyKey The idempotency key of the original direct spend transaction
* @param amount The amount being reversed to the destination address
* @param idempotencyKey An idempotent key to avoid doing the same operation twice
*/
function directSpendReverse(
bytes32 originalIdempotencyKey,
uint256 amount,
bytes32 idempotencyKey
) external;
/**
* @notice Executes a transfer from the sourceAddress into the storage address
* to add liquidity for reversal operations and withdrawals
*
* @param sourceAddress The origin of funds to add liquidity from
* @param amount The amount of funds being added to the storage contract
*/
function addStorageLiquidity(
address sourceAddress,
uint256 amount
) external;
/**
* @notice Gets the FundingMode configured for the FundsStorage instance
*/
function getFundingMode() external view returns(FundingMode);
}// SPDX-License-Identifier: UNLICENSED
// Copyright 2023 Immersve
pragma solidity ^0.8.28;
import { ITypes } from "./ITypes.sol";
/**
* @notice Factory for creating FundsStorage instances.
*/
interface IFundsStorageFactory is ITypes {
/**
* @notice Event logged when a new FundsStorage is created.
* @param token The token used by the FundsStorage.
* @param addr The address of the created FundsStorage.
* @param name The name of the created FundsStorage.
*/
event FundsStorageCreated(address token, address addr, string name);
/**
* @notice Get the deployed factory logic version.
*/
function getVersion() external pure returns(uint256);
/**
* @notice Get the deployed factory commit id.
*/
function getCommitId() external view returns(string memory);
/**
* @notice Get the deployed factory build number.
*/
function getBuildNumber() external view returns(string memory);
/**
* @notice Get the address of the beacon used for FundsStorage instances
* created by this factory.
*/
function getStorageBeaconAddress() external view returns(address);
/**
* @notice Get the address of the FundsAdmin used to configure FundsStorage
* instances created by this factory.
*/
function getAdminAddress() external view returns(address);
/**
* @notice Create a new FundsStorage. The address of the deployed contract is
* determined by the sender address and the name. Deployment will fail if the
* a name has already been used from the same message sender.
* @param token The token supported by the funds storage.
* @param name The name of the funds storage.
*/
function createFundsStorage(address token, string calldata name, FundingMode fundingMode) external returns(address);
/**
* @notice Check if an address is for a FundsStorage created by this factory.
* @param addr the address to check.
*/
function isFundsStorage(address addr) external view returns(bool);
}// SPDX-License-Identifier: UNLICENSED
// Copyright 2025 Immersve
pragma solidity ^0.8.28;
/**
* @notice Interface containing common direct spend types
*/
interface ITypes {
/**
* @notice Direct Spend operation
* - DEBIT: Transfer assets from funding address into storage contract
* - REFUND: Transfer assets from refund pool into funding address
* - REVERSAL: Transfer assets from storage contract into funding address
*/
enum DirectSpendOperationType{ DEBIT, REFUND, REVERSAL }
/**
* @notice Funding Mode
* - DEPOSIT: Funding address is required to do a deposit on the storage
* contract via ERC-20 transfer. Balance, debits and refunds are kept
* fully off-chain.
* - APPROVAL: Funding address is required to approve ERC-20 approval to
* the storage contract. Debits are executed during payments and refunds
* are executed when funds become available in the refund pool
*
* See: https://docs.immersve.com/guides/funding-protocols/#protocol-variants
*/
enum FundingMode{ DEPOSIT, APPROVAL }
/** @dev The details of a Direct Spend transaction */
struct DirectSpendTransaction {
uint256 amount;
uint256 timestamp; // epoch
address fundingAddress;
DirectSpendOperationType operationType;
bool exists;
uint256 reversedAmount;
}
}{
"optimizer": {
"enabled": true,
"runs": 10000
},
"evmVersion": "paris",
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"libraries": {}
}Contract ABI
API[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AccessControlBadConfirmation","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bytes32","name":"neededRole","type":"bytes32"}],"name":"AccessControlUnauthorizedAccount","type":"error"},{"inputs":[{"internalType":"address","name":"target","type":"address"}],"name":"AddressEmptyCode","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"AddressInsufficientBalance","type":"error"},{"inputs":[],"name":"DirectSpendDisabled","type":"error"},{"inputs":[],"name":"DirectSpendReversalInsufficientFunds","type":"error"},{"inputs":[],"name":"DirectSpendTransactionExpired","type":"error"},{"inputs":[],"name":"DirectSpendTransactionNotFound","type":"error"},{"inputs":[{"internalType":"address","name":"implementation","type":"address"}],"name":"ERC1967InvalidImplementation","type":"error"},{"inputs":[],"name":"ERC1967NonPayable","type":"error"},{"inputs":[],"name":"EnforcedPause","type":"error"},{"inputs":[],"name":"ExpectedPause","type":"error"},{"inputs":[],"name":"ExpiryDatePassed","type":"error"},{"inputs":[],"name":"FailedInnerCall","type":"error"},{"inputs":[{"internalType":"enum ITypes.FundingMode","name":"current","type":"uint8"},{"internalType":"enum ITypes.FundingMode","name":"expected","type":"uint8"}],"name":"FundingModeInvalid","type":"error"},{"inputs":[],"name":"IdempotencyKeyAlreadyUsed","type":"error"},{"inputs":[],"name":"InvalidInitialization","type":"error"},{"inputs":[],"name":"MerkleRootInvalid","type":"error"},{"inputs":[],"name":"NonceOutOfSequence","type":"error"},{"inputs":[],"name":"NotInitializing","type":"error"},{"inputs":[],"name":"OperationUnsupported","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"SenderAccountNotAuthorized","type":"error"},{"inputs":[],"name":"SignatureUnauthorized","type":"error"},{"inputs":[{"internalType":"address","name":"source","type":"address"}],"name":"StorageAccountInvalid","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"TokenNotSupported","type":"error"},{"inputs":[],"name":"UUPSUnauthorizedCallContext","type":"error"},{"inputs":[{"internalType":"bytes32","name":"slot","type":"bytes32"}],"name":"UUPSUnsupportedProxiableUUID","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"address","name":"addr","type":"address"},{"indexed":false,"internalType":"string","name":"name","type":"string"}],"name":"FundsStorageCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"version","type":"uint64"}],"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":"from","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"nonce","type":"uint256"}],"name":"Settlement","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"refundee","type":"address"},{"indexed":false,"internalType":"address","name":"sourceAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"nonce","type":"uint256"}],"name":"StorageLiquidityAdded","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":"SETTLER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"UPGRADE_INTERFACE_VERSION","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"WITHDRAWAL_SIGNER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"signerAuthorizer","type":"address"}],"name":"_requireWithdrawalSignerAuthorized","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"refundee","type":"address"},{"internalType":"address","name":"sourceAddress","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"bytes32","name":"merkleRoot","type":"bytes32"}],"name":"addStorageLiquidity","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"string","name":"name","type":"string"},{"internalType":"enum ITypes.FundingMode","name":"fundingMode","type":"uint8"}],"name":"createFundsStorage","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"storageAddress","type":"address"},{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes32","name":"idempotencyKey","type":"bytes32"}],"name":"directSpendDebit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"storageAddress","type":"address"},{"internalType":"bytes32","name":"idempotencyKey","type":"bytes32"}],"name":"directSpendGetTransaction","outputs":[{"components":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"timestamp","type":"uint256"},{"internalType":"address","name":"fundingAddress","type":"address"},{"internalType":"enum ITypes.DirectSpendOperationType","name":"operationType","type":"uint8"},{"internalType":"bool","name":"exists","type":"bool"},{"internalType":"uint256","name":"reversedAmount","type":"uint256"}],"internalType":"struct ITypes.DirectSpendTransaction","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"storageAddress","type":"address"},{"internalType":"address","name":"destinationAddress","type":"address"},{"internalType":"address","name":"sourceAddress","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes32","name":"idempotencyKey","type":"bytes32"}],"name":"directSpendRefund","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"storageAddress","type":"address"},{"internalType":"bytes32","name":"originalIdempotencyKey","type":"bytes32"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes32","name":"idempotencyKey","type":"bytes32"}],"name":"directSpendReverse","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"disableDirectSpend","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"enableDirectSpend","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getAdminAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getAdminLogicAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getBuildNumber","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getCommitId","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getDirectSpendReversalCutoffSeconds","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":[{"internalType":"address","name":"token","type":"address"}],"name":"getSettlementAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"fundsStorage","type":"address"}],"name":"getSettlementNonce","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getStorageBeaconAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getStorageLogicAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getVersion","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"},{"internalType":"address","name":"","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"settlerAddress","type":"address"}],"name":"grantSettlerRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"withdrawalSigner","type":"address"}],"name":"grantWithdrawalSignerRole","outputs":[],"stateMutability":"nonpayable","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":"string","name":"commitId","type":"string"},{"internalType":"string","name":"buildNumber","type":"string"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"addr","type":"address"}],"name":"isFundsStorage","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","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":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"callerConfirmation","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"},{"internalType":"address","name":"","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"settlerAddress","type":"address"}],"name":"revokeSettlerRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"withdrawalSigner","type":"address"}],"name":"revokeWithdrawalSignerRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"expiry","type":"uint256"}],"name":"setDirectSpendReversalCutoffSeconds","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"address","name":"settlementAddress","type":"address"}],"name":"setSettlementAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"bytes32","name":"merkleRoot","type":"bytes32"}],"name":"settle","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"adminAccount","type":"address"}],"name":"transferDefaultAdminRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplAddress","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"upgradeToAndCall","outputs":[],"stateMutability":"payable","type":"function"}]Contract Creation Code
60a06040523060805234801561001457600080fd5b5061001d610075565b60405161002990610127565b604051809103906000f080158015610045573d6000803e3d6000fd5b50600180546001600160a01b03929092166001600160a01b03199283161790556002805490911630179055610134565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000900460ff16156100c55760405163f92ee8a960e01b815260040160405180910390fd5b80546001600160401b03908116146101245780546001600160401b0319166001600160401b0390811782556040519081527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b50565b61285e80613c9b83390190565b608051613b3e61015d60003960008181611a3801528181611a610152611d7a0152613b3e6000f3fe6080604052600436106102e75760003560e01c80637eda306511610184578063a217fddf116100d6578063ca0eab921161008a578063e0c5b96411610064578063e0c5b964146108e1578063e0e95661146108ff578063f135d06f1461091457600080fd5b8063ca0eab92146108ac578063d547741f1461043a578063daa68a01146108cc57600080fd5b8063ad3cb1cc116100bb578063ad3cb1cc14610830578063ad73807914610879578063b2e6b9121461089957600080fd5b8063a217fddf146107fb578063a77280a41461081057600080fd5b806391d14854116101385780639ed27e72116101125780639ed27e72146107855780639eff927d146107a5578063a14ec1c8146107c557600080fd5b806391d14854146106cc5780639d766e60146107315780639dc68d271461075157600080fd5b80638456cb59116101695780638456cb5914610677578063882d25d41461068c5780638986dc92146106ac57600080fd5b80637eda30651461064057806383999e861461066257600080fd5b80634cd88b761161023d5780635e893aa8116101f15780636c30da72116101cb5780636c30da72146105bf57806372241f1f146105df5780637445e85c1461060c57600080fd5b80635e893aa8146105635780636211773e14610581578063641ef0b0146105a157600080fd5b806352d1902d1161022257806352d1902d146104f75780635bb08bcd1461050c5780635c975abb1461052c57600080fd5b80634cd88b76146104c45780634f1ef286146104e457600080fd5b8063248a9ca31161029f57806336568abe1161027957806336568abe1461046f57806336e894531461048f5780633f4ba83a146104af57600080fd5b8063248a9ca3146103eb5780632f2ff15d1461043a578063356b73a71461045a57600080fd5b80630e04e445116102d05780630e04e4451461033f5780631526e0871461037857806320f47f271461039a57600080fd5b806301ffc9a7146102ec5780630d8e6e2c14610321575b600080fd5b3480156102f857600080fd5b5061030c61030736600461268e565b610934565b60405190151581526020015b60405180910390f35b34801561032d57600080fd5b5060015b604051908152602001610318565b34801561034b57600080fd5b5061030c61035a3660046126e5565b6001600160a01b031660009081526005602052604090205460ff1690565b34801561038457600080fd5b506103986103933660046126e5565b6109cd565b005b3480156103a657600080fd5b506103d36103b53660046126e5565b6001600160a01b039081166000908152600660205260409020541690565b6040516001600160a01b039091168152602001610318565b3480156103f757600080fd5b50610331610406366004612702565b60009081527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800602052604090206001015490565b34801561044657600080fd5b5061039861045536600461271b565b6109f4565b34801561046657600080fd5b50610398610a26565b34801561047b57600080fd5b5061039861048a36600461271b565b610a73565b34801561049b57600080fd5b506103986104aa36600461274b565b610abf565b3480156104bb57600080fd5b50610398610b11565b3480156104d057600080fd5b506103986104df3660046127c2565b610b27565b6103986104f23660046128bc565b610ba8565b34801561050357600080fd5b50610331610cb9565b34801561051857600080fd5b506103986105273660046126e5565b610ce8565b34801561053857600080fd5b507fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f033005460ff1661030c565b34801561056f57600080fd5b506002546001600160a01b03166103d3565b34801561058d57600080fd5b5061039861059c366004612969565b610d1d565b3480156105ad57600080fd5b506001546001600160a01b03166103d3565b3480156105cb57600080fd5b506103986105da3660046126e5565b610df1565b3480156105eb57600080fd5b506105ff6105fa3660046129af565b610e6a565b6040516103189190612a0a565b34801561061857600080fd5b506103317f6666bf5bfee463d10a7fc50448047f8a53b7762d7e28fbc5c643182785f3fd3f81565b34801561064c57600080fd5b50610655610f32565b6040516103189190612abb565b34801561066e57600080fd5b50610398610fc4565b34801561068357600080fd5b50610398610ffa565b34801561069857600080fd5b506103986106a73660046126e5565b61100d565b3480156106b857600080fd5b506103986106c7366004612702565b611042565b3480156106d857600080fd5b5061030c6106e736600461271b565b60009182527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800602090815260408084206001600160a01b0393909316845291905290205460ff1690565b34801561073d57600080fd5b5061039861074c3660046126e5565b611053565b34801561075d57600080fd5b506103317f4824dd03b57de4bb122dd97fb0eac61746a2848a58aaec225ff6798314b82e2b81565b34801561079157600080fd5b506103986107a03660046126e5565b611088565b3480156107b157600080fd5b506103986107c0366004612ace565b6110bd565b3480156107d157600080fd5b506103316107e03660046126e5565b6001600160a01b031660009081526007602052604090205490565b34801561080757600080fd5b50610331600081565b34801561081c57600080fd5b5061039861082b366004612b09565b611159565b34801561083c57600080fd5b506106556040518060400160405280600581526020017f352e302e3000000000000000000000000000000000000000000000000000000081525081565b34801561088557600080fd5b50610398610894366004612ace565b611389565b3480156108a557600080fd5b50306103d3565b3480156108b857600080fd5b506103d36108c7366004612b5a565b611533565b3480156108d857600080fd5b506106556116de565b3480156108ed57600080fd5b506000546001600160a01b03166103d3565b34801561090b57600080fd5b50600954610331565b34801561092057600080fd5b5061039861092f366004612bc6565b6116ed565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b0000000000000000000000000000000000000000000000000000000014806109c757507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316145b92915050565b60006109d88161183c565b6109e3600083611846565b506109ef600033611915565b505050565b6040517fc357622d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000610a318161183c565b50600880547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff1674010000000000000000000000000000000000000000179055565b6001600160a01b0381163314610ab5576040517f6697b23200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6109ef8282611915565b6000610aca8161183c565b506001600160a01b03918216600090815260066020526040902080547fffffffffffffffffffffffff00000000000000000000000000000000000000001691909216179055565b6000610b1c8161183c565b610b246119bb565b50565b610b2f611a2d565b6000610b3a8161183c565b6000546001600160a01b0316151580610b5557610b55611aff565b6003610b62848683612cc2565b506004610b70868883612cc2565b5050600880547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff169055505062093a80600955505050565b610bb0611a2d565b610bba8282611d50565b600082905060008054906101000a90046001600160a01b03166001600160a01b0316633659cfe6826001600160a01b031663641ef0b06040518163ffffffff1660e01b8152600401602060405180830381865afa158015610c1f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c439190612dbe565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e084901b1681526001600160a01b039091166004820152602401600060405180830381600087803b158015610c9c57600080fd5b505af1158015610cb0573d6000803e3d6000fd5b50505050505050565b6000610cc3611d6f565b507f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc90565b6000610cf38161183c565b6109ef7f6666bf5bfee463d10a7fc50448047f8a53b7762d7e28fbc5c643182785f3fd3f83611846565b7f6666bf5bfee463d10a7fc50448047f8a53b7762d7e28fbc5c643182785f3fd3f610d478161183c565b610d4f611dd1565b610d57611e2d565b6000610d6286611e81565b6040517f08b1c8050000000000000000000000000000000000000000000000000000000081526001600160a01b0387811660048301526024820187905260448201869052919250908216906308b1c805906064015b600060405180830381600087803b158015610dd157600080fd5b505af1158015610de5573d6000803e3d6000fd5b50505050505050505050565b610df9611dd1565b6001600160a01b03811660009081527f30fdd05c961c3b53fafbb4bb42e92ecd0d99e9875668e3f346965af1473a07fb602052604090205460ff16610b24576040517f2b1fcd6600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040805160c081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905290610ea584611e81565b6040517f77989e77000000000000000000000000000000000000000000000000000000008152600481018590529091506001600160a01b038216906377989e779060240160c060405180830381865afa158015610f06573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f2a9190612df0565b949350505050565b606060038054610f4190612c21565b80601f0160208091040260200160405190810160405280929190818152602001828054610f6d90612c21565b8015610fba5780601f10610f8f57610100808354040283529160200191610fba565b820191906000526020600020905b815481529060010190602001808311610f9d57829003601f168201915b5050505050905090565b6000610fcf8161183c565b50600880547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff169055565b60006110058161183c565b610b24611ee7565b60006110188161183c565b6109ef7f4824dd03b57de4bb122dd97fb0eac61746a2848a58aaec225ff6798314b82e2b83611846565b600061104d8161183c565b50600955565b600061105e8161183c565b6109ef7f6666bf5bfee463d10a7fc50448047f8a53b7762d7e28fbc5c643182785f3fd3f83611915565b60006110938161183c565b6109ef7f4824dd03b57de4bb122dd97fb0eac61746a2848a58aaec225ff6798314b82e2b83611915565b7f6666bf5bfee463d10a7fc50448047f8a53b7762d7e28fbc5c643182785f3fd3f6110e78161183c565b6110ef611dd1565b6110f7611e2d565b600061110286611e81565b6040517f0e02015a0000000000000000000000000000000000000000000000000000000081526004810187905260248101869052604481018590529091506001600160a01b03821690630e02015a90606401610db7565b7f6666bf5bfee463d10a7fc50448047f8a53b7762d7e28fbc5c643182785f3fd3f6111838161183c565b61118b611dd1565b81156111c3576040517faa6905cc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b0386166000908152600760205260409020546111e7906001612e6b565b831461121f576040517f5e3312b600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600061122a87611e81565b90506000816001600160a01b03166321df0da76040518163ffffffff1660e01b8152600401602060405180830381865afa15801561126c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112909190612dbe565b905061129b81611f42565b6040517f6c535be70000000000000000000000000000000000000000000000000000000081526001600160a01b03888116600483015260248201889052831690636c535be790604401600060405180830381600087803b1580156112fe57600080fd5b505af1158015611312573d6000803e3d6000fd5b505050506001600160a01b038881166000818152600760209081526040918290208990558151928352928a1692820192909252908101879052606081018690527fcd7c65ed8cfeb9a0e64513e51c9a506b7f49a353fc48b42affd6993c2af80eb49060800160405180910390a15050505050505050565b7f6666bf5bfee463d10a7fc50448047f8a53b7762d7e28fbc5c643182785f3fd3f6113b38161183c565b6113bb611dd1565b81156113f3576040517faa6905cc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006113fe86611e81565b6001600160a01b038716600090815260076020526040902054909150611425906001612e6b565b841461145d576040517f5e3312b600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517fdfeaa4b3000000000000000000000000000000000000000000000000000000008152600481018690526001600160a01b0382169063dfeaa4b390602401600060405180830381600087803b1580156114b857600080fd5b505af11580156114cc573d6000803e3d6000fd5b505050506001600160a01b0386166000818152600760209081526040918290208790558151928352820187905281018590527f93744be23632b71c15fda59d4fcb485fc80f35677969b2262f752f3c26a12a829060600160405180910390a1505050505050565b600061153d611a2d565b61154685611f42565b6040517fffffffffffffffffffffffff00000000000000000000000000000000000000009060009061157b9087908790612ea5565b6040519081900390209050600061159433848416612e6b565b600080546040805183815260208101909152929350909183916001600160a01b0316906040516115c390612674565b6115ce929190612eb5565b8190604051809103906000f59050801580156115ee573d6000803e3d6000fd5b506040517f125a02370000000000000000000000000000000000000000000000000000000081529091506001600160a01b0382169063125a02379061163f9030908d908d908d908d90600401612f02565b600060405180830381600087803b15801561165957600080fd5b505af115801561166d573d6000803e3d6000fd5b5050506001600160a01b03821660009081526005602052604090819020805460ff19166001179055517f52eb04d640c7a602488455e1c58ec60f4aca2ba18be6496ca4d8f719ca3c912591506116ca908b9084908c908c90612f56565b60405180910390a198975050505050505050565b606060048054610f4190612c21565b7f6666bf5bfee463d10a7fc50448047f8a53b7762d7e28fbc5c643182785f3fd3f6117178161183c565b61171f611dd1565b611727611e2d565b600061173287611e81565b6040517fc3ef90da0000000000000000000000000000000000000000000000000000000081526001600160a01b038881166004830152878116602483015260448201879052606482018690529192509082169063c3ef90da90608401600060405180830381600087803b1580156117a857600080fd5b505af11580156117bc573d6000803e3d6000fd5b505050506000816001600160a01b03166321df0da76040518163ffffffff1660e01b8152600401602060405180830381865afa158015611800573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118249190612dbe565b905061183281878988611f9e565b5050505050505050565b610b24813361202c565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800602081815260408084206001600160a01b038616855290915282205460ff1661190b576000848152602082815260408083206001600160a01b03871684529091529020805460ff191660011790556118c13390565b6001600160a01b0316836001600160a01b0316857f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a460019150506109c7565b60009150506109c7565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800602081815260408084206001600160a01b038616855290915282205460ff161561190b576000848152602082815260408083206001600160a01b0387168085529252808320805460ff1916905551339287917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a460019150506109c7565b6119c36120b9565b7fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f03300805460ff191681557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a150565b306001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161480611ac657507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316611aba7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b6001600160a01b031614155b15611afd576040517fe07c8dba00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0080546002919068010000000000000000900460ff1680611b4e5750805467ffffffffffffffff808416911610155b15611b85576040517ff92ee8a900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80547fffffffffffffffffffffffffffffffffffffffffffffff0000000000000000001667ffffffffffffffff83161768010000000000000000178155611bca611a2d565b6000611bfd7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b90506000819050806001600160a01b031663641ef0b06040518163ffffffff1660e01b8152600401602060405180830381865afa158015611c42573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c669190612dbe565b30604051611c7390612681565b6001600160a01b03928316815291166020820152604001604051809103906000f080158015611ca6573d6000803e3d6000fd5b50600080547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0392909216919091179055611ce7612114565b505080547fffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffff16815560405167ffffffffffffffff831681527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15050565b611d58611a2d565b611d6182612124565b611d6b828261212f565b5050565b306001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614611afd576040517fe07c8dba00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f033005460ff1615611afd576040517fd93c066500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60085474010000000000000000000000000000000000000000900460ff16611afd576040517f03b395ba00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b03811660009081526005602052604081205460ff16611ee3576040517fe22117bd0000000000000000000000000000000000000000000000000000000081526001600160a01b03831660048201526024015b60405180910390fd5b5090565b611eef611dd1565b7fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f03300805460ff191660011781557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a25833611a0f565b6001600160a01b0381811660009081526006602052604090205416610b24576040517f06439c6b0000000000000000000000000000000000000000000000000000000081526001600160a01b0382166004820152602401611eda565b604080516001600160a01b0385811660248301528416604482015260648082018490528251808303909101815260849091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f23b872dd00000000000000000000000000000000000000000000000000000000179052612026908590612230565b50505050565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800602090815260408083206001600160a01b038516845290915290205460ff16611d6b576040517fe2517d3f0000000000000000000000000000000000000000000000000000000081526001600160a01b038216600482015260248101839052604401611eda565b7fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f033005460ff16611afd576040517f8dfc202b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61211c6122ac565b611afd612313565b6000611d6b8161183c565b816001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa925050508015612189575060408051601f3d908101601f1916820190925261218691810190612f88565b60015b6121ca576040517f4c9c8ce30000000000000000000000000000000000000000000000000000000081526001600160a01b0383166004820152602401611eda565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc8114612226576040517faa1d49a400000000000000000000000000000000000000000000000000000000815260048101829052602401611eda565b6109ef8383612346565b60006122456001600160a01b0384168361239c565b9050805160001415801561226a5750808060200190518101906122689190612fa1565b155b156109ef576040517f5274afe70000000000000000000000000000000000000000000000000000000081526001600160a01b0384166004820152602401611eda565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005468010000000000000000900460ff16611afd576040517fd7e6bcf800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61231b6122ac565b7fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f03300805460ff19169055565b61234f826123b1565b6040516001600160a01b038316907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a2805115612394576109ef8282612459565b611d6b6124cf565b60606123aa83836000612507565b9392505050565b806001600160a01b03163b600003612400576040517f4c9c8ce30000000000000000000000000000000000000000000000000000000081526001600160a01b0382166004820152602401611eda565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0392909216919091179055565b6060600080846001600160a01b0316846040516124769190612fbc565b600060405180830381855af49150503d80600081146124b1576040519150601f19603f3d011682016040523d82523d6000602084013e6124b6565b606091505b50915091506124c68583836125bd565b95945050505050565b3415611afd576040517fb398979f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b606081471015612545576040517fcd786059000000000000000000000000000000000000000000000000000000008152306004820152602401611eda565b600080856001600160a01b031684866040516125619190612fbc565b60006040518083038185875af1925050503d806000811461259e576040519150601f19603f3d011682016040523d82523d6000602084013e6125a3565b606091505b50915091506125b38683836125bd565b9695505050505050565b6060826125d2576125cd82612632565b6123aa565b81511580156125e957506001600160a01b0384163b155b1561262b576040517f9996b3150000000000000000000000000000000000000000000000000000000081526001600160a01b0385166004820152602401611eda565b50806123aa565b8051156126425780518082602001fd5b6040517f1425ea4200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6105eb80612fd983390190565b610545806135c483390190565b6000602082840312156126a057600080fd5b81357fffffffff00000000000000000000000000000000000000000000000000000000811681146123aa57600080fd5b6001600160a01b0381168114610b2457600080fd5b6000602082840312156126f757600080fd5b81356123aa816126d0565b60006020828403121561271457600080fd5b5035919050565b6000806040838503121561272e57600080fd5b823591506020830135612740816126d0565b809150509250929050565b6000806040838503121561275e57600080fd5b8235612769816126d0565b91506020830135612740816126d0565b60008083601f84011261278b57600080fd5b50813567ffffffffffffffff8111156127a357600080fd5b6020830191508360208285010111156127bb57600080fd5b9250929050565b600080600080604085870312156127d857600080fd5b843567ffffffffffffffff8111156127ef57600080fd5b6127fb87828801612779565b909550935050602085013567ffffffffffffffff81111561281b57600080fd5b61282787828801612779565b95989497509550505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60405160c0810167ffffffffffffffff8111828210171561288557612885612833565b60405290565b604051601f8201601f1916810167ffffffffffffffff811182821017156128b4576128b4612833565b604052919050565b600080604083850312156128cf57600080fd5b82356128da816126d0565b9150602083013567ffffffffffffffff8111156128f657600080fd5b8301601f8101851361290757600080fd5b803567ffffffffffffffff81111561292157612921612833565b6129346020601f19601f8401160161288b565b81815286602083850101111561294957600080fd5b816020840160208301376000602083830101528093505050509250929050565b6000806000806080858703121561297f57600080fd5b843561298a816126d0565b9350602085013561299a816126d0565b93969395505050506040820135916060013590565b600080604083850312156129c257600080fd5b82356129cd816126d0565b946020939093013593505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b600060c08201905082518252602083015160208301526001600160a01b036040840151166040830152606083015160038110612a4857612a486129db565b8060608401525060808301511515608083015260a083015160a083015292915050565b60005b83811015612a86578181015183820152602001612a6e565b50506000910152565b60008151808452612aa7816020860160208601612a6b565b601f01601f19169290920160200192915050565b6020815260006123aa6020830184612a8f565b60008060008060808587031215612ae457600080fd5b8435612aef816126d0565b966020860135965060408601359560600135945092505050565b600080600080600060a08688031215612b2157600080fd5b8535612b2c816126d0565b94506020860135612b3c816126d0565b94979496505050506040830135926060810135926080909101359150565b60008060008060608587031215612b7057600080fd5b8435612b7b816126d0565b9350602085013567ffffffffffffffff811115612b9757600080fd5b612ba387828801612779565b909450925050604085013560028110612bbb57600080fd5b939692955090935050565b600080600080600060a08688031215612bde57600080fd5b8535612be9816126d0565b94506020860135612bf9816126d0565b93506040860135612c09816126d0565b94979396509394606081013594506080013592915050565b600181811c90821680612c3557607f821691505b602082108103612c6e577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b601f8211156109ef57806000526020600020601f840160051c81016020851015612c9b5750805b601f840160051c820191505b81811015612cbb5760008155600101612ca7565b5050505050565b67ffffffffffffffff831115612cda57612cda612833565b612cee83612ce88354612c21565b83612c74565b6000601f841160018114612d405760008515612d0a5750838201355b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600387901b1c1916600186901b178355612cbb565b600083815260209020601f19861690835b82811015612d715786850135825560209485019460019092019101612d51565b5086821015612dac577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60f88860031b161c19848701351681555b505060018560011b0183555050505050565b600060208284031215612dd057600080fd5b81516123aa816126d0565b80518015158114612deb57600080fd5b919050565b600060c0828403128015612e0357600080fd5b506000612e0e612862565b83518152602080850151908201526040840151612e2a816126d0565b6040820152606084015160038110612e40578283fd5b6060820152612e5160808501612ddb565b608082015260a09384015193810193909352509092915050565b808201808211156109c7577f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b8183823760009101908152919050565b6001600160a01b0383168152604060208201526000610f2a6040830184612a8f565b818352818160208501375060006020828401015260006020601f19601f840116840101905092915050565b6001600160a01b03861681526001600160a01b0385166020820152608060408201526000612f34608083018587612ed7565b905060028310612f4657612f466129db565b8260608301529695505050505050565b6001600160a01b03851681526001600160a01b03841660208201526060604082015260006125b3606083018486612ed7565b600060208284031215612f9a57600080fd5b5051919050565b600060208284031215612fb357600080fd5b6123aa82612ddb565b60008251612fce818460208701612a6b565b919091019291505056fe60a06040526040516105eb3803806105eb83398101604081905261002291610387565b61002c828261003e565b506001600160a01b0316608052610484565b610047826100fe565b6040516001600160a01b038316907f1cf3b03a6cf19fa2baba4df148e9dcabedea7f8a5c07840e207e5c089be95d3e90600090a28051156100f2576100ed826001600160a01b0316635c60da1b6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156100c3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906100e7919061044d565b82610211565b505050565b6100fa610288565b5050565b806001600160a01b03163b60000361013957604051631933b43b60e21b81526001600160a01b03821660048201526024015b60405180910390fd5b807fa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d5080546001600160a01b0319166001600160a01b0392831617905560408051635c60da1b60e01b81529051600092841691635c60da1b9160048083019260209291908290030181865afa1580156101b5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101d9919061044d565b9050806001600160a01b03163b6000036100fa57604051634c9c8ce360e01b81526001600160a01b0382166004820152602401610130565b6060600080846001600160a01b03168460405161022e9190610468565b600060405180830381855af49150503d8060008114610269576040519150601f19603f3d011682016040523d82523d6000602084013e61026e565b606091505b50909250905061027f8583836102a9565b95945050505050565b34156102a75760405163b398979f60e01b815260040160405180910390fd5b565b6060826102be576102b982610308565b610301565b81511580156102d557506001600160a01b0384163b155b156102fe57604051639996b31560e01b81526001600160a01b0385166004820152602401610130565b50805b9392505050565b8051156103185780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b80516001600160a01b038116811461034857600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b8381101561037e578181015183820152602001610366565b50506000910152565b6000806040838503121561039a57600080fd5b6103a383610331565b60208401519092506001600160401b038111156103bf57600080fd5b8301601f810185136103d057600080fd5b80516001600160401b038111156103e9576103e961034d565b604051601f8201601f19908116603f011681016001600160401b03811182821017156104175761041761034d565b60405281815282820160200187101561042f57600080fd5b610440826020830160208601610363565b8093505050509250929050565b60006020828403121561045f57600080fd5b61030182610331565b6000825161047a818460208701610363565b9190910192915050565b60805161014d61049e60003960006024015261014d6000f3fe608060405261000c61000e565b005b61001e610019610020565b6100b6565b565b60007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16635c60da1b6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561008d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906100b191906100da565b905090565b3660008037600080366000845af43d6000803e8080156100d5573d6000f35b3d6000fd5b6000602082840312156100ec57600080fd5b815173ffffffffffffffffffffffffffffffffffffffff8116811461011057600080fd5b939250505056fea2646970667358221220847da51342687254596c326192e2f3d8105e3ef1bf337cd24124316a6711d7ad64736f6c634300081c0033608060405234801561001057600080fd5b5060405161054538038061054583398101604081905261002f91610165565b806001600160a01b03811661005f57604051631e4fbdf760e01b8152600060048201526024015b60405180910390fd5b61006881610079565b50610072826100c9565b5050610198565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b806001600160a01b03163b6000036100ff5760405163211eb15960e21b81526001600160a01b0382166004820152602401610056565b600180546001600160a01b0319166001600160a01b0383169081179091556040517fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b80516001600160a01b038116811461016057600080fd5b919050565b6000806040838503121561017857600080fd5b61018183610149565b915061018f60208401610149565b90509250929050565b61039e806101a76000396000f3fe608060405234801561001057600080fd5b50600436106100675760003560e01c8063715018a611610050578063715018a6146100c45780638da5cb5b146100cc578063f2fde38b146100ea57600080fd5b80633659cfe61461006c5780635c60da1b14610081575b600080fd5b61007f61007a36600461032b565b6100fd565b005b60015473ffffffffffffffffffffffffffffffffffffffff165b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b61007f610111565b60005473ffffffffffffffffffffffffffffffffffffffff1661009b565b61007f6100f836600461032b565b610125565b61010561018b565b61010e816101de565b50565b61011961018b565b61012360006102b6565b565b61012d61018b565b73ffffffffffffffffffffffffffffffffffffffff8116610182576040517f1e4fbdf7000000000000000000000000000000000000000000000000000000008152600060048201526024015b60405180910390fd5b61010e816102b6565b60005473ffffffffffffffffffffffffffffffffffffffff163314610123576040517f118cdaa7000000000000000000000000000000000000000000000000000000008152336004820152602401610179565b8073ffffffffffffffffffffffffffffffffffffffff163b600003610247576040517f847ac56400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff82166004820152602401610179565b600180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83169081179091556040517fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60006020828403121561033d57600080fd5b813573ffffffffffffffffffffffffffffffffffffffff8116811461036157600080fd5b939250505056fea2646970667358221220e240865f9ac07da05345e9974bc71e5d074faab729148d0ee16b859b84ebd81e64736f6c634300081c0033a264697066735822122022a97ad9efa8b9e5b21adc17ae9b7941c7aca8fc6bcb658890a6d8f7d6d0b91864736f6c634300081c00336080604052348015600f57600080fd5b5061283f8061001f6000396000f3fe608060405234801561001057600080fd5b50600436106100df5760003560e01c806377989e771161008c578063c3ef90da11610066578063c3ef90da146101f7578063dfeaa4b31461020a578063f5a701ff1461021d578063fe55892d1461023057600080fd5b806377989e771461017857806384b0196e1461019857806396726af6146101b357600080fd5b806317d7de7c116100bd57806317d7de7c1461011f57806321df0da71461013d5780636c535be71461016557600080fd5b806308b1c805146100e45780630e02015a146100f9578063125a02371461010c575b600080fd5b6100f76100f2366004611f84565b610243565b005b6100f7610107366004611fb9565b610456565b6100f761011a366004611ff9565b610838565b610127610acb565b60405161013491906120f4565b60405180910390f35b60025460405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610134565b6100f7610173366004612107565b610b5d565b61018b610186366004612133565b610b90565b604051610134919061217b565b6101a0610c91565b60405161013497969594939291906121e9565b6101e96101c13660046122aa565b73ffffffffffffffffffffffffffffffffffffffff1660009081526003602052604090205490565b604051908152602001610134565b6100f76102053660046122c7565b610d92565b6100f7610218366004612133565b610f88565b60055460ff16604051610134919061231d565b6100f761023e36600461235f565b6110bb565b61024d600161127e565b610256336112e3565b61025f81611352565b6002546102849073ffffffffffffffffffffffffffffffffffffffff16843085611458565b6040518060c001604052808381526020014281526020018473ffffffffffffffffffffffffffffffffffffffff168152602001600060028111156102ca576102ca61214c565b8152600160208083018290526000604093840181905285815260048252839020845181559084015191810191909155908201516002808301805473ffffffffffffffffffffffffffffffffffffffff9093167fffffffffffffffffffffffff000000000000000000000000000000000000000084168117825560608601519391927fffffffffffffffffffffff0000000000000000000000000000000000000000009092161790740100000000000000000000000000000000000000009084908111156103995761039961214c565b021790555060808201516002820180549115157501000000000000000000000000000000000000000000027fffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffffff90921691909117905560a0909101516003909101556040805173ffffffffffffffffffffffffffffffffffffffff85168152602081018490529081018290527f7d21ef3935fe7d9657ac99fe98a59e40da46146de3c917413ddf4fb52decc6369060600160405180910390a1505050565b610460600161127e565b610469336112e3565b61047281611352565b6000838152600460209081526040808320815160c0810183528154815260018201549381019390935260028082015473ffffffffffffffffffffffffffffffffffffffff811693850193909352909160608401917401000000000000000000000000000000000000000090910460ff16908111156104f2576104f261214c565b60028111156105035761050361214c565b815260028201547501000000000000000000000000000000000000000000900460ff16151560208201526003909101546040909101526080810151909150610577576040517f43c02c5500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008160600151600281111561058f5761058f61214c565b146105c6576040517fc357622d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6105cf816114e1565b60a081015181516000916105e291612465565b90508084111561061e576040517f553531ac00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60408201516002546106479073ffffffffffffffffffffffffffffffffffffffff1682876115c0565b848360a001516106579190612478565b60008781526004602090815260409182902060030192909255805160c081018252878152429281019290925273ffffffffffffffffffffffffffffffffffffffff8316908201526060810160028152600160208083018290526040928301899052600088815260048252839020845181559084015191810191909155908201516002808301805473ffffffffffffffffffffffffffffffffffffffff9093167fffffffffffffffffffffffff000000000000000000000000000000000000000084168117825560608601519391927fffffffffffffffffffffff0000000000000000000000000000000000000000009092161790740100000000000000000000000000000000000000009084908111156107735761077361214c565b02179055506080828101516002830180549115157501000000000000000000000000000000000000000000027fffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffffff90921691909117905560a0909201516003909101556040805188815273ffffffffffffffffffffffffffffffffffffffff84166020820152908101879052606081018690527fe15319dd10a12f32753daaee2634b65e852596eadaad6d88ab268aca668c51a7910160405180910390a1505050505050565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000810460ff16159067ffffffffffffffff166000811580156108835750825b905060008267ffffffffffffffff1660011480156108a05750303b155b9050811580156108ae575080155b156108e5576040517ff92ee8a900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b84547fffffffffffffffffffffffffffffffffffffffffffffffff000000000000000016600117855583156109465784547fffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffff16680100000000000000001785555b6000805473ffffffffffffffffffffffffffffffffffffffff808d167fffffffffffffffffffffffff00000000000000000000000000000000000000009283161790925560028054928c169290911691909117905560016109a8888a8361252c565b50600580548791907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600183818111156109e5576109e561214c565b0217905550610a5e6040518060400160405280601a81526020017f496d6d65727376652e46756e647353746f726167654c6f6769630000000000008152506040518060400160405280600181526020017f31000000000000000000000000000000000000000000000000000000000000008152506115fe565b8315610abf5784547fffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffff168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b50505050505050505050565b606060018054610ada9061248b565b80601f0160208091040260200160405190810160405280929190818152602001828054610b069061248b565b8015610b535780601f10610b2857610100808354040283529160200191610b53565b820191906000526020600020905b815481529060010190602001808311610b3657829003601f168201915b5050505050905090565b610b66336112e3565b60025473ffffffffffffffffffffffffffffffffffffffff16610b8b81843085611458565b505050565b6040805160c081018252600080825260208201819052918101829052606081018290526080810182905260a0810191909152600082815260046020908152604091829020825160c0810184528154815260018201549281019290925260028082015473ffffffffffffffffffffffffffffffffffffffff81169484019490945291929091606084019174010000000000000000000000000000000000000000900460ff1690811115610c4457610c4461214c565b6002811115610c5557610c5561214c565b815260028201547501000000000000000000000000000000000000000000900460ff161515602082015260039091015460409091015292915050565b600060608082808083817fa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d1008054909150158015610cd057506001810154155b610d3b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f4549503731323a20556e696e697469616c697a6564000000000000000000000060448201526064015b60405180910390fd5b610d43611610565b610d4b6116e5565b604080516000808252602082019092527f0f000000000000000000000000000000000000000000000000000000000000009c939b5091995046985030975095509350915050565b610d9c600161127e565b610da5336112e3565b610dae81611352565b6040518060c001604052808381526020014281526020018573ffffffffffffffffffffffffffffffffffffffff16815260200160016002811115610df457610df461214c565b8152600160208083018290526000604093840181905285815260048252839020845181559084015191810191909155908201516002808301805473ffffffffffffffffffffffffffffffffffffffff9093167fffffffffffffffffffffffff000000000000000000000000000000000000000084168117825560608601519391927fffffffffffffffffffffff000000000000000000000000000000000000000000909216179074010000000000000000000000000000000000000000908490811115610ec357610ec361214c565b02179055506080828101516002830180549115157501000000000000000000000000000000000000000000027fffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffffff90921691909117905560a0909201516003909101556040805173ffffffffffffffffffffffffffffffffffffffff878116825286166020820152908101849052606081018390527f07ed227ae1ca3d28b0af8938dee03ab2355de9dbd5e3f2dae93bd2ad1bea912c910160405180910390a150505050565b610f91336112e3565b600080546002546040517f20f47f2700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff91821660048201529116906320f47f2790602401602060405180830381865afa158015611004573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110289190612628565b905073ffffffffffffffffffffffffffffffffffffffff8116611093576002546040517f06439c6b00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9091166004820152602401610d32565b6002546110b79073ffffffffffffffffffffffffffffffffffffffff1682846115c0565b5050565b6110c3611736565b6110cd600061127e565b82421115611107576040517f2730e78400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b33600090815260036020526040902054611122906001612478565b821461115a576040517f5e3312b600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b604080517ffb11d65370c515a75d6d2e4455dbe146db87055102d011540dfa18c581cba39b60208201523391810191909152606081018590526080810184905260a081018390526000906111c69060c001604051602081830303815290604052805190602001206117b7565b90506111d28183611805565b336000908152600360205260409020839055841561120e5760025461120e9073ffffffffffffffffffffffffffffffffffffffff1633876115c0565b7f8b501036de8a7422d7f8b7311d40441e079b4221e9edc276b3452124024e32cb338686866000604051611246959493929190612645565b60405180910390a15061127860017f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f0055565b50505050565b60055460ff168160018111156112965761129661214c565b8160018111156112a8576112a861214c565b146110b75780826040517fccf269a2000000000000000000000000000000000000000000000000000000008152600401610d32929190612691565b60005473ffffffffffffffffffffffffffffffffffffffff82811691161461134f576040517f903edfc000000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff82166004820152602401610d32565b50565b6000818152600460209081526040808320815160c0810183528154815260018201549381019390935260028082015473ffffffffffffffffffffffffffffffffffffffff811693850193909352909160608401917401000000000000000000000000000000000000000090910460ff16908111156113d2576113d261214c565b60028111156113e3576113e361214c565b815260028201547501000000000000000000000000000000000000000000900460ff16151560208201526003909101546040909101526080810151909150156110b7576040517f6538f59800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60405173ffffffffffffffffffffffffffffffffffffffff84811660248301528381166044830152606482018390526112789186918216906323b872dd906084015b604051602081830303815290604052915060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505061189b565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663e0e956616040518163ffffffff1660e01b81526004016020604051808303816000875af1158015611551573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061157591906126b7565b82602001516115849190612478565b9050804211156110b7576040517faf5556c400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60405173ffffffffffffffffffffffffffffffffffffffff838116602483015260448201839052610b8b91859182169063a9059cbb9060640161149a565b611606611931565b6110b7828261199a565b7fa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d10280546060917fa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d100916116619061248b565b80601f016020809104026020016040519081016040528092919081815260200182805461168d9061248b565b80156116da5780601f106116af576101008083540402835291602001916116da565b820191906000526020600020905b8154815290600101906020018083116116bd57829003601f168201915b505050505091505090565b7fa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d10380546060917fa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d100916116619061248b565b7f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f0080547ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016117b1576040517f3ee5aeb500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60029055565b60006117ff6117c4611a0d565b836040517f19010000000000000000000000000000000000000000000000000000000000008152600281019290925260228201526042902090565b92915050565b60006118118383611a1c565b6000546040517f6c30da7200000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8084166004830152929350911690636c30da729060240160006040518083038186803b15801561187e57600080fd5b505afa158015611892573d6000803e3d6000fd5b50505050505050565b60006118bd73ffffffffffffffffffffffffffffffffffffffff841683611a46565b905080516000141580156118e25750808060200190518101906118e091906126d0565b155b15610b8b576040517f5274afe700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff84166004820152602401610d32565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005468010000000000000000900460ff16611998576040517fd7e6bcf800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b565b6119a2611931565b7fa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d1007fa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d1026119ee84826126f2565b50600381016119fd83826126f2565b5060008082556001909101555050565b6000611a17611a5b565b905090565b600080600080611a2c8686611acf565b925092509250611a3c8282611b1c565b5090949350505050565b6060611a5483836000611c20565b9392505050565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f611a86611ce3565b611a8e611d5f565b60408051602081019490945283019190915260608201524660808201523060a082015260c00160405160208183030381529060405280519060200120905090565b60008060008351604103611b095760208401516040850151606086015160001a611afb88828585611db5565b955095509550505050611b15565b50508151600091506002905b9250925092565b6000826003811115611b3057611b3061214c565b03611b39575050565b6001826003811115611b4d57611b4d61214c565b03611b84576040517ff645eedf00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6002826003811115611b9857611b9861214c565b03611bd2576040517ffce698f700000000000000000000000000000000000000000000000000000000815260048101829052602401610d32565b6003826003811115611be657611be661214c565b036110b7576040517fd78bce0c00000000000000000000000000000000000000000000000000000000815260048101829052602401610d32565b606081471015611c5e576040517fcd786059000000000000000000000000000000000000000000000000000000008152306004820152602401610d32565b6000808573ffffffffffffffffffffffffffffffffffffffff168486604051611c8791906127ed565b60006040518083038185875af1925050503d8060008114611cc4576040519150601f19603f3d011682016040523d82523d6000602084013e611cc9565b606091505b5091509150611cd9868383611e91565b9695505050505050565b60007fa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d10081611d0f611610565b805190915015611d2757805160209091012092915050565b81548015611d36579392505050565b7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470935050505090565b60007fa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d10081611d8b6116e5565b805190915015611da357805160209091012092915050565b60018201548015611d36579392505050565b600080807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0841115611df05750600091506003905082611e87565b604080516000808252602082018084528a905260ff891692820192909252606081018790526080810186905260019060a0016020604051602081039080840390855afa158015611e44573d6000803e3d6000fd5b5050604051601f19015191505073ffffffffffffffffffffffffffffffffffffffff8116611e7d57506000925060019150829050611e87565b9250600091508190505b9450945094915050565b606082611ea657611ea182611f20565b611a54565b8151158015611eca575073ffffffffffffffffffffffffffffffffffffffff84163b155b15611f19576040517f9996b31500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff85166004820152602401610d32565b5080611a54565b805115611f305780518082602001fd5b6040517f1425ea4200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff8116811461134f57600080fd5b600080600060608486031215611f9957600080fd5b8335611fa481611f62565b95602085013595506040909401359392505050565b600080600060608486031215611fce57600080fd5b505081359360208301359350604090920135919050565b803560028110611ff457600080fd5b919050565b60008060008060006080868803121561201157600080fd5b853561201c81611f62565b9450602086013561202c81611f62565b9350604086013567ffffffffffffffff81111561204857600080fd5b8601601f8101881361205957600080fd5b803567ffffffffffffffff81111561207057600080fd5b88602082840101111561208257600080fd5b6020919091019350915061209860608701611fe5565b90509295509295909350565b60005b838110156120bf5781810151838201526020016120a7565b50506000910152565b600081518084526120e08160208601602086016120a4565b601f01601f19169290920160200192915050565b602081526000611a5460208301846120c8565b6000806040838503121561211a57600080fd5b823561212581611f62565b946020939093013593505050565b60006020828403121561214557600080fd5b5035919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b600060c082019050825182526020830151602083015273ffffffffffffffffffffffffffffffffffffffff60408401511660408301526060830151600381106121c6576121c661214c565b8060608401525060808301511515608083015260a083015160a083015292915050565b7fff000000000000000000000000000000000000000000000000000000000000008816815260e06020820152600061222460e08301896120c8565b828103604084015261223681896120c8565b6060840188905273ffffffffffffffffffffffffffffffffffffffff8716608085015260a0840186905283810360c08501528451808252602080870193509091019060005b8181101561229957835183526020938401939092019160010161227b565b50909b9a5050505050505050505050565b6000602082840312156122bc57600080fd5b8135611a5481611f62565b600080600080608085870312156122dd57600080fd5b84356122e881611f62565b935060208501356122f881611f62565b93969395505050506040820135916060013590565b6002811061134f5761134f61214c565b6020810161232a8361230d565b91905290565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000806000806080858703121561237557600080fd5b843593506020850135925060408501359150606085013567ffffffffffffffff8111156123a157600080fd5b8501601f810187136123b257600080fd5b803567ffffffffffffffff8111156123cc576123cc612330565b604051601f19603f601f19601f8501160116810181811067ffffffffffffffff821117156123fc576123fc612330565b60405281815282820160200189101561241457600080fd5b8160208401602083013760006020838301015280935050505092959194509250565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b818103818111156117ff576117ff612436565b808201808211156117ff576117ff612436565b600181811c9082168061249f57607f821691505b6020821081036124d8577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b601f821115610b8b57806000526020600020601f840160051c810160208510156125055750805b601f840160051c820191505b818110156125255760008155600101612511565b5050505050565b67ffffffffffffffff83111561254457612544612330565b61255883612552835461248b565b836124de565b6000601f8411600181146125aa57600085156125745750838201355b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600387901b1c1916600186901b178355612525565b600083815260209020601f19861690835b828110156125db57868501358255602094850194600190920191016125bb565b5086821015612616577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60f88860031b161c19848701351681555b505060018560011b0183555050505050565b60006020828403121561263a57600080fd5b8151611a5481611f62565b600060a08201905073ffffffffffffffffffffffffffffffffffffffff871682528560208301528460408301528360608301526126818361230d565b8260808301529695505050505050565b6040810161269e8461230d565b8382526126aa8361230d565b8260208301529392505050565b6000602082840312156126c957600080fd5b5051919050565b6000602082840312156126e257600080fd5b81518015158114611a5457600080fd5b815167ffffffffffffffff81111561270c5761270c612330565b6127208161271a845461248b565b846124de565b6020601f821160018114612772576000831561273c5750848201515b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600385901b1c1916600184901b178455612525565b600084815260208120601f198516915b828110156127a25787850151825560209485019460019092019101612782565b50848210156127de57868401517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600387901b60f8161c191681555b50505050600190811b01905550565b600082516127ff8184602087016120a4565b919091019291505056fea264697066735822122098ae5e975e981abf76e94e6e87ea4247def6f1e3c12f6f6339e632906ef1847664736f6c634300081c0033
Deployed Bytecode
0x6080604052600436106102e75760003560e01c80637eda306511610184578063a217fddf116100d6578063ca0eab921161008a578063e0c5b96411610064578063e0c5b964146108e1578063e0e95661146108ff578063f135d06f1461091457600080fd5b8063ca0eab92146108ac578063d547741f1461043a578063daa68a01146108cc57600080fd5b8063ad3cb1cc116100bb578063ad3cb1cc14610830578063ad73807914610879578063b2e6b9121461089957600080fd5b8063a217fddf146107fb578063a77280a41461081057600080fd5b806391d14854116101385780639ed27e72116101125780639ed27e72146107855780639eff927d146107a5578063a14ec1c8146107c557600080fd5b806391d14854146106cc5780639d766e60146107315780639dc68d271461075157600080fd5b80638456cb59116101695780638456cb5914610677578063882d25d41461068c5780638986dc92146106ac57600080fd5b80637eda30651461064057806383999e861461066257600080fd5b80634cd88b761161023d5780635e893aa8116101f15780636c30da72116101cb5780636c30da72146105bf57806372241f1f146105df5780637445e85c1461060c57600080fd5b80635e893aa8146105635780636211773e14610581578063641ef0b0146105a157600080fd5b806352d1902d1161022257806352d1902d146104f75780635bb08bcd1461050c5780635c975abb1461052c57600080fd5b80634cd88b76146104c45780634f1ef286146104e457600080fd5b8063248a9ca31161029f57806336568abe1161027957806336568abe1461046f57806336e894531461048f5780633f4ba83a146104af57600080fd5b8063248a9ca3146103eb5780632f2ff15d1461043a578063356b73a71461045a57600080fd5b80630e04e445116102d05780630e04e4451461033f5780631526e0871461037857806320f47f271461039a57600080fd5b806301ffc9a7146102ec5780630d8e6e2c14610321575b600080fd5b3480156102f857600080fd5b5061030c61030736600461268e565b610934565b60405190151581526020015b60405180910390f35b34801561032d57600080fd5b5060015b604051908152602001610318565b34801561034b57600080fd5b5061030c61035a3660046126e5565b6001600160a01b031660009081526005602052604090205460ff1690565b34801561038457600080fd5b506103986103933660046126e5565b6109cd565b005b3480156103a657600080fd5b506103d36103b53660046126e5565b6001600160a01b039081166000908152600660205260409020541690565b6040516001600160a01b039091168152602001610318565b3480156103f757600080fd5b50610331610406366004612702565b60009081527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800602052604090206001015490565b34801561044657600080fd5b5061039861045536600461271b565b6109f4565b34801561046657600080fd5b50610398610a26565b34801561047b57600080fd5b5061039861048a36600461271b565b610a73565b34801561049b57600080fd5b506103986104aa36600461274b565b610abf565b3480156104bb57600080fd5b50610398610b11565b3480156104d057600080fd5b506103986104df3660046127c2565b610b27565b6103986104f23660046128bc565b610ba8565b34801561050357600080fd5b50610331610cb9565b34801561051857600080fd5b506103986105273660046126e5565b610ce8565b34801561053857600080fd5b507fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f033005460ff1661030c565b34801561056f57600080fd5b506002546001600160a01b03166103d3565b34801561058d57600080fd5b5061039861059c366004612969565b610d1d565b3480156105ad57600080fd5b506001546001600160a01b03166103d3565b3480156105cb57600080fd5b506103986105da3660046126e5565b610df1565b3480156105eb57600080fd5b506105ff6105fa3660046129af565b610e6a565b6040516103189190612a0a565b34801561061857600080fd5b506103317f6666bf5bfee463d10a7fc50448047f8a53b7762d7e28fbc5c643182785f3fd3f81565b34801561064c57600080fd5b50610655610f32565b6040516103189190612abb565b34801561066e57600080fd5b50610398610fc4565b34801561068357600080fd5b50610398610ffa565b34801561069857600080fd5b506103986106a73660046126e5565b61100d565b3480156106b857600080fd5b506103986106c7366004612702565b611042565b3480156106d857600080fd5b5061030c6106e736600461271b565b60009182527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800602090815260408084206001600160a01b0393909316845291905290205460ff1690565b34801561073d57600080fd5b5061039861074c3660046126e5565b611053565b34801561075d57600080fd5b506103317f4824dd03b57de4bb122dd97fb0eac61746a2848a58aaec225ff6798314b82e2b81565b34801561079157600080fd5b506103986107a03660046126e5565b611088565b3480156107b157600080fd5b506103986107c0366004612ace565b6110bd565b3480156107d157600080fd5b506103316107e03660046126e5565b6001600160a01b031660009081526007602052604090205490565b34801561080757600080fd5b50610331600081565b34801561081c57600080fd5b5061039861082b366004612b09565b611159565b34801561083c57600080fd5b506106556040518060400160405280600581526020017f352e302e3000000000000000000000000000000000000000000000000000000081525081565b34801561088557600080fd5b50610398610894366004612ace565b611389565b3480156108a557600080fd5b50306103d3565b3480156108b857600080fd5b506103d36108c7366004612b5a565b611533565b3480156108d857600080fd5b506106556116de565b3480156108ed57600080fd5b506000546001600160a01b03166103d3565b34801561090b57600080fd5b50600954610331565b34801561092057600080fd5b5061039861092f366004612bc6565b6116ed565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b0000000000000000000000000000000000000000000000000000000014806109c757507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316145b92915050565b60006109d88161183c565b6109e3600083611846565b506109ef600033611915565b505050565b6040517fc357622d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000610a318161183c565b50600880547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff1674010000000000000000000000000000000000000000179055565b6001600160a01b0381163314610ab5576040517f6697b23200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6109ef8282611915565b6000610aca8161183c565b506001600160a01b03918216600090815260066020526040902080547fffffffffffffffffffffffff00000000000000000000000000000000000000001691909216179055565b6000610b1c8161183c565b610b246119bb565b50565b610b2f611a2d565b6000610b3a8161183c565b6000546001600160a01b0316151580610b5557610b55611aff565b6003610b62848683612cc2565b506004610b70868883612cc2565b5050600880547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff169055505062093a80600955505050565b610bb0611a2d565b610bba8282611d50565b600082905060008054906101000a90046001600160a01b03166001600160a01b0316633659cfe6826001600160a01b031663641ef0b06040518163ffffffff1660e01b8152600401602060405180830381865afa158015610c1f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c439190612dbe565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e084901b1681526001600160a01b039091166004820152602401600060405180830381600087803b158015610c9c57600080fd5b505af1158015610cb0573d6000803e3d6000fd5b50505050505050565b6000610cc3611d6f565b507f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc90565b6000610cf38161183c565b6109ef7f6666bf5bfee463d10a7fc50448047f8a53b7762d7e28fbc5c643182785f3fd3f83611846565b7f6666bf5bfee463d10a7fc50448047f8a53b7762d7e28fbc5c643182785f3fd3f610d478161183c565b610d4f611dd1565b610d57611e2d565b6000610d6286611e81565b6040517f08b1c8050000000000000000000000000000000000000000000000000000000081526001600160a01b0387811660048301526024820187905260448201869052919250908216906308b1c805906064015b600060405180830381600087803b158015610dd157600080fd5b505af1158015610de5573d6000803e3d6000fd5b50505050505050505050565b610df9611dd1565b6001600160a01b03811660009081527f30fdd05c961c3b53fafbb4bb42e92ecd0d99e9875668e3f346965af1473a07fb602052604090205460ff16610b24576040517f2b1fcd6600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040805160c081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905290610ea584611e81565b6040517f77989e77000000000000000000000000000000000000000000000000000000008152600481018590529091506001600160a01b038216906377989e779060240160c060405180830381865afa158015610f06573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f2a9190612df0565b949350505050565b606060038054610f4190612c21565b80601f0160208091040260200160405190810160405280929190818152602001828054610f6d90612c21565b8015610fba5780601f10610f8f57610100808354040283529160200191610fba565b820191906000526020600020905b815481529060010190602001808311610f9d57829003601f168201915b5050505050905090565b6000610fcf8161183c565b50600880547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff169055565b60006110058161183c565b610b24611ee7565b60006110188161183c565b6109ef7f4824dd03b57de4bb122dd97fb0eac61746a2848a58aaec225ff6798314b82e2b83611846565b600061104d8161183c565b50600955565b600061105e8161183c565b6109ef7f6666bf5bfee463d10a7fc50448047f8a53b7762d7e28fbc5c643182785f3fd3f83611915565b60006110938161183c565b6109ef7f4824dd03b57de4bb122dd97fb0eac61746a2848a58aaec225ff6798314b82e2b83611915565b7f6666bf5bfee463d10a7fc50448047f8a53b7762d7e28fbc5c643182785f3fd3f6110e78161183c565b6110ef611dd1565b6110f7611e2d565b600061110286611e81565b6040517f0e02015a0000000000000000000000000000000000000000000000000000000081526004810187905260248101869052604481018590529091506001600160a01b03821690630e02015a90606401610db7565b7f6666bf5bfee463d10a7fc50448047f8a53b7762d7e28fbc5c643182785f3fd3f6111838161183c565b61118b611dd1565b81156111c3576040517faa6905cc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b0386166000908152600760205260409020546111e7906001612e6b565b831461121f576040517f5e3312b600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600061122a87611e81565b90506000816001600160a01b03166321df0da76040518163ffffffff1660e01b8152600401602060405180830381865afa15801561126c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112909190612dbe565b905061129b81611f42565b6040517f6c535be70000000000000000000000000000000000000000000000000000000081526001600160a01b03888116600483015260248201889052831690636c535be790604401600060405180830381600087803b1580156112fe57600080fd5b505af1158015611312573d6000803e3d6000fd5b505050506001600160a01b038881166000818152600760209081526040918290208990558151928352928a1692820192909252908101879052606081018690527fcd7c65ed8cfeb9a0e64513e51c9a506b7f49a353fc48b42affd6993c2af80eb49060800160405180910390a15050505050505050565b7f6666bf5bfee463d10a7fc50448047f8a53b7762d7e28fbc5c643182785f3fd3f6113b38161183c565b6113bb611dd1565b81156113f3576040517faa6905cc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006113fe86611e81565b6001600160a01b038716600090815260076020526040902054909150611425906001612e6b565b841461145d576040517f5e3312b600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517fdfeaa4b3000000000000000000000000000000000000000000000000000000008152600481018690526001600160a01b0382169063dfeaa4b390602401600060405180830381600087803b1580156114b857600080fd5b505af11580156114cc573d6000803e3d6000fd5b505050506001600160a01b0386166000818152600760209081526040918290208790558151928352820187905281018590527f93744be23632b71c15fda59d4fcb485fc80f35677969b2262f752f3c26a12a829060600160405180910390a1505050505050565b600061153d611a2d565b61154685611f42565b6040517fffffffffffffffffffffffff00000000000000000000000000000000000000009060009061157b9087908790612ea5565b6040519081900390209050600061159433848416612e6b565b600080546040805183815260208101909152929350909183916001600160a01b0316906040516115c390612674565b6115ce929190612eb5565b8190604051809103906000f59050801580156115ee573d6000803e3d6000fd5b506040517f125a02370000000000000000000000000000000000000000000000000000000081529091506001600160a01b0382169063125a02379061163f9030908d908d908d908d90600401612f02565b600060405180830381600087803b15801561165957600080fd5b505af115801561166d573d6000803e3d6000fd5b5050506001600160a01b03821660009081526005602052604090819020805460ff19166001179055517f52eb04d640c7a602488455e1c58ec60f4aca2ba18be6496ca4d8f719ca3c912591506116ca908b9084908c908c90612f56565b60405180910390a198975050505050505050565b606060048054610f4190612c21565b7f6666bf5bfee463d10a7fc50448047f8a53b7762d7e28fbc5c643182785f3fd3f6117178161183c565b61171f611dd1565b611727611e2d565b600061173287611e81565b6040517fc3ef90da0000000000000000000000000000000000000000000000000000000081526001600160a01b038881166004830152878116602483015260448201879052606482018690529192509082169063c3ef90da90608401600060405180830381600087803b1580156117a857600080fd5b505af11580156117bc573d6000803e3d6000fd5b505050506000816001600160a01b03166321df0da76040518163ffffffff1660e01b8152600401602060405180830381865afa158015611800573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118249190612dbe565b905061183281878988611f9e565b5050505050505050565b610b24813361202c565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800602081815260408084206001600160a01b038616855290915282205460ff1661190b576000848152602082815260408083206001600160a01b03871684529091529020805460ff191660011790556118c13390565b6001600160a01b0316836001600160a01b0316857f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a460019150506109c7565b60009150506109c7565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800602081815260408084206001600160a01b038616855290915282205460ff161561190b576000848152602082815260408083206001600160a01b0387168085529252808320805460ff1916905551339287917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a460019150506109c7565b6119c36120b9565b7fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f03300805460ff191681557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a150565b306001600160a01b037f00000000000000000000000044c0317f5b2bd8b730b3f180220591e5c1e7f934161480611ac657507f00000000000000000000000044c0317f5b2bd8b730b3f180220591e5c1e7f9346001600160a01b0316611aba7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b6001600160a01b031614155b15611afd576040517fe07c8dba00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0080546002919068010000000000000000900460ff1680611b4e5750805467ffffffffffffffff808416911610155b15611b85576040517ff92ee8a900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80547fffffffffffffffffffffffffffffffffffffffffffffff0000000000000000001667ffffffffffffffff83161768010000000000000000178155611bca611a2d565b6000611bfd7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b90506000819050806001600160a01b031663641ef0b06040518163ffffffff1660e01b8152600401602060405180830381865afa158015611c42573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c669190612dbe565b30604051611c7390612681565b6001600160a01b03928316815291166020820152604001604051809103906000f080158015611ca6573d6000803e3d6000fd5b50600080547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0392909216919091179055611ce7612114565b505080547fffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffff16815560405167ffffffffffffffff831681527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15050565b611d58611a2d565b611d6182612124565b611d6b828261212f565b5050565b306001600160a01b037f00000000000000000000000044c0317f5b2bd8b730b3f180220591e5c1e7f9341614611afd576040517fe07c8dba00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f033005460ff1615611afd576040517fd93c066500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60085474010000000000000000000000000000000000000000900460ff16611afd576040517f03b395ba00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b03811660009081526005602052604081205460ff16611ee3576040517fe22117bd0000000000000000000000000000000000000000000000000000000081526001600160a01b03831660048201526024015b60405180910390fd5b5090565b611eef611dd1565b7fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f03300805460ff191660011781557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a25833611a0f565b6001600160a01b0381811660009081526006602052604090205416610b24576040517f06439c6b0000000000000000000000000000000000000000000000000000000081526001600160a01b0382166004820152602401611eda565b604080516001600160a01b0385811660248301528416604482015260648082018490528251808303909101815260849091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f23b872dd00000000000000000000000000000000000000000000000000000000179052612026908590612230565b50505050565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800602090815260408083206001600160a01b038516845290915290205460ff16611d6b576040517fe2517d3f0000000000000000000000000000000000000000000000000000000081526001600160a01b038216600482015260248101839052604401611eda565b7fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f033005460ff16611afd576040517f8dfc202b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61211c6122ac565b611afd612313565b6000611d6b8161183c565b816001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa925050508015612189575060408051601f3d908101601f1916820190925261218691810190612f88565b60015b6121ca576040517f4c9c8ce30000000000000000000000000000000000000000000000000000000081526001600160a01b0383166004820152602401611eda565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc8114612226576040517faa1d49a400000000000000000000000000000000000000000000000000000000815260048101829052602401611eda565b6109ef8383612346565b60006122456001600160a01b0384168361239c565b9050805160001415801561226a5750808060200190518101906122689190612fa1565b155b156109ef576040517f5274afe70000000000000000000000000000000000000000000000000000000081526001600160a01b0384166004820152602401611eda565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005468010000000000000000900460ff16611afd576040517fd7e6bcf800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61231b6122ac565b7fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f03300805460ff19169055565b61234f826123b1565b6040516001600160a01b038316907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a2805115612394576109ef8282612459565b611d6b6124cf565b60606123aa83836000612507565b9392505050565b806001600160a01b03163b600003612400576040517f4c9c8ce30000000000000000000000000000000000000000000000000000000081526001600160a01b0382166004820152602401611eda565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0392909216919091179055565b6060600080846001600160a01b0316846040516124769190612fbc565b600060405180830381855af49150503d80600081146124b1576040519150601f19603f3d011682016040523d82523d6000602084013e6124b6565b606091505b50915091506124c68583836125bd565b95945050505050565b3415611afd576040517fb398979f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b606081471015612545576040517fcd786059000000000000000000000000000000000000000000000000000000008152306004820152602401611eda565b600080856001600160a01b031684866040516125619190612fbc565b60006040518083038185875af1925050503d806000811461259e576040519150601f19603f3d011682016040523d82523d6000602084013e6125a3565b606091505b50915091506125b38683836125bd565b9695505050505050565b6060826125d2576125cd82612632565b6123aa565b81511580156125e957506001600160a01b0384163b155b1561262b576040517f9996b3150000000000000000000000000000000000000000000000000000000081526001600160a01b0385166004820152602401611eda565b50806123aa565b8051156126425780518082602001fd5b6040517f1425ea4200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6105eb80612fd983390190565b610545806135c483390190565b6000602082840312156126a057600080fd5b81357fffffffff00000000000000000000000000000000000000000000000000000000811681146123aa57600080fd5b6001600160a01b0381168114610b2457600080fd5b6000602082840312156126f757600080fd5b81356123aa816126d0565b60006020828403121561271457600080fd5b5035919050565b6000806040838503121561272e57600080fd5b823591506020830135612740816126d0565b809150509250929050565b6000806040838503121561275e57600080fd5b8235612769816126d0565b91506020830135612740816126d0565b60008083601f84011261278b57600080fd5b50813567ffffffffffffffff8111156127a357600080fd5b6020830191508360208285010111156127bb57600080fd5b9250929050565b600080600080604085870312156127d857600080fd5b843567ffffffffffffffff8111156127ef57600080fd5b6127fb87828801612779565b909550935050602085013567ffffffffffffffff81111561281b57600080fd5b61282787828801612779565b95989497509550505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60405160c0810167ffffffffffffffff8111828210171561288557612885612833565b60405290565b604051601f8201601f1916810167ffffffffffffffff811182821017156128b4576128b4612833565b604052919050565b600080604083850312156128cf57600080fd5b82356128da816126d0565b9150602083013567ffffffffffffffff8111156128f657600080fd5b8301601f8101851361290757600080fd5b803567ffffffffffffffff81111561292157612921612833565b6129346020601f19601f8401160161288b565b81815286602083850101111561294957600080fd5b816020840160208301376000602083830101528093505050509250929050565b6000806000806080858703121561297f57600080fd5b843561298a816126d0565b9350602085013561299a816126d0565b93969395505050506040820135916060013590565b600080604083850312156129c257600080fd5b82356129cd816126d0565b946020939093013593505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b600060c08201905082518252602083015160208301526001600160a01b036040840151166040830152606083015160038110612a4857612a486129db565b8060608401525060808301511515608083015260a083015160a083015292915050565b60005b83811015612a86578181015183820152602001612a6e565b50506000910152565b60008151808452612aa7816020860160208601612a6b565b601f01601f19169290920160200192915050565b6020815260006123aa6020830184612a8f565b60008060008060808587031215612ae457600080fd5b8435612aef816126d0565b966020860135965060408601359560600135945092505050565b600080600080600060a08688031215612b2157600080fd5b8535612b2c816126d0565b94506020860135612b3c816126d0565b94979496505050506040830135926060810135926080909101359150565b60008060008060608587031215612b7057600080fd5b8435612b7b816126d0565b9350602085013567ffffffffffffffff811115612b9757600080fd5b612ba387828801612779565b909450925050604085013560028110612bbb57600080fd5b939692955090935050565b600080600080600060a08688031215612bde57600080fd5b8535612be9816126d0565b94506020860135612bf9816126d0565b93506040860135612c09816126d0565b94979396509394606081013594506080013592915050565b600181811c90821680612c3557607f821691505b602082108103612c6e577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b601f8211156109ef57806000526020600020601f840160051c81016020851015612c9b5750805b601f840160051c820191505b81811015612cbb5760008155600101612ca7565b5050505050565b67ffffffffffffffff831115612cda57612cda612833565b612cee83612ce88354612c21565b83612c74565b6000601f841160018114612d405760008515612d0a5750838201355b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600387901b1c1916600186901b178355612cbb565b600083815260209020601f19861690835b82811015612d715786850135825560209485019460019092019101612d51565b5086821015612dac577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60f88860031b161c19848701351681555b505060018560011b0183555050505050565b600060208284031215612dd057600080fd5b81516123aa816126d0565b80518015158114612deb57600080fd5b919050565b600060c0828403128015612e0357600080fd5b506000612e0e612862565b83518152602080850151908201526040840151612e2a816126d0565b6040820152606084015160038110612e40578283fd5b6060820152612e5160808501612ddb565b608082015260a09384015193810193909352509092915050565b808201808211156109c7577f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b8183823760009101908152919050565b6001600160a01b0383168152604060208201526000610f2a6040830184612a8f565b818352818160208501375060006020828401015260006020601f19601f840116840101905092915050565b6001600160a01b03861681526001600160a01b0385166020820152608060408201526000612f34608083018587612ed7565b905060028310612f4657612f466129db565b8260608301529695505050505050565b6001600160a01b03851681526001600160a01b03841660208201526060604082015260006125b3606083018486612ed7565b600060208284031215612f9a57600080fd5b5051919050565b600060208284031215612fb357600080fd5b6123aa82612ddb565b60008251612fce818460208701612a6b565b919091019291505056fe60a06040526040516105eb3803806105eb83398101604081905261002291610387565b61002c828261003e565b506001600160a01b0316608052610484565b610047826100fe565b6040516001600160a01b038316907f1cf3b03a6cf19fa2baba4df148e9dcabedea7f8a5c07840e207e5c089be95d3e90600090a28051156100f2576100ed826001600160a01b0316635c60da1b6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156100c3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906100e7919061044d565b82610211565b505050565b6100fa610288565b5050565b806001600160a01b03163b60000361013957604051631933b43b60e21b81526001600160a01b03821660048201526024015b60405180910390fd5b807fa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d5080546001600160a01b0319166001600160a01b0392831617905560408051635c60da1b60e01b81529051600092841691635c60da1b9160048083019260209291908290030181865afa1580156101b5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101d9919061044d565b9050806001600160a01b03163b6000036100fa57604051634c9c8ce360e01b81526001600160a01b0382166004820152602401610130565b6060600080846001600160a01b03168460405161022e9190610468565b600060405180830381855af49150503d8060008114610269576040519150601f19603f3d011682016040523d82523d6000602084013e61026e565b606091505b50909250905061027f8583836102a9565b95945050505050565b34156102a75760405163b398979f60e01b815260040160405180910390fd5b565b6060826102be576102b982610308565b610301565b81511580156102d557506001600160a01b0384163b155b156102fe57604051639996b31560e01b81526001600160a01b0385166004820152602401610130565b50805b9392505050565b8051156103185780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b80516001600160a01b038116811461034857600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b8381101561037e578181015183820152602001610366565b50506000910152565b6000806040838503121561039a57600080fd5b6103a383610331565b60208401519092506001600160401b038111156103bf57600080fd5b8301601f810185136103d057600080fd5b80516001600160401b038111156103e9576103e961034d565b604051601f8201601f19908116603f011681016001600160401b03811182821017156104175761041761034d565b60405281815282820160200187101561042f57600080fd5b610440826020830160208601610363565b8093505050509250929050565b60006020828403121561045f57600080fd5b61030182610331565b6000825161047a818460208701610363565b9190910192915050565b60805161014d61049e60003960006024015261014d6000f3fe608060405261000c61000e565b005b61001e610019610020565b6100b6565b565b60007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16635c60da1b6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561008d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906100b191906100da565b905090565b3660008037600080366000845af43d6000803e8080156100d5573d6000f35b3d6000fd5b6000602082840312156100ec57600080fd5b815173ffffffffffffffffffffffffffffffffffffffff8116811461011057600080fd5b939250505056fea2646970667358221220847da51342687254596c326192e2f3d8105e3ef1bf337cd24124316a6711d7ad64736f6c634300081c0033608060405234801561001057600080fd5b5060405161054538038061054583398101604081905261002f91610165565b806001600160a01b03811661005f57604051631e4fbdf760e01b8152600060048201526024015b60405180910390fd5b61006881610079565b50610072826100c9565b5050610198565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b806001600160a01b03163b6000036100ff5760405163211eb15960e21b81526001600160a01b0382166004820152602401610056565b600180546001600160a01b0319166001600160a01b0383169081179091556040517fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b80516001600160a01b038116811461016057600080fd5b919050565b6000806040838503121561017857600080fd5b61018183610149565b915061018f60208401610149565b90509250929050565b61039e806101a76000396000f3fe608060405234801561001057600080fd5b50600436106100675760003560e01c8063715018a611610050578063715018a6146100c45780638da5cb5b146100cc578063f2fde38b146100ea57600080fd5b80633659cfe61461006c5780635c60da1b14610081575b600080fd5b61007f61007a36600461032b565b6100fd565b005b60015473ffffffffffffffffffffffffffffffffffffffff165b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b61007f610111565b60005473ffffffffffffffffffffffffffffffffffffffff1661009b565b61007f6100f836600461032b565b610125565b61010561018b565b61010e816101de565b50565b61011961018b565b61012360006102b6565b565b61012d61018b565b73ffffffffffffffffffffffffffffffffffffffff8116610182576040517f1e4fbdf7000000000000000000000000000000000000000000000000000000008152600060048201526024015b60405180910390fd5b61010e816102b6565b60005473ffffffffffffffffffffffffffffffffffffffff163314610123576040517f118cdaa7000000000000000000000000000000000000000000000000000000008152336004820152602401610179565b8073ffffffffffffffffffffffffffffffffffffffff163b600003610247576040517f847ac56400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff82166004820152602401610179565b600180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83169081179091556040517fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60006020828403121561033d57600080fd5b813573ffffffffffffffffffffffffffffffffffffffff8116811461036157600080fd5b939250505056fea2646970667358221220e240865f9ac07da05345e9974bc71e5d074faab729148d0ee16b859b84ebd81e64736f6c634300081c0033a264697066735822122022a97ad9efa8b9e5b21adc17ae9b7941c7aca8fc6bcb658890a6d8f7d6d0b91864736f6c634300081c0033
Loading...
Loading
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.