Skip to content
Verified contractExactUNLICENSED

UniswapLaunchFactoryV3

Address0x228cf77d91f7edd0c69538336196ca0acacca30e
Balance

0 ETH

 

Transactions

205

 

Compiler

solc 0.8.30

 

Same code

Only this contract

 

Details

Compiler
solc 0.8.30+commit.73712a01
Language
solidity
Optimization
Yes, 200 runs
EVM version
cancun
Via IR
yes
License
UNLICENSED
Match
Exactcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
26,328,520
Creation transaction
0xe15e50fb0a…929a248024

109 files

The source code is large: one file is shown at a time. Choose a file in the list.

src/v3/UniswapLaunchFactoryV3.sol

// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.30;

import {IERC1271} from "./LaunchFactoryBaseV3.sol";
import {UniswapVenueV3} from "./UniswapVenueV3.sol";
import {UniswapLaunchFactoryV3Joiner} from "./UniswapLaunchFactoryV3Joiner.sol";
import {UniswapLaunchFactoryV3Checks} from "./UniswapLaunchFactoryV3Checks.sol";
import {PriceAttestorV2} from "../v2/PriceAttestorV2.sol";
import {LaunchTermsV3} from "./V3Shared.sol";
import {RouteConfig} from "../lz/Routes.sol";

