Token dfx-gyen-usdc-v2

 

Overview ERC20

Price
$0.00 @ 0.000000 ETH
Fully Diluted Market Cap
Total Supply:
24.913095 dfx-gyen-v2

Holders:
4 addresses
Contract:
0x3c3badfbf97ec7caebff761694dd642f2c8b11e80x3c3BAdFBF97EC7CaEBFf761694DD642F2C8B11E8

Decimals:
18

Social Profiles:
Not Available, Update ?

Balance
24.883095651641884054 dfx-gyen-v2

Value
$0.00
0xc63c6bfe1e7efccfadcb2eb4a0fd3b1b0e659e55
Loading
[ Download CSV Export  ] 
Loading
[ Download CSV Export  ] 
Loading

Click here to update the token ICO / general information
# Exchange Pair Price  24H Volume % Volume
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.

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

Contract Name:
Curve

Compiler Version
v0.8.17+commit.8df45f5f

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion, MIT license

Contract Source Code (Solidity)

/**
 *Submitted for verification at Arbiscan.io on 2023-04-27
*/

// SPDX-License-Identifier: MIT

// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.

pragma solidity ^0.8.13;
pragma experimental ABIEncoderV2;

interface IFlashCallback {
    function flashCallback(
        uint256 fee0,
        uint256 fee1,
        bytes calldata data
    ) external;
}

// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol)

// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @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);

    /**
     * @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 `to`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address to, 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 `from` to `to` 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 from, address to, uint256 amount) external returns (bool);
}

// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Permit.sol)

/**
 * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
 * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
 *
 * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
 * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
 * need to send a transaction, and thus is not required to hold Ether at all.
 */
interface IERC20Permit {
    /**
     * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
     * given ``owner``'s signed approval.
     *
     * IMPORTANT: The same issues {IERC20-approve} has related to transaction
     * ordering also apply here.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `deadline` must be a timestamp in the future.
     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
     * over the EIP712-formatted function arguments.
     * - the signature must use ``owner``'s current nonce (see {nonces}).
     *
     * For more information on the signature format, see the
     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
     * section].
     */
    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;

    /**
     * @dev Returns the current nonce for `owner`. This value must be
     * included whenever a signature is generated for {permit}.
     *
     * Every successful call to {permit} increases ``owner``'s nonce by one. This
     * prevents a signature from being used multiple times.
     */
    function nonces(address owner) external view returns (uint256);

    /**
     * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
     */
    // solhint-disable-next-line func-name-mixedcase
    function DOMAIN_SEPARATOR() external view returns (bytes32);
}

// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)

/**
 * @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
     *
     * Furthermore, `isContract` will also return true if the target contract within
     * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
     * which only has an effect at the end of a transaction.
     * ====
     *
     * [IMPORTANT]
     * ====
     * You shouldn't rely on `isContract` to protect against flash loan attacks!
     *
     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
     * constructor.
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize/address.code.length, which returns 0
        // for contracts in construction, since the code is only stored at the end
        // of the constructor execution.

        return account.code.length > 0;
    }

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

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

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

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

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

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

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
     * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
     *
     * _Available since v4.8._
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        if (success) {
            if (returndata.length == 0) {
                // only check isContract if the call was successful and the return data is empty
                // otherwise we already know that it was a contract
                require(isContract(target), "Address: call to non-contract");
            }
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason or using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    function _revert(bytes memory returndata, string memory errorMessage) private pure {
        // 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
            /// @solidity memory-safe-assembly
            assembly {
                let returndata_size := mload(returndata)
                revert(add(32, returndata), returndata_size)
            }
        } else {
            revert(errorMessage);
        }
    }
}

/**
 * @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 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'
        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) + value;
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

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

    function safePermit(
        IERC20Permit token,
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal {
        uint256 nonceBefore = token.nonces(owner);
        token.permit(owner, spender, value, deadline, v, r, s);
        uint256 nonceAfter = token.nonces(owner);
        require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
    }

    /**
     * @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
            require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
        }
    }
}

/*
 * ABDK Math 64.64 Smart Contract Library.  Copyright © 2019 by ABDK Consulting.
 * Author: Mikhail Vladimirov <[email protected]>
 */

/**
 * Smart contract library of mathematical functions operating with signed
 * 64.64-bit fixed point numbers.  Signed 64.64-bit fixed point number is
 * basically a simple fraction whose numerator is signed 128-bit integer and
 * denominator is 2^64.  As long as denominator is always the same, there is no
 * need to store it, thus in Solidity signed 64.64-bit fixed point numbers are
 * represented by int128 type holding only the numerator.
 */
library ABDKMath64x64 {
  /*
   * Minimum value signed 64.64-bit fixed point number may have. 
   */
  int128 private constant MIN_64x64 = -0x80000000000000000000000000000000;

  /*
   * Maximum value signed 64.64-bit fixed point number may have. 
   */
  int128 private constant MAX_64x64 = 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF;

  /**
   * Convert signed 256-bit integer number into signed 64.64-bit fixed point
   * number.  Revert on overflow.
   *
   * @param x signed 256-bit integer number
   * @return signed 64.64-bit fixed point number
   */
  function fromInt (int256 x) internal pure returns (int128) {
    unchecked {
      require (x >= -0x8000000000000000 && x <= 0x7FFFFFFFFFFFFFFF);
      return int128 (x << 64);
    }
  }

  /**
   * Convert signed 64.64 fixed point number into signed 64-bit integer number
   * rounding down.
   *
   * @param x signed 64.64-bit fixed point number
   * @return signed 64-bit integer number
   */
  function toInt (int128 x) internal pure returns (int64) {
    unchecked {
      return int64 (x >> 64);
    }
  }

  /**
   * Convert unsigned 256-bit integer number into signed 64.64-bit fixed point
   * number.  Revert on overflow.
   *
   * @param x unsigned 256-bit integer number
   * @return signed 64.64-bit fixed point number
   */
  function fromUInt (uint256 x) internal pure returns (int128) {
    unchecked {
      require (x <= 0x7FFFFFFFFFFFFFFF);
      return int128 (int256 (x << 64));
    }
  }

  /**
   * Convert signed 64.64 fixed point number into unsigned 64-bit integer
   * number rounding down.  Revert on underflow.
   *
   * @param x signed 64.64-bit fixed point number
   * @return unsigned 64-bit integer number
   */
  function toUInt (int128 x) internal pure returns (uint64) {
    unchecked {
      require (x >= 0);
      return uint64 (uint128 (x >> 64));
    }
  }

  /**
   * Convert signed 128.128 fixed point number into signed 64.64-bit fixed point
   * number rounding down.  Revert on overflow.
   *
   * @param x signed 128.128-bin fixed point number
   * @return signed 64.64-bit fixed point number
   */
  function from128x128 (int256 x) internal pure returns (int128) {
    unchecked {
      int256 result = x >> 64;
      require (result >= MIN_64x64 && result <= MAX_64x64);
      return int128 (result);
    }
  }

  /**
   * Convert signed 64.64 fixed point number into signed 128.128 fixed point
   * number.
   *
   * @param x signed 64.64-bit fixed point number
   * @return signed 128.128 fixed point number
   */
  function to128x128 (int128 x) internal pure returns (int256) {
    unchecked {
      return int256 (x) << 64;
    }
  }

  /**
   * Calculate x + y.  Revert on overflow.
   *
   * @param x signed 64.64-bit fixed point number
   * @param y signed 64.64-bit fixed point number
   * @return signed 64.64-bit fixed point number
   */
  function add (int128 x, int128 y) internal pure returns (int128) {
    unchecked {
      int256 result = int256(x) + y;
      require (result >= MIN_64x64 && result <= MAX_64x64);
      return int128 (result);
    }
  }

  /**
   * Calculate x - y.  Revert on overflow.
   *
   * @param x signed 64.64-bit fixed point number
   * @param y signed 64.64-bit fixed point number
   * @return signed 64.64-bit fixed point number
   */
  function sub (int128 x, int128 y) internal pure returns (int128) {
    unchecked {
      int256 result = int256(x) - y;
      require (result >= MIN_64x64 && result <= MAX_64x64);
      return int128 (result);
    }
  }

  /**
   * Calculate x * y rounding down.  Revert on overflow.
   *
   * @param x signed 64.64-bit fixed point number
   * @param y signed 64.64-bit fixed point number
   * @return signed 64.64-bit fixed point number
   */
  function mul (int128 x, int128 y) internal pure returns (int128) {
    unchecked {
      int256 result = int256(x) * y >> 64;
      require (result >= MIN_64x64 && result <= MAX_64x64);
      return int128 (result);
    }
  }

  /**
   * Calculate x * y rounding towards zero, where x is signed 64.64 fixed point
   * number and y is signed 256-bit integer number.  Revert on overflow.
   *
   * @param x signed 64.64 fixed point number
   * @param y signed 256-bit integer number
   * @return signed 256-bit integer number
   */
  function muli (int128 x, int256 y) internal pure returns (int256) {
    unchecked {
      if (x == MIN_64x64) {
        require (y >= -0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF &&
          y <= 0x1000000000000000000000000000000000000000000000000);
        return -y << 63;
      } else {
        bool negativeResult = false;
        if (x < 0) {
          x = -x;
          negativeResult = true;
        }
        if (y < 0) {
          y = -y; // We rely on overflow behavior here
          negativeResult = !negativeResult;
        }
        uint256 absoluteResult = mulu (x, uint256 (y));
        if (negativeResult) {
          require (absoluteResult <=
            0x8000000000000000000000000000000000000000000000000000000000000000);
          return -int256 (absoluteResult); // We rely on overflow behavior here
        } else {
          require (absoluteResult <=
            0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);
          return int256 (absoluteResult);
        }
      }
    }
  }

  /**
   * Calculate x * y rounding down, where x is signed 64.64 fixed point number
   * and y is unsigned 256-bit integer number.  Revert on overflow.
   *
   * @param x signed 64.64 fixed point number
   * @param y unsigned 256-bit integer number
   * @return unsigned 256-bit integer number
   */
  function mulu (int128 x, uint256 y) internal pure returns (uint256) {
    unchecked {
      if (y == 0) return 0;

      require (x >= 0);

      uint256 lo = (uint256 (int256 (x)) * (y & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)) >> 64;
      uint256 hi = uint256 (int256 (x)) * (y >> 128);

      require (hi <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);
      hi <<= 64;

      require (hi <=
        0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF - lo);
      return hi + lo;
    }
  }

  /**
   * Calculate x / y rounding towards zero.  Revert on overflow or when y is
   * zero.
   *
   * @param x signed 64.64-bit fixed point number
   * @param y signed 64.64-bit fixed point number
   * @return signed 64.64-bit fixed point number
   */
  function div (int128 x, int128 y) internal pure returns (int128) {
    unchecked {
      require (y != 0);
      int256 result = (int256 (x) << 64) / y;
      require (result >= MIN_64x64 && result <= MAX_64x64);
      return int128 (result);
    }
  }

  /**
   * Calculate x / y rounding towards zero, where x and y are signed 256-bit
   * integer numbers.  Revert on overflow or when y is zero.
   *
   * @param x signed 256-bit integer number
   * @param y signed 256-bit integer number
   * @return signed 64.64-bit fixed point number
   */
  function divi (int256 x, int256 y) internal pure returns (int128) {
    unchecked {
      require (y != 0);

      bool negativeResult = false;
      if (x < 0) {
        x = -x; // We rely on overflow behavior here
        negativeResult = true;
      }
      if (y < 0) {
        y = -y; // We rely on overflow behavior here
        negativeResult = !negativeResult;
      }
      uint128 absoluteResult = divuu (uint256 (x), uint256 (y));
      if (negativeResult) {
        require (absoluteResult <= 0x80000000000000000000000000000000);
        return -int128 (absoluteResult); // We rely on overflow behavior here
      } else {
        require (absoluteResult <= 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);
        return int128 (absoluteResult); // We rely on overflow behavior here
      }
    }
  }

  /**
   * Calculate x / y rounding towards zero, where x and y are unsigned 256-bit
   * integer numbers.  Revert on overflow or when y is zero.
   *
   * @param x unsigned 256-bit integer number
   * @param y unsigned 256-bit integer number
   * @return signed 64.64-bit fixed point number
   */
  function divu (uint256 x, uint256 y) internal pure returns (int128) {
    unchecked {
      require (y != 0);
      uint128 result = divuu (x, y);
      require (result <= uint128 (MAX_64x64));
      return int128 (result);
    }
  }

  /**
   * Calculate -x.  Revert on overflow.
   *
   * @param x signed 64.64-bit fixed point number
   * @return signed 64.64-bit fixed point number
   */
  function neg (int128 x) internal pure returns (int128) {
    unchecked {
      require (x != MIN_64x64);
      return -x;
    }
  }

  /**
   * Calculate |x|.  Revert on overflow.
   *
   * @param x signed 64.64-bit fixed point number
   * @return signed 64.64-bit fixed point number
   */
  function abs (int128 x) internal pure returns (int128) {
    unchecked {
      require (x != MIN_64x64);
      return x < 0 ? -x : x;
    }
  }

  /**
   * Calculate 1 / x rounding towards zero.  Revert on overflow or when x is
   * zero.
   *
   * @param x signed 64.64-bit fixed point number
   * @return signed 64.64-bit fixed point number
   */
  function inv (int128 x) internal pure returns (int128) {
    unchecked {
      require (x != 0);
      int256 result = int256 (0x100000000000000000000000000000000) / x;
      require (result >= MIN_64x64 && result <= MAX_64x64);
      return int128 (result);
    }
  }

  /**
   * Calculate arithmetics average of x and y, i.e. (x + y) / 2 rounding down.
   *
   * @param x signed 64.64-bit fixed point number
   * @param y signed 64.64-bit fixed point number
   * @return signed 64.64-bit fixed point number
   */
  function avg (int128 x, int128 y) internal pure returns (int128) {
    unchecked {
      return int128 ((int256 (x) + int256 (y)) >> 1);
    }
  }

  /**
   * Calculate geometric average of x and y, i.e. sqrt (x * y) rounding down.
   * Revert on overflow or in case x * y is negative.
   *
   * @param x signed 64.64-bit fixed point number
   * @param y signed 64.64-bit fixed point number
   * @return signed 64.64-bit fixed point number
   */
  function gavg (int128 x, int128 y) internal pure returns (int128) {
    unchecked {
      int256 m = int256 (x) * int256 (y);
      require (m >= 0);
      require (m <
          0x4000000000000000000000000000000000000000000000000000000000000000);
      return int128 (sqrtu (uint256 (m)));
    }
  }

  /**
   * Calculate x^y assuming 0^0 is 1, where x is signed 64.64 fixed point number
   * and y is unsigned 256-bit integer number.  Revert on overflow.
   *
   * @param x signed 64.64-bit fixed point number
   * @param y uint256 value
   * @return signed 64.64-bit fixed point number
   */
  function pow (int128 x, uint256 y) internal pure returns (int128) {
    unchecked {
      bool negative = x < 0 && y & 1 == 1;

      uint256 absX = uint128 (x < 0 ? -x : x);
      uint256 absResult;
      absResult = 0x100000000000000000000000000000000;

      if (absX <= 0x10000000000000000) {
        absX <<= 63;
        while (y != 0) {
          if (y & 0x1 != 0) {
            absResult = absResult * absX >> 127;
          }
          absX = absX * absX >> 127;

          if (y & 0x2 != 0) {
            absResult = absResult * absX >> 127;
          }
          absX = absX * absX >> 127;

          if (y & 0x4 != 0) {
            absResult = absResult * absX >> 127;
          }
          absX = absX * absX >> 127;

          if (y & 0x8 != 0) {
            absResult = absResult * absX >> 127;
          }
          absX = absX * absX >> 127;

          y >>= 4;
        }

        absResult >>= 64;
      } else {
        uint256 absXShift = 63;
        if (absX < 0x1000000000000000000000000) { absX <<= 32; absXShift -= 32; }
        if (absX < 0x10000000000000000000000000000) { absX <<= 16; absXShift -= 16; }
        if (absX < 0x1000000000000000000000000000000) { absX <<= 8; absXShift -= 8; }
        if (absX < 0x10000000000000000000000000000000) { absX <<= 4; absXShift -= 4; }
        if (absX < 0x40000000000000000000000000000000) { absX <<= 2; absXShift -= 2; }
        if (absX < 0x80000000000000000000000000000000) { absX <<= 1; absXShift -= 1; }

        uint256 resultShift = 0;
        while (y != 0) {
          require (absXShift < 64);

          if (y & 0x1 != 0) {
            absResult = absResult * absX >> 127;
            resultShift += absXShift;
            if (absResult > 0x100000000000000000000000000000000) {
              absResult >>= 1;
              resultShift += 1;
            }
          }
          absX = absX * absX >> 127;
          absXShift <<= 1;
          if (absX >= 0x100000000000000000000000000000000) {
              absX >>= 1;
              absXShift += 1;
          }

          y >>= 1;
        }

        require (resultShift < 64);
        absResult >>= 64 - resultShift;
      }
      int256 result = negative ? -int256 (absResult) : int256 (absResult);
      require (result >= MIN_64x64 && result <= MAX_64x64);
      return int128 (result);
    }
  }

  /**
   * Calculate sqrt (x) rounding down.  Revert if x < 0.
   *
   * @param x signed 64.64-bit fixed point number
   * @return signed 64.64-bit fixed point number
   */
  function sqrt (int128 x) internal pure returns (int128) {
    unchecked {
      require (x >= 0);
      return int128 (sqrtu (uint256 (int256 (x)) << 64));
    }
  }

  /**
   * Calculate binary logarithm of x.  Revert if x <= 0.
   *
   * @param x signed 64.64-bit fixed point number
   * @return signed 64.64-bit fixed point number
   */
  function log_2 (int128 x) internal pure returns (int128) {
    unchecked {
      require (x > 0);

      int256 msb = 0;
      int256 xc = x;
      if (xc >= 0x10000000000000000) { xc >>= 64; msb += 64; }
      if (xc >= 0x100000000) { xc >>= 32; msb += 32; }
      if (xc >= 0x10000) { xc >>= 16; msb += 16; }
      if (xc >= 0x100) { xc >>= 8; msb += 8; }
      if (xc >= 0x10) { xc >>= 4; msb += 4; }
      if (xc >= 0x4) { xc >>= 2; msb += 2; }
      if (xc >= 0x2) msb += 1;  // No need to shift xc anymore

      int256 result = msb - 64 << 64;
      uint256 ux = uint256 (int256 (x)) << uint256 (127 - msb);
      for (int256 bit = 0x8000000000000000; bit > 0; bit >>= 1) {
        ux *= ux;
        uint256 b = ux >> 255;
        ux >>= 127 + b;
        result += bit * int256 (b);
      }

      return int128 (result);
    }
  }

  /**
   * Calculate natural logarithm of x.  Revert if x <= 0.
   *
   * @param x signed 64.64-bit fixed point number
   * @return signed 64.64-bit fixed point number
   */
  function ln (int128 x) internal pure returns (int128) {
    unchecked {
      require (x > 0);

      return int128 (int256 (
          uint256 (int256 (log_2 (x))) * 0xB17217F7D1CF79ABC9E3B39803F2F6AF >> 128));
    }
  }

  /**
   * Calculate binary exponent of x.  Revert on overflow.
   *
   * @param x signed 64.64-bit fixed point number
   * @return signed 64.64-bit fixed point number
   */
  function exp_2 (int128 x) internal pure returns (int128) {
    unchecked {
      require (x < 0x400000000000000000); // Overflow

      if (x < -0x400000000000000000) return 0; // Underflow

      uint256 result = 0x80000000000000000000000000000000;

      if (x & 0x8000000000000000 > 0)
        result = result * 0x16A09E667F3BCC908B2FB1366EA957D3E >> 128;
      if (x & 0x4000000000000000 > 0)
        result = result * 0x1306FE0A31B7152DE8D5A46305C85EDEC >> 128;
      if (x & 0x2000000000000000 > 0)
        result = result * 0x1172B83C7D517ADCDF7C8C50EB14A791F >> 128;
      if (x & 0x1000000000000000 > 0)
        result = result * 0x10B5586CF9890F6298B92B71842A98363 >> 128;
      if (x & 0x800000000000000 > 0)
        result = result * 0x1059B0D31585743AE7C548EB68CA417FD >> 128;
      if (x & 0x400000000000000 > 0)
        result = result * 0x102C9A3E778060EE6F7CACA4F7A29BDE8 >> 128;
      if (x & 0x200000000000000 > 0)
        result = result * 0x10163DA9FB33356D84A66AE336DCDFA3F >> 128;
      if (x & 0x100000000000000 > 0)
        result = result * 0x100B1AFA5ABCBED6129AB13EC11DC9543 >> 128;
      if (x & 0x80000000000000 > 0)
        result = result * 0x10058C86DA1C09EA1FF19D294CF2F679B >> 128;
      if (x & 0x40000000000000 > 0)
        result = result * 0x1002C605E2E8CEC506D21BFC89A23A00F >> 128;
      if (x & 0x20000000000000 > 0)
        result = result * 0x100162F3904051FA128BCA9C55C31E5DF >> 128;
      if (x & 0x10000000000000 > 0)
        result = result * 0x1000B175EFFDC76BA38E31671CA939725 >> 128;
      if (x & 0x8000000000000 > 0)
        result = result * 0x100058BA01FB9F96D6CACD4B180917C3D >> 128;
      if (x & 0x4000000000000 > 0)
        result = result * 0x10002C5CC37DA9491D0985C348C68E7B3 >> 128;
      if (x & 0x2000000000000 > 0)
        result = result * 0x1000162E525EE054754457D5995292026 >> 128;
      if (x & 0x1000000000000 > 0)
        result = result * 0x10000B17255775C040618BF4A4ADE83FC >> 128;
      if (x & 0x800000000000 > 0)
        result = result * 0x1000058B91B5BC9AE2EED81E9B7D4CFAB >> 128;
      if (x & 0x400000000000 > 0)
        result = result * 0x100002C5C89D5EC6CA4D7C8ACC017B7C9 >> 128;
      if (x & 0x200000000000 > 0)
        result = result * 0x10000162E43F4F831060E02D839A9D16D >> 128;
      if (x & 0x100000000000 > 0)
        result = result * 0x100000B1721BCFC99D9F890EA06911763 >> 128;
      if (x & 0x80000000000 > 0)
        result = result * 0x10000058B90CF1E6D97F9CA14DBCC1628 >> 128;
      if (x & 0x40000000000 > 0)
        result = result * 0x1000002C5C863B73F016468F6BAC5CA2B >> 128;
      if (x & 0x20000000000 > 0)
        result = result * 0x100000162E430E5A18F6119E3C02282A5 >> 128;
      if (x & 0x10000000000 > 0)
        result = result * 0x1000000B1721835514B86E6D96EFD1BFE >> 128;
      if (x & 0x8000000000 > 0)
        result = result * 0x100000058B90C0B48C6BE5DF846C5B2EF >> 128;
      if (x & 0x4000000000 > 0)
        result = result * 0x10000002C5C8601CC6B9E94213C72737A >> 128;
      if (x & 0x2000000000 > 0)
        result = result * 0x1000000162E42FFF037DF38AA2B219F06 >> 128;
      if (x & 0x1000000000 > 0)
        result = result * 0x10000000B17217FBA9C739AA5819F44F9 >> 128;
      if (x & 0x800000000 > 0)
        result = result * 0x1000000058B90BFCDEE5ACD3C1CEDC823 >> 128;
      if (x & 0x400000000 > 0)
        result = result * 0x100000002C5C85FE31F35A6A30DA1BE50 >> 128;
      if (x & 0x200000000 > 0)
        result = result * 0x10000000162E42FF0999CE3541B9FFFCF >> 128;
      if (x & 0x100000000 > 0)
        result = result * 0x100000000B17217F80F4EF5AADDA45554 >> 128;
      if (x & 0x80000000 > 0)
        result = result * 0x10000000058B90BFBF8479BD5A81B51AD >> 128;
      if (x & 0x40000000 > 0)
        result = result * 0x1000000002C5C85FDF84BD62AE30A74CC >> 128;
      if (x & 0x20000000 > 0)
        result = result * 0x100000000162E42FEFB2FED257559BDAA >> 128;
      if (x & 0x10000000 > 0)
        result = result * 0x1000000000B17217F7D5A7716BBA4A9AE >> 128;
      if (x & 0x8000000 > 0)
        result = result * 0x100000000058B90BFBE9DDBAC5E109CCE >> 128;
      if (x & 0x4000000 > 0)
        result = result * 0x10000000002C5C85FDF4B15DE6F17EB0D >> 128;
      if (x & 0x2000000 > 0)
        result = result * 0x1000000000162E42FEFA494F1478FDE05 >> 128;
      if (x & 0x1000000 > 0)
        result = result * 0x10000000000B17217F7D20CF927C8E94C >> 128;
      if (x & 0x800000 > 0)
        result = result * 0x1000000000058B90BFBE8F71CB4E4B33D >> 128;
      if (x & 0x400000 > 0)
        result = result * 0x100000000002C5C85FDF477B662B26945 >> 128;
      if (x & 0x200000 > 0)
        result = result * 0x10000000000162E42FEFA3AE53369388C >> 128;
      if (x & 0x100000 > 0)
        result = result * 0x100000000000B17217F7D1D351A389D40 >> 128;
      if (x & 0x80000 > 0)
        result = result * 0x10000000000058B90BFBE8E8B2D3D4EDE >> 128;
      if (x & 0x40000 > 0)
        result = result * 0x1000000000002C5C85FDF4741BEA6E77E >> 128;
      if (x & 0x20000 > 0)
        result = result * 0x100000000000162E42FEFA39FE95583C2 >> 128;
      if (x & 0x10000 > 0)
        result = result * 0x1000000000000B17217F7D1CFB72B45E1 >> 128;
      if (x & 0x8000 > 0)
        result = result * 0x100000000000058B90BFBE8E7CC35C3F0 >> 128;
      if (x & 0x4000 > 0)
        result = result * 0x10000000000002C5C85FDF473E242EA38 >> 128;
      if (x & 0x2000 > 0)
        result = result * 0x1000000000000162E42FEFA39F02B772C >> 128;
      if (x & 0x1000 > 0)
        result = result * 0x10000000000000B17217F7D1CF7D83C1A >> 128;
      if (x & 0x800 > 0)
        result = result * 0x1000000000000058B90BFBE8E7BDCBE2E >> 128;
      if (x & 0x400 > 0)
        result = result * 0x100000000000002C5C85FDF473DEA871F >> 128;
      if (x & 0x200 > 0)
        result = result * 0x10000000000000162E42FEFA39EF44D91 >> 128;
      if (x & 0x100 > 0)
        result = result * 0x100000000000000B17217F7D1CF79E949 >> 128;
      if (x & 0x80 > 0)
        result = result * 0x10000000000000058B90BFBE8E7BCE544 >> 128;
      if (x & 0x40 > 0)
        result = result * 0x1000000000000002C5C85FDF473DE6ECA >> 128;
      if (x & 0x20 > 0)
        result = result * 0x100000000000000162E42FEFA39EF366F >> 128;
      if (x & 0x10 > 0)
        result = result * 0x1000000000000000B17217F7D1CF79AFA >> 128;
      if (x & 0x8 > 0)
        result = result * 0x100000000000000058B90BFBE8E7BCD6D >> 128;
      if (x & 0x4 > 0)
        result = result * 0x10000000000000002C5C85FDF473DE6B2 >> 128;
      if (x & 0x2 > 0)
        result = result * 0x1000000000000000162E42FEFA39EF358 >> 128;
      if (x & 0x1 > 0)
        result = result * 0x10000000000000000B17217F7D1CF79AB >> 128;

      result >>= uint256 (int256 (63 - (x >> 64)));
      require (result <= uint256 (int256 (MAX_64x64)));

      return int128 (int256 (result));
    }
  }

  /**
   * Calculate natural exponent of x.  Revert on overflow.
   *
   * @param x signed 64.64-bit fixed point number
   * @return signed 64.64-bit fixed point number
   */
  function exp (int128 x) internal pure returns (int128) {
    unchecked {
      require (x < 0x400000000000000000); // Overflow

      if (x < -0x400000000000000000) return 0; // Underflow

      return exp_2 (
          int128 (int256 (x) * 0x171547652B82FE1777D0FFDA0D23A7D12 >> 128));
    }
  }

  /**
   * Calculate x / y rounding towards zero, where x and y are unsigned 256-bit
   * integer numbers.  Revert on overflow or when y is zero.
   *
   * @param x unsigned 256-bit integer number
   * @param y unsigned 256-bit integer number
   * @return unsigned 64.64-bit fixed point number
   */
  function divuu (uint256 x, uint256 y) private pure returns (uint128) {
    unchecked {
      require (y != 0);

      uint256 result;

      if (x <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)
        result = (x << 64) / y;
      else {
        uint256 msb = 192;
        uint256 xc = x >> 192;
        if (xc >= 0x100000000) { xc >>= 32; msb += 32; }
        if (xc >= 0x10000) { xc >>= 16; msb += 16; }
        if (xc >= 0x100) { xc >>= 8; msb += 8; }
        if (xc >= 0x10) { xc >>= 4; msb += 4; }
        if (xc >= 0x4) { xc >>= 2; msb += 2; }
        if (xc >= 0x2) msb += 1;  // No need to shift xc anymore

        result = (x << 255 - msb) / ((y - 1 >> msb - 191) + 1);
        require (result <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);

        uint256 hi = result * (y >> 128);
        uint256 lo = result * (y & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);

        uint256 xh = x >> 192;
        uint256 xl = x << 64;

        if (xl < lo) xh -= 1;
        xl -= lo; // We rely on overflow behavior here
        lo = hi << 128;
        if (xl < lo) xh -= 1;
        xl -= lo; // We rely on overflow behavior here

        assert (xh == hi >> 128);

        result += xl / y;
      }

      require (result <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);
      return uint128 (result);
    }
  }

  /**
   * Calculate sqrt (x) rounding down, where x is unsigned 256-bit integer
   * number.
   *
   * @param x unsigned 256-bit integer number
   * @return unsigned 128-bit integer number
   */
  function sqrtu (uint256 x) private pure returns (uint128) {
    unchecked {
      if (x == 0) return 0;
      else {
        uint256 xx = x;
        uint256 r = 1;
        if (xx >= 0x100000000000000000000000000000000) { xx >>= 128; r <<= 64; }
        if (xx >= 0x10000000000000000) { xx >>= 64; r <<= 32; }
        if (xx >= 0x100000000) { xx >>= 32; r <<= 16; }
        if (xx >= 0x10000) { xx >>= 16; r <<= 8; }
        if (xx >= 0x100) { xx >>= 8; r <<= 4; }
        if (xx >= 0x10) { xx >>= 4; r <<= 2; }
        if (xx >= 0x8) { r <<= 1; }
        r = (r + x / r) >> 1;
        r = (r + x / r) >> 1;
        r = (r + x / r) >> 1;
        r = (r + x / r) >> 1;
        r = (r + x / r) >> 1;
        r = (r + x / r) >> 1;
        r = (r + x / r) >> 1; // Seven iterations should be enough
        uint256 r1 = x / r;
        return uint128 (r < r1 ? r : r1);
      }
    }
  }
}

