Source Code
Overview
ETH Balance
0 ETH
ETH Value
$0.00View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Cross-Chain Transactions
Loading...
Loading
This contract contains unverified libraries: QueryAlgebraTicksSuperCompact, QueryFluid, QueryFluidLite, QueryHorizonTicksSuperCompact, QueryIzumiSuperCompact, QueryPancakeInfinityLBReserveSuperCompact, QueryUniv3TicksSuperCompact, QueryUniv4TicksSuperCompact, QueryZoraTicksSuperCompact
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.
Contract Name:
QueryData
Compiler Version
v0.8.17+commit.8df45f5f
Optimization Enabled:
Yes with 200 runs
Other Settings:
london EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "./interface/IAlgebraPool.sol";
import "./interface/ICLPoolManager.sol";
import "./interface/IHooks.sol";
import "./interface/IHorizonPool.sol";
import "./interface/IPoolManager.sol";
import "./interface/IPositionManager.sol";
import "./interface/IStateView.sol";
import "./interface/IUniswapV3Pool.sol";
import "./interface/IZora.sol";
import "./interface/IZumiPool.sol";
import "./extLib/QueryUniv3TicksSuperCompact.sol";
import "./extLib/QueryAlgebraTicksSuperCompact.sol";
import "./extLib/QueryHorizonTicksSuperCompact.sol";
import "./extLib/QueryIzumiSuperCompact.sol";
import "./extLib/QueryUniv4TicksSuperCompact.sol";
import "./extLib/QueryZoraTicksSuperCompact.sol";
import "./extLib/QueryPancakeInfinityLBReserveSuperCompact.sol";
import "./extLib/QueryFluid.sol";
import "./extLib/QueryFluidLite.sol";
contract QueryData is OwnableUpgradeable {
// Core contract addresses (Unichain)
address public constant POOL_MANAGER = 0x1F98400000000000000000000000000000000004;
address public constant STATE_VIEW = 0x86e8631A016F9068C3f085fAF484Ee3F5fDee8f2;
address public constant POSITION_MANAGER = 0x4529A01c7A0410167c5740C487A8DE60232617bf;
// FluidLite contract addresses
address public constant FLUID_LITE_DEX = 0x0000000000000000000000000000000000000000;
address public constant FLUID_LITE_DEPLOYER_CONTRACT = 0x0000000000000000000000000000000000000000;
function initialize() public initializer {
__Ownable_init();
}
type Currency is address;
/// @notice Returns the key for identifying a pool
struct PoolKey {
/// @notice The lower currency of the pool, sorted numerically
Currency currency0;
/// @notice The higher currency of the pool, sorted numerically
Currency currency1;
/// @notice The pool LP fee, capped at 1_000_000. If the highest bit is 1, the pool has a dynamic fee and must be exactly equal to 0x800000
uint24 fee;
/// @notice Ticks that involve positions must be a multiple of tick spacing
int24 tickSpacing;
/// @notice The hooks of the pool
IHooks hooks;
}
struct SuperVar {
int24 tickSpacing;
int24 currTick;
int24 right;
int24 left;
int24 leftMost;
int24 rightMost;
uint256 initPoint;
uint256 initPoint2;
}
function queryUniv3TicksSuperCompact(address pool, uint256 len) public view returns (bytes memory) {
return QueryUniv3TicksSuperCompact.queryUniv3TicksSuperCompact(pool, len);
}
function queryAlgebraTicksSuperCompact(address pool, uint256 len) public view returns (bytes memory) {
return QueryAlgebraTicksSuperCompact.queryAlgebraTicksSuperCompact(pool, len);
}
function queryAlgebraTicksSuperCompact3_back(address pool, uint256 len) public view returns (bytes memory) {
return QueryAlgebraTicksSuperCompact.queryAlgebraTicksSuperCompact3_back(pool, len);
}
function queryHorizonTicksSuperCompact(address pool, uint256 len) public view returns (bytes memory) {
return QueryHorizonTicksSuperCompact.queryHorizonTicksSuperCompact(pool, len);
}
function queryAlgebraTicksSuperCompact2(address pool, uint256 len) public view returns (bytes memory) {
return QueryAlgebraTicksSuperCompact.queryAlgebraTicksSuperCompact2(pool, len);
}
function queryIzumiSuperCompact(address pool, uint256 len) public view returns (bytes memory, bytes memory) {
return QueryIzumiSuperCompact.queryIzumiSuperCompact(pool, len);
}
function queryAlgebraTicksSuperCompact3(address pool, uint256 len) public view returns (bytes memory) {
return QueryAlgebraTicksSuperCompact.queryAlgebraTicksSuperCompact3(pool, len);
}
function queryUniv4TicksSuperCompact(bytes32 poolId, uint256 len) public view returns (bytes memory) {
return QueryUniv4TicksSuperCompact.queryUniv4TicksSuperCompact(
poolId, len, STATE_VIEW, POSITION_MANAGER
);
}
/*
* @notice Query the ticks of a Uniswap V4 pool for no position manager
* @param poolId The ID of the pool
* @param len The length of the ticks
* @param STATE_VIEW The address of the state view
* @param poolkey The pool key
* @return The ticks
*/
function queryUniv4TicksSuperCompactForNoPositionManager(bytes32 poolId, uint256 len, IPositionManager.PoolKey calldata poolkey) public view returns (bytes memory) {
return QueryUniv4TicksSuperCompact.queryUniv4TicksSuperCompactForNoPositionManager(
poolId, len, STATE_VIEW, poolkey
);
}
function queryPancakeInfinityTicksSuperCompact(bytes32 poolId, uint256 len) public view returns (bytes memory) {
return QueryUniv4TicksSuperCompact.queryPancakeInfinityTicksSuperCompact(
poolId, len
);
}
function queryPancakeInfinityLBReserveSuperCompact(bytes32 poolId) public view returns (uint256 totalReserveX, uint256 totalReserveY) {
return QueryPancakeInfinityLBReserveSuperCompact.queryPancakeInfinityLBReserve(
poolId
);
}
function queryZoraTicksSuperCompact(address coin, uint256 len) public view returns (bytes memory) {
return QueryZoraTicksSuperCompact.queryZoraTicksSuperCompact(coin, len, STATE_VIEW);
}
// General function for all v4 pools
function toId(IZoraCoin.PoolKey memory poolKey) public pure returns (bytes32 poolId) {
return QueryZoraTicksSuperCompact.toId(poolKey);
}
// Specifically for Zora
function getPoolKeyOfZora(address coin) public view returns (IZoraCoin.PoolKey memory) {
return QueryZoraTicksSuperCompact.getPoolKeyOfZora(coin);
}
// Specifically for Zora
function getSlot0OfZora(address coin)
public
view
returns (int256 liquidity, uint160 sqrtPriceX96, int24 tick, uint24 protocolFee, uint24 lpFee)
{
return QueryZoraTicksSuperCompact.getSlot0OfZora(coin, POOL_MANAGER);
}
// Specifically for Fluid
function queryFluid(address pool, uint256 dexVariables) public view returns (uint256 centerPrice, uint256 rangeShift, uint256 thresholdShift, uint256 centerPriceShift) {
return QueryFluid.queryFluid(pool, dexVariables);
}
// Specifically for FluidLite
function queryFluidLite(bytes8 dexId) public view returns (QueryFluidLite.DexKey memory dexKey, uint256 centerPrice, uint256 dexVariables, uint256 rangeShift, uint256 thresholdShift, uint256 centerPriceShift) {
return QueryFluidLite.queryFluidLite(FLUID_LITE_DEX, FLUID_LITE_DEPLOYER_CONTRACT, dexId);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)
pragma solidity ^0.8.0;
import "../utils/ContextUpgradeable.sol";
import "../proxy/utils/Initializable.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
function __Ownable_init() internal onlyInitializing {
__Ownable_init_unchained();
}
function __Ownable_init_unchained() internal onlyInitializing {
_transferOwnership(_msgSender());
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[49] private __gap;
}interface IAlgebraPool {
function globalState()
external
view
returns (
uint160 price,
int24 tick,
int24 prevInitializedTick,
uint16 fee,
uint16 timepointIndex,
uint8 communityFee,
bool unlocked
);
function tickSpacing() external view returns (int24);
function ticks(int24 tick)
external
view
returns (
uint128 liquidityTotal,
int128 liquidityDelta,
uint256 outerFeeGrowth0Token,
uint256 outerFeeGrowth1Token,
int24 prevTick,
int24 nextTick,
uint160 outerSecondsPerLiquidity,
uint32 outerSecondsSpent,
bool hasLimitOrders
);
function tickTable(int16 wordPosition) external view returns (uint256);
function prevInitializedTick() external view returns (int24);
}
interface IAlgebraPoolV1_9 {
function globalState()
external
view
returns (
uint160 price,
int24 tick,
int24 prevInitializedTick,
uint16 fee,
uint16 timepointIndex,
uint8 communityFee,
bool unlocked
);
function tickSpacing() external view returns (int24);
function ticks(int24 tick)
external
view
returns (
uint128 liquidityTotal,
int128 liquidityDelta,
uint256 outerFeeGrowth0Token,
uint256 outerFeeGrowth1Token,
int56 outerTickCumulative,
uint160 outerSecondsPerLiquidity,
uint32 outerSecondsSpent,
bool initialized
);
function tickTable(int16 wordPosition) external view returns (uint256);
}/// @notice Tick info library for Pancake Infinity
library Tick {
struct Info {
uint128 liquidityGross;
int128 liquidityNet;
uint256 feeGrowthOutside0X128;
uint256 feeGrowthOutside1X128;
}
}
interface ICLPoolManager {
type PoolId is bytes32;
/// @notice Get the tick info about a specific tick in the pool
function getPoolTickInfo(PoolId id, int24 tick) external view returns (Tick.Info memory);
/// @notice Get the tick bitmap info about a specific range (a word range) in the pool
function getPoolBitmapInfo(PoolId id, int16 word) external view returns (uint256 tickBitmap);
/// @notice Get Slot0 of the pool: sqrtPriceX96, tick, protocolFee, lpFee
function getSlot0(PoolId id)
external
view
returns (uint160 sqrtPriceX96, int24 tick, uint24 protocolFee, uint24 lpFee);
}interface IHooks {}interface IHorizonPool {
function tickDistance() external view returns (int24);
function ticks(int24 tick)
external
view
returns (
uint128 liquidityGross,
int128 liquidityNet,
uint256 feeGrowthOutside,
uint128 secondsPerLiquidityOutside
);
function initializedTicks(int24 tick) external view returns (int24 previous, int24 next);
function getPoolState()
external
view
returns (uint160 sqrtP, int24 currentTick, int24 nearestCurrentTick, bool locked);
}interface IPoolManager {
function extsload(bytes32 startSlot, uint256 nSlots) external view returns (bytes32[] memory);
}import "./IHooks.sol";
interface IPositionManager {
type Currency is address;
/// @notice Returns the key for identifying a pool
struct PoolKey {
/// @notice The lower currency of the pool, sorted numerically
Currency currency0;
/// @notice The higher currency of the pool, sorted numerically
Currency currency1;
/// @notice The pool LP fee, capped at 1_000_000. If the highest bit is 1, the pool has a dynamic fee and must be exactly equal to 0x800000
uint24 fee;
/// @notice Ticks that involve positions must be a multiple of tick spacing
int24 tickSpacing;
/// @notice The hooks of the pool
IHooks hooks;
}
function poolKeys(bytes25 poolId) external view returns (PoolKey memory);
}interface IStateView {
type PoolId is bytes32;
/// @notice Retrieves the tick bitmap of a pool at a specific tick.
/// @dev Corresponds to pools[poolId].tickBitmap[tick]
/// @param poolId The ID of the pool.
/// @param tick The tick to retrieve the bitmap for.
/// @return tickBitmap The bitmap of the tick.
function getTickBitmap(PoolId poolId, int16 tick) external view returns (uint256 tickBitmap);
/// @notice Retrieves the liquidity information of a pool at a specific tick.
/// @dev Corresponds to pools[poolId].ticks[tick].liquidityGross and pools[poolId].ticks[tick].liquidityNet. A more gas efficient version of getTickInfo
/// @param poolId The ID of the pool.
/// @param tick The tick to retrieve liquidity for.
/// @return liquidityGross The total position liquidity that references this tick
/// @return liquidityNet The amount of net liquidity added (subtracted) when tick is crossed from left to right (right to left)
function getTickLiquidity(PoolId poolId, int24 tick)
external
view
returns (uint128 liquidityGross, int128 liquidityNet);
/// @notice Get Slot0 of the pool: sqrtPriceX96, tick, protocolFee, lpFee
/// @dev Corresponds to pools[poolId].slot0
/// @param poolId The ID of the pool.
/// @return sqrtPriceX96 The square root of the price of the pool, in Q96 precision.
/// @return tick The current tick of the pool.
/// @return protocolFee The protocol fee of the pool.
/// @return lpFee The swap fee of the pool.
function getSlot0(PoolId poolId)
external
view
returns (uint160 sqrtPriceX96, int24 tick, uint24 protocolFee, uint24 lpFee);
}import "./IUniswapV3PoolImmutables.sol";
import "./IUniswapV3PoolState.sol";
/// @title The interface for a Uniswap V3 Pool
/// @notice A Uniswap pool facilitates swapping and automated market making between any two assets that strictly conform
/// to the ERC20 specification
/// @dev The pool interface is broken up into many smaller pieces
interface IUniswapV3Pool is IUniswapV3PoolImmutables, IUniswapV3PoolState {}import "./IHooks.sol";
interface IZoraCoin {
type Currency is address;
struct PoolKey {
/// @notice The lower currency of the pool, sorted numerically
Currency currency0;
/// @notice The higher currency of the pool, sorted numerically
Currency currency1;
/// @notice The pool LP fee, capped at 1_000_000. If the highest bit is 1, the pool has a dynamic fee and must be exactly equal to 0x800000
uint24 fee;
/// @notice Ticks that involve positions must be a multiple of tick spacing
int24 tickSpacing;
/// @notice The hooks of the pool
IHooks hooks;
}
function getPoolKey() external view returns (PoolKey memory);
}interface IZumiPool {
function points(int24 tick) external view returns (uint256, int128, uint256, uint256, bool);
function pointDelta() external view returns (int24);
function orderOrEndpoint(int24 tick) external view returns (int24);
function limitOrderData(int24 point)
external
view
returns (
uint128 sellingX,
uint128 earnY,
uint256 accEarnY,
uint256 legacyAccEarnY,
uint128 legacyEarnY,
uint128 sellingY,
uint128 earnX,
uint128 legacyEarnX,
uint256 accEarnX,
uint256 legacyAccEarnX
);
function pointBitmap(int16 tick) external view returns (uint256);
function factory() external view returns (address);
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;
import "../interface/IAlgebraPool.sol";
import "../interface/ICLPoolManager.sol";
import "../interface/IHooks.sol";
import "../interface/IHorizonPool.sol";
import "../interface/IPoolManager.sol";
import "../interface/IPositionManager.sol";
import "../interface/IStateView.sol";
import "../interface/IUniswapV3Pool.sol";
import "../interface/IZora.sol";
import "../interface/IZumiPool.sol";
library QueryUniv3TicksSuperCompact {
struct SuperVar {
int24 tickSpacing;
int24 currTick;
int24 right;
int24 left;
int24 leftMost;
int24 rightMost;
uint256 initPoint;
uint256 initPoint2;
}
function queryUniv3TicksSuperCompact(address pool, uint256 len) public view returns (bytes memory) {
SuperVar memory tmp;
tmp.tickSpacing = IUniswapV3Pool(pool).tickSpacing();
// fix-bug: pancake pool's slot returns different types of params than uniV3, which will cause problem
{
(, bytes memory slot0) = pool.staticcall(abi.encodeWithSignature("slot0()"));
int24 currTick;
assembly {
currTick := mload(add(slot0, 64))
}
tmp.currTick = currTick;
}
tmp.right = tmp.currTick / tmp.tickSpacing / int24(256);
tmp.leftMost = -887_272 / tmp.tickSpacing / int24(256) - 2;
tmp.rightMost = 887_272 / tmp.tickSpacing / int24(256) + 1;
if (tmp.currTick < 0) {
tmp.initPoint = uint256(
int256(tmp.currTick) / int256(tmp.tickSpacing)
- (int256(tmp.currTick) / int256(tmp.tickSpacing) / 256 - 1) * 256
) % 256;
} else {
tmp.initPoint = (uint256(int256(tmp.currTick)) / uint256(int256(tmp.tickSpacing))) % 256;
}
tmp.initPoint2 = tmp.initPoint;
if (tmp.currTick < 0) tmp.right--;
bytes memory tickInfo;
tmp.left = tmp.right;
uint256 index = 0;
while (index < len / 2 && tmp.right < tmp.rightMost) {
uint256 res = IUniswapV3Pool(pool).tickBitmap(int16(tmp.right));
if (res > 0) {
res = res >> tmp.initPoint;
for (uint256 i = tmp.initPoint; i < 256 && index < len / 2; i++) {
uint256 isInit = res & 0x01;
if (isInit > 0) {
int256 tick = int256((256 * tmp.right + int256(i)) * tmp.tickSpacing);
// (, int128 liquidityNet,,,,,,) = IUniswapV3Pool(pool).ticks(int24(int256(tick)));
// fix-bug: to make consistent with solidlyV3 and ramsesV2
int128 liquidityNet;
(, bytes memory d) = pool.staticcall(
abi.encodeWithSelector(IUniswapV3PoolState.ticks.selector, int24(int256(tick)))
);
assembly {
liquidityNet := mload(add(d, 64))
}
int256 data = int256(uint256(int256(tick)) << 128)
+ (int256(liquidityNet) & 0x00000000000000000000000000000000ffffffffffffffffffffffffffffffff);
tickInfo = bytes.concat(tickInfo, bytes32(uint256(data)));
index++;
}
res = res >> 1;
}
}
tmp.initPoint = 0;
tmp.right++;
}
bool isInitPoint = true;
while (index < len && tmp.left > tmp.leftMost) {
uint256 res = IUniswapV3Pool(pool).tickBitmap(int16(tmp.left));
if (res > 0 && tmp.initPoint2 != 0) {
res = isInitPoint ? res << ((256 - tmp.initPoint2) % 256) : res;
for (uint256 i = tmp.initPoint2 - 1; i >= 0 && index < len; i--) {
uint256 isInit = res & 0x8000000000000000000000000000000000000000000000000000000000000000;
if (isInit > 0) {
int256 tick = int256((256 * tmp.left + int256(i)) * tmp.tickSpacing);
// (, int128 liquidityNet,,,,,,) = IUniswapV3Pool(pool).ticks(int24(int256(tick)));
// fix-bug: to make consistent with solidlyV3 and ramsesV2
int128 liquidityNet;
(, bytes memory d) = pool.staticcall(
abi.encodeWithSelector(IUniswapV3PoolState.ticks.selector, int24(int256(tick)))
);
assembly {
liquidityNet := mload(add(d, 64))
}
int256 data = int256(uint256(int256(tick)) << 128)
+ (int256(liquidityNet) & 0x00000000000000000000000000000000ffffffffffffffffffffffffffffffff);
tickInfo = bytes.concat(tickInfo, bytes32(uint256(data)));
index++;
}
res = res << 1;
if (i == 0) break;
}
}
isInitPoint = false;
tmp.initPoint2 = 256;
tmp.left--;
}
return tickInfo;
}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;
import "../interface/IAlgebraPool.sol";
import "../interface/ICLPoolManager.sol";
import "../interface/IHooks.sol";
import "../interface/IHorizonPool.sol";
import "../interface/IPoolManager.sol";
import "../interface/IPositionManager.sol";
import "../interface/IStateView.sol";
import "../interface/IUniswapV3Pool.sol";
import "../interface/IZora.sol";
import "../interface/IZumiPool.sol";
library QueryAlgebraTicksSuperCompact {
int24 internal constant MIN_TICK_MINUS_1 = -887_272 - 1;
int24 internal constant MAX_TICK_PLUS_1 = 887_272 + 1;
struct SuperVar {
int24 tickSpacing;
int24 currTick;
int24 right;
int24 left;
int24 leftMost;
int24 rightMost;
uint256 initPoint;
uint256 initPoint2;
}
function queryAlgebraTicksSuperCompact(address pool, uint256 len) public view returns (bytes memory) {
SuperVar memory tmp;
{
(, bytes memory slot0) = pool.staticcall(abi.encodeWithSignature("globalState()"));
int24 currTick;
assembly {
currTick := mload(add(slot0, 64))
}
tmp.currTick = currTick;
}
tmp.right = tmp.currTick / int24(256);
tmp.leftMost = -887_272 / int24(256) - 2;
tmp.rightMost = 887_272 / int24(256) + 1;
if (tmp.currTick < 0) {
tmp.initPoint = (256 - (uint256(int256(-tmp.currTick)) % 256)) % 256;
} else {
tmp.initPoint = uint256(int256(tmp.currTick)) % 256;
}
tmp.initPoint2 = tmp.initPoint;
if (tmp.currTick < 0) tmp.right--;
bytes memory tickInfo;
tmp.left = tmp.right;
uint256 index = 0;
while (index < len / 2 && tmp.right < tmp.rightMost) {
uint256 res = IAlgebraPoolV1_9(pool).tickTable(int16(tmp.right));
if (res > 0) {
res = res >> tmp.initPoint;
for (uint256 i = tmp.initPoint; i < 256 && index < len / 2; i++) {
uint256 isInit = res & 0x01;
if (isInit > 0) {
int256 tick = int256((256 * tmp.right + int256(i)));
// (, int128 liquidityNet,,,,,,) = IAlgebraPoolV1_9(pool).ticks(int24(int256(tick)));
(, bytes memory deltaL) = pool.staticcall(abi.encodeWithSignature("ticks(int24)", tick));
int128 liquidityNet;
assembly {
liquidityNet := mload(add(deltaL, 64))
}
int256 data = int256(uint256(int256(tick)) << 128)
+ (int256(liquidityNet) & 0x00000000000000000000000000000000ffffffffffffffffffffffffffffffff);
tickInfo = bytes.concat(tickInfo, bytes32(uint256(data)));
index++;
}
res = res >> 1;
}
}
tmp.initPoint = 0;
tmp.right++;
}
bool isInitPoint = true;
while (index < len && tmp.left > tmp.leftMost) {
uint256 res = IAlgebraPoolV1_9(pool).tickTable(int16(tmp.left));
if (res > 0 && tmp.initPoint2 != 0) {
res = isInitPoint ? res << ((256 - tmp.initPoint2) % 256) : res;
for (uint256 i = tmp.initPoint2 - 1; i >= 0 && index < len; i--) {
uint256 isInit = res & 0x8000000000000000000000000000000000000000000000000000000000000000;
if (isInit > 0) {
int256 tick = int256((256 * tmp.left + int256(i)));
// (, int128 liquidityNet,,,,,,) = IAlgebraPoolV1_9(pool).ticks(int24(int256(tick)));
(, bytes memory deltaL) = pool.staticcall(abi.encodeWithSignature("ticks(int24)", tick));
int128 liquidityNet;
assembly {
liquidityNet := mload(add(deltaL, 64))
}
int256 data = int256(uint256(int256(tick)) << 128)
+ (int256(liquidityNet) & 0x00000000000000000000000000000000ffffffffffffffffffffffffffffffff);
tickInfo = bytes.concat(tickInfo, bytes32(uint256(data)));
index++;
}
res = res << 1;
if (i == 0) break;
}
}
isInitPoint = false;
tmp.initPoint2 = 256;
tmp.left--;
}
return tickInfo;
}
function queryAlgebraTicksSuperCompact2(address pool, uint256 iteration) public view returns (bytes memory) {
int24 currTick;
{
(bool s, bytes memory res) = pool.staticcall(abi.encodeWithSignature("prevInitializedTick()"));
if (s) {
currTick = abi.decode(res, (int24));
} else {
(s, res) = pool.staticcall(abi.encodeWithSignature("globalState()"));
if (s) {
assembly {
currTick := mload(add(res, 96))
}
}
}
}
int24 currTick2 = currTick;
uint256 threshold = iteration / 2;
// travel from left to right
bytes memory tickInfo;
while (currTick < MAX_TICK_PLUS_1 && iteration > threshold) {
(, int128 liquidityNet,,, int24 prevTick, int24 nextTick,,,) = IAlgebraPool(pool).ticks(currTick);
int256 data = int256(uint256(int256(currTick)) << 128)
+ (int256(liquidityNet) & 0x00000000000000000000000000000000ffffffffffffffffffffffffffffffff);
tickInfo = bytes.concat(tickInfo, bytes32(uint256(data)));
if (currTick == nextTick) {
break;
}
currTick = nextTick;
iteration--;
}
while (currTick2 > MIN_TICK_MINUS_1 && iteration > 0) {
(, int128 liquidityNet,,, int24 prevTick, int24 nextTick,,,) = IAlgebraPool(pool).ticks(currTick2);
int256 data = int256(uint256(int256(currTick2)) << 128)
+ (int256(liquidityNet) & 0x00000000000000000000000000000000ffffffffffffffffffffffffffffffff);
tickInfo = bytes.concat(tickInfo, bytes32(uint256(data)));
if (currTick2 == prevTick) {
break;
}
currTick2 = prevTick;
iteration--;
}
return tickInfo;
}
function queryAlgebraTicksSuperCompact3_back(address pool, uint256 len) public view returns (bytes memory) {
SuperVar memory tmp;
tmp.tickSpacing = IAlgebraPool(pool).tickSpacing();
{
(, bytes memory slot0) = pool.staticcall(abi.encodeWithSignature("globalState()"));
int24 currTick;
assembly {
currTick := mload(add(slot0, 64))
}
tmp.currTick = currTick;
}
tmp.right = tmp.currTick / tmp.tickSpacing / int24(256);
tmp.leftMost = -887_272 / tmp.tickSpacing / int24(256) - 2;
tmp.rightMost = 887_272 / tmp.tickSpacing / int24(256) + 1;
if (tmp.currTick < 0) {
tmp.initPoint = uint256(
int256(tmp.currTick) / int256(tmp.tickSpacing)
- (int256(tmp.currTick) / int256(tmp.tickSpacing) / 256 - 1) * 256
) % 256;
} else {
tmp.initPoint = (uint256(int256(tmp.currTick)) / uint256(int256(tmp.tickSpacing))) % 256;
}
tmp.initPoint2 = tmp.initPoint;
if (tmp.currTick < 0) tmp.right--;
bytes memory tickInfo;
tmp.left = tmp.right;
uint256 index = 0;
while (index < len / 2 && tmp.right < tmp.rightMost) {
uint256 res = IAlgebraPoolV1_9(pool).tickTable(int16(tmp.right));
if (res > 0) {
res = res >> tmp.initPoint;
for (uint256 i = tmp.initPoint; i < 256 && index < len / 2; i++) {
uint256 isInit = res & 0x01;
if (isInit > 0) {
int256 tick = int256((256 * tmp.right + int256(i)) * tmp.tickSpacing);
// (, int128 liquidityNet,,,,,,) = IAlgebraPoolV1_9(pool).ticks(int24(int256(tick)));
(, bytes memory deltaL) = pool.staticcall(abi.encodeWithSignature("ticks(int24)", tick));
int128 liquidityNet;
assembly {
liquidityNet := mload(add(deltaL, 64))
}
int256 data = int256(uint256(int256(tick)) << 128)
+ (int256(liquidityNet) & 0x00000000000000000000000000000000ffffffffffffffffffffffffffffffff);
tickInfo = bytes.concat(tickInfo, bytes32(uint256(data)));
index++;
}
res = res >> 1;
}
}
tmp.initPoint = 0;
tmp.right++;
}
bool isInitPoint = true;
while (index < len && tmp.left > tmp.leftMost) {
uint256 res = IAlgebraPoolV1_9(pool).tickTable(int16(tmp.left));
if (res > 0 && tmp.initPoint2 != 0) {
res = isInitPoint ? res << ((256 - tmp.initPoint2) % 256) : res;
for (uint256 i = tmp.initPoint2 - 1; i >= 0 && index < len; i--) {
uint256 isInit = res & 0x8000000000000000000000000000000000000000000000000000000000000000;
if (isInit > 0) {
int256 tick = int256((256 * tmp.left + int256(i)) * tmp.tickSpacing);
// (, int128 liquidityNet,,,,,,) = IAlgebraPoolV1_9(pool).ticks(int24(int256(tick)));
(, bytes memory deltaL) = pool.staticcall(abi.encodeWithSignature("ticks(int24)", tick));
int128 liquidityNet;
assembly {
liquidityNet := mload(add(deltaL, 64))
}
int256 data = int256(uint256(int256(tick)) << 128)
+ (int256(liquidityNet) & 0x00000000000000000000000000000000ffffffffffffffffffffffffffffffff);
tickInfo = bytes.concat(tickInfo, bytes32(uint256(data)));
index++;
}
res = res << 1;
if (i == 0) break;
}
}
isInitPoint = false;
tmp.initPoint2 = 256;
tmp.left--;
}
return tickInfo;
}
function queryAlgebraTicksSuperCompact3(address pool, uint256 len) public view returns (bytes memory) {
SuperVar memory tmp;
tmp.tickSpacing = 1;
{
(, bytes memory slot0) = pool.staticcall(abi.encodeWithSignature("globalState()"));
int24 currTick;
assembly {
currTick := mload(add(slot0, 64))
}
tmp.currTick = currTick;
}
int24 step = int24(int256(len)) * 200;
tmp.right = tmp.currTick / tmp.tickSpacing / int24(256);
tmp.leftMost = (tmp.currTick - step) / tmp.tickSpacing / int24(256) - 2;
tmp.rightMost = (tmp.currTick + step) / tmp.tickSpacing / int24(256) + 1;
if (tmp.currTick < 0) {
tmp.initPoint = uint256(
int256(tmp.currTick) / int256(tmp.tickSpacing)
- (int256(tmp.currTick) / int256(tmp.tickSpacing) / 256 - 1) * 256
) % 256;
} else {
tmp.initPoint = (uint256(int256(tmp.currTick)) / uint256(int256(tmp.tickSpacing))) % 256;
}
tmp.initPoint2 = tmp.initPoint;
if (tmp.currTick < 0) tmp.right--;
bytes memory tickInfo;
tmp.left = tmp.right;
uint256 index = 0;
while (index < len / 2 && tmp.right < tmp.rightMost) {
uint256 res = IAlgebraPoolV1_9(pool).tickTable(int16(tmp.right));
if (res > 0) {
res = res >> tmp.initPoint;
for (uint256 i = tmp.initPoint; i < 256 && index < len / 2; i++) {
uint256 isInit = res & 0x01;
if (isInit > 0) {
int256 tick = int256((256 * tmp.right + int256(i)) * tmp.tickSpacing);
// (, int128 liquidityNet,,,,,,) = IAlgebraPoolV1_9(pool).ticks(int24(int256(tick)));
(, bytes memory deltaL) = pool.staticcall(abi.encodeWithSignature("ticks(int24)", tick));
int128 liquidityNet;
assembly {
liquidityNet := mload(add(deltaL, 64))
}
int256 data = int256(uint256(int256(tick)) << 128)
+ (int256(liquidityNet) & 0x00000000000000000000000000000000ffffffffffffffffffffffffffffffff);
tickInfo = bytes.concat(tickInfo, bytes32(uint256(data)));
index++;
}
res = res >> 1;
}
}
tmp.initPoint = 0;
tmp.right++;
}
bool isInitPoint = true;
while (index < len && tmp.left > tmp.leftMost) {
uint256 res = IAlgebraPoolV1_9(pool).tickTable(int16(tmp.left));
if (res > 0 && tmp.initPoint2 != 0) {
res = isInitPoint ? res << ((256 - tmp.initPoint2) % 256) : res;
for (uint256 i = tmp.initPoint2 - 1; i >= 0 && index < len; i--) {
uint256 isInit = res & 0x8000000000000000000000000000000000000000000000000000000000000000;
if (isInit > 0) {
int256 tick = int256((256 * tmp.left + int256(i)) * tmp.tickSpacing);
// (, int128 liquidityNet,,,,,,) = IAlgebraPoolV1_9(pool).ticks(int24(int256(tick)));
(, bytes memory deltaL) = pool.staticcall(abi.encodeWithSignature("ticks(int24)", tick));
int128 liquidityNet;
assembly {
liquidityNet := mload(add(deltaL, 64))
}
int256 data = int256(uint256(int256(tick)) << 128)
+ (int256(liquidityNet) & 0x00000000000000000000000000000000ffffffffffffffffffffffffffffffff);
tickInfo = bytes.concat(tickInfo, bytes32(uint256(data)));
index++;
}
res = res << 1;
if (i == 0) break;
}
}
isInitPoint = false;
tmp.initPoint2 = 256;
tmp.left--;
}
return tickInfo;
}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;
import "../interface/IAlgebraPool.sol";
import "../interface/ICLPoolManager.sol";
import "../interface/IHooks.sol";
import "../interface/IHorizonPool.sol";
import "../interface/IPoolManager.sol";
import "../interface/IPositionManager.sol";
import "../interface/IStateView.sol";
import "../interface/IUniswapV3Pool.sol";
import "../interface/IZora.sol";
import "../interface/IZumiPool.sol";
library QueryHorizonTicksSuperCompact {
int24 internal constant MIN_TICK_MINUS_1 = -887_272 - 1;
int24 internal constant MAX_TICK_PLUS_1 = 887_272 + 1;
struct SuperVar {
int24 tickSpacing;
int24 currTick;
int24 right;
int24 left;
int24 leftMost;
int24 rightMost;
uint256 initPoint;
uint256 initPoint2;
}
function queryHorizonTicksSuperCompact(address pool, uint256 len) public view returns (bytes memory) {
(,, int24 currTick,) = IHorizonPool(pool).getPoolState();
int24 currTick2 = currTick;
uint256 threshold = len / 2;
// travel from left to right
bytes memory tickInfo;
while (currTick < MAX_TICK_PLUS_1 && len > threshold) {
(, int128 liquidityNet,,) = IHorizonPool(pool).ticks(currTick);
int256 data = int256(uint256(int256(currTick)) << 128)
+ (int256(liquidityNet) & 0x00000000000000000000000000000000ffffffffffffffffffffffffffffffff);
tickInfo = bytes.concat(tickInfo, bytes32(uint256(data)));
(, int24 nextTick) = IHorizonPool(pool).initializedTicks(currTick);
if (currTick == nextTick) {
break;
}
currTick = nextTick;
len--;
}
while (currTick2 > MIN_TICK_MINUS_1 && len > 0) {
(, int128 liquidityNet,,) = IHorizonPool(pool).ticks(currTick2);
int256 data = int256(uint256(int256(currTick2)) << 128)
+ (int256(liquidityNet) & 0x00000000000000000000000000000000ffffffffffffffffffffffffffffffff);
tickInfo = bytes.concat(tickInfo, bytes32(uint256(data)));
(int24 prevTick,) = IHorizonPool(pool).initializedTicks(currTick2);
if (prevTick == currTick2) {
break;
}
currTick2 = prevTick;
len--;
}
return tickInfo;
}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;
import "../interface/IAlgebraPool.sol";
import "../interface/ICLPoolManager.sol";
import "../interface/IHooks.sol";
import "../interface/IHorizonPool.sol";
import "../interface/IPoolManager.sol";
import "../interface/IPositionManager.sol";
import "../interface/IStateView.sol";
import "../interface/IUniswapV3Pool.sol";
import "../interface/IZora.sol";
import "../interface/IZumiPool.sol";
library QueryIzumiSuperCompact {
int24 internal constant MIN_TICK_MINUS_1 = -887_272 - 1;
int24 internal constant MAX_TICK_PLUS_1 = 887_272 + 1;
struct SuperVar {
int24 tickSpacing;
int24 currTick;
int24 right;
int24 left;
int24 leftMost;
int24 rightMost;
uint256 initPoint;
uint256 initPoint2;
}
function queryIzumiSuperCompact(address pool, uint256 len) public view returns (bytes memory, bytes memory) {
SuperVar memory tmp;
tmp.tickSpacing = IZumiPool(pool).pointDelta();
{
(, bytes memory slot0) = pool.staticcall(abi.encodeWithSignature("state()"));
int24 currTick;
assembly {
currTick := mload(add(slot0, 64))
}
tmp.currTick = currTick;
}
tmp.right = tmp.currTick / tmp.tickSpacing / int24(256);
tmp.leftMost = -887_272 / tmp.tickSpacing / int24(256) - 2;
tmp.rightMost = 887_272 / tmp.tickSpacing / int24(256) + 1;
if (tmp.currTick < 0) {
tmp.initPoint = uint256(
int256(tmp.currTick) / int256(tmp.tickSpacing)
- (int256(tmp.currTick) / int256(tmp.tickSpacing) / 256 - 1) * 256
) % 256;
} else {
tmp.initPoint = (uint256(int256(tmp.currTick)) / uint256(int256(tmp.tickSpacing))) % 256;
}
tmp.initPoint2 = tmp.initPoint;
if (tmp.currTick < 0) tmp.right--;
bytes memory tickInfo;
bytes memory limitOrderInfo;
tmp.left = tmp.right;
uint256 index = 0;
while (index < len / 2 && tmp.right < tmp.rightMost) {
uint256 res = IZumiPool(pool).pointBitmap(int16(tmp.right));
if (res > 0) {
res = res >> tmp.initPoint;
for (uint256 i = tmp.initPoint; i < 256; i++) {
uint256 isInit = res & 0x01;
if (isInit > 0) {
int24 tick = int24(int256((256 * tmp.right + int256(i)) * tmp.tickSpacing));
int24 orderOrEndpoint = IZumiPool(pool).orderOrEndpoint(tick / tmp.tickSpacing);
if (orderOrEndpoint & 0x01 == 0x01) {
(, int128 liquidityNet,,,) = IZumiPool(pool).points(tick);
if (liquidityNet != 0) {
int256 data = int256(uint256(int256(tick)) << 128)
+ (
int256(liquidityNet)
& 0x00000000000000000000000000000000ffffffffffffffffffffffffffffffff
);
tickInfo = bytes.concat(tickInfo, bytes32(uint256(data)));
index++;
}
}
if (orderOrEndpoint & 0x02 == 0x02) {
(uint128 sellingX,,,,, uint128 sellingY,,,,) = IZumiPool(pool).limitOrderData(tick);
if (sellingX != 0 || sellingY != 0) {
bytes32 data =
bytes32(abi.encodePacked(int32(tick), uint112(sellingX), uint112(sellingY)));
limitOrderInfo = bytes.concat(limitOrderInfo, data);
index++;
}
}
}
res = res >> 1;
}
}
tmp.initPoint = 0;
tmp.right++;
}
bool isInitPoint = true;
while (index < len && tmp.left > tmp.leftMost) {
uint256 res = IZumiPool(pool).pointBitmap(int16(tmp.left));
if (res > 0 && tmp.initPoint2 != 0) {
res = isInitPoint ? res << ((256 - tmp.initPoint2) % 256) : res;
for (uint256 i = tmp.initPoint2 - 1; i >= 0 && index < len; i--) {
uint256 isInit = res & 0x8000000000000000000000000000000000000000000000000000000000000000;
if (isInit > 0) {
int24 tick = int24(int256((256 * tmp.left + int256(i)) * tmp.tickSpacing));
int24 orderOrEndpoint = IZumiPool(pool).orderOrEndpoint(tick / tmp.tickSpacing);
if (orderOrEndpoint & 0x01 == 0x01) {
(, int128 liquidityNet,,,) = IZumiPool(pool).points(tick);
if (liquidityNet != 0) {
int256 data = int256(uint256(int256(tick)) << 128)
+ (
int256(liquidityNet)
& 0x00000000000000000000000000000000ffffffffffffffffffffffffffffffff
);
tickInfo = bytes.concat(tickInfo, bytes32(uint256(data)));
index++;
}
}
if (orderOrEndpoint & 0x02 == 0x02) {
(uint128 sellingX,,,,, uint128 sellingY,,,,) = IZumiPool(pool).limitOrderData(tick);
if (sellingX != 0 || sellingY != 0) {
bytes32 data =
bytes32(abi.encodePacked(int32(tick), uint112(sellingX), uint112(sellingY)));
limitOrderInfo = bytes.concat(limitOrderInfo, data);
index++;
}
}
}
res = res << 1;
if (i == 0) break;
}
}
isInitPoint = false;
tmp.initPoint2 = 256;
tmp.left--;
}
return (tickInfo, limitOrderInfo);
}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;
import "../interface/IAlgebraPool.sol";
import "../interface/ICLPoolManager.sol";
import "../interface/IHooks.sol";
import "../interface/IHorizonPool.sol";
import "../interface/IPoolManager.sol";
import "../interface/IPositionManager.sol";
import "../interface/IStateView.sol";
import "../interface/IUniswapV3Pool.sol";
import "../interface/IZora.sol";
import "../interface/IZumiPool.sol";
library QueryUniv4TicksSuperCompact {
address public constant PANCAKE_INFINITY_CLPOOLMANAGER = 0xa0FfB9c1CE1Fe56963B0321B32E7A0302114058b;
address public constant PANCAKE_INFINITY_POSITION_MANAGER = 0x55f4c8abA71A1e923edC303eb4fEfF14608cC226;
uint256 internal constant OFFSET_TICK_SPACING = 16;
struct SuperVar {
int24 tickSpacing;
int24 currTick;
int24 right;
int24 left;
int24 leftMost;
int24 rightMost;
uint256 initPoint;
uint256 initPoint2;
}
function getTickSpacing(bytes32 params) internal pure returns (int24 tickSpacing) {
assembly {
tickSpacing := and(shr(OFFSET_TICK_SPACING, params), 0xffffff)
}
}
function queryUniv4TicksSuperCompact(
bytes32 poolId,
uint256 len,
address STATE_VIEW,
address POSITION_MANAGER
) public view returns (bytes memory) {
SuperVar memory tmp;
IPositionManager.PoolKey memory poolkey = IPositionManager(POSITION_MANAGER).poolKeys(bytes25(poolId));
tmp.tickSpacing = poolkey.tickSpacing;
IStateView.PoolId statePoolId = IStateView.PoolId.wrap(poolId);
{
(uint160 sqrtPriceX96, int24 tick, uint24 protocolFee, uint24 lpFee) =
IStateView(STATE_VIEW).getSlot0(statePoolId);
tmp.currTick = tick;
}
tmp.right = tmp.currTick / tmp.tickSpacing / int24(256);
tmp.leftMost = -887_272 / tmp.tickSpacing / int24(256) - 2;
tmp.rightMost = 887_272 / tmp.tickSpacing / int24(256) + 1;
if (tmp.currTick < 0) {
tmp.initPoint = uint256(
int256(tmp.currTick) / int256(tmp.tickSpacing)
- (int256(tmp.currTick) / int256(tmp.tickSpacing) / 256 - 1) * 256
) % 256;
} else {
tmp.initPoint = (uint256(int256(tmp.currTick)) / uint256(int256(tmp.tickSpacing))) % 256;
}
tmp.initPoint2 = tmp.initPoint;
if (tmp.currTick < 0) tmp.right--;
bytes memory tickInfo;
tmp.left = tmp.right;
uint256 index = 0;
while (index < len / 2 && tmp.right < tmp.rightMost) {
uint256 res = IStateView(STATE_VIEW).getTickBitmap(statePoolId, int16(tmp.right));
if (res > 0) {
res = res >> tmp.initPoint;
for (uint256 i = tmp.initPoint; i < 256 && index < len / 2; i++) {
uint256 isInit = res & 0x01;
if (isInit > 0) {
int256 tick = int256((256 * tmp.right + int256(i)) * tmp.tickSpacing);
(uint128 liquidityGross, int128 liquidityNet) =
IStateView(STATE_VIEW).getTickLiquidity(statePoolId, int24(int256(tick)));
int256 data = int256(uint256(int256(tick)) << 128)
+ (int256(liquidityNet) & 0x00000000000000000000000000000000ffffffffffffffffffffffffffffffff);
tickInfo = bytes.concat(tickInfo, bytes32(uint256(data)));
index++;
}
res = res >> 1;
}
}
tmp.initPoint = 0;
tmp.right++;
}
bool isInitPoint = true;
while (index < len && tmp.left > tmp.leftMost) {
uint256 res = IStateView(STATE_VIEW).getTickBitmap(statePoolId, int16(tmp.left));
if (res > 0 && tmp.initPoint2 != 0) {
res = isInitPoint ? res << ((256 - tmp.initPoint2) % 256) : res;
for (uint256 i = tmp.initPoint2 - 1; i >= 0 && index < len; i--) {
uint256 isInit = res & 0x8000000000000000000000000000000000000000000000000000000000000000;
if (isInit > 0) {
int256 tick = int256((256 * tmp.left + int256(i)) * tmp.tickSpacing);
(uint128 liquidityGross, int128 liquidityNet) =
IStateView(STATE_VIEW).getTickLiquidity(statePoolId, int24(int256(tick)));
int256 data = int256(uint256(int256(tick)) << 128)
+ (int256(liquidityNet) & 0x00000000000000000000000000000000ffffffffffffffffffffffffffffffff);
tickInfo = bytes.concat(tickInfo, bytes32(uint256(data)));
index++;
}
res = res << 1;
if (i == 0) break;
}
}
isInitPoint = false;
tmp.initPoint2 = 256;
tmp.left--;
}
return tickInfo;
}
function queryUniv4TicksSuperCompactForNoPositionManager(
bytes32 poolId,
uint256 len,
address STATE_VIEW,
IPositionManager.PoolKey calldata poolkey
) public view returns (bytes memory) {
SuperVar memory tmp;
tmp.tickSpacing = poolkey.tickSpacing;
IStateView.PoolId statePoolId = IStateView.PoolId.wrap(poolId);
{
(uint160 sqrtPriceX96, int24 tick, uint24 protocolFee, uint24 lpFee) =
IStateView(STATE_VIEW).getSlot0(statePoolId);
tmp.currTick = tick;
}
tmp.right = tmp.currTick / tmp.tickSpacing / int24(256);
tmp.leftMost = -887_272 / tmp.tickSpacing / int24(256) - 2;
tmp.rightMost = 887_272 / tmp.tickSpacing / int24(256) + 1;
if (tmp.currTick < 0) {
tmp.initPoint = uint256(
int256(tmp.currTick) / int256(tmp.tickSpacing)
- (int256(tmp.currTick) / int256(tmp.tickSpacing) / 256 - 1) * 256
) % 256;
} else {
tmp.initPoint = (uint256(int256(tmp.currTick)) / uint256(int256(tmp.tickSpacing))) % 256;
}
tmp.initPoint2 = tmp.initPoint;
if (tmp.currTick < 0) tmp.right--;
bytes memory tickInfo;
tmp.left = tmp.right;
uint256 index = 0;
while (index < len / 2 && tmp.right < tmp.rightMost) {
uint256 res = IStateView(STATE_VIEW).getTickBitmap(statePoolId, int16(tmp.right));
if (res > 0) {
res = res >> tmp.initPoint;
for (uint256 i = tmp.initPoint; i < 256 && index < len / 2; i++) {
uint256 isInit = res & 0x01;
if (isInit > 0) {
int256 tick = int256((256 * tmp.right + int256(i)) * tmp.tickSpacing);
(uint128 liquidityGross, int128 liquidityNet) =
IStateView(STATE_VIEW).getTickLiquidity(statePoolId, int24(int256(tick)));
int256 data = int256(uint256(int256(tick)) << 128)
+ (int256(liquidityNet) & 0x00000000000000000000000000000000ffffffffffffffffffffffffffffffff);
tickInfo = bytes.concat(tickInfo, bytes32(uint256(data)));
index++;
}
res = res >> 1;
}
}
tmp.initPoint = 0;
tmp.right++;
}
bool isInitPoint = true;
while (index < len && tmp.left > tmp.leftMost) {
uint256 res = IStateView(STATE_VIEW).getTickBitmap(statePoolId, int16(tmp.left));
if (res > 0 && tmp.initPoint2 != 0) {
res = isInitPoint ? res << ((256 - tmp.initPoint2) % 256) : res;
for (uint256 i = tmp.initPoint2 - 1; i >= 0 && index < len; i--) {
uint256 isInit = res & 0x8000000000000000000000000000000000000000000000000000000000000000;
if (isInit > 0) {
int256 tick = int256((256 * tmp.left + int256(i)) * tmp.tickSpacing);
(uint128 liquidityGross, int128 liquidityNet) =
IStateView(STATE_VIEW).getTickLiquidity(statePoolId, int24(int256(tick)));
int256 data = int256(uint256(int256(tick)) << 128)
+ (int256(liquidityNet) & 0x00000000000000000000000000000000ffffffffffffffffffffffffffffffff);
tickInfo = bytes.concat(tickInfo, bytes32(uint256(data)));
index++;
}
res = res << 1;
if (i == 0) break;
}
}
isInitPoint = false;
tmp.initPoint2 = 256;
tmp.left--;
}
return tickInfo;
}
function queryPancakeInfinityTicksSuperCompact(
bytes32 poolId,
uint256 len
) public view returns (bytes memory) {
SuperVar memory tmp;
{
(, bytes memory result) = PANCAKE_INFINITY_POSITION_MANAGER.staticcall(
abi.encodeWithSignature("poolKeys(bytes25)", bytes25(poolId))
);
bytes32 parameters;
assembly {
// Skip currency0 (32), currency1 (32), hooks (32), poolManager (32), fee (32)
// Parameters is at offset 160 (32 * 5)
parameters := mload(add(result, 192))
}
tmp.tickSpacing = getTickSpacing(parameters);
}
ICLPoolManager.PoolId clPoolId = ICLPoolManager.PoolId.wrap(poolId);
{
(, int24 tick,,) = ICLPoolManager(PANCAKE_INFINITY_CLPOOLMANAGER).getSlot0(clPoolId);
tmp.currTick = tick;
}
tmp.right = tmp.currTick / tmp.tickSpacing / int24(256);
tmp.leftMost = -887_272 / tmp.tickSpacing / int24(256) - 2;
tmp.rightMost = 887_272 / tmp.tickSpacing / int24(256) + 1;
if (tmp.currTick < 0) {
tmp.initPoint = uint256(
int256(tmp.currTick) / int256(tmp.tickSpacing)
- (int256(tmp.currTick) / int256(tmp.tickSpacing) / 256 - 1) * 256
) % 256;
} else {
tmp.initPoint = (uint256(int256(tmp.currTick)) / uint256(int256(tmp.tickSpacing))) % 256;
}
tmp.initPoint2 = tmp.initPoint;
if (tmp.currTick < 0) tmp.right--;
bytes memory tickInfo;
tmp.left = tmp.right;
uint256 index = 0;
while (index < len / 2 && tmp.right < tmp.rightMost) {
uint256 res = ICLPoolManager(PANCAKE_INFINITY_CLPOOLMANAGER).getPoolBitmapInfo(clPoolId, int16(tmp.right));
if (res > 0) {
res = res >> tmp.initPoint;
for (uint256 i = tmp.initPoint; i < 256 && index < len / 2; i++) {
uint256 isInit = res & 0x01;
if (isInit > 0) {
int256 tick = int256((256 * tmp.right + int256(i)) * tmp.tickSpacing);
Tick.Info memory tickInfo_ = ICLPoolManager(PANCAKE_INFINITY_CLPOOLMANAGER).getPoolTickInfo(
clPoolId, int24(int256(tick))
);
int128 liquidityNet = tickInfo_.liquidityNet;
int256 data = int256(uint256(int256(tick)) << 128)
+ (int256(liquidityNet) & 0x00000000000000000000000000000000ffffffffffffffffffffffffffffffff);
tickInfo = bytes.concat(tickInfo, bytes32(uint256(data)));
index++;
}
res = res >> 1;
}
}
tmp.initPoint = 0;
tmp.right++;
}
bool isInitPoint = true;
while (index < len && tmp.left > tmp.leftMost) {
uint256 res = ICLPoolManager(PANCAKE_INFINITY_CLPOOLMANAGER).getPoolBitmapInfo(clPoolId, int16(tmp.left));
if (res > 0 && tmp.initPoint2 != 0) {
res = isInitPoint ? res << ((256 - tmp.initPoint2) % 256) : res;
for (uint256 i = tmp.initPoint2 - 1; i >= 0 && index < len; i--) {
uint256 isInit = res & 0x8000000000000000000000000000000000000000000000000000000000000000;
if (isInit > 0) {
int256 tick = int256((256 * tmp.left + int256(i)) * tmp.tickSpacing);
Tick.Info memory tickInfo_ = ICLPoolManager(PANCAKE_INFINITY_CLPOOLMANAGER).getPoolTickInfo(
clPoolId, int24(int256(tick))
);
int128 liquidityNet = tickInfo_.liquidityNet;
int256 data = int256(uint256(int256(tick)) << 128)
+ (int256(liquidityNet) & 0x00000000000000000000000000000000ffffffffffffffffffffffffffffffff);
tickInfo = bytes.concat(tickInfo, bytes32(uint256(data)));
index++;
}
res = res << 1;
if (i == 0) break;
}
}
isInitPoint = false;
tmp.initPoint2 = 256;
tmp.left--;
}
return tickInfo;
}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;
import "../interface/IAlgebraPool.sol";
import "../interface/ICLPoolManager.sol";
import "../interface/IHooks.sol";
import "../interface/IHorizonPool.sol";
import "../interface/IPoolManager.sol";
import "../interface/IPositionManager.sol";
import "../interface/IStateView.sol";
import "../interface/IUniswapV3Pool.sol";
import "../interface/IZora.sol";
import "../interface/IZumiPool.sol";
library QueryZoraTicksSuperCompact {
bytes32 internal constant POOLS_SLOT = bytes32(uint256(6));
struct SuperVar {
int24 tickSpacing;
int24 currTick;
int24 right;
int24 left;
int24 leftMost;
int24 rightMost;
uint256 initPoint;
uint256 initPoint2;
}
function queryZoraTicksSuperCompact(
address coin,
uint256 len,
address STATE_VIEW
) public view returns (bytes memory) {
SuperVar memory tmp;
IZoraCoin.PoolKey memory poolkey = IZoraCoin(coin).getPoolKey();
tmp.tickSpacing = poolkey.tickSpacing;
bytes32 poolId = toId(poolkey);
IStateView.PoolId statePoolId = IStateView.PoolId.wrap(poolId);
{
(uint160 sqrtPriceX96, int24 tick, uint24 protocolFee, uint24 lpFee) =
IStateView(STATE_VIEW).getSlot0(statePoolId);
tmp.currTick = tick;
}
tmp.right = tmp.currTick / tmp.tickSpacing / int24(256);
tmp.leftMost = -887_272 / tmp.tickSpacing / int24(256) - 2;
tmp.rightMost = 887_272 / tmp.tickSpacing / int24(256) + 1;
if (tmp.currTick < 0) {
tmp.initPoint = uint256(
int256(tmp.currTick) / int256(tmp.tickSpacing)
- (int256(tmp.currTick) / int256(tmp.tickSpacing) / 256 - 1) * 256
) % 256;
} else {
tmp.initPoint = (uint256(int256(tmp.currTick)) / uint256(int256(tmp.tickSpacing))) % 256;
}
tmp.initPoint2 = tmp.initPoint;
if (tmp.currTick < 0) tmp.right--;
bytes memory tickInfo;
tmp.left = tmp.right;
uint256 index = 0;
while (index < len / 2 && tmp.right < tmp.rightMost) {
uint256 res = IStateView(STATE_VIEW).getTickBitmap(statePoolId, int16(tmp.right));
if (res > 0) {
res = res >> tmp.initPoint;
for (uint256 i = tmp.initPoint; i < 256 && index < len / 2; i++) {
uint256 isInit = res & 0x01;
if (isInit > 0) {
int256 tick = int256((256 * tmp.right + int256(i)) * tmp.tickSpacing);
(uint128 liquidityGross, int128 liquidityNet) =
IStateView(STATE_VIEW).getTickLiquidity(statePoolId, int24(int256(tick)));
int256 data = int256(uint256(int256(tick)) << 128)
+ (int256(liquidityNet) & 0x00000000000000000000000000000000ffffffffffffffffffffffffffffffff);
tickInfo = bytes.concat(tickInfo, bytes32(uint256(data)));
index++;
}
res = res >> 1;
}
}
tmp.initPoint = 0;
tmp.right++;
}
bool isInitPoint = true;
while (index < len && tmp.left > tmp.leftMost) {
uint256 res = IStateView(STATE_VIEW).getTickBitmap(statePoolId, int16(tmp.left));
if (res > 0 && tmp.initPoint2 != 0) {
res = isInitPoint ? res << ((256 - tmp.initPoint2) % 256) : res;
for (uint256 i = tmp.initPoint2 - 1; i >= 0 && index < len; i--) {
uint256 isInit = res & 0x8000000000000000000000000000000000000000000000000000000000000000;
if (isInit > 0) {
int256 tick = int256((256 * tmp.left + int256(i)) * tmp.tickSpacing);
(uint128 liquidityGross, int128 liquidityNet) =
IStateView(STATE_VIEW).getTickLiquidity(statePoolId, int24(int256(tick)));
int256 data = int256(uint256(int256(tick)) << 128)
+ (int256(liquidityNet) & 0x00000000000000000000000000000000ffffffffffffffffffffffffffffffff);
tickInfo = bytes.concat(tickInfo, bytes32(uint256(data)));
index++;
}
res = res << 1;
if (i == 0) break;
}
}
isInitPoint = false;
tmp.initPoint2 = 256;
tmp.left--;
}
return tickInfo;
}
// General function for all v4 pools
function toId(IZoraCoin.PoolKey memory poolKey) public pure returns (bytes32 poolId) {
assembly ("memory-safe") {
// 0xa0 represents the total size of the poolKey struct (5 slots of 32 bytes)
poolId := keccak256(poolKey, 0xa0)
}
}
// Specifically for Zora
function getPoolKeyOfZora(address coin)
public
view
returns (IZoraCoin.PoolKey memory)
{
IZoraCoin.PoolKey memory poolKey = IZoraCoin(coin).getPoolKey();
return poolKey;
}
// Specifically for Zora
function getSlot0OfZora(address coin, address POOL_MANAGER)
public
view
returns (int256 liquidity, uint160 sqrtPriceX96, int24 tick, uint24 protocolFee, uint24 lpFee)
{
IZoraCoin.PoolKey memory poolKey = IZoraCoin(coin).getPoolKey();
bytes32 poolId = toId(poolKey);
bytes32 slot = _getPoolStateSlot(poolId);
bytes32[] memory slot0 = IPoolManager(POOL_MANAGER).extsload(slot, 4);
bytes32 data = slot0[0];
liquidity = int256(uint256(slot0[3]));
// 24 bits |24bits|24bits |24 bits|160 bits
// 0x000000 |000bb8|000000 |ffff75 |0000000000000000fe3aa841ba359daa0ea9eff7
// ---------- | fee |protocolfee | tick | sqrtPriceX96
assembly ("memory-safe") {
// bottom 160 bits of data
sqrtPriceX96 := and(data, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)
// next 24 bits of data
tick := signextend(2, shr(160, data))
// next 24 bits of data
protocolFee := and(shr(184, data), 0xFFFFFF)
// last 24 bits of data
lpFee := and(shr(208, data), 0xFFFFFF)
}
}
function _getPoolStateSlot(bytes32 poolId) internal pure returns (bytes32) {
return keccak256(abi.encodePacked(poolId, POOLS_SLOT));
}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;
import "../interface/IBinPoolManager.sol";
library QueryPancakeInfinityLBReserveSuperCompact {
address public constant PANCAKE_INFINITY_LBPOOLMANAGER = 0xC697d2898e0D09264376196696c51D7aBbbAA4a9;
function queryPancakeInfinityLBReserve(bytes32 poolId)
public
view
returns (uint256 totalReserveX, uint256 totalReserveY)
{
IBinPoolManager.PoolId lbPoolId = IBinPoolManager.PoolId.wrap(poolId);
uint24 minBinId = IBinPoolManager(PANCAKE_INFINITY_LBPOOLMANAGER).getNextNonEmptyBin(lbPoolId, false, 1);
uint24 maxBinId = IBinPoolManager(PANCAKE_INFINITY_LBPOOLMANAGER).getNextNonEmptyBin(lbPoolId, true, type(uint24).max);
(uint24 activeId, , ) = IBinPoolManager(PANCAKE_INFINITY_LBPOOLMANAGER).getSlot0(lbPoolId);
for (uint24 i = minBinId; i <= maxBinId; i++) {
(uint128 reserveX, uint128 reserveY,,) = IBinPoolManager(PANCAKE_INFINITY_LBPOOLMANAGER).getBin(lbPoolId, i);
if (i < activeId) {
totalReserveY += reserveY;
} else if (i > activeId) {
totalReserveX += reserveX;
} else {
// i == activeId
totalReserveX += reserveX;
totalReserveY += reserveY;
}
}
}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;
import "../interface/IFluid.sol";
library QueryFluid {
/*//////////////////////////////////////////////////////////////
CONSTANTS / IMMUTABLES
//////////////////////////////////////////////////////////////*/
uint256 internal constant X30 = 0x3fffffff;
/// @dev storage slot for range shift
uint256 internal constant DEX_RANGE_SHIFT_SLOT = 7;
/// @dev storage slot for threshold shift
uint256 internal constant DEX_THRESHOLD_SHIFT_SLOT = 8;
/// @dev storage slot for center price shift
uint256 internal constant DEX_CENTER_PRICE_SHIFT_SLOT = 9;
/*//////////////////////////////////////////////////////////////
External Functions
//////////////////////////////////////////////////////////////*/
function queryFluid(
address pool_,
uint256 dexVariables2_
) public view returns (uint256 centerPrice_, uint256 rangeShift_, uint256 thresholdShift_, uint256 centerPriceShift_) {
centerPrice_ = getCenterPrice(pool_, dexVariables2_);
(rangeShift_, thresholdShift_, centerPriceShift_) = getShiftStatus(pool_);
}
/*//////////////////////////////////////////////////////////////
Internal Functions
//////////////////////////////////////////////////////////////*/
/// @notice Retrieves the center price of the pool.
function getCenterPrice(
address pool_,
uint256 dexVariables2_
) internal view returns (uint256 centerPrice_) {
// Get deployerContract and shift address
IFluidDexT1.ConstantViews memory constantsView_ = IFluidDexT1(pool_).constantsView();
address deployerContract_ = constantsView_.deployerContract;
// centerPrice_ => center price hook
centerPrice_ = (dexVariables2_ >> 112) & X30;
// center price should be fetched from external source. For exmaple, in case of wstETH <> ETH pool,
// we would want the center price to be pegged to wstETH exchange rate into ETH
centerPrice_ = ICenterPriceOfFluid(AddressCalcs.addressCalc(deployerContract_, centerPrice_)).centerPrice();
}
/// @notice Retrieves the shift status of the pool.
function getShiftStatus(
address pool_
) internal view returns (
uint256 _rangeShift,
uint256 _thresholdShift,
uint256 _centerPriceShift
) {
IFluidDexT1.ConstantViews memory constantsView_ = IFluidDexT1(pool_).constantsView();
address shift_ = constantsView_.implementations.shift;
// read storage of variables.sol: https://etherscan.io/address/0x5B6B500981d7Faa8c83Be20514EA8067fbd42304#code#F7#L1
_rangeShift = IShifting(shift_).readFromStorage(bytes32(DEX_RANGE_SHIFT_SLOT));
_thresholdShift = IShifting(shift_).readFromStorage(bytes32(DEX_THRESHOLD_SHIFT_SLOT));
_centerPriceShift = IShifting(shift_).readFromStorage(bytes32(DEX_CENTER_PRICE_SHIFT_SLOT));
}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;
import { AddressCalcs } from "../interface/IFluid.sol";
import "../interface/IFluidLite.sol";
library QueryFluidLite {
// Copy from ConstantVariables of https://etherscan.io/address/0xBbcb91440523216e2b87052A99F69c604A7b6e00#code
/*//////////////////////////////////////////////////////////////
CONSTANTS / IMMUTABLES
//////////////////////////////////////////////////////////////*/
uint256 internal constant X19 = 0x7ffff;
struct DexKey {
address token0;
address token1;
bytes32 salt;
}
/*//////////////////////////////////////////////////////////////
External Functions
//////////////////////////////////////////////////////////////*/
function queryFluidLite(
address dex_,
address deployerContract_,
bytes8 dexId_
) public view returns (DexKey memory dexKey_, uint256 centerPrice_, uint256 dexVariables_, uint256 rangeShift_, uint256 thresholdShift_, uint256 centerPriceShift_) {
dexKey_ = getDexKey(dex_, dexId_);
centerPrice_ = getCenterPrice(dex_, deployerContract_, dexKey_);
(dexVariables_, rangeShift_, thresholdShift_, centerPriceShift_) = getShiftStatus(dex_, dexId_);
}
/*//////////////////////////////////////////////////////////////
Internal Functions
//////////////////////////////////////////////////////////////*/
/// @notice Retrieves the dexKey for a given dexId.
function getDexKey(address dex_, bytes8 dexId_) internal view returns (DexKey memory dexKey_) {
uint256 length_ = _readStorage(dex_, DexLiteSlotsLink.DEX_LITE_DEXES_LIST_SLOT);
bytes32 dataSlot_ = keccak256(abi.encode(DexLiteSlotsLink.DEX_LITE_DEXES_LIST_SLOT));
for (uint256 i = 0; i < length_; i++) {
uint256 offset_ = i * 3;
address token0_ = address(uint160(_readStorage(dex_, uint256(dataSlot_) + offset_)));
address token1_ = address(uint160(_readStorage(dex_, uint256(dataSlot_) + offset_ + 1)));
bytes32 salt_ = bytes32(_readStorage(dex_, uint256(dataSlot_) + offset_ + 2));
if (bytes8(keccak256(abi.encode(DexKey(token0_, token1_, salt_)))) == dexId_) {
return DexKey(token0_, token1_, salt_);
}
}
revert("DexKey not found");
}
/// @notice Retrieves the center price for a given dexId.
function getCenterPrice(address dex_, address deployerContract_, DexKey memory dexKey_) internal view returns (uint256 centerPrice_) {
bytes8 dexId_ = bytes8(keccak256(abi.encode(dexKey_)));
uint256 dexVariables_ = _readMappingStorage(dex_, DexLiteSlotsLink.DEX_LITE_DEX_VARIABLES_SLOT, dexId_);
centerPrice_ = ICenterPriceOfFluidLite(AddressCalcs.addressCalc(deployerContract_, ((dexVariables_ >> DexLiteSlotsLink.BITS_DEX_LITE_DEX_VARIABLES_CENTER_PRICE_CONTRACT_ADDRESS) & X19))).centerPrice(dexKey_.token0, dexKey_.token1);
}
/// @notice Retrieves the shift status for a given dexId.
function getShiftStatus(address dex_, bytes8 dexId_) internal view returns (uint256 dexVariables_,uint256 rangeShift_, uint256 thresholdShift_, uint256 centerPriceShift_) {
dexVariables_ = _readMappingStorage(dex_, DexLiteSlotsLink.DEX_LITE_DEX_VARIABLES_SLOT, dexId_);
rangeShift_ = _readMappingStorage(dex_, DexLiteSlotsLink.DEX_LITE_RANGE_SHIFT_SLOT, dexId_);
thresholdShift_ = _readMappingStorage(dex_, DexLiteSlotsLink.DEX_LITE_THRESHOLD_SHIFT_SLOT, dexId_);
centerPriceShift_ = _readMappingStorage(dex_, DexLiteSlotsLink.DEX_LITE_CENTER_PRICE_SHIFT_SLOT, dexId_);
}
function _readStorage(address dex_, uint256 slot_) internal view returns (uint256 value_) {
value_ = IFluidDexLite(dex_).readFromStorage(bytes32(slot_));
}
function _readMappingStorage(address dex_, uint256 baseSlot_, bytes8 key_) internal view returns (uint256 value_) {
bytes32 slot_ = DexLiteSlotsLink.calculateMappingStorageSlot(baseSlot_, key_);
value_ = IFluidDexLite(dex_).readFromStorage(slot_);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
import "../proxy/utils/Initializable.sol";
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract ContextUpgradeable is Initializable {
function __Context_init() internal onlyInitializing {
}
function __Context_init_unchained() internal onlyInitializing {
}
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[50] private __gap;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.1) (proxy/utils/Initializable.sol)
pragma solidity ^0.8.2;
import "../../utils/AddressUpgradeable.sol";
/**
* @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
* behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
* external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
* function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
*
* The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
* reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
* case an upgrade adds a module that needs to be initialized.
*
* For example:
*
* [.hljs-theme-light.nopadding]
* ```
* contract MyToken is ERC20Upgradeable {
* function initialize() initializer public {
* __ERC20_init("MyToken", "MTK");
* }
* }
* contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
* function initializeV2() reinitializer(2) public {
* __ERC20Permit_init("MyToken");
* }
* }
* ```
*
* TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
* possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
*
* CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
* that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
*
* [CAUTION]
* ====
* Avoid leaving a contract uninitialized.
*
* An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
* contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
* the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
*
* [.hljs-theme-light.nopadding]
* ```
* /// @custom:oz-upgrades-unsafe-allow constructor
* constructor() {
* _disableInitializers();
* }
* ```
* ====
*/
abstract contract Initializable {
/**
* @dev Indicates that the contract has been initialized.
* @custom:oz-retyped-from bool
*/
uint8 private _initialized;
/**
* @dev Indicates that the contract is in the process of being initialized.
*/
bool private _initializing;
/**
* @dev Triggered when the contract has been initialized or reinitialized.
*/
event Initialized(uint8 version);
/**
* @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
* `onlyInitializing` functions can be used to initialize parent contracts.
*
* Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a
* constructor.
*
* Emits an {Initialized} event.
*/
modifier initializer() {
bool isTopLevelCall = !_initializing;
require(
(isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),
"Initializable: contract is already initialized"
);
_initialized = 1;
if (isTopLevelCall) {
_initializing = true;
}
_;
if (isTopLevelCall) {
_initializing = false;
emit Initialized(1);
}
}
/**
* @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
* contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
* used to initialize parent contracts.
*
* A reinitializer may be used after the original initialization step. This is essential to configure modules that
* are added through upgrades and that require initialization.
*
* When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
* cannot be nested. If one is invoked in the context of another, execution will revert.
*
* Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
* a contract, executing them in the right order is up to the developer or operator.
*
* WARNING: setting the version to 255 will prevent any future reinitialization.
*
* Emits an {Initialized} event.
*/
modifier reinitializer(uint8 version) {
require(!_initializing && _initialized < version, "Initializable: contract is already initialized");
_initialized = version;
_initializing = true;
_;
_initializing = false;
emit Initialized(version);
}
/**
* @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
* {initializer} and {reinitializer} modifiers, directly or indirectly.
*/
modifier onlyInitializing() {
require(_initializing, "Initializable: contract is not initializing");
_;
}
/**
* @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
* Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
* to any version. It is recommended to use this to lock implementation contracts that are designed to be called
* through proxies.
*
* Emits an {Initialized} event the first time it is successfully executed.
*/
function _disableInitializers() internal virtual {
require(!_initializing, "Initializable: contract is initializing");
if (_initialized < type(uint8).max) {
_initialized = type(uint8).max;
emit Initialized(type(uint8).max);
}
}
/**
* @dev Returns the highest version that has been initialized. See {reinitializer}.
*/
function _getInitializedVersion() internal view returns (uint8) {
return _initialized;
}
/**
* @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.
*/
function _isInitializing() internal view returns (bool) {
return _initializing;
}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;
/// @title Pool state that never changes
/// @notice These parameters are fixed for a pool forever, i.e., the methods will always return the same values
interface IUniswapV3PoolImmutables {
/// @notice The contract that deployed the pool, which must adhere to the IUniswapV3Factory interface
/// @return The contract address
function factory() external view returns (address);
/// @notice The first of the two tokens of the pool, sorted by address
/// @return The token contract address
function token0() external view returns (address);
/// @notice The second of the two tokens of the pool, sorted by address
/// @return The token contract address
function token1() external view returns (address);
/// @notice The pool's fee in hundredths of a bip, i.e. 1e-6
/// @return The fee
function fee() external view returns (uint24);
/// @notice The pool tick spacing
/// @dev Ticks can only be used at multiples of this value, minimum of 1 and always positive
/// e.g.: a tickSpacing of 3 means ticks can be initialized every 3rd tick, i.e., ..., -6, -3, 0, 3, 6, ...
/// This value is an int24 to avoid casting even though it is always positive.
/// @return The tick spacing
function tickSpacing() external view returns (int24);
/// @notice The maximum amount of position liquidity that can use any tick in the range
/// @dev This parameter is enforced per tick to prevent liquidity from overflowing a uint128 at any point, and
/// also prevents out-of-range liquidity from being used to prevent adding in-range liquidity to a pool
/// @return The max amount of liquidity per tick
function maxLiquidityPerTick() external view returns (uint128);
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;
/// @title Pool state that can change
/// @notice These methods compose the pool's state, and can change with any frequency including multiple times
/// per transaction
interface IUniswapV3PoolState {
/// @notice The 0th storage slot in the pool stores many values, and is exposed as a single method to save gas
/// when accessed externally.
/// @return sqrtPriceX96 The current price of the pool as a sqrt(token1/token0) Q64.96 value
/// tick The current tick of the pool, i.e. according to the last tick transition that was run.
/// This value may not always be equal to SqrtTickMath.getTickAtSqrtRatio(sqrtPriceX96) if the price is on a tick
/// boundary.
/// observationIndex The index of the last oracle observation that was written,
/// observationCardinality The current maximum number of observations stored in the pool,
/// observationCardinalityNext The next maximum number of observations, to be updated when the observation.
/// feeProtocol The protocol fee for both tokens of the pool.
/// Encoded as two 4 bit values, where the protocol fee of token1 is shifted 4 bits and the protocol fee of token0
/// is the lower 4 bits. Used as the denominator of a fraction of the swap fee, e.g. 4 means 1/4th of the swap fee.
/// unlocked Whether the pool is currently locked to reentrancy
function slot0()
external
view
returns (
uint160 sqrtPriceX96,
int24 tick,
uint16 observationIndex,
uint16 observationCardinality,
uint16 observationCardinalityNext,
uint8 feeProtocol,
bool unlocked
);
/// @notice The fee growth as a Q128.128 fees of token0 collected per unit of liquidity for the entire life of the pool
/// @dev This value can overflow the uint256
function feeGrowthGlobal0X128() external view returns (uint256);
/// @notice The fee growth as a Q128.128 fees of token1 collected per unit of liquidity for the entire life of the pool
/// @dev This value can overflow the uint256
function feeGrowthGlobal1X128() external view returns (uint256);
/// @notice The amounts of token0 and token1 that are owed to the protocol
/// @dev Protocol fees will never exceed uint128 max in either token
function protocolFees() external view returns (uint128 token0, uint128 token1);
/// @notice The currently in range liquidity available to the pool
/// @dev This value has no relationship to the total liquidity across all ticks
function liquidity() external view returns (uint128);
/// @notice Look up information about a specific tick in the pool
/// @param tick The tick to look up
/// @return liquidityGross the total amount of position liquidity that uses the pool either as tick lower or
/// tick upper,
/// liquidityNet how much liquidity changes when the pool price crosses the tick,
/// feeGrowthOutside0X128 the fee growth on the other side of the tick from the current tick in token0,
/// feeGrowthOutside1X128 the fee growth on the other side of the tick from the current tick in token1,
/// tickCumulativeOutside the cumulative tick value on the other side of the tick from the current tick
/// secondsPerLiquidityOutsideX128 the seconds spent per liquidity on the other side of the tick from the current tick,
/// secondsOutside the seconds spent on the other side of the tick from the current tick,
/// initialized Set to true if the tick is initialized, i.e. liquidityGross is greater than 0, otherwise equal to false.
/// Outside values can only be used if the tick is initialized, i.e. if liquidityGross is greater than 0.
/// In addition, these values are only relative and must be used only in comparison to previous snapshots for
/// a specific position.
function ticks(int24 tick)
external
view
returns (
uint128 liquidityGross,
int128 liquidityNet,
uint256 feeGrowthOutside0X128,
uint256 feeGrowthOutside1X128,
int56 tickCumulativeOutside,
uint160 secondsPerLiquidityOutsideX128,
uint32 secondsOutside,
bool initialized
);
/// @notice Returns 256 packed tick initialized boolean values. See TickBitmap for more information
function tickBitmap(int16 wordPosition) external view returns (uint256);
/// @notice Returns the information about a position by the position's key
/// @param key The position's key is a hash of a preimage composed by the owner, tickLower and tickUpper
/// @return _liquidity The amount of liquidity in the position,
/// Returns feeGrowthInside0LastX128 fee growth of token0 inside the tick range as of the last mint/burn/poke,
/// Returns feeGrowthInside1LastX128 fee growth of token1 inside the tick range as of the last mint/burn/poke,
/// Returns tokensOwed0 the computed amount of token0 owed to the position as of the last mint/burn/poke,
/// Returns tokensOwed1 the computed amount of token1 owed to the position as of the last mint/burn/poke
function positions(bytes32 key)
external
view
returns (
uint128 _liquidity,
uint256 feeGrowthInside0LastX128,
uint256 feeGrowthInside1LastX128,
uint128 tokensOwed0,
uint128 tokensOwed1
);
/// @notice Returns data about a specific observation index
/// @param index The element of the observations array to fetch
/// @dev You most likely want to use #observe() instead of this method to get an observation as of some amount of time
/// ago, rather than at a specific index in the array.
/// @return blockTimestamp The timestamp of the observation,
/// Returns tickCumulative the tick multiplied by seconds elapsed for the life of the pool as of the observation timestamp,
/// Returns secondsPerLiquidityCumulativeX128 the seconds per in range liquidity for the life of the pool as of the observation timestamp,
/// Returns initialized whether the observation has been initialized and the values are safe to use
function observations(uint256 index)
external
view
returns (
uint32 blockTimestamp,
int56 tickCumulative,
uint160 secondsPerLiquidityCumulativeX128,
bool initialized
);
}interface IBinPoolManager {
type PoolId is bytes32;
/// @notice Get the current value in slot0 of the given pool
function getSlot0(PoolId id) external view returns (uint24 activeId, uint24 protocolFee, uint24 lpFee);
/// @notice Returns the reserves of a bin
/// @param id The id of the bin
/// @return binReserveX The reserve of token X in the bin
/// @return binReserveY The reserve of token Y in the bin
/// @return binLiquidity The total liquidity in the bin
/// @return totalShares The total shares minted in the bin
function getBin(PoolId id, uint24 binId)
external
view
returns (uint128 binReserveX, uint128 binReserveY, uint256 binLiquidity, uint256 totalShares);
/// @notice Returns the next non-empty bin
/// @dev The next non-empty bin is the bin with a higher (if swapForY is true) or lower (if swapForY is false)
/// id that has a non-zero reserve of token X or Y.
/// @param swapForY Whether the swap is for token Y (true) or token X (false)
/// @param id The id of the bin
/// @return nextId The id of the next non-empty bin
function getNextNonEmptyBin(PoolId id, bool swapForY, uint24 binId) external view returns (uint24 nextId);
}/// @notice implements calculation of address for contracts deployed through CREATE.
/// Accepts contract deployed from which address & nonce
library AddressCalcs {
/// @notice Computes the address of a contract based
/// @param deployedFrom_ Address from which the contract was deployed
/// @param nonce_ Nonce at which the contract was deployed
/// @return contract_ Address of deployed contract
function addressCalc(address deployedFrom_, uint nonce_) internal pure returns (address contract_) {
// @dev based on https://ethereum.stackexchange.com/a/61413
// nonce of smart contract always starts with 1. so, with nonce 0 there won't be any deployment
// hence, nonce of vault deployment starts with 1.
bytes memory data;
if (nonce_ == 0x00) {
return address(0);
} else if (nonce_ <= 0x7f) {
data = abi.encodePacked(bytes1(0xd6), bytes1(0x94), deployedFrom_, uint8(nonce_));
} else if (nonce_ <= 0xff) {
data = abi.encodePacked(bytes1(0xd7), bytes1(0x94), deployedFrom_, bytes1(0x81), uint8(nonce_));
} else if (nonce_ <= 0xffff) {
data = abi.encodePacked(bytes1(0xd8), bytes1(0x94), deployedFrom_, bytes1(0x82), uint16(nonce_));
} else if (nonce_ <= 0xffffff) {
data = abi.encodePacked(bytes1(0xd9), bytes1(0x94), deployedFrom_, bytes1(0x83), uint24(nonce_));
} else {
data = abi.encodePacked(bytes1(0xda), bytes1(0x94), deployedFrom_, bytes1(0x84), uint32(nonce_));
}
return address(uint160(uint256(keccak256(data))));
}
}
interface IFluidDexT1 {
struct Implementations {
address shift;
address admin;
address colOperations;
address debtOperations;
address perfectOperationsAndOracle;
}
struct ConstantViews {
uint256 dexId;
address liquidity;
address factory;
Implementations implementations;
address deployerContract;
address token0;
address token1;
bytes32 supplyToken0Slot;
bytes32 borrowToken0Slot;
bytes32 supplyToken1Slot;
bytes32 borrowToken1Slot;
bytes32 exchangePriceToken0Slot;
bytes32 exchangePriceToken1Slot;
uint256 oracleMapping;
}
function constantsView() external view returns (ConstantViews memory constantsView_);
}
interface ICenterPriceOfFluid {
/// @notice Retrieves the center price for the pool
/// @dev This function is marked as non-constant (potentially state-changing) to allow flexibility in price fetching mechanisms.
/// While typically used as a read-only operation, this design permits write operations if needed for certain token pairs
/// (e.g., fetching up-to-date exchange rates that may require state changes).
/// @return price The current price ratio of token1 to token0, expressed with 27 decimal places
function centerPrice() external view returns (uint price);
}
interface IShifting {
function readFromStorage(bytes32 slot_) external view returns (uint256 result_);
}/// Copy from https://etherscan.io/address/0xBbcb91440523216e2b87052A99F69c604A7b6e00#code
/// @notice library that helps in reading / working with storage slot data of Fluid Dex Lite.
library DexLiteSlotsLink {
/// @dev storage slot for dexes list
uint256 internal constant DEX_LITE_DEXES_LIST_SLOT = 1;
/// @dev storage slot for is dex variables
uint256 internal constant DEX_LITE_DEX_VARIABLES_SLOT = 2;
/// @dev storage slot for center price shift
uint256 internal constant DEX_LITE_CENTER_PRICE_SHIFT_SLOT = 3;
/// @dev storage slot for range shift
uint256 internal constant DEX_LITE_RANGE_SHIFT_SLOT = 4;
/// @dev storage slot for threshold shift
uint256 internal constant DEX_LITE_THRESHOLD_SHIFT_SLOT = 5;
// DexVariables
uint256 internal constant BITS_DEX_LITE_DEX_VARIABLES_CENTER_PRICE_CONTRACT_ADDRESS = 63;
uint256 internal constant BITS_DEX_LITE_DEX_VARIABLES_TOKEN_0_TOTAL_SUPPLY_ADJUSTED = 136;
uint256 internal constant BITS_DEX_LITE_DEX_VARIABLES_TOKEN_1_TOTAL_SUPPLY_ADJUSTED = 196;
/// @notice Calculating the slot ID for Dex contract for single mapping at `slot_` for `key_`
function calculateMappingStorageSlot(uint256 slot_, bytes32 key_) internal pure returns (bytes32) {
return keccak256(abi.encode(key_, slot_));
}
}
/// @notice Arithmetic library with operations for fixed-point numbers.
/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/FixedPointMathLib.sol)
/// @author Inspired by USM (https://github.com/usmfum/USM/blob/master/contracts/WadMath.sol)
library FixedPointMathLib {
/*//////////////////////////////////////////////////////////////
SIMPLIFIED FIXED POINT OPERATIONS
//////////////////////////////////////////////////////////////*/
uint256 internal constant MAX_UINT256 = 2**256 - 1;
uint256 internal constant WAD = 1e18; // The scalar of ETH and most ERC20s.
function mulWadDown(uint256 x, uint256 y) internal pure returns (uint256) {
return mulDivDown(x, y, WAD); // Equivalent to (x * y) / WAD rounded down.
}
function mulWadUp(uint256 x, uint256 y) internal pure returns (uint256) {
return mulDivUp(x, y, WAD); // Equivalent to (x * y) / WAD rounded up.
}
function divWadDown(uint256 x, uint256 y) internal pure returns (uint256) {
return mulDivDown(x, WAD, y); // Equivalent to (x * WAD) / y rounded down.
}
function divWadUp(uint256 x, uint256 y) internal pure returns (uint256) {
return mulDivUp(x, WAD, y); // Equivalent to (x * WAD) / y rounded up.
}
/*//////////////////////////////////////////////////////////////
LOW LEVEL FIXED POINT OPERATIONS
//////////////////////////////////////////////////////////////*/
function mulDivDown(
uint256 x,
uint256 y,
uint256 denominator
) internal pure returns (uint256 z) {
/// @solidity memory-safe-assembly
assembly {
// Equivalent to require(denominator != 0 && (y == 0 || x <= type(uint256).max / y))
if iszero(mul(denominator, iszero(mul(y, gt(x, div(MAX_UINT256, y)))))) {
revert(0, 0)
}
// Divide x * y by the denominator.
z := div(mul(x, y), denominator)
}
}
function mulDivUp(
uint256 x,
uint256 y,
uint256 denominator
) internal pure returns (uint256 z) {
/// @solidity memory-safe-assembly
assembly {
// Equivalent to require(denominator != 0 && (y == 0 || x <= type(uint256).max / y))
if iszero(mul(denominator, iszero(mul(y, gt(x, div(MAX_UINT256, y)))))) {
revert(0, 0)
}
// If x * y modulo the denominator is strictly greater than 0,
// 1 is added to round up the division of x * y by the denominator.
z := add(gt(mod(mul(x, y), denominator), 0), div(mul(x, y), denominator))
}
}
function rpow(
uint256 x,
uint256 n,
uint256 scalar
) internal pure returns (uint256 z) {
/// @solidity memory-safe-assembly
assembly {
switch x
case 0 {
switch n
case 0 {
// 0 ** 0 = 1
z := scalar
}
default {
// 0 ** n = 0
z := 0
}
}
default {
switch mod(n, 2)
case 0 {
// If n is even, store scalar in z for now.
z := scalar
}
default {
// If n is odd, store x in z for now.
z := x
}
// Shifting right by 1 is like dividing by 2.
let half := shr(1, scalar)
for {
// Shift n right by 1 before looping to halve it.
n := shr(1, n)
} n {
// Shift n right by 1 each iteration to halve it.
n := shr(1, n)
} {
// Revert immediately if x ** 2 would overflow.
// Equivalent to iszero(eq(div(xx, x), x)) here.
if shr(128, x) {
revert(0, 0)
}
// Store x squared.
let xx := mul(x, x)
// Round to the nearest number.
let xxRound := add(xx, half)
// Revert if xx + half overflowed.
if lt(xxRound, xx) {
revert(0, 0)
}
// Set x to scaled xxRound.
x := div(xxRound, scalar)
// If n is even:
if mod(n, 2) {
// Compute z * x.
let zx := mul(z, x)
// If z * x overflowed:
if iszero(eq(div(zx, x), z)) {
// Revert if x is non-zero.
if iszero(iszero(x)) {
revert(0, 0)
}
}
// Round to the nearest number.
let zxRound := add(zx, half)
// Revert if zx + half overflowed.
if lt(zxRound, zx) {
revert(0, 0)
}
// Return properly scaled zxRound.
z := div(zxRound, scalar)
}
}
}
}
}
/*//////////////////////////////////////////////////////////////
GENERAL NUMBER UTILITIES
//////////////////////////////////////////////////////////////*/
function sqrt(uint256 x) internal pure returns (uint256 z) {
/// @solidity memory-safe-assembly
assembly {
let y := x // We start y at x, which will help us make our initial estimate.
z := 181 // The "correct" value is 1, but this saves a multiplication later.
// This segment is to get a reasonable initial estimate for the Babylonian method. With a bad
// start, the correct # of bits increases ~linearly each iteration instead of ~quadratically.
// We check y >= 2^(k + 8) but shift right by k bits
// each branch to ensure that if x >= 256, then y >= 256.
if iszero(lt(y, 0x10000000000000000000000000000000000)) {
y := shr(128, y)
z := shl(64, z)
}
if iszero(lt(y, 0x1000000000000000000)) {
y := shr(64, y)
z := shl(32, z)
}
if iszero(lt(y, 0x10000000000)) {
y := shr(32, y)
z := shl(16, z)
}
if iszero(lt(y, 0x1000000)) {
y := shr(16, y)
z := shl(8, z)
}
// Goal was to get z*z*y within a small factor of x. More iterations could
// get y in a tighter range. Currently, we will have y in [256, 256*2^16).
// We ensured y >= 256 so that the relative difference between y and y+1 is small.
// That's not possible if x < 256 but we can just verify those cases exhaustively.
// Now, z*z*y <= x < z*z*(y+1), and y <= 2^(16+8), and either y >= 256, or x < 256.
// Correctness can be checked exhaustively for x < 256, so we assume y >= 256.
// Then z*sqrt(y) is within sqrt(257)/sqrt(256) of sqrt(x), or about 20bps.
// For s in the range [1/256, 256], the estimate f(s) = (181/1024) * (s+1) is in the range
// (1/2.84 * sqrt(s), 2.84 * sqrt(s)), with largest error when s = 1 and when s = 256 or 1/256.
// Since y is in [256, 256*2^16), let a = y/65536, so that a is in [1/256, 256). Then we can estimate
// sqrt(y) using sqrt(65536) * 181/1024 * (a + 1) = 181/4 * (y + 65536)/65536 = 181 * (y + 65536)/2^18.
// There is no overflow risk here since y < 2^136 after the first branch above.
z := shr(18, mul(z, add(y, 65536))) // A mul() is saved from starting z at 181.
// Given the worst case multiplicative error of 2.84 above, 7 iterations should be enough.
z := shr(1, add(z, div(x, z)))
z := shr(1, add(z, div(x, z)))
z := shr(1, add(z, div(x, z)))
z := shr(1, add(z, div(x, z)))
z := shr(1, add(z, div(x, z)))
z := shr(1, add(z, div(x, z)))
z := shr(1, add(z, div(x, z)))
// If x+1 is a perfect square, the Babylonian method cycles between
// floor(sqrt(x)) and ceil(sqrt(x)). This statement ensures we return floor.
// See: https://en.wikipedia.org/wiki/Integer_square_root#Using_only_integer_division
// Since the ceil is rare, we save gas on the assignment and repeat division in the rare case.
// If you don't care whether the floor or ceil square root is returned, you can remove this statement.
z := sub(z, lt(div(x, z), z))
}
}
function unsafeMod(uint256 x, uint256 y) internal pure returns (uint256 z) {
/// @solidity memory-safe-assembly
assembly {
// Mod x by y. Note this will return
// 0 instead of reverting if y is zero.
z := mod(x, y)
}
}
function unsafeDiv(uint256 x, uint256 y) internal pure returns (uint256 r) {
/// @solidity memory-safe-assembly
assembly {
// Divide x by y. Note this will return
// 0 instead of reverting if y is zero.
r := div(x, y)
}
}
function unsafeDivUp(uint256 x, uint256 y) internal pure returns (uint256 z) {
/// @solidity memory-safe-assembly
assembly {
// Add 1 to x * y if x % y > 0. Note this will
// return 0 instead of reverting if y is zero.
z := add(gt(mod(x, y), 0), div(x, y))
}
}
}
interface IFluidDexLite {
function readFromStorage(bytes32 slot_) external view returns (uint256 result_);
}
interface ICenterPriceOfFluidLite {
/// @notice Retrieves the center price for the pool. The `view` modifier is added to support view functions.
/// Notice that
/// @dev This function is marked as non-constant (potentially state-changing) to allow flexibility in price fetching mechanisms.
/// While typically used as a read-only operation, this design permits write operations if needed for certain token pairs
/// (e.g., fetching up-to-date exchange rates that may require state changes).
/// @return price The current price of token0 in terms of token1, expressed with 27 decimal places
function centerPrice(address token0_, address token1_) external view returns (uint256);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library AddressUpgradeable {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
* the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
*
* _Available since v4.8._
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata,
string memory errorMessage
) internal view returns (bytes memory) {
if (success) {
if (returndata.length == 0) {
// only check isContract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
require(isContract(target), "Address: call to non-contract");
}
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
/**
* @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason or using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
function _revert(bytes memory returndata, string memory errorMessage) private pure {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}{
"remappings": [
"@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/",
"@openzeppelin/contracts/=lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/contracts/",
"erc4626-tests/=lib/openzeppelin-contracts-upgradeable/lib/erc4626-tests/",
"forge-std/=lib/forge-std/src/",
"halmos-cheatcodes/=lib/openzeppelin-contracts-upgradeable/lib/halmos-cheatcodes/src/",
"openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/",
"openzeppelin-contracts/=lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/",
"ds-test/=lib/openzeppelin-contracts-upgradeable/lib/forge-std/lib/ds-test/src/",
"openzeppelin-foundry-upgrades/=lib/openzeppelin-foundry-upgrades/src/",
"openzeppelin/=lib/openzeppelin-contracts/contracts/"
],
"optimizer": {
"enabled": true,
"runs": 200
},
"metadata": {
"useLiteralContent": true,
"bytecodeHash": "ipfs"
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"evmVersion": "london",
"viaIR": true,
"libraries": {
"src/Quote.sol": {
"QueryAlgebraTicksSuperCompact": "0x7720a57fce419963108a4ca9e5131d0c39d6a556",
"QueryFluid": "0xac7e7a13d62d817c88531710fa308a766299f644",
"QueryFluidLite": "0xa86d99e80cf3cc61a256bf443483f0f75f74f57f",
"QueryHorizonTicksSuperCompact": "0x2a741b29212d410440a9b782ee85c8939ad7f172",
"QueryIzumiSuperCompact": "0x1792f5f1214ade56c08ab9689f96f2e861a5f264",
"QueryPancakeInfinityLBReserveSuperCompact": "0x600c6d5c1f15726a711d6d71a4205add668d5374",
"QueryUniv3TicksSuperCompact": "0x5e916b28c62d0752a1c953d96c400efb330b6815",
"QueryUniv4TicksSuperCompact": "0x1d3d302185e032e454ad50067987169d6a322c19",
"QueryZoraTicksSuperCompact": "0x7856f02e7080d507c08abb85058976761f0ab0e1"
}
}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"inputs":[],"name":"FLUID_LITE_DEPLOYER_CONTRACT","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"FLUID_LITE_DEX","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"POOL_MANAGER","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"POSITION_MANAGER","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"STATE_VIEW","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"coin","type":"address"}],"name":"getPoolKeyOfZora","outputs":[{"components":[{"internalType":"IZoraCoin.Currency","name":"currency0","type":"address"},{"internalType":"IZoraCoin.Currency","name":"currency1","type":"address"},{"internalType":"uint24","name":"fee","type":"uint24"},{"internalType":"int24","name":"tickSpacing","type":"int24"},{"internalType":"contract IHooks","name":"hooks","type":"address"}],"internalType":"struct IZoraCoin.PoolKey","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"coin","type":"address"}],"name":"getSlot0OfZora","outputs":[{"internalType":"int256","name":"liquidity","type":"int256"},{"internalType":"uint160","name":"sqrtPriceX96","type":"uint160"},{"internalType":"int24","name":"tick","type":"int24"},{"internalType":"uint24","name":"protocolFee","type":"uint24"},{"internalType":"uint24","name":"lpFee","type":"uint24"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"pool","type":"address"},{"internalType":"uint256","name":"len","type":"uint256"}],"name":"queryAlgebraTicksSuperCompact","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"pool","type":"address"},{"internalType":"uint256","name":"len","type":"uint256"}],"name":"queryAlgebraTicksSuperCompact2","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"pool","type":"address"},{"internalType":"uint256","name":"len","type":"uint256"}],"name":"queryAlgebraTicksSuperCompact3","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"pool","type":"address"},{"internalType":"uint256","name":"len","type":"uint256"}],"name":"queryAlgebraTicksSuperCompact3_back","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"pool","type":"address"},{"internalType":"uint256","name":"dexVariables","type":"uint256"}],"name":"queryFluid","outputs":[{"internalType":"uint256","name":"centerPrice","type":"uint256"},{"internalType":"uint256","name":"rangeShift","type":"uint256"},{"internalType":"uint256","name":"thresholdShift","type":"uint256"},{"internalType":"uint256","name":"centerPriceShift","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes8","name":"dexId","type":"bytes8"}],"name":"queryFluidLite","outputs":[{"components":[{"internalType":"address","name":"token0","type":"address"},{"internalType":"address","name":"token1","type":"address"},{"internalType":"bytes32","name":"salt","type":"bytes32"}],"internalType":"struct QueryFluidLite.DexKey","name":"dexKey","type":"tuple"},{"internalType":"uint256","name":"centerPrice","type":"uint256"},{"internalType":"uint256","name":"dexVariables","type":"uint256"},{"internalType":"uint256","name":"rangeShift","type":"uint256"},{"internalType":"uint256","name":"thresholdShift","type":"uint256"},{"internalType":"uint256","name":"centerPriceShift","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"pool","type":"address"},{"internalType":"uint256","name":"len","type":"uint256"}],"name":"queryHorizonTicksSuperCompact","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"pool","type":"address"},{"internalType":"uint256","name":"len","type":"uint256"}],"name":"queryIzumiSuperCompact","outputs":[{"internalType":"bytes","name":"","type":"bytes"},{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"poolId","type":"bytes32"}],"name":"queryPancakeInfinityLBReserveSuperCompact","outputs":[{"internalType":"uint256","name":"totalReserveX","type":"uint256"},{"internalType":"uint256","name":"totalReserveY","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"poolId","type":"bytes32"},{"internalType":"uint256","name":"len","type":"uint256"}],"name":"queryPancakeInfinityTicksSuperCompact","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"pool","type":"address"},{"internalType":"uint256","name":"len","type":"uint256"}],"name":"queryUniv3TicksSuperCompact","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"poolId","type":"bytes32"},{"internalType":"uint256","name":"len","type":"uint256"}],"name":"queryUniv4TicksSuperCompact","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"poolId","type":"bytes32"},{"internalType":"uint256","name":"len","type":"uint256"},{"components":[{"internalType":"IPositionManager.Currency","name":"currency0","type":"address"},{"internalType":"IPositionManager.Currency","name":"currency1","type":"address"},{"internalType":"uint24","name":"fee","type":"uint24"},{"internalType":"int24","name":"tickSpacing","type":"int24"},{"internalType":"contract IHooks","name":"hooks","type":"address"}],"internalType":"struct IPositionManager.PoolKey","name":"poolkey","type":"tuple"}],"name":"queryUniv4TicksSuperCompactForNoPositionManager","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"coin","type":"address"},{"internalType":"uint256","name":"len","type":"uint256"}],"name":"queryZoraTicksSuperCompact","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"IZoraCoin.Currency","name":"currency0","type":"address"},{"internalType":"IZoraCoin.Currency","name":"currency1","type":"address"},{"internalType":"uint24","name":"fee","type":"uint24"},{"internalType":"int24","name":"tickSpacing","type":"int24"},{"internalType":"contract IHooks","name":"hooks","type":"address"}],"internalType":"struct IZoraCoin.PoolKey","name":"poolKey","type":"tuple"}],"name":"toId","outputs":[{"internalType":"bytes32","name":"poolId","type":"bytes32"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}]Contract Creation Code
608080604052346100165761145c908161001c8239f35b600080fdfe6080604081815260049081361015610017575b600080fd5b600092833560e01c9081631bea83fe14611149575080632cf8f1f6146110a85780632d6d225e1461105857806332c961d914610f21578063395960bb14610873578063417be3f214610e87578063512bcef914610e21578063594a1bf314610d1157806362308e8514610cee57806367ce2fc614610bfd578063715018a614610ba05780637df8773a14610b505780638129fc1c14610a1e57806388c0a8a7146108a85780638da5cb5b1461087f578063a3f18ed814610873578063aa4cfccd14610844578063b79b5004146106cf578063c38f8f351461067f578063c684206c146105f1578063ca883bec14610563578063cb9886e214610464578063cd7f833c14610337578063d1c62f261461029d578063f2fde38b1461020b5763f9f59a771461014357600080fd5b346102075782816003193601126102045761019292610160611177565b835163f9f59a7760e01b81526001600160a01b0390911691810191825260243560208301529384918291604090910190565b0381735e916b28c62d0752a1c953d96c400efb330b68155af49182156101fa57836101d194936101d5575b5050519182916020835260208301906111b0565b0390f35b6101f29293503d8091833e6101ea8183611223565b8101906113ce565b9038806101bd565b81513d85823e3d90fd5b80fd5b8280fd5b50903461020757602036600319011261020757610226611177565b9161022f611278565b6001600160a01b0383161561024b5783610248846112d0565b80f35b906020608492519162461bcd60e51b8352820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152fd5b5034610207576102ac36611262565b9082519363df966b3160e01b855284015260248301527386e8631a016f9068c3f085faf484ee3f5fdee8f26044830152734529a01c7a0410167c5740c487a8de60232617bf60648301528282608481731d3d302185e032e454ad50067987169d6a322c195af49182156101fa57836101d194936101d5575050519182916020835260208301906111b0565b50903461020757602036600319011261020757610352611177565b8251635d2b752d60e11b81526001600160a01b03918216928101929092526004617e61608e1b0160248301529160a082604481737856f02e7080d507c08abb85058976761f0ab0e15af490811561045b57849385908691879588956103dd575b5060a09750835196875216602086015260020b9084015262ffffff8092166060840152166080820152f35b965050925050915060a0833d8211610453575b816103fd60a09383611223565b8101031261044f57825191602084015193828516850361044b5760a09550610426828201611418565b9261043f608061043860608501611408565b9301611408565b949593919493386103b2565b8580fd5b8380fd5b3d91506103f0565b513d85823e3d90fd5b50346102075760e03660031901126102075760a036604319011261020757805191634ebc99a160e11b835280359083015260243560248301527386e8631a016f9068c3f085faf484ee3f5fdee8f2604483015260443560018060a01b039081811680910361055f57606484015260643581811680910361055f57608484015260843562ffffff811680910361055f5760a484015260a4358060020b80910361055f5760c484015260c43590811680910361044f5760e4830152828261010481731d3d302185e032e454ad50067987169d6a322c195af49182156101fa57836101d194936101d5575050519182916020835260208301906111b0565b8480fd5b5034610207578281600319360112610204576105b392610581611177565b83516332a20efb60e21b81526001600160a01b0390911691810191825260243560208301529384918291604090910190565b0381737720a57fce419963108a4ca9e5131d0c39d6a5565af49182156101fa57836101d194936101d5575050519182916020835260208301906111b0565b5034610207578281600319360112610204576106419261060f611177565b83516331a1081b60e21b81526001600160a01b0390911691810191825260243560208301529384918291604090910190565b0381732a741b29212d410440a9b782ee85c8939ad7f1725af49182156101fa57836101d194936101d5575050519182916020835260208301906111b0565b5034610207578281600319360112610204576105b39261069d611177565b835163c38f8f3560e01b81526001600160a01b0390911691810191825260243560208301529384918291604090910190565b5082903461082e576020918260031936011261020457833567ffffffffffffffff60c01b811680910361082e578183805161070981611207565b828152828782015201528183519563a1eeee8960e01b8752860152816024860152604485015261010093848160648173a86d99e80cf3cc61a256bf443483f0f75f74f57f5af49283156108395782908390849285948680986107a7575b5050815181516001600160a01b039081168252898301511698810198909852810151908701526060860152608085015260a084015260c083015260e0820152f35b95509550509450505081853d8711610832575b6107c48183611223565b81010385811261082e5760601361020457508151906107e282611207565b6107eb816113f4565b82526107f88482016113f4565b848301528281015183830152606081015192608082015160a0830151918060e060c086015195015195969293949596908a610766565b5080fd5b503d6107ba565b51913d9150823e3d90fd5b83823461082e578160031936011261082e57602090517386e8631a016f9068c3f085faf484ee3f5fdee8f28152f35b50505050610012611245565b83823461082e578160031936011261082e5760335490516001600160a01b039091168152602090f35b509034610207576020366003190112610207576108c3611177565b83608084516108d1816111d5565b8281526020810183905285810183905260608101839052015282516388c0a8a760e01b81526001600160a01b039182169281019290925260a082602481737856f02e7080d507c08abb85058976761f0ab0e15af4938415610a13578094610981575b60a08561097f865180926080908160018060a01b039182815116855282602082015116602086015262ffffff6040820151166040860152606081015160020b6060860152015116910152565bf35b9091935060a0843d8211610a0b575b8161099d60a09383611223565b810103126102045760808351946109b3866111d5565b6109bc816113f4565b86526109ca602082016113f4565b60208701526109da858201611408565b858701526109ea60608201611418565b6060870152015191821682036102045750608083015261097f60a038610933565b3d9150610990565b8351903d90823e3d90fd5b509034610207578260031936011261020757825460ff8160081c161591828093610b43575b8015610b2c575b15610ad2575060ff198116600117845581610ac1575b50610a7a60ff845460081c16610a7581611319565b611319565b610a83336112d0565b610a8b575080f35b60207f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989161ff001984541684555160018152a180f35b61ffff191661010117835538610a60565b608490602085519162461bcd60e51b8352820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152fd5b50303b158015610a4a5750600160ff831614610a4a565b50600160ff831610610a43565b5034610207578281600319360112610204576105b392610b6e611177565b8351633efc3b9d60e11b81526001600160a01b0390911691810191825260243560208301529384918291604090910190565b8334610204578060031936011261020457610bb9611278565b603380546001600160a01b0319811690915581906001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a380f35b5090346102075781600319360112610207576080610c4f91610c1d611177565b84516333e717e360e11b81526001600160a01b0390911691810191825260243560208301529283918291604090910190565b038173ac7e7a13d62d817c88531710fa308a766299f6445af4908115610ce25783928485928694610c94575b5060809550815194855260208501528301526060820152f35b9350509250506080813d8211610cda575b81610cb260809383611223565b8101031261020757608092508051602082015192606081840151930151919392919238610c7b565b3d9150610ca5565b505051903d90823e3d90fd5b83823461082e578160031936011261082e57602090516004617e61608e1b018152f35b5090346102075781600319360112610207579180610d6393610d31611177565b845163594a1bf360e01b81526001600160a01b0390911691810191825260243560208301529485918291604090910190565b0381731792f5f1214ade56c08ab9689f96f2e861a5f2645af4908115610e165780938192610db3575b50506101d190610da583519484869586528501906111b0565b9083820360208501526111b0565b915092503d8084833e610dc68183611223565b810190828183031261044f5780519067ffffffffffffffff9182811161044b5783610df2918301611379565b946020820151928311610204575091610e0f916101d19301611379565b9038610d8c565b8251903d90823e3d90fd5b503461020757610e3036611262565b9082519363512bcef960e01b855284015260248301528282604481731d3d302185e032e454ad50067987169d6a322c195af49182156101fa57836101d194936101d5575050519182916020835260208301906111b0565b5034610207578060031936011261020757610ea0611177565b815163148ec71960e31b81526001600160a01b039091169281019290925260248035908301527386e8631a016f9068c3f085faf484ee3f5fdee8f260448301528282606481737856f02e7080d507c08abb85058976761f0ab0e15af49182156101fa57836101d194936101d5575050519182916020835260208301906111b0565b5082903461082e5760a036600319011261082e57805192610f41846111d5565b610f49611177565b8452602435936001600160a01b03808616860361055f576020958683015260443562ffffff8116810361044b57848301526064358060020b810361044b576060830152608435908116810361055f5790610ff491608082015283519263aa5d0ea160e01b84528301906080908160018060a01b039182815116855282602082015116602086015262ffffff6040820151166040860152606081015160020b6060860152015116910152565b838160a481737856f02e7080d507c08abb85058976761f0ab0e15af4928315610e16578093611026575b505051908152f35b909192508382813d8311611051575b61103f8183611223565b8101031261020457505190838061101e565b503d611035565b5034610207578281600319360112610204576105b392611076611177565b83516316b6912f60e11b81526001600160a01b0390911691810191825260243560208301529384918291604090910190565b5091903461082e57602036600319011261082e578251906363e8cdbb60e11b8252803590820152828160248173600c6d5c1f15726a711d6d71a4205add668d53745af490811561113f57828092611108575b505082519182526020820152f35b915091508282813d8311611138575b6111218183611223565b8101031261020457506020815191015138806110fa565b503d611117565b83513d84823e3d90fd5b84903461082e578160031936011261082e5780734529a01c7a0410167c5740c487a8de60232617bf60209252f35b600435906001600160a01b038216820361001257565b60005b8381106111a05750506000910152565b8181015183820152602001611190565b906020916111c98151809281855285808601910161118d565b601f01601f1916010190565b60a0810190811067ffffffffffffffff8211176111f157604052565b634e487b7160e01b600052604160045260246000fd5b6060810190811067ffffffffffffffff8211176111f157604052565b90601f8019910116810190811067ffffffffffffffff8211176111f157604052565b503461001257600036600319011261001257602060405160008152f35b6040906003190112610012576004359060243590565b6033546001600160a01b0316330361128c57565b606460405162461bcd60e51b815260206004820152602060248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152fd5b603380546001600160a01b039283166001600160a01b0319821681179092559091167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a3565b1561132057565b60405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608490fd5b81601f8201121561001257805167ffffffffffffffff81116111f157604051926113ad601f8301601f191660200185611223565b81845260208284010111610012576113cb916020808501910161118d565b90565b9060208282031261001257815167ffffffffffffffff8111610012576113cb9201611379565b51906001600160a01b038216820361001257565b519062ffffff8216820361001257565b51908160020b82036100125756fea26469706673582212206175b84b300a26795113456698b9e39cee7b078d72dafd761810a589aa91273064736f6c63430008110033
Deployed Bytecode
0x6080604081815260049081361015610017575b600080fd5b600092833560e01c9081631bea83fe14611149575080632cf8f1f6146110a85780632d6d225e1461105857806332c961d914610f21578063395960bb14610873578063417be3f214610e87578063512bcef914610e21578063594a1bf314610d1157806362308e8514610cee57806367ce2fc614610bfd578063715018a614610ba05780637df8773a14610b505780638129fc1c14610a1e57806388c0a8a7146108a85780638da5cb5b1461087f578063a3f18ed814610873578063aa4cfccd14610844578063b79b5004146106cf578063c38f8f351461067f578063c684206c146105f1578063ca883bec14610563578063cb9886e214610464578063cd7f833c14610337578063d1c62f261461029d578063f2fde38b1461020b5763f9f59a771461014357600080fd5b346102075782816003193601126102045761019292610160611177565b835163f9f59a7760e01b81526001600160a01b0390911691810191825260243560208301529384918291604090910190565b0381735e916b28c62d0752a1c953d96c400efb330b68155af49182156101fa57836101d194936101d5575b5050519182916020835260208301906111b0565b0390f35b6101f29293503d8091833e6101ea8183611223565b8101906113ce565b9038806101bd565b81513d85823e3d90fd5b80fd5b8280fd5b50903461020757602036600319011261020757610226611177565b9161022f611278565b6001600160a01b0383161561024b5783610248846112d0565b80f35b906020608492519162461bcd60e51b8352820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152fd5b5034610207576102ac36611262565b9082519363df966b3160e01b855284015260248301527386e8631a016f9068c3f085faf484ee3f5fdee8f26044830152734529a01c7a0410167c5740c487a8de60232617bf60648301528282608481731d3d302185e032e454ad50067987169d6a322c195af49182156101fa57836101d194936101d5575050519182916020835260208301906111b0565b50903461020757602036600319011261020757610352611177565b8251635d2b752d60e11b81526001600160a01b03918216928101929092526004617e61608e1b0160248301529160a082604481737856f02e7080d507c08abb85058976761f0ab0e15af490811561045b57849385908691879588956103dd575b5060a09750835196875216602086015260020b9084015262ffffff8092166060840152166080820152f35b965050925050915060a0833d8211610453575b816103fd60a09383611223565b8101031261044f57825191602084015193828516850361044b5760a09550610426828201611418565b9261043f608061043860608501611408565b9301611408565b949593919493386103b2565b8580fd5b8380fd5b3d91506103f0565b513d85823e3d90fd5b50346102075760e03660031901126102075760a036604319011261020757805191634ebc99a160e11b835280359083015260243560248301527386e8631a016f9068c3f085faf484ee3f5fdee8f2604483015260443560018060a01b039081811680910361055f57606484015260643581811680910361055f57608484015260843562ffffff811680910361055f5760a484015260a4358060020b80910361055f5760c484015260c43590811680910361044f5760e4830152828261010481731d3d302185e032e454ad50067987169d6a322c195af49182156101fa57836101d194936101d5575050519182916020835260208301906111b0565b8480fd5b5034610207578281600319360112610204576105b392610581611177565b83516332a20efb60e21b81526001600160a01b0390911691810191825260243560208301529384918291604090910190565b0381737720a57fce419963108a4ca9e5131d0c39d6a5565af49182156101fa57836101d194936101d5575050519182916020835260208301906111b0565b5034610207578281600319360112610204576106419261060f611177565b83516331a1081b60e21b81526001600160a01b0390911691810191825260243560208301529384918291604090910190565b0381732a741b29212d410440a9b782ee85c8939ad7f1725af49182156101fa57836101d194936101d5575050519182916020835260208301906111b0565b5034610207578281600319360112610204576105b39261069d611177565b835163c38f8f3560e01b81526001600160a01b0390911691810191825260243560208301529384918291604090910190565b5082903461082e576020918260031936011261020457833567ffffffffffffffff60c01b811680910361082e578183805161070981611207565b828152828782015201528183519563a1eeee8960e01b8752860152816024860152604485015261010093848160648173a86d99e80cf3cc61a256bf443483f0f75f74f57f5af49283156108395782908390849285948680986107a7575b5050815181516001600160a01b039081168252898301511698810198909852810151908701526060860152608085015260a084015260c083015260e0820152f35b95509550509450505081853d8711610832575b6107c48183611223565b81010385811261082e5760601361020457508151906107e282611207565b6107eb816113f4565b82526107f88482016113f4565b848301528281015183830152606081015192608082015160a0830151918060e060c086015195015195969293949596908a610766565b5080fd5b503d6107ba565b51913d9150823e3d90fd5b83823461082e578160031936011261082e57602090517386e8631a016f9068c3f085faf484ee3f5fdee8f28152f35b50505050610012611245565b83823461082e578160031936011261082e5760335490516001600160a01b039091168152602090f35b509034610207576020366003190112610207576108c3611177565b83608084516108d1816111d5565b8281526020810183905285810183905260608101839052015282516388c0a8a760e01b81526001600160a01b039182169281019290925260a082602481737856f02e7080d507c08abb85058976761f0ab0e15af4938415610a13578094610981575b60a08561097f865180926080908160018060a01b039182815116855282602082015116602086015262ffffff6040820151166040860152606081015160020b6060860152015116910152565bf35b9091935060a0843d8211610a0b575b8161099d60a09383611223565b810103126102045760808351946109b3866111d5565b6109bc816113f4565b86526109ca602082016113f4565b60208701526109da858201611408565b858701526109ea60608201611418565b6060870152015191821682036102045750608083015261097f60a038610933565b3d9150610990565b8351903d90823e3d90fd5b509034610207578260031936011261020757825460ff8160081c161591828093610b43575b8015610b2c575b15610ad2575060ff198116600117845581610ac1575b50610a7a60ff845460081c16610a7581611319565b611319565b610a83336112d0565b610a8b575080f35b60207f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989161ff001984541684555160018152a180f35b61ffff191661010117835538610a60565b608490602085519162461bcd60e51b8352820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152fd5b50303b158015610a4a5750600160ff831614610a4a565b50600160ff831610610a43565b5034610207578281600319360112610204576105b392610b6e611177565b8351633efc3b9d60e11b81526001600160a01b0390911691810191825260243560208301529384918291604090910190565b8334610204578060031936011261020457610bb9611278565b603380546001600160a01b0319811690915581906001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a380f35b5090346102075781600319360112610207576080610c4f91610c1d611177565b84516333e717e360e11b81526001600160a01b0390911691810191825260243560208301529283918291604090910190565b038173ac7e7a13d62d817c88531710fa308a766299f6445af4908115610ce25783928485928694610c94575b5060809550815194855260208501528301526060820152f35b9350509250506080813d8211610cda575b81610cb260809383611223565b8101031261020757608092508051602082015192606081840151930151919392919238610c7b565b3d9150610ca5565b505051903d90823e3d90fd5b83823461082e578160031936011261082e57602090516004617e61608e1b018152f35b5090346102075781600319360112610207579180610d6393610d31611177565b845163594a1bf360e01b81526001600160a01b0390911691810191825260243560208301529485918291604090910190565b0381731792f5f1214ade56c08ab9689f96f2e861a5f2645af4908115610e165780938192610db3575b50506101d190610da583519484869586528501906111b0565b9083820360208501526111b0565b915092503d8084833e610dc68183611223565b810190828183031261044f5780519067ffffffffffffffff9182811161044b5783610df2918301611379565b946020820151928311610204575091610e0f916101d19301611379565b9038610d8c565b8251903d90823e3d90fd5b503461020757610e3036611262565b9082519363512bcef960e01b855284015260248301528282604481731d3d302185e032e454ad50067987169d6a322c195af49182156101fa57836101d194936101d5575050519182916020835260208301906111b0565b5034610207578060031936011261020757610ea0611177565b815163148ec71960e31b81526001600160a01b039091169281019290925260248035908301527386e8631a016f9068c3f085faf484ee3f5fdee8f260448301528282606481737856f02e7080d507c08abb85058976761f0ab0e15af49182156101fa57836101d194936101d5575050519182916020835260208301906111b0565b5082903461082e5760a036600319011261082e57805192610f41846111d5565b610f49611177565b8452602435936001600160a01b03808616860361055f576020958683015260443562ffffff8116810361044b57848301526064358060020b810361044b576060830152608435908116810361055f5790610ff491608082015283519263aa5d0ea160e01b84528301906080908160018060a01b039182815116855282602082015116602086015262ffffff6040820151166040860152606081015160020b6060860152015116910152565b838160a481737856f02e7080d507c08abb85058976761f0ab0e15af4928315610e16578093611026575b505051908152f35b909192508382813d8311611051575b61103f8183611223565b8101031261020457505190838061101e565b503d611035565b5034610207578281600319360112610204576105b392611076611177565b83516316b6912f60e11b81526001600160a01b0390911691810191825260243560208301529384918291604090910190565b5091903461082e57602036600319011261082e578251906363e8cdbb60e11b8252803590820152828160248173600c6d5c1f15726a711d6d71a4205add668d53745af490811561113f57828092611108575b505082519182526020820152f35b915091508282813d8311611138575b6111218183611223565b8101031261020457506020815191015138806110fa565b503d611117565b83513d84823e3d90fd5b84903461082e578160031936011261082e5780734529a01c7a0410167c5740c487a8de60232617bf60209252f35b600435906001600160a01b038216820361001257565b60005b8381106111a05750506000910152565b8181015183820152602001611190565b906020916111c98151809281855285808601910161118d565b601f01601f1916010190565b60a0810190811067ffffffffffffffff8211176111f157604052565b634e487b7160e01b600052604160045260246000fd5b6060810190811067ffffffffffffffff8211176111f157604052565b90601f8019910116810190811067ffffffffffffffff8211176111f157604052565b503461001257600036600319011261001257602060405160008152f35b6040906003190112610012576004359060243590565b6033546001600160a01b0316330361128c57565b606460405162461bcd60e51b815260206004820152602060248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152fd5b603380546001600160a01b039283166001600160a01b0319821681179092559091167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a3565b1561132057565b60405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608490fd5b81601f8201121561001257805167ffffffffffffffff81116111f157604051926113ad601f8301601f191660200185611223565b81845260208284010111610012576113cb916020808501910161118d565b90565b9060208282031261001257815167ffffffffffffffff8111610012576113cb9201611379565b51906001600160a01b038216820361001257565b519062ffffff8216820361001257565b51908160020b82036100125756fea26469706673582212206175b84b300a26795113456698b9e39cee7b078d72dafd761810a589aa91273064736f6c63430008110033
Loading...
Loading
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in ETH
0
Multichain Portfolio | 35 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
Loading...
Loading
Loading...
Loading
Loading...
Loading
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.