Mumbai Testnet

Contract

0xF69821f7364FFc154E4a5003794EE2D9F40FD8Cc

Overview

MATIC Balance

Multichain Info

N/A
Transaction Hash
Method
Block
From
To
Value
0x60806040256462962022-03-24 10:52:23797 days ago1648119143IN
 Create: SyntheticAggregator
0 MATIC0.001376151.50000012

Parent Transaction Hash Block From To Value
View All Internal Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
SyntheticAggregator

Compiler Version
v0.8.5+commit.a4f2e591

Optimization Enabled:
Yes with 800 runs

Other Settings:
default evmVersion

Contract Source Code (Solidity Standard Json-Input format)

File 1 of 9 : SyntheticAggregator.sol
// SPDX-License-Identifier: agpl-3.0
pragma solidity 0.8.5;

import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol";
import "./base/RegistryManager.sol";
import "../interfaces/IDerivativeLogic.sol";
import "../interfaces/IRegistry.sol";
import "../libs/LibDerivative.sol";

/**
    Error codes:
    - S1 = ERROR_SYNTHETIC_AGGREGATOR_DERIVATIVE_HASH_NOT_MATCH
    - S2 = ERROR_SYNTHETIC_AGGREGATOR_WRONG_MARGIN
    - S3 = ERROR_SYNTHETIC_AGGREGATOR_COMMISSION_TOO_BIG
 */

/// @notice Opium.SyntheticAggregator contract initialized, identifies and caches syntheticId sensitive data
contract SyntheticAggregator is ReentrancyGuardUpgradeable, RegistryManager {
    using LibDerivative for LibDerivative.Derivative;

    // Emitted when new ticker is initialized
    event LogSyntheticInit(LibDerivative.Derivative indexed derivative, bytes32 indexed derivativeHash);

    struct SyntheticCache {
        uint256 buyerMargin;
        uint256 sellerMargin;
        uint256 authorCommission;
        address authorAddress;
        bool init;
    }
    mapping(bytes32 => SyntheticCache) private syntheticCaches;

    // ****************** EXTERNAL FUNCTIONS ******************

    function initialize(address _registry) external initializer {
        __RegistryManager__init(_registry);
        __ReentrancyGuard_init();
    }

    /// @notice Initializes ticker, if was not initialized and returns buyer and seller margin from cache
    /// @param _derivativeHash bytes32 hash of derivative
    /// @param _derivative LibDerivative.Derivative itself
    /// @return buyerMargin uint256 Margin of buyer
    /// @return sellerMargin uint256 Margin of seller
    function getOrCacheMargin(bytes32 _derivativeHash, LibDerivative.Derivative calldata _derivative)
        external
        returns (uint256 buyerMargin, uint256 sellerMargin)
    {
        // Initialize derivative if wasn't initialized before
        if (!syntheticCaches[_derivativeHash].init) {
            _initDerivative(_derivativeHash, _derivative);
        }
        return (syntheticCaches[_derivativeHash].buyerMargin, syntheticCaches[_derivativeHash].sellerMargin);
    }

    /// @notice Initializes ticker if not previously initialized and returns the cached `syntheticId` data
    /// @param _derivativeHash bytes32 hash of derivative
    /// @param _derivative LibDerivative.Derivative itself
    function getOrCacheSyntheticCache(bytes32 _derivativeHash, LibDerivative.Derivative calldata _derivative)
        external
        returns (SyntheticCache memory)
    {
        // Initialize derivative if wasn't initialized before
        if (!syntheticCaches[_derivativeHash].init) {
            _initDerivative(_derivativeHash, _derivative);
        }
        return syntheticCaches[_derivativeHash];
    }

    // ****************** PRIVATE FUNCTIONS ******************

    /// @notice Initializes ticker: caches syntheticId type, margin, author address and commission
    /// @param _derivativeHash bytes32 Hash of derivative
    /// @param _derivative Derivative Derivative itself
    function _initDerivative(bytes32 _derivativeHash, LibDerivative.Derivative memory _derivative)
        private
        nonReentrant
    {
        // For security reasons we calculate hash of provided _derivative
        bytes32 derivativeHash = _derivative.getDerivativeHash();
        require(derivativeHash == _derivativeHash, "S1");

        // Get margin from SyntheticId
        (uint256 buyerMargin, uint256 sellerMargin) = IDerivativeLogic(_derivative.syntheticId).getMargin(_derivative);
        // We are not allowing both margins to be equal to 0
        require(buyerMargin != 0 || sellerMargin != 0, "S2");

        // AUTHOR COMMISSION
        // Get commission from syntheticId
        uint256 authorCommission = IDerivativeLogic(_derivative.syntheticId).getAuthorCommission();
        RegistryEntities.ProtocolParametersArgs memory protocolParametersArgs = registry.getProtocolParameters();
        // Check if commission is not greater than the max cap set in the Registry by the governance
        require(authorCommission <= protocolParametersArgs.derivativeAuthorExecutionFeeCap, "S3");
        // Cache values by derivative hash
        syntheticCaches[derivativeHash] = SyntheticCache({
            buyerMargin: buyerMargin,
            sellerMargin: sellerMargin,
            authorCommission: authorCommission,
            authorAddress: IDerivativeLogic(_derivative.syntheticId).getAuthorAddress(),
            init: true
        });

        // Emits an event upon initialization of a derivative recipe (so only once during its lifecycle)
        emit LogSyntheticInit(_derivative, derivativeHash);
    }

    // Reserved storage space to allow for layout changes in the future.
    uint256[50] private __gap;
}

