ETH Price: $3,224.94 (+0.88%)

Contract

0x6330D5F08f51057F36F46d6751eCDc0c65Ef7E9e
 

Overview

ETH Balance

0 ETH

ETH Value

$0.00

Token Holdings

Sponsored

Transaction Hash
Method
Block
From
To
Value
Migrate Vesting ...1190410432024-04-21 6:27:432 days ago1713680863IN
Synthetix: OP Reward Escrow V2
0 ETH0.000000170.0077816
Nominate New Own...1190410272024-04-21 6:27:112 days ago1713680831IN
Synthetix: OP Reward Escrow V2
0 ETH0.000000190.00790013
Migrate Vesting ...1190409882024-04-21 6:25:532 days ago1713680753IN
Synthetix: OP Reward Escrow V2
0 ETH0.000000170.00790572
Create Escrow En...1190409442024-04-21 6:24:252 days ago1713680665IN
Synthetix: OP Reward Escrow V2
0 ETH0.000000490.00776786
Create Escrow En...1190409362024-04-21 6:24:092 days ago1713680649IN
Synthetix: OP Reward Escrow V2
0 ETH0.000000490.00770424
Create Escrow En...1190408502024-04-21 6:21:172 days ago1713680477IN
Synthetix: OP Reward Escrow V2
0 ETH0.00000050.00782964
Migrate Vesting ...1190407282024-04-21 6:17:132 days ago1713680233IN
Synthetix: OP Reward Escrow V2
0 ETH0.000000170.00779178
Migrate Vesting ...1190407192024-04-21 6:16:552 days ago1713680215IN
Synthetix: OP Reward Escrow V2
0 ETH0.000000160.00759764
Nominate Account...1190406862024-04-21 6:15:492 days ago1713680149IN
Synthetix: OP Reward Escrow V2
0 ETH0.00000020.00771233
Nominate New Own...1190406772024-04-21 6:15:312 days ago1713680131IN
Synthetix: OP Reward Escrow V2
0 ETH0.000000180.00768599
Migrate Vesting ...1190402702024-04-21 6:01:572 days ago1713679317IN
Synthetix: OP Reward Escrow V2
0 ETH0.000000160.00760415
Nominate Account...1190402532024-04-21 6:01:232 days ago1713679283IN
Synthetix: OP Reward Escrow V2
0 ETH0.00000020.00771262
Nominate New Own...1190402352024-04-21 6:00:472 days ago1713679247IN
Synthetix: OP Reward Escrow V2
0 ETH0.000000180.00773044
Migrate Vesting ...1190402312024-04-21 6:00:392 days ago1713679239IN
Synthetix: OP Reward Escrow V2
0 ETH0.000000170.00776811
Nominate New Own...1190402192024-04-21 6:00:152 days ago1713679215IN
Synthetix: OP Reward Escrow V2
0 ETH0.000000180.00766236
Migrate Account ...1189659962024-04-19 12:46:094 days ago1713530769IN
Synthetix: OP Reward Escrow V2
0 ETH0.000001440.06043582
Migrate Vesting ...1189655052024-04-19 12:29:474 days ago1713529787IN
Synthetix: OP Reward Escrow V2
0 ETH0.000001350.06147449
Nominate New Own...1189654702024-04-19 12:28:374 days ago1713529717IN
Synthetix: OP Reward Escrow V2
0 ETH0.000001540.06356269
Vest1174312082024-03-15 0:06:3340 days ago1710461193IN
Synthetix: OP Reward Escrow V2
0 ETH0.000001080.0063196
Vest1174176742024-03-14 16:35:2540 days ago1710434125IN
Synthetix: OP Reward Escrow V2
0 ETH0.000097990.1610351
Vest1173972332024-03-14 5:14:0340 days ago1710393243IN
Synthetix: OP Reward Escrow V2
0 ETH0.000000450.00666443
Vest1173972152024-03-14 5:13:2740 days ago1710393207IN
Synthetix: OP Reward Escrow V2
0 ETH0.000000170.00666443
Vest1173972052024-03-14 5:13:0740 days ago1710393187IN
Synthetix: OP Reward Escrow V2
0 ETH0.000000170.00666443
Vest1173879202024-03-14 0:03:3741 days ago1710374617IN
Synthetix: OP Reward Escrow V2
0 ETH0.000000030.00088559
Vest1173813452024-03-13 20:24:2741 days ago1710361467IN
Synthetix: OP Reward Escrow V2
0 ETH0.000000050.00100031
View all transactions

Latest 25 internal transactions (View All)

Advanced mode:
Parent Transaction Hash Block From To Value
1075582822023-07-30 11:09:01268 days ago1690715341
Synthetix: OP Reward Escrow V2
0 ETH
1075582822023-07-30 11:09:01268 days ago1690715341
Synthetix: OP Reward Escrow V2
0 ETH
1075582682023-07-30 11:08:33268 days ago1690715313
Synthetix: OP Reward Escrow V2
0 ETH
1075582682023-07-30 11:08:33268 days ago1690715313
Synthetix: OP Reward Escrow V2
0 ETH
1075582272023-07-30 11:07:11268 days ago1690715231
Synthetix: OP Reward Escrow V2
0 ETH
1075582272023-07-30 11:07:11268 days ago1690715231
Synthetix: OP Reward Escrow V2
0 ETH
1075581042023-07-30 11:03:05268 days ago1690714985
Synthetix: OP Reward Escrow V2
0 ETH
1075581042023-07-30 11:03:05268 days ago1690714985
Synthetix: OP Reward Escrow V2
0 ETH
1075581042023-07-30 11:03:05268 days ago1690714985
Synthetix: OP Reward Escrow V2
0 ETH
1075581042023-07-30 11:03:05268 days ago1690714985
Synthetix: OP Reward Escrow V2
0 ETH
1075581042023-07-30 11:03:05268 days ago1690714985
Synthetix: OP Reward Escrow V2
0 ETH
1075581042023-07-30 11:03:05268 days ago1690714985
Synthetix: OP Reward Escrow V2
0 ETH
1075581042023-07-30 11:03:05268 days ago1690714985
Synthetix: OP Reward Escrow V2
0 ETH
1075581042023-07-30 11:03:05268 days ago1690714985
Synthetix: OP Reward Escrow V2
0 ETH
1075581042023-07-30 11:03:05268 days ago1690714985
Synthetix: OP Reward Escrow V2
0 ETH
1075580812023-07-30 11:02:19268 days ago1690714939
Synthetix: OP Reward Escrow V2
0 ETH
1075580812023-07-30 11:02:19268 days ago1690714939
Synthetix: OP Reward Escrow V2
0 ETH
1075580412023-07-30 11:00:59268 days ago1690714859
Synthetix: OP Reward Escrow V2
0 ETH
1075580412023-07-30 11:00:59268 days ago1690714859
Synthetix: OP Reward Escrow V2
0 ETH
1075580412023-07-30 11:00:59268 days ago1690714859
Synthetix: OP Reward Escrow V2
0 ETH
1075580412023-07-30 11:00:59268 days ago1690714859
Synthetix: OP Reward Escrow V2
0 ETH
1075580412023-07-30 11:00:59268 days ago1690714859
Synthetix: OP Reward Escrow V2
0 ETH
1075580412023-07-30 11:00:59268 days ago1690714859
Synthetix: OP Reward Escrow V2
0 ETH
1075580412023-07-30 11:00:59268 days ago1690714859
Synthetix: OP Reward Escrow V2
0 ETH
1075579822023-07-30 10:59:01268 days ago1690714741
Synthetix: OP Reward Escrow V2
0 ETH
View All Internal Transactions

Latest 25 Deposits

L2 Txn Hash L1 Deposit Txn Value Token
0xcbabc5dc981e0e10dbf5042a392f61c84bcd1d959b732307d78842fbc6364bf22024-03-03 7:55:4351 days ago17094525431,027.924023127145802915 Synthetix Ne... (SNX)
0xcbabc5dc981e0e10dbf5042a392f61c84bcd1d959b732307d78842fbc6364bf22024-03-03 7:55:4351 days ago17094525431,027.924023127145802912 Synthetix Ne... (SNX)
0x7c2fce0840c4c4c762be77364d37b8a3c65b294a699cdd05fa81a075b626617e2024-02-26 8:58:5957 days ago1708937939562.701732193676628524 Synthetix Ne... (SNX)
0x7c2fce0840c4c4c762be77364d37b8a3c65b294a699cdd05fa81a075b626617e2024-02-26 8:58:5957 days ago1708937939562.701732193676628526 Synthetix Ne... (SNX)
0xdd7690b1137bfa9a3b40f7af0dd0b43a515ddbe7b1775fde75add75d2f8670112024-02-05 8:29:5178 days ago17071217912,054.380738414453068969 Synthetix Ne... (SNX)
0xdd7690b1137bfa9a3b40f7af0dd0b43a515ddbe7b1775fde75add75d2f8670112024-02-05 8:29:5178 days ago17071217912,054.380738414453068971 Synthetix Ne... (SNX)
0x24fe2d6da7e8cbaf137ee84a2b1e337953d70bab4dbab59b5ececb264aa121902024-02-03 5:27:1580 days ago1706938035412.810018376587495754 Synthetix Ne... (SNX)
0x24fe2d6da7e8cbaf137ee84a2b1e337953d70bab4dbab59b5ececb264aa121902024-02-03 5:27:1580 days ago1706938035412.810018376587495753 Synthetix Ne... (SNX)
0x64c9d6ac3e85ecee2c7400e71e528f80cbb80f2b931b712bfc81f09c5afc4a3b2024-01-21 4:56:2193 days ago17058129810.075232709929352787 Synthetix Ne... (SNX)
0x64c9d6ac3e85ecee2c7400e71e528f80cbb80f2b931b712bfc81f09c5afc4a3b2024-01-21 4:56:2193 days ago17058129810.075232709929352783 Synthetix Ne... (SNX)
0x080c40e52c8c2a181bd02d5577cdbb0d21231de614b0ce73bd45d8344bc5ab782024-01-06 3:00:49108 days ago17045100492,172.882537583291508623 Synthetix Ne... (SNX)
0xecc0387795d7c034e9af913993c9eaf0c1171ce26b7171da8828645cdd3c84182024-01-06 3:00:49108 days ago1704510049183.129371452960263472 Synthetix Ne... (SNX)
0xa6027521dc189705e65a030339581fb5aa840d58414998143615842affef1a822023-12-31 9:35:49114 days ago17040153491,449.988631447087427833 Synthetix Ne... (SNX)
0xabb10409e448d6698ba8f3b76634336316f3b885967a10c03cf1a23638482ff52023-12-22 8:28:09123 days ago170323368925,485.254757808236544116 Synthetix Ne... (SNX)
0xe5c51d1d0be5b6ff95a41fb0f5906dc3b55a406eee5bdb4ee8e743fe602fe6d22023-12-22 8:28:09123 days ago170323368917,967.216632009913925485 Synthetix Ne... (SNX)
0xa6f8e2d2eeb152ff210b854eabf28af9224ef2c9185c3d262aa73e1a5bdf1b4b2023-12-14 12:35:35131 days ago170255733532,027.244065637233561986 Synthetix Ne... (SNX)
0x70bcad7d3af42db1b5e493f1d91fe669664f1731cf0629ffda575bc03d91a3282023-12-11 8:02:09134 days ago17022817296,754.26729765563312374 Synthetix Ne... (SNX)
0x4c71472663e8ce14e3784941379067a1fabafece57a1072562e6889fc62822072023-12-10 1:19:15136 days ago17021711551,264.658269859941740731 Synthetix Ne... (SNX)
0xa5bff940f523c98952df6d2b4edee843d9f98829eaefc35efe5c0adbf42db5db2023-12-07 0:01:25139 days ago1701907285130,178 Synthetix Ne... (SNX)
0xc82489f175d734b9b9b6433522d6f5480443f19490fccbf53152ea80e757765d2023-12-02 3:53:57143 days ago17014892371,810.20663487552776499 Synthetix Ne... (SNX)
0xd328215eea9354a3eca5be67f7f83273e6717c5cf5836051712f38ec0f2b072b2023-12-02 3:53:57143 days ago170148923714,413.955691296474129776 Synthetix Ne... (SNX)
0x915e2bb8d52ff9ea000655288407f1a90a294902d70a5f6c791fd8805c25a4f32023-12-01 15:26:45144 days ago1701444405277.628082549538397169 Synthetix Ne... (SNX)
0xbc35dea217aeed840a7f1841a6aebabcf324179842b9f6573f244c420638efb92023-11-30 0:01:29146 days ago1701302489130,178 Synthetix Ne... (SNX)
0xd6f840472213ff30dba1be8e2e57a7660505ea18cbc959281f9600c8269db1d12023-11-25 1:18:05151 days ago1700875085139.798673317541472935 Synthetix Ne... (SNX)
0x4ef0e24581c56d700c4a9b2da53b8673ff6f7c5b0afe398c6462b319c380fd5e2023-11-23 0:01:19153 days ago1700697679130,178 Synthetix Ne... (SNX)
View All Deposits

Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
ImportableRewardEscrowV2

Compiler Version
v0.5.16+commit.9c3226ce

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion

Contract Source Code (Solidity)

/**
 *Submitted for verification at optimistic.etherscan.io on 2022-10-20
*/

/*
   ____            __   __        __   _
  / __/__ __ ___  / /_ / /  ___  / /_ (_)__ __
 _\ \ / // // _ \/ __// _ \/ -_)/ __// / \ \ /
/___/ \_, //_//_/\__//_//_/\__/ \__//_/ /_\_\
     /___/

* Synthetix: ImportableRewardEscrowV2.sol
*
* Latest source (may be newer): https://github.com/Synthetixio/synthetix/blob/master/contracts/ImportableRewardEscrowV2.sol
* Docs: https://docs.synthetix.io/contracts/ImportableRewardEscrowV2
*
* Contract Dependencies: 
*	- BaseRewardEscrowV2
*	- IAddressResolver
*	- IRewardEscrowV2Storage
*	- Owned
*	- State
* Libraries: 
*	- SafeCast
*	- SafeDecimalMath
*	- SafeMath
*	- SignedSafeMath
*	- VestingEntries
*
* MIT License
* ===========
*
* Copyright (c) 2022 Synthetix
*
* 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
*/



pragma solidity ^0.5.16;

// https://docs.synthetix.io/contracts/source/contracts/owned
contract Owned {
    address public owner;
    address public nominatedOwner;

    constructor(address _owner) public {
        require(_owner != address(0), "Owner address cannot be 0");
        owner = _owner;
        emit OwnerChanged(address(0), _owner);
    }

    function nominateNewOwner(address _owner) external onlyOwner {
        nominatedOwner = _owner;
        emit OwnerNominated(_owner);
    }

    function acceptOwnership() external {
        require(msg.sender == nominatedOwner, "You must be nominated before you can accept ownership");
        emit OwnerChanged(owner, nominatedOwner);
        owner = nominatedOwner;
        nominatedOwner = address(0);
    }

    modifier onlyOwner {
        _onlyOwner();
        _;
    }

    function _onlyOwner() private view {
        require(msg.sender == owner, "Only the contract owner may perform this action");
    }

    event OwnerNominated(address newOwner);
    event OwnerChanged(address oldOwner, address newOwner);
}


// https://docs.synthetix.io/contracts/source/interfaces/iaddressresolver
interface IAddressResolver {
    function getAddress(bytes32 name) external view returns (address);

    function getSynth(bytes32 key) external view returns (address);

    function requireAndGetAddress(bytes32 name, string calldata reason) external view returns (address);
}


// https://docs.synthetix.io/contracts/source/interfaces/isynth
interface ISynth {
    // Views
    function currencyKey() external view returns (bytes32);

    function transferableSynths(address account) external view returns (uint);

    // Mutative functions
    function transferAndSettle(address to, uint value) external returns (bool);

    function transferFromAndSettle(
        address from,
        address to,
        uint value
    ) external returns (bool);

    // Restricted: used internally to Synthetix
    function burn(address account, uint amount) external;

    function issue(address account, uint amount) external;
}


// https://docs.synthetix.io/contracts/source/interfaces/iissuer
interface IIssuer {
    // Views

    function allNetworksDebtInfo()
        external
        view
        returns (
            uint256 debt,
            uint256 sharesSupply,
            bool isStale
        );

    function anySynthOrSNXRateIsInvalid() external view returns (bool anyRateInvalid);

    function availableCurrencyKeys() external view returns (bytes32[] memory);

    function availableSynthCount() external view returns (uint);

    function availableSynths(uint index) external view returns (ISynth);

    function canBurnSynths(address account) external view returns (bool);

    function collateral(address account) external view returns (uint);

    function collateralisationRatio(address issuer) external view returns (uint);

    function collateralisationRatioAndAnyRatesInvalid(address _issuer)
        external
        view
        returns (uint cratio, bool anyRateIsInvalid);

    function debtBalanceOf(address issuer, bytes32 currencyKey) external view returns (uint debtBalance);

    function issuanceRatio() external view returns (uint);

    function lastIssueEvent(address account) external view returns (uint);

    function maxIssuableSynths(address issuer) external view returns (uint maxIssuable);

    function minimumStakeTime() external view returns (uint);

    function remainingIssuableSynths(address issuer)
        external
        view
        returns (
            uint maxIssuable,
            uint alreadyIssued,
            uint totalSystemDebt
        );

    function synths(bytes32 currencyKey) external view returns (ISynth);

    function getSynths(bytes32[] calldata currencyKeys) external view returns (ISynth[] memory);

    function synthsByAddress(address synthAddress) external view returns (bytes32);

    function totalIssuedSynths(bytes32 currencyKey, bool excludeOtherCollateral) external view returns (uint);

    function transferableSynthetixAndAnyRateIsInvalid(address account, uint balance)
        external
        view
        returns (uint transferable, bool anyRateIsInvalid);

    function liquidationAmounts(address account, bool isSelfLiquidation)
        external
        view
        returns (
            uint totalRedeemed,
            uint debtToRemove,
            uint escrowToLiquidate,
            uint initialDebtBalance
        );

