ETH Price: $2,390.17 (-3.54%)

Contract

0x4AC36E1Fa7daBeFEc885f30B163c571080b2c335
 
Transaction Hash
Method
Block
From
To
Transfer Ownersh...200647502024-06-10 23:36:35114 days ago1718062595IN
0x4AC36E1F...080b2c335
0 ETH0.0003502111.39020048
Set Token Slippa...198695962024-05-14 17:03:59141 days ago1715706239IN
0x4AC36E1F...080b2c335
0 ETH0.0005048810.56833627
Set Whitelist Cu...198695962024-05-14 17:03:59141 days ago1715706239IN
0x4AC36E1F...080b2c335
0 ETH0.0006412610.56833627
Set Whitelist V3...198695962024-05-14 17:03:59141 days ago1715706239IN
0x4AC36E1F...080b2c335
0 ETH0.0005788410.56833627
0x60e06040198695962024-05-14 17:03:59141 days ago1715706239IN
 Create: SwapManager
0 ETH0.0214644410.56833627

Latest 25 internal transactions (View All)

Advanced mode:
Parent Transaction Hash Block From To
208766302024-10-02 8:30:4721 hrs ago1727857847
0x4AC36E1F...080b2c335
0.29636713 ETH
208766302024-10-02 8:30:4721 hrs ago1727857847
0x4AC36E1F...080b2c335
0.29636713 ETH
208562022024-09-29 12:09:233 days ago1727611763
0x4AC36E1F...080b2c335
12.13358213 ETH
208562022024-09-29 12:09:233 days ago1727611763
0x4AC36E1F...080b2c335
12.13358213 ETH
208506942024-09-28 17:41:474 days ago1727545307
0x4AC36E1F...080b2c335
0.00099937 ETH
208506942024-09-28 17:41:474 days ago1727545307
0x4AC36E1F...080b2c335
0.00099937 ETH
208505232024-09-28 17:07:114 days ago1727543231
0x4AC36E1F...080b2c335
0.00999414 ETH
208505232024-09-28 17:07:114 days ago1727543231
0x4AC36E1F...080b2c335
0.00999414 ETH
208461812024-09-28 2:35:115 days ago1727490911
0x4AC36E1F...080b2c335
9.86607414 ETH
208461812024-09-28 2:35:115 days ago1727490911
0x4AC36E1F...080b2c335
9.86607414 ETH
207842852024-09-19 11:16:4713 days ago1726744607
0x4AC36E1F...080b2c335
3.2389147 ETH
207842852024-09-19 11:16:4713 days ago1726744607
0x4AC36E1F...080b2c335
3.2389147 ETH
207813462024-09-19 1:26:2314 days ago1726709183
0x4AC36E1F...080b2c335
6.64725898 ETH
207813462024-09-19 1:26:2314 days ago1726709183
0x4AC36E1F...080b2c335
6.64725898 ETH
207643602024-09-16 16:26:4716 days ago1726504007
0x4AC36E1F...080b2c335
0.80489681 ETH
207643602024-09-16 16:26:4716 days ago1726504007
0x4AC36E1F...080b2c335
0.80489681 ETH
207321122024-09-12 4:21:3521 days ago1726114895
0x4AC36E1F...080b2c335
0.11917251 ETH
207321122024-09-12 4:21:3521 days ago1726114895
0x4AC36E1F...080b2c335
0.11917251 ETH
207183612024-09-10 6:15:1122 days ago1725948911
0x4AC36E1F...080b2c335
0.89827273 ETH
207183612024-09-10 6:15:1122 days ago1725948911
0x4AC36E1F...080b2c335
0.89827273 ETH
207114522024-09-09 7:05:5923 days ago1725865559
0x4AC36E1F...080b2c335
17.45411942 ETH
207114522024-09-09 7:05:5923 days ago1725865559
0x4AC36E1F...080b2c335
17.45411942 ETH
207022722024-09-08 0:20:3525 days ago1725754835
0x4AC36E1F...080b2c335
40.00241807 ETH
207022722024-09-08 0:20:3525 days ago1725754835
0x4AC36E1F...080b2c335
40.00241807 ETH
207004932024-09-07 18:23:2325 days ago1725733403
0x4AC36E1F...080b2c335
0.71943825 ETH
View All Internal Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
SwapManager

Compiler Version
v0.8.21+commit.d9974bed

Optimization Enabled:
Yes with 200 runs

Other Settings:
shanghai EvmVersion
File 1 of 23 : SwapManager.sol
// SPDX-License-Identifier: MIT
pragma solidity =0.8.21;

import {TransferHelper} from "v3-periphery/libraries/TransferHelper.sol";
import {Ownable} from "oz/access/Ownable.sol";
import {Ownable2Step} from "oz/access/Ownable2Step.sol";
import {IERC20} from "oz/token/ERC20/IERC20.sol";
import {SafeERC20} from "oz/token/ERC20/utils/SafeERC20.sol";
import {SafeCast} from "oz/utils/math/SafeCast.sol";

import {IUniswapV3Pool} from "@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol";
import {ISwapRouter} from "v3-periphery/interfaces/ISwapRouter.sol";
import {ICurvePool} from "../interfaces/ICurvePool.sol";
import {IWETH9} from "../interfaces/IWETH9.sol";

import {TickMath} from "v3-core-0.8/libraries/TickMath.sol";
import {FullMath} from "v3-core-0.8/libraries/FullMath.sol";

error SwapManager__SlippageNotSet();
error SwapManager__ZeroAddress();
error SwapManager__NoLiquidity();
error SwapManager__InvalidPoolToken();
error SwapManager__NoPool(address tokenIn);
error SwapManager__MIN_TWAP_DURATION(uint32 duration);
error SwapManager__ExceedPercentage(uint256 given, uint256 max);
error SwapManager__SlippageExceeded(uint256 amountOut, uint256 minAmountOut);
error SwapManager__TooLittleRecieved(uint256 amountOut, uint256 minAmountOut);

contract SwapManager is Ownable2Step {
    using SafeERC20 for IERC20;
    using SafeCast for uint256;

    uint256 internal constant ZERO = 0;
    uint256 internal constant ONE = 1;
    uint256 internal constant MIN_DEADLINE = 30; // 30 seconds
    uint32 public constant MIN_TWAP_DURATION = 3_600;
    uint256 internal constant ONE_HUNDRED_PERCENT = 100_0000;
    uint256 internal constant MAX_SLIPPAGE = 5_00_00; //5%

    uint32 public twapDuration;

    address public immutable NULL;
    address public immutable WETH9;
    address public immutable v3SwapRouter;

    // token => pool
    mapping(address => address) public v3Pools;
    mapping(address => address) public curvePools;
    mapping(address => uint24) public slippage;

    event UniswapV3PoolUpdated(address token, address pool);
    event CurvePoolUpdated(address token, address pool);
    event TokenSlippageUpdated(address token, uint24 slippage);
    event TwapDurationUpdated(uint32 duration);

    constructor(address _intialOwner, address _weth9, address _null, address _v3SwapRouter) Ownable(_intialOwner) {
        if (_weth9 == address(0) || _v3SwapRouter == address(0) || _v3SwapRouter == address(0)) {
            revert SwapManager__ZeroAddress();
        }
        WETH9 = _weth9;
        NULL = _null;
        v3SwapRouter = _v3SwapRouter;
        twapDuration = MIN_TWAP_DURATION;
    }

    /**
     * @notice Swap tokens from the uniswap v3 pools.
     * @param tokenIn The input token address.
     * @param amountIn The amount of input tokens.
     * @return amountOut The amount of output tokens.
     */
    function swapUinv3(address tokenIn, uint256 amountIn, uint256 amountOutMinimum)
        public
        returns (uint256 amountOut)
    {
        if (amountOutMinimum == 0) revert SwapManager__NoLiquidity();

        address pool = _getV3Pool(tokenIn);
        uint256 deadline = block.timestamp + MIN_DEADLINE;
        uint24 poolFee = IUniswapV3Pool(pool).fee();

        TransferHelper.safeTransferFrom(tokenIn, msg.sender, address(this), amountIn);
        IERC20(tokenIn).forceApprove(v3SwapRouter, amountIn);
        amountOut = ISwapRouter(v3SwapRouter).exactInputSingle(
            ISwapRouter.ExactInputSingleParams({
                tokenIn: tokenIn,
                tokenOut: WETH9,
                fee: poolFee,
                recipient: address(this),
                deadline: deadline,
                amountIn: amountIn,
                amountOutMinimum: amountOutMinimum,
                sqrtPriceLimitX96: 0
            })
        );

        if (amountOut < amountOutMinimum) revert SwapManager__SlippageExceeded(amountOut, amountOutMinimum);

        // After the swap, the balance of WETH9 will always remain greater than 0
        IWETH9(WETH9).withdraw(IWETH9(WETH9).balanceOf(address(this)));
        amountOut = address(this).balance;
        TransferHelper.safeTransferETH(msg.sender, amountOut);
    }

    /**
     * @notice Swap tokens from the curve pools.
     * @param tokenIn The input token address.
     * @param amountIn The amount of input tokens.
     * @return amountOut The amount of output tokens.
     */
    function swapCurve(address tokenIn, uint256 amountIn, uint256 amountOutMinimum)
        public
        returns (uint256 amountOut)
    {
        if (amountOutMinimum == 0) revert SwapManager__NoLiquidity();
        address pool = _getCurvePool(tokenIn);

        TransferHelper.safeTransferFrom(tokenIn, msg.sender, address(this), amountIn);
        IERC20(tokenIn).forceApprove(pool, amountIn);

        (int128 _inIdx, int128 _outIdx) = _getCurveTokenIndex(pool, tokenIn);
        amountOut = ICurvePool(pool).exchange(_inIdx, _outIdx, amountIn, amountOutMinimum);

        if (amountOut < amountOutMinimum) revert SwapManager__SlippageExceeded(amountOut, amountOutMinimum);

        amountOut = address(this).balance;
        TransferHelper.safeTransferETH(msg.sender, amountOut);
    }

    // [internal functions]

    function _getV3Pool(address tokenIn) internal view returns (address pool) {
        pool = v3Pools[tokenIn];
        if (pool == address(0)) revert SwapManager__NoPool(tokenIn);
    }

    function _getCurvePool(address tokenIn) internal view returns (address pool) {
        pool = curvePools[tokenIn];
        if (pool == address(0)) revert SwapManager__NoPool(tokenIn);
    }

    function _getCurveTokenIndex(address pool, address tokenIn) internal view returns (int128 _inIdx, int128 _outIdx) {
        (address token0,) = _getCurvPoolTokens(pool);
        int128 _i0 = int128(int256(ZERO));
        int128 _i1 = int128(int256(ONE));
        return token0 == tokenIn ? (_i0, _i1) : (_i1, _i0);
    }

    function getMinimumAmount(address token, uint256 amount) public view returns (uint256) {
        if (slippage[token] == 0) revert SwapManager__SlippageNotSet();
        uint256 oneMinusSlippage = ONE_HUNDRED_PERCENT - slippage[token];
        return FullMath.mulDiv(amount, oneMinusSlippage, ONE_HUNDRED_PERCENT);
    }

    function _getCurvPoolTokens(address pool) internal view returns (address token0, address token1) {
        token0 = ICurvePool(pool).coins(ZERO);
        token1 = ICurvePool(pool).coins(ONE);
    }

    /// @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)
    {
        unchecked {
            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, ONE << 192)
                    : FullMath.mulDiv(ONE << 192, baseAmount, ratioX192);
            } else {
                uint256 ratioX128 = FullMath.mulDiv(sqrtRatioX96, sqrtRatioX96, ONE << 64);
                quoteAmount = baseToken < quoteToken
                    ? FullMath.mulDiv(ratioX128, baseAmount, ONE << 128)
                    : FullMath.mulDiv(ONE << 128, baseAmount, ratioX128);
            }
        }
    }

    // [view functions]

    /**
     * @dev Fetches virtual price of the curve pool and
     * estimates the amount of tokenOut to receive for a given amount of tokenIn using a Curve pool
     * @param amountIn The amount of input tokens
     * @param tokenIn The address of the input token
     * @return amountOut The estimated amount of output tokens
     */
    function estimateCurveAmountOut(uint256 amountIn, address tokenIn) public view returns (uint256 amountOut) {
        address pool = _getCurvePool(tokenIn);
        (int128 i, int128 j) = _getCurveTokenIndex(pool, tokenIn);
        amountOut = ICurvePool(pool).get_dy(i, j, amountIn);
    }

    /**
     * @dev Fetches time-weighted average price in ticks from Uniswap pool and
     * estimates the amount of tokenOut to receive for a given amount of tokenIn using a Uniswap V3 pool
     * @param amountIn The amount of input tokens
     * @param tokenIn The address of the input token
     * @param tokenOut The address of the output token
     * @return amountOut The estimated amount of output tokens
     */
    function estimateV3AmountOut(uint128 amountIn, address tokenIn, address tokenOut)
        public
        view
        returns (uint256 amountOut)
    {
        address pool = _getV3Pool(tokenIn);
        uint32 secondsAgo = twapDuration;
        uint32[] memory secondsAgos = new uint32[](2);
        secondsAgos[0] = secondsAgo; // secondsAgo
        secondsAgos[1] = 0;

        // int56 since tick * time = int24 * uint32
        // 56 = 24 + 32
        (int56[] memory tickCumulatives,) = IUniswapV3Pool(pool).observe(secondsAgos);

        int56 tickCumulativesDelta;
        unchecked {
            tickCumulativesDelta = tickCumulatives[1] - tickCumulatives[0];
        }

        // int56 / uint32 = int24
        int24 tick = int24(tickCumulativesDelta / int32(secondsAgo));
        // Always round to negative infinity
        /*
        int doesn't round down when it is negative

        int56 a = -3
        -3 / 10 = -3.3333... so round down to -4
        but we get
        a / 10 = -3

        so if tickCumulativeDelta < 0 and division has remainder, then round
        down
        */
        if (tickCumulativesDelta < 0 && (tickCumulativesDelta % int32(secondsAgo) != 0)) {
            unchecked {
                tick--;
            }
        }

        amountOut = _getQuoteAtTick(tick, amountIn, tokenIn, tokenOut);
    }

    // [setter functions]

    /**
     * @dev Sets the Uniswap V3 pool address for a given token along with the slippage tolerance
     * @param _token The address of the token
     * @param _pool The address of the Uniswap V3 pool
     * @param _slippage The slippage tolerance for the pool
     */
    function setWhitelistV3Pool(address _token, address _pool, uint24 _slippage) external onlyOwner {
        if (_token == address(0) || _pool == address(0)) revert SwapManager__ZeroAddress();
        if (_slippage > MAX_SLIPPAGE) revert SwapManager__ExceedPercentage(_slippage, MAX_SLIPPAGE);

        (address token0, address token1) = (IUniswapV3Pool(_pool).token0(), IUniswapV3Pool(_pool).token1());

        if (token0 != _token && token0 != WETH9) revert SwapManager__InvalidPoolToken();
        if (token1 != _token && token1 != WETH9) revert SwapManager__InvalidPoolToken();

        v3Pools[_token] = _pool;
        slippage[_token] = _slippage;
        emit UniswapV3PoolUpdated(_token, _pool);
    }

    /**
     * @dev Sets the Curve pool address for a given token along with the slippage tolerance
     * @param _token The address of the token
     * @param _pool The address of the Curve pool
     * @param _slippage The slippage tolerance for the pool
     */
    function setWhitelistCurvePool(address _token, address _pool, uint24 _slippage) external onlyOwner {
        if (_token == address(0) || _pool == address(0)) revert SwapManager__ZeroAddress();
        if (_slippage > MAX_SLIPPAGE) revert SwapManager__ExceedPercentage(_slippage, MAX_SLIPPAGE);

        (address token0, address token1) = _getCurvPoolTokens(_pool);

        if (token0 != _token && token0 != NULL) revert SwapManager__InvalidPoolToken();
        if (token1 != _token && token1 != NULL) revert SwapManager__InvalidPoolToken();

        curvePools[_token] = _pool;
        slippage[_token] = _slippage;
        emit CurvePoolUpdated(_token, _pool);
    }

    /**
     * @dev Sets the slippage tolerance for a given token
     * @param _token The address of the token
     * @param _slippage The slippage tolerance for the token
     */
    function setTokenSlippage(address _token, uint24 _slippage) external onlyOwner {
        if (_slippage > MAX_SLIPPAGE) revert SwapManager__ExceedPercentage(_slippage, MAX_SLIPPAGE);
        slippage[_token] = _slippage;
        emit TokenSlippageUpdated(_token, _slippage);
    }

    /**
     * @dev Sets the duration for time-weighted average price (TWAP) calculations
     * @param _duration The duration in seconds
     */
    function setTwapDuration(uint32 _duration) external onlyOwner {
        if (_duration < MIN_TWAP_DURATION) revert SwapManager__MIN_TWAP_DURATION(_duration);
        twapDuration = _duration;
        emit TwapDurationUpdated(_duration);
    }

    receive() external payable {}
}

