Source Code
Overview
ETH Balance
0 ETH
ETH Value
$0.00
Cross-Chain Transactions
Loading...
Loading
Contract Name:
PublicLock
Compiler Version
v0.8.13+commit.abaa5c0e
Optimization Enabled:
Yes with 80 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/utils/introspection/ERC165StorageUpgradeable.sol";
import "./mixins/MixinDisable.sol";
import "./mixins/MixinERC721Enumerable.sol";
import "./mixins/MixinFunds.sol";
import "./mixins/MixinGrantKeys.sol";
import "./mixins/MixinKeys.sol";
import "./mixins/MixinLockCore.sol";
import "./mixins/MixinLockMetadata.sol";
import "./mixins/MixinPurchase.sol";
import "./mixins/MixinRefunds.sol";
import "./mixins/MixinTransfer.sol";
import "./mixins/MixinRoles.sol";
import "./mixins/MixinConvenienceOwnable.sol";
/**
* @title The Lock contract
* @author Julien Genestoux (unlock-protocol.com)
* @dev ERC165 allows our contract to be queried to determine whether it implements a given interface.
* Every ERC-721 compliant contract must implement the ERC165 interface.
* https://eips.ethereum.org/EIPS/eip-721
*/
contract PublicLock is
Initializable,
ERC165StorageUpgradeable,
MixinRoles,
MixinFunds,
MixinDisable,
MixinLockCore,
MixinKeys,
MixinLockMetadata,
MixinERC721Enumerable,
MixinGrantKeys,
MixinPurchase,
MixinTransfer,
MixinRefunds,
MixinConvenienceOwnable
{
function initialize(
address payable _lockCreator,
uint _expirationDuration,
address _tokenAddress,
uint _keyPrice,
uint _maxNumberOfKeys,
string calldata _lockName
) public initializer {
MixinFunds._initializeMixinFunds(_tokenAddress);
MixinLockCore._initializeMixinLockCore(
_lockCreator,
_expirationDuration,
_keyPrice,
_maxNumberOfKeys
);
MixinLockMetadata._initializeMixinLockMetadata(
_lockName
);
MixinERC721Enumerable._initializeMixinERC721Enumerable();
MixinRefunds._initializeMixinRefunds();
MixinRoles._initializeMixinRoles(_lockCreator);
MixinConvenienceOwnable
._initializeMixinConvenienceOwnable(_lockCreator);
// registering the interface for erc721 with ERC165.sol using
// the ID specified in the standard: https://eips.ethereum.org/EIPS/eip-721
_registerInterface(0x80ac58cd);
}
/**
* @notice Allow the contract to accept tips in ETH sent directly to the contract.
* @dev This is okay to use even if the lock is priced in ERC-20 tokens
*/
receive() external payable {}
/**
Overrides
*/
function supportsInterface(
bytes4 interfaceId
)
public
view
virtual
override(
MixinERC721Enumerable,
MixinLockMetadata,
AccessControlUpgradeable,
ERC165StorageUpgradeable
)
returns (bool)
{
return super.supportsInterface(interfaceId);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (access/AccessControl.sol)
pragma solidity ^0.8.0;
import "./IAccessControlUpgradeable.sol";
import "../utils/ContextUpgradeable.sol";
import "../utils/StringsUpgradeable.sol";
import "../utils/introspection/ERC165Upgradeable.sol";
import "../proxy/utils/Initializable.sol";
/**
* @dev Contract module that allows children to implement role-based access
* control mechanisms. This is a lightweight version that doesn't allow enumerating role
* members except through off-chain means by accessing the contract event logs. Some
* applications may benefit from on-chain enumerability, for those cases see
* {AccessControlEnumerable}.
*
* Roles are referred to by their `bytes32` identifier. These should be exposed
* in the external API and be unique. The best way to achieve this is by
* using `public constant` hash digests:
*
* ```
* bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
* ```
*
* Roles can be used to represent a set of permissions. To restrict access to a
* function call, use {hasRole}:
*
* ```
* function foo() public {
* require(hasRole(MY_ROLE, msg.sender));
* ...
* }
* ```
*
* Roles can be granted and revoked dynamically via the {grantRole} and
* {revokeRole} functions. Each role has an associated admin role, and only
* accounts that have a role's admin role can call {grantRole} and {revokeRole}.
*
* By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
* that only accounts with this role will be able to grant or revoke other
* roles. More complex role relationships can be created by using
* {_setRoleAdmin}.
*
* WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
* grant and revoke this role. Extra precautions should be taken to secure
* accounts that have been granted it.
*/
abstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControlUpgradeable, ERC165Upgradeable {
function __AccessControl_init() internal onlyInitializing {
}
function __AccessControl_init_unchained() internal onlyInitializing {
}
struct RoleData {
mapping(address => bool) members;
bytes32 adminRole;
}
mapping(bytes32 => RoleData) private _roles;
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
/**
* @dev Modifier that checks that an account has a specific role. Reverts
* with a standardized message including the required role.
*
* The format of the revert reason is given by the following regular expression:
*
* /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
*
* _Available since v4.1._
*/
modifier onlyRole(bytes32 role) {
_checkRole(role);
_;
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IAccessControlUpgradeable).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) public view virtual override returns (bool) {
return _roles[role].members[account];
}
/**
* @dev Revert with a standard message if `_msgSender()` is missing `role`.
* Overriding this function changes the behavior of the {onlyRole} modifier.
*
* Format of the revert message is described in {_checkRole}.
*
* _Available since v4.6._
*/
function _checkRole(bytes32 role) internal view virtual {
_checkRole(role, _msgSender());
}
/**
* @dev Revert with a standard message if `account` is missing `role`.
*
* The format of the revert reason is given by the following regular expression:
*
* /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
*/
function _checkRole(bytes32 role, address account) internal view virtual {
if (!hasRole(role, account)) {
revert(
string(
abi.encodePacked(
"AccessControl: account ",
StringsUpgradeable.toHexString(account),
" is missing role ",
StringsUpgradeable.toHexString(uint256(role), 32)
)
)
);
}
}
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) {
return _roles[role].adminRole;
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*
* May emit a {RoleGranted} event.
*/
function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
_grantRole(role, account);
}
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*
* May emit a {RoleRevoked} event.
*/
function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
_revokeRole(role, account);
}
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been revoked `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `account`.
*
* May emit a {RoleRevoked} event.
*/
function renounceRole(bytes32 role, address account) public virtual override {
require(account == _msgSender(), "AccessControl: can only renounce roles for self");
_revokeRole(role, account);
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event. Note that unlike {grantRole}, this function doesn't perform any
* checks on the calling account.
*
* May emit a {RoleGranted} event.
*
* [WARNING]
* ====
* This function should only be called from the constructor when setting
* up the initial roles for the system.
*
* Using this function in any other way is effectively circumventing the admin
* system imposed by {AccessControl}.
* ====
*
* NOTE: This function is deprecated in favor of {_grantRole}.
*/
function _setupRole(bytes32 role, address account) internal virtual {
_grantRole(role, account);
}
/**
* @dev Sets `adminRole` as ``role``'s admin role.
*
* Emits a {RoleAdminChanged} event.
*/
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
bytes32 previousAdminRole = getRoleAdmin(role);
_roles[role].adminRole = adminRole;
emit RoleAdminChanged(role, previousAdminRole, adminRole);
}
/**
* @dev Grants `role` to `account`.
*
* Internal function without access restriction.
*
* May emit a {RoleGranted} event.
*/
function _grantRole(bytes32 role, address account) internal virtual {
if (!hasRole(role, account)) {
_roles[role].members[account] = true;
emit RoleGranted(role, account, _msgSender());
}
}
/**
* @dev Revokes `role` from `account`.
*
* Internal function without access restriction.
*
* May emit a {RoleRevoked} event.
*/
function _revokeRole(bytes32 role, address account) internal virtual {
if (hasRole(role, account)) {
_roles[role].members[account] = false;
emit RoleRevoked(role, account, _msgSender());
}
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[49] private __gap;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)
pragma solidity ^0.8.0;
/**
* @dev External interface of AccessControl declared to support ERC165 detection.
*/
interface IAccessControlUpgradeable {
/**
* @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
*
* `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
* {RoleAdminChanged} not being emitted signaling this.
*
* _Available since v3.1._
*/
event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);
/**
* @dev Emitted when `account` is granted `role`.
*
* `sender` is the account that originated the contract call, an admin role
* bearer except when using {AccessControl-_setupRole}.
*/
event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Emitted when `account` is revoked `role`.
*
* `sender` is the account that originated the contract call:
* - if using `revokeRole`, it is the admin role bearer
* - if using `renounceRole`, it is the role bearer (i.e. `account`)
*/
event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) external view returns (bool);
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {AccessControl-_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) external view returns (bytes32);
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function grantRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function revokeRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been granted `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `account`.
*/
function renounceRole(bytes32 role, address account) external;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.1) (proxy/utils/Initializable.sol)
pragma solidity ^0.8.2;
import "../../utils/AddressUpgradeable.sol";
/**
* @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
* behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
* external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
* function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
*
* The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
* reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
* case an upgrade adds a module that needs to be initialized.
*
* For example:
*
* [.hljs-theme-light.nopadding]
* ```
* contract MyToken is ERC20Upgradeable {
* function initialize() initializer public {
* __ERC20_init("MyToken", "MTK");
* }
* }
* contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
* function initializeV2() reinitializer(2) public {
* __ERC20Permit_init("MyToken");
* }
* }
* ```
*
* TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
* possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
*
* CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
* that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
*
* [CAUTION]
* ====
* Avoid leaving a contract uninitialized.
*
* An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
* contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
* the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
*
* [.hljs-theme-light.nopadding]
* ```
* /// @custom:oz-upgrades-unsafe-allow constructor
* constructor() {
* _disableInitializers();
* }
* ```
* ====
*/
abstract contract Initializable {
/**
* @dev Indicates that the contract has been initialized.
* @custom:oz-retyped-from bool
*/
uint8 private _initialized;
/**
* @dev Indicates that the contract is in the process of being initialized.
*/
bool private _initializing;
/**
* @dev Triggered when the contract has been initialized or reinitialized.
*/
event Initialized(uint8 version);
/**
* @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
* `onlyInitializing` functions can be used to initialize parent contracts.
*
* Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a
* constructor.
*
* Emits an {Initialized} event.
*/
modifier initializer() {
bool isTopLevelCall = !_initializing;
require(
(isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),
"Initializable: contract is already initialized"
);
_initialized = 1;
if (isTopLevelCall) {
_initializing = true;
}
_;
if (isTopLevelCall) {
_initializing = false;
emit Initialized(1);
}
}
/**
* @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
* contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
* used to initialize parent contracts.
*
* A reinitializer may be used after the original initialization step. This is essential to configure modules that
* are added through upgrades and that require initialization.
*
* When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
* cannot be nested. If one is invoked in the context of another, execution will revert.
*
* Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
* a contract, executing them in the right order is up to the developer or operator.
*
* WARNING: setting the version to 255 will prevent any future reinitialization.
*
* Emits an {Initialized} event.
*/
modifier reinitializer(uint8 version) {
require(!_initializing && _initialized < version, "Initializable: contract is already initialized");
_initialized = version;
_initializing = true;
_;
_initializing = false;
emit Initialized(version);
}
/**
* @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
* {initializer} and {reinitializer} modifiers, directly or indirectly.
*/
modifier onlyInitializing() {
require(_initializing, "Initializable: contract is not initializing");
_;
}
/**
* @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
* Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
* to any version. It is recommended to use this to lock implementation contracts that are designed to be called
* through proxies.
*
* Emits an {Initialized} event the first time it is successfully executed.
*/
function _disableInitializers() internal virtual {
require(!_initializing, "Initializable: contract is initializing");
if (_initialized < type(uint8).max) {
_initialized = type(uint8).max;
emit Initialized(type(uint8).max);
}
}
/**
* @dev Returns the highest version that has been initialized. See {reinitializer}.
*/
function _getInitializedVersion() internal view returns (uint8) {
return _initialized;
}
/**
* @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.
*/
function _isInitializing() internal view returns (bool) {
return _initializing;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
* https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
*
* Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
* presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
* need to send a transaction, and thus is not required to hold Ether at all.
*/
interface IERC20PermitUpgradeable {
/**
* @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
* given ``owner``'s signed approval.
*
* IMPORTANT: The same issues {IERC20-approve} has related to transaction
* ordering also apply here.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `deadline` must be a timestamp in the future.
* - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
* over the EIP712-formatted function arguments.
* - the signature must use ``owner``'s current nonce (see {nonces}).
*
* For more information on the signature format, see the
* https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
* section].
*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
/**
* @dev Returns the current nonce for `owner`. This value must be
* included whenever a signature is generated for {permit}.
*
* Every successful call to {permit} increases ``owner``'s nonce by one. This
* prevents a signature from being used multiple times.
*/
function nonces(address owner) external view returns (uint256);
/**
* @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view returns (bytes32);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20Upgradeable {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `from` to `to` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 amount
) external returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.0;
import "../IERC20Upgradeable.sol";
import "../extensions/draft-IERC20PermitUpgradeable.sol";
import "../../../utils/AddressUpgradeable.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20Upgradeable {
using AddressUpgradeable for address;
function safeTransfer(
IERC20Upgradeable token,
address to,
uint256 value
) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
function safeTransferFrom(
IERC20Upgradeable token,
address from,
address to,
uint256 value
) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
/**
* @dev Deprecated. This function has issues similar to the ones found in
* {IERC20-approve}, and its usage is discouraged.
*
* Whenever possible, use {safeIncreaseAllowance} and
* {safeDecreaseAllowance} instead.
*/
function safeApprove(
IERC20Upgradeable token,
address spender,
uint256 value
) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
require(
(value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
function safeIncreaseAllowance(
IERC20Upgradeable token,
address spender,
uint256 value
) internal {
uint256 newAllowance = token.allowance(address(this), spender) + value;
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
function safeDecreaseAllowance(
IERC20Upgradeable token,
address spender,
uint256 value
) internal {
unchecked {
uint256 oldAllowance = token.allowance(address(this), spender);
require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
uint256 newAllowance = oldAllowance - value;
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
}
function safePermit(
IERC20PermitUpgradeable token,
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) internal {
uint256 nonceBefore = token.nonces(owner);
token.permit(owner, spender, value, deadline, v, r, s);
uint256 nonceAfter = token.nonces(owner);
require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20Upgradeable token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
if (returndata.length > 0) {
// Return data is optional
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)
pragma solidity ^0.8.0;
/**
* @title ERC721 token receiver interface
* @dev Interface for any contract that wants to support safeTransfers
* from ERC721 asset contracts.
*/
interface IERC721ReceiverUpgradeable {
/**
* @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
* by `operator` from `from`, this function is called.
*
* It must return its Solidity selector to confirm the token transfer.
* If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
*
* The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.
*/
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library AddressUpgradeable {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
* the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
*
* _Available since v4.8._
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata,
string memory errorMessage
) internal view returns (bytes memory) {
if (success) {
if (returndata.length == 0) {
// only check isContract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
require(isContract(target), "Address: call to non-contract");
}
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
/**
* @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason or using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
function _revert(bytes memory returndata, string memory errorMessage) private pure {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
import "../proxy/utils/Initializable.sol";
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract ContextUpgradeable is Initializable {
function __Context_init() internal onlyInitializing {
}
function __Context_init_unchained() internal onlyInitializing {
}
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[50] private __gap;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165Storage.sol)
pragma solidity ^0.8.0;
import "./ERC165Upgradeable.sol";
import "../../proxy/utils/Initializable.sol";
/**
* @dev Storage based implementation of the {IERC165} interface.
*
* Contracts may inherit from this and call {_registerInterface} to declare
* their support of an interface.
*/
abstract contract ERC165StorageUpgradeable is Initializable, ERC165Upgradeable {
function __ERC165Storage_init() internal onlyInitializing {
}
function __ERC165Storage_init_unchained() internal onlyInitializing {
}
/**
* @dev Mapping of interface ids to whether or not it's supported.
*/
mapping(bytes4 => bool) private _supportedInterfaces;
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return super.supportsInterface(interfaceId) || _supportedInterfaces[interfaceId];
}
/**
* @dev Registers the contract as an implementer of the interface defined by
* `interfaceId`. Support of the actual ERC165 interface is automatic and
* registering its interface id is not required.
*
* See {IERC165-supportsInterface}.
*
* Requirements:
*
* - `interfaceId` cannot be the ERC165 invalid interface (`0xffffffff`).
*/
function _registerInterface(bytes4 interfaceId) internal virtual {
require(interfaceId != 0xffffffff, "ERC165: invalid interface id");
_supportedInterfaces[interfaceId] = true;
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[49] private __gap;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)
pragma solidity ^0.8.0;
import "./IERC165Upgradeable.sol";
import "../../proxy/utils/Initializable.sol";
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*
* Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
*/
abstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable {
function __ERC165_init() internal onlyInitializing {
}
function __ERC165_init_unchained() internal onlyInitializing {
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165Upgradeable).interfaceId;
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[50] private __gap;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165Upgradeable {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol)
pragma solidity ^0.8.0;
/**
* @dev Standard math utilities missing in the Solidity language.
*/
library MathUpgradeable {
enum Rounding {
Down, // Toward negative infinity
Up, // Toward infinity
Zero // Toward zero
}
/**
* @dev Returns the largest of two numbers.
*/
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a > b ? a : b;
}
/**
* @dev Returns the smallest of two numbers.
*/
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two numbers. The result is rounded towards
* zero.
*/
function average(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b) / 2 can overflow.
return (a & b) + (a ^ b) / 2;
}
/**
* @dev Returns the ceiling of the division of two numbers.
*
* This differs from standard division with `/` in that it rounds up instead
* of rounding down.
*/
function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b - 1) / b can overflow on addition, so we distribute.
return a == 0 ? 0 : (a - 1) / b + 1;
}
/**
* @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
* @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)
* with further edits by Uniswap Labs also under MIT license.
*/
function mulDiv(
uint256 x,
uint256 y,
uint256 denominator
) internal pure returns (uint256 result) {
unchecked {
// 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
// use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
// variables such that product = prod1 * 2^256 + prod0.
uint256 prod0; // Least significant 256 bits of the product
uint256 prod1; // Most significant 256 bits of the product
assembly {
let mm := mulmod(x, y, not(0))
prod0 := mul(x, y)
prod1 := sub(sub(mm, prod0), lt(mm, prod0))
}
// Handle non-overflow cases, 256 by 256 division.
if (prod1 == 0) {
return prod0 / denominator;
}
// Make sure the result is less than 2^256. Also prevents denominator == 0.
require(denominator > prod1);
///////////////////////////////////////////////
// 512 by 256 division.
///////////////////////////////////////////////
// Make division exact by subtracting the remainder from [prod1 prod0].
uint256 remainder;
assembly {
// Compute remainder using mulmod.
remainder := mulmod(x, y, denominator)
// Subtract 256 bit number from 512 bit number.
prod1 := sub(prod1, gt(remainder, prod0))
prod0 := sub(prod0, remainder)
}
// Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.
// See https://cs.stackexchange.com/q/138556/92363.
// Does not overflow because the denominator cannot be zero at this stage in the function.
uint256 twos = denominator & (~denominator + 1);
assembly {
// Divide denominator by twos.
denominator := div(denominator, twos)
// Divide [prod1 prod0] by twos.
prod0 := div(prod0, twos)
// Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
twos := add(div(sub(0, twos), twos), 1)
}
// Shift in bits from prod1 into prod0.
prod0 |= prod1 * twos;
// Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
// that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
// four bits. That is, denominator * inv = 1 mod 2^4.
uint256 inverse = (3 * denominator) ^ 2;
// Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works
// in modular arithmetic, doubling the correct bits in each step.
inverse *= 2 - denominator * inverse; // inverse mod 2^8
inverse *= 2 - denominator * inverse; // inverse mod 2^16
inverse *= 2 - denominator * inverse; // inverse mod 2^32
inverse *= 2 - denominator * inverse; // inverse mod 2^64
inverse *= 2 - denominator * inverse; // inverse mod 2^128
inverse *= 2 - denominator * inverse; // inverse mod 2^256
// Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
// This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
// less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
// is no longer required.
result = prod0 * inverse;
return result;
}
}
/**
* @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
*/
function mulDiv(
uint256 x,
uint256 y,
uint256 denominator,
Rounding rounding
) internal pure returns (uint256) {
uint256 result = mulDiv(x, y, denominator);
if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {
result += 1;
}
return result;
}
/**
* @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.
*
* Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
*/
function sqrt(uint256 a) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
// For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
//
// We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
// `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
//
// This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
// → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
// → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
//
// Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
uint256 result = 1 << (log2(a) >> 1);
// At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
// since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
// every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
// into the expected uint128 result.
unchecked {
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
return min(result, a / result);
}
}
/**
* @notice Calculates sqrt(a), following the selected rounding direction.
*/
function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = sqrt(a);
return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);
}
}
/**
* @dev Return the log in base 2, rounded down, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 128;
}
if (value >> 64 > 0) {
value >>= 64;
result += 64;
}
if (value >> 32 > 0) {
value >>= 32;
result += 32;
}
if (value >> 16 > 0) {
value >>= 16;
result += 16;
}
if (value >> 8 > 0) {
value >>= 8;
result += 8;
}
if (value >> 4 > 0) {
value >>= 4;
result += 4;
}
if (value >> 2 > 0) {
value >>= 2;
result += 2;
}
if (value >> 1 > 0) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 2, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log2(value);
return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 10, rounded down, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >= 10**64) {
value /= 10**64;
result += 64;
}
if (value >= 10**32) {
value /= 10**32;
result += 32;
}
if (value >= 10**16) {
value /= 10**16;
result += 16;
}
if (value >= 10**8) {
value /= 10**8;
result += 8;
}
if (value >= 10**4) {
value /= 10**4;
result += 4;
}
if (value >= 10**2) {
value /= 10**2;
result += 2;
}
if (value >= 10**1) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 10, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log10(value);
return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 256, rounded down, of a positive value.
* Returns 0 if given 0.
*
* Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
*/
function log256(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 16;
}
if (value >> 64 > 0) {
value >>= 64;
result += 8;
}
if (value >> 32 > 0) {
value >>= 32;
result += 4;
}
if (value >> 16 > 0) {
value >>= 16;
result += 2;
}
if (value >> 8 > 0) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 10, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log256(value);
return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol)
pragma solidity ^0.8.0;
import "./math/MathUpgradeable.sol";
/**
* @dev String operations.
*/
library StringsUpgradeable {
bytes16 private constant _SYMBOLS = "0123456789abcdef";
uint8 private constant _ADDRESS_LENGTH = 20;
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
unchecked {
uint256 length = MathUpgradeable.log10(value) + 1;
string memory buffer = new string(length);
uint256 ptr;
/// @solidity memory-safe-assembly
assembly {
ptr := add(buffer, add(32, length))
}
while (true) {
ptr--;
/// @solidity memory-safe-assembly
assembly {
mstore8(ptr, byte(mod(value, 10), _SYMBOLS))
}
value /= 10;
if (value == 0) break;
}
return buffer;
}
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
unchecked {
return toHexString(value, MathUpgradeable.log256(value) + 1);
}
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
/**
* @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
*/
function toHexString(address addr) internal pure returns (string memory) {
return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
}
}// SPDX-License-Identifier: MIT
pragma solidity >=0.5.17 <0.9.0;
/**
* @notice Functions to be implemented by a keyCancelHook.
* @dev Lock hooks are configured by calling `setEventHooks` on the lock.
*/
interface ILockKeyCancelHook {
/**
* @notice If the lock owner has registered an implementer
* then this hook is called with every key cancel.
* @param operator the msg.sender issuing the cancel
* @param to the account which had the key canceled
* @param refund the amount sent to the `to` account (ETH or a ERC-20 token)
*/
function onKeyCancel(
address operator,
address to,
uint256 refund
) external;
}// SPDX-License-Identifier: MIT
pragma solidity >=0.5.17 <0.9.0;
/**
* @notice Functions to be implemented by a keyExtendHook.
* @dev Lock hooks are configured by calling `setEventHooks` on the lock.
*/
interface ILockKeyExtendHook {
/**
* @notice This hook every time a key is extended.
* @param tokenId tje id of the key
* @param from the msg.sender making the purchase
* @param newTimestamp the new expiration timestamp after the key extension
* @param prevTimestamp the expiration timestamp of the key before being extended
*/
function onKeyExtend(
uint tokenId,
address from,
uint newTimestamp,
uint prevTimestamp
) external;
}// SPDX-License-Identifier: MIT
pragma solidity >=0.5.17 <0.9.0;
/**
* @notice Functions to be implemented by a KeyGrantedHook.
* @dev Lock hooks are configured by calling `setEventHooks` on the lock.
*/
interface ILockKeyGrantHook {
/**
* @notice If the lock owner has registered an implementer then this hook
* is called with every key granted.
* @param tokenId the id of the granted key
* @param from the msg.sender granting the key
* @param recipient the account which will be granted a key
* @param keyManager an additional keyManager for the key
* @param expiration the expiration timestamp of the key
* @dev the lock's address is the `msg.sender` when this function is called
*/
function onKeyGranted(
uint tokenId,
address from,
address recipient,
address keyManager,
uint expiration
) external;
}// SPDX-License-Identifier: MIT
pragma solidity >=0.5.17 <0.9.0;
/**
* @notice Functions to be implemented by a keyPurchaseHook.
* @dev Lock hooks are configured by calling `setEventHooks` on the lock.
*/
interface ILockKeyPurchaseHook {
/**
* @notice Used to determine the purchase price before issueing a transaction.
* This allows the hook to offer a discount on purchases.
* This may revert to prevent a purchase.
* @param from the msg.sender making the purchase
* @param recipient the account which will be granted a key
* @param referrer the account which referred this key sale
* @param data arbitrary data populated by the front-end which initiated the sale
* @return minKeyPrice the minimum value/price required to purchase a key with these settings
* @dev the lock's address is the `msg.sender` when this function is called via
* the lock's `purchasePriceFor` function
*/
function keyPurchasePrice(
address from,
address recipient,
address referrer,
bytes calldata data
) external view returns (uint minKeyPrice);
/**
* @notice If the lock owner has registered an implementer then this hook
* is called with every key sold.
* @param tokenId the id of the purchased key
* @param from the msg.sender making the purchase
* @param recipient the account which will be granted a key
* @param referrer the account which referred this key sale
* @param data arbitrary data populated by the front-end which initiated the sale
* @param minKeyPrice the price including any discount granted from calling this
* hook's `keyPurchasePrice` function
* @param pricePaid the value/pricePaid included with the purchase transaction
* @dev the lock's address is the `msg.sender` when this function is called
*/
function onKeyPurchase(
uint tokenId,
address from,
address recipient,
address referrer,
bytes calldata data,
uint minKeyPrice,
uint pricePaid
) external;
}// SPDX-License-Identifier: MIT
pragma solidity >=0.5.17 <0.9.0;
/**
* @notice Functions to be implemented by a onKeyTransferHook Hook.
* @dev Lock hooks are configured by calling `setEventHooks` on the lock.
*/
interface ILockKeyTransferHook {
/**
* @notice If the lock owner has registered an implementer then this hook
* is called every time balanceOf is called
* @param lockAddress the address of the current lock
* @param tokenId the Id of the transferred key
* @param operator who initiated the transfer
* @param from the previous owner of transferred key
* @param from the previous owner of transferred key
* @param to the new owner of the key
* @param expirationTimestamp the key expiration timestamp (after transfer)
*/
function onKeyTransfer(
address lockAddress,
uint tokenId,
address operator,
address from,
address to,
uint expirationTimestamp
) external;
}// SPDX-License-Identifier: MIT
pragma solidity >=0.5.17 <0.9.0;
/**
* @notice Functions to be implemented by a tokenURIHook.
* @dev Lock hooks are configured by calling `setEventHooks` on the lock.
*/
interface ILockTokenURIHook {
/**
* @notice If the lock owner has registered an implementer
* then this hook is called every time `tokenURI()` is called
* @param lockAddress the address of the lock
* @param operator the msg.sender issuing the call
* @param owner the owner of the key for which we are retrieving the `tokenUri`
* @param keyId the id (tokenId) of the key (if applicable)
* @param expirationTimestamp the key expiration timestamp
* @return the tokenURI
*/
function tokenURI(
address lockAddress,
address operator,
address owner,
uint256 keyId,
uint expirationTimestamp
) external view returns (string memory);
}// SPDX-License-Identifier: MIT
pragma solidity >=0.5.17 <0.9.0;
/**
* @notice Functions to be implemented by a hasValidKey Hook.
* @dev Lock hooks are configured by calling `setEventHooks` on the lock.
*/
interface ILockValidKeyHook {
/**
* @notice If the lock owner has registered an implementer then this hook
* is called every time `isValidKey` is called (which affects `getHasValidKey` and `balanceOf`)
* @param lockAddress the address of the current lock
* @param operator the address that is calling the function (`msg.sender`)
* @param tokenId the id of the token to check
* @param expirationTimestamp the key expiration timestamp
* @param keyOwner the owner of the key
* @param isValidKey the actual validity of the key
*/
function isValidKey(
address lockAddress,
address operator,
uint tokenId,
uint expirationTimestamp,
address keyOwner,
bool isValidKey
) external view returns (bool);
}// SPDX-License-Identifier: MIT
pragma solidity >=0.5.17 <0.9.0;
/**
* @title The Unlock Interface
**/
interface IUnlock {
// Use initialize instead of a constructor to support proxies(for upgradeability via zos).
function initialize(address _unlockOwner) external;
/**
* @dev deploy a ProxyAdmin contract used to upgrade locks
*/
function initializeProxyAdmin() external;
/**
* Retrieve the contract address of the proxy admin that manages the locks
* @return _proxyAdminAddress the address of the ProxyAdmin instance
*/
function proxyAdminAddress()
external
view
returns (address _proxyAdminAddress);
/**
* @notice Create lock (legacy)
* This deploys a lock for a creator. It also keeps track of the deployed lock.
* @param _expirationDuration the duration of the lock (pass 0 for unlimited duration)
* @param _tokenAddress set to the ERC20 token address, or 0 for ETH.
* @param _keyPrice the price of each key
* @param _maxNumberOfKeys the maximum nimbers of keys to be edited
* @param _lockName the name of the lock
* param _salt [deprec] -- kept only for backwards copatibility
* This may be implemented as a sequence ID or with RNG. It's used with `create2`
* to know the lock's address before the transaction is mined.
* @dev internally call `createUpgradeableLock`
*/
function createLock(
uint _expirationDuration,
address _tokenAddress,
uint _keyPrice,
uint _maxNumberOfKeys,
string calldata _lockName,
bytes12 // _salt
) external returns (address);
/**
* @notice Create lock (default)
* This deploys a lock for a creator. It also keeps track of the deployed lock.
* @param data bytes containing the call to initialize the lock template
* @dev this call is passed as encoded function - for instance:
* bytes memory data = abi.encodeWithSignature(
* 'initialize(address,uint256,address,uint256,uint256,string)',
* msg.sender,
* _expirationDuration,
* _tokenAddress,
* _keyPrice,
* _maxNumberOfKeys,
* _lockName
* );
* @return address of the create lock
*/
function createUpgradeableLock(
bytes memory data
) external returns (address);
/**
* Create an upgradeable lock using a specific PublicLock version
* @param data bytes containing the call to initialize the lock template
* (refer to createUpgradeableLock for more details)
* @param _lockVersion the version of the lock to use
*/
function createUpgradeableLockAtVersion(
bytes memory data,
uint16 _lockVersion
) external returns (address);
/**
* @notice Upgrade a lock to a specific version
* @dev only available for publicLockVersion > 10 (proxyAdmin /required)
* @param lockAddress the existing lock address
* @param version the version number you are targeting
* Likely implemented with OpenZeppelin TransparentProxy contract
*/
function upgradeLock(
address payable lockAddress,
uint16 version
) external returns (address);
/**
* This function keeps track of the added GDP, as well as grants of discount tokens
* to the referrer, if applicable.
* The number of discount tokens granted is based on the value of the referal,
* the current growth rate and the lock's discount token distribution rate
* This function is invoked by a previously deployed lock only.
*/
function recordKeyPurchase(
uint _value,
address _referrer // solhint-disable-line no-unused-vars
) external;
/**
* @notice [DEPRECATED] Call to this function has been removed from PublicLock > v9.
* @dev [DEPRECATED] Kept for backwards compatibility
* This function will keep track of consumed discounts by a given user.
* It will also grant discount tokens to the creator who is granting the discount based on the
* amount of discount and compensation rate.
* This function is invoked by a previously deployed lock only.
*/
function recordConsumedDiscount(
uint _discount,
uint _tokens // solhint-disable-line no-unused-vars
) external view;
/**
* @notice [DEPRECATED] Call to this function has been removed from PublicLock > v9.
* @dev [DEPRECATED] Kept for backwards compatibility
* This function returns the discount available for a user, when purchasing a
* a key from a lock.
* This does not modify the state. It returns both the discount and the number of tokens
* consumed to grant that discount.
*/
function computeAvailableDiscountFor(
address _purchaser, // solhint-disable-line no-unused-vars
uint _keyPrice // solhint-disable-line no-unused-vars
) external pure returns (uint discount, uint tokens);
// Function to read the globalTokenURI field.
function globalBaseTokenURI()
external
view
returns (string memory);
/**
* @dev Redundant with globalBaseTokenURI() for backwards compatibility with v3 & v4 locks.
*/
function getGlobalBaseTokenURI()
external
view
returns (string memory);
// Function to read the globalTokenSymbol field.
function globalTokenSymbol()
external
view
returns (string memory);
// Function to read the chainId field.
function chainId() external view returns (uint);
/**
* @dev Redundant with globalTokenSymbol() for backwards compatibility with v3 & v4 locks.
*/
function getGlobalTokenSymbol()
external
view
returns (string memory);
/**
* @notice Allows the owner to update configuration variables
*/
function configUnlock(
address _udt,
address _weth,
uint _estimatedGasForPurchase,
string calldata _symbol,
string calldata _URI,
uint _chainId
) external;
/**
* @notice Add a PublicLock template to be used for future calls to `createLock`.
* @dev This is used to upgrade conytract per version number
*/
function addLockTemplate(
address impl,
uint16 version
) external;
/**
* Match lock templates addresses with version numbers
* @param _version the number of the version of the template
* @return _implAddress address of the lock templates
*/
function publicLockImpls(
uint16 _version
) external view returns (address _implAddress);
/**
* Match version numbers with lock templates addresses
* @param _impl the address of the deployed template contract (PublicLock)
* @return number of the version corresponding to this address
*/
function publicLockVersions(
address _impl
) external view returns (uint16);
/**
* Retrive the latest existing lock template version
* @return _version the version number of the latest template (used to deploy contracts)
*/
function publicLockLatestVersion()
external
view
returns (uint16 _version);
/**
* @notice Upgrade the PublicLock template used for future calls to `createLock`.
* @dev This will initialize the template and revokeOwnership.
*/
function setLockTemplate(
address payable _publicLockAddress
) external;
// Allows the owner to change the value tracking variables as needed.
function resetTrackedValue(
uint _grossNetworkProduct,
uint _totalDiscountGranted
) external;
function grossNetworkProduct()
external
view
returns (uint);
function totalDiscountGranted()
external
view
returns (uint);
function locks(
address
)
external
view
returns (
bool deployed,
uint totalSales,
uint yieldedDiscountTokens
);
// The address of the public lock template, used when `createLock` is called
function publicLockAddress()
external
view
returns (address);
// Map token address to exchange contract address if the token is supported
// Used for GDP calculations
function uniswapOracles(
address
) external view returns (address);
// The WETH token address, used for value calculations
function weth() external view returns (address);
// The UDT token address, used to mint tokens on referral
function udt() external view returns (address);
// The approx amount of gas required to purchase a key
function estimatedGasForPurchase()
external
view
returns (uint);
/**
* Helper to get the network mining basefee as introduced in EIP-1559
* @dev this helper can be wrapped in try/catch statement to avoid
* revert in networks where EIP-1559 is not implemented
*/
function networkBaseFee() external view returns (uint);
// The version number of the current Unlock implementation on this network
function unlockVersion() external pure returns (uint16);
/**
* @notice allows the owner to set the oracle address to use for value conversions
* setting the _oracleAddress to address(0) removes support for the token
* @dev This will also call update to ensure at least one datapoint has been recorded.
*/
function setOracle(
address _tokenAddress,
address _oracleAddress
) external;
// Initialize the Ownable contract, granting contract ownership to the specified sender
function __initializeOwnable(address sender) external;
/**
* @dev Returns true if the caller is the current owner.
*/
function isOwner() external view returns (bool);
/**
* @dev Returns the address of the current owner.
*/
function owner() external view returns (address);
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() external;
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) external;
/**
* Set the fee collected by the protocol
* @param _protocolFee fee (in basis points)
*/
function setProtocolFee(uint _protocolFee) external;
/**
* The fee (in basis points) collected by the protocol on each purchase /
extension / renewal of a key
* @return the protocol fee in basic point
*/
function protocolFee() external view returns (uint);
/**
* Returns the ProxyAdmin contract address that manage upgrades for
* the current Unlock contract.
* @dev this reads the address directly from storage, at the slot `_ADMIN_SLOT`
* defined by Open Zeppelin's EIP1967 Proxy implementation which corresponds
* to the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1
*/
function getAdmin() external view returns (address);
/**
* Call executed by a lock after its version upgrade triggred by `upgradeLock`
* - PublicLock v12 > v13 (mainnet): migrate an existing Lock to another instance
* of the Unlock contract
* @dev The `msg.sender` will be the upgraded lock
*/
function postLockUpgrade() external;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./MixinLockCore.sol";
import "./MixinErrors.sol";
/**
* @title Mixin to add support for `ownable()`
* @dev `Mixins` are a design pattern seen in the 0x contracts. It simply
* separates logically groupings of code to ease readability.
*/
contract MixinConvenienceOwnable is
MixinErrors,
MixinLockCore
{
// used for `owner()`convenience helper
address private _convenienceOwner;
// events
event OwnershipTransferred(
address previousOwner,
address newOwner
);
function _initializeMixinConvenienceOwnable(
address _sender
) internal {
_convenienceOwner = _sender;
}
/** `owner()` is provided as an helper to mimick the `Ownable` contract ABI.
* The `Ownable` logic is used by many 3rd party services to determine
* contract ownership - e.g. who is allowed to edit metadata on Opensea.
*
* @notice This logic is NOT used internally by the Unlock Protocol and is made
* available only as a convenience helper.
*/
function owner() public view returns (address) {
return _convenienceOwner;
}
/** Setter for the `owner` convenience helper (see `owner()` docstring for more).
* @notice This logic is NOT used internally by the Unlock Protocol ans is made
* available only as a convenience helper.
* @param account address returned by the `owner()` helper
*/
function setOwner(address account) public {
_onlyLockManager();
if (account == address(0)) {
revert OWNER_CANT_BE_ADDRESS_ZERO();
}
address _previousOwner = _convenienceOwner;
_convenienceOwner = account;
emit OwnershipTransferred(_previousOwner, account);
}
function isOwner(
address account
) public view returns (bool) {
return _convenienceOwner == account;
}
uint256[1000] private __safe_upgrade_gap;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* The ability to disable locks has been removed on v10 to decrease contract code size.
* Disabling locks can be achieved by setting `setMaxNumberOfKeys` to `totalSupply`
* and expire all existing keys.
* @dev the variables are kept to prevent conflicts in storage layout during upgrades
*/
contract MixinDisable {
bool isAlive;
uint256[1000] private __safe_upgrade_gap;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./MixinKeys.sol";
import "./MixinLockCore.sol";
import "./MixinErrors.sol";
import "@openzeppelin/contracts-upgradeable/utils/introspection/ERC165StorageUpgradeable.sol";
/**
* @title Implements the ERC-721 Enumerable extension.
*/
contract MixinERC721Enumerable is
ERC165StorageUpgradeable,
MixinErrors,
MixinLockCore, // Implements totalSupply
MixinKeys
{
function _initializeMixinERC721Enumerable() internal {
/**
* register the supported interface to conform to ERC721Enumerable via ERC165
* 0x780e9d63 ===
* bytes4(keccak256('totalSupply()')) ^
* bytes4(keccak256('tokenOfOwnerByIndex(address,uint256)')) ^
* bytes4(keccak256('tokenByIndex(uint256)'))
*/
_registerInterface(0x780e9d63);
}
/// @notice Enumerate valid NFTs
/// @dev Throws if `_index` >= `totalSupply()`.
/// @param _index A counter less than `totalSupply()`
/// @return The token identifier for the `_index`th NFT,
/// (sort order not specified)
function tokenByIndex(
uint256 _index
) public view returns (uint256) {
if (_index >= _totalSupply) {
revert OUT_OF_RANGE();
}
return _index;
}
function supportsInterface(
bytes4 interfaceId
)
public
view
virtual
override(
AccessControlUpgradeable,
ERC165StorageUpgradeable
)
returns (bool)
{
return super.supportsInterface(interfaceId);
}
uint256[1000] private __safe_upgrade_gap;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @title List of all error messages
* (replace string errors message to save on contract size)
*/
contract MixinErrors {
// generic
error OUT_OF_RANGE();
error NULL_VALUE();
error INVALID_ADDRESS();
error INVALID_TOKEN();
error INVALID_LENGTH();
error UNAUTHORIZED();
// erc 721
error NON_COMPLIANT_ERC721_RECEIVER();
// roles
error ONLY_LOCK_MANAGER_OR_KEY_GRANTER();
error ONLY_KEY_MANAGER_OR_APPROVED();
error UNAUTHORIZED_KEY_MANAGER_UPDATE();
error ONLY_LOCK_MANAGER();
// single key status
error KEY_NOT_VALID();
error NO_SUCH_KEY();
// single key operations
error CANT_EXTEND_NON_EXPIRING_KEY();
error NOT_ENOUGH_TIME();
error NOT_ENOUGH_FUNDS();
// migration & data schema
error SCHEMA_VERSION_NOT_CORRECT();
error MIGRATION_REQUIRED();
// lock status/settings
error OWNER_CANT_BE_ADDRESS_ZERO();
error MAX_KEYS_REACHED();
error KEY_TRANSFERS_DISABLED();
error CANT_BE_SMALLER_THAN_SUPPLY();
// transfers and approvals
error TRANSFER_TO_SELF();
error CANNOT_APPROVE_SELF();
// keys management
error LOCK_SOLD_OUT();
// purchase
error INSUFFICIENT_ERC20_VALUE();
error INSUFFICIENT_VALUE();
// renewals
error NON_RENEWABLE_LOCK();
error LOCK_HAS_CHANGED();
error NOT_READY_FOR_RENEWAL();
// gas refund
error GAS_REFUND_FAILED();
// hooks
// NB: `hookIndex` designed the index of hook address in the params of `setEventHooks`
error INVALID_HOOK(uint8 hookIndex);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./MixinErrors.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol";
/**
* @title An implementation of the money related functions.
*/
contract MixinFunds is MixinErrors {
using AddressUpgradeable for address payable;
using SafeERC20Upgradeable for IERC20Upgradeable;
/**
* The token-type that this Lock is priced in. If 0, then use ETH, else this is
* a ERC20 token address.
*/
address public tokenAddress;
function _initializeMixinFunds(
address _tokenAddress
) internal {
_isValidToken(_tokenAddress);
tokenAddress = _tokenAddress;
}
function _isValidToken(
address _tokenAddress
) internal view {
if (
_tokenAddress != address(0) &&
IERC20Upgradeable(_tokenAddress).totalSupply() < 0
) {
revert INVALID_TOKEN();
}
}
/**
* Transfers funds from the contract to the account provided.
*
* Security: be wary of re-entrancy when calling this function.
*/
function _transfer(
address _tokenAddress,
address payable _to,
uint _amount
) internal {
if (_amount > 0) {
if (_tokenAddress == address(0)) {
// https://diligence.consensys.net/blog/2019/09/stop-using-soliditys-transfer-now/
_to.sendValue(_amount);
} else {
IERC20Upgradeable token = IERC20Upgradeable(
_tokenAddress
);
token.safeTransfer(_to, _amount);
}
}
}
uint256[1000] private __safe_upgrade_gap;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./MixinKeys.sol";
import "./MixinRoles.sol";
import "./MixinErrors.sol";
/**
* @title Mixin allowing the Lock owner to grant / gift keys to users.
* @author HardlyDifficult
* @dev `Mixins` are a design pattern seen in the 0x contracts. It simply
* separates logically groupings of code to ease readability.
*/
contract MixinGrantKeys is
MixinErrors,
MixinRoles,
MixinKeys
{
/**
* Allows the Lock owner to give a collection of users a key with no charge.
* Each key may be assigned a different expiration date.
*/
function grantKeys(
address[] calldata _recipients,
uint[] calldata _expirationTimestamps,
address[] calldata _keyManagers
) external returns (uint[] memory) {
_lockIsUpToDate();
if (
!hasRole(KEY_GRANTER_ROLE, msg.sender) &&
!isLockManager(msg.sender)
) {
revert ONLY_LOCK_MANAGER_OR_KEY_GRANTER();
}
uint[] memory tokenIds = new uint[](_recipients.length);
for (uint i = 0; i < _recipients.length; i++) {
// an event is triggered
tokenIds[i] = _createNewKey(
_recipients[i],
_keyManagers[i],
_expirationTimestamps[i]
);
if (address(onKeyGrantHook) != address(0)) {
onKeyGrantHook.onKeyGranted(
tokenIds[i],
msg.sender,
_recipients[i],
_keyManagers[i],
_expirationTimestamps[i]
);
}
}
return tokenIds;
}
/**
* Allows the Lock owner or key granter to extend an existing keys with no charge. This is the "renewal" equivalent of `grantKeys`.
* @param _tokenId The id of the token to extend
* @param _duration The duration in secondes to add ot the key
* @dev set `_duration` to 0 to use the default duration of the lock
*/
function grantKeyExtension(
uint _tokenId,
uint _duration
) external {
_lockIsUpToDate();
_isKey(_tokenId);
if (
!hasRole(KEY_GRANTER_ROLE, msg.sender) &&
!isLockManager(msg.sender)
) {
revert ONLY_LOCK_MANAGER_OR_KEY_GRANTER();
}
_extendKey(_tokenId, _duration);
}
uint256[1000] private __safe_upgrade_gap;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./MixinLockCore.sol";
import "./MixinErrors.sol";
import "../interfaces/IUnlock.sol";
/**
* @title Mixin for managing `Key` data, as well as the * Approval related functions needed to meet the ERC721
* standard.
* @dev `Mixins` are a design pattern seen in the 0x contracts. It simply
* separates logically groupings of code to ease readability.
*/
contract MixinKeys is MixinErrors, MixinLockCore {
// The struct for a key
struct Key {
uint tokenId;
uint expirationTimestamp;
}
// Emitted when the Lock owner expires a user's Key
event ExpireKey(uint indexed tokenId);
// Emitted when the expiration of a key is modified
event ExpirationChanged(
uint indexed tokenId,
uint newExpiration,
uint amount,
bool timeAdded
);
// fire when a key is extended
event KeyExtended(uint indexed tokenId, uint newTimestamp);
event KeyManagerChanged(uint indexed _tokenId, address indexed _newManager);
event KeysMigrated(uint updatedRecordsCount);
event LockConfig(
uint expirationDuration,
uint maxNumberOfKeys,
uint maxKeysPerAcccount
);
// Deprecated: don't use this anymore as we know enable multiple keys per owner.
mapping(address => Key) internal keyByOwner;
// Each tokenId can have at most exactly one owner at a time.
// Returns address(0) if the token does not exist
mapping(uint => address) internal _ownerOf;
// Keep track of the total number of unique owners for this lock (both expired and valid).
// This may be larger than totalSupply
uint public numberOfOwners;
// A given key has both an owner and a manager.
// If keyManager == address(0) then the key owner is also the manager
// Each key can have at most 1 keyManager.
mapping(uint => address) public keyManagerOf;
// Keeping track of approved transfers
// This is a mapping of addresses which have approved
// the transfer of a key to another address where their key can be transferred
// Note: the approver may actually NOT have a key... and there can only
// be a single approved address
mapping(uint => address) internal approved;
// Keeping track of approved operators for a given Key manager.
// This approves a given operator for all keys managed by the calling "keyManager"
// The caller may not currently be the keyManager for ANY keys.
// These approvals are never reset/revoked automatically, unlike "approved",
// which is reset on transfer.
mapping(address => mapping(address => bool))
internal managerToOperatorApproved;
// store all keys: tokenId => token
mapping(uint256 => Key) internal _keys;
// store ownership: owner => array of tokens owned by that owner
mapping(address => mapping(uint256 => uint256)) private _ownedKeyIds;
// store indexes: owner => list of tokenIds
mapping(uint256 => uint256) private _ownedKeysIndex;
// Mapping owner address to token count
mapping(address => uint256) private _balances;
/**
* Ensure that the caller is the keyManager of the key
* or that the caller has been approved
* for ownership of that key
* @dev This is a modifier
*/
function _onlyKeyManagerOrApproved(uint _tokenId) internal view {
address realKeyManager = keyManagerOf[_tokenId] == address(0)
? _ownerOf[_tokenId]
: keyManagerOf[_tokenId];
if (
!isLockManager(msg.sender) &&
!_isKeyManager(_tokenId, msg.sender) &&
approved[_tokenId] != msg.sender &&
!isApprovedForAll(realKeyManager, msg.sender)
) {
revert ONLY_KEY_MANAGER_OR_APPROVED();
}
}
/**
* Check if a key is expired or not
* @dev This is a modifier
*/
function _isValidKey(uint _tokenId) internal view {
if (!isValidKey(_tokenId)) {
revert KEY_NOT_VALID();
}
}
/**
* Check if a key actually exists
* @dev This is a modifier
*/
function _isKey(uint _tokenId) internal view {
if (_keys[_tokenId].tokenId == 0) {
revert NO_SUCH_KEY();
}
}
/**
* Deactivate an existing key
* @param _tokenId the id of token to burn
* @notice the key will be expired and ownership records will be destroyed
*/
function burn(uint _tokenId) public {
_isKey(_tokenId);
_onlyKeyManagerOrApproved(_tokenId);
emit Transfer(_ownerOf[_tokenId], address(0), _tokenId);
// expire key
_cancelKey(_tokenId);
// delete owner
_ownerOf[_tokenId] = address(0);
}
/**
* Migrate data from the previous single owner => key mapping to
* the new data structure w multiple tokens.
*/
function migrate(bytes calldata /*_calldata*/) public virtual {
// make sure we have correct data version before migrating
require(
((schemaVersion == publicLockVersion() - 1) || schemaVersion == 0),
"SCHEMA_VERSION_NOT_CORRECT"
);
// only for mainnet
if (block.chainid == 1) {
// Hardcoded address for the redeployed Unlock contract on mainnet
address newUnlockAddress = 0xe79B93f8E22676774F2A8dAd469175ebd00029FA;
// trigger migration from the new Unlock
IUnlock(newUnlockAddress).postLockUpgrade();
// update unlock ref in this lock
unlockProtocol = IUnlock(newUnlockAddress);
}
// update data version
schemaVersion = publicLockVersion();
}
/**
* Set the schema version to the latest
* @notice only lock manager call call this
*/
function updateSchemaVersion() public {
_onlyLockManager();
schemaVersion = publicLockVersion();
}
/**
* Returns the id of a key for a specific owner at a specific index
* @notice Enumerate keys assigned to an owner
* @dev Throws if `_index` >= `totalKeys(_keyOwner)` or if
* `_keyOwner` is the zero address, representing invalid keys.
* @param _keyOwner address of the owner
* @param _index position index in the array of all keys - less than `totalKeys(_keyOwner)`
* @return The token identifier for the `_index`th key assigned to `_keyOwner`,
* (sort order not specified)
* NB: name kept to be ERC721 compatible
*/
function tokenOfOwnerByIndex(
address _keyOwner,
uint256 _index
) public view returns (uint256) {
if (_index >= totalKeys(_keyOwner)) {
revert OUT_OF_RANGE();
}
return _ownedKeyIds[_keyOwner][_index];
}
/**
* Create a new key with a new tokenId and store it
*
*/
function _createNewKey(
address _recipient,
address _keyManager,
uint expirationTimestamp
) internal returns (uint tokenId) {
if (_recipient == address(0)) {
revert INVALID_ADDRESS();
}
// We increment the tokenId counter
_totalSupply++;
tokenId = _totalSupply;
// create the key
_keys[tokenId] = Key(tokenId, expirationTimestamp);
// increase total number of unique owners
if (totalKeys(_recipient) == 0) {
numberOfOwners++;
}
// store ownership
_createOwnershipRecord(tokenId, _recipient);
// set key manager
_setKeyManagerOf(tokenId, _keyManager);
// trigger event
emit Transfer(
address(0), // This is a creation.
_recipient,
tokenId
);
}
function _extendKey(
uint _tokenId,
uint _duration
) internal returns (uint newTimestamp) {
uint expirationTimestamp = _keys[_tokenId].expirationTimestamp;
// prevent extending a valid non-expiring key
if (expirationTimestamp == type(uint).max) {
revert CANT_EXTEND_NON_EXPIRING_KEY();
}
// if non-expiring but not valid then extend
uint duration = _duration == 0 ? expirationDuration : _duration;
if (duration == type(uint).max) {
newTimestamp = type(uint).max;
} else {
if (expirationTimestamp > block.timestamp) {
// extends a valid key
newTimestamp = expirationTimestamp + duration;
} else {
// renew an expired or cancelled key
newTimestamp = block.timestamp + duration;
}
}
_keys[_tokenId].expirationTimestamp = newTimestamp;
emit KeyExtended(_tokenId, newTimestamp);
// call the hook
if (address(onKeyExtendHook) != address(0)) {
onKeyExtendHook.onKeyExtend(
_tokenId,
msg.sender,
newTimestamp,
expirationTimestamp
);
}
}
/**
* Record ownership info and udpate balance for new owner
* @param _tokenId the id of the token to cancel
* @param _recipient the address of the new owner
*/
function _createOwnershipRecord(uint _tokenId, address _recipient) internal {
uint length = totalKeys(_recipient);
// make sure address does not have more keys than allowed
if (length >= _maxKeysPerAddress) {
revert MAX_KEYS_REACHED();
}
// record new owner
_ownedKeysIndex[_tokenId] = length;
_ownedKeyIds[_recipient][length] = _tokenId;
// update ownership mapping
_ownerOf[_tokenId] = _recipient;
_balances[_recipient] += 1;
}
/**
* Merge existing keys
* @param _tokenIdFrom the id of the token to substract time from
* @param _tokenIdTo the id of the destination token to add time
* @param _amount the amount of time to transfer (in seconds)
*/
function mergeKeys(uint _tokenIdFrom, uint _tokenIdTo, uint _amount) public {
// checks
_isKey(_tokenIdFrom);
_isValidKey(_tokenIdFrom);
_onlyKeyManagerOrApproved(_tokenIdFrom);
_isKey(_tokenIdTo);
// make sure there is enough time remaining
if (_amount > keyExpirationTimestampFor(_tokenIdFrom) - block.timestamp) {
revert NOT_ENOUGH_TIME();
}
// deduct time from parent key
_timeMachine(_tokenIdFrom, _amount, false);
// add time to destination key
_timeMachine(_tokenIdTo, _amount, true);
}
/**
* Delete ownership info and udpate balance for previous owner
* @param _tokenId the id of the token to cancel
*/
function _deleteOwnershipRecord(uint _tokenId) internal {
// get owner
address previousOwner = _ownerOf[_tokenId];
// delete previous ownership
uint lastTokenIndex = totalKeys(previousOwner) - 1;
uint index = _ownedKeysIndex[_tokenId];
// When the token to delete is the last token, the swap operation is unnecessary
if (index != lastTokenIndex) {
uint256 lastTokenId = _ownedKeyIds[previousOwner][lastTokenIndex];
_ownedKeyIds[previousOwner][index] = lastTokenId; // Move the last token to the slot of the to-delete token
_ownedKeysIndex[lastTokenId] = index; // Update the moved token's index
}
// Deletes the contents at the last position of the array
delete _ownedKeyIds[previousOwner][lastTokenIndex];
// remove from owner count if thats the only key
if (totalKeys(previousOwner) == 1) {
numberOfOwners--;
}
// update balance
_balances[previousOwner] -= 1;
}
/**
* Internal logic to expire the key
* @param _tokenId the id of the token to cancel
* @notice this won't 'burn' the token, as it would still exist in the record
*/
function _cancelKey(uint _tokenId) internal {
// expire the key
_keys[_tokenId].expirationTimestamp = block.timestamp;
}
/**
* @return The number of keys owned by `_keyOwner` (expired or not)
*/
function totalKeys(address _keyOwner) public view returns (uint) {
if (_keyOwner == address(0)) {
revert INVALID_ADDRESS();
}
return _balances[_keyOwner];
}
/**
* In the specific case of a Lock, `balanceOf` returns only the tokens with a valid expiration timerange
* @return balance The number of valid keys owned by `_keyOwner`
*/
function balanceOf(address _keyOwner) public view returns (uint balance) {
uint length = totalKeys(_keyOwner);
for (uint i = 0; i < length; i++) {
if (isValidKey(tokenOfOwnerByIndex(_keyOwner, i))) {
balance++;
}
}
}
/**
* Check if a certain key is valid
* @param _tokenId the id of the key to check validity
* @notice this makes use of the onValidKeyHook if it is set
*/
function isValidKey(uint _tokenId) public view returns (bool) {
bool isValid = _keys[_tokenId].expirationTimestamp > block.timestamp;
// use hook if it exists
if (address(onValidKeyHook) != address(0)) {
isValid = onValidKeyHook.isValidKey(
address(this),
msg.sender,
_tokenId,
_keys[_tokenId].expirationTimestamp,
_ownerOf[_tokenId],
isValid
);
}
return isValid;
}
/**
* Checks if the user has at least one non-expired key.
* @param _keyOwner the
*/
function getHasValidKey(
address _keyOwner
) public view returns (bool isValid) {
// check hook directly with address if user has no valid keys
if (balanceOf(_keyOwner) == 0) {
if (address(onValidKeyHook) != address(0)) {
return
onValidKeyHook.isValidKey(
address(this),
msg.sender,
0, // no token specified
0, // no token specified
_keyOwner,
false
);
}
}
// `balanceOf` returns only valid keys
return balanceOf(_keyOwner) >= 1;
}
/**
* Returns the key's ExpirationTimestamp field for a given token.
* @param _tokenId the tokenId of the key
* @dev Returns 0 if the owner has never owned a key for this lock
*/
function keyExpirationTimestampFor(uint _tokenId) public view returns (uint) {
return _keys[_tokenId].expirationTimestamp;
}
/**
* Returns the owner of a given tokenId
* @param _tokenId the id of the token
* @return the address of the owner
*/
function ownerOf(uint _tokenId) public view returns (address) {
return _ownerOf[_tokenId];
}
/**
* @notice Public function for setting the manager for a given key
* @param _tokenId The id of the key to assign rights for
* @param _keyManager the address with the manager's rights for the given key.
* Setting _keyManager to address(0) means the keyOwner is also the keyManager
*/
function setKeyManagerOf(uint _tokenId, address _keyManager) public {
_isKey(_tokenId);
if (
// is already key manager
!_isKeyManager(_tokenId, msg.sender) &&
// is lock manager
!isLockManager(msg.sender)
) {
revert UNAUTHORIZED_KEY_MANAGER_UPDATE();
}
_setKeyManagerOf(_tokenId, _keyManager);
}
function _setKeyManagerOf(uint _tokenId, address _keyManager) internal {
if (keyManagerOf[_tokenId] != _keyManager) {
keyManagerOf[_tokenId] = _keyManager;
_clearApproval(_tokenId);
emit KeyManagerChanged(_tokenId, _keyManager);
}
}
/**
* This approves _approved to get ownership of _tokenId.
* Note: that since this is used for both purchase and transfer approvals
* the approved token may not exist.
*/
function approve(address _approved, uint _tokenId) public {
_onlyKeyManagerOrApproved(_tokenId);
if (msg.sender == _approved) {
revert CANNOT_APPROVE_SELF();
}
approved[_tokenId] = _approved;
emit Approval(_ownerOf[_tokenId], _approved, _tokenId);
}
/**
* @notice Get the approved address for a single NFT
* @dev Throws if `_tokenId` is not a valid NFT.
* @param _tokenId The NFT to find the approved address for
* @return The approved address for this NFT, or the zero address if there is none
*/
function getApproved(uint _tokenId) public view returns (address) {
_isKey(_tokenId);
address approvedRecipient = approved[_tokenId];
return approvedRecipient;
}
/**
* @dev Tells whether an operator is approved by a given keyManager
* @param _owner owner address which you want to query the approval of
* @param _operator operator address which you want to query the approval of
* @return bool whether the given operator is approved by the given owner
*/
function isApprovedForAll(
address _owner,
address _operator
) public view returns (bool) {
return managerToOperatorApproved[_owner][_operator];
}
/**
* Returns true if _keyManager is explicitly set as key manager, or if the
* address is the owner but no km is set.
* identified by _tokenId
*/
function _isKeyManager(
uint _tokenId,
address _keyManager
) internal view returns (bool) {
if (
// is explicitely a key manager
keyManagerOf[_tokenId] == _keyManager ||
// is owner and no key manager is set
((ownerOf(_tokenId) == _keyManager) &&
keyManagerOf[_tokenId] == address(0))
) {
return true;
} else {
return false;
}
}
/**
* @notice Modify the expirationTimestamp of a key
* by a given amount.
* @param _tokenId The ID of the key to modify.
* @param _deltaT The amount of time in seconds by which
* to modify the keys expirationTimestamp
* @param _addTime Choose whether to increase or decrease
* expirationTimestamp (false == decrease, true == increase)
* @dev Throws if owner does not have a valid key.
*/
function _timeMachine(
uint _tokenId,
uint256 _deltaT,
bool _addTime
) internal {
_isKey(_tokenId);
uint formerTimestamp = _keys[_tokenId].expirationTimestamp;
if (_addTime) {
if (formerTimestamp > block.timestamp) {
// append to valid key
_keys[_tokenId].expirationTimestamp = formerTimestamp + _deltaT;
} else {
// add from now if key is expired
_keys[_tokenId].expirationTimestamp = block.timestamp + _deltaT;
}
} else {
_keys[_tokenId].expirationTimestamp = formerTimestamp - _deltaT;
}
emit ExpirationChanged(
_tokenId,
_keys[_tokenId].expirationTimestamp,
_deltaT,
_addTime
);
}
/**
* @dev Function to clear current approval of a given token ID
* @param _tokenId uint256 ID of the token to be transferred
*/
function _clearApproval(uint256 _tokenId) internal {
if (approved[_tokenId] != address(0)) {
approved[_tokenId] = address(0);
}
}
/**
* Update the main key properties for the entire lock:
* - default duration of each key
* - the maximum number of keys the lock can edit
* - the maximum number of keys a single address can hold
* @notice keys previously bought are unaffected by this changes in expiration duration (i.e.
* existing keys timestamps are not recalculated/updated)
* @param _newExpirationDuration the new amount of time for each key purchased or type(uint).max for a non-expiring key
* @param _maxKeysPerAcccount the maximum amount of key a single user can own
* @param _maxNumberOfKeys uint the maximum number of keys
* @dev _maxNumberOfKeys Can't be smaller than the existing supply
*/
function updateLockConfig(
uint _newExpirationDuration,
uint _maxNumberOfKeys,
uint _maxKeysPerAcccount
) external {
_onlyLockManager();
if (_maxKeysPerAcccount == 0) {
revert NULL_VALUE();
}
if (_maxNumberOfKeys < _totalSupply) {
revert CANT_BE_SMALLER_THAN_SUPPLY();
}
_maxKeysPerAddress = _maxKeysPerAcccount;
expirationDuration = _newExpirationDuration;
maxNumberOfKeys = _maxNumberOfKeys;
emit LockConfig(
_newExpirationDuration,
_maxNumberOfKeys,
_maxKeysPerAddress
);
}
/**
* @return the maximum number of key allowed for a single address
*/
function maxKeysPerAddress() external view returns (uint) {
return _maxKeysPerAddress;
}
// decrease 1000 to 996 when adding new tokens/owners mappings in v10
uint256[996] private __safe_upgrade_gap;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol";
import "./MixinDisable.sol";
import "./MixinRoles.sol";
import "./MixinErrors.sol";
import "../interfaces/IUnlock.sol";
import "./MixinFunds.sol";
import "../interfaces/hooks/ILockKeyCancelHook.sol";
import "../interfaces/hooks/ILockKeyPurchaseHook.sol";
import "../interfaces/hooks/ILockValidKeyHook.sol";
import "../interfaces/hooks/ILockKeyGrantHook.sol";
import "../interfaces/hooks/ILockTokenURIHook.sol";
import "../interfaces/hooks/ILockKeyTransferHook.sol";
import "../interfaces/hooks/ILockKeyExtendHook.sol";
/**
* @title Mixin for core lock data and functions.
* @dev `Mixins` are a design pattern seen in the 0x contracts. It simply
* separates logically groupings of code to ease readability.
*/
contract MixinLockCore is
MixinRoles,
MixinFunds,
MixinDisable
{
using AddressUpgradeable for address;
event Withdrawal(
address indexed sender,
address indexed tokenAddress,
address indexed recipient,
uint amount
);
event PricingChanged(
uint oldKeyPrice,
uint keyPrice,
address oldTokenAddress,
address tokenAddress
);
/**
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
*/
event Transfer(
address indexed from,
address indexed to,
uint256 indexed tokenId
);
/**
* @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
*/
event Approval(
address indexed owner,
address indexed approved,
uint256 indexed tokenId
);
event EventHooksUpdated(
address onKeyPurchaseHook,
address onKeyCancelHook,
address onValidKeyHook,
address onTokenURIHook,
address onKeyTransferHook,
address onKeyExtendHook,
address onKeyGrantHook
);
/**
* @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
*/
event ApprovalForAll(
address indexed owner,
address indexed operator,
bool approved
);
// Unlock Protocol address
IUnlock public unlockProtocol;
// Duration in seconds for which the keys are valid, after creation
// should we take a smaller type use less gas?
uint public expirationDuration;
// price in wei of the next key
uint public keyPrice;
// Max number of keys sold if the keyReleaseMechanism is public
uint public maxNumberOfKeys;
// A count of how many new key purchases there have been
uint internal _totalSupply;
// DEPREC: this is not used anymore (kept as private var for storage layout compat)
address payable private beneficiary;
// The denominator component for values specified in basis points.
uint internal constant BASIS_POINTS_DEN = 10000;
// lock hooks
ILockKeyPurchaseHook public onKeyPurchaseHook;
ILockKeyCancelHook public onKeyCancelHook;
ILockValidKeyHook public onValidKeyHook;
ILockTokenURIHook public onTokenURIHook;
// use to check data version (added to v10)
uint public schemaVersion;
// keep track of how many key a single address can use (added to v10)
uint internal _maxKeysPerAddress;
// one more hook (added to v11)
ILockKeyTransferHook public onKeyTransferHook;
// two more hooks (added to v12)
ILockKeyExtendHook public onKeyExtendHook;
ILockKeyGrantHook public onKeyGrantHook;
// modifier to check if data has been upgraded
function _lockIsUpToDate() internal view {
if (schemaVersion != publicLockVersion()) {
revert MIGRATION_REQUIRED();
}
}
function _initializeMixinLockCore(
address payable,
uint _expirationDuration,
uint _keyPrice,
uint _maxNumberOfKeys
) internal {
unlockProtocol = IUnlock(msg.sender); // Make sure we link back to Unlock's smart contract.
expirationDuration = _expirationDuration;
keyPrice = _keyPrice;
maxNumberOfKeys = _maxNumberOfKeys;
// update only when initialized
schemaVersion = publicLockVersion();
// only a single key per address is allowed by default
_maxKeysPerAddress = 1;
}
// The version number of the current implementation on this network
function publicLockVersion()
public
pure
returns (uint16)
{
return 13;
}
/**
* @dev Called by owner to withdraw all ETH funds from the lock
* @param _recipient specifies the address to send ETH to.
* @param _amount specifies the max amount to withdraw, which may be reduced when
* considering the available balance. Set to 0 or MAX_UINT to withdraw everything.
*/
function withdraw(
address _tokenAddress,
address payable _recipient,
uint _amount
) external {
_onlyLockManager();
// get balance
uint balance;
if (_tokenAddress == address(0)) {
balance = address(this).balance;
} else {
balance = IERC20Upgradeable(_tokenAddress).balanceOf(
address(this)
);
}
uint amount;
if (_amount == 0 || _amount > balance) {
if (balance <= 0) {
revert NOT_ENOUGH_FUNDS();
}
amount = balance;
} else {
amount = _amount;
}
emit Withdrawal(
msg.sender,
_tokenAddress,
_recipient,
amount
);
// Security: re-entrancy not a risk as this is the last line of an external function
_transfer(_tokenAddress, _recipient, amount);
}
/**
* A function which lets the owner of the lock change the pricing for future purchases.
* This consists of 2 parts: The token address and the price in the given token.
* In order to set the token to ETH, use 0 for the token Address.
*/
function updateKeyPricing(
uint _keyPrice,
address _tokenAddress
) external {
_onlyLockManager();
_isValidToken(_tokenAddress);
uint oldKeyPrice = keyPrice;
address oldTokenAddress = tokenAddress;
keyPrice = _keyPrice;
tokenAddress = _tokenAddress;
emit PricingChanged(
oldKeyPrice,
keyPrice,
oldTokenAddress,
tokenAddress
);
}
/**
* @notice Allows a lock manager to add or remove an event hook
*/
function setEventHooks(
address _onKeyPurchaseHook,
address _onKeyCancelHook,
address _onValidKeyHook,
address _onTokenURIHook,
address _onKeyTransferHook,
address _onKeyExtendHook,
address _onKeyGrantHook
) external {
_onlyLockManager();
if (
_onKeyPurchaseHook != address(0) &&
!_onKeyPurchaseHook.isContract()
) {
revert INVALID_HOOK(0);
}
if (
_onKeyCancelHook != address(0) &&
!_onKeyCancelHook.isContract()
) {
revert INVALID_HOOK(1);
}
if (
_onValidKeyHook != address(0) &&
!_onValidKeyHook.isContract()
) {
revert INVALID_HOOK(2);
}
if (
_onTokenURIHook != address(0) &&
!_onTokenURIHook.isContract()
) {
revert INVALID_HOOK(3);
}
if (
_onKeyTransferHook != address(0) &&
!_onKeyTransferHook.isContract()
) {
revert INVALID_HOOK(4);
}
if (
_onKeyExtendHook != address(0) &&
!_onKeyExtendHook.isContract()
) {
revert INVALID_HOOK(5);
}
if (
_onKeyGrantHook != address(0) &&
!_onKeyGrantHook.isContract()
) {
revert INVALID_HOOK(6);
}
onKeyPurchaseHook = ILockKeyPurchaseHook(
_onKeyPurchaseHook
);
onKeyCancelHook = ILockKeyCancelHook(_onKeyCancelHook);
onTokenURIHook = ILockTokenURIHook(_onTokenURIHook);
onValidKeyHook = ILockValidKeyHook(_onValidKeyHook);
onKeyTransferHook = ILockKeyTransferHook(
_onKeyTransferHook
);
onKeyExtendHook = ILockKeyExtendHook(_onKeyExtendHook);
onKeyGrantHook = ILockKeyGrantHook(_onKeyGrantHook);
emit EventHooksUpdated(
_onKeyPurchaseHook,
_onKeyCancelHook,
_onValidKeyHook,
_onTokenURIHook,
_onKeyTransferHook,
_onKeyExtendHook,
_onKeyGrantHook
);
}
/**
* Returns the total number of keys, including non-valid ones
* @return _totalKeysCreated the total number of keys, valid or not
*/
function totalSupply() public view returns (uint256 _totalKeysCreated) {
return _totalSupply;
}
// decreased from 1000 to 998 when adding `schemaVersion` and `maxKeysPerAddress` in v10
// decreased from 998 to 997 when adding `onKeyTransferHook` in v11
// decreased from 997 to 996 when adding `onKeyExtendHook` in v12
// decreased from 996 to 995 when adding `onKeyGrantHook` in v12
uint256[995] private __safe_upgrade_gap;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts-upgradeable/utils/introspection/ERC165StorageUpgradeable.sol";
// import '@openzeppelin/contracts-upgradeable/token/ERC721/extensions/IERC721EnumerableUpgradeable.sol';
import "../UnlockUtils.sol";
import "./MixinKeys.sol";
import "./MixinLockCore.sol";
import "./MixinRoles.sol";
/**
* @title Mixin for metadata about the Lock.
* @dev `Mixins` are a design pattern seen in the 0x contracts. It simply
* separates logically groupings of code to ease readability.
*/
contract MixinLockMetadata is
ERC165StorageUpgradeable,
MixinRoles,
MixinLockCore,
MixinKeys
{
using UnlockUtils for uint;
using UnlockUtils for address;
using UnlockUtils for string;
/// A descriptive name for a collection of NFTs in this contract.Defaults to "Unlock-Protocol" but is settable by lock owner
string public name;
/// An abbreviated name for NFTs in this contract. Defaults to "KEY" but is settable by lock owner
string private lockSymbol;
// the base Token URI for this Lock. If not set by lock owner, the global URI stored in Unlock is used.
string private baseTokenURI;
event LockMetadata(
string name,
string symbol,
string baseTokenURI
);
function _initializeMixinLockMetadata(
string calldata _lockName
) internal {
ERC165StorageUpgradeable.__ERC165Storage_init();
name = _lockName;
// registering the optional erc721 metadata interface with ERC165.sol using
// the ID specified in the standard: https://eips.ethereum.org/EIPS/eip-721
_registerInterface(0x5b5e139f);
}
/**
* Allows the Lock owner to assign
* @param _lockName a descriptive name for this Lock.
* @param _lockSymbol a Symbol for this Lock (default to KEY).
* @param _baseTokenURI the baseTokenURI for this Lock
*/
function setLockMetadata(
string calldata _lockName,
string calldata _lockSymbol,
string calldata _baseTokenURI
) public {
_onlyLockManager();
name = _lockName;
lockSymbol = _lockSymbol;
baseTokenURI = _baseTokenURI;
emit LockMetadata(name, lockSymbol, baseTokenURI);
}
/**
* @dev Gets the token symbol
* @return string representing the token name
*/
function symbol() external view returns (string memory) {
if (bytes(lockSymbol).length == 0) {
return unlockProtocol.globalTokenSymbol();
} else {
return lockSymbol;
}
}
/** @notice A distinct Uniform Resource Identifier (URI) for a given asset.
* @param _tokenId The iD of the token for which we want to retrieve the URI.
* If 0 is passed here, we just return the appropriate baseTokenURI.
* If a custom URI has been set we don't return the lock address.
* It may be included in the custom baseTokenURI if needed.
* @dev URIs are defined in RFC 3986. The URI may point to a JSON file
* that conforms to the "ERC721 Metadata JSON Schema".
* https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md
*/
function tokenURI(
uint256 _tokenId
) external view returns (string memory) {
string memory URI;
string memory tokenId;
string memory lockAddress = address(this).address2Str();
string memory seperator;
if (_tokenId != 0) {
tokenId = _tokenId.uint2Str();
} else {
tokenId = "";
}
if (address(onTokenURIHook) != address(0)) {
uint expirationTimestamp = keyExpirationTimestampFor(
_tokenId
);
return
onTokenURIHook.tokenURI(
address(this),
msg.sender,
ownerOf(_tokenId),
_tokenId,
expirationTimestamp
);
}
if (bytes(baseTokenURI).length == 0) {
URI = unlockProtocol.globalBaseTokenURI();
seperator = "/";
} else {
URI = baseTokenURI;
seperator = "";
lockAddress = "";
}
return URI.strConcat(lockAddress, seperator, tokenId);
}
function supportsInterface(
bytes4 interfaceId
)
public
view
virtual
override(
AccessControlUpgradeable,
ERC165StorageUpgradeable
)
returns (bool)
{
return super.supportsInterface(interfaceId);
}
uint256[1000] private __safe_upgrade_gap;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./MixinDisable.sol";
import "./MixinKeys.sol";
import "./MixinLockCore.sol";
import "./MixinFunds.sol";
import "./MixinErrors.sol";
/**
* @title Mixin for the purchase-related functions.
* @dev `Mixins` are a design pattern seen in the 0x contracts. It simply
* separates logically groupings of code to ease readability.
*/
contract MixinPurchase is
MixinErrors,
MixinFunds,
MixinDisable,
MixinLockCore,
MixinKeys
{
event GasRefunded(
address indexed receiver,
uint refundedAmount,
address tokenAddress
);
event UnlockCallFailed(
address indexed lockAddress,
address unlockAddress
);
event ReferrerFee(
address indexed referrer,
uint fee
);
event GasRefundValueChanged(
uint refundValue
);
// default to 0
uint256 internal _gasRefundValue;
// Keep track of ERC20 price when purchased
mapping(uint256 => uint256) internal _originalPrices;
// Keep track of duration when purchased
mapping(uint256 => uint256) internal _originalDurations;
// keep track of token pricing when purchased
mapping(uint256 => address) internal _originalTokens;
mapping(address => uint) public referrerFees;
error TransferFailed();
/**
* @dev Set the value/price to be refunded to the sender on purchase
*/
function setGasRefundValue(
uint256 _refundValue
) external {
_onlyLockManager();
_gasRefundValue = _refundValue;
emit GasRefundValueChanged(_refundValue);
}
/**
* @dev Returns value/price to be refunded to the sender on purchase
*/
function gasRefundValue()
external
view
returns (uint256 _refundValue)
{
return _gasRefundValue;
}
/**
* Set a specific percentage of the keyPrice to be sent to the referrer while purchasing,
* extending or renewing a key.
* @param _referrer the address of the referrer. If set to the 0x address, any referrer will receive the fee.
* @param _feeBasisPoint the percentage of the price to be used for this
* specific referrer (in basis points)
* @dev To send a fixed percentage of the key price to all referrers, set a percentage to `address(0)`
*/
function setReferrerFee(
address _referrer,
uint _feeBasisPoint
) public {
_onlyLockManager();
referrerFees[_referrer] = _feeBasisPoint;
emit ReferrerFee(_referrer, _feeBasisPoint);
}
/**
@dev internal function to execute the payments to referrers if any is set
*/
function _payReferrer(address _referrer) internal {
if(_referrer != address(0)) {
// get default value
uint basisPointsToPay = referrerFees[address(0)];
// get value for the referrer
if (referrerFees[_referrer] != 0) {
basisPointsToPay = referrerFees[_referrer];
}
// pay the referrer if necessary
if (basisPointsToPay != 0) {
_transfer(
tokenAddress,
payable(_referrer),
(keyPrice * basisPointsToPay) / BASIS_POINTS_DEN
);
}
}
}
/**
* @param _baseAmount the total amount to calculate the fee
* @dev internal function to execute the payments to referrers if any is set
*/
function _payProtocol(uint _baseAmount) internal {
// get fee from Unlock
uint protocolFee;
// make sure unlock is a contract, and we catch possible reverts
if (address(unlockProtocol).code.length > 0) {
try unlockProtocol.protocolFee() returns (uint _fee){
// calculate fee to be paid
protocolFee = (_baseAmount * _fee) / BASIS_POINTS_DEN;
// pay fee to Unlock
if (protocolFee != 0) {
_transfer(tokenAddress, payable(address(unlockProtocol)), protocolFee);
}
} catch {
// emit missing unlock
emit UnlockCallFailed(
address(this),
address(unlockProtocol)
);
}
}
}
/**
* @dev Helper to communicate with Unlock (record GNP and mint UDT tokens)
*/
function _recordKeyPurchase(
uint _keyPrice,
address _referrer
) internal {
// make sure unlock is a contract, and we catch possible reverts
if (address(unlockProtocol).code.length > 0) {
// call Unlock contract to record GNP
// the function is capped by gas to prevent running out of gas
try
unlockProtocol.recordKeyPurchase{ gas: 300000 }(
_keyPrice,
_referrer
)
{} catch {
// emit missing unlock
emit UnlockCallFailed(
address(this),
address(unlockProtocol)
);
}
} else {
// emit missing unlock
emit UnlockCallFailed(
address(this),
address(unlockProtocol)
);
}
}
/**
* @dev helper to keep track of price and duration settings of a key
* at purchase / extend time
* @notice stores values are used to prevent renewal if a key has settings
* has changed
*/
function _recordTokenTerms(
uint _tokenId,
uint _keyPrice
) internal {
if (_originalPrices[_tokenId] != _keyPrice) {
_originalPrices[_tokenId] = _keyPrice;
}
if (
_originalDurations[_tokenId] != expirationDuration
) {
_originalDurations[_tokenId] = expirationDuration;
}
if (_originalTokens[_tokenId] != tokenAddress) {
_originalTokens[_tokenId] = tokenAddress;
}
}
/**
* @dev helper to check if the pricing or duration of the lock have been modified
* since the key was bought
*/
function isRenewable(uint _tokenId, address _referrer) public view returns (bool) {
// check the lock
if (
_originalDurations[_tokenId] == type(uint).max ||
tokenAddress == address(0)
) {
revert NON_RENEWABLE_LOCK();
}
// make sure key duration haven't decreased or price hasn't increase
if (
_originalPrices[_tokenId] < purchasePriceFor(ownerOf(_tokenId), _referrer, "") ||
_originalDurations[_tokenId] > expirationDuration ||
_originalTokens[_tokenId] != tokenAddress
) {
revert LOCK_HAS_CHANGED();
}
// make sure key is ready for renewal (at least 90% expired)
// check if key is 90% expired
uint deadline =
(_keys[_tokenId].expirationTimestamp - expirationDuration) // origin
+
(expirationDuration * 9000 / BASIS_POINTS_DEN); // 90% of duration
if (block.timestamp < deadline) {
revert NOT_READY_FOR_RENEWAL();
}
return true;
}
/**
* @dev simple helper to check the amount of ERC20 tokens declared
* by user is enough to cover the actual price
*/
function _checkValue(uint _declared, uint _actual) private pure {
if (_declared < _actual) {
revert INSUFFICIENT_ERC20_VALUE();
}
}
/**
* @dev helper to pay ERC20 tokens
*/
function _transferValue(address _payer, uint _priceToPay) private {
if (tokenAddress != address(0)) {
IERC20Upgradeable(tokenAddress).transferFrom(
_payer,
address(this),
_priceToPay
);
} else if (msg.value < _priceToPay) {
// We explicitly allow for greater amounts of ETH or tokens to allow 'donations'
revert INSUFFICIENT_VALUE();
}
}
/**
* @dev Purchase function
* @param _values array of tokens amount to pay for this purchase >= the current keyPrice - any applicable discount
* (_values is ignored when using ETH)
* @param _recipients array of addresses of the recipients of the purchased key
* @param _referrers array of addresses of the users making the referral
* @param _keyManagers optional array of addresses to grant managing rights to a specific address on creation
* @param _data arbitrary data populated by the front-end which initiated the sale
* @notice when called for an existing and non-expired key, the `_keyManager` param will be ignored
* @dev Setting _value to keyPrice exactly doubles as a security feature. That way if the lock owner increases the
* price while my transaction is pending I can't be charged more than I expected (only applicable to ERC-20 when more
* than keyPrice is approved for spending).
*/
function purchase(
uint256[] memory _values,
address[] memory _recipients,
address[] memory _referrers,
address[] memory _keyManagers,
bytes[] calldata _data
) external payable returns (uint[] memory) {
_lockIsUpToDate();
if (
_totalSupply + _recipients.length > maxNumberOfKeys
) {
revert LOCK_SOLD_OUT();
}
if (
(_recipients.length != _referrers.length) ||
(_recipients.length != _keyManagers.length)
) {
revert INVALID_LENGTH();
}
uint totalPriceToPay;
uint[] memory tokenIds = new uint[](_recipients.length);
for (uint256 i = 0; i < _recipients.length; i++) {
// check recipient address
address _recipient = _recipients[i];
// create a new key, check for a non-expiring key
tokenIds[i] = _createNewKey(
_recipient,
_keyManagers[i],
expirationDuration == type(uint).max
? type(uint).max
: block.timestamp + expirationDuration
);
// price
uint inMemoryKeyPrice = purchasePriceFor(
_recipient,
_referrers[i],
_data[i]
);
totalPriceToPay = totalPriceToPay + inMemoryKeyPrice;
// store values at purchase time
_recordTokenTerms(tokenIds[i], inMemoryKeyPrice);
// make sure erc20 price is correct
if(tokenAddress != address(0)) {
_checkValue(_values[i], inMemoryKeyPrice);
}
// store in unlock
_recordKeyPurchase(inMemoryKeyPrice, _referrers[i]);
// fire hook
uint pricePaid = tokenAddress == address(0)
? msg.value
: _values[i];
if (address(onKeyPurchaseHook) != address(0)) {
onKeyPurchaseHook.onKeyPurchase(
tokenIds[i],
msg.sender,
_recipient,
_referrers[i],
_data[i],
inMemoryKeyPrice,
pricePaid
);
}
}
// transfer the ERC20 tokens
_transferValue(msg.sender, totalPriceToPay);
// pay protocol
_payProtocol(totalPriceToPay);
// refund gas
_refundGas();
// send what is due to referrers
for (uint256 i = 0; i < _referrers.length; i++) {
_payReferrer(_referrers[i]);
}
return tokenIds;
}
/**
* @dev Extend function
* @param _value the number of tokens to pay for this purchase >= the current keyPrice - any applicable discount
* (_value is ignored when using ETH)
* @param _tokenId id of the key to extend
* @param _referrer address of the user making the referral
* @param _data arbitrary data populated by the front-end which initiated the sale
* @dev Throws if lock is disabled or key does not exist for _recipient. Throws if _recipient == address(0).
*/
function extend(
uint _value,
uint _tokenId,
address _referrer,
bytes calldata _data
) public payable {
_lockIsUpToDate();
_isKey(_tokenId);
// extend key duration
_extendKey(_tokenId, 0);
// transfer the tokens
uint inMemoryKeyPrice = purchasePriceFor(
ownerOf(_tokenId),
_referrer,
_data
);
// make sure erc20 price is correct
if(tokenAddress != address(0)) {
_checkValue(_value, inMemoryKeyPrice);
}
// process in unlock
_recordKeyPurchase(inMemoryKeyPrice, _referrer);
// pay value in ERC20
_transferValue(msg.sender, inMemoryKeyPrice);
// if key params have changed, then update them
_recordTokenTerms(_tokenId, inMemoryKeyPrice);
// refund gas (if applicable)
_refundGas();
// send what is due to referrer
_payReferrer(_referrer);
// pay protocol
_payProtocol(inMemoryKeyPrice);
}
/**
* Renew a given token
* @notice only works for non-free, expiring, ERC20 locks
* @param _tokenId the ID fo the token to renew
* @param _referrer the address of the person to be granted UDT
*/
function renewMembershipFor(
uint _tokenId,
address _referrer
) public {
_lockIsUpToDate();
_isKey(_tokenId);
// check if key is ripe for renewal
isRenewable(_tokenId, _referrer);
// extend key duration
_extendKey(_tokenId, 0);
// store in unlock
_recordKeyPurchase(keyPrice, _referrer);
// transfer the tokens
_transferValue(ownerOf(_tokenId), keyPrice);
// refund gas if applicable
_refundGas();
// send what is due to referrer
_payReferrer(_referrer);
// pay protocol
_payProtocol(keyPrice);
}
/**
* @notice returns the minimum price paid for a purchase with these params.
* @dev minKeyPrice considers any discount from Unlock or the OnKeyPurchase hook
*/
function purchasePriceFor(
address _recipient,
address _referrer,
bytes memory _data
) public view returns (uint minKeyPrice) {
if (address(onKeyPurchaseHook) != address(0)) {
minKeyPrice = onKeyPurchaseHook.keyPurchasePrice(
msg.sender,
_recipient,
_referrer,
_data
);
} else {
minKeyPrice = keyPrice;
}
}
/**
* Refund the specified gas amount and emit an event
* @notice this does sth only if `_gasRefundValue` is non-null
*/
function _refundGas() internal {
if (_gasRefundValue != 0) {
_transfer(tokenAddress, payable(msg.sender), _gasRefundValue);
emit GasRefunded(
msg.sender,
_gasRefundValue,
tokenAddress
);
}
}
// decreased from 1000 to 997 when added mappings for initial purchases pricing and duration on v10
// decreased from 997 to 996 when added the `referrerFees` mapping on v11
uint256[996] private __safe_upgrade_gap;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./MixinKeys.sol";
import "./MixinLockCore.sol";
import "./MixinRoles.sol";
import "./MixinFunds.sol";
import "./MixinPurchase.sol";
contract MixinRefunds is
MixinRoles,
MixinFunds,
MixinLockCore,
MixinKeys,
MixinPurchase
{
// CancelAndRefund will return funds based on time remaining minus this penalty.
// This is calculated as `proRatedRefund * refundPenaltyBasisPoints / BASIS_POINTS_DEN`.
uint public refundPenaltyBasisPoints;
uint public freeTrialLength;
event CancelKey(
uint indexed tokenId,
address indexed owner,
address indexed sendTo,
uint refund
);
event RefundPenaltyChanged(
uint freeTrialLength,
uint refundPenaltyBasisPoints
);
function _initializeMixinRefunds() internal {
// default to 10%
refundPenaltyBasisPoints = 1000;
}
/**
* @dev Invoked by the lock owner to destroy the user's key and perform a refund and cancellation
* of the key
* @param _tokenId The id of the key to expire
* @param _amount The amount to refund
*/
function expireAndRefundFor(
uint _tokenId,
uint _amount
) external {
_isKey(_tokenId);
_isValidKey(_tokenId);
_onlyLockManager();
_cancelAndRefund(_tokenId, _amount);
}
/**
* @dev Destroys the key and sends a refund based on the amount of time remaining.
* @param _tokenId The id of the key to cancel.
*/
function cancelAndRefund(uint _tokenId) external {
_isKey(_tokenId);
_isValidKey(_tokenId);
_onlyKeyManagerOrApproved(_tokenId);
uint refund = getCancelAndRefundValue(_tokenId);
_cancelAndRefund(_tokenId, refund);
}
/**
* Allow the owner to change the refund penalty.
*/
function updateRefundPenalty(
uint _freeTrialLength,
uint _refundPenaltyBasisPoints
) external {
_onlyLockManager();
emit RefundPenaltyChanged(
_freeTrialLength,
_refundPenaltyBasisPoints
);
freeTrialLength = _freeTrialLength;
refundPenaltyBasisPoints = _refundPenaltyBasisPoints;
}
/**
* @dev cancels the key for the given keyOwner and sends the refund to the msg.sender.
* @notice this deletes ownership info and expire the key, but doesnt 'burn' it
*/
function _cancelAndRefund(
uint _tokenId,
uint refund
) internal {
address payable keyOwner = payable(ownerOf(_tokenId));
// expire the key without affecting the ownership record
_cancelKey(_tokenId);
// emit event
emit CancelKey(_tokenId, keyOwner, msg.sender, refund);
if (refund > 0) {
_transfer(tokenAddress, keyOwner, refund);
}
// make future reccuring transactions impossible
_originalDurations[_tokenId] = 0;
_originalPrices[_tokenId] = 0;
// inform the hook if there is one registered
if (address(onKeyCancelHook) != address(0)) {
onKeyCancelHook.onKeyCancel(
msg.sender,
keyOwner,
refund
);
}
}
/**
* @dev Determines how much of a refund a key would be worth if a cancelAndRefund
* is issued now.
* @param _tokenId the key to check the refund value for.
* @notice due to the time required to mine a tx, the actual refund amount will be lower
* than what the user reads from this call.
*/
function getCancelAndRefundValue(
uint _tokenId
) public view returns (uint refund) {
_isValidKey(_tokenId);
// return entire purchased price if key is non-expiring
if (expirationDuration == type(uint).max) {
return keyPrice;
}
// substract free trial value
uint timeRemaining = keyExpirationTimestampFor(
_tokenId
) - block.timestamp;
if (
timeRemaining + freeTrialLength >= expirationDuration
) {
refund = keyPrice;
} else {
refund =
(keyPrice * timeRemaining) /
expirationDuration;
}
// Apply the penalty if this is not a free trial
if (
freeTrialLength == 0 ||
timeRemaining + freeTrialLength < expirationDuration
) {
uint penalty = (keyPrice * refundPenaltyBasisPoints) /
BASIS_POINTS_DEN;
if (refund > penalty) {
refund -= penalty;
} else {
refund = 0;
}
}
}
uint256[1000] private __safe_upgrade_gap;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
// This contract mostly follows the pattern established by openzeppelin in
// openzeppelin/contracts-ethereum-package/contracts/access/roles
import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";
import "./MixinErrors.sol";
contract MixinRoles is
AccessControlUpgradeable,
MixinErrors
{
// roles
bytes32 internal constant LOCK_MANAGER_ROLE = keccak256("LOCK_MANAGER");
bytes32 internal constant KEY_GRANTER_ROLE = keccak256("KEY_GRANTER");
// events
event LockManagerAdded(address indexed account);
event LockManagerRemoved(address indexed account);
event KeyGranterAdded(address indexed account);
event KeyGranterRemoved(address indexed account);
// initializer
function _initializeMixinRoles(address sender) internal {
// for admin mamangers to add other lock admins
_setRoleAdmin(LOCK_MANAGER_ROLE, LOCK_MANAGER_ROLE);
// for lock managers to add/remove key granters
_setRoleAdmin(KEY_GRANTER_ROLE, LOCK_MANAGER_ROLE);
if (!isLockManager(sender)) {
_setupRole(LOCK_MANAGER_ROLE, sender);
}
if (!hasRole(KEY_GRANTER_ROLE, sender)) {
_setupRole(KEY_GRANTER_ROLE, sender);
}
}
// modifiers
function _onlyLockManager() internal view {
if (!hasRole(LOCK_MANAGER_ROLE, msg.sender)) {
revert ONLY_LOCK_MANAGER();
}
}
// lock manager functions
function isLockManager(
address account
) public view returns (bool) {
return hasRole(LOCK_MANAGER_ROLE, account);
}
function addLockManager(address account) public {
_onlyLockManager();
grantRole(LOCK_MANAGER_ROLE, account);
emit LockManagerAdded(account);
}
function renounceLockManager() public {
renounceRole(LOCK_MANAGER_ROLE, msg.sender);
emit LockManagerRemoved(msg.sender);
}
uint256[1000] private __safe_upgrade_gap;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./MixinRoles.sol";
import "./MixinDisable.sol";
import "./MixinKeys.sol";
import "./MixinFunds.sol";
import "./MixinLockCore.sol";
import "./MixinPurchase.sol";
import "./MixinErrors.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC721/IERC721ReceiverUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol";
/**
* @title Mixin for the transfer-related functions needed to meet the ERC721
* standard.
* @dev `Mixins` are a design pattern seen in the 0x contracts. It simply
* separates logically groupings of code to ease readability.
*/
contract MixinTransfer is
MixinErrors,
MixinRoles,
MixinFunds,
MixinLockCore,
MixinKeys,
MixinPurchase
{
using AddressUpgradeable for address;
event TransferFeeChanged(uint transferFeeBasisPoints);
// 0x150b7a02 == bytes4(keccak256('onERC721Received(address,address,uint256,bytes)'))
bytes4 private constant _ERC721_RECEIVED = 0x150b7a02;
// The fee relative to keyPrice to charge when transfering a Key to another account
// (potentially on a 0x marketplace).
// This is calculated as `keyPrice * transferFeeBasisPoints / BASIS_POINTS_DEN`.
uint public transferFeeBasisPoints;
/**
* @dev helper to check if transfer have been disabled
*/
function _transferNotDisabled() internal view {
if (
transferFeeBasisPoints >= BASIS_POINTS_DEN && !isLockManager(msg.sender)
) {
revert KEY_TRANSFERS_DISABLED();
}
}
/**
* @notice Allows the key owner to safely transfer a portion of the remaining time
* from their key to a new key
* @param _tokenIdFrom the key to share
* @param _to The recipient of the shared time
* @param _timeShared The amount of time shared
*/
function shareKey(address _to, uint _tokenIdFrom, uint _timeShared) public {
_lockIsUpToDate();
if (maxNumberOfKeys <= _totalSupply) {
revert LOCK_SOLD_OUT();
}
_onlyKeyManagerOrApproved(_tokenIdFrom);
_isValidKey(_tokenIdFrom);
_transferNotDisabled();
address keyOwner = _ownerOf[_tokenIdFrom];
// store time to be added
uint time;
// get the remaining time for the origin key
uint timeRemaining = keyExpirationTimestampFor(_tokenIdFrom) -
block.timestamp;
// get the transfer fee based on amount of time wanted share
uint fee = getTransferFee(_tokenIdFrom, _timeShared);
uint timePlusFee = _timeShared + fee;
// ensure that we don't try to share too much
if (timePlusFee < timeRemaining) {
// now we can safely set the time
time = _timeShared;
// deduct time from parent key, including transfer fee
_timeMachine(_tokenIdFrom, timePlusFee, false);
} else {
// we have to recalculate the fee here
fee = getTransferFee(_tokenIdFrom, timeRemaining);
time = timeRemaining - fee;
_keys[_tokenIdFrom].expirationTimestamp = block.timestamp; // Effectively expiring the key
emit ExpireKey(_tokenIdFrom);
}
// create new key
uint tokenIdTo = _createNewKey(_to, address(0), block.timestamp + time);
// trigger event
emit Transfer(keyOwner, _to, tokenIdTo);
if (!_checkOnERC721Received(keyOwner, _to, tokenIdTo, "")) {
revert NON_COMPLIANT_ERC721_RECEIVER();
}
}
/**
* an ERC721-like function to transfer a token from one account to another.
* @param _from the owner of token to transfer
* @param _recipient the address that will receive the token
* @param _tokenId the id of the token
* @dev Requirements: if the caller is not `from`, it must be approved to move this token by
* either {approve} or {setApprovalForAll}.
* The key manager will be reset to address zero after the transfer
*/
function transferFrom(
address _from,
address _recipient,
uint _tokenId
) public {
_onlyKeyManagerOrApproved(_tokenId);
// reset key manager to address zero
keyManagerOf[_tokenId] = address(0);
_transferFrom(_from, _recipient, _tokenId);
}
/**
* Lending a key allows you to transfer the token while retaining the
* ownerships right by setting yourself as a key manager first.
* @param _from the owner of token to transfer
* @param _recipient the address that will receive the token
* @param _tokenId the id of the token
* @notice This function can only called by 1) the key owner when no key manager is set or 2) the key manager.
* After calling the function, the `_recipient` will be the new owner, and the sender of the tx
* will become the key manager.
*/
function lendKey(address _from, address _recipient, uint _tokenId) public {
// make sure caller is either owner or key manager
if (!_isKeyManager(_tokenId, msg.sender)) {
revert UNAUTHORIZED();
}
// transfer key ownership to lender
_transferFrom(_from, _recipient, _tokenId);
// set key owner as key manager
keyManagerOf[_tokenId] = msg.sender;
}
/**
* Unlend is called when you have lent a key and want to claim its full ownership back.
* @param _recipient the address that will receive the token ownership
* @param _tokenId the id of the token
* @dev Only the key manager of the token can call this function
*/
function unlendKey(address _recipient, uint _tokenId) public {
if (msg.sender != keyManagerOf[_tokenId]) {
revert UNAUTHORIZED();
}
_transferFrom(ownerOf(_tokenId), _recipient, _tokenId);
}
/**
* This functions contains the logic to transfer a token
* from an account to another
*/
function _transferFrom(
address _from,
address _recipient,
uint _tokenId
) private {
_isValidKey(_tokenId);
_transferNotDisabled();
// incorrect _from field
if (ownerOf(_tokenId) != _from) {
revert UNAUTHORIZED();
}
if (_recipient == address(0)) {
revert INVALID_ADDRESS();
}
if (_from == _recipient) {
revert TRANSFER_TO_SELF();
}
// subtract the fee from the senders key before the transfer
_timeMachine(_tokenId, getTransferFee(_tokenId, 0), false);
// transfer a token
Key storage key = _keys[_tokenId];
// update expiration
key.expirationTimestamp = keyExpirationTimestampFor(_tokenId);
// increase total number of unique owners
if (totalKeys(_recipient) == 0) {
numberOfOwners++;
}
// delete token from previous owner
_deleteOwnershipRecord(_tokenId);
// record new owner
_createOwnershipRecord(_tokenId, _recipient);
// clear any previous approvals
_clearApproval(_tokenId);
// make future reccuring transactions impossible
_originalDurations[_tokenId] = 0;
_originalPrices[_tokenId] = 0;
// trigger event
emit Transfer(_from, _recipient, _tokenId);
// fire hook if it exists
if (address(onKeyTransferHook) != address(0)) {
onKeyTransferHook.onKeyTransfer(
address(this),
_tokenId,
msg.sender, // operator
_from,
_recipient,
key.expirationTimestamp
);
}
}
/**
* @notice Transfers the ownership of an NFT from one address to another address
* @dev This works identically to the other function with an extra data parameter,
* except this function just sets data to ''
* @param _from The current owner of the NFT
* @param _to The new owner
* @param _tokenId The NFT to transfer
*/
function safeTransferFrom(address _from, address _to, uint _tokenId) public {
safeTransferFrom(_from, _to, _tokenId, "");
}
/**
* @dev Sets or unsets the approval of a given operator
* An operator is allowed to transfer all tokens of the sender on their behalf
* @param _to operator address to set the approval
* @param _approved representing the status of the approval to be set
* @notice disabled when transfers are disabled
*/
function setApprovalForAll(address _to, bool _approved) public {
_transferNotDisabled();
if (_to == msg.sender) {
revert CANNOT_APPROVE_SELF();
}
managerToOperatorApproved[msg.sender][_to] = _approved;
emit ApprovalForAll(msg.sender, _to, _approved);
}
/**
* @notice Transfers the ownership of an NFT from one address to another address.
* When transfer is complete, this functions
* checks if `_to` is a smart contract (code size > 0). If so, it calls
* `onERC721Received` on `_to` and throws if the return value is not
* `bytes4(keccak256('onERC721Received(address,address,uint,bytes)'))`.
* @param _from The current owner of the NFT
* @param _to The new owner
* @param _tokenId The NFT to transfer
* @param _data Additional data with no specified format, sent in call to `_to`
*/
function safeTransferFrom(
address _from,
address _to,
uint _tokenId,
bytes memory _data
) public {
transferFrom(_from, _to, _tokenId);
if (!_checkOnERC721Received(_from, _to, _tokenId, _data)) {
revert NON_COMPLIANT_ERC721_RECEIVER();
}
}
/**
* Allow the Lock owner to change the transfer fee.
*/
function updateTransferFee(uint _transferFeeBasisPoints) external {
_onlyLockManager();
emit TransferFeeChanged(_transferFeeBasisPoints);
transferFeeBasisPoints = _transferFeeBasisPoints;
}
/**
* Determines how much of a fee would need to be paid in order to
* transfer to another account. This is pro-rated so the fee goes
* down overtime.
* @dev Throws if _tokenId is not have a valid key
* @param _tokenId The id of the key check the transfer fee for.
* @param _time The amount of time to calculate the fee for.
* @return The transfer fee in seconds.
*/
function getTransferFee(
uint _tokenId,
uint _time
) public view returns (uint) {
_isKey(_tokenId);
uint expirationTimestamp = keyExpirationTimestampFor(_tokenId);
if (expirationTimestamp < block.timestamp) {
return 0;
} else {
uint timeToTransfer;
if (_time == 0) {
timeToTransfer = expirationTimestamp - block.timestamp;
} else {
timeToTransfer = _time;
}
return (timeToTransfer * transferFeeBasisPoints) / BASIS_POINTS_DEN;
}
}
/**
* @dev Internal function to invoke `onERC721Received` on a target address
* The call is not executed if the target address is not a contract
* @param from address representing the previous owner of the given token ID
* @param to target address that will receive the tokens
* @param tokenId uint256 ID of the token to be transferred
* @param _data bytes optional data to send along with the call
* @return whether the call correctly returned the expected magic value
*/
function _checkOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory _data
) internal returns (bool) {
if (!to.isContract()) {
return true;
}
bytes4 retval = IERC721ReceiverUpgradeable(to).onERC721Received(
msg.sender,
from,
tokenId,
_data
);
return (retval == _ERC721_RECEIVED);
}
uint256[1000] private __safe_upgrade_gap;
}// SPDX-License-Identifier: MIT
pragma solidity >=0.5.17 <=0.8.13;
// This contract provides some utility methods for use with the unlock protocol smart contracts.
// Borrowed from:
// https://github.com/oraclize/ethereum-api/blob/master/oraclizeAPI_0.5.sol#L943
library UnlockUtils {
function strConcat(
string memory _a,
string memory _b,
string memory _c,
string memory _d
)
internal
pure
returns (string memory _concatenatedString)
{
return string(abi.encodePacked(_a, _b, _c, _d));
}
function uint2Str(
uint _i
) internal pure returns (string memory _uintAsString) {
// make a copy of the param to avoid security/no-assign-params error
uint c = _i;
if (_i == 0) {
return "0";
}
uint j = _i;
uint len;
while (j != 0) {
len++;
j /= 10;
}
bytes memory bstr = new bytes(len);
uint k = len;
while (c != 0) {
k = k - 1;
uint8 temp = (48 + uint8(c - (c / 10) * 10));
bytes1 b1 = bytes1(temp);
bstr[k] = b1;
c /= 10;
}
return string(bstr);
}
function address2Str(
address _addr
) internal pure returns (string memory) {
bytes32 value = bytes32(uint256(uint160(_addr)));
bytes memory alphabet = "0123456789abcdef";
bytes memory str = new bytes(42);
str[0] = "0";
str[1] = "x";
for (uint i = 0; i < 20; i++) {
str[2 + i * 2] = alphabet[uint8(value[i + 12] >> 4)];
str[3 + i * 2] = alphabet[
uint8(value[i + 12] & 0x0f)
];
}
return string(str);
}
}{
"optimizer": {
"enabled": true,
"runs": 80
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"libraries": {}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[],"name":"CANNOT_APPROVE_SELF","type":"error"},{"inputs":[],"name":"CANT_BE_SMALLER_THAN_SUPPLY","type":"error"},{"inputs":[],"name":"CANT_EXTEND_NON_EXPIRING_KEY","type":"error"},{"inputs":[],"name":"GAS_REFUND_FAILED","type":"error"},{"inputs":[],"name":"INSUFFICIENT_ERC20_VALUE","type":"error"},{"inputs":[],"name":"INSUFFICIENT_VALUE","type":"error"},{"inputs":[],"name":"INVALID_ADDRESS","type":"error"},{"inputs":[{"internalType":"uint8","name":"hookIndex","type":"uint8"}],"name":"INVALID_HOOK","type":"error"},{"inputs":[],"name":"INVALID_LENGTH","type":"error"},{"inputs":[],"name":"INVALID_TOKEN","type":"error"},{"inputs":[],"name":"KEY_NOT_VALID","type":"error"},{"inputs":[],"name":"KEY_TRANSFERS_DISABLED","type":"error"},{"inputs":[],"name":"LOCK_HAS_CHANGED","type":"error"},{"inputs":[],"name":"LOCK_SOLD_OUT","type":"error"},{"inputs":[],"name":"MAX_KEYS_REACHED","type":"error"},{"inputs":[],"name":"MIGRATION_REQUIRED","type":"error"},{"inputs":[],"name":"NON_COMPLIANT_ERC721_RECEIVER","type":"error"},{"inputs":[],"name":"NON_RENEWABLE_LOCK","type":"error"},{"inputs":[],"name":"NOT_ENOUGH_FUNDS","type":"error"},{"inputs":[],"name":"NOT_ENOUGH_TIME","type":"error"},{"inputs":[],"name":"NOT_READY_FOR_RENEWAL","type":"error"},{"inputs":[],"name":"NO_SUCH_KEY","type":"error"},{"inputs":[],"name":"NULL_VALUE","type":"error"},{"inputs":[],"name":"ONLY_KEY_MANAGER_OR_APPROVED","type":"error"},{"inputs":[],"name":"ONLY_LOCK_MANAGER","type":"error"},{"inputs":[],"name":"ONLY_LOCK_MANAGER_OR_KEY_GRANTER","type":"error"},{"inputs":[],"name":"OUT_OF_RANGE","type":"error"},{"inputs":[],"name":"OWNER_CANT_BE_ADDRESS_ZERO","type":"error"},{"inputs":[],"name":"SCHEMA_VERSION_NOT_CORRECT","type":"error"},{"inputs":[],"name":"TRANSFER_TO_SELF","type":"error"},{"inputs":[],"name":"TransferFailed","type":"error"},{"inputs":[],"name":"UNAUTHORIZED","type":"error"},{"inputs":[],"name":"UNAUTHORIZED_KEY_MANAGER_UPDATE","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"sendTo","type":"address"},{"indexed":false,"internalType":"uint256","name":"refund","type":"uint256"}],"name":"CancelKey","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"onKeyPurchaseHook","type":"address"},{"indexed":false,"internalType":"address","name":"onKeyCancelHook","type":"address"},{"indexed":false,"internalType":"address","name":"onValidKeyHook","type":"address"},{"indexed":false,"internalType":"address","name":"onTokenURIHook","type":"address"},{"indexed":false,"internalType":"address","name":"onKeyTransferHook","type":"address"},{"indexed":false,"internalType":"address","name":"onKeyExtendHook","type":"address"},{"indexed":false,"internalType":"address","name":"onKeyGrantHook","type":"address"}],"name":"EventHooksUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newExpiration","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"bool","name":"timeAdded","type":"bool"}],"name":"ExpirationChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ExpireKey","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"refundValue","type":"uint256"}],"name":"GasRefundValueChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"uint256","name":"refundedAmount","type":"uint256"},{"indexed":false,"internalType":"address","name":"tokenAddress","type":"address"}],"name":"GasRefunded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newTimestamp","type":"uint256"}],"name":"KeyExtended","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"}],"name":"KeyGranterAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"}],"name":"KeyGranterRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"_tokenId","type":"uint256"},{"indexed":true,"internalType":"address","name":"_newManager","type":"address"}],"name":"KeyManagerChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"updatedRecordsCount","type":"uint256"}],"name":"KeysMigrated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"expirationDuration","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"maxNumberOfKeys","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"maxKeysPerAcccount","type":"uint256"}],"name":"LockConfig","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"}],"name":"LockManagerAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"}],"name":"LockManagerRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"name","type":"string"},{"indexed":false,"internalType":"string","name":"symbol","type":"string"},{"indexed":false,"internalType":"string","name":"baseTokenURI","type":"string"}],"name":"LockMetadata","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":false,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"oldKeyPrice","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"keyPrice","type":"uint256"},{"indexed":false,"internalType":"address","name":"oldTokenAddress","type":"address"},{"indexed":false,"internalType":"address","name":"tokenAddress","type":"address"}],"name":"PricingChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"referrer","type":"address"},{"indexed":false,"internalType":"uint256","name":"fee","type":"uint256"}],"name":"ReferrerFee","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"freeTrialLength","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"refundPenaltyBasisPoints","type":"uint256"}],"name":"RefundPenaltyChanged","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":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"transferFeeBasisPoints","type":"uint256"}],"name":"TransferFeeChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"lockAddress","type":"address"},{"indexed":false,"internalType":"address","name":"unlockAddress","type":"address"}],"name":"UnlockCallFailed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":true,"internalType":"address","name":"tokenAddress","type":"address"},{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Withdrawal","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"addLockManager","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_approved","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_keyOwner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"balance","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"burn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"cancelAndRefund","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"expirationDuration","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"expireAndRefundFor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_value","type":"uint256"},{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"address","name":"_referrer","type":"address"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"extend","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"freeTrialLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"gasRefundValue","outputs":[{"internalType":"uint256","name":"_refundValue","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"getCancelAndRefundValue","outputs":[{"internalType":"uint256","name":"refund","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_keyOwner","type":"address"}],"name":"getHasValidKey","outputs":[{"internalType":"bool","name":"isValid","type":"bool"}],"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":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"uint256","name":"_time","type":"uint256"}],"name":"getTransferFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"uint256","name":"_duration","type":"uint256"}],"name":"grantKeyExtension","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_recipients","type":"address[]"},{"internalType":"uint256[]","name":"_expirationTimestamps","type":"uint256[]"},{"internalType":"address[]","name":"_keyManagers","type":"address[]"}],"name":"grantKeys","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","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":"address payable","name":"_lockCreator","type":"address"},{"internalType":"uint256","name":"_expirationDuration","type":"uint256"},{"internalType":"address","name":"_tokenAddress","type":"address"},{"internalType":"uint256","name":"_keyPrice","type":"uint256"},{"internalType":"uint256","name":"_maxNumberOfKeys","type":"uint256"},{"internalType":"string","name":"_lockName","type":"string"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"address","name":"_operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"isLockManager","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"isOwner","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"address","name":"_referrer","type":"address"}],"name":"isRenewable","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"isValidKey","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"keyExpirationTimestampFor","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"keyManagerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"keyPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_from","type":"address"},{"internalType":"address","name":"_recipient","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"lendKey","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"maxKeysPerAddress","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxNumberOfKeys","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenIdFrom","type":"uint256"},{"internalType":"uint256","name":"_tokenIdTo","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"mergeKeys","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes","name":"","type":"bytes"}],"name":"migrate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"numberOfOwners","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"onKeyCancelHook","outputs":[{"internalType":"contract ILockKeyCancelHook","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"onKeyExtendHook","outputs":[{"internalType":"contract ILockKeyExtendHook","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"onKeyGrantHook","outputs":[{"internalType":"contract ILockKeyGrantHook","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"onKeyPurchaseHook","outputs":[{"internalType":"contract ILockKeyPurchaseHook","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"onKeyTransferHook","outputs":[{"internalType":"contract ILockKeyTransferHook","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"onTokenURIHook","outputs":[{"internalType":"contract ILockTokenURIHook","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"onValidKeyHook","outputs":[{"internalType":"contract ILockValidKeyHook","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"publicLockVersion","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_values","type":"uint256[]"},{"internalType":"address[]","name":"_recipients","type":"address[]"},{"internalType":"address[]","name":"_referrers","type":"address[]"},{"internalType":"address[]","name":"_keyManagers","type":"address[]"},{"internalType":"bytes[]","name":"_data","type":"bytes[]"}],"name":"purchase","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_recipient","type":"address"},{"internalType":"address","name":"_referrer","type":"address"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"purchasePriceFor","outputs":[{"internalType":"uint256","name":"minKeyPrice","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"referrerFees","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"refundPenaltyBasisPoints","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"address","name":"_referrer","type":"address"}],"name":"renewMembershipFor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceLockManager","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_from","type":"address"},{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_from","type":"address"},{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"schemaVersion","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"bool","name":"_approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_onKeyPurchaseHook","type":"address"},{"internalType":"address","name":"_onKeyCancelHook","type":"address"},{"internalType":"address","name":"_onValidKeyHook","type":"address"},{"internalType":"address","name":"_onTokenURIHook","type":"address"},{"internalType":"address","name":"_onKeyTransferHook","type":"address"},{"internalType":"address","name":"_onKeyExtendHook","type":"address"},{"internalType":"address","name":"_onKeyGrantHook","type":"address"}],"name":"setEventHooks","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_refundValue","type":"uint256"}],"name":"setGasRefundValue","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"address","name":"_keyManager","type":"address"}],"name":"setKeyManagerOf","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"_lockName","type":"string"},{"internalType":"string","name":"_lockSymbol","type":"string"},{"internalType":"string","name":"_baseTokenURI","type":"string"}],"name":"setLockMetadata","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"setOwner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_referrer","type":"address"},{"internalType":"uint256","name":"_feeBasisPoint","type":"uint256"}],"name":"setReferrerFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_tokenIdFrom","type":"uint256"},{"internalType":"uint256","name":"_timeShared","type":"uint256"}],"name":"shareKey","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":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tokenAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_index","type":"uint256"}],"name":"tokenByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_keyOwner","type":"address"},{"internalType":"uint256","name":"_index","type":"uint256"}],"name":"tokenOfOwnerByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_keyOwner","type":"address"}],"name":"totalKeys","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"_totalKeysCreated","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"transferFeeBasisPoints","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_from","type":"address"},{"internalType":"address","name":"_recipient","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_recipient","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"unlendKey","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unlockProtocol","outputs":[{"internalType":"contract IUnlock","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_keyPrice","type":"uint256"},{"internalType":"address","name":"_tokenAddress","type":"address"}],"name":"updateKeyPricing","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_newExpirationDuration","type":"uint256"},{"internalType":"uint256","name":"_maxNumberOfKeys","type":"uint256"},{"internalType":"uint256","name":"_maxKeysPerAcccount","type":"uint256"}],"name":"updateLockConfig","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_freeTrialLength","type":"uint256"},{"internalType":"uint256","name":"_refundPenaltyBasisPoints","type":"uint256"}],"name":"updateRefundPenalty","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"updateSchemaVersion","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_transferFeeBasisPoints","type":"uint256"}],"name":"updateTransferFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_tokenAddress","type":"address"},{"internalType":"address payable","name":"_recipient","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]Contract Creation Code
608060405234801561001057600080fd5b50615fab80620000216000396000f3fe6080604052600436106104185760003560e01c806370a0823111610220578063b11d7ec111610124578063d32bfb6c116100b1578063d32bfb6c14610d40578063d52e4a1014610d60578063d547741f14610d76578063d813cc1914610d96578063d9caed1214610da9578063debe2b0d14610dc9578063e985e9c514610de9578063f0ba604014610e09578063f12c6b6e14610e1e578063f32e8b2414610e3e578063f5766b3914610e5357600080fd5b8063b11d7ec114610bf4578063b129694e14610c14578063b1a3b25d14610c35578063b88d4fde14610c55578063c23135dd14610c75578063c87b56dd14610ca3578063c907c3ec14610cc3578063d1b8759b14610ce4578063d1bbd49c14610d04578063d250348514610d2057600080fd5b806391d14854116101ad57806391d1485414610abb57806392ac98a514610adb57806393fd184414610afb57806395d89b4114610b125780639d76ea5814610b27578063a217fddf14610b48578063a22cb46514610b5d578063a2e4cd2e14610b7d578063a375cb0514610b9d578063a98d362314610bb4578063aae4b8f714610bd457600080fd5b806370a082311461098457806374b6c106146109a457806374cac47d146109bb5780637ec2a724146109db578063812eecd4146109fc57806381a3c94314610a1c5780638505fe9514610a3c5780638577a6d514610a5c5780638932a90d14610a7c5780638da5cb5b14610a9c57600080fd5b80632f54bf6e116103275780634d025fed116102b45780634d025fed146108185780634e2ce6d31461084f5780634f6ccce71461086657806350878a471461088657806354b249fb146108a6578063558b71e9146108d757806356e0d51f146108f75780636207a8da1461090e5780636352211e146109245780636d8ea5b4146109445780636eadde431461096457600080fd5b80632f54bf6e146106c75780632f745c59146106f7578063338189971461071757806336568abe14610737578063389f07e81461075757806339f4698614610778578063407dc5891461079857806342842e0e146107b857806342966c68146107d85780634cd38c1d146107f857600080fd5b806313af4035116103a557806313af40351461058757806318160ddd146105a7578063183767da146105bd578063217751bc146105d457806323b872dd146105f5578063248a9ca31461061557806326e9ca0714610645578063282478df146106665780632d33dd5b146106865780632f2ff15d146106a757600080fd5b806301ffc9a714610424578063068208cd1461045957806306fdde031461047b578063081812fc1461049d578063095ea7b3146104ca578063097ba333146104ea5780630c2db8d1146105185780630f15023b1461053857806310e569731461055957806311a4c03a1461057057600080fd5b3661041f57005b600080fd5b34801561043057600080fd5b5061044461043f36600461505a565b610e73565b60405190151581526020015b60405180910390f35b34801561046557600080fd5b50610479610474366004615077565b610e84565b005b34801561048757600080fd5b50610490610f03565b60405161045091906150fb565b3480156104a957600080fd5b506104bd6104b836600461510e565b610f92565b6040516104509190615127565b3480156104d657600080fd5b506104796104e5366004615150565b610fba565b3480156104f657600080fd5b5061050a61050536600461523f565b611055565b604051908152602001610450565b34801561052457600080fd5b506104796105333660046152a0565b6110f6565b34801561054457600080fd5b50610c83546104bd906001600160a01b031681565b34801561056557600080fd5b5061050a610c855481565b34801561057c57600080fd5b5061050a610c845481565b34801561059357600080fd5b506104796105a23660046152e1565b61114b565b3480156105b357600080fd5b50610c875461050a565b3480156105c957600080fd5b5061050a6124075481565b3480156105e057600080fd5b50610c8a546104bd906001600160a01b031681565b34801561060157600080fd5b506104796106103660046152a0565b6111dc565b34801561062157600080fd5b5061050a61063036600461510e565b60009081526097602052604090206001015490565b34801561065157600080fd5b50610c8b546104bd906001600160a01b031681565b34801561067257600080fd5b50610479610681366004615077565b61120d565b34801561069257600080fd5b50610c89546104bd906001600160a01b031681565b3480156106b357600080fd5b506104796106c23660046152fe565b6112b2565b3480156106d357600080fd5b506104446106e23660046152e1565b612bda546001600160a01b0390811691161490565b34801561070357600080fd5b5061050a610712366004615150565b6112d7565b61072a610725366004615466565b61132b565b604051610450919061553d565b34801561074357600080fd5b506104796107523660046152fe565b611709565b34801561076357600080fd5b50610c8f546104bd906001600160a01b031681565b34801561078457600080fd5b50610479610793366004615581565b61178c565b3480156107a457600080fd5b506104796107b3366004615150565b6117da565b3480156107c457600080fd5b506104796107d33660046152a0565b611825565b3480156107e457600080fd5b506104796107f336600461510e565b611840565b34801561080457600080fd5b50610479610813366004615581565b6118b6565b34801561082457600080fd5b506104bd61083336600461510e565b611078602052600090815260409020546001600160a01b031681565b34801561085b57600080fd5b5061050a610c8d5481565b34801561087257600080fd5b5061050a61088136600461510e565b61191a565b34801561089257600080fd5b506104446108a13660046152fe565b611943565b3480156108b257600080fd5b5061050a6108c136600461510e565b600090815261107b602052604090206001015490565b3480156108e357600080fd5b506104796108f2366004615581565b611a99565b34801561090357600080fd5b5061050a6127f05481565b34801561091a57600080fd5b5061201e5461050a565b34801561093057600080fd5b506104bd61093f36600461510e565b611abd565b34801561095057600080fd5b5061044461095f3660046152e1565b611ad9565b34801561097057600080fd5b5061047961097f3660046155e4565b611b8d565b34801561099057600080fd5b5061050a61099f3660046152e1565b611d0c565b3480156109b057600080fd5b5061050a610c865481565b3480156109c757600080fd5b506104796109d6366004615669565b611d5e565b3480156109e757600080fd5b50610c8c546104bd906001600160a01b031681565b348015610a0857600080fd5b5061050a610a173660046152e1565b61203f565b348015610a2857600080fd5b5061072a610a373660046156ff565b612085565b348015610a4857600080fd5b50610479610a573660046152fe565b6122f4565b348015610a6857600080fd5b50610479610a7736600461510e565b61235b565b348015610a8857600080fd5b50610479610a97366004615779565b61239c565b348015610aa857600080fd5b50612bda546001600160a01b03166104bd565b348015610ac757600080fd5b50610444610ad63660046152fe565b6124a7565b348015610ae757600080fd5b5061050a610af636600461510e565b6124d2565b348015610b0757600080fd5b5061050a6110775481565b348015610b1e57600080fd5b506104906125c1565b348015610b3357600080fd5b506104b1546104bd906001600160a01b031681565b348015610b5457600080fd5b5061050a600081565b348015610b6957600080fd5b50610479610b783660046157c8565b6126ec565b348015610b8957600080fd5b50610479610b983660046152fe565b61278a565b348015610ba957600080fd5b5061050a6127f15481565b348015610bc057600080fd5b50610444610bcf36600461510e565b612818565b348015610be057600080fd5b50610444610bef3660046152e1565b6128dc565b348015610c0057600080fd5b50610479610c0f3660046152fe565b6128f6565b348015610c2057600080fd5b50610c91546104bd906001600160a01b031681565b348015610c4157600080fd5b5061050a610c50366004615581565b612944565b348015610c6157600080fd5b50610479610c703660046157f6565b6129b7565b348015610c8157600080fd5b5061050a610c903660046152e1565b6120226020526000908152604090205481565b348015610caf57600080fd5b50610490610cbe36600461510e565b6129f1565b348015610ccf57600080fd5b50610c90546104bd906001600160a01b031681565b348015610cf057600080fd5b50610479610cff366004615861565b612c83565b348015610d1057600080fd5b50604051600d8152602001610450565b348015610d2c57600080fd5b50610479610d3b3660046152e1565b612cfe565b348015610d4c57600080fd5b50610479610d5b36600461510e565b612d55565b348015610d6c57600080fd5b50610c8e5461050a565b348015610d8257600080fd5b50610479610d913660046152fe565b612d87565b610479610da43660046158e8565b612dac565b348015610db557600080fd5b50610479610dc43660046152a0565b612e73565b348015610dd557600080fd5b50610479610de4366004615150565b612fa9565b348015610df557600080fd5b50610444610e04366004615951565b61300b565b348015610e1557600080fd5b5061047961303a565b348015610e2a57600080fd5b50610479610e3936600461597f565b61307f565b348015610e4a57600080fd5b5061047961321e565b348015610e5f57600080fd5b50610479610e6e36600461510e565b61322e565b6000610e7e82613272565b92915050565b610e8d8361327d565b610e96836132af565b610e9f836132d5565b610ea88261327d565b600083815261107b6020526040902060010154610ec69042906159ca565b811115610ee6576040516310e88eed60e31b815260040160405180910390fd5b610ef28382600061339f565b610efe8282600161339f565b505050565b6114638054610f11906159e1565b80601f0160208091040260200160405190810160405280929190818152602001828054610f3d906159e1565b8015610f8a5780601f10610f5f57610100808354040283529160200191610f8a565b820191906000526020600020905b815481529060010190602001808311610f6d57829003601f168201915b505050505081565b6000610f9d8261327d565b50600090815261107960205260409020546001600160a01b031690565b610fc3816132d5565b6001600160a01b0382163303610fec57604051637899146560e11b815260040160405180910390fd5b60008181526110796020908152604080832080546001600160a01b0319166001600160a01b03878116918217909255611076909352818420549151859492909116917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591a45050565b610c89546000906001600160a01b0316156110e957610c895460405163221c1fd160e01b81526001600160a01b039091169063221c1fd1906110a1903390889088908890600401615a15565b602060405180830381865afa1580156110be573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110e29190615a49565b90506110ef565b50610c85545b9392505050565b6111008133613471565b61111d5760405163075fd2b160e01b815260040160405180910390fd5b6111288383836134e9565b60009081526110786020526040902080546001600160a01b031916331790555050565b6111536136cf565b6001600160a01b03811661117a576040516330c6e09f60e21b815260040160405180910390fd5b612bda80546001600160a01b038381166001600160a01b031983168117909355604080519190921680825260208201939093527f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0910160405180910390a15050565b6111e5816132d5565b60008181526110786020526040902080546001600160a01b0319169055610efe8383836134e9565b6112156136cf565b806000036112365760405163e03b033d60e01b815260040160405180910390fd5b610c875482101561125a57604051631d00cd6b60e01b815260040160405180910390fd5b610c8e819055610c84839055610c8682905560408051848152602081018490529081018290527f9a09448a3f24d3a01ccc67103c7cddbeea820176a18182cc83d0bce585f26a5b9060600160405180910390a1505050565b6000828152609760205260409020600101546112cd81613706565b610efe8383613710565b60006112e28361203f565b821061130157604051630471175760e11b815260040160405180910390fd5b506001600160a01b0391909116600090815261107c60209081526040808320938352929052205490565b6060611335613796565b610c86548651610c87546113499190615a62565b1115611368576040516331af695160e01b815260040160405180910390fd5b8451865114158061137b57508351865114155b15611399576040516376b3b52560e11b815260040160405180910390fd5b60008087516001600160401b038111156113b5576113b561517c565b6040519080825280602002602001820160405280156113de578160200160208202803683370190505b50905060005b88518110156116a057600089828151811061140157611401615a7a565b602002602001015190506114508189848151811061142157611421615a7a565b6020026020010151600019610c84541461144857610c84546114439042615a62565b6137ba565b6000196137ba565b83838151811061146257611462615a7a565b60200260200101818152505060006114ec828b858151811061148657611486615a7a565b60200260200101518a8a878181106114a0576114a0615a7a565b90506020028101906114b29190615a90565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061105592505050565b90506114f88186615a62565b945061151d84848151811061150f5761150f615a7a565b602002602001015182613895565b6104b1546001600160a01b031615611552576115528c848151811061154457611544615a7a565b602002602001015182613946565b611575818b858151811061156857611568615a7a565b6020026020010151613967565b6104b1546000906001600160a01b0316156115a9578c848151811061159c5761159c615a7a565b60200260200101516115ab565b345b610c89549091506001600160a01b03161561168a57610c895485516001600160a01b0390911690635e895f29908790879081106115ea576115ea615a7a565b602002602001015133868f898151811061160657611606615a7a565b60200260200101518e8e8b81811061162057611620615a7a565b90506020028101906116329190615a90565b89896040518963ffffffff1660e01b8152600401611657989796959493929190615ad6565b600060405180830381600087803b15801561167157600080fd5b505af1158015611685573d6000803e3d6000fd5b505050505b505050808061169890615b40565b9150506113e4565b506116ab3383613a3c565b6116b482613ae7565b6116bc613bdb565b60005b87518110156116fc576116ea8882815181106116dd576116dd615a7a565b6020026020010151613c4f565b806116f481615b40565b9150506116bf565b5098975050505050505050565b6001600160a01b038116331461177e5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b60648201526084015b60405180910390fd5b6117888282613cf7565b5050565b6117946136cf565b60408051838152602081018390527fd6867bc538320e67d7bdc35860c27c08486eb490b4fd9b820fff18fb28381d3c910160405180910390a16127f1919091556127f055565b600081815261107860205260409020546001600160a01b031633146118125760405163075fd2b160e01b815260040160405180910390fd5b61178861181e82611abd565b83836134e9565b610efe838383604051806020016040528060008152506129b7565b6118498161327d565b611852816132d5565b600081815261107660205260408082205490518392916001600160a01b031690600080516020615f36833981519152908390a4600090815261107b6020908152604080832042600190910155611076909152902080546001600160a01b0319169055565b6118be613796565b6118c78261327d565b6118df600080516020615ef6833981519152336124a7565b1580156118f257506118f0336128dc565b155b1561191057604051631798fedb60e01b815260040160405180910390fd5b610efe8282613d5e565b6000610c8754821061193f57604051630471175760e11b815260040160405180910390fd5b5090565b60008281526120206020526040812054600019148061196c57506104b1546001600160a01b0316155b1561198a57604051636cd40e1160e11b815260040160405180910390fd5b6119ac61199684611abd565b8360405180602001604052806000815250611055565b600084815261201f602052604090205410806119d95750610c845460008481526120206020526040902054115b80611a0357506104b154600084815261202160205260409020546001600160a01b03908116911614155b15611a215760405163986739e760e01b815260040160405180910390fd5b6000612710610c8454612328611a379190615b59565b611a419190615b78565b610c8454600086815261107b6020526040902060010154611a6291906159ca565b611a6c9190615a62565b905080421015611a8f576040516360d8ec3360e11b815260040160405180910390fd5b5060019392505050565b611aa28261327d565b611aab826132af565b611ab36136cf565b6117888282613ebf565b600090815261107660205260409020546001600160a01b031690565b6000611ae482611d0c565b600003611b7a57610c8b546001600160a01b031615611b7a57610c8b5460405163084fdbc760e31b81526001600160a01b039091169063427ede3890611b399030903390600090819089908290600401615b9a565b602060405180830381865afa158015611b56573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e7e9190615bd5565b6001611b8583611d0c565b101592915050565b600054610100900460ff1615808015611bad5750600054600160ff909116105b80611bce5750611bbc30613fea565b158015611bce575060005460ff166001145b611c315760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401611775565b6000805460ff191660011790558015611c54576000805461ff0019166101001790555b611c5d86613ff9565b611c6988888787614025565b611c738383614066565b611c7b61408c565b611c876103e86127f055565b611c908861409c565b612bda80546001600160a01b0319166001600160a01b038a16179055611cbc6380ac58cd60e01b614133565b8015611d02576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5050505050505050565b600080611d188361203f565b905060005b81811015611d5757611d32610bcf85836112d7565b15611d455782611d4181615b40565b9350505b80611d4f81615b40565b915050611d1d565b5050919050565b611d666136cf565b6001600160a01b03871615801590611d8d5750611d8b876001600160a01b0316613fea565b155b15611dae57604051636788e02b60e01b815260006004820152602401611775565b6001600160a01b03861615801590611dd55750611dd3866001600160a01b0316613fea565b155b15611df657604051636788e02b60e01b815260016004820152602401611775565b6001600160a01b03851615801590611e1d5750611e1b856001600160a01b0316613fea565b155b15611e3e57604051636788e02b60e01b815260026004820152602401611775565b6001600160a01b03841615801590611e655750611e63846001600160a01b0316613fea565b155b15611e8657604051636788e02b60e01b815260036004820152602401611775565b6001600160a01b03831615801590611ead5750611eab836001600160a01b0316613fea565b155b15611ecd57604051636788e02b60e01b8152600481810152602401611775565b6001600160a01b03821615801590611ef45750611ef2826001600160a01b0316613fea565b155b15611f1557604051636788e02b60e01b815260056004820152602401611775565b6001600160a01b03811615801590611f3c5750611f3a816001600160a01b0316613fea565b155b15611f5d57604051636788e02b60e01b815260066004820152602401611775565b610c8980546001600160a01b038981166001600160a01b03199283168117909355610c8a80548a83169084168117909155610c8c80548984169085168117909155610c8b80548b85169086168117909155610c8f80548a86169087168117909155610c9080548a87169088168117909155610c918054968a16969097168617909655604080519788526020880194909452928601526060850152608084015260a083019190915260c08201527f0a851288e37fa9a8bc562891998524e95c286fe84f693c1921e0fd0792171af69060e00160405180910390a150505050505050565b60006001600160a01b03821661206857604051635963709b60e01b815260040160405180910390fd5b506001600160a01b0316600090815261107e602052604090205490565b606061208f613796565b6120a7600080516020615ef6833981519152336124a7565b1580156120ba57506120b8336128dc565b155b156120d857604051631798fedb60e01b815260040160405180910390fd5b6000866001600160401b038111156120f2576120f261517c565b60405190808252806020026020018201604052801561211b578160200160208202803683370190505b50905060005b878110156122e85761219889898381811061213e5761213e615a7a565b905060200201602081019061215391906152e1565b86868481811061216557612165615a7a565b905060200201602081019061217a91906152e1565b89898581811061218c5761218c615a7a565b905060200201356137ba565b8282815181106121aa576121aa615a7a565b6020908102919091010152610c91546001600160a01b0316156122d657610c915482516001600160a01b03909116906348a254b8908490849081106121f1576121f1615a7a565b6020026020010151338c8c8681811061220c5761220c615a7a565b905060200201602081019061222191906152e1565b89898781811061223357612233615a7a565b905060200201602081019061224891906152e1565b8c8c8881811061225a5761225a615a7a565b6040516001600160e01b031960e08a901b16815260048101979097526001600160a01b039586166024880152938516604487015250921660648401526020020135608482015260a401600060405180830381600087803b1580156122bd57600080fd5b505af11580156122d1573d6000803e3d6000fd5b505050505b806122e081615b40565b915050612121565b50979650505050505050565b6122fc613796565b6123058261327d565b61230f8282611943565b5061231b826000613d5e565b50612329610c855482613967565b61233e61233583611abd565b610c8554613a3c565b612346613bdb565b61234f81613c4f565b611788610c8554613ae7565b6123636136cf565b6040518181527f0496ed1e61eb69727f9659a8e859288db4758ffb1f744d1c1424634f90a257f49060200160405180910390a161240755565b6123a86001600d615bf2565b61ffff16610c8d5414806123bd5750610c8d54155b6124065760405162461bcd60e51b815260206004820152601a60248201527914d0d211535057d5915494d253d397d393d517d0d3d4949150d560321b6044820152606401611775565b4660010361249d57600073e79b93f8e22676774f2a8dad469175ebd00029fa9050806001600160a01b031663ed9674bd6040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561246257600080fd5b505af1158015612476573d6000803e3d6000fd5b5050610c8380546001600160a01b0319166001600160a01b03949094169390931790925550505b5050600d610c8d55565b60009182526097602090815260408084206001600160a01b0393909316845291905290205460ff1690565b60006124dd826132af565b600019610c8454036124f2575050610c855490565b600082815261107b60205260408120600101546125109042906159ca565b9050610c84546127f154826125259190615a62565b1061253557610c85549150612555565b610c845481610c85546125489190615b59565b6125529190615b78565b91505b6127f15415806125745750610c84546127f1546125729083615a62565b105b156125bb5760006127106127f054610c85546125909190615b59565b61259a9190615b78565b9050808311156125b5576125ae81846159ca565b9250611d57565b60009250505b50919050565b606061146480546125d1906159e1565b905060000361265b57610c8360009054906101000a90046001600160a01b03166001600160a01b031663cec410526040518163ffffffff1660e01b8152600401600060405180830381865afa15801561262e573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526126569190810190615c15565b905090565b6114648054612669906159e1565b80601f0160208091040260200160405190810160405280929190818152602001828054612695906159e1565b80156126e25780601f106126b7576101008083540402835291602001916126e2565b820191906000526020600020905b8154815290600101906020018083116126c557829003601f168201915b5050505050905090565b6126f46141b2565b336001600160a01b0383160361271d57604051637899146560e11b815260040160405180910390fd5b33600081815261107a602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b6127926136cf565b61279b816141eb565b610c8580546104b18054928590556001600160a01b031983166001600160a01b0385811691821790925560408051848152602081018890529290941693820184905260608201529091907f3615065ccf48367ac483ac86701248e2e5ff55bdd9be845007d34a3b68d719d49060800160405180910390a150505050565b600081815261107b6020526040812060010154610c8b5442909111906001600160a01b031615610e7e57610c8b54600084815261107b60209081526040808320600101546110769092529182902054915163084fdbc760e31b81526001600160a01b039384169363427ede389361289b93309333938b9316908990600401615b9a565b602060405180830381865afa1580156128b8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110ef9190615bd5565b6000610e7e600080516020615f56833981519152836124a7565b6128ff8261327d565b6129098233613471565b15801561291c575061291a336128dc565b155b1561293a5760405163866c2fa760e01b815260040160405180910390fd5b6117888282614282565b600061294f8361327d565b600083815261107b602052604090206001015442811015612974576000915050610e7e565b60008360000361298f5761298842836159ca565b9050612992565b50825b61271061240754826129a49190615b59565b6129ae9190615b78565b92505050610e7e565b6129c28484846111dc565b6129ce8484848461430f565b6129eb576040516303f8ea1560e41b815260040160405180910390fd5b50505050565b606080806000612a00306143c6565b905060608515612a1a57612a13866145b1565b9250612a2d565b6040518060200160405280600081525092505b610c8c546001600160a01b031615612b0457600086815261107b6020526040902060010154610c8c546001600160a01b031663988b93ad3033612a6f8b611abd565b60405160e085901b6001600160e01b03191681526001600160a01b03938416600482015291831660248301529091166044820152606481018a90526084810184905260a401600060405180830381865afa158015612ad1573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052612af99190810190615c15565b979650505050505050565b6114658054612b12906159e1565b9050600003612bba57610c8360009054906101000a90046001600160a01b03166001600160a01b031663a998e9fb6040518163ffffffff1660e01b8152600401600060405180830381865afa158015612b6f573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052612b979190810190615c15565b9350604051806040016040528060018152602001602f60f81b8152509050612c6d565b6114658054612bc8906159e1565b80601f0160208091040260200160405190810160405280929190818152602001828054612bf4906159e1565b8015612c415780601f10612c1657610100808354040283529160200191612c41565b820191906000526020600020905b815481529060010190602001808311612c2457829003601f168201915b505050505093506040518060200160405280600081525090506040518060200160405280600081525091505b612c79848383866146e1565b9695505050505050565b612c8b6136cf565b612c986114638787614fb4565b50612ca66114648585614fb4565b50612cb46114658383614fb4565b507f1e6d6a19e45ae156dcf4155bc83cf8f59e98d536000998f0e95f4cd330ecfb3e611463611464611465604051612cee93929190615d2a565b60405180910390a1505050505050565b612d066136cf565b612d1e600080516020615f56833981519152826112b2565b6040516001600160a01b038216907f91d5c045d5bd98bf59a379b259ebca05b93bf79af1845fdf87e3172385d4c7f790600090a250565b612d5e8161327d565b612d67816132af565b612d70816132d5565b6000612d7b826124d2565b90506117888282613ebf565b600082815260976020526040902060010154612da281613706565b610efe8383613cf7565b612db4613796565b612dbd8461327d565b612dc8846000613d5e565b506000612e14612dd786611abd565b8585858080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061105592505050565b6104b1549091506001600160a01b031615612e3357612e338682613946565b612e3d8185613967565b612e473382613a3c565b612e518582613895565b612e59613bdb565b612e6284613c4f565b612e6b81613ae7565b505050505050565b612e7b6136cf565b60006001600160a01b038416612e92575047612f02565b6040516370a0823160e01b81526001600160a01b038516906370a0823190612ebe903090600401615127565b602060405180830381865afa158015612edb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612eff9190615a49565b90505b6000821580612f1057508183115b15612f3d5760008211612f36576040516303e09bb960e31b815260040160405180910390fd5b5080612f40565b50815b836001600160a01b0316856001600160a01b0316336001600160a01b03167f342e7ff505a8a0364cd0dc2ff195c315e43bce86b204846ecd36913e117b109e84604051612f8f91815260200190565b60405180910390a4612fa2858583614713565b5050505050565b612fb16136cf565b6001600160a01b0382166000818152612022602052604090819020839055517fa027572bb55de556a0df93bd38c3871aaf311245c2cd34f0da045aa33a66dbc590612fff9084815260200190565b60405180910390a25050565b6001600160a01b03918216600090815261107a6020908152604080832093909416825291909152205460ff1690565b613052600080516020615f5683398151915233611709565b60405133907f42885193b8178d25fca25a38e6fcc93918501e91be06d85e0c8afb3bad95238090600090a2565b613087613796565b610c8754610c8654116130ad576040516331af695160e01b815260040160405180910390fd5b6130b6826132d5565b6130bf826132af565b6130c76141b2565b600082815261107660205260408120546001600160a01b03169080426130fd86600090815261107b602052604090206001015490565b61310791906159ca565b905060006131158686612944565b905060006131238287615a62565b9050828110156131415785935061313c8782600061339f565b613199565b61314b8784612944565b915061315782846159ca565b600088815261107b6020526040808220426001909101555191955088917f59f2fe866dd27a1c2d34115520888c3150365cbc931aab97fa88c4b9ab40b7959190a25b60006131aa89826114438842615a62565b905080896001600160a01b0316876001600160a01b0316600080516020615f3683398151915260405160405180910390a46131f6868a836040518060200160405280600081525061430f565b613213576040516303f8ea1560e41b815260040160405180910390fd5b505050505050505050565b6132266136cf565b600d610c8d55565b6132366136cf565b61201e8190556040518181527f4d816c1058de34c4241ba72c371fb3f2ea05147691b364f04d16bc967ae68a119060200160405180910390a150565b6000610e7e8261474f565b600081815261107b602052604081205490036132ac576040516378fe247360e01b815260040160405180910390fd5b50565b6132b881612818565b6132ac576040516306cfa7d760e11b815260040160405180910390fd5b600081815261107860205260408120546001600160a01b03161561331157600082815261107860205260409020546001600160a01b031661332b565b600082815261107660205260409020546001600160a01b03165b9050613336336128dc565b15801561334a57506133488233613471565b155b801561336e5750600082815261107960205260409020546001600160a01b03163314155b8015613381575061337f813361300b565b155b156117885760405163e17c6d4560e01b815260040160405180910390fd5b6133a88361327d565b600083815261107b602052604090206001015481156133f557428111156133eb576133d38382615a62565b600085815261107b6020526040902060010155613413565b6133d38342615a62565b6133ff83826159ca565b600085815261107b60205260409020600101555b600084815261107b602090815260409182902060010154825190815290810185905283151581830152905185917f3c907806849e9204e0e26bb095dfe4b3071576c4323f766735c548211556d052919081900360600190a250505050565b600082815261107860205260408120546001600160a01b03838116911614806134d45750816001600160a01b03166134a884611abd565b6001600160a01b03161480156134d45750600083815261107860205260409020546001600160a01b0316155b156134e157506001610e7e565b506000610e7e565b6134f2816132af565b6134fa6141b2565b826001600160a01b031661350d82611abd565b6001600160a01b0316146135345760405163075fd2b160e01b815260040160405180910390fd5b6001600160a01b03821661355b57604051635963709b60e01b815260040160405180910390fd5b816001600160a01b0316836001600160a01b03160361358d57604051633fbd1a4960e01b815260040160405180910390fd5b6135a38161359c836000612944565b600061339f565b600081815261107b602052604090206135bb8361203f565b6000036135d95761107780549060006135d383615b40565b91905055505b6135e28261475a565b6135ec8284614860565b6135f582614905565b60008281526120206020908152604080832083905561201f9091528082208290555183916001600160a01b038087169290881691600080516020615f3683398151915291a4610c8f546001600160a01b0316156129eb57610c8f5460018201546040516375b37aef60e01b8152306004820152602481018590523360448201526001600160a01b038781166064830152868116608483015260a48201929092529116906375b37aef9060c401600060405180830381600087803b1580156136bb57600080fd5b505af1158015611d02573d6000803e3d6000fd5b6136e7600080516020615f56833981519152336124a7565b61370457604051632386d63160e21b815260040160405180910390fd5b565b6132ac8133614942565b61371a82826124a7565b6117885760008281526097602090815260408083206001600160a01b03851684529091529020805460ff191660011790556137523390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b610c8d54600d14613704576040516302eae03b60e61b815260040160405180910390fd5b60006001600160a01b0384166137e357604051635963709b60e01b815260040160405180910390fd5b610c8780549060006137f483615b40565b9091555050610c87546040805180820182528281526020808201868152600085815261107b90925292902090518155905160019091015590506138368461203f565b60000361385457611077805490600061384e83615b40565b91905055505b61385e8185614860565b6138688184614282565b60405181906001600160a01b03861690600090600080516020615f36833981519152908290a49392505050565b600082815261201f602052604090205481146138be57600082815261201f602052604090208190555b610c845460008381526120206020526040902054146138ec57610c8454600083815261202060205260409020555b6104b154600083815261202160205260409020546001600160a01b03908116911614611788576104b15460008381526120216020526040902080546001600160a01b0319166001600160a01b039092169190911790555050565b80821015611788576040516330005fb160e21b815260040160405180910390fd5b610c83546001600160a01b03163b15613a1057610c835460405163939d9f1f60e01b8152600481018490526001600160a01b0383811660248301529091169063939d9f1f90620493e090604401600060405180830381600088803b1580156139ce57600080fd5b5087f1935050505080156139e0575060015b61178857610c83546040513091600080516020615f1683398151915291612fff916001600160a01b031690615127565b610c83546040513091600080516020615f1683398151915291612fff916001600160a01b031690615127565b6104b1546001600160a01b031615613ac6576104b1546040516323b872dd60e01b81526001600160a01b03909116906323b872dd90613a8390859030908690600401615d63565b6020604051808303816000875af1158015613aa2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610efe9190615bd5565b80341015611788576040516306c3cddf60e41b815260040160405180910390fd5b610c83546000906001600160a01b03163b1561178857610c8360009054906101000a90046001600160a01b03166001600160a01b031663b0e21e8a6040518163ffffffff1660e01b8152600401602060405180830381865afa925050508015613b6d575060408051601f3d908101601f19168201909252613b6a91810190615a49565b60015b613b9d57610c83546040513091600080516020615f1683398151915291612fff916001600160a01b031690615127565b612710613baa8285615b59565b613bb49190615b78565b91508115610efe576104b154610c8354610efe916001600160a01b03908116911684614713565b61201e5415613704576104b15461201e54613c01916001600160a01b0316903390614713565b61201e546104b154604080519283526001600160a01b03909116602083015233917f522a883b471164223f18b50f326da8671372b64b4792eac0e63d447e714c3e3b910160405180910390a2565b6001600160a01b038116156132ac576120226020527fbed07da93ba22716a54f603f075ff3d6567a94916ac6d58738883fb4a4b47ea6546001600160a01b0382166000908152604090205415613cbb57506001600160a01b038116600090815261202260205260409020545b8015611788576104b154610c8554611788916001600160a01b031690849061271090613ce8908690615b59565b613cf29190615b78565b614713565b613d0182826124a7565b156117885760008281526097602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b600082815261107b60205260408120600190810154908101613d9357604051630fed19c160e11b815260040160405180910390fd5b60008315613da15783613da6565b610c84545b90506000198103613dbb576000199250613de1565b42821115613dd457613dcd8183615a62565b9250613de1565b613dde8142615a62565b92505b600085815261107b6020526040908190206001018490555185907f3ca112768ff7861e008ace1c11570c52e404c043e585545b5957a1e20961dde390613e2a9086815260200190565b60405180910390a2610c90546001600160a01b031615613eb757610c90546040516202d72d60e71b81526004810187905233602482015260448101859052606481018490526001600160a01b039091169063016b968090608401600060405180830381600087803b158015613e9e57600080fd5b505af1158015613eb2573d6000803e3d6000fd5b505050505b505092915050565b6000613eca83611abd565b600084815261107b60205260409020426001909101559050336001600160a01b0316816001600160a01b0316847f0a7068a9989857441c039a14a42b67ed71dd1fcfe5a9b17cc87b252e47bce52885604051613f2891815260200190565b60405180910390a48115613f4e576104b154613f4e906001600160a01b03168284614713565b60008381526120206020908152604080832083905561201f909152812055610c8a546001600160a01b031615610efe57610c8a5460405163b499b6c560e01b81526001600160a01b039091169063b499b6c590613fb390339085908790600401615d63565b600060405180830381600087803b158015613fcd57600080fd5b505af1158015613fe1573d6000803e3d6000fd5b50505050505050565b6001600160a01b03163b151590565b614002816141eb565b6104b180546001600160a01b0319166001600160a01b0392909216919091179055565b610c8380546001600160a01b03191633179055610c84839055610c85829055610c86819055614052600d90565b61ffff16610c8d5550506001610c8e555050565b61406e61499b565b61407b6114638383614fb4565b50611788635b5e139f60e01b614133565b61370463780e9d6360e01b614133565b6140b4600080516020615f5683398151915280614a06565b6140da600080516020615ef6833981519152600080516020615f56833981519152614a06565b6140e3816128dc565b6140ff576140ff600080516020615f5683398151915282614a51565b614117600080516020615ef6833981519152826124a7565b6132ac576132ac600080516020615ef683398151915282614a51565b6001600160e01b0319808216900361418d5760405162461bcd60e51b815260206004820152601c60248201527f4552433136353a20696e76616c696420696e74657266616365206964000000006044820152606401611775565b6001600160e01b0319166000908152606560205260409020805460ff19166001179055565b61271061240754101580156141cd57506141cb336128dc565b155b15613704576040516323f21a3d60e21b815260040160405180910390fd5b6001600160a01b0381161580159061426457506000816001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561423e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906142629190615a49565b105b156132ac5760405163684cae7960e11b815260040160405180910390fd5b600082815261107860205260409020546001600160a01b038281169116146117885760008281526110786020526040902080546001600160a01b0319166001600160a01b0383161790556142d582614905565b6040516001600160a01b0382169083907f9d2895c45a420624de863a2f437b022d879f457bf7a829044055a10c5a6fd5e390600090a35050565b6000614323846001600160a01b0316613fea565b61432f575060016143be565b604051630a85bd0160e11b81526000906001600160a01b0386169063150b7a02906143649033908a9089908990600401615d87565b6020604051808303816000875af1158015614383573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906143a79190615dba565b6001600160e01b031916630a85bd0160e11b149150505b949350505050565b604080518082018252601081526f181899199a1a9b1b9c1cb0b131b232b360811b60208201528151602a80825260608281019094526001600160a01b0385169291600091602082018180368337019050509050600360fc1b8160008151811061443157614431615a7a565b60200101906001600160f81b031916908160001a905350600f60fb1b8160018151811061446057614460615a7a565b60200101906001600160f81b031916908160001a90535060005b60148110156145a8578260048561449284600c615a62565b602081106144a2576144a2615a7a565b1a60f81b6001600160f81b031916901c60f81c60ff16815181106144c8576144c8615a7a565b01602001516001600160f81b031916826144e3836002615b59565b6144ee906002615a62565b815181106144fe576144fe615a7a565b60200101906001600160f81b031916908160001a905350828461452283600c615a62565b6020811061453257614532615a7a565b825191901a600f1690811061454957614549615a7a565b01602001516001600160f81b03191682614564836002615b59565b61456f906003615a62565b8151811061457f5761457f615a7a565b60200101906001600160f81b031916908160001a905350806145a081615b40565b91505061447a565b50949350505050565b60608160008190036145dc5750506040805180820190915260018152600360fc1b6020820152919050565b8260005b811561460657806145f081615b40565b91506145ff9050600a83615b78565b91506145e0565b6000816001600160401b038111156146205761462061517c565b6040519080825280601f01601f19166020018201604052801561464a576020820181803683370190505b509050815b84156146d7576146606001826159ca565b9050600061466f600a87615b78565b61467a90600a615b59565b61468490876159ca565b61468f906030615dd7565b905060008160f81b9050808484815181106146ac576146ac615a7a565b60200101906001600160f81b031916908160001a9053506146ce600a88615b78565b9650505061464f565b5095945050505050565b6060848484846040516020016146fa9493929190615dfc565b6040516020818303038152906040529050949350505050565b8015610efe576001600160a01b03831661473a57610efe6001600160a01b03831682614a5b565b826129eb6001600160a01b0382168484614b71565b6000610e7e82614bc3565b600081815261107660205260408120546001600160a01b031690600161477f8361203f565b61478991906159ca565b600084815261107d60205260409020549091508082146147df576001600160a01b038316600090815261107c60209081526040808320858452825280832054848452818420819055835261107d90915290208190555b6001600160a01b038316600090815261107c6020908152604080832085845290915281205561480d8361203f565b60010361482b57611077805490600061482583615e53565b91905055505b6001600160a01b038316600090815261107e602052604081208054600192906148559084906159ca565b909155505050505050565b600061486b8261203f565b9050610c8e54811061489057604051630bf6c32360e11b815260040160405180910390fd5b600083815261107d602090815260408083208490556001600160a01b03851680845261107c83528184208585528352818420879055868452611076835281842080546001600160a01b03191682179055835261107e90915281208054600192906148fb908490615a62565b9091555050505050565b600081815261107960205260409020546001600160a01b0316156132ac5760009081526110796020526040902080546001600160a01b0319169055565b61494c82826124a7565b6117885761495981614be8565b614964836020614bfa565b604051602001614975929190615e6a565b60408051601f198184030181529082905262461bcd60e51b8252611775916004016150fb565b600054610100900460ff166137045760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608401611775565b600082815260976020526040808220600101805490849055905190918391839186917fbd79b86ffe0ab8e8776151514217cd7cacd52c909f66475c3af44e129f0b00ff9190a4505050565b6117888282613710565b80471015614aab5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e63650000006044820152606401611775565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114614af8576040519150601f19603f3d011682016040523d82523d6000602084013e614afd565b606091505b5050905080610efe5760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c20726044820152791958da5c1a595b9d081b585e481a185d99481c995d995c9d195960321b6064820152608401611775565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052610efe908490614d95565b60006001600160e01b03198216637965db0b60e01b1480610e7e5750610e7e82614e67565b6060610e7e6001600160a01b03831660145b60606000614c09836002615b59565b614c14906002615a62565b6001600160401b03811115614c2b57614c2b61517c565b6040519080825280601f01601f191660200182016040528015614c55576020820181803683370190505b509050600360fc1b81600081518110614c7057614c70615a7a565b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110614c9f57614c9f615a7a565b60200101906001600160f81b031916908160001a9053506000614cc3846002615b59565b614cce906001615a62565b90505b6001811115614d46576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110614d0257614d02615a7a565b1a60f81b828281518110614d1857614d18615a7a565b60200101906001600160f81b031916908160001a90535060049490941c93614d3f81615e53565b9050614cd1565b5083156110ef5760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401611775565b6000614dea826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316614ea39092919063ffffffff16565b805190915015610efe5780806020019051810190614e089190615bd5565b610efe5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401611775565b60006301ffc9a760e01b6001600160e01b031983161480610e7e5750506001600160e01b03191660009081526065602052604090205460ff1690565b60606143be848460008585600080866001600160a01b03168587604051614eca9190615ed9565b60006040518083038185875af1925050503d8060008114614f07576040519150601f19603f3d011682016040523d82523d6000602084013e614f0c565b606091505b5091509150612af98783838760608315614f85578251600003614f7e57614f3285613fea565b614f7e5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401611775565b50816143be565b6143be8383815115614f9a5781518083602001fd5b8060405162461bcd60e51b815260040161177591906150fb565b828054614fc0906159e1565b90600052602060002090601f016020900481019282614fe25760008555615028565b82601f10614ffb5782800160ff19823516178555615028565b82800160010185558215615028579182015b8281111561502857823582559160200191906001019061500d565b5061193f9291505b8082111561193f5760008155600101615030565b6001600160e01b0319811681146132ac57600080fd5b60006020828403121561506c57600080fd5b81356110ef81615044565b60008060006060848603121561508c57600080fd5b505081359360208301359350604090920135919050565b60005b838110156150be5781810151838201526020016150a6565b838111156129eb5750506000910152565b600081518084526150e78160208601602086016150a3565b601f01601f19169290920160200192915050565b6020815260006110ef60208301846150cf565b60006020828403121561512057600080fd5b5035919050565b6001600160a01b0391909116815260200190565b6001600160a01b03811681146132ac57600080fd5b6000806040838503121561516357600080fd5b823561516e8161513b565b946020939093013593505050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b03811182821017156151ba576151ba61517c565b604052919050565b60006001600160401b038211156151db576151db61517c565b50601f01601f191660200190565b600082601f8301126151fa57600080fd5b813561520d615208826151c2565b615192565b81815284602083860101111561522257600080fd5b816020850160208301376000918101602001919091529392505050565b60008060006060848603121561525457600080fd5b833561525f8161513b565b9250602084013561526f8161513b565b915060408401356001600160401b0381111561528a57600080fd5b615296868287016151e9565b9150509250925092565b6000806000606084860312156152b557600080fd5b83356152c08161513b565b925060208401356152d08161513b565b929592945050506040919091013590565b6000602082840312156152f357600080fd5b81356110ef8161513b565b6000806040838503121561531157600080fd5b8235915060208301356153238161513b565b809150509250929050565b60006001600160401b038211156153475761534761517c565b5060051b60200190565b600082601f83011261536257600080fd5b813560206153726152088361532e565b82815260059290921b8401810191818101908684111561539157600080fd5b8286015b848110156153ac5780358352918301918301615395565b509695505050505050565b600082601f8301126153c857600080fd5b813560206153d86152088361532e565b82815260059290921b840181019181810190868411156153f757600080fd5b8286015b848110156153ac57803561540e8161513b565b83529183019183016153fb565b60008083601f84011261542d57600080fd5b5081356001600160401b0381111561544457600080fd5b6020830191508360208260051b850101111561545f57600080fd5b9250929050565b60008060008060008060a0878903121561547f57600080fd5b86356001600160401b038082111561549657600080fd5b6154a28a838b01615351565b975060208901359150808211156154b857600080fd5b6154c48a838b016153b7565b965060408901359150808211156154da57600080fd5b6154e68a838b016153b7565b955060608901359150808211156154fc57600080fd5b6155088a838b016153b7565b9450608089013591508082111561551e57600080fd5b5061552b89828a0161541b565b979a9699509497509295939492505050565b6020808252825182820181905260009190848201906040850190845b8181101561557557835183529284019291840191600101615559565b50909695505050505050565b6000806040838503121561559457600080fd5b50508035926020909101359150565b60008083601f8401126155b557600080fd5b5081356001600160401b038111156155cc57600080fd5b60208301915083602082850101111561545f57600080fd5b600080600080600080600060c0888a0312156155ff57600080fd5b873561560a8161513b565b96506020880135955060408801356156218161513b565b9450606088013593506080880135925060a08801356001600160401b0381111561564a57600080fd5b6156568a828b016155a3565b989b979a50959850939692959293505050565b600080600080600080600060e0888a03121561568457600080fd5b873561568f8161513b565b9650602088013561569f8161513b565b955060408801356156af8161513b565b945060608801356156bf8161513b565b935060808801356156cf8161513b565b925060a08801356156df8161513b565b915060c08801356156ef8161513b565b8091505092959891949750929550565b6000806000806000806060878903121561571857600080fd5b86356001600160401b038082111561572f57600080fd5b61573b8a838b0161541b565b9098509650602089013591508082111561575457600080fd5b6157608a838b0161541b565b9096509450604089013591508082111561551e57600080fd5b6000806020838503121561578c57600080fd5b82356001600160401b038111156157a257600080fd5b6157ae858286016155a3565b90969095509350505050565b80151581146132ac57600080fd5b600080604083850312156157db57600080fd5b82356157e68161513b565b91506020830135615323816157ba565b6000806000806080858703121561580c57600080fd5b84356158178161513b565b935060208501356158278161513b565b92506040850135915060608501356001600160401b0381111561584957600080fd5b615855878288016151e9565b91505092959194509250565b6000806000806000806060878903121561587a57600080fd5b86356001600160401b038082111561589157600080fd5b61589d8a838b016155a3565b909850965060208901359150808211156158b657600080fd5b6158c28a838b016155a3565b909650945060408901359150808211156158db57600080fd5b5061552b89828a016155a3565b60008060008060006080868803121561590057600080fd5b853594506020860135935060408601356159198161513b565b925060608601356001600160401b0381111561593457600080fd5b615940888289016155a3565b969995985093965092949392505050565b6000806040838503121561596457600080fd5b823561596f8161513b565b915060208301356153238161513b565b60008060006060848603121561599457600080fd5b833561599f8161513b565b95602085013595506040909401359392505050565b634e487b7160e01b600052601160045260246000fd5b6000828210156159dc576159dc6159b4565b500390565b600181811c908216806159f557607f821691505b6020821081036125bb57634e487b7160e01b600052602260045260246000fd5b6001600160a01b038581168252848116602083015283166040820152608060608201819052600090612c79908301846150cf565b600060208284031215615a5b57600080fd5b5051919050565b60008219821115615a7557615a756159b4565b500190565b634e487b7160e01b600052603260045260246000fd5b6000808335601e19843603018112615aa757600080fd5b8301803591506001600160401b03821115615ac157600080fd5b60200191503681900382131561545f57600080fd5b8881526001600160a01b03888116602083015287811660408301528616606082015260e06080820181905281018490526000610100858782850137600083870182015260a08301949094525060c0810191909152601f909201601f19169091010195945050505050565b600060018201615b5257615b526159b4565b5060010190565b6000816000190483118215151615615b7357615b736159b4565b500290565b600082615b9557634e487b7160e01b600052601260045260246000fd5b500490565b6001600160a01b039687168152948616602086015260408501939093526060840191909152909216608082015290151560a082015260c00190565b600060208284031215615be757600080fd5b81516110ef816157ba565b600061ffff83811690831681811015615c0d57615c0d6159b4565b039392505050565b600060208284031215615c2757600080fd5b81516001600160401b03811115615c3d57600080fd5b8201601f81018413615c4e57600080fd5b8051615c5c615208826151c2565b818152856020838501011115615c7157600080fd5b615c828260208301602086016150a3565b95945050505050565b8054600090600181811c9080831680615ca557607f831692505b60208084108203615cc657634e487b7160e01b600052602260045260246000fd5b83885260208801828015615ce15760018114615cf257615d1d565b60ff19871682528282019750615d1d565b60008981526020902060005b87811015615d1757815484820152908601908401615cfe565b83019850505b5050505050505092915050565b606081526000615d3d6060830186615c8b565b8281036020840152615d4f8186615c8b565b90508281036040840152612c798185615c8b565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090612c79908301846150cf565b600060208284031215615dcc57600080fd5b81516110ef81615044565b600060ff821660ff84168060ff03821115615df457615df46159b4565b019392505050565b60008551615e0e818460208a016150a3565b855190830190615e22818360208a016150a3565b8551910190615e358183602089016150a3565b8451910190615e488183602088016150a3565b019695505050505050565b600081615e6257615e626159b4565b506000190190565b76020b1b1b2b9b9a1b7b73a3937b61d1030b1b1b7bab73a1604d1b815260008351615e9c8160178501602088016150a3565b7001034b99036b4b9b9b4b733903937b6329607d1b6017918401918201528351615ecd8160288401602088016150a3565b01602801949350505050565b60008251615eeb8184602087016150a3565b919091019291505056feb309c40027c81d382c3b58d8de24207a34b27e1db369b1434e4a11311f154b5e6b18946261693dfd6c760d986b28ad2238b5b0267f8e5b6bc40a2f998e2f20acddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efb89cdd26cddd51301940bf2715f765b626b8a5a9e2681ac62dc83cc2db2530c0a264697066735822122072d9bd72f63c49d265df60994a48518eedda32e12e5b9d9db81509124d910da864736f6c634300080d0033
Deployed Bytecode
0x6080604052600436106104185760003560e01c806370a0823111610220578063b11d7ec111610124578063d32bfb6c116100b1578063d32bfb6c14610d40578063d52e4a1014610d60578063d547741f14610d76578063d813cc1914610d96578063d9caed1214610da9578063debe2b0d14610dc9578063e985e9c514610de9578063f0ba604014610e09578063f12c6b6e14610e1e578063f32e8b2414610e3e578063f5766b3914610e5357600080fd5b8063b11d7ec114610bf4578063b129694e14610c14578063b1a3b25d14610c35578063b88d4fde14610c55578063c23135dd14610c75578063c87b56dd14610ca3578063c907c3ec14610cc3578063d1b8759b14610ce4578063d1bbd49c14610d04578063d250348514610d2057600080fd5b806391d14854116101ad57806391d1485414610abb57806392ac98a514610adb57806393fd184414610afb57806395d89b4114610b125780639d76ea5814610b27578063a217fddf14610b48578063a22cb46514610b5d578063a2e4cd2e14610b7d578063a375cb0514610b9d578063a98d362314610bb4578063aae4b8f714610bd457600080fd5b806370a082311461098457806374b6c106146109a457806374cac47d146109bb5780637ec2a724146109db578063812eecd4146109fc57806381a3c94314610a1c5780638505fe9514610a3c5780638577a6d514610a5c5780638932a90d14610a7c5780638da5cb5b14610a9c57600080fd5b80632f54bf6e116103275780634d025fed116102b45780634d025fed146108185780634e2ce6d31461084f5780634f6ccce71461086657806350878a471461088657806354b249fb146108a6578063558b71e9146108d757806356e0d51f146108f75780636207a8da1461090e5780636352211e146109245780636d8ea5b4146109445780636eadde431461096457600080fd5b80632f54bf6e146106c75780632f745c59146106f7578063338189971461071757806336568abe14610737578063389f07e81461075757806339f4698614610778578063407dc5891461079857806342842e0e146107b857806342966c68146107d85780634cd38c1d146107f857600080fd5b806313af4035116103a557806313af40351461058757806318160ddd146105a7578063183767da146105bd578063217751bc146105d457806323b872dd146105f5578063248a9ca31461061557806326e9ca0714610645578063282478df146106665780632d33dd5b146106865780632f2ff15d146106a757600080fd5b806301ffc9a714610424578063068208cd1461045957806306fdde031461047b578063081812fc1461049d578063095ea7b3146104ca578063097ba333146104ea5780630c2db8d1146105185780630f15023b1461053857806310e569731461055957806311a4c03a1461057057600080fd5b3661041f57005b600080fd5b34801561043057600080fd5b5061044461043f36600461505a565b610e73565b60405190151581526020015b60405180910390f35b34801561046557600080fd5b50610479610474366004615077565b610e84565b005b34801561048757600080fd5b50610490610f03565b60405161045091906150fb565b3480156104a957600080fd5b506104bd6104b836600461510e565b610f92565b6040516104509190615127565b3480156104d657600080fd5b506104796104e5366004615150565b610fba565b3480156104f657600080fd5b5061050a61050536600461523f565b611055565b604051908152602001610450565b34801561052457600080fd5b506104796105333660046152a0565b6110f6565b34801561054457600080fd5b50610c83546104bd906001600160a01b031681565b34801561056557600080fd5b5061050a610c855481565b34801561057c57600080fd5b5061050a610c845481565b34801561059357600080fd5b506104796105a23660046152e1565b61114b565b3480156105b357600080fd5b50610c875461050a565b3480156105c957600080fd5b5061050a6124075481565b3480156105e057600080fd5b50610c8a546104bd906001600160a01b031681565b34801561060157600080fd5b506104796106103660046152a0565b6111dc565b34801561062157600080fd5b5061050a61063036600461510e565b60009081526097602052604090206001015490565b34801561065157600080fd5b50610c8b546104bd906001600160a01b031681565b34801561067257600080fd5b50610479610681366004615077565b61120d565b34801561069257600080fd5b50610c89546104bd906001600160a01b031681565b3480156106b357600080fd5b506104796106c23660046152fe565b6112b2565b3480156106d357600080fd5b506104446106e23660046152e1565b612bda546001600160a01b0390811691161490565b34801561070357600080fd5b5061050a610712366004615150565b6112d7565b61072a610725366004615466565b61132b565b604051610450919061553d565b34801561074357600080fd5b506104796107523660046152fe565b611709565b34801561076357600080fd5b50610c8f546104bd906001600160a01b031681565b34801561078457600080fd5b50610479610793366004615581565b61178c565b3480156107a457600080fd5b506104796107b3366004615150565b6117da565b3480156107c457600080fd5b506104796107d33660046152a0565b611825565b3480156107e457600080fd5b506104796107f336600461510e565b611840565b34801561080457600080fd5b50610479610813366004615581565b6118b6565b34801561082457600080fd5b506104bd61083336600461510e565b611078602052600090815260409020546001600160a01b031681565b34801561085b57600080fd5b5061050a610c8d5481565b34801561087257600080fd5b5061050a61088136600461510e565b61191a565b34801561089257600080fd5b506104446108a13660046152fe565b611943565b3480156108b257600080fd5b5061050a6108c136600461510e565b600090815261107b602052604090206001015490565b3480156108e357600080fd5b506104796108f2366004615581565b611a99565b34801561090357600080fd5b5061050a6127f05481565b34801561091a57600080fd5b5061201e5461050a565b34801561093057600080fd5b506104bd61093f36600461510e565b611abd565b34801561095057600080fd5b5061044461095f3660046152e1565b611ad9565b34801561097057600080fd5b5061047961097f3660046155e4565b611b8d565b34801561099057600080fd5b5061050a61099f3660046152e1565b611d0c565b3480156109b057600080fd5b5061050a610c865481565b3480156109c757600080fd5b506104796109d6366004615669565b611d5e565b3480156109e757600080fd5b50610c8c546104bd906001600160a01b031681565b348015610a0857600080fd5b5061050a610a173660046152e1565b61203f565b348015610a2857600080fd5b5061072a610a373660046156ff565b612085565b348015610a4857600080fd5b50610479610a573660046152fe565b6122f4565b348015610a6857600080fd5b50610479610a7736600461510e565b61235b565b348015610a8857600080fd5b50610479610a97366004615779565b61239c565b348015610aa857600080fd5b50612bda546001600160a01b03166104bd565b348015610ac757600080fd5b50610444610ad63660046152fe565b6124a7565b348015610ae757600080fd5b5061050a610af636600461510e565b6124d2565b348015610b0757600080fd5b5061050a6110775481565b348015610b1e57600080fd5b506104906125c1565b348015610b3357600080fd5b506104b1546104bd906001600160a01b031681565b348015610b5457600080fd5b5061050a600081565b348015610b6957600080fd5b50610479610b783660046157c8565b6126ec565b348015610b8957600080fd5b50610479610b983660046152fe565b61278a565b348015610ba957600080fd5b5061050a6127f15481565b348015610bc057600080fd5b50610444610bcf36600461510e565b612818565b348015610be057600080fd5b50610444610bef3660046152e1565b6128dc565b348015610c0057600080fd5b50610479610c0f3660046152fe565b6128f6565b348015610c2057600080fd5b50610c91546104bd906001600160a01b031681565b348015610c4157600080fd5b5061050a610c50366004615581565b612944565b348015610c6157600080fd5b50610479610c703660046157f6565b6129b7565b348015610c8157600080fd5b5061050a610c903660046152e1565b6120226020526000908152604090205481565b348015610caf57600080fd5b50610490610cbe36600461510e565b6129f1565b348015610ccf57600080fd5b50610c90546104bd906001600160a01b031681565b348015610cf057600080fd5b50610479610cff366004615861565b612c83565b348015610d1057600080fd5b50604051600d8152602001610450565b348015610d2c57600080fd5b50610479610d3b3660046152e1565b612cfe565b348015610d4c57600080fd5b50610479610d5b36600461510e565b612d55565b348015610d6c57600080fd5b50610c8e5461050a565b348015610d8257600080fd5b50610479610d913660046152fe565b612d87565b610479610da43660046158e8565b612dac565b348015610db557600080fd5b50610479610dc43660046152a0565b612e73565b348015610dd557600080fd5b50610479610de4366004615150565b612fa9565b348015610df557600080fd5b50610444610e04366004615951565b61300b565b348015610e1557600080fd5b5061047961303a565b348015610e2a57600080fd5b50610479610e3936600461597f565b61307f565b348015610e4a57600080fd5b5061047961321e565b348015610e5f57600080fd5b50610479610e6e36600461510e565b61322e565b6000610e7e82613272565b92915050565b610e8d8361327d565b610e96836132af565b610e9f836132d5565b610ea88261327d565b600083815261107b6020526040902060010154610ec69042906159ca565b811115610ee6576040516310e88eed60e31b815260040160405180910390fd5b610ef28382600061339f565b610efe8282600161339f565b505050565b6114638054610f11906159e1565b80601f0160208091040260200160405190810160405280929190818152602001828054610f3d906159e1565b8015610f8a5780601f10610f5f57610100808354040283529160200191610f8a565b820191906000526020600020905b815481529060010190602001808311610f6d57829003601f168201915b505050505081565b6000610f9d8261327d565b50600090815261107960205260409020546001600160a01b031690565b610fc3816132d5565b6001600160a01b0382163303610fec57604051637899146560e11b815260040160405180910390fd5b60008181526110796020908152604080832080546001600160a01b0319166001600160a01b03878116918217909255611076909352818420549151859492909116917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591a45050565b610c89546000906001600160a01b0316156110e957610c895460405163221c1fd160e01b81526001600160a01b039091169063221c1fd1906110a1903390889088908890600401615a15565b602060405180830381865afa1580156110be573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110e29190615a49565b90506110ef565b50610c85545b9392505050565b6111008133613471565b61111d5760405163075fd2b160e01b815260040160405180910390fd5b6111288383836134e9565b60009081526110786020526040902080546001600160a01b031916331790555050565b6111536136cf565b6001600160a01b03811661117a576040516330c6e09f60e21b815260040160405180910390fd5b612bda80546001600160a01b038381166001600160a01b031983168117909355604080519190921680825260208201939093527f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0910160405180910390a15050565b6111e5816132d5565b60008181526110786020526040902080546001600160a01b0319169055610efe8383836134e9565b6112156136cf565b806000036112365760405163e03b033d60e01b815260040160405180910390fd5b610c875482101561125a57604051631d00cd6b60e01b815260040160405180910390fd5b610c8e819055610c84839055610c8682905560408051848152602081018490529081018290527f9a09448a3f24d3a01ccc67103c7cddbeea820176a18182cc83d0bce585f26a5b9060600160405180910390a1505050565b6000828152609760205260409020600101546112cd81613706565b610efe8383613710565b60006112e28361203f565b821061130157604051630471175760e11b815260040160405180910390fd5b506001600160a01b0391909116600090815261107c60209081526040808320938352929052205490565b6060611335613796565b610c86548651610c87546113499190615a62565b1115611368576040516331af695160e01b815260040160405180910390fd5b8451865114158061137b57508351865114155b15611399576040516376b3b52560e11b815260040160405180910390fd5b60008087516001600160401b038111156113b5576113b561517c565b6040519080825280602002602001820160405280156113de578160200160208202803683370190505b50905060005b88518110156116a057600089828151811061140157611401615a7a565b602002602001015190506114508189848151811061142157611421615a7a565b6020026020010151600019610c84541461144857610c84546114439042615a62565b6137ba565b6000196137ba565b83838151811061146257611462615a7a565b60200260200101818152505060006114ec828b858151811061148657611486615a7a565b60200260200101518a8a878181106114a0576114a0615a7a565b90506020028101906114b29190615a90565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061105592505050565b90506114f88186615a62565b945061151d84848151811061150f5761150f615a7a565b602002602001015182613895565b6104b1546001600160a01b031615611552576115528c848151811061154457611544615a7a565b602002602001015182613946565b611575818b858151811061156857611568615a7a565b6020026020010151613967565b6104b1546000906001600160a01b0316156115a9578c848151811061159c5761159c615a7a565b60200260200101516115ab565b345b610c89549091506001600160a01b03161561168a57610c895485516001600160a01b0390911690635e895f29908790879081106115ea576115ea615a7a565b602002602001015133868f898151811061160657611606615a7a565b60200260200101518e8e8b81811061162057611620615a7a565b90506020028101906116329190615a90565b89896040518963ffffffff1660e01b8152600401611657989796959493929190615ad6565b600060405180830381600087803b15801561167157600080fd5b505af1158015611685573d6000803e3d6000fd5b505050505b505050808061169890615b40565b9150506113e4565b506116ab3383613a3c565b6116b482613ae7565b6116bc613bdb565b60005b87518110156116fc576116ea8882815181106116dd576116dd615a7a565b6020026020010151613c4f565b806116f481615b40565b9150506116bf565b5098975050505050505050565b6001600160a01b038116331461177e5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b60648201526084015b60405180910390fd5b6117888282613cf7565b5050565b6117946136cf565b60408051838152602081018390527fd6867bc538320e67d7bdc35860c27c08486eb490b4fd9b820fff18fb28381d3c910160405180910390a16127f1919091556127f055565b600081815261107860205260409020546001600160a01b031633146118125760405163075fd2b160e01b815260040160405180910390fd5b61178861181e82611abd565b83836134e9565b610efe838383604051806020016040528060008152506129b7565b6118498161327d565b611852816132d5565b600081815261107660205260408082205490518392916001600160a01b031690600080516020615f36833981519152908390a4600090815261107b6020908152604080832042600190910155611076909152902080546001600160a01b0319169055565b6118be613796565b6118c78261327d565b6118df600080516020615ef6833981519152336124a7565b1580156118f257506118f0336128dc565b155b1561191057604051631798fedb60e01b815260040160405180910390fd5b610efe8282613d5e565b6000610c8754821061193f57604051630471175760e11b815260040160405180910390fd5b5090565b60008281526120206020526040812054600019148061196c57506104b1546001600160a01b0316155b1561198a57604051636cd40e1160e11b815260040160405180910390fd5b6119ac61199684611abd565b8360405180602001604052806000815250611055565b600084815261201f602052604090205410806119d95750610c845460008481526120206020526040902054115b80611a0357506104b154600084815261202160205260409020546001600160a01b03908116911614155b15611a215760405163986739e760e01b815260040160405180910390fd5b6000612710610c8454612328611a379190615b59565b611a419190615b78565b610c8454600086815261107b6020526040902060010154611a6291906159ca565b611a6c9190615a62565b905080421015611a8f576040516360d8ec3360e11b815260040160405180910390fd5b5060019392505050565b611aa28261327d565b611aab826132af565b611ab36136cf565b6117888282613ebf565b600090815261107660205260409020546001600160a01b031690565b6000611ae482611d0c565b600003611b7a57610c8b546001600160a01b031615611b7a57610c8b5460405163084fdbc760e31b81526001600160a01b039091169063427ede3890611b399030903390600090819089908290600401615b9a565b602060405180830381865afa158015611b56573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e7e9190615bd5565b6001611b8583611d0c565b101592915050565b600054610100900460ff1615808015611bad5750600054600160ff909116105b80611bce5750611bbc30613fea565b158015611bce575060005460ff166001145b611c315760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401611775565b6000805460ff191660011790558015611c54576000805461ff0019166101001790555b611c5d86613ff9565b611c6988888787614025565b611c738383614066565b611c7b61408c565b611c876103e86127f055565b611c908861409c565b612bda80546001600160a01b0319166001600160a01b038a16179055611cbc6380ac58cd60e01b614133565b8015611d02576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5050505050505050565b600080611d188361203f565b905060005b81811015611d5757611d32610bcf85836112d7565b15611d455782611d4181615b40565b9350505b80611d4f81615b40565b915050611d1d565b5050919050565b611d666136cf565b6001600160a01b03871615801590611d8d5750611d8b876001600160a01b0316613fea565b155b15611dae57604051636788e02b60e01b815260006004820152602401611775565b6001600160a01b03861615801590611dd55750611dd3866001600160a01b0316613fea565b155b15611df657604051636788e02b60e01b815260016004820152602401611775565b6001600160a01b03851615801590611e1d5750611e1b856001600160a01b0316613fea565b155b15611e3e57604051636788e02b60e01b815260026004820152602401611775565b6001600160a01b03841615801590611e655750611e63846001600160a01b0316613fea565b155b15611e8657604051636788e02b60e01b815260036004820152602401611775565b6001600160a01b03831615801590611ead5750611eab836001600160a01b0316613fea565b155b15611ecd57604051636788e02b60e01b8152600481810152602401611775565b6001600160a01b03821615801590611ef45750611ef2826001600160a01b0316613fea565b155b15611f1557604051636788e02b60e01b815260056004820152602401611775565b6001600160a01b03811615801590611f3c5750611f3a816001600160a01b0316613fea565b155b15611f5d57604051636788e02b60e01b815260066004820152602401611775565b610c8980546001600160a01b038981166001600160a01b03199283168117909355610c8a80548a83169084168117909155610c8c80548984169085168117909155610c8b80548b85169086168117909155610c8f80548a86169087168117909155610c9080548a87169088168117909155610c918054968a16969097168617909655604080519788526020880194909452928601526060850152608084015260a083019190915260c08201527f0a851288e37fa9a8bc562891998524e95c286fe84f693c1921e0fd0792171af69060e00160405180910390a150505050505050565b60006001600160a01b03821661206857604051635963709b60e01b815260040160405180910390fd5b506001600160a01b0316600090815261107e602052604090205490565b606061208f613796565b6120a7600080516020615ef6833981519152336124a7565b1580156120ba57506120b8336128dc565b155b156120d857604051631798fedb60e01b815260040160405180910390fd5b6000866001600160401b038111156120f2576120f261517c565b60405190808252806020026020018201604052801561211b578160200160208202803683370190505b50905060005b878110156122e85761219889898381811061213e5761213e615a7a565b905060200201602081019061215391906152e1565b86868481811061216557612165615a7a565b905060200201602081019061217a91906152e1565b89898581811061218c5761218c615a7a565b905060200201356137ba565b8282815181106121aa576121aa615a7a565b6020908102919091010152610c91546001600160a01b0316156122d657610c915482516001600160a01b03909116906348a254b8908490849081106121f1576121f1615a7a565b6020026020010151338c8c8681811061220c5761220c615a7a565b905060200201602081019061222191906152e1565b89898781811061223357612233615a7a565b905060200201602081019061224891906152e1565b8c8c8881811061225a5761225a615a7a565b6040516001600160e01b031960e08a901b16815260048101979097526001600160a01b039586166024880152938516604487015250921660648401526020020135608482015260a401600060405180830381600087803b1580156122bd57600080fd5b505af11580156122d1573d6000803e3d6000fd5b505050505b806122e081615b40565b915050612121565b50979650505050505050565b6122fc613796565b6123058261327d565b61230f8282611943565b5061231b826000613d5e565b50612329610c855482613967565b61233e61233583611abd565b610c8554613a3c565b612346613bdb565b61234f81613c4f565b611788610c8554613ae7565b6123636136cf565b6040518181527f0496ed1e61eb69727f9659a8e859288db4758ffb1f744d1c1424634f90a257f49060200160405180910390a161240755565b6123a86001600d615bf2565b61ffff16610c8d5414806123bd5750610c8d54155b6124065760405162461bcd60e51b815260206004820152601a60248201527914d0d211535057d5915494d253d397d393d517d0d3d4949150d560321b6044820152606401611775565b4660010361249d57600073e79b93f8e22676774f2a8dad469175ebd00029fa9050806001600160a01b031663ed9674bd6040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561246257600080fd5b505af1158015612476573d6000803e3d6000fd5b5050610c8380546001600160a01b0319166001600160a01b03949094169390931790925550505b5050600d610c8d55565b60009182526097602090815260408084206001600160a01b0393909316845291905290205460ff1690565b60006124dd826132af565b600019610c8454036124f2575050610c855490565b600082815261107b60205260408120600101546125109042906159ca565b9050610c84546127f154826125259190615a62565b1061253557610c85549150612555565b610c845481610c85546125489190615b59565b6125529190615b78565b91505b6127f15415806125745750610c84546127f1546125729083615a62565b105b156125bb5760006127106127f054610c85546125909190615b59565b61259a9190615b78565b9050808311156125b5576125ae81846159ca565b9250611d57565b60009250505b50919050565b606061146480546125d1906159e1565b905060000361265b57610c8360009054906101000a90046001600160a01b03166001600160a01b031663cec410526040518163ffffffff1660e01b8152600401600060405180830381865afa15801561262e573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526126569190810190615c15565b905090565b6114648054612669906159e1565b80601f0160208091040260200160405190810160405280929190818152602001828054612695906159e1565b80156126e25780601f106126b7576101008083540402835291602001916126e2565b820191906000526020600020905b8154815290600101906020018083116126c557829003601f168201915b5050505050905090565b6126f46141b2565b336001600160a01b0383160361271d57604051637899146560e11b815260040160405180910390fd5b33600081815261107a602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b6127926136cf565b61279b816141eb565b610c8580546104b18054928590556001600160a01b031983166001600160a01b0385811691821790925560408051848152602081018890529290941693820184905260608201529091907f3615065ccf48367ac483ac86701248e2e5ff55bdd9be845007d34a3b68d719d49060800160405180910390a150505050565b600081815261107b6020526040812060010154610c8b5442909111906001600160a01b031615610e7e57610c8b54600084815261107b60209081526040808320600101546110769092529182902054915163084fdbc760e31b81526001600160a01b039384169363427ede389361289b93309333938b9316908990600401615b9a565b602060405180830381865afa1580156128b8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110ef9190615bd5565b6000610e7e600080516020615f56833981519152836124a7565b6128ff8261327d565b6129098233613471565b15801561291c575061291a336128dc565b155b1561293a5760405163866c2fa760e01b815260040160405180910390fd5b6117888282614282565b600061294f8361327d565b600083815261107b602052604090206001015442811015612974576000915050610e7e565b60008360000361298f5761298842836159ca565b9050612992565b50825b61271061240754826129a49190615b59565b6129ae9190615b78565b92505050610e7e565b6129c28484846111dc565b6129ce8484848461430f565b6129eb576040516303f8ea1560e41b815260040160405180910390fd5b50505050565b606080806000612a00306143c6565b905060608515612a1a57612a13866145b1565b9250612a2d565b6040518060200160405280600081525092505b610c8c546001600160a01b031615612b0457600086815261107b6020526040902060010154610c8c546001600160a01b031663988b93ad3033612a6f8b611abd565b60405160e085901b6001600160e01b03191681526001600160a01b03938416600482015291831660248301529091166044820152606481018a90526084810184905260a401600060405180830381865afa158015612ad1573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052612af99190810190615c15565b979650505050505050565b6114658054612b12906159e1565b9050600003612bba57610c8360009054906101000a90046001600160a01b03166001600160a01b031663a998e9fb6040518163ffffffff1660e01b8152600401600060405180830381865afa158015612b6f573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052612b979190810190615c15565b9350604051806040016040528060018152602001602f60f81b8152509050612c6d565b6114658054612bc8906159e1565b80601f0160208091040260200160405190810160405280929190818152602001828054612bf4906159e1565b8015612c415780601f10612c1657610100808354040283529160200191612c41565b820191906000526020600020905b815481529060010190602001808311612c2457829003601f168201915b505050505093506040518060200160405280600081525090506040518060200160405280600081525091505b612c79848383866146e1565b9695505050505050565b612c8b6136cf565b612c986114638787614fb4565b50612ca66114648585614fb4565b50612cb46114658383614fb4565b507f1e6d6a19e45ae156dcf4155bc83cf8f59e98d536000998f0e95f4cd330ecfb3e611463611464611465604051612cee93929190615d2a565b60405180910390a1505050505050565b612d066136cf565b612d1e600080516020615f56833981519152826112b2565b6040516001600160a01b038216907f91d5c045d5bd98bf59a379b259ebca05b93bf79af1845fdf87e3172385d4c7f790600090a250565b612d5e8161327d565b612d67816132af565b612d70816132d5565b6000612d7b826124d2565b90506117888282613ebf565b600082815260976020526040902060010154612da281613706565b610efe8383613cf7565b612db4613796565b612dbd8461327d565b612dc8846000613d5e565b506000612e14612dd786611abd565b8585858080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061105592505050565b6104b1549091506001600160a01b031615612e3357612e338682613946565b612e3d8185613967565b612e473382613a3c565b612e518582613895565b612e59613bdb565b612e6284613c4f565b612e6b81613ae7565b505050505050565b612e7b6136cf565b60006001600160a01b038416612e92575047612f02565b6040516370a0823160e01b81526001600160a01b038516906370a0823190612ebe903090600401615127565b602060405180830381865afa158015612edb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612eff9190615a49565b90505b6000821580612f1057508183115b15612f3d5760008211612f36576040516303e09bb960e31b815260040160405180910390fd5b5080612f40565b50815b836001600160a01b0316856001600160a01b0316336001600160a01b03167f342e7ff505a8a0364cd0dc2ff195c315e43bce86b204846ecd36913e117b109e84604051612f8f91815260200190565b60405180910390a4612fa2858583614713565b5050505050565b612fb16136cf565b6001600160a01b0382166000818152612022602052604090819020839055517fa027572bb55de556a0df93bd38c3871aaf311245c2cd34f0da045aa33a66dbc590612fff9084815260200190565b60405180910390a25050565b6001600160a01b03918216600090815261107a6020908152604080832093909416825291909152205460ff1690565b613052600080516020615f5683398151915233611709565b60405133907f42885193b8178d25fca25a38e6fcc93918501e91be06d85e0c8afb3bad95238090600090a2565b613087613796565b610c8754610c8654116130ad576040516331af695160e01b815260040160405180910390fd5b6130b6826132d5565b6130bf826132af565b6130c76141b2565b600082815261107660205260408120546001600160a01b03169080426130fd86600090815261107b602052604090206001015490565b61310791906159ca565b905060006131158686612944565b905060006131238287615a62565b9050828110156131415785935061313c8782600061339f565b613199565b61314b8784612944565b915061315782846159ca565b600088815261107b6020526040808220426001909101555191955088917f59f2fe866dd27a1c2d34115520888c3150365cbc931aab97fa88c4b9ab40b7959190a25b60006131aa89826114438842615a62565b905080896001600160a01b0316876001600160a01b0316600080516020615f3683398151915260405160405180910390a46131f6868a836040518060200160405280600081525061430f565b613213576040516303f8ea1560e41b815260040160405180910390fd5b505050505050505050565b6132266136cf565b600d610c8d55565b6132366136cf565b61201e8190556040518181527f4d816c1058de34c4241ba72c371fb3f2ea05147691b364f04d16bc967ae68a119060200160405180910390a150565b6000610e7e8261474f565b600081815261107b602052604081205490036132ac576040516378fe247360e01b815260040160405180910390fd5b50565b6132b881612818565b6132ac576040516306cfa7d760e11b815260040160405180910390fd5b600081815261107860205260408120546001600160a01b03161561331157600082815261107860205260409020546001600160a01b031661332b565b600082815261107660205260409020546001600160a01b03165b9050613336336128dc565b15801561334a57506133488233613471565b155b801561336e5750600082815261107960205260409020546001600160a01b03163314155b8015613381575061337f813361300b565b155b156117885760405163e17c6d4560e01b815260040160405180910390fd5b6133a88361327d565b600083815261107b602052604090206001015481156133f557428111156133eb576133d38382615a62565b600085815261107b6020526040902060010155613413565b6133d38342615a62565b6133ff83826159ca565b600085815261107b60205260409020600101555b600084815261107b602090815260409182902060010154825190815290810185905283151581830152905185917f3c907806849e9204e0e26bb095dfe4b3071576c4323f766735c548211556d052919081900360600190a250505050565b600082815261107860205260408120546001600160a01b03838116911614806134d45750816001600160a01b03166134a884611abd565b6001600160a01b03161480156134d45750600083815261107860205260409020546001600160a01b0316155b156134e157506001610e7e565b506000610e7e565b6134f2816132af565b6134fa6141b2565b826001600160a01b031661350d82611abd565b6001600160a01b0316146135345760405163075fd2b160e01b815260040160405180910390fd5b6001600160a01b03821661355b57604051635963709b60e01b815260040160405180910390fd5b816001600160a01b0316836001600160a01b03160361358d57604051633fbd1a4960e01b815260040160405180910390fd5b6135a38161359c836000612944565b600061339f565b600081815261107b602052604090206135bb8361203f565b6000036135d95761107780549060006135d383615b40565b91905055505b6135e28261475a565b6135ec8284614860565b6135f582614905565b60008281526120206020908152604080832083905561201f9091528082208290555183916001600160a01b038087169290881691600080516020615f3683398151915291a4610c8f546001600160a01b0316156129eb57610c8f5460018201546040516375b37aef60e01b8152306004820152602481018590523360448201526001600160a01b038781166064830152868116608483015260a48201929092529116906375b37aef9060c401600060405180830381600087803b1580156136bb57600080fd5b505af1158015611d02573d6000803e3d6000fd5b6136e7600080516020615f56833981519152336124a7565b61370457604051632386d63160e21b815260040160405180910390fd5b565b6132ac8133614942565b61371a82826124a7565b6117885760008281526097602090815260408083206001600160a01b03851684529091529020805460ff191660011790556137523390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b610c8d54600d14613704576040516302eae03b60e61b815260040160405180910390fd5b60006001600160a01b0384166137e357604051635963709b60e01b815260040160405180910390fd5b610c8780549060006137f483615b40565b9091555050610c87546040805180820182528281526020808201868152600085815261107b90925292902090518155905160019091015590506138368461203f565b60000361385457611077805490600061384e83615b40565b91905055505b61385e8185614860565b6138688184614282565b60405181906001600160a01b03861690600090600080516020615f36833981519152908290a49392505050565b600082815261201f602052604090205481146138be57600082815261201f602052604090208190555b610c845460008381526120206020526040902054146138ec57610c8454600083815261202060205260409020555b6104b154600083815261202160205260409020546001600160a01b03908116911614611788576104b15460008381526120216020526040902080546001600160a01b0319166001600160a01b039092169190911790555050565b80821015611788576040516330005fb160e21b815260040160405180910390fd5b610c83546001600160a01b03163b15613a1057610c835460405163939d9f1f60e01b8152600481018490526001600160a01b0383811660248301529091169063939d9f1f90620493e090604401600060405180830381600088803b1580156139ce57600080fd5b5087f1935050505080156139e0575060015b61178857610c83546040513091600080516020615f1683398151915291612fff916001600160a01b031690615127565b610c83546040513091600080516020615f1683398151915291612fff916001600160a01b031690615127565b6104b1546001600160a01b031615613ac6576104b1546040516323b872dd60e01b81526001600160a01b03909116906323b872dd90613a8390859030908690600401615d63565b6020604051808303816000875af1158015613aa2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610efe9190615bd5565b80341015611788576040516306c3cddf60e41b815260040160405180910390fd5b610c83546000906001600160a01b03163b1561178857610c8360009054906101000a90046001600160a01b03166001600160a01b031663b0e21e8a6040518163ffffffff1660e01b8152600401602060405180830381865afa925050508015613b6d575060408051601f3d908101601f19168201909252613b6a91810190615a49565b60015b613b9d57610c83546040513091600080516020615f1683398151915291612fff916001600160a01b031690615127565b612710613baa8285615b59565b613bb49190615b78565b91508115610efe576104b154610c8354610efe916001600160a01b03908116911684614713565b61201e5415613704576104b15461201e54613c01916001600160a01b0316903390614713565b61201e546104b154604080519283526001600160a01b03909116602083015233917f522a883b471164223f18b50f326da8671372b64b4792eac0e63d447e714c3e3b910160405180910390a2565b6001600160a01b038116156132ac576120226020527fbed07da93ba22716a54f603f075ff3d6567a94916ac6d58738883fb4a4b47ea6546001600160a01b0382166000908152604090205415613cbb57506001600160a01b038116600090815261202260205260409020545b8015611788576104b154610c8554611788916001600160a01b031690849061271090613ce8908690615b59565b613cf29190615b78565b614713565b613d0182826124a7565b156117885760008281526097602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b600082815261107b60205260408120600190810154908101613d9357604051630fed19c160e11b815260040160405180910390fd5b60008315613da15783613da6565b610c84545b90506000198103613dbb576000199250613de1565b42821115613dd457613dcd8183615a62565b9250613de1565b613dde8142615a62565b92505b600085815261107b6020526040908190206001018490555185907f3ca112768ff7861e008ace1c11570c52e404c043e585545b5957a1e20961dde390613e2a9086815260200190565b60405180910390a2610c90546001600160a01b031615613eb757610c90546040516202d72d60e71b81526004810187905233602482015260448101859052606481018490526001600160a01b039091169063016b968090608401600060405180830381600087803b158015613e9e57600080fd5b505af1158015613eb2573d6000803e3d6000fd5b505050505b505092915050565b6000613eca83611abd565b600084815261107b60205260409020426001909101559050336001600160a01b0316816001600160a01b0316847f0a7068a9989857441c039a14a42b67ed71dd1fcfe5a9b17cc87b252e47bce52885604051613f2891815260200190565b60405180910390a48115613f4e576104b154613f4e906001600160a01b03168284614713565b60008381526120206020908152604080832083905561201f909152812055610c8a546001600160a01b031615610efe57610c8a5460405163b499b6c560e01b81526001600160a01b039091169063b499b6c590613fb390339085908790600401615d63565b600060405180830381600087803b158015613fcd57600080fd5b505af1158015613fe1573d6000803e3d6000fd5b50505050505050565b6001600160a01b03163b151590565b614002816141eb565b6104b180546001600160a01b0319166001600160a01b0392909216919091179055565b610c8380546001600160a01b03191633179055610c84839055610c85829055610c86819055614052600d90565b61ffff16610c8d5550506001610c8e555050565b61406e61499b565b61407b6114638383614fb4565b50611788635b5e139f60e01b614133565b61370463780e9d6360e01b614133565b6140b4600080516020615f5683398151915280614a06565b6140da600080516020615ef6833981519152600080516020615f56833981519152614a06565b6140e3816128dc565b6140ff576140ff600080516020615f5683398151915282614a51565b614117600080516020615ef6833981519152826124a7565b6132ac576132ac600080516020615ef683398151915282614a51565b6001600160e01b0319808216900361418d5760405162461bcd60e51b815260206004820152601c60248201527f4552433136353a20696e76616c696420696e74657266616365206964000000006044820152606401611775565b6001600160e01b0319166000908152606560205260409020805460ff19166001179055565b61271061240754101580156141cd57506141cb336128dc565b155b15613704576040516323f21a3d60e21b815260040160405180910390fd5b6001600160a01b0381161580159061426457506000816001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561423e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906142629190615a49565b105b156132ac5760405163684cae7960e11b815260040160405180910390fd5b600082815261107860205260409020546001600160a01b038281169116146117885760008281526110786020526040902080546001600160a01b0319166001600160a01b0383161790556142d582614905565b6040516001600160a01b0382169083907f9d2895c45a420624de863a2f437b022d879f457bf7a829044055a10c5a6fd5e390600090a35050565b6000614323846001600160a01b0316613fea565b61432f575060016143be565b604051630a85bd0160e11b81526000906001600160a01b0386169063150b7a02906143649033908a9089908990600401615d87565b6020604051808303816000875af1158015614383573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906143a79190615dba565b6001600160e01b031916630a85bd0160e11b149150505b949350505050565b604080518082018252601081526f181899199a1a9b1b9c1cb0b131b232b360811b60208201528151602a80825260608281019094526001600160a01b0385169291600091602082018180368337019050509050600360fc1b8160008151811061443157614431615a7a565b60200101906001600160f81b031916908160001a905350600f60fb1b8160018151811061446057614460615a7a565b60200101906001600160f81b031916908160001a90535060005b60148110156145a8578260048561449284600c615a62565b602081106144a2576144a2615a7a565b1a60f81b6001600160f81b031916901c60f81c60ff16815181106144c8576144c8615a7a565b01602001516001600160f81b031916826144e3836002615b59565b6144ee906002615a62565b815181106144fe576144fe615a7a565b60200101906001600160f81b031916908160001a905350828461452283600c615a62565b6020811061453257614532615a7a565b825191901a600f1690811061454957614549615a7a565b01602001516001600160f81b03191682614564836002615b59565b61456f906003615a62565b8151811061457f5761457f615a7a565b60200101906001600160f81b031916908160001a905350806145a081615b40565b91505061447a565b50949350505050565b60608160008190036145dc5750506040805180820190915260018152600360fc1b6020820152919050565b8260005b811561460657806145f081615b40565b91506145ff9050600a83615b78565b91506145e0565b6000816001600160401b038111156146205761462061517c565b6040519080825280601f01601f19166020018201604052801561464a576020820181803683370190505b509050815b84156146d7576146606001826159ca565b9050600061466f600a87615b78565b61467a90600a615b59565b61468490876159ca565b61468f906030615dd7565b905060008160f81b9050808484815181106146ac576146ac615a7a565b60200101906001600160f81b031916908160001a9053506146ce600a88615b78565b9650505061464f565b5095945050505050565b6060848484846040516020016146fa9493929190615dfc565b6040516020818303038152906040529050949350505050565b8015610efe576001600160a01b03831661473a57610efe6001600160a01b03831682614a5b565b826129eb6001600160a01b0382168484614b71565b6000610e7e82614bc3565b600081815261107660205260408120546001600160a01b031690600161477f8361203f565b61478991906159ca565b600084815261107d60205260409020549091508082146147df576001600160a01b038316600090815261107c60209081526040808320858452825280832054848452818420819055835261107d90915290208190555b6001600160a01b038316600090815261107c6020908152604080832085845290915281205561480d8361203f565b60010361482b57611077805490600061482583615e53565b91905055505b6001600160a01b038316600090815261107e602052604081208054600192906148559084906159ca565b909155505050505050565b600061486b8261203f565b9050610c8e54811061489057604051630bf6c32360e11b815260040160405180910390fd5b600083815261107d602090815260408083208490556001600160a01b03851680845261107c83528184208585528352818420879055868452611076835281842080546001600160a01b03191682179055835261107e90915281208054600192906148fb908490615a62565b9091555050505050565b600081815261107960205260409020546001600160a01b0316156132ac5760009081526110796020526040902080546001600160a01b0319169055565b61494c82826124a7565b6117885761495981614be8565b614964836020614bfa565b604051602001614975929190615e6a565b60408051601f198184030181529082905262461bcd60e51b8252611775916004016150fb565b600054610100900460ff166137045760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608401611775565b600082815260976020526040808220600101805490849055905190918391839186917fbd79b86ffe0ab8e8776151514217cd7cacd52c909f66475c3af44e129f0b00ff9190a4505050565b6117888282613710565b80471015614aab5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e63650000006044820152606401611775565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114614af8576040519150601f19603f3d011682016040523d82523d6000602084013e614afd565b606091505b5050905080610efe5760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c20726044820152791958da5c1a595b9d081b585e481a185d99481c995d995c9d195960321b6064820152608401611775565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052610efe908490614d95565b60006001600160e01b03198216637965db0b60e01b1480610e7e5750610e7e82614e67565b6060610e7e6001600160a01b03831660145b60606000614c09836002615b59565b614c14906002615a62565b6001600160401b03811115614c2b57614c2b61517c565b6040519080825280601f01601f191660200182016040528015614c55576020820181803683370190505b509050600360fc1b81600081518110614c7057614c70615a7a565b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110614c9f57614c9f615a7a565b60200101906001600160f81b031916908160001a9053506000614cc3846002615b59565b614cce906001615a62565b90505b6001811115614d46576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110614d0257614d02615a7a565b1a60f81b828281518110614d1857614d18615a7a565b60200101906001600160f81b031916908160001a90535060049490941c93614d3f81615e53565b9050614cd1565b5083156110ef5760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401611775565b6000614dea826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316614ea39092919063ffffffff16565b805190915015610efe5780806020019051810190614e089190615bd5565b610efe5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401611775565b60006301ffc9a760e01b6001600160e01b031983161480610e7e5750506001600160e01b03191660009081526065602052604090205460ff1690565b60606143be848460008585600080866001600160a01b03168587604051614eca9190615ed9565b60006040518083038185875af1925050503d8060008114614f07576040519150601f19603f3d011682016040523d82523d6000602084013e614f0c565b606091505b5091509150612af98783838760608315614f85578251600003614f7e57614f3285613fea565b614f7e5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401611775565b50816143be565b6143be8383815115614f9a5781518083602001fd5b8060405162461bcd60e51b815260040161177591906150fb565b828054614fc0906159e1565b90600052602060002090601f016020900481019282614fe25760008555615028565b82601f10614ffb5782800160ff19823516178555615028565b82800160010185558215615028579182015b8281111561502857823582559160200191906001019061500d565b5061193f9291505b8082111561193f5760008155600101615030565b6001600160e01b0319811681146132ac57600080fd5b60006020828403121561506c57600080fd5b81356110ef81615044565b60008060006060848603121561508c57600080fd5b505081359360208301359350604090920135919050565b60005b838110156150be5781810151838201526020016150a6565b838111156129eb5750506000910152565b600081518084526150e78160208601602086016150a3565b601f01601f19169290920160200192915050565b6020815260006110ef60208301846150cf565b60006020828403121561512057600080fd5b5035919050565b6001600160a01b0391909116815260200190565b6001600160a01b03811681146132ac57600080fd5b6000806040838503121561516357600080fd5b823561516e8161513b565b946020939093013593505050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b03811182821017156151ba576151ba61517c565b604052919050565b60006001600160401b038211156151db576151db61517c565b50601f01601f191660200190565b600082601f8301126151fa57600080fd5b813561520d615208826151c2565b615192565b81815284602083860101111561522257600080fd5b816020850160208301376000918101602001919091529392505050565b60008060006060848603121561525457600080fd5b833561525f8161513b565b9250602084013561526f8161513b565b915060408401356001600160401b0381111561528a57600080fd5b615296868287016151e9565b9150509250925092565b6000806000606084860312156152b557600080fd5b83356152c08161513b565b925060208401356152d08161513b565b929592945050506040919091013590565b6000602082840312156152f357600080fd5b81356110ef8161513b565b6000806040838503121561531157600080fd5b8235915060208301356153238161513b565b809150509250929050565b60006001600160401b038211156153475761534761517c565b5060051b60200190565b600082601f83011261536257600080fd5b813560206153726152088361532e565b82815260059290921b8401810191818101908684111561539157600080fd5b8286015b848110156153ac5780358352918301918301615395565b509695505050505050565b600082601f8301126153c857600080fd5b813560206153d86152088361532e565b82815260059290921b840181019181810190868411156153f757600080fd5b8286015b848110156153ac57803561540e8161513b565b83529183019183016153fb565b60008083601f84011261542d57600080fd5b5081356001600160401b0381111561544457600080fd5b6020830191508360208260051b850101111561545f57600080fd5b9250929050565b60008060008060008060a0878903121561547f57600080fd5b86356001600160401b038082111561549657600080fd5b6154a28a838b01615351565b975060208901359150808211156154b857600080fd5b6154c48a838b016153b7565b965060408901359150808211156154da57600080fd5b6154e68a838b016153b7565b955060608901359150808211156154fc57600080fd5b6155088a838b016153b7565b9450608089013591508082111561551e57600080fd5b5061552b89828a0161541b565b979a9699509497509295939492505050565b6020808252825182820181905260009190848201906040850190845b8181101561557557835183529284019291840191600101615559565b50909695505050505050565b6000806040838503121561559457600080fd5b50508035926020909101359150565b60008083601f8401126155b557600080fd5b5081356001600160401b038111156155cc57600080fd5b60208301915083602082850101111561545f57600080fd5b600080600080600080600060c0888a0312156155ff57600080fd5b873561560a8161513b565b96506020880135955060408801356156218161513b565b9450606088013593506080880135925060a08801356001600160401b0381111561564a57600080fd5b6156568a828b016155a3565b989b979a50959850939692959293505050565b600080600080600080600060e0888a03121561568457600080fd5b873561568f8161513b565b9650602088013561569f8161513b565b955060408801356156af8161513b565b945060608801356156bf8161513b565b935060808801356156cf8161513b565b925060a08801356156df8161513b565b915060c08801356156ef8161513b565b8091505092959891949750929550565b6000806000806000806060878903121561571857600080fd5b86356001600160401b038082111561572f57600080fd5b61573b8a838b0161541b565b9098509650602089013591508082111561575457600080fd5b6157608a838b0161541b565b9096509450604089013591508082111561551e57600080fd5b6000806020838503121561578c57600080fd5b82356001600160401b038111156157a257600080fd5b6157ae858286016155a3565b90969095509350505050565b80151581146132ac57600080fd5b600080604083850312156157db57600080fd5b82356157e68161513b565b91506020830135615323816157ba565b6000806000806080858703121561580c57600080fd5b84356158178161513b565b935060208501356158278161513b565b92506040850135915060608501356001600160401b0381111561584957600080fd5b615855878288016151e9565b91505092959194509250565b6000806000806000806060878903121561587a57600080fd5b86356001600160401b038082111561589157600080fd5b61589d8a838b016155a3565b909850965060208901359150808211156158b657600080fd5b6158c28a838b016155a3565b909650945060408901359150808211156158db57600080fd5b5061552b89828a016155a3565b60008060008060006080868803121561590057600080fd5b853594506020860135935060408601356159198161513b565b925060608601356001600160401b0381111561593457600080fd5b615940888289016155a3565b969995985093965092949392505050565b6000806040838503121561596457600080fd5b823561596f8161513b565b915060208301356153238161513b565b60008060006060848603121561599457600080fd5b833561599f8161513b565b95602085013595506040909401359392505050565b634e487b7160e01b600052601160045260246000fd5b6000828210156159dc576159dc6159b4565b500390565b600181811c908216806159f557607f821691505b6020821081036125bb57634e487b7160e01b600052602260045260246000fd5b6001600160a01b038581168252848116602083015283166040820152608060608201819052600090612c79908301846150cf565b600060208284031215615a5b57600080fd5b5051919050565b60008219821115615a7557615a756159b4565b500190565b634e487b7160e01b600052603260045260246000fd5b6000808335601e19843603018112615aa757600080fd5b8301803591506001600160401b03821115615ac157600080fd5b60200191503681900382131561545f57600080fd5b8881526001600160a01b03888116602083015287811660408301528616606082015260e06080820181905281018490526000610100858782850137600083870182015260a08301949094525060c0810191909152601f909201601f19169091010195945050505050565b600060018201615b5257615b526159b4565b5060010190565b6000816000190483118215151615615b7357615b736159b4565b500290565b600082615b9557634e487b7160e01b600052601260045260246000fd5b500490565b6001600160a01b039687168152948616602086015260408501939093526060840191909152909216608082015290151560a082015260c00190565b600060208284031215615be757600080fd5b81516110ef816157ba565b600061ffff83811690831681811015615c0d57615c0d6159b4565b039392505050565b600060208284031215615c2757600080fd5b81516001600160401b03811115615c3d57600080fd5b8201601f81018413615c4e57600080fd5b8051615c5c615208826151c2565b818152856020838501011115615c7157600080fd5b615c828260208301602086016150a3565b95945050505050565b8054600090600181811c9080831680615ca557607f831692505b60208084108203615cc657634e487b7160e01b600052602260045260246000fd5b83885260208801828015615ce15760018114615cf257615d1d565b60ff19871682528282019750615d1d565b60008981526020902060005b87811015615d1757815484820152908601908401615cfe565b83019850505b5050505050505092915050565b606081526000615d3d6060830186615c8b565b8281036020840152615d4f8186615c8b565b90508281036040840152612c798185615c8b565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090612c79908301846150cf565b600060208284031215615dcc57600080fd5b81516110ef81615044565b600060ff821660ff84168060ff03821115615df457615df46159b4565b019392505050565b60008551615e0e818460208a016150a3565b855190830190615e22818360208a016150a3565b8551910190615e358183602089016150a3565b8451910190615e488183602088016150a3565b019695505050505050565b600081615e6257615e626159b4565b506000190190565b76020b1b1b2b9b9a1b7b73a3937b61d1030b1b1b7bab73a1604d1b815260008351615e9c8160178501602088016150a3565b7001034b99036b4b9b9b4b733903937b6329607d1b6017918401918201528351615ecd8160288401602088016150a3565b01602801949350505050565b60008251615eeb8184602087016150a3565b919091019291505056feb309c40027c81d382c3b58d8de24207a34b27e1db369b1434e4a11311f154b5e6b18946261693dfd6c760d986b28ad2238b5b0267f8e5b6bc40a2f998e2f20acddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efb89cdd26cddd51301940bf2715f765b626b8a5a9e2681ac62dc83cc2db2530c0a264697066735822122072d9bd72f63c49d265df60994a48518eedda32e12e5b9d9db81509124d910da864736f6c634300080d0033
Loading...
Loading
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 34 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
Loading...
Loading
Loading...
Loading
Loading...
Loading
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.