    // Restricted: used internally to Synthetix
    function addSynths(ISynth[] calldata synthsToAdd) external;

    function issueSynths(address from, uint amount) external;

    function issueSynthsOnBehalf(
        address issueFor,
        address from,
        uint amount
    ) external;

    function issueMaxSynths(address from) external;

    function issueMaxSynthsOnBehalf(address issueFor, address from) external;

    function burnSynths(address from, uint amount) external;

    function burnSynthsOnBehalf(
        address burnForAddress,
        address from,
        uint amount
    ) external;

    function burnSynthsToTarget(address from) external;

    function burnSynthsToTargetOnBehalf(address burnForAddress, address from) external;

    function burnForRedemption(
        address deprecatedSynthProxy,
        address account,
        uint balance
    ) external;

    function setCurrentPeriodId(uint128 periodId) external;

    function liquidateAccount(address account, bool isSelfLiquidation)
        external
        returns (
            uint totalRedeemed,
            uint debtRemoved,
            uint escrowToLiquidate
        );

    function issueSynthsWithoutDebt(
        bytes32 currencyKey,
        address to,
        uint amount
    ) external returns (bool rateInvalid);

    function burnSynthsWithoutDebt(
        bytes32 currencyKey,
        address to,
        uint amount
    ) external returns (bool rateInvalid);
}


// Inheritance


// Internal references


// https://docs.synthetix.io/contracts/source/contracts/addressresolver
contract AddressResolver is Owned, IAddressResolver {
    mapping(bytes32 => address) public repository;

    constructor(address _owner) public Owned(_owner) {}

    /* ========== RESTRICTED FUNCTIONS ========== */

    function importAddresses(bytes32[] calldata names, address[] calldata destinations) external onlyOwner {
        require(names.length == destinations.length, "Input lengths must match");

        for (uint i = 0; i < names.length; i++) {
            bytes32 name = names[i];
            address destination = destinations[i];
            repository[name] = destination;
            emit AddressImported(name, destination);
        }
    }

    /* ========= PUBLIC FUNCTIONS ========== */

    function rebuildCaches(MixinResolver[] calldata destinations) external {
        for (uint i = 0; i < destinations.length; i++) {
            destinations[i].rebuildCache();
        }
    }

    /* ========== VIEWS ========== */

    function areAddressesImported(bytes32[] calldata names, address[] calldata destinations) external view returns (bool) {
        for (uint i = 0; i < names.length; i++) {
            if (repository[names[i]] != destinations[i]) {
                return false;
            }
        }
        return true;
    }

    function getAddress(bytes32 name) external view returns (address) {
        return repository[name];
    }

    function requireAndGetAddress(bytes32 name, string calldata reason) external view returns (address) {
        address _foundAddress = repository[name];
        require(_foundAddress != address(0), reason);
        return _foundAddress;
    }

    function getSynth(bytes32 key) external view returns (address) {
        IIssuer issuer = IIssuer(repository["Issuer"]);
        require(address(issuer) != address(0), "Cannot find Issuer address");
        return address(issuer.synths(key));
    }

    /* ========== EVENTS ========== */

    event AddressImported(bytes32 name, address destination);
}


// Internal references


// https://docs.synthetix.io/contracts/source/contracts/mixinresolver
contract MixinResolver {
    AddressResolver public resolver;

    mapping(bytes32 => address) private addressCache;

    constructor(address _resolver) internal {
        resolver = AddressResolver(_resolver);
    }

    /* ========== INTERNAL FUNCTIONS ========== */

    function combineArrays(bytes32[] memory first, bytes32[] memory second)
        internal
        pure
        returns (bytes32[] memory combination)
    {
        combination = new bytes32[](first.length + second.length);

        for (uint i = 0; i < first.length; i++) {
            combination[i] = first[i];
        }

        for (uint j = 0; j < second.length; j++) {
            combination[first.length + j] = second[j];
        }
    }

    /* ========== PUBLIC FUNCTIONS ========== */

    // Note: this function is public not external in order for it to be overridden and invoked via super in subclasses
    function resolverAddressesRequired() public view returns (bytes32[] memory addresses) {}

    function rebuildCache() public {
        bytes32[] memory requiredAddresses = resolverAddressesRequired();
        // The resolver must call this function whenver it updates its state
        for (uint i = 0; i < requiredAddresses.length; i++) {
            bytes32 name = requiredAddresses[i];
            // Note: can only be invoked once the resolver has all the targets needed added
            address destination =
                resolver.requireAndGetAddress(name, string(abi.encodePacked("Resolver missing target: ", name)));
            addressCache[name] = destination;
            emit CacheUpdated(name, destination);
        }
    }

    /* ========== VIEWS ========== */

    function isResolverCached() external view returns (bool) {
        bytes32[] memory requiredAddresses = resolverAddressesRequired();
        for (uint i = 0; i < requiredAddresses.length; i++) {
            bytes32 name = requiredAddresses[i];
            // false if our cache is invalid or if the resolver doesn't have the required address
            if (resolver.getAddress(name) != addressCache[name] || addressCache[name] == address(0)) {
                return false;
            }
        }

        return true;
    }

    /* ========== INTERNAL FUNCTIONS ========== */

    function requireAndGetAddress(bytes32 name) internal view returns (address) {
        address _foundAddress = addressCache[name];
        require(_foundAddress != address(0), string(abi.encodePacked("Missing address: ", name)));
        return _foundAddress;
    }

    /* ========== EVENTS ========== */

    event CacheUpdated(bytes32 name, address destination);
}


pragma experimental ABIEncoderV2;

library VestingEntries {
    struct VestingEntry {
        uint64 endTime;
        uint256 escrowAmount;
    }
    struct VestingEntryWithID {
        uint64 endTime;
        uint256 escrowAmount;
        uint256 entryID;
    }
}

/// SIP-252: this is the interface for immutable V2 escrow (renamed with suffix Frozen).
/// These sources need to exist here and match on-chain frozen contracts for tests and reference.
/// the reason for the naming mess is that the immutable LiquidatorRewards expects a working
/// RewardEscrowV2 resolver entry for its getReward method, so the "new" (would be V3)
/// needs to be found at that entry for liq-rewards to function.
interface IRewardEscrowV2Frozen {
    // Views
    function balanceOf(address account) external view returns (uint);

    function numVestingEntries(address account) external view returns (uint);

    function totalEscrowedBalance() external view returns (uint);

    function totalEscrowedAccountBalance(address account) external view returns (uint);

    function totalVestedAccountBalance(address account) external view returns (uint);

    function getVestingQuantity(address account, uint256[] calldata entryIDs) external view returns (uint);

    function getVestingSchedules(
        address account,
        uint256 index,
        uint256 pageSize
    ) external view returns (VestingEntries.VestingEntryWithID[] memory);

    function getAccountVestingEntryIDs(
        address account,
        uint256 index,
        uint256 pageSize
    ) external view returns (uint256[] memory);

    function getVestingEntryClaimable(address account, uint256 entryID) external view returns (uint);

    function getVestingEntry(address account, uint256 entryID) external view returns (uint64, uint256);

    // Mutative functions
    function vest(uint256[] calldata entryIDs) external;

    function createEscrowEntry(
        address beneficiary,
        uint256 deposit,
        uint256 duration
    ) external;

    function appendVestingEntry(
        address account,
        uint256 quantity,
        uint256 duration
    ) external;

    function migrateVestingSchedule(address _addressToMigrate) external;

    function migrateAccountEscrowBalances(
        address[] calldata accounts,
        uint256[] calldata escrowBalances,
        uint256[] calldata vestedBalances
    ) external;

    // Account Merging
    function startMergingWindow() external;

    function mergeAccount(address accountToMerge, uint256[] calldata entryIDs) external;

    function nominateAccountToMerge(address account) external;

    function accountMergingIsOpen() external view returns (bool);

    // L2 Migration
    function importVestingEntries(
        address account,
        uint256 escrowedAmount,
        VestingEntries.VestingEntry[] calldata vestingEntries
    ) external;

    // Return amount of SNX transfered to SynthetixBridgeToOptimism deposit contract
    function burnForMigration(address account, uint256[] calldata entryIDs)
        external
        returns (uint256 escrowedAccountBalance, VestingEntries.VestingEntry[] memory vestingEntries);

    function nextEntryId() external view returns (uint);

    function vestingSchedules(address account, uint256 entryId) external view returns (VestingEntries.VestingEntry memory);

    function accountVestingEntryIDs(address account, uint256 index) external view returns (uint);

    //function totalEscrowedAccountBalance(address account) external view returns (uint);
    //function totalVestedAccountBalance(address account) external view returns (uint);
}


interface IRewardEscrowV2Storage {
    /// Views
    function numVestingEntries(address account) external view returns (uint);

    function totalEscrowedAccountBalance(address account) external view returns (uint);

    function totalVestedAccountBalance(address account) external view returns (uint);

    function totalEscrowedBalance() external view returns (uint);

    function nextEntryId() external view returns (uint);

    function vestingSchedules(address account, uint256 entryId) external view returns (VestingEntries.VestingEntry memory);

    function accountVestingEntryIDs(address account, uint256 index) external view returns (uint);

    /// Mutative
    function setZeroAmount(address account, uint entryId) external;

    function setZeroAmountUntilTarget(
        address account,
        uint startIndex,
        uint targetAmount
    )
        external
        returns (
            uint total,
            uint endIndex,
            uint lastEntryTime
        );

    function updateEscrowAccountBalance(address account, int delta) external;

    function updateVestedAccountBalance(address account, int delta) external;

    function updateTotalEscrowedBalance(int delta) external;

    function addVestingEntry(address account, VestingEntries.VestingEntry calldata entry) external returns (uint);

    // setFallbackRewardEscrow is used for configuration but not used by contracts
}

/// this should remain backwards compatible to IRewardEscrowV2Frozen
/// ideally this would be done by inheriting from that interface
/// but solidity v0.5 doesn't support interface inheritance
interface IRewardEscrowV2 {
    // Views
    function balanceOf(address account) external view returns (uint);

    function numVestingEntries(address account) external view returns (uint);

    function totalEscrowedBalance() external view returns (uint);

    function totalEscrowedAccountBalance(address account) external view returns (uint);

    function totalVestedAccountBalance(address account) external view returns (uint);

    function getVestingQuantity(address account, uint256[] calldata entryIDs) external view returns (uint);

    function getVestingSchedules(
        address account,
        uint256 index,
        uint256 pageSize
    ) external view returns (VestingEntries.VestingEntryWithID[] memory);

    function getAccountVestingEntryIDs(
        address account,
        uint256 index,
        uint256 pageSize
    ) external view returns (uint256[] memory);

    function getVestingEntryClaimable(address account, uint256 entryID) external view returns (uint);

    function getVestingEntry(address account, uint256 entryID) external view returns (uint64, uint256);

    // Mutative functions
    function vest(uint256[] calldata entryIDs) external;

    function createEscrowEntry(
        address beneficiary,
        uint256 deposit,
        uint256 duration
    ) external;

    function appendVestingEntry(
        address account,
        uint256 quantity,
        uint256 duration
    ) external;

    function migrateVestingSchedule(address _addressToMigrate) external;

    function migrateAccountEscrowBalances(
        address[] calldata accounts,
        uint256[] calldata escrowBalances,
        uint256[] calldata vestedBalances
    ) external;

    // Account Merging
    function startMergingWindow() external;

    function mergeAccount(address accountToMerge, uint256[] calldata entryIDs) external;

    function nominateAccountToMerge(address account) external;

    function accountMergingIsOpen() external view returns (bool);

    // L2 Migration
    function importVestingEntries(
        address account,
        uint256 escrowedAmount,
        VestingEntries.VestingEntry[] calldata vestingEntries
    ) external;

    // Return amount of SNX transfered to SynthetixBridgeToOptimism deposit contract
    function burnForMigration(address account, uint256[] calldata entryIDs)
        external
        returns (uint256 escrowedAccountBalance, VestingEntries.VestingEntry[] memory vestingEntries);

    function nextEntryId() external view returns (uint);

    function vestingSchedules(address account, uint256 entryId) external view returns (VestingEntries.VestingEntry memory);

    function accountVestingEntryIDs(address account, uint256 index) external view returns (uint);

    /// below are methods not available in IRewardEscrowV2Frozen

    // revoke entries for liquidations (access controlled to Synthetix)
    function revokeFrom(
        address account,
        address recipient,
        uint targetAmount,
        uint startIndex
    ) external;
}


// SPDX-License-Identifier: MIT

/*
The MIT License (MIT)

Copyright (c) 2016-2020 zOS Global Limited

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.
*/

/*
 * When we upgrade to solidity v0.6.0 or above, we should be able to
 * just do import `"openzeppelin-solidity-3.0.0/contracts/math/SignedSafeMath.sol";`
 * wherever this is used.
 */


/**
 * @title SignedSafeMath
 * @dev Signed math operations with safety checks that revert on error.
 */
library SignedSafeMath {
    int256 private constant _INT256_MIN = -2**255;

    /**
     * @dev Returns the multiplication of two signed integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     *
     * - Multiplication cannot overflow.
     */
    function mul(int256 a, int256 b) internal pure returns (int256) {
        // 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 0;
        }

        require(!(a == -1 && b == _INT256_MIN), "SignedSafeMath: multiplication overflow");

        int256 c = a * b;
        require(c / a == b, "SignedSafeMath: multiplication overflow");

        return c;
    }

    /**
     * @dev Returns the integer division of two signed integers. Reverts 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(int256 a, int256 b) internal pure returns (int256) {
        require(b != 0, "SignedSafeMath: division by zero");
        require(!(b == -1 && a == _INT256_MIN), "SignedSafeMath: division overflow");

        int256 c = a / b;

        return c;
    }

    /**
     * @dev Returns the subtraction of two signed integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(int256 a, int256 b) internal pure returns (int256) {
        int256 c = a - b;
        require((b >= 0 && c <= a) || (b < 0 && c > a), "SignedSafeMath: subtraction overflow");

        return c;
    }

    /**
     * @dev Returns the addition of two signed integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     *
     * - Addition cannot overflow.
     */
    function add(int256 a, int256 b) internal pure returns (int256) {
        int256 c = a + b;
        require((b >= 0 && c >= a) || (b < 0 && c < a), "SignedSafeMath: addition overflow");

        return c;
    }
}


/**
 * @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, 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");
        uint256 c = a - b;

        return c;
    }

    /**
     * @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) {
        // 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-solidity/pull/522
        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. Reverts 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) {
        // Solidity only automatically asserts when dividing by 0
        require(b > 0, "SafeMath: division by zero");
        uint256 c = a / b;
        // assert(a == b * c + a % b); // There is no case in which this doesn't hold

        return c;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts 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;
    }
}


// Inheritance


// https://docs.synthetix.io/contracts/source/contracts/state
contract State is Owned {
    // the address of the contract that can modify variables
    // this can only be changed by the owner of this contract
    address public associatedContract;

    constructor(address _associatedContract) internal {
        // This contract is abstract, and thus cannot be instantiated directly
        require(owner != address(0), "Owner must be set");

        associatedContract = _associatedContract;
        emit AssociatedContractUpdated(_associatedContract);
    }

    /* ========== SETTERS ========== */

    // Change the associated contract to a new address
    function setAssociatedContract(address _associatedContract) external onlyOwner {
        associatedContract = _associatedContract;
        emit AssociatedContractUpdated(_associatedContract);
    }

    /* ========== MODIFIERS ========== */

    modifier onlyAssociatedContract {
        require(msg.sender == associatedContract, "Only the associated contract can perform this action");
        _;
    }

    /* ========== EVENTS ========== */

    event AssociatedContractUpdated(address associatedContract);
}


// interface for vesting entries


// interface


// libraries


// inheritance