/// @title Contains 512-bit math functions
/// @notice Facilitates multiplication and division that can have overflow of an intermediate value without any loss of precision
/// @dev Handles "phantom overflow" i.e., allows multiplication and division where an intermediate value overflows 256 bits
library FullMath {
    /// @notice Calculates floor(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
    /// @param a The multiplicand
    /// @param b The multiplier
    /// @param denominator The divisor
    /// @return result The 256-bit result
    /// @dev Credit to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv
    function mulDiv(
        uint256 a,
        uint256 b,
        uint256 denominator
    ) internal pure returns (uint256 result) {
        // 512-bit multiply [prod1 prod0] = a * b
        // Compute the product mod 2**256 and mod 2**256 - 1
        // then use the Chinese Remainder Theorem to reconstruct
        // the 512 bit result. The result is stored in two 256
        // variables such that product = prod1 * 2**256 + prod0
        uint256 prod0; // Least significant 256 bits of the product
        uint256 prod1; // Most significant 256 bits of the product
        assembly {
            let mm := mulmod(a, b, not(0))
            prod0 := mul(a, b)
            prod1 := sub(sub(mm, prod0), lt(mm, prod0))
        }

        // Handle non-overflow cases, 256 by 256 division
        if (prod1 == 0) {
            require(denominator > 0);
            assembly {
                result := div(prod0, denominator)
            }
            return result;
        }

        // Make sure the result is less than 2**256.
        // Also prevents denominator == 0
        require(denominator > prod1);

        ///////////////////////////////////////////////
        // 512 by 256 division.
        ///////////////////////////////////////////////

        // Make division exact by subtracting the remainder from [prod1 prod0]
        // Compute remainder using mulmod
        uint256 remainder;
        assembly {
            remainder := mulmod(a, b, denominator)
        }
        // Subtract 256 bit number from 512 bit number
        assembly {
            prod1 := sub(prod1, gt(remainder, prod0))
            prod0 := sub(prod0, remainder)
        }

        // Factor powers of two out of denominator
        // Compute largest power of two divisor of denominator.
        // Always >= 1.
        uint256 twos = denominator & (~denominator + 1);
        // Divide denominator by power of two
        assembly {
            denominator := div(denominator, twos)
        }

        // Divide [prod1 prod0] by the factors of two
        assembly {
            prod0 := div(prod0, twos)
        }
        // Shift in bits from prod1 into prod0. For this we need
        // to flip `twos` such that it is 2**256 / twos.
        // If twos is zero, then it becomes one
        assembly {
            twos := add(div(sub(0, twos), twos), 1)
        }
        prod0 |= prod1 * twos;

        // Invert denominator mod 2**256
        // Now that denominator is an odd number, it has an inverse
        // modulo 2**256 such that denominator * inv = 1 mod 2**256.
        // Compute the inverse by starting with a seed that is correct
        // correct for four bits. That is, denominator * inv = 1 mod 2**4
        uint256 inv = (3 * denominator) ^ 2;
        // Now use Newton-Raphson iteration to improve the precision.
        // Thanks to Hensel's lifting lemma, this also works in modular
        // arithmetic, doubling the correct bits in each step.
        inv *= 2 - denominator * inv; // inverse mod 2**8
        inv *= 2 - denominator * inv; // inverse mod 2**16
        inv *= 2 - denominator * inv; // inverse mod 2**32
        inv *= 2 - denominator * inv; // inverse mod 2**64
        inv *= 2 - denominator * inv; // inverse mod 2**128
        inv *= 2 - denominator * inv; // inverse mod 2**256

        // Because the division is now exact we can divide by multiplying
        // with the modular inverse of denominator. This will give us the
        // correct result modulo 2**256. Since the precoditions guarantee
        // that the outcome is less than 2**256, this is the final result.
        // We don't need to compute the high bits of the result and prod1
        // is no longer required.
        result = prod0 * inv;
        return result;
    }

    /// @notice Calculates ceil(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
    /// @param a The multiplicand
    /// @param b The multiplier
    /// @param denominator The divisor
    /// @return result The 256-bit result
    function mulDivRoundingUp(
        uint256 a,
        uint256 b,
        uint256 denominator
    ) internal pure returns (uint256 result) {
        result = mulDiv(a, b, denominator);
        if (mulmod(a, b, denominator) > 0) {
            require(result < type(uint256).max);
            result++;
        }
    }
}

/// @title Prevents delegatecall to a contract
/// @notice Base contract that provides a modifier for preventing delegatecall to methods in a child contract
abstract contract NoDelegateCall {
    /// @dev The original address of this contract
    address private immutable original;

    constructor() {
        // Immutables are computed in the init code of the contract, and then inlined into the deployed bytecode.
        // In other words, this variable won't change when it's checked at runtime.
        original = address(this);
    }

    /// @dev Private method is used instead of inlining into modifier because modifiers are copied into each method,
    ///     and the use of immutable means the address bytes are copied in every place the modifier is used.
    function checkNotDelegateCall() private view {
        require(address(this) == original);
    }

    /// @notice Prevents delegatecall into the modified method
    modifier noDelegateCall() {
        checkNotDelegateCall();
        _;
    }
}

// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.

// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/ERC20.sol)

// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)

/**
 * @dev Interface for the optional metadata functions from the ERC20 standard.
 *
 * _Available since v4.1._
 */
interface IERC20Metadata is IERC20 {
    /**
     * @dev Returns the name of the token.
     */
    function name() external view returns (string memory);

    /**
     * @dev Returns the symbol of the token.
     */
    function symbol() external view returns (string memory);

    /**
     * @dev Returns the decimals places of the token.
     */
    function decimals() external view returns (uint8);
}

// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

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

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }
}

/**
 * @dev Implementation of the {IERC20} interface.
 *
 * This implementation is agnostic to the way tokens are created. This means
 * that a supply mechanism has to be added in a derived contract using {_mint}.
 * For a generic mechanism see {ERC20PresetMinterPauser}.
 *
 * TIP: For a detailed writeup see our guide
 * https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How
 * to implement supply mechanisms].
 *
 * The default value of {decimals} is 18. To change this, you should override
 * this function so it returns a different value.
 *
 * We have followed general OpenZeppelin Contracts guidelines: functions revert
 * instead returning `false` on failure. This behavior is nonetheless
 * conventional and does not conflict with the expectations of ERC20
 * applications.
 *
 * Additionally, an {Approval} event is emitted on calls to {transferFrom}.
 * This allows applications to reconstruct the allowance for all accounts just
 * by listening to said events. Other implementations of the EIP may not emit
 * these events, as it isn't required by the specification.
 *
 * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
 * functions have been added to mitigate the well-known issues around setting
 * allowances. See {IERC20-approve}.
 */
contract ERC20 is Context, IERC20, IERC20Metadata {
    mapping(address => uint256) private _balances;

    mapping(address => mapping(address => uint256)) private _allowances;

    uint256 private _totalSupply;

    string private _name;
    string private _symbol;

    /**
     * @dev Sets the values for {name} and {symbol}.
     *
     * All two of these values are immutable: they can only be set once during
     * construction.
     */
    constructor(string memory name_, string memory symbol_) {
        _name = name_;
        _symbol = symbol_;
    }

    /**
     * @dev Returns the name of the token.
     */
    function name() public view virtual override returns (string memory) {
        return _name;
    }

    /**
     * @dev Returns the symbol of the token, usually a shorter version of the
     * name.
     */
    function symbol() public view virtual override returns (string memory) {
        return _symbol;
    }

    /**
     * @dev Returns the number of decimals used to get its user representation.
     * For example, if `decimals` equals `2`, a balance of `505` tokens should
     * be displayed to a user as `5.05` (`505 / 10 ** 2`).
     *
     * Tokens usually opt for a value of 18, imitating the relationship between
     * Ether and Wei. This is the default value returned by this function, unless
     * it's overridden.
     *
     * NOTE: This information is only used for _display_ purposes: it in
     * no way affects any of the arithmetic of the contract, including
     * {IERC20-balanceOf} and {IERC20-transfer}.
     */
    function decimals() public view virtual override returns (uint8) {
        return 18;
    }

    /**
     * @dev See {IERC20-totalSupply}.
     */
    function totalSupply() public view virtual override returns (uint256) {
        return _totalSupply;
    }

    /**
     * @dev See {IERC20-balanceOf}.
     */
    function balanceOf(address account) public view virtual override returns (uint256) {
        return _balances[account];
    }

    /**
     * @dev See {IERC20-transfer}.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - the caller must have a balance of at least `amount`.
     */
    function transfer(address to, uint256 amount) public virtual override returns (bool) {
        address owner = _msgSender();
        _transfer(owner, to, amount);
        return true;
    }

    /**
     * @dev See {IERC20-allowance}.
     */
    function allowance(address owner, address spender) public view virtual override returns (uint256) {
        return _allowances[owner][spender];
    }

    /**
     * @dev See {IERC20-approve}.
     *
     * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on
     * `transferFrom`. This is semantically equivalent to an infinite approval.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function approve(address spender, uint256 amount) public virtual override returns (bool) {
        address owner = _msgSender();
        _approve(owner, spender, amount);
        return true;
    }

    /**
     * @dev See {IERC20-transferFrom}.
     *
     * Emits an {Approval} event indicating the updated allowance. This is not
     * required by the EIP. See the note at the beginning of {ERC20}.
     *
     * NOTE: Does not update the allowance if the current allowance
     * is the maximum `uint256`.
     *
     * Requirements:
     *
     * - `from` and `to` cannot be the zero address.
     * - `from` must have a balance of at least `amount`.
     * - the caller must have allowance for ``from``'s tokens of at least
     * `amount`.
     */
    function transferFrom(address from, address to, uint256 amount) public virtual override returns (bool) {
        address spender = _msgSender();
        _spendAllowance(from, spender, amount);
        _transfer(from, to, amount);
        return true;
    }

    /**
     * @dev Atomically increases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {IERC20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
        address owner = _msgSender();
        _approve(owner, spender, allowance(owner, spender) + addedValue);
        return true;
    }

    /**
     * @dev Atomically decreases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {IERC20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `spender` must have allowance for the caller of at least
     * `subtractedValue`.
     */
    function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
        address owner = _msgSender();
        uint256 currentAllowance = allowance(owner, spender);
        require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
        unchecked {
            _approve(owner, spender, currentAllowance - subtractedValue);
        }

        return true;
    }

    /**
     * @dev Moves `amount` of tokens from `from` to `to`.
     *
     * This internal function is equivalent to {transfer}, and can be used to
     * e.g. implement automatic token fees, slashing mechanisms, etc.
     *
     * Emits a {Transfer} event.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `from` must have a balance of at least `amount`.
     */
    function _transfer(address from, address to, uint256 amount) internal virtual {
        require(from != address(0), "ERC20: transfer from the zero address");
        require(to != address(0), "ERC20: transfer to the zero address");

        _beforeTokenTransfer(from, to, amount);

        uint256 fromBalance = _balances[from];
        require(fromBalance >= amount, "ERC20: transfer amount exceeds balance");
        unchecked {
            _balances[from] = fromBalance - amount;
            // Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by
            // decrementing then incrementing.
            _balances[to] += amount;
        }

        emit Transfer(from, to, amount);

        _afterTokenTransfer(from, to, amount);
    }

    /** @dev Creates `amount` tokens and assigns them to `account`, increasing
     * the total supply.
     *
     * Emits a {Transfer} event with `from` set to the zero address.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     */
    function _mint(address account, uint256 amount) internal virtual {
        require(account != address(0), "ERC20: mint to the zero address");

        _beforeTokenTransfer(address(0), account, amount);

        _totalSupply += amount;
        unchecked {
            // Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.
            _balances[account] += amount;
        }
        emit Transfer(address(0), account, amount);

        _afterTokenTransfer(address(0), account, amount);
    }

    /**
     * @dev Destroys `amount` tokens from `account`, reducing the
     * total supply.
     *
     * Emits a {Transfer} event with `to` set to the zero address.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     * - `account` must have at least `amount` tokens.
     */
    function _burn(address account, uint256 amount) internal virtual {
        require(account != address(0), "ERC20: burn from the zero address");

        _beforeTokenTransfer(account, address(0), amount);

        uint256 accountBalance = _balances[account];
        require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
        unchecked {
            _balances[account] = accountBalance - amount;
            // Overflow not possible: amount <= accountBalance <= totalSupply.
            _totalSupply -= amount;
        }

        emit Transfer(account, address(0), amount);

        _afterTokenTransfer(account, address(0), amount);
    }

    /**
     * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
     *
     * This internal function is equivalent to `approve`, and can be used to
     * e.g. set automatic allowances for certain subsystems, etc.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `owner` cannot be the zero address.
     * - `spender` cannot be the zero address.
     */
    function _approve(address owner, address spender, uint256 amount) internal virtual {
        require(owner != address(0), "ERC20: approve from the zero address");
        require(spender != address(0), "ERC20: approve to the zero address");

        _allowances[owner][spender] = amount;
        emit Approval(owner, spender, amount);
    }

    /**
     * @dev Updates `owner` s allowance for `spender` based on spent `amount`.
     *
     * Does not update the allowance amount in case of infinite allowance.
     * Revert if not enough allowance is available.
     *
     * Might emit an {Approval} event.
     */
    function _spendAllowance(address owner, address spender, uint256 amount) internal virtual {
        uint256 currentAllowance = allowance(owner, spender);
        if (currentAllowance != type(uint256).max) {
            require(currentAllowance >= amount, "ERC20: insufficient allowance");
            unchecked {
                _approve(owner, spender, currentAllowance - amount);
            }
        }
    }

    /**
     * @dev Hook that is called before any transfer of tokens. This includes
     * minting and burning.
     *
     * Calling conditions:
     *
     * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
     * will be transferred to `to`.
     * - when `from` is zero, `amount` tokens will be minted for `to`.
     * - when `to` is zero, `amount` of ``from``'s tokens will be burned.
     * - `from` and `to` are never both zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual {}

    /**
     * @dev Hook that is called after any transfer of tokens. This includes
     * minting and burning.
     *
     * Calling conditions:
     *
     * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
     * has been transferred to `to`.
     * - when `from` is zero, `amount` tokens have been minted for `to`.
     * - when `to` is zero, `amount` of ``from``'s tokens have been burned.
     * - `from` and `to` are never both zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _afterTokenTransfer(address from, address to, uint256 amount) internal virtual {}
}

// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.

// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.

interface IOracle {
    function acceptOwnership() external;

    function accessController() external view returns (address);

    function aggregator() external view returns (address);

    function confirmAggregator(address _aggregator) external;

    function decimals() external view returns (uint8);

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

    function getAnswer(uint256 _roundId) external view returns (int256);

    function getRoundData(uint80 _roundId)
        external
        view
        returns (
            uint80 roundId,
            int256 answer,
            uint256 startedAt,
            uint256 updatedAt,
            uint80 answeredInRound
        );

    function getTimestamp(uint256 _roundId) external view returns (uint256);

    function latestAnswer() external view returns (int256);

    function latestRound() external view returns (uint256);

    function latestRoundData()
        external
        view
        returns (
            uint80 roundId,
            int256 answer,
            uint256 startedAt,
            uint256 updatedAt,
            uint80 answeredInRound
        );

    function latestTimestamp() external view returns (uint256);

    function owner() external view returns (address);

    function phaseAggregators(uint16) external view returns (address);

    function phaseId() external view returns (uint16);

    function proposeAggregator(address _aggregator) external;

    function proposedAggregator() external view returns (address);

    function proposedGetRoundData(uint80 _roundId)
        external
        view
        returns (
            uint80 roundId,
            int256 answer,
            uint256 startedAt,
            uint256 updatedAt,
            uint80 answeredInRound
        );

    function proposedLatestRoundData()
        external
        view
        returns (
            uint80 roundId,
            int256 answer,
            uint256 startedAt,
            uint256 updatedAt,
            uint80 answeredInRound
        );

    function setController(address _accessController) external;

    function transferOwnership(address _to) external;

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

// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.

// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.

interface IAssimilator {
    function oracleDecimals() external view returns(uint256);
    
    function tokenDecimals() external view returns(uint256);

    function getRate() external view returns (uint256);

    function intakeRaw(uint256 amount) external returns (int128);

    function intakeRawAndGetBalance(uint256 amount)
        external
        returns (int128, int128);

    function intakeNumeraire(int128 amount) external returns (uint256);

    function intakeNumeraireLPRatio(
        uint256,
        uint256,
        uint256,
        uint256,
        uint256,
        uint256,
        address,
        int128
    ) external returns (uint256);

    function outputRaw(address dst, uint256 amount) external returns (int128);

    function outputRawAndGetBalance(address dst, uint256 amount)
        external
        returns (int128, int128);

    function outputNumeraire(address dst, int128 amount)
        external
        returns (uint256);

    function viewRawAmount(int128) external view returns (uint256);

    function viewRawAmountLPRatio(
        uint256,
        uint256,
        address,
        int128
    ) external view returns (uint256);

    function viewNumeraireAmount(uint256) external view returns (int128);

    function viewNumeraireBalanceLPRatio(
        uint256,
        uint256,
        address
    ) external view returns (int128);

    function viewNumeraireBalance(address) external view returns (int128);

    function viewNumeraireAmountAndBalance(address, uint256)
        external
        view
        returns (int128, int128);

    function transferFee(int128, address) external;
}

interface ICurveFactory {
    function getProtocolFee() external view returns (int128);
    function getProtocolTreasury() external view returns (address);
    function getGlobalFrozenState() external view returns (bool);
    function getFlashableState() external view returns (bool);
    function isPoolGuarded(address pool) external view returns (bool);
    function getPoolGuardAmount(address pool) external view returns (uint256);
    function getPoolCap(address pool) external view returns (uint256);
}

struct OriginSwapData {
    address _origin;
    address _target;
    uint256 _originAmount;
    address _recipient;
    address _curveFactory;
}

struct TargetSwapData {
    address _origin;
    address _target;
    uint256 _targetAmount;
    address _recipient;
    address _curveFactory;
}

struct SwapInfo {
    int128 totalAmount;
    int128 totalFee;
    int128 amountToUser;
    int128 amountToTreasury;
    int128 protocolFeePercentage;
    address treasury;
    ICurveFactory curveFactory;
}

struct CurveInfo {
    string _name;
    string _symbol;
    address _baseCurrency;
    address _quoteCurrency;
    uint256 _baseWeight;
    uint256 _quoteWeight;
    IOracle _baseOracle;
    IOracle _quoteOracle;
    uint256 _alpha;
    uint256 _beta;
    uint256 _feeAtHalt;
    uint256 _epsilon;
    uint256 _lambda;
}

struct DepositData {
    uint256 deposits;
    uint256 minQuote;
    uint256 minBase;
    uint256 maxQuote;
    uint256 maxBase;
}

struct IntakeNumLpRatioInfo {
    uint256 baseWeight;
    uint256 minBase;
    uint256 maxBase;
    uint256 quoteWeight;
    uint256 minQuote;
    uint256 maxQuote;
    int128 amount;
}

library Assimilators {
    using ABDKMath64x64 for int128;
    using Address for address;

    IAssimilator public constant iAsmltr = IAssimilator(address(0));

    function delegate(address _callee, bytes memory _data) internal returns (bytes memory) {
        require(_callee.isContract(), "Assimilators/callee-is-not-a-contract");

        // solhint-disable-next-line
        (bool _success, bytes memory returnData_) = _callee.delegatecall(_data);

        // solhint-disable-next-line
        assembly {
            if eq(_success, 0) {
                revert(add(returnData_, 0x20), returndatasize())
            }
        }

        return returnData_;
    }

    function getRate(address _assim) internal view returns (uint256 amount_) {
        amount_ = IAssimilator(_assim).getRate();
    }

    function viewRawAmount(address _assim, int128 _amt) internal view returns (uint256 amount_) {
        amount_ = IAssimilator(_assim).viewRawAmount(_amt);
    }

    function viewRawAmountLPRatio(
        address _assim,
        uint256 _baseWeight,
        uint256 _quoteWeight,
        int128 _amount
    ) internal view returns (uint256 amount_) {
        amount_ = IAssimilator(_assim).viewRawAmountLPRatio(_baseWeight, _quoteWeight, address(this), _amount);
    }

    function viewNumeraireAmount(address _assim, uint256 _amt) internal view returns (int128 amt_) {
        amt_ = IAssimilator(_assim).viewNumeraireAmount(_amt);
    }

    function viewNumeraireAmountAndBalance(address _assim, uint256 _amt)
        internal
        view
        returns (int128 amt_, int128 bal_)
    {
        (amt_, bal_) = IAssimilator(_assim).viewNumeraireAmountAndBalance(address(this), _amt);
    }

    function viewNumeraireBalance(address _assim) internal view returns (int128 bal_) {
        bal_ = IAssimilator(_assim).viewNumeraireBalance(address(this));
    }

    function viewNumeraireBalanceLPRatio(
        uint256 _baseWeight,
        uint256 _quoteWeight,
        address _assim
    ) internal view returns (int128 bal_) {
        bal_ = IAssimilator(_assim).viewNumeraireBalanceLPRatio(_baseWeight, _quoteWeight, address(this));
    }

    function intakeRaw(address _assim, uint256 _amt) internal returns (int128 amt_) {
        bytes memory data = abi.encodeWithSelector(iAsmltr.intakeRaw.selector, _amt);

        amt_ = abi.decode(delegate(_assim, data), (int128));
    }

    function intakeRawAndGetBalance(address _assim, uint256 _amt) internal returns (int128 amt_, int128 bal_) {
        bytes memory data = abi.encodeWithSelector(iAsmltr.intakeRawAndGetBalance.selector, _amt);

        (amt_, bal_) = abi.decode(delegate(_assim, data), (int128, int128));
    }

    function intakeNumeraire(address _assim, int128 _amt) internal returns (uint256 amt_) {
        bytes memory data = abi.encodeWithSelector(iAsmltr.intakeNumeraire.selector, _amt);

        amt_ = abi.decode(delegate(_assim, data), (uint256));
    }

    function intakeNumeraireLPRatio(
        address _assim,
        IntakeNumLpRatioInfo memory info
    ) internal returns (uint256 amt_) {
        bytes memory data = abi.encodeWithSelector(
            iAsmltr.intakeNumeraireLPRatio.selector,
            info.baseWeight,
            info.minBase,
            info.maxBase,
            info.quoteWeight,
            info.minQuote,
            info.maxQuote,
            address(this),
            // _amount
            info.amount
        );

        amt_ = abi.decode(delegate(_assim, data), (uint256));
    }

    function outputRaw(
        address _assim,
        address _dst,
        uint256 _amt
    ) internal returns (int128 amt_) {
        bytes memory data = abi.encodeWithSelector(iAsmltr.outputRaw.selector, _dst, _amt);

        amt_ = abi.decode(delegate(_assim, data), (int128));

        amt_ = amt_.neg();
    }

    function outputRawAndGetBalance(
        address _assim,
        address _dst,
        uint256 _amt
    ) internal returns (int128 amt_, int128 bal_) {
        bytes memory data = abi.encodeWithSelector(iAsmltr.outputRawAndGetBalance.selector, _dst, _amt);

        (amt_, bal_) = abi.decode(delegate(_assim, data), (int128, int128));

        amt_ = amt_.neg();
    }

    function outputNumeraire(
        address _assim,
        address _dst,
        int128 _amt
    ) internal returns (uint256 amt_) {
        bytes memory data = abi.encodeWithSelector(iAsmltr.outputNumeraire.selector, _dst, _amt.abs());

        amt_ = abi.decode(delegate(_assim, data), (uint256));
    }

    function transferFee(
        address _assim,
        int128 _amt,
        address _treasury
    ) internal {
        bytes memory data = abi.encodeWithSelector(iAsmltr.transferFee.selector, _amt, _treasury);
        delegate(_assim, data);
    }
}

contract Storage {
    struct Curve {
        // Curve parameters
        int128 alpha;
        int128 beta;
        int128 delta;
        int128 epsilon;
        int128 lambda;
        int128[] weights;
        // Assets and their assimilators
        Assimilator[] assets;
        mapping(address => Assimilator) assimilators;
        // Oracles to determine the price
        // Note that 0'th index should always be USDC 1e18
        // Oracle's pricing should be denominated in Currency/USDC
        mapping(address => IOracle) oracles;
        // ERC20 Interface
        uint256 totalSupply;
        mapping(address => uint256) balances;
        mapping(address => mapping(address => uint256)) allowances;
    }

    struct Assimilator {
        address addr;
        uint8 ix;
    }

    // Curve parameters
    Curve public curve;

    // Ownable
    address public owner;

    string public name;
    string public symbol;
    uint8 public constant decimals = 18;

    address[] public derivatives;
    address[] public numeraires;
    address[] public reserves;

    // Curve operational state
    bool public frozen = false;
    bool public emergency = false;
    bool internal notEntered = true;
}

// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.

library UnsafeMath64x64 {

  /**
   * Calculate x * y rounding down.
   *
   * @param x signed 64.64-bit fixed point number
   * @param y signed 64.64-bit fixed point number
   * @return signed 64.64-bit fixed point number
   */

  function us_mul (int128 x, int128 y) internal pure returns (int128) {
    int256 result = int256(x) * y >> 64;
    return int128 (result);
  }

  /**
   * Calculate x / y rounding towards zero.  Revert on overflow or when y is
   * zero.
   *
   * @param x signed 64.64-bit fixed point number
   * @param y signed 64.64-bit fixed point number
   * @return signed 64.64-bit fixed point number
   */

  function us_div (int128 x, int128 y) internal pure returns (int128) {
    int256 result = (int256 (x) << 64) / y;
    return int128 (result);
  }

}

