ETH Price: $3,381.22 (-1.18%)

Contract

0xd8EF3cACe8b4907117a45B0b125c68560532F94D
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Redeem212701122024-11-26 6:23:4721 hrs ago1732602227IN
Set: Basic Issuance Module
0 ETH0.001655517.0817264
Redeem212219362024-11-19 13:00:117 days ago1732021211IN
Set: Basic Issuance Module
0 ETH0.0209782423.69023639
Redeem211723832024-11-12 15:05:1114 days ago1731423911IN
Set: Basic Issuance Module
0 ETH0.0023852323.40457108
Redeem211494172024-11-09 10:11:4717 days ago1731147107IN
Set: Basic Issuance Module
0 ETH0.005921158.42092685
Redeem211443652024-11-08 17:17:5918 days ago1731086279IN
Set: Basic Issuance Module
0 ETH0.0050654115.95427786
Redeem211443592024-11-08 17:16:4718 days ago1731086207IN
Set: Basic Issuance Module
0 ETH0.0068958618.53314725
Redeem211388982024-11-07 22:57:4719 days ago1731020267IN
Set: Basic Issuance Module
0 ETH0.0090161931.15531812
Redeem211309242024-11-06 20:13:1120 days ago1730923991IN
Set: Basic Issuance Module
0 ETH0.0024494720.67123726
Redeem211309142024-11-06 20:11:1120 days ago1730923871IN
Set: Basic Issuance Module
0 ETH0.0090315320.90527193
Redeem211309042024-11-06 20:09:1120 days ago1730923751IN
Set: Basic Issuance Module
0 ETH0.0036890820.78392133
Redeem210695882024-10-29 6:45:3528 days ago1730184335IN
Set: Basic Issuance Module
0 ETH0.001104618.45130518
Redeem210506642024-10-26 15:23:2331 days ago1729956203IN
Set: Basic Issuance Module
0 ETH0.000948078
Redeem210375542024-10-24 19:28:5933 days ago1729798139IN
Set: Basic Issuance Module
0 ETH0.0016591214
Redeem210074922024-10-20 14:49:2337 days ago1729435763IN
Set: Basic Issuance Module
0 ETH0.0136778715.44588817
Redeem209810552024-10-16 22:18:2341 days ago1729117103IN
Set: Basic Issuance Module
0 ETH0.007371769.71038485
Redeem209697172024-10-15 8:16:4742 days ago1728980207IN
Set: Basic Issuance Module
0 ETH0.0017702413.54276104
Redeem209478412024-10-12 6:48:5945 days ago1728715739IN
Set: Basic Issuance Module
0 ETH0.00667788.79613347
Redeem209471272024-10-12 4:25:4745 days ago1728707147IN
Set: Basic Issuance Module
0 ETH0.003645027.26248159
Redeem209470562024-10-12 4:11:3546 days ago1728706295IN
Set: Basic Issuance Module
0 ETH0.0048787.6128933
Redeem209171792024-10-08 0:09:5950 days ago1728346199IN
Set: Basic Issuance Module
0 ETH0.00405789.99655386
Redeem209123422024-10-07 7:59:2350 days ago1728287963IN
Set: Basic Issuance Module
0 ETH0.003713766.84286789
Redeem208937582024-10-04 17:48:5953 days ago1728064139IN
Set: Basic Issuance Module
0 ETH0.005675028.81
Redeem208678092024-10-01 2:58:4757 days ago1727751527IN
Set: Basic Issuance Module
0 ETH0.002342355.39989794
Redeem208670752024-10-01 0:31:3557 days ago1727742695IN
Set: Basic Issuance Module
0 ETH0.004575787.99563147
Redeem208670582024-10-01 0:28:1157 days ago1727742491IN
Set: Basic Issuance Module
0 ETH0.004333136.70628249
View all transactions

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading

Similar Match Source Code
This contract matches the deployed Bytecode of the Source Code for Contract 0x508910aA...A355BA35B
The constructor portion of the code might be different and could alter the actual behaviour of the contract

Contract Name:
BasicIssuanceModule

Compiler Version
v0.6.10+commit.00c0fcaf

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion, Apache-2.0 license

Contract Source Code (Solidity)

/**
 *Submitted for verification at Etherscan.io on 2020-09-08
*/

/**
 *Submitted for verification at Etherscan.io on 2020-09-08
*/

// Dependency file: @openzeppelin/contracts/utils/Address.sol