/// A contract for reading and writing to/from storage while falling back to values from
/// previous RewardEscrowV2 contract.
contract RewardEscrowV2Storage is IRewardEscrowV2Storage, State {
    using SafeMath for uint;
    using SignedSafeMath for int;

    // cheaper storage for L1 compared to original struct, only used for storage
    // original struct still used in interface for backwards compatibility
    struct StorageEntry {
        uint32 endTime;
        uint224 escrowAmount;
    }

    /// INTERNAL storage

    // accounts => vesting entries
    mapping(address => mapping(uint => StorageEntry)) internal _vestingSchedules;

    // accounts => entry ids
    mapping(address => uint[]) internal _accountVestingEntryIds;

    // accounts => cache of entry counts in fallback contract
    // this as an int in order to be able to store ZERO_PLACEHOLDER to only cache once
    mapping(address => int) internal _fallbackCounts;

    // account's total escrow SNX balance (still to vest)
    // this as an int in order to be able to store ZERO_PLACEHOLDER to prevent reading stale values
    mapping(address => int) internal _totalEscrowedAccountBalance;

    // account's total vested rewards (vested already)
    // this as an int in order to be able to store ZERO_PLACEHOLDER to prevent reading stale values
    mapping(address => int) internal _totalVestedAccountBalance;

    // The total remaining escrow balance of contract
    uint internal _totalEscrowedBalance;

    /// PUBLIC storage

    // Counter for new vesting entry ids.
    uint public nextEntryId;

    // id starting from which the new entries are stored in this contact only (and don't need to be read from fallback)
    uint public firstNonFallbackId;

    // -1 wei is a zero value placeholder in the read-through storage.
    // needed to prevent writing zeros and reading stale values (0 is used to mean uninitialized)
    // The alternative of explicit flags introduces its own set problems of ensuring they are written and read
    // correctly (in addition to the values themselves). It adds code complexity, and gas costs, which when optimized
    // lead to added coupling between different variables and even more complexity and potential for mistakenly
    // invalidating or not invalidating the cache.
    int internal constant ZERO_PLACEHOLDER = -1;

    // previous rewards escrow contract
    IRewardEscrowV2Frozen public fallbackRewardEscrow;

    // interface view
    bytes32 public constant CONTRACT_NAME = "RewardEscrowV2Storage";

    /* ========== CONSTRUCTOR ========== */

    constructor(address _owner, address _associatedContract) public Owned(_owner) State(_associatedContract) {}

    /// this can happen only once and assumes that IRewardEscrowV2Frozen is in fact Frozen both in code and in
    /// data(!!) with most mutative methods reverting (e.g. due to blocked transfers)
    function setFallbackRewardEscrow(IRewardEscrowV2Frozen _fallbackRewardEscrow) external onlyOwner {
        require(address(fallbackRewardEscrow) == address(0), "already set");
        require(address(_fallbackRewardEscrow) != address(0), "cannot be zero address");

        fallbackRewardEscrow = _fallbackRewardEscrow;
        nextEntryId = _fallbackRewardEscrow.nextEntryId();
        firstNonFallbackId = nextEntryId;

        // carry over previous balance tracking
        _totalEscrowedBalance = fallbackRewardEscrow.totalEscrowedBalance();
    }

    /* ========== VIEWS ========== */

    function vestingSchedules(address account, uint entryId)
        public
        view
        withFallback
        returns (VestingEntries.VestingEntry memory entry)
    {
        // read stored entry
        StorageEntry memory stored = _vestingSchedules[account][entryId];
        // convert to previous data size format
        entry = VestingEntries.VestingEntry({endTime: stored.endTime, escrowAmount: stored.escrowAmount});
        // read from fallback if this entryId was created in the old contract and wasn't written locally
        // this assumes that no new entries can be created with endTime = 0 (checked during addVestingEntry)
        if (entryId < firstNonFallbackId && entry.endTime == 0) {
            entry = fallbackRewardEscrow.vestingSchedules(account, entryId);
        }
        return entry;
    }

    function accountVestingEntryIDs(address account, uint index) public view withFallback returns (uint) {
        uint fallbackCount = _fallbackNumVestingEntries(account);

        // this assumes no new entries can be created in the old contract
        // any added entries in the old contract after this value is cached will be ignored
        if (index < fallbackCount) {
            return fallbackRewardEscrow.accountVestingEntryIDs(account, index);
        } else {
            return _accountVestingEntryIds[account][index - fallbackCount];
        }
    }

    function totalEscrowedBalance() public view withFallback returns (uint) {
        return _totalEscrowedBalance;
    }

    function totalEscrowedAccountBalance(address account) public view withFallback returns (uint) {
        // this as an int in order to be able to store ZERO_PLACEHOLDER which is -1
        int v = _totalEscrowedAccountBalance[account];

        // 0 should never be stored to prevent reading stale value from fallback
        if (v == 0) {
            return fallbackRewardEscrow.totalEscrowedAccountBalance(account);
        } else {
            return _readWithZeroPlaceholder(v);
        }
    }

    function totalVestedAccountBalance(address account) public view withFallback returns (uint) {
        // this as an int in order to be able to store ZERO_PLACEHOLDER which is -1
        int v = _totalVestedAccountBalance[account];

        // 0 should never be stored to prevent reading stale value from fallback
        if (v == 0) {
            return fallbackRewardEscrow.totalVestedAccountBalance(account);
        } else {
            return _readWithZeroPlaceholder(v);
        }
    }

    /// The number of vesting dates in an account's schedule.
    function numVestingEntries(address account) public view withFallback returns (uint) {
        /// assumes no enties can be written in frozen contract
        return _fallbackNumVestingEntries(account) + _accountVestingEntryIds[account].length;
    }

    /* ========== INTERNAL VIEWS ========== */

    function _fallbackNumVestingEntries(address account) internal view returns (uint) {
        // cache is used here to prevent external calls during looping
        int v = _fallbackCounts[account];
        if (v == 0) {
            // uninitialized
            return fallbackRewardEscrow.numVestingEntries(account);
        } else {
            return _readWithZeroPlaceholder(v);
        }
    }

    /* ========== MUTATIVE FUNCTIONS ========== */

    /// zeros out a single entry
    function setZeroAmount(address account, uint entryId) public withFallback onlyAssociatedContract {
        // load storage entry
        StorageEntry storage storedEntry = _vestingSchedules[account][entryId];
        // endTime is used for cache invalidation
        uint endTime = storedEntry.endTime;
        // update endTime from fallback if this is first time this entry is written in this contract
        if (endTime == 0) {
            // entry should be in fallback, otherwise it would have endTime or be uninitialized
            endTime = fallbackRewardEscrow.vestingSchedules(account, entryId).endTime;
        }
        _setZeroAmountWithEndTime(account, entryId, endTime);
    }

    /// zero out multiple entries in order of accountVestingEntryIDs until target is reached (or entries exhausted)
    /// @param account: account
    /// @param startIndex: index into accountVestingEntryIDs to start with. NOT an entryID.
    /// @param targetAmount: amount to try and reach during the iteration, once the amount it reached (and passed)
    ///     the iteration stops
    /// @return total: total sum reached, may different from targetAmount (higher if sum is a bit more), lower
    ///     if target wasn't reached reaching the length of the array
    /// @return endIndex: the index of the last revoked entry
    /// @return lastEntryTime: the endTime of the last revoked entry
    function setZeroAmountUntilTarget(
        address account,
        uint startIndex,
        uint targetAmount
    )
        external
        withFallback
        onlyAssociatedContract
        returns (
            uint total,
            uint endIndex,
            uint lastEntryTime
        )
    {
        require(targetAmount > 0, "targetAmount is zero");

        // store the count to reduce external calls in accountVestingEntryIDs
        _cacheFallbackIDCount(account);

        uint numIds = numVestingEntries(account);
        require(numIds > 0, "no entries to iterate");
        require(startIndex < numIds, "startIndex too high");

        uint entryID;
        uint i;
        VestingEntries.VestingEntry memory entry;
        for (i = startIndex; i < numIds; i++) {
            entryID = accountVestingEntryIDs(account, i);
            entry = vestingSchedules(account, entryID);

            // skip vested
            if (entry.escrowAmount > 0) {
                total = total.add(entry.escrowAmount);

                // set to zero, endTime is correct because vestingSchedules will use fallback if needed
                _setZeroAmountWithEndTime(account, entryID, entry.endTime);

                if (total >= targetAmount) {
                    break;
                }
            }
        }
        i = i == numIds ? i - 1 : i; // i was incremented one extra time if there was no break
        return (total, i, entry.endTime);
    }

    function updateEscrowAccountBalance(address account, int delta) external withFallback onlyAssociatedContract {
        // add / subtract to previous balance
        int total = int(totalEscrowedAccountBalance(account)).add(delta);
        require(total >= 0, "updateEscrowAccountBalance: balance must be positive");
        // zero value must never be written, because it is used to signal uninitialized
        //  writing an actual 0 will result in stale value being read from fallback
        // casting is safe because checked above
        _totalEscrowedAccountBalance[account] = _writeWithZeroPlaceholder(uint(total));

        // update the global total
        updateTotalEscrowedBalance(delta);
    }

    function updateVestedAccountBalance(address account, int delta) external withFallback onlyAssociatedContract {
        // add / subtract to previous balance
        int total = int(totalVestedAccountBalance(account)).add(delta);
        require(total >= 0, "updateVestedAccountBalance: balance must be positive");
        // zero value must never be written, because it is used to signal uninitialized
        //  writing an actual 0 will result in stale value being read from fallback
        // casting is safe because checked above
        _totalVestedAccountBalance[account] = _writeWithZeroPlaceholder(uint(total));
    }

    /// this method is unused in contracts (because updateEscrowAccountBalance uses it), but it is here
    /// for completeness, in case a fix to one of these values is needed (but not the other)
    function updateTotalEscrowedBalance(int delta) public withFallback onlyAssociatedContract {
        int total = int(totalEscrowedBalance()).add(delta);
        require(total >= 0, "updateTotalEscrowedBalance: balance must be positive");
        _totalEscrowedBalance = uint(total);
    }

    /// append entry for an account
    function addVestingEntry(address account, VestingEntries.VestingEntry calldata entry)
        external
        withFallback
        onlyAssociatedContract
        returns (uint)
    {
        // zero time is used as read-miss flag in this contract
        require(entry.endTime != 0, "vesting target time zero");

        uint entryId = nextEntryId;
        // since this is a completely new entry, it's safe to write it directly without checking fallback data
        _vestingSchedules[account][entryId] = StorageEntry({
            endTime: uint32(entry.endTime),
            escrowAmount: uint224(entry.escrowAmount)
        });

        // append entryId to list of entries for account
        _accountVestingEntryIds[account].push(entryId);

        // Increment the next entry id.
        nextEntryId++;

        return entryId;
    }

    /* ========== INTERNAL MUTATIVE ========== */

    /// zeros out a single entry in local contract with provided time while ensuring
    /// that endTime is not being stored as zero if it passed as zero
    function _setZeroAmountWithEndTime(
        address account,
        uint entryId,
        uint endTime
    ) internal {
        // load storage entry
        StorageEntry storage storedEntry = _vestingSchedules[account][entryId];
        // Impossible edge-case: checking that endTime is not zero (in which case the entry will be
        // read from fallback again). A zero endTime with non-zero amount is not possible in the old contract
        // but it's better to check just for completeness still, and write current timestamp (vestable).
        storedEntry.endTime = uint32(endTime != 0 ? endTime : block.timestamp);
        storedEntry.escrowAmount = 0;
    }

    /// this caching is done to prevent repeatedly calling the old contract for number of entries
    /// during looping
    function _cacheFallbackIDCount(address account) internal {
        if (_fallbackCounts[account] == 0) {
            uint fallbackCount = fallbackRewardEscrow.numVestingEntries(account);
            // cache the value but don't write zero
            _fallbackCounts[account] = _writeWithZeroPlaceholder(fallbackCount);
        }
    }

    /* ========== HELPER ========== */

    function _writeWithZeroPlaceholder(uint v) internal pure returns (int) {
        // 0 is uninitialized value, so a special value is used to store an actual 0 (that is initialized)
        return v == 0 ? ZERO_PLACEHOLDER : int(v);
    }

    function _readWithZeroPlaceholder(int v) internal pure returns (uint) {
        // 0 is uninitialized value, so a special value is used to store an actual 0 (that is initialized)
        return uint(v == ZERO_PLACEHOLDER ? 0 : v);
    }

    /* ========== Modifier ========== */

    modifier withFallback() {
        require(address(fallbackRewardEscrow) != address(0), "fallback not set");
        _;
    }
}


// https://docs.synthetix.io/contracts/source/contracts/limitedsetup
contract LimitedSetup {
    uint public setupExpiryTime;

    /**
     * @dev LimitedSetup Constructor.
     * @param setupDuration The time the setup period will last for.
     */
    constructor(uint setupDuration) internal {
        setupExpiryTime = now + setupDuration;
    }

    modifier onlyDuringSetup {
        require(now < setupExpiryTime, "Can only perform this action during setup");
        _;
    }
}


// SPDX-License-Identifier: MIT


/**
 * @dev Wrappers over Solidity's uintXX casting operators with added overflow
 * checks.
 *
 * Downcasting from uint256 in Solidity does not revert on overflow. This can
 * easily result in undesired exploitation or bugs, since developers usually
 * assume that overflows raise errors. `SafeCast` restores this intuition by
 * reverting the transaction when such 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.
 *
 * Can be combined with {SafeMath} to extend it to smaller types, by performing
 * all math on `uint256` and then downcasting.
 */
library SafeCast {
    /**
     * @dev Returns the downcasted uint128 from uint256, reverting on
     * overflow (when the input is greater than largest uint128).
     *
     * Counterpart to Solidity's `uint128` operator.
     *
     * Requirements:
     *
     * - input must fit into 128 bits
     */
    function toUint128(uint256 value) internal pure returns (uint128) {
        require(value < 2**128, "SafeCast: value doesn't fit in 128 bits");
        return uint128(value);
    }

    /**
     * @dev Returns the downcasted uint64 from uint256, reverting on
     * overflow (when the input is greater than largest uint64).
     *
     * Counterpart to Solidity's `uint64` operator.
     *
     * Requirements:
     *
     * - input must fit into 64 bits
     */
    function toUint64(uint256 value) internal pure returns (uint64) {
        require(value < 2**64, "SafeCast: value doesn't fit in 64 bits");
        return uint64(value);
    }

    /**
     * @dev Returns the downcasted uint32 from uint256, reverting on
     * overflow (when the input is greater than largest uint32).
     *
     * Counterpart to Solidity's `uint32` operator.
     *
     * Requirements:
     *
     * - input must fit into 32 bits
     */
    function toUint32(uint256 value) internal pure returns (uint32) {
        require(value < 2**32, "SafeCast: value doesn't fit in 32 bits");
        return uint32(value);
    }

    /**
     * @dev Returns the downcasted uint16 from uint256, reverting on
     * overflow (when the input is greater than largest uint16).
     *
     * Counterpart to Solidity's `uint16` operator.
     *
     * Requirements:
     *
     * - input must fit into 16 bits
     */
    function toUint16(uint256 value) internal pure returns (uint16) {
        require(value < 2**16, "SafeCast: value doesn't fit in 16 bits");
        return uint16(value);
    }

    /**
     * @dev Returns the downcasted uint8 from uint256, reverting on
     * overflow (when the input is greater than largest uint8).
     *
     * Counterpart to Solidity's `uint8` operator.
     *
     * Requirements:
     *
     * - input must fit into 8 bits.
     */
    function toUint8(uint256 value) internal pure returns (uint8) {
        require(value < 2**8, "SafeCast: value doesn't fit in 8 bits");
        return uint8(value);
    }

    /**
     * @dev Converts a signed int256 into an unsigned uint256.
     *
     * Requirements:
     *
     * - input must be greater than or equal to 0.
     */
    function toUint256(int256 value) internal pure returns (uint256) {
        require(value >= 0, "SafeCast: value must be positive");
        return uint256(value);
    }

    /**
     * @dev Converts an unsigned uint256 into a signed int256.
     *
     * Requirements:
     *
     * - input must be less than or equal to maxInt256.
     */
    function toInt256(uint256 value) internal pure returns (int256) {
        require(value < 2**255, "SafeCast: value doesn't fit in an int256");
        return int256(value);
    }
}


// Libraries


// https://docs.synthetix.io/contracts/source/libraries/safedecimalmath
library SafeDecimalMath {
    using SafeMath for uint;

    /* Number of decimal places in the representations. */
    uint8 public constant decimals = 18;
    uint8 public constant highPrecisionDecimals = 27;

    /* The number representing 1.0. */
    uint public constant UNIT = 10**uint(decimals);

    /* The number representing 1.0 for higher fidelity numbers. */
    uint public constant PRECISE_UNIT = 10**uint(highPrecisionDecimals);
    uint private constant UNIT_TO_HIGH_PRECISION_CONVERSION_FACTOR = 10**uint(highPrecisionDecimals - decimals);

    /**
     * @return Provides an interface to UNIT.
     */
    function unit() external pure returns (uint) {
        return UNIT;
    }

    /**
     * @return Provides an interface to PRECISE_UNIT.
     */
    function preciseUnit() external pure returns (uint) {
        return PRECISE_UNIT;
    }

    /**
     * @return The result of multiplying x and y, interpreting the operands as fixed-point
     * decimals.
     *
     * @dev A unit factor is divided out after the product of x and y is evaluated,
     * so that product must be less than 2**256. As this is an integer division,
     * the internal division always rounds down. This helps save on gas. Rounding
     * is more expensive on gas.
     */
    function multiplyDecimal(uint x, uint y) internal pure returns (uint) {
        /* Divide by UNIT to remove the extra factor introduced by the product. */
        return x.mul(y) / UNIT;
    }

    /**
     * @return The result of safely multiplying x and y, interpreting the operands
     * as fixed-point decimals of the specified precision unit.
     *
     * @dev The operands should be in the form of a the specified unit factor which will be
     * divided out after the product of x and y is evaluated, so that product must be
     * less than 2**256.
     *
     * Unlike multiplyDecimal, this function rounds the result to the nearest increment.
     * Rounding is useful when you need to retain fidelity for small decimal numbers
     * (eg. small fractions or percentages).
     */
    function _multiplyDecimalRound(
        uint x,
        uint y,
        uint precisionUnit
    ) private pure returns (uint) {
        /* Divide by UNIT to remove the extra factor introduced by the product. */
        uint quotientTimesTen = x.mul(y) / (precisionUnit / 10);

        if (quotientTimesTen % 10 >= 5) {
            quotientTimesTen += 10;
        }

        return quotientTimesTen / 10;
    }

    /**
     * @return The result of safely multiplying x and y, interpreting the operands
     * as fixed-point decimals of a precise unit.
     *
     * @dev The operands should be in the precise unit factor which will be
     * divided out after the product of x and y is evaluated, so that product must be
     * less than 2**256.
     *
     * Unlike multiplyDecimal, this function rounds the result to the nearest increment.
     * Rounding is useful when you need to retain fidelity for small decimal numbers
     * (eg. small fractions or percentages).
     */
    function multiplyDecimalRoundPrecise(uint x, uint y) internal pure returns (uint) {
        return _multiplyDecimalRound(x, y, PRECISE_UNIT);
    }

    /**
     * @return The result of safely multiplying x and y, interpreting the operands
     * as fixed-point decimals of a standard unit.
     *
     * @dev The operands should be in the standard unit factor which will be
     * divided out after the product of x and y is evaluated, so that product must be
     * less than 2**256.
     *
     * Unlike multiplyDecimal, this function rounds the result to the nearest increment.
     * Rounding is useful when you need to retain fidelity for small decimal numbers
     * (eg. small fractions or percentages).
     */
    function multiplyDecimalRound(uint x, uint y) internal pure returns (uint) {
        return _multiplyDecimalRound(x, y, UNIT);
    }

    /**
     * @return The result of safely dividing x and y. The return value is a high
     * precision decimal.
     *
     * @dev y is divided after the product of x and the standard precision unit
     * is evaluated, so the product of x and UNIT must be less than 2**256. As
     * this is an integer division, the result is always rounded down.
     * This helps save on gas. Rounding is more expensive on gas.
     */
    function divideDecimal(uint x, uint y) internal pure returns (uint) {
        /* Reintroduce the UNIT factor that will be divided out by y. */
        return x.mul(UNIT).div(y);
    }

    /**
     * @return The result of safely dividing x and y. The return value is as a rounded
     * decimal in the precision unit specified in the parameter.
     *
     * @dev y is divided after the product of x and the specified precision unit
     * is evaluated, so the product of x and the specified precision unit must
     * be less than 2**256. The result is rounded to the nearest increment.
     */
    function _divideDecimalRound(
        uint x,
        uint y,
        uint precisionUnit
    ) private pure returns (uint) {
        uint resultTimesTen = x.mul(precisionUnit * 10).div(y);

        if (resultTimesTen % 10 >= 5) {
            resultTimesTen += 10;
        }

        return resultTimesTen / 10;
    }

    /**
     * @return The result of safely dividing x and y. The return value is as a rounded
     * standard precision decimal.
     *
     * @dev y is divided after the product of x and the standard precision unit
     * is evaluated, so the product of x and the standard precision unit must
     * be less than 2**256. The result is rounded to the nearest increment.
     */
    function divideDecimalRound(uint x, uint y) internal pure returns (uint) {
        return _divideDecimalRound(x, y, UNIT);
    }

    /**
     * @return The result of safely dividing x and y. The return value is as a rounded
     * high precision decimal.
     *
     * @dev y is divided after the product of x and the high precision unit
     * is evaluated, so the product of x and the high precision unit must
     * be less than 2**256. The result is rounded to the nearest increment.
     */
    function divideDecimalRoundPrecise(uint x, uint y) internal pure returns (uint) {
        return _divideDecimalRound(x, y, PRECISE_UNIT);
    }

    /**
     * @dev Convert a standard decimal representation to a high precision one.
     */
    function decimalToPreciseDecimal(uint i) internal pure returns (uint) {
        return i.mul(UNIT_TO_HIGH_PRECISION_CONVERSION_FACTOR);
    }

    /**
     * @dev Convert a high precision decimal to a standard decimal representation.
     */
    function preciseDecimalToDecimal(uint i) internal pure returns (uint) {
        uint quotientTimesTen = i / (UNIT_TO_HIGH_PRECISION_CONVERSION_FACTOR / 10);

        if (quotientTimesTen % 10 >= 5) {
            quotientTimesTen += 10;
        }

        return quotientTimesTen / 10;
    }

    // Computes `a - b`, setting the value to 0 if b > a.
    function floorsub(uint a, uint b) internal pure returns (uint) {
        return b >= a ? 0 : a - b;
    }

    /* ---------- Utilities ---------- */
    /*
     * Absolute value of the input, returned as a signed number.
     */
    function signedAbs(int x) internal pure returns (int) {
        return x < 0 ? -x : x;
    }

    /*
     * Absolute value of the input, returned as an unsigned number.
     */
    function abs(int x) internal pure returns (uint) {
        return uint(signedAbs(x));
    }
}