library CurveMath {
    int128 private constant ONE = 0x10000000000000000;
    int128 private constant MAX = 0x4000000000000000; // .25 in layman's terms
    int128 private constant MAX_DIFF = -0x10C6F7A0B5EE;
    int128 private constant ONE_WEI = 0x12;

    using ABDKMath64x64 for int128;
    using UnsafeMath64x64 for int128;
    using ABDKMath64x64 for uint256;

    // This is used to prevent stack too deep errors
    function calculateFee(
        int128 _gLiq,
        int128[] memory _bals,
        Storage.Curve storage curve,
        int128[] memory _weights
    ) internal view returns (int128 psi_) {
        int128 _beta = curve.beta;
        int128 _delta = curve.delta;

        psi_ = calculateFee(_gLiq, _bals, _beta, _delta, _weights);
    }

    function calculateFee(
        int128 _gLiq,
        int128[] memory _bals,
        int128 _beta,
        int128 _delta,
        int128[] memory _weights
    ) internal pure returns (int128 psi_) {
        uint256 _length = _bals.length;

        for (uint256 i = 0; i < _length; i++) {
            int128 _ideal = _gLiq.mul(_weights[i]);
            psi_ += calculateMicroFee(_bals[i], _ideal, _beta, _delta);
        }
    }

    function calculateMicroFee(
        int128 _bal,
        int128 _ideal,
        int128 _beta,
        int128 _delta
    ) private pure returns (int128 fee_) {
        if (_bal < _ideal) {
            int128 _threshold = _ideal.mul(ONE - _beta);

            if (_bal < _threshold) {
                int128 _feeMargin = _threshold - _bal;

                fee_ = _feeMargin.mul(_delta);
                fee_ = fee_.div(_ideal);

                if (fee_ > MAX) fee_ = MAX;

                fee_ = fee_.mul(_feeMargin);
            } else fee_ = 0;
        } else {
            int128 _threshold = _ideal.mul(ONE + _beta);

            if (_bal > _threshold) {
                int128 _feeMargin = _bal - _threshold;

                fee_ = _feeMargin.mul(_delta);
                fee_ = fee_.div(_ideal);

                if (fee_ > MAX) fee_ = MAX;

                fee_ = fee_.mul(_feeMargin);
            } else fee_ = 0;
        }
    }

    function calculateTrade(
        Storage.Curve storage curve,
        int128 _oGLiq,
        int128 _nGLiq,
        int128[] memory _oBals,
        int128[] memory _nBals,
        int128 _inputAmt,
        uint256 _outputIndex
    ) internal view returns (int128 outputAmt_) {
        outputAmt_ = -_inputAmt;

        int128 _lambda = curve.lambda;
        int128[] memory _weights = curve.weights;

        int128 _omega = calculateFee(_oGLiq, _oBals, curve, _weights);
        int128 _psi;

        for (uint256 i = 0; i < 32; i++) {
            _psi = calculateFee(_nGLiq, _nBals, curve, _weights);

            int128 prevAmount;
            {
                prevAmount = outputAmt_;
                outputAmt_ = _omega < _psi ? -(_inputAmt + _omega - _psi) : -(_inputAmt + _lambda.mul(_omega - _psi));
                // outputAmt_ = _omega < _psi ? -(_inputAmt + _omega - _psi) : -(_inputAmt +_omega - _psi);
            }

            if (outputAmt_ / 1e13 == prevAmount / 1e13) {
                _nGLiq = _oGLiq + _inputAmt + outputAmt_;

                _nBals[_outputIndex] = _oBals[_outputIndex] + outputAmt_;

                enforceHalts(curve, _oGLiq, _nGLiq, _oBals, _nBals, _weights);

                enforceSwapInvariant(_oGLiq, _omega, _nGLiq, _psi);
                return outputAmt_;
            } else {
                _nGLiq = _oGLiq + _inputAmt + outputAmt_;

                _nBals[_outputIndex] = _oBals[_outputIndex].add(outputAmt_);
            }
        }

        revert("Curve/swap-convergence-failed");
    }

    function calculateLiquidityMembrane(
        Storage.Curve storage curve,
        int128 _oGLiq,
        int128 _nGLiq,
        int128[] memory _oBals,
        int128[] memory _nBals
    ) internal view returns (int128 curves_) {
        enforceHalts(curve, _oGLiq, _nGLiq, _oBals, _nBals, curve.weights);

        int128 _omega;
        int128 _psi;

        {
            int128 _beta = curve.beta;
            int128 _delta = curve.delta;
            int128[] memory _weights = curve.weights;

            _omega = calculateFee(_oGLiq, _oBals, _beta, _delta, _weights);
            _psi = calculateFee(_nGLiq, _nBals, _beta, _delta, _weights);
        }

        int128 _feeDiff = _psi.sub(_omega);
        int128 _liqDiff = _nGLiq.sub(_oGLiq);
        int128 _oUtil = _oGLiq.sub(_omega);
        int128 _totalShells = curve.totalSupply.divu(1e18);
        int128 _curveMultiplier;

        if (_totalShells == 0) {
            curves_ = _nGLiq.sub(_psi);
        } else if (_feeDiff >= 0) {
            _curveMultiplier = _liqDiff.sub(_feeDiff).div(_oUtil);
        } else {
            _curveMultiplier = _liqDiff.sub(curve.lambda.mul(_feeDiff));

            _curveMultiplier = _curveMultiplier.div(_oUtil);
        }

        if (_totalShells != 0) {
            curves_ = _totalShells.mul(_curveMultiplier);
        }
    }

    function enforceSwapInvariant(
        int128 _oGLiq,
        int128 _omega,
        int128 _nGLiq,
        int128 _psi
    ) private pure {
        int128 _nextUtil = _nGLiq - _psi;

        int128 _prevUtil = _oGLiq - _omega;

        int128 _diff = _nextUtil - _prevUtil;

        require(0 < _diff || _diff >= MAX_DIFF, "Curve/swap-invariant-violation");
    }

    function enforceHalts(
        Storage.Curve storage curve,
        int128 _oGLiq,
        int128 _nGLiq,
        int128[] memory _oBals,
        int128[] memory _nBals,
        int128[] memory _weights
    ) private view {
        uint256 _length = _nBals.length;
        int128 _alpha = curve.alpha;

        for (uint256 i = 0; i < _length; i++) {
            int128 _nIdeal = _nGLiq.mul(_weights[i]);

            if (_nBals[i] > _nIdeal) {
                int128 _upperAlpha = ONE + _alpha;

                int128 _nHalt = _nIdeal.mul(_upperAlpha);

                if (_nBals[i] > _nHalt) {
                    int128 _oHalt = _oGLiq.mul(_weights[i]).mul(_upperAlpha);

                    if (_oBals[i] < _oHalt) revert("Curve/upper-halt");
                    if (_nBals[i] - _nHalt > _oBals[i] - _oHalt) revert("Curve/upper-halt");
                }
            } else {
                int128 _lowerAlpha = ONE - _alpha;

                int128 _nHalt = _nIdeal.mul(_lowerAlpha);

                if (_nBals[i] < _nHalt) {
                    int128 _oHalt = _oGLiq.mul(_weights[i]);
                    _oHalt = _oHalt.mul(_lowerAlpha);

                    if (_oBals[i] > _oHalt) revert("Curve/lower-halt");
                    if (_nHalt - _nBals[i] > _oHalt - _oBals[i]) revert("Curve/lower-halt");
                }
            }
        }
    }
}

library Orchestrator {
    using SafeERC20 for IERC20;
    using ABDKMath64x64 for int128;
    using ABDKMath64x64 for uint256;

    int128 private constant ONE_WEI = 0x12;

    event ParametersSet(uint256 alpha, uint256 beta, uint256 delta, uint256 epsilon, uint256 lambda);

    event AssetIncluded(address indexed numeraire, address indexed reserve, uint256 weight);

    event AssimilatorIncluded(
        address indexed derivative,
        address indexed numeraire,
        address indexed reserve,
        address assimilator
    );

    function setParams(
        Storage.Curve storage curve,
        uint256 _alpha,
        uint256 _beta,
        uint256 _feeAtHalt,
        uint256 _epsilon,
        uint256 _lambda
    ) external {
        require(0 < _alpha && _alpha < 1e18, "Curve/parameter-invalid-alpha");

        require(_beta < _alpha, "Curve/parameter-invalid-beta");

        require(_feeAtHalt <= 5e17, "Curve/parameter-invalid-max");

        require(_epsilon <= 1e16, "Curve/parameter-invalid-epsilon");

        require(_lambda <= 1e18, "Curve/parameter-invalid-lambda");

        int128 _omega = getFee(curve);

        curve.alpha = (_alpha + 1).divu(1e18);

        curve.beta = (_beta + 1).divu(1e18);

        curve.delta = (_feeAtHalt).divu(1e18).div(uint256(2).fromUInt().mul(curve.alpha.sub(curve.beta))) + ONE_WEI;

        curve.epsilon = (_epsilon + 1).divu(1e18);

        curve.lambda = (_lambda + 1).divu(1e18);

        int128 _psi = getFee(curve);

        require(_omega >= _psi, "Curve/parameters-increase-fee");

        emit ParametersSet(_alpha, _beta, curve.delta.mulu(1e18), _epsilon, _lambda);
    }

    function setAssimilator(
        Storage.Curve storage curve,
        address _baseCurrency,
        address _baseAssim,
        address _quoteCurrency,
        address _quoteAssim
    ) external {
        require(_baseCurrency != address(0), "Curve/numeraire-cannot-be-zeroth-address");
        require(_baseAssim != address(0), "Curve/numeraire-assimilator-cannot-be-zeroth-address");
        require(_quoteCurrency != address(0), "Curve/reserve-cannot-be-zeroth-address");
        require(_quoteAssim != address(0), "Curve/reserve-assimilator-cannot-be-zeroth-address");

        Storage.Assimilator storage _baseAssimilator = curve.assimilators[_baseCurrency];
        _baseAssimilator.addr = _baseAssim;

        Storage.Assimilator storage _quoteAssimilator = curve.assimilators[_quoteCurrency];
        _quoteAssimilator.addr = _quoteAssim;

        curve.assets[0] = _baseAssimilator;
        curve.assets[1] = _quoteAssimilator;

    }

    function getFee(Storage.Curve storage curve) private view returns (int128 fee_) {
        int128 _gLiq;

        // Always pairs
        int128[] memory _bals = new int128[](2);

        for (uint256 i = 0; i < _bals.length; i++) {
            int128 _bal = Assimilators.viewNumeraireBalance(curve.assets[i].addr);

            _bals[i] = _bal;

            _gLiq += _bal;
        }

        fee_ = CurveMath.calculateFee(_gLiq, _bals, curve.beta, curve.delta, curve.weights);
    }

    function initialize(
        Storage.Curve storage curve,
        address[] storage numeraires,
        address[] storage reserves,
        address[] storage derivatives,
        address[] calldata _assets,
        uint256[] calldata _assetWeights
    ) external {
        require(_assetWeights.length == 2, "Curve/assetWeights-must-be-length-two");
        require(_assets.length % 5 == 0, "Curve/assets-must-be-divisible-by-five");

        for (uint256 i = 0; i < _assetWeights.length; i++) {
            uint256 ix = i * 5;

            numeraires.push(_assets[ix]);
            derivatives.push(_assets[ix]);

            reserves.push(_assets[2 + ix]);
            if (_assets[ix] != _assets[2 + ix]) derivatives.push(_assets[2 + ix]);

            includeAsset(
                curve,
                _assets[ix], // numeraire
                _assets[1 + ix], // numeraire assimilator
                _assets[2 + ix], // reserve
                _assets[3 + ix], // reserve assimilator
                _assets[4 + ix], // reserve approve to
                _assetWeights[i]
            );
        }
    }

    function includeAsset(
        Storage.Curve storage curve,
        address _numeraire,
        address _numeraireAssim,
        address _reserve,
        address _reserveAssim,
        address _reserveApproveTo,
        uint256 _weight
    ) private {
        require(_numeraire != address(0), "Curve/numeraire-cannot-be-zeroth-address");

        require(_numeraireAssim != address(0), "Curve/numeraire-assimilator-cannot-be-zeroth-address");

        require(_reserve != address(0), "Curve/reserve-cannot-be-zeroth-address");

        require(_reserveAssim != address(0), "Curve/reserve-assimilator-cannot-be-zeroth-address");

        require(_weight < 1e18, "Curve/weight-must-be-less-than-one");

        if (_numeraire != _reserve) IERC20(_numeraire).safeApprove(_reserveApproveTo, type(uint).max);

        Storage.Assimilator storage _numeraireAssimilator = curve.assimilators[_numeraire];

        _numeraireAssimilator.addr = _numeraireAssim;

        _numeraireAssimilator.ix = uint8(curve.assets.length);

        Storage.Assimilator storage _reserveAssimilator = curve.assimilators[_reserve];

        _reserveAssimilator.addr = _reserveAssim;

        _reserveAssimilator.ix = uint8(curve.assets.length);

        int128 __weight = _weight.divu(1e18).add(uint256(1).divu(1e18));

        curve.weights.push(__weight);

        curve.assets.push(_numeraireAssimilator);

        emit AssetIncluded(_numeraire, _reserve, _weight);

        emit AssimilatorIncluded(_numeraire, _numeraire, _reserve, _numeraireAssim);

        if (_numeraireAssim != _reserveAssim) {
            emit AssimilatorIncluded(_reserve, _numeraire, _reserve, _reserveAssim);
        }
    }

    function viewCurve(Storage.Curve storage curve)
        external
        view
        returns (
            uint256 alpha_,
            uint256 beta_,
            uint256 delta_,
            uint256 epsilon_,
            uint256 lambda_
        )
    {
        alpha_ = curve.alpha.mulu(1e18);

        beta_ = curve.beta.mulu(1e18);

        delta_ = curve.delta.mulu(1e18);

        epsilon_ = curve.epsilon.mulu(1e18);

        lambda_ = curve.lambda.mulu(1e18);
    }
}

library ProportionalLiquidity {
    using ABDKMath64x64 for uint256;
    using ABDKMath64x64 for int128;
    using UnsafeMath64x64 for int128;

    event Transfer(address indexed from, address indexed to, uint256 value);

    int128 public constant ONE = 0x10000000000000000;
    int128 public constant ONE_WEI = 0x12;

    function proportionalDeposit(Storage.Curve storage curve, DepositData memory depositData)
        external
        returns (uint256 curves_, uint256[] memory)
    {
        int128 __deposit = depositData.deposits.divu(1e18);

        uint256 _length = curve.assets.length;

        uint256[] memory deposits_ = new uint256[](_length);

        (int128 _oGLiq, int128[] memory _oBals) = getGrossLiquidityAndBalancesForDeposit(curve);

        // Needed to calculate liquidity invariant
        // (int128 _oGLiqProp, int128[] memory _oBalsProp) = getGrossLiquidityAndBalances(curve);

        // No liquidity, oracle sets the ratio
        if (_oGLiq == 0) {
            for (uint256 i = 0; i < _length; i++) {
                // Variable here to avoid stack-too-deep errors
                int128 _d = __deposit.mul(curve.weights[i]);
                deposits_[i] = Assimilators.intakeNumeraire(curve.assets[i].addr, _d.add(ONE_WEI));
            }
        } else {
            // We already have an existing pool ratio
            // which must be respected
            int128 _multiplier = __deposit.div(_oGLiq);

            uint256 _baseWeight = curve.weights[0].mulu(1e18);
            uint256 _quoteWeight = curve.weights[1].mulu(1e18);

            for (uint256 i = 0; i < _length; i++) {
                IntakeNumLpRatioInfo memory info;
                info.baseWeight = _baseWeight;
                info.minBase = depositData.minBase;
                info.maxBase = depositData.maxBase;
                info.quoteWeight = _quoteWeight;
                info.minQuote = depositData.minQuote;
                info.maxQuote = depositData.maxQuote;
                info.amount = _oBals[i].mul(_multiplier).add(ONE_WEI);
                deposits_[i] = Assimilators.intakeNumeraireLPRatio(
                    curve.assets[i].addr,
                    info
                );
            }
        }

        int128 _totalShells = curve.totalSupply.divu(1e18);

        int128 _newShells = __deposit;

        if (_totalShells > 0) {
            _newShells = __deposit.mul(_totalShells);
            _newShells = _newShells.div(_oGLiq);
        }

        require(_newShells > 0, "Proportional Liquidity/can't mint negative amount");
        mint(curve, msg.sender, curves_ = _newShells.mulu(1e18));

        return (curves_, deposits_);
    }

    function viewProportionalDeposit(Storage.Curve storage curve, uint256 _deposit)
        external
        view
        returns (uint256 curves_, uint256[] memory)
    {
        int128 __deposit = _deposit.divu(1e18);

        uint256 _length = curve.assets.length;

        (int128 _oGLiq, int128[] memory _oBals) = getGrossLiquidityAndBalancesForDeposit(curve);

        uint256[] memory deposits_ = new uint256[](_length);

        // No liquidity
        if (_oGLiq == 0) {
            for (uint256 i = 0; i < _length; i++) {
                deposits_[i] = Assimilators.viewRawAmount(
                    curve.assets[i].addr,
                    __deposit.mul(curve.weights[i]).add(ONE_WEI)
                );
            }
        } else {
            // We already have an existing pool ratio
            // this must be respected
            int128 _multiplier = __deposit.div(_oGLiq);

            uint256 _baseWeight = curve.weights[0].mulu(1e18);
            uint256 _quoteWeight = curve.weights[1].mulu(1e18);

            // Deposits into the pool is determined by existing LP ratio
            for (uint256 i = 0; i < _length; i++) {
                deposits_[i] = Assimilators.viewRawAmountLPRatio(
                    curve.assets[i].addr,
                    _baseWeight,
                    _quoteWeight,
                    _oBals[i].mul(_multiplier).add(ONE_WEI)
                );
            }
        }

        int128 _totalShells = curve.totalSupply.divu(1e18);

        int128 _newShells = __deposit;

        if (_totalShells > 0) {
            _newShells = __deposit.mul(_totalShells);
            _newShells = _newShells.div(_oGLiq);
        }

        curves_ = _newShells.mulu(1e18);

        return (curves_, deposits_);
    }

    function proportionalWithdraw(Storage.Curve storage curve, uint256 _withdrawal)
        external
        returns (uint256[] memory)
    {
        uint256 _length = curve.assets.length;

        (, int128[] memory _oBals) = getGrossLiquidityAndBalances(curve);

        uint256[] memory withdrawals_ = new uint256[](_length);

        int128 _totalShells = curve.totalSupply.divu(1e18);
        int128 __withdrawal = _withdrawal.divu(1e18);

        int128 _multiplier = __withdrawal.div(_totalShells);

        for (uint256 i = 0; i < _length; i++) {
            withdrawals_[i] = Assimilators.outputNumeraire(
                curve.assets[i].addr,
                msg.sender,
                _oBals[i].mul(_multiplier)
            );
        }

        burn(curve, msg.sender, _withdrawal);

        return withdrawals_;
    }

    function viewProportionalWithdraw(Storage.Curve storage curve, uint256 _withdrawal)
        external
        view
        returns (uint256[] memory)
    {
        uint256 _length = curve.assets.length;

        (, int128[] memory _oBals) = getGrossLiquidityAndBalances(curve);

        uint256[] memory withdrawals_ = new uint256[](_length);

        int128 _multiplier = _withdrawal.divu(1e18).div(curve.totalSupply.divu(1e18));

        for (uint256 i = 0; i < _length; i++) {
            withdrawals_[i] = Assimilators.viewRawAmount(curve.assets[i].addr, _oBals[i].mul(_multiplier));
        }

        return withdrawals_;
    }

    function getGrossLiquidityAndBalancesForDeposit(Storage.Curve storage curve)
        internal
        view
        returns (int128 grossLiquidity_, int128[] memory)
    {
        uint256 _length = curve.assets.length;

        int128[] memory balances_ = new int128[](_length);
        uint256 _baseWeight = curve.weights[0].mulu(1e18);
        uint256 _quoteWeight = curve.weights[1].mulu(1e18);

        for (uint256 i = 0; i < _length; i++) {
            int128 _bal = Assimilators.viewNumeraireBalanceLPRatio(_baseWeight, _quoteWeight, curve.assets[i].addr);

            balances_[i] = _bal;
            grossLiquidity_ += _bal;
        }

        return (grossLiquidity_, balances_);
    }

    function getGrossLiquidityAndBalances(Storage.Curve storage curve)
        internal
        view
        returns (int128 grossLiquidity_, int128[] memory)
    {
        uint256 _length = curve.assets.length;

        int128[] memory balances_ = new int128[](_length);

        for (uint256 i = 0; i < _length; i++) {
            int128 _bal = Assimilators.viewNumeraireBalance(curve.assets[i].addr);

            balances_[i] = _bal;
            grossLiquidity_ += _bal;
        }

        return (grossLiquidity_, balances_);
    }

    function burn(
        Storage.Curve storage curve,
        address account,
        uint256 amount
    ) private {
        curve.balances[account] = burnSub(curve.balances[account], amount);

        curve.totalSupply = burnSub(curve.totalSupply, amount);

        emit Transfer(msg.sender, address(0), amount);
    }

    function mint(
        Storage.Curve storage curve,
        address account,
        uint256 amount
    ) private {
        uint256 minLock = 1e6;
        if (curve.totalSupply == 0) {
            require(amount > minLock, "Proportional Liquidity/amount too small!");
            uint256 toMintAmt = amount - minLock;
            // mint to lp provider
            curve.totalSupply = mintAdd(curve.totalSupply, toMintAmt);
            curve.balances[account] = mintAdd(
                curve.balances[account],
                toMintAmt
            );
            emit Transfer(address(0), msg.sender, toMintAmt);
            // mint to 0 address
            curve.totalSupply = mintAdd(curve.totalSupply, minLock);
            curve.balances[address(0)] = mintAdd(
                curve.balances[address(0)],
                minLock
            );
            emit Transfer(address(this), address(0), minLock);
        } else {
            curve.totalSupply = mintAdd(curve.totalSupply, amount);
            curve.balances[account] = mintAdd(curve.balances[account], amount);
            emit Transfer(address(0), msg.sender, amount);
        }
    }

    function mintAdd(uint256 x, uint256 y) private pure returns (uint256 z) {
        require((z = x + y) >= x, "Curve/mint-overflow");
    }

    function burnSub(uint256 x, uint256 y) private pure returns (uint256 z) {
        require((z = x - y) <= x, "Curve/burn-underflow");
    }
}

// OpenZeppelin Contracts (last updated v4.6.0) (utils/math/SafeMath.sol)

// CAUTION
// This version of SafeMath should only be used with Solidity 0.8 or later,
// because it relies on the compiler's built in overflow checks.

