ETH Price: $3,145.70 (-0.37%)

Contract

0x16F1B45f175D0d8625Fc57Eab12904C620D8D557
 

Overview

ETH Balance

0 ETH

ETH Value

$0.00

Sponsored

Transaction Hash
Method
Block
From
To
Value
0x6101a0601161285912024-02-13 20:25:5968 days ago1707855959IN
 Create: UniswapAMM
0 ETH0.000227370.10073437

Advanced mode:
Parent Txn Hash Block From To Value
View All Internal Transactions

Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
UniswapAMM

Compiler Version
v0.8.19+commit.7dd6d404

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion

Contract Source Code (Solidity Standard Json-Input format)

File 1 of 23 : UniswapAMM.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.19;

// ==========================================================
// ====================== UniswapAMM.sol ====================
// ==========================================================

/**
 * @title Uniswap AMM
 * @dev Interactions with UniswapV3
 */

import { IPriceFeed, ChainlinkLibrary } from  "../Libraries/Chainlink.sol";
import { ILiquidityHelper } from "../Utils/ILiquidityHelper.sol";
import { ISwapRouter } from "@uniswap/v3-periphery/contracts/interfaces/ISwapRouter.sol";
import { OracleLibrary } from "@uniswap/v3-periphery/contracts/libraries/OracleLibrary.sol";
import { TransferHelper } from "@uniswap/v3-periphery/contracts/libraries/TransferHelper.sol";
import { IUniswapV3Pool } from "@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol";
import { IERC20Metadata } from "@openzeppelin/contracts/interfaces/IERC20Metadata.sol";
import { Math } from "@openzeppelin/contracts/utils/math/Math.sol";
import { IMarketMaker } from "../Balancer/IMarketMaker.sol";
import { ISweep } from "../Sweep/ISweep.sol";

contract UniswapAMM {
    using Math for uint256;

    ISwapRouter private immutable router;
    IERC20Metadata public immutable base;
    ISweep public immutable sweep;
    IPriceFeed public immutable oracleBase;
    IPriceFeed public immutable sequencer;
    address public immutable pool;
    uint256 public immutable oracleBaseUpdateFrequency;
    bool private immutable flag; // The sort status of tokens
    ILiquidityHelper private immutable liquidityHelper;
    IMarketMaker public marketMaker;

    // Uniswap V3
    uint32 private constant LOOKBACK = 1 days;
    uint16 private constant DEADLINE_GAP = 15 minutes;
    uint256 private constant PRECISION = 1e6;

    constructor(
        address _sweep,
        address _base,
        address _sequencer,
        address _pool,
        address _oracleBase,
        uint256 _oracleBaseUpdateFrequency,
        address _liquidityHelper,
        address _router
    ) {
        sweep = ISweep(_sweep);
        base = IERC20Metadata(_base);
        oracleBase = IPriceFeed(_oracleBase);
        sequencer = IPriceFeed(_sequencer);
        pool = _pool;
        oracleBaseUpdateFrequency = _oracleBaseUpdateFrequency;
        liquidityHelper = ILiquidityHelper(_liquidityHelper);
        flag = _base < _sweep;
        router = ISwapRouter(_router);
    }

    // Events
    event Bought(uint256 usdxAmount);
    event Sold(uint256 sweepAmount);

    // Errors
    error ZeroAmount();
    error BadRate();
    error NotOwnerOrGov();

    modifier onlyOwner () {
        if (msg.sender != sweep.fastMultisig() && msg.sender != sweep.owner())
            revert NotOwnerOrGov();
        _;
    }

    /**
     * @notice Get Price
     * @dev Get the quote for selling 1 unit of a token.
     */
    function getPrice() public view returns (uint256 amountOut) {
        int24 tick = liquidityHelper.getCurrentTick(pool);

        uint256 quote = OracleLibrary.getQuoteAtTick(
            tick,
            uint128(10 ** sweep.decimals()),
            address(sweep),
            address(base)
        );
        uint256 price = ChainlinkLibrary.getPrice(
            oracleBase,
            sequencer,
            oracleBaseUpdateFrequency
        );

        uint8 quoteDecimals = base.decimals();
        uint8 priceDecimals = ChainlinkLibrary.getDecimals(oracleBase);

        amountOut = PRECISION.mulDiv(quote * price, 10 ** (quoteDecimals + priceDecimals));
    }

    function getPriceAtCurrentTick() public view returns (uint256) {
        int24 tick = liquidityHelper.getCurrentTick(pool);
        return getPriceAtTick(tick);
    }

    function getPriceAtTick(int24 tick) public view returns (uint256 price) {
        uint256 quote = OracleLibrary.getQuoteAtTick(
            tick,
            uint128(10 ** sweep.decimals()),
            address(sweep),
            address(base)
        );
        uint8 quoteDecimals = base.decimals();
        price = PRECISION.mulDiv(quote, 10 ** quoteDecimals);
    }

    function getTickFromPrice(uint256 price, uint8 decimals, int24 tickSpacing) public view returns (int24) {
        return liquidityHelper.getTickFromPrice(price, decimals, tickSpacing, flag);
    }

    /**
     * @notice Get TWA Price
     * @dev Get the quote for selling 1 unit of a token.
     */
    function getTWAPrice() external view returns (uint256 amountOut) {
        uint256 price = ChainlinkLibrary.getPrice(
            oracleBase,
            sequencer,
            oracleBaseUpdateFrequency
        );
        // Get the average price tick first
        (int24 arithmeticMeanTick, ) = OracleLibrary.consult(pool, LOOKBACK);

        // Get the quote for selling 1 unit of a token.
        uint256 quote = OracleLibrary.getQuoteAtTick(
            arithmeticMeanTick,
            uint128(10 ** sweep.decimals()),
            address(sweep),
            address(base)
        );

        uint8 quoteDecimals = base.decimals();
        uint8 priceDecimals = ChainlinkLibrary.getDecimals(oracleBase);

        amountOut = PRECISION.mulDiv(quote * price, 10 ** (quoteDecimals + priceDecimals));
    }

    function getPositions(uint256 tokenId)
        public view
        returns (uint256 usdxAmount, uint256 sweepAmount, uint256 lp)
    {
        lp = 0;
        (uint256 amount0, uint256 amount1) = liquidityHelper.getTokenAmountsFromLP(tokenId, pool);
        (usdxAmount, sweepAmount) = flag ? (amount0, amount1) : (amount1, amount0);
    }

    /* ========== Actions ========== */

    /**
     * @notice Buy Sweep
     * @param usdxAddress Token Address to use for buying sweep.
     * @param usdxAmount Token Amount.
     * @param amountOutMin Minimum amount out.
     * @dev Increases the sweep balance and decrease collateral balance.
     */
    function buySweep(address usdxAddress, uint256 usdxAmount, uint256 amountOutMin) 
        external returns (uint256 sweepAmount)
    {
        if (address(marketMaker) != address(0) && marketMaker.getBuyPrice() < getPrice() ) {
            TransferHelper.safeTransferFrom(address(base), msg.sender, address(this), usdxAmount);
            TransferHelper.safeApprove(address(base), address(marketMaker), usdxAmount);
            sweepAmount = marketMaker.buySweep(usdxAmount);
            TransferHelper.safeTransfer(address(sweep), msg.sender, sweepAmount);
        } else {
            checkRate(usdxAddress, usdxAmount, amountOutMin);
            sweepAmount = swap(usdxAddress, address(sweep), usdxAmount, amountOutMin, pool);
        }

        emit Bought(usdxAmount);
    }

    /**
     * @notice Sell Sweep
     * @param usdxAddress Token Address to return after selling sweep.
     * @param sweepAmount Sweep Amount.
     * @param amountOutMin Minimum amount out.
     * @dev Decreases the sweep balance and increase collateral balance
     */
    function sellSweep(address usdxAddress, uint256 sweepAmount, uint256 amountOutMin) 
        external returns (uint256 tokenAmount)
    {
        emit Sold(sweepAmount);
        checkRate(usdxAddress, amountOutMin, sweepAmount);
        tokenAmount = swap(address(sweep), usdxAddress, sweepAmount, amountOutMin, pool);
    }

    function setMarketMaker(address _marketMaker) external onlyOwner {
        marketMaker = IMarketMaker(_marketMaker);
    }

    /**
     * @notice Swap tokenA into tokenB using uniV3Router.ExactInputSingle()
     * @param tokenA Address to in
     * @param tokenB Address to out
     * @param amountIn Amount of _tokenA
     * @param amountOutMin Minimum amount out.
     * @param poolAddress Pool to use in the swap
     */
    function swap(address tokenA, address tokenB, uint256 amountIn, uint256 amountOutMin, address poolAddress) 
        private returns (uint256 amountOut)
    {
        // Approval
        TransferHelper.safeTransferFrom(tokenA, msg.sender, address(this), amountIn);
        TransferHelper.safeApprove(tokenA, address(router), amountIn);

        ISwapRouter.ExactInputSingleParams memory swapParams = ISwapRouter
            .ExactInputSingleParams({
                tokenIn: tokenA,
                tokenOut: tokenB,
                fee: IUniswapV3Pool(poolAddress).fee(),
                recipient: msg.sender,
                deadline: block.timestamp + DEADLINE_GAP,
                amountIn: amountIn,
                amountOutMinimum: amountOutMin,
                sqrtPriceLimitX96: 0
            });

        amountOut = router.exactInputSingle(swapParams);
    }

    function checkRate(address usdxAddress, uint256 usdxAmount, uint256 sweepAmount) internal view {
        if(usdxAmount == 0 || sweepAmount == 0) revert ZeroAmount();
        uint256 tokenFactor = 10 ** IERC20Metadata(usdxAddress).decimals();
        uint256 sweepFactor = 10 ** sweep.decimals();
        uint256 rate = usdxAmount * sweepFactor * PRECISION / (tokenFactor * sweepAmount);

        if(rate > 16e5 || rate < 6e5) revert BadRate();
    }
}

File 2 of 23 : IERC20Metadata.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (interfaces/IERC20Metadata.sol)

pragma solidity ^0.8.0;

import "../token/ERC20/extensions/IERC20Metadata.sol";

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