// https://docs.synthetix.io/contracts/source/interfaces/ierc20
interface IERC20 {
    // ERC20 Optional Views
    function name() external view returns (string memory);

    function symbol() external view returns (string memory);

    function decimals() external view returns (uint8);

    // Views
    function totalSupply() external view returns (uint);

    function balanceOf(address owner) external view returns (uint);

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

    // Mutative functions
    function transfer(address to, uint value) external returns (bool);

    function approve(address spender, uint value) external returns (bool);

    function transferFrom(
        address from,
        address to,
        uint value
    ) external returns (bool);

    // Events
    event Transfer(address indexed from, address indexed to, uint value);

    event Approval(address indexed owner, address indexed spender, uint value);
}


// https://docs.synthetix.io/contracts/source/interfaces/ifeepool
interface IFeePool {
    // Views

    // solhint-disable-next-line func-name-mixedcase
    function FEE_ADDRESS() external view returns (address);

    function feesAvailable(address account) external view returns (uint, uint);

    function feePeriodDuration() external view returns (uint);

    function isFeesClaimable(address account) external view returns (bool);

    function targetThreshold() external view returns (uint);

    function totalFeesAvailable() external view returns (uint);

    function totalRewardsAvailable() external view returns (uint);

    // Mutative Functions
    function claimFees() external returns (bool);

    function claimOnBehalf(address claimingForAddress) external returns (bool);

    function closeCurrentFeePeriod() external;

    function closeSecondary(uint snxBackedDebt, uint debtShareSupply) external;

    function recordFeePaid(uint sUSDAmount) external;

    function setRewardsToDistribute(uint amount) external;
}


// Inheritance


// Libraries


// Internal references


// https://docs.synthetix.io/contracts/RewardEscrow
contract BaseRewardEscrowV2 is Owned, IRewardEscrowV2, LimitedSetup(8 weeks), MixinResolver {
    using SafeMath for uint;
    using SafeDecimalMath for uint;

    /* Mapping of nominated address to recieve account merging */
    mapping(address => address) public nominatedReceiver;

    /* Max escrow duration */
    uint public max_duration = 2 * 52 weeks; // Default max 2 years duration

    /* Max account merging duration */
    uint public maxAccountMergingDuration = 4 weeks; // Default 4 weeks is max

    /* ========== ACCOUNT MERGING CONFIGURATION ========== */

    uint public accountMergingDuration = 1 weeks;

    uint public accountMergingStartTime;

    /* ========== ADDRESS RESOLVER CONFIGURATION ========== */

    bytes32 private constant CONTRACT_SYNTHETIX = "Synthetix";
    bytes32 private constant CONTRACT_ISSUER = "Issuer";
    bytes32 private constant CONTRACT_FEEPOOL = "FeePool";
    bytes32 private constant CONTRACT_REWARDESCROWV2STORAGE = "RewardEscrowV2Storage";

    /* ========== CONSTRUCTOR ========== */

    constructor(address _owner, address _resolver) public Owned(_owner) MixinResolver(_resolver) {}

    /* ========== VIEWS ======================= */

    function feePool() internal view returns (IFeePool) {
        return IFeePool(requireAndGetAddress(CONTRACT_FEEPOOL));
    }

    function synthetixERC20() internal view returns (IERC20) {
        return IERC20(requireAndGetAddress(CONTRACT_SYNTHETIX));
    }

    function issuer() internal view returns (IIssuer) {
        return IIssuer(requireAndGetAddress(CONTRACT_ISSUER));
    }

    function state() internal view returns (IRewardEscrowV2Storage) {
        return IRewardEscrowV2Storage(requireAndGetAddress(CONTRACT_REWARDESCROWV2STORAGE));
    }

    function _notImplemented() internal pure {
        revert("Cannot be run on this layer");
    }

    /* ========== VIEW FUNCTIONS ========== */

    // Note: use public visibility so that it can be invoked in a subclass
    function resolverAddressesRequired() public view returns (bytes32[] memory addresses) {
        addresses = new bytes32[](4);
        addresses[0] = CONTRACT_SYNTHETIX;
        addresses[1] = CONTRACT_FEEPOOL;
        addresses[2] = CONTRACT_ISSUER;
        addresses[3] = CONTRACT_REWARDESCROWV2STORAGE;
    }

    /// views forwarded from storage contract

    function numVestingEntries(address account) public view returns (uint) {
        return state().numVestingEntries(account);
    }

    function totalEscrowedBalance() public view returns (uint) {
        return state().totalEscrowedBalance();
    }

    function totalEscrowedAccountBalance(address account) public view returns (uint) {
        return state().totalEscrowedAccountBalance(account);
    }

    function totalVestedAccountBalance(address account) external view returns (uint) {
        return state().totalVestedAccountBalance(account);
    }

    function nextEntryId() external view returns (uint) {
        return state().nextEntryId();
    }

    function vestingSchedules(address account, uint256 entryId) public view returns (VestingEntries.VestingEntry memory) {
        return state().vestingSchedules(account, entryId);
    }

    function accountVestingEntryIDs(address account, uint256 index) public view returns (uint) {
        return state().accountVestingEntryIDs(account, index);
    }

    /**
     * @notice A simple alias to totalEscrowedAccountBalance: provides ERC20 balance integration.
     */
    function balanceOf(address account) public view returns (uint) {
        return totalEscrowedAccountBalance(account);
    }

    /**
     * @notice Get a particular schedule entry for an account.
     * @return The vesting entry object and rate per second emission.
     */
    function getVestingEntry(address account, uint256 entryID) external view returns (uint64 endTime, uint256 escrowAmount) {
        VestingEntries.VestingEntry memory entry = vestingSchedules(account, entryID);
        return (entry.endTime, entry.escrowAmount);
    }

    function getVestingSchedules(
        address account,
        uint256 index,
        uint256 pageSize
    ) external view returns (VestingEntries.VestingEntryWithID[] memory) {
        uint256 endIndex = index + pageSize;

        // If index starts after the endIndex return no results
        if (endIndex <= index) {
            return new VestingEntries.VestingEntryWithID[](0);
        }

        // If the page extends past the end of the accountVestingEntryIDs, truncate it.
        if (endIndex > numVestingEntries(account)) {
            endIndex = numVestingEntries(account);
        }

        uint256 n = endIndex - index;
        uint256 entryID;
        VestingEntries.VestingEntry memory entry;
        VestingEntries.VestingEntryWithID[] memory vestingEntries = new VestingEntries.VestingEntryWithID[](n);
        for (uint256 i; i < n; i++) {
            entryID = accountVestingEntryIDs(account, i + index);

            entry = vestingSchedules(account, entryID);

            vestingEntries[i] = VestingEntries.VestingEntryWithID({
                endTime: uint64(entry.endTime),
                escrowAmount: entry.escrowAmount,
                entryID: entryID
            });
        }
        return vestingEntries;
    }

    function getAccountVestingEntryIDs(
        address account,
        uint256 index,
        uint256 pageSize
    ) external view returns (uint256[] memory) {
        uint256 endIndex = index + pageSize;

        // If the page extends past the end of the accountVestingEntryIDs, truncate it.
        uint numEntries = numVestingEntries(account);
        if (endIndex > numEntries) {
            endIndex = numEntries;
        }
        if (endIndex <= index) {
            return new uint256[](0);
        }

        uint256 n = endIndex - index;
        uint256[] memory page = new uint256[](n);
        for (uint256 i; i < n; i++) {
            page[i] = accountVestingEntryIDs(account, i + index);
        }
        return page;
    }

    function getVestingQuantity(address account, uint256[] calldata entryIDs) external view returns (uint total) {
        VestingEntries.VestingEntry memory entry;
        for (uint i = 0; i < entryIDs.length; i++) {
            entry = vestingSchedules(account, entryIDs[i]);

            /* Skip entry if escrowAmount == 0 */
            if (entry.escrowAmount != 0) {
                uint256 quantity = _claimableAmount(entry);

                /* add quantity to total */
                total = total.add(quantity);
            }
        }
    }

    function getVestingEntryClaimable(address account, uint256 entryID) external view returns (uint) {
        return _claimableAmount(vestingSchedules(account, entryID));
    }

    function _claimableAmount(VestingEntries.VestingEntry memory _entry) internal view returns (uint256) {
        uint256 quantity;
        if (_entry.escrowAmount != 0) {
            /* Escrow amounts claimable if block.timestamp equal to or after entry endTime */
            quantity = block.timestamp >= _entry.endTime ? _entry.escrowAmount : 0;
        }
        return quantity;
    }

    /* ========== MUTATIVE FUNCTIONS ========== */

    /**
     * Vest escrowed amounts that are claimable
     * Allows users to vest their vesting entries based on msg.sender
     */
    function vest(uint256[] calldata entryIDs) external {
        // only account can call vest
        address account = msg.sender;

        uint256 total;
        VestingEntries.VestingEntry memory entry;
        uint256 quantity;
        for (uint i = 0; i < entryIDs.length; i++) {
            entry = vestingSchedules(account, entryIDs[i]);

            /* Skip entry if escrowAmount == 0 already vested */
            if (entry.escrowAmount != 0) {
                quantity = _claimableAmount(entry);

                /* update entry to remove escrowAmount */
                if (quantity > 0) {
                    state().setZeroAmount(account, entryIDs[i]);
                }

                /* add quantity to total */
                total = total.add(quantity);
            }
        }

        /* Transfer vested tokens. Will revert if total > totalEscrowedAccountBalance */
        if (total != 0) {
            _subtractAndTransfer(account, account, total);
            // update total vested
            state().updateVestedAccountBalance(account, SafeCast.toInt256(total));
            emit Vested(account, block.timestamp, total);
        }
    }

    /// method for revoking vesting entries regardless of schedule to be used for liquidations
    /// access controlled to only Synthetix contract
    /// @param account: account
    /// @param recipient: account to transfer the revoked tokens to
    /// @param targetAmount: amount of SNX to revoke, when this amount is reached, no more entries are revoked
    /// @param startIndex: index into accountVestingEntryIDs[account] to start iterating from
    function revokeFrom(
        address account,
        address recipient,
        uint targetAmount,
        uint startIndex
    ) external onlySynthetix {
        require(account != address(0), "account not set");
        require(recipient != address(0), "recipient not set");

        // set stored entries to zero
        (uint total, uint endIndex, uint lastEntryTime) =
            state().setZeroAmountUntilTarget(account, startIndex, targetAmount);

        // check total is indeed enough
        // the caller should have checked for the general amount of escrow
        // but only here we check that startIndex results in sufficient amount
        require(total >= targetAmount, "entries sum less than target");

        // if too much was revoked
        if (total > targetAmount) {
            // only take the precise amount needed by adding a new entry with the difference from total
            uint refund = total.sub(targetAmount);
            uint entryID =
                state().addVestingEntry(
                    account,
                    VestingEntries.VestingEntry({endTime: uint64(lastEntryTime), escrowAmount: refund})
                );
            // emit event
            uint duration = lastEntryTime > block.timestamp ? lastEntryTime.sub(block.timestamp) : 0;
            emit VestingEntryCreated(account, block.timestamp, refund, duration, entryID);
        }

        // update the aggregates and move the tokens
        _subtractAndTransfer(account, recipient, targetAmount);

        emit Revoked(account, recipient, targetAmount, startIndex, endIndex);
    }

    /// remove tokens from vesting aggregates and transfer them to recipient
    function _subtractAndTransfer(
        address subtractFrom,
        address transferTo,
        uint256 amount
    ) internal {
        state().updateEscrowAccountBalance(subtractFrom, -SafeCast.toInt256(amount));
        synthetixERC20().transfer(transferTo, amount);
    }

    /**
     * @notice Create an escrow entry to lock SNX for a given duration in seconds
     * @dev This call expects that the depositor (msg.sender) has already approved the Reward escrow contract
     to spend the the amount being escrowed.
     */
    function createEscrowEntry(
        address beneficiary,
        uint256 deposit,
        uint256 duration
    ) external {
        require(beneficiary != address(0), "Cannot create escrow with address(0)");

        /* Transfer SNX from msg.sender */
        require(synthetixERC20().transferFrom(msg.sender, address(this), deposit), "token transfer failed");

        /* Append vesting entry for the beneficiary address */
        _appendVestingEntry(beneficiary, deposit, duration);
    }

    /**
     * @notice Add a new vesting entry at a given time and quantity to an account's schedule.
     * @dev A call to this should accompany a previous successful call to synthetix.transfer(rewardEscrow, amount),
     * to ensure that when the funds are withdrawn, there is enough balance.
     * @param account The account to append a new vesting entry to.
     * @param quantity The quantity of SNX that will be escrowed.
     * @param duration The duration that SNX will be emitted.
     */
    function appendVestingEntry(
        address account,
        uint256 quantity,
        uint256 duration
    ) external onlyFeePool {
        _appendVestingEntry(account, quantity, duration);
    }

    function _appendVestingEntry(
        address account,
        uint256 quantity,
        uint256 duration
    ) internal {
        /* No empty or already-passed vesting entries allowed. */
        require(quantity != 0, "Quantity cannot be zero");
        require(duration > 0 && duration <= max_duration, "Cannot escrow with 0 duration OR above max_duration");

        // Add quantity to account's escrowed balance to the total balance
        state().updateEscrowAccountBalance(account, SafeCast.toInt256(quantity));

        /* There must be enough balance in the contract to provide for the vesting entry. */
        require(
            totalEscrowedBalance() <= synthetixERC20().balanceOf(address(this)),
            "Must be enough balance in the contract to provide for the vesting entry"
        );

        /* Escrow the tokens for duration. */
        uint endTime = block.timestamp + duration;

        // store vesting entry
        uint entryID =
            state().addVestingEntry(
                account,
                VestingEntries.VestingEntry({endTime: uint64(endTime), escrowAmount: quantity})
            );

        emit VestingEntryCreated(account, block.timestamp, quantity, duration, entryID);
    }

    /* ========== ACCOUNT MERGING ========== */

    function accountMergingIsOpen() public view returns (bool) {
        return accountMergingStartTime.add(accountMergingDuration) > block.timestamp;
    }

    function startMergingWindow() external onlyOwner {
        accountMergingStartTime = block.timestamp;
        emit AccountMergingStarted(accountMergingStartTime, accountMergingStartTime.add(accountMergingDuration));
    }

    function setAccountMergingDuration(uint256 duration) external onlyOwner {
        require(duration <= maxAccountMergingDuration, "exceeds max merging duration");
        accountMergingDuration = duration;
        emit AccountMergingDurationUpdated(duration);
    }

    function setMaxAccountMergingWindow(uint256 duration) external onlyOwner {
        maxAccountMergingDuration = duration;
        emit MaxAccountMergingDurationUpdated(duration);
    }

    function setMaxEscrowDuration(uint256 duration) external onlyOwner {
        max_duration = duration;
        emit MaxEscrowDurationUpdated(duration);
    }

    /* Nominate an account to merge escrow and vesting schedule */
    function nominateAccountToMerge(address account) external {
        require(account != msg.sender, "Cannot nominate own account to merge");
        require(accountMergingIsOpen(), "Account merging has ended");
        require(issuer().debtBalanceOf(msg.sender, "sUSD") == 0, "Cannot merge accounts with debt");
        nominatedReceiver[msg.sender] = account;
        emit NominateAccountToMerge(msg.sender, account);
    }

    function mergeAccount(address from, uint256[] calldata entryIDs) external {
        require(accountMergingIsOpen(), "Account merging has ended");
        require(issuer().debtBalanceOf(from, "sUSD") == 0, "Cannot merge accounts with debt");
        require(nominatedReceiver[from] == msg.sender, "Address is not nominated to merge");
        address to = msg.sender;

        uint256 totalEscrowAmountMerged;
        VestingEntries.VestingEntry memory entry;
        for (uint i = 0; i < entryIDs.length; i++) {
            // retrieve entry
            entry = vestingSchedules(from, entryIDs[i]);

            /* ignore vesting entries with zero escrowAmount */
            if (entry.escrowAmount != 0) {
                // set previous entry amount to zero
                state().setZeroAmount(from, entryIDs[i]);

                // append new entry for recipient, the new entry will have new entryID
                state().addVestingEntry(to, entry);

                /* Add the escrowAmount of entry to the totalEscrowAmountMerged */
                totalEscrowAmountMerged = totalEscrowAmountMerged.add(entry.escrowAmount);
            }
        }

        // remove from old account
        state().updateEscrowAccountBalance(from, -SafeCast.toInt256(totalEscrowAmountMerged));
        // add to recipient account
        state().updateEscrowAccountBalance(to, SafeCast.toInt256(totalEscrowAmountMerged));

        emit AccountMerged(from, to, totalEscrowAmountMerged, entryIDs, block.timestamp);
    }

    /* ========== MIGRATION OLD ESCROW ========== */

    function migrateVestingSchedule(address) external {
        _notImplemented();
    }

    function migrateAccountEscrowBalances(
        address[] calldata,
        uint256[] calldata,
        uint256[] calldata
    ) external {
        _notImplemented();
    }

    /* ========== L2 MIGRATION ========== */

    function burnForMigration(address, uint[] calldata) external returns (uint256, VestingEntries.VestingEntry[] memory) {
        _notImplemented();
    }

    function importVestingEntries(
        address,
        uint256,
        VestingEntries.VestingEntry[] calldata
    ) external {
        _notImplemented();
    }

    /* ========== MODIFIERS ========== */
    modifier onlyFeePool() {
        require(msg.sender == address(feePool()), "Only the FeePool can perform this action");
        _;
    }

    modifier onlySynthetix() {
        require(msg.sender == address(synthetixERC20()), "Only Synthetix");
        _;
    }

    /* ========== EVENTS ========== */
    event Vested(address indexed beneficiary, uint time, uint value);
    event VestingEntryCreated(address indexed beneficiary, uint time, uint value, uint duration, uint entryID);
    event MaxEscrowDurationUpdated(uint newDuration);
    event MaxAccountMergingDurationUpdated(uint newDuration);
    event AccountMergingDurationUpdated(uint newDuration);
    event AccountMergingStarted(uint time, uint endTime);
    event AccountMerged(
        address indexed accountToMerge,
        address destinationAddress,
        uint escrowAmountMerged,
        uint[] entryIDs,
        uint time
    );
    event NominateAccountToMerge(address indexed account, address destination);
    event Revoked(address indexed account, address indexed recipient, uint targetAmount, uint startIndex, uint endIndex);
}


