Verified contractExactUNLICENSED
PriceAttestorV3
Address0x0e6ff904f764c0b5b84a9c3c1780e08dff84deb9
- Balance
0 ETH
- Transactions
3
- 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,515
- Creation transaction
- 0x28af4a92a6…7363478378
4 files
- src/v3/PriceAttestorV3.solmain11.71 KB
- src/FactoryList.sol3.63 KB
- src/v2/PriceAttestorV2.sol40.03 KB
- src/venues/OpeningDust.sol3.4 KB
src/v3/PriceAttestorV3.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.30;
import {PriceAttestorV2} from "../v2/PriceAttestorV2.sol";
/// @title PriceAttestorV3
/// @notice The v3 launch factory's attestor: PriceAttestorV2, unchanged and inherited whole (the
/// same EIP-712 domain, so the one signature over a snapshot verifies here and on the live
/// PriceAttestorV2 alike), plus the v3 opening rules of the owner's decision of 2026-10-31:
///
/// 1. AN ADMIN-SETTABLE MINIMUM OPENING MARKET CAP, PER CHAIN. v2's floor is the constant
/// `MIN_MARKET_CAP_USD` ($3,000 a chain). v3's is `minMarketCapUsd`, which the admin
/// moves within the hard bounds [MIN_MARKET_CAP_LOWER_BOUND_USD,
/// MIN_MARKET_CAP_UPPER_BOUND_USD] = [$600, $3,000] a chain (`setMinMarketCapUsd`, event
/// `MinMarketCapSet` on every change in force). It opens at INITIAL_MIN_MARKET_CAP_USD
/// ($600). The most stays v2's `MAX_MARKET_CAP_USD`. A RAISE takes effect only
/// MIN_RAISE_DELAY (1 h, = MAX_DEADLINE_WINDOW) after it is set (owner Q26, 2026-10-31):
/// a snapshot already signed -- its deadline at most 1 h away -- lands under the minimum
/// it was signed against. The pending value and its time are readable
/// (`pendingMinMarketCapUsd`, `pendingMinMarketCapAt`), with an event when scheduled
/// (`MinMarketCapRaiseScheduled`) and when in force (`MinMarketCapSet`, emitted by the
/// first write after that time: `activateMinMarketCapUsd`, anyone's, or a launch). A
/// LOWERING is immediate and drops any pending raise. A launch is judged by the minimum in
/// force when it lands (`minMarketCapUsd()`).
/// 2. SUPPLY_SLICE ONLY. v3 drops the locked-supply mode (`SUPPLY_TOTAL`): every chain mints
/// its own slice and pools all of it. A snapshot with any other supply mode is refused.
///
/// @dev WHY A NEW CONTRACT. The live PriceAttestorV2's `openingUsdPerToken` is `pure` over the
/// constant floor and is not virtual, and the live contract must keep its v1/v2 behaviour
/// (and its bytecode, which go-live checks against the chain). So v3 gets this attestor, on the
/// same signer, and calls `attestV3` -- never the inherited `attest`, which still prices with
/// v2's constant floor for any factory that would call it.
///
/// PER CHAIN. A SUPPLY_SLICE snapshot's `marketCapUsd` is ONE chain's opening market cap: each
/// chain's token reports its own slice, the price is `cap x legs / (launchTotal / 1e9)`, and
/// the whole coin opens at `cap x legs`. So the bounds here, like v2's, are per chain: $600 a
/// chain is $3,000 for a coin on five chains.
///
/// One launch id is consumed once on THIS contract. A v3 snapshot cannot be replayed on the
/// live attestor through a v2 factory: its terms hash is v3's (LaunchTermsV3), which a v2
/// factory never rebuilds, and below $3,000 a chain the live attestor refuses its cap anyway.
contract PriceAttestorV3 is PriceAttestorV2 {
/// @notice The lowest value the admin may set the minimum to: $600 a chain (owner 2026-10-31;
/// the five-chain coin opens at $3,000, one pump.fun curve). The owner changes the bounds
/// here, in one place.
uint32 public constant MIN_MARKET_CAP_LOWER_BOUND_USD = 600;
/// @notice The highest value the admin may set the minimum to: v2's $3,000 a chain. Never above
/// MAX_MARKET_CAP_USD.
uint32 public constant MIN_MARKET_CAP_UPPER_BOUND_USD = 3_000;
/// @notice The minimum this contract is deployed with: $600 a chain.
uint32 public constant INITIAL_MIN_MARKET_CAP_USD = 600;
/// @notice How long a RAISE of the minimum waits before it is in force (owner Q26): one hour, the
/// longest a signed snapshot may be good for (MAX_DEADLINE_WINDOW).
uint64 public constant MIN_RAISE_DELAY = MAX_DEADLINE_WINDOW;
/// @dev The minimum last put in force (the pending raise, once due, is in force without a write).
uint32 internal _minMarketCapUsd;
/// @notice A raise of the minimum waiting for `pendingMinMarketCapAt`; 0 for none.
uint32 public pendingMinMarketCapUsd;
/// @notice When `pendingMinMarketCapUsd` is in force (unix seconds); 0 for none.
uint64 public pendingMinMarketCapAt;
/// @notice A minimum is in force: set at deploy (0 -> 600), lowered (at once), or a raise whose
/// delay has passed, activated by the first write after it.
event MinMarketCapSet(uint32 previous, uint32 minMarketCapUsd);
/// @notice The admin raised the minimum: `minMarketCapUsd` is in force from `effectiveAt`.
event MinMarketCapRaiseScheduled(uint32 current, uint32 minMarketCapUsd, uint64 effectiveAt);
/// @notice A minimum outside [MIN_MARKET_CAP_LOWER_BOUND_USD, MIN_MARKET_CAP_UPPER_BOUND_USD].
error MinMarketCapOutOfBounds(uint32 minMarketCapUsd);
/// @notice v3 launches are SUPPLY_SLICE only (owner 2026-10-31).
error SupplyModeNotV3(uint8 supplyMode);
constructor(
uint32 localEid_,
address signer_,
address admin_,
address signerAdmin_,
uint256 minUsdPerQuote_,
uint256 maxUsdPerQuote_
) PriceAttestorV2(localEid_, signer_, admin_, signerAdmin_, minUsdPerQuote_, maxUsdPerQuote_) {
// Compile-time facts, held here so a bounds edit that breaks them cannot deploy.
assert(
MIN_MARKET_CAP_LOWER_BOUND_USD > 0 && MIN_MARKET_CAP_LOWER_BOUND_USD <= INITIAL_MIN_MARKET_CAP_USD
&& INITIAL_MIN_MARKET_CAP_USD <= MIN_MARKET_CAP_UPPER_BOUND_USD
&& MIN_MARKET_CAP_UPPER_BOUND_USD <= MAX_MARKET_CAP_USD
);
_minMarketCapUsd = INITIAL_MIN_MARKET_CAP_USD;
emit MinMarketCapSet(0, INITIAL_MIN_MARKET_CAP_USD);
}
/// @notice The least opening market cap PER CHAIN a v3 launch may sign right now, in whole
/// dollars: the pending raise once its time has come, else the one last in force.
function minMarketCapUsd() public view returns (uint32) {
uint64 at = pendingMinMarketCapAt;
return at != 0 && block.timestamp >= at ? pendingMinMarketCapUsd : _minMarketCapUsd;
}
/// @notice Set the minimum opening market cap per chain for later v3 launches. The admin's (the
/// factory admin this attestor records), within the hard bounds. Lower than (or equal to)
/// the one in force: in force at once, and a pending raise is dropped. Higher: pending,
/// in force MIN_RAISE_DELAY from now; a second raise replaces the first and its time
/// starts again. A launch already made is not touched.
function setMinMarketCapUsd(uint32 minMarketCapUsd_) external {
if (msg.sender != admin) revert NotAdmin();
if (minMarketCapUsd_ < MIN_MARKET_CAP_LOWER_BOUND_USD || minMarketCapUsd_ > MIN_MARKET_CAP_UPPER_BOUND_USD) {
revert MinMarketCapOutOfBounds(minMarketCapUsd_);
}
_activate();
uint32 current = _minMarketCapUsd;
if (minMarketCapUsd_ <= current) {
pendingMinMarketCapUsd = 0;
pendingMinMarketCapAt = 0;
emit MinMarketCapSet(current, minMarketCapUsd_);
_minMarketCapUsd = minMarketCapUsd_;
} else {
uint64 at = uint64(block.timestamp) + MIN_RAISE_DELAY;
pendingMinMarketCapUsd = minMarketCapUsd_;
pendingMinMarketCapAt = at;
emit MinMarketCapRaiseScheduled(current, minMarketCapUsd_, at);
}
}
/// @notice Put a raise whose time has come in force in storage, with its event. Anyone's; a
/// no-op otherwise. (`minMarketCapUsd()` already answers with it either way.)
function activateMinMarketCapUsd() external {
_activate();
}
function _activate() internal {
uint64 at = pendingMinMarketCapAt;
if (at == 0 || block.timestamp < at) return;
uint32 next = pendingMinMarketCapUsd;
emit MinMarketCapSet(_minMarketCapUsd, next);
_minMarketCapUsd = next;
pendingMinMarketCapUsd = 0;
pendingMinMarketCapAt = 0;
}
/// @notice `attest` for a v3 launch: the same checks, the same consumption, the same event, with
/// the v3 price (`openingUsdPerTokenV3`). The v3 factory's only call here.
function attestV3(Snapshot calldata snap, bytes calldata signature, address quote)
external
returns (uint256 quotePerToken, uint8 quoteDecimals)
{
if (!isFactory[msg.sender]) revert NotFactory();
_activate();
uint256 usdPerQuote;
(usdPerQuote, quotePerToken, quoteDecimals) = _evaluateV3(snap, signature, quote);
consumed[snap.launchId] = true;
emit Attested(snap.launchId, usdPerQuote, quotePerToken);
}
/// @notice What `attestV3` would return right now, without consuming anything.
function previewV3(Snapshot calldata snap, bytes calldata signature, address quote)
external
view
returns (uint256 quotePerToken, uint8 quoteDecimals)
{
(, quotePerToken, quoteDecimals) = _evaluateV3(snap, signature, quote);
}
/// @notice The only `usdPerToken` a v3 snapshot over these legs may carry: `cap` dollars per
/// chain over each chain's slice, SUPPLY_SLICE only, `cap` within [minMarketCapUsd,
/// MAX_MARKET_CAP_USD]. Above the floor it is exactly v2's `openingUsdPerToken(legs, cap,
/// SUPPLY_SLICE)` (the same operations in the same order; web/lib/launch/v2.mjs
/// `openingUsdPerTokenV2`, the Solana program's v3 price).
function openingUsdPerTokenV3(Leg[] calldata legs, uint32 cap, uint8 supplyMode)
public
view
returns (uint256 usdPerToken)
{
if (supplyMode != SUPPLY_SLICE) revert SupplyModeNotV3(supplyMode);
if (cap < minMarketCapUsd() || cap > MAX_MARKET_CAP_USD) revert MarketCapOutOfRange(cap);
uint256 launchTotal;
for (uint256 i = 0; i < legs.length; i++) {
if (legs[i].slice != legs[0].slice) revert UnequalSlices(legs[i].lzEid);
launchTotal += legs[i].slice;
}
if (launchTotal == 0 || launchTotal % TOKEN_UNIT != 0) revert SupplyNotWholeTokens(launchTotal);
usdPerToken = (uint256(cap) * WAD * legs.length) / (launchTotal / TOKEN_UNIT);
if (usdPerToken == 0) revert ZeroPrice();
}
/// @dev PriceAttestorV2's `_evaluate`, check for check, with the v3 price.
function _evaluateV3(Snapshot calldata snap, bytes calldata signature, address quote)
internal
view
returns (uint256 usdPerQuote, uint256 quotePerToken, uint8 quoteDecimals)
{
if (block.timestamp > snap.deadline) revert SnapshotExpired(snap.deadline);
uint256 latest = block.timestamp + MAX_DEADLINE_WINDOW;
if (snap.deadline > latest) revert DeadlineTooFar(snap.deadline, latest);
if (consumed[snap.launchId]) revert AlreadyConsumed(snap.launchId);
if (_recover(snap, signature) != signer) revert BadSignature();
uint256 required = openingUsdPerTokenV3(snap.legs, snap.marketCapUsd, snap.supplyMode);
if (snap.usdPerToken != required) revert NotOpeningMarketCap(snap.usdPerToken, required);
usdPerQuote = _quoteForThisChain(snap);
if (usdPerQuote == 0) revert ZeroPrice();
quoteDecimals = _checkPlausible(usdPerQuote, quote);
quotePerToken = (snap.usdPerToken * WAD) / usdPerQuote;
if (quotePerToken == 0) revert PriceRoundsToZero();
}
}
src/FactoryList.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.30;
/// @title FactoryList
/// @notice An append-only list of the launch factories a contract serves.
///
/// WHY A LIST AND NOT ONE FACTORY. The hook, the locker, the fee collector and the attestor each
/// used to take ONE factory, once. A new factory -- a new token, a new opening rule -- then meant a
/// new hook at a new mined address, and a hook's address is what routers and hook lists know it by.
/// With a list, a later factory is added to the same contracts and the hook keeps its address.
///
/// WHAT AN ADDED FACTORY CAN AND CANNOT DO. It can open NEW pools and launches, exactly as the first
/// one can. It cannot touch anything that already exists: every pool and launch is recorded once,
/// by the factory that created it, with its fee and rules fixed then, and nothing in these
/// contracts lets a factory -- any factory -- write to a record after it is made. Factories are
/// never removed or replaced, so no launch ever loses the factory it was made by.
///
/// WHO ADDS ONE. `factoryAdmin`, the platform's admin key; no timelock. It starts as the address
/// that deploys the contract, so the deploy can add the first factory in the same run, and the
/// deploy then hands it to the admin (`setFactoryAdmin`). That key can add a factory of its own
/// that opens new pools on its own terms. It is a power over new launches only.
abstract contract FactoryList {
/// @notice Whether `factory` may act here.
mapping(address => bool) public isFactory;
/// @notice Every factory ever added, in order. Never shrinks.
address[] private _factories;
/// @notice May add a factory (and, on the hook, name who else may add liquidity).
address public factoryAdmin;
event FactoryAdded(address indexed factory, uint256 index);
event FactoryAdminSet(address indexed previous, address indexed next);
error ZeroFactory();
error FactoryAlreadyAdded(address factory);
error NotFactoryAdmin();
error ZeroFactoryAdmin();
modifier onlyFactoryAdmin() {
if (msg.sender != factoryAdmin) revert NotFactoryAdmin();
_;
}
function _initFactoryAdmin(address admin_) internal {
if (admin_ == address(0)) revert ZeroFactoryAdmin();
factoryAdmin = admin_;
emit FactoryAdminSet(address(0), admin_);
}
/// @notice Hand the role to another key. The current admin only.
function setFactoryAdmin(address next) external onlyFactoryAdmin {
if (next == address(0)) revert ZeroFactoryAdmin();
emit FactoryAdminSet(factoryAdmin, next);
factoryAdmin = next;
}
/// @notice Add a factory that may open NEW pools or launches here. Append-only: no factory is
/// ever removed or replaced, and none can change a record already made.
function addFactory(address factory_) external onlyFactoryAdmin {
_addFactory(factory_);
}
function _addFactory(address factory_) internal {
if (factory_ == address(0)) revert ZeroFactory();
if (isFactory[factory_]) revert FactoryAlreadyAdded(factory_);
isFactory[factory_] = true;
_factories.push(factory_);
emit FactoryAdded(factory_, _factories.length - 1);
}
/// @notice Every factory added, oldest first.
function factories() external view returns (address[] memory) {
return _factories;
}
function factoryCount() external view returns (uint256) {
return _factories.length;
}
function factoryAt(uint256 index) external view returns (address) {
return _factories[index];
}
}
src/v2/PriceAttestorV2.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.30;
import {quoteBandFloorFits} from "../venues/OpeningDust.sol";
import {FactoryList} from "../FactoryList.sol";
/// @dev What the attestor asks the pair registry: a listed asset's decimals and USD band.
interface IPairTerms {
function terms(address asset) external view returns (uint8 decimals, uint256 minUsdPerQuote, uint256 maxUsdPerQuote);
}
/// @title PriceAttestor
/// @notice Turns one off-chain price snapshot into the starting price for this chain's pool, so
/// all five pools open at the same price in USD.
///
/// WHY THIS EXISTS. Each chain pairs against its own native asset -- ETH on Ethereum, Base and
/// Robinhood, BNB on BSC, SOL on Solana. A tick of TOKEN/ETH is not comparable to a tick of
/// TOKEN/SOL, so "all five open at the same price" cannot mean the same number. It means the same
/// price in USD, and that requires knowing what each quote asset was worth at the launch instant.
///
/// ONE SIGNATURE, FIVE CHAINS. The snapshot carries every chain's quote price and is signed once.
/// Each chain reads its own entry out of the same payload, so the five deploys cannot disagree
/// about what ETH was worth even in principle -- and anyone can check afterwards that all five
/// used one snapshot, because it is one signature over one set of numbers.
///
/// THE DOMAIN DELIBERATELY OMITS chainId AND verifyingContract. Including either would make the
/// signature chain-specific and there would be five signatures over five payloads, with nothing
/// tying them together. The cost is that a snapshot is valid on every chain, so replay protection
/// cannot come from the domain: it comes from `deadline` and from each chain consuming a
/// `launchId` exactly once.
///
/// THE DEADLINE IS WHAT MAKES "SAME PRICE" TRUE. Quote prices move. A snapshot used twenty
/// minutes late opens that chain's pool at a stale price, and the gap is extracted from the
/// liquidity by the first arbitrageur. Past the deadline the deploy fails instead, which is the
/// right outcome -- a launch that opens misaligned is worse than one that has to be retried.
///
/// THE SIGNER IS TRUSTED, AND BOUNDED THE SAME WAY ON EVERY CHAIN. A compromised signer could
/// attest a wrong quote price, opening this chain's pool away from the others so the difference is
/// arbitraged out of the creator's liquidity.
///
/// There is no price oracle here, deliberately. Oracle coverage across these five chains is
/// uneven and unreliable on Robinhood in particular, and a guard present on four of them and
/// absent on the fifth is worse than no guard: it reads as though all five are covered while the
/// chain least likely to have a feed is the one trusting the signer completely.
///
/// Instead each deployment fixes a plausibility band -- the lowest and highest USD price this
/// chain's quote asset may ever be attested at. It is not a price source and does not pretend to
/// be one. It bounds the damage: ETH attested at $3, or at $300,000, is refused on every chain
/// identically, with no external contract, no staleness window, and nowhere the check quietly
/// does nothing.
///
/// It does not catch a plausible-but-wrong price. ETH attested at $3,300 when it is $3,000 gets
/// through, and that 10% lands in an arbitrageur's pocket rather than the creator's liquidity.
/// That residual risk belongs to the signing key, and the answer to it is custody and rotation,
/// not a feed.
///
/// THE SIGNER DOES NOT CHOOSE WHAT THE TOKEN IS WORTH. Every launch opens at the market cap PER
/// CHAIN its creator chose (`marketCapUsd`, $3,000 to $500,000): the snapshot's `usdPerToken` must
/// be exactly `openingUsdPerToken` of its own legs, cap and supply mode, or the launch is refused
/// here. The signer prices the quote assets, nothing else.
/// @dev Factory v2's attestor (docs/factory-v2.md). PriceAttestor, with the snapshot carrying three
/// more signed values, in a domain of its own (`PangeaLaunchPrice` version 3):
///
/// - `marketCapUsd`: the opening market cap PER CHAIN, in whole dollars, that the creator
/// chose. At least `MIN_MARKET_CAP_USD` ($3,000, v1's fixed figure) and at most
/// `MAX_MARKET_CAP_USD`. The price is still not the signer's: `usdPerToken` must be exactly
/// `openingUsdPerToken(legs, marketCapUsd, supplyMode)`.
/// - `supplyMode`: what each chain's token reports as its supply, which is what a tracker
/// multiplies the price by. `SUPPLY_SLICE` (0, v1's launches): one chain's slice, so the cap
/// is over the slice. `SUPPLY_TOTAL` (1, the 20%-circulating launch): the whole launch
/// total on every chain, so the cap is over the total and the price is lower by the number
/// of chains -- each chain still reads `marketCapUsd`.
/// - `terms`: the hash of what the launch agreed to beyond its price (its payees and its fee:
/// LaunchFactoryBaseV2.termsHash), checked by each chain's factory or program.
/// - each leg's `feeBps` (version 3, owner decision 2026-10-23): the pool fee is per chain,
/// not one figure for the whole launch. Version 2 carried a single `Snapshot.feeBps`; it
/// moved into `Leg`, and the domain's version moved with it so a version 2 signature can
/// never be read as a version 3 one.
///
/// Everything else -- the deadline window, the bands, one consumption per launch id, the
/// recovery rule, the launch authorisation -- is v1's. The v1 notes follow; where they say
/// every launch opens at $3,000, read: at `marketCapUsd`, never below $3,000.
contract PriceAttestorV2 is FactoryList {
/// @notice One chain's part of a launch: what its quote asset is worth, and which token it is.
///
/// @dev `usdPerQuote` is 1e18-scaled, so `3000e18` is $3,000.
///
/// `token` is that chain's token address as a LayerZero peer: an EVM address left-padded
/// to 32 bytes, or on Solana the OFT Store (not the mint: the store is what LayerZero
/// reports as the sender). It is here so the signature covers far more than a
/// price. An EVM token address is CREATE2 over its whole constructor -- name, symbol,
/// supply, creator, metadata, salt -- so one word per chain commits to every one of them,
/// and the set of legs IS the peer set. Before this the launcher supplied the peers and
/// the token parameters unsigned, which made the price signer no check on it at all: a
/// peer is an address allowed to mint, so one extra entry was unlimited supply.
struct Leg {
uint32 lzEid;
uint256 usdPerQuote;
bytes32 token;
/// @notice That chain's share of the launch total.
///
/// @dev THIS IS WHAT KEEPS THE GLOBAL SUPPLY HONEST, and it is signed rather than implied
/// because the token's address no longer implies it. A token's address used to be
/// CREATE2 over every constructor argument, slice among them, so signing the address
/// signed the slice; that is also why one token had five unrelated addresses. Taking
/// the chain-varying arguments out of the init code made the five agree and left this
/// one value unbound -- a launcher could have passed the whole launch total on every
/// chain and minted five times the supply, with every address still matching its leg.
/// So the signer states each chain's slice, and each chain checks its own.
uint256 slice;
/// @notice That chain's pool fee, in bps of each trade's quote side: what its fee splitter
/// and its pool are opened with. Within [MIN_FEE_BPS, MAX_FEE_BPS], the hook's own
/// bounds.
/// @dev Signed per leg, so the chains of one launch may charge different fees. Every leg's
/// fee is held to the bounds on EVERY chain (`_evaluate`), like the other per-leg
/// checks: a leg only its own chain could refuse would let the rest land without it.
uint16 feeBps;
}
/// @notice The whole launch, signed once and passed to all five deploys.
struct Snapshot {
bytes32 launchId;
/// @notice The opening market cap per chain, in whole US dollars: at least
/// `MIN_MARKET_CAP_USD`, at most `MAX_MARKET_CAP_USD`.
uint32 marketCapUsd;
/// @notice `SUPPLY_SLICE` or `SUPPLY_TOTAL`: what the cap is measured over.
uint8 supplyMode;
/// @notice The launch terms' hash (LaunchFactoryBaseV2.termsHash).
bytes32 terms;
/// @dev The launch price in USD per whole token, 1e18-scaled. NOT the signer's to choose:
/// it must be `openingUsdPerToken(legs, marketCapUsd, supplyMode)`, and a snapshot
/// carrying anything else is refused. Signed, so the one signature Solana and the four
/// EVM chains verify covers it.
uint256 usdPerToken;
uint64 deadline;
Leg[] legs;
}
bytes32 private constant LEG_TYPEHASH =
keccak256("Leg(uint32 lzEid,uint256 usdPerQuote,bytes32 token,uint256 slice,uint16 feeBps)");
bytes32 private constant SNAPSHOT_TYPEHASH = keccak256(
"Snapshot(bytes32 launchId,uint32 marketCapUsd,uint8 supplyMode,bytes32 terms,uint256 usdPerToken,uint64 deadline,Leg[] legs)Leg(uint32 lzEid,uint256 usdPerQuote,bytes32 token,uint256 slice,uint16 feeBps)"
);
bytes32 private constant DOMAIN_TYPEHASH = keccak256("EIP712Domain(string name,string version)");
/// @dev Computed from name and version alone -- see the note above on why chainId and
/// verifyingContract are excluded.
bytes32 public constant DOMAIN_SEPARATOR =
keccak256(abi.encode(DOMAIN_TYPEHASH, keccak256("PangeaLaunchPrice"), keccak256("3")));
uint256 public constant WAD = 1e18;
uint256 public constant BPS = 10_000;
/// @notice The least and the most pool fee a leg may sign, in bps: PangeaFeeHook's and
/// FeeSplitterV2's MIN_FEE_BPS and MAX_FEE_BPS (0.3% to 5%).
uint16 public constant MIN_FEE_BPS = 30;
uint16 public constant MAX_FEE_BPS = 500;
/// @notice The least opening market cap per chain a creator may choose, in whole dollars: v1's
/// fixed $3,000. Nobody can launch below it.
uint32 public constant MIN_MARKET_CAP_USD = 3_000;
/// @notice The most, in whole dollars: $500,000 a chain (owner decision 2026-10-22). Above it
/// a figure is refused as a mistake.
uint32 public constant MAX_MARKET_CAP_USD = 500_000;
/// @notice Each chain's token reports its own slice as its supply (v1's launches).
uint8 public constant SUPPLY_SLICE = 0;
/// @notice Each chain's token reports the whole launch total as its supply.
uint8 public constant SUPPLY_TOTAL = 1;
/// @notice One whole launched token in base units. The token has 9 decimals on every chain.
uint256 public constant TOKEN_UNIT = 1e9;
/// @notice The furthest ahead of now a snapshot's deadline may sit.
/// @dev The deadline is what bounds how stale a price a pool can open at, and it is the
/// signer's to choose -- so without a ceiling a snapshot signed with a deadline a year out
/// is a standing licence to open that launch at today's price whenever it suits. A launch
/// is five transactions sent together and the orchestrator signs fifteen minutes; an hour
/// is comfortably more than that and still short enough to mean something.
uint64 public constant MAX_DEADLINE_WINDOW = 1 hours;
/// @notice This chain's LayerZero endpoint id. Selects which entry of the snapshot applies.
uint32 public immutable localEid;
/// @notice The band this chain's NATIVE coin may be attested within, 1e18-scaled USD.
/// @dev Immutable. Set wide enough that no honest market move trips it and narrow enough that
/// an absurd value cannot pass -- for an ETH-quoted chain, something like $100 to
/// $100,000 rather than a tight collar around the current price. A launch quoted in a
/// listed asset is held to that asset's band in `registry` instead.
uint256 public immutable minUsdPerQuote;
uint256 public immutable maxUsdPerQuote;
/// @notice The pair registry: which assets besides the native coin a launch may pair against,
/// their decimals and their USD bands. Zero until named, and then only native launches
/// can be attested.
/// @dev Named once, by the deployer, like the factory -- so a band can be changed only through
/// the registry's own admin, and only for launches not yet made.
address public registry;
address public signer;
address public pendingSigner;
/// @notice The key that launches: the factory's admin, recorded here so this contract can
/// refuse to let it also be the key that chooses the signer.
/// @dev It holds NO power over the signer. It did once, and that made the signer no check on
/// it at all: the launching key could install a signer of its own and then launch
/// anything. What it may do here is hand itself over, so this record can follow the
/// factory's admin when that moves.
address public admin;
address public pendingAdmin;
/// @notice The only key that may rotate the signer. Never the same key as `admin`.
/// @dev "A compromised admin alone can launch nothing the signer did not sign" is only true if
/// the admin cannot replace the signer. So rotation belongs to a separate role with its
/// own two-step handover, and construction and both handovers refuse to let the two
/// roles meet in one address. This contract cannot see who holds the keys, or whether the
/// factory's own admin has moved somewhere else -- keeping them apart in custody is the
/// part no contract can do.
address public signerAdmin;
address public pendingSignerAdmin;
// The only callers `attest` accepts: the listed launch factories (`isFactory`, FactoryList),
// mid-launch. The snapshot and its signature are public the moment any chain's launch
// transaction is visible, and the same pair is valid on all five chains. If anyone could
// present them, anyone could consume a launch id ahead of the factory and the real launch
// would revert -- on this chain, or on the four that had not landed yet. A launch id is
// consumed once, whichever listed factory presents it.
/// @notice May add a factory, append-only. Whoever deployed this contract.
address public immutable deployer;
/// @notice Launch ids already used on this chain. One pool per launch per chain.
mapping(bytes32 => bool) public consumed;
event Attested(bytes32 indexed launchId, uint256 usdPerQuote, uint256 quotePerToken);
event SignerProposed(address indexed from, address indexed to);
event SignerChanged(address indexed from, address indexed to);
event RegistrySet(address registry);
event AdminProposed(address indexed from, address indexed to);
event AdminChanged(address indexed from, address indexed to);
event SignerAdminProposed(address indexed from, address indexed to);
event SignerAdminChanged(address indexed from, address indexed to);
error ZeroAddress();
error BadSignature();
error SnapshotExpired(uint64 deadline);
error DeadlineTooFar(uint64 deadline, uint256 latest);
error DuplicateLegForThisChain(uint32 localEid);
error AlreadyConsumed(bytes32 launchId);
error NoQuoteForThisChain(uint32 localEid);
error ZeroPrice();
error QuotePriceImplausible(uint256 usdPerQuote, uint256 min, uint256 max);
error InvalidBand(uint256 min, uint256 max);
error PriceRoundsToZero();
/// @notice The launch's supply, the legs' slices added up, is not a whole number of tokens.
error SupplyNotWholeTokens(uint256 launchTotal);
/// @notice The snapshot's price is not its market cap over the supply its mode reports.
error NotOpeningMarketCap(uint256 usdPerToken, uint256 required);
error MarketCapOutOfRange(uint32 marketCapUsd);
error UnknownSupplyMode(uint8 supplyMode);
error UnequalSlices(uint32 lzEid);
/// @notice A leg's pool fee is outside [MIN_FEE_BPS, MAX_FEE_BPS].
error LegFeeOutOfRange(uint32 lzEid, uint16 feeBps);
error NotAdmin();
error NotSignerAdmin();
error RolesMustDiffer();
error NotPending();
error NotFactory();
error NotDeployer();
error RegistryAlreadySet();
/// @notice A launch quoted in an asset, on an attestor with no registry to list it.
error NoRegistry(address quote);
constructor(
uint32 localEid_,
address signer_,
address admin_,
address signerAdmin_,
uint256 minUsdPerQuote_,
uint256 maxUsdPerQuote_
) {
if (signer_ == address(0) || admin_ == address(0) || signerAdmin_ == address(0)) revert ZeroAddress();
if (signerAdmin_ == admin_) revert RolesMustDiffer();
// The native coin has 18 decimals, and its band's floor is held to the same 1e-30 USD a
// base unit as a listed asset's, so no opening against it can owe more dust than the
// locker may pay (OpeningDust.sol). Never close for a real native coin.
if (minUsdPerQuote_ == 0 || maxUsdPerQuote_ < minUsdPerQuote_ || !quoteBandFloorFits(minUsdPerQuote_, 18)) {
revert InvalidBand(minUsdPerQuote_, maxUsdPerQuote_);
}
localEid = localEid_;
deployer = msg.sender;
_initFactoryAdmin(msg.sender);
signer = signer_;
admin = admin_;
signerAdmin = signerAdmin_;
minUsdPerQuote = minUsdPerQuote_;
maxUsdPerQuote = maxUsdPerQuote_;
}
/// @notice Name the pair registry. Once, by the deployer.
function setRegistry(address registry_) external {
if (msg.sender != deployer) revert NotDeployer();
if (registry != address(0)) revert RegistryAlreadySet();
if (registry_ == address(0)) revert ZeroAddress();
registry = registry_;
emit RegistrySet(registry_);
}
// --------------------------------------------------------- attestation
/// @notice Verify a snapshot and return this chain's starting price, in quote units per
/// token, 1e18-scaled, with the quote's decimals. Consumes the launch id, so this
/// succeeds once per launch.
/// @param quote The asset this launch pairs against: zero for the native coin, otherwise one
/// the registry lists -- refused if it does not. The signed price is a price in it, and
/// is held to its band.
/// @dev State-changing by design, and factory-only for that reason: the consumption is what
/// stops the same snapshot seeding a second pool on this chain later at a price that has
/// since gone stale, so it must not be something a stranger can spend first. `preview`
/// is the same checks and the same arithmetic for everyone else.
function attest(Snapshot calldata snap, bytes calldata signature, address quote)
external
returns (uint256 quotePerToken, uint8 quoteDecimals)
{
if (!isFactory[msg.sender]) revert NotFactory();
uint256 usdPerQuote;
(usdPerQuote, quotePerToken, quoteDecimals) = _evaluate(snap, signature, quote);
consumed[snap.launchId] = true;
emit Attested(snap.launchId, usdPerQuote, quotePerToken);
}
/// @notice What `attest` would return right now, without consuming anything. Reverts
/// wherever `attest` would, apart from the caller check.
function preview(Snapshot calldata snap, bytes calldata signature, address quote)
external
view
returns (uint256 quotePerToken, uint8 quoteDecimals)
{
(, quotePerToken, quoteDecimals) = _evaluate(snap, signature, quote);
}
/// @dev Every check a snapshot has to pass, in one place, so that `preview` cannot say yes to
/// something `attest` will refuse.
function _evaluate(Snapshot calldata snap, bytes calldata signature, address quote)
internal
view
returns (uint256 usdPerQuote, uint256 quotePerToken, uint8 quoteDecimals)
{
if (block.timestamp > snap.deadline) revert SnapshotExpired(snap.deadline);
uint256 latest = block.timestamp + MAX_DEADLINE_WINDOW;
if (snap.deadline > latest) revert DeadlineTooFar(snap.deadline, latest);
if (consumed[snap.launchId]) revert AlreadyConsumed(snap.launchId);
if (_recover(snap, signature) != signer) revert BadSignature();
// The price per token is not the signer's: it is the chosen opening market cap over the
// supply each chain reports, from the slices the legs state, which every chain's factory
// has already held to its slice and to the total.
uint256 required = openingUsdPerToken(snap.legs, snap.marketCapUsd, snap.supplyMode);
if (snap.usdPerToken != required) revert NotOpeningMarketCap(snap.usdPerToken, required);
usdPerQuote = _quoteForThisChain(snap);
if (usdPerQuote == 0) revert ZeroPrice();
quoteDecimals = _checkPlausible(usdPerQuote, quote);
quotePerToken = (snap.usdPerToken * WAD) / usdPerQuote;
// A price that rounds to zero would seed a pool giving tokens away. Better to fail the
// launch than to open one.
if (quotePerToken == 0) revert PriceRoundsToZero();
}
/// @notice The only `usdPerToken` a snapshot over these legs may carry: `cap` dollars per chain
/// over the supply each chain's token reports.
/// @dev `launchTotal` is the legs' slices added up, in base units, and must be a whole number
/// of tokens. Identical to `openingUsdPerTokenV2` in web/lib/launch/v2.mjs and to the
/// Solana program's v2 price, which multiply and divide in the same order (vector:
/// test/fixtures/snapshot-v2-vector.json). Reverts `ZeroPrice` for a supply so large the
/// price rounds to nothing.
///
/// `cap` is whole dollars within [MIN_MARKET_CAP_USD, MAX_MARKET_CAP_USD]. With
/// `SUPPLY_SLICE` the arithmetic is v1's, with `cap` for v1's fixed 3,000:
/// `floor(cap x 1e18 x legs / (launchTotal / TOKEN_UNIT))`. With `SUPPLY_TOTAL` each chain
/// reports the whole total, so `floor(cap x 1e18 / (launchTotal / TOKEN_UNIT))`.
function openingUsdPerToken(Leg[] calldata legs, uint32 cap, uint8 supplyMode)
public
pure
returns (uint256 usdPerToken)
{
if (cap < MIN_MARKET_CAP_USD || cap > MAX_MARKET_CAP_USD) revert MarketCapOutOfRange(cap);
uint256 launchTotal;
for (uint256 i = 0; i < legs.length; i++) {
// Every chain the same slice (audit B3 L-1): the cap is measured over "one chain's
// slice", which is only each chain's when they are equal. Unequal slices would open a
// chain below the minimum while the average sat at it.
if (legs[i].slice != legs[0].slice) revert UnequalSlices(legs[i].lzEid);
launchTotal += legs[i].slice;
}
if (launchTotal == 0 || launchTotal % TOKEN_UNIT != 0) revert SupplyNotWholeTokens(launchTotal);
uint256 capWad = uint256(cap) * WAD;
if (supplyMode == SUPPLY_SLICE) {
usdPerToken = (capWad * legs.length) / (launchTotal / TOKEN_UNIT);
} else if (supplyMode == SUPPLY_TOTAL) {
usdPerToken = capWad / (launchTotal / TOKEN_UNIT);
} else {
revert UnknownSupplyMode(supplyMode);
}
if (usdPerToken == 0) revert ZeroPrice();
}
/// @dev Also holds every leg's pool fee to [MIN_FEE_BPS, MAX_FEE_BPS].
///
/// Linear scan. The snapshot holds one entry per launch chain -- five -- so this is
/// cheaper than a mapping and keeps the signed payload a flat array that an off-chain
/// signer and a human auditor can both read.
///
/// Scans to the end rather than stopping at the first match: two entries for this chain
/// would be two prices, and which one applied would depend on their order.
function _quoteForThisChain(Snapshot calldata snap) internal view returns (uint256 usdPerQuote) {
bool found;
for (uint256 i = 0; i < snap.legs.length; i++) {
// Every leg's fee, not only this chain's: the same answer on every chain, so a leg its
// own chain would refuse cannot leave the others launched without it.
uint16 fee = snap.legs[i].feeBps;
if (fee < MIN_FEE_BPS || fee > MAX_FEE_BPS) revert LegFeeOutOfRange(snap.legs[i].lzEid, fee);
if (snap.legs[i].lzEid != localEid) continue;
if (found) revert DuplicateLegForThisChain(localEid);
found = true;
usdPerQuote = snap.legs[i].usdPerQuote;
}
if (!found) revert NoQuoteForThisChain(localEid);
}
/// @dev The whole guard: no oracle, no staleness, no chain where it silently does nothing.
/// It cannot tell a right price from a slightly wrong one, and is not meant to. The native
/// coin is held to this contract's band and has 18 decimals on every chain in the set; a
/// listed asset to its own band and the decimals it was listed with -- and an asset the
/// registry does not list is refused here, before anything is deployed.
function _checkPlausible(uint256 usdPerQuote, address quote) internal view returns (uint8 decimals) {
uint256 lo = minUsdPerQuote;
uint256 hi = maxUsdPerQuote;
decimals = 18;
if (quote != address(0)) {
if (registry == address(0)) revert NoRegistry(quote);
(decimals, lo, hi) = IPairTerms(registry).terms(quote);
}
if (usdPerQuote < lo || usdPerQuote > hi) revert QuotePriceImplausible(usdPerQuote, lo, hi);
}
// ------------------------------------------------- what Solana's launch can carry
/// @notice Whether a launch with a Solana leg is one the Solana program can be sent: its
/// metadata URI is one the program writes back out (`isIpfsHashUri`), its fee minimum
/// and its Solana slice fit the v2 wire's amounts (`fitsWireAmount`), the slice times
/// the legs fits a u64, there is one Solana leg only, and every leg's
/// `usdPerQuote` fits the wire's price (`fitsWirePrice`). Pure, so every chain gives
/// the same answer (LaunchFactoryBaseV2 `BadTerms(8)`).
/// @dev The Solana leg does not carry these values in full: the URI travels as a form and a
/// sha-256 digest (launch_leg.rs `ipfs_uri`), amounts as `m x 10^e` with a u32 `m`
/// (price.rs `encode_amount`) and prices as a 27-bit `m` and a 5-bit `e` (price.rs
/// `encode_usd_per_quote`). A launch whose values do not fit could land on every EVM chain
/// while its Solana leg never can.
function solanaCanCarry(string calldata metadataURI, uint256 feeMin, Leg[] calldata legs)
external
pure
returns (bool)
{
if (!isIpfsHashUri(metadataURI) || !fitsWireAmount(feeMin)) return false;
bool testnet;
uint256 solanaLegs;
for (uint256 i = 0; i < legs.length; i++) {
if (legs[i].lzEid == 40168) testnet = true;
if (legs[i].lzEid == 30168 || legs[i].lzEid == 40168) solanaLegs++;
}
// One Solana leg (audit round 7, I): the program is one chain's -- a second Solana leg, or
// mainnet beside testnet, is a peer it cannot name and a slice it cannot be.
if (solanaLegs > 1) return false;
for (uint256 i = 0; i < legs.length; i++) {
if (!fitsWirePrice(legs[i].usdPerQuote)) return false;
uint32 eid = legs[i].lzEid;
if (eid == 30168 || eid == 40168) {
// And the total the program computes from it, its slice times its chains, checked
// as a u64 (launch_leg.rs `launch_total`).
if (!fitsWireAmount(legs[i].slice) || legs[i].slice * legs.length > type(uint64).max) return false;
} else if (!isSolanaPeerChain(eid, testnet)) {
return false;
}
}
return true;
}
/// @notice Whether the Solana program can name `eid` as a peer: one of its `PEER_CHAINS`
/// (launch_leg.rs) -- mainnet Ethereum, BNB Chain, Base, Robinhood Chain; on devnet BNB
/// Chain testnet, Sepolia, Base Sepolia. Any other EVM leg beside a Solana leg could
/// land on every EVM chain while the Solana leg never can (audit round 6, I-4).
function isSolanaPeerChain(uint32 eid, bool testnet) public pure returns (bool) {
if (testnet) return eid == 40102 || eid == 40161 || eid == 40245;
return eid == 30101 || eid == 30102 || eid == 30184 || eid == 30416;
}
/// @notice A u64 written in at most nine significant digits: `m x 10^e`, `m` a u32.
function fitsWireAmount(uint256 v) public pure returns (bool) {
return v <= type(uint64).max && _mantissaFits(v, type(uint32).max, 255);
}
/// @notice A price the Solana wire carries: `m x 10^e`, `m` below 2^27, `e` at most 31, and
/// the value a u128 (what the program decodes it into).
function fitsWirePrice(uint256 v) public pure returns (bool) {
return v <= type(uint128).max && _mantissaFits(v, (1 << 27) - 1, 31);
}
function _mantissaFits(uint256 v, uint256 max, uint256 maxE) internal pure returns (bool) {
uint256 e;
while (v > max) {
if (v % 10 != 0) return false;
v /= 10;
e++;
}
return e <= maxE;
}
/// @notice Whether `uri` is exactly what the Solana program writes for a metadata hash:
/// `ipfs://` and a sha-256 content identifier in its canonical spelling -- a CIDv0
/// (`Qm...`, base58 of 0x1220 and the digest) or a CIDv1 raw or dag-pb (`bafkrei...`,
/// `bafybei...`: `b` and lower-case unpadded base32 of 0x01, the codec, 0x1220 and the
/// digest). The same rule as web/lib/launch/ipfs-uri.mjs `ipfsHashUriProblem`
/// (vector: test/fixtures/solana-wire-vector.json).
/// @dev Exact, not a pattern: a CIDv0 is decoded and must be 34 bytes starting 0x1220 (46
/// base58 digits with no leading `1` re-encode to themselves exactly when they do); a
/// CIDv1 is 58 base32 digits after `b`, whose first 32 bits are the fixed header -- the
/// first six digits, and the top two bits of the seventh -- and whose last digit's two
/// padding bits are zero, which is when it re-encodes to itself.
function isIpfsHashUri(string calldata uri) public pure returns (bool) {
bytes calldata b = bytes(uri);
if (b.length < 7 || bytes7(b[:7]) != "ipfs://") return false;
if (b.length == 53) {
// 46 base58 digits, in two 128-bit limbs: value = hi x 2^128 + lo.
uint256 hi;
uint256 lo;
for (uint256 i = 7; i < 53; i++) {
uint256 d = _base58Digit(uint8(b[i]));
if (d >= 58) return false;
lo = lo * 58 + d;
hi = hi * 58 + (lo >> 128);
lo &= type(uint128).max;
}
return hi >> 128 == 0x1220;
}
if (b.length != 66) return false;
bytes7 head = bytes7(b[7:14]);
if (head != "bafkrei" && head != "bafybei") return false;
for (uint256 i = 14; i < 66; i++) {
uint256 d = _base32Digit(uint8(b[i]));
if (d >= 32 || (i == 14 && d >= 8) || (i == 65 && d & 3 != 0)) return false;
}
return true;
}
/// @dev Bitcoin's base58 alphabet: no 0, O, I or l. 58 for anything else.
function _base58Digit(uint8 c) internal pure returns (uint256) {
if (c >= 0x31 && c <= 0x39) return c - 0x31; // 1-9
if (c >= 0x41 && c <= 0x48) return c - 0x41 + 9; // A-H
if (c >= 0x4a && c <= 0x4e) return c - 0x4a + 17; // J-N
if (c >= 0x50 && c <= 0x5a) return c - 0x50 + 22; // P-Z
if (c >= 0x61 && c <= 0x6b) return c - 0x61 + 33; // a-k
if (c >= 0x6d && c <= 0x7a) return c - 0x6d + 44; // m-z
return 58;
}
/// @dev RFC 4648 base32, lower case: a-z then 2-7. 32 for anything else.
function _base32Digit(uint8 c) internal pure returns (uint256) {
if (c >= 0x61 && c <= 0x7a) return c - 0x61;
if (c >= 0x32 && c <= 0x37) return c - 0x32 + 26;
return 32;
}
// ------------------------------------------------------------- hashing
function hash(Snapshot calldata snap) public pure returns (bytes32) {
bytes32[] memory legHashes = new bytes32[](snap.legs.length);
for (uint256 i = 0; i < snap.legs.length; i++) {
Leg calldata leg = snap.legs[i];
legHashes[i] = keccak256(abi.encode(LEG_TYPEHASH, leg.lzEid, leg.usdPerQuote, leg.token, leg.slice, leg.feeBps));
}
bytes32 structHash = keccak256(
abi.encode(
SNAPSHOT_TYPEHASH,
snap.launchId,
snap.marketCapUsd,
snap.supplyMode,
snap.terms,
snap.usdPerToken,
snap.deadline,
keccak256(abi.encodePacked(legHashes))
)
);
return keccak256(abi.encodePacked("\x19\x01", DOMAIN_SEPARATOR, structHash));
}
function _recover(Snapshot calldata snap, bytes calldata signature) internal pure returns (address) {
return _recoverDigest(hash(snap), signature);
}
/// @dev One recovery rule for every signature this system checks. A fixed 65-byte layout and
/// the upper half of the curve order rejected: every signature has a second valid form
/// with a flipped `s`, and accepting both would let one attestation or one authorisation
/// be presented two ways.
function _recoverDigest(bytes32 digest, bytes calldata signature) internal pure returns (address) {
if (signature.length != 65) revert BadSignature();
bytes32 r;
bytes32 s;
uint8 v;
assembly {
r := calldataload(signature.offset)
s := calldataload(add(signature.offset, 32))
v := byte(0, calldataload(add(signature.offset, 64)))
}
if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
revert BadSignature();
}
address recovered = ecrecover(digest, v, r, s);
if (recovered == address(0)) revert BadSignature();
return recovered;
}
/* ------------------------------------------------ a creator's launch authorisation
Verified here rather than in the factory, for two reasons.
The factory had no room. UniswapLaunchFactory runs at 24,216 bytes against the 24,576 limit
-- 360 to spare -- and the deleted PancakeLaunchFactory came to within 20 bytes of it with
a second copy of this recovery inside, one more line of anything from not deploying at all.
This contract is about 5,600 bytes. (Infinity was removed as a venue on 2026-10-11, so the
tighter of the two factories is gone; the margin it demonstrated is why this lives here and
the reason below is why it stays here. Figures from 2026-10-13: re-measure with
`forge build --sizes`.)
And it is the right home regardless: this is the contract that owns EIP-712 and the
malleability rule for this system, and a second implementation of either, in another
contract, is two things that can drift apart. The factory asks; it does not re-derive.
This domain is separate from the price domain, so a price attestation can never be replayed
as a launch authorisation or the reverse, and it omits chainId and verifyingContract for the
same reason the price domain does: one signature has to work on all four chains, or a
creator signs four times for one launch. */
bytes32 public constant LAUNCH_AUTH_DOMAIN_SEPARATOR = keccak256(
abi.encode(DOMAIN_TYPEHASH, keccak256("PangeaLaunchAuth"), keccak256("2"))
);
bytes32 public constant LAUNCH_AUTH_TYPEHASH =
keccak256("LaunchAuth(bytes32 launchId,address launcher)");
/// @notice The digest a creator signs to let `launcher` launch `launchId` on their behalf.
/// @dev Public so a wallet, a frontend, a test and the factory all take it from one place
/// instead of reimplementing EIP-712 four times and disagreeing about one field.
function launchAuthHash(bytes32 launchId, address launcher) public pure returns (bytes32) {
return keccak256(
abi.encodePacked(
"\x19\x01",
LAUNCH_AUTH_DOMAIN_SEPARATOR,
keccak256(abi.encode(LAUNCH_AUTH_TYPEHASH, launchId, launcher))
)
);
}
/// @notice Who authorised `launcher` to launch `launchId`.
/// @dev Returns the recovered address rather than a boolean, and compares nothing: the factory
/// knows which creator it is expecting and this contract does not. Reverts `BadSignature`
/// on anything that is not a canonical 65-byte signature.
function recoverLaunchAuth(bytes32 launchId, address launcher, bytes calldata signature)
external
pure
returns (address)
{
return _recoverDigest(launchAuthHash(launchId, launcher), signature);
}
// -------------------------------------------------------------- admin
/// @dev Two-step. Signing keys rotate, and a mistyped signer would reject every launch on
/// this chain until it was corrected. Gated on `signerAdmin`, not `admin` -- see there.
function proposeSigner(address to) external {
if (msg.sender != signerAdmin) revert NotSignerAdmin();
if (to == address(0)) revert ZeroAddress();
pendingSigner = to;
emit SignerProposed(signer, to);
}
function acceptSigner() external {
if (msg.sender != pendingSigner) revert NotPending();
emit SignerChanged(signer, msg.sender);
signer = msg.sender;
pendingSigner = address(0);
}
/// @dev Two-step, like the signer. Without a handover the key named at deployment holds the
/// role forever, so it could never be moved to a multisig.
function proposeSignerAdmin(address to) external {
if (msg.sender != signerAdmin) revert NotSignerAdmin();
if (to == address(0)) revert ZeroAddress();
pendingSignerAdmin = to;
emit SignerAdminProposed(signerAdmin, to);
}
function acceptSignerAdmin() external {
if (msg.sender != pendingSignerAdmin) revert NotPending();
if (msg.sender == admin) revert RolesMustDiffer();
emit SignerAdminChanged(signerAdmin, msg.sender);
signerAdmin = msg.sender;
pendingSignerAdmin = address(0);
}
/// @dev Two-step. This role no longer decides who the signer is; see `admin`.
function proposeAdmin(address to) external {
if (msg.sender != admin) revert NotAdmin();
if (to == address(0)) revert ZeroAddress();
pendingAdmin = to;
emit AdminProposed(admin, to);
}
function acceptAdmin() external {
if (msg.sender != pendingAdmin) revert NotPending();
if (msg.sender == signerAdmin) revert RolesMustDiffer();
emit AdminChanged(admin, msg.sender);
admin = msg.sender;
pendingAdmin = address(0);
}
}
src/venues/OpeningDust.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.30;
// The quote dust an in-range opening owes, and the quotes it can be owed in
//
// A pool whose token is currency1 -- every native-quoted one, and any asset that sorts below the
// token -- opens one unit of square-root price under the top of its range, so its liquidity is
// active from the first block (LiquidityLocker). The position then owes the pool the quote for the
// sliver between that price and the range's top:
//
// dust = ceil(L * 2^96 / (sqrtP * sqrtU)), sqrtU - sqrtP = 1, L ~ slice * 2^96 / sqrtP
// ~ slice / (p^1.5 * 2^96)
//
// where p is token base units per quote base unit. Every launch opens at a $3,000 market cap over
// its launch total T (base units), so p = u * T / 3000 with u the quote's USD per BASE unit, and
// with a slice of at most T:
//
// dust <= 3000^1.5 / (u^1.5 * T^0.5 * 2^96)
//
// It grows as the quote gets cheaper per base unit, and it is worth nothing in dollars anywhere:
// dust * u ~ 7.6e-27 / sqrt(p) USD.
//
// THE TWO NUMBERS. A quote may only be listed (PairRegistry) or attested as the native coin
// (PriceAttestor) with a price band whose floor is at least 1e-30 USD per base unit
// (`quoteBandFloorFits`), which is an 18-decimal asset at $1e-12 a whole unit -- below every
// real asset. At that floor, with the smallest launch the attestor accepts (one whole token,
// T = 1e9, all of it in one slice), the formula gives 6.6e16 base units; the default launch
// (a 200M slice of 1B) owes 4.2e11 there and exactly 1 for any quote worth more than ~$5.6e-5 a
// whole 18-decimal unit. So `MAX_OPENING_DUST` = 1e17 is enough for every launch the contracts
// accept against every quote they accept, and test/InRangeOpening.t.sol holds the two to each
// other.
//
// WHAT THE CAP IS FOR. The factory pays the exact dust from its float and nothing more -- the
// locker pulls what the pool says the position owes -- so the cap is not what the float loses per
// launch. It is the sanity bound on that pull: a position on the wrong side of its price owes the
// slice's worth of quote, not dust, and is refused (LiquidityLocker.QuoteSideTooLarge) whenever
// that is more than the cap. Below the cap the float's own balance is the bound.
// The most quote, in its base units, an opening may owe and the factory may pay for it.
uint256 constant MAX_OPENING_DUST = 1e17;
// Base units of a quote that 1e18-scaled USD 1 (that is, $1e-18) may buy at the most: 1e12, which
// is 1e-30 USD a base unit. See `quoteBandFloorFits`.
uint256 constant MAX_QUOTE_BASE_UNITS_PER_WAD_USD = 1e12;
/// @notice Whether a band whose floor is `minUsdPerQuote` (USD per whole unit, 1e18-scaled) for a
/// quote of `decimals` keeps every opening's dust within `MAX_OPENING_DUST`: at least
/// 1e-30 USD a base unit.
/// @dev minUsdPerQuote >= 10^decimals / 1e12, the division exact (both powers of ten) and nothing
/// multiplied, so no band can overflow it. For 18 decimals the floor is 1e6 ($1e-12 a whole
/// unit); for 12 decimals or fewer it is 1, the least a band can be.
function quoteBandFloorFits(uint256 minUsdPerQuote, uint8 decimals) pure returns (bool) {
uint256 unit = 10 ** uint256(decimals);
uint256 floor = unit <= MAX_QUOTE_BASE_UNITS_PER_WAD_USD ? 1 : unit / MAX_QUOTE_BASE_UNITS_PER_WAD_USD;
return minUsdPerQuote >= floor;
}
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.