File 2 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 3 of 23 : Ownable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)

pragma solidity ^0.8.20;

import {Context} from "../utils/Context.sol";

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

    /**
     * @dev The caller account is not authorized to perform an operation.
     */
    error OwnableUnauthorizedAccount(address account);

    /**
     * @dev The owner is not a valid owner account. (eg. `address(0)`)
     */
    error OwnableInvalidOwner(address owner);

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

    /**
     * @dev Initializes the contract setting the address provided by the deployer as the initial owner.
     */
    constructor(address initialOwner) {
        if (initialOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _transferOwnership(initialOwner);
    }

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

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

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        if (owner() != _msgSender()) {
            revert OwnableUnauthorizedAccount(_msgSender());
        }
    }

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

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        if (newOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _transferOwnership(newOwner);
    }

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

File 4 of 23 : Ownable2Step.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable2Step.sol)

pragma solidity ^0.8.20;

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

/**
 * @dev Contract module which provides access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * The initial owner is specified at deployment time in the constructor for `Ownable`. This
 * can later be changed with {transferOwnership} and {acceptOwnership}.
 *
 * This module is used through inheritance. It will make available all functions
 * from parent (Ownable).
 */
abstract contract Ownable2Step is Ownable {
    address private _pendingOwner;

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

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

    /**
     * @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual override onlyOwner {
        _pendingOwner = newOwner;
        emit OwnershipTransferStarted(owner(), newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual override {
        delete _pendingOwner;
        super._transferOwnership(newOwner);
    }

    /**
     * @dev The new owner accepts the ownership transfer.
     */
    function acceptOwnership() public virtual {
        address sender = _msgSender();
        if (pendingOwner() != sender) {
            revert OwnableUnauthorizedAccount(sender);
        }
        _transferOwnership(sender);
    }
}

File 5 of 23 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.20;

/**
 * @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 value of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

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

    /**
     * @dev Moves a `value` amount of 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 value) 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 a `value` amount of tokens 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 value) external returns (bool);

    /**
     * @dev Moves a `value` amount of tokens from `from` to `to` using the
     * allowance mechanism. `value` 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 value) external returns (bool);
}

File 6 of 23 : SafeERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.20;

import {IERC20} from "../IERC20.sol";
import {IERC20Permit} from "../extensions/IERC20Permit.sol";
import {Address} from "../../../utils/Address.sol";

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

    /**
     * @dev An operation with an ERC20 token failed.
     */
    error SafeERC20FailedOperation(address token);

    /**
     * @dev Indicates a failed `decreaseAllowance` request.
     */
    error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);

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

    /**
     * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
     * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
     */
    function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));
    }

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

    /**
     * @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
     * value, non-reverting calls are assumed to be successful.
     */
    function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
        unchecked {
            uint256 currentAllowance = token.allowance(address(this), spender);
            if (currentAllowance < requestedDecrease) {
                revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
            }
            forceApprove(token, spender, currentAllowance - requestedDecrease);
        }
    }

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

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

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

        bytes memory returndata = address(token).functionCall(data);
        if (returndata.length != 0 && !abi.decode(returndata, (bool))) {
            revert SafeERC20FailedOperation(address(token));
        }
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     *
     * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
     */
    function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false
        // and not revert is the subcall reverts.

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

File 7 of 23 : SafeCast.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/SafeCast.sol)
// This file was procedurally generated from scripts/generate/templates/SafeCast.js.

pragma solidity ^0.8.20;

/**
 * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow
 * checks.
 *
 * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can
 * easily result in undesired exploitation or bugs, since developers usually
 * assume that overflows raise errors. `SafeCast` restores this intuition by
 * reverting the transaction when such an operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 */