// pragma solidity ^0.6.2;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [// importANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // According to EIP-1052, 0x0 is the value returned for not-yet created accounts
        // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
        // for accounts without code, i.e. `keccak256('')`
        bytes32 codehash;
        bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
        // solhint-disable-next-line no-inline-assembly
        assembly { codehash := extcodehash(account) }
        return (codehash != accountHash && codehash != 0x0);
    }

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

        // solhint-disable-next-line avoid-low-level-calls, avoid-call-value
        (bool success, ) = recipient.call{ value: amount }("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

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

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

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

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

    function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
        require(isContract(target), "Address: call to non-contract");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
        if (success) {
            return returndata;
        } else {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly

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

// Dependency file: @openzeppelin/contracts/token/ERC20/SafeERC20.sol



// pragma solidity ^0.6.0;

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

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

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

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

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

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

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

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

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

// Dependency file: @openzeppelin/contracts/math/SignedSafeMath.sol



// pragma solidity ^0.6.0;

/**
 * @title SignedSafeMath
 * @dev Signed math operations with safety checks that revert on error.
 */
library SignedSafeMath {
    int256 constant private _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;
    }
}

// Dependency file: contracts/interfaces/IModule.sol

/*
    Copyright 2020 Set Labs Inc.

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

    http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.


*/
// pragma solidity 0.6.10;


/**
 * @title IModule
 * @author Set Protocol
 *
 * Interface for interacting with Modules.
 */
interface IModule {
    /**
     * Called by a SetToken to notify that this module was removed from the Set token. Any logic can be included
     * in case checks need to be made or state needs to be cleared.
     */
    function removeModule() external;
}
// Dependency file: contracts/lib/ExplicitERC20.sol

/*
    Copyright 2020 Set Labs Inc.

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

    http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.


*/

// pragma solidity 0.6.10;

// import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
// import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";
// import { SafeMath } from "@openzeppelin/contracts/math/SafeMath.sol";

/**
 * @title ExplicitERC20
 * @author Set Protocol
 *
 * Utility functions for ERC20 transfers that require the explicit amount to be transferred.
 */
library ExplicitERC20 {
    using SafeMath for uint256;

    /**
     * When given allowance, transfers a token from the "_from" to the "_to" of quantity "_quantity".
     * Ensures that the recipient has received the correct quantity (ie no fees taken on transfer)
     *
     * @param _token           ERC20 token to approve
     * @param _from            The account to transfer tokens from
     * @param _to              The account to transfer tokens to
     * @param _quantity        The quantity to transfer
     */
    function transferFrom(
        IERC20 _token,
        address _from,
        address _to,
        uint256 _quantity
    )
        internal
    {
        // Call specified ERC20 contract to transfer tokens (via proxy).
        if (_quantity > 0) {
            uint256 existingBalance = _token.balanceOf(_to);

            SafeERC20.safeTransferFrom(
                _token,
                _from,
                _to,
                _quantity
            );

            uint256 newBalance = _token.balanceOf(_to);

            // Verify transfer quantity is reflected in balance
            require(
                newBalance == existingBalance.add(_quantity),
                "Invalid post transfer balance"
            );
        }
    }
}

// Dependency file: contracts/lib/PreciseUnitMath.sol

/*
    Copyright 2020 Set Labs Inc.

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

    http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.


*/

// pragma solidity 0.6.10;
// pragma experimental ABIEncoderV2;

// import { SafeMath } from "@openzeppelin/contracts/math/SafeMath.sol";
// import { SignedSafeMath } from "@openzeppelin/contracts/math/SignedSafeMath.sol";


/**
 * @title PreciseUnitMath
 * @author Set Protocol
 *
 * Arithmetic for fixed-point numbers with 18 decimals of precision. Some functions taken from
 * dYdX's BaseMath library.
 */
library PreciseUnitMath {
    using SafeMath for uint256;
    using SignedSafeMath for int256;

    // The number One in precise units.
    uint256 constant internal PRECISE_UNIT = 10 ** 18;
    int256 constant internal PRECISE_UNIT_INT = 10 ** 18;

    // Max unsigned integer value
    uint256 constant internal MAX_UINT_256 = type(uint256).max;
    // Max and min signed integer value
    int256 constant internal MAX_INT_256 = type(int256).max;
    int256 constant internal MIN_INT_256 = type(int256).min;

    /**
     * @dev Getter function since constants can't be read directly from libraries.
     */
    function preciseUnit() internal pure returns (uint256) {
        return PRECISE_UNIT;
    }

    /**
     * @dev Getter function since constants can't be read directly from libraries.
     */
    function preciseUnitInt() internal pure returns (int256) {
        return PRECISE_UNIT_INT;
    }

    /**
     * @dev Getter function since constants can't be read directly from libraries.
     */
    function maxUint256() internal pure returns (uint256) {
        return MAX_UINT_256;
    }

    /**
     * @dev Getter function since constants can't be read directly from libraries.
     */
    function maxInt256() internal pure returns (int256) {
        return MAX_INT_256;
    }

    /**
     * @dev Getter function since constants can't be read directly from libraries.
     */
    function minInt256() internal pure returns (int256) {
        return MIN_INT_256;
    }

    /**
     * @dev Multiplies value a by value b (result is rounded down). It's assumed that the value b is the significand
     * of a number with 18 decimals precision.
     */
    function preciseMul(uint256 a, uint256 b) internal pure returns (uint256) {
        return a.mul(b).div(PRECISE_UNIT);
    }

    /**
     * @dev Multiplies value a by value b (result is rounded towards zero). It's assumed that the value b is the
     * significand of a number with 18 decimals precision.
     */
    function preciseMul(int256 a, int256 b) internal pure returns (int256) {
        return a.mul(b).div(PRECISE_UNIT_INT);
    }

    /**
     * @dev Multiplies value a by value b (result is rounded up). It's assumed that the value b is the significand
     * of a number with 18 decimals precision.
     */
    function preciseMulCeil(uint256 a, uint256 b) internal pure returns (uint256) {
        if (a == 0 || b == 0) {
            return 0;
        }
        return a.mul(b).sub(1).div(PRECISE_UNIT).add(1);
    }

    /**
     * @dev Divides value a by value b (result is rounded down).
     */
    function preciseDiv(uint256 a, uint256 b) internal pure returns (uint256) {
        return a.mul(PRECISE_UNIT).div(b);
    }


    /**
     * @dev Divides value a by value b (result is rounded towards 0).
     */
    function preciseDiv(int256 a, int256 b) internal pure returns (int256) {
        return a.mul(PRECISE_UNIT_INT).div(b);
    }

    /**
     * @dev Divides value a by value b (result is rounded up or away from 0).
     */
    function preciseDivCeil(uint256 a, uint256 b) internal pure returns (uint256) {
        require(b != 0, "Cant divide by 0");

        return a > 0 ? a.mul(PRECISE_UNIT).sub(1).div(b).add(1) : 0;
    }

    /**
     * @dev Divides value a by value b (result is rounded down - positive numbers toward 0 and negative away from 0).
     */
    function divDown(int256 a, int256 b) internal pure returns (int256) {
        require(b != 0, "Cant divide by 0");
        require(a != MIN_INT_256 || b != -1, "Invalid input");

        int256 result = a.div(b);
        if (a ^ b < 0 && a % b != 0) {
            result = result.sub(1);
        }

        return result;
    }

    /**
     * @dev Multiplies value a by value b where rounding is towards the lesser number. 
     * (positive values are rounded towards zero and negative values are rounded away from 0). 
     */
    function conservativePreciseMul(int256 a, int256 b) internal pure returns (int256) {
        return divDown(a.mul(b), PRECISE_UNIT_INT);
    }

    /**
     * @dev Divides value a by value b where rounding is towards the lesser number. 
     * (positive values are rounded towards zero and negative values are rounded away from 0). 
     */
    function conservativePreciseDiv(int256 a, int256 b) internal pure returns (int256) {
        return divDown(a.mul(PRECISE_UNIT_INT), b);
    }
}
// Dependency file: contracts/protocol/lib/Position.sol

/*
    Copyright 2020 Set Labs Inc.

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

    http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.


*/

// pragma solidity 0.6.10;
// pragma experimental "ABIEncoderV2";

// import { SafeCast } from "@openzeppelin/contracts/utils/SafeCast.sol";
// import { SafeMath } from "@openzeppelin/contracts/math/SafeMath.sol";
// import { SignedSafeMath } from "@openzeppelin/contracts/math/SignedSafeMath.sol";

// import { ISetToken } from "../../interfaces/ISetToken.sol";
// import { PreciseUnitMath } from "../../lib/PreciseUnitMath.sol";

/**
 * @title Position
 * @author Set Protocol
 *
 * Collection of helper functions for handling and updating SetToken Positions
 */
library Position {
    using SafeCast for uint256;
    using SafeMath for uint256;
    using SafeCast for int256;
    using SignedSafeMath for int256;
    using PreciseUnitMath for uint256;

    /* ============ Helper ============ */

    /**
     * Returns whether the SetToken has a default position for a given component (if the real unit is > 0)
     */
    function hasDefaultPosition(ISetToken _setToken, address _component) internal view returns(bool) {
        return _setToken.getDefaultPositionRealUnit(_component) > 0;
    }

    /**
     * Returns whether the SetToken has an external position for a given component (if # of position modules is > 0)
     */
    function hasExternalPosition(ISetToken _setToken, address _component) internal view returns(bool) {
        return _setToken.getExternalPositionModules(_component).length > 0;
    }
    
    /**
     * Returns whether the SetToken component default position real unit is greater than or equal to units passed in.
     */
    function hasSufficientDefaultUnits(ISetToken _setToken, address _component, uint256 _unit) internal view returns(bool) {
        return _setToken.getDefaultPositionRealUnit(_component) >= _unit.toInt256();
    }

    /**
     * Returns whether the SetToken component external position is greater than or equal to the real units passed in.
     */
    function hasSufficientExternalUnits(
        ISetToken _setToken,
        address _component,
        address _positionModule,
        uint256 _unit
    )
        internal
        view
        returns(bool)
    {
       return _setToken.getExternalPositionRealUnit(_component, _positionModule) >= _unit.toInt256();    
    }

    /**
     * If the position does not exist, create a new Position and add to the SetToken. If it already exists,
     * then set the position units. If the new units is 0, remove the position. Handles adding/removing of 
     * components where needed (in light of potential external positions).
     *
     * @param _setToken           Address of SetToken being modified
     * @param _component          Address of the component
     * @param _newUnit            Quantity of Position units - must be >= 0
     */
    function editDefaultPosition(ISetToken _setToken, address _component, uint256 _newUnit) internal {
        bool isPositionFound = hasDefaultPosition(_setToken, _component);
        if (!isPositionFound && _newUnit > 0) {
            // If there is no Default Position and no External Modules, then component does not exist
            if (!hasExternalPosition(_setToken, _component)) {
                _setToken.addComponent(_component);
            }
        } else if (isPositionFound && _newUnit == 0) {
            // If there is a Default Position and no external positions, remove the component
            if (!hasExternalPosition(_setToken, _component)) {
                _setToken.removeComponent(_component);
            }
        }

        _setToken.editDefaultPositionUnit(_component, _newUnit.toInt256());
    }

    /**
     * Update an external position and remove and external positions or components if necessary. The logic flows as follows:
     * 1) If component is not already added then add component and external position. 
     * 2) If component is added but no existing external position using the passed module exists then add the external position.
     * 3) If the existing position is being added to then just update the unit
     * 4) If the position is being closed and no other external positions or default positions are associated with the component
     *    then untrack the component and remove external position.
     * 5) If the position is being closed and  other existing positions still exist for the component then just remove the
     *    external position.
     *
     * @param _setToken         SetToken being updated
     * @param _component        Component position being updated
     * @param _module           Module external position is associated with
     * @param _newUnit          Position units of new external position
     * @param _data             Arbitrary data associated with the position
     */
    function editExternalPosition(
        ISetToken _setToken,
        address _component,
        address _module,
        int256 _newUnit,
        bytes memory _data
    )
        internal
    {
        if (!_setToken.isComponent(_component)) {
            _setToken.addComponent(_component);
            addExternalPosition(_setToken, _component, _module, _newUnit, _data);
        } else if (!_setToken.isExternalPositionModule(_component, _module)) {
            addExternalPosition(_setToken, _component, _module, _newUnit, _data);
        } else if (_newUnit != 0) {
            _setToken.editExternalPositionUnit(_component, _module, _newUnit);
        } else {
            // If no default or external position remaining then remove component from components array
            if (_setToken.getDefaultPositionRealUnit(_component) == 0 && _setToken.getExternalPositionModules(_component).length == 1) {
                _setToken.removeComponent(_component);
            }
            _setToken.removeExternalPositionModule(_component, _module);
        }
    }

    /**
     * Add a new external position from a previously untracked module.
     *
     * @param _setToken         SetToken being updated
     * @param _component        Component position being updated
     * @param _module           Module external position is associated with
     * @param _newUnit          Position units of new external position
     * @param _data             Arbitrary data associated with the position
     */
    function addExternalPosition(
        ISetToken _setToken,
        address _component,
        address _module,
        int256 _newUnit,
        bytes memory _data
    )
        internal
    {
        _setToken.addExternalPositionModule(_component, _module);
        _setToken.editExternalPositionUnit(_component, _module, _newUnit);
        _setToken.editExternalPositionData(_component, _module, _data);
    }

    /**
     * Get total notional amount of Default position
     *
     * @param _setTokenSupply     Supply of SetToken in precise units (10^18)
     * @param _positionUnit       Quantity of Position units
     *
     * @return                    Total notional amount of units
     */
    function getDefaultTotalNotional(uint256 _setTokenSupply, uint256 _positionUnit) internal pure returns (uint256) {
        return _setTokenSupply.preciseMul(_positionUnit);
    }

    /**
     * Get position unit from total notional amount
     *
     * @param _setTokenSupply     Supply of SetToken in precise units (10^18)
     * @param _totalNotional      Total notional amount of component prior to
     * @return                    Default position unit
     */
    function getDefaultPositionUnit(uint256 _setTokenSupply, uint256 _totalNotional) internal pure returns (uint256) {
        return _totalNotional.preciseDiv(_setTokenSupply);
    }

    /**
     * Calculate the new position unit given total notional values pre and post executing an action that changes SetToken state
     * The intention is to make updates to the units without accidentally picking up airdropped assets as well.
     *
     * @param _setTokenSupply     Supply of SetToken in precise units (10^18)
     * @param _preTotalNotional   Total notional amount of component prior to executing action
     * @param _postTotalNotional  Total notional amount of component after the executing action
     * @param _prePositionUnit    Position unit of SetToken prior to executing action
     * @return                    New position unit
     */
    function calculateDefaultEditPositionUnit(
        uint256 _setTokenSupply,
        uint256 _preTotalNotional,
        uint256 _postTotalNotional,
        uint256 _prePositionUnit
    )
        internal
        pure
        returns (uint256)
    {
        // If pre action total notional amount is greater then subtract post action total notional and calculate new position units
        if (_preTotalNotional >= _postTotalNotional) {
            uint256 unitsToSub = _preTotalNotional.sub(_postTotalNotional).preciseDivCeil(_setTokenSupply);
            return _prePositionUnit.sub(unitsToSub);
        } else {
            // Else subtract post action total notional from pre action total notional and calculate new position units
            uint256 unitsToAdd = _postTotalNotional.sub(_preTotalNotional).preciseDiv(_setTokenSupply);
            return _prePositionUnit.add(unitsToAdd);
        }
    }
}

// Dependency file: contracts/protocol/lib/ModuleBase.sol

/*
    Copyright 2020 Set Labs Inc.

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

    http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.


*/

// pragma solidity 0.6.10;

// import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";

// import { ExplicitERC20 } from "../../lib/ExplicitERC20.sol";
// import { IController } from "../../interfaces/IController.sol";
// import { IModule } from "../../interfaces/IModule.sol";
// import { ISetToken } from "../../interfaces/ISetToken.sol";

/**
 * @title ModuleBase
 * @author Set Protocol
 *
 * Abstract class that houses common Module-related state and functions.
 */
abstract contract ModuleBase is IModule {

    /* ============ State Variables ============ */

    // Address of the controller
    IController public controller;

    /* ============ Modifiers ============ */

    modifier onlySetManager(ISetToken _setToken, address _caller) {
        require(isSetManager(_setToken, _caller), "Must be the SetToken manager");
        _;
    }

    modifier onlyValidAndInitializedSet(ISetToken _setToken) {
        require(isSetValidAndInitialized(_setToken), "Must be a valid and initialized SetToken");
        _;
    }

    /**
     * Throws if the sender is not a SetToken's module or module not enabled
     */
    modifier onlyModule(ISetToken _setToken) {
        require(
            _setToken.moduleStates(msg.sender) == ISetToken.ModuleState.INITIALIZED,
            "Only the module can call"
        );

        require(
            controller.isModule(msg.sender),
            "Module must be enabled on controller"
        );
        _;
    }

    /**
     * Utilized during module initializations to check that the module is in pending state
     * and that the SetToken is valid
     */
    modifier onlyValidAndPendingSet(ISetToken _setToken) {
        require(controller.isSet(address(_setToken)), "Must be controller-enabled SetToken");
        require(isSetPendingInitialization(_setToken), "Must be pending initialization");        
        _;
    }

    /* ============ Constructor ============ */

    /**
     * Set state variables and map asset pairs to their oracles
     *
     * @param _controller             Address of controller contract
     */
    constructor(IController _controller) public {
        controller = _controller;
    }

    /* ============ Internal Functions ============ */

    /**
     * Transfers tokens from an address (that has set allowance on the module).
     *
     * @param  _token          The address of the ERC20 token
     * @param  _from           The address to transfer from
     * @param  _to             The address to transfer to
     * @param  _quantity       The number of tokens to transfer
     */
    function transferFrom(IERC20 _token, address _from, address _to, uint256 _quantity) internal {
        ExplicitERC20.transferFrom(_token, _from, _to, _quantity);
    }

    /**
     * Returns true if the module is in process of initialization on the SetToken
     */
    function isSetPendingInitialization(ISetToken _setToken) internal view returns(bool) {
        return _setToken.isPendingModule(address(this));
    }

    /**
     * Returns true if the address is the SetToken's manager
     */
    function isSetManager(ISetToken _setToken, address _toCheck) internal view returns(bool) {
        return _setToken.manager() == _toCheck;
    }

    /**
     * Returns true if SetToken must be enabled on the controller 
     * and module is registered on the SetToken
     */
    function isSetValidAndInitialized(ISetToken _setToken) internal view returns(bool) {
        return controller.isSet(address(_setToken)) &&
            _setToken.isInitializedModule(address(this));
    }
}
// Dependency file: @openzeppelin/contracts/token/ERC20/IERC20.sol



// pragma solidity ^0.6.0;

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

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

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

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

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

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

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

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

// Dependency file: contracts/interfaces/ISetToken.sol

/*
    Copyright 2020 Set Labs Inc.

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

    http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.


*/
// pragma solidity 0.6.10;
// pragma experimental "ABIEncoderV2";

// import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";

/**
 * @title ISetToken
 * @author Set Protocol
 *
 * Interface for operating with SetTokens.
 */
interface ISetToken is IERC20 {

    /* ============ Enums ============ */

    enum ModuleState {
        NONE,
        PENDING,
        INITIALIZED
    }

    /* ============ Structs ============ */
    /**
     * The base definition of a SetToken Position
     *
     * @param component           Address of token in the Position
     * @param module              If not in default state, the address of associated module
     * @param unit                Each unit is the # of components per 10^18 of a SetToken
     * @param positionState       Position ENUM. Default is 0; External is 1
     * @param data                Arbitrary data
     */
    struct Position {
        address component;
        address module;
        int256 unit;
        uint8 positionState;
        bytes data;
    }

    /**
     * A struct that stores a component's cash position details and external positions
     * This data structure allows O(1) access to a component's cash position units and 
     * virtual units.
     *
     * @param virtualUnit               Virtual value of a component's DEFAULT position. Stored as virtual for efficiency
     *                                  updating all units at once via the position multiplier. Virtual units are achieved
     *                                  by dividing a "real" value by the "positionMultiplier"
     * @param componentIndex            
     * @param externalPositionModules   List of external modules attached to each external position. Each module
     *                                  maps to an external position
     * @param externalPositions         Mapping of module => ExternalPosition struct for a given component
     */
    struct ComponentPosition {
      int256 virtualUnit;
      address[] externalPositionModules;
      mapping(address => ExternalPosition) externalPositions;
    }

    /**
     * A struct that stores a component's external position details including virtual unit and any
     * auxiliary data.
     *
     * @param virtualUnit       Virtual value of a component's EXTERNAL position.
     * @param data              Arbitrary data
     */
    struct ExternalPosition {
      int256 virtualUnit;
      bytes data;
    }


    /* ============ Functions ============ */
    
    function addComponent(address _component) external;
    function removeComponent(address _component) external;
    function editDefaultPositionUnit(address _component, int256 _realUnit) external;
    function addExternalPositionModule(address _component, address _positionModule) external;
    function removeExternalPositionModule(address _component, address _positionModule) external;
    function editExternalPositionUnit(address _component, address _positionModule, int256 _realUnit) external;
    function editExternalPositionData(address _component, address _positionModule, bytes calldata _data) external;

    function invoke(address _target, uint256 _value, bytes calldata _data) external returns(bytes memory);

    function editPositionMultiplier(int256 _newMultiplier) external;

    function mint(address _account, uint256 _quantity) external;
    function burn(address _account, uint256 _quantity) external;

    function lock() external;
    function unlock() external;

    function addModule(address _module) external;
    function removeModule(address _module) external;
    function initializeModule() external;

    function setManager(address _manager) external;

    function manager() external view returns (address);
    function moduleStates(address _module) external view returns (ModuleState);
    function getModules() external view returns (address[] memory);
    
    function getDefaultPositionRealUnit(address _component) external view returns(int256);
    function getExternalPositionRealUnit(address _component, address _positionModule) external view returns(int256);
    function getComponents() external view returns(address[] memory);
    function getExternalPositionModules(address _component) external view returns(address[] memory);
    function getExternalPositionData(address _component, address _positionModule) external view returns(bytes memory);
    function isExternalPositionModule(address _component, address _module) external view returns(bool);
    function isComponent(address _component) external view returns(bool);
    
    function positionMultiplier() external view returns (int256);
    function getPositions() external view returns (Position[] memory);
    function getTotalComponentRealUnits(address _component) external view returns(int256);

    function isInitializedModule(address _module) external view returns(bool);
    function isPendingModule(address _module) external view returns(bool);
    function isLocked() external view returns (bool);
}
// Dependency file: contracts/protocol/lib/Invoke.sol

/*
    Copyright 2020 Set Labs Inc.

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

    http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.


*/

// pragma solidity 0.6.10;

// import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
// import { SafeMath } from "@openzeppelin/contracts/math/SafeMath.sol";

// import { ISetToken } from "../../interfaces/ISetToken.sol";


/**
 * @title Invoke
 * @author Set Protocol
 *
 * A collection of common utility functions for interacting with the SetToken's invoke function
 */
library Invoke {
    using SafeMath for uint256;

    /* ============ Internal ============ */

    /**
     * Instructs the SetToken to set approvals of the ERC20 token to a spender.
     *
     * @param _setToken        SetToken instance to invoke
     * @param _token           ERC20 token to approve
     * @param _spender         The account allowed to spend the SetToken's balance
     * @param _quantity        The quantity of allowance to allow
     */
    function invokeApprove(
        ISetToken _setToken,
        address _token,
        address _spender,
        uint256 _quantity
    )
        internal
    {
        bytes memory callData = abi.encodeWithSignature("approve(address,uint256)", _spender, _quantity);
        _setToken.invoke(_token, 0, callData);
    }

    /**
     * Instructs the SetToken to transfer the ERC20 token to a recipient.
     *
     * @param _setToken        SetToken instance to invoke
     * @param _token           ERC20 token to transfer
     * @param _to              The recipient account
     * @param _quantity        The quantity to transfer
     */
    function invokeTransfer(
        ISetToken _setToken,
        address _token,
        address _to,
        uint256 _quantity
    )
        internal
    {
        if (_quantity > 0) {
            bytes memory callData = abi.encodeWithSignature("transfer(address,uint256)", _to, _quantity);
            _setToken.invoke(_token, 0, callData);
        }
    }

    /**
     * Instructs the SetToken to transfer the ERC20 token to a recipient.
     * The new SetToken balance must equal the existing balance less the quantity transferred
     *
     * @param _setToken        SetToken instance to invoke
     * @param _token           ERC20 token to transfer
     * @param _to              The recipient account
     * @param _quantity        The quantity to transfer
     */
    function strictInvokeTransfer(
        ISetToken _setToken,
        address _token,
        address _to,
        uint256 _quantity
    )
        internal
    {
        if (_quantity > 0) {
            // Retrieve current balance of token for the SetToken
            uint256 existingBalance = IERC20(_token).balanceOf(address(_setToken));

            Invoke.invokeTransfer(_setToken, _token, _to, _quantity);

            // Get new balance of transferred token for SetToken
            uint256 newBalance = IERC20(_token).balanceOf(address(_setToken));

            // Verify only the transfer quantity is subtracted
            require(
                newBalance == existingBalance.sub(_quantity),
                "Invalid post transfer balance"
            );
        }
    }

    /**
     * Instructs the SetToken to unwrap the passed quantity of WETH
     *
     * @param _setToken        SetToken instance to invoke
     * @param _weth            WETH address
     * @param _quantity        The quantity to unwrap
     */
    function invokeUnwrapWETH(ISetToken _setToken, address _weth, uint256 _quantity) internal {
        bytes memory callData = abi.encodeWithSignature("withdraw(uint256)", _quantity);
        _setToken.invoke(_weth, 0, callData);
    }

    /**
     * Instructs the SetToken to wrap the passed quantity of ETH
     *
     * @param _setToken        SetToken instance to invoke
     * @param _weth            WETH address
     * @param _quantity        The quantity to unwrap
     */
    function invokeWrapWETH(ISetToken _setToken, address _weth, uint256 _quantity) internal {
        bytes memory callData = abi.encodeWithSignature("deposit()");
        _setToken.invoke(_weth, _quantity, callData);
    }
}
// Dependency file: contracts/interfaces/IManagerIssuanceHook.sol

/*
    Copyright 2020 Set Labs Inc.

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

    http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.


*/
// pragma solidity 0.6.10;

// import { ISetToken } from "./ISetToken.sol";

interface IManagerIssuanceHook {
    function invokePreIssueHook(ISetToken _setToken, uint256 _issueQuantity, address _sender, address _to) external;
}
// Dependency file: contracts/interfaces/IController.sol

/*
    Copyright 2020 Set Labs Inc.

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

    http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.


*/
// pragma solidity 0.6.10;

interface IController {
    function addSet(address _setToken) external;
    function getModuleFee(address _module, uint256 _feeType) external view returns(uint256);
    function resourceId(uint256 _id) external view returns(address);
    function feeRecipient() external view returns(address);
    function isModule(address _module) external view returns(bool);
    function isSet(address _setToken) external view returns(bool);
    function isSystemContract(address _contractAddress) external view returns (bool);
}
// Dependency file: @openzeppelin/contracts/math/SafeMath.sol



// pragma solidity ^0.6.0;

/**
 * @dev Wrappers over Solidity's arithmetic operations with added overflow
 * checks.
 *
 * Arithmetic operations in Solidity wrap on overflow. This can easily result
 * in bugs, because programmers usually assume that an overflow raises an
 * error, which is the standard behavior in high level programming languages.
 * `SafeMath` restores this intuition by reverting the transaction when an
 * operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 */
library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, 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) {
        return sub(a, b, "SafeMath: subtraction overflow");
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b <= a, errorMessage);
        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-contracts/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) {
        return div(a, b, "SafeMath: division by zero");
    }

    /**
     * @dev Returns the integer division of two unsigned integers. Reverts with custom message 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, string memory errorMessage) internal pure returns (uint256) {
        require(b > 0, errorMessage);
        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) {
        return mod(a, b, "SafeMath: modulo by zero");
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts with custom message 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, string memory errorMessage) internal pure returns (uint256) {
        require(b != 0, errorMessage);
        return a % b;
    }
}

// Dependency file: @openzeppelin/contracts/utils/SafeCast.sol



// pragma solidity ^0.6.0;


/**
 * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow
 * checks.
 *
 * Downcasting from uint256/int256 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} and {SignedSafeMath} to extend it to smaller types, by performing
 * all math on `uint256` and `int256` 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 Returns the downcasted int128 from int256, reverting on
     * overflow (when the input is less than smallest int128 or
     * greater than largest int128).
     *
     * Counterpart to Solidity's `int128` operator.
     *
     * Requirements:
     *
     * - input must fit into 128 bits
     *
     * _Available since v3.1._
     */
    function toInt128(int256 value) internal pure returns (int128) {
        require(value >= -2**127 && value < 2**127, "SafeCast: value doesn\'t fit in 128 bits");
        return int128(value);
    }

    /**
     * @dev Returns the downcasted int64 from int256, reverting on
     * overflow (when the input is less than smallest int64 or
     * greater than largest int64).
     *
     * Counterpart to Solidity's `int64` operator.
     *
     * Requirements:
     *
     * - input must fit into 64 bits
     *
     * _Available since v3.1._
     */
    function toInt64(int256 value) internal pure returns (int64) {
        require(value >= -2**63 && value < 2**63, "SafeCast: value doesn\'t fit in 64 bits");
        return int64(value);
    }

    /**
     * @dev Returns the downcasted int32 from int256, reverting on
     * overflow (when the input is less than smallest int32 or
     * greater than largest int32).
     *
     * Counterpart to Solidity's `int32` operator.
     *
     * Requirements:
     *
     * - input must fit into 32 bits
     *
     * _Available since v3.1._
     */
    function toInt32(int256 value) internal pure returns (int32) {
        require(value >= -2**31 && value < 2**31, "SafeCast: value doesn\'t fit in 32 bits");
        return int32(value);
    }

    /**
     * @dev Returns the downcasted int16 from int256, reverting on
     * overflow (when the input is less than smallest int16 or
     * greater than largest int16).
     *
     * Counterpart to Solidity's `int16` operator.
     *
     * Requirements:
     *
     * - input must fit into 16 bits
     *
     * _Available since v3.1._
     */
    function toInt16(int256 value) internal pure returns (int16) {
        require(value >= -2**15 && value < 2**15, "SafeCast: value doesn\'t fit in 16 bits");
        return int16(value);
    }

    /**
     * @dev Returns the downcasted int8 from int256, reverting on
     * overflow (when the input is less than smallest int8 or
     * greater than largest int8).
     *
     * Counterpart to Solidity's `int8` operator.
     *
     * Requirements:
     *
     * - input must fit into 8 bits.
     *
     * _Available since v3.1._
     */
    function toInt8(int256 value) internal pure returns (int8) {
        require(value >= -2**7 && value < 2**7, "SafeCast: value doesn\'t fit in 8 bits");
        return int8(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);
    }
}

