ETH Price: $3,496.61 (+2.84%)
Gas: 10 Gwei

Contract

0xC48782b432df53De02Cb75501A8bB38D063b8928
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Token Holdings

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
0x60a06040195695962024-04-02 17:29:47105 days ago1712078987IN
 Create: CurveHandler
0 ETH0.097724440

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
CurveHandler

Compiler Version
v0.8.17+commit.8df45f5f

Optimization Enabled:
Yes with 200 runs

Other Settings:
london EvmVersion, GNU GPLv3 license
File 1 of 35 : CurveHandler.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.17;

import "SafeERC20.sol";
import "IERC20.sol";

import "ILpToken.sol";
import "ICurveHandler.sol";
import "ICurveRegistryCache.sol";
import "IWETH.sol";
import "ICurvePoolV1.sol";
import "ICurvePoolV0.sol";
import "ICurvePoolV2.sol";
import "ICurvePoolV7.sol";
import "ICurvePoolV1Eth.sol";
import "ICurvePoolV2Eth.sol";
import "IController.sol";

import "StringUtils.sol";

/// @notice This contract acts as a wrapper for depositing and removing liquidity to and from Curve pools.
/// Please be aware of the following:
/// - This contract accepts WETH and unwraps it for Curve pool deposits
/// - This contract should only be used through delegate calls for deposits and withdrawals
/// - Slippage from deposits and withdrawals is handled in the ConicPool (do not use handler elsewhere)
contract CurveHandler is ICurveHandler {
    using SafeERC20 for IERC20;

    address internal constant _ETH_ADDRESS = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
    IWETH internal constant _WETH = IWETH(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2);

    // Normal calls to `exchange` functions will read various state variables, resulting in
    // gas fees that are always in the double-digit thousand gas.
    // On the other hand, a reentrant call will only read a single warm variable (100 gas)
    // and call a contract already touched, so it will use vastly less than 5k gas.
    // In practice, reentrant calls appear to use ~1.5k gas while non-reentrant
    // calls use ~60k gas.
    // We are better off setting this value a little too high compared to the ~1.5k estimate
    // to make sure that we always prevent reentrant calls.
    uint256 internal constant LOCK_GAS_THRESHOLD = 5_000;

    // Recent factory pools are deployed using a minimal proxy pattern pointing to
    // 1. `0x847ee1227a9900b73aeeb3a47fac92c52fd54ed9`
    // 2. `0x94b4dfd9ba5865cc931195c99a2db42f3fc5d45b`
    // The exact bytecodes are:
    // 1. `0x363d3d373d3d3d363d73847ee1227a9900b73aeeb3a47fac92c52fd54ed95af43d82803e903d91602b57fd5bf3`
    // 2. `0x363d3d373d3d3d363d7394b4dfd9ba5865cc931195c99a2db42f3fc5d45b5af43d82803e903d91602b57fd5bf3`
    // that yield the following hashes, against which we can compare the result of `EXTCODEHASH` to
    // check whether it is from this factory or not.
    // This check is very local, so we do not include it in the `CurveRegistryCache`.
    // Note that other pools may have `price_oracle` that do not check for reentrancy, so we cannot
    // rely on this check for any pool with the `price_oracle` function.
    // We only include the hash codes of pools created through factories, because
    // the bytecode is otherwise slightly different for each pool
    // Since this is only an optimization for gas purposes, we choose to make this constant,
    // even if that means that we might miss this optimization for new factories deployed later.
    bytes32 internal constant ETH_FACTORY_POOL_CODE_HASH_1 =
        0x9e28a09452d2354fc4e15e3244dde27cbc4d52f12a10b91f2ca755b672bfa9be;
    bytes32 internal constant ETH_FACTORY_POOL_CODE_HASH_2 =
        0x3429b8decaf6b79a2721e434f60c3c47b9961fdba16eb6ac6c50d3690ac25276;

    IController internal immutable controller;

    constructor(address controller_) {
        controller = IController(controller_);
    }

    /// @notice Deposits single sided liquidity into a Curve pool
    /// @dev This supports both v1 and v2 (crypto) pools.
    /// @param _curvePool Curve pool to deposit into
    /// @param _token Asset to deposit
    /// @param _amount Amount of asset to deposit
    function deposit(address _curvePool, address _token, uint256 _amount) public override {
        ICurveRegistryCache registry_ = controller.curveRegistryCache();
        bool isETH = _isETH(_curvePool, _token);
        if (!registry_.hasCoinDirectly(_curvePool, isETH ? _ETH_ADDRESS : _token)) {
            address intermediate = registry_.basePool(_curvePool);
            require(intermediate != address(0), "CurveHandler: intermediate not found");
            address lpToken = registry_.lpToken(intermediate);
            uint256 balanceBefore = ILpToken(lpToken).balanceOf(address(this));
            _addLiquidity(intermediate, _amount, _token);
            _token = lpToken;
            _amount = ILpToken(_token).balanceOf(address(this)) - balanceBefore;
        }
        _addLiquidity(_curvePool, _amount, _token);
    }

    /// @notice Withdraws single sided liquidity from a Curve pool
    /// @param _curvePool Curve pool to withdraw from
    /// @param _token Underlying asset to withdraw
    /// @param _amount Amount of Curve LP tokens to withdraw
    function withdraw(address _curvePool, address _token, uint256 _amount) external override {
        ICurveRegistryCache registry_ = controller.curveRegistryCache();
        bool isETH = _isETH(_curvePool, _token);
        if (!registry_.hasCoinDirectly(_curvePool, isETH ? _ETH_ADDRESS : _token)) {
            address intermediate = registry_.basePool(_curvePool);
            require(intermediate != address(0), "CurveHandler: intermediate not found");
            address lpToken = registry_.lpToken(intermediate);
            uint256 balanceBefore = ILpToken(lpToken).balanceOf(address(this));
            _removeLiquidity(_curvePool, _amount, lpToken);
            _curvePool = intermediate;
            _amount = ILpToken(lpToken).balanceOf(address(this)) - balanceBefore;
        }

        _removeLiquidity(_curvePool, _amount, _token);
    }

    function isReentrantCall(address _curvePool) public override returns (bool) {
        // In this version, curve pools have a price oracle that has a reentrancy lock
        // so this call will only succeed if we are not in a reentrant call
        // This is cheaper than trying to do an exchange
        bytes32 codeHash = _curvePool.codehash;
        if (codeHash == ETH_FACTORY_POOL_CODE_HASH_1 || codeHash == ETH_FACTORY_POOL_CODE_HASH_2) {
            try ICurvePoolV2Eth(_curvePool).price_oracle() {
                return false;
            } catch {
                return true;
            }
        }

        uint256 interfaceVersion_ = controller.curveRegistryCache().interfaceVersion(_curvePool);
        bool ethIndexFirst_ = _isEthIndexFirst(_curvePool);

        // If we don't have any other way to check for reentrancy, we try to do a swap
        // with 0 amount, which can behave in 3 ways depending on the state and the pool:
        // 1. If it succeeds, there was definitely no lock in place, so the call is not reentrant
        // 2. If it fails, it can fail in 2 ways:
        //   a. It fails because some pools do not allow to swap 0 amount. This also means that the call is non-reentrant
        //   b. It fails because there is a reentrancy lock in place, which means that the call is reentrant
        // Checking for case 1 is trivial. For case 2a vs 2b, we check the amount of gas consumed by the call.
        // Some more details about the values are given in the comments of `LOCK_GAS_THRESHOLD`
        uint256 gasUsed;
        uint256 currentGasLeft = gasleft();
        if (interfaceVersion_ == 2) {
            try
                ICurvePoolV2Eth(_curvePool).exchange(
                    ethIndexFirst_ ? uint256(0) : uint256(1),
                    ethIndexFirst_ ? uint256(1) : uint256(0),
                    uint256(0),
                    uint256(0)
                )
            {
                return false;
            } catch {
                gasUsed = currentGasLeft - gasleft();
            }
        } else {
            try
                ICurvePoolV1Eth(_curvePool).exchange(
                    ethIndexFirst_ ? int128(0) : int128(1),
                    ethIndexFirst_ ? int128(1) : int128(0),
                    uint256(0),
                    uint256(0)
                )
            {
                return false;
            } catch {
                gasUsed = currentGasLeft - gasleft();
            }
        }

        return gasUsed < LOCK_GAS_THRESHOLD;
    }

    /// @notice Validates if a given Curve pool is currently in reentrancy
    /// @dev Reverts if it is in reentrancy
    /// @param _curvePool Curve pool to validate
    function reentrancyCheck(address _curvePool) external override {
        require(!isReentrantCall(_curvePool), "CurveHandler: reentrant call");
    }

    function _removeLiquidity(
        address _curvePool,
        uint256 _amount, // Curve LP token amount
        address _token // underlying asset to withdraw
    ) internal {
        bool isETH = _isETH(_curvePool, _token);
        int128 index = controller.curveRegistryCache().coinIndex(
            _curvePool,
            isETH ? _ETH_ADDRESS : _token
        );

        uint256 balanceBeforeWithdraw = address(this).balance;

        uint256 interfaceVersion_ = controller.curveRegistryCache().interfaceVersion(_curvePool);
        if (interfaceVersion_ == 0) {
            _version_0_remove_liquidity_one_coin(_curvePool, _amount, index);
        } else if (_hasDynamicAddLiquidity(_curvePool)) {
            ICurvePoolV7(_curvePool).remove_liquidity_one_coin(_amount, index, 0);
        } else if (interfaceVersion_ == 1) {
            ICurvePoolV1(_curvePool).remove_liquidity_one_coin(_amount, index, 0);
        } else if (interfaceVersion_ == 2) {
            ICurvePoolV2(_curvePool).remove_liquidity_one_coin(
                _amount,
                uint256(uint128(index)),
                0,
                isETH,
                address(this)
            );
        } else {
            revert("CurveHandler: unsupported interface version");
        }

        if (isETH) {
            uint256 balanceIncrease = address(this).balance - balanceBeforeWithdraw;
            _wrapWETH(balanceIncrease);
        }
    }

    /// Version 0 pools don't have a `remove_liquidity_one_coin` function.
    /// So we work around this by calling `removing_liquidity`
    /// and then swapping all the coins to the target
    function _version_0_remove_liquidity_one_coin(
        address _curvePool,
        uint256 _amount,
        int128 _index
    ) internal {
        ICurveRegistryCache registry_ = controller.curveRegistryCache();
        uint256 coins = registry_.nCoins(_curvePool);
        if (coins == 2) {
            uint256[2] memory min_amounts;
            ICurvePoolV0(_curvePool).remove_liquidity(_amount, min_amounts);
        } else if (coins == 3) {
            uint256[3] memory min_amounts;
            ICurvePoolV0(_curvePool).remove_liquidity(_amount, min_amounts);
        } else if (coins == 4) {
            uint256[4] memory min_amounts;
            ICurvePoolV0(_curvePool).remove_liquidity(_amount, min_amounts);
        } else if (coins == 5) {
            uint256[5] memory min_amounts;
            ICurvePoolV0(_curvePool).remove_liquidity(_amount, min_amounts);
        } else if (coins == 6) {
            uint256[6] memory min_amounts;
            ICurvePoolV0(_curvePool).remove_liquidity(_amount, min_amounts);
        } else if (coins == 7) {
            uint256[7] memory min_amounts;
            ICurvePoolV0(_curvePool).remove_liquidity(_amount, min_amounts);
        } else if (coins == 8) {
            uint256[8] memory min_amounts;
            ICurvePoolV0(_curvePool).remove_liquidity(_amount, min_amounts);
        } else {
            revert("CurveHandler: unsupported coins");
        }

        for (uint256 i = 0; i < coins; i++) {
            if (i == uint256(int256(_index))) continue;
            address[] memory coins_ = registry_.coins(_curvePool);
            address coin_ = coins_[i];
            uint256 balance_ = IERC20(coin_).balanceOf(address(this));
            if (balance_ == 0) continue;
            IERC20(coin_).forceApprove(_curvePool, balance_);
            ICurvePoolV0(_curvePool).exchange(int128(int256(i)), _index, balance_, 0);
        }
    }

    function _wrapWETH(uint256 amount) internal {
        _WETH.deposit{value: amount}();
    }

    function _unwrapWETH(uint256 amount) internal {
        _WETH.withdraw(amount);
    }

    function _addLiquidity(
        address _curvePool,
        uint256 _amount, // amount of asset to deposit
        address _token // asset to deposit
    ) internal {
        bool isETH = _isETH(_curvePool, _token);
        if (!isETH) {
            IERC20(_token).forceApprove(_curvePool, _amount);
        }

        ICurveRegistryCache registry_ = controller.curveRegistryCache();
        uint256 index = uint128(registry_.coinIndex(_curvePool, isETH ? _ETH_ADDRESS : _token));
        uint256 coins = registry_.nCoins(_curvePool);
        if (_hasDynamicAddLiquidity(_curvePool)) {
            uint256[] memory amounts = new uint256[](coins);
            amounts[index] = _amount;
            ICurvePoolV7(_curvePool).add_liquidity(amounts, 0);
        } else if (coins == 2) {
            uint256[2] memory amounts;
            amounts[index] = _amount;
            if (isETH) {
                _unwrapWETH(_amount);
                ICurvePoolV1Eth(_curvePool).add_liquidity{value: _amount}(amounts, 0);
            } else {
                ICurvePoolV1(_curvePool).add_liquidity(amounts, 0);
            }
        } else if (coins == 3) {
            uint256[3] memory amounts;
            amounts[index] = _amount;
            if (isETH) {
                _unwrapWETH(_amount);
                ICurvePoolV1Eth(_curvePool).add_liquidity{value: _amount}(amounts, 0);
            } else {
                ICurvePoolV1(_curvePool).add_liquidity(amounts, 0);
            }
        } else if (coins == 4) {
            uint256[4] memory amounts;
            amounts[index] = _amount;
            if (isETH) {
                _unwrapWETH(_amount);
                ICurvePoolV1Eth(_curvePool).add_liquidity{value: _amount}(amounts, 0);
            } else {
                ICurvePoolV1(_curvePool).add_liquidity(amounts, 0);
            }
        } else if (coins == 5) {
            uint256[5] memory amounts;
            amounts[index] = _amount;
            if (isETH) {
                _unwrapWETH(_amount);
                ICurvePoolV1Eth(_curvePool).add_liquidity{value: _amount}(amounts, 0);
            } else {
                ICurvePoolV1(_curvePool).add_liquidity(amounts, 0);
            }
        } else if (coins == 6) {
            uint256[6] memory amounts;
            amounts[index] = _amount;
            if (isETH) {
                _unwrapWETH(_amount);
                ICurvePoolV1Eth(_curvePool).add_liquidity{value: _amount}(amounts, 0);
            } else {
                ICurvePoolV1(_curvePool).add_liquidity(amounts, 0);
            }
        } else if (coins == 7) {
            uint256[7] memory amounts;
            amounts[index] = _amount;
            if (isETH) {
                _unwrapWETH(_amount);
                ICurvePoolV1Eth(_curvePool).add_liquidity{value: _amount}(amounts, 0);
            } else {
                ICurvePoolV1(_curvePool).add_liquidity(amounts, 0);
            }
        } else if (coins == 8) {
            uint256[8] memory amounts;
            amounts[index] = _amount;
            if (isETH) {
                _unwrapWETH(_amount);
                ICurvePoolV1Eth(_curvePool).add_liquidity{value: _amount}(amounts, 0);
            } else {
                ICurvePoolV1(_curvePool).add_liquidity(amounts, 0);
            }
        } else {
            revert("invalid number of coins for curve pool");
        }
    }

    function _isETH(address pool, address token) internal view returns (bool) {
        return
            token == address(_WETH) &&
            controller.curveRegistryCache().hasCoinDirectly(pool, _ETH_ADDRESS);
    }

    function _isETH(address pool) internal view returns (bool) {
        return controller.curveRegistryCache().hasCoinDirectly(pool, _ETH_ADDRESS);
    }

    function _isEthIndexFirst(address pool) internal view returns (bool) {
        return controller.curveRegistryCache().coinIndex(pool, address(_WETH)) == int128(0);
    }

    function _hasDynamicAddLiquidity(address pool) internal view returns (bool) {
        try ICurvePoolV7(pool).version() returns (string memory version) {
            uint256 majorVersion = StringUtils.extractMajorVersion(version);
            return majorVersion >= 7;
        } catch {
            return false;
        }
    }
}