File 2 of 9 : ReentrancyGuardUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)

pragma solidity ^0.8.0;
import "../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;

    uint256 private _status;

    function __ReentrancyGuard_init() internal onlyInitializing {
        __ReentrancyGuard_init_unchained();
    }

    function __ReentrancyGuard_init_unchained() internal onlyInitializing {
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and making it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        // On the first call to nonReentrant, _notEntered will be true
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

        // Any calls to nonReentrant after this point will fail
        _status = _ENTERED;

        _;

        // By storing the original value once again, a refund is triggered (see
        // https://eips.ethereum.org/EIPS/eip-2200)
        _status = _NOT_ENTERED;
    }
    uint256[49] private __gap;
}

File 2 of 9 : RegistryManager.sol
// SPDX-License-Identifier: agpl-3.0
pragma solidity 0.8.5;

import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "../../interfaces/IRegistry.sol";

/**
    Error codes:
    - M1 = ERROR_REGISTRY_MANAGER_ONLY_REGISTRY_MANAGER_ROLE
    - M2 = ERROR_REGISTRY_MANAGER_ONLY_CORE_CONFIGURATION_UPDATER_ROLE
 */
contract RegistryManager is Initializable {
    event LogRegistryChanged(address indexed _changer, address indexed _newRegistryAddress);

    IRegistry internal registry;

    modifier onlyRegistryManager() {
        require(registry.isRegistryManager(msg.sender), "M1");
        _;
    }

    modifier onlyCoreConfigurationUpdater() {
        require(registry.isCoreConfigurationUpdater(msg.sender), "M2");
        _;
    }

    function __RegistryManager__init(address _registry) internal initializer {
        require(_registry != address(0));
        registry = IRegistry(_registry);
        emit LogRegistryChanged(msg.sender, _registry);
    }

    function setRegistry(address _registry) external onlyRegistryManager {
        registry = IRegistry(_registry);
        emit LogRegistryChanged(msg.sender, _registry);
    }

    function getRegistry() external view returns (address) {
        return address(registry);
    }

    // Reserved storage space to allow for layout changes in the future.
    uint256[50] private __gap;
}

File 2 of 9 : IDerivativeLogic.sol
// SPDX-License-Identifier: agpl-3.0
pragma solidity 0.8.5;

import "../libs/LibDerivative.sol";

/// @title Opium.Interface.IDerivativeLogic is an interface that every syntheticId should implement
interface IDerivativeLogic {
    // Event with syntheticId metadata JSON string (for DIB.ONE derivative explorer)
    event LogMetadataSet(string metadata);

    /// @notice Validates ticker
    /// @param _derivative Derivative Instance of derivative to validate
    /// @return Returns boolean whether ticker is valid
    function validateInput(LibDerivative.Derivative memory _derivative) external view returns (bool);

    /// @return Returns the custom name of a derivative ticker which will be used as part of the name of its positions
    function getSyntheticIdName() external view returns (string memory);

    /// @notice Calculates margin required for derivative creation
    /// @param _derivative Derivative Instance of derivative
    /// @return buyerMargin uint256 Margin needed from buyer (LONG position)
    /// @return sellerMargin uint256 Margin needed from seller (SHORT position)
    function getMargin(LibDerivative.Derivative memory _derivative)
        external
        view
        returns (uint256 buyerMargin, uint256 sellerMargin);

    /// @notice Calculates payout for derivative execution
    /// @param _derivative Derivative Instance of derivative
    /// @param _result uint256 Data retrieved from oracleId on the maturity
    /// @return buyerPayout uint256 Payout in ratio for buyer (LONG position holder)
    /// @return sellerPayout uint256 Payout in ratio for seller (SHORT position holder)
    function getExecutionPayout(LibDerivative.Derivative memory _derivative, uint256 _result)
        external
        view
        returns (uint256 buyerPayout, uint256 sellerPayout);