// Inheritance


// https://docs.synthetix.io/contracts/RewardEscrow
contract ImportableRewardEscrowV2 is BaseRewardEscrowV2 {
    /* ========== ADDRESS RESOLVER CONFIGURATION ========== */
    bytes32 private constant CONTRACT_SYNTHETIX_BRIDGE_BASE = "SynthetixBridgeToBase";

    /* ========== CONSTRUCTOR ========== */

    constructor(address _owner, address _resolver) public BaseRewardEscrowV2(_owner, _resolver) {}

    /* ========== VIEWS ======================= */

    function resolverAddressesRequired() public view returns (bytes32[] memory addresses) {
        bytes32[] memory existingAddresses = BaseRewardEscrowV2.resolverAddressesRequired();
        bytes32[] memory newAddresses = new bytes32[](1);
        newAddresses[0] = CONTRACT_SYNTHETIX_BRIDGE_BASE;
        return combineArrays(existingAddresses, newAddresses);
    }

    function synthetixBridgeToBase() internal view returns (address) {
        return requireAndGetAddress(CONTRACT_SYNTHETIX_BRIDGE_BASE);
    }

    /* ========== MUTATIVE FUNCTIONS ========== */

    function importVestingEntries(
        address account,
        uint256 escrowedAmount,
        VestingEntries.VestingEntry[] calldata vestingEntries
    ) external onlySynthetixBridge {
        // add escrowedAmount to account and total aggregates
        state().updateEscrowAccountBalance(account, SafeCast.toInt256(escrowedAmount));

        // There must be enough balance in the contract to provide for the escrowed balance.
        require(
            totalEscrowedBalance() <= synthetixERC20().balanceOf(address(this)),
            "Insufficient balance in the contract to provide for escrowed balance"
        );

        for (uint i = 0; i < vestingEntries.length; i++) {
            state().addVestingEntry(account, vestingEntries[i]);
        }
    }

    modifier onlySynthetixBridge() {
        require(msg.sender == synthetixBridgeToBase(), "Can only be invoked by SynthetixBridgeToBase contract");
        _;
    }
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"address","name":"_resolver","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"accountToMerge","type":"address"},{"indexed":false,"internalType":"address","name":"destinationAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"escrowAmountMerged","type":"uint256"},{"indexed":false,"internalType":"uint256[]","name":"entryIDs","type":"uint256[]"},{"indexed":false,"internalType":"uint256","name":"time","type":"uint256"}],"name":"AccountMerged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"newDuration","type":"uint256"}],"name":"AccountMergingDurationUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"time","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"endTime","type":"uint256"}],"name":"AccountMergingStarted","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"name","type":"bytes32"},{"indexed":false,"internalType":"address","name":"destination","type":"address"}],"name":"CacheUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"newDuration","type":"uint256"}],"name":"MaxAccountMergingDurationUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"newDuration","type":"uint256"}],"name":"MaxEscrowDurationUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"address","name":"destination","type":"address"}],"name":"NominateAccountToMerge","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldOwner","type":"address"},{"indexed":false,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnerChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnerNominated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"targetAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"startIndex","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"endIndex","type":"uint256"}],"name":"Revoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"beneficiary","type":"address"},{"indexed":false,"internalType":"uint256","name":"time","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Vested","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"beneficiary","type":"address"},{"indexed":false,"internalType":"uint256","name":"time","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"duration","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"entryID","type":"uint256"}],"name":"VestingEntryCreated","type":"event"},{"constant":false,"inputs":[],"name":"acceptOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"accountMergingDuration","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"accountMergingIsOpen","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"accountMergingStartTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"accountVestingEntryIDs","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"quantity","type":"uint256"},{"internalType":"uint256","name":"duration","type":"uint256"}],"name":"appendVestingEntry","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256[]","name":"","type":"uint256[]"}],"name":"burnForMigration","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"components":[{"internalType":"uint64","name":"endTime","type":"uint64"},{"internalType":"uint256","name":"escrowAmount","type":"uint256"}],"internalType":"struct VestingEntries.VestingEntry[]","name":"","type":"tuple[]"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"beneficiary","type":"address"},{"internalType":"uint256","name":"deposit","type":"uint256"},{"internalType":"uint256","name":"duration","type":"uint256"}],"name":"createEscrowEntry","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"index","type":"uint256"},{"internalType":"uint256","name":"pageSize","type":"uint256"}],"name":"getAccountVestingEntryIDs","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"entryID","type":"uint256"}],"name":"getVestingEntry","outputs":[{"internalType":"uint64","name":"endTime","type":"uint64"},{"internalType":"uint256","name":"escrowAmount","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"entryID","type":"uint256"}],"name":"getVestingEntryClaimable","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256[]","name":"entryIDs","type":"uint256[]"}],"name":"getVestingQuantity","outputs":[{"internalType":"uint256","name":"total","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"index","type":"uint256"},{"internalType":"uint256","name":"pageSize","type":"uint256"}],"name":"getVestingSchedules","outputs":[{"components":[{"internalType":"uint64","name":"endTime","type":"uint64"},{"internalType":"uint256","name":"escrowAmount","type":"uint256"},{"internalType":"uint256","name":"entryID","type":"uint256"}],"internalType":"struct VestingEntries.VestingEntryWithID[]","name":"","type":"tuple[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"escrowedAmount","type":"uint256"},{"components":[{"internalType":"uint64","name":"endTime","type":"uint64"},{"internalType":"uint256","name":"escrowAmount","type":"uint256"}],"internalType":"struct VestingEntries.VestingEntry[]","name":"vestingEntries","type":"tuple[]"}],"name":"importVestingEntries","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"isResolverCached","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"maxAccountMergingDuration","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"max_duration","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"uint256[]","name":"entryIDs","type":"uint256[]"}],"name":"mergeAccount","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address[]","name":"","type":"address[]"},{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"uint256[]","name":"","type":"uint256[]"}],"name":"migrateAccountEscrowBalances","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"migrateVestingSchedule","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"nextEntryId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"nominateAccountToMerge","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"name":"nominateNewOwner","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"nominatedOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"nominatedReceiver","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"numVestingEntries","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"rebuildCache","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"resolver","outputs":[{"internalType":"contract AddressResolver","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"resolverAddressesRequired","outputs":[{"internalType":"bytes32[]","name":"addresses","type":"bytes32[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"targetAmount","type":"uint256"},{"internalType":"uint256","name":"startIndex","type":"uint256"}],"name":"revokeFrom","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"duration","type":"uint256"}],"name":"setAccountMergingDuration","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"duration","type":"uint256"}],"name":"setMaxAccountMergingWindow","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"duration","type":"uint256"}],"name":"setMaxEscrowDuration","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"setupExpiryTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"startMergingWindow","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"totalEscrowedAccountBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"totalEscrowedBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"totalVestedAccountBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256[]","name":"entryIDs","type":"uint256[]"}],"name":"vest","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"entryId","type":"uint256"}],"name":"vestingSchedules","outputs":[{"components":[{"internalType":"uint64","name":"endTime","type":"uint64"},{"internalType":"uint256","name":"escrowAmount","type":"uint256"}],"internalType":"struct VestingEntries.VestingEntry","name":"","type":"tuple"}],"payable":false,"stateMutability":"view","type":"function"}]

