HYPE Price: $23.52 (+4.17%)
 

Overview

HYPE Balance

HyperEVM LogoHyperEVM LogoHyperEVM Logo0 HYPE

HYPE Value

$0.00

More Info

Private Name Tags

Multichain Info

No addresses found
Transaction Hash
Block
From
To
Multicall194857852025-11-17 22:48:1267 days ago1763419692IN
0x0F8F203f...d589F3a9e
0 HYPE0.000102780.3222
Collect194857662025-11-17 22:47:5467 days ago1763419674IN
0x0F8F203f...d589F3a9e
0 HYPE0.000039990.12
Multicall194856632025-11-17 22:46:1267 days ago1763419572IN
0x0F8F203f...d589F3a9e
0 HYPE0.000501111.11212514
Multicall193891332025-11-16 20:23:4569 days ago1763324625IN
0x0F8F203f...d589F3a9e
0 HYPE0.000038880.136174
Multicall191813572025-11-14 11:36:1071 days ago1763120170IN
0x0F8F203f...d589F3a9e
0 HYPE0.000317891.0535
Multicall191595982025-11-14 5:39:2871 days ago1763098768IN
0x0F8F203f...d589F3a9e
0 HYPE0.000066940.18365
Multicall191595792025-11-14 5:39:0971 days ago1763098749IN
0x0F8F203f...d589F3a9e
0 HYPE0.00008140.22194837
Multicall191449552025-11-14 1:39:2571 days ago1763084365IN
0x0F8F203f...d589F3a9e
0 HYPE0.000730882.744
Multicall191445542025-11-14 1:32:5171 days ago1763083971IN
0x0F8F203f...d589F3a9e
0 HYPE0.001365082.9809865
Multicall190936752025-11-13 11:38:4672 days ago1763033926IN
0x0F8F203f...d589F3a9e
0 HYPE0.000057620.18166
Multicall190935822025-11-13 11:37:1472 days ago1763033834IN
0x0F8F203f...d589F3a9e
0 HYPE0.00006330.1996
Multicall190918542025-11-13 11:08:5572 days ago1763032135IN
0x0F8F203f...d589F3a9e
0 HYPE0.000030240.11
Multicall190591942025-11-13 2:13:3072 days ago1763000010IN
0x0F8F203f...d589F3a9e
0 HYPE0.000035940.1115344
Multicall190591072025-11-13 2:12:0472 days ago1762999924IN
0x0F8F203f...d589F3a9e
0 HYPE0.000336941.04573218
Multicall190582622025-11-13 1:58:1372 days ago1762999093IN
0x0F8F203f...d589F3a9e
0 HYPE0.00002980.106032
Multicall190561902025-11-13 1:24:1572 days ago1762997055IN
0x0F8F203f...d589F3a9e
0 HYPE0.000207830.3227
Multicall190249612025-11-12 16:52:1873 days ago1762966338IN
0x0F8F203f...d589F3a9e
0 HYPE0.00009980.29104414
Increase Liquidi...190165192025-11-12 14:33:5573 days ago1762958035IN
0x0F8F203f...d589F3a9e
0 HYPE0.001108453.65821129
Collect190163432025-11-12 14:31:0173 days ago1762957861IN
0x0F8F203f...d589F3a9e
0 HYPE0.000609733.39290169
Multicall190072892025-11-12 12:02:3673 days ago1762948956IN
0x0F8F203f...d589F3a9e
0 HYPE0.0037182710.62
Multicall189857152025-11-12 6:08:5673 days ago1762927736IN
0x0F8F203f...d589F3a9e
0 HYPE0.000026620.11076193
Multicall189503792025-11-11 20:29:3974 days ago1762892979IN
0x0F8F203f...d589F3a9e
0 HYPE0.000156050.5117
Multicall189499302025-11-11 20:22:1774 days ago1762892537IN
0x0F8F203f...d589F3a9e
0 HYPE0.000148440.8499
Multicall189350322025-11-11 16:18:0374 days ago1762877883IN
0x0F8F203f...d589F3a9e
0 HYPE0.001191293.81112458
Safe Transfer Fr...189348952025-11-11 16:15:4974 days ago1762877749IN
0x0F8F203f...d589F3a9e
0 HYPE0.000138851.66145708
View all transactions

Latest 25 internal transactions (View All)

Advanced mode:
Parent Transaction Hash Block From To
194857852025-11-17 22:48:1267 days ago1763419692
0x0F8F203f...d589F3a9e
63.62775713 HYPE
194857852025-11-17 22:48:1267 days ago1763419692
0x0F8F203f...d589F3a9e
63.62775713 HYPE
194856632025-11-17 22:46:1267 days ago1763419572
0x0F8F203f...d589F3a9e
878.16427289 HYPE
194856632025-11-17 22:46:1267 days ago1763419572
0x0F8F203f...d589F3a9e
878.16427289 HYPE
191813572025-11-14 11:36:1071 days ago1763120170
0x0F8F203f...d589F3a9e
0.00035946 HYPE
191813572025-11-14 11:36:1071 days ago1763120170
0x0F8F203f...d589F3a9e
0.00035946 HYPE
191595982025-11-14 5:39:2871 days ago1763098768
0x0F8F203f...d589F3a9e
0.00120157 HYPE
191595982025-11-14 5:39:2871 days ago1763098768
0x0F8F203f...d589F3a9e
0.00120157 HYPE
191595792025-11-14 5:39:0971 days ago1763098749
0x0F8F203f...d589F3a9e
0.00084351 HYPE
191595792025-11-14 5:39:0971 days ago1763098749
0x0F8F203f...d589F3a9e
0.00084351 HYPE
191449552025-11-14 1:39:2571 days ago1763084365
0x0F8F203f...d589F3a9e
0.03558706 HYPE
191449552025-11-14 1:39:2571 days ago1763084365
0x0F8F203f...d589F3a9e
0.03558706 HYPE
191445542025-11-14 1:32:5171 days ago1763083971
0x0F8F203f...d589F3a9e
3.56008399 HYPE
191445542025-11-14 1:32:5171 days ago1763083971
0x0F8F203f...d589F3a9e
3.56008399 HYPE
190936752025-11-13 11:38:4672 days ago1763033926
0x0F8F203f...d589F3a9e
0.10656114 HYPE
190936752025-11-13 11:38:4672 days ago1763033926
0x0F8F203f...d589F3a9e
0.10656114 HYPE
190935822025-11-13 11:37:1472 days ago1763033834
0x0F8F203f...d589F3a9e
0.07159324 HYPE
190935822025-11-13 11:37:1472 days ago1763033834
0x0F8F203f...d589F3a9e
0.07159324 HYPE
190591942025-11-13 2:13:3072 days ago1763000010
0x0F8F203f...d589F3a9e
10.83761048 HYPE
190591942025-11-13 2:13:3072 days ago1763000010
0x0F8F203f...d589F3a9e
10.83761048 HYPE
190591072025-11-13 2:12:0472 days ago1762999924
0x0F8F203f...d589F3a9e
7.32656119 HYPE
190591072025-11-13 2:12:0472 days ago1762999924
0x0F8F203f...d589F3a9e
7.32656119 HYPE
189503792025-11-11 20:29:3974 days ago1762892979
0x0F8F203f...d589F3a9e
58.48005913 HYPE
189503792025-11-11 20:29:3974 days ago1762892979
0x0F8F203f...d589F3a9e
58.48005913 HYPE
189350322025-11-11 16:18:0374 days ago1762877883
0x0F8F203f...d589F3a9e
144.44642995 HYPE
View All Internal Transactions
Cross-Chain Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
RamsesV3PositionManager

Compiler Version
v0.8.28+commit.7893614a

Optimization Enabled:
Yes with 300 runs

Other Settings:
cancun EvmVersion
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8.0;
pragma abicoder v2;

import {ERC721} from "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import {ERC721Enumerable, IERC165} from "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
import {IERC721, IERC721Metadata} from "@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol";
import {Multicall} from "./base/Multicall.sol";

import {IRamsesV3Pool} from "../core/interfaces/IRamsesV3Pool.sol";
import {FixedPoint128} from "../core/libraries/FixedPoint128.sol";
import {FullMath} from "../core/libraries/FullMath.sol";

import {INonfungiblePositionManager} from "./interfaces/INonfungiblePositionManager.sol";
import {IRamsesV3PositionManager} from "./interfaces/IRamsesV3PositionManager.sol";
import {INonfungibleTokenPositionDescriptor} from "./interfaces/INonfungibleTokenPositionDescriptor.sol";
import {PositionKey} from "./libraries/PositionKey.sol";
import {PoolAddress} from "./libraries/PoolAddress.sol";
import {LiquidityManagement} from "./base/LiquidityManagement.sol";
import {PeripheryImmutableState} from "./base/PeripheryImmutableState.sol";
import {PeripheryValidation} from "./base/PeripheryValidation.sol";
import {PoolInitializer} from "./base/PoolInitializer.sol";

import {IGaugeV3} from "../gauge/interfaces/IGaugeV3.sol";
import {IVoter} from "../../interfaces/IVoter.sol";
import {IAccessHub} from "../../interfaces/IAccessHub.sol";

