ETH Price: $2,700.00 (+2.55%)

Contract

0x2C0df87E073755139101b35c0A51e065291cc2d3
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
0x60a06040124245452021-05-13 6:49:431233 days ago1620888583IN
 Create: StarkPerpetual
0 ETH0.12822821110

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
StarkPerpetual

Compiler Version
v0.6.11+commit.5ef660b1

Optimization Enabled:
Yes with 100 runs

Other Settings:
default evmVersion, Apache-2.0 license

Contract Source Code (Solidity Multiple files format)

File 1 of 13: StarkPerpetual.sol
/*
  Copyright 2019,2020 StarkWare Industries Ltd.

  Licensed under the Apache License, Version 2.0 (the "License").
  You may not use this file except in compliance with the License.
  You may obtain a copy of the License at

  https://www.starkware.co/open-source-license/

  Unless required by applicable law or agreed to in writing,
  software distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions
  and limitations under the License.
*/
// SPDX-License-Identifier: Apache-2.0.
pragma solidity ^0.6.11;

import "MainDispatcher.sol";
import "PerpetualStorage.sol";

contract StarkPerpetual is MainDispatcher, PerpetualStorage {
    string public constant VERSION = "1.0.0";

    // Salt for a 8 bit unique spread of all relevant selectors. Pre-caclulated.
    // ---------- The following code was auto-generated. PLEASE DO NOT EDIT. ----------
    uint256 constant MAGIC_SALT = 24748;
    uint256 constant IDX_MAP_0 = 0x3000100000203000002010004002012003003200010000001222000021002010;
    uint256 constant IDX_MAP_1 = 0x4300000140200010000000001000030000300100000222303302;
    uint256 constant IDX_MAP_2 = 0x10001300000020200020000220001002020000320000020031100030020012;
    uint256 constant IDX_MAP_3 = 0x120300002000000000000100000000202001002000040101130302000000;
    // ---------- End of auto-generated code. ----------

    function getNumSubcontracts() internal pure override returns (uint256) {
        return 4;
    }

    function magicSalt() internal pure override returns(uint256) {
        return MAGIC_SALT;
    }

    function handlerMapSection(uint256 section) internal view override returns(uint256) {
        if(section == 0) {
            return IDX_MAP_0;
        }
        else if(section == 1) {
            return IDX_MAP_1;
        }
        else if(section == 2) {
            return IDX_MAP_2;
        }
        else if(section == 3) {
            return IDX_MAP_3;
        }
        revert("BAD_IDX_MAP_SECTION");
    }

    function expectedIdByIndex(uint256 index)
        internal pure override returns (string memory id) {
        if (index == 1){
            id = "StarkWare_AllVerifiers_2020_1";
        } else if (index == 2){
            id = "StarkWare_PerpetualTokensAndRamping_2020_1";
        } else if (index == 3){
            id = "StarkWare_PerpetualState_2020_1";
        } else if (index == 4){
            id = "StarkWare_PerpetualForcedActions_2020_1";
        } else {
            revert("UNEXPECTED_INDEX");
        }
    }

    function initializationSentinel() internal view override {
        string memory REVERT_MSG = "INITIALIZATION_BLOCKED";
        // This initializer sets state etc. It must not be applied twice.
        // I.e. it can run only when the state is still empty.
        require(int(sharedStateHash) == 0, REVERT_MSG);
        require(int(globalConfigurationHash) == 0, REVERT_MSG);
        require(systemAssetType == 0, REVERT_MSG);
    }
}

File 2 of 13: BlockDirectCall.sol
/*
  Copyright 2019,2020 StarkWare Industries Ltd.

  Licensed under the Apache License, Version 2.0 (the "License").
  You may not use this file except in compliance with the License.
  You may obtain a copy of the License at

  https://www.starkware.co/open-source-license/

  Unless required by applicable law or agreed to in writing,
  software distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions
  and limitations under the License.
*/
// SPDX-License-Identifier: Apache-2.0.
pragma solidity ^0.6.11;

/*
  This contract provides means to block direct call of an external function.
  A derived contract (e.g. MainDispatcherBase) should decorate sensitive functions with the
  notCalledDirectly modifier, thereby preventing it from being called directly, and allowing only calling
  using delegate_call.

  This Guard contract uses pseudo-random slot, So each deployed contract would have its own guard.
*/
abstract contract BlockDirectCall {
    bytes32 immutable UNIQUE_SAFEGUARD_SLOT; // NOLINT naming-convention.
    constructor( ) internal {
        // The slot is pseudo-random to allow hierarchy of contracts with guarded functions.
        bytes32 slot = keccak256(abi.encode(this, block.timestamp, gasleft()));
        UNIQUE_SAFEGUARD_SLOT = slot;
        assembly {
            sstore(slot, 42)
        }
    }

    modifier notCalledDirectly() {
        { // Prevent too many local variables in stack.
            uint256 safeGuardValue;
            bytes32 slot = UNIQUE_SAFEGUARD_SLOT;
            assembly {
                safeGuardValue := sload(slot)
            }
            require(safeGuardValue == 0, "DIRECT_CALL_DISALLOWED");
        }
        _;
    }
}

File 3 of 13: Common.sol
/*
  Copyright 2019,2020 StarkWare Industries Ltd.

  Licensed under the Apache License, Version 2.0 (the "License").
  You may not use this file except in compliance with the License.
  You may obtain a copy of the License at

  https://www.starkware.co/open-source-license/

  Unless required by applicable law or agreed to in writing,
  software distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions
  and limitations under the License.
*/
// SPDX-License-Identifier: Apache-2.0.
pragma solidity ^0.6.11;

/*
  Common Utility librarries.
  I. Addresses (extending address).
*/
library Addresses {
    function isContract(address account) internal view returns (bool) {
        uint256 size;
        assembly {
            size := extcodesize(account)
        }
        return size > 0;
    }

    function performEthTransfer(address recipient, uint256 amount) internal {
        (bool success, ) = recipient.call{value: amount}(""); // NOLINT: low-level-calls.
        require(success, "ETH_TRANSFER_FAILED");
    }

    /*
      Safe wrapper around ERC20/ERC721 calls.
      This is required because many deployed ERC20 contracts don't return a value.
      See https://github.com/ethereum/solidity/issues/4116.
    */
    function safeTokenContractCall(address tokenAddress, bytes memory callData) internal {
        require(isContract(tokenAddress), "BAD_TOKEN_ADDRESS");
        // NOLINTNEXTLINE: low-level-calls.
        (bool success, bytes memory returndata) = tokenAddress.call(callData);
        require(success, string(returndata));

        if (returndata.length > 0) {
            require(abi.decode(returndata, (bool)), "TOKEN_OPERATION_FAILED");
        }
    }

    /*
      Similar to safeTokenContractCall, but always ignores the return value.

      Assumes some other method is used to detect the failures
      (e.g. balance is checked before and after the call).
    */
    function uncheckedTokenContractCall(address tokenAddress, bytes memory callData) internal {
        // NOLINTNEXTLINE: low-level-calls.
        (bool success, bytes memory returndata) = tokenAddress.call(callData);
        require(success, string(returndata));
    }

}

library UintArray {
    function hashSubArray(uint256[] memory array, uint256 subArrayStart, uint256 subArraySize)
        internal pure
        returns(bytes32 subArrayHash)
    {
        require(array.length >= subArrayStart + subArraySize, "ILLEGAL_SUBARRAY_DIMENSIONS");
        uint256 startOffsetBytes = 0x20 * (1 + subArrayStart);
        uint256 dataSizeBytes = 0x20 * subArraySize;
        assembly {
            subArrayHash := keccak256(add(array, startOffsetBytes), dataSizeBytes)
        }
    }

    /*
      Returns the address of a cell in offset within a uint256[] array.
      This allows assigning new variable of dynamic unit256[] pointing to a sub_array
      with a layout of serialied uint256[] (i.e. length+content).
    */
    function extractSerializedUintArray(uint256[] memory programOutput, uint256 offset)
        internal pure
        returns (uint256[] memory addr)
    {
        uint256 memOffset = 0x20 * (offset + 1);
        assembly {
            addr := add(programOutput, memOffset)
        }
    }

}