library SafeCast {
    /**
     * @dev Value doesn't fit in an uint of `bits` size.
     */
    error SafeCastOverflowedUintDowncast(uint8 bits, uint256 value);

    /**
     * @dev An int value doesn't fit in an uint of `bits` size.
     */
    error SafeCastOverflowedIntToUint(int256 value);

    /**
     * @dev Value doesn't fit in an int of `bits` size.
     */
    error SafeCastOverflowedIntDowncast(uint8 bits, int256 value);

    /**
     * @dev An uint value doesn't fit in an int of `bits` size.
     */
    error SafeCastOverflowedUintToInt(uint256 value);

    /**
     * @dev Returns the downcasted uint248 from uint256, reverting on
     * overflow (when the input is greater than largest uint248).
     *
     * Counterpart to Solidity's `uint248` operator.
     *
     * Requirements:
     *
     * - input must fit into 248 bits
     */
    function toUint248(uint256 value) internal pure returns (uint248) {
        if (value > type(uint248).max) {
            revert SafeCastOverflowedUintDowncast(248, value);
        }
        return uint248(value);
    }

    /**
     * @dev Returns the downcasted uint240 from uint256, reverting on
     * overflow (when the input is greater than largest uint240).
     *
     * Counterpart to Solidity's `uint240` operator.
     *
     * Requirements:
     *
     * - input must fit into 240 bits
     */
    function toUint240(uint256 value) internal pure returns (uint240) {
        if (value > type(uint240).max) {
            revert SafeCastOverflowedUintDowncast(240, value);
        }
        return uint240(value);
    }

    /**
     * @dev Returns the downcasted uint232 from uint256, reverting on
     * overflow (when the input is greater than largest uint232).
     *
     * Counterpart to Solidity's `uint232` operator.
     *
     * Requirements:
     *
     * - input must fit into 232 bits
     */
    function toUint232(uint256 value) internal pure returns (uint232) {
        if (value > type(uint232).max) {
            revert SafeCastOverflowedUintDowncast(232, value);
        }
        return uint232(value);
    }

    /**
     * @dev Returns the downcasted uint224 from uint256, reverting on
     * overflow (when the input is greater than largest uint224).
     *
     * Counterpart to Solidity's `uint224` operator.
     *
     * Requirements:
     *
     * - input must fit into 224 bits
     */
    function toUint224(uint256 value) internal pure returns (uint224) {
        if (value > type(uint224).max) {
            revert SafeCastOverflowedUintDowncast(224, value);
        }
        return uint224(value);
    }

    /**
     * @dev Returns the downcasted uint216 from uint256, reverting on
     * overflow (when the input is greater than largest uint216).
     *
     * Counterpart to Solidity's `uint216` operator.
     *
     * Requirements:
     *
     * - input must fit into 216 bits
     */
    function toUint216(uint256 value) internal pure returns (uint216) {
        if (value > type(uint216).max) {
            revert SafeCastOverflowedUintDowncast(216, value);
        }
        return uint216(value);
    }

    /**
     * @dev Returns the downcasted uint208 from uint256, reverting on
     * overflow (when the input is greater than largest uint208).
     *
     * Counterpart to Solidity's `uint208` operator.
     *
     * Requirements:
     *
     * - input must fit into 208 bits
     */
    function toUint208(uint256 value) internal pure returns (uint208) {
        if (value > type(uint208).max) {
            revert SafeCastOverflowedUintDowncast(208, value);
        }
        return uint208(value);
    }

    /**
     * @dev Returns the downcasted uint200 from uint256, reverting on
     * overflow (when the input is greater than largest uint200).
     *
     * Counterpart to Solidity's `uint200` operator.
     *
     * Requirements:
     *
     * - input must fit into 200 bits
     */
    function toUint200(uint256 value) internal pure returns (uint200) {
        if (value > type(uint200).max) {
            revert SafeCastOverflowedUintDowncast(200, value);
        }
        return uint200(value);
    }

    /**
     * @dev Returns the downcasted uint192 from uint256, reverting on
     * overflow (when the input is greater than largest uint192).
     *
     * Counterpart to Solidity's `uint192` operator.
     *
     * Requirements:
     *
     * - input must fit into 192 bits
     */
    function toUint192(uint256 value) internal pure returns (uint192) {
        if (value > type(uint192).max) {
            revert SafeCastOverflowedUintDowncast(192, value);
        }
        return uint192(value);
    }

    /**
     * @dev Returns the downcasted uint184 from uint256, reverting on
     * overflow (when the input is greater than largest uint184).
     *
     * Counterpart to Solidity's `uint184` operator.
     *
     * Requirements:
     *
     * - input must fit into 184 bits
     */
    function toUint184(uint256 value) internal pure returns (uint184) {
        if (value > type(uint184).max) {
            revert SafeCastOverflowedUintDowncast(184, value);
        }
        return uint184(value);
    }

    /**
     * @dev Returns the downcasted uint176 from uint256, reverting on
     * overflow (when the input is greater than largest uint176).
     *
     * Counterpart to Solidity's `uint176` operator.
     *
     * Requirements:
     *
     * - input must fit into 176 bits
     */
    function toUint176(uint256 value) internal pure returns (uint176) {
        if (value > type(uint176).max) {
            revert SafeCastOverflowedUintDowncast(176, value);
        }
        return uint176(value);
    }

    /**
     * @dev Returns the downcasted uint168 from uint256, reverting on
     * overflow (when the input is greater than largest uint168).
     *
     * Counterpart to Solidity's `uint168` operator.
     *
     * Requirements:
     *
     * - input must fit into 168 bits
     */
    function toUint168(uint256 value) internal pure returns (uint168) {
        if (value > type(uint168).max) {
            revert SafeCastOverflowedUintDowncast(168, value);
        }
        return uint168(value);
    }

    /**
     * @dev Returns the downcasted uint160 from uint256, reverting on
     * overflow (when the input is greater than largest uint160).
     *
     * Counterpart to Solidity's `uint160` operator.
     *
     * Requirements:
     *
     * - input must fit into 160 bits
     */
    function toUint160(uint256 value) internal pure returns (uint160) {
        if (value > type(uint160).max) {
            revert SafeCastOverflowedUintDowncast(160, value);
        }
        return uint160(value);
    }

    /**
     * @dev Returns the downcasted uint152 from uint256, reverting on
     * overflow (when the input is greater than largest uint152).
     *
     * Counterpart to Solidity's `uint152` operator.
     *
     * Requirements:
     *
     * - input must fit into 152 bits
     */
    function toUint152(uint256 value) internal pure returns (uint152) {
        if (value > type(uint152).max) {
            revert SafeCastOverflowedUintDowncast(152, value);
        }
        return uint152(value);
    }

    /**
     * @dev Returns the downcasted uint144 from uint256, reverting on
     * overflow (when the input is greater than largest uint144).
     *
     * Counterpart to Solidity's `uint144` operator.
     *
     * Requirements:
     *
     * - input must fit into 144 bits
     */
    function toUint144(uint256 value) internal pure returns (uint144) {
        if (value > type(uint144).max) {
            revert SafeCastOverflowedUintDowncast(144, value);
        }
        return uint144(value);
    }

    /**
     * @dev Returns the downcasted uint136 from uint256, reverting on
     * overflow (when the input is greater than largest uint136).
     *
     * Counterpart to Solidity's `uint136` operator.
     *
     * Requirements:
     *
     * - input must fit into 136 bits
     */
    function toUint136(uint256 value) internal pure returns (uint136) {
        if (value > type(uint136).max) {
            revert SafeCastOverflowedUintDowncast(136, value);
        }
        return uint136(value);
    }

    /**
     * @dev Returns the downcasted uint128 from uint256, reverting on
     * overflow (when the input is greater than largest uint128).
     *
     * Counterpart to Solidity's `uint128` operator.
     *
     * Requirements:
     *
     * - input must fit into 128 bits
     */
    function toUint128(uint256 value) internal pure returns (uint128) {
        if (value > type(uint128).max) {
            revert SafeCastOverflowedUintDowncast(128, value);
        }
        return uint128(value);
    }

    /**
     * @dev Returns the downcasted uint120 from uint256, reverting on
     * overflow (when the input is greater than largest uint120).
     *
     * Counterpart to Solidity's `uint120` operator.
     *
     * Requirements:
     *
     * - input must fit into 120 bits
     */
    function toUint120(uint256 value) internal pure returns (uint120) {
        if (value > type(uint120).max) {
            revert SafeCastOverflowedUintDowncast(120, value);
        }
        return uint120(value);
    }

    /**
     * @dev Returns the downcasted uint112 from uint256, reverting on
     * overflow (when the input is greater than largest uint112).
     *
     * Counterpart to Solidity's `uint112` operator.
     *
     * Requirements:
     *
     * - input must fit into 112 bits
     */
    function toUint112(uint256 value) internal pure returns (uint112) {
        if (value > type(uint112).max) {
            revert SafeCastOverflowedUintDowncast(112, value);
        }
        return uint112(value);
    }

    /**
     * @dev Returns the downcasted uint104 from uint256, reverting on
     * overflow (when the input is greater than largest uint104).
     *
     * Counterpart to Solidity's `uint104` operator.
     *
     * Requirements:
     *
     * - input must fit into 104 bits
     */
    function toUint104(uint256 value) internal pure returns (uint104) {
        if (value > type(uint104).max) {
            revert SafeCastOverflowedUintDowncast(104, value);
        }
        return uint104(value);
    }

    /**
     * @dev Returns the downcasted uint96 from uint256, reverting on
     * overflow (when the input is greater than largest uint96).
     *
     * Counterpart to Solidity's `uint96` operator.
     *
     * Requirements:
     *
     * - input must fit into 96 bits
     */
    function toUint96(uint256 value) internal pure returns (uint96) {
        if (value > type(uint96).max) {
            revert SafeCastOverflowedUintDowncast(96, value);
        }
        return uint96(value);
    }

    /**
     * @dev Returns the downcasted uint88 from uint256, reverting on
     * overflow (when the input is greater than largest uint88).
     *
     * Counterpart to Solidity's `uint88` operator.
     *
     * Requirements:
     *
     * - input must fit into 88 bits
     */
    function toUint88(uint256 value) internal pure returns (uint88) {
        if (value > type(uint88).max) {
            revert SafeCastOverflowedUintDowncast(88, value);
        }
        return uint88(value);
    }

    /**
     * @dev Returns the downcasted uint80 from uint256, reverting on
     * overflow (when the input is greater than largest uint80).
     *
     * Counterpart to Solidity's `uint80` operator.
     *
     * Requirements:
     *
     * - input must fit into 80 bits
     */
    function toUint80(uint256 value) internal pure returns (uint80) {
        if (value > type(uint80).max) {
            revert SafeCastOverflowedUintDowncast(80, value);
        }
        return uint80(value);
    }

    /**
     * @dev Returns the downcasted uint72 from uint256, reverting on
     * overflow (when the input is greater than largest uint72).
     *
     * Counterpart to Solidity's `uint72` operator.
     *
     * Requirements:
     *
     * - input must fit into 72 bits
     */
    function toUint72(uint256 value) internal pure returns (uint72) {
        if (value > type(uint72).max) {
            revert SafeCastOverflowedUintDowncast(72, value);
        }
        return uint72(value);
    }

    /**
     * @dev Returns the downcasted uint64 from uint256, reverting on
     * overflow (when the input is greater than largest uint64).
     *
     * Counterpart to Solidity's `uint64` operator.
     *
     * Requirements:
     *
     * - input must fit into 64 bits
     */
    function toUint64(uint256 value) internal pure returns (uint64) {
        if (value > type(uint64).max) {
            revert SafeCastOverflowedUintDowncast(64, value);
        }
        return uint64(value);
    }

    /**
     * @dev Returns the downcasted uint56 from uint256, reverting on
     * overflow (when the input is greater than largest uint56).
     *
     * Counterpart to Solidity's `uint56` operator.
     *
     * Requirements:
     *
     * - input must fit into 56 bits
     */
    function toUint56(uint256 value) internal pure returns (uint56) {
        if (value > type(uint56).max) {
            revert SafeCastOverflowedUintDowncast(56, value);
        }
        return uint56(value);
    }

    /**
     * @dev Returns the downcasted uint48 from uint256, reverting on
     * overflow (when the input is greater than largest uint48).
     *
     * Counterpart to Solidity's `uint48` operator.
     *
     * Requirements:
     *
     * - input must fit into 48 bits
     */
    function toUint48(uint256 value) internal pure returns (uint48) {
        if (value > type(uint48).max) {
            revert SafeCastOverflowedUintDowncast(48, value);
        }
        return uint48(value);
    }

    /**
     * @dev Returns the downcasted uint40 from uint256, reverting on
     * overflow (when the input is greater than largest uint40).
     *
     * Counterpart to Solidity's `uint40` operator.
     *
     * Requirements:
     *
     * - input must fit into 40 bits
     */
    function toUint40(uint256 value) internal pure returns (uint40) {
        if (value > type(uint40).max) {
            revert SafeCastOverflowedUintDowncast(40, value);
        }
        return uint40(value);
    }

    /**
     * @dev Returns the downcasted uint32 from uint256, reverting on
     * overflow (when the input is greater than largest uint32).
     *
     * Counterpart to Solidity's `uint32` operator.
     *
     * Requirements:
     *
     * - input must fit into 32 bits
     */
    function toUint32(uint256 value) internal pure returns (uint32) {
        if (value > type(uint32).max) {
            revert SafeCastOverflowedUintDowncast(32, value);
        }
        return uint32(value);
    }

    /**
     * @dev Returns the downcasted uint24 from uint256, reverting on
     * overflow (when the input is greater than largest uint24).
     *
     * Counterpart to Solidity's `uint24` operator.
     *
     * Requirements:
     *
     * - input must fit into 24 bits
     */
    function toUint24(uint256 value) internal pure returns (uint24) {
        if (value > type(uint24).max) {
            revert SafeCastOverflowedUintDowncast(24, value);
        }
        return uint24(value);
    }

    /**
     * @dev Returns the downcasted uint16 from uint256, reverting on
     * overflow (when the input is greater than largest uint16).
     *
     * Counterpart to Solidity's `uint16` operator.
     *
     * Requirements:
     *
     * - input must fit into 16 bits
     */
    function toUint16(uint256 value) internal pure returns (uint16) {
        if (value > type(uint16).max) {
            revert SafeCastOverflowedUintDowncast(16, value);
        }
        return uint16(value);
    }

    /**
     * @dev Returns the downcasted uint8 from uint256, reverting on
     * overflow (when the input is greater than largest uint8).
     *
     * Counterpart to Solidity's `uint8` operator.
     *
     * Requirements:
     *
     * - input must fit into 8 bits
     */
    function toUint8(uint256 value) internal pure returns (uint8) {
        if (value > type(uint8).max) {
            revert SafeCastOverflowedUintDowncast(8, value);
        }
        return uint8(value);
    }

    /**
     * @dev Converts a signed int256 into an unsigned uint256.
     *
     * Requirements:
     *
     * - input must be greater than or equal to 0.
     */
    function toUint256(int256 value) internal pure returns (uint256) {
        if (value < 0) {
            revert SafeCastOverflowedIntToUint(value);
        }
        return uint256(value);
    }

    /**
     * @dev Returns the downcasted int248 from int256, reverting on
     * overflow (when the input is less than smallest int248 or
     * greater than largest int248).
     *
     * Counterpart to Solidity's `int248` operator.
     *
     * Requirements:
     *
     * - input must fit into 248 bits
     */
    function toInt248(int256 value) internal pure returns (int248 downcasted) {
        downcasted = int248(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(248, value);
        }
    }

    /**
     * @dev Returns the downcasted int240 from int256, reverting on
     * overflow (when the input is less than smallest int240 or
     * greater than largest int240).
     *
     * Counterpart to Solidity's `int240` operator.
     *
     * Requirements:
     *
     * - input must fit into 240 bits
     */
    function toInt240(int256 value) internal pure returns (int240 downcasted) {
        downcasted = int240(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(240, value);
        }
    }

    /**
     * @dev Returns the downcasted int232 from int256, reverting on
     * overflow (when the input is less than smallest int232 or
     * greater than largest int232).
     *
     * Counterpart to Solidity's `int232` operator.
     *
     * Requirements:
     *
     * - input must fit into 232 bits
     */
    function toInt232(int256 value) internal pure returns (int232 downcasted) {
        downcasted = int232(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(232, value);
        }
    }

    /**
     * @dev Returns the downcasted int224 from int256, reverting on
     * overflow (when the input is less than smallest int224 or
     * greater than largest int224).
     *
     * Counterpart to Solidity's `int224` operator.
     *
     * Requirements:
     *
     * - input must fit into 224 bits
     */
    function toInt224(int256 value) internal pure returns (int224 downcasted) {
        downcasted = int224(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(224, value);
        }
    }

    /**
     * @dev Returns the downcasted int216 from int256, reverting on
     * overflow (when the input is less than smallest int216 or
     * greater than largest int216).
     *
     * Counterpart to Solidity's `int216` operator.
     *
     * Requirements:
     *
     * - input must fit into 216 bits
     */
    function toInt216(int256 value) internal pure returns (int216 downcasted) {
        downcasted = int216(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(216, value);
        }
    }

    /**
     * @dev Returns the downcasted int208 from int256, reverting on
     * overflow (when the input is less than smallest int208 or
     * greater than largest int208).
     *
     * Counterpart to Solidity's `int208` operator.
     *
     * Requirements:
     *
     * - input must fit into 208 bits
     */
    function toInt208(int256 value) internal pure returns (int208 downcasted) {
        downcasted = int208(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(208, value);
        }
    }

    /**
     * @dev Returns the downcasted int200 from int256, reverting on
     * overflow (when the input is less than smallest int200 or
     * greater than largest int200).
     *
     * Counterpart to Solidity's `int200` operator.
     *
     * Requirements:
     *
     * - input must fit into 200 bits
     */
    function toInt200(int256 value) internal pure returns (int200 downcasted) {
        downcasted = int200(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(200, value);
        }
    }

    /**
     * @dev Returns the downcasted int192 from int256, reverting on
     * overflow (when the input is less than smallest int192 or
     * greater than largest int192).
     *
     * Counterpart to Solidity's `int192` operator.
     *
     * Requirements:
     *
     * - input must fit into 192 bits
     */
    function toInt192(int256 value) internal pure returns (int192 downcasted) {
        downcasted = int192(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(192, value);
        }
    }

    /**
     * @dev Returns the downcasted int184 from int256, reverting on
     * overflow (when the input is less than smallest int184 or
     * greater than largest int184).
     *
     * Counterpart to Solidity's `int184` operator.
     *
     * Requirements:
     *
     * - input must fit into 184 bits
     */
    function toInt184(int256 value) internal pure returns (int184 downcasted) {
        downcasted = int184(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(184, value);
        }
    }

    /**
     * @dev Returns the downcasted int176 from int256, reverting on
     * overflow (when the input is less than smallest int176 or
     * greater than largest int176).
     *
     * Counterpart to Solidity's `int176` operator.
     *
     * Requirements:
     *
     * - input must fit into 176 bits
     */
    function toInt176(int256 value) internal pure returns (int176 downcasted) {
        downcasted = int176(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(176, value);
        }
    }

    /**
     * @dev Returns the downcasted int168 from int256, reverting on
     * overflow (when the input is less than smallest int168 or
     * greater than largest int168).
     *
     * Counterpart to Solidity's `int168` operator.
     *
     * Requirements:
     *
     * - input must fit into 168 bits
     */
    function toInt168(int256 value) internal pure returns (int168 downcasted) {
        downcasted = int168(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(168, value);
        }
    }

    /**
     * @dev Returns the downcasted int160 from int256, reverting on
     * overflow (when the input is less than smallest int160 or
     * greater than largest int160).
     *
     * Counterpart to Solidity's `int160` operator.
     *
     * Requirements:
     *
     * - input must fit into 160 bits
     */
    function toInt160(int256 value) internal pure returns (int160 downcasted) {
        downcasted = int160(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(160, value);
        }
    }

    /**
     * @dev Returns the downcasted int152 from int256, reverting on
     * overflow (when the input is less than smallest int152 or
     * greater than largest int152).
     *
     * Counterpart to Solidity's `int152` operator.
     *
     * Requirements:
     *
     * - input must fit into 152 bits
     */
    function toInt152(int256 value) internal pure returns (int152 downcasted) {
        downcasted = int152(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(152, value);
        }
    }

    /**
     * @dev Returns the downcasted int144 from int256, reverting on
     * overflow (when the input is less than smallest int144 or
     * greater than largest int144).
     *
     * Counterpart to Solidity's `int144` operator.
     *
     * Requirements:
     *
     * - input must fit into 144 bits
     */
    function toInt144(int256 value) internal pure returns (int144 downcasted) {
        downcasted = int144(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(144, value);
        }
    }

    /**
     * @dev Returns the downcasted int136 from int256, reverting on
     * overflow (when the input is less than smallest int136 or
     * greater than largest int136).
     *
     * Counterpart to Solidity's `int136` operator.
     *
     * Requirements:
     *
     * - input must fit into 136 bits
     */
    function toInt136(int256 value) internal pure returns (int136 downcasted) {
        downcasted = int136(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(136, value);
        }
    }

    /**
     * @dev Returns the downcasted int128 from int256, reverting on
     * overflow (when the input is less than smallest int128 or
     * greater than largest int128).
     *
     * Counterpart to Solidity's `int128` operator.
     *
     * Requirements:
     *
     * - input must fit into 128 bits
     */
    function toInt128(int256 value) internal pure returns (int128 downcasted) {
        downcasted = int128(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(128, value);
        }
    }

    /**
     * @dev Returns the downcasted int120 from int256, reverting on
     * overflow (when the input is less than smallest int120 or
     * greater than largest int120).
     *
     * Counterpart to Solidity's `int120` operator.
     *
     * Requirements:
     *
     * - input must fit into 120 bits
     */
    function toInt120(int256 value) internal pure returns (int120 downcasted) {
        downcasted = int120(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(120, value);
        }
    }

    /**
     * @dev Returns the downcasted int112 from int256, reverting on
     * overflow (when the input is less than smallest int112 or
     * greater than largest int112).
     *
     * Counterpart to Solidity's `int112` operator.
     *
     * Requirements:
     *
     * - input must fit into 112 bits
     */
    function toInt112(int256 value) internal pure returns (int112 downcasted) {
        downcasted = int112(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(112, value);
        }
    }

    /**
     * @dev Returns the downcasted int104 from int256, reverting on
     * overflow (when the input is less than smallest int104 or
     * greater than largest int104).
     *
     * Counterpart to Solidity's `int104` operator.
     *
     * Requirements:
     *
     * - input must fit into 104 bits
     */
    function toInt104(int256 value) internal pure returns (int104 downcasted) {
        downcasted = int104(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(104, value);
        }
    }

    /**
     * @dev Returns the downcasted int96 from int256, reverting on
     * overflow (when the input is less than smallest int96 or
     * greater than largest int96).
     *
     * Counterpart to Solidity's `int96` operator.
     *
     * Requirements:
     *
     * - input must fit into 96 bits
     */
    function toInt96(int256 value) internal pure returns (int96 downcasted) {
        downcasted = int96(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(96, value);
        }
    }

    /**
     * @dev Returns the downcasted int88 from int256, reverting on
     * overflow (when the input is less than smallest int88 or
     * greater than largest int88).
     *
     * Counterpart to Solidity's `int88` operator.
     *
     * Requirements:
     *
     * - input must fit into 88 bits
     */
    function toInt88(int256 value) internal pure returns (int88 downcasted) {
        downcasted = int88(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(88, value);
        }
    }

    /**
     * @dev Returns the downcasted int80 from int256, reverting on
     * overflow (when the input is less than smallest int80 or
     * greater than largest int80).
     *
     * Counterpart to Solidity's `int80` operator.
     *
     * Requirements:
     *
     * - input must fit into 80 bits
     */
    function toInt80(int256 value) internal pure returns (int80 downcasted) {
        downcasted = int80(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(80, value);
        }
    }

    /**
     * @dev Returns the downcasted int72 from int256, reverting on
     * overflow (when the input is less than smallest int72 or
     * greater than largest int72).
     *
     * Counterpart to Solidity's `int72` operator.
     *
     * Requirements:
     *
     * - input must fit into 72 bits
     */
    function toInt72(int256 value) internal pure returns (int72 downcasted) {
        downcasted = int72(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(72, value);
        }
    }

    /**
     * @dev Returns the downcasted int64 from int256, reverting on
     * overflow (when the input is less than smallest int64 or
     * greater than largest int64).
     *
     * Counterpart to Solidity's `int64` operator.
     *
     * Requirements:
     *
     * - input must fit into 64 bits
     */
    function toInt64(int256 value) internal pure returns (int64 downcasted) {
        downcasted = int64(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(64, value);
        }
    }

    /**
     * @dev Returns the downcasted int56 from int256, reverting on
     * overflow (when the input is less than smallest int56 or
     * greater than largest int56).
     *
     * Counterpart to Solidity's `int56` operator.
     *
     * Requirements:
     *
     * - input must fit into 56 bits
     */
    function toInt56(int256 value) internal pure returns (int56 downcasted) {
        downcasted = int56(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(56, value);
        }
    }

    /**
     * @dev Returns the downcasted int48 from int256, reverting on
     * overflow (when the input is less than smallest int48 or
     * greater than largest int48).
     *
     * Counterpart to Solidity's `int48` operator.
     *
     * Requirements:
     *
     * - input must fit into 48 bits
     */
    function toInt48(int256 value) internal pure returns (int48 downcasted) {
        downcasted = int48(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(48, value);
        }
    }

    /**
     * @dev Returns the downcasted int40 from int256, reverting on
     * overflow (when the input is less than smallest int40 or
     * greater than largest int40).
     *
     * Counterpart to Solidity's `int40` operator.
     *
     * Requirements:
     *
     * - input must fit into 40 bits
     */
    function toInt40(int256 value) internal pure returns (int40 downcasted) {
        downcasted = int40(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(40, value);
        }
    }

    /**
     * @dev Returns the downcasted int32 from int256, reverting on
     * overflow (when the input is less than smallest int32 or
     * greater than largest int32).
     *
     * Counterpart to Solidity's `int32` operator.
     *
     * Requirements:
     *
     * - input must fit into 32 bits
     */
    function toInt32(int256 value) internal pure returns (int32 downcasted) {
        downcasted = int32(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(32, value);
        }
    }

    /**
     * @dev Returns the downcasted int24 from int256, reverting on
     * overflow (when the input is less than smallest int24 or
     * greater than largest int24).
     *
     * Counterpart to Solidity's `int24` operator.
     *
     * Requirements:
     *
     * - input must fit into 24 bits
     */
    function toInt24(int256 value) internal pure returns (int24 downcasted) {
        downcasted = int24(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(24, value);
        }
    }

    /**
     * @dev Returns the downcasted int16 from int256, reverting on
     * overflow (when the input is less than smallest int16 or
     * greater than largest int16).
     *
     * Counterpart to Solidity's `int16` operator.
     *
     * Requirements:
     *
     * - input must fit into 16 bits
     */
    function toInt16(int256 value) internal pure returns (int16 downcasted) {
        downcasted = int16(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(16, value);
        }
    }

    /**
     * @dev Returns the downcasted int8 from int256, reverting on
     * overflow (when the input is less than smallest int8 or
     * greater than largest int8).
     *
     * Counterpart to Solidity's `int8` operator.
     *
     * Requirements:
     *
     * - input must fit into 8 bits
     */
    function toInt8(int256 value) internal pure returns (int8 downcasted) {
        downcasted = int8(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(8, value);
        }
    }

    /**
     * @dev Converts an unsigned uint256 into a signed int256.
     *
     * Requirements:
     *
     * - input must be less than or equal to maxInt256.
     */
    function toInt256(uint256 value) internal pure returns (int256) {
        // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive
        if (value > uint256(type(int256).max)) {
            revert SafeCastOverflowedUintToInt(value);
        }
        return int256(value);
    }
}

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

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

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

}