/// @title NFT positions
/// @notice Wraps Ramses V3 positions in the ERC721 non-fungible token interface
contract RamsesV3PositionManager is
    Multicall,
    PeripheryImmutableState,
    PoolInitializer,
    LiquidityManagement,
    PeripheryValidation,
    ERC721,
    ERC721Enumerable,
    IRamsesV3PositionManager
{
    /// @dev details about the Ramses position
    struct Position {
        /// @dev the ID of the pool with which this token is connected
        uint48 poolId;
        /// @dev last updated timestamp
        uint32 lastModified;
        /// @dev the tick range of the position
        int24 tickLower;
        int24 tickUpper;
        /// @dev the liquidity of the position
        uint128 liquidity;
        /// @dev the fee growth of the aggregate position as of the last action on the individual position
        uint256 feeGrowthInside0LastX128;
        uint256 feeGrowthInside1LastX128;
        /// @dev how many uncollected tokens are owed to the position, as of the last computation
        uint128 tokensOwed0;
        uint128 tokensOwed1;
    }

    /// @dev IDs of pools assigned by this contract
    mapping(address pool => uint48 id) private _poolIds;

    /// @dev Pool keys by pool ID, to save on SSTOREs for position data
    mapping(uint48 id => PoolAddress.PoolKey key) private _poolIdToPoolKey;

    /// @dev The token ID position data
    mapping(uint256 tokenId => Position position) private _positions;

    /// @dev The ID of the next token that will be minted. Skips 0
    uint176 private _nextId = 1;
    /// @dev The ID of the next pool that is used for the first time. Skips 0
    uint48 private _nextPoolId = 1;

    /// @dev The address of the token descriptor contract, which handles generating token URIs for position tokens
    address private immutable _tokenDescriptor;

    /// @dev access control hub
    IAccessHub private immutable accessHub;

    /// @dev the address of the voter contract
    IVoter private voter;
    address private ram;
    address private xRam;

    constructor(
        address _deployer,
        address _WETH9,
        address _tokenDescriptor_,
        address _accessHub
    ) ERC721("Ramses V3 Non Fungible Position", "RAM-V3-NFP") PeripheryImmutableState(_deployer, _WETH9) {
        _tokenDescriptor = _tokenDescriptor_;
        accessHub = IAccessHub(_accessHub);
    }

    /// @inheritdoc INonfungiblePositionManager
    function positions(
        uint256 tokenId
    )
        external
        view
        override
        returns (
            address token0,
            address token1,
            int24 tickSpacing,
            int24 tickLower,
            int24 tickUpper,
            uint128 liquidity,
            uint256 feeGrowthInside0LastX128,
            uint256 feeGrowthInside1LastX128,
            uint128 tokensOwed0,
            uint128 tokensOwed1
        )
    {
        Position memory position = _positions[tokenId];
        if (position.poolId == 0) revert InvalidTokenId(tokenId);
        PoolAddress.PoolKey memory poolKey = _poolIdToPoolKey[position.poolId];
        return (
            poolKey.token0,
            poolKey.token1,
            poolKey.tickSpacing,
            position.tickLower,
            position.tickUpper,
            position.liquidity,
            position.feeGrowthInside0LastX128,
            position.feeGrowthInside1LastX128,
            position.tokensOwed0,
            position.tokensOwed1
        );
    }

    /// @dev Caches a pool key
    function cachePoolKey(address pool, PoolAddress.PoolKey memory poolKey) private returns (uint48 poolId) {
        poolId = _poolIds[pool];
        if (poolId == 0) {
            _poolIds[pool] = (poolId = _nextPoolId++);
            _poolIdToPoolKey[poolId] = poolKey;
        }
    }

    /// @inheritdoc INonfungiblePositionManager
    function mint(
        MintParams calldata params
    )
        external
        payable
        override
        checkDeadline(params.deadline)
        returns (uint256 tokenId, uint128 liquidity, uint256 amount0, uint256 amount1)
    {
        IRamsesV3Pool pool;
        unchecked {
            tokenId = _nextId++;
        }
        (liquidity, amount0, amount1, pool) = addLiquidity(
            AddLiquidityParams({
                token0: params.token0,
                token1: params.token1,
                tickSpacing: params.tickSpacing,
                recipient: address(this),
                index: tokenId,
                tickLower: params.tickLower,
                tickUpper: params.tickUpper,
                amount0Desired: params.amount0Desired,
                amount1Desired: params.amount1Desired,
                amount0Min: params.amount0Min,
                amount1Min: params.amount1Min
            })
        );

        _mint(params.recipient, tokenId);

        bytes32 positionKey = PositionKey.compute(address(this), tokenId, params.tickLower, params.tickUpper);
        (, uint256 feeGrowthInside0LastX128, uint256 feeGrowthInside1LastX128, , ) = pool.positions(positionKey);

        /// @dev idempotent set
        uint48 poolId = cachePoolKey(
            address(pool),
            PoolAddress.PoolKey({token0: params.token0, token1: params.token1, tickSpacing: params.tickSpacing})
        );

        _positions[tokenId] = Position({
            poolId: poolId,
            lastModified: uint32(block.timestamp),
            tickLower: params.tickLower,
            tickUpper: params.tickUpper,
            liquidity: liquidity,
            feeGrowthInside0LastX128: feeGrowthInside0LastX128,
            feeGrowthInside1LastX128: feeGrowthInside1LastX128,
            tokensOwed0: 0,
            tokensOwed1: 0
        });

        emit IncreaseLiquidity(tokenId, liquidity, amount0, amount1);
    }

    modifier isAuthorizedForToken(uint256 tokenId) {
        address owner = _ownerOf(tokenId);
        _checkAuthorized(owner, msg.sender, tokenId);
        _;
    }

    function tokenURI(uint256 tokenId) public view override(ERC721, IERC721Metadata) returns (string memory) {
        _requireOwned(tokenId);
        return INonfungibleTokenPositionDescriptor(_tokenDescriptor).tokenURI(this, tokenId);
    }

    function _tryClaimRewards(uint256 tokenId, IRamsesV3Pool pool) private {
        if (voter != IVoter(address(0))) {
            address gauge = voter.gaugeForPool(address(pool));
            if (gauge != address(0)) {
                // only claim protocol tokens to prevent gas bomb attacks
                address[] memory rewardTokens = new address[](2);
                rewardTokens[0] = ram;
                rewardTokens[1] = xRam;
                
                try IGaugeV3(gauge).getRewardForOwner(tokenId, rewardTokens) {
                } catch {
                }
            }
        }
    }

    /// @inheritdoc INonfungiblePositionManager
    function increaseLiquidity(
        IncreaseLiquidityParams calldata params
    )
        external
        payable
        override
        isAuthorizedForToken(params.tokenId)
        checkDeadline(params.deadline)
        returns (uint128 liquidity, uint256 amount0, uint256 amount1)
    {
        Position storage position = _positions[params.tokenId];

        PoolAddress.PoolKey memory poolKey = _poolIdToPoolKey[position.poolId];
        IRamsesV3Pool pool;
        (liquidity, amount0, amount1, pool) = addLiquidity(
            AddLiquidityParams({
                token0: poolKey.token0,
                token1: poolKey.token1,
                tickSpacing: poolKey.tickSpacing,
                tickLower: position.tickLower,
                tickUpper: position.tickUpper,
                amount0Desired: params.amount0Desired,
                amount1Desired: params.amount1Desired,
                amount0Min: params.amount0Min,
                amount1Min: params.amount1Min,
                recipient: address(this),
                index: params.tokenId
            })
        );
        /// @dev claim rewards after modifying liquidity ensures period already advanced for first claims
        _tryClaimRewards(params.tokenId, pool);

        bytes32 positionKey = PositionKey.compute(
            address(this),
            params.tokenId,
            position.tickLower,
            position.tickUpper
        );

        /// @dev this is now updated to the current transaction
        (, uint256 feeGrowthInside0LastX128, uint256 feeGrowthInside1LastX128, , ) = pool.positions(positionKey);

        unchecked {
            position.tokensOwed0 += uint128(
                FullMath.mulDiv(
                    feeGrowthInside0LastX128 - position.feeGrowthInside0LastX128,
                    position.liquidity,
                    FixedPoint128.Q128
                )
            );
            position.tokensOwed1 += uint128(
                FullMath.mulDiv(
                    feeGrowthInside1LastX128 - position.feeGrowthInside1LastX128,
                    position.liquidity,
                    FixedPoint128.Q128
                )
            );
        }

        position.feeGrowthInside0LastX128 = feeGrowthInside0LastX128;
        position.feeGrowthInside1LastX128 = feeGrowthInside1LastX128;

        unchecked {
            position.liquidity += liquidity;
        }
        
        // checkpoint
        position.lastModified = uint32(block.timestamp);

        emit IncreaseLiquidity(params.tokenId, liquidity, amount0, amount1);
    }

    /// @inheritdoc INonfungiblePositionManager
    function decreaseLiquidity(
        DecreaseLiquidityParams calldata params
    )
        external
        payable
        override
        isAuthorizedForToken(params.tokenId)
        checkDeadline(params.deadline)
        returns (uint256 amount0, uint256 amount1)
    {
        require(params.liquidity > 0);
        Position storage position = _positions[params.tokenId];

        uint128 positionLiquidity = position.liquidity;
        require(positionLiquidity >= params.liquidity);

        PoolAddress.PoolKey memory poolKey = _poolIdToPoolKey[position.poolId];
        
        
        IRamsesV3Pool pool = IRamsesV3Pool(PoolAddress.computeAddress(deployer, poolKey));
        (amount0, amount1) = pool.burn(params.tokenId, position.tickLower, position.tickUpper, params.liquidity);
        /// @dev claim rewards after modifying liquidity ensures period already advanced for first claims
        _tryClaimRewards(params.tokenId, pool);

        if (amount0 < params.amount0Min || amount1 < params.amount1Min) revert CheckSlippage();

        bytes32 positionKey = PositionKey.compute(
            address(this),
            params.tokenId,
            position.tickLower,
            position.tickUpper
        );
        /// @dev this is now updated to the current transaction
        (, uint256 feeGrowthInside0LastX128, uint256 feeGrowthInside1LastX128, , ) = pool.positions(positionKey);

        unchecked {
            position.tokensOwed0 +=
                uint128(amount0) +
                uint128(
                    FullMath.mulDiv(
                        feeGrowthInside0LastX128 - position.feeGrowthInside0LastX128,
                        positionLiquidity,
                        FixedPoint128.Q128
                    )
                );
            position.tokensOwed1 +=
                uint128(amount1) +
                uint128(
                    FullMath.mulDiv(
                        feeGrowthInside1LastX128 - position.feeGrowthInside1LastX128,
                        positionLiquidity,
                        FixedPoint128.Q128
                    )
                );
        }

        position.feeGrowthInside0LastX128 = feeGrowthInside0LastX128;
        position.feeGrowthInside1LastX128 = feeGrowthInside1LastX128;
        /// @dev subtraction is safe because we checked positionLiquidity is gte params.liquidity
        unchecked {
            position.liquidity = positionLiquidity - params.liquidity;
        }

        // checkpoint
        position.lastModified = uint32(block.timestamp);

        emit DecreaseLiquidity(params.tokenId, params.liquidity, amount0, amount1);
    }

    /// @inheritdoc INonfungiblePositionManager
    function collect(
        CollectParams calldata params
    ) external payable override isAuthorizedForToken(params.tokenId) returns (uint256 amount0, uint256 amount1) {
        require(params.amount0Max > 0 || params.amount1Max > 0);

        Position storage position = _positions[params.tokenId];

        PoolAddress.PoolKey memory poolKey = _poolIdToPoolKey[position.poolId];

        IRamsesV3Pool pool = IRamsesV3Pool(PoolAddress.computeAddress(deployer, poolKey));

        (uint128 tokensOwed0, uint128 tokensOwed1) = (position.tokensOwed0, position.tokensOwed1);

        /// @dev trigger an update of the position fees owed and fee growth snapshots if it has any liquidity
        if (position.liquidity > 0) {
            pool.burn(params.tokenId, position.tickLower, position.tickUpper, 0);
            (, uint256 feeGrowthInside0LastX128, uint256 feeGrowthInside1LastX128, , ) = pool.positions(
                PositionKey.compute(address(this), params.tokenId, position.tickLower, position.tickUpper)
            );

            unchecked {
                tokensOwed0 += uint128(
                    FullMath.mulDiv(
                        feeGrowthInside0LastX128 - position.feeGrowthInside0LastX128,
                        position.liquidity,
                        FixedPoint128.Q128
                    )
                );
                tokensOwed1 += uint128(
                    FullMath.mulDiv(
                        feeGrowthInside1LastX128 - position.feeGrowthInside1LastX128,
                        position.liquidity,
                        FixedPoint128.Q128
                    )
                );
            }

            position.feeGrowthInside0LastX128 = feeGrowthInside0LastX128;
            position.feeGrowthInside1LastX128 = feeGrowthInside1LastX128;
        }

        /// @dev compute the arguments to give to the pool#collect method
        (uint128 amount0Collect, uint128 amount1Collect) = (
            params.amount0Max > tokensOwed0 ? tokensOwed0 : params.amount0Max,
            params.amount1Max > tokensOwed1 ? tokensOwed1 : params.amount1Max
        );

        /// @dev allow collecting to the nft position manager address with address 0
        address recipient = params.recipient == address(0) ? address(this) : params.recipient;

        /// @dev the actual amounts collected are returned
        (amount0, amount1) = pool.collect(
            recipient,
            params.tokenId,
            position.tickLower,
            position.tickUpper,
            amount0Collect,
            amount1Collect
        );

        /// @dev sometimes there will be a few less wei than expected due to rounding down in core, but we just subtract the full amount expected
        /// @dev instead of the actual amount so we can burn the token
        unchecked {
            (position.tokensOwed0, position.tokensOwed1) = (tokensOwed0 - amount0Collect, tokensOwed1 - amount1Collect);
        }

        emit Collect(params.tokenId, recipient, amount0Collect, amount1Collect);
    }

    /// @inheritdoc IRamsesV3PositionManager
    function getReward(uint256 tokenId, address[] calldata tokens) external payable isAuthorizedForToken(tokenId) {
        Position storage position = _positions[tokenId];


        PoolAddress.PoolKey memory poolKey = _poolIdToPoolKey[position.poolId];
        IGaugeV3 gauge = IGaugeV3(voter.gaugeForPool(PoolAddress.computeAddress(deployer, poolKey)));
        
        gauge.getRewardForOwner(tokenId, tokens);
    }

    /// @inheritdoc IRamsesV3PositionManager
    function getPeriodReward(
        uint256 period, 
        uint256 tokenId, 
        address[] calldata tokens,
        address receiver
    ) external payable isAuthorizedForToken(tokenId) {
        Position storage position = _positions[tokenId];
        
        PoolAddress.PoolKey memory poolKey = _poolIdToPoolKey[position.poolId];
        address gauge = voter.gaugeForPool(PoolAddress.computeAddress(deployer, poolKey));
            
        IGaugeV3(gauge).getPeriodReward(period, tokens, address(this), tokenId, position.tickLower, position.tickUpper, receiver);
    }

    /// @inheritdoc IRamsesV3PositionManager
    function positionLastModified(uint256 tokenId) external view returns (uint32) {
        return _positions[tokenId].lastModified;
    }

    /// @inheritdoc INonfungiblePositionManager
    function burn(uint256 tokenId) external payable override isAuthorizedForToken(tokenId) {
        Position storage position = _positions[tokenId];
        if (position.liquidity > 0 || position.tokensOwed0 > 0 || position.tokensOwed1 > 0) revert NotCleared();
        delete _positions[tokenId];
        _burn(tokenId);
    }

    /// @notice extra function that allows for the 2-step deployment of CL first, then governance later
    /// @dev gated to the timelock
    function setVoter(IVoter _voter) external {
        require(msg.sender == accessHub.timelock());
        voter = _voter;
        
        // cache ram and xphar addresses to save gas on every claim
        ram = _voter.ram();
        xRam = _voter.xRam();
    }

    //** Overrides */

    function _update(
        address to,
        uint256 tokenId,
        address auth
    ) internal override(ERC721, ERC721Enumerable) returns (address) {
        return super._update(to, tokenId, auth);
    }

    function _increaseBalance(address account, uint128 value) internal override(ERC721, ERC721Enumerable) {
        super._increaseBalance(account, value);
    }

    function supportsInterface(
        bytes4 interfaceId
    ) public view override(ERC721, IERC165, ERC721Enumerable) returns (bool) {
        return super.supportsInterface(interfaceId);
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC721/ERC721.sol)

pragma solidity ^0.8.20;

import {IERC721} from "./IERC721.sol";
import {IERC721Metadata} from "./extensions/IERC721Metadata.sol";
import {ERC721Utils} from "./utils/ERC721Utils.sol";
import {Context} from "../../utils/Context.sol";
import {Strings} from "../../utils/Strings.sol";
import {IERC165, ERC165} from "../../utils/introspection/ERC165.sol";
import {IERC721Errors} from "../../interfaces/draft-IERC6093.sol";

/**
 * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC-721] Non-Fungible Token Standard, including
 * the Metadata extension, but not including the Enumerable extension, which is available separately as
 * {ERC721Enumerable}.
 */
abstract contract ERC721 is Context, ERC165, IERC721, IERC721Metadata, IERC721Errors {
    using Strings for uint256;

    // Token name
    string private _name;

    // Token symbol
    string private _symbol;

    mapping(uint256 tokenId => address) private _owners;

    mapping(address owner => uint256) private _balances;

    mapping(uint256 tokenId => address) private _tokenApprovals;

    mapping(address owner => mapping(address operator => bool)) private _operatorApprovals;

    /**
     * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.
     */
    constructor(string memory name_, string memory symbol_) {
        _name = name_;
        _symbol = symbol_;
    }

    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
        return
            interfaceId == type(IERC721).interfaceId ||
            interfaceId == type(IERC721Metadata).interfaceId ||
            super.supportsInterface(interfaceId);
    }

    /**
     * @dev See {IERC721-balanceOf}.
     */
    function balanceOf(address owner) public view virtual returns (uint256) {
        if (owner == address(0)) {
            revert ERC721InvalidOwner(address(0));
        }
        return _balances[owner];
    }

    /**
     * @dev See {IERC721-ownerOf}.
     */
    function ownerOf(uint256 tokenId) public view virtual returns (address) {
        return _requireOwned(tokenId);
    }

    /**
     * @dev See {IERC721Metadata-name}.
     */
    function name() public view virtual returns (string memory) {
        return _name;
    }

    /**
     * @dev See {IERC721Metadata-symbol}.
     */
    function symbol() public view virtual returns (string memory) {
        return _symbol;
    }

    /**
     * @dev See {IERC721Metadata-tokenURI}.
     */
    function tokenURI(uint256 tokenId) public view virtual returns (string memory) {
        _requireOwned(tokenId);

        string memory baseURI = _baseURI();
        return bytes(baseURI).length > 0 ? string.concat(baseURI, tokenId.toString()) : "";
    }

    /**
     * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
     * token will be the concatenation of the `baseURI` and the `tokenId`. Empty
     * by default, can be overridden in child contracts.
     */
    function _baseURI() internal view virtual returns (string memory) {
        return "";
    }

    /**
     * @dev See {IERC721-approve}.
     */
    function approve(address to, uint256 tokenId) public virtual {
        _approve(to, tokenId, _msgSender());
    }

    /**
     * @dev See {IERC721-getApproved}.
     */
    function getApproved(uint256 tokenId) public view virtual returns (address) {
        _requireOwned(tokenId);

        return _getApproved(tokenId);
    }

    /**
     * @dev See {IERC721-setApprovalForAll}.
     */
    function setApprovalForAll(address operator, bool approved) public virtual {
        _setApprovalForAll(_msgSender(), operator, approved);
    }

    /**
     * @dev See {IERC721-isApprovedForAll}.
     */
    function isApprovedForAll(address owner, address operator) public view virtual returns (bool) {
        return _operatorApprovals[owner][operator];
    }

    /**
     * @dev See {IERC721-transferFrom}.
     */
    function transferFrom(address from, address to, uint256 tokenId) public virtual {
        if (to == address(0)) {
            revert ERC721InvalidReceiver(address(0));
        }
        // Setting an "auth" arguments enables the `_isAuthorized` check which verifies that the token exists
        // (from != 0). Therefore, it is not needed to verify that the return value is not 0 here.
        address previousOwner = _update(to, tokenId, _msgSender());
        if (previousOwner != from) {
            revert ERC721IncorrectOwner(from, tokenId, previousOwner);
        }
    }

    /**
     * @dev See {IERC721-safeTransferFrom}.
     */
    function safeTransferFrom(address from, address to, uint256 tokenId) public {
        safeTransferFrom(from, to, tokenId, "");
    }

    /**
     * @dev See {IERC721-safeTransferFrom}.
     */
    function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data) public virtual {
        transferFrom(from, to, tokenId);
        ERC721Utils.checkOnERC721Received(_msgSender(), from, to, tokenId, data);
    }

    /**
     * @dev Returns the owner of the `tokenId`. Does NOT revert if token doesn't exist
     *
     * IMPORTANT: Any overrides to this function that add ownership of tokens not tracked by the
     * core ERC-721 logic MUST be matched with the use of {_increaseBalance} to keep balances
     * consistent with ownership. The invariant to preserve is that for any address `a` the value returned by
     * `balanceOf(a)` must be equal to the number of tokens such that `_ownerOf(tokenId)` is `a`.
     */
    function _ownerOf(uint256 tokenId) internal view virtual returns (address) {
        return _owners[tokenId];
    }

    /**
     * @dev Returns the approved address for `tokenId`. Returns 0 if `tokenId` is not minted.
     */
    function _getApproved(uint256 tokenId) internal view virtual returns (address) {
        return _tokenApprovals[tokenId];
    }

    /**
     * @dev Returns whether `spender` is allowed to manage `owner`'s tokens, or `tokenId` in
     * particular (ignoring whether it is owned by `owner`).
     *
     * WARNING: This function assumes that `owner` is the actual owner of `tokenId` and does not verify this
     * assumption.
     */
    function _isAuthorized(address owner, address spender, uint256 tokenId) internal view virtual returns (bool) {
        return
            spender != address(0) &&
            (owner == spender || isApprovedForAll(owner, spender) || _getApproved(tokenId) == spender);
    }

    /**
     * @dev Checks if `spender` can operate on `tokenId`, assuming the provided `owner` is the actual owner.
     * Reverts if:
     * - `spender` does not have approval from `owner` for `tokenId`.
     * - `spender` does not have approval to manage all of `owner`'s assets.
     *
     * WARNING: This function assumes that `owner` is the actual owner of `tokenId` and does not verify this
     * assumption.
     */
    function _checkAuthorized(address owner, address spender, uint256 tokenId) internal view virtual {
        if (!_isAuthorized(owner, spender, tokenId)) {
            if (owner == address(0)) {
                revert ERC721NonexistentToken(tokenId);
            } else {
                revert ERC721InsufficientApproval(spender, tokenId);
            }
        }
    }

    /**
     * @dev Unsafe write access to the balances, used by extensions that "mint" tokens using an {ownerOf} override.
     *
     * NOTE: the value is limited to type(uint128).max. This protect against _balance overflow. It is unrealistic that
     * a uint256 would ever overflow from increments when these increments are bounded to uint128 values.
     *
     * WARNING: Increasing an account's balance using this function tends to be paired with an override of the
     * {_ownerOf} function to resolve the ownership of the corresponding tokens so that balances and ownership
     * remain consistent with one another.
     */
    function _increaseBalance(address account, uint128 value) internal virtual {
        unchecked {
            _balances[account] += value;
        }
    }

    /**
     * @dev Transfers `tokenId` from its current owner to `to`, or alternatively mints (or burns) if the current owner
     * (or `to`) is the zero address. Returns the owner of the `tokenId` before the update.
     *
     * The `auth` argument is optional. If the value passed is non 0, then this function will check that
     * `auth` is either the owner of the token, or approved to operate on the token (by the owner).
     *
     * Emits a {Transfer} event.
     *
     * NOTE: If overriding this function in a way that tracks balances, see also {_increaseBalance}.
     */
    function _update(address to, uint256 tokenId, address auth) internal virtual returns (address) {
        address from = _ownerOf(tokenId);

        // Perform (optional) operator check
        if (auth != address(0)) {
            _checkAuthorized(from, auth, tokenId);
        }

        // Execute the update
        if (from != address(0)) {
            // Clear approval. No need to re-authorize or emit the Approval event
            _approve(address(0), tokenId, address(0), false);

            unchecked {
                _balances[from] -= 1;
            }
        }

        if (to != address(0)) {
            unchecked {
                _balances[to] += 1;
            }
        }

        _owners[tokenId] = to;

        emit Transfer(from, to, tokenId);

        return from;
    }

    /**
     * @dev Mints `tokenId` and transfers it to `to`.
     *
     * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible
     *
     * Requirements:
     *
     * - `tokenId` must not exist.
     * - `to` cannot be the zero address.
     *
     * Emits a {Transfer} event.
     */
    function _mint(address to, uint256 tokenId) internal {
        if (to == address(0)) {
            revert ERC721InvalidReceiver(address(0));
        }
        address previousOwner = _update(to, tokenId, address(0));
        if (previousOwner != address(0)) {
            revert ERC721InvalidSender(address(0));
        }
    }

    /**
     * @dev Mints `tokenId`, transfers it to `to` and checks for `to` acceptance.
     *
     * Requirements:
     *
     * - `tokenId` must not exist.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function _safeMint(address to, uint256 tokenId) internal {
        _safeMint(to, tokenId, "");
    }

    /**
     * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is
     * forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
     */
    function _safeMint(address to, uint256 tokenId, bytes memory data) internal virtual {
        _mint(to, tokenId);
        ERC721Utils.checkOnERC721Received(_msgSender(), address(0), to, tokenId, data);
    }

    /**
     * @dev Destroys `tokenId`.
     * The approval is cleared when the token is burned.
     * This is an internal function that does not check if the sender is authorized to operate on the token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     *
     * Emits a {Transfer} event.
     */
    function _burn(uint256 tokenId) internal {
        address previousOwner = _update(address(0), tokenId, address(0));
        if (previousOwner == address(0)) {
            revert ERC721NonexistentToken(tokenId);
        }
    }

    /**
     * @dev Transfers `tokenId` from `from` to `to`.
     *  As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     *
     * Emits a {Transfer} event.
     */
    function _transfer(address from, address to, uint256 tokenId) internal {
        if (to == address(0)) {
            revert ERC721InvalidReceiver(address(0));
        }
        address previousOwner = _update(to, tokenId, address(0));
        if (previousOwner == address(0)) {
            revert ERC721NonexistentToken(tokenId);
        } else if (previousOwner != from) {
            revert ERC721IncorrectOwner(from, tokenId, previousOwner);
        }
    }

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`, checking that contract recipients
     * are aware of the ERC-721 standard to prevent tokens from being forever locked.
     *
     * `data` is additional data, it has no specified format and it is sent in call to `to`.
     *
     * This internal function is like {safeTransferFrom} in the sense that it invokes
     * {IERC721Receiver-onERC721Received} on the receiver, and can be used to e.g.
     * implement alternative mechanisms to perform token transfer, such as signature-based.
     *
     * Requirements:
     *
     * - `tokenId` token must exist and be owned by `from`.
     * - `to` cannot be the zero address.
     * - `from` cannot be the zero address.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function _safeTransfer(address from, address to, uint256 tokenId) internal {
        _safeTransfer(from, to, tokenId, "");
    }

    /**
     * @dev Same as {xref-ERC721-_safeTransfer-address-address-uint256-}[`_safeTransfer`], with an additional `data` parameter which is
     * forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
     */
    function _safeTransfer(address from, address to, uint256 tokenId, bytes memory data) internal virtual {
        _transfer(from, to, tokenId);
        ERC721Utils.checkOnERC721Received(_msgSender(), from, to, tokenId, data);
    }

    /**
     * @dev Approve `to` to operate on `tokenId`
     *
     * The `auth` argument is optional. If the value passed is non 0, then this function will check that `auth` is
     * either the owner of the token, or approved to operate on all tokens held by this owner.
     *
     * Emits an {Approval} event.
     *
     * Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument.
     */
    function _approve(address to, uint256 tokenId, address auth) internal {
        _approve(to, tokenId, auth, true);
    }

    /**
     * @dev Variant of `_approve` with an optional flag to enable or disable the {Approval} event. The event is not
     * emitted in the context of transfers.
     */
    function _approve(address to, uint256 tokenId, address auth, bool emitEvent) internal virtual {
        // Avoid reading the owner unless necessary
        if (emitEvent || auth != address(0)) {
            address owner = _requireOwned(tokenId);

            // We do not use _isAuthorized because single-token approvals should not be able to call approve
            if (auth != address(0) && owner != auth && !isApprovedForAll(owner, auth)) {
                revert ERC721InvalidApprover(auth);
            }

            if (emitEvent) {
                emit Approval(owner, to, tokenId);
            }
        }

        _tokenApprovals[tokenId] = to;
    }

    /**
     * @dev Approve `operator` to operate on all of `owner` tokens
     *
     * Requirements:
     * - operator can't be the address zero.
     *
     * Emits an {ApprovalForAll} event.
     */
    function _setApprovalForAll(address owner, address operator, bool approved) internal virtual {
        if (operator == address(0)) {
            revert ERC721InvalidOperator(operator);
        }
        _operatorApprovals[owner][operator] = approved;
        emit ApprovalForAll(owner, operator, approved);
    }

    /**
     * @dev Reverts if the `tokenId` doesn't have a current owner (it hasn't been minted, or it has been burned).
     * Returns the owner.
     *
     * Overrides to ownership logic should be done to {_ownerOf}.
     */
    function _requireOwned(uint256 tokenId) internal view returns (address) {
        address owner = _ownerOf(tokenId);
        if (owner == address(0)) {
            revert ERC721NonexistentToken(tokenId);
        }
        return owner;
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC721/extensions/ERC721Enumerable.sol)

pragma solidity ^0.8.20;

import {ERC721} from "../ERC721.sol";
import {IERC721Enumerable} from "./IERC721Enumerable.sol";
import {IERC165} from "../../../utils/introspection/ERC165.sol";

/**
 * @dev This implements an optional extension of {ERC721} defined in the ERC that adds enumerability
 * of all the token ids in the contract as well as all token ids owned by each account.
 *
 * CAUTION: {ERC721} extensions that implement custom `balanceOf` logic, such as {ERC721Consecutive},
 * interfere with enumerability and should not be used together with {ERC721Enumerable}.
 */
abstract contract ERC721Enumerable is ERC721, IERC721Enumerable {
    mapping(address owner => mapping(uint256 index => uint256)) private _ownedTokens;
    mapping(uint256 tokenId => uint256) private _ownedTokensIndex;

    uint256[] private _allTokens;
    mapping(uint256 tokenId => uint256) private _allTokensIndex;

    /**
     * @dev An `owner`'s token query was out of bounds for `index`.
     *
     * NOTE: The owner being `address(0)` indicates a global out of bounds index.
     */
    error ERC721OutOfBoundsIndex(address owner, uint256 index);

    /**
     * @dev Batch mint is not allowed.
     */
    error ERC721EnumerableForbiddenBatchMint();

    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) {
        return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId);
    }

    /**
     * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
     */
    function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual returns (uint256) {
        if (index >= balanceOf(owner)) {
            revert ERC721OutOfBoundsIndex(owner, index);
        }
        return _ownedTokens[owner][index];
    }

    /**
     * @dev See {IERC721Enumerable-totalSupply}.
     */
    function totalSupply() public view virtual returns (uint256) {
        return _allTokens.length;
    }

    /**
     * @dev See {IERC721Enumerable-tokenByIndex}.
     */
    function tokenByIndex(uint256 index) public view virtual returns (uint256) {
        if (index >= totalSupply()) {
            revert ERC721OutOfBoundsIndex(address(0), index);
        }
        return _allTokens[index];
    }

    /**
     * @dev See {ERC721-_update}.
     */
    function _update(address to, uint256 tokenId, address auth) internal virtual override returns (address) {
        address previousOwner = super._update(to, tokenId, auth);

        if (previousOwner == address(0)) {
            _addTokenToAllTokensEnumeration(tokenId);
        } else if (previousOwner != to) {
            _removeTokenFromOwnerEnumeration(previousOwner, tokenId);
        }
        if (to == address(0)) {
            _removeTokenFromAllTokensEnumeration(tokenId);
        } else if (previousOwner != to) {
            _addTokenToOwnerEnumeration(to, tokenId);
        }

        return previousOwner;
    }

    /**
     * @dev Private function to add a token to this extension's ownership-tracking data structures.
     * @param to address representing the new owner of the given token ID
     * @param tokenId uint256 ID of the token to be added to the tokens list of the given address
     */
    function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private {
        uint256 length = balanceOf(to) - 1;
        _ownedTokens[to][length] = tokenId;
        _ownedTokensIndex[tokenId] = length;
    }

    /**
     * @dev Private function to add a token to this extension's token tracking data structures.
     * @param tokenId uint256 ID of the token to be added to the tokens list
     */
    function _addTokenToAllTokensEnumeration(uint256 tokenId) private {
        _allTokensIndex[tokenId] = _allTokens.length;
        _allTokens.push(tokenId);
    }

    /**
     * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that
     * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for
     * gas optimizations e.g. when performing a transfer operation (avoiding double writes).
     * This has O(1) time complexity, but alters the order of the _ownedTokens array.
     * @param from address representing the previous owner of the given token ID
     * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address
     */
    function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private {
        // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and
        // then delete the last slot (swap and pop).

        uint256 lastTokenIndex = balanceOf(from);
        uint256 tokenIndex = _ownedTokensIndex[tokenId];

        mapping(uint256 index => uint256) storage _ownedTokensByOwner = _ownedTokens[from];

        // When the token to delete is the last token, the swap operation is unnecessary
        if (tokenIndex != lastTokenIndex) {
            uint256 lastTokenId = _ownedTokensByOwner[lastTokenIndex];

            _ownedTokensByOwner[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
            _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index
        }

        // This also deletes the contents at the last position of the array
        delete _ownedTokensIndex[tokenId];
        delete _ownedTokensByOwner[lastTokenIndex];
    }

    /**
     * @dev Private function to remove a token from this extension's token tracking data structures.
     * This has O(1) time complexity, but alters the order of the _allTokens array.
     * @param tokenId uint256 ID of the token to be removed from the tokens list
     */
    function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private {
        // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and
        // then delete the last slot (swap and pop).

        uint256 lastTokenIndex = _allTokens.length - 1;
        uint256 tokenIndex = _allTokensIndex[tokenId];

        // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so
        // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding
        // an 'if' statement (like in _removeTokenFromOwnerEnumeration)
        uint256 lastTokenId = _allTokens[lastTokenIndex];

        _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
        _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index

        // This also deletes the contents at the last position of the array
        delete _allTokensIndex[tokenId];
        _allTokens.pop();
    }

    /**
     * See {ERC721-_increaseBalance}. We need that to account tokens that were minted in batch
     */
    function _increaseBalance(address account, uint128 amount) internal virtual override {
        if (amount > 0) {
            revert ERC721EnumerableForbiddenBatchMint();
        }
        super._increaseBalance(account, amount);
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/extensions/IERC721Metadata.sol)

pragma solidity ^0.8.20;

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

/**
 * @title ERC-721 Non-Fungible Token Standard, optional metadata extension
 * @dev See https://eips.ethereum.org/EIPS/eip-721
 */
interface IERC721Metadata is IERC721 {
    /**
     * @dev Returns the token collection name.
     */
    function name() external view returns (string memory);

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

    /**
     * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
     */
    function tokenURI(uint256 tokenId) external view returns (string memory);
}

File 5 of 68 : Multicall.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8.0;
pragma abicoder v2;

import '../interfaces/IMulticall.sol';

/// @title Multicall
/// @notice Enables calling multiple methods in a single call to the contract
abstract contract Multicall is IMulticall {
    /// @inheritdoc IMulticall
    function multicall(bytes[] calldata data) public payable override returns (bytes[] memory results) {
        results = new bytes[](data.length);
        for (uint256 i = 0; i < data.length; i++) {
            (bool success, bytes memory result) = address(this).delegatecall(data[i]);

            if (!success) {
                // Next 5 lines from https://ethereum.stackexchange.com/a/83577
                if (result.length < 68) revert();
                assembly {
                    result := add(result, 0x04)
                }
                revert(abi.decode(result, (string)));
            }

            results[i] = result;
        }
    }
}

// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

import {IRamsesV3PoolImmutables} from "./pool/IRamsesV3PoolImmutables.sol";
import {IRamsesV3PoolState} from "./pool/IRamsesV3PoolState.sol";
import {IRamsesV3PoolDerivedState} from "./pool/IRamsesV3PoolDerivedState.sol";
import {IRamsesV3PoolActions} from "./pool/IRamsesV3PoolActions.sol";
import {IRamsesV3PoolOwnerActions} from "./pool/IRamsesV3PoolOwnerActions.sol";
import {IRamsesV3PoolErrors} from "./pool/IRamsesV3PoolErrors.sol";
import {IRamsesV3PoolEvents} from "./pool/IRamsesV3PoolEvents.sol";

/// @title The interface for a Ramses V3 Pool
/// @notice A Ramses 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 IRamsesV3Pool is
    IRamsesV3PoolImmutables,
    IRamsesV3PoolState,
    IRamsesV3PoolDerivedState,
    IRamsesV3PoolActions,
    IRamsesV3PoolOwnerActions,
    IRamsesV3PoolErrors,
    IRamsesV3PoolEvents
{
    /// @notice if a new period, advance on interaction
    function _advancePeriod() external;

    /// @notice Get the index of the last period in the pool
    /// @return The index of the last period
    function lastPeriod() external view returns (uint256);

    /// @notice allows reading arbitrary storage slots
    function readStorage(bytes32[] calldata slots) external view returns (bytes32[] memory returnData);
}

File 7 of 68 : FixedPoint128.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.4.0;

/// @title FixedPoint128
/// @notice A library for handling binary fixed point numbers, see https://en.wikipedia.org/wiki/Q_(number_format)
library FixedPoint128 {
    uint256 internal constant Q128 = 0x100000000000000000000000000000000;
}

// 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++;
            }
        }
    }
}

// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.7.5;
pragma abicoder v2;

import {IPoolInitializer} from './IPoolInitializer.sol';
import {IPeripheryPayments} from './IPeripheryPayments.sol';
import {IPeripheryImmutableState} from './IPeripheryImmutableState.sol';
import {PoolAddress} from '../libraries/PoolAddress.sol';

import {IERC721} from '@openzeppelin/contracts/token/ERC721/IERC721.sol';
import {IERC721Metadata} from '@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol';
import {IERC721Enumerable} from '@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol';

import {IPeripheryErrors} from './IPeripheryErrors.sol';

/// @title Non-fungible token for positions
/// @notice Wraps Ramses V3 positions in a non-fungible token interface which allows for them to be transferred
/// and authorized.
interface INonfungiblePositionManager is
    IPeripheryErrors,
    IPoolInitializer,
    IPeripheryPayments,
    IPeripheryImmutableState,
    IERC721,
    IERC721Metadata,
    IERC721Enumerable
{
    /// @notice Emitted when liquidity is increased for a position NFT
    /// @dev Also emitted when a token is minted
    /// @param tokenId The ID of the token for which liquidity was increased
    /// @param liquidity The amount by which liquidity for the NFT position was increased
    /// @param amount0 The amount of token0 that was paid for the increase in liquidity
    /// @param amount1 The amount of token1 that was paid for the increase in liquidity
    event IncreaseLiquidity(uint256 indexed tokenId, uint128 liquidity, uint256 amount0, uint256 amount1);
    /// @notice Emitted when liquidity is decreased for a position NFT
    /// @param tokenId The ID of the token for which liquidity was decreased
    /// @param liquidity The amount by which liquidity for the NFT position was decreased
    /// @param amount0 The amount of token0 that was accounted for the decrease in liquidity
    /// @param amount1 The amount of token1 that was accounted for the decrease in liquidity
    event DecreaseLiquidity(uint256 indexed tokenId, uint128 liquidity, uint256 amount0, uint256 amount1);
    /// @notice Emitted when tokens are collected for a position NFT
    /// @dev The amounts reported may not be exactly equivalent to the amounts transferred, due to rounding behavior
    /// @param tokenId The ID of the token for which underlying tokens were collected
    /// @param recipient The address of the account that received the collected tokens
    /// @param amount0 The amount of token0 owed to the position that was collected
    /// @param amount1 The amount of token1 owed to the position that was collected
    event Collect(uint256 indexed tokenId, address recipient, uint256 amount0, uint256 amount1);

    /// @notice Returns the position information associated with a given token ID.
    /// @dev Throws if the token ID is not valid.
    /// @param tokenId The ID of the token that represents the position
    /// @return token0 The address of the token0 for a specific pool
    /// @return token1 The address of the token1 for a specific pool
    /// @return tickSpacing The tickSpacing the pool
    /// @return tickLower The lower end of the tick range for the position
    /// @return tickUpper The higher end of the tick range for the position
    /// @return liquidity The liquidity of the position
    /// @return feeGrowthInside0LastX128 The fee growth of token0 as of the last action on the individual position
    /// @return feeGrowthInside1LastX128 The fee growth of token1 as of the last action on the individual position
    /// @return tokensOwed0 The uncollected amount of token0 owed to the position as of the last computation
    /// @return tokensOwed1 The uncollected amount of token1 owed to the position as of the last computation
    function positions(
        uint256 tokenId
    )
        external
        view
        returns (
            address token0,
            address token1,
            int24 tickSpacing,
            int24 tickLower,
            int24 tickUpper,
            uint128 liquidity,
            uint256 feeGrowthInside0LastX128,
            uint256 feeGrowthInside1LastX128,
            uint128 tokensOwed0,
            uint128 tokensOwed1
        );

    struct MintParams {
        address token0;
        address token1;
        int24 tickSpacing;
        int24 tickLower;
        int24 tickUpper;
        uint256 amount0Desired;
        uint256 amount1Desired;
        uint256 amount0Min;
        uint256 amount1Min;
        address recipient;
        uint256 deadline;
    }

    /// @notice Creates a new position wrapped in a NFT
    /// @dev Call this when the pool does exist and is initialized. Note that if the pool is created but not initialized
    /// a method does not exist, i.e. the pool is assumed to be initialized.
    /// @param params The params necessary to mint a position, encoded as `MintParams` in calldata
    /// @return tokenId The ID of the token that represents the minted position
    /// @return liquidity The amount of liquidity for this position
    /// @return amount0 The amount of token0
    /// @return amount1 The amount of token1
    function mint(
        MintParams calldata params
    ) external payable returns (uint256 tokenId, uint128 liquidity, uint256 amount0, uint256 amount1);

    struct IncreaseLiquidityParams {
        uint256 tokenId;
        uint256 amount0Desired;
        uint256 amount1Desired;
        uint256 amount0Min;
        uint256 amount1Min;
        uint256 deadline;
    }

    /// @notice Increases the amount of liquidity in a position, with tokens paid by the `msg.sender`
    /// @param params tokenId The ID of the token for which liquidity is being increased,
    /// amount0Desired The desired amount of token0 to be spent,
    /// amount1Desired The desired amount of token1 to be spent,
    /// amount0Min The minimum amount of token0 to spend, which serves as a slippage check,
    /// amount1Min The minimum amount of token1 to spend, which serves as a slippage check,
    /// deadline The time by which the transaction must be included to effect the change
    /// @return liquidity The new liquidity amount as a result of the increase
    /// @return amount0 The amount of token0 to acheive resulting liquidity
    /// @return amount1 The amount of token1 to acheive resulting liquidity
    function increaseLiquidity(
        IncreaseLiquidityParams calldata params
    ) external payable returns (uint128 liquidity, uint256 amount0, uint256 amount1);

    struct DecreaseLiquidityParams {
        uint256 tokenId;
        uint128 liquidity;
        uint256 amount0Min;
        uint256 amount1Min;
        uint256 deadline;
    }

    /// @notice Decreases the amount of liquidity in a position and accounts it to the position
    /// @param params tokenId The ID of the token for which liquidity is being decreased,
    /// amount The amount by which liquidity will be decreased,
    /// amount0Min The minimum amount of token0 that should be accounted for the burned liquidity,
    /// amount1Min The minimum amount of token1 that should be accounted for the burned liquidity,
    /// deadline The time by which the transaction must be included to effect the change
    /// @return amount0 The amount of token0 accounted to the position's tokens owed
    /// @return amount1 The amount of token1 accounted to the position's tokens owed
    function decreaseLiquidity(
        DecreaseLiquidityParams calldata params
    ) external payable returns (uint256 amount0, uint256 amount1);

    struct CollectParams {
        uint256 tokenId;
        address recipient;
        uint128 amount0Max;
        uint128 amount1Max;
    }

    /// @notice Collects up to a maximum amount of fees owed to a specific position to the recipient
    /// @param params tokenId The ID of the NFT for which tokens are being collected,
    /// recipient The account that should receive the tokens,
    /// amount0Max The maximum amount of token0 to collect,
    /// amount1Max The maximum amount of token1 to collect
    /// @return amount0 The amount of fees collected in token0
    /// @return amount1 The amount of fees collected in token1
    function collect(CollectParams calldata params) external payable returns (uint256 amount0, uint256 amount1);

    /// @notice Burns a token ID, which deletes it from the NFT contract. The token must have 0 liquidity and all tokens
    /// must be collected first.
    /// @param tokenId The ID of the token that is being burned
    function burn(uint256 tokenId) external payable;

}

// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.7.5;
pragma abicoder v2;

import {INonfungiblePositionManager} from './INonfungiblePositionManager.sol';

/// @title Ramses V3 Non-fungible token for positions
/// @notice Extends the standard NFT position manager with additional functionality
/// @dev This interface extends INonfungiblePositionManager with Ramses-specific features
interface IRamsesV3PositionManager is INonfungiblePositionManager {
    /// @notice Returns the last modification timestamp for a position
    /// @dev Used for extra checks in gauge rewarder
    /// @param tokenId The ID of the NFT position
    /// @return The timestamp of the last modification (0 if never modified)
    function positionLastModified(uint256 tokenId) external view returns (uint32);
    
    /// @notice Claims gauge rewards from liquidity incentives for a specific tokenId
    /// @dev Made payable to support multicall operations with ETH
    /// @param tokenId The ID of the token to claim rewards from
    /// @param tokens an array of reward tokens to claim
    function getReward(uint256 tokenId, address[] calldata tokens) external payable;
    
    /// @notice Claims gauge rewards for a specific period
    /// @dev Allows users to claim rewards for specific periods when they have accumulated many unclaimed periods
    /// @dev Made payable to support multicall operations with ETH
    /// @param period The specific period to claim rewards for (must be <= current period)
    /// @param tokenId The ID of the token to claim rewards from  
    /// @param tokens Array of reward tokens to claim
    /// @param receiver The address to send the rewards to
    function getPeriodReward(
        uint256 period,
        uint256 tokenId,
        address[] calldata tokens,
        address receiver
    ) external payable;
}

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

import './INonfungiblePositionManager.sol';

/// @title Describes position NFT tokens via URI
interface INonfungibleTokenPositionDescriptor {
    /// @notice Produces the URI describing a particular token ID for a position manager
    /// @dev Note this URI may be a data: URI with the JSON contents directly inlined
    /// @param positionManager The position manager for which to describe the token
    /// @param tokenId The ID of the token for which to produce a description, which may not be valid
    /// @return The URI of the ERC721-compliant metadata
    function tokenURI(INonfungiblePositionManager positionManager, uint256 tokenId)
        external
        view
        returns (string memory);
}

// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

library PositionKey {
    /// @dev Returns the key of the position in the core library
    function compute(address owner, uint256 index, int24 tickLower, int24 tickUpper) internal pure returns (bytes32) {
        return keccak256(abi.encodePacked(owner, index, tickLower, tickUpper));
    }
}

// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

/// @title Provides functions for deriving a pool address from the deployer, tokens, and the fee
library PoolAddress {
    bytes32 internal constant POOL_INIT_CODE_HASH = 0x892f127ed4b26ca352056c8fb54585a3268f76f97fdd84d5836ef4bda8d8c685;

    /// @notice The identifying key of the pool
    struct PoolKey {
        address token0;
        address token1;
        int24 tickSpacing;
    }

    /// @notice Returns PoolKey: the ordered tokens with the matched fee levels
    /// @param tokenA The first token of a pool, unsorted
    /// @param tokenB The second token of a pool, unsorted
    /// @param tickSpacing The tickSpacing of the pool
    /// @return Poolkey The pool details with ordered token0 and token1 assignments
    function getPoolKey(address tokenA, address tokenB, int24 tickSpacing) internal pure returns (PoolKey memory) {
        if (tokenA > tokenB) (tokenA, tokenB) = (tokenB, tokenA);
        return PoolKey({token0: tokenA, token1: tokenB, tickSpacing: tickSpacing});
    }

    /// @notice Deterministically computes the pool address given the deployer and PoolKey
    /// @param deployer The Uniswap V3 deployer contract address
    /// @param key The PoolKey
    /// @return pool The contract address of the V3 pool
    function computeAddress(address deployer, PoolKey memory key) internal pure returns (address pool) {
        require(key.token0 < key.token1, "!TokenOrder");
        pool = address(
            uint160(
                uint256(
                    keccak256(
                        abi.encodePacked(
                            hex'ff',
                            deployer,
                            keccak256(abi.encode(key.token0, key.token1, key.tickSpacing)),
                            POOL_INIT_CODE_HASH
                        )
                    )
                )
            )
        );
    }
}

// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8.0;
pragma abicoder v2;

import {IRamsesV3Factory} from "../../core/interfaces/IRamsesV3Factory.sol";
import {IUniswapV3MintCallback} from "../../core/interfaces/callback/IUniswapV3MintCallback.sol";
import {TickMath} from "../../core/libraries/TickMath.sol";

import {PoolAddress} from "../libraries/PoolAddress.sol";
import {CallbackValidation} from "../libraries/CallbackValidation.sol";
import {LiquidityAmounts} from "../libraries/LiquidityAmounts.sol";

import {PeripheryPayments} from "./PeripheryPayments.sol";
import {PeripheryImmutableState} from "./PeripheryImmutableState.sol";
import {IRamsesV3Pool} from "../../core/interfaces/IRamsesV3Pool.sol";

/// @title Liquidity management functions
/// @notice Internal functions for safely managing liquidity in Ramses V3
abstract contract LiquidityManagement is IUniswapV3MintCallback, PeripheryImmutableState, PeripheryPayments {
    error Slippage();

    struct MintCallbackData {
        PoolAddress.PoolKey poolKey;
        address payer;
    }

    /// @inheritdoc IUniswapV3MintCallback
    function uniswapV3MintCallback(uint256 amount0Owed, uint256 amount1Owed, bytes calldata data) external override {
        MintCallbackData memory decoded = abi.decode(data, (MintCallbackData));
        CallbackValidation.verifyCallback(deployer, decoded.poolKey);

        if (amount0Owed > 0) pay(decoded.poolKey.token0, decoded.payer, msg.sender, amount0Owed);
        if (amount1Owed > 0) pay(decoded.poolKey.token1, decoded.payer, msg.sender, amount1Owed);
    }

    struct AddLiquidityParams {
        address token0;
        address token1;
        int24 tickSpacing;
        address recipient;
        uint256 index;
        int24 tickLower;
        int24 tickUpper;
        uint256 amount0Desired;
        uint256 amount1Desired;
        uint256 amount0Min;
        uint256 amount1Min;
    }

    /// @notice Add liquidity to an initialized pool
    function addLiquidity(AddLiquidityParams memory params)
        internal
        returns (uint128 liquidity, uint256 amount0, uint256 amount1, IRamsesV3Pool pool)
    {
        PoolAddress.PoolKey memory poolKey =
            PoolAddress.PoolKey({token0: params.token0, token1: params.token1, tickSpacing: params.tickSpacing});

        pool = IRamsesV3Pool(PoolAddress.computeAddress(deployer, poolKey));

        /// @dev compute the liquidity amount
        {
            (uint160 sqrtPriceX96,,,,,,) = pool.slot0();
            uint160 sqrtRatioAX96 = TickMath.getSqrtRatioAtTick(params.tickLower);
            uint160 sqrtRatioBX96 = TickMath.getSqrtRatioAtTick(params.tickUpper);

            liquidity = LiquidityAmounts.getLiquidityForAmounts(
                sqrtPriceX96, sqrtRatioAX96, sqrtRatioBX96, params.amount0Desired, params.amount1Desired
            );
        }

        (amount0, amount1) = pool.mint(
            params.recipient,
            params.index,
            params.tickLower,
            params.tickUpper,
            liquidity,
            abi.encode(MintCallbackData({poolKey: poolKey, payer: msg.sender}))
        );

        if (amount0 < params.amount0Min || amount1 < params.amount1Min) revert Slippage();
    }
}

File 15 of 68 : PeripheryImmutableState.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8.0;

import '../interfaces/IPeripheryImmutableState.sol';

/// @title Immutable state
/// @notice Immutable state used by periphery contracts
abstract contract PeripheryImmutableState is IPeripheryImmutableState {
    /// @inheritdoc IPeripheryImmutableState
    address public immutable override deployer;
    /// @inheritdoc IPeripheryImmutableState
    address public immutable override WETH9;

    constructor(address _deployer, address _WETH9) {
        deployer = _deployer;
        WETH9 = _WETH9;
    }
}

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

import './BlockTimestamp.sol';

abstract contract PeripheryValidation is BlockTimestamp {
    error Old();
    modifier checkDeadline(uint256 deadline) {
        if (_blockTimestamp() > deadline) revert Old();
        _;
    }
}

File 17 of 68 : PoolInitializer.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8.0;

import {IRamsesV3Factory} from "../../core/interfaces/IRamsesV3Factory.sol";
import {IRamsesV3Pool} from "../../core/interfaces/IRamsesV3Pool.sol";
import {IRamsesV3PoolDeployer} from "../../core/interfaces/IRamsesV3PoolDeployer.sol";

import {PeripheryImmutableState} from "./PeripheryImmutableState.sol";
import {IPoolInitializer} from "../interfaces/IPoolInitializer.sol";

/// @title Creates and initializes V3 Pools
abstract contract PoolInitializer is IPoolInitializer, PeripheryImmutableState {
    /// @inheritdoc IPoolInitializer
    function createAndInitializePoolIfNecessary(address token0, address token1, int24 tickSpacing, uint160 sqrtPriceX96)
        external
        payable
        override
        returns (address pool)
    {
        require(token0 < token1);
        IRamsesV3Factory factory = IRamsesV3Factory(IRamsesV3PoolDeployer(deployer).RamsesV3Factory());
        pool = factory.getPool(token0, token1, tickSpacing);

        if (pool == address(0)) {
            pool = factory.createPool(token0, token1, tickSpacing, sqrtPriceX96);
        } else {
            (uint160 sqrtPriceX96Existing,,,,,,) = IRamsesV3Pool(pool).slot0();
            if (sqrtPriceX96Existing == 0) {
                IRamsesV3Pool(pool).initialize(sqrtPriceX96);
            }
        }
    }
}

// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.26;

interface IGaugeV3 {
    /// @notice Emitted when a reward notification is made.
    /// @param from The address from which the reward is notified.
    /// @param reward The address of the reward token.
    /// @param amount The amount of rewards notified.
    /// @param period The period for which the rewards are notified.
    event NotifyReward(
        address indexed from,
        address indexed reward,
        uint256 amount,
        uint256 period
    );

    /// @notice Emitted when a bribe is made.
    /// @param from The address from which the bribe is made.
    /// @param reward The address of the reward token.
    /// @param amount The amount of tokens bribed.
    /// @param period The period for which the bribe is made.
    event Bribe(
        address indexed from,
        address indexed reward,
        uint256 amount,
        uint256 period
    );

    /// @notice Emitted when rewards are claimed.
    /// @param period The period for which the rewards are claimed.
    /// @param _positionHash The identifier of the NFP for which rewards are claimed.
    /// @param receiver The address of the receiver of the claimed rewards.
    /// @param reward The address of the reward token.
    /// @param amount The amount of rewards claimed.
    event ClaimRewards(
        uint256 period,
        bytes32 _positionHash,
        address receiver,
        address reward,
        uint256 amount
    );

    /// @notice Emitted when a new reward token was pushed to the rewards array
    event RewardAdded(address reward);

    /// @notice Emitted when a reward token was removed from the rewards array
    event RewardRemoved(address reward);

    /// @notice Retrieves the value of the firstPeriod variable.
    /// @return The value of the firstPeriod variable.
    function firstPeriod() external returns (uint256);
    
    /// @notice Retrieves the cached r33 address for gas optimization
    /// @return The cached r33 address
    function r33() external view returns (address);

    /// @notice Retrieves the total supply of a specific token for a given period.
    /// @param period The period for which to retrieve the total supply.
    /// @param token The address of the token for which to retrieve the total supply.
    /// @return The total supply of the specified token for the given period.
    function tokenTotalSupplyByPeriod(
        uint256 period,
        address token
    ) external view returns (uint256);

    /// @notice Retrieves the getTokenTotalSupplyByPeriod of the current period.
    /// @dev included to support voter's left() check during distribute().
    /// @param token The address of the token for which to retrieve the remaining amount.
    /// @return The amount of tokens left to distribute in this period.
    function left(address token) external view returns (uint256);

    /// @notice Retrieves the reward rate for a specific reward address.
    /// @dev this method returns the base rate without boost
    /// @param token The address of the reward for which to retrieve the reward rate.
    /// @return The reward rate for the specified reward address.
    function rewardRate(address token) external view returns (uint256);

    /// @notice Retrieves the claimed amount for a specific period, position hash, and user address.
    /// @param period The period for which to retrieve the claimed amount.
    /// @param _positionHash The identifier of the NFP for which to retrieve the claimed amount.
    /// @param reward The address of the token for the claimed amount.
    /// @return The claimed amount for the specified period, token ID, and user address.
    function periodClaimedAmount(
        uint256 period,
        bytes32 _positionHash,
        address reward
    ) external view returns (uint256);

    /// @notice Retrieves the last claimed period for a specific token, token ID combination.
    /// @param token The address of the reward token for which to retrieve the last claimed period.
    /// @param _positionHash The identifier of the NFP for which to retrieve the last claimed period.
    /// @return The last claimed period for the specified token and token ID.
    function lastClaimByToken(
        address token,
        bytes32 _positionHash
    ) external view returns (uint256);

    /// @notice Retrieves the reward address at the specified index in the rewards array.
    /// @param index The index of the reward address to retrieve.
    /// @return The reward address at the specified index.
    function rewards(uint256 index) external view returns (address);

    /// @notice Checks if a given address is a valid reward.
    /// @param reward The address to check.
    /// @return A boolean indicating whether the address is a valid reward.
    function isReward(address reward) external view returns (bool);

    /// @notice Returns an array of reward token addresses.
    /// @return An array of reward token addresses.
    function getRewardTokens() external view returns (address[] memory);

    /// @notice Returns the hash used to store positions in a mapping
    /// @param owner The address of the position owner
    /// @param index The index of the position
    /// @param tickLower The lower tick boundary of the position
    /// @param tickUpper The upper tick boundary of the position
    /// @return _hash The hash used to store positions in a mapping
    function positionHash(
        address owner,
        uint256 index,
        int24 tickLower,
        int24 tickUpper
    ) external pure returns (bytes32);


    /// (legacy version for backward compatibility)
    /// @notice Returns the amount of rewards earned for an NFP
    /// @param token The address of the token for which to retrieve the earned rewards.
    /// @param tokenId The identifier of the specific NFP for which to retrieve the earned rewards.
    /// @return reward The amount of rewards earned for the specified NFP and tokens.
    function earned(
        address token,
        uint256 tokenId
    ) external view returns (uint256 reward);

    /// (new version with multiple NFP managers)
    /// @notice Returns the amount of rewards earned for an NFP (new version)
    /// @param token The address of the token for which to retrieve the earned rewards.
    /// @param nfpManagerAddress The address of the NFP manager for which to retrieve the earned rewards.
    /// @param tokenId The identifier of the specific NFP for which to retrieve the earned rewards.
    /// @return reward The amount of rewards earned for the specified NFP and tokens.
    function earned(
        address token,
        address nfpManagerAddress,
        uint256 tokenId
    ) external view returns (uint256 reward);

    /// @notice Returns the amount of rewards earned during a period for an NFP.
    /// @param period The period for which to retrieve the earned rewards.
    /// @param token The address of the token for which to retrieve the earned rewards.
    /// @param tokenId The identifier of the specific NFP for which to retrieve the earned rewards.
    /// @return reward The amount of rewards earned for the specified NFP and tokens.
    function periodEarned(
        uint256 period,
        address token,
        uint256 tokenId
    ) external view returns (uint256);

    /// @notice Returns the amount of rewards earned during a period for an NFP.
    /// @param period The period for which to retrieve the earned rewards.
    /// @param token The address of the token for which to retrieve the earned rewards.
    /// @param nfpManagerAddress The address of the NFP manager for which to retrieve the earned rewards.
    /// @param tokenId The identifier of the specific NFP for which to retrieve the earned rewards.
    /// @return reward The amount of rewards earned for the specified NFP and tokens.
    function periodEarned(
        uint256 period,
        address token,
        address nfpManagerAddress,
        uint256 tokenId
    ) external view returns (uint256);

    /// @notice Retrieves the earned rewards for a specific period, token, owner, index, tickLower, and tickUpper.
    /// @param period The period for which to retrieve the earned rewards.
    /// @param token The address of the token for which to retrieve the earned rewards.
    /// @param owner The address of the owner for which to retrieve the earned rewards.
    /// @param index The index for which to retrieve the earned rewards.
    /// @param tickLower The tick lower bound for which to retrieve the earned rewards.
    /// @param tickUpper The tick upper bound for which to retrieve the earned rewards.
    /// @return The earned rewards for the specified period, token, owner, index, tickLower, and tickUpper.
    function periodEarned(
        uint256 period,
        address token,
        address owner,
        uint256 index,
        int24 tickLower,
        int24 tickUpper
    ) external view returns (uint256);

    /// @notice Retrieves the earned rewards for a specific period, token, owner, index, tickLower, and tickUpper.
    /// @dev used by getReward() and saves gas by saving states
    /// @param period The period for which to retrieve the earned rewards.
    /// @param token The address of the token for which to retrieve the earned rewards.
    /// @param owner The address of the owner for which to retrieve the earned rewards.
    /// @param index The index for which to retrieve the earned rewards.
    /// @param tickLower The tick lower bound for which to retrieve the earned rewards.
    /// @param tickUpper The tick upper bound for which to retrieve the earned rewards.
    /// @param caching Whether to cache the results or not.
    /// @return The earned rewards for the specified period, token, owner, index, tickLower, and tickUpper.
    function cachePeriodEarned(
        uint256 period,
        address token,
        address owner,
        uint256 index,
        int24 tickLower,
        int24 tickUpper,
        bool caching
    ) external returns (uint256);

    /// @notice Notifies the contract about the amount of rewards to be distributed for a specific token.
    /// @param token The address of the token for which to notify the reward amount.
    /// @param amount The amount of rewards to be distributed.
    function notifyRewardAmount(address token, uint256 amount) external;

    /// @notice Retrieves the rewards for a specific period, set of tokens, owner, index, tickLower, tickUpper, and receiver.
    /// @param period The period for which to retrieve the rewards.
    /// @param tokens An array of token addresses for which to retrieve the rewards.
    /// @param owner The address of the owner for which to retrieve the rewards.
    /// @param index The index for which to retrieve the rewards.
    /// @param tickLower The tick lower bound for which to retrieve the rewards.
    /// @param tickUpper The tick upper bound for which to retrieve the rewards.
    /// @param receiver The address of the receiver of the rewards.
    function getPeriodReward(
        uint256 period,
        address[] calldata tokens,
        address owner,
        uint256 index,
        int24 tickLower,
        int24 tickUpper,
        address receiver
    ) external;


    /// @notice retrieves rewards based on an NFP id and an array of tokens
    function getReward(uint256 tokenId, address[] memory tokens) external;
    /// @notice retrieves rewards based on an array of NFP ids and an array of tokens
    function getReward(
        uint256[] calldata tokenIds,
        address[] memory tokens
    ) external;
    /// @notice Get reward for an NFP token owner (only callable by authorized NFP managers)
    /// @param tokenId The ID of the NFP token
    /// @param tokens Array of reward tokens to claim
    function getRewardForOwner(
        uint256 tokenId,
        address[] memory tokens
    ) external;

    /// @notice Claims rewards for a token owner from the Voter contract
    /// @dev Only callable by the Voter contract when users claim through the UI
    /// @dev Allows specifying which NFP manager holds the token
    /// @param nfpManagerAddress The address of the NFP manager that holds the token
    /// @param tokenId The ID of the NFP token to claim rewards for
    /// @param tokens Array of reward tokens to claim
    function getRewardForOwnerFromVoter(
        address nfpManagerAddress,
        uint256 tokenId,
        address[] memory tokens
    ) external;

    function addRewards(address reward) external;

    function removeRewards(address reward) external;

    /// @notice Notifies rewards for periods greater than current period
    /// @dev does not push fees
    /// @dev requires reward token to be whitelisted
    function notifyRewardAmountForPeriod(
        address token,
        uint256 amount,
        uint256 period
    ) external;

    /// @notice Notifies rewards for the next period
    /// @dev does not push fees
    /// @dev requires reward token to be whitelisted
    function notifyRewardAmountNextPeriod(
        address token,
        uint256 amount
    ) external;

    /// @notice Synchronize all cached values from voter in a single call for gas optimization
    /// @dev Combines rewardValidator, nfpManagers, and r33 cache updates
    function syncCache() external;

    /// @notice Check if an address is an authorized claimer  
    /// @param claimer The address to check
    /// @return true if the address is an authorized claimer
    function isAuthorizedClaimer(address claimer) external view returns (bool);

    /// @notice Get all authorized claimers
    /// @return Array of authorized claimer addresses
    function getAuthorizedClaimers() external view returns (address[] memory);
}

File 19 of 68 : IVoter.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;
pragma abicoder v2;

interface IVoter {
    event GaugeCreated(address indexed gauge, address creator, address feeDistributor, address indexed pool);

    event GaugeKilled(address indexed gauge);

    event GaugeRevived(address indexed gauge);

    event Voted(address indexed owner, uint256 weight, address indexed pool);

    event Abstained(address indexed owner, uint256 weight);

    event Deposit(address indexed lp, address indexed gauge, address indexed owner, uint256 amount);

    event Withdraw(address indexed lp, address indexed gauge, address indexed owner, uint256 amount);

    event NotifyReward(address indexed sender, address indexed reward, uint256 amount);

    event DistributeReward(address indexed sender, address indexed gauge, uint256 amount);

    event EmissionsRatio(address indexed caller, uint256 oldRatio, uint256 newRatio);

    event NewGovernor(address indexed sender, address indexed governor);

    event Whitelisted(address indexed whitelister, address indexed token);

    event WhitelistRevoked(address indexed forbidder, address indexed token);

    event Poke(address indexed user);

    event EmissionsRedirected(address indexed sourceGauge, address indexed destinationGauge);

    struct InitializationParams {
        address ram;
        address legacyFactory;
        address gauges;
        address feeDistributorFactory;
        address minter;
        address msig;
        address xRam;
        address clFactory;
        address clGaugeFactory;
        address nfpManager;
        address feeRecipientFactory;
        address voteModule;
    }

    function initialize(InitializationParams memory inputs) external;

    /// @notice denominator basis
    function BASIS() external view returns (uint256);

    /// @notice ratio of xRam emissions globally
    function xRatio() external view returns (uint256);

    /// @notice minimum time threshold for rewarder (in seconds)
    function timeThresholdForRewarder() external view returns (uint256);

    /// @notice reward validator contract for anti-sybil validation
    function rewardValidator() external view returns (address);

    /// @notice toggle anti-sybil mechanism
    function toggleAntiSybil() external;

    /// @notice set the reward validator contract
    /// @param _rewardValidator The address of the RewardValidator contract
    function setRewardValidator(address _rewardValidator) external;

    /// @notice xRam contract address
    function xRam() external view returns (address);

    /// @notice legacy factory address (uni-v2/stableswap)
    function legacyFactory() external view returns (address);

    /// @notice concentrated liquidity factory
    function clFactory() external view returns (address);

    /// @notice gauge factory for CL
    function clGaugeFactory() external view returns (address);

    /// @notice legacy fee recipient factory
    function feeRecipientFactory() external view returns (address);

    /// @notice peripheral NFPManager contract
    function nfpManager() external view returns (address);

    /// @notice returns the address of the current governor
    /// @return _governor address of the governor
    function governor() external view returns (address _governor);

    /// @notice the address of the vote module
    /// @return _voteModule the vote module contract address
    function voteModule() external view returns (address _voteModule);

    /// @notice address of the central access Hub
    function accessHub() external view returns (address);

    /// @notice distributes emissions from the minter to the voter
    /// @param amount the amount of tokens to notify
    function notifyRewardAmount(uint256 amount) external;

    /// @notice distributes the emissions for a specific gauge
    /// @param _gauge the gauge address
    function distribute(address _gauge) external;

    /// @notice returns the address of the gauge factory
    /// @param _gaugeFactory gauge factory address
    function gaugeFactory() external view returns (address _gaugeFactory);

    /// @notice returns the address of the feeDistributor factory
    /// @return _feeDistributorFactory feeDist factory address
    function feeDistributorFactory() external view returns (address _feeDistributorFactory);

    /// @notice returns the address of the minter contract
    /// @return _minter address of the minter
    function minter() external view returns (address _minter);

    /// @notice check if the gauge is active for governance use
    /// @param _gauge address of the gauge
    /// @return _trueOrFalse if the gauge is alive
    function isAlive(address _gauge) external view returns (bool _trueOrFalse);

    /// @notice allows the token to be paired with other whitelisted assets to participate in governance
    /// @param _token the address of the token
    function whitelist(address _token) external;

    /// @notice effectively disqualifies a token from governance
    /// @param _token the address of the token
    function revokeWhitelist(address _token) external;

    /// @notice returns if the address is a gauge
    /// @param gauge address of the gauge
    /// @return _trueOrFalse boolean if the address is a gauge
    function isGauge(address gauge) external view returns (bool _trueOrFalse);

    /// @notice disable a gauge from governance
    /// @param _gauge address of the gauge
    function killGauge(address _gauge) external;

    /// @notice re-activate a dead gauge
    /// @param _gauge address of the gauge
    function reviveGauge(address _gauge) external;

    /// @notice re-cast a tokenID's votes
    /// @param owner address of the owner
    function poke(address owner) external;

    /// @notice sets the main destinationGauge of a token pairing
    /// @param tokenA address of tokenA
    /// @param tokenB address of tokenB
    /// @param destinationGauge the main gauge to set to
    function redirectEmissions(address tokenA, address tokenB, address destinationGauge) external;

    /// @notice returns if the address is a fee distributor
    /// @param _feeDistributor address of the feeDist
    /// @return _trueOrFalse if the address is a fee distributor
    function isFeeDistributor(address _feeDistributor) external view returns (bool _trueOrFalse);

    /// @notice returns the address of the emission's token
    /// @return _ram emissions token contract address
    function ram() external view returns (address _ram);

    /// @notice returns the address of the pool's gauge, if any
    /// @param _pool pool address
    /// @return _gauge gauge address
    function gaugeForPool(address _pool) external view returns (address _gauge);

    /// @notice returns the address of the pool's feeDistributor, if any
    /// @param _gauge address of the gauge
    /// @return _feeDistributor address of the pool's feedist
    function feeDistributorForGauge(address _gauge) external view returns (address _feeDistributor);

    /// @notice returns the gauge address of a CL pool
    /// @param tokenA address of token A in the pair
    /// @param tokenB address of token B in the pair
    /// @param tickSpacing tickspacing of the pool
    /// @return gauge address of the gauge
    function gaugeForClPool(address tokenA, address tokenB, int24 tickSpacing) external view returns (address gauge);

    /// @notice returns the array of all tickspacings for the tokenA/tokenB combination
    /// @param tokenA address of token A in the pair
    /// @param tokenB address of token B in the pair
    /// @return _ts array of all the tickspacings
    function tickSpacingsForPair(address tokenA, address tokenB) external view returns (int24[] memory _ts);

    /// @notice returns the destination of a gauge redirect
    /// @param gauge address of gauge
    function gaugeRedirect(address gauge) external view returns (address);

    /// @notice returns the block.timestamp divided by 1 week in seconds
    /// @return period the period used for gauges
    function getPeriod() external view returns (uint256 period);

    /// @notice cast a vote to direct emissions to gauges and earn incentives
    /// @param owner address of the owner
    /// @param _pools the list of pools to vote on
    /// @param _weights an arbitrary weight per pool which will be normalized to 100% regardless of numerical inputs
    function vote(address owner, address[] calldata _pools, uint256[] calldata _weights) external;

    /// @notice reset the vote of an address
    /// @param owner address of the owner
    function reset(address owner) external;

    /// @notice set the governor address
    /// @param _governor the new governor address
    function setGovernor(address _governor) external;

    /// @notice recover stuck emissions
    /// @param _gauge the gauge address
    /// @param _period the period
    function stuckEmissionsRecovery(address _gauge, uint256 _period) external;

    /// @notice creates a legacy gauge for the pool
    /// @param _pool pool's address
    /// @return _gauge address of the new gauge
    function createGauge(address _pool) external returns (address _gauge);

    /// @notice create a concentrated liquidity gauge
    /// @param tokenA the address of tokenA
    /// @param tokenB the address of tokenB
    /// @param tickSpacing the tickspacing of the pool
    /// @return _clGauge address of the new gauge
    function createCLGauge(address tokenA, address tokenB, int24 tickSpacing) external returns (address _clGauge);

    /// @notice claim concentrated liquidity gauge rewards for specific NFP token ids
    /// @param _gauges array of gauges
    /// @param _tokens two dimensional array for the tokens to claim
    /// @param _nfpTokenIds two dimensional array for the NFPs
    /// @param _nfpManagers array of NFP manager addresses for each gauge
    function claimClGaugeRewards(
        address[] calldata _gauges,
        address[][] calldata _tokens,
        uint256[][] calldata _nfpTokenIds,
        address[] calldata _nfpManagers
    ) external;

    /// @notice claim concentrated liquidity gauge rewards (backwards compatible - auto-detects NFP managers)
    /// @param _gauges array of gauges
    /// @param _tokens two dimensional array for the tokens to claim
    /// @param _nfpTokenIds two dimensional array for the NFPs
    function claimClGaugeRewards(
        address[] calldata _gauges,
        address[][] calldata _tokens,
        uint256[][] calldata _nfpTokenIds
    ) external;

    /// @notice claim arbitrary rewards from specific feeDists
    /// @param owner address of the owner
    /// @param _feeDistributors address of the feeDists
    /// @param _tokens two dimensional array for the tokens to claim
    function claimIncentives(address owner, address[] calldata _feeDistributors, address[][] calldata _tokens)
        external;

    /// @notice claim arbitrary rewards from specific feeDists and break up legacy pairs
    /// @param owner address of the owner
    /// @param _feeDistributors address of the feeDists
    /// @param _tokens two dimensional array for the tokens to claim
    function claimLegacyIncentives(address owner, address[] calldata _feeDistributors, address[][] calldata _tokens)
        external;

    /// @notice claim arbitrary rewards from specific gauges
    /// @param _gauges address of the gauges
    /// @param _tokens two dimensional array for the tokens to claim
    function claimRewards(address[] calldata _gauges, address[][] calldata _tokens) external;

    /// @notice distribute emissions to a gauge for a specific period
    /// @param _gauge address of the gauge
    /// @param _period value of the period
    function distributeForPeriod(address _gauge, uint256 _period) external;

    /// @notice attempt distribution of emissions to all gauges
    function distributeAll() external;

    /// @notice distribute emissions to gauges by index
    /// @param startIndex start of the loop
    /// @param endIndex end of the loop
    function batchDistributeByIndex(uint256 startIndex, uint256 endIndex) external;

    /// @notice lets governance update lastDistro period for a gauge
    /// @dev should only be used if distribute() is running out of gas
    /// @dev gaugePeriodDistributed will stop double claiming
    /// @param _gauge gauge to update
    /// @param _period period to update to
    function updateLastDistro(address _gauge, uint256 _period) external;

    /// @notice returns the votes cast for a tokenID
    /// @param owner address of the owner
    /// @return votes an array of votes casted
    /// @return weights an array of the weights casted per pool
    function getVotes(address owner, uint256 period)
        external
        view
        returns (address[] memory votes, uint256[] memory weights);

    /// @notice returns an array of all the pools
    /// @return _pools the array of pools
    function getAllPools() external view returns (address[] memory _pools);

    /// @notice returns the length of pools
    function getPoolsLength() external view returns (uint256);

    /// @notice returns the pool at index
    function getPool(uint256 index) external view returns (address);

    /// @notice returns an array of all the gauges
    /// @return _gauges the array of gauges
    function getAllGauges() external view returns (address[] memory _gauges);

    /// @notice returns the length of gauges
    function getGaugesLength() external view returns (uint256);

    /// @notice returns the gauge at index
    function getGauge(uint256 index) external view returns (address);

    /// @notice returns an array of all the feeDists
    /// @return _feeDistributors the array of feeDists
    function getAllFeeDistributors() external view returns (address[] memory _feeDistributors);

    /// @notice sets the xRamRatio default
    function setGlobalRatio(uint256 _xRatio) external;

    /// @notice whether the token is whitelisted in governance
    function isWhitelisted(address _token) external view returns (bool _tf);

    /// @notice function for removing malicious or stuffed tokens
    function removeFeeDistributorReward(address _feeDist, address _token) external;

    /// @notice returns the total votes for a pool in a specific period
    /// @param pool the pool address to check
    /// @param period the period to check
    /// @return votes the total votes for the pool in that period
    function poolTotalVotesPerPeriod(address pool, uint256 period) external view returns (uint256 votes);

    /// @notice returns the pool address for a given gauge
    /// @param gauge address of the gauge
    /// @return pool address of the pool
    function poolForGauge(address gauge) external view returns (address pool);

    /// @notice returns the pool address for a given feeDistributor
    /// @param feeDistributor address of the feeDistributor
    /// @return pool address of the pool
    function poolForFeeDistributor(address feeDistributor) external view returns (address pool);

    /// @notice returns the voting power used by a voter for a period
    /// @param user address of the user
    /// @param period the period to check
    function userVotingPowerPerPeriod(address user, uint256 period) external view returns (uint256 votingPower);

    /// @notice returns the total votes for a specific period
    /// @param period the period to check
    /// @return weight the total votes for that period
    function totalVotesPerPeriod(uint256 period) external view returns (uint256 weight);

    /// @notice returns the total rewards allocated for a specific period
    /// @param period the period to check
    /// @return amount the total rewards for that period
    function totalRewardPerPeriod(uint256 period) external view returns (uint256 amount);

    /// @notice returns the last distribution period for a gauge
    /// @param _gauge address of the gauge
    /// @return period the last period distributions occurred
    function lastDistro(address _gauge) external view returns (uint256 period);

    /// @notice returns if the gauge is a Cl gauge
    /// @param gauge the gauge to check
    function isClGauge(address gauge) external view returns (bool);

    /// @notice returns if the gauge is a legacy gauge
    /// @param gauge the gauge to check
    function isLegacyGauge(address gauge) external view returns (bool);

    /// @notice sets a new NFP manager
    function setNfpManager(address _nfpManager) external;

    /// @notice sets the minimum time threshold for rewarder (in seconds)
    function setTimeThresholdForRewarder(uint256 _timeThreshold) external;

    /// @notice returns all voters for a period
    function getAllVotersPerPeriod(uint256 period) external view returns (address[] memory);

    /// @notice returns the length of all voters for a period
    function getAllVotersPerPeriodLength(uint256 period) external view returns (uint256);

    /// @notice returns voter at index for a period
    function getAllVotersPerPeriodAt(uint256 period, uint256 index) external view returns (address);

    /// @notice Update FeeDistributor for a gauge (emergency governance function)
    function updateFeeDistributorForGauge(address _gauge, address _newFeeDistributor) external;

    /// @notice Create a new FeeDistributor with specified feeRecipient (emergency governance function)
    function createFeeDistributorWithRecipient(address _feeRecipient) external returns (address);

    /// @notice returns if the anti-sybil is enabled
    function isAntiSybilEnabled() external view returns (bool);
    
    /// @notice returns all authorized claimers for CL gauges
    function getAllAuthorizedClaimers() external view returns (address[] memory);
    
    /// @notice Add a new authorized claimer to the whitelist
    function addAuthorizedClaimer(address _claimer) external;
    
    /// @notice Remove an authorized claimer from the whitelist
    function removeAuthorizedClaimer(address _claimer) external;
}

File 20 of 68 : IAccessHub.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;

import {IVoteModule} from "contracts/interfaces/IVoteModule.sol";
import {IVoter} from "contracts/interfaces/IVoter.sol";
import {IFeeRecipientFactory} from "contracts/interfaces/IFeeRecipientFactory.sol";
import {IMinter} from "contracts/interfaces/IMinter.sol";
import {IXRam} from "contracts/interfaces/IXRam.sol";
import {IR33} from "contracts/interfaces/IR33.sol";
import {IRamsesV3Factory} from "contracts/CL/core/interfaces/IRamsesV3Factory.sol";
import {IPairFactory} from "contracts/interfaces/IPairFactory.sol";
import {IFeeCollector} from "contracts/CL/gauge/interfaces/IFeeCollector.sol";

interface IAccessHub {
    error SAME_ADDRESS();
    error NOT_TIMELOCK(address);
    error MANUAL_EXECUTION_FAILURE(bytes);
    error KICK_FORBIDDEN(address);

    /// @dev Struct to hold initialization parameters
    struct InitParams {
        address timelock;
        address treasury;
        address voter;
        address minter;
        address xRam;
        address r33;
        address ramsesV3PoolFactory;
        address poolFactory;
        address clGaugeFactory;
        address gaugeFactory;
        address feeRecipientFactory;
        address feeDistributorFactory;
        address feeCollector;
        address voteModule;
    }

    /// @notice protocol timelock address
    function timelock() external view returns (address timelock);

    /// @notice protocol treasury address
    function treasury() external view returns (address treasury);

    /// @notice vote module
    function voteModule() external view returns (IVoteModule voteModule);

    /// @notice voter
    function voter() external view returns (IVoter voter);

    /// @notice weekly emissions minter
    function minter() external view returns (IMinter minter);

    /// @notice xRam contract  
    function xRam() external view returns (IXRam xRam);

    /// @notice R33 contract
    function r33() external view returns (IR33 r33);

    /// @notice CL V3 factory
    function ramsesV3PoolFactory() external view returns (IRamsesV3Factory ramsesV3PoolFactory);

    /// @notice legacy pair factory
    function poolFactory() external view returns (IPairFactory poolFactory);

    /// @notice fee collector contract
    function feeCollector() external view returns (IFeeCollector feeCollector);

    /// @notice concentrated (v3) gauge factory
    function clGaugeFactory() external view returns (address _clGaugeFactory);

    /// @notice legacy gauge factory address
    function gaugeFactory() external view returns (address _gaugeFactory);

    /// @notice the feeDistributor factory address
    function feeDistributorFactory() external view returns (address _feeDistributorFactory);

    /// @notice fee recipient factory
    function feeRecipientFactory() external view returns (IFeeRecipientFactory _feeRecipientFactory);

    /// @notice initializing function for setting values in the AccessHub
    function initialize(InitParams calldata params) external;

    /// @notice re-initializing function for updating values in the AccessHub
    function reinit(InitParams calldata params) external;

    /// @notice sets the swap fees for multiple pairs
    function setSwapFees(address[] calldata _pools, uint24[] calldata _swapFees)
        external;

    /// @notice sets the split of fees between LPs and voters
    function setFeeSplitCL(address[] calldata _pools, uint24[] calldata _feeProtocol) external;

    /// @notice sets the split of fees between LPs and voters for legacy pools
    function setFeeSplitLegacy(address[] calldata _pools, uint256[] calldata _feeSplits) external;

    /**
     * Voter governance
     */

    /// @notice sets a new governor address in the voter.sol contract
    function setNewGovernorInVoter(address _newGovernor) external;

    /// @notice whitelists a token for governance, or removes if boolean is set to false
    function governanceWhitelist(address[] calldata _token, bool[] calldata _whitelisted) external;

    /// @notice kills active gauges, removing them from earning further emissions, and claims their fees prior
    function killGauge(address[] calldata _pairs) external;

    /// @notice revives inactive/killed gauges
    function reviveGauge(address[] calldata _pairs) external;

    /// @notice sets the ratio of xRam/Ramses awarded globally to LPs
    function setEmissionsRatioInVoter(uint256 _pct) external;

    /// @notice allows governance to retrieve emissions in the voter contract that will not be distributed due to the gauge being inactive
    /// @dev allows per-period retrieval for granularity
    function retrieveStuckEmissionsToGovernance(address _gauge, uint256 _period) external;

    /// @notice sets the minimum time threshold for rewarder (in seconds)
    function setTimeThresholdForRewarder(uint256 _timeThreshold) external;

    /// @notice creates a new gauge for a legacy pool
    function createLegacyGauge(address _pool) external returns (address);

    /// @notice creates a new concentrated liquidity gauge for a CL pool
    function createCLGauge(address tokenA, address tokenB, int24 tickSpacing) external returns (address);

    /**
     * xRam Functions
     */

    /// @notice enables or disables the transfer whitelist in xRam
    function transferWhitelistInXRam(address[] calldata _who, bool[] calldata _whitelisted) external;

    /// @notice enables or disables the transfer whitelist in xRam
    function transferToWhitelistInXRam(address[] calldata _who, bool[] calldata _whitelisted) external;

    /// @notice enables or disables the governance in xRam
    function toggleXRamGovernance(bool enable) external;

    /// @notice rescues any trapped tokens in xRam
    function rescueTrappedTokens(address[] calldata _tokens, uint256[] calldata _amounts) external;

    /**
     * X33 Functions
     */

    /// @notice transfers the r33 operator address
    function transferOperatorInR33(address _newOperator) external;

    /**
     * Minter Functions
     */

    function updateEmissionsMultiplierInMinter(uint256 _newMultiplier) external;

    /**
     * Reward List Functions
     */
    /// @notice function for removing rewards for feeDistributors
    function removeFeeDistributorRewards(address[] calldata _pools, address[] calldata _rewards) external;

    /**
     * FeeCollector functions
     */

    /// @notice Sets the treasury address to a new value.
    /// @param newTreasury The new address to set as the treasury.
    function setTreasuryInFeeCollector(address newTreasury) external;

    /// @notice Sets the value of treasury fees to a new amount.
    /// @param _treasuryFees The new amount of treasury fees to be set.
    function setTreasuryFeesInFeeCollector(uint256 _treasuryFees) external;

    /**
     * FeeRecipientFactory functions
     */

    /// @notice set the fee % to be sent to the treasury
    /// @param _feeToTreasury the fee % to be sent to the treasury
    function setFeeToTreasuryInFeeRecipientFactory(uint256 _feeToTreasury) external;

    /// @notice set a new treasury address
    /// @param _treasury the new address
    function setTreasuryInFeeRecipientFactory(address _treasury) external;

    /**
     * CL Pool Factory functions
     */

    /// @notice enables a tickSpacing with the given initialFee amount
    /// @dev unlike UniswapV3, we map via the tickSpacing rather than the fee tier
    /// @dev tickSpacings may never be removed once enabled
    /// @param tickSpacing The spacing between ticks to be enforced for all pools created
    /// @param initialFee The initial fee amount, denominated in hundredths of a bip (i.e. 1e-6)
    function enableTickSpacing(int24 tickSpacing, uint24 initialFee) external;

    /// @notice sets the feeProtocol (feeSplit) for new CL pools and stored in the factory
    function setGlobalClFeeProtocol(uint24 _feeProtocolGlobal) external;

    /// @notice sets the address of the voter in the v3 factory for gauge fee setting
    function setVoterAddressInFactoryV3(address _voter) external;

    /// @notice sets the address of the feeCollector in the v3 factory for fee routing
    function setFeeCollectorInFactoryV3(address _newFeeCollector) external;

    /**
     * Legacy Pool Factory functions
     */

    /// @notice sets the treasury address in the legacy factory
    function setTreasuryInLegacyFactory(address _treasury) external;

    /// @notice sets the voter address in the legacy factory
    function setVoterInLegacyFactory(address _voter) external;

    /// @notice enables or disables if there is a feeSplit when no gauge for legacy pairs
    function setFeeSplitWhenNoGauge(bool status) external;

    /// @notice set the default feeSplit in the legacy factory
    function setLegacyFeeSplitGlobal(uint256 _feeSplit) external;

    /// @notice set the default swap fee for legacy pools
    function setLegacyFeeGlobal(uint256 _fee) external;

    /// @notice sets whether a pair can have skim() called or not for rebasing purposes
    function setSkimEnabledLegacy(address _pair, bool _status) external;

    /**
     * VoteModule Functions
     */

    /// @notice sets addresses as exempt or removes their exemption
    function setCooldownExemption(address[] calldata _candidates, bool[] calldata _exempt) external;

    /// @notice function to change the cooldown in the voteModule
    function setNewVoteModuleCooldown(uint256 _newCooldown) external;

    /// @notice sets the address of the voter in the fee recipient factory for fee recipient creation
    function setVoterInFeeRecipientFactory(address _voter) external;


    /**
     * Timelock gated functions
     */

    /// @notice timelock gated payload execution in case tokens get stuck or other unexpected behaviors
    function execute(address _target, bytes calldata _payload) external;

    /// @notice timelock gated function to change the timelock
    function setNewTimelock(address _timelock) external;

    /// @notice function for initializing the voter contract with its dependencies
    function initializeVoter(
        IVoter.InitializationParams memory inputs
    ) external;


    /// @notice this function helps us manage atomic r33 self-compounding without manual hassle
    function compoundR33() external;

    /// @notice clawback bribes/incentives from a FeeDistributor for the next period
    /// @param _tokenToClawback the token to clawback
    /// @param _poolAddress the pool to clawback from
    function clawbackIncentives(address _tokenToClawback, address _poolAddress) external;

    /// @notice transfers the xRam operator
    function transferOperatorInXRam(address _operator) external;

    /// @notice set the reward validator contract
    /// @param _rewardValidator The address of the RewardValidator contract
    function setRewardValidator(address _rewardValidator) external;

    /// @notice set the nfp manager
    /// @param _nfpManager The address of the NfpManager contract
    function setNfpManager(address _nfpManager) external;

    /// @notice set the cl gauge factory implementation
    /// @param _clGaugeFactory The address of the ClGaugeFactory contract
    function setClGaugeFactoryImpl(address _clGaugeFactory) external;

    /// @notice add an authorized claimer to the voter
    /// @param _claimer The address of the authorized claimer
    function addAuthorizedClaimerVoter(address _claimer) external;
    
    /// @notice remove an authorized claimer from the voter
    /// @param _claimer The address of the authorized claimer to remove
    function removeAuthorizedClaimerVoter(address _claimer) external;

    function syncClGaugesBatch(uint256 startIndex, uint256 endIndex) external;

    /// @notice Add a reward token to a specific CL gauge
    /// @param _gauge The gauge address to add the reward to
    /// @param _reward The reward token address to add
    function addRewardsToGauge(address _gauge, address _reward) external;

    /// @notice Remove a reward token from a specific CL gauge
    /// @param _gauge The gauge address to remove the reward from
    /// @param _reward The reward token address to remove
    function removeRewardsFromGauge(address _gauge, address _reward) external;

    /// @notice Add reward tokens to multiple CL gauges
    /// @param _gauges Array of gauge addresses to add rewards to
    /// @param _rewards Array of reward token addresses to add
    function batchAddRewardsToGauges(address[] calldata _gauges, address[] calldata _rewards) external;

    /// @notice Remove reward tokens from multiple CL gauges
    /// @param _gauges Array of gauge addresses to remove rewards from
    /// @param _rewards Array of reward token addresses to remove
    function batchRemoveRewardsFromGauges(address[] calldata _gauges, address[] calldata _rewards) external;
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC721/IERC721.sol)

pragma solidity ^0.8.20;

import {IERC165} from "../../utils/introspection/IERC165.sol";

/**
 * @dev Required interface of an ERC-721 compliant contract.
 */
interface IERC721 is IERC165 {
    /**
     * @dev Emitted when `tokenId` token is transferred from `from` to `to`.
     */
    event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
     */
    event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
     */
    event ApprovalForAll(address indexed owner, address indexed operator, bool approved);

    /**
     * @dev Returns the number of tokens in ``owner``'s account.
     */
    function balanceOf(address owner) external view returns (uint256 balance);

    /**
     * @dev Returns the owner of the `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function ownerOf(uint256 tokenId) external view returns (address owner);

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon
     *   a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
     * are aware of the ERC-721 protocol to prevent tokens from being forever locked.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or
     *   {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon
     *   a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(address from, address to, uint256 tokenId) external;

    /**
     * @dev Transfers `tokenId` token from `from` to `to`.
     *
     * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC-721
     * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must
     * understand this adds an external call which potentially creates a reentrancy vulnerability.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address from, address to, uint256 tokenId) external;

    /**
     * @dev Gives permission to `to` to transfer `tokenId` token to another account.
     * The approval is cleared when the token is transferred.
     *
     * Only a single account can be approved at a time, so approving the zero address clears previous approvals.
     *
     * Requirements:
     *
     * - The caller must own the token or be an approved operator.
     * - `tokenId` must exist.
     *
     * Emits an {Approval} event.
     */
    function approve(address to, uint256 tokenId) external;

    /**
     * @dev Approve or remove `operator` as an operator for the caller.
     * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
     *
     * Requirements:
     *
     * - The `operator` cannot be the address zero.
     *
     * Emits an {ApprovalForAll} event.
     */
    function setApprovalForAll(address operator, bool approved) external;

    /**
     * @dev Returns the account approved for `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function getApproved(uint256 tokenId) external view returns (address operator);

    /**
     * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
     *
     * See {setApprovalForAll}
     */
    function isApprovedForAll(address owner, address operator) external view returns (bool);
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC721/utils/ERC721Utils.sol)