/**
 * @dev Wrappers over Solidity's arithmetic operations.
 *
 * NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler
 * now has built in overflow checking.
 */
library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            uint256 c = a + b;
            if (c < a) return (false, 0);
            return (true, c);
        }
    }

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

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

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

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

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

    /**
     * @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 a - b;
    }

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

    /**
     * @dev Returns the integer division of two unsigned integers, reverting on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator.
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return a / b;
    }

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

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

    /**
     * @dev Returns the integer division of two unsigned integers, reverting with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * 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) {
        unchecked {
            require(b > 0, errorMessage);
            return a / b;
        }
    }

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

// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// This program is disstributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.

// Finds new Curves! logs their addresses and provides `isCurve(address) -> (bool)`

// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.

interface IFreeFromUpTo {
    function freeFromUpTo(address from, uint256 value) external returns (uint256 freed);
}

// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)

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

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

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor() {
        _transferOwnership(_msgSender());
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        _checkOwner();
        _;
    }

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

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
    }

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

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

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}

// OpenZeppelin Contracts (last updated v4.8.0) (security/ReentrancyGuard.sol)

/**
 * @dev Contract module that helps prevent reentrant calls to a function.
 *
 * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
 * available, which can be applied to functions to make sure there are no nested
 * (reentrant) calls to them.
 *
 * Note that because there is a single `nonReentrant` guard, functions marked as
 * `nonReentrant` may not call one another. This can be worked around by making
 * those functions `private`, and then adding `external` `nonReentrant` entry
 * points to them.
 *
 * TIP: If you would like to learn more about reentrancy and alternative ways
 * to protect against it, check out our blog post
 * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
 */
abstract contract 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() {
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and making it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        _nonReentrantBefore();
        _;
        _nonReentrantAfter();
    }

    function _nonReentrantBefore() private {
        // On the first call to nonReentrant, _status will be _NOT_ENTERED
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

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

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

    /**
     * @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
     * `nonReentrant` function in the call stack.
     */
    function _reentrancyGuardEntered() internal view returns (bool) {
        return _status == _ENTERED;
    }
}

contract CurveFactory is Ownable, ReentrancyGuard {
    event NewCurve(address indexed caller, bytes32 indexed id, address indexed curve);

    mapping(bytes32 => address) public curves;

    function getCurve(address _baseCurrency, address _quoteCurrency) external view returns (address) {
        bytes32 curveId = keccak256(abi.encode(_baseCurrency, _quoteCurrency));
        return (curves[curveId]);
    }

    function newCurve(
        string memory _name,
        string memory _symbol,
        address _baseCurrency,
        address _quoteCurrency,
        uint256 _baseWeight,
        uint256 _quoteWeight,
        address _baseAssimilator,
        address _quoteAssimilator
    ) public nonReentrant onlyOwner returns (Curve) {
        bytes32 curveId = keccak256(abi.encode(_baseCurrency, _quoteCurrency));
        if (curves[curveId] != address(0)) revert("CurveFactory/currency-pair-already-exists");

        address[] memory _assets = new address[](10);
        uint256[] memory _assetWeights = new uint256[](2);

        // Base Currency
        _assets[0] = _baseCurrency;
        _assets[1] = _baseAssimilator;
        _assets[2] = _baseCurrency;
        _assets[3] = _baseAssimilator;
        _assets[4] = _baseCurrency;

        // Quote Currency (typically USDC)
        _assets[5] = _quoteCurrency;
        _assets[6] = _quoteAssimilator;
        _assets[7] = _quoteCurrency;
        _assets[8] = _quoteAssimilator;
        _assets[9] = _quoteCurrency;

        // Weights
        _assetWeights[0] = _baseWeight;
        _assetWeights[1] = _quoteWeight;

        // New curve
        Curve curve = new Curve(_name, _symbol, _assets, _assetWeights, address(this));
        curve.transferOwnership(msg.sender);
        curves[curveId] = address(curve);

        emit NewCurve(msg.sender, curveId, address(curve));

        return curve;
    }
}

library Swaps {
    using ABDKMath64x64 for int128;
    using ABDKMath64x64 for int256;
    using UnsafeMath64x64 for int128;
    using ABDKMath64x64 for uint256;
    using SafeMath for uint256;

    event Trade(
        address indexed trader,
        address indexed origin,
        address indexed target,
        uint256 originAmount,
        uint256 targetAmount,
        int128 rawProtocolFee
    );

    int128 public constant ONE = 0x10000000000000000;

    function getOriginAndTarget(
        Storage.Curve storage curve,
        address _o,
        address _t
    ) private view returns (Storage.Assimilator memory, Storage.Assimilator memory) {
        Storage.Assimilator memory o_ = curve.assimilators[_o];
        Storage.Assimilator memory t_ = curve.assimilators[_t];

        require(o_.addr != address(0), "Curve/origin-not-supported");
        require(t_.addr != address(0), "Curve/target-not-supported");

        return (o_, t_);
    }

    function originSwap(Storage.Curve storage curve, OriginSwapData memory _swapData)
        external
        returns (
            uint256 tAmt_
        )
    {
        (Storage.Assimilator memory _o, Storage.Assimilator memory _t) =
            getOriginAndTarget(curve, _swapData._origin, _swapData._target);

        if (_o.ix == _t.ix)
            return
                Assimilators.outputNumeraire(
                    _t.addr,
                    _swapData._recipient,
                    Assimilators.intakeRaw(_o.addr, _swapData._originAmount)
                );

        SwapInfo memory _swapInfo;
        (int128 _amt, int128 _oGLiq, int128 _nGLiq, int128[] memory _oBals, int128[] memory _nBals) =
            getOriginSwapData(curve, _o.ix, _t.ix, _o.addr, _swapData._originAmount);

        _swapInfo.totalAmount = _amt;

        _amt = CurveMath.calculateTrade(curve, _oGLiq, _nGLiq, _oBals, _nBals, _amt, _t.ix);

        _swapInfo.curveFactory = ICurveFactory(_swapData._curveFactory);
        _swapInfo.amountToUser = _amt.us_mul(ONE - curve.epsilon);
        // _swapInfo.totalFee = _swapInfo.totalAmount + _swapInfo.amountToUser;
        _swapInfo.totalFee = _swapInfo.amountToUser - _amt;
        _swapInfo.protocolFeePercentage = _swapInfo.curveFactory.getProtocolFee();
        _swapInfo.treasury = _swapInfo.curveFactory.getProtocolTreasury();
        _swapInfo.amountToTreasury = _swapInfo.totalFee.muli(_swapInfo.protocolFeePercentage).divi(100000);
        Assimilators.transferFee(_t.addr, _swapInfo.amountToTreasury, _swapInfo.treasury);
        tAmt_ = Assimilators.outputNumeraire(_t.addr, _swapData._recipient, _swapInfo.amountToUser);

        emit Trade(msg.sender, _swapData._origin, _swapData._target, _swapData._originAmount, tAmt_, _swapInfo.amountToTreasury);
    }

    function viewOriginSwap(
        Storage.Curve storage curve,
        address _origin,
        address _target,
        uint256 _originAmount
    ) external view returns (uint256 tAmt_) {
        (Storage.Assimilator memory _o, Storage.Assimilator memory _t) = getOriginAndTarget(curve, _origin, _target);

        if (_o.ix == _t.ix)
            return Assimilators.viewRawAmount(_t.addr, Assimilators.viewNumeraireAmount(_o.addr, _originAmount));

        (int128 _amt, int128 _oGLiq, int128 _nGLiq, int128[] memory _nBals, int128[] memory _oBals) =
            viewOriginSwapData(curve, _o.ix, _t.ix, _originAmount, _o.addr);

        _amt = CurveMath.calculateTrade(curve, _oGLiq, _nGLiq, _oBals, _nBals, _amt, _t.ix);

        _amt = _amt.us_mul(ONE - curve.epsilon);

        tAmt_ = Assimilators.viewRawAmount(_t.addr, _amt.abs());
    }

    function targetSwap(Storage.Curve storage curve, TargetSwapData memory _swapData)
        external
        returns (
            uint256 oAmt_
        )
    {
        (Storage.Assimilator memory _o, Storage.Assimilator memory _t) =
            getOriginAndTarget(curve, _swapData._origin, _swapData._target);

        if (_o.ix == _t.ix)
            return
                Assimilators.intakeNumeraire(
                    _o.addr,
                    Assimilators.outputRaw(_t.addr, _swapData._recipient, _swapData._targetAmount)
                );

        (int128 _amt, int128 _oGLiq, int128 _nGLiq, int128[] memory _oBals, int128[] memory _nBals) =
            getTargetSwapData(curve, _t.ix, _o.ix, _t.addr, _swapData._recipient, _swapData._targetAmount);

        _amt = CurveMath.calculateTrade(curve, _oGLiq, _nGLiq, _oBals, _nBals, _amt, _o.ix);

        SwapInfo memory _swapInfo;

        _swapInfo.totalAmount = _amt;
        _swapInfo.curveFactory = ICurveFactory(_swapData._curveFactory);
        _swapInfo.amountToUser = _amt.us_mul(ONE + curve.epsilon);
        _swapInfo.totalFee = _swapInfo.amountToUser - _amt;
        _swapInfo.protocolFeePercentage = _swapInfo.curveFactory.getProtocolFee();
        _swapInfo.treasury = _swapInfo.curveFactory.getProtocolTreasury();
        _swapInfo.amountToTreasury = _swapInfo.totalFee.muli(_swapInfo.protocolFeePercentage).divi(100000);

        Assimilators.transferFee(_o.addr, _swapInfo.amountToTreasury, _swapInfo.treasury);

        oAmt_ = Assimilators.intakeNumeraire(_o.addr, _swapInfo.amountToUser);

        emit Trade(msg.sender, _swapData._origin, _swapData._target, oAmt_, _swapData._targetAmount, _swapInfo.amountToTreasury);
    }

    function viewTargetSwap(
        Storage.Curve storage curve,
        address _origin,
        address _target,
        uint256 _targetAmount
    ) external view returns (uint256 oAmt_) {
        (Storage.Assimilator memory _o, Storage.Assimilator memory _t) = getOriginAndTarget(curve, _origin, _target);

        if (_o.ix == _t.ix)
            return Assimilators.viewRawAmount(_o.addr, Assimilators.viewNumeraireAmount(_t.addr, _targetAmount));

        (int128 _amt, int128 _oGLiq, int128 _nGLiq, int128[] memory _nBals, int128[] memory _oBals) =
            viewTargetSwapData(curve, _t.ix, _o.ix, _targetAmount, _t.addr);

        _amt = CurveMath.calculateTrade(curve, _oGLiq, _nGLiq, _oBals, _nBals, _amt, _o.ix);

        _amt = _amt.us_mul(ONE + curve.epsilon);

        oAmt_ = Assimilators.viewRawAmount(_o.addr, _amt);
    }

    function getOriginSwapData(
        Storage.Curve storage curve,
        uint256 _inputIx,
        uint256 _outputIx,
        address _assim,
        uint256 _amt
    )
        private
        returns (
            int128 amt_,
            int128 oGLiq_,
            int128 nGLiq_,
            int128[] memory,
            int128[] memory
        )
    {
        uint256 _length = curve.assets.length;

        int128[] memory oBals_ = new int128[](_length);
        int128[] memory nBals_ = new int128[](_length);
        Storage.Assimilator[] memory _reserves = curve.assets;

        for (uint256 i = 0; i < _length; i++) {
            if (i != _inputIx) nBals_[i] = oBals_[i] = Assimilators.viewNumeraireBalance(_reserves[i].addr);
            else {
                int128 _bal;
                (amt_, _bal) = Assimilators.intakeRawAndGetBalance(_assim, _amt);

                oBals_[i] = _bal.sub(amt_);
                nBals_[i] = _bal;
            }

            oGLiq_ += oBals_[i];
            nGLiq_ += nBals_[i];
        }

        nGLiq_ = nGLiq_.sub(amt_);
        nBals_[_outputIx] = ABDKMath64x64.sub(nBals_[_outputIx], amt_);

        return (amt_, oGLiq_, nGLiq_, oBals_, nBals_);
    }

    function getTargetSwapData(
        Storage.Curve storage curve,
        uint256 _inputIx,
        uint256 _outputIx,
        address _assim,
        address _recipient,
        uint256 _amt
    )
        private
        returns (
            int128 amt_,
            int128 oGLiq_,
            int128 nGLiq_,
            int128[] memory,
            int128[] memory
        )
    {
        uint256 _length = curve.assets.length;

        int128[] memory oBals_ = new int128[](_length);
        int128[] memory nBals_ = new int128[](_length);
        Storage.Assimilator[] memory _reserves = curve.assets;

        for (uint256 i = 0; i < _length; i++) {
            if (i != _inputIx) nBals_[i] = oBals_[i] = Assimilators.viewNumeraireBalance(_reserves[i].addr);
            else {
                int128 _bal;
                (amt_, _bal) = Assimilators.outputRawAndGetBalance(_assim, _recipient, _amt);

                oBals_[i] = _bal.sub(amt_);
                nBals_[i] = _bal;
            }

            oGLiq_ += oBals_[i];
            nGLiq_ += nBals_[i];
        }

        nGLiq_ = nGLiq_.sub(amt_);
        nBals_[_outputIx] = ABDKMath64x64.sub(nBals_[_outputIx], amt_);

        return (amt_, oGLiq_, nGLiq_, oBals_, nBals_);
    }

    function viewOriginSwapData(
        Storage.Curve storage curve,
        uint256 _inputIx,
        uint256 _outputIx,
        uint256 _amt,
        address _assim
    )
        private
        view
        returns (
            int128 amt_,
            int128 oGLiq_,
            int128 nGLiq_,
            int128[] memory,
            int128[] memory
        )
    {
        uint256 _length = curve.assets.length;
        int128[] memory nBals_ = new int128[](_length);
        int128[] memory oBals_ = new int128[](_length);

        for (uint256 i = 0; i < _length; i++) {
            if (i != _inputIx) nBals_[i] = oBals_[i] = Assimilators.viewNumeraireBalance(curve.assets[i].addr);
            else {
                int128 _bal;
                (amt_, _bal) = Assimilators.viewNumeraireAmountAndBalance(_assim, _amt);

                oBals_[i] = _bal;
                nBals_[i] = _bal.add(amt_);
            }

            oGLiq_ += oBals_[i];
            nGLiq_ += nBals_[i];
        }

        nGLiq_ = nGLiq_.sub(amt_);
        nBals_[_outputIx] = ABDKMath64x64.sub(nBals_[_outputIx], amt_);

        return (amt_, oGLiq_, nGLiq_, nBals_, oBals_);
    }

    function viewTargetSwapData(
        Storage.Curve storage curve,
        uint256 _inputIx,
        uint256 _outputIx,
        uint256 _amt,
        address _assim
    )
        private
        view
        returns (
            int128 amt_,
            int128 oGLiq_,
            int128 nGLiq_,
            int128[] memory,
            int128[] memory
        )
    {
        uint256 _length = curve.assets.length;
        int128[] memory nBals_ = new int128[](_length);
        int128[] memory oBals_ = new int128[](_length);

        for (uint256 i = 0; i < _length; i++) {
            if (i != _inputIx) nBals_[i] = oBals_[i] = Assimilators.viewNumeraireBalance(curve.assets[i].addr);
            else {
                int128 _bal;
                (amt_, _bal) = Assimilators.viewNumeraireAmountAndBalance(_assim, _amt);
                amt_ = amt_.neg();

                oBals_[i] = _bal;
                nBals_[i] = _bal.add(amt_);
            }

            oGLiq_ += oBals_[i];
            nGLiq_ += nBals_[i];
        }

        nGLiq_ = nGLiq_.sub(amt_);
        nBals_[_outputIx] = ABDKMath64x64.sub(nBals_[_outputIx], amt_);

        return (amt_, oGLiq_, nGLiq_, nBals_, oBals_);
    }
}

// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.

library ViewLiquidity {
    using ABDKMath64x64 for int128;

    function viewLiquidity(Storage.Curve storage curve)
        external
        view
        returns (uint256 total_, uint256[] memory individual_)
    {
        uint256 _length = curve.assets.length;

        individual_ = new uint256[](_length);

        for (uint256 i = 0; i < _length; i++) {
            uint256 _liquidity = Assimilators.viewNumeraireBalance(curve.assets[i].addr).mulu(1e18);

            total_ += _liquidity;
            individual_[i] = _liquidity;
        }

        return (total_, individual_);
    }
}

library Curves {
    using ABDKMath64x64 for int128;

    event Approval(
        address indexed _owner,
        address indexed spender,
        uint256 value
    );
    event Transfer(address indexed from, address indexed to, uint256 value);

    function add(
        uint256 x,
        uint256 y,
        string memory errorMessage
    ) private pure returns (uint256 z) {
        require((z = x + y) >= x, errorMessage);
    }

    function sub(
        uint256 x,
        uint256 y,
        string memory errorMessage
    ) private pure returns (uint256 z) {
        require((z = x - y) <= x, errorMessage);
    }

    /**
     * @dev See {IERC20-transfer}.
     *
     * Requirements:
     *
     * - `recipient` cannot be the zero address.
     * - the caller must have a balance of at least `amount`.
     */
    function transfer(
        Storage.Curve storage curve,
        address recipient,
        uint256 amount
    ) external returns (bool) {
        _transfer(curve, msg.sender, recipient, amount);
        return true;
    }

    /**
     * @dev See {IERC20-approve}.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function approve(
        Storage.Curve storage curve,
        address spender,
        uint256 amount
    ) external returns (bool) {
        _approve(curve, msg.sender, spender, amount);
        return true;
    }

    /**
     * @dev See {IERC20-transferFrom}.
     *
     * Emits an {Approval} event indicating the updated allowance. This is not
     * required by the EIP. See the note at the beginning of {ERC20};
     *
     * Requirements:
     * - `sender` and `recipient` cannot be the zero address.
     * - `sender` must have a balance of at least `amount`.
     * - the caller must have allowance for `sender`'s tokens of at least
     * `amount`
     */
    function transferFrom(
        Storage.Curve storage curve,
        address sender,
        address recipient,
        uint256 amount
    ) external returns (bool) {
        _transfer(curve, sender, recipient, amount);
        _approve(
            curve,
            sender,
            msg.sender,
            sub(
                curve.allowances[sender][msg.sender],
                amount,
                "Curve/insufficient-allowance"
            )
        );
        return true;
    }

    /**
     * @dev Atomically increases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {IERC20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function increaseAllowance(
        Storage.Curve storage curve,
        address spender,
        uint256 addedValue
    ) external returns (bool) {
        _approve(
            curve,
            msg.sender,
            spender,
            add(
                curve.allowances[msg.sender][spender],
                addedValue,
                "Curve/approval-overflow"
            )
        );
        return true;
    }

    /**
     * @dev Atomically decreases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {IERC20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `spender` must have allowance for the caller of at least
     * `subtractedValue`.
     */
    function decreaseAllowance(
        Storage.Curve storage curve,
        address spender,
        uint256 subtractedValue
    ) external returns (bool) {
        _approve(
            curve,
            msg.sender,
            spender,
            sub(
                curve.allowances[msg.sender][spender],
                subtractedValue,
                "Curve/allowance-decrease-underflow"
            )
        );
        return true;
    }

    /**
     * @dev Moves tokens `amount` from `sender` to `recipient`.
     *
     * This is public function is equivalent to {transfer}, and can be used to
     * e.g. implement automatic token fees, slashing mechanisms, etc.
     *
     * Emits a {Transfer} event.
     *
     * Requirements:
     *
     * - `sender` cannot be the zero address.
     * - `recipient` cannot be the zero address.
     * - `sender` must have a balance of at least `amount`.
     */
    function _transfer(
        Storage.Curve storage curve,
        address sender,
        address recipient,
        uint256 amount
    ) private {
        require(sender != address(0), "ERC20: transfer from the zero address");
        require(recipient != address(0), "ERC20: transfer to the zero address");

        curve.balances[sender] = sub(
            curve.balances[sender],
            amount,
            "Curve/insufficient-balance"
        );
        curve.balances[recipient] = add(
            curve.balances[recipient],
            amount,
            "Curve/transfer-overflow"
        );
        emit Transfer(sender, recipient, amount);
    }

    /**
     * @dev Sets `amount` as the allowance of `spender` over the `_owner`s tokens.
     *
     * This is public function is equivalent to `approve`, and can be used to
     * e.g. set automatic allowances for certain subsystems, etc.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `_owner` cannot be the zero address.
     * - `spender` cannot be the zero address.
     */
    function _approve(
        Storage.Curve storage curve,
        address _owner,
        address spender,
        uint256 amount
    ) private {
        require(_owner != address(0), "ERC20: approve from the zero address");
        require(spender != address(0), "ERC20: approve to the zero address");

        curve.allowances[_owner][spender] = amount;
        emit Approval(_owner, spender, amount);
    }
}