File 9 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 10 of 23 : ICurvePool.sol
// SPDX-License-Identifier: MIT
pragma solidity =0.8.21;

/**
 * @title CurvePool Interface
 * @dev Interface for interacting with a Curve.fi pool contract.
 */
interface ICurvePool {
    /**
     * @dev Exchanges one asset for another within the Curve pool.
     * @param from coin index of the asset to exchange from.
     * @param to coin index of the asset to exchange to.
     * @param input Amount of input asset to exchange.
     * @param minOutput Minimum acceptable amount of output asset to receive.
     * @return output The amount of output asset received.
     */
    function exchange(int128 from, int128 to, uint256 input, uint256 minOutput)
        external
        payable
        returns (uint256 output);

    /**
     * @dev Gets the virtual price of the pool.
     * @return price virtual price of the pool.
     */
    function get_virtual_price() external view returns (uint256 price);

    /**
     * @dev Gets the address of a coin within the pool.
     * @param index The index of the coin.
     * @return coin address of the coin.
     */
    function coins(uint256 index) external view returns (address coin);

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

File 11 of 23 : IWETH9.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity =0.8.21;

import "oz/token/ERC20/IERC20.sol";

/// @title Interface for WETH9
interface IWETH9 is IERC20 {
    /// @notice Deposit ether to get wrapped ether
    function deposit() external payable;