pragma solidity ^0.8.20;

import {IERC721Receiver} from "../IERC721Receiver.sol";
import {IERC721Errors} from "../../../interfaces/draft-IERC6093.sol";

/**
 * @dev Library that provide common ERC-721 utility functions.
 *
 * See https://eips.ethereum.org/EIPS/eip-721[ERC-721].
 *
 * _Available since v5.1._
 */
library ERC721Utils {
    /**
     * @dev Performs an acceptance check for the provided `operator` by calling {IERC721-onERC721Received}
     * on the `to` address. The `operator` is generally the address that initiated the token transfer (i.e. `msg.sender`).
     *
     * The acceptance call is not executed and treated as a no-op if the target address doesn't contain code (i.e. an EOA).
     * Otherwise, the recipient must implement {IERC721Receiver-onERC721Received} and return the acceptance magic value to accept
     * the transfer.
     */
    function checkOnERC721Received(
        address operator,
        address from,
        address to,
        uint256 tokenId,
        bytes memory data
    ) internal {
        if (to.code.length > 0) {
            try IERC721Receiver(to).onERC721Received(operator, from, tokenId, data) returns (bytes4 retval) {
                if (retval != IERC721Receiver.onERC721Received.selector) {
                    // Token rejected
                    revert IERC721Errors.ERC721InvalidReceiver(to);
                }
            } catch (bytes memory reason) {
                if (reason.length == 0) {
                    // non-IERC721Receiver implementer
                    revert IERC721Errors.ERC721InvalidReceiver(to);
                } else {
                    assembly ("memory-safe") {
                        revert(add(32, reason), mload(reason))
                    }
                }
            }
        }
    }
}

