ETH Price: $2,421.03 (+3.32%)

Contract

0xE450074D5F3D7590389A33499fd65B5B6A2FFc5A

Overview

ETH Balance

0 ETH

ETH Value

$0.00

Sponsored

Transaction Hash
Method
Block
From
To
0x608060402286279042024-07-04 9:29:5971 days ago1720085399IN
 Create: MultiCollateralOnOffRamp
0 ETH0.000549640.148901

Parent Transaction Hash Block From To
View All Internal Transactions

Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
MultiCollateralOnOffRamp

Compiler Version
v0.8.4+commit.c7e474f2

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 27 : MultiCollateralOnOffRamp.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

// external
import "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/utils/math/SafeMathUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol";

// internal
import "../utils/proxy/solidity-0.8.0/ProxyReentrancyGuard.sol";
import "../utils/proxy/solidity-0.8.0/ProxyOwned.sol";
import "../utils/proxy/solidity-0.8.0/ProxyPausable.sol";

import "@uniswap/v3-periphery/contracts/interfaces/ISwapRouter.sol";
import "@uniswap/v3-periphery/contracts/interfaces/IQuoter.sol";
import "@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol";
import "@uniswap/v3-core/contracts/interfaces/IUniswapV3Factory.sol";
import "../utils/libraries/UniswapMath.sol";

// interfaces
import "../interfaces/ICurveSUSD.sol";
import "../interfaces/IPriceFeed.sol";
import "../interfaces/IPositionalMarketManagerTruncated.sol";

interface WethLike {
    function deposit() external payable;

    function withdraw(uint) external;
}

interface IERC20Decimals {
    function decimals() external view returns (uint);
}

/// @title MultiCollateralOnOffRamp to use different collateral than default
contract MultiCollateralOnOffRamp is Initializable, ProxyOwned, ProxyPausable, ProxyReentrancyGuard {
    using SafeERC20Upgradeable for IERC20Upgradeable;

    uint private constant ONE = 1e18;
    uint private constant COLLATERAL_TRANSFORMER_MULTIPLIER = 1e12;

    IERC20Upgradeable public sUSD;

    mapping(address => bool) public collateralSupported;

    mapping(address => bool) public ammsSupported;

    ISwapRouter public swapRouter;

    IPriceFeed public priceFeed;

    // should be lower case but left due to proxy compatibility
    address public WETH9;
    address public usdc;
    address public usdt;
    address public dai;

    bool public curveOnrampEnabled;

    uint public maxAllowedPegSlippagePercentage;

    ICurveSUSD public curveSUSD;

    mapping(address => bytes) public pathPerCollateral;

    mapping(address => bytes32) public priceFeedKeyPerCollateral;

    // deprecated, left due to proxy compatibility
    IPositionalMarketManagerTruncated public manager;

    mapping(address => bytes) public pathPerCollateralOfframp;

    mapping(address => uint) public maxAllowedPegSlippagePercentagePerCollateral;

    receive() external payable {}

    function initialize(address _owner, IERC20Upgradeable _sUSD) external initializer {
        setOwner(_owner);
        initNonReentrant();
        sUSD = _sUSD;
    }

    /// @notice use the collateral and collateralAmount to buy sUSD
    /// @return convertedAmount The amount of sUSD received.
    function onramp(address collateral, uint collateralAmount)
        external
        nonReentrant
        notPaused
        returns (uint convertedAmount)
    {
        require(collateralSupported[collateral], "Unsupported collateral");
        require(ammsSupported[msg.sender], "Unsupported caller");

        IERC20Upgradeable(collateral).safeTransferFrom(msg.sender, address(this), collateralAmount);

        //TODO: on Release set a path for WETH
        if (curveOnrampEnabled && (collateral == usdc || collateral == dai || collateral == usdt)) {
            // for stable coins use Curve
            convertedAmount = _swapViaCurve(collateral, collateralAmount);
        } else {
            // use a path over WETH pools for other ammsSupported collaterals (OP, ARB)
            convertedAmount = _swapExactInput(collateralAmount, collateral);
        }
        sUSD.safeTransfer(msg.sender, convertedAmount);

        emit Onramped(collateral, collateralAmount);
    }

    /// @notice use native eth as a collateral to buy sUSD
    /// @return convertedAmount The amount of sUSD received.
    function onrampWithEth(uint amount) external payable nonReentrant notPaused returns (uint convertedAmount) {
        require(collateralSupported[address(WETH9)], "Unsupported collateral");
        require(ammsSupported[msg.sender], "Unsupported caller");
        require(amount > 0, "Can not exchange 0 ETH");
        require(msg.value == amount, "Amount ETH has to be equal to the specified amount");

        uint balanceBefore = IERC20Upgradeable(WETH9).balanceOf(address(this));
        WethLike(WETH9).deposit{value: amount}();

        uint balanceDiff = IERC20Upgradeable(WETH9).balanceOf(address(this)) - balanceBefore;
        require(balanceDiff == amount, "Not enough WETH received");

        convertedAmount = _swapExactInput(amount, WETH9);

        sUSD.safeTransfer(msg.sender, convertedAmount);

        emit OnrampedEth(amount);
    }

    /// @notice offramp the amount of sUSD into the target collateral
    /// @return convertedAmount The amount of sUSD to offramp.
    function offramp(address collateral, uint amount) external nonReentrant notPaused returns (uint convertedAmount) {
        require(collateralSupported[collateral], "Unsupported collateral");
        require(ammsSupported[msg.sender], "Unsupported caller");
        sUSD.safeTransferFrom(msg.sender, address(this), amount);

        if (curveOnrampEnabled && (collateral == usdc || collateral == dai || collateral == usdt)) {
            // for stable coins use Curve
            convertedAmount = _swapViaCurveOfframp(collateral, amount);
        } else {
            // for other use defined path
            convertedAmount = _swapExactInputOfframp(amount, collateral);
        }
        IERC20Upgradeable(collateral).safeTransfer(msg.sender, convertedAmount);

        emit Offramped(collateral, amount);
    }

    function offrampIntoEth(uint amount) external nonReentrant notPaused returns (uint convertedAmount) {
        require(ammsSupported[msg.sender], "Unsupported caller");

        sUSD.safeTransferFrom(msg.sender, address(this), amount);

        convertedAmount = _swapExactInputOfframp(amount, WETH9);

        WethLike(WETH9).withdraw(convertedAmount);

        bool sent = payable(msg.sender).send(convertedAmount);
        require(sent, "Failed to send Ether");

        emit OfframpedEth(amount);
    }

    ///////////////////////Curve related code///////////////////
    function _swapViaCurve(address collateral, uint collateralQuote) internal returns (uint amountOut) {
        int128 curveIndex = _mapCollateralToCurveIndex(collateral);
        require(curveIndex > 0 && curveOnrampEnabled, "unsupported collateral");

        amountOut = curveSUSD.exchange_underlying(
            curveIndex,
            0,
            collateralQuote,
            getMinimumReceived(collateral, collateralQuote) // the minimum received is predefined
        );

        // ensure the amount received is within allowed range per maxAllowedPegSlippagePercentage
        require(amountOut <= getMaximumReceived(collateral, collateralQuote), "Amount above max allowed peg slippage");
    }

    function _swapViaCurveOfframp(address collateral, uint amount) internal returns (uint amountOut) {
        int128 curveIndex = _mapCollateralToCurveIndex(collateral);
        require(curveIndex > 0 && curveOnrampEnabled, "unsupported collateral");

        sUSD.approve(address(curveSUSD), amount);

        amountOut = curveSUSD.exchange_underlying(
            0,
            curveIndex,
            amount,
            getMinimumReceivedOfframp(collateral, amount) // the minimum received is predefined
        );

        // ensure the amount received is within allowed range per maxAllowedPegSlippagePercentage
        require(amountOut <= getMaximumReceivedOfframp(collateral, amount), "Amount above max allowed peg slippage");
    }

    ///////////////////////UNISWAP related code///////////////////

    /// @notice _swapExactInput swaps a fixed amount of tokenIn for a maximum possible amount of tokenOut
    /// @param amountIn The exact amount of tokenIn that will be swapped for tokenOut.
    /// @param tokenIn Address of first token
    /// @return amountOut The amount of tokenOut received.
    function _swapExactInput(uint amountIn, address tokenIn) internal returns (uint amountOut) {
        IERC20Upgradeable(tokenIn).approve(address(swapRouter), amountIn);

        bytes memory pathToUse = pathPerCollateral[tokenIn];
        if (pathToUse.length == 0) {
            uint24 fee = 3000;
            pathToUse = abi.encodePacked(address(tokenIn), fee, WETH9, fee, address(sUSD));
        }

        // Multiple pool swaps are encoded through bytes called a `path`. A path is a sequence of token addresses and poolFees that define the pools used in the swaps.
        ISwapRouter.ExactInputParams memory params = ISwapRouter.ExactInputParams({
            path: pathToUse,
            recipient: address(this),
            deadline: block.timestamp + 15,
            amountIn: amountIn,
            amountOutMinimum: getMinimumReceived(tokenIn, amountIn)
        });

        // The call to `exactInput` executes the swap.
        amountOut = swapRouter.exactInput(params);

        // ensure the amount received is withing allowed range per maxAllowedPegSlippagePercentage
        require(amountOut <= getMaximumReceived(tokenIn, amountIn), "Amount above max allowed peg slippage");
    }

    function _swapExactInputOfframp(uint amountIn, address tokenOut) internal returns (uint amountOut) {
        sUSD.approve(address(swapRouter), amountIn);

        bytes memory pathToUse = pathPerCollateralOfframp[tokenOut];
        if (pathToUse.length == 0) {
            uint24 fee = 3000;
            pathToUse = abi.encodePacked(address(sUSD), fee, WETH9, fee, address(tokenOut));
        }

        // Multiple pool swaps are encoded through bytes called a `path`. A path is a sequence of token addresses and poolFees that define the pools used in the swaps.
        ISwapRouter.ExactInputParams memory params = ISwapRouter.ExactInputParams({
            path: pathToUse,
            recipient: address(this),
            deadline: block.timestamp + 15,
            amountIn: amountIn,
            amountOutMinimum: getMinimumReceivedOfframp(tokenOut, amountIn)
        });

        // The call to `exactInput` executes the swap.
        amountOut = swapRouter.exactInput(params);

        // ensure the amount received is withing allowed range per maxAllowedPegSlippagePercentage
        require(amountOut <= getMaximumReceivedOfframp(tokenOut, amountIn), "Amount above max allowed peg slippage");
    }

    function _mapCollateralToCurveIndex(address collateral) internal view returns (int128) {
        if (collateral == dai) {
            return 1;
        }
        if (collateral == usdc) {
            return 2;
        }
        if (collateral == usdt) {
            return 3;
        }
        return 0;
    }

    function _reverseTransformCollateral(uint value) internal view returns (uint) {
        if (IERC20Decimals(address(sUSD)).decimals() == 6) {
            return value * 1e12;
        } else {
            return value;
        }
    }

    function _transformCollateral(uint value) internal view returns (uint) {
        if (IERC20Decimals(address(sUSD)).decimals() == 6) {
            return value / 1e12;
        } else {
            return value;
        }
    }

    /////////// read methods

    /// @notice return the guaranteed payout for the given collateral and amount
    function getMinimumReceived(address collateral, uint amount) public view returns (uint minReceived) {
        if (_mapCollateralToCurveIndex(collateral) > 0) {
            uint transformedCollateralForPegCheck = collateral == usdc || collateral == usdt
                ? amount * (COLLATERAL_TRANSFORMER_MULTIPLIER)
                : amount;
            minReceived =
                (transformedCollateralForPegCheck * (ONE - _getMaxAllowedPegSlippagePercentageForCollateral(collateral))) /
                ONE;
        } else {
            uint currentCollateralPrice = priceFeed.rateForCurrency(priceFeedKeyPerCollateral[collateral]);
            require(currentCollateralPrice > 0, "no price available from price feed");
            minReceived =
                (((amount * currentCollateralPrice) / ONE) *
                    (ONE - _getMaxAllowedPegSlippagePercentageForCollateral(collateral))) /
                ONE;
        }
        minReceived = _transformCollateral(minReceived);
    }

    // @notice return the minimum needed of collateral to receive amount of sUSD
    function getMinimumNeeded(address collateral, uint amount) public view returns (uint minNeeded) {
        amount = _reverseTransformCollateral(amount);
        if (_mapCollateralToCurveIndex(collateral) > 0) {
            minNeeded = (amount * (ONE + _getMaxAllowedPegSlippagePercentageForCollateral(collateral))) / ONE;
            if (collateral == usdc || collateral == usdt) {
                minNeeded = minNeeded / COLLATERAL_TRANSFORMER_MULTIPLIER;
            }
        } else {
            uint currentCollateralPrice = priceFeed.rateForCurrency(priceFeedKeyPerCollateral[collateral]);
            require(currentCollateralPrice > 0, "no price available from price feed");
            minNeeded =
                (((amount * ONE) / currentCollateralPrice) *
                    (ONE + _getMaxAllowedPegSlippagePercentageForCollateral(collateral))) /
                ONE;
        }
    }

    /// @notice return the guaranteed largest payout for the given collateral and amount
    function getMaximumReceived(address collateral, uint amount) public view returns (uint maxReceived) {
        if (_mapCollateralToCurveIndex(collateral) > 0) {
            uint transformedCollateralForPegCheck = collateral == usdc || collateral == usdt
                ? amount * (COLLATERAL_TRANSFORMER_MULTIPLIER)
                : amount;
            maxReceived =
                (transformedCollateralForPegCheck * (ONE + _getMaxAllowedPegSlippagePercentageForCollateral(collateral))) /
                ONE;
        } else {
            uint currentCollateralPrice = priceFeed.rateForCurrency(priceFeedKeyPerCollateral[collateral]);
            require(currentCollateralPrice > 0, "no price available from price feed");
            maxReceived =
                (((amount * currentCollateralPrice) / ONE) *
                    (ONE + _getMaxAllowedPegSlippagePercentageForCollateral(collateral))) /
                ONE;
        }
        maxReceived = _transformCollateral(maxReceived);
    }

    /// @notice return the minimum received amount in collateral for sUSD amount
    function getMinimumReceivedOfframp(address collateral, uint amount) public view returns (uint minReceivedOfframp) {
        amount = _reverseTransformCollateral(amount);
        if (_mapCollateralToCurveIndex(collateral) > 0) {
            minReceivedOfframp = (amount * (ONE - _getMaxAllowedPegSlippagePercentageForCollateral(collateral))) / ONE;
            if (collateral == usdc || collateral == usdt) {
                minReceivedOfframp = minReceivedOfframp / COLLATERAL_TRANSFORMER_MULTIPLIER;
            }
        } else {
            uint currentCollateralPrice = priceFeed.rateForCurrency(priceFeedKeyPerCollateral[collateral]);
            require(currentCollateralPrice > 0, "no price available from price feed");
            minReceivedOfframp =
                (((amount * ONE) / currentCollateralPrice) *
                    (ONE - _getMaxAllowedPegSlippagePercentageForCollateral(collateral))) /
                ONE;
        }
    }

    /// @notice return the maximum received amount in collateral for sUSD amount
    function getMaximumReceivedOfframp(address collateral, uint amount) public view returns (uint maxReceivedOfframp) {
        maxReceivedOfframp = getMinimumNeeded(collateral, amount);
    }

    /// @notice utility method to pack best path
    function getEncodedPacked(
        address inToken,
        uint24 feeIn,
        address proxy,
        uint24 feeOut,
        address target
    ) external view returns (bytes memory encoded) {
        if (proxy != address(0)) {
            encoded = abi.encodePacked(inToken, feeIn, proxy, feeOut, target);
        } else {
            encoded = abi.encodePacked(inToken, feeOut, target);
        }
    }

    function _getMaxAllowedPegSlippagePercentageForCollateral(address collateral) internal view returns (uint) {
        return
            (maxAllowedPegSlippagePercentagePerCollateral[collateral] > 0 &&
                maxAllowedPegSlippagePercentagePerCollateral[collateral] < maxAllowedPegSlippagePercentage)
                ? maxAllowedPegSlippagePercentagePerCollateral[collateral]
                : maxAllowedPegSlippagePercentage;
    }

    //////////////// setters

    /// @notice setSupportedCollateral which can be used for onramp
    function setSupportedCollateral(address collateral, bool supported) external onlyOwner {
        require(collateral != address(0), "Can not set a zero address!");
        collateralSupported[collateral] = supported;
        emit SetSupportedCollateral(collateral, supported);
    }

    /// @notice setSupportedAMM which can call the onramp method
    function setSupportedAMM(address amm, bool supported) external onlyOwner {
        require(amm != address(0), "Can not set a zero address!");
        ammsSupported[amm] = supported;
        emit SetSupportedAMM(amm, supported);
    }

    /// @notice setWETH
    function setWETH(address _weth) external onlyOwner {
        require(_weth != address(0), "Can not set a zero address!");
        WETH9 = _weth;
        emit SetWETH(_weth);
    }

    /// @notice setUSD
    function setSUSD(address _usd) external onlyOwner {
        require(_usd != address(0), "Can not set a zero address!");
        sUSD = IERC20Upgradeable(_usd);
        emit SetSUSD(_usd);
    }

    /// @notice setSwapRouter
    function setSwapRouter(address _router) external onlyOwner {
        require(_router != address(0), "Can not set a zero address!");
        swapRouter = ISwapRouter(_router);
        emit SetSwapRouter(_router);
    }

    /// @notice setPriceFeed
    function setPriceFeed(address _priceFeed) external onlyOwner {
        require(_priceFeed != address(0), "Can not set a zero address!");
        priceFeed = IPriceFeed(_priceFeed);
        emit SetPriceFeed(_priceFeed);
    }

    /// @notice map a key to an asset for price feed
    function setPriceFeedKeyPerAsset(bytes32 key, address asset) external onlyOwner {
        require(asset != address(0), "Can not set a zero address!");
        priceFeedKeyPerCollateral[asset] = key;
        emit SetPriceFeedKeyPerAsset(key, asset);
    }

    /// @notice map a path for a given collateral
    function setPathPerCollateral(
        address asset,
        bytes calldata path,
        bool doReset
    ) external onlyOwner {
        require(asset != address(0), "Can not set a zero address!");
        if (doReset) {
            bytes memory resetVar;
            pathPerCollateral[asset] = resetVar;
        } else {
            pathPerCollateral[asset] = path;
        }
        emit SetPathPerCollateral(asset, path, doReset);
    }

    /// @notice map a path for a given collateral offramp
    function setPathPerCollateralOfframp(
        address asset,
        bytes calldata path,
        bool doReset
    ) external onlyOwner {
        require(asset != address(0), "Can not set a zero address!");
        if (doReset) {
            bytes memory resetVar;
            pathPerCollateralOfframp[asset] = resetVar;
        } else {
            pathPerCollateralOfframp[asset] = path;
        }
        emit SetPathPerCollateralOfframp(asset, path, doReset);
    }

    /// @notice set max slippage for a given collateral
    function setMaxAllowedPegSlippagePercentagePerCollateral(address collateral, uint _maxAllowedSlippagePerCollateral)
        external
        onlyOwner
    {
        require(collateral != address(0), "Can not set a zero address!");
        require(_maxAllowedSlippagePerCollateral <= maxAllowedPegSlippagePercentage, "Can not set higher than default");
        maxAllowedPegSlippagePercentagePerCollateral[collateral] = _maxAllowedSlippagePerCollateral;
        emit SetMaxAllowedPegSlippagePercentagePerCollateral(collateral, _maxAllowedSlippagePerCollateral);
    }

    /// @notice set max default slippage
    function setMaxAllowedPegSlippagePercentage(uint _maxAllowedSlippage) external onlyOwner {
        require(_maxAllowedSlippage <= 2 * 1e16, "Can not set higher than 2%");
        maxAllowedPegSlippagePercentage = _maxAllowedSlippage;
        emit SetMaxAllowedPegSlippagePercentage(_maxAllowedSlippage);
    }

    /// @notice Updates contract parametars
    /// @param _curveSUSD curve sUSD pool exchanger contract
    /// @param _dai DAI address
    /// @param _usdc USDC address
    /// @param _usdt USDT addresss
    /// @param _curveOnrampEnabled whether AMM supports curve onramp
    /// @param _maxAllowedPegSlippagePercentage maximum discount AMM accepts for sUSD purchases
    function setCurveSUSD(
        address _curveSUSD,
        address _dai,
        address _usdc,
        address _usdt,
        bool _curveOnrampEnabled,
        uint _maxAllowedPegSlippagePercentage
    ) external onlyOwner {
        require(!_curveOnrampEnabled || _curveSUSD != address(0), "Can not set a zero address!");
        if (address(curveSUSD) != address(0)) {
            // clear previous approvals
            if (dai != address(0)) {
                IERC20Upgradeable(dai).approve(address(curveSUSD), 0);
            }
            if (usdc != address(0)) {
                IERC20Upgradeable(usdc).approve(address(curveSUSD), 0);
            }
            if (usdt != address(0)) {
                IERC20Upgradeable(usdt).approve(address(curveSUSD), 0);
            }
        }
        curveSUSD = ICurveSUSD(_curveSUSD);
        dai = _dai;
        usdc = _usdc;
        usdt = _usdt;
        IERC20Upgradeable(dai).approve(_curveSUSD, type(uint).max);
        IERC20Upgradeable(usdc).approve(_curveSUSD, type(uint).max);
        IERC20Upgradeable(usdt).approve(_curveSUSD, type(uint).max);
        curveOnrampEnabled = _curveOnrampEnabled;
        maxAllowedPegSlippagePercentage = _maxAllowedPegSlippagePercentage;
        emit CurveSUSDSet(_curveSUSD, _dai, _usdc, _usdt, _curveOnrampEnabled, _maxAllowedPegSlippagePercentage);
    }

    ////////////////events
    event CurveSUSDSet(
        address _curveSUSD,
        address _dai,
        address _usdc,
        address _usdt,
        bool _curveOnrampEnabled,
        uint _maxAllowedPegSlippagePercentage
    );
    event SetPriceFeedKeyPerAsset(bytes32 key, address asset);
    event SetPriceFeed(address _priceFeed);
    event SetSwapRouter(address _router);
    event SetSUSD(address _usd);
    event SetWETH(address _weth);
    event SetSupportedAMM(address amm, bool supported);
    event SetSupportedCollateral(address collateral, bool supported);
    event Onramped(address collateral, uint amount);
    event OnrampedEth(uint amount);
    event Offramped(address collateral, uint amount);
    event OfframpedEth(uint amount);
    event SetPathPerCollateral(address asset, bytes path, bool doReset);
    event SetPathPerCollateralOfframp(address asset, bytes path, bool doReset);
    event SetMaxAllowedPegSlippagePercentagePerCollateral(address collateral, uint _maxAllowedSlippagePerCollateral);
    event SetMaxAllowedPegSlippagePercentage(uint _maxAllowedSlippage);
}