File 2 of 35 : SafeERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;

import "IERC20.sol";
import "IERC20Permit.sol";
import "Address.sol";

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

    /**
     * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeTransfer(IERC20 token, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
    }

    /**
     * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
     * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
     */
    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));
    }

    /**
     * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 oldAllowance = token.allowance(address(this), spender);
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));
    }

    /**
     * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    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");
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));
        }
    }

    /**
     * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
     * to be set to zero before setting it to a non-zero value, such as USDT.
     */
    function forceApprove(IERC20 token, address spender, uint256 value) internal {
        bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);

        if (!_callOptionalReturnBool(token, approvalCall)) {
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));
            _callOptionalReturn(token, approvalCall);
        }
    }

    /**
     * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.
     * Revert on invalid signature.
     */
    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");
        require(returndata.length == 0 || abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation 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).
     *
     * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
     */
    function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
        // 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 cannot use {Address-functionCall} here since this should return false
        // and not revert is the subcall reverts.

        (bool success, bytes memory returndata) = address(token).call(data);
        return
            success && (returndata.length == 0 || abi.decode(returndata, (bool))) && Address.isContract(address(token));
    }
}

File 3 of 35 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

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

File 4 of 35 : IERC20Permit.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/extensions/IERC20Permit.sol)

pragma solidity ^0.8.0;

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

File 5 of 35 : Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)

pragma solidity ^0.8.1;