// 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;
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/Strings.sol)

pragma solidity ^0.8.20;

import {Math} from "./math/Math.sol";
import {SignedMath} from "./math/SignedMath.sol";

/**
 * @dev String operations.
 */
library Strings {
    bytes16 private constant HEX_DIGITS = "0123456789abcdef";
    uint8 private constant ADDRESS_LENGTH = 20;

    /**
     * @dev The `value` string doesn't fit in the specified `length`.
     */
    error StringsInsufficientHexLength(uint256 value, uint256 length);

    /**
     * @dev Converts a `uint256` to its ASCII `string` decimal representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        unchecked {
            uint256 length = Math.log10(value) + 1;
            string memory buffer = new string(length);
            uint256 ptr;
            assembly ("memory-safe") {
                ptr := add(buffer, add(32, length))
            }
            while (true) {
                ptr--;
                assembly ("memory-safe") {
                    mstore8(ptr, byte(mod(value, 10), HEX_DIGITS))
                }
                value /= 10;
                if (value == 0) break;
            }
            return buffer;
        }
    }

    /**
     * @dev Converts a `int256` to its ASCII `string` decimal representation.
     */
    function toStringSigned(int256 value) internal pure returns (string memory) {
        return string.concat(value < 0 ? "-" : "", toString(SignedMath.abs(value)));
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        unchecked {
            return toHexString(value, Math.log256(value) + 1);
        }
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
     */
    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
        uint256 localValue = value;
        bytes memory buffer = new bytes(2 * length + 2);
        buffer[0] = "0";
        buffer[1] = "x";
        for (uint256 i = 2 * length + 1; i > 1; --i) {
            buffer[i] = HEX_DIGITS[localValue & 0xf];
            localValue >>= 4;
        }
        if (localValue != 0) {
            revert StringsInsufficientHexLength(value, length);
        }
        return string(buffer);
    }

    /**
     * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal
     * representation.
     */
    function toHexString(address addr) internal pure returns (string memory) {
        return toHexString(uint256(uint160(addr)), ADDRESS_LENGTH);
    }

    /**
     * @dev Converts an `address` with fixed length of 20 bytes to its checksummed ASCII `string` hexadecimal
     * representation, according to EIP-55.
     */
    function toChecksumHexString(address addr) internal pure returns (string memory) {
        bytes memory buffer = bytes(toHexString(addr));

        // hash the hex part of buffer (skip length + 2 bytes, length 40)
        uint256 hashValue;
        assembly ("memory-safe") {
            hashValue := shr(96, keccak256(add(buffer, 0x22), 40))
        }

        for (uint256 i = 41; i > 1; --i) {
            // possible values for buffer[i] are 48 (0) to 57 (9) and 97 (a) to 102 (f)
            if (hashValue & 0xf > 7 && uint8(buffer[i]) > 96) {
                // case shift by xoring with 0x20
                buffer[i] ^= 0x20;
            }
            hashValue >>= 4;
        }
        return string(buffer);
    }

    /**
     * @dev Returns true if the two strings are equal.
     */
    function equal(string memory a, string memory b) internal pure returns (bool) {
        return bytes(a).length == bytes(b).length && keccak256(bytes(a)) == keccak256(bytes(b));
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/introspection/ERC165.sol)

pragma solidity ^0.8.20;

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

/**
 * @dev Implementation of the {IERC165} interface.
 *
 * Contracts that want to implement ERC-165 should inherit from this contract and override {supportsInterface} to check
 * for the additional interface id that will be supported. For example:
 *
 * ```solidity
 * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
 *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
 * }
 * ```
 */
abstract contract ERC165 is IERC165 {
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {
        return interfaceId == type(IERC165).interfaceId;
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (interfaces/draft-IERC6093.sol)
pragma solidity ^0.8.20;

/**
 * @dev Standard ERC-20 Errors
 * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-20 tokens.
 */
interface IERC20Errors {
    /**
     * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     * @param balance Current balance for the interacting account.
     * @param needed Minimum amount required to perform a transfer.
     */
    error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed);

    /**
     * @dev Indicates a failure with the token `sender`. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     */
    error ERC20InvalidSender(address sender);

    /**
     * @dev Indicates a failure with the token `receiver`. Used in transfers.
     * @param receiver Address to which tokens are being transferred.
     */
    error ERC20InvalidReceiver(address receiver);

    /**
     * @dev Indicates a failure with the `spender`’s `allowance`. Used in transfers.
     * @param spender Address that may be allowed to operate on tokens without being their owner.
     * @param allowance Amount of tokens a `spender` is allowed to operate with.
     * @param needed Minimum amount required to perform a transfer.
     */
    error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed);

    /**
     * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
     * @param approver Address initiating an approval operation.
     */
    error ERC20InvalidApprover(address approver);

    /**
     * @dev Indicates a failure with the `spender` to be approved. Used in approvals.
     * @param spender Address that may be allowed to operate on tokens without being their owner.
     */
    error ERC20InvalidSpender(address spender);
}

/**
 * @dev Standard ERC-721 Errors
 * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-721 tokens.
 */
interface IERC721Errors {
    /**
     * @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in ERC-20.
     * Used in balance queries.
     * @param owner Address of the current owner of a token.
     */
    error ERC721InvalidOwner(address owner);

    /**
     * @dev Indicates a `tokenId` whose `owner` is the zero address.
     * @param tokenId Identifier number of a token.
     */
    error ERC721NonexistentToken(uint256 tokenId);

    /**
     * @dev Indicates an error related to the ownership over a particular token. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     * @param tokenId Identifier number of a token.
     * @param owner Address of the current owner of a token.
     */
    error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner);

    /**
     * @dev Indicates a failure with the token `sender`. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     */
    error ERC721InvalidSender(address sender);

    /**
     * @dev Indicates a failure with the token `receiver`. Used in transfers.
     * @param receiver Address to which tokens are being transferred.
     */
    error ERC721InvalidReceiver(address receiver);

    /**
     * @dev Indicates a failure with the `operator`’s approval. Used in transfers.
     * @param operator Address that may be allowed to operate on tokens without being their owner.
     * @param tokenId Identifier number of a token.
     */
    error ERC721InsufficientApproval(address operator, uint256 tokenId);

    /**
     * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
     * @param approver Address initiating an approval operation.
     */
    error ERC721InvalidApprover(address approver);

    /**
     * @dev Indicates a failure with the `operator` to be approved. Used in approvals.
     * @param operator Address that may be allowed to operate on tokens without being their owner.
     */
    error ERC721InvalidOperator(address operator);
}

/**
 * @dev Standard ERC-1155 Errors
 * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-1155 tokens.
 */
interface IERC1155Errors {
    /**
     * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     * @param balance Current balance for the interacting account.
     * @param needed Minimum amount required to perform a transfer.
     * @param tokenId Identifier number of a token.
     */
    error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId);

    /**
     * @dev Indicates a failure with the token `sender`. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     */
    error ERC1155InvalidSender(address sender);

    /**
     * @dev Indicates a failure with the token `receiver`. Used in transfers.
     * @param receiver Address to which tokens are being transferred.
     */
    error ERC1155InvalidReceiver(address receiver);

    /**
     * @dev Indicates a failure with the `operator`’s approval. Used in transfers.
     * @param operator Address that may be allowed to operate on tokens without being their owner.
     * @param owner Address of the current owner of a token.
     */
    error ERC1155MissingApprovalForAll(address operator, address owner);

    /**
     * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
     * @param approver Address initiating an approval operation.
     */
    error ERC1155InvalidApprover(address approver);

    /**
     * @dev Indicates a failure with the `operator` to be approved. Used in approvals.
     * @param operator Address that may be allowed to operate on tokens without being their owner.
     */
    error ERC1155InvalidOperator(address operator);

    /**
     * @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation.
     * Used in batch transfers.
     * @param idsLength Length of the array of token identifiers
     * @param valuesLength Length of the array of token amounts
     */
    error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength);
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/extensions/IERC721Enumerable.sol)

pragma solidity ^0.8.20;

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

/**
 * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
 * @dev See https://eips.ethereum.org/EIPS/eip-721
 */
interface IERC721Enumerable is IERC721 {
    /**
     * @dev Returns the total amount of tokens stored by the contract.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns a token ID owned by `owner` at a given `index` of its token list.
     * Use along with {balanceOf} to enumerate all of ``owner``'s tokens.
     */
    function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256);

    /**
     * @dev Returns a token ID at a given `index` of all the tokens stored by the contract.
     * Use along with {totalSupply} to enumerate all tokens.
     */
    function tokenByIndex(uint256 index) external view returns (uint256);
}

// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.7.5;
pragma abicoder v2;

/// @title Multicall interface
/// @notice Enables calling multiple methods in a single call to the contract
interface IMulticall {
    /// @notice Call multiple functions in the current contract and return the data from all of them if they all succeed
    /// @dev The `msg.value` should not be trusted for any method callable from multicall.
    /// @param data The encoded function data for each of the calls to make to this contract
    /// @return results The results from each of the calls passed in via data
    function multicall(bytes[] calldata data) external payable returns (bytes[] memory results);
}

// 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 IRamsesV3PoolImmutables {
    /// @notice The contract that deployed the pool, which must adhere to the IRamsesV3Factory 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);
}

// 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 IRamsesV3PoolState {
    /// @notice The 0th storage slot in the pool stores many values, and is exposed as a single method to save gas
    /// when accessed externally.
    /// @return sqrtPriceX96 The current price of the pool as a sqrt(token1/token0) Q64.96 value
    /// @return tick The current tick of the pool, i.e. according to the last tick transition that was run.
    /// This value may not always be equal to SqrtTickMath.getTickAtSqrtRatio(sqrtPriceX96) if the price is on a tick
    /// boundary.
    /// @return observationIndex The index of the last oracle observation that was written,
    /// @return observationCardinality The current maximum number of observations stored in the pool,
    /// @return observationCardinalityNext The next maximum number of observations, to be updated when the observation.
    /// @return feeProtocol The protocol fee for both tokens of the pool.
    /// Encoded as two 4 bit values, where the protocol fee of token1 is shifted 4 bits and the protocol fee of token0
    /// is the lower 4 bits. Used as the denominator of a fraction of the swap fee, e.g. 4 means 1/4th of the swap fee.
    /// unlocked Whether the pool is currently locked to reentrancy
    function slot0()
        external
        view
        returns (
            uint160 sqrtPriceX96,
            int24 tick,
            uint16 observationIndex,
            uint16 observationCardinality,
            uint16 observationCardinalityNext,
            uint24 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 Get the accumulated fee growth for the first token in the pool before protocol fees
    /// @dev This value can overflow the uint256
    function grossFeeGrowthGlobal0X128() external view returns (uint256);

    /// @notice Get the accumulated fee growth for the second token in the pool before protocol fees
    /// @dev This value can overflow the uint256
    function grossFeeGrowthGlobal1X128() external view returns (uint256);

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

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

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

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

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

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

    /// @notice get the period seconds in range of a specific position
    /// @param period the period number
    /// @param owner owner address
    /// @param index position index
    /// @param tickLower lower bound of range
    /// @param tickUpper upper bound of range
    /// @return periodSecondsInsideX96 seconds the position was in range for the period
    function positionPeriodSecondsInRange(
        uint256 period,
        address owner,
        uint256 index,
        int24 tickLower,
        int24 tickUpper
    ) external view returns (uint256 periodSecondsInsideX96);
}

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

// 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 IRamsesV3PoolActions {
    /// @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 index The index 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,
        uint256 index,
        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 index The index of the position to be 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,
        uint256 index,
        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 index The index for which the liquidity will be burned
    /// @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(
        uint256 index,
        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;
}

// 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 IRamsesV3PoolOwnerActions {
    /// @notice Set the denominator of the protocol's % share of the fees
    function setFeeProtocol() 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);

    function setFee(uint24 _fee) external;
}

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

/// @title Errors emitted by a pool
/// @notice Contains all custom errors that can be emitted by the pool
interface IRamsesV3PoolErrors {
    /*//////////////////////////////////////////////////////////////
                            POOL ERRORS
    //////////////////////////////////////////////////////////////*/

    /// @notice Thrown when the pool is locked during a swap or mint/burn operation
    error LOK(); // Locked

    /// @notice Thrown when tick lower is greater than upper in position management
    error TLU(); // Tick Lower > Upper

    /// @notice Thrown when tick lower is less than minimum allowed
    error TLM(); // Tick Lower < Min

    /// @notice Thrown when tick upper is greater than maximum allowed
    error TUM(); // Tick Upper > Max

    /// @notice Thrown when the pool is already initialized
    error AI(); // Already Initialized

    /// @notice Thrown when the first margin value is zero
    error M0(); // Mint token 0 error

    /// @notice Thrown when the second margin value is zero
    error M1(); // Mint token1 error

    /// @notice Thrown when amount specified is invalid
    error AS(); // Amount Specified Invalid

    /// @notice Thrown when input amount is insufficient
    error IIA(); // Insufficient Input Amount

    /// @notice Thrown when pool lacks sufficient liquidity for operation
    error L(); // Insufficient Liquidity

    /// @notice Thrown when the first fee value is zero
    error F0(); // Fee0 issue or Fee = 0

    /// @notice Thrown when the second fee value is zero
    error F1(); // Fee1 issue

    /// @notice Thrown when square price limit is invalid
    error SPL(); // Square Price Limit Invalid
}

File 35 of 68 : IRamsesV3PoolEvents.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 IRamsesV3PoolEvents {
    /// @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 index The index of the position
    /// @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,
        uint256 index,
        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);
}

// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.7.5;
pragma abicoder v2;

/// @title Creates and initializes V3 Pools
/// @notice Provides a method for creating and initializing a pool, if necessary, for bundling with other methods that
/// require the pool to exist.
interface IPoolInitializer {
    /// @notice Creates a new pool if it does not exist, then initializes if not initialized
    /// @dev This method can be bundled with others via IMulticall for the first action (e.g. mint) performed against a pool
    /// @param token0 The contract address of token0 of the pool
    /// @param token1 The contract address of token1 of the pool
    /// @param tickSpacing The tickSpacing of the v3 pool for the specified token pair
    /// @param sqrtPriceX96 The initial square root price of the pool as a Q64.96 value
    /// @return pool Returns the pool address based on the pair of tokens and fee, will return the newly created pool address if necessary
    function createAndInitializePoolIfNecessary(
        address token0,
        address token1,
        int24 tickSpacing,
        uint160 sqrtPriceX96
    ) external payable returns (address pool);
}

// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.7.5;

/// @title Periphery Payments
/// @notice Functions to ease deposits and withdrawals of ETH
interface IPeripheryPayments {
    /// @notice Unwraps the contract's WETH9 balance and sends it to recipient as ETH.
    /// @dev The amountMinimum parameter prevents malicious contracts from stealing WETH9 from users.
    /// @param amountMinimum The minimum amount of WETH9 to unwrap
    /// @param recipient The address receiving ETH
    function unwrapWETH9(uint256 amountMinimum, address recipient) external payable;

    /// @notice Refunds any ETH balance held by this contract to the `msg.sender`
    /// @dev Useful for bundling with mint or increase liquidity that uses ether, or exact output swaps
    /// that use ether for the input amount
    function refundETH() external payable;

    /// @notice Transfers the full amount of a token held by this contract to recipient
    /// @dev The amountMinimum parameter prevents malicious contracts from stealing the token from users
    /// @param token The contract address of the token which will be transferred to `recipient`
    /// @param amountMinimum The minimum amount of token required for a transfer
    /// @param recipient The destination address of the token
    function sweepToken(
        address token,
        uint256 amountMinimum,
        address recipient
    ) external payable;
}

// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

/// @title Immutable state
/// @notice Functions that return immutable state of the router
interface IPeripheryImmutableState {
    /// @return Returns the address of the Uniswap V3 deployer
    function deployer() external view returns (address);

    /// @return Returns the address of WETH9
    function WETH9() external view returns (address);
}

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

/// @title Errors emitted by the NonFungiblePositionManager
/// @notice Contains all events emitted by the NfpManager
interface IPeripheryErrors {
    error InvalidTokenId(uint256 tokenId);
    error CheckSlippage();
    error NotCleared();
}

// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

/// @title The interface for the Ramses V3 Factory
/// @notice The Ramses V3 Factory facilitates creation of Ramses V3 pools and control over the protocol fees
interface IRamsesV3Factory {
    /// @notice Emitted when a pool is created
    /// @param token0 The first token of the pool by address sort order
    /// @param token1 The second token of the pool by address sort order
    /// @param fee The fee collected upon every swap in the pool, denominated in hundredths of a bip
    /// @param tickSpacing The minimum number of ticks between initialized ticks
    /// @param pool The address of the created pool
    event PoolCreated(
        address indexed token0, address indexed token1, uint24 indexed fee, int24 tickSpacing, address pool
    );

    /// @notice Emitted when a new tickspacing amount is enabled for pool creation via the factory
    /// @dev unlike UniswapV3, we map via the tickSpacing rather than the fee tier
    /// @param tickSpacing The minimum number of ticks between initialized ticks
    /// @param fee The fee, denominated in hundredths of a bip
    event TickSpacingEnabled(int24 indexed tickSpacing, uint24 indexed fee);

    /// @notice Emitted when the protocol fee is changed
    /// @param feeProtocolOld The previous value of the protocol fee
    /// @param feeProtocolNew The updated value of the protocol fee
    event SetFeeProtocol(uint24 feeProtocolOld, uint24 feeProtocolNew);

    /// @notice Emitted when the protocol fee is changed
    /// @param pool The pool address
    /// @param feeProtocolOld The previous value of the protocol fee
    /// @param feeProtocolNew The updated value of the protocol fee
    event SetPoolFeeProtocol(address pool, uint24 feeProtocolOld, uint24 feeProtocolNew);

    /// @notice Emitted when a pool's fee is changed
    /// @param pool The pool address
    /// @param newFee The updated value of the protocol fee
    event FeeAdjustment(address pool, uint24 newFee);

    /// @notice Emitted when the fee collector is changed
    /// @param oldFeeCollector The previous implementation
    /// @param newFeeCollector The new implementation
    event FeeCollectorChanged(address indexed oldFeeCollector, address indexed newFeeCollector);

    /// @notice Returns the PoolDeployer address
    /// @return The address of the PoolDeployer contract
    function ramsesV3PoolDeployer() external returns (address);

    /// @notice Returns the fee amount for a given tickSpacing, if enabled, or 0 if not enabled
    /// @dev A tickSpacing can never be removed, so this value should be hard coded or cached in the calling context
    /// @dev unlike UniswapV3, we map via the tickSpacing rather than the fee tier
    /// @param tickSpacing The enabled tickSpacing. Returns 0 in case of unenabled tickSpacing
    /// @return initialFee The initial fee
    function tickSpacingInitialFee(int24 tickSpacing) external view returns (uint24 initialFee);

    /// @notice Returns the pool address for a given pair of tokens and a tickSpacing, or address 0 if it does not exist
    /// @dev tokenA and tokenB may be passed in either token0/token1 or token1/token0 order
    /// @dev unlike UniswapV3, we map via the tickSpacing rather than the fee tier
    /// @param tokenA The contract address of either token0 or token1
    /// @param tokenB The contract address of the other token
    /// @param tickSpacing The tickSpacing of the pool
    /// @return pool The pool address
    function getPool(address tokenA, address tokenB, int24 tickSpacing) external view returns (address pool);

    /// @notice Creates a pool for the given two tokens and fee
    /// @dev unlike UniswapV3, we map via the tickSpacing rather than the fee tier
    /// @param tokenA One of the two tokens in the desired pool
    /// @param tokenB The other of the two tokens in the desired pool
    /// @param tickSpacing The desired tickSpacing for the pool
    /// @param sqrtPriceX96 initial sqrtPriceX96 of the pool
    /// @dev tokenA and tokenB may be passed in either order: token0/token1 or token1/token0.
    /// @dev The call will revert if the pool already exists, the tickSpacing is invalid, or the token arguments are invalid.
    /// @return pool The address of the newly created pool
    function createPool(address tokenA, address tokenB, int24 tickSpacing, uint160 sqrtPriceX96)
        external
        returns (address pool);

    /// @notice Enables a tickSpacing with the given initialFee amount
    /// @dev unlike UniswapV3, we map via the tickSpacing rather than the fee tier
    /// @dev tickSpacings may never be removed once enabled
    /// @param tickSpacing The spacing between ticks to be enforced for all pools created
    /// @param initialFee The initial fee amount, denominated in hundredths of a bip (i.e. 1e-6)
    function enableTickSpacing(int24 tickSpacing, uint24 initialFee) external;

    /// @notice Returns the default protocol fee value
    /// @return _feeProtocol The default protocol fee percentage
    function feeProtocol() external view returns (uint24 _feeProtocol);

    /// @notice Returns the protocol fee percentage for a specific pool
    /// @dev If the fee is 0 or the pool is uninitialized, returns the Factory's default feeProtocol
    /// @param pool The address of the pool
    /// @return _feeProtocol The protocol fee percentage for the specified pool
    function poolFeeProtocol(address pool) external view returns (uint24 _feeProtocol);

    /// @notice Sets the default protocol fee percentage
    /// @param _feeProtocol New default protocol fee percentage for token0 and token1
    function setFeeProtocol(uint24 _feeProtocol) external;

    /// @notice Retrieves the parameters used in constructing a pool
    /// @dev Called by the pool constructor to fetch the pool's parameters
    /// @return factory The factory address
    /// @return token0 The first token of the pool by address sort order
    /// @return token1 The second token of the pool by address sort order
    /// @return fee The initialized fee tier of the pool, denominated in hundredths of a bip
    /// @return tickSpacing The minimum number of ticks between initialized ticks
    function parameters()
        external
        view
        returns (address factory, address token0, address token1, uint24 fee, int24 tickSpacing);

    /// @notice Updates the fee collector address
    /// @param _feeCollector The new fee collector address
    function setFeeCollector(address _feeCollector) external;

    /// @notice Updates the swap fee for a specific pool
    /// @param _pool The address of the pool to modify
    /// @param _fee The new fee value, scaled where 1_000_000 = 100%
    function setFee(address _pool, uint24 _fee) external;

    /// @notice Returns the current fee collector address
    /// @dev The fee collector contract determines the distribution of protocol fees
    /// @return The address of the fee collector contract
    function feeCollector() external view returns (address);

    /// @notice Flag for getting a pool to use the default feeProcotol
    /// @dev type(uint24).max denotes using default feeProcotol
    function DEFAULT_FEE_FLAG() external view returns (uint24);

    /// @notice Updates the protocol fee percentage for a specific pool
    /// @dev type(uint24).max denotes using default feeProcotol
    /// @param pool The address of the pool to modify
    /// @param _feeProtocol The new protocol fee percentage to assign
    function setPoolFeeProtocol(address pool, uint24 _feeProtocol) external;

    /// @notice Enables fee protocol splitting upon gauge creation
    /// @param pool The address of the pool to enable fee splitting for
    function gaugeFeeSplitEnable(address pool) external;

    /// @notice Updates the voter contract address
    /// @param _voter The new voter contract address
    function setVoter(address _voter) external;

    /// @notice Checks if a given address is a V3 pool
    /// @param _pool The address to check
    /// @return isV3 True if the address is a V3 pool, false otherwise
    function isPairV3(address _pool) external view returns (bool isV3);

    /// @notice Initializes the factory with a pool deployer
    /// @param poolDeployer The address of the pool deployer contract
    function initialize(address poolDeployer) external;

    /// @notice returns the voter
    function voter() external returns (address);
}

// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

/// @dev original UniswapV3 callbacks maintained to ensure seamless integrations

/// @title Callback for IUniswapV3PoolActions#mint
/// @notice Any contract that calls IUniswapV3PoolActions#mint must implement this interface
interface IUniswapV3MintCallback {
    /// @notice Called to `msg.sender` after minting liquidity to a position from IUniswapV3Pool#mint.
    /// @dev In the implementation you must pay the pool tokens owed for the minted liquidity.
    /// The caller of this method must be checked to be a UniswapV3Pool deployed by the canonical UniswapV3Factory.
    /// @param amount0Owed The amount of token0 due to the pool for the minted liquidity
    /// @param amount1Owed The amount of token1 due to the pool for the minted liquidity
    /// @param data Any data passed through by the caller via the IUniswapV3PoolActions#mint call
    function uniswapV3MintCallback(uint256 amount0Owed, uint256 amount1Owed, bytes calldata data) external;
}

// 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;

            /// @dev this divides by 1<<32 rounding up to go from a Q128.128 to a Q128.96.
            /// @dev we then downcast because we know the result always fits within 160 bits due to our tick input constraint
            /// @dev 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 {
            /// @dev 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; /// @dev 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;
        }
    }
}

// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8.0;

import '../../core/interfaces/IRamsesV3Pool.sol';
import './PoolAddress.sol';

/// @notice Provides validation for callbacks from Ramses V3 Pools
library CallbackValidation {
    /// @notice Returns the address of a valid Ramses V3 Pool
    /// @param deployer The contract address of the Ramses V3 deployer
    /// @param tokenA The contract address of either token0 or token1
    /// @param tokenB The contract address of the other token
    /// @param tickSpacing The tickSpacing of the pool
    /// @return pool The V3 pool contract address
    function verifyCallback(
        address deployer,
        address tokenA,
        address tokenB,
        int24 tickSpacing
    ) internal view returns (IRamsesV3Pool pool) {
        return verifyCallback(deployer, PoolAddress.getPoolKey(tokenA, tokenB, tickSpacing));
    }

    /// @notice Returns the address of a valid Ramses V3 Pool
    /// @param deployer The contract address of the Ramses V3 deployer
    /// @param poolKey The identifying key of the V3 pool
    /// @return pool The V3 pool contract address
    function verifyCallback(
        address deployer,
        PoolAddress.PoolKey memory poolKey
    ) internal view returns (IRamsesV3Pool pool) {
        pool = IRamsesV3Pool(PoolAddress.computeAddress(deployer, poolKey));
        require(msg.sender == address(pool));
    }
}

// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

import '../../core/libraries/FullMath.sol';
import '../../core/libraries/FixedPoint96.sol';

/// @title Liquidity amount functions
/// @notice Provides functions for computing liquidity amounts from token amounts and prices
library LiquidityAmounts {
    /// @notice Downcasts uint256 to uint128
    /// @param x The uint258 to be downcasted
    /// @return y The passed value, downcasted to uint128
    function toUint128(uint256 x) private pure returns (uint128 y) {
        require((y = uint128(x)) == x);
    }

    /// @notice Computes the amount of liquidity received for a given amount of token0 and price range
    /// @dev Calculates amount0 * (sqrt(upper) * sqrt(lower)) / (sqrt(upper) - sqrt(lower))
    /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary
    /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary
    /// @param amount0 The amount0 being sent in
    /// @return liquidity The amount of returned liquidity
    function getLiquidityForAmount0(
        uint160 sqrtRatioAX96,
        uint160 sqrtRatioBX96,
        uint256 amount0
    ) internal pure returns (uint128 liquidity) {
        if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96);
        uint256 intermediate = FullMath.mulDiv(sqrtRatioAX96, sqrtRatioBX96, FixedPoint96.Q96);
        unchecked {
            return toUint128(FullMath.mulDiv(amount0, intermediate, sqrtRatioBX96 - sqrtRatioAX96));
        }
    }

    /// @notice Computes the amount of liquidity received for a given amount of token1 and price range
    /// @dev Calculates amount1 / (sqrt(upper) - sqrt(lower)).
    /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary
    /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary
    /// @param amount1 The amount1 being sent in
    /// @return liquidity The amount of returned liquidity
    function getLiquidityForAmount1(
        uint160 sqrtRatioAX96,
        uint160 sqrtRatioBX96,
        uint256 amount1
    ) internal pure returns (uint128 liquidity) {
        if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96);
        unchecked {
            return toUint128(FullMath.mulDiv(amount1, FixedPoint96.Q96, sqrtRatioBX96 - sqrtRatioAX96));
        }
    }

    /// @notice Computes the maximum amount of liquidity received for a given amount of token0, token1, the current
    /// pool prices and the prices at the tick boundaries
    /// @param sqrtRatioX96 A sqrt price representing the current pool prices
    /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary
    /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary
    /// @param amount0 The amount of token0 being sent in
    /// @param amount1 The amount of token1 being sent in
    /// @return liquidity The maximum amount of liquidity received
    function getLiquidityForAmounts(
        uint160 sqrtRatioX96,
        uint160 sqrtRatioAX96,
        uint160 sqrtRatioBX96,
        uint256 amount0,
        uint256 amount1
    ) internal pure returns (uint128 liquidity) {
        if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96);

        if (sqrtRatioX96 <= sqrtRatioAX96) {
            liquidity = getLiquidityForAmount0(sqrtRatioAX96, sqrtRatioBX96, amount0);
        } else if (sqrtRatioX96 < sqrtRatioBX96) {
            uint128 liquidity0 = getLiquidityForAmount0(sqrtRatioX96, sqrtRatioBX96, amount0);
            uint128 liquidity1 = getLiquidityForAmount1(sqrtRatioAX96, sqrtRatioX96, amount1);

            liquidity = liquidity0 < liquidity1 ? liquidity0 : liquidity1;
        } else {
            liquidity = getLiquidityForAmount1(sqrtRatioAX96, sqrtRatioBX96, amount1);
        }
    }

    /// @notice Computes the amount of token0 for a given amount of liquidity and a price range
    /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary
    /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary
    /// @param liquidity The liquidity being valued
    /// @return amount0 The amount of token0
    function getAmount0ForLiquidity(
        uint160 sqrtRatioAX96,
        uint160 sqrtRatioBX96,
        uint128 liquidity
    ) internal pure returns (uint256 amount0) {
        unchecked {
            if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96);

            return
                FullMath.mulDiv(
                    uint256(liquidity) << FixedPoint96.RESOLUTION,
                    sqrtRatioBX96 - sqrtRatioAX96,
                    sqrtRatioBX96
                ) / sqrtRatioAX96;
        }
    }

    /// @notice Computes the amount of token1 for a given amount of liquidity and a price range
    /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary
    /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary
    /// @param liquidity The liquidity being valued
    /// @return amount1 The amount of token1
    function getAmount1ForLiquidity(
        uint160 sqrtRatioAX96,
        uint160 sqrtRatioBX96,
        uint128 liquidity
    ) internal pure returns (uint256 amount1) {
        if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96);

        unchecked {
            return FullMath.mulDiv(liquidity, sqrtRatioBX96 - sqrtRatioAX96, FixedPoint96.Q96);
        }
    }

    /// @notice Computes the token0 and token1 value for a given amount of liquidity, the current
    /// pool prices and the prices at the tick boundaries
    /// @param sqrtRatioX96 A sqrt price representing the current pool prices
    /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary
    /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary
    /// @param liquidity The liquidity being valued
    /// @return amount0 The amount of token0
    /// @return amount1 The amount of token1
    function getAmountsForLiquidity(
        uint160 sqrtRatioX96,
        uint160 sqrtRatioAX96,
        uint160 sqrtRatioBX96,
        uint128 liquidity
    ) internal pure returns (uint256 amount0, uint256 amount1) {
        if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96);

        if (sqrtRatioX96 <= sqrtRatioAX96) {
            amount0 = getAmount0ForLiquidity(sqrtRatioAX96, sqrtRatioBX96, liquidity);
        } else if (sqrtRatioX96 < sqrtRatioBX96) {
            amount0 = getAmount0ForLiquidity(sqrtRatioX96, sqrtRatioBX96, liquidity);
            amount1 = getAmount1ForLiquidity(sqrtRatioAX96, sqrtRatioX96, liquidity);
        } else {
            amount1 = getAmount1ForLiquidity(sqrtRatioAX96, sqrtRatioBX96, liquidity);
        }
    }
}

// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.7.5;

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

import '../interfaces/IPeripheryPayments.sol';
import '../interfaces/external/IWETH9.sol';

import '../libraries/TransferHelper.sol';

import './PeripheryImmutableState.sol';