    /// @notice Withdraw wrapped ether to get ether
    function withdraw(uint256) external;
}

File 12 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 13 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 14 of 23 : Context.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)

pragma solidity ^0.8.20;

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

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

    function _contextSuffixLength() internal view virtual returns (uint256) {
        return 0;
    }
}

File 15 of 23 : IERC20Permit.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Permit.sol)

pragma solidity ^0.8.20;

/**
 * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
 * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
 *
 * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
 * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
 * need to send a transaction, and thus is not required to hold Ether at all.
 *
 * ==== Security Considerations
 *
 * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature
 * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be
 * considered as an intention to spend the allowance in any specific way. The second is that because permits have
 * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should
 * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be
 * generally recommended is:
 *
 * ```solidity
 * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {
 *     try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}
 *     doThing(..., value);
 * }
 *
 * function doThing(..., uint256 value) public {
 *     token.safeTransferFrom(msg.sender, address(this), value);
 *     ...
 * }
 * ```
 *
 * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of
 * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also
 * {SafeERC20-safeTransferFrom}).
 *
 * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so
 * contracts should have entry points that don't rely on permit.
 */
interface IERC20Permit {
    /**
     * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
     * given ``owner``'s signed approval.
     *
     * IMPORTANT: The same issues {IERC20-approve} has related to transaction
     * ordering also apply here.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `deadline` must be a timestamp in the future.
     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
     * over the EIP712-formatted function arguments.
     * - the signature must use ``owner``'s current nonce (see {nonces}).
     *
     * For more information on the signature format, see the
     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
     * section].
     *
     * CAUTION: See Security Considerations above.
     */
    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;

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

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

File 16 of 23 : Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)

pragma solidity ^0.8.20;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev The ETH balance of the account is not enough to perform the operation.
     */
    error AddressInsufficientBalance(address account);

    /**
     * @dev There's no code at `target` (it is not a contract).
     */
    error AddressEmptyCode(address target);

    /**
     * @dev A call to an address target failed. The target may have reverted.
     */
    error FailedInnerCall();

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

        (bool success, ) = recipient.call{value: amount}("");
        if (!success) {
            revert FailedInnerCall();
        }
    }

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

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
        if (address(this).balance < value) {
            revert AddressInsufficientBalance(address(this));
        }
        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResultFromTarget(target, success, returndata);
    }

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

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

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target
     * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an
     * unsuccessful call.
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata
    ) internal view returns (bytes memory) {
        if (!success) {
            _revert(returndata);
        } else {
            // only check if target is a contract if the call was successful and the return data is empty
            // otherwise we already know that it was a contract
            if (returndata.length == 0 && target.code.length == 0) {
                revert AddressEmptyCode(target);
            }
            return returndata;
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the
     * revert reason or with a default {FailedInnerCall} error.
     */
    function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {
        if (!success) {
            _revert(returndata);
        } else {
            return returndata;
        }
    }

    /**
     * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.
     */
    function _revert(bytes memory returndata) private pure {
        // Look for revert reason and bubble it up if present
        if (returndata.length > 0) {
            // The easiest way to bubble the revert reason is using memory via assembly
            /// @solidity memory-safe-assembly
            assembly {
                let returndata_size := mload(returndata)
                revert(add(32, returndata), returndata_size)
            }
        } else {
            revert FailedInnerCall();
        }
    }
}

File 17 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 18 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
    /// tick The current tick of the pool, i.e. according to the last tick transition that was run.
    /// This value may not always be equal to SqrtTickMath.getTickAtSqrtRatio(sqrtPriceX96) if the price is on a tick
    /// boundary.
    /// observationIndex The index of the last oracle observation that was written,
    /// observationCardinality The current maximum number of observations stored in the pool,
    /// observationCardinalityNext The next maximum number of observations, to be updated when the observation.
    /// feeProtocol The protocol fee for both tokens of the pool.
    /// Encoded as two 4 bit values, where the protocol fee of token1 is shifted 4 bits and the protocol fee of token0
    /// is the lower 4 bits. Used as the denominator of a fraction of the swap fee, e.g. 4 means 1/4th of the swap fee.
    /// unlocked Whether the pool is currently locked to reentrancy
    function slot0()
        external
        view
        returns (
            uint160 sqrtPriceX96,
            int24 tick,
            uint16 observationIndex,
            uint16 observationCardinality,
            uint16 observationCardinalityNext,
            uint8 feeProtocol,
            bool unlocked
        );

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

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

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

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

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

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

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

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

File 19 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 20 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 21 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 22 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 23 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;
}