// Dependency file: @openzeppelin/contracts/utils/ReentrancyGuard.sol



// pragma solidity ^0.6.0;

/**
 * @dev Contract module that helps prevent reentrant calls to a function.
 *
 * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
 * available, which can be applied to functions to make sure there are no nested
 * (reentrant) calls to them.
 *
 * Note that because there is a single `nonReentrant` guard, functions marked as
 * `nonReentrant` may not call one another. This can be worked around by making
 * those functions `private`, and then adding `external` `nonReentrant` entry
 * points to them.
 *
 * TIP: If you would like to learn more about reentrancy and alternative ways
 * to protect against it, check out our blog post
 * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
 */
contract ReentrancyGuard {
    // Booleans are more expensive than uint256 or any type that takes up a full
    // word because each write operation emits an extra SLOAD to first read the
    // slot's contents, replace the bits taken up by the boolean, and then write
    // back. This is the compiler's defense against contract upgrades and
    // pointer aliasing, and it cannot be disabled.

    // The values being non-zero value makes deployment a bit more expensive,
    // but in exchange the refund on every call to nonReentrant will be lower in
    // amount. Since refunds are capped to a percentage of the total
    // transaction's gas, it is best to keep them low in cases like this one, to
    // increase the likelihood of the full refund coming into effect.
    uint256 private constant _NOT_ENTERED = 1;
    uint256 private constant _ENTERED = 2;

    uint256 private _status;

    constructor () internal {
        _status = _NOT_ENTERED;
    }

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

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

        _;

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


/*
    Copyright 2020 Set Labs Inc.
    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at
    http://www.apache.org/licenses/LICENSE-2.0
    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

*/

pragma solidity 0.6.10;
pragma experimental "ABIEncoderV2";

// import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
// import { ReentrancyGuard } from "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
// import { SafeCast } from "@openzeppelin/contracts/utils/SafeCast.sol";
// import { SafeMath } from "@openzeppelin/contracts/math/SafeMath.sol";

// import { IController } from "../../interfaces/IController.sol";
// import { IManagerIssuanceHook } from "../../interfaces/IManagerIssuanceHook.sol";
// import { Invoke } from "../lib/Invoke.sol";
// import { ISetToken } from "../../interfaces/ISetToken.sol";
// import { ModuleBase } from "../lib/ModuleBase.sol";
// import { Position } from "../lib/Position.sol";
// import { PreciseUnitMath } from "../../lib/PreciseUnitMath.sol";

/**
 * @title BasicIssuanceModule
 * @author Set Protocol
 *
 * Module that enables issuance and redemption functionality on a SetToken. This is a module that is
 * required to bring the totalSupply of a Set above 0.
 */
contract BasicIssuanceModule is ModuleBase, ReentrancyGuard {
    using Invoke for ISetToken;
    using Position for ISetToken.Position;
    using Position for ISetToken;
    using PreciseUnitMath for uint256;
    using SafeMath for uint256;
    using SafeCast for int256;

    /* ============ Events ============ */

    event SetTokenIssued(
        address indexed _setToken,
        address indexed _issuer,
        address indexed _to,
        address _hookContract,
        uint256 _quantity
    );
    event SetTokenRedeemed(
        address indexed _setToken,
        address indexed _redeemer,
        address indexed _to,
        uint256 _quantity
    );

    /* ============ State Variables ============ */

    // Mapping of SetToken to Issuance hook configurations
    mapping(ISetToken => IManagerIssuanceHook) public managerIssuanceHook;

    /* ============ Constructor ============ */

    /**
     * Set state controller state variable
     *
     * @param _controller             Address of controller contract
     */
    constructor(IController _controller) public ModuleBase(_controller) {}

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

    /**
     * Deposits the SetToken's position components into the SetToken and mints the SetToken of the given quantity
     * to the specified _to address. This function only handles Default Positions (positionState = 0).
     *
     * @param _setToken             Instance of the SetToken contract
     * @param _quantity             Quantity of the SetToken to mint
     * @param _to                   Address to mint SetToken to
     */
    function issue(
        ISetToken _setToken,
        uint256 _quantity,
        address _to
    ) 
        external
        nonReentrant
        onlyValidAndInitializedSet(_setToken)
    {
        require(_quantity > 0, "Issue quantity must be > 0");

        address hookContract = _callPreIssueHooks(_setToken, _quantity, msg.sender, _to);

        (
            address[] memory components,
            uint256[] memory componentQuantities
        ) = getRequiredComponentUnitsForIssue(_setToken, _quantity);

        // For each position, transfer the required underlying to the SetToken
        for (uint256 i = 0; i < components.length; i++) {
            // Transfer the component to the SetToken
            transferFrom(
                IERC20(components[i]),
                msg.sender,
                address(_setToken),
                componentQuantities[i]
            );
        }

        // Mint the SetToken
        _setToken.mint(_to, _quantity);

        emit SetTokenIssued(address(_setToken), msg.sender, _to, hookContract, _quantity);
    }

    /**
     * Redeems the SetToken's positions and sends the components of the given
     * quantity to the caller. This function only handles Default Positions (positionState = 0).
     *
     * @param _setToken             Instance of the SetToken contract
     * @param _quantity             Quantity of the SetToken to redeem
     * @param _to                   Address to send component assets to
     */
    function redeem(
        ISetToken _setToken,
        uint256 _quantity,
        address _to
    )
        external
        nonReentrant
        onlyValidAndInitializedSet(_setToken)
    {
        require(_quantity > 0, "Redeem quantity must be > 0");

        // Burn the SetToken - ERC20's internal burn already checks that the user has enough balance
        _setToken.burn(msg.sender, _quantity);

        // For each position, invoke the SetToken to transfer the tokens to the user
        address[] memory components = _setToken.getComponents();
        for (uint256 i = 0; i < components.length; i++) {
            address component = components[i];
            require(!_setToken.hasExternalPosition(component), "Only default positions are supported");

            uint256 unit = _setToken.getDefaultPositionRealUnit(component).toUint256();

            // Use preciseMul to round down to ensure overcollateration when small redeem quantities are provided
            uint256 componentQuantity = _quantity.preciseMul(unit);

            // Instruct the SetToken to transfer the component to the user
            _setToken.strictInvokeTransfer(
                component,
                _to,
                componentQuantity
            );
        }

        emit SetTokenRedeemed(address(_setToken), msg.sender, _to, _quantity);
    }

    /**
     * Initializes this module to the SetToken with issuance-related hooks. Only callable by the SetToken's manager.
     * Hook addresses are optional. Address(0) means that no hook will be called
     *
     * @param _setToken             Instance of the SetToken to issue
     * @param _preIssueHook         Instance of the Manager Contract with the Pre-Issuance Hook function
     */
    function initialize(
        ISetToken _setToken,
        IManagerIssuanceHook _preIssueHook
    )
        external
        onlySetManager(_setToken, msg.sender)
        onlyValidAndPendingSet(_setToken)
    {
        managerIssuanceHook[_setToken] = _preIssueHook;

        _setToken.initializeModule();
    }

    /**
     * Reverts as this module should not be removable after added. Users should always
     * have a way to redeem their Sets
     */
    function removeModule() external override {
        revert("The BasicIssuanceModule module cannot be removed");
    }

    /* ============ External Getter Functions ============ */

    /**
     * Retrieves the addresses and units required to mint a particular quantity of SetToken.
     *
     * @param _setToken             Instance of the SetToken to issue
     * @param _quantity             Quantity of SetToken to issue
     * @return address[]            List of component addresses
     * @return uint256[]            List of component units required to issue the quantity of SetTokens
     */
    function getRequiredComponentUnitsForIssue(
        ISetToken _setToken,
        uint256 _quantity
    )
        public
        view
        onlyValidAndInitializedSet(_setToken)
        returns (address[] memory, uint256[] memory)
    {
        address[] memory components = _setToken.getComponents();

        uint256[] memory notionalUnits = new uint256[](components.length);

        for (uint256 i = 0; i < components.length; i++) {
            require(!_setToken.hasExternalPosition(components[i]), "Only default positions are supported");

            notionalUnits[i] = _setToken.getDefaultPositionRealUnit(components[i]).toUint256().preciseMulCeil(_quantity);
        }

        return (components, notionalUnits);
    }

    /* ============ Internal Functions ============ */

    /**
     * If a pre-issue hook has been configured, call the external-protocol contract. Pre-issue hook logic
     * can contain arbitrary logic including validations, external function calls, etc.
     */
    function _callPreIssueHooks(
        ISetToken _setToken,
        uint256 _quantity,
        address _caller,
        address _to
    )
        internal
        returns(address)
    {
        IManagerIssuanceHook preIssueHook = managerIssuanceHook[_setToken];
        if (address(preIssueHook) != address(0)) {
            preIssueHook.invokePreIssueHook(_setToken, _quantity, _caller, _to);
            return address(preIssueHook);
        }

        return address(0);
    }
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"contract IController","name":"_controller","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_setToken","type":"address"},{"indexed":true,"internalType":"address","name":"_issuer","type":"address"},{"indexed":true,"internalType":"address","name":"_to","type":"address"},{"indexed":false,"internalType":"address","name":"_hookContract","type":"address"},{"indexed":false,"internalType":"uint256","name":"_quantity","type":"uint256"}],"name":"SetTokenIssued","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_setToken","type":"address"},{"indexed":true,"internalType":"address","name":"_redeemer","type":"address"},{"indexed":true,"internalType":"address","name":"_to","type":"address"},{"indexed":false,"internalType":"uint256","name":"_quantity","type":"uint256"}],"name":"SetTokenRedeemed","type":"event"},{"inputs":[],"name":"controller","outputs":[{"internalType":"contract IController","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract ISetToken","name":"_setToken","type":"address"},{"internalType":"uint256","name":"_quantity","type":"uint256"}],"name":"getRequiredComponentUnitsForIssue","outputs":[{"internalType":"address[]","name":"","type":"address[]"},{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract ISetToken","name":"_setToken","type":"address"},{"internalType":"contract IManagerIssuanceHook","name":"_preIssueHook","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract ISetToken","name":"_setToken","type":"address"},{"internalType":"uint256","name":"_quantity","type":"uint256"},{"internalType":"address","name":"_to","type":"address"}],"name":"issue","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract ISetToken","name":"","type":"address"}],"name":"managerIssuanceHook","outputs":[{"internalType":"contract IManagerIssuanceHook","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract ISetToken","name":"_setToken","type":"address"},{"internalType":"uint256","name":"_quantity","type":"uint256"},{"internalType":"address","name":"_to","type":"address"}],"name":"redeem","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"removeModule","outputs":[],"stateMutability":"nonpayable","type":"function"}]

Deployed Bytecode

0x608060405234801561001057600080fd5b506004361061007d5760003560e01c80637a4ffd031161005b5780637a4ffd03146100bd578063847ef08d146100e7578063dfe75335146100ef578063f77c47911461010f5761007d565b8063485cc955146100825780635c833bfd146100975780636d78f47a146100aa575b600080fd5b61009561009036600461149e565b610117565b005b6100956100a5366004611501565b61028a565b6100956100b8366004611501565b610551565b6100d06100cb3660046114d6565b6106ec565b6040516100de929190611638565b60405180910390f35b6100956108ab565b6101026100fd366004611482565b6108c3565b6040516100de91906115b7565b6101026108de565b813361012382826108ed565b6101485760405162461bcd60e51b815260040161013f906119e3565b60405180910390fd5b600054604051631d3af8fb60e21b815285916001600160a01b0316906374ebe3ec906101789084906004016115b7565b60206040518083038186803b15801561019057600080fd5b505afa1580156101a4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101c891906113d6565b6101e45760405162461bcd60e51b815260040161013f906119a0565b6101ed8161097d565b6102095760405162461bcd60e51b815260040161013f9061184e565b6001600160a01b0385811660008181526002602052604080822080546001600160a01b0319169489169490941790935582516307ff078f60e11b815292519192630ffe0f1e926004808301939282900301818387803b15801561026b57600080fd5b505af115801561027f573d6000803e3d6000fd5b505050505050505050565b600260015414156102ad5760405162461bcd60e51b815260040161013f90611a64565b6002600155826102bc816109fc565b6102d85760405162461bcd60e51b815260040161013f90611704565b600083116102f85760405162461bcd60e51b815260040161013f9061174c565b604051632770a7eb60e21b81526001600160a01b03851690639dc29fac9061032690339087906004016115cb565b600060405180830381600087803b15801561034057600080fd5b505af1158015610354573d6000803e3d6000fd5b505050506060846001600160a01b03166399d50d5d6040518163ffffffff1660e01b815260040160006040518083038186803b15801561039357600080fd5b505afa1580156103a7573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526103cf919081019061132b565b905060005b81518110156104f05760008282815181106103eb57fe5b6020026020010151905061041181886001600160a01b0316610ab090919063ffffffff16565b1561042e5760405162461bcd60e51b815260040161013f9061180a565b60006104b4886001600160a01b03166366cb8d2f846040518263ffffffff1660e01b815260040161045f91906115b7565b60206040518083038186803b15801561047757600080fd5b505afa15801561048b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104af9190611542565b610b3c565b905060006104c8888363ffffffff610b6216565b90506104e56001600160a01b038a1684898463ffffffff610b9316565b5050506001016103d4565b50826001600160a01b0316336001600160a01b0316866001600160a01b03167f05f8aaada00823525432114f0e904c6f7c0198a5b8f113ee635ff81aaf9566ad8760405161053e9190611a9b565b60405180910390a4505060018055505050565b600260015414156105745760405162461bcd60e51b815260040161013f90611a64565b600260015582610583816109fc565b61059f5760405162461bcd60e51b815260040161013f90611704565b600083116105bf5760405162461bcd60e51b815260040161013f90611885565b60006105cd85853386610cde565b90506060806105dc87876106ec565b909250905060005b82518110156106275761061f8382815181106105fc57fe5b6020026020010151338a85858151811061061257fe5b6020026020010151610d7c565b6001016105e4565b506040516340c10f1960e01b81526001600160a01b038816906340c10f19906106569088908a906004016115cb565b600060405180830381600087803b15801561067057600080fd5b505af1158015610684573d6000803e3d6000fd5b50505050846001600160a01b0316336001600160a01b0316886001600160a01b03167fc07f1e2fe31c4d90eae81f76d263d7995aac043a99d6ee6de9c0506047f541c2868a6040516106d79291906115cb565b60405180910390a45050600180555050505050565b606080836106f9816109fc565b6107155760405162461bcd60e51b815260040161013f90611704565b6060856001600160a01b03166399d50d5d6040518163ffffffff1660e01b815260040160006040518083038186803b15801561075057600080fd5b505afa158015610764573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261078c919081019061132b565b90506060815167ffffffffffffffff811180156107a857600080fd5b506040519080825280602002602001820160405280156107d2578160200160208202803683370190505b50905060005b825181101561089e576108108382815181106107f057fe5b6020026020010151896001600160a01b0316610ab090919063ffffffff16565b1561082d5760405162461bcd60e51b815260040161013f9061180a565b61087f876108738a6001600160a01b03166366cb8d2f87868151811061084f57fe5b60200260200101516040518263ffffffff1660e01b815260040161045f91906115b7565b9063ffffffff610d8816565b82828151811061088b57fe5b60209081029190910101526001016107d8565b5090969095509350505050565b60405162461bcd60e51b815260040161013f906117ba565b6002602052600090815260409020546001600160a01b031681565b6000546001600160a01b031681565b6000816001600160a01b0316836001600160a01b031663481c6a756040518163ffffffff1660e01b815260040160206040518083038186803b15801561093257600080fd5b505afa158015610946573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061096a919061130f565b6001600160a01b03161490505b92915050565b6040516353bae5f760e01b81526000906001600160a01b038316906353bae5f7906109ac9030906004016115b7565b60206040518083038186803b1580156109c457600080fd5b505afa1580156109d8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061097791906113d6565b60008054604051631d3af8fb60e21b81526001600160a01b03909116906374ebe3ec90610a2d9085906004016115b7565b60206040518083038186803b158015610a4557600080fd5b505afa158015610a59573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a7d91906113d6565b801561097757506040516335fc6c9f60e21b81526001600160a01b0383169063d7f1b27c906109ac9030906004016115b7565b600080836001600160a01b031663a7bdad03846040518263ffffffff1660e01b8152600401610adf91906115b7565b60006040518083038186803b158015610af757600080fd5b505afa158015610b0b573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610b33919081019061132b565b51119392505050565b600080821215610b5e5760405162461bcd60e51b815260040161013f906118bc565b5090565b6000610b8c670de0b6b3a7640000610b80858563ffffffff610ddf16565b9063ffffffff610e1916565b9392505050565b8015610cd8576040516370a0823160e01b81526000906001600160a01b038516906370a0823190610bc89088906004016115b7565b60206040518083038186803b158015610be057600080fd5b505afa158015610bf4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c189190611542565b9050610c2685858585610e5b565b6040516370a0823160e01b81526000906001600160a01b038616906370a0823190610c559089906004016115b7565b60206040518083038186803b158015610c6d57600080fd5b505afa158015610c81573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ca59190611542565b9050610cb7828463ffffffff610f2816565b8114610cd55760405162461bcd60e51b815260040161013f90611932565b50505b50505050565b6001600160a01b038085166000908152600260205260408120549091168015610d6e5760405163a045808360e01b81526001600160a01b0382169063a045808390610d339089908990899089906004016116c6565b600060405180830381600087803b158015610d4d57600080fd5b505af1158015610d61573d6000803e3d6000fd5b5050505080915050610d74565b60009150505b949350505050565b610cd884848484610f6a565b6000821580610d95575081155b15610da257506000610977565b610b8c6001610dd3670de0b6b3a7640000610b8083610dc7898963ffffffff610ddf16565b9063ffffffff610f2816565b9063ffffffff61108e16565b600082610dee57506000610977565b82820282848281610dfb57fe5b0414610b8c5760405162461bcd60e51b815260040161013f906118f1565b6000610b8c83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506110b3565b8015610cd85760608282604051602401610e769291906115cb565b60408051601f198184030181529181526020820180516001600160e01b031663a9059cbb60e01b179052516347b7819960e11b81529091506001600160a01b03861690638f6f033290610ed29087906000908690600401611608565b600060405180830381600087803b158015610eec57600080fd5b505af1158015610f00573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610cd591908101906113f6565b6000610b8c83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506110ea565b8015610cd8576040516370a0823160e01b81526000906001600160a01b038616906370a0823190610f9f9086906004016115b7565b60206040518083038186803b158015610fb757600080fd5b505afa158015610fcb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fef9190611542565b9050610ffd85858585611116565b6040516370a0823160e01b81526000906001600160a01b038716906370a082319061102c9087906004016115b7565b60206040518083038186803b15801561104457600080fd5b505afa158015611058573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061107c9190611542565b9050610cb7828463ffffffff61108e16565b600082820183811015610b8c5760405162461bcd60e51b815260040161013f90611783565b600081836110d45760405162461bcd60e51b815260040161013f91906116f1565b5060008385816110e057fe5b0495945050505050565b6000818484111561110e5760405162461bcd60e51b815260040161013f91906116f1565b505050900390565b610cd8846323b872dd60e01b858585604051602401611137939291906115e4565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915260606111be826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166111fd9092919063ffffffff16565b8051909150156111f857808060200190518101906111dc91906113d6565b6111f85760405162461bcd60e51b815260040161013f90611a1a565b505050565b6060610d7484846000856060611212856112cb565b61122e5760405162461bcd60e51b815260040161013f90611969565b60006060866001600160a01b0316858760405161124b919061159b565b60006040518083038185875af1925050503d8060008114611288576040519150601f19603f3d011682016040523d82523d6000602084013e61128d565b606091505b509150915081156112a1579150610d749050565b8051156112b15780518082602001fd5b8360405162461bcd60e51b815260040161013f91906116f1565b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470818114801590610d74575050151592915050565b805161097781611af7565b600060208284031215611320578081fd5b8151610b8c81611af7565b6000602080838503121561133d578182fd5b825167ffffffffffffffff80821115611354578384fd5b81850186601f820112611365578485fd5b8051925081831115611375578485fd5b8383029150611385848301611aa4565b8381528481019082860184840187018a101561139f578788fd5b8794505b858510156113c9576113b58a82611304565b8352600194909401939186019186016113a3565b5098975050505050505050565b6000602082840312156113e7578081fd5b81518015158114610b8c578182fd5b600060208284031215611407578081fd5b815167ffffffffffffffff8082111561141e578283fd5b81840185601f82011261142f578384fd5b805192508183111561143f578384fd5b611452601f8401601f1916602001611aa4565b9150828252856020848301011115611468578384fd5b611479836020840160208401611acb565b50949350505050565b600060208284031215611493578081fd5b8135610b8c81611af7565b600080604083850312156114b0578081fd5b82356114bb81611af7565b915060208301356114cb81611af7565b809150509250929050565b600080604083850312156114e8578182fd5b82356114f381611af7565b946020939093013593505050565b600080600060608486031215611515578081fd5b833561152081611af7565b925060208401359150604084013561153781611af7565b809150509250925092565b600060208284031215611553578081fd5b5051919050565b815260200190565b6001600160a01b03169052565b60008151808452611587816020860160208601611acb565b601f01601f19169290920160200192915050565b600082516115ad818460208701611acb565b9190910192915050565b6001600160a01b0391909116815260200190565b6001600160a01b03929092168252602082015260400190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b600060018060a01b03851682528360208301526060604083015261162f606083018461156f565b95945050505050565b604080825283519082018190526000906020906060840190828701845b8281101561167857611668848351611562565b9284019290840190600101611655565b5050508381038285015280855161168f8184611a9b565b91508387019250845b818110156116b9576116ab83855161155a565b938501939250600101611698565b5090979650505050505050565b6001600160a01b03948516815260208101939093529083166040830152909116606082015260800190565b600060208252610b8c602083018461156f565b60208082526028908201527f4d75737420626520612076616c696420616e6420696e697469616c697a65642060408201526729b2ba2a37b5b2b760c11b606082015260800190565b6020808252601b908201527f52656465656d207175616e74697479206d757374206265203e20300000000000604082015260600190565b6020808252601b908201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604082015260600190565b60208082526030908201527f54686520426173696349737375616e63654d6f64756c65206d6f64756c65206360408201526f185b9b9bdd081899481c995b5bdd995960821b606082015260800190565b60208082526024908201527f4f6e6c792064656661756c7420706f736974696f6e732061726520737570706f6040820152631c9d195960e21b606082015260800190565b6020808252601e908201527f4d7573742062652070656e64696e6720696e697469616c697a6174696f6e0000604082015260600190565b6020808252601a908201527f4973737565207175616e74697479206d757374206265203e2030000000000000604082015260600190565b6020808252818101527f53616665436173743a2076616c7565206d75737420626520706f736974697665604082015260600190565b60208082526021908201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6040820152607760f81b606082015260800190565b6020808252601d908201527f496e76616c696420706f7374207472616e736665722062616c616e6365000000604082015260600190565b6020808252601d908201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604082015260600190565b60208082526023908201527f4d75737420626520636f6e74726f6c6c65722d656e61626c656420536574546f60408201526235b2b760e91b606082015260800190565b6020808252601c908201527f4d7573742062652074686520536574546f6b656e206d616e6167657200000000604082015260600190565b6020808252602a908201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6040820152691bdd081cdd58d8d9595960b21b606082015260800190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b90815260200190565b60405181810167ffffffffffffffff81118282101715611ac357600080fd5b604052919050565b60005b83811015611ae6578181015183820152602001611ace565b83811115610cd85750506000910152565b6001600160a01b0381168114611b0c57600080fd5b5056fea26469706673582212205afb30bbc76cd694b9469cdace9272085847eeeee2e2ca3ef8c11c06490e3d8664736f6c634300060a0033

Deployed Bytecode Sourcemap

68664:7599:0:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;73643:321;;;;;;;;;:::i;:::-;;71853:1379;;;;;;;;;:::i;70329:1097::-;;;;;;;;;:::i;74738:749::-;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;74118:119;;;:::i;69473:69::-;;;;;;;;;:::i;:::-;;;;;;;;33462:29;;;:::i;73643:321::-;73787:9;73798:10;33630:32;33643:9;33654:7;33630:12;:32::i;:::-;33622:73;;;;-1:-1:-1;;;33622:73:0;;;;;;;;;;;;;;;;;34579:10:::1;::::0;:36:::1;::::0;-1:-1:-1;;;34579:36:0;;73842:9;;-1:-1:-1;;;;;34579:10:0::1;::::0;:16:::1;::::0;:36:::1;::::0;73842:9;;34579:36:::1;;;;;;;;;;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;34571:84;;;;-1:-1:-1::0;;;34571:84:0::1;;;;;;;;;34674:37;34701:9;34674:26;:37::i;:::-;34666:80;;;;-1:-1:-1::0;;;34666:80:0::1;;;;;;;;;-1:-1:-1::0;;;;;73869:30:0;;::::2;;::::0;;;:19:::2;:30;::::0;;;;;:46;;-1:-1:-1;;;;;;73869:46:0::2;::::0;;::::2;::::0;;;::::2;::::0;;;73928:28;;-1:-1:-1;;;73928:28:0;;;;73869:30;;73928:26:::2;::::0;:28:::2;::::0;;::::2;::::0;73869:30;73928:28;;;;;73869:30;;73928:28;::::2;;::::0;::::2;;;;::::0;::::2;;;;;;;;;;;;::::0;::::2;;;;;;;;;33706:1:::1;73643:321:::0;;;;:::o;71853:1379::-;66044:1;66650:7;;:19;;66642:63;;;;-1:-1:-1;;;66642:63:0;;;;;;;;;66044:1;66783:7;:18;72032:9;33799:35:::1;72032:9:::0;33799:24:::1;:35::i;:::-;33791:88;;;;-1:-1:-1::0;;;33791:88:0::1;;;;;;;;;72079:1:::2;72067:9;:13;72059:53;;;;-1:-1:-1::0;;;72059:53:0::2;;;;;;;;;72227:37;::::0;-1:-1:-1;;;72227:37:0;;-1:-1:-1;;;;;72227:14:0;::::2;::::0;::::2;::::0;:37:::2;::::0;72242:10:::2;::::0;72254:9;;72227:37:::2;;;;;;;;;;;;;;;;;;;;;;::::0;::::2;;;;;;;;;;;;::::0;::::2;;;;;;;;;72363:27;72393:9;-1:-1:-1::0;;;;;72393:23:0::2;;:25;;;;;;;;;;;;;;;;;;;;;;;;;;;::::0;::::2;;;;;;;;;;;;::::0;::::2;;;;;;;;;;;;;;;;;::::0;;::::2;-1:-1:-1::0;;72393:25:0::2;::::0;::::2;;::::0;::::2;::::0;;;::::2;::::0;::::2;;;72363:55:::0;-1:-1:-1;72434:9:0::2;72429:714;72453:10;:17;72449:1;:21;72429:714;;;72492:17;72512:10;72523:1;72512:13;;;;;;;;;;;;;;72492:33;;72549:40;72579:9;72549;-1:-1:-1::0;;;;;72549:29:0::2;;;:40;;;;:::i;:::-;72548:41;72540:90;;;;-1:-1:-1::0;;;72540:90:0::2;;;;;;;;;72647:12;72662:59;:9;-1:-1:-1::0;;;;;72662:36:0::2;;72699:9;72662:47;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;::::0;::::2;;;;;;;;;;;;::::0;::::2;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:57;:59::i;:::-;72647:74:::0;-1:-1:-1;72853:25:0::2;72881:26;:9:::0;72647:74;72881:26:::2;:20;:26;:::i;:::-;72853:54:::0;-1:-1:-1;73000:131:0::2;-1:-1:-1::0;;;;;73000:30:0;::::2;73049:9:::0;73077:3;72853:54;73000:131:::2;:30;:131;:::i;:::-;-1:-1:-1::0;;;72472:3:0::2;;72429:714;;;;73209:3;-1:-1:-1::0;;;;;73160:64:0::2;73197:10;-1:-1:-1::0;;;;;73160:64:0::2;73185:9;-1:-1:-1::0;;;;;73160:64:0::2;;73214:9;73160:64;;;;;;;;;;;;;;;-1:-1:-1::0;;66000:1:0;66962:22;;-1:-1:-1;;;71853:1379:0:o;70329:1097::-;66044:1;66650:7;;:19;;66642:63;;;;-1:-1:-1;;;66642:63:0;;;;;;;;;66044:1;66783:7;:18;70508:9;33799:35:::1;70508:9:::0;33799:24:::1;:35::i;:::-;33791:88;;;;-1:-1:-1::0;;;33791:88:0::1;;;;;;;;;70555:1:::2;70543:9;:13;70535:52;;;;-1:-1:-1::0;;;70535:52:0::2;;;;;;;;;70600:20;70623:57;70642:9;70653;70664:10;70676:3;70623:18;:57::i;:::-;70600:80;;70708:27;70750:36:::0;70800:55:::2;70834:9;70845;70800:33;:55::i;:::-;70693:162:::0;;-1:-1:-1;70693:162:0;-1:-1:-1;70953:9:0::2;70948:304;70972:10;:17;70968:1;:21;70948:304;;;71066:174;71104:10;71115:1;71104:13;;;;;;;;;;;;;;71137:10;71174:9;71203:19;71223:1;71203:22;;;;;;;;;;;;;;71066:12;:174::i;:::-;70991:3;;70948:304;;;-1:-1:-1::0;71294:30:0::2;::::0;-1:-1:-1;;;71294:30:0;;-1:-1:-1;;;;;71294:14:0;::::2;::::0;::::2;::::0;:30:::2;::::0;71309:3;;71314:9;;71294:30:::2;;;;;;;;;;;;;;;;;;;;;;::::0;::::2;;;;;;;;;;;;::::0;::::2;;;;;;;;;71389:3;-1:-1:-1::0;;;;;71342:76:0::2;71377:10;-1:-1:-1::0;;;;;71342:76:0::2;71365:9;-1:-1:-1::0;;;;;71342:76:0::2;;71394:12;71408:9;71342:76;;;;;;;;;;;;;;;;-1:-1:-1::0;;66000:1:0;66962:22;;-1:-1:-1;;;;;70329:1097:0:o;74738:749::-;74941:16;74959;74912:9;33799:35;33824:9;33799:24;:35::i;:::-;33791:88;;;;-1:-1:-1;;;33791:88:0;;;;;;;;;74993:27:::1;75023:9;-1:-1:-1::0;;;;;75023:23:0::1;;:25;;;;;;;;;;;;;;;;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;;;;;;::::0;;::::1;-1:-1:-1::0;;75023:25:0::1;::::0;::::1;;::::0;::::1;::::0;;;::::1;::::0;::::1;;;74993:55;;75061:30;75108:10;:17;75094:32;;;;;;;;::::0;::::1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;::::0;-1:-1:-1;75094:32:0::1;-1:-1:-1::0;75061:65:0;-1:-1:-1;75144:9:0::1;75139:294;75163:10;:17;75159:1;:21;75139:294;;;75211:44;75241:10;75252:1;75241:13;;;;;;;;;;;;;;75211:9;-1:-1:-1::0;;;;;75211:29:0::1;;;:44;;;;:::i;:::-;75210:45;75202:94;;;;-1:-1:-1::0;;;75202:94:0::1;;;;;;;;;75332:89;75411:9;75332:63;:9;-1:-1:-1::0;;;;;75332:36:0::1;;75369:10;75380:1;75369:13;;;;;;;;;;;;;;75332:51;;;;;;;;;;;;;;;;:63;:78:::0;:89:::1;:78;:89;:::i;:::-;75313:13;75327:1;75313:16;;;;;;;;;::::0;;::::1;::::0;;;;;:108;75182:3:::1;;75139:294;;;-1:-1:-1::0;75453:10:0;;;;-1:-1:-1;74738:749:0;-1:-1:-1;;;;74738:749:0:o;74118:119::-;74171:58;;-1:-1:-1;;;74171:58:0;;;;;;;;69473:69;;;;;;;;;;;;-1:-1:-1;;;;;69473:69:0;;:::o;33462:29::-;;;-1:-1:-1;;;;;33462:29:0;;:::o;36019:146::-;36102:4;36149:8;-1:-1:-1;;;;;36126:31:0;:9;-1:-1:-1;;;;;36126:17:0;;:19;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;36126:31:0;;36119:38;;36019:146;;;;;:::o;35780:151::-;35883:40;;-1:-1:-1;;;35883:40:0;;35859:4;;-1:-1:-1;;;;;35883:25:0;;;;;:40;;35917:4;;35883:40;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;36308:206;36385:4;36409:10;;:36;;-1:-1:-1;;;36409:36:0;;-1:-1:-1;;;;;36409:10:0;;;;:16;;:36;;36434:9;;36409:36;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:97;;;;-1:-1:-1;36462:44:0;;-1:-1:-1;;;36462:44:0;;-1:-1:-1;;;;;36462:29:0;;;;;:44;;36500:4;;36462:44;;;;24033:183;24125:4;24207:1;24149:9;-1:-1:-1;;;;;24149:36:0;;24186:10;24149:48;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;24149:48:0;;;;;;;;;;;;;;:55;:59;;24033:183;-1:-1:-1;;;24033:183:0:o;60925:171::-;60981:7;61018:1;61009:5;:10;;61001:55;;;;-1:-1:-1;;;61001:55:0;;;;;;;;;-1:-1:-1;61082:5:0;60925:171::o;19280:126::-;19345:7;19372:26;17741:8;19372;:1;19378;19372:8;:5;:8;:::i;:::-;:12;:26;:12;:26;:::i;:::-;19365:33;19280:126;-1:-1:-1;;;19280:126:0:o;48170:803::-;48350:13;;48346:620;;48473:44;;-1:-1:-1;;;48473:44:0;;48447:23;;-1:-1:-1;;;;;48473:24:0;;;;;:44;;48506:9;;48473:44;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;48447:70;;48534:56;48556:9;48567:6;48575:3;48580:9;48534:21;:56::i;:::-;48694:44;;-1:-1:-1;;;48694:44:0;;48673:18;;-1:-1:-1;;;;;48694:24:0;;;;;:44;;48727:9;;48694:44;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;48673:65;-1:-1:-1;48859:30:0;:15;48879:9;48859:30;:19;:30;:::i;:::-;48845:10;:44;48819:135;;;;-1:-1:-1;;;48819:135:0;;;;;;;;;48346:620;;;48170:803;;;;:::o;75767:493::-;-1:-1:-1;;;;;76004:30:0;;;75943:7;76004:30;;;:19;:30;;;;;;75943:7;;76004:30;76049:35;;76045:178;;76101:67;;-1:-1:-1;;;76101:67:0;;-1:-1:-1;;;;;76101:31:0;;;;;:67;;76133:9;;76144;;76155:7;;76164:3;;76101:67;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;76198:12;76183:28;;;;;76045:178;76250:1;76235:17;;;75767:493;;;;;;;:::o;35502:169::-;35606:57;35633:6;35641:5;35648:3;35653:9;35606:26;:57::i;19923:211::-;19992:7;20016:6;;;:16;;-1:-1:-1;20026:6:0;;20016:16;20012:57;;;-1:-1:-1;20056:1:0;20049:8;;20012:57;20086:40;20124:1;20086:33;17741:8;20086:15;20124:1;20086:8;:1;20092;20086:8;:5;:8;:::i;:::-;:12;:15;:12;:15;:::i;:33::-;:37;:40;:37;:40;:::i;54403:471::-;54461:7;54706:6;54702:47;;-1:-1:-1;54736:1:0;54729:8;;54702:47;54773:5;;;54777:1;54773;:5;:1;54797:5;;;;;:10;54789:56;;;;-1:-1:-1;;;54789:56:0;;;;;;;;55350:132;55408:7;55435:39;55439:1;55442;55435:39;;;;;;;;;;;;;;;;;:3;:39::i;47372:367::-;47546:13;;47542:190;;47576:21;47653:3;47658:9;47600:68;;;;;;;;;;;;;;-1:-1:-1;;47600:68:0;;;;;;;;;;;;;;-1:-1:-1;;;;;47600:68:0;-1:-1:-1;;;47600:68:0;;;47683:37;-1:-1:-1;;;47683:37:0;;47600:68;;-1:-1:-1;;;;;;47683:16:0;;;;;:37;;47700:6;;-1:-1:-1;;47600:68:0;;47683:37;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;47683:37:0;;;;;;;;;;;;;53513:136;53571:7;53598:43;53602:1;53605;53598:43;;;;;;;;;;;;;;;;;:3;:43::i;15683:768::-;15922:13;;15918:526;;15978:21;;-1:-1:-1;;;15978:21:0;;15952:23;;-1:-1:-1;;;;;15978:16:0;;;;;:21;;15995:3;;15978:21;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;15952:47;;16016:140;16061:6;16086:5;16110:3;16132:9;16016:26;:140::i;:::-;16194:21;;-1:-1:-1;;;16194:21:0;;16173:18;;-1:-1:-1;;;;;16194:16:0;;;;;:21;;16211:3;;16194:21;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;16173:42;-1:-1:-1;16337:30:0;:15;16357:9;16337:30;:19;:30;:::i;53049:181::-;53107:7;53139:5;;;53163:6;;;;53155:46;;;;-1:-1:-1;;;53155:46:0;;;;;;;;55978:278;56064:7;56099:12;56092:5;56084:28;;;;-1:-1:-1;;;56084:28:0;;;;;;;;;;;56123:9;56139:1;56135;:5;;;;;;;55978:278;-1:-1:-1;;;;;55978:278:0:o;53952:192::-;54038:7;54074:12;54066:6;;;;54058:29;;;;-1:-1:-1;;;54058:29:0;;;;;;;;;;-1:-1:-1;;;54110:5:0;;;53952:192::o;7291:205::-;7392:96;7412:5;7442:27;;;7471:4;7477:2;7481:5;7419:68;;;;;;;;;;;;;;;-1:-1:-1;;7419:68:0;;;;;;;;;;;;;;-1:-1:-1;;;;;7419:68:0;-1:-1:-1;;;;;;7419:68:0;;;;;;;;;;9835:23;9861:69;9889:4;9861:69;;;;;;;;;;;;;;;;;9869:5;-1:-1:-1;;;;;9861:27:0;;;:69;;;;;:::i;:::-;9945:17;;9835:95;;-1:-1:-1;9945:21:0;9941:224;;10087:10;10076:30;;;;;;;;;;;;;;10068:85;;;;-1:-1:-1;;;10068:85:0;;;;;;;;;9411:761;;;:::o;3972:196::-;4075:12;4107:53;4130:6;4138:4;4144:1;4147:12;5479;5512:18;5523:6;5512:10;:18::i;:::-;5504:60;;;;-1:-1:-1;;;5504:60:0;;;;;;;;;5638:12;5652:23;5679:6;-1:-1:-1;;;;;5679:11:0;5699:8;5710:4;5679:36;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;5637:78;;;;5730:7;5726:595;;;5761:10;-1:-1:-1;5754:17:0;;-1:-1:-1;5754:17:0;5726:595;5875:17;;:21;5871:439;;6138:10;6132:17;6199:15;6186:10;6182:2;6178:19;6171:44;6086:148;6281:12;6274:20;;-1:-1:-1;;;6274:20:0;;;;;;;;;854:619;914:4;1382:20;;1225:66;1422:23;;;;;;:42;;-1:-1:-1;;1449:15:0;;;1414:51;-1:-1:-1;;854:619:0:o;142:134:-1:-;220:13;;238:33;220:13;238:33;;2402:263;;2517:2;2505:9;2496:7;2492:23;2488:32;2485:2;;;-1:-1;;2523:12;2485:2;226:6;220:13;238:33;265:5;238:33;;2672:392;;2812:2;;2800:9;2791:7;2787:23;2783:32;2780:2;;;-1:-1;;2818:12;2780:2;2869:17;2863:24;2907:18;;2899:6;2896:30;2893:2;;;-1:-1;;2929:12;2893:2;3031:6;3020:9;3016:22;429:3;422:4;414:6;410:17;406:27;396:2;;-1:-1;;437:12;396:2;477:6;471:13;457:27;;2907:18;26765:6;26762:30;26759:2;;;-1:-1;;26795:12;26759:2;2812;26832:6;26828:17;;;499:80;2812:2;26828:17;26893:15;499:80;;;607:21;;;664:14;;;;639:17;;;744:27;;;;;741:36;-1:-1;738:2;;;-1:-1;;780:12;738:2;-1:-1;806:10;;800:217;825:6;822:1;819:13;800:217;;;905:48;949:3;937:10;905:48;;;893:61;;847:1;840:9;;;;;968:14;;;;996;;800:217;;;-1:-1;2949:99;2774:290;-1:-1;;;;;;;;2774:290;3071:257;;3183:2;3171:9;3162:7;3158:23;3154:32;3151:2;;;-1:-1;;3189:12;3151:2;1112:6;1106:13;31951:5;29378:13;29371:21;31929:5;31926:32;31916:2;;-1:-1;;31962:12;3335:360;;3459:2;3447:9;3438:7;3434:23;3430:32;3427:2;;;-1:-1;;3465:12;3427:2;3516:17;3510:24;3554:18;;3546:6;3543:30;3540:2;;;-1:-1;;3576:12;3540:2;3662:6;3651:9;3647:22;1279:3;1272:4;1264:6;1260:17;1256:27;1246:2;;-1:-1;;1287:12;1246:2;1327:6;1321:13;1307:27;;3554:18;27060:6;27057:30;27054:2;;;-1:-1;;27090:12;27054:2;1349:64;27163:9;27144:17;;-1:-1;;27140:33;3459:2;27221:15;1349:64;;;1340:73;;1433:6;1426:5;1419:21;1537:3;3459:2;1528:6;1461;1519:16;;1516:25;1513:2;;;-1:-1;;1544:12;1513:2;1564:39;1596:6;3459:2;1495:5;1491:16;3459:2;1461:6;1457:17;1564:39;;;-1:-1;3596:83;3421:274;-1:-1;;;;3421:274;3702:277;;3824:2;3812:9;3803:7;3799:23;3795:32;3792:2;;;-1:-1;;3830:12;3792:2;1910:6;1897:20;1922:51;1967:5;1922:51;;3986:460;;;4154:2;4142:9;4133:7;4129:23;4125:32;4122:2;;;-1:-1;;4160:12;4122:2;1910:6;1897:20;1922:51;1967:5;1922:51;;;4212:81;-1:-1;4330:2;4398:22;;1713:20;1738:62;1713:20;1738:62;;;4338:92;;;;4116:330;;;;;;4453:402;;;4592:2;4580:9;4571:7;4567:23;4563:32;4560:2;;;-1:-1;;4598:12;4560:2;1910:6;1897:20;1922:51;1967:5;1922:51;;;4650:81;4768:2;4807:22;;;;2191:20;;-1:-1;;;4554:301;4862:527;;;;5018:2;5006:9;4997:7;4993:23;4989:32;4986:2;;;-1:-1;;5024:12;4986:2;1910:6;1897:20;1922:51;1967:5;1922:51;;;5076:81;-1:-1;5194:2;5233:22;;2191:20;;-1:-1;5302:2;5341:22;;72:20;97:33;72:20;97:33;;;5310:63;;;;4980:409;;;;;;5396:261;;5510:2;5498:9;5489:7;5485:23;5481:32;5478:2;;;-1:-1;;5516:12;5478:2;-1:-1;2062:13;;5472:185;-1:-1;5472:185;6117:173;15295:37;;6279:4;6270:14;;6197:93;6447:103;-1:-1;;;;;29787:54;6508:37;;6502:48;8135:343;;8277:5;27672:12;28475:6;28470:3;28463:19;8370:52;8415:6;28512:4;28507:3;28503:14;28512:4;8396:5;8392:16;8370:52;;;27163:9;31709:14;-1:-1;;31705:28;8434:39;;;;28512:4;8434:39;;8225:253;-1:-1;;8225:253;15464:271;;8645:5;27672:12;8756:52;8801:6;8796:3;8789:4;8782:5;8778:16;8756:52;;;8820:16;;;;;15598:137;-1:-1;;15598:137;15742:222;-1:-1;;;;;29787:54;;;;6508:37;;15869:2;15854:18;;15840:124;15971:349;-1:-1;;;;;29787:54;;;;6377:58;;16306:2;16291:18;;15295:37;16134:2;16119:18;;16105:215;16327:444;-1:-1;;;;;29787:54;;;6508:37;;29787:54;;;;16674:2;16659:18;;6508:37;16757:2;16742:18;;15295:37;;;;16510:2;16495:18;;16481:290;16778:544;;2907:18;;29798:42;;;29294:5;29787:54;6515:3;6508:37;31085:24;17159:2;17148:9;17144:18;9460:58;16987:2;17196;17185:9;17181:18;17174:48;17236:76;16987:2;16976:9;16972:18;17298:6;17236:76;;;17228:84;16958:364;-1:-1;;;;;16958:364;17669:629;17924:2;17938:47;;;27672:12;;17909:18;;;28463:19;;;17669:629;;28512:4;;28503:14;;;;27368;;;17669:629;7116:260;7141:6;7138:1;7135:13;7116:260;;;6022:46;6064:3;7208:6;7202:13;6022:46;;;6088:14;;;;28203;;;;7163:1;7156:9;7116:260;;;7120:14;;;18155:9;18149:4;18145:20;28512:4;18129:9;18125:18;18118:48;18180:108;7630:5;27672:12;7649:86;7728:6;7723:3;7649:86;;;7642:93;;28512:4;7806:5;27368:14;7818:21;;-1:-1;7845:260;7870:6;7867:1;7864:13;7845:260;;;7958:63;8017:3;7937:6;7931:13;7958:63;;;28203:14;;;;7951:70;-1:-1;7163:1;7885:9;7845:260;;;-1:-1;18172:116;;17895:403;-1:-1;;;;;;;17895:403;18861:592;-1:-1;;;;;29787:54;;;8939:70;;19273:2;19258:18;;15295:37;;;;29787:54;;;19356:2;19341:18;;6508:37;29787:54;;;19439:2;19424:18;;6508:37;19090:3;19075:19;;19061:392;19460:310;;19607:2;19628:17;19621:47;19682:78;19607:2;19596:9;19592:18;19746:6;19682:78;;19777:416;19977:2;19991:47;;;10109:2;19962:18;;;28463:19;10145:34;28503:14;;;10125:55;-1:-1;;;10200:12;;;10193:32;10244:12;;;19948:245;20200:416;20400:2;20414:47;;;10495:2;20385:18;;;28463:19;10531:29;28503:14;;;10511:50;10580:12;;;20371:245;20623:416;20823:2;20837:47;;;10831:2;20808:18;;;28463:19;10867:29;28503:14;;;10847:50;10916:12;;;20794:245;21046:416;21246:2;21260:47;;;11167:2;21231:18;;;28463:19;11203:34;28503:14;;;11183:55;-1:-1;;;11258:12;;;11251:40;11310:12;;;21217:245;21469:416;21669:2;21683:47;;;11561:2;21654:18;;;28463:19;11597:34;28503:14;;;11577:55;-1:-1;;;11652:12;;;11645:28;11692:12;;;21640:245;21892:416;22092:2;22106:47;;;11943:2;22077:18;;;28463:19;11979:32;28503:14;;;11959:53;12031:12;;;22063:245;22315:416;22515:2;22529:47;;;12282:2;22500:18;;;28463:19;12318:28;28503:14;;;12298:49;12366:12;;;22486:245;22738:416;22938:2;22952:47;;;22923:18;;;28463:19;12653:34;28503:14;;;12633:55;12707:12;;;22909:245;23161:416;23361:2;23375:47;;;12958:2;23346:18;;;28463:19;12994:34;28503:14;;;12974:55;-1:-1;;;13049:12;;;13042:25;13086:12;;;23332:245;23584:416;23784:2;23798:47;;;13337:2;23769:18;;;28463:19;13373:31;28503:14;;;13353:52;13424:12;;;23755:245;24007:416;24207:2;24221:47;;;13675:2;24192:18;;;28463:19;13711:31;28503:14;;;13691:52;13762:12;;;24178:245;24430:416;24630:2;24644:47;;;14013:2;24615:18;;;28463:19;14049:34;28503:14;;;14029:55;-1:-1;;;14104:12;;;14097:27;14143:12;;;24601:245;24853:416;25053:2;25067:47;;;14394:2;25038:18;;;28463:19;14430:30;28503:14;;;14410:51;14480:12;;;25024:245;25276:416;25476:2;25490:47;;;14731:2;25461:18;;;28463:19;14767:34;28503:14;;;14747:55;-1:-1;;;14822:12;;;14815:34;14868:12;;;25447:245;25699:416;25899:2;25913:47;;;15119:2;25884:18;;;28463:19;15155:33;28503:14;;;15135:54;15208:12;;;25870:245;26122:222;15295:37;;;26249:2;26234:18;;26220:124;26351:256;26413:2;26407:9;26439:17;;;26514:18;26499:34;;26535:22;;;26496:62;26493:2;;;26571:1;;26561:12;26493:2;26413;26580:22;26391:216;;-1:-1;26391:216;31365:268;31430:1;31437:101;31451:6;31448:1;31445:13;31437:101;;;31518:11;;;31512:18;31499:11;;;31492:39;31473:2;31466:10;31437:101;;;31553:6;31550:1;31547:13;31544:2;;;-1:-1;;31430:1;31600:16;;31593:27;31414:219;31746:117;-1:-1;;;;;29787:54;;31805:35;;31795:2;;31854:1;;31844:12;31795:2;31789:74;

Swarm Source

ipfs://5afb30bbc76cd694b9469cdace9272085847eeeee2e2ca3ef8c11c06490e3d86

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading
[ Download: CSV Export  ]

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