abstract contract PeripheryPayments is IPeripheryPayments, PeripheryImmutableState {
    receive() external payable {
        require(msg.sender == WETH9, 'Not WETH9');
    }

    /// @inheritdoc IPeripheryPayments
    function unwrapWETH9(uint256 amountMinimum, address recipient) public payable override {
        uint256 balanceWETH9 = IWETH9(WETH9).balanceOf(address(this));
        require(balanceWETH9 >= amountMinimum, 'Insufficient WETH9');

        if (balanceWETH9 > 0) {
            IWETH9(WETH9).withdraw(balanceWETH9);
            TransferHelper.safeTransferETH(recipient, balanceWETH9);
        }
    }

    /// @inheritdoc IPeripheryPayments
    function sweepToken(
        address token,
        uint256 amountMinimum,
        address recipient
    ) public payable override {
        uint256 balanceToken = IERC20(token).balanceOf(address(this));
        require(balanceToken >= amountMinimum, 'Insufficient token');

        if (balanceToken > 0) {
            TransferHelper.safeTransfer(token, recipient, balanceToken);
        }
    }

    /// @inheritdoc IPeripheryPayments
    function refundETH() external payable override {
        if (address(this).balance > 0) TransferHelper.safeTransferETH(msg.sender, address(this).balance);
    }

    /// @param token The token to pay
    /// @param payer The entity that must pay
    /// @param recipient The entity that will receive payment
    /// @param value The amount to pay
    function pay(
        address token,
        address payer,
        address recipient,
        uint256 value
    ) internal {
        if (token == WETH9 && address(this).balance >= value) {
            // pay with WETH9
            IWETH9(WETH9).deposit{value: value}(); // wrap only what is needed to pay
            IWETH9(WETH9).transfer(recipient, value);
        } else if (payer == address(this)) {
            // pay with tokens already in the contract (for the exact input multihop case)
            TransferHelper.safeTransfer(token, recipient, value);
        } else {
            // pull payment
            TransferHelper.safeTransferFrom(token, payer, recipient, value);
        }
    }
}

File 46 of 68 : BlockTimestamp.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8.0;

/// @title Function for getting block timestamp
/// @dev Base contract that is overridden for tests
abstract contract BlockTimestamp {
    /// @dev Method that exists purely to be overridden for tests
    /// @return The current block timestamp
    function _blockTimestamp() internal view virtual returns (uint256) {
        return block.timestamp;
    }
}

// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

/// @title An interface for a contract that is capable of deploying Ramses V3 Pools
/// @notice A contract that constructs a pool must implement this to pass arguments to the pool
/// @dev This is used to avoid having constructor arguments in the pool contract, which results in the init code hash
/// of the pool being constant allowing the CREATE2 address of the pool to be cheaply computed on-chain
interface IRamsesV3PoolDeployer {
    /// @notice Get the parameters to be used in constructing the pool, set transiently during pool creation.
    /// @dev Called by the pool constructor to fetch the parameters of the pool
    /// Returns factory The factory address
    /// Returns token0 The first token of the pool by address sort order
    /// Returns token1 The second token of the pool by address sort order
    /// Returns fee The fee collected upon every swap in the pool, denominated in hundredths of a bip
    /// Returns tickSpacing The minimum number of ticks between initialized ticks
    function parameters()
        external
        view
        returns (address factory, address token0, address token1, uint24 fee, int24 tickSpacing);

    /// @dev Deploys a pool with the given parameters by transiently setting the parameters storage slot and then
    /// clearing it after deploying the pool.
    /// @param token0 The first token of the pool by address sort order
    /// @param token1 The second token of the pool by address sort order
    /// @param tickSpacing The tickSpacing of the pool
    function deploy(address token0, address token1, int24 tickSpacing) external returns (address pool);

    function RamsesV3Factory() external view returns (address factory);
}

// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8.0;

interface IVoteModule {
    /**
     * Events
     */
    event Deposit(address indexed from, uint256 amount);

    event Withdraw(address indexed from, uint256 amount);

    event NotifyReward(address indexed from, uint256 amount);

    event ExemptedFromCooldown(address indexed candidate, bool status);

    event NewCooldown(uint256 oldCooldown, uint256 newCooldown);

    event Delegate(address indexed delegator, address indexed delegatee, bool indexed isAdded);

    event SetAdmin(address indexed owner, address indexed operator, bool indexed isAdded);

    /**
     * Functions
     */
    function delegates(address) external view returns (address);
    /// @notice mapping for admins for a specific address
    /// @param owner the owner to check against
    /// @return operator the address that is designated as an admin/operator
    function admins(address owner) external view returns (address operator);

    function accessHub() external view returns (address);


    /// @notice returns the current period
    function getPeriod() external view returns (uint256);


    /// @notice the time which users can deposit and withdraw
    function unlockTime() external view returns (uint256 _timestamp);

    /// @notice deposits all xRAM in the caller's wallet
    function depositAll() external;

    /// @notice deposit a specified amount of xRam
    function deposit(uint256 amount) external;

    /// @notice withdraw all xRAM
    function withdrawAll() external;

    /// @notice withdraw a specified amount of xRAM
    function withdraw(uint256 amount) external;

    /// @notice check for admin perms
    /// @param operator the address to check
    /// @param owner the owner to check against for permissions
    function isAdminFor(address operator, address owner) external view returns (bool approved);

    /// @notice check for delegations
    /// @param delegate the address to check
    /// @param owner the owner to check against for permissions
    function isDelegateFor(address delegate, address owner) external view returns (bool approved);

    /// @notice used by the xRAM contract to notify pending rebases
    /// @param amount the amount of RAM to be notified from exit penalties
    function notifyRewardAmount(uint256 amount) external;

    /// @notice the address of the xRAM token (staking/voting token)
    /// @return _xRam the address
    function xRam() external view returns (address _xRam);    

    /// @notice address of the voter contract
    /// @return _voter the voter contract address
    function voter() external view returns (address _voter);

    /// @notice returns the total voting power (equal to total supply in the VoteModule)
    /// @return _totalSupply the total voting power
    function totalSupply() external view returns (uint256 _totalSupply);

    /// @notice voting power
    /// @param user the address to check
    /// @return amount the staked balance
    function balanceOf(address user) external view returns (uint256 amount);

    /// @notice delegate voting perms to another address
    /// @param delegatee who you delegate to
    /// @dev set address(0) to revoke
    function delegate(address delegatee) external;

    /// @notice give admin permissions to a another address
    /// @param operator the address to give administrative perms to
    /// @dev set address(0) to revoke
    function setAdmin(address operator) external;

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

    function setCooldownExemption(address, bool) external;

    /// @notice lock period after rebase starts accruing
    function cooldown() external returns (uint256);

    function setNewCooldown(uint256) external;
}

// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8.0;

import {IVoter} from "contracts/interfaces/IVoter.sol";

interface IFeeRecipientFactory {
    /// @notice the pair fees for a specific pair
    /// @param pair the pair to check
    /// @return feeRecipient the feeRecipient contract address for the pair
    function feeRecipientForPair(address pair) external view returns (address feeRecipient);

    /// @notice the last feeRecipient address created
    /// @return _feeRecipient the address of the last pair fees contract
    function lastFeeRecipient() external view returns (address _feeRecipient);
    /// @notice create the pair fees for a pair
    /// @param pair the address of the pair
    /// @return _feeRecipient the address of the newly created feeRecipient
    function createFeeRecipient(address pair) external returns (address _feeRecipient);

    /// @notice the fee % going to the treasury
    /// @return _feeToTreasury the fee %
    function feeToTreasury() external view returns (uint256 _feeToTreasury);

    /// @notice get the treasury address
    /// @return _treasury address of the treasury
    function treasury() external view returns (address _treasury);

    /// @notice get the voter address
    /// @return _voter address of the voter
    function voter() external view returns (address _voter);

    /// @notice set the fee % to be sent to the treasury
    /// @param _feeToTreasury the fee % to be sent to the treasury
    function setFeeToTreasury(uint256 _feeToTreasury) external;

    /// @notice set the treasury address
    /// @param _treasury the address of the treasury
    function setTreasury(address _treasury) external;

    /// @notice set the voter address
    /// @param _voter the address of the voter
    function setVoter(address _voter) external;
}

// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8.0;

interface IMinter {
    event SetVeDist(address _value);
    event SetVoter(address _value);
    event Mint(address indexed sender, uint256 weekly);
    event RebaseUnsuccessful(uint256 _current, uint256 _currentPeriod);
    event EmissionsMultiplierUpdated(uint256 _emissionsMultiplier);

    /// @notice decay or inflation scaled to 10_000 = 100%
    /// @return _multiplier the emissions multiplier
    function emissionsMultiplier() external view returns (uint256 _multiplier);

    /// @notice unix timestamp of current epoch's start
    /// @return _activePeriod the active period
    function activePeriod() external view returns (uint256 _activePeriod);

    /// @notice update the epoch (period) -- callable once a week at >= Thursday 0 UTC
    /// @return period the new period
    function updatePeriod() external returns (uint256 period);

    /// @notice intialize epoch0 + emissions (immediately active for this week)
    function initEpoch0() external;

    /// @notice updates the emissions multiplier
    /// @param _emissionsMultiplier the new emissions multiplier
    function updateEmissionsMultiplier(uint256 _emissionsMultiplier) external;

    /// @notice calculates the emissions to be sent to the voter
    /// @return _weeklyEmissions the amount of emissions for the week
    function calculateWeeklyEmissions() external view returns (uint256 _weeklyEmissions);

    /// @notice kicks off the initial minting and variable declarations
    function kickoff(
        address _rex,
        address _voter,
        uint256 _initialWeeklyEmissions,
        uint256 _initialMultiplier,
        address _xRam
    ) external;

    /// @notice returns (block.timestamp / 1 week) for gauge use
    /// @return period period number
    function getPeriod() external view returns (uint256 period);

    /// @notice returns the numerical value of the current epoch
    /// @return _epoch epoch number
    function getEpoch() external view returns (uint256 _epoch);
}

// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8.0;

import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {IERC20Extended} from "./IERC20Extended.sol";
import {IVoter} from "./IVoter.sol";
import {Pausable} from "@openzeppelin/contracts/utils/Pausable.sol";

interface IXRam is IERC20 {
    event InstantExit(address indexed user, uint256);
    event XRamRedeemed(address indexed user, uint256);
    event Converted(address indexed user, uint256);

    event Exemption(address indexed candidate, bool status, bool success);

    event NewOperator(address indexed o, address indexed n);

    event Rebase(address indexed caller, uint256 amount);

    /// @notice address of the ram token
    function RAM() external view returns (IERC20Extended);

    /// @notice address of the voter
    function VOTER() external view returns (IVoter);

    function MINTER() external view returns (address);

    function ACCESS_HUB() external view returns (address);

    /// @notice address of the operator
    function operator() external view returns (address);

    /// @notice address of the VoteModule
    function VOTE_MODULE() external view returns (address);

    /// @notice max slashing amount
    function SLASHING_PENALTY() external view returns (uint256);

    /// @notice denominator
    function BASIS() external view returns (uint256);

    function ram() external view returns (address);

    /// @notice the last period rebases were distributed
    function lastDistributedPeriod() external view returns (uint256);

    /// @notice amount of burns in total
    function totalBurned() external view returns (uint256);

    /// @notice pauses the contract
    function pause() external;

    /// @notice unpauses the contract
    function unpause() external;

    /**
     *
     */
    // General use functions
    /**
     *
     */

    /// @dev mints xRAM for each ram.
    function convertEmissionsToken(uint256 _amount) external;

    /// @notice function called by the minter to send the rebases once a week
    function rebase() external;
    /**
     * @dev exit instantly with a penalty
     * @param _amount amount of xRAM to exit
     */
    function exit(uint256 _amount) external returns (uint256 _exitedAmount);

    /**
     *
     */
    // Permissioned functions, timelock/operator gated
    /**
     *
     */

    /// @dev allows rescue of any non-stake token
    function rescueTrappedTokens(address[] calldata _tokens, uint256[] calldata _amounts) external;

    /// @notice migrates the operator to another contract
    function migrateOperator(address _operator) external;

    /// @notice set exemption status for an address
    function setExemption(address[] calldata _exemptee, bool[] calldata _exempt) external;

    function setExemptionTo(address[] calldata _exemptee, bool[] calldata _exempt) external;

    /**
     *
     */
    // Getter functions
    /**
     *
     */

    /// @notice returns the amount of RAM within the contract
    function getBalanceResiding() external view returns (uint256);

    /// @notice whether the address is exempt
    /// @param _who who to check
    /// @return _exempt whether it's exempt
    function isExempt(address _who) external view returns (bool _exempt);

    /// @notice whether the address is exempt to
    /// @param _who who to check
    /// @return _exempt whether it's exempt
    function isExemptTo(address _who) external view returns (bool _exempt);
}

// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8.0;

import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {IXRam} from "contracts/interfaces/IXRam.sol";

interface IR33 is IERC20  {
    /// @dev parameters passed to the aggregator swap
    struct AggregatorParams {
        address aggregator; // address of the whitelisted aggregator
        address tokenIn; // token to swap from
        uint256 amountIn; // amount of tokenIn to swap
        uint256 minAmountOut; // minimum amount of tokenOut to receive
        bytes callData; // encoded swap calldata
    }

    event Entered(address indexed user, uint256 amount, uint256 ratioAtDeposit);
    event Exited(address indexed user, uint256 _outAmount, uint256 ratioAtWithdrawal);

    event NewOperator(address _oldOperator, address _newOperator);
    event Compounded(uint256 oldRatio, uint256 newRatio, uint256 amount);
    event SwappedBribe(address indexed operator, address indexed tokenIn, uint256 amountIn, uint256 amountOut);
    /// @notice Event emitted when an aggregator's whitelist status changes
    event AggregatorWhitelistUpdated(address aggregator, bool status);

    event Unlocked(uint256 _ts);

    event UpdatedIndex(uint256 _index);

    event ClaimedIncentives(address[] feeDistributors, address[][] tokens);

    function whitelistedAggregators(address aggregator) external returns (bool);

    /// @notice submits the optimized votes for the epoch
    function submitVotes(address[] calldata _pools, uint256[] calldata _weights) external;

    /// @notice swap function using aggregators to process rewards into RAM
    function swapIncentiveViaAggregator(AggregatorParams calldata _params) external;

    /// @notice compounds any existing RAM within the contract
    function compound() external;

    /// @notice direct claim
    function claimIncentives(address[] calldata _feeDistributors, address[][] calldata _tokens) external;

    /// @notice rescue stuck tokens
    function rescue(address _token, uint256 _amount) external;

    /// @notice allows the operator to unlock the contract for the current period
    function unlock() external;

    /// @notice add or remove an aggregator from the whitelist (timelocked)
    /// @param _aggregator address of the aggregator to update
    /// @param _status new whitelist status
    function whitelistAggregator(address _aggregator, bool _status) external;

    /// @notice transfers the operator via accesshub
    function transferOperator(address _newOperator) external;

    /// @notice simple getPeriod call
    function getPeriod() external view returns (uint256 period);

    /// @notice if the contract is unlocked for deposits
    function isUnlocked() external view returns (bool);

    /// @notice determines whether the cooldown is active
    function isCooldownActive() external view returns (bool);

    /// @notice address of the current operator
    function operator() external view returns (address);

    /// @notice accessHub address
    function accessHub() external view returns (address);

    /// @notice returns the ratio of xRam per X33 token
    function ratio() external view returns (uint256 _ratio);

    /// @notice whether the periods are unlocked
    function periodUnlockStatus(uint256 _period) external view returns (bool unlocked);

    /// @notice the ram token
    function ram() external view returns (IERC20);

    /// @notice the xRAM token
    function xRam() external view returns (IXRam);

}

// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8.0;

interface IPairFactory {
    event PairCreated(address indexed token0, address indexed token1, address pair, uint256);

    event SetFee(uint256 indexed fee);

    event SetVoter(address indexed voter);

    event SetPairFee(address indexed pair, uint256 indexed fee);

    event SetFeeSplit(uint256 indexed _feeSplit);

    event SetPairFeeSplit(address indexed pair, uint256 indexed _feeSplit);

    event SkimStatus(address indexed _pair, bool indexed _status);

    event NewTreasury(address indexed _caller, address indexed _newTreasury);

    event FeeSplitWhenNoGauge(address indexed _caller, bool indexed _status);

    event SetFeeRecipient(address indexed pair, address indexed feeRecipient);

    /// @notice returns the total length of legacy pairs
    /// @return _length the length
    function allPairsLength() external view returns (uint256 _length);

    /// @notice calculates if the address is a legacy pair
    /// @param pair the address to check
    /// @return _boolean the bool return
    function isPair(address pair) external view returns (bool _boolean);

    /// @notice calculates the pairCodeHash
    /// @return _hash the pair code hash
    function pairCodeHash() external view returns (bytes32 _hash);

    /// @param tokenA address of tokenA
    /// @param tokenB address of tokenB
    /// @param stable whether it uses the stable curve
    /// @return _pair the address of the pair
    function getPair(address tokenA, address tokenB, bool stable) external view returns (address _pair);

    /// @notice creates a new legacy pair
    /// @param tokenA address of tokenA
    /// @param tokenB address of tokenB
    /// @param stable whether it uses the stable curve
    /// @return pair the address of the created pair
    function createPair(address tokenA, address tokenB, bool stable) external returns (address pair);

    /// @notice the address of the voter
    /// @return _voter the address of the voter
    function voter() external view returns (address _voter);

    /// @notice returns the address of a pair based on the index
    /// @param _index the index to check for a pair
    /// @return _pair the address of the pair at the index
    function allPairs(uint256 _index) external view returns (address _pair);

    /// @notice the swap fee of a pair
    /// @param _pair the address of the pair
    /// @return _fee the fee
    function pairFee(address _pair) external view returns (uint256 _fee);

    /// @notice the split of fees
    /// @return _split the feeSplit
    function feeSplit() external view returns (uint256 _split);

    /// @notice sets the swap fee for a pair
    /// @param _pair the address of the pair
    /// @param _fee the fee for the pair
    function setPairFee(address _pair, uint256 _fee) external;

    /// @notice set the swap fees of the pair
    /// @param _fee the fee, scaled to MAX 500_000 = 50%
    function setFee(uint256 _fee) external;

    /// @notice the address for the treasury
    /// @return _treasury address of the treasury
    function treasury() external view returns (address _treasury);

    /// @notice sets the pairFees contract
    /// @param _pair the address of the pair
    /// @param _pairFees the address of the new Pair Fees
    function setFeeRecipient(address _pair, address _pairFees) external;

    /// @notice sets the feeSplit for a pair
    /// @param _pair the address of the pair
    /// @param _feeSplit the feeSplit
    function setPairFeeSplit(address _pair, uint256 _feeSplit) external;

    /// @notice whether there is feeSplit when there's no gauge
    /// @return _boolean whether there is a feesplit when no gauge
    function feeSplitWhenNoGauge() external view returns (bool _boolean);

    /// @notice whether a pair can be skimmed
    /// @param _pair the pair address
    /// @return _boolean whether skim is enabled
    function skimEnabled(address _pair) external view returns (bool _boolean);

    /// @notice set whether skim is enabled for a specific pair
    function setSkimEnabled(address _pair, bool _status) external;

    /// @notice sets a new treasury address
    /// @param _treasury the new treasury address
    function setTreasury(address _treasury) external;

    /// @notice set whether there should be a feesplit without gauges
    /// @param status whether enabled or not
    function setFeeSplitWhenNoGauge(bool status) external;

    /// @notice sets the feesSplit globally
    /// @param _feeSplit the fee split
    function setFeeSplit(uint256 _feeSplit) external;

    /// @notice sets the voter
    /// @param _voter the voter address
    function setVoter(address _voter) external;
}

// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8.0;

import {IRamsesV3Pool} from "../../core/interfaces/IRamsesV3Pool.sol";

interface IFeeCollector {
    /// @notice Emitted when the treasury address is changed.
    /// @param oldTreasury The previous treasury address.
    /// @param newTreasury The new treasury address.
    event TreasuryChanged(address oldTreasury, address newTreasury);


    /// @notice Emitted when the treasury fees value is changed.
    /// @param oldTreasuryFees The previous value of the treasury fees.
    /// @param newTreasuryFees The new value of the treasury fees.
    event TreasuryFeesChanged(uint256 oldTreasuryFees, uint256 newTreasuryFees);

    /// @notice Emitted when protocol fees are collected from a pool and distributed to the fee distributor and treasury.
    /// @param pool The address of the pool from which the fees were collected.
    /// @param feeDistAmount0 The amount of fee tokens (token 0) distributed to the fee distributor.
    /// @param feeDistAmount1 The amount of fee tokens (token 1) distributed to the fee distributor.
    /// @param treasuryAmount0 The amount of fee tokens (token 0) allocated to the treasury.
    /// @param treasuryAmount1 The amount of fee tokens (token 1) allocated to the treasury.
    event FeesCollected(
        address pool, uint256 feeDistAmount0, uint256 feeDistAmount1, uint256 treasuryAmount0, uint256 treasuryAmount1
    );

    /// @notice Returns the treasury address.
    function treasury() external returns (address);

    /// @notice Returns the treasury fees ratio.
    function treasuryFees() external returns (uint256);

    /// @notice Sets the treasury address to a new value.
    /// @param newTreasury The new address to set as the treasury.
    function setTreasury(address newTreasury) external;

    /// @notice Sets the voter address to a new value.
    /// @param newVoter The new address to set as the voter.
    function setVoter(address newVoter) external;

    /// @notice Sets the value of treasury fees to a new amount.
    /// @param _treasuryFees The new amount of treasury fees to be set.
    function setTreasuryFees(uint256 _treasuryFees) external;

    /// @notice Collects protocol fees from a specified pool and distributes them to the fee distributor and treasury.
    /// @param pool The pool from which to collect the protocol fees.
    function collectProtocolFees(address pool) external;
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/introspection/IERC165.sol)

pragma solidity ^0.8.20;

/**
 * @dev Interface of the ERC-165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[ERC].
 *
 * Implementers can declare support of contract interfaces, which can then be
 * queried by others ({ERC165Checker}).
 *
 * For an implementation, see {ERC165}.
 */
interface IERC165 {
    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[ERC section]
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
}

File 56 of 68 : IERC721Receiver.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC721/IERC721Receiver.sol)

pragma solidity ^0.8.20;

/**
 * @title ERC-721 token receiver interface
 * @dev Interface for any contract that wants to support safeTransfers
 * from ERC-721 asset contracts.
 */
interface IERC721Receiver {
    /**
     * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
     * by `operator` from `from`, this function is called.
     *
     * It must return its Solidity selector to confirm the token transfer.
     * If any other value is returned or the interface is not implemented by the recipient, the transfer will be
     * reverted.
     *
     * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.
     */
    function onERC721Received(
        address operator,
        address from,
        uint256 tokenId,
        bytes calldata data
    ) external returns (bytes4);
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/math/Math.sol)

pragma solidity ^0.8.20;

import {Panic} from "../Panic.sol";
import {SafeCast} from "./SafeCast.sol";

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library Math {
    enum Rounding {
        Floor, // Toward negative infinity
        Ceil, // Toward positive infinity
        Trunc, // Toward zero
        Expand // Away from zero
    }

    /**
     * @dev Returns the addition of two unsigned integers, with an success flag (no overflow).
     */
    function tryAdd(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
        unchecked {
            uint256 c = a + b;
            if (c < a) return (false, 0);
            return (true, c);
        }
    }

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

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

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

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

    /**
     * @dev Branchless ternary evaluation for `a ? b : c`. Gas costs are constant.
     *
     * IMPORTANT: This function may reduce bytecode size and consume less gas when used standalone.
     * However, the compiler may optimize Solidity ternary operations (i.e. `a ? b : c`) to only compute
     * one branch when needed, making this function more expensive.
     */
    function ternary(bool condition, uint256 a, uint256 b) internal pure returns (uint256) {
        unchecked {
            // branchless ternary works because:
            // b ^ (a ^ b) == a
            // b ^ 0 == b
            return b ^ ((a ^ b) * SafeCast.toUint(condition));
        }
    }

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

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

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

    /**
     * @dev Returns the ceiling of the division of two numbers.
     *
     * This differs from standard division with `/` in that it rounds towards infinity instead
     * of rounding towards zero.
     */
    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
        if (b == 0) {
            // Guarantee the same behavior as in a regular Solidity division.
            Panic.panic(Panic.DIVISION_BY_ZERO);
        }

        // The following calculation ensures accurate ceiling division without overflow.
        // Since a is non-zero, (a - 1) / b will not overflow.
        // The largest possible result occurs when (a - 1) / b is type(uint256).max,
        // but the largest value we can obtain is type(uint256).max - 1, which happens
        // when a = type(uint256).max and b = 1.
        unchecked {
            return SafeCast.toUint(a > 0) * ((a - 1) / b + 1);
        }
    }

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

            // Handle non-overflow cases, 256 by 256 division.
            if (prod1 == 0) {
                // Solidity will revert if denominator == 0, unlike the div opcode on its own.
                // The surrounding unchecked block does not change this fact.
                // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
                return prod0 / denominator;
            }

            // Make sure the result is less than 2²⁵⁶. Also prevents denominator == 0.
            if (denominator <= prod1) {
                Panic.panic(ternary(denominator == 0, Panic.DIVISION_BY_ZERO, Panic.UNDER_OVERFLOW));
            }

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

            // Make division exact by subtracting the remainder from [prod1 prod0].
            uint256 remainder;
            assembly {
                // Compute remainder using mulmod.
                remainder := mulmod(x, y, denominator)

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

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

            uint256 twos = denominator & (0 - denominator);
            assembly {
                // Divide denominator by twos.
                denominator := div(denominator, twos)

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

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

            // Shift in bits from prod1 into prod0.
            prod0 |= prod1 * twos;

            // Invert denominator mod 2²⁵⁶. Now that denominator is an odd number, it has an inverse modulo 2²⁵⁶ such
            // that denominator * inv ≡ 1 mod 2²⁵⁶. Compute the inverse by starting with a seed that is correct for
            // four bits. That is, denominator * inv ≡ 1 mod 2⁴.
            uint256 inverse = (3 * denominator) ^ 2;

            // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also
            // works in modular arithmetic, doubling the correct bits in each step.
            inverse *= 2 - denominator * inverse; // inverse mod 2⁸
            inverse *= 2 - denominator * inverse; // inverse mod 2¹⁶
            inverse *= 2 - denominator * inverse; // inverse mod 2³²
            inverse *= 2 - denominator * inverse; // inverse mod 2⁶⁴
            inverse *= 2 - denominator * inverse; // inverse mod 2¹²⁸
            inverse *= 2 - denominator * inverse; // inverse mod 2²⁵⁶

            // 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²⁵⁶. Since the preconditions guarantee that the outcome is
            // less than 2²⁵⁶, this is the final result. We don't need to compute the high bits of the result and prod1
            // is no longer required.
            result = prod0 * inverse;
            return result;
        }
    }

    /**
     * @dev Calculates x * y / denominator with full precision, following the selected rounding direction.
     */
    function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {
        return mulDiv(x, y, denominator) + SafeCast.toUint(unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0);
    }

    /**
     * @dev Calculate the modular multiplicative inverse of a number in Z/nZ.
     *
     * If n is a prime, then Z/nZ is a field. In that case all elements are inversible, except 0.
     * If n is not a prime, then Z/nZ is not a field, and some elements might not be inversible.
     *
     * If the input value is not inversible, 0 is returned.
     *
     * NOTE: If you know for sure that n is (big) a prime, it may be cheaper to use Fermat's little theorem and get the
     * inverse using `Math.modExp(a, n - 2, n)`. See {invModPrime}.
     */
    function invMod(uint256 a, uint256 n) internal pure returns (uint256) {
        unchecked {
            if (n == 0) return 0;

            // The inverse modulo is calculated using the Extended Euclidean Algorithm (iterative version)
            // Used to compute integers x and y such that: ax + ny = gcd(a, n).
            // When the gcd is 1, then the inverse of a modulo n exists and it's x.
            // ax + ny = 1
            // ax = 1 + (-y)n
            // ax ≡ 1 (mod n) # x is the inverse of a modulo n

            // If the remainder is 0 the gcd is n right away.
            uint256 remainder = a % n;
            uint256 gcd = n;

            // Therefore the initial coefficients are:
            // ax + ny = gcd(a, n) = n
            // 0a + 1n = n
            int256 x = 0;
            int256 y = 1;

            while (remainder != 0) {
                uint256 quotient = gcd / remainder;

                (gcd, remainder) = (
                    // The old remainder is the next gcd to try.
                    remainder,
                    // Compute the next remainder.
                    // Can't overflow given that (a % gcd) * (gcd // (a % gcd)) <= gcd
                    // where gcd is at most n (capped to type(uint256).max)
                    gcd - remainder * quotient
                );

                (x, y) = (
                    // Increment the coefficient of a.
                    y,
                    // Decrement the coefficient of n.
                    // Can overflow, but the result is casted to uint256 so that the
                    // next value of y is "wrapped around" to a value between 0 and n - 1.
                    x - y * int256(quotient)
                );
            }

            if (gcd != 1) return 0; // No inverse exists.
            return ternary(x < 0, n - uint256(-x), uint256(x)); // Wrap the result if it's negative.
        }
    }

    /**
     * @dev Variant of {invMod}. More efficient, but only works if `p` is known to be a prime greater than `2`.
     *
     * From https://en.wikipedia.org/wiki/Fermat%27s_little_theorem[Fermat's little theorem], we know that if p is
     * prime, then `a**(p-1) ≡ 1 mod p`. As a consequence, we have `a * a**(p-2) ≡ 1 mod p`, which means that
     * `a**(p-2)` is the modular multiplicative inverse of a in Fp.
     *
     * NOTE: this function does NOT check that `p` is a prime greater than `2`.
     */
    function invModPrime(uint256 a, uint256 p) internal view returns (uint256) {
        unchecked {
            return Math.modExp(a, p - 2, p);
        }
    }

    /**
     * @dev Returns the modular exponentiation of the specified base, exponent and modulus (b ** e % m)
     *
     * Requirements:
     * - modulus can't be zero
     * - underlying staticcall to precompile must succeed
     *
     * IMPORTANT: The result is only valid if the underlying call succeeds. When using this function, make
     * sure the chain you're using it on supports the precompiled contract for modular exponentiation
     * at address 0x05 as specified in https://eips.ethereum.org/EIPS/eip-198[EIP-198]. Otherwise,
     * the underlying function will succeed given the lack of a revert, but the result may be incorrectly
     * interpreted as 0.
     */
    function modExp(uint256 b, uint256 e, uint256 m) internal view returns (uint256) {
        (bool success, uint256 result) = tryModExp(b, e, m);
        if (!success) {
            Panic.panic(Panic.DIVISION_BY_ZERO);
        }
        return result;
    }

    /**
     * @dev Returns the modular exponentiation of the specified base, exponent and modulus (b ** e % m).
     * It includes a success flag indicating if the operation succeeded. Operation will be marked as failed if trying
     * to operate modulo 0 or if the underlying precompile reverted.
     *
     * IMPORTANT: The result is only valid if the success flag is true. When using this function, make sure the chain
     * you're using it on supports the precompiled contract for modular exponentiation at address 0x05 as specified in
     * https://eips.ethereum.org/EIPS/eip-198[EIP-198]. Otherwise, the underlying function will succeed given the lack
     * of a revert, but the result may be incorrectly interpreted as 0.
     */
    function tryModExp(uint256 b, uint256 e, uint256 m) internal view returns (bool success, uint256 result) {
        if (m == 0) return (false, 0);
        assembly ("memory-safe") {
            let ptr := mload(0x40)
            // | Offset    | Content    | Content (Hex)                                                      |
            // |-----------|------------|--------------------------------------------------------------------|
            // | 0x00:0x1f | size of b  | 0x0000000000000000000000000000000000000000000000000000000000000020 |
            // | 0x20:0x3f | size of e  | 0x0000000000000000000000000000000000000000000000000000000000000020 |
            // | 0x40:0x5f | size of m  | 0x0000000000000000000000000000000000000000000000000000000000000020 |
            // | 0x60:0x7f | value of b | 0x<.............................................................b> |
            // | 0x80:0x9f | value of e | 0x<.............................................................e> |
            // | 0xa0:0xbf | value of m | 0x<.............................................................m> |
            mstore(ptr, 0x20)
            mstore(add(ptr, 0x20), 0x20)
            mstore(add(ptr, 0x40), 0x20)
            mstore(add(ptr, 0x60), b)
            mstore(add(ptr, 0x80), e)
            mstore(add(ptr, 0xa0), m)

            // Given the result < m, it's guaranteed to fit in 32 bytes,
            // so we can use the memory scratch space located at offset 0.
            success := staticcall(gas(), 0x05, ptr, 0xc0, 0x00, 0x20)
            result := mload(0x00)
        }
    }

    /**
     * @dev Variant of {modExp} that supports inputs of arbitrary length.
     */
    function modExp(bytes memory b, bytes memory e, bytes memory m) internal view returns (bytes memory) {
        (bool success, bytes memory result) = tryModExp(b, e, m);
        if (!success) {
            Panic.panic(Panic.DIVISION_BY_ZERO);
        }
        return result;
    }

    /**
     * @dev Variant of {tryModExp} that supports inputs of arbitrary length.
     */
    function tryModExp(
        bytes memory b,
        bytes memory e,
        bytes memory m
    ) internal view returns (bool success, bytes memory result) {
        if (_zeroBytes(m)) return (false, new bytes(0));

        uint256 mLen = m.length;

        // Encode call args in result and move the free memory pointer
        result = abi.encodePacked(b.length, e.length, mLen, b, e, m);

        assembly ("memory-safe") {
            let dataPtr := add(result, 0x20)
            // Write result on top of args to avoid allocating extra memory.
            success := staticcall(gas(), 0x05, dataPtr, mload(result), dataPtr, mLen)
            // Overwrite the length.
            // result.length > returndatasize() is guaranteed because returndatasize() == m.length
            mstore(result, mLen)
            // Set the memory pointer after the returned data.
            mstore(0x40, add(dataPtr, mLen))
        }
    }

    /**
     * @dev Returns whether the provided byte array is zero.
     */
    function _zeroBytes(bytes memory byteArray) private pure returns (bool) {
        for (uint256 i = 0; i < byteArray.length; ++i) {
            if (byteArray[i] != 0) {
                return false;
            }
        }
        return true;
    }

    /**
     * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded
     * towards zero.
     *
     * This method is based on Newton's method for computing square roots; the algorithm is restricted to only
     * using integer operations.
     */
    function sqrt(uint256 a) internal pure returns (uint256) {
        unchecked {
            // Take care of easy edge cases when a == 0 or a == 1
            if (a <= 1) {
                return a;
            }

            // In this function, we use Newton's method to get a root of `f(x) := x² - a`. It involves building a
            // sequence x_n that converges toward sqrt(a). For each iteration x_n, we also define the error between
            // the current value as `ε_n = | x_n - sqrt(a) |`.
            //
            // For our first estimation, we consider `e` the smallest power of 2 which is bigger than the square root
            // of the target. (i.e. `2**(e-1) ≤ sqrt(a) < 2**e`). We know that `e ≤ 128` because `(2¹²⁸)² = 2²⁵⁶` is
            // bigger than any uint256.
            //
            // By noticing that
            // `2**(e-1) ≤ sqrt(a) < 2**e → (2**(e-1))² ≤ a < (2**e)² → 2**(2*e-2) ≤ a < 2**(2*e)`
            // we can deduce that `e - 1` is `log2(a) / 2`. We can thus compute `x_n = 2**(e-1)` using a method similar
            // to the msb function.
            uint256 aa = a;
            uint256 xn = 1;

            if (aa >= (1 << 128)) {
                aa >>= 128;
                xn <<= 64;
            }
            if (aa >= (1 << 64)) {
                aa >>= 64;
                xn <<= 32;
            }
            if (aa >= (1 << 32)) {
                aa >>= 32;
                xn <<= 16;
            }
            if (aa >= (1 << 16)) {
                aa >>= 16;
                xn <<= 8;
            }
            if (aa >= (1 << 8)) {
                aa >>= 8;
                xn <<= 4;
            }
            if (aa >= (1 << 4)) {
                aa >>= 4;
                xn <<= 2;
            }
            if (aa >= (1 << 2)) {
                xn <<= 1;
            }

            // We now have x_n such that `x_n = 2**(e-1) ≤ sqrt(a) < 2**e = 2 * x_n`. This implies ε_n ≤ 2**(e-1).
            //
            // We can refine our estimation by noticing that the middle of that interval minimizes the error.
            // If we move x_n to equal 2**(e-1) + 2**(e-2), then we reduce the error to ε_n ≤ 2**(e-2).
            // This is going to be our x_0 (and ε_0)
            xn = (3 * xn) >> 1; // ε_0 := | x_0 - sqrt(a) | ≤ 2**(e-2)

            // From here, Newton's method give us:
            // x_{n+1} = (x_n + a / x_n) / 2
            //
            // One should note that:
            // x_{n+1}² - a = ((x_n + a / x_n) / 2)² - a
            //              = ((x_n² + a) / (2 * x_n))² - a
            //              = (x_n⁴ + 2 * a * x_n² + a²) / (4 * x_n²) - a
            //              = (x_n⁴ + 2 * a * x_n² + a² - 4 * a * x_n²) / (4 * x_n²)
            //              = (x_n⁴ - 2 * a * x_n² + a²) / (4 * x_n²)
            //              = (x_n² - a)² / (2 * x_n)²
            //              = ((x_n² - a) / (2 * x_n))²
            //              ≥ 0
            // Which proves that for all n ≥ 1, sqrt(a) ≤ x_n
            //
            // This gives us the proof of quadratic convergence of the sequence:
            // ε_{n+1} = | x_{n+1} - sqrt(a) |
            //         = | (x_n + a / x_n) / 2 - sqrt(a) |
            //         = | (x_n² + a - 2*x_n*sqrt(a)) / (2 * x_n) |
            //         = | (x_n - sqrt(a))² / (2 * x_n) |
            //         = | ε_n² / (2 * x_n) |
            //         = ε_n² / | (2 * x_n) |
            //
            // For the first iteration, we have a special case where x_0 is known:
            // ε_1 = ε_0² / | (2 * x_0) |
            //     ≤ (2**(e-2))² / (2 * (2**(e-1) + 2**(e-2)))
            //     ≤ 2**(2*e-4) / (3 * 2**(e-1))
            //     ≤ 2**(e-3) / 3
            //     ≤ 2**(e-3-log2(3))
            //     ≤ 2**(e-4.5)
            //
            // For the following iterations, we use the fact that, 2**(e-1) ≤ sqrt(a) ≤ x_n:
            // ε_{n+1} = ε_n² / | (2 * x_n) |
            //         ≤ (2**(e-k))² / (2 * 2**(e-1))
            //         ≤ 2**(2*e-2*k) / 2**e
            //         ≤ 2**(e-2*k)
            xn = (xn + a / xn) >> 1; // ε_1 := | x_1 - sqrt(a) | ≤ 2**(e-4.5)  -- special case, see above
            xn = (xn + a / xn) >> 1; // ε_2 := | x_2 - sqrt(a) | ≤ 2**(e-9)    -- general case with k = 4.5
            xn = (xn + a / xn) >> 1; // ε_3 := | x_3 - sqrt(a) | ≤ 2**(e-18)   -- general case with k = 9
            xn = (xn + a / xn) >> 1; // ε_4 := | x_4 - sqrt(a) | ≤ 2**(e-36)   -- general case with k = 18
            xn = (xn + a / xn) >> 1; // ε_5 := | x_5 - sqrt(a) | ≤ 2**(e-72)   -- general case with k = 36
            xn = (xn + a / xn) >> 1; // ε_6 := | x_6 - sqrt(a) | ≤ 2**(e-144)  -- general case with k = 72

            // Because e ≤ 128 (as discussed during the first estimation phase), we know have reached a precision
            // ε_6 ≤ 2**(e-144) < 1. Given we're operating on integers, then we can ensure that xn is now either
            // sqrt(a) or sqrt(a) + 1.
            return xn - SafeCast.toUint(xn > a / xn);
        }
    }

    /**
     * @dev Calculates sqrt(a), following the selected rounding direction.
     */
    function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = sqrt(a);
            return result + SafeCast.toUint(unsignedRoundsUp(rounding) && result * result < a);
        }
    }

    /**
     * @dev Return the log in base 2 of a positive value rounded towards zero.
     * Returns 0 if given 0.
     */
    function log2(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        uint256 exp;
        unchecked {
            exp = 128 * SafeCast.toUint(value > (1 << 128) - 1);
            value >>= exp;
            result += exp;

            exp = 64 * SafeCast.toUint(value > (1 << 64) - 1);
            value >>= exp;
            result += exp;

            exp = 32 * SafeCast.toUint(value > (1 << 32) - 1);
            value >>= exp;
            result += exp;

            exp = 16 * SafeCast.toUint(value > (1 << 16) - 1);
            value >>= exp;
            result += exp;

            exp = 8 * SafeCast.toUint(value > (1 << 8) - 1);
            value >>= exp;
            result += exp;

            exp = 4 * SafeCast.toUint(value > (1 << 4) - 1);
            value >>= exp;
            result += exp;

            exp = 2 * SafeCast.toUint(value > (1 << 2) - 1);
            value >>= exp;
            result += exp;

            result += SafeCast.toUint(value > 1);
        }
        return result;
    }

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

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

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

    /**
     * @dev Return the log in base 256 of a positive value rounded towards zero.
     * Returns 0 if given 0.
     *
     * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
     */
    function log256(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        uint256 isGt;
        unchecked {
            isGt = SafeCast.toUint(value > (1 << 128) - 1);
            value >>= isGt * 128;
            result += isGt * 16;

            isGt = SafeCast.toUint(value > (1 << 64) - 1);
            value >>= isGt * 64;
            result += isGt * 8;

            isGt = SafeCast.toUint(value > (1 << 32) - 1);
            value >>= isGt * 32;
            result += isGt * 4;

            isGt = SafeCast.toUint(value > (1 << 16) - 1);
            value >>= isGt * 16;
            result += isGt * 2;

            result += SafeCast.toUint(value > (1 << 8) - 1);
        }
        return result;
    }

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

    /**
     * @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers.
     */
    function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {
        return uint8(rounding) % 2 == 1;
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/math/SignedMath.sol)