contract Curve is Storage, NoDelegateCall {
    using SafeMath for uint256;
    using ABDKMath64x64 for int128;
    using SafeERC20 for IERC20;

    address private curveFactory;

    event Approval(
        address indexed _owner,
        address indexed spender,
        uint256 value
    );

    event ParametersSet(
        uint256 alpha,
        uint256 beta,
        uint256 delta,
        uint256 epsilon,
        uint256 lambda
    );

    event AssetIncluded(
        address indexed numeraire,
        address indexed reserve,
        uint256 weight
    );

    event AssimilatorIncluded(
        address indexed derivative,
        address indexed numeraire,
        address indexed reserve,
        address assimilator
    );

    event PartitionRedeemed(
        address indexed token,
        address indexed redeemer,
        uint256 value
    );

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

    event FrozenSet(bool isFrozen);

    event EmergencyAlarm(bool isEmergency);

    event Trade(
        address indexed trader,
        address indexed origin,
        address indexed target,
        uint256 originAmount,
        uint256 targetAmount,
        int128 rawProtocolFee
    );

    event Transfer(address indexed from, address indexed to, uint256 value);

    event Flash(
        address indexed from,
        address indexed to,
        uint256 value0,
        uint256 value1,
        uint256 paid0,
        uint256 paid1
    );

    modifier onlyOwner() {
        require(msg.sender == owner, "Curve/caller-is-not-owner");
        _;
    }

    modifier nonReentrant() {
        require(notEntered, "Curve/re-entered");
        notEntered = false;
        _;
        notEntered = true;
    }

    modifier transactable() {
        require(!frozen, "Curve/frozen-only-allowing-proportional-withdraw");
        _;
    }

    modifier isEmergency() {
        require(
            emergency,
            "Curve/emergency-only-allowing-emergency-proportional-withdraw"
        );
        _;
    }

    modifier isNotEmergency() {
        require(
            !emergency,
            "Curve/emergency-only-allowing-emergency-proportional-withdraw"
        );
        _;
    }

    modifier deadline(uint256 _deadline) {
        require(block.timestamp < _deadline, "Curve/tx-deadline-passed");
        _;
    }

    modifier globallyTransactable() {
        require(
            !ICurveFactory(address(curveFactory)).getGlobalFrozenState(),
            "Curve/frozen-globally-only-allowing-proportional-withdraw"
        );
        _;
    }

    modifier isFlashable() {
        require(
            ICurveFactory(address(curveFactory)).getFlashableState(),
            "Curve/flashloans-paused"
        );
        _;
    }

    modifier isDepositable(address pool, uint256 deposits) {
        {
            uint256 poolCap = ICurveFactory(curveFactory).getPoolCap(pool);
            uint256 supply = totalSupply();
            require(
                poolCap == 0 || supply.add(deposits) <= poolCap,
                "curve/exceeds pool cap"
            );
        }
        if (!ICurveFactory(curveFactory).isPoolGuarded(pool)) {
            _;
        } else {
            _;
            uint256 poolGuardAmt = ICurveFactory(curveFactory).getPoolGuardAmount(pool);
            require(curve.balances[msg.sender] <= poolGuardAmt, "curve/deposit-exceeds-guard-amt");
        }
    }

    constructor(
        string memory _name,
        string memory _symbol,
        address[] memory _assets,
        uint256[] memory _assetWeights,
        address _factory
    ) {
        require(_factory != address(0), "Curve/curve factory zero address!");
        owner = msg.sender;
        name = _name;
        symbol = _symbol;
        curveFactory = _factory;
        emit OwnershipTransfered(address(0), msg.sender);

        Orchestrator.initialize(
            curve,
            numeraires,
            reserves,
            derivatives,
            _assets,
            _assetWeights
        );
    }

    /// @notice sets the parameters for the pool
    /// @param _alpha the value for alpha (halt threshold) must be less than or equal to 1 and greater than 0
    /// @param _beta the value for beta must be less than alpha and greater than 0
    /// @param _feeAtHalt the maximum value for the fee at the halt point
    /// @param _epsilon the base fee for the pool
    /// @param _lambda the value for lambda must be less than or equal to 1 and greater than zero
    function setParams(
        uint256 _alpha,
        uint256 _beta,
        uint256 _feeAtHalt,
        uint256 _epsilon,
        uint256 _lambda
    ) external onlyOwner {
        Orchestrator.setParams(
            curve,
            _alpha,
            _beta,
            _feeAtHalt,
            _epsilon,
            _lambda
        );
    }

    function setAssimilator(
        address _baseCurrency,
        address _baseAssim,
        address _quoteCurrency,
        address _quoteAssim
    ) external onlyOwner {
        Orchestrator.setAssimilator(
            curve,
            _baseCurrency,
            _baseAssim,
            _quoteCurrency,
            _quoteAssim
        );
    }

    /// @notice excludes an assimilator from the curve
    /// @param _derivative the address of the assimilator to exclude
    function excludeDerivative(address _derivative) external onlyOwner {
        for (uint256 i = 0; i < numeraires.length; i++) {
            if (_derivative == numeraires[i])
                revert("Curve/cannot-delete-numeraire");
            if (_derivative == reserves[i])
                revert("Curve/cannot-delete-reserve");
        }

        delete curve.assimilators[_derivative];
    }

    /// @notice view the current parameters of the curve
    /// @return alpha_ the current alpha value
    ///  beta_ the current beta value
    ///  delta_ the current delta value
    ///  epsilon_ the current epsilon value
    ///  lambda_ the current lambda value
    ///  omega_ the current omega value
    function viewCurve()
        external
        view
        returns (
            uint256 alpha_,
            uint256 beta_,
            uint256 delta_,
            uint256 epsilon_,
            uint256 lambda_
        )
    {
        return Orchestrator.viewCurve(curve);
    }

    function setEmergency(bool _emergency) external onlyOwner {
        emit EmergencyAlarm(_emergency);

        emergency = _emergency;
    }

    function setFrozen(bool _toFreezeOrNotToFreeze) external onlyOwner {
        emit FrozenSet(_toFreezeOrNotToFreeze);

        frozen = _toFreezeOrNotToFreeze;
    }

    function transferOwnership(address _newOwner) external onlyOwner {
        require(
            _newOwner != address(0),
            "Curve/new-owner-cannot-be-zeroth-address"
        );

        emit OwnershipTransfered(owner, _newOwner);

        owner = _newOwner;
    }

    /// @notice swap a dynamic origin amount for a fixed target amount
    /// @param _origin the address of the origin
    /// @param _target the address of the target
    /// @param _originAmount the origin amount
    /// @param _minTargetAmount the minimum target amount
    /// @param _deadline deadline in block number after which the trade will not execute
    /// @return targetAmount_ the amount of target that has been swapped for the origin amount
    function originSwap(
        address _origin,
        address _target,
        uint256 _originAmount,
        uint256 _minTargetAmount,
        uint256 _deadline
    )
        external
        deadline(_deadline)
        globallyTransactable
        transactable
        noDelegateCall
        isNotEmergency
        nonReentrant
        returns (uint256 targetAmount_)
    {
        OriginSwapData memory _swapData;
        _swapData._origin = _origin;
        _swapData._target = _target;
        _swapData._originAmount = _originAmount;
        _swapData._recipient = msg.sender;
        _swapData._curveFactory = curveFactory;
        targetAmount_ = Swaps.originSwap(curve, _swapData);
        // targetAmount_ = Swaps.originSwap(curve, _origin, _target, _originAmount, msg.sender,curveFactory);

        require(
            targetAmount_ >= _minTargetAmount,
            "Curve/below-min-target-amount"
        );
    }

    /// @notice view how much target amount a fixed origin amount will swap for
    /// @param _origin the address of the origin
    /// @param _target the address of the target
    /// @param _originAmount the origin amount
    /// @return targetAmount_ the target amount that would have been swapped for the origin amount
    function viewOriginSwap(
        address _origin,
        address _target,
        uint256 _originAmount
    )
        external
        view
        globallyTransactable
        transactable
        returns (uint256 targetAmount_)
    {
        targetAmount_ = Swaps.viewOriginSwap(
            curve,
            _origin,
            _target,
            _originAmount
        );
    }

    /// @notice swap a dynamic origin amount for a fixed target amount
    /// @param _origin the address of the origin
    /// @param _target the address of the target
    /// @param _maxOriginAmount the maximum origin amount
    /// @param _targetAmount the target amount
    /// @param _deadline deadline in block number after which the trade will not execute
    /// @return originAmount_ the amount of origin that has been swapped for the target
    function targetSwap(
        address _origin,
        address _target,
        uint256 _maxOriginAmount,
        uint256 _targetAmount,
        uint256 _deadline
    )
        external
        deadline(_deadline)
        globallyTransactable
        transactable
        noDelegateCall
        isNotEmergency
        nonReentrant
        returns (uint256 originAmount_)
    {
        TargetSwapData memory _swapData;
        _swapData._origin = _origin;
        _swapData._target = _target;
        _swapData._targetAmount = _targetAmount;
        _swapData._recipient = msg.sender;
        _swapData._curveFactory = curveFactory;
        originAmount_ = Swaps.targetSwap(curve, _swapData);
        // originAmount_ = Swaps.targetSwap(curve, _origin, _target, _targetAmount, msg.sender,curveFactory);

        require(
            originAmount_ <= _maxOriginAmount,
            "Curve/above-max-origin-amount"
        );
    }

    /// @notice view how much of the origin currency the target currency will take
    /// @param _origin the address of the origin
    /// @param _target the address of the target
    /// @param _targetAmount the target amount
    /// @return originAmount_ the amount of target that has been swapped for the origin
    function viewTargetSwap(
        address _origin,
        address _target,
        uint256 _targetAmount
    )
        external
        view
        globallyTransactable
        transactable
        returns (uint256 originAmount_)
    {
        originAmount_ = Swaps.viewTargetSwap(
            curve,
            _origin,
            _target,
            _targetAmount
        );
    }
 
    /// @notice deposit into the pool with no slippage from the numeraire assets the pool supports
    /// @param  _deposit the full amount you want to deposit into the pool which will be divided up evenly amongst
    ///                  the numeraire assets of the pool
    /// @return ( the amount of curves you receive in return for your deposit,
    ///           the amount deposited for each numeraire)
    function deposit(uint256 _deposit,uint256 _minQuoteAmount,uint256 _minBaseAmount,uint256 _maxQuoteAmount, uint256 _maxBaseAmount, uint256 _deadline)
        external
        deadline(_deadline)
        globallyTransactable
        transactable
        nonReentrant
        noDelegateCall
        isNotEmergency
        isDepositable(address(this), _deposit)
        returns (uint256, uint256[] memory)
    {
        require(_deposit >0, "Curve/deposit_below_zero");
        
        // (curvesMinted_,  deposits_)
        DepositData memory _depositData;
        _depositData.deposits = _deposit;
        _depositData.minQuote = _minQuoteAmount;
        _depositData.minBase = _minBaseAmount;
        _depositData.maxQuote = _maxQuoteAmount;
        _depositData.maxBase = _maxBaseAmount;
        (
            uint256 curvesMinted_,
            uint256[] memory deposits_
        ) = ProportionalLiquidity.proportionalDeposit(curve, _depositData);
        return (curvesMinted_, deposits_);
    }

    /// @notice view deposits and curves minted a given deposit would return
    /// @param _deposit the full amount of stablecoins you want to deposit. Divided evenly according to the
    ///                 prevailing proportions of the numeraire assets of the pool
    /// @return (the amount of curves you receive in return for your deposit,
    ///          the amount deposited for each numeraire)
    function viewDeposit(uint256 _deposit)
        external
        view
        globallyTransactable
        transactable
        returns (uint256, uint256[] memory)
    {
        // curvesToMint_, depositsToMake_
        return ProportionalLiquidity.viewProportionalDeposit(curve, _deposit);
    }

    /// @notice  Emergency withdraw tokens in the event that the oracle somehow bugs out
    ///          and no one is able to withdraw due to the invariant check
    /// @param   _curvesToBurn the full amount you want to withdraw from the pool which will be withdrawn from evenly amongst the
    ///                        numeraire assets of the pool
    /// @return withdrawals_ the amonts of numeraire assets withdrawn from the pool
    function emergencyWithdraw(uint256 _curvesToBurn, uint256 _deadline)
        external
        isEmergency
        deadline(_deadline)
        nonReentrant
        noDelegateCall
        returns (uint256[] memory withdrawals_)
    {
        return ProportionalLiquidity.proportionalWithdraw(curve, _curvesToBurn);
    }

    /// @notice  withdrawas amount of curve tokens from the the pool equally from the numeraire assets of the pool with no slippage
    /// @param   _curvesToBurn the full amount you want to withdraw from the pool which will be withdrawn from evenly amongst the
    ///                        numeraire assets of the pool
    /// @return withdrawals_ the amonts of numeraire assets withdrawn from the pool
    function withdraw(uint256 _curvesToBurn, uint256 _deadline)
        external
        deadline(_deadline)
        nonReentrant
        noDelegateCall
        isNotEmergency
        returns (uint256[] memory withdrawals_)
    {
        return ProportionalLiquidity.proportionalWithdraw(curve, _curvesToBurn);
    }

    /// @notice  views the withdrawal information from the pool
    /// @param   _curvesToBurn the full amount you want to withdraw from the pool which will be withdrawn from evenly amongst the
    ///                        numeraire assets of the pool
    /// @return the amonnts of numeraire assets withdrawn from the pool
    function viewWithdraw(uint256 _curvesToBurn)
        external
        view
        globallyTransactable
        transactable
        returns (uint256[] memory)
    {
        return
            ProportionalLiquidity.viewProportionalWithdraw(
                curve,
                _curvesToBurn
            );
    }

    function supportsInterface(bytes4 _interface)
        public
        pure
        returns (bool supports_)
    {
        supports_ =
            this.supportsInterface.selector == _interface || // erc165
            bytes4(0x7f5828d0) == _interface || // eip173
            bytes4(0x36372b07) == _interface; // erc20
    }

    /// @notice transfers curve tokens
    /// @param _recipient the address of where to send the curve tokens
    /// @param _amount the amount of curve tokens to send
    /// @return success_ the success bool of the call
    function transfer(address _recipient, uint256 _amount)
        public
        nonReentrant
        noDelegateCall
        isNotEmergency
        returns (bool success_)
    {
        success_ = Curves.transfer(curve, _recipient, _amount);
    }

    /// @notice transfers curve tokens from one address to another address
    /// @param _sender the account from which the curve tokens will be sent
    /// @param _recipient the account to which the curve tokens will be sent
    /// @param _amount the amount of curve tokens to transfer
    /// @return success_ the success bool of the call
    function transferFrom(
        address _sender,
        address _recipient,
        uint256 _amount
    )
        public
        nonReentrant
        noDelegateCall
        isNotEmergency
        returns (bool success_)
    {
        success_ = Curves.transferFrom(curve, _sender, _recipient, _amount);
    }

    /// @notice approves a user to spend curve tokens on their behalf
    /// @param _spender the account to allow to spend from msg.sender
    /// @param _amount the amount to specify the spender can spend
    /// @return success_ the success bool of this call
    function approve(address _spender, uint256 _amount)
        public
        nonReentrant
        noDelegateCall
        returns (bool success_)
    {
        success_ = Curves.approve(curve, _spender, _amount);
    }

    function flash(
        address recipient,
        uint256 amount0,
        uint256 amount1,
        bytes calldata data
    )
        external
        isFlashable
        globallyTransactable
        nonReentrant
        noDelegateCall
        transactable
        isNotEmergency
    {
        uint256 fee = curve.epsilon.mulu(1e18);

        require(
            IERC20(derivatives[0]).balanceOf(address(this)) > 0,
            "Curve/token0-zero-liquidity-depth"
        );
        require(
            IERC20(derivatives[1]).balanceOf(address(this)) > 0,
            "Curve/token1-zero-liquidity-depth"
        );

        uint256 fee0 = FullMath.mulDivRoundingUp(amount0, fee, 1e18);
        uint256 fee1 = FullMath.mulDivRoundingUp(amount1, fee, 1e18);

        uint256 balance0Before = IERC20(derivatives[0]).balanceOf(
            address(this)
        );
        uint256 balance1Before = IERC20(derivatives[1]).balanceOf(
            address(this)
        );

        if (amount0 > 0)
            IERC20(derivatives[0]).safeTransfer(recipient, amount0);
        if (amount1 > 0)
            IERC20(derivatives[1]).safeTransfer(recipient, amount1);

        IFlashCallback(msg.sender).flashCallback(fee0, fee1, data);

        uint256 balance0After = IERC20(derivatives[0]).balanceOf(address(this));
        uint256 balance1After = IERC20(derivatives[1]).balanceOf(address(this));

        require(
            balance0Before.add(fee0) <= balance0After,
            "Curve/insufficient-token0-returned"
        );
        require(
            balance1Before.add(fee1) <= balance1After,
            "Curve/insufficient-token1-returned"
        );

        // sub is safe because we know balanceAfter is gt balanceBefore by at least fee
        uint256 paid0 = balance0After - balance0Before;
        uint256 paid1 = balance1After - balance1Before;

        IERC20(derivatives[0]).safeTransfer(owner, paid0);
        IERC20(derivatives[1]).safeTransfer(owner, paid1);

        emit Flash(msg.sender, recipient, amount0, amount1, paid0, paid1);
    }

    /// @notice view the curve token balance of a given account
    /// @param _account the account to view the balance of
    /// @return balance_ the curve token ballance of the given account
    function balanceOf(address _account)
        public
        view
        returns (uint256 balance_)
    {
        balance_ = curve.balances[_account];
    }

    /// @notice views the total curve supply of the pool
    /// @return totalSupply_ the total supply of curve tokens
    function totalSupply() public view returns (uint256 totalSupply_) {
        totalSupply_ = curve.totalSupply;
    }

    /// @notice views the total allowance one address has to spend from another address
    /// @param _owner the address of the owner
    /// @param _spender the address of the spender
    /// @return allowance_ the amount the owner has allotted the spender
    function allowance(address _owner, address _spender)
        public
        view
        returns (uint256 allowance_)
    {
        allowance_ = curve.allowances[_owner][_spender];
    }

    /// @notice views the total amount of liquidity in the curve in numeraire value and format - 18 decimals
    /// @return total_ the total value in the curve
    /// @return individual_ the individual values in the curve
    function liquidity()
        public
        view
        returns (uint256 total_, uint256[] memory individual_)
    {
        return ViewLiquidity.viewLiquidity(curve);
    }

    /// @notice view the assimilator address for a derivative
    /// @return assimilator_ the assimilator address
    function assimilator(address _derivative)
        public
        view
        returns (address assimilator_)
    {
        assimilator_ = curve.assimilators[_derivative].addr;
    }
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"string","name":"_name","type":"string"},{"internalType":"string","name":"_symbol","type":"string"},{"internalType":"address[]","name":"_assets","type":"address[]"},{"internalType":"uint256[]","name":"_assetWeights","type":"uint256[]"},{"internalType":"address","name":"_factory","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"numeraire","type":"address"},{"indexed":true,"internalType":"address","name":"reserve","type":"address"},{"indexed":false,"internalType":"uint256","name":"weight","type":"uint256"}],"name":"AssetIncluded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"derivative","type":"address"},{"indexed":true,"internalType":"address","name":"numeraire","type":"address"},{"indexed":true,"internalType":"address","name":"reserve","type":"address"},{"indexed":false,"internalType":"address","name":"assimilator","type":"address"}],"name":"AssimilatorIncluded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"isEmergency","type":"bool"}],"name":"EmergencyAlarm","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value0","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"value1","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"paid0","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"paid1","type":"uint256"}],"name":"Flash","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"isFrozen","type":"bool"}],"name":"FrozenSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransfered","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"alpha","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"beta","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"delta","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"epsilon","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"lambda","type":"uint256"}],"name":"ParametersSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":true,"internalType":"address","name":"redeemer","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"PartitionRedeemed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"trader","type":"address"},{"indexed":true,"internalType":"address","name":"origin","type":"address"},{"indexed":true,"internalType":"address","name":"target","type":"address"},{"indexed":false,"internalType":"uint256","name":"originAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"targetAmount","type":"uint256"},{"indexed":false,"internalType":"int128","name":"rawProtocolFee","type":"int128"}],"name":"Trade","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"address","name":"_spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"allowance_","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_spender","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"success_","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_derivative","type":"address"}],"name":"assimilator","outputs":[{"internalType":"address","name":"assimilator_","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"balance_","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"curve","outputs":[{"internalType":"int128","name":"alpha","type":"int128"},{"internalType":"int128","name":"beta","type":"int128"},{"internalType":"int128","name":"delta","type":"int128"},{"internalType":"int128","name":"epsilon","type":"int128"},{"internalType":"int128","name":"lambda","type":"int128"},{"internalType":"uint256","name":"totalSupply","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_deposit","type":"uint256"},{"internalType":"uint256","name":"_minQuoteAmount","type":"uint256"},{"internalType":"uint256","name":"_minBaseAmount","type":"uint256"},{"internalType":"uint256","name":"_maxQuoteAmount","type":"uint256"},{"internalType":"uint256","name":"_maxBaseAmount","type":"uint256"},{"internalType":"uint256","name":"_deadline","type":"uint256"}],"name":"deposit","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"derivatives","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"emergency","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_curvesToBurn","type":"uint256"},{"internalType":"uint256","name":"_deadline","type":"uint256"}],"name":"emergencyWithdraw","outputs":[{"internalType":"uint256[]","name":"withdrawals_","type":"uint256[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_derivative","type":"address"}],"name":"excludeDerivative","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount0","type":"uint256"},{"internalType":"uint256","name":"amount1","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"flash","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"frozen","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"liquidity","outputs":[{"internalType":"uint256","name":"total_","type":"uint256"},{"internalType":"uint256[]","name":"individual_","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"numeraires","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_origin","type":"address"},{"internalType":"address","name":"_target","type":"address"},{"internalType":"uint256","name":"_originAmount","type":"uint256"},{"internalType":"uint256","name":"_minTargetAmount","type":"uint256"},{"internalType":"uint256","name":"_deadline","type":"uint256"}],"name":"originSwap","outputs":[{"internalType":"uint256","name":"targetAmount_","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"reserves","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_baseCurrency","type":"address"},{"internalType":"address","name":"_baseAssim","type":"address"},{"internalType":"address","name":"_quoteCurrency","type":"address"},{"internalType":"address","name":"_quoteAssim","type":"address"}],"name":"setAssimilator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_emergency","type":"bool"}],"name":"setEmergency","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_toFreezeOrNotToFreeze","type":"bool"}],"name":"setFrozen","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_alpha","type":"uint256"},{"internalType":"uint256","name":"_beta","type":"uint256"},{"internalType":"uint256","name":"_feeAtHalt","type":"uint256"},{"internalType":"uint256","name":"_epsilon","type":"uint256"},{"internalType":"uint256","name":"_lambda","type":"uint256"}],"name":"setParams","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"_interface","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"supports_","type":"bool"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_origin","type":"address"},{"internalType":"address","name":"_target","type":"address"},{"internalType":"uint256","name":"_maxOriginAmount","type":"uint256"},{"internalType":"uint256","name":"_targetAmount","type":"uint256"},{"internalType":"uint256","name":"_deadline","type":"uint256"}],"name":"targetSwap","outputs":[{"internalType":"uint256","name":"originAmount_","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"totalSupply_","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_recipient","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"success_","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_sender","type":"address"},{"internalType":"address","name":"_recipient","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"success_","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"viewCurve","outputs":[{"internalType":"uint256","name":"alpha_","type":"uint256"},{"internalType":"uint256","name":"beta_","type":"uint256"},{"internalType":"uint256","name":"delta_","type":"uint256"},{"internalType":"uint256","name":"epsilon_","type":"uint256"},{"internalType":"uint256","name":"lambda_","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_deposit","type":"uint256"}],"name":"viewDeposit","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_origin","type":"address"},{"internalType":"address","name":"_target","type":"address"},{"internalType":"uint256","name":"_originAmount","type":"uint256"}],"name":"viewOriginSwap","outputs":[{"internalType":"uint256","name":"targetAmount_","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_origin","type":"address"},{"internalType":"address","name":"_target","type":"address"},{"internalType":"uint256","name":"_targetAmount","type":"uint256"}],"name":"viewTargetSwap","outputs":[{"internalType":"uint256","name":"originAmount_","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_curvesToBurn","type":"uint256"}],"name":"viewWithdraw","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_curvesToBurn","type":"uint256"},{"internalType":"uint256","name":"_deadline","type":"uint256"}],"name":"withdraw","outputs":[{"internalType":"uint256[]","name":"withdrawals_","type":"uint256[]"}],"stateMutability":"nonpayable","type":"function"}]

Deployed Bytecode