/// @title UniswapLaunchFactoryV3
/// @notice Pangea launch factory v3 on Uniswap v4 (docs/factory-v3.md): Ethereum, Base, BSC,
///         Robinhood. The launch itself is here; everything else -- adding a chain after launch
///         (`joinChain`, `addChain`, `seedJoined`), every admin call (the hook, the launch buys,
///         launchers, the admin) and every read (`launches`, `launchV3`, `predictToken`,
///         `checkTerms`, ...) -- is the companion's code, run here by delegatecall, on this
///         contract's storage, as this contract.
/// @dev THE COMPANION IS DEPLOYED FIRST, with the same arguments, and named here (`joiner_`). It
///      runs on this contract's storage, so what must agree is what it holds as immutables: this
///      constructor reads every one of them back from it and refuses a companion whose endpoint,
///      attestor, deployer, platform, operator, collector, parts deployer, chain, pool manager or
///      locker differs from its own (`JoinerMismatch`). Its address is an immutable here, and only
///      the fallback reaches it -- and `_checkLaunch`, which hands it `launch`'s own calldata to
///      check the inputs (v3, for size). Every selector this contract does not have goes to the
///      companion, which refuses direct calls to anything that writes.
contract UniswapLaunchFactoryV3 is UniswapVenueV3 {
    /// @notice The companion holding the add-a-chain, admin and read code. Reached only by delegatecall.
    address public immutable joiner;

    /// @notice The input checks (UniswapLaunchFactoryV3Checks), made by the companion: `launch`
    ///         asks it (`_checkLaunch`); previews call it here.
    address public immutable checks;

    constructor(
        address lzEndpoint_,
        address attestor_,
        address tokenDeployer_,
        address poolManager_,
        address locker_,
        address platform_,
        address operator_,
        address admin_,
        address feeCollector_,
        address parts_,
        address joiner_,
        bytes32[] memory hookCodehashes_,
        RouteConfig[] memory routes_
    )
        UniswapVenueV3(
            lzEndpoint_, attestor_, tokenDeployer_, poolManager_, locker_, platform_, operator_, admin_, feeCollector_,
            parts_, hookCodehashes_, routes_
        )
    {
        UniswapLaunchFactoryV3Joiner j = UniswapLaunchFactoryV3Joiner(payable(joiner_));
        if (joiner_.code.length == 0) revert JoinerMismatch(0);
        if (j.lzEndpoint() != lzEndpoint) revert JoinerMismatch(1);
        if (address(j.attestor()) != address(attestor)) revert JoinerMismatch(2);
        if (address(j.tokenDeployer()) != address(tokenDeployer)) revert JoinerMismatch(3);
        if (j.platform() != platform) revert JoinerMismatch(4);
        if (j.operator() != operator) revert JoinerMismatch(5);
        if (address(j.feeCollector()) != address(feeCollector)) revert JoinerMismatch(6);
        if (address(j.parts()) != address(parts)) revert JoinerMismatch(7);
        if (j.localEid() != localEid) revert JoinerMismatch(8);
        if (j.poolManager() != poolManager) revert JoinerMismatch(9);
        if (address(j.locker()) != address(locker)) revert JoinerMismatch(11);
        joiner = joiner_;
        // The checks the companion made, on this factory's attestor and chain.
        address c = j.checks();
        if (c.code.length == 0) revert JoinerMismatch(12);
        if (address(UniswapLaunchFactoryV3Checks(c).attestor()) != address(attestor)) revert JoinerMismatch(13);
        if (UniswapLaunchFactoryV3Checks(c).localEid() != localEid) revert JoinerMismatch(14);
        checks = c;
    }

    /// @notice The companion named at construction disagrees with this factory: `field` is which
    ///         immutable (0: it has no code).
    error JoinerMismatch(uint256 field);

    /// @notice Launch, as the creator themselves or as the platform on their behalf -- its admin,
    ///         or a launcher its admin has listed.
    ///
    /// @dev NOT PERMISSIONLESS, and the reason is specific to launching on five chains at once. The
    ///      snapshot's signature is the real authorisation -- it names the token, the price, the fee
    ///      and the peer set, so a caller can change nothing about the launch except the tick,
    ///      inside a tolerance capped at 1%. But that signature becomes public the moment the first
    ///      chain is launched, and with this open to anyone, whoever watches that transaction could
    ///      take the remaining four chains and bundle the launch with the first buy atomically on
    ///      each. The creator would be front-run on their own token, on the chains they had not
    ///      reached yet, and could do nothing about it.
    ///
    ///      A listed launcher is how the platform does this for a creator who holds funds on one
    ///      chain and has signed nothing. `launchAuthorized` is how a creator hands it to somebody
    ///      the platform has not listed.
    function launch(
        LaunchParams calldata p,
        LaunchTermsV3 calldata terms,
        PriceAttestorV2.Snapshot calldata snap,
        bytes calldata signature
    ) external payable returns (Launch memory out) {
        if (msg.sender != p.creator && msg.sender != admin && !isLauncher[msg.sender]) {
            revert NotLauncher(p.creator);
        }
        return _launch(p, terms, snap, signature);
    }

    /// @notice Launch on behalf of a creator who signed for it, paying their gas for them.
    ///
    /// ## Why this exists
    ///
    /// A creator cannot be `msg.sender` on four chains without first holding ETH on Ethereum, ETH
    /// on Base, ETH on Robinhood and BNB on BSC. That is four funded balances in three assets
    /// before they can begin, which is not a launchpad, and it is why `launch` being
    /// creator-or-admin was only half an answer: the admin half meant the platform paying for
    /// every launch with nothing tying its hands.
    ///
    /// So the creator signs, once, for free, and anyone they authorised broadcasts. Gas is the
    /// launcher's problem, which is the platform's, which is what a launch fee is for.
    ///
    /// ## Why the signature names the launcher
    ///
    /// Because it is the one thing that makes a PUBLIC authorisation safe. This signature is
    /// visible from the moment the first chain is launched -- the same exposure that stops `launch`
    /// being open -- and binding `launcher` into what is signed means seeing it is worthless to
    /// anyone else: a bot replaying it is not the named launcher, so the recovery still matches but
    /// the gate does not open.
    ///
    /// That is also what lets ONE signature cover all four chains. The domain omits `chainId` and
    /// `verifyingContract` for the same reason `PriceAttestor`'s does: a chain-specific domain
    /// would mean four signatures, four prompts, and nothing tying them together. Replay is bounded
    /// by `launchId`, which every chain consumes exactly once.
    ///
    /// ## What it does not permit
    ///
    /// Nothing the creator did not already control. The signature carries no price, no fee and no
    /// supply -- all of those are in the snapshot the platform's price signer signed, and the token
    /// address commits to the creator, the name, the symbol, the metadata URI, the hook and the
    /// launch buys. A launcher holding this signature can launch THAT launch, or nothing.
    ///
    /// ## A creator that is a contract (v2)
    ///
    /// A multisig, a smart account or a tokenomics contract cannot produce an ECDSA signature, so
    /// for a creator with code the same digest -- `attestor.launchAuthHash(launchId, msg.sender)`,
    /// so a Safe signs exactly what an EOA signs -- is put to the creator's own EIP-1271
    /// `isValidSignature`, as a static call with at most `ERC1271_GAS`, and must return the magic
    /// value. An EIP-7702 delegated EOA has code and takes this path; a delegation that does not
    /// implement EIP-1271 fails closed.
    ///
    /// @param creatorAuth A 65-byte ECDSA signature by `p.creator` over `launchAuthHash(launchId,
    ///        msg.sender)`, or, for a creator with code, whatever its `isValidSignature` accepts.
    function launchAuthorized(
        LaunchParams calldata p,
        LaunchTermsV3 calldata terms,
        PriceAttestorV2.Snapshot calldata snap,
        bytes calldata signature,
        bytes calldata creatorAuth
    ) external payable returns (Launch memory out) {
        if (p.creator.code.length == 0) {
            // Verified by the attestor, which owns EIP-712 and the malleability rule for this
            // system: two implementations of one signature scheme are two things that can drift.
            address signer = attestor.recoverLaunchAuth(snap.launchId, msg.sender, creatorAuth);
            if (signer != p.creator) revert BadCreatorAuth(signer, p.creator);
        } else {
            bytes32 digest = attestor.launchAuthHash(snap.launchId, msg.sender);
            (bool ok, bytes memory ret) = p.creator.staticcall{gas: ERC1271_GAS}(
                abi.encodeCall(IERC1271.isValidSignature, (digest, creatorAuth))
            );
            if (!ok || ret.length < 32 || abi.decode(ret, (bytes32)) != bytes32(IERC1271.isValidSignature.selector)) {
                revert ContractCreatorRefused(p.creator);
            }
        }
        return _launch(p, terms, snap, signature);
    }

    /// @dev The input checks, in the companion: `launch` and `launchAuthorized` take the same first
    ///      four arguments as `checkLaunch(p, terms, snap, signature)`, so their calldata is its
    ///      calldata with the selector changed (`launchAuthorized`'s fifth argument is past what it
    ///      decodes). A STATICCALL to the companion itself, not a delegatecall (audit R1c M-1): a
    ///      delegatecall keeps the call's value, and `checkLaunch` is not payable, so every launch
    ///      sent with its opening buy reverted. `checkLaunch` reads no storage -- only pure code and
    ///      the attestor, an immutable this constructor holds equal to the companion's -- so its
    ///      answer is the same either way. A refusal comes back as the companion's revert, unchanged.
    function _checkLaunch() internal view override returns (bytes32 th, bool pay, bytes32 payer, uint256 feeMin) {
        address j = checks;
        bytes4 sel = UniswapLaunchFactoryV3Checks.checkLaunch.selector;
        assembly ("memory-safe") {
            let ptr := mload(0x40)
            calldatacopy(ptr, 0, calldatasize())
            mstore(ptr, or(and(mload(ptr), not(shl(224, 0xffffffff))), sel))
            let ok := staticcall(gas(), j, ptr, calldatasize(), 0, 0)
            if iszero(ok) {
                returndatacopy(ptr, 0, returndatasize())
                revert(ptr, returndatasize())
            }
            if iszero(eq(returndatasize(), 0x80)) { revert(0, 0) }
            returndatacopy(ptr, 0, 0x80)
            th := mload(ptr)
            pay := iszero(iszero(mload(add(ptr, 0x20))))
            payer := mload(add(ptr, 0x40))
            feeMin := mload(add(ptr, 0x60))
        }
    }

    /// @dev Everything else is the companion's: delegatecall, with this contract's storage and
    ///      identity, and its answer or revert passed back unchanged. Not payable: none of the
    ///      companion's functions takes value, and `receive` takes the dust float.
    fallback() external {
        address j = joiner;
        // Memory-safe in the compiler's sense: it works only past the free memory pointer, and
        // never comes back to Solidity code.
        assembly ("memory-safe") {
            let ptr := mload(0x40)
            calldatacopy(ptr, 0, calldatasize())
            let ok := delegatecall(gas(), j, ptr, calldatasize(), 0, 0)
            returndatacopy(ptr, 0, returndatasize())
            if iszero(ok) { revert(ptr, returndatasize()) }
            return(ptr, returndatasize())
        }
    }
}
Compiler settingsShow
{
  "viaIR": true,
  "metadata": {
    "bytecodeHash": "ipfs"
  },
  "libraries": {},
  "optimizer": {
    "runs": 200,
    "enabled": true
  },
  "evmVersion": "cancun",
  "remappings": [
    "@layerzerolabs/lz-evm-protocol-v2/=lib/layerzero/protocol-v2/",
    "@layerzerolabs/oapp-evm/=lib/layerzero/oapp-evm/",
    "@layerzerolabs/oft-evm/=lib/layerzero/oft-evm/",
    "@openzeppelin/=lib/openzeppelin-contracts/",
    "@uniswap/v4-core/=lib/uniswap-v4-core/",
    "ds-test/=lib/openzeppelin-contracts/lib/forge-std/lib/ds-test/src/",
    "erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
    "forge-std/=lib/forge-std/src/",
    "halmos-cheatcodes/=lib/openzeppelin-contracts/lib/halmos-cheatcodes/src/",
    "layerzero/=lib/layerzero/",
    "openzeppelin-contracts/=lib/openzeppelin-contracts/",
    "solmate/=lib/solmate/",
    "uniswap-v4-core/=lib/uniswap-v4-core/src/"
  ]
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.