60806040526303bfc4006006556224ea0060075562093a806008553480156200002757600080fd5b5060405162003933380380620039338339810160408190526200004a916200011d565b8181806249d400836001600160a01b038116620000845760405162461bcd60e51b81526004016200007b90620001d9565b60405180910390fd5b600080546001600160a01b0319166001600160a01b0383161781556040517fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c91620000d1918490620001b3565b60405180910390a1504201600255600380546001600160a01b0319166001600160a01b0392909216919091179055506200023492505050565b805162000117816200021a565b92915050565b600080604083850312156200013157600080fd5b60006200013f85856200010a565b925050602062000152858286016200010a565b9150509250929050565b620001678162000206565b82525050565b6200016781620001f4565b600062000187601983620001eb565b7f4f776e657220616464726573732063616e6e6f74206265203000000000000000815260200192915050565b60408101620001c382856200015c565b620001d260208301846200016d565b9392505050565b60208082528101620001178162000178565b90815260200190565b60006001600160a01b03821662000117565b6000620001178260006200011782620001f4565b6200022581620001f4565b81146200023157600080fd5b50565b6136ef80620002446000396000f3fe608060405234801561001057600080fd5b506004361061025e5760003560e01c806370a0823111610146578063899ffef4116100c3578063b95375bd11610087578063b95375bd146104ec578063cd7b43dd146104ff578063de065f6714610512578063e6b2cf6c14610525578063eac624891461052d578063f0b882ba1461054d5761025e565b8063899ffef4146104a15780638da5cb5b146104b6578063910a326d146104be578063a0416ed3146104c6578063ae582549146104d95761025e565b80637839b92f1161010a5780637839b92f1461043f5780637993e6991461045257806379ba5097146104655780637cc1d7561461046d57806380d46f58146104805761025e565b806370a08231146103e957806371e780f3146103fc57806373307e40146104045780637418536014610417578063773ab39f1461041f5761025e565b806330104c5f116101df57806345626bd6116101a357806345626bd61461037057806346ba2d901461039057806353a47bb7146103985780635eb8cf25146103ad5780636154c343146103b55780636dc05bd3146103d65761025e565b806330104c5f1461031c578063326a3cfb1461032f57806334c7fec91461034257806337088ffc146103555780634525aabc1461035d5761025e565b8063178c565511610226578063178c5655146102d35780631bb47b44146102db578063204b676a146102ee578063227d517a146103015780632af64bd3146103145761025e565b8063018c6c551461026357806304f3bcec1461027857806305662986146102965780630fcdefb7146102ab5780631627540c146102c0575b600080fd5b6102766102713660046127e3565b610560565b005b6102806105a8565b60405161028d9190613380565b60405180910390f35b61029e6105b7565b60405161028d9190613336565b6102b36105d8565b60405161028d9190613344565b6102766102ce3660046124e0565b6105de565b610276610631565b6102766102e936600461267b565b61068e565b6102b36102fc3660046124e0565b6106df565b6102b361030f3660046124e0565b61076a565b61029e61079f565b6102b361032a3660046125da565b6108b6565b6102b361033d3660046124e0565b6108d1565b610276610350366004612766565b610906565b6102b3610aba565b61027661036b3660046127e3565b610ac0565b61038361037e3660046125da565b610afd565b60405161028d919061350f565b6102b3610b89565b6103a0610b8f565b60405161028d91906131d7565b6102b3610b9e565b6103c86103c33660046125da565b610ba4565b60405161028d929190613597565b6102b36103e4366004612585565b610bcf565b6102b36103f73660046124e0565b610c34565b6102b3610c3f565b6103a06104123660046124e0565b610cbe565b610276610cd9565b61043261042d36600461267b565b610e2f565b60405161028d9190613314565b61027661044d3660046124e0565b610f5a565b6102766104603660046127e3565b610f65565b610276610fc4565b61027661047b3660046124e0565b611060565b61049361048e366004612585565b6111b0565b60405161028d92919061351d565b6104a96111c4565b60405161028d9190613303565b6103a0611238565b6102b3611247565b6102766104d436600461267b565b61124d565b6102b36104e73660046125da565b611318565b6102766104fa3660046126c8565b61139f565b61027661050d366004612614565b6113a7565b610276610520366004612524565b6115aa565b6102b3611876565b61054061053b36600461267b565b6118b8565b60405161028d9190613325565b61027661055b366004612585565b611969565b610568611cdf565b60078190556040517fe829efae5d8a2f7163f46c23a8190bf14625c1e446561ca0f5cf279ab7c8015e9061059d908390613344565b60405180910390a150565b6003546001600160a01b031681565b6000426105d1600854600954611d0b90919063ffffffff16565b1190505b90565b60095481565b6105e6611cdf565b600180546001600160a01b0319166001600160a01b0383161790556040517f906a1c6bd7e3091ea86693dd029a831c19049ce77f1dce2ce0bab1cacbabce229061059d9083906131d7565b610639611cdf565b4260098190556008547fceade2b9bc02350b17075c94bb699508b89ed2752f501ea42024b1bb5fd34445919061067690829063ffffffff611d0b16565b60405161068492919061353d565b60405180910390a1565b610696611d30565b6001600160a01b0316336001600160a01b0316146106cf5760405162461bcd60e51b81526004016106c6906134bf565b60405180910390fd5b6106da838383611d45565b505050565b60006106e9611fa1565b6001600160a01b031663204b676a836040518263ffffffff1660e01b815260040161071491906131d7565b60206040518083038186803b15801561072c57600080fd5b505afa158015610740573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506107649190810190612801565b92915050565b6000610774611fa1565b6001600160a01b031663227d517a836040518263ffffffff1660e01b815260040161071491906131d7565b600060606107ab6111c4565b905060005b81518110156108ad5760008282815181106107c757fe5b60209081029190910181015160008181526004928390526040908190205460035491516321f8a72160e01b81529294506001600160a01b03908116939116916321f8a7219161081891869101613344565b60206040518083038186803b15801561083057600080fd5b505afa158015610844573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506108689190810190612506565b6001600160a01b031614158061089357506000818152600460205260409020546001600160a01b0316155b156108a457600093505050506105d5565b506001016107b0565b50600191505090565b60006108ca6108c58484610afd565b611fc4565b9392505050565b60006108db611fa1565b6001600160a01b031663326a3cfb836040518263ffffffff1660e01b815260040161071491906131d7565b336000610911612389565b6000805b858110156109ed576109398588888481811061092d57fe5b90506020020135610afd565b925082602001516000146109e55761095083611fc4565b915081156109d257610960611fa1565b6001600160a01b031663534015598689898581811061097b57fe5b905060200201356040518363ffffffff1660e01b815260040161099f929190613242565b600060405180830381600087803b1580156109b957600080fd5b505af11580156109cd573d6000803e3d6000fd5b505050505b6109e2848363ffffffff611d0b16565b93505b600101610915565b508215610ab2576109ff848585611ff5565b610a07611fa1565b6001600160a01b0316633e21e59a85610a1f866120f4565b6040518363ffffffff1660e01b8152600401610a3c929190613242565b600060405180830381600087803b158015610a5657600080fd5b505af1158015610a6a573d6000803e3d6000fd5b50505050836001600160a01b03167ffbeff59d2bfda0d79ea8a29f8c57c66d48c7a13eabbdb90908d9115ec41c9dc64285604051610aa992919061353d565b60405180910390a25b505050505050565b60075481565b610ac8611cdf565b60068190556040517f6b92bd20c4b2e6861047ba7209ddc78d538419aae187d0df46716b827b8997a49061059d908390613344565b610b05612389565b610b0d611fa1565b6001600160a01b03166345626bd684846040518363ffffffff1660e01b8152600401610b3a929190613242565b604080518083038186803b158015610b5157600080fd5b505afa158015610b65573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506108ca91908101906127c5565b60025481565b6001546001600160a01b031681565b60065481565b600080610baf612389565b610bb98585610afd565b80516020909101519093509150505b9250929050565b6000610bd9612389565b60005b83811015610c2b57610bf48686868481811061092d57fe5b91508160200151600014610c23576000610c0d83611fc4565b9050610c1f848263ffffffff611d0b16565b9350505b600101610bdc565b50509392505050565b6000610764826108d1565b6000610c49611fa1565b6001600160a01b03166371e780f36040518163ffffffff1660e01b815260040160206040518083038186803b158015610c8157600080fd5b505afa158015610c95573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610cb99190810190612801565b905090565b6005602052600090815260409020546001600160a01b031681565b6060610ce36111c4565b905060005b8151811015610e2b576000828281518110610cff57fe5b602002602001015190506000600360009054906101000a90046001600160a01b03166001600160a01b031663dacb2d018384604051602001610d4191906131cc565b6040516020818303038152906040526040518363ffffffff1660e01b8152600401610d6d929190613360565b60206040518083038186803b158015610d8557600080fd5b505afa158015610d99573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610dbd9190810190612506565b6000838152600460205260409081902080546001600160a01b0319166001600160a01b038416179055519091507f88a93678a3692f6789d9546fc621bf7234b101ddb7d4fe479455112831b8aa6890610e199084908490613352565b60405180910390a15050600101610ce8565b5050565b6060828201838111610e75576040805160008082526020820190925290610e6c565b610e596123a0565b815260200190600190039081610e515790505b509150506108ca565b610e7e856106df565b811115610e9157610e8e856106df565b90505b8381036000610e9e612389565b606083604051908082528060200260200182016040528015610eda57816020015b610ec76123a0565b815260200190600190039081610ebf5790505b50905060005b84811015610f4d57610ef48a8a8301611318565b9350610f008a85610afd565b9250604051806060016040528084600001516001600160401b031681526020018460200151815260200185815250828281518110610f3a57fe5b6020908102919091010152600101610ee0565b5098975050505050505050565b610f6261211d565b50565b610f6d611cdf565b600754811115610f8f5760405162461bcd60e51b81526004016106c6906134af565b60088190556040517f723c43349da7aeae47190396f2e2fbe6bedb46b9e9705bc5b908d65bc7a1e0e69061059d908390613344565b6001546001600160a01b03163314610fee5760405162461bcd60e51b81526004016106c6906133af565b6000546001546040517fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c92611031926001600160a01b0391821692911690613227565b60405180910390a160018054600080546001600160a01b03199081166001600160a01b03841617909155169055565b6001600160a01b0381163314156110895760405162461bcd60e51b81526004016106c69061346f565b6110916105b7565b6110ad5760405162461bcd60e51b81526004016106c69061344f565b6110b5612135565b6001600160a01b031663d37c4d8b336040518263ffffffff1660e01b81526004016110e0919061320d565b60206040518083038186803b1580156110f857600080fd5b505afa15801561110c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506111309190810190612801565b1561114d5760405162461bcd60e51b81526004016106c6906134ff565b336000818152600560205260409081902080546001600160a01b0319166001600160a01b038516179055517fcf51776bb16e5780edcca2e64a9ba8a9c7d5d00a6699cbd7606e465361ba4852906111a59084906131d7565b60405180910390a250565b600060606111bc61211d565b935093915050565b6060806111cf612149565b60408051600180825281830190925291925060609190602080830190803883390190505090507453796e746865746978427269646765546f4261736560581b8160008151811061121b57fe5b602002602001018181525050611231828261220e565b9250505090565b6000546001600160a01b031681565b60085481565b6001600160a01b0383166112735760405162461bcd60e51b81526004016106c6906133df565b61127b6122ca565b6001600160a01b03166323b872dd3330856040518463ffffffff1660e01b81526004016112aa939291906131e5565b602060405180830381600087803b1580156112c457600080fd5b505af11580156112d8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506112fc91908101906127a7565b6106cf5760405162461bcd60e51b81526004016106c69061345f565b6000611322611fa1565b6001600160a01b031663ae58254984846040518363ffffffff1660e01b815260040161134f929190613242565b60206040518083038186803b15801561136757600080fd5b505afa15801561137b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506108ca9190810190612801565b610ab261211d565b6113af6122e1565b6001600160a01b0316336001600160a01b0316146113df5760405162461bcd60e51b81526004016106c6906133ef565b6113e7611fa1565b6001600160a01b031663cec7bdb1856113ff866120f4565b6040518363ffffffff1660e01b815260040161141c929190613242565b600060405180830381600087803b15801561143657600080fd5b505af115801561144a573d6000803e3d6000fd5b505050506114566122ca565b6001600160a01b03166370a08231306040518263ffffffff1660e01b815260040161148191906131d7565b60206040518083038186803b15801561149957600080fd5b505afa1580156114ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506114d19190810190612801565b6114d9610c3f565b11156114f75760405162461bcd60e51b81526004016106c6906134ef565b60005b818110156115a35761150a611fa1565b6001600160a01b03166343ba57df8685858581811061152557fe5b9050604002016040518363ffffffff1660e01b815260040161154892919061326b565b602060405180830381600087803b15801561156257600080fd5b505af1158015611576573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061159a9190810190612801565b506001016114fa565b5050505050565b6115b26122ca565b6001600160a01b0316336001600160a01b0316146115e25760405162461bcd60e51b81526004016106c69061340f565b6001600160a01b0384166116085760405162461bcd60e51b81526004016106c6906134cf565b6001600160a01b03831661162e5760405162461bcd60e51b81526004016106c69061349f565b600080600061163b611fa1565b6001600160a01b03166327f071d28886886040518463ffffffff1660e01b815260040161166a939291906132e8565b606060405180830381600087803b15801561168457600080fd5b505af1158015611698573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506116bc919081019061281f565b925092509250848310156116e25760405162461bcd60e51b81526004016106c69061339f565b848311156118135760006116fc848763ffffffff61230416565b90506000611708611fa1565b6001600160a01b03166343ba57df8a6040518060400160405280876001600160401b03168152602001868152506040518363ffffffff1660e01b8152600401611752929190613286565b602060405180830381600087803b15801561176c57600080fd5b505af1158015611780573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506117a49190810190612801565b905060004284116117b65760006117c6565b6117c6844263ffffffff61230416565b9050896001600160a01b03167f2cc016694185d38abbe28d9e9baea2e9d95a321ae43475e5ea7b643756840bc0428584866040516118079493929190613559565b60405180910390a25050505b61181e878787611ff5565b856001600160a01b0316876001600160a01b03167f18db3cc7a567ad50ae1cf6998aff0c3c2cff4e7c1338a1909def5a5a12ae23a18787866040516118659392919061354b565b60405180910390a350505050505050565b6000611880611fa1565b6001600160a01b031663e6b2cf6c6040518163ffffffff1660e01b815260040160206040518083038186803b158015610c8157600080fd5b606082820160006118c8866106df565b9050808211156118d6578091505b8482116118f557505060408051600081526020810190915290506108ca565b604080518684038082526020808202830101909252606090828015611924578160200160208202803883390190505b50905060005b8281101561195d5761193e89898301611318565b82828151811061194a57fe5b602090810291909101015260010161192a565b50979650505050505050565b6119716105b7565b61198d5760405162461bcd60e51b81526004016106c69061344f565b611995612135565b6001600160a01b031663d37c4d8b846040518263ffffffff1660e01b81526004016119c0919061325d565b60206040518083038186803b1580156119d857600080fd5b505afa1580156119ec573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250611a109190810190612801565b15611a2d5760405162461bcd60e51b81526004016106c6906134ff565b6001600160a01b03838116600090815260056020526040902054163314611a665760405162461bcd60e51b81526004016106c69061348f565b336000611a71612389565b60005b84811015611bbc57611a8c8787878481811061092d57fe5b91508160200151600014611bb457611aa2611fa1565b6001600160a01b0316635340155988888885818110611abd57fe5b905060200201356040518363ffffffff1660e01b8152600401611ae1929190613242565b600060405180830381600087803b158015611afb57600080fd5b505af1158015611b0f573d6000803e3d6000fd5b50505050611b1b611fa1565b6001600160a01b03166343ba57df85846040518363ffffffff1660e01b8152600401611b48929190613286565b602060405180830381600087803b158015611b6257600080fd5b505af1158015611b76573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250611b9a9190810190612801565b506020820151611bb190849063ffffffff611d0b16565b92505b600101611a74565b50611bc5611fa1565b6001600160a01b031663cec7bdb187611bdd856120f4565b6000036040518363ffffffff1660e01b8152600401611bfd929190613242565b600060405180830381600087803b158015611c1757600080fd5b505af1158015611c2b573d6000803e3d6000fd5b50505050611c37611fa1565b6001600160a01b031663cec7bdb184611c4f856120f4565b6040518363ffffffff1660e01b8152600401611c6c929190613242565b600060405180830381600087803b158015611c8657600080fd5b505af1158015611c9a573d6000803e3d6000fd5b50505050856001600160a01b03167f48d567deaa7db90f8a443344e519ca8906521ffe118e1df43e89a3c257963f7c8484888842604051610aa99594939291906132a1565b6000546001600160a01b03163314611d095760405162461bcd60e51b81526004016106c69061347f565b565b6000828201838110156108ca5760405162461bcd60e51b81526004016106c6906133bf565b6000610cb966119959541bdbdb60ca1b61232c565b81611d625760405162461bcd60e51b81526004016106c69061342f565b600081118015611d7457506006548111155b611d905760405162461bcd60e51b81526004016106c6906133cf565b611d98611fa1565b6001600160a01b031663cec7bdb184611db0856120f4565b6040518363ffffffff1660e01b8152600401611dcd929190613242565b600060405180830381600087803b158015611de757600080fd5b505af1158015611dfb573d6000803e3d6000fd5b50505050611e076122ca565b6001600160a01b03166370a08231306040518263ffffffff1660e01b8152600401611e3291906131d7565b60206040518083038186803b158015611e4a57600080fd5b505afa158015611e5e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250611e829190810190612801565b611e8a610c3f565b1115611ea85760405162461bcd60e51b81526004016106c69061343f565b4281016000611eb5611fa1565b6001600160a01b03166343ba57df866040518060400160405280866001600160401b03168152602001888152506040518363ffffffff1660e01b8152600401611eff929190613286565b602060405180830381600087803b158015611f1957600080fd5b505af1158015611f2d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250611f519190810190612801565b9050846001600160a01b03167f2cc016694185d38abbe28d9e9baea2e9d95a321ae43475e5ea7b643756840bc042868685604051611f929493929190613559565b60405180910390a25050505050565b6000610cb974526577617264457363726f77563253746f7261676560581b61232c565b60008082602001516000146107645782516001600160401b0316421015611fec5760006108ca565b50506020015190565b611ffd611fa1565b6001600160a01b031663cec7bdb184612015846120f4565b6000036040518363ffffffff1660e01b8152600401612035929190613242565b600060405180830381600087803b15801561204f57600080fd5b505af1158015612063573d6000803e3d6000fd5b5050505061206f6122ca565b6001600160a01b031663a9059cbb83836040518363ffffffff1660e01b815260040161209c929190613242565b602060405180830381600087803b1580156120b657600080fd5b505af11580156120ca573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506120ee91908101906127a7565b50505050565b6000600160ff1b82106121195760405162461bcd60e51b81526004016106c6906134df565b5090565b60405162461bcd60e51b81526004016106c69061341f565b6000610cb96524b9b9bab2b960d11b61232c565b60408051600480825260a0820190925260609160208201608080388339019050509050680a6f2dce8d0cae8d2f60bb1b8160008151811061218657fe5b60200260200101818152505066119959541bdbdb60ca1b816001815181106121aa57fe5b6020026020010181815250506524b9b9bab2b960d11b816002815181106121cd57fe5b60200260200101818152505074526577617264457363726f77563253746f7261676560581b816003815181106121ff57fe5b60200260200101818152505090565b6060815183510160405190808252806020026020018201604052801561223e578160200160208202803883390190505b50905060005b83518110156122805783818151811061225957fe5b602002602001015182828151811061226d57fe5b6020908102919091010152600101612244565b5060005b82518110156122c35782818151811061229957fe5b60200260200101518282865101815181106122b057fe5b6020908102919091010152600101612284565b5092915050565b6000610cb9680a6f2dce8d0cae8d2f60bb1b61232c565b6000610cb97453796e746865746978427269646765546f4261736560581b61232c565b6000828211156123265760405162461bcd60e51b81526004016106c6906133ff565b50900390565b60008181526004602090815260408083205490516001600160a01b03909116918215159161235c918691016131ac565b604051602081830303815290604052906122c35760405162461bcd60e51b81526004016106c6919061338e565b604080518082019091526000808252602082015290565b604051806060016040528060006001600160401b0316815260200160008152602001600081525090565b80356107648161367d565b80516107648161367d565b60008083601f8401126123f257600080fd5b5081356001600160401b0381111561240957600080fd5b602083019150836020820283011115610bc857600080fd5b60008083601f84011261243357600080fd5b5081356001600160401b0381111561244a57600080fd5b602083019150836040820283011115610bc857600080fd5b805161076481613691565b60006040828403121561247f57600080fd5b61248960406135a5565b9050600061249784846124d5565b82525060206124a8848483016124bf565b60208301525092915050565b80356107648161369a565b80516107648161369a565b8035610764816136a3565b8051610764816136a3565b6000602082840312156124f257600080fd5b60006124fe84846123ca565b949350505050565b60006020828403121561251857600080fd5b60006124fe84846123d5565b6000806000806080858703121561253a57600080fd5b600061254687876123ca565b9450506020612557878288016123ca565b9350506040612568878288016124b4565b9250506060612579878288016124b4565b91505092959194509250565b60008060006040848603121561259a57600080fd5b60006125a686866123ca565b93505060208401356001600160401b038111156125c257600080fd5b6125ce868287016123e0565b92509250509250925092565b600080604083850312156125ed57600080fd5b60006125f985856123ca565b925050602061260a858286016124b4565b9150509250929050565b6000806000806060858703121561262a57600080fd5b600061263687876123ca565b9450506020612647878288016124b4565b93505060408501356001600160401b0381111561266357600080fd5b61266f87828801612421565b95989497509550505050565b60008060006060848603121561269057600080fd5b600061269c86866123ca565b93505060206126ad868287016124b4565b92505060406126be868287016124b4565b9150509250925092565b600080600080600080606087890312156126e157600080fd5b86356001600160401b038111156126f757600080fd5b61270389828a016123e0565b965096505060208701356001600160401b0381111561272157600080fd5b61272d89828a016123e0565b945094505060408701356001600160401b0381111561274b57600080fd5b61275789828a016123e0565b92509250509295509295509295565b6000806020838503121561277957600080fd5b82356001600160401b0381111561278f57600080fd5b61279b858286016123e0565b92509250509250929050565b6000602082840312156127b957600080fd5b60006124fe8484612462565b6000604082840312156127d757600080fd5b60006124fe848461246d565b6000602082840312156127f557600080fd5b60006124fe84846124b4565b60006020828403121561281357600080fd5b60006124fe84846124bf565b60008060006060848603121561283457600080fd5b600061284086866124bf565b9350506020612851868287016124bf565b92505060406126be868287016124bf565b600061286e8383612a3b565b505060200190565b60006128828383613115565b505060600190565b6000612896838361317f565b505060400190565b6128a781613629565b82525050565b6128a781613601565b60006128c1826135d1565b6128cb81856135d5565b93506128d6836135cb565b8060005b838110156129045781516128ee8882612862565b97506128f9836135cb565b9250506001016128da565b509495945050505050565b600061291a826135d1565b61292481856135d5565b935061292f836135cb565b8060005b838110156129045781516129478882612876565b9750612952836135cb565b925050600101612933565b6000612968826135d1565b61297281856135d5565b935061297d836135cb565b8060005b83811015612904578151612995888261288a565b97506129a0836135cb565b925050600101612981565b60006129b783856135d5565b93506001600160fb1b038311156129cd57600080fd5b6020830292506129de83858461363b565b50500190565b60006129ef826135d1565b6129f981856135d5565b9350612a04836135cb565b8060005b83811015612904578151612a1c8882612862565b9750612a27836135cb565b925050600101612a08565b6128a78161360c565b6128a7816105d5565b6128a7612a50826105d5565b6105d5565b6128a781613630565b6000612a69826135d1565b612a7381856135d5565b9350612a83818560208601613647565b612a8c81613673565b9093019392505050565b6000612aa3601c836135d5565b7f656e74726965732073756d206c657373207468616e2074617267657400000000815260200192915050565b6000612adc6035836135d5565b7f596f75206d757374206265206e6f6d696e61746564206265666f726520796f7581527402063616e20616363657074206f776e65727368697605c1b602082015260400192915050565b6000612b33601b836135d5565b7f536166654d6174683a206164646974696f6e206f766572666c6f770000000000815260200192915050565b6000612b6c6033836135d5565b7f43616e6e6f7420657363726f7720776974682030206475726174696f6e204f528152721030b137bb329036b0bc2fb23ab930ba34b7b760691b602082015260400192915050565b6000612bc16024836135d5565b7f43616e6e6f742063726561746520657363726f772077697468206164647265738152637328302960e01b602082015260400192915050565b6000612c076035836135d5565b7f43616e206f6e6c7920626520696e766f6b65642062792053796e746865746978815274109c9a5919d9551bd0985cd94818dbdb9d1c9858dd605a1b602082015260400192915050565b6000612c5e601e836135d5565b7f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815260200192915050565b6000612c97600e836135d5565b6d09edcd8f240a6f2dce8d0cae8d2f60931b815260200192915050565b6000612cc1601b836135d5565b7f43616e6e6f742062652072756e206f6e2074686973206c617965720000000000815260200192915050565b6000612cfa6011836135de565b70026b4b9b9b4b7339030b2323932b9b99d1607d1b815260110192915050565b6000612d276017836135d5565b7f5175616e746974792063616e6e6f74206265207a65726f000000000000000000815260200192915050565b6000612d606047836135d5565b7f4d75737420626520656e6f7567682062616c616e636520696e2074686520636f81527f6e747261637420746f2070726f7669646520666f72207468652076657374696e6020820152666720656e74727960c81b604082015260600192915050565b6000612dcf6019836135d5565b7f4163636f756e74206d657267696e672068617320656e64656400000000000000815260200192915050565b6000612e086015836135d5565b741d1bdad95b881d1c985b9cd9995c8819985a5b1959605a1b815260200192915050565b6000612e396024836135d5565b7f43616e6e6f74206e6f6d696e617465206f776e206163636f756e7420746f206d8152636572676560e01b602082015260400192915050565b6000612e7f602f836135d5565b7f4f6e6c792074686520636f6e7472616374206f776e6572206d6179207065726681526e37b936903a3434b99030b1ba34b7b760891b602082015260400192915050565b631cd554d160e21b9052565b6000612edc6021836135d5565b7f41646472657373206973206e6f74206e6f6d696e6174656420746f206d6572678152606560f81b602082015260400192915050565b6000612f1f6011836135d5565b701c9958da5c1a595b9d081b9bdd081cd95d607a1b815260200192915050565b6000612f4c601c836135d5565b7f65786365656473206d6178206d657267696e67206475726174696f6e00000000815260200192915050565b6000612f856019836135de565b7f5265736f6c766572206d697373696e67207461726765743a2000000000000000815260190192915050565b6000612fbe6028836135d5565b7f4f6e6c792074686520466565506f6f6c2063616e20706572666f726d20746869815267399030b1ba34b7b760c11b602082015260400192915050565b6000613008600f836135d5565b6e1858d8dbdd5b9d081b9bdd081cd95d608a1b815260200192915050565b60006130336028836135d5565b7f53616665436173743a2076616c756520646f65736e27742066697420696e2061815267371034b73a191a9b60c11b602082015260400192915050565b600061307d6044836135d5565b7f496e73756666696369656e742062616c616e636520696e2074686520636f6e7481527f7261637420746f2070726f7669646520666f7220657363726f7765642062616c602082015263616e636560e01b604082015260600192915050565b60006130e9601f836135d5565b7f43616e6e6f74206d65726765206163636f756e74732077697468206465627400815260200192915050565b8051606083019061312684826131a3565b5060208201516131396020850182612a3b565b5060408201516120ee6040850182612a3b565b6040820161315a82806135f2565b61316484826131a3565b5061317260208301836135e3565b6120ee6020850182612a3b565b8051604083019061319084826131a3565b5060208201516120ee6020850182612a3b565b6128a78161361d565b60006131b782612ced565b91506131c38284612a44565b50602001919050565b60006131b782612f78565b6020810161076482846128ad565b606081016131f3828661289e565b61320060208301856128ad565b6124fe6040830184612a3b565b6040810161321b828461289e565b61076460208301612ec3565b6040810161323582856128ad565b6108ca60208301846128ad565b6040810161325082856128ad565b6108ca6020830184612a3b565b6040810161321b82846128ad565b6060810161327982856128ad565b6108ca602083018461314c565b6060810161329482856128ad565b6108ca602083018461317f565b608081016132af82886128ad565b6132bc6020830187612a3b565b81810360408301526132cf8185876129ab565b90506132de6060830184612a3b565b9695505050505050565b606081016132f682866128ad565b6132006020830185612a3b565b602080825281016108ca81846128b6565b602080825281016108ca818461290f565b602080825281016108ca81846129e4565b602081016107648284612a32565b602081016107648284612a3b565b604081016132358285612a3b565b6040810161336e8285612a3b565b81810360208301526124fe8184612a5e565b602081016107648284612a55565b602080825281016108ca8184612a5e565b6020808252810161076481612a96565b6020808252810161076481612acf565b6020808252810161076481612b26565b6020808252810161076481612b5f565b6020808252810161076481612bb4565b6020808252810161076481612bfa565b6020808252810161076481612c51565b6020808252810161076481612c8a565b6020808252810161076481612cb4565b6020808252810161076481612d1a565b6020808252810161076481612d53565b6020808252810161076481612dc2565b6020808252810161076481612dfb565b6020808252810161076481612e2c565b6020808252810161076481612e72565b6020808252810161076481612ecf565b6020808252810161076481612f12565b6020808252810161076481612f3f565b6020808252810161076481612fb1565b6020808252810161076481612ffb565b6020808252810161076481613026565b6020808252810161076481613070565b60208082528101610764816130dc565b60408101610764828461317f565b6040810161352b8285612a3b565b81810360208301526124fe818461295d565b604081016132508285612a3b565b606081016132f68286612a3b565b608081016135678287612a3b565b6135746020830186612a3b565b6135816040830185612a3b565b61358e6060830184612a3b565b95945050505050565b6040810161325082856131a3565b6040518181016001600160401b03811182821017156135c357600080fd5b604052919050565b60200190565b5190565b90815260200190565b919050565b60006108ca60208401846124b4565b60006108ca60208401846124ca565b600061076482613611565b151590565b6001600160a01b031690565b6001600160401b031690565b6000610764825b600061076482613601565b82818337506000910152565b60005b8381101561366257818101518382015260200161364a565b838111156120ee5750506000910152565b601f01601f191690565b61368681613601565b8114610f6257600080fd5b6136868161360c565b613686816105d5565b6136868161361d56fea365627a7a72315820548d7e03dbddde9de723946b9470f701d7854b6b5ffe06adcb05794ac93ee26d6c6578706572696d656e74616cf564736f6c63430005100040000000000000000000000000302d2451d9f47620374b54c521423bf0403916a20000000000000000000000001cb059b7e74fd21665968c908806143e744d5f30