pragma solidity ^0.8.0;

import "../IERC20.sol";

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

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

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

File 4 of 23 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

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

    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

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

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

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

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

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

File 5 of 23 : Math.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol)

pragma solidity ^0.8.0;

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library Math {
    enum Rounding {
        Down, // Toward negative infinity
        Up, // Toward infinity
        Zero // Toward zero
    }

    /**
     * @dev Returns the largest of two numbers.
     */
    function max(uint256 a, uint256 b) internal pure returns (uint256) {
        return a > b ? a : b;
    }

    /**
     * @dev Returns the smallest of two numbers.
     */
    function min(uint256 a, uint256 b) internal pure returns (uint256) {
        return a < b ? a : b;
    }

    /**
     * @dev Returns the average of two numbers. The result is rounded towards
     * zero.
     */
    function average(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b) / 2 can overflow.
        return (a & b) + (a ^ b) / 2;
    }

    /**
     * @dev Returns the ceiling of the division of two numbers.
     *
     * This differs from standard division with `/` in that it rounds up instead
     * of rounding down.
     */
    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b - 1) / b can overflow on addition, so we distribute.
        return a == 0 ? 0 : (a - 1) / b + 1;
    }

    /**
     * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
     * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)
     * with further edits by Uniswap Labs also under MIT license.
     */
    function mulDiv(
        uint256 x,
        uint256 y,
        uint256 denominator
    ) internal pure returns (uint256 result) {
        unchecked {
            // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
            // 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(x, y, not(0))
                prod0 := mul(x, y)
                prod1 := sub(sub(mm, prod0), lt(mm, prod0))
            }

            // Handle non-overflow cases, 256 by 256 division.
            if (prod1 == 0) {
                return prod0 / denominator;
            }

            // 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].
            uint256 remainder;
            assembly {
                // Compute remainder using mulmod.
                remainder := mulmod(x, y, denominator)

                // Subtract 256 bit number from 512 bit number.
                prod1 := sub(prod1, gt(remainder, prod0))
                prod0 := sub(prod0, remainder)
            }

            // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.
            // See https://cs.stackexchange.com/q/138556/92363.

            // Does not overflow because the denominator cannot be zero at this stage in the function.
            uint256 twos = denominator & (~denominator + 1);
            assembly {
                // Divide denominator by twos.
                denominator := div(denominator, twos)

                // Divide [prod1 prod0] by twos.
                prod0 := div(prod0, twos)

                // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
                twos := add(div(sub(0, twos), twos), 1)
            }

            // Shift in bits from prod1 into prod0.
            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 for
            // four bits. That is, denominator * inv = 1 mod 2^4.
            uint256 inverse = (3 * denominator) ^ 2;

            // Use the 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.
            inverse *= 2 - denominator * inverse; // inverse mod 2^8
            inverse *= 2 - denominator * inverse; // inverse mod 2^16
            inverse *= 2 - denominator * inverse; // inverse mod 2^32
            inverse *= 2 - denominator * inverse; // inverse mod 2^64
            inverse *= 2 - denominator * inverse; // inverse mod 2^128
            inverse *= 2 - denominator * inverse; // 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 preconditions 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 * inverse;
            return result;
        }
    }

    /**
     * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
     */
    function mulDiv(
        uint256 x,
        uint256 y,
        uint256 denominator,
        Rounding rounding
    ) internal pure returns (uint256) {
        uint256 result = mulDiv(x, y, denominator);
        if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {
            result += 1;
        }
        return result;
    }

    /**
     * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.
     *
     * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
     */
    function sqrt(uint256 a) internal pure returns (uint256) {
        if (a == 0) {
            return 0;
        }

        // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
        //
        // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
        // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
        //
        // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
        // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
        // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
        //
        // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
        uint256 result = 1 << (log2(a) >> 1);

        // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
        // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
        // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
        // into the expected uint128 result.
        unchecked {
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            return min(result, a / result);
        }
    }

    /**
     * @notice Calculates sqrt(a), following the selected rounding direction.
     */
    function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = sqrt(a);
            return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 2, rounded down, of a positive value.
     * Returns 0 if given 0.
     */
    function log2(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >> 128 > 0) {
                value >>= 128;
                result += 128;
            }
            if (value >> 64 > 0) {
                value >>= 64;
                result += 64;
            }
            if (value >> 32 > 0) {
                value >>= 32;
                result += 32;
            }
            if (value >> 16 > 0) {
                value >>= 16;
                result += 16;
            }
            if (value >> 8 > 0) {
                value >>= 8;
                result += 8;
            }
            if (value >> 4 > 0) {
                value >>= 4;
                result += 4;
            }
            if (value >> 2 > 0) {
                value >>= 2;
                result += 2;
            }
            if (value >> 1 > 0) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 2, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log2(value);
            return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 10, rounded down, of a positive value.
     * Returns 0 if given 0.
     */
    function log10(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >= 10**64) {
                value /= 10**64;
                result += 64;
            }
            if (value >= 10**32) {
                value /= 10**32;
                result += 32;
            }
            if (value >= 10**16) {
                value /= 10**16;
                result += 16;
            }
            if (value >= 10**8) {
                value /= 10**8;
                result += 8;
            }
            if (value >= 10**4) {
                value /= 10**4;
                result += 4;
            }
            if (value >= 10**2) {
                value /= 10**2;
                result += 2;
            }
            if (value >= 10**1) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 10, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log10(value);
            return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 256, rounded down, of a positive value.
     * Returns 0 if given 0.
     *
     * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
     */
    function log256(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >> 128 > 0) {
                value >>= 128;
                result += 16;
            }
            if (value >> 64 > 0) {
                value >>= 64;
                result += 8;
            }
            if (value >> 32 > 0) {
                value >>= 32;
                result += 4;
            }
            if (value >> 16 > 0) {
                value >>= 16;
                result += 2;
            }
            if (value >> 8 > 0) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 10, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log256(value);
            return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0);
        }
    }
}

File 6 of 23 : 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 7 of 23 : IUniswapV3Pool.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

import {IUniswapV3PoolImmutables} from './pool/IUniswapV3PoolImmutables.sol';
import {IUniswapV3PoolState} from './pool/IUniswapV3PoolState.sol';
import {IUniswapV3PoolDerivedState} from './pool/IUniswapV3PoolDerivedState.sol';
import {IUniswapV3PoolActions} from './pool/IUniswapV3PoolActions.sol';
import {IUniswapV3PoolOwnerActions} from './pool/IUniswapV3PoolOwnerActions.sol';
import {IUniswapV3PoolErrors} from './pool/IUniswapV3PoolErrors.sol';
import {IUniswapV3PoolEvents} from './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,
    IUniswapV3PoolErrors,
    IUniswapV3PoolEvents
{

}

File 8 of 23 : 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 9 of 23 : 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 10 of 23 : IUniswapV3PoolErrors.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

/// @title Errors emitted by a pool
/// @notice Contains all events emitted by the pool
interface IUniswapV3PoolErrors {
    error LOK();
    error TLU();
    error TLM();
    error TUM();
    error AI();
    error M0();
    error M1();
    error AS();
    error IIA();
    error L();
    error F0();
    error F1();
}

File 11 of 23 : 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);
}

File 12 of 23 : 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 13 of 23 : 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 14 of 23 : 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
    /// @return 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.
    /// @return observationIndex The index of the last oracle observation that was written,
    /// @return observationCardinality The current maximum number of observations stored in the pool,
    /// @return observationCardinalityNext The next maximum number of observations, to be updated when the observation.
    /// @return 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
    /// @return The liquidity at the current price of the pool
    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
    /// @return liquidityNet how much liquidity changes when the pool price crosses the tick,
    /// @return feeGrowthOutside0X128 the fee growth on the other side of the tick from the current tick in token0,
    /// @return feeGrowthOutside1X128 the fee growth on the other side of the tick from the current tick in token1,
    /// @return tickCumulativeOutside the cumulative tick value on the other side of the tick from the current tick
    /// @return secondsPerLiquidityOutsideX128 the seconds spent per liquidity on the other side of the tick from the current tick,
    /// @return secondsOutside the seconds spent on the other side of the tick from the current tick,
    /// @return 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,
    /// @return feeGrowthInside0LastX128 fee growth of token0 inside the tick range as of the last mint/burn/poke,
    /// @return feeGrowthInside1LastX128 fee growth of token1 inside the tick range as of the last mint/burn/poke,
    /// @return tokensOwed0 the computed amount of token0 owed to the position as of the last mint/burn/poke,
    /// @return 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,
    /// @return tickCumulative the tick multiplied by seconds elapsed for the life of the pool as of the observation timestamp,
    /// @return secondsPerLiquidityCumulativeX128 the seconds per in range liquidity for the life of the pool as of the observation timestamp,
    /// @return 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 15 of 23 : FullMath.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

