ETH Price: $2,496.98 (+1.69%)

Contract

0xf86FD6735f88d5b6aa709B357AD5Be22CEDf1A05
 
Transaction Hash
Method
Block
From
To
Commit Block205516242024-08-17 23:27:5915 days ago1723937279IN
Layer2Finance: Rollup Chain
0 ETH0.0013288210.70485748
Execute Block205451962024-08-17 1:54:5916 days ago1723859699IN
Layer2Finance: Rollup Chain
0 ETH0.0005911910.80573863
Sync Balance205449352024-08-17 1:02:2316 days ago1723856543IN
Layer2Finance: Rollup Chain
0 ETH0.0013613210.92495948
Sync Balance205448322024-08-17 0:41:2316 days ago1723855283IN
Layer2Finance: Rollup Chain
0 ETH0.0013592310.91008832
Sync Balance205447372024-08-17 0:22:2316 days ago1723854143IN
Layer2Finance: Rollup Chain
0 ETH0.0013589810.90616303
Commit Block205446442024-08-17 0:03:2316 days ago1723853003IN
Layer2Finance: Rollup Chain
0 ETH0.0010890211.05664016
Sync Balance205446342024-08-17 0:01:2316 days ago1723852883IN
Layer2Finance: Rollup Chain
0 ETH0.0014018911.25051323
Execute Block205062202024-08-11 15:19:2321 days ago1723389563IN
Layer2Finance: Rollup Chain
0 ETH0.0014936112.10891919
Commit Block205057662024-08-11 13:48:2322 days ago1723384103IN
Layer2Finance: Rollup Chain
0 ETH0.0023663311.94513339
Sync Balance205048652024-08-11 10:46:2322 days ago1723373183IN
Layer2Finance: Rollup Chain
0 ETH0.0015316910.94664545
Execute Block205047752024-08-11 10:28:2322 days ago1723372103IN
Layer2Finance: Rollup Chain
0 ETH0.0005981910.93379216
Sync Balance205047652024-08-11 10:26:2322 days ago1723371983IN
Layer2Finance: Rollup Chain
0 ETH0.0015435511.03135683
Sync Balance205047152024-08-11 10:16:2322 days ago1723371383IN
Layer2Finance: Rollup Chain
0 ETH0.0015280810.92470357
Sync Balance205046652024-08-11 10:06:2322 days ago1723370783IN
Layer2Finance: Rollup Chain
0 ETH0.0018349311.11049008
Sync Balance205046152024-08-11 9:56:2322 days ago1723370183IN
Layer2Finance: Rollup Chain
0 ETH0.0018713710.93294795
Sync Balance205045652024-08-11 9:46:2322 days ago1723369583IN
Layer2Finance: Rollup Chain
0 ETH0.0017999811.05136691
Sync Balance205044622024-08-11 9:25:2322 days ago1723368323IN
Layer2Finance: Rollup Chain
0 ETH0.0013931411.18033415
Sync Balance205044122024-08-11 9:15:2322 days ago1723367723IN
Layer2Finance: Rollup Chain
0 ETH0.0013784811.06457886
Sync Balance205043672024-08-11 9:06:2322 days ago1723367183IN
Layer2Finance: Rollup Chain
0 ETH0.0013709811.0024915
Commit Block205043222024-08-11 8:57:2322 days ago1723366643IN
Layer2Finance: Rollup Chain
0 ETH0.0010896211.06003576
Sync Balance205043132024-08-11 8:55:2322 days ago1723366523IN
Layer2Finance: Rollup Chain
0 ETH0.0013790211.06701336
Withdraw204735952024-08-07 2:05:3526 days ago1722996335IN
Layer2Finance: Rollup Chain
0 ETH0.000086561.28211009
Withdraw204735872024-08-07 2:03:5926 days ago1722996239IN
Layer2Finance: Rollup Chain
0 ETH0.000179072.11625851
Execute Block204644102024-08-05 19:19:2327 days ago1722885563IN
Layer2Finance: Rollup Chain
0 ETH0.0140805718.52261819
Execute Block204639972024-08-05 17:56:2327 days ago1722880583IN
Layer2Finance: Rollup Chain
0 ETH0.0010501919.19524168
View all transactions

Latest 6 internal transactions

Advanced mode:
Parent Transaction Hash Block From To
122922312021-04-22 20:42:481228 days ago1619124168
Layer2Finance: Rollup Chain
0.1 ETH
122922312021-04-22 20:42:481228 days ago1619124168
Layer2Finance: Rollup Chain
0.1 ETH
122921242021-04-22 20:17:211228 days ago1619122641
Layer2Finance: Rollup Chain
1.000003 ETH
122921242021-04-22 20:17:211228 days ago1619122641
Layer2Finance: Rollup Chain
1.000003 ETH
122855022021-04-21 19:43:581229 days ago1619034238
Layer2Finance: Rollup Chain
1 ETH
122852562021-04-21 18:52:491229 days ago1619031169
Layer2Finance: Rollup Chain
0.1 ETH
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
RollupChain

Compiler Version
v0.7.6+commit.7338295f

Optimization Enabled:
Yes with 800 runs

Other Settings:
default evmVersion, MIT license
File 1 of 17 : RollupChain.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;
pragma experimental ABIEncoderV2;

import "@openzeppelin/contracts/math/SafeMath.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/Pausable.sol";

/* Internal Imports */
import {DataTypes as dt} from "./libraries/DataTypes.sol";
import "./TransitionDisputer.sol";
import "./Registry.sol";
import "./strategies/interfaces/IStrategy.sol";
import "./libraries/MerkleTree.sol";
import "./libraries/Transitions.sol";
import "./interfaces/IWETH.sol";

contract RollupChain is Ownable, Pausable {
    using SafeMath for uint256;
    using SafeERC20 for IERC20;

    /* Fields */
    // The state transition disputer
    TransitionDisputer transitionDisputer;
    // Asset and strategy registry
    Registry registry;

    // All the blocks (prepared and/or executed).
    dt.Block[] public blocks;
    uint256 public countExecuted = 0;

    // Track pending deposits roundtrip status across L1->L2->L1.
    // Each deposit record ID is a count++ (i.e. it's a queue).
    // - L1 deposit() creates it in "pending" status
    // - commitBlock() moves it to "done" status
    // - fraudulent block moves it back to "pending" status
    // - executeBlock() deletes it
    enum PendingDepositStatus {Pending, Done}
    struct PendingDeposit {
        bytes32 dhash; // keccak256(abi.encodePacked(account, assetId, amount))
        uint64 blockId; // rollup block; "pending": baseline of censorship, "done": block holding L2 transition
        PendingDepositStatus status;
    }
    mapping(uint256 => PendingDeposit) public pendingDeposits;
    uint256 public pendingDepositsExecuteHead; // moves up inside blockExecute() -- lowest
    uint256 public pendingDepositsCommitHead; // moves up inside blockCommit() -- intermediate
    uint256 public pendingDepositsTail; // moves up inside L1 deposit() -- highest

    // Track pending withdraws arriving from L2 then done on L1 across 2 phases.
    // A separate mapping is used for each phase:
    // (1) pendingWithdrawCommits: commitBlock() --> executeBlock(), per blockId
    // (2) pendingWithdraws: executeBlock() --> L1-withdraw, per user account address
    //
    // - commitBlock() creates pendingWithdrawCommits entries for the blockId.
    // - executeBlock() aggregates them into per-account pendingWithdraws entries and
    //   deletes the pendingWithdrawCommits entries.
    // - fraudulent block deletes the pendingWithdrawCommits during the blockId rollback.
    // - L1 withdraw() gives the funds and deletes the account's pendingWithdraws entries.
    struct PendingWithdrawCommit {
        address account;
        uint32 assetId;
        uint256 amount;
    }
    mapping(uint256 => PendingWithdrawCommit[]) public pendingWithdrawCommits;

    // Mapping of account => assetId => pendingWithdrawAmount
    mapping(address => mapping(uint32 => uint256)) public pendingWithdraws;

    // Track pending L1-to-L2 balance sync roundtrip across L1->L2->L1.
    // Each balance sync record ID is a count++ (i.e. it's a queue).
    // - L1-to-L2 Balance Sync creates in "pending" status
    // - commitBlock() moves it to "done" status
    // - fraudulent block moves it back to "pending" status
    // - executeBlock() deletes it
    enum PendingBalanceSyncStatus {Pending, Done}
    struct PendingBalanceSync {
        bytes32 bhash; // keccak256(abi.encodePacked(strategyId, delta))
        uint64 blockId; // rollup block; "pending": baseline of censorship, "done": block holding L2 transition
        PendingBalanceSyncStatus status;
    }
    mapping(uint256 => PendingBalanceSync) public pendingBalanceSyncs;
    uint256 public pendingBalanceSyncsExecuteHead; // moves up inside blockExecute() -- lowest
    uint256 public pendingBalanceSyncsCommitHead; // moves up inside blockCommit() -- intermediate
    uint256 public pendingBalanceSyncsTail; // moves up inside L1 Balance Sync -- highest

    // Track the asset balances of strategies to compute deltas after syncBalance() calls.
    mapping(uint32 => uint256) public strategyAssetBalances;

    // per-asset (total deposit - total withdrawal) amount
    mapping(address => uint256) public netDeposits;
    // per-asset (total deposit - total withdrawal) limit
    mapping(address => uint256) public netDepositLimits;

    uint256 public blockChallengePeriod; // delay (in # of ETH blocks) to challenge a rollup block
    uint256 public maxPriorityTxDelay; // delay (in # of rollup blocks) to reflect an L1-initiated tx in a rollup block

    address public operator;

    /* Events */
    event RollupBlockCommitted(uint256 blockId);
    event RollupBlockExecuted(uint256 blockId);
    event RollupBlockReverted(uint256 blockId, string reason);
    event BalanceSync(uint32 strategyId, int256 delta, uint256 syncId);
    event AssetDeposited(address account, uint32 assetId, uint256 amount, uint256 depositId);
    event AssetWithdrawn(address account, uint32 assetId, uint256 amount);
    event OperatorChanged(address previousOperator, address newOperator);

    constructor(
        uint256 _blockChallengePeriod,
        uint256 _maxPriorityTxDelay,
        address _transitionDisputerAddress,
        address _registryAddress,
        address _operator
    ) {
        blockChallengePeriod = _blockChallengePeriod;
        maxPriorityTxDelay = _maxPriorityTxDelay;
        transitionDisputer = TransitionDisputer(_transitionDisputerAddress);
        registry = Registry(_registryAddress);
        operator = _operator;
    }

    modifier onlyOperator() {
        require(msg.sender == operator, "caller is not operator");
        _;
    }

    fallback() external payable {}

    receive() external payable {}

    /**********************
     * External Functions *
     **********************/

    /**
     * @notice Deposits ERC20 asset.
     *
     * @param _asset The asset address;
     * @param _amount The amount;
     */
    function deposit(address _asset, uint256 _amount) external whenNotPaused {
        _deposit(_asset, _amount);
        IERC20(_asset).safeTransferFrom(msg.sender, address(this), _amount);
    }

    /**
     * @notice Deposits ETH.
     *
     * @param _amount The amount;
     * @param _weth The address for WETH.
     */
    function depositETH(address _weth, uint256 _amount) external payable whenNotPaused {
        require(msg.value == _amount, "ETH amount mismatch");
        _deposit(_weth, _amount);
        IWETH(_weth).deposit{value: _amount}();
    }

    /**
     * @notice Executes pending withdraw of an asset to an account.
     *
     * @param _account The destination account.
     * @param _asset The asset address;
     */
    function withdraw(address _account, address _asset) external whenNotPaused {
        uint256 amount = _withdraw(_account, _asset);
        IERC20(_asset).safeTransfer(_account, amount);
    }

    /**
     * @notice Executes pending withdraw of ETH to an account.
     *
     * @param _account The destination account.
     * @param _weth The address for WETH.
     */
    function withdrawETH(address _account, address _weth) external whenNotPaused {
        uint256 amount = _withdraw(_account, _weth);
        IWETH(_weth).withdraw(amount);
        (bool sent, ) = _account.call{value: amount}("");
        require(sent, "Failed to withdraw ETH");
    }

    /**
     * @notice Submit a prepared batch as a new rollup block.
     *
     * @param _blockId Rollup block id
     * @param _transitions List of layer-2 transitions
     */
    function commitBlock(uint256 _blockId, bytes[] calldata _transitions) external whenNotPaused onlyOperator {
        require(_blockId == blocks.length, "Wrong block ID");

        bytes32[] memory leafs = new bytes32[](_transitions.length);
        for (uint256 i = 0; i < _transitions.length; i++) {
            leafs[i] = keccak256(_transitions[i]);
        }
        bytes32 root = MerkleTree.getMerkleRoot(leafs);

        // Loop over transition and handle these cases:
        // 1- deposit: update the pending deposit record
        // 2- withdraw: create a pending withdraw-commit record
        // 3- commitment sync: fill the "intents" array for future executeBlock()
        // 4- balance sync: update the pending balance sync record

        uint256[] memory intentIndexes = new uint256[](_transitions.length);
        uint32 numIntents = 0;

        for (uint256 i = 0; i < _transitions.length; i++) {
            uint8 transitionType = Transitions.extractTransitionType(_transitions[i]);
            if (
                transitionType == Transitions.TRANSITION_TYPE_COMMIT ||
                transitionType == Transitions.TRANSITION_TYPE_UNCOMMIT
            ) {
                continue;
            } else if (transitionType == Transitions.TRANSITION_TYPE_SYNC_COMMITMENT) {
                intentIndexes[numIntents++] = i;
            } else if (transitionType == Transitions.TRANSITION_TYPE_DEPOSIT) {
                // Update the pending deposit record.
                dt.DepositTransition memory dp = Transitions.decodeDepositTransition(_transitions[i]);
                uint256 depositId = pendingDepositsCommitHead;
                require(depositId < pendingDepositsTail, "invalid deposit transition, no pending deposits");

                PendingDeposit memory pend = pendingDeposits[depositId];
                bytes32 dhash = keccak256(abi.encodePacked(dp.account, dp.assetId, dp.amount));
                require(pend.dhash == dhash, "invalid deposit transition, mismatch or wrong ordering");

                pendingDeposits[depositId].status = PendingDepositStatus.Done;
                pendingDeposits[depositId].blockId = uint64(_blockId); // "done": block holding the transition
                pendingDepositsCommitHead++;
            } else if (transitionType == Transitions.TRANSITION_TYPE_WITHDRAW) {
                // Append the pending withdraw-commit record for this blockId.
                dt.WithdrawTransition memory wd = Transitions.decodeWithdrawTransition(_transitions[i]);
                pendingWithdrawCommits[_blockId].push(
                    PendingWithdrawCommit({account: wd.account, assetId: wd.assetId, amount: wd.amount})
                );
            } else if (transitionType == Transitions.TRANSITION_TYPE_SYNC_BALANCE) {
                // Update the pending balance sync record.
                dt.BalanceSyncTransition memory bs = Transitions.decodeBalanceSyncTransition(_transitions[i]);
                uint256 syncId = pendingBalanceSyncsCommitHead;
                require(syncId < pendingBalanceSyncsTail, "invalid balance sync transition, no pending balance syncs");

                PendingBalanceSync memory pend = pendingBalanceSyncs[syncId];
                bytes32 bhash = keccak256(abi.encodePacked(bs.strategyId, bs.newAssetDelta));
                require(pend.bhash == bhash, "invalid balance sync transition, mismatch or wrong ordering");

                pendingBalanceSyncs[syncId].status = PendingBalanceSyncStatus.Done;
                pendingBalanceSyncs[syncId].blockId = uint64(_blockId); // "done": block holding the transition
                pendingBalanceSyncsCommitHead++;
            }
        }

        // Compute the intent hash.
        bytes32 intentHash = bytes32(0);
        if (numIntents > 0) {
            bytes32[] memory intents = new bytes32[](numIntents);
            for (uint256 i = 0; i < numIntents; i++) {
                intents[i] = keccak256(_transitions[intentIndexes[i]]);
            }
            intentHash = keccak256(abi.encodePacked(intents));
        }

        dt.Block memory rollupBlock =
            dt.Block({
                rootHash: root,
                intentHash: intentHash,
                blockTime: uint128(block.number),
                blockSize: uint128(_transitions.length)
            });
        blocks.push(rollupBlock);

        emit RollupBlockCommitted(_blockId);
    }

    /**
     * @notice Execute a rollup block after it passes the challenge period.
     * @dev Note: only the "intent" transitions (commitment sync) are given to executeBlock() instead of
     * re-sending the whole rollup block. This includes the case of a rollup block with zero intents.
     *
     * @param _intents List of CommitmentSync transitions of the rollup block
     */
    function executeBlock(bytes[] calldata _intents) external whenNotPaused {
        uint256 blockId = countExecuted;
        require(blockId < blocks.length, "No blocks pending execution");
        require(blocks[blockId].blockTime + blockChallengePeriod < block.number, "Block still in challenge period");

        // Validate the input intent transitions.
        bytes32 intentHash = bytes32(0);
        if (_intents.length > 0) {
            bytes32[] memory hashes = new bytes32[](_intents.length);
            for (uint256 i = 0; i < _intents.length; i++) {
                hashes[i] = keccak256(_intents[i]);
            }

            intentHash = keccak256(abi.encodePacked(hashes));
        }

        require(intentHash == blocks[blockId].intentHash, "Invalid block intent transitions");

        // Decode the intent transitions and execute the strategy updates.
        for (uint256 i = 0; i < _intents.length; i++) {
            dt.CommitmentSyncTransition memory cs = Transitions.decodeCommitmentSyncTransition(_intents[i]);

            address stAddr = registry.strategyIndexToAddress(cs.strategyId);
            require(stAddr != address(0), "Unknown strategy ID");
            IStrategy strategy = IStrategy(stAddr);

            if (cs.pendingCommitAmount > cs.pendingUncommitAmount) {
                uint256 commitAmount = cs.pendingCommitAmount.sub(cs.pendingUncommitAmount);
                IERC20(strategy.getAssetAddress()).safeIncreaseAllowance(stAddr, commitAmount);
                strategy.aggregateCommit(commitAmount);
                strategyAssetBalances[cs.strategyId] = strategyAssetBalances[cs.strategyId].add(commitAmount);
            } else if (cs.pendingCommitAmount < cs.pendingUncommitAmount) {
                uint256 uncommitAmount = cs.pendingUncommitAmount.sub(cs.pendingCommitAmount);
                strategy.aggregateUncommit(uncommitAmount);
                strategyAssetBalances[cs.strategyId] = strategyAssetBalances[cs.strategyId].sub(uncommitAmount);
            }
        }

        countExecuted++;

        // Delete pending deposit records finalized by this block.
        while (pendingDepositsExecuteHead < pendingDepositsCommitHead) {
            PendingDeposit memory pend = pendingDeposits[pendingDepositsExecuteHead];
            if (pend.status != PendingDepositStatus.Done || pend.blockId > blockId) {
                break;
            }
            delete pendingDeposits[pendingDepositsExecuteHead];
            pendingDepositsExecuteHead++;
        }

        // Aggregate the pending withdraw-commit records for this blockId into the final
        // pending withdraw records per account (for later L1 withdraw), and delete them.
        for (uint256 i = 0; i < pendingWithdrawCommits[blockId].length; i++) {
            PendingWithdrawCommit memory pwc = pendingWithdrawCommits[blockId][i];

            // Find and increment this account's assetId total amount
            pendingWithdraws[pwc.account][pwc.assetId] += pwc.amount;
        }

        delete pendingWithdrawCommits[blockId];

        // Delete pending balance sync records finalized by this block.
        while (pendingBalanceSyncsExecuteHead < pendingBalanceSyncsCommitHead) {
            PendingBalanceSync memory pend = pendingBalanceSyncs[pendingBalanceSyncsExecuteHead];
            if (pend.status != PendingBalanceSyncStatus.Done || pend.blockId > blockId) {
                break;
            }
            delete pendingBalanceSyncs[pendingBalanceSyncsExecuteHead];
            pendingBalanceSyncsExecuteHead++;
        }

        emit RollupBlockExecuted(blockId);
    }

    /**
     * @notice Sync the latest L1 strategy asset balance to L2
     * @dev L2 operator will submit BalanceSync transition based on the emitted event
     *
     * @param _strategyId Strategy id
     */
    function syncBalance(uint32 _strategyId) external whenNotPaused onlyOperator {
        address stAddr = registry.strategyIndexToAddress(_strategyId);
        require(stAddr != address(0), "Unknown strategy ID");

        uint256 newBalance = IStrategy(stAddr).syncBalance();
        uint256 oldBalance = strategyAssetBalances[_strategyId];
        int256 delta;
        if (newBalance >= oldBalance) {
            delta = int256(newBalance.sub(oldBalance));
        } else {
            delta = -int256(oldBalance.sub(newBalance));
        }
        strategyAssetBalances[_strategyId] = newBalance;

        // Add a pending balance sync record.
        uint256 syncId = pendingBalanceSyncsTail++;
        bytes32 bhash = keccak256(abi.encodePacked(_strategyId, delta));
        pendingBalanceSyncs[syncId] = PendingBalanceSync({
            bhash: bhash,
            blockId: uint64(blocks.length), // "pending": baseline of censorship delay
            status: PendingBalanceSyncStatus.Pending
        });

        emit BalanceSync(_strategyId, delta, syncId);
    }

    /**
     * @notice Dispute a transition in a block.
     * @dev Provide the transition proofs of the previous (valid) transition
     * and the disputed transition, the account proof, and the strategy proof. Both the account proof and
     * strategy proof are always needed even if the disputed transition only updates the account or only
     * updates the strategy because the transition stateRoot = hash(accountStateRoot, strategyStateRoot).
     * If the transition is invalid, prune the chain from that invalid block.
     *
     * @param _prevTransitionProof The inclusion proof of the transition immediately before the fraudulent transition.
     * @param _invalidTransitionProof The inclusion proof of the fraudulent transition.
     * @param _accountProof The inclusion proof of the account involved.
     * @param _strategyProof The inclusion proof of the strategy involved.
     */
    function disputeTransition(
        dt.TransitionProof calldata _prevTransitionProof,
        dt.TransitionProof calldata _invalidTransitionProof,
        dt.AccountProof calldata _accountProof,
        dt.StrategyProof calldata _strategyProof
    ) external {
        uint256 invalidTransitionBlockId = _invalidTransitionProof.blockId;
        dt.Block memory invalidTransitionBlock = blocks[invalidTransitionBlockId];
        require(
            invalidTransitionBlock.blockTime + blockChallengePeriod > block.number,
            "Block challenge period is over"
        );

        bool success;
        bytes memory returnData;
        (success, returnData) = address(transitionDisputer).call(
            abi.encodeWithSelector(
                transitionDisputer.disputeTransition.selector,
                _prevTransitionProof,
                _invalidTransitionProof,
                _accountProof,
                _strategyProof,
                blocks[_prevTransitionProof.blockId],
                invalidTransitionBlock,
                registry
            )
        );

        if (success) {
            string memory reason = abi.decode((returnData), (string));
            _revertBlock(invalidTransitionBlockId, reason);
        } else {
            revert("Failed to dispute");
        }
    }

    /**
     * @notice Dispute if operator failed to reflect an L1-initiated priority tx
     * in a rollup block within the maxPriorityTxDelay
     */
    function disputePriorityTxDelay() external {
        uint256 currentBlockId = getCurrentBlockId();

        if (pendingDepositsCommitHead < pendingDepositsTail) {
            if (currentBlockId.sub(pendingDeposits[pendingDepositsCommitHead].blockId) > maxPriorityTxDelay) {
                _pause();
                return;
            }
        }

        if (pendingBalanceSyncsCommitHead < pendingBalanceSyncsTail) {
            if (currentBlockId.sub(pendingBalanceSyncs[pendingBalanceSyncsCommitHead].blockId) > maxPriorityTxDelay) {
                _pause();
                return;
            }
        }
        revert("Not exceed max priority tx delay");
    }

    /**
     * @notice Called by the owner to pause contract
     * @dev emergency use only
     */
    function pause() external onlyOwner {
        _pause();
    }

    /**
     * @notice Called by the owner to unpause contract
     * @dev emergency use only
     */
    function unpause() external onlyOwner {
        _unpause();
    }

    /**
     * @notice Owner drains one type of tokens when the contract is paused
     * @dev emergency use only
     *
     * @param _asset drained asset address
     * @param _amount drained asset amount
     */
    function drainToken(address _asset, uint256 _amount) external whenPaused onlyOwner {
        IERC20(_asset).safeTransfer(msg.sender, _amount);
    }

    /**
     * @notice Owner drains ETH when the contract is paused
     * @dev This is for emergency situations.
     *
     * @param _amount drained ETH amount
     */
    function drainETH(uint256 _amount) external whenPaused onlyOwner {
        (bool sent, ) = msg.sender.call{value: _amount}("");
        require(sent, "Failed to drain ETH");
    }

    /**
     * @notice Called by the owner to set blockChallengePeriod
     * @param _blockChallengePeriod delay (in # of ETH blocks) to challenge a rollup block
     */
    function setBlockChallengePeriod(uint256 _blockChallengePeriod) external onlyOwner {
        blockChallengePeriod = _blockChallengePeriod;
    }

    /**
     * @notice Called by the owner to set maxPriorityTxDelay
     * @param _maxPriorityTxDelay delay (in # of rollup blocks) to reflect an L1-initiated tx in a rollup block
     */
    function setMaxPriorityTxDelay(uint256 _maxPriorityTxDelay) external onlyOwner {
        maxPriorityTxDelay = _maxPriorityTxDelay;
    }

    /**
     * @notice Called by the owner to set operator account address
     * @param _operator operator's ETH address
     */
    function setOperator(address _operator) external onlyOwner {
        emit OperatorChanged(operator, _operator);
        operator = _operator;
    }

    /**
     * @notice Called by the owner to set net deposit limit
     * @param _asset asset token address
     * @param _limit asset net deposit limit amount
     */
    function setNetDepositLimit(address _asset, uint256 _limit) external onlyOwner {
        uint32 assetId = registry.assetAddressToIndex(_asset);
        require(assetId != 0, "Unknown asset");
        netDepositLimits[_asset] = _limit;
    }

    /**
     * @notice Get current rollup block id
     * @return current rollup block id
     */
    function getCurrentBlockId() public view returns (uint256) {
        return blocks.length - 1;
    }

    /*********************
     * Private Functions *
     *********************/

    /**
     * @notice internal deposit processing without actual token transfer.
     *
     * @param _asset The asset token address.
     * @param _amount The asset token amount.
     */
    function _deposit(address _asset, uint256 _amount) private {
        address account = msg.sender;
        uint32 assetId = registry.assetAddressToIndex(_asset);

        require(assetId != 0, "Unknown asset");

        uint256 netDeposit = netDeposits[_asset].add(_amount);
        require(netDeposit <= netDepositLimits[_asset], "net deposit exceeds limit");
        netDeposits[_asset] = netDeposit;

        // Add a pending deposit record.
        uint256 depositId = pendingDepositsTail++;
        bytes32 dhash = keccak256(abi.encodePacked(account, assetId, _amount));
        pendingDeposits[depositId] = PendingDeposit({
            dhash: dhash,
            blockId: uint64(blocks.length), // "pending": baseline of censorship delay
            status: PendingDepositStatus.Pending
        });

        emit AssetDeposited(account, assetId, _amount, depositId);
    }

    /**
     * @notice internal withdrawal processing without actual token transfer.
     *
     * @param _account The destination account.
     * @param _asset The asset token address.
     * @return amount to withdraw
     */
    function _withdraw(address _account, address _asset) private returns (uint256) {
        uint32 assetId = registry.assetAddressToIndex(_asset);
        require(assetId > 0, "Asset not registered");

        uint256 amount = pendingWithdraws[_account][assetId];
        require(amount > 0, "Nothing to withdraw");

        if (netDeposits[_asset] < amount) {
            netDeposits[_asset] = 0;
        } else {
            netDeposits[_asset] = netDeposits[_asset].sub(amount);
        }
        pendingWithdraws[_account][assetId] = 0;

        emit AssetWithdrawn(_account, assetId, amount);
        return amount;
    }

    /**
     * @notice Revert rollup block on dispute success
     *
     * @param _blockId Rollup block id
     * @param _reason Revert reason
     */
    function _revertBlock(uint256 _blockId, string memory _reason) private {
        // pause contract
        _pause();

        // revert blocks and pending states
        while (blocks.length > _blockId) {
            pendingWithdrawCommits[blocks.length - 1];
            blocks.pop();
        }
        bool first;
        for (uint256 i = pendingDepositsExecuteHead; i < pendingDepositsTail; i++) {
            if (pendingDeposits[i].blockId >= _blockId) {
                if (!first) {
                    pendingDepositsCommitHead = i;
                    first = true;
                }
                pendingDeposits[i].blockId = uint64(_blockId);
                pendingDeposits[i].status = PendingDepositStatus.Pending;
            }
        }
        first = false;
        for (uint256 i = pendingBalanceSyncsExecuteHead; i < pendingBalanceSyncsTail; i++) {
            if (pendingBalanceSyncs[i].blockId >= _blockId) {
                if (!first) {
                    pendingBalanceSyncsCommitHead = i;
                    first = true;
                }
                pendingBalanceSyncs[i].blockId = uint64(_blockId);
                pendingBalanceSyncs[i].status = PendingBalanceSyncStatus.Pending;
            }
        }

        emit RollupBlockReverted(_blockId, _reason);
    }
}