File 2 of 27 : SafeERC20Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;

import "../IERC20Upgradeable.sol";
import "../../../utils/AddressUpgradeable.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 SafeERC20Upgradeable {
    using AddressUpgradeable for address;

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

    function safeTransferFrom(
        IERC20Upgradeable 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(
        IERC20Upgradeable token,
        address spender,
        uint256 value
    ) internal {
        // safeApprove should only be called when setting an initial allowance,
        // or when resetting it to zero. To increase and decrease it, use
        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
        require(
            (value == 0) || (token.allowance(address(this), spender) == 0),
            "SafeERC20: approve from non-zero to non-zero allowance"
        );
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
    }

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

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

    /**
     * @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(IERC20Upgradeable token, bytes memory data) private {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
        // the target address contains contract code and also asserts for success in the low-level call.

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

File 3 of 27 : OwnableUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)

pragma solidity ^0.8.0;

import "../utils/ContextUpgradeable.sol";
import "../proxy/utils/Initializable.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 OwnableUpgradeable is Initializable, ContextUpgradeable {
    address private _owner;

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

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    function __Ownable_init() internal onlyInitializing {
        __Context_init_unchained();
        __Ownable_init_unchained();
    }

    function __Ownable_init_unchained() internal onlyInitializing {
        _transferOwnership(_msgSender());
    }

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

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

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        _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);
    }
    uint256[49] private __gap;
}

File 4 of 27 : Initializable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (proxy/utils/Initializable.sol)

pragma solidity ^0.8.0;

import "../../utils/AddressUpgradeable.sol";

/**
 * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
 * behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an
 * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
 * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
 *
 * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
 * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
 *
 * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
 * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
 *
 * [CAUTION]
 * ====
 * Avoid leaving a contract uninitialized.
 *
 * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
 * contract, which may impact the proxy. To initialize the implementation contract, you can either invoke the
 * initializer manually, or you can include a constructor to automatically mark it as initialized when it is deployed:
 *
 * [.hljs-theme-light.nopadding]
 * ```
 * /// @custom:oz-upgrades-unsafe-allow constructor
 * constructor() initializer {}
 * ```
 * ====
 */
abstract contract Initializable {
    /**
     * @dev Indicates that the contract has been initialized.
     */
    bool private _initialized;

    /**
     * @dev Indicates that the contract is in the process of being initialized.
     */
    bool private _initializing;

    /**
     * @dev Modifier to protect an initializer function from being invoked twice.
     */
    modifier initializer() {
        // If the contract is initializing we ignore whether _initialized is set in order to support multiple
        // inheritance patterns, but we only do this in the context of a constructor, because in other contexts the
        // contract may have been reentered.
        require(_initializing ? _isConstructor() : !_initialized, "Initializable: contract is already initialized");

        bool isTopLevelCall = !_initializing;
        if (isTopLevelCall) {
            _initializing = true;
            _initialized = true;
        }

        _;

        if (isTopLevelCall) {
            _initializing = false;
        }
    }

    /**
     * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
     * {initializer} modifier, directly or indirectly.
     */
    modifier onlyInitializing() {
        require(_initializing, "Initializable: contract is not initializing");
        _;
    }

    function _isConstructor() private view returns (bool) {
        return !AddressUpgradeable.isContract(address(this));
    }
}

File 5 of 27 : SafeMathUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/math/SafeMath.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

File 6 of 27 : IERC20Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

File 7 of 27 : PausableUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (security/Pausable.sol)

pragma solidity ^0.8.0;

import "../utils/ContextUpgradeable.sol";
import "../proxy/utils/Initializable.sol";

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

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

    bool private _paused;

    /**
     * @dev Initializes the contract in unpaused state.
     */
    function __Pausable_init() internal onlyInitializing {
        __Context_init_unchained();
        __Pausable_init_unchained();
    }

    function __Pausable_init_unchained() internal onlyInitializing {
        _paused = false;
    }

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

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

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

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

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

File 8 of 27 : ProxyReentrancyGuard.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev Contract module that helps prevent reentrant calls to a function.
 *
 * Inheriting from `ReentrancyGuard` will make the `nonReentrant` modifier
 * available, which can be aplied to functions to make sure there are no nested
 * (reentrant) calls to them.
 *
 * Note that because there is a single `nonReentrant` guard, functions marked as
 * `nonReentrant` may not call one another. This can be worked around by making
 * those functions `private`, and then adding `external` `nonReentrant` entry
 * points to them.
 */
contract ProxyReentrancyGuard {
    /// @dev counter to allow mutex lock with only one SSTORE operation
    uint256 private _guardCounter;
    bool private _initialized;

    function initNonReentrant() public {
        require(!_initialized, "Already initialized");
        _initialized = true;
        _guardCounter = 1;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and make it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        _guardCounter += 1;
        uint256 localCounter = _guardCounter;
        _;
        require(localCounter == _guardCounter, "ReentrancyGuard: reentrant call");
    }
}

File 9 of 27 : ProxyOwned.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

// Clone of syntetix contract without constructor
contract ProxyOwned {
    address public owner;
    address public nominatedOwner;
    bool private _initialized;
    bool private _transferredAtInit;

    function setOwner(address _owner) public {
        require(_owner != address(0), "Owner address cannot be 0");
        require(!_initialized, "Already initialized, use nominateNewOwner");
        _initialized = true;
        owner = _owner;
        emit OwnerChanged(address(0), _owner);
    }

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

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

    function transferOwnershipAtInit(address proxyAddress) external onlyOwner {
        require(proxyAddress != address(0), "Invalid address");
        require(!_transferredAtInit, "Already transferred");
        owner = proxyAddress;
        _transferredAtInit = true;
        emit OwnerChanged(owner, proxyAddress);
    }

    modifier onlyOwner {
        _onlyOwner();
        _;
    }

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

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

File 10 of 27 : ProxyPausable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

// Inheritance
import "./ProxyOwned.sol";

// Clone of syntetix contract without constructor

contract ProxyPausable is ProxyOwned {
    uint public lastPauseTime;
    bool public paused;

    

    /**
     * @notice Change the paused state of the contract
     * @dev Only the contract owner may call this.
     */
    function setPaused(bool _paused) external onlyOwner {
        // Ensure we're actually changing the state before we do anything
        if (_paused == paused) {
            return;
        }

        // Set our paused state.
        paused = _paused;

        // If applicable, set the last pause time.
        if (paused) {
            lastPauseTime = block.timestamp;
        }

        // Let everyone know that our pause state has changed.
        emit PauseChanged(paused);
    }

    event PauseChanged(bool isPaused);

    modifier notPaused {
        require(!paused, "This action cannot be performed while the contract is paused");
        _;
    }
}

File 11 of 27 : ISwapRouter.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.7.5;
pragma abicoder v2;

import '@uniswap/v3-core/contracts/interfaces/callback/IUniswapV3SwapCallback.sol';

/// @title Router token swapping functionality
/// @notice Functions for swapping tokens via Uniswap V3
interface ISwapRouter is IUniswapV3SwapCallback {
    struct ExactInputSingleParams {
        address tokenIn;
        address tokenOut;
        uint24 fee;
        address recipient;
        uint256 deadline;
        uint256 amountIn;
        uint256 amountOutMinimum;
        uint160 sqrtPriceLimitX96;
    }

    /// @notice Swaps `amountIn` of one token for as much as possible of another token
    /// @param params The parameters necessary for the swap, encoded as `ExactInputSingleParams` in calldata
    /// @return amountOut The amount of the received token
    function exactInputSingle(ExactInputSingleParams calldata params) external payable returns (uint256 amountOut);

    struct ExactInputParams {
        bytes path;
        address recipient;
        uint256 deadline;
        uint256 amountIn;
        uint256 amountOutMinimum;
    }

    /// @notice Swaps `amountIn` of one token for as much as possible of another along the specified path
    /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactInputParams` in calldata
    /// @return amountOut The amount of the received token
    function exactInput(ExactInputParams calldata params) external payable returns (uint256 amountOut);

    struct ExactOutputSingleParams {
        address tokenIn;
        address tokenOut;
        uint24 fee;
        address recipient;
        uint256 deadline;
        uint256 amountOut;
        uint256 amountInMaximum;
        uint160 sqrtPriceLimitX96;
    }

    /// @notice Swaps as little as possible of one token for `amountOut` of another token
    /// @param params The parameters necessary for the swap, encoded as `ExactOutputSingleParams` in calldata
    /// @return amountIn The amount of the input token
    function exactOutputSingle(ExactOutputSingleParams calldata params) external payable returns (uint256 amountIn);

    struct ExactOutputParams {
        bytes path;
        address recipient;
        uint256 deadline;
        uint256 amountOut;
        uint256 amountInMaximum;
    }

    /// @notice Swaps as little as possible of one token for `amountOut` of another along the specified path (reversed)
    /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactOutputParams` in calldata
    /// @return amountIn The amount of the input token
    function exactOutput(ExactOutputParams calldata params) external payable returns (uint256 amountIn);
}

File 12 of 27 : IQuoter.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.7.5;
pragma abicoder v2;

/// @title Quoter Interface
/// @notice Supports quoting the calculated amounts from exact input or exact output swaps
/// @dev These functions are not marked view because they rely on calling non-view functions and reverting
/// to compute the result. They are also not gas efficient and should not be called on-chain.
interface IQuoter {
    /// @notice Returns the amount out received for a given exact input swap without executing the swap
    /// @param path The path of the swap, i.e. each token pair and the pool fee
    /// @param amountIn The amount of the first token to swap
    /// @return amountOut The amount of the last token that would be received
    function quoteExactInput(bytes memory path, uint256 amountIn) external returns (uint256 amountOut);

    /// @notice Returns the amount out received for a given exact input but for a swap of a single pool
    /// @param tokenIn The token being swapped in
    /// @param tokenOut The token being swapped out
    /// @param fee The fee of the token pool to consider for the pair
    /// @param amountIn The desired input amount
    /// @param sqrtPriceLimitX96 The price limit of the pool that cannot be exceeded by the swap
    /// @return amountOut The amount of `tokenOut` that would be received
    function quoteExactInputSingle(
        address tokenIn,
        address tokenOut,
        uint24 fee,
        uint256 amountIn,
        uint160 sqrtPriceLimitX96
    ) external returns (uint256 amountOut);

    /// @notice Returns the amount in required for a given exact output swap without executing the swap
    /// @param path The path of the swap, i.e. each token pair and the pool fee. Path must be provided in reverse order
    /// @param amountOut The amount of the last token to receive
    /// @return amountIn The amount of first token required to be paid
    function quoteExactOutput(bytes memory path, uint256 amountOut) external returns (uint256 amountIn);

    /// @notice Returns the amount in required to receive the given exact output amount but for a swap of a single pool
    /// @param tokenIn The token being swapped in
    /// @param tokenOut The token being swapped out
    /// @param fee The fee of the token pool to consider for the pair
    /// @param amountOut The desired output amount
    /// @param sqrtPriceLimitX96 The price limit of the pool that cannot be exceeded by the swap
    /// @return amountIn The amount required as the input for the swap in order to receive `amountOut`
    function quoteExactOutputSingle(
        address tokenIn,
        address tokenOut,
        uint24 fee,
        uint256 amountOut,
        uint160 sqrtPriceLimitX96
    ) external returns (uint256 amountIn);
}

File 13 of 27 : IUniswapV3Pool.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

import './pool/IUniswapV3PoolImmutables.sol';
import './pool/IUniswapV3PoolState.sol';
import './pool/IUniswapV3PoolDerivedState.sol';
import './pool/IUniswapV3PoolActions.sol';
import './pool/IUniswapV3PoolOwnerActions.sol';
import './pool/IUniswapV3PoolEvents.sol';

/// @title The interface for a Uniswap V3 Pool
/// @notice A Uniswap pool facilitates swapping and automated market making between any two assets that strictly conform
/// to the ERC20 specification
/// @dev The pool interface is broken up into many smaller pieces
interface IUniswapV3Pool is
    IUniswapV3PoolImmutables,
    IUniswapV3PoolState,
    IUniswapV3PoolDerivedState,
    IUniswapV3PoolActions,
    IUniswapV3PoolOwnerActions,
    IUniswapV3PoolEvents
{

}

File 14 of 27 : IUniswapV3Factory.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

/// @title The interface for the Uniswap V3 Factory
/// @notice The Uniswap V3 Factory facilitates creation of Uniswap V3 pools and control over the protocol fees
interface IUniswapV3Factory {
    /// @notice Emitted when the owner of the factory is changed
    /// @param oldOwner The owner before the owner was changed
    /// @param newOwner The owner after the owner was changed
    event OwnerChanged(address indexed oldOwner, address indexed newOwner);

    /// @notice Emitted when a pool is created
    /// @param token0 The first token of the pool by address sort order
    /// @param token1 The second token of the pool by address sort order
    /// @param fee The fee collected upon every swap in the pool, denominated in hundredths of a bip
    /// @param tickSpacing The minimum number of ticks between initialized ticks
    /// @param pool The address of the created pool
    event PoolCreated(
        address indexed token0,
        address indexed token1,
        uint24 indexed fee,
        int24 tickSpacing,
        address pool
    );

    /// @notice Emitted when a new fee amount is enabled for pool creation via the factory
    /// @param fee The enabled fee, denominated in hundredths of a bip
    /// @param tickSpacing The minimum number of ticks between initialized ticks for pools created with the given fee
    event FeeAmountEnabled(uint24 indexed fee, int24 indexed tickSpacing);

    /// @notice Returns the current owner of the factory
    /// @dev Can be changed by the current owner via setOwner
    /// @return The address of the factory owner
    function owner() external view returns (address);

    /// @notice Returns the tick spacing for a given fee amount, if enabled, or 0 if not enabled
    /// @dev A fee amount can never be removed, so this value should be hard coded or cached in the calling context
    /// @param fee The enabled fee, denominated in hundredths of a bip. Returns 0 in case of unenabled fee
    /// @return The tick spacing
    function feeAmountTickSpacing(uint24 fee) external view returns (int24);

    /// @notice Returns the pool address for a given pair of tokens and a fee, or address 0 if it does not exist
    /// @dev tokenA and tokenB may be passed in either token0/token1 or token1/token0 order
    /// @param tokenA The contract address of either token0 or token1
    /// @param tokenB The contract address of the other token
    /// @param fee The fee collected upon every swap in the pool, denominated in hundredths of a bip
    /// @return pool The pool address
    function getPool(
        address tokenA,
        address tokenB,
        uint24 fee
    ) external view returns (address pool);

    /// @notice Creates a pool for the given two tokens and fee
    /// @param tokenA One of the two tokens in the desired pool
    /// @param tokenB The other of the two tokens in the desired pool
    /// @param fee The desired fee for the pool
    /// @dev tokenA and tokenB may be passed in either order: token0/token1 or token1/token0. tickSpacing is retrieved
    /// from the fee. The call will revert if the pool already exists, the fee is invalid, or the token arguments
    /// are invalid.
    /// @return pool The address of the newly created pool
    function createPool(
        address tokenA,
        address tokenB,
        uint24 fee
    ) external returns (address pool);

    /// @notice Updates the owner of the factory
    /// @dev Must be called by the current owner
    /// @param _owner The new owner of the factory
    function setOwner(address _owner) external;

    /// @notice Enables a fee amount with the given tickSpacing
    /// @dev Fee amounts may never be removed once enabled
    /// @param fee The fee amount to enable, denominated in hundredths of a bip (i.e. 1e-6)
    /// @param tickSpacing The spacing between ticks to be enforced for all pools created with the given fee amount
    function enableFeeAmount(uint24 fee, int24 tickSpacing) external;
}

File 15 of 27 : UniswapMath.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.7.0;

/// @title Math library for computing sqrt prices from ticks and vice versa; Contains 512-bit math functions
/// @notice Facilitates multiplication and division that can have overflow of an intermediate value without any loss of precision;
/// Computes sqrt price for ticks of size 1.0001, i.e. sqrt(1.0001^tick) as fixed point Q64.96 numbers. Supports
/// prices between 2**-128 and 2**128
/// @dev Handles "phantom overflow" i.e., allows multiplication and division where an intermediate value overflows 256 bits

library UniswapMath {
    uint256 internal constant Q192 = 0x1000000000000000000000000000000000000000000000000;
    uint256 internal constant Q96 = 0x1000000000000000000000000;

    /// @dev The minimum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**-128
    int24 internal constant MIN_TICK = -887272;
    /// @dev The maximum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**128
    int24 internal constant MAX_TICK = -MIN_TICK;

    /// @dev The minimum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MIN_TICK)
    uint160 internal constant MIN_SQRT_RATIO = 4295128739;
    /// @dev The maximum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MAX_TICK)
    uint160 internal constant MAX_SQRT_RATIO = 1461446703485210103287273052203988822378723970342;

    /// @notice Calculates floor(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
    /// @param a The multiplicand
    /// @param b The multiplier
    /// @param denominator The divisor
    /// @return result The 256-bit result
    /// @dev Credit to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv
    function mulDiv(
        uint256 a,
        uint256 b,
        uint256 denominator
    ) internal pure returns (uint256 result) {
        // 512-bit multiply [prod1 prod0] = a * b
        // Compute the product mod 2**256 and mod 2**256 - 1
        // then use the Chinese Remainder Theorem to reconstruct
        // the 512 bit result. The result is stored in two 256
        // variables such that product = prod1 * 2**256 + prod0
        uint256 prod0; // Least significant 256 bits of the product
        uint256 prod1; // Most significant 256 bits of the product
        assembly {
            let mm := mulmod(a, b, not(0))
            prod0 := mul(a, b)
            prod1 := sub(sub(mm, prod0), lt(mm, prod0))
        }

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

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

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

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

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

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

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

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

    /// @notice Calculates sqrt(1.0001^tick) * 2^96
    /// @dev Throws if |tick| > max tick
    /// @param tick The input tick for the above formula
    /// @return sqrtPriceX96 A Fixed point Q64.96 number representing the sqrt of the ratio of the two assets (token1/token0)
    /// at the given tick
    function getSqrtRatioAtTick(int24 tick) internal pure returns (uint160 sqrtPriceX96) {
        uint256 absTick = tick < 0 ? uint256(-int256(tick)) : uint256(int256(tick));
        require(absTick <= uint256(int256(MAX_TICK)), 'T');

        uint256 ratio = absTick & 0x1 != 0 ? 0xfffcb933bd6fad37aa2d162d1a594001 : 0x100000000000000000000000000000000;
        if (absTick & 0x2 != 0) ratio = (ratio * 0xfff97272373d413259a46990580e213a) >> 128;
        if (absTick & 0x4 != 0) ratio = (ratio * 0xfff2e50f5f656932ef12357cf3c7fdcc) >> 128;
        if (absTick & 0x8 != 0) ratio = (ratio * 0xffe5caca7e10e4e61c3624eaa0941cd0) >> 128;
        if (absTick & 0x10 != 0) ratio = (ratio * 0xffcb9843d60f6159c9db58835c926644) >> 128;
        if (absTick & 0x20 != 0) ratio = (ratio * 0xff973b41fa98c081472e6896dfb254c0) >> 128;
        if (absTick & 0x40 != 0) ratio = (ratio * 0xff2ea16466c96a3843ec78b326b52861) >> 128;
        if (absTick & 0x80 != 0) ratio = (ratio * 0xfe5dee046a99a2a811c461f1969c3053) >> 128;
        if (absTick & 0x100 != 0) ratio = (ratio * 0xfcbe86c7900a88aedcffc83b479aa3a4) >> 128;
        if (absTick & 0x200 != 0) ratio = (ratio * 0xf987a7253ac413176f2b074cf7815e54) >> 128;
        if (absTick & 0x400 != 0) ratio = (ratio * 0xf3392b0822b70005940c7a398e4b70f3) >> 128;
        if (absTick & 0x800 != 0) ratio = (ratio * 0xe7159475a2c29b7443b29c7fa6e889d9) >> 128;
        if (absTick & 0x1000 != 0) ratio = (ratio * 0xd097f3bdfd2022b8845ad8f792aa5825) >> 128;
        if (absTick & 0x2000 != 0) ratio = (ratio * 0xa9f746462d870fdf8a65dc1f90e061e5) >> 128;
        if (absTick & 0x4000 != 0) ratio = (ratio * 0x70d869a156d2a1b890bb3df62baf32f7) >> 128;
        if (absTick & 0x8000 != 0) ratio = (ratio * 0x31be135f97d08fd981231505542fcfa6) >> 128;
        if (absTick & 0x10000 != 0) ratio = (ratio * 0x9aa508b5b7a84e1c677de54f3e99bc9) >> 128;
        if (absTick & 0x20000 != 0) ratio = (ratio * 0x5d6af8dedb81196699c329225ee604) >> 128;
        if (absTick & 0x40000 != 0) ratio = (ratio * 0x2216e584f5fa1ea926041bedfe98) >> 128;
        if (absTick & 0x80000 != 0) ratio = (ratio * 0x48a170391f7dc42444e8fa2) >> 128;

        if (tick > 0) ratio = type(uint256).max / ratio;

        // this divides by 1<<32 rounding up to go from a Q128.128 to a Q128.96.
        // we then downcast because we know the result always fits within 160 bits due to our tick input constraint
        // we round up in the division so getTickAtSqrtRatio of the output price is always consistent
        sqrtPriceX96 = uint160((ratio >> 32) + (ratio % (1 << 32) == 0 ? 0 : 1));
    }

    /// @notice Calculates the greatest tick value such that getRatioAtTick(tick) <= ratio
    /// @dev Throws in case sqrtPriceX96 < MIN_SQRT_RATIO, as MIN_SQRT_RATIO is the lowest value getRatioAtTick may
    /// ever return.
    /// @param sqrtPriceX96 The sqrt ratio for which to compute the tick as a Q64.96
    /// @return tick The greatest tick for which the ratio is less than or equal to the input ratio
    function getTickAtSqrtRatio(uint160 sqrtPriceX96) internal pure returns (int24 tick) {
        // second inequality must be < because the price can never reach the price at the max tick
        require(sqrtPriceX96 >= MIN_SQRT_RATIO && sqrtPriceX96 < MAX_SQRT_RATIO, 'R');
        uint256 ratio = uint256(sqrtPriceX96) << 32;

        uint256 r = ratio;
        uint256 msb = 0;

        assembly {
            let f := shl(7, gt(r, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF))
            msb := or(msb, f)
            r := shr(f, r)
        }
        assembly {
            let f := shl(6, gt(r, 0xFFFFFFFFFFFFFFFF))
            msb := or(msb, f)
            r := shr(f, r)
        }
        assembly {
            let f := shl(5, gt(r, 0xFFFFFFFF))
            msb := or(msb, f)
            r := shr(f, r)
        }
        assembly {
            let f := shl(4, gt(r, 0xFFFF))
            msb := or(msb, f)
            r := shr(f, r)
        }
        assembly {
            let f := shl(3, gt(r, 0xFF))
            msb := or(msb, f)
            r := shr(f, r)
        }
        assembly {
            let f := shl(2, gt(r, 0xF))
            msb := or(msb, f)
            r := shr(f, r)
        }
        assembly {
            let f := shl(1, gt(r, 0x3))
            msb := or(msb, f)
            r := shr(f, r)
        }
        assembly {
            let f := gt(r, 0x1)
            msb := or(msb, f)
        }

        if (msb >= 128) r = ratio >> (msb - 127);
        else r = ratio << (127 - msb);

        int256 log_2 = (int256(msb) - 128) << 64;

        assembly {
            r := shr(127, mul(r, r))
            let f := shr(128, r)
            log_2 := or(log_2, shl(63, f))
            r := shr(f, r)
        }
        assembly {
            r := shr(127, mul(r, r))
            let f := shr(128, r)
            log_2 := or(log_2, shl(62, f))
            r := shr(f, r)
        }
        assembly {
            r := shr(127, mul(r, r))
            let f := shr(128, r)
            log_2 := or(log_2, shl(61, f))
            r := shr(f, r)
        }
        assembly {
            r := shr(127, mul(r, r))
            let f := shr(128, r)
            log_2 := or(log_2, shl(60, f))
            r := shr(f, r)
        }
        assembly {
            r := shr(127, mul(r, r))
            let f := shr(128, r)
            log_2 := or(log_2, shl(59, f))
            r := shr(f, r)
        }
        assembly {
            r := shr(127, mul(r, r))
            let f := shr(128, r)
            log_2 := or(log_2, shl(58, f))
            r := shr(f, r)
        }
        assembly {
            r := shr(127, mul(r, r))
            let f := shr(128, r)
            log_2 := or(log_2, shl(57, f))
            r := shr(f, r)
        }
        assembly {
            r := shr(127, mul(r, r))
            let f := shr(128, r)
            log_2 := or(log_2, shl(56, f))
            r := shr(f, r)
        }
        assembly {
            r := shr(127, mul(r, r))
            let f := shr(128, r)
            log_2 := or(log_2, shl(55, f))
            r := shr(f, r)
        }
        assembly {
            r := shr(127, mul(r, r))
            let f := shr(128, r)
            log_2 := or(log_2, shl(54, f))
            r := shr(f, r)
        }
        assembly {
            r := shr(127, mul(r, r))
            let f := shr(128, r)
            log_2 := or(log_2, shl(53, f))
            r := shr(f, r)
        }
        assembly {
            r := shr(127, mul(r, r))
            let f := shr(128, r)
            log_2 := or(log_2, shl(52, f))
            r := shr(f, r)
        }
        assembly {
            r := shr(127, mul(r, r))
            let f := shr(128, r)
            log_2 := or(log_2, shl(51, f))
            r := shr(f, r)
        }
        assembly {
            r := shr(127, mul(r, r))
            let f := shr(128, r)
            log_2 := or(log_2, shl(50, f))
        }

        int256 log_sqrt10001 = log_2 * 255738958999603826347141; // 128.128 number

        int24 tickLow = int24((log_sqrt10001 - 3402992956809132418596140100660247210) >> 128);
        int24 tickHi = int24((log_sqrt10001 + 291339464771989622907027621153398088495) >> 128);

        tick = tickLow == tickHi ? tickLow : getSqrtRatioAtTick(tickHi) <= sqrtPriceX96 ? tickHi : tickLow;
    }
}

File 16 of 27 : ICurveSUSD.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.5.16;

interface ICurveSUSD {
    function exchange_underlying(
        int128 i,
        int128 j,
        uint256 _dx,
        uint256 _min_dy
    ) external returns (uint256);

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

    //    @notice Perform an exchange between two underlying coins
    //    @param i Index value for the underlying coin to send
    //    @param j Index valie of the underlying coin to receive
    //    @param _dx Amount of `i` being exchanged
    //    @param _min_dy Minimum amount of `j` to receive
    //    @param _receiver Address that receives `j`
    //    @return Actual amount of `j` received

    // indexes:
    // 0 = sUSD 18 dec 0x8c6f28f2F1A3C87F0f938b96d27520d9751ec8d9
    // 1= DAI 18 dec 0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1
    // 2= USDC 6 dec 0x7F5c764cBc14f9669B88837ca1490cCa17c31607
    // 3= USDT 6 dec 0x94b008aA00579c1307B0EF2c499aD98a8ce58e58
}

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

pragma solidity >=0.5.16;

interface IPriceFeed {
    // Structs
    struct RateAndUpdatedTime {
        uint216 rate;
        uint40 time;
    }

    // Mutative functions
    function addAggregator(bytes32 currencyKey, address aggregatorAddress) external;

    function removeAggregator(bytes32 currencyKey) external;

    // Views

    function rateForCurrency(bytes32 currencyKey) external view returns (uint);

    function rateAndUpdatedTime(bytes32 currencyKey) external view returns (uint rate, uint time);

    function getRates() external view returns (uint[] memory);

    function getCurrencies() external view returns (bytes32[] memory);
}

File 18 of 27 : IPositionalMarketManagerTruncated.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

interface IPositionalMarketManagerTruncated {
    function transformCollateral(uint value) external view returns (uint);

    function reverseTransformCollateral(uint value) external view returns (uint);
}

File 19 of 27 : AddressUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Address.sol)

pragma solidity ^0.8.0;

/**
 * @dev Collection of functions related to the address type
 */
library AddressUpgradeable {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize, which returns 0 for contracts in
        // construction, since the code is only stored at the end of the
        // constructor execution.

        uint256 size;
        assembly {
            size := extcodesize(account)
        }
        return size > 0;
    }

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

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

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

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

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

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

        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

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

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

        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason 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 {
            // 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

                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

File 20 of 27 : ContextUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

pragma solidity ^0.8.0;
import "../proxy/utils/Initializable.sol";

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

    function __Context_init_unchained() internal onlyInitializing {
    }
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }
    uint256[50] private __gap;
}

File 21 of 27 : IUniswapV3SwapCallback.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

/// @title Callback for IUniswapV3PoolActions#swap
/// @notice Any contract that calls IUniswapV3PoolActions#swap must implement this interface
interface IUniswapV3SwapCallback {
    /// @notice Called to `msg.sender` after executing a swap via IUniswapV3Pool#swap.
    /// @dev In the implementation you must pay the pool tokens owed for the swap.
    /// The caller of this method must be checked to be a UniswapV3Pool deployed by the canonical UniswapV3Factory.
    /// amount0Delta and amount1Delta can both be 0 if no tokens were swapped.
    /// @param amount0Delta The amount of token0 that was sent (negative) or must be received (positive) by the pool by
    /// the end of the swap. If positive, the callback must send that amount of token0 to the pool.
    /// @param amount1Delta The amount of token1 that was sent (negative) or must be received (positive) by the pool by
    /// the end of the swap. If positive, the callback must send that amount of token1 to the pool.
    /// @param data Any data passed through by the caller via the IUniswapV3PoolActions#swap call
    function uniswapV3SwapCallback(
        int256 amount0Delta,
        int256 amount1Delta,
        bytes calldata data
    ) external;
}

File 22 of 27 : IUniswapV3PoolImmutables.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

/// @title Pool state that never changes
/// @notice These parameters are fixed for a pool forever, i.e., the methods will always return the same values
interface IUniswapV3PoolImmutables {
    /// @notice The contract that deployed the pool, which must adhere to the IUniswapV3Factory interface
    /// @return The contract address
    function factory() external view returns (address);

    /// @notice The first of the two tokens of the pool, sorted by address
    /// @return The token contract address
    function token0() external view returns (address);

    /// @notice The second of the two tokens of the pool, sorted by address
    /// @return The token contract address
    function token1() external view returns (address);

    /// @notice The pool's fee in hundredths of a bip, i.e. 1e-6
    /// @return The fee
    function fee() external view returns (uint24);

    /// @notice The pool tick spacing
    /// @dev Ticks can only be used at multiples of this value, minimum of 1 and always positive
    /// e.g.: a tickSpacing of 3 means ticks can be initialized every 3rd tick, i.e., ..., -6, -3, 0, 3, 6, ...
    /// This value is an int24 to avoid casting even though it is always positive.
    /// @return The tick spacing
    function tickSpacing() external view returns (int24);

    /// @notice The maximum amount of position liquidity that can use any tick in the range
    /// @dev This parameter is enforced per tick to prevent liquidity from overflowing a uint128 at any point, and
    /// also prevents out-of-range liquidity from being used to prevent adding in-range liquidity to a pool
    /// @return The max amount of liquidity per tick
    function maxLiquidityPerTick() external view returns (uint128);
}

File 23 of 27 : IUniswapV3PoolState.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

/// @title Pool state that can change
/// @notice These methods compose the pool's state, and can change with any frequency including multiple times
/// per transaction
interface IUniswapV3PoolState {
    /// @notice The 0th storage slot in the pool stores many values, and is exposed as a single method to save gas
    /// when accessed externally.
    /// @return sqrtPriceX96 The current price of the pool as a sqrt(token1/token0) Q64.96 value
    /// tick The current tick of the pool, i.e. according to the last tick transition that was run.
    /// This value may not always be equal to SqrtTickMath.getTickAtSqrtRatio(sqrtPriceX96) if the price is on a tick
    /// boundary.
    /// observationIndex The index of the last oracle observation that was written,
    /// observationCardinality The current maximum number of observations stored in the pool,
    /// observationCardinalityNext The next maximum number of observations, to be updated when the observation.
    /// feeProtocol The protocol fee for both tokens of the pool.
    /// Encoded as two 4 bit values, where the protocol fee of token1 is shifted 4 bits and the protocol fee of token0
    /// is the lower 4 bits. Used as the denominator of a fraction of the swap fee, e.g. 4 means 1/4th of the swap fee.
    /// unlocked Whether the pool is currently locked to reentrancy
    function slot0()
        external
        view
        returns (
            uint160 sqrtPriceX96,
            int24 tick,
            uint16 observationIndex,
            uint16 observationCardinality,
            uint16 observationCardinalityNext,
            uint8 feeProtocol,
            bool unlocked
        );

    /// @notice The fee growth as a Q128.128 fees of token0 collected per unit of liquidity for the entire life of the pool
    /// @dev This value can overflow the uint256
    function feeGrowthGlobal0X128() external view returns (uint256);

    /// @notice The fee growth as a Q128.128 fees of token1 collected per unit of liquidity for the entire life of the pool
    /// @dev This value can overflow the uint256
    function feeGrowthGlobal1X128() external view returns (uint256);

    /// @notice The amounts of token0 and token1 that are owed to the protocol
    /// @dev Protocol fees will never exceed uint128 max in either token
    function protocolFees() external view returns (uint128 token0, uint128 token1);

    /// @notice The currently in range liquidity available to the pool
    /// @dev This value has no relationship to the total liquidity across all ticks
    function liquidity() external view returns (uint128);

    /// @notice Look up information about a specific tick in the pool
    /// @param tick The tick to look up
    /// @return liquidityGross the total amount of position liquidity that uses the pool either as tick lower or
    /// tick upper,
    /// liquidityNet how much liquidity changes when the pool price crosses the tick,
    /// feeGrowthOutside0X128 the fee growth on the other side of the tick from the current tick in token0,
    /// feeGrowthOutside1X128 the fee growth on the other side of the tick from the current tick in token1,
    /// tickCumulativeOutside the cumulative tick value on the other side of the tick from the current tick
    /// secondsPerLiquidityOutsideX128 the seconds spent per liquidity on the other side of the tick from the current tick,
    /// secondsOutside the seconds spent on the other side of the tick from the current tick,
    /// initialized Set to true if the tick is initialized, i.e. liquidityGross is greater than 0, otherwise equal to false.
    /// Outside values can only be used if the tick is initialized, i.e. if liquidityGross is greater than 0.
    /// In addition, these values are only relative and must be used only in comparison to previous snapshots for
    /// a specific position.
    function ticks(int24 tick)
        external
        view
        returns (
            uint128 liquidityGross,
            int128 liquidityNet,
            uint256 feeGrowthOutside0X128,
            uint256 feeGrowthOutside1X128,
            int56 tickCumulativeOutside,
            uint160 secondsPerLiquidityOutsideX128,
            uint32 secondsOutside,
            bool initialized
        );

    /// @notice Returns 256 packed tick initialized boolean values. See TickBitmap for more information
    function tickBitmap(int16 wordPosition) external view returns (uint256);

    /// @notice Returns the information about a position by the position's key
    /// @param key The position's key is a hash of a preimage composed by the owner, tickLower and tickUpper
    /// @return _liquidity The amount of liquidity in the position,
    /// Returns feeGrowthInside0LastX128 fee growth of token0 inside the tick range as of the last mint/burn/poke,
    /// Returns feeGrowthInside1LastX128 fee growth of token1 inside the tick range as of the last mint/burn/poke,
    /// Returns tokensOwed0 the computed amount of token0 owed to the position as of the last mint/burn/poke,
    /// Returns tokensOwed1 the computed amount of token1 owed to the position as of the last mint/burn/poke
    function positions(bytes32 key)
        external
        view
        returns (
            uint128 _liquidity,
            uint256 feeGrowthInside0LastX128,
            uint256 feeGrowthInside1LastX128,
            uint128 tokensOwed0,
            uint128 tokensOwed1
        );

    /// @notice Returns data about a specific observation index
    /// @param index The element of the observations array to fetch
    /// @dev You most likely want to use #observe() instead of this method to get an observation as of some amount of time
    /// ago, rather than at a specific index in the array.
    /// @return blockTimestamp The timestamp of the observation,
    /// Returns tickCumulative the tick multiplied by seconds elapsed for the life of the pool as of the observation timestamp,
    /// Returns secondsPerLiquidityCumulativeX128 the seconds per in range liquidity for the life of the pool as of the observation timestamp,
    /// Returns initialized whether the observation has been initialized and the values are safe to use
    function observations(uint256 index)
        external
        view
        returns (
            uint32 blockTimestamp,
            int56 tickCumulative,
            uint160 secondsPerLiquidityCumulativeX128,
            bool initialized
        );
}

File 24 of 27 : IUniswapV3PoolDerivedState.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

/// @title Pool state that is not stored
/// @notice Contains view functions to provide information about the pool that is computed rather than stored on the
/// blockchain. The functions here may have variable gas costs.
interface IUniswapV3PoolDerivedState {
    /// @notice Returns the cumulative tick and liquidity as of each timestamp `secondsAgo` from the current block timestamp
    /// @dev To get a time weighted average tick or liquidity-in-range, you must call this with two values, one representing
    /// the beginning of the period and another for the end of the period. E.g., to get the last hour time-weighted average tick,
    /// you must call it with secondsAgos = [3600, 0].
    /// @dev The time weighted average tick represents the geometric time weighted average price of the pool, in
    /// log base sqrt(1.0001) of token1 / token0. The TickMath library can be used to go from a tick value to a ratio.
    /// @param secondsAgos From how long ago each cumulative tick and liquidity value should be returned
    /// @return tickCumulatives Cumulative tick values as of each `secondsAgos` from the current block timestamp
    /// @return secondsPerLiquidityCumulativeX128s Cumulative seconds per liquidity-in-range value as of each `secondsAgos` from the current block
    /// timestamp
    function observe(uint32[] calldata secondsAgos)
        external
        view
        returns (int56[] memory tickCumulatives, uint160[] memory secondsPerLiquidityCumulativeX128s);

    /// @notice Returns a snapshot of the tick cumulative, seconds per liquidity and seconds inside a tick range
    /// @dev Snapshots must only be compared to other snapshots, taken over a period for which a position existed.
    /// I.e., snapshots cannot be compared if a position is not held for the entire period between when the first
    /// snapshot is taken and the second snapshot is taken.
    /// @param tickLower The lower tick of the range
    /// @param tickUpper The upper tick of the range
    /// @return tickCumulativeInside The snapshot of the tick accumulator for the range
    /// @return secondsPerLiquidityInsideX128 The snapshot of seconds per liquidity for the range
    /// @return secondsInside The snapshot of seconds per liquidity for the range
    function snapshotCumulativesInside(int24 tickLower, int24 tickUpper)
        external
        view
        returns (
            int56 tickCumulativeInside,
            uint160 secondsPerLiquidityInsideX128,
            uint32 secondsInside
        );
}

File 25 of 27 : IUniswapV3PoolActions.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

/// @title Permissionless pool actions
/// @notice Contains pool methods that can be called by anyone
interface IUniswapV3PoolActions {
    /// @notice Sets the initial price for the pool
    /// @dev Price is represented as a sqrt(amountToken1/amountToken0) Q64.96 value
    /// @param sqrtPriceX96 the initial sqrt price of the pool as a Q64.96
    function initialize(uint160 sqrtPriceX96) external;

    /// @notice Adds liquidity for the given recipient/tickLower/tickUpper position
    /// @dev The caller of this method receives a callback in the form of IUniswapV3MintCallback#uniswapV3MintCallback
    /// in which they must pay any token0 or token1 owed for the liquidity. The amount of token0/token1 due depends
    /// on tickLower, tickUpper, the amount of liquidity, and the current price.
    /// @param recipient The address for which the liquidity will be created
    /// @param tickLower The lower tick of the position in which to add liquidity
    /// @param tickUpper The upper tick of the position in which to add liquidity
    /// @param amount The amount of liquidity to mint
    /// @param data Any data that should be passed through to the callback
    /// @return amount0 The amount of token0 that was paid to mint the given amount of liquidity. Matches the value in the callback
    /// @return amount1 The amount of token1 that was paid to mint the given amount of liquidity. Matches the value in the callback
    function mint(
        address recipient,
        int24 tickLower,
        int24 tickUpper,
        uint128 amount,
        bytes calldata data
    ) external returns (uint256 amount0, uint256 amount1);

    /// @notice Collects tokens owed to a position
    /// @dev Does not recompute fees earned, which must be done either via mint or burn of any amount of liquidity.
    /// Collect must be called by the position owner. To withdraw only token0 or only token1, amount0Requested or
    /// amount1Requested may be set to zero. To withdraw all tokens owed, caller may pass any value greater than the
    /// actual tokens owed, e.g. type(uint128).max. Tokens owed may be from accumulated swap fees or burned liquidity.
    /// @param recipient The address which should receive the fees collected
    /// @param tickLower The lower tick of the position for which to collect fees
    /// @param tickUpper The upper tick of the position for which to collect fees
    /// @param amount0Requested How much token0 should be withdrawn from the fees owed
    /// @param amount1Requested How much token1 should be withdrawn from the fees owed
    /// @return amount0 The amount of fees collected in token0
    /// @return amount1 The amount of fees collected in token1
    function collect(
        address recipient,
        int24 tickLower,
        int24 tickUpper,
        uint128 amount0Requested,
        uint128 amount1Requested
    ) external returns (uint128 amount0, uint128 amount1);

    /// @notice Burn liquidity from the sender and account tokens owed for the liquidity to the position
    /// @dev Can be used to trigger a recalculation of fees owed to a position by calling with an amount of 0
    /// @dev Fees must be collected separately via a call to #collect
    /// @param tickLower The lower tick of the position for which to burn liquidity
    /// @param tickUpper The upper tick of the position for which to burn liquidity
    /// @param amount How much liquidity to burn
    /// @return amount0 The amount of token0 sent to the recipient
    /// @return amount1 The amount of token1 sent to the recipient
    function burn(
        int24 tickLower,
        int24 tickUpper,
        uint128 amount
    ) external returns (uint256 amount0, uint256 amount1);

    /// @notice Swap token0 for token1, or token1 for token0
    /// @dev The caller of this method receives a callback in the form of IUniswapV3SwapCallback#uniswapV3SwapCallback
    /// @param recipient The address to receive the output of the swap
    /// @param zeroForOne The direction of the swap, true for token0 to token1, false for token1 to token0
    /// @param amountSpecified The amount of the swap, which implicitly configures the swap as exact input (positive), or exact output (negative)
    /// @param sqrtPriceLimitX96 The Q64.96 sqrt price limit. If zero for one, the price cannot be less than this
    /// value after the swap. If one for zero, the price cannot be greater than this value after the swap
    /// @param data Any data to be passed through to the callback
    /// @return amount0 The delta of the balance of token0 of the pool, exact when negative, minimum when positive
    /// @return amount1 The delta of the balance of token1 of the pool, exact when negative, minimum when positive
    function swap(
        address recipient,
        bool zeroForOne,
        int256 amountSpecified,
        uint160 sqrtPriceLimitX96,
        bytes calldata data
    ) external returns (int256 amount0, int256 amount1);

    /// @notice Receive token0 and/or token1 and pay it back, plus a fee, in the callback
    /// @dev The caller of this method receives a callback in the form of IUniswapV3FlashCallback#uniswapV3FlashCallback
    /// @dev Can be used to donate underlying tokens pro-rata to currently in-range liquidity providers by calling
    /// with 0 amount{0,1} and sending the donation amount(s) from the callback
    /// @param recipient The address which will receive the token0 and token1 amounts
    /// @param amount0 The amount of token0 to send
    /// @param amount1 The amount of token1 to send
    /// @param data Any data to be passed through to the callback
    function flash(
        address recipient,
        uint256 amount0,
        uint256 amount1,
        bytes calldata data
    ) external;

    /// @notice Increase the maximum number of price and liquidity observations that this pool will store
    /// @dev This method is no-op if the pool already has an observationCardinalityNext greater than or equal to
    /// the input observationCardinalityNext.
    /// @param observationCardinalityNext The desired minimum number of observations for the pool to store
    function increaseObservationCardinalityNext(uint16 observationCardinalityNext) external;
}

File 26 of 27 : IUniswapV3PoolOwnerActions.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

/// @title Permissioned pool actions
/// @notice Contains pool methods that may only be called by the factory owner
interface IUniswapV3PoolOwnerActions {
    /// @notice Set the denominator of the protocol's % share of the fees
    /// @param feeProtocol0 new protocol fee for token0 of the pool
    /// @param feeProtocol1 new protocol fee for token1 of the pool
    function setFeeProtocol(uint8 feeProtocol0, uint8 feeProtocol1) external;

    /// @notice Collect the protocol fee accrued to the pool
    /// @param recipient The address to which collected protocol fees should be sent
    /// @param amount0Requested The maximum amount of token0 to send, can be 0 to collect fees in only token1
    /// @param amount1Requested The maximum amount of token1 to send, can be 0 to collect fees in only token0
    /// @return amount0 The protocol fee collected in token0
    /// @return amount1 The protocol fee collected in token1
    function collectProtocol(
        address recipient,
        uint128 amount0Requested,
        uint128 amount1Requested
    ) external returns (uint128 amount0, uint128 amount1);
}

File 27 of 27 : IUniswapV3PoolEvents.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

/// @title Events emitted by a pool
/// @notice Contains all events emitted by the pool
interface IUniswapV3PoolEvents {
    /// @notice Emitted exactly once by a pool when #initialize is first called on the pool
    /// @dev Mint/Burn/Swap cannot be emitted by the pool before Initialize
    /// @param sqrtPriceX96 The initial sqrt price of the pool, as a Q64.96
    /// @param tick The initial tick of the pool, i.e. log base 1.0001 of the starting price of the pool
    event Initialize(uint160 sqrtPriceX96, int24 tick);

    /// @notice Emitted when liquidity is minted for a given position
    /// @param sender The address that minted the liquidity
    /// @param owner The owner of the position and recipient of any minted liquidity
    /// @param tickLower The lower tick of the position
    /// @param tickUpper The upper tick of the position
    /// @param amount The amount of liquidity minted to the position range
    /// @param amount0 How much token0 was required for the minted liquidity
    /// @param amount1 How much token1 was required for the minted liquidity
    event Mint(
        address sender,
        address indexed owner,
        int24 indexed tickLower,
        int24 indexed tickUpper,
        uint128 amount,
        uint256 amount0,
        uint256 amount1
    );

    /// @notice Emitted when fees are collected by the owner of a position
    /// @dev Collect events may be emitted with zero amount0 and amount1 when the caller chooses not to collect fees
    /// @param owner The owner of the position for which fees are collected
    /// @param tickLower The lower tick of the position
    /// @param tickUpper The upper tick of the position
    /// @param amount0 The amount of token0 fees collected
    /// @param amount1 The amount of token1 fees collected
    event Collect(
        address indexed owner,
        address recipient,
        int24 indexed tickLower,
        int24 indexed tickUpper,
        uint128 amount0,
        uint128 amount1
    );

    /// @notice Emitted when a position's liquidity is removed
    /// @dev Does not withdraw any fees earned by the liquidity position, which must be withdrawn via #collect
    /// @param owner The owner of the position for which liquidity is removed
    /// @param tickLower The lower tick of the position
    /// @param tickUpper The upper tick of the position
    /// @param amount The amount of liquidity to remove
    /// @param amount0 The amount of token0 withdrawn
    /// @param amount1 The amount of token1 withdrawn
    event Burn(
        address indexed owner,
        int24 indexed tickLower,
        int24 indexed tickUpper,
        uint128 amount,
        uint256 amount0,
        uint256 amount1
    );

    /// @notice Emitted by the pool for any swaps between token0 and token1
    /// @param sender The address that initiated the swap call, and that received the callback
    /// @param recipient The address that received the output of the swap
    /// @param amount0 The delta of the token0 balance of the pool
    /// @param amount1 The delta of the token1 balance of the pool
    /// @param sqrtPriceX96 The sqrt(price) of the pool after the swap, as a Q64.96
    /// @param liquidity The liquidity of the pool after the swap
    /// @param tick The log base 1.0001 of price of the pool after the swap
    event Swap(
        address indexed sender,
        address indexed recipient,
        int256 amount0,
        int256 amount1,
        uint160 sqrtPriceX96,
        uint128 liquidity,
        int24 tick
    );

    /// @notice Emitted by the pool for any flashes of token0/token1
    /// @param sender The address that initiated the swap call, and that received the callback
    /// @param recipient The address that received the tokens from flash
    /// @param amount0 The amount of token0 that was flashed
    /// @param amount1 The amount of token1 that was flashed
    /// @param paid0 The amount of token0 paid for the flash, which can exceed the amount0 plus the fee
    /// @param paid1 The amount of token1 paid for the flash, which can exceed the amount1 plus the fee
    event Flash(
        address indexed sender,
        address indexed recipient,
        uint256 amount0,
        uint256 amount1,
        uint256 paid0,
        uint256 paid1
    );

    /// @notice Emitted by the pool for increases to the number of observations that can be stored
    /// @dev observationCardinalityNext is not the observation cardinality until an observation is written at the index
    /// just before a mint/swap/burn.
    /// @param observationCardinalityNextOld The previous value of the next observation cardinality
    /// @param observationCardinalityNextNew The updated value of the next observation cardinality
    event IncreaseObservationCardinalityNext(
        uint16 observationCardinalityNextOld,
        uint16 observationCardinalityNextNew
    );

    /// @notice Emitted when the protocol fee is changed by the pool
    /// @param feeProtocol0Old The previous value of the token0 protocol fee
    /// @param feeProtocol1Old The previous value of the token1 protocol fee
    /// @param feeProtocol0New The updated value of the token0 protocol fee
    /// @param feeProtocol1New The updated value of the token1 protocol fee
    event SetFeeProtocol(uint8 feeProtocol0Old, uint8 feeProtocol1Old, uint8 feeProtocol0New, uint8 feeProtocol1New);

    /// @notice Emitted when the collected protocol fees are withdrawn by the factory owner
    /// @param sender The address that collects the protocol fees
    /// @param recipient The address that receives the collected protocol fees
    /// @param amount0 The amount of token0 protocol fees that is withdrawn
    /// @param amount0 The amount of token1 protocol fees that is withdrawn
    event CollectProtocol(address indexed sender, address indexed recipient, uint128 amount0, uint128 amount1);
}

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

Contract Security Audit

Contract ABI

[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_curveSUSD","type":"address"},{"indexed":false,"internalType":"address","name":"_dai","type":"address"},{"indexed":false,"internalType":"address","name":"_usdc","type":"address"},{"indexed":false,"internalType":"address","name":"_usdt","type":"address"},{"indexed":false,"internalType":"bool","name":"_curveOnrampEnabled","type":"bool"},{"indexed":false,"internalType":"uint256","name":"_maxAllowedPegSlippagePercentage","type":"uint256"}],"name":"CurveSUSDSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"collateral","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Offramped","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"OfframpedEth","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"collateral","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Onramped","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"OnrampedEth","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldOwner","type":"address"},{"indexed":false,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnerChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnerNominated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"isPaused","type":"bool"}],"name":"PauseChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_maxAllowedSlippage","type":"uint256"}],"name":"SetMaxAllowedPegSlippagePercentage","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"collateral","type":"address"},{"indexed":false,"internalType":"uint256","name":"_maxAllowedSlippagePerCollateral","type":"uint256"}],"name":"SetMaxAllowedPegSlippagePercentagePerCollateral","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"asset","type":"address"},{"indexed":false,"internalType":"bytes","name":"path","type":"bytes"},{"indexed":false,"internalType":"bool","name":"doReset","type":"bool"}],"name":"SetPathPerCollateral","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"asset","type":"address"},{"indexed":false,"internalType":"bytes","name":"path","type":"bytes"},{"indexed":false,"internalType":"bool","name":"doReset","type":"bool"}],"name":"SetPathPerCollateralOfframp","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_priceFeed","type":"address"}],"name":"SetPriceFeed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"key","type":"bytes32"},{"indexed":false,"internalType":"address","name":"asset","type":"address"}],"name":"SetPriceFeedKeyPerAsset","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_usd","type":"address"}],"name":"SetSUSD","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"amm","type":"address"},{"indexed":false,"internalType":"bool","name":"supported","type":"bool"}],"name":"SetSupportedAMM","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"collateral","type":"address"},{"indexed":false,"internalType":"bool","name":"supported","type":"bool"}],"name":"SetSupportedCollateral","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_router","type":"address"}],"name":"SetSwapRouter","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_weth","type":"address"}],"name":"SetWETH","type":"event"},{"inputs":[],"name":"WETH9","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"acceptOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"ammsSupported","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"collateralSupported","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"curveOnrampEnabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"curveSUSD","outputs":[{"internalType":"contract ICurveSUSD","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"dai","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"inToken","type":"address"},{"internalType":"uint24","name":"feeIn","type":"uint24"},{"internalType":"address","name":"proxy","type":"address"},{"internalType":"uint24","name":"feeOut","type":"uint24"},{"internalType":"address","name":"target","type":"address"}],"name":"getEncodedPacked","outputs":[{"internalType":"bytes","name":"encoded","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"collateral","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"getMaximumReceived","outputs":[{"internalType":"uint256","name":"maxReceived","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"collateral","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"getMaximumReceivedOfframp","outputs":[{"internalType":"uint256","name":"maxReceivedOfframp","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"collateral","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"getMinimumNeeded","outputs":[{"internalType":"uint256","name":"minNeeded","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"collateral","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"getMinimumReceived","outputs":[{"internalType":"uint256","name":"minReceived","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"collateral","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"getMinimumReceivedOfframp","outputs":[{"internalType":"uint256","name":"minReceivedOfframp","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"initNonReentrant","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"contract IERC20Upgradeable","name":"_sUSD","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"lastPauseTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"manager","outputs":[{"internalType":"contract IPositionalMarketManagerTruncated","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxAllowedPegSlippagePercentage","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"maxAllowedPegSlippagePercentagePerCollateral","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"name":"nominateNewOwner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"nominatedOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"collateral","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"offramp","outputs":[{"internalType":"uint256","name":"convertedAmount","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"offrampIntoEth","outputs":[{"internalType":"uint256","name":"convertedAmount","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"collateral","type":"address"},{"internalType":"uint256","name":"collateralAmount","type":"uint256"}],"name":"onramp","outputs":[{"internalType":"uint256","name":"convertedAmount","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"onrampWithEth","outputs":[{"internalType":"uint256","name":"convertedAmount","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"pathPerCollateral","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"pathPerCollateralOfframp","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"priceFeed","outputs":[{"internalType":"contract IPriceFeed","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"priceFeedKeyPerCollateral","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"sUSD","outputs":[{"internalType":"contract IERC20Upgradeable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_curveSUSD","type":"address"},{"internalType":"address","name":"_dai","type":"address"},{"internalType":"address","name":"_usdc","type":"address"},{"internalType":"address","name":"_usdt","type":"address"},{"internalType":"bool","name":"_curveOnrampEnabled","type":"bool"},{"internalType":"uint256","name":"_maxAllowedPegSlippagePercentage","type":"uint256"}],"name":"setCurveSUSD","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_maxAllowedSlippage","type":"uint256"}],"name":"setMaxAllowedPegSlippagePercentage","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"collateral","type":"address"},{"internalType":"uint256","name":"_maxAllowedSlippagePerCollateral","type":"uint256"}],"name":"setMaxAllowedPegSlippagePercentagePerCollateral","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"name":"setOwner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"},{"internalType":"bytes","name":"path","type":"bytes"},{"internalType":"bool","name":"doReset","type":"bool"}],"name":"setPathPerCollateral","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"},{"internalType":"bytes","name":"path","type":"bytes"},{"internalType":"bool","name":"doReset","type":"bool"}],"name":"setPathPerCollateralOfframp","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_paused","type":"bool"}],"name":"setPaused","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_priceFeed","type":"address"}],"name":"setPriceFeed","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"key","type":"bytes32"},{"internalType":"address","name":"asset","type":"address"}],"name":"setPriceFeedKeyPerAsset","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_usd","type":"address"}],"name":"setSUSD","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"amm","type":"address"},{"internalType":"bool","name":"supported","type":"bool"}],"name":"setSupportedAMM","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"collateral","type":"address"},{"internalType":"bool","name":"supported","type":"bool"}],"name":"setSupportedCollateral","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_router","type":"address"}],"name":"setSwapRouter","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_weth","type":"address"}],"name":"setWETH","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"swapRouter","outputs":[{"internalType":"contract ISwapRouter","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"proxyAddress","type":"address"}],"name":"transferOwnershipAtInit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"usdc","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"usdt","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}]

608060405234801561001057600080fd5b50613eeb806100206000396000f3fe6080604052600436106102cd5760003560e01c80635c975abb11610175578063a5bf660d116100dc578063c4ebcb5411610095578063da6070251161006f578063da607025146108f7578063ebc7977214610917578063f4b9fa751461092c578063f5866a461461094c57600080fd5b8063c4ebcb5414610897578063cb4ba524146108b7578063d3c4297c146108d757600080fd5b8063a5bf660d146107c7578063b45e98d9146107e7578063b98b63f814610807578063c31c9c0714610837578063c3b83f5f14610857578063c42f4c8b1461087757600080fd5b80638826e5de1161012e5780638826e5de146107065780638b3ac44c146107265780638da5cb5b1461074657806391b4ded91461076c5780639324cac714610782578063953caf51146107a757600080fd5b80635c975abb1461063d578063724e78da14610657578063741bef1a1461067757806379ba5097146106975780637d904d3a146106ac57806382e76c36146106d957600080fd5b80632f48ab7d11610234578063481c6a75116101ed5780634c932368116101c75780634c932368146105bd57806353a47bb7146105dd5780635b769f3c146105fd5780635c5189bb1461061d57600080fd5b8063481c6a751461055d578063485cc9551461057d5780634aa4a4fc1461059d57600080fd5b80632f48ab7d1461048557806338053078146104bd5780633e413bee146104dd57806341273657146104fd578063420a038c1461051d578063477bf5a51461053d57600080fd5b80631fbb38e8116102865780631fbb38e8146103ae57806321ef44c6146103df5780632213af25146103ff57806322bdb38c1461041f5780632909f51a1461043f5780632ab8de381461045557600080fd5b80630d9393cf146102d95780631321b85d1461030c57806313af40351461031f5780631627540c1461034157806316c38b3c14610361578063178b8ac81461038157600080fd5b366102d457005b600080fd5b3480156102e557600080fd5b506102f96102f43660046139e0565b61096c565b6040519081526020015b60405180910390f35b6102f961031a366004613a67565b610b29565b34801561032b57600080fd5b5061033f61033a3660046137e8565b610ed9565b005b34801561034d57600080fd5b5061033f61035c3660046137e8565b611014565b34801561036d57600080fd5b5061033f61037c366004613a0b565b61106a565b34801561038d57600080fd5b506103a161039c366004613974565b6110e0565b6040516103039190613b94565b3480156103ba57600080fd5b50600d546103cf90600160a01b900460ff1681565b6040519015158152602001610303565b3480156103eb57600080fd5b5061033f6103fa3660046137e8565b611178565b34801561040b57600080fd5b506103a161041a3660046137e8565b6111fc565b34801561042b57600080fd5b506103a161043a3660046137e8565b611296565b34801561044b57600080fd5b506102f9600e5481565b34801561046157600080fd5b506103cf6104703660046137e8565b60066020526000908152604090205460ff1681565b34801561049157600080fd5b50600c546104a5906001600160a01b031681565b6040516001600160a01b039091168152602001610303565b3480156104c957600080fd5b5061033f6104d83660046138b4565b6112af565b3480156104e957600080fd5b50600b546104a5906001600160a01b031681565b34801561050957600080fd5b5061033f6105183660046137e8565b61137c565b34801561052957600080fd5b506102f96105383660046139e0565b6113f8565b34801561054957600080fd5b5061033f610558366004613a43565b6115b1565b34801561056957600080fd5b506012546104a5906001600160a01b031681565b34801561058957600080fd5b5061033f610598366004613947565b61163a565b3480156105a957600080fd5b50600a546104a5906001600160a01b031681565b3480156105c957600080fd5b506102f96105d83660046139e0565b611726565b3480156105e957600080fd5b506001546104a5906001600160a01b031681565b34801561060957600080fd5b5061033f6106183660046137e8565b6118d7565b34801561062957600080fd5b5061033f610638366004613a67565b611953565b34801561064957600080fd5b506003546103cf9060ff1681565b34801561066357600080fd5b5061033f6106723660046137e8565b6119e7565b34801561068357600080fd5b506009546104a5906001600160a01b031681565b3480156106a357600080fd5b5061033f611a63565b3480156106b857600080fd5b506102f96106c73660046137e8565b60146020526000908152604090205481565b3480156106e557600080fd5b506102f96106f43660046137e8565b60116020526000908152604090205481565b34801561071257600080fd5b506102f96107213660046139e0565b611b60565b34801561073257600080fd5b506102f96107413660046139e0565b611c7d565b34801561075257600080fd5b506000546104a5906201000090046001600160a01b031681565b34801561077857600080fd5b506102f960025481565b34801561078e57600080fd5b506005546104a59061010090046001600160a01b031681565b3480156107b357600080fd5b5061033f6107c236600461387c565b611dfe565b3480156107d357600080fd5b50600f546104a5906001600160a01b031681565b3480156107f357600080fd5b506102f9610802366004613a67565b611e88565b34801561081357600080fd5b506103cf6108223660046137e8565b60076020526000908152604090205460ff1681565b34801561084357600080fd5b506008546104a5906001600160a01b031681565b34801561086357600080fd5b5061033f6108723660046137e8565b612043565b34801561088357600080fd5b506102f96108923660046139e0565b61215c565b3480156108a357600080fd5b5061033f6108b23660046138b4565b612168565b3480156108c357600080fd5b506102f96108d23660046139e0565b612227565b3480156108e357600080fd5b5061033f6108f2366004613804565b61237f565b34801561090357600080fd5b5061033f61091236600461387c565b6127fb565b34801561092357600080fd5b5061033f612885565b34801561093857600080fd5b50600d546104a5906001600160a01b031681565b34801561095857600080fd5b5061033f6109673660046139e0565b6128e3565b6000610977826129b0565b9150600061098484612a58565b600f0b1315610a0d57670de0b6b3a764000061099f84612abd565b6109b190670de0b6b3a7640000613e04565b6109bb9084613de5565b6109c59190613dc5565b600b549091506001600160a01b03848116911614806109f15750600c546001600160a01b038481169116145b15610a0857610a0564e8d4a5100082613dc5565b90505b610b23565b6009546001600160a01b038481166000908152601160205260408082205490516315905ec160e31b815260048101919091529092919091169063ac82f6089060240160206040518083038186803b158015610a6757600080fd5b505afa158015610a7b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a9f9190613a7f565b905060008111610aca5760405162461bcd60e51b8152600401610ac190613ca5565b60405180910390fd5b670de0b6b3a7640000610adc85612abd565b610aee90670de0b6b3a7640000613e04565b82610b01670de0b6b3a764000087613de5565b610b0b9190613dc5565b610b159190613de5565b610b1f9190613dc5565b9150505b92915050565b6000600160046000828254610b3e9190613dad565b909155505060045460035460ff1615610b695760405162461bcd60e51b8152600401610ac190613c48565b600a546001600160a01b031660009081526006602052604090205460ff16610ba35760405162461bcd60e51b8152600401610ac190613ba7565b3360009081526007602052604090205460ff16610bd25760405162461bcd60e51b8152600401610ac190613c1c565b60008311610c1b5760405162461bcd60e51b8152602060048201526016602482015275086c2dc40dcdee840caf0c6d0c2dcceca4060408aa8960531b6044820152606401610ac1565b823414610c855760405162461bcd60e51b815260206004820152603260248201527f416d6f756e74204554482068617320746f20626520657175616c20746f20746860448201527119481cdc1958da599a595908185b5bdd5b9d60721b6064820152608401610ac1565b600a546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a082319060240160206040518083038186803b158015610cc957600080fd5b505afa158015610cdd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d019190613a7f565b9050600a60009054906101000a90046001600160a01b03166001600160a01b031663d0e30db0856040518263ffffffff1660e01b81526004016000604051808303818588803b158015610d5357600080fd5b505af1158015610d67573d6000803e3d6000fd5b5050600a546040516370a0823160e01b8152306004820152600094508593506001600160a01b0390911691506370a082319060240160206040518083038186803b158015610db457600080fd5b505afa158015610dc8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dec9190613a7f565b610df69190613e04565b9050848114610e475760405162461bcd60e51b815260206004820152601860248201527f4e6f7420656e6f756768205745544820726563656976656400000000000000006044820152606401610ac1565b600a54610e5e9086906001600160a01b0316612b25565b600554909450610e7d9061010090046001600160a01b03163386612d92565b6040518581527f1d21653337ffd9933b1202c6f3c39cd605ff6743734277eb4e927881358330ca9060200160405180910390a150506004548114610ed35760405162461bcd60e51b8152600401610ac190613ce7565b50919050565b6001600160a01b038116610f2f5760405162461bcd60e51b815260206004820152601960248201527f4f776e657220616464726573732063616e6e6f742062652030000000000000006044820152606401610ac1565b600154600160a01b900460ff1615610f9b5760405162461bcd60e51b815260206004820152602960248201527f416c726561647920696e697469616c697a65642c20757365206e6f6d696e617460448201526832a732bba7bbb732b960b91b6064820152608401610ac1565b6001805460ff60a01b1916600160a01b179055600080546001600160a01b03831662010000810262010000600160b01b03199092169190911782556040805192835260208301919091527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c91015b60405180910390a150565b61101c612de8565b600180546001600160a01b0319166001600160a01b0383169081179091556040519081527f906a1c6bd7e3091ea86693dd029a831c19049ce77f1dce2ce0bab1cacbabce2290602001611009565b611072612de8565b60035460ff16151581151514156110865750565b6003805460ff191682151590811790915560ff16156110a457426002555b60035460405160ff909116151581527f8fb6c181ee25a520cf3dd6565006ef91229fcfe5a989566c2a3b8c115570cec590602001611009565b50565b60606001600160a01b0384161561112057858585858560405160200161110a959493929190613ac3565b604051602081830303815290604052905061116f565b6040516bffffffffffffffffffffffff19606088811b821660208401526001600160e81b031960e887901b16603484015284901b166037820152604b0160405160208183030381529060405290505b95945050505050565b611180612de8565b6001600160a01b0381166111a65760405162461bcd60e51b8152600401610ac190613d1e565b60058054610100600160a81b0319166101006001600160a01b038416908102919091179091556040519081527f74a8764fc8d62d2d844c8c54426bd94ad034e0e92abdf5280ff75e2cbd678fb690602001611009565b6013602052600090815260409020805461121590613e47565b80601f016020809104026020016040519081016040528092919081815260200182805461124190613e47565b801561128e5780601f106112635761010080835404028352916020019161128e565b820191906000526020600020905b81548152906001019060200180831161127157829003601f168201915b505050505081565b6010602052600090815260409020805461121590613e47565b6112b7612de8565b6001600160a01b0384166112dd5760405162461bcd60e51b8152600401610ac190613d1e565b8015611314576001600160a01b038416600090815260106020526040902060608051909161130d916080906136cc565b5050611339565b6001600160a01b038416600090815260106020526040902061133790848461374c565b505b7fd3b7ee92d897f8cd1e3f97fea5e9af64ae3e6dbb89aec16c39e922958af0e4ef8484848460405161136e9493929190613b31565b60405180910390a150505050565b611384612de8565b6001600160a01b0381166113aa5760405162461bcd60e51b8152600401610ac190613d1e565b600880546001600160a01b0319166001600160a01b0383169081179091556040519081527fd2d21ca3f6860b1fb0c8a54f761f0cd731cdc2e66db8d850c25eabbbbab0411e90602001611009565b60008061140484612a58565b600f0b131561149457600b546000906001600160a01b03858116911614806114395750600c546001600160a01b038581169116145b6114435782611452565b61145264e8d4a5100084613de5565b9050670de0b6b3a764000061146685612abd565b61147890670de0b6b3a7640000613dad565b6114829083613de5565b61148c9190613dc5565b9150506115a1565b6009546001600160a01b038481166000908152601160205260408082205490516315905ec160e31b815260048101919091529092919091169063ac82f6089060240160206040518083038186803b1580156114ee57600080fd5b505afa158015611502573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115269190613a7f565b9050600081116115485760405162461bcd60e51b8152600401610ac190613ca5565b670de0b6b3a764000061155a85612abd565b61156c90670de0b6b3a7640000613dad565b670de0b6b3a764000061157f8487613de5565b6115899190613dc5565b6115939190613de5565b61159d9190613dc5565b9150505b6115aa81612e62565b9392505050565b6115b9612de8565b6001600160a01b0381166115df5760405162461bcd60e51b8152600401610ac190613d1e565b6001600160a01b0381166000818152601160209081526040918290208590558151858152908101929092527f8ca223f1e27a56a1e9f08d9b3c59f60de0598f93413be07e2580ef1a84e4818c91015b60405180910390a15050565b600054610100900460ff166116555760005460ff1615611659565b303b155b6116bc5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610ac1565b600054610100900460ff161580156116de576000805461ffff19166101011790555b6116e783610ed9565b6116ef612885565b60058054610100600160a81b0319166101006001600160a01b038516021790558015611721576000805461ff00191690555b505050565b600060016004600082825461173b9190613dad565b909155505060045460035460ff16156117665760405162461bcd60e51b8152600401610ac190613c48565b6001600160a01b03841660009081526006602052604090205460ff1661179e5760405162461bcd60e51b8152600401610ac190613ba7565b3360009081526007602052604090205460ff166117cd5760405162461bcd60e51b8152600401610ac190613c1c565b6005546117ea9061010090046001600160a01b0316333086612f01565b600d54600160a01b900460ff16801561183f5750600b546001600160a01b03858116911614806118275750600d546001600160a01b038581169116145b8061183f5750600c546001600160a01b038581169116145b156118555761184e8484612f3f565b9150611862565b61185f838561310f565b91505b6118766001600160a01b0385163384612d92565b7f959784334a6c68fffefe45835ca75cf1ce27c5fe9f0e424f81fefcd7663622d384846040516118a7929190613b7b565b60405180910390a160045481146118d05760405162461bcd60e51b8152600401610ac190613ce7565b5092915050565b6118df612de8565b6001600160a01b0381166119055760405162461bcd60e51b8152600401610ac190613d1e565b600a80546001600160a01b0319166001600160a01b0383169081179091556040519081527fe390bcec6614d6b1f8ae47a4d9d46531ce328e3d293ecd6ddd015cb01eff030090602001611009565b61195b612de8565b66470de4df8200008111156119b25760405162461bcd60e51b815260206004820152601a60248201527f43616e206e6f742073657420686967686572207468616e2032250000000000006044820152606401610ac1565b600e8190556040518181527f32266df6c6a587ffa9b674c3cba38c095d95f15cf737e81c544f426c9270517090602001611009565b6119ef612de8565b6001600160a01b038116611a155760405162461bcd60e51b8152600401610ac190613d1e565b600980546001600160a01b0319166001600160a01b0383169081179091556040519081527ff724a45d041687842411f2b977ef22ab8f43c8f1104f4592b42a00f9b34a643d90602001611009565b6001546001600160a01b03163314611adb5760405162461bcd60e51b815260206004820152603560248201527f596f75206d757374206265206e6f6d696e61746564206265666f726520796f7560448201527402063616e20616363657074206f776e65727368697605c1b6064820152608401610ac1565b60005460015460408051620100009093046001600160a01b03908116845290911660208301527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c910160405180910390a1600180546000805462010000600160b01b0319166001600160a01b03831662010000021790556001600160a01b0319169055565b6000611b6b826129b0565b91506000611b7884612a58565b600f0b1315611ba557670de0b6b3a7640000611b9384612abd565b6109b190670de0b6b3a7640000613dad565b6009546001600160a01b038481166000908152601160205260408082205490516315905ec160e31b815260048101919091529092919091169063ac82f6089060240160206040518083038186803b158015611bff57600080fd5b505afa158015611c13573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c379190613a7f565b905060008111611c595760405162461bcd60e51b8152600401610ac190613ca5565b670de0b6b3a7640000611c6b85612abd565b610aee90670de0b6b3a7640000613dad565b6000600160046000828254611c929190613dad565b909155505060045460035460ff1615611cbd5760405162461bcd60e51b8152600401610ac190613c48565b6001600160a01b03841660009081526006602052604090205460ff16611cf55760405162461bcd60e51b8152600401610ac190613ba7565b3360009081526007602052604090205460ff16611d245760405162461bcd60e51b8152600401610ac190613c1c565b611d396001600160a01b038516333086612f01565b600d54600160a01b900460ff168015611d8e5750600b546001600160a01b0385811691161480611d765750600d546001600160a01b038581169116145b80611d8e5750600c546001600160a01b038581169116145b15611da457611d9d848461335f565b9150611db1565b611dae8385612b25565b91505b600554611dcd9061010090046001600160a01b03163384612d92565b7f5853647b869c89b776cea981783043fb2c8d9f0f16d6596c592fe9c46d18bcf484846040516118a7929190613b7b565b611e06612de8565b6001600160a01b038216611e2c5760405162461bcd60e51b8152600401610ac190613d1e565b6001600160a01b038216600081815260076020908152604091829020805460ff19168515159081179091558251938452908301527f38c2fbcd5e86222b26aadd09cdf191ada1a02ecd24c0bad919cce414e83bce86910161162e565b6000600160046000828254611e9d9190613dad565b909155505060045460035460ff1615611ec85760405162461bcd60e51b8152600401610ac190613c48565b3360009081526007602052604090205460ff16611ef75760405162461bcd60e51b8152600401610ac190613c1c565b600554611f149061010090046001600160a01b0316333086612f01565b600a54611f2b9084906001600160a01b031661310f565b600a54604051632e1a7d4d60e01b8152600481018390529193506001600160a01b031690632e1a7d4d90602401600060405180830381600087803b158015611f7257600080fd5b505af1158015611f86573d6000803e3d6000fd5b50506040516000925033915084156108fc0290859084818181858888f19350505050905080611fee5760405162461bcd60e51b81526020600482015260146024820152732330b4b632b2103a379039b2b7321022ba3432b960611b6044820152606401610ac1565b6040518481527f06c33e95d844c66a239d77c9dde1638cf061853d0fb9b77624ba3930ea5e13409060200160405180910390a1506004548114610ed35760405162461bcd60e51b8152600401610ac190613ce7565b61204b612de8565b6001600160a01b0381166120935760405162461bcd60e51b815260206004820152600f60248201526e496e76616c6964206164647265737360881b6044820152606401610ac1565b600154600160a81b900460ff16156120e35760405162461bcd60e51b8152602060048201526013602482015272105b1c9958591e481d1c985b9cd9995c9c9959606a1b6044820152606401610ac1565b600080546001600160a01b038381166201000081810262010000600160b01b031990941693909317938490556001805460ff60a81b1916600160a81b1790556040805193909404909116825260208201527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c9101611009565b60006115aa8383611b60565b612170612de8565b6001600160a01b0384166121965760405162461bcd60e51b8152600401610ac190613d1e565b80156121cd576001600160a01b03841660009081526013602052604090206060805190916121c6916080906136cc565b50506121f2565b6001600160a01b03841660009081526013602052604090206121f090848461374c565b505b7fb3e563b89bf0a11edbcc16ff8d93058a89d8b9b250963ec2092cba251db7e80e8484848460405161136e9493929190613b31565b60008061223384612a58565b600f0b13156122a757600b546000906001600160a01b03858116911614806122685750600c546001600160a01b038581169116145b6122725782612281565b61228164e8d4a5100084613de5565b9050670de0b6b3a764000061229585612abd565b61147890670de0b6b3a7640000613e04565b6009546001600160a01b038481166000908152601160205260408082205490516315905ec160e31b815260048101919091529092919091169063ac82f6089060240160206040518083038186803b15801561230157600080fd5b505afa158015612315573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123399190613a7f565b90506000811161235b5760405162461bcd60e51b8152600401610ac190613ca5565b670de0b6b3a764000061236d85612abd565b61156c90670de0b6b3a7640000613e04565b612387612de8565b81158061239c57506001600160a01b03861615155b6123b85760405162461bcd60e51b8152600401610ac190613d1e565b600f546001600160a01b03161561259d57600d546001600160a01b03161561246557600d54600f5460405163095ea7b360e01b81526001600160a01b039283169263095ea7b39261241192911690600090600401613b7b565b602060405180830381600087803b15801561242b57600080fd5b505af115801561243f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124639190613a27565b505b600b546001600160a01b03161561250157600b54600f5460405163095ea7b360e01b81526001600160a01b039283169263095ea7b3926124ad92911690600090600401613b7b565b602060405180830381600087803b1580156124c757600080fd5b505af11580156124db573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124ff9190613a27565b505b600c546001600160a01b03161561259d57600c54600f5460405163095ea7b360e01b81526001600160a01b039283169263095ea7b39261254992911690600090600401613b7b565b602060405180830381600087803b15801561256357600080fd5b505af1158015612577573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061259b9190613a27565b505b600f80546001600160a01b038089166001600160a01b031992831617909255600d80548884169083168117909155600b8054888516908416179055600c80549387169390921692909217905560405163095ea7b360e01b815263095ea7b39061260e90899060001990600401613b7b565b602060405180830381600087803b15801561262857600080fd5b505af115801561263c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126609190613a27565b50600b5460405163095ea7b360e01b81526001600160a01b039091169063095ea7b39061269590899060001990600401613b7b565b602060405180830381600087803b1580156126af57600080fd5b505af11580156126c3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126e79190613a27565b50600c5460405163095ea7b360e01b81526001600160a01b039091169063095ea7b39061271c90899060001990600401613b7b565b602060405180830381600087803b15801561273657600080fd5b505af115801561274a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061276e9190613a27565b50600d8054831515600160a01b810260ff60a01b1990921691909117909155600e829055604080516001600160a01b03898116825288811660208301528781168284015286166060820152608081019290925260a08201839052517fa4db60d8d97ea35442f00dd184c71f951541462f55930f217cd83ae236ec74ab9181900360c00190a1505050505050565b612803612de8565b6001600160a01b0382166128295760405162461bcd60e51b8152600401610ac190613d1e565b6001600160a01b038216600081815260066020908152604091829020805460ff19168515159081179091558251938452908301527f5224b67e466b1ae7b3e4397bec3663e69813fca9262c30a6c7594b92badaf041910161162e565b60055460ff16156128ce5760405162461bcd60e51b8152602060048201526013602482015272105b1c9958591e481a5b9a5d1a585b1a5e9959606a1b6044820152606401610ac1565b6005805460ff19166001908117909155600455565b6128eb612de8565b6001600160a01b0382166129115760405162461bcd60e51b8152600401610ac190613d1e565b600e548111156129635760405162461bcd60e51b815260206004820152601f60248201527f43616e206e6f742073657420686967686572207468616e2064656661756c74006044820152606401610ac1565b6001600160a01b03821660009081526014602052604090819020829055517fbecbc03040bc790a255d073a8a8b65af77277f1f0d20ae79890613a98e5508729061162e9084908490613b7b565b6000600560019054906101000a90046001600160a01b03166001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b158015612a0057600080fd5b505afa158015612a14573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a389190613a7f565b60061415612a4f57610b238264e8d4a51000613de5565b5090565b919050565b600d546000906001600160a01b0383811691161415612a7957506001919050565b600b546001600160a01b0383811691161415612a9757506002919050565b600c546001600160a01b0383811691161415612ab557506003919050565b506000919050565b6001600160a01b03811660009081526014602052604081205415801590612afd5750600e546001600160a01b038316600090815260146020526040902054105b612b0957600e54610b23565b506001600160a01b031660009081526014602052604090205490565b60085460405163095ea7b360e01b81526000916001600160a01b038085169263095ea7b392612b5a9216908790600401613b7b565b602060405180830381600087803b158015612b7457600080fd5b505af1158015612b88573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612bac9190613a27565b506001600160a01b03821660009081526010602052604081208054612bd090613e47565b80601f0160208091040260200160405190810160405280929190818152602001828054612bfc90613e47565b8015612c495780601f10612c1e57610100808354040283529160200191612c49565b820191906000526020600020905b815481529060010190602001808311612c2c57829003601f168201915b50505050509050805160001415612ca257600a54600554604051610bb892612c8f92879285926001600160a01b0390811692849261010090910490911690602001613ac3565b6040516020818303038152906040529150505b6040805160a0810182528281523060208201526000918101612cc542600f613dad565b8152602001868152602001612cda8688612227565b905260085460405163c04b8d5960e01b81529192506001600160a01b03169063c04b8d5990612d0d908490600401613d55565b602060405180830381600087803b158015612d2757600080fd5b505af1158015612d3b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d5f9190613a7f565b9250612d6b84866113f8565b831115612d8a5760405162461bcd60e51b8152600401610ac190613bd7565b505092915050565b6117218363a9059cbb60e01b8484604051602401612db1929190613b7b565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152613482565b6000546201000090046001600160a01b03163314612e605760405162461bcd60e51b815260206004820152602f60248201527f4f6e6c792074686520636f6e7472616374206f776e6572206d6179207065726660448201526e37b936903a3434b99030b1ba34b7b760891b6064820152608401610ac1565b565b6000600560019054906101000a90046001600160a01b03166001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b158015612eb257600080fd5b505afa158015612ec6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612eea9190613a7f565b60061415612a4f57610b2364e8d4a5100083613dc5565b6040516001600160a01b0380851660248301528316604482015260648101829052612f399085906323b872dd60e01b90608401612db1565b50505050565b600080612f4b84612a58565b9050600081600f0b138015612f695750600d54600160a01b900460ff165b612fae5760405162461bcd60e51b81526020600482015260166024820152751d5b9cdd5c1c1bdc9d19590818dbdb1b185d195c985b60521b6044820152606401610ac1565b600554600f5460405163095ea7b360e01b81526001600160a01b0361010090930483169263095ea7b392612fe9929116908790600401613b7b565b602060405180830381600087803b15801561300357600080fd5b505af1158015613017573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061303b9190613a27565b50600f546001600160a01b031663a6417ed66000838661305b898261096c565b6040516001600160e01b031960e087901b168152600f94850b60048201529290930b602483015260448201526064810191909152608401602060405180830381600087803b1580156130ac57600080fd5b505af11580156130c0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130e49190613a7f565b91506130f0848461215c565b8211156118d05760405162461bcd60e51b8152600401610ac190613bd7565b60055460085460405163095ea7b360e01b815260009261010090046001600160a01b039081169263095ea7b39261314e92909116908790600401613b7b565b602060405180830381600087803b15801561316857600080fd5b505af115801561317c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131a09190613a27565b506001600160a01b038216600090815260136020526040812080546131c490613e47565b80601f01602080910402602001604051908101604052809291908181526020018280546131f090613e47565b801561323d5780601f106132125761010080835404028352916020019161323d565b820191906000526020600020905b81548152906001019060200180831161322057829003601f168201915b5050505050905080516000141561329657600554600a54604051610bb892613283926001600160a01b036101009092048216928592919091169082908990602001613ac3565b6040516020818303038152906040529150505b6040805160a08101825282815230602082015260009181016132b942600f613dad565b81526020018681526020016132ce868861096c565b905260085460405163c04b8d5960e01b81529192506001600160a01b03169063c04b8d5990613301908490600401613d55565b602060405180830381600087803b15801561331b57600080fd5b505af115801561332f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133539190613a7f565b9250612d6b848661215c565b60008061336b84612a58565b9050600081600f0b1380156133895750600d54600160a01b900460ff165b6133ce5760405162461bcd60e51b81526020600482015260166024820152751d5b9cdd5c1c1bdc9d19590818dbdb1b185d195c985b60521b6044820152606401610ac1565b600f546001600160a01b031663a6417ed6826000866133ed8982612227565b6040516001600160e01b031960e087901b168152600f94850b60048201529290930b602483015260448201526064810191909152608401602060405180830381600087803b15801561343e57600080fd5b505af1158015613452573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134769190613a7f565b91506130f084846113f8565b60006134d7826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166135549092919063ffffffff16565b80519091501561172157808060200190518101906134f59190613a27565b6117215760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610ac1565b6060613563848460008561356b565b949350505050565b6060824710156135cc5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610ac1565b843b61361a5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610ac1565b600080866001600160a01b031685876040516136369190613b15565b60006040518083038185875af1925050503d8060008114613673576040519150601f19603f3d011682016040523d82523d6000602084013e613678565b606091505b5091509150613688828286613693565b979650505050505050565b606083156136a25750816115aa565b8251156136b25782518084602001fd5b8160405162461bcd60e51b8152600401610ac19190613b94565b8280546136d890613e47565b90600052602060002090601f0160209004810192826136fa5760008555613740565b82601f1061371357805160ff1916838001178555613740565b82800160010185558215613740579182015b82811115613740578251825591602001919060010190613725565b50612a4f9291506137c0565b82805461375890613e47565b90600052602060002090601f01602090048101928261377a5760008555613740565b82601f106137935782800160ff19823516178555613740565b82800160010185558215613740579182015b828111156137405782358255916020019190600101906137a5565b5b80821115612a4f57600081556001016137c1565b803562ffffff81168114612a5357600080fd5b6000602082840312156137f9578081fd5b81356115aa81613e92565b60008060008060008060c0878903121561381c578182fd5b863561382781613e92565b9550602087013561383781613e92565b9450604087013561384781613e92565b9350606087013561385781613e92565b9250608087013561386781613ea7565b8092505060a087013590509295509295509295565b6000806040838503121561388e578182fd5b823561389981613e92565b915060208301356138a981613ea7565b809150509250929050565b600080600080606085870312156138c9578384fd5b84356138d481613e92565b9350602085013567ffffffffffffffff808211156138f0578485fd5b818701915087601f830112613903578485fd5b813581811115613911578586fd5b886020828501011115613922578586fd5b602083019550809450505050604085013561393c81613ea7565b939692955090935050565b60008060408385031215613959578182fd5b823561396481613e92565b915060208301356138a981613e92565b600080600080600060a0868803121561398b578081fd5b853561399681613e92565b94506139a4602087016137d5565b935060408601356139b481613e92565b92506139c2606087016137d5565b915060808601356139d281613e92565b809150509295509295909350565b600080604083850312156139f2578182fd5b82356139fd81613e92565b946020939093013593505050565b600060208284031215613a1c578081fd5b81356115aa81613ea7565b600060208284031215613a38578081fd5b81516115aa81613ea7565b60008060408385031215613a55578182fd5b8235915060208301356138a981613e92565b600060208284031215613a78578081fd5b5035919050565b600060208284031215613a90578081fd5b5051919050565b60008151808452613aaf816020860160208601613e1b565b601f01601f19169290920160200192915050565b6bffffffffffffffffffffffff19606096871b811682526001600160e81b031960e896871b8116601484015294871b811660178301529290941b909216602b840152921b909116602e82015260420190565b60008251613b27818460208701613e1b565b9190910192915050565b6001600160a01b038516815260606020820181905281018390528284608083013760008184016080908101919091529115156040820152601f909201601f19169091010192915050565b6001600160a01b03929092168252602082015260400190565b6020815260006115aa6020830184613a97565b602080825260169082015275155b9cdd5c1c1bdc9d19590818dbdb1b185d195c985b60521b604082015260600190565b60208082526025908201527f416d6f756e742061626f7665206d617820616c6c6f7765642070656720736c69604082015264707061676560d81b606082015260800190565b6020808252601290820152712ab739bab83837b93a32b21031b0b63632b960711b604082015260600190565b6020808252603c908201527f5468697320616374696f6e2063616e6e6f7420626520706572666f726d65642060408201527f7768696c652074686520636f6e74726163742069732070617573656400000000606082015260800190565b60208082526022908201527f6e6f20707269636520617661696c61626c652066726f6d207072696365206665604082015261195960f21b606082015260800190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b6020808252601b908201527f43616e206e6f74207365742061207a65726f2061646472657373210000000000604082015260600190565b602081526000825160a06020840152613d7160c0840182613a97565b905060018060a01b0360208501511660408401526040840151606084015260608401516080840152608084015160a08401528091505092915050565b60008219821115613dc057613dc0613e7c565b500190565b600082613de057634e487b7160e01b81526012600452602481fd5b500490565b6000816000190483118215151615613dff57613dff613e7c565b500290565b600082821015613e1657613e16613e7c565b500390565b60005b83811015613e36578181015183820152602001613e1e565b83811115612f395750506000910152565b600181811c90821680613e5b57607f821691505b60208210811415610ed357634e487b7160e01b600052602260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b6001600160a01b03811681146110dd57600080fd5b80151581146110dd57600080fdfea2646970667358221220f4b01a8838fc906bca783958f8575d8c1c7cf5fdcc97d38b6cd682fa820dfe0764736f6c63430008040033

Deployed Bytecode

0x6080604052600436106102cd5760003560e01c80635c975abb11610175578063a5bf660d116100dc578063c4ebcb5411610095578063da6070251161006f578063da607025146108f7578063ebc7977214610917578063f4b9fa751461092c578063f5866a461461094c57600080fd5b8063c4ebcb5414610897578063cb4ba524146108b7578063d3c4297c146108d757600080fd5b8063a5bf660d146107c7578063b45e98d9146107e7578063b98b63f814610807578063c31c9c0714610837578063c3b83f5f14610857578063c42f4c8b1461087757600080fd5b80638826e5de1161012e5780638826e5de146107065780638b3ac44c146107265780638da5cb5b1461074657806391b4ded91461076c5780639324cac714610782578063953caf51146107a757600080fd5b80635c975abb1461063d578063724e78da14610657578063741bef1a1461067757806379ba5097146106975780637d904d3a146106ac57806382e76c36146106d957600080fd5b80632f48ab7d11610234578063481c6a75116101ed5780634c932368116101c75780634c932368146105bd57806353a47bb7146105dd5780635b769f3c146105fd5780635c5189bb1461061d57600080fd5b8063481c6a751461055d578063485cc9551461057d5780634aa4a4fc1461059d57600080fd5b80632f48ab7d1461048557806338053078146104bd5780633e413bee146104dd57806341273657146104fd578063420a038c1461051d578063477bf5a51461053d57600080fd5b80631fbb38e8116102865780631fbb38e8146103ae57806321ef44c6146103df5780632213af25146103ff57806322bdb38c1461041f5780632909f51a1461043f5780632ab8de381461045557600080fd5b80630d9393cf146102d95780631321b85d1461030c57806313af40351461031f5780631627540c1461034157806316c38b3c14610361578063178b8ac81461038157600080fd5b366102d457005b600080fd5b3480156102e557600080fd5b506102f96102f43660046139e0565b61096c565b6040519081526020015b60405180910390f35b6102f961031a366004613a67565b610b29565b34801561032b57600080fd5b5061033f61033a3660046137e8565b610ed9565b005b34801561034d57600080fd5b5061033f61035c3660046137e8565b611014565b34801561036d57600080fd5b5061033f61037c366004613a0b565b61106a565b34801561038d57600080fd5b506103a161039c366004613974565b6110e0565b6040516103039190613b94565b3480156103ba57600080fd5b50600d546103cf90600160a01b900460ff1681565b6040519015158152602001610303565b3480156103eb57600080fd5b5061033f6103fa3660046137e8565b611178565b34801561040b57600080fd5b506103a161041a3660046137e8565b6111fc565b34801561042b57600080fd5b506103a161043a3660046137e8565b611296565b34801561044b57600080fd5b506102f9600e5481565b34801561046157600080fd5b506103cf6104703660046137e8565b60066020526000908152604090205460ff1681565b34801561049157600080fd5b50600c546104a5906001600160a01b031681565b6040516001600160a01b039091168152602001610303565b3480156104c957600080fd5b5061033f6104d83660046138b4565b6112af565b3480156104e957600080fd5b50600b546104a5906001600160a01b031681565b34801561050957600080fd5b5061033f6105183660046137e8565b61137c565b34801561052957600080fd5b506102f96105383660046139e0565b6113f8565b34801561054957600080fd5b5061033f610558366004613a43565b6115b1565b34801561056957600080fd5b506012546104a5906001600160a01b031681565b34801561058957600080fd5b5061033f610598366004613947565b61163a565b3480156105a957600080fd5b50600a546104a5906001600160a01b031681565b3480156105c957600080fd5b506102f96105d83660046139e0565b611726565b3480156105e957600080fd5b506001546104a5906001600160a01b031681565b34801561060957600080fd5b5061033f6106183660046137e8565b6118d7565b34801561062957600080fd5b5061033f610638366004613a67565b611953565b34801561064957600080fd5b506003546103cf9060ff1681565b34801561066357600080fd5b5061033f6106723660046137e8565b6119e7565b34801561068357600080fd5b506009546104a5906001600160a01b031681565b3480156106a357600080fd5b5061033f611a63565b3480156106b857600080fd5b506102f96106c73660046137e8565b60146020526000908152604090205481565b3480156106e557600080fd5b506102f96106f43660046137e8565b60116020526000908152604090205481565b34801561071257600080fd5b506102f96107213660046139e0565b611b60565b34801561073257600080fd5b506102f96107413660046139e0565b611c7d565b34801561075257600080fd5b506000546104a5906201000090046001600160a01b031681565b34801561077857600080fd5b506102f960025481565b34801561078e57600080fd5b506005546104a59061010090046001600160a01b031681565b3480156107b357600080fd5b5061033f6107c236600461387c565b611dfe565b3480156107d357600080fd5b50600f546104a5906001600160a01b031681565b3480156107f357600080fd5b506102f9610802366004613a67565b611e88565b34801561081357600080fd5b506103cf6108223660046137e8565b60076020526000908152604090205460ff1681565b34801561084357600080fd5b506008546104a5906001600160a01b031681565b34801561086357600080fd5b5061033f6108723660046137e8565b612043565b34801561088357600080fd5b506102f96108923660046139e0565b61215c565b3480156108a357600080fd5b5061033f6108b23660046138b4565b612168565b3480156108c357600080fd5b506102f96108d23660046139e0565b612227565b3480156108e357600080fd5b5061033f6108f2366004613804565b61237f565b34801561090357600080fd5b5061033f61091236600461387c565b6127fb565b34801561092357600080fd5b5061033f612885565b34801561093857600080fd5b50600d546104a5906001600160a01b031681565b34801561095857600080fd5b5061033f6109673660046139e0565b6128e3565b6000610977826129b0565b9150600061098484612a58565b600f0b1315610a0d57670de0b6b3a764000061099f84612abd565b6109b190670de0b6b3a7640000613e04565b6109bb9084613de5565b6109c59190613dc5565b600b549091506001600160a01b03848116911614806109f15750600c546001600160a01b038481169116145b15610a0857610a0564e8d4a5100082613dc5565b90505b610b23565b6009546001600160a01b038481166000908152601160205260408082205490516315905ec160e31b815260048101919091529092919091169063ac82f6089060240160206040518083038186803b158015610a6757600080fd5b505afa158015610a7b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a9f9190613a7f565b905060008111610aca5760405162461bcd60e51b8152600401610ac190613ca5565b60405180910390fd5b670de0b6b3a7640000610adc85612abd565b610aee90670de0b6b3a7640000613e04565b82610b01670de0b6b3a764000087613de5565b610b0b9190613dc5565b610b159190613de5565b610b1f9190613dc5565b9150505b92915050565b6000600160046000828254610b3e9190613dad565b909155505060045460035460ff1615610b695760405162461bcd60e51b8152600401610ac190613c48565b600a546001600160a01b031660009081526006602052604090205460ff16610ba35760405162461bcd60e51b8152600401610ac190613ba7565b3360009081526007602052604090205460ff16610bd25760405162461bcd60e51b8152600401610ac190613c1c565b60008311610c1b5760405162461bcd60e51b8152602060048201526016602482015275086c2dc40dcdee840caf0c6d0c2dcceca4060408aa8960531b6044820152606401610ac1565b823414610c855760405162461bcd60e51b815260206004820152603260248201527f416d6f756e74204554482068617320746f20626520657175616c20746f20746860448201527119481cdc1958da599a595908185b5bdd5b9d60721b6064820152608401610ac1565b600a546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a082319060240160206040518083038186803b158015610cc957600080fd5b505afa158015610cdd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d019190613a7f565b9050600a60009054906101000a90046001600160a01b03166001600160a01b031663d0e30db0856040518263ffffffff1660e01b81526004016000604051808303818588803b158015610d5357600080fd5b505af1158015610d67573d6000803e3d6000fd5b5050600a546040516370a0823160e01b8152306004820152600094508593506001600160a01b0390911691506370a082319060240160206040518083038186803b158015610db457600080fd5b505afa158015610dc8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dec9190613a7f565b610df69190613e04565b9050848114610e475760405162461bcd60e51b815260206004820152601860248201527f4e6f7420656e6f756768205745544820726563656976656400000000000000006044820152606401610ac1565b600a54610e5e9086906001600160a01b0316612b25565b600554909450610e7d9061010090046001600160a01b03163386612d92565b6040518581527f1d21653337ffd9933b1202c6f3c39cd605ff6743734277eb4e927881358330ca9060200160405180910390a150506004548114610ed35760405162461bcd60e51b8152600401610ac190613ce7565b50919050565b6001600160a01b038116610f2f5760405162461bcd60e51b815260206004820152601960248201527f4f776e657220616464726573732063616e6e6f742062652030000000000000006044820152606401610ac1565b600154600160a01b900460ff1615610f9b5760405162461bcd60e51b815260206004820152602960248201527f416c726561647920696e697469616c697a65642c20757365206e6f6d696e617460448201526832a732bba7bbb732b960b91b6064820152608401610ac1565b6001805460ff60a01b1916600160a01b179055600080546001600160a01b03831662010000810262010000600160b01b03199092169190911782556040805192835260208301919091527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c91015b60405180910390a150565b61101c612de8565b600180546001600160a01b0319166001600160a01b0383169081179091556040519081527f906a1c6bd7e3091ea86693dd029a831c19049ce77f1dce2ce0bab1cacbabce2290602001611009565b611072612de8565b60035460ff16151581151514156110865750565b6003805460ff191682151590811790915560ff16156110a457426002555b60035460405160ff909116151581527f8fb6c181ee25a520cf3dd6565006ef91229fcfe5a989566c2a3b8c115570cec590602001611009565b50565b60606001600160a01b0384161561112057858585858560405160200161110a959493929190613ac3565b604051602081830303815290604052905061116f565b6040516bffffffffffffffffffffffff19606088811b821660208401526001600160e81b031960e887901b16603484015284901b166037820152604b0160405160208183030381529060405290505b95945050505050565b611180612de8565b6001600160a01b0381166111a65760405162461bcd60e51b8152600401610ac190613d1e565b60058054610100600160a81b0319166101006001600160a01b038416908102919091179091556040519081527f74a8764fc8d62d2d844c8c54426bd94ad034e0e92abdf5280ff75e2cbd678fb690602001611009565b6013602052600090815260409020805461121590613e47565b80601f016020809104026020016040519081016040528092919081815260200182805461124190613e47565b801561128e5780601f106112635761010080835404028352916020019161128e565b820191906000526020600020905b81548152906001019060200180831161127157829003601f168201915b505050505081565b6010602052600090815260409020805461121590613e47565b6112b7612de8565b6001600160a01b0384166112dd5760405162461bcd60e51b8152600401610ac190613d1e565b8015611314576001600160a01b038416600090815260106020526040902060608051909161130d916080906136cc565b5050611339565b6001600160a01b038416600090815260106020526040902061133790848461374c565b505b7fd3b7ee92d897f8cd1e3f97fea5e9af64ae3e6dbb89aec16c39e922958af0e4ef8484848460405161136e9493929190613b31565b60405180910390a150505050565b611384612de8565b6001600160a01b0381166113aa5760405162461bcd60e51b8152600401610ac190613d1e565b600880546001600160a01b0319166001600160a01b0383169081179091556040519081527fd2d21ca3f6860b1fb0c8a54f761f0cd731cdc2e66db8d850c25eabbbbab0411e90602001611009565b60008061140484612a58565b600f0b131561149457600b546000906001600160a01b03858116911614806114395750600c546001600160a01b038581169116145b6114435782611452565b61145264e8d4a5100084613de5565b9050670de0b6b3a764000061146685612abd565b61147890670de0b6b3a7640000613dad565b6114829083613de5565b61148c9190613dc5565b9150506115a1565b6009546001600160a01b038481166000908152601160205260408082205490516315905ec160e31b815260048101919091529092919091169063ac82f6089060240160206040518083038186803b1580156114ee57600080fd5b505afa158015611502573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115269190613a7f565b9050600081116115485760405162461bcd60e51b8152600401610ac190613ca5565b670de0b6b3a764000061155a85612abd565b61156c90670de0b6b3a7640000613dad565b670de0b6b3a764000061157f8487613de5565b6115899190613dc5565b6115939190613de5565b61159d9190613dc5565b9150505b6115aa81612e62565b9392505050565b6115b9612de8565b6001600160a01b0381166115df5760405162461bcd60e51b8152600401610ac190613d1e565b6001600160a01b0381166000818152601160209081526040918290208590558151858152908101929092527f8ca223f1e27a56a1e9f08d9b3c59f60de0598f93413be07e2580ef1a84e4818c91015b60405180910390a15050565b600054610100900460ff166116555760005460ff1615611659565b303b155b6116bc5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610ac1565b600054610100900460ff161580156116de576000805461ffff19166101011790555b6116e783610ed9565b6116ef612885565b60058054610100600160a81b0319166101006001600160a01b038516021790558015611721576000805461ff00191690555b505050565b600060016004600082825461173b9190613dad565b909155505060045460035460ff16156117665760405162461bcd60e51b8152600401610ac190613c48565b6001600160a01b03841660009081526006602052604090205460ff1661179e5760405162461bcd60e51b8152600401610ac190613ba7565b3360009081526007602052604090205460ff166117cd5760405162461bcd60e51b8152600401610ac190613c1c565b6005546117ea9061010090046001600160a01b0316333086612f01565b600d54600160a01b900460ff16801561183f5750600b546001600160a01b03858116911614806118275750600d546001600160a01b038581169116145b8061183f5750600c546001600160a01b038581169116145b156118555761184e8484612f3f565b9150611862565b61185f838561310f565b91505b6118766001600160a01b0385163384612d92565b7f959784334a6c68fffefe45835ca75cf1ce27c5fe9f0e424f81fefcd7663622d384846040516118a7929190613b7b565b60405180910390a160045481146118d05760405162461bcd60e51b8152600401610ac190613ce7565b5092915050565b6118df612de8565b6001600160a01b0381166119055760405162461bcd60e51b8152600401610ac190613d1e565b600a80546001600160a01b0319166001600160a01b0383169081179091556040519081527fe390bcec6614d6b1f8ae47a4d9d46531ce328e3d293ecd6ddd015cb01eff030090602001611009565b61195b612de8565b66470de4df8200008111156119b25760405162461bcd60e51b815260206004820152601a60248201527f43616e206e6f742073657420686967686572207468616e2032250000000000006044820152606401610ac1565b600e8190556040518181527f32266df6c6a587ffa9b674c3cba38c095d95f15cf737e81c544f426c9270517090602001611009565b6119ef612de8565b6001600160a01b038116611a155760405162461bcd60e51b8152600401610ac190613d1e565b600980546001600160a01b0319166001600160a01b0383169081179091556040519081527ff724a45d041687842411f2b977ef22ab8f43c8f1104f4592b42a00f9b34a643d90602001611009565b6001546001600160a01b03163314611adb5760405162461bcd60e51b815260206004820152603560248201527f596f75206d757374206265206e6f6d696e61746564206265666f726520796f7560448201527402063616e20616363657074206f776e65727368697605c1b6064820152608401610ac1565b60005460015460408051620100009093046001600160a01b03908116845290911660208301527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c910160405180910390a1600180546000805462010000600160b01b0319166001600160a01b03831662010000021790556001600160a01b0319169055565b6000611b6b826129b0565b91506000611b7884612a58565b600f0b1315611ba557670de0b6b3a7640000611b9384612abd565b6109b190670de0b6b3a7640000613dad565b6009546001600160a01b038481166000908152601160205260408082205490516315905ec160e31b815260048101919091529092919091169063ac82f6089060240160206040518083038186803b158015611bff57600080fd5b505afa158015611c13573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c379190613a7f565b905060008111611c595760405162461bcd60e51b8152600401610ac190613ca5565b670de0b6b3a7640000611c6b85612abd565b610aee90670de0b6b3a7640000613dad565b6000600160046000828254611c929190613dad565b909155505060045460035460ff1615611cbd5760405162461bcd60e51b8152600401610ac190613c48565b6001600160a01b03841660009081526006602052604090205460ff16611cf55760405162461bcd60e51b8152600401610ac190613ba7565b3360009081526007602052604090205460ff16611d245760405162461bcd60e51b8152600401610ac190613c1c565b611d396001600160a01b038516333086612f01565b600d54600160a01b900460ff168015611d8e5750600b546001600160a01b0385811691161480611d765750600d546001600160a01b038581169116145b80611d8e5750600c546001600160a01b038581169116145b15611da457611d9d848461335f565b9150611db1565b611dae8385612b25565b91505b600554611dcd9061010090046001600160a01b03163384612d92565b7f5853647b869c89b776cea981783043fb2c8d9f0f16d6596c592fe9c46d18bcf484846040516118a7929190613b7b565b611e06612de8565b6001600160a01b038216611e2c5760405162461bcd60e51b8152600401610ac190613d1e565b6001600160a01b038216600081815260076020908152604091829020805460ff19168515159081179091558251938452908301527f38c2fbcd5e86222b26aadd09cdf191ada1a02ecd24c0bad919cce414e83bce86910161162e565b6000600160046000828254611e9d9190613dad565b909155505060045460035460ff1615611ec85760405162461bcd60e51b8152600401610ac190613c48565b3360009081526007602052604090205460ff16611ef75760405162461bcd60e51b8152600401610ac190613c1c565b600554611f149061010090046001600160a01b0316333086612f01565b600a54611f2b9084906001600160a01b031661310f565b600a54604051632e1a7d4d60e01b8152600481018390529193506001600160a01b031690632e1a7d4d90602401600060405180830381600087803b158015611f7257600080fd5b505af1158015611f86573d6000803e3d6000fd5b50506040516000925033915084156108fc0290859084818181858888f19350505050905080611fee5760405162461bcd60e51b81526020600482015260146024820152732330b4b632b2103a379039b2b7321022ba3432b960611b6044820152606401610ac1565b6040518481527f06c33e95d844c66a239d77c9dde1638cf061853d0fb9b77624ba3930ea5e13409060200160405180910390a1506004548114610ed35760405162461bcd60e51b8152600401610ac190613ce7565b61204b612de8565b6001600160a01b0381166120935760405162461bcd60e51b815260206004820152600f60248201526e496e76616c6964206164647265737360881b6044820152606401610ac1565b600154600160a81b900460ff16156120e35760405162461bcd60e51b8152602060048201526013602482015272105b1c9958591e481d1c985b9cd9995c9c9959606a1b6044820152606401610ac1565b600080546001600160a01b038381166201000081810262010000600160b01b031990941693909317938490556001805460ff60a81b1916600160a81b1790556040805193909404909116825260208201527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c9101611009565b60006115aa8383611b60565b612170612de8565b6001600160a01b0384166121965760405162461bcd60e51b8152600401610ac190613d1e565b80156121cd576001600160a01b03841660009081526013602052604090206060805190916121c6916080906136cc565b50506121f2565b6001600160a01b03841660009081526013602052604090206121f090848461374c565b505b7fb3e563b89bf0a11edbcc16ff8d93058a89d8b9b250963ec2092cba251db7e80e8484848460405161136e9493929190613b31565b60008061223384612a58565b600f0b13156122a757600b546000906001600160a01b03858116911614806122685750600c546001600160a01b038581169116145b6122725782612281565b61228164e8d4a5100084613de5565b9050670de0b6b3a764000061229585612abd565b61147890670de0b6b3a7640000613e04565b6009546001600160a01b038481166000908152601160205260408082205490516315905ec160e31b815260048101919091529092919091169063ac82f6089060240160206040518083038186803b15801561230157600080fd5b505afa158015612315573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123399190613a7f565b90506000811161235b5760405162461bcd60e51b8152600401610ac190613ca5565b670de0b6b3a764000061236d85612abd565b61156c90670de0b6b3a7640000613e04565b612387612de8565b81158061239c57506001600160a01b03861615155b6123b85760405162461bcd60e51b8152600401610ac190613d1e565b600f546001600160a01b03161561259d57600d546001600160a01b03161561246557600d54600f5460405163095ea7b360e01b81526001600160a01b039283169263095ea7b39261241192911690600090600401613b7b565b602060405180830381600087803b15801561242b57600080fd5b505af115801561243f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124639190613a27565b505b600b546001600160a01b03161561250157600b54600f5460405163095ea7b360e01b81526001600160a01b039283169263095ea7b3926124ad92911690600090600401613b7b565b602060405180830381600087803b1580156124c757600080fd5b505af11580156124db573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124ff9190613a27565b505b600c546001600160a01b03161561259d57600c54600f5460405163095ea7b360e01b81526001600160a01b039283169263095ea7b39261254992911690600090600401613b7b565b602060405180830381600087803b15801561256357600080fd5b505af1158015612577573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061259b9190613a27565b505b600f80546001600160a01b038089166001600160a01b031992831617909255600d80548884169083168117909155600b8054888516908416179055600c80549387169390921692909217905560405163095ea7b360e01b815263095ea7b39061260e90899060001990600401613b7b565b602060405180830381600087803b15801561262857600080fd5b505af115801561263c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126609190613a27565b50600b5460405163095ea7b360e01b81526001600160a01b039091169063095ea7b39061269590899060001990600401613b7b565b602060405180830381600087803b1580156126af57600080fd5b505af11580156126c3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126e79190613a27565b50600c5460405163095ea7b360e01b81526001600160a01b039091169063095ea7b39061271c90899060001990600401613b7b565b602060405180830381600087803b15801561273657600080fd5b505af115801561274a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061276e9190613a27565b50600d8054831515600160a01b810260ff60a01b1990921691909117909155600e829055604080516001600160a01b03898116825288811660208301528781168284015286166060820152608081019290925260a08201839052517fa4db60d8d97ea35442f00dd184c71f951541462f55930f217cd83ae236ec74ab9181900360c00190a1505050505050565b612803612de8565b6001600160a01b0382166128295760405162461bcd60e51b8152600401610ac190613d1e565b6001600160a01b038216600081815260066020908152604091829020805460ff19168515159081179091558251938452908301527f5224b67e466b1ae7b3e4397bec3663e69813fca9262c30a6c7594b92badaf041910161162e565b60055460ff16156128ce5760405162461bcd60e51b8152602060048201526013602482015272105b1c9958591e481a5b9a5d1a585b1a5e9959606a1b6044820152606401610ac1565b6005805460ff19166001908117909155600455565b6128eb612de8565b6001600160a01b0382166129115760405162461bcd60e51b8152600401610ac190613d1e565b600e548111156129635760405162461bcd60e51b815260206004820152601f60248201527f43616e206e6f742073657420686967686572207468616e2064656661756c74006044820152606401610ac1565b6001600160a01b03821660009081526014602052604090819020829055517fbecbc03040bc790a255d073a8a8b65af77277f1f0d20ae79890613a98e5508729061162e9084908490613b7b565b6000600560019054906101000a90046001600160a01b03166001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b158015612a0057600080fd5b505afa158015612a14573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a389190613a7f565b60061415612a4f57610b238264e8d4a51000613de5565b5090565b919050565b600d546000906001600160a01b0383811691161415612a7957506001919050565b600b546001600160a01b0383811691161415612a9757506002919050565b600c546001600160a01b0383811691161415612ab557506003919050565b506000919050565b6001600160a01b03811660009081526014602052604081205415801590612afd5750600e546001600160a01b038316600090815260146020526040902054105b612b0957600e54610b23565b506001600160a01b031660009081526014602052604090205490565b60085460405163095ea7b360e01b81526000916001600160a01b038085169263095ea7b392612b5a9216908790600401613b7b565b602060405180830381600087803b158015612b7457600080fd5b505af1158015612b88573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612bac9190613a27565b506001600160a01b03821660009081526010602052604081208054612bd090613e47565b80601f0160208091040260200160405190810160405280929190818152602001828054612bfc90613e47565b8015612c495780601f10612c1e57610100808354040283529160200191612c49565b820191906000526020600020905b815481529060010190602001808311612c2c57829003601f168201915b50505050509050805160001415612ca257600a54600554604051610bb892612c8f92879285926001600160a01b0390811692849261010090910490911690602001613ac3565b6040516020818303038152906040529150505b6040805160a0810182528281523060208201526000918101612cc542600f613dad565b8152602001868152602001612cda8688612227565b905260085460405163c04b8d5960e01b81529192506001600160a01b03169063c04b8d5990612d0d908490600401613d55565b602060405180830381600087803b158015612d2757600080fd5b505af1158015612d3b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d5f9190613a7f565b9250612d6b84866113f8565b831115612d8a5760405162461bcd60e51b8152600401610ac190613bd7565b505092915050565b6117218363a9059cbb60e01b8484604051602401612db1929190613b7b565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152613482565b6000546201000090046001600160a01b03163314612e605760405162461bcd60e51b815260206004820152602f60248201527f4f6e6c792074686520636f6e7472616374206f776e6572206d6179207065726660448201526e37b936903a3434b99030b1ba34b7b760891b6064820152608401610ac1565b565b6000600560019054906101000a90046001600160a01b03166001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b158015612eb257600080fd5b505afa158015612ec6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612eea9190613a7f565b60061415612a4f57610b2364e8d4a5100083613dc5565b6040516001600160a01b0380851660248301528316604482015260648101829052612f399085906323b872dd60e01b90608401612db1565b50505050565b600080612f4b84612a58565b9050600081600f0b138015612f695750600d54600160a01b900460ff165b612fae5760405162461bcd60e51b81526020600482015260166024820152751d5b9cdd5c1c1bdc9d19590818dbdb1b185d195c985b60521b6044820152606401610ac1565b600554600f5460405163095ea7b360e01b81526001600160a01b0361010090930483169263095ea7b392612fe9929116908790600401613b7b565b602060405180830381600087803b15801561300357600080fd5b505af1158015613017573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061303b9190613a27565b50600f546001600160a01b031663a6417ed66000838661305b898261096c565b6040516001600160e01b031960e087901b168152600f94850b60048201529290930b602483015260448201526064810191909152608401602060405180830381600087803b1580156130ac57600080fd5b505af11580156130c0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130e49190613a7f565b91506130f0848461215c565b8211156118d05760405162461bcd60e51b8152600401610ac190613bd7565b60055460085460405163095ea7b360e01b815260009261010090046001600160a01b039081169263095ea7b39261314e92909116908790600401613b7b565b602060405180830381600087803b15801561316857600080fd5b505af115801561317c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131a09190613a27565b506001600160a01b038216600090815260136020526040812080546131c490613e47565b80601f01602080910402602001604051908101604052809291908181526020018280546131f090613e47565b801561323d5780601f106132125761010080835404028352916020019161323d565b820191906000526020600020905b81548152906001019060200180831161322057829003601f168201915b5050505050905080516000141561329657600554600a54604051610bb892613283926001600160a01b036101009092048216928592919091169082908990602001613ac3565b6040516020818303038152906040529150505b6040805160a08101825282815230602082015260009181016132b942600f613dad565b81526020018681526020016132ce868861096c565b905260085460405163c04b8d5960e01b81529192506001600160a01b03169063c04b8d5990613301908490600401613d55565b602060405180830381600087803b15801561331b57600080fd5b505af115801561332f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133539190613a7f565b9250612d6b848661215c565b60008061336b84612a58565b9050600081600f0b1380156133895750600d54600160a01b900460ff165b6133ce5760405162461bcd60e51b81526020600482015260166024820152751d5b9cdd5c1c1bdc9d19590818dbdb1b185d195c985b60521b6044820152606401610ac1565b600f546001600160a01b031663a6417ed6826000866133ed8982612227565b6040516001600160e01b031960e087901b168152600f94850b60048201529290930b602483015260448201526064810191909152608401602060405180830381600087803b15801561343e57600080fd5b505af1158015613452573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134769190613a7f565b91506130f084846113f8565b60006134d7826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166135549092919063ffffffff16565b80519091501561172157808060200190518101906134f59190613a27565b6117215760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610ac1565b6060613563848460008561356b565b949350505050565b6060824710156135cc5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610ac1565b843b61361a5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610ac1565b600080866001600160a01b031685876040516136369190613b15565b60006040518083038185875af1925050503d8060008114613673576040519150601f19603f3d011682016040523d82523d6000602084013e613678565b606091505b5091509150613688828286613693565b979650505050505050565b606083156136a25750816115aa565b8251156136b25782518084602001fd5b8160405162461bcd60e51b8152600401610ac19190613b94565b8280546136d890613e47565b90600052602060002090601f0160209004810192826136fa5760008555613740565b82601f1061371357805160ff1916838001178555613740565b82800160010185558215613740579182015b82811115613740578251825591602001919060010190613725565b50612a4f9291506137c0565b82805461375890613e47565b90600052602060002090601f01602090048101928261377a5760008555613740565b82601f106137935782800160ff19823516178555613740565b82800160010185558215613740579182015b828111156137405782358255916020019190600101906137a5565b5b80821115612a4f57600081556001016137c1565b803562ffffff81168114612a5357600080fd5b6000602082840312156137f9578081fd5b81356115aa81613e92565b60008060008060008060c0878903121561381c578182fd5b863561382781613e92565b9550602087013561383781613e92565b9450604087013561384781613e92565b9350606087013561385781613e92565b9250608087013561386781613ea7565b8092505060a087013590509295509295509295565b6000806040838503121561388e578182fd5b823561389981613e92565b915060208301356138a981613ea7565b809150509250929050565b600080600080606085870312156138c9578384fd5b84356138d481613e92565b9350602085013567ffffffffffffffff808211156138f0578485fd5b818701915087601f830112613903578485fd5b813581811115613911578586fd5b886020828501011115613922578586fd5b602083019550809450505050604085013561393c81613ea7565b939692955090935050565b60008060408385031215613959578182fd5b823561396481613e92565b915060208301356138a981613e92565b600080600080600060a0868803121561398b578081fd5b853561399681613e92565b94506139a4602087016137d5565b935060408601356139b481613e92565b92506139c2606087016137d5565b915060808601356139d281613e92565b809150509295509295909350565b600080604083850312156139f2578182fd5b82356139fd81613e92565b946020939093013593505050565b600060208284031215613a1c578081fd5b81356115aa81613ea7565b600060208284031215613a38578081fd5b81516115aa81613ea7565b60008060408385031215613a55578182fd5b8235915060208301356138a981613e92565b600060208284031215613a78578081fd5b5035919050565b600060208284031215613a90578081fd5b5051919050565b60008151808452613aaf816020860160208601613e1b565b601f01601f19169290920160200192915050565b6bffffffffffffffffffffffff19606096871b811682526001600160e81b031960e896871b8116601484015294871b811660178301529290941b909216602b840152921b909116602e82015260420190565b60008251613b27818460208701613e1b565b9190910192915050565b6001600160a01b038516815260606020820181905281018390528284608083013760008184016080908101919091529115156040820152601f909201601f19169091010192915050565b6001600160a01b03929092168252602082015260400190565b6020815260006115aa6020830184613a97565b602080825260169082015275155b9cdd5c1c1bdc9d19590818dbdb1b185d195c985b60521b604082015260600190565b60208082526025908201527f416d6f756e742061626f7665206d617820616c6c6f7765642070656720736c69604082015264707061676560d81b606082015260800190565b6020808252601290820152712ab739bab83837b93a32b21031b0b63632b960711b604082015260600190565b6020808252603c908201527f5468697320616374696f6e2063616e6e6f7420626520706572666f726d65642060408201527f7768696c652074686520636f6e74726163742069732070617573656400000000606082015260800190565b60208082526022908201527f6e6f20707269636520617661696c61626c652066726f6d207072696365206665604082015261195960f21b606082015260800190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b6020808252601b908201527f43616e206e6f74207365742061207a65726f2061646472657373210000000000604082015260600190565b602081526000825160a06020840152613d7160c0840182613a97565b905060018060a01b0360208501511660408401526040840151606084015260608401516080840152608084015160a08401528091505092915050565b60008219821115613dc057613dc0613e7c565b500190565b600082613de057634e487b7160e01b81526012600452602481fd5b500490565b6000816000190483118215151615613dff57613dff613e7c565b500290565b600082821015613e1657613e16613e7c565b500390565b60005b83811015613e36578181015183820152602001613e1e565b83811115612f395750506000910152565b600181811c90821680613e5b57607f821691505b60208210811415610ed357634e487b7160e01b600052602260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b6001600160a01b03811681146110dd57600080fd5b80151581146110dd57600080fdfea2646970667358221220f4b01a8838fc906bca783958f8575d8c1c7cf5fdcc97d38b6cd682fa820dfe0764736f6c63430008040033

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