ClankerPresaleEthToCreator

Description:

Multi-signature wallet contract requiring multiple confirmations for transaction execution.

Blockchain: Ethereum

Source Code: View Code On The Blockchain

Solidity Source Code:

{{
  "language": "Solidity",
  "sources": {
    "src/extensions/ClankerPresaleEthToCreator.sol": {
      "content": "// SPDX-License-Identifier: MIT
pragma solidity ^0.8.28;

import {IClanker} from "../interfaces/IClanker.sol";
import {IClankerExtension} from "../interfaces/IClankerExtension.sol";
import {IClankerPresaleAllowlist} from "./interfaces/IClankerPresaleAllowlist.sol";
import {IClankerPresaleEthToCreator} from "./interfaces/IClankerPresaleEthToCreator.sol";

import {IOwnerAdmins} from "../interfaces/IOwnerAdmins.sol";
import {OwnerAdmins} from "../utils/OwnerAdmins.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {ReentrancyGuard} from "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import {PoolKey} from "@uniswap/v4-core/src/types/PoolKey.sol";

contract ClankerPresaleEthToCreator is ReentrancyGuard, IClankerPresaleEthToCreator, OwnerAdmins {
    IClanker public immutable factory;

    // deployment time buffers
    uint256 public constant SALT_SET_BUFFER = 1 days; // buffer for presale admin to set salt for deployment
    uint256 public constant DEPLOYMENT_BAD_BUFFER = 3 days; // buffer for deployment to be considered bad

    // max presale duration
    uint256 public constant MAX_PRESALE_DURATION = 6 weeks;

    // min lockup duration
    uint256 public minLockupDuration;

    // clanker fee info
    uint256 public clankerDefaultFeeBps;
    uint256 public constant BPS = 10_000;
    address public clankerFeeRecipient;

    // next presale id
    uint256 private _presaleId;

    // per presale info
    mapping(uint256 presaleId => Presale presale) public presaleState;
    mapping(uint256 presaleId => mapping(address user => uint256 amount)) public presaleBuys;
    mapping(uint256 presaleId => mapping(address user => uint256 amount)) public presaleClaimed;

    // enabled allowlists
    mapping(address allowlist => bool enabled) public enabledAllowlists;

    modifier onlyFactory() {
        if (msg.sender != address(factory)) revert Unauthorized();
        _;
    }

    modifier presaleExists(uint256 presaleId_) {
        if (presaleState[presaleId_].maxEthGoal == 0) revert InvalidPresale();
        _;
    }

    modifier updatePresaleState(uint256 presaleId_) {
        Presale storage presale = presaleState[presaleId_];

        // update to minimum or failed if time expired if in active state
        if (presale.status == PresaleStatus.Active && presale.endTime <= block.timestamp) {
            if (presale.ethRaised >= presale.minEthGoal) {
                presale.status = PresaleStatus.SuccessfulMinimumHit;
            } else {
                presale.status = PresaleStatus.Failed;
            }
        }
        _;
    }

    constructor(address owner_, address factory_, address clankerFeeRecipient_)
        OwnerAdmins(owner_)
    {
        factory = IClanker(factory_);
        _presaleId = 1;
        clankerFeeRecipient = clankerFeeRecipient_;
        minLockupDuration = 7 days;
        clankerDefaultFeeBps = 500; // 5%
    }

    function setAllowlist(address allowlist, bool enabled) external onlyOwner {
        enabledAllowlists[allowlist] = enabled;
        emit SetAllowlist(allowlist, enabled);
    }

    function setMinLockupDuration(uint256 minLockupDuration_) external onlyOwner {
        uint256 oldMinLockupDuration = minLockupDuration;
        minLockupDuration = minLockupDuration_;
        emit MinLockupDurationUpdated(oldMinLockupDuration, minLockupDuration_);
    }

    function setClankerDefaultFee(uint256 clankerDefaultFeeBps_) external onlyOwner {
        if (clankerDefaultFeeBps_ >= BPS) revert InvalidClankerFee();

        uint256 oldFee = clankerDefaultFeeBps;
        clankerDefaultFeeBps = clankerDefaultFeeBps_;

        emit ClankerDefaultFeeUpdated(oldFee, clankerDefaultFeeBps_);
    }

    function setClankerFeeForPresale(uint256 presaleId, uint256 newFee)
        external
        presaleExists(presaleId)
        onlyOwner
    {
        // can only set lower
        if (newFee >= presaleState[presaleId].clankerFee) revert InvalidClankerFee();

        uint256 oldFee = presaleState[presaleId].clankerFee;
        presaleState[presaleId].clankerFee = newFee;
        emit ClankerFeeUpdatedForPresale(presaleId, oldFee, newFee);
    }

    function getPresale(uint256 presaleId_) public view returns (Presale memory) {
        return presaleState[presaleId_];
    }

    function setClankerFeeRecipient(address recipient) external onlyOwner {
        address oldRecipient = clankerFeeRecipient;
        clankerFeeRecipient = recipient;
        emit ClankerFeeRecipientUpdated(oldRecipient, recipient);
    }

    function startPresale(
        IClanker.DeploymentConfig memory deploymentConfig,
        uint256 minEthGoal,
        uint256 maxEthGoal,
        uint256 presaleDuration,
        address presaleOwner,
        uint256 lockupDuration,
        uint256 vestingDuration,
        address allowlist,
        bytes calldata allowlistInitializationData
    ) external onlyAdmin returns (uint256 presaleId) {
        presaleId = _presaleId++;

        // ensure presale presaleOwner is set
        if (presaleOwner == address(0)) {
            revert InvalidPresaleOwner();
        }

        // ensure presale is present the last extension in the token's deployment config
        if (
            deploymentConfig.extensionConfigs.length == 0
                || deploymentConfig.extensionConfigs[deploymentConfig.extensionConfigs.length - 1]
                    .extension != address(this)
        ) {
            revert PresaleNotLastExtension();
        }

        // ensure presale supply is not zero
        if (
            deploymentConfig.extensionConfigs[deploymentConfig.extensionConfigs.length - 1]
                .extensionBps == 0
        ) {
            revert InvalidPresaleSupply();
        }

        // ensure msg value is zero
        if (
            deploymentConfig.extensionConfigs[deploymentConfig.extensionConfigs.length - 1].msgValue
                != 0
        ) {
            revert InvalidMsgValue();
        }

        // ensure min and max eth goals are present and valid
        if (maxEthGoal == 0 || minEthGoal > maxEthGoal) {
            revert InvalidEthGoal();
        }

        // ensure time limit is present and valid
        if (presaleDuration == 0 || presaleDuration > MAX_PRESALE_DURATION) {
            revert InvalidPresaleDuration();
        }

        // ensure lockup duration is valid
        if (lockupDuration < minLockupDuration) {
            revert LockupDurationTooShort();
        }

        // check that allowlist checker is enabled
        if (allowlist != address(0) && !enabledAllowlists[allowlist]) {
            revert AllowlistNotEnabled();
        }

        // initialize allowlist checker
        if (allowlist != address(0)) {
            IClankerPresaleAllowlist(allowlist).initialize(
                presaleId, presaleOwner, allowlistInitializationData
            );
        }

        // set token deployment config's presale ID
        deploymentConfig.extensionConfigs[deploymentConfig.extensionConfigs.length - 1]
            .extensionData = abi.encode(presaleId);

        // note: it is recommended to simulate a call to deployToken() with the deploymentConfig
        // to ensure that the token will fail with 'NotExpectingTokenDeployment()',
        // reaching this error messages means that the deploymentConfig is valid up to the
        // point of this presale executing.
        // encode the presale id of zero into the extension data for the simulation

        presaleState[presaleId] = Presale({
            presaleOwner: presaleOwner,
            allowlist: allowlist,
            deploymentConfig: deploymentConfig,
            status: PresaleStatus.Active,
            minEthGoal: minEthGoal,
            maxEthGoal: maxEthGoal,
            endTime: block.timestamp + presaleDuration,
            ethRaised: 0,
            deploymentExpected: false,
            deployedToken: address(0),
            tokenSupply: 0,
            ethClaimed: false,
            lockupDuration: lockupDuration,
            vestingDuration: vestingDuration,
            lockupEndTime: 0,
            vestingEndTime: 0,
            clankerFee: clankerDefaultFeeBps
        });

        emit PresaleStarted({
            presaleId: presaleId,
            allowlist: allowlist,
            deploymentConfig: deploymentConfig,
            minEthGoal: minEthGoal,
            maxEthGoal: maxEthGoal,
            presaleDuration: presaleDuration,
            presaleOwner: presaleOwner,
            lockupDuration: lockupDuration,
            vestingDuration: vestingDuration,
            clankerFeeBps: clankerDefaultFeeBps
        });
    }

    function endPresale(uint256 presaleId, bytes32 salt)
        external
        presaleExists(presaleId)
        updatePresaleState(presaleId)
        returns (address token)
    {
        Presale storage presale = presaleState[presaleId];

        // presale can be ended in three states:
        // 1. maximum eth is hit at any point
        // 2. min eth is hit and deadline has expired
        // 3. min eth is hit and the presale owner wants to end the presale early (must be in active state)
        bool presaleCanEnd = presale.status == PresaleStatus.SuccessfulMaximumHit
            || presale.status == PresaleStatus.SuccessfulMinimumHit
            || (
                presale.status == PresaleStatus.Active && msg.sender == presale.presaleOwner
                    && presale.minEthGoal <= presale.ethRaised
            );
        if (!presaleCanEnd) revert PresaleNotReadyForDeployment();

        // if presale's end time has passed without a successful deployment, set the presale to failed
        //
        // presales with an invalid token deployment config can fail to deploy. we don't want
        // to fail the presale if a single bad deploy happens, as someone could force a bad deploy
        // by calling endPresale() with a salt that resolves to an already deployed token
        if (presale.endTime + DEPLOYMENT_BAD_BUFFER < block.timestamp) {
            // allow users to withdraw their eth
            presale.status = PresaleStatus.Failed;
            emit PresaleFailed(presaleId);
            return address(0);
        }

        // give presale owner opportunity to set the salt
        if (
            msg.sender != presale.presaleOwner
                && block.timestamp < presale.endTime + SALT_SET_BUFFER
        ) {
            revert PresaleSaltBufferNotExpired();
        }

        // update token deployment config with salt
        presale.deploymentConfig.tokenConfig.salt = salt;

        // record lockup and vesting end times
        presale.lockupEndTime = block.timestamp + presale.lockupDuration;
        presale.vestingEndTime = presale.lockupEndTime + presale.vestingDuration;

        // set deployment ongoing to true
        presale.deploymentExpected = true;

        // deploy token
        token = factory.deployToken(presale.deploymentConfig);

        emit PresaleDeployed(presaleId, token);
    }

    // buy into presale without passing info to the allowlist checker
    function buyIntoPresale(uint256 presaleId) external payable {
        _buyIntoPresale(presaleId, bytes(""));
    }

    // buy into the presale with an allowlist checker
    function buyIntoPresaleWithProof(uint256 presaleId, bytes calldata proof) external payable {
        _buyIntoPresale(presaleId, proof);
    }

    function _buyIntoPresale(uint256 presaleId, bytes memory proof)
        internal
        presaleExists(presaleId)
        nonReentrant
    {
        Presale storage presale = presaleState[presaleId];

        // ensure presale is active and time limit has not been reached
        if (presale.status != PresaleStatus.Active || presale.endTime <= block.timestamp) {
            revert PresaleNotActive();
        }

        // determine amount of eth to use for presale
        uint256 ethToUse = msg.value + presale.ethRaised > presale.maxEthGoal
            ? presale.maxEthGoal - presale.ethRaised
            : msg.value;

        // record a user's eth contribution
        presaleBuys[presaleId][msg.sender] += ethToUse;

        // check if a user is allowlisted
        if (presale.allowlist != address(0)) {
            uint256 allowedAmount = IClankerPresaleAllowlist(presale.allowlist)
                .getAllowedAmountForBuyer(presaleId, msg.sender, proof);
            if (presaleBuys[presaleId][msg.sender] > allowedAmount) {
                revert AllowlistAmountExceeded(allowedAmount);
            }
        }

        // update eth raised
        presale.ethRaised += ethToUse;

        // update presale state if max eth goal is met, do not update if min goal is met
        if (presale.ethRaised == presale.maxEthGoal) {
            presale.status = PresaleStatus.SuccessfulMaximumHit;
        }

        // refund excess eth
        if (msg.value > ethToUse) {
            // send eth to recipient
            (bool sent,) = payable(msg.sender).call{value: msg.value - ethToUse}("");
            if (!sent) revert EthTransferFailed();
        }

        emit PresaleBuy(presaleId, msg.sender, ethToUse, presale.ethRaised);
    }

    function withdrawFromPresale(uint256 presaleId, uint256 amount, address recipient)
        external
        presaleExists(presaleId)
        updatePresaleState(presaleId)
        nonReentrant
    {
        Presale storage presale = presaleState[presaleId];

        // ensure presale is ongoing or failed
        if (presale.status != PresaleStatus.Failed && presale.status != PresaleStatus.Active) {
            revert PresaleSuccessful();
        }

        // ensure user has a balance in the presale
        if (presaleBuys[presaleId][msg.sender] < amount) revert InsufficientBalance();

        // update user's balance
        presaleBuys[presaleId][msg.sender] -= amount;

        // update eth raised
        presale.ethRaised -= amount;

        // send eth to recipient
        (bool sent,) = payable(recipient).call{value: amount}("");
        if (!sent) revert EthTransferFailed();

        emit WithdrawFromPresale(presaleId, msg.sender, amount, presale.ethRaised);
    }

    function claimTokens(uint256 presaleId) external presaleExists(presaleId) {
        Presale storage presale = presaleState[presaleId];

        // ensure presale is claimable
        if (presale.status != PresaleStatus.Claimable) revert PresaleNotClaimable();

        // ensure lockup period has passed
        if (block.timestamp < presale.lockupEndTime) revert PresaleLockupNotPassed();

        // determine amount of tokens to send to user
        uint256 ethBuyInAmount = _getAmountClaimable(
            presaleId,
            msg.sender,
            presale.lockupEndTime,
            presale.vestingEndTime,
            presale.vestingDuration
        );

        // update user's claimed amount
        presaleClaimed[presaleId][msg.sender] += ethBuyInAmount;

        // determine token amount to send to user
        uint256 tokenAmount = presale.tokenSupply * ethBuyInAmount / presale.ethRaised;
        if (tokenAmount == 0) revert NoTokensToClaim();

        // send tokens to user
        IERC20(presale.deployedToken).transfer(msg.sender, tokenAmount);

        emit ClaimTokens(presaleId, msg.sender, tokenAmount);
    }

    // helper function to determine amount of tokens available to claim
    function amountAvailableToClaim(uint256 presaleId, address user)
        external
        view
        presaleExists(presaleId)
        returns (uint256)
    {
        Presale memory presale = presaleState[presaleId];

        if (presale.status != PresaleStatus.Claimable) return 0;
        if (block.timestamp < presale.lockupEndTime) return 0;

        uint256 ethBuyInAmount = _getAmountClaimable(
            presaleId, user, presale.lockupEndTime, presale.vestingEndTime, presale.vestingDuration
        );
        return presale.tokenSupply * ethBuyInAmount / presale.ethRaised;
    }

    function _getAmountClaimable(
        uint256 presaleId,
        address user,
        uint256 lockupEndTime,
        uint256 vestingEndTime,
        uint256 vestingDuration
    ) internal view returns (uint256) {
        // determine amount of tokens to send to user
        uint256 ethBuyInAmount;
        if (block.timestamp >= vestingEndTime) {
            // if vesting period has passed, send rest of tokens
            ethBuyInAmount = presaleBuys[presaleId][user] - presaleClaimed[presaleId][user];
        } else {
            // if vesting period has not passed, send vested portion of tokens minus what
            // has already been claimed
            ethBuyInAmount =
                presaleBuys[presaleId][user] * (block.timestamp - lockupEndTime) / vestingDuration;
            ethBuyInAmount = ethBuyInAmount - presaleClaimed[presaleId][user];
        }

        return ethBuyInAmount;
    }

    function claimEth(uint256 presaleId, address recipient) external presaleExists(presaleId) {
        Presale storage presale = presaleState[presaleId];

        // if not presale owner or owner, revert
        if (msg.sender != presale.presaleOwner && msg.sender != owner()) revert Unauthorized();

        // if owner, must be sending eth fee to the presale owner
        if (msg.sender == owner() && recipient != presale.presaleOwner) {
            revert RecipientMustBePresaleOwner();
        }

        // if eth has already been claimed, revert
        if (presale.ethClaimed) revert PresaleAlreadyClaimed();
        presale.ethClaimed = true;

        // ensure presale is claimable
        if (presale.status != PresaleStatus.Claimable) revert PresaleNotClaimable();

        // determine fee
        uint256 fee = (presale.ethRaised * presale.clankerFee) / BPS;
        uint256 amountAfterFee = presale.ethRaised - fee;

        // send eth to user's recipient
        (bool sent,) = payable(recipient).call{value: amountAfterFee}("");
        if (!sent) revert EthTransferFailed();

        // send eth to clanker
        if (fee > 0) {
            (bool sent,) = payable(clankerFeeRecipient).call{value: fee}("");
            if (!sent) revert EthTransferFailed();
        }

        emit ClaimEth(presaleId, recipient, amountAfterFee, fee);
    }

    function receiveTokens(
        IClanker.DeploymentConfig calldata deploymentConfig,
        PoolKey memory,
        address token,
        uint256 extensionSupply,
        uint256 extensionIndex
    ) external payable nonReentrant onlyFactory {
        uint256 presaleId =
            abi.decode(deploymentConfig.extensionConfigs[extensionIndex].extensionData, (uint256));
        Presale storage presale = presaleState[presaleId];

        // ensure that the msgValue is zero
        if (deploymentConfig.extensionConfigs[extensionIndex].msgValue != 0 || msg.value != 0) {
            revert IClankerExtension.InvalidMsgValue();
        }

        // ensure token deployment is ongoing
        if (!presale.deploymentExpected) revert NotExpectingTokenDeployment();
        presale.deploymentExpected = false;

        // pull in token supply
        IERC20(token).transferFrom(msg.sender, address(this), extensionSupply);

        // update deployed token
        presale.deployedToken = token;

        // record token supply
        presale.tokenSupply = extensionSupply;

        // update presale state to claimable
        presale.status = PresaleStatus.Claimable;
    }

    function supportsInterface(bytes4 interfaceId) external pure returns (bool) {
        return interfaceId == type(IClankerExtension).interfaceId;
    }
}
"
    },
    "src/interfaces/IClanker.sol": {
      "content": "// SPDX-License-Identifier: MIT
pragma solidity ^0.8.28;

import {IOwnerAdmins} from "./IOwnerAdmins.sol";
import {PoolId} from "@uniswap/v4-core/src/types/PoolId.sol";

interface IClanker is IOwnerAdmins {
    struct TokenConfig {
        address tokenAdmin;
        string name;
        string symbol;
        bytes32 salt;
        string image;
        string metadata;
        string context;
        uint256 originatingChainId;
    }

    struct PoolConfig {
        address hook;
        address pairedToken;
        int24 tickIfToken0IsClanker;
        int24 tickSpacing;
        bytes poolData;
    }

    struct LockerConfig {
        address locker;
        // reward info
        address[] rewardAdmins;
        address[] rewardRecipients;
        uint16[] rewardBps;
        // liquidity placement info
        int24[] tickLower;
        int24[] tickUpper;
        uint16[] positionBps;
        bytes lockerData;
    }

    struct ExtensionConfig {
        address extension;
        uint256 msgValue;
        uint16 extensionBps;
        bytes extensionData;
    }

    struct DeploymentConfig {
        TokenConfig tokenConfig;
        PoolConfig poolConfig;
        LockerConfig lockerConfig;
        MevModuleConfig mevModuleConfig;
        ExtensionConfig[] extensionConfigs;
    }

    struct MevModuleConfig {
        address mevModule;
        bytes mevModuleData;
    }

    struct DeploymentInfo {
        address token;
        address hook;
        address locker;
        address[] extensions;
    }

    /// @notice When the factory is deprecated
    error Deprecated();
    /// @notice When the token is not found to collect rewards for
    error NotFound();

    /// @notice When the function is only valid on the originating chain
    error OnlyOriginatingChain();
    /// @notice When the function is only valid on a non-originating chain
    error OnlyNonOriginatingChains();

    /// @notice When the hook is invalid
    error InvalidHook();
    /// @notice When the locker is invalid
    error InvalidLocker();
    /// @notice When the extension contract is invalid
    error InvalidExtension();

    /// @notice When the hook is not enabled
    error HookNotEnabled();
    /// @notice When the locker is not enabled
    error LockerNotEnabled();
    /// @notice When the extension contract is not enabled
    error ExtensionNotEnabled();
    /// @notice When the mev module is not enabled
    error MevModuleNotEnabled();

    /// @notice When the token is not paired to the pool
    error ExtensionMsgValueMismatch();
    /// @notice When the maximum number of extensions is exceeded
    error MaxExtensionsExceeded();
    /// @notice When the extension supply percentage is exceeded
    error MaxExtensionBpsExceeded();

    /// @notice When the mev module is invalid
    error InvalidMevModule();
    /// @notice When the team fee recipient is not set
    error TeamFeeRecipientNotSet();

    event TokenCreated(
        address msgSender,
        address indexed tokenAddress,
        address indexed tokenAdmin,
        string tokenImage,
        string tokenName,
        string tokenSymbol,
        string tokenMetadata,
        string tokenContext,
        int24 startingTick,
        address poolHook,
        PoolId poolId,
        address pairedToken,
        address locker,
        address mevModule,
        uint256 extensionsSupply,
        address[] extensions
    );
    event ExtensionTriggered(address extension, uint256 extensionSupply, uint256 msgValue);

    event SetDeprecated(bool deprecated);
    event SetExtension(address extension, bool enabled);
    event SetHook(address hook, bool enabled);
    event SetMevModule(address mevModule, bool enabled);
    event SetLocker(address locker, address hook, bool enabled);

    event SetTeamFeeRecipient(address oldTeamFeeRecipient, address newTeamFeeRecipient);
    event ClaimTeamFees(address indexed token, address indexed recipient, uint256 amount);

    function deprecated() external view returns (bool);

    function deployToken(DeploymentConfig memory deploymentConfig)
        external
        payable
        returns (address tokenAddress);

    function tokenDeploymentInfo(address token) external view returns (DeploymentInfo memory);
}
"
    },
    "src/interfaces/IClankerExtension.sol": {
      "content": "// SPDX-License-Identifier: MIT
pragma solidity ^0.8.28;

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

import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
import {PoolKey} from "@uniswap/v4-core/src/types/PoolKey.sol";

interface IClankerExtension is IERC165 {
    // error when the msgValue is not zero when it is expected to be zero
    error InvalidMsgValue();

    // take extension's token supply from the factory and perform allocation logic
    function receiveTokens(
        IClanker.DeploymentConfig calldata deploymentConfig,
        PoolKey memory poolKey,
        address token,
        uint256 extensionSupply,
        uint256 extensionIndex
    ) external payable;
}
"
    },
    "src/extensions/interfaces/IClankerPresaleAllowlist.sol": {
      "content": "// SPDX-License-Identifier: MIT
pragma solidity ^0.8.28;

interface IClankerPresaleAllowlist {
    error Unauthorized();

    // called once per presale to pass in allowlist specific data
    function initialize(uint256 presaleId, address presaleOwner, bytes calldata initializationData)
        external;

    // get the allowed amount for a buyer
    function getAllowedAmountForBuyer(uint256 presaleId, address buyer, bytes calldata proof)
        external
        view
        returns (uint256);
}
"
    },
    "src/extensions/interfaces/IClankerPresaleEthToCreator.sol": {
      "content": "// SPDX-License-Identifier: MIT
pragma solidity ^0.8.28;

import {IClanker} from "../../interfaces/IClanker.sol";
import {IClankerExtension} from "../../interfaces/IClankerExtension.sol";

interface IClankerPresaleEthToCreator is IClankerExtension {
    event PresaleStarted(
        uint256 presaleId,
        address allowlist,
        IClanker.DeploymentConfig deploymentConfig,
        uint256 minEthGoal,
        uint256 maxEthGoal,
        uint256 presaleDuration,
        address presaleOwner,
        uint256 lockupDuration,
        uint256 vestingDuration,
        uint256 clankerFeeBps
    );

    event PresaleDeployed(uint256 indexed presaleId, address token);
    event PresaleFailed(uint256 indexed presaleId);
    event PresaleBuy(uint256 indexed presaleId, address buyer, uint256 ethToUse, uint256 ethRaised);
    event WithdrawFromPresale(
        uint256 indexed presaleId, address withdrawer, uint256 amount, uint256 ethRaised
    );
    event ClaimTokens(uint256 indexed presaleId, address claimer, uint256 tokenAmount);
    event ClaimEth(uint256 indexed presaleId, address recipient, uint256 ethAmount, uint256 fee);
    event WithdrawWithdrawFee(address recipient, uint256 amount);
    event ClankerFeeRecipientUpdated(address oldRecipient, address recipient);
    event MinLockupDurationUpdated(uint256 oldMinLockupDuration, uint256 minLockupDuration);
    event ClankerDefaultFeeUpdated(uint256 oldClankerDefaultFee, uint256 clankerDefaultFee);
    event ClankerFeeUpdatedForPresale(uint256 presaleId, uint256 oldClankerFee, uint256 clankerFee);
    event SetAllowlist(address allowlist, bool enabled);

    struct Presale {
        PresaleStatus status; // current status of the presale
        IClanker.DeploymentConfig deploymentConfig; // token to be deployed upon successful presale
        address allowlist; // address of the allowlist for the presale
        // presale success configuration fields
        address presaleOwner; // address to claim raised eth on successful presale
        uint256 minEthGoal; // minimum eth goal for successful presale, presale will fail if this goal is not met and the time limit is reached
        uint256 maxEthGoal; // maximum eth goal for successful presale, presale will end early if this goal is reached
        uint256 endTime; // timestamp when presale expires
        // presale fields
        address deployedToken; // address of the token that was deployed
        uint256 ethRaised; // total eth raised during presale
        uint256 tokenSupply; // supply of the token that was deployed to distribute to presale buyers
        // toggle flags
        bool deploymentExpected; // bool to flag to us that we are expecting a token deployment from the factory
        bool ethClaimed; // bool to flag to us that the tokens have been claimed
        // lockup and vesting fields
        uint256 lockupDuration; // duration of the lockup period
        uint256 vestingDuration; // duration of the vesting period
        uint256 lockupEndTime; // timestamp to mark when the lockup period ends
        uint256 vestingEndTime; // timestamp to mark when the vesting period ends
        uint256 clankerFee; // clanker's fee to take in weth on successful presale
    }

    enum PresaleStatus {
        NotCreated,
        Active,
        SuccessfulMinimumHit,
        SuccessfulMaximumHit,
        Failed,
        Claimable
    }

    error PresaleNotLastExtension();
    error InvalidPresaleSupply();
    error InvalidPresaleDuration();
    error InvalidEthGoal();
    error InvalidPresaleOwner();
    error InvalidTimeLimit();
    error InvalidClankerFee();
    error RecipientMustBePresaleOwner();
    error AllowlistNotEnabled();
    error PresaleNotActive();
    error PresaleSuccessful();
    error InsufficientBalance();
    error InvalidPresale();
    error PresaleNotReadyForDeployment();
    error PresaleAlreadyClaimed();
    error PresaleSaltBufferNotExpired();
    error NoTokensToClaim();
    error NotExpectingTokenDeployment();
    error PresaleNotClaimable();
    error PresaleLockupNotPassed();
    error EthTransferFailed();
    error NoWithdrawFeeAccumulated();
    error LockupDurationTooShort();
    error AllowlistAmountExceeded(uint256 allowedAmount);

    function getPresale(uint256 _presaleId) external view returns (Presale memory);
}
"
    },
    "src/interfaces/IOwnerAdmins.sol": {
      "content": "// SPDX-License-Identifier: MIT
pragma solidity ^0.8.28;

interface IOwnerAdmins {
    error Unauthorized();

    event SetAdmin(address indexed admin, bool enabled);

    function setAdmin(address admin, bool isAdmin) external;
}
"
    },
    "src/utils/OwnerAdmins.sol": {
      "content": "// SPDX-License-Identifier: MIT
pragma solidity ^0.8.28;

import {IOwnerAdmins} from "../interfaces/IOwnerAdmins.sol";
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";

abstract contract OwnerAdmins is Ownable, IOwnerAdmins {
    mapping(address => bool) public admins;

    constructor(address owner_) Ownable(owner_) {}

    function setAdmin(address admin, bool enabled) external onlyOwner {
        admins[admin] = enabled;
        emit SetAdmin(admin, enabled);
    }

    modifier onlyAdmin() {
        if (!admins[msg.sender]) revert Unauthorized();
        _;
    }

    modifier onlyOwnerOrAdmin() {
        if (!admins[msg.sender] && msg.sender != owner()) revert Unauthorized();
        _;
    }
}
"
    },
    "lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol": {
      "content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.20;

/**
 * @dev Interface of the ERC-20 standard as defined in the ERC.
 */
interface IERC20 {
    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);

    /**
     * @dev Returns the value of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

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

    /**
     * @dev Moves a `value` amount of tokens from the caller's account to `to`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address to, uint256 value) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets a `value` amount of tokens as the allowance of `spender` over the
     * caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 value) external returns (bool);

    /**
     * @dev Moves a `value` amount of tokens from `from` to `to` using the
     * allowance mechanism. `value` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address from, address to, uint256 value) external returns (bool);
}
"
    },
    "lib/openzeppelin-contracts/contracts/utils/ReentrancyGuard.sol": {
      "content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.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 EIP-1153 (transient storage) is available on the chain you're deploying at,
 * consider using {ReentrancyGuardTransient} instead.
 *
 * 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;
    }
}
"
    },
    "lib/v4-core/src/types/PoolKey.sol": {
      "content": "// 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;
}
"
    },
    "lib/v4-core/src/types/PoolId.sol": {
      "content": "// 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)
        }
    }
}
"
    },
    "lib/openzeppelin-contracts/contracts/utils/introspection/IERC165.sol": {
      "content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/introspection/IERC165.sol)

pragma solidity ^0.8.20;

/**
 * @dev Interface of the ERC-165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[ERC].
 *
 * Implementers can declare support of contract interfaces, which can then be
 * queried by others ({ERC165Checker}).
 *
 * For an implementation, see {ERC165}.
 */
interface IERC165 {
    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[ERC section]
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
"
    },
    "lib/openzeppelin-contracts/contracts/access/Ownable.sol": {
      "content": "// 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);
    }
}
"
    },
    "lib/v4-core/src/types/Currency.sol": {
      "content": "// 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)));
    }
}
"
    },
    "lib/v4-core/src/interfaces/IHooks.sol": {
      "content": "// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {PoolKey} from "../types/PoolKey.sol";
import {BalanceDelta} from "../types/BalanceDelta.sol";
import {IPoolManager} from "./IPoolManager.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,
        IPoolManager.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,
        IPoolManager.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,
        IPoolManager.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,
        IPoolManager.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,
        IPoolManager.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,
        IPoolManager.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);
}
"
    },
    "lib/openzeppelin-contracts/contracts/utils/Context.sol": {
      "content": "// 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;
    }
}
"
    },
    "lib/v4-core/src/interfaces/external/IERC20Minimal.sol": {
      "content": "// 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);
}
"
    },
    "lib/v4-core/src/libraries/CustomRevert.sol": {
      "content": "// 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))
            msto

Tags:
ERC20, ERC165, Multisig, Mintable, Burnable, Swap, Liquidity, Upgradeable, Multi-Signature, Factory|addr:0xf7db81910444ab0f07ba264d7636d219a8c7769d|verified:true|block:23676803|tx:0x89853e8037fe38be846745db248a5998f76d5e862e4469b8284d5bfb64e87399|first_check:1761668883

Submitted on: 2025-10-28 17:28:05

Comments

Log in to comment.

No comments yet.