File 2 of 17 : Ownable.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

import "../utils/Context.sol";
/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract Ownable is Context {
    address private _owner;

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor () internal {
        address msgSender = _msgSender();
        _owner = msgSender;
        emit OwnershipTransferred(address(0), msgSender);
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
        _;
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        emit OwnershipTransferred(_owner, address(0));
        _owner = address(0);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        emit OwnershipTransferred(_owner, newOwner);
        _owner = newOwner;
    }
}

File 3 of 17 : ECDSA.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

/**
 * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
 *
 * These functions can be used to verify that a message was signed by the holder
 * of the private keys of a given address.
 */
library ECDSA {
    /**
     * @dev Returns the address that signed a hashed message (`hash`) with
     * `signature`. This address can then be used for verification purposes.
     *
     * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
     * this function rejects them by requiring the `s` value to be in the lower
     * half order, and the `v` value to be either 27 or 28.
     *
     * IMPORTANT: `hash` _must_ be the result of a hash operation for the
     * verification to be secure: it is possible to craft signatures that
     * recover to arbitrary addresses for non-hashed data. A safe way to ensure
     * this is by receiving a hash of the original message (which may otherwise
     * be too long), and then calling {toEthSignedMessageHash} on it.
     */
    function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
        // Check the signature length
        if (signature.length != 65) {
            revert("ECDSA: invalid signature length");
        }

        // Divide the signature in r, s and v variables
        bytes32 r;
        bytes32 s;
        uint8 v;

        // ecrecover takes the signature parameters, and the only way to get them
        // currently is to use assembly.
        // solhint-disable-next-line no-inline-assembly
        assembly {
            r := mload(add(signature, 0x20))
            s := mload(add(signature, 0x40))
            v := byte(0, mload(add(signature, 0x60)))
        }

        return recover(hash, v, r, s);
    }

    /**
     * @dev Overload of {ECDSA-recover-bytes32-bytes-} that receives the `v`,
     * `r` and `s` signature fields separately.
     */
    function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) {
        // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
        // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
        // the valid range for s in (281): 0 < s < secp256k1n ÷ 2 + 1, and for v in (282): v ∈ {27, 28}. Most
        // signatures from current libraries generate a unique signature with an s-value in the lower half order.
        //
        // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
        // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
        // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
        // these malleable signatures as well.
        require(uint256(s) <= 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0, "ECDSA: invalid signature 's' value");
        require(v == 27 || v == 28, "ECDSA: invalid signature 'v' value");

        // If the signature is valid (and not malleable), return the signer address
        address signer = ecrecover(hash, v, r, s);
        require(signer != address(0), "ECDSA: invalid signature");

        return signer;
    }

    /**
     * @dev Returns an Ethereum Signed Message, created from a `hash`. This
     * replicates the behavior of the
     * https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_sign[`eth_sign`]
     * JSON-RPC method.
     *
     * See {recover}.
     */
    function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {
        // 32 is the length in bytes of hash,
        // enforced by the type signature above
        return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash));
    }
}

File 4 of 17 : SafeMath.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

/**
 * @dev Wrappers over Solidity's arithmetic operations with added overflow
 * checks.
 *
 * Arithmetic operations in Solidity wrap on overflow. This can easily result
 * in bugs, because programmers usually assume that an overflow raises an
 * error, which is the standard behavior in high level programming languages.
 * `SafeMath` restores this intuition by reverting the transaction when an
 * operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 */
library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        uint256 c = a + b;
        if (c < a) return (false, 0);
        return (true, c);
    }

    /**
     * @dev Returns the substraction of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        if (b > a) return (false, 0);
        return (true, a - b);
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
        // benefit is lost if 'b' is also tested.
        // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
        if (a == 0) return (true, 0);
        uint256 c = a * b;
        if (c / a != b) return (false, 0);
        return (true, c);
    }

    /**
     * @dev Returns the division of two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        if (b == 0) return (false, 0);
        return (true, a / b);
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        if (b == 0) return (false, 0);
        return (true, a % b);
    }

    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     *
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a, "SafeMath: addition overflow");
        return c;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        require(b <= a, "SafeMath: subtraction overflow");
        return a - b;
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     *
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        if (a == 0) return 0;
        uint256 c = a * b;
        require(c / a == b, "SafeMath: multiplication overflow");
        return c;
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        require(b > 0, "SafeMath: division by zero");
        return a / b;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        require(b > 0, "SafeMath: modulo by zero");
        return a % b;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {trySub}.
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b <= a, errorMessage);
        return a - b;
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryDiv}.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b > 0, errorMessage);
        return a / b;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting with custom message when dividing by zero.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryMod}.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b > 0, errorMessage);
        return a % b;
    }
}

File 5 of 17 : IERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the amount of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves `amount` tokens from the caller's account to `recipient`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address recipient, uint256 amount) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 amount) external returns (bool);

    /**
     * @dev Moves `amount` tokens from `sender` to `recipient` using the
     * allowance mechanism. `amount` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);

    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);
}

File 6 of 17 : SafeERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

import "./IERC20.sol";
import "../../math/SafeMath.sol";
import "../../utils/Address.sol";

/**
 * @title SafeERC20
 * @dev Wrappers around ERC20 operations that throw on failure (when the token
 * contract returns false). Tokens that return no value (and instead revert or
 * throw on failure) are also supported, non-reverting calls are assumed to be
 * successful.
 * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
 * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
 */
library SafeERC20 {
    using SafeMath for uint256;
    using Address for address;

    function safeTransfer(IERC20 token, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
    }

    function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
    }

    /**
     * @dev Deprecated. This function has issues similar to the ones found in
     * {IERC20-approve}, and its usage is discouraged.
     *
     * Whenever possible, use {safeIncreaseAllowance} and
     * {safeDecreaseAllowance} instead.
     */
    function safeApprove(IERC20 token, address spender, uint256 value) internal {
        // safeApprove should only be called when setting an initial allowance,
        // or when resetting it to zero. To increase and decrease it, use
        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
        // solhint-disable-next-line max-line-length
        require((value == 0) || (token.allowance(address(this), spender) == 0),
            "SafeERC20: approve from non-zero to non-zero allowance"
        );
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
    }

    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 newAllowance = token.allowance(address(this), spender).add(value);
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

    function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero");
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     */
    function _callOptionalReturn(IERC20 token, bytes memory data) private {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
        // the target address contains contract code and also asserts for success in the low-level call.

        bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
        if (returndata.length > 0) { // Return data is optional
            // solhint-disable-next-line max-line-length
            require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
        }
    }
}

File 7 of 17 : Address.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.2 <0.8.0;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @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;
        // solhint-disable-next-line no-inline-assembly
        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");

        // solhint-disable-next-line avoid-low-level-calls, avoid-call-value
        (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");

        // solhint-disable-next-line avoid-low-level-calls
        (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");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.staticcall(data);
        return _verifyCallResult(success, returndata, errorMessage);
    }

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

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

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return _verifyCallResult(success, returndata, errorMessage);
    }

    function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private 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

                // solhint-disable-next-line no-inline-assembly
                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

File 8 of 17 : Context.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

/*
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with GSN meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract Context {
    function _msgSender() internal view virtual returns (address payable) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes memory) {
        this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
        return msg.data;
    }
}

File 9 of 17 : Pausable.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

import "./Context.sol";

/**
 * @dev Contract module which allows children to implement an emergency stop
 * mechanism that can be triggered by an authorized account.
 *
 * This module is used through inheritance. It will make available the
 * modifiers `whenNotPaused` and `whenPaused`, which can be applied to
 * the functions of your contract. Note that they will not be pausable by
 * simply including this module, only once the modifiers are put in place.
 */