    /// @notice Returns syntheticId author address for Opium commissions
    /// @return authorAddress address The address of syntheticId address
    function getAuthorAddress() external view returns (address authorAddress);

    /// @notice Returns syntheticId author commission in base of COMMISSION_BASE
    /// @return commission uint256 Author commission
    function getAuthorCommission() external view returns (uint256 commission);

    /// @notice Returns whether thirdparty could execute on derivative's owner's behalf
    /// @param _derivativeOwner address Derivative owner address
    /// @return Returns boolean whether _derivativeOwner allowed third party execution
    function thirdpartyExecutionAllowed(address _derivativeOwner) external view returns (bool);

    /// @notice Sets whether thirds parties are allowed or not to execute derivative's on msg.sender's behalf
    /// @param _allow bool Flag for execution allowance
    function allowThirdpartyExecution(bool _allow) external;
}

File 2 of 9 : IRegistry.sol
// SPDX-License-Identifier: agpl-3.0
pragma solidity 0.8.5;
import "../core/registry/RegistryEntities.sol";

interface IRegistry {
    function initialize(address _governor) external;

    function setProtocolAddresses(
        address _opiumProxyFactory,
        address _core,
        address _oracleAggregator,
        address _syntheticAggregator,
        address _tokenSpender
    ) external;

    function setNoDataCancellationPeriod(uint32 _noDataCancellationPeriod) external;

    function addToWhitelist(address _whitelisted) external;

    function removeFromWhitelist(address _whitelisted) external;

    function setProtocolExecutionReserveClaimer(address _protocolExecutionReserveClaimer) external;

    function setProtocolRedemptionReserveClaimer(address _protocolRedemptionReserveClaimer) external;

    function setProtocolExecutionReservePart(uint32 _protocolExecutionReservePart) external;

    function setDerivativeAuthorExecutionFeeCap(uint32 _derivativeAuthorExecutionFeeCap) external;

    function setProtocolRedemptionReservePart(uint32 _protocolRedemptionReservePart) external;

    function setDerivativeAuthorRedemptionReservePart(uint32 _derivativeAuthorRedemptionReservePart) external;

    function pause() external;

    function pauseProtocolPositionCreation() external;

    function pauseProtocolPositionMinting() external;

    function pauseProtocolPositionRedemption() external;

    function pauseProtocolPositionExecution() external;

    function pauseProtocolPositionCancellation() external;

    function pauseProtocolReserveClaim() external;

    function unpause() external;

    function getProtocolParameters() external view returns (RegistryEntities.ProtocolParametersArgs memory);

    function getProtocolAddresses() external view returns (RegistryEntities.ProtocolAddressesArgs memory);

    function isRegistryManager(address _address) external view returns (bool);

    function isCoreConfigurationUpdater(address _address) external view returns (bool);

    function getCore() external view returns (address);

    function isCoreSpenderWhitelisted(address _address) external view returns (bool);

    function isProtocolPaused() external view returns (bool);

    function isProtocolPositionCreationPaused() external view returns (bool);

    function isProtocolPositionMintingPaused() external view returns (bool);

    function isProtocolPositionRedemptionPaused() external view returns (bool);

    function isProtocolPositionExecutionPaused() external view returns (bool);

    function isProtocolPositionCancellationPaused() external view returns (bool);

    function isProtocolReserveClaimPaused() external view returns (bool);
}

File 2 of 9 : LibDerivative.sol
// SPDX-License-Identifier: agpl-3.0
pragma solidity 0.8.5;

/// @title Opium.Lib.LibDerivative contract should be inherited by contracts that use Derivative structure and calculate derivativeHash
library LibDerivative {
    enum PositionType {
        SHORT,
        LONG
    }

    // Opium derivative structure (ticker) definition
    struct Derivative {
        // Margin parameter for syntheticId
        uint256 margin;
        // Maturity of derivative
        uint256 endTime;
        // Additional parameters for syntheticId
        uint256[] params;
        // oracleId of derivative
        address oracleId;
        // Margin token address of derivative
        address token;
        // syntheticId of derivative
        address syntheticId;
    }

    /// @notice Calculates hash of provided Derivative
    /// @param _derivative Derivative Instance of derivative to hash
    /// @return derivativeHash bytes32 Derivative hash
    function getDerivativeHash(Derivative memory _derivative) internal pure returns (bytes32 derivativeHash) {
        derivativeHash = keccak256(
            abi.encodePacked(
                _derivative.margin,
                _derivative.endTime,
                _derivative.params,
                _derivative.oracleId,
                _derivative.token,
                _derivative.syntheticId
            )
        );
    }
}