pragma solidity ^0.8.20;

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

/**
 * @dev Standard signed math utilities missing in the Solidity language.
 */
library SignedMath {
    /**
     * @dev Branchless ternary evaluation for `a ? b : c`. Gas costs are constant.
     *
     * IMPORTANT: This function may reduce bytecode size and consume less gas when used standalone.
     * However, the compiler may optimize Solidity ternary operations (i.e. `a ? b : c`) to only compute
     * one branch when needed, making this function more expensive.
     */
    function ternary(bool condition, int256 a, int256 b) internal pure returns (int256) {
        unchecked {
            // branchless ternary works because:
            // b ^ (a ^ b) == a
            // b ^ 0 == b
            return b ^ ((a ^ b) * int256(SafeCast.toUint(condition)));
        }
    }

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

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

    /**
     * @dev Returns the average of two signed numbers without overflow.
     * The result is rounded towards zero.
     */
    function average(int256 a, int256 b) internal pure returns (int256) {
        // Formula from the book "Hacker's Delight"
        int256 x = (a & b) + ((a ^ b) >> 1);
        return x + (int256(uint256(x) >> 255) & (a ^ b));
    }

    /**
     * @dev Returns the absolute unsigned value of a signed value.
     */
    function abs(int256 n) internal pure returns (uint256) {
        unchecked {
            // Formula from the "Bit Twiddling Hacks" by Sean Eron Anderson.
            // Since `n` is a signed integer, the generated bytecode will use the SAR opcode to perform the right shift,
            // taking advantage of the most significant (or "sign" bit) in two's complement representation.
            // This opcode adds new most significant bits set to the value of the previous most significant bit. As a result,
            // the mask will either be `bytes32(0)` (if n is positive) or `~bytes32(0)` (if n is negative).
            int256 mask = n >> 255;

            // A `bytes32(0)` mask leaves the input unchanged, while a `~bytes32(0)` mask complements it.
            return uint256((n + mask) ^ mask);
        }
    }
}

File 59 of 68 : FixedPoint96.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.4.0;

/// @title FixedPoint96
/// @notice A library for handling binary fixed point numbers, see https://en.wikipedia.org/wiki/Q_(number_format)
/// @dev Used in SqrtPriceMath.sol
library FixedPoint96 {
    uint8 internal constant RESOLUTION = 96;
    uint256 internal constant Q96 = 0x1000000000000000000000000;
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.20;

/**
 * @dev Interface of the ERC-20 standard as defined in the ERC.
 */
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);
}

// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8.0;

import '@openzeppelin/contracts/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;
}

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

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
import {IERC20Permit} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol";

interface IERC20Extended is IERC20, IERC20Metadata, IERC20Permit {
    function mint(address account, uint256 amount) external;

    function burn(uint256 amount) external;

    function transfer(address to, uint256 value) external returns (bool);

    function transferFrom(
        address from,
        address to,
        uint256 value
    ) external returns (bool);

    function burnFrom(address account, uint256 value) external;
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Pausable.sol)

pragma solidity ^0.8.20;

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

/**
 * @dev Contract module which allows children to implement an emergency stop
 * mechanism that can be triggered by an authorized account.
 *
 * This module is used through inheritance. It will make available the
 * modifiers `whenNotPaused` and `whenPaused`, which can be applied to
 * the functions of your contract. Note that they will not be pausable by
 * simply including this module, only once the modifiers are put in place.
 */
abstract contract Pausable is Context {
    bool private _paused;

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

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

    /**
     * @dev The operation failed because the contract is paused.
     */
    error EnforcedPause();

    /**
     * @dev The operation failed because the contract is not paused.
     */
    error ExpectedPause();

    /**
     * @dev Initializes the contract in unpaused state.
     */
    constructor() {
        _paused = false;
    }

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

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

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

    /**
     * @dev Throws if the contract is paused.
     */
    function _requireNotPaused() internal view virtual {
        if (paused()) {
            revert EnforcedPause();
        }
    }

    /**
     * @dev Throws if the contract is not paused.
     */
    function _requirePaused() internal view virtual {
        if (!paused()) {
            revert ExpectedPause();
        }
    }

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

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

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/Panic.sol)

pragma solidity ^0.8.20;

/**
 * @dev Helper library for emitting standardized panic codes.
 *
 * ```solidity
 * contract Example {
 *      using Panic for uint256;
 *
 *      // Use any of the declared internal constants
 *      function foo() { Panic.GENERIC.panic(); }
 *
 *      // Alternatively
 *      function foo() { Panic.panic(Panic.GENERIC); }
 * }
 * ```
 *
 * Follows the list from https://github.com/ethereum/solidity/blob/v0.8.24/libsolutil/ErrorCodes.h[libsolutil].
 *
 * _Available since v5.1._
 */
// slither-disable-next-line unused-state
library Panic {
    /// @dev generic / unspecified error
    uint256 internal constant GENERIC = 0x00;
    /// @dev used by the assert() builtin
    uint256 internal constant ASSERT = 0x01;
    /// @dev arithmetic underflow or overflow
    uint256 internal constant UNDER_OVERFLOW = 0x11;
    /// @dev division or modulo by zero
    uint256 internal constant DIVISION_BY_ZERO = 0x12;
    /// @dev enum conversion error
    uint256 internal constant ENUM_CONVERSION_ERROR = 0x21;
    /// @dev invalid encoding in storage
    uint256 internal constant STORAGE_ENCODING_ERROR = 0x22;
    /// @dev empty array pop
    uint256 internal constant EMPTY_ARRAY_POP = 0x31;
    /// @dev array out of bounds access
    uint256 internal constant ARRAY_OUT_OF_BOUNDS = 0x32;
    /// @dev resource error (too large allocation or too large array)
    uint256 internal constant RESOURCE_ERROR = 0x41;
    /// @dev calling invalid internal function
    uint256 internal constant INVALID_INTERNAL_FUNCTION = 0x51;

    /// @dev Reverts with a panic code. Recommended to use with
    /// the internal constants with predefined codes.
    function panic(uint256 code) internal pure {
        assembly ("memory-safe") {
            mstore(0x00, 0x4e487b71)
            mstore(0x20, code)
            revert(0x1c, 0x24)
        }
    }
}

File 66 of 68 : SafeCast.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.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/bool 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);
    }

    /**
     * @dev Cast a boolean (false or true) to a uint256 (0 or 1) with no jump.
     */
    function toUint(bool b) internal pure returns (uint256 u) {
        assembly ("memory-safe") {
            u := iszero(iszero(b))
        }
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/extensions/IERC20Metadata.sol)

pragma solidity ^0.8.20;

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

/**
 * @dev Interface for the optional metadata functions from the ERC-20 standard.
 */
interface IERC20Metadata is IERC20 {
    /**
     * @dev Returns the name of the token.
     */
    function name() external view returns (string memory);

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

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

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/extensions/IERC20Permit.sol)

pragma solidity ^0.8.20;