abstract contract Pausable is Context {
    /**
     * @dev Emitted when the pause is triggered by `account`.
     */
    event Paused(address account);

    /**
     * @dev Emitted when the pause is lifted by `account`.
     */
    event Unpaused(address account);

    bool private _paused;

    /**
     * @dev Initializes the contract in unpaused state.
     */
    constructor () internal {
        _paused = false;
    }

    /**
     * @dev Returns true if the contract is paused, and false otherwise.
     */
    function paused() public view virtual returns (bool) {
        return _paused;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is not paused.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    modifier whenNotPaused() {
        require(!paused(), "Pausable: paused");
        _;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is paused.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    modifier whenPaused() {
        require(paused(), "Pausable: not paused");
        _;
    }

    /**
     * @dev Triggers stopped state.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    function _pause() internal virtual whenNotPaused {
        _paused = true;
        emit Paused(_msgSender());
    }

    /**
     * @dev Returns to normal state.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    function _unpause() internal virtual whenPaused {
        _paused = false;
        emit Unpaused(_msgSender());
    }
}

File 10 of 17 : Registry.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

import "@openzeppelin/contracts/access/Ownable.sol";

contract Registry is Ownable {
    // Map asset addresses to indexes.
    mapping(address => uint32) public assetAddressToIndex;
    mapping(uint32 => address) public assetIndexToAddress;
    uint32 numAssets = 0;

    // Valid strategies.
    mapping(address => uint32) public strategyAddressToIndex;
    mapping(uint32 => address) public strategyIndexToAddress;
    uint32 numStrategies = 0;

    event AssetRegistered(address asset, uint32 assetId);
    event StrategyRegistered(address strategy, uint32 strategyId);
    event StrategyUpdated(address previousStrategy, address newStrategy, uint32 strategyId);

    /**
     * @notice Register a asset
     * @param _asset The asset token address;
     */
    function registerAsset(address _asset) external onlyOwner {
        require(_asset != address(0), "Invalid asset");
        require(assetAddressToIndex[_asset] == 0, "Asset already registered");

        // Register asset with an index >= 1 (zero is reserved).
        numAssets++;
        assetAddressToIndex[_asset] = numAssets;
        assetIndexToAddress[numAssets] = _asset;

        emit AssetRegistered(_asset, numAssets);
    }

    /**
     * @notice Register a strategy
     * @param _strategy The strategy contract address;
     */
    function registerStrategy(address _strategy) external onlyOwner {
        require(_strategy != address(0), "Invalid strategy");
        require(strategyAddressToIndex[_strategy] == 0, "Strategy already registered");

        // Register strategy with an index >= 1 (zero is reserved).
        numStrategies++;
        strategyAddressToIndex[_strategy] = numStrategies;
        strategyIndexToAddress[numStrategies] = _strategy;

        emit StrategyRegistered(_strategy, numStrategies);
    }

    /**
     * @notice Update the address of an existing strategy
     * @param _strategy The strategy contract address;
     * @param _strategyId The strategy ID;
     */
    function updateStrategy(address _strategy, uint32 _strategyId) external onlyOwner {
        require(_strategy != address(0), "Invalid strategy");
        require(strategyIndexToAddress[_strategyId] != address(0), "Strategy doesn't exist");

        address previousStrategy = strategyIndexToAddress[_strategyId];
        strategyAddressToIndex[previousStrategy] = 0;
        strategyAddressToIndex[_strategy] = _strategyId;
        strategyIndexToAddress[_strategyId] = _strategy;

        emit StrategyUpdated(previousStrategy, _strategy, _strategyId);
    }
}

File 11 of 17 : TransitionDisputer.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;
pragma experimental ABIEncoderV2;

import "@openzeppelin/contracts/math/SafeMath.sol";

import {DataTypes as dt} from "./libraries/DataTypes.sol";
import "./libraries/MerkleTree.sol";
import "./libraries/Transitions.sol";
import "./TransitionEvaluator.sol";
import "./Registry.sol";

contract TransitionDisputer {
    // state root of empty strategy set and empty account set
    bytes32 public constant INIT_TRANSITION_STATE_ROOT =
        bytes32(0xcf277fb80a82478460e8988570b718f1e083ceb76f7e271a1a1497e5975f53ae);

    using SafeMath for uint256;

    TransitionEvaluator transitionEvaluator;

    constructor(TransitionEvaluator _transitionEvaluator) {
        transitionEvaluator = _transitionEvaluator;
    }

    /**********************
     * External Functions *
     **********************/

    /**
     * @notice Dispute a transition.
     *
     * @param _prevTransitionProof The inclusion proof of the transition immediately before the disputed transition.
     * @param _invalidTransitionProof The inclusion proof of the disputed transition.
     * @param _accountProof The inclusion proof of the account involved.
     * @param _strategyProof The inclusion proof of the strategy involved.
     * @param _prevTransitionBlock The block containing the previous transition.
     * @param _invalidTransitionBlock The block containing the disputed transition.
     * @param _registry The address of the Registry contract.
     *
     * @return reason of the transition being determined as invalid
     */
    function disputeTransition(
        dt.TransitionProof calldata _prevTransitionProof,
        dt.TransitionProof calldata _invalidTransitionProof,
        dt.AccountProof calldata _accountProof,
        dt.StrategyProof calldata _strategyProof,
        dt.Block calldata _prevTransitionBlock,
        dt.Block calldata _invalidTransitionBlock,
        Registry _registry
    ) external returns (string memory) {
        if (_invalidTransitionProof.blockId == 0 && _invalidTransitionProof.index == 0) {
            require(_invalidInitTransition(_invalidTransitionProof, _invalidTransitionBlock), "no fraud detected");
            return "invalid init transition";
        }

        // ------ #1: verify sequential transitions
        // First verify that the transitions are sequential and in their respective block root hashes.
        _verifySequentialTransitions(
            _prevTransitionProof,
            _invalidTransitionProof,
            _prevTransitionBlock,
            _invalidTransitionBlock
        );

        // ------ #2: decode transitions to get post- and pre-StateRoot, and ids of account and strategy
        (bool ok, bytes32 preStateRoot, bytes32 postStateRoot, uint32 accountId, uint32 strategyId) =
            _getStateRootsAndIds(_prevTransitionProof.transition, _invalidTransitionProof.transition);
        // If not success something went wrong with the decoding...
        if (!ok) {
            // revert the block if it has an incorrectly encoded transition!
            return "invalid encoding";
        }

        // ------ #3: verify transition stateRoot == hash(accountStateRoot, strategyStateRoot)
        // The account and strategy stateRoots must always be given irrespective of what is being disputed.
        require(
            _checkTwoTreeStateRoot(preStateRoot, _accountProof.stateRoot, _strategyProof.stateRoot),
            "Failed combined two-tree stateRoot verification check"
        );

        // ------ #4: verify account and strategy inclusion
        if (accountId > 0) {
            _verifyProofInclusion(
                _accountProof.stateRoot,
                keccak256(_getAccountInfoBytes(_accountProof.value)),
                _accountProof.index,
                _accountProof.siblings
            );
        }
        if (strategyId > 0) {
            _verifyProofInclusion(
                _strategyProof.stateRoot,
                keccak256(_getStrategyInfoBytes(_strategyProof.value)),
                _strategyProof.index,
                _strategyProof.siblings
            );
        }

        // ------ #5: verify deposit account id mapping
        uint8 transitionType = Transitions.extractTransitionType(_invalidTransitionProof.transition);
        if (transitionType == Transitions.TRANSITION_TYPE_DEPOSIT) {
            DataTypes.DepositTransition memory transition =
                Transitions.decodeDepositTransition(_invalidTransitionProof.transition);
            if (_accountProof.value.account == transition.account && _accountProof.value.accountId != accountId) {
                // same account address with different id
                return "invalid account id";
            }
        }

        // ------ #6: verify transition account and strategy indexes
        if (accountId > 0) {
            require(_accountProof.index == accountId, "Supplied account index is incorrect");
        }
        if (strategyId > 0) {
            require(_strategyProof.index == strategyId, "Supplied strategy index is incorrect");
        }

        // ------ #7: evaluate transition and verify new state root
        // split function to address "stack too deep" compiler error
        return
            _evaluateInvalidTransition(
                _invalidTransitionProof.transition,
                _accountProof,
                _strategyProof,
                postStateRoot,
                _registry
            );
    }

    /*********************
     * Private Functions *
     *********************/

    /**
     * @notice Evaluate a disputed transition
     * @dev This was split from the disputeTransition function to address "stack too deep" compiler error
     *
     * @param _invalidTransition The disputed transition.
     * @param _accountProof The inclusion proof of the account involved.
     * @param _strategyProof The inclusion proof of the strategy involved.
     * @param _postStateRoot State root of the disputed transition.
     * @param _registry The address of the Registry contract.
     */
    function _evaluateInvalidTransition(
        bytes calldata _invalidTransition,
        dt.AccountProof calldata _accountProof,
        dt.StrategyProof calldata _strategyProof,
        bytes32 _postStateRoot,
        Registry _registry
    ) private returns (string memory) {
        // Apply the transaction and verify the state root after that.
        bool ok;
        bytes memory returnData;
        // Make the external call
        (ok, returnData) = address(transitionEvaluator).call(
            abi.encodeWithSelector(
                transitionEvaluator.evaluateTransition.selector,
                _invalidTransition,
                _accountProof.value,
                _strategyProof.value,
                _registry
            )
        );
        // Check if it was successful. If not, we've got to revert.
        if (!ok) {
            return "failed to evaluate";
        }
        // It was successful so let's decode the outputs to get the new leaf nodes we'll have to insert
        bytes32[2] memory outputs = abi.decode((returnData), (bytes32[2]));

        // Check if the combined new stateRoots of account and strategy Merkle trees is incorrect.
        ok = _updateAndVerify(_postStateRoot, outputs, _accountProof, _strategyProof);
        if (!ok) {
            // revert the block because we found an invalid post state root
            return "invalid post-state root";
        }

        revert("No fraud detected");
    }

    /**
     * @notice Get state roots, account id, and strategy id of the disputed transition.
     *
     * @param _preStateTransition transition immediately before the disputed transition
     * @param _invalidTransition the disputed transition
     */
    function _getStateRootsAndIds(bytes memory _preStateTransition, bytes memory _invalidTransition)
        private
        returns (
            bool,
            bytes32,
            bytes32,
            uint32,
            uint32
        )
    {
        bool success;
        bytes memory returnData;
        bytes32 preStateRoot;
        bytes32 postStateRoot;
        uint32 accountId;
        uint32 strategyId;

        // First decode the prestate root
        (success, returnData) = address(transitionEvaluator).call(
            abi.encodeWithSelector(transitionEvaluator.getTransitionStateRootAndAccessIds.selector, _preStateTransition)
        );

        // Make sure the call was successful
        require(success, "If the preStateRoot is invalid, then prove that invalid instead");
        (preStateRoot, , ) = abi.decode((returnData), (bytes32, uint32, uint32));

        // Now that we have the prestateRoot, let's decode the postState
        (success, returnData) = address(transitionEvaluator).call(
            abi.encodeWithSelector(TransitionEvaluator.getTransitionStateRootAndAccessIds.selector, _invalidTransition)
        );

        // If the call was successful let's decode!
        if (success) {
            (postStateRoot, accountId, strategyId) = abi.decode((returnData), (bytes32, uint32, uint32));
        }
        return (success, preStateRoot, postStateRoot, accountId, strategyId);
    }

    /**
     * @notice Evaluate if the init transition of the first block is invalid
     *
     * @param _initTransitionProof The inclusion proof of the disputed initial transition.
     * @param _firstBlock The first rollup block
     */
    function _invalidInitTransition(dt.TransitionProof calldata _initTransitionProof, dt.Block calldata _firstBlock)
        private
        returns (bool)
    {
        require(_checkTransitionInclusion(_initTransitionProof, _firstBlock), "transition not included in block");
        (bool success, bytes memory returnData) =
            address(transitionEvaluator).call(
                abi.encodeWithSelector(
                    TransitionEvaluator.getTransitionStateRootAndAccessIds.selector,
                    _initTransitionProof.transition
                )
            );
        if (!success) {
            return true; // transition is invalid
        }
        (bytes32 postStateRoot, , ) = abi.decode((returnData), (bytes32, uint32, uint32));

        // Transition is invalid if stateRoot not match the expected init root
        // It's OK that other fields of the transition are incorrect.
        return postStateRoot != INIT_TRANSITION_STATE_ROOT;
    }

    /**
     * @notice Get the bytes value for this account.
     *
     * @param _accountInfo Account info
     */
    function _getAccountInfoBytes(dt.AccountInfo memory _accountInfo) private pure returns (bytes memory) {
        // If it's an empty storage slot, return 32 bytes of zeros (empty value)
        if (
            _accountInfo.account == address(0) &&
            _accountInfo.accountId == 0 &&
            _accountInfo.idleAssets.length == 0 &&
            _accountInfo.stTokens.length == 0 &&
            _accountInfo.timestamp == 0
        ) {
            return abi.encodePacked(uint256(0));
        }
        // Here we don't use `abi.encode([struct])` because it's not clear
        // how to generate that encoding client-side.
        return
            abi.encode(
                _accountInfo.account,
                _accountInfo.accountId,
                _accountInfo.idleAssets,
                _accountInfo.stTokens,
                _accountInfo.timestamp
            );
    }

    /**
     * @notice Get the bytes value for this strategy.
     * @param _strategyInfo Strategy info
     */
    function _getStrategyInfoBytes(dt.StrategyInfo memory _strategyInfo) private pure returns (bytes memory) {
        // If it's an empty storage slot, return 32 bytes of zeros (empty value)
        if (
            _strategyInfo.assetId == 0 &&
            _strategyInfo.assetBalance == 0 &&
            _strategyInfo.stTokenSupply == 0 &&
            _strategyInfo.pendingCommitAmount == 0 &&
            _strategyInfo.pendingUncommitAmount == 0
        ) {
            return abi.encodePacked(uint256(0));
        }
        // Here we don't use `abi.encode([struct])` because it's not clear
        // how to generate that encoding client-side.
        return
            abi.encode(
                _strategyInfo.assetId,
                _strategyInfo.assetBalance,
                _strategyInfo.stTokenSupply,
                _strategyInfo.pendingCommitAmount,
                _strategyInfo.pendingUncommitAmount
            );
    }

    /**
     * @notice Verifies that two transitions were included one after another.
     * @dev This is used to make sure we are comparing the correct prestate & poststate.
     */
    function _verifySequentialTransitions(
        dt.TransitionProof calldata _tp0,
        dt.TransitionProof calldata _tp1,
        dt.Block calldata _prevTransitionBlock,
        dt.Block calldata _invalidTransitionBlock
    ) private pure returns (bool) {
        // Start by checking if they are in the same block
        if (_tp0.blockId == _tp1.blockId) {
            // If the blocknumber is the same, check that tp0 precedes tp1
            require(_tp0.index + 1 == _tp1.index, "Transitions must be sequential");
            require(_tp1.index < _invalidTransitionBlock.blockSize, "_tp1 outside block range");
        } else {
            // If not in the same block, check that:
            // 0) the blocks are one after another
            require(_tp0.blockId + 1 == _tp1.blockId, "Blocks must be sequential or equal");

            // 1) the index of tp0 is the last in its block
            require(_tp0.index == _prevTransitionBlock.blockSize - 1, "_tp0 must be last in its block");

            // 2) the index of tp1 is the first in its block
            require(_tp1.index == 0, "_tp1 must be first in its block");
        }

        // Verify inclusion
        require(_checkTransitionInclusion(_tp0, _prevTransitionBlock), "_tp0 must be included in its block");
        require(_checkTransitionInclusion(_tp1, _invalidTransitionBlock), "_tp1 must be included in its block");

        return true;
    }

    /**
     * @notice Check to see if a transition is included in the block.
     */
    function _checkTransitionInclusion(dt.TransitionProof memory _tp, dt.Block memory _block)
        private
        pure
        returns (bool)
    {
        bytes32 rootHash = _block.rootHash;
        bytes32 leafHash = keccak256(_tp.transition);
        return MerkleTree.verify(rootHash, leafHash, _tp.index, _tp.siblings);
    }

    /**
     * @notice Check if the combined stateRoot of the two Merkle trees (account, strategy) matches the stateRoot.
     */
    function _checkTwoTreeStateRoot(
        bytes32 _stateRoot,
        bytes32 _accountStateRoot,
        bytes32 _strategyStateRoot
    ) private pure returns (bool) {
        bytes32 newStateRoot = keccak256(abi.encodePacked(_accountStateRoot, _strategyStateRoot));
        return (_stateRoot == newStateRoot);
    }

    /**
     * @notice Check if an account or strategy proof is included in the state root.
     */
    function _verifyProofInclusion(
        bytes32 _stateRoot,
        bytes32 _leafHash,
        uint32 _index,
        bytes32[] memory _siblings
    ) private pure {
        bool ok = MerkleTree.verify(_stateRoot, _leafHash, _index, _siblings);
        require(ok, "Failed proof inclusion verification check");
    }

    /**
     * @notice Update the account and strategy Merkle trees with their new leaf nodes and check validity.
     */
    function _updateAndVerify(
        bytes32 _stateRoot,
        bytes32[2] memory _leafHashes,
        dt.AccountProof memory _accountProof,
        dt.StrategyProof memory _strategyProof
    ) private pure returns (bool) {
        if (_leafHashes[0] == bytes32(0) && _leafHashes[1] == bytes32(0)) {
            return false;
        }

        // If there is an account update, compute its new Merkle tree root.
        bytes32 accountStateRoot = _accountProof.stateRoot;
        if (_leafHashes[0] != bytes32(0)) {
            accountStateRoot = MerkleTree.computeRoot(_leafHashes[0], _accountProof.index, _accountProof.siblings);
        }

        // If there is a strategy update, compute its new Merkle tree root.
        bytes32 strategyStateRoot = _strategyProof.stateRoot;
        if (_leafHashes[1] != bytes32(0)) {
            strategyStateRoot = MerkleTree.computeRoot(_leafHashes[1], _strategyProof.index, _strategyProof.siblings);
        }

        return _checkTwoTreeStateRoot(_stateRoot, accountStateRoot, strategyStateRoot);
    }
}

File 12 of 17 : TransitionEvaluator.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;
pragma experimental ABIEncoderV2;

import "@openzeppelin/contracts/math/SafeMath.sol";
import "@openzeppelin/contracts/cryptography/ECDSA.sol";

/* Internal Imports */
import "./libraries/DataTypes.sol";
import "./libraries/Transitions.sol";
import "./Registry.sol";
import "./strategies/interfaces/IStrategy.sol";

contract TransitionEvaluator {
    using SafeMath for uint256;

    /**********************
     * External Functions *
     **********************/

    /**
     * @notice Evaluate a transition.
     *
     * @param _transition The disputed transition.
     * @param _accountInfo The involved account from the previous transition.
     * @param _strategyInfo The involved strategy from the previous transition.
     * @param _registry The address of the Registry contract.
     * @return hashes of account and strategy after applying the transition.
     */
    function evaluateTransition(
        bytes calldata _transition,
        DataTypes.AccountInfo calldata _accountInfo,
        DataTypes.StrategyInfo calldata _strategyInfo,
        Registry _registry
    ) external view returns (bytes32[2] memory) {
        // Extract the transition type
        uint8 transitionType = Transitions.extractTransitionType(_transition);
        bytes32[2] memory outputs;
        DataTypes.AccountInfo memory updatedAccountInfo;
        DataTypes.StrategyInfo memory updatedStrategyInfo;
        // Apply the transition and record the resulting storage slots
        if (transitionType == Transitions.TRANSITION_TYPE_DEPOSIT) {
            DataTypes.DepositTransition memory deposit = Transitions.decodeDepositTransition(_transition);
            updatedAccountInfo = _applyDepositTransition(deposit, _accountInfo);
            outputs[0] = _getAccountInfoHash(updatedAccountInfo);
        } else if (transitionType == Transitions.TRANSITION_TYPE_WITHDRAW) {
            DataTypes.WithdrawTransition memory withdraw = Transitions.decodeWithdrawTransition(_transition);
            updatedAccountInfo = _applyWithdrawTransition(withdraw, _accountInfo);
            outputs[0] = _getAccountInfoHash(updatedAccountInfo);
        } else if (transitionType == Transitions.TRANSITION_TYPE_COMMIT) {
            DataTypes.CommitTransition memory commit = Transitions.decodeCommitTransition(_transition);
            (updatedAccountInfo, updatedStrategyInfo) = _applyCommitTransition(
                commit,
                _accountInfo,
                _strategyInfo,
                _registry
            );
            outputs[0] = _getAccountInfoHash(updatedAccountInfo);
            outputs[1] = _getStrategyInfoHash(updatedStrategyInfo);
        } else if (transitionType == Transitions.TRANSITION_TYPE_UNCOMMIT) {
            DataTypes.UncommitTransition memory uncommit = Transitions.decodeUncommitTransition(_transition);
            (updatedAccountInfo, updatedStrategyInfo) = _applyUncommitTransition(uncommit, _accountInfo, _strategyInfo);
            outputs[0] = _getAccountInfoHash(updatedAccountInfo);
            outputs[1] = _getStrategyInfoHash(updatedStrategyInfo);
        } else if (transitionType == Transitions.TRANSITION_TYPE_SYNC_COMMITMENT) {
            DataTypes.CommitmentSyncTransition memory commitmentSync =
                Transitions.decodeCommitmentSyncTransition(_transition);
            updatedStrategyInfo = _applyCommitmentSyncTransition(commitmentSync, _strategyInfo);
            outputs[1] = _getStrategyInfoHash(updatedStrategyInfo);
        } else if (transitionType == Transitions.TRANSITION_TYPE_SYNC_BALANCE) {
            DataTypes.BalanceSyncTransition memory balanceSync = Transitions.decodeBalanceSyncTransition(_transition);
            updatedStrategyInfo = _applyBalanceSyncTransition(balanceSync, _strategyInfo);
            outputs[1] = _getStrategyInfoHash(updatedStrategyInfo);
        } else {
            revert("Transition type not recognized");
        }
        return outputs;
    }

    /**
     * @notice Return the (stateRoot, accountId, strategyId) for this transition.
     */
    function getTransitionStateRootAndAccessIds(bytes calldata _rawTransition)
        external
        pure
        returns (
            bytes32,
            uint32,
            uint32
        )
    {
        // Initialize memory rawTransition
        bytes memory rawTransition = _rawTransition;
        // Initialize stateRoot and account and strategy IDs.
        bytes32 stateRoot;
        uint32 accountId;
        uint32 strategyId;
        uint8 transitionType = Transitions.extractTransitionType(rawTransition);
        if (transitionType == Transitions.TRANSITION_TYPE_DEPOSIT) {
            DataTypes.DepositTransition memory transition = Transitions.decodeDepositTransition(rawTransition);
            stateRoot = transition.stateRoot;
            accountId = transition.accountId;
        } else if (transitionType == Transitions.TRANSITION_TYPE_WITHDRAW) {
            DataTypes.WithdrawTransition memory transition = Transitions.decodeWithdrawTransition(rawTransition);
            stateRoot = transition.stateRoot;
            accountId = transition.accountId;
        } else if (transitionType == Transitions.TRANSITION_TYPE_COMMIT) {
            DataTypes.CommitTransition memory transition = Transitions.decodeCommitTransition(rawTransition);
            stateRoot = transition.stateRoot;
            accountId = transition.accountId;
            strategyId = transition.strategyId;
        } else if (transitionType == Transitions.TRANSITION_TYPE_UNCOMMIT) {
            DataTypes.UncommitTransition memory transition = Transitions.decodeUncommitTransition(rawTransition);
            stateRoot = transition.stateRoot;
            accountId = transition.accountId;
            strategyId = transition.strategyId;
        } else if (transitionType == Transitions.TRANSITION_TYPE_SYNC_COMMITMENT) {
            DataTypes.CommitmentSyncTransition memory transition =
                Transitions.decodeCommitmentSyncTransition(rawTransition);
            stateRoot = transition.stateRoot;
            strategyId = transition.strategyId;
        } else if (transitionType == Transitions.TRANSITION_TYPE_SYNC_BALANCE) {
            DataTypes.BalanceSyncTransition memory transition = Transitions.decodeBalanceSyncTransition(rawTransition);
            stateRoot = transition.stateRoot;
            strategyId = transition.strategyId;
        } else if (transitionType == Transitions.TRANSITION_TYPE_INIT) {
            DataTypes.InitTransition memory transition = Transitions.decodeInitTransition(rawTransition);
            stateRoot = transition.stateRoot;
        } else {
            revert("Transition type not recognized");
        }
        return (stateRoot, accountId, strategyId);
    }

    /*********************
     * Private Functions *
     *********************/

    /**
     * @notice Apply a DepositTransition.
     *
     * @param _transition The disputed transition.
     * @param _accountInfo The involved account from the previous transition.
     * @return new account info after apply the disputed transition
     */
    function _applyDepositTransition(
        DataTypes.DepositTransition memory _transition,
        DataTypes.AccountInfo memory _accountInfo
    ) private pure returns (DataTypes.AccountInfo memory) {
        if (_accountInfo.account == address(0)) {
            // first time deposit of this account
            require(_accountInfo.accountId == 0, "empty account id must be zero");
            require(_accountInfo.idleAssets.length == 0, "empty account idleAssets must be empty");
            require(_accountInfo.stTokens.length == 0, "empty account stTokens must be empty");
            require(_accountInfo.timestamp == 0, "empty account timestamp must be zero");
            _accountInfo.account = _transition.account;
            _accountInfo.accountId = _transition.accountId;
        } else {
            require(_accountInfo.account == _transition.account, "account address not match");
            require(_accountInfo.accountId == _transition.accountId, "account id not match");
        }
        if (_transition.assetId >= _accountInfo.idleAssets.length) {
            uint256[] memory idleAssets = new uint256[](_transition.assetId + 1);
            for (uint256 i = 0; i < _accountInfo.idleAssets.length; i++) {
                idleAssets[i] = _accountInfo.idleAssets[i];
            }
            _accountInfo.idleAssets = idleAssets;
        }
        _accountInfo.idleAssets[_transition.assetId] = _accountInfo.idleAssets[_transition.assetId].add(
            _transition.amount
        );

        return _accountInfo;
    }

    /**
     * @notice Apply a WithdrawTransition.
     *
     * @param _transition The disputed transition.
     * @param _accountInfo The involved account from the previous transition.
     * @return new account info after apply the disputed transition
     */
    function _applyWithdrawTransition(
        DataTypes.WithdrawTransition memory _transition,
        DataTypes.AccountInfo memory _accountInfo
    ) private pure returns (DataTypes.AccountInfo memory) {
        bytes32 txHash =
            keccak256(
                abi.encodePacked(
                    _transition.transitionType,
                    _transition.account,
                    _transition.assetId,
                    _transition.amount,
                    _transition.timestamp
                )
            );
        bytes32 prefixedHash = ECDSA.toEthSignedMessageHash(txHash);
        require(
            ECDSA.recover(prefixedHash, _transition.signature) == _accountInfo.account,
            "Withdraw signature is invalid"
        );

        require(_accountInfo.accountId == _transition.accountId, "account id not match");
        require(_accountInfo.timestamp < _transition.timestamp, "timestamp should monotonically increasing");
        _accountInfo.timestamp = _transition.timestamp;

        _accountInfo.idleAssets[_transition.assetId] = _accountInfo.idleAssets[_transition.assetId].sub(
            _transition.amount
        );

        return _accountInfo;
    }

    /**
     * @notice Apply a CommitTransition.
     *
     * @param _transition The disputed transition.
     * @param _accountInfo The involved account from the previous transition.
     * @param _strategyInfo The involved strategy from the previous transition.
     * @return new account and strategy info after apply the disputed transition
     */
    function _applyCommitTransition(
        DataTypes.CommitTransition memory _transition,
        DataTypes.AccountInfo memory _accountInfo,
        DataTypes.StrategyInfo memory _strategyInfo,
        Registry _registry
    ) private view returns (DataTypes.AccountInfo memory, DataTypes.StrategyInfo memory) {
        bytes32 txHash =
            keccak256(
                abi.encodePacked(
                    _transition.transitionType,
                    _transition.strategyId,
                    _transition.assetAmount,
                    _transition.timestamp
                )
            );
        bytes32 prefixedHash = ECDSA.toEthSignedMessageHash(txHash);
        require(
            ECDSA.recover(prefixedHash, _transition.signature) == _accountInfo.account,
            "Commit signature is invalid"
        );

        uint256 newStToken;
        if (_strategyInfo.assetBalance == 0 || _strategyInfo.stTokenSupply == 0) {
            require(_strategyInfo.stTokenSupply == 0, "empty strategy stTokenSupply must be zero");
            require(_strategyInfo.pendingCommitAmount == 0, "empty strategy pendingCommitAmount must be zero");
            if (_strategyInfo.assetId == 0) {
                // first time commit of new strategy
                require(_strategyInfo.pendingUncommitAmount == 0, "new strategy pendingUncommitAmount must be zero");
                address strategyAddr = _registry.strategyIndexToAddress(_transition.strategyId);
                address assetAddr = IStrategy(strategyAddr).getAssetAddress();
                _strategyInfo.assetId = _registry.assetAddressToIndex(assetAddr);
            }
            newStToken = _transition.assetAmount;
        } else {
            newStToken = _transition.assetAmount.mul(_strategyInfo.stTokenSupply).div(_strategyInfo.assetBalance);
        }

        _accountInfo.idleAssets[_strategyInfo.assetId] = _accountInfo.idleAssets[_strategyInfo.assetId].sub(
            _transition.assetAmount
        );

        if (_transition.strategyId >= _accountInfo.stTokens.length) {
            uint256[] memory stTokens = new uint256[](_transition.strategyId + 1);
            for (uint256 i = 0; i < _accountInfo.stTokens.length; i++) {
                stTokens[i] = _accountInfo.stTokens[i];
            }
            _accountInfo.stTokens = stTokens;
        }
        _accountInfo.stTokens[_transition.strategyId] = _accountInfo.stTokens[_transition.strategyId].add(newStToken);
        require(_accountInfo.accountId == _transition.accountId, "account id not match");
        require(_accountInfo.timestamp < _transition.timestamp, "timestamp should monotonically increasing");
        _accountInfo.timestamp = _transition.timestamp;

        _strategyInfo.stTokenSupply = _strategyInfo.stTokenSupply.add(newStToken);
        _strategyInfo.assetBalance = _strategyInfo.assetBalance.add(_transition.assetAmount);
        _strategyInfo.pendingCommitAmount = _strategyInfo.pendingCommitAmount.add(_transition.assetAmount);

        return (_accountInfo, _strategyInfo);
    }

    /**
     * @notice Apply a UncommitTransition.
     *
     * @param _transition The disputed transition.
     * @param _accountInfo The involved account from the previous transition.
     * @param _strategyInfo The involved strategy from the previous transition.
     * @return new account and strategy info after apply the disputed transition
     */
    function _applyUncommitTransition(
        DataTypes.UncommitTransition memory _transition,
        DataTypes.AccountInfo memory _accountInfo,
        DataTypes.StrategyInfo memory _strategyInfo
    ) private pure returns (DataTypes.AccountInfo memory, DataTypes.StrategyInfo memory) {
        bytes32 txHash =
            keccak256(
                abi.encodePacked(
                    _transition.transitionType,
                    _transition.strategyId,
                    _transition.stTokenAmount,
                    _transition.timestamp
                )
            );
        bytes32 prefixedHash = ECDSA.toEthSignedMessageHash(txHash);
        require(
            ECDSA.recover(prefixedHash, _transition.signature) == _accountInfo.account,
            "Uncommit signature is invalid"
        );

        uint256 newIdleAsset =
            _transition.stTokenAmount.mul(_strategyInfo.assetBalance).div(_strategyInfo.stTokenSupply);

        _accountInfo.idleAssets[_strategyInfo.assetId] = _accountInfo.idleAssets[_strategyInfo.assetId].add(
            newIdleAsset
        );
        _accountInfo.stTokens[_transition.strategyId] = _accountInfo.stTokens[_transition.strategyId].sub(
            _transition.stTokenAmount
        );
        require(_accountInfo.accountId == _transition.accountId, "account id not match");
        require(_accountInfo.timestamp < _transition.timestamp, "timestamp should monotonically increasing");
        _accountInfo.timestamp = _transition.timestamp;

        _strategyInfo.stTokenSupply = _strategyInfo.stTokenSupply.sub(_transition.stTokenAmount);
        _strategyInfo.assetBalance = _strategyInfo.assetBalance.sub(newIdleAsset);
        _strategyInfo.pendingUncommitAmount = _strategyInfo.pendingUncommitAmount.add(newIdleAsset);

        return (_accountInfo, _strategyInfo);
    }

    /**
     * @notice Apply a CommitmentSyncTransition.
     *
     * @param _transition The disputed transition.
     * @param _strategyInfo The involved strategy from the previous transition.
     * @return new strategy info after apply the disputed transition
     */
    function _applyCommitmentSyncTransition(
        DataTypes.CommitmentSyncTransition memory _transition,
        DataTypes.StrategyInfo memory _strategyInfo
    ) private pure returns (DataTypes.StrategyInfo memory) {
        require(
            _transition.pendingCommitAmount == _strategyInfo.pendingCommitAmount,
            "pending commitment amount not match"
        );
        require(
            _transition.pendingUncommitAmount == _strategyInfo.pendingUncommitAmount,
            "pending uncommitment amount not match"
        );
        _strategyInfo.pendingCommitAmount = 0;
        _strategyInfo.pendingUncommitAmount = 0;

        return _strategyInfo;
    }

    /**
     * @notice Apply a BalanceSyncTransition.
     *
     * @param _transition The disputed transition.
     * @param _strategyInfo The involved strategy from the previous transition.
     * @return new strategy info after apply the disputed transition
     */
    function _applyBalanceSyncTransition(
        DataTypes.BalanceSyncTransition memory _transition,
        DataTypes.StrategyInfo memory _strategyInfo
    ) private pure returns (DataTypes.StrategyInfo memory) {
        if (_transition.newAssetDelta >= 0) {
            uint256 delta = uint256(_transition.newAssetDelta);
            _strategyInfo.assetBalance = _strategyInfo.assetBalance.add(delta);
        } else {
            uint256 delta = uint256(-_transition.newAssetDelta);
            _strategyInfo.assetBalance = _strategyInfo.assetBalance.sub(delta);
        }
        return _strategyInfo;
    }

    /**
     * @notice Get the hash of the AccountInfo.
     * @param _accountInfo Account info
     */
    function _getAccountInfoHash(DataTypes.AccountInfo memory _accountInfo) private pure returns (bytes32) {
        // Here we don't use `abi.encode([struct])` because it's not clear
        // how to generate that encoding client-side.
        return
            keccak256(
                abi.encode(
                    _accountInfo.account,
                    _accountInfo.accountId,
                    _accountInfo.idleAssets,
                    _accountInfo.stTokens,
                    _accountInfo.timestamp
                )
            );
    }

    /**
     * Get the hash of the StrategyInfo.
     */
    /**
     * @notice Get the hash of the StrategyInfo.
     * @param _strategyInfo Strategy info
     */
    function _getStrategyInfoHash(DataTypes.StrategyInfo memory _strategyInfo) private pure returns (bytes32) {
        // Here we don't use `abi.encode([struct])` because it's not clear
        // how to generate that encoding client-side.
        return
            keccak256(
                abi.encode(
                    _strategyInfo.assetId,
                    _strategyInfo.assetBalance,
                    _strategyInfo.stTokenSupply,
                    _strategyInfo.pendingCommitAmount,
                    _strategyInfo.pendingUncommitAmount
                )
            );
    }
}

File 13 of 17 : IWETH.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

interface IWETH {
    function totalSupply() external view returns (uint256);

    function balanceOf(address account) external view returns (uint256);

    function transfer(address recipient, uint256 amount) external returns (bool);

    function allowance(address owner, address spender) external view returns (uint256);

    function approve(address spender, uint256 amount) external returns (bool);

    function transferFrom(
        address src,
        address dst,
        uint256 wad
    ) external returns (bool);

    function deposit() external payable;

    function withdraw(uint256 wad) external;
}

File 14 of 17 : DataTypes.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

library DataTypes {
    struct Block {
        bytes32 rootHash;
        bytes32 intentHash; // hash of L2-to-L1 commitment sync transitions
        uint128 blockTime; // blockNum when this rollup block is committed
        uint128 blockSize; // number of transitions in the block
    }

    struct InitTransition {
        uint8 transitionType;
        bytes32 stateRoot;
    }

    struct DepositTransition {
        uint8 transitionType;
        bytes32 stateRoot;
        address account; // must provide L1 address for "pending deposit" handling
        uint32 accountId; // needed for transition evaluation in case of dispute
        uint32 assetId;
        uint256 amount;
    }

    struct WithdrawTransition {
        uint8 transitionType;
        bytes32 stateRoot;
        address account; // must provide L1 target address for "pending withdraw" handling
        uint32 accountId;
        uint32 assetId;
        uint256 amount;
        uint64 timestamp; // Unix epoch (msec, UTC)
        bytes signature;
    }

    struct CommitTransition {
        uint8 transitionType;
        bytes32 stateRoot;
        uint32 accountId;
        uint32 strategyId;
        uint256 assetAmount;
        uint64 timestamp; // Unix epoch (msec, UTC)
        bytes signature;
    }

    struct UncommitTransition {
        uint8 transitionType;
        bytes32 stateRoot;
        uint32 accountId;
        uint32 strategyId;
        uint256 stTokenAmount;
        uint64 timestamp; // Unix epoch (msec, UTC)
        bytes signature;
    }

    struct BalanceSyncTransition {
        uint8 transitionType;
        bytes32 stateRoot;
        uint32 strategyId;
        int256 newAssetDelta;
    }

    struct CommitmentSyncTransition {
        uint8 transitionType;
        bytes32 stateRoot;
        uint32 strategyId;
        uint256 pendingCommitAmount;
        uint256 pendingUncommitAmount;
    }

    struct AccountInfo {
        address account;
        uint32 accountId; // mapping only on L2 must be part of stateRoot
        uint256[] idleAssets; // indexed by assetId
        uint256[] stTokens; // indexed by strategyId
        uint64 timestamp; // Unix epoch (msec, UTC)
    }

    struct StrategyInfo {
        uint32 assetId;
        uint256 assetBalance;
        uint256 stTokenSupply;
        uint256 pendingCommitAmount;
        uint256 pendingUncommitAmount;
    }

    struct TransitionProof {
        bytes transition;
        uint256 blockId;
        uint32 index;
        bytes32[] siblings;
    }

    // Even when the disputed transition only affects an account without not a strategy
    // (e.g. deposit), or only affects a strategy without an account (e.g. syncBalance),
    // both AccountProof and StrategyProof must be sent to at least give the root hashes
    // of the two separate Merkle trees (account and strategy).
    // Each transition stateRoot = hash(accountStateRoot, strategyStateRoot).
    struct AccountProof {
        bytes32 stateRoot; // for the account Merkle tree
        AccountInfo value;
        uint32 index;
        bytes32[] siblings;
    }

    struct StrategyProof {
        bytes32 stateRoot; // for the strategy Merkle tree
        StrategyInfo value;
        uint32 index;
        bytes32[] siblings;
    }
}

File 15 of 17 : MerkleTree.sol
// SPDX-License-Identifier: MIT
/*
(The MIT License)

Copyright 2020 Optimism

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

pragma solidity >0.5.0 <0.8.0;

/**
 * @title MerkleTree
 * @author River Keefer
 */
library MerkleTree {
    /**********************
     * Internal Functions *
     **********************/

    /**
     * Calculates a merkle root for a list of 32-byte leaf hashes.  WARNING: If the number
     * of leaves passed in is not a power of two, it pads out the tree with zero hashes.
     * If you do not know the original length of elements for the tree you are verifying,
     * then this may allow empty leaves past _elements.length to pass a verification check down the line.
     * @param _elements Array of hashes from which to generate a merkle root.
     * @return Merkle root of the leaves, with zero hashes for non-powers-of-two (see above).
     */
    function getMerkleRoot(bytes32[] memory _elements) internal pure returns (bytes32) {
        require(_elements.length > 0, "MerkleTree: Must provide at least one leaf hash.");

        if (_elements.length == 1) {
            return _elements[0];
        }

        uint256[32] memory defaults =
            [
                0x290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e563,
                0x633dc4d7da7256660a892f8f1604a44b5432649cc8ec5cb3ced4c4e6ac94dd1d,
                0x890740a8eb06ce9be422cb8da5cdafc2b58c0a5e24036c578de2a433c828ff7d,
                0x3b8ec09e026fdc305365dfc94e189a81b38c7597b3d941c279f042e8206e0bd8,
                0xecd50eee38e386bd62be9bedb990706951b65fe053bd9d8a521af753d139e2da,
                0xdefff6d330bb5403f63b14f33b578274160de3a50df4efecf0e0db73bcdd3da5,
                0x617bdd11f7c0a11f49db22f629387a12da7596f9d1704d7465177c63d88ec7d7,
                0x292c23a9aa1d8bea7e2435e555a4a60e379a5a35f3f452bae60121073fb6eead,
                0xe1cea92ed99acdcb045a6726b2f87107e8a61620a232cf4d7d5b5766b3952e10,
                0x7ad66c0a68c72cb89e4fb4303841966e4062a76ab97451e3b9fb526a5ceb7f82,
                0xe026cc5a4aed3c22a58cbd3d2ac754c9352c5436f638042dca99034e83636516,
                0x3d04cffd8b46a874edf5cfae63077de85f849a660426697b06a829c70dd1409c,
                0xad676aa337a485e4728a0b240d92b3ef7b3c372d06d189322bfd5f61f1e7203e,
                0xa2fca4a49658f9fab7aa63289c91b7c7b6c832a6d0e69334ff5b0a3483d09dab,
                0x4ebfd9cd7bca2505f7bef59cc1c12ecc708fff26ae4af19abe852afe9e20c862,
                0x2def10d13dd169f550f578bda343d9717a138562e0093b380a1120789d53cf10,
                0x776a31db34a1a0a7caaf862cffdfff1789297ffadc380bd3d39281d340abd3ad,
                0xe2e7610b87a5fdf3a72ebe271287d923ab990eefac64b6e59d79f8b7e08c46e3,
                0x504364a5c6858bf98fff714ab5be9de19ed31a976860efbd0e772a2efe23e2e0,
                0x4f05f4acb83f5b65168d9fef89d56d4d77b8944015e6b1eed81b0238e2d0dba3,
                0x44a6d974c75b07423e1d6d33f481916fdd45830aea11b6347e700cd8b9f0767c,
                0xedf260291f734ddac396a956127dde4c34c0cfb8d8052f88ac139658ccf2d507,
                0x6075c657a105351e7f0fce53bc320113324a522e8fd52dc878c762551e01a46e,
                0x6ca6a3f763a9395f7da16014725ca7ee17e4815c0ff8119bf33f273dee11833b,
                0x1c25ef10ffeb3c7d08aa707d17286e0b0d3cbcb50f1bd3b6523b63ba3b52dd0f,
                0xfffc43bd08273ccf135fd3cacbeef055418e09eb728d727c4d5d5c556cdea7e3,
                0xc5ab8111456b1f28f3c7a0a604b4553ce905cb019c463ee159137af83c350b22,
                0x0ff273fcbf4ae0f2bd88d6cf319ff4004f8d7dca70d4ced4e74d2c74139739e6,
                0x7fa06ba11241ddd5efdc65d4e39c9f6991b74fd4b81b62230808216c876f827c,
                0x7e275adf313a996c7e2950cac67caba02a5ff925ebf9906b58949f3e77aec5b9,
                0x8f6162fa308d2b3a15dc33cffac85f13ab349173121645aedf00f471663108be,
                0x78ccaaab73373552f207a63599de54d7d8d0c1805f86ce7da15818d09f4cff62
            ];

        // Reserve memory space for our hashes.
        bytes memory buf = new bytes(64);

        // We'll need to keep track of left and right siblings.
        bytes32 leftSibling;
        bytes32 rightSibling;

        // Number of non-empty nodes at the current depth.
        uint256 rowSize = _elements.length;

        // Current depth, counting from 0 at the leaves
        uint256 depth = 0;

        // Common sub-expressions
        uint256 halfRowSize; // rowSize / 2
        bool rowSizeIsOdd; // rowSize % 2 == 1

        while (rowSize > 1) {
            halfRowSize = rowSize / 2;
            rowSizeIsOdd = rowSize % 2 == 1;

            for (uint256 i = 0; i < halfRowSize; i++) {
                leftSibling = _elements[(2 * i)];
                rightSibling = _elements[(2 * i) + 1];
                assembly {
                    mstore(add(buf, 32), leftSibling)
                    mstore(add(buf, 64), rightSibling)
                }

                _elements[i] = keccak256(buf);
            }

            if (rowSizeIsOdd) {
                leftSibling = _elements[rowSize - 1];
                rightSibling = bytes32(defaults[depth]);
                assembly {
                    mstore(add(buf, 32), leftSibling)
                    mstore(add(buf, 64), rightSibling)
                }

                _elements[halfRowSize] = keccak256(buf);
            }

            rowSize = halfRowSize + (rowSizeIsOdd ? 1 : 0);
            depth++;
        }

        return _elements[0];
    }

    /**
     * Verifies a merkle branch for the given leaf hash.  Assumes the original length
     * of leaves generated is a known, correct input, and does not return true for indices
     * extending past that index (even if _siblings would be otherwise valid.)
     * @param _root The Merkle root to verify against.
     * @param _leaf The leaf hash to verify inclusion of.
     * @param _index The index in the tree of this leaf.
     * @param _siblings Array of sibling nodes in the inclusion proof, starting from depth 0 (bottom of the tree).
     * @return Whether or not the merkle branch and leaf passes verification.
     */
    function verify(
        bytes32 _root,
        bytes32 _leaf,
        uint256 _index,
        bytes32[] memory _siblings
    ) internal pure returns (bool) {
        return (_root == computeRoot(_leaf, _index, _siblings));
    }

    /**
     * Compute the root of a merkle branch for the given leaf hash.  Assumes the original length
     * of leaves generated is a known, correct input, and does not return true for indices
     * extending past that index (even if _siblings would be otherwise valid.)
     * @param _leaf The leaf hash to verify inclusion of.
     * @param _index The index in the tree of this leaf.
     * @param _siblings Array of sibling nodes in the inclusion proof, starting from depth 0 (bottom of the tree).
     * @return The new merkle root.
     */
    function computeRoot(
        bytes32 _leaf,
        uint256 _index,
        bytes32[] memory _siblings
    ) internal pure returns (bytes32) {
        bytes32 computedRoot = _leaf;

        for (uint256 i = 0; i < _siblings.length; i++) {
            if ((_index & 1) == 1) {
                computedRoot = keccak256(abi.encodePacked(_siblings[i], computedRoot));
            } else {
                computedRoot = keccak256(abi.encodePacked(computedRoot, _siblings[i]));
            }
            _index >>= 1;
        }

        return computedRoot;
    }
}

File 16 of 17 : Transitions.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;
pragma experimental ABIEncoderV2;

import "../libraries/DataTypes.sol";

library Transitions {
    // Transition Types
    uint8 public constant TRANSITION_TYPE_INVALID = 0;
    uint8 public constant TRANSITION_TYPE_DEPOSIT = 1;
    uint8 public constant TRANSITION_TYPE_WITHDRAW = 2;
    uint8 public constant TRANSITION_TYPE_COMMIT = 3;
    uint8 public constant TRANSITION_TYPE_UNCOMMIT = 4;
    uint8 public constant TRANSITION_TYPE_SYNC_COMMITMENT = 5;
    uint8 public constant TRANSITION_TYPE_SYNC_BALANCE = 6;
    uint8 public constant TRANSITION_TYPE_INIT = 7;

    function extractTransitionType(bytes memory _bytes) internal pure returns (uint8) {
        uint8 transitionType;
        assembly {
            transitionType := mload(add(_bytes, 0x20))
        }
        return transitionType;
    }

    function decodeDepositTransition(bytes memory _rawBytes)
        internal
        pure
        returns (DataTypes.DepositTransition memory)
    {
        (uint8 transitionType, bytes32 stateRoot, address account, uint32 accountId, uint32 assetId, uint256 amount) =
            abi.decode((_rawBytes), (uint8, bytes32, address, uint32, uint32, uint256));
        DataTypes.DepositTransition memory transition =
            DataTypes.DepositTransition(transitionType, stateRoot, account, accountId, assetId, amount);
        return transition;
    }

    function decodeWithdrawTransition(bytes memory _rawBytes)
        internal
        pure
        returns (DataTypes.WithdrawTransition memory)
    {
        (
            uint8 transitionType,
            bytes32 stateRoot,
            address account,
            uint32 accountId,
            uint32 assetId,
            uint256 amount,
            uint64 timestamp,
            bytes memory signature
        ) = abi.decode((_rawBytes), (uint8, bytes32, address, uint32, uint32, uint256, uint64, bytes));
        DataTypes.WithdrawTransition memory transition =
            DataTypes.WithdrawTransition(
                transitionType,
                stateRoot,
                account,
                accountId,
                assetId,
                amount,
                timestamp,
                signature
            );
        return transition;
    }

    function decodeCommitTransition(bytes memory _rawBytes) internal pure returns (DataTypes.CommitTransition memory) {
        (
            uint8 transitionType,
            bytes32 stateRoot,
            uint32 accountId,
            uint32 strategyId,
            uint256 assetAmount,
            uint64 timestamp,
            bytes memory signature
        ) = abi.decode((_rawBytes), (uint8, bytes32, uint32, uint32, uint256, uint64, bytes));
        DataTypes.CommitTransition memory transition =
            DataTypes.CommitTransition(
                transitionType,
                stateRoot,
                accountId,
                strategyId,
                assetAmount,
                timestamp,
                signature
            );
        return transition;
    }

    function decodeUncommitTransition(bytes memory _rawBytes)
        internal
        pure
        returns (DataTypes.UncommitTransition memory)
    {
        (
            uint8 transitionType,
            bytes32 stateRoot,
            uint32 accountId,
            uint32 strategyId,
            uint256 stTokenAmount,
            uint64 timestamp,
            bytes memory signature
        ) = abi.decode((_rawBytes), (uint8, bytes32, uint32, uint32, uint256, uint64, bytes));
        DataTypes.UncommitTransition memory transition =
            DataTypes.UncommitTransition(
                transitionType,
                stateRoot,
                accountId,
                strategyId,
                stTokenAmount,
                timestamp,
                signature
            );
        return transition;
    }

    function decodeCommitmentSyncTransition(bytes memory _rawBytes)
        internal
        pure
        returns (DataTypes.CommitmentSyncTransition memory)
    {
        (
            uint8 transitionType,
            bytes32 stateRoot,
            uint32 strategyId,
            uint256 pendingCommitAmount,
            uint256 pendingUncommitAmount
        ) = abi.decode((_rawBytes), (uint8, bytes32, uint32, uint256, uint256));
        DataTypes.CommitmentSyncTransition memory transition =
            DataTypes.CommitmentSyncTransition(
                transitionType,
                stateRoot,
                strategyId,
                pendingCommitAmount,
                pendingUncommitAmount
            );
        return transition;
    }

    function decodeBalanceSyncTransition(bytes memory _rawBytes)
        internal
        pure
        returns (DataTypes.BalanceSyncTransition memory)
    {
        (uint8 transitionType, bytes32 stateRoot, uint32 strategyId, int256 newAssetDelta) =
            abi.decode((_rawBytes), (uint8, bytes32, uint32, int256));
        DataTypes.BalanceSyncTransition memory transition =
            DataTypes.BalanceSyncTransition(transitionType, stateRoot, strategyId, newAssetDelta);
        return transition;
    }

    function decodeInitTransition(bytes memory _rawBytes) internal pure returns (DataTypes.InitTransition memory) {
        (uint8 transitionType, bytes32 stateRoot) = abi.decode((_rawBytes), (uint8, bytes32));
        DataTypes.InitTransition memory transition = DataTypes.InitTransition(transitionType, stateRoot);
        return transition;
    }
}

File 17 of 17 : IStrategy.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

/**
 * @title Interface for DeFi strategies
 *
 * @notice Strategy provides abstraction for a DeFi strategy. A single type of asset token can be committed to or
 * uncommitted from a strategy per instructions from L2. Periodically, the yield is reflected in the asset balance and
 * synced back to L2.
 */
interface IStrategy {
    event Committed(uint256 commitAmount);

    event UnCommitted(uint256 uncommitAmount);

    event ControllerChanged(address previousController, address newController);

    /**
     * @dev Returns the address of the asset token.
     */
    function getAssetAddress() external view returns (address);

    /**
     * @dev Harvests protocol tokens and update the asset balance.
     */
    function harvest() external;

    /**
     * @dev Returns the asset balance. May sync with the protocol to update the balance.
     */
    function syncBalance() external returns (uint256);

    /**
     * @dev Commits to strategy per instructions from L2.
     *
     * @param commitAmount The aggregated asset amount to commit.
     */
    function aggregateCommit(uint256 commitAmount) external;

    /**
     * @dev Uncommits from strategy per instructions from L2.
     *
     * @param uncommitAmount The aggregated asset amount to uncommit.
     */
    function aggregateUncommit(uint256 uncommitAmount) external;
}

Settings
{
  "evmVersion": "istanbul",
  "libraries": {},
  "metadata": {
    "bytecodeHash": "ipfs",
    "useLiteralContent": true
  },
  "optimizer": {
    "enabled": true,
    "runs": 800
  },
  "remappings": [],
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "abi"
      ]
    }
  }
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"uint256","name":"_blockChallengePeriod","type":"uint256"},{"internalType":"uint256","name":"_maxPriorityTxDelay","type":"uint256"},{"internalType":"address","name":"_transitionDisputerAddress","type":"address"},{"internalType":"address","name":"_registryAddress","type":"address"},{"internalType":"address","name":"_operator","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint32","name":"assetId","type":"uint32"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"depositId","type":"uint256"}],"name":"AssetDeposited","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint32","name":"assetId","type":"uint32"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"AssetWithdrawn","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint32","name":"strategyId","type":"uint32"},{"indexed":false,"internalType":"int256","name":"delta","type":"int256"},{"indexed":false,"internalType":"uint256","name":"syncId","type":"uint256"}],"name":"BalanceSync","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"previousOperator","type":"address"},{"indexed":false,"internalType":"address","name":"newOperator","type":"address"}],"name":"OperatorChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"blockId","type":"uint256"}],"name":"RollupBlockCommitted","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"blockId","type":"uint256"}],"name":"RollupBlockExecuted","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"blockId","type":"uint256"},{"indexed":false,"internalType":"string","name":"reason","type":"string"}],"name":"RollupBlockReverted","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"stateMutability":"payable","type":"fallback"},{"inputs":[],"name":"blockChallengePeriod","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"blocks","outputs":[{"internalType":"bytes32","name":"rootHash","type":"bytes32"},{"internalType":"bytes32","name":"intentHash","type":"bytes32"},{"internalType":"uint128","name":"blockTime","type":"uint128"},{"internalType":"uint128","name":"blockSize","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_blockId","type":"uint256"},{"internalType":"bytes[]","name":"_transitions","type":"bytes[]"}],"name":"commitBlock","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"countExecuted","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_asset","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"deposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_weth","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"depositETH","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"disputePriorityTxDelay","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"bytes","name":"transition","type":"bytes"},{"internalType":"uint256","name":"blockId","type":"uint256"},{"internalType":"uint32","name":"index","type":"uint32"},{"internalType":"bytes32[]","name":"siblings","type":"bytes32[]"}],"internalType":"struct DataTypes.TransitionProof","name":"_prevTransitionProof","type":"tuple"},{"components":[{"internalType":"bytes","name":"transition","type":"bytes"},{"internalType":"uint256","name":"blockId","type":"uint256"},{"internalType":"uint32","name":"index","type":"uint32"},{"internalType":"bytes32[]","name":"siblings","type":"bytes32[]"}],"internalType":"struct DataTypes.TransitionProof","name":"_invalidTransitionProof","type":"tuple"},{"components":[{"internalType":"bytes32","name":"stateRoot","type":"bytes32"},{"components":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint32","name":"accountId","type":"uint32"},{"internalType":"uint256[]","name":"idleAssets","type":"uint256[]"},{"internalType":"uint256[]","name":"stTokens","type":"uint256[]"},{"internalType":"uint64","name":"timestamp","type":"uint64"}],"internalType":"struct DataTypes.AccountInfo","name":"value","type":"tuple"},{"internalType":"uint32","name":"index","type":"uint32"},{"internalType":"bytes32[]","name":"siblings","type":"bytes32[]"}],"internalType":"struct DataTypes.AccountProof","name":"_accountProof","type":"tuple"},{"components":[{"internalType":"bytes32","name":"stateRoot","type":"bytes32"},{"components":[{"internalType":"uint32","name":"assetId","type":"uint32"},{"internalType":"uint256","name":"assetBalance","type":"uint256"},{"internalType":"uint256","name":"stTokenSupply","type":"uint256"},{"internalType":"uint256","name":"pendingCommitAmount","type":"uint256"},{"internalType":"uint256","name":"pendingUncommitAmount","type":"uint256"}],"internalType":"struct DataTypes.StrategyInfo","name":"value","type":"tuple"},{"internalType":"uint32","name":"index","type":"uint32"},{"internalType":"bytes32[]","name":"siblings","type":"bytes32[]"}],"internalType":"struct DataTypes.StrategyProof","name":"_strategyProof","type":"tuple"}],"name":"disputeTransition","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"drainETH","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_asset","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"drainToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes[]","name":"_intents","type":"bytes[]"}],"name":"executeBlock","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getCurrentBlockId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxPriorityTxDelay","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"netDepositLimits","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"netDeposits","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"operator","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"pendingBalanceSyncs","outputs":[{"internalType":"bytes32","name":"bhash","type":"bytes32"},{"internalType":"uint64","name":"blockId","type":"uint64"},{"internalType":"enum RollupChain.PendingBalanceSyncStatus","name":"status","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingBalanceSyncsCommitHead","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingBalanceSyncsExecuteHead","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingBalanceSyncsTail","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"pendingDeposits","outputs":[{"internalType":"bytes32","name":"dhash","type":"bytes32"},{"internalType":"uint64","name":"blockId","type":"uint64"},{"internalType":"enum RollupChain.PendingDepositStatus","name":"status","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingDepositsCommitHead","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingDepositsExecuteHead","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingDepositsTail","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"pendingWithdrawCommits","outputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint32","name":"assetId","type":"uint32"},{"internalType":"uint256","name":"amount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint32","name":"","type":"uint32"}],"name":"pendingWithdraws","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_blockChallengePeriod","type":"uint256"}],"name":"setBlockChallengePeriod","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_maxPriorityTxDelay","type":"uint256"}],"name":"setMaxPriorityTxDelay","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_asset","type":"address"},{"internalType":"uint256","name":"_limit","type":"uint256"}],"name":"setNetDepositLimit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_operator","type":"address"}],"name":"setOperator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"","type":"uint32"}],"name":"strategyAssetBalances","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"_strategyId","type":"uint32"}],"name":"syncBalance","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"},{"internalType":"address","name":"_asset","type":"address"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"},{"internalType":"address","name":"_weth","type":"address"}],"name":"withdrawETH","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]