Settings
{
  "remappings": [
    "src/=src/",
    "forge-std/=lib/forge-std/src/",
    "oz/=lib/openzeppelin-contracts/contracts/",
    "v3-periphery/=lib/v3-periphery/contracts/",
    "@uniswap/v3-core/=lib/v3-core/",
    "v3-core-0.8/=lib/v3-core-0.8/contracts/",
    "@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
    "ds-test/=lib/forge-std/lib/ds-test/src/",
    "erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
    "openzeppelin-contracts/=lib/openzeppelin-contracts/",
    "v3-core/=lib/v3-core/"
  ],
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "metadata": {
    "useLiteralContent": false,
    "bytecodeHash": "ipfs",
    "appendCBOR": true
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "evmVersion": "shanghai",
  "viaIR": false,
  "libraries": {}
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"_intialOwner","type":"address"},{"internalType":"address","name":"_weth9","type":"address"},{"internalType":"address","name":"_null","type":"address"},{"internalType":"address","name":"_v3SwapRouter","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"target","type":"address"}],"name":"AddressEmptyCode","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"AddressInsufficientBalance","type":"error"},{"inputs":[],"name":"FailedInnerCall","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"OwnableInvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"OwnableUnauthorizedAccount","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"inputs":[{"internalType":"uint256","name":"given","type":"uint256"},{"internalType":"uint256","name":"max","type":"uint256"}],"name":"SwapManager__ExceedPercentage","type":"error"},{"inputs":[],"name":"SwapManager__InvalidPoolToken","type":"error"},{"inputs":[{"internalType":"uint32","name":"duration","type":"uint32"}],"name":"SwapManager__MIN_TWAP_DURATION","type":"error"},{"inputs":[],"name":"SwapManager__NoLiquidity","type":"error"},{"inputs":[{"internalType":"address","name":"tokenIn","type":"address"}],"name":"SwapManager__NoPool","type":"error"},{"inputs":[{"internalType":"uint256","name":"amountOut","type":"uint256"},{"internalType":"uint256","name":"minAmountOut","type":"uint256"}],"name":"SwapManager__SlippageExceeded","type":"error"},{"inputs":[],"name":"SwapManager__SlippageNotSet","type":"error"},{"inputs":[],"name":"SwapManager__ZeroAddress","type":"error"},{"inputs":[],"name":"T","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"address","name":"pool","type":"address"}],"name":"CurvePoolUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferStarted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint24","name":"slippage","type":"uint24"}],"name":"TokenSlippageUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint32","name":"duration","type":"uint32"}],"name":"TwapDurationUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"address","name":"pool","type":"address"}],"name":"UniswapV3PoolUpdated","type":"event"},{"inputs":[],"name":"MIN_TWAP_DURATION","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"NULL","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"WETH9","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"acceptOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"curvePools","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountIn","type":"uint256"},{"internalType":"address","name":"tokenIn","type":"address"}],"name":"estimateCurveAmountOut","outputs":[{"internalType":"uint256","name":"amountOut","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint128","name":"amountIn","type":"uint128"},{"internalType":"address","name":"tokenIn","type":"address"},{"internalType":"address","name":"tokenOut","type":"address"}],"name":"estimateV3AmountOut","outputs":[{"internalType":"uint256","name":"amountOut","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"getMinimumAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint24","name":"_slippage","type":"uint24"}],"name":"setTokenSlippage","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"_duration","type":"uint32"}],"name":"setTwapDuration","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"address","name":"_pool","type":"address"},{"internalType":"uint24","name":"_slippage","type":"uint24"}],"name":"setWhitelistCurvePool","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"address","name":"_pool","type":"address"},{"internalType":"uint24","name":"_slippage","type":"uint24"}],"name":"setWhitelistV3Pool","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"slippage","outputs":[{"internalType":"uint24","name":"","type":"uint24"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"tokenIn","type":"address"},{"internalType":"uint256","name":"amountIn","type":"uint256"},{"internalType":"uint256","name":"amountOutMinimum","type":"uint256"}],"name":"swapCurve","outputs":[{"internalType":"uint256","name":"amountOut","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"tokenIn","type":"address"},{"internalType":"uint256","name":"amountIn","type":"uint256"},{"internalType":"uint256","name":"amountOutMinimum","type":"uint256"}],"name":"swapUinv3","outputs":[{"internalType":"uint256","name":"amountOut","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"twapDuration","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"v3Pools","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"v3SwapRouter","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}]

60e060405234801562000010575f80fd5b50604051620025003803806200250083398101604081905262000033916200017c565b836001600160a01b0381166200006257604051631e4fbdf760e01b81525f600482015260240160405180910390fd5b6200006d81620000f3565b506001600160a01b03831615806200008c57506001600160a01b038116155b806200009f57506001600160a01b038116155b15620000be5760405163853ef42360e01b815260040160405180910390fd5b6001600160a01b0392831660a0529082166080521660c052506001805463ffffffff60a01b191660e160a41b179055620001d6565b600180546001600160a01b03191690556200010e8162000111565b50565b5f80546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b80516001600160a01b038116811462000177575f80fd5b919050565b5f805f806080858703121562000190575f80fd5b6200019b8562000160565b9350620001ab6020860162000160565b9250620001bb6040860162000160565b9150620001cb6060860162000160565b905092959194509250565b60805160a05160c0516122c7620002395f395f8181610150015281816106cc015261076a01525f818161020c0152818161070b0152818161082001528181610b760152610be801525f8181610435015281816110a5015261111701526122c75ff3fe608060405260043610610134575f3560e01c8063a7888718116100a8578063d4ae6fe21161006d578063d4ae6fe2146103d3578063dcc0cfac146103e8578063e30c397814610407578063f26be3fc14610424578063f2fde38b14610457578063f3e50f8c14610476575f80fd5b8063a788871814610323578063b6f76c2614610357578063c081f25614610376578063c433c80a14610395578063ca1f841a146103b4575f80fd5b80636062222c116100f95780636062222c14610272578063715018a61461029f57806379ba5097146102b557806386b3abbb146102c95780638da5cb5b146102e8578063a74984c714610304575f80fd5b80631865e9d11461013f57806326d895451461018f5780632d29ad74146101c75780634aa4a4fc146101fb5780635e0acb621461022e575f80fd5b3661013b57005b5f80fd5b34801561014a575f80fd5b506101727f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020015b60405180910390f35b34801561019a575f80fd5b506001546101b290600160a01b900463ffffffff1681565b60405163ffffffff9091168152602001610186565b3480156101d2575f80fd5b506101726101e1366004611d43565b60026020525f90815260409020546001600160a01b031681565b348015610206575f80fd5b506101727f000000000000000000000000000000000000000000000000000000000000000081565b348015610239575f80fd5b5061025e610248366004611d43565b60046020525f908152604090205462ffffff1681565b60405162ffffff9091168152602001610186565b34801561027d575f80fd5b5061029161028c366004611d5e565b610495565b604051908152602001610186565b3480156102aa575f80fd5b506102b36105bc565b005b3480156102c0575f80fd5b506102b36105cf565b3480156102d4575f80fd5b506102916102e3366004611d5e565b610613565b3480156102f3575f80fd5b505f546001600160a01b0316610172565b34801561030f575f80fd5b5061029161031e366004611d90565b6108f1565b34801561032e575f80fd5b5061017261033d366004611d43565b60036020525f90815260409020546001600160a01b031681565b348015610362575f80fd5b506102b3610371366004611dca565b610971565b348015610381575f80fd5b506102b3610390366004611e01565b610a17565b3480156103a0575f80fd5b506102b36103af366004611e49565b610cc1565b3480156103bf575f80fd5b506102916103ce366004611e6c565b610d54565b3480156103de575f80fd5b506101b2610e1081565b3480156103f3575f80fd5b50610291610402366004611eb4565b610eec565b348015610412575f80fd5b506001546001600160a01b0316610172565b34801561042f575f80fd5b506101727f000000000000000000000000000000000000000000000000000000000000000081565b348015610462575f80fd5b506102b3610471366004611d43565b610f8d565b348015610481575f80fd5b506102b3610490366004611e01565b610ffd565b5f815f036104b657604051630146092760e31b815260040160405180910390fd5b5f6104c0856111e5565b90506104ce8533308761122d565b6104e26001600160a01b0386168286611332565b5f806104ee83886113eb565b604051630f7c084960e21b8152600f83810b600483015282900b6024820152604481018990526064810188905291935091506001600160a01b03841690633df02124906084016020604051808303815f875af1158015610550573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906105749190611ed7565b9350848410156105a55760405162de97bd60e11b815260048101859052602481018690526044015b60405180910390fd5b4793506105b23385611428565b5050509392505050565b6105c46114cc565b6105cd5f6114f8565b565b60015433906001600160a01b031681146106075760405163118cdaa760e01b81526001600160a01b038216600482015260240161059c565b610610816114f8565b50565b5f815f0361063457604051630146092760e31b815260040160405180910390fd5b5f61063e85611511565b90505f61064c601e42611f02565b90505f826001600160a01b031663ddca3f436040518163ffffffff1660e01b8152600401602060405180830381865afa15801561068b573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906106af9190611f15565b90506106bd8733308961122d565b6106f16001600160a01b0388167f000000000000000000000000000000000000000000000000000000000000000088611332565b60408051610100810182526001600160a01b0389811682527f00000000000000000000000000000000000000000000000000000000000000008116602083015262ffffff8416828401523060608301526080820185905260a0820189905260c082018890525f60e0830152915163414bf38960e01b81527f00000000000000000000000000000000000000000000000000000000000000009092169163414bf3899161079f91600401611f30565b6020604051808303815f875af11580156107bb573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906107df9190611ed7565b93508484101561080b5760405162de97bd60e11b8152600481018590526024810186905260440161059c565b6040516370a0823160e01b81523060048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690632e1a7d4d9082906370a0823190602401602060405180830381865afa158015610875573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906108999190611ed7565b6040518263ffffffff1660e01b81526004016108b791815260200190565b5f604051808303815f87803b1580156108ce575f80fd5b505af11580156108e0573d5f803e3d5ffd5b505050504793506105b23385611428565b6001600160a01b0382165f9081526004602052604081205462ffffff16810361092d576040516358639f9160e11b815260040160405180910390fd5b6001600160a01b0383165f908152600460205260408120546109579062ffffff16620f4240611fac565b90506109678382620f4240611554565b9150505b92915050565b6109796114cc565b61c3508162ffffff1611156109b057604051637af6b7f760e11b815262ffffff8216600482015261c350602482015260440161059c565b6001600160a01b0382165f81815260046020908152604091829020805462ffffff191662ffffff86169081179091558251938452908301527f331c9f15537835cd06a06447966265c87267468e71eddd7a15461d4b17185386910160405180910390a15050565b610a1f6114cc565b6001600160a01b0383161580610a3c57506001600160a01b038216155b15610a5a5760405163853ef42360e01b815260040160405180910390fd5b61c3508162ffffff161115610a9157604051637af6b7f760e11b815262ffffff8216600482015261c350602482015260440161059c565b5f80836001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa158015610acf573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610af39190611fbf565b846001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa158015610b2f573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610b539190611fbf565b91509150846001600160a01b0316826001600160a01b031614158015610bab57507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b031614155b15610bc95760405163c371b75d60e01b815260040160405180910390fd5b846001600160a01b0316816001600160a01b031614158015610c1d57507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316816001600160a01b031614155b15610c3b5760405163c371b75d60e01b815260040160405180910390fd5b6001600160a01b038581165f81815260026020908152604080832080546001600160a01b031916958a1695861790556004825291829020805462ffffff191662ffffff891617905581519283528201929092527f9d27e1cf9405ac4b83e4312189a6b67a70f739977fba26869888adbf76fd882391015b60405180910390a15050505050565b610cc96114cc565b610e1063ffffffff82161015610cfa5760405163e9171e1760e01b815263ffffffff8216600482015260240161059c565b6001805463ffffffff60a01b1916600160a01b63ffffffff8416908102919091179091556040519081527f670aac3910a07dcfe5267c8b0bf2357abdb454e509764d13e94e85ee13c6da209060200160405180910390a150565b5f80610d5f84611511565b600154604080516002808252606082018352939450600160a01b90920463ffffffff16925f929160208301908036833701905050905081815f81518110610da857610da8611fee565b602002602001019063ffffffff16908163ffffffff16815250505f81600181518110610dd657610dd6611fee565b63ffffffff9092166020928302919091019091015260405163883bdbfd60e01b81525f906001600160a01b0385169063883bdbfd90610e19908590600401612002565b5f60405180830381865afa158015610e33573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f19168201604052610e5a9190810190612110565b5090505f815f81518110610e7057610e70611fee565b602002602001015182600181518110610e8b57610e8b611fee565b60200260200101510390505f8460030b82610ea691906121e9565b90505f8260060b128015610ec95750610ec3600386900b83612225565b60060b15155b15610ed2575f19015b610ede818b8b8b6115ff565b9a9950505050505050505050565b5f80610ef7836111e5565b90505f80610f0583866113eb565b604051635e0d443f60e01b8152600f83810b600483015282900b60248201526044810189905291935091506001600160a01b03841690635e0d443f90606401602060405180830381865afa158015610f5f573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610f839190611ed7565b9695505050505050565b610f956114cc565b600180546001600160a01b0383166001600160a01b03199091168117909155610fc55f546001600160a01b031690565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b6110056114cc565b6001600160a01b038316158061102257506001600160a01b038216155b156110405760405163853ef42360e01b815260040160405180910390fd5b61c3508162ffffff16111561107757604051637af6b7f760e11b815262ffffff8216600482015261c350602482015260440161059c565b5f80611082846116f4565b91509150846001600160a01b0316826001600160a01b0316141580156110da57507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b031614155b156110f85760405163c371b75d60e01b815260040160405180910390fd5b846001600160a01b0316816001600160a01b03161415801561114c57507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316816001600160a01b031614155b1561116a5760405163c371b75d60e01b815260040160405180910390fd5b6001600160a01b038581165f81815260036020908152604080832080546001600160a01b031916958a1695861790556004825291829020805462ffffff191662ffffff891617905581519283528201929092527f8fca21c5d308d0debabdfc9dddde40c80ec0ad3e7fac4a6e5f72f038c3aef82d9101610cb2565b6001600160a01b038082165f9081526003602052604090205416806112285760405163b0a43ba560e01b81526001600160a01b038316600482015260240161059c565b919050565b604080516001600160a01b0385811660248301528481166044830152606480830185905283518084039091018152608490920183526020820180516001600160e01b03166323b872dd60e01b17905291515f928392908816916112909190612246565b5f604051808303815f865af19150503d805f81146112c9576040519150601f19603f3d011682016040523d82523d5f602084013e6112ce565b606091505b50915091508180156112f85750805115806112f85750808060200190518101906112f89190612272565b61132a5760405162461bcd60e51b815260206004820152600360248201526229aa2360e91b604482015260640161059c565b505050505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663095ea7b360e01b17905261138384826117d0565b6113e557604080516001600160a01b03851660248201525f6044808301919091528251808303909101815260649091019091526020810180516001600160e01b031663095ea7b360e01b1790526113db908590611871565b6113e58482611871565b50505050565b5f805f6113f7856116f4565b5090505f60016001600160a01b038084169087161461141757808261141a565b81815b945094505050509250929050565b604080515f808252602082019092526001600160a01b0384169083906040516114519190612246565b5f6040518083038185875af1925050503d805f811461148b576040519150601f19603f3d011682016040523d82523d5f602084013e611490565b606091505b50509050806114c75760405162461bcd60e51b815260206004820152600360248201526253544560e81b604482015260640161059c565b505050565b5f546001600160a01b031633146105cd5760405163118cdaa760e01b815233600482015260240161059c565b600180546001600160a01b0319169055610610816118d2565b6001600160a01b038082165f9081526002602052604090205416806112285760405163b0a43ba560e01b81526001600160a01b038316600482015260240161059c565b5f80805f19858709858702925082811083820303915050805f03611588575f841161157d575f80fd5b5082900490506115f8565b808411611593575f80fd5b5f848688095f868103871696879004966002600389028118808a02820302808a02820302808a02820302808a02820302808a02820302808a02909103029181900381900460010186841190950394909402919094039290920491909117919091029150505b9392505050565b5f8061160a86611921565b90506001600160801b036001600160a01b03821611611679576001600160a01b038082168002908481169086161061165957611654600160c01b6001600160801b03881683611554565b611671565b611671816001600160801b038816600160c01b611554565b9250506116eb565b5f6116976001600160a01b0383168068010000000000000000611554565b9050836001600160a01b0316856001600160a01b0316106116cf576116ca600160801b6001600160801b03881683611554565b6116e7565b6116e7816001600160801b038816600160801b611554565b9250505b50949350505050565b60405163c661065760e01b81525f600482018190529081906001600160a01b0384169063c661065790602401602060405180830381865afa15801561173b573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061175f9190611fbf565b60405163c661065760e01b8152600160048201529092506001600160a01b0384169063c661065790602401602060405180830381865afa1580156117a5573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906117c99190611fbf565b9050915091565b5f805f846001600160a01b0316846040516117eb9190612246565b5f604051808303815f865af19150503d805f8114611824576040519150601f19603f3d011682016040523d82523d5f602084013e611829565b606091505b50915091508180156118535750805115806118535750808060200190518101906118539190612272565b801561186857505f856001600160a01b03163b115b95945050505050565b5f6118856001600160a01b03841683611c3c565b905080515f141580156118a95750808060200190518101906118a79190612272565b155b156114c757604051635274afe760e01b81526001600160a01b038416600482015260240161059c565b5f80546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b5f805f8360020b12611936578260020b61193d565b8260020b5f035b9050620d89e8811115611963576040516315e4079d60e11b815260040160405180910390fd5b5f816001165f0361197857600160801b61198a565b6ffffcb933bd6fad37aa2d162d1a5940015b70ffffffffffffffffffffffffffffffffff16905060028216156119be576ffff97272373d413259a46990580e213a0260801c5b60048216156119dd576ffff2e50f5f656932ef12357cf3c7fdcc0260801c5b60088216156119fc576fffe5caca7e10e4e61c3624eaa0941cd00260801c5b6010821615611a1b576fffcb9843d60f6159c9db58835c9266440260801c5b6020821615611a3a576fff973b41fa98c081472e6896dfb254c00260801c5b6040821615611a59576fff2ea16466c96a3843ec78b326b528610260801c5b6080821615611a78576ffe5dee046a99a2a811c461f1969c30530260801c5b610100821615611a98576ffcbe86c7900a88aedcffc83b479aa3a40260801c5b610200821615611ab8576ff987a7253ac413176f2b074cf7815e540260801c5b610400821615611ad8576ff3392b0822b70005940c7a398e4b70f30260801c5b610800821615611af8576fe7159475a2c29b7443b29c7fa6e889d90260801c5b611000821615611b18576fd097f3bdfd2022b8845ad8f792aa58250260801c5b612000821615611b38576fa9f746462d870fdf8a65dc1f90e061e50260801c5b614000821615611b58576f70d869a156d2a1b890bb3df62baf32f70260801c5b618000821615611b78576f31be135f97d08fd981231505542fcfa60260801c5b62010000821615611b99576f09aa508b5b7a84e1c677de54f3e99bc90260801c5b62020000821615611bb9576e5d6af8dedb81196699c329225ee6040260801c5b62040000821615611bd8576d2216e584f5fa1ea926041bedfe980260801c5b62080000821615611bf5576b048a170391f7dc42444e8fa20260801c5b5f8460020b1315611c1457805f1981611c1057611c106121d5565b0490505b640100000000810615611c28576001611c2a565b5f5b60ff16602082901c0192505050919050565b60606115f883835f845f80856001600160a01b03168486604051611c609190612246565b5f6040518083038185875af1925050503d805f8114611c9a576040519150601f19603f3d011682016040523d82523d5f602084013e611c9f565b606091505b5091509150610f83868383606082611cbf57611cba82611d06565b6115f8565b8151158015611cd657506001600160a01b0384163b155b15611cff57604051639996b31560e01b81526001600160a01b038516600482015260240161059c565b50806115f8565b805115611d165780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b6001600160a01b0381168114610610575f80fd5b5f60208284031215611d53575f80fd5b81356115f881611d2f565b5f805f60608486031215611d70575f80fd5b8335611d7b81611d2f565b95602085013595506040909401359392505050565b5f8060408385031215611da1575f80fd5b8235611dac81611d2f565b946020939093013593505050565b62ffffff81168114610610575f80fd5b5f8060408385031215611ddb575f80fd5b8235611de681611d2f565b91506020830135611df681611dba565b809150509250929050565b5f805f60608486031215611e13575f80fd5b8335611e1e81611d2f565b92506020840135611e2e81611d2f565b91506040840135611e3e81611dba565b809150509250925092565b5f60208284031215611e59575f80fd5b813563ffffffff811681146115f8575f80fd5b5f805f60608486031215611e7e575f80fd5b83356001600160801b0381168114611e94575f80fd5b92506020840135611ea481611d2f565b91506040840135611e3e81611d2f565b5f8060408385031215611ec5575f80fd5b823591506020830135611df681611d2f565b5f60208284031215611ee7575f80fd5b5051919050565b634e487b7160e01b5f52601160045260245ffd5b8082018082111561096b5761096b611eee565b5f60208284031215611f25575f80fd5b81516115f881611dba565b5f6101008201905060018060a01b0380845116835280602085015116602084015262ffffff6040850151166040840152806060850151166060840152506080830151608083015260a083015160a083015260c083015160c083015260e0830151611fa560e08401826001600160a01b03169052565b5092915050565b8181038181111561096b5761096b611eee565b5f60208284031215611fcf575f80fd5b81516115f881611d2f565b634e487b7160e01b5f52604160045260245ffd5b634e487b7160e01b5f52603260045260245ffd5b602080825282518282018190525f9190848201906040850190845b8181101561203f57835163ffffffff168352928401929184019160010161201d565b50909695505050505050565b604051601f8201601f1916810167ffffffffffffffff8111828210171561207457612074611fda565b604052919050565b5f67ffffffffffffffff82111561209557612095611fda565b5060051b60200190565b5f82601f8301126120ae575f80fd5b815160206120c36120be8361207c565b61204b565b82815260059290921b840181019181810190868411156120e1575f80fd5b8286015b848110156121055780516120f881611d2f565b83529183019183016120e5565b509695505050505050565b5f8060408385031215612121575f80fd5b825167ffffffffffffffff80821115612138575f80fd5b818501915085601f83011261214b575f80fd5b8151602061215b6120be8361207c565b82815260059290921b84018101918181019089841115612179575f80fd5b948201945b838610156121a65785518060060b8114612197575f8081fd5b8252948201949082019061217e565b918801519196509093505050808211156121be575f80fd5b506121cb8582860161209f565b9150509250929050565b634e487b7160e01b5f52601260045260245ffd5b5f8160060b8360060b806121ff576121ff6121d5565b667fffffffffffff1982145f198214161561221c5761221c611eee565b90059392505050565b5f8260060b80612237576122376121d5565b808360060b0791505092915050565b5f82515f5b81811015612265576020818601810151858301520161224b565b505f920191825250919050565b5f60208284031215612282575f80fd5b815180151581146115f8575f80fdfea2646970667358221220e118057f8578ebbbb10b6a824070f6e51e00d0f4ec47d2dc0bce511b33bc01b764736f6c63430008150033000000000000000000000000eb658c4ea908ac4daf9c309d8f883d6ad758b3a3000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee000000000000000000000000e592427a0aece92de3edee1f18e0157c05861564

Deployed Bytecode

0x608060405260043610610134575f3560e01c8063a7888718116100a8578063d4ae6fe21161006d578063d4ae6fe2146103d3578063dcc0cfac146103e8578063e30c397814610407578063f26be3fc14610424578063f2fde38b14610457578063f3e50f8c14610476575f80fd5b8063a788871814610323578063b6f76c2614610357578063c081f25614610376578063c433c80a14610395578063ca1f841a146103b4575f80fd5b80636062222c116100f95780636062222c14610272578063715018a61461029f57806379ba5097146102b557806386b3abbb146102c95780638da5cb5b146102e8578063a74984c714610304575f80fd5b80631865e9d11461013f57806326d895451461018f5780632d29ad74146101c75780634aa4a4fc146101fb5780635e0acb621461022e575f80fd5b3661013b57005b5f80fd5b34801561014a575f80fd5b506101727f000000000000000000000000e592427a0aece92de3edee1f18e0157c0586156481565b6040516001600160a01b0390911681526020015b60405180910390f35b34801561019a575f80fd5b506001546101b290600160a01b900463ffffffff1681565b60405163ffffffff9091168152602001610186565b3480156101d2575f80fd5b506101726101e1366004611d43565b60026020525f90815260409020546001600160a01b031681565b348015610206575f80fd5b506101727f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc281565b348015610239575f80fd5b5061025e610248366004611d43565b60046020525f908152604090205462ffffff1681565b60405162ffffff9091168152602001610186565b34801561027d575f80fd5b5061029161028c366004611d5e565b610495565b604051908152602001610186565b3480156102aa575f80fd5b506102b36105bc565b005b3480156102c0575f80fd5b506102b36105cf565b3480156102d4575f80fd5b506102916102e3366004611d5e565b610613565b3480156102f3575f80fd5b505f546001600160a01b0316610172565b34801561030f575f80fd5b5061029161031e366004611d90565b6108f1565b34801561032e575f80fd5b5061017261033d366004611d43565b60036020525f90815260409020546001600160a01b031681565b348015610362575f80fd5b506102b3610371366004611dca565b610971565b348015610381575f80fd5b506102b3610390366004611e01565b610a17565b3480156103a0575f80fd5b506102b36103af366004611e49565b610cc1565b3480156103bf575f80fd5b506102916103ce366004611e6c565b610d54565b3480156103de575f80fd5b506101b2610e1081565b3480156103f3575f80fd5b50610291610402366004611eb4565b610eec565b348015610412575f80fd5b506001546001600160a01b0316610172565b34801561042f575f80fd5b506101727f000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee81565b348015610462575f80fd5b506102b3610471366004611d43565b610f8d565b348015610481575f80fd5b506102b3610490366004611e01565b610ffd565b5f815f036104b657604051630146092760e31b815260040160405180910390fd5b5f6104c0856111e5565b90506104ce8533308761122d565b6104e26001600160a01b0386168286611332565b5f806104ee83886113eb565b604051630f7c084960e21b8152600f83810b600483015282900b6024820152604481018990526064810188905291935091506001600160a01b03841690633df02124906084016020604051808303815f875af1158015610550573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906105749190611ed7565b9350848410156105a55760405162de97bd60e11b815260048101859052602481018690526044015b60405180910390fd5b4793506105b23385611428565b5050509392505050565b6105c46114cc565b6105cd5f6114f8565b565b60015433906001600160a01b031681146106075760405163118cdaa760e01b81526001600160a01b038216600482015260240161059c565b610610816114f8565b50565b5f815f0361063457604051630146092760e31b815260040160405180910390fd5b5f61063e85611511565b90505f61064c601e42611f02565b90505f826001600160a01b031663ddca3f436040518163ffffffff1660e01b8152600401602060405180830381865afa15801561068b573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906106af9190611f15565b90506106bd8733308961122d565b6106f16001600160a01b0388167f000000000000000000000000e592427a0aece92de3edee1f18e0157c0586156488611332565b60408051610100810182526001600160a01b0389811682527f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc28116602083015262ffffff8416828401523060608301526080820185905260a0820189905260c082018890525f60e0830152915163414bf38960e01b81527f000000000000000000000000e592427a0aece92de3edee1f18e0157c058615649092169163414bf3899161079f91600401611f30565b6020604051808303815f875af11580156107bb573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906107df9190611ed7565b93508484101561080b5760405162de97bd60e11b8152600481018590526024810186905260440161059c565b6040516370a0823160e01b81523060048201527f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031690632e1a7d4d9082906370a0823190602401602060405180830381865afa158015610875573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906108999190611ed7565b6040518263ffffffff1660e01b81526004016108b791815260200190565b5f604051808303815f87803b1580156108ce575f80fd5b505af11580156108e0573d5f803e3d5ffd5b505050504793506105b23385611428565b6001600160a01b0382165f9081526004602052604081205462ffffff16810361092d576040516358639f9160e11b815260040160405180910390fd5b6001600160a01b0383165f908152600460205260408120546109579062ffffff16620f4240611fac565b90506109678382620f4240611554565b9150505b92915050565b6109796114cc565b61c3508162ffffff1611156109b057604051637af6b7f760e11b815262ffffff8216600482015261c350602482015260440161059c565b6001600160a01b0382165f81815260046020908152604091829020805462ffffff191662ffffff86169081179091558251938452908301527f331c9f15537835cd06a06447966265c87267468e71eddd7a15461d4b17185386910160405180910390a15050565b610a1f6114cc565b6001600160a01b0383161580610a3c57506001600160a01b038216155b15610a5a5760405163853ef42360e01b815260040160405180910390fd5b61c3508162ffffff161115610a9157604051637af6b7f760e11b815262ffffff8216600482015261c350602482015260440161059c565b5f80836001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa158015610acf573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610af39190611fbf565b846001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa158015610b2f573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610b539190611fbf565b91509150846001600160a01b0316826001600160a01b031614158015610bab57507f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b0316826001600160a01b031614155b15610bc95760405163c371b75d60e01b815260040160405180910390fd5b846001600160a01b0316816001600160a01b031614158015610c1d57507f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b0316816001600160a01b031614155b15610c3b5760405163c371b75d60e01b815260040160405180910390fd5b6001600160a01b038581165f81815260026020908152604080832080546001600160a01b031916958a1695861790556004825291829020805462ffffff191662ffffff891617905581519283528201929092527f9d27e1cf9405ac4b83e4312189a6b67a70f739977fba26869888adbf76fd882391015b60405180910390a15050505050565b610cc96114cc565b610e1063ffffffff82161015610cfa5760405163e9171e1760e01b815263ffffffff8216600482015260240161059c565b6001805463ffffffff60a01b1916600160a01b63ffffffff8416908102919091179091556040519081527f670aac3910a07dcfe5267c8b0bf2357abdb454e509764d13e94e85ee13c6da209060200160405180910390a150565b5f80610d5f84611511565b600154604080516002808252606082018352939450600160a01b90920463ffffffff16925f929160208301908036833701905050905081815f81518110610da857610da8611fee565b602002602001019063ffffffff16908163ffffffff16815250505f81600181518110610dd657610dd6611fee565b63ffffffff9092166020928302919091019091015260405163883bdbfd60e01b81525f906001600160a01b0385169063883bdbfd90610e19908590600401612002565b5f60405180830381865afa158015610e33573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f19168201604052610e5a9190810190612110565b5090505f815f81518110610e7057610e70611fee565b602002602001015182600181518110610e8b57610e8b611fee565b60200260200101510390505f8460030b82610ea691906121e9565b90505f8260060b128015610ec95750610ec3600386900b83612225565b60060b15155b15610ed2575f19015b610ede818b8b8b6115ff565b9a9950505050505050505050565b5f80610ef7836111e5565b90505f80610f0583866113eb565b604051635e0d443f60e01b8152600f83810b600483015282900b60248201526044810189905291935091506001600160a01b03841690635e0d443f90606401602060405180830381865afa158015610f5f573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610f839190611ed7565b9695505050505050565b610f956114cc565b600180546001600160a01b0383166001600160a01b03199091168117909155610fc55f546001600160a01b031690565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b6110056114cc565b6001600160a01b038316158061102257506001600160a01b038216155b156110405760405163853ef42360e01b815260040160405180910390fd5b61c3508162ffffff16111561107757604051637af6b7f760e11b815262ffffff8216600482015261c350602482015260440161059c565b5f80611082846116f4565b91509150846001600160a01b0316826001600160a01b0316141580156110da57507f000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee6001600160a01b0316826001600160a01b031614155b156110f85760405163c371b75d60e01b815260040160405180910390fd5b846001600160a01b0316816001600160a01b03161415801561114c57507f000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee6001600160a01b0316816001600160a01b031614155b1561116a5760405163c371b75d60e01b815260040160405180910390fd5b6001600160a01b038581165f81815260036020908152604080832080546001600160a01b031916958a1695861790556004825291829020805462ffffff191662ffffff891617905581519283528201929092527f8fca21c5d308d0debabdfc9dddde40c80ec0ad3e7fac4a6e5f72f038c3aef82d9101610cb2565b6001600160a01b038082165f9081526003602052604090205416806112285760405163b0a43ba560e01b81526001600160a01b038316600482015260240161059c565b919050565b604080516001600160a01b0385811660248301528481166044830152606480830185905283518084039091018152608490920183526020820180516001600160e01b03166323b872dd60e01b17905291515f928392908816916112909190612246565b5f604051808303815f865af19150503d805f81146112c9576040519150601f19603f3d011682016040523d82523d5f602084013e6112ce565b606091505b50915091508180156112f85750805115806112f85750808060200190518101906112f89190612272565b61132a5760405162461bcd60e51b815260206004820152600360248201526229aa2360e91b604482015260640161059c565b505050505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663095ea7b360e01b17905261138384826117d0565b6113e557604080516001600160a01b03851660248201525f6044808301919091528251808303909101815260649091019091526020810180516001600160e01b031663095ea7b360e01b1790526113db908590611871565b6113e58482611871565b50505050565b5f805f6113f7856116f4565b5090505f60016001600160a01b038084169087161461141757808261141a565b81815b945094505050509250929050565b604080515f808252602082019092526001600160a01b0384169083906040516114519190612246565b5f6040518083038185875af1925050503d805f811461148b576040519150601f19603f3d011682016040523d82523d5f602084013e611490565b606091505b50509050806114c75760405162461bcd60e51b815260206004820152600360248201526253544560e81b604482015260640161059c565b505050565b5f546001600160a01b031633146105cd5760405163118cdaa760e01b815233600482015260240161059c565b600180546001600160a01b0319169055610610816118d2565b6001600160a01b038082165f9081526002602052604090205416806112285760405163b0a43ba560e01b81526001600160a01b038316600482015260240161059c565b5f80805f19858709858702925082811083820303915050805f03611588575f841161157d575f80fd5b5082900490506115f8565b808411611593575f80fd5b5f848688095f868103871696879004966002600389028118808a02820302808a02820302808a02820302808a02820302808a02820302808a02909103029181900381900460010186841190950394909402919094039290920491909117919091029150505b9392505050565b5f8061160a86611921565b90506001600160801b036001600160a01b03821611611679576001600160a01b038082168002908481169086161061165957611654600160c01b6001600160801b03881683611554565b611671565b611671816001600160801b038816600160c01b611554565b9250506116eb565b5f6116976001600160a01b0383168068010000000000000000611554565b9050836001600160a01b0316856001600160a01b0316106116cf576116ca600160801b6001600160801b03881683611554565b6116e7565b6116e7816001600160801b038816600160801b611554565b9250505b50949350505050565b60405163c661065760e01b81525f600482018190529081906001600160a01b0384169063c661065790602401602060405180830381865afa15801561173b573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061175f9190611fbf565b60405163c661065760e01b8152600160048201529092506001600160a01b0384169063c661065790602401602060405180830381865afa1580156117a5573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906117c99190611fbf565b9050915091565b5f805f846001600160a01b0316846040516117eb9190612246565b5f604051808303815f865af19150503d805f8114611824576040519150601f19603f3d011682016040523d82523d5f602084013e611829565b606091505b50915091508180156118535750805115806118535750808060200190518101906118539190612272565b801561186857505f856001600160a01b03163b115b95945050505050565b5f6118856001600160a01b03841683611c3c565b905080515f141580156118a95750808060200190518101906118a79190612272565b155b156114c757604051635274afe760e01b81526001600160a01b038416600482015260240161059c565b5f80546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b5f805f8360020b12611936578260020b61193d565b8260020b5f035b9050620d89e8811115611963576040516315e4079d60e11b815260040160405180910390fd5b5f816001165f0361197857600160801b61198a565b6ffffcb933bd6fad37aa2d162d1a5940015b70ffffffffffffffffffffffffffffffffff16905060028216156119be576ffff97272373d413259a46990580e213a0260801c5b60048216156119dd576ffff2e50f5f656932ef12357cf3c7fdcc0260801c5b60088216156119fc576fffe5caca7e10e4e61c3624eaa0941cd00260801c5b6010821615611a1b576fffcb9843d60f6159c9db58835c9266440260801c5b6020821615611a3a576fff973b41fa98c081472e6896dfb254c00260801c5b6040821615611a59576fff2ea16466c96a3843ec78b326b528610260801c5b6080821615611a78576ffe5dee046a99a2a811c461f1969c30530260801c5b610100821615611a98576ffcbe86c7900a88aedcffc83b479aa3a40260801c5b610200821615611ab8576ff987a7253ac413176f2b074cf7815e540260801c5b610400821615611ad8576ff3392b0822b70005940c7a398e4b70f30260801c5b610800821615611af8576fe7159475a2c29b7443b29c7fa6e889d90260801c5b611000821615611b18576fd097f3bdfd2022b8845ad8f792aa58250260801c5b612000821615611b38576fa9f746462d870fdf8a65dc1f90e061e50260801c5b614000821615611b58576f70d869a156d2a1b890bb3df62baf32f70260801c5b618000821615611b78576f31be135f97d08fd981231505542fcfa60260801c5b62010000821615611b99576f09aa508b5b7a84e1c677de54f3e99bc90260801c5b62020000821615611bb9576e5d6af8dedb81196699c329225ee6040260801c5b62040000821615611bd8576d2216e584f5fa1ea926041bedfe980260801c5b62080000821615611bf5576b048a170391f7dc42444e8fa20260801c5b5f8460020b1315611c1457805f1981611c1057611c106121d5565b0490505b640100000000810615611c28576001611c2a565b5f5b60ff16602082901c0192505050919050565b60606115f883835f845f80856001600160a01b03168486604051611c609190612246565b5f6040518083038185875af1925050503d805f8114611c9a576040519150601f19603f3d011682016040523d82523d5f602084013e611c9f565b606091505b5091509150610f83868383606082611cbf57611cba82611d06565b6115f8565b8151158015611cd657506001600160a01b0384163b155b15611cff57604051639996b31560e01b81526001600160a01b038516600482015260240161059c565b50806115f8565b805115611d165780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b6001600160a01b0381168114610610575f80fd5b5f60208284031215611d53575f80fd5b81356115f881611d2f565b5f805f60608486031215611d70575f80fd5b8335611d7b81611d2f565b95602085013595506040909401359392505050565b5f8060408385031215611da1575f80fd5b8235611dac81611d2f565b946020939093013593505050565b62ffffff81168114610610575f80fd5b5f8060408385031215611ddb575f80fd5b8235611de681611d2f565b91506020830135611df681611dba565b809150509250929050565b5f805f60608486031215611e13575f80fd5b8335611e1e81611d2f565b92506020840135611e2e81611d2f565b91506040840135611e3e81611dba565b809150509250925092565b5f60208284031215611e59575f80fd5b813563ffffffff811681146115f8575f80fd5b5f805f60608486031215611e7e575f80fd5b83356001600160801b0381168114611e94575f80fd5b92506020840135611ea481611d2f565b91506040840135611e3e81611d2f565b5f8060408385031215611ec5575f80fd5b823591506020830135611df681611d2f565b5f60208284031215611ee7575f80fd5b5051919050565b634e487b7160e01b5f52601160045260245ffd5b8082018082111561096b5761096b611eee565b5f60208284031215611f25575f80fd5b81516115f881611dba565b5f6101008201905060018060a01b0380845116835280602085015116602084015262ffffff6040850151166040840152806060850151166060840152506080830151608083015260a083015160a083015260c083015160c083015260e0830151611fa560e08401826001600160a01b03169052565b5092915050565b8181038181111561096b5761096b611eee565b5f60208284031215611fcf575f80fd5b81516115f881611d2f565b634e487b7160e01b5f52604160045260245ffd5b634e487b7160e01b5f52603260045260245ffd5b602080825282518282018190525f9190848201906040850190845b8181101561203f57835163ffffffff168352928401929184019160010161201d565b50909695505050505050565b604051601f8201601f1916810167ffffffffffffffff8111828210171561207457612074611fda565b604052919050565b5f67ffffffffffffffff82111561209557612095611fda565b5060051b60200190565b5f82601f8301126120ae575f80fd5b815160206120c36120be8361207c565b61204b565b82815260059290921b840181019181810190868411156120e1575f80fd5b8286015b848110156121055780516120f881611d2f565b83529183019183016120e5565b509695505050505050565b5f8060408385031215612121575f80fd5b825167ffffffffffffffff80821115612138575f80fd5b818501915085601f83011261214b575f80fd5b8151602061215b6120be8361207c565b82815260059290921b84018101918181019089841115612179575f80fd5b948201945b838610156121a65785518060060b8114612197575f8081fd5b8252948201949082019061217e565b918801519196509093505050808211156121be575f80fd5b506121cb8582860161209f565b9150509250929050565b634e487b7160e01b5f52601260045260245ffd5b5f8160060b8360060b806121ff576121ff6121d5565b667fffffffffffff1982145f198214161561221c5761221c611eee565b90059392505050565b5f8260060b80612237576122376121d5565b808360060b0791505092915050565b5f82515f5b81811015612265576020818601810151858301520161224b565b505f920191825250919050565b5f60208284031215612282575f80fd5b815180151581146115f8575f80fdfea2646970667358221220e118057f8578ebbbb10b6a824070f6e51e00d0f4ec47d2dc0bce511b33bc01b764736f6c63430008150033

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

000000000000000000000000eb658c4ea908ac4daf9c309d8f883d6ad758b3a3000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee000000000000000000000000e592427a0aece92de3edee1f18e0157c05861564

-----Decoded View---------------
Arg [0] : _intialOwner (address): 0xeB658c4Ea908aC4dAF9c309D8f883d6aD758b3A3
Arg [1] : _weth9 (address): 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2
Arg [2] : _null (address): 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE
Arg [3] : _v3SwapRouter (address): 0xE592427A0AEce92De3Edee1F18E0157C05861564

-----Encoded View---------------
4 Constructor Arguments found :
Arg [0] : 000000000000000000000000eb658c4ea908ac4daf9c309d8f883d6ad758b3a3
Arg [1] : 000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2
Arg [2] : 000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
Arg [3] : 000000000000000000000000e592427a0aece92de3edee1f18e0157c05861564


Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading
[ Download: CSV Export  ]
[ 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.