Source Code
Overview
ETH Balance
0 ETH
Eth Value
$0.00View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
Loading...
Loading
Cross-Chain Transactions
Loading...
Loading
Contract Name:
PackageManager
Compiler Version
v0.8.18+commit.87f61d96
Contract Source Code (Solidity)
/**
*Submitted for verification at Etherscan.io on 2026-02-20
*/
// Sources flattened with hardhat v2.28.6 https://hardhat.org
// SPDX-License-Identifier: MIT
// File @openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol@v4.9.6
// Original license: SPDX_License_Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.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
*
* Furthermore, `isContract` will also return true if the target contract within
* the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
* which only has an effect at the end of a transaction.
* ====
*
* [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://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.8.0/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 Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(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);
}
}
}
// File @openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol@v4.9.6
// Original license: SPDX_License_Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/Initializable.sol)
pragma solidity ^0.8.2;
/**
* @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
* behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
* external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
* function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
*
* The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
* reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
* case an upgrade adds a module that needs to be initialized.
*
* For example:
*
* [.hljs-theme-light.nopadding]
* ```solidity
* contract MyToken is ERC20Upgradeable {
* function initialize() initializer public {
* __ERC20_init("MyToken", "MTK");
* }
* }
*
* contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
* function initializeV2() reinitializer(2) public {
* __ERC20Permit_init("MyToken");
* }
* }
* ```
*
* TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
* possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
*
* CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
* that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
*
* [CAUTION]
* ====
* Avoid leaving a contract uninitialized.
*
* An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
* contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
* the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
*
* [.hljs-theme-light.nopadding]
* ```
* /// @custom:oz-upgrades-unsafe-allow constructor
* constructor() {
* _disableInitializers();
* }
* ```
* ====
*/
abstract contract Initializable {
/**
* @dev 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;
}
}
// File @openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol@v4.9.6
// Original license: SPDX_License_Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.4) (utils/Context.sol)
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract ContextUpgradeable is Initializable {
function __Context_init() internal onlyInitializing {
}
function __Context_init_unchained() internal onlyInitializing {
}
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
/**
* @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;
}
// File @openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol@v4.9.6
// Original license: SPDX_License_Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)
pragma solidity ^0.8.0;
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
function __Ownable_init() internal onlyInitializing {
__Ownable_init_unchained();
}
function __Ownable_init_unchained() internal onlyInitializing {
_transferOwnership(_msgSender());
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
/**
* @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;
}
// File @openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol@v4.9.6
// Original license: SPDX_License_Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)
pragma solidity ^0.8.0;
/**
* @dev Contract module which allows children to implement an emergency stop
* mechanism that can be triggered by an authorized account.
*
* This module is used through inheritance. It will make available the
* modifiers `whenNotPaused` and `whenPaused`, which can be applied to
* the functions of your contract. Note that they will not be pausable by
* simply including this module, only once the modifiers are put in place.
*/
abstract contract PausableUpgradeable is Initializable, ContextUpgradeable {
/**
* @dev Emitted when the pause is triggered by `account`.
*/
event Paused(address account);
/**
* @dev Emitted when the pause is lifted by `account`.
*/
event Unpaused(address account);
bool private _paused;
/**
* @dev Initializes the contract in unpaused state.
*/
function __Pausable_init() internal onlyInitializing {
__Pausable_init_unchained();
}
function __Pausable_init_unchained() internal onlyInitializing {
_paused = false;
}
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*
* Requirements:
*
* - The contract must not be paused.
*/
modifier whenNotPaused() {
_requireNotPaused();
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*
* Requirements:
*
* - The contract must be paused.
*/
modifier whenPaused() {
_requirePaused();
_;
}
/**
* @dev Returns true if the contract is paused, and false otherwise.
*/
function paused() public view virtual returns (bool) {
return _paused;
}
/**
* @dev Throws if the contract is paused.
*/
function _requireNotPaused() internal view virtual {
require(!paused(), "Pausable: paused");
}
/**
* @dev Throws if the contract is not paused.
*/
function _requirePaused() internal view virtual {
require(paused(), "Pausable: not paused");
}
/**
* @dev Triggers stopped state.
*
* Requirements:
*
* - The contract must not be paused.
*/
function _pause() internal virtual whenNotPaused {
_paused = true;
emit Paused(_msgSender());
}
/**
* @dev Returns to normal state.
*
* Requirements:
*
* - The contract must be paused.
*/
function _unpause() internal virtual whenPaused {
_paused = false;
emit Unpaused(_msgSender());
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[49] private __gap;
}
// File @openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol@v4.9.6
// Original license: SPDX_License_Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol)
pragma solidity ^0.8.0;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuardUpgradeable is Initializable {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
function __ReentrancyGuard_init() internal onlyInitializing {
__ReentrancyGuard_init_unchained();
}
function __ReentrancyGuard_init_unchained() internal onlyInitializing {
_status = _NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
// On the first call to nonReentrant, _status will be _NOT_ENTERED
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
}
function _nonReentrantAfter() private {
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
/**
* @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
* `nonReentrant` function in the call stack.
*/
function _reentrancyGuardEntered() internal view returns (bool) {
return _status == _ENTERED;
}
/**
* @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;
}
// File @openzeppelin/contracts/utils/math/Math.sol@v4.9.6
// Original license: SPDX_License_Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol)
pragma solidity ^0.8.0;
/**
* @dev Standard math utilities missing in the Solidity language.
*/
library Math {
enum Rounding {
Down, // Toward negative infinity
Up, // Toward infinity
Zero // Toward zero
}
/**
* @dev Returns the largest of two numbers.
*/
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a > b ? a : b;
}
/**
* @dev Returns the smallest of two numbers.
*/
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two numbers. The result is rounded towards
* zero.
*/
function average(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b) / 2 can overflow.
return (a & b) + (a ^ b) / 2;
}
/**
* @dev Returns the ceiling of the division of two numbers.
*
* This differs from standard division with `/` in that it rounds up instead
* of rounding down.
*/
function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b - 1) / b can overflow on addition, so we distribute.
return a == 0 ? 0 : (a - 1) / b + 1;
}
/**
* @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
* @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)
* with further edits by Uniswap Labs also under MIT license.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {
unchecked {
// 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
// use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
// variables such that product = prod1 * 2^256 + prod0.
uint256 prod0; // Least significant 256 bits of the product
uint256 prod1; // Most significant 256 bits of the product
assembly {
let mm := mulmod(x, y, not(0))
prod0 := mul(x, y)
prod1 := sub(sub(mm, prod0), lt(mm, prod0))
}
// Handle non-overflow cases, 256 by 256 division.
if (prod1 == 0) {
// Solidity will revert if denominator == 0, unlike the div opcode on its own.
// The surrounding unchecked block does not change this fact.
// See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
return prod0 / denominator;
}
// Make sure the result is less than 2^256. Also prevents denominator == 0.
require(denominator > prod1, "Math: mulDiv overflow");
///////////////////////////////////////////////
// 512 by 256 division.
///////////////////////////////////////////////
// Make division exact by subtracting the remainder from [prod1 prod0].
uint256 remainder;
assembly {
// Compute remainder using mulmod.
remainder := mulmod(x, y, denominator)
// Subtract 256 bit number from 512 bit number.
prod1 := sub(prod1, gt(remainder, prod0))
prod0 := sub(prod0, remainder)
}
// Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.
// See https://cs.stackexchange.com/q/138556/92363.
// Does not overflow because the denominator cannot be zero at this stage in the function.
uint256 twos = denominator & (~denominator + 1);
assembly {
// Divide denominator by twos.
denominator := div(denominator, twos)
// Divide [prod1 prod0] by twos.
prod0 := div(prod0, twos)
// Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
twos := add(div(sub(0, twos), twos), 1)
}
// Shift in bits from prod1 into prod0.
prod0 |= prod1 * twos;
// Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
// that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
// four bits. That is, denominator * inv = 1 mod 2^4.
uint256 inverse = (3 * denominator) ^ 2;
// Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works
// in modular arithmetic, doubling the correct bits in each step.
inverse *= 2 - denominator * inverse; // inverse mod 2^8
inverse *= 2 - denominator * inverse; // inverse mod 2^16
inverse *= 2 - denominator * inverse; // inverse mod 2^32
inverse *= 2 - denominator * inverse; // inverse mod 2^64
inverse *= 2 - denominator * inverse; // inverse mod 2^128
inverse *= 2 - denominator * inverse; // inverse mod 2^256
// Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
// This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
// less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
// is no longer required.
result = prod0 * inverse;
return result;
}
}
/**
* @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {
uint256 result = mulDiv(x, y, denominator);
if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {
result += 1;
}
return result;
}
/**
* @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.
*
* Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
*/
function sqrt(uint256 a) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
// For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
//
// We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
// `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
//
// This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
// → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
// → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
//
// Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
uint256 result = 1 << (log2(a) >> 1);
// At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
// since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
// every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
// into the expected uint128 result.
unchecked {
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
return min(result, a / result);
}
}
/**
* @notice Calculates sqrt(a), following the selected rounding direction.
*/
function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = sqrt(a);
return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);
}
}
/**
* @dev Return the log in base 2, rounded down, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 128;
}
if (value >> 64 > 0) {
value >>= 64;
result += 64;
}
if (value >> 32 > 0) {
value >>= 32;
result += 32;
}
if (value >> 16 > 0) {
value >>= 16;
result += 16;
}
if (value >> 8 > 0) {
value >>= 8;
result += 8;
}
if (value >> 4 > 0) {
value >>= 4;
result += 4;
}
if (value >> 2 > 0) {
value >>= 2;
result += 2;
}
if (value >> 1 > 0) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 2, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log2(value);
return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 10, rounded down, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >= 10 ** 64) {
value /= 10 ** 64;
result += 64;
}
if (value >= 10 ** 32) {
value /= 10 ** 32;
result += 32;
}
if (value >= 10 ** 16) {
value /= 10 ** 16;
result += 16;
}
if (value >= 10 ** 8) {
value /= 10 ** 8;
result += 8;
}
if (value >= 10 ** 4) {
value /= 10 ** 4;
result += 4;
}
if (value >= 10 ** 2) {
value /= 10 ** 2;
result += 2;
}
if (value >= 10 ** 1) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 10, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log10(value);
return result + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 256, rounded down, of a positive value.
* Returns 0 if given 0.
*
* Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
*/
function log256(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 16;
}
if (value >> 64 > 0) {
value >>= 64;
result += 8;
}
if (value >> 32 > 0) {
value >>= 32;
result += 4;
}
if (value >> 16 > 0) {
value >>= 16;
result += 2;
}
if (value >> 8 > 0) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 256, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log256(value);
return result + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0);
}
}
}
// File @openzeppelin/contracts/utils/math/SignedMath.sol@v4.9.6
// Original license: SPDX_License_Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol)
pragma solidity ^0.8.0;
/**
* @dev Standard signed math utilities missing in the Solidity language.
*/
library SignedMath {
/**
* @dev Returns the largest of two signed numbers.
*/
function max(int256 a, int256 b) internal pure returns (int256) {
return a > b ? a : b;
}
/**
* @dev Returns the smallest of two signed numbers.
*/
function min(int256 a, int256 b) internal pure returns (int256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two signed numbers without overflow.
* The result is rounded towards zero.
*/
function average(int256 a, int256 b) internal pure returns (int256) {
// Formula from the book "Hacker's Delight"
int256 x = (a & b) + ((a ^ b) >> 1);
return x + (int256(uint256(x) >> 255) & (a ^ b));
}
/**
* @dev Returns the absolute unsigned value of a signed value.
*/
function abs(int256 n) internal pure returns (uint256) {
unchecked {
// must be unchecked in order to support `n = type(int256).min`
return uint256(n >= 0 ? n : -n);
}
}
}
// File @openzeppelin/contracts/utils/Strings.sol@v4.9.6
// Original license: SPDX_License_Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol)
pragma solidity ^0.8.0;
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant _SYMBOLS = "0123456789abcdef";
uint8 private constant _ADDRESS_LENGTH = 20;
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
unchecked {
uint256 length = Math.log10(value) + 1;
string memory buffer = new string(length);
uint256 ptr;
/// @solidity memory-safe-assembly
assembly {
ptr := add(buffer, add(32, length))
}
while (true) {
ptr--;
/// @solidity memory-safe-assembly
assembly {
mstore8(ptr, byte(mod(value, 10), _SYMBOLS))
}
value /= 10;
if (value == 0) break;
}
return buffer;
}
}
/**
* @dev Converts a `int256` to its ASCII `string` decimal representation.
*/
function toString(int256 value) internal pure returns (string memory) {
return string(abi.encodePacked(value < 0 ? "-" : "", toString(SignedMath.abs(value))));
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
unchecked {
return toHexString(value, Math.log256(value) + 1);
}
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
/**
* @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
*/
function toHexString(address addr) internal pure returns (string memory) {
return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
}
/**
* @dev Returns true if the two strings are equal.
*/
function equal(string memory a, string memory b) internal pure returns (bool) {
return keccak256(bytes(a)) == keccak256(bytes(b));
}
}
// File @openzeppelin/contracts/utils/cryptography/ECDSA.sol@v4.9.6
// Original license: SPDX_License_Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/cryptography/ECDSA.sol)
pragma solidity ^0.8.0;
/**
* @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
*
* These functions can be used to verify that a message was signed by the holder
* of the private keys of a given address.
*/
library ECDSA {
enum RecoverError {
NoError,
InvalidSignature,
InvalidSignatureLength,
InvalidSignatureS,
InvalidSignatureV // Deprecated in v4.8
}
function _throwError(RecoverError error) private pure {
if (error == RecoverError.NoError) {
return; // no error: do nothing
} else if (error == RecoverError.InvalidSignature) {
revert("ECDSA: invalid signature");
} else if (error == RecoverError.InvalidSignatureLength) {
revert("ECDSA: invalid signature length");
} else if (error == RecoverError.InvalidSignatureS) {
revert("ECDSA: invalid signature 's' value");
}
}
/**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature` or error string. This address can then be used for verification purposes.
*
* The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {toEthSignedMessageHash} on it.
*
* Documentation for signature generation:
* - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]
* - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]
*
* _Available since v4.3._
*/
function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {
if (signature.length == 65) {
bytes32 r;
bytes32 s;
uint8 v;
// ecrecover takes the signature parameters, and the only way to get them
// currently is to use assembly.
/// @solidity memory-safe-assembly
assembly {
r := mload(add(signature, 0x20))
s := mload(add(signature, 0x40))
v := byte(0, mload(add(signature, 0x60)))
}
return tryRecover(hash, v, r, s);
} else {
return (address(0), RecoverError.InvalidSignatureLength);
}
}
/**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature`. This address can then be used for verification purposes.
*
* The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {toEthSignedMessageHash} on it.
*/
function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, signature);
_throwError(error);
return recovered;
}
/**
* @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.
*
* See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]
*
* _Available since v4.3._
*/
function tryRecover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address, RecoverError) {
bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);
uint8 v = uint8((uint256(vs) >> 255) + 27);
return tryRecover(hash, v, r, s);
}
/**
* @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.
*
* _Available since v4.2._
*/
function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, r, vs);
_throwError(error);
return recovered;
}
/**
* @dev Overload of {ECDSA-tryRecover} that receives the `v`,
* `r` and `s` signature fields separately.
*
* _Available since v4.3._
*/
function tryRecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address, RecoverError) {
// EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
// unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
// the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most
// signatures from current libraries generate a unique signature with an s-value in the lower half order.
//
// If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
// with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
// vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
// these malleable signatures as well.
if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
return (address(0), RecoverError.InvalidSignatureS);
}
// If the signature is valid (and not malleable), return the signer address
address signer = ecrecover(hash, v, r, s);
if (signer == address(0)) {
return (address(0), RecoverError.InvalidSignature);
}
return (signer, RecoverError.NoError);
}
/**
* @dev Overload of {ECDSA-recover} that receives the `v`,
* `r` and `s` signature fields separately.
*/
function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, v, r, s);
_throwError(error);
return recovered;
}
/**
* @dev Returns an Ethereum Signed Message, created from a `hash`. This
* produces hash corresponding to the one signed with the
* https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
* JSON-RPC method as part of EIP-191.
*
* See {recover}.
*/
function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32 message) {
// 32 is the length in bytes of hash,
// enforced by the type signature above
/// @solidity memory-safe-assembly
assembly {
mstore(0x00, "\x19Ethereum Signed Message:\n32")
mstore(0x1c, hash)
message := keccak256(0x00, 0x3c)
}
}
/**
* @dev Returns an Ethereum Signed Message, created from `s`. This
* produces hash corresponding to the one signed with the
* https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
* JSON-RPC method as part of EIP-191.
*
* See {recover}.
*/
function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {
return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", Strings.toString(s.length), s));
}
/**
* @dev Returns an Ethereum Signed Typed Data, created from a
* `domainSeparator` and a `structHash`. This produces hash corresponding
* to the one signed with the
* https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]
* JSON-RPC method as part of EIP-712.
*
* See {recover}.
*/
function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32 data) {
/// @solidity memory-safe-assembly
assembly {
let ptr := mload(0x40)
mstore(ptr, "\x19\x01")
mstore(add(ptr, 0x02), domainSeparator)
mstore(add(ptr, 0x22), structHash)
data := keccak256(ptr, 0x42)
}
}
/**
* @dev Returns an Ethereum Signed Data with intended validator, created from a
* `validator` and `data` according to the version 0 of EIP-191.
*
* See {recover}.
*/
function toDataWithIntendedValidatorHash(address validator, bytes memory data) internal pure returns (bytes32) {
return keccak256(abi.encodePacked("\x19\x00", validator, data));
}
}
// File contracts/payment.sol
// Original license: SPDX_License_Identifier: MIT
pragma solidity ^0.8.18;
error InvalidSignature();
error IncorrectPayment();
error CannotDowngrade();
error InvalidNonce();
error ZeroAddress();
error TransferToTreasuryFailed();
contract PackageManager is Initializable, OwnableUpgradeable, ReentrancyGuardUpgradeable, PausableUpgradeable {
using ECDSA for bytes32;
address public backendSigner;
address public feeRecipient;
mapping(address => uint8) public userPackage;
mapping(address => uint256) public userNonce;
mapping(address => uint256) public expireAt;
event PackagePurchased(address indexed user, uint8 indexed pkgId, uint128 amountWei, uint256 expireAt, uint256 nonce, bytes signature, uint256 timestamp);
/// @notice Emitted when backend signer changes
event BackendSignerChanged(address indexed previousSigner, address indexed newSigner);
event FeeRecipientUpdated(address indexed newRecipient);
function initialize(address _backendSigner) external initializer {
if (_backendSigner == address(0)) revert ZeroAddress();
__Ownable_init();
__ReentrancyGuard_init();
__Pausable_init();
feeRecipient = msg.sender;
backendSigner = _backendSigner;
}
function _chainId() public view returns (uint256 id) {
assembly {
id := chainid()
}
}
function _hashPacked(address user, uint8 pkgId, uint128 amountWei, uint256 expireTimestamp, uint256 nonce) internal pure returns (bytes32) {
return keccak256(abi.encodePacked(user, pkgId, amountWei, expireTimestamp, nonce));
}
function setBackendSigner(address _backendSigner) external onlyOwner {
if (_backendSigner == address(0)) revert ZeroAddress();
emit BackendSignerChanged(backendSigner, _backendSigner);
backendSigner = _backendSigner;
}
function setFeeRecipient(address _feeRecipient) external onlyOwner {
if (_feeRecipient == address(0)) revert ZeroAddress();
feeRecipient = _feeRecipient;
emit FeeRecipientUpdated(_feeRecipient);
}
function verifySignature(address user, uint8 pkgId, uint128 amountWei, uint256 expireTimestamp, uint256 nonce, bytes calldata signature) internal view returns (bool) {
bytes32 msgHash = _hashPacked(user, pkgId, amountWei, expireTimestamp, nonce);
bytes32 ethHash = keccak256(abi.encodePacked('\x19Ethereum Signed Message:\n32', msgHash));
address recoveredSigner = ethHash.recover(signature);
return recoveredSigner == backendSigner;
}
/**
* @notice Buy or upgrade a package using a backend-signed offer.
* @param newPkgId the package id to buy
* @param amountWei the native amount in wei the backend computed and signed
* @param expireTimestamp unix timestamp when the package should expire for the user
* @param chainId chain id included in signed payload (must match current chain)
* @param nonce backend-provided nonce (must be userNonce + 1)
* @param signature backend signature bytes
*
* Requirements:
* - signature must be valid and issued by backendSigner
* - msg.value must equal amountWei
* - nonce must equal userNonce[user] + 1 (prevents reuse)
* - if newPkgId <= current and current not expired -> revert (no downgrade / no same-level re-purchase while active)
* - for upgrades where user has active package, backend must have reduced amountWei (discount) off-chain
**/
function buyPackage(uint8 newPkgId, uint128 amountWei, uint256 expireTimestamp, uint256 nonce, uint256 chainId, bytes calldata signature) external payable nonReentrant whenNotPaused {
uint256 currentChain = _chainId();
if (chainId != currentChain) revert InvalidSignature();
address user = msg.sender;
if (nonce <= userNonce[user]) revert InvalidNonce();
// verify signature
bool ok = verifySignature(user, newPkgId, amountWei, expireTimestamp, nonce, signature);
if (!ok) revert InvalidSignature();
// check paid amount
if (uint128(msg.value) != amountWei) revert IncorrectPayment();
uint8 currentPkg = userPackage[user];
uint256 currentExpire = expireAt[user];
if (newPkgId <= currentPkg && block.timestamp < currentExpire) {
revert CannotDowngrade();
}
// update nonce first to prevent reentrancy misuse
userNonce[user] = nonce;
// update package and expiry
userPackage[user] = newPkgId;
expireAt[user] = expireTimestamp;
(bool sent, ) = payable(feeRecipient).call{ value: msg.value }('');
if (!sent) revert TransferToTreasuryFailed();
emit PackagePurchased(user, newPkgId, amountWei, expireTimestamp, nonce, signature, block.timestamp);
}
function getUserPackage(address user) external view returns (uint8 pkgId, uint256 expires, uint256 nextNonce) {
pkgId = userPackage[user];
expires = expireAt[user];
nextNonce = userNonce[user] + 1;
}
function pause() external onlyOwner {
_pause();
}
function unpause() external onlyOwner {
_unpause();
}
receive() external payable {
// allow receiving, but ideally payments go via buyPackage
}
fallback() external payable {}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[],"name":"CannotDowngrade","type":"error"},{"inputs":[],"name":"IncorrectPayment","type":"error"},{"inputs":[],"name":"InvalidNonce","type":"error"},{"inputs":[],"name":"InvalidSignature","type":"error"},{"inputs":[],"name":"TransferToTreasuryFailed","type":"error"},{"inputs":[],"name":"ZeroAddress","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousSigner","type":"address"},{"indexed":true,"internalType":"address","name":"newSigner","type":"address"}],"name":"BackendSignerChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"newRecipient","type":"address"}],"name":"FeeRecipientUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"uint8","name":"pkgId","type":"uint8"},{"indexed":false,"internalType":"uint128","name":"amountWei","type":"uint128"},{"indexed":false,"internalType":"uint256","name":"expireAt","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"nonce","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"signature","type":"bytes"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"PackagePurchased","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"stateMutability":"payable","type":"fallback"},{"inputs":[],"name":"_chainId","outputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"backendSigner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint8","name":"newPkgId","type":"uint8"},{"internalType":"uint128","name":"amountWei","type":"uint128"},{"internalType":"uint256","name":"expireTimestamp","type":"uint256"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"bytes","name":"signature","type":"bytes"}],"name":"buyPackage","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"expireAt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"feeRecipient","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"getUserPackage","outputs":[{"internalType":"uint8","name":"pkgId","type":"uint8"},{"internalType":"uint256","name":"expires","type":"uint256"},{"internalType":"uint256","name":"nextNonce","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_backendSigner","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_backendSigner","type":"address"}],"name":"setBackendSigner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_feeRecipient","type":"address"}],"name":"setFeeRecipient","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"userNonce","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"userPackage","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}]Contract Creation Code
608060405234801561001057600080fd5b5061129a806100206000396000f3fe6080604052600436106100f55760003560e01c8063747734121161008f578063c4d66de811610061578063c4d66de81461029b578063d527b8e1146102bb578063df5bd0f7146102fd578063e74b981b1461032a578063f2fde38b1461034a57005b806374773412146102165780638456cb59146102295780638da5cb5b1461023e578063957458d41461025c57005b806346904840116100c857806346904840146101865780635c975abb146101be57806365d65e86146101e1578063715018a61461020157005b8062acf191146100fe5780632e04b8e71461011157806336f95670146101515780633f4ba83a1461017157005b366100fc57005b005b6100fc61010c366004611094565b61036a565b34801561011d57600080fd5b5061013e61012c36600461115b565b60cc6020526000908152604090205481565b6040519081526020015b60405180910390f35b34801561015d57600080fd5b506100fc61016c36600461115b565b610609565b34801561017d57600080fd5b506100fc610694565b34801561019257600080fd5b5060ca546101a6906001600160a01b031681565b6040516001600160a01b039091168152602001610148565b3480156101ca57600080fd5b5060975460ff166040519015158152602001610148565b3480156101ed57600080fd5b5060c9546101a6906001600160a01b031681565b34801561020d57600080fd5b506100fc6106a6565b34801561022257600080fd5b504661013e565b34801561023557600080fd5b506100fc6106b8565b34801561024a57600080fd5b506033546001600160a01b03166101a6565b34801561026857600080fd5b5061027c61027736600461115b565b6106c8565b6040805160ff9094168452602084019290925290820152606001610148565b3480156102a757600080fd5b506100fc6102b636600461115b565b61070f565b3480156102c757600080fd5b506102eb6102d636600461115b565b60cb6020526000908152604090205460ff1681565b60405160ff9091168152602001610148565b34801561030957600080fd5b5061013e61031836600461115b565b60cd6020526000908152604090205481565b34801561033657600080fd5b506100fc61034536600461115b565b610895565b34801561035657600080fd5b506100fc61036536600461115b565b61090e565b610372610987565b61037a6109e0565b4683811461039b57604051638baa579f60e01b815260040160405180910390fd5b33600081815260cc602052604090205486116103ca57604051633ab3447f60e11b815260040160405180910390fd5b60006103db828b8b8b8b8a8a610a33565b9050806103fb57604051638baa579f60e01b815260040160405180910390fd5b886001600160801b0316346001600160801b03161461042d5760405163569e8c1160e01b815260040160405180910390fd5b6001600160a01b038216600090815260cb602090815260408083205460cd9092529091205460ff918216918c16821080159061046857508042105b1561048657604051635666717d60e01b815260040160405180910390fd5b8860cc6000866001600160a01b03166001600160a01b03168152602001908152602001600020819055508b60cb6000866001600160a01b03166001600160a01b0316815260200190815260200160002060006101000a81548160ff021916908360ff1602179055508960cd6000866001600160a01b03166001600160a01b0316815260200190815260200160002081905550600060ca60009054906101000a90046001600160a01b03166001600160a01b03163460405160006040518083038185875af1925050503d806000811461057a576040519150601f19603f3d011682016040523d82523d6000602084013e61057f565b606091505b50509050806105a157604051636ff3882760e01b815260040160405180910390fd5b8c60ff16856001600160a01b03167fb73f78b69c23aa5b65048c5d365006e62e3e53bb0c5df203124651baac811dfd8e8e8e8d8d426040516105e89695949392919061118b565b60405180910390a35050505050506106006001606555565b50505050505050565b610611610b77565b6001600160a01b0381166106385760405163d92e233d60e01b815260040160405180910390fd5b60c9546040516001600160a01b038084169216907f60c5293782c70b9080e83e261790b280285209d93c36a68814b4c9a150f047de90600090a360c980546001600160a01b0319166001600160a01b0392909216919091179055565b61069c610b77565b6106a4610bd1565b565b6106ae610b77565b6106a46000610c23565b6106c0610b77565b6106a4610c75565b6001600160a01b038116600090815260cb602090815260408083205460cd83528184205460cc9093529083205460ff90911692906107079060016111e2565b929491935050565b600054610100900460ff161580801561072f5750600054600160ff909116105b806107495750303b158015610749575060005460ff166001145b6107c05760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a656400000000000000000000000000000000000060648201526084015b60405180910390fd5b6000805460ff1916600117905580156107e3576000805461ff0019166101001790555b6001600160a01b03821661080a5760405163d92e233d60e01b815260040160405180910390fd5b610812610cb2565b61081a610ce1565b610822610d10565b60ca8054336001600160a01b03199182161790915560c980549091166001600160a01b0384161790558015610891576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5050565b61089d610b77565b6001600160a01b0381166108c45760405163d92e233d60e01b815260040160405180910390fd5b60ca80546001600160a01b0319166001600160a01b0383169081179091556040517f7a7b5a0a132f9e0581eb8527f66eae9ee89c2a3e79d4ac7e41a1f1f4d48a7fc290600090a250565b610916610b77565b6001600160a01b03811661097b5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016107b7565b61098481610c23565b50565b6002606554036109d95760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016107b7565b6002606555565b60975460ff16156106a45760405162461bcd60e51b815260206004820152601060248201527f5061757361626c653a207061757365640000000000000000000000000000000060448201526064016107b7565b60408051606089901b6bffffffffffffffffffffffff191660208083019190915260f889901b7fff00000000000000000000000000000000000000000000000000000000000000166034830152608088901b6fffffffffffffffffffffffffffffffff19166035830152604582018790526065808301879052835180840390910181526085830184528051908201207f19457468657265756d205369676e6564204d6573736167653a0a33320000000060a584015260c18084018290528451808503909101815260e18401808652815191840191909120601f8701849004909302840161010190810190955285815260009491938592610b509291899189918291018382808284376000920191909152508693925050610d3f9050565b60c9546001600160a01b039081169116149b9a5050505050505050505050565b6001606555565b6033546001600160a01b031633146106a45760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016107b7565b610bd9610d65565b6097805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b610c7d6109e0565b6097805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258610c063390565b600054610100900460ff16610cd95760405162461bcd60e51b81526004016107b790611203565b6106a4610db7565b600054610100900460ff16610d085760405162461bcd60e51b81526004016107b790611203565b6106a4610de7565b600054610100900460ff16610d375760405162461bcd60e51b81526004016107b790611203565b6106a4610e0e565b6000806000610d4e8585610e41565b91509150610d5b81610e86565b5090505b92915050565b60975460ff166106a45760405162461bcd60e51b815260206004820152601460248201527f5061757361626c653a206e6f742070617573656400000000000000000000000060448201526064016107b7565b600054610100900460ff16610dde5760405162461bcd60e51b81526004016107b790611203565b6106a433610c23565b600054610100900460ff16610b705760405162461bcd60e51b81526004016107b790611203565b600054610100900460ff16610e355760405162461bcd60e51b81526004016107b790611203565b6097805460ff19169055565b6000808251604103610e775760208301516040840151606085015160001a610e6b87828585610fd0565b94509450505050610e7f565b506000905060025b9250929050565b6000816004811115610e9a57610e9a61124e565b03610ea25750565b6001816004811115610eb657610eb661124e565b03610f035760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e6174757265000000000000000060448201526064016107b7565b6002816004811115610f1757610f1761124e565b03610f645760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e6774680060448201526064016107b7565b6003816004811115610f7857610f7861124e565b036109845760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b60648201526084016107b7565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0831115611007575060009050600361108b565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa15801561105b573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381166110845760006001925092505061108b565b9150600090505b94509492505050565b600080600080600080600060c0888a0312156110af57600080fd5b873560ff811681146110c057600080fd5b965060208801356001600160801b03811681146110dc57600080fd5b955060408801359450606088013593506080880135925060a088013567ffffffffffffffff8082111561110e57600080fd5b818a0191508a601f83011261112257600080fd5b81358181111561113157600080fd5b8b602082850101111561114357600080fd5b60208301945080935050505092959891949750929550565b60006020828403121561116d57600080fd5b81356001600160a01b038116811461118457600080fd5b9392505050565b6001600160801b038716815285602082015284604082015260a060608201528260a0820152828460c0830137600060c08483010152600060c0601f19601f8601168301019050826080830152979650505050505050565b80820180821115610d5f57634e487b7160e01b600052601160045260246000fd5b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b634e487b7160e01b600052602160045260246000fdfea264697066735822122025afa6c37a225d7c129b30ab8c43b4dfe865da8f972fc5b351bf9c68c33ba88964736f6c63430008120033
Deployed Bytecode
0x6080604052600436106100f55760003560e01c8063747734121161008f578063c4d66de811610061578063c4d66de81461029b578063d527b8e1146102bb578063df5bd0f7146102fd578063e74b981b1461032a578063f2fde38b1461034a57005b806374773412146102165780638456cb59146102295780638da5cb5b1461023e578063957458d41461025c57005b806346904840116100c857806346904840146101865780635c975abb146101be57806365d65e86146101e1578063715018a61461020157005b8062acf191146100fe5780632e04b8e71461011157806336f95670146101515780633f4ba83a1461017157005b366100fc57005b005b6100fc61010c366004611094565b61036a565b34801561011d57600080fd5b5061013e61012c36600461115b565b60cc6020526000908152604090205481565b6040519081526020015b60405180910390f35b34801561015d57600080fd5b506100fc61016c36600461115b565b610609565b34801561017d57600080fd5b506100fc610694565b34801561019257600080fd5b5060ca546101a6906001600160a01b031681565b6040516001600160a01b039091168152602001610148565b3480156101ca57600080fd5b5060975460ff166040519015158152602001610148565b3480156101ed57600080fd5b5060c9546101a6906001600160a01b031681565b34801561020d57600080fd5b506100fc6106a6565b34801561022257600080fd5b504661013e565b34801561023557600080fd5b506100fc6106b8565b34801561024a57600080fd5b506033546001600160a01b03166101a6565b34801561026857600080fd5b5061027c61027736600461115b565b6106c8565b6040805160ff9094168452602084019290925290820152606001610148565b3480156102a757600080fd5b506100fc6102b636600461115b565b61070f565b3480156102c757600080fd5b506102eb6102d636600461115b565b60cb6020526000908152604090205460ff1681565b60405160ff9091168152602001610148565b34801561030957600080fd5b5061013e61031836600461115b565b60cd6020526000908152604090205481565b34801561033657600080fd5b506100fc61034536600461115b565b610895565b34801561035657600080fd5b506100fc61036536600461115b565b61090e565b610372610987565b61037a6109e0565b4683811461039b57604051638baa579f60e01b815260040160405180910390fd5b33600081815260cc602052604090205486116103ca57604051633ab3447f60e11b815260040160405180910390fd5b60006103db828b8b8b8b8a8a610a33565b9050806103fb57604051638baa579f60e01b815260040160405180910390fd5b886001600160801b0316346001600160801b03161461042d5760405163569e8c1160e01b815260040160405180910390fd5b6001600160a01b038216600090815260cb602090815260408083205460cd9092529091205460ff918216918c16821080159061046857508042105b1561048657604051635666717d60e01b815260040160405180910390fd5b8860cc6000866001600160a01b03166001600160a01b03168152602001908152602001600020819055508b60cb6000866001600160a01b03166001600160a01b0316815260200190815260200160002060006101000a81548160ff021916908360ff1602179055508960cd6000866001600160a01b03166001600160a01b0316815260200190815260200160002081905550600060ca60009054906101000a90046001600160a01b03166001600160a01b03163460405160006040518083038185875af1925050503d806000811461057a576040519150601f19603f3d011682016040523d82523d6000602084013e61057f565b606091505b50509050806105a157604051636ff3882760e01b815260040160405180910390fd5b8c60ff16856001600160a01b03167fb73f78b69c23aa5b65048c5d365006e62e3e53bb0c5df203124651baac811dfd8e8e8e8d8d426040516105e89695949392919061118b565b60405180910390a35050505050506106006001606555565b50505050505050565b610611610b77565b6001600160a01b0381166106385760405163d92e233d60e01b815260040160405180910390fd5b60c9546040516001600160a01b038084169216907f60c5293782c70b9080e83e261790b280285209d93c36a68814b4c9a150f047de90600090a360c980546001600160a01b0319166001600160a01b0392909216919091179055565b61069c610b77565b6106a4610bd1565b565b6106ae610b77565b6106a46000610c23565b6106c0610b77565b6106a4610c75565b6001600160a01b038116600090815260cb602090815260408083205460cd83528184205460cc9093529083205460ff90911692906107079060016111e2565b929491935050565b600054610100900460ff161580801561072f5750600054600160ff909116105b806107495750303b158015610749575060005460ff166001145b6107c05760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a656400000000000000000000000000000000000060648201526084015b60405180910390fd5b6000805460ff1916600117905580156107e3576000805461ff0019166101001790555b6001600160a01b03821661080a5760405163d92e233d60e01b815260040160405180910390fd5b610812610cb2565b61081a610ce1565b610822610d10565b60ca8054336001600160a01b03199182161790915560c980549091166001600160a01b0384161790558015610891576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5050565b61089d610b77565b6001600160a01b0381166108c45760405163d92e233d60e01b815260040160405180910390fd5b60ca80546001600160a01b0319166001600160a01b0383169081179091556040517f7a7b5a0a132f9e0581eb8527f66eae9ee89c2a3e79d4ac7e41a1f1f4d48a7fc290600090a250565b610916610b77565b6001600160a01b03811661097b5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016107b7565b61098481610c23565b50565b6002606554036109d95760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016107b7565b6002606555565b60975460ff16156106a45760405162461bcd60e51b815260206004820152601060248201527f5061757361626c653a207061757365640000000000000000000000000000000060448201526064016107b7565b60408051606089901b6bffffffffffffffffffffffff191660208083019190915260f889901b7fff00000000000000000000000000000000000000000000000000000000000000166034830152608088901b6fffffffffffffffffffffffffffffffff19166035830152604582018790526065808301879052835180840390910181526085830184528051908201207f19457468657265756d205369676e6564204d6573736167653a0a33320000000060a584015260c18084018290528451808503909101815260e18401808652815191840191909120601f8701849004909302840161010190810190955285815260009491938592610b509291899189918291018382808284376000920191909152508693925050610d3f9050565b60c9546001600160a01b039081169116149b9a5050505050505050505050565b6001606555565b6033546001600160a01b031633146106a45760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016107b7565b610bd9610d65565b6097805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b610c7d6109e0565b6097805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258610c063390565b600054610100900460ff16610cd95760405162461bcd60e51b81526004016107b790611203565b6106a4610db7565b600054610100900460ff16610d085760405162461bcd60e51b81526004016107b790611203565b6106a4610de7565b600054610100900460ff16610d375760405162461bcd60e51b81526004016107b790611203565b6106a4610e0e565b6000806000610d4e8585610e41565b91509150610d5b81610e86565b5090505b92915050565b60975460ff166106a45760405162461bcd60e51b815260206004820152601460248201527f5061757361626c653a206e6f742070617573656400000000000000000000000060448201526064016107b7565b600054610100900460ff16610dde5760405162461bcd60e51b81526004016107b790611203565b6106a433610c23565b600054610100900460ff16610b705760405162461bcd60e51b81526004016107b790611203565b600054610100900460ff16610e355760405162461bcd60e51b81526004016107b790611203565b6097805460ff19169055565b6000808251604103610e775760208301516040840151606085015160001a610e6b87828585610fd0565b94509450505050610e7f565b506000905060025b9250929050565b6000816004811115610e9a57610e9a61124e565b03610ea25750565b6001816004811115610eb657610eb661124e565b03610f035760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e6174757265000000000000000060448201526064016107b7565b6002816004811115610f1757610f1761124e565b03610f645760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e6774680060448201526064016107b7565b6003816004811115610f7857610f7861124e565b036109845760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b60648201526084016107b7565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0831115611007575060009050600361108b565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa15801561105b573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381166110845760006001925092505061108b565b9150600090505b94509492505050565b600080600080600080600060c0888a0312156110af57600080fd5b873560ff811681146110c057600080fd5b965060208801356001600160801b03811681146110dc57600080fd5b955060408801359450606088013593506080880135925060a088013567ffffffffffffffff8082111561110e57600080fd5b818a0191508a601f83011261112257600080fd5b81358181111561113157600080fd5b8b602082850101111561114357600080fd5b60208301945080935050505092959891949750929550565b60006020828403121561116d57600080fd5b81356001600160a01b038116811461118457600080fd5b9392505050565b6001600160801b038716815285602082015284604082015260a060608201528260a0820152828460c0830137600060c08483010152600060c0601f19601f8601168301019050826080830152979650505050505050565b80820180821115610d5f57634e487b7160e01b600052601160045260246000fd5b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b634e487b7160e01b600052602160045260246000fdfea264697066735822122025afa6c37a225d7c129b30ab8c43b4dfe865da8f972fc5b351bf9c68c33ba88964736f6c63430008120033
Deployed Bytecode Sourcemap
55748:4982:0:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;58980:1263;;;;;;:::i;:::-;;:::i;56009:44::-;;;;;;;;;;-1:-1:-1;56009:44:0;;;;;:::i;:::-;;;;;;;;;;;;;;;;;1631:25:1;;;1619:2;1604:18;56009:44:0;;;;;;;;57107:236;;;;;;;;;;-1:-1:-1;57107:236:0;;;;;:::i;:::-;;:::i;60531:61::-;;;;;;;;;;;;;:::i;55926:27::-;;;;;;;;;;-1:-1:-1;55926:27:0;;;;-1:-1:-1;;;;;55926:27:0;;;;;;-1:-1:-1;;;;;1831:55:1;;;1813:74;;1801:2;1786:18;55926:27:0;1667:226:1;23459:86:0;;;;;;;;;;-1:-1:-1;23530:7:0;;;;23459:86;;2063:14:1;;2056:22;2038:41;;2026:2;2011:18;23459:86:0;1898:187:1;55893:28:0;;;;;;;;;;-1:-1:-1;55893:28:0;;;;-1:-1:-1;;;;;55893:28:0;;;20398:103;;;;;;;;;;;;;:::i;56756:105::-;;;;;;;;;;-1:-1:-1;56840:9:0;56756:105;;60470:57;;;;;;;;;;;;;:::i;19757:87::-;;;;;;;;;;-1:-1:-1;19830:6:0;;-1:-1:-1;;;;;19830:6:0;19757:87;;60249:217;;;;;;;;;;-1:-1:-1;60249:217:0;;;;;:::i;:::-;;:::i;:::-;;;;2318:4:1;2306:17;;;2288:36;;2355:2;2340:18;;2333:34;;;;2383:18;;;2376:34;2276:2;2261:18;60249:217:0;2090:326:1;56469:281:0;;;;;;;;;;-1:-1:-1;56469:281:0;;;;;:::i;:::-;;:::i;55960:44::-;;;;;;;;;;-1:-1:-1;55960:44:0;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;2593:4:1;2581:17;;;2563:36;;2551:2;2536:18;55960:44:0;2421:184:1;56058:43:0;;;;;;;;;;-1:-1:-1;56058:43:0;;;;;:::i;:::-;;;;;;;;;;;;;;57347:214;;;;;;;;;;-1:-1:-1;57347:214:0;;;;;:::i;:::-;;:::i;20656:201::-;;;;;;;;;;-1:-1:-1;20656:201:0;;;;;:::i;:::-;;:::i;58980:1263::-;27369:21;:19;:21::i;:::-;23064:19:::1;:17;:19::i;:::-;56840:9:::0;59213:23;;::::2;59209:54;;59245:18;;-1:-1:-1::0;;;59245:18:0::2;;;;;;;;;;;59209:54;59285:10;59270:12;59315:15:::0;;;:9:::2;:15;::::0;;;;;59306:24;::::2;59302:51;;59339:14;;-1:-1:-1::0;;;59339:14:0::2;;;;;;;;;;;59302:51;59385:7;59395:77;59411:4;59417:8;59427:9;59438:15;59455:5;59462:9;;59395:15;:77::i;:::-;59385:87;;59484:2;59479:34;;59495:18;;-1:-1:-1::0;;;59495:18:0::2;;;;;;;;;;;59479:34;59572:9;-1:-1:-1::0;;;;;59550:31:0::2;59558:9;-1:-1:-1::0;;;;;59550:31:0::2;;59546:62;;59590:18;;-1:-1:-1::0;;;59590:18:0::2;;;;;;;;;;;59546:62;-1:-1:-1::0;;;;;59636:17:0;::::2;59617:16;59636:17:::0;;;:11:::2;:17;::::0;;;;;;;;59684:8:::2;:14:::0;;;;;;;59636:17:::2;::::0;;::::2;::::0;59711:22;::::2;::::0;-1:-1:-1;59711:22:0;::::2;::::0;:57:::2;;;59755:13;59737:15;:31;59711:57;59707:104;;;59786:17;;-1:-1:-1::0;;;59786:17:0::2;;;;;;;;;;;59707:104;59891:5;59873:9;:15;59883:4;-1:-1:-1::0;;;;;59873:15:0::2;-1:-1:-1::0;;;;;59873:15:0::2;;;;;;;;;;;;:23;;;;59959:8;59939:11;:17;59951:4;-1:-1:-1::0;;;;;59939:17:0::2;-1:-1:-1::0;;;;;59939:17:0::2;;;;;;;;;;;;;:28;;;;;;;;;;;;;;;;;;59991:15;59974:8;:14;59983:4;-1:-1:-1::0;;;;;59974:14:0::2;-1:-1:-1::0;;;;;59974:14:0::2;;;;;;;;;;;;:32;;;;60014:9;60037:12;;;;;;;;;-1:-1:-1::0;;;;;60037:12:0::2;-1:-1:-1::0;;;;;60029:26:0::2;60064:9;60029:50;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;60013:66;;;60091:4;60086:44;;60104:26;;-1:-1:-1::0;;;60104:26:0::2;;;;;;;;;;;60086:44;60165:8;60142:95;;60159:4;-1:-1:-1::0;;;;;60142:95:0::2;;60175:9;60186:15;60203:5;60210:9;;60221:15;60142:95;;;;;;;;;;;:::i;:::-;;;;;;;;59162:1081;;;;;;27413:20:::0;26630:1;27933:7;:22;27750:213;27413:20;58980:1263;;;;;;;:::o;57107:236::-;19643:13;:11;:13::i;:::-;-1:-1:-1;;;;;57187:28:0;::::1;57183:54;;57224:13;;-1:-1:-1::0;;;57224:13:0::1;;;;;;;;;;;57183:54;57270:13;::::0;57249:51:::1;::::0;-1:-1:-1;;;;;57249:51:0;;::::1;::::0;57270:13:::1;::::0;57249:51:::1;::::0;57270:13:::1;::::0;57249:51:::1;57307:13;:30:::0;;-1:-1:-1;;;;;;57307:30:0::1;-1:-1:-1::0;;;;;57307:30:0;;;::::1;::::0;;;::::1;::::0;;57107:236::o;60531:61::-;19643:13;:11;:13::i;:::-;60576:10:::1;:8;:10::i;:::-;60531:61::o:0;20398:103::-;19643:13;:11;:13::i;:::-;20463:30:::1;20490:1;20463:18;:30::i;60470:57::-:0;19643:13;:11;:13::i;:::-;60513:8:::1;:6;:8::i;60249:217::-:0;-1:-1:-1;;;;;60374:17:0;;60310:11;60374:17;;;:11;:17;;;;;;;;;60408:8;:14;;;;;;60441:9;:15;;;;;;;60374:17;;;;;60310:11;60441:19;;60374:17;60441:19;:::i;:::-;60249:217;;;;-1:-1:-1;;60249:217:0:o;56469:281::-;13241:19;13264:13;;;;;;13263:14;;13311:34;;;;-1:-1:-1;13329:12:0;;13344:1;13329:12;;;;:16;13311:34;13310:108;;;-1:-1:-1;13390:4:0;1958:19;:23;;;13351:66;;-1:-1:-1;13400:12:0;;;;;:17;13351:66;13288:204;;;;-1:-1:-1;;;13288:204:0;;3973:2:1;13288:204:0;;;3955:21:1;4012:2;3992:18;;;3985:30;4051:34;4031:18;;;4024:62;4122:16;4102:18;;;4095:44;4156:19;;13288:204:0;;;;;;;;;13503:12;:16;;-1:-1:-1;;13503:16:0;13518:1;13503:16;;;13530:67;;;;13565:13;:20;;-1:-1:-1;;13565:20:0;;;;;13530:67;-1:-1:-1;;;;;56545:28:0;::::1;56541:54;;56582:13;;-1:-1:-1::0;;;56582:13:0::1;;;;;;;;;;;56541:54;56604:16;:14;:16::i;:::-;56627:24;:22;:24::i;:::-;56658:17;:15;:17::i;:::-;56682:12;:25:::0;;56697:10:::1;-1:-1:-1::0;;;;;;56682:25:0;;::::1;;::::0;;;56714:13:::1;:30:::0;;;;::::1;-1:-1:-1::0;;;;;56714:30:0;::::1;;::::0;;13619:102;;;;13670:5;13654:21;;-1:-1:-1;;13654:21:0;;;13695:14;;-1:-1:-1;2563:36:1;;13695:14:0;;2551:2:1;2536:18;13695:14:0;;;;;;;13619:102;13230:498;56469:281;:::o;57347:214::-;19643:13;:11;:13::i;:::-;-1:-1:-1;;;;;57425:27:0;::::1;57421:53;;57461:13;;-1:-1:-1::0;;;57461:13:0::1;;;;;;;;;;;57421:53;57481:12;:28:::0;;-1:-1:-1;;;;;;57481:28:0::1;-1:-1:-1::0;;;;;57481:28:0;::::1;::::0;;::::1;::::0;;;57521:34:::1;::::0;::::1;::::0;-1:-1:-1;;57521:34:0::1;57347:214:::0;:::o;20656:201::-;19643:13;:11;:13::i;:::-;-1:-1:-1;;;;;20745:22:0;::::1;20737:73;;;::::0;-1:-1:-1;;;20737:73:0;;4587:2:1;20737:73:0::1;::::0;::::1;4569:21:1::0;4626:2;4606:18;;;4599:30;4665:34;4645:18;;;4638:62;-1:-1:-1;;;4716:18:1;;;4709:36;4762:19;;20737:73:0::1;4385:402:1::0;20737:73:0::1;20821:28;20840:8;20821:18;:28::i;:::-;20656:201:::0;:::o;27449:293::-;26674:1;27583:7;;:19;27575:63;;;;-1:-1:-1;;;27575:63:0;;4994:2:1;27575:63:0;;;4976:21:1;5033:2;5013:18;;;5006:30;5072:33;5052:18;;;5045:61;5123:18;;27575:63:0;4792:355:1;27575:63:0;26674:1;27716:7;:18;27449:293::o;23618:108::-;23530:7;;;;23688:9;23680:38;;;;-1:-1:-1;;;23680:38:0;;5354:2:1;23680:38:0;;;5336:21:1;5393:2;5373:18;;;5366:30;5432:18;5412;;;5405:46;5468:18;;23680:38:0;5152:340:1;57565:460:0;57030:64;;;6912:2:1;6908:15;;;-1:-1:-1;;6904:53:1;57030:64:0;;;;6892:66:1;;;;7014:3;6992:16;;;7010:13;6988:36;6974:12;;;6967:58;7063:3;7059:16;;;-1:-1:-1;;7055:62:1;7041:12;;;7034:84;7134:12;;;7127:28;;;7171:12;;;;7164:28;;;57030:64:0;;;;;;;;;;7208:13:1;;;57030:64:0;;57020:75;;;;;;5739:66:1;57850:61:0;;;5727:79:1;5822:12;;;;5815:28;;;57850:61:0;;;;;;;;;;5859:12:1;;;57850:61:0;;;57840:72;;;;;;;;;57945:26;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;57020:75:0;;-1:-1:-1;;57945:26:0;;5859:12:1;57961:9:0;;57945:26;;;;;57961:9;57945:26;;57961:9;57945:26;;;;;;;;;-1:-1:-1;57945:7:0;;:26;-1:-1:-1;;57945:15:0;:26;-1:-1:-1;57945:26:0:i;:::-;58006:13;;-1:-1:-1;;;;;58006:13:0;;;57987:32;;;;57565:460;-1:-1:-1;;;;;;;;;;;57565:460:0:o;27750:213::-;26630:1;27933:7;:22;27750:213::o;19922:132::-;19830:6;;-1:-1:-1;;;;;19830:6:0;17713:10;19986:23;19978:68;;;;-1:-1:-1;;;19978:68:0;;6084:2:1;19978:68:0;;;6066:21:1;;;6103:18;;;6096:30;6162:34;6142:18;;;6135:62;6214:18;;19978:68:0;5882:356:1;24314:120:0;23323:16;:14;:16::i;:::-;24373:7:::1;:15:::0;;-1:-1:-1;;24373:15:0::1;::::0;;24404:22:::1;17713:10:::0;24413:12:::1;24404:22;::::0;-1:-1:-1;;;;;1831:55:1;;;1813:74;;1801:2;1786:18;24404:22:0::1;;;;;;;24314:120::o:0;21017:191::-;21110:6;;;-1:-1:-1;;;;;21127:17:0;;;-1:-1:-1;;;;;;21127:17:0;;;;;;;21160:40;;21110:6;;;21127:17;21110:6;;21160:40;;21091:16;;21160:40;21080:128;21017:191;:::o;24055:118::-;23064:19;:17;:19::i;:::-;24115:7:::1;:14:::0;;-1:-1:-1;;24115:14:0::1;24125:4;24115:14;::::0;;24145:20:::1;24152:12;17713:10:::0;;17633:98;19300:97;15384:13;;;;;;;15376:69;;;;-1:-1:-1;;;15376:69:0;;;;;;;:::i;:::-;19363:26:::1;:24;:26::i;26716:113::-:0;15384:13;;;;;;;15376:69;;;;-1:-1:-1;;;15376:69:0;;;;;;;:::i;:::-;26787:34:::1;:32;:34::i;22629:99::-:0;15384:13;;;;;;;15376:69;;;;-1:-1:-1;;;15376:69:0;;;;;;;:::i;:::-;22693:27:::1;:25;:27::i;49864:231::-:0;49942:7;49963:17;49982:18;50004:27;50015:4;50021:9;50004:10;:27::i;:::-;49962:69;;;;50042:18;50054:5;50042:11;:18::i;:::-;-1:-1:-1;50078:9:0;-1:-1:-1;49864:231:0;;;;;:::o;23803:108::-;23530:7;;;;23862:41;;;;-1:-1:-1;;;23862:41:0;;7434:2:1;23862:41:0;;;7416:21:1;7473:2;7453:18;;;7446:30;7512:22;7492:18;;;7485:50;7552:18;;23862:41:0;7232:344:1;19405:113:0;15384:13;;;;;;;15376:69;;;;-1:-1:-1;;;15376:69:0;;;;;;;:::i;:::-;19478:32:::1;17713:10:::0;19478:18:::1;:32::i;26837:111::-:0;15384:13;;;;;;;15376:69;;;;-1:-1:-1;;;15376:69:0;;;;;;;:::i;22736:97::-;15384:13;;;;;;;15376:69;;;;-1:-1:-1;;;15376:69:0;;;;;;;:::i;:::-;22810:7:::1;:15:::0;;-1:-1:-1;;22810:15:0::1;::::0;;22736:97::o;48315:747::-;48396:7;48405:12;48434:9;:16;48454:2;48434:22;48430:625;;48778:4;48763:20;;48757:27;48828:4;48813:20;;48807:27;48886:4;48871:20;;48865:27;48473:9;48857:36;48929:25;48940:4;48857:36;48757:27;48807;48929:10;:25::i;:::-;48922:32;;;;;;;;;48430:625;-1:-1:-1;49003:1:0;;-1:-1:-1;49007:35:0;48430:625;48315:747;;;;;:::o;46708:521::-;46786:20;46777:5;:29;;;;;;;;:::i;:::-;;46773:449;;46708:521;:::o;46773:449::-;46884:29;46875:5;:38;;;;;;;;:::i;:::-;;46871:351;;46930:34;;-1:-1:-1;;;46930:34:0;;7915:2:1;46930:34:0;;;7897:21:1;7954:2;7934:18;;;7927:30;7993:26;7973:18;;;7966:54;8037:18;;46930:34:0;7713:348:1;46871:351:0;46995:35;46986:5;:44;;;;;;;;:::i;:::-;;46982:240;;47047:41;;-1:-1:-1;;;47047:41:0;;8268:2:1;47047:41:0;;;8250:21:1;8307:2;8287:18;;;8280:30;8346:33;8326:18;;;8319:61;8397:18;;47047:41:0;8066:355:1;46982:240:0;47119:30;47110:5;:39;;;;;;;;:::i;:::-;;47106:116;;47166:44;;-1:-1:-1;;;47166:44:0;;8628:2:1;47166:44:0;;;8610:21:1;8667:2;8647:18;;;8640:30;8706:34;8686:18;;;8679:62;-1:-1:-1;;;8757:18:1;;;8750:32;8799:19;;47166:44:0;8426:398:1;51248:1477:0;51336:7;;52270:66;52257:79;;52253:163;;;-1:-1:-1;52369:1:0;;-1:-1:-1;52373:30:0;52353:51;;52253:163;52530:24;;;52513:14;52530:24;;;;;;;;;9056:25:1;;;9129:4;9117:17;;9097:18;;;9090:45;;;;9151:18;;;9144:34;;;9194:18;;;9187:34;;;52530:24:0;;9028:19:1;;52530:24:0;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;52530:24:0;;-1:-1:-1;;52530:24:0;;;-1:-1:-1;;;;;;;52569:20:0;;52565:103;;52622:1;52626:29;52606:50;;;;;;;52565:103;52688:6;-1:-1:-1;52696:20:0;;-1:-1:-1;51248:1477:0;;;;;;;;:::o;14:1152:1:-;127:6;135;143;151;159;167;175;228:3;216:9;207:7;203:23;199:33;196:53;;;245:1;242;235:12;196:53;284:9;271:23;334:4;327:5;323:16;316:5;313:27;303:55;;354:1;351;344:12;303:55;377:5;-1:-1:-1;434:2:1;419:18;;406:32;-1:-1:-1;;;;;469:48:1;;457:61;;447:89;;532:1;529;522:12;447:89;555:7;-1:-1:-1;609:2:1;594:18;;581:32;;-1:-1:-1;660:2:1;645:18;;632:32;;-1:-1:-1;711:3:1;696:19;;683:33;;-1:-1:-1;767:3:1;752:19;;739:33;791:18;821:14;;;818:34;;;848:1;845;838:12;818:34;886:6;875:9;871:22;861:32;;931:7;924:4;920:2;916:13;912:27;902:55;;953:1;950;943:12;902:55;993:2;980:16;1019:2;1011:6;1008:14;1005:34;;;1035:1;1032;1025:12;1005:34;1080:7;1075:2;1066:6;1062:2;1058:15;1054:24;1051:37;1048:57;;;1101:1;1098;1091:12;1048:57;1132:2;1128;1124:11;1114:21;;1154:6;1144:16;;;;;14:1152;;;;;;;;;;:::o;1171:309::-;1230:6;1283:2;1271:9;1262:7;1258:23;1254:32;1251:52;;;1299:1;1296;1289:12;1251:52;1338:9;1325:23;-1:-1:-1;;;;;1381:5:1;1377:54;1370:5;1367:65;1357:93;;1446:1;1443;1436:12;1357:93;1469:5;1171:309;-1:-1:-1;;;1171:309:1:o;2820:719::-;-1:-1:-1;;;;;3093:6:1;3089:47;3078:9;3071:66;3173:6;3168:2;3157:9;3153:18;3146:34;3216:6;3211:2;3200:9;3196:18;3189:34;3259:3;3254:2;3243:9;3239:18;3232:31;3300:6;3294:3;3283:9;3279:19;3272:35;3358:6;3350;3344:3;3333:9;3329:19;3316:49;3415:1;3409:3;3400:6;3389:9;3385:22;3381:32;3374:43;3052:4;3485:3;3478:2;3474:7;3469:2;3461:6;3457:15;3453:29;3442:9;3438:45;3434:55;3426:63;;3526:6;3520:3;3509:9;3505:19;3498:35;2820:719;;;;;;;;;:::o;3544:222::-;3609:9;;;3630:10;;;3627:133;;;3682:10;3677:3;3673:20;3670:1;3663:31;3717:4;3714:1;3707:15;3745:4;3742:1;3735:15;6243:407;6445:2;6427:21;;;6484:2;6464:18;;;6457:30;6523:34;6518:2;6503:18;;6496:62;-1:-1:-1;;;6589:2:1;6574:18;;6567:41;6640:3;6625:19;;6243:407::o;7581:127::-;7642:10;7637:3;7633:20;7630:1;7623:31;7673:4;7670:1;7663:15;7697:4;7694:1;7687:15
Swarm Source
ipfs://25afa6c37a225d7c129b30ab8c43b4dfe865da8f972fc5b351bf9c68c33ba889
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in ETH
0
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.