File 2 of 9 : Initializable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (proxy/utils/Initializable.sol)

pragma solidity ^0.8.0;

import "../../utils/AddressUpgradeable.sol";

/**
 * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
 * behind a proxy. Since a proxied contract can't have 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.
 *
 * 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 initialize the implementation contract, you can either invoke the
 * initializer manually, or you can include a constructor to automatically mark it as initialized when it is deployed:
 *
 * [.hljs-theme-light.nopadding]
 * ```
 * /// @custom:oz-upgrades-unsafe-allow constructor
 * constructor() initializer {}
 * ```
 * ====
 */
abstract contract Initializable {
    /**
     * @dev Indicates that the contract has been initialized.
     */
    bool private _initialized;

    /**
     * @dev Indicates that the contract is in the process of being initialized.
     */
    bool private _initializing;

    /**
     * @dev Modifier to protect an initializer function from being invoked twice.
     */
    modifier initializer() {
        // If the contract is initializing we ignore whether _initialized is set in order to support multiple
        // inheritance patterns, but we only do this in the context of a constructor, because in other contexts the
        // contract may have been reentered.
        require(_initializing ? _isConstructor() : !_initialized, "Initializable: contract is already initialized");

        bool isTopLevelCall = !_initializing;
        if (isTopLevelCall) {
            _initializing = true;
            _initialized = true;
        }

        _;

        if (isTopLevelCall) {
            _initializing = false;
        }
    }

    /**
     * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
     * {initializer} modifier, directly or indirectly.
     */
    modifier onlyInitializing() {
        require(_initializing, "Initializable: contract is not initializing");
        _;
    }

    function _isConstructor() private view returns (bool) {
        return !AddressUpgradeable.isContract(address(this));
    }
}

File 2 of 9 : AddressUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Address.sol)

pragma solidity ^0.8.0;

/**
 * @dev Collection of functions related to the address type
 */