/*
  II. StarkExTypes - Common data types.
*/
library StarkExTypes {

    // Structure representing a list of verifiers (validity/availability).
    // A statement is valid only if all the verifiers in the list agree on it.
    // Adding a verifier to the list is immediate - this is used for fast resolution of
    // any soundness issues.
    // Removing from the list is time-locked, to ensure that any user of the system
    // not content with the announced removal has ample time to leave the system before it is
    // removed.
    struct ApprovalChainData {
        address[] list;
        // Represents the time after which the verifier with the given address can be removed.
        // Removal of the verifier with address A is allowed only in the case the value
        // of unlockedForRemovalTime[A] != 0 and unlockedForRemovalTime[A] < (current time).
        mapping (address => uint256) unlockedForRemovalTime;
    }
}

File 4 of 13: GovernanceStorage.sol
/*
  Copyright 2019,2020 StarkWare Industries Ltd.

  Licensed under the Apache License, Version 2.0 (the "License").
  You may not use this file except in compliance with the License.
  You may obtain a copy of the License at

  https://www.starkware.co/open-source-license/

  Unless required by applicable law or agreed to in writing,
  software distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions
  and limitations under the License.
*/
// SPDX-License-Identifier: Apache-2.0.
pragma solidity ^0.6.11;

/*
  Holds the governance slots for ALL entities, including proxy and the main contract.
*/
contract GovernanceStorage {

    struct GovernanceInfoStruct {
        mapping (address => bool) effectiveGovernors;
        address candidateGovernor;
        bool initialized;
    }

    // A map from a Governor tag to its own GovernanceInfoStruct.
    mapping (string => GovernanceInfoStruct) internal governanceInfo;
}

File 5 of 13: Identity.sol
/*
  Copyright 2019,2020 StarkWare Industries Ltd.

  Licensed under the Apache License, Version 2.0 (the "License").
  You may not use this file except in compliance with the License.
  You may obtain a copy of the License at

  https://www.starkware.co/open-source-license/

  Unless required by applicable law or agreed to in writing,
  software distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions
  and limitations under the License.
*/
// SPDX-License-Identifier: Apache-2.0.
pragma solidity ^0.6.11;

interface Identity {

    /*
      Allows a caller, typically another contract,
      to ensure that the provided address is of the expected type and version.
    */
    function identify()
        external pure
        returns(string memory);
}

File 6 of 13: IDispatcherBase.sol
/*
  Copyright 2019,2020 StarkWare Industries Ltd.

  Licensed under the Apache License, Version 2.0 (the "License").
  You may not use this file except in compliance with the License.
  You may obtain a copy of the License at

  https://www.starkware.co/open-source-license/

  Unless required by applicable law or agreed to in writing,
  software distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions
  and limitations under the License.
*/
// SPDX-License-Identifier: Apache-2.0.
pragma solidity ^0.6.11;

/*
  Interface for generic dispatcher to use,
  which the concrete dispatcher must implement.

  I contains the functions that are specific to the concrete dispatcher instance.

  The interface is implemented as contract, because interface implies all methods external.
*/
abstract contract IDispatcherBase {

    function getSubContract(bytes4 selector) internal view virtual returns (address);

    function setSubContractAddress(uint256 index, address subContract) internal virtual;

    function getNumSubcontracts() internal pure virtual returns (uint256);

    function validateSubContractIndex(uint256 index, address subContract) internal pure virtual;

    /*
      Ensures initializer can be called. Reverts otherwise.
    */
    function initializationSentinel() internal view virtual;
}

File 7 of 13: IFactRegistry.sol
/*
  Copyright 2019,2020 StarkWare Industries Ltd.

  Licensed under the Apache License, Version 2.0 (the "License").
  You may not use this file except in compliance with the License.
  You may obtain a copy of the License at

  https://www.starkware.co/open-source-license/

  Unless required by applicable law or agreed to in writing,
  software distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions
  and limitations under the License.
*/
// SPDX-License-Identifier: Apache-2.0.
pragma solidity ^0.6.11;

/*
  The Fact Registry design pattern is a way to separate cryptographic verification from the
  business logic of the contract flow.

  A fact registry holds a hash table of verified "facts" which are represented by a hash of claims
  that the registry hash check and found valid. This table may be queried by accessing the
  isValid() function of the registry with a given hash.

  In addition, each fact registry exposes a registry specific function for submitting new claims
  together with their proofs. The information submitted varies from one registry to the other
  depending of the type of fact requiring verification.

  For further reading on the Fact Registry design pattern see this
  `StarkWare blog post <https://medium.com/starkware/the-fact-registry-a64aafb598b6>`_.
*/
interface IFactRegistry {
    /*
      Returns true if the given fact was previously registered in the contract.
    */
    function isValid(bytes32 fact)
        external view
        returns(bool);
}

File 8 of 13: MainDispatcher.sol
/*
  Copyright 2019,2020 StarkWare Industries Ltd.

  Licensed under the Apache License, Version 2.0 (the "License").
  You may not use this file except in compliance with the License.
  You may obtain a copy of the License at

  https://www.starkware.co/open-source-license/

  Unless required by applicable law or agreed to in writing,
  software distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions
  and limitations under the License.
*/
// SPDX-License-Identifier: Apache-2.0.
pragma solidity ^0.6.11;

import "MainStorage.sol";
import "MainDispatcherBase.sol";

abstract contract MainDispatcher is MainStorage, MainDispatcherBase {

    uint256 constant SUBCONTRACT_BITS = 4;

    function magicSalt() internal pure virtual returns(uint256);
    function handlerMapSection(uint256 section) internal view virtual returns(uint256);
    function expectedIdByIndex(uint256 index) internal pure virtual returns (string memory id);

    function validateSubContractIndex(uint256 index, address subContract) internal pure override {
        string memory id = SubContractor(subContract).identify();
        bytes32 hashed_expected_id = keccak256(abi.encodePacked(expectedIdByIndex(index)));
        require(
            hashed_expected_id == keccak256(abi.encodePacked(id)),
            "MISPLACED_INDEX_OR_BAD_CONTRACT_ID"
        );
    }

    function getSubContract(bytes4 selector) internal view override returns (address) {
        uint256 location = 0xFF & uint256(keccak256(abi.encodePacked(selector, magicSalt())));
        uint256 subContractIdx;
        uint256 offset = (SUBCONTRACT_BITS * location) % 256;

        // We have 64 locations in each register, hence the >>6 (i.e. location // 64).
        subContractIdx = (handlerMapSection(location >> 6) >> offset) & 0xF;
        return subContracts[subContractIdx];
    }

    function setSubContractAddress(uint256 index, address subContractAddress) internal override {
        subContracts[index] = subContractAddress;
    }
}

File 9 of 13: MainDispatcherBase.sol
/*
  Copyright 2019,2020 StarkWare Industries Ltd.

  Licensed under the Apache License, Version 2.0 (the "License").
  You may not use this file except in compliance with the License.
  You may obtain a copy of the License at

  https://www.starkware.co/open-source-license/

  Unless required by applicable law or agreed to in writing,
  software distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions
  and limitations under the License.
*/
// SPDX-License-Identifier: Apache-2.0.
pragma solidity ^0.6.11;

import "SubContractor.sol";
import "IDispatcherBase.sol";
import "BlockDirectCall.sol";
import "Common.sol";