Deployed Bytecode

0x608060405234801561001057600080fd5b506004361061025e5760003560e01c806370a0823111610146578063899ffef4116100c3578063b95375bd11610087578063b95375bd146104ec578063cd7b43dd146104ff578063de065f6714610512578063e6b2cf6c14610525578063eac624891461052d578063f0b882ba1461054d5761025e565b8063899ffef4146104a15780638da5cb5b146104b6578063910a326d146104be578063a0416ed3146104c6578063ae582549146104d95761025e565b80637839b92f1161010a5780637839b92f1461043f5780637993e6991461045257806379ba5097146104655780637cc1d7561461046d57806380d46f58146104805761025e565b806370a08231146103e957806371e780f3146103fc57806373307e40146104045780637418536014610417578063773ab39f1461041f5761025e565b806330104c5f116101df57806345626bd6116101a357806345626bd61461037057806346ba2d901461039057806353a47bb7146103985780635eb8cf25146103ad5780636154c343146103b55780636dc05bd3146103d65761025e565b806330104c5f1461031c578063326a3cfb1461032f57806334c7fec91461034257806337088ffc146103555780634525aabc1461035d5761025e565b8063178c565511610226578063178c5655146102d35780631bb47b44146102db578063204b676a146102ee578063227d517a146103015780632af64bd3146103145761025e565b8063018c6c551461026357806304f3bcec1461027857806305662986146102965780630fcdefb7146102ab5780631627540c146102c0575b600080fd5b6102766102713660046127e3565b610560565b005b6102806105a8565b60405161028d9190613380565b60405180910390f35b61029e6105b7565b60405161028d9190613336565b6102b36105d8565b60405161028d9190613344565b6102766102ce3660046124e0565b6105de565b610276610631565b6102766102e936600461267b565b61068e565b6102b36102fc3660046124e0565b6106df565b6102b361030f3660046124e0565b61076a565b61029e61079f565b6102b361032a3660046125da565b6108b6565b6102b361033d3660046124e0565b6108d1565b610276610350366004612766565b610906565b6102b3610aba565b61027661036b3660046127e3565b610ac0565b61038361037e3660046125da565b610afd565b60405161028d919061350f565b6102b3610b89565b6103a0610b8f565b60405161028d91906131d7565b6102b3610b9e565b6103c86103c33660046125da565b610ba4565b60405161028d929190613597565b6102b36103e4366004612585565b610bcf565b6102b36103f73660046124e0565b610c34565b6102b3610c3f565b6103a06104123660046124e0565b610cbe565b610276610cd9565b61043261042d36600461267b565b610e2f565b60405161028d9190613314565b61027661044d3660046124e0565b610f5a565b6102766104603660046127e3565b610f65565b610276610fc4565b61027661047b3660046124e0565b611060565b61049361048e366004612585565b6111b0565b60405161028d92919061351d565b6104a96111c4565b60405161028d9190613303565b6103a0611238565b6102b3611247565b6102766104d436600461267b565b61124d565b6102b36104e73660046125da565b611318565b6102766104fa3660046126c8565b61139f565b61027661050d366004612614565b6113a7565b610276610520366004612524565b6115aa565b6102b3611876565b61054061053b36600461267b565b6118b8565b60405161028d9190613325565b61027661055b366004612585565b611969565b610568611cdf565b60078190556040517fe829efae5d8a2f7163f46c23a8190bf14625c1e446561ca0f5cf279ab7c8015e9061059d908390613344565b60405180910390a150565b6003546001600160a01b031681565b6000426105d1600854600954611d0b90919063ffffffff16565b1190505b90565b60095481565b6105e6611cdf565b600180546001600160a01b0319166001600160a01b0383161790556040517f906a1c6bd7e3091ea86693dd029a831c19049ce77f1dce2ce0bab1cacbabce229061059d9083906131d7565b610639611cdf565b4260098190556008547fceade2b9bc02350b17075c94bb699508b89ed2752f501ea42024b1bb5fd34445919061067690829063ffffffff611d0b16565b60405161068492919061353d565b60405180910390a1565b610696611d30565b6001600160a01b0316336001600160a01b0316146106cf5760405162461bcd60e51b81526004016106c6906134bf565b60405180910390fd5b6106da838383611d45565b505050565b60006106e9611fa1565b6001600160a01b031663204b676a836040518263ffffffff1660e01b815260040161071491906131d7565b60206040518083038186803b15801561072c57600080fd5b505afa158015610740573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506107649190810190612801565b92915050565b6000610774611fa1565b6001600160a01b031663227d517a836040518263ffffffff1660e01b815260040161071491906131d7565b600060606107ab6111c4565b905060005b81518110156108ad5760008282815181106107c757fe5b60209081029190910181015160008181526004928390526040908190205460035491516321f8a72160e01b81529294506001600160a01b03908116939116916321f8a7219161081891869101613344565b60206040518083038186803b15801561083057600080fd5b505afa158015610844573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506108689190810190612506565b6001600160a01b031614158061089357506000818152600460205260409020546001600160a01b0316155b156108a457600093505050506105d5565b506001016107b0565b50600191505090565b60006108ca6108c58484610afd565b611fc4565b9392505050565b60006108db611fa1565b6001600160a01b031663326a3cfb836040518263ffffffff1660e01b815260040161071491906131d7565b336000610911612389565b6000805b858110156109ed576109398588888481811061092d57fe5b90506020020135610afd565b925082602001516000146109e55761095083611fc4565b915081156109d257610960611fa1565b6001600160a01b031663534015598689898581811061097b57fe5b905060200201356040518363ffffffff1660e01b815260040161099f929190613242565b600060405180830381600087803b1580156109b957600080fd5b505af11580156109cd573d6000803e3d6000fd5b505050505b6109e2848363ffffffff611d0b16565b93505b600101610915565b508215610ab2576109ff848585611ff5565b610a07611fa1565b6001600160a01b0316633e21e59a85610a1f866120f4565b6040518363ffffffff1660e01b8152600401610a3c929190613242565b600060405180830381600087803b158015610a5657600080fd5b505af1158015610a6a573d6000803e3d6000fd5b50505050836001600160a01b03167ffbeff59d2bfda0d79ea8a29f8c57c66d48c7a13eabbdb90908d9115ec41c9dc64285604051610aa992919061353d565b60405180910390a25b505050505050565b60075481565b610ac8611cdf565b60068190556040517f6b92bd20c4b2e6861047ba7209ddc78d538419aae187d0df46716b827b8997a49061059d908390613344565b610b05612389565b610b0d611fa1565b6001600160a01b03166345626bd684846040518363ffffffff1660e01b8152600401610b3a929190613242565b604080518083038186803b158015610b5157600080fd5b505afa158015610b65573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506108ca91908101906127c5565b60025481565b6001546001600160a01b031681565b60065481565b600080610baf612389565b610bb98585610afd565b80516020909101519093509150505b9250929050565b6000610bd9612389565b60005b83811015610c2b57610bf48686868481811061092d57fe5b91508160200151600014610c23576000610c0d83611fc4565b9050610c1f848263ffffffff611d0b16565b9350505b600101610bdc565b50509392505050565b6000610764826108d1565b6000610c49611fa1565b6001600160a01b03166371e780f36040518163ffffffff1660e01b815260040160206040518083038186803b158015610c8157600080fd5b505afa158015610c95573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610cb99190810190612801565b905090565b6005602052600090815260409020546001600160a01b031681565b6060610ce36111c4565b905060005b8151811015610e2b576000828281518110610cff57fe5b602002602001015190506000600360009054906101000a90046001600160a01b03166001600160a01b031663dacb2d018384604051602001610d4191906131cc565b6040516020818303038152906040526040518363ffffffff1660e01b8152600401610d6d929190613360565b60206040518083038186803b158015610d8557600080fd5b505afa158015610d99573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610dbd9190810190612506565b6000838152600460205260409081902080546001600160a01b0319166001600160a01b038416179055519091507f88a93678a3692f6789d9546fc621bf7234b101ddb7d4fe479455112831b8aa6890610e199084908490613352565b60405180910390a15050600101610ce8565b5050565b6060828201838111610e75576040805160008082526020820190925290610e6c565b610e596123a0565b815260200190600190039081610e515790505b509150506108ca565b610e7e856106df565b811115610e9157610e8e856106df565b90505b8381036000610e9e612389565b606083604051908082528060200260200182016040528015610eda57816020015b610ec76123a0565b815260200190600190039081610ebf5790505b50905060005b84811015610f4d57610ef48a8a8301611318565b9350610f008a85610afd565b9250604051806060016040528084600001516001600160401b031681526020018460200151815260200185815250828281518110610f3a57fe5b6020908102919091010152600101610ee0565b5098975050505050505050565b610f6261211d565b50565b610f6d611cdf565b600754811115610f8f5760405162461bcd60e51b81526004016106c6906134af565b60088190556040517f723c43349da7aeae47190396f2e2fbe6bedb46b9e9705bc5b908d65bc7a1e0e69061059d908390613344565b6001546001600160a01b03163314610fee5760405162461bcd60e51b81526004016106c6906133af565b6000546001546040517fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c92611031926001600160a01b0391821692911690613227565b60405180910390a160018054600080546001600160a01b03199081166001600160a01b03841617909155169055565b6001600160a01b0381163314156110895760405162461bcd60e51b81526004016106c69061346f565b6110916105b7565b6110ad5760405162461bcd60e51b81526004016106c69061344f565b6110b5612135565b6001600160a01b031663d37c4d8b336040518263ffffffff1660e01b81526004016110e0919061320d565b60206040518083038186803b1580156110f857600080fd5b505afa15801561110c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506111309190810190612801565b1561114d5760405162461bcd60e51b81526004016106c6906134ff565b336000818152600560205260409081902080546001600160a01b0319166001600160a01b038516179055517fcf51776bb16e5780edcca2e64a9ba8a9c7d5d00a6699cbd7606e465361ba4852906111a59084906131d7565b60405180910390a250565b600060606111bc61211d565b935093915050565b6060806111cf612149565b60408051600180825281830190925291925060609190602080830190803883390190505090507453796e746865746978427269646765546f4261736560581b8160008151811061121b57fe5b602002602001018181525050611231828261220e565b9250505090565b6000546001600160a01b031681565b60085481565b6001600160a01b0383166112735760405162461bcd60e51b81526004016106c6906133df565b61127b6122ca565b6001600160a01b03166323b872dd3330856040518463ffffffff1660e01b81526004016112aa939291906131e5565b602060405180830381600087803b1580156112c457600080fd5b505af11580156112d8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506112fc91908101906127a7565b6106cf5760405162461bcd60e51b81526004016106c69061345f565b6000611322611fa1565b6001600160a01b031663ae58254984846040518363ffffffff1660e01b815260040161134f929190613242565b60206040518083038186803b15801561136757600080fd5b505afa15801561137b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506108ca9190810190612801565b610ab261211d565b6113af6122e1565b6001600160a01b0316336001600160a01b0316146113df5760405162461bcd60e51b81526004016106c6906133ef565b6113e7611fa1565b6001600160a01b031663cec7bdb1856113ff866120f4565b6040518363ffffffff1660e01b815260040161141c929190613242565b600060405180830381600087803b15801561143657600080fd5b505af115801561144a573d6000803e3d6000fd5b505050506114566122ca565b6001600160a01b03166370a08231306040518263ffffffff1660e01b815260040161148191906131d7565b60206040518083038186803b15801561149957600080fd5b505afa1580156114ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506114d19190810190612801565b6114d9610c3f565b11156114f75760405162461bcd60e51b81526004016106c6906134ef565b60005b818110156115a35761150a611fa1565b6001600160a01b03166343ba57df8685858581811061152557fe5b9050604002016040518363ffffffff1660e01b815260040161154892919061326b565b602060405180830381600087803b15801561156257600080fd5b505af1158015611576573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061159a9190810190612801565b506001016114fa565b5050505050565b6115b26122ca565b6001600160a01b0316336001600160a01b0316146115e25760405162461bcd60e51b81526004016106c69061340f565b6001600160a01b0384166116085760405162461bcd60e51b81526004016106c6906134cf565b6001600160a01b03831661162e5760405162461bcd60e51b81526004016106c69061349f565b600080600061163b611fa1565b6001600160a01b03166327f071d28886886040518463ffffffff1660e01b815260040161166a939291906132e8565b606060405180830381600087803b15801561168457600080fd5b505af1158015611698573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506116bc919081019061281f565b925092509250848310156116e25760405162461bcd60e51b81526004016106c69061339f565b848311156118135760006116fc848763ffffffff61230416565b90506000611708611fa1565b6001600160a01b03166343ba57df8a6040518060400160405280876001600160401b03168152602001868152506040518363ffffffff1660e01b8152600401611752929190613286565b602060405180830381600087803b15801561176c57600080fd5b505af1158015611780573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506117a49190810190612801565b905060004284116117b65760006117c6565b6117c6844263ffffffff61230416565b9050896001600160a01b03167f2cc016694185d38abbe28d9e9baea2e9d95a321ae43475e5ea7b643756840bc0428584866040516118079493929190613559565b60405180910390a25050505b61181e878787611ff5565b856001600160a01b0316876001600160a01b03167f18db3cc7a567ad50ae1cf6998aff0c3c2cff4e7c1338a1909def5a5a12ae23a18787866040516118659392919061354b565b60405180910390a350505050505050565b6000611880611fa1565b6001600160a01b031663e6b2cf6c6040518163ffffffff1660e01b815260040160206040518083038186803b158015610c8157600080fd5b606082820160006118c8866106df565b9050808211156118d6578091505b8482116118f557505060408051600081526020810190915290506108ca565b604080518684038082526020808202830101909252606090828015611924578160200160208202803883390190505b50905060005b8281101561195d5761193e89898301611318565b82828151811061194a57fe5b602090810291909101015260010161192a565b50979650505050505050565b6119716105b7565b61198d5760405162461bcd60e51b81526004016106c69061344f565b611995612135565b6001600160a01b031663d37c4d8b846040518263ffffffff1660e01b81526004016119c0919061325d565b60206040518083038186803b1580156119d857600080fd5b505afa1580156119ec573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250611a109190810190612801565b15611a2d5760405162461bcd60e51b81526004016106c6906134ff565b6001600160a01b03838116600090815260056020526040902054163314611a665760405162461bcd60e51b81526004016106c69061348f565b336000611a71612389565b60005b84811015611bbc57611a8c8787878481811061092d57fe5b91508160200151600014611bb457611aa2611fa1565b6001600160a01b0316635340155988888885818110611abd57fe5b905060200201356040518363ffffffff1660e01b8152600401611ae1929190613242565b600060405180830381600087803b158015611afb57600080fd5b505af1158015611b0f573d6000803e3d6000fd5b50505050611b1b611fa1565b6001600160a01b03166343ba57df85846040518363ffffffff1660e01b8152600401611b48929190613286565b602060405180830381600087803b158015611b6257600080fd5b505af1158015611b76573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250611b9a9190810190612801565b506020820151611bb190849063ffffffff611d0b16565b92505b600101611a74565b50611bc5611fa1565b6001600160a01b031663cec7bdb187611bdd856120f4565b6000036040518363ffffffff1660e01b8152600401611bfd929190613242565b600060405180830381600087803b158015611c1757600080fd5b505af1158015611c2b573d6000803e3d6000fd5b50505050611c37611fa1565b6001600160a01b031663cec7bdb184611c4f856120f4565b6040518363ffffffff1660e01b8152600401611c6c929190613242565b600060405180830381600087803b158015611c8657600080fd5b505af1158015611c9a573d6000803e3d6000fd5b50505050856001600160a01b03167f48d567deaa7db90f8a443344e519ca8906521ffe118e1df43e89a3c257963f7c8484888842604051610aa99594939291906132a1565b6000546001600160a01b03163314611d095760405162461bcd60e51b81526004016106c69061347f565b565b6000828201838110156108ca5760405162461bcd60e51b81526004016106c6906133bf565b6000610cb966119959541bdbdb60ca1b61232c565b81611d625760405162461bcd60e51b81526004016106c69061342f565b600081118015611d7457506006548111155b611d905760405162461bcd60e51b81526004016106c6906133cf565b611d98611fa1565b6001600160a01b031663cec7bdb184611db0856120f4565b6040518363ffffffff1660e01b8152600401611dcd929190613242565b600060405180830381600087803b158015611de757600080fd5b505af1158015611dfb573d6000803e3d6000fd5b50505050611e076122ca565b6001600160a01b03166370a08231306040518263ffffffff1660e01b8152600401611e3291906131d7565b60206040518083038186803b158015611e4a57600080fd5b505afa158015611e5e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250611e829190810190612801565b611e8a610c3f565b1115611ea85760405162461bcd60e51b81526004016106c69061343f565b4281016000611eb5611fa1565b6001600160a01b03166343ba57df866040518060400160405280866001600160401b03168152602001888152506040518363ffffffff1660e01b8152600401611eff929190613286565b602060405180830381600087803b158015611f1957600080fd5b505af1158015611f2d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250611f519190810190612801565b9050846001600160a01b03167f2cc016694185d38abbe28d9e9baea2e9d95a321ae43475e5ea7b643756840bc042868685604051611f929493929190613559565b60405180910390a25050505050565b6000610cb974526577617264457363726f77563253746f7261676560581b61232c565b60008082602001516000146107645782516001600160401b0316421015611fec5760006108ca565b50506020015190565b611ffd611fa1565b6001600160a01b031663cec7bdb184612015846120f4565b6000036040518363ffffffff1660e01b8152600401612035929190613242565b600060405180830381600087803b15801561204f57600080fd5b505af1158015612063573d6000803e3d6000fd5b5050505061206f6122ca565b6001600160a01b031663a9059cbb83836040518363ffffffff1660e01b815260040161209c929190613242565b602060405180830381600087803b1580156120b657600080fd5b505af11580156120ca573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506120ee91908101906127a7565b50505050565b6000600160ff1b82106121195760405162461bcd60e51b81526004016106c6906134df565b5090565b60405162461bcd60e51b81526004016106c69061341f565b6000610cb96524b9b9bab2b960d11b61232c565b60408051600480825260a0820190925260609160208201608080388339019050509050680a6f2dce8d0cae8d2f60bb1b8160008151811061218657fe5b60200260200101818152505066119959541bdbdb60ca1b816001815181106121aa57fe5b6020026020010181815250506524b9b9bab2b960d11b816002815181106121cd57fe5b60200260200101818152505074526577617264457363726f77563253746f7261676560581b816003815181106121ff57fe5b60200260200101818152505090565b6060815183510160405190808252806020026020018201604052801561223e578160200160208202803883390190505b50905060005b83518110156122805783818151811061225957fe5b602002602001015182828151811061226d57fe5b6020908102919091010152600101612244565b5060005b82518110156122c35782818151811061229957fe5b60200260200101518282865101815181106122b057fe5b6020908102919091010152600101612284565b5092915050565b6000610cb9680a6f2dce8d0cae8d2f60bb1b61232c565b6000610cb97453796e746865746978427269646765546f4261736560581b61232c565b6000828211156123265760405162461bcd60e51b81526004016106c6906133ff565b50900390565b60008181526004602090815260408083205490516001600160a01b03909116918215159161235c918691016131ac565b604051602081830303815290604052906122c35760405162461bcd60e51b81526004016106c6919061338e565b604080518082019091526000808252602082015290565b604051806060016040528060006001600160401b0316815260200160008152602001600081525090565b80356107648161367d565b80516107648161367d565b60008083601f8401126123f257600080fd5b5081356001600160401b0381111561240957600080fd5b602083019150836020820283011115610bc857600080fd5b60008083601f84011261243357600080fd5b5081356001600160401b0381111561244a57600080fd5b602083019150836040820283011115610bc857600080fd5b805161076481613691565b60006040828403121561247f57600080fd5b61248960406135a5565b9050600061249784846124d5565b82525060206124a8848483016124bf565b60208301525092915050565b80356107648161369a565b80516107648161369a565b8035610764816136a3565b8051610764816136a3565b6000602082840312156124f257600080fd5b60006124fe84846123ca565b949350505050565b60006020828403121561251857600080fd5b60006124fe84846123d5565b6000806000806080858703121561253a57600080fd5b600061254687876123ca565b9450506020612557878288016123ca565b9350506040612568878288016124b4565b9250506060612579878288016124b4565b91505092959194509250565b60008060006040848603121561259a57600080fd5b60006125a686866123ca565b93505060208401356001600160401b038111156125c257600080fd5b6125ce868287016123e0565b92509250509250925092565b600080604083850312156125ed57600080fd5b60006125f985856123ca565b925050602061260a858286016124b4565b9150509250929050565b6000806000806060858703121561262a57600080fd5b600061263687876123ca565b9450506020612647878288016124b4565b93505060408501356001600160401b0381111561266357600080fd5b61266f87828801612421565b95989497509550505050565b60008060006060848603121561269057600080fd5b600061269c86866123ca565b93505060206126ad868287016124b4565b92505060406126be868287016124b4565b9150509250925092565b600080600080600080606087890312156126e157600080fd5b86356001600160401b038111156126f757600080fd5b61270389828a016123e0565b965096505060208701356001600160401b0381111561272157600080fd5b61272d89828a016123e0565b945094505060408701356001600160401b0381111561274b57600080fd5b61275789828a016123e0565b92509250509295509295509295565b6000806020838503121561277957600080fd5b82356001600160401b0381111561278f57600080fd5b61279b858286016123e0565b92509250509250929050565b6000602082840312156127b957600080fd5b60006124fe8484612462565b6000604082840312156127d757600080fd5b60006124fe848461246d565b6000602082840312156127f557600080fd5b60006124fe84846124b4565b60006020828403121561281357600080fd5b60006124fe84846124bf565b60008060006060848603121561283457600080fd5b600061284086866124bf565b9350506020612851868287016124bf565b92505060406126be868287016124bf565b600061286e8383612a3b565b505060200190565b60006128828383613115565b505060600190565b6000612896838361317f565b505060400190565b6128a781613629565b82525050565b6128a781613601565b60006128c1826135d1565b6128cb81856135d5565b93506128d6836135cb565b8060005b838110156129045781516128ee8882612862565b97506128f9836135cb565b9250506001016128da565b509495945050505050565b600061291a826135d1565b61292481856135d5565b935061292f836135cb565b8060005b838110156129045781516129478882612876565b9750612952836135cb565b925050600101612933565b6000612968826135d1565b61297281856135d5565b935061297d836135cb565b8060005b83811015612904578151612995888261288a565b97506129a0836135cb565b925050600101612981565b60006129b783856135d5565b93506001600160fb1b038311156129cd57600080fd5b6020830292506129de83858461363b565b50500190565b60006129ef826135d1565b6129f981856135d5565b9350612a04836135cb565b8060005b83811015612904578151612a1c8882612862565b9750612a27836135cb565b925050600101612a08565b6128a78161360c565b6128a7816105d5565b6128a7612a50826105d5565b6105d5565b6128a781613630565b6000612a69826135d1565b612a7381856135d5565b9350612a83818560208601613647565b612a8c81613673565b9093019392505050565b6000612aa3601c836135d5565b7f656e74726965732073756d206c657373207468616e2074617267657400000000815260200192915050565b6000612adc6035836135d5565b7f596f75206d757374206265206e6f6d696e61746564206265666f726520796f7581527402063616e20616363657074206f776e65727368697605c1b602082015260400192915050565b6000612b33601b836135d5565b7f536166654d6174683a206164646974696f6e206f766572666c6f770000000000815260200192915050565b6000612b6c6033836135d5565b7f43616e6e6f7420657363726f7720776974682030206475726174696f6e204f528152721030b137bb329036b0bc2fb23ab930ba34b7b760691b602082015260400192915050565b6000612bc16024836135d5565b7f43616e6e6f742063726561746520657363726f772077697468206164647265738152637328302960e01b602082015260400192915050565b6000612c076035836135d5565b7f43616e206f6e6c7920626520696e766f6b65642062792053796e746865746978815274109c9a5919d9551bd0985cd94818dbdb9d1c9858dd605a1b602082015260400192915050565b6000612c5e601e836135d5565b7f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815260200192915050565b6000612c97600e836135d5565b6d09edcd8f240a6f2dce8d0cae8d2f60931b815260200192915050565b6000612cc1601b836135d5565b7f43616e6e6f742062652072756e206f6e2074686973206c617965720000000000815260200192915050565b6000612cfa6011836135de565b70026b4b9b9b4b7339030b2323932b9b99d1607d1b815260110192915050565b6000612d276017836135d5565b7f5175616e746974792063616e6e6f74206265207a65726f000000000000000000815260200192915050565b6000612d606047836135d5565b7f4d75737420626520656e6f7567682062616c616e636520696e2074686520636f81527f6e747261637420746f2070726f7669646520666f72207468652076657374696e6020820152666720656e74727960c81b604082015260600192915050565b6000612dcf6019836135d5565b7f4163636f756e74206d657267696e672068617320656e64656400000000000000815260200192915050565b6000612e086015836135d5565b741d1bdad95b881d1c985b9cd9995c8819985a5b1959605a1b815260200192915050565b6000612e396024836135d5565b7f43616e6e6f74206e6f6d696e617465206f776e206163636f756e7420746f206d8152636572676560e01b602082015260400192915050565b6000612e7f602f836135d5565b7f4f6e6c792074686520636f6e7472616374206f776e6572206d6179207065726681526e37b936903a3434b99030b1ba34b7b760891b602082015260400192915050565b631cd554d160e21b9052565b6000612edc6021836135d5565b7f41646472657373206973206e6f74206e6f6d696e6174656420746f206d6572678152606560f81b602082015260400192915050565b6000612f1f6011836135d5565b701c9958da5c1a595b9d081b9bdd081cd95d607a1b815260200192915050565b6000612f4c601c836135d5565b7f65786365656473206d6178206d657267696e67206475726174696f6e00000000815260200192915050565b6000612f856019836135de565b7f5265736f6c766572206d697373696e67207461726765743a2000000000000000815260190192915050565b6000612fbe6028836135d5565b7f4f6e6c792074686520466565506f6f6c2063616e20706572666f726d20746869815267399030b1ba34b7b760c11b602082015260400192915050565b6000613008600f836135d5565b6e1858d8dbdd5b9d081b9bdd081cd95d608a1b815260200192915050565b60006130336028836135d5565b7f53616665436173743a2076616c756520646f65736e27742066697420696e2061815267371034b73a191a9b60c11b602082015260400192915050565b600061307d6044836135d5565b7f496e73756666696369656e742062616c616e636520696e2074686520636f6e7481527f7261637420746f2070726f7669646520666f7220657363726f7765642062616c602082015263616e636560e01b604082015260600192915050565b60006130e9601f836135d5565b7f43616e6e6f74206d65726765206163636f756e74732077697468206465627400815260200192915050565b8051606083019061312684826131a3565b5060208201516131396020850182612a3b565b5060408201516120ee6040850182612a3b565b6040820161315a82806135f2565b61316484826131a3565b5061317260208301836135e3565b6120ee6020850182612a3b565b8051604083019061319084826131a3565b5060208201516120ee6020850182612a3b565b6128a78161361d565b60006131b782612ced565b91506131c38284612a44565b50602001919050565b60006131b782612f78565b6020810161076482846128ad565b606081016131f3828661289e565b61320060208301856128ad565b6124fe6040830184612a3b565b6040810161321b828461289e565b61076460208301612ec3565b6040810161323582856128ad565b6108ca60208301846128ad565b6040810161325082856128ad565b6108ca6020830184612a3b565b6040810161321b82846128ad565b6060810161327982856128ad565b6108ca602083018461314c565b6060810161329482856128ad565b6108ca602083018461317f565b608081016132af82886128ad565b6132bc6020830187612a3b565b81810360408301526132cf8185876129ab565b90506132de6060830184612a3b565b9695505050505050565b606081016132f682866128ad565b6132006020830185612a3b565b602080825281016108ca81846128b6565b602080825281016108ca818461290f565b602080825281016108ca81846129e4565b602081016107648284612a32565b602081016107648284612a3b565b604081016132358285612a3b565b6040810161336e8285612a3b565b81810360208301526124fe8184612a5e565b602081016107648284612a55565b602080825281016108ca8184612a5e565b6020808252810161076481612a96565b6020808252810161076481612acf565b6020808252810161076481612b26565b6020808252810161076481612b5f565b6020808252810161076481612bb4565b6020808252810161076481612bfa565b6020808252810161076481612c51565b6020808252810161076481612c8a565b6020808252810161076481612cb4565b6020808252810161076481612d1a565b6020808252810161076481612d53565b6020808252810161076481612dc2565b6020808252810161076481612dfb565b6020808252810161076481612e2c565b6020808252810161076481612e72565b6020808252810161076481612ecf565b6020808252810161076481612f12565b6020808252810161076481612f3f565b6020808252810161076481612fb1565b6020808252810161076481612ffb565b6020808252810161076481613026565b6020808252810161076481613070565b60208082528101610764816130dc565b60408101610764828461317f565b6040810161352b8285612a3b565b81810360208301526124fe818461295d565b604081016132508285612a3b565b606081016132f68286612a3b565b608081016135678287612a3b565b6135746020830186612a3b565b6135816040830185612a3b565b61358e6060830184612a3b565b95945050505050565b6040810161325082856131a3565b6040518181016001600160401b03811182821017156135c357600080fd5b604052919050565b60200190565b5190565b90815260200190565b919050565b60006108ca60208401846124b4565b60006108ca60208401846124ca565b600061076482613611565b151590565b6001600160a01b031690565b6001600160401b031690565b6000610764825b600061076482613601565b82818337506000910152565b60005b8381101561366257818101518382015260200161364a565b838111156120ee5750506000910152565b601f01601f191690565b61368681613601565b8114610f6257600080fd5b6136868161360c565b613686816105d5565b6136868161361d56fea365627a7a72315820548d7e03dbddde9de723946b9470f701d7854b6b5ffe06adcb05794ac93ee26d6c6578706572696d656e74616cf564736f6c63430005100040

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

000000000000000000000000302d2451d9f47620374b54c521423bf0403916a20000000000000000000000001cb059b7e74fd21665968c908806143e744d5f30

-----Decoded View---------------
Arg [0] : _owner (address): 0x302d2451d9f47620374B54c521423Bf0403916A2
Arg [1] : _resolver (address): 0x1Cb059b7e74fD21665968C908806143E744D5F30

-----Encoded View---------------
2 Constructor Arguments found :
Arg [0] : 000000000000000000000000302d2451d9f47620374b54c521423bf0403916a2
Arg [1] : 0000000000000000000000001cb059b7e74fd21665968c908806143e744d5f30


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
[ Download: CSV Export  ]
[ 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.