library AddressUpgradeable {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize, which returns 0 for contracts in
        // construction, since the code is only stored at the end of the
        // constructor execution.

        uint256 size;
        assembly {
            size := extcodesize(account)
        }
        return size > 0;
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

        (bool success, ) = recipient.call{value: amount}("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain `call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason, it is bubbled up by this
     * function (like regular Solidity function calls).
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCall(target, data, "Address: low-level call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }

    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        require(isContract(target), "Address: call to non-contract");

        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        return functionStaticCall(target, data, "Address: low-level static call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        require(isContract(target), "Address: static call to non-contract");

        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly

                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

File 2 of 9 : RegistryEntities.sol
// SPDX-License-Identifier: agpl-3.0
pragma solidity 0.8.5;

library RegistryEntities {
    struct ProtocolParametersArgs {
        // Period of time after which ticker could be canceled if no data was provided to the `oracleId`
        uint32 noDataCancellationPeriod;
        // Max fee that derivative author can set
        // it works as an upper bound for when the derivative authors set their synthetic's fee
        uint32 derivativeAuthorExecutionFeeCap;
        // Fixed part (percentage) that the derivative author receives for each redemption of market neutral positions
        // It is not set by the derivative authors themselves
        uint32 derivativeAuthorRedemptionReservePart;
        // Represents which part of derivative author reserves originated from derivative executions go to the protocol reserves
        uint32 protocolExecutionReservePart;
        // Represents which part of derivative author reserves originated from redemption of market neutral positions go to the protocol reserves
        uint32 protocolRedemptionReservePart;
        /// Initially uninitialized variables to allow some flexibility in case of future changes and upgradeability
        uint32 __gapOne;
        uint32 __gapTwo;
        uint32 __gapThree;
    }

    struct ProtocolAddressesArgs {
        // Address of Opium.Core contract
        address core;
        // Address of Opium.OpiumProxyFactory contract
        address opiumProxyFactory;
        // Address of Opium.OracleAggregator contract
        address oracleAggregator;
        // Address of Opium.SyntheticAggregator contract
        address syntheticAggregator;
        // Address of Opium.TokenSpender contract
        address tokenSpender;
        // Address of the recipient of execution protocol reserves
        address protocolExecutionReserveClaimer;
        // Address of the recipient of redemption protocol reserves
        address protocolRedemptionReserveClaimer;
        /// Initially uninitialized variables to allow some flexibility in case of future changes and upgradeability
        uint32 __gapOne;
        uint32 __gapTwo;
    }

    struct ProtocolPausabilityArgs {
        // if true, all the protocol's entry-points are paused
        bool protocolGlobal;
        // if true, no new positions can be created
        bool protocolPositionCreation;
        // if true, no new positions can be minted
        bool protocolPositionMinting;
        // if true, no new positions can be redeemed
        bool protocolPositionRedemption;
        // if true, no new positions can be executed
        bool protocolPositionExecution;
        // if true, no new positions can be cancelled
        bool protocolPositionCancellation;
        // if true, no reserves can be claimed
        bool protocolReserveClaim;
        /// Initially uninitialized variables to allow some flexibility in case of future changes and upgradeability
        bool __gapOne;
        bool __gapTwo;
        bool __gapThree;
        bool __gapFour;
    }
}

Settings
{
  "optimizer": {
    "enabled": true,
    "runs": 800
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "metadata": {
    "useLiteralContent": true
  },
  "libraries": {}
}

Contract ABI

[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_changer","type":"address"},{"indexed":true,"internalType":"address","name":"_newRegistryAddress","type":"address"}],"name":"LogRegistryChanged","type":"event"},{"anonymous":false,"inputs":[{"components":[{"internalType":"uint256","name":"margin","type":"uint256"},{"internalType":"uint256","name":"endTime","type":"uint256"},{"internalType":"uint256[]","name":"params","type":"uint256[]"},{"internalType":"address","name":"oracleId","type":"address"},{"internalType":"address","name":"token","type":"address"},{"internalType":"address","name":"syntheticId","type":"address"}],"indexed":true,"internalType":"struct LibDerivative.Derivative","name":"derivative","type":"tuple"},{"indexed":true,"internalType":"bytes32","name":"derivativeHash","type":"bytes32"}],"name":"LogSyntheticInit","type":"event"},{"inputs":[{"internalType":"bytes32","name":"_derivativeHash","type":"bytes32"},{"components":[{"internalType":"uint256","name":"margin","type":"uint256"},{"internalType":"uint256","name":"endTime","type":"uint256"},{"internalType":"uint256[]","name":"params","type":"uint256[]"},{"internalType":"address","name":"oracleId","type":"address"},{"internalType":"address","name":"token","type":"address"},{"internalType":"address","name":"syntheticId","type":"address"}],"internalType":"struct LibDerivative.Derivative","name":"_derivative","type":"tuple"}],"name":"getOrCacheMargin","outputs":[{"internalType":"uint256","name":"buyerMargin","type":"uint256"},{"internalType":"uint256","name":"sellerMargin","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_derivativeHash","type":"bytes32"},{"components":[{"internalType":"uint256","name":"margin","type":"uint256"},{"internalType":"uint256","name":"endTime","type":"uint256"},{"internalType":"uint256[]","name":"params","type":"uint256[]"},{"internalType":"address","name":"oracleId","type":"address"},{"internalType":"address","name":"token","type":"address"},{"internalType":"address","name":"syntheticId","type":"address"}],"internalType":"struct LibDerivative.Derivative","name":"_derivative","type":"tuple"}],"name":"getOrCacheSyntheticCache","outputs":[{"components":[{"internalType":"uint256","name":"buyerMargin","type":"uint256"},{"internalType":"uint256","name":"sellerMargin","type":"uint256"},{"internalType":"uint256","name":"authorCommission","type":"uint256"},{"internalType":"address","name":"authorAddress","type":"address"},{"internalType":"bool","name":"init","type":"bool"}],"internalType":"struct SyntheticAggregator.SyntheticCache","name":"","type":"tuple"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getRegistry","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_registry","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_registry","type":"address"}],"name":"setRegistry","outputs":[],"stateMutability":"nonpayable","type":"function"}]

608060405234801561001057600080fd5b50610fa4806100206000396000f3fe608060405234801561001057600080fd5b50600436106100675760003560e01c8063a28702f111610050578063a28702f1146100b4578063a91ee0dc14610114578063c4d66de81461012957600080fd5b80635ab1bd531461006c5780638d52f0701461008c575b600080fd5b6033546040516001600160a01b0390911681526020015b60405180910390f35b61009f61009a366004610b13565b61013c565b60408051928352602083019190915201610083565b6100c76100c2366004610b13565b61018d565b6040516100839190600060a0820190508251825260208301516020830152604083015160408301526001600160a01b03606084015116606083015260808301511515608083015292915050565b610127610122366004610ab0565b610258565b005b610127610137366004610ab0565b610362565b6000828152606660205260408120600301548190600160a01b900460ff16610170576101708461016b85610e43565b61042d565b505050600090815260666020526040902080546001909101549091565b6101ca6040518060a0016040528060008152602001600081526020016000815260200160006001600160a01b031681526020016000151581525090565b600083815260666020526040902060030154600160a01b900460ff166101f7576101f78361016b84610e43565b5050600090815260666020908152604091829020825160a081018452815481526001820154928101929092526002810154928201929092526003909101546001600160a01b0381166060830152600160a01b900460ff161515608082015290565b603354604051634048d90960e01b81523360048201526001600160a01b0390911690634048d9099060240160206040518083038186803b15801561029b57600080fd5b505afa1580156102af573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102d39190610af1565b6103095760405162461bcd60e51b81526020600482015260026024820152614d3160f01b60448201526064015b60405180910390fd5b6033805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b03831690811790915560405133907fec10a16af385903532506d1567380fd8d93d880e8ed4bcacc42b0848e781406a90600090a350565b600054610100900460ff1661037d5760005460ff1615610381565b303b155b6103e45760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610300565b600054610100900460ff16158015610406576000805461ffff19166101011790555b61040f82610837565b610417610959565b8015610429576000805461ff00191690555b5050565b600260015414156104805760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610300565b60026001556000610490826109ce565b90508281146104c65760405162461bcd60e51b8152602060048201526002602482015261533160f01b6044820152606401610300565b6000808360a001516001600160a01b0316630433fe45856040518263ffffffff1660e01b81526004016104f99190610d3f565b604080518083038186803b15801561051057600080fd5b505afa158015610524573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105489190610c3f565b9150915081600014158061055b57508015155b61058c5760405162461bcd60e51b8152602060048201526002602482015261299960f11b6044820152606401610300565b60008460a001516001600160a01b0316633a84543e6040518163ffffffff1660e01b815260040160206040518083038186803b1580156105cb57600080fd5b505afa1580156105df573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106039190610c26565b90506000603360009054906101000a90046001600160a01b03166001600160a01b031663c58aad876040518163ffffffff1660e01b81526004016101006040518083038186803b15801561065657600080fd5b505afa15801561066a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061068e9190610b61565b9050806020015163ffffffff168211156106cf5760405162461bcd60e51b8152602060048201526002602482015261533360f01b6044820152606401610300565b6040518060a001604052808581526020018481526020018381526020018760a001516001600160a01b031663a4300ee56040518163ffffffff1660e01b815260040160206040518083038186803b15801561072957600080fd5b505afa15801561073d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107619190610ad4565b6001600160a01b039081168252600160209283018190526000898152606684526040908190208551815593850151918401919091558381015160028401556060840151600390930180546080909501511515600160a01b027fffffffffffffffffffffff0000000000000000000000000000000000000000009095169390921692909217929092179091555185906107fa908890610c96565b604051908190038120907f29aa7d92d69bcc6e17d252d7860e10e2a096dbb7d00b9017322852681fc8693590600090a35050600180555050505050565b600054610100900460ff166108525760005460ff1615610856565b303b155b6108b95760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610300565b600054610100900460ff161580156108db576000805461ffff19166101011790555b6001600160a01b0382166108ee57600080fd5b6033805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b03841690811790915560405133907fec10a16af385903532506d1567380fd8d93d880e8ed4bcacc42b0848e781406a90600090a38015610429576000805461ff00191690555050565b600054610100900460ff166109c45760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608401610300565b6109cc610a1b565b565b80516020808301516040808501516060860151608087015160a088015193516000976109fe979096959101610cee565b604051602081830303815290604052805190602001209050919050565b600054610100900460ff16610a865760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608401610300565b60018055565b8035610a9781610f56565b919050565b805163ffffffff81168114610a9757600080fd5b600060208284031215610ac257600080fd5b8135610acd81610f56565b9392505050565b600060208284031215610ae657600080fd5b8151610acd81610f56565b600060208284031215610b0357600080fd5b81518015158114610acd57600080fd5b60008060408385031215610b2657600080fd5b82359150602083013567ffffffffffffffff811115610b4457600080fd5b830160c08186031215610b5657600080fd5b809150509250929050565b6000610100808385031215610b7557600080fd5b6040519081019067ffffffffffffffff82118183101715610b9857610b98610f40565b81604052610ba584610a9c565b8152610bb360208501610a9c565b6020820152610bc460408501610a9c565b6040820152610bd560608501610a9c565b6060820152610be660808501610a9c565b6080820152610bf760a08501610a9c565b60a0820152610c0860c08501610a9c565b60c0820152610c1960e08501610a9c565b60e0820152949350505050565b600060208284031215610c3857600080fd5b5051919050565b60008060408385031215610c5257600080fd5b505080516020909101519092909150565b60008151602080840160005b83811015610c8b57815187529582019590820190600101610c6f565b509495945050505050565b81518152602082015160208201526000610cb7604083016040850151610c63565b6001600160a01b038060608601511682528060808601511660208301528060a0860151166040830152506060810191505092915050565b8681528560208201526000610d066040830187610c63565b6bffffffffffffffffffffffff19606096871b8116825294861b851660148201529290941b9092166028820152603c0195945050505050565b6000602080835260e08301845182850152818501516040850152604085015160c06060860152818151808452610100870191508483019350600092505b80831015610d9c5783518252928401926001929092019190840190610d7c565b5060608701516001600160a01b0381166080880152935060808701516001600160a01b03811660a0880152935060a08701516001600160a01b03811660c088015293509695505050505050565b60405160c0810167ffffffffffffffff81118282101715610e0c57610e0c610f40565b60405290565b604051601f8201601f1916810167ffffffffffffffff81118282101715610e3b57610e3b610f40565b604052919050565b600060c08236031215610e5557600080fd5b610e5d610de9565b8235815260208084013581830152604084013567ffffffffffffffff80821115610e8657600080fd5b9085019036601f830112610e9957600080fd5b813581811115610eab57610eab610f40565b8060051b9150610ebc848301610e12565b818152848101908486013685870188011115610ed757600080fd5b600095505b83861015610efa578035835260019590950194918601918601610edc565b50806040880152505050505050610f1360608401610a8c565b6060820152610f2460808401610a8c565b6080820152610f3560a08401610a8c565b60a082015292915050565b634e487b7160e01b600052604160045260246000fd5b6001600160a01b0381168114610f6b57600080fd5b5056fea2646970667358221220bdda9d198fe0ec226c4c49e83b1433300d6579972a72b0a1c28a9f3904ce14ff64736f6c63430008050033

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106100675760003560e01c8063a28702f111610050578063a28702f1146100b4578063a91ee0dc14610114578063c4d66de81461012957600080fd5b80635ab1bd531461006c5780638d52f0701461008c575b600080fd5b6033546040516001600160a01b0390911681526020015b60405180910390f35b61009f61009a366004610b13565b61013c565b60408051928352602083019190915201610083565b6100c76100c2366004610b13565b61018d565b6040516100839190600060a0820190508251825260208301516020830152604083015160408301526001600160a01b03606084015116606083015260808301511515608083015292915050565b610127610122366004610ab0565b610258565b005b610127610137366004610ab0565b610362565b6000828152606660205260408120600301548190600160a01b900460ff16610170576101708461016b85610e43565b61042d565b505050600090815260666020526040902080546001909101549091565b6101ca6040518060a0016040528060008152602001600081526020016000815260200160006001600160a01b031681526020016000151581525090565b600083815260666020526040902060030154600160a01b900460ff166101f7576101f78361016b84610e43565b5050600090815260666020908152604091829020825160a081018452815481526001820154928101929092526002810154928201929092526003909101546001600160a01b0381166060830152600160a01b900460ff161515608082015290565b603354604051634048d90960e01b81523360048201526001600160a01b0390911690634048d9099060240160206040518083038186803b15801561029b57600080fd5b505afa1580156102af573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102d39190610af1565b6103095760405162461bcd60e51b81526020600482015260026024820152614d3160f01b60448201526064015b60405180910390fd5b6033805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b03831690811790915560405133907fec10a16af385903532506d1567380fd8d93d880e8ed4bcacc42b0848e781406a90600090a350565b600054610100900460ff1661037d5760005460ff1615610381565b303b155b6103e45760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610300565b600054610100900460ff16158015610406576000805461ffff19166101011790555b61040f82610837565b610417610959565b8015610429576000805461ff00191690555b5050565b600260015414156104805760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610300565b60026001556000610490826109ce565b90508281146104c65760405162461bcd60e51b8152602060048201526002602482015261533160f01b6044820152606401610300565b6000808360a001516001600160a01b0316630433fe45856040518263ffffffff1660e01b81526004016104f99190610d3f565b604080518083038186803b15801561051057600080fd5b505afa158015610524573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105489190610c3f565b9150915081600014158061055b57508015155b61058c5760405162461bcd60e51b8152602060048201526002602482015261299960f11b6044820152606401610300565b60008460a001516001600160a01b0316633a84543e6040518163ffffffff1660e01b815260040160206040518083038186803b1580156105cb57600080fd5b505afa1580156105df573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106039190610c26565b90506000603360009054906101000a90046001600160a01b03166001600160a01b031663c58aad876040518163ffffffff1660e01b81526004016101006040518083038186803b15801561065657600080fd5b505afa15801561066a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061068e9190610b61565b9050806020015163ffffffff168211156106cf5760405162461bcd60e51b8152602060048201526002602482015261533360f01b6044820152606401610300565b6040518060a001604052808581526020018481526020018381526020018760a001516001600160a01b031663a4300ee56040518163ffffffff1660e01b815260040160206040518083038186803b15801561072957600080fd5b505afa15801561073d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107619190610ad4565b6001600160a01b039081168252600160209283018190526000898152606684526040908190208551815593850151918401919091558381015160028401556060840151600390930180546080909501511515600160a01b027fffffffffffffffffffffff0000000000000000000000000000000000000000009095169390921692909217929092179091555185906107fa908890610c96565b604051908190038120907f29aa7d92d69bcc6e17d252d7860e10e2a096dbb7d00b9017322852681fc8693590600090a35050600180555050505050565b600054610100900460ff166108525760005460ff1615610856565b303b155b6108b95760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610300565b600054610100900460ff161580156108db576000805461ffff19166101011790555b6001600160a01b0382166108ee57600080fd5b6033805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b03841690811790915560405133907fec10a16af385903532506d1567380fd8d93d880e8ed4bcacc42b0848e781406a90600090a38015610429576000805461ff00191690555050565b600054610100900460ff166109c45760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608401610300565b6109cc610a1b565b565b80516020808301516040808501516060860151608087015160a088015193516000976109fe979096959101610cee565b604051602081830303815290604052805190602001209050919050565b600054610100900460ff16610a865760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608401610300565b60018055565b8035610a9781610f56565b919050565b805163ffffffff81168114610a9757600080fd5b600060208284031215610ac257600080fd5b8135610acd81610f56565b9392505050565b600060208284031215610ae657600080fd5b8151610acd81610f56565b600060208284031215610b0357600080fd5b81518015158114610acd57600080fd5b60008060408385031215610b2657600080fd5b82359150602083013567ffffffffffffffff811115610b4457600080fd5b830160c08186031215610b5657600080fd5b809150509250929050565b6000610100808385031215610b7557600080fd5b6040519081019067ffffffffffffffff82118183101715610b9857610b98610f40565b81604052610ba584610a9c565b8152610bb360208501610a9c565b6020820152610bc460408501610a9c565b6040820152610bd560608501610a9c565b6060820152610be660808501610a9c565b6080820152610bf760a08501610a9c565b60a0820152610c0860c08501610a9c565b60c0820152610c1960e08501610a9c565b60e0820152949350505050565b600060208284031215610c3857600080fd5b5051919050565b60008060408385031215610c5257600080fd5b505080516020909101519092909150565b60008151602080840160005b83811015610c8b57815187529582019590820190600101610c6f565b509495945050505050565b81518152602082015160208201526000610cb7604083016040850151610c63565b6001600160a01b038060608601511682528060808601511660208301528060a0860151166040830152506060810191505092915050565b8681528560208201526000610d066040830187610c63565b6bffffffffffffffffffffffff19606096871b8116825294861b851660148201529290941b9092166028820152603c0195945050505050565b6000602080835260e08301845182850152818501516040850152604085015160c06060860152818151808452610100870191508483019350600092505b80831015610d9c5783518252928401926001929092019190840190610d7c565b5060608701516001600160a01b0381166080880152935060808701516001600160a01b03811660a0880152935060a08701516001600160a01b03811660c088015293509695505050505050565b60405160c0810167ffffffffffffffff81118282101715610e0c57610e0c610f40565b60405290565b604051601f8201601f1916810167ffffffffffffffff81118282101715610e3b57610e3b610f40565b604052919050565b600060c08236031215610e5557600080fd5b610e5d610de9565b8235815260208084013581830152604084013567ffffffffffffffff80821115610e8657600080fd5b9085019036601f830112610e9957600080fd5b813581811115610eab57610eab610f40565b8060051b9150610ebc848301610e12565b818152848101908486013685870188011115610ed757600080fd5b600095505b83861015610efa578035835260019590950194918601918601610edc565b50806040880152505050505050610f1360608401610a8c565b6060820152610f2460808401610a8c565b6080820152610f3560a08401610a8c565b60a082015292915050565b634e487b7160e01b600052604160045260246000fd5b6001600160a01b0381168114610f6b57600080fd5b5056fea2646970667358221220bdda9d198fe0ec226c4c49e83b1433300d6579972a72b0a1c28a9f3904ce14ff64736f6c63430008050033

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Txn Hash Block Value Eth2 PubKey Valid
View All Deposits
[ Download: CSV Export  ]

A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.