Source Code
Overview
ETH Balance
0 ETH
ETH Value
$0.00View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Cross-Chain Transactions
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:
PreMarketV2
Compiler Version
v0.8.20+commit.a1b79de6
Optimization Enabled:
Yes with 200 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.20;
import { Initializable } from "ozu/proxy/utils/Initializable.sol";
import { UUPSUpgradeable } from "ozu/proxy/utils/UUPSUpgradeable.sol";
import { ReentrancyGuardUpgradeable } from "ozu/utils/ReentrancyGuardUpgradeable.sol";
import { GasMode, YieldMode } from "./const/Blast.sol";
import { PreMarketConfig } from "./features/PreMarketConfig.sol";
import { PreMarketFill } from "./features/PreMarketFill.sol";
import { PreMarketMarkets } from "./features/PreMarketMarkets.sol";
import { PreMarketOrdersV2 } from "./features/PreMarketOrdersV2.sol";
import { PreMarketStorage } from "./features/PreMarketStorage.sol";
import { PreMarketYield } from "./features/PreMarketYield.sol";
import { IBlast } from "./interfaces/external/IBlast.sol";
import { IBlastPoints } from "./interfaces/external/IBlastPoints.sol";
import { IERC20Rebasing } from "./interfaces/external/IERC20Rebasing.sol";
import "./errors/PreMarket.sol";
import { Storage } from "./storage/PreMarket.sol";
/// @custom:oz-upgrades-from src/PreMarket.sol:PreMarket
contract PreMarketV2 is
Initializable,
ReentrancyGuardUpgradeable,
UUPSUpgradeable,
PreMarketStorage,
PreMarketConfig,
PreMarketMarkets,
PreMarketOrdersV2,
PreMarketFill,
PreMarketYield
{
function initialize(
address blast,
address usdb,
address weth,
address points,
address pointsOperator
)
public
initializer
{
__UUPSUpgradeable_init();
IBlast(blast).configureClaimableGas();
Storage storage $ = _getOwnStorage();
$.owner = msg.sender;
$.weth = weth;
$.usdb = usdb;
IERC20Rebasing(usdb).configure(YieldMode.CLAIMABLE);
IERC20Rebasing(weth).configure(YieldMode.CLAIMABLE);
IBlastPoints(points).configurePointsOperator(pointsOperator);
}
function _authorizeUpgrade(address) internal view override {
if (_getOwnStorage().owner != msg.sender) revert Unauthorized();
}
function getVersion() external pure returns (uint256) {
return 2;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/Initializable.sol)
pragma solidity ^0.8.20;
/**
* @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
* behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
* external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
* function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
*
* The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
* reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
* case an upgrade adds a module that needs to be initialized.
*
* For example:
*
* [.hljs-theme-light.nopadding]
* ```solidity
* contract MyToken is ERC20Upgradeable {
* function initialize() initializer public {
* __ERC20_init("MyToken", "MTK");
* }
* }
*
* contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
* function initializeV2() reinitializer(2) public {
* __ERC20Permit_init("MyToken");
* }
* }
* ```
*
* TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
* possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
*
* CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
* that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
*
* [CAUTION]
* ====
* Avoid leaving a contract uninitialized.
*
* An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
* contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
* the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
*
* [.hljs-theme-light.nopadding]
* ```
* /// @custom:oz-upgrades-unsafe-allow constructor
* constructor() {
* _disableInitializers();
* }
* ```
* ====
*/
abstract contract Initializable {
/**
* @dev Storage of the initializable contract.
*
* It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions
* when using with upgradeable contracts.
*
* @custom:storage-location erc7201:openzeppelin.storage.Initializable
*/
struct InitializableStorage {
/**
* @dev Indicates that the contract has been initialized.
*/
uint64 _initialized;
/**
* @dev Indicates that the contract is in the process of being initialized.
*/
bool _initializing;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Initializable")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00;
/**
* @dev The contract is already initialized.
*/
error InvalidInitialization();
/**
* @dev The contract is not initializing.
*/
error NotInitializing();
/**
* @dev Triggered when the contract has been initialized or reinitialized.
*/
event Initialized(uint64 version);
/**
* @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
* `onlyInitializing` functions can be used to initialize parent contracts.
*
* Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any
* number of times. This behavior in the constructor can be useful during testing and is not expected to be used in
* production.
*
* Emits an {Initialized} event.
*/
modifier initializer() {
// solhint-disable-next-line var-name-mixedcase
InitializableStorage storage $ = _getInitializableStorage();
// Cache values to avoid duplicated sloads
bool isTopLevelCall = !$._initializing;
uint64 initialized = $._initialized;
// Allowed calls:
// - initialSetup: the contract is not in the initializing state and no previous version was
// initialized
// - construction: the contract is initialized at version 1 (no reininitialization) and the
// current contract is just being deployed
bool initialSetup = initialized == 0 && isTopLevelCall;
bool construction = initialized == 1 && address(this).code.length == 0;
if (!initialSetup && !construction) {
revert InvalidInitialization();
}
$._initialized = 1;
if (isTopLevelCall) {
$._initializing = true;
}
_;
if (isTopLevelCall) {
$._initializing = false;
emit Initialized(1);
}
}
/**
* @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
* contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
* used to initialize parent contracts.
*
* A reinitializer may be used after the original initialization step. This is essential to configure modules that
* are added through upgrades and that require initialization.
*
* When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
* cannot be nested. If one is invoked in the context of another, execution will revert.
*
* Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
* a contract, executing them in the right order is up to the developer or operator.
*
* WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization.
*
* Emits an {Initialized} event.
*/
modifier reinitializer(uint64 version) {
// solhint-disable-next-line var-name-mixedcase
InitializableStorage storage $ = _getInitializableStorage();
if ($._initializing || $._initialized >= version) {
revert InvalidInitialization();
}
$._initialized = version;
$._initializing = true;
_;
$._initializing = false;
emit Initialized(version);
}
/**
* @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
* {initializer} and {reinitializer} modifiers, directly or indirectly.
*/
modifier onlyInitializing() {
_checkInitializing();
_;
}
/**
* @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}.
*/
function _checkInitializing() internal view virtual {
if (!_isInitializing()) {
revert NotInitializing();
}
}
/**
* @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
* Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
* to any version. It is recommended to use this to lock implementation contracts that are designed to be called
* through proxies.
*
* Emits an {Initialized} event the first time it is successfully executed.
*/
function _disableInitializers() internal virtual {
// solhint-disable-next-line var-name-mixedcase
InitializableStorage storage $ = _getInitializableStorage();
if ($._initializing) {
revert InvalidInitialization();
}
if ($._initialized != type(uint64).max) {
$._initialized = type(uint64).max;
emit Initialized(type(uint64).max);
}
}
/**
* @dev Returns the highest version that has been initialized. See {reinitializer}.
*/
function _getInitializedVersion() internal view returns (uint64) {
return _getInitializableStorage()._initialized;
}
/**
* @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.
*/
function _isInitializing() internal view returns (bool) {
return _getInitializableStorage()._initializing;
}
/**
* @dev Returns a pointer to the storage namespace.
*/
// solhint-disable-next-line var-name-mixedcase
function _getInitializableStorage() private pure returns (InitializableStorage storage $) {
assembly {
$.slot := INITIALIZABLE_STORAGE
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/UUPSUpgradeable.sol)
pragma solidity ^0.8.20;
import {IERC1822Proxiable} from "@openzeppelin/contracts/interfaces/draft-IERC1822.sol";
import {ERC1967Utils} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Utils.sol";
import {Initializable} from "./Initializable.sol";
/**
* @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an
* {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy.
*
* A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is
* reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing
* `UUPSUpgradeable` with a custom implementation of upgrades.
*
* The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism.
*/
abstract contract UUPSUpgradeable is Initializable, IERC1822Proxiable {
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable
address private immutable __self = address(this);
/**
* @dev The version of the upgrade interface of the contract. If this getter is missing, both `upgradeTo(address)`
* and `upgradeToAndCall(address,bytes)` are present, and `upgradeTo` must be used if no function should be called,
* while `upgradeToAndCall` will invoke the `receive` function if the second argument is the empty byte string.
* If the getter returns `"5.0.0"`, only `upgradeToAndCall(address,bytes)` is present, and the second argument must
* be the empty byte string if no function should be called, making it impossible to invoke the `receive` function
* during an upgrade.
*/
string public constant UPGRADE_INTERFACE_VERSION = "5.0.0";
/**
* @dev The call is from an unauthorized context.
*/
error UUPSUnauthorizedCallContext();
/**
* @dev The storage `slot` is unsupported as a UUID.
*/
error UUPSUnsupportedProxiableUUID(bytes32 slot);
/**
* @dev Check that the execution is being performed through a delegatecall call and that the execution context is
* a proxy contract with an implementation (as defined in ERC1967) pointing to self. This should only be the case
* for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a
* function through ERC1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to
* fail.
*/
modifier onlyProxy() {
_checkProxy();
_;
}
/**
* @dev Check that the execution is not being performed through a delegate call. This allows a function to be
* callable on the implementing contract but not through proxies.
*/
modifier notDelegated() {
_checkNotDelegated();
_;
}
function __UUPSUpgradeable_init() internal onlyInitializing {
}
function __UUPSUpgradeable_init_unchained() internal onlyInitializing {
}
/**
* @dev Implementation of the ERC1822 {proxiableUUID} function. This returns the storage slot used by the
* implementation. It is used to validate the implementation's compatibility when performing an upgrade.
*
* IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
* bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
* function revert if invoked through a proxy. This is guaranteed by the `notDelegated` modifier.
*/
function proxiableUUID() external view virtual notDelegated returns (bytes32) {
return ERC1967Utils.IMPLEMENTATION_SLOT;
}
/**
* @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call
* encoded in `data`.
*
* Calls {_authorizeUpgrade}.
*
* Emits an {Upgraded} event.
*
* @custom:oz-upgrades-unsafe-allow-reachable delegatecall
*/
function upgradeToAndCall(address newImplementation, bytes memory data) public payable virtual onlyProxy {
_authorizeUpgrade(newImplementation);
_upgradeToAndCallUUPS(newImplementation, data);
}
/**
* @dev Reverts if the execution is not performed via delegatecall or the execution
* context is not of a proxy with an ERC1967-compliant implementation pointing to self.
* See {_onlyProxy}.
*/
function _checkProxy() internal view virtual {
if (
address(this) == __self || // Must be called through delegatecall
ERC1967Utils.getImplementation() != __self // Must be called through an active proxy
) {
revert UUPSUnauthorizedCallContext();
}
}
/**
* @dev Reverts if the execution is performed via delegatecall.
* See {notDelegated}.
*/
function _checkNotDelegated() internal view virtual {
if (address(this) != __self) {
// Must not be called through delegatecall
revert UUPSUnauthorizedCallContext();
}
}
/**
* @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by
* {upgradeToAndCall}.
*
* Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}.
*
* ```solidity
* function _authorizeUpgrade(address) internal onlyOwner {}
* ```
*/
function _authorizeUpgrade(address newImplementation) internal virtual;
/**
* @dev Performs an implementation upgrade with a security check for UUPS proxies, and additional setup call.
*
* As a security check, {proxiableUUID} is invoked in the new implementation, and the return value
* is expected to be the implementation slot in ERC1967.
*
* Emits an {IERC1967-Upgraded} event.
*/
function _upgradeToAndCallUUPS(address newImplementation, bytes memory data) private {
try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {
if (slot != ERC1967Utils.IMPLEMENTATION_SLOT) {
revert UUPSUnsupportedProxiableUUID(slot);
}
ERC1967Utils.upgradeToAndCall(newImplementation, data);
} catch {
// The implementation is not UUPS
revert ERC1967Utils.ERC1967InvalidImplementation(newImplementation);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/ReentrancyGuard.sol)
pragma solidity ^0.8.20;
import {Initializable} from "../proxy/utils/Initializable.sol";
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuardUpgradeable is Initializable {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant NOT_ENTERED = 1;
uint256 private constant ENTERED = 2;
/// @custom:storage-location erc7201:openzeppelin.storage.ReentrancyGuard
struct ReentrancyGuardStorage {
uint256 _status;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.ReentrancyGuard")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant ReentrancyGuardStorageLocation = 0x9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00;
function _getReentrancyGuardStorage() private pure returns (ReentrancyGuardStorage storage $) {
assembly {
$.slot := ReentrancyGuardStorageLocation
}
}
/**
* @dev Unauthorized reentrant call.
*/
error ReentrancyGuardReentrantCall();
function __ReentrancyGuard_init() internal onlyInitializing {
__ReentrancyGuard_init_unchained();
}
function __ReentrancyGuard_init_unchained() internal onlyInitializing {
ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage();
$._status = NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage();
// On the first call to nonReentrant, _status will be NOT_ENTERED
if ($._status == ENTERED) {
revert ReentrancyGuardReentrantCall();
}
// Any calls to nonReentrant after this point will fail
$._status = ENTERED;
}
function _nonReentrantAfter() private {
ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage();
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
$._status = NOT_ENTERED;
}
/**
* @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
* `nonReentrant` function in the call stack.
*/
function _reentrancyGuardEntered() internal view returns (bool) {
ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage();
return $._status == ENTERED;
}
}// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.20;
enum YieldMode {
AUTOMATIC,
VOID,
CLAIMABLE
}
enum GasMode {
VOID,
CLAIMABLE
}// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.20;
import "../errors/PreMarket.sol";
import "../events/PreMarket.sol";
import { IPreMarketConfig } from "../interfaces/IPreMarketConfig.sol";
import { Market } from "../model/Market.sol";
import { Storage } from "../storage/PreMarket.sol";
import { PreMarketStorage } from "./PreMarketStorage.sol";
contract PreMarketConfig is PreMarketStorage, IPreMarketConfig {
function updateConfig(
address owner,
address collateral,
address feeWallet,
uint32 settleDurationSec,
uint16 minCollateralBPS,
uint16 maxCollateralBPS,
uint16 settleFeeBPS,
uint16 cancelFeeBPS,
uint256 minOrderUsdb,
uint256 minOrderWeth
)
external
{
Storage storage $ = _getOwnStorage();
require($.owner == msg.sender, "owner");
require(owner != address(0), "new owner");
require(collateral != address(0), "new collateral");
require(feeWallet != address(0), "new feeWallet");
require(settleDurationSec >= 86400, "settleDurationSec");
require(minCollateralBPS <= 10000, "minCollateralBPS");
require(maxCollateralBPS <= 10000, "maxCollateralBPS");
require(settleFeeBPS <= 10000, "settleFeeBPS");
require(cancelFeeBPS <= 10000, "cancelFeeBPS");
require(minOrderUsdb > 0, "minOrderUsdb");
require(minOrderWeth > 0, "minOrderWeth");
$.owner = owner;
$.collateral = collateral;
$.feeWallet = feeWallet;
$.settleDurationSec = settleDurationSec;
$.minCollateralBPS = minCollateralBPS;
$.maxCollateralBPS = maxCollateralBPS;
$.settleFeeBPS = settleFeeBPS;
$.cancelFeeBPS = cancelFeeBPS;
$.minOrderUsdb = minOrderUsdb;
$.minOrderWeth = minOrderWeth;
emit PreMarketEvents.UpdateConfig(
owner,
collateral,
feeWallet,
settleDurationSec,
minCollateralBPS,
maxCollateralBPS,
settleFeeBPS,
cancelFeeBPS,
minOrderUsdb,
minOrderWeth
);
}
function getConfig()
external
view
returns (
address owner,
address collateral,
address feeWallet,
uint32 settleDurationSec,
uint16 minCollateralBPS,
uint16 maxCollateralBPS,
uint16 settleFeeBPS,
uint16 cancelFeeBPS,
uint256 minOrderUsdb,
uint256 minOrderWeth
)
{
Storage storage $ = _getOwnStorage();
return (
$.owner,
$.collateral,
$.feeWallet,
$.settleDurationSec,
$.minCollateralBPS,
$.maxCollateralBPS,
$.settleFeeBPS,
$.cancelFeeBPS,
$.minOrderUsdb,
$.minOrderWeth
);
}
}// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.20;
import "../errors/PreMarket.sol";
import { IPreMarketFill } from "../interfaces/IPreMarketFill.sol";
import { Fill } from "../model/Fill.sol";
import { Market } from "../model/Market.sol";
import { Order } from "../model/Order.sol";
import { Storage } from "../storage/PreMarket.sol";
import { PreMarketStorage } from "./PreMarketStorage.sol";
contract PreMarketFill is PreMarketStorage, IPreMarketFill {
function getFill(uint256 fillId) external view returns (Fill memory) {
return _getOwnStorage().fills[fillId];
}
}// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.20;
import "../const/Market.sol";
import "../errors/PreMarket.sol";
import { MarketEvents } from "../events/Market.sol";
import { IPreMarketMarket } from "../interfaces/IPreMarketMarket.sol";
import { Market } from "../model/Market.sol";
import { Storage } from "../storage/PreMarket.sol";
import { PreMarketStorage } from "./PreMarketStorage.sol";
contract PreMarketMarkets is PreMarketStorage, IPreMarketMarket {
function createMarket(bytes32 name) external returns (uint32) {
Storage storage $ = _getOwnStorage();
if ($.owner != msg.sender) revert Unauthorized();
if (name == bytes32(0)) revert MarketNameMissing();
uint32 marketId = ++$.lastMarketId;
Market storage market = $.markets[marketId];
market.name = name;
market.locked = false;
emit MarketEvents.CreateMarket(marketId, name);
return marketId;
}
function updateMarket(
uint32 marketId,
bytes32 name,
address token,
uint32 goliveDate,
uint256 conversionRate
)
external
{
Storage storage $ = _getOwnStorage();
if ($.owner != msg.sender) revert Unauthorized();
Market storage market = $.markets[marketId];
if (market.name == bytes32(0)) revert MarketMissing(marketId);
if (token != market.token) {
require(conversionRate != 0, "malformed configuration");
}
market.name = name;
market.token = token;
market.conversionRate = conversionRate;
if (goliveDate != market.goliveDate) {
// if set, market golive date should not be in the past
if (goliveDate <= block.timestamp) revert MarketStaleGoliveDate(goliveDate, block.timestamp);
market.goliveDate = goliveDate;
market.expirationDate = goliveDate + $.settleDurationSec;
}
emit MarketEvents.UpdateMarket(
marketId, name, token, goliveDate, market.expirationDate, conversionRate
);
}
function lockMarket(uint32 marketId) external {
Storage storage $ = _getOwnStorage();
if ($.owner != msg.sender) revert Unauthorized();
Market storage market = $.markets[marketId];
if (market.name == bytes32(0)) revert MarketMissing(0);
if (market.locked) revert MarketAlreadyLocked();
market.locked = true;
emit MarketEvents.LockMarket(marketId);
}
function unlockMarket(uint32 marketId) external {
Storage storage $ = _getOwnStorage();
if ($.owner != msg.sender) revert Unauthorized();
Market storage market = $.markets[marketId];
if (market.name == bytes32(0)) revert MarketMissing(0);
if (!market.locked) revert MarketAlreadyUnocked();
market.locked = false;
emit MarketEvents.UnlockMarket(marketId);
}
function getMarket(uint32 marketId) external view returns (Market memory) {
return _getOwnStorage().markets[marketId];
}
function getMarketStatus(uint32 marketId) public view returns (uint8) {
return _getMarketStatus(_getOwnStorage().markets[marketId]);
}
function _getMarketStatus(Market storage market) internal view returns (uint8) {
if (market.name == bytes32(0)) revert MarketMissing(0);
if (market.locked == true) return MARKET_LOCKED;
if (market.goliveDate == 0 || market.goliveDate > block.timestamp) return MARKET_OPEN;
if (market.token != address(0) && market.conversionRate != 0) {
if (market.expirationDate > block.timestamp) return MARKET_SETTLING;
return MARKET_CLOSED;
} else {
return MARKET_INVALID;
}
}
}// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.20;
import "../const/Fill.sol";
import "../const/Market.sol";
import "../const/Order.sol";
import "../errors/PreMarket.sol";
import "../events/Market.sol";
import "../events/Order.sol";
import { ICollateral } from "../interfaces/ICollateral.sol";
import { IPreMarketOrder } from "../interfaces/IPreMarketOrder.sol";
import { Utils } from "../libs/Utils.sol";
import { Fill } from "../model/Fill.sol";
import { Market } from "../model/Market.sol";
import { Order } from "../model/Order.sol";
import { Storage } from "../storage/PreMarket.sol";
import { PreMarketMarkets } from "./PreMarketMarkets.sol";
import { PreMarketStorage } from "./PreMarketStorage.sol";
import { IERC20 } from "oz/token/ERC20/IERC20.sol";
import { SafeERC20 } from "oz/token/ERC20/utils/SafeERC20.sol";
import { Math } from "oz/utils/math/Math.sol";
import { ReentrancyGuardUpgradeable } from "ozu/utils/ReentrancyGuardUpgradeable.sol";
contract PreMarketOrdersV2 is
ReentrancyGuardUpgradeable,
PreMarketStorage,
PreMarketMarkets,
IPreMarketOrder
{
uint16 private constant BPS = 10000; // 100%
using SafeERC20 for IERC20;
function createOrder(
uint32 marketId,
uint256 marketAmount,
address paymentToken,
uint256 paymentAmount,
uint256 collateralAmount,
bool allowPartial,
uint8 side,
bytes calldata data
)
external
nonReentrant
returns (uint128 orderId)
{
if (side != 0 && side != 1) revert OrderSideMalformed(side);
if (marketId == 0) revert OrderMarketIdMissing();
if (marketAmount == 0) revert OrderMarketAmountMissing();
if (paymentToken == address(0)) revert OrderPaymentTokenMissing();
if (paymentAmount == 0) revert OrderPaymentAmountMissing();
Storage storage $ = _getOwnStorage();
if (paymentToken == $.usdb && paymentAmount < $.minOrderUsdb) {
revert MinimumOrderViolation(paymentAmount, $.minOrderUsdb); // 10e18
}
if (paymentToken == $.weth && paymentAmount < $.minOrderWeth) {
revert MinimumOrderViolation(paymentAmount, $.minOrderWeth); // 28e14
}
// payment amount should be within max allowed
if (paymentAmount > 1e32) revert MaximumOrderViolation(paymentAmount, 1e32);
// min 1 unit is allowed to be sold / bought
if (marketAmount < 1e18) revert MinimumOrderViolation(marketAmount, 1e18);
// max 100,000,000,000,000 units are allowed to be sold / bought
if (marketAmount > 1e32) revert MaximumOrderViolation(marketAmount, 1e32);
// payment token to be either weth or usdb
if (paymentToken != $.usdb && paymentToken != $.weth) {
revert OrderUnsupportedPaymentToken(paymentToken);
}
if (side == ORDER_SIDE_BUY) {
// buyer should deposit 100% of paymentAmount
if (collateralAmount != paymentAmount) {
revert OrderCollateralAmountOutOfBounds(collateralAmount);
}
} else {
// seller has to provide either 50% or 100% of paymentAmount as collateral
uint256 minCollateralAmount = Math.mulDiv($.minCollateralBPS, paymentAmount, BPS);
uint256 maxCollateralAmount = Math.mulDiv($.maxCollateralBPS, paymentAmount, BPS);
if (collateralAmount != minCollateralAmount && collateralAmount != maxCollateralAmount) {
revert OrderCollateralAmountOutOfBounds(collateralAmount);
}
}
if (_getMarketStatus($.markets[marketId]) != MARKET_OPEN) {
revert OrderMarketInvalidStatus();
}
orderId = ++$.lastOrderId;
IERC20(paymentToken).safeTransferFrom(msg.sender, address(this), collateralAmount);
Order storage order = $.orders[orderId];
order.side = side;
// implied order.status = ORDER_OPEN;
order.allowPartial = allowPartial;
// implied order.numFills = 0;
order.marketId = marketId;
order.marketAmount = marketAmount;
order.paymentToken = paymentToken;
order.paymentAmount = paymentAmount;
order.collateralAmount = collateralAmount;
// implied order.filledAmount = 0;
// implied order.settledAmount = 0;
order.maker = msg.sender;
emit OrderEvents.CreateOrder(
orderId,
marketId,
marketAmount,
paymentToken,
paymentAmount,
collateralAmount,
allowPartial,
side,
msg.sender
);
if (side == ORDER_SIDE_BUY) {
// buyer gets an nft
ICollateral($.collateral).mint(msg.sender, Utils.toTokenId(orderId, 0), data);
}
return orderId;
}
function repriceOrder(
uint128 orderId,
uint256 newMarketAmount
)
external
nonReentrant
returns (uint128 newOrderId)
{
Storage storage $ = _getOwnStorage();
Order storage order = $.orders[orderId];
Market storage market = $.markets[order.marketId];
if (_getMarketStatus(market) != MARKET_OPEN) {
revert OrderMarketInvalidStatus();
}
if (orderId == 0) revert OrderIdMissing();
if (order.marketId == 0) revert OrderNotFound();
if (order.side == ORDER_SIDE_BUY) {
if (msg.sender != ICollateral($.collateral).ownerOf(Utils.toTokenId(orderId, 0))) {
revert Unauthorized();
}
} else {
if (msg.sender != order.maker) revert Unauthorized();
}
if (order.status != ORDER_OPEN) revert OrderStatusInvalid();
if (newMarketAmount == 0) revert OrderMarketAmountMissing();
uint256 fees = Math.mulDiv(order.collateralAmount, $.cancelFeeBPS, BPS);
uint256 remainingCollateral = order.collateralAmount
- Math.mulDiv(order.filledAmount, order.collateralAmount, order.paymentAmount);
if (fees >= remainingCollateral) revert OrderInsufficientAmount();
if (fees > 0) IERC20(order.paymentToken).safeTransfer($.feeWallet, fees);
uint256 newCollateralAmount = remainingCollateral - fees;
uint256 newPaymentAmount =
Math.mulDiv(newCollateralAmount, order.paymentAmount, order.collateralAmount);
if (order.paymentToken == $.usdb && newCollateralAmount < $.minOrderUsdb) {
revert MinimumOrderViolation(newCollateralAmount, $.minOrderUsdb);
}
if (order.paymentToken == $.weth && newCollateralAmount < $.minOrderWeth) {
revert MinimumOrderViolation(newCollateralAmount, $.minOrderWeth);
}
// min 1 unit is allowed to be sold / bought
if (newMarketAmount < 1e18) revert MinimumOrderViolation(newMarketAmount, 1e18);
// max 100,000,000,000,000 units are allowed to be sold / bought
if (newMarketAmount > 1e32) revert MaximumOrderViolation(newMarketAmount, 1e32);
newOrderId = ++$.lastOrderId;
Order storage newOrder = $.orders[newOrderId];
newOrder.side = order.side;
// implied newOrder.status = ORDER_OPEN;
newOrder.allowPartial = order.allowPartial;
// implied newOrder.numFills = 0;
newOrder.marketId = order.marketId;
newOrder.marketAmount = newMarketAmount;
newOrder.paymentToken = order.paymentToken;
newOrder.paymentAmount = newPaymentAmount;
newOrder.collateralAmount = newCollateralAmount;
// implied newOrder.filledAmount = 0;
// implied newOrder.settledAmount = 0;
newOrder.maker = msg.sender;
emit OrderEvents.CreateOrder(
newOrderId,
newOrder.marketId,
newOrder.marketAmount,
newOrder.paymentToken,
newOrder.paymentAmount,
newOrder.collateralAmount,
newOrder.allowPartial,
newOrder.side,
msg.sender
);
if (newOrder.side == ORDER_SIDE_BUY) {
// buyer gets an nft
ICollateral($.collateral).mint(msg.sender, Utils.toTokenId(newOrderId, 0), abi.encodePacked());
}
if (order.filledAmount > 0) {
order.status = ORDER_FILLED;
order.marketAmount = Math.mulDiv(order.marketAmount, order.filledAmount, order.paymentAmount);
order.paymentAmount = order.filledAmount;
order.collateralAmount = order.collateralAmount - remainingCollateral;
emit OrderEvents.RepriceOrder(
orderId,
order.marketId,
newOrderId,
order.marketAmount,
newMarketAmount,
order.collateralAmount,
newOrder.collateralAmount,
msg.sender
);
} else {
if (order.side == ORDER_SIDE_BUY) {
ICollateral($.collateral).burn(Utils.toTokenId(orderId, 0));
}
order.status = ORDER_CANCELLED;
emit OrderEvents.CancelOrder(orderId, order.marketId, msg.sender);
}
return newOrderId;
}
function fillOrder(
uint128 orderId,
uint256 fillAmount,
bytes calldata data
)
external
nonReentrant
returns (uint256 fillId)
{
if (orderId == 0) revert OrderIdMissing();
Storage storage $ = _getOwnStorage();
Order storage order = $.orders[orderId];
if (order.marketId == 0) revert OrderNotFound();
if (order.status != ORDER_OPEN) revert OrderStatusInvalid();
if (order.maker == msg.sender) revert Unauthorized();
if (fillAmount < 1e18) revert MinimumOrderViolation(fillAmount, 1e18);
if (fillAmount > order.marketAmount) {
revert MinimumOrderViolation(fillAmount, order.marketAmount);
}
uint256 totalCost;
if (fillAmount == order.marketAmount) {
totalCost = order.paymentAmount;
} else {
totalCost = Math.mulDiv(fillAmount, order.paymentAmount, order.marketAmount);
}
if (order.paymentToken == $.usdb && totalCost < $.minOrderUsdb) {
revert MinimumOrderViolation(totalCost, $.minOrderUsdb);
}
if (order.paymentToken == $.weth && totalCost < $.minOrderWeth) {
revert MinimumOrderViolation(totalCost, $.minOrderWeth);
}
if (order.allowPartial) {
if (totalCost > order.paymentAmount - order.filledAmount) {
revert OrderInsufficientAmount();
}
} else {
if (order.filledAmount != 0) revert OrderStatusInvalid();
if (totalCost != order.paymentAmount) revert OrderInsufficientAmount();
}
if (_getMarketStatus($.markets[order.marketId]) != MARKET_OPEN) {
revert OrderMarketInvalidStatus();
}
order.filledAmount += totalCost;
order.status = (order.paymentAmount - order.filledAmount <= 1) ? ORDER_FILLED : ORDER_OPEN;
IERC20(order.paymentToken).safeTransferFrom(msg.sender, address(this), totalCost);
fillId = Utils.toTokenId(orderId, ++order.numFills);
Fill storage fill = $.fills[fillId];
fill.taker = msg.sender;
fill.amount = fillAmount;
fill.orderId = orderId;
// implied fill.status = FILL_OPEN;
emit OrderEvents.FillOrder(orderId, order.marketId, fillId, fillAmount, msg.sender);
if (order.side == ORDER_SIDE_SELL) {
// buyer gets an nft
ICollateral($.collateral).mint(msg.sender, fillId, data);
}
return fillId;
}
function cancelOrder(uint128 orderId) external nonReentrant {
Storage storage $ = _getOwnStorage();
Order storage order = $.orders[orderId];
if (order.marketId == 0) revert OrderNotFound();
if (order.status != ORDER_OPEN) revert OrderStatusInvalid();
if (order.filledAmount > 0) revert OrderStatusInvalid();
if (order.side == ORDER_SIDE_BUY) {
uint256 tokenId = Utils.toTokenId(orderId, 0);
if (msg.sender != ICollateral($.collateral).ownerOf(tokenId)) revert Unauthorized();
ICollateral($.collateral).burn(tokenId);
} else {
if (msg.sender != order.maker) revert Unauthorized();
}
order.status = ORDER_CANCELLED;
uint32 feeBPS = getMarketStatus(order.marketId) == MARKET_INVALID ? 0 : $.cancelFeeBPS;
uint256 fees = Math.mulDiv(order.collateralAmount, feeBPS, BPS);
uint256 payout = order.collateralAmount - fees;
IERC20(order.paymentToken).safeTransfer(msg.sender, payout);
if (fees > 0) IERC20(order.paymentToken).safeTransfer($.feeWallet, fees);
emit OrderEvents.CancelOrder(orderId, order.marketId, msg.sender);
}
function settleOrder(uint256 tokenId) external nonReentrant {
(uint128 orderId,) = Utils.fromTokenId(tokenId);
Storage storage $ = _getOwnStorage();
Order storage order = $.orders[orderId];
if (order.marketId == 0) revert OrderNotFound();
if (order.status != ORDER_OPEN && order.status != ORDER_FILLED) revert OrderStatusInvalid();
if (order.filledAmount == 0) revert OrderStatusInvalid();
Market storage market = $.markets[order.marketId];
if (_getMarketStatus(market) != MARKET_SETTLING) {
revert OrderMarketInvalidStatus();
}
uint256 marketTokenAmount;
uint256 paymentTokenAmount;
Fill storage fill = $.fills[tokenId];
if (order.side == ORDER_SIDE_BUY) {
if (fill.taker == address(0)) revert OrderFillNotFound(tokenId);
if (fill.taker != msg.sender) revert Unauthorized();
if (fill.status != FILL_OPEN) revert OrderFillInvalidStatus(fill.status);
marketTokenAmount = Math.mulDiv(fill.amount, market.conversionRate, 1e18);
paymentTokenAmount = Math.mulDiv(fill.amount, order.paymentAmount, order.marketAmount);
fill.status = FILL_SETTLED;
order.settledAmount += paymentTokenAmount;
} else {
if (order.maker != msg.sender) revert Unauthorized();
uint256 filled = Math.mulDiv(order.filledAmount, order.marketAmount, order.paymentAmount);
marketTokenAmount = Math.mulDiv(filled, market.conversionRate, 1e18);
paymentTokenAmount = order.filledAmount;
order.settledAmount = paymentTokenAmount;
}
if ((order.filledAmount - order.settledAmount) <= 1) {
order.status = ORDER_SETTLED;
}
IERC20(market.token).safeTransferFrom(msg.sender, address(this), marketTokenAmount);
uint256 buyerCollateral = order.side == ORDER_SIDE_BUY
? order.collateralAmount
: Math.mulDiv(fill.amount, order.paymentAmount, order.marketAmount);
uint256 sellerCollateral = order.side == ORDER_SIDE_BUY
? Math.mulDiv(fill.amount, order.paymentAmount, order.marketAmount)
: order.collateralAmount;
uint256 sellerPayout;
if (order.side == ORDER_SIDE_BUY) {
uint256 sellerCollateralRatioE18 = Math.mulDiv(sellerCollateral, 1e18, buyerCollateral);
sellerPayout = sellerCollateral + Math.mulDiv(buyerCollateral, sellerCollateralRatioE18, 1e18);
} else {
sellerPayout = sellerCollateral + order.filledAmount;
}
uint256 fees = Math.mulDiv(sellerPayout, $.settleFeeBPS, BPS);
IERC20(order.paymentToken).safeTransfer(msg.sender, sellerPayout - fees);
if (fees > 0) IERC20(order.paymentToken).safeTransfer($.feeWallet, fees);
emit OrderEvents.SettleOrder(orderId, order.marketId, tokenId, paymentTokenAmount, msg.sender);
}
function claimOrder(uint256 tokenId) external nonReentrant {
Storage storage $ = _getOwnStorage();
if (ICollateral($.collateral).ownerOf(tokenId) != msg.sender) revert Unauthorized();
(uint128 orderId,) = Utils.fromTokenId(tokenId);
Order storage order = $.orders[orderId];
if (order.marketId == 0) revert OrderNotFound();
if (order.status != ORDER_OPEN && order.status != ORDER_FILLED && order.status != ORDER_SETTLED)
{
revert OrderStatusInvalid();
}
Market storage market = $.markets[order.marketId];
uint8 mStatus = _getMarketStatus(market);
if (mStatus != MARKET_SETTLING && mStatus != MARKET_CLOSED) revert OrderMarketInvalidStatus();
if (order.side == ORDER_SIDE_BUY) {
uint256 deltaClaimed = order.settledAmount - order.claimedAmount;
if (deltaClaimed > 0) {
order.claimedAmount += deltaClaimed;
uint256 claimed = Math.mulDiv(deltaClaimed, order.marketAmount, order.paymentAmount);
uint256 marketTokenAmount = Math.mulDiv(claimed, market.conversionRate, 1e18);
uint256 fees = Math.mulDiv(marketTokenAmount, $.settleFeeBPS, BPS);
uint256 claimedAmount = marketTokenAmount - fees;
IERC20(market.token).safeTransfer(msg.sender, claimedAmount);
IERC20(market.token).safeTransfer($.feeWallet, fees);
emit OrderEvents.ClaimOrder(
orderId, order.marketId, tokenId, claimedAmount, market.token, msg.sender
);
}
if ((order.filledAmount - order.claimedAmount) <= 1) {
order.status = ORDER_CLAIMED;
// burn rights to claim again
ICollateral($.collateral).burn(tokenId);
} else if (mStatus == MARKET_CLOSED) {
order.status = ORDER_CLAIMED;
uint256 deltaForfeit = order.filledAmount - order.settledAmount;
if (deltaForfeit > 0) {
uint256 collateralAmount = deltaForfeit * 2;
uint256 fees = Math.mulDiv(collateralAmount, $.settleFeeBPS, BPS);
uint256 amount = collateralAmount - fees;
IERC20(order.paymentToken).safeTransfer(msg.sender, amount);
IERC20(order.paymentToken).safeTransfer($.feeWallet, fees);
emit OrderEvents.ClaimOrder(
orderId, order.marketId, tokenId, amount, order.paymentToken, msg.sender
);
}
// burn rights to claim again
ICollateral($.collateral).burn(tokenId);
}
} else {
Fill storage fill = $.fills[tokenId];
if (fill.taker == address(0)) revert OrderFillNotFound(tokenId);
if (fill.status != FILL_OPEN) revert OrderFillInvalidStatus(fill.status);
if (order.status == ORDER_SETTLED) {
fill.status = FILL_CLAIMED;
order.claimedAmount += Math.mulDiv(fill.amount, order.paymentAmount, order.marketAmount);
uint256 marketTokenAmount = Math.mulDiv(fill.amount, market.conversionRate, 1e18);
uint256 fees = Math.mulDiv(marketTokenAmount, $.settleFeeBPS, BPS);
uint256 amount = marketTokenAmount - fees;
IERC20(market.token).safeTransfer(msg.sender, amount);
IERC20(market.token).safeTransfer($.feeWallet, fees);
emit OrderEvents.ClaimOrder(
orderId, order.marketId, tokenId, amount, market.token, msg.sender
);
// burn rights to claim again
ICollateral($.collateral).burn(tokenId);
} else if (mStatus == MARKET_CLOSED) {
fill.status = FILL_CLAIMED;
uint256 deltaForfeit = Math.mulDiv(fill.amount, order.paymentAmount, order.marketAmount);
order.claimedAmount += deltaForfeit;
uint256 buyersShareOfSellersCollateralE18 =
Math.mulDiv(fill.amount, 1e18, order.marketAmount);
uint256 forfeitPayout = deltaForfeit
+ Math.mulDiv(order.collateralAmount, buyersShareOfSellersCollateralE18, 1e18);
uint256 fees = Math.mulDiv(forfeitPayout, $.settleFeeBPS, BPS);
uint256 claimedAmount = forfeitPayout - fees;
IERC20(order.paymentToken).safeTransfer(msg.sender, claimedAmount);
if (fees > 0) IERC20(order.paymentToken).safeTransfer($.feeWallet, fees);
emit OrderEvents.ClaimOrder(
orderId, order.marketId, tokenId, claimedAmount, order.paymentToken, msg.sender
);
// burn rights to claim again
ICollateral($.collateral).burn(tokenId);
}
if ((order.filledAmount - order.claimedAmount) <= 1) {
order.status = ORDER_CLAIMED;
}
}
}
function recoverOrder(uint256 tokenId) external {
Storage storage $ = _getOwnStorage();
(uint128 orderId,) = Utils.fromTokenId(tokenId);
Order storage order = $.orders[orderId];
if (order.marketId == 0) revert OrderNotFound();
Market storage market = $.markets[order.marketId];
if (_getMarketStatus(market) != MARKET_INVALID) revert OrderMarketInvalidStatus();
Fill storage fill = $.fills[tokenId];
bool isNFTOwner = false;
try ICollateral($.collateral).ownerOf(tokenId) returns (address nftOwner) {
isNFTOwner = nftOwner == msg.sender;
} catch (bytes memory) { }
if (isNFTOwner) {
if (order.side == ORDER_SIDE_BUY) {
if (order.status != ORDER_OPEN && order.status != ORDER_FILLED) revert OrderStatusInvalid();
order.status = ORDER_RECOVERED;
ICollateral($.collateral).burn(tokenId);
IERC20(order.paymentToken).safeTransfer(msg.sender, order.collateralAmount);
emit OrderEvents.RecoverFunds(
orderId, order.marketId, tokenId, order.collateralAmount, msg.sender
);
} else {
if (fill.status != FILL_OPEN) revert FillStatusInvalid();
fill.status = FILL_RECOVERED;
uint256 claimedAmount = Math.mulDiv(fill.amount, order.paymentAmount, order.marketAmount);
ICollateral($.collateral).burn(tokenId);
IERC20(order.paymentToken).safeTransfer(msg.sender, claimedAmount);
emit OrderEvents.RecoverFunds(orderId, order.marketId, tokenId, claimedAmount, msg.sender);
}
} else if (
(order.side == ORDER_SIDE_SELL && order.maker == msg.sender)
|| (order.side == ORDER_SIDE_BUY && fill.taker == msg.sender)
) {
if (order.side == ORDER_SIDE_BUY) {
if (fill.status != FILL_OPEN) revert FillStatusInvalid();
fill.status = FILL_RECOVERED;
uint256 claimedAmount = Math.mulDiv(fill.amount, order.paymentAmount, order.marketAmount);
IERC20(order.paymentToken).safeTransfer(msg.sender, claimedAmount);
emit OrderEvents.RecoverFunds(orderId, order.marketId, tokenId, claimedAmount, msg.sender);
} else {
if (order.status != ORDER_OPEN && order.status != ORDER_FILLED) revert OrderStatusInvalid();
order.status = ORDER_RECOVERED;
IERC20(order.paymentToken).safeTransfer(msg.sender, order.collateralAmount);
emit OrderEvents.RecoverFunds(
orderId, order.marketId, tokenId, order.collateralAmount, msg.sender
);
}
} else {
revert Unauthorized();
}
}
function getOrder(uint128 orderId) external view returns (Order memory) {
return _getOwnStorage().orders[orderId];
}
function getOrderMarketStatus(uint128 orderId) external view returns (uint8) {
Storage storage $ = _getOwnStorage();
return _getMarketStatus($.markets[$.orders[orderId].marketId]);
}
}// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.20;
import { Storage } from "../storage/PreMarket.sol";
contract PreMarketStorage {
// keccak256(abi.encode(uint256(keccak256("markets.pump.PreMarket")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant PreMarketStorageLocation =
0x80a98cd2d492b7b86287ff2105d133cc8f51a35b91a585bb6e4d3400a1adab00;
function _getOwnStorage() internal pure returns (Storage storage store) {
assembly {
store.slot := PreMarketStorageLocation
}
}
}// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.20;
import "../errors/PreMarket.sol";
import "../events/PreMarket.sol";
import { IPreMarketYield } from "../interfaces/IPreMarketYield.sol";
import { IERC20Rebasing } from "../interfaces/external/IERC20Rebasing.sol";
import { PreMarketStorage } from "./PreMarketStorage.sol";
contract PreMarketYield is PreMarketStorage, IPreMarketYield {
function getClaimableAmount(address token) external view returns (uint256) {
return IERC20Rebasing(token).getClaimableAmount(address(this));
}
function claimYield(address token, address receiver, uint256 amount) external {
if (_getOwnStorage().owner != msg.sender) revert Unauthorized();
IERC20Rebasing(token).claim(receiver, amount);
emit PreMarketEvents.ClaimYield(token, receiver, amount);
}
}// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.20;
import { GasMode, YieldMode } from "../../const/Blast.sol";
interface IBlast {
function configure(YieldMode _yield, GasMode gasMode, address governor) external;
function configureClaimableYield() external;
function configureClaimableGas() external;
function claimAllYield(
address contractAddress,
address recipientOfYield
)
external
returns (uint256);
function claimAllGas(address contractAddress, address recipientOfGas) external returns (uint256);
}// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.20;
interface IBlastPoints {
function configurePointsOperator(address operator) external;
}// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.20;
import { YieldMode } from "../../const/Blast.sol";
interface IERC20Rebasing {
function configure(YieldMode) external returns (uint256);
function claim(address recipient, uint256 amount) external returns (uint256);
function getClaimableAmount(address account) external view returns (uint256);
}// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.20; error Unauthorized(); error MarketNameMissing(); error MarketMalformedConfig(); error MarketMissing(uint256 id); error MarketLive(); error MarketAlreadyLocked(); error MarketAlreadyUnocked(); error MarketStaleGoliveDate(uint256 current, uint256 proposed); error MinimumOrderViolation(uint256 current, uint256 proposed); error MaximumOrderViolation(uint256 current, uint256 proposed); error OrderSideMalformed(uint8 proposed); error OrderMarketIdMissing(); error OrderMarketAmountMissing(); error OrderPaymentTokenMissing(); error OrderPaymentAmountMissing(); error OrderUnsupportedPaymentToken(address proposed); error OrderCollateralAmountOutOfBounds(uint256 proposed); error OrderMarketInvalidStatus(); error OrderIdMissing(); error OrderNotFound(); error OrderStatusInvalid(); error OrderInsufficientAmount(); error OrderMissingFillId(); error OrderFillNotFound(uint256 fillId); error OrderFillInvalidStatus(uint8 status); error FillStatusInvalid(); error InvalidOwnerAddress(); error InvalidFeeWalletAddress(); error InvalidCancelFeeBPS(); error InvalidSettleFeeBPS();
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.20;
import { Fill } from "../model/Fill.sol";
import { Market } from "../model/Market.sol";
import { Order } from "../model/Order.sol";
struct Storage {
mapping(uint32 => Market) markets;
mapping(uint128 => Order) orders;
mapping(uint256 => Fill) fills;
uint32 lastMarketId;
uint128 lastOrderId;
address owner;
uint32 settleDurationSec; // 86400
uint16 minCollateralBPS; // 0-10000
uint16 maxCollateralBPS; // 0-10000
address weth;
address usdb;
address collateral;
address feeWallet;
uint16 settleFeeBPS; // 0-10000
uint16 cancelFeeBPS; // 0-10000
uint256 minOrderUsdb;
uint256 minOrderWeth;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/draft-IERC1822.sol)
pragma solidity ^0.8.20;
/**
* @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified
* proxy whose upgrades are fully controlled by the current implementation.
*/
interface IERC1822Proxiable {
/**
* @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation
* address.
*
* IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
* bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
* function revert if invoked through a proxy.
*/
function proxiableUUID() external view returns (bytes32);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (proxy/ERC1967/ERC1967Utils.sol)
pragma solidity ^0.8.20;
import {IBeacon} from "../beacon/IBeacon.sol";
import {Address} from "../../utils/Address.sol";
import {StorageSlot} from "../../utils/StorageSlot.sol";
/**
* @dev This abstract contract provides getters and event emitting update functions for
* https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.
*/
library ERC1967Utils {
// We re-declare ERC-1967 events here because they can't be used directly from IERC1967.
// This will be fixed in Solidity 0.8.21. At that point we should remove these events.
/**
* @dev Emitted when the implementation is upgraded.
*/
event Upgraded(address indexed implementation);
/**
* @dev Emitted when the admin account has changed.
*/
event AdminChanged(address previousAdmin, address newAdmin);
/**
* @dev Emitted when the beacon is changed.
*/
event BeaconUpgraded(address indexed beacon);
/**
* @dev Storage slot with the address of the current implementation.
* This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1.
*/
// solhint-disable-next-line private-vars-leading-underscore
bytes32 internal constant IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
/**
* @dev The `implementation` of the proxy is invalid.
*/
error ERC1967InvalidImplementation(address implementation);
/**
* @dev The `admin` of the proxy is invalid.
*/
error ERC1967InvalidAdmin(address admin);
/**
* @dev The `beacon` of the proxy is invalid.
*/
error ERC1967InvalidBeacon(address beacon);
/**
* @dev An upgrade function sees `msg.value > 0` that may be lost.
*/
error ERC1967NonPayable();
/**
* @dev Returns the current implementation address.
*/
function getImplementation() internal view returns (address) {
return StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value;
}
/**
* @dev Stores a new address in the EIP1967 implementation slot.
*/
function _setImplementation(address newImplementation) private {
if (newImplementation.code.length == 0) {
revert ERC1967InvalidImplementation(newImplementation);
}
StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value = newImplementation;
}
/**
* @dev Performs implementation upgrade with additional setup call if data is nonempty.
* This function is payable only if the setup call is performed, otherwise `msg.value` is rejected
* to avoid stuck value in the contract.
*
* Emits an {IERC1967-Upgraded} event.
*/
function upgradeToAndCall(address newImplementation, bytes memory data) internal {
_setImplementation(newImplementation);
emit Upgraded(newImplementation);
if (data.length > 0) {
Address.functionDelegateCall(newImplementation, data);
} else {
_checkNonPayable();
}
}
/**
* @dev Storage slot with the admin of the contract.
* This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1.
*/
// solhint-disable-next-line private-vars-leading-underscore
bytes32 internal constant ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
/**
* @dev Returns the current admin.
*
* TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using
* the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.
* `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`
*/
function getAdmin() internal view returns (address) {
return StorageSlot.getAddressSlot(ADMIN_SLOT).value;
}
/**
* @dev Stores a new address in the EIP1967 admin slot.
*/
function _setAdmin(address newAdmin) private {
if (newAdmin == address(0)) {
revert ERC1967InvalidAdmin(address(0));
}
StorageSlot.getAddressSlot(ADMIN_SLOT).value = newAdmin;
}
/**
* @dev Changes the admin of the proxy.
*
* Emits an {IERC1967-AdminChanged} event.
*/
function changeAdmin(address newAdmin) internal {
emit AdminChanged(getAdmin(), newAdmin);
_setAdmin(newAdmin);
}
/**
* @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.
* This is the keccak-256 hash of "eip1967.proxy.beacon" subtracted by 1.
*/
// solhint-disable-next-line private-vars-leading-underscore
bytes32 internal constant BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;
/**
* @dev Returns the current beacon.
*/
function getBeacon() internal view returns (address) {
return StorageSlot.getAddressSlot(BEACON_SLOT).value;
}
/**
* @dev Stores a new beacon in the EIP1967 beacon slot.
*/
function _setBeacon(address newBeacon) private {
if (newBeacon.code.length == 0) {
revert ERC1967InvalidBeacon(newBeacon);
}
StorageSlot.getAddressSlot(BEACON_SLOT).value = newBeacon;
address beaconImplementation = IBeacon(newBeacon).implementation();
if (beaconImplementation.code.length == 0) {
revert ERC1967InvalidImplementation(beaconImplementation);
}
}
/**
* @dev Change the beacon and trigger a setup call if data is nonempty.
* This function is payable only if the setup call is performed, otherwise `msg.value` is rejected
* to avoid stuck value in the contract.
*
* Emits an {IERC1967-BeaconUpgraded} event.
*
* CAUTION: Invoking this function has no effect on an instance of {BeaconProxy} since v5, since
* it uses an immutable beacon without looking at the value of the ERC-1967 beacon slot for
* efficiency.
*/
function upgradeBeaconToAndCall(address newBeacon, bytes memory data) internal {
_setBeacon(newBeacon);
emit BeaconUpgraded(newBeacon);
if (data.length > 0) {
Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);
} else {
_checkNonPayable();
}
}
/**
* @dev Reverts if `msg.value` is not zero. It can be used to avoid `msg.value` stuck in the contract
* if an upgrade doesn't perform an initialization call.
*/
function _checkNonPayable() private {
if (msg.value > 0) {
revert ERC1967NonPayable();
}
}
}// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.20;
// forgefmt: disable-start
library PreMarketEvents {
event UpdateConfig(
address owner,
address collateral,
address feeWallet,
uint32 settleDurationSec,
uint16 minCollateralBPS,
uint16 maxCollateralBPS,
uint16 settleFeeBPS,
uint16 cancelFeeBPS,
uint256 minOrderUsdb,
uint256 minOrderWeth
);
event ClaimYield(
address token,
address receiver,
uint256 amount
);
}//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.20;
interface IPreMarketConfig {
function updateConfig(
address owner,
address collateral,
address feeWallet,
uint32 settleDurationSec,
uint16 minCollateralBPS,
uint16 maxCollateralBPS,
uint16 settleFeeBPS,
uint16 cancelFeeBPS,
uint256 minOrderUsdb,
uint256 minOrderWeth
)
external;
function getConfig()
external
view
returns (
address owner,
address collateral,
address feeWallet,
uint32 settleDurationSec,
uint16 minCollateralBPS,
uint16 maxCollateralBPS,
uint16 settleFeeBPS,
uint16 cancelFeeBPS,
uint256 minOrderUsdb,
uint256 minOrderWeth
);
}// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.20;
struct Market {
bytes32 name;
address token;
bool locked;
uint32 goliveDate;
uint32 expirationDate;
uint256 conversionRate;
}//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.20;
import { Fill } from "../model/Fill.sol";
interface IPreMarketFill {
function getFill(uint256 tokenId) external view returns (Fill memory);
}// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.20;
struct Fill {
address taker;
uint256 amount;
uint128 orderId;
uint8 status;
}// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.20;
struct Order {
// _s0
uint8 side;
uint8 status;
bool allowPartial;
uint32 numFills;
uint32 marketId;
// _s1
uint256 marketAmount;
// _s2
address paymentToken;
// _s3
uint256 paymentAmount;
// _s4
uint256 collateralAmount;
// _s5
uint256 filledAmount;
// _s6
uint256 settledAmount;
// _s7
uint256 claimedAmount;
// _s8
address maker;
}// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.20; uint8 constant MARKET_OPEN = 0; uint8 constant MARKET_SETTLING = 1; uint8 constant MARKET_CLOSED = 2; uint8 constant MARKET_LOCKED = 3; uint8 constant MARKET_INVALID = 4;
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.20;
// forgefmt: disable-start
library MarketEvents {
event CreateMarket(
uint32 indexed marketId,
bytes32 name
);
event UpdateMarket(
uint32 indexed marketId,
bytes32 name,
address token,
uint32 goliveDate,
uint32 expirationDate,
uint256 conversionRate
);
event LockMarket(
uint32 indexed marketId
);
event UnlockMarket(
uint32 indexed marketId
);
}//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.20;
import { Market } from "../model/Market.sol";
interface IPreMarketMarket {
function createMarket(bytes32 name) external returns (uint32 marketId);
function updateMarket(
uint32 marketId,
bytes32 name,
address token,
uint32 goliveDate,
uint256 conversionRate
)
external;
function lockMarket(uint32 marketId) external;
function unlockMarket(uint32 marketId) external;
function getMarket(uint32 marketId) external view returns (Market memory);
function getMarketStatus(uint32 marketId) external view returns (uint8);
}// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.20; uint8 constant FILL_OPEN = 0; uint8 constant FILL_SETTLED = 1; uint8 constant FILL_CLAIMED = 2; uint8 constant FILL_RECOVERED = 3;
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.20; uint8 constant ORDER_OPEN = 0; uint8 constant ORDER_CANCELLED = 1; uint8 constant ORDER_FILLED = 2; uint8 constant ORDER_SETTLED = 3; uint8 constant ORDER_CLAIMED = 4; uint8 constant ORDER_RECOVERED = 5; uint8 constant ORDER_SIDE_BUY = 0; uint8 constant ORDER_SIDE_SELL = 1;
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.20;
// forgefmt: disable-start
library OrderEvents {
event CreateOrder(
uint128 indexed orderId,
uint32 indexed marketId,
uint256 marketAmount,
address paymentToken,
uint256 paymentAmount,
uint256 collateralAmount,
bool allowPartial,
uint8 side,
address actor
);
event RepriceOrder(
uint128 indexed orderId,
uint32 indexed marketId,
uint128 indexed newOrderId,
uint256 marketAmount,
uint256 newMarketAmount,
uint256 collateralAmount,
uint256 newCollateralAmount,
address actor
);
event FillOrder(
uint128 indexed orderId,
uint32 indexed marketId,
uint256 indexed fillId,
uint256 fillAmount,
address actor
);
event CancelOrder(
uint128 indexed orderId,
uint32 indexed marketId,
address actor
);
event SettleOrder(
uint128 indexed orderId,
uint32 indexed marketId,
uint256 indexed fillId,
uint256 settledAmount,
address actor
);
event ClaimOrder(
uint128 indexed orderId,
uint32 indexed marketId,
uint256 indexed fillId,
uint256 claimedAmount,
address claimedToken,
address actor
);
event RecoverFunds(
uint128 indexed orderId,
uint32 indexed marketId,
uint256 indexed fillId,
uint256 recoveredAmount,
address actor
);
}
// forgefmt: disable-end//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.20;
import { ICollateralBurnable } from "./ICollateralBurnable.sol";
import { ICollateralConfig } from "./ICollateralConfig.sol";
import { ICollateralMetadata } from "./ICollateralMetadata.sol";
import { ICollateralMintable } from "./ICollateralMintable.sol";
import { IERC721 } from "oz/token/ERC721/IERC721.sol";
interface ICollateral is
IERC721,
ICollateralConfig,
ICollateralMintable,
ICollateralBurnable,
ICollateralMetadata
{ }//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.20;
import { Order } from "../model/Order.sol";
interface IPreMarketOrder {
function createOrder(
uint32 marketId,
uint256 marketAmount,
address paymentToken,
uint256 paymentAmount,
uint256 collateralAmount,
bool allowPartial,
uint8 side,
bytes calldata data
)
external
returns (uint128 orderId);
function fillOrder(
uint128 orderId,
uint256 fillAmount,
bytes calldata data
)
external
returns (uint256 fillId);
function repriceOrder(
uint128 orderId,
uint256 newMarketAmount
)
external
returns (uint128 newOrderId);
function cancelOrder(uint128 orderId) external;
function settleOrder(uint256 tokenId) external;
function claimOrder(uint256 tokenId) external;
function recoverOrder(uint256 tokenId) external;
function getOrder(uint128 id) external view returns (Order memory);
function getOrderMarketStatus(uint128 id) external view returns (uint8);
}// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.20;
library Utils {
function timestamp() internal view returns (uint32 value) {
value = uint32(block.timestamp % 2 ** 32);
}
function toTokenId(uint128 orderId, uint32 fillId) internal pure returns (uint256) {
return uint256(bytes32(uint256(orderId) << 128 | uint128(fillId)));
}
function fromTokenId(uint256 tokenId) internal pure returns (uint128, uint32) {
return (uint128(tokenId >> 128), uint32(tokenId));
}
function bytes32ToString(bytes32 _bytes32) internal pure returns (string memory) {
uint8 i = 0;
while (i < 32 && _bytes32[i] != 0) {
unchecked {
++i;
}
}
bytes memory bytesArray = new bytes(i);
for (i = 0; i < 32 && _bytes32[i] != 0;) {
bytesArray[i] = _bytes32[i];
unchecked {
++i;
}
}
return string(bytesArray);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the value of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the value of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 value) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the
* allowance mechanism. `value` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 value) external returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../IERC20.sol";
import {IERC20Permit} from "../extensions/IERC20Permit.sol";
import {Address} from "../../../utils/Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using Address for address;
/**
* @dev An operation with an ERC20 token failed.
*/
error SafeERC20FailedOperation(address token);
/**
* @dev Indicates a failed `decreaseAllowance` request.
*/
error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);
/**
* @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));
}
/**
* @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
* calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
*/
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));
}
/**
* @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 oldAllowance = token.allowance(address(this), spender);
forceApprove(token, spender, oldAllowance + value);
}
/**
* @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
* value, non-reverting calls are assumed to be successful.
*/
function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
unchecked {
uint256 currentAllowance = token.allowance(address(this), spender);
if (currentAllowance < requestedDecrease) {
revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
}
forceApprove(token, spender, currentAllowance - requestedDecrease);
}
}
/**
* @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
* to be set to zero before setting it to a non-zero value, such as USDT.
*/
function forceApprove(IERC20 token, address spender, uint256 value) internal {
bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));
if (!_callOptionalReturnBool(token, approvalCall)) {
_callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));
_callOptionalReturn(token, approvalCall);
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data);
if (returndata.length != 0 && !abi.decode(returndata, (bool))) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*
* This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
*/
function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false
// and not revert is the subcall reverts.
(bool success, bytes memory returndata) = address(token).call(data);
return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && address(token).code.length > 0;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/Math.sol)
pragma solidity ^0.8.20;
/**
* @dev Standard math utilities missing in the Solidity language.
*/
library Math {
/**
* @dev Muldiv operation overflow.
*/
error MathOverflowedMulDiv();
enum Rounding {
Floor, // Toward negative infinity
Ceil, // Toward positive infinity
Trunc, // Toward zero
Expand // Away from zero
}
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the subtraction of two unsigned integers, with an overflow flag.
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
/**
* @dev Returns the largest of two numbers.
*/
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a > b ? a : b;
}
/**
* @dev Returns the smallest of two numbers.
*/
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two numbers. The result is rounded towards
* zero.
*/
function average(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b) / 2 can overflow.
return (a & b) + (a ^ b) / 2;
}
/**
* @dev Returns the ceiling of the division of two numbers.
*
* This differs from standard division with `/` in that it rounds towards infinity instead
* of rounding towards zero.
*/
function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
if (b == 0) {
// Guarantee the same behavior as in a regular Solidity division.
return a / b;
}
// (a + b - 1) / b can overflow on addition, so we distribute.
return a == 0 ? 0 : (a - 1) / b + 1;
}
/**
* @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or
* denominator == 0.
* @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by
* Uniswap Labs also under MIT license.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {
unchecked {
// 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
// use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
// variables such that product = prod1 * 2^256 + prod0.
uint256 prod0 = x * y; // Least significant 256 bits of the product
uint256 prod1; // Most significant 256 bits of the product
assembly {
let mm := mulmod(x, y, not(0))
prod1 := sub(sub(mm, prod0), lt(mm, prod0))
}
// Handle non-overflow cases, 256 by 256 division.
if (prod1 == 0) {
// Solidity will revert if denominator == 0, unlike the div opcode on its own.
// The surrounding unchecked block does not change this fact.
// See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
return prod0 / denominator;
}
// Make sure the result is less than 2^256. Also prevents denominator == 0.
if (denominator <= prod1) {
revert MathOverflowedMulDiv();
}
///////////////////////////////////////////////
// 512 by 256 division.
///////////////////////////////////////////////
// Make division exact by subtracting the remainder from [prod1 prod0].
uint256 remainder;
assembly {
// Compute remainder using mulmod.
remainder := mulmod(x, y, denominator)
// Subtract 256 bit number from 512 bit number.
prod1 := sub(prod1, gt(remainder, prod0))
prod0 := sub(prod0, remainder)
}
// Factor powers of two out of denominator and compute largest power of two divisor of denominator.
// Always >= 1. See https://cs.stackexchange.com/q/138556/92363.
uint256 twos = denominator & (0 - denominator);
assembly {
// Divide denominator by twos.
denominator := div(denominator, twos)
// Divide [prod1 prod0] by twos.
prod0 := div(prod0, twos)
// Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
twos := add(div(sub(0, twos), twos), 1)
}
// Shift in bits from prod1 into prod0.
prod0 |= prod1 * twos;
// Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
// that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
// four bits. That is, denominator * inv = 1 mod 2^4.
uint256 inverse = (3 * denominator) ^ 2;
// Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also
// works in modular arithmetic, doubling the correct bits in each step.
inverse *= 2 - denominator * inverse; // inverse mod 2^8
inverse *= 2 - denominator * inverse; // inverse mod 2^16
inverse *= 2 - denominator * inverse; // inverse mod 2^32
inverse *= 2 - denominator * inverse; // inverse mod 2^64
inverse *= 2 - denominator * inverse; // inverse mod 2^128
inverse *= 2 - denominator * inverse; // inverse mod 2^256
// Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
// This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
// less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
// is no longer required.
result = prod0 * inverse;
return result;
}
}
/**
* @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {
uint256 result = mulDiv(x, y, denominator);
if (unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0) {
result += 1;
}
return result;
}
/**
* @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded
* towards zero.
*
* Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
*/
function sqrt(uint256 a) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
// For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
//
// We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
// `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
//
// This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
// → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
// → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
//
// Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
uint256 result = 1 << (log2(a) >> 1);
// At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
// since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
// every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
// into the expected uint128 result.
unchecked {
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
return min(result, a / result);
}
}
/**
* @notice Calculates sqrt(a), following the selected rounding direction.
*/
function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = sqrt(a);
return result + (unsignedRoundsUp(rounding) && result * result < a ? 1 : 0);
}
}
/**
* @dev Return the log in base 2 of a positive value rounded towards zero.
* Returns 0 if given 0.
*/
function log2(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 128;
}
if (value >> 64 > 0) {
value >>= 64;
result += 64;
}
if (value >> 32 > 0) {
value >>= 32;
result += 32;
}
if (value >> 16 > 0) {
value >>= 16;
result += 16;
}
if (value >> 8 > 0) {
value >>= 8;
result += 8;
}
if (value >> 4 > 0) {
value >>= 4;
result += 4;
}
if (value >> 2 > 0) {
value >>= 2;
result += 2;
}
if (value >> 1 > 0) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 2, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log2(value);
return result + (unsignedRoundsUp(rounding) && 1 << result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 10 of a positive value rounded towards zero.
* Returns 0 if given 0.
*/
function log10(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >= 10 ** 64) {
value /= 10 ** 64;
result += 64;
}
if (value >= 10 ** 32) {
value /= 10 ** 32;
result += 32;
}
if (value >= 10 ** 16) {
value /= 10 ** 16;
result += 16;
}
if (value >= 10 ** 8) {
value /= 10 ** 8;
result += 8;
}
if (value >= 10 ** 4) {
value /= 10 ** 4;
result += 4;
}
if (value >= 10 ** 2) {
value /= 10 ** 2;
result += 2;
}
if (value >= 10 ** 1) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 10, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log10(value);
return result + (unsignedRoundsUp(rounding) && 10 ** result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 256 of a positive value rounded towards zero.
* Returns 0 if given 0.
*
* Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
*/
function log256(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 16;
}
if (value >> 64 > 0) {
value >>= 64;
result += 8;
}
if (value >> 32 > 0) {
value >>= 32;
result += 4;
}
if (value >> 16 > 0) {
value >>= 16;
result += 2;
}
if (value >> 8 > 0) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 256, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log256(value);
return result + (unsignedRoundsUp(rounding) && 1 << (result << 3) < value ? 1 : 0);
}
}
/**
* @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers.
*/
function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {
return uint8(rounding) % 2 == 1;
}
}//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.20;
import { YieldMode } from "./external/IBlast.sol";
interface IPreMarketYield {
function getClaimableAmount(address token) external view returns (uint256);
function claimYield(address token, address receiver, uint256 amount) external;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (proxy/beacon/IBeacon.sol)
pragma solidity ^0.8.20;
/**
* @dev This is the interface that {BeaconProxy} expects of its beacon.
*/
interface IBeacon {
/**
* @dev Must return an address that can be used as a delegate call target.
*
* {UpgradeableBeacon} will check that this address is a contract.
*/
function implementation() external view returns (address);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)
pragma solidity ^0.8.20;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev The ETH balance of the account is not enough to perform the operation.
*/
error AddressInsufficientBalance(address account);
/**
* @dev There's no code at `target` (it is not a contract).
*/
error AddressEmptyCode(address target);
/**
* @dev A call to an address target failed. The target may have reverted.
*/
error FailedInnerCall();
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
if (address(this).balance < amount) {
revert AddressInsufficientBalance(address(this));
}
(bool success, ) = recipient.call{value: amount}("");
if (!success) {
revert FailedInnerCall();
}
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason or custom error, it is bubbled
* up by this function (like regular Solidity function calls). However, if
* the call reverted with no returned reason, this function reverts with a
* {FailedInnerCall} error.
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
if (address(this).balance < value) {
revert AddressInsufficientBalance(address(this));
}
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target
* was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an
* unsuccessful call.
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata
) internal view returns (bytes memory) {
if (!success) {
_revert(returndata);
} else {
// only check if target is a contract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
if (returndata.length == 0 && target.code.length == 0) {
revert AddressEmptyCode(target);
}
return returndata;
}
}
/**
* @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the
* revert reason or with a default {FailedInnerCall} error.
*/
function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {
if (!success) {
_revert(returndata);
} else {
return returndata;
}
}
/**
* @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.
*/
function _revert(bytes memory returndata) private pure {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert FailedInnerCall();
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/StorageSlot.sol)
// This file was procedurally generated from scripts/generate/templates/StorageSlot.js.
pragma solidity ^0.8.20;
/**
* @dev Library for reading and writing primitive types to specific storage slots.
*
* Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
* This library helps with reading and writing to such slots without the need for inline assembly.
*
* The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
*
* Example usage to set ERC1967 implementation slot:
* ```solidity
* contract ERC1967 {
* bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
*
* function _getImplementation() internal view returns (address) {
* return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
* }
*
* function _setImplementation(address newImplementation) internal {
* require(newImplementation.code.length > 0);
* StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
* }
* }
* ```
*/
library StorageSlot {
struct AddressSlot {
address value;
}
struct BooleanSlot {
bool value;
}
struct Bytes32Slot {
bytes32 value;
}
struct Uint256Slot {
uint256 value;
}
struct StringSlot {
string value;
}
struct BytesSlot {
bytes value;
}
/**
* @dev Returns an `AddressSlot` with member `value` located at `slot`.
*/
function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `BooleanSlot` with member `value` located at `slot`.
*/
function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `Bytes32Slot` with member `value` located at `slot`.
*/
function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `Uint256Slot` with member `value` located at `slot`.
*/
function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `StringSlot` with member `value` located at `slot`.
*/
function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `StringSlot` representation of the string storage pointer `store`.
*/
function getStringSlot(string storage store) internal pure returns (StringSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := store.slot
}
}
/**
* @dev Returns an `BytesSlot` with member `value` located at `slot`.
*/
function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`.
*/
function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := store.slot
}
}
}//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.20;
interface ICollateralBurnable {
function burn(uint256 orderId) external;
}//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.20;
interface ICollateralConfig {
function updateConfig(address owner, address operator, bytes32 tokenUri) external;
function getConfig() external view returns (address owner, address operator, bytes32 tokenUri);
}//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.20;
interface ICollateralMetadata {
function tokenURI(uint256 tokenId) external returns (string memory);
}//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.20;
interface ICollateralMintable {
function mint(address receiver, uint256 tokenId, bytes calldata data) external;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/IERC721.sol)
pragma solidity ^0.8.20;
import {IERC165} from "../../utils/introspection/IERC165.sol";
/**
* @dev Required interface of an ERC721 compliant contract.
*/
interface IERC721 is IERC165 {
/**
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
*/
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
*/
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
*/
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/**
* @dev Returns the number of tokens in ``owner``'s account.
*/
function balanceOf(address owner) external view returns (uint256 balance);
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) external view returns (address owner);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon
* a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must have been allowed to move this token by either {approve} or
* {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon
* a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(address from, address to, uint256 tokenId) external;
/**
* @dev Transfers `tokenId` token from `from` to `to`.
*
* WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721
* or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must
* understand this adds an external call which potentially creates a reentrancy vulnerability.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 tokenId) external;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the address zero.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool approved) external;
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}
*/
function isApprovedForAll(address owner, address operator) external view returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Permit.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
* https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
*
* Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
* presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
* need to send a transaction, and thus is not required to hold Ether at all.
*
* ==== Security Considerations
*
* There are two important considerations concerning the use of `permit`. The first is that a valid permit signature
* expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be
* considered as an intention to spend the allowance in any specific way. The second is that because permits have
* built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should
* take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be
* generally recommended is:
*
* ```solidity
* function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {
* try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}
* doThing(..., value);
* }
*
* function doThing(..., uint256 value) public {
* token.safeTransferFrom(msg.sender, address(this), value);
* ...
* }
* ```
*
* Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of
* `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also
* {SafeERC20-safeTransferFrom}).
*
* Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so
* contracts should have entry points that don't rely on permit.
*/
interface IERC20Permit {
/**
* @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
* given ``owner``'s signed approval.
*
* IMPORTANT: The same issues {IERC20-approve} has related to transaction
* ordering also apply here.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `deadline` must be a timestamp in the future.
* - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
* over the EIP712-formatted function arguments.
* - the signature must use ``owner``'s current nonce (see {nonces}).
*
* For more information on the signature format, see the
* https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
* section].
*
* CAUTION: See Security Considerations above.
*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
/**
* @dev Returns the current nonce for `owner`. This value must be
* included whenever a signature is generated for {permit}.
*
* Every successful call to {permit} increases ``owner``'s nonce by one. This
* prevents a signature from being used multiple times.
*/
function nonces(address owner) external view returns (uint256);
/**
* @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view returns (bytes32);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}{
"remappings": [
"ds-test/=lib/forge-std/lib/ds-test/src/",
"forge-std/=lib/forge-std/src/",
"openzeppelin-foundry-upgrades/=lib/openzeppelin-foundry-upgrades/src/",
"sol-uriencode/=lib/sol-uriencode/src/",
"solidity-stringutils/=lib/openzeppelin-foundry-upgrades/lib/solidity-stringutils/",
"oz/=lib/openzeppelin-contracts/contracts/",
"ozu/=lib/openzeppelin-contracts-upgradeable/contracts/",
"@prb/math/=lib/prb-math/",
"@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/",
"@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
"@prb/test/=lib/prb-math/node_modules/@prb/test/",
"erc4626-tests/=lib/openzeppelin-contracts-upgradeable/lib/erc4626-tests/",
"openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/",
"openzeppelin-contracts/=lib/openzeppelin-contracts/",
"prb-math/=lib/prb-math/src/"
],
"optimizer": {
"enabled": true,
"runs": 200
},
"metadata": {
"useLiteralContent": false,
"bytecodeHash": "ipfs",
"appendCBOR": true
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"evmVersion": "paris",
"libraries": {}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"address","name":"target","type":"address"}],"name":"AddressEmptyCode","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"AddressInsufficientBalance","type":"error"},{"inputs":[{"internalType":"address","name":"implementation","type":"address"}],"name":"ERC1967InvalidImplementation","type":"error"},{"inputs":[],"name":"ERC1967NonPayable","type":"error"},{"inputs":[],"name":"FailedInnerCall","type":"error"},{"inputs":[],"name":"FillStatusInvalid","type":"error"},{"inputs":[],"name":"InvalidInitialization","type":"error"},{"inputs":[],"name":"MarketAlreadyLocked","type":"error"},{"inputs":[],"name":"MarketAlreadyUnocked","type":"error"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"name":"MarketMissing","type":"error"},{"inputs":[],"name":"MarketNameMissing","type":"error"},{"inputs":[{"internalType":"uint256","name":"current","type":"uint256"},{"internalType":"uint256","name":"proposed","type":"uint256"}],"name":"MarketStaleGoliveDate","type":"error"},{"inputs":[],"name":"MathOverflowedMulDiv","type":"error"},{"inputs":[{"internalType":"uint256","name":"current","type":"uint256"},{"internalType":"uint256","name":"proposed","type":"uint256"}],"name":"MaximumOrderViolation","type":"error"},{"inputs":[{"internalType":"uint256","name":"current","type":"uint256"},{"internalType":"uint256","name":"proposed","type":"uint256"}],"name":"MinimumOrderViolation","type":"error"},{"inputs":[],"name":"NotInitializing","type":"error"},{"inputs":[{"internalType":"uint256","name":"proposed","type":"uint256"}],"name":"OrderCollateralAmountOutOfBounds","type":"error"},{"inputs":[{"internalType":"uint8","name":"status","type":"uint8"}],"name":"OrderFillInvalidStatus","type":"error"},{"inputs":[{"internalType":"uint256","name":"fillId","type":"uint256"}],"name":"OrderFillNotFound","type":"error"},{"inputs":[],"name":"OrderIdMissing","type":"error"},{"inputs":[],"name":"OrderInsufficientAmount","type":"error"},{"inputs":[],"name":"OrderMarketAmountMissing","type":"error"},{"inputs":[],"name":"OrderMarketIdMissing","type":"error"},{"inputs":[],"name":"OrderMarketInvalidStatus","type":"error"},{"inputs":[],"name":"OrderNotFound","type":"error"},{"inputs":[],"name":"OrderPaymentAmountMissing","type":"error"},{"inputs":[],"name":"OrderPaymentTokenMissing","type":"error"},{"inputs":[{"internalType":"uint8","name":"proposed","type":"uint8"}],"name":"OrderSideMalformed","type":"error"},{"inputs":[],"name":"OrderStatusInvalid","type":"error"},{"inputs":[{"internalType":"address","name":"proposed","type":"address"}],"name":"OrderUnsupportedPaymentToken","type":"error"},{"inputs":[],"name":"ReentrancyGuardReentrantCall","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"inputs":[],"name":"UUPSUnauthorizedCallContext","type":"error"},{"inputs":[{"internalType":"bytes32","name":"slot","type":"bytes32"}],"name":"UUPSUnsupportedProxiableUUID","type":"error"},{"inputs":[],"name":"Unauthorized","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint128","name":"orderId","type":"uint128"},{"indexed":true,"internalType":"uint32","name":"marketId","type":"uint32"},{"indexed":false,"internalType":"address","name":"actor","type":"address"}],"name":"CancelOrder","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint128","name":"orderId","type":"uint128"},{"indexed":true,"internalType":"uint32","name":"marketId","type":"uint32"},{"indexed":true,"internalType":"uint256","name":"fillId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"claimedAmount","type":"uint256"},{"indexed":false,"internalType":"address","name":"claimedToken","type":"address"},{"indexed":false,"internalType":"address","name":"actor","type":"address"}],"name":"ClaimOrder","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"ClaimYield","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint32","name":"marketId","type":"uint32"},{"indexed":false,"internalType":"bytes32","name":"name","type":"bytes32"}],"name":"CreateMarket","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint128","name":"orderId","type":"uint128"},{"indexed":true,"internalType":"uint32","name":"marketId","type":"uint32"},{"indexed":false,"internalType":"uint256","name":"marketAmount","type":"uint256"},{"indexed":false,"internalType":"address","name":"paymentToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"paymentAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"collateralAmount","type":"uint256"},{"indexed":false,"internalType":"bool","name":"allowPartial","type":"bool"},{"indexed":false,"internalType":"uint8","name":"side","type":"uint8"},{"indexed":false,"internalType":"address","name":"actor","type":"address"}],"name":"CreateOrder","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint128","name":"orderId","type":"uint128"},{"indexed":true,"internalType":"uint32","name":"marketId","type":"uint32"},{"indexed":true,"internalType":"uint256","name":"fillId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"fillAmount","type":"uint256"},{"indexed":false,"internalType":"address","name":"actor","type":"address"}],"name":"FillOrder","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"version","type":"uint64"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint32","name":"marketId","type":"uint32"}],"name":"LockMarket","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint128","name":"orderId","type":"uint128"},{"indexed":true,"internalType":"uint32","name":"marketId","type":"uint32"},{"indexed":true,"internalType":"uint256","name":"fillId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"recoveredAmount","type":"uint256"},{"indexed":false,"internalType":"address","name":"actor","type":"address"}],"name":"RecoverFunds","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint128","name":"orderId","type":"uint128"},{"indexed":true,"internalType":"uint32","name":"marketId","type":"uint32"},{"indexed":true,"internalType":"uint128","name":"newOrderId","type":"uint128"},{"indexed":false,"internalType":"uint256","name":"marketAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newMarketAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"collateralAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newCollateralAmount","type":"uint256"},{"indexed":false,"internalType":"address","name":"actor","type":"address"}],"name":"RepriceOrder","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint128","name":"orderId","type":"uint128"},{"indexed":true,"internalType":"uint32","name":"marketId","type":"uint32"},{"indexed":true,"internalType":"uint256","name":"fillId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"settledAmount","type":"uint256"},{"indexed":false,"internalType":"address","name":"actor","type":"address"}],"name":"SettleOrder","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint32","name":"marketId","type":"uint32"}],"name":"UnlockMarket","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"address","name":"collateral","type":"address"},{"indexed":false,"internalType":"address","name":"feeWallet","type":"address"},{"indexed":false,"internalType":"uint32","name":"settleDurationSec","type":"uint32"},{"indexed":false,"internalType":"uint16","name":"minCollateralBPS","type":"uint16"},{"indexed":false,"internalType":"uint16","name":"maxCollateralBPS","type":"uint16"},{"indexed":false,"internalType":"uint16","name":"settleFeeBPS","type":"uint16"},{"indexed":false,"internalType":"uint16","name":"cancelFeeBPS","type":"uint16"},{"indexed":false,"internalType":"uint256","name":"minOrderUsdb","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"minOrderWeth","type":"uint256"}],"name":"UpdateConfig","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint32","name":"marketId","type":"uint32"},{"indexed":false,"internalType":"bytes32","name":"name","type":"bytes32"},{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint32","name":"goliveDate","type":"uint32"},{"indexed":false,"internalType":"uint32","name":"expirationDate","type":"uint32"},{"indexed":false,"internalType":"uint256","name":"conversionRate","type":"uint256"}],"name":"UpdateMarket","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"implementation","type":"address"}],"name":"Upgraded","type":"event"},{"inputs":[],"name":"UPGRADE_INTERFACE_VERSION","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint128","name":"orderId","type":"uint128"}],"name":"cancelOrder","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"claimOrder","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"claimYield","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"name","type":"bytes32"}],"name":"createMarket","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"marketId","type":"uint32"},{"internalType":"uint256","name":"marketAmount","type":"uint256"},{"internalType":"address","name":"paymentToken","type":"address"},{"internalType":"uint256","name":"paymentAmount","type":"uint256"},{"internalType":"uint256","name":"collateralAmount","type":"uint256"},{"internalType":"bool","name":"allowPartial","type":"bool"},{"internalType":"uint8","name":"side","type":"uint8"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"createOrder","outputs":[{"internalType":"uint128","name":"orderId","type":"uint128"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint128","name":"orderId","type":"uint128"},{"internalType":"uint256","name":"fillAmount","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"fillOrder","outputs":[{"internalType":"uint256","name":"fillId","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"getClaimableAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getConfig","outputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"collateral","type":"address"},{"internalType":"address","name":"feeWallet","type":"address"},{"internalType":"uint32","name":"settleDurationSec","type":"uint32"},{"internalType":"uint16","name":"minCollateralBPS","type":"uint16"},{"internalType":"uint16","name":"maxCollateralBPS","type":"uint16"},{"internalType":"uint16","name":"settleFeeBPS","type":"uint16"},{"internalType":"uint16","name":"cancelFeeBPS","type":"uint16"},{"internalType":"uint256","name":"minOrderUsdb","type":"uint256"},{"internalType":"uint256","name":"minOrderWeth","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"fillId","type":"uint256"}],"name":"getFill","outputs":[{"components":[{"internalType":"address","name":"taker","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint128","name":"orderId","type":"uint128"},{"internalType":"uint8","name":"status","type":"uint8"}],"internalType":"struct Fill","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"marketId","type":"uint32"}],"name":"getMarket","outputs":[{"components":[{"internalType":"bytes32","name":"name","type":"bytes32"},{"internalType":"address","name":"token","type":"address"},{"internalType":"bool","name":"locked","type":"bool"},{"internalType":"uint32","name":"goliveDate","type":"uint32"},{"internalType":"uint32","name":"expirationDate","type":"uint32"},{"internalType":"uint256","name":"conversionRate","type":"uint256"}],"internalType":"struct Market","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"marketId","type":"uint32"}],"name":"getMarketStatus","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint128","name":"orderId","type":"uint128"}],"name":"getOrder","outputs":[{"components":[{"internalType":"uint8","name":"side","type":"uint8"},{"internalType":"uint8","name":"status","type":"uint8"},{"internalType":"bool","name":"allowPartial","type":"bool"},{"internalType":"uint32","name":"numFills","type":"uint32"},{"internalType":"uint32","name":"marketId","type":"uint32"},{"internalType":"uint256","name":"marketAmount","type":"uint256"},{"internalType":"address","name":"paymentToken","type":"address"},{"internalType":"uint256","name":"paymentAmount","type":"uint256"},{"internalType":"uint256","name":"collateralAmount","type":"uint256"},{"internalType":"uint256","name":"filledAmount","type":"uint256"},{"internalType":"uint256","name":"settledAmount","type":"uint256"},{"internalType":"uint256","name":"claimedAmount","type":"uint256"},{"internalType":"address","name":"maker","type":"address"}],"internalType":"struct Order","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint128","name":"orderId","type":"uint128"}],"name":"getOrderMarketStatus","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getVersion","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"blast","type":"address"},{"internalType":"address","name":"usdb","type":"address"},{"internalType":"address","name":"weth","type":"address"},{"internalType":"address","name":"points","type":"address"},{"internalType":"address","name":"pointsOperator","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"marketId","type":"uint32"}],"name":"lockMarket","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"proxiableUUID","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"recoverOrder","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint128","name":"orderId","type":"uint128"},{"internalType":"uint256","name":"newMarketAmount","type":"uint256"}],"name":"repriceOrder","outputs":[{"internalType":"uint128","name":"newOrderId","type":"uint128"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"settleOrder","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"marketId","type":"uint32"}],"name":"unlockMarket","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"collateral","type":"address"},{"internalType":"address","name":"feeWallet","type":"address"},{"internalType":"uint32","name":"settleDurationSec","type":"uint32"},{"internalType":"uint16","name":"minCollateralBPS","type":"uint16"},{"internalType":"uint16","name":"maxCollateralBPS","type":"uint16"},{"internalType":"uint16","name":"settleFeeBPS","type":"uint16"},{"internalType":"uint16","name":"cancelFeeBPS","type":"uint16"},{"internalType":"uint256","name":"minOrderUsdb","type":"uint256"},{"internalType":"uint256","name":"minOrderWeth","type":"uint256"}],"name":"updateConfig","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"marketId","type":"uint32"},{"internalType":"bytes32","name":"name","type":"bytes32"},{"internalType":"address","name":"token","type":"address"},{"internalType":"uint32","name":"goliveDate","type":"uint32"},{"internalType":"uint256","name":"conversionRate","type":"uint256"}],"name":"updateMarket","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"upgradeToAndCall","outputs":[],"stateMutability":"payable","type":"function"}]Contract Creation Code
60a06040523060805234801561001457600080fd5b506080516151aa61003e600039600081816143290152818161435201526144be01526151aa6000f3fe6080604052600436106101665760003560e01c8063ad3cb1cc116100d1578063c45991391161008a578063e12f3a6111610064578063e12f3a6114610515578063eb600e9814610535578063f06ef37214610555578063f97196621461057557600080fd5b8063c45991391461046d578063d36177e21461048d578063dbc91396146104f557600080fd5b8063ad3cb1cc14610324578063b50e801d14610362578063c253283a14610382578063c29b5e7d146103a2578063c2c79dec146103c2578063c3f909d41461044257600080fd5b806325ae2ae51161012357806325ae2ae5146102645780633a3f8239146102845780634f1ef286146102a457806352d1902d146102b7578063a0c4aa24146102cc578063aa2a47ec146102ec57600080fd5b80630d8e6e2c1461016b578063117d41281461018e5780631459457a146101bb578063152c5a7f146101dd5780632243118a1461020f578063235e22c814610244575b600080fd5b34801561017757600080fd5b5060025b6040519081526020015b60405180910390f35b34801561019a57600080fd5b506101ae6101a9366004614898565b610595565b60405161018591906148b3565b3480156101c757600080fd5b506101db6101d63660046149a3565b6106e2565b005b3480156101e957600080fd5b506101fd6101f8366004614a28565b6109cb565b60405160ff9091168152602001610185565b34801561021b57600080fd5b5061022f61022a366004614a43565b6109f9565b60405163ffffffff9091168152602001610185565b34801561025057600080fd5b506101fd61025f366004614898565b610af1565b34801561027057600080fd5b506101db61027f366004614a6e565b610b42565b34801561029057600080fd5b506101db61029f366004614a43565b610fd0565b6101db6102b2366004614b36565b6118f6565b3480156102c357600080fd5b5061017b611915565b3480156102d857600080fd5b506101db6102e7366004614a28565b611932565b3480156102f857600080fd5b5061030c610307366004614bfa565b611a13565b6040516001600160801b039091168152602001610185565b34801561033057600080fd5b50610355604051806040016040528060058152602001640352e302e360dc1b81525081565b6040516101859190614c74565b34801561036e57600080fd5b506101db61037d366004614a43565b612284565b34801561038e57600080fd5b506101db61039d366004614a28565b612705565b3480156103ae57600080fd5b506101db6103bd366004614c87565b6127ed565b3480156103ce57600080fd5b506103e26103dd366004614a28565b612a15565b6040516101859190815181526020808301516001600160a01b03169082015260408083015115159082015260608083015163ffffffff908116918301919091526080808401519091169082015260a0918201519181019190915260c00190565b34801561044e57600080fd5b50610457612ac7565b6040516101859a99989796959493929190614cde565b34801561047957600080fd5b506101db610488366004614a43565b612bb6565b34801561049957600080fd5b506104ad6104a8366004614a43565b6130d6565b604051610185919081516001600160a01b03168152602080830151908201526040808301516001600160801b03169082015260609182015160ff169181019190915260800190565b34801561050157600080fd5b506101db610510366004614898565b613161565b34801561052157600080fd5b5061017b610530366004614d43565b613482565b34801561054157600080fd5b5061030c610550366004614db7565b6134ed565b34801561056157600080fd5b5061017b610570366004614e69565b613ac5565b34801561058157600080fd5b506101db610590366004614ec3565b613fbd565b604080516101a081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e0810182905261010081018290526101208101829052610140810182905261016081018290526101808101919091526106066140b4565b6001600160801b0390921660009081526001928301602090815260409182902082516101a081018452815460ff80821683526101008083048216958401959095526201000082041615159482019490945263ffffffff6301000000850481166060830152600160381b90940490931660808401529384015460a083015260028401546001600160a01b0390811660c0840152600385015460e08401526004850154918301919091526005840154610120830152600684015461014083015260078401546101608301526008909301549092166101808301525090565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a008054600160401b810460ff16159067ffffffffffffffff166000811580156107285750825b905060008267ffffffffffffffff1660011480156107455750303b155b905081158015610753575080155b156107715760405163f92ee8a960e01b815260040160405180910390fd5b845467ffffffffffffffff19166001178555831561079b57845460ff60401b1916600160401b1785555b6107a36140d8565b896001600160a01b0316634e606c476040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156107de57600080fd5b505af11580156107f2573d6000803e3d6000fd5b5050505060006108006140b4565b60048181018054336001600160a01b03199182161790915560058301805482166001600160a01b038e811691909117909155600684018054909216908e16908117909155604051631a33757d60e01b815292935091631a33757d916108689160029101614f04565b6020604051808303816000875af1158015610887573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108ab9190614f2c565b50604051631a33757d60e01b81526001600160a01b038a1690631a33757d906108d990600290600401614f04565b6020604051808303816000875af11580156108f8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061091c9190614f2c565b506040516336b91f2b60e01b81526001600160a01b0388811660048301528916906336b91f2b90602401600060405180830381600087803b15801561096057600080fd5b505af1158015610974573d6000803e3d6000fd5b505050505083156109bf57845460ff60401b19168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b50505050505050505050565b60006109f36109d86140b4565b63ffffffff84166000908152602091909152604090206140e2565b92915050565b600080610a046140b4565b60048101549091506001600160a01b03163314610a33576040516282b42960e81b815260040160405180910390fd5b82610a51576040516316da084d60e01b815260040160405180910390fd5b600381018054600091908290610a6c9063ffffffff16614f5b565b825463ffffffff8083166101009490940a848102910219909116179092556000818152602085905260409081902087815560018101805460ff60a01b191690559051929350917f2820edc4d29cba9570d3fbae3ab860f4ade3b014afb6f56d0a06c0d14bbdfa6290610ae19088815260200190565b60405180910390a2509392505050565b600080610afc6140b4565b6001600160801b0384166000908152600182016020908152604080832054600160381b900463ffffffff168352908390529020909150610b3b906140e2565b9392505050565b6000610b4c6140b4565b60048101549091506001600160a01b03163314610b985760405162461bcd60e51b815260206004820152600560248201526437bbb732b960d91b60448201526064015b60405180910390fd5b6001600160a01b038b16610bda5760405162461bcd60e51b81526020600482015260096024820152683732bb9037bbb732b960b91b6044820152606401610b8f565b6001600160a01b038a16610c215760405162461bcd60e51b815260206004820152600e60248201526d1b995dc818dbdb1b185d195c985b60921b6044820152606401610b8f565b6001600160a01b038916610c675760405162461bcd60e51b815260206004820152600d60248201526c1b995dc819995955d85b1b195d609a1b6044820152606401610b8f565b620151808863ffffffff161015610cb45760405162461bcd60e51b8152602060048201526011602482015270736574746c654475726174696f6e53656360781b6044820152606401610b8f565b6127108761ffff161115610cfd5760405162461bcd60e51b815260206004820152601060248201526f6d696e436f6c6c61746572616c42505360801b6044820152606401610b8f565b6127108661ffff161115610d465760405162461bcd60e51b815260206004820152601060248201526f6d6178436f6c6c61746572616c42505360801b6044820152606401610b8f565b6127108561ffff161115610d8b5760405162461bcd60e51b815260206004820152600c60248201526b736574746c6546656542505360a01b6044820152606401610b8f565b6127108461ffff161115610dd05760405162461bcd60e51b815260206004820152600c60248201526b63616e63656c46656542505360a01b6044820152606401610b8f565b60008311610e0f5760405162461bcd60e51b815260206004820152600c60248201526b36b4b727b93232b92ab9b23160a11b6044820152606401610b8f565b60008211610e4e5760405162461bcd60e51b815260206004820152600c60248201526b0dad2dc9ee4c8cae4aecae8d60a31b6044820152606401610b8f565b8a8160040160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550898160070160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550888160080160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550878160040160146101000a81548163ffffffff021916908363ffffffff160217905550868160040160186101000a81548161ffff021916908361ffff1602179055508581600401601a6101000a81548161ffff021916908361ffff160217905550848160080160146101000a81548161ffff021916908361ffff160217905550838160080160166101000a81548161ffff021916908361ffff1602179055508281600901819055508181600a01819055507fb89a010aec1e42857c9871309ebd537deea00f8c5ebf62c2132ea37e5107f8d58b8b8b8b8b8b8b8b8b8b604051610fbb9a99989796959493929190614cde565b60405180910390a15050505050505050505050565b610fd86141be565b6000610fe26140b4565b60078101546040516331a9108f60e11b81526004810185905291925033916001600160a01b0390911690636352211e90602401602060405180830381865afa158015611032573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110569190614f7e565b6001600160a01b03161461107c576040516282b42960e81b815260040160405180910390fd5b608082901c6000818152600183016020526040812080549091600160381b90910463ffffffff1690036110c25760405163d36d896560e01b815260040160405180910390fd5b8054610100900460ff16158015906110e457508054610100900460ff16600214155b80156110fa57508054610100900460ff16600314155b1561111857604051630c0d8d9760e11b815260040160405180910390fd5b8054600160381b900463ffffffff1660009081526020849052604081209061113f826140e2565b905060ff8116600114801590611159575060ff8116600214155b1561117757604051630286465760e01b815260040160405180910390fd5b825460ff166114bb576000836007015484600601546111969190614f9b565b905080156112b657808460070160008282546111b29190614fae565b9250508190555060006111ce82866001015487600301546141f6565b905060006111e9828660020154670de0b6b3a76400006141f6565b600889015490915060009061120d908390600160a01b900461ffff166127106141f6565b9050600061121b8284614f9b565b6001880154909150611237906001600160a01b031633836142ba565b60088a01546001880154611258916001600160a01b039182169116846142ba565b87546001880154604080518481526001600160a01b03909216602083015233908201528c91600160381b900463ffffffff16906001600160801b038c16906000805160206151158339815191529060600160405180910390a4505050505b6001846007015485600501546112cc9190614f9b565b1161134357835461ff0019166104001784556007860154604051630852cd8d60e31b8152600481018990526001600160a01b03909116906342966c6890602401600060405180830381600087803b15801561132657600080fd5b505af115801561133a573d6000803e3d6000fd5b505050506114b5565b60011960ff8316016114b557835461ff0019166104001784556006840154600585015460009161137291614f9b565b90508015611453576000611387826002614fc1565b60088901549091506000906113ab908390600160a01b900461ffff166127106141f6565b905060006113b98284614f9b565b60028901549091506113d5906001600160a01b031633836142ba565b60088a015460028901546113f6916001600160a01b039182169116846142ba565b87546002890154604080518481526001600160a01b03909216602083015233908201528c91600160381b900463ffffffff16906001600160801b038c16906000805160206151158339815191529060600160405180910390a45050505b6007870154604051630852cd8d60e31b8152600481018a90526001600160a01b03909116906342966c6890602401600060405180830381600087803b15801561149b57600080fd5b505af11580156114af573d6000803e3d6000fd5b50505050505b506118d7565b6000868152600286016020526040902080546001600160a01b03166114f65760405163f2bad5d960e01b815260048101889052602401610b8f565b6002810154600160801b900460ff161561153457600281015460405163c7dcb64560e01b8152600160801b90910460ff166004820152602401610b8f565b835460021961010090910460ff16016116dc5760028101805460ff60801b1916600160811b17905560018082015460038601549186015461157592906141f6565b8460070160008282546115889190614fae565b9250508190555060006115ac82600101548560020154670de0b6b3a76400006141f6565b60088801549091506000906115d0908390600160a01b900461ffff166127106141f6565b905060006115de8284614f9b565b60018701549091506115fa906001600160a01b031633836142ba565b6008890154600187015461161b916001600160a01b039182169116846142ba565b86546001870154604080518481526001600160a01b03909216602083015233908201528b91600160381b900463ffffffff16906001600160801b038b16906000805160206151158339815191529060600160405180910390a46007890154604051630852cd8d60e31b8152600481018c90526001600160a01b03909116906342966c6890602401600060405180830381600087803b1580156116bc57600080fd5b505af11580156116d0573d6000803e3d6000fd5b505050505050506118ac565b60011960ff8316016118ac5760028101805460ff60801b1916600160811b17905560018082015460038601549186015460009261171992916141f6565b90508085600701600082825461172f9190614fae565b9250508190555060006117538360010154670de0b6b3a764000088600101546141f6565b9050600061176e876004015483670de0b6b3a76400006141f6565b6117789084614fae565b60088a015490915060009061179c908390600160a01b900461ffff166127106141f6565b905060006117aa8284614f9b565b60028a01549091506117c6906001600160a01b031633836142ba565b81156117ed5760088b015460028a01546117ed916001600160a01b039182169116846142ba565b885460028a0154604080518481526001600160a01b03909216602083015233908201528d91600160381b900463ffffffff16906001600160801b038d16906000805160206151158339815191529060600160405180910390a460078b0154604051630852cd8d60e31b8152600481018e90526001600160a01b03909116906342966c6890602401600060405180830381600087803b15801561188e57600080fd5b505af11580156118a2573d6000803e3d6000fd5b5050505050505050505b6001846007015485600501546118c29190614f9b565b116118d557835461ff0019166104001784555b505b50505050506118f3600160008051602061515583398151915255565b50565b6118fe61431e565b611907826143c3565b61191182826143f6565b5050565b600061191f6144b3565b5060008051602061513583398151915290565b600061193c6140b4565b60048101549091506001600160a01b0316331461196b576040516282b42960e81b815260040160405180910390fd5b63ffffffff8216600090815260208290526040902080546119a257604051631c49468b60e01b815260006004820152602401610b8f565b6001810154600160a01b900460ff166119ce5760405163b30ae46960e01b815260040160405180910390fd5b60018101805460ff60a01b1916905560405163ffffffff8416907f33d0c04178450ebd390f012032d5b023aaca03425cd3da3295dd543d297a2c9390600090a2505050565b6000611a1d6141be565b6000611a276140b4565b6001600160801b038516600090815260018201602090815260408083208054600160381b900463ffffffff1684529184905282209293509190611a69826140e2565b60ff1614611a8a57604051630286465760e01b815260040160405180910390fd5b856001600160801b0316600003611ab457604051630f00004760e01b815260040160405180910390fd5b8154600160381b900463ffffffff16600003611ae35760405163d36d896560e01b815260040160405180910390fd5b815460ff16611b9e5760078301546001600160a01b0316636352211e611b0a8860006144fc565b6040518263ffffffff1660e01b8152600401611b2891815260200190565b602060405180830381865afa158015611b45573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b699190614f7e565b6001600160a01b0316336001600160a01b031614611b99576040516282b42960e81b815260040160405180910390fd5b611bca565b60088201546001600160a01b03163314611bca576040516282b42960e81b815260040160405180910390fd5b8154610100900460ff1615611bf257604051630c0d8d9760e11b815260040160405180910390fd5b84600003611c1357604051630d45dd4360e41b815260040160405180910390fd5b60048201546008840154600091611c3791600160b01b900461ffff166127106141f6565b90506000611c528460050154856004015486600301546141f6565b8460040154611c619190614f9b565b9050808210611c8357604051631b02a49960e31b815260040160405180910390fd5b8115611caa5760088501546002850154611caa916001600160a01b039182169116846142ba565b6000611cb68383614f9b565b90506000611ccd82876003015488600401546141f6565b600688015460028801549192506001600160a01b039182169116148015611cf75750866009015482105b15611d25576009870154604051631569884360e11b8152610b8f918491600401918252602082015260400190565b600587015460028701546001600160a01b039081169116148015611d4c575086600a015482105b15611d7a57600a870154604051631569884360e11b8152610b8f918491600401918252602082015260400190565b670de0b6b3a7640000891015611db457604051631569884360e11b8152600481018a9052670de0b6b3a76400006024820152604401610b8f565b6d04ee2d6d415b85acef8100000000891115611dfa57604051634ffde66360e11b8152600481018a90526d04ee2d6d415b85acef81000000006024820152604401610b8f565b600387018054600490611e1d9064010000000090046001600160801b0316614fd8565b91906101000a8154816001600160801b0302191690836001600160801b031602179055975060008760010160008a6001600160801b03166001600160801b0316815260200190815260200160002090508660000160009054906101000a900460ff168160000160006101000a81548160ff021916908360ff1602179055508660000160029054906101000a900460ff168160000160026101000a81548160ff0219169083151502179055508660000160079054906101000a900463ffffffff168160000160076101000a81548163ffffffff021916908363ffffffff1602179055508981600101819055508660020160009054906101000a90046001600160a01b03168160020160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550818160030181905550828160040181905550338160080160006101000a8154816001600160a01b0302191690836001600160a01b031602179055508060000160079054906101000a900463ffffffff1663ffffffff16896001600160801b03167faa8ac08a06c239d1f903d0d62c57a818e0d6891c0babe035ab40be406f6426dc83600101548460020160009054906101000a90046001600160a01b0316856003015486600401548760000160029054906101000a900460ff168860000160009054906101000a900460ff16336040516120289796959493929190614ff4565b60405180910390a3805460ff166120bc5760078801546001600160a01b03166394d008ef336120588c60006144fc565b604080516000815260208101918290526001600160e01b031960e086901b1690915261208992919060248101615032565b600060405180830381600087803b1580156120a357600080fd5b505af11580156120b7573d6000803e3d6000fd5b505050505b60058701541561218f57865461ff0019166102001787556001870154600588015460038901546120ed9291906141f6565b600188015560058701546003880155600487015461210c908590614f9b565b6004888101829055885460018a01549184015460408051938452602084018f905283810194909452606083015233608083015291516001600160801b038c81169363ffffffff600160381b9091041692908f16917f2daf94091fcdf2eed1152f1f832186f30cfd783cc735f817f678e01265ccd76a9181900360a00190a4612265565b865460ff166122075760078801546001600160a01b03166342966c686121b68d60006144fc565b6040518263ffffffff1660e01b81526004016121d491815260200190565b600060405180830381600087803b1580156121ee57600080fd5b505af1158015612202573d6000803e3d6000fd5b505050505b865461010061ff001990911617808855604051338152600160381b90910463ffffffff16906001600160801b038d16907f854317c6d782af6ff1704bbcec07ae861c7fa26b6cbe9b9e47022733394690039060200160405180910390a35b50505050505050506109f3600160008051602061515583398151915255565b61228c6141be565b608081901c600061229b6140b4565b6001600160801b03831660009081526001820160205260408120805492935091600160381b900463ffffffff1690036122e75760405163d36d896560e01b815260040160405180910390fd5b8054610100900460ff161580159061230957508054610100900460ff16600214155b1561232757604051630c0d8d9760e11b815260040160405180910390fd5b806005015460000361234c57604051630c0d8d9760e11b815260040160405180910390fd5b8054600160381b900463ffffffff1660009081526020839052604090206001612374826140e2565b60ff161461239557604051630286465760e01b815260040160405180910390fd5b60008581526002840160205260408120835482919060ff166124b05780546001600160a01b03166123dc5760405163f2bad5d960e01b815260048101899052602401610b8f565b80546001600160a01b03163314612405576040516282b42960e81b815260040160405180910390fd5b6002810154600160801b900460ff161561244357600281015460405163c7dcb64560e01b8152600160801b90910460ff166004820152602401610b8f565b61245e81600101548560020154670de0b6b3a76400006141f6565b92506124778160010154866003015487600101546141f6565b60028201805460ff60801b1916600160801b17905560068601805491935083916000906124a5908490614fae565b909155506125219050565b60088501546001600160a01b031633146124dc576040516282b42960e81b815260040160405180910390fd5b60006124f58660050154876001015488600301546141f6565b905061250e818660020154670de0b6b3a76400006141f6565b6005870154600688018190559094509250505b6001856006015486600501546125379190614f9b565b1161254a57845461ff0019166103001785555b6001840154612564906001600160a01b0316333086614516565b845460009060ff161561258d576125888260010154876003015488600101546141f6565b612593565b85600401545b865490915060009060ff16156125ad5786600401546125c4565b6125c48360010154886003015489600101546141f6565b875490915060009060ff1661260f5760006125e883670de0b6b3a7640000866141f6565b90506125fd8482670de0b6b3a76400006141f6565b6126079084614fae565b915050612621565b600588015461261e9083614fae565b90505b6008890154600090612642908390600160a01b900461ffff166127106141f6565b9050612667336126528385614f9b565b60028c01546001600160a01b031691906142ba565b801561268e5760088a015460028a015461268e916001600160a01b039182169116836142ba565b8854604080518881523360208201528e92600160381b900463ffffffff16916001600160801b038f16917fb33e4676d9570305ffbf6c52ca80a1002b6a509bcf76ddc819a89f5c296bd502910160405180910390a450505050505050505050506118f3600160008051602061515583398151915255565b600061270f6140b4565b60048101549091506001600160a01b0316331461273e576040516282b42960e81b815260040160405180910390fd5b63ffffffff82166000908152602082905260409020805461277557604051631c49468b60e01b815260006004820152602401610b8f565b6001810154600160a01b900460ff16156127a2576040516398a5b02160e01b815260040160405180910390fd5b60018101805460ff60a01b1916600160a01b17905560405163ffffffff8416907fa3290d5864e447679f47bc9038aea7145505744d44db1462b1e084bbfd85b25890600090a2505050565b60006127f76140b4565b60048101549091506001600160a01b03163314612826576040516282b42960e81b815260040160405180910390fd5b63ffffffff86166000908152602082905260409020805461286257604051631c49468b60e01b815263ffffffff88166004820152602401610b8f565b60018101546001600160a01b038681169116146128c957826000036128c95760405162461bcd60e51b815260206004820152601760248201527f6d616c666f726d656420636f6e66696775726174696f6e0000000000000000006044820152606401610b8f565b8581556001810180546001600160a01b0319166001600160a01b038716179081905560028201849055600160a81b900463ffffffff9081169085161461299f57428463ffffffff161161293d576040516338f9135b60e01b815263ffffffff85166004820152426024820152604401610b8f565b60018101805463ffffffff808716600160a81b0263ffffffff60a81b1990921691909117909155600483015461297c91600160a01b9091041685615059565b8160010160196101000a81548163ffffffff021916908363ffffffff1602179055505b6001810154604080518881526001600160a01b038816602082015263ffffffff87811682840152600160c81b90930483166060820152608081018690529051918916917fbda709448a0c4f1c82cb97751ccbe39c44a8fea43a2eee090e998da86cd3e79a9181900360a00190a250505050505050565b6040805160c081018252600080825260208201819052918101829052606081018290526080810182905260a0810191909152612a4f6140b4565b63ffffffff92831660009081526020918252604090819020815160c0810183528154815260018201546001600160a01b0381169482019490945260ff600160a01b850416151592810192909252600160a81b830485166060830152600160c81b90920490931660808401526002015460a08301525090565b6000806000806000806000806000806000612ae06140b4565b90508060040160009054906101000a90046001600160a01b03168160070160009054906101000a90046001600160a01b03168260080160009054906101000a90046001600160a01b03168360040160149054906101000a900463ffffffff168460040160189054906101000a900461ffff1685600401601a9054906101000a900461ffff168660080160149054906101000a900461ffff168760080160169054906101000a900461ffff16886009015489600a01549a509a509a509a509a509a509a509a509a509a505090919293949596979899565b6000612bc06140b4565b608083901c6000818152600183016020526040812080549394509192600160381b900463ffffffff169003612c085760405163d36d896560e01b815260040160405180910390fd5b8054600160381b900463ffffffff1660009081526020849052604090206004612c30826140e2565b60ff1614612c5157604051630286465760e01b815260040160405180910390fd5b6000858152600285016020526040808220600787015491516331a9108f60e11b8152600481018990529092916001600160a01b031690636352211e90602401602060405180830381865afa925050508015612cc9575060408051601f3d908101601f19168201909252612cc691810190614f7e565b60015b612d03573d808015612cf7576040519150601f19603f3d011682016040523d82523d6000602084013e612cfc565b606091505b5050612d11565b6001600160a01b0316331490505b8015612f7e57835460ff16612e4b578354610100900460ff1615801590612d4257508354610100900460ff16600214155b15612d6057604051630c0d8d9760e11b815260040160405180910390fd5b835461ff0019166105001784556007860154604051630852cd8d60e31b8152600481018990526001600160a01b03909116906342966c6890602401600060405180830381600087803b158015612db557600080fd5b505af1158015612dc9573d6000803e3d6000fd5b50505060048501546002860154612dec92506001600160a01b03169033906142ba565b83546004850154604080519182523360208301528992600160381b900463ffffffff16916001600160801b038916917f49c11b53b8d71d8eef91d52b6cf910b6d36675f48e26bd393cd043f060a8ea68910160405180910390a46130cd565b6002820154600160801b900460ff1615612e78576040516378cd1d6d60e01b815260040160405180910390fd5b60028201805460ff60801b1916600360801b179055600180830154600386015491860154600092612ea992916141f6565b6007880154604051630852cd8d60e31b8152600481018b90529192506001600160a01b0316906342966c6890602401600060405180830381600087803b158015612ef257600080fd5b505af1158015612f06573d6000803e3d6000fd5b5050506002860154612f2391506001600160a01b031633836142ba565b8454604080518381523360208201528a92600160381b900463ffffffff16916001600160801b038a16917f49c11b53b8d71d8eef91d52b6cf910b6d36675f48e26bd393cd043f060a8ea68910160405180910390a4506130cd565b835460ff166001148015612f9e575060088401546001600160a01b031633145b80612fbf5750835460ff16158015612fbf575081546001600160a01b031633145b156130b557835460ff16613047576002820154600160801b900460ff1615612ffa576040516378cd1d6d60e01b815260040160405180910390fd5b60028201805460ff60801b1916600360801b17905560018083015460038601549186015460009261302b92916141f6565b6002860154909150612f23906001600160a01b031633836142ba565b8354610100900460ff161580159061306957508354610100900460ff16600214155b1561308757604051630c0d8d9760e11b815260040160405180910390fd5b835461ff00191661050017845560048401546002850154612dec916001600160a01b039091169033906142ba565b6040516282b42960e81b815260040160405180910390fd5b50505050505050565b6040805160808101825260008082526020820181905291810182905260608101919091526131026140b4565b600092835260029081016020908152604093849020845160808101865281546001600160a01b03168152600182015492810192909252909101546001600160801b03811693820193909352600160801b90920460ff1660608301525090565b6131696141be565b60006131736140b4565b6001600160801b03831660009081526001820160205260408120805492935091600160381b900463ffffffff1690036131bf5760405163d36d896560e01b815260040160405180910390fd5b8054610100900460ff16156131e757604051630c0d8d9760e11b815260040160405180910390fd5b60058101541561320a57604051630c0d8d9760e11b815260040160405180910390fd5b805460ff166133265760006132208460006144fc565b60078401546040516331a9108f60e11b8152600481018390529192506001600160a01b031690636352211e90602401602060405180830381865afa15801561326c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906132909190614f7e565b6001600160a01b0316336001600160a01b0316146132c0576040516282b42960e81b815260040160405180910390fd5b6007830154604051630852cd8d60e31b8152600481018390526001600160a01b03909116906342966c6890602401600060405180830381600087803b15801561330857600080fd5b505af115801561331c573d6000803e3d6000fd5b5050505050613352565b60088101546001600160a01b03163314613352576040516282b42960e81b815260040160405180910390fd5b805461ff0019166101001780825560009060049061337d9063ffffffff600160381b909104166109cb565b60ff161461339a576008830154600160b01b900461ffff1661339d565b60005b61ffff16905060006133c083600401548363ffffffff1661271061ffff166141f6565b905060008184600401546133d49190614f9b565b60028501549091506133f0906001600160a01b031633836142ba565b81156134175760088501546002850154613417916001600160a01b039182169116846142ba565b8354604051338152600160381b90910463ffffffff16906001600160801b038816907f854317c6d782af6ff1704bbcec07ae861c7fa26b6cbe9b9e47022733394690039060200160405180910390a350505050506118f3600160008051602061515583398151915255565b60405163e12f3a6160e01b81523060048201526000906001600160a01b0383169063e12f3a6190602401602060405180830381865afa1580156134c9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109f39190614f2c565b60006134f76141be565b60ff84161580159061350d57508360ff16600114155b156135305760405163070d5ee760e31b815260ff85166004820152602401610b8f565b8963ffffffff16600003613557576040516359f4f17160e01b815260040160405180910390fd5b8860000361357857604051630d45dd4360e41b815260040160405180910390fd5b6001600160a01b03881661359f576040516330b3bbd960e11b815260040160405180910390fd5b866000036135c057604051630d895b6760e41b815260040160405180910390fd5b60006135ca6140b4565b60068101549091506001600160a01b038a811691161480156135ef5750806009015488105b1561361d576009810154604051631569884360e11b8152610b8f918a91600401918252602082015260400190565b60058101546001600160a01b038a8116911614801561363f575080600a015488105b1561366d57600a810154604051631569884360e11b8152610b8f918a91600401918252602082015260400190565b6d04ee2d6d415b85acef81000000008811156136b357604051634ffde66360e11b8152600481018990526d04ee2d6d415b85acef81000000006024820152604401610b8f565b670de0b6b3a76400008a10156136ed57604051631569884360e11b8152600481018b9052670de0b6b3a76400006024820152604401610b8f565b6d04ee2d6d415b85acef81000000008a111561373357604051634ffde66360e11b8152600481018b90526d04ee2d6d415b85acef81000000006024820152604401610b8f565b60068101546001600160a01b038a8116911614801590613763575060058101546001600160a01b038a8116911614155b1561378c576040516308f72c0560e11b81526001600160a01b038a166004820152602401610b8f565b60ff85166137bc578787146137b75760405163a18f530360e01b815260048101889052602401610b8f565b613835565b60048101546000906137dc90600160c01b900461ffff168a6127106141f6565b60048301549091506000906137ff90600160d01b900461ffff168b6127106141f6565b90508189141580156138115750808914155b156138325760405163a18f530360e01b8152600481018a9052602401610b8f565b50505b63ffffffff8b166000908152602082905260408120613853906140e2565b60ff161461387457604051630286465760e01b815260040160405180910390fd5b6003810180546004906138979064010000000090046001600160801b0316614fd8565b91906101000a8154816001600160801b0302191690836001600160801b03160217905591506138dc3330898c6001600160a01b0316614516909392919063ffffffff16565b6000816001016000846001600160801b03166001600160801b031681526020019081526020016000209050858160000160006101000a81548160ff021916908360ff160217905550868160000160026101000a81548160ff0219169083151502179055508b8160000160076101000a81548163ffffffff021916908363ffffffff1602179055508a8160010181905550898160020160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550888160030181905550878160040181905550338160080160006101000a8154816001600160a01b0302191690836001600160a01b031602179055508b63ffffffff16836001600160801b03167faa8ac08a06c239d1f903d0d62c57a818e0d6891c0babe035ab40be406f6426dc8d8d8d8d8d8d33604051613a1c9796959493929190614ff4565b60405180910390a360ff8616613a9f5760078201546001600160a01b03166394d008ef33613a4b8660006144fc565b88886040518563ffffffff1660e01b8152600401613a6c949392919061507d565b600060405180830381600087803b158015613a8657600080fd5b505af1158015613a9a573d6000803e3d6000fd5b505050505b5050613ab8600160008051602061515583398151915255565b9998505050505050505050565b6000613acf6141be565b846001600160801b0316600003613af957604051630f00004760e01b815260040160405180910390fd5b6000613b036140b4565b6001600160801b03871660009081526001820160205260408120805492935091600160381b900463ffffffff169003613b4f5760405163d36d896560e01b815260040160405180910390fd5b8054610100900460ff1615613b7757604051630c0d8d9760e11b815260040160405180910390fd5b6008810154336001600160a01b0390911603613ba5576040516282b42960e81b815260040160405180910390fd5b670de0b6b3a7640000861015613bdf57604051631569884360e11b815260048101879052670de0b6b3a76400006024820152604401610b8f565b8060010154861115613c14576001810154604051631569884360e11b8152610b8f918891600401918252602082015260400190565b600081600101548703613c2c57506003810154613c42565b613c3f87836003015484600101546141f6565b90505b600683015460028301546001600160a01b039081169116148015613c695750826009015481105b15613c97576009830154604051631569884360e11b8152610b8f918391600401918252602082015260400190565b600583015460028301546001600160a01b039081169116148015613cbe575082600a015481105b15613cec57600a830154604051631569884360e11b8152610b8f918391600401918252602082015260400190565b815462010000900460ff1615613d355781600501548260030154613d109190614f9b565b811115613d3057604051631b02a49960e31b815260040160405180910390fd5b613d7c565b600582015415613d5857604051630c0d8d9760e11b815260040160405180910390fd5b81600301548114613d7c57604051631b02a49960e31b815260040160405180910390fd5b8154600160381b900463ffffffff166000908152602084905260408120613da2906140e2565b60ff1614613dc357604051630286465760e01b815260040160405180910390fd5b80826005016000828254613dd79190614fae565b909155505060058201546003830154600191613df291614f9b565b1115613dff576000613e02565b60025b825460ff919091166101000261ff00199091161782556002820154613e32906001600160a01b0316333084614516565b8154613e779089908490600390613e55906301000000900463ffffffff16614f5b565b91906101000a81548163ffffffff021916908363ffffffff16021790556144fc565b6000818152600280860160205260409182902080546001600160a01b031916339081178255600182018c905591810180546001600160801b038e166001600160801b03199091168117909155865493519498509093889363ffffffff600160381b90910416927fb8d1b8d2b35a9ca0afb36cd59b0a2447409cd536763cc0c8d4d79103c303a24791613f1a918e82526001600160a01b0316602082015260400190565b60405180910390a4825460ff1660001901613f9a5760078401546040516394d008ef60e01b81526001600160a01b03909116906394d008ef90613f6790339089908c908c9060040161507d565b600060405180830381600087803b158015613f8157600080fd5b505af1158015613f95573d6000803e3d6000fd5b505050505b50505050613fb5600160008051602061515583398151915255565b949350505050565b33613fc66140b4565b600401546001600160a01b031614613ff0576040516282b42960e81b815260040160405180910390fd5b604051635569f64b60e11b81526001600160a01b0383811660048301526024820183905284169063aad3ec96906044016020604051808303816000875af115801561403f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906140639190614f2c565b50604080516001600160a01b038086168252841660208201529081018290527f497d80235eb5f8a92716d1e222145fe1ca6c1a328bec04ae59e6bef77da1aace9060600160405180910390a1505050565b7f80a98cd2d492b7b86287ff2105d133cc8f51a35b91a585bb6e4d3400a1adab0090565b6140e0614555565b565b805460009061410757604051631c49468b60e01b815260006004820152602401610b8f565b600182810154600160a01b900460ff161515900361412757506003919050565b6001820154600160a81b900463ffffffff1615806141565750600182015442600160a81b90910463ffffffff16115b1561416357506000919050565b60018201546001600160a01b0316158015906141825750600282015415155b156141b157600182015442600160c81b90910463ffffffff1611156141a957506001919050565b506002919050565b506004919050565b919050565b6000805160206151558339815191528054600119016141f057604051633ee5aeb560e01b815260040160405180910390fd5b60029055565b600083830281600019858709828110838203039150508060000361422d57838281614223576142236150c5565b0492505050610b3b565b80841161424d5760405163227bc15360e01b815260040160405180910390fd5b6000848688096000868103871696879004966002600389028118808a02820302808a02820302808a02820302808a02820302808a02820302808a02909103029181900381900460010186841190950394909402919094039290920491909117919091029150509392505050565b6040516001600160a01b0383811660248301526044820183905261431991859182169063a9059cbb906064015b604051602081830303815290604052915060e01b6020820180516001600160e01b03838183161783525050505061459e565b505050565b306001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614806143a557507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316614399600080516020615135833981519152546001600160a01b031690565b6001600160a01b031614155b156140e05760405163703e46dd60e11b815260040160405180910390fd5b336143cc6140b4565b600401546001600160a01b0316146118f3576040516282b42960e81b815260040160405180910390fd5b816001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa925050508015614450575060408051601f3d908101601f1916820190925261444d91810190614f2c565b60015b61447857604051634c9c8ce360e01b81526001600160a01b0383166004820152602401610b8f565b60008051602061513583398151915281146144a957604051632a87526960e21b815260048101829052602401610b8f565b6143198383614601565b306001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146140e05760405163703e46dd60e11b815260040160405180910390fd5b63ffffffff1660809190911b6001600160801b0319161790565b6040516001600160a01b03848116602483015283811660448301526064820183905261454f9186918216906323b872dd906084016142e7565b50505050565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0054600160401b900460ff166140e057604051631afcd79f60e31b815260040160405180910390fd5b60006145b36001600160a01b03841683614657565b905080516000141580156145d85750808060200190518101906145d691906150db565b155b1561431957604051635274afe760e01b81526001600160a01b0384166004820152602401610b8f565b61460a82614665565b6040516001600160a01b038316907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a280511561464f5761431982826146ca565b611911614740565b6060610b3b8383600061475f565b806001600160a01b03163b60000361469b57604051634c9c8ce360e01b81526001600160a01b0382166004820152602401610b8f565b60008051602061513583398151915280546001600160a01b0319166001600160a01b0392909216919091179055565b6060600080846001600160a01b0316846040516146e791906150f8565b600060405180830381855af49150503d8060008114614722576040519150601f19603f3d011682016040523d82523d6000602084013e614727565b606091505b50915091506147378583836147fc565b95945050505050565b34156140e05760405163b398979f60e01b815260040160405180910390fd5b6060814710156147845760405163cd78605960e01b8152306004820152602401610b8f565b600080856001600160a01b031684866040516147a091906150f8565b60006040518083038185875af1925050503d80600081146147dd576040519150601f19603f3d011682016040523d82523d6000602084013e6147e2565b606091505b50915091506147f28683836147fc565b9695505050505050565b6060826148115761480c82614858565b610b3b565b815115801561482857506001600160a01b0384163b155b1561485157604051639996b31560e01b81526001600160a01b0385166004820152602401610b8f565b5080610b3b565b8051156148685780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b80356001600160801b03811681146141b957600080fd5b6000602082840312156148aa57600080fd5b610b3b82614881565b815160ff1681526101a0810160208301516148d3602084018260ff169052565b5060408301516148e7604084018215159052565b5060608301516148ff606084018263ffffffff169052565b506080830151614917608084018263ffffffff169052565b5060a083015160a083015260c083015161493c60c08401826001600160a01b03169052565b5060e083810151908301526101008084015190830152610120808401519083015261014080840151908301526101608084015190830152610180928301516001600160a01b0316929091019190915290565b6001600160a01b03811681146118f357600080fd5b600080600080600060a086880312156149bb57600080fd5b85356149c68161498e565b945060208601356149d68161498e565b935060408601356149e68161498e565b925060608601356149f68161498e565b91506080860135614a068161498e565b809150509295509295909350565b803563ffffffff811681146141b957600080fd5b600060208284031215614a3a57600080fd5b610b3b82614a14565b600060208284031215614a5557600080fd5b5035919050565b803561ffff811681146141b957600080fd5b6000806000806000806000806000806101408b8d031215614a8e57600080fd5b8a35614a998161498e565b995060208b0135614aa98161498e565b985060408b0135614ab98161498e565b9750614ac760608c01614a14565b9650614ad560808c01614a5c565b9550614ae360a08c01614a5c565b9450614af160c08c01614a5c565b9350614aff60e08c01614a5c565b92506101008b013591506101208b013590509295989b9194979a5092959850565b634e487b7160e01b600052604160045260246000fd5b60008060408385031215614b4957600080fd5b8235614b548161498e565b9150602083013567ffffffffffffffff80821115614b7157600080fd5b818501915085601f830112614b8557600080fd5b813581811115614b9757614b97614b20565b604051601f8201601f19908116603f01168101908382118183101715614bbf57614bbf614b20565b81604052828152886020848701011115614bd857600080fd5b8260208601602083013760006020848301015280955050505050509250929050565b60008060408385031215614c0d57600080fd5b614c1683614881565b946020939093013593505050565b60005b83811015614c3f578181015183820152602001614c27565b50506000910152565b60008151808452614c60816020860160208601614c24565b601f01601f19169290920160200192915050565b602081526000610b3b6020830184614c48565b600080600080600060a08688031215614c9f57600080fd5b614ca886614a14565b9450602086013593506040860135614cbf8161498e565b9250614ccd60608701614a14565b949793965091946080013592915050565b6001600160a01b039a8b168152988a1660208a015296909816604088015263ffffffff94909416606087015261ffff928316608087015290821660a0860152811660c08501521660e08301526101008201929092526101208101919091526101400190565b600060208284031215614d5557600080fd5b8135610b3b8161498e565b80151581146118f357600080fd5b60008083601f840112614d8057600080fd5b50813567ffffffffffffffff811115614d9857600080fd5b602083019150836020828501011115614db057600080fd5b9250929050565b60008060008060008060008060006101008a8c031215614dd657600080fd5b614ddf8a614a14565b985060208a0135975060408a0135614df68161498e565b965060608a0135955060808a0135945060a08a0135614e1481614d60565b935060c08a013560ff81168114614e2a57600080fd5b925060e08a013567ffffffffffffffff811115614e4657600080fd5b614e528c828d01614d6e565b915080935050809150509295985092959850929598565b60008060008060608587031215614e7f57600080fd5b614e8885614881565b935060208501359250604085013567ffffffffffffffff811115614eab57600080fd5b614eb787828801614d6e565b95989497509550505050565b600080600060608486031215614ed857600080fd5b8335614ee38161498e565b92506020840135614ef38161498e565b929592945050506040919091013590565b6020810160038310614f2657634e487b7160e01b600052602160045260246000fd5b91905290565b600060208284031215614f3e57600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b600063ffffffff808316818103614f7457614f74614f45565b6001019392505050565b600060208284031215614f9057600080fd5b8151610b3b8161498e565b818103818111156109f3576109f3614f45565b808201808211156109f3576109f3614f45565b80820281158282048414176109f3576109f3614f45565b60006001600160801b03808316818103614f7457614f74614f45565b9687526001600160a01b039586166020880152604087019490945260608601929092521515608085015260ff1660a08401521660c082015260e00190565b60018060a01b03841681528260208201526060604082015260006147376060830184614c48565b63ffffffff81811683821601908082111561507657615076614f45565b5092915050565b6001600160a01b0385168152602081018490526060604082018190528101829052818360808301376000818301608090810191909152601f909201601f191601019392505050565b634e487b7160e01b600052601260045260246000fd5b6000602082840312156150ed57600080fd5b8151610b3b81614d60565b6000825161510a818460208701614c24565b919091019291505056fe27abe55cf1d4ce00255947a030f9e2add0bb74bdd5dc4d64a67c254aeb7cadb2360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00a26469706673582212206b1026867d76531ec520260db69789d1b1ef94e797cdc0dfd94792e1ce88aeee64736f6c63430008140033
Deployed Bytecode
0x6080604052600436106101665760003560e01c8063ad3cb1cc116100d1578063c45991391161008a578063e12f3a6111610064578063e12f3a6114610515578063eb600e9814610535578063f06ef37214610555578063f97196621461057557600080fd5b8063c45991391461046d578063d36177e21461048d578063dbc91396146104f557600080fd5b8063ad3cb1cc14610324578063b50e801d14610362578063c253283a14610382578063c29b5e7d146103a2578063c2c79dec146103c2578063c3f909d41461044257600080fd5b806325ae2ae51161012357806325ae2ae5146102645780633a3f8239146102845780634f1ef286146102a457806352d1902d146102b7578063a0c4aa24146102cc578063aa2a47ec146102ec57600080fd5b80630d8e6e2c1461016b578063117d41281461018e5780631459457a146101bb578063152c5a7f146101dd5780632243118a1461020f578063235e22c814610244575b600080fd5b34801561017757600080fd5b5060025b6040519081526020015b60405180910390f35b34801561019a57600080fd5b506101ae6101a9366004614898565b610595565b60405161018591906148b3565b3480156101c757600080fd5b506101db6101d63660046149a3565b6106e2565b005b3480156101e957600080fd5b506101fd6101f8366004614a28565b6109cb565b60405160ff9091168152602001610185565b34801561021b57600080fd5b5061022f61022a366004614a43565b6109f9565b60405163ffffffff9091168152602001610185565b34801561025057600080fd5b506101fd61025f366004614898565b610af1565b34801561027057600080fd5b506101db61027f366004614a6e565b610b42565b34801561029057600080fd5b506101db61029f366004614a43565b610fd0565b6101db6102b2366004614b36565b6118f6565b3480156102c357600080fd5b5061017b611915565b3480156102d857600080fd5b506101db6102e7366004614a28565b611932565b3480156102f857600080fd5b5061030c610307366004614bfa565b611a13565b6040516001600160801b039091168152602001610185565b34801561033057600080fd5b50610355604051806040016040528060058152602001640352e302e360dc1b81525081565b6040516101859190614c74565b34801561036e57600080fd5b506101db61037d366004614a43565b612284565b34801561038e57600080fd5b506101db61039d366004614a28565b612705565b3480156103ae57600080fd5b506101db6103bd366004614c87565b6127ed565b3480156103ce57600080fd5b506103e26103dd366004614a28565b612a15565b6040516101859190815181526020808301516001600160a01b03169082015260408083015115159082015260608083015163ffffffff908116918301919091526080808401519091169082015260a0918201519181019190915260c00190565b34801561044e57600080fd5b50610457612ac7565b6040516101859a99989796959493929190614cde565b34801561047957600080fd5b506101db610488366004614a43565b612bb6565b34801561049957600080fd5b506104ad6104a8366004614a43565b6130d6565b604051610185919081516001600160a01b03168152602080830151908201526040808301516001600160801b03169082015260609182015160ff169181019190915260800190565b34801561050157600080fd5b506101db610510366004614898565b613161565b34801561052157600080fd5b5061017b610530366004614d43565b613482565b34801561054157600080fd5b5061030c610550366004614db7565b6134ed565b34801561056157600080fd5b5061017b610570366004614e69565b613ac5565b34801561058157600080fd5b506101db610590366004614ec3565b613fbd565b604080516101a081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e0810182905261010081018290526101208101829052610140810182905261016081018290526101808101919091526106066140b4565b6001600160801b0390921660009081526001928301602090815260409182902082516101a081018452815460ff80821683526101008083048216958401959095526201000082041615159482019490945263ffffffff6301000000850481166060830152600160381b90940490931660808401529384015460a083015260028401546001600160a01b0390811660c0840152600385015460e08401526004850154918301919091526005840154610120830152600684015461014083015260078401546101608301526008909301549092166101808301525090565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a008054600160401b810460ff16159067ffffffffffffffff166000811580156107285750825b905060008267ffffffffffffffff1660011480156107455750303b155b905081158015610753575080155b156107715760405163f92ee8a960e01b815260040160405180910390fd5b845467ffffffffffffffff19166001178555831561079b57845460ff60401b1916600160401b1785555b6107a36140d8565b896001600160a01b0316634e606c476040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156107de57600080fd5b505af11580156107f2573d6000803e3d6000fd5b5050505060006108006140b4565b60048181018054336001600160a01b03199182161790915560058301805482166001600160a01b038e811691909117909155600684018054909216908e16908117909155604051631a33757d60e01b815292935091631a33757d916108689160029101614f04565b6020604051808303816000875af1158015610887573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108ab9190614f2c565b50604051631a33757d60e01b81526001600160a01b038a1690631a33757d906108d990600290600401614f04565b6020604051808303816000875af11580156108f8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061091c9190614f2c565b506040516336b91f2b60e01b81526001600160a01b0388811660048301528916906336b91f2b90602401600060405180830381600087803b15801561096057600080fd5b505af1158015610974573d6000803e3d6000fd5b505050505083156109bf57845460ff60401b19168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b50505050505050505050565b60006109f36109d86140b4565b63ffffffff84166000908152602091909152604090206140e2565b92915050565b600080610a046140b4565b60048101549091506001600160a01b03163314610a33576040516282b42960e81b815260040160405180910390fd5b82610a51576040516316da084d60e01b815260040160405180910390fd5b600381018054600091908290610a6c9063ffffffff16614f5b565b825463ffffffff8083166101009490940a848102910219909116179092556000818152602085905260409081902087815560018101805460ff60a01b191690559051929350917f2820edc4d29cba9570d3fbae3ab860f4ade3b014afb6f56d0a06c0d14bbdfa6290610ae19088815260200190565b60405180910390a2509392505050565b600080610afc6140b4565b6001600160801b0384166000908152600182016020908152604080832054600160381b900463ffffffff168352908390529020909150610b3b906140e2565b9392505050565b6000610b4c6140b4565b60048101549091506001600160a01b03163314610b985760405162461bcd60e51b815260206004820152600560248201526437bbb732b960d91b60448201526064015b60405180910390fd5b6001600160a01b038b16610bda5760405162461bcd60e51b81526020600482015260096024820152683732bb9037bbb732b960b91b6044820152606401610b8f565b6001600160a01b038a16610c215760405162461bcd60e51b815260206004820152600e60248201526d1b995dc818dbdb1b185d195c985b60921b6044820152606401610b8f565b6001600160a01b038916610c675760405162461bcd60e51b815260206004820152600d60248201526c1b995dc819995955d85b1b195d609a1b6044820152606401610b8f565b620151808863ffffffff161015610cb45760405162461bcd60e51b8152602060048201526011602482015270736574746c654475726174696f6e53656360781b6044820152606401610b8f565b6127108761ffff161115610cfd5760405162461bcd60e51b815260206004820152601060248201526f6d696e436f6c6c61746572616c42505360801b6044820152606401610b8f565b6127108661ffff161115610d465760405162461bcd60e51b815260206004820152601060248201526f6d6178436f6c6c61746572616c42505360801b6044820152606401610b8f565b6127108561ffff161115610d8b5760405162461bcd60e51b815260206004820152600c60248201526b736574746c6546656542505360a01b6044820152606401610b8f565b6127108461ffff161115610dd05760405162461bcd60e51b815260206004820152600c60248201526b63616e63656c46656542505360a01b6044820152606401610b8f565b60008311610e0f5760405162461bcd60e51b815260206004820152600c60248201526b36b4b727b93232b92ab9b23160a11b6044820152606401610b8f565b60008211610e4e5760405162461bcd60e51b815260206004820152600c60248201526b0dad2dc9ee4c8cae4aecae8d60a31b6044820152606401610b8f565b8a8160040160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550898160070160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550888160080160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550878160040160146101000a81548163ffffffff021916908363ffffffff160217905550868160040160186101000a81548161ffff021916908361ffff1602179055508581600401601a6101000a81548161ffff021916908361ffff160217905550848160080160146101000a81548161ffff021916908361ffff160217905550838160080160166101000a81548161ffff021916908361ffff1602179055508281600901819055508181600a01819055507fb89a010aec1e42857c9871309ebd537deea00f8c5ebf62c2132ea37e5107f8d58b8b8b8b8b8b8b8b8b8b604051610fbb9a99989796959493929190614cde565b60405180910390a15050505050505050505050565b610fd86141be565b6000610fe26140b4565b60078101546040516331a9108f60e11b81526004810185905291925033916001600160a01b0390911690636352211e90602401602060405180830381865afa158015611032573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110569190614f7e565b6001600160a01b03161461107c576040516282b42960e81b815260040160405180910390fd5b608082901c6000818152600183016020526040812080549091600160381b90910463ffffffff1690036110c25760405163d36d896560e01b815260040160405180910390fd5b8054610100900460ff16158015906110e457508054610100900460ff16600214155b80156110fa57508054610100900460ff16600314155b1561111857604051630c0d8d9760e11b815260040160405180910390fd5b8054600160381b900463ffffffff1660009081526020849052604081209061113f826140e2565b905060ff8116600114801590611159575060ff8116600214155b1561117757604051630286465760e01b815260040160405180910390fd5b825460ff166114bb576000836007015484600601546111969190614f9b565b905080156112b657808460070160008282546111b29190614fae565b9250508190555060006111ce82866001015487600301546141f6565b905060006111e9828660020154670de0b6b3a76400006141f6565b600889015490915060009061120d908390600160a01b900461ffff166127106141f6565b9050600061121b8284614f9b565b6001880154909150611237906001600160a01b031633836142ba565b60088a01546001880154611258916001600160a01b039182169116846142ba565b87546001880154604080518481526001600160a01b03909216602083015233908201528c91600160381b900463ffffffff16906001600160801b038c16906000805160206151158339815191529060600160405180910390a4505050505b6001846007015485600501546112cc9190614f9b565b1161134357835461ff0019166104001784556007860154604051630852cd8d60e31b8152600481018990526001600160a01b03909116906342966c6890602401600060405180830381600087803b15801561132657600080fd5b505af115801561133a573d6000803e3d6000fd5b505050506114b5565b60011960ff8316016114b557835461ff0019166104001784556006840154600585015460009161137291614f9b565b90508015611453576000611387826002614fc1565b60088901549091506000906113ab908390600160a01b900461ffff166127106141f6565b905060006113b98284614f9b565b60028901549091506113d5906001600160a01b031633836142ba565b60088a015460028901546113f6916001600160a01b039182169116846142ba565b87546002890154604080518481526001600160a01b03909216602083015233908201528c91600160381b900463ffffffff16906001600160801b038c16906000805160206151158339815191529060600160405180910390a45050505b6007870154604051630852cd8d60e31b8152600481018a90526001600160a01b03909116906342966c6890602401600060405180830381600087803b15801561149b57600080fd5b505af11580156114af573d6000803e3d6000fd5b50505050505b506118d7565b6000868152600286016020526040902080546001600160a01b03166114f65760405163f2bad5d960e01b815260048101889052602401610b8f565b6002810154600160801b900460ff161561153457600281015460405163c7dcb64560e01b8152600160801b90910460ff166004820152602401610b8f565b835460021961010090910460ff16016116dc5760028101805460ff60801b1916600160811b17905560018082015460038601549186015461157592906141f6565b8460070160008282546115889190614fae565b9250508190555060006115ac82600101548560020154670de0b6b3a76400006141f6565b60088801549091506000906115d0908390600160a01b900461ffff166127106141f6565b905060006115de8284614f9b565b60018701549091506115fa906001600160a01b031633836142ba565b6008890154600187015461161b916001600160a01b039182169116846142ba565b86546001870154604080518481526001600160a01b03909216602083015233908201528b91600160381b900463ffffffff16906001600160801b038b16906000805160206151158339815191529060600160405180910390a46007890154604051630852cd8d60e31b8152600481018c90526001600160a01b03909116906342966c6890602401600060405180830381600087803b1580156116bc57600080fd5b505af11580156116d0573d6000803e3d6000fd5b505050505050506118ac565b60011960ff8316016118ac5760028101805460ff60801b1916600160811b17905560018082015460038601549186015460009261171992916141f6565b90508085600701600082825461172f9190614fae565b9250508190555060006117538360010154670de0b6b3a764000088600101546141f6565b9050600061176e876004015483670de0b6b3a76400006141f6565b6117789084614fae565b60088a015490915060009061179c908390600160a01b900461ffff166127106141f6565b905060006117aa8284614f9b565b60028a01549091506117c6906001600160a01b031633836142ba565b81156117ed5760088b015460028a01546117ed916001600160a01b039182169116846142ba565b885460028a0154604080518481526001600160a01b03909216602083015233908201528d91600160381b900463ffffffff16906001600160801b038d16906000805160206151158339815191529060600160405180910390a460078b0154604051630852cd8d60e31b8152600481018e90526001600160a01b03909116906342966c6890602401600060405180830381600087803b15801561188e57600080fd5b505af11580156118a2573d6000803e3d6000fd5b5050505050505050505b6001846007015485600501546118c29190614f9b565b116118d557835461ff0019166104001784555b505b50505050506118f3600160008051602061515583398151915255565b50565b6118fe61431e565b611907826143c3565b61191182826143f6565b5050565b600061191f6144b3565b5060008051602061513583398151915290565b600061193c6140b4565b60048101549091506001600160a01b0316331461196b576040516282b42960e81b815260040160405180910390fd5b63ffffffff8216600090815260208290526040902080546119a257604051631c49468b60e01b815260006004820152602401610b8f565b6001810154600160a01b900460ff166119ce5760405163b30ae46960e01b815260040160405180910390fd5b60018101805460ff60a01b1916905560405163ffffffff8416907f33d0c04178450ebd390f012032d5b023aaca03425cd3da3295dd543d297a2c9390600090a2505050565b6000611a1d6141be565b6000611a276140b4565b6001600160801b038516600090815260018201602090815260408083208054600160381b900463ffffffff1684529184905282209293509190611a69826140e2565b60ff1614611a8a57604051630286465760e01b815260040160405180910390fd5b856001600160801b0316600003611ab457604051630f00004760e01b815260040160405180910390fd5b8154600160381b900463ffffffff16600003611ae35760405163d36d896560e01b815260040160405180910390fd5b815460ff16611b9e5760078301546001600160a01b0316636352211e611b0a8860006144fc565b6040518263ffffffff1660e01b8152600401611b2891815260200190565b602060405180830381865afa158015611b45573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b699190614f7e565b6001600160a01b0316336001600160a01b031614611b99576040516282b42960e81b815260040160405180910390fd5b611bca565b60088201546001600160a01b03163314611bca576040516282b42960e81b815260040160405180910390fd5b8154610100900460ff1615611bf257604051630c0d8d9760e11b815260040160405180910390fd5b84600003611c1357604051630d45dd4360e41b815260040160405180910390fd5b60048201546008840154600091611c3791600160b01b900461ffff166127106141f6565b90506000611c528460050154856004015486600301546141f6565b8460040154611c619190614f9b565b9050808210611c8357604051631b02a49960e31b815260040160405180910390fd5b8115611caa5760088501546002850154611caa916001600160a01b039182169116846142ba565b6000611cb68383614f9b565b90506000611ccd82876003015488600401546141f6565b600688015460028801549192506001600160a01b039182169116148015611cf75750866009015482105b15611d25576009870154604051631569884360e11b8152610b8f918491600401918252602082015260400190565b600587015460028701546001600160a01b039081169116148015611d4c575086600a015482105b15611d7a57600a870154604051631569884360e11b8152610b8f918491600401918252602082015260400190565b670de0b6b3a7640000891015611db457604051631569884360e11b8152600481018a9052670de0b6b3a76400006024820152604401610b8f565b6d04ee2d6d415b85acef8100000000891115611dfa57604051634ffde66360e11b8152600481018a90526d04ee2d6d415b85acef81000000006024820152604401610b8f565b600387018054600490611e1d9064010000000090046001600160801b0316614fd8565b91906101000a8154816001600160801b0302191690836001600160801b031602179055975060008760010160008a6001600160801b03166001600160801b0316815260200190815260200160002090508660000160009054906101000a900460ff168160000160006101000a81548160ff021916908360ff1602179055508660000160029054906101000a900460ff168160000160026101000a81548160ff0219169083151502179055508660000160079054906101000a900463ffffffff168160000160076101000a81548163ffffffff021916908363ffffffff1602179055508981600101819055508660020160009054906101000a90046001600160a01b03168160020160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550818160030181905550828160040181905550338160080160006101000a8154816001600160a01b0302191690836001600160a01b031602179055508060000160079054906101000a900463ffffffff1663ffffffff16896001600160801b03167faa8ac08a06c239d1f903d0d62c57a818e0d6891c0babe035ab40be406f6426dc83600101548460020160009054906101000a90046001600160a01b0316856003015486600401548760000160029054906101000a900460ff168860000160009054906101000a900460ff16336040516120289796959493929190614ff4565b60405180910390a3805460ff166120bc5760078801546001600160a01b03166394d008ef336120588c60006144fc565b604080516000815260208101918290526001600160e01b031960e086901b1690915261208992919060248101615032565b600060405180830381600087803b1580156120a357600080fd5b505af11580156120b7573d6000803e3d6000fd5b505050505b60058701541561218f57865461ff0019166102001787556001870154600588015460038901546120ed9291906141f6565b600188015560058701546003880155600487015461210c908590614f9b565b6004888101829055885460018a01549184015460408051938452602084018f905283810194909452606083015233608083015291516001600160801b038c81169363ffffffff600160381b9091041692908f16917f2daf94091fcdf2eed1152f1f832186f30cfd783cc735f817f678e01265ccd76a9181900360a00190a4612265565b865460ff166122075760078801546001600160a01b03166342966c686121b68d60006144fc565b6040518263ffffffff1660e01b81526004016121d491815260200190565b600060405180830381600087803b1580156121ee57600080fd5b505af1158015612202573d6000803e3d6000fd5b505050505b865461010061ff001990911617808855604051338152600160381b90910463ffffffff16906001600160801b038d16907f854317c6d782af6ff1704bbcec07ae861c7fa26b6cbe9b9e47022733394690039060200160405180910390a35b50505050505050506109f3600160008051602061515583398151915255565b61228c6141be565b608081901c600061229b6140b4565b6001600160801b03831660009081526001820160205260408120805492935091600160381b900463ffffffff1690036122e75760405163d36d896560e01b815260040160405180910390fd5b8054610100900460ff161580159061230957508054610100900460ff16600214155b1561232757604051630c0d8d9760e11b815260040160405180910390fd5b806005015460000361234c57604051630c0d8d9760e11b815260040160405180910390fd5b8054600160381b900463ffffffff1660009081526020839052604090206001612374826140e2565b60ff161461239557604051630286465760e01b815260040160405180910390fd5b60008581526002840160205260408120835482919060ff166124b05780546001600160a01b03166123dc5760405163f2bad5d960e01b815260048101899052602401610b8f565b80546001600160a01b03163314612405576040516282b42960e81b815260040160405180910390fd5b6002810154600160801b900460ff161561244357600281015460405163c7dcb64560e01b8152600160801b90910460ff166004820152602401610b8f565b61245e81600101548560020154670de0b6b3a76400006141f6565b92506124778160010154866003015487600101546141f6565b60028201805460ff60801b1916600160801b17905560068601805491935083916000906124a5908490614fae565b909155506125219050565b60088501546001600160a01b031633146124dc576040516282b42960e81b815260040160405180910390fd5b60006124f58660050154876001015488600301546141f6565b905061250e818660020154670de0b6b3a76400006141f6565b6005870154600688018190559094509250505b6001856006015486600501546125379190614f9b565b1161254a57845461ff0019166103001785555b6001840154612564906001600160a01b0316333086614516565b845460009060ff161561258d576125888260010154876003015488600101546141f6565b612593565b85600401545b865490915060009060ff16156125ad5786600401546125c4565b6125c48360010154886003015489600101546141f6565b875490915060009060ff1661260f5760006125e883670de0b6b3a7640000866141f6565b90506125fd8482670de0b6b3a76400006141f6565b6126079084614fae565b915050612621565b600588015461261e9083614fae565b90505b6008890154600090612642908390600160a01b900461ffff166127106141f6565b9050612667336126528385614f9b565b60028c01546001600160a01b031691906142ba565b801561268e5760088a015460028a015461268e916001600160a01b039182169116836142ba565b8854604080518881523360208201528e92600160381b900463ffffffff16916001600160801b038f16917fb33e4676d9570305ffbf6c52ca80a1002b6a509bcf76ddc819a89f5c296bd502910160405180910390a450505050505050505050506118f3600160008051602061515583398151915255565b600061270f6140b4565b60048101549091506001600160a01b0316331461273e576040516282b42960e81b815260040160405180910390fd5b63ffffffff82166000908152602082905260409020805461277557604051631c49468b60e01b815260006004820152602401610b8f565b6001810154600160a01b900460ff16156127a2576040516398a5b02160e01b815260040160405180910390fd5b60018101805460ff60a01b1916600160a01b17905560405163ffffffff8416907fa3290d5864e447679f47bc9038aea7145505744d44db1462b1e084bbfd85b25890600090a2505050565b60006127f76140b4565b60048101549091506001600160a01b03163314612826576040516282b42960e81b815260040160405180910390fd5b63ffffffff86166000908152602082905260409020805461286257604051631c49468b60e01b815263ffffffff88166004820152602401610b8f565b60018101546001600160a01b038681169116146128c957826000036128c95760405162461bcd60e51b815260206004820152601760248201527f6d616c666f726d656420636f6e66696775726174696f6e0000000000000000006044820152606401610b8f565b8581556001810180546001600160a01b0319166001600160a01b038716179081905560028201849055600160a81b900463ffffffff9081169085161461299f57428463ffffffff161161293d576040516338f9135b60e01b815263ffffffff85166004820152426024820152604401610b8f565b60018101805463ffffffff808716600160a81b0263ffffffff60a81b1990921691909117909155600483015461297c91600160a01b9091041685615059565b8160010160196101000a81548163ffffffff021916908363ffffffff1602179055505b6001810154604080518881526001600160a01b038816602082015263ffffffff87811682840152600160c81b90930483166060820152608081018690529051918916917fbda709448a0c4f1c82cb97751ccbe39c44a8fea43a2eee090e998da86cd3e79a9181900360a00190a250505050505050565b6040805160c081018252600080825260208201819052918101829052606081018290526080810182905260a0810191909152612a4f6140b4565b63ffffffff92831660009081526020918252604090819020815160c0810183528154815260018201546001600160a01b0381169482019490945260ff600160a01b850416151592810192909252600160a81b830485166060830152600160c81b90920490931660808401526002015460a08301525090565b6000806000806000806000806000806000612ae06140b4565b90508060040160009054906101000a90046001600160a01b03168160070160009054906101000a90046001600160a01b03168260080160009054906101000a90046001600160a01b03168360040160149054906101000a900463ffffffff168460040160189054906101000a900461ffff1685600401601a9054906101000a900461ffff168660080160149054906101000a900461ffff168760080160169054906101000a900461ffff16886009015489600a01549a509a509a509a509a509a509a509a509a509a505090919293949596979899565b6000612bc06140b4565b608083901c6000818152600183016020526040812080549394509192600160381b900463ffffffff169003612c085760405163d36d896560e01b815260040160405180910390fd5b8054600160381b900463ffffffff1660009081526020849052604090206004612c30826140e2565b60ff1614612c5157604051630286465760e01b815260040160405180910390fd5b6000858152600285016020526040808220600787015491516331a9108f60e11b8152600481018990529092916001600160a01b031690636352211e90602401602060405180830381865afa925050508015612cc9575060408051601f3d908101601f19168201909252612cc691810190614f7e565b60015b612d03573d808015612cf7576040519150601f19603f3d011682016040523d82523d6000602084013e612cfc565b606091505b5050612d11565b6001600160a01b0316331490505b8015612f7e57835460ff16612e4b578354610100900460ff1615801590612d4257508354610100900460ff16600214155b15612d6057604051630c0d8d9760e11b815260040160405180910390fd5b835461ff0019166105001784556007860154604051630852cd8d60e31b8152600481018990526001600160a01b03909116906342966c6890602401600060405180830381600087803b158015612db557600080fd5b505af1158015612dc9573d6000803e3d6000fd5b50505060048501546002860154612dec92506001600160a01b03169033906142ba565b83546004850154604080519182523360208301528992600160381b900463ffffffff16916001600160801b038916917f49c11b53b8d71d8eef91d52b6cf910b6d36675f48e26bd393cd043f060a8ea68910160405180910390a46130cd565b6002820154600160801b900460ff1615612e78576040516378cd1d6d60e01b815260040160405180910390fd5b60028201805460ff60801b1916600360801b179055600180830154600386015491860154600092612ea992916141f6565b6007880154604051630852cd8d60e31b8152600481018b90529192506001600160a01b0316906342966c6890602401600060405180830381600087803b158015612ef257600080fd5b505af1158015612f06573d6000803e3d6000fd5b5050506002860154612f2391506001600160a01b031633836142ba565b8454604080518381523360208201528a92600160381b900463ffffffff16916001600160801b038a16917f49c11b53b8d71d8eef91d52b6cf910b6d36675f48e26bd393cd043f060a8ea68910160405180910390a4506130cd565b835460ff166001148015612f9e575060088401546001600160a01b031633145b80612fbf5750835460ff16158015612fbf575081546001600160a01b031633145b156130b557835460ff16613047576002820154600160801b900460ff1615612ffa576040516378cd1d6d60e01b815260040160405180910390fd5b60028201805460ff60801b1916600360801b17905560018083015460038601549186015460009261302b92916141f6565b6002860154909150612f23906001600160a01b031633836142ba565b8354610100900460ff161580159061306957508354610100900460ff16600214155b1561308757604051630c0d8d9760e11b815260040160405180910390fd5b835461ff00191661050017845560048401546002850154612dec916001600160a01b039091169033906142ba565b6040516282b42960e81b815260040160405180910390fd5b50505050505050565b6040805160808101825260008082526020820181905291810182905260608101919091526131026140b4565b600092835260029081016020908152604093849020845160808101865281546001600160a01b03168152600182015492810192909252909101546001600160801b03811693820193909352600160801b90920460ff1660608301525090565b6131696141be565b60006131736140b4565b6001600160801b03831660009081526001820160205260408120805492935091600160381b900463ffffffff1690036131bf5760405163d36d896560e01b815260040160405180910390fd5b8054610100900460ff16156131e757604051630c0d8d9760e11b815260040160405180910390fd5b60058101541561320a57604051630c0d8d9760e11b815260040160405180910390fd5b805460ff166133265760006132208460006144fc565b60078401546040516331a9108f60e11b8152600481018390529192506001600160a01b031690636352211e90602401602060405180830381865afa15801561326c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906132909190614f7e565b6001600160a01b0316336001600160a01b0316146132c0576040516282b42960e81b815260040160405180910390fd5b6007830154604051630852cd8d60e31b8152600481018390526001600160a01b03909116906342966c6890602401600060405180830381600087803b15801561330857600080fd5b505af115801561331c573d6000803e3d6000fd5b5050505050613352565b60088101546001600160a01b03163314613352576040516282b42960e81b815260040160405180910390fd5b805461ff0019166101001780825560009060049061337d9063ffffffff600160381b909104166109cb565b60ff161461339a576008830154600160b01b900461ffff1661339d565b60005b61ffff16905060006133c083600401548363ffffffff1661271061ffff166141f6565b905060008184600401546133d49190614f9b565b60028501549091506133f0906001600160a01b031633836142ba565b81156134175760088501546002850154613417916001600160a01b039182169116846142ba565b8354604051338152600160381b90910463ffffffff16906001600160801b038816907f854317c6d782af6ff1704bbcec07ae861c7fa26b6cbe9b9e47022733394690039060200160405180910390a350505050506118f3600160008051602061515583398151915255565b60405163e12f3a6160e01b81523060048201526000906001600160a01b0383169063e12f3a6190602401602060405180830381865afa1580156134c9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109f39190614f2c565b60006134f76141be565b60ff84161580159061350d57508360ff16600114155b156135305760405163070d5ee760e31b815260ff85166004820152602401610b8f565b8963ffffffff16600003613557576040516359f4f17160e01b815260040160405180910390fd5b8860000361357857604051630d45dd4360e41b815260040160405180910390fd5b6001600160a01b03881661359f576040516330b3bbd960e11b815260040160405180910390fd5b866000036135c057604051630d895b6760e41b815260040160405180910390fd5b60006135ca6140b4565b60068101549091506001600160a01b038a811691161480156135ef5750806009015488105b1561361d576009810154604051631569884360e11b8152610b8f918a91600401918252602082015260400190565b60058101546001600160a01b038a8116911614801561363f575080600a015488105b1561366d57600a810154604051631569884360e11b8152610b8f918a91600401918252602082015260400190565b6d04ee2d6d415b85acef81000000008811156136b357604051634ffde66360e11b8152600481018990526d04ee2d6d415b85acef81000000006024820152604401610b8f565b670de0b6b3a76400008a10156136ed57604051631569884360e11b8152600481018b9052670de0b6b3a76400006024820152604401610b8f565b6d04ee2d6d415b85acef81000000008a111561373357604051634ffde66360e11b8152600481018b90526d04ee2d6d415b85acef81000000006024820152604401610b8f565b60068101546001600160a01b038a8116911614801590613763575060058101546001600160a01b038a8116911614155b1561378c576040516308f72c0560e11b81526001600160a01b038a166004820152602401610b8f565b60ff85166137bc578787146137b75760405163a18f530360e01b815260048101889052602401610b8f565b613835565b60048101546000906137dc90600160c01b900461ffff168a6127106141f6565b60048301549091506000906137ff90600160d01b900461ffff168b6127106141f6565b90508189141580156138115750808914155b156138325760405163a18f530360e01b8152600481018a9052602401610b8f565b50505b63ffffffff8b166000908152602082905260408120613853906140e2565b60ff161461387457604051630286465760e01b815260040160405180910390fd5b6003810180546004906138979064010000000090046001600160801b0316614fd8565b91906101000a8154816001600160801b0302191690836001600160801b03160217905591506138dc3330898c6001600160a01b0316614516909392919063ffffffff16565b6000816001016000846001600160801b03166001600160801b031681526020019081526020016000209050858160000160006101000a81548160ff021916908360ff160217905550868160000160026101000a81548160ff0219169083151502179055508b8160000160076101000a81548163ffffffff021916908363ffffffff1602179055508a8160010181905550898160020160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550888160030181905550878160040181905550338160080160006101000a8154816001600160a01b0302191690836001600160a01b031602179055508b63ffffffff16836001600160801b03167faa8ac08a06c239d1f903d0d62c57a818e0d6891c0babe035ab40be406f6426dc8d8d8d8d8d8d33604051613a1c9796959493929190614ff4565b60405180910390a360ff8616613a9f5760078201546001600160a01b03166394d008ef33613a4b8660006144fc565b88886040518563ffffffff1660e01b8152600401613a6c949392919061507d565b600060405180830381600087803b158015613a8657600080fd5b505af1158015613a9a573d6000803e3d6000fd5b505050505b5050613ab8600160008051602061515583398151915255565b9998505050505050505050565b6000613acf6141be565b846001600160801b0316600003613af957604051630f00004760e01b815260040160405180910390fd5b6000613b036140b4565b6001600160801b03871660009081526001820160205260408120805492935091600160381b900463ffffffff169003613b4f5760405163d36d896560e01b815260040160405180910390fd5b8054610100900460ff1615613b7757604051630c0d8d9760e11b815260040160405180910390fd5b6008810154336001600160a01b0390911603613ba5576040516282b42960e81b815260040160405180910390fd5b670de0b6b3a7640000861015613bdf57604051631569884360e11b815260048101879052670de0b6b3a76400006024820152604401610b8f565b8060010154861115613c14576001810154604051631569884360e11b8152610b8f918891600401918252602082015260400190565b600081600101548703613c2c57506003810154613c42565b613c3f87836003015484600101546141f6565b90505b600683015460028301546001600160a01b039081169116148015613c695750826009015481105b15613c97576009830154604051631569884360e11b8152610b8f918391600401918252602082015260400190565b600583015460028301546001600160a01b039081169116148015613cbe575082600a015481105b15613cec57600a830154604051631569884360e11b8152610b8f918391600401918252602082015260400190565b815462010000900460ff1615613d355781600501548260030154613d109190614f9b565b811115613d3057604051631b02a49960e31b815260040160405180910390fd5b613d7c565b600582015415613d5857604051630c0d8d9760e11b815260040160405180910390fd5b81600301548114613d7c57604051631b02a49960e31b815260040160405180910390fd5b8154600160381b900463ffffffff166000908152602084905260408120613da2906140e2565b60ff1614613dc357604051630286465760e01b815260040160405180910390fd5b80826005016000828254613dd79190614fae565b909155505060058201546003830154600191613df291614f9b565b1115613dff576000613e02565b60025b825460ff919091166101000261ff00199091161782556002820154613e32906001600160a01b0316333084614516565b8154613e779089908490600390613e55906301000000900463ffffffff16614f5b565b91906101000a81548163ffffffff021916908363ffffffff16021790556144fc565b6000818152600280860160205260409182902080546001600160a01b031916339081178255600182018c905591810180546001600160801b038e166001600160801b03199091168117909155865493519498509093889363ffffffff600160381b90910416927fb8d1b8d2b35a9ca0afb36cd59b0a2447409cd536763cc0c8d4d79103c303a24791613f1a918e82526001600160a01b0316602082015260400190565b60405180910390a4825460ff1660001901613f9a5760078401546040516394d008ef60e01b81526001600160a01b03909116906394d008ef90613f6790339089908c908c9060040161507d565b600060405180830381600087803b158015613f8157600080fd5b505af1158015613f95573d6000803e3d6000fd5b505050505b50505050613fb5600160008051602061515583398151915255565b949350505050565b33613fc66140b4565b600401546001600160a01b031614613ff0576040516282b42960e81b815260040160405180910390fd5b604051635569f64b60e11b81526001600160a01b0383811660048301526024820183905284169063aad3ec96906044016020604051808303816000875af115801561403f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906140639190614f2c565b50604080516001600160a01b038086168252841660208201529081018290527f497d80235eb5f8a92716d1e222145fe1ca6c1a328bec04ae59e6bef77da1aace9060600160405180910390a1505050565b7f80a98cd2d492b7b86287ff2105d133cc8f51a35b91a585bb6e4d3400a1adab0090565b6140e0614555565b565b805460009061410757604051631c49468b60e01b815260006004820152602401610b8f565b600182810154600160a01b900460ff161515900361412757506003919050565b6001820154600160a81b900463ffffffff1615806141565750600182015442600160a81b90910463ffffffff16115b1561416357506000919050565b60018201546001600160a01b0316158015906141825750600282015415155b156141b157600182015442600160c81b90910463ffffffff1611156141a957506001919050565b506002919050565b506004919050565b919050565b6000805160206151558339815191528054600119016141f057604051633ee5aeb560e01b815260040160405180910390fd5b60029055565b600083830281600019858709828110838203039150508060000361422d57838281614223576142236150c5565b0492505050610b3b565b80841161424d5760405163227bc15360e01b815260040160405180910390fd5b6000848688096000868103871696879004966002600389028118808a02820302808a02820302808a02820302808a02820302808a02820302808a02909103029181900381900460010186841190950394909402919094039290920491909117919091029150509392505050565b6040516001600160a01b0383811660248301526044820183905261431991859182169063a9059cbb906064015b604051602081830303815290604052915060e01b6020820180516001600160e01b03838183161783525050505061459e565b505050565b306001600160a01b037f000000000000000000000000894b60b8361807ce79c0caf0773dbfd3133b007a1614806143a557507f000000000000000000000000894b60b8361807ce79c0caf0773dbfd3133b007a6001600160a01b0316614399600080516020615135833981519152546001600160a01b031690565b6001600160a01b031614155b156140e05760405163703e46dd60e11b815260040160405180910390fd5b336143cc6140b4565b600401546001600160a01b0316146118f3576040516282b42960e81b815260040160405180910390fd5b816001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa925050508015614450575060408051601f3d908101601f1916820190925261444d91810190614f2c565b60015b61447857604051634c9c8ce360e01b81526001600160a01b0383166004820152602401610b8f565b60008051602061513583398151915281146144a957604051632a87526960e21b815260048101829052602401610b8f565b6143198383614601565b306001600160a01b037f000000000000000000000000894b60b8361807ce79c0caf0773dbfd3133b007a16146140e05760405163703e46dd60e11b815260040160405180910390fd5b63ffffffff1660809190911b6001600160801b0319161790565b6040516001600160a01b03848116602483015283811660448301526064820183905261454f9186918216906323b872dd906084016142e7565b50505050565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0054600160401b900460ff166140e057604051631afcd79f60e31b815260040160405180910390fd5b60006145b36001600160a01b03841683614657565b905080516000141580156145d85750808060200190518101906145d691906150db565b155b1561431957604051635274afe760e01b81526001600160a01b0384166004820152602401610b8f565b61460a82614665565b6040516001600160a01b038316907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a280511561464f5761431982826146ca565b611911614740565b6060610b3b8383600061475f565b806001600160a01b03163b60000361469b57604051634c9c8ce360e01b81526001600160a01b0382166004820152602401610b8f565b60008051602061513583398151915280546001600160a01b0319166001600160a01b0392909216919091179055565b6060600080846001600160a01b0316846040516146e791906150f8565b600060405180830381855af49150503d8060008114614722576040519150601f19603f3d011682016040523d82523d6000602084013e614727565b606091505b50915091506147378583836147fc565b95945050505050565b34156140e05760405163b398979f60e01b815260040160405180910390fd5b6060814710156147845760405163cd78605960e01b8152306004820152602401610b8f565b600080856001600160a01b031684866040516147a091906150f8565b60006040518083038185875af1925050503d80600081146147dd576040519150601f19603f3d011682016040523d82523d6000602084013e6147e2565b606091505b50915091506147f28683836147fc565b9695505050505050565b6060826148115761480c82614858565b610b3b565b815115801561482857506001600160a01b0384163b155b1561485157604051639996b31560e01b81526001600160a01b0385166004820152602401610b8f565b5080610b3b565b8051156148685780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b80356001600160801b03811681146141b957600080fd5b6000602082840312156148aa57600080fd5b610b3b82614881565b815160ff1681526101a0810160208301516148d3602084018260ff169052565b5060408301516148e7604084018215159052565b5060608301516148ff606084018263ffffffff169052565b506080830151614917608084018263ffffffff169052565b5060a083015160a083015260c083015161493c60c08401826001600160a01b03169052565b5060e083810151908301526101008084015190830152610120808401519083015261014080840151908301526101608084015190830152610180928301516001600160a01b0316929091019190915290565b6001600160a01b03811681146118f357600080fd5b600080600080600060a086880312156149bb57600080fd5b85356149c68161498e565b945060208601356149d68161498e565b935060408601356149e68161498e565b925060608601356149f68161498e565b91506080860135614a068161498e565b809150509295509295909350565b803563ffffffff811681146141b957600080fd5b600060208284031215614a3a57600080fd5b610b3b82614a14565b600060208284031215614a5557600080fd5b5035919050565b803561ffff811681146141b957600080fd5b6000806000806000806000806000806101408b8d031215614a8e57600080fd5b8a35614a998161498e565b995060208b0135614aa98161498e565b985060408b0135614ab98161498e565b9750614ac760608c01614a14565b9650614ad560808c01614a5c565b9550614ae360a08c01614a5c565b9450614af160c08c01614a5c565b9350614aff60e08c01614a5c565b92506101008b013591506101208b013590509295989b9194979a5092959850565b634e487b7160e01b600052604160045260246000fd5b60008060408385031215614b4957600080fd5b8235614b548161498e565b9150602083013567ffffffffffffffff80821115614b7157600080fd5b818501915085601f830112614b8557600080fd5b813581811115614b9757614b97614b20565b604051601f8201601f19908116603f01168101908382118183101715614bbf57614bbf614b20565b81604052828152886020848701011115614bd857600080fd5b8260208601602083013760006020848301015280955050505050509250929050565b60008060408385031215614c0d57600080fd5b614c1683614881565b946020939093013593505050565b60005b83811015614c3f578181015183820152602001614c27565b50506000910152565b60008151808452614c60816020860160208601614c24565b601f01601f19169290920160200192915050565b602081526000610b3b6020830184614c48565b600080600080600060a08688031215614c9f57600080fd5b614ca886614a14565b9450602086013593506040860135614cbf8161498e565b9250614ccd60608701614a14565b949793965091946080013592915050565b6001600160a01b039a8b168152988a1660208a015296909816604088015263ffffffff94909416606087015261ffff928316608087015290821660a0860152811660c08501521660e08301526101008201929092526101208101919091526101400190565b600060208284031215614d5557600080fd5b8135610b3b8161498e565b80151581146118f357600080fd5b60008083601f840112614d8057600080fd5b50813567ffffffffffffffff811115614d9857600080fd5b602083019150836020828501011115614db057600080fd5b9250929050565b60008060008060008060008060006101008a8c031215614dd657600080fd5b614ddf8a614a14565b985060208a0135975060408a0135614df68161498e565b965060608a0135955060808a0135945060a08a0135614e1481614d60565b935060c08a013560ff81168114614e2a57600080fd5b925060e08a013567ffffffffffffffff811115614e4657600080fd5b614e528c828d01614d6e565b915080935050809150509295985092959850929598565b60008060008060608587031215614e7f57600080fd5b614e8885614881565b935060208501359250604085013567ffffffffffffffff811115614eab57600080fd5b614eb787828801614d6e565b95989497509550505050565b600080600060608486031215614ed857600080fd5b8335614ee38161498e565b92506020840135614ef38161498e565b929592945050506040919091013590565b6020810160038310614f2657634e487b7160e01b600052602160045260246000fd5b91905290565b600060208284031215614f3e57600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b600063ffffffff808316818103614f7457614f74614f45565b6001019392505050565b600060208284031215614f9057600080fd5b8151610b3b8161498e565b818103818111156109f3576109f3614f45565b808201808211156109f3576109f3614f45565b80820281158282048414176109f3576109f3614f45565b60006001600160801b03808316818103614f7457614f74614f45565b9687526001600160a01b039586166020880152604087019490945260608601929092521515608085015260ff1660a08401521660c082015260e00190565b60018060a01b03841681528260208201526060604082015260006147376060830184614c48565b63ffffffff81811683821601908082111561507657615076614f45565b5092915050565b6001600160a01b0385168152602081018490526060604082018190528101829052818360808301376000818301608090810191909152601f909201601f191601019392505050565b634e487b7160e01b600052601260045260246000fd5b6000602082840312156150ed57600080fd5b8151610b3b81614d60565b6000825161510a818460208701614c24565b919091019291505056fe27abe55cf1d4ce00255947a030f9e2add0bb74bdd5dc4d64a67c254aeb7cadb2360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00a26469706673582212206b1026867d76531ec520260db69789d1b1ef94e797cdc0dfd94792e1ce88aeee64736f6c63430008140033
Loading...
Loading
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in ETH
0
Multichain Portfolio | 35 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
Loading...
Loading
Loading...
Loading
Loading...
Loading
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.