/**
 * @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.8.0/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);
        }
    }
}

File 6 of 35 : ILpToken.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.17;

import "IERC20Metadata.sol";

interface ILpToken is IERC20Metadata {
    function minter() external view returns (address);

    function mint(address account, uint256 amount, address ubo) external returns (uint256);

    function burn(address _owner, uint256 _amount, address ubo) external returns (uint256);

    function taint(address from, address to, uint256 amount) external;
}

File 7 of 35 : IERC20Metadata.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)

pragma solidity ^0.8.0;

import "IERC20.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);
}

File 8 of 35 : ICurveHandler.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.17;

interface ICurveHandler {
    function deposit(address _curvePool, address _token, uint256 _amount) external;

    function withdraw(address _curvePool, address _token, uint256 _amount) external;

    function reentrancyCheck(address _curvePool) external;

    function isReentrantCall(address _curvePool) external returns (bool);
}

File 9 of 35 : ICurveRegistryCache.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.17;

import "IBooster.sol";
import "CurvePoolUtils.sol";
import "Types.sol";

interface ICurveRegistryCache {
    event PoolInitialized(address indexed pool, uint256 indexed pid);

    function BOOSTER() external view returns (IBooster);

    function initPool(address pool_) external;

    function initPool(address pool_, uint256 pid_) external;

    function initPool(address pool_, Types.PoolInfo memory poolInfo_) external;

    function initPool(address pool_, uint256 pid_, Types.PoolInfo memory poolInfo_) external;

    function lpToken(address pool_) external view returns (address);

    function assetType(address pool_) external view returns (CurvePoolUtils.AssetType);

    function isRegistered(address pool_) external view returns (bool);

    function hasCoinDirectly(address pool_, address coin_) external view returns (bool);

    function hasCoinAnywhere(address pool_, address coin_) external view returns (bool);

    function basePool(address pool_) external view returns (address);

    function coinIndex(address pool_, address coin_) external view returns (int128);

    function nCoins(address pool_) external view returns (uint256);

    function coinIndices(
        address pool_,
        address from_,
        address to_
    ) external view returns (int128, int128, bool);

    function decimals(address pool_) external view returns (uint256[] memory);

    function interfaceVersion(address pool_) external view returns (uint256);

    function poolFromLpToken(address lpToken_) external view returns (address);

    function coins(address pool_) external view returns (address[] memory);

    function getPid(address _pool) external view returns (uint256);

    function getRewardPool(address _pool) external view returns (address);

    function isShutdownPid(uint256 pid_) external view returns (bool);

    /// @notice this returns the underlying coins of a pool, including the underlying of the base pool
    /// if the given pool is a meta pool
    /// This does not return the LP token of the base pool as an underlying
    /// e.g. if the pool is 3CrvFrax, this will return FRAX, DAI, USDC, USDT
    function getAllUnderlyingCoins(address pool) external view returns (address[] memory);
}

File 10 of 35 : IBooster.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.17;

interface IBooster {
    function poolInfo(
        uint256 pid
    )
        external
        view
        returns (
            address lpToken,
            address token,
            address gauge,
            address crvRewards,
            address stash,
            bool shutdown
        );

    function poolLength() external view returns (uint256);

    function deposit(uint256 _pid, uint256 _amount, bool _stake) external returns (bool);

    function withdraw(uint256 _pid, uint256 _amount) external returns (bool);

    function withdrawAll(uint256 _pid) external returns (bool);

    function depositAll(uint256 _pid, bool _stake) external returns (bool);

    function earmarkRewards(uint256 _pid) external returns (bool);

    function isShutdown() external view returns (bool);
}

File 11 of 35 : CurvePoolUtils.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.17;

import "ICurvePoolV2.sol";
import "ICurvePoolV1.sol";
import "ScaledMath.sol";

library CurvePoolUtils {
    using ScaledMath for uint256;

    error NotWithinThreshold(address pool, uint256 assetA, uint256 assetB);

    /// @dev by default, allow for 30 bps deviation regardless of pool fees
    uint256 internal constant _DEFAULT_IMBALANCE_BUFFER = 30e14;

    /// @dev Curve scales the `fee` by 1e10
    uint8 internal constant _CURVE_POOL_FEE_DECIMALS = 10;

    /// @dev allow imbalance to be buffer + 3x the fee, e.g. if fee is 3.6 bps and buffer is 30 bps, allow 40.8 bps
    uint256 internal constant _FEE_IMBALANCE_MULTIPLIER = 3;

    enum AssetType {
        USD,
        ETH,
        BTC,
        OTHER,
        CRYPTO
    }

    struct PoolMeta {
        address pool;
        uint256 numberOfCoins;
        AssetType assetType;
        uint256[] decimals;
        uint256[] prices;
        uint256[] imbalanceBuffers;
    }

    function ensurePoolBalanced(PoolMeta memory poolMeta) internal view {
        uint256 poolFee = ICurvePoolV1(poolMeta.pool).fee().convertScale(
            _CURVE_POOL_FEE_DECIMALS,
            18
        );

        for (uint256 i = 0; i < poolMeta.numberOfCoins - 1; i++) {
            uint256 fromDecimals = poolMeta.decimals[i];
            uint256 fromBalance = 10 ** fromDecimals;
            uint256 fromPrice = poolMeta.prices[i];

            for (uint256 j = i + 1; j < poolMeta.numberOfCoins; j++) {
                uint256 toDecimals = poolMeta.decimals[j];
                uint256 toPrice = poolMeta.prices[j];
                uint256 toExpectedUnscaled = (fromBalance * fromPrice) / toPrice;
                uint256 toExpected = toExpectedUnscaled.convertScale(
                    uint8(fromDecimals),
                    uint8(toDecimals)
                );

                uint256 toActual;

                if (poolMeta.assetType == AssetType.CRYPTO) {
                    // Handling crypto pools
                    toActual = ICurvePoolV2(poolMeta.pool).get_dy(i, j, fromBalance);
                } else {
                    // Handling other pools
                    toActual = ICurvePoolV1(poolMeta.pool).get_dy(
                        int128(uint128(i)),
                        int128(uint128(j)),
                        fromBalance
                    );
                }
                uint256 _maxImbalanceBuffer = poolMeta.imbalanceBuffers[i].max(
                    poolMeta.imbalanceBuffers[j]
                );

                if (!_isWithinThreshold(toExpected, toActual, poolFee, _maxImbalanceBuffer))
                    revert NotWithinThreshold(poolMeta.pool, i, j);
            }
        }
    }

    function _isWithinThreshold(
        uint256 a,
        uint256 b,
        uint256 poolFee,
        uint256 imbalanceBuffer
    ) internal pure returns (bool) {
        if (imbalanceBuffer == 0) imbalanceBuffer = _DEFAULT_IMBALANCE_BUFFER;
        uint256 imbalanceTreshold = imbalanceBuffer + poolFee * _FEE_IMBALANCE_MULTIPLIER;
        if (a > b) return (a - b).divDown(a) <= imbalanceTreshold;
        return (b - a).divDown(b) <= imbalanceTreshold;
    }
}

File 12 of 35 : ICurvePoolV2.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.17;

interface ICurvePoolV2 {
    function token() external view returns (address);

    function coins(uint256 i) external view returns (address);

    function factory() external view returns (address);

    function exchange(
        uint256 i,
        uint256 j,
        uint256 dx,
        uint256 min_dy,
        bool use_eth,
        address receiver
    ) external returns (uint256);

    function exchange_underlying(
        uint256 i,
        uint256 j,
        uint256 dx,
        uint256 min_dy,
        address receiver
    ) external returns (uint256);

    function add_liquidity(
        uint256[2] memory amounts,
        uint256 min_mint_amount,
        bool use_eth,
        address receiver
    ) external returns (uint256);

    function add_liquidity(
        uint256[2] memory amounts,
        uint256 min_mint_amount
    ) external returns (uint256);

    function add_liquidity(
        uint256[3] memory amounts,
        uint256 min_mint_amount,
        bool use_eth,
        address receiver
    ) external returns (uint256);

    function add_liquidity(
        uint256[3] memory amounts,
        uint256 min_mint_amount
    ) external returns (uint256);

    function remove_liquidity(
        uint256 _amount,
        uint256[2] memory min_amounts,
        bool use_eth,
        address receiver
    ) external;

    function remove_liquidity(uint256 _amount, uint256[2] memory min_amounts) external;

    function remove_liquidity(
        uint256 _amount,
        uint256[3] memory min_amounts,
        bool use_eth,
        address receiver
    ) external;

    function remove_liquidity(uint256 _amount, uint256[3] memory min_amounts) external;

    function remove_liquidity_one_coin(
        uint256 token_amount,
        uint256 i,
        uint256 min_amount,
        bool use_eth,
        address receiver
    ) external returns (uint256);

    function get_dy(uint256 i, uint256 j, uint256 dx) external view returns (uint256);

    function calc_token_amount(uint256[] memory amounts) external view returns (uint256);

    function calc_withdraw_one_coin(
        uint256 token_amount,
        uint256 i
    ) external view returns (uint256);

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

File 13 of 35 : ICurvePoolV1.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.17;

interface ICurvePoolV1 {
    function get_virtual_price() external view returns (uint256);

    function add_liquidity(uint256[8] calldata amounts, uint256 min_mint_amount) external;

    function add_liquidity(uint256[7] calldata amounts, uint256 min_mint_amount) external;

    function add_liquidity(uint256[6] calldata amounts, uint256 min_mint_amount) external;

    function add_liquidity(uint256[5] calldata amounts, uint256 min_mint_amount) external;

    function add_liquidity(uint256[4] calldata amounts, uint256 min_mint_amount) external;

    function add_liquidity(uint256[3] calldata amounts, uint256 min_mint_amount) external;

    function add_liquidity(uint256[2] calldata amounts, uint256 min_mint_amount) external;

    function remove_liquidity_imbalance(
        uint256[4] calldata amounts,
        uint256 max_burn_amount
    ) external;

    function remove_liquidity_imbalance(
        uint256[3] calldata amounts,
        uint256 max_burn_amount
    ) external;

    function remove_liquidity_imbalance(
        uint256[2] calldata amounts,
        uint256 max_burn_amount
    ) external;

    function lp_token() external view returns (address);

    function A_PRECISION() external view returns (uint256);

    function A_precise() external view returns (uint256);

    function remove_liquidity(uint256 _amount, uint256[3] calldata min_amounts) external;

    function exchange(
        int128 from,
        int128 to,
        uint256 _from_amount,
        uint256 _min_to_amount
    ) external;

    function coins(uint256 i) external view returns (address);

    function balances(uint256 i) external view returns (uint256);

    function get_dy(int128 i, int128 j, uint256 _dx) external view returns (uint256);

    function calc_token_amount(
        uint256[4] calldata amounts,
        bool deposit
    ) external view returns (uint256);

    function calc_token_amount(
        uint256[3] calldata amounts,
        bool deposit
    ) external view returns (uint256);

    function calc_token_amount(
        uint256[2] calldata amounts,
        bool deposit
    ) external view returns (uint256);

    function calc_withdraw_one_coin(
        uint256 _token_amount,
        int128 i
    ) external view returns (uint256);

    function remove_liquidity_one_coin(
        uint256 _token_amount,
        int128 i,
        uint256 min_amount
    ) external;

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

File 14 of 35 : ScaledMath.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.17;

library ScaledMath {
    uint256 internal constant DECIMALS = 18;
    uint256 internal constant ONE = 10 ** DECIMALS;

    function mulDown(uint256 a, uint256 b) internal pure returns (uint256) {
        return (a * b) / ONE;
    }

    function mulDown(uint256 a, uint256 b, uint256 decimals) internal pure returns (uint256) {
        return (a * b) / (10 ** decimals);
    }

    function divDown(uint256 a, uint256 b) internal pure returns (uint256) {
        return (a * ONE) / b;
    }

    function divDown(uint256 a, uint256 b, uint256 decimals) internal pure returns (uint256) {
        return (a * 10 ** decimals) / b;
    }

    function divUp(uint256 a, uint256 b) internal pure returns (uint256) {
        if (a == 0) {
            return 0;
        }
        return ((a * ONE) - 1) / b + 1;
    }

    function mulDown(int256 a, int256 b) internal pure returns (int256) {
        return (a * b) / int256(ONE);
    }

    function mulDownUint128(uint128 a, uint128 b) internal pure returns (uint128) {
        return (a * b) / uint128(ONE);
    }

    function mulDown(int256 a, int256 b, uint256 decimals) internal pure returns (int256) {
        return (a * b) / int256(10 ** decimals);
    }

    function divDown(int256 a, int256 b) internal pure returns (int256) {
        return (a * int256(ONE)) / b;
    }

    function divDownUint128(uint128 a, uint128 b) internal pure returns (uint128) {
        return (a * uint128(ONE)) / b;
    }

    function divDown(int256 a, int256 b, uint256 decimals) internal pure returns (int256) {
        return (a * int256(10 ** decimals)) / b;
    }

    function convertScale(
        uint256 a,
        uint8 fromDecimals,
        uint8 toDecimals
    ) internal pure returns (uint256) {
        if (fromDecimals == toDecimals) return a;
        if (fromDecimals > toDecimals) return downscale(a, fromDecimals, toDecimals);
        return upscale(a, fromDecimals, toDecimals);
    }

    function convertScale(
        int256 a,
        uint8 fromDecimals,
        uint8 toDecimals
    ) internal pure returns (int256) {
        if (fromDecimals == toDecimals) return a;
        if (fromDecimals > toDecimals) return downscale(a, fromDecimals, toDecimals);
        return upscale(a, fromDecimals, toDecimals);
    }

    function upscale(
        uint256 a,
        uint8 fromDecimals,
        uint8 toDecimals
    ) internal pure returns (uint256) {
        return a * (10 ** (toDecimals - fromDecimals));
    }

    function downscale(
        uint256 a,
        uint8 fromDecimals,
        uint8 toDecimals
    ) internal pure returns (uint256) {
        return a / (10 ** (fromDecimals - toDecimals));
    }

    function upscale(
        int256 a,
        uint8 fromDecimals,
        uint8 toDecimals
    ) internal pure returns (int256) {
        return a * int256(10 ** (toDecimals - fromDecimals));
    }

    function downscale(
        int256 a,
        uint8 fromDecimals,
        uint8 toDecimals
    ) internal pure returns (int256) {
        return a / int256(10 ** (fromDecimals - toDecimals));
    }

    function intPow(uint256 a, uint256 n) internal pure returns (uint256) {
        uint256 result = ONE;
        for (uint256 i; i < n; ) {
            result = mulDown(result, a);
            unchecked {
                ++i;
            }
        }
        return result;
    }

    function absSub(uint256 a, uint256 b) internal pure returns (uint256) {
        unchecked {
            return a >= b ? a - b : b - a;
        }
    }

    function max(uint256 a, uint256 b) internal pure returns (uint256) {
        return a >= b ? a : b;
    }

    function min(uint256 a, uint256 b) internal pure returns (uint256) {
        return a <= b ? a : b;
    }
}

File 15 of 35 : Types.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.17;

library Types {
    struct Coin {
        address coinAddress;
        uint8 decimals;
    }

    struct CliffInfo {
        uint256 currentCliff;
        bool withinThreshold;
    }

    struct PoolInfo {
        address lpToken;
        address basePool;
        uint256 assetType;
    }
}

File 16 of 35 : IWETH.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.17;

import "IERC20.sol";

interface IWETH is IERC20 {
    function deposit() external payable;

    function withdraw(uint256 wad) external;
}

File 17 of 35 : ICurvePoolV0.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.17;

interface ICurvePoolV0 {
    function get_virtual_price() external view returns (uint256);

    function add_liquidity(uint256[8] calldata amounts, uint256 min_mint_amount) external;

    function add_liquidity(uint256[7] calldata amounts, uint256 min_mint_amount) external;

    function add_liquidity(uint256[6] calldata amounts, uint256 min_mint_amount) external;

    function add_liquidity(uint256[5] calldata amounts, uint256 min_mint_amount) external;

    function add_liquidity(uint256[4] calldata amounts, uint256 min_mint_amount) external;

    function add_liquidity(uint256[3] calldata amounts, uint256 min_mint_amount) external;

    function add_liquidity(uint256[2] calldata amounts, uint256 min_mint_amount) external;

    function remove_liquidity_imbalance(
        uint256[4] calldata amounts,
        uint256 max_burn_amount
    ) external;

    function remove_liquidity_imbalance(
        uint256[3] calldata amounts,
        uint256 max_burn_amount
    ) external;

    function remove_liquidity_imbalance(
        uint256[2] calldata amounts,
        uint256 max_burn_amount
    ) external;

    function lp_token() external view returns (address);

    function A_PRECISION() external view returns (uint256);

    function A_precise() external view returns (uint256);

    function remove_liquidity(uint256 _amount, uint256[2] calldata min_amounts) external;

    function remove_liquidity(uint256 _amount, uint256[3] calldata min_amounts) external;

    function remove_liquidity(uint256 _amount, uint256[4] calldata min_amounts) external;

    function remove_liquidity(uint256 _amount, uint256[5] calldata min_amounts) external;

    function remove_liquidity(uint256 _amount, uint256[6] calldata min_amounts) external;

    function remove_liquidity(uint256 _amount, uint256[7] calldata min_amounts) external;

    function remove_liquidity(uint256 _amount, uint256[8] calldata min_amounts) external;

    function exchange(
        int128 from,
        int128 to,
        uint256 _from_amount,
        uint256 _min_to_amount
    ) external;

    function coins(int128 i) external view returns (address);

    function balances(int128 i) external view returns (uint256);

    function get_dy(int128 i, int128 j, uint256 _dx) external view returns (uint256);

    function calc_token_amount(
        uint256[4] calldata amounts,
        bool deposit
    ) external view returns (uint256);

    function calc_token_amount(
        uint256[3] calldata amounts,
        bool deposit
    ) external view returns (uint256);

    function calc_token_amount(
        uint256[2] calldata amounts,
        bool deposit
    ) external view returns (uint256);

    function calc_withdraw_one_coin(
        uint256 _token_amount,
        int128 i
    ) external view returns (uint256);
}

File 18 of 35 : ICurvePoolV7.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.17;

interface ICurvePoolV7 {
    function exchange(int128 i, int128 j, uint256 _dx, uint256 _min_dy) external returns (uint256);

    function exchange(
        int128 i,
        int128 j,
        uint256 _dx,
        uint256 _min_dy,
        address _receiver
    ) external returns (uint256);

    function exchange_received(
        int128 i,
        int128 j,
        uint256 _dx,
        uint256 _min_dy
    ) external returns (uint256);

    function exchange_received(
        int128 i,
        int128 j,
        uint256 _dx,
        uint256 _min_dy,
        address _receiver
    ) external returns (uint256);

    function add_liquidity(
        uint256[] memory _amounts,
        uint256 _min_mint_amount
    ) external returns (uint256);

    function add_liquidity(
        uint256[] memory _amounts,
        uint256 _min_mint_amount,
        address _receiver
    ) external returns (uint256);

    function remove_liquidity_one_coin(
        uint256 _burn_amount,
        int128 i,
        uint256 _min_received
    ) external returns (uint256);

    function remove_liquidity_one_coin(
        uint256 _burn_amount,
        int128 i,
        uint256 _min_received,
        address _receiver
    ) external returns (uint256);

    function remove_liquidity_imbalance(
        uint256[] memory _amounts,
        uint256 _max_burn_amount
    ) external returns (uint256);

    function remove_liquidity_imbalance(
        uint256[] memory _amounts,
        uint256 _max_burn_amount,
        address _receiver
    ) external returns (uint256);

    function remove_liquidity(
        uint256 _burn_amount,
        uint256[] memory _min_amounts
    ) external returns (uint256[] memory);

    function remove_liquidity(
        uint256 _burn_amount,
        uint256[] memory _min_amounts,
        address _receiver
    ) external returns (uint256[] memory);

    function remove_liquidity(
        uint256 _burn_amount,
        uint256[] memory _min_amounts,
        address _receiver,
        bool _claim_admin_fees
    ) external returns (uint256[] memory);

    function withdraw_admin_fees() external;

    function last_price(uint256 i) external view returns (uint256);

    function ema_price(uint256 i) external view returns (uint256);

    function get_p(uint256 i) external view returns (uint256);

    function price_oracle(uint256 i) external view returns (uint256);

    function D_oracle() external view returns (uint256);

    function transfer(address _to, uint256 _value) external returns (bool);

    function transferFrom(address _from, address _to, uint256 _value) external returns (bool);

    function approve(address _spender, uint256 _value) external returns (bool);

    function permit(
        address _owner,
        address _spender,
        uint256 _value,
        uint256 _deadline,
        uint8 _v,
        bytes32 _r,
        bytes32 _s
    ) external returns (bool);

    function DOMAIN_SEPARATOR() external view returns (bytes32);

    function get_dx(int128 i, int128 j, uint256 dy) external view returns (uint256);

    function get_dy(int128 i, int128 j, uint256 dx) external view returns (uint256);

    function calc_withdraw_one_coin(uint256 _burn_amount, int128 i) external view returns (uint256);

    function totalSupply() external view returns (uint256);

    function get_virtual_price() external view returns (uint256);

    function calc_token_amount(
        uint256[] memory _amounts,
        bool _is_deposit
    ) external view returns (uint256);

    function A() external view returns (uint256);

    function A_precise() external view returns (uint256);

    function balances(uint256 i) external view returns (uint256);

    function get_balances() external view returns (uint256[] memory);

    function stored_rates() external view returns (uint256[] memory);

    function dynamic_fee(int128 i, int128 j) external view returns (uint256);

    function ramp_A(uint256 _future_A, uint256 _future_time) external;

    function stop_ramp_A() external;

    function set_new_fee(uint256 _new_fee, uint256 _new_offpeg_fee_multiplier) external;

    function set_ma_exp_time(uint256 _ma_exp_time, uint256 _D_ma_time) external;

    function N_COINS() external view returns (uint256);

    function coins(uint256 arg0) external view returns (address);

    function fee() external view returns (uint256);

    function offpeg_fee_multiplier() external view returns (uint256);

    function admin_fee() external view returns (uint256);

    function initial_A() external view returns (uint256);

    function future_A() external view returns (uint256);

    function initial_A_time() external view returns (uint256);

    function future_A_time() external view returns (uint256);

    function admin_balances(uint256 arg0) external view returns (uint256);

    function ma_exp_time() external view returns (uint256);

    function D_ma_time() external view returns (uint256);

    function ma_last_time() external view returns (uint256);

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

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

    function decimals() external view returns (uint8);

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

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

    function allowance(address arg0, address arg1) external view returns (uint256);

    function nonces(address arg0) external view returns (uint256);

    function salt() external view returns (bytes32);
}

File 19 of 35 : ICurvePoolV1Eth.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.17;

interface ICurvePoolV1Eth {
    function add_liquidity(uint256[2] calldata amounts, uint256 min_mint_amount) external payable;

    function add_liquidity(uint256[3] calldata amounts, uint256 min_mint_amount) external payable;

    function add_liquidity(uint256[4] calldata amounts, uint256 min_mint_amount) external payable;

    function add_liquidity(uint256[5] calldata amounts, uint256 min_mint_amount) external payable;

    function add_liquidity(uint256[6] calldata amounts, uint256 min_mint_amount) external payable;

    function add_liquidity(uint256[7] calldata amounts, uint256 min_mint_amount) external payable;

    function add_liquidity(uint256[8] calldata amounts, uint256 min_mint_amount) external payable;

    function remove_liquidity_imbalance(
        uint256[3] calldata amounts,
        uint256 max_burn_amount
    ) external;

    function remove_liquidity_imbalance(
        uint256[2] calldata amounts,
        uint256 max_burn_amount
    ) external;

    function remove_liquidity_one_coin(
        uint256 _token_amount,
        int128 i,
        uint256 min_amount
    ) external;

    function remove_liquidity(uint256 _amount, uint256[2] calldata min_amounts) external;

    function remove_liquidity(uint256 _amount, uint256[3] calldata min_amounts) external;

    function get_virtual_price() external view returns (uint256);

    function coins(uint256 i) external view returns (address);

    function get_dy(uint256 i, uint256 j, uint256 dx) external view returns (uint256);

    function calc_token_amount(
        uint256[3] calldata amounts,
        bool deposit
    ) external view returns (uint256);

    function calc_token_amount(
        uint256[2] calldata amounts,
        bool deposit
    ) external view returns (uint256);

    function calc_withdraw_one_coin(
        uint256 _token_amount,
        int128 i
    ) external view returns (uint256);

    function exchange(
        int128 from,
        int128 to,
        uint256 _from_amount,
        uint256 _min_to_amount
    ) external payable;
}

File 20 of 35 : ICurvePoolV2Eth.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.17;

interface ICurvePoolV2Eth {
    function token() external view returns (address);

    function coins(uint256 i) external view returns (address);

    function factory() external view returns (address);

    function exchange(
        uint256 i,
        uint256 j,
        uint256 dx,
        uint256 min_dy
    ) external payable returns (uint256);

    function exchange(
        uint256 i,
        uint256 j,
        uint256 dx,
        uint256 min_dy,
        bool use_eth,
        address receiver
    ) external returns (uint256);

    function exchange_underlying(
        uint256 i,
        uint256 j,
        uint256 dx,
        uint256 min_dy,
        address receiver
    ) external returns (uint256);

    function add_liquidity(
        uint256[2] memory amounts,
        uint256 min_mint_amount,
        bool use_eth,
        address receiver
    ) external payable returns (uint256);

    function add_liquidity(
        uint256[2] memory amounts,
        uint256 min_mint_amount
    ) external returns (uint256);

    function add_liquidity(
        uint256[3] memory amounts,
        uint256 min_mint_amount,
        bool use_eth,
        address receiver
    ) external payable returns (uint256);

    function add_liquidity(
        uint256[3] memory amounts,
        uint256 min_mint_amount
    ) external returns (uint256);

    function remove_liquidity(
        uint256 _amount,
        uint256[2] memory min_amounts,
        bool use_eth,
        address receiver
    ) external;

    function remove_liquidity(uint256 _amount, uint256[2] memory min_amounts) external;

    function remove_liquidity(
        uint256 _amount,
        uint256[3] memory min_amounts,
        bool use_eth,
        address receiver
    ) external;

    function remove_liquidity(uint256 _amount, uint256[3] memory min_amounts) external;

    function remove_liquidity_one_coin(
        uint256 token_amount,
        uint256 i,
        uint256 min_amount,
        bool use_eth,
        address receiver
    ) external returns (uint256);

    function get_dy(uint256 i, uint256 j, uint256 dx) external view returns (uint256);

    function calc_token_amount(uint256[] memory amounts) external view returns (uint256);

    function calc_withdraw_one_coin(
        uint256 token_amount,
        uint256 i
    ) external view returns (uint256);

    function get_virtual_price() external view returns (uint256);

    function price_oracle() external view returns (uint256);

    function apply_new_parameters() external;
}

File 21 of 35 : IController.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.17;

import "IConicPoolWeightManagement.sol";
import "IConicPool.sol";
import "IGenericOracle.sol";
import "IInflationManager.sol";
import "ILpTokenStaker.sol";
import "IBonding.sol";
import "IPoolAdapter.sol";
import "IFeeRecipient.sol";
import "ICurveRegistryCache.sol";

interface IController {
    event PoolAdded(address indexed pool);
    event PoolRemoved(address indexed pool);
    event PoolShutdown(address indexed pool);
    event ConvexBoosterSet(address convexBooster);
    event CurveHandlerSet(address curveHandler);
    event ConvexHandlerSet(address convexHandler);
    event CurveRegistryCacheSet(address curveRegistryCache);
    event InflationManagerSet(address inflationManager);
    event BondingSet(address bonding);
    event FeeRecipientSet(address feeRecipient);
    event PriceOracleSet(address priceOracle);
    event WeightUpdateMinDelaySet(uint256 weightUpdateMinDelay);
    event PauseManagerSet(address indexed manager, bool isManager);
    event MultiDepositsWithdrawsWhitelistSet(address pool, bool allowed);
    event MinimumTaintedTransferAmountSet(address indexed token, uint256 amount);
    event DefaultPoolAdapterSet(address poolAdapter);
    event CustomPoolAdapterSet(address indexed pool, address poolAdapter);

    struct WeightUpdate {
        address conicPoolAddress;
        IConicPoolWeightManagement.PoolWeight[] weights;
    }

    function initialize(address _lpTokenStaker) external;

    // inflation manager

    function inflationManager() external view returns (IInflationManager);

    function setInflationManager(address manager) external;

    // views
    function curveRegistryCache() external view returns (ICurveRegistryCache);

    // pool adapter
    function poolAdapterFor(address pool) external view returns (IPoolAdapter);

    function defaultPoolAdapter() external view returns (IPoolAdapter);

    function setDefaultPoolAdapter(address poolAdapter) external;

    function setCustomPoolAdapter(address pool, address poolAdapter) external;

    /// lp token staker
    function switchLpTokenStaker(address _lpTokenStaker) external;

    function lpTokenStaker() external view returns (ILpTokenStaker);

    // bonding
    function bonding() external view returns (IBonding);

    function setBonding(address _bonding) external;

    // fees
    function feeRecipient() external view returns (IFeeRecipient);

    function setFeeRecipient(address _feeRecipient) external;

    // oracle
    function priceOracle() external view returns (IGenericOracle);

    function setPriceOracle(address oracle) external;

    // pool functions

    function listPools() external view returns (address[] memory);

    function listActivePools() external view returns (address[] memory);

    function isPool(address poolAddress) external view returns (bool);

    function isActivePool(address poolAddress) external view returns (bool);

    function addPool(address poolAddress) external;

    function shutdownPool(address poolAddress) external;

    function removePool(address poolAddress) external;

    function cncToken() external view returns (address);

    function lastWeightUpdate(address poolAddress) external view returns (uint256);

    function updateWeights(WeightUpdate memory update) external;

    function updateAllWeights(WeightUpdate[] memory weights) external;

    // handler functions

    function convexBooster() external view returns (address);

    function curveHandler() external view returns (address);

    function convexHandler() external view returns (address);

    function setConvexBooster(address _convexBooster) external;

    function setCurveHandler(address _curveHandler) external;

    function setConvexHandler(address _convexHandler) external;

    function setCurveRegistryCache(address curveRegistryCache_) external;

    function setWeightUpdateMinDelay(uint256 delay) external;

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

    function listPauseManagers() external view returns (address[] memory);

    function setPauseManager(address account, bool isManager) external;

    // deposit/withdrawal whitelist
    function isAllowedMultipleDepositsWithdraws(address poolAddress) external view returns (bool);

    function setAllowedMultipleDepositsWithdraws(address account, bool allowed) external;

    function getMultipleDepositsWithdrawsWhitelist() external view returns (address[] memory);

    // tainted transfer amount
    function setMinimumTaintedTransferAmount(address token, uint256 amount) external;

    function getMinimumTaintedTransferAmount(address token) external view returns (uint256);

    // constants

    function MAX_WEIGHT_UPDATE_MIN_DELAY() external view returns (uint256);

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

File 22 of 35 : IConicPoolWeightManagement.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.17;

interface IConicPoolWeightManagement {
    struct PoolWeight {
        address poolAddress;
        uint256 weight;
    }

    function addPool(address pool) external;

    function removePool(address pool) external;

    function updateWeights(PoolWeight[] memory poolWeights) external;

    function handleDepeggedCurvePool(address curvePool_) external;

    function handleInvalidConvexPid(address pool) external returns (uint256);

    function allPools() external view returns (address[] memory);

    function poolsCount() external view returns (uint256);

    function getPoolAtIndex(uint256 _index) external view returns (address);

    function getWeight(address curvePool) external view returns (uint256);

    function getWeights() external view returns (PoolWeight[] memory);

    function isRegisteredPool(address _pool) external view returns (bool);
}

File 23 of 35 : IConicPool.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.17;

import "ILpToken.sol";
import "IRewardManager.sol";
import "IOracle.sol";
import "IController.sol";
import "IPausable.sol";
import "IConicPoolWeightManagement.sol";

interface IConicPool is IConicPoolWeightManagement, IPausable {
    event Deposit(
        address indexed sender,
        address indexed receiver,
        uint256 depositedAmount,
        uint256 lpReceived
    );
    event Withdraw(address indexed account, uint256 amount);
    event NewWeight(address indexed curvePool, uint256 newWeight);
    event NewMaxIdleCurveLpRatio(uint256 newRatio);
    event ClaimedRewards(uint256 claimedCrv, uint256 claimedCvx);
    event HandledDepeggedCurvePool(address curvePool_);
    event HandledInvalidConvexPid(address curvePool_, uint256 pid_);
    event CurvePoolAdded(address curvePool_);
    event CurvePoolRemoved(address curvePool_);
    event Shutdown();
    event DepegThresholdUpdated(uint256 newThreshold);
    event MaxDeviationUpdated(uint256 newMaxDeviation);
    event RebalancingRewardsEnabledSet(bool enabled);
    event EmergencyRebalancingRewardFactorUpdated(uint256 factor);

    struct PoolWithAmount {
        address poolAddress;
        uint256 amount;
    }

    function underlying() external view returns (IERC20Metadata);

    function lpToken() external view returns (ILpToken);

    function rewardManager() external view returns (IRewardManager);

    function depegThreshold() external view returns (uint256);

    function maxDeviation() external view returns (uint256);

    function maxIdleCurveLpRatio() external view returns (uint256);

    function setMaxIdleCurveLpRatio(uint256 value) external;

    function setMaxDeviation(uint256 maxDeviation_) external;

    function updateDepegThreshold(uint256 value) external;

    function depositFor(
        address _account,
        uint256 _amount,
        uint256 _minLpReceived,
        bool stake
    ) external returns (uint256);

    function deposit(uint256 _amount, uint256 _minLpReceived) external returns (uint256);

    function deposit(
        uint256 _amount,
        uint256 _minLpReceived,
        bool stake
    ) external returns (uint256);

    function exchangeRate() external view returns (uint256);

    function usdExchangeRate() external view returns (uint256);

    function unstakeAndWithdraw(uint256 _amount, uint256 _minAmount) external returns (uint256);

    function unstakeAndWithdraw(
        uint256 _amount,
        uint256 _minAmount,
        address _to
    ) external returns (uint256);

    function withdraw(uint256 _amount, uint256 _minAmount) external returns (uint256);

    function withdraw(uint256 _amount, uint256 _minAmount, address _to) external returns (uint256);

    function getAllocatedUnderlying() external view returns (PoolWithAmount[] memory);

    function rebalancingRewardActive() external view returns (bool);

    function totalDeviationAfterWeightUpdate() external view returns (uint256);

    function computeTotalDeviation() external view returns (uint256);

    /// @notice returns the total amount of funds held by this pool in terms of underlying
    function totalUnderlying() external view returns (uint256);

    function getTotalAndPerPoolUnderlying()
        external
        view
        returns (
            uint256 totalUnderlying_,
            uint256 totalAllocated_,
            uint256[] memory perPoolUnderlying_
        );

    /// @notice same as `totalUnderlying` but returns a cached version
    /// that might be slightly outdated if oracle prices have changed
    /// @dev this is useful in cases where we want to reduce gas usage and do
    /// not need a precise value
    function cachedTotalUnderlying() external view returns (uint256);

    function updateRewardSpendingApproval(address token, bool approved) external;

    function shutdownPool() external;

    function isShutdown() external view returns (bool);

    function isBalanced() external view returns (bool);

    function rebalancingRewardsEnabled() external view returns (bool);

    function setRebalancingRewardsEnabled(bool enabled) external;

    function getAllUnderlyingCoins() external view returns (address[] memory result);

    function rebalancingRewardsFactor() external view returns (uint256);

    function rebalancingRewardsActivatedAt() external view returns (uint64);

    function getWeights() external view returns (PoolWeight[] memory);

    function runSanityChecks() external;
}

File 24 of 35 : IRewardManager.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.17;

interface IRewardManager {
    event ClaimedRewards(uint256 claimedCrv, uint256 claimedCvx);
    event SoldRewardTokens(uint256 targetTokenReceived);
    event ExtraRewardAdded(address reward);
    event ExtraRewardRemoved(address reward);
    event ExtraRewardsCurvePoolSet(address extraReward, address curvePool);
    event FeesSet(uint256 feePercentage);
    event FeesEnabled(uint256 feePercentage);
    event EarningsClaimed(
        address indexed claimedBy,
        uint256 cncEarned,
        uint256 crvEarned,
        uint256 cvxEarned
    );

    function accountCheckpoint(address account) external;

    function poolCheckpoint() external returns (bool);

    function addExtraReward(address reward) external returns (bool);

    function addBatchExtraRewards(address[] memory rewards) external;

    function conicPool() external view returns (address);

    function setFeePercentage(uint256 _feePercentage) external;

    function claimableRewards(
        address account
    ) external view returns (uint256 cncRewards, uint256 crvRewards, uint256 cvxRewards);

    function claimEarnings() external returns (uint256, uint256, uint256);

    function claimPoolEarningsAndSellRewardTokens() external;

    function feePercentage() external view returns (uint256);

    function feesEnabled() external view returns (bool);
}

File 25 of 35 : IOracle.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.17;

interface IOracle {
    event TokenUpdated(address indexed token, address feed, uint256 maxDelay, bool isEthPrice);

    /// @notice returns the price in USD of symbol.
    function getUSDPrice(address token) external view returns (uint256);

    /// @notice returns if the given token is supported for pricing.
    function isTokenSupported(address token) external view returns (bool);
}

File 26 of 35 : IPausable.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.17;

import "Ownable.sol";

import "IController.sol";

interface IPausable {
    event Paused(uint256 pausedUntil);
    event PauseDurationSet(uint256 pauseDuration);

    function controller() external view returns (IController);

    function pausedUntil() external view returns (uint256);

    function pauseDuration() external view returns (uint256);

    function isPaused() external view returns (bool);

    function setPauseDuration(uint256 _pauseDuration) external;

    function pause() external;
}

File 27 of 35 : Ownable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)

pragma solidity ^0.8.0;

import "Context.sol";

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

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

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor() {
        _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. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby disabling 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);
    }
}

File 28 of 35 : Context.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

pragma solidity ^0.8.0;

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with 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;
    }
}

File 29 of 35 : IGenericOracle.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.17;

import "IOracle.sol";

interface IGenericOracle is IOracle {
    /// @notice returns the oracle to be used to price `token`
    function getOracle(address token) external view returns (IOracle);

    /// @notice converts the price of an LP token to the given underlying
    function curveLpToUnderlying(
        address curveLpToken,
        address underlying,
        uint256 curveLpAmount
    ) external view returns (uint256);

    /// @notice same as above but avoids fetching the underlying price again
    function curveLpToUnderlying(
        address curveLpToken,
        address underlying,
        uint256 curveLpAmount,
        uint256 underlyingPrice
    ) external view returns (uint256);

    /// @notice converts the price an underlying asset to a given Curve LP token
    function underlyingToCurveLp(
        address underlying,
        address curveLpToken,
        uint256 underlyingAmount
    ) external view returns (uint256);
}

File 30 of 35 : IInflationManager.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.17;

interface IInflationManager {
    event TokensClaimed(address indexed pool, uint256 cncAmount);
    event RebalancingRewardHandlerAdded(address indexed pool, address indexed handler);
    event RebalancingRewardHandlerRemoved(address indexed pool, address indexed handler);
    event PoolWeightsUpdated();

    function executeInflationRateUpdate() external;

    function updatePoolWeights() external;

    /// @notice returns the weights of the Conic pools to know how much inflation
    /// each of them will receive, as well as the total amount of USD value in all the pools
    function computePoolWeights()
        external
        view
        returns (address[] memory _pools, uint256[] memory poolWeights, uint256 totalUSDValue);

    function computePoolWeight(
        address pool
    ) external view returns (uint256 poolWeight, uint256 totalUSDValue);

    function currentInflationRate() external view returns (uint256);

    function getCurrentPoolInflationRate(address pool) external view returns (uint256);

    function handleRebalancingRewards(
        address account,
        uint256 deviationBefore,
        uint256 deviationAfter
    ) external;

    function addPoolRebalancingRewardHandler(
        address poolAddress,
        address rebalancingRewardHandler
    ) external;

    function removePoolRebalancingRewardHandler(
        address poolAddress,
        address rebalancingRewardHandler
    ) external;

    function rebalancingRewardHandlers(
        address poolAddress
    ) external view returns (address[] memory);

    function hasPoolRebalancingRewardHandler(
        address poolAddress,
        address handler
    ) external view returns (bool);
}

File 31 of 35 : ILpTokenStaker.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.17;

interface ILpTokenStaker {
    event LpTokenStaked(address indexed account, uint256 amount);
    event LpTokenUnstaked(address indexed account, uint256 amount);
    event TokensClaimed(address indexed pool, uint256 cncAmount);
    event Shutdown();

    function stake(uint256 amount, address conicPool) external;

    function unstake(uint256 amount, address conicPool) external;

    function stakeFor(uint256 amount, address conicPool, address account) external;

    function unstakeFor(uint256 amount, address conicPool, address account) external;

    function unstakeFrom(uint256 amount, address account) external;

    function getUserBalanceForPool(
        address conicPool,
        address account
    ) external view returns (uint256);

    function getBalanceForPool(address conicPool) external view returns (uint256);

    function updateBoost(address user) external;

    function claimCNCRewardsForPool(address pool) external;

    function claimableCnc(address pool) external view returns (uint256);

    function checkpoint(address pool) external returns (uint256);

    function shutdown() external;

    function getBoost(address user) external view returns (uint256);

    function isShutdown() external view returns (bool);
}

File 32 of 35 : IBonding.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.17;

interface IBonding {
    event CncStartPriceSet(uint256 startPrice);
    event PriceIncreaseFactorSet(uint256 factor);
    event MinBondingAmountSet(uint256 amount);
    event Bonded(
        address indexed account,
        address indexed recipient,
        uint256 lpTokenAmount,
        uint256 cncReceived,
        uint256 lockTime
    );
    event DebtPoolSet(address indexed pool);
    event DebtPoolFeesClaimed(uint256 crvAmount, uint256 cvxAmount, uint256 cncAmount);
    event StreamClaimed(address indexed account, uint256 amount);
    event BondingStarted(uint256 amount, uint256 epochs);
    event RemainingCNCRecovered(uint256 amount);

    function startBonding() external;

    function setCncStartPrice(uint256 _cncStartPrice) external;

    function setCncPriceIncreaseFactor(uint256 _priceIncreaseFactor) external;

    function setMinBondingAmount(uint256 _minBondingAmount) external;

    function setDebtPool(address _debtPool) external;

    function bondCncCrvUsd(
        uint256 lpTokenAmount,
        uint256 minCncReceived,
        uint64 cncLockTime
    ) external returns (uint256);

    function recoverRemainingCNC() external;

    function claimStream() external;

    function claimFeesForDebtPool() external;

    function streamCheckpoint() external;

    function accountCheckpoint(address account) external;

    function computeCurrentCncBondPrice() external view returns (uint256);

    function cncAvailable() external view returns (uint256);

    function cncBondPrice() external view returns (uint256);

    function bondCncCrvUsdFor(
        uint256 lpTokenAmount,
        uint256 minCncReceived,
        uint64 cncLockTime,
        address recipient
    ) external returns (uint256);
}

File 33 of 35 : IPoolAdapter.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.17;

interface IPoolAdapter {
    /// @notice This is to set which LP token price the value computation should use
    /// `Latest` uses a freshly computed price
    /// `Cached` uses the price in cache
    /// `Minimum` uses the minimum of these two
    enum PriceMode {
        Latest,
        Cached,
        Minimum
    }

    /// @notice Deposit `underlyingAmount` of `underlying` into `pool`
    /// @dev This function should be written with the assumption that it will be delegate-called into
    function deposit(address pool, address underlying, uint256 underlyingAmount) external;

    /// @notice Withdraw `underlyingAmount` of `underlying` from `pool`
    /// @dev This function should be written with the assumption that it will be delegate-called into
    function withdraw(address pool, address underlying, uint256 underlyingAmount) external;

    /// @notice Returns the amount of of assets that `conicPool` holds in `pool`, in terms of USD
    function computePoolValueInUSD(
        address conicPool,
        address pool
    ) external view returns (uint256 usdAmount);

    /// @notice Updates the price caches of the given pools
    function updatePriceCache(address pool) external;

    /// @notice Returns the amount of of assets that `conicPool` holds in `pool`, in terms of USD
    /// using the given price mode
    function computePoolValueInUSD(
        address conicPool,
        address pool,
        PriceMode priceMode
    ) external view returns (uint256 usdAmount);

    /// @notice Returns the amount of of assets that `conicPool` holds in `pool`, in terms of underlying
    function computePoolValueInUnderlying(
        address conicPool,
        address pool,
        address underlying,
        uint256 underlyingPrice
    ) external view returns (uint256 underlyingAmount);

    /// @notice Returns the amount of of assets that `conicPool` holds in `pool`, in terms of underlying
    /// using the given price mode
    function computePoolValueInUnderlying(
        address conicPool,
        address pool,
        address underlying,
        uint256 underlyingPrice,
        PriceMode priceMode
    ) external view returns (uint256 underlyingAmount);

    /// @notice Claim earnings of `conicPool` from `pool`
    function claimEarnings(address conicPool, address pool) external;

    /// @notice Returns the LP token of a given `pool`
    function lpToken(address pool) external view returns (address);

    /// @notice Returns true if `pool` supports `asset`
    function supportsAsset(address pool, address asset) external view returns (bool);

    /// @notice Returns the amount of CRV earned by `pool` on Convex
    function getCRVEarnedOnConvex(
        address account,
        address curvePool
    ) external view returns (uint256);

    /// @notice Executes a sanity check, e.g. checking for reentrancy
    function executeSanityCheck(address pool) external;

    /// @notice returns all the underlying coins of the pool
    function getAllUnderlyingCoins(address pool) external view returns (address[] memory);
}

File 34 of 35 : IFeeRecipient.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.17;

interface IFeeRecipient {
    event FeesReceived(address indexed sender, uint256 crvAmount, uint256 cvxAmount);

    function receiveFees(uint256 amountCrv, uint256 amountCvx) external;
}

File 35 of 35 : StringUtils.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.17;

library StringUtils {
    uint256 internal constant _ASCII_0 = 48;

    function extractMajorVersion(string memory version) internal pure returns (uint256) {
        bytes memory versionBytes = bytes(version);
        uint256 majorVersion = 0;
        for (
            uint256 i = versionBytes[0] == "v" ? 1 : 0;
            i < versionBytes.length && versionBytes[i] != ".";
            i++
        ) {
            majorVersion = majorVersion * 10 + (uint256(uint8(versionBytes[i])) - _ASCII_0);
        }
        return majorVersion;
    }
}

Settings
{
  "evmVersion": "london",
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "libraries": {
    "CurveHandler.sol": {}
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  }
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"controller_","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"_curvePool","type":"address"},{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"deposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_curvePool","type":"address"}],"name":"isReentrantCall","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_curvePool","type":"address"}],"name":"reentrancyCheck","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_curvePool","type":"address"},{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"}]

60a06040523480156200001157600080fd5b5060405162002c0538038062002c05833981016040819052620000349162000046565b6001600160a01b031660805262000078565b6000602082840312156200005957600080fd5b81516001600160a01b03811681146200007157600080fd5b9392505050565b608051612b39620000cc600039600081816101870152818161040a015281816107b401528181610af901528181610c3201528181610d6c015281816114f9015281816116220152611ab00152612b396000f3fe608060405234801561001057600080fd5b506004361061004c5760003560e01c80631aa5fba9146100515780638340f54914610078578063af9fe9e51461008d578063d9caed12146100a0575b600080fd5b61006461005f3660046124d9565b6100b3565b604051901515815260200160405180910390f35b61008b6100863660046124f6565b610406565b005b61008b61009b3660046124d9565b610757565b61008b6100ae3660046124f6565b6107b0565b60006001600160a01b0382163f7f9e28a09452d2354fc4e15e3244dde27cbc4d52f12a10b91f2ca755b672bfa9be81148061010d57507f3429b8decaf6b79a2721e434f60c3c47b9961fdba16eb6ac6c50d3690ac2527681145b1561018357826001600160a01b03166386fc88d36040518163ffffffff1660e01b8152600401602060405180830381865afa92505050801561016c575060408051601f3d908101601f1916820190925261016991810190612537565b60015b6101795750600192915050565b5060009392505050565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316639f82b2176040518163ffffffff1660e01b8152600401602060405180830381865afa1580156101e3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102079190612550565b604051630bb075af60e11b81526001600160a01b0386811660048301529190911690631760eb5e90602401602060405180830381865afa15801561024f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102739190612537565b9050600061028085610af1565b90506000805a90508360020361034e57866001600160a01b0316635b41b908846102ab5760016102ae565b60005b856102ba5760006102bd565b60015b6040516001600160e01b031960e085901b1681526004810192909252602482015260006044820181905260648201526084016020604051808303816000875af192505050801561032a575060408051601f3d908101601f1916820190925261032791810190612537565b60015b610340575a6103399082612583565b91506103f8565b506000979650505050505050565b866001600160a01b0316633df021248461036957600161036c565b60005b8561037857600061037b565b60015b6040516001600160e01b031960e085901b168152600f92830b6004820152910b60248201526000604482018190526064820152608401600060405180830381600087803b1580156103cb57600080fd5b505af19250505080156103dc575060015b6103eb575a6103399082612583565b5060009695505050505050565b506113881195945050505050565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316639f82b2176040518163ffffffff1660e01b8152600401602060405180830381865afa158015610466573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061048a9190612550565b905060006104988585610c07565b9050816001600160a01b031663b677560f86836104b557866104cb565b73eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee5b6040516001600160e01b031960e085901b1681526001600160a01b03928316600482015291166024820152604401602060405180830381865afa158015610516573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061053a9190612596565b610745576040516339d16a2360e11b81526001600160a01b038681166004830152600091908416906373a2d44690602401602060405180830381865afa158015610588573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105ac9190612550565b90506001600160a01b0381166105dd5760405162461bcd60e51b81526004016105d4906125b8565b60405180910390fd5b604051631da958a960e21b81526001600160a01b038281166004830152600091908516906376a562a490602401602060405180830381865afa158015610627573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061064b9190612550565b6040516370a0823160e01b81523060048201529091506000906001600160a01b038316906370a0823190602401602060405180830381865afa158015610695573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106b99190612537565b90506106c6838789610d41565b6040516370a0823160e01b8152306004820152919650869181906001600160a01b038416906370a0823190602401602060405180830381865afa158015610711573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107359190612537565b61073f9190612583565b95505050505b610750858486610d41565b5050505050565b610760816100b3565b156107ad5760405162461bcd60e51b815260206004820152601c60248201527f437572766548616e646c65723a207265656e7472616e742063616c6c0000000060448201526064016105d4565b50565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316639f82b2176040518163ffffffff1660e01b8152600401602060405180830381865afa158015610810573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108349190612550565b905060006108428585610c07565b9050816001600160a01b031663b677560f868361085f5786610875565b73eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee5b6040516001600160e01b031960e085901b1681526001600160a01b03928316600482015291166024820152604401602060405180830381865afa1580156108c0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108e49190612596565b610ae6576040516339d16a2360e11b81526001600160a01b038681166004830152600091908416906373a2d44690602401602060405180830381865afa158015610932573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109569190612550565b90506001600160a01b03811661097e5760405162461bcd60e51b81526004016105d4906125b8565b604051631da958a960e21b81526001600160a01b038281166004830152600091908516906376a562a490602401602060405180830381865afa1580156109c8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109ec9190612550565b6040516370a0823160e01b81523060048201529091506000906001600160a01b038316906370a0823190602401602060405180830381865afa158015610a36573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a5a9190612537565b9050610a678887846114e7565b6040516370a0823160e01b8152306004820152929750879281906001600160a01b038416906370a0823190602401602060405180830381865afa158015610ab2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ad69190612537565b610ae09190612583565b95505050505b6107508584866114e7565b600080600f0b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316639f82b2176040518163ffffffff1660e01b8152600401602060405180830381865afa158015610b55573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b799190612550565b604051623ae2e960e21b81526001600160a01b03858116600483015273c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26024830152919091169062eb8ba490604401602060405180830381865afa158015610bd9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bfd91906125fc565b600f0b1492915050565b60006001600160a01b03821673c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2148015610d3857507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316639f82b2176040518163ffffffff1660e01b8152600401602060405180830381865afa158015610c8e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cb29190612550565b60405163b677560f60e01b81526001600160a01b03858116600483015273eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee6024830152919091169063b677560f90604401602060405180830381865afa158015610d14573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d389190612596565b90505b92915050565b6000610d4d8483610c07565b905080610d6857610d686001600160a01b038316858561190d565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316639f82b2176040518163ffffffff1660e01b8152600401602060405180830381865afa158015610dc8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dec9190612550565b90506000816001600160a01b031662eb8ba48785610e0a5786610e20565b73eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee5b6040516001600160e01b031960e085901b1681526001600160a01b03928316600482015291166024820152604401602060405180830381865afa158015610e6b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e8f91906125fc565b604051635f92e81560e11b81526001600160a01b0388811660048301526001600160801b0392909216925060009184169063bf25d02a90602401602060405180830381865afa158015610ee6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f0a9190612537565b9050610f15876119c7565b15610ff85760008167ffffffffffffffff811115610f3557610f3561261f565b604051908082528060200260200182016040528015610f5e578160200160208202803683370190505b50905086818481518110610f7457610f74612635565b6020908102919091010152604051635b96faef60e11b81526001600160a01b0389169063b72df5de90610fae90849060009060040161264b565b6020604051808303816000875af1158015610fcd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ff19190612537565b50506114de565b806002036110ff576110086123f1565b8681846002811061101b5761101b612635565b602002015284156110975761102f87611a4b565b604051630b4c7e4d60e01b81526001600160a01b03891690630b4c7e4d9089906110609085906000906004016126b6565b6000604051808303818588803b15801561107957600080fd5b505af115801561108d573d6000803e3d6000fd5b50505050506110f9565b604051630b4c7e4d60e01b81526001600160a01b03891690630b4c7e4d906110c69084906000906004016126b6565b600060405180830381600087803b1580156110e057600080fd5b505af11580156110f4573d6000803e3d6000fd5b505050505b506114de565b806003036111965761110f61240f565b8681846003811061112257611122612635565b602002015284156111675761113687611a4b565b604051634515cef360e01b81526001600160a01b03891690634515cef39089906110609085906000906004016126f4565b604051634515cef360e01b81526001600160a01b03891690634515cef3906110c69084906000906004016126f4565b8060040361122b576111a661242d565b868184600481106111b9576111b9612635565b602002015284156111fd576111cd87611a4b565b60405162a6cbcd60e21b81526001600160a01b0389169063029b2f34908990611060908590600090600401612732565b60405162a6cbcd60e21b81526001600160a01b0389169063029b2f34906110c6908490600090600401612732565b806005036112c25761123b61244b565b8681846005811061124e5761124e612635565b602002015284156112935761126287611a4b565b604051638473849960e01b81526001600160a01b038916906384738499908990611060908590600090600401612770565b604051638473849960e01b81526001600160a01b038916906384738499906110c6908490600090600401612770565b80600603611359576112d2612469565b868184600681106112e5576112e5612635565b6020020152841561132a576112f987611a4b565b604051633f8a44f360e01b81526001600160a01b03891690633f8a44f39089906110609085906000906004016127ae565b604051633f8a44f360e01b81526001600160a01b03891690633f8a44f3906110c69084906000906004016127ae565b806007036113f057611369612487565b8681846007811061137c5761137c612635565b602002015284156113c15761139087611a4b565b60405163a5918ca160e01b81526001600160a01b0389169063a5918ca19089906110609085906000906004016127ec565b60405163a5918ca160e01b81526001600160a01b0389169063a5918ca1906110c69084906000906004016127ec565b80600803611487576114006124a5565b8681846008811061141357611413612635565b602002015284156114585761142787611a4b565b6040516352d7f31760e01b81526001600160a01b038916906352d7f31790899061106090859060009060040161282b565b6040516352d7f31760e01b81526001600160a01b038916906352d7f317906110c690849060009060040161282b565b60405162461bcd60e51b815260206004820152602660248201527f696e76616c6964206e756d626572206f6620636f696e7320666f72206375727660448201526519481c1bdbdb60d21b60648201526084016105d4565b50505050505050565b60006114f38483610c07565b905060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316639f82b2176040518163ffffffff1660e01b8152600401602060405180830381865afa158015611555573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115799190612550565b6001600160a01b031662eb8ba4868461159257856115a8565b73eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee5b6040516001600160e01b031960e085901b1681526001600160a01b03928316600482015291166024820152604401602060405180830381865afa1580156115f3573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061161791906125fc565b9050600047905060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316639f82b2176040518163ffffffff1660e01b8152600401602060405180830381865afa15801561167e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116a29190612550565b604051630bb075af60e11b81526001600160a01b0389811660048301529190911690631760eb5e90602401602060405180830381865afa1580156116ea573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061170e9190612537565b90508060000361172857611723878785611aac565b6118e6565b611731876119c7565b156117b957604051630d2680e960e11b815260048101879052600f84900b6024820152600060448201526001600160a01b03881690631a4d01d2906064015b6020604051808303816000875af115801561178f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117b39190612537565b506118e6565b8060010361183157604051630d2680e960e11b815260048101879052600f84900b6024820152600060448201526001600160a01b03881690631a4d01d290606401600060405180830381600087803b15801561181457600080fd5b505af1158015611828573d6000803e3d6000fd5b505050506118e6565b8060020361188a576040516307329bcd60e01b8152600481018790526001600160801b03841660248201526000604482015284151560648201523060848201526001600160a01b038816906307329bcd9060a401611770565b60405162461bcd60e51b815260206004820152602b60248201527f437572766548616e646c65723a20756e737570706f7274656420696e7465726660448201526a30b1b2903b32b939b4b7b760a91b60648201526084016105d4565b83156114de5760006118f88347612583565b905061190381611fa2565b5050505050505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663095ea7b360e01b17905261195e8482612005565b6119c157604080516001600160a01b038516602482015260006044808301919091528251808303909101815260649091019091526020810180516001600160e01b031663095ea7b360e01b1790526119b79085906120ac565b6119c184826120ac565b50505050565b6000816001600160a01b03166354fd4d506040518163ffffffff1660e01b8152600401600060405180830381865afa925050508015611a2857506040513d6000823e601f3d908101601f19168201604052611a25919081019061289d565b60015b611a3457506000919050565b6000611a3f82612186565b60071115949350505050565b604051632e1a7d4d60e01b81526004810182905273c02aaa39b223fe8d0a0e5c4f27ead9083c756cc290632e1a7d4d90602401600060405180830381600087803b158015611a9857600080fd5b505af1158015610750573d6000803e3d6000fd5b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316639f82b2176040518163ffffffff1660e01b8152600401602060405180830381865afa158015611b0c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b309190612550565b604051635f92e81560e11b81526001600160a01b03868116600483015291925060009183169063bf25d02a90602401602060405180830381865afa158015611b7c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ba09190612537565b905080600203611c1857611bb26123f1565b6040516316cd8e2760e21b81526001600160a01b03871690635b36389c90611be09088908590600401612931565b600060405180830381600087803b158015611bfa57600080fd5b505af1158015611c0e573d6000803e3d6000fd5b5050505050611dd4565b80600303611c5657611c2861240f565b60405163ecb586a560e01b81526001600160a01b0387169063ecb586a590611be09088908590600401612945565b80600403611c9457611c6661242d565b604051637d49d87560e01b81526001600160a01b03871690637d49d87590611be09088908590600401612959565b80600503611cd257611ca461244b565b6040516371dffae760e11b81526001600160a01b0387169063e3bff5ce90611be0908890859060040161296d565b80600603611d1057611ce2612469565b60405163684916a560e01b81526001600160a01b0387169063684916a590611be09088908590600401612981565b80600703611d4e57611d20612487565b604051635c912d2b60e01b81526001600160a01b03871690635c912d2b90611be09088908590600401612995565b80600803611d8c57611d5e6124a5565b604051633fec654960e01b81526001600160a01b03871690633fec654990611be090889085906004016129aa565b60405162461bcd60e51b815260206004820152601f60248201527f437572766548616e646c65723a20756e737570706f7274656420636f696e730060448201526064016105d4565b60005b81811015611f9a5783600f0b810315611f8857604051630fa1ef5160e31b81526001600160a01b03878116600483015260009190851690637d0f7a8890602401600060405180830381865afa158015611e34573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611e5c91908101906129bf565b90506000818381518110611e7257611e72612635565b60209081029190910101516040516370a0823160e01b81523060048201529091506000906001600160a01b038316906370a0823190602401602060405180830381865afa158015611ec7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611eeb9190612537565b905080600003611efd57505050611f88565b611f116001600160a01b0383168a8361190d565b604051630f7c084960e21b8152600f85810b600483015288900b602482015260448101829052600060648201526001600160a01b038a1690633df0212490608401600060405180830381600087803b158015611f6c57600080fd5b505af1158015611f80573d6000803e3d6000fd5b505050505050505b80611f9281612a71565b915050611dd7565b505050505050565b73c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031663d0e30db0826040518263ffffffff1660e01b81526004016000604051808303818588803b158015611ff157600080fd5b505af1158015611f9a573d6000803e3d6000fd5b6000806000846001600160a01b0316846040516120229190612a8a565b6000604051808303816000865af19150503d806000811461205f576040519150601f19603f3d011682016040523d82523d6000602084013e612064565b606091505b509150915081801561208e57508051158061208e57508080602001905181019061208e9190612596565b80156120a357506001600160a01b0385163b15155b95945050505050565b6000612101826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661225d9092919063ffffffff16565b90508051600014806121225750808060200190518101906121229190612596565b6121815760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016105d4565b505050565b600080829050600080826000815181106121a2576121a2612635565b6020910101516001600160f81b031916603b60f91b146121c35760006121c6565b60015b60ff1690505b82518110801561220157508281815181106121e9576121e9612635565b6020910101516001600160f81b031916601760f91b14155b1561225557603083828151811061221a5761221a612635565b016020015161222c919060f81c612583565b61223783600a612aa6565b6122419190612abd565b91508061224d81612a71565b9150506121cc565b509392505050565b606061226c8484600085612276565b90505b9392505050565b6060824710156122d75760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016105d4565b600080866001600160a01b031685876040516122f39190612a8a565b60006040518083038185875af1925050503d8060008114612330576040519150601f19603f3d011682016040523d82523d6000602084013e612335565b606091505b509150915061234687838387612353565b925050505b949350505050565b606083156123c25782516000036123bb576001600160a01b0385163b6123bb5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016105d4565b508161234b565b61234b83838151156123d75781518083602001fd5b8060405162461bcd60e51b81526004016105d49190612ad0565b60405180604001604052806002906020820280368337509192915050565b60405180606001604052806003906020820280368337509192915050565b60405180608001604052806004906020820280368337509192915050565b6040518060a001604052806005906020820280368337509192915050565b6040518060c001604052806006906020820280368337509192915050565b6040518060e001604052806007906020820280368337509192915050565b6040518061010001604052806008906020820280368337509192915050565b6001600160a01b03811681146107ad57600080fd5b6000602082840312156124eb57600080fd5b813561226f816124c4565b60008060006060848603121561250b57600080fd5b8335612516816124c4565b92506020840135612526816124c4565b929592945050506040919091013590565b60006020828403121561254957600080fd5b5051919050565b60006020828403121561256257600080fd5b815161226f816124c4565b634e487b7160e01b600052601160045260246000fd5b81810381811115610d3b57610d3b61256d565b6000602082840312156125a857600080fd5b8151801515811461226f57600080fd5b60208082526024908201527f437572766548616e646c65723a20696e7465726d656469617465206e6f7420666040820152631bdd5b9960e21b606082015260800190565b60006020828403121561260e57600080fd5b815180600f0b811461226f57600080fd5b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b604080825283519082018190526000906020906060840190828701845b8281101561268457815184529284019290840190600101612668565b50505092019290925292915050565b8060005b60028110156119c1578151845260209384019390910190600101612697565b606081016126c48285612693565b8260408301529392505050565b8060005b60038110156119c15781518452602093840193909101906001016126d5565b6080810161270282856126d1565b8260608301529392505050565b8060005b60048110156119c1578151845260209384019390910190600101612713565b60a08101612740828561270f565b8260808301529392505050565b8060005b60058110156119c1578151845260209384019390910190600101612751565b60c0810161277e828561274d565b8260a08301529392505050565b8060005b60068110156119c157815184526020938401939091019060010161278f565b60e081016127bc828561278b565b8260c08301529392505050565b8060005b60078110156119c15781518452602093840193909101906001016127cd565b61010081016127fb82856127c9565b8260e08301529392505050565b8060005b60088110156119c157815184526020938401939091019060010161280c565b610120810161283a8285612808565b826101008301529392505050565b604051601f8201601f1916810167ffffffffffffffff811182821017156128715761287161261f565b604052919050565b60005b8381101561289457818101518382015260200161287c565b50506000910152565b6000602082840312156128af57600080fd5b815167ffffffffffffffff808211156128c757600080fd5b818401915084601f8301126128db57600080fd5b8151818111156128ed576128ed61261f565b612900601f8201601f1916602001612848565b915080825285602082850101111561291757600080fd5b612928816020840160208601612879565b50949350505050565b8281526060810161226f6020830184612693565b8281526080810161226f60208301846126d1565b82815260a0810161226f602083018461270f565b82815260c0810161226f602083018461274d565b82815260e0810161226f602083018461278b565b828152610100810161226f60208301846127c9565b828152610120810161226f6020830184612808565b600060208083850312156129d257600080fd5b825167ffffffffffffffff808211156129ea57600080fd5b818501915085601f8301126129fe57600080fd5b815181811115612a1057612a1061261f565b8060051b9150612a21848301612848565b8181529183018401918481019088841115612a3b57600080fd5b938501935b83851015612a655784519250612a55836124c4565b8282529385019390850190612a40565b98975050505050505050565b600060018201612a8357612a8361256d565b5060010190565b60008251612a9c818460208701612879565b9190910192915050565b8082028115828204841417610d3b57610d3b61256d565b80820180821115610d3b57610d3b61256d565b6020815260008251806020840152612aef816040850160208701612879565b601f01601f1916919091016040019291505056fea26469706673582212206b75539d99a87634d22f70623f1087da272c7b9e758acda55e6bd71e8279089164736f6c634300081100330000000000000000000000002790ec478f150a98f5d96755601a26403df57eae

Deployed Bytecode

0x608060405234801561001057600080fd5b506004361061004c5760003560e01c80631aa5fba9146100515780638340f54914610078578063af9fe9e51461008d578063d9caed12146100a0575b600080fd5b61006461005f3660046124d9565b6100b3565b604051901515815260200160405180910390f35b61008b6100863660046124f6565b610406565b005b61008b61009b3660046124d9565b610757565b61008b6100ae3660046124f6565b6107b0565b60006001600160a01b0382163f7f9e28a09452d2354fc4e15e3244dde27cbc4d52f12a10b91f2ca755b672bfa9be81148061010d57507f3429b8decaf6b79a2721e434f60c3c47b9961fdba16eb6ac6c50d3690ac2527681145b1561018357826001600160a01b03166386fc88d36040518163ffffffff1660e01b8152600401602060405180830381865afa92505050801561016c575060408051601f3d908101601f1916820190925261016991810190612537565b60015b6101795750600192915050565b5060009392505050565b60007f0000000000000000000000002790ec478f150a98f5d96755601a26403df57eae6001600160a01b0316639f82b2176040518163ffffffff1660e01b8152600401602060405180830381865afa1580156101e3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102079190612550565b604051630bb075af60e11b81526001600160a01b0386811660048301529190911690631760eb5e90602401602060405180830381865afa15801561024f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102739190612537565b9050600061028085610af1565b90506000805a90508360020361034e57866001600160a01b0316635b41b908846102ab5760016102ae565b60005b856102ba5760006102bd565b60015b6040516001600160e01b031960e085901b1681526004810192909252602482015260006044820181905260648201526084016020604051808303816000875af192505050801561032a575060408051601f3d908101601f1916820190925261032791810190612537565b60015b610340575a6103399082612583565b91506103f8565b506000979650505050505050565b866001600160a01b0316633df021248461036957600161036c565b60005b8561037857600061037b565b60015b6040516001600160e01b031960e085901b168152600f92830b6004820152910b60248201526000604482018190526064820152608401600060405180830381600087803b1580156103cb57600080fd5b505af19250505080156103dc575060015b6103eb575a6103399082612583565b5060009695505050505050565b506113881195945050505050565b60007f0000000000000000000000002790ec478f150a98f5d96755601a26403df57eae6001600160a01b0316639f82b2176040518163ffffffff1660e01b8152600401602060405180830381865afa158015610466573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061048a9190612550565b905060006104988585610c07565b9050816001600160a01b031663b677560f86836104b557866104cb565b73eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee5b6040516001600160e01b031960e085901b1681526001600160a01b03928316600482015291166024820152604401602060405180830381865afa158015610516573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061053a9190612596565b610745576040516339d16a2360e11b81526001600160a01b038681166004830152600091908416906373a2d44690602401602060405180830381865afa158015610588573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105ac9190612550565b90506001600160a01b0381166105dd5760405162461bcd60e51b81526004016105d4906125b8565b60405180910390fd5b604051631da958a960e21b81526001600160a01b038281166004830152600091908516906376a562a490602401602060405180830381865afa158015610627573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061064b9190612550565b6040516370a0823160e01b81523060048201529091506000906001600160a01b038316906370a0823190602401602060405180830381865afa158015610695573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106b99190612537565b90506106c6838789610d41565b6040516370a0823160e01b8152306004820152919650869181906001600160a01b038416906370a0823190602401602060405180830381865afa158015610711573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107359190612537565b61073f9190612583565b95505050505b610750858486610d41565b5050505050565b610760816100b3565b156107ad5760405162461bcd60e51b815260206004820152601c60248201527f437572766548616e646c65723a207265656e7472616e742063616c6c0000000060448201526064016105d4565b50565b60007f0000000000000000000000002790ec478f150a98f5d96755601a26403df57eae6001600160a01b0316639f82b2176040518163ffffffff1660e01b8152600401602060405180830381865afa158015610810573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108349190612550565b905060006108428585610c07565b9050816001600160a01b031663b677560f868361085f5786610875565b73eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee5b6040516001600160e01b031960e085901b1681526001600160a01b03928316600482015291166024820152604401602060405180830381865afa1580156108c0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108e49190612596565b610ae6576040516339d16a2360e11b81526001600160a01b038681166004830152600091908416906373a2d44690602401602060405180830381865afa158015610932573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109569190612550565b90506001600160a01b03811661097e5760405162461bcd60e51b81526004016105d4906125b8565b604051631da958a960e21b81526001600160a01b038281166004830152600091908516906376a562a490602401602060405180830381865afa1580156109c8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109ec9190612550565b6040516370a0823160e01b81523060048201529091506000906001600160a01b038316906370a0823190602401602060405180830381865afa158015610a36573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a5a9190612537565b9050610a678887846114e7565b6040516370a0823160e01b8152306004820152929750879281906001600160a01b038416906370a0823190602401602060405180830381865afa158015610ab2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ad69190612537565b610ae09190612583565b95505050505b6107508584866114e7565b600080600f0b7f0000000000000000000000002790ec478f150a98f5d96755601a26403df57eae6001600160a01b0316639f82b2176040518163ffffffff1660e01b8152600401602060405180830381865afa158015610b55573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b799190612550565b604051623ae2e960e21b81526001600160a01b03858116600483015273c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26024830152919091169062eb8ba490604401602060405180830381865afa158015610bd9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bfd91906125fc565b600f0b1492915050565b60006001600160a01b03821673c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2148015610d3857507f0000000000000000000000002790ec478f150a98f5d96755601a26403df57eae6001600160a01b0316639f82b2176040518163ffffffff1660e01b8152600401602060405180830381865afa158015610c8e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cb29190612550565b60405163b677560f60e01b81526001600160a01b03858116600483015273eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee6024830152919091169063b677560f90604401602060405180830381865afa158015610d14573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d389190612596565b90505b92915050565b6000610d4d8483610c07565b905080610d6857610d686001600160a01b038316858561190d565b60007f0000000000000000000000002790ec478f150a98f5d96755601a26403df57eae6001600160a01b0316639f82b2176040518163ffffffff1660e01b8152600401602060405180830381865afa158015610dc8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dec9190612550565b90506000816001600160a01b031662eb8ba48785610e0a5786610e20565b73eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee5b6040516001600160e01b031960e085901b1681526001600160a01b03928316600482015291166024820152604401602060405180830381865afa158015610e6b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e8f91906125fc565b604051635f92e81560e11b81526001600160a01b0388811660048301526001600160801b0392909216925060009184169063bf25d02a90602401602060405180830381865afa158015610ee6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f0a9190612537565b9050610f15876119c7565b15610ff85760008167ffffffffffffffff811115610f3557610f3561261f565b604051908082528060200260200182016040528015610f5e578160200160208202803683370190505b50905086818481518110610f7457610f74612635565b6020908102919091010152604051635b96faef60e11b81526001600160a01b0389169063b72df5de90610fae90849060009060040161264b565b6020604051808303816000875af1158015610fcd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ff19190612537565b50506114de565b806002036110ff576110086123f1565b8681846002811061101b5761101b612635565b602002015284156110975761102f87611a4b565b604051630b4c7e4d60e01b81526001600160a01b03891690630b4c7e4d9089906110609085906000906004016126b6565b6000604051808303818588803b15801561107957600080fd5b505af115801561108d573d6000803e3d6000fd5b50505050506110f9565b604051630b4c7e4d60e01b81526001600160a01b03891690630b4c7e4d906110c69084906000906004016126b6565b600060405180830381600087803b1580156110e057600080fd5b505af11580156110f4573d6000803e3d6000fd5b505050505b506114de565b806003036111965761110f61240f565b8681846003811061112257611122612635565b602002015284156111675761113687611a4b565b604051634515cef360e01b81526001600160a01b03891690634515cef39089906110609085906000906004016126f4565b604051634515cef360e01b81526001600160a01b03891690634515cef3906110c69084906000906004016126f4565b8060040361122b576111a661242d565b868184600481106111b9576111b9612635565b602002015284156111fd576111cd87611a4b565b60405162a6cbcd60e21b81526001600160a01b0389169063029b2f34908990611060908590600090600401612732565b60405162a6cbcd60e21b81526001600160a01b0389169063029b2f34906110c6908490600090600401612732565b806005036112c25761123b61244b565b8681846005811061124e5761124e612635565b602002015284156112935761126287611a4b565b604051638473849960e01b81526001600160a01b038916906384738499908990611060908590600090600401612770565b604051638473849960e01b81526001600160a01b038916906384738499906110c6908490600090600401612770565b80600603611359576112d2612469565b868184600681106112e5576112e5612635565b6020020152841561132a576112f987611a4b565b604051633f8a44f360e01b81526001600160a01b03891690633f8a44f39089906110609085906000906004016127ae565b604051633f8a44f360e01b81526001600160a01b03891690633f8a44f3906110c69084906000906004016127ae565b806007036113f057611369612487565b8681846007811061137c5761137c612635565b602002015284156113c15761139087611a4b565b60405163a5918ca160e01b81526001600160a01b0389169063a5918ca19089906110609085906000906004016127ec565b60405163a5918ca160e01b81526001600160a01b0389169063a5918ca1906110c69084906000906004016127ec565b80600803611487576114006124a5565b8681846008811061141357611413612635565b602002015284156114585761142787611a4b565b6040516352d7f31760e01b81526001600160a01b038916906352d7f31790899061106090859060009060040161282b565b6040516352d7f31760e01b81526001600160a01b038916906352d7f317906110c690849060009060040161282b565b60405162461bcd60e51b815260206004820152602660248201527f696e76616c6964206e756d626572206f6620636f696e7320666f72206375727660448201526519481c1bdbdb60d21b60648201526084016105d4565b50505050505050565b60006114f38483610c07565b905060007f0000000000000000000000002790ec478f150a98f5d96755601a26403df57eae6001600160a01b0316639f82b2176040518163ffffffff1660e01b8152600401602060405180830381865afa158015611555573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115799190612550565b6001600160a01b031662eb8ba4868461159257856115a8565b73eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee5b6040516001600160e01b031960e085901b1681526001600160a01b03928316600482015291166024820152604401602060405180830381865afa1580156115f3573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061161791906125fc565b9050600047905060007f0000000000000000000000002790ec478f150a98f5d96755601a26403df57eae6001600160a01b0316639f82b2176040518163ffffffff1660e01b8152600401602060405180830381865afa15801561167e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116a29190612550565b604051630bb075af60e11b81526001600160a01b0389811660048301529190911690631760eb5e90602401602060405180830381865afa1580156116ea573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061170e9190612537565b90508060000361172857611723878785611aac565b6118e6565b611731876119c7565b156117b957604051630d2680e960e11b815260048101879052600f84900b6024820152600060448201526001600160a01b03881690631a4d01d2906064015b6020604051808303816000875af115801561178f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117b39190612537565b506118e6565b8060010361183157604051630d2680e960e11b815260048101879052600f84900b6024820152600060448201526001600160a01b03881690631a4d01d290606401600060405180830381600087803b15801561181457600080fd5b505af1158015611828573d6000803e3d6000fd5b505050506118e6565b8060020361188a576040516307329bcd60e01b8152600481018790526001600160801b03841660248201526000604482015284151560648201523060848201526001600160a01b038816906307329bcd9060a401611770565b60405162461bcd60e51b815260206004820152602b60248201527f437572766548616e646c65723a20756e737570706f7274656420696e7465726660448201526a30b1b2903b32b939b4b7b760a91b60648201526084016105d4565b83156114de5760006118f88347612583565b905061190381611fa2565b5050505050505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663095ea7b360e01b17905261195e8482612005565b6119c157604080516001600160a01b038516602482015260006044808301919091528251808303909101815260649091019091526020810180516001600160e01b031663095ea7b360e01b1790526119b79085906120ac565b6119c184826120ac565b50505050565b6000816001600160a01b03166354fd4d506040518163ffffffff1660e01b8152600401600060405180830381865afa925050508015611a2857506040513d6000823e601f3d908101601f19168201604052611a25919081019061289d565b60015b611a3457506000919050565b6000611a3f82612186565b60071115949350505050565b604051632e1a7d4d60e01b81526004810182905273c02aaa39b223fe8d0a0e5c4f27ead9083c756cc290632e1a7d4d90602401600060405180830381600087803b158015611a9857600080fd5b505af1158015610750573d6000803e3d6000fd5b60007f0000000000000000000000002790ec478f150a98f5d96755601a26403df57eae6001600160a01b0316639f82b2176040518163ffffffff1660e01b8152600401602060405180830381865afa158015611b0c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b309190612550565b604051635f92e81560e11b81526001600160a01b03868116600483015291925060009183169063bf25d02a90602401602060405180830381865afa158015611b7c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ba09190612537565b905080600203611c1857611bb26123f1565b6040516316cd8e2760e21b81526001600160a01b03871690635b36389c90611be09088908590600401612931565b600060405180830381600087803b158015611bfa57600080fd5b505af1158015611c0e573d6000803e3d6000fd5b5050505050611dd4565b80600303611c5657611c2861240f565b60405163ecb586a560e01b81526001600160a01b0387169063ecb586a590611be09088908590600401612945565b80600403611c9457611c6661242d565b604051637d49d87560e01b81526001600160a01b03871690637d49d87590611be09088908590600401612959565b80600503611cd257611ca461244b565b6040516371dffae760e11b81526001600160a01b0387169063e3bff5ce90611be0908890859060040161296d565b80600603611d1057611ce2612469565b60405163684916a560e01b81526001600160a01b0387169063684916a590611be09088908590600401612981565b80600703611d4e57611d20612487565b604051635c912d2b60e01b81526001600160a01b03871690635c912d2b90611be09088908590600401612995565b80600803611d8c57611d5e6124a5565b604051633fec654960e01b81526001600160a01b03871690633fec654990611be090889085906004016129aa565b60405162461bcd60e51b815260206004820152601f60248201527f437572766548616e646c65723a20756e737570706f7274656420636f696e730060448201526064016105d4565b60005b81811015611f9a5783600f0b810315611f8857604051630fa1ef5160e31b81526001600160a01b03878116600483015260009190851690637d0f7a8890602401600060405180830381865afa158015611e34573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611e5c91908101906129bf565b90506000818381518110611e7257611e72612635565b60209081029190910101516040516370a0823160e01b81523060048201529091506000906001600160a01b038316906370a0823190602401602060405180830381865afa158015611ec7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611eeb9190612537565b905080600003611efd57505050611f88565b611f116001600160a01b0383168a8361190d565b604051630f7c084960e21b8152600f85810b600483015288900b602482015260448101829052600060648201526001600160a01b038a1690633df0212490608401600060405180830381600087803b158015611f6c57600080fd5b505af1158015611f80573d6000803e3d6000fd5b505050505050505b80611f9281612a71565b915050611dd7565b505050505050565b73c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031663d0e30db0826040518263ffffffff1660e01b81526004016000604051808303818588803b158015611ff157600080fd5b505af1158015611f9a573d6000803e3d6000fd5b6000806000846001600160a01b0316846040516120229190612a8a565b6000604051808303816000865af19150503d806000811461205f576040519150601f19603f3d011682016040523d82523d6000602084013e612064565b606091505b509150915081801561208e57508051158061208e57508080602001905181019061208e9190612596565b80156120a357506001600160a01b0385163b15155b95945050505050565b6000612101826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661225d9092919063ffffffff16565b90508051600014806121225750808060200190518101906121229190612596565b6121815760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016105d4565b505050565b600080829050600080826000815181106121a2576121a2612635565b6020910101516001600160f81b031916603b60f91b146121c35760006121c6565b60015b60ff1690505b82518110801561220157508281815181106121e9576121e9612635565b6020910101516001600160f81b031916601760f91b14155b1561225557603083828151811061221a5761221a612635565b016020015161222c919060f81c612583565b61223783600a612aa6565b6122419190612abd565b91508061224d81612a71565b9150506121cc565b509392505050565b606061226c8484600085612276565b90505b9392505050565b6060824710156122d75760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016105d4565b600080866001600160a01b031685876040516122f39190612a8a565b60006040518083038185875af1925050503d8060008114612330576040519150601f19603f3d011682016040523d82523d6000602084013e612335565b606091505b509150915061234687838387612353565b925050505b949350505050565b606083156123c25782516000036123bb576001600160a01b0385163b6123bb5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016105d4565b508161234b565b61234b83838151156123d75781518083602001fd5b8060405162461bcd60e51b81526004016105d49190612ad0565b60405180604001604052806002906020820280368337509192915050565b60405180606001604052806003906020820280368337509192915050565b60405180608001604052806004906020820280368337509192915050565b6040518060a001604052806005906020820280368337509192915050565b6040518060c001604052806006906020820280368337509192915050565b6040518060e001604052806007906020820280368337509192915050565b6040518061010001604052806008906020820280368337509192915050565b6001600160a01b03811681146107ad57600080fd5b6000602082840312156124eb57600080fd5b813561226f816124c4565b60008060006060848603121561250b57600080fd5b8335612516816124c4565b92506020840135612526816124c4565b929592945050506040919091013590565b60006020828403121561254957600080fd5b5051919050565b60006020828403121561256257600080fd5b815161226f816124c4565b634e487b7160e01b600052601160045260246000fd5b81810381811115610d3b57610d3b61256d565b6000602082840312156125a857600080fd5b8151801515811461226f57600080fd5b60208082526024908201527f437572766548616e646c65723a20696e7465726d656469617465206e6f7420666040820152631bdd5b9960e21b606082015260800190565b60006020828403121561260e57600080fd5b815180600f0b811461226f57600080fd5b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b604080825283519082018190526000906020906060840190828701845b8281101561268457815184529284019290840190600101612668565b50505092019290925292915050565b8060005b60028110156119c1578151845260209384019390910190600101612697565b606081016126c48285612693565b8260408301529392505050565b8060005b60038110156119c15781518452602093840193909101906001016126d5565b6080810161270282856126d1565b8260608301529392505050565b8060005b60048110156119c1578151845260209384019390910190600101612713565b60a08101612740828561270f565b8260808301529392505050565b8060005b60058110156119c1578151845260209384019390910190600101612751565b60c0810161277e828561274d565b8260a08301529392505050565b8060005b60068110156119c157815184526020938401939091019060010161278f565b60e081016127bc828561278b565b8260c08301529392505050565b8060005b60078110156119c15781518452602093840193909101906001016127cd565b61010081016127fb82856127c9565b8260e08301529392505050565b8060005b60088110156119c157815184526020938401939091019060010161280c565b610120810161283a8285612808565b826101008301529392505050565b604051601f8201601f1916810167ffffffffffffffff811182821017156128715761287161261f565b604052919050565b60005b8381101561289457818101518382015260200161287c565b50506000910152565b6000602082840312156128af57600080fd5b815167ffffffffffffffff808211156128c757600080fd5b818401915084601f8301126128db57600080fd5b8151818111156128ed576128ed61261f565b612900601f8201601f1916602001612848565b915080825285602082850101111561291757600080fd5b612928816020840160208601612879565b50949350505050565b8281526060810161226f6020830184612693565b8281526080810161226f60208301846126d1565b82815260a0810161226f602083018461270f565b82815260c0810161226f602083018461274d565b82815260e0810161226f602083018461278b565b828152610100810161226f60208301846127c9565b828152610120810161226f6020830184612808565b600060208083850312156129d257600080fd5b825167ffffffffffffffff808211156129ea57600080fd5b818501915085601f8301126129fe57600080fd5b815181811115612a1057612a1061261f565b8060051b9150612a21848301612848565b8181529183018401918481019088841115612a3b57600080fd5b938501935b83851015612a655784519250612a55836124c4565b8282529385019390850190612a40565b98975050505050505050565b600060018201612a8357612a8361256d565b5060010190565b60008251612a9c818460208701612879565b9190910192915050565b8082028115828204841417610d3b57610d3b61256d565b80820180821115610d3b57610d3b61256d565b6020815260008251806020840152612aef816040850160208701612879565b601f01601f1916919091016040019291505056fea26469706673582212206b75539d99a87634d22f70623f1087da272c7b9e758acda55e6bd71e8279089164736f6c63430008110033

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

0000000000000000000000002790ec478f150a98f5d96755601a26403df57eae

-----Decoded View---------------
Arg [0] : controller_ (address): 0x2790EC478f150a98F5D96755601a26403DF57EaE

-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 0000000000000000000000002790ec478f150a98f5d96755601a26403df57eae


Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

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

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