/**
 * @dev Interface of the ERC-20 Permit extension allowing approvals to be made via signatures, as defined in
 * https://eips.ethereum.org/EIPS/eip-2612[ERC-2612].
 *
 * Adds the {permit} method, which can be used to change an account's ERC-20 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);
}

Settings
{
  "remappings": [
    "@layerzerolabs/=node_modules/@layerzerolabs/",
    "@layerzerolabs/lz-evm-protocol-v2/=node_modules/@layerzerolabs/lz-evm-protocol-v2/",
    "@openzeppelin-contracts-upgradeable/=dependencies/@openzeppelin-contracts-upgradeable-5.1.0/",
    "@openzeppelin-contracts/contracts/=dependencies/@openzeppelin-contracts-5.1.0/",
    "@openzeppelin/contracts-upgradeable/=dependencies/@openzeppelin-contracts-upgradeable-5.1.0/",
    "@openzeppelin/contracts/=dependencies/@openzeppelin-contracts-5.1.0/",
    "erc4626-tests/=dependencies/erc4626-property-tests-1.0/",
    "forge-std/=dependencies/forge-std-1.9.4/src/",
    "permit2/=lib/permit2/",
    "@openzeppelin-3.4.2/=node_modules/@openzeppelin-3.4.2/",
    "@openzeppelin-contracts-5.1.0/=dependencies/@openzeppelin-contracts-5.1.0/",
    "@openzeppelin-contracts-upgradeable-5.1.0/=dependencies/@openzeppelin-contracts-upgradeable-5.1.0/",
    "@uniswap/=node_modules/@uniswap/",
    "base64-sol/=node_modules/base64-sol/",
    "erc4626-property-tests-1.0/=dependencies/erc4626-property-tests-1.0/",
    "eth-gas-reporter/=node_modules/eth-gas-reporter/",
    "forge-std-1.9.4/=dependencies/forge-std-1.9.4/src/",
    "hardhat/=node_modules/hardhat/",
    "solidity-bytes-utils/=node_modules/solidity-bytes-utils/",
    "solmate/=node_modules/solmate/"
  ],
  "optimizer": {
    "enabled": true,
    "runs": 300
  },
  "metadata": {
    "useLiteralContent": false,
    "bytecodeHash": "ipfs",
    "appendCBOR": true
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "evmVersion": "cancun",
  "viaIR": true
}

Contract Security Audit

Contract ABI

API
[{"inputs":[{"internalType":"address","name":"_deployer","type":"address"},{"internalType":"address","name":"_WETH9","type":"address"},{"internalType":"address","name":"_tokenDescriptor_","type":"address"},{"internalType":"address","name":"_accessHub","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"CheckSlippage","type":"error"},{"inputs":[],"name":"ERC721EnumerableForbiddenBatchMint","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"address","name":"owner","type":"address"}],"name":"ERC721IncorrectOwner","type":"error"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ERC721InsufficientApproval","type":"error"},{"inputs":[{"internalType":"address","name":"approver","type":"address"}],"name":"ERC721InvalidApprover","type":"error"},{"inputs":[{"internalType":"address","name":"operator","type":"address"}],"name":"ERC721InvalidOperator","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"ERC721InvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"}],"name":"ERC721InvalidReceiver","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"}],"name":"ERC721InvalidSender","type":"error"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ERC721NonexistentToken","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"ERC721OutOfBoundsIndex","type":"error"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"InvalidTokenId","type":"error"},{"inputs":[],"name":"NotCleared","type":"error"},{"inputs":[],"name":"Old","type":"error"},{"inputs":[],"name":"Slippage","type":"error"},{"inputs":[],"name":"T","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount0","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount1","type":"uint256"}],"name":"Collect","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint128","name":"liquidity","type":"uint128"},{"indexed":false,"internalType":"uint256","name":"amount0","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount1","type":"uint256"}],"name":"DecreaseLiquidity","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint128","name":"liquidity","type":"uint128"},{"indexed":false,"internalType":"uint256","name":"amount0","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount1","type":"uint256"}],"name":"IncreaseLiquidity","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[],"name":"WETH9","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"burn","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint128","name":"amount0Max","type":"uint128"},{"internalType":"uint128","name":"amount1Max","type":"uint128"}],"internalType":"struct INonfungiblePositionManager.CollectParams","name":"params","type":"tuple"}],"name":"collect","outputs":[{"internalType":"uint256","name":"amount0","type":"uint256"},{"internalType":"uint256","name":"amount1","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"token0","type":"address"},{"internalType":"address","name":"token1","type":"address"},{"internalType":"int24","name":"tickSpacing","type":"int24"},{"internalType":"uint160","name":"sqrtPriceX96","type":"uint160"}],"name":"createAndInitializePoolIfNecessary","outputs":[{"internalType":"address","name":"pool","type":"address"}],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint128","name":"liquidity","type":"uint128"},{"internalType":"uint256","name":"amount0Min","type":"uint256"},{"internalType":"uint256","name":"amount1Min","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"internalType":"struct INonfungiblePositionManager.DecreaseLiquidityParams","name":"params","type":"tuple"}],"name":"decreaseLiquidity","outputs":[{"internalType":"uint256","name":"amount0","type":"uint256"},{"internalType":"uint256","name":"amount1","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"deployer","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"period","type":"uint256"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"address[]","name":"tokens","type":"address[]"},{"internalType":"address","name":"receiver","type":"address"}],"name":"getPeriodReward","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"address[]","name":"tokens","type":"address[]"}],"name":"getReward","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"amount0Desired","type":"uint256"},{"internalType":"uint256","name":"amount1Desired","type":"uint256"},{"internalType":"uint256","name":"amount0Min","type":"uint256"},{"internalType":"uint256","name":"amount1Min","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"internalType":"struct INonfungiblePositionManager.IncreaseLiquidityParams","name":"params","type":"tuple"}],"name":"increaseLiquidity","outputs":[{"internalType":"uint128","name":"liquidity","type":"uint128"},{"internalType":"uint256","name":"amount0","type":"uint256"},{"internalType":"uint256","name":"amount1","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"token0","type":"address"},{"internalType":"address","name":"token1","type":"address"},{"internalType":"int24","name":"tickSpacing","type":"int24"},{"internalType":"int24","name":"tickLower","type":"int24"},{"internalType":"int24","name":"tickUpper","type":"int24"},{"internalType":"uint256","name":"amount0Desired","type":"uint256"},{"internalType":"uint256","name":"amount1Desired","type":"uint256"},{"internalType":"uint256","name":"amount0Min","type":"uint256"},{"internalType":"uint256","name":"amount1Min","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"internalType":"struct INonfungiblePositionManager.MintParams","name":"params","type":"tuple"}],"name":"mint","outputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint128","name":"liquidity","type":"uint128"},{"internalType":"uint256","name":"amount0","type":"uint256"},{"internalType":"uint256","name":"amount1","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"bytes[]","name":"data","type":"bytes[]"}],"name":"multicall","outputs":[{"internalType":"bytes[]","name":"results","type":"bytes[]"}],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"positionLastModified","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"positions","outputs":[{"internalType":"address","name":"token0","type":"address"},{"internalType":"address","name":"token1","type":"address"},{"internalType":"int24","name":"tickSpacing","type":"int24"},{"internalType":"int24","name":"tickLower","type":"int24"},{"internalType":"int24","name":"tickUpper","type":"int24"},{"internalType":"uint128","name":"liquidity","type":"uint128"},{"internalType":"uint256","name":"feeGrowthInside0LastX128","type":"uint256"},{"internalType":"uint256","name":"feeGrowthInside1LastX128","type":"uint256"},{"internalType":"uint128","name":"tokensOwed0","type":"uint128"},{"internalType":"uint128","name":"tokensOwed1","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"refundETH","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IVoter","name":"_voter","type":"address"}],"name":"setVoter","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amountMinimum","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"}],"name":"sweepToken","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenOfOwnerByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount0Owed","type":"uint256"},{"internalType":"uint256","name":"amount1Owed","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"uniswapV3MintCallback","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountMinimum","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"}],"name":"unwrapWETH9","outputs":[],"stateMutability":"payable","type":"function"},{"stateMutability":"payable","type":"receive"}]

610100604052346103f957614b9d6080813803918261001d816103fd565b9384928339810103126103f95761003381610422565b61003f60208301610422565b91610058606061005160408401610422565b9201610422565b9061006360406103fd565b93601f85527f52616d736573205633204e6f6e2046756e6769626c6520506f736974696f6e00602086015261009860406103fd565b600a815269052414d2d56332d4e46560b41b602082015260809490945260a05283516001600160401b03811161030d575f54600181811c911680156103ef575b60208210146102ef57601f811161038d575b50602094601f821160011461032c579481929394955f92610321575b50508160011b915f199060031b1c1916175f555b82516001600160401b03811161030d57600154600181811c91168015610303575b60208210146102ef57601f811161028c575b506020601f821160011461022957819293945f9261021e575b50508160011b915f199060031b1c1916176001555b600d80546001600160e01b03191676010000000000000000000000000000000000000000000117905560c0526001600160a01b031660e052604051614766908161043782396080518181816106420152818161185c01528181611ddc01528181611f7e01528181612fb9015261381f015260a051818181610f120152818161100d0152818161313d0152613e99015260c05181611cf9015260e051816110640152f35b015190505f80610166565b601f1982169060015f52805f20915f5b8181106102745750958360019596971061025c575b505050811b0160015561017b565b01515f1960f88460031b161c191690555f808061024e565b9192602060018192868b015181550194019201610239565b60015f527fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf6601f830160051c810191602084106102e5575b601f0160051c01905b8181106102da575061014d565b5f81556001016102cd565b90915081906102c4565b634e487b7160e01b5f52602260045260245ffd5b90607f169061013b565b634e487b7160e01b5f52604160045260245ffd5b015190505f80610106565b601f198216955f8052805f20915f5b8881106103755750836001959697981061035d575b505050811b015f5561011a565b01515f1960f88460031b161c191690555f8080610350565b9192602060018192868501518155019401920161033b565b5f80527f290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e563601f830160051c810191602084106103e5575b601f0160051c01905b8181106103da57506100ea565b5f81556001016103cd565b90915081906103c4565b90607f16906100d8565b5f80fd5b6040519190601f01601f191682016001600160401b0381118382101761030d57604052565b51906001600160a01b03821682036103f95756fe60806040526004361015610022575b3615610018575f80fd5b610020613133565b005b5f3560e01c806301ffc9a71461024157806306fdde031461023c578063081812fc14610237578063095ea7b3146102325780630c49ccbe1461022d57806312210e8a1461022857806313979cb51461022357806318160ddd1461021e578063219f5d171461021957806323b872dd146102145780632f745c591461020f57806342842e0e1461020a57806342966c681461020557806349404b7c146102005780634aa4a4fc146101fb5780634bc2a657146101f65780634f6ccce7146101f15780636352211e146101ec5780636d70c415146101e757806370a08231146101e257806395d89b41146101dd57806399fbab88146101d85780639da180aa146101d3578063a22cb465146101ce578063ac9650d8146101c9578063b88d4fde146101c4578063c87b56dd146101bf578063d3487997146101ba578063d5f39488146101b5578063df2ab5bb146101b0578063e985e9c5146101ab578063f126fb67146101a6578063f5f8d365146101a15763fc6f78650361000e576122a1565b6121bc565b611f0e565b611e9d565b611e00565b611dbd565b611d5b565b611cb3565b611c23565b611a78565b611959565b6117b3565b6115f9565b611544565b611515565b61125f565b611230565b6111ca565b611031565b610fee565b610eda565b610e0f565b610de6565b610d6c565b610d55565b6109c9565b6109ac565b610979565b61095d565b61056d565b610465565b610417565b610327565b61025c565b6001600160e01b031981160361025857565b5f80fd5b346102585760203660031901126102585760043561027981610246565b63ffffffff60e01b1663780e9d6360e01b81149081156102a2575b506040519015158152602090f35b6380ac58cd60e01b8114915081156102d4575b81156102c3575b505f610294565b6301ffc9a760e01b1490505f6102bc565b635b5e139f60e01b811491506102b5565b5f91031261025857565b805180835260209291819084018484015e5f828201840152601f01601f1916010190565b9060206103249281815201906102ef565b90565b34610258575f366003190112610258576040515f5f548060011c906001811690811561040d575b6020831082146103f95782855260208501919081156103e05750600114610390575b61038c8461038081860382611ba5565b60405191829182610313565b0390f35b5f8080529250907f290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e5635b8184106103cc5750500161038082610370565b8054848401526020909301926001016103b9565b60ff191682525090151560051b01905061038082610370565b634e487b7160e01b5f52602260045260245ffd5b91607f169161034e565b346102585760203660031901126102585760043561043481613196565b505f52600460205260206001600160a01b0360405f205416604051908152f35b6001600160a01b0381160361025857565b346102585760403660031901126102585760043561048281610454565b6024359061048f82613196565b3315158061055a575b8061051a575b6105075782610020936104ea926001600160a01b0380861691167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9255f80a45f52600460205260405f2090565b906001600160a01b03166001600160601b0360a01b825416179055565b63a9fbf51f60e01b5f523360045260245ffd5b5060ff6105523361053c846001600160a01b03165f52600560205260405f2090565b906001600160a01b03165f5260205260405f2090565b54161561049e565b50336001600160a01b0382161415610498565b60a036600319011261025857600435805f52600260205261059d816001600160a01b0360405f20541633906131c9565b608435421161094e576105c16001600160801b036105b96126ec565b161515612710565b6105d3815f52600c60205260405f2090565b8054916105e08360801c90565b916105f86105ec6126ec565b6001600160801b031690565b9261060f6001600160801b03821694851015612710565b61067261066661064061063b65ffffffffffff89165b65ffffffffffff165f52600b60205260405f2090565b612717565b7f00000000000000000000000000000000000000000000000000000000000000006132a1565b6001600160a01b031690565b936001600160a01b03851690604061069a6106908960501c60020b90565b9860681c60020b90565b6106a26126ec565b8251633423a2b560e11b81526004810189905260029a8b0b60248201529190990b60448201526001600160801b039098166064890152876084815f865af19586156108f6575f975f97610915575b506106fb908661344b565b6044358710801561090a575b6108fb5760a06107599261073886546107306107268260501c60020b90565b9160681c60020b90565b908930613598565b90604051808096819463514ea4bf60e01b8352600483019190602083019252565b03915afa9182156108f6575f905f936108bf575b5060018501828154830390610781916135de565b6001600160801b03166001600160801b038a81169190910116600387019081546107b1906001600160801b031690565b016001600160801b031681546001600160801b0319166001600160801b03909116178155600287019384548603906107e8916135de565b81546001600160801b038082169281168c82160116608091821c01901b6001600160801b031916179055555561081c6126ec565b8254910360801b6001600160801b0319166fffffffffffff00000000ffffffffffff909116174260301b69ffffffff00000000000016179055818361085f6126ec565b60405192839261088992846040919493926001600160801b03606083019616825260208201520152565b037f26f6a048ee9138f2c0ce266f322cb99228e8d619ae2bff30c67f8dcf9d2377b491a260408051928352602083019190915290f35b90506108e491925060a03d60a0116108ef575b6108dc8183611ba5565b810190612774565b50509291505f61076d565b503d6108d2565b612769565b630c971c7b60e01b5f5260045ffd5b506064358610610707565b6106fb985061093d91975060403d604011610947575b6109358183611ba5565b810190612753565b97909796906106f0565b503d61092b565b63b8e3f2bf60e01b5f5260045ffd5b5f366003190112610258574761096f57005b610020473361373c565b34610258576020366003190112610258576004355f52600c602052602063ffffffff60405f205460301c16604051908152f35b34610258575f366003190112610258576020600854604051908152f35b60c036600319011261025857600435805f5260026020526109f9816001600160a01b0360405f20541633906131c9565b60a435421161094e5780610a1d6001600160a01b03925f52600c60205260405f2090565b90610b058254610a3861063b6106258365ffffffffffff1690565b80516001600160a01b031691610a666040610a5d60208501516001600160a01b031690565b93015160020b90565b90610a776107268260501c60020b90565b610ae960243591610adf60443594610ac860643597610abe6084355b9a610aae610a9f611bc7565b6001600160a01b03909e168e52565b6001600160a01b031660208d0152565b60020b60408b0152565b3060608a0152608089018b905260020b60a0890152565b60020b60c0870152565b60e08501526101008401526101208301526101408201526137e2565b939195909294610b15858461344b565b60a0610b63825496610b42610b2d8960501c60020b90565b610b3a8a60681c60020b90565b908830613598565b60405195868094819363514ea4bf60e01b8352600483019190602083019252565b0392165afa80156108f65761038c95610c99935f905f93610d02575b50610ba86105ec60018601936001600160801b03610ba1865486039260801c90565b16906135de565b91610bee610bd26003870194610bc586546001600160801b031690565b016001600160801b031690565b84546001600160801b0319166001600160801b03909116178455565b610c416002860193610c21610c176105ec87548903610c116105ec8c5460801c90565b906135de565b825460801c610bc5565b81546001600160801b031660809190911b6001600160801b031916179055565b5555610c75610c5587610bc5845460801c90565b82546001600160801b031660809190911b6001600160801b031916178255565b805469ffffffff00000000000019164260301b69ffffffff00000000000016179055565b604080516001600160801b0386168152602081018790529081018390527f3067048beee31b25b2f1681f88dac838c8bba36af25bfb2b7cf7473a5847e35f90606090a2604051938493846040919493926001600160801b03606083019616825260208201520152565b9050610d1e91925060a03d60a0116108ef576108dc8183611ba5565b50509291505f610b7f565b606090600319011261025857600435610d4181610454565b90602435610d4e81610454565b9060443590565b3461025857610020610d6636610d29565b916127b3565b3461025857604036600319011261025857600435610d8981610454565b6001600160a01b0360243591610d9e81612b1b565b831015610dd057165f52600660205260405f20905f5260205261038c60405f2054604051918291829190602083019252565b63295f44f760e21b5f521660045260245260445ffd5b3461025857610020610df736610d29565b9060405192610e07602085611ba5565b5f8452612e3c565b602036600319011261025857600435805f526002602052610e3f816001600160a01b0360405f20541633906131c9565b805f52600c60205260405f20805460801c1590811591610ec3575b8115610eaa575b50610e9b5780610e96610e7f610020935f52600c60205260405f2090565b60035f918281558260018201558260028201550155565b6139fc565b634950196560e11b5f5260045ffd5b60030154610ebb915060801c6105ec565b15155f610e61565b60038101546001600160801b031615159150610e5a565b604036600319011261025857602435600435610ef582610454565b6040516370a0823160e01b81523060048201526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016929091602083602481875afa9283156108f6575f93610fb9575b50610f5990831015612925565b81610f6057005b823b1561025857604051632e1a7d4d60e01b815260048101839052925f908490602490829084905af19283156108f65761002093610f9f575b5061373c565b80610fad5f610fb393611ba5565b806102e5565b5f610f99565b610f59919350610fe09060203d602011610fe7575b610fd88183611ba5565b810190612916565b9290610f4c565b503d610fce565b34610258575f3660031901126102585760206040516001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168152f35b346102585760203660031901126102585760043561104e81610454565b6040516334cc866d60e21b8152906020826004817f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03165afa80156108f6576001600160a01b036110b29181945f916111ab575b50163314612710565b600e80546001600160a01b0319166001600160a01b038316179055604051638f33b5e560e01b81529116602082600481845afa9081156108f65761111b6020926004945f9161118e575b506001600160a01b03166001600160601b0360a01b600f541617600f55565b604051630448cd8d60e21b815292839182905afa80156108f657610020915f9161115f575b506001600160a01b03166001600160601b0360a01b6010541617601055565b611181915060203d602011611187575b6111798183611ba5565b810190612966565b5f611140565b503d61116f565b6111a59150843d8611611187576111798183611ba5565b5f6110fc565b6111c4915060203d602011611187576111798183611ba5565b5f6110a9565b346102585760203660031901126102585760043560085481101561121a5760085f527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30154604051908152602090f35b63295f44f760e21b5f525f60045260245260445ffd5b3461025857602036600319011261025857602061124e600435613196565b6001600160a01b0360405191168152f35b6101603660031901126102585761014435421161094e576113656001600160b01b03611293600d546001600160b01b031690565b600d805475ffffffffffffffffffffffffffffffffffffffffffff19166001600160b01b03600184018516161790551661130f6112ce61298f565b6112d661299b565b6112de6129b4565b6112e66129c0565b6112ee6129cc565b610ae960a43591610adf60c43594610ac860e43597610abe61010435610a93565b611326856113219795979493946129a7565b613bb6565b60a06001600160a01b0361134361133b6129c0565b6107306129cc565b9216916040518096819263514ea4bf60e01b8352600483019190602083019252565b0381845afa9384156108f65761038c9461146e925f925f926114e9575b506113e09061138f61298f565b906113db61139b61299b565b6113d16113a66129b4565b916113c16113b2611bd9565b6001600160a01b039097168752565b6001600160a01b03166020860152565b60020b6040840152565b613d65565b916114316113ec6129c0565b6114276113f76129cc565b91611411611403611be8565b65ffffffffffff9098168852565b4263ffffffff16602088015260020b6040870152565b60020b6060850152565b6001600160801b038916608084015260a083015260c08201525f60e08201525f610100820152611469865f52600c60205260405f2090565b6129d8565b837f3067048beee31b25b2f1681f88dac838c8bba36af25bfb2b7cf7473a5847e35f604051806114ba86868b846040919493926001600160801b03606083019616825260208201520152565b0390a260405194859485909493926001600160801b036060936080840197845216602083015260408201520152565b6113e0935061150891925060a03d60a0116108ef576108dc8183611ba5565b5050939150929190611382565b3461025857602036600319011261025857602061153c60043561153781610454565b612b1b565b604051908152f35b34610258575f366003190112610258576040515f6001548060011c90600181169081156115ef575b6020831082146103f95782855260208501919081156103e0575060011461159d5761038c8461038081860382611ba5565b60015f9081529250907fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf65b8184106115db5750500161038082610370565b8054848401526020909301926001016115c8565b91607f169161156c565b3461025857602036600319011261025857600435611627611622825f52600c60205260405f2090565b612b4c565b9065ffffffffffff61163f835165ffffffffffff1690565b1615611770575061165c61063b610625835165ffffffffffff1690565b9061038c61167183516001600160a01b031690565b91611694604061168b60208701516001600160a01b031690565b95015160020b90565b906116a3604082015160020b90565b606082015160020b60808301516001600160801b031660a08401519160c0850151936116ee6101006116df60e08901516001600160801b031690565b9701516001600160801b031690565b966040519a8b9a8b98969492909a99979593916101408a019b6001600160a01b03168a526001600160a01b031660208a015260020b604089015260020b606088015260020b60808701526001600160801b031660a086015260c085015260e08401526001600160801b03166101008301526001600160801b0316906101200152565b63ed15e6cf60e01b5f5260045260245ffd5b9181601f840112156102585782359167ffffffffffffffff8311610258576020808501948460051b01011161025857565b60803660031901126102585760243560043560443567ffffffffffffffff8111610258576117e5903690600401611782565b9190606435926117f484610454565b845f526002602052611815856001600160a01b0360405f20541633906131c9565b611827855f52600c60205260405f2090565b546118ac602061184161063b65ffffffffffff8516610625565b611880611859610666600e546001600160a01b031690565b917f00000000000000000000000000000000000000000000000000000000000000006132a1565b6040516302045be960e41b81526001600160a01b03909116600482015292839190829081906024820190565b03915afa80156108f6576001600160a01b03915f91611930575b5016926118e36118d98360501c60020b90565b9260681c60020b90565b91843b15610258575f968793611912926040519a8b998a9889976329b2f63760e01b8952309260048a01612c75565b03925af180156108f65761192257005b80610fad5f61002093611ba5565b611949915060203d602011611187576111798183611ba5565b5f6118c6565b8015150361025857565b346102585760403660031901126102585760043561197681610454565b6024356119828161194f565b6001600160a01b038216918215611a06576119b990335f52600560205260405f20906001600160a01b03165f5260205260405f2090565b60ff1981541660ff831515161790557f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3160405180611a01339482919091602081019215159052565b0390a3005b82630b61174360e31b5f5260045260245ffd5b602081016020825282518091526040820191602060408360051b8301019401925f915b838310611a4b57505050505090565b9091929394602080611a69600193603f1986820301875289516102ef565b97019301930191939290611a3c565b60203660031901126102585760043567ffffffffffffffff811161025857611aa4903690600401611782565b90611aae82612cdc565b915f5b818110611ac6576040518061038c8682611a19565b5f80611ad3838587612d25565b90611ae360405180938193612d6c565b0390305af4611af0612d79565b9015611b165790600191611b048287612e28565b52611b0f8186612e28565b5001611ab1565b604481511061025857611b38816024806004611b509501518301019101612da8565b60405162461bcd60e51b815291829160048301610313565b0390fd5b634e487b7160e01b5f52604160045260245ffd5b6060810190811067ffffffffffffffff821117611b8457604052565b611b54565b6040810190811067ffffffffffffffff821117611b8457604052565b90601f8019910116810190811067ffffffffffffffff821117611b8457604052565b60405190611bd761016083611ba5565b565b60405190611bd7606083611ba5565b60405190611bd761012083611ba5565b60405190611bd7604083611ba5565b67ffffffffffffffff8111611b8457601f01601f191660200190565b3461025857608036600319011261025857600435611c4081610454565b60243590611c4d82610454565b6044356064359267ffffffffffffffff8411610258573660238501121561025857836004013592611c7d84611c07565b93611c8b6040519586611ba5565b8085523660248288010111610258576020815f92602461002099018389013786010152612e3c565b3461025857602036600319011261025857600435611cd081613196565b506040519063e9dc637560e01b825230600483015260248201525f816044816001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000165afa80156108f65761038c915f91611d39575b5060405191829182610313565b611d5591503d805f833e611d4d8183611ba5565b810190612da8565b5f611d2c565b346102585760603660031901126102585760443560243560043567ffffffffffffffff831161025857366023840112156102585782600401359167ffffffffffffffff8311610258573660248486010111610258576024610020940191612f37565b34610258575f3660031901126102585760206040516001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168152f35b606036600319011261025857600435611e1881610454565b602435604435611e2781610454565b6040516370a0823160e01b8152306004820152916020836024816001600160a01b0388165afa9283156108f6575f93611e78575b50611e6890831015613046565b81611e6f57005b61002092613fbb565b611e68919350611e969060203d602011610fe757610fd88183611ba5565b9290611e5b565b3461025857604036600319011261025857602060ff611ef7600435611ec181610454565b6001600160a01b0360243591611ed683610454565b165f526005845260405f20906001600160a01b03165f5260205260405f2090565b54166040519015158152f35b8060020b0361025857565b608036600319011261025857600435611f2681610454565b60243590611f3382610454565b604435611f3f81611f03565b60643592611f4c84610454565b611f696001600160a01b0382166001600160a01b03851610612710565b60405163027ce3dd60e61b81526020816004817f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03165afa80156108f6576001600160a01b03915f9161219d575b506040516328af8d0b60e01b81526001600160a01b03868116600483015284166024820152600285900b604482015291169190602081606481865afa9081156108f6575f9161217e575b506001600160a01b038116806120ae5750506040516308caa96b60e21b81526001600160a01b039485166004820152908416602482015260029290920b604483015292909116606482015290602090829060849082905f905af180156108f65761038c915f9161208f575b505b6040516001600160a01b0390911681529081906020820190565b6120a8915060203d602011611187576111798183611ba5565b5f612073565b935093505050604051633850c7bd60e01b815260e081600481855afa80156108f6576001600160a01b03915f91612149575b5016156120f3575b5061038c9150612075565b803b156102585760405163f637731d60e01b81526001600160a01b039390931660048401525f908390602490829084905af19182156108f65761038c92156120e85780610fad5f61214393611ba5565b5f6120e8565b61216b915060e03d60e011612177575b6121638183611ba5565b810190613096565b5050505050505f6120e0565b503d612159565b612197915060203d602011611187576111798183611ba5565b5f612008565b6121b6915060203d602011611187576111798183611ba5565b5f611fbe565b60403660031901126102585760043560243567ffffffffffffffff8111610258576121eb903690600401611782565b825f93929352600260205261220f826001600160a01b0360405f20541633906131c9565b61223b602061184161063b61062561222f875f52600c60205260405f2090565b5465ffffffffffff1690565b03915afa80156108f6576001600160a01b03915f91612282575b5016803b1561025857611912935f8094604051968795869485936353c2957d60e11b855260048501613103565b61229b915060203d602011611187576111798183611ba5565b5f612255565b608036600319011261025857600435805f5260026020526122d1816001600160a01b0360405f20541633906131c9565b6001600160801b036122e16126f8565b16158015906126c3575b6122f490612710565b612306815f52600c60205260405f2090565b8054909161232461066661064061063b65ffffffffffff8616610625565b600384019384549161234661233f846001600160801b031690565b9360801c90565b92809380966123586105ec8260801c90565b612571575b5050506123686126f8565b6001600160801b038481169116111561256157829586935b612388612704565b6001600160801b03888116911611156125535786925b6001600160a01b036123ae61299b565b166125455730945b546123c48160501c60020b90565b60405163a02f106960e01b81526001600160a01b038881166004830152602482018b9052600292830b604483015260689390931c90910b60648201526001600160801b039a8b16608482015299851660a48b0152168860c4815a6040945f91f19687156108f6575f985f986124fe575b50836124af87946001600160801b03809c9961038c9b9996612493837f40d0efd1a53d60ecbf40971b9daf7dc90178c3aadc7aab1765632738fa8b8f019b6124e299031685906001600160801b0382549181199060801b169116179055565b03166001600160801b03166001600160801b0319825416179055565b604051938493849160409194936001600160801b0380926001600160a01b03606087019816865216602085015216910152565b0390a26040805191851682529290931660208401528291820190565b8697959294969399508691985060403d60401161253e575b6125208183611ba5565b810161252b9161311a565b9690969891949295975098929598612434565b503d612516565b61254d61299b565b946123b6565b61255b612704565b9261239e565b6125696126f8565b958693612380565b9094506125cd91965060406001600160a01b038416916125976107268260501c60020b90565b8251633423a2b560e11b8152600481018a9052600292830b6024820152910b60448201525f606482015292839081906084820190565b03815f855af19182156108f65761260e926126a5575b5060a08454916107386125f98460501c60020b90565b6126068560681c60020b90565b908a30613598565b03915afa9182156108f6575f905f9361267e575b506126736126536001870199610bc56105ec6126428d5487039760801c90565b966001600160801b038816906135de565b96610bc56105ec6002890195610c1187548903916001600160801b031690565b9755555f808061235d565b905061269a91925060a03d60a0116108ef576108dc8183611ba5565b50509291505f612622565b6126bd9060403d604011610947576109358183611ba5565b506125e3565b506122f46126d26105ec612704565b151590506122eb565b6001600160801b0381160361025857565b602435610324816126db565b604435610324816126db565b606435610324816126db565b1561025857565b9060405161272481611b68565b6040600182946001600160a01b03815416845201546001600160a01b038116602084015260a01c60020b910152565b9190826040910312610258576020825192015190565b6040513d5f823e3d90fd5b908160a091031261025857805161278a816126db565b91602082015191604081015191608060608301516127a7816126db565b920151610324816126db565b91906001600160a01b038116928315612903576001600160a01b0391835f5260026020526127ec60405f206001600160a01b0390541690565b90336128f3575b8484831696871580156128c3575b61281c846001600160a01b03165f52600360205260405f2090565b60018154019055612839846104ea855f52600260205260405f2090565b82828a7fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef5f80a4156128ad5761286e8261467c565b870361289d575b5050501680830361288557505050565b6364283d7b60e01b5f5260045260245260445260645ffd5b6128a6916146d8565b5f84612875565b87811461286e576128be82856145f8565b61286e565b6128cc8361406c565b6128e7856001600160a01b03165f52600360205260405f2090565b80545f19019055612801565b6128fe8533846131c9565b6127f3565b633250574960e11b5f525f60045260245ffd5b90816020910312610258575190565b1561292c57565b60405162461bcd60e51b8152602060048201526012602482015271496e73756666696369656e7420574554483960701b6044820152606490fd5b90816020910312610258575161032481610454565b634e487b7160e01b5f52603260045260245ffd5b60043561032481610454565b60243561032481610454565b6101243561032481610454565b60443561032481611f03565b60643561032481611f03565b60843561032481611f03565b90610c216101006003611bd794612a126129f8865165ffffffffffff1690565b825465ffffffffffff191665ffffffffffff909116178255565b612a4c612a26602087015163ffffffff1690565b825469ffffffff000000000000191660309190911b69ffffffff00000000000016178255565b612a7c612a5d604087015160020b90565b829081549060501b62ffffff60501b169062ffffff60501b1916179055565b612aad612a8d606087015160020b90565b825460689190911b62ffffff60681b1662ffffff60681b19909116178255565b612ac4610c5560808701516001600160801b031690565b60a0850151600182015560c085015160028201550192612b0d612af160e08301516001600160801b031690565b85546001600160801b0319166001600160801b03909116178555565b01516001600160801b031690565b6001600160a01b03168015612b39575f52600360205260405f205490565b6322718ad960e21b5f525f60045260245ffd5b9060405161012081019080821067ffffffffffffffff831117611b8457611bd791604052610100612c2460038396612bfa612bea8254612ba0612b948265ffffffffffff1690565b65ffffffffffff168952565b63ffffffff603082901c166020890152612bca612bc08260501c60020b90565b60020b60408a0152565b612be4612bda8260681c60020b90565b60020b60608a0152565b60801c90565b6001600160801b03166080870152565b600181015460a0860152600281015460c086015201546001600160801b03811660e0850152612be4565b6001600160801b0316910152565b916020908281520191905f5b818110612c4b5750505090565b9091926020806001926001600160a01b038735612c6781610454565b168152019401929101612c3e565b9692612ca260c097936001600160a01b0397939288939c9b979c8b5260e060208c015260e08b0191612c32565b99166040880152606087015260020b608086015260020b60a085015216910152565b67ffffffffffffffff8111611b845760051b60200190565b90612ce682612cc4565b612cf36040519182611ba5565b8281528092612d04601f1991612cc4565b01905f5b828110612d1457505050565b806060602080938501015201612d08565b9190811015612d675760051b81013590601e198136030182121561025857019081359167ffffffffffffffff8311610258576020018236038113610258579190565b61297b565b908092918237015f815290565b3d15612da3573d90612d8a82611c07565b91612d986040519384611ba5565b82523d5f602084013e565b606090565b6020818303126102585780519067ffffffffffffffff8211610258570181601f8201121561025857805190612ddc82611c07565b92612dea6040519485611ba5565b8284526020838301011161025857815f9260208093018386015e8301015290565b805115612d675760200190565b805160011015612d675760400190565b8051821015612d675760209160051b010190565b909291612e4a8185846127b3565b833b612e57575b50505050565b602091612e796040519485938493630a85bd0160e11b85523360048601613e2c565b03815f6001600160a01b0387165af15f9181612f06575b50612eca5750612e9e612d79565b8051919082612ec357633250574960e11b5f526001600160a01b03821660045260245ffd5b9050602001fd5b6001600160e01b03191663757a42ff60e11b01612eeb57505f808080612e51565b633250574960e11b5f526001600160a01b031660045260245ffd5b612f2991925060203d602011612f30575b612f218183611ba5565b810190613e17565b905f612e90565b503d612f17565b9291809192810103926080841261025857606060405194612f5786611b89565b1261025857612fdd606060405193612f6e85611b68565b8035612f7981610454565b85526020810135612f8981610454565b60208601526040810135612f9c81611f03565b6040860152848752013592612fb084610454565b602086019384527f0000000000000000000000000000000000000000000000000000000000000000613e5a565b508061301f575b5081612fef57505050565b61301861300a6020611bd7955101516001600160a01b031690565b91516001600160a01b031690565b3391613e8c565b83515161304091906001600160a01b031683516001600160a01b0316613018565b5f612fe4565b1561304d57565b60405162461bcd60e51b815260206004820152601260248201527124b739bab33334b1b4b2b73a103a37b5b2b760711b6044820152606490fd5b519061ffff8216820361025857565b908160e09103126102585780516130ac81610454565b9160208201516130bb81611f03565b916130c860408201613087565b916130d560608301613087565b916130e260808201613087565b9160a082015162ffffff811681036102585760c0909201516103248161194f565b604090610324949281528160208201520191612c32565b919082604091031261025857602082516127a7816126db565b6001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016330361316557565b60405162461bcd60e51b81526020600482015260096024820152684e6f7420574554483960b81b6044820152606490fd5b805f5260026020526001600160a01b0360405f2054169081156131b7575090565b637e27328960e01b5f5260045260245ffd5b9190916131e76001600160a01b038416801515908161322f57501590565b6131f057505050565b6001600160a01b031661320f57637e27328960e01b5f5260045260245ffd5b63177e802f60e01b5f526001600160a01b0390911660045260245260445ffd5b6001600160a01b0384168082149250821561326e575b50811561325157501590565b9050835f5260046020526001600160a01b0360405f205416141590565b9091505f52600560205260ff6132988660405f20906001600160a01b03165f5260205260405f2090565b5416905f613245565b906001600160a01b038151169160208201926001600160a01b0384511611156133ad5761332861339e61032494846133366132fc6040610a5d6132ee6106669a516001600160a01b031690565b95516001600160a01b031690565b604080516001600160a01b0395861660208201908152959094169084015260020b606083015281608081015b03601f198101835282611ba5565b5190206040516001600160f81b03196020820190815260609590951b6bffffffffffffffffffffffff1916602182015260358101919091527f892f127ed4b26ca352056c8fb54585a3268f76f97fdd84d5836ef4bda8d8c68560558201529182906075820190565b5190206001600160a01b031690565b60405162461bcd60e51b815260206004820152600b60248201526a10aa37b5b2b727b93232b960a91b6044820152606490fd5b604051606091906133f18382611ba5565b6002815291601f1901366020840137565b6060602091604081019381526040838201528451809452019201905f5b81811061342c5750505090565b82516001600160a01b031684526020938401939092019160010161341f565b9061345e600e546001600160a01b031690565b906001600160a01b03821661347257505050565b6001600160a01b036020916134906134be946001600160a01b031690565b906040518095819482936302045be960e41b845216600483019190916001600160a01b036020820193169052565b03915afa80156108f6576001600160a01b03915f91613579575b501690816134e4575050565b6134ec6133e0565b613518613501600f546001600160a01b031690565b61350a83612e0b565b906001600160a01b03169052565b61353661352d6010546001600160a01b031690565b61350a83612e18565b823b1561025857613560925f92836040518096819582946353c2957d60e11b845260048401613402565b03925af161356b5750565b80610fad5f611bd793611ba5565b613592915060203d602011611187576111798183611ba5565b5f6134d8565b9290916040519260208401946001600160601b03199060601b168552603484015260e81b605483015260e81b6057820152603a81526135d8605a82611ba5565b51902090565b5f19828209908281029283808410930392808403931461361d57600160801b83101561025857600160801b910990828211900360801b910360801c1790565b50505060801c90565b5f19600160601b8209918160601b918280851094039380850394146136a957600160601b8291613657868411612710565b0981805f03168092046002816003021880820260020302808202600203028082026002030280820260020302808202600203028091026002030293600183805f03040190848311900302920304170290565b5091506136b7821515612710565b0490565b5f1982820990828102928380841093039280840393146136fa5782600160601b111561025857600160601b910990828211900360a01b910360601c1790565b50505060601c90565b90915f19838309928083029283808610950394808603951461372d57908291613657868411612710565b505091506136b7821515612710565b5f9190829160405190613750602083611ba5565b83825260208201915f36843751925af1613768612d79565b501561377057565b60405162461bcd60e51b815260206004820152600360248201526253544560e81b6044820152606490fd5b929360c0946001600160801b03936001600160a01b03610324999894168652602086015260020b604085015260020b60608401521660808201528160a082015201906102ef565b80516001600160a01b03169061381661380560208301516001600160a01b031690565b6113d16113a6604085015160020b90565b613843610666837f00000000000000000000000000000000000000000000000000000000000000006132a1565b604051633850c7bd60e01b81526001600160a01b038216949060e081600481895afa80156108f6576040915f916139d7575b5060a08501966138b761389161388c8a5160020b90565b6140ae565b9260c08801936138a561388c865160020b90565b60e08a0151916101008b015193614428565b975f876139646133286139476138f26138ea60806138df60608801516001600160a01b031690565b960151975160020b90565b985160020b90565b9c6138fb611bf8565b90815233602082015289519283916020830191909160606001600160a01b03602060808401956040815184815116875284848201511684880152015160020b6040860152015116910152565b8c88519c8d9889978896638221b8c160e01b88526004880161379b565b03925af19283156108f6575f945f946139b0575b508385610120830151119182156139a1575b505061399257565b6307dd37f760e41b5f5260045ffd5b61014001511190505f8061398a565b9093506139cd91945060403d604011610947576109358183611ba5565b939093925f613978565b6139f0915060e03d60e011612177576121638183611ba5565b5050505050505f613875565b805f5260026020526001600160a01b0360405f205416801590811580613b86575b613a2f845f52600260205260405f2090565b80546001600160a01b0319169055835f837fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8280a48215613b725750613a748361467c565b6008545f19810190808211613b6d57845f5260096020528060405f2054921015612d675760085f527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee281015490821015612d67577ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee382018190555f908152600960205260409020555f838152600960205260408120556008548015613b59575f19810190600854821015612d675760085f8181527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee29092019190915555506131b75750565b634e487b7160e01b5f52603160045260245ffd5b613cdc565b15613a7457613b8183826145f8565b613a74565b613b8f8461406c565b613baa826001600160a01b03165f52600360205260405f2090565b80545f19019055613a1d565b906001600160a01b038216918215612903575f828152600260205260409020546001600160a01b0316916001600160a01b0383169384159485159586613cac575b613c12856001600160a01b03165f52600360205260405f2090565b60018154019055613c2f856104ea865f52600260205260405f2090565b8383837fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef5f80a415613c9657613c648361467c565b03613c86575b505050613c7357565b6339e3563760e11b5f525f60045260245ffd5b613c8f916146d8565b5f80613c6a565b808214613c6457613ca783866145f8565b613c64565b613cb58461406c565b613cd0866001600160a01b03165f52600360205260405f2090565b80545f19019055613bf7565b634e487b7160e01b5f52601160045260245ffd5b815181546001600160a01b0319166001600160a01b039190911617815560409060010191613d436001600160a01b0360208301511684906001600160a01b03166001600160601b0360a01b825416179055565b0151815460a09190911b62ffffff60a01b1662ffffff60a01b19909116179055565b9190916001600160a01b0381165f52600a60205265ffffffffffff60405f205416928315613d91575050565b909250600d549065ffffffffffff8260b01c169165ffffffffffff8314613b6d5765ffffffffffff60b01b19166001830160b01b65ffffffffffff60b01b1617600d556001600160a01b03939093165f908152600a60205260409020805465ffffffffffff191665ffffffffffff831617905591611bd790613e1284610625565b613cf0565b90816020910312610258575161032481610246565b90926001600160a01b03608093816103249796168452166020830152604082015281606082015201906102ef565b6001600160a01b0391613e6c916132a1565b169081330361025857565b9081602091031261025857516103248161194f565b9290926001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001693846001600160a01b0383161480613fb1575b15613f88575050823b1561025857604051630d0e30db60e41b8152925f8460048185855af19283156108f657613f3894602094613f74575b505f60405180968195829463a9059cbb60e01b845260048401602090939291936001600160a01b0360408201951681520152565b03925af180156108f657613f495750565b613f6a9060203d602011613f6d575b613f628183611ba5565b810190613e77565b50565b503d613f58565b80610fad5f613f8293611ba5565b5f613f04565b9093509091906001600160a01b0381163003613fa85750611bd792613fbb565b611bd7936144c8565b5082471015613ecc565b60405163a9059cbb60e01b602082019081526001600160a01b03909316602482015260448101939093525f928392908390613ff98160648101613328565b51925af1614005612d79565b8161403d575b501561401357565b60405162461bcd60e51b815260206004820152600260248201526114d560f21b6044820152606490fd5b8051801592508215614052575b50505f61400b565b6140659250602080918301019101613e77565b5f8061404a565b61407e905f52600460205260405f2090565b80546001600160a01b0319169055565b801561409a575f190490565b634e487b7160e01b5f52601260045260245ffd5b60020b5f81121561442257805f035b620d89e88111614413576001600160a01b03916001821615614401576001600160881b036ffffcb933bd6fad37aa2d162d1a5940015b1691600281166143e5575b600481166143c9575b600881166143ad575b60108116614391575b60208116614375575b60408116614359575b6080811661433d575b6101008116614321575b6102008116614305575b61040081166142e9575b61080081166142cd575b61100081166142b1575b6120008116614295575b6140008116614279575b618000811661425d575b620100008116614241575b620200008116614226575b62040000811661420b575b62080000166141f2575b5f126141e4575b6141cd6141c38260201c90565b9163ffffffff1690565b6141db5760ff5f5b16011690565b60ff60016141d5565b6141ed9061408e565b6141b6565b6b048a170391f7dc42444e8fa290910260801c906141af565b6d2216e584f5fa1ea926041bedfe9890920260801c916141a5565b916e5d6af8dedb81196699c329225ee6040260801c9161419a565b916f09aa508b5b7a84e1c677de54f3e99bc90260801c9161418f565b916f31be135f97d08fd981231505542fcfa60260801c91614184565b916f70d869a156d2a1b890bb3df62baf32f70260801c9161417a565b916fa9f746462d870fdf8a65dc1f90e061e50260801c91614170565b916fd097f3bdfd2022b8845ad8f792aa58250260801c91614166565b916fe7159475a2c29b7443b29c7fa6e889d90260801c9161415c565b916ff3392b0822b70005940c7a398e4b70f30260801c91614152565b916ff987a7253ac413176f2b074cf7815e540260801c91614148565b916ffcbe86c7900a88aedcffc83b479aa3a40260801c9161413e565b916ffe5dee046a99a2a811c461f1969c30530260801c91614134565b916fff2ea16466c96a3843ec78b326b528610260801c9161412b565b916fff973b41fa98c081472e6896dfb254c00260801c91614122565b916fffcb9843d60f6159c9db58835c9266440260801c91614119565b916fffe5caca7e10e4e61c3624eaa0941cd00260801c91614110565b916ffff2e50f5f656932ef12357cf3c7fdcc0260801c91614107565b916ffff97272373d413259a46990580e213a0260801c916140fe565b6001600160881b03600160801b6140f3565b6315e4079d60e11b5f5260045ffd5b806140bd565b936001600160a01b0383166001600160a01b038316116144c0575b6001600160a01b0385811695908316861161446457505061032493506145af565b92909391946001600160a01b038216115f146144b457829161448a9161449095946145af565b9361457f565b6001600160801b0381166001600160801b038316105f146144af575090565b905090565b9150506103249261457f565b909190614443565b905f80949381946001600160a01b03604051928160208501966323b872dd60e01b885216602485015216604483015260648201526064815261450b608482611ba5565b51925af1614517612d79565b81614550575b501561452557565b60405162461bcd60e51b815260206004820152600360248201526229aa2360e91b6044820152606490fd5b8051801592508215614565575b50505f61451d565b6145789250602080918301019101613e77565b5f8061455d565b916001600160a01b03610324936145a493828116838316116145a9575b031690613626565b61471c565b9061459c565b916145a491610324936001600160a01b0382166001600160a01b038216116145f2575b6001600160a01b03906145e98284168383166136bb565b92031691613703565b906145d2565b5f9161464e9161460781612b1b565b9180855260076020526001600160a01b0360408620549216855260066020526040852091838103614651575b5084526007602052836040812055905f5260205260405f2090565b55565b838652826020526040862054818752836020528060408820558652600760205260408620555f614633565b600854815f5260096020528060405f205568010000000000000000811015611b845760018101600855600854811015612d675760085f527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155565b906146e282612b1b565b5f19810192908311613b6d576001600160a01b03165f52600660205260405f20825f526020528060405f20555f52600760205260405f2055565b906001600160801b0382169182036102585756fea2646970667358221220b9eead389919ad508f1e86ff624e1b64abc02a2bb3aaba3768663606dc793c2364736f6c634300081c0033000000000000000000000000301d2e3c7db5904b3971cf9c36195e37c5a148730000000000000000000000005555555555555555555555555555555555555555000000000000000000000000d9abc43b7b3c8d498f6530f50c692abdc96b173e0000000000000000000000006631a487d59893831b331653225e0bfebf6ea1ec

Deployed Bytecode

0x60806040526004361015610022575b3615610018575f80fd5b610020613133565b005b5f3560e01c806301ffc9a71461024157806306fdde031461023c578063081812fc14610237578063095ea7b3146102325780630c49ccbe1461022d57806312210e8a1461022857806313979cb51461022357806318160ddd1461021e578063219f5d171461021957806323b872dd146102145780632f745c591461020f57806342842e0e1461020a57806342966c681461020557806349404b7c146102005780634aa4a4fc146101fb5780634bc2a657146101f65780634f6ccce7146101f15780636352211e146101ec5780636d70c415146101e757806370a08231146101e257806395d89b41146101dd57806399fbab88146101d85780639da180aa146101d3578063a22cb465146101ce578063ac9650d8146101c9578063b88d4fde146101c4578063c87b56dd146101bf578063d3487997146101ba578063d5f39488146101b5578063df2ab5bb146101b0578063e985e9c5146101ab578063f126fb67146101a6578063f5f8d365146101a15763fc6f78650361000e576122a1565b6121bc565b611f0e565b611e9d565b611e00565b611dbd565b611d5b565b611cb3565b611c23565b611a78565b611959565b6117b3565b6115f9565b611544565b611515565b61125f565b611230565b6111ca565b611031565b610fee565b610eda565b610e0f565b610de6565b610d6c565b610d55565b6109c9565b6109ac565b610979565b61095d565b61056d565b610465565b610417565b610327565b61025c565b6001600160e01b031981160361025857565b5f80fd5b346102585760203660031901126102585760043561027981610246565b63ffffffff60e01b1663780e9d6360e01b81149081156102a2575b506040519015158152602090f35b6380ac58cd60e01b8114915081156102d4575b81156102c3575b505f610294565b6301ffc9a760e01b1490505f6102bc565b635b5e139f60e01b811491506102b5565b5f91031261025857565b805180835260209291819084018484015e5f828201840152601f01601f1916010190565b9060206103249281815201906102ef565b90565b34610258575f366003190112610258576040515f5f548060011c906001811690811561040d575b6020831082146103f95782855260208501919081156103e05750600114610390575b61038c8461038081860382611ba5565b60405191829182610313565b0390f35b5f8080529250907f290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e5635b8184106103cc5750500161038082610370565b8054848401526020909301926001016103b9565b60ff191682525090151560051b01905061038082610370565b634e487b7160e01b5f52602260045260245ffd5b91607f169161034e565b346102585760203660031901126102585760043561043481613196565b505f52600460205260206001600160a01b0360405f205416604051908152f35b6001600160a01b0381160361025857565b346102585760403660031901126102585760043561048281610454565b6024359061048f82613196565b3315158061055a575b8061051a575b6105075782610020936104ea926001600160a01b0380861691167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9255f80a45f52600460205260405f2090565b906001600160a01b03166001600160601b0360a01b825416179055565b63a9fbf51f60e01b5f523360045260245ffd5b5060ff6105523361053c846001600160a01b03165f52600560205260405f2090565b906001600160a01b03165f5260205260405f2090565b54161561049e565b50336001600160a01b0382161415610498565b60a036600319011261025857600435805f52600260205261059d816001600160a01b0360405f20541633906131c9565b608435421161094e576105c16001600160801b036105b96126ec565b161515612710565b6105d3815f52600c60205260405f2090565b8054916105e08360801c90565b916105f86105ec6126ec565b6001600160801b031690565b9261060f6001600160801b03821694851015612710565b61067261066661064061063b65ffffffffffff89165b65ffffffffffff165f52600b60205260405f2090565b612717565b7f000000000000000000000000301d2e3c7db5904b3971cf9c36195e37c5a148736132a1565b6001600160a01b031690565b936001600160a01b03851690604061069a6106908960501c60020b90565b9860681c60020b90565b6106a26126ec565b8251633423a2b560e11b81526004810189905260029a8b0b60248201529190990b60448201526001600160801b039098166064890152876084815f865af19586156108f6575f975f97610915575b506106fb908661344b565b6044358710801561090a575b6108fb5760a06107599261073886546107306107268260501c60020b90565b9160681c60020b90565b908930613598565b90604051808096819463514ea4bf60e01b8352600483019190602083019252565b03915afa9182156108f6575f905f936108bf575b5060018501828154830390610781916135de565b6001600160801b03166001600160801b038a81169190910116600387019081546107b1906001600160801b031690565b016001600160801b031681546001600160801b0319166001600160801b03909116178155600287019384548603906107e8916135de565b81546001600160801b038082169281168c82160116608091821c01901b6001600160801b031916179055555561081c6126ec565b8254910360801b6001600160801b0319166fffffffffffff00000000ffffffffffff909116174260301b69ffffffff00000000000016179055818361085f6126ec565b60405192839261088992846040919493926001600160801b03606083019616825260208201520152565b037f26f6a048ee9138f2c0ce266f322cb99228e8d619ae2bff30c67f8dcf9d2377b491a260408051928352602083019190915290f35b90506108e491925060a03d60a0116108ef575b6108dc8183611ba5565b810190612774565b50509291505f61076d565b503d6108d2565b612769565b630c971c7b60e01b5f5260045ffd5b506064358610610707565b6106fb985061093d91975060403d604011610947575b6109358183611ba5565b810190612753565b97909796906106f0565b503d61092b565b63b8e3f2bf60e01b5f5260045ffd5b5f366003190112610258574761096f57005b610020473361373c565b34610258576020366003190112610258576004355f52600c602052602063ffffffff60405f205460301c16604051908152f35b34610258575f366003190112610258576020600854604051908152f35b60c036600319011261025857600435805f5260026020526109f9816001600160a01b0360405f20541633906131c9565b60a435421161094e5780610a1d6001600160a01b03925f52600c60205260405f2090565b90610b058254610a3861063b6106258365ffffffffffff1690565b80516001600160a01b031691610a666040610a5d60208501516001600160a01b031690565b93015160020b90565b90610a776107268260501c60020b90565b610ae960243591610adf60443594610ac860643597610abe6084355b9a610aae610a9f611bc7565b6001600160a01b03909e168e52565b6001600160a01b031660208d0152565b60020b60408b0152565b3060608a0152608089018b905260020b60a0890152565b60020b60c0870152565b60e08501526101008401526101208301526101408201526137e2565b939195909294610b15858461344b565b60a0610b63825496610b42610b2d8960501c60020b90565b610b3a8a60681c60020b90565b908830613598565b60405195868094819363514ea4bf60e01b8352600483019190602083019252565b0392165afa80156108f65761038c95610c99935f905f93610d02575b50610ba86105ec60018601936001600160801b03610ba1865486039260801c90565b16906135de565b91610bee610bd26003870194610bc586546001600160801b031690565b016001600160801b031690565b84546001600160801b0319166001600160801b03909116178455565b610c416002860193610c21610c176105ec87548903610c116105ec8c5460801c90565b906135de565b825460801c610bc5565b81546001600160801b031660809190911b6001600160801b031916179055565b5555610c75610c5587610bc5845460801c90565b82546001600160801b031660809190911b6001600160801b031916178255565b805469ffffffff00000000000019164260301b69ffffffff00000000000016179055565b604080516001600160801b0386168152602081018790529081018390527f3067048beee31b25b2f1681f88dac838c8bba36af25bfb2b7cf7473a5847e35f90606090a2604051938493846040919493926001600160801b03606083019616825260208201520152565b9050610d1e91925060a03d60a0116108ef576108dc8183611ba5565b50509291505f610b7f565b606090600319011261025857600435610d4181610454565b90602435610d4e81610454565b9060443590565b3461025857610020610d6636610d29565b916127b3565b3461025857604036600319011261025857600435610d8981610454565b6001600160a01b0360243591610d9e81612b1b565b831015610dd057165f52600660205260405f20905f5260205261038c60405f2054604051918291829190602083019252565b63295f44f760e21b5f521660045260245260445ffd5b3461025857610020610df736610d29565b9060405192610e07602085611ba5565b5f8452612e3c565b602036600319011261025857600435805f526002602052610e3f816001600160a01b0360405f20541633906131c9565b805f52600c60205260405f20805460801c1590811591610ec3575b8115610eaa575b50610e9b5780610e96610e7f610020935f52600c60205260405f2090565b60035f918281558260018201558260028201550155565b6139fc565b634950196560e11b5f5260045ffd5b60030154610ebb915060801c6105ec565b15155f610e61565b60038101546001600160801b031615159150610e5a565b604036600319011261025857602435600435610ef582610454565b6040516370a0823160e01b81523060048201526001600160a01b037f000000000000000000000000555555555555555555555555555555555555555516929091602083602481875afa9283156108f6575f93610fb9575b50610f5990831015612925565b81610f6057005b823b1561025857604051632e1a7d4d60e01b815260048101839052925f908490602490829084905af19283156108f65761002093610f9f575b5061373c565b80610fad5f610fb393611ba5565b806102e5565b5f610f99565b610f59919350610fe09060203d602011610fe7575b610fd88183611ba5565b810190612916565b9290610f4c565b503d610fce565b34610258575f3660031901126102585760206040516001600160a01b037f0000000000000000000000005555555555555555555555555555555555555555168152f35b346102585760203660031901126102585760043561104e81610454565b6040516334cc866d60e21b8152906020826004817f0000000000000000000000006631a487d59893831b331653225e0bfebf6ea1ec6001600160a01b03165afa80156108f6576001600160a01b036110b29181945f916111ab575b50163314612710565b600e80546001600160a01b0319166001600160a01b038316179055604051638f33b5e560e01b81529116602082600481845afa9081156108f65761111b6020926004945f9161118e575b506001600160a01b03166001600160601b0360a01b600f541617600f55565b604051630448cd8d60e21b815292839182905afa80156108f657610020915f9161115f575b506001600160a01b03166001600160601b0360a01b6010541617601055565b611181915060203d602011611187575b6111798183611ba5565b810190612966565b5f611140565b503d61116f565b6111a59150843d8611611187576111798183611ba5565b5f6110fc565b6111c4915060203d602011611187576111798183611ba5565b5f6110a9565b346102585760203660031901126102585760043560085481101561121a5760085f527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30154604051908152602090f35b63295f44f760e21b5f525f60045260245260445ffd5b3461025857602036600319011261025857602061124e600435613196565b6001600160a01b0360405191168152f35b6101603660031901126102585761014435421161094e576113656001600160b01b03611293600d546001600160b01b031690565b600d805475ffffffffffffffffffffffffffffffffffffffffffff19166001600160b01b03600184018516161790551661130f6112ce61298f565b6112d661299b565b6112de6129b4565b6112e66129c0565b6112ee6129cc565b610ae960a43591610adf60c43594610ac860e43597610abe61010435610a93565b611326856113219795979493946129a7565b613bb6565b60a06001600160a01b0361134361133b6129c0565b6107306129cc565b9216916040518096819263514ea4bf60e01b8352600483019190602083019252565b0381845afa9384156108f65761038c9461146e925f925f926114e9575b506113e09061138f61298f565b906113db61139b61299b565b6113d16113a66129b4565b916113c16113b2611bd9565b6001600160a01b039097168752565b6001600160a01b03166020860152565b60020b6040840152565b613d65565b916114316113ec6129c0565b6114276113f76129cc565b91611411611403611be8565b65ffffffffffff9098168852565b4263ffffffff16602088015260020b6040870152565b60020b6060850152565b6001600160801b038916608084015260a083015260c08201525f60e08201525f610100820152611469865f52600c60205260405f2090565b6129d8565b837f3067048beee31b25b2f1681f88dac838c8bba36af25bfb2b7cf7473a5847e35f604051806114ba86868b846040919493926001600160801b03606083019616825260208201520152565b0390a260405194859485909493926001600160801b036060936080840197845216602083015260408201520152565b6113e0935061150891925060a03d60a0116108ef576108dc8183611ba5565b5050939150929190611382565b3461025857602036600319011261025857602061153c60043561153781610454565b612b1b565b604051908152f35b34610258575f366003190112610258576040515f6001548060011c90600181169081156115ef575b6020831082146103f95782855260208501919081156103e0575060011461159d5761038c8461038081860382611ba5565b60015f9081529250907fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf65b8184106115db5750500161038082610370565b8054848401526020909301926001016115c8565b91607f169161156c565b3461025857602036600319011261025857600435611627611622825f52600c60205260405f2090565b612b4c565b9065ffffffffffff61163f835165ffffffffffff1690565b1615611770575061165c61063b610625835165ffffffffffff1690565b9061038c61167183516001600160a01b031690565b91611694604061168b60208701516001600160a01b031690565b95015160020b90565b906116a3604082015160020b90565b606082015160020b60808301516001600160801b031660a08401519160c0850151936116ee6101006116df60e08901516001600160801b031690565b9701516001600160801b031690565b966040519a8b9a8b98969492909a99979593916101408a019b6001600160a01b03168a526001600160a01b031660208a015260020b604089015260020b606088015260020b60808701526001600160801b031660a086015260c085015260e08401526001600160801b03166101008301526001600160801b0316906101200152565b63ed15e6cf60e01b5f5260045260245ffd5b9181601f840112156102585782359167ffffffffffffffff8311610258576020808501948460051b01011161025857565b60803660031901126102585760243560043560443567ffffffffffffffff8111610258576117e5903690600401611782565b9190606435926117f484610454565b845f526002602052611815856001600160a01b0360405f20541633906131c9565b611827855f52600c60205260405f2090565b546118ac602061184161063b65ffffffffffff8516610625565b611880611859610666600e546001600160a01b031690565b917f000000000000000000000000301d2e3c7db5904b3971cf9c36195e37c5a148736132a1565b6040516302045be960e41b81526001600160a01b03909116600482015292839190829081906024820190565b03915afa80156108f6576001600160a01b03915f91611930575b5016926118e36118d98360501c60020b90565b9260681c60020b90565b91843b15610258575f968793611912926040519a8b998a9889976329b2f63760e01b8952309260048a01612c75565b03925af180156108f65761192257005b80610fad5f61002093611ba5565b611949915060203d602011611187576111798183611ba5565b5f6118c6565b8015150361025857565b346102585760403660031901126102585760043561197681610454565b6024356119828161194f565b6001600160a01b038216918215611a06576119b990335f52600560205260405f20906001600160a01b03165f5260205260405f2090565b60ff1981541660ff831515161790557f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3160405180611a01339482919091602081019215159052565b0390a3005b82630b61174360e31b5f5260045260245ffd5b602081016020825282518091526040820191602060408360051b8301019401925f915b838310611a4b57505050505090565b9091929394602080611a69600193603f1986820301875289516102ef565b97019301930191939290611a3c565b60203660031901126102585760043567ffffffffffffffff811161025857611aa4903690600401611782565b90611aae82612cdc565b915f5b818110611ac6576040518061038c8682611a19565b5f80611ad3838587612d25565b90611ae360405180938193612d6c565b0390305af4611af0612d79565b9015611b165790600191611b048287612e28565b52611b0f8186612e28565b5001611ab1565b604481511061025857611b38816024806004611b509501518301019101612da8565b60405162461bcd60e51b815291829160048301610313565b0390fd5b634e487b7160e01b5f52604160045260245ffd5b6060810190811067ffffffffffffffff821117611b8457604052565b611b54565b6040810190811067ffffffffffffffff821117611b8457604052565b90601f8019910116810190811067ffffffffffffffff821117611b8457604052565b60405190611bd761016083611ba5565b565b60405190611bd7606083611ba5565b60405190611bd761012083611ba5565b60405190611bd7604083611ba5565b67ffffffffffffffff8111611b8457601f01601f191660200190565b3461025857608036600319011261025857600435611c4081610454565b60243590611c4d82610454565b6044356064359267ffffffffffffffff8411610258573660238501121561025857836004013592611c7d84611c07565b93611c8b6040519586611ba5565b8085523660248288010111610258576020815f92602461002099018389013786010152612e3c565b3461025857602036600319011261025857600435611cd081613196565b506040519063e9dc637560e01b825230600483015260248201525f816044816001600160a01b037f000000000000000000000000d9abc43b7b3c8d498f6530f50c692abdc96b173e165afa80156108f65761038c915f91611d39575b5060405191829182610313565b611d5591503d805f833e611d4d8183611ba5565b810190612da8565b5f611d2c565b346102585760603660031901126102585760443560243560043567ffffffffffffffff831161025857366023840112156102585782600401359167ffffffffffffffff8311610258573660248486010111610258576024610020940191612f37565b34610258575f3660031901126102585760206040516001600160a01b037f000000000000000000000000301d2e3c7db5904b3971cf9c36195e37c5a14873168152f35b606036600319011261025857600435611e1881610454565b602435604435611e2781610454565b6040516370a0823160e01b8152306004820152916020836024816001600160a01b0388165afa9283156108f6575f93611e78575b50611e6890831015613046565b81611e6f57005b61002092613fbb565b611e68919350611e969060203d602011610fe757610fd88183611ba5565b9290611e5b565b3461025857604036600319011261025857602060ff611ef7600435611ec181610454565b6001600160a01b0360243591611ed683610454565b165f526005845260405f20906001600160a01b03165f5260205260405f2090565b54166040519015158152f35b8060020b0361025857565b608036600319011261025857600435611f2681610454565b60243590611f3382610454565b604435611f3f81611f03565b60643592611f4c84610454565b611f696001600160a01b0382166001600160a01b03851610612710565b60405163027ce3dd60e61b81526020816004817f000000000000000000000000301d2e3c7db5904b3971cf9c36195e37c5a148736001600160a01b03165afa80156108f6576001600160a01b03915f9161219d575b506040516328af8d0b60e01b81526001600160a01b03868116600483015284166024820152600285900b604482015291169190602081606481865afa9081156108f6575f9161217e575b506001600160a01b038116806120ae5750506040516308caa96b60e21b81526001600160a01b039485166004820152908416602482015260029290920b604483015292909116606482015290602090829060849082905f905af180156108f65761038c915f9161208f575b505b6040516001600160a01b0390911681529081906020820190565b6120a8915060203d602011611187576111798183611ba5565b5f612073565b935093505050604051633850c7bd60e01b815260e081600481855afa80156108f6576001600160a01b03915f91612149575b5016156120f3575b5061038c9150612075565b803b156102585760405163f637731d60e01b81526001600160a01b039390931660048401525f908390602490829084905af19182156108f65761038c92156120e85780610fad5f61214393611ba5565b5f6120e8565b61216b915060e03d60e011612177575b6121638183611ba5565b810190613096565b5050505050505f6120e0565b503d612159565b612197915060203d602011611187576111798183611ba5565b5f612008565b6121b6915060203d602011611187576111798183611ba5565b5f611fbe565b60403660031901126102585760043560243567ffffffffffffffff8111610258576121eb903690600401611782565b825f93929352600260205261220f826001600160a01b0360405f20541633906131c9565b61223b602061184161063b61062561222f875f52600c60205260405f2090565b5465ffffffffffff1690565b03915afa80156108f6576001600160a01b03915f91612282575b5016803b1561025857611912935f8094604051968795869485936353c2957d60e11b855260048501613103565b61229b915060203d602011611187576111798183611ba5565b5f612255565b608036600319011261025857600435805f5260026020526122d1816001600160a01b0360405f20541633906131c9565b6001600160801b036122e16126f8565b16158015906126c3575b6122f490612710565b612306815f52600c60205260405f2090565b8054909161232461066661064061063b65ffffffffffff8616610625565b600384019384549161234661233f846001600160801b031690565b9360801c90565b92809380966123586105ec8260801c90565b612571575b5050506123686126f8565b6001600160801b038481169116111561256157829586935b612388612704565b6001600160801b03888116911611156125535786925b6001600160a01b036123ae61299b565b166125455730945b546123c48160501c60020b90565b60405163a02f106960e01b81526001600160a01b038881166004830152602482018b9052600292830b604483015260689390931c90910b60648201526001600160801b039a8b16608482015299851660a48b0152168860c4815a6040945f91f19687156108f6575f985f986124fe575b50836124af87946001600160801b03809c9961038c9b9996612493837f40d0efd1a53d60ecbf40971b9daf7dc90178c3aadc7aab1765632738fa8b8f019b6124e299031685906001600160801b0382549181199060801b169116179055565b03166001600160801b03166001600160801b0319825416179055565b604051938493849160409194936001600160801b0380926001600160a01b03606087019816865216602085015216910152565b0390a26040805191851682529290931660208401528291820190565b8697959294969399508691985060403d60401161253e575b6125208183611ba5565b810161252b9161311a565b9690969891949295975098929598612434565b503d612516565b61254d61299b565b946123b6565b61255b612704565b9261239e565b6125696126f8565b958693612380565b9094506125cd91965060406001600160a01b038416916125976107268260501c60020b90565b8251633423a2b560e11b8152600481018a9052600292830b6024820152910b60448201525f606482015292839081906084820190565b03815f855af19182156108f65761260e926126a5575b5060a08454916107386125f98460501c60020b90565b6126068560681c60020b90565b908a30613598565b03915afa9182156108f6575f905f9361267e575b506126736126536001870199610bc56105ec6126428d5487039760801c90565b966001600160801b038816906135de565b96610bc56105ec6002890195610c1187548903916001600160801b031690565b9755555f808061235d565b905061269a91925060a03d60a0116108ef576108dc8183611ba5565b50509291505f612622565b6126bd9060403d604011610947576109358183611ba5565b506125e3565b506122f46126d26105ec612704565b151590506122eb565b6001600160801b0381160361025857565b602435610324816126db565b604435610324816126db565b606435610324816126db565b1561025857565b9060405161272481611b68565b6040600182946001600160a01b03815416845201546001600160a01b038116602084015260a01c60020b910152565b9190826040910312610258576020825192015190565b6040513d5f823e3d90fd5b908160a091031261025857805161278a816126db565b91602082015191604081015191608060608301516127a7816126db565b920151610324816126db565b91906001600160a01b038116928315612903576001600160a01b0391835f5260026020526127ec60405f206001600160a01b0390541690565b90336128f3575b8484831696871580156128c3575b61281c846001600160a01b03165f52600360205260405f2090565b60018154019055612839846104ea855f52600260205260405f2090565b82828a7fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef5f80a4156128ad5761286e8261467c565b870361289d575b5050501680830361288557505050565b6364283d7b60e01b5f5260045260245260445260645ffd5b6128a6916146d8565b5f84612875565b87811461286e576128be82856145f8565b61286e565b6128cc8361406c565b6128e7856001600160a01b03165f52600360205260405f2090565b80545f19019055612801565b6128fe8533846131c9565b6127f3565b633250574960e11b5f525f60045260245ffd5b90816020910312610258575190565b1561292c57565b60405162461bcd60e51b8152602060048201526012602482015271496e73756666696369656e7420574554483960701b6044820152606490fd5b90816020910312610258575161032481610454565b634e487b7160e01b5f52603260045260245ffd5b60043561032481610454565b60243561032481610454565b6101243561032481610454565b60443561032481611f03565b60643561032481611f03565b60843561032481611f03565b90610c216101006003611bd794612a126129f8865165ffffffffffff1690565b825465ffffffffffff191665ffffffffffff909116178255565b612a4c612a26602087015163ffffffff1690565b825469ffffffff000000000000191660309190911b69ffffffff00000000000016178255565b612a7c612a5d604087015160020b90565b829081549060501b62ffffff60501b169062ffffff60501b1916179055565b612aad612a8d606087015160020b90565b825460689190911b62ffffff60681b1662ffffff60681b19909116178255565b612ac4610c5560808701516001600160801b031690565b60a0850151600182015560c085015160028201550192612b0d612af160e08301516001600160801b031690565b85546001600160801b0319166001600160801b03909116178555565b01516001600160801b031690565b6001600160a01b03168015612b39575f52600360205260405f205490565b6322718ad960e21b5f525f60045260245ffd5b9060405161012081019080821067ffffffffffffffff831117611b8457611bd791604052610100612c2460038396612bfa612bea8254612ba0612b948265ffffffffffff1690565b65ffffffffffff168952565b63ffffffff603082901c166020890152612bca612bc08260501c60020b90565b60020b60408a0152565b612be4612bda8260681c60020b90565b60020b60608a0152565b60801c90565b6001600160801b03166080870152565b600181015460a0860152600281015460c086015201546001600160801b03811660e0850152612be4565b6001600160801b0316910152565b916020908281520191905f5b818110612c4b5750505090565b9091926020806001926001600160a01b038735612c6781610454565b168152019401929101612c3e565b9692612ca260c097936001600160a01b0397939288939c9b979c8b5260e060208c015260e08b0191612c32565b99166040880152606087015260020b608086015260020b60a085015216910152565b67ffffffffffffffff8111611b845760051b60200190565b90612ce682612cc4565b612cf36040519182611ba5565b8281528092612d04601f1991612cc4565b01905f5b828110612d1457505050565b806060602080938501015201612d08565b9190811015612d675760051b81013590601e198136030182121561025857019081359167ffffffffffffffff8311610258576020018236038113610258579190565b61297b565b908092918237015f815290565b3d15612da3573d90612d8a82611c07565b91612d986040519384611ba5565b82523d5f602084013e565b606090565b6020818303126102585780519067ffffffffffffffff8211610258570181601f8201121561025857805190612ddc82611c07565b92612dea6040519485611ba5565b8284526020838301011161025857815f9260208093018386015e8301015290565b805115612d675760200190565b805160011015612d675760400190565b8051821015612d675760209160051b010190565b909291612e4a8185846127b3565b833b612e57575b50505050565b602091612e796040519485938493630a85bd0160e11b85523360048601613e2c565b03815f6001600160a01b0387165af15f9181612f06575b50612eca5750612e9e612d79565b8051919082612ec357633250574960e11b5f526001600160a01b03821660045260245ffd5b9050602001fd5b6001600160e01b03191663757a42ff60e11b01612eeb57505f808080612e51565b633250574960e11b5f526001600160a01b031660045260245ffd5b612f2991925060203d602011612f30575b612f218183611ba5565b810190613e17565b905f612e90565b503d612f17565b9291809192810103926080841261025857606060405194612f5786611b89565b1261025857612fdd606060405193612f6e85611b68565b8035612f7981610454565b85526020810135612f8981610454565b60208601526040810135612f9c81611f03565b6040860152848752013592612fb084610454565b602086019384527f000000000000000000000000301d2e3c7db5904b3971cf9c36195e37c5a14873613e5a565b508061301f575b5081612fef57505050565b61301861300a6020611bd7955101516001600160a01b031690565b91516001600160a01b031690565b3391613e8c565b83515161304091906001600160a01b031683516001600160a01b0316613018565b5f612fe4565b1561304d57565b60405162461bcd60e51b815260206004820152601260248201527124b739bab33334b1b4b2b73a103a37b5b2b760711b6044820152606490fd5b519061ffff8216820361025857565b908160e09103126102585780516130ac81610454565b9160208201516130bb81611f03565b916130c860408201613087565b916130d560608301613087565b916130e260808201613087565b9160a082015162ffffff811681036102585760c0909201516103248161194f565b604090610324949281528160208201520191612c32565b919082604091031261025857602082516127a7816126db565b6001600160a01b037f000000000000000000000000555555555555555555555555555555555555555516330361316557565b60405162461bcd60e51b81526020600482015260096024820152684e6f7420574554483960b81b6044820152606490fd5b805f5260026020526001600160a01b0360405f2054169081156131b7575090565b637e27328960e01b5f5260045260245ffd5b9190916131e76001600160a01b038416801515908161322f57501590565b6131f057505050565b6001600160a01b031661320f57637e27328960e01b5f5260045260245ffd5b63177e802f60e01b5f526001600160a01b0390911660045260245260445ffd5b6001600160a01b0384168082149250821561326e575b50811561325157501590565b9050835f5260046020526001600160a01b0360405f205416141590565b9091505f52600560205260ff6132988660405f20906001600160a01b03165f5260205260405f2090565b5416905f613245565b906001600160a01b038151169160208201926001600160a01b0384511611156133ad5761332861339e61032494846133366132fc6040610a5d6132ee6106669a516001600160a01b031690565b95516001600160a01b031690565b604080516001600160a01b0395861660208201908152959094169084015260020b606083015281608081015b03601f198101835282611ba5565b5190206040516001600160f81b03196020820190815260609590951b6bffffffffffffffffffffffff1916602182015260358101919091527f892f127ed4b26ca352056c8fb54585a3268f76f97fdd84d5836ef4bda8d8c68560558201529182906075820190565b5190206001600160a01b031690565b60405162461bcd60e51b815260206004820152600b60248201526a10aa37b5b2b727b93232b960a91b6044820152606490fd5b604051606091906133f18382611ba5565b6002815291601f1901366020840137565b6060602091604081019381526040838201528451809452019201905f5b81811061342c5750505090565b82516001600160a01b031684526020938401939092019160010161341f565b9061345e600e546001600160a01b031690565b906001600160a01b03821661347257505050565b6001600160a01b036020916134906134be946001600160a01b031690565b906040518095819482936302045be960e41b845216600483019190916001600160a01b036020820193169052565b03915afa80156108f6576001600160a01b03915f91613579575b501690816134e4575050565b6134ec6133e0565b613518613501600f546001600160a01b031690565b61350a83612e0b565b906001600160a01b03169052565b61353661352d6010546001600160a01b031690565b61350a83612e18565b823b1561025857613560925f92836040518096819582946353c2957d60e11b845260048401613402565b03925af161356b5750565b80610fad5f611bd793611ba5565b613592915060203d602011611187576111798183611ba5565b5f6134d8565b9290916040519260208401946001600160601b03199060601b168552603484015260e81b605483015260e81b6057820152603a81526135d8605a82611ba5565b51902090565b5f19828209908281029283808410930392808403931461361d57600160801b83101561025857600160801b910990828211900360801b910360801c1790565b50505060801c90565b5f19600160601b8209918160601b918280851094039380850394146136a957600160601b8291613657868411612710565b0981805f03168092046002816003021880820260020302808202600203028082026002030280820260020302808202600203028091026002030293600183805f03040190848311900302920304170290565b5091506136b7821515612710565b0490565b5f1982820990828102928380841093039280840393146136fa5782600160601b111561025857600160601b910990828211900360a01b910360601c1790565b50505060601c90565b90915f19838309928083029283808610950394808603951461372d57908291613657868411612710565b505091506136b7821515612710565b5f9190829160405190613750602083611ba5565b83825260208201915f36843751925af1613768612d79565b501561377057565b60405162461bcd60e51b815260206004820152600360248201526253544560e81b6044820152606490fd5b929360c0946001600160801b03936001600160a01b03610324999894168652602086015260020b604085015260020b60608401521660808201528160a082015201906102ef565b80516001600160a01b03169061381661380560208301516001600160a01b031690565b6113d16113a6604085015160020b90565b613843610666837f000000000000000000000000301d2e3c7db5904b3971cf9c36195e37c5a148736132a1565b604051633850c7bd60e01b81526001600160a01b038216949060e081600481895afa80156108f6576040915f916139d7575b5060a08501966138b761389161388c8a5160020b90565b6140ae565b9260c08801936138a561388c865160020b90565b60e08a0151916101008b015193614428565b975f876139646133286139476138f26138ea60806138df60608801516001600160a01b031690565b960151975160020b90565b985160020b90565b9c6138fb611bf8565b90815233602082015289519283916020830191909160606001600160a01b03602060808401956040815184815116875284848201511684880152015160020b6040860152015116910152565b8c88519c8d9889978896638221b8c160e01b88526004880161379b565b03925af19283156108f6575f945f946139b0575b508385610120830151119182156139a1575b505061399257565b6307dd37f760e41b5f5260045ffd5b61014001511190505f8061398a565b9093506139cd91945060403d604011610947576109358183611ba5565b939093925f613978565b6139f0915060e03d60e011612177576121638183611ba5565b5050505050505f613875565b805f5260026020526001600160a01b0360405f205416801590811580613b86575b613a2f845f52600260205260405f2090565b80546001600160a01b0319169055835f837fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8280a48215613b725750613a748361467c565b6008545f19810190808211613b6d57845f5260096020528060405f2054921015612d675760085f527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee281015490821015612d67577ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee382018190555f908152600960205260409020555f838152600960205260408120556008548015613b59575f19810190600854821015612d675760085f8181527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee29092019190915555506131b75750565b634e487b7160e01b5f52603160045260245ffd5b613cdc565b15613a7457613b8183826145f8565b613a74565b613b8f8461406c565b613baa826001600160a01b03165f52600360205260405f2090565b80545f19019055613a1d565b906001600160a01b038216918215612903575f828152600260205260409020546001600160a01b0316916001600160a01b0383169384159485159586613cac575b613c12856001600160a01b03165f52600360205260405f2090565b60018154019055613c2f856104ea865f52600260205260405f2090565b8383837fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef5f80a415613c9657613c648361467c565b03613c86575b505050613c7357565b6339e3563760e11b5f525f60045260245ffd5b613c8f916146d8565b5f80613c6a565b808214613c6457613ca783866145f8565b613c64565b613cb58461406c565b613cd0866001600160a01b03165f52600360205260405f2090565b80545f19019055613bf7565b634e487b7160e01b5f52601160045260245ffd5b815181546001600160a01b0319166001600160a01b039190911617815560409060010191613d436001600160a01b0360208301511684906001600160a01b03166001600160601b0360a01b825416179055565b0151815460a09190911b62ffffff60a01b1662ffffff60a01b19909116179055565b9190916001600160a01b0381165f52600a60205265ffffffffffff60405f205416928315613d91575050565b909250600d549065ffffffffffff8260b01c169165ffffffffffff8314613b6d5765ffffffffffff60b01b19166001830160b01b65ffffffffffff60b01b1617600d556001600160a01b03939093165f908152600a60205260409020805465ffffffffffff191665ffffffffffff831617905591611bd790613e1284610625565b613cf0565b90816020910312610258575161032481610246565b90926001600160a01b03608093816103249796168452166020830152604082015281606082015201906102ef565b6001600160a01b0391613e6c916132a1565b169081330361025857565b9081602091031261025857516103248161194f565b9290926001600160a01b037f00000000000000000000000055555555555555555555555555555555555555551693846001600160a01b0383161480613fb1575b15613f88575050823b1561025857604051630d0e30db60e41b8152925f8460048185855af19283156108f657613f3894602094613f74575b505f60405180968195829463a9059cbb60e01b845260048401602090939291936001600160a01b0360408201951681520152565b03925af180156108f657613f495750565b613f6a9060203d602011613f6d575b613f628183611ba5565b810190613e77565b50565b503d613f58565b80610fad5f613f8293611ba5565b5f613f04565b9093509091906001600160a01b0381163003613fa85750611bd792613fbb565b611bd7936144c8565b5082471015613ecc565b60405163a9059cbb60e01b602082019081526001600160a01b03909316602482015260448101939093525f928392908390613ff98160648101613328565b51925af1614005612d79565b8161403d575b501561401357565b60405162461bcd60e51b815260206004820152600260248201526114d560f21b6044820152606490fd5b8051801592508215614052575b50505f61400b565b6140659250602080918301019101613e77565b5f8061404a565b61407e905f52600460205260405f2090565b80546001600160a01b0319169055565b801561409a575f190490565b634e487b7160e01b5f52601260045260245ffd5b60020b5f81121561442257805f035b620d89e88111614413576001600160a01b03916001821615614401576001600160881b036ffffcb933bd6fad37aa2d162d1a5940015b1691600281166143e5575b600481166143c9575b600881166143ad575b60108116614391575b60208116614375575b60408116614359575b6080811661433d575b6101008116614321575b6102008116614305575b61040081166142e9575b61080081166142cd575b61100081166142b1575b6120008116614295575b6140008116614279575b618000811661425d575b620100008116614241575b620200008116614226575b62040000811661420b575b62080000166141f2575b5f126141e4575b6141cd6141c38260201c90565b9163ffffffff1690565b6141db5760ff5f5b16011690565b60ff60016141d5565b6141ed9061408e565b6141b6565b6b048a170391f7dc42444e8fa290910260801c906141af565b6d2216e584f5fa1ea926041bedfe9890920260801c916141a5565b916e5d6af8dedb81196699c329225ee6040260801c9161419a565b916f09aa508b5b7a84e1c677de54f3e99bc90260801c9161418f565b916f31be135f97d08fd981231505542fcfa60260801c91614184565b916f70d869a156d2a1b890bb3df62baf32f70260801c9161417a565b916fa9f746462d870fdf8a65dc1f90e061e50260801c91614170565b916fd097f3bdfd2022b8845ad8f792aa58250260801c91614166565b916fe7159475a2c29b7443b29c7fa6e889d90260801c9161415c565b916ff3392b0822b70005940c7a398e4b70f30260801c91614152565b916ff987a7253ac413176f2b074cf7815e540260801c91614148565b916ffcbe86c7900a88aedcffc83b479aa3a40260801c9161413e565b916ffe5dee046a99a2a811c461f1969c30530260801c91614134565b916fff2ea16466c96a3843ec78b326b528610260801c9161412b565b916fff973b41fa98c081472e6896dfb254c00260801c91614122565b916fffcb9843d60f6159c9db58835c9266440260801c91614119565b916fffe5caca7e10e4e61c3624eaa0941cd00260801c91614110565b916ffff2e50f5f656932ef12357cf3c7fdcc0260801c91614107565b916ffff97272373d413259a46990580e213a0260801c916140fe565b6001600160881b03600160801b6140f3565b6315e4079d60e11b5f5260045ffd5b806140bd565b936001600160a01b0383166001600160a01b038316116144c0575b6001600160a01b0385811695908316861161446457505061032493506145af565b92909391946001600160a01b038216115f146144b457829161448a9161449095946145af565b9361457f565b6001600160801b0381166001600160801b038316105f146144af575090565b905090565b9150506103249261457f565b909190614443565b905f80949381946001600160a01b03604051928160208501966323b872dd60e01b885216602485015216604483015260648201526064815261450b608482611ba5565b51925af1614517612d79565b81614550575b501561452557565b60405162461bcd60e51b815260206004820152600360248201526229aa2360e91b6044820152606490fd5b8051801592508215614565575b50505f61451d565b6145789250602080918301019101613e77565b5f8061455d565b916001600160a01b03610324936145a493828116838316116145a9575b031690613626565b61471c565b9061459c565b916145a491610324936001600160a01b0382166001600160a01b038216116145f2575b6001600160a01b03906145e98284168383166136bb565b92031691613703565b906145d2565b5f9161464e9161460781612b1b565b9180855260076020526001600160a01b0360408620549216855260066020526040852091838103614651575b5084526007602052836040812055905f5260205260405f2090565b55565b838652826020526040862054818752836020528060408820558652600760205260408620555f614633565b600854815f5260096020528060405f205568010000000000000000811015611b845760018101600855600854811015612d675760085f527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155565b906146e282612b1b565b5f19810192908311613b6d576001600160a01b03165f52600660205260405f20825f526020528060405f20555f52600760205260405f2055565b906001600160801b0382169182036102585756fea2646970667358221220b9eead389919ad508f1e86ff624e1b64abc02a2bb3aaba3768663606dc793c2364736f6c634300081c0033

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

000000000000000000000000301d2e3c7db5904b3971cf9c36195e37c5a148730000000000000000000000005555555555555555555555555555555555555555000000000000000000000000d9abc43b7b3c8d498f6530f50c692abdc96b173e0000000000000000000000006631a487d59893831b331653225e0bfebf6ea1ec

-----Decoded View---------------
Arg [0] : _deployer (address): 0x301d2E3c7Db5904b3971cf9C36195e37c5a14873
Arg [1] : _WETH9 (address): 0x5555555555555555555555555555555555555555
Arg [2] : _tokenDescriptor_ (address): 0xD9aBc43B7b3c8D498F6530F50C692ABDc96b173e
Arg [3] : _accessHub (address): 0x6631a487d59893831b331653225E0bfeBf6Ea1EC

-----Encoded View---------------
4 Constructor Arguments found :
Arg [0] : 000000000000000000000000301d2e3c7db5904b3971cf9c36195e37c5a14873
Arg [1] : 0000000000000000000000005555555555555555555555555555555555555555
Arg [2] : 000000000000000000000000d9abc43b7b3c8d498f6530f50c692abdc96b173e
Arg [3] : 0000000000000000000000006631a487d59893831b331653225e0bfebf6ea1ec


Block Transaction Gas Used Reward
view all blocks ##produced##

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
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.