608060405260006004553480156200001657600080fd5b506040516200525a3803806200525a83398101604081905262000039916200010c565b600062000045620000eb565b600080546001600160a01b0319166001600160a01b0383169081178255604051929350917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a3506000805460ff60a01b19169055601294909455601392909255600180546001600160a01b039283166001600160a01b03199182161790915560028054938316938216939093179092556014805491909316911617905562000169565b3390565b80516001600160a01b03811681146200010757600080fd5b919050565b600080600080600060a0868803121562000124578081fd5b85519450602086015193506200013d60408701620000ef565b92506200014d60608701620000ef565b91506200015d60808701620000ef565b90509295509295909350565b6150e180620001796000396000f3fe6080604052600436106102bf5760003560e01c80639ae2369d1161016e578063b90405da116100cb578063ec8dedb71161007f578063f25b3f9911610064578063f25b3f99146106ee578063f2fde38b1461071e578063f940e3851461073e576102c6565b8063ec8dedb7146106b9578063ed038f5c146106d9576102c6565b8063cb5f3129116100b0578063cb5f312914610659578063cdcab4a314610679578063dfe9fbd114610699576102c6565b8063b90405da14610624578063c145e2a614610644576102c6565b8063a9adf05511610122578063aef72fde11610107578063aef72fde146105da578063b3ab15fb146105ef578063b64ccb491461060f576102c6565b8063a9adf055146105b0578063aedb2727146105c5576102c6565b8063a1545a5211610153578063a1545a5214610541578063a35a2eda14610561578063a793279414610590576102c6565b80639ae2369d146105015780639d4323be14610521576102c6565b8063570ca7351161021c5780638456cb59116101d05780638da5cb5b116101b55780638da5cb5b146104b7578063978d602a146104cc5780639790525f146104ec576102c6565b80638456cb59146104825780638bdc623214610497576102c6565b806370d063051161020157806370d063051461043857806370ec737214610458578063715018a61461046d576102c6565b8063570ca735146103f45780635c975abb14610416576102c6565b80632e5990541161027357806341db203c1161025857806341db203c1461039f57806347e7ef24146103bf5780634f17ceb2146103df576102c6565b80632e599054146103775780633f4ba83a1461038a576102c6565b8063142a2b0a116102a4578063142a2b0a14610313578063239cbf411461034257806325fe097514610357576102c6565b8063097e24a0146102c85780630bd9e1f9146102e8576102c6565b366102c657005b005b3480156102d457600080fd5b506102c66102e33660046140ae565b61075e565b3480156102f457600080fd5b506102fd610f48565b60405161030a9190614e73565b60405180910390f35b34801561031f57600080fd5b5061033361032e3660046141e1565b610f4e565b60405161030a939291906147e3565b34801561034e57600080fd5b506102fd610f7d565b34801561036357600080fd5b506102fd610372366004614081565b610f83565b6102c6610385366004614056565b610fa0565b34801561039657600080fd5b506102c661106e565b3480156103ab57600080fd5b506102fd6103ba36600461427c565b6110da565b3480156103cb57600080fd5b506102c66103da366004614056565b6110ec565b3480156103eb57600080fd5b506102fd61115c565b34801561040057600080fd5b50610409611162565b60405161030a9190614730565b34801561042257600080fd5b5061042b611171565b60405161030a91906147b1565b34801561044457600080fd5b506102fd610453366004613fe6565b611181565b34801561046457600080fd5b506102fd611193565b34801561047957600080fd5b506102c6611199565b34801561048e57600080fd5b506102c6611245565b3480156104a357600080fd5b506102c66104b2366004614134565b6112af565b3480156104c357600080fd5b50610409611488565b3480156104d857600080fd5b506102c66104e736600461401e565b611497565b3480156104f857600080fd5b506102fd6115d3565b34801561050d57600080fd5b506102c661051c36600461427c565b6115d9565b34801561052d57600080fd5b506102c661053c366004614056565b6118cf565b34801561054d57600080fd5b506102fd61055c366004613fe6565b611995565b34801561056d57600080fd5b5061058161057c36600461425b565b6119a7565b60405161030a9392919061475e565b34801561059c57600080fd5b506103336105ab3660046141e1565b6119fa565b3480156105bc57600080fd5b506102fd611a29565b3480156105d157600080fd5b506102fd611a2f565b3480156105e657600080fd5b506102fd611a35565b3480156105fb57600080fd5b506102c661060a366004613fe6565b611a3f565b34801561061b57600080fd5b506102fd611b0a565b34801561063057600080fd5b506102c661063f3660046141e1565b611b10565b34801561065057600080fd5b506102c6611b77565b34801561066557600080fd5b506102c66106743660046141e1565b611c2f565b34801561068557600080fd5b506102c66106943660046141e1565b611c96565b3480156106a557600080fd5b506102c66106b4366004614056565b611dc4565b3480156106c557600080fd5b506102c66106d4366004614211565b611ee9565b3480156106e557600080fd5b506102fd6127bb565b3480156106fa57600080fd5b5061070e6107093660046141e1565b6127c1565b60405161030a94939291906147bc565b34801561072a57600080fd5b506102c6610739366004613fe6565b612808565b34801561074a57600080fd5b506102c661075936600461401e565b61290a565b610766611171565b156107ab576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b60045460035481106107d85760405162461bcd60e51b81526004016107cf90614b72565b60405180910390fd5b43601254600383815481106107e957fe5b60009182526020909120600260039092020101546001600160801b031601106108245760405162461bcd60e51b81526004016107cf90614a4c565b600082156108fc5760008367ffffffffffffffff8111801561084557600080fd5b5060405190808252806020026020018201604052801561086f578160200160208202803683370190505b50905060005b848110156108d05785858281811061088957fe5b905060200281019061089b9190614ee5565b6040516108a99291906146e4565b60405180910390208282815181106108bd57fe5b6020908102919091010152600101610875565b50806040516020016108e291906146ae565b604051602081830303815290604052805190602001209150505b6003828154811061090957fe5b90600052602060002090600302016001015481146109395760405162461bcd60e51b81526004016107cf90614b3d565b60005b83811015610c8a5760006109a186868481811061095557fe5b90506020028101906109679190614ee5565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061297e92505050565b6002546040808301519051635a2f9ddb60e11b81529293506000926001600160a01b039092169163b45f3bb6916109da91600401614eb6565b60206040518083038186803b1580156109f257600080fd5b505afa158015610a06573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a2a9190614002565b90506001600160a01b038116610a525760405162461bcd60e51b81526004016107cf90614a15565b6080820151606083015182911015610bae576000610a81846080015185606001516129e490919063ffffffff16565b9050610b098382846001600160a01b031663670ab5e96040518163ffffffff1660e01b815260040160206040518083038186803b158015610ac157600080fd5b505afa158015610ad5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610af99190614002565b6001600160a01b03169190612a41565b6040516304df9d0360e01b81526001600160a01b038316906304df9d0390610b35908490600401614e73565b600060405180830381600087803b158015610b4f57600080fd5b505af1158015610b63573d6000803e3d6000fd5b5050505060408481015163ffffffff9081166000908152600f6020529190912054610b90918390612b2c16565b60408086015163ffffffff166000908152600f602052205550610c7f565b826080015183606001511015610c7f576000610bdb846060015185608001516129e490919063ffffffff16565b604051633d709f1560e21b81529091506001600160a01b0383169063f5c27c5490610c0a908490600401614e73565b600060405180830381600087803b158015610c2457600080fd5b505af1158015610c38573d6000803e3d6000fd5b5050505060408481015163ffffffff9081166000908152600f6020529190912054610c659183906129e416565b60408086015163ffffffff166000908152600f6020522055505b50505060010161093c565b506004805460010190555b6007546006541015610d7057600654600090815260056020908152604080832081516060810183528154815260018083015467ffffffffffffffff81169583019590955290939192840191600160401b900460ff1690811115610cf457fe5b6001811115610cff57fe5b9052509050600181604001516001811115610d1657fe5b141580610d30575082816020015167ffffffffffffffff16115b15610d3b5750610d70565b506006805460009081526005602052604081209081556001908101805468ffffffffffffffffff191690558154019055610c95565b60005b600083815260096020526040902054811015610e18576000838152600960205260408120805483908110610da357fe5b6000918252602080832060408051606081018252600290940290910180546001600160a01b03811680865263ffffffff600160a01b9092048216868601908152600193840154968501879052908752600a85528387209051909116865290925290922080549091019055919091019050610d73565b506000828152600960205260408120610e3091613dd2565b600d54600c541015610f0b57600c546000908152600b6020908152604080832081516060810183528154815260018083015467ffffffffffffffff81169583019590955290939192840191600160401b900460ff1690811115610e8f57fe5b6001811115610e9a57fe5b9052509050600181604001516001811115610eb157fe5b141580610ecb575082816020015167ffffffffffffffff16115b15610ed65750610f0b565b50600c80546000908152600b602052604081209081556001908101805468ffffffffffffffffff191690558154019055610e30565b7f7dcbc30b0913ee9985c884dea0928f45844ec4f1feb3ab49bb25fdeb1fd838ce82604051610f3a9190614e73565b60405180910390a150505050565b60075481565b600b602052600090815260409020805460019091015467ffffffffffffffff811690600160401b900460ff1683565b600c5481565b600a60209081526000928352604080842090915290825290205481565b610fa8611171565b15610fed576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b80341461100c5760405162461bcd60e51b81526004016107cf906149de565b6110168282612b8d565b816001600160a01b031663d0e30db0826040518263ffffffff1660e01b81526004016000604051808303818588803b15801561105157600080fd5b505af1158015611065573d6000803e3d6000fd5b50505050505050565b611076612dab565b6001600160a01b0316611087611488565b6001600160a01b0316146110d0576040805162461bcd60e51b81526020600482018190526024820152600080516020615032833981519152604482015290519081900360640190fd5b6110d8612daf565b565b600f6020526000908152604090205481565b6110f4611171565b15611139576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b6111438282612b8d565b6111586001600160a01b038316333084612e52565b5050565b600e5481565b6014546001600160a01b031681565b600054600160a01b900460ff1690565b60106020526000908152604090205481565b60135481565b6111a1612dab565b6001600160a01b03166111b2611488565b6001600160a01b0316146111fb576040805162461bcd60e51b81526020600482018190526024820152600080516020615032833981519152604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b61124d612dab565b6001600160a01b031661125e611488565b6001600160a01b0316146112a7576040805162461bcd60e51b81526020600482018190526024820152600080516020615032833981519152604482015290519081900360640190fd5b6110d8612eac565b6000836020013590506000600382815481106112c757fe5b6000918252602091829020604080516080810182526003909302909101805483526001810154938301939093526002909201546001600160801b03808216938301849052600160801b9091041660608201526012549092504391011161133f5760405162461bcd60e51b81526004016107cf90614ba9565b60006060600160009054906101000a90046001600160a01b03166001600160a01b031663092dff5860e01b8989898960038e602001358154811061137f57fe5b600091825260209091206002546040516113b29796959493600302909201918c916001600160a01b031690602401614cf1565b60408051601f198184030181529181526020820180516001600160e01b03166001600160e01b03199094169390931790925290516113f091906146f4565b6000604051808303816000865af19150503d806000811461142d576040519150601f19603f3d011682016040523d82523d6000602084013e611432565b606091505b50909250905081156114665760008180602001905181019061145491906140ee565b90506114608582612f35565b5061147e565b60405162461bcd60e51b81526004016107cf90614848565b5050505050505050565b6000546001600160a01b031690565b61149f611171565b156114e4576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b60006114f083836130c6565b604051632e1a7d4d60e01b81529091506001600160a01b03831690632e1a7d4d9061151f908490600401614e73565b600060405180830381600087803b15801561153957600080fd5b505af115801561154d573d6000803e3d6000fd5b505050506000836001600160a01b03168260405161156a90614710565b60006040518083038185875af1925050503d80600081146115a7576040519150601f19603f3d011682016040523d82523d6000602084013e6115ac565b606091505b50509050806115cd5760405162461bcd60e51b81526004016107cf90614970565b50505050565b60065481565b6115e1611171565b15611626576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b6014546001600160a01b031633146116505760405162461bcd60e51b81526004016107cf90614c4c565b600254604051635a2f9ddb60e11b81526000916001600160a01b03169063b45f3bb690611681908590600401614eb6565b60206040518083038186803b15801561169957600080fd5b505afa1580156116ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116d19190614002565b90506001600160a01b0381166116f95760405162461bcd60e51b81526004016107cf90614a15565b6000816001600160a01b031663fd9c652b6040518163ffffffff1660e01b8152600401602060405180830381600087803b15801561173657600080fd5b505af115801561174a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061176e91906141f9565b63ffffffff84166000908152600f602052604081205491925081831061179f5761179883836129e4565b90506117af565b6117a982846129e4565b60000390505b63ffffffff85166000908152600f60209081526040808320869055600e80546001810190915590519092916117e8918991869101614713565b60408051601f19818403018152828252805160209182012060608401835280845260035467ffffffffffffffff169184019190915292508101600090526000838152600b602090815260409182902083518155908301516001808301805467ffffffffffffffff191667ffffffffffffffff9093169290921780835593850151929360ff60401b191690600160401b90849081111561188357fe5b02179055509050507f0fd8e389fca8b6a7e1044129d3ab36e1d3c299a2100fdedd302084044b79f8418784846040516118be93929190614ec7565b60405180910390a150505050505050565b6118d7611171565b61191f576040805162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604482015290519081900360640190fd5b611927612dab565b6001600160a01b0316611938611488565b6001600160a01b031614611981576040805162461bcd60e51b81526020600482018190526024820152600080516020615032833981519152604482015290519081900360640190fd5b6111586001600160a01b03831633836132a5565b60116020526000908152604090205481565b600960205281600052604060002081815481106119c357600080fd5b6000918252602090912060029091020180546001909101546001600160a01b0382169350600160a01b90910463ffffffff16915083565b6005602052600090815260409020805460019091015467ffffffffffffffff811690600160401b900460ff1683565b600d5481565b60085481565b6003546000190190565b611a47612dab565b6001600160a01b0316611a58611488565b6001600160a01b031614611aa1576040805162461bcd60e51b81526020600482018190526024820152600080516020615032833981519152604482015290519081900360640190fd5b6014546040517fd58299b712891143e76310d5e664c4203c940a67db37cf856bdaa3c5c76a802c91611ae0916001600160a01b03909116908490614744565b60405180910390a1601480546001600160a01b0319166001600160a01b0392909216919091179055565b60125481565b611b18612dab565b6001600160a01b0316611b29611488565b6001600160a01b031614611b72576040805162461bcd60e51b81526020600482018190526024820152600080516020615032833981519152604482015290519081900360640190fd5b601255565b6000611b81611a35565b90506008546007541015611bd057601354600754600090815260056020526040902060010154611bbc90839067ffffffffffffffff166129e4565b1115611bd057611bca612eac565b506110d8565b600e54600d541015611c1757601354600d546000908152600b6020526040902060010154611c0990839067ffffffffffffffff166129e4565b1115611c1757611bca612eac565b60405162461bcd60e51b81526004016107cf90614be0565b611c37612dab565b6001600160a01b0316611c48611488565b6001600160a01b031614611c91576040805162461bcd60e51b81526020600482018190526024820152600080516020615032833981519152604482015290519081900360640190fd5b601355565b611c9e611171565b611ce6576040805162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604482015290519081900360640190fd5b611cee612dab565b6001600160a01b0316611cff611488565b6001600160a01b031614611d48576040805162461bcd60e51b81526020600482018190526024820152600080516020615032833981519152604482015290519081900360640190fd5b6000336001600160a01b031682604051611d6190614710565b60006040518083038185875af1925050503d8060008114611d9e576040519150601f19603f3d011682016040523d82523d6000602084013e611da3565b606091505b50509050806111585760405162461bcd60e51b81526004016107cf906149a7565b611dcc612dab565b6001600160a01b0316611ddd611488565b6001600160a01b031614611e26576040805162461bcd60e51b81526020600482018190526024820152600080516020615032833981519152604482015290519081900360640190fd5b60025460405163639260df60e01b81526000916001600160a01b03169063639260df90611e57908690600401614730565b60206040518083038186803b158015611e6f57600080fd5b505afa158015611e83573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ea79190614298565b905063ffffffff8116611ecc5760405162461bcd60e51b81526004016107cf90614c15565b506001600160a01b03909116600090815260116020526040902055565b611ef1611171565b15611f36576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b6014546001600160a01b03163314611f605760405162461bcd60e51b81526004016107cf90614c4c565b6003548314611f815760405162461bcd60e51b81526004016107cf90614cba565b60008167ffffffffffffffff81118015611f9a57600080fd5b50604051908082528060200260200182016040528015611fc4578160200160208202803683370190505b50905060005b8281101561202557838382818110611fde57fe5b9050602002810190611ff09190614ee5565b604051611ffe9291906146e4565b604051809103902082828151811061201257fe5b6020908102919091010152600101611fca565b506000612031826132f7565b905060008367ffffffffffffffff8111801561204c57600080fd5b50604051908082528060200260200182016040528015612076578160200160208202803683370190505b5090506000805b858110156125955760006120e288888481811061209657fe5b90506020028101906120a89190614ee5565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061399b92505050565b905060ff8116600314806120f9575060ff81166004145b15612104575061258d565b60ff81166005141561213a5781848480600101955063ffffffff168151811061212957fe5b60200260200101818152505061258b565b60ff8116600114156122d65760006121a389898581811061215757fe5b90506020028101906121699190614ee5565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506139a292505050565b6007546008549192509081106121cb5760405162461bcd60e51b81526004016107cf90614913565b600081815260056020908152604080832081516060810183528154815260018083015467ffffffffffffffff81169583019590955290939192840191600160401b900460ff169081111561221b57fe5b600181111561222657fe5b8152505090506000836040015184608001518560a0015160405160200161224f93929190614677565b6040516020818303038152906040528051906020012090508082600001511461228a5760405162461bcd60e51b81526004016107cf9061487f565b505060009081526005602052604090206001908101805460ff60401b1916600160401b1767ffffffffffffffff191667ffffffffffffffff8d161790556007805490910190555061258b565b60ff8116600214156123f957600061233f8989858181106122f357fe5b90506020028101906123059190614ee5565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250613a1992505050565b60008b81526009602090815260408083208151606081018352828601516001600160a01b039081168252608087015163ffffffff90811683870190815260a090980151948301948552835460018181018655948852959096209151600290950290910180549651909516600160a01b027fffffffffffffffff00000000ffffffffffffffffffffffffffffffffffffffff949091166001600160a01b0319909616959095179290921693909317825591519101555061258b565b60ff81166006141561258b57600061246289898581811061241657fe5b90506020028101906124289190614ee5565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250613aab92505050565b600d54600e5491925090811061248a5760405162461bcd60e51b81526004016107cf90614a83565b6000818152600b6020908152604080832081516060810183528154815260018083015467ffffffffffffffff81169583019590955290939192840191600160401b900460ff16908111156124da57fe5b60018111156124e557fe5b815250509050600083604001518460600151604051602001612508929190614713565b604051602081830303815290604052805190602001209050808260000151146125435760405162461bcd60e51b81526004016107cf90614ae0565b50506000908152600b602052604090206001908101805460ff60401b1916600160401b1767ffffffffffffffff191667ffffffffffffffff8d16179055600d80549091019055505b505b60010161207d565b50600063ffffffff8216156126935760008263ffffffff1667ffffffffffffffff811180156125c357600080fd5b506040519080825280602002602001820160405280156125ed578160200160208202803683370190505b50905060005b8363ffffffff1681101561266757888886838151811061260f57fe5b602002602001015181811061262057fe5b90506020028101906126329190614ee5565b6040516126409291906146e4565b604051809103902082828151811061265457fe5b60209081029190910101526001016125f3565b508060405160200161267991906146ae565b604051602081830303815290604052805190602001209150505b60408051608081018252858152602081018381526001600160801b034381168385019081528a821660608501908152600380546001810182556000829052865191027fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b81019190915593517fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85c85015590517fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85d909301805491518316600160801b029383166fffffffffffffffffffffffffffffffff199092169190911790911691909117905590517f8f398593f037f47ea1fc7ede311023f216c9f01cea5795d6df8c3caf1eaecff0906127a8908b90614e73565b60405180910390a1505050505050505050565b60045481565b600381815481106127d157600080fd5b60009182526020909120600390910201805460018201546002909201549092506001600160801b0380821691600160801b90041684565b612810612dab565b6001600160a01b0316612821611488565b6001600160a01b03161461286a576040805162461bcd60e51b81526020600482018190526024820152600080516020615032833981519152604482015290519081900360640190fd5b6001600160a01b0381166128af5760405162461bcd60e51b8152600401808060200182810382526026815260200180614fe66026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b612912611171565b15612957576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b600061296383836130c6565b90506129796001600160a01b03831684836132a5565b505050565b612986613df6565b6000806000806000868060200190518101906129a29190614429565b6040805160a08101825260ff9096168652602086019490945263ffffffff9092169284019290925260608301919091526080820152955050505050505b919050565b600082821115612a3b576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b6000612ad782856001600160a01b031663dd62ed3e30876040518363ffffffff1660e01b815260040180836001600160a01b03168152602001826001600160a01b031681526020019250505060206040518083038186803b158015612aa557600080fd5b505afa158015612ab9573d6000803e3d6000fd5b505050506040513d6020811015612acf57600080fd5b505190612b2c565b604080516001600160a01b038616602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663095ea7b360e01b1790529091506115cd908590613b05565b600082820183811015612b86576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b9392505050565b60025460405163639260df60e01b815233916000916001600160a01b039091169063639260df90612bc2908790600401614730565b60206040518083038186803b158015612bda57600080fd5b505afa158015612bee573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c129190614298565b905063ffffffff8116612c375760405162461bcd60e51b81526004016107cf90614c15565b6001600160a01b038416600090815260106020526040812054612c5a9085612b2c565b6001600160a01b038616600090815260116020526040902054909150811115612c955760405162461bcd60e51b81526004016107cf906148dc565b6001600160a01b038516600090815260106020908152604080832084905560088054600181019091559051909291612cd391879187918a9101614677565b60408051601f19818403018152828252805160209182012060608401835280845260035467ffffffffffffffff1691840191909152925081016000905260008381526005602090815260409182902083518155908301516001808301805467ffffffffffffffff191667ffffffffffffffff9093169290921780835593850151929360ff60401b191690600160401b908490811115612d6e57fe5b02179055509050507fba6b61ba25da48510b2a171056f2d2ea3d73c9c0618aa8fdbafa7e991f82ee25858588856040516118be9493929190614785565b3390565b612db7611171565b612dff576040805162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604482015290519081900360640190fd5b6000805460ff60a01b191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa612e35612dab565b604080516001600160a01b039092168252519081900360200190a1565b604080516001600160a01b0380861660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b1790526115cd908590613b05565b612eb4611171565b15612ef9576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b6000805460ff60a01b1916600160a01b1790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258612e35612dab565b612f3d612eac565b600354821015612f8957600380546000198101600052600960205280612f5f57fe5b60008281526020812060036000199093019283020181815560018101829055600201559055612f3d565b6006546000905b6008548110156130075760008181526005602052604090206001015467ffffffffffffffff168411612fff5781612fcb576007819055600191505b6000818152600560205260409020600101805467ffffffffffffffff191667ffffffffffffffff86161760ff60401b191690555b600101612f90565b5050600c546000905b600e54811015613087576000818152600b602052604090206001015467ffffffffffffffff16841161307f578161304b57600d819055600191505b6000818152600b60205260409020600101805467ffffffffffffffff191667ffffffffffffffff86161760ff60401b191690555b600101613010565b507f36a66b31987e7e6abdbfed3b1968c201f8c3a138705e5087cd66e221faf1e1ff83836040516130b9929190614e7c565b60405180910390a1505050565b60025460405163639260df60e01b815260009182916001600160a01b039091169063639260df906130fb908690600401614730565b60206040518083038186803b15801561311357600080fd5b505afa158015613127573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061314b9190614298565b905060008163ffffffff16116131735760405162461bcd60e51b81526004016107cf90614c83565b6001600160a01b0384166000908152600a6020908152604080832063ffffffff85168452909152902054806131ba5760405162461bcd60e51b81526004016107cf90614811565b6001600160a01b0384166000908152601060205260409020548111156131f8576001600160a01b038416600090815260106020526040812055613235565b6001600160a01b03841660009081526010602052604090205461321b90826129e4565b6001600160a01b0385166000908152601060205260409020555b6001600160a01b0385166000908152600a6020908152604080832063ffffffff8616845290915280822091909155517fa8d2059deb1787b03478662fb43905086ccfe9e47b2e454d0186076b49539586906132959087908590859061475e565b60405180910390a1949350505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052612979908490613b05565b6000808251116133385760405162461bcd60e51b81526004018080602001828103825260308152602001806150526030913960400191505060405180910390fd5b81516001141561335e578160008151811061334f57fe5b602002602001015190506129df565b60408051610400810182527f290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e56381527f633dc4d7da7256660a892f8f1604a44b5432649cc8ec5cb3ced4c4e6ac94dd1d60208201527f890740a8eb06ce9be422cb8da5cdafc2b58c0a5e24036c578de2a433c828ff7d818301527f3b8ec09e026fdc305365dfc94e189a81b38c7597b3d941c279f042e8206e0bd86060808301919091527fecd50eee38e386bd62be9bedb990706951b65fe053bd9d8a521af753d139e2da60808301527fdefff6d330bb5403f63b14f33b578274160de3a50df4efecf0e0db73bcdd3da560a08301527f617bdd11f7c0a11f49db22f629387a12da7596f9d1704d7465177c63d88ec7d760c08301527f292c23a9aa1d8bea7e2435e555a4a60e379a5a35f3f452bae60121073fb6eead60e08301527fe1cea92ed99acdcb045a6726b2f87107e8a61620a232cf4d7d5b5766b3952e106101008301527f7ad66c0a68c72cb89e4fb4303841966e4062a76ab97451e3b9fb526a5ceb7f826101208301527fe026cc5a4aed3c22a58cbd3d2ac754c9352c5436f638042dca99034e836365166101408301527f3d04cffd8b46a874edf5cfae63077de85f849a660426697b06a829c70dd1409c6101608301527fad676aa337a485e4728a0b240d92b3ef7b3c372d06d189322bfd5f61f1e7203e6101808301527fa2fca4a49658f9fab7aa63289c91b7c7b6c832a6d0e69334ff5b0a3483d09dab6101a08301527f4ebfd9cd7bca2505f7bef59cc1c12ecc708fff26ae4af19abe852afe9e20c8626101c08301527f2def10d13dd169f550f578bda343d9717a138562e0093b380a1120789d53cf106101e08301527f776a31db34a1a0a7caaf862cffdfff1789297ffadc380bd3d39281d340abd3ad6102008301527fe2e7610b87a5fdf3a72ebe271287d923ab990eefac64b6e59d79f8b7e08c46e36102208301527f504364a5c6858bf98fff714ab5be9de19ed31a976860efbd0e772a2efe23e2e06102408301527f4f05f4acb83f5b65168d9fef89d56d4d77b8944015e6b1eed81b0238e2d0dba36102608301527f44a6d974c75b07423e1d6d33f481916fdd45830aea11b6347e700cd8b9f0767c6102808301527fedf260291f734ddac396a956127dde4c34c0cfb8d8052f88ac139658ccf2d5076102a08301527f6075c657a105351e7f0fce53bc320113324a522e8fd52dc878c762551e01a46e6102c08301527f6ca6a3f763a9395f7da16014725ca7ee17e4815c0ff8119bf33f273dee11833b6102e08301527f1c25ef10ffeb3c7d08aa707d17286e0b0d3cbcb50f1bd3b6523b63ba3b52dd0f6103008301527ffffc43bd08273ccf135fd3cacbeef055418e09eb728d727c4d5d5c556cdea7e36103208301527fc5ab8111456b1f28f3c7a0a604b4553ce905cb019c463ee159137af83c350b226103408301527f0ff273fcbf4ae0f2bd88d6cf319ff4004f8d7dca70d4ced4e74d2c74139739e66103608301527f7fa06ba11241ddd5efdc65d4e39c9f6991b74fd4b81b62230808216c876f827c6103808301527f7e275adf313a996c7e2950cac67caba02a5ff925ebf9906b58949f3e77aec5b96103a08301527f8f6162fa308d2b3a15dc33cffac85f13ab349173121645aedf00f471663108be6103c08301527f78ccaaab73373552f207a63599de54d7d8d0c1805f86ce7da15818d09f4cff626103e083015282518381529081018352909160009190602082018180368337505085519192506000918291508180805b60018411156139775750506002820460018084161460005b828110156138f3578a816002028151811061389a57fe5b602002602001015196508a81600202600101815181106138b657fe5b6020026020010151955086602089015285604089015287805190602001208b82815181106138e057fe5b6020908102919091010152600101613883565b5080156139565789600185038151811061390957fe5b6020026020010151955087836020811061391f57fe5b602002015160001b945085602088015284604088015286805190602001208a838151811061394957fe5b6020026020010181815250505b80613962576000613965565b60015b60ff168201935060019092019161386b565b8960008151811061398457fe5b602002602001015198505050505050505050919050565b6020015190565b6139aa613e24565b600080600080600080878060200190518101906139c791906142b4565b6040805160c08101825260ff909716875260208701959095526001600160a01b039093169385019390935263ffffffff9081166060850152909116608083015260a08201529650505050505050919050565b613a21613e59565b60008060008060008060008089806020019051810190613a419190614323565b604080516101008101825260ff909916895260208901979097526001600160a01b039095169587019590955263ffffffff92831660608701529116608085015260a084015267ffffffffffffffff90911660c083015260e082015298505050505050505050919050565b613ab3613e9f565b60008060008085806020019051810190613acd91906143e4565b6040805160808101825260ff9095168552602085019390935263ffffffff909116918301919091526060820152945050505050919050565b6000613b5a826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316613bb69092919063ffffffff16565b80519091501561297957808060200190516020811015613b7957600080fd5b50516129795760405162461bcd60e51b815260040180806020018281038252602a815260200180615082602a913960400191505060405180910390fd5b6060613bc58484600085613bcd565b949350505050565b606082471015613c0e5760405162461bcd60e51b815260040180806020018281038252602681526020018061500c6026913960400191505060405180910390fd5b613c1785613d28565b613c68576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b600080866001600160a01b031685876040518082805190602001908083835b60208310613ca65780518252601f199092019160209182019101613c87565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114613d08576040519150601f19603f3d011682016040523d82523d6000602084013e613d0d565b606091505b5091509150613d1d828286613d2e565b979650505050505050565b3b151590565b60608315613d3d575081612b86565b825115613d4d5782518084602001fd5b8160405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015613d97578181015183820152602001613d7f565b50505050905090810190601f168015613dc45780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5080546000825560020290600052602060002090810190613df39190613ec6565b50565b6040805160a08101825260008082526020820181905291810182905260608101829052608081019190915290565b6040805160c081018252600080825260208201819052918101829052606081018290526080810182905260a081019190915290565b604080516101008101825260008082526020820181905291810182905260608082018390526080820183905260a0820183905260c082019290925260e081019190915290565b60408051608081018252600080825260208201819052918101829052606081019190915290565b5b80821115613f045780547fffffffffffffffff00000000000000000000000000000000000000000000000016815560006001820155600201613ec7565b5090565b600067ffffffffffffffff80841115613f1d57fe5b604051601f8501601f191681016020018281118282101715613f3b57fe5b604052848152915081838501861015613f5357600080fd5b613f61856020830186614f72565b50509392505050565b60008083601f840112613f7b578182fd5b50813567ffffffffffffffff811115613f92578182fd5b6020830191508360208083028501011115613fac57600080fd5b9250929050565b600060808284031215613fc4578081fd5b50919050565b80356129df81614fbd565b805160ff811681146129df57600080fd5b600060208284031215613ff7578081fd5b8135612b8681614fa8565b600060208284031215614013578081fd5b8151612b8681614fa8565b60008060408385031215614030578081fd5b823561403b81614fa8565b9150602083013561404b81614fa8565b809150509250929050565b60008060408385031215614068578182fd5b823561407381614fa8565b946020939093013593505050565b60008060408385031215614093578182fd5b823561409e81614fa8565b9150602083013561404b81614fbd565b600080602083850312156140c0578182fd5b823567ffffffffffffffff8111156140d6578283fd5b6140e285828601613f6a565b90969095509350505050565b6000602082840312156140ff578081fd5b815167ffffffffffffffff811115614115578182fd5b8201601f81018413614125578182fd5b613bc584825160208401613f08565b60008060008060808587031215614149578182fd5b843567ffffffffffffffff80821115614160578384fd5b61416c88838901613fb3565b95506020870135915080821115614181578384fd5b61418d88838901613fb3565b945060408701359150808211156141a2578384fd5b6141ae88838901613fb3565b935060608701359150808211156141c3578283fd5b50850161010081880312156141d6578182fd5b939692955090935050565b6000602082840312156141f2578081fd5b5035919050565b60006020828403121561420a578081fd5b5051919050565b600080600060408486031215614225578081fd5b83359250602084013567ffffffffffffffff811115614242578182fd5b61424e86828701613f6a565b9497909650939450505050565b6000806040838503121561426d578182fd5b50508035926020909101359150565b60006020828403121561428d578081fd5b8135612b8681614fbd565b6000602082840312156142a9578081fd5b8151612b8681614fbd565b60008060008060008060c087890312156142cc578384fd5b6142d587613fd5565b95506020870151945060408701516142ec81614fa8565b60608801519094506142fd81614fbd565b608088015190935061430e81614fbd565b8092505060a087015190509295509295509295565b600080600080600080600080610100898b03121561433f578586fd5b61434889613fd5565b975060208901519650604089015161435f81614fa8565b60608a015190965061437081614fbd565b60808a015190955061438181614fbd565b60a08a015160c08b0151919550935061439981614fcf565b60e08a015190925067ffffffffffffffff8111156143b5578182fd5b8901601f81018b136143c5578182fd5b6143d48b825160208401613f08565b9150509295985092959890939650565b600080600080608085870312156143f9578182fd5b61440285613fd5565b935060208501519250604085015161441981614fbd565b6060959095015193969295505050565b600080600080600060a08688031215614440578283fd5b61444986613fd5565b945060208601519350604086015161446081614fbd565b6060870151608090970151959894975095949392505050565b60008284527f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8311156144aa578081fd5b6020830280836020870137939093016020019283525090919050565b6001600160a01b03169052565b805182526020810151602083015260408101516001600160801b03808216604085015280606084015116606085015250505050565b8054825260018101546020830152600201546001600160801b038116604083015260801c606090910152565b600061010082358452602083013561454b81614fbd565b63ffffffff808216602087015260408501356040870152606085013560608701526080850135608087015260a085013560a087015260c0850135915061459082614fbd565b1660c08501526145a360e0840184614f2a565b8260e08701526145b68387018284614479565b9695505050505050565b60008135601e198336030181126145d5578182fd5b8201803567ffffffffffffffff8111156145ed578283fd5b8036038413156145fb578283fd5b60808552806080860152806020830160a087013784810160a00183905260208481013590860152601f01601f19168401905061463960408401613fca565b614646604086018261466d565b506146546060840184614f2a565b60a08684030160608701526145b660a084018284614479565b63ffffffff169052565b60609390931b6bffffffffffffffffffffffff1916835260e09190911b6001600160e01b0319166014830152601882015260380190565b815160009082906020808601845b838110156146d8578151855293820193908201906001016146bc565b50929695505050505050565b6000828483379101908152919050565b60008251614706818460208701614f72565b9190910192915050565b90565b60e09290921b6001600160e01b0319168252600482015260240190565b6001600160a01b0391909116815260200190565b6001600160a01b0392831681529116602082015260400190565b6001600160a01b0393909316835263ffffffff919091166020830152604082015260600190565b6001600160a01b0394909416845263ffffffff9290921660208401526040830152606082015260800190565b901515815260200190565b93845260208401929092526001600160801b03908116604084015216606082015260800190565b83815267ffffffffffffffff831660208201526060810161480383614f9e565b826040830152949350505050565b60208082526013908201527f4e6f7468696e6720746f20776974686472617700000000000000000000000000604082015260600190565b60208082526011908201527f4661696c656420746f2064697370757465000000000000000000000000000000604082015260600190565b60208082526036908201527f696e76616c6964206465706f736974207472616e736974696f6e2c206d69736d60408201527f61746368206f722077726f6e67206f72646572696e6700000000000000000000606082015260800190565b60208082526019908201527f6e6574206465706f7369742065786365656473206c696d697400000000000000604082015260600190565b6020808252602f908201527f696e76616c6964206465706f736974207472616e736974696f6e2c206e6f207060408201527f656e64696e67206465706f736974730000000000000000000000000000000000606082015260800190565b60208082526016908201527f4661696c656420746f2077697468647261772045544800000000000000000000604082015260600190565b60208082526013908201527f4661696c656420746f20647261696e2045544800000000000000000000000000604082015260600190565b60208082526013908201527f45544820616d6f756e74206d69736d6174636800000000000000000000000000604082015260600190565b60208082526013908201527f556e6b6e6f776e20737472617465677920494400000000000000000000000000604082015260600190565b6020808252601f908201527f426c6f636b207374696c6c20696e206368616c6c656e676520706572696f6400604082015260600190565b60208082526039908201527f696e76616c69642062616c616e63652073796e63207472616e736974696f6e2c60408201527f206e6f2070656e64696e672062616c616e63652073796e637300000000000000606082015260800190565b6020808252603b908201527f696e76616c69642062616c616e63652073796e63207472616e736974696f6e2c60408201527f206d69736d61746368206f722077726f6e67206f72646572696e670000000000606082015260800190565b6020808252818101527f496e76616c696420626c6f636b20696e74656e74207472616e736974696f6e73604082015260600190565b6020808252601b908201527f4e6f20626c6f636b732070656e64696e6720657865637574696f6e0000000000604082015260600190565b6020808252601e908201527f426c6f636b206368616c6c656e676520706572696f64206973206f7665720000604082015260600190565b6020808252818101527f4e6f7420657863656564206d6178207072696f726974792074782064656c6179604082015260600190565b6020808252600d908201527f556e6b6e6f776e20617373657400000000000000000000000000000000000000604082015260600190565b60208082526016908201527f63616c6c6572206973206e6f74206f70657261746f7200000000000000000000604082015260600190565b60208082526014908201527f4173736574206e6f742072656769737465726564000000000000000000000000604082015260600190565b6020808252600e908201527f57726f6e6720626c6f636b204944000000000000000000000000000000000000604082015260600190565b60006101a0808352614d058184018b6145c0565b90508281036020840152614d19818a6145c0565b90508281036040840152873581526020880135609e19893603018112614d3d578283fd5b6080602083015288018035614d5181614fa8565b6001600160a01b031660808301526020810135614d6d81614fbd565b63ffffffff1660a0830152614d856040820182614f2a565b60a060c0850152614d9b61012085018284614479565b915050614dab6060830183614f2a565b848303607f190160e0860152614dc2838284614479565b9250505060808201359150614dd682614fcf565b61010067ffffffffffffffff831681850152614df460408c01613fca565b9250614e03604085018461466d565b614e1060608c018c614f2a565b93508483036060860152614e25838583614479565b9450508584036060870152614e3a848b614534565b9450614e49608087018a614508565b614e55818701896144d3565b50505050614e676101808301846144c6565b98975050505050505050565b90815260200190565b6000838252604060208301528251806040840152614ea1816060850160208701614f72565b601f01601f1916919091016060019392505050565b63ffffffff91909116815260200190565b63ffffffff9390931683526020830191909152604082015260600190565b6000808335601e19843603018112614efb578283fd5b83018035915067ffffffffffffffff821115614f15578283fd5b602001915036819003821315613fac57600080fd5b6000808335601e19843603018112614f40578283fd5b830160208101925035905067ffffffffffffffff811115614f6057600080fd5b602081023603831315613fac57600080fd5b60005b83811015614f8d578181015183820152602001614f75565b838111156115cd5750506000910152565b60028110613df357fe5b6001600160a01b0381168114613df357600080fd5b63ffffffff81168114613df357600080fd5b67ffffffffffffffff81168114613df357600080fdfe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65724d65726b6c65547265653a204d7573742070726f76696465206174206c65617374206f6e65206c65616620686173682e5361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a2646970667358221220c4429aae98d236e14394adaa77e96094e68e515f209d28ca1690632ec3da98e964736f6c63430007060033000000000000000000000000000000000000000000000000000000000000001e000000000000000000000000000000000000000000000000000000000000003c0000000000000000000000005d3c0f4ca5ee99f8e8f59ff9a5fab04f6a7e007f000000000000000000000000fe81ab6930a30bdae731fe7b6c6abfbeafc014a80000000000000000000000006c0af0e2a174aaffe9f336c0ae4d0e535735294f