abstract contract MainDispatcherBase is IDispatcherBase, BlockDirectCall {

    using Addresses for address;

    /*
      This entry point serves only transactions with empty calldata. (i.e. pure value transfer tx).
      We don't expect to receive such, thus block them.
    */
    receive() external payable {
        revert("CONTRACT_NOT_EXPECTED_TO_RECEIVE");
    }

    fallback() external payable {
        address subContractAddress = getSubContract(msg.sig);
        require(subContractAddress != address(0x0), "NO_CONTRACT_FOR_FUNCTION");

        assembly {
            // Copy msg.data. We take full control of memory in this inline assembly
            // block because it will not return to Solidity code. We overwrite the
            // Solidity scratch pad at memory position 0.
            calldatacopy(0, 0, calldatasize())

            // Call the implementation.
            // out and outsize are 0 for now, as we don"t know the out size yet.
            let result := delegatecall(gas(), subContractAddress, 0, calldatasize(), 0, 0)

            // Copy the returned data.
            returndatacopy(0, 0, returndatasize())

            switch result
                // delegatecall returns 0 on error.
                case 0 {
                    revert(0, returndatasize())
                }
                default {
                    return(0, returndatasize())
                }
        }
    }

    /*
      1. Extract subcontracts.
      2. Verify correct sub-contract initializer size.
      3. Extract sub-contract initializer data.
      4. Call sub-contract initializer.

      The init data bytes passed to initialize are structed as following:
      I. N slots (uin256 size) addresses of the deployed sub-contracts.
      II. An address of an external initialization contract (optional, or ZERO_ADDRESS).
      III. (Up to) N bytes sections of the sub-contracts initializers.

      If already initialized (i.e. upgrade) we expect the init data to be consistent with this.
      and if a different size of init data is expected when upgrading, the initializerSize should
      reflect this.

      If an external initializer contract is not used, ZERO_ADDRESS is passed in its slot.
      If the external initializer contract is used, all the remaining init data is passed to it,
      and internal initialization will not occur.

      External Initialization Contract
      --------------------------------
      External Initialization Contract (EIC) is a hook for custom initialization.
      Typically in an upgrade flow, the expected initialization contains only the addresses of
      the sub-contracts. Normal initialization of the sub-contracts is such that is not needed
      in an upgrade, and actually may be very dangerous, as changing of state on a working system
      may corrupt it.

      In the event that some state initialization is required, the EIC is a hook that allows this.
      It may be deployed and called specifically for this purpose.

      The address of the EIC must be provided (if at all) when a new implementation is added to
      a Proxy contract (as part of the initialization vector).
      Hence, it is considered part of the code open to reviewers prior to a time-locked upgrade.

      When a custom initialization is performed using an EIC,
      the main dispatcher initialize extracts and stores the sub-contracts addresses, and then
      yields to the EIC, skipping the rest of its initialization code.


      Flow of MainDispatcher initialize
      ---------------------------------
      1. Extraction and assignment of subcontracts addresses
         Main dispatcher expects a valid and consistent set of addresses in the passed data.
         It validates that, extracts the addresses from the data, and validates that the addresses
         are of the expected type and order. Then those addresses are stored.

      2. Extraction of EIC address
         The address of the EIC is extracted from the data.
         External Initializer Contract is optional. ZERO_ADDRESS indicates it is not used.

      3a. EIC is used
          Dispatcher calls the EIC initialize function with the remaining data.
          Note - In this option 3b is not performed.

      3b. EIC is not used
          If there is additional initialization data then:
          I. Sentitenl function is called to permit subcontracts initialization.
          II. Dispatcher loops through the subcontracts and for each one it extracts the
              initializing data and passes it to the subcontract's initialize function.

    */
    // NOLINTNEXTLINE: external-function.
    function initialize(bytes memory data) public virtual
        notCalledDirectly
    {
        // Number of sub-contracts.
        uint256 nSubContracts = getNumSubcontracts();

        // We support currently 4 bits per contract, i.e. 16, reserving 00 leads to 15.
        require(nSubContracts <= 15, "TOO_MANY_SUB_CONTRACTS");

        // Init data MUST include addresses for all sub-contracts + EIC.
        require(data.length >= 32 * (nSubContracts + 1), "SUB_CONTRACTS_NOT_PROVIDED");

        // Size of passed data, excluding sub-contract addresses.
        uint256 additionalDataSize = data.length - 32 * (nSubContracts + 1);

        // Sum of subcontract initializers. Aggregated for verification near the end.
        uint256 totalInitSizes = 0;

        // Offset (within data) of sub-contract initializer vector.
        // Just past the sub-contract addresses.
        uint256 initDataContractsOffset = 32 * (nSubContracts + 1);

        // Extract & update contract addresses.
        for (uint256 nContract = 1; nContract <= nSubContracts; nContract++) {
            address contractAddress;

            // Extract sub-contract address.
            assembly {
                contractAddress := mload(add(data, mul(32, nContract)))
            }

            validateSubContractIndex(nContract, contractAddress);

            // Contracts are indexed from 1 and 0 is not in use here.
            setSubContractAddress(nContract, contractAddress);
        }

        // Check if we have an external initializer contract.
        address externalInitializerAddr;

        // 2. Extract sub-contract address, again. It's cheaper than reading from storage.
        assembly {
            externalInitializerAddr := mload(add(data, mul(32, add(nSubContracts, 1))))
        }

        // 3(a). Yield to EIC initialization.
        if (externalInitializerAddr != address(0x0)) {
            callExternalInitializer(data, externalInitializerAddr, additionalDataSize);
            return;
        }

        // 3(b). Subcontracts initialization.
        // I. If no init data passed besides sub-contracts, return.
        if (additionalDataSize == 0) {
            return;
        }

        // Just to be on the safe side.
        assert(externalInitializerAddr == address(0x0));

        // II. Gate further initialization.
        initializationSentinel();

        // III. Loops through the subcontracts, extracts their data and calls their initializer.
        for (uint256 nContract = 1; nContract <= nSubContracts; nContract++) {
            address contractAddress;

            // Extract sub-contract address, again. It's cheaper than reading from storage.
            assembly {
                contractAddress := mload(add(data, mul(32, nContract)))
            }
            // The initializerSize returns the expected size, with respect also to the state status.
            // i.e. different size if it's a first init (clean state) or upgrade init (alive state).
            // NOLINTNEXTLINE: calls-loop.

            // The initializerSize is called via delegatecall, so that it can relate to the state,
            // and not only to the new contract code. (e.g. return 0 if state-intialized else 192).
            // NOLINTNEXTLINE: reentrancy-events low-level-calls calls-loop.
            (bool success, bytes memory returndata) = contractAddress.delegatecall(
                abi.encodeWithSelector(SubContractor(contractAddress).initializerSize.selector));
            require(success, string(returndata));
            uint256 initSize = abi.decode(returndata, (uint256));
            require(initSize <= additionalDataSize, "INVALID_INITIALIZER_SIZE");
            require(totalInitSizes + initSize <= additionalDataSize, "INVALID_INITIALIZER_SIZE");

            if (initSize == 0) {
                continue;
            }

            // Extract sub-contract init vector.
            bytes memory subContractInitData = new bytes(initSize);
            for (uint256 trgOffset = 32; trgOffset <= initSize; trgOffset += 32) {
                assembly {
                    mstore(
                        add(subContractInitData, trgOffset),
                        mload(add(add(data, trgOffset), initDataContractsOffset))
                    )
                }
            }

            // Call sub-contract initializer.
            // NOLINTNEXTLINE: low-level-calls.
            (success, returndata) = contractAddress.delegatecall(
                abi.encodeWithSelector(this.initialize.selector, subContractInitData)
            );
            require(success, string(returndata));
            totalInitSizes += initSize;
            initDataContractsOffset += initSize;
        }
        require(
            additionalDataSize == totalInitSizes,
            "MISMATCHING_INIT_DATA_SIZE");
    }

    function callExternalInitializer(
        bytes memory data,
        address externalInitializerAddr,
        uint256 dataSize)
        private {
        require(externalInitializerAddr.isContract(), "NOT_A_CONTRACT");
        require(dataSize <= data.length, "INVALID_DATA_SIZE");
        bytes memory extInitData = new bytes(dataSize);

        // Prepare memcpy pointers.
        uint256 srcDataOffset = 32 + data.length - dataSize;
        uint256 srcData;
        uint256 trgData;

        assembly {
            srcData := add(data, srcDataOffset)
            trgData := add(extInitData, 32)
        }

        // Copy initializer data to be passed to the EIC.
        for (uint256 seek = 0; seek < dataSize; seek += 32) {
            assembly {
                mstore(
                    add(trgData, seek),
                    mload(add(srcData, seek))
                )
            }
        }

        // NOLINTNEXTLINE: low-level-calls.
        (bool success, bytes memory returndata) = externalInitializerAddr.delegatecall(
            abi.encodeWithSelector(this.initialize.selector, extInitData)
        );
        require(success, string(returndata));
        require(returndata.length == 0, string(returndata));
    }
}

