Overview
S Balance
S Value
$0.00More Info
Private Name Tags
ContractCreator
Loading...
Loading
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.
Contract Name:
Factory
Compiler Version
v0.8.22+commit.4fc1097e
Optimization Enabled:
Yes with 200 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity ^0.8.19; import "@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol"; import "./Market.sol"; contract Factory is Initializable, PausableUpgradeable, UUPSUpgradeable, OwnableUpgradeable { // State variables address public feeRecipient; uint256 public marketCreationFee; address public marketImplementation; address public governor; address public susdToken; uint256 public tradingFee; uint256 public lpShare; uint256 public protocolShare; mapping(address => bool) public whitelistedAddresses; mapping(uint256 => address) public markets; mapping(address => bool) public verifiedMarkets; uint256 public marketId; // Events event MarketCreated( address indexed market, uint256 indexed marketId, string[] outcomes, uint256 resolutionDelay, address reporter, address governor ); event WhitelistedAddressAdded(address indexed account); event WhitelistedAddressRemoved(address indexed account); event MarketCreationFeeSet(uint256 newFee); event MarketVerified(address indexed market, bool verified); event GovernorSet(address newGovernor); event TradingFeeSet(uint256 newTradingFee); event FeeSharesSet(uint256 newLpShare, uint256 newProtocolShare); event MarketImplementationUpgraded(address newImplementation); /// @custom:oz-upgrades-unsafe-allow constructor constructor() { _disableInitializers(); } function initialize( address _governor, address _feeRecipient, uint256 _marketCreationFee, address _marketImplementation, address _susdToken ) external initializer { __Pausable_init(); __Ownable_init(_governor); __UUPSUpgradeable_init(); require(_governor != address(0), "Invalid governor"); require(_feeRecipient != address(0), "Invalid fee recipient"); require(_marketImplementation != address(0), "Invalid market implementation"); require(_susdToken != address(0), "Invalid SUSD token"); marketId = 0; feeRecipient = _feeRecipient; governor = _governor; marketCreationFee = _marketCreationFee; marketImplementation = _marketImplementation; susdToken = _susdToken; tradingFee = 1000; // 10% default lpShare = 900; // 9% to LPs protocolShare = 100; // 1% to protocol } function _authorizeUpgrade(address newImplementation) internal override onlyOwner {} function createMarket( string[] calldata outcomes, uint256 _resolutionDelay, uint256 _disputeBondAmount, address _reporter, uint256 _b ) external whenNotPaused returns (address market) { if (!whitelistedAddresses[msg.sender]) { require( IERC20(susdToken).transferFrom(msg.sender, feeRecipient, marketCreationFee), "Market creation fee transfer failed" ); } bytes memory initData = abi.encodeWithSelector( Market(address(0)).initialize.selector, Market.MarketInitParams({ outcomes: outcomes, feeRecipient: feeRecipient, resolutionDelay: _resolutionDelay, reporter: _reporter, governor: governor, b: _b, tradingFee: tradingFee, susdToken: susdToken, disputeBondAmount: _disputeBondAmount }) ); market = address(new ERC1967Proxy( marketImplementation, initData )); markets[marketId] = market; marketId++; verifiedMarkets[market] = true; emit MarketCreated( market, marketId - 1, outcomes, _resolutionDelay, _reporter, governor ); } function upgradeMarketImplementation(address newImplementation) external onlyOwner { require(newImplementation != address(0), "Invalid implementation"); marketImplementation = newImplementation; emit MarketImplementationUpgraded(newImplementation); } function setTradingFee(uint256 _tradingFee) external onlyOwner { require(_tradingFee <= 2000, "Fee too high"); // Max 20% tradingFee = _tradingFee; emit TradingFeeSet(_tradingFee); } function setFeeShares(uint256 _lpShare, uint256 _protocolShare) external onlyOwner { require(_lpShare + _protocolShare == tradingFee, "Shares must sum to trading fee"); lpShare = _lpShare; protocolShare = _protocolShare; emit FeeSharesSet(_lpShare, _protocolShare); } function addWhitelistedAddress(address account) external onlyOwner { whitelistedAddresses[account] = true; emit WhitelistedAddressAdded(account); } function removeWhitelistedAddress(address account) external onlyOwner { whitelistedAddresses[account] = false; emit WhitelistedAddressRemoved(account); } function setMarketCreationFee(uint256 _fee) external onlyOwner { marketCreationFee = _fee; emit MarketCreationFeeSet(_fee); } function setGovernor(address _governor) external onlyOwner { require(_governor != address(0), "Invalid governor"); governor = _governor; emit GovernorSet(_governor); } function getMarketAddress(uint256 _marketId) external view returns (address) { return markets[_marketId]; } function pause() external onlyOwner { _pause(); } function unpause() external onlyOwner { _unpause(); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol) pragma solidity ^0.8.20; import {ContextUpgradeable} from "../utils/ContextUpgradeable.sol"; import {Initializable} from "../proxy/utils/Initializable.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * The initial owner is set to the address provided by the deployer. This can * later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable { /// @custom:storage-location erc7201:openzeppelin.storage.Ownable struct OwnableStorage { address _owner; } // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Ownable")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant OwnableStorageLocation = 0x9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300; function _getOwnableStorage() private pure returns (OwnableStorage storage $) { assembly { $.slot := OwnableStorageLocation } } /** * @dev The caller account is not authorized to perform an operation. */ error OwnableUnauthorizedAccount(address account); /** * @dev The owner is not a valid owner account. (eg. `address(0)`) */ error OwnableInvalidOwner(address owner); event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the address provided by the deployer as the initial owner. */ function __Ownable_init(address initialOwner) internal onlyInitializing { __Ownable_init_unchained(initialOwner); } function __Ownable_init_unchained(address initialOwner) internal onlyInitializing { if (initialOwner == address(0)) { revert OwnableInvalidOwner(address(0)); } _transferOwnership(initialOwner); } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { _checkOwner(); _; } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { OwnableStorage storage $ = _getOwnableStorage(); return $._owner; } /** * @dev Throws if the sender is not the owner. */ function _checkOwner() internal view virtual { if (owner() != _msgSender()) { revert OwnableUnauthorizedAccount(_msgSender()); } } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby disabling any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { if (newOwner == address(0)) { revert OwnableInvalidOwner(address(0)); } _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { OwnableStorage storage $ = _getOwnableStorage(); address oldOwner = $._owner; $._owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/Initializable.sol) pragma solidity ^0.8.20; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in * case an upgrade adds a module that needs to be initialized. * * For example: * * [.hljs-theme-light.nopadding] * ```solidity * contract MyToken is ERC20Upgradeable { * function initialize() initializer public { * __ERC20_init("MyToken", "MTK"); * } * } * * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable { * function initializeV2() reinitializer(2) public { * __ERC20Permit_init("MyToken"); * } * } * ``` * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. * * [CAUTION] * ==== * Avoid leaving a contract uninitialized. * * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed: * * [.hljs-theme-light.nopadding] * ``` * /// @custom:oz-upgrades-unsafe-allow constructor * constructor() { * _disableInitializers(); * } * ``` * ==== */ abstract contract Initializable { /** * @dev Storage of the initializable contract. * * It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions * when using with upgradeable contracts. * * @custom:storage-location erc7201:openzeppelin.storage.Initializable */ struct InitializableStorage { /** * @dev Indicates that the contract has been initialized. */ uint64 _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool _initializing; } // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Initializable")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00; /** * @dev The contract is already initialized. */ error InvalidInitialization(); /** * @dev The contract is not initializing. */ error NotInitializing(); /** * @dev Triggered when the contract has been initialized or reinitialized. */ event Initialized(uint64 version); /** * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope, * `onlyInitializing` functions can be used to initialize parent contracts. * * Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any * number of times. This behavior in the constructor can be useful during testing and is not expected to be used in * production. * * Emits an {Initialized} event. */ modifier initializer() { // solhint-disable-next-line var-name-mixedcase InitializableStorage storage $ = _getInitializableStorage(); // Cache values to avoid duplicated sloads bool isTopLevelCall = !$._initializing; uint64 initialized = $._initialized; // Allowed calls: // - initialSetup: the contract is not in the initializing state and no previous version was // initialized // - construction: the contract is initialized at version 1 (no reininitialization) and the // current contract is just being deployed bool initialSetup = initialized == 0 && isTopLevelCall; bool construction = initialized == 1 && address(this).code.length == 0; if (!initialSetup && !construction) { revert InvalidInitialization(); } $._initialized = 1; if (isTopLevelCall) { $._initializing = true; } _; if (isTopLevelCall) { $._initializing = false; emit Initialized(1); } } /** * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be * used to initialize parent contracts. * * A reinitializer may be used after the original initialization step. This is essential to configure modules that * are added through upgrades and that require initialization. * * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer` * cannot be nested. If one is invoked in the context of another, execution will revert. * * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in * a contract, executing them in the right order is up to the developer or operator. * * WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization. * * Emits an {Initialized} event. */ modifier reinitializer(uint64 version) { // solhint-disable-next-line var-name-mixedcase InitializableStorage storage $ = _getInitializableStorage(); if ($._initializing || $._initialized >= version) { revert InvalidInitialization(); } $._initialized = version; $._initializing = true; _; $._initializing = false; emit Initialized(version); } /** * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the * {initializer} and {reinitializer} modifiers, directly or indirectly. */ modifier onlyInitializing() { _checkInitializing(); _; } /** * @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}. */ function _checkInitializing() internal view virtual { if (!_isInitializing()) { revert NotInitializing(); } } /** * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call. * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized * to any version. It is recommended to use this to lock implementation contracts that are designed to be called * through proxies. * * Emits an {Initialized} event the first time it is successfully executed. */ function _disableInitializers() internal virtual { // solhint-disable-next-line var-name-mixedcase InitializableStorage storage $ = _getInitializableStorage(); if ($._initializing) { revert InvalidInitialization(); } if ($._initialized != type(uint64).max) { $._initialized = type(uint64).max; emit Initialized(type(uint64).max); } } /** * @dev Returns the highest version that has been initialized. See {reinitializer}. */ function _getInitializedVersion() internal view returns (uint64) { return _getInitializableStorage()._initialized; } /** * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}. */ function _isInitializing() internal view returns (bool) { return _getInitializableStorage()._initializing; } /** * @dev Returns a pointer to the storage namespace. */ // solhint-disable-next-line var-name-mixedcase function _getInitializableStorage() private pure returns (InitializableStorage storage $) { assembly { $.slot := INITIALIZABLE_STORAGE } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.2.0) (proxy/utils/UUPSUpgradeable.sol) pragma solidity ^0.8.22; import {IERC1822Proxiable} from "@openzeppelin/contracts/interfaces/draft-IERC1822.sol"; import {ERC1967Utils} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Utils.sol"; import {Initializable} from "./Initializable.sol"; /** * @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an * {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy. * * A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is * reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing * `UUPSUpgradeable` with a custom implementation of upgrades. * * The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism. */ abstract contract UUPSUpgradeable is Initializable, IERC1822Proxiable { /// @custom:oz-upgrades-unsafe-allow state-variable-immutable address private immutable __self = address(this); /** * @dev The version of the upgrade interface of the contract. If this getter is missing, both `upgradeTo(address)` * and `upgradeToAndCall(address,bytes)` are present, and `upgradeTo` must be used if no function should be called, * while `upgradeToAndCall` will invoke the `receive` function if the second argument is the empty byte string. * If the getter returns `"5.0.0"`, only `upgradeToAndCall(address,bytes)` is present, and the second argument must * be the empty byte string if no function should be called, making it impossible to invoke the `receive` function * during an upgrade. */ string public constant UPGRADE_INTERFACE_VERSION = "5.0.0"; /** * @dev The call is from an unauthorized context. */ error UUPSUnauthorizedCallContext(); /** * @dev The storage `slot` is unsupported as a UUID. */ error UUPSUnsupportedProxiableUUID(bytes32 slot); /** * @dev Check that the execution is being performed through a delegatecall call and that the execution context is * a proxy contract with an implementation (as defined in ERC-1967) pointing to self. This should only be the case * for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a * function through ERC-1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to * fail. */ modifier onlyProxy() { _checkProxy(); _; } /** * @dev Check that the execution is not being performed through a delegate call. This allows a function to be * callable on the implementing contract but not through proxies. */ modifier notDelegated() { _checkNotDelegated(); _; } function __UUPSUpgradeable_init() internal onlyInitializing { } function __UUPSUpgradeable_init_unchained() internal onlyInitializing { } /** * @dev Implementation of the ERC-1822 {proxiableUUID} function. This returns the storage slot used by the * implementation. It is used to validate the implementation's compatibility when performing an upgrade. * * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this * function revert if invoked through a proxy. This is guaranteed by the `notDelegated` modifier. */ function proxiableUUID() external view virtual notDelegated returns (bytes32) { return ERC1967Utils.IMPLEMENTATION_SLOT; } /** * @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call * encoded in `data`. * * Calls {_authorizeUpgrade}. * * Emits an {Upgraded} event. * * @custom:oz-upgrades-unsafe-allow-reachable delegatecall */ function upgradeToAndCall(address newImplementation, bytes memory data) public payable virtual onlyProxy { _authorizeUpgrade(newImplementation); _upgradeToAndCallUUPS(newImplementation, data); } /** * @dev Reverts if the execution is not performed via delegatecall or the execution * context is not of a proxy with an ERC-1967 compliant implementation pointing to self. * See {_onlyProxy}. */ function _checkProxy() internal view virtual { if ( address(this) == __self || // Must be called through delegatecall ERC1967Utils.getImplementation() != __self // Must be called through an active proxy ) { revert UUPSUnauthorizedCallContext(); } } /** * @dev Reverts if the execution is performed via delegatecall. * See {notDelegated}. */ function _checkNotDelegated() internal view virtual { if (address(this) != __self) { // Must not be called through delegatecall revert UUPSUnauthorizedCallContext(); } } /** * @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by * {upgradeToAndCall}. * * Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}. * * ```solidity * function _authorizeUpgrade(address) internal onlyOwner {} * ``` */ function _authorizeUpgrade(address newImplementation) internal virtual; /** * @dev Performs an implementation upgrade with a security check for UUPS proxies, and additional setup call. * * As a security check, {proxiableUUID} is invoked in the new implementation, and the return value * is expected to be the implementation slot in ERC-1967. * * Emits an {IERC1967-Upgraded} event. */ function _upgradeToAndCallUUPS(address newImplementation, bytes memory data) private { try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) { if (slot != ERC1967Utils.IMPLEMENTATION_SLOT) { revert UUPSUnsupportedProxiableUUID(slot); } ERC1967Utils.upgradeToAndCall(newImplementation, data); } catch { // The implementation is not UUPS revert ERC1967Utils.ERC1967InvalidImplementation(newImplementation); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol) pragma solidity ^0.8.20; import {Initializable} from "../proxy/utils/Initializable.sol"; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract ContextUpgradeable is Initializable { function __Context_init() internal onlyInitializing { } function __Context_init_unchained() internal onlyInitializing { } function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } function _contextSuffixLength() internal view virtual returns (uint256) { return 0; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/Pausable.sol) pragma solidity ^0.8.20; import {ContextUpgradeable} from "../utils/ContextUpgradeable.sol"; import {Initializable} from "../proxy/utils/Initializable.sol"; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ abstract contract PausableUpgradeable is Initializable, ContextUpgradeable { /// @custom:storage-location erc7201:openzeppelin.storage.Pausable struct PausableStorage { bool _paused; } // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Pausable")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant PausableStorageLocation = 0xcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f03300; function _getPausableStorage() private pure returns (PausableStorage storage $) { assembly { $.slot := PausableStorageLocation } } /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); /** * @dev The operation failed because the contract is paused. */ error EnforcedPause(); /** * @dev The operation failed because the contract is not paused. */ error ExpectedPause(); /** * @dev Initializes the contract in unpaused state. */ function __Pausable_init() internal onlyInitializing { __Pausable_init_unchained(); } function __Pausable_init_unchained() internal onlyInitializing { PausableStorage storage $ = _getPausableStorage(); $._paused = false; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { _requireNotPaused(); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { _requirePaused(); _; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { PausableStorage storage $ = _getPausableStorage(); return $._paused; } /** * @dev Throws if the contract is paused. */ function _requireNotPaused() internal view virtual { if (paused()) { revert EnforcedPause(); } } /** * @dev Throws if the contract is not paused. */ function _requirePaused() internal view virtual { if (!paused()) { revert ExpectedPause(); } } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { PausableStorage storage $ = _getPausableStorage(); $._paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { PausableStorage storage $ = _getPausableStorage(); $._paused = false; emit Unpaused(_msgSender()); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/ReentrancyGuard.sol) pragma solidity ^0.8.20; import {Initializable} from "../proxy/utils/Initializable.sol"; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If EIP-1153 (transient storage) is available on the chain you're deploying at, * consider using {ReentrancyGuardTransient} instead. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuardUpgradeable is Initializable { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant NOT_ENTERED = 1; uint256 private constant ENTERED = 2; /// @custom:storage-location erc7201:openzeppelin.storage.ReentrancyGuard struct ReentrancyGuardStorage { uint256 _status; } // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.ReentrancyGuard")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant ReentrancyGuardStorageLocation = 0x9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00; function _getReentrancyGuardStorage() private pure returns (ReentrancyGuardStorage storage $) { assembly { $.slot := ReentrancyGuardStorageLocation } } /** * @dev Unauthorized reentrant call. */ error ReentrancyGuardReentrantCall(); function __ReentrancyGuard_init() internal onlyInitializing { __ReentrancyGuard_init_unchained(); } function __ReentrancyGuard_init_unchained() internal onlyInitializing { ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage(); $._status = NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and making it call a * `private` function that does the actual work. */ modifier nonReentrant() { _nonReentrantBefore(); _; _nonReentrantAfter(); } function _nonReentrantBefore() private { ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage(); // On the first call to nonReentrant, _status will be NOT_ENTERED if ($._status == ENTERED) { revert ReentrancyGuardReentrantCall(); } // Any calls to nonReentrant after this point will fail $._status = ENTERED; } function _nonReentrantAfter() private { ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage(); // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) $._status = NOT_ENTERED; } /** * @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a * `nonReentrant` function in the call stack. */ function _reentrancyGuardEntered() internal view returns (bool) { ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage(); return $._status == ENTERED; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (interfaces/draft-IERC1822.sol) pragma solidity ^0.8.20; /** * @dev ERC-1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified * proxy whose upgrades are fully controlled by the current implementation. */ interface IERC1822Proxiable { /** * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation * address. * * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this * function revert if invoked through a proxy. */ function proxiableUUID() external view returns (bytes32); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC1967.sol) pragma solidity ^0.8.20; /** * @dev ERC-1967: Proxy Storage Slots. This interface contains the events defined in the ERC. */ interface IERC1967 { /** * @dev Emitted when the implementation is upgraded. */ event Upgraded(address indexed implementation); /** * @dev Emitted when the admin account has changed. */ event AdminChanged(address previousAdmin, address newAdmin); /** * @dev Emitted when the beacon is changed. */ event BeaconUpgraded(address indexed beacon); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (proxy/beacon/IBeacon.sol) pragma solidity ^0.8.20; /** * @dev This is the interface that {BeaconProxy} expects of its beacon. */ interface IBeacon { /** * @dev Must return an address that can be used as a delegate call target. * * {UpgradeableBeacon} will check that this address is a contract. */ function implementation() external view returns (address); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.2.0) (proxy/ERC1967/ERC1967Proxy.sol) pragma solidity ^0.8.22; import {Proxy} from "../Proxy.sol"; import {ERC1967Utils} from "./ERC1967Utils.sol"; /** * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an * implementation address that can be changed. This address is stored in storage in the location specified by * https://eips.ethereum.org/EIPS/eip-1967[ERC-1967], so that it doesn't conflict with the storage layout of the * implementation behind the proxy. */ contract ERC1967Proxy is Proxy { /** * @dev Initializes the upgradeable proxy with an initial implementation specified by `implementation`. * * If `_data` is nonempty, it's used as data in a delegate call to `implementation`. This will typically be an * encoded function call, and allows initializing the storage of the proxy like a Solidity constructor. * * Requirements: * * - If `data` is empty, `msg.value` must be zero. */ constructor(address implementation, bytes memory _data) payable { ERC1967Utils.upgradeToAndCall(implementation, _data); } /** * @dev Returns the current implementation address. * * TIP: To get this value clients can read directly from the storage slot shown below (specified by ERC-1967) using * the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc` */ function _implementation() internal view virtual override returns (address) { return ERC1967Utils.getImplementation(); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.2.0) (proxy/ERC1967/ERC1967Utils.sol) pragma solidity ^0.8.22; import {IBeacon} from "../beacon/IBeacon.sol"; import {IERC1967} from "../../interfaces/IERC1967.sol"; import {Address} from "../../utils/Address.sol"; import {StorageSlot} from "../../utils/StorageSlot.sol"; /** * @dev This library provides getters and event emitting update functions for * https://eips.ethereum.org/EIPS/eip-1967[ERC-1967] slots. */ library ERC1967Utils { /** * @dev Storage slot with the address of the current implementation. * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1. */ // solhint-disable-next-line private-vars-leading-underscore bytes32 internal constant IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; /** * @dev The `implementation` of the proxy is invalid. */ error ERC1967InvalidImplementation(address implementation); /** * @dev The `admin` of the proxy is invalid. */ error ERC1967InvalidAdmin(address admin); /** * @dev The `beacon` of the proxy is invalid. */ error ERC1967InvalidBeacon(address beacon); /** * @dev An upgrade function sees `msg.value > 0` that may be lost. */ error ERC1967NonPayable(); /** * @dev Returns the current implementation address. */ function getImplementation() internal view returns (address) { return StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value; } /** * @dev Stores a new address in the ERC-1967 implementation slot. */ function _setImplementation(address newImplementation) private { if (newImplementation.code.length == 0) { revert ERC1967InvalidImplementation(newImplementation); } StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value = newImplementation; } /** * @dev Performs implementation upgrade with additional setup call if data is nonempty. * This function is payable only if the setup call is performed, otherwise `msg.value` is rejected * to avoid stuck value in the contract. * * Emits an {IERC1967-Upgraded} event. */ function upgradeToAndCall(address newImplementation, bytes memory data) internal { _setImplementation(newImplementation); emit IERC1967.Upgraded(newImplementation); if (data.length > 0) { Address.functionDelegateCall(newImplementation, data); } else { _checkNonPayable(); } } /** * @dev Storage slot with the admin of the contract. * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1. */ // solhint-disable-next-line private-vars-leading-underscore bytes32 internal constant ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103; /** * @dev Returns the current admin. * * TIP: To get this value clients can read directly from the storage slot shown below (specified by ERC-1967) using * the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103` */ function getAdmin() internal view returns (address) { return StorageSlot.getAddressSlot(ADMIN_SLOT).value; } /** * @dev Stores a new address in the ERC-1967 admin slot. */ function _setAdmin(address newAdmin) private { if (newAdmin == address(0)) { revert ERC1967InvalidAdmin(address(0)); } StorageSlot.getAddressSlot(ADMIN_SLOT).value = newAdmin; } /** * @dev Changes the admin of the proxy. * * Emits an {IERC1967-AdminChanged} event. */ function changeAdmin(address newAdmin) internal { emit IERC1967.AdminChanged(getAdmin(), newAdmin); _setAdmin(newAdmin); } /** * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy. * This is the keccak-256 hash of "eip1967.proxy.beacon" subtracted by 1. */ // solhint-disable-next-line private-vars-leading-underscore bytes32 internal constant BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50; /** * @dev Returns the current beacon. */ function getBeacon() internal view returns (address) { return StorageSlot.getAddressSlot(BEACON_SLOT).value; } /** * @dev Stores a new beacon in the ERC-1967 beacon slot. */ function _setBeacon(address newBeacon) private { if (newBeacon.code.length == 0) { revert ERC1967InvalidBeacon(newBeacon); } StorageSlot.getAddressSlot(BEACON_SLOT).value = newBeacon; address beaconImplementation = IBeacon(newBeacon).implementation(); if (beaconImplementation.code.length == 0) { revert ERC1967InvalidImplementation(beaconImplementation); } } /** * @dev Change the beacon and trigger a setup call if data is nonempty. * This function is payable only if the setup call is performed, otherwise `msg.value` is rejected * to avoid stuck value in the contract. * * Emits an {IERC1967-BeaconUpgraded} event. * * CAUTION: Invoking this function has no effect on an instance of {BeaconProxy} since v5, since * it uses an immutable beacon without looking at the value of the ERC-1967 beacon slot for * efficiency. */ function upgradeBeaconToAndCall(address newBeacon, bytes memory data) internal { _setBeacon(newBeacon); emit IERC1967.BeaconUpgraded(newBeacon); if (data.length > 0) { Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data); } else { _checkNonPayable(); } } /** * @dev Reverts if `msg.value` is not zero. It can be used to avoid `msg.value` stuck in the contract * if an upgrade doesn't perform an initialization call. */ function _checkNonPayable() private { if (msg.value > 0) { revert ERC1967NonPayable(); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (proxy/Proxy.sol) pragma solidity ^0.8.20; /** * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to * be specified by overriding the virtual {_implementation} function. * * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a * different contract through the {_delegate} function. * * The success and return data of the delegated call will be returned back to the caller of the proxy. */ abstract contract Proxy { /** * @dev Delegates the current call to `implementation`. * * This function does not return to its internal call site, it will return directly to the external caller. */ function _delegate(address implementation) internal virtual { assembly { // Copy msg.data. We take full control of memory in this inline assembly // block because it will not return to Solidity code. We overwrite the // Solidity scratch pad at memory position 0. calldatacopy(0, 0, calldatasize()) // Call the implementation. // out and outsize are 0 because we don't know the size yet. let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0) // Copy the returned data. returndatacopy(0, 0, returndatasize()) switch result // delegatecall returns 0 on error. case 0 { revert(0, returndatasize()) } default { return(0, returndatasize()) } } } /** * @dev This is a virtual function that should be overridden so it returns the address to which the fallback * function and {_fallback} should delegate. */ function _implementation() internal view virtual returns (address); /** * @dev Delegates the current call to the address returned by `_implementation()`. * * This function does not return to its internal call site, it will return directly to the external caller. */ function _fallback() internal virtual { _delegate(_implementation()); } /** * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other * function in the contract matches the call data. */ fallback() external payable virtual { _fallback(); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC-20 standard as defined in the ERC. */ interface IERC20 { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the value of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the value of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves a `value` amount of tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 value) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets a `value` amount of tokens as the allowance of `spender` over the * caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 value) external returns (bool); /** * @dev Moves a `value` amount of tokens from `from` to `to` using the * allowance mechanism. `value` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 value) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.2.0) (utils/Address.sol) pragma solidity ^0.8.20; import {Errors} from "./Errors.sol"; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev There's no code at `target` (it is not a contract). */ error AddressEmptyCode(address target); /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { if (address(this).balance < amount) { revert Errors.InsufficientBalance(address(this).balance, amount); } (bool success, bytes memory returndata) = recipient.call{value: amount}(""); if (!success) { _revert(returndata); } } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason or custom error, it is bubbled * up by this function (like regular Solidity function calls). However, if * the call reverted with no returned reason, this function reverts with a * {Errors.FailedCall} error. * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { if (address(this).balance < value) { revert Errors.InsufficientBalance(address(this).balance, value); } (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target * was not a contract or bubbling up the revert reason (falling back to {Errors.FailedCall}) in case * of an unsuccessful call. */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata ) internal view returns (bytes memory) { if (!success) { _revert(returndata); } else { // only check if target is a contract if the call was successful and the return data is empty // otherwise we already know that it was a contract if (returndata.length == 0 && target.code.length == 0) { revert AddressEmptyCode(target); } return returndata; } } /** * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the * revert reason or with a default {Errors.FailedCall} error. */ function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) { if (!success) { _revert(returndata); } else { return returndata; } } /** * @dev Reverts with returndata if present. Otherwise reverts with {Errors.FailedCall}. */ function _revert(bytes memory returndata) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly ("memory-safe") { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert Errors.FailedCall(); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/Errors.sol) pragma solidity ^0.8.20; /** * @dev Collection of common custom errors used in multiple contracts * * IMPORTANT: Backwards compatibility is not guaranteed in future versions of the library. * It is recommended to avoid relying on the error API for critical functionality. * * _Available since v5.1._ */ library Errors { /** * @dev The ETH balance of the account is not enough to perform the operation. */ error InsufficientBalance(uint256 balance, uint256 needed); /** * @dev A call to an address target failed. The target may have reverted. */ error FailedCall(); /** * @dev The deployment failed. */ error FailedDeployment(); /** * @dev A necessary precompile is missing. */ error MissingPrecompile(address); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/StorageSlot.sol) // This file was procedurally generated from scripts/generate/templates/StorageSlot.js. pragma solidity ^0.8.20; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC-1967 implementation slot: * ```solidity * contract ERC1967 { * // Define the slot. Alternatively, use the SlotDerivation library to derive the slot. * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(newImplementation.code.length > 0); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` * * TIP: Consider using this library along with {SlotDerivation}. */ library StorageSlot { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } struct Int256Slot { int256 value; } struct StringSlot { string value; } struct BytesSlot { bytes value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { assembly ("memory-safe") { r.slot := slot } } /** * @dev Returns a `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { assembly ("memory-safe") { r.slot := slot } } /** * @dev Returns a `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { assembly ("memory-safe") { r.slot := slot } } /** * @dev Returns a `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { assembly ("memory-safe") { r.slot := slot } } /** * @dev Returns a `Int256Slot` with member `value` located at `slot`. */ function getInt256Slot(bytes32 slot) internal pure returns (Int256Slot storage r) { assembly ("memory-safe") { r.slot := slot } } /** * @dev Returns a `StringSlot` with member `value` located at `slot`. */ function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) { assembly ("memory-safe") { r.slot := slot } } /** * @dev Returns an `StringSlot` representation of the string storage pointer `store`. */ function getStringSlot(string storage store) internal pure returns (StringSlot storage r) { assembly ("memory-safe") { r.slot := store.slot } } /** * @dev Returns a `BytesSlot` with member `value` located at `slot`. */ function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) { assembly ("memory-safe") { r.slot := slot } } /** * @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`. */ function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) { assembly ("memory-safe") { r.slot := store.slot } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.19; library LMSRMath { // Fixed point precision uint256 constant FIXED_ONE = 1e18; // Maximum value for exponentiation to avoid overflow uint256 constant MAX_EXPONENT = 100e18; function calcCost( uint256[] memory outcomeShares, int256[] memory shareDeltas, uint256 b ) internal pure returns (int256) { require(outcomeShares.length == shareDeltas.length, "Array length mismatch"); require(outcomeShares.length > 0, "Empty arrays"); require(b > 0, "Invalid liquidity parameter"); // Calculate cost before trade uint256 costBefore = calcCostFromShares(outcomeShares, b); // Calculate new outcome shares after trade uint256[] memory newShares = new uint256[](outcomeShares.length); for (uint256 i = 0; i < outcomeShares.length; i++) { if (shareDeltas[i] >= 0) { newShares[i] = outcomeShares[i] + uint256(shareDeltas[i]); } else { require(outcomeShares[i] >= uint256(-shareDeltas[i]), "Insufficient shares"); newShares[i] = outcomeShares[i] - uint256(-shareDeltas[i]); } } // Calculate cost after trade uint256 costAfter = calcCostFromShares(newShares, b); // Return difference in costs if (costAfter >= costBefore) { return int256(costAfter - costBefore); } else { return -int256(costBefore - costAfter); } } function calcCostFromShares( uint256[] memory shares, uint256 b ) internal pure returns (uint256) { uint256 sum = 0; // Calculate sum of exp(q_i/b) for all outcomes for (uint256 i = 0; i < shares.length; i++) { // Normalize shares by dividing by b uint256 normalizedShares = (shares[i] * FIXED_ONE) / b; // Prevent overflow by capping the exponent if (normalizedShares > MAX_EXPONENT) { normalizedShares = MAX_EXPONENT; } // Calculate exp(q_i/b) and add to sum sum += exp(normalizedShares); } // Calculate b * ln(sum) return (b * ln(sum)) / FIXED_ONE; } function calcMarginalPrice( uint256 outcomeIndex, uint256[] memory shares, uint256 b ) internal pure returns (uint256) { require(outcomeIndex < shares.length, "Invalid outcome index"); // Calculate sum of exp(q_i/b) for all outcomes uint256 sum = 0; for (uint256 i = 0; i < shares.length; i++) { uint256 normalizedShares = (shares[i] * FIXED_ONE) / b; if (normalizedShares > MAX_EXPONENT) { normalizedShares = MAX_EXPONENT; } sum += exp(normalizedShares); } // Calculate exp(q_i/b) for the specific outcome uint256 normalizedOutcomeShares = (shares[outcomeIndex] * FIXED_ONE) / b; if (normalizedOutcomeShares > MAX_EXPONENT) { normalizedOutcomeShares = MAX_EXPONENT; } uint256 outcomeExp = exp(normalizedOutcomeShares); // Calculate price = exp(q_i/b) / sum(exp(q_j/b)) return (outcomeExp * FIXED_ONE) / sum; } function exp(uint256 x) internal pure returns (uint256) { // If x is 0, e^0 = 1 if (x == 0) return FIXED_ONE; // If x is very large, return maximum value to avoid overflow if (x > MAX_EXPONENT) return type(uint256).max; // Taylor series approximation for e^x // e^x = 1 + x + x^2/2! + x^3/3! + ... + x^n/n! uint256 result = FIXED_ONE; // 1 uint256 term = FIXED_ONE; // Start with 1 // Add x term = (term * x) / FIXED_ONE; result += term; // Add x^2/2! term = (term * x) / (2 * FIXED_ONE); result += term; // Add x^3/3! term = (term * x) / (3 * FIXED_ONE); result += term; // Add x^4/4! term = (term * x) / (4 * FIXED_ONE); result += term; // Add x^5/5! term = (term * x) / (5 * FIXED_ONE); result += term; // Add x^6/6! term = (term * x) / (6 * FIXED_ONE); result += term; // Add x^7/7! term = (term * x) / (7 * FIXED_ONE); result += term; // Add x^8/8! term = (term * x) / (8 * FIXED_ONE); result += term; return result; } function ln(uint256 x) internal pure returns (uint256) { // If x is 0 or very small, return a very negative number // In practice, this should never happen in LMSR if (x < FIXED_ONE / 1000) { return 0; // Should revert in practice } // If x is 1, ln(1) = 0 if (x == FIXED_ONE) return 0; // If x < 1, use ln(x) = -ln(1/x) if (x < FIXED_ONE) { return type(uint256).max - ln((FIXED_ONE * FIXED_ONE) / x) + 1; } // For x > 1, use binary search to find y such that e^y = x uint256 low = 0; uint256 high = MAX_EXPONENT; uint256 mid; uint256 midExp; // Binary search for 32 iterations (sufficient precision) for (uint256 i = 0; i < 32; i++) { mid = (low + high) / 2; midExp = exp(mid); if (midExp < x) { low = mid; } else if (midExp > x) { high = mid; } else { return mid; // Exact match found } } // Return the closest approximation return (low + high) / 2; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.19; import "@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "./LMSRMath.sol"; contract Market is Initializable, ReentrancyGuardUpgradeable, PausableUpgradeable, UUPSUpgradeable, OwnableUpgradeable { // State variables address public factory; address public feeRecipient; address public reporter; address public governor; address public susdToken; uint256 public b; uint256 public resolutionDelay; string[] public outcomes; // Mutable state variables mapping(uint256 => uint256) public outcomeShares; mapping(address => mapping(uint256 => uint256)) public userShares; bool public resolved; uint256 public winningOutcome; uint256 public resolutionTimestamp; uint256 public totalFunding; uint256 public funding; uint256 public tradingFee; // Dispute mechanism variables uint256 public constant DISPUTE_PERIOD = 3 days; uint256 public reporterResolutionDeadline; mapping(uint256 => uint256) public disputeVotes; uint256 public mostVotedOutcome; uint256 public totalVotes; mapping(address => bool) public hasVoted; mapping(address => uint256) public disputeBonds; uint256 public disputeBondAmount; // Fixed point precision uint256 private constant FIXED_ONE = 1e18; // Maximum trade size as percentage of liquidity uint256 public constant MAX_TRADE_PERCENTAGE = 20; // 20% of liquidity // Events event Trade(address indexed user, int256[] amounts, uint256[] shareBalances, uint256 feesPaid); event MarketResolved(uint256 indexed outcome); event Payout(address indexed user, uint256 amount); event ResolutionProposed(uint256 indexed outcome, uint256 resolutionTimestamp); event TradingFeeSet(uint256 newFee); event DisputeSubmitted(address indexed disputer, uint256 indexed proposedOutcome, uint256 bondAmount); event VoteCast(address indexed voter, uint256 indexed outcome); event ReporterDeadlineSet(uint256 deadline); event EmergencyResolution(uint256 indexed outcome, address resolver); /// @custom:oz-upgrades-unsafe-allow constructor constructor() { _disableInitializers(); } struct MarketInitParams { string[] outcomes; address feeRecipient; uint256 resolutionDelay; address reporter; address governor; uint256 b; uint256 tradingFee; address susdToken; uint256 disputeBondAmount; } function initialize(MarketInitParams calldata params) external initializer { __ReentrancyGuard_init(); __Pausable_init(); __Ownable_init(params.governor); __UUPSUpgradeable_init(); require(params.outcomes.length >= 2, "Must have at least 2 outcomes"); require(params.feeRecipient != address(0), "Invalid fee recipient"); require(params.reporter != address(0), "Invalid reporter"); require(params.governor != address(0), "Invalid governor"); require(params.susdToken != address(0), "Invalid SUSD token"); require(params.b > 0, "Invalid liquidity parameter"); factory = msg.sender; feeRecipient = params.feeRecipient; reporter = params.reporter; governor = params.governor; susdToken = params.susdToken; b = params.b; resolutionDelay = params.resolutionDelay; tradingFee = params.tradingFee; disputeBondAmount = params.disputeBondAmount; for (uint256 i = 0; i < params.outcomes.length; i++) { outcomes.push(params.outcomes[i]); outcomeShares[i] = 1e18; } reporterResolutionDeadline = block.timestamp + 30 days; emit ReporterDeadlineSet(reporterResolutionDeadline); // Transfer ownership to the governor // _transferOwnership(_governor); } function _authorizeUpgrade(address newImplementation) internal override onlyOwner {} // Modifiers modifier onlyReporter() { require(msg.sender == reporter, "Only reporter can call this function"); _; } modifier onlyGovernor() { require(msg.sender == governor, "Only governor can call this function"); _; } modifier onlyFactory() { require(msg.sender == factory, "Only factory can call this function"); _; } // Existing Market contract functions function getCurrentShares() public view returns (uint256[] memory) { uint256[] memory shares = new uint256[](outcomes.length); for (uint256 i = 0; i < outcomes.length; i++) { shares[i] = outcomeShares[i]; } return shares; } function getCost(int256[] memory shareDeltas) public view returns (int256) { require(shareDeltas.length == outcomes.length, "Invalid array length"); // Get current shares uint256[] memory shares = getCurrentShares(); // Calculate cost using LMSR math return LMSRMath.calcCost(shares, shareDeltas, b); } function getNetCost(int256[] memory shareDeltas) public view returns (uint256) { int256 cost = getCost(shareDeltas); // If cost is negative (selling), return 0 as net cost if (cost <= 0) return 0; // Apply trading fee uint256 fee = (uint256(cost) * tradingFee) / 10000; return uint256(cost) + fee; } function getMarginalPrice(uint256 outcomeIndex) public view returns (uint256) { require(outcomeIndex < outcomes.length, "Invalid outcome index"); uint256[] memory shares = getCurrentShares(); return LMSRMath.calcMarginalPrice(outcomeIndex, shares, b); } function trade(int256[] calldata shareDeltas, uint256 maxCost) external nonReentrant whenNotPaused { // CHECKS require(!resolved, "Market already resolved"); require(shareDeltas.length == outcomes.length, "Invalid array length"); // Validate trade size to prevent manipulation uint256[] memory shares = getCurrentShares(); for (uint256 i = 0; i < shareDeltas.length; i++) { if (shareDeltas[i] > 0) { // Ensure buy orders don't exceed maximum percentage of current market shares require( uint256(shareDeltas[i]) <= (shares[i] * MAX_TRADE_PERCENTAGE) / 100, "Trade size too large" ); } else if (shareDeltas[i] < 0) { // Ensure sell orders don't exceed user's balance require( uint256(-shareDeltas[i]) <= userShares[msg.sender][i], "Insufficient shares" ); } } // Calculate cost using LMSR int256 cost = getCost(shareDeltas); // Apply trading fee (only for buys) uint256 fee = 0; uint256 tradeTotalCost = 0; if (cost > 0) { fee = (uint256(cost) * tradingFee) / 10000; tradeTotalCost = uint256(cost) + fee; // Slippage protection require(tradeTotalCost <= maxCost, "Slippage exceeded"); } // EFFECTS // Update state variables for (uint256 i = 0; i < shareDeltas.length; i++) { if (shareDeltas[i] > 0) { outcomeShares[i] += uint256(shareDeltas[i]); userShares[msg.sender][i] += uint256(shareDeltas[i]); } else if (shareDeltas[i] < 0) { outcomeShares[i] -= uint256(-shareDeltas[i]); userShares[msg.sender][i] -= uint256(-shareDeltas[i]); } } if (cost > 0) { funding += uint256(cost); totalFunding += uint256(cost) + fee; } // INTERACTIONS if (cost > 0) { // User is buying, transfer SUSD from user require( IERC20(susdToken).transferFrom(msg.sender, address(this), uint256(cost)), "Trade transfer failed" ); // Transfer fee if (fee > 0) { require( IERC20(susdToken).transferFrom(msg.sender, feeRecipient, fee), "Fee transfer failed" ); } } else if (cost < 0) { // User is selling, transfer SUSD to user require( IERC20(susdToken).transfer(msg.sender, uint256(-cost)), "Payout transfer failed" ); } // Get updated share balances for the event uint256[] memory newBalances = getCurrentShares(); emit Trade(msg.sender, shareDeltas, newBalances, fee); } function resolveMarket(uint256 outcome) external onlyReporter { require(!resolved, "Market already resolved"); require(block.timestamp >= reporterResolutionDeadline, "Too early"); require(outcome < outcomes.length, "Invalid outcome"); winningOutcome = outcome; resolutionTimestamp = block.timestamp; resolved = true; emit ResolutionProposed(outcome, resolutionTimestamp); emit MarketResolved(outcome); } function overrideResolution(uint256 outcome) external onlyGovernor { require(!resolved, "Market already resolved"); require(block.timestamp < resolutionTimestamp, "Dispute period ended"); require(outcome < outcomes.length, "Invalid outcome"); resolved = true; winningOutcome = outcome; resolutionTimestamp = 0; emit MarketResolved(outcome); } function payout() external nonReentrant { require(resolved, "Market not resolved"); uint256 shares = userShares[msg.sender][winningOutcome]; require(shares > 0, "No winning shares"); uint256 payoutAmount = shares; userShares[msg.sender][winningOutcome] = 0; require(IERC20(susdToken).transfer(msg.sender, payoutAmount), "Payout transfer failed"); emit Payout(msg.sender, payoutAmount); } // Dispute mechanism for users function submitDispute(uint256 proposedOutcome) external nonReentrant { require(!resolved, "Market already resolved"); require(proposedOutcome < outcomes.length, "Invalid outcome"); require(!hasVoted[msg.sender], "Already voted"); require(block.timestamp <= resolutionTimestamp + DISPUTE_PERIOD, "Dispute period ended"); require(IERC20(susdToken).transferFrom(msg.sender, address(this), disputeBondAmount), "Bond transfer failed"); disputeBonds[msg.sender] = disputeBondAmount; disputeVotes[proposedOutcome] += disputeBondAmount; totalVotes += disputeBondAmount; hasVoted[msg.sender] = true; if (disputeVotes[proposedOutcome] > disputeVotes[mostVotedOutcome]) { mostVotedOutcome = proposedOutcome; } emit DisputeSubmitted(msg.sender, proposedOutcome, disputeBondAmount); emit VoteCast(msg.sender, proposedOutcome); } function finalizeDispute() external nonReentrant { require(!resolved, "Market already resolved"); require(block.timestamp > resolutionTimestamp + DISPUTE_PERIOD, "Dispute period not ended"); require(totalVotes > 0, "No disputes submitted"); winningOutcome = mostVotedOutcome; resolved = true; emit MarketResolved(mostVotedOutcome); } function claimDisputeBond() external nonReentrant { require(resolved, "Market not resolved"); require(disputeBonds[msg.sender] > 0, "No bond to claim"); require(block.timestamp > resolutionTimestamp + DISPUTE_PERIOD, "Dispute period not ended"); uint256 bondAmount = disputeBonds[msg.sender]; disputeBonds[msg.sender] = 0; // If voted for winning outcome, get reward from losing votes if (hasVoted[msg.sender]) { uint256 shareOfWinningVotes = (bondAmount * 1e18) / disputeVotes[winningOutcome]; bondAmount += (totalVotes - disputeVotes[winningOutcome]) * shareOfWinningVotes / 1e18; } require(IERC20(susdToken).transfer(msg.sender, bondAmount), "Bond return failed"); } // Emergency resolution if reporter never resolves function emergencyResolve() external { require(!resolved, "Market already resolved"); require(block.timestamp > reporterResolutionDeadline, "Reporter deadline not passed"); // If disputes exist, use most voted outcome uint256 finalOutcome = totalVotes > 0 ? mostVotedOutcome : 0; resolved = true; winningOutcome = finalOutcome; emit EmergencyResolution(finalOutcome, msg.sender); emit MarketResolved(finalOutcome); } // Allow governor to set a new reporter deadline function setReporterDeadline(uint256 newDeadline) external onlyGovernor { require(newDeadline > block.timestamp, "Deadline must be in future"); reporterResolutionDeadline = newDeadline; emit ReporterDeadlineSet(newDeadline); } function verifyInitialization( string[] calldata _outcomes, uint256 _resolutionDelay, address _reporter, address _governor ) external view returns (bool) { // Verify that initialization parameters match if (_outcomes.length != outcomes.length) return false; if (_reporter != reporter) return false; if (_governor != governor) return false; if (_resolutionDelay != resolutionDelay) return false; // Verify outcomes match for (uint256 i = 0; i < _outcomes.length; i++) { if (keccak256(bytes(_outcomes[i])) != keccak256(bytes(outcomes[i]))) { return false; } } return true; } // View functions function getMarketInfo() external view returns ( string[] memory, uint256[] memory, uint256, bool, uint256 ) { uint256[] memory shares = getCurrentShares(); return (outcomes, shares, b, resolved, winningOutcome); } function getResolutionDelay() external view returns (uint256) { return resolutionDelay; } function getProposedOutcome() external view returns (uint256) { return winningOutcome; } function getResolutionTimestamp() external view returns (uint256) { return resolutionTimestamp; } function getReporter() external view returns (address) { return reporter; } function getGovernor() external view returns (address) { return governor; } function getAIAddress() external view returns (address) { return address(this); } function getTradingFee() external view returns (uint256) { return tradingFee; } // Pause/unpause functions function pause() external onlyOwner { _pause(); } function unpause() external onlyOwner { _unpause(); } }
{ "optimizer": { "enabled": true, "runs": 200 }, "evmVersion": "paris", "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":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"target","type":"address"}],"name":"AddressEmptyCode","type":"error"},{"inputs":[{"internalType":"address","name":"implementation","type":"address"}],"name":"ERC1967InvalidImplementation","type":"error"},{"inputs":[],"name":"ERC1967NonPayable","type":"error"},{"inputs":[],"name":"EnforcedPause","type":"error"},{"inputs":[],"name":"ExpectedPause","type":"error"},{"inputs":[],"name":"FailedCall","type":"error"},{"inputs":[],"name":"InvalidInitialization","type":"error"},{"inputs":[],"name":"NotInitializing","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"OwnableInvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"OwnableUnauthorizedAccount","type":"error"},{"inputs":[],"name":"UUPSUnauthorizedCallContext","type":"error"},{"inputs":[{"internalType":"bytes32","name":"slot","type":"bytes32"}],"name":"UUPSUnsupportedProxiableUUID","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"newLpShare","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newProtocolShare","type":"uint256"}],"name":"FeeSharesSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"newGovernor","type":"address"}],"name":"GovernorSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"version","type":"uint64"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"market","type":"address"},{"indexed":true,"internalType":"uint256","name":"marketId","type":"uint256"},{"indexed":false,"internalType":"string[]","name":"outcomes","type":"string[]"},{"indexed":false,"internalType":"uint256","name":"resolutionDelay","type":"uint256"},{"indexed":false,"internalType":"address","name":"reporter","type":"address"},{"indexed":false,"internalType":"address","name":"governor","type":"address"}],"name":"MarketCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"newFee","type":"uint256"}],"name":"MarketCreationFeeSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"newImplementation","type":"address"}],"name":"MarketImplementationUpgraded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"market","type":"address"},{"indexed":false,"internalType":"bool","name":"verified","type":"bool"}],"name":"MarketVerified","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":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"newTradingFee","type":"uint256"}],"name":"TradingFeeSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"implementation","type":"address"}],"name":"Upgraded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"}],"name":"WhitelistedAddressAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"}],"name":"WhitelistedAddressRemoved","type":"event"},{"inputs":[],"name":"UPGRADE_INTERFACE_VERSION","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"addWhitelistedAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string[]","name":"outcomes","type":"string[]"},{"internalType":"uint256","name":"_resolutionDelay","type":"uint256"},{"internalType":"uint256","name":"_disputeBondAmount","type":"uint256"},{"internalType":"address","name":"_reporter","type":"address"},{"internalType":"uint256","name":"_b","type":"uint256"}],"name":"createMarket","outputs":[{"internalType":"address","name":"market","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"feeRecipient","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_marketId","type":"uint256"}],"name":"getMarketAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"governor","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_governor","type":"address"},{"internalType":"address","name":"_feeRecipient","type":"address"},{"internalType":"uint256","name":"_marketCreationFee","type":"uint256"},{"internalType":"address","name":"_marketImplementation","type":"address"},{"internalType":"address","name":"_susdToken","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"lpShare","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"marketCreationFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"marketId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"marketImplementation","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"markets","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","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":"protocolShare","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"proxiableUUID","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"removeWhitelistedAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_lpShare","type":"uint256"},{"internalType":"uint256","name":"_protocolShare","type":"uint256"}],"name":"setFeeShares","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_governor","type":"address"}],"name":"setGovernor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_fee","type":"uint256"}],"name":"setMarketCreationFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tradingFee","type":"uint256"}],"name":"setTradingFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"susdToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tradingFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","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":"newImplementation","type":"address"}],"name":"upgradeMarketImplementation","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"upgradeToAndCall","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"verifiedMarkets","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"whitelistedAddresses","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
60a06040523060805234801561001457600080fd5b5061001d610022565b6100d4565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000900460ff16156100725760405163f92ee8a960e01b815260040160405180910390fd5b80546001600160401b03908116146100d15780546001600160401b0319166001600160401b0390811782556040519081527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b50565b6080516122006100fd60003960008181611195015281816111bf015261131401526122006000f3fe608060405260043610620001ff5760003560e01c806366f13ae41162000117578063ad3cb1cc11620000a1578063e9d8a6ab116200006c578063e9d8a6ab146200062d578063ebc38ab01462000652578063f2fde38b146200066a578063f39690e4146200068f57600080fd5b8063ad3cb1cc1462000567578063b0d54bcf14620005a9578063b1283e7714620005ce578063c42cf535146200060857600080fd5b80638456cb5911620000e25780638456cb5914620004b75780638da5cb5b14620004cf5780639cb120c4146200050e5780639f37022a146200054257600080fd5b806366f13ae4146200043d5780636ed71ede1462000462578063715018a6146200047a5780637ba73267146200049257600080fd5b806339cfc386116200019957806352d1902d116200016457806352d1902d14620003c0578063530cd5ab14620003d857806356f4335214620003fd5780635c975abb146200041557600080fd5b806339cfc386146200034d5780633f4ba83a146200036f5780634690484014620003875780634f1ef28614620003a957600080fd5b806329975b4311620001da57806329975b4314620002af5780632ef1bdfa14620002d65780632f1ac04a14620002ee57806333e1a223146200032857600080fd5b806306c933d814620002045780630c340a24146200024d5780631103f3151462000288575b600080fd5b3480156200021157600080fd5b5062000238620002233660046200170c565b60086020526000908152604090205460ff1681565b60405190151581526020015b60405180910390f35b3480156200025a57600080fd5b506003546200026f906001600160a01b031681565b6040516001600160a01b03909116815260200162000244565b3480156200029557600080fd5b50620002a060075481565b60405190815260200162000244565b348015620002bc57600080fd5b50620002d4620002ce3660046200170c565b620006b1565b005b348015620002e357600080fd5b50620002a060015481565b348015620002fb57600080fd5b506200026f6200030d3660046200172a565b6000908152600960205260409020546001600160a01b031690565b3480156200033557600080fd5b50620002d46200034736600462001744565b62000707565b3480156200035a57600080fd5b506002546200026f906001600160a01b031681565b3480156200037c57600080fd5b50620002d4620009e0565b3480156200039457600080fd5b506000546200026f906001600160a01b031681565b620002d4620003ba36600462001853565b620009f6565b348015620003cd57600080fd5b50620002a062000a1b565b348015620003e557600080fd5b50620002d4620003f73660046200170c565b62000a3b565b3480156200040a57600080fd5b50620002a060055481565b3480156200042257600080fd5b50600080516020620021ab8339815191525460ff1662000238565b3480156200044a57600080fd5b50620002d46200045c366004620018bc565b62000a8e565b3480156200046f57600080fd5b50620002a0600b5481565b3480156200048757600080fd5b50620002d462000b3d565b3480156200049f57600080fd5b50620002d4620004b13660046200170c565b62000b53565b348015620004c457600080fd5b50620002d462000c03565b348015620004dc57600080fd5b507f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300546001600160a01b03166200026f565b3480156200051b57600080fd5b50620002386200052d3660046200170c565b600a6020526000908152604090205460ff1681565b3480156200054f57600080fd5b50620002d4620005613660046200172a565b62000c17565b3480156200057457600080fd5b506200059a604051806040016040528060058152602001640352e302e360dc1b81525081565b60405162000244919062001933565b348015620005b657600080fd5b50620002d4620005c83660046200172a565b62000c57565b348015620005db57600080fd5b506200026f620005ed3660046200172a565b6009602052600090815260409020546001600160a01b031681565b3480156200061557600080fd5b50620002d4620006273660046200170c565b62000cda565b3480156200063a57600080fd5b506200026f6200064c36600462001948565b62000d7e565b3480156200065f57600080fd5b50620002a060065481565b3480156200067757600080fd5b50620002d4620006893660046200170c565b62001057565b3480156200069c57600080fd5b506004546200026f906001600160a01b031681565b620006bb6200109b565b6001600160a01b038116600081815260086020526040808220805460ff19166001179055517fd1bba68c128cc3f427e5831b3c6f99f480b6efa6b9e80c757768f6124158cc3f9190a250565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a008054600160401b810460ff16159067ffffffffffffffff166000811580156200074e5750825b905060008267ffffffffffffffff1660011480156200076c5750303b155b9050811580156200077b575080155b156200079a5760405163f92ee8a960e01b815260040160405180910390fd5b845467ffffffffffffffff191660011785558315620007c557845460ff60401b1916600160401b1785555b620007cf620010f9565b620007da8a6200110d565b620007e462001122565b6001600160a01b038a16620008335760405162461bcd60e51b815260206004820152601060248201526f24b73b30b634b21033b7bb32b93737b960811b60448201526064015b60405180910390fd5b6001600160a01b038916620008835760405162461bcd60e51b8152602060048201526015602482015274125b9d985b1a5908199959481c9958da5c1a595b9d605a1b60448201526064016200082a565b6001600160a01b038716620008db5760405162461bcd60e51b815260206004820152601d60248201527f496e76616c6964206d61726b657420696d706c656d656e746174696f6e00000060448201526064016200082a565b6001600160a01b038616620009285760405162461bcd60e51b815260206004820152601260248201527124b73b30b634b21029aaa9a2103a37b5b2b760711b60448201526064016200082a565b6000600b81905580546001600160a01b03808c166001600160a01b031992831617909255600380548d841690831617905560018a9055600280548a841690831617905560048054928916929091169190911790556103e860055561038460065560646007558315620009d457845460ff60401b19168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b50505050505050505050565b620009ea6200109b565b620009f46200112c565b565b62000a006200118a565b62000a0b8262001233565b62000a1782826200123d565b5050565b600062000a2762001309565b506000805160206200218b83398151915290565b62000a456200109b565b6001600160a01b038116600081815260086020526040808220805460ff19169055517ff1abf01a1043b7c244d128e8595cf0c1d10743b022b03a02dffd8ca3bf729f5a9190a250565b62000a986200109b565b60055462000aa7828462001a03565b1462000af65760405162461bcd60e51b815260206004820152601e60248201527f536861726573206d7573742073756d20746f2074726164696e6720666565000060448201526064016200082a565b6006829055600781905560408051838152602081018390527ffabf709ddcab6908663bc153944d0c2f54570ba46d078aecb046e384610874d4910160405180910390a15050565b62000b476200109b565b620009f4600062001353565b62000b5d6200109b565b6001600160a01b03811662000bae5760405162461bcd60e51b815260206004820152601660248201527524b73b30b634b21034b6b83632b6b2b73a30ba34b7b760511b60448201526064016200082a565b600280546001600160a01b0319166001600160a01b0383169081179091556040519081527f2f8d421b6e2d75bbf3d3d560eed8a5c39e6ccdc4c00d72195885d91a38a4063a906020015b60405180910390a150565b62000c0d6200109b565b620009f4620013c4565b62000c216200109b565b60018190556040518181527f583934e5b9be5235b40454ddbb9f61b157293eafefaa7b988cff6fd79f2ca43e9060200162000bf8565b62000c616200109b565b6107d081111562000ca45760405162461bcd60e51b815260206004820152600c60248201526b08ccaca40e8dede40d0d2ced60a31b60448201526064016200082a565b60058190556040518181527f8dac05368d9e10fc43395ddcbdcae6457d0b4c159bc464504c1b386aed79be129060200162000bf8565b62000ce46200109b565b6001600160a01b03811662000d2f5760405162461bcd60e51b815260206004820152601060248201526f24b73b30b634b21033b7bb32b93737b960811b60448201526064016200082a565b600380546001600160a01b0319166001600160a01b0383169081179091556040519081527f1cbb37f5a02c38ab13773cb770fae505cce417a4d81560117389e3a9f7e001f29060200162000bf8565b600062000d8a62001411565b3360009081526008602052604090205460ff1662000e8157600480546000546001546040516323b872dd60e01b815233948101949094526001600160a01b039182166024850152604484015216906323b872dd906064016020604051808303816000875af115801562000e01573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000e27919062001a19565b62000e815760405162461bcd60e51b815260206004820152602360248201527f4d61726b6574206372656174696f6e20666565207472616e73666572206661696044820152621b195960ea1b60648201526084016200082a565b604080516101208101909152600090632de7106f60e21b908062000ea68a8c62001a3d565b81526000546001600160a01b03908116602083015260408083018b905288821660608401526003548216608084015260a0830188905260055460c084015260045490911660e08301526101009091018890525162000f08919060240162001b41565b60408051601f198184030181529181526020820180516001600160e01b03166001600160e01b03199094169390931790925260025491519092506001600160a01b0390911690829062000f5b90620016e1565b62000f6892919062001bfd565b604051809103906000f08015801562000f85573d6000803e3d6000fd5b50600b8054600090815260096020526040812080546001600160a01b0319166001600160a01b038516179055815492945062000fc18362001c2b565b90915550506001600160a01b0382166000908152600a60205260409020805460ff19166001908117909155600b5462000ffb919062001c47565b6003546040516001600160a01b03808616927f1b179d22cf76bd96582f4407459d768c37c7fb000a78cb008159d61f1c7175ad9262001044928e928e928e928d92169062001c86565b60405180910390a3509695505050505050565b620010616200109b565b6001600160a01b0381166200108d57604051631e4fbdf760e01b8152600060048201526024016200082a565b620010988162001353565b50565b33620010ce7f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300546001600160a01b031690565b6001600160a01b031614620009f45760405163118cdaa760e01b81523360048201526024016200082a565b6200110362001444565b620009f46200148e565b6200111762001444565b6200109881620014b2565b620009f462001444565b62001136620014bc565b600080516020620021ab833981519152805460ff191681557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200162000bf8565b306001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614806200121457507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316620012086000805160206200218b833981519152546001600160a01b031690565b6001600160a01b031614155b15620009f45760405163703e46dd60e11b815260040160405180910390fd5b620010986200109b565b816001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa9250505080156200129a575060408051601f3d908101601f19168201909252620012979181019062001d48565b60015b620012c457604051634c9c8ce360e01b81526001600160a01b03831660048201526024016200082a565b6000805160206200218b8339815191528114620012f857604051632a87526960e21b8152600481018290526024016200082a565b620013048383620014ee565b505050565b306001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614620009f45760405163703e46dd60e11b815260040160405180910390fd5b7f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c19930080546001600160a01b031981166001600160a01b03848116918217845560405192169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3505050565b620013ce62001411565b600080516020620021ab833981519152805460ff191660011781557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2583362001171565b600080516020620021ab8339815191525460ff1615620009f45760405163d93c066560e01b815260040160405180910390fd5b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0054600160401b900460ff16620009f457604051631afcd79f60e31b815260040160405180910390fd5b6200149862001444565b600080516020620021ab833981519152805460ff19169055565b6200106162001444565b600080516020620021ab8339815191525460ff16620009f457604051638dfc202b60e01b815260040160405180910390fd5b620014f9826200154b565b6040516001600160a01b038316907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a28051156200154157620013048282620015b3565b62000a1762001631565b806001600160a01b03163b6000036200158357604051634c9c8ce360e01b81526001600160a01b03821660048201526024016200082a565b6000805160206200218b83398151915280546001600160a01b0319166001600160a01b0392909216919091179055565b6060600080846001600160a01b031684604051620015d2919062001d62565b600060405180830381855af49150503d80600081146200160f576040519150601f19603f3d011682016040523d82523d6000602084013e62001614565b606091505b50915091506200162685838362001651565b925050505b92915050565b3415620009f45760405163b398979f60e01b815260040160405180910390fd5b6060826200166a576200166482620016b7565b620016b0565b81511580156200168257506001600160a01b0384163b155b15620016ad57604051639996b31560e01b81526001600160a01b03851660048201526024016200082a565b50805b9392505050565b805115620016c85780518082602001fd5b60405163d6bda27560e01b815260040160405180910390fd5b61040a8062001d8183390190565b80356001600160a01b03811681146200170757600080fd5b919050565b6000602082840312156200171f57600080fd5b620016b082620016ef565b6000602082840312156200173d57600080fd5b5035919050565b600080600080600060a086880312156200175d57600080fd5b6200176886620016ef565b94506200177860208701620016ef565b9350604086013592506200178f60608701620016ef565b91506200179f60808701620016ef565b90509295509295909350565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff81118282101715620017ed57620017ed620017ab565b604052919050565b600067ffffffffffffffff831115620018125762001812620017ab565b62001827601f8401601f1916602001620017c1565b90508281528383830111156200183c57600080fd5b828260208301376000602084830101529392505050565b600080604083850312156200186757600080fd5b6200187283620016ef565b9150602083013567ffffffffffffffff8111156200188f57600080fd5b8301601f81018513620018a157600080fd5b620018b285823560208401620017f5565b9150509250929050565b60008060408385031215620018d057600080fd5b50508035926020909101359150565b60005b83811015620018fc578181015183820152602001620018e2565b50506000910152565b600081518084526200191f816020860160208601620018df565b601f01601f19169290920160200192915050565b602081526000620016b0602083018462001905565b60008060008060008060a087890312156200196257600080fd5b863567ffffffffffffffff808211156200197b57600080fd5b818901915089601f8301126200199057600080fd5b813581811115620019a057600080fd5b8a60208260051b8501011115620019b657600080fd5b60209283019850965050870135935060408701359250620019da60608801620016ef565b9150608087013590509295509295509295565b634e487b7160e01b600052601160045260246000fd5b808201808211156200162b576200162b620019ed565b60006020828403121562001a2c57600080fd5b81518015158114620016b057600080fd5b600067ffffffffffffffff8084111562001a5b5762001a5b620017ab565b8360051b602062001a6f60208301620017c1565b8681529185019160208101903684111562001a8957600080fd5b865b8481101562001ad75780358681111562001aa55760008081fd5b880136601f82011262001ab85760008081fd5b62001ac8368235878401620017f5565b84525091830191830162001a8b565b50979650505050505050565b60008282518085526020808601955060208260051b8401016020860160005b8481101562001b3457601f1986840301895262001b2183835162001905565b9884019892509083019060010162001b02565b5090979650505050505050565b602081526000825161012080602085015262001b6261014085018362001ae3565b9150602085015162001b7f60408601826001600160a01b03169052565b5060408501516060850152606085015162001ba560808601826001600160a01b03169052565b5060808501516001600160a01b03811660a08601525060a085015160c085015260c085015160e085015260e085015161010062001bec818701836001600160a01b03169052565b959095015193019290925250919050565b6001600160a01b038316815260406020820181905260009062001c239083018462001905565b949350505050565b60006001820162001c405762001c40620019ed565b5060010190565b818103818111156200162b576200162b620019ed565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b60808082528101859052600060a0600587901b8301810190830188835b8981101562001d1e57858403609f190183528135368c9003601e1901811262001ccb57600080fd5b8b01602081810191359067ffffffffffffffff82111562001ceb57600080fd5b81360383131562001cfb57600080fd5b62001d0887838562001c5d565b9650948501949390930192505060010162001ca3565b5050506020830195909552506001600160a01b039283166040820152911660609091015292915050565b60006020828403121562001d5b57600080fd5b5051919050565b6000825162001d76818460208701620018df565b919091019291505056fe608060405260405161040a38038061040a83398101604081905261002291610268565b61002c8282610033565b5050610352565b61003c82610092565b6040516001600160a01b038316907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a280511561008657610081828261010e565b505050565b61008e610185565b5050565b806001600160a01b03163b6000036100cd57604051634c9c8ce360e01b81526001600160a01b03821660048201526024015b60405180910390fd5b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80546001600160a01b0319166001600160a01b0392909216919091179055565b6060600080846001600160a01b03168460405161012b9190610336565b600060405180830381855af49150503d8060008114610166576040519150601f19603f3d011682016040523d82523d6000602084013e61016b565b606091505b50909250905061017c8583836101a6565b95945050505050565b34156101a45760405163b398979f60e01b815260040160405180910390fd5b565b6060826101bb576101b682610205565b6101fe565b81511580156101d257506001600160a01b0384163b155b156101fb57604051639996b31560e01b81526001600160a01b03851660048201526024016100c4565b50805b9392505050565b8051156102155780518082602001fd5b60405163d6bda27560e01b815260040160405180910390fd5b634e487b7160e01b600052604160045260246000fd5b60005b8381101561025f578181015183820152602001610247565b50506000910152565b6000806040838503121561027b57600080fd5b82516001600160a01b038116811461029257600080fd5b60208401519092506001600160401b03808211156102af57600080fd5b818501915085601f8301126102c357600080fd5b8151818111156102d5576102d561022e565b604051601f8201601f19908116603f011681019083821181831017156102fd576102fd61022e565b8160405282815288602084870101111561031657600080fd5b610327836020830160208801610244565b80955050505050509250929050565b60008251610348818460208701610244565b9190910192915050565b60aa806103606000396000f3fe6080604052600a600c565b005b60186014601a565b6051565b565b6000604c7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b905090565b3660008037600080366000845af43d6000803e808015606f573d6000f35b3d6000fdfea26469706673582212201d1e675cd71e57bb3f08113f3040612bee9b14a06a3515aeb6fc806b55a6323764736f6c63430008160033360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbccd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f03300a2646970667358221220f947d6b5d89b3973c156473cc0b4c19a1359571ac26d943c1a61590faed461de64736f6c63430008160033
Deployed Bytecode
0x608060405260043610620001ff5760003560e01c806366f13ae41162000117578063ad3cb1cc11620000a1578063e9d8a6ab116200006c578063e9d8a6ab146200062d578063ebc38ab01462000652578063f2fde38b146200066a578063f39690e4146200068f57600080fd5b8063ad3cb1cc1462000567578063b0d54bcf14620005a9578063b1283e7714620005ce578063c42cf535146200060857600080fd5b80638456cb5911620000e25780638456cb5914620004b75780638da5cb5b14620004cf5780639cb120c4146200050e5780639f37022a146200054257600080fd5b806366f13ae4146200043d5780636ed71ede1462000462578063715018a6146200047a5780637ba73267146200049257600080fd5b806339cfc386116200019957806352d1902d116200016457806352d1902d14620003c0578063530cd5ab14620003d857806356f4335214620003fd5780635c975abb146200041557600080fd5b806339cfc386146200034d5780633f4ba83a146200036f5780634690484014620003875780634f1ef28614620003a957600080fd5b806329975b4311620001da57806329975b4314620002af5780632ef1bdfa14620002d65780632f1ac04a14620002ee57806333e1a223146200032857600080fd5b806306c933d814620002045780630c340a24146200024d5780631103f3151462000288575b600080fd5b3480156200021157600080fd5b5062000238620002233660046200170c565b60086020526000908152604090205460ff1681565b60405190151581526020015b60405180910390f35b3480156200025a57600080fd5b506003546200026f906001600160a01b031681565b6040516001600160a01b03909116815260200162000244565b3480156200029557600080fd5b50620002a060075481565b60405190815260200162000244565b348015620002bc57600080fd5b50620002d4620002ce3660046200170c565b620006b1565b005b348015620002e357600080fd5b50620002a060015481565b348015620002fb57600080fd5b506200026f6200030d3660046200172a565b6000908152600960205260409020546001600160a01b031690565b3480156200033557600080fd5b50620002d46200034736600462001744565b62000707565b3480156200035a57600080fd5b506002546200026f906001600160a01b031681565b3480156200037c57600080fd5b50620002d4620009e0565b3480156200039457600080fd5b506000546200026f906001600160a01b031681565b620002d4620003ba36600462001853565b620009f6565b348015620003cd57600080fd5b50620002a062000a1b565b348015620003e557600080fd5b50620002d4620003f73660046200170c565b62000a3b565b3480156200040a57600080fd5b50620002a060055481565b3480156200042257600080fd5b50600080516020620021ab8339815191525460ff1662000238565b3480156200044a57600080fd5b50620002d46200045c366004620018bc565b62000a8e565b3480156200046f57600080fd5b50620002a0600b5481565b3480156200048757600080fd5b50620002d462000b3d565b3480156200049f57600080fd5b50620002d4620004b13660046200170c565b62000b53565b348015620004c457600080fd5b50620002d462000c03565b348015620004dc57600080fd5b507f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300546001600160a01b03166200026f565b3480156200051b57600080fd5b50620002386200052d3660046200170c565b600a6020526000908152604090205460ff1681565b3480156200054f57600080fd5b50620002d4620005613660046200172a565b62000c17565b3480156200057457600080fd5b506200059a604051806040016040528060058152602001640352e302e360dc1b81525081565b60405162000244919062001933565b348015620005b657600080fd5b50620002d4620005c83660046200172a565b62000c57565b348015620005db57600080fd5b506200026f620005ed3660046200172a565b6009602052600090815260409020546001600160a01b031681565b3480156200061557600080fd5b50620002d4620006273660046200170c565b62000cda565b3480156200063a57600080fd5b506200026f6200064c36600462001948565b62000d7e565b3480156200065f57600080fd5b50620002a060065481565b3480156200067757600080fd5b50620002d4620006893660046200170c565b62001057565b3480156200069c57600080fd5b506004546200026f906001600160a01b031681565b620006bb6200109b565b6001600160a01b038116600081815260086020526040808220805460ff19166001179055517fd1bba68c128cc3f427e5831b3c6f99f480b6efa6b9e80c757768f6124158cc3f9190a250565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a008054600160401b810460ff16159067ffffffffffffffff166000811580156200074e5750825b905060008267ffffffffffffffff1660011480156200076c5750303b155b9050811580156200077b575080155b156200079a5760405163f92ee8a960e01b815260040160405180910390fd5b845467ffffffffffffffff191660011785558315620007c557845460ff60401b1916600160401b1785555b620007cf620010f9565b620007da8a6200110d565b620007e462001122565b6001600160a01b038a16620008335760405162461bcd60e51b815260206004820152601060248201526f24b73b30b634b21033b7bb32b93737b960811b60448201526064015b60405180910390fd5b6001600160a01b038916620008835760405162461bcd60e51b8152602060048201526015602482015274125b9d985b1a5908199959481c9958da5c1a595b9d605a1b60448201526064016200082a565b6001600160a01b038716620008db5760405162461bcd60e51b815260206004820152601d60248201527f496e76616c6964206d61726b657420696d706c656d656e746174696f6e00000060448201526064016200082a565b6001600160a01b038616620009285760405162461bcd60e51b815260206004820152601260248201527124b73b30b634b21029aaa9a2103a37b5b2b760711b60448201526064016200082a565b6000600b81905580546001600160a01b03808c166001600160a01b031992831617909255600380548d841690831617905560018a9055600280548a841690831617905560048054928916929091169190911790556103e860055561038460065560646007558315620009d457845460ff60401b19168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b50505050505050505050565b620009ea6200109b565b620009f46200112c565b565b62000a006200118a565b62000a0b8262001233565b62000a1782826200123d565b5050565b600062000a2762001309565b506000805160206200218b83398151915290565b62000a456200109b565b6001600160a01b038116600081815260086020526040808220805460ff19169055517ff1abf01a1043b7c244d128e8595cf0c1d10743b022b03a02dffd8ca3bf729f5a9190a250565b62000a986200109b565b60055462000aa7828462001a03565b1462000af65760405162461bcd60e51b815260206004820152601e60248201527f536861726573206d7573742073756d20746f2074726164696e6720666565000060448201526064016200082a565b6006829055600781905560408051838152602081018390527ffabf709ddcab6908663bc153944d0c2f54570ba46d078aecb046e384610874d4910160405180910390a15050565b62000b476200109b565b620009f4600062001353565b62000b5d6200109b565b6001600160a01b03811662000bae5760405162461bcd60e51b815260206004820152601660248201527524b73b30b634b21034b6b83632b6b2b73a30ba34b7b760511b60448201526064016200082a565b600280546001600160a01b0319166001600160a01b0383169081179091556040519081527f2f8d421b6e2d75bbf3d3d560eed8a5c39e6ccdc4c00d72195885d91a38a4063a906020015b60405180910390a150565b62000c0d6200109b565b620009f4620013c4565b62000c216200109b565b60018190556040518181527f583934e5b9be5235b40454ddbb9f61b157293eafefaa7b988cff6fd79f2ca43e9060200162000bf8565b62000c616200109b565b6107d081111562000ca45760405162461bcd60e51b815260206004820152600c60248201526b08ccaca40e8dede40d0d2ced60a31b60448201526064016200082a565b60058190556040518181527f8dac05368d9e10fc43395ddcbdcae6457d0b4c159bc464504c1b386aed79be129060200162000bf8565b62000ce46200109b565b6001600160a01b03811662000d2f5760405162461bcd60e51b815260206004820152601060248201526f24b73b30b634b21033b7bb32b93737b960811b60448201526064016200082a565b600380546001600160a01b0319166001600160a01b0383169081179091556040519081527f1cbb37f5a02c38ab13773cb770fae505cce417a4d81560117389e3a9f7e001f29060200162000bf8565b600062000d8a62001411565b3360009081526008602052604090205460ff1662000e8157600480546000546001546040516323b872dd60e01b815233948101949094526001600160a01b039182166024850152604484015216906323b872dd906064016020604051808303816000875af115801562000e01573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000e27919062001a19565b62000e815760405162461bcd60e51b815260206004820152602360248201527f4d61726b6574206372656174696f6e20666565207472616e73666572206661696044820152621b195960ea1b60648201526084016200082a565b604080516101208101909152600090632de7106f60e21b908062000ea68a8c62001a3d565b81526000546001600160a01b03908116602083015260408083018b905288821660608401526003548216608084015260a0830188905260055460c084015260045490911660e08301526101009091018890525162000f08919060240162001b41565b60408051601f198184030181529181526020820180516001600160e01b03166001600160e01b03199094169390931790925260025491519092506001600160a01b0390911690829062000f5b90620016e1565b62000f6892919062001bfd565b604051809103906000f08015801562000f85573d6000803e3d6000fd5b50600b8054600090815260096020526040812080546001600160a01b0319166001600160a01b038516179055815492945062000fc18362001c2b565b90915550506001600160a01b0382166000908152600a60205260409020805460ff19166001908117909155600b5462000ffb919062001c47565b6003546040516001600160a01b03808616927f1b179d22cf76bd96582f4407459d768c37c7fb000a78cb008159d61f1c7175ad9262001044928e928e928e928d92169062001c86565b60405180910390a3509695505050505050565b620010616200109b565b6001600160a01b0381166200108d57604051631e4fbdf760e01b8152600060048201526024016200082a565b620010988162001353565b50565b33620010ce7f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300546001600160a01b031690565b6001600160a01b031614620009f45760405163118cdaa760e01b81523360048201526024016200082a565b6200110362001444565b620009f46200148e565b6200111762001444565b6200109881620014b2565b620009f462001444565b62001136620014bc565b600080516020620021ab833981519152805460ff191681557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200162000bf8565b306001600160a01b037f0000000000000000000000008542eca10cbe5897dd8cd746d0bf45fe9f9dbbe21614806200121457507f0000000000000000000000008542eca10cbe5897dd8cd746d0bf45fe9f9dbbe26001600160a01b0316620012086000805160206200218b833981519152546001600160a01b031690565b6001600160a01b031614155b15620009f45760405163703e46dd60e11b815260040160405180910390fd5b620010986200109b565b816001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa9250505080156200129a575060408051601f3d908101601f19168201909252620012979181019062001d48565b60015b620012c457604051634c9c8ce360e01b81526001600160a01b03831660048201526024016200082a565b6000805160206200218b8339815191528114620012f857604051632a87526960e21b8152600481018290526024016200082a565b620013048383620014ee565b505050565b306001600160a01b037f0000000000000000000000008542eca10cbe5897dd8cd746d0bf45fe9f9dbbe21614620009f45760405163703e46dd60e11b815260040160405180910390fd5b7f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c19930080546001600160a01b031981166001600160a01b03848116918217845560405192169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3505050565b620013ce62001411565b600080516020620021ab833981519152805460ff191660011781557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2583362001171565b600080516020620021ab8339815191525460ff1615620009f45760405163d93c066560e01b815260040160405180910390fd5b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0054600160401b900460ff16620009f457604051631afcd79f60e31b815260040160405180910390fd5b6200149862001444565b600080516020620021ab833981519152805460ff19169055565b6200106162001444565b600080516020620021ab8339815191525460ff16620009f457604051638dfc202b60e01b815260040160405180910390fd5b620014f9826200154b565b6040516001600160a01b038316907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a28051156200154157620013048282620015b3565b62000a1762001631565b806001600160a01b03163b6000036200158357604051634c9c8ce360e01b81526001600160a01b03821660048201526024016200082a565b6000805160206200218b83398151915280546001600160a01b0319166001600160a01b0392909216919091179055565b6060600080846001600160a01b031684604051620015d2919062001d62565b600060405180830381855af49150503d80600081146200160f576040519150601f19603f3d011682016040523d82523d6000602084013e62001614565b606091505b50915091506200162685838362001651565b925050505b92915050565b3415620009f45760405163b398979f60e01b815260040160405180910390fd5b6060826200166a576200166482620016b7565b620016b0565b81511580156200168257506001600160a01b0384163b155b15620016ad57604051639996b31560e01b81526001600160a01b03851660048201526024016200082a565b50805b9392505050565b805115620016c85780518082602001fd5b60405163d6bda27560e01b815260040160405180910390fd5b61040a8062001d8183390190565b80356001600160a01b03811681146200170757600080fd5b919050565b6000602082840312156200171f57600080fd5b620016b082620016ef565b6000602082840312156200173d57600080fd5b5035919050565b600080600080600060a086880312156200175d57600080fd5b6200176886620016ef565b94506200177860208701620016ef565b9350604086013592506200178f60608701620016ef565b91506200179f60808701620016ef565b90509295509295909350565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff81118282101715620017ed57620017ed620017ab565b604052919050565b600067ffffffffffffffff831115620018125762001812620017ab565b62001827601f8401601f1916602001620017c1565b90508281528383830111156200183c57600080fd5b828260208301376000602084830101529392505050565b600080604083850312156200186757600080fd5b6200187283620016ef565b9150602083013567ffffffffffffffff8111156200188f57600080fd5b8301601f81018513620018a157600080fd5b620018b285823560208401620017f5565b9150509250929050565b60008060408385031215620018d057600080fd5b50508035926020909101359150565b60005b83811015620018fc578181015183820152602001620018e2565b50506000910152565b600081518084526200191f816020860160208601620018df565b601f01601f19169290920160200192915050565b602081526000620016b0602083018462001905565b60008060008060008060a087890312156200196257600080fd5b863567ffffffffffffffff808211156200197b57600080fd5b818901915089601f8301126200199057600080fd5b813581811115620019a057600080fd5b8a60208260051b8501011115620019b657600080fd5b60209283019850965050870135935060408701359250620019da60608801620016ef565b9150608087013590509295509295509295565b634e487b7160e01b600052601160045260246000fd5b808201808211156200162b576200162b620019ed565b60006020828403121562001a2c57600080fd5b81518015158114620016b057600080fd5b600067ffffffffffffffff8084111562001a5b5762001a5b620017ab565b8360051b602062001a6f60208301620017c1565b8681529185019160208101903684111562001a8957600080fd5b865b8481101562001ad75780358681111562001aa55760008081fd5b880136601f82011262001ab85760008081fd5b62001ac8368235878401620017f5565b84525091830191830162001a8b565b50979650505050505050565b60008282518085526020808601955060208260051b8401016020860160005b8481101562001b3457601f1986840301895262001b2183835162001905565b9884019892509083019060010162001b02565b5090979650505050505050565b602081526000825161012080602085015262001b6261014085018362001ae3565b9150602085015162001b7f60408601826001600160a01b03169052565b5060408501516060850152606085015162001ba560808601826001600160a01b03169052565b5060808501516001600160a01b03811660a08601525060a085015160c085015260c085015160e085015260e085015161010062001bec818701836001600160a01b03169052565b959095015193019290925250919050565b6001600160a01b038316815260406020820181905260009062001c239083018462001905565b949350505050565b60006001820162001c405762001c40620019ed565b5060010190565b818103818111156200162b576200162b620019ed565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b60808082528101859052600060a0600587901b8301810190830188835b8981101562001d1e57858403609f190183528135368c9003601e1901811262001ccb57600080fd5b8b01602081810191359067ffffffffffffffff82111562001ceb57600080fd5b81360383131562001cfb57600080fd5b62001d0887838562001c5d565b9650948501949390930192505060010162001ca3565b5050506020830195909552506001600160a01b039283166040820152911660609091015292915050565b60006020828403121562001d5b57600080fd5b5051919050565b6000825162001d76818460208701620018df565b919091019291505056fe608060405260405161040a38038061040a83398101604081905261002291610268565b61002c8282610033565b5050610352565b61003c82610092565b6040516001600160a01b038316907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a280511561008657610081828261010e565b505050565b61008e610185565b5050565b806001600160a01b03163b6000036100cd57604051634c9c8ce360e01b81526001600160a01b03821660048201526024015b60405180910390fd5b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80546001600160a01b0319166001600160a01b0392909216919091179055565b6060600080846001600160a01b03168460405161012b9190610336565b600060405180830381855af49150503d8060008114610166576040519150601f19603f3d011682016040523d82523d6000602084013e61016b565b606091505b50909250905061017c8583836101a6565b95945050505050565b34156101a45760405163b398979f60e01b815260040160405180910390fd5b565b6060826101bb576101b682610205565b6101fe565b81511580156101d257506001600160a01b0384163b155b156101fb57604051639996b31560e01b81526001600160a01b03851660048201526024016100c4565b50805b9392505050565b8051156102155780518082602001fd5b60405163d6bda27560e01b815260040160405180910390fd5b634e487b7160e01b600052604160045260246000fd5b60005b8381101561025f578181015183820152602001610247565b50506000910152565b6000806040838503121561027b57600080fd5b82516001600160a01b038116811461029257600080fd5b60208401519092506001600160401b03808211156102af57600080fd5b818501915085601f8301126102c357600080fd5b8151818111156102d5576102d561022e565b604051601f8201601f19908116603f011681019083821181831017156102fd576102fd61022e565b8160405282815288602084870101111561031657600080fd5b610327836020830160208801610244565b80955050505050509250929050565b60008251610348818460208701610244565b9190910192915050565b60aa806103606000396000f3fe6080604052600a600c565b005b60186014601a565b6051565b565b6000604c7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b905090565b3660008037600080366000845af43d6000803e808015606f573d6000f35b3d6000fdfea26469706673582212201d1e675cd71e57bb3f08113f3040612bee9b14a06a3515aeb6fc806b55a6323764736f6c63430008160033360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbccd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f03300a2646970667358221220f947d6b5d89b3973c156473cc0b4c19a1359571ac26d943c1a61590faed461de64736f6c63430008160033
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 31 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
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.