Deployed Bytecode

0x6080604052600436106102bf5760003560e01c80639ae2369d1161016e578063b90405da116100cb578063ec8dedb71161007f578063f25b3f9911610064578063f25b3f99146106ee578063f2fde38b1461071e578063f940e3851461073e576102c6565b8063ec8dedb7146106b9578063ed038f5c146106d9576102c6565b8063cb5f3129116100b0578063cb5f312914610659578063cdcab4a314610679578063dfe9fbd114610699576102c6565b8063b90405da14610624578063c145e2a614610644576102c6565b8063a9adf05511610122578063aef72fde11610107578063aef72fde146105da578063b3ab15fb146105ef578063b64ccb491461060f576102c6565b8063a9adf055146105b0578063aedb2727146105c5576102c6565b8063a1545a5211610153578063a1545a5214610541578063a35a2eda14610561578063a793279414610590576102c6565b80639ae2369d146105015780639d4323be14610521576102c6565b8063570ca7351161021c5780638456cb59116101d05780638da5cb5b116101b55780638da5cb5b146104b7578063978d602a146104cc5780639790525f146104ec576102c6565b80638456cb59146104825780638bdc623214610497576102c6565b806370d063051161020157806370d063051461043857806370ec737214610458578063715018a61461046d576102c6565b8063570ca735146103f45780635c975abb14610416576102c6565b80632e5990541161027357806341db203c1161025857806341db203c1461039f57806347e7ef24146103bf5780634f17ceb2146103df576102c6565b80632e599054146103775780633f4ba83a1461038a576102c6565b8063142a2b0a116102a4578063142a2b0a14610313578063239cbf411461034257806325fe097514610357576102c6565b8063097e24a0146102c85780630bd9e1f9146102e8576102c6565b366102c657005b005b3480156102d457600080fd5b506102c66102e33660046140ae565b61075e565b3480156102f457600080fd5b506102fd610f48565b60405161030a9190614e73565b60405180910390f35b34801561031f57600080fd5b5061033361032e3660046141e1565b610f4e565b60405161030a939291906147e3565b34801561034e57600080fd5b506102fd610f7d565b34801561036357600080fd5b506102fd610372366004614081565b610f83565b6102c6610385366004614056565b610fa0565b34801561039657600080fd5b506102c661106e565b3480156103ab57600080fd5b506102fd6103ba36600461427c565b6110da565b3480156103cb57600080fd5b506102c66103da366004614056565b6110ec565b3480156103eb57600080fd5b506102fd61115c565b34801561040057600080fd5b50610409611162565b60405161030a9190614730565b34801561042257600080fd5b5061042b611171565b60405161030a91906147b1565b34801561044457600080fd5b506102fd610453366004613fe6565b611181565b34801561046457600080fd5b506102fd611193565b34801561047957600080fd5b506102c6611199565b34801561048e57600080fd5b506102c6611245565b3480156104a357600080fd5b506102c66104b2366004614134565b6112af565b3480156104c357600080fd5b50610409611488565b3480156104d857600080fd5b506102c66104e736600461401e565b611497565b3480156104f857600080fd5b506102fd6115d3565b34801561050d57600080fd5b506102c661051c36600461427c565b6115d9565b34801561052d57600080fd5b506102c661053c366004614056565b6118cf565b34801561054d57600080fd5b506102fd61055c366004613fe6565b611995565b34801561056d57600080fd5b5061058161057c36600461425b565b6119a7565b60405161030a9392919061475e565b34801561059c57600080fd5b506103336105ab3660046141e1565b6119fa565b3480156105bc57600080fd5b506102fd611a29565b3480156105d157600080fd5b506102fd611a2f565b3480156105e657600080fd5b506102fd611a35565b3480156105fb57600080fd5b506102c661060a366004613fe6565b611a3f565b34801561061b57600080fd5b506102fd611b0a565b34801561063057600080fd5b506102c661063f3660046141e1565b611b10565b34801561065057600080fd5b506102c6611b77565b34801561066557600080fd5b506102c66106743660046141e1565b611c2f565b34801561068557600080fd5b506102c66106943660046141e1565b611c96565b3480156106a557600080fd5b506102c66106b4366004614056565b611dc4565b3480156106c557600080fd5b506102c66106d4366004614211565b611ee9565b3480156106e557600080fd5b506102fd6127bb565b3480156106fa57600080fd5b5061070e6107093660046141e1565b6127c1565b60405161030a94939291906147bc565b34801561072a57600080fd5b506102c6610739366004613fe6565b612808565b34801561074a57600080fd5b506102c661075936600461401e565b61290a565b610766611171565b156107ab576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b60045460035481106107d85760405162461bcd60e51b81526004016107cf90614b72565b60405180910390fd5b43601254600383815481106107e957fe5b60009182526020909120600260039092020101546001600160801b031601106108245760405162461bcd60e51b81526004016107cf90614a4c565b600082156108fc5760008367ffffffffffffffff8111801561084557600080fd5b5060405190808252806020026020018201604052801561086f578160200160208202803683370190505b50905060005b848110156108d05785858281811061088957fe5b905060200281019061089b9190614ee5565b6040516108a99291906146e4565b60405180910390208282815181106108bd57fe5b6020908102919091010152600101610875565b50806040516020016108e291906146ae565b604051602081830303815290604052805190602001209150505b6003828154811061090957fe5b90600052602060002090600302016001015481146109395760405162461bcd60e51b81526004016107cf90614b3d565b60005b83811015610c8a5760006109a186868481811061095557fe5b90506020028101906109679190614ee5565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061297e92505050565b6002546040808301519051635a2f9ddb60e11b81529293506000926001600160a01b039092169163b45f3bb6916109da91600401614eb6565b60206040518083038186803b1580156109f257600080fd5b505afa158015610a06573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a2a9190614002565b90506001600160a01b038116610a525760405162461bcd60e51b81526004016107cf90614a15565b6080820151606083015182911015610bae576000610a81846080015185606001516129e490919063ffffffff16565b9050610b098382846001600160a01b031663670ab5e96040518163ffffffff1660e01b815260040160206040518083038186803b158015610ac157600080fd5b505afa158015610ad5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610af99190614002565b6001600160a01b03169190612a41565b6040516304df9d0360e01b81526001600160a01b038316906304df9d0390610b35908490600401614e73565b600060405180830381600087803b158015610b4f57600080fd5b505af1158015610b63573d6000803e3d6000fd5b5050505060408481015163ffffffff9081166000908152600f6020529190912054610b90918390612b2c16565b60408086015163ffffffff166000908152600f602052205550610c7f565b826080015183606001511015610c7f576000610bdb846060015185608001516129e490919063ffffffff16565b604051633d709f1560e21b81529091506001600160a01b0383169063f5c27c5490610c0a908490600401614e73565b600060405180830381600087803b158015610c2457600080fd5b505af1158015610c38573d6000803e3d6000fd5b5050505060408481015163ffffffff9081166000908152600f6020529190912054610c659183906129e416565b60408086015163ffffffff166000908152600f6020522055505b50505060010161093c565b506004805460010190555b6007546006541015610d7057600654600090815260056020908152604080832081516060810183528154815260018083015467ffffffffffffffff81169583019590955290939192840191600160401b900460ff1690811115610cf457fe5b6001811115610cff57fe5b9052509050600181604001516001811115610d1657fe5b141580610d30575082816020015167ffffffffffffffff16115b15610d3b5750610d70565b506006805460009081526005602052604081209081556001908101805468ffffffffffffffffff191690558154019055610c95565b60005b600083815260096020526040902054811015610e18576000838152600960205260408120805483908110610da357fe5b6000918252602080832060408051606081018252600290940290910180546001600160a01b03811680865263ffffffff600160a01b9092048216868601908152600193840154968501879052908752600a85528387209051909116865290925290922080549091019055919091019050610d73565b506000828152600960205260408120610e3091613dd2565b600d54600c541015610f0b57600c546000908152600b6020908152604080832081516060810183528154815260018083015467ffffffffffffffff81169583019590955290939192840191600160401b900460ff1690811115610e8f57fe5b6001811115610e9a57fe5b9052509050600181604001516001811115610eb157fe5b141580610ecb575082816020015167ffffffffffffffff16115b15610ed65750610f0b565b50600c80546000908152600b602052604081209081556001908101805468ffffffffffffffffff191690558154019055610e30565b7f7dcbc30b0913ee9985c884dea0928f45844ec4f1feb3ab49bb25fdeb1fd838ce82604051610f3a9190614e73565b60405180910390a150505050565b60075481565b600b602052600090815260409020805460019091015467ffffffffffffffff811690600160401b900460ff1683565b600c5481565b600a60209081526000928352604080842090915290825290205481565b610fa8611171565b15610fed576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b80341461100c5760405162461bcd60e51b81526004016107cf906149de565b6110168282612b8d565b816001600160a01b031663d0e30db0826040518263ffffffff1660e01b81526004016000604051808303818588803b15801561105157600080fd5b505af1158015611065573d6000803e3d6000fd5b50505050505050565b611076612dab565b6001600160a01b0316611087611488565b6001600160a01b0316146110d0576040805162461bcd60e51b81526020600482018190526024820152600080516020615032833981519152604482015290519081900360640190fd5b6110d8612daf565b565b600f6020526000908152604090205481565b6110f4611171565b15611139576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b6111438282612b8d565b6111586001600160a01b038316333084612e52565b5050565b600e5481565b6014546001600160a01b031681565b600054600160a01b900460ff1690565b60106020526000908152604090205481565b60135481565b6111a1612dab565b6001600160a01b03166111b2611488565b6001600160a01b0316146111fb576040805162461bcd60e51b81526020600482018190526024820152600080516020615032833981519152604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b61124d612dab565b6001600160a01b031661125e611488565b6001600160a01b0316146112a7576040805162461bcd60e51b81526020600482018190526024820152600080516020615032833981519152604482015290519081900360640190fd5b6110d8612eac565b6000836020013590506000600382815481106112c757fe5b6000918252602091829020604080516080810182526003909302909101805483526001810154938301939093526002909201546001600160801b03808216938301849052600160801b9091041660608201526012549092504391011161133f5760405162461bcd60e51b81526004016107cf90614ba9565b60006060600160009054906101000a90046001600160a01b03166001600160a01b031663092dff5860e01b8989898960038e602001358154811061137f57fe5b600091825260209091206002546040516113b29796959493600302909201918c916001600160a01b031690602401614cf1565b60408051601f198184030181529181526020820180516001600160e01b03166001600160e01b03199094169390931790925290516113f091906146f4565b6000604051808303816000865af19150503d806000811461142d576040519150601f19603f3d011682016040523d82523d6000602084013e611432565b606091505b50909250905081156114665760008180602001905181019061145491906140ee565b90506114608582612f35565b5061147e565b60405162461bcd60e51b81526004016107cf90614848565b5050505050505050565b6000546001600160a01b031690565b61149f611171565b156114e4576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b60006114f083836130c6565b604051632e1a7d4d60e01b81529091506001600160a01b03831690632e1a7d4d9061151f908490600401614e73565b600060405180830381600087803b15801561153957600080fd5b505af115801561154d573d6000803e3d6000fd5b505050506000836001600160a01b03168260405161156a90614710565b60006040518083038185875af1925050503d80600081146115a7576040519150601f19603f3d011682016040523d82523d6000602084013e6115ac565b606091505b50509050806115cd5760405162461bcd60e51b81526004016107cf90614970565b50505050565b60065481565b6115e1611171565b15611626576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b6014546001600160a01b031633146116505760405162461bcd60e51b81526004016107cf90614c4c565b600254604051635a2f9ddb60e11b81526000916001600160a01b03169063b45f3bb690611681908590600401614eb6565b60206040518083038186803b15801561169957600080fd5b505afa1580156116ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116d19190614002565b90506001600160a01b0381166116f95760405162461bcd60e51b81526004016107cf90614a15565b6000816001600160a01b031663fd9c652b6040518163ffffffff1660e01b8152600401602060405180830381600087803b15801561173657600080fd5b505af115801561174a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061176e91906141f9565b63ffffffff84166000908152600f602052604081205491925081831061179f5761179883836129e4565b90506117af565b6117a982846129e4565b60000390505b63ffffffff85166000908152600f60209081526040808320869055600e80546001810190915590519092916117e8918991869101614713565b60408051601f19818403018152828252805160209182012060608401835280845260035467ffffffffffffffff169184019190915292508101600090526000838152600b602090815260409182902083518155908301516001808301805467ffffffffffffffff191667ffffffffffffffff9093169290921780835593850151929360ff60401b191690600160401b90849081111561188357fe5b02179055509050507f0fd8e389fca8b6a7e1044129d3ab36e1d3c299a2100fdedd302084044b79f8418784846040516118be93929190614ec7565b60405180910390a150505050505050565b6118d7611171565b61191f576040805162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604482015290519081900360640190fd5b611927612dab565b6001600160a01b0316611938611488565b6001600160a01b031614611981576040805162461bcd60e51b81526020600482018190526024820152600080516020615032833981519152604482015290519081900360640190fd5b6111586001600160a01b03831633836132a5565b60116020526000908152604090205481565b600960205281600052604060002081815481106119c357600080fd5b6000918252602090912060029091020180546001909101546001600160a01b0382169350600160a01b90910463ffffffff16915083565b6005602052600090815260409020805460019091015467ffffffffffffffff811690600160401b900460ff1683565b600d5481565b60085481565b6003546000190190565b611a47612dab565b6001600160a01b0316611a58611488565b6001600160a01b031614611aa1576040805162461bcd60e51b81526020600482018190526024820152600080516020615032833981519152604482015290519081900360640190fd5b6014546040517fd58299b712891143e76310d5e664c4203c940a67db37cf856bdaa3c5c76a802c91611ae0916001600160a01b03909116908490614744565b60405180910390a1601480546001600160a01b0319166001600160a01b0392909216919091179055565b60125481565b611b18612dab565b6001600160a01b0316611b29611488565b6001600160a01b031614611b72576040805162461bcd60e51b81526020600482018190526024820152600080516020615032833981519152604482015290519081900360640190fd5b601255565b6000611b81611a35565b90506008546007541015611bd057601354600754600090815260056020526040902060010154611bbc90839067ffffffffffffffff166129e4565b1115611bd057611bca612eac565b506110d8565b600e54600d541015611c1757601354600d546000908152600b6020526040902060010154611c0990839067ffffffffffffffff166129e4565b1115611c1757611bca612eac565b60405162461bcd60e51b81526004016107cf90614be0565b611c37612dab565b6001600160a01b0316611c48611488565b6001600160a01b031614611c91576040805162461bcd60e51b81526020600482018190526024820152600080516020615032833981519152604482015290519081900360640190fd5b601355565b611c9e611171565b611ce6576040805162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604482015290519081900360640190fd5b611cee612dab565b6001600160a01b0316611cff611488565b6001600160a01b031614611d48576040805162461bcd60e51b81526020600482018190526024820152600080516020615032833981519152604482015290519081900360640190fd5b6000336001600160a01b031682604051611d6190614710565b60006040518083038185875af1925050503d8060008114611d9e576040519150601f19603f3d011682016040523d82523d6000602084013e611da3565b606091505b50509050806111585760405162461bcd60e51b81526004016107cf906149a7565b611dcc612dab565b6001600160a01b0316611ddd611488565b6001600160a01b031614611e26576040805162461bcd60e51b81526020600482018190526024820152600080516020615032833981519152604482015290519081900360640190fd5b60025460405163639260df60e01b81526000916001600160a01b03169063639260df90611e57908690600401614730565b60206040518083038186803b158015611e6f57600080fd5b505afa158015611e83573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ea79190614298565b905063ffffffff8116611ecc5760405162461bcd60e51b81526004016107cf90614c15565b506001600160a01b03909116600090815260116020526040902055565b611ef1611171565b15611f36576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b6014546001600160a01b03163314611f605760405162461bcd60e51b81526004016107cf90614c4c565b6003548314611f815760405162461bcd60e51b81526004016107cf90614cba565b60008167ffffffffffffffff81118015611f9a57600080fd5b50604051908082528060200260200182016040528015611fc4578160200160208202803683370190505b50905060005b8281101561202557838382818110611fde57fe5b9050602002810190611ff09190614ee5565b604051611ffe9291906146e4565b604051809103902082828151811061201257fe5b6020908102919091010152600101611fca565b506000612031826132f7565b905060008367ffffffffffffffff8111801561204c57600080fd5b50604051908082528060200260200182016040528015612076578160200160208202803683370190505b5090506000805b858110156125955760006120e288888481811061209657fe5b90506020028101906120a89190614ee5565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061399b92505050565b905060ff8116600314806120f9575060ff81166004145b15612104575061258d565b60ff81166005141561213a5781848480600101955063ffffffff168151811061212957fe5b60200260200101818152505061258b565b60ff8116600114156122d65760006121a389898581811061215757fe5b90506020028101906121699190614ee5565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506139a292505050565b6007546008549192509081106121cb5760405162461bcd60e51b81526004016107cf90614913565b600081815260056020908152604080832081516060810183528154815260018083015467ffffffffffffffff81169583019590955290939192840191600160401b900460ff169081111561221b57fe5b600181111561222657fe5b8152505090506000836040015184608001518560a0015160405160200161224f93929190614677565b6040516020818303038152906040528051906020012090508082600001511461228a5760405162461bcd60e51b81526004016107cf9061487f565b505060009081526005602052604090206001908101805460ff60401b1916600160401b1767ffffffffffffffff191667ffffffffffffffff8d161790556007805490910190555061258b565b60ff8116600214156123f957600061233f8989858181106122f357fe5b90506020028101906123059190614ee5565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250613a1992505050565b60008b81526009602090815260408083208151606081018352828601516001600160a01b039081168252608087015163ffffffff90811683870190815260a090980151948301948552835460018181018655948852959096209151600290950290910180549651909516600160a01b027fffffffffffffffff00000000ffffffffffffffffffffffffffffffffffffffff949091166001600160a01b0319909616959095179290921693909317825591519101555061258b565b60ff81166006141561258b57600061246289898581811061241657fe5b90506020028101906124289190614ee5565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250613aab92505050565b600d54600e5491925090811061248a5760405162461bcd60e51b81526004016107cf90614a83565b6000818152600b6020908152604080832081516060810183528154815260018083015467ffffffffffffffff81169583019590955290939192840191600160401b900460ff16908111156124da57fe5b60018111156124e557fe5b815250509050600083604001518460600151604051602001612508929190614713565b604051602081830303815290604052805190602001209050808260000151146125435760405162461bcd60e51b81526004016107cf90614ae0565b50506000908152600b602052604090206001908101805460ff60401b1916600160401b1767ffffffffffffffff191667ffffffffffffffff8d16179055600d80549091019055505b505b60010161207d565b50600063ffffffff8216156126935760008263ffffffff1667ffffffffffffffff811180156125c357600080fd5b506040519080825280602002602001820160405280156125ed578160200160208202803683370190505b50905060005b8363ffffffff1681101561266757888886838151811061260f57fe5b602002602001015181811061262057fe5b90506020028101906126329190614ee5565b6040516126409291906146e4565b604051809103902082828151811061265457fe5b60209081029190910101526001016125f3565b508060405160200161267991906146ae565b604051602081830303815290604052805190602001209150505b60408051608081018252858152602081018381526001600160801b034381168385019081528a821660608501908152600380546001810182556000829052865191027fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b81019190915593517fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85c85015590517fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85d909301805491518316600160801b029383166fffffffffffffffffffffffffffffffff199092169190911790911691909117905590517f8f398593f037f47ea1fc7ede311023f216c9f01cea5795d6df8c3caf1eaecff0906127a8908b90614e73565b60405180910390a1505050505050505050565b60045481565b600381815481106127d157600080fd5b60009182526020909120600390910201805460018201546002909201549092506001600160801b0380821691600160801b90041684565b612810612dab565b6001600160a01b0316612821611488565b6001600160a01b03161461286a576040805162461bcd60e51b81526020600482018190526024820152600080516020615032833981519152604482015290519081900360640190fd5b6001600160a01b0381166128af5760405162461bcd60e51b8152600401808060200182810382526026815260200180614fe66026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b612912611171565b15612957576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b600061296383836130c6565b90506129796001600160a01b03831684836132a5565b505050565b612986613df6565b6000806000806000868060200190518101906129a29190614429565b6040805160a08101825260ff9096168652602086019490945263ffffffff9092169284019290925260608301919091526080820152955050505050505b919050565b600082821115612a3b576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b6000612ad782856001600160a01b031663dd62ed3e30876040518363ffffffff1660e01b815260040180836001600160a01b03168152602001826001600160a01b031681526020019250505060206040518083038186803b158015612aa557600080fd5b505afa158015612ab9573d6000803e3d6000fd5b505050506040513d6020811015612acf57600080fd5b505190612b2c565b604080516001600160a01b038616602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663095ea7b360e01b1790529091506115cd908590613b05565b600082820183811015612b86576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b9392505050565b60025460405163639260df60e01b815233916000916001600160a01b039091169063639260df90612bc2908790600401614730565b60206040518083038186803b158015612bda57600080fd5b505afa158015612bee573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c129190614298565b905063ffffffff8116612c375760405162461bcd60e51b81526004016107cf90614c15565b6001600160a01b038416600090815260106020526040812054612c5a9085612b2c565b6001600160a01b038616600090815260116020526040902054909150811115612c955760405162461bcd60e51b81526004016107cf906148dc565b6001600160a01b038516600090815260106020908152604080832084905560088054600181019091559051909291612cd391879187918a9101614677565b60408051601f19818403018152828252805160209182012060608401835280845260035467ffffffffffffffff1691840191909152925081016000905260008381526005602090815260409182902083518155908301516001808301805467ffffffffffffffff191667ffffffffffffffff9093169290921780835593850151929360ff60401b191690600160401b908490811115612d6e57fe5b02179055509050507fba6b61ba25da48510b2a171056f2d2ea3d73c9c0618aa8fdbafa7e991f82ee25858588856040516118be9493929190614785565b3390565b612db7611171565b612dff576040805162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604482015290519081900360640190fd5b6000805460ff60a01b191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa612e35612dab565b604080516001600160a01b039092168252519081900360200190a1565b604080516001600160a01b0380861660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b1790526115cd908590613b05565b612eb4611171565b15612ef9576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b6000805460ff60a01b1916600160a01b1790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258612e35612dab565b612f3d612eac565b600354821015612f8957600380546000198101600052600960205280612f5f57fe5b60008281526020812060036000199093019283020181815560018101829055600201559055612f3d565b6006546000905b6008548110156130075760008181526005602052604090206001015467ffffffffffffffff168411612fff5781612fcb576007819055600191505b6000818152600560205260409020600101805467ffffffffffffffff191667ffffffffffffffff86161760ff60401b191690555b600101612f90565b5050600c546000905b600e54811015613087576000818152600b602052604090206001015467ffffffffffffffff16841161307f578161304b57600d819055600191505b6000818152600b60205260409020600101805467ffffffffffffffff191667ffffffffffffffff86161760ff60401b191690555b600101613010565b507f36a66b31987e7e6abdbfed3b1968c201f8c3a138705e5087cd66e221faf1e1ff83836040516130b9929190614e7c565b60405180910390a1505050565b60025460405163639260df60e01b815260009182916001600160a01b039091169063639260df906130fb908690600401614730565b60206040518083038186803b15801561311357600080fd5b505afa158015613127573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061314b9190614298565b905060008163ffffffff16116131735760405162461bcd60e51b81526004016107cf90614c83565b6001600160a01b0384166000908152600a6020908152604080832063ffffffff85168452909152902054806131ba5760405162461bcd60e51b81526004016107cf90614811565b6001600160a01b0384166000908152601060205260409020548111156131f8576001600160a01b038416600090815260106020526040812055613235565b6001600160a01b03841660009081526010602052604090205461321b90826129e4565b6001600160a01b0385166000908152601060205260409020555b6001600160a01b0385166000908152600a6020908152604080832063ffffffff8616845290915280822091909155517fa8d2059deb1787b03478662fb43905086ccfe9e47b2e454d0186076b49539586906132959087908590859061475e565b60405180910390a1949350505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052612979908490613b05565b6000808251116133385760405162461bcd60e51b81526004018080602001828103825260308152602001806150526030913960400191505060405180910390fd5b81516001141561335e578160008151811061334f57fe5b602002602001015190506129df565b60408051610400810182527f290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e56381527f633dc4d7da7256660a892f8f1604a44b5432649cc8ec5cb3ced4c4e6ac94dd1d60208201527f890740a8eb06ce9be422cb8da5cdafc2b58c0a5e24036c578de2a433c828ff7d818301527f3b8ec09e026fdc305365dfc94e189a81b38c7597b3d941c279f042e8206e0bd86060808301919091527fecd50eee38e386bd62be9bedb990706951b65fe053bd9d8a521af753d139e2da60808301527fdefff6d330bb5403f63b14f33b578274160de3a50df4efecf0e0db73bcdd3da560a08301527f617bdd11f7c0a11f49db22f629387a12da7596f9d1704d7465177c63d88ec7d760c08301527f292c23a9aa1d8bea7e2435e555a4a60e379a5a35f3f452bae60121073fb6eead60e08301527fe1cea92ed99acdcb045a6726b2f87107e8a61620a232cf4d7d5b5766b3952e106101008301527f7ad66c0a68c72cb89e4fb4303841966e4062a76ab97451e3b9fb526a5ceb7f826101208301527fe026cc5a4aed3c22a58cbd3d2ac754c9352c5436f638042dca99034e836365166101408301527f3d04cffd8b46a874edf5cfae63077de85f849a660426697b06a829c70dd1409c6101608301527fad676aa337a485e4728a0b240d92b3ef7b3c372d06d189322bfd5f61f1e7203e6101808301527fa2fca4a49658f9fab7aa63289c91b7c7b6c832a6d0e69334ff5b0a3483d09dab6101a08301527f4ebfd9cd7bca2505f7bef59cc1c12ecc708fff26ae4af19abe852afe9e20c8626101c08301527f2def10d13dd169f550f578bda343d9717a138562e0093b380a1120789d53cf106101e08301527f776a31db34a1a0a7caaf862cffdfff1789297ffadc380bd3d39281d340abd3ad6102008301527fe2e7610b87a5fdf3a72ebe271287d923ab990eefac64b6e59d79f8b7e08c46e36102208301527f504364a5c6858bf98fff714ab5be9de19ed31a976860efbd0e772a2efe23e2e06102408301527f4f05f4acb83f5b65168d9fef89d56d4d77b8944015e6b1eed81b0238e2d0dba36102608301527f44a6d974c75b07423e1d6d33f481916fdd45830aea11b6347e700cd8b9f0767c6102808301527fedf260291f734ddac396a956127dde4c34c0cfb8d8052f88ac139658ccf2d5076102a08301527f6075c657a105351e7f0fce53bc320113324a522e8fd52dc878c762551e01a46e6102c08301527f6ca6a3f763a9395f7da16014725ca7ee17e4815c0ff8119bf33f273dee11833b6102e08301527f1c25ef10ffeb3c7d08aa707d17286e0b0d3cbcb50f1bd3b6523b63ba3b52dd0f6103008301527ffffc43bd08273ccf135fd3cacbeef055418e09eb728d727c4d5d5c556cdea7e36103208301527fc5ab8111456b1f28f3c7a0a604b4553ce905cb019c463ee159137af83c350b226103408301527f0ff273fcbf4ae0f2bd88d6cf319ff4004f8d7dca70d4ced4e74d2c74139739e66103608301527f7fa06ba11241ddd5efdc65d4e39c9f6991b74fd4b81b62230808216c876f827c6103808301527f7e275adf313a996c7e2950cac67caba02a5ff925ebf9906b58949f3e77aec5b96103a08301527f8f6162fa308d2b3a15dc33cffac85f13ab349173121645aedf00f471663108be6103c08301527f78ccaaab73373552f207a63599de54d7d8d0c1805f86ce7da15818d09f4cff626103e083015282518381529081018352909160009190602082018180368337505085519192506000918291508180805b60018411156139775750506002820460018084161460005b828110156138f3578a816002028151811061389a57fe5b602002602001015196508a81600202600101815181106138b657fe5b6020026020010151955086602089015285604089015287805190602001208b82815181106138e057fe5b6020908102919091010152600101613883565b5080156139565789600185038151811061390957fe5b6020026020010151955087836020811061391f57fe5b602002015160001b945085602088015284604088015286805190602001208a838151811061394957fe5b6020026020010181815250505b80613962576000613965565b60015b60ff168201935060019092019161386b565b8960008151811061398457fe5b602002602001015198505050505050505050919050565b6020015190565b6139aa613e24565b600080600080600080878060200190518101906139c791906142b4565b6040805160c08101825260ff909716875260208701959095526001600160a01b039093169385019390935263ffffffff9081166060850152909116608083015260a08201529650505050505050919050565b613a21613e59565b60008060008060008060008089806020019051810190613a419190614323565b604080516101008101825260ff909916895260208901979097526001600160a01b039095169587019590955263ffffffff92831660608701529116608085015260a084015267ffffffffffffffff90911660c083015260e082015298505050505050505050919050565b613ab3613e9f565b60008060008085806020019051810190613acd91906143e4565b6040805160808101825260ff9095168552602085019390935263ffffffff909116918301919091526060820152945050505050919050565b6000613b5a826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316613bb69092919063ffffffff16565b80519091501561297957808060200190516020811015613b7957600080fd5b50516129795760405162461bcd60e51b815260040180806020018281038252602a815260200180615082602a913960400191505060405180910390fd5b6060613bc58484600085613bcd565b949350505050565b606082471015613c0e5760405162461bcd60e51b815260040180806020018281038252602681526020018061500c6026913960400191505060405180910390fd5b613c1785613d28565b613c68576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b600080866001600160a01b031685876040518082805190602001908083835b60208310613ca65780518252601f199092019160209182019101613c87565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114613d08576040519150601f19603f3d011682016040523d82523d6000602084013e613d0d565b606091505b5091509150613d1d828286613d2e565b979650505050505050565b3b151590565b60608315613d3d575081612b86565b825115613d4d5782518084602001fd5b8160405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015613d97578181015183820152602001613d7f565b50505050905090810190601f168015613dc45780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5080546000825560020290600052602060002090810190613df39190613ec6565b50565b6040805160a08101825260008082526020820181905291810182905260608101829052608081019190915290565b6040805160c081018252600080825260208201819052918101829052606081018290526080810182905260a081019190915290565b604080516101008101825260008082526020820181905291810182905260608082018390526080820183905260a0820183905260c082019290925260e081019190915290565b60408051608081018252600080825260208201819052918101829052606081019190915290565b5b80821115613f045780547fffffffffffffffff00000000000000000000000000000000000000000000000016815560006001820155600201613ec7565b5090565b600067ffffffffffffffff80841115613f1d57fe5b604051601f8501601f191681016020018281118282101715613f3b57fe5b604052848152915081838501861015613f5357600080fd5b613f61856020830186614f72565b50509392505050565b60008083601f840112613f7b578182fd5b50813567ffffffffffffffff811115613f92578182fd5b6020830191508360208083028501011115613fac57600080fd5b9250929050565b600060808284031215613fc4578081fd5b50919050565b80356129df81614fbd565b805160ff811681146129df57600080fd5b600060208284031215613ff7578081fd5b8135612b8681614fa8565b600060208284031215614013578081fd5b8151612b8681614fa8565b60008060408385031215614030578081fd5b823561403b81614fa8565b9150602083013561404b81614fa8565b809150509250929050565b60008060408385031215614068578182fd5b823561407381614fa8565b946020939093013593505050565b60008060408385031215614093578182fd5b823561409e81614fa8565b9150602083013561404b81614fbd565b600080602083850312156140c0578182fd5b823567ffffffffffffffff8111156140d6578283fd5b6140e285828601613f6a565b90969095509350505050565b6000602082840312156140ff578081fd5b815167ffffffffffffffff811115614115578182fd5b8201601f81018413614125578182fd5b613bc584825160208401613f08565b60008060008060808587031215614149578182fd5b843567ffffffffffffffff80821115614160578384fd5b61416c88838901613fb3565b95506020870135915080821115614181578384fd5b61418d88838901613fb3565b945060408701359150808211156141a2578384fd5b6141ae88838901613fb3565b935060608701359150808211156141c3578283fd5b50850161010081880312156141d6578182fd5b939692955090935050565b6000602082840312156141f2578081fd5b5035919050565b60006020828403121561420a578081fd5b5051919050565b600080600060408486031215614225578081fd5b83359250602084013567ffffffffffffffff811115614242578182fd5b61424e86828701613f6a565b9497909650939450505050565b6000806040838503121561426d578182fd5b50508035926020909101359150565b60006020828403121561428d578081fd5b8135612b8681614fbd565b6000602082840312156142a9578081fd5b8151612b8681614fbd565b60008060008060008060c087890312156142cc578384fd5b6142d587613fd5565b95506020870151945060408701516142ec81614fa8565b60608801519094506142fd81614fbd565b608088015190935061430e81614fbd565b8092505060a087015190509295509295509295565b600080600080600080600080610100898b03121561433f578586fd5b61434889613fd5565b975060208901519650604089015161435f81614fa8565b60608a015190965061437081614fbd565b60808a015190955061438181614fbd565b60a08a015160c08b0151919550935061439981614fcf565b60e08a015190925067ffffffffffffffff8111156143b5578182fd5b8901601f81018b136143c5578182fd5b6143d48b825160208401613f08565b9150509295985092959890939650565b600080600080608085870312156143f9578182fd5b61440285613fd5565b935060208501519250604085015161441981614fbd565b6060959095015193969295505050565b600080600080600060a08688031215614440578283fd5b61444986613fd5565b945060208601519350604086015161446081614fbd565b6060870151608090970151959894975095949392505050565b60008284527f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8311156144aa578081fd5b6020830280836020870137939093016020019283525090919050565b6001600160a01b03169052565b805182526020810151602083015260408101516001600160801b03808216604085015280606084015116606085015250505050565b8054825260018101546020830152600201546001600160801b038116604083015260801c606090910152565b600061010082358452602083013561454b81614fbd565b63ffffffff808216602087015260408501356040870152606085013560608701526080850135608087015260a085013560a087015260c0850135915061459082614fbd565b1660c08501526145a360e0840184614f2a565b8260e08701526145b68387018284614479565b9695505050505050565b60008135601e198336030181126145d5578182fd5b8201803567ffffffffffffffff8111156145ed578283fd5b8036038413156145fb578283fd5b60808552806080860152806020830160a087013784810160a00183905260208481013590860152601f01601f19168401905061463960408401613fca565b614646604086018261466d565b506146546060840184614f2a565b60a08684030160608701526145b660a084018284614479565b63ffffffff169052565b60609390931b6bffffffffffffffffffffffff1916835260e09190911b6001600160e01b0319166014830152601882015260380190565b815160009082906020808601845b838110156146d8578151855293820193908201906001016146bc565b50929695505050505050565b6000828483379101908152919050565b60008251614706818460208701614f72565b9190910192915050565b90565b60e09290921b6001600160e01b0319168252600482015260240190565b6001600160a01b0391909116815260200190565b6001600160a01b0392831681529116602082015260400190565b6001600160a01b0393909316835263ffffffff919091166020830152604082015260600190565b6001600160a01b0394909416845263ffffffff9290921660208401526040830152606082015260800190565b901515815260200190565b93845260208401929092526001600160801b03908116604084015216606082015260800190565b83815267ffffffffffffffff831660208201526060810161480383614f9e565b826040830152949350505050565b60208082526013908201527f4e6f7468696e6720746f20776974686472617700000000000000000000000000604082015260600190565b60208082526011908201527f4661696c656420746f2064697370757465000000000000000000000000000000604082015260600190565b60208082526036908201527f696e76616c6964206465706f736974207472616e736974696f6e2c206d69736d60408201527f61746368206f722077726f6e67206f72646572696e6700000000000000000000606082015260800190565b60208082526019908201527f6e6574206465706f7369742065786365656473206c696d697400000000000000604082015260600190565b6020808252602f908201527f696e76616c6964206465706f736974207472616e736974696f6e2c206e6f207060408201527f656e64696e67206465706f736974730000000000000000000000000000000000606082015260800190565b60208082526016908201527f4661696c656420746f2077697468647261772045544800000000000000000000604082015260600190565b60208082526013908201527f4661696c656420746f20647261696e2045544800000000000000000000000000604082015260600190565b60208082526013908201527f45544820616d6f756e74206d69736d6174636800000000000000000000000000604082015260600190565b60208082526013908201527f556e6b6e6f776e20737472617465677920494400000000000000000000000000604082015260600190565b6020808252601f908201527f426c6f636b207374696c6c20696e206368616c6c656e676520706572696f6400604082015260600190565b60208082526039908201527f696e76616c69642062616c616e63652073796e63207472616e736974696f6e2c60408201527f206e6f2070656e64696e672062616c616e63652073796e637300000000000000606082015260800190565b6020808252603b908201527f696e76616c69642062616c616e63652073796e63207472616e736974696f6e2c60408201527f206d69736d61746368206f722077726f6e67206f72646572696e670000000000606082015260800190565b6020808252818101527f496e76616c696420626c6f636b20696e74656e74207472616e736974696f6e73604082015260600190565b6020808252601b908201527f4e6f20626c6f636b732070656e64696e6720657865637574696f6e0000000000604082015260600190565b6020808252601e908201527f426c6f636b206368616c6c656e676520706572696f64206973206f7665720000604082015260600190565b6020808252818101527f4e6f7420657863656564206d6178207072696f726974792074782064656c6179604082015260600190565b6020808252600d908201527f556e6b6e6f776e20617373657400000000000000000000000000000000000000604082015260600190565b60208082526016908201527f63616c6c6572206973206e6f74206f70657261746f7200000000000000000000604082015260600190565b60208082526014908201527f4173736574206e6f742072656769737465726564000000000000000000000000604082015260600190565b6020808252600e908201527f57726f6e6720626c6f636b204944000000000000000000000000000000000000604082015260600190565b60006101a0808352614d058184018b6145c0565b90508281036020840152614d19818a6145c0565b90508281036040840152873581526020880135609e19893603018112614d3d578283fd5b6080602083015288018035614d5181614fa8565b6001600160a01b031660808301526020810135614d6d81614fbd565b63ffffffff1660a0830152614d856040820182614f2a565b60a060c0850152614d9b61012085018284614479565b915050614dab6060830183614f2a565b848303607f190160e0860152614dc2838284614479565b9250505060808201359150614dd682614fcf565b61010067ffffffffffffffff831681850152614df460408c01613fca565b9250614e03604085018461466d565b614e1060608c018c614f2a565b93508483036060860152614e25838583614479565b9450508584036060870152614e3a848b614534565b9450614e49608087018a614508565b614e55818701896144d3565b50505050614e676101808301846144c6565b98975050505050505050565b90815260200190565b6000838252604060208301528251806040840152614ea1816060850160208701614f72565b601f01601f1916919091016060019392505050565b63ffffffff91909116815260200190565b63ffffffff9390931683526020830191909152604082015260600190565b6000808335601e19843603018112614efb578283fd5b83018035915067ffffffffffffffff821115614f15578283fd5b602001915036819003821315613fac57600080fd5b6000808335601e19843603018112614f40578283fd5b830160208101925035905067ffffffffffffffff811115614f6057600080fd5b602081023603831315613fac57600080fd5b60005b83811015614f8d578181015183820152602001614f75565b838111156115cd5750506000910152565b60028110613df357fe5b6001600160a01b0381168114613df357600080fd5b63ffffffff81168114613df357600080fd5b67ffffffffffffffff81168114613df357600080fdfe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65724d65726b6c65547265653a204d7573742070726f76696465206174206c65617374206f6e65206c65616620686173682e5361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a2646970667358221220c4429aae98d236e14394adaa77e96094e68e515f209d28ca1690632ec3da98e964736f6c63430007060033

Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)