File 10 of 13: MainStorage.sol
/*
  Copyright 2019,2020 StarkWare Industries Ltd.

  Licensed under the Apache License, Version 2.0 (the "License").
  You may not use this file except in compliance with the License.
  You may obtain a copy of the License at

  https://www.starkware.co/open-source-license/

  Unless required by applicable law or agreed to in writing,
  software distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions
  and limitations under the License.
*/
// SPDX-License-Identifier: Apache-2.0.
pragma solidity ^0.6.11;

import "IFactRegistry.sol";
import "ProxyStorage.sol";
import "Common.sol";
/*
  Holds ALL the main contract state (storage) variables.
*/
contract MainStorage is ProxyStorage {

    uint256 constant internal LAYOUT_LENGTH = 2**64;

    IFactRegistry escapeVerifier_;

    // Global dex-frozen flag.
    bool stateFrozen;                               // NOLINT: constable-states.

    // Time when unFreeze can be successfully called (UNFREEZE_DELAY after freeze).
    uint256 unFreezeTime;                           // NOLINT: constable-states.

    // Pending deposits.
    // A map STARK key => asset id => vault id => quantized amount.
    mapping (uint256 => mapping (uint256 => mapping (uint256 => uint256))) pendingDeposits;

    // Cancellation requests.
    // A map STARK key => asset id => vault id => request timestamp.
    mapping (uint256 => mapping (uint256 => mapping (uint256 => uint256))) cancellationRequests;

    // Pending withdrawals.
    // A map STARK key => asset id => quantized amount.
    mapping (uint256 => mapping (uint256 => uint256)) pendingWithdrawals;

    // vault_id => escape used boolean.
    mapping (uint256 => bool) escapesUsed;

    // Number of escapes that were performed when frozen.
    uint256 escapesUsedCount;                       // NOLINT: constable-states.

    // NOTE: fullWithdrawalRequests is deprecated, and replaced by forcedActionRequests.
    // NOLINTNEXTLINE naming-convention.
    mapping (uint256 => mapping (uint256 => uint256)) fullWithdrawalRequests_DEPRECATED;

    // State sequence number.
    uint256 sequenceNumber;                         // NOLINT: constable-states uninitialized-state.

    // Vaults Tree Root & Height.
    uint256 vaultRoot;                              // NOLINT: constable-states uninitialized-state.
    uint256 vaultTreeHeight;                        // NOLINT: constable-states uninitialized-state.

    // Order Tree Root & Height.
    uint256 orderRoot;                              // NOLINT: constable-states uninitialized-state.
    uint256 orderTreeHeight;                        // NOLINT: constable-states uninitialized-state.

    // True if and only if the address is allowed to add tokens.
    mapping (address => bool) tokenAdmins;

    // True if and only if the address is allowed to register users.
    mapping (address => bool) userAdmins;

    // True if and only if the address is an operator (allowed to update state).
    mapping (address => bool) operators;

    // Mapping of contract ID to asset data.
    mapping (uint256 => bytes) assetTypeToAssetInfo;    // NOLINT: uninitialized-state.

    // Mapping of registered contract IDs.
    mapping (uint256 => bool) registeredAssetType;      // NOLINT: uninitialized-state.

    // Mapping from contract ID to quantum.
    mapping (uint256 => uint256) assetTypeToQuantum;    // NOLINT: uninitialized-state.

    // This mapping is no longer in use, remains for backwards compatibility.
    mapping (address => uint256) starkKeys_DEPRECATED;  // NOLINT: naming-convention.

    // Mapping from STARK public key to the Ethereum public key of its owner.
    mapping (uint256 => address) ethKeys;               // NOLINT: uninitialized-state.

    // Timelocked state transition and availability verification chain.
    StarkExTypes.ApprovalChainData verifiersChain;
    StarkExTypes.ApprovalChainData availabilityVerifiersChain;

    // Batch id of last accepted proof.
    uint256 lastBatchId;                            // NOLINT: constable-states uninitialized-state.

    // Mapping between sub-contract index to sub-contract address.
    mapping(uint256 => address) subContracts;       // NOLINT: uninitialized-state.

    mapping (uint256 => bool) permissiveAssetType_DEPRECATED; // NOLINT: naming-convention.
    // ---- END OF MAIN STORAGE AS DEPLOYED IN STARKEX2.0 ----

    // Onchain-data version configured for the system.
    uint256 onchainDataVersion;                     // NOLINT: constable-states uninitialized-state.

    // Counter of forced action request in block. The key is the block number.
    mapping(uint256 => uint256) forcedRequestsInBlock;

    // ForcedAction requests: actionHash => requestTime.
    mapping(bytes32 => uint256) forcedActionRequests;

    // Mapping for timelocked actions.
    // A actionKey => activation time.
    mapping (bytes32 => uint256) actionsTimeLock;

    // Reserved storage space for Extensibility.
    // Every added MUST be added above the end gap, and the __endGap size must be reduced
    // accordingly.
    // NOLINTNEXTLINE: naming-convention.
    uint256[LAYOUT_LENGTH - 36] private __endGap;  // __endGap complements layout to LAYOUT_LENGTH.
}

File 11 of 13: PerpetualStorage.sol
/*
  Copyright 2019,2020 StarkWare Industries Ltd.

  Licensed under the Apache License, Version 2.0 (the "License").
  You may not use this file except in compliance with the License.
  You may obtain a copy of the License at

  https://www.starkware.co/open-source-license/

  Unless required by applicable law or agreed to in writing,
  software distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions
  and limitations under the License.
*/
// SPDX-License-Identifier: Apache-2.0.
pragma solidity ^0.6.11;

import "MainStorage.sol";

/*
  Extends MainStorage, holds Perpetual App specific state (storage) variables.

  ALL State variables that are common to all applications, reside in MainStorage,
  whereas ALL the Perpetual app specific ones reside here.
*/
contract PerpetualStorage is MainStorage {
    uint256 systemAssetType;                       // NOLINT: constable-states uninitialized-state.

    bytes32 public globalConfigurationHash;        // NOLINT: constable-states uninitialized-state.

    mapping(uint256 => bytes32) public configurationHash; // NOLINT: uninitialized-state.

    bytes32 sharedStateHash;                       // NOLINT: constable-states uninitialized-state.

    // Configuration apply time-lock.
    // The delay is held in storage (and not constant)
    // So that it can be modified during upgrade.
    uint256 public configurationDelay;             // NOLINT: constable-states.

    // Reserved storage space for Extensibility.
    // Every added MUST be added above the end gap, and the __endGap size must be reduced
    // accordingly.
    // NOLINTNEXTLINE: naming-convention shadowing-abstract.
    uint256[LAYOUT_LENGTH - 5] private __endGap;  // __endGap complements layout to LAYOUT_LENGTH.
}

File 12 of 13: ProxyStorage.sol
/*
  Copyright 2019,2020 StarkWare Industries Ltd.

  Licensed under the Apache License, Version 2.0 (the "License").
  You may not use this file except in compliance with the License.
  You may obtain a copy of the License at

  https://www.starkware.co/open-source-license/

  Unless required by applicable law or agreed to in writing,
  software distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions
  and limitations under the License.
*/
// SPDX-License-Identifier: Apache-2.0.
pragma solidity ^0.6.11;

import "GovernanceStorage.sol";

/*
  Holds the Proxy-specific state variables.
  This contract is inherited by the GovernanceStorage (and indirectly by MainStorage)
  to prevent collision hazard.
*/
contract ProxyStorage is GovernanceStorage {

    // Stores the hash of the initialization vector of the added implementation.
    // Upon upgradeTo the implementation, the initialization vector is verified
    // to be identical to the one submitted when adding the implementation.
    mapping (address => bytes32) internal initializationHash;

    // The time after which we can switch to the implementation.
    mapping (address => uint256) internal enabledTime;

    // A central storage of the flags whether implementation has been initialized.
    // Note - it can be used flexibly enough to accommodate multiple levels of initialization
    // (i.e. using different key salting schemes for different initialization levels).
    mapping (bytes32 => bool) internal initialized;
}