/// @title Contains 512-bit math functions
/// @notice Facilitates multiplication and division that can have overflow of an intermediate value without any loss of precision
/// @dev Handles "phantom overflow" i.e., allows multiplication and division where an intermediate value overflows 256 bits
library FullMath {
    /// @notice Calculates floor(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
    /// @param a The multiplicand
    /// @param b The multiplier
    /// @param denominator The divisor
    /// @return result The 256-bit result
    /// @dev Credit to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv
    function mulDiv(
        uint256 a,
        uint256 b,
        uint256 denominator
    ) internal pure returns (uint256 result) {
        unchecked {
            // 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 = (0 - denominator) & denominator;
            // Divide denominator by power of two
            assembly {
                denominator := div(denominator, twos)
            }

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

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

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

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

File 16 of 23 : TickMath.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8.0;

/// @title Math library for computing sqrt prices from ticks and vice versa
/// @notice 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
library TickMath {
    error T();
    error R();

    /// @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 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) {
        unchecked {
            uint256 absTick = tick < 0 ? uint256(-int256(tick)) : uint256(int256(tick));
            if (absTick > uint256(int256(MAX_TICK))) revert 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) {
        unchecked {
            // second inequality must be < because the price can never reach the price at the max tick
            if (!(sqrtPriceX96 >= MIN_SQRT_RATIO && sqrtPriceX96 < MAX_SQRT_RATIO)) revert 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 17 of 23 : 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 18 of 23 : OracleLibrary.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0 <0.9.0;

import '@uniswap/v3-core/contracts/libraries/FullMath.sol';
import '@uniswap/v3-core/contracts/libraries/TickMath.sol';
import '@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol';

/// @title Oracle library
/// @notice Provides functions to integrate with V3 pool oracle
library OracleLibrary {
    /// @notice Calculates time-weighted means of tick and liquidity for a given Uniswap V3 pool
    /// @param pool Address of the pool that we want to observe
    /// @param secondsAgo Number of seconds in the past from which to calculate the time-weighted means
    /// @return arithmeticMeanTick The arithmetic mean tick from (block.timestamp - secondsAgo) to block.timestamp
    /// @return harmonicMeanLiquidity The harmonic mean liquidity from (block.timestamp - secondsAgo) to block.timestamp
    function consult(address pool, uint32 secondsAgo)
        internal
        view
        returns (int24 arithmeticMeanTick, uint128 harmonicMeanLiquidity)
    {
        require(secondsAgo != 0, 'BP');

        uint32[] memory secondsAgos = new uint32[](2);
        secondsAgos[0] = secondsAgo;
        secondsAgos[1] = 0;

        (int56[] memory tickCumulatives, uint160[] memory secondsPerLiquidityCumulativeX128s) = IUniswapV3Pool(pool)
            .observe(secondsAgos);

        int56 tickCumulativesDelta = tickCumulatives[1] - tickCumulatives[0];
        uint160 secondsPerLiquidityCumulativesDelta = secondsPerLiquidityCumulativeX128s[1] -
            secondsPerLiquidityCumulativeX128s[0];

        arithmeticMeanTick = int24(tickCumulativesDelta / int56(uint56(secondsAgo)));
        // Always round to negative infinity
        if (tickCumulativesDelta < 0 && (tickCumulativesDelta % int56(uint56(secondsAgo)) != 0)) arithmeticMeanTick--;

        // We are multiplying here instead of shifting to ensure that harmonicMeanLiquidity doesn't overflow uint128
        uint192 secondsAgoX160 = uint192(secondsAgo) * type(uint160).max;
        harmonicMeanLiquidity = uint128(secondsAgoX160 / (uint192(secondsPerLiquidityCumulativesDelta) << 32));
    }

    /// @notice Given a tick and a token amount, calculates the amount of token received in exchange
    /// @param tick Tick value used to calculate the quote
    /// @param baseAmount Amount of token to be converted
    /// @param baseToken Address of an ERC20 token contract used as the baseAmount denomination
    /// @param quoteToken Address of an ERC20 token contract used as the quoteAmount denomination
    /// @return quoteAmount Amount of quoteToken received for baseAmount of baseToken
    function getQuoteAtTick(
        int24 tick,
        uint128 baseAmount,
        address baseToken,
        address quoteToken
    ) internal pure returns (uint256 quoteAmount) {
        uint160 sqrtRatioX96 = TickMath.getSqrtRatioAtTick(tick);

        // Calculate quoteAmount with better precision if it doesn't overflow when multiplied by itself
        if (sqrtRatioX96 <= type(uint128).max) {
            uint256 ratioX192 = uint256(sqrtRatioX96) * sqrtRatioX96;
            quoteAmount = baseToken < quoteToken
                ? FullMath.mulDiv(ratioX192, baseAmount, 1 << 192)
                : FullMath.mulDiv(1 << 192, baseAmount, ratioX192);
        } else {
            uint256 ratioX128 = FullMath.mulDiv(sqrtRatioX96, sqrtRatioX96, 1 << 64);
            quoteAmount = baseToken < quoteToken
                ? FullMath.mulDiv(ratioX128, baseAmount, 1 << 128)
                : FullMath.mulDiv(1 << 128, baseAmount, ratioX128);
        }
    }

    /// @notice Given a pool, it returns the number of seconds ago of the oldest stored observation
    /// @param pool Address of Uniswap V3 pool that we want to observe
    /// @return secondsAgo The number of seconds ago of the oldest observation stored for the pool
    function getOldestObservationSecondsAgo(address pool) internal view returns (uint32 secondsAgo) {
        (, , uint16 observationIndex, uint16 observationCardinality, , , ) = IUniswapV3Pool(pool).slot0();
        require(observationCardinality > 0, 'NI');

        (uint32 observationTimestamp, , , bool initialized) = IUniswapV3Pool(pool).observations(
            (observationIndex + 1) % observationCardinality
        );

        // The next index might not be initialized if the cardinality is in the process of increasing
        // In this case the oldest observation is always in index 0
        if (!initialized) {
            (observationTimestamp, , , ) = IUniswapV3Pool(pool).observations(0);
        }

        unchecked {
            secondsAgo = uint32(block.timestamp) - observationTimestamp;
        }
    }

    /// @notice Given a pool, it returns the tick value as of the start of the current block
    /// @param pool Address of Uniswap V3 pool
    /// @return The tick that the pool was in at the start of the current block
    function getBlockStartingTickAndLiquidity(address pool) internal view returns (int24, uint128) {
        (, int24 tick, uint16 observationIndex, uint16 observationCardinality, , , ) = IUniswapV3Pool(pool).slot0();

        // 2 observations are needed to reliably calculate the block starting tick
        require(observationCardinality > 1, 'NEO');

        // If the latest observation occurred in the past, then no tick-changing trades have happened in this block
        // therefore the tick in `slot0` is the same as at the beginning of the current block.
        // We don't need to check if this observation is initialized - it is guaranteed to be.
        (
            uint32 observationTimestamp,
            int56 tickCumulative,
            uint160 secondsPerLiquidityCumulativeX128,

        ) = IUniswapV3Pool(pool).observations(observationIndex);
        if (observationTimestamp != uint32(block.timestamp)) {
            return (tick, IUniswapV3Pool(pool).liquidity());
        }

        uint256 prevIndex = (uint256(observationIndex) + observationCardinality - 1) % observationCardinality;
        (
            uint32 prevObservationTimestamp,
            int56 prevTickCumulative,
            uint160 prevSecondsPerLiquidityCumulativeX128,
            bool prevInitialized
        ) = IUniswapV3Pool(pool).observations(prevIndex);

        require(prevInitialized, 'ONI');

        uint32 delta = observationTimestamp - prevObservationTimestamp;
        tick = int24((tickCumulative - int56(uint56(prevTickCumulative))) / int56(uint56(delta)));
        uint128 liquidity = uint128(
            (uint192(delta) * type(uint160).max) /
                (uint192(secondsPerLiquidityCumulativeX128 - prevSecondsPerLiquidityCumulativeX128) << 32)
        );
        return (tick, liquidity);
    }

    /// @notice Information for calculating a weighted arithmetic mean tick
    struct WeightedTickData {
        int24 tick;
        uint128 weight;
    }

    /// @notice Given an array of ticks and weights, calculates the weighted arithmetic mean tick
    /// @param weightedTickData An array of ticks and weights
    /// @return weightedArithmeticMeanTick The weighted arithmetic mean tick
    /// @dev Each entry of `weightedTickData` should represents ticks from pools with the same underlying pool tokens. If they do not,
    /// extreme care must be taken to ensure that ticks are comparable (including decimal differences).
    /// @dev Note that the weighted arithmetic mean tick corresponds to the weighted geometric mean price.
    function getWeightedArithmeticMeanTick(WeightedTickData[] memory weightedTickData)
        internal
        pure
        returns (int24 weightedArithmeticMeanTick)
    {
        // Accumulates the sum of products between each tick and its weight
        int256 numerator;

        // Accumulates the sum of the weights
        uint256 denominator;

        // Products fit in 152 bits, so it would take an array of length ~2**104 to overflow this logic
        for (uint256 i; i < weightedTickData.length; i++) {
            numerator += weightedTickData[i].tick * int256(uint256(weightedTickData[i].weight));
            denominator += weightedTickData[i].weight;
        }

        weightedArithmeticMeanTick = int24(numerator / int256(denominator));
        // Always round to negative infinity
        if (numerator < 0 && (numerator % int256(denominator) != 0)) weightedArithmeticMeanTick--;
    }

    /// @notice Returns the "synthetic" tick which represents the price of the first entry in `tokens` in terms of the last
    /// @dev Useful for calculating relative prices along routes.
    /// @dev There must be one tick for each pairwise set of tokens.
    /// @param tokens The token contract addresses
    /// @param ticks The ticks, representing the price of each token pair in `tokens`
    /// @return syntheticTick The synthetic tick, representing the relative price of the outermost tokens in `tokens`
    function getChainedPrice(address[] memory tokens, int24[] memory ticks)
        internal
        pure
        returns (int256 syntheticTick)
    {
        require(tokens.length - 1 == ticks.length, 'DL');
        for (uint256 i = 1; i <= ticks.length; i++) {
            // check the tokens for address sort order, then accumulate the
            // ticks into the running synthetic tick, ensuring that intermediate tokens "cancel out"
            tokens[i - 1] < tokens[i] ? syntheticTick += ticks[i - 1] : syntheticTick -= ticks[i - 1];
        }
    }
}

File 19 of 23 : TransferHelper.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.6.0;

import '@openzeppelin/contracts/token/ERC20/IERC20.sol';

library TransferHelper {
    /// @notice Transfers tokens from the targeted address to the given destination
    /// @notice Errors with 'STF' if transfer fails
    /// @param token The contract address of the token to be transferred
    /// @param from The originating address from which the tokens will be transferred
    /// @param to The destination address of the transfer
    /// @param value The amount to be transferred
    function safeTransferFrom(
        address token,
        address from,
        address to,
        uint256 value
    ) internal {
        (bool success, bytes memory data) = token.call(
            abi.encodeWithSelector(IERC20.transferFrom.selector, from, to, value)
        );
        require(success && (data.length == 0 || abi.decode(data, (bool))), 'STF');
    }

    /// @notice Transfers tokens from msg.sender to a recipient
    /// @dev Errors with ST if transfer fails
    /// @param token The contract address of the token which will be transferred
    /// @param to The recipient of the transfer
    /// @param value The value of the transfer
    function safeTransfer(
        address token,
        address to,
        uint256 value
    ) internal {
        (bool success, bytes memory data) = token.call(abi.encodeWithSelector(IERC20.transfer.selector, to, value));
        require(success && (data.length == 0 || abi.decode(data, (bool))), 'ST');
    }

    /// @notice Approves the stipulated contract to spend the given allowance in the given token
    /// @dev Errors with 'SA' if transfer fails
    /// @param token The contract address of the token to be approved
    /// @param to The target of the approval
    /// @param value The amount of the given token the target will be allowed to spend
    function safeApprove(
        address token,
        address to,
        uint256 value
    ) internal {
        (bool success, bytes memory data) = token.call(abi.encodeWithSelector(IERC20.approve.selector, to, value));
        require(success && (data.length == 0 || abi.decode(data, (bool))), 'SA');
    }

    /// @notice Transfers ETH to the recipient address
    /// @dev Fails with `STE`
    /// @param to The destination of the transfer
    /// @param value The value to be transferred
    function safeTransferETH(address to, uint256 value) internal {
        (bool success, ) = to.call{value: value}(new bytes(0));
        require(success, 'STE');
    }
}

File 20 of 23 : IMarketMaker.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.19;

interface IMarketMaker {
    function getBuyPrice() external view returns (uint256 price); 
    function buySweep(uint256 usdxAmount) external returns (uint256 sweepAmount);
}

File 21 of 23 : Chainlink.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.19;

interface IPriceFeed {
    function latestAnswer() external view returns (int256);

    function latestTimestamp() external view returns (uint256);

    function latestRound() external view returns (uint256);

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

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

    function decimals() external view returns (uint8);

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

    function version() external view returns (uint256);

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

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

library ChainlinkLibrary {
    uint8 constant USD_DECIMALS = 6;

    function getDecimals(IPriceFeed oracle) internal view returns (uint8) {
        return oracle.decimals();
    }

    function getPrice(IPriceFeed oracle) internal view returns (uint256) {
        (
            uint80 roundID,
            int256 price,
            ,
            uint256 timeStamp,
            uint80 answeredInRound
        ) = oracle.latestRoundData();
        require(answeredInRound >= roundID, "Old data");
        require(timeStamp > 0, "Round not complete");

        return uint256(price);
    }

    function getPrice(
        IPriceFeed oracle,
        IPriceFeed sequencerOracle,
        uint256 frequency
    ) internal view returns (uint256) {
        if (address(sequencerOracle) != address(0))
            checkUptime(sequencerOracle);

        (uint256 roundId, int256 price, , uint256 updatedAt, ) = oracle
            .latestRoundData();
        require(price > 0 && roundId != 0 && updatedAt != 0, "Invalid Price");
        if (frequency > 0)
            require(block.timestamp - updatedAt <= frequency, "Stale Price");

        return uint256(price);
    }

    function checkUptime(IPriceFeed sequencerOracle) internal view {
        (, int256 answer, uint256 startedAt, , ) = sequencerOracle
            .latestRoundData();
        require(answer <= 0, "Sequencer Down"); // 0: Sequencer is up, 1: Sequencer is down
        require(block.timestamp - startedAt > 1 hours, "Grace Period Not Over");
    }

    function convertTokenToToken(
        uint256 amount0,
        uint8 token0Decimals,
        uint8 token1Decimals,
        IPriceFeed oracle0,
        IPriceFeed oracle1
    ) internal view returns (uint256 amount1) {
        uint256 price0 = getPrice(oracle0);
        uint256 price1 = getPrice(oracle1);
        amount1 =
            (amount0 * price0 * (10 ** token1Decimals)) /
            (price1 * (10 ** token0Decimals));
    }

    function convertTokenToUsd(
        uint256 amount,
        uint8 tokenDecimals,
        IPriceFeed oracle
    ) internal view returns (uint256 amountUsd) {
        uint8 decimals = getDecimals(oracle);
        uint256 price = getPrice(oracle);

        amountUsd =
            (amount * price * (10 ** USD_DECIMALS)) /
            10 ** (decimals + tokenDecimals);
    }

    function convertUsdToToken(
        uint256 amountUsd,
        uint256 tokenDecimals,
        IPriceFeed oracle
    ) internal view returns (uint256 amount) {
        uint8 decimals = getDecimals(oracle);
        uint256 price = getPrice(oracle);

        amount =
            (amountUsd * 10 ** (decimals + tokenDecimals)) /
            (price * (10 ** USD_DECIMALS));
    }
}

File 22 of 23 : ISweep.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.19;

interface ISweep {
    struct Minter {
        uint256 maxAmount;
        uint256 mintedAmount;
        bool isListed;
        bool isEnabled;
    }

    function isMintingAllowed() external view returns (bool);

    function DEFAULT_ADMIN_ADDRESS() external view returns (address);

    function balancer() external view returns (address);

    function treasury() external view returns (address);

    function allowance(
        address holder,
        address spender
    ) external view returns (uint256);

    function approve(address spender, uint256 amount) external returns (bool);

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

    function decimals() external view returns (uint8);

    function decreaseAllowance(
        address spender,
        uint256 subtractedValue
    ) external returns (bool);

    function isValidMinter(address) external view returns (bool);

    function amm() external view returns (address);

    function ammPrice() external view returns (uint256);

    function twaPrice() external view returns (uint256);

    function increaseAllowance(
        address spender,
        uint256 addedValue
    ) external returns (bool);

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

    function owner() external view returns (address);

    function fastMultisig() external view returns (address);

    function burn(uint256 amount) external;

    function mint(uint256 amount) external;

    function minters(address minterAaddress) external returns (Minter memory);

    function minterAddresses(uint256 index) external view returns (address);

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

    function targetPrice() external view returns (uint256);

    function interestRate() external view returns (int256);

    function periodStart() external view returns (uint256);

    function stepValue() external view returns (int256);

    function arbSpread() external view returns (uint256);

    function refreshInterestRate(int256 newInterestRate, uint256 newPeriodStart) external;

    function setTargetPrice(
        uint256 currentTargetPrice,
        uint256 nextTargetPrice
    ) external;

    function setInterestRate(
        int256 currentInterestRate,
        int256 nextInterestRate
    ) external;

    function setPeriodStart(
        uint256 currentPeriodStart,
        uint256 nextPeriodStart
    ) external;

    function startNewPeriod() external;

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

    function totalSupply() external view returns (uint256);

    function convertToUSD(uint256 amount) external view returns (uint256);

    function convertToSWEEP(uint256 amount) external view returns (uint256);

    function transfer(
        address recipient,
        uint256 amount
    ) external returns (bool);

    function transferFrom(
        address sender,
        address recipient,
        uint256 amount
    ) external returns (bool);
}

File 23 of 23 : ILiquidityHelper.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity 0.8.19;

interface ILiquidityHelper {

    function getTokenAmountsFromLP(uint256 tokenId, address pool) external view returns (uint256 amount0, uint256 amount1);

    function getTickFromPrice(uint256 price, uint256 decimal, int24 tickSpacing, bool flag) external pure returns (int24 tick);

    function getCurrentTick(address pool) external view returns (int24 tickCurrent);

}

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

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"_sweep","type":"address"},{"internalType":"address","name":"_base","type":"address"},{"internalType":"address","name":"_sequencer","type":"address"},{"internalType":"address","name":"_pool","type":"address"},{"internalType":"address","name":"_oracleBase","type":"address"},{"internalType":"uint256","name":"_oracleBaseUpdateFrequency","type":"uint256"},{"internalType":"address","name":"_liquidityHelper","type":"address"},{"internalType":"address","name":"_router","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"BadRate","type":"error"},{"inputs":[],"name":"NotOwnerOrGov","type":"error"},{"inputs":[],"name":"T","type":"error"},{"inputs":[],"name":"ZeroAmount","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"usdxAmount","type":"uint256"}],"name":"Bought","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"sweepAmount","type":"uint256"}],"name":"Sold","type":"event"},{"inputs":[],"name":"base","outputs":[{"internalType":"contract IERC20Metadata","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"usdxAddress","type":"address"},{"internalType":"uint256","name":"usdxAmount","type":"uint256"},{"internalType":"uint256","name":"amountOutMin","type":"uint256"}],"name":"buySweep","outputs":[{"internalType":"uint256","name":"sweepAmount","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getPositions","outputs":[{"internalType":"uint256","name":"usdxAmount","type":"uint256"},{"internalType":"uint256","name":"sweepAmount","type":"uint256"},{"internalType":"uint256","name":"lp","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPrice","outputs":[{"internalType":"uint256","name":"amountOut","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPriceAtCurrentTick","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"int24","name":"tick","type":"int24"}],"name":"getPriceAtTick","outputs":[{"internalType":"uint256","name":"price","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getTWAPrice","outputs":[{"internalType":"uint256","name":"amountOut","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint8","name":"decimals","type":"uint8"},{"internalType":"int24","name":"tickSpacing","type":"int24"}],"name":"getTickFromPrice","outputs":[{"internalType":"int24","name":"","type":"int24"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"marketMaker","outputs":[{"internalType":"contract IMarketMaker","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"oracleBase","outputs":[{"internalType":"contract IPriceFeed","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"oracleBaseUpdateFrequency","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pool","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"usdxAddress","type":"address"},{"internalType":"uint256","name":"sweepAmount","type":"uint256"},{"internalType":"uint256","name":"amountOutMin","type":"uint256"}],"name":"sellSweep","outputs":[{"internalType":"uint256","name":"tokenAmount","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"sequencer","outputs":[{"internalType":"contract IPriceFeed","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_marketMaker","type":"address"}],"name":"setMarketMaker","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"sweep","outputs":[{"internalType":"contract ISweep","name":"","type":"address"}],"stateMutability":"view","type":"function"}]

6101a06040523480156200001257600080fd5b5060405162002a8938038062002a8983398101604081905262000035916200009b565b6001600160a01b0397881660c081905296881660a081905293881660e052948716610100529286166101205261014052908416610180529190911061016052166080526200013a565b80516001600160a01b03811681146200009657600080fd5b919050565b600080600080600080600080610100898b031215620000b957600080fd5b620000c4896200007e565b9750620000d460208a016200007e565b9650620000e460408a016200007e565b9550620000f460608a016200007e565b94506200010460808a016200007e565b935060a089015192506200011b60c08a016200007e565b91506200012b60e08a016200007e565b90509295985092959890939650565b60805160a05160c05160e05161010051610120516101405161016051610180516127e9620002a0600039600081816102f00152818161096b01528181610cad0152610d7d0152600081816103b40152610d52015260008181610254015281816104d50152610a8701526000818161010a015281816103200152818161045f01528181610502015281816108c60152818161093e0152610c8001526000818161022d015281816104b40152610a660152600081816101d7015281816104930152818161069601528181610a450152610b3a01526000818161018f0152818161043b01528181610535015281816105c201528181610867015281816108a3015281816109e001528181610b7601528181610df901528181610e97015261100b0152600081816101fe015281816105e30152818161060d01528181610792015281816107c201528181610ab10152610bd8015260008181611115015261126f01526127e96000f3fe608060405234801561001057600080fd5b50600436106101005760003560e01c80635c1bba38116100975780639ca2f8c6116100665780639ca2f8c614610291578063bf56c3fb146102a4578063f4f7fd25146102ac578063f54c42d7146102d257600080fd5b80635c1bba381461022857806375cdf6491461024f5780638c60c71c1461027657806398d5fdca1461028957600080fd5b806338da412e116100d357806338da412e146101b15780634562aee3146101d25780635001f3b5146101f9578063598790991461022057600080fd5b806316f0115b146101055780631f21f9af1461014957806330e005961461015c57806335faa4161461018a575b600080fd5b61012c7f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020015b60405180910390f35b60005461012c906001600160a01b031681565b61016f61016a366004612077565b6102e7565b60408051938452602084019290925290820152606001610140565b61012c7f000000000000000000000000000000000000000000000000000000000000000081565b6101c46101bf3660046120a8565b6103f0565b604051908152602001610140565b61012c7f000000000000000000000000000000000000000000000000000000000000000081565b61012c7f000000000000000000000000000000000000000000000000000000000000000081565b6101c461048b565b61012c7f000000000000000000000000000000000000000000000000000000000000000081565b6101c47f000000000000000000000000000000000000000000000000000000000000000081565b6101c46102843660046120a8565b6106f3565b6101c4610927565b6101c461029f3660046120ec565b610b6d565b6101c4610c69565b6102bf6102ba366004612118565b610d29565b60405160029190910b8152602001610140565b6102e56102e036600461215a565b610df7565b005b600080600080807f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663886c2978877f00000000000000000000000000000000000000000000000000000000000000006040518363ffffffff1660e01b815260040161036e9291909182526001600160a01b0316602082015260400190565b6040805180830381865afa15801561038a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103ae9190612177565b915091507f00000000000000000000000000000000000000000000000000000000000000006103de5780826103e1565b81815b90979096509294509192505050565b60007f92f64ca637d023f354075a4be751b169c1a8a9ccb6d33cdd0cb35205439957278360405161042391815260200190565b60405180910390a1610436848385610f6d565b6104837f00000000000000000000000000000000000000000000000000000000000000008585857f0000000000000000000000000000000000000000000000000000000000000000611101565b949350505050565b6000806104f97f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000006112ea565b9050600061052a7f000000000000000000000000000000000000000000000000000000000000000062015180611431565b5090506000610607827f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015610591573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105b5919061219b565b6105c090600a6122b2565b7f00000000000000000000000000000000000000000000000000000000000000007f000000000000000000000000000000000000000000000000000000000000000061167b565b905060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015610669573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061068d919061219b565b905060006106ba7f0000000000000000000000000000000000000000000000000000000000000000611789565b90506106e96106c986856122c1565b6106d383856122d8565b6106de90600a6122b2565b620f424091906117f3565b9550505050505090565b600080546001600160a01b0316158015906107885750610711610927565b60008054906101000a90046001600160a01b03166001600160a01b031663018a25e86040518163ffffffff1660e01b8152600401602060405180830381865afa158015610762573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061078691906122f1565b105b15610892576107b97f00000000000000000000000000000000000000000000000000000000000000003330866118a2565b6000546107f1907f0000000000000000000000000000000000000000000000000000000000000000906001600160a01b0316856119a4565b6000546040516369ae990b60e01b8152600481018590526001600160a01b03909116906369ae990b906024016020604051808303816000875af115801561083c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061086091906122f1565b905061088d7f00000000000000000000000000000000000000000000000000000000000000003383611aa4565b6108ed565b61089d848484610f6d565b6108ea847f000000000000000000000000000000000000000000000000000000000000000085857f0000000000000000000000000000000000000000000000000000000000000000611101565b90505b6040518381527f4e08ba899977cf7d4c2964bce71c6b9a7ef76ee5166a4c1249a1e08016e33ef19060200160405180910390a19392505050565b60405163040a5dc160e01b81526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000008116600483015260009182917f0000000000000000000000000000000000000000000000000000000000000000169063040a5dc190602401602060405180830381865afa1580156109b2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109d6919061230a565b90506000610a3c827f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015610591573d6000803e3d6000fd5b90506000610aab7f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000006112ea565b905060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015610b0d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b31919061219b565b90506000610b5e7f0000000000000000000000000000000000000000000000000000000000000000611789565b90506106e96106c984866122c1565b600080610bd2837f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015610591573d6000803e3d6000fd5b905060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015610c34573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c58919061219b565b9050610483826106de83600a6122b2565b60405163040a5dc160e01b81526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000008116600483015260009182917f0000000000000000000000000000000000000000000000000000000000000000169063040a5dc190602401602060405180830381865afa158015610cf4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d18919061230a565b9050610d2381610b6d565b91505090565b6040516348bd18b760e01b81526004810184905260ff83166024820152600282900b60448201527f0000000000000000000000000000000000000000000000000000000000000000151560648201526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906348bd18b790608401602060405180830381865afa158015610dcc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610483919061230a565b9392505050565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663baf4a3126040518163ffffffff1660e01b8152600401602060405180830381865afa158015610e55573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e799190612327565b6001600160a01b0316336001600160a01b031614158015610f2d57507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316638da5cb5b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610ef3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f179190612327565b6001600160a01b0316336001600160a01b031614155b15610f4b576040516338ae11af60e01b815260040160405180910390fd5b600080546001600160a01b0319166001600160a01b0392909216919091179055565b811580610f78575080155b15610f9657604051631f2a200560e01b815260040160405180910390fd5b6000836001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015610fd6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ffa919061219b565b61100590600a6122b2565b905060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015611067573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061108b919061219b565b61109690600a6122b2565b905060006110a484846122c1565b620f42406110b284886122c1565b6110bc91906122c1565b6110c6919061235a565b905062186a008111806110db5750620927c081105b156110f95760405163491dee2160e01b815260040160405180910390fd5b505050505050565b600061110f863330876118a2565b61113a867f0000000000000000000000000000000000000000000000000000000000000000866119a4565b6000604051806101000160405280886001600160a01b03168152602001876001600160a01b03168152602001846001600160a01b031663ddca3f436040518163ffffffff1660e01b8152600401602060405180830381865afa1580156111a4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111c8919061236e565b62ffffff1681523360208201526040016111e461038442612393565b8152602080820188905260408083018890526000606093840152805163414bf38960e01b815284516001600160a01b03908116600483015292850151831660248201529084015162ffffff16604482015291830151811660648301526080830151608483015260a083015160a483015260c083015160c483015260e0830151811660e48301529192507f00000000000000000000000000000000000000000000000000000000000000009091169063414bf38990610104016020604051808303816000875af11580156112bb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112df91906122f1565b979650505050505050565b60006001600160a01b038316156113045761130483611b9d565b6000806000866001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa158015611347573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061136b91906123c5565b50935050925069ffffffffffffffffffff16925060008213801561138e57508215155b801561139957508015155b6113da5760405162461bcd60e51b815260206004820152600d60248201526c496e76616c696420507269636560981b60448201526064015b60405180910390fd5b841561142757846113eb8242612415565b11156114275760405162461bcd60e51b815260206004820152600b60248201526a5374616c6520507269636560a81b60448201526064016113d1565b5095945050505050565b6000808263ffffffff1660000361146f5760405162461bcd60e51b8152602060048201526002602482015261042560f41b60448201526064016113d1565b60408051600280825260608201835260009260208301908036833701905050905083816000815181106114a4576114a461243e565b602002602001019063ffffffff16908163ffffffff16815250506000816001815181106114d3576114d361243e565b602002602001019063ffffffff16908163ffffffff1681525050600080866001600160a01b031663883bdbfd846040518263ffffffff1660e01b815260040161151c9190612454565b600060405180830381865afa158015611539573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526115619190810190612567565b9150915060008260008151811061157a5761157a61243e565b6020026020010151836001815181106115955761159561243e565b60200260200101516115a79190612633565b90506000826000815181106115be576115be61243e565b6020026020010151836001815181106115d9576115d961243e565b60200260200101516115eb9190612660565b90506115fd63ffffffff891683612687565b965060008260060b128015611623575061161d63ffffffff8916836126c5565b60060b15155b156116365786611632816126e7565b9750505b600061164f6001600160a01b0363ffffffff8b1661270a565b905061166c640100000000600160c01b03602084901b168261273c565b96505050505050509250929050565b60008061168786611ca2565b90506001600160801b036001600160a01b0382161161170d5760006116b56001600160a01b038316806122c1565b9050836001600160a01b0316856001600160a01b0316106116ed576116e8600160c01b876001600160801b031683611fc5565b611705565b61170581876001600160801b0316600160c01b611fc5565b925050611780565b600061172c6001600160a01b0383168068010000000000000000611fc5565b9050836001600160a01b0316856001600160a01b0316106117645761175f600160801b876001600160801b031683611fc5565b61177c565b61177c81876001600160801b0316600160801b611fc5565b9250505b50949350505050565b6000816001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156117c9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117ed919061219b565b92915050565b600080806000198587098587029250828110838203039150508060000361182d5783828161182357611823612344565b0492505050610df0565b80841161183957600080fd5b60008486880960026001871981018816978890046003810283188082028403028082028403028082028403028082028403028082028403029081029092039091026000889003889004909101858311909403939093029303949094049190911702949350505050565b604080516001600160a01b0385811660248301528481166044830152606480830185905283518084039091018152608490920183526020820180516001600160e01b03166323b872dd60e01b17905291516000928392908816916119069190612762565b6000604051808303816000865af19150503d8060008114611943576040519150601f19603f3d011682016040523d82523d6000602084013e611948565b606091505b50915091508180156119725750805115806119725750808060200190518101906119729190612791565b6110f95760405162461bcd60e51b815260206004820152600360248201526229aa2360e91b60448201526064016113d1565b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b031663095ea7b360e01b1790529151600092839290871691611a009190612762565b6000604051808303816000865af19150503d8060008114611a3d576040519150601f19603f3d011682016040523d82523d6000602084013e611a42565b606091505b5091509150818015611a6c575080511580611a6c575080806020019051810190611a6c9190612791565b611a9d5760405162461bcd60e51b8152602060048201526002602482015261534160f01b60448201526064016113d1565b5050505050565b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b031663a9059cbb60e01b1790529151600092839290871691611b009190612762565b6000604051808303816000865af19150503d8060008114611b3d576040519150601f19603f3d011682016040523d82523d6000602084013e611b42565b606091505b5091509150818015611b6c575080511580611b6c575080806020019051810190611b6c9190612791565b611a9d5760405162461bcd60e51b815260206004820152600260248201526114d560f21b60448201526064016113d1565b600080826001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa158015611bde573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c0291906123c5565b505092509250506000821315611c4b5760405162461bcd60e51b815260206004820152600e60248201526d29b2b8bab2b731b2b9102237bbb760911b60448201526064016113d1565b610e10611c588242612415565b11611c9d5760405162461bcd60e51b815260206004820152601560248201527423b930b1b2902832b934b7b2102737ba1027bb32b960591b60448201526064016113d1565b505050565b60008060008360020b12611cb9578260020b611cc1565b8260020b6000035b9050620d89e8811115611ce7576040516315e4079d60e11b815260040160405180910390fd5b600081600116600003611cfe57600160801b611d10565b6ffffcb933bd6fad37aa2d162d1a5940015b70ffffffffffffffffffffffffffffffffff1690506002821615611d44576ffff97272373d413259a46990580e213a0260801c5b6004821615611d63576ffff2e50f5f656932ef12357cf3c7fdcc0260801c5b6008821615611d82576fffe5caca7e10e4e61c3624eaa0941cd00260801c5b6010821615611da1576fffcb9843d60f6159c9db58835c9266440260801c5b6020821615611dc0576fff973b41fa98c081472e6896dfb254c00260801c5b6040821615611ddf576fff2ea16466c96a3843ec78b326b528610260801c5b6080821615611dfe576ffe5dee046a99a2a811c461f1969c30530260801c5b610100821615611e1e576ffcbe86c7900a88aedcffc83b479aa3a40260801c5b610200821615611e3e576ff987a7253ac413176f2b074cf7815e540260801c5b610400821615611e5e576ff3392b0822b70005940c7a398e4b70f30260801c5b610800821615611e7e576fe7159475a2c29b7443b29c7fa6e889d90260801c5b611000821615611e9e576fd097f3bdfd2022b8845ad8f792aa58250260801c5b612000821615611ebe576fa9f746462d870fdf8a65dc1f90e061e50260801c5b614000821615611ede576f70d869a156d2a1b890bb3df62baf32f70260801c5b618000821615611efe576f31be135f97d08fd981231505542fcfa60260801c5b62010000821615611f1f576f09aa508b5b7a84e1c677de54f3e99bc90260801c5b62020000821615611f3f576e5d6af8dedb81196699c329225ee6040260801c5b62040000821615611f5e576d2216e584f5fa1ea926041bedfe980260801c5b62080000821615611f7b576b048a170391f7dc42444e8fa20260801c5b60008460020b1315611f9c578060001981611f9857611f98612344565b0490505b640100000000810615611fb0576001611fb3565b60005b60ff16602082901c0192505050919050565b6000808060001985870985870292508281108382030391505080600003611ffe5760008411611ff357600080fd5b508290049050610df0565b80841161200a57600080fd5b6000848688096000868103871696879004966002600389028118808a02820302808a02820302808a02820302808a02820302808a02820302808a02909103029181900381900460010186841190950394909402919094039290920491909117919091029150509392505050565b60006020828403121561208957600080fd5b5035919050565b6001600160a01b03811681146120a557600080fd5b50565b6000806000606084860312156120bd57600080fd5b83356120c881612090565b95602085013595506040909401359392505050565b8060020b81146120a557600080fd5b6000602082840312156120fe57600080fd5b8135610df0816120dd565b60ff811681146120a557600080fd5b60008060006060848603121561212d57600080fd5b83359250602084013561213f81612109565b9150604084013561214f816120dd565b809150509250925092565b60006020828403121561216c57600080fd5b8135610df081612090565b6000806040838503121561218a57600080fd5b505080516020909101519092909150565b6000602082840312156121ad57600080fd5b8151610df081612109565b634e487b7160e01b600052601160045260246000fd5b600181815b808511156122095781600019048211156121ef576121ef6121b8565b808516156121fc57918102915b93841c93908002906121d3565b509250929050565b600082612220575060016117ed565b8161222d575060006117ed565b8160018114612243576002811461224d57612269565b60019150506117ed565b60ff84111561225e5761225e6121b8565b50506001821b6117ed565b5060208310610133831016604e8410600b841016171561228c575081810a6117ed565b61229683836121ce565b80600019048211156122aa576122aa6121b8565b029392505050565b6000610df060ff841683612211565b80820281158282048414176117ed576117ed6121b8565b60ff81811683821601908111156117ed576117ed6121b8565b60006020828403121561230357600080fd5b5051919050565b60006020828403121561231c57600080fd5b8151610df0816120dd565b60006020828403121561233957600080fd5b8151610df081612090565b634e487b7160e01b600052601260045260246000fd5b60008261236957612369612344565b500490565b60006020828403121561238057600080fd5b815162ffffff81168114610df057600080fd5b808201808211156117ed576117ed6121b8565b805169ffffffffffffffffffff811681146123c057600080fd5b919050565b600080600080600060a086880312156123dd57600080fd5b6123e6866123a6565b9450602086015193506040860151925060608601519150612409608087016123a6565b90509295509295909350565b818103818111156117ed576117ed6121b8565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b6020808252825182820181905260009190848201906040850190845b8181101561249257835163ffffffff1683529284019291840191600101612470565b50909695505050505050565b604051601f8201601f1916810167ffffffffffffffff811182821017156124c7576124c7612428565b604052919050565b600067ffffffffffffffff8211156124e9576124e9612428565b5060051b60200190565b600082601f83011261250457600080fd5b81516020612519612514836124cf565b61249e565b82815260059290921b8401810191818101908684111561253857600080fd5b8286015b8481101561255c57805161254f81612090565b835291830191830161253c565b509695505050505050565b6000806040838503121561257a57600080fd5b825167ffffffffffffffff8082111561259257600080fd5b818501915085601f8301126125a657600080fd5b815160206125b6612514836124cf565b82815260059290921b840181019181810190898411156125d557600080fd5b948201945b838610156126035785518060060b81146125f45760008081fd5b825294820194908201906125da565b9188015191965090935050508082111561261c57600080fd5b50612629858286016124f3565b9150509250929050565b600682810b9082900b03667fffffffffffff198112667fffffffffffff821317156117ed576117ed6121b8565b6001600160a01b03828116828216039080821115612680576126806121b8565b5092915050565b60008160060b8360060b8061269e5761269e612344565b667fffffffffffff198214600019821416156126bc576126bc6121b8565b90059392505050565b60008260060b806126d8576126d8612344565b808360060b0791505092915050565b60008160020b627fffff198103612700576127006121b8565b6000190192915050565b6001600160c01b03828116828216818102831692918115828504821417612733576127336121b8565b50505092915050565b60006001600160c01b038381168061275657612756612344565b92169190910492915050565b6000825160005b818110156127835760208186018101518583015201612769565b506000920191825250919050565b6000602082840312156127a357600080fd5b81518015158114610df057600080fdfea26469706673582212200757a30d8a504064800f2b3f1a68063e0220d287a88443394dd288d5504a33e864736f6c63430008130033000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435740000000000000000000000000b2c639c533813f4aa9d7837caf62653d097ff85000000000000000000000000371ead81c9102c9bf4874a9075ffff170f2ee3890000000000000000000000000215a3012611f9d9fe1590fb16c58e4920d9276d00000000000000000000000016a9fa2fda030272ce99b29cf780dfa30361e0f30000000000000000000000000000000000000000000000000000000000015180000000000000000000000000e3e123ed9fec48a6f40a8ac7be9afeddad80f146000000000000000000000000e592427a0aece92de3edee1f18e0157c05861564

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106101005760003560e01c80635c1bba38116100975780639ca2f8c6116100665780639ca2f8c614610291578063bf56c3fb146102a4578063f4f7fd25146102ac578063f54c42d7146102d257600080fd5b80635c1bba381461022857806375cdf6491461024f5780638c60c71c1461027657806398d5fdca1461028957600080fd5b806338da412e116100d357806338da412e146101b15780634562aee3146101d25780635001f3b5146101f9578063598790991461022057600080fd5b806316f0115b146101055780631f21f9af1461014957806330e005961461015c57806335faa4161461018a575b600080fd5b61012c7f0000000000000000000000000215a3012611f9d9fe1590fb16c58e4920d9276d81565b6040516001600160a01b0390911681526020015b60405180910390f35b60005461012c906001600160a01b031681565b61016f61016a366004612077565b6102e7565b60408051938452602084019290925290820152606001610140565b61012c7f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d4357481565b6101c46101bf3660046120a8565b6103f0565b604051908152602001610140565b61012c7f00000000000000000000000016a9fa2fda030272ce99b29cf780dfa30361e0f381565b61012c7f0000000000000000000000000b2c639c533813f4aa9d7837caf62653d097ff8581565b6101c461048b565b61012c7f000000000000000000000000371ead81c9102c9bf4874a9075ffff170f2ee38981565b6101c47f000000000000000000000000000000000000000000000000000000000001518081565b6101c46102843660046120a8565b6106f3565b6101c4610927565b6101c461029f3660046120ec565b610b6d565b6101c4610c69565b6102bf6102ba366004612118565b610d29565b60405160029190910b8152602001610140565b6102e56102e036600461215a565b610df7565b005b600080600080807f000000000000000000000000e3e123ed9fec48a6f40a8ac7be9afeddad80f1466001600160a01b031663886c2978877f0000000000000000000000000215a3012611f9d9fe1590fb16c58e4920d9276d6040518363ffffffff1660e01b815260040161036e9291909182526001600160a01b0316602082015260400190565b6040805180830381865afa15801561038a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103ae9190612177565b915091507f00000000000000000000000000000000000000000000000000000000000000016103de5780826103e1565b81815b90979096509294509192505050565b60007f92f64ca637d023f354075a4be751b169c1a8a9ccb6d33cdd0cb35205439957278360405161042391815260200190565b60405180910390a1610436848385610f6d565b6104837f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435748585857f0000000000000000000000000215a3012611f9d9fe1590fb16c58e4920d9276d611101565b949350505050565b6000806104f97f00000000000000000000000016a9fa2fda030272ce99b29cf780dfa30361e0f37f000000000000000000000000371ead81c9102c9bf4874a9075ffff170f2ee3897f00000000000000000000000000000000000000000000000000000000000151806112ea565b9050600061052a7f0000000000000000000000000215a3012611f9d9fe1590fb16c58e4920d9276d62015180611431565b5090506000610607827f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435746001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015610591573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105b5919061219b565b6105c090600a6122b2565b7f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435747f0000000000000000000000000b2c639c533813f4aa9d7837caf62653d097ff8561167b565b905060007f0000000000000000000000000b2c639c533813f4aa9d7837caf62653d097ff856001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015610669573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061068d919061219b565b905060006106ba7f00000000000000000000000016a9fa2fda030272ce99b29cf780dfa30361e0f3611789565b90506106e96106c986856122c1565b6106d383856122d8565b6106de90600a6122b2565b620f424091906117f3565b9550505050505090565b600080546001600160a01b0316158015906107885750610711610927565b60008054906101000a90046001600160a01b03166001600160a01b031663018a25e86040518163ffffffff1660e01b8152600401602060405180830381865afa158015610762573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061078691906122f1565b105b15610892576107b97f0000000000000000000000000b2c639c533813f4aa9d7837caf62653d097ff853330866118a2565b6000546107f1907f0000000000000000000000000b2c639c533813f4aa9d7837caf62653d097ff85906001600160a01b0316856119a4565b6000546040516369ae990b60e01b8152600481018590526001600160a01b03909116906369ae990b906024016020604051808303816000875af115801561083c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061086091906122f1565b905061088d7f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435743383611aa4565b6108ed565b61089d848484610f6d565b6108ea847f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d4357485857f0000000000000000000000000215a3012611f9d9fe1590fb16c58e4920d9276d611101565b90505b6040518381527f4e08ba899977cf7d4c2964bce71c6b9a7ef76ee5166a4c1249a1e08016e33ef19060200160405180910390a19392505050565b60405163040a5dc160e01b81526001600160a01b037f0000000000000000000000000215a3012611f9d9fe1590fb16c58e4920d9276d8116600483015260009182917f000000000000000000000000e3e123ed9fec48a6f40a8ac7be9afeddad80f146169063040a5dc190602401602060405180830381865afa1580156109b2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109d6919061230a565b90506000610a3c827f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435746001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015610591573d6000803e3d6000fd5b90506000610aab7f00000000000000000000000016a9fa2fda030272ce99b29cf780dfa30361e0f37f000000000000000000000000371ead81c9102c9bf4874a9075ffff170f2ee3897f00000000000000000000000000000000000000000000000000000000000151806112ea565b905060007f0000000000000000000000000b2c639c533813f4aa9d7837caf62653d097ff856001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015610b0d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b31919061219b565b90506000610b5e7f00000000000000000000000016a9fa2fda030272ce99b29cf780dfa30361e0f3611789565b90506106e96106c984866122c1565b600080610bd2837f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435746001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015610591573d6000803e3d6000fd5b905060007f0000000000000000000000000b2c639c533813f4aa9d7837caf62653d097ff856001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015610c34573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c58919061219b565b9050610483826106de83600a6122b2565b60405163040a5dc160e01b81526001600160a01b037f0000000000000000000000000215a3012611f9d9fe1590fb16c58e4920d9276d8116600483015260009182917f000000000000000000000000e3e123ed9fec48a6f40a8ac7be9afeddad80f146169063040a5dc190602401602060405180830381865afa158015610cf4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d18919061230a565b9050610d2381610b6d565b91505090565b6040516348bd18b760e01b81526004810184905260ff83166024820152600282900b60448201527f0000000000000000000000000000000000000000000000000000000000000001151560648201526000907f000000000000000000000000e3e123ed9fec48a6f40a8ac7be9afeddad80f1466001600160a01b0316906348bd18b790608401602060405180830381865afa158015610dcc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610483919061230a565b9392505050565b7f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435746001600160a01b031663baf4a3126040518163ffffffff1660e01b8152600401602060405180830381865afa158015610e55573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e799190612327565b6001600160a01b0316336001600160a01b031614158015610f2d57507f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435746001600160a01b0316638da5cb5b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610ef3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f179190612327565b6001600160a01b0316336001600160a01b031614155b15610f4b576040516338ae11af60e01b815260040160405180910390fd5b600080546001600160a01b0319166001600160a01b0392909216919091179055565b811580610f78575080155b15610f9657604051631f2a200560e01b815260040160405180910390fd5b6000836001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015610fd6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ffa919061219b565b61100590600a6122b2565b905060007f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435746001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015611067573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061108b919061219b565b61109690600a6122b2565b905060006110a484846122c1565b620f42406110b284886122c1565b6110bc91906122c1565b6110c6919061235a565b905062186a008111806110db5750620927c081105b156110f95760405163491dee2160e01b815260040160405180910390fd5b505050505050565b600061110f863330876118a2565b61113a867f000000000000000000000000e592427a0aece92de3edee1f18e0157c05861564866119a4565b6000604051806101000160405280886001600160a01b03168152602001876001600160a01b03168152602001846001600160a01b031663ddca3f436040518163ffffffff1660e01b8152600401602060405180830381865afa1580156111a4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111c8919061236e565b62ffffff1681523360208201526040016111e461038442612393565b8152602080820188905260408083018890526000606093840152805163414bf38960e01b815284516001600160a01b03908116600483015292850151831660248201529084015162ffffff16604482015291830151811660648301526080830151608483015260a083015160a483015260c083015160c483015260e0830151811660e48301529192507f000000000000000000000000e592427a0aece92de3edee1f18e0157c058615649091169063414bf38990610104016020604051808303816000875af11580156112bb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112df91906122f1565b979650505050505050565b60006001600160a01b038316156113045761130483611b9d565b6000806000866001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa158015611347573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061136b91906123c5565b50935050925069ffffffffffffffffffff16925060008213801561138e57508215155b801561139957508015155b6113da5760405162461bcd60e51b815260206004820152600d60248201526c496e76616c696420507269636560981b60448201526064015b60405180910390fd5b841561142757846113eb8242612415565b11156114275760405162461bcd60e51b815260206004820152600b60248201526a5374616c6520507269636560a81b60448201526064016113d1565b5095945050505050565b6000808263ffffffff1660000361146f5760405162461bcd60e51b8152602060048201526002602482015261042560f41b60448201526064016113d1565b60408051600280825260608201835260009260208301908036833701905050905083816000815181106114a4576114a461243e565b602002602001019063ffffffff16908163ffffffff16815250506000816001815181106114d3576114d361243e565b602002602001019063ffffffff16908163ffffffff1681525050600080866001600160a01b031663883bdbfd846040518263ffffffff1660e01b815260040161151c9190612454565b600060405180830381865afa158015611539573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526115619190810190612567565b9150915060008260008151811061157a5761157a61243e565b6020026020010151836001815181106115955761159561243e565b60200260200101516115a79190612633565b90506000826000815181106115be576115be61243e565b6020026020010151836001815181106115d9576115d961243e565b60200260200101516115eb9190612660565b90506115fd63ffffffff891683612687565b965060008260060b128015611623575061161d63ffffffff8916836126c5565b60060b15155b156116365786611632816126e7565b9750505b600061164f6001600160a01b0363ffffffff8b1661270a565b905061166c640100000000600160c01b03602084901b168261273c565b96505050505050509250929050565b60008061168786611ca2565b90506001600160801b036001600160a01b0382161161170d5760006116b56001600160a01b038316806122c1565b9050836001600160a01b0316856001600160a01b0316106116ed576116e8600160c01b876001600160801b031683611fc5565b611705565b61170581876001600160801b0316600160c01b611fc5565b925050611780565b600061172c6001600160a01b0383168068010000000000000000611fc5565b9050836001600160a01b0316856001600160a01b0316106117645761175f600160801b876001600160801b031683611fc5565b61177c565b61177c81876001600160801b0316600160801b611fc5565b9250505b50949350505050565b6000816001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156117c9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117ed919061219b565b92915050565b600080806000198587098587029250828110838203039150508060000361182d5783828161182357611823612344565b0492505050610df0565b80841161183957600080fd5b60008486880960026001871981018816978890046003810283188082028403028082028403028082028403028082028403028082028403029081029092039091026000889003889004909101858311909403939093029303949094049190911702949350505050565b604080516001600160a01b0385811660248301528481166044830152606480830185905283518084039091018152608490920183526020820180516001600160e01b03166323b872dd60e01b17905291516000928392908816916119069190612762565b6000604051808303816000865af19150503d8060008114611943576040519150601f19603f3d011682016040523d82523d6000602084013e611948565b606091505b50915091508180156119725750805115806119725750808060200190518101906119729190612791565b6110f95760405162461bcd60e51b815260206004820152600360248201526229aa2360e91b60448201526064016113d1565b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b031663095ea7b360e01b1790529151600092839290871691611a009190612762565b6000604051808303816000865af19150503d8060008114611a3d576040519150601f19603f3d011682016040523d82523d6000602084013e611a42565b606091505b5091509150818015611a6c575080511580611a6c575080806020019051810190611a6c9190612791565b611a9d5760405162461bcd60e51b8152602060048201526002602482015261534160f01b60448201526064016113d1565b5050505050565b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b031663a9059cbb60e01b1790529151600092839290871691611b009190612762565b6000604051808303816000865af19150503d8060008114611b3d576040519150601f19603f3d011682016040523d82523d6000602084013e611b42565b606091505b5091509150818015611b6c575080511580611b6c575080806020019051810190611b6c9190612791565b611a9d5760405162461bcd60e51b815260206004820152600260248201526114d560f21b60448201526064016113d1565b600080826001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa158015611bde573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c0291906123c5565b505092509250506000821315611c4b5760405162461bcd60e51b815260206004820152600e60248201526d29b2b8bab2b731b2b9102237bbb760911b60448201526064016113d1565b610e10611c588242612415565b11611c9d5760405162461bcd60e51b815260206004820152601560248201527423b930b1b2902832b934b7b2102737ba1027bb32b960591b60448201526064016113d1565b505050565b60008060008360020b12611cb9578260020b611cc1565b8260020b6000035b9050620d89e8811115611ce7576040516315e4079d60e11b815260040160405180910390fd5b600081600116600003611cfe57600160801b611d10565b6ffffcb933bd6fad37aa2d162d1a5940015b70ffffffffffffffffffffffffffffffffff1690506002821615611d44576ffff97272373d413259a46990580e213a0260801c5b6004821615611d63576ffff2e50f5f656932ef12357cf3c7fdcc0260801c5b6008821615611d82576fffe5caca7e10e4e61c3624eaa0941cd00260801c5b6010821615611da1576fffcb9843d60f6159c9db58835c9266440260801c5b6020821615611dc0576fff973b41fa98c081472e6896dfb254c00260801c5b6040821615611ddf576fff2ea16466c96a3843ec78b326b528610260801c5b6080821615611dfe576ffe5dee046a99a2a811c461f1969c30530260801c5b610100821615611e1e576ffcbe86c7900a88aedcffc83b479aa3a40260801c5b610200821615611e3e576ff987a7253ac413176f2b074cf7815e540260801c5b610400821615611e5e576ff3392b0822b70005940c7a398e4b70f30260801c5b610800821615611e7e576fe7159475a2c29b7443b29c7fa6e889d90260801c5b611000821615611e9e576fd097f3bdfd2022b8845ad8f792aa58250260801c5b612000821615611ebe576fa9f746462d870fdf8a65dc1f90e061e50260801c5b614000821615611ede576f70d869a156d2a1b890bb3df62baf32f70260801c5b618000821615611efe576f31be135f97d08fd981231505542fcfa60260801c5b62010000821615611f1f576f09aa508b5b7a84e1c677de54f3e99bc90260801c5b62020000821615611f3f576e5d6af8dedb81196699c329225ee6040260801c5b62040000821615611f5e576d2216e584f5fa1ea926041bedfe980260801c5b62080000821615611f7b576b048a170391f7dc42444e8fa20260801c5b60008460020b1315611f9c578060001981611f9857611f98612344565b0490505b640100000000810615611fb0576001611fb3565b60005b60ff16602082901c0192505050919050565b6000808060001985870985870292508281108382030391505080600003611ffe5760008411611ff357600080fd5b508290049050610df0565b80841161200a57600080fd5b6000848688096000868103871696879004966002600389028118808a02820302808a02820302808a02820302808a02820302808a02820302808a02909103029181900381900460010186841190950394909402919094039290920491909117919091029150509392505050565b60006020828403121561208957600080fd5b5035919050565b6001600160a01b03811681146120a557600080fd5b50565b6000806000606084860312156120bd57600080fd5b83356120c881612090565b95602085013595506040909401359392505050565b8060020b81146120a557600080fd5b6000602082840312156120fe57600080fd5b8135610df0816120dd565b60ff811681146120a557600080fd5b60008060006060848603121561212d57600080fd5b83359250602084013561213f81612109565b9150604084013561214f816120dd565b809150509250925092565b60006020828403121561216c57600080fd5b8135610df081612090565b6000806040838503121561218a57600080fd5b505080516020909101519092909150565b6000602082840312156121ad57600080fd5b8151610df081612109565b634e487b7160e01b600052601160045260246000fd5b600181815b808511156122095781600019048211156121ef576121ef6121b8565b808516156121fc57918102915b93841c93908002906121d3565b509250929050565b600082612220575060016117ed565b8161222d575060006117ed565b8160018114612243576002811461224d57612269565b60019150506117ed565b60ff84111561225e5761225e6121b8565b50506001821b6117ed565b5060208310610133831016604e8410600b841016171561228c575081810a6117ed565b61229683836121ce565b80600019048211156122aa576122aa6121b8565b029392505050565b6000610df060ff841683612211565b80820281158282048414176117ed576117ed6121b8565b60ff81811683821601908111156117ed576117ed6121b8565b60006020828403121561230357600080fd5b5051919050565b60006020828403121561231c57600080fd5b8151610df0816120dd565b60006020828403121561233957600080fd5b8151610df081612090565b634e487b7160e01b600052601260045260246000fd5b60008261236957612369612344565b500490565b60006020828403121561238057600080fd5b815162ffffff81168114610df057600080fd5b808201808211156117ed576117ed6121b8565b805169ffffffffffffffffffff811681146123c057600080fd5b919050565b600080600080600060a086880312156123dd57600080fd5b6123e6866123a6565b9450602086015193506040860151925060608601519150612409608087016123a6565b90509295509295909350565b818103818111156117ed576117ed6121b8565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b6020808252825182820181905260009190848201906040850190845b8181101561249257835163ffffffff1683529284019291840191600101612470565b50909695505050505050565b604051601f8201601f1916810167ffffffffffffffff811182821017156124c7576124c7612428565b604052919050565b600067ffffffffffffffff8211156124e9576124e9612428565b5060051b60200190565b600082601f83011261250457600080fd5b81516020612519612514836124cf565b61249e565b82815260059290921b8401810191818101908684111561253857600080fd5b8286015b8481101561255c57805161254f81612090565b835291830191830161253c565b509695505050505050565b6000806040838503121561257a57600080fd5b825167ffffffffffffffff8082111561259257600080fd5b818501915085601f8301126125a657600080fd5b815160206125b6612514836124cf565b82815260059290921b840181019181810190898411156125d557600080fd5b948201945b838610156126035785518060060b81146125f45760008081fd5b825294820194908201906125da565b9188015191965090935050508082111561261c57600080fd5b50612629858286016124f3565b9150509250929050565b600682810b9082900b03667fffffffffffff198112667fffffffffffff821317156117ed576117ed6121b8565b6001600160a01b03828116828216039080821115612680576126806121b8565b5092915050565b60008160060b8360060b8061269e5761269e612344565b667fffffffffffff198214600019821416156126bc576126bc6121b8565b90059392505050565b60008260060b806126d8576126d8612344565b808360060b0791505092915050565b60008160020b627fffff198103612700576127006121b8565b6000190192915050565b6001600160c01b03828116828216818102831692918115828504821417612733576127336121b8565b50505092915050565b60006001600160c01b038381168061275657612756612344565b92169190910492915050565b6000825160005b818110156127835760208186018101518583015201612769565b506000920191825250919050565b6000602082840312156127a357600080fd5b81518015158114610df057600080fdfea26469706673582212200757a30d8a504064800f2b3f1a68063e0220d287a88443394dd288d5504a33e864736f6c63430008130033

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

000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435740000000000000000000000000b2c639c533813f4aa9d7837caf62653d097ff85000000000000000000000000371ead81c9102c9bf4874a9075ffff170f2ee3890000000000000000000000000215a3012611f9d9fe1590fb16c58e4920d9276d00000000000000000000000016a9fa2fda030272ce99b29cf780dfa30361e0f30000000000000000000000000000000000000000000000000000000000015180000000000000000000000000e3e123ed9fec48a6f40a8ac7be9afeddad80f146000000000000000000000000e592427a0aece92de3edee1f18e0157c05861564

-----Decoded View---------------
Arg [0] : _sweep (address): 0xB88a5Ac00917a02d82c7cd6CEBd73E2852d43574
Arg [1] : _base (address): 0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85
Arg [2] : _sequencer (address): 0x371EAD81c9102C9BF4874A9075FFFf170F2Ee389
Arg [3] : _pool (address): 0x0215a3012611f9D9fe1590fb16C58E4920D9276D
Arg [4] : _oracleBase (address): 0x16a9FA2FDa030272Ce99B29CF780dFA30361E0f3
Arg [5] : _oracleBaseUpdateFrequency (uint256): 86400
Arg [6] : _liquidityHelper (address): 0xe3E123ED9fec48a6f40A8aC7bE9afEDDAD80F146
Arg [7] : _router (address): 0xE592427A0AEce92De3Edee1F18E0157C05861564

-----Encoded View---------------
8 Constructor Arguments found :
Arg [0] : 000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d43574
Arg [1] : 0000000000000000000000000b2c639c533813f4aa9d7837caf62653d097ff85
Arg [2] : 000000000000000000000000371ead81c9102c9bf4874a9075ffff170f2ee389
Arg [3] : 0000000000000000000000000215a3012611f9d9fe1590fb16c58e4920d9276d
Arg [4] : 00000000000000000000000016a9fa2fda030272ce99b29cf780dfa30361e0f3
Arg [5] : 0000000000000000000000000000000000000000000000000000000000015180
Arg [6] : 000000000000000000000000e3e123ed9fec48a6f40a8ac7be9afeddad80f146
Arg [7] : 000000000000000000000000e592427a0aece92de3edee1f18e0157c05861564


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

Validator Index Block Amount
View All Withdrawals

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