Source Code
Latest 8 from a total of 8 transactions
| Transaction Hash |
|
Block
|
From
|
To
|
|||||
|---|---|---|---|---|---|---|---|---|---|
| Distribute Fees | 37998950 | 96 days ago | IN | 0 ETH | 0.0000126 | ||||
| Distribute Fees | 37974076 | 96 days ago | IN | 0 ETH | 0.00001089 | ||||
| Distribute Fees | 37972765 | 96 days ago | IN | 0 ETH | 0.00000412 | ||||
| Set NFT Collecti... | 37881410 | 98 days ago | IN | 0 ETH | 0.00000005 | ||||
| Set Custom ERC20... | 37881410 | 98 days ago | IN | 0 ETH | 0.00000005 | ||||
| Set USDC Address | 37881410 | 98 days ago | IN | 0 ETH | 0.00000005 | ||||
| Set Artist Addre... | 37881410 | 98 days ago | IN | 0 ETH | 0.00000005 | ||||
| Set Fee Recipien... | 37881410 | 98 days ago | IN | 0 ETH | 0.00000003 |
Latest 1 internal transaction
| Parent Transaction Hash | Block | From | To | |||
|---|---|---|---|---|---|---|
| 37881211 | 98 days ago | Contract Creation | 0 ETH |
Cross-Chain Transactions
Loading...
Loading
Contract Name:
FlamingStarHook
Compiler Version
v0.8.26+commit.8a97fa7a
Optimization Enabled:
Yes with 1000000 runs
Other Settings:
cancun EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;
import {BaseHook} from "@uniswap/v4-periphery/src/utils/BaseHook.sol";
import {Hooks} from "@uniswap/v4-core/src/libraries/Hooks.sol";
import {IPoolManager} from "@uniswap/v4-core/src/interfaces/IPoolManager.sol";
import {PoolKey} from "@uniswap/v4-core/src/types/PoolKey.sol";
import {Currency} from "@uniswap/v4-core/src/types/Currency.sol";
import {BalanceDelta} from "@uniswap/v4-core/src/types/BalanceDelta.sol";
import {SwapParams} from "@uniswap/v4-core/src/types/PoolOperation.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {IERC721} from "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
import {ReentrancyGuard} from "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
/// @notice Interface for FlamingStarNFT contract
interface IFlamingStarNFT is IERC721 {
function totalMinted() external view returns (uint256);
}
/// @title FlamingStarHook - Enhanced fee hook with NFT holder distribution
/// @notice Takes configurable fee and distributes to artist and NFT holders
/// @dev Blocks exact output swaps, only allows exact input
contract FlamingStarHook is BaseHook, Ownable, ReentrancyGuard {
// ============================================
// STATE VARIABLES
// ============================================
address public feeRecipient;
// Distribution addresses
address public artistAddress; // Receives 50% of USDC in distribution
address public usdcAddress; // USDC token contract
address public customERC20Address; // Custom ERC20 token (to be burned)
IERC721 public nftCollection; // NFT contract for holder distribution
uint256 public feeBps; // Fee rate in basis points (600 = 6%)
// Constants
address public constant BURN_ADDRESS = 0x000000000000000000000000000000000000dEaD;
uint256 public constant BPS_DENOMINATOR = 10000;
// ============================================
// EVENTS
// ============================================
event FeeRecipientUpdated(address indexed oldRecipient, address indexed newRecipient);
event ArtistAddressUpdated(address indexed oldArtist, address indexed newArtist);
event USDCAddressUpdated(address indexed oldUsdc, address indexed newUsdc);
event CustomERC20AddressUpdated(address indexed oldERC20, address indexed newERC20);
event NFTCollectionUpdated(address indexed nftCollection);
event FeeBpsUpdated(uint256 oldFeeBps, uint256 newFeeBps);
event CustomERC20Burned(uint256 amount);
event ArtistPaid(address indexed artist, uint256 amount);
event HolderPaid(address indexed holder, uint256 nftCount, uint256 shareAmount);
event FeesDistributedToHolders(uint256 totalAmount, uint256 uniqueHolders, uint256 timestamp);
event EmergencyWithdrawal(address indexed to, address indexed token, uint256 amount);
// ============================================
// ERRORS
// ============================================
/// @notice Exact output swaps are not allowed (like TokenWorks)
error ExactOutputNotAllowed();
// ============================================
// CONSTRUCTOR
// ============================================
constructor(
IPoolManager _poolManager,
address _feeRecipient,
address _owner
) BaseHook(_poolManager) Ownable(_owner) {
require(_feeRecipient != address(0), "Invalid recipient");
require(_owner != address(0), "Invalid owner");
feeRecipient = _feeRecipient;
feeBps = 600; // Default 6% fee
}
// ============================================
// HOOK PERMISSIONS
// ============================================
function getHookPermissions() public pure override returns (Hooks.Permissions memory) {
return Hooks.Permissions({
beforeInitialize: false,
afterInitialize: false,
beforeAddLiquidity: false,
beforeRemoveLiquidity: false,
afterAddLiquidity: false,
afterRemoveLiquidity: false,
beforeSwap: false,
afterSwap: true, // Only afterSwap
beforeDonate: false,
afterDonate: false,
beforeSwapReturnDelta: false,
afterSwapReturnDelta: true, // Take fees
afterAddLiquidityReturnDelta: false,
afterRemoveLiquidityReturnDelta: false
});
}
// ============================================
// HOOK FUNCTION - CORE LOGIC (UNCHANGED)
// ============================================
function _afterSwap(
address,
PoolKey calldata key,
SwapParams calldata params,
BalanceDelta delta,
bytes calldata
) internal override returns (bytes4, int128) {
// Restrict Exact Output swaps (like TokenWorks does)
if (params.amountSpecified > 0) {
revert ExactOutputNotAllowed();
}
// Since we only allow exact input, the unspecified currency is always the output
// User specifies input (negative amount), receives variable output
Currency unspecifiedCurrency = params.zeroForOne ? key.currency1 : key.currency0;
int128 unspecifiedAmount = params.zeroForOne ? delta.amount1() : delta.amount0();
// No positive unspecified amount = no fee
if (unspecifiedAmount <= 0) {
return (BaseHook.afterSwap.selector, 0);
}
// Calculate fee using configurable feeBps
uint256 feeAmount = (uint128(unspecifiedAmount) * feeBps) / BPS_DENOMINATOR;
if (feeAmount == 0) {
return (BaseHook.afterSwap.selector, 0);
}
// Take fee directly to recipient
poolManager.take(unspecifiedCurrency, feeRecipient, feeAmount);
// Return fee amount to adjust user's final balance
// Cast uint256 → uint128 → int128
return (BaseHook.afterSwap.selector, int128(uint128(feeAmount)));
}
// ============================================
// ADMIN FUNCTIONS - CONFIGURATION
// ============================================
function setFeeRecipient(address newRecipient) external onlyOwner {
require(newRecipient != address(0), "Invalid recipient");
address oldRecipient = feeRecipient;
feeRecipient = newRecipient;
emit FeeRecipientUpdated(oldRecipient, newRecipient);
}
function setArtistAddress(address _artist) external onlyOwner {
require(_artist != address(0), "Invalid artist address");
address oldArtist = artistAddress;
artistAddress = _artist;
emit ArtistAddressUpdated(oldArtist, _artist);
}
function setUSDCAddress(address _usdc) external onlyOwner {
require(_usdc != address(0), "Invalid USDC address");
address oldUsdc = usdcAddress;
usdcAddress = _usdc;
emit USDCAddressUpdated(oldUsdc, _usdc);
}
function setCustomERC20Address(address _customERC20) external onlyOwner {
require(_customERC20 != address(0), "Invalid ERC20 address");
address oldERC20 = customERC20Address;
customERC20Address = _customERC20;
emit CustomERC20AddressUpdated(oldERC20, _customERC20);
}
function setNFTCollection(address _nftCollection) external onlyOwner {
require(_nftCollection != address(0), "Invalid NFT address");
nftCollection = IERC721(_nftCollection);
emit NFTCollectionUpdated(_nftCollection);
}
function setFeeBps(uint256 _feeBps) external onlyOwner {
uint256 oldFeeBps = feeBps;
feeBps = _feeBps;
emit FeeBpsUpdated(oldFeeBps, _feeBps);
}
// ============================================
// FEE DISTRIBUTION - PUBLIC FUNCTION
// ============================================
/// @notice Distributes accumulated fees: burns CustomERC20, distributes USDC
/// @dev Can be called by anyone - triggers both burn and distribution
function distributeFees() external nonReentrant {
// Burn all accumulated CustomERC20
_burnCustomERC20();
// Distribute all accumulated USDC (50% artist, 50% NFT holders)
_distributeUSDC();
}
// ============================================
// INTERNAL DISTRIBUTION FUNCTIONS
// ============================================
/// @notice Burns all accumulated CustomERC20 tokens
function _burnCustomERC20() internal {
if (customERC20Address == address(0)) return;
IERC20 customToken = IERC20(customERC20Address);
uint256 balance = customToken.balanceOf(address(this));
if (balance == 0) return;
require(customToken.transfer(BURN_ADDRESS, balance), "Burn transfer failed");
emit CustomERC20Burned(balance);
}
/// @notice Distributes USDC: 50% to artist, 50% to NFT holders
function _distributeUSDC() internal {
if (usdcAddress == address(0)) return;
IERC20 usdcToken = IERC20(usdcAddress);
uint256 balance = usdcToken.balanceOf(address(this));
if (balance == 0) return;
uint256 artistShare = balance / 2;
uint256 holderShare = balance - artistShare;
// Send 50% to artist
if (artistAddress != address(0)) {
require(usdcToken.transfer(artistAddress, artistShare), "Artist transfer failed");
emit ArtistPaid(artistAddress, artistShare);
} else {
// If no artist set, add to holder share
holderShare += artistShare;
}
// Distribute 50% to NFT holders
if (address(nftCollection) != address(0)) {
_distributeToNFTHolders(holderShare);
} else {
// If no NFT collection, send to artist
if (artistAddress != address(0)) {
require(usdcToken.transfer(artistAddress, holderShare), "Fallback transfer failed");
}
}
}
/// @notice Distributes fees proportionally to NFT holders
/// @dev Uses exact pattern from FlamingStarHook for proven reliability
function _distributeToNFTHolders(uint256 totalAmount) internal {
IFlamingStarNFT nft = IFlamingStarNFT(address(nftCollection));
IERC20 usdcToken = IERC20(usdcAddress);
uint256 mintedCount = nft.totalMinted();
if (mintedCount == 0) {
// No NFTs minted, send to artist
if (artistAddress != address(0)) {
require(usdcToken.transfer(artistAddress, totalAmount), "Fallback transfer failed");
}
return;
}
// Build holder list
address[] memory holders = new address[](mintedCount);
uint256[] memory nftCounts = new uint256[](mintedCount);
uint256 uniqueHolders = 0;
for (uint256 tokenId = 0; tokenId < mintedCount; tokenId++) {
address owner = nft.ownerOf(tokenId);
bool found = false;
uint256 holderIndex;
for (uint256 i = 0; i < uniqueHolders; i++) {
if (holders[i] == owner) {
found = true;
holderIndex = i;
break;
}
}
if (found) {
nftCounts[holderIndex]++;
} else {
holders[uniqueHolders] = owner;
nftCounts[uniqueHolders] = 1;
uniqueHolders++;
}
}
// Distribute proportional shares
for (uint256 i = 0; i < uniqueHolders; i++) {
uint256 share = (totalAmount * nftCounts[i]) / mintedCount;
if (share > 0) {
require(usdcToken.transfer(holders[i], share), "Holder transfer failed");
emit HolderPaid(holders[i], nftCounts[i], share);
}
}
emit FeesDistributedToHolders(totalAmount, uniqueHolders, block.timestamp);
}
// ============================================
// EMERGENCY FUNCTIONS
// ============================================
/// @notice Emergency withdrawal of any token
/// @dev Only owner can call - safety mechanism if distribution fails
function emergencyWithdraw(address token, address to, uint256 amount) external onlyOwner nonReentrant {
require(to != address(0), "Invalid recipient");
require(token != address(0), "Invalid token");
IERC20(token).transfer(to, amount);
emit EmergencyWithdrawal(to, token, amount);
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {Hooks} from "@uniswap/v4-core/src/libraries/Hooks.sol";
import {IPoolManager} from "@uniswap/v4-core/src/interfaces/IPoolManager.sol";
import {IHooks} from "@uniswap/v4-core/src/interfaces/IHooks.sol";
import {BalanceDelta} from "@uniswap/v4-core/src/types/BalanceDelta.sol";
import {PoolKey} from "@uniswap/v4-core/src/types/PoolKey.sol";
import {BeforeSwapDelta} from "@uniswap/v4-core/src/types/BeforeSwapDelta.sol";
import {ImmutableState} from "../base/ImmutableState.sol";
import {ModifyLiquidityParams, SwapParams} from "@uniswap/v4-core/src/types/PoolOperation.sol";
/// @title Base Hook
/// @notice abstract contract for hook implementations
abstract contract BaseHook is IHooks, ImmutableState {
error HookNotImplemented();
constructor(IPoolManager _manager) ImmutableState(_manager) {
validateHookAddress(this);
}
/// @notice Returns a struct of permissions to signal which hook functions are to be implemented
/// @dev Used at deployment to validate the address correctly represents the expected permissions
/// @return Permissions struct
function getHookPermissions() public pure virtual returns (Hooks.Permissions memory);
/// @notice Validates the deployed hook address agrees with the expected permissions of the hook
/// @dev this function is virtual so that we can override it during testing,
/// which allows us to deploy an implementation to any address
/// and then etch the bytecode into the correct address
function validateHookAddress(BaseHook _this) internal pure virtual {
Hooks.validateHookPermissions(_this, getHookPermissions());
}
/// @inheritdoc IHooks
function beforeInitialize(address sender, PoolKey calldata key, uint160 sqrtPriceX96)
external
onlyPoolManager
returns (bytes4)
{
return _beforeInitialize(sender, key, sqrtPriceX96);
}
function _beforeInitialize(address, PoolKey calldata, uint160) internal virtual returns (bytes4) {
revert HookNotImplemented();
}
/// @inheritdoc IHooks
function afterInitialize(address sender, PoolKey calldata key, uint160 sqrtPriceX96, int24 tick)
external
onlyPoolManager
returns (bytes4)
{
return _afterInitialize(sender, key, sqrtPriceX96, tick);
}
function _afterInitialize(address, PoolKey calldata, uint160, int24) internal virtual returns (bytes4) {
revert HookNotImplemented();
}
/// @inheritdoc IHooks
function beforeAddLiquidity(
address sender,
PoolKey calldata key,
ModifyLiquidityParams calldata params,
bytes calldata hookData
) external onlyPoolManager returns (bytes4) {
return _beforeAddLiquidity(sender, key, params, hookData);
}
function _beforeAddLiquidity(address, PoolKey calldata, ModifyLiquidityParams calldata, bytes calldata)
internal
virtual
returns (bytes4)
{
revert HookNotImplemented();
}
/// @inheritdoc IHooks
function beforeRemoveLiquidity(
address sender,
PoolKey calldata key,
ModifyLiquidityParams calldata params,
bytes calldata hookData
) external onlyPoolManager returns (bytes4) {
return _beforeRemoveLiquidity(sender, key, params, hookData);
}
function _beforeRemoveLiquidity(address, PoolKey calldata, ModifyLiquidityParams calldata, bytes calldata)
internal
virtual
returns (bytes4)
{
revert HookNotImplemented();
}
/// @inheritdoc IHooks
function afterAddLiquidity(
address sender,
PoolKey calldata key,
ModifyLiquidityParams calldata params,
BalanceDelta delta,
BalanceDelta feesAccrued,
bytes calldata hookData
) external onlyPoolManager returns (bytes4, BalanceDelta) {
return _afterAddLiquidity(sender, key, params, delta, feesAccrued, hookData);
}
function _afterAddLiquidity(
address,
PoolKey calldata,
ModifyLiquidityParams calldata,
BalanceDelta,
BalanceDelta,
bytes calldata
) internal virtual returns (bytes4, BalanceDelta) {
revert HookNotImplemented();
}
/// @inheritdoc IHooks
function afterRemoveLiquidity(
address sender,
PoolKey calldata key,
ModifyLiquidityParams calldata params,
BalanceDelta delta,
BalanceDelta feesAccrued,
bytes calldata hookData
) external onlyPoolManager returns (bytes4, BalanceDelta) {
return _afterRemoveLiquidity(sender, key, params, delta, feesAccrued, hookData);
}
function _afterRemoveLiquidity(
address,
PoolKey calldata,
ModifyLiquidityParams calldata,
BalanceDelta,
BalanceDelta,
bytes calldata
) internal virtual returns (bytes4, BalanceDelta) {
revert HookNotImplemented();
}
/// @inheritdoc IHooks
function beforeSwap(address sender, PoolKey calldata key, SwapParams calldata params, bytes calldata hookData)
external
onlyPoolManager
returns (bytes4, BeforeSwapDelta, uint24)
{
return _beforeSwap(sender, key, params, hookData);
}
function _beforeSwap(address, PoolKey calldata, SwapParams calldata, bytes calldata)
internal
virtual
returns (bytes4, BeforeSwapDelta, uint24)
{
revert HookNotImplemented();
}
/// @inheritdoc IHooks
function afterSwap(
address sender,
PoolKey calldata key,
SwapParams calldata params,
BalanceDelta delta,
bytes calldata hookData
) external onlyPoolManager returns (bytes4, int128) {
return _afterSwap(sender, key, params, delta, hookData);
}
function _afterSwap(address, PoolKey calldata, SwapParams calldata, BalanceDelta, bytes calldata)
internal
virtual
returns (bytes4, int128)
{
revert HookNotImplemented();
}
/// @inheritdoc IHooks
function beforeDonate(
address sender,
PoolKey calldata key,
uint256 amount0,
uint256 amount1,
bytes calldata hookData
) external onlyPoolManager returns (bytes4) {
return _beforeDonate(sender, key, amount0, amount1, hookData);
}
function _beforeDonate(address, PoolKey calldata, uint256, uint256, bytes calldata)
internal
virtual
returns (bytes4)
{
revert HookNotImplemented();
}
/// @inheritdoc IHooks
function afterDonate(
address sender,
PoolKey calldata key,
uint256 amount0,
uint256 amount1,
bytes calldata hookData
) external onlyPoolManager returns (bytes4) {
return _afterDonate(sender, key, amount0, amount1, hookData);
}
function _afterDonate(address, PoolKey calldata, uint256, uint256, bytes calldata)
internal
virtual
returns (bytes4)
{
revert HookNotImplemented();
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {PoolKey} from "../types/PoolKey.sol";
import {IHooks} from "../interfaces/IHooks.sol";
import {SafeCast} from "./SafeCast.sol";
import {LPFeeLibrary} from "./LPFeeLibrary.sol";
import {BalanceDelta, toBalanceDelta, BalanceDeltaLibrary} from "../types/BalanceDelta.sol";
import {BeforeSwapDelta, BeforeSwapDeltaLibrary} from "../types/BeforeSwapDelta.sol";
import {IPoolManager} from "../interfaces/IPoolManager.sol";
import {ModifyLiquidityParams, SwapParams} from "../types/PoolOperation.sol";
import {ParseBytes} from "./ParseBytes.sol";
import {CustomRevert} from "./CustomRevert.sol";
/// @notice V4 decides whether to invoke specific hooks by inspecting the least significant bits
/// of the address that the hooks contract is deployed to.
/// For example, a hooks contract deployed to address: 0x0000000000000000000000000000000000002400
/// has the lowest bits '10 0100 0000 0000' which would cause the 'before initialize' and 'after add liquidity' hooks to be used.
library Hooks {
using LPFeeLibrary for uint24;
using Hooks for IHooks;
using SafeCast for int256;
using BeforeSwapDeltaLibrary for BeforeSwapDelta;
using ParseBytes for bytes;
using CustomRevert for bytes4;
uint160 internal constant ALL_HOOK_MASK = uint160((1 << 14) - 1);
uint160 internal constant BEFORE_INITIALIZE_FLAG = 1 << 13;
uint160 internal constant AFTER_INITIALIZE_FLAG = 1 << 12;
uint160 internal constant BEFORE_ADD_LIQUIDITY_FLAG = 1 << 11;
uint160 internal constant AFTER_ADD_LIQUIDITY_FLAG = 1 << 10;
uint160 internal constant BEFORE_REMOVE_LIQUIDITY_FLAG = 1 << 9;
uint160 internal constant AFTER_REMOVE_LIQUIDITY_FLAG = 1 << 8;
uint160 internal constant BEFORE_SWAP_FLAG = 1 << 7;
uint160 internal constant AFTER_SWAP_FLAG = 1 << 6;
uint160 internal constant BEFORE_DONATE_FLAG = 1 << 5;
uint160 internal constant AFTER_DONATE_FLAG = 1 << 4;
uint160 internal constant BEFORE_SWAP_RETURNS_DELTA_FLAG = 1 << 3;
uint160 internal constant AFTER_SWAP_RETURNS_DELTA_FLAG = 1 << 2;
uint160 internal constant AFTER_ADD_LIQUIDITY_RETURNS_DELTA_FLAG = 1 << 1;
uint160 internal constant AFTER_REMOVE_LIQUIDITY_RETURNS_DELTA_FLAG = 1 << 0;
struct Permissions {
bool beforeInitialize;
bool afterInitialize;
bool beforeAddLiquidity;
bool afterAddLiquidity;
bool beforeRemoveLiquidity;
bool afterRemoveLiquidity;
bool beforeSwap;
bool afterSwap;
bool beforeDonate;
bool afterDonate;
bool beforeSwapReturnDelta;
bool afterSwapReturnDelta;
bool afterAddLiquidityReturnDelta;
bool afterRemoveLiquidityReturnDelta;
}
/// @notice Thrown if the address will not lead to the specified hook calls being called
/// @param hooks The address of the hooks contract
error HookAddressNotValid(address hooks);
/// @notice Hook did not return its selector
error InvalidHookResponse();
/// @notice Additional context for ERC-7751 wrapped error when a hook call fails
error HookCallFailed();
/// @notice The hook's delta changed the swap from exactIn to exactOut or vice versa
error HookDeltaExceedsSwapAmount();
/// @notice Utility function intended to be used in hook constructors to ensure
/// the deployed hooks address causes the intended hooks to be called
/// @param permissions The hooks that are intended to be called
/// @dev permissions param is memory as the function will be called from constructors
function validateHookPermissions(IHooks self, Permissions memory permissions) internal pure {
if (
permissions.beforeInitialize != self.hasPermission(BEFORE_INITIALIZE_FLAG)
|| permissions.afterInitialize != self.hasPermission(AFTER_INITIALIZE_FLAG)
|| permissions.beforeAddLiquidity != self.hasPermission(BEFORE_ADD_LIQUIDITY_FLAG)
|| permissions.afterAddLiquidity != self.hasPermission(AFTER_ADD_LIQUIDITY_FLAG)
|| permissions.beforeRemoveLiquidity != self.hasPermission(BEFORE_REMOVE_LIQUIDITY_FLAG)
|| permissions.afterRemoveLiquidity != self.hasPermission(AFTER_REMOVE_LIQUIDITY_FLAG)
|| permissions.beforeSwap != self.hasPermission(BEFORE_SWAP_FLAG)
|| permissions.afterSwap != self.hasPermission(AFTER_SWAP_FLAG)
|| permissions.beforeDonate != self.hasPermission(BEFORE_DONATE_FLAG)
|| permissions.afterDonate != self.hasPermission(AFTER_DONATE_FLAG)
|| permissions.beforeSwapReturnDelta != self.hasPermission(BEFORE_SWAP_RETURNS_DELTA_FLAG)
|| permissions.afterSwapReturnDelta != self.hasPermission(AFTER_SWAP_RETURNS_DELTA_FLAG)
|| permissions.afterAddLiquidityReturnDelta != self.hasPermission(AFTER_ADD_LIQUIDITY_RETURNS_DELTA_FLAG)
|| permissions.afterRemoveLiquidityReturnDelta
!= self.hasPermission(AFTER_REMOVE_LIQUIDITY_RETURNS_DELTA_FLAG)
) {
HookAddressNotValid.selector.revertWith(address(self));
}
}
/// @notice Ensures that the hook address includes at least one hook flag or dynamic fees, or is the 0 address
/// @param self The hook to verify
/// @param fee The fee of the pool the hook is used with
/// @return bool True if the hook address is valid
function isValidHookAddress(IHooks self, uint24 fee) internal pure returns (bool) {
// The hook can only have a flag to return a hook delta on an action if it also has the corresponding action flag
if (!self.hasPermission(BEFORE_SWAP_FLAG) && self.hasPermission(BEFORE_SWAP_RETURNS_DELTA_FLAG)) return false;
if (!self.hasPermission(AFTER_SWAP_FLAG) && self.hasPermission(AFTER_SWAP_RETURNS_DELTA_FLAG)) return false;
if (!self.hasPermission(AFTER_ADD_LIQUIDITY_FLAG) && self.hasPermission(AFTER_ADD_LIQUIDITY_RETURNS_DELTA_FLAG))
{
return false;
}
if (
!self.hasPermission(AFTER_REMOVE_LIQUIDITY_FLAG)
&& self.hasPermission(AFTER_REMOVE_LIQUIDITY_RETURNS_DELTA_FLAG)
) return false;
// If there is no hook contract set, then fee cannot be dynamic
// If a hook contract is set, it must have at least 1 flag set, or have a dynamic fee
return address(self) == address(0)
? !fee.isDynamicFee()
: (uint160(address(self)) & ALL_HOOK_MASK > 0 || fee.isDynamicFee());
}
/// @notice performs a hook call using the given calldata on the given hook that doesn't return a delta
/// @return result The complete data returned by the hook
function callHook(IHooks self, bytes memory data) internal returns (bytes memory result) {
bool success;
assembly ("memory-safe") {
success := call(gas(), self, 0, add(data, 0x20), mload(data), 0, 0)
}
// Revert with FailedHookCall, containing any error message to bubble up
if (!success) CustomRevert.bubbleUpAndRevertWith(address(self), bytes4(data), HookCallFailed.selector);
// The call was successful, fetch the returned data
assembly ("memory-safe") {
// allocate result byte array from the free memory pointer
result := mload(0x40)
// store new free memory pointer at the end of the array padded to 32 bytes
mstore(0x40, add(result, and(add(returndatasize(), 0x3f), not(0x1f))))
// store length in memory
mstore(result, returndatasize())
// copy return data to result
returndatacopy(add(result, 0x20), 0, returndatasize())
}
// Length must be at least 32 to contain the selector. Check expected selector and returned selector match.
if (result.length < 32 || result.parseSelector() != data.parseSelector()) {
InvalidHookResponse.selector.revertWith();
}
}
/// @notice performs a hook call using the given calldata on the given hook
/// @return int256 The delta returned by the hook
function callHookWithReturnDelta(IHooks self, bytes memory data, bool parseReturn) internal returns (int256) {
bytes memory result = callHook(self, data);
// If this hook wasn't meant to return something, default to 0 delta
if (!parseReturn) return 0;
// A length of 64 bytes is required to return a bytes4, and a 32 byte delta
if (result.length != 64) InvalidHookResponse.selector.revertWith();
return result.parseReturnDelta();
}
/// @notice modifier to prevent calling a hook if they initiated the action
modifier noSelfCall(IHooks self) {
if (msg.sender != address(self)) {
_;
}
}
/// @notice calls beforeInitialize hook if permissioned and validates return value
function beforeInitialize(IHooks self, PoolKey memory key, uint160 sqrtPriceX96) internal noSelfCall(self) {
if (self.hasPermission(BEFORE_INITIALIZE_FLAG)) {
self.callHook(abi.encodeCall(IHooks.beforeInitialize, (msg.sender, key, sqrtPriceX96)));
}
}
/// @notice calls afterInitialize hook if permissioned and validates return value
function afterInitialize(IHooks self, PoolKey memory key, uint160 sqrtPriceX96, int24 tick)
internal
noSelfCall(self)
{
if (self.hasPermission(AFTER_INITIALIZE_FLAG)) {
self.callHook(abi.encodeCall(IHooks.afterInitialize, (msg.sender, key, sqrtPriceX96, tick)));
}
}
/// @notice calls beforeModifyLiquidity hook if permissioned and validates return value
function beforeModifyLiquidity(
IHooks self,
PoolKey memory key,
ModifyLiquidityParams memory params,
bytes calldata hookData
) internal noSelfCall(self) {
if (params.liquidityDelta > 0 && self.hasPermission(BEFORE_ADD_LIQUIDITY_FLAG)) {
self.callHook(abi.encodeCall(IHooks.beforeAddLiquidity, (msg.sender, key, params, hookData)));
} else if (params.liquidityDelta <= 0 && self.hasPermission(BEFORE_REMOVE_LIQUIDITY_FLAG)) {
self.callHook(abi.encodeCall(IHooks.beforeRemoveLiquidity, (msg.sender, key, params, hookData)));
}
}
/// @notice calls afterModifyLiquidity hook if permissioned and validates return value
function afterModifyLiquidity(
IHooks self,
PoolKey memory key,
ModifyLiquidityParams memory params,
BalanceDelta delta,
BalanceDelta feesAccrued,
bytes calldata hookData
) internal returns (BalanceDelta callerDelta, BalanceDelta hookDelta) {
if (msg.sender == address(self)) return (delta, BalanceDeltaLibrary.ZERO_DELTA);
callerDelta = delta;
if (params.liquidityDelta > 0) {
if (self.hasPermission(AFTER_ADD_LIQUIDITY_FLAG)) {
hookDelta = BalanceDelta.wrap(
self.callHookWithReturnDelta(
abi.encodeCall(
IHooks.afterAddLiquidity, (msg.sender, key, params, delta, feesAccrued, hookData)
),
self.hasPermission(AFTER_ADD_LIQUIDITY_RETURNS_DELTA_FLAG)
)
);
callerDelta = callerDelta - hookDelta;
}
} else {
if (self.hasPermission(AFTER_REMOVE_LIQUIDITY_FLAG)) {
hookDelta = BalanceDelta.wrap(
self.callHookWithReturnDelta(
abi.encodeCall(
IHooks.afterRemoveLiquidity, (msg.sender, key, params, delta, feesAccrued, hookData)
),
self.hasPermission(AFTER_REMOVE_LIQUIDITY_RETURNS_DELTA_FLAG)
)
);
callerDelta = callerDelta - hookDelta;
}
}
}
/// @notice calls beforeSwap hook if permissioned and validates return value
function beforeSwap(IHooks self, PoolKey memory key, SwapParams memory params, bytes calldata hookData)
internal
returns (int256 amountToSwap, BeforeSwapDelta hookReturn, uint24 lpFeeOverride)
{
amountToSwap = params.amountSpecified;
if (msg.sender == address(self)) return (amountToSwap, BeforeSwapDeltaLibrary.ZERO_DELTA, lpFeeOverride);
if (self.hasPermission(BEFORE_SWAP_FLAG)) {
bytes memory result = callHook(self, abi.encodeCall(IHooks.beforeSwap, (msg.sender, key, params, hookData)));
// A length of 96 bytes is required to return a bytes4, a 32 byte delta, and an LP fee
if (result.length != 96) InvalidHookResponse.selector.revertWith();
// dynamic fee pools that want to override the cache fee, return a valid fee with the override flag. If override flag
// is set but an invalid fee is returned, the transaction will revert. Otherwise the current LP fee will be used
if (key.fee.isDynamicFee()) lpFeeOverride = result.parseFee();
// skip this logic for the case where the hook return is 0
if (self.hasPermission(BEFORE_SWAP_RETURNS_DELTA_FLAG)) {
hookReturn = BeforeSwapDelta.wrap(result.parseReturnDelta());
// any return in unspecified is passed to the afterSwap hook for handling
int128 hookDeltaSpecified = hookReturn.getSpecifiedDelta();
// Update the swap amount according to the hook's return, and check that the swap type doesn't change (exact input/output)
if (hookDeltaSpecified != 0) {
bool exactInput = amountToSwap < 0;
amountToSwap += hookDeltaSpecified;
if (exactInput ? amountToSwap > 0 : amountToSwap < 0) {
HookDeltaExceedsSwapAmount.selector.revertWith();
}
}
}
}
}
/// @notice calls afterSwap hook if permissioned and validates return value
function afterSwap(
IHooks self,
PoolKey memory key,
SwapParams memory params,
BalanceDelta swapDelta,
bytes calldata hookData,
BeforeSwapDelta beforeSwapHookReturn
) internal returns (BalanceDelta, BalanceDelta) {
if (msg.sender == address(self)) return (swapDelta, BalanceDeltaLibrary.ZERO_DELTA);
int128 hookDeltaSpecified = beforeSwapHookReturn.getSpecifiedDelta();
int128 hookDeltaUnspecified = beforeSwapHookReturn.getUnspecifiedDelta();
if (self.hasPermission(AFTER_SWAP_FLAG)) {
hookDeltaUnspecified += self.callHookWithReturnDelta(
abi.encodeCall(IHooks.afterSwap, (msg.sender, key, params, swapDelta, hookData)),
self.hasPermission(AFTER_SWAP_RETURNS_DELTA_FLAG)
).toInt128();
}
BalanceDelta hookDelta;
if (hookDeltaUnspecified != 0 || hookDeltaSpecified != 0) {
hookDelta = (params.amountSpecified < 0 == params.zeroForOne)
? toBalanceDelta(hookDeltaSpecified, hookDeltaUnspecified)
: toBalanceDelta(hookDeltaUnspecified, hookDeltaSpecified);
// the caller has to pay for (or receive) the hook's delta
swapDelta = swapDelta - hookDelta;
}
return (swapDelta, hookDelta);
}
/// @notice calls beforeDonate hook if permissioned and validates return value
function beforeDonate(IHooks self, PoolKey memory key, uint256 amount0, uint256 amount1, bytes calldata hookData)
internal
noSelfCall(self)
{
if (self.hasPermission(BEFORE_DONATE_FLAG)) {
self.callHook(abi.encodeCall(IHooks.beforeDonate, (msg.sender, key, amount0, amount1, hookData)));
}
}
/// @notice calls afterDonate hook if permissioned and validates return value
function afterDonate(IHooks self, PoolKey memory key, uint256 amount0, uint256 amount1, bytes calldata hookData)
internal
noSelfCall(self)
{
if (self.hasPermission(AFTER_DONATE_FLAG)) {
self.callHook(abi.encodeCall(IHooks.afterDonate, (msg.sender, key, amount0, amount1, hookData)));
}
}
function hasPermission(IHooks self, uint160 flag) internal pure returns (bool) {
return uint160(address(self)) & flag != 0;
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
import {Currency} from "../types/Currency.sol";
import {PoolKey} from "../types/PoolKey.sol";
import {IHooks} from "./IHooks.sol";
import {IERC6909Claims} from "./external/IERC6909Claims.sol";
import {IProtocolFees} from "./IProtocolFees.sol";
import {BalanceDelta} from "../types/BalanceDelta.sol";
import {PoolId} from "../types/PoolId.sol";
import {IExtsload} from "./IExtsload.sol";
import {IExttload} from "./IExttload.sol";
import {ModifyLiquidityParams, SwapParams} from "../types/PoolOperation.sol";
/// @notice Interface for the PoolManager
interface IPoolManager is IProtocolFees, IERC6909Claims, IExtsload, IExttload {
/// @notice Thrown when a currency is not netted out after the contract is unlocked
error CurrencyNotSettled();
/// @notice Thrown when trying to interact with a non-initialized pool
error PoolNotInitialized();
/// @notice Thrown when unlock is called, but the contract is already unlocked
error AlreadyUnlocked();
/// @notice Thrown when a function is called that requires the contract to be unlocked, but it is not
error ManagerLocked();
/// @notice Pools are limited to type(int16).max tickSpacing in #initialize, to prevent overflow
error TickSpacingTooLarge(int24 tickSpacing);
/// @notice Pools must have a positive non-zero tickSpacing passed to #initialize
error TickSpacingTooSmall(int24 tickSpacing);
/// @notice PoolKey must have currencies where address(currency0) < address(currency1)
error CurrenciesOutOfOrderOrEqual(address currency0, address currency1);
/// @notice Thrown when a call to updateDynamicLPFee is made by an address that is not the hook,
/// or on a pool that does not have a dynamic swap fee.
error UnauthorizedDynamicLPFeeUpdate();
/// @notice Thrown when trying to swap amount of 0
error SwapAmountCannotBeZero();
///@notice Thrown when native currency is passed to a non native settlement
error NonzeroNativeValue();
/// @notice Thrown when `clear` is called with an amount that is not exactly equal to the open currency delta.
error MustClearExactPositiveDelta();
/// @notice Emitted when a new pool is initialized
/// @param id The abi encoded hash of the pool key struct for the new pool
/// @param currency0 The first currency of the pool by address sort order
/// @param currency1 The second currency of the pool by address sort order
/// @param fee The fee collected upon every swap in the pool, denominated in hundredths of a bip
/// @param tickSpacing The minimum number of ticks between initialized ticks
/// @param hooks The hooks contract address for the pool, or address(0) if none
/// @param sqrtPriceX96 The price of the pool on initialization
/// @param tick The initial tick of the pool corresponding to the initialized price
event Initialize(
PoolId indexed id,
Currency indexed currency0,
Currency indexed currency1,
uint24 fee,
int24 tickSpacing,
IHooks hooks,
uint160 sqrtPriceX96,
int24 tick
);
/// @notice Emitted when a liquidity position is modified
/// @param id The abi encoded hash of the pool key struct for the pool that was modified
/// @param sender The address that modified the pool
/// @param tickLower The lower tick of the position
/// @param tickUpper The upper tick of the position
/// @param liquidityDelta The amount of liquidity that was added or removed
/// @param salt The extra data to make positions unique
event ModifyLiquidity(
PoolId indexed id, address indexed sender, int24 tickLower, int24 tickUpper, int256 liquidityDelta, bytes32 salt
);
/// @notice Emitted for swaps between currency0 and currency1
/// @param id The abi encoded hash of the pool key struct for the pool that was modified
/// @param sender The address that initiated the swap call, and that received the callback
/// @param amount0 The delta of the currency0 balance of the pool
/// @param amount1 The delta of the currency1 balance of the pool
/// @param sqrtPriceX96 The sqrt(price) of the pool after the swap, as a Q64.96
/// @param liquidity The liquidity of the pool after the swap
/// @param tick The log base 1.0001 of the price of the pool after the swap
/// @param fee The swap fee in hundredths of a bip
event Swap(
PoolId indexed id,
address indexed sender,
int128 amount0,
int128 amount1,
uint160 sqrtPriceX96,
uint128 liquidity,
int24 tick,
uint24 fee
);
/// @notice Emitted for donations
/// @param id The abi encoded hash of the pool key struct for the pool that was donated to
/// @param sender The address that initiated the donate call
/// @param amount0 The amount donated in currency0
/// @param amount1 The amount donated in currency1
event Donate(PoolId indexed id, address indexed sender, uint256 amount0, uint256 amount1);
/// @notice All interactions on the contract that account deltas require unlocking. A caller that calls `unlock` must implement
/// `IUnlockCallback(msg.sender).unlockCallback(data)`, where they interact with the remaining functions on this contract.
/// @dev The only functions callable without an unlocking are `initialize` and `updateDynamicLPFee`
/// @param data Any data to pass to the callback, via `IUnlockCallback(msg.sender).unlockCallback(data)`
/// @return The data returned by the call to `IUnlockCallback(msg.sender).unlockCallback(data)`
function unlock(bytes calldata data) external returns (bytes memory);
/// @notice Initialize the state for a given pool ID
/// @dev A swap fee totaling MAX_SWAP_FEE (100%) makes exact output swaps impossible since the input is entirely consumed by the fee
/// @param key The pool key for the pool to initialize
/// @param sqrtPriceX96 The initial square root price
/// @return tick The initial tick of the pool
function initialize(PoolKey memory key, uint160 sqrtPriceX96) external returns (int24 tick);
/// @notice Modify the liquidity for the given pool
/// @dev Poke by calling with a zero liquidityDelta
/// @param key The pool to modify liquidity in
/// @param params The parameters for modifying the liquidity
/// @param hookData The data to pass through to the add/removeLiquidity hooks
/// @return callerDelta The balance delta of the caller of modifyLiquidity. This is the total of both principal, fee deltas, and hook deltas if applicable
/// @return feesAccrued The balance delta of the fees generated in the liquidity range. Returned for informational purposes
/// @dev Note that feesAccrued can be artificially inflated by a malicious actor and integrators should be careful using the value
/// For pools with a single liquidity position, actors can donate to themselves to inflate feeGrowthGlobal (and consequently feesAccrued)
/// atomically donating and collecting fees in the same unlockCallback may make the inflated value more extreme
function modifyLiquidity(PoolKey memory key, ModifyLiquidityParams memory params, bytes calldata hookData)
external
returns (BalanceDelta callerDelta, BalanceDelta feesAccrued);
/// @notice Swap against the given pool
/// @param key The pool to swap in
/// @param params The parameters for swapping
/// @param hookData The data to pass through to the swap hooks
/// @return swapDelta The balance delta of the address swapping
/// @dev Swapping on low liquidity pools may cause unexpected swap amounts when liquidity available is less than amountSpecified.
/// Additionally note that if interacting with hooks that have the BEFORE_SWAP_RETURNS_DELTA_FLAG or AFTER_SWAP_RETURNS_DELTA_FLAG
/// the hook may alter the swap input/output. Integrators should perform checks on the returned swapDelta.
function swap(PoolKey memory key, SwapParams memory params, bytes calldata hookData)
external
returns (BalanceDelta swapDelta);
/// @notice Donate the given currency amounts to the in-range liquidity providers of a pool
/// @dev Calls to donate can be frontrun adding just-in-time liquidity, with the aim of receiving a portion donated funds.
/// Donors should keep this in mind when designing donation mechanisms.
/// @dev This function donates to in-range LPs at slot0.tick. In certain edge-cases of the swap algorithm, the `sqrtPrice` of
/// a pool can be at the lower boundary of tick `n`, but the `slot0.tick` of the pool is already `n - 1`. In this case a call to
/// `donate` would donate to tick `n - 1` (slot0.tick) not tick `n` (getTickAtSqrtPrice(slot0.sqrtPriceX96)).
/// Read the comments in `Pool.swap()` for more information about this.
/// @param key The key of the pool to donate to
/// @param amount0 The amount of currency0 to donate
/// @param amount1 The amount of currency1 to donate
/// @param hookData The data to pass through to the donate hooks
/// @return BalanceDelta The delta of the caller after the donate
function donate(PoolKey memory key, uint256 amount0, uint256 amount1, bytes calldata hookData)
external
returns (BalanceDelta);
/// @notice Writes the current ERC20 balance of the specified currency to transient storage
/// This is used to checkpoint balances for the manager and derive deltas for the caller.
/// @dev This MUST be called before any ERC20 tokens are sent into the contract, but can be skipped
/// for native tokens because the amount to settle is determined by the sent value.
/// However, if an ERC20 token has been synced and not settled, and the caller instead wants to settle
/// native funds, this function can be called with the native currency to then be able to settle the native currency
function sync(Currency currency) external;
/// @notice Called by the user to net out some value owed to the user
/// @dev Will revert if the requested amount is not available, consider using `mint` instead
/// @dev Can also be used as a mechanism for free flash loans
/// @param currency The currency to withdraw from the pool manager
/// @param to The address to withdraw to
/// @param amount The amount of currency to withdraw
function take(Currency currency, address to, uint256 amount) external;
/// @notice Called by the user to pay what is owed
/// @return paid The amount of currency settled
function settle() external payable returns (uint256 paid);
/// @notice Called by the user to pay on behalf of another address
/// @param recipient The address to credit for the payment
/// @return paid The amount of currency settled
function settleFor(address recipient) external payable returns (uint256 paid);
/// @notice WARNING - Any currency that is cleared, will be non-retrievable, and locked in the contract permanently.
/// A call to clear will zero out a positive balance WITHOUT a corresponding transfer.
/// @dev This could be used to clear a balance that is considered dust.
/// Additionally, the amount must be the exact positive balance. This is to enforce that the caller is aware of the amount being cleared.
function clear(Currency currency, uint256 amount) external;
/// @notice Called by the user to move value into ERC6909 balance
/// @param to The address to mint the tokens to
/// @param id The currency address to mint to ERC6909s, as a uint256
/// @param amount The amount of currency to mint
/// @dev The id is converted to a uint160 to correspond to a currency address
/// If the upper 12 bytes are not 0, they will be 0-ed out
function mint(address to, uint256 id, uint256 amount) external;
/// @notice Called by the user to move value from ERC6909 balance
/// @param from The address to burn the tokens from
/// @param id The currency address to burn from ERC6909s, as a uint256
/// @param amount The amount of currency to burn
/// @dev The id is converted to a uint160 to correspond to a currency address
/// If the upper 12 bytes are not 0, they will be 0-ed out
function burn(address from, uint256 id, uint256 amount) external;
/// @notice Updates the pools lp fees for the a pool that has enabled dynamic lp fees.
/// @dev A swap fee totaling MAX_SWAP_FEE (100%) makes exact output swaps impossible since the input is entirely consumed by the fee
/// @param key The key of the pool to update dynamic LP fees for
/// @param newDynamicLPFee The new dynamic pool LP fee
function updateDynamicLPFee(PoolKey memory key, uint24 newDynamicLPFee) external;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {Currency} from "./Currency.sol";
import {IHooks} from "../interfaces/IHooks.sol";
import {PoolIdLibrary} from "./PoolId.sol";
using PoolIdLibrary for PoolKey global;
/// @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;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {IERC20Minimal} from "../interfaces/external/IERC20Minimal.sol";
import {CustomRevert} from "../libraries/CustomRevert.sol";
type Currency is address;
using {greaterThan as >, lessThan as <, greaterThanOrEqualTo as >=, equals as ==} for Currency global;
using CurrencyLibrary for Currency global;
function equals(Currency currency, Currency other) pure returns (bool) {
return Currency.unwrap(currency) == Currency.unwrap(other);
}
function greaterThan(Currency currency, Currency other) pure returns (bool) {
return Currency.unwrap(currency) > Currency.unwrap(other);
}
function lessThan(Currency currency, Currency other) pure returns (bool) {
return Currency.unwrap(currency) < Currency.unwrap(other);
}
function greaterThanOrEqualTo(Currency currency, Currency other) pure returns (bool) {
return Currency.unwrap(currency) >= Currency.unwrap(other);
}
/// @title CurrencyLibrary
/// @dev This library allows for transferring and holding native tokens and ERC20 tokens
library CurrencyLibrary {
/// @notice Additional context for ERC-7751 wrapped error when a native transfer fails
error NativeTransferFailed();
/// @notice Additional context for ERC-7751 wrapped error when an ERC20 transfer fails
error ERC20TransferFailed();
/// @notice A constant to represent the native currency
Currency public constant ADDRESS_ZERO = Currency.wrap(address(0));
function transfer(Currency currency, address to, uint256 amount) internal {
// altered from https://github.com/transmissions11/solmate/blob/44a9963d4c78111f77caa0e65d677b8b46d6f2e6/src/utils/SafeTransferLib.sol
// modified custom error selectors
bool success;
if (currency.isAddressZero()) {
assembly ("memory-safe") {
// Transfer the ETH and revert if it fails.
success := call(gas(), to, amount, 0, 0, 0, 0)
}
// revert with NativeTransferFailed, containing the bubbled up error as an argument
if (!success) {
CustomRevert.bubbleUpAndRevertWith(to, bytes4(0), NativeTransferFailed.selector);
}
} else {
assembly ("memory-safe") {
// Get a pointer to some free memory.
let fmp := mload(0x40)
// Write the abi-encoded calldata into memory, beginning with the function selector.
mstore(fmp, 0xa9059cbb00000000000000000000000000000000000000000000000000000000)
mstore(add(fmp, 4), and(to, 0xffffffffffffffffffffffffffffffffffffffff)) // Append and mask the "to" argument.
mstore(add(fmp, 36), amount) // Append the "amount" argument. Masking not required as it's a full 32 byte type.
success :=
and(
// Set success to whether the call reverted, if not we check it either
// returned exactly 1 (can't just be non-zero data), or had no return data.
or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),
// We use 68 because the length of our calldata totals up like so: 4 + 32 * 2.
// We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.
// Counterintuitively, this call must be positioned second to the or() call in the
// surrounding and() call or else returndatasize() will be zero during the computation.
call(gas(), currency, 0, fmp, 68, 0, 32)
)
// Now clean the memory we used
mstore(fmp, 0) // 4 byte `selector` and 28 bytes of `to` were stored here
mstore(add(fmp, 0x20), 0) // 4 bytes of `to` and 28 bytes of `amount` were stored here
mstore(add(fmp, 0x40), 0) // 4 bytes of `amount` were stored here
}
// revert with ERC20TransferFailed, containing the bubbled up error as an argument
if (!success) {
CustomRevert.bubbleUpAndRevertWith(
Currency.unwrap(currency), IERC20Minimal.transfer.selector, ERC20TransferFailed.selector
);
}
}
}
function balanceOfSelf(Currency currency) internal view returns (uint256) {
if (currency.isAddressZero()) {
return address(this).balance;
} else {
return IERC20Minimal(Currency.unwrap(currency)).balanceOf(address(this));
}
}
function balanceOf(Currency currency, address owner) internal view returns (uint256) {
if (currency.isAddressZero()) {
return owner.balance;
} else {
return IERC20Minimal(Currency.unwrap(currency)).balanceOf(owner);
}
}
function isAddressZero(Currency currency) internal pure returns (bool) {
return Currency.unwrap(currency) == Currency.unwrap(ADDRESS_ZERO);
}
function toId(Currency currency) internal pure returns (uint256) {
return uint160(Currency.unwrap(currency));
}
// If the upper 12 bytes are non-zero, they will be zero-ed out
// Therefore, fromId() and toId() are not inverses of each other
function fromId(uint256 id) internal pure returns (Currency) {
return Currency.wrap(address(uint160(id)));
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {SafeCast} from "../libraries/SafeCast.sol";
/// @dev Two `int128` values packed into a single `int256` where the upper 128 bits represent the amount0
/// and the lower 128 bits represent the amount1.
type BalanceDelta is int256;
using {add as +, sub as -, eq as ==, neq as !=} for BalanceDelta global;
using BalanceDeltaLibrary for BalanceDelta global;
using SafeCast for int256;
function toBalanceDelta(int128 _amount0, int128 _amount1) pure returns (BalanceDelta balanceDelta) {
assembly ("memory-safe") {
balanceDelta := or(shl(128, _amount0), and(sub(shl(128, 1), 1), _amount1))
}
}
function add(BalanceDelta a, BalanceDelta b) pure returns (BalanceDelta) {
int256 res0;
int256 res1;
assembly ("memory-safe") {
let a0 := sar(128, a)
let a1 := signextend(15, a)
let b0 := sar(128, b)
let b1 := signextend(15, b)
res0 := add(a0, b0)
res1 := add(a1, b1)
}
return toBalanceDelta(res0.toInt128(), res1.toInt128());
}
function sub(BalanceDelta a, BalanceDelta b) pure returns (BalanceDelta) {
int256 res0;
int256 res1;
assembly ("memory-safe") {
let a0 := sar(128, a)
let a1 := signextend(15, a)
let b0 := sar(128, b)
let b1 := signextend(15, b)
res0 := sub(a0, b0)
res1 := sub(a1, b1)
}
return toBalanceDelta(res0.toInt128(), res1.toInt128());
}
function eq(BalanceDelta a, BalanceDelta b) pure returns (bool) {
return BalanceDelta.unwrap(a) == BalanceDelta.unwrap(b);
}
function neq(BalanceDelta a, BalanceDelta b) pure returns (bool) {
return BalanceDelta.unwrap(a) != BalanceDelta.unwrap(b);
}
/// @notice Library for getting the amount0 and amount1 deltas from the BalanceDelta type
library BalanceDeltaLibrary {
/// @notice A BalanceDelta of 0
BalanceDelta public constant ZERO_DELTA = BalanceDelta.wrap(0);
function amount0(BalanceDelta balanceDelta) internal pure returns (int128 _amount0) {
assembly ("memory-safe") {
_amount0 := sar(128, balanceDelta)
}
}
function amount1(BalanceDelta balanceDelta) internal pure returns (int128 _amount1) {
assembly ("memory-safe") {
_amount1 := signextend(15, balanceDelta)
}
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
import {PoolKey} from "../types/PoolKey.sol";
import {BalanceDelta} from "../types/BalanceDelta.sol";
/// @notice Parameter struct for `ModifyLiquidity` pool operations
struct ModifyLiquidityParams {
// the lower and upper tick of the position
int24 tickLower;
int24 tickUpper;
// how to modify the liquidity
int256 liquidityDelta;
// a value to set if you want unique liquidity positions at the same range
bytes32 salt;
}
/// @notice Parameter struct for `Swap` pool operations
struct SwapParams {
/// Whether to swap token0 for token1 or vice versa
bool zeroForOne;
/// The desired input amount if negative (exactIn), or the desired output amount if positive (exactOut)
int256 amountSpecified;
/// The sqrt price at which, if reached, the swap will stop executing
uint160 sqrtPriceLimitX96;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the value of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the value of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 value) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the
* allowance mechanism. `value` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 value) external returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/IERC721.sol)
pragma solidity ^0.8.20;
import {IERC165} from "../../utils/introspection/IERC165.sol";
/**
* @dev Required interface of an ERC721 compliant contract.
*/
interface IERC721 is IERC165 {
/**
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
*/
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
*/
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
*/
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/**
* @dev Returns the number of tokens in ``owner``'s account.
*/
function balanceOf(address owner) external view returns (uint256 balance);
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) external view returns (address owner);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon
* a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must have been allowed to move this token by either {approve} or
* {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon
* a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(address from, address to, uint256 tokenId) external;
/**
* @dev Transfers `tokenId` token from `from` to `to`.
*
* WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721
* or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must
* understand this adds an external call which potentially creates a reentrancy vulnerability.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 tokenId) external;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the address zero.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool approved) external;
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}
*/
function isApprovedForAll(address owner, address operator) external view returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)
pragma solidity ^0.8.20;
import {Context} from "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* The initial owner is set to the address provided by the deployer. This can
* later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
/**
* @dev The caller account is not authorized to perform an operation.
*/
error OwnableUnauthorizedAccount(address account);
/**
* @dev The owner is not a valid owner account. (eg. `address(0)`)
*/
error OwnableInvalidOwner(address owner);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the address provided by the deployer as the initial owner.
*/
constructor(address initialOwner) {
if (initialOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(initialOwner);
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
if (owner() != _msgSender()) {
revert OwnableUnauthorizedAccount(_msgSender());
}
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
if (newOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/ReentrancyGuard.sol)
pragma solidity ^0.8.20;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant NOT_ENTERED = 1;
uint256 private constant ENTERED = 2;
uint256 private _status;
/**
* @dev Unauthorized reentrant call.
*/
error ReentrancyGuardReentrantCall();
constructor() {
_status = NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
// On the first call to nonReentrant, _status will be NOT_ENTERED
if (_status == ENTERED) {
revert ReentrancyGuardReentrantCall();
}
// Any calls to nonReentrant after this point will fail
_status = ENTERED;
}
function _nonReentrantAfter() private {
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = NOT_ENTERED;
}
/**
* @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
* `nonReentrant` function in the call stack.
*/
function _reentrancyGuardEntered() internal view returns (bool) {
return _status == ENTERED;
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {PoolKey} from "../types/PoolKey.sol";
import {BalanceDelta} from "../types/BalanceDelta.sol";
import {ModifyLiquidityParams, SwapParams} from "../types/PoolOperation.sol";
import {BeforeSwapDelta} from "../types/BeforeSwapDelta.sol";
/// @notice V4 decides whether to invoke specific hooks by inspecting the least significant bits
/// of the address that the hooks contract is deployed to.
/// For example, a hooks contract deployed to address: 0x0000000000000000000000000000000000002400
/// has the lowest bits '10 0100 0000 0000' which would cause the 'before initialize' and 'after add liquidity' hooks to be used.
/// See the Hooks library for the full spec.
/// @dev Should only be callable by the v4 PoolManager.
interface IHooks {
/// @notice The hook called before the state of a pool is initialized
/// @param sender The initial msg.sender for the initialize call
/// @param key The key for the pool being initialized
/// @param sqrtPriceX96 The sqrt(price) of the pool as a Q64.96
/// @return bytes4 The function selector for the hook
function beforeInitialize(address sender, PoolKey calldata key, uint160 sqrtPriceX96) external returns (bytes4);
/// @notice The hook called after the state of a pool is initialized
/// @param sender The initial msg.sender for the initialize call
/// @param key The key for the pool being initialized
/// @param sqrtPriceX96 The sqrt(price) of the pool as a Q64.96
/// @param tick The current tick after the state of a pool is initialized
/// @return bytes4 The function selector for the hook
function afterInitialize(address sender, PoolKey calldata key, uint160 sqrtPriceX96, int24 tick)
external
returns (bytes4);
/// @notice The hook called before liquidity is added
/// @param sender The initial msg.sender for the add liquidity call
/// @param key The key for the pool
/// @param params The parameters for adding liquidity
/// @param hookData Arbitrary data handed into the PoolManager by the liquidity provider to be passed on to the hook
/// @return bytes4 The function selector for the hook
function beforeAddLiquidity(
address sender,
PoolKey calldata key,
ModifyLiquidityParams calldata params,
bytes calldata hookData
) external returns (bytes4);
/// @notice The hook called after liquidity is added
/// @param sender The initial msg.sender for the add liquidity call
/// @param key The key for the pool
/// @param params The parameters for adding liquidity
/// @param delta The caller's balance delta after adding liquidity; the sum of principal delta, fees accrued, and hook delta
/// @param feesAccrued The fees accrued since the last time fees were collected from this position
/// @param hookData Arbitrary data handed into the PoolManager by the liquidity provider to be passed on to the hook
/// @return bytes4 The function selector for the hook
/// @return BalanceDelta The hook's delta in token0 and token1. Positive: the hook is owed/took currency, negative: the hook owes/sent currency
function afterAddLiquidity(
address sender,
PoolKey calldata key,
ModifyLiquidityParams calldata params,
BalanceDelta delta,
BalanceDelta feesAccrued,
bytes calldata hookData
) external returns (bytes4, BalanceDelta);
/// @notice The hook called before liquidity is removed
/// @param sender The initial msg.sender for the remove liquidity call
/// @param key The key for the pool
/// @param params The parameters for removing liquidity
/// @param hookData Arbitrary data handed into the PoolManager by the liquidity provider to be be passed on to the hook
/// @return bytes4 The function selector for the hook
function beforeRemoveLiquidity(
address sender,
PoolKey calldata key,
ModifyLiquidityParams calldata params,
bytes calldata hookData
) external returns (bytes4);
/// @notice The hook called after liquidity is removed
/// @param sender The initial msg.sender for the remove liquidity call
/// @param key The key for the pool
/// @param params The parameters for removing liquidity
/// @param delta The caller's balance delta after removing liquidity; the sum of principal delta, fees accrued, and hook delta
/// @param feesAccrued The fees accrued since the last time fees were collected from this position
/// @param hookData Arbitrary data handed into the PoolManager by the liquidity provider to be be passed on to the hook
/// @return bytes4 The function selector for the hook
/// @return BalanceDelta The hook's delta in token0 and token1. Positive: the hook is owed/took currency, negative: the hook owes/sent currency
function afterRemoveLiquidity(
address sender,
PoolKey calldata key,
ModifyLiquidityParams calldata params,
BalanceDelta delta,
BalanceDelta feesAccrued,
bytes calldata hookData
) external returns (bytes4, BalanceDelta);
/// @notice The hook called before a swap
/// @param sender The initial msg.sender for the swap call
/// @param key The key for the pool
/// @param params The parameters for the swap
/// @param hookData Arbitrary data handed into the PoolManager by the swapper to be be passed on to the hook
/// @return bytes4 The function selector for the hook
/// @return BeforeSwapDelta The hook's delta in specified and unspecified currencies. Positive: the hook is owed/took currency, negative: the hook owes/sent currency
/// @return uint24 Optionally override the lp fee, only used if three conditions are met: 1. the Pool has a dynamic fee, 2. the value's 2nd highest bit is set (23rd bit, 0x400000), and 3. the value is less than or equal to the maximum fee (1 million)
function beforeSwap(address sender, PoolKey calldata key, SwapParams calldata params, bytes calldata hookData)
external
returns (bytes4, BeforeSwapDelta, uint24);
/// @notice The hook called after a swap
/// @param sender The initial msg.sender for the swap call
/// @param key The key for the pool
/// @param params The parameters for the swap
/// @param delta The amount owed to the caller (positive) or owed to the pool (negative)
/// @param hookData Arbitrary data handed into the PoolManager by the swapper to be be passed on to the hook
/// @return bytes4 The function selector for the hook
/// @return int128 The hook's delta in unspecified currency. Positive: the hook is owed/took currency, negative: the hook owes/sent currency
function afterSwap(
address sender,
PoolKey calldata key,
SwapParams calldata params,
BalanceDelta delta,
bytes calldata hookData
) external returns (bytes4, int128);
/// @notice The hook called before donate
/// @param sender The initial msg.sender for the donate call
/// @param key The key for the pool
/// @param amount0 The amount of token0 being donated
/// @param amount1 The amount of token1 being donated
/// @param hookData Arbitrary data handed into the PoolManager by the donor to be be passed on to the hook
/// @return bytes4 The function selector for the hook
function beforeDonate(
address sender,
PoolKey calldata key,
uint256 amount0,
uint256 amount1,
bytes calldata hookData
) external returns (bytes4);
/// @notice The hook called after donate
/// @param sender The initial msg.sender for the donate call
/// @param key The key for the pool
/// @param amount0 The amount of token0 being donated
/// @param amount1 The amount of token1 being donated
/// @param hookData Arbitrary data handed into the PoolManager by the donor to be be passed on to the hook
/// @return bytes4 The function selector for the hook
function afterDonate(
address sender,
PoolKey calldata key,
uint256 amount0,
uint256 amount1,
bytes calldata hookData
) external returns (bytes4);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
// Return type of the beforeSwap hook.
// Upper 128 bits is the delta in specified tokens. Lower 128 bits is delta in unspecified tokens (to match the afterSwap hook)
type BeforeSwapDelta is int256;
// Creates a BeforeSwapDelta from specified and unspecified
function toBeforeSwapDelta(int128 deltaSpecified, int128 deltaUnspecified)
pure
returns (BeforeSwapDelta beforeSwapDelta)
{
assembly ("memory-safe") {
beforeSwapDelta := or(shl(128, deltaSpecified), and(sub(shl(128, 1), 1), deltaUnspecified))
}
}
/// @notice Library for getting the specified and unspecified deltas from the BeforeSwapDelta type
library BeforeSwapDeltaLibrary {
/// @notice A BeforeSwapDelta of 0
BeforeSwapDelta public constant ZERO_DELTA = BeforeSwapDelta.wrap(0);
/// extracts int128 from the upper 128 bits of the BeforeSwapDelta
/// returned by beforeSwap
function getSpecifiedDelta(BeforeSwapDelta delta) internal pure returns (int128 deltaSpecified) {
assembly ("memory-safe") {
deltaSpecified := sar(128, delta)
}
}
/// extracts int128 from the lower 128 bits of the BeforeSwapDelta
/// returned by beforeSwap and afterSwap
function getUnspecifiedDelta(BeforeSwapDelta delta) internal pure returns (int128 deltaUnspecified) {
assembly ("memory-safe") {
deltaUnspecified := signextend(15, delta)
}
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {IPoolManager} from "@uniswap/v4-core/src/interfaces/IPoolManager.sol";
import {IImmutableState} from "../interfaces/IImmutableState.sol";
/// @title Immutable State
/// @notice A collection of immutable state variables, commonly used across multiple contracts
contract ImmutableState is IImmutableState {
/// @inheritdoc IImmutableState
IPoolManager public immutable poolManager;
/// @notice Thrown when the caller is not PoolManager
error NotPoolManager();
/// @notice Only allow calls from the PoolManager contract
modifier onlyPoolManager() {
if (msg.sender != address(poolManager)) revert NotPoolManager();
_;
}
constructor(IPoolManager _poolManager) {
poolManager = _poolManager;
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {CustomRevert} from "./CustomRevert.sol";
/// @title Safe casting methods
/// @notice Contains methods for safely casting between types
library SafeCast {
using CustomRevert for bytes4;
error SafeCastOverflow();
/// @notice Cast a uint256 to a uint160, revert on overflow
/// @param x The uint256 to be downcasted
/// @return y The downcasted integer, now type uint160
function toUint160(uint256 x) internal pure returns (uint160 y) {
y = uint160(x);
if (y != x) SafeCastOverflow.selector.revertWith();
}
/// @notice Cast a uint256 to a uint128, revert on overflow
/// @param x The uint256 to be downcasted
/// @return y The downcasted integer, now type uint128
function toUint128(uint256 x) internal pure returns (uint128 y) {
y = uint128(x);
if (x != y) SafeCastOverflow.selector.revertWith();
}
/// @notice Cast a int128 to a uint128, revert on overflow or underflow
/// @param x The int128 to be casted
/// @return y The casted integer, now type uint128
function toUint128(int128 x) internal pure returns (uint128 y) {
if (x < 0) SafeCastOverflow.selector.revertWith();
y = uint128(x);
}
/// @notice Cast a int256 to a int128, revert on overflow or underflow
/// @param x The int256 to be downcasted
/// @return y The downcasted integer, now type int128
function toInt128(int256 x) internal pure returns (int128 y) {
y = int128(x);
if (y != x) SafeCastOverflow.selector.revertWith();
}
/// @notice Cast a uint256 to a int256, revert on overflow
/// @param x The uint256 to be casted
/// @return y The casted integer, now type int256
function toInt256(uint256 x) internal pure returns (int256 y) {
y = int256(x);
if (y < 0) SafeCastOverflow.selector.revertWith();
}
/// @notice Cast a uint256 to a int128, revert on overflow
/// @param x The uint256 to be downcasted
/// @return The downcasted integer, now type int128
function toInt128(uint256 x) internal pure returns (int128) {
if (x >= 1 << 127) SafeCastOverflow.selector.revertWith();
return int128(int256(x));
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {CustomRevert} from "./CustomRevert.sol";
/// @notice Library of helper functions for a pools LP fee
library LPFeeLibrary {
using LPFeeLibrary for uint24;
using CustomRevert for bytes4;
/// @notice Thrown when the static or dynamic fee on a pool exceeds 100%.
error LPFeeTooLarge(uint24 fee);
/// @notice An lp fee of exactly 0b1000000... signals a dynamic fee pool. This isn't a valid static fee as it is > MAX_LP_FEE
uint24 public constant DYNAMIC_FEE_FLAG = 0x800000;
/// @notice the second bit of the fee returned by beforeSwap is used to signal if the stored LP fee should be overridden in this swap
// only dynamic-fee pools can return a fee via the beforeSwap hook
uint24 public constant OVERRIDE_FEE_FLAG = 0x400000;
/// @notice mask to remove the override fee flag from a fee returned by the beforeSwaphook
uint24 public constant REMOVE_OVERRIDE_MASK = 0xBFFFFF;
/// @notice the lp fee is represented in hundredths of a bip, so the max is 100%
uint24 public constant MAX_LP_FEE = 1000000;
/// @notice returns true if a pool's LP fee signals that the pool has a dynamic fee
/// @param self The fee to check
/// @return bool True of the fee is dynamic
function isDynamicFee(uint24 self) internal pure returns (bool) {
return self == DYNAMIC_FEE_FLAG;
}
/// @notice returns true if an LP fee is valid, aka not above the maximum permitted fee
/// @param self The fee to check
/// @return bool True of the fee is valid
function isValid(uint24 self) internal pure returns (bool) {
return self <= MAX_LP_FEE;
}
/// @notice validates whether an LP fee is larger than the maximum, and reverts if invalid
/// @param self The fee to validate
function validate(uint24 self) internal pure {
if (!self.isValid()) LPFeeTooLarge.selector.revertWith(self);
}
/// @notice gets and validates the initial LP fee for a pool. Dynamic fee pools have an initial fee of 0.
/// @dev if a dynamic fee pool wants a non-0 initial fee, it should call `updateDynamicLPFee` in the afterInitialize hook
/// @param self The fee to get the initial LP from
/// @return initialFee 0 if the fee is dynamic, otherwise the fee (if valid)
function getInitialLPFee(uint24 self) internal pure returns (uint24) {
// the initial fee for a dynamic fee pool is 0
if (self.isDynamicFee()) return 0;
self.validate();
return self;
}
/// @notice returns true if the fee has the override flag set (2nd highest bit of the uint24)
/// @param self The fee to check
/// @return bool True of the fee has the override flag set
function isOverride(uint24 self) internal pure returns (bool) {
return self & OVERRIDE_FEE_FLAG != 0;
}
/// @notice returns a fee with the override flag removed
/// @param self The fee to remove the override flag from
/// @return fee The fee without the override flag set
function removeOverrideFlag(uint24 self) internal pure returns (uint24) {
return self & REMOVE_OVERRIDE_MASK;
}
/// @notice Removes the override flag and validates the fee (reverts if the fee is too large)
/// @param self The fee to remove the override flag from, and then validate
/// @return fee The fee without the override flag set (if valid)
function removeOverrideFlagAndValidate(uint24 self) internal pure returns (uint24 fee) {
fee = self.removeOverrideFlag();
fee.validate();
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/// @notice Parses bytes returned from hooks and the byte selector used to check return selectors from hooks.
/// @dev parseSelector also is used to parse the expected selector
/// For parsing hook returns, note that all hooks return either bytes4 or (bytes4, 32-byte-delta) or (bytes4, 32-byte-delta, uint24).
library ParseBytes {
function parseSelector(bytes memory result) internal pure returns (bytes4 selector) {
// equivalent: (selector,) = abi.decode(result, (bytes4, int256));
assembly ("memory-safe") {
selector := mload(add(result, 0x20))
}
}
function parseFee(bytes memory result) internal pure returns (uint24 lpFee) {
// equivalent: (,, lpFee) = abi.decode(result, (bytes4, int256, uint24));
assembly ("memory-safe") {
lpFee := mload(add(result, 0x60))
}
}
function parseReturnDelta(bytes memory result) internal pure returns (int256 hookReturn) {
// equivalent: (, hookReturnDelta) = abi.decode(result, (bytes4, int256));
assembly ("memory-safe") {
hookReturn := mload(add(result, 0x40))
}
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/// @title Library for reverting with custom errors efficiently
/// @notice Contains functions for reverting with custom errors with different argument types efficiently
/// @dev To use this library, declare `using CustomRevert for bytes4;` and replace `revert CustomError()` with
/// `CustomError.selector.revertWith()`
/// @dev The functions may tamper with the free memory pointer but it is fine since the call context is exited immediately
library CustomRevert {
/// @dev ERC-7751 error for wrapping bubbled up reverts
error WrappedError(address target, bytes4 selector, bytes reason, bytes details);
/// @dev Reverts with the selector of a custom error in the scratch space
function revertWith(bytes4 selector) internal pure {
assembly ("memory-safe") {
mstore(0, selector)
revert(0, 0x04)
}
}
/// @dev Reverts with a custom error with an address argument in the scratch space
function revertWith(bytes4 selector, address addr) internal pure {
assembly ("memory-safe") {
mstore(0, selector)
mstore(0x04, and(addr, 0xffffffffffffffffffffffffffffffffffffffff))
revert(0, 0x24)
}
}
/// @dev Reverts with a custom error with an int24 argument in the scratch space
function revertWith(bytes4 selector, int24 value) internal pure {
assembly ("memory-safe") {
mstore(0, selector)
mstore(0x04, signextend(2, value))
revert(0, 0x24)
}
}
/// @dev Reverts with a custom error with a uint160 argument in the scratch space
function revertWith(bytes4 selector, uint160 value) internal pure {
assembly ("memory-safe") {
mstore(0, selector)
mstore(0x04, and(value, 0xffffffffffffffffffffffffffffffffffffffff))
revert(0, 0x24)
}
}
/// @dev Reverts with a custom error with two int24 arguments
function revertWith(bytes4 selector, int24 value1, int24 value2) internal pure {
assembly ("memory-safe") {
let fmp := mload(0x40)
mstore(fmp, selector)
mstore(add(fmp, 0x04), signextend(2, value1))
mstore(add(fmp, 0x24), signextend(2, value2))
revert(fmp, 0x44)
}
}
/// @dev Reverts with a custom error with two uint160 arguments
function revertWith(bytes4 selector, uint160 value1, uint160 value2) internal pure {
assembly ("memory-safe") {
let fmp := mload(0x40)
mstore(fmp, selector)
mstore(add(fmp, 0x04), and(value1, 0xffffffffffffffffffffffffffffffffffffffff))
mstore(add(fmp, 0x24), and(value2, 0xffffffffffffffffffffffffffffffffffffffff))
revert(fmp, 0x44)
}
}
/// @dev Reverts with a custom error with two address arguments
function revertWith(bytes4 selector, address value1, address value2) internal pure {
assembly ("memory-safe") {
let fmp := mload(0x40)
mstore(fmp, selector)
mstore(add(fmp, 0x04), and(value1, 0xffffffffffffffffffffffffffffffffffffffff))
mstore(add(fmp, 0x24), and(value2, 0xffffffffffffffffffffffffffffffffffffffff))
revert(fmp, 0x44)
}
}
/// @notice bubble up the revert message returned by a call and revert with a wrapped ERC-7751 error
/// @dev this method can be vulnerable to revert data bombs
function bubbleUpAndRevertWith(
address revertingContract,
bytes4 revertingFunctionSelector,
bytes4 additionalContext
) internal pure {
bytes4 wrappedErrorSelector = WrappedError.selector;
assembly ("memory-safe") {
// Ensure the size of the revert data is a multiple of 32 bytes
let encodedDataSize := mul(div(add(returndatasize(), 31), 32), 32)
let fmp := mload(0x40)
// Encode wrapped error selector, address, function selector, offset, additional context, size, revert reason
mstore(fmp, wrappedErrorSelector)
mstore(add(fmp, 0x04), and(revertingContract, 0xffffffffffffffffffffffffffffffffffffffff))
mstore(
add(fmp, 0x24),
and(revertingFunctionSelector, 0xffffffff00000000000000000000000000000000000000000000000000000000)
)
// offset revert reason
mstore(add(fmp, 0x44), 0x80)
// offset additional context
mstore(add(fmp, 0x64), add(0xa0, encodedDataSize))
// size revert reason
mstore(add(fmp, 0x84), returndatasize())
// revert reason
returndatacopy(add(fmp, 0xa4), 0, returndatasize())
// size additional context
mstore(add(fmp, add(0xa4, encodedDataSize)), 0x04)
// additional context
mstore(
add(fmp, add(0xc4, encodedDataSize)),
and(additionalContext, 0xffffffff00000000000000000000000000000000000000000000000000000000)
)
revert(fmp, add(0xe4, encodedDataSize))
}
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/// @notice Interface for claims over a contract balance, wrapped as a ERC6909
interface IERC6909Claims {
/*//////////////////////////////////////////////////////////////
EVENTS
//////////////////////////////////////////////////////////////*/
event OperatorSet(address indexed owner, address indexed operator, bool approved);
event Approval(address indexed owner, address indexed spender, uint256 indexed id, uint256 amount);
event Transfer(address caller, address indexed from, address indexed to, uint256 indexed id, uint256 amount);
/*//////////////////////////////////////////////////////////////
FUNCTIONS
//////////////////////////////////////////////////////////////*/
/// @notice Owner balance of an id.
/// @param owner The address of the owner.
/// @param id The id of the token.
/// @return amount The balance of the token.
function balanceOf(address owner, uint256 id) external view returns (uint256 amount);
/// @notice Spender allowance of an id.
/// @param owner The address of the owner.
/// @param spender The address of the spender.
/// @param id The id of the token.
/// @return amount The allowance of the token.
function allowance(address owner, address spender, uint256 id) external view returns (uint256 amount);
/// @notice Checks if a spender is approved by an owner as an operator
/// @param owner The address of the owner.
/// @param spender The address of the spender.
/// @return approved The approval status.
function isOperator(address owner, address spender) external view returns (bool approved);
/// @notice Transfers an amount of an id from the caller to a receiver.
/// @param receiver The address of the receiver.
/// @param id The id of the token.
/// @param amount The amount of the token.
/// @return bool True, always, unless the function reverts
function transfer(address receiver, uint256 id, uint256 amount) external returns (bool);
/// @notice Transfers an amount of an id from a sender to a receiver.
/// @param sender The address of the sender.
/// @param receiver The address of the receiver.
/// @param id The id of the token.
/// @param amount The amount of the token.
/// @return bool True, always, unless the function reverts
function transferFrom(address sender, address receiver, uint256 id, uint256 amount) external returns (bool);
/// @notice Approves an amount of an id to a spender.
/// @param spender The address of the spender.
/// @param id The id of the token.
/// @param amount The amount of the token.
/// @return bool True, always
function approve(address spender, uint256 id, uint256 amount) external returns (bool);
/// @notice Sets or removes an operator for the caller.
/// @param operator The address of the operator.
/// @param approved The approval status.
/// @return bool True, always
function setOperator(address operator, bool approved) external returns (bool);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {Currency} from "../types/Currency.sol";
import {PoolId} from "../types/PoolId.sol";
import {PoolKey} from "../types/PoolKey.sol";
/// @notice Interface for all protocol-fee related functions in the pool manager
interface IProtocolFees {
/// @notice Thrown when protocol fee is set too high
error ProtocolFeeTooLarge(uint24 fee);
/// @notice Thrown when collectProtocolFees or setProtocolFee is not called by the controller.
error InvalidCaller();
/// @notice Thrown when collectProtocolFees is attempted on a token that is synced.
error ProtocolFeeCurrencySynced();
/// @notice Emitted when the protocol fee controller address is updated in setProtocolFeeController.
event ProtocolFeeControllerUpdated(address indexed protocolFeeController);
/// @notice Emitted when the protocol fee is updated for a pool.
event ProtocolFeeUpdated(PoolId indexed id, uint24 protocolFee);
/// @notice Given a currency address, returns the protocol fees accrued in that currency
/// @param currency The currency to check
/// @return amount The amount of protocol fees accrued in the currency
function protocolFeesAccrued(Currency currency) external view returns (uint256 amount);
/// @notice Sets the protocol fee for the given pool
/// @param key The key of the pool to set a protocol fee for
/// @param newProtocolFee The fee to set
function setProtocolFee(PoolKey memory key, uint24 newProtocolFee) external;
/// @notice Sets the protocol fee controller
/// @param controller The new protocol fee controller
function setProtocolFeeController(address controller) external;
/// @notice Collects the protocol fees for a given recipient and currency, returning the amount collected
/// @dev This will revert if the contract is unlocked
/// @param recipient The address to receive the protocol fees
/// @param currency The currency to withdraw
/// @param amount The amount of currency to withdraw
/// @return amountCollected The amount of currency successfully withdrawn
function collectProtocolFees(address recipient, Currency currency, uint256 amount)
external
returns (uint256 amountCollected);
/// @notice Returns the current protocol fee controller address
/// @return address The current protocol fee controller address
function protocolFeeController() external view returns (address);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {PoolKey} from "./PoolKey.sol";
type PoolId is bytes32;
/// @notice Library for computing the ID of a pool
library PoolIdLibrary {
/// @notice Returns value equal to keccak256(abi.encode(poolKey))
function toId(PoolKey memory poolKey) internal pure returns (PoolId poolId) {
assembly ("memory-safe") {
// 0xa0 represents the total size of the poolKey struct (5 slots of 32 bytes)
poolId := keccak256(poolKey, 0xa0)
}
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/// @notice Interface for functions to access any storage slot in a contract
interface IExtsload {
/// @notice Called by external contracts to access granular pool state
/// @param slot Key of slot to sload
/// @return value The value of the slot as bytes32
function extsload(bytes32 slot) external view returns (bytes32 value);
/// @notice Called by external contracts to access granular pool state
/// @param startSlot Key of slot to start sloading from
/// @param nSlots Number of slots to load into return value
/// @return values List of loaded values.
function extsload(bytes32 startSlot, uint256 nSlots) external view returns (bytes32[] memory values);
/// @notice Called by external contracts to access sparse pool state
/// @param slots List of slots to SLOAD from.
/// @return values List of loaded values.
function extsload(bytes32[] calldata slots) external view returns (bytes32[] memory values);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
/// @notice Interface for functions to access any transient storage slot in a contract
interface IExttload {
/// @notice Called by external contracts to access transient storage of the contract
/// @param slot Key of slot to tload
/// @return value The value of the slot as bytes32
function exttload(bytes32 slot) external view returns (bytes32 value);
/// @notice Called by external contracts to access sparse transient pool state
/// @param slots List of slots to tload
/// @return values List of loaded values
function exttload(bytes32[] calldata slots) external view returns (bytes32[] memory values);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/// @title Minimal ERC20 interface for Uniswap
/// @notice Contains a subset of the full ERC20 interface that is used in Uniswap V3
interface IERC20Minimal {
/// @notice Returns an account's balance in the token
/// @param account The account for which to look up the number of tokens it has, i.e. its balance
/// @return The number of tokens held by the account
function balanceOf(address account) external view returns (uint256);
/// @notice Transfers the amount of token from the `msg.sender` to the recipient
/// @param recipient The account that will receive the amount transferred
/// @param amount The number of tokens to send from the sender to the recipient
/// @return Returns true for a successful transfer, false for an unsuccessful transfer
function transfer(address recipient, uint256 amount) external returns (bool);
/// @notice Returns the current allowance given to a spender by an owner
/// @param owner The account of the token owner
/// @param spender The account of the token spender
/// @return The current allowance granted by `owner` to `spender`
function allowance(address owner, address spender) external view returns (uint256);
/// @notice Sets the allowance of a spender from the `msg.sender` to the value `amount`
/// @param spender The account which will be allowed to spend a given amount of the owners tokens
/// @param amount The amount of tokens allowed to be used by `spender`
/// @return Returns true for a successful approval, false for unsuccessful
function approve(address spender, uint256 amount) external returns (bool);
/// @notice Transfers `amount` tokens from `sender` to `recipient` up to the allowance given to the `msg.sender`
/// @param sender The account from which the transfer will be initiated
/// @param recipient The recipient of the transfer
/// @param amount The amount of the transfer
/// @return Returns true for a successful transfer, false for unsuccessful
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/// @notice Event emitted when tokens are transferred from one address to another, either via `#transfer` or `#transferFrom`.
/// @param from The account from which the tokens were sent, i.e. the balance decreased
/// @param to The account to which the tokens were sent, i.e. the balance increased
/// @param value The amount of tokens that were transferred
event Transfer(address indexed from, address indexed to, uint256 value);
/// @notice Event emitted when the approval amount for the spender of a given owner's tokens changes.
/// @param owner The account that approved spending of its tokens
/// @param spender The account for which the spending allowance was modified
/// @param value The new allowance from the owner to the spender
event Approval(address indexed owner, address indexed spender, uint256 value);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)
pragma solidity ^0.8.20;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {IPoolManager} from "@uniswap/v4-core/src/interfaces/IPoolManager.sol";
/// @title IImmutableState
/// @notice Interface for the ImmutableState contract
interface IImmutableState {
/// @notice The Uniswap v4 PoolManager contract
function poolManager() external view returns (IPoolManager);
}{
"remappings": [
"@uniswap/v4-core/=lib/v4-core/",
"@uniswap/v4-periphery/=lib/v4-periphery/",
"forge-std/=lib/forge-std/src/",
"@openzeppelin/=lib/v4-core/lib/openzeppelin-contracts/",
"solmate/=lib/v4-core/lib/solmate/",
"permit2/=lib/v4-periphery/lib/permit2/",
"ds-test/=lib/forge-std/lib/ds-test/src/",
"solady/=lib/solady/src/"
],
"optimizer": {
"enabled": true,
"runs": 1000000
},
"metadata": {
"useLiteralContent": false,
"bytecodeHash": "ipfs",
"appendCBOR": true
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"evmVersion": "cancun",
"viaIR": true
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"contract IPoolManager","name":"_poolManager","type":"address"},{"internalType":"address","name":"_feeRecipient","type":"address"},{"internalType":"address","name":"_owner","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"ExactOutputNotAllowed","type":"error"},{"inputs":[],"name":"HookNotImplemented","type":"error"},{"inputs":[],"name":"NotPoolManager","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"OwnableInvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"OwnableUnauthorizedAccount","type":"error"},{"inputs":[],"name":"ReentrancyGuardReentrantCall","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"oldArtist","type":"address"},{"indexed":true,"internalType":"address","name":"newArtist","type":"address"}],"name":"ArtistAddressUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"artist","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"ArtistPaid","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"oldERC20","type":"address"},{"indexed":true,"internalType":"address","name":"newERC20","type":"address"}],"name":"CustomERC20AddressUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"CustomERC20Burned","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"EmergencyWithdrawal","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"oldFeeBps","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newFeeBps","type":"uint256"}],"name":"FeeBpsUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"oldRecipient","type":"address"},{"indexed":true,"internalType":"address","name":"newRecipient","type":"address"}],"name":"FeeRecipientUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"totalAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"uniqueHolders","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"FeesDistributedToHolders","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"holder","type":"address"},{"indexed":false,"internalType":"uint256","name":"nftCount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"shareAmount","type":"uint256"}],"name":"HolderPaid","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"nftCollection","type":"address"}],"name":"NFTCollectionUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"oldUsdc","type":"address"},{"indexed":true,"internalType":"address","name":"newUsdc","type":"address"}],"name":"USDCAddressUpdated","type":"event"},{"inputs":[],"name":"BPS_DENOMINATOR","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"BURN_ADDRESS","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"components":[{"internalType":"Currency","name":"currency0","type":"address"},{"internalType":"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 PoolKey","name":"key","type":"tuple"},{"components":[{"internalType":"int24","name":"tickLower","type":"int24"},{"internalType":"int24","name":"tickUpper","type":"int24"},{"internalType":"int256","name":"liquidityDelta","type":"int256"},{"internalType":"bytes32","name":"salt","type":"bytes32"}],"internalType":"struct ModifyLiquidityParams","name":"params","type":"tuple"},{"internalType":"BalanceDelta","name":"delta","type":"int256"},{"internalType":"BalanceDelta","name":"feesAccrued","type":"int256"},{"internalType":"bytes","name":"hookData","type":"bytes"}],"name":"afterAddLiquidity","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"},{"internalType":"BalanceDelta","name":"","type":"int256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"components":[{"internalType":"Currency","name":"currency0","type":"address"},{"internalType":"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 PoolKey","name":"key","type":"tuple"},{"internalType":"uint256","name":"amount0","type":"uint256"},{"internalType":"uint256","name":"amount1","type":"uint256"},{"internalType":"bytes","name":"hookData","type":"bytes"}],"name":"afterDonate","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"components":[{"internalType":"Currency","name":"currency0","type":"address"},{"internalType":"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 PoolKey","name":"key","type":"tuple"},{"internalType":"uint160","name":"sqrtPriceX96","type":"uint160"},{"internalType":"int24","name":"tick","type":"int24"}],"name":"afterInitialize","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"components":[{"internalType":"Currency","name":"currency0","type":"address"},{"internalType":"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 PoolKey","name":"key","type":"tuple"},{"components":[{"internalType":"int24","name":"tickLower","type":"int24"},{"internalType":"int24","name":"tickUpper","type":"int24"},{"internalType":"int256","name":"liquidityDelta","type":"int256"},{"internalType":"bytes32","name":"salt","type":"bytes32"}],"internalType":"struct ModifyLiquidityParams","name":"params","type":"tuple"},{"internalType":"BalanceDelta","name":"delta","type":"int256"},{"internalType":"BalanceDelta","name":"feesAccrued","type":"int256"},{"internalType":"bytes","name":"hookData","type":"bytes"}],"name":"afterRemoveLiquidity","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"},{"internalType":"BalanceDelta","name":"","type":"int256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"components":[{"internalType":"Currency","name":"currency0","type":"address"},{"internalType":"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 PoolKey","name":"key","type":"tuple"},{"components":[{"internalType":"bool","name":"zeroForOne","type":"bool"},{"internalType":"int256","name":"amountSpecified","type":"int256"},{"internalType":"uint160","name":"sqrtPriceLimitX96","type":"uint160"}],"internalType":"struct SwapParams","name":"params","type":"tuple"},{"internalType":"BalanceDelta","name":"delta","type":"int256"},{"internalType":"bytes","name":"hookData","type":"bytes"}],"name":"afterSwap","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"},{"internalType":"int128","name":"","type":"int128"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"artistAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"components":[{"internalType":"Currency","name":"currency0","type":"address"},{"internalType":"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 PoolKey","name":"key","type":"tuple"},{"components":[{"internalType":"int24","name":"tickLower","type":"int24"},{"internalType":"int24","name":"tickUpper","type":"int24"},{"internalType":"int256","name":"liquidityDelta","type":"int256"},{"internalType":"bytes32","name":"salt","type":"bytes32"}],"internalType":"struct ModifyLiquidityParams","name":"params","type":"tuple"},{"internalType":"bytes","name":"hookData","type":"bytes"}],"name":"beforeAddLiquidity","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"components":[{"internalType":"Currency","name":"currency0","type":"address"},{"internalType":"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 PoolKey","name":"key","type":"tuple"},{"internalType":"uint256","name":"amount0","type":"uint256"},{"internalType":"uint256","name":"amount1","type":"uint256"},{"internalType":"bytes","name":"hookData","type":"bytes"}],"name":"beforeDonate","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"components":[{"internalType":"Currency","name":"currency0","type":"address"},{"internalType":"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 PoolKey","name":"key","type":"tuple"},{"internalType":"uint160","name":"sqrtPriceX96","type":"uint160"}],"name":"beforeInitialize","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"components":[{"internalType":"Currency","name":"currency0","type":"address"},{"internalType":"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 PoolKey","name":"key","type":"tuple"},{"components":[{"internalType":"int24","name":"tickLower","type":"int24"},{"internalType":"int24","name":"tickUpper","type":"int24"},{"internalType":"int256","name":"liquidityDelta","type":"int256"},{"internalType":"bytes32","name":"salt","type":"bytes32"}],"internalType":"struct ModifyLiquidityParams","name":"params","type":"tuple"},{"internalType":"bytes","name":"hookData","type":"bytes"}],"name":"beforeRemoveLiquidity","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"components":[{"internalType":"Currency","name":"currency0","type":"address"},{"internalType":"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 PoolKey","name":"key","type":"tuple"},{"components":[{"internalType":"bool","name":"zeroForOne","type":"bool"},{"internalType":"int256","name":"amountSpecified","type":"int256"},{"internalType":"uint160","name":"sqrtPriceLimitX96","type":"uint160"}],"internalType":"struct SwapParams","name":"params","type":"tuple"},{"internalType":"bytes","name":"hookData","type":"bytes"}],"name":"beforeSwap","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"},{"internalType":"BeforeSwapDelta","name":"","type":"int256"},{"internalType":"uint24","name":"","type":"uint24"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"customERC20Address","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"distributeFees","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"emergencyWithdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"feeBps","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"feeRecipient","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getHookPermissions","outputs":[{"components":[{"internalType":"bool","name":"beforeInitialize","type":"bool"},{"internalType":"bool","name":"afterInitialize","type":"bool"},{"internalType":"bool","name":"beforeAddLiquidity","type":"bool"},{"internalType":"bool","name":"afterAddLiquidity","type":"bool"},{"internalType":"bool","name":"beforeRemoveLiquidity","type":"bool"},{"internalType":"bool","name":"afterRemoveLiquidity","type":"bool"},{"internalType":"bool","name":"beforeSwap","type":"bool"},{"internalType":"bool","name":"afterSwap","type":"bool"},{"internalType":"bool","name":"beforeDonate","type":"bool"},{"internalType":"bool","name":"afterDonate","type":"bool"},{"internalType":"bool","name":"beforeSwapReturnDelta","type":"bool"},{"internalType":"bool","name":"afterSwapReturnDelta","type":"bool"},{"internalType":"bool","name":"afterAddLiquidityReturnDelta","type":"bool"},{"internalType":"bool","name":"afterRemoveLiquidityReturnDelta","type":"bool"}],"internalType":"struct Hooks.Permissions","name":"","type":"tuple"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"nftCollection","outputs":[{"internalType":"contract IERC721","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"poolManager","outputs":[{"internalType":"contract IPoolManager","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_artist","type":"address"}],"name":"setArtistAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_customERC20","type":"address"}],"name":"setCustomERC20Address","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_feeBps","type":"uint256"}],"name":"setFeeBps","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newRecipient","type":"address"}],"name":"setFeeRecipient","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_nftCollection","type":"address"}],"name":"setNFTCollection","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_usdc","type":"address"}],"name":"setUSDCAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"usdcAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}]Contract Creation Code
60a06040523461037157604051601f6129aa38819003918201601f19168301916001600160401b03831184841017610375578084926060946040528339810103126103715780516001600160a01b03811681036103715761006e6040610067602085016103a9565b93016103a9565b906080525f6101a061007e610389565b8281528260208201528260408201528260608201528260808201528260a08201528260c08201528260e0820152826101008201528261012082015282610140820152826101608201528261018082015201525f6101a06100dc610389565b8281528260208201528260408201528260608201528260808201528260a08201528260c0820152600160e08201528261010082015282610120820152826101408201526001610160820152826101808201520152612000301615801590610364575b8015610357575b801561034a575b801561033d575b8015610330575b8015610324575b8015610314575b8015610308575b80156102fc575b80156102f0575b80156102e0575b80156102d4575b80156102c8575b6102b5576001600160a01b03169081156102a2575f80546001600160a01b031981168417825560405193916001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09080a3600180556001600160a01b031690811561026c5750600280546001600160a01b0319169190911790556102586007556040516125ec90816103be823960805181818161054a0152818161067c0152818161071401528181610a2001528181610cf10152818161104a015281816111b0015281816113d301526119830152f35b62461bcd60e51b8152602060048201526011602482015270125b9d985b1a59081c9958da5c1a595b9d607a1b6044820152606490fd5b631e4fbdf760e01b5f525f60045260245ffd5b630732d7b560e51b5f523060045260245ffd5b50600130161515610192565b5060023016151561018b565b5060043016151560011415610184565b5060083016151561017d565b50601030161515610176565b5060203016151561016f565b5060403016151560011415610168565b50608030161515610161565b506101003016151561015a565b5061020030161515610153565b506104003016151561014c565b5061080030161515610145565b506110003016151561013e565b5f80fd5b634e487b7160e01b5f52604160045260245ffd5b604051906101c082016001600160401b0381118382101761037557604052565b51906001600160a01b03821682036103715756fe6080806040526004361015610012575f80fd5b5f3560e01c90816302d454571461145c5750806321d0ee70146113a957806324a9d85314611421578063259982e5146113a95780632832c59e146113585780632b4fd7791461124f57806346904840146111fe578063575e24b4146110e95780636588103b146110985780636c2bbe7e14610cc55780636fe7e6eb14610fbb578063715018a614610f2157806372c27b6214610eaf5780638c12c88714610d8f5780638da5cb5b14610d3f5780639f063efc14610cc5578063a22e4faa14610ba5578063aaf5bfc314610a85578063b47b2fb114610959578063b6a8b0fa1461051f578063bb57ad201461090d578063c4e833ce14610789578063d7eb3f3a14610738578063dc4c90d3146106ca578063dc98354e146105fa578063e1a45218146105c0578063e1b4af691461051f578063e63ea40814610362578063e74b981b1461029b578063f2fde38b146101af5763fccc281314610171575f80fd5b346101ab575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101ab57602060405161dead8152f35b5f80fd5b346101ab5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101ab5773ffffffffffffffffffffffffffffffffffffffff6101fb6114aa565b610203611863565b16801561026f5773ffffffffffffffffffffffffffffffffffffffff5f54827fffffffffffffffffffffffff00000000000000000000000000000000000000008216175f55167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e05f80a3005b7f1e4fbdf7000000000000000000000000000000000000000000000000000000005f525f60045260245ffd5b346101ab5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101ab5773ffffffffffffffffffffffffffffffffffffffff6102e76114aa565b6102ef611863565b166102fb8115156117e6565b73ffffffffffffffffffffffffffffffffffffffff600254827fffffffffffffffffffffffff0000000000000000000000000000000000000000821617600255167faaebcf1bfa00580e41d966056b48521fa9f202645c86d4ddf28113e617c1b1d35f80a3005b346101ab5760607ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101ab576103996114aa565b60243573ffffffffffffffffffffffffffffffffffffffff8116908181036101ab5773ffffffffffffffffffffffffffffffffffffffff604435936103dc611863565b6103e4611af1565b6103ef8415156117e6565b169283156104c1576040517fa9059cbb00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff929092166004830152602482018190526020826044815f885af19081156104b6577f9495d03190a79a43e534c9e328ff322f6283261383f5f19c809564f6ad5a57b39260209261048b575b50604051908152a360018055005b6104aa90833d85116104af575b6104a281836117a5565b81019061184b565b61047d565b503d610498565b6040513d5f823e3d90fd5b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600d60248201527f496e76616c696420746f6b656e000000000000000000000000000000000000006044820152fd5b346101ab5761052d366116ba565b50505050505073ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000163303610598577f0a85dc29000000000000000000000000000000000000000000000000000000005f5260045ffd5b7fae18210a000000000000000000000000000000000000000000000000000000005f5260045ffd5b346101ab575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101ab5760206040516127108152f35b346101ab5760e07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101ab576106316114aa565b5060a07fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc3601126101ab57610664611697565b5073ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000163303610598577f0a85dc29000000000000000000000000000000000000000000000000000000005f5260045ffd5b346101ab575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101ab57602060405173ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000168152f35b346101ab575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101ab57602073ffffffffffffffffffffffffffffffffffffffff60035416604051908152f35b346101ab575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101ab575f6101a06040516107c78161175b565b8281528260208201528260408201528260608201528260808201528260a08201528260c08201528260e0820152826101008201528261012082015282610140820152826101608201528261018082015201526101c0602060405161082a8161175b565b5f8152818101905f8252604081015f8152606082015f8152608083015f815260a084015f815260c085015f815260e0860190600182526101008701925f84526101208801945f86526101408901965f88526101608a019860018a526101a06101808c019b5f8d52019b5f8d526040519d8e915f835251151591015251151560408d015251151560608c015251151560808b015251151560a08a015251151560c089015251151560e08801525115156101008701525115156101208601525115156101408501525115156101608401525115156101808301525115156101a0820152f35b346101ab575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101ab57610943611af1565b61094b611b2a565b610953611d32565b60018055005b346101ab576101607ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101ab576109916114aa565b5060a07fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc3601126101ab5760607fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff3c3601126101ab576101443567ffffffffffffffff81116101ab57610a079036906004016114cd565b505073ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000163303610598576040610a54610124356118ef565b7fffffffff00000000000000000000000000000000000000000000000000000000835192168252600f0b6020820152f35b346101ab5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101ab5773ffffffffffffffffffffffffffffffffffffffff610ad16114aa565b610ad9611863565b168015610b475773ffffffffffffffffffffffffffffffffffffffff600454827fffffffffffffffffffffffff0000000000000000000000000000000000000000821617600455167fd6f103212e42c9ad7ce0b1d967e2f8b8cf8385a9220c0dc52c5c2fe9f6925f8f5f80a3005b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f496e76616c6964205553444320616464726573730000000000000000000000006044820152fd5b346101ab5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101ab5773ffffffffffffffffffffffffffffffffffffffff610bf16114aa565b610bf9611863565b168015610c675773ffffffffffffffffffffffffffffffffffffffff600354827fffffffffffffffffffffffff0000000000000000000000000000000000000000821617600355167f88bb0d30cd096c9e787230eb4b23281536acf0d6806dde8a6cc454808abbe8a45f80a3005b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f496e76616c6964206172746973742061646472657373000000000000000000006044820152fd5b346101ab57610cd3366115c6565b5050505050505073ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000163303610598577f0a85dc29000000000000000000000000000000000000000000000000000000005f5260045ffd5b346101ab575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101ab57602073ffffffffffffffffffffffffffffffffffffffff5f5416604051908152f35b346101ab5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101ab5773ffffffffffffffffffffffffffffffffffffffff610ddb6114aa565b610de3611863565b168015610e515773ffffffffffffffffffffffffffffffffffffffff600554827fffffffffffffffffffffffff0000000000000000000000000000000000000000821617600555167f53ca7c33bd496d83d897e526656d27ec062bb160170ebb50f6420cffb27c1ae15f80a3005b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f496e76616c6964204552433230206164647265737300000000000000000000006044820152fd5b346101ab5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101ab577f5ec5620e288c4be955ccb6cfb3d55431a8fed5c4c96ffacc4b9506360695f64e6040600435610f0c611863565b600754908060075582519182526020820152a1005b346101ab575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101ab57610f57611863565b5f73ffffffffffffffffffffffffffffffffffffffff81547fffffffffffffffffffffffff000000000000000000000000000000000000000081168355167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a3005b346101ab576101007ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101ab57610ff36114aa565b5060a07fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc3601126101ab57611026611697565b5060e4358060020b036101ab5773ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000163303610598577f0a85dc29000000000000000000000000000000000000000000000000000000005f5260045ffd5b346101ab575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101ab57602073ffffffffffffffffffffffffffffffffffffffff60065416604051908152f35b346101ab576101407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101ab576111216114aa565b5060a07fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc3601126101ab5760607fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff3c3601126101ab576101243567ffffffffffffffff81116101ab576111979036906004016114cd565b505073ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000163303610598577f0a85dc29000000000000000000000000000000000000000000000000000000005f5260045ffd5b346101ab575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101ab57602073ffffffffffffffffffffffffffffffffffffffff60025416604051908152f35b346101ab5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101ab5773ffffffffffffffffffffffffffffffffffffffff61129b6114aa565b6112a3611863565b1680156112fa57807fffffffffffffffffffffffff000000000000000000000000000000000000000060065416176006557fca87b4660417fb706ee5ce97aa88ce27f880beada493d35369edd786a38de4b55f80a2005b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f496e76616c6964204e46542061646472657373000000000000000000000000006044820152fd5b346101ab575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101ab57602073ffffffffffffffffffffffffffffffffffffffff60055416604051908152f35b346101ab576113b7366114fb565b505050505073ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000163303610598577f0a85dc29000000000000000000000000000000000000000000000000000000005f5260045ffd5b346101ab575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101ab576020600754604051908152f35b346101ab575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101ab5760209073ffffffffffffffffffffffffffffffffffffffff600454168152f35b6004359073ffffffffffffffffffffffffffffffffffffffff821682036101ab57565b9181601f840112156101ab5782359167ffffffffffffffff83116101ab57602083818601950101116101ab57565b906101607ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc8301126101ab5760043573ffffffffffffffffffffffffffffffffffffffff811681036101ab579160a07fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc8201126101ab5760249160807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff3c8301126101ab5760c491610144359067ffffffffffffffff82116101ab576115c2916004016114cd565b9091565b906101a07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc8301126101ab5760043573ffffffffffffffffffffffffffffffffffffffff811681036101ab579160a07fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc8201126101ab5760249160807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff3c8301126101ab5760c49161014435916101643591610184359067ffffffffffffffff82116101ab576115c2916004016114cd565b60c4359073ffffffffffffffffffffffffffffffffffffffff821682036101ab57565b6101207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc8201126101ab5760043573ffffffffffffffffffffffffffffffffffffffff811681036101ab579160a07fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc8301126101ab5760249160c4359160e43591610104359067ffffffffffffffff82116101ab576115c2916004016114cd565b6101c0810190811067ffffffffffffffff82111761177857604052565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b90601f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0910116810190811067ffffffffffffffff82111761177857604052565b156117ed57565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f496e76616c696420726563697069656e740000000000000000000000000000006044820152fd5b908160209103126101ab575180151581036101ab5790565b73ffffffffffffffffffffffffffffffffffffffff5f5416330361188357565b7f118cdaa7000000000000000000000000000000000000000000000000000000005f523360045260245ffd5b818102929181159184041417156118c257565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b905f60e43513611ac95760c4359182151583036101ab578215611aa35760443573ffffffffffffffffffffffffffffffffffffffff811681036101ab57925b15611a9b57600f0b5b5f81600f0b1315611a7357611964612710916fffffffffffffffffffffffffffffffff60075491166118af565b04918215611a735773ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff6002541691813b156101ab57606473ffffffffffffffffffffffffffffffffffffffff915f809460405196879586947f0b0d9c0900000000000000000000000000000000000000000000000000000000865216600485015260248401528860448401525af180156104b657611a63575b506fffffffffffffffffffffffffffffffff7fb47b2fb1000000000000000000000000000000000000000000000000000000009216600f0b90565b5f611a6d916117a5565b5f611a28565b507fb47b2fb10000000000000000000000000000000000000000000000000000000091505f90565b60801d611937565b60243573ffffffffffffffffffffffffffffffffffffffff811681036101ab579261192e565b7f6fdd6ae0000000000000000000000000000000000000000000000000000000005f5260045ffd5b600260015414611b02576002600155565b7f3ee5aeb5000000000000000000000000000000000000000000000000000000005f5260045ffd5b73ffffffffffffffffffffffffffffffffffffffff600554168015611cca57604051907f70a08231000000000000000000000000000000000000000000000000000000008252306004830152602082602481845afa9182156104b6575f92611c96575b508115611c925760205f916044604051809481937fa9059cbb00000000000000000000000000000000000000000000000000000000835261dead60048401528760248401525af19081156104b6575f91611c73575b5015611c155760207f18602925c4a7040bd1d3f8eb867d5d4ecbcdce76a6e132a2a9bcade539b2146c91604051908152a1565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f4275726e207472616e73666572206661696c65640000000000000000000000006044820152fd5b611c8c915060203d6020116104af576104a281836117a5565b5f611be2565b5050565b9091506020813d602011611cc2575b81611cb2602093836117a5565b810103126101ab5751905f611b8d565b3d9150611ca5565b50565b15611cd457565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f46616c6c6261636b207472616e73666572206661696c656400000000000000006044820152fd5b73ffffffffffffffffffffffffffffffffffffffff600454168015611cca576040517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152602081602481855afa9081156104b6575f9161200b575b508015611c92578060011c8082039182116118c25760035473ffffffffffffffffffffffffffffffffffffffff16828115611fd157506040517fa9059cbb00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff919091166004820152602481018290526020816044815f885af19081156104b6575f91611fb2575b5015611f54577f87a97bb7195135cfd4eb53a7ae5b65a883ed2ca3207893d97815d33afd138451602073ffffffffffffffffffffffffffffffffffffffff6003541692604051908152a25b60065473ffffffffffffffffffffffffffffffffffffffff1615611ea257611ea091506120c3565b565b73ffffffffffffffffffffffffffffffffffffffff600354169081611ec657505050565b6040517fa9059cbb00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff929092166004830152602482015290602090829060449082905f905af180156104b657611ea0915f91611f35575b50611ccd565b611f4e915060203d6020116104af576104a281836117a5565b5f611f2f565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f417274697374207472616e73666572206661696c6564000000000000000000006044820152fd5b611fcb915060203d6020116104af576104a281836117a5565b5f611e2d565b925050810180911115611e78577f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b90506020813d602011612035575b81612026602093836117a5565b810103126101ab57515f611d94565b3d9150612019565b67ffffffffffffffff81116117785760051b60200190565b80518210156120695760209160051b010190565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81146118c25760010190565b73ffffffffffffffffffffffffffffffffffffffff6006541673ffffffffffffffffffffffffffffffffffffffff600454166040517fa2309ff8000000000000000000000000000000000000000000000000000000008152602081600481865afa9081156104b6575f91612584575b508015908161255b576121448161203d565b9261215260405194856117a5565b8184527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe061217f8361203d565b0136602086013761218f8261203d565b9161219d60405193846117a5565b8083527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe06121ca8261203d565b013660208501375f955f5b8281106123f85750505f5b868110612226575050505050507f7872ed8e4ddb264941bcb17d63551451e0454ac885f3ec52ec374a6c0c12dc2e916060916040519182526020820152426040820152a1565b61223a6122338286612055565b51896118af565b856123cb578290049081612253575b60019150016121e0565b6122d160208373ffffffffffffffffffffffffffffffffffffffff612278858c612055565b511660405193849283927fa9059cbb000000000000000000000000000000000000000000000000000000008452600484016020909392919373ffffffffffffffffffffffffffffffffffffffff60408201951681520152565b03815f895af19081156104b6575f916123ad575b501561234f576001917fa585a9b4dadb6c3f9c2c42b828af0c5a3f4cb8197ff6ea04b86a3cbfd6e0fe77604073ffffffffffffffffffffffffffffffffffffffff612330858c612055565b51169261233d858a612055565b519082519182526020820152a2612249565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f486f6c646572207472616e73666572206661696c6564000000000000000000006044820152fd5b6123c5915060203d81116104af576104a281836117a5565b5f6122e5565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b6040517f6352211e000000000000000000000000000000000000000000000000000000008152816004820152602081602481865afa9081156104b6575f9161250d575b505f9081805b8b81106124bd575b50156124795750908161247161246a6124646001958a612055565b51612096565b9188612055565b525b016121d5565b6124b79150986001929973ffffffffffffffffffffffffffffffffffffffff6124a2838c612055565b91169052826124b18289612055565b52612096565b97612473565b73ffffffffffffffffffffffffffffffffffffffff6124dc828d612055565b511673ffffffffffffffffffffffffffffffffffffffff84161461250257600101612441565b92505060015f612449565b90506020813d8211612553575b81612527602093836117a5565b810103126101ab575173ffffffffffffffffffffffffffffffffffffffff811681036101ab575f61243b565b3d915061251a565b505091905073ffffffffffffffffffffffffffffffffffffffff600354169081611ec657505050565b90506020813d6020116125ae575b8161259f602093836117a5565b810103126101ab57515f612132565b3d915061259256fea264697066735822122098516431a6b188fca48956959f60333e99c1b4d3de6f599a4fb04355c56c7e8f64736f6c634300081a0033000000000000000000000000498581ff718922c3f8e6a244956af099b2652b2b000000000000000000000000026c6f753beb4ff3f6748fea5657a1fb0ddedb74000000000000000000000000026c6f753beb4ff3f6748fea5657a1fb0ddedb74
Deployed Bytecode
0x6080806040526004361015610012575f80fd5b5f3560e01c90816302d454571461145c5750806321d0ee70146113a957806324a9d85314611421578063259982e5146113a95780632832c59e146113585780632b4fd7791461124f57806346904840146111fe578063575e24b4146110e95780636588103b146110985780636c2bbe7e14610cc55780636fe7e6eb14610fbb578063715018a614610f2157806372c27b6214610eaf5780638c12c88714610d8f5780638da5cb5b14610d3f5780639f063efc14610cc5578063a22e4faa14610ba5578063aaf5bfc314610a85578063b47b2fb114610959578063b6a8b0fa1461051f578063bb57ad201461090d578063c4e833ce14610789578063d7eb3f3a14610738578063dc4c90d3146106ca578063dc98354e146105fa578063e1a45218146105c0578063e1b4af691461051f578063e63ea40814610362578063e74b981b1461029b578063f2fde38b146101af5763fccc281314610171575f80fd5b346101ab575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101ab57602060405161dead8152f35b5f80fd5b346101ab5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101ab5773ffffffffffffffffffffffffffffffffffffffff6101fb6114aa565b610203611863565b16801561026f5773ffffffffffffffffffffffffffffffffffffffff5f54827fffffffffffffffffffffffff00000000000000000000000000000000000000008216175f55167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e05f80a3005b7f1e4fbdf7000000000000000000000000000000000000000000000000000000005f525f60045260245ffd5b346101ab5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101ab5773ffffffffffffffffffffffffffffffffffffffff6102e76114aa565b6102ef611863565b166102fb8115156117e6565b73ffffffffffffffffffffffffffffffffffffffff600254827fffffffffffffffffffffffff0000000000000000000000000000000000000000821617600255167faaebcf1bfa00580e41d966056b48521fa9f202645c86d4ddf28113e617c1b1d35f80a3005b346101ab5760607ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101ab576103996114aa565b60243573ffffffffffffffffffffffffffffffffffffffff8116908181036101ab5773ffffffffffffffffffffffffffffffffffffffff604435936103dc611863565b6103e4611af1565b6103ef8415156117e6565b169283156104c1576040517fa9059cbb00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff929092166004830152602482018190526020826044815f885af19081156104b6577f9495d03190a79a43e534c9e328ff322f6283261383f5f19c809564f6ad5a57b39260209261048b575b50604051908152a360018055005b6104aa90833d85116104af575b6104a281836117a5565b81019061184b565b61047d565b503d610498565b6040513d5f823e3d90fd5b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600d60248201527f496e76616c696420746f6b656e000000000000000000000000000000000000006044820152fd5b346101ab5761052d366116ba565b50505050505073ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000498581ff718922c3f8e6a244956af099b2652b2b163303610598577f0a85dc29000000000000000000000000000000000000000000000000000000005f5260045ffd5b7fae18210a000000000000000000000000000000000000000000000000000000005f5260045ffd5b346101ab575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101ab5760206040516127108152f35b346101ab5760e07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101ab576106316114aa565b5060a07fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc3601126101ab57610664611697565b5073ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000498581ff718922c3f8e6a244956af099b2652b2b163303610598577f0a85dc29000000000000000000000000000000000000000000000000000000005f5260045ffd5b346101ab575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101ab57602060405173ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000498581ff718922c3f8e6a244956af099b2652b2b168152f35b346101ab575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101ab57602073ffffffffffffffffffffffffffffffffffffffff60035416604051908152f35b346101ab575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101ab575f6101a06040516107c78161175b565b8281528260208201528260408201528260608201528260808201528260a08201528260c08201528260e0820152826101008201528261012082015282610140820152826101608201528261018082015201526101c0602060405161082a8161175b565b5f8152818101905f8252604081015f8152606082015f8152608083015f815260a084015f815260c085015f815260e0860190600182526101008701925f84526101208801945f86526101408901965f88526101608a019860018a526101a06101808c019b5f8d52019b5f8d526040519d8e915f835251151591015251151560408d015251151560608c015251151560808b015251151560a08a015251151560c089015251151560e08801525115156101008701525115156101208601525115156101408501525115156101608401525115156101808301525115156101a0820152f35b346101ab575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101ab57610943611af1565b61094b611b2a565b610953611d32565b60018055005b346101ab576101607ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101ab576109916114aa565b5060a07fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc3601126101ab5760607fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff3c3601126101ab576101443567ffffffffffffffff81116101ab57610a079036906004016114cd565b505073ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000498581ff718922c3f8e6a244956af099b2652b2b163303610598576040610a54610124356118ef565b7fffffffff00000000000000000000000000000000000000000000000000000000835192168252600f0b6020820152f35b346101ab5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101ab5773ffffffffffffffffffffffffffffffffffffffff610ad16114aa565b610ad9611863565b168015610b475773ffffffffffffffffffffffffffffffffffffffff600454827fffffffffffffffffffffffff0000000000000000000000000000000000000000821617600455167fd6f103212e42c9ad7ce0b1d967e2f8b8cf8385a9220c0dc52c5c2fe9f6925f8f5f80a3005b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f496e76616c6964205553444320616464726573730000000000000000000000006044820152fd5b346101ab5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101ab5773ffffffffffffffffffffffffffffffffffffffff610bf16114aa565b610bf9611863565b168015610c675773ffffffffffffffffffffffffffffffffffffffff600354827fffffffffffffffffffffffff0000000000000000000000000000000000000000821617600355167f88bb0d30cd096c9e787230eb4b23281536acf0d6806dde8a6cc454808abbe8a45f80a3005b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f496e76616c6964206172746973742061646472657373000000000000000000006044820152fd5b346101ab57610cd3366115c6565b5050505050505073ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000498581ff718922c3f8e6a244956af099b2652b2b163303610598577f0a85dc29000000000000000000000000000000000000000000000000000000005f5260045ffd5b346101ab575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101ab57602073ffffffffffffffffffffffffffffffffffffffff5f5416604051908152f35b346101ab5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101ab5773ffffffffffffffffffffffffffffffffffffffff610ddb6114aa565b610de3611863565b168015610e515773ffffffffffffffffffffffffffffffffffffffff600554827fffffffffffffffffffffffff0000000000000000000000000000000000000000821617600555167f53ca7c33bd496d83d897e526656d27ec062bb160170ebb50f6420cffb27c1ae15f80a3005b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f496e76616c6964204552433230206164647265737300000000000000000000006044820152fd5b346101ab5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101ab577f5ec5620e288c4be955ccb6cfb3d55431a8fed5c4c96ffacc4b9506360695f64e6040600435610f0c611863565b600754908060075582519182526020820152a1005b346101ab575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101ab57610f57611863565b5f73ffffffffffffffffffffffffffffffffffffffff81547fffffffffffffffffffffffff000000000000000000000000000000000000000081168355167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a3005b346101ab576101007ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101ab57610ff36114aa565b5060a07fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc3601126101ab57611026611697565b5060e4358060020b036101ab5773ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000498581ff718922c3f8e6a244956af099b2652b2b163303610598577f0a85dc29000000000000000000000000000000000000000000000000000000005f5260045ffd5b346101ab575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101ab57602073ffffffffffffffffffffffffffffffffffffffff60065416604051908152f35b346101ab576101407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101ab576111216114aa565b5060a07fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc3601126101ab5760607fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff3c3601126101ab576101243567ffffffffffffffff81116101ab576111979036906004016114cd565b505073ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000498581ff718922c3f8e6a244956af099b2652b2b163303610598577f0a85dc29000000000000000000000000000000000000000000000000000000005f5260045ffd5b346101ab575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101ab57602073ffffffffffffffffffffffffffffffffffffffff60025416604051908152f35b346101ab5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101ab5773ffffffffffffffffffffffffffffffffffffffff61129b6114aa565b6112a3611863565b1680156112fa57807fffffffffffffffffffffffff000000000000000000000000000000000000000060065416176006557fca87b4660417fb706ee5ce97aa88ce27f880beada493d35369edd786a38de4b55f80a2005b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f496e76616c6964204e46542061646472657373000000000000000000000000006044820152fd5b346101ab575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101ab57602073ffffffffffffffffffffffffffffffffffffffff60055416604051908152f35b346101ab576113b7366114fb565b505050505073ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000498581ff718922c3f8e6a244956af099b2652b2b163303610598577f0a85dc29000000000000000000000000000000000000000000000000000000005f5260045ffd5b346101ab575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101ab576020600754604051908152f35b346101ab575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101ab5760209073ffffffffffffffffffffffffffffffffffffffff600454168152f35b6004359073ffffffffffffffffffffffffffffffffffffffff821682036101ab57565b9181601f840112156101ab5782359167ffffffffffffffff83116101ab57602083818601950101116101ab57565b906101607ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc8301126101ab5760043573ffffffffffffffffffffffffffffffffffffffff811681036101ab579160a07fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc8201126101ab5760249160807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff3c8301126101ab5760c491610144359067ffffffffffffffff82116101ab576115c2916004016114cd565b9091565b906101a07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc8301126101ab5760043573ffffffffffffffffffffffffffffffffffffffff811681036101ab579160a07fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc8201126101ab5760249160807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff3c8301126101ab5760c49161014435916101643591610184359067ffffffffffffffff82116101ab576115c2916004016114cd565b60c4359073ffffffffffffffffffffffffffffffffffffffff821682036101ab57565b6101207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc8201126101ab5760043573ffffffffffffffffffffffffffffffffffffffff811681036101ab579160a07fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc8301126101ab5760249160c4359160e43591610104359067ffffffffffffffff82116101ab576115c2916004016114cd565b6101c0810190811067ffffffffffffffff82111761177857604052565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b90601f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0910116810190811067ffffffffffffffff82111761177857604052565b156117ed57565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f496e76616c696420726563697069656e740000000000000000000000000000006044820152fd5b908160209103126101ab575180151581036101ab5790565b73ffffffffffffffffffffffffffffffffffffffff5f5416330361188357565b7f118cdaa7000000000000000000000000000000000000000000000000000000005f523360045260245ffd5b818102929181159184041417156118c257565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b905f60e43513611ac95760c4359182151583036101ab578215611aa35760443573ffffffffffffffffffffffffffffffffffffffff811681036101ab57925b15611a9b57600f0b5b5f81600f0b1315611a7357611964612710916fffffffffffffffffffffffffffffffff60075491166118af565b04918215611a735773ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000498581ff718922c3f8e6a244956af099b2652b2b1673ffffffffffffffffffffffffffffffffffffffff6002541691813b156101ab57606473ffffffffffffffffffffffffffffffffffffffff915f809460405196879586947f0b0d9c0900000000000000000000000000000000000000000000000000000000865216600485015260248401528860448401525af180156104b657611a63575b506fffffffffffffffffffffffffffffffff7fb47b2fb1000000000000000000000000000000000000000000000000000000009216600f0b90565b5f611a6d916117a5565b5f611a28565b507fb47b2fb10000000000000000000000000000000000000000000000000000000091505f90565b60801d611937565b60243573ffffffffffffffffffffffffffffffffffffffff811681036101ab579261192e565b7f6fdd6ae0000000000000000000000000000000000000000000000000000000005f5260045ffd5b600260015414611b02576002600155565b7f3ee5aeb5000000000000000000000000000000000000000000000000000000005f5260045ffd5b73ffffffffffffffffffffffffffffffffffffffff600554168015611cca57604051907f70a08231000000000000000000000000000000000000000000000000000000008252306004830152602082602481845afa9182156104b6575f92611c96575b508115611c925760205f916044604051809481937fa9059cbb00000000000000000000000000000000000000000000000000000000835261dead60048401528760248401525af19081156104b6575f91611c73575b5015611c155760207f18602925c4a7040bd1d3f8eb867d5d4ecbcdce76a6e132a2a9bcade539b2146c91604051908152a1565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f4275726e207472616e73666572206661696c65640000000000000000000000006044820152fd5b611c8c915060203d6020116104af576104a281836117a5565b5f611be2565b5050565b9091506020813d602011611cc2575b81611cb2602093836117a5565b810103126101ab5751905f611b8d565b3d9150611ca5565b50565b15611cd457565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f46616c6c6261636b207472616e73666572206661696c656400000000000000006044820152fd5b73ffffffffffffffffffffffffffffffffffffffff600454168015611cca576040517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152602081602481855afa9081156104b6575f9161200b575b508015611c92578060011c8082039182116118c25760035473ffffffffffffffffffffffffffffffffffffffff16828115611fd157506040517fa9059cbb00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff919091166004820152602481018290526020816044815f885af19081156104b6575f91611fb2575b5015611f54577f87a97bb7195135cfd4eb53a7ae5b65a883ed2ca3207893d97815d33afd138451602073ffffffffffffffffffffffffffffffffffffffff6003541692604051908152a25b60065473ffffffffffffffffffffffffffffffffffffffff1615611ea257611ea091506120c3565b565b73ffffffffffffffffffffffffffffffffffffffff600354169081611ec657505050565b6040517fa9059cbb00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff929092166004830152602482015290602090829060449082905f905af180156104b657611ea0915f91611f35575b50611ccd565b611f4e915060203d6020116104af576104a281836117a5565b5f611f2f565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f417274697374207472616e73666572206661696c6564000000000000000000006044820152fd5b611fcb915060203d6020116104af576104a281836117a5565b5f611e2d565b925050810180911115611e78577f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b90506020813d602011612035575b81612026602093836117a5565b810103126101ab57515f611d94565b3d9150612019565b67ffffffffffffffff81116117785760051b60200190565b80518210156120695760209160051b010190565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81146118c25760010190565b73ffffffffffffffffffffffffffffffffffffffff6006541673ffffffffffffffffffffffffffffffffffffffff600454166040517fa2309ff8000000000000000000000000000000000000000000000000000000008152602081600481865afa9081156104b6575f91612584575b508015908161255b576121448161203d565b9261215260405194856117a5565b8184527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe061217f8361203d565b0136602086013761218f8261203d565b9161219d60405193846117a5565b8083527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe06121ca8261203d565b013660208501375f955f5b8281106123f85750505f5b868110612226575050505050507f7872ed8e4ddb264941bcb17d63551451e0454ac885f3ec52ec374a6c0c12dc2e916060916040519182526020820152426040820152a1565b61223a6122338286612055565b51896118af565b856123cb578290049081612253575b60019150016121e0565b6122d160208373ffffffffffffffffffffffffffffffffffffffff612278858c612055565b511660405193849283927fa9059cbb000000000000000000000000000000000000000000000000000000008452600484016020909392919373ffffffffffffffffffffffffffffffffffffffff60408201951681520152565b03815f895af19081156104b6575f916123ad575b501561234f576001917fa585a9b4dadb6c3f9c2c42b828af0c5a3f4cb8197ff6ea04b86a3cbfd6e0fe77604073ffffffffffffffffffffffffffffffffffffffff612330858c612055565b51169261233d858a612055565b519082519182526020820152a2612249565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f486f6c646572207472616e73666572206661696c6564000000000000000000006044820152fd5b6123c5915060203d81116104af576104a281836117a5565b5f6122e5565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b6040517f6352211e000000000000000000000000000000000000000000000000000000008152816004820152602081602481865afa9081156104b6575f9161250d575b505f9081805b8b81106124bd575b50156124795750908161247161246a6124646001958a612055565b51612096565b9188612055565b525b016121d5565b6124b79150986001929973ffffffffffffffffffffffffffffffffffffffff6124a2838c612055565b91169052826124b18289612055565b52612096565b97612473565b73ffffffffffffffffffffffffffffffffffffffff6124dc828d612055565b511673ffffffffffffffffffffffffffffffffffffffff84161461250257600101612441565b92505060015f612449565b90506020813d8211612553575b81612527602093836117a5565b810103126101ab575173ffffffffffffffffffffffffffffffffffffffff811681036101ab575f61243b565b3d915061251a565b505091905073ffffffffffffffffffffffffffffffffffffffff600354169081611ec657505050565b90506020813d6020116125ae575b8161259f602093836117a5565b810103126101ab57515f612132565b3d915061259256fea264697066735822122098516431a6b188fca48956959f60333e99c1b4d3de6f599a4fb04355c56c7e8f64736f6c634300081a0033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000498581ff718922c3f8e6a244956af099b2652b2b000000000000000000000000026c6f753beb4ff3f6748fea5657a1fb0ddedb74000000000000000000000000026c6f753beb4ff3f6748fea5657a1fb0ddedb74
-----Decoded View---------------
Arg [0] : _poolManager (address): 0x498581fF718922c3f8e6A244956aF099B2652b2b
Arg [1] : _feeRecipient (address): 0x026C6f753BEB4FF3f6748fEa5657A1Fb0DdEDB74
Arg [2] : _owner (address): 0x026C6f753BEB4FF3f6748fEa5657A1Fb0DdEDB74
-----Encoded View---------------
3 Constructor Arguments found :
Arg [0] : 000000000000000000000000498581ff718922c3f8e6a244956af099b2652b2b
Arg [1] : 000000000000000000000000026c6f753beb4ff3f6748fea5657a1fb0ddedb74
Arg [2] : 000000000000000000000000026c6f753beb4ff3f6748fea5657a1fb0ddedb74
Loading...
Loading
Loading...
Loading
Loading...
Loading
Net Worth in USD
$324.15
Net Worth in ETH
0.155772
Token Allocations
USDC
100.00%
Multichain Portfolio | 34 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|---|---|---|---|---|
| BASE | 100.00% | $0.999917 | 324.1813 | $324.15 |
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.