ETH Price: $3,232.52 (-0.68%)
Gas: 1 Gwei

Contract

0x8A09062CFb5e3dc1EA9130b755E447B9078CFFDB
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To

There are no matching entries

Please try again later

Latest 1 internal transaction

Advanced mode:
Parent Transaction Hash Block From To
170323722023-04-12 13:58:59472 days ago1681307939  Contract Creation0 ETH
Loading...
Loading

Similar Match Source Code
This contract matches the deployed Bytecode of the Source Code for Contract 0x55b7736b...4DD9f9c33
The constructor portion of the code might be different and could alter the actual behaviour of the contract

Contract Name:
PancakeV3LmPool

Compiler Version
v0.7.6+commit.7338295f

Optimization Enabled:
Yes with 1000000 runs

Other Settings:
default evmVersion
File 1 of 19 : PancakeV3LmPool.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity =0.7.6;

import '@pancakeswap/v3-core/contracts/libraries/LowGasSafeMath.sol';
import '@pancakeswap/v3-core/contracts/libraries/SafeCast.sol';
import '@pancakeswap/v3-core/contracts/libraries/FullMath.sol';
import '@pancakeswap/v3-core/contracts/libraries/FixedPoint128.sol';
import '@pancakeswap/v3-core/contracts/interfaces/IPancakeV3Pool.sol';

import './libraries/LmTick.sol';

import './interfaces/IPancakeV3LmPool.sol';
import './interfaces/ILMPool.sol';
import './interfaces/IMasterChefV3.sol';
import './interfaces/IPancakeV3LmPoolDeveloper.sol';

