Skip to content
Verified contractExactUNLICENSED

UniswapLaunchFactoryV2

Address0xf7052a4e38e241bc66bfae6eb27d10b2a42cacb4
Balance

0 ETH

 

Transactions

176

 

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,280,552
Creation transaction
0x998f0fb894…ec5aead5a4

87 files

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

src/v2/UniswapLaunchFactoryV2.sol

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

import {IERC1271} from "./LaunchFactoryBaseV2.sol";
import {UniswapVenueV2} from "./UniswapVenueV2.sol";
import {UniswapLaunchFactoryV2Joiner} from "./UniswapLaunchFactoryV2Joiner.sol";
import {PriceAttestorV2} from "./PriceAttestorV2.sol";
import {RouteConfig} from "../lz/Routes.sol";

/// @title UniswapLaunchFactoryV2
/// @notice Pangea launch factory v2 on Uniswap v4 (docs/factory-v2.md): Ethereum, Base, BSC,
///         Robinhood. The launch itself is here; adding a chain after launch (`joinChain`,
///         `addChain`, `seedJoined`) 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, hook
///      locker or either tokenomics implementation differs from its own (`JoinerMismatch`). (It was made here once, which put this
///      contract's init code past the 49,152-byte limit with four routes.) Its address is an
///      immutable here, and only the fallback reaches it: every selector this contract does not have
///      goes to the companion, which has the three add-a-chain functions and refuses direct calls.
contract UniswapLaunchFactoryV2 is UniswapVenueV2 {
    /// @notice The companion holding the add-a-chain code. Reached only by delegatecall.
    address public immutable joiner;

    constructor(
        address lzEndpoint_,
        address attestor_,
        address tokenDeployer_,
        address poolManager_,
        address feeHook_,
        address locker_,
        address platform_,
        address operator_,
        address admin_,
        address feeCollector_,
        address parts_,
        address joiner_,
        address tokenomicsImplementation_,
        address tokenomicsV2Implementation_,
        RouteConfig[] memory routes_
    ) UniswapVenueV2(lzEndpoint_, attestor_, tokenDeployer_, poolManager_, feeHook_, locker_, platform_, operator_, admin_, feeCollector_, parts_, tokenomicsImplementation_, tokenomicsV2Implementation_, routes_) {
        UniswapLaunchFactoryV2Joiner j = UniswapLaunchFactoryV2Joiner(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.feeHook()) != address(feeHook)) revert JoinerMismatch(10);
        if (address(j.locker()) != address(locker)) revert JoinerMismatch(11);
        if (j.tokenomicsImplementation() != tokenomicsImplementation) revert JoinerMismatch(12);
        if (j.tokenomicsV2Implementation() != tokenomicsV2Implementation) revert JoinerMismatch(13);
        joiner = joiner_;
    }

    /// @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,
        LaunchTerms 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 and the metadata URI. 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,
        LaunchTerms 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 vault half of the payee check, run in the companion for size (EIP-170: with B26's
    ///      second vault kind this contract's runtime was 24,869 bytes). A static call to this
    ///      contract, which the fallback below delegates to the joiner's `checkVaultPayee`: the
    ///      same logic (LaunchFactoryBaseV2 `_checkVaultPayee`), as this contract, with immutables
    ///      the constructor held equal to this contract's (JoinerMismatch 12 and 13). Its revert --
    ///      `PayeeNotAllowed(payee)` -- comes back unchanged.
    function _checkVaultPayee(
        address payee,
        address creator,
        bytes32 launchId,
        PriceAttestorV2.Leg[] calldata legs,
        address[] calldata quotes
    ) internal view override {
        (bool ok, bytes memory ret) = address(this).staticcall(
            abi.encodeCall(UniswapLaunchFactoryV2Joiner.checkVaultPayee, (payee, creator, launchId, legs, quotes))
        );
        if (!ok) {
            assembly ("memory-safe") {
                revert(add(ret, 0x20), mload(ret))
            }
        }
    }

    /// @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.