File 13 of 13: SubContractor.sol
/*
  Copyright 2019,2020 StarkWare Industries Ltd.

  Licensed under the Apache License, Version 2.0 (the "License").
  You may not use this file except in compliance with the License.
  You may obtain a copy of the License at

  https://www.starkware.co/open-source-license/

  Unless required by applicable law or agreed to in writing,
  software distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions
  and limitations under the License.
*/
// SPDX-License-Identifier: Apache-2.0.
pragma solidity ^0.6.11;

import "Identity.sol";

interface SubContractor is Identity {

    function initialize(bytes calldata data)
        external;

    function initializerSize()
        external view
        returns(uint256);
}

Contract Security Audit

Contract ABI

[{"stateMutability":"payable","type":"fallback"},{"inputs":[],"name":"VERSION","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"configurationDelay","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"configurationHash","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"globalConfigurationHash","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"data","type":"bytes"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]

60a060405234801561001057600080fd5b50600030425a604080516001600160a01b03909416602080860191909152848201939093526060808501929092528051808503909201825260809384019052805191012090819052602a9055506080516113b76100776000398061036452506113b76000f3fe60806040526004361061004e5760003560e01c8063439fab9114610133578063adac3e15146101e6578063c1a851301461020d578063f2011f6614610222578063ffa1ad741461024c576100a0565b366100a0576040805162461bcd60e51b815260206004820181905260248201527f434f4e54524143545f4e4f545f45585045435445445f544f5f52454345495645604482015290519081900360640190fd5b60006100b76000356001600160e01b0319166102d6565b90506001600160a01b03811661010f576040805162461bcd60e51b81526020600482015260186024820152772727afa1a7a72a2920a1aa2fa327a92fa32aa721aa24a7a760411b604482015290519081900360640190fd5b3660008037600080366000845af43d6000803e80801561012e573d6000f35b3d6000fd5b34801561013f57600080fd5b506101e46004803603602081101561015657600080fd5b810190602081018135600160201b81111561017057600080fd5b82018360208201111561018257600080fd5b803590602001918460018302840111600160201b831117156101a357600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550610362945050505050565b005b3480156101f257600080fd5b506101fb6109cb565b60408051918252519081900360200190f35b34801561021957600080fd5b506101fb6109d9565b34801561022e57600080fd5b506101fb6004803603602081101561024557600080fd5b50356109e7565b34801561025857600080fd5b50610261610a01565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561029b578181015183820152602001610283565b50505050905090810190601f1680156102c85780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b600080826102e2610a22565b604080516001600160e01b03199093166020808501919091526024808501939093528151808503909301835260449093019052805191012060ff169050600080610100600484020690508061033a600685901c610a28565b600f911c166000908152601e60205260409020546001600160a01b031693505050505b919050565b7f000000000000000000000000000000000000000000000000000000000000000080549081156103d2576040805162461bcd60e51b81526020600482015260166024820152751112549150d517d0d0531317d11254d0531313d5d15160521b604482015290519081900360640190fd5b505060006103de610b20565b9050600f81111561042f576040805162461bcd60e51b8152602060048201526016602482015275544f4f5f4d414e595f5355425f434f4e54524143545360501b604482015290519081900360640190fd5b806001016020028251101561048b576040805162461bcd60e51b815260206004820152601a60248201527f5355425f434f4e5452414354535f4e4f545f50524f5649444544000000000000604482015290519081900360640190fd5b8151600182810160200291829003916000915b8481116104c957602081028601516104b68282610b25565b6104c08282610d78565b5060010161049e565b50602060018501028501516001600160a01b038116156104f8576104ee868286610da6565b50505050506109c8565b836105075750505050506109c8565b6001600160a01b0381161561051857fe5b6105206110b5565b60015b85811161096d576020808202880151604080516004815260248101825292830180516001600160e01b0316633cc660ad60e01b1781529051835192936000936060936001600160a01b03871693918291908083835b602083106105975780518252601f199092019160209182019101610578565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855af49150503d80600081146105f7576040519150601f19603f3d011682016040523d82523d6000602084013e6105fc565b606091505b509150915081819061068c5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610651578181015183820152602001610639565b50505050905090810190601f16801561067e5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008180602001905160208110156106a457600080fd5b50519050888111156106f8576040805162461bcd60e51b8152602060048201526018602482015277494e56414c49445f494e495449414c495a45525f53495a4560401b604482015290519081900360640190fd5b88818901111561074a576040805162461bcd60e51b8152602060048201526018602482015277494e56414c49445f494e495449414c495a45525f53495a4560401b604482015290519081900360640190fd5b806107585750505050610965565b60608167ffffffffffffffff8111801561077157600080fd5b506040519080825280601f01601f19166020018201604052801561079c576020820181803683370190505b50905060205b8281116107bb578c8101890151828201526020016107a2565b506040516020602482018181528351604484015283516001600160a01b0389169363439fab9160e01b9386939283926064019185019080838360005b8381101561080f5781810151838201526020016107f7565b50505050905090810190601f16801561083c5780820380516001836020036101000a031916815260200191505b5060408051601f198184030181529181526020820180516001600160e01b03166001600160e01b0319909716969096178652518151919590945084935091508083835b6020831061089e5780518252601f19909201916020918201910161087f565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855af49150503d80600081146108fe576040519150601f19603f3d011682016040523d82523d6000602084013e610903565b606091505b50909450925082846109565760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315610651578181015183820152602001610639565b50509687019695909501945050505b600101610523565b508284146109c2576040805162461bcd60e51b815260206004820152601a60248201527f4d49534d41544348494e475f494e49545f444154415f53495a45000000000000604482015290519081900360640190fd5b50505050505b50565b680100000000000000015481565b680100000000000000045481565b680100000000000000026020526000908152604090205481565b604051806040016040528060058152602001640312e302e360dc1b81525081565b6160ac90565b600081610a5657507f300010000020300000201000400201200300320001000000122200002100201061035d565b8160011415610a80575079430000014020001000000000100003000030010000022230330261035d565b8160021415610aaf57507e1000130000002020002000022000100202000032000002003110003002001261035d565b8160031415610add57507d12030000200000000000010000000020200100200004010113030200000061035d565b6040805162461bcd60e51b81526020600482015260136024820152722120a22fa4a22c2fa6a0a82fa9a2a1aa24a7a760691b604482015290519081900360640190fd5b600490565b6060816001600160a01b031663eeb728666040518163ffffffff1660e01b815260040160006040518083038186803b158015610b6057600080fd5b505afa158015610b74573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526020811015610b9d57600080fd5b8101908080516040519392919084600160201b821115610bbc57600080fd5b908301906020820185811115610bd157600080fd5b8251600160201b811182820188101715610bea57600080fd5b82525081516020918201929091019080838360005b83811015610c17578181015183820152602001610bff565b50505050905090810190601f168015610c445780820380516001836020036101000a031916815260200191505b5060405250505090506000610c58846111ee565b6040516020018082805190602001908083835b60208310610c8a5780518252601f199092019160209182019101610c6b565b6001836020036101000a038019825116818451168082178552505050505050905001915050604051602081830303815290604052805190602001209050816040516020018082805190602001908083835b60208310610cfa5780518252601f199092019160209182019101610cdb565b6001836020036101000a038019825116818451168082178552505050505050905001915050604051602081830303815290604052805190602001208114610d725760405162461bcd60e51b81526004018080602001828103825260228152602001806113606022913960400191505060405180910390fd5b50505050565b6000918252601e602052604090912080546001600160a01b0319166001600160a01b03909216919091179055565b610db8826001600160a01b0316611308565b610dfa576040805162461bcd60e51b815260206004820152600e60248201526d1393d517d057d0d3d395149050d560921b604482015290519081900360640190fd5b8251811115610e44576040805162461bcd60e51b8152602060048201526011602482015270494e56414c49445f444154415f53495a4560781b604482015290519081900360640190fd5b60608167ffffffffffffffff81118015610e5d57600080fd5b506040519080825280601f01601f191660200182016040528015610e88576020820181803683370190505b5084519091508290036020818101918601810190830160005b85811015610eb9578281015182820152602001610ea1565b5060006060876001600160a01b031663439fab9160e01b876040516024018080602001828103825283818151815260200191508051906020019080838360005b83811015610f11578181015183820152602001610ef9565b50505050905090810190601f168015610f3e5780820380516001836020036101000a031916815260200191505b5060408051601f198184030181529181526020820180516001600160e01b03166001600160e01b0319909716969096178652518151919590945084935091508083835b60208310610fa05780518252601f199092019160209182019101610f81565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855af49150503d8060008114611000576040519150601f19603f3d011682016040523d82523d6000602084013e611005565b606091505b50915091508181906110585760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315610651578181015183820152602001610639565b5080518190156110a95760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315610651578181015183820152602001610639565b50505050505050505050565b60408051808201909152601681527512539255125053125690551253d397d09313d0d2d15160521b6020820152680100000000000000035481901561113b5760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315610651578181015183820152602001610639565b5068010000000000000001548190156111955760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315610651578181015183820152602001610639565b50600160401b548190156111ea5760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315610651578181015183820152602001610639565b5050565b60608160011415611233575060408051808201909152601d81527f537461726b576172655f416c6c5665726966696572735f323032305f31000000602082015261035d565b816002141561125c576040518060600160405280602a8152602001611336602a9139905061035d565b816003141561129f575060408051808201909152601f81527f537461726b576172655f50657270657475616c53746174655f323032305f3100602082015261035d565b81600414156112c85760405180606001604052806027815260200161130f60279139905061035d565b6040805162461bcd60e51b815260206004820152601060248201526f0aa9c8ab0a08a86a88a88be929c888ab60831b604482015290519081900360640190fd5b3b15159056fe537461726b576172655f50657270657475616c466f72636564416374696f6e735f323032305f31537461726b576172655f50657270657475616c546f6b656e73416e6452616d70696e675f323032305f314d4953504c414345445f494e4445585f4f525f4241445f434f4e54524143545f4944a264697066735822122005e8b7a15f93acce17b8b75a4d4bdf04a6a2220b908849ea3e41588be7e3760e64736f6c634300060b0033

Deployed Bytecode

0x60806040526004361061004e5760003560e01c8063439fab9114610133578063adac3e15146101e6578063c1a851301461020d578063f2011f6614610222578063ffa1ad741461024c576100a0565b366100a0576040805162461bcd60e51b815260206004820181905260248201527f434f4e54524143545f4e4f545f45585045435445445f544f5f52454345495645604482015290519081900360640190fd5b60006100b76000356001600160e01b0319166102d6565b90506001600160a01b03811661010f576040805162461bcd60e51b81526020600482015260186024820152772727afa1a7a72a2920a1aa2fa327a92fa32aa721aa24a7a760411b604482015290519081900360640190fd5b3660008037600080366000845af43d6000803e80801561012e573d6000f35b3d6000fd5b34801561013f57600080fd5b506101e46004803603602081101561015657600080fd5b810190602081018135600160201b81111561017057600080fd5b82018360208201111561018257600080fd5b803590602001918460018302840111600160201b831117156101a357600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550610362945050505050565b005b3480156101f257600080fd5b506101fb6109cb565b60408051918252519081900360200190f35b34801561021957600080fd5b506101fb6109d9565b34801561022e57600080fd5b506101fb6004803603602081101561024557600080fd5b50356109e7565b34801561025857600080fd5b50610261610a01565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561029b578181015183820152602001610283565b50505050905090810190601f1680156102c85780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b600080826102e2610a22565b604080516001600160e01b03199093166020808501919091526024808501939093528151808503909301835260449093019052805191012060ff169050600080610100600484020690508061033a600685901c610a28565b600f911c166000908152601e60205260409020546001600160a01b031693505050505b919050565b7fa8be027c40582873fe725a541de3bd3b732b003dc1a1a6df763248c6df60208d80549081156103d2576040805162461bcd60e51b81526020600482015260166024820152751112549150d517d0d0531317d11254d0531313d5d15160521b604482015290519081900360640190fd5b505060006103de610b20565b9050600f81111561042f576040805162461bcd60e51b8152602060048201526016602482015275544f4f5f4d414e595f5355425f434f4e54524143545360501b604482015290519081900360640190fd5b806001016020028251101561048b576040805162461bcd60e51b815260206004820152601a60248201527f5355425f434f4e5452414354535f4e4f545f50524f5649444544000000000000604482015290519081900360640190fd5b8151600182810160200291829003916000915b8481116104c957602081028601516104b68282610b25565b6104c08282610d78565b5060010161049e565b50602060018501028501516001600160a01b038116156104f8576104ee868286610da6565b50505050506109c8565b836105075750505050506109c8565b6001600160a01b0381161561051857fe5b6105206110b5565b60015b85811161096d576020808202880151604080516004815260248101825292830180516001600160e01b0316633cc660ad60e01b1781529051835192936000936060936001600160a01b03871693918291908083835b602083106105975780518252601f199092019160209182019101610578565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855af49150503d80600081146105f7576040519150601f19603f3d011682016040523d82523d6000602084013e6105fc565b606091505b509150915081819061068c5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610651578181015183820152602001610639565b50505050905090810190601f16801561067e5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008180602001905160208110156106a457600080fd5b50519050888111156106f8576040805162461bcd60e51b8152602060048201526018602482015277494e56414c49445f494e495449414c495a45525f53495a4560401b604482015290519081900360640190fd5b88818901111561074a576040805162461bcd60e51b8152602060048201526018602482015277494e56414c49445f494e495449414c495a45525f53495a4560401b604482015290519081900360640190fd5b806107585750505050610965565b60608167ffffffffffffffff8111801561077157600080fd5b506040519080825280601f01601f19166020018201604052801561079c576020820181803683370190505b50905060205b8281116107bb578c8101890151828201526020016107a2565b506040516020602482018181528351604484015283516001600160a01b0389169363439fab9160e01b9386939283926064019185019080838360005b8381101561080f5781810151838201526020016107f7565b50505050905090810190601f16801561083c5780820380516001836020036101000a031916815260200191505b5060408051601f198184030181529181526020820180516001600160e01b03166001600160e01b0319909716969096178652518151919590945084935091508083835b6020831061089e5780518252601f19909201916020918201910161087f565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855af49150503d80600081146108fe576040519150601f19603f3d011682016040523d82523d6000602084013e610903565b606091505b50909450925082846109565760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315610651578181015183820152602001610639565b50509687019695909501945050505b600101610523565b508284146109c2576040805162461bcd60e51b815260206004820152601a60248201527f4d49534d41544348494e475f494e49545f444154415f53495a45000000000000604482015290519081900360640190fd5b50505050505b50565b680100000000000000015481565b680100000000000000045481565b680100000000000000026020526000908152604090205481565b604051806040016040528060058152602001640312e302e360dc1b81525081565b6160ac90565b600081610a5657507f300010000020300000201000400201200300320001000000122200002100201061035d565b8160011415610a80575079430000014020001000000000100003000030010000022230330261035d565b8160021415610aaf57507e1000130000002020002000022000100202000032000002003110003002001261035d565b8160031415610add57507d12030000200000000000010000000020200100200004010113030200000061035d565b6040805162461bcd60e51b81526020600482015260136024820152722120a22fa4a22c2fa6a0a82fa9a2a1aa24a7a760691b604482015290519081900360640190fd5b600490565b6060816001600160a01b031663eeb728666040518163ffffffff1660e01b815260040160006040518083038186803b158015610b6057600080fd5b505afa158015610b74573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526020811015610b9d57600080fd5b8101908080516040519392919084600160201b821115610bbc57600080fd5b908301906020820185811115610bd157600080fd5b8251600160201b811182820188101715610bea57600080fd5b82525081516020918201929091019080838360005b83811015610c17578181015183820152602001610bff565b50505050905090810190601f168015610c445780820380516001836020036101000a031916815260200191505b5060405250505090506000610c58846111ee565b6040516020018082805190602001908083835b60208310610c8a5780518252601f199092019160209182019101610c6b565b6001836020036101000a038019825116818451168082178552505050505050905001915050604051602081830303815290604052805190602001209050816040516020018082805190602001908083835b60208310610cfa5780518252601f199092019160209182019101610cdb565b6001836020036101000a038019825116818451168082178552505050505050905001915050604051602081830303815290604052805190602001208114610d725760405162461bcd60e51b81526004018080602001828103825260228152602001806113606022913960400191505060405180910390fd5b50505050565b6000918252601e602052604090912080546001600160a01b0319166001600160a01b03909216919091179055565b610db8826001600160a01b0316611308565b610dfa576040805162461bcd60e51b815260206004820152600e60248201526d1393d517d057d0d3d395149050d560921b604482015290519081900360640190fd5b8251811115610e44576040805162461bcd60e51b8152602060048201526011602482015270494e56414c49445f444154415f53495a4560781b604482015290519081900360640190fd5b60608167ffffffffffffffff81118015610e5d57600080fd5b506040519080825280601f01601f191660200182016040528015610e88576020820181803683370190505b5084519091508290036020818101918601810190830160005b85811015610eb9578281015182820152602001610ea1565b5060006060876001600160a01b031663439fab9160e01b876040516024018080602001828103825283818151815260200191508051906020019080838360005b83811015610f11578181015183820152602001610ef9565b50505050905090810190601f168015610f3e5780820380516001836020036101000a031916815260200191505b5060408051601f198184030181529181526020820180516001600160e01b03166001600160e01b0319909716969096178652518151919590945084935091508083835b60208310610fa05780518252601f199092019160209182019101610f81565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855af49150503d8060008114611000576040519150601f19603f3d011682016040523d82523d6000602084013e611005565b606091505b50915091508181906110585760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315610651578181015183820152602001610639565b5080518190156110a95760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315610651578181015183820152602001610639565b50505050505050505050565b60408051808201909152601681527512539255125053125690551253d397d09313d0d2d15160521b6020820152680100000000000000035481901561113b5760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315610651578181015183820152602001610639565b5068010000000000000001548190156111955760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315610651578181015183820152602001610639565b50600160401b548190156111ea5760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315610651578181015183820152602001610639565b5050565b60608160011415611233575060408051808201909152601d81527f537461726b576172655f416c6c5665726966696572735f323032305f31000000602082015261035d565b816002141561125c576040518060600160405280602a8152602001611336602a9139905061035d565b816003141561129f575060408051808201909152601f81527f537461726b576172655f50657270657475616c53746174655f323032305f3100602082015261035d565b81600414156112c85760405180606001604052806027815260200161130f60279139905061035d565b6040805162461bcd60e51b815260206004820152601060248201526f0aa9c8ab0a08a86a88a88be929c888ab60831b604482015290519081900360640190fd5b3b15159056fe537461726b576172655f50657270657475616c466f72636564416374696f6e735f323032305f31537461726b576172655f50657270657475616c546f6b656e73416e6452616d70696e675f323032305f314d4953504c414345445f494e4445585f4f525f4241445f434f4e54524143545f4944a264697066735822122005e8b7a15f93acce17b8b75a4d4bdf04a6a2220b908849ea3e41588be7e3760e64736f6c634300060b0033

Deployed Bytecode Sourcemap

723:2350:11:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1093:42:7;;;-1:-1:-1;;;1093:42:7;;;;;;;;;;;;;;;;;;;;;;;;;;;;723:2350:11;1186:26:7;1215:23;1230:7;;-1:-1:-1;;;;;;1230:7:7;1215:14;:23::i;:::-;1186:52;-1:-1:-1;;;;;;1256:34:7;;1248:71;;;;;-1:-1:-1;;;1248:71:7;;;;;;;;;;;;-1:-1:-1;;;1248:71:7;;;;;;;;;;;;;;;1598:14;1595:1;1592;1579:34;1824:1;1821;1805:14;1802:1;1782:18;1775:5;1762:64;1900:16;1897:1;1894;1879:38;1938:6;2013:74;;;;2144:16;2141:1;2134:27;2013:74;2052:16;2049:1;2042:27;5417:4837;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;5417:4837:7;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;5417:4837:7;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;5417:4837:7;;-1:-1:-1;5417:4837:7;;-1:-1:-1;;;;;5417:4837:7:i;:::-;;1064:38:9;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;1500:33;;;;;;;;;;;;;:::i;1165:52::-;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;1165:52:9;;:::i;789:40:11:-;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1499:488:6;1572:7;1591:16;1652:8;1662:11;:9;:11::i;:::-;1635:39;;;-1:-1:-1;;;;;;1635:39:6;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1625:50;;;;;1610:4;:66;;-1:-1:-1;;;1767:3:6;1635:39;1736:27;;1735:35;1718:52;;1922:6;1886:32;1916:1;1904:8;:13;;1886:17;:32::i;:::-;1932:3;1886:42;;1885:50;1952:28;;;;:12;:28;;;;;;-1:-1:-1;;;;;1952:28:6;;-1:-1:-1;;;;1499:488:6;;;;:::o;5417:4837:7:-;1636:21:0;1716:11;;;1762:19;;1754:54;;;;;-1:-1:-1;;;1754:54:0;;;;;;;;;;;;-1:-1:-1;;;1754:54:0;;;;;;;;;;;;;;;5417:4837:7;;5547:21:::1;5571:20;:18;:20::i;:::-;5547:44;;5715:2;5698:13;:19;;5690:54;;;::::0;;-1:-1:-1;;;5690:54:7;;::::1;;::::0;::::1;::::0;::::1;::::0;;;;-1:-1:-1;;;5690:54:7;;;;;;;;;;;;;::::1;;5857:13;5873:1;5857:17;5851:2;:24;5836:4;:11;:39;;5828:78;;;::::0;;-1:-1:-1;;;5828:78:7;;::::1;;::::0;::::1;::::0;::::1;::::0;;;;::::1;::::0;;;;;;;;;;;;;::::1;;6012:11:::0;;6048:1:::1;6032:17:::0;;::::1;6026:2;:24;6012:38:::0;;;::::1;::::0;5983:26:::1;::::0;6418:473:::1;6459:13;6446:9;:26;6418:473;;6650:2;6646:18:::0;::::1;6636:29:::0;::::1;6630:36:::0;6694:52:::1;6654:9:::0;6630:36;6694:24:::1;:52::i;:::-;6831:49;6853:9;6864:15;6831:21;:49::i;:::-;-1:-1:-1::0;6474:11:7::1;;6418:473;;;-1:-1:-1::0;7166:2:7::1;7189:1;7170:21:::0;::::1;7162:30;7152:41:::0;::::1;7146:48:::0;-1:-1:-1;;;;;7264:39:7;::::1;::::0;7260:164:::1;;7319:74;7343:4;7349:23;7374:18;7319:23;:74::i;:::-;7407:7;;;;;;;7260:164;7552:23:::0;7548:60:::1;;7591:7;;;;;;;7548:60;-1:-1:-1::0;;;;;7665:39:7;::::1;::::0;7658:47:::1;;;;7760:24;:22;:24::i;:::-;7917:1;7892:2246;7933:13;7920:9;:26;7892:2246;;8171:2;8167:18:::0;;::::1;8157:29:::0;::::1;8151:36:::0;8824:79:::1;::::0;;;;;::::1;::::0;::::1;::::0;;;;::::1;::::0;;-1:-1:-1;;;;;8824:79:7::1;-1:-1:-1::0;;;8824:79:7::1;::::0;;8778:126;;;;8151:36;;7975:23:::1;::::0;8751::::1;::::0;-1:-1:-1;;;;;8778:28:7;::::1;::::0;:126;;;8824:79;8778:126;;8824:79;8778:126:::1;;;;;;::::0;;;;-1:-1:-1;;8778:126:7;;;;::::1;::::0;;::::1;::::0;::::1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8736:168;;;;8926:7;8942:10;8918:36;;;;;-1:-1:-1::0;;;8918:36:7::1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;::::0;;::::1;::::0;;;::::1;::::0;::::1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8968:16;8998:10;8987:33;;;;;;;;;;;;::::0;::::1;;-1:-1:-1::0;8987:33:7;;-1:-1:-1;9042:30:7;;::::1;;9034:67;;;::::0;;-1:-1:-1;;;9034:67:7;;::::1;;::::0;::::1;::::0;::::1;::::0;;;;-1:-1:-1;;;9034:67:7;;;;;;;;;;;;;::::1;;9152:18;9140:8;9123:14;:25;:47;;9115:84;;;::::0;;-1:-1:-1;;;9115:84:7;;::::1;;::::0;::::1;::::0;::::1;::::0;;;;-1:-1:-1;;;9115:84:7;;;;;;;;;;;;;::::1;;9218:13:::0;9214:60:::1;;9251:8;;;;;;9214:60;9337:32;9382:8;9372:19;;;;;;;;::::0;::::1;;;;;;;;;;;;;;;;;;;;;;;;;;::::0;::::1;::::0;;::::1;::::0;::::1;;::::0;-1:-1:-1;9372:19:7::1;-1:-1:-1::0;9337:54:7;-1:-1:-1;9430:2:7::1;9405:322;9447:8;9434:9;:21;9405:322;;9626:20:::0;;::::1;9622:50:::0;::::1;9616:57:::0;9555:35;;::::1;9523:172:::0;9470:2:::1;9457:15;9405:322;;;-1:-1:-1::0;9905:69:7::1;::::0;::::1;;::::0;::::1;::::0;;;;;;;;;;;-1:-1:-1;;;;;9859:28:7;::::1;::::0;-1:-1:-1;;;9928:24:7;9954:19;;9905:69;;;;;;;::::1;::::0;;;;;::::1;;;;;;;::::0;;::::1;::::0;;;::::1;::::0;::::1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1::0;9905:69:7::1;::::0;;-1:-1:-1;;9905:69:7;;::::1;::::0;;;;;;::::1;::::0;::::1;::::0;;-1:-1:-1;;;;;9905:69:7::1;-1:-1:-1::0;;;;;;9905:69:7;;::::1;::::0;;;::::1;::::0;;9859:129;;;9905:69;;9859:129;;-1:-1:-1;9859:129:7;;-1:-1:-1;9905:69:7;-1:-1:-1;9859:129:7;;9905:69;9859:129:::1;;;;;;::::0;;;;-1:-1:-1;;9859:129:7;;;;::::1;::::0;;::::1;::::0;::::1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1::0;9835:153:7;;-1:-1:-1;9835:153:7;-1:-1:-1;9835:153:7;;10002:36:::1;;;::::0;-1:-1:-1;;;10002:36:7;;::::1;;::::0;::::1;::::0;;;;;;;;;;;;;;;;;;;;;;::::1;::::0;;;;;;;::::1;;::::0;;::::1;::::0;;;::::1;::::0;::::1;;;;;-1:-1:-1::0;;10052:26:7;;::::1;::::0;10092:35;;;::::1;::::0;-1:-1:-1;;;7892:2246:7::1;7948:11;;7892:2246;;;;10190:14;10168:18;:36;10147:100;;;::::0;;-1:-1:-1;;;10147:100:7;;::::1;;::::0;::::1;::::0;::::1;::::0;;;;::::1;::::0;;;;;;;;;;;;;::::1;;1828:1:0;;;;;;5417:4837:7::0;:::o;1064:38:9:-;;;;:::o;1500:33::-;;;;:::o;1165:52::-;;;;;;;;;;;;;:::o;789:40:11:-;;;;;;;;;;;;;;-1:-1:-1;;;789:40:11;;;;:::o;1592:95::-;1035:5;1592:95;:::o;1693:413::-;1768:7;1790:12;1787:274;;-1:-1:-1;1075:66:11;1818:16;;1787:274;1862:7;1873:1;1862:12;1859:202;;;-1:-1:-1;1176:54:11;1890:16;;1859:202;1934:7;1945:1;1934:12;1931:130;;;-1:-1:-1;1265:64:11;1962:16;;1931:130;2006:7;2017:1;2006:12;2003:58;;;-1:-1:-1;1364:62:11;2034:16;;2003:58;2070:29;;;-1:-1:-1;;;2070:29:11;;;;;;;;;;;;-1:-1:-1;;;2070:29:11;;;;;;;;;;;;;;1490:96;1578:1;1490:96;:::o;1091:402:6:-;1194:16;1227:11;-1:-1:-1;;;;;1213:35:6;;:37;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;1213:37:6;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;1213:37:6;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;1213:37:6;;;;;;-1:-1:-1;1213:37:6;;;;;;;;;;-1:-1:-1;1213:37:6;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1194:56;;1260:26;1316:24;1334:5;1316:17;:24::i;:::-;1299:42;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;1299:42:6;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1289:53;;;;;;1260:82;;1422:2;1405:20;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;1405:20:6;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1395:31;;;;;;1373:18;:53;1352:134;;;;-1:-1:-1;;;1352:134:6;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1091:402;;;;:::o;1993:149::-;2095:19;;;;:12;:19;;;;;;:40;;-1:-1:-1;;;;;;2095:40:6;-1:-1:-1;;;;;2095:40:6;;;;;;;;;1993:149::o;10260:1234:7:-;10422:36;:23;-1:-1:-1;;;;;10422:34:7;;:36::i;:::-;10414:63;;;;;-1:-1:-1;;;10414:63:7;;;;;;;;;;;;-1:-1:-1;;;10414:63:7;;;;;;;;;;;;;;;10507:4;:11;10495:8;:23;;10487:53;;;;;-1:-1:-1;;;10487:53:7;;;;;;;;;;;;-1:-1:-1;;;10487:53:7;;;;;;;;;;;;;;;10550:24;10587:8;10577:19;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;10577:19:7;-1:-1:-1;10672:11:7;;10550:46;;-1:-1:-1;10667:27:7;;;:2;:27;;;;10789:24;;;;;10837:20;;10643:21;10935:228;10965:8;10958:4;:15;10935:228;;;11102:18;;;11096:25;11056:18;;;11028:111;10983:2;10975:10;10935:228;;;;11218:12;11232:23;11259;-1:-1:-1;;;;;11259:36:7;11332:24;;;11358:11;11309:61;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;11309:61:7;;;-1:-1:-1;;11309:61:7;;;;;;;;;;;;;;-1:-1:-1;;;;;11309:61:7;-1:-1:-1;;;;;;11309:61:7;;;;;;;;;11259:121;;;11309:61;;11259:121;;-1:-1:-1;11259:121:7;;-1:-1:-1;11309:61:7;-1:-1:-1;11259:121:7;;11309:61;11259:121;;;;;;;;;;-1:-1:-1;;11259:121:7;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;11217:163;;;;11398:7;11414:10;11390:36;;;;;-1:-1:-1;;;11390:36:7;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;11444:17:7;;:10;;:22;11436:51;;;;-1:-1:-1;;;11436:51:7;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;10260:1234;;;;;;;;;:::o;2638:433:11:-;2705:51;;;;;;;;;;;;-1:-1:-1;;;2705:51:11;;;;2915:15;;2705:51;;2911:25;2903:46;;;;-1:-1:-1;;;2903:46:11;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;2971:23:11;;3002:10;;2967:33;2959:54;;;;-1:-1:-1;;;2959:54:11;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;3031:15:11;3053:10;;3031:20;3023:41;;;;-1:-1:-1;;;3023:41:11;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2638:433;:::o;2112:520::-;2194:16;2226:5;2235:1;2226:10;2222:404;;;-1:-1:-1;2251:36:11;;;;;;;;;;;;;;;;;2222:404;;;2308:5;2317:1;2308:10;2304:322;;;2333:49;;;;;;;;;;;;;;;;;;;2304:322;;;2403:5;2412:1;2403:10;2399:227;;;-1:-1:-1;2428:38:11;;;;;;;;;;;;;;;;;2399:227;;;2487:5;2496:1;2487:10;2483:143;;;2512:46;;;;;;;;;;;;;;;;;;;2483:143;;;2589:26;;;-1:-1:-1;;;2589:26:11;;;;;;;;;;;;-1:-1:-1;;;2589:26:11;;;;;;;;;;;;;;757:190:1;886:20;932:8;;;757:190::o

Swarm Source

ipfs://05e8b7a15f93acce17b8b75a4d4bdf04a6a2220b908849ea3e41588be7e3760e

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

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading
[ 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.