0x608060405234801561001057600080fd5b506004361061021c5760003560e01c806370a0823111610125578063a8e9d528116100ad578063caa6fea41161007c578063caa6fea414610551578063d828bb8814610563578063dd62ed3e14610576578063e5cf8a5c146105af578063f2fde38b146105c257600080fd5b8063a8e9d52814610505578063a9059cbb14610518578063c0046e391461052b578063c912ff7a1461053e57600080fd5b80637e932d32116100f45780637e932d32146104b15780638334278d146104c4578063838e6a22146104d75780638da5cb5b146104ea57806395d89b41146104fd57600080fd5b806370a08231146103f25780637165485d1461041b57806372b4129a1461048b57806379a390a51461049e57600080fd5b806323b872dd116101a8578063490e6cbc11610177578063490e6cbc14610376578063525d0da7146103895780635872278a1461039c578063595520c7146103af5780636f2ef95b146103df57600080fd5b806323b872dd146102f2578063313ce567146103055780633cae77f71461031f578063441a3e701461036357600080fd5b8063095ea7b3116101ef578063095ea7b3146102805780630b2583c81461029357806318160ddd146102b45780631a686502146102bc5780631f276b6e146102d257600080fd5b806301ffc9a7146102215780630501d55614610249578063054f7d9c1461025e57806306fdde031461026b575b600080fd5b61023461022f366004612e2c565b6105d5565b60405190151581526020015b60405180910390f35b61025c610257366004612e67565b610627565b005b6010546102349060ff1681565b6102736106a9565b6040516102409190612ea8565b61023461028e366004612ef2565b610737565b6102a66102a1366004612f1c565b610819565b604051908152602001610240565b6007546102a6565b6102c4610a7a565b604051610240929190612fa4565b6102e56102e0366004612fbd565b610b00565b6040516102409190612fdf565b610234610300366004612ff2565b610c1f565b61030d601281565b60405160ff9091168152602001610240565b61034b61032d36600461302e565b6001600160a01b039081166000908152600560205260409020541690565b6040516001600160a01b039091168152602001610240565b6102e5610371366004612fbd565b610d31565b61025c610384366004613049565b610db7565b6102a6610397366004612ff2565b611644565b6102c46103aa3660046130dd565b611798565b6103b7611dbc565b604080519586526020860194909452928401919091526060830152608082015260a001610240565b6102c46103ed366004613120565b611e50565b6102a661040036600461302e565b6001600160a01b031660009081526008602052604090205490565b60005460015460025460075461044e93600f81810b94600160801b92839004820b9481830b9493909104820b92910b9086565b60408051600f97880b815295870b602087015293860b9385019390935290840b606084015290920b608082015260a081019190915260c001610240565b6102a6610499366004612f1c565b611f93565b61025c6104ac366004613139565b6121d8565b61025c6104bf366004612e67565b612292565b61034b6104d2366004613120565b612304565b6102a66104e5366004612ff2565b61232e565b600a5461034b906001600160a01b031681565b61027361243d565b61034b610513366004613120565b61244a565b610234610526366004612ef2565b61245a565b61034b610539366004613120565b61250f565b61025c61054c36600461302e565b61251f565b60105461023490610100900460ff1681565b61025c61057136600461318d565b612684565b6102a66105843660046131c8565b6001600160a01b03918216600090815260096020908152604080832093909416825291909152205490565b6102e56105bd366004613120565b61273b565b61025c6105d036600461302e565b612878565b60006301ffc9a760e01b6001600160e01b03198316148061060657506307f5828d60e41b6001600160e01b03198316145b8061062157506336372b0760e01b6001600160e01b03198316145b92915050565b600a546001600160a01b0316331461065a5760405162461bcd60e51b8152600401610651906131fb565b60405180910390fd5b60405181151581527fa44450e52bea871e50cfee059fbe027c26ff43fd7534c06b7de61d90b58ab3c19060200160405180910390a1601080549115156101000261ff0019909216919091179055565b600b80546106b690613232565b80601f01602080910402602001604051908101604052809291908181526020018280546106e290613232565b801561072f5780601f106107045761010080835404028352916020019161072f565b820191906000526020600020905b81548152906001019060200180831161071257829003601f168201915b505050505081565b60105460009062010000900460ff166107625760405162461bcd60e51b81526004016106519061326c565b6010805462ff000019169055610776612965565b60405163e60ac42960e01b8152600060048201526001600160a01b038416602482015260448101839052738dc15673477fc356db21ad8224db41123d3f8ce89063e60ac429906064015b602060405180830381865af41580156107dd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108019190613296565b6010805462ff00001916620100001790559392505050565b60008180421061083b5760405162461bcd60e51b8152600401610651906132b3565b601060039054906101000a90046001600160a01b03166001600160a01b0316636a8e1cd06040518163ffffffff1660e01b8152600401602060405180830381865afa15801561088e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108b29190613296565b156108cf5760405162461bcd60e51b8152600401610651906132ea565b60105460ff16156108f25760405162461bcd60e51b815260040161065190613347565b6108fa612965565b601054610100900460ff16156109225760405162461bcd60e51b815260040161065190613397565b60105462010000900460ff1661094a5760405162461bcd60e51b81526004016106519061326c565b6010805462ff00001916908190556040805160a0810182526001600160a01b038a8116825289811660208301528183018990523360608301526301000000909304909216608083015251630d44e8a560e11b8152737e5739244940cd3c8137ba90b6eb0c139da5f35c90631a89d14a906109cb9060009085906004016133f4565b602060405180830381865af41580156109e8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a0c9190613440565b925084831015610a5e5760405162461bcd60e51b815260206004820152601d60248201527f43757276652f62656c6f772d6d696e2d7461726765742d616d6f756e740000006044820152606401610651565b50506010805462ff000019166201000017905595945050505050565b604051633745793960e11b81526000600482018190529060609073e6c74a83d2b8d1b6a1b46d499cf274dfba647ad390636e8af27290602401600060405180830381865af4158015610ad0573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610af891908101906134ff565b915091509091565b601054606090610100900460ff16610b2a5760405162461bcd60e51b815260040161065190613397565b81804210610b4a5760405162461bcd60e51b8152600401610651906132b3565b60105462010000900460ff16610b725760405162461bcd60e51b81526004016106519061326c565b6010805462ff000019169055610b86612965565b60405163044fd3db60e41b81526000600482015260248101859052732a22a524337c7fa74a121471834981e4fd6e6a5e906344fd3db090604401600060405180830381865af4158015610bdd573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610c059190810190613546565b9150506010805462ff000019166201000017905592915050565b60105460009062010000900460ff16610c4a5760405162461bcd60e51b81526004016106519061326c565b6010805462ff000019169055610c5e612965565b601054610100900460ff1615610c865760405162461bcd60e51b815260040161065190613397565b6040516303a90f6960e31b8152600060048201526001600160a01b0380861660248301528416604482015260648101839052738dc15673477fc356db21ad8224db41123d3f8ce890631d487b4890608401602060405180830381865af4158015610cf4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d189190613296565b6010805462ff0000191662010000179055949350505050565b606081804210610d535760405162461bcd60e51b8152600401610651906132b3565b60105462010000900460ff16610d7b5760405162461bcd60e51b81526004016106519061326c565b6010805462ff000019169055610d8f612965565b601054610100900460ff1615610b865760405162461bcd60e51b815260040161065190613397565b601060039054906101000a90046001600160a01b03166001600160a01b031663d94abcee6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610e0a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e2e9190613296565b610e7a5760405162461bcd60e51b815260206004820152601760248201527f43757276652f666c6173686c6f616e732d7061757365640000000000000000006044820152606401610651565b601060039054906101000a90046001600160a01b03166001600160a01b0316636a8e1cd06040518163ffffffff1660e01b8152600401602060405180830381865afa158015610ecd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ef19190613296565b15610f0e5760405162461bcd60e51b8152600401610651906132ea565b60105462010000900460ff16610f365760405162461bcd60e51b81526004016106519061326c565b6010805462ff000019169055610f4a612965565b60105460ff1615610f6d5760405162461bcd60e51b815260040161065190613347565b601054610100900460ff1615610f955760405162461bcd60e51b815260040161065190613397565b600154600090610fb790600160801b9004600f0b670de0b6b3a764000061299c565b90506000600d600081548110610fcf57610fcf61357b565b6000918252602090912001546040516370a0823160e01b81523060048201526001600160a01b03909116906370a0823190602401602060405180830381865afa158015611020573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110449190613440565b1161109b5760405162461bcd60e51b815260206004820152602160248201527f43757276652f746f6b656e302d7a65726f2d6c69717569646974792d646570746044820152600d60fb1b6064820152608401610651565b6000600d6001815481106110b1576110b161357b565b6000918252602090912001546040516370a0823160e01b81523060048201526001600160a01b03909116906370a0823190602401602060405180830381865afa158015611102573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111269190613440565b1161117d5760405162461bcd60e51b815260206004820152602160248201527f43757276652f746f6b656e312d7a65726f2d6c69717569646974792d646570746044820152600d60fb1b6064820152608401610651565b60006111928683670de0b6b3a7640000612a10565b905060006111a98684670de0b6b3a7640000612a10565b90506000600d6000815481106111c1576111c161357b565b6000918252602090912001546040516370a0823160e01b81523060048201526001600160a01b03909116906370a0823190602401602060405180830381865afa158015611212573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112369190613440565b90506000600d60018154811061124e5761124e61357b565b6000918252602090912001546040516370a0823160e01b81523060048201526001600160a01b03909116906370a0823190602401602060405180830381865afa15801561129f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112c39190613440565b90508815611300576113008a8a600d6000815481106112e4576112e461357b565b6000918252602090912001546001600160a01b03169190612a5b565b871561131f5761131f8a89600d6001815481106112e4576112e461357b565b6040516361c9276b60e11b8152339063c3924ed69061134890879087908c908c90600401613591565b600060405180830381600087803b15801561136257600080fd5b505af1158015611376573d6000803e3d6000fd5b505050506000600d6000815481106113905761139061357b565b6000918252602090912001546040516370a0823160e01b81523060048201526001600160a01b03909116906370a0823190602401602060405180830381865afa1580156113e1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114059190613440565b90506000600d60018154811061141d5761141d61357b565b6000918252602090912001546040516370a0823160e01b81523060048201526001600160a01b03909116906370a0823190602401602060405180830381865afa15801561146e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114929190613440565b90508161149f8588612ab2565b11156114f85760405162461bcd60e51b815260206004820152602260248201527f43757276652f696e73756666696369656e742d746f6b656e302d72657475726e604482015261195960f21b6064820152608401610651565b806115038487612ab2565b111561155c5760405162461bcd60e51b815260206004820152602260248201527f43757276652f696e73756666696369656e742d746f6b656e312d72657475726e604482015261195960f21b6064820152608401610651565b600061156885846135e4565b9050600061157685846135e4565b90506115a6600a60009054906101000a90046001600160a01b031683600d6000815481106112e4576112e461357b565b600a54600d80546115ce926001600160a01b031691849160019081106112e4576112e461357b565b604080518e8152602081018e9052908101839052606081018290526001600160a01b038f169033907fbdbdb71d7860376ba52b25a5028beea23581364a40522f6bcfb86bb1f2dca6339060800160405180910390a350506010805462ff0000191662010000179055505050505050505050505050565b6000601060039054906101000a90046001600160a01b03166001600160a01b0316636a8e1cd06040518163ffffffff1660e01b8152600401602060405180830381865afa158015611699573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116bd9190613296565b156116da5760405162461bcd60e51b8152600401610651906132ea565b60105460ff16156116fd5760405162461bcd60e51b815260040161065190613347565b6040516315be82e960e21b8152600060048201526001600160a01b0380861660248301528416604482015260648101839052737e5739244940cd3c8137ba90b6eb0c139da5f35c906356fa0ba4906084015b602060405180830381865af415801561176c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117909190613440565b949350505050565b60006060828042106117bc5760405162461bcd60e51b8152600401610651906132b3565b601060039054906101000a90046001600160a01b03166001600160a01b0316636a8e1cd06040518163ffffffff1660e01b8152600401602060405180830381865afa15801561180f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118339190613296565b156118505760405162461bcd60e51b8152600401610651906132ea565b60105460ff16156118735760405162461bcd60e51b815260040161065190613347565b60105462010000900460ff1661189b5760405162461bcd60e51b81526004016106519061326c565b6010805462ff0000191690556118af612965565b601054610100900460ff16156118d75760405162461bcd60e51b815260040161065190613397565b60105460405163128be30760e31b81523060048201819052918b91600091630100000090046001600160a01b03169063945f183890602401602060405180830381865afa15801561192c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119509190613440565b9050600061195d60075490565b90508115806119755750816119728285612ab2565b11155b6119ba5760405162461bcd60e51b8152602060048201526016602482015275063757276652f6578636565647320706f6f6c206361760541b6044820152606401610651565b505060105460405163772a650160e01b81526001600160a01b03848116600483015263010000009092049091169063772a650190602401602060405180830381865afa158015611a0e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a329190613296565b611b7d5760008b11611a815760405162461bcd60e51b815260206004820152601860248201527743757276652f6465706f7369745f62656c6f775f7a65726f60401b6044820152606401610651565b611ab36040518060a0016040528060008152602001600081526020016000815260200160008152602001600081525090565b8b8152602081018b815260408083018c8152606084018c8152608085018c81529251629d2ea960e41b8152600060048201819052865160248301529451604482015291516064830152516084820152905160a48201528190732a22a524337c7fa74a121471834981e4fd6e6a5e906309d2ea909060c401600060405180830381865af4158015611b47573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611b6f91908101906134ff565b9098509650611d9b92505050565b60008b11611bc85760405162461bcd60e51b815260206004820152601860248201527743757276652f6465706f7369745f62656c6f775f7a65726f60401b6044820152606401610651565b611bfa6040518060a0016040528060008152602001600081526020016000815260200160008152602001600081525090565b8b8152602081018b815260408083018c8152606084018c8152608085018c81529251629d2ea960e41b8152600060048201819052865160248301529451604482015291516064830152516084820152905160a48201528190732a22a524337c7fa74a121471834981e4fd6e6a5e906309d2ea909060c401600060405180830381865af4158015611c8e573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611cb691908101906134ff565b60105460405163914dbfc160e01b81526001600160a01b038981166004830152939b509199506000955063010000009004909116925063914dbfc19150602401602060405180830381865afa158015611d13573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d379190613440565b33600090815260086020526040902054909150811015611d995760405162461bcd60e51b815260206004820152601f60248201527f63757276652f6465706f7369742d657863656564732d67756172642d616d74006044820152606401610651565b505b50506010805462ff0000191662010000179055509097909650945050505050565b600080600080600073f6a1775ccfdfe2c37b3375798a3cf3b7ded4532d63faa50b5d60006040518263ffffffff1660e01b8152600401611dfe91815260200190565b60a060405180830381865af4158015611e1b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e3f91906135f7565b945094509450945094509091929394565b60006060601060039054906101000a90046001600160a01b03166001600160a01b0316636a8e1cd06040518163ffffffff1660e01b8152600401602060405180830381865afa158015611ea7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ecb9190613296565b15611ee85760405162461bcd60e51b8152600401610651906132ea565b60105460ff1615611f0b5760405162461bcd60e51b815260040161065190613347565b60405163822f39d560e01b81526000600482015260248101849052732a22a524337c7fa74a121471834981e4fd6e6a5e9063822f39d590604401600060405180830381865af4158015611f62573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611f8a91908101906134ff565b91509150915091565b600081804210611fb55760405162461bcd60e51b8152600401610651906132b3565b601060039054906101000a90046001600160a01b03166001600160a01b0316636a8e1cd06040518163ffffffff1660e01b8152600401602060405180830381865afa158015612008573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061202c9190613296565b156120495760405162461bcd60e51b8152600401610651906132ea565b60105460ff161561206c5760405162461bcd60e51b815260040161065190613347565b612074612965565b601054610100900460ff161561209c5760405162461bcd60e51b815260040161065190613397565b60105462010000900460ff166120c45760405162461bcd60e51b81526004016106519061326c565b6010805462ff00001916908190556040805160a0810182526001600160a01b038a811682528981166020830152818301889052336060830152630100000090930490921660808301525163498e2a2560e11b8152737e5739244940cd3c8137ba90b6eb0c139da5f35c9063931c544a906121459060009085906004016133f4565b602060405180830381865af4158015612162573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121869190613440565b925085831115610a5e5760405162461bcd60e51b815260206004820152601d60248201527f43757276652f61626f76652d6d61782d6f726967696e2d616d6f756e740000006044820152606401610651565b600a546001600160a01b031633146122025760405162461bcd60e51b8152600401610651906131fb565b604051632e6ce08560e11b8152600060048201526001600160a01b038086166024830152808516604483015280841660648301528216608482015273f6a1775ccfdfe2c37b3375798a3cf3b7ded4532d90635cd9c10a9060a40160006040518083038186803b15801561227457600080fd5b505af4158015612288573d6000803e3d6000fd5b5050505050505050565b600a546001600160a01b031633146122bc5760405162461bcd60e51b8152600401610651906131fb565b60405181151581527f7c029deaca9b6c66abb68e5f874a812822f0fcaa52a890f980a7ab1afb5edba69060200160405180910390a16010805460ff1916911515919091179055565b600f818154811061231457600080fd5b6000918252602090912001546001600160a01b0316905081565b6000601060039054906101000a90046001600160a01b03166001600160a01b0316636a8e1cd06040518163ffffffff1660e01b8152600401602060405180830381865afa158015612383573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123a79190613296565b156123c45760405162461bcd60e51b8152600401610651906132ea565b60105460ff16156123e75760405162461bcd60e51b815260040161065190613347565b604051637dba2aed60e11b8152600060048201526001600160a01b0380861660248301528416604482015260648101839052737e5739244940cd3c8137ba90b6eb0c139da5f35c9063fb7455da9060840161174f565b600c80546106b690613232565b600e818154811061231457600080fd5b60105460009062010000900460ff166124855760405162461bcd60e51b81526004016106519061326c565b6010805462ff000019169055612499612965565b601054610100900460ff16156124c15760405162461bcd60e51b815260040161065190613397565b60405163a4bcd45960e01b8152600060048201526001600160a01b038416602482015260448101839052738dc15673477fc356db21ad8224db41123d3f8ce89063a4bcd459906064016107c0565b600d818154811061231457600080fd5b600a546001600160a01b031633146125495760405162461bcd60e51b8152600401610651906131fb565b60005b600e5481101561265c57600e81815481106125695761256961357b565b6000918252602090912001546001600160a01b03908116908316036125d05760405162461bcd60e51b815260206004820152601d60248201527f43757276652f63616e6e6f742d64656c6574652d6e756d6572616972650000006044820152606401610651565b600f81815481106125e3576125e361357b565b6000918252602090912001546001600160a01b039081169083160361264a5760405162461bcd60e51b815260206004820152601b60248201527f43757276652f63616e6e6f742d64656c6574652d7265736572766500000000006044820152606401610651565b8061265481613637565b91505061254c565b506001600160a01b0316600090815260056020526040902080546001600160a81b0319169055565b600a546001600160a01b031633146126ae5760405162461bcd60e51b8152600401610651906131fb565b60405163231888b760e01b8152600060048201526024810186905260448101859052606481018490526084810183905260a4810182905273f6a1775ccfdfe2c37b3375798a3cf3b7ded4532d9063231888b79060c40160006040518083038186803b15801561271c57600080fd5b505af4158015612730573d6000803e3d6000fd5b505050505050505050565b6060601060039054906101000a90046001600160a01b03166001600160a01b0316636a8e1cd06040518163ffffffff1660e01b8152600401602060405180830381865afa158015612790573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127b49190613296565b156127d15760405162461bcd60e51b8152600401610651906132ea565b60105460ff16156127f45760405162461bcd60e51b815260040161065190613347565b6040516330771ac760e11b81526000600482015260248101839052732a22a524337c7fa74a121471834981e4fd6e6a5e906360ee358e90604401600060405180830381865af415801561284b573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526106219190810190613546565b919050565b600a546001600160a01b031633146128a25760405162461bcd60e51b8152600401610651906131fb565b6001600160a01b0381166129095760405162461bcd60e51b815260206004820152602860248201527f43757276652f6e65772d6f776e65722d63616e6e6f742d62652d7a65726f74686044820152672d6164647265737360c01b6064820152608401610651565b600a546040516001600160a01b038084169216907f0d18b5fd22306e373229b9439188228edca81207d1667f604daf6cef8aa3ee6790600090a3600a80546001600160a01b0319166001600160a01b0392909216919091179055565b306001600160a01b037f0000000000000000000000003c3badfbf97ec7caebff761694dd642f2c8b11e8161461299a57600080fd5b565b6000816000036129ae57506000610621565b600083600f0b12156129bf57600080fd5b600f83900b6fffffffffffffffffffffffffffffffff8316810260401c90608084901c026001600160c01b038111156129f757600080fd5b60401b8119811115612a0857600080fd5b019392505050565b6000612a1d848484612abe565b905060008280612a2f57612a2f613650565b8486091115612a54576000198110612a4657600080fd5b80612a5081613637565b9150505b9392505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052612aad908490612c37565b505050565b6000612a548284613666565b6000808060001985870985870292508281108382030391505080600003612af75760008411612aec57600080fd5b508290049050612a54565b808411612b0357600080fd5b6000848688098084039381119092039190506000612b2386196001613666565b8616958690049593849004936000819003046001019050612b448184613679565b909317926000612b55876003613679565b6002189050612b648188613679565b612b6f9060026135e4565b612b799082613679565b9050612b858188613679565b612b909060026135e4565b612b9a9082613679565b9050612ba68188613679565b612bb19060026135e4565b612bbb9082613679565b9050612bc78188613679565b612bd29060026135e4565b612bdc9082613679565b9050612be88188613679565b612bf39060026135e4565b612bfd9082613679565b9050612c098188613679565b612c149060026135e4565b612c1e9082613679565b9050612c2a8186613679565b9998505050505050505050565b6000612c8c826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612d099092919063ffffffff16565b805190915015612aad5780806020019051810190612caa9190613296565b612aad5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610651565b6060611790848460008585600080866001600160a01b03168587604051612d309190613690565b60006040518083038185875af1925050503d8060008114612d6d576040519150601f19603f3d011682016040523d82523d6000602084013e612d72565b606091505b5091509150612d8387838387612d8e565b979650505050505050565b60608315612dfd578251600003612df6576001600160a01b0385163b612df65760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610651565b5081611790565b6117908383815115612e125781518083602001fd5b8060405162461bcd60e51b81526004016106519190612ea8565b600060208284031215612e3e57600080fd5b81356001600160e01b031981168114612a5457600080fd5b8015158114612e6457600080fd5b50565b600060208284031215612e7957600080fd5b8135612a5481612e56565b60005b83811015612e9f578181015183820152602001612e87565b50506000910152565b6020815260008251806020840152612ec7816040850160208701612e84565b601f01601f19169190910160400192915050565b80356001600160a01b038116811461287357600080fd5b60008060408385031215612f0557600080fd5b612f0e83612edb565b946020939093013593505050565b600080600080600060a08688031215612f3457600080fd5b612f3d86612edb565b9450612f4b60208701612edb565b94979496505050506040830135926060810135926080909101359150565b600081518084526020808501945080840160005b83811015612f9957815187529582019590820190600101612f7d565b509495945050505050565b8281526040602082015260006117906040830184612f69565b60008060408385031215612fd057600080fd5b50508035926020909101359150565b602081526000612a546020830184612f69565b60008060006060848603121561300757600080fd5b61301084612edb565b925061301e60208501612edb565b9150604084013590509250925092565b60006020828403121561304057600080fd5b612a5482612edb565b60008060008060006080868803121561306157600080fd5b61306a86612edb565b94506020860135935060408601359250606086013567ffffffffffffffff8082111561309557600080fd5b818801915088601f8301126130a957600080fd5b8135818111156130b857600080fd5b8960208285010111156130ca57600080fd5b9699959850939650602001949392505050565b60008060008060008060c087890312156130f657600080fd5b505084359660208601359650604086013595606081013595506080810135945060a0013592509050565b60006020828403121561313257600080fd5b5035919050565b6000806000806080858703121561314f57600080fd5b61315885612edb565b935061316660208601612edb565b925061317460408601612edb565b915061318260608601612edb565b905092959194509250565b600080600080600060a086880312156131a557600080fd5b505083359560208501359550604085013594606081013594506080013592509050565b600080604083850312156131db57600080fd5b6131e483612edb565b91506131f260208401612edb565b90509250929050565b60208082526019908201527f43757276652f63616c6c65722d69732d6e6f742d6f776e657200000000000000604082015260600190565b600181811c9082168061324657607f821691505b60208210810361326657634e487b7160e01b600052602260045260246000fd5b50919050565b60208082526010908201526f10dd5c9d994bdc994b595b9d195c995960821b604082015260600190565b6000602082840312156132a857600080fd5b8151612a5481612e56565b60208082526018908201527f43757276652f74782d646561646c696e652d7061737365640000000000000000604082015260600190565b60208082526039908201527f43757276652f66726f7a656e2d676c6f62616c6c792d6f6e6c792d616c6c6f7760408201527f696e672d70726f706f7274696f6e616c2d776974686472617700000000000000606082015260800190565b60208082526030908201527f43757276652f66726f7a656e2d6f6e6c792d616c6c6f77696e672d70726f706f60408201526f7274696f6e616c2d776974686472617760801b606082015260800190565b6020808252603d908201527f43757276652f656d657267656e63792d6f6e6c792d616c6c6f77696e672d656d60408201527f657267656e63792d70726f706f7274696f6e616c2d7769746864726177000000606082015260800190565b82815260c08101612a54602083018480516001600160a01b0390811683526020808301518216908401526040808301519084015260608083015182169084015260809182015116910152565b60006020828403121561345257600080fd5b5051919050565b634e487b7160e01b600052604160045260246000fd5b600082601f83011261348057600080fd5b8151602067ffffffffffffffff8083111561349d5761349d613459565b8260051b604051601f19603f830116810181811084821117156134c2576134c2613459565b6040529384528581018301938381019250878511156134e057600080fd5b83870191505b84821015612d83578151835291830191908301906134e6565b6000806040838503121561351257600080fd5b82519150602083015167ffffffffffffffff81111561353057600080fd5b61353c8582860161346f565b9150509250929050565b60006020828403121561355857600080fd5b815167ffffffffffffffff81111561356f57600080fd5b6117908482850161346f565b634e487b7160e01b600052603260045260246000fd5b84815283602082015260606040820152816060820152818360808301376000818301608090810191909152601f909201601f191601019392505050565b634e487b7160e01b600052601160045260246000fd5b81810381811115610621576106216135ce565b600080600080600060a0868803121561360f57600080fd5b5050835160208501516040860151606087015160809097015192989197509594509092509050565b600060018201613649576136496135ce565b5060010190565b634e487b7160e01b600052601260045260246000fd5b80820180821115610621576106216135ce565b8082028115828204841417610621576106216135ce565b600082516136a2818460208701612e84565b919091019291505056fea2646970667358221220a7b7aa470f4fce8d3d753a89f985ed3a9115fe874c83044897b789f1fdcdaa2864736f6c63430008110033

Deployed ByteCode Sourcemap