contract PancakeV3LmPool is IPancakeV3LmPool {
    using LowGasSafeMath for uint256;
    using LowGasSafeMath for int256;
    using SafeCast for uint256;
    using SafeCast for int256;
    using LmTick for mapping(int24 => LmTick.Info);

    uint256 public constant REWARD_PRECISION = 1e12;

    IPancakeV3Pool public immutable pool;
    IMasterChefV3 public immutable masterChef;

    // The first version LMPool.
    ILMPool public immutable firstLMPool;

    // The second version LMPool.
    ILMPool public immutable secondLMPool;

    mapping(int24 => bool) public lmTicksFlag;

    uint256 public rewardGrowthGlobalX128;

    mapping(int24 => LmTick.Info) public lmTicks;

    uint128 public lmLiquidity;

    uint32 public lastRewardTimestamp;

    // Need to initialize the LMPool when first call from v3 pool or MCV3.
    bool public initialization;

    // Check whether rewardGrowthInside is negative at first.
    mapping(int24 => mapping(int24 => bool)) public negativeRewardGrowthInsideFlag;
    // Record the first negative RewardGrowthInside value.
    mapping(int24 => mapping(int24 => uint256)) public negativeRewardGrowthInsideInitValue;
    // To save gas , only need to check negativeRewardGrowthInsideFlag once.
    mapping(int24 => mapping(int24 => bool)) public checkNegativeFlag;

    // To save gas , only need to check negative tick info in second LMPool once.
    mapping(int24 => mapping(int24 => bool)) public checkSecondLMPool;

    modifier onlyPool() {
        require(msg.sender == address(pool), 'Not pool');
        _;
    }

    modifier onlyMasterChef() {
        require(msg.sender == address(masterChef), 'Not MC');
        _;
    }

    modifier onlyPoolOrMasterChef() {
        require(msg.sender == address(pool) || msg.sender == address(masterChef), 'Not pool or MC');
        _;
    }

    constructor() {
        (
            address poolAddress,
            address masterChefAddress,
            address firstLMPoolAddress,
            address secondLMPoolAddress
        ) = IPancakeV3LmPoolDeveloper(msg.sender).parameters();
        pool = IPancakeV3Pool(poolAddress);
        masterChef = IMasterChefV3(masterChefAddress);
        lastRewardTimestamp = uint32(block.timestamp);
        firstLMPool = ILMPool(firstLMPoolAddress);
        secondLMPool = ILMPool(secondLMPoolAddress);
    }

    /// @notice Will trigger this once when the first call from MasterChefV3 or V3 pool,
    /// this will update the latest global information from old LMPool.
    /// Because we will deploy new LMPool and set LMPool in v3 pool in the same transaction, so we can call initialize at the same tx.
    function initialize() external override {
        if (!initialization) {
            initialization = true;
            rewardGrowthGlobalX128 = secondLMPool.rewardGrowthGlobalX128();
            lmLiquidity = secondLMPool.lmLiquidity();
            lastRewardTimestamp = secondLMPool.lastRewardTimestamp();
        }
    }

    function _getLMTicks(int24 tick) internal view returns (LmTick.Info memory info) {
        // When tick had updated in secondLMPool , read tick info from secondLMPool, or read from firstLMPool.
        if (secondLMPool.lmTicksFlag(tick)) {
            (info.liquidityGross, info.liquidityNet, info.rewardGrowthOutsideX128) = secondLMPool.lmTicks(tick);
        } else {
            (info.liquidityGross, info.liquidityNet, info.rewardGrowthOutsideX128) = firstLMPool.lmTicks(tick);
        }
    }

    /// @notice Update tick information from old LMPool when need to update the tick information at the first time.
    /// @dev Old LMPool ticks information can be compatible.
    function _updateLMTicks(int24 tick) internal {
        if (!lmTicksFlag[tick]) {
            lmTicksFlag[tick] = true;
            lmTicks[tick] = _getLMTicks(tick);
        }
    }

    function accumulateReward(uint32 currTimestamp) external override onlyPoolOrMasterChef {
        if (currTimestamp <= lastRewardTimestamp) {
            return;
        }

        if (lmLiquidity != 0) {
            (uint256 rewardPerSecond, uint256 endTime) = masterChef.getLatestPeriodInfo(address(pool));

            uint32 endTimestamp = uint32(endTime);
            uint32 duration;
            if (endTimestamp > currTimestamp) {
                duration = currTimestamp - lastRewardTimestamp;
            } else if (endTimestamp > lastRewardTimestamp) {
                duration = endTimestamp - lastRewardTimestamp;
            }

            if (duration != 0) {
                rewardGrowthGlobalX128 += FullMath.mulDiv(
                    duration,
                    FullMath.mulDiv(rewardPerSecond, FixedPoint128.Q128, REWARD_PRECISION),
                    lmLiquidity
                );
            }
        }

        lastRewardTimestamp = currTimestamp;
    }

    function crossLmTick(int24 tick, bool zeroForOne) external override onlyPool {
        // Update the lmTicks state from the secondLMPool.
        _updateLMTicks(tick);

        if (lmTicks[tick].liquidityGross == 0) {
            return;
        }

        int128 lmLiquidityNet = lmTicks.cross(tick, rewardGrowthGlobalX128);

        if (zeroForOne) {
            lmLiquidityNet = -lmLiquidityNet;
        }

        lmLiquidity = LiquidityMath.addDelta(lmLiquidity, lmLiquidityNet);
    }

    /// @notice This will check the whether the range RewardGrowthInside is negative when the range ticks were initialized.
    /// @dev This is for fixing the issues that rewardGrowthInsideX128 can be underflow on purpose.
    /// If the rewardGrowthInsideX128 is negative , we will process it as a positive number.
    /// Because the RewardGrowthInside is self-incrementing, so we record the initial value as zero point.
    function _checkNegativeRewardGrowthInside(int24 tickLower, int24 tickUpper) internal {
        if (!checkNegativeFlag[tickLower][tickUpper]) {
            checkNegativeFlag[tickLower][tickUpper] = true;
            (uint256 rewardGrowthInsideX128, bool isNegative) = _getRewardGrowthInsideInternal(tickLower, tickUpper);

            bool isNegativeInSecondLMPool;

            // Need to read negativeRewardGrowthInsideInitValue from secondLMPool at first
            if (!checkSecondLMPool[tickLower][tickUpper]) {
                checkSecondLMPool[tickLower][tickUpper] = true;

                isNegativeInSecondLMPool = secondLMPool.negativeRewardGrowthInsideFlag(tickLower, tickUpper);

                // Need to use the old negativeRewardGrowthInsideInitValue when new value is bigger.
                if (isNegativeInSecondLMPool) {
                    uint256 OldNegativeRewardGrowthInsideInitValue = secondLMPool.negativeRewardGrowthInsideInitValue(
                        tickLower,
                        tickUpper
                    );
                    // If isNegative is false at the time we check, we still need to set rewardGrowthInsideX128 as negative.
                    // If isNegative is true , we need to use the smaller negative rewardGrowthInside as the new zero point.
                    if (
                        !isNegative || (isNegative && OldNegativeRewardGrowthInsideInitValue < rewardGrowthInsideX128)
                    ) {
                        rewardGrowthInsideX128 = OldNegativeRewardGrowthInsideInitValue;
                    }
                }
            }
            // Need to set negativeRewardGrowthInsideFlag[tickLower][tickUpper] as true to be compatible with secondLMPool when isNegative or isNegativeInSecondLMPool is true
            if (isNegative || isNegativeInSecondLMPool) {
                negativeRewardGrowthInsideFlag[tickLower][tickUpper] = true;
                negativeRewardGrowthInsideInitValue[tickLower][tickUpper] = rewardGrowthInsideX128;
            }
        }
    }

    /// @notice Need to rest Negative Tick info when tick flipped.
    function _clearNegativeTickInfo(int24 tickLower, int24 tickUpper) internal {
        checkNegativeFlag[tickLower][tickUpper] = false;
        negativeRewardGrowthInsideFlag[tickLower][tickUpper] = false;
        negativeRewardGrowthInsideInitValue[tickLower][tickUpper] = 0;
        // No need to check secondLMPool after tick flipped.
        if (!checkSecondLMPool[tickLower][tickUpper]) checkSecondLMPool[tickLower][tickUpper] = true;
    }

    function updatePosition(int24 tickLower, int24 tickUpper, int128 liquidityDelta) external onlyMasterChef {
        // Update the lmTicks state from the secondLMPool.
        _updateLMTicks(tickLower);
        _updateLMTicks(tickUpper);
        (, int24 tick, , , , , ) = pool.slot0();
        uint128 maxLiquidityPerTick = pool.maxLiquidityPerTick();
        uint256 _rewardGrowthGlobalX128 = rewardGrowthGlobalX128;

        bool flippedLower;
        bool flippedUpper;
        if (liquidityDelta != 0) {
            flippedLower = lmTicks.update(
                tickLower,
                tick,
                liquidityDelta,
                _rewardGrowthGlobalX128,
                false,
                maxLiquidityPerTick
            );
            flippedUpper = lmTicks.update(
                tickUpper,
                tick,
                liquidityDelta,
                _rewardGrowthGlobalX128,
                true,
                maxLiquidityPerTick
            );
        }

        if (tick >= tickLower && tick < tickUpper) {
            lmLiquidity = LiquidityMath.addDelta(lmLiquidity, liquidityDelta);
        }

        if (liquidityDelta < 0) {
            if (flippedLower) {
                lmTicks.clear(tickLower);
            }
            if (flippedUpper) {
                lmTicks.clear(tickUpper);
            }
        }
        // Need to rest Negative Tick info when tick flipped.
        if (liquidityDelta < 0 && (flippedLower || flippedUpper)) {
            _clearNegativeTickInfo(tickLower, tickUpper);
        } else {
            _checkNegativeRewardGrowthInside(tickLower, tickUpper);
        }
    }

    function getRewardGrowthInside(
        int24 tickLower,
        int24 tickUpper
    ) external view returns (uint256 rewardGrowthInsideX128) {
        (rewardGrowthInsideX128, ) = _getRewardGrowthInsideInternal(tickLower, tickUpper);
        if (checkSecondLMPool[tickLower][tickUpper]) {
            if (negativeRewardGrowthInsideFlag[tickLower][tickUpper]) {
                rewardGrowthInsideX128 =
                    rewardGrowthInsideX128 -
                    negativeRewardGrowthInsideInitValue[tickLower][tickUpper];
            }
        } else {
            bool isNegativeInSecondLMPool = secondLMPool.negativeRewardGrowthInsideFlag(tickLower, tickUpper);
            if (isNegativeInSecondLMPool) {
                uint256 OldNegativeRewardGrowthInsideInitValue = secondLMPool.negativeRewardGrowthInsideInitValue(
                    tickLower,
                    tickUpper
                );

                rewardGrowthInsideX128 = rewardGrowthInsideX128 - OldNegativeRewardGrowthInsideInitValue;
            }
        }
    }

    function _getRewardGrowthInsideInternal(
        int24 tickLower,
        int24 tickUpper
    ) internal view returns (uint256 rewardGrowthInsideX128, bool isNegative) {
        (, int24 tick, , , , , ) = pool.slot0();
        LmTick.Info memory lower;
        if (lmTicksFlag[tickLower]) {
            lower = lmTicks[tickLower];
        } else {
            lower = _getLMTicks(tickLower);
        }
        LmTick.Info memory upper;
        if (lmTicksFlag[tickUpper]) {
            upper = lmTicks[tickUpper];
        } else {
            upper = _getLMTicks(tickUpper);
        }

        // calculate reward growth below
        uint256 rewardGrowthBelowX128;
        if (tick >= tickLower) {
            rewardGrowthBelowX128 = lower.rewardGrowthOutsideX128;
        } else {
            rewardGrowthBelowX128 = rewardGrowthGlobalX128 - lower.rewardGrowthOutsideX128;
        }

        // calculate reward growth above
        uint256 rewardGrowthAboveX128;
        if (tick < tickUpper) {
            rewardGrowthAboveX128 = upper.rewardGrowthOutsideX128;
        } else {
            rewardGrowthAboveX128 = rewardGrowthGlobalX128 - upper.rewardGrowthOutsideX128;
        }

        rewardGrowthInsideX128 = rewardGrowthGlobalX128 - rewardGrowthBelowX128 - rewardGrowthAboveX128;
        isNegative = (rewardGrowthBelowX128 + rewardGrowthAboveX128) > rewardGrowthGlobalX128;
    }
}

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