000000000000000000000000000000000000000000000000000000000000001e000000000000000000000000000000000000000000000000000000000000003c0000000000000000000000005d3c0f4ca5ee99f8e8f59ff9a5fab04f6a7e007f000000000000000000000000fe81ab6930a30bdae731fe7b6c6abfbeafc014a80000000000000000000000006c0af0e2a174aaffe9f336c0ae4d0e535735294f

-----Decoded View---------------
Arg [0] : _blockChallengePeriod (uint256): 30
Arg [1] : _maxPriorityTxDelay (uint256): 60
Arg [2] : _transitionDisputerAddress (address): 0x5D3c0F4cA5EE99f8E8F59Ff9A5fAb04F6a7e007f
Arg [3] : _registryAddress (address): 0xFe81ab6930A30BdaE731fe7b6C6ABFbEAFc014a8
Arg [4] : _operator (address): 0x6c0aF0E2a174AAffE9F336C0Ae4D0e535735294F

-----Encoded View---------------
5 Constructor Arguments found :
Arg [0] : 000000000000000000000000000000000000000000000000000000000000001e
Arg [1] : 000000000000000000000000000000000000000000000000000000000000003c
Arg [2] : 0000000000000000000000005d3c0f4ca5ee99f8e8f59ff9a5fab04f6a7e007f
Arg [3] : 000000000000000000000000fe81ab6930a30bdae731fe7b6c6abfbeafc014a8
Arg [4] : 0000000000000000000000006c0af0e2a174aaffe9f336c0ae4d0e535735294f


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  ]
[ 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.