140950:21818:0:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;156846:331;;;;;;:::i;:::-;;:::i;:::-;;;470:14:1;;463:22;445:41;;433:2;418:18;156846:331:0;;;;;;;;147560:143;;;;;;:::i;:::-;;:::i;:::-;;81704:26;;;;;;;;;81473:18;;;:::i;:::-;;;;;;;:::i;158615:222::-;;;;;;:::i;:::-;;:::i;148642:955::-;;;;;;:::i;:::-;;:::i;:::-;;;2576:25:1;;;2564:2;2549:18;148642:955:0;2430:177:1;161458:117:0;161550:17;;161458:117;;162273:180;;;:::i;:::-;;;;;;;;:::i;155108:327::-;;;;;;:::i;:::-;;:::i;:::-;;;;;;;:::i;158021:320::-;;;;;;:::i;:::-;;:::i;81525:35::-;;81558:2;81525:35;;;;;4413:4:1;4401:17;;;4383:36;;4371:2;4356:18;81525:35:0;4241:184:1;162578:187:0;;;;;;:::i;:::-;-1:-1:-1;;;;;162721:31:0;;;162668:20;162721:31;;;:18;:31;;;;;:36;;;162578:187;;;;-1:-1:-1;;;;;4785:32:1;;;4767:51;;4755:2;4740:18;162578:187:0;4621:203:1;155853:321:0;;;;;;:::i;:::-;;:::i;158845:2117::-;;;;;;:::i;:::-;;:::i;152087:403::-;;;;;;:::i;:::-;;:::i;152914:1022::-;;;;;;:::i;:::-;;:::i;147263:289::-;;;:::i;:::-;;;;6423:25:1;;;6479:2;6464:18;;6457:34;;;;6507:18;;;6500:34;;;;6565:2;6550:18;;6543:34;6608:3;6593:19;;6586:35;6410:3;6395:19;147263:289:0;6164:463:1;154353:304:0;;;;;;:::i;:::-;;:::i;161167:162::-;;;;;;:::i;:::-;-1:-1:-1;;;;;161297:24:0;161252:16;161297:24;;;:14;:24;;;;;;;161167:162;81401:18;;;;;;;;;;;;;;;;-1:-1:-1;;;81401:18:0;;;;;;;;;;;;;;;;;;;;;;;;;;;7123:2:1;7112:22;;;7094:41;;7171:22;;;7166:2;7151:18;;7144:50;7230:22;;;7210:18;;;7203:50;;;;7289:22;;;7284:2;7269:18;;7262:50;7349:22;;;7343:3;7328:19;;7321:51;7403:3;7388:19;;7381:35;;;;7081:3;7066:19;81401:18:0;6817:605:1;150803:955:0;;;;;;:::i;:::-;;:::i;146045:359::-;;;;;;:::i;:::-;;:::i;147711:168::-;;;;;;:::i;:::-;;:::i;81638:25::-;;;;;;:::i;:::-;;:::i;149934:403::-;;;;;;:::i;:::-;;:::i;81444:20::-;;;;;-1:-1:-1;;;;;81444:20:0;;;81498;;;:::i;81604:27::-;;;;;;:::i;:::-;;:::i;157412:252::-;;;;;;:::i;:::-;;:::i;81569:28::-;;;;;;:::i;:::-;;:::i;146538:402::-;;;;;;:::i;:::-;;:::i;81737:29::-;;;;;;;;;;;;145678:359;;;;;;:::i;:::-;;:::i;161846:192::-;;;;;;:::i;:::-;-1:-1:-1;;;;;161996:24:0;;;161947:18;161996:24;;;:16;:24;;;;;;;;:34;;;;;;;;;;;;;161846:192;156512:326;;;;;;:::i;:::-;;:::i;147887:282::-;;;;;;:::i;:::-;;:::i;156846:331::-;156940:14;-1:-1:-1;;;;;;;;;156997:45:0;;;;:104;;-1:-1:-1;;;;;;;;;;157069:32:0;;;156997:104;:163;;;-1:-1:-1;;;;;;;;;;157128:32:0;;;156997:163;156972:188;156846:331;-1:-1:-1;;156846:331:0:o;147560:143::-;142598:5;;-1:-1:-1;;;;;142598:5:0;142584:10;:19;142576:57;;;;-1:-1:-1;;;142576:57:0;;;;;;;:::i;:::-;;;;;;;;;147634:26:::1;::::0;470:14:1;;463:22;445:41;;147634:26:0::1;::::0;433:2:1;418:18;147634:26:0::1;;;;;;;147673:9;:22:::0;;;::::1;;;;-1:-1:-1::0;;147673:22:0;;::::1;::::0;;;::::1;::::0;;147560:143::o;81473:18::-;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o;158615:222::-;142704:10;;158747:13;;142704:10;;;;;142696:39;;;;-1:-1:-1;;;142696:39:0;;;;;;;:::i;:::-;142746:10;:18;;-1:-1:-1;;142746:18:0;;;52107:22:::1;:20;:22::i;:::-;158789:40:::2;::::0;-1:-1:-1;;;158789:40:0;;158804:5:::2;158789:40;::::0;::::2;9879:25:1::0;-1:-1:-1;;;;;9940:32:1;;9920:18;;;9913:60;9989:18;;;9982:34;;;158789:6:0::2;::::0;:14:::2;::::0;9852:18:1;;158789:40:0::2;;;;;;;;;;;;;;;;;;::::0;::::2;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;142787:10:::0;:17;;-1:-1:-1;;142787:17:0;;;;;158778:51;158615:222;-1:-1:-1;;;158615:222:0:o;148642:955::-;149003:21;148852:9;143393;143375:15;:27;143367:64;;;;-1:-1:-1;;;143367:64:0;;;;;;;:::i;:::-;143547:12:::1;;;;;;;;;-1:-1:-1::0;;;;;143547:12:0::1;-1:-1:-1::0;;;;;143525:57:0::1;;:59;;;;;;;;;;;;;;;;;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;143524:60;143502:167;;;;-1:-1:-1::0;;;143502:167:0::1;;;;;;;:::i;:::-;142864:6:::2;::::0;::::2;;142863:7;142855:68;;;;-1:-1:-1::0;;;142855:68:0::2;;;;;;;:::i;:::-;52107:22:::3;:20;:22::i;:::-;143193:9:::4;::::0;::::4;::::0;::::4;;;143192:10;143170:121;;;;-1:-1:-1::0;;;143170:121:0::4;;;;;;;:::i;:::-;142704:10:::5;::::0;;;::::5;;;142696:39;;;;-1:-1:-1::0;;;142696:39:0::5;;;;;;;:::i;:::-;142746:10;:18:::0;;-1:-1:-1;;142746:18:0::5;::::0;;;;-1:-1:-1;;;;;;;;;;;;;149084:27:0;;::::6;::::0;;149122;;::::6;-1:-1:-1::0;;;149122:27:0;-1:-1:-1;;;149160:39:0;;;149233:10:::6;-1:-1:-1::0;;;149210:33:0;149280:12;;;::::6;::::0;;::::6;-1:-1:-1::0;;;149254:38:0;149319:34;-1:-1:-1;;;149319:34:0;;:5:::6;::::0;:16:::6;::::0;:34:::6;::::0;-1:-1:-1;;;;149319:34:0::6;;;:::i;:::-;;;;;;;;;;;;;;;;;;::::0;::::6;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;149303:50;;149516:16;149499:13;:33;;149477:112;;;::::0;-1:-1:-1;;;149477:112:0;;13068:2:1;149477:112:0::6;::::0;::::6;13050:21:1::0;13107:2;13087:18;;;13080:30;13146:31;13126:18;;;13119:59;13195:18;;149477:112:0::6;12866:353:1::0;149477:112:0::6;-1:-1:-1::0;;142787:10:0::5;:17:::0;;-1:-1:-1;;142787:17:0::5;::::0;::::5;::::0;;148642:955;;-1:-1:-1;;;;;148642:955:0:o;162273:180::-;162411:34;;-1:-1:-1;;;162411:34:0;;162342:14;162411:34;;;2576:25:1;;;162342:14:0;162358:28;;162411:13;;:27;;2549:18:1;;162411:34:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;162411:34:0;;;;;;;;;;;;:::i;:::-;162404:41;;;;162273:180;;:::o;155108:327::-;143007:9;;155309:29;;143007:9;;;;;142985:120;;;;-1:-1:-1;;;142985:120:0;;;;;;;:::i;:::-;155234:9:::1;143393;143375:15;:27;143367:64;;;;-1:-1:-1::0;;;143367:64:0::1;;;;;;;:::i;:::-;142704:10:::2;::::0;;;::::2;;;142696:39;;;;-1:-1:-1::0;;;142696:39:0::2;;;;;;;:::i;:::-;142746:10;:18:::0;;-1:-1:-1;;142746:18:0::2;::::0;;52107:22:::3;:20;:22::i;:::-;155363:64:::4;::::0;-1:-1:-1;;;155363:64:0;;155406:5:::4;155363:64;::::0;::::4;15101:25:1::0;15142:18;;;15135:34;;;155363:21:0::4;::::0;:42:::4;::::0;15074:18:1;;155363:64:0::4;;;;;;;;;;;;;;;;;::::0;::::4;;;;;;;;;;;;;;;;;::::0;;::::4;-1:-1:-1::0;;155363:64:0::4;::::0;::::4;;::::0;::::4;::::0;;;::::4;::::0;::::4;:::i;:::-;155356:71;;-1:-1:-1::0;142787:10:0::2;:17:::0;;-1:-1:-1;;142787:17:0::2;::::0;::::2;::::0;;155108:327;;-1:-1:-1;;155108:327:0:o;158021:320::-;142704:10;;158235:13;;142704:10;;;;;142696:39;;;;-1:-1:-1;;;142696:39:0;;;;;;;:::i;:::-;142746:10;:18;;-1:-1:-1;;142746:18:0;;;52107:22:::1;:20;:22::i;:::-;143193:9:::2;::::0;::::2;::::0;::::2;;;143192:10;143170:121;;;;-1:-1:-1::0;;;143170:121:0::2;;;;;;;:::i;:::-;158277:56:::3;::::0;-1:-1:-1;;;158277:56:0;;158297:5:::3;158277:56;::::0;::::3;15807:25:1::0;-1:-1:-1;;;;;15906:15:1;;;15886:18;;;15879:43;15958:15;;15938:18;;;15931:43;15990:18;;;15983:34;;;158277:6:0::3;::::0;:19:::3;::::0;15779::1;;158277:56:0::3;;;;;;;;;;;;;;;;;::::0;::::3;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;142787:10:::0;:17;;-1:-1:-1;;142787:17:0;;;;;158266:67;158021:320;-1:-1:-1;;;;158021:320:0:o;155853:321::-;156048:29;155949:9;143393;143375:15;:27;143367:64;;;;-1:-1:-1;;;143367:64:0;;;;;;;:::i;:::-;142704:10:::1;::::0;;;::::1;;;142696:39;;;;-1:-1:-1::0;;;142696:39:0::1;;;;;;;:::i;:::-;142746:10;:18:::0;;-1:-1:-1;;142746:18:0::1;::::0;;52107:22:::2;:20;:22::i;:::-;143193:9:::3;::::0;::::3;::::0;::::3;;;143192:10;143170:121;;;;-1:-1:-1::0;;;143170:121:0::3;;;;;;;:::i;158845:2117::-:0;143775:12;;;;;;;;;-1:-1:-1;;;;;143775:12:0;-1:-1:-1;;;;;143753:54:0;;:56;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;143731:129;;;;-1:-1:-1;;;143731:129:0;;16230:2:1;143731:129:0;;;16212:21:1;16269:2;16249:18;;;16242:30;16308:25;16288:18;;;16281:53;16351:18;;143731:129:0;16028:347:1;143731:129:0;143547:12:::1;;;;;;;;;-1:-1:-1::0;;;;;143547:12:0::1;-1:-1:-1::0;;;;;143525:57:0::1;;:59;;;;;;;;;;;;;;;;;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;143524:60;143502:167;;;;-1:-1:-1::0;;;143502:167:0::1;;;;;;;:::i;:::-;142704:10:::2;::::0;;;::::2;;;142696:39;;;;-1:-1:-1::0;;;142696:39:0::2;;;;;;;:::i;:::-;142746:10;:18:::0;;-1:-1:-1;;142746:18:0::2;::::0;;52107:22:::3;:20;:22::i;:::-;142864:6:::4;::::0;::::4;;142863:7;142855:68;;;;-1:-1:-1::0;;;142855:68:0::4;;;;;;;:::i;:::-;143193:9:::5;::::0;::::5;::::0;::::5;;;143192:10;143170:121;;;;-1:-1:-1::0;;;143170:121:0::5;;;;;;;:::i;:::-;159168:13:::6;::::0;159154:11:::6;::::0;159168:24:::6;::::0;-1:-1:-1;;;159168:13:0;::::6;;;159187:4;159168:18;:24::i;:::-;159154:38;;159277:1;159234:11;159246:1;159234:14;;;;;;;;:::i;:::-;;::::0;;;::::6;::::0;;;::::6;::::0;159227:47:::6;::::0;-1:-1:-1;;;159227:47:0;;159268:4:::6;159227:47;::::0;::::6;4767:51:1::0;-1:-1:-1;;;;;159234:14:0;;::::6;::::0;159227:32:::6;::::0;4740:18:1;;159227:47:0::6;;;;;;;;;;;;;;;;;::::0;::::6;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;:51;159205:134;;;::::0;-1:-1:-1;;;159205:134:0;;16714:2:1;159205:134:0::6;::::0;::::6;16696:21:1::0;16753:2;16733:18;;;16726:30;16792:34;16772:18;;;16765:62;-1:-1:-1;;;16843:18:1;;;16836:31;16884:19;;159205:134:0::6;16512:397:1::0;159205:134:0::6;159422:1;159379:11;159391:1;159379:14;;;;;;;;:::i;:::-;;::::0;;;::::6;::::0;;;::::6;::::0;159372:47:::6;::::0;-1:-1:-1;;;159372:47:0;;159413:4:::6;159372:47;::::0;::::6;4767:51:1::0;-1:-1:-1;;;;;159379:14:0;;::::6;::::0;159372:32:::6;::::0;4740:18:1;;159372:47:0::6;;;;;;;;;;;;;;;;;::::0;::::6;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;:51;159350:134;;;::::0;-1:-1:-1;;;159350:134:0;;17116:2:1;159350:134:0::6;::::0;::::6;17098:21:1::0;17155:2;17135:18;;;17128:30;17194:34;17174:18;;;17167:62;-1:-1:-1;;;17245:18:1;;;17238:31;17286:19;;159350:134:0::6;16914:397:1::0;159350:134:0::6;159497:12;159512:45;159538:7;159547:3;159552:4;159512:25;:45::i;:::-;159497:60;;159568:12;159583:45;159609:7;159618:3;159623:4;159583:25;:45::i;:::-;159568:60;;159641:22;159673:11;159685:1;159673:14;;;;;;;;:::i;:::-;;::::0;;;::::6;::::0;;;::::6;::::0;159666:71:::6;::::0;-1:-1:-1;;;159666:71:0;;159721:4:::6;159666:71;::::0;::::6;4767:51:1::0;-1:-1:-1;;;;;159673:14:0;;::::6;::::0;159666:32:::6;::::0;4740:18:1;;159666:71:0::6;;;;;;;;;;;;;;;;;::::0;::::6;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;159641:96;;159748:22;159780:11;159792:1;159780:14;;;;;;;;:::i;:::-;;::::0;;;::::6;::::0;;;::::6;::::0;159773:71:::6;::::0;-1:-1:-1;;;159773:71:0;;159828:4:::6;159773:71;::::0;::::6;4767:51:1::0;-1:-1:-1;;;;;159780:14:0;;::::6;::::0;159773:32:::6;::::0;4740:18:1;;159773:71:0::6;;;;;;;;;;;;;;;;;::::0;::::6;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;159748:96:::0;-1:-1:-1;159861:11:0;;159857:85:::6;;159887:55;159923:9;159934:7;159894:11;159906:1;159894:14;;;;;;;;:::i;:::-;;::::0;;;::::6;::::0;;;::::6;::::0;-1:-1:-1;;;;;159894:14:0::6;::::0;159887:55;:35:::6;:55::i;:::-;159957:11:::0;;159953:85:::6;;159983:55;160019:9;160030:7;159990:11;160002:1;159990:14;;;;;;;;:::i;159983:55::-;160051:58;::::0;-1:-1:-1;;;160051:58:0;;160066:10:::6;::::0;160051:40:::6;::::0;:58:::6;::::0;160092:4;;160098;;160104;;;;160051:58:::6;;;:::i;:::-;;;;;;;;;;;;;;;;;;::::0;::::6;;;;;;;;;;;;::::0;::::6;;;;;;;;;160122:21;160153:11;160165:1;160153:14;;;;;;;;:::i;:::-;;::::0;;;::::6;::::0;;;::::6;::::0;160146:47:::6;::::0;-1:-1:-1;;;160146:47:0;;160187:4:::6;160146:47;::::0;::::6;4767:51:1::0;-1:-1:-1;;;;;160153:14:0;;::::6;::::0;160146:32:::6;::::0;4740:18:1;;160146:47:0::6;;;;;;;;;;;;;;;;;::::0;::::6;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;160122:71;;160204:21;160235:11;160247:1;160235:14;;;;;;;;:::i;:::-;;::::0;;;::::6;::::0;;;::::6;::::0;160228:47:::6;::::0;-1:-1:-1;;;160228:47:0;;160269:4:::6;160228:47;::::0;::::6;4767:51:1::0;-1:-1:-1;;;;;160235:14:0;;::::6;::::0;160228:32:::6;::::0;4740:18:1;;160228:47:0::6;;;;;;;;;;;;;;;;;::::0;::::6;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;160204:71:::0;-1:-1:-1;160338:13:0;160310:24:::6;:14:::0;160329:4;160310:18:::6;:24::i;:::-;:41;;160288:125;;;::::0;-1:-1:-1;;;160288:125:0;;18056:2:1;160288:125:0::6;::::0;::::6;18038:21:1::0;18095:2;18075:18;;;18068:30;18134:34;18114:18;;;18107:62;-1:-1:-1;;;18185:18:1;;;18178:32;18227:19;;160288:125:0::6;17854:398:1::0;160288:125:0::6;160474:13:::0;160446:24:::6;:14:::0;160465:4;160446:18:::6;:24::i;:::-;:41;;160424:125;;;::::0;-1:-1:-1;;;160424:125:0;;18459:2:1;160424:125:0::6;::::0;::::6;18441:21:1::0;18498:2;18478:18;;;18471:30;18537:34;18517:18;;;18510:62;-1:-1:-1;;;18588:18:1;;;18581:32;18630:19;;160424:125:0::6;18257:398:1::0;160424:125:0::6;160651:13;160667:30;160683:14:::0;160667:13;:30:::6;:::i;:::-;160651:46:::0;-1:-1:-1;160708:13:0::6;160724:30;160740:14:::0;160724:13;:30:::6;:::i;:::-;160708:46;;160767:49;160803:5;;;;;;;;;-1:-1:-1::0;;;;;160803:5:0::6;160810;160774:11;160786:1;160774:14;;;;;;;;:::i;160767:49::-;160863:5;::::0;160834:11:::6;:14:::0;;160827:49:::6;::::0;-1:-1:-1;;;;;160863:5:0::6;::::0;160870;;160863;;160834:14;::::6;;;;;:::i;160827:49::-;160894:60;::::0;;19156:25:1;;;19212:2;19197:18;;19190:34;;;19240:18;;;19233:34;;;19298:2;19283:18;;19276:34;;;-1:-1:-1;;;;;160894:60:0;::::6;::::0;160900:10:::6;::::0;160894:60:::6;::::0;19143:3:1;19128:19;160894:60:0::6;;;;;;;-1:-1:-1::0;;142787:10:0::2;:17:::0;;-1:-1:-1;;142787:17:0::2;::::0;::::2;::::0;;-1:-1:-1;;;;;;;;;;;;158845:2117:0:o;152087:403::-;152304:21;143547:12;;;;;;;;;-1:-1:-1;;;;;143547:12:0;-1:-1:-1;;;;;143525:57:0;;:59;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;143524:60;143502:167;;;;-1:-1:-1;;;143502:167:0;;;;;;;:::i;:::-;142864:6:::1;::::0;::::1;;142863:7;142855:68;;;;-1:-1:-1::0;;;142855:68:0::1;;;;;;;:::i;:::-;152359:123:::2;::::0;-1:-1:-1;;;152359:123:0;;152394:5:::2;152359:123;::::0;::::2;15807:25:1::0;-1:-1:-1;;;;;15906:15:1;;;15886:18;;;15879:43;15958:15;;15938:18;;;15931:43;15990:18;;;15983:34;;;152359:5:0::2;::::0;:20:::2;::::0;15779:19:1;;152359:123:0::2;;;;;;;;;;;;;;;;;;::::0;::::2;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;152343:139:::0;152087:403;-1:-1:-1;;;;152087:403:0:o;152914:1022::-;153298:7;153307:16;153099:9;143393;143375:15;:27;143367:64;;;;-1:-1:-1;;;143367:64:0;;;;;;;:::i;:::-;143547:12:::1;;;;;;;;;-1:-1:-1::0;;;;;143547:12:0::1;-1:-1:-1::0;;;;;143525:57:0::1;;:59;;;;;;;;;;;;;;;;;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;143524:60;143502:167;;;;-1:-1:-1::0;;;143502:167:0::1;;;;;;;:::i;:::-;142864:6:::2;::::0;::::2;;142863:7;142855:68;;;;-1:-1:-1::0;;;142855:68:0::2;;;;;;;:::i;:::-;142704:10:::3;::::0;;;::::3;;;142696:39;;;;-1:-1:-1::0;;;142696:39:0::3;;;;;;;:::i;:::-;142746:10;:18:::0;;-1:-1:-1;;142746:18:0::3;::::0;;52107:22:::4;:20;:22::i;:::-;143193:9:::5;::::0;::::5;::::0;::::5;;;143192:10;143170:121;;;;-1:-1:-1::0;;;143170:121:0::5;;;;;;;:::i;:::-;144001:12:::6;::::0;143987:44:::6;::::0;-1:-1:-1;;;143987:44:0;;153263:4:::6;143987:44;::::0;::::6;4767:51:1::0;;;153263:4:0;153270:8;;143969:15:::6;::::0;144001:12;;::::6;-1:-1:-1::0;;;;;144001:12:0::6;::::0;143987:38:::6;::::0;4740:18:1;;143987:44:0::6;;;;;;;;;;;;;;;;;::::0;::::6;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;143969:62;;144046:14;144063:13;161550:17:::0;;;161458:117;144063:13:::6;144046:30:::0;-1:-1:-1;144117:12:0;;;:47:::6;;-1:-1:-1::0;144157:7:0;144133:20:::6;:6:::0;144144:8;144133:10:::6;:20::i;:::-;:31;;144117:47;144091:131;;;::::0;-1:-1:-1;;;144091:131:0;;19523:2:1;144091:131:0::6;::::0;::::6;19505:21:1::0;19562:2;19542:18;;;19535:30;-1:-1:-1;;;19581:18:1;;;19574:52;19643:18;;144091:131:0::6;19321:346:1::0;144091:131:0::6;-1:-1:-1::0;;144263:12:0::6;::::0;144249:47:::6;::::0;-1:-1:-1;;;144249:47:0;;-1:-1:-1;;;;;4785:32:1;;;144249:47:0::6;::::0;::::6;4767:51:1::0;144263:12:0;;;::::6;::::0;;::::6;::::0;144249:41:::6;::::0;4740:18:1;;144249:47:0::6;;;;;;;;;;;;;;;;;::::0;::::6;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;144244:307;;153359:1:::7;153349:8;:11;153341:48;;;::::0;-1:-1:-1;;;153341:48:0;;19874:2:1;153341:48:0::7;::::0;::::7;19856:21:1::0;19913:2;19893:18;;;19886:30;-1:-1:-1;;;19932:18:1;;;19925:54;19996:18;;153341:48:0::7;19672:348:1::0;153341:48:0::7;153450:31;-1:-1:-1::0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;153450:31:0::7;153492:32:::0;;;153535:21:::7;::::0;::::7;:39:::0;;;153585:20:::7;::::0;;::::7;:37:::0;;;153633:21:::7;::::0;::::7;:39:::0;;;153683:20:::7;::::0;::::7;:37:::0;;;153822:62;;-1:-1:-1;;;153822:62:0;;-1:-1:-1;153822:62:0::7;::::0;::::7;20286:25:1::0;;;20347:13;;20327:18;;;20320:41;20397:22;;20377:18;;;20370:50;20456:22;;20436:18;;;20429:50;20516:22;20495:19;;;20488:51;20576:23;;20555:19;;;20548:52;-1:-1:-1;;153822:21:0::7;::::0;:41:::7;::::0;20258:19:1;;153822:62:0::7;;;;;;;;;;;;;;;;;::::0;::::7;;;;;;;;;;;;;;;;;::::0;;::::7;-1:-1:-1::0;;153822:62:0::7;::::0;::::7;;::::0;::::7;::::0;;;::::7;::::0;::::7;:::i;:::-;153731:153:::0;;-1:-1:-1;153731:153:0;-1:-1:-1;144244:307:0::6;::::0;-1:-1:-1;;;144244:307:0::6;;153359:1:::7;153349:8;:11;153341:48;;;::::0;-1:-1:-1;;;153341:48:0;;19874:2:1;153341:48:0::7;::::0;::::7;19856:21:1::0;19913:2;19893:18;;;19886:30;-1:-1:-1;;;19932:18:1;;;19925:54;19996:18;;153341:48:0::7;19672:348:1::0;153341:48:0::7;153450:31;-1:-1:-1::0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;153450:31:0::7;153492:32:::0;;;153535:21:::7;::::0;::::7;:39:::0;;;153585:20:::7;::::0;;::::7;:37:::0;;;153633:21:::7;::::0;::::7;:39:::0;;;153683:20:::7;::::0;::::7;:37:::0;;;153822:62;;-1:-1:-1;;;153822:62:0;;-1:-1:-1;153822:62:0::7;::::0;::::7;20286:25:1::0;;;20347:13;;20327:18;;;20320:41;20397:22;;20377:18;;;20370:50;20456:22;;20436:18;;;20429:50;20516:22;20495:19;;;20488:51;20576:23;;20555:19;;;20548:52;-1:-1:-1;;153822:21:0::7;::::0;:41:::7;::::0;20258:19:1;;153822:62:0::7;;;;;;;;;;;;;;;;;::::0;::::7;;;;;;;;;;;;;;;;;::::0;;::::7;-1:-1:-1::0;;153822:62:0::7;::::0;::::7;;::::0;::::7;::::0;;;::::7;::::0;::::7;:::i;:::-;144400:12:::6;::::0;144386:52:::6;::::0;-1:-1:-1;;;144386:52:0;;-1:-1:-1;;;;;4785:32:1;;;144386:52:0::6;::::0;::::6;4767:51:1::0;153731:153:0;;-1:-1:-1;153731:153:0;;-1:-1:-1;144363:20:0::6;::::0;-1:-1:-1;144400:12:0;;::::6;::::0;;::::6;::::0;-1:-1:-1;144386:46:0::6;::::0;-1:-1:-1;4740:18:1;;144386:52:0::6;;;;;;;;;;;;;;;;;::::0;::::6;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;144476:10;144461:5;:26:::0;;;:14:::6;:26;::::0;;;;;144363:75;;-1:-1:-1;144461:42:0;-1:-1:-1;144461:42:0::6;144453:86;;;::::0;-1:-1:-1;;;144453:86:0;;20813:2:1;144453:86:0::6;::::0;::::6;20795:21:1::0;20852:2;20832:18;;;20825:30;20891:33;20871:18;;;20864:61;20942:18;;144453:86:0::6;20611:355:1::0;144453:86:0::6;144332:219;144244:307;-1:-1:-1::0;;142787:10:0::3;:17:::0;;-1:-1:-1;;142787:17:0::3;::::0;::::3;::::0;;-1:-1:-1;152914:1022:0;;;;-1:-1:-1;152914:1022:0;-1:-1:-1;;;;;152914:1022:0:o;147263:289::-;147348:14;147377:13;147405:14;147434:16;147465:15;147515:12;:22;147538:5;147515:29;;;;;;;;;;;;;2576:25:1;;2564:2;2549:18;;2430:177;147515:29:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;147508:36;;;;;;;;;;147263:289;;;;;:::o;154353:304::-;154494:7;154503:16;143547:12;;;;;;;;;-1:-1:-1;;;;;143547:12:0;-1:-1:-1;;;;;143525:57:0;;:59;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;143524:60;143502:167;;;;-1:-1:-1;;;143502:167:0;;;;;;;:::i;:::-;142864:6:::1;::::0;::::1;;142863:7;142855:68;;;;-1:-1:-1::0;;;142855:68:0::1;;;;;;;:::i;:::-;154587:62:::2;::::0;-1:-1:-1;;;154587:62:0;;154633:5:::2;154587:62;::::0;::::2;15101:25:1::0;15142:18;;;15135:34;;;154587:21:0::2;::::0;:45:::2;::::0;15074:18:1;;154587:62:0::2;;;;;;;;;;;;;;;;;::::0;::::2;;;;;;;;;;;;;;;;;::::0;;::::2;-1:-1:-1::0;;154587:62:0::2;::::0;::::2;;::::0;::::2;::::0;;;::::2;::::0;::::2;:::i;:::-;154580:69;;;;154353:304:::0;;;:::o;150803:955::-;151164:21;151013:9;143393;143375:15;:27;143367:64;;;;-1:-1:-1;;;143367:64:0;;;;;;;:::i;:::-;143547:12:::1;;;;;;;;;-1:-1:-1::0;;;;;143547:12:0::1;-1:-1:-1::0;;;;;143525:57:0::1;;:59;;;;;;;;;;;;;;;;;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;143524:60;143502:167;;;;-1:-1:-1::0;;;143502:167:0::1;;;;;;;:::i;:::-;142864:6:::2;::::0;::::2;;142863:7;142855:68;;;;-1:-1:-1::0;;;142855:68:0::2;;;;;;;:::i;:::-;52107:22:::3;:20;:22::i;:::-;143193:9:::4;::::0;::::4;::::0;::::4;;;143192:10;143170:121;;;;-1:-1:-1::0;;;143170:121:0::4;;;;;;;:::i;:::-;142704:10:::5;::::0;;;::::5;;;142696:39;;;;-1:-1:-1::0;;;142696:39:0::5;;;;;;;:::i;:::-;142746:10;:18:::0;;-1:-1:-1;;142746:18:0::5;::::0;;;;-1:-1:-1;;;;;;;;;;;;;151245:27:0;;::::6;::::0;;151283;;::::6;-1:-1:-1::0;;;151283:27:0;-1:-1:-1;;;151321:39:0;;;151394:10:::6;-1:-1:-1::0;;;151371:33:0;151441:12;;;::::6;::::0;;::::6;-1:-1:-1::0;;;151415:38:0;151480:34;-1:-1:-1;;;151480:34:0;;:5:::6;::::0;:16:::6;::::0;:34:::6;::::0;-1:-1:-1;;;;151480:34:0::6;;;:::i;:::-;;;;;;;;;;;;;;;;;;::::0;::::6;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;151464:50;;151677:16;151660:13;:33;;151638:112;;;::::0;-1:-1:-1;;;151638:112:0;;21980:2:1;151638:112:0::6;::::0;::::6;21962:21:1::0;22019:2;21999:18;;;21992:30;22058:31;22038:18;;;22031:59;22107:18;;151638:112:0::6;21778:353:1::0;146045:359:0;142598:5;;-1:-1:-1;;;;;142598:5:0;142584:10;:19;142576:57;;;;-1:-1:-1;;;142576:57:0;;;;;;;:::i;:::-;146230:166:::1;::::0;-1:-1:-1;;;146230:166:0;;146272:5:::1;146230:166;::::0;::::1;22423:25:1::0;-1:-1:-1;;;;;22522:15:1;;;22502:18;;;22495:43;22574:15;;;22554:18;;;22547:43;22626:15;;;22606:18;;;22599:43;22679:15;;22658:19;;;22651:44;146230:12:0::1;::::0;:27:::1;::::0;22395:19:1;;146230:166:0::1;;;;;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;::::0;::::1;;;;;;;;;146045:359:::0;;;;:::o;147711:168::-;142598:5;;-1:-1:-1;;;;;142598:5:0;142584:10;:19;142576:57;;;;-1:-1:-1;;;142576:57:0;;;;;;;:::i;:::-;147794:33:::1;::::0;470:14:1;;463:22;445:41;;147794:33:0::1;::::0;433:2:1;418:18;147794:33:0::1;;;;;;;147840:6;:31:::0;;-1:-1:-1;;147840:31:0::1;::::0;::::1;;::::0;;;::::1;::::0;;147711:168::o;81638:25::-;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;81638:25:0;;-1:-1:-1;81638:25:0;:::o;149934:403::-;150151:21;143547:12;;;;;;;;;-1:-1:-1;;;;;143547:12:0;-1:-1:-1;;;;;143525:57:0;;:59;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;143524:60;143502:167;;;;-1:-1:-1;;;143502:167:0;;;;;;;:::i;:::-;142864:6:::1;::::0;::::1;;142863:7;142855:68;;;;-1:-1:-1::0;;;142855:68:0::1;;;;;;;:::i;:::-;150206:123:::2;::::0;-1:-1:-1;;;150206:123:0;;150241:5:::2;150206:123;::::0;::::2;15807:25:1::0;-1:-1:-1;;;;;15906:15:1;;;15886:18;;;15879:43;15958:15;;15938:18;;;15931:43;15990:18;;;15983:34;;;150206:5:0::2;::::0;:20:::2;::::0;15779:19:1;;150206:123:0::2;15548:475:1::0;81498:20:0;;;;;;;:::i;81604:27::-;;;;;;;;;;;;157412:252;142704:10;;157571:13;;142704:10;;;;;142696:39;;;;-1:-1:-1;;;142696:39:0;;;;;;;:::i;:::-;142746:10;:18;;-1:-1:-1;;142746:18:0;;;52107:22:::1;:20;:22::i;:::-;143193:9:::2;::::0;::::2;::::0;::::2;;;143192:10;143170:121;;;;-1:-1:-1::0;;;143170:121:0::2;;;;;;;:::i;:::-;157613:43:::3;::::0;-1:-1:-1;;;157613:43:0;;157629:5:::3;157613:43;::::0;::::3;9879:25:1::0;-1:-1:-1;;;;;9940:32:1;;9920:18;;;9913:60;9989:18;;;9982:34;;;157613:6:0::3;::::0;:15:::3;::::0;9852:18:1;;157613:43:0::3;9649:373:1::0;81569:28:0;;;;;;;;;;;;146538:402;142598:5;;-1:-1:-1;;;;;142598:5:0;142584:10;:19;142576:57;;;;-1:-1:-1;;;142576:57:0;;;;;;;:::i;:::-;146621:9:::1;146616:266;146640:10;:17:::0;146636:21;::::1;146616:266;;;146698:10;146709:1;146698:13;;;;;;;;:::i;:::-;;::::0;;;::::1;::::0;;;::::1;::::0;-1:-1:-1;;;;;146698:13:0;;::::1;146683:28:::0;;::::1;::::0;146679:90:::1;;146730:39;::::0;-1:-1:-1;;;146730:39:0;;22908:2:1;146730:39:0::1;::::0;::::1;22890:21:1::0;22947:2;22927:18;;;22920:30;22986:31;22966:18;;;22959:59;23035:18;;146730:39:0::1;22706:353:1::0;146679:90:0::1;146803:8;146812:1;146803:11;;;;;;;;:::i;:::-;;::::0;;;::::1;::::0;;;::::1;::::0;-1:-1:-1;;;;;146803:11:0;;::::1;146788:26:::0;;::::1;::::0;146784:86:::1;;146833:37;::::0;-1:-1:-1;;;146833:37:0;;23266:2:1;146833:37:0::1;::::0;::::1;23248:21:1::0;23305:2;23285:18;;;23278:30;23344:29;23324:18;;;23317:57;23391:18;;146833:37:0::1;23064:351:1::0;146784:86:0::1;146659:3:::0;::::1;::::0;::::1;:::i;:::-;;;;146616:266;;;-1:-1:-1::0;;;;;;146901:31:0::1;:5;:31:::0;;;:18:::1;:31;::::0;;;;146894:38;;-1:-1:-1;;;;;;146894:38:0;;;146538:402::o;145678:359::-;142598:5;;-1:-1:-1;;;;;142598:5:0;142584:10;:19;142576:57;;;;-1:-1:-1;;;142576:57:0;;;;;;;:::i;:::-;145865:164:::1;::::0;-1:-1:-1;;;145865:164:0;;145902:5:::1;145865:164;::::0;::::1;23875:25:1::0;23916:18;;;23909:34;;;23959:18;;;23952:34;;;24002:18;;;23995:34;;;24045:19;;;24038:35;;;24089:19;;;24082:35;;;145865:12:0::1;::::0;:22:::1;::::0;23847:19:1;;145865:164:0::1;;;;;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;::::0;::::1;;;;;;;;;145678:359:::0;;;;;:::o;156512:326::-;156659:16;143547:12;;;;;;;;;-1:-1:-1;;;;;143547:12:0;-1:-1:-1;;;;;143525:57:0;;:59;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;143524:60;143502:167;;;;-1:-1:-1;;;143502:167:0;;;;;;;:::i;:::-;142864:6:::1;::::0;::::1;;142863:7;142855:68;;;;-1:-1:-1::0;;;142855:68:0::1;;;;;;;:::i;:::-;156713:117:::2;::::0;-1:-1:-1;;;156713:117:0;;156778:5:::2;156713:117;::::0;::::2;15101:25:1::0;15142:18;;;15135:34;;;156713:21:0::2;::::0;:46:::2;::::0;15074:18:1;;156713:117:0::2;;;;;;;;;;;;;;;;;::::0;::::2;;;;;;;;;;;;;;;;;::::0;;::::2;-1:-1:-1::0;;156713:117:0::2;::::0;::::2;;::::0;::::2;::::0;;;::::2;::::0;::::2;:::i;142934:1::-;156512:326:::0;;;:::o;147887:282::-;142598:5;;-1:-1:-1;;;;;142598:5:0;142584:10;:19;142576:57;;;;-1:-1:-1;;;142576:57:0;;;;;;;:::i;:::-;-1:-1:-1;;;;;147985:23:0;::::1;147963:113;;;::::0;-1:-1:-1;;;147963:113:0;;24330:2:1;147963:113:0::1;::::0;::::1;24312:21:1::0;24369:2;24349:18;;;24342:30;24408:34;24388:18;;;24381:62;-1:-1:-1;;;24459:18:1;;;24452:38;24507:19;;147963:113:0::1;24128:404:1::0;147963:113:0::1;148114:5;::::0;148094:37:::1;::::0;-1:-1:-1;;;;;148094:37:0;;::::1;::::0;148114:5:::1;::::0;148094:37:::1;::::0;148114:5:::1;::::0;148094:37:::1;148144:5;:17:::0;;-1:-1:-1;;;;;;148144:17:0::1;-1:-1:-1::0;;;;;148144:17:0;;;::::1;::::0;;;::::1;::::0;;147887:282::o;51900:98::-;51972:4;-1:-1:-1;;;;;51981:8:0;51964:25;;51956:34;;;;;;51900:98::o;26086:529::-;26145:7;26184:1;26189;26184:6;26180:20;;-1:-1:-1;26199:1:0;26192:8;;26180:20;26225:1;26220;:6;;;;26211:16;;;;;;26261:10;;;;26280:34;26276:38;;26252:63;;26320:2;26251:71;;26373:3;26368:8;;;26344:33;-1:-1:-1;;;;;26397:56:0;;;26388:66;;;;;;26470:2;26463:9;26507:71;;26492:86;;;26483:96;;;;;;26595:7;;26086:529;-1:-1:-1;;;26086:529:0:o;50781:325::-;50907:14;50943:25;50950:1;50953;50956:11;50943:6;:25::i;:::-;50934:34;;51011:1;50996:11;50983:25;;;;;:::i;:::-;50993:1;50990;50983:25;:29;50979:120;;;-1:-1:-1;;51037:6:0;:26;51029:35;;;;;;51079:8;;;;:::i;:::-;;;;50979:120;50781:325;;;;;:::o;16075:177::-;16185:58;;;-1:-1:-1;;;;;24861:32:1;;16185:58:0;;;24843:51:1;24910:18;;;;24903:34;;;16185:58:0;;;;;;;;;;24816:18:1;;;;16185:58:0;;;;;;;;-1:-1:-1;;;;;16185:58:0;-1:-1:-1;;;16185:58:0;;;16158:86;;16178:5;;16158:19;:86::i;:::-;16075:177;;;:::o;108798:98::-;108856:7;108883:5;108887:1;108883;:5;:::i;46618:3874::-;46734:14;;;-1:-1:-1;;47250:1:0;47247;47240:20;47290:1;47287;47283:9;47274:18;;47342:5;47338:2;47335:13;47327:5;47323:2;47319:14;47315:34;47306:43;;;47435:5;47444:1;47435:10;47431:185;;47484:1;47470:11;:15;47462:24;;;;;;-1:-1:-1;47539:23:0;;;;-1:-1:-1;47591:13:0;;47431:185;47747:5;47733:11;:19;47725:28;;;;;;48038:17;48116:11;48113:1;48110;48103:25;48293:21;;;;48249:20;;48238:32;;;;48090:38;-1:-1:-1;48479:12:0;48509:16;:12;;48524:1;48509:16;:::i;:::-;48494:32;;48623:22;;;;;48756:16;;;;;49010:1;49006:12;;;49002:23;49027:1;48998:31;;-1:-1:-1;49059:12:0;48998:31;49059:5;:12;:::i;:::-;49050:21;;;;49412:11;49427:15;49431:11;49427:1;:15;:::i;:::-;49446:1;49426:21;;-1:-1:-1;49677:17:0;49426:21;49677:11;:17;:::i;:::-;49673:21;;:1;:21;:::i;:::-;49666:28;;;;:::i;:::-;;-1:-1:-1;49736:17:0;49666:28;49736:11;:17;:::i;:::-;49732:21;;:1;:21;:::i;:::-;49725:28;;;;:::i;:::-;;-1:-1:-1;49796:17:0;49725:28;49796:11;:17;:::i;:::-;49792:21;;:1;:21;:::i;:::-;49785:28;;;;:::i;:::-;;-1:-1:-1;49856:17:0;49785:28;49856:11;:17;:::i;:::-;49852:21;;:1;:21;:::i;:::-;49845:28;;;;:::i;:::-;;-1:-1:-1;49916:17:0;49845:28;49916:11;:17;:::i;:::-;49912:21;;:1;:21;:::i;:::-;49905:28;;;;:::i;:::-;;-1:-1:-1;49977:17:0;49905:28;49977:11;:17;:::i;:::-;49973:21;;:1;:21;:::i;:::-;49966:28;;;;:::i;:::-;;-1:-1:-1;50449:11:0;49966:28;50449:5;:11;:::i;:::-;50440:20;46618:3874;-1:-1:-1;;;;;;;;;46618:3874:0:o;18963:716::-;19387:23;19413:69;19441:4;19413:69;;;;;;;;;;;;;;;;;19421:5;-1:-1:-1;;;;;19413:27:0;;;:69;;;;;:::i;:::-;19497:17;;19387:95;;-1:-1:-1;19497:21:0;19493:179;;19594:10;19583:30;;;;;;;;;;;;:::i;:::-;19575:85;;;;-1:-1:-1;;;19575:85:0;;25453:2:1;19575:85:0;;;25435:21:1;25492:2;25472:18;;;25465:30;25531:34;25511:18;;;25504:62;-1:-1:-1;;;25582:18:1;;;25575:40;25632:19;;19575:85:0;25251:406:1;10145:229:0;10282:12;10314:52;10336:6;10344:4;10350:1;10353:12;10282;11519;11533:23;11560:6;-1:-1:-1;;;;;11560:11:0;11579:5;11586:4;11560:31;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;11518:73;;;;11609:69;11636:6;11644:7;11653:10;11665:12;11609:26;:69::i;:::-;11602:76;11231:455;-1:-1:-1;;;;;;;11231:455:0:o;13804:644::-;13989:12;14018:7;14014:427;;;14046:10;:17;14067:1;14046:22;14042:290;;-1:-1:-1;;;;;7684:19:0;;;14256:60;;;;-1:-1:-1;;;14256:60:0;;26563:2:1;14256:60:0;;;26545:21:1;26602:2;26582:18;;;26575:30;26641:31;26621:18;;;26614:59;26690:18;;14256:60:0;26361:353:1;14256:60:0;-1:-1:-1;14353:10:0;14346:17;;14014:427;14396:33;14404:10;14416:12;15151:17;;:21;15147:388;;15383:10;15377:17;15440:15;15427:10;15423:2;15419:19;15412:44;15147:388;15510:12;15503:20;;-1:-1:-1;;;15503:20:0;;;;;;;;:::i;14:286:1:-;72:6;125:2;113:9;104:7;100:23;96:32;93:52;;;141:1;138;131:12;93:52;167:23;;-1:-1:-1;;;;;;219:32:1;;209:43;;199:71;;266:1;263;256:12;497:118;583:5;576:13;569:21;562:5;559:32;549:60;;605:1;602;595:12;549:60;497:118;:::o;620:241::-;676:6;729:2;717:9;708:7;704:23;700:32;697:52;;;745:1;742;735:12;697:52;784:9;771:23;803:28;825:5;803:28;:::i;866:250::-;951:1;961:113;975:6;972:1;969:13;961:113;;;1051:11;;;1045:18;1032:11;;;1025:39;997:2;990:10;961:113;;;-1:-1:-1;;1108:1:1;1090:16;;1083:27;866:250::o;1121:396::-;1270:2;1259:9;1252:21;1233:4;1302:6;1296:13;1345:6;1340:2;1329:9;1325:18;1318:34;1361:79;1433:6;1428:2;1417:9;1413:18;1408:2;1400:6;1396:15;1361:79;:::i;:::-;1501:2;1480:15;-1:-1:-1;;1476:29:1;1461:45;;;;1508:2;1457:54;;1121:396;-1:-1:-1;;1121:396:1:o;1522:173::-;1590:20;;-1:-1:-1;;;;;1639:31:1;;1629:42;;1619:70;;1685:1;1682;1675:12;1700:254;1768:6;1776;1829:2;1817:9;1808:7;1804:23;1800:32;1797:52;;;1845:1;1842;1835:12;1797:52;1868:29;1887:9;1868:29;:::i;:::-;1858:39;1944:2;1929:18;;;;1916:32;;-1:-1:-1;;;1700:254:1:o;1959:466::-;2054:6;2062;2070;2078;2086;2139:3;2127:9;2118:7;2114:23;2110:33;2107:53;;;2156:1;2153;2146:12;2107:53;2179:29;2198:9;2179:29;:::i;:::-;2169:39;;2227:38;2261:2;2250:9;2246:18;2227:38;:::i;:::-;1959:466;;2217:48;;-1:-1:-1;;;;2312:2:1;2297:18;;2284:32;;2363:2;2348:18;;2335:32;;2414:3;2399:19;;;2386:33;;-1:-1:-1;1959:466:1:o;2612:435::-;2665:3;2703:5;2697:12;2730:6;2725:3;2718:19;2756:4;2785:2;2780:3;2776:12;2769:19;;2822:2;2815:5;2811:14;2843:1;2853:169;2867:6;2864:1;2861:13;2853:169;;;2928:13;;2916:26;;2962:12;;;;2997:15;;;;2889:1;2882:9;2853:169;;;-1:-1:-1;3038:3:1;;2612:435;-1:-1:-1;;;;;2612:435:1:o;3052:332::-;3259:6;3248:9;3241:25;3302:2;3297;3286:9;3282:18;3275:30;3222:4;3322:56;3374:2;3363:9;3359:18;3351:6;3322:56;:::i;3389:248::-;3457:6;3465;3518:2;3506:9;3497:7;3493:23;3489:32;3486:52;;;3534:1;3531;3524:12;3486:52;-1:-1:-1;;3557:23:1;;;3627:2;3612:18;;;3599:32;;-1:-1:-1;3389:248:1:o;3642:261::-;3821:2;3810:9;3803:21;3784:4;3841:56;3893:2;3882:9;3878:18;3870:6;3841:56;:::i;3908:328::-;3985:6;3993;4001;4054:2;4042:9;4033:7;4029:23;4025:32;4022:52;;;4070:1;4067;4060:12;4022:52;4093:29;4112:9;4093:29;:::i;:::-;4083:39;;4141:38;4175:2;4164:9;4160:18;4141:38;:::i;:::-;4131:48;;4226:2;4215:9;4211:18;4198:32;4188:42;;3908:328;;;;;:::o;4430:186::-;4489:6;4542:2;4530:9;4521:7;4517:23;4513:32;4510:52;;;4558:1;4555;4548:12;4510:52;4581:29;4600:9;4581:29;:::i;4829:802::-;4926:6;4934;4942;4950;4958;5011:3;4999:9;4990:7;4986:23;4982:33;4979:53;;;5028:1;5025;5018:12;4979:53;5051:29;5070:9;5051:29;:::i;:::-;5041:39;;5127:2;5116:9;5112:18;5099:32;5089:42;;5178:2;5167:9;5163:18;5150:32;5140:42;;5233:2;5222:9;5218:18;5205:32;5256:18;5297:2;5289:6;5286:14;5283:34;;;5313:1;5310;5303:12;5283:34;5351:6;5340:9;5336:22;5326:32;;5396:7;5389:4;5385:2;5381:13;5377:27;5367:55;;5418:1;5415;5408:12;5367:55;5458:2;5445:16;5484:2;5476:6;5473:14;5470:34;;;5500:1;5497;5490:12;5470:34;5545:7;5540:2;5531:6;5527:2;5523:15;5519:24;5516:37;5513:57;;;5566:1;5563;5556:12;5513:57;4829:802;;;;-1:-1:-1;4829:802:1;;-1:-1:-1;5597:2:1;5589:11;;5619:6;4829:802;-1:-1:-1;;;4829:802:1:o;5636:523::-;5740:6;5748;5756;5764;5772;5780;5833:3;5821:9;5812:7;5808:23;5804:33;5801:53;;;5850:1;5847;5840:12;5801:53;-1:-1:-1;;5873:23:1;;;5943:2;5928:18;;5915:32;;-1:-1:-1;5994:2:1;5979:18;;5966:32;;6045:2;6030:18;;6017:32;;-1:-1:-1;6096:3:1;6081:19;;6068:33;;-1:-1:-1;6148:3:1;6133:19;6120:33;;-1:-1:-1;5636:523:1;-1:-1:-1;5636:523:1:o;6632:180::-;6691:6;6744:2;6732:9;6723:7;6719:23;6715:32;6712:52;;;6760:1;6757;6750:12;6712:52;-1:-1:-1;6783:23:1;;6632:180;-1:-1:-1;6632:180:1:o;7427:409::-;7513:6;7521;7529;7537;7590:3;7578:9;7569:7;7565:23;7561:33;7558:53;;;7607:1;7604;7597:12;7558:53;7630:29;7649:9;7630:29;:::i;:::-;7620:39;;7678:38;7712:2;7701:9;7697:18;7678:38;:::i;:::-;7668:48;;7735:38;7769:2;7758:9;7754:18;7735:38;:::i;:::-;7725:48;;7792:38;7826:2;7815:9;7811:18;7792:38;:::i;:::-;7782:48;;7427:409;;;;;;;:::o;7841:454::-;7936:6;7944;7952;7960;7968;8021:3;8009:9;8000:7;7996:23;7992:33;7989:53;;;8038:1;8035;8028:12;7989:53;-1:-1:-1;;8061:23:1;;;8131:2;8116:18;;8103:32;;-1:-1:-1;8182:2:1;8167:18;;8154:32;;8233:2;8218:18;;8205:32;;-1:-1:-1;8284:3:1;8269:19;8256:33;;-1:-1:-1;7841:454:1;-1:-1:-1;7841:454:1:o;8300:260::-;8368:6;8376;8429:2;8417:9;8408:7;8404:23;8400:32;8397:52;;;8445:1;8442;8435:12;8397:52;8468:29;8487:9;8468:29;:::i;:::-;8458:39;;8516:38;8550:2;8539:9;8535:18;8516:38;:::i;:::-;8506:48;;8300:260;;;;;:::o;8565:349::-;8767:2;8749:21;;;8806:2;8786:18;;;8779:30;8845:27;8840:2;8825:18;;8818:55;8905:2;8890:18;;8565:349::o;8919:380::-;8998:1;8994:12;;;;9041;;;9062:61;;9116:4;9108:6;9104:17;9094:27;;9062:61;9169:2;9161:6;9158:14;9138:18;9135:38;9132:161;;9215:10;9210:3;9206:20;9203:1;9196:31;9250:4;9247:1;9240:15;9278:4;9275:1;9268:15;9132:161;;8919:380;;;:::o;9304:340::-;9506:2;9488:21;;;9545:2;9525:18;;;9518:30;-1:-1:-1;;;9579:2:1;9564:18;;9557:46;9635:2;9620:18;;9304:340::o;10027:245::-;10094:6;10147:2;10135:9;10126:7;10122:23;10118:32;10115:52;;;10163:1;10160;10153:12;10115:52;10195:9;10189:16;10214:28;10236:5;10214:28;:::i;10277:348::-;10479:2;10461:21;;;10518:2;10498:18;;;10491:30;10557:26;10552:2;10537:18;;10530:54;10616:2;10601:18;;10277:348::o;10630:421::-;10832:2;10814:21;;;10871:2;10851:18;;;10844:30;10910:34;10905:2;10890:18;;10883:62;10981:27;10976:2;10961:18;;10954:55;11041:3;11026:19;;10630:421::o;11056:412::-;11258:2;11240:21;;;11297:2;11277:18;;;11270:30;11336:34;11331:2;11316:18;;11309:62;-1:-1:-1;;;11402:2:1;11387:18;;11380:46;11458:3;11443:19;;11056:412::o;11473:425::-;11675:2;11657:21;;;11714:2;11694:18;;;11687:30;11753:34;11748:2;11733:18;;11726:62;11824:31;11819:2;11804:18;;11797:59;11888:3;11873:19;;11473:425::o;12305:367::-;12572:25;;;12559:3;12544:19;;12606:60;12662:2;12647:18;;12639:6;12025:12;;-1:-1:-1;;;;;12021:21:1;;;12009:34;;12096:4;12085:16;;;12079:23;12075:32;;12059:14;;;12052:56;12157:4;12146:16;;;12140:23;12124:14;;;12117:47;12217:4;12206:16;;;12200:23;12196:32;;12180:14;;;12173:56;12282:4;12271:16;;;12265:23;12261:32;12245:14;;12238:56;11903:397;12677:184;12747:6;12800:2;12788:9;12779:7;12775:23;12771:32;12768:52;;;12816:1;12813;12806:12;12768:52;-1:-1:-1;12839:16:1;;12677:184;-1:-1:-1;12677:184:1:o;13434:127::-;13495:10;13490:3;13486:20;13483:1;13476:31;13526:4;13523:1;13516:15;13550:4;13547:1;13540:15;13566:899;13631:5;13684:3;13677:4;13669:6;13665:17;13661:27;13651:55;;13702:1;13699;13692:12;13651:55;13731:6;13725:13;13757:4;13780:18;13817:2;13813;13810:10;13807:36;;;13823:18;;:::i;:::-;13869:2;13866:1;13862:10;13901:2;13895:9;13964:2;13960:7;13955:2;13951;13947:11;13943:25;13935:6;13931:38;14019:6;14007:10;14004:22;13999:2;13987:10;13984:18;13981:46;13978:72;;;14030:18;;:::i;:::-;14066:2;14059:22;14116:18;;;14192:15;;;14188:24;;;14150:15;;;;-1:-1:-1;14224:15:1;;;14221:35;;;14252:1;14249;14242:12;14221:35;14288:2;14280:6;14276:15;14265:26;;14300:135;14316:6;14311:3;14308:15;14300:135;;;14382:10;;14370:23;;14413:12;;;;14333;;;;14300:135;;14470:424;14574:6;14582;14635:2;14623:9;14614:7;14610:23;14606:32;14603:52;;;14651:1;14648;14641:12;14603:52;14680:9;14674:16;14664:26;;14734:2;14723:9;14719:18;14713:25;14761:18;14753:6;14750:30;14747:50;;;14793:1;14790;14783:12;14747:50;14816:72;14880:7;14871:6;14860:9;14856:22;14816:72;:::i;:::-;14806:82;;;14470:424;;;;;:::o;15180:363::-;15275:6;15328:2;15316:9;15307:7;15303:23;15299:32;15296:52;;;15344:1;15341;15334:12;15296:52;15377:9;15371:16;15410:18;15402:6;15399:30;15396:50;;;15442:1;15439;15432:12;15396:50;15465:72;15529:7;15520:6;15509:9;15505:22;15465:72;:::i;16380:127::-;16441:10;16436:3;16432:20;16429:1;16422:31;16472:4;16469:1;16462:15;16496:4;16493:1;16486:15;17316:533;17529:6;17518:9;17511:25;17572:6;17567:2;17556:9;17552:18;17545:34;17615:2;17610;17599:9;17595:18;17588:30;17654:6;17649:2;17638:9;17634:18;17627:34;17712:6;17704;17698:3;17687:9;17683:19;17670:49;17769:1;17739:22;;;17763:3;17735:32;;;17728:43;;;;17832:2;17811:15;;;-1:-1:-1;;17807:29:1;17792:45;17788:55;;17316:533;-1:-1:-1;;;17316:533:1:o;18660:127::-;18721:10;18716:3;18712:20;18709:1;18702:31;18752:4;18749:1;18742:15;18776:4;18773:1;18766:15;18792:128;18859:9;;;18880:11;;;18877:37;;;18894:18;;:::i;20971:430::-;21077:6;21085;21093;21101;21109;21162:3;21150:9;21141:7;21137:23;21133:33;21130:53;;;21179:1;21176;21169:12;21130:53;-1:-1:-1;;21202:16:1;;21258:2;21243:18;;21237:25;21302:2;21287:18;;21281:25;21346:2;21331:18;;21325:25;21390:3;21375:19;;;21369:26;21202:16;;21237:25;;-1:-1:-1;21281:25:1;21325;-1:-1:-1;21369:26:1;;-1:-1:-1;20971:430:1;-1:-1:-1;20971:430:1:o;23420:135::-;23459:3;23480:17;;;23477:43;;23500:18;;:::i;:::-;-1:-1:-1;23547:1:1;23536:13;;23420:135::o;24537:127::-;24598:10;24593:3;24589:20;24586:1;24579:31;24629:4;24626:1;24619:15;24653:4;24650:1;24643:15;24948:125;25013:9;;;25034:10;;;25031:36;;;25047:18;;:::i;25078:168::-;25151:9;;;25182;;25199:15;;;25193:22;;25179:37;25169:71;;25220:18;;:::i;26069:287::-;26198:3;26236:6;26230:13;26252:66;26311:6;26306:3;26299:4;26291:6;26287:17;26252:66;:::i;:::-;26334:16;;;;;26069:287;-1:-1:-1;;26069:287:1:o

Metadata Hash

ipfs://a7b7aa470f4fce8d3d753a89f985ed3a9115fe874c83044897b789f1fdcdaa28
Loading