import './pool/IPancakeV3PoolImmutables.sol';
import './pool/IPancakeV3PoolState.sol';
import './pool/IPancakeV3PoolDerivedState.sol';
import './pool/IPancakeV3PoolActions.sol';
import './pool/IPancakeV3PoolOwnerActions.sol';
import './pool/IPancakeV3PoolEvents.sol';

/// @title The interface for a PancakeSwap V3 Pool
/// @notice A PancakeSwap 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 IPancakeV3Pool is
    IPancakeV3PoolImmutables,
    IPancakeV3PoolState,
    IPancakeV3PoolDerivedState,
    IPancakeV3PoolActions,
    IPancakeV3PoolOwnerActions,
    IPancakeV3PoolEvents
{

}

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

/// @title Permissionless pool actions
/// @notice Contains pool methods that can be called by anyone
interface IPancakeV3PoolActions {
    /// @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 IPancakeV3MintCallback#pancakeV3MintCallback
    /// in which they must pay any token0 or token1 owed for the liquidity. The amount of token0/token1 due depends
    /// on tickLower, tickUpper, the amount of liquidity, and the current price.
    /// @param recipient The address for which the liquidity will be created
    /// @param tickLower The lower tick of the position in which to add liquidity
    /// @param tickUpper The upper tick of the position in which to add liquidity
    /// @param amount The amount of liquidity to mint
    /// @param data Any data that should be passed through to the callback
    /// @return amount0 The amount of token0 that was paid to mint the given amount of liquidity. Matches the value in the callback
    /// @return amount1 The amount of token1 that was paid to mint the given amount of liquidity. Matches the value in the callback
    function mint(
        address recipient,
        int24 tickLower,
        int24 tickUpper,
        uint128 amount,
        bytes calldata data
    ) external returns (uint256 amount0, uint256 amount1);

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

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

    /// @notice Swap token0 for token1, or token1 for token0
    /// @dev The caller of this method receives a callback in the form of IPancakeV3SwapCallback#pancakeV3SwapCallback
    /// @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 IPancakeV3FlashCallback#pancakeV3FlashCallback
    /// @dev Can be used to donate underlying tokens pro-rata to currently in-range liquidity providers by calling
    /// with 0 amount{0,1} and sending the donation amount(s) from the callback
    /// @param recipient The address which will receive the token0 and token1 amounts
    /// @param amount0 The amount of token0 to send
    /// @param amount1 The amount of token1 to send
    /// @param data Any data to be passed through to the callback
    function flash(
        address recipient,
        uint256 amount0,
        uint256 amount1,
        bytes calldata data
    ) external;

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

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

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

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

File 5 of 19 : IPancakeV3PoolEvents.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 IPancakeV3PoolEvents {
    /// @notice Emitted exactly once by a pool when #initialize is first called on the pool
    /// @dev Mint/Burn/Swap cannot be emitted by the pool before Initialize
    /// @param sqrtPriceX96 The initial sqrt price of the pool, as a Q64.96
    /// @param tick The initial tick of the pool, i.e. log base 1.0001 of the starting price of the pool
    event Initialize(uint160 sqrtPriceX96, int24 tick);

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

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

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

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

    /// @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(
        uint32 feeProtocol0Old,
        uint32 feeProtocol1Old,
        uint32 feeProtocol0New,
        uint32 feeProtocol1New
    );

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

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

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

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

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

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

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

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

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

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

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

    /// @notice Set the LM pool to enable liquidity mining
    function setLmPool(address lmPool) external;
}

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

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

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

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

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

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

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

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

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

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

File 9 of 19 : 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;
}

File 10 of 19 : FullMath.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.4.0 <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) {
        // 512-bit multiply [prod1 prod0] = a * b
        // Compute the product mod 2**256 and mod 2**256 - 1
        // then use the Chinese Remainder Theorem to reconstruct
        // the 512 bit result. The result is stored in two 256
        // variables such that product = prod1 * 2**256 + prod0
        uint256 prod0; // Least significant 256 bits of the product
        uint256 prod1; // Most significant 256 bits of the product
        assembly {
            let mm := mulmod(a, b, not(0))
            prod0 := mul(a, b)
            prod1 := sub(sub(mm, prod0), lt(mm, prod0))
        }

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

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

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

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

        // Factor powers of two out of denominator
        // Compute largest power of two divisor of denominator.
        // Always >= 1.
        uint256 twos = -denominator & denominator;
        // 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) {
        result = mulDiv(a, b, denominator);
        if (mulmod(a, b, denominator) > 0) {
            require(result < type(uint256).max);
            result++;
        }
    }
}

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

/// @title Math library for liquidity
library LiquidityMath {
    /// @notice Add a signed liquidity delta to liquidity and revert if it overflows or underflows
    /// @param x The liquidity before change
    /// @param y The delta by which liquidity should be changed
    /// @return z The liquidity delta
    function addDelta(uint128 x, int128 y) internal pure returns (uint128 z) {
        if (y < 0) {
            require((z = x - uint128(-y)) < x, 'LS');
        } else {
            require((z = x + uint128(y)) >= x, 'LA');
        }
    }
}

File 12 of 19 : LowGasSafeMath.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.7.0;

/// @title Optimized overflow and underflow safe math operations
/// @notice Contains methods for doing math operations that revert on overflow or underflow for minimal gas cost
library LowGasSafeMath {
    /// @notice Returns x + y, reverts if sum overflows uint256
    /// @param x The augend
    /// @param y The addend
    /// @return z The sum of x and y
    function add(uint256 x, uint256 y) internal pure returns (uint256 z) {
        require((z = x + y) >= x);
    }

    /// @notice Returns x - y, reverts if underflows
    /// @param x The minuend
    /// @param y The subtrahend
    /// @return z The difference of x and y
    function sub(uint256 x, uint256 y) internal pure returns (uint256 z) {
        require((z = x - y) <= x);
    }

    /// @notice Returns x * y, reverts if overflows
    /// @param x The multiplicand
    /// @param y The multiplier
    /// @return z The product of x and y
    function mul(uint256 x, uint256 y) internal pure returns (uint256 z) {
        require(x == 0 || (z = x * y) / x == y);
    }

    /// @notice Returns x + y, reverts if overflows or underflows
    /// @param x The augend
    /// @param y The addend
    /// @return z The sum of x and y
    function add(int256 x, int256 y) internal pure returns (int256 z) {
        require((z = x + y) >= x == (y >= 0));
    }

    /// @notice Returns x - y, reverts if overflows or underflows
    /// @param x The minuend
    /// @param y The subtrahend
    /// @return z The difference of x and y
    function sub(int256 x, int256 y) internal pure returns (int256 z) {
        require((z = x - y) <= x == (y >= 0));
    }
}

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

/// @title Safe casting methods
/// @notice Contains methods for safely casting between types
library SafeCast {
    /// @notice Cast a uint256 to a uint160, revert on overflow
    /// @param y The uint256 to be downcasted
    /// @return z The downcasted integer, now type uint160
    function toUint160(uint256 y) internal pure returns (uint160 z) {
        require((z = uint160(y)) == y);
    }

    /// @notice Cast a int256 to a int128, revert on overflow or underflow
    /// @param y The int256 to be downcasted
    /// @return z The downcasted integer, now type int128
    function toInt128(int256 y) internal pure returns (int128 z) {
        require((z = int128(y)) == y);
    }

    /// @notice Cast a uint256 to a int256, revert on overflow
    /// @param y The uint256 to be casted
    /// @return z The casted integer, now type int256
    function toInt256(uint256 y) internal pure returns (int256 z) {
        require(y < 2**255);
        z = int256(y);
    }
}

File 14 of 19 : TickMath.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0 <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 {
    /// @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) {
        uint256 absTick = tick < 0 ? uint256(-int256(tick)) : uint256(int256(tick));
        require(absTick <= uint256(MAX_TICK), 'T');

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

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

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

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

        uint256 r = ratio;
        uint256 msb = 0;

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

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

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

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

        int256 log_sqrt10001 = log_2 * 255738958999603826347141; // 128.128 number

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

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

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

interface ILMPool {
    function lmTicks(int24) external view returns (uint128, int128, uint256);

    function rewardGrowthGlobalX128() external view returns (uint256);

    function lmLiquidity() external view returns (uint128);

    function lastRewardTimestamp() external view returns (uint32);

    function getRewardGrowthInside(int24 tickLower, int24 tickUpper) external view returns (uint256);

    function OldLMPool() external view returns (address);

    function lmTicksFlag(int24 tick) external view returns (bool);

    function negativeRewardGrowthInsideFlag(int24 tickLower, int24 tickUpper) external view returns (bool);

    function negativeRewardGrowthInsideInitValue(int24 tickLower, int24 tickUpper) external view returns (uint256);

    function checkNegativeFlag(int24 tickLower, int24 tickUpper) external view returns (bool);
}

File 16 of 19 : IMasterChefV3.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity =0.7.6;

interface IMasterChefV3 {
    function nonfungiblePositionManager() external view returns (address);

    function getLatestPeriodInfo(address _v3Pool) external view returns (uint256 cakePerSecond, uint256 endTime);

    function poolInfo(uint256 pid) external view returns (uint256, address, address, address, uint24, uint256, uint256);
}

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

interface IPancakeV3LmPool {
    function accumulateReward(uint32 currTimestamp) external;

    function crossLmTick(int24 tick, bool zeroForOne) external;

    function initialize() external;
}

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

interface IPancakeV3LmPoolDeveloper {
    function parameters() external view returns (address pool, address masterChef, address firstLMPool, address secondLMPool);
}

File 19 of 19 : LmTick.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0 <0.8.0;

import '@pancakeswap/v3-core/contracts/libraries/LowGasSafeMath.sol';
import '@pancakeswap/v3-core/contracts/libraries/SafeCast.sol';

import '@pancakeswap/v3-core/contracts/libraries/TickMath.sol';
import '@pancakeswap/v3-core/contracts/libraries/LiquidityMath.sol';

/// @title LmTick
/// @notice Contains functions for managing tick processes and relevant calculations
library LmTick {
    using LowGasSafeMath for int256;
    using SafeCast for int256;

    // info stored for each initialized individual tick
    struct Info {
        // the total position liquidity that references this tick
        uint128 liquidityGross;
        // amount of net liquidity added (subtracted) when tick is crossed from left to right (right to left),
        int128 liquidityNet;
        // reward growth per unit of liquidity on the _other_ side of this tick (relative to the current tick)
        // only has relative meaning, not absolute — the value depends on when the tick is initialized
        uint256 rewardGrowthOutsideX128;
    }

    /// @notice Retrieves reward growth data
    /// @param self The mapping containing all tick information for initialized ticks
    /// @param tickLower The lower tick boundary of the position
    /// @param tickUpper The upper tick boundary of the position
    /// @param tickCurrent The current tick
    /// @param rewardGrowthGlobalX128 The all-time global reward growth, per unit of liquidity
    /// @return rewardGrowthInsideX128 The all-time reward growth, per unit of liquidity, inside the position's tick boundaries
    function getRewardGrowthInside(
        mapping(int24 => LmTick.Info) storage self,
        int24 tickLower,
        int24 tickUpper,
        int24 tickCurrent,
        uint256 rewardGrowthGlobalX128
    ) internal view returns (uint256 rewardGrowthInsideX128) {
        Info storage lower = self[tickLower];
        Info storage upper = self[tickUpper];

        // calculate reward growth below
        uint256 rewardGrowthBelowX128;
        if (tickCurrent >= tickLower) {
            rewardGrowthBelowX128 = lower.rewardGrowthOutsideX128;
        } else {
            rewardGrowthBelowX128 = rewardGrowthGlobalX128 - lower.rewardGrowthOutsideX128;
        }

        // calculate reward growth above
        uint256 rewardGrowthAboveX128;
        if (tickCurrent < tickUpper) {
            rewardGrowthAboveX128 = upper.rewardGrowthOutsideX128;
        } else {
            rewardGrowthAboveX128 = rewardGrowthGlobalX128 - upper.rewardGrowthOutsideX128;
        }

        rewardGrowthInsideX128 = rewardGrowthGlobalX128 - rewardGrowthBelowX128 - rewardGrowthAboveX128;
    }

    /// @notice Updates a tick and returns true if the tick was flipped from initialized to uninitialized, or vice versa
    /// @param self The mapping containing all tick information for initialized ticks
    /// @param tick The tick that will be updated
    /// @param tickCurrent The current tick
    /// @param liquidityDelta A new amount of liquidity to be added (subtracted) when tick is crossed from left to right (right to left)
    /// @param rewardGrowthGlobalX128 The all-time global reward growth, per unit of liquidity
    /// @param upper true for updating a position's upper tick, or false for updating a position's lower tick
    /// @param maxLiquidity The maximum liquidity allocation for a single tick
    /// @return flipped Whether the tick was flipped from initialized to uninitialized, or vice versa
    function update(
        mapping(int24 => LmTick.Info) storage self,
        int24 tick,
        int24 tickCurrent,
        int128 liquidityDelta,
        uint256 rewardGrowthGlobalX128,
        bool upper,
        uint128 maxLiquidity
    ) internal returns (bool flipped) {
        LmTick.Info storage info = self[tick];

        uint128 liquidityGrossBefore = info.liquidityGross;
        uint128 liquidityGrossAfter = LiquidityMath.addDelta(liquidityGrossBefore, liquidityDelta);

        require(liquidityGrossAfter <= maxLiquidity, 'LO');

        flipped = (liquidityGrossAfter == 0) != (liquidityGrossBefore == 0);

        if (liquidityGrossBefore == 0) {
            // by convention, we assume that all growth before a tick was initialized happened _below_ the tick
            if (tick <= tickCurrent) {
                info.rewardGrowthOutsideX128 = rewardGrowthGlobalX128;
            }
        }

        info.liquidityGross = liquidityGrossAfter;

        // when the lower (upper) tick is crossed left to right (right to left), liquidity must be added (removed)
        info.liquidityNet = upper
            ? int256(info.liquidityNet).sub(liquidityDelta).toInt128()
            : int256(info.liquidityNet).add(liquidityDelta).toInt128();
    }

    /// @notice Clears tick data
    /// @param self The mapping containing all initialized tick information for initialized ticks
    /// @param tick The tick that will be cleared
    function clear(mapping(int24 => LmTick.Info) storage self, int24 tick) internal {
        delete self[tick];
    }

    /// @notice Transitions to next tick as needed by price movement
    /// @param self The mapping containing all tick information for initialized ticks
    /// @param tick The destination tick of the transition
    /// @param rewardGrowthGlobalX128 The all-time global reward growth, per unit of liquidity, in token0
    /// @return liquidityNet The amount of liquidity added (subtracted) when tick is crossed from left to right (right to left)
    function cross(
        mapping(int24 => LmTick.Info) storage self,
        int24 tick,
        uint256 rewardGrowthGlobalX128
    ) internal returns (int128 liquidityNet) {
        LmTick.Info storage info = self[tick];
        info.rewardGrowthOutsideX128 = rewardGrowthGlobalX128 - info.rewardGrowthOutsideX128;
        liquidityNet = info.liquidityNet;
    }
}

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

Contract Security Audit

Contract ABI

[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"REWARD_PRECISION","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"currTimestamp","type":"uint32"}],"name":"accumulateReward","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"int24","name":"","type":"int24"},{"internalType":"int24","name":"","type":"int24"}],"name":"checkNegativeFlag","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"int24","name":"","type":"int24"},{"internalType":"int24","name":"","type":"int24"}],"name":"checkSecondLMPool","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"int24","name":"tick","type":"int24"},{"internalType":"bool","name":"zeroForOne","type":"bool"}],"name":"crossLmTick","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"firstLMPool","outputs":[{"internalType":"contract ILMPool","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"int24","name":"tickLower","type":"int24"},{"internalType":"int24","name":"tickUpper","type":"int24"}],"name":"getRewardGrowthInside","outputs":[{"internalType":"uint256","name":"rewardGrowthInsideX128","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"initialization","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"lastRewardTimestamp","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lmLiquidity","outputs":[{"internalType":"uint128","name":"","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"int24","name":"","type":"int24"}],"name":"lmTicks","outputs":[{"internalType":"uint128","name":"liquidityGross","type":"uint128"},{"internalType":"int128","name":"liquidityNet","type":"int128"},{"internalType":"uint256","name":"rewardGrowthOutsideX128","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"int24","name":"","type":"int24"}],"name":"lmTicksFlag","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"masterChef","outputs":[{"internalType":"contract IMasterChefV3","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"int24","name":"","type":"int24"},{"internalType":"int24","name":"","type":"int24"}],"name":"negativeRewardGrowthInsideFlag","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"int24","name":"","type":"int24"},{"internalType":"int24","name":"","type":"int24"}],"name":"negativeRewardGrowthInsideInitValue","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pool","outputs":[{"internalType":"contract IPancakeV3Pool","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardGrowthGlobalX128","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"secondLMPool","outputs":[{"internalType":"contract ILMPool","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"int24","name":"tickLower","type":"int24"},{"internalType":"int24","name":"tickUpper","type":"int24"},{"internalType":"int128","name":"liquidityDelta","type":"int128"}],"name":"updatePosition","outputs":[],"stateMutability":"nonpayable","type":"function"}]

Deployed Bytecode

0x608060405234801561001057600080fd5b506004361061016c5760003560e01c80638910faf1116100cd578063c172085e11610081578063f8077fae11610066578063f8077fae146103a0578063f9461601146103c1578063fcad09fc146103eb5761016c565b8063c172085e1461036b578063c3487ff8146103735761016c565b8063a9c6abe0116100b2578063a9c6abe014610331578063ac1f40e11461035b578063b77efe0f146103635761016c565b80638910faf1146102d5578063a4984633146103095761016c565b8063575a86b211610124578063702d75d211610109578063702d75d2146102835780637ddb11d4146102ad5780638129fc1c146102cd5761016c565b8063575a86b21461027357806357806ada1461027b5761016c565b8063214a6fe211610155578063214a6fe2146101e057806337182c1b146102055780633d6aa5e1146102595761016c565b806306b712bf1461017157806316f0115b146101af575b600080fd5b61019b6004803603604081101561018757600080fd5b508035600290810b9160200135900b610415565b604080519115158252519081900360200190f35b6101b7610435565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b610203600480360360208110156101f657600080fd5b503563ffffffff16610459565b005b6102256004803603602081101561021b57600080fd5b503560020b61078d565b604080516fffffffffffffffffffffffffffffffff9094168452600f9290920b602084015282820152519081900360600190f35b6102616107d2565b60408051918252519081900360200190f35b6101b76107db565b6102616107ff565b6102616004803603604081101561029957600080fd5b508035600290810b9160200135900b610805565b61019b600480360360208110156102c357600080fd5b503560020b610a0c565b610203610a21565b610203600480360360608110156102eb57600080fd5b508035600290810b91602081013590910b9060400135600f0b610d27565b6102036004803603604081101561031f57600080fd5b50803560020b90602001351515611053565b61019b6004803603604081101561034757600080fd5b508035600290810b9160200135900b6111be565b6101b76111de565b6101b7611202565b61019b611226565b61037b611247565b604080516fffffffffffffffffffffffffffffffff9092168252519081900360200190f35b6103a861125f565b6040805163ffffffff9092168252519081900360200190f35b610261600480360360408110156103d757600080fd5b508035600290810b9160200135900b61127f565b61019b6004803603604081101561040157600080fd5b508035600290810b9160200135900b61129c565b600460209081526000928352604080842090915290825290205460ff1681565b7f0000000000000000000000006ca298d2983ab03aa1da7679389d955a4efee15c81565b3373ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000006ca298d2983ab03aa1da7679389d955a4efee15c1614806104d257503373ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000556b9306565093c855aea9ae92a594704c2cd59e16145b61053d57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600e60248201527f4e6f7420706f6f6c206f72204d43000000000000000000000000000000000000604482015290519081900360640190fd5b60035463ffffffff7001000000000000000000000000000000009091048116908216116105695761078a565b6003546fffffffffffffffffffffffffffffffff1615610746576000807f000000000000000000000000556b9306565093c855aea9ae92a594704c2cd59e73ffffffffffffffffffffffffffffffffffffffff1663a15ea89f7f0000000000000000000000006ca298d2983ab03aa1da7679389d955a4efee15c6040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff168152602001915050604080518083038186803b15801561062c57600080fd5b505afa158015610640573d6000803e3d6000fd5b505050506040513d604081101561065657600080fd5b508051602090910151909250905080600063ffffffff808616908316111561069d5750600354700100000000000000000000000000000000900463ffffffff1684036106e6565b60035463ffffffff700100000000000000000000000000000000909104811690831611156106e65750600354700100000000000000000000000000000000900463ffffffff1681035b63ffffffff811615610741576107378163ffffffff1661071d8670010000000000000000000000000000000064e8d4a510006112bc565b6003546fffffffffffffffffffffffffffffffff166112bc565b6001805490910190555b505050505b600380547fffffffffffffffffffffffff00000000ffffffffffffffffffffffffffffffff1670010000000000000000000000000000000063ffffffff8416021790555b50565b600260205260009081526040902080546001909101546fffffffffffffffffffffffffffffffff8216917001000000000000000000000000000000009004600f0b9083565b64e8d4a5100081565b7f000000000000000000000000556b9306565093c855aea9ae92a594704c2cd59e81565b60015481565b6000610811838361138a565b50600284810b810b600090815260076020908152604080832087850b90940b8352929052205490915060ff161561089c57600283810b810b600090815260046020908152604080832086850b90940b8352929052205460ff161561089757600283810b810b600090815260056020908152604080832086850b90940b8352929052205490035b610a06565b60007f000000000000000000000000161c4e0f7927e0eb30bac902591bfd57b2ca5cd973ffffffffffffffffffffffffffffffffffffffff166306b712bf85856040518363ffffffff1660e01b8152600401808360020b81526020018260020b81526020019250505060206040518083038186803b15801561091d57600080fd5b505afa158015610931573d6000803e3d6000fd5b505050506040513d602081101561094757600080fd5b505190508015610a045760007f000000000000000000000000161c4e0f7927e0eb30bac902591bfd57b2ca5cd973ffffffffffffffffffffffffffffffffffffffff1663f946160186866040518363ffffffff1660e01b8152600401808360020b81526020018260020b81526020019250505060206040518083038186803b1580156109d257600080fd5b505afa1580156109e6573d6000803e3d6000fd5b505050506040513d60208110156109fc57600080fd5b505190920391505b505b92915050565b60006020819052908152604090205460ff1681565b60035474010000000000000000000000000000000000000000900460ff16610d2557600380547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff1674010000000000000000000000000000000000000000179055604080517f57806ada000000000000000000000000000000000000000000000000000000008152905173ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000161c4e0f7927e0eb30bac902591bfd57b2ca5cd916916357806ada916004808301926020929190829003018186803b158015610b0857600080fd5b505afa158015610b1c573d6000803e3d6000fd5b505050506040513d6020811015610b3257600080fd5b5051600155604080517fc3487ff8000000000000000000000000000000000000000000000000000000008152905173ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000161c4e0f7927e0eb30bac902591bfd57b2ca5cd9169163c3487ff8916004808301926020929190829003018186803b158015610bbd57600080fd5b505afa158015610bd1573d6000803e3d6000fd5b505050506040513d6020811015610be757600080fd5b5051600380547fffffffffffffffffffffffffffffffff00000000000000000000000000000000166fffffffffffffffffffffffffffffffff909216919091179055604080517ff8077fae00000000000000000000000000000000000000000000000000000000815290517f000000000000000000000000161c4e0f7927e0eb30bac902591bfd57b2ca5cd973ffffffffffffffffffffffffffffffffffffffff169163f8077fae916004808301926020929190829003018186803b158015610caf57600080fd5b505afa158015610cc3573d6000803e3d6000fd5b505050506040513d6020811015610cd957600080fd5b50516003805463ffffffff909216700100000000000000000000000000000000027fffffffffffffffffffffffff00000000ffffffffffffffffffffffffffffffff9092169190911790555b565b3373ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000556b9306565093c855aea9ae92a594704c2cd59e1614610dcb57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600660248201527f4e6f74204d430000000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b610dd4836115bf565b610ddd826115bf565b60007f0000000000000000000000006ca298d2983ab03aa1da7679389d955a4efee15c73ffffffffffffffffffffffffffffffffffffffff16633850c7bd6040518163ffffffff1660e01b815260040160e06040518083038186803b158015610e4557600080fd5b505afa158015610e59573d6000803e3d6000fd5b505050506040513d60e0811015610e6f57600080fd5b50602090810151604080517f70cf754a000000000000000000000000000000000000000000000000000000008152905191935060009273ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000006ca298d2983ab03aa1da7679389d955a4efee15c16926370cf754a926004808201939291829003018186803b158015610eff57600080fd5b505afa158015610f13573d6000803e3d6000fd5b505050506040513d6020811015610f2957600080fd5b5051600154909150600080600f86900b15610f6557610f4f60028987898760008a6116aa565b9150610f6260028887898760018a6116aa565b90505b8760020b8560020b12158015610f8057508660020b8560020b125b15610fe657600354610fa4906fffffffffffffffffffffffffffffffff1687611893565b600380547fffffffffffffffffffffffffffffffff00000000000000000000000000000000166fffffffffffffffffffffffffffffffff929092169190911790555b600086600f0b1215611014578115611003576110036002896119d2565b8015611014576110146002886119d2565b600086600f0b12801561102b5750818061102b5750805b1561103f5761103a88886119f1565b611049565b6110498888611adb565b5050505050505050565b3373ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000006ca298d2983ab03aa1da7679389d955a4efee15c16146110f757604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600860248201527f4e6f7420706f6f6c000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b611100826115bf565b600282810b810b600090815260209190915260409020546fffffffffffffffffffffffffffffffff16611132576111ba565b600061114c836001546002611df49092919063ffffffff16565b90508115611158576000035b600354611177906fffffffffffffffffffffffffffffffff1682611893565b600380547fffffffffffffffffffffffffffffffff00000000000000000000000000000000166fffffffffffffffffffffffffffffffff92909216919091179055505b5050565b600760209081526000928352604080842090915290825290205460ff1681565b7f0000000000000000000000000bda23d287334d0646dd55263706e354f8ffc2ad81565b7f000000000000000000000000161c4e0f7927e0eb30bac902591bfd57b2ca5cd981565b60035474010000000000000000000000000000000000000000900460ff1681565b6003546fffffffffffffffffffffffffffffffff1681565b600354700100000000000000000000000000000000900463ffffffff1681565b600560209081526000928352604080842090915290825290205481565b600660209081526000928352604080842090915290825290205460ff1681565b600080807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff85870986860292508281109083900303905080611310576000841161130557600080fd5b508290049050611383565b80841161131c57600080fd5b6000848688096000868103871696879004966002600389028118808a02820302808a02820302808a02820302808a02820302808a02820302808a02909103029181900381900460010186841190950394909402919094039290920491909117919091029150505b9392505050565b60008060007f0000000000000000000000006ca298d2983ab03aa1da7679389d955a4efee15c73ffffffffffffffffffffffffffffffffffffffff16633850c7bd6040518163ffffffff1660e01b815260040160e06040518083038186803b1580156113f557600080fd5b505afa158015611409573d6000803e3d6000fd5b505050506040513d60e081101561141f57600080fd5b5060200151905061142e6120d6565b600286810b900b60009081526020819052604090205460ff16156114b45750600285810b810b60009081526020918252604090819020815160608101835281546fffffffffffffffffffffffffffffffff811682527001000000000000000000000000000000009004600f90810b810b900b9381019390935260010154908201526114c0565b6114bd86611e33565b90505b6114c86120d6565b600286810b900b60009081526020819052604090205460ff161561154e5750600285810b810b60009081526020918252604090819020815160608101835281546fffffffffffffffffffffffffffffffff811682527001000000000000000000000000000000009004600f90810b810b900b93810193909352600101549082015261155a565b61155786611e33565b90505b60008760020b8460020b126115745750604082015161157f565b506040820151600154035b60008760020b8560020b121561159a575060408201516115a5565b506040820151600154035b6001548281038290039a9290910111975095505050505050565b600281810b900b60009081526020819052604090205460ff1661078a57600281810b900b600090815260208190526040902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600117905561162381611e33565b600291820b820b600090815260209283526040908190208251815494840151600f0b6fffffffffffffffffffffffffffffffff908116700100000000000000000000000000000000029181167fffffffffffffffffffffffffffffffff00000000000000000000000000000000909616959095179094169390931783550151600190910155565b600286810b900b600090815260208890526040812080546fffffffffffffffffffffffffffffffff16826116de8289611893565b9050846fffffffffffffffffffffffffffffffff16816fffffffffffffffffffffffffffffffff16111561177357604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600260248201527f4c4f000000000000000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b6fffffffffffffffffffffffffffffffff82811615908216158114159450156117ab578860020b8a60020b136117ab57600183018790555b82547fffffffffffffffffffffffffffffffff00000000000000000000000000000000166fffffffffffffffffffffffffffffffff82161783558561182257825461181d90611818907001000000000000000000000000000000009004600f90810b810b908b900b612099565b6120af565b611850565b825461185090611818907001000000000000000000000000000000009004600f90810b810b908b900b6120c0565b8354600f9190910b6fffffffffffffffffffffffffffffffff90811670010000000000000000000000000000000002911617909255509098975050505050505050565b60008082600f0b121561193a57826fffffffffffffffffffffffffffffffff168260000384039150816fffffffffffffffffffffffffffffffff161061089757604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600260248201527f4c53000000000000000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b826fffffffffffffffffffffffffffffffff168284019150816fffffffffffffffffffffffffffffffff161015610a0657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600260248201527f4c41000000000000000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b600290810b900b60009081526020919091526040812081815560010155565b600282810b810b600081815260066020908152604080832086860b90950b80845294825280832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0090811690915584845260048352818420868552835281842080549091169055838352600582528083208584528252808320839055928252600781528282209382529290925290205460ff166111ba57600282810b810b600090815260076020908152604080832085850b90940b83529290522080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790555050565b600282810b810b600090815260066020908152604080832085850b90940b8352929052205460ff166111ba57600282810b810b600090815260066020908152604080832085850b90940b835292905290812080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600117905580611b61848461138a565b600286810b810b600090815260076020908152604080832089850b90940b8352929052908120549294509092509060ff16611d7857600285810b80820b600090815260076020908152604080832089860b9586900b845282529182902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600117905581517f06b712bf000000000000000000000000000000000000000000000000000000008152600481019390935260248301939093525173ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000161c4e0f7927e0eb30bac902591bfd57b2ca5cd916926306b712bf9260448082019391829003018186803b158015611c7657600080fd5b505afa158015611c8a573d6000803e3d6000fd5b505050506040513d6020811015611ca057600080fd5b505190508015611d785760007f000000000000000000000000161c4e0f7927e0eb30bac902591bfd57b2ca5cd973ffffffffffffffffffffffffffffffffffffffff1663f946160187876040518363ffffffff1660e01b8152600401808360020b81526020018260020b81526020019250505060206040518083038186803b158015611d2b57600080fd5b505afa158015611d3f573d6000803e3d6000fd5b505050506040513d6020811015611d5557600080fd5b50519050821580611d6d5750828015611d6d57508381105b15611d76578093505b505b8180611d815750805b15611ded57600285810b810b600081815260046020908152604080832089860b90950b80845294825280832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055928252600581528282209382529290925290208390555b5050505050565b600291820b90910b60009081526020929092526040909120600181018054909203909155547001000000000000000000000000000000009004600f0b90565b611e3b6120d6565b7f000000000000000000000000161c4e0f7927e0eb30bac902591bfd57b2ca5cd973ffffffffffffffffffffffffffffffffffffffff16637ddb11d4836040518263ffffffff1660e01b8152600401808260020b815260200191505060206040518083038186803b158015611eaf57600080fd5b505afa158015611ec3573d6000803e3d6000fd5b505050506040513d6020811015611ed957600080fd5b505115611fbc577f000000000000000000000000161c4e0f7927e0eb30bac902591bfd57b2ca5cd973ffffffffffffffffffffffffffffffffffffffff166337182c1b836040518263ffffffff1660e01b8152600401808260020b815260200191505060606040518083038186803b158015611f5457600080fd5b505afa158015611f68573d6000803e3d6000fd5b505050506040513d6060811015611f7e57600080fd5b50805160208083015160409384015193850193909352600f92830b90920b918301919091526fffffffffffffffffffffffffffffffff168152612094565b7f0000000000000000000000000bda23d287334d0646dd55263706e354f8ffc2ad73ffffffffffffffffffffffffffffffffffffffff166337182c1b836040518263ffffffff1660e01b8152600401808260020b815260200191505060606040518083038186803b15801561203057600080fd5b505afa158015612044573d6000803e3d6000fd5b505050506040513d606081101561205a57600080fd5b50805160208083015160409384015193850193909352600f92830b90920b918301919091526fffffffffffffffffffffffffffffffff1681525b919050565b81810182811215600083121514610a0657600080fd5b80600f81900b811461209457600080fd5b80820382811315600083121514610a0657600080fd5b60408051606081018252600080825260208201819052918101919091529056fea264697066735822122014b46b08bc557ede3b7ad01219890880239177816dff17297908b859eeb4f0a164736f6c63430007060033

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

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

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