Verified contractPartialMIT
PeddlesLaunchOrchestratorV20
Address0x07bac67c56d81eafb495c05ed43eb9ef48aa1978
- Balance
0 ETH
- Transactions
4
- Compiler
solc 0.8.26
- Same code
Only this contract
Details
- Compiler
- solc 0.8.26+commit.8a97fa7a
- Language
- solidity
- Optimization
- Yes, 200 runs
- EVM version
- cancun
- Via IR
- yes
- License
- MIT
- Match
- Partialcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 26,374,003
- Creation transaction
- 0xa12049e829…8b8aa2639b
- Libraries
- src/perp/library/PeddlesPerpLib.sol:PeddlesPerpLib0x8fc3…3b25fasrc/perp/library/PeddlesPerpLong.sol:PeddlesPerpLong0x0a0b…a9d941src/perp/library/PeddlesPerpExits.sol:PeddlesPerpExits0xe460…81db47src/perp/library/PeddlesPerpShort.sol:PeddlesPerpShort0x6599…064634src/perp/library/PeddlesPerpReserve.sol:PeddlesPerpReserve0x24ed…a10ac2
src/PeddlesV20.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;
/*
_______ _______ ______ ______ _ _______
( ____ )( ____ \( __ \ ( __ \ ( \ ( ____ \( ____ \
| ( )|| ( \/| ( \ )| ( \ )| ( | ( \/| ( \/
| (____)|| (__ | | ) || | ) || | | (__ | (_____
| _____)| __) | | | || | | || | | __) (_____ )
| ( | ( | | ) || | ) || | | ( ) |
| ) | (____/\| (__/ )| (__/ )| (____/\| (____/\/\____) |
|/ (_______/(______/ (______/ (_______/(_______/\_______)
THE STOCK-PAIRED LAUNCHPAD
Launch tokens and NFTs paired against tokenised stocks.
100% of supply goes to liquidity, locked from block zero.
Holders earn the stock you are paired to.
Website https://peddles.xyz
X https://x.com/PeddlesX
Telegram https://t.me/peddlesnews
*/
library PeddlesMerkleProof {
function verify(bytes32[] calldata proof, bytes32 root, bytes32 leaf) internal pure returns (bool) {
return processProof(proof, leaf) == root;
}
function processProof(bytes32[] calldata proof, bytes32 leaf) internal pure returns (bytes32 computedHash) {
computedHash = leaf;
for (uint256 i; i < proof.length; i++) {
bytes32 proofElement = proof[i];
if (computedHash <= proofElement) {
computedHash = keccak256(abi.encodePacked(computedHash, proofElement));
} else {
computedHash = keccak256(abi.encodePacked(proofElement, computedHash));
}
}
}
}
interface IERC20Minimal {
function transfer(address to, uint256 amount) external returns (bool);
function balanceOf(address account) external view returns (uint256);
}
contract PeddlesOwnable {
address public owner;
address public pendingOwner;
event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
modifier onlyOwner() { require(msg.sender == owner, "NOT_OWNER"); _; }
constructor(address initialOwner) {
require(initialOwner != address(0), "ZERO_OWNER");
owner = initialOwner;
emit OwnershipTransferred(address(0), initialOwner);
}
function transferOwnership(address nextOwner) external onlyOwner {
require(nextOwner != address(0), "ZERO_OWNER");
pendingOwner = nextOwner;
emit OwnershipTransferStarted(owner, nextOwner);
}
function acceptOwnership() external {
require(msg.sender == pendingOwner, "NOT_PENDING_OWNER");
address old = owner;
owner = msg.sender;
pendingOwner = address(0);
emit OwnershipTransferred(old, msg.sender);
}
// ---- No stuck funds ---------------------------------------------------------
//
// NOTHING that inherits this base custodies value. A launch mints every allocation
// straight into the vaults and never to itself, `launchAndBuy`'s dev buy delivers its
// tokens to the buyer, and the vault factory only deploys contracts. So a balance sitting
// on one of these contracts is never someone's — there is no claimant to have a claim.
//
// It can still arrive, three ways. `launch`, `launchAndBuy` and `graduate` are `payable`,
// so a caller can attach more value than the legs spend, and the liquidity executor may
// hand wei back if it does not consume the whole activation value. `SELFDESTRUCT` and a
// block fee payout force native currency onto any address. And anyone can push an ERC-20
// to any address. Before this existed every one of those balances was stranded for good.
//
// OWNER-GATED, unlike the permissionless sweeps on the vaults below. These contracts
// already have a live owner (the allocation defaults, the swap router), and a delay here
// cannot cost a claimant anything, because there is no claimant. It is safe to move the
// ERC-20 leg too — which the vaults' sweep refuses — precisely because these contracts
// hold no launch supply, no vested balance and no airdrop allocation at any point.
event ETHRescued(address indexed to, uint256 amount);
event TokenRescued(address indexed asset, address indexed to, uint256 amount);
function rescueETH(address to) external onlyOwner returns (uint256 amount) {
require(to != address(0), "ZERO_TO");
amount = address(this).balance;
if (amount == 0) return 0;
(bool ok,) = payable(to).call{value: amount}("");
require(ok, "ETH_RESCUE_FAILED");
emit ETHRescued(to, amount);
}
/// @dev Tolerates the non-standard ERC-20s that return nothing from `transfer`.
function rescueToken(address asset, address to) external onlyOwner returns (uint256 amount) {
require(asset != address(0) && to != address(0), "ZERO_TO");
amount = IERC20Minimal(asset).balanceOf(address(this));
if (amount == 0) return 0;
(bool ok, bytes memory ret) = asset.call(abi.encodeCall(IERC20Minimal.transfer, (to, amount)));
require(ok && (ret.length == 0 || abi.decode(ret, (bool))), "TOKEN_RESCUE_FAILED");
emit TokenRescued(asset, to, amount);
}
}
interface IPeddlesVaultRegistryV20 {
struct VaultSet {
address liquidityVault;
address airdropVault;
address vestingVault;
address burnVault;
}
struct AllocationPlan {
uint16 liquidityBps;
uint16 airdropBps;
uint16 vestingBps;
uint16 burnBps;
uint16 vaultBps;
bool airdropEnabled;
bool treasuryEnabled;
uint16 clogBps;
}
function registerToken(address token, address creator) external;
function setVaults(address token, VaultSet calldata vaults) external;
function getVaults(address token) external view returns (VaultSet memory);
function setAllocation(address token, AllocationPlan calldata plan) external;
function setAirdropSchedule(address token, uint64 startsAt, uint32 epochLength, uint16 epochCount, bool active) external;
function setBurnSchedule(
address token, uint64 launchTime, uint32 epochLength, uint16 firstBurnBps,
uint16 minVoteBps, uint16 maxVoteBps, uint16 scheduledBurnBps, bool active
) external;
function reserveSingleSidedLiquidity(
address token, address quoteToken, address poolManager, address positionManager,
address hook, uint24 fee, int24 tickSpacing
) external;
function isPeddles(address token) external view returns (bool);
function liquidityOf(address token) external view returns (
bool active, address quoteToken, address poolManager, address positionManager,
address hook, bytes32 poolId, uint256 positionId, uint24 fee,
int24 tickSpacing, uint64 activatedAt
);
}
interface IPeddlesFactoryV20 {
function createPeddles(uint8 variant, bytes32 salt, bytes calldata params, bytes[] calldata initCalls)
external
payable
returns (address token);
function getPeddlesAddress(uint8 variant, address sender, bytes32 salt) external view returns (address token);
function isVariantSupported(uint8 variant) external view returns (bool);
/// @dev Declared as a flat tuple rather than the factory's `VariantAllocation` struct.
/// Every field is fixed-size, so the struct encodes as seven consecutive words and
/// decodes identically to seven return values — and this file deliberately imports
/// nothing, talking to the factory only through this interface.
function variantAllocation(uint8 variant)
external
view
returns (
uint16 liquidityBps,
uint16 airdropBps,
uint16 vestingBps,
uint16 burnBps,
uint16 clogBps,
uint16 clogSliceBps,
uint64 clogMinInterval
);
}
/// @notice The clog vault factory, as the orchestrator needs it.
interface IPeddlesClogVaultFactoryV20 {
function predict(
address caller,
address token,
address router,
address creator,
uint256 sliceCap,
uint64 minInterval
) external view returns (address);
function create(
address token,
address router,
address creator,
uint256 sliceCap,
uint64 minInterval
) external returns (address vault);
}
interface IPeddlesTokenV20 {
function mint(address to, uint256 amount) external;
function burn(uint256 amount) external;
function totalSupply() external view returns (uint256);
function renounceRole(bytes32 role, address account) external;
function renounceLastAdmin() external;
function setHolderRewards(address rewards) external;
function grantRole(bytes32 role, address account) external;
}
/// @dev Byte-identical layout to v4-core's `PoolKey` and to `PeddlesFeeHook`'s hand-rolled copy.
struct PeddlesPoolKeyV20 {
address currency0;
address currency1;
uint24 fee;
int24 tickSpacing;
address hooks;
}
/// @notice The one call a WETH launch makes into `PeddlesFeeHook`: register the pool with its
/// launch terms. The hook deploys the pool's holder-rewards distributor and returns it.
interface IPeddlesFeeHookV20 {
function registerPool(
PeddlesPoolKeyV20 calldata key,
address token,
address quote,
address creator,
uint16 creatorTaxBps,
uint16 excessToCreatorBps,
address[] calldata excluded
) external returns (address rewards);
/// @dev `onlyPoolCreator`. Used by the NFT graduation orchestrator, which registers a
/// holder-committed pool with ITSELF as creator so it can bind the payout to the collection's
/// fee distributor in the launch transaction — and has no other call site, so it never moves.
function setCreatorPayout(bytes32 poolId, address payout) external;
function poolConfig(bytes32 poolId) external view returns (PeddlesFeeHookPoolConfigV20 memory);
}
/// @dev Byte-identical layout to `PeddlesFeeHook.PoolConfig`.
struct PeddlesFeeHookPoolConfigV20 {
address quote;
uint16 creatorTaxBps;
uint16 excessToCreatorBps;
bool registered;
address token;
uint32 startBlock;
uint32 sniperWindow;
address creator;
address creatorPayout;
address rewards;
}
/// @notice The canonical-distributor proof (`PeddlesNftFeeDistributorFactory`).
interface IPeddlesNftFeeDistributorFactoryV20 {
function isDistributor(address distributor) external view returns (bool);
}
/// @notice The two calls a graduation makes into a collection's `PeddlesNftFeeDistributor`.
interface IPeddlesNftFeeDistributorV20 {
function collection() external view returns (address);
function initAssets(address quote, address token, address tokenHolderRewards, uint16 holderShareBps) external;
}
interface IPeddlesLiquidityExecutorV20 {
function poolManager() external view returns (address);
function positionManager() external view returns (address);
function quoteToken() external view returns (address);
function hook() external view returns (address);
function fee() external view returns (uint24);
function tickSpacing() external view returns (int24);
function poolKeyFor(address token) external view returns (PeddlesPoolKeyV20 memory key);
function activateSingleSidedLiquidity(
address token,
uint256 amountPeddles,
uint160 sqrtPriceX96,
int24 tickLower,
int24 tickUpper,
uint256 liquidity
) external payable returns (bytes32 poolId, uint256 positionId);
}
/// @dev The dev-buy leg of `launchAndBuy`. Deliberately the PUBLIC `buy` of
/// `PeddlesV4SwapRouter` and nothing else: the creator's first buy goes through the exact same
/// swap path, and pays the exact same pool tax, as any other trader's. Unlike the stock
/// path there is no `approve` step — this pool's quote leg is native ETH, so the value simply
/// travels with the call.
interface IPeddlesV4RouterBuyV20 {
function buy(address token, uint256 minOut, address to) external payable returns (uint256 out);
}
interface IPeddlesNFTBondingCollectionV20 {
function owner() external view returns (address);
function graduationReady() external view returns (bool);
function graduated() external view returns (bool);
function recordPeddlesGraduation(
address token,
address liquidityVault,
address vestingVault,
address airdropVault,
address burnVault
) external;
}
/// @notice The no-stuck-funds exit shared by the four V20 vaults.
///
/// A vault has NO OWNER on purpose: the creator must not be able to reach the supply it holds,
/// and neither must the platform. So this exit is permissionless — and it is only safe to be
/// permissionless because of what it refuses to move.
///
/// `token` is the launch supply this vault custodies and owes to a claimant: the liquidity
/// executor, an airdrop claimant, the vesting beneficiary, the burn schedule. It is NOT
/// sweepable. Every wei and every OTHER ERC-20 sitting here arrived by mistake and is owed to
/// nobody, so who receives it is not a question anyone has standing in; a caller-chosen
/// recipient is not a withdrawal primitive when there is no withdrawal to point it at.
///
/// Value reaches a vault two ways no contract can refuse: `SELFDESTRUCT` and a block fee payout
/// force native currency onto any address, and anyone can push an ERC-20 anywhere. No vault has
/// a `receive`, a `fallback` or a `payable` function, so its correct native balance is always
/// zero — and until this existed, a forced balance stayed there forever.
///
/// `_sweepableToken` is how a subclass states how much of the CUSTODIED token is provably no
/// longer owed to anyone. It is 0 here, so by default the launch supply cannot be touched at all.
abstract contract PeddlesVaultSalvageV20 {
IERC20Minimal public immutable token;
event StraySwept(address indexed asset, address indexed to, uint256 amount);
constructor(address token_) {
require(token_ != address(0), "ZERO_TOKEN");
token = IERC20Minimal(token_);
}
/// @dev How much of the custodied token is owed to no one. Zero unless a subclass can prove
/// otherwise from its own state.
function _sweepableToken() internal view virtual returns (uint256) {
return 0;
}
/// @notice Move a stray balance out. `asset == address(0)` sweeps native currency.
///
/// @dev ONE function rather than a native one and an ERC-20 one, and no companion view:
/// `PeddlesVaultFactoryV20` carries the creation code of all four vaults and has a few
/// hundred bytes of EIP-170 headroom left, so every extra selector here is spent four times
/// over there. The ERC-20 leg tolerates the non-standard tokens that return nothing from
/// `transfer`, because a stray is exactly where one of those turns up.
function sweepStray(address asset, address to) external returns (uint256 amount) {
require(to != address(0), "ZERO_ADDRESS");
if (asset == address(0)) {
amount = address(this).balance;
if (amount == 0) return 0;
(bool okNative,) = payable(to).call{value: amount}("");
require(okNative, "SWEEP_FAILED");
} else {
amount = asset == address(token) ? _sweepableToken() : IERC20Minimal(asset).balanceOf(address(this));
if (amount == 0) return 0;
(bool ok, bytes memory ret) = asset.call(abi.encodeCall(IERC20Minimal.transfer, (to, amount)));
require(ok && (ret.length == 0 || abi.decode(ret, (bool))), "SWEEP_FAILED");
}
emit StraySwept(asset, to, amount);
}
}
/// @notice V20 liquidity vault. The creator is deliberately not an owner.
/// Only the configured liquidity executor can pull the allocation, one time,
/// and it must pull it to itself for position creation.
contract PeddlesLiquidityVaultV20 is PeddlesVaultSalvageV20 {
address public immutable liquidityManager;
bool public activated;
event LiquidityPulled(address indexed manager, uint256 amount);
constructor(address token_, address liquidityManager_) PeddlesVaultSalvageV20(token_) {
require(liquidityManager_ != address(0), "ZERO_MANAGER");
liquidityManager = liquidityManager_;
}
/// @dev Before activation the entire balance IS the launch allocation, and `pullForLiquidity`
/// is required to pull all of it — so nothing here is stray and nothing is sweepable. Once
/// `activated` is set that pull can never run again, so anything remaining or arriving after
/// it, launch token included, has no path out and no claimant.
function _sweepableToken() internal view override returns (uint256) {
return activated ? token.balanceOf(address(this)) : 0;
}
function pullForLiquidity(address to, uint256 amount) external {
require(msg.sender == liquidityManager, "NOT_MANAGER");
require(to == liquidityManager, "BAD_RECEIVER");
require(!activated, "ALREADY_ACTIVATED");
require(amount > 0 && amount == token.balanceOf(address(this)), "MUST_PULL_FULL_BALANCE");
activated = true;
require(token.transfer(to, amount), "TRANSFER_FAILED");
emit LiquidityPulled(msg.sender, amount);
}
}
/// @notice V20 airdrop vault. Epoch publication belongs to the platform publisher,
/// never to the token creator. Claims are cumulative.
contract PeddlesAirdropVaultV20 is PeddlesVaultSalvageV20 {
using PeddlesMerkleProof for bytes32[];
address public immutable claimsPublisher;
uint64 public immutable claimsStart;
uint32 public immutable epochLength;
uint16 public immutable epochCount;
bytes32 public claimRoot;
string public claimsURI;
bool public claimsOpen;
uint8 public currentEpoch;
mapping(uint8 => bytes32) public epochRoots;
mapping(uint8 => string) public epochURIs;
mapping(address => uint256) private _claimed;
event ClaimEpochRootUpdated(uint8 indexed epoch, bytes32 indexed root, string claimsURI);
event ClaimsOpenUpdated(bool open);
event Claimed(uint256 indexed index, address indexed account, uint256 amount);
constructor(address token_, address publisher_, uint64 start_, uint32 epochLength_, uint16 epochCount_)
PeddlesVaultSalvageV20(token_)
{
require(publisher_ != address(0), "ZERO_PUBLISHER");
require(epochLength_ > 0 && epochCount_ > 0, "BAD_SCHEDULE");
claimsPublisher = publisher_;
claimsStart = start_;
epochLength = epochLength_;
epochCount = epochCount_;
}
modifier onlyPublisher() {
require(msg.sender == claimsPublisher, "NOT_PUBLISHER");
_;
}
function setEpochClaimRoot(uint8 epoch, bytes32 root, string calldata uri) external onlyPublisher {
require(epoch > 0 && epoch <= epochCount, "BAD_EPOCH");
require(epoch <= currentClaimEpoch(), "EPOCH_NOT_READY");
require(epoch == currentEpoch + 1, "EPOCH_NOT_SEQUENTIAL");
require(root != bytes32(0), "ZERO_ROOT");
epochRoots[epoch] = root;
epochURIs[epoch] = uri;
if (epoch >= currentEpoch) {
currentEpoch = epoch;
claimRoot = root;
claimsURI = uri;
}
claimsOpen = true;
emit ClaimEpochRootUpdated(epoch, root, uri);
emit ClaimsOpenUpdated(true);
}
function setClaimsOpen(bool open) external onlyPublisher {
claimsOpen = open;
emit ClaimsOpenUpdated(open);
}
function currentClaimEpoch() public view returns (uint8) {
if (block.timestamp < claimsStart) return 0;
uint256 epoch = ((block.timestamp - claimsStart) / epochLength) + 1;
if (epoch > epochCount) epoch = epochCount;
return uint8(epoch);
}
function merkleRoot() external view returns (bytes32) {
return claimRoot;
}
function claimed(address account) external view returns (uint256) {
return _claimed[account];
}
function claimable(address account, uint256 cumulativeAmount) external view returns (uint256) {
if (!claimsOpen || block.timestamp < claimsStart || _claimed[account] >= cumulativeAmount) return 0;
return cumulativeAmount - _claimed[account];
}
function claimIndexed(uint256 index, address account, uint256 cumulativeAmount, bytes32[] calldata proof) external {
require(account == msg.sender, "NOT_ACCOUNT");
_claim(index, account, cumulativeAmount, keccak256(abi.encodePacked(index, account, cumulativeAmount)), proof);
}
function claim(address account, uint256 cumulativeAmount, bytes32[] calldata proof) external {
require(account == msg.sender, "NOT_ACCOUNT");
_claim(type(uint256).max, account, cumulativeAmount, keccak256(abi.encodePacked(account, cumulativeAmount)), proof);
}
function _claim(
uint256 index,
address account,
uint256 cumulativeAmount,
bytes32 leaf,
bytes32[] calldata proof
) internal {
require(claimsOpen, "CLAIMS_CLOSED");
require(block.timestamp >= claimsStart, "CLAIMS_NOT_STARTED");
require(claimRoot != bytes32(0), "ROOT_NOT_SET");
require(_claimed[account] < cumulativeAmount, "ALREADY_CLAIMED");
require(proof.verify(claimRoot, leaf), "INVALID_CLAIM");
uint256 payout = cumulativeAmount - _claimed[account];
_claimed[account] = cumulativeAmount;
require(token.transfer(account, payout), "TRANSFER_FAILED");
emit Claimed(index, account, payout);
}
}
/// @notice V20 burn vault. Schedule is immutable after deployment and anyone can execute it.
contract PeddlesBurnVaultV20 is PeddlesVaultSalvageV20 {
uint64 public immutable launchTime;
uint32 public immutable epochLength;
uint16 public immutable firstBurnBps;
uint16 public immutable scheduledBurnBps;
uint16 public constant finalEpoch = 10;
uint32 public executedEpochs;
uint256 public initialBurnVault;
uint256 public totalBurned;
event ScheduledBurnExecuted(uint32 indexed epoch, uint256 amount, uint16 appliedBps, uint256 remainingBurnVault);
constructor(
address token_,
uint64 launchTime_,
uint32 epochLength_,
uint16 firstBurnBps_,
uint16 scheduledBurnBps_
) PeddlesVaultSalvageV20(token_) {
require(launchTime_ > 0, "ZERO_LAUNCH_TIME");
require(epochLength_ > 0, "BAD_EPOCH_LENGTH");
require(firstBurnBps_ <= 10_000 && scheduledBurnBps_ <= 10_000, "BAD_BPS");
launchTime = launchTime_;
epochLength = epochLength_;
firstBurnBps = firstBurnBps_;
scheduledBurnBps = scheduledBurnBps_;
}
function startsAt() external view returns (uint64) { return launchTime; }
function minVoteBps() external view returns (uint16) { return scheduledBurnBps; }
function maxVoteBps() external view returns (uint16) { return scheduledBurnBps; }
function defaultVoteBps() external view returns (uint16) { return scheduledBurnBps; }
function remainingBurnVault() public view returns (uint256) { return token.balanceOf(address(this)); }
function dueTimestamp(uint32 epoch) public view returns (uint256) {
if (epoch == 0) return 0;
if (epoch == 1) return uint256(launchTime) + 24 hours;
if (epoch >= finalEpoch) return uint256(launchTime) + 100 days;
return uint256(launchTime) + (uint256(epoch) * uint256(epochLength));
}
function currentBurnEpoch() public view returns (uint32) {
for (uint32 epoch = finalEpoch; epoch >= 1; epoch--) {
if (block.timestamp >= dueTimestamp(epoch)) return epoch;
if (epoch == 1) break;
}
return 0;
}
function nextBurnEpoch() public view returns (uint32) {
return executedEpochs >= finalEpoch ? 0 : executedEpochs + 1;
}
function nextBurnAt() public view returns (uint256) {
return dueTimestamp(nextBurnEpoch());
}
function nextBurnAmount(uint16) public view returns (uint256 amount, uint16 appliedBps) {
uint32 epoch = nextBurnEpoch();
uint256 remaining = remainingBurnVault();
if (epoch == 0 || remaining == 0) return (0, 0);
if (epoch == 1) {
uint256 base = initialBurnVault == 0 ? remaining : initialBurnVault;
appliedBps = firstBurnBps;
amount = (base * appliedBps) / 10_000;
if (amount > remaining) amount = remaining;
} else if (epoch >= finalEpoch) {
appliedBps = 10_000;
amount = remaining;
} else {
appliedBps = scheduledBurnBps;
amount = (remaining * appliedBps) / 10_000;
}
}
function executeScheduledBurn() public returns (uint256 amount) {
uint32 epoch = nextBurnEpoch();
require(epoch > 0, "BURN_COMPLETE");
require(block.timestamp >= dueTimestamp(epoch), "EPOCH_NOT_READY");
if (initialBurnVault == 0) initialBurnVault = remainingBurnVault();
uint16 appliedBps;
(amount, appliedBps) = nextBurnAmount(0);
// A ZERO-AMOUNT EPOCH ADVANCES THE SCHEDULE. It must not revert.
//
// This was `require(amount > 0, "NOTHING_TO_BURN")`, which reverted WITHOUT writing
// `executedEpochs`. Any epoch whose share rounds to nothing — firstBurnBps == 0,
// scheduledBurnBps == 0, or simply `remaining * bps < 10_000` on a small remainder —
// therefore blocked the schedule permanently, and with it the FINAL epoch that sweeps
// the remainder to 100%. The vault's whole exit sat behind an epoch that could never
// be executed.
//
// Skipping it is the correct behaviour and not a weakening: nothing is owed for an
// epoch that burns nothing, the emitted event records the zero so the schedule stays
// auditable, and the next epoch becomes reachable.
executedEpochs = epoch;
if (amount > 0) {
totalBurned += amount;
IPeddlesTokenV20(address(token)).burn(amount);
}
emit ScheduledBurnExecuted(epoch, amount, appliedBps, remainingBurnVault());
}
function releaseForBurn(uint16, address) external returns (uint256 amount) {
return executeScheduledBurn();
}
}
contract PeddlesVestingVaultV20 is PeddlesVaultSalvageV20 {
address public immutable beneficiary;
uint64 public immutable start;
uint64 public immutable cliff;
uint64 public immutable duration;
uint256 public immutable totalAllocation;
uint256 public released;
event Released(address indexed beneficiary, uint256 amount);
constructor(
address token_,
address beneficiary_,
uint64 start_,
uint64 cliff_,
uint64 duration_,
uint256 totalAllocation_
) PeddlesVaultSalvageV20(token_) {
require(beneficiary_ != address(0), "ZERO_BENEFICIARY");
require(duration_ > 0 && cliff_ <= duration_, "BAD_SCHEDULE");
beneficiary = beneficiary_;
start = start_;
cliff = cliff_;
duration = duration_;
totalAllocation = totalAllocation_;
}
function vestedAmount(uint64 timestamp) public view returns (uint256) {
if (timestamp < start + cliff) return 0;
if (timestamp >= start + duration) return totalAllocation;
return (totalAllocation * (timestamp - start)) / duration;
}
function releasable() public view returns (uint256) {
return vestedAmount(uint64(block.timestamp)) - released;
}
function release() external {
uint256 amount = releasable();
require(amount > 0, "NOTHING_TO_RELEASE");
released += amount;
require(token.transfer(beneficiary, amount), "TRANSFER_FAILED");
emit Released(beneficiary, amount);
}
/// @dev `release` pays against an IMMUTABLE `totalAllocation`, never against the balance, so
/// `totalAllocation - released` is the most the beneficiary can ever still take out of here
/// and any balance above that has no exit — an overpayment, or tokens someone pushed in.
/// Returns 0 while the vault is exactly funded or underfunded, which is the normal case.
function _sweepableToken() internal view override returns (uint256) {
uint256 owed = totalAllocation - released;
uint256 balance = token.balanceOf(address(this));
return balance > owed ? balance - owed : 0;
}
}
/// @notice Strict deterministic V20 factory. Registry failures revert the whole launch.
/// @notice Deploys and predicts the four V20 launch vaults.
///
/// NO OWNER (2026-09-16). It used to inherit `PeddlesOwnable`: the owner chose which contracts may
/// create vaults (and could create vaults itself), and held native/ERC-20 rescues to an address of
/// its choosing. None of that was disclosed, and none of it is needed once the deploy is done:
///
/// * operators are the two V20 orchestrators. They take this factory's address in their own
/// constructors, so they cannot be constructor arguments here. Instead the deploy session's key
/// (`wirer`, immutable) sets them and then SEALS the set in the same deploy. After
/// `sealOperators()` nobody can add or remove an operator, and the wirer holds no other power;
/// * `createFourVaults` is operators-only (the owner shortcut is gone);
/// * this factory custodies nothing, so its stray exits are permissionless and pay the
/// immutable `treasury`.
contract PeddlesVaultFactoryV20 {
IPeddlesVaultRegistryV20 public immutable registry;
/// @notice The deploy session's key. It may set operators until `sealOperators()`, and nothing else.
address public immutable wirer;
/// @notice The only address the stray sweeps pay.
address public immutable treasury;
/// @notice True once the operator set is final. One-way.
bool public operatorsSealed;
mapping(address => bool) public operators;
struct CreateVaultsInput {
address token;
address creator;
uint16 liquidityBps;
uint16 airdropBps;
uint16 vestingBps;
uint16 burnBps;
uint16 vaultBps;
/// @dev Share held by this launch TYPE's clog vault. The clog is not one of the four
/// vaults this factory builds, but its share has to travel with the others or
/// every allocation sum downstream is short by exactly the clog.
uint16 clogBps;
bool airdropEnabled;
uint256 liquidityAmount;
uint256 airdropAmount;
uint256 vestingAmount;
uint256 burnAmount;
uint64 vestingStart;
uint64 vestingCliff;
uint64 vestingDuration;
uint64 airdropStartsAt;
uint32 airdropEpochLength;
uint16 airdropEpochCount;
uint64 burnStartsAt;
uint32 burnEpochLength;
uint16 firstBurnBps;
uint16 minVoteBps;
uint16 maxVoteBps;
uint16 defaultVoteBps;
address quoteToken;
address poolManager;
address positionManager;
address hook;
address liquidityManager;
address airdropPublisher;
uint24 fee;
int24 tickSpacing;
}
event OperatorUpdated(address indexed operator, bool allowed);
event OperatorsSealed();
event StraySwept(address indexed asset, address indexed to, uint256 amount);
event VaultSetCreated(
address indexed token,
address indexed creator,
address liquidityVault,
address airdropVault,
address vestingVault,
address burnVault
);
constructor(address wirer_, address registry_, address treasury_) {
require(wirer_ != address(0) && registry_ != address(0) && treasury_ != address(0), "ZERO_ADDR");
wirer = wirer_;
registry = IPeddlesVaultRegistryV20(registry_);
treasury = treasury_;
}
modifier onlyOperator() {
require(operators[msg.sender], "NOT_OPERATOR");
_;
}
/// @notice Deploy-session wiring only: the wirer sets the operator set before sealing it.
function setOperator(address operator, bool allowed) external {
require(msg.sender == wirer && !operatorsSealed, "OPERATORS_SEALED");
require(operator != address(0), "ZERO_OPERATOR");
operators[operator] = allowed;
emit OperatorUpdated(operator, allowed);
}
/// @notice Make the operator set permanent. One-way; the deploy script calls it and asserts it.
function sealOperators() external {
require(msg.sender == wirer, "NOT_WIRER");
operatorsSealed = true;
emit OperatorsSealed();
}
/// @notice Pay force-sent native to `treasury`. Permissionless: this factory owes nothing.
function sweepNative() external returns (uint256 amount) {
amount = address(this).balance;
require(amount != 0, "NOTHING_TO_SWEEP");
(bool ok,) = payable(treasury).call{value: amount}("");
require(ok, "SWEEP_FAILED");
emit StraySwept(address(0), treasury, amount);
}
/// @notice Pay a stray ERC-20's whole balance to `treasury`. Permissionless; tolerates no-return tokens.
function sweepToken(address asset) external returns (uint256 amount) {
amount = IERC20Minimal(asset).balanceOf(address(this));
require(amount != 0, "NOTHING_TO_SWEEP");
(bool ok, bytes memory ret) = asset.call(abi.encodeCall(IERC20Minimal.transfer, (treasury, amount)));
require(ok && (ret.length == 0 || abi.decode(ret, (bool))), "SWEEP_FAILED");
emit StraySwept(asset, treasury, amount);
}
function _salt(address token, bytes1 kind) internal pure returns (bytes32) {
return keccak256(abi.encodePacked("PEDDLES_V20_VAULT", token, kind));
}
function _compute(bytes32 salt, bytes32 initCodeHash) internal view returns (address) {
return address(uint160(uint256(keccak256(abi.encodePacked(bytes1(0xff), address(this), salt, initCodeHash)))));
}
/// @notice Addresses `createFourVaults` WILL deploy for this exact input.
/// @dev A vault whose allocation is 0 bps is NOT deployed, and therefore predicts
/// address(0). Prediction and deployment read the same `bps > 0` condition from the
/// same struct, so the two can never disagree: see `_predict` / `createFourVaults`.
function predictFourVaults(CreateVaultsInput calldata input)
external
view
returns (IPeddlesVaultRegistryV20.VaultSet memory vaultSet)
{
vaultSet = _predict(input);
}
function _predict(CreateVaultsInput calldata input)
internal
view
returns (IPeddlesVaultRegistryV20.VaultSet memory vaultSet)
{
// Zero-allocation vaults are NOT deployed, so they predict address(0). Every field
// below still feeds the CREATE2 init-code hash exactly as before, so the address of a
// vault that IS deployed is unchanged by this branch.
if (input.liquidityBps > 0) {
vaultSet.liquidityVault = _compute(
_salt(input.token, 0x01),
keccak256(abi.encodePacked(type(PeddlesLiquidityVaultV20).creationCode, abi.encode(input.token, input.liquidityManager)))
);
}
if (input.airdropBps > 0) {
vaultSet.airdropVault = _compute(
_salt(input.token, 0x02),
keccak256(abi.encodePacked(type(PeddlesAirdropVaultV20).creationCode, abi.encode(
input.token,
input.airdropPublisher,
input.airdropStartsAt,
input.airdropEpochLength,
input.airdropEpochCount
)))
);
}
if (input.vestingBps > 0) {
vaultSet.vestingVault = _compute(
_salt(input.token, 0x03),
keccak256(abi.encodePacked(type(PeddlesVestingVaultV20).creationCode, abi.encode(
input.token,
input.creator,
input.vestingStart,
input.vestingCliff,
input.vestingDuration,
input.vestingAmount
)))
);
}
if (input.burnBps > 0) {
vaultSet.burnVault = _compute(
_salt(input.token, 0x04),
keccak256(abi.encodePacked(type(PeddlesBurnVaultV20).creationCode, abi.encode(
input.token,
input.burnStartsAt,
input.burnEpochLength,
input.firstBurnBps,
input.defaultVoteBps
)))
);
}
}
function createFourVaults(CreateVaultsInput calldata input)
external
onlyOperator
returns (IPeddlesVaultRegistryV20.VaultSet memory vaultSet)
{
_validate(input);
IPeddlesVaultRegistryV20.VaultSet memory existing = registry.getVaults(input.token);
require(existing.liquidityVault == address(0), "VAULTS_ALREADY_EXIST");
// A vault is deployed ONLY when its allocation is non-zero. At 0 bps the contract
// would hold nothing for the whole life of the token: it is gas burned on every
// launch and three extra addresses in the trust surface, and — worse — a permanent
// trap, because each vault's exit is gated on its own allocation (the vesting vault
// releases against an immutable totalAllocation of 0, the airdrop vault pays only
// against roots the platform publisher may never post, and the burn vault's
// executeScheduledBurn reverts NOTHING_TO_BURN). Anything that ever lands in one of
// them is stuck forever. Not deploying them is the fix.
//
// The condition is per-vault `bps > 0`, never "liquidity only", so re-enabling any
// allocation through the orchestrator setters brings its vault back automatically.
// `_predict` above reads the SAME condition off the SAME struct, so the predicted
// set and the deployed set always agree, including on address(0) for a skip.
address liquidityVault;
address airdropVault;
address vestingVault;
address burnVault;
if (input.liquidityBps > 0) {
liquidityVault = address(new PeddlesLiquidityVaultV20{salt: _salt(input.token, 0x01)}(
input.token,
input.liquidityManager
));
}
if (input.airdropBps > 0) {
airdropVault = address(new PeddlesAirdropVaultV20{salt: _salt(input.token, 0x02)}(
input.token,
input.airdropPublisher,
input.airdropStartsAt,
input.airdropEpochLength,
input.airdropEpochCount
));
}
if (input.vestingBps > 0) {
vestingVault = address(new PeddlesVestingVaultV20{salt: _salt(input.token, 0x03)}(
input.token,
input.creator,
input.vestingStart,
input.vestingCliff,
input.vestingDuration,
input.vestingAmount
));
}
if (input.burnBps > 0) {
burnVault = address(new PeddlesBurnVaultV20{salt: _salt(input.token, 0x04)}(
input.token,
input.burnStartsAt,
input.burnEpochLength,
input.firstBurnBps,
input.defaultVoteBps
));
}
vaultSet = IPeddlesVaultRegistryV20.VaultSet({
liquidityVault: liquidityVault,
airdropVault: airdropVault,
vestingVault: vestingVault,
burnVault: burnVault
});
registry.registerToken(input.token, input.creator);
registry.setVaults(input.token, vaultSet);
registry.setAllocation(input.token, IPeddlesVaultRegistryV20.AllocationPlan({
liquidityBps: input.liquidityBps,
airdropBps: input.airdropBps,
vestingBps: input.vestingBps,
burnBps: input.burnBps,
vaultBps: input.vaultBps,
airdropEnabled: input.airdropEnabled,
treasuryEnabled: false,
clogBps: input.clogBps
}));
registry.setAirdropSchedule(
input.token,
input.airdropStartsAt,
input.airdropEpochLength,
input.airdropEpochCount,
input.airdropEnabled
);
registry.setBurnSchedule(
input.token,
input.burnStartsAt,
input.burnEpochLength,
input.firstBurnBps,
input.minVoteBps,
input.maxVoteBps,
input.defaultVoteBps,
// Active only when a burn vault actually exists. Advertising a live burn
// schedule for a token that has no burn vault is a lie indexers would repeat.
input.burnBps > 0
);
registry.reserveSingleSidedLiquidity(
input.token,
input.quoteToken,
input.poolManager,
input.positionManager,
input.hook,
input.fee,
input.tickSpacing
);
IPeddlesVaultRegistryV20.VaultSet memory recorded = registry.getVaults(input.token);
require(recorded.liquidityVault == vaultSet.liquidityVault, "REGISTRY_LIQUIDITY_MISMATCH");
require(recorded.airdropVault == vaultSet.airdropVault, "REGISTRY_AIRDROP_MISMATCH");
require(recorded.vestingVault == vaultSet.vestingVault, "REGISTRY_VESTING_MISMATCH");
require(recorded.burnVault == vaultSet.burnVault, "REGISTRY_BURN_MISMATCH");
emit VaultSetCreated(
input.token,
input.creator,
vaultSet.liquidityVault,
vaultSet.airdropVault,
vaultSet.vestingVault,
vaultSet.burnVault
);
}
function _validate(CreateVaultsInput calldata input) internal pure {
require(input.token != address(0) && input.creator != address(0), "ZERO_ADDRESS");
require(input.liquidityManager != address(0), "ZERO_LIQUIDITY_MANAGER");
require(input.airdropPublisher != address(0), "ZERO_AIRDROP_PUBLISHER");
require(input.quoteToken != address(0) && input.poolManager != address(0) && input.positionManager != address(0), "BAD_POOL_CONFIG");
// input.hook is checked against the orchestrator's immutable fee hook AND the executor's
// configured hook in the orchestrator's _validatePoolConfig, not here: this factory does not
// know which hook the stack uses.
require(input.tickSpacing > 0 && input.fee > 0, "BAD_POOL_PARAMS");
// Schedule fields stay CONSTRUCTOR- and REGISTRY-valid even when their allocation is
// zero and no vault is built from them: `createFourVaults` writes the airdrop and burn
// schedules into the registry on EVERY launch, and the registry rejects a zero epoch
// length or count regardless of allocation. Keeping the floor here means a later
// setter flip back to a non-zero split cannot produce an unconstructable vault.
require(input.vestingDuration > 0 && input.vestingCliff <= input.vestingDuration, "BAD_VESTING");
require(input.airdropEpochLength > 0 && input.airdropEpochCount > 0, "BAD_AIRDROP_SCHEDULE");
// The 10-epoch airdrop is a PRODUCT rule; it only binds when there is an airdrop to pay.
require(input.airdropBps == 0 || input.airdropEpochCount == 10, "BAD_AIRDROP_EPOCH_COUNT");
require(input.burnEpochLength > 0, "BAD_BURN_SCHEDULE");
// The liquidity vault is the one vault that is always deployed; it anchors the
// "VAULTS_ALREADY_EXIST" re-entry guard above, so it may never be skipped.
require(input.liquidityBps > 0, "ZERO_LIQUIDITY");
// No airdrop allocation means no airdrop vault, so an "enabled" airdrop would point
// an active registry schedule at address(0).
require(input.airdropBps > 0 || !input.airdropEnabled, "AIRDROP_WITHOUT_ALLOCATION");
require(uint256(input.airdropBps) + uint256(input.burnBps) == uint256(input.vaultBps), "VAULT_MISMATCH");
require(
uint256(input.liquidityBps) + input.airdropBps + input.vestingBps + input.burnBps + input.clogBps
== 10_000,
"BPS_MISMATCH"
);
}
}
abstract contract PeddlesAtomicBaseV20 is PeddlesOwnable {
bytes32 internal constant DEFAULT_ADMIN_ROLE = bytes32(0);
bytes32 internal constant MINT_ROLE = keccak256("MINT_ROLE");
bytes32 internal constant BURN_ROLE = keccak256("BURN_ROLE");
bytes32 internal constant METADATA_ROLE = keccak256("METADATA_ROLE");
bytes4 internal constant UPDATE_CONTRACT_URI_SELECTOR = bytes4(keccak256("updateContractURI(string)"));
bytes4 internal constant UPDATE_EXTRA_METADATA_SELECTOR = bytes4(keccak256("updateExtraMetadata(string,string)"));
struct AssetParamsV1 {
uint8 version;
string name;
string symbol;
address initialAdmin;
uint8 decimals;
}
IPeddlesFactoryV20 public immutable peddlesFactory;
PeddlesVaultFactoryV20 public immutable vaultFactory;
IPeddlesVaultRegistryV20 public immutable registry;
/// @notice `PeddlesFeeHook`: every pool this orchestrator launches carries it in its PoolKey
/// and is registered with it, with the creator's launch terms, inside the launch transaction.
/// IMMUTABLE — it replaces `PeddlesCreatorFeeHook`, whose router-side ledger is retired.
IPeddlesFeeHookV20 public immutable feeHook;
IPeddlesLiquidityExecutorV20 public immutable liquidityExecutor;
address public immutable airdropPublisher;
/// @dev Sentinel used by the deploy config when no airdrop publisher exists yet.
address internal constant DEAD_PUBLISHER = 0x00000000000000000000000000000000DeaDBeef;
/// @notice True when the configured publisher could plausibly post a claim root.
/// Deliberately conservative: it cannot prove an EOA's key is held, only rule out the
/// two states that are definitely unusable — unset, and the dead sentinel.
function _airdropPublisherIsLive() internal view returns (bool) {
return airdropPublisher != address(0) && airdropPublisher != DEAD_PUBLISHER;
}
/// @notice The `PeddlesV4SwapRouter` this stack's launch pools trade through. WRITE-ONCE.
///
/// The launch orchestrator buys through it (`launchAndBuy`) and builds every clog vault on it;
/// both orchestrators exclude it from holder rewards, because it holds launched tokens mid-sell.
/// It used to be re-pointable, which let one owner transaction swap the router a creator's dev
/// buy and every future clog vault trusted. Set once at deploy; there is no second write.
address public swapRouter;
event SwapRouterUpdated(address indexed swapRouter);
/// @notice The flat launch fee, in native, charged on EVERY launch and graduation this contract
/// performs — owner, 2026-09-19: "$2 on every launch type, on every chain, in that chain's
/// native currency". A contract cannot read USD, so the owner keeps `launchFee` near $2 as the
/// native price moves, always at or below `maxLaunchFee`.
///
/// `maxLaunchFee` is IMMUTABLE and per chain: raising it needs a redeploy, which is what makes it
/// a cap rather than a suggestion — the same shape as `PeddlesStockLaunchpad.launchFee`, so the
/// stock and WETH paths cannot drift apart.
///
/// NO STUCK FUNDS: the fee is pushed to `launchFeeTreasury` inside the same transaction
/// (`_takeLaunchFee`); nothing is retained, so there is no balance to sweep.
address public immutable launchFeeTreasury;
uint256 public immutable maxLaunchFee;
uint256 public launchFee;
event LaunchFeeUpdated(uint256 launchFee);
event LaunchFeePaid(address indexed payer, uint256 amount);
/// @notice Retune the launch fee toward $2 as the native price moves. Never above the cap.
function setLaunchFee(uint256 next) external onlyOwner {
require(next <= maxLaunchFee, "FEE_ABOVE_CAP");
launchFee = next;
emit LaunchFeeUpdated(next);
}
/// @dev Take the launch fee out of `msg.value` and push it to the treasury now. Returns the
/// native left for the caller's other purposes (dev buy, factory value). Reverts when
/// `msg.value` cannot cover it — a launch is never free because the caller sent too little.
function _takeLaunchFee() internal returns (uint256 remaining) {
uint256 fee = launchFee;
require(msg.value >= fee, "LAUNCH_FEE_REQUIRED");
if (fee > 0) {
(bool ok,) = payable(launchFeeTreasury).call{value: fee}("");
require(ok, "FEE_TRANSFER_FAILED");
emit LaunchFeePaid(msg.sender, fee);
}
return msg.value - fee;
}
/// @notice Bind the swap router, once.
function setSwapRouter(address swapRouter_) external onlyOwner {
require(swapRouter == address(0) && swapRouter_ != address(0), "ROUTER_WRITE_ONCE");
swapRouter = swapRouter_;
emit SwapRouterUpdated(swapRouter_);
}
uint256 private _locked;
modifier nonReentrant() {
require(_locked == 0, "REENTRANT");
_locked = 1;
_;
_locked = 0;
}
constructor(
address initialOwner,
address peddlesFactory_,
address vaultFactory_,
address registry_,
address feeHook_,
address liquidityExecutor_,
address airdropPublisher_,
address launchFeeTreasury_,
uint256 maxLaunchFee_,
uint256 launchFee_
) PeddlesOwnable(initialOwner) {
require(
peddlesFactory_ != address(0) && vaultFactory_ != address(0) && registry_ != address(0)
&& feeHook_ != address(0) && liquidityExecutor_ != address(0)
&& airdropPublisher_ != address(0) && launchFeeTreasury_ != address(0),
"ZERO_INFRA"
);
require(launchFee_ <= maxLaunchFee_, "FEE_ABOVE_CAP");
launchFeeTreasury = launchFeeTreasury_;
maxLaunchFee = maxLaunchFee_;
launchFee = launchFee_;
emit LaunchFeeUpdated(launchFee_);
peddlesFactory = IPeddlesFactoryV20(peddlesFactory_);
vaultFactory = PeddlesVaultFactoryV20(vaultFactory_);
registry = IPeddlesVaultRegistryV20(registry_);
feeHook = IPeddlesFeeHookV20(feeHook_);
liquidityExecutor = IPeddlesLiquidityExecutorV20(liquidityExecutor_);
airdropPublisher = airdropPublisher_;
}
function _selector(bytes calldata data) internal pure returns (bytes4 selector) {
require(data.length >= 4, "BAD_INIT_CALL");
assembly ("memory-safe") { selector := calldataload(data.offset) }
}
function _validateAssetParams(bytes calldata encoded) internal view returns (uint8 decimals) {
AssetParamsV1 memory asset = abi.decode(encoded, (AssetParamsV1));
require(asset.version == 1, "BAD_ASSET_VERSION");
require(bytes(asset.name).length > 0 && bytes(asset.name).length <= 120, "BAD_ASSET_NAME");
require(bytes(asset.symbol).length > 0 && bytes(asset.symbol).length <= 24, "BAD_ASSET_SYMBOL");
require(asset.initialAdmin == address(this), "ADMIN_MUST_BE_ORCHESTRATOR");
require(asset.decimals >= 6 && asset.decimals <= 18, "BAD_DECIMALS");
return asset.decimals;
}
function _withRequiredRoles(
bytes[] calldata supplied,
address predictedBurnVault,
address creator,
uint256 totalSupply
) internal view returns (bytes[] memory calls) {
// User-controlled initialization is metadata-only. Role and supply changes
// are built by this contract so a creator cannot retain an unlimited minter.
for (uint256 i; i < supplied.length; i++) {
bytes4 selector = _selector(supplied[i]);
require(
selector == UPDATE_CONTRACT_URI_SELECTOR || selector == UPDATE_EXTRA_METADATA_SELECTOR,
"UNSAFE_INIT_CALL"
);
}
// BURN_ROLE exists for exactly one holder: the burn vault. At 0 burn bps no burn
// vault is deployed, `predictedBurnVault` is address(0), and the token's grantRole
// reverts on the zero address — so the grant is omitted rather than faked. The token
// then ships with NO burn-role holder at all, which is the correct end state for a
// 100%-liquidity launch: nothing can burn supply after the mint.
bool hasBurnVault = predictedBurnVault != address(0);
calls = new bytes[](supplied.length + (hasBurnVault ? 4 : 3));
for (uint256 i; i < supplied.length; i++) calls[i] = supplied[i];
uint256 n = supplied.length;
calls[n++] = abi.encodeWithSignature("updateSupplyCap(uint256)", totalSupply);
calls[n++] = abi.encodeWithSignature("grantRole(bytes32,address)", MINT_ROLE, address(this));
if (hasBurnVault) {
calls[n++] = abi.encodeWithSignature("grantRole(bytes32,address)", BURN_ROLE, predictedBurnVault);
}
calls[n] = abi.encodeWithSignature("grantRole(bytes32,address)", METADATA_ROLE, creator);
}
function _validateAmounts(PeddlesVaultFactoryV20.CreateVaultsInput calldata input) internal pure returns (uint256 total) {
return _validateAmounts(input, 0, 0);
}
/// @dev The allocation arithmetic, with the clog included.
///
/// `total` is the WHOLE supply — the four vault buckets plus the clog — so every bps
/// share is measured against the same denominator the creator and the buyer were shown.
/// Deriving the total from the four buckets alone would make each stated percentage mean
/// something slightly different on a clog launch than on a plain one, which is exactly the
/// kind of quiet divergence the allocation rules exist to stop.
///
/// The caller states `clogAmount` and this pins it to the variant's declared `clogBps`.
/// Nothing here trusts the caller: a wrong clog amount fails the launch rather than
/// silently shifting supply between the pool and the creator.
function _validateAmounts(
PeddlesVaultFactoryV20.CreateVaultsInput calldata input,
uint16 clogBps,
uint256 clogAmount
) internal pure returns (uint256 total) {
uint256 vaulted = input.liquidityAmount + input.airdropAmount + input.vestingAmount + input.burnAmount;
total = vaulted + clogAmount;
require(total > 0, "ZERO_SUPPLY");
require(clogAmount == (total * clogBps) / 10_000, "BAD_CLOG_AMOUNT");
require(input.liquidityAmount == (total * input.liquidityBps) / 10_000, "BAD_LIQUIDITY_AMOUNT");
require(input.airdropAmount == (total * input.airdropBps) / 10_000, "BAD_AIRDROP_AMOUNT");
require(input.vestingAmount == (total * input.vestingBps) / 10_000, "BAD_VESTING_AMOUNT");
require(input.burnAmount == vaulted - input.liquidityAmount - input.airdropAmount - input.vestingAmount, "BAD_BURN_AMOUNT");
}
function _validateOneBillionSupply(uint256 total, uint8 decimals) internal pure {
require(total == 1_000_000_000 * (10 ** uint256(decimals)), "SUPPLY_MUST_BE_ONE_BILLION");
}
function _lockSchedule(PeddlesVaultFactoryV20.CreateVaultsInput memory input)
internal
view
returns (PeddlesVaultFactoryV20.CreateVaultsInput memory)
{
input.vestingStart = uint64(block.timestamp);
input.airdropStartsAt = uint64(block.timestamp + 24 hours);
input.burnStartsAt = uint64(block.timestamp);
input.airdropPublisher = airdropPublisher;
return input;
}
function _validatePoolConfig(PeddlesVaultFactoryV20.CreateVaultsInput calldata input) internal view {
require(input.liquidityManager == address(liquidityExecutor), "BAD_LIQUIDITY_MANAGER");
require(input.airdropPublisher == airdropPublisher, "BAD_AIRDROP_PUBLISHER");
require(input.poolManager == liquidityExecutor.poolManager(), "BAD_POOL_MANAGER");
require(input.positionManager == liquidityExecutor.positionManager(), "BAD_POSITION_MANAGER");
require(input.quoteToken == liquidityExecutor.quoteToken(), "BAD_QUOTE_TOKEN");
// Every WETH launch pool is HOOKED by `feeHook`, exactly like the stock path: the tax is
// charged inside the swap, whatever router or bot trades it. The executor builds the
// PoolKey from its own `hook`, which is owner-settable, so it is pinned to this
// orchestrator's immutable hook here — a repointed executor fails the launch closed
// rather than opening a pool this orchestrator cannot register.
require(input.hook == address(feeHook) && liquidityExecutor.hook() == address(feeHook), "BAD_EXECUTOR_HOOK");
require(input.fee == liquidityExecutor.fee(), "BAD_POOL_FEE");
require(input.tickSpacing == liquidityExecutor.tickSpacing(), "BAD_TICK_SPACING");
}
/// @dev Register the pool with `feeHook` — MANDATORY, no try/catch — and point the token's
/// transfer notifications at the holder-rewards distributor the hook deployed for it.
///
/// Excluded from earning: the executor (it holds the position and any mint dust), the
/// PositionManager, every vault of this launch, the clog vault — so a clog's rewards cannot
/// reach the creator through its `sweepStray` — and the swap router the clog vault sells
/// through. The router holds tokens mid-`sell`; when the seller is itself excluded (the clog
/// vault) and no other holder is eligible, the router would otherwise be the ONLY eligible
/// holder at the router->PoolManager notification and be credited every pending reward, which
/// then only its owner's rescue could move. Zero slots are skipped by the distributor; the
/// hook adds the PoolManager and itself.
///
/// Must run while this contract is still the token's admin (before `renounceLastAdmin`) and
/// before any swap, so the tax and the distributor apply to the very first trade.
function _registerWithFeeHook(
address token,
address creator,
uint16 creatorTaxBps,
uint16 excessToCreatorBps,
IPeddlesVaultRegistryV20.VaultSet memory vaults,
address clogVault,
address router
) internal {
address[] memory excluded = new address[](8);
excluded[0] = address(liquidityExecutor);
excluded[1] = liquidityExecutor.positionManager();
excluded[2] = vaults.liquidityVault;
excluded[3] = vaults.airdropVault;
excluded[4] = vaults.vestingVault;
excluded[5] = vaults.burnVault;
excluded[6] = clogVault;
excluded[7] = router;
address rewards = feeHook.registerPool(
liquidityExecutor.poolKeyFor(token),
token,
liquidityExecutor.quoteToken(),
creator,
creatorTaxBps,
excessToCreatorBps,
excluded
);
IPeddlesTokenV20(token).setHolderRewards(rewards);
}
function _mintAllocations(
address token,
IPeddlesVaultRegistryV20.VaultSet memory vaults,
PeddlesVaultFactoryV20.CreateVaultsInput calldata input,
uint256 expectedSupply
) internal {
IPeddlesTokenV20 peddles = IPeddlesTokenV20(token);
_mintAllocation(peddles, vaults.liquidityVault, input.liquidityAmount);
_mintAllocation(peddles, vaults.airdropVault, input.airdropAmount);
_mintAllocation(peddles, vaults.vestingVault, input.vestingAmount);
_mintAllocation(peddles, vaults.burnVault, input.burnAmount);
// `_validateAmounts` already proved the four buckets plus the clog sum to
// `expectedSupply`; this proves every one of them was actually minted, so the full
// supply is accounted for with no stranded remainder even though some vaults were
// skipped. The clog was minted before this call, so it is included in the balance.
require(peddles.totalSupply() == expectedSupply, "SUPPLY_MISMATCH");
}
/// @dev Vault existence and allocation size are the SAME switch, so they must agree in
/// both directions. A funded allocation with no vault would mint to address(0) (the token
/// reverts) or, worse, silently drop supply; a deployed vault with nothing to hold is the
/// empty-vault trap this design removes. Either mismatch is a bug, not a launch.
function _mintAllocation(IPeddlesTokenV20 peddles, address vault, uint256 amount) private {
if (amount == 0) {
require(vault == address(0), "VAULT_WITHOUT_ALLOCATION");
return;
}
require(vault != address(0), "ALLOCATION_WITHOUT_VAULT");
peddles.mint(vault, amount);
}
function _verifyRegistry(
address token,
IPeddlesVaultRegistryV20.VaultSet memory vaults,
bytes32 poolId,
uint256 positionId
) internal view {
require(registry.isPeddles(token), "TOKEN_NOT_REGISTERED");
IPeddlesVaultRegistryV20.VaultSet memory recorded = registry.getVaults(token);
require(recorded.liquidityVault == vaults.liquidityVault, "BAD_REGISTERED_LIQUIDITY");
require(recorded.airdropVault == vaults.airdropVault, "BAD_REGISTERED_AIRDROP");
require(recorded.vestingVault == vaults.vestingVault, "BAD_REGISTERED_VESTING");
require(recorded.burnVault == vaults.burnVault, "BAD_REGISTERED_BURN");
(
bool active,,,,, bytes32 registeredPoolId, uint256 registeredPositionId,,,
) = registry.liquidityOf(token);
require(active, "TRADING_NOT_ACTIVE");
require(registeredPoolId == poolId && registeredPositionId == positionId, "LIQUIDITY_STATE_MISMATCH");
}
event DevBought(address indexed token, address indexed buyer, uint256 ethIn, uint256 tokensOut);
/// @dev Buy `token` for `msg.sender` through the public swap router, leaving NOTHING here.
///
/// The router delivers the tokens straight to `msg.sender`. What the creator got is MEASURED
/// as their own balance delta, not taken from the router's return value, and the creator's
/// slippage floor is enforced against that measurement.
///
/// NO STUCK FUNDS. On a partial fill `PeddlesV4SwapRouter.buy` refunds the unspent ETH to its
/// caller, this contract, which has no `receive`: the refund reverts and the whole launch
/// reverts with it. Fail-closed; nothing is ever left here.
function _devBuy(address token, uint256 devBuyValue, uint256 minTokensOut)
internal
returns (uint256 tokensOut)
{
if (devBuyValue == 0) {
// A slippage floor with nothing to spend is a mistake, not a no-op: fail closed
// rather than silently launch with no dev buy when the caller clearly wanted one.
require(minTokensOut == 0, "NO_DEV_BUY");
return 0;
}
address router = swapRouter;
require(router != address(0), "NO_SWAP_ROUTER");
uint256 before = IERC20Minimal(token).balanceOf(msg.sender);
IPeddlesV4RouterBuyV20(router).buy{value: devBuyValue}(token, minTokensOut, msg.sender);
tokensOut = IERC20Minimal(token).balanceOf(msg.sender) - before;
require(tokensOut >= minTokensOut, "DEV_BUY_SLIPPAGE");
emit DevBought(token, msg.sender, devBuyValue, tokensOut);
}
function _activate(
address token,
uint256 amountPeddles,
uint160 sqrtPriceX96,
int24 tickLower,
int24 tickUpper,
uint256 liquidity,
uint256 value
) internal returns (bytes32 poolId, uint256 positionId) {
require(liquidity > 0 && amountPeddles > 0 && sqrtPriceX96 > 0, "BAD_LIQUIDITY_INPUT");
return liquidityExecutor.activateSingleSidedLiquidity{value: value}(
token,
amountPeddles,
sqrtPriceX96,
tickLower,
tickUpper,
liquidity
);
}
}
contract PeddlesLaunchOrchestratorV20 is PeddlesAtomicBaseV20 {
struct LaunchInput {
uint8 variant;
bytes32 salt;
bytes params;
bytes[] initCalls;
PeddlesVaultFactoryV20.CreateVaultsInput vaultInput;
/// @dev The pool's all-in swap tax, bps (100..1000). Fixed for the life of the pool.
uint16 creatorTaxBps;
/// @dev Share of the tax above 1.00% paid to the creator instead of holders, bps (0..10000).
uint16 excessToCreatorBps;
uint256 factoryValue;
uint256 amountPeddles;
uint160 sqrtPriceX96;
int24 tickLower;
int24 tickUpper;
uint256 liquidity;
}
event PeddlesLaunchedV20(
address indexed token,
address indexed creator,
bytes32 indexed salt,
address liquidityVault,
address airdropVault,
address vestingVault,
address burnVault,
uint16 creatorTaxBps,
uint16 excessToCreatorBps,
bytes32 poolId,
uint256 positionId
);
// Owner-settable default allocation for the standard (create) launch path. The four
// bps MUST sum to 10000. Default: LIQUIDITY 10000 / AIRDROP 0 / VESTING 0 / BURN 0.
//
// 100% of a launch's supply goes to liquidity, and NOTHING is burned at launch. This is a
// product rule, not a tuning choice (CLAUDE.md: "no supply burn at launch — on any launch
// type"). The only burn in the system is the platform flywheel, which buys PEDL on the open
// market with accrued fees and burns what it bought; that removes supply the platform paid
// for, which is not the same thing as never issuing a creator's supply in the first place.
//
// This previously defaulted to 7500 liquidity / 2500 burn, which silently destroyed a
// quarter of every launch's supply.
//
// STORAGE, not literals, so retuning is a setter call. A launch's vaultInput must match
// these exactly.
uint16 public defaultLiquidityBps = 10_000;
uint16 public defaultAirdropBps = 0;
uint16 public defaultVestingBps = 0;
uint16 public defaultBurnBps = 0;
event DefaultAllocationUpdated(uint16 liquidityBps, uint16 airdropBps, uint16 vestingBps, uint16 burnBps);
/// @notice Factory that deploys this launch's clog vault, when the launch TYPE declares
/// a clog allocation. WRITE-ONCE. A variant that declares a clog refuses to launch
/// while this is unset, rather than launching without the vault.
///
/// It was re-pointable, and `_mintClog` trusts it for both the predicted and the
/// deployed vault address, so one owner transaction could have minted up to
/// CLOG_BPS_MAX of every later clog launch's supply into a contract of the owner's
/// choosing. Set once at deploy; there is no second write.
///
/// It is a separate contract because `PeddlesVaultFactoryV20` cannot grow: that
/// contract embeds each vault's creation code twice and has ~1,100 bytes of headroom.
address public clogVaultFactory;
event ClogVaultFactoryUpdated(address indexed clogVaultFactory);
event ClogVaultFunded(
address indexed token, address indexed vault, uint256 amount, uint256 sliceCap, uint64 minInterval
);
/// @notice Domain tag of the creator-bound launch salt (see `launchSalt`).
bytes32 public constant LAUNCH_SALT_DOMAIN = keccak256("PEDDLES_V20_LAUNCH_SALT");
/// @notice The salt this orchestrator hands the factory for a launch by `creator` with the
/// caller-chosen `salt`.
///
/// WHY. The factory binds a salt to ITS caller, which is this contract, so with the raw caller
/// salt every creator shared ONE address space: anyone who saw a pending launch's salt (in the
/// mempool, or behind an advertised "pre-launch" address) could launch a different token at the
/// creator's address first. Mixing the creator in here gives each creator a disjoint space —
/// the same guarantee `PeddlesStockLaunchpad._boundSalt` gives the stock path. The creator of a
/// launch is always `msg.sender` (`CREATOR_MISMATCH`), so nobody else can produce this salt
/// through this contract, and replaying a creator's calldata from another account lands at a
/// different address.
function launchSalt(address creator, bytes32 salt) public pure returns (bytes32) {
return keccak256(abi.encode(LAUNCH_SALT_DOMAIN, creator, salt));
}
/// @notice Where a launch by `creator` with launch type `variant` and caller salt `salt` puts
/// its token. One chain read; `launch`/`launchAndBuy` deploy exactly here or revert.
function predictLaunchToken(address creator, uint8 variant, bytes32 salt) public view returns (address) {
return peddlesFactory.getPeddlesAddress(variant, address(this), launchSalt(creator, salt));
}
/// @notice Burner pre-registered for ONE future launch, keyed by that launch's PREDICTED token
/// address (`predictLaunchToken(creator, variant, salt)` — creator-bound, so only that
/// creator's launch can ever consume it).
///
/// WHY IT EXISTS. A launched token ships with no BURN_ROLE holder and no admin left to grant
/// one, so nothing can ever burn it. That is right for every creator's coin. It is wrong for
/// exactly one: PEDL, fair-launched through this path, whose buyback flywheel must burn what it
/// buys (the ONLY burn in the system). The protocol owner names the flywheel here BEFORE the
/// launch; the launch grants it BURN_ROLE while this contract is still the token's admin, then
/// renounces admin as always. Launch calldata and ABI are unchanged; a launch with nothing
/// registered behaves exactly as before.
///
/// WHAT BURN_ROLE PERMITS (read from PeddlesTokenV20, which is the whole security argument):
/// `burn(amount)` of the CALLER'S OWN balance and nothing else. The token has no `burnFrom`,
/// the role cannot mint, and after `renounceLastAdmin` nobody can grant or re-grant any role.
/// So a registered burner can never reduce another holder's balance; it can only destroy
/// tokens it bought itself.
///
/// Only the owner registers; only a token that does not exist yet can be named (a launched
/// token always has code, so this also refuses one already recorded); `burner = 0` clears it.
/// The grant is consumed by the launch that produces that exact address, and deleted.
mapping(address => address) public launchBurner;
event LaunchBurnerSet(address indexed token, address indexed burner);
event LaunchBurnerCleared(address indexed token);
event LaunchBurnerGranted(address indexed token, address indexed burner);
function setLaunchBurner(address token, address burner) external onlyOwner {
require(token != address(0), "ZERO_TOKEN");
require(token.code.length == 0, "TOKEN_ALREADY_LAUNCHED");
launchBurner[token] = burner;
if (burner == address(0)) emit LaunchBurnerCleared(token);
else emit LaunchBurnerSet(token, burner);
}
/// @dev A separate function so `_launch` carries no extra stack slot.
function _grantLaunchBurner(address token) private {
address burner = launchBurner[token];
if (burner == address(0)) return;
delete launchBurner[token];
IPeddlesTokenV20(token).grantRole(BURN_ROLE, burner);
emit LaunchBurnerGranted(token, burner);
}
/// @notice Bind the factory that builds clog vaults for clog launch types, once.
function setClogVaultFactory(address clogVaultFactory_) external onlyOwner {
require(clogVaultFactory == address(0) && clogVaultFactory_ != address(0), "CLOG_FACTORY_WRITE_ONCE");
clogVaultFactory = clogVaultFactory_;
emit ClogVaultFactoryUpdated(clogVaultFactory_);
}
/// @dev Build this launch type's clog vault and mint its allocation into it.
///
/// The vault is deployed HERE rather than by `PeddlesVaultFactoryV20` for a size reason,
/// not a design preference — see `clogVaultFactory`.
///
/// NOTHING IS TAKEN ON TRUST. The address is predicted and then compared to what was
/// actually deployed, exactly as the four V20 vaults are, because the alternative failure
/// is silent: supply minted to an address that holds no code is supply destroyed.
function _mintClog(
address token,
uint256 clogAmount,
uint16 clogBps,
uint16 clogSliceBps,
uint64 clogMinInterval,
uint256 total
) private returns (address vault) {
if (clogBps == 0) {
// A clog amount on a type that declares no clog is a mistake, not a no-op.
require(clogAmount == 0, "CLOG_WITHOUT_ALLOCATION");
return address(0);
}
address factory_ = clogVaultFactory;
require(factory_ != address(0), "NO_CLOG_VAULT_FACTORY");
address router = swapRouter;
// A clog vault bound to a zero router can never sell and its allocation is stranded
// until `escape()` opens six months later. Refuse the launch instead.
require(router != address(0), "NO_SWAP_ROUTER");
uint256 sliceCap = (total * clogSliceBps) / 10_000;
require(sliceCap > 0, "CLOG_SLICE_ROUNDS_TO_ZERO");
address predicted = IPeddlesClogVaultFactoryV20(factory_).predict(
address(this), token, router, msg.sender, sliceCap, clogMinInterval
);
vault = IPeddlesClogVaultFactoryV20(factory_).create(
token, router, msg.sender, sliceCap, clogMinInterval
);
require(vault == predicted, "CLOG_VAULT_PREDICTION_MISMATCH");
IPeddlesTokenV20(token).mint(vault, clogAmount);
emit ClogVaultFunded(token, vault, clogAmount, sliceCap, clogMinInterval);
}
constructor(
address initialOwner,
address peddlesFactory_,
address vaultFactory_,
address registry_,
address feeHook_,
address liquidityExecutor_,
address airdropPublisher_,
address launchFeeTreasury_,
uint256 maxLaunchFee_,
uint256 launchFee_
) PeddlesAtomicBaseV20(
initialOwner,
peddlesFactory_,
vaultFactory_,
registry_,
feeHook_,
liquidityExecutor_,
airdropPublisher_,
launchFeeTreasury_,
maxLaunchFee_,
launchFee_
) {}
/// @notice Owner-settable default allocation for the create path; the four bps sum to 10000.
function setDefaultAllocation(uint16 liquidityBps_, uint16 airdropBps_, uint16 vestingBps_, uint16 burnBps_)
external
onlyOwner
{
require(uint256(liquidityBps_) + airdropBps_ + vestingBps_ + burnBps_ == 10_000, "BPS_SUM");
require(liquidityBps_ > 0, "ZERO_LIQUIDITY");
// An airdrop allocation is only claimable if a real publisher can post the claim root.
// `airdropPublisher` is IMMUTABLE here and in every vault it seeds, and the deployed
// config sets it to 0x...DeaDBeef — an address nobody holds. Without this guard, one
// owner call enabling a non-zero airdrop share would make every subsequent launch mint
// that share into a vault whose only key is dead: permanently unclaimable, unfixable
// without redeploying the orchestrator. CLAUDE.md forbids an exit gated on a condition
// that can never be met, so the allocation is refused rather than the funds stranded.
require(airdropBps_ == 0 || _airdropPublisherIsLive(), "AIRDROP_PUBLISHER_UNUSABLE");
// No supply burn at launch, on any launch type. Enforced HERE and not only in the
// default values, because a default is just the starting point — without this, one
// owner call could reintroduce a launch-time burn for every subsequent launch, and
// creators who read the rule when they launched would have had a quarter of their
// supply destroyed by a setting changed after the fact.
//
// Burning is not forbidden in general: the platform flywheel buys PEDL on the open
// market and burns what it paid for. That is the platform spending its own revenue.
// Destroying a creator's supply at mint is a different act and is refused.
require(burnBps_ == 0, "NO_LAUNCH_BURN");
// VESTING IS CLOSED on every launch type (CLAUDE.md), and `registerVariant` already
// refuses it for registered types. Variant 0's allocation comes from HERE, so it is
// refused here too; otherwise one owner call reopened a creator vesting vault.
require(vestingBps_ == 0, "NO_VESTING");
defaultLiquidityBps = liquidityBps_;
defaultAirdropBps = airdropBps_;
defaultVestingBps = vestingBps_;
defaultBurnBps = burnBps_;
emit DefaultAllocationUpdated(liquidityBps_, airdropBps_, vestingBps_, burnBps_);
}
function launch(LaunchInput calldata input)
external
payable
nonReentrant
returns (
address token,
IPeddlesVaultRegistryV20.VaultSet memory vaults,
bytes32 poolId,
uint256 positionId
)
{
// The launch fee comes off the top; every remaining wei not earmarked for the factory
// funds the liquidity activation, exactly as it always has.
uint256 available = _takeLaunchFee();
require(input.factoryValue <= available, "BAD_FACTORY_VALUE");
return _launch(input, available - input.factoryValue);
}
/// @notice Launch and immediately buy, in ONE transaction.
///
/// ATOMICITY IS THE POINT. Launching and then buying in a second transaction lets a bot see
/// the launch land and snipe the pool in between, so the creator pays a worse price than the
/// public. Here both legs share a transaction: if the buy reverts — slippage, an unset router,
/// a pool that did not initialise — the launch reverts with it and NOTHING persists. This
/// mirrors `PeddlesStockLaunchpad.createCoinAndBuy` so the two paths are not subtly different.
///
/// NO PRIVILEGE. The dev buy is an ordinary `PeddlesV4SwapRouter.buy` for `msg.sender`'s own
/// account, executed AFTER the pool is live and registered with `feeHook`, so it pays the
/// pool's own tax like any other buyer of the same size. The ONE difference is the opening
/// tax: the hook recognises a swap in the transaction that registered the pool, in its block,
/// and charges it the pool's ordinary rate rather than the decaying 20% opener — the same
/// exemption `PeddlesStockLaunchpad.createCoinAndBuy` gets.
///
/// NO APPROVAL STEP. Unlike the stock path, this pool's quote leg is native ETH, so the dev
/// buy is funded by `msg.value` and needs no ERC20 `approve` beforehand. The UI flow is one
/// signature, not two.
///
/// LAUNCH FEE. `launchFee` (≈ $2 in native, owner 2026-09-19) is taken first and pushed to the
/// treasury; `msg.value` is `launchFee + factoryValue + devBuyValue + liquidity funding`.
///
/// @param devBuyValue Wei of `msg.value` to spend on the dev buy. 0 launches with no dev buy.
/// @param minTokensOut Slippage floor for the dev buy; the call reverts if it is not met.
function launchAndBuy(LaunchInput calldata input, uint256 devBuyValue, uint256 minTokensOut)
external
payable
nonReentrant
returns (
address token,
IPeddlesVaultRegistryV20.VaultSet memory vaults,
bytes32 poolId,
uint256 positionId,
uint256 tokensOut
)
{
// Written as two subtractions rather than `factoryValue + devBuyValue <= msg.value` so an
// overflow surfaces as this message instead of an arithmetic panic.
uint256 available = _takeLaunchFee();
require(devBuyValue <= available, "BAD_DEV_BUY_VALUE");
require(input.factoryValue <= available - devBuyValue, "BAD_FACTORY_VALUE");
(token, vaults, poolId, positionId) = _launch(input, available - input.factoryValue - devBuyValue);
tokensOut = _devBuy(token, devBuyValue, minTokensOut);
}
function _launch(LaunchInput calldata input, uint256 liquidityValue)
private
returns (
address token,
IPeddlesVaultRegistryV20.VaultSet memory vaults,
bytes32 poolId,
uint256 positionId
)
{
require(peddlesFactory.isVariantSupported(input.variant), "UNSUPPORTED_VARIANT");
uint8 tokenDecimals = _validateAssetParams(input.params);
require(input.vaultInput.creator == msg.sender, "CREATOR_MISMATCH");
require(input.vaultInput.token == address(0), "TOKEN_SET_BY_ORCHESTRATOR");
_validateCreateTokenRules(input.vaultInput, input.variant);
(,,,, uint16 clogBps, uint16 clogSliceBps, uint64 clogMinInterval) = _allocationFor(input.variant);
// DERIVED, not supplied. Total supply is already pinned to exactly one billion by
// `_validateOneBillionSupply`, so the clog is a pure function of the launch type's
// declared share — there is no caller-stated figure that could disagree with it, and
// therefore no way to shift supply between the pool and the creator by lying about it.
uint256 clogAmount = ((1_000_000_000 * (10 ** uint256(tokenDecimals))) * clogBps) / 10_000;
uint256 total = _validateAmounts(input.vaultInput, clogBps, clogAmount);
_validateOneBillionSupply(total, tokenDecimals);
// CREATOR-BOUND salt for BOTH the prediction and the deployment (see `launchSalt`).
address predictedToken = predictLaunchToken(msg.sender, input.variant, input.salt);
PeddlesVaultFactoryV20.CreateVaultsInput memory vaultInput = _lockSchedule(input.vaultInput);
vaultInput.token = predictedToken;
IPeddlesVaultRegistryV20.VaultSet memory predictedVaults = vaultFactory.predictFourVaults(vaultInput);
bytes[] memory initCalls = _withRequiredRoles(input.initCalls, predictedVaults.burnVault, msg.sender, total);
token = peddlesFactory.createPeddles{value: input.factoryValue}(
input.variant, launchSalt(msg.sender, input.salt), input.params, initCalls
);
require(token == predictedToken, "TOKEN_PREDICTION_MISMATCH");
vaults = vaultFactory.createFourVaults(vaultInput);
// Compare the WHOLE set, not just the burn vault. A skipped vault predicts and
// deploys address(0), so an all-four compare is the only thing that proves the
// prediction the BURN_ROLE grant above was built from still describes reality —
// and that the factory skipped exactly the vaults this launch expected it to.
require(
vaults.liquidityVault == predictedVaults.liquidityVault
&& vaults.airdropVault == predictedVaults.airdropVault
&& vaults.vestingVault == predictedVaults.vestingVault
&& vaults.burnVault == predictedVaults.burnVault,
"VAULT_PREDICTION_MISMATCH"
);
address clogVault = _mintClog(token, clogAmount, clogBps, clogSliceBps, clogMinInterval, total);
_mintAllocations(token, vaults, input.vaultInput, total);
_registerWithFeeHook(
token, msg.sender, input.creatorTaxBps, input.excessToCreatorBps, vaults, clogVault, swapRouter
);
(poolId, positionId) = _activate(
token,
input.amountPeddles,
input.sqrtPriceX96,
input.tickLower,
input.tickUpper,
input.liquidity,
liquidityValue
);
_verifyRegistry(token, vaults, poolId, positionId);
// A pre-registered burner (see `launchBurner`) gets BURN_ROLE while this contract is still
// the token's admin — the last moment anyone can grant a role — and the registration is
// consumed.
_grantLaunchBurner(token);
IPeddlesTokenV20(token).renounceRole(MINT_ROLE, address(this));
IPeddlesTokenV20(token).renounceLastAdmin();
emit PeddlesLaunchedV20(
token,
msg.sender,
input.salt,
vaults.liquidityVault,
vaults.airdropVault,
vaults.vestingVault,
vaults.burnVault,
input.creatorTaxBps,
input.excessToCreatorBps,
poolId,
positionId
);
}
/// @dev Allocation for a REGISTERED launch type comes from the variant, which declared it
/// write-once at registration. Variant 0 is the built-in asset type: it cannot be
/// registered, so it keeps the owner-configured defaults it has always used.
function _allocationFor(uint8 variant)
internal
view
returns (uint16 liquidityBps, uint16 airdropBps, uint16 vestingBps, uint16 burnBps, uint16 clogBps,
uint16 clogSliceBps, uint64 clogMinInterval)
{
if (variant == 0) {
return (defaultLiquidityBps, defaultAirdropBps, defaultVestingBps, defaultBurnBps, 0, 0, 0);
}
return peddlesFactory.variantAllocation(variant);
}
function _validateCreateTokenRules(PeddlesVaultFactoryV20.CreateVaultsInput calldata input, uint8 variant) internal view {
(uint16 liqBps, uint16 airBps, uint16 vestBps, uint16 burnBps_, uint16 clogBps_,,) = _allocationFor(variant);
// Allocation must match what the LAUNCH TYPE declares.
require(input.liquidityBps == liqBps, "CREATE_BAD_LIQUIDITY");
require(input.airdropBps == airBps, "CREATE_BAD_AIRDROP");
require(input.vestingBps == vestBps, "CREATE_BAD_VESTING");
require(input.burnBps == burnBps_, "CREATE_BAD_BURN");
require(input.clogBps == clogBps_, "CREATE_BAD_CLOG");
// Vault bps = airdrop + burn; airdrop is enabled iff its allocation is non-zero.
require(
input.vaultBps == uint16(uint256(airBps) + burnBps_) && input.airdropEnabled == (airBps > 0),
"CREATE_BAD_VAULT"
);
// Vesting schedule is only pinned to the 60d/540d protocol schedule when vesting is used;
// with 0 vesting the vault is created but funded 0, so only require a factory-valid schedule.
if (vestBps > 0) {
require(input.vestingCliff == 60 days && input.vestingDuration == 540 days, "CREATE_BAD_VESTING_SCHEDULE");
} else {
require(input.vestingDuration > 0 && input.vestingCliff <= input.vestingDuration, "CREATE_BAD_VESTING_SCHEDULE");
}
// Same rule as vesting above: the protocol airdrop/burn schedules are only pinned when
// that allocation is actually funded and its vault is actually deployed. At 0 bps the
// fields are inert plumbing for the registry writes and only need to clear the vault
// factory's `_validate` floor, so pinning exact constants here would be a require that
// can never affect an outcome.
if (airBps > 0) {
require(input.airdropEpochLength == 10 days && input.airdropEpochCount == 10, "CREATE_BAD_AIRDROP_SCHEDULE");
}
if (burnBps_ > 0) {
require(input.burnEpochLength == 10 days && input.firstBurnBps == 1000 && input.defaultVoteBps == 1000, "CREATE_BAD_BURN_SCHEDULE");
}
_validatePoolConfig(input);
}
}
contract PeddlesNFTBondingGraduationOrchestratorV20 is PeddlesAtomicBaseV20 {
struct GraduateInput {
address collection;
uint8 variant;
bytes32 salt;
bytes params;
bytes[] initCalls;
PeddlesVaultFactoryV20.CreateVaultsInput vaultInput;
/// @dev The pool's all-in swap tax, bps (100..1000). Fixed for the life of the pool.
uint16 creatorTaxBps;
/// @dev Share of the tax above 1.00% paid to the creator instead of holders, bps (0..10000).
uint16 excessToCreatorBps;
uint256 factoryValue;
uint256 amountPeddles;
uint160 sqrtPriceX96;
int24 tickLower;
int24 tickUpper;
uint256 liquidity;
}
/// @notice The `PeddlesNftFeeDistributorFactory` whose distributors count as a holder
/// commitment. IMMUTABLE: there is no pointer an owner could re-aim at a look-alike.
IPeddlesNftFeeDistributorFactoryV20 public immutable nftFeeDistributorFactory;
/// @notice Collection => the `relayParamsHash` of the ONE graduation ANY caller may perform for
/// it. Zero = no consent. Set and revoked by the collection owner, revocable until graduated.
///
/// @dev WHY THIS EXISTS (owner, 2026-09-19). A bonding collection graduates when its curve
/// sells out — "an objective, unfakeable moment that nobody chooses" — and yet listing the coin
/// used to require `collection.owner()` to press a button. A collection could therefore sell
/// out completely and its coin never list, because the one person who could press it went
/// quiet. That is an exit gated on a condition that may never arrive, which is exactly what the
/// no-stuck-funds rule forbids everywhere else in this repo.
///
/// The creator still decides EVERYTHING about the launch: they hash the whole `GraduateInput`
/// — name, symbol, decimals, salt, the vault input (quote leg, pool manager, fee, tick spacing,
/// every allocation amount and the creator address), the fee terms, the opening price, the tick
/// range and the liquidity — plus the holder share, and commit it here. A relayer chooses only
/// the block, and can produce nothing but that exact launch.
mapping(address => bytes32) public graduationOptIn;
/// @notice The collection owner committed (or, with `bytes32(0)`, withdrew) the one graduation
/// anybody may relay for `collection`.
event GraduationOptInSet(address indexed collection, address indexed collectionOwner, bytes32 paramsHash);
/// @notice The same commitment, WITH ITS PREIMAGE. A hash authorises a relay; it does not tell
/// anyone what to send. Publishing the whole `GraduateInput` on-chain is what makes the relay
/// permissionless IN PRACTICE rather than only in principle — a stranger can rebuild the exact
/// call from this log and needs nothing from Peddles, no API and no off-chain store, to do it.
event GraduationCommitted(
address indexed collection,
address indexed collectionOwner,
bytes32 paramsHash,
GraduateInput input,
uint16 holderShareBps
);
event NFTBondingGraduatedV20(
address indexed collection,
address indexed creator,
address indexed token,
address liquidityVault,
address airdropVault,
address vestingVault,
address burnVault,
uint16 creatorTaxBps,
uint16 excessToCreatorBps,
bytes32 poolId,
uint256 positionId
);
/// @notice The launch bound this coin's creator fee stream to the collection's distributor,
/// split `holderShareBps` to NFT holders and the rest to the creator. Permanent.
event HolderFeesCommitted(
address indexed collection,
address indexed token,
address indexed distributor,
bytes32 poolId,
uint16 holderShareBps
);
constructor(
address initialOwner,
address peddlesFactory_,
address vaultFactory_,
address registry_,
address feeHook_,
address liquidityExecutor_,
address airdropPublisher_,
address nftFeeDistributorFactory_,
address launchFeeTreasury_,
uint256 maxLaunchFee_,
uint256 launchFee_
) PeddlesAtomicBaseV20(
initialOwner,
peddlesFactory_,
vaultFactory_,
registry_,
feeHook_,
liquidityExecutor_,
airdropPublisher_,
launchFeeTreasury_,
maxLaunchFee_,
launchFee_
) {
require(nftFeeDistributorFactory_ != address(0), "ZERO_INFRA");
nftFeeDistributorFactory = IPeddlesNftFeeDistributorFactoryV20(nftFeeDistributorFactory_);
}
/// @notice The exact graduation a relayer may perform for `input.collection`, on this chain and
/// this orchestrator. EVERY field of the launch is inside it, because every field is
/// economically load-bearing: `input.params` carries the name, symbol and decimals;
/// `input.vaultInput` carries the quote leg, the pool manager, the fee, the tick spacing, the
/// creator address and every allocation amount; `sqrtPriceX96`, `tickLower`, `tickUpper` and
/// `liquidity` carry the OPENING PRICE and the shape of the position; `creatorTaxBps` and
/// `excessToCreatorBps` carry the permanent fee terms; `holderShareBps` carries the NFT
/// holders' split. The whole struct is hashed rather than a hand-picked subset so that a field
/// added later cannot silently fall outside the commitment.
///
/// @dev The collection owner computes this, passes it to `setGraduationOptIn`, and a relay that
/// deviates by one byte reverts `RELAY_PARAMS_MISMATCH`.
function relayParamsHash(GraduateInput calldata input, uint16 holderShareBps)
public
view
returns (bytes32)
{
return keccak256(abi.encode(block.chainid, address(this), input, holderShareBps));
}
/// @notice Collection owner commits ONE graduation anybody may relay — the one whose
/// `relayParamsHash` is `paramsHash` — or withdraws consent with `bytes32(0)`.
///
/// @dev Only the collection's own owner can write it. The protocol owner has no path here at
/// all, so opening the gate creates no way to burn a collection's one-shot `graduated` latch
/// against a creator who did not ask for it: with no consent a relay reverts `NOT_OPTED_IN`,
/// and after a revoke it reverts `NOT_OPTED_IN` again.
function setGraduationOptIn(address collection, bytes32 paramsHash) external {
require(collection != address(0), "ZERO_COLLECTION");
address collectionOwner = IPeddlesNFTBondingCollectionV20(collection).owner();
require(msg.sender == collectionOwner, "NOT_COLLECTION_OWNER");
graduationOptIn[collection] = paramsHash;
emit GraduationOptInSet(collection, collectionOwner, paramsHash);
}
/// @notice Commit a graduation AND publish its preimage, in one call. This is the entry a
/// creator should use; `setGraduationOptIn` above remains for revoking (`bytes32(0)`) and for a
/// creator who would rather not put the parameters in a log.
///
/// @dev The hash is computed here rather than supplied, so the log and the stored commitment
/// cannot disagree: whatever this event carries IS what a relayer may send.
function commitGraduation(GraduateInput calldata input, uint16 holderShareBps)
external
returns (bytes32 paramsHash)
{
require(input.collection != address(0), "ZERO_COLLECTION");
address collectionOwner = IPeddlesNFTBondingCollectionV20(input.collection).owner();
require(msg.sender == collectionOwner, "NOT_COLLECTION_OWNER");
paramsHash = relayParamsHash(input, holderShareBps);
graduationOptIn[input.collection] = paramsHash;
emit GraduationOptInSet(input.collection, collectionOwner, paramsHash);
emit GraduationCommitted(input.collection, collectionOwner, paramsHash, input, holderShareBps);
}
/// @notice Graduate, fix the holder split, and dev-buy — in ONE transaction. The ONLY entry.
///
/// ONE ENTRY, NOT TWO — AND THE RELAY SHARES IT. The former `graduate(GraduateInput)` is gone:
/// under via-IR a second external entry sharing the private body duplicated it and the contract
/// measured 27,473 bytes, over EIP-170. A graduation with no holder split and no dev buy is
/// `graduateAndBuy(input, 0, 0, 0)`. The permissionless relay added on 2026-09-19 is a BRANCH
/// inside this function rather than a `graduateForCollection` of its own, for the same measured
/// reason: a second entry point would duplicate `_graduate` again and blow the code-size limit.
///
/// WHO MAY CALL IT. Either the collection owner — the path that always existed, with their own
/// terms and an in-transaction dev buy — or ANYBODY AT ALL, relaying the exact graduation the
/// collection owner committed with `setGraduationOptIn`. A relay must send EXACTLY the launch
/// fee (`RELAY_FEE_ONLY`), which is what makes "a relayer never dev-buys inside the launch" a
/// structural fact rather than a check: once the fee is taken, `devBuyValue <= available`
/// forces `devBuyValue` to zero, and a slippage floor with nothing to spend is already refused
/// by `_devBuy`. Nothing else is lost — `PeddlesFactoryV20.createPeddles` and
/// `activateSingleSidedLiquidity` both refuse native outright. A relayer therefore pays gas and
/// the ≈ $2 launch fee (owner 2026-09-19: every launch type pays it), like a stock relay.
///
/// HOLDER SPLIT. When the collection's `holderRewards()` is the distributor
/// `nftFeeDistributorFactory` built for it, the hook's creator leg is bound to that distributor
/// here, permanently, and the distributor splits every unit `holderShareBps` to NFT holders
/// (pro rata to pieces held) and the rest to the collection owner. `holderShareBps` is the
/// creator's own choice, 0..10000, and nobody can change it afterwards. For a collection with no
/// canonical distributor it must be 0 (`NO_HOLDER_DISTRIBUTOR`): a creator who meant to pay
/// holders is refused rather than launched without them.
///
/// DEV BUY. Identical to `PeddlesLaunchOrchestratorV20.launchAndBuy`: an ordinary router buy
/// for `msg.sender` after the pool is live and registered, measured as the buyer's balance
/// delta, paying the pool's ordinary tax (the hook's in-transaction dev-buy marker), reverting
/// the whole graduation on slippage or a partial fill.
function graduateAndBuy(
GraduateInput calldata input,
uint16 holderShareBps,
uint256 devBuyValue,
uint256 minTokensOut
)
external
payable
nonReentrant
returns (
address token,
IPeddlesVaultRegistryV20.VaultSet memory vaults,
bytes32 poolId,
uint256 positionId,
uint256 tokensOut
)
{
require(holderShareBps <= 10_000, "BAD_HOLDER_SHARE");
uint256 available = _takeLaunchFee();
require(devBuyValue <= available, "BAD_DEV_BUY_VALUE");
require(input.factoryValue <= available - devBuyValue, "BAD_FACTORY_VALUE");
(token, vaults, poolId, positionId) =
_graduate(input, holderShareBps, available - input.factoryValue - devBuyValue);
tokensOut = _devBuy(token, devBuyValue, minTokensOut);
}
function _graduate(GraduateInput calldata input, uint16 holderShareBps, uint256 liquidityValue)
private
returns (
address token,
IPeddlesVaultRegistryV20.VaultSet memory vaults,
bytes32 poolId,
uint256 positionId
)
{
IPeddlesNFTBondingCollectionV20 collection = IPeddlesNFTBondingCollectionV20(input.collection);
// THE CREATOR IS THE COLLECTION OWNER, NOT THE CALLER. Read once, from the collection, and
// used for every decision below that used to read `msg.sender`: the vault input's creator,
// the token's METADATA_ROLE, the hook's creator (and therefore the fee payout on an
// uncommitted launch) and the graduation event. A relayer is a pair of hands, never a party.
address collectionOwner = collection.owner();
if (msg.sender != collectionOwner) {
// A relay carries EXACTLY the launch fee and nothing else, so it can neither fund a dev
// buy for itself nor push native into the two callees that refuse it. The fee was
// already taken in `graduateAndBuy`; a relayer pays gas and the fee, like the stock path.
require(msg.value == launchFee, "RELAY_FEE_ONLY");
bytes32 consent = graduationOptIn[input.collection];
require(consent != bytes32(0), "NOT_OPTED_IN");
require(consent == relayParamsHash(input, holderShareBps), "RELAY_PARAMS_MISMATCH");
}
// AFTER the consent check, deliberately. A relayer who deviates by one byte is told exactly
// that, rather than being told the mutated field is invalid — which would make a
// parameter-substitution attempt indistinguishable from an ordinary malformed launch.
require(peddlesFactory.isVariantSupported(input.variant), "UNSUPPORTED_VARIANT");
uint8 tokenDecimals = _validateAssetParams(input.params);
require(collection.graduationReady(), "NOT_READY");
require(!collection.graduated(), "ALREADY_GRADUATED");
require(input.vaultInput.creator == collectionOwner, "CREATOR_MISMATCH");
require(input.vaultInput.token == address(0), "TOKEN_SET_BY_ORCHESTRATOR");
_validateBondingRules(input.vaultInput);
// A clog variant graduated through this path would mint no clog vault while its
// declared allocation says one exists — supply silently returned to the pool and a
// launch page describing something that did not happen. Refuse it outright.
// Read straight from the factory: `_allocationFor` lives on the launch orchestrator,
// which is a SIBLING of this contract, not a parent. Variant 0 reports no clog.
(,,,, uint16 gradClogBps,,) = peddlesFactory.variantAllocation(input.variant);
require(gradClogBps == 0, "CLOG_NOT_ON_GRADUATION");
uint256 total = _validateAmounts(input.vaultInput);
_validateOneBillionSupply(total, tokenDecimals);
// Resolved BEFORE anything is created, so a wrong split statement fails for free.
address distributor = _holderDistributor(input.collection, holderShareBps);
address predictedToken = peddlesFactory.getPeddlesAddress(input.variant, address(this), input.salt);
PeddlesVaultFactoryV20.CreateVaultsInput memory vaultInput = _lockSchedule(input.vaultInput);
vaultInput.token = predictedToken;
IPeddlesVaultRegistryV20.VaultSet memory predictedVaults = vaultFactory.predictFourVaults(vaultInput);
bytes[] memory initCalls =
_withRequiredRoles(input.initCalls, predictedVaults.burnVault, collectionOwner, total);
token = peddlesFactory.createPeddles{value: input.factoryValue}(input.variant, input.salt, input.params, initCalls);
require(token == predictedToken, "TOKEN_PREDICTION_MISMATCH");
vaults = vaultFactory.createFourVaults(vaultInput);
// Compare the WHOLE set, not just the burn vault. A skipped vault predicts and
// deploys address(0), so an all-four compare is the only thing that proves the
// prediction the BURN_ROLE grant above was built from still describes reality —
// and that the factory skipped exactly the vaults this launch expected it to.
require(
vaults.liquidityVault == predictedVaults.liquidityVault
&& vaults.airdropVault == predictedVaults.airdropVault
&& vaults.vestingVault == predictedVaults.vestingVault
&& vaults.burnVault == predictedVaults.burnVault,
"VAULT_PREDICTION_MISMATCH"
);
_mintAllocations(token, vaults, input.vaultInput, total);
collection.recordPeddlesGraduation(
token,
vaults.liquidityVault,
vaults.vestingVault,
vaults.airdropVault,
vaults.burnVault
);
// The router is excluded here as on the launch path: it holds the token mid-sell, and an
// eligible router would be credited rewards nobody can ever claim.
//
// A committed launch registers THIS contract as the pool's creator, so that it — and only
// it, and only here — can bind the payout to the distributor. `vaultInput.creator` and
// the token's METADATA_ROLE stay the human.
_registerWithFeeHook(
token,
distributor == address(0) ? collectionOwner : address(this),
input.creatorTaxBps,
input.excessToCreatorBps,
vaults,
address(0),
swapRouter
);
(poolId, positionId) = _activate(
token,
input.amountPeddles,
input.sqrtPriceX96,
input.tickLower,
input.tickUpper,
input.liquidity,
liquidityValue
);
if (distributor != address(0)) _commitHolderFees(input.collection, token, distributor, poolId, holderShareBps);
_verifyRegistry(token, vaults, poolId, positionId);
IPeddlesTokenV20(token).renounceRole(MINT_ROLE, address(this));
IPeddlesTokenV20(token).renounceLastAdmin();
emit NFTBondingGraduatedV20(
input.collection,
collectionOwner,
token,
vaults.liquidityVault,
vaults.airdropVault,
vaults.vestingVault,
vaults.burnVault,
input.creatorTaxBps,
input.excessToCreatorBps,
poolId,
positionId
);
}
/// @dev The collection's canonical distributor, or zero when it has none.
///
/// Committed means: `collection.holderRewards()` is non-zero AND the distributor factory built
/// it. A legacy or foreign distributor is simply not a commitment. A canonical distributor
/// built for ANOTHER collection is refused outright — minters were shown a Peddles distributor,
/// so a launch must not quietly treat it as uncommitted.
function _holderDistributor(address collection, uint16 holderShareBps) private view returns (address d) {
(bool ok, bytes memory ret) = collection.staticcall(abi.encodeWithSignature("holderRewards()"));
if (ok && ret.length >= 32) d = abi.decode(ret, (address));
if (d == address(0) || !nftFeeDistributorFactory.isDistributor(d)) {
require(holderShareBps == 0, "NO_HOLDER_DISTRIBUTOR");
return address(0);
}
require(IPeddlesNftFeeDistributorV20(d).collection() == collection, "DISTRIBUTOR_COLLECTION_MISMATCH");
}
/// @dev Bind the pool's creator leg to the distributor and fix its assets and split. Runs after
/// activation (the pool id exists) and before this transaction ends, so no swap by anyone else
/// can precede it. Neither call is best-effort. There is no other call site of
/// `setCreatorPayout` in this contract, so the binding can never move.
function _commitHolderFees(
address collection,
address token,
address distributor,
bytes32 poolId,
uint16 holderShareBps
) private {
feeHook.setCreatorPayout(poolId, distributor);
IPeddlesNftFeeDistributorV20(distributor).initAssets(
liquidityExecutor.quoteToken(), token, feeHook.poolConfig(poolId).rewards, holderShareBps
);
emit HolderFeesCommitted(collection, token, distributor, poolId, holderShareBps);
}
/// @dev NFT bonding graduation is a 100% LIQUIDITY launch: the entire supply goes into
/// the permanently locked single-sided position at graduation. No airdrop, no vesting and
/// no burn allocation, so the vault factory deploys only the liquidity vault.
///
/// The former 6000/1000/1000/2000 split is now REJECTED here — it was a `require`, not a
/// setting, so 100% liquidity was unreachable on this path.
///
/// The vesting/airdrop/burn SCHEDULE requires that used to sit alongside it (60d cliff /
/// 540d duration, 10 x 10d airdrop epochs, 1000 bps first burn and default vote) are
/// DROPPED rather than kept inert. With the three allocations hard-pinned to zero on this
/// path they can never change an outcome: no vesting vault, airdrop vault or burn vault is
/// constructed from them, so they would be dead constants an auditor has to disprove, and
/// dead constants are exactly how an unsatisfiable require gets missed. They are not left
/// unchecked either — `PeddlesVaultFactoryV20._validate` still enforces the floor they
/// genuinely need (vestingDuration > 0 with cliff <= duration, non-zero airdrop epoch
/// length and count, non-zero burn epoch length) because the airdrop and burn schedules
/// are written into the registry on every launch and the registry rejects zeros. That
/// floor is also what keeps a later setter flip back to a non-zero split constructable.
function _validateBondingRules(PeddlesVaultFactoryV20.CreateVaultsInput calldata input) internal view {
require(input.liquidityBps == 10_000, "BONDING_LIQUIDITY_MUST_BE_100");
require(input.airdropBps == 0, "BONDING_AIRDROP_MUST_BE_0");
require(input.vestingBps == 0, "BONDING_VESTING_MUST_BE_0");
require(input.burnBps == 0, "BONDING_BURN_MUST_BE_0");
// vaultBps mirrors airdrop + burn, and an "enabled" airdrop with no allocation would
// mark an active registry airdrop schedule against a vault that does not exist.
require(input.vaultBps == 0 && !input.airdropEnabled, "BONDING_VAULT_MUST_BE_0");
_validatePoolConfig(input);
}
}
Compiler settingsShow
{
"viaIR": true,
"metadata": {
"appendCBOR": false,
"bytecodeHash": "none",
"useLiteralContent": false
},
"libraries": {
"src/perp/library/PeddlesPerpLib.sol": {
"PeddlesPerpLib": "0x8fC3b671ccAD296d38c008a31e2a20C51e3B25FA"
},
"src/perp/library/PeddlesPerpLong.sol": {
"PeddlesPerpLong": "0x0A0b78348Be1a37eCf5Fe99EaB74B28A8eA9d941"
},
"src/perp/library/PeddlesPerpExits.sol": {
"PeddlesPerpExits": "0xe4600aaF6EEd091E317f1e25d79aa742CA81dB47"
},
"src/perp/library/PeddlesPerpShort.sol": {
"PeddlesPerpShort": "0x65997dC3a9C549A11a8695cc56f8759655064634"
},
"src/perp/library/PeddlesPerpReserve.sol": {
"PeddlesPerpReserve": "0x24ed8808Ae2f404D9C0ffadd329aFfD9E6a10Ac2"
}
},
"optimizer": {
"runs": 200,
"enabled": true
},
"evmVersion": "cancun",
"remappings": [
"forge-std/=lib/forge-std/src/",
"@uniswap/v4-core/=lib/v4-core/",
"@uniswap/v4-periphery/=lib/v4-periphery/",
"solady/=lib/solady/",
"@openzeppelin/contracts/=lib/infinity-core/lib/openzeppelin-contracts/contracts/",
"permit2/=lib/v4-periphery/lib/permit2/",
"infinity-core/=lib/infinity-core/",
"lib/infinity-core/lib/pancake-create3-factory/lib/openzeppelin-contracts/lib/forge-std/:ds-test/=lib/infinity-core/lib/pancake-create3-factory/lib/openzeppelin-contracts/lib/forge-std/lib/ds-test/src/",
"lib/infinity-core/lib/pancake-create3-factory/lib/openzeppelin-contracts/lib/forge-std/:ds-test/=lib/infinity-core/lib/pancake-create3-factory/lib/openzeppelin-contracts/lib/forge-std/lib/ds-test/src/",
"lib/v4-periphery/lib/permit2/lib/forge-gas-snapshot/lib/forge-std/:ds-test/=lib/v4-periphery/lib/permit2/lib/forge-gas-snapshot/lib/forge-std/lib/ds-test/src/",
"lib/v4-periphery/lib/permit2/lib/forge-gas-snapshot/lib/forge-std/:ds-test/=lib/v4-periphery/lib/permit2/lib/forge-gas-snapshot/lib/forge-std/lib/ds-test/src/",
"lib/v4-periphery/lib/v4-core/lib/openzeppelin-contracts/lib/forge-std/:ds-test/=lib/v4-periphery/lib/v4-core/lib/openzeppelin-contracts/lib/forge-std/lib/ds-test/src/",
"lib/v4-periphery/lib/v4-core/lib/openzeppelin-contracts/lib/forge-std/:ds-test/=lib/v4-periphery/lib/v4-core/lib/openzeppelin-contracts/lib/forge-std/lib/ds-test/src/",
"lib/infinity-core/lib/openzeppelin-contracts/lib/forge-std/:ds-test/=lib/infinity-core/lib/openzeppelin-contracts/lib/forge-std/lib/ds-test/src/",
"lib/infinity-core/lib/openzeppelin-contracts/lib/forge-std/:ds-test/=lib/infinity-core/lib/openzeppelin-contracts/lib/forge-std/lib/ds-test/src/",
"lib/infinity-core/lib/pancake-create3-factory/lib/openzeppelin-contracts/:erc4626-tests/=lib/infinity-core/lib/pancake-create3-factory/lib/openzeppelin-contracts/lib/erc4626-tests/",
"lib/infinity-core/lib/pancake-create3-factory/lib/openzeppelin-contracts/:erc4626-tests/=lib/infinity-core/lib/pancake-create3-factory/lib/openzeppelin-contracts/lib/erc4626-tests/",
"lib/v4-core/lib/openzeppelin-contracts/lib/forge-std/:ds-test/=lib/v4-core/lib/openzeppelin-contracts/lib/forge-std/lib/ds-test/src/",
"lib/v4-core/lib/openzeppelin-contracts/lib/forge-std/:ds-test/=lib/v4-core/lib/openzeppelin-contracts/lib/forge-std/lib/ds-test/src/",
"lib/v4-periphery/lib/permit2/lib/forge-std/:ds-test/=lib/v4-periphery/lib/permit2/lib/forge-std/lib/ds-test/src/",
"lib/v4-periphery/lib/permit2/lib/forge-std/:ds-test/=lib/v4-periphery/lib/permit2/lib/forge-std/lib/ds-test/src/",
"lib/v4-periphery/lib/permit2/lib/solmate/:ds-test/=lib/v4-periphery/lib/permit2/lib/solmate/lib/ds-test/src/",
"lib/v4-periphery/lib/permit2/lib/solmate/:ds-test/=lib/v4-periphery/lib/permit2/lib/solmate/lib/ds-test/src/",
"lib/v4-periphery/lib/v4-core/lib/openzeppelin-contracts/:erc4626-tests/=lib/v4-periphery/lib/v4-core/lib/openzeppelin-contracts/lib/erc4626-tests/",
"lib/v4-periphery/lib/v4-core/lib/openzeppelin-contracts/:erc4626-tests/=lib/v4-periphery/lib/v4-core/lib/openzeppelin-contracts/lib/erc4626-tests/",
"lib/v4-periphery/lib/v4-core/lib/solmate/:ds-test/=lib/v4-periphery/lib/v4-core/lib/solmate/lib/ds-test/src/",
"lib/v4-periphery/lib/v4-core/lib/solmate/:ds-test/=lib/v4-periphery/lib/v4-core/lib/solmate/lib/ds-test/src/",
"lib/infinity-core/lib/openzeppelin-contracts/:erc4626-tests/=lib/infinity-core/lib/openzeppelin-contracts/lib/erc4626-tests/",
"lib/infinity-core/lib/openzeppelin-contracts/:erc4626-tests/=lib/infinity-core/lib/openzeppelin-contracts/lib/erc4626-tests/",
"lib/infinity-core/lib/pancake-create3-factory/:forge-gas-snapshot/=lib/infinity-core/lib/pancake-create3-factory/lib/forge-gas-snapshot/src/",
"lib/infinity-core/lib/pancake-create3-factory/:forge-gas-snapshot/=lib/infinity-core/lib/pancake-create3-factory/lib/forge-gas-snapshot/src/",
"lib/infinity-core/lib/pancake-create3-factory/:openzeppelin-contracts/=lib/infinity-core/lib/pancake-create3-factory/lib/openzeppelin-contracts/",
"lib/infinity-core/lib/pancake-create3-factory/:openzeppelin-contracts/=lib/infinity-core/lib/pancake-create3-factory/lib/openzeppelin-contracts/",
"lib/infinity-core/lib/solmate/:ds-test/=lib/infinity-core/lib/solmate/lib/ds-test/src/",
"lib/infinity-core/lib/solmate/:ds-test/=lib/infinity-core/lib/solmate/lib/ds-test/src/",
"lib/v4-core/lib/openzeppelin-contracts/:erc4626-tests/=lib/v4-core/lib/openzeppelin-contracts/lib/erc4626-tests/",
"lib/v4-core/lib/openzeppelin-contracts/:erc4626-tests/=lib/v4-core/lib/openzeppelin-contracts/lib/erc4626-tests/",
"lib/v4-core/lib/solmate/:ds-test/=lib/v4-core/lib/solmate/lib/ds-test/src/",
"lib/v4-core/lib/solmate/:ds-test/=lib/v4-core/lib/solmate/lib/ds-test/src/",
"lib/v4-periphery/lib/permit2/:solmate/=lib/v4-periphery/lib/permit2/lib/solmate/",
"lib/v4-periphery/lib/permit2/:solmate/=lib/v4-periphery/lib/permit2/lib/solmate/",
"lib/v4-periphery/lib/permit2/:forge-gas-snapshot/=lib/v4-periphery/lib/permit2/lib/forge-gas-snapshot/src/",
"lib/v4-periphery/lib/permit2/:forge-gas-snapshot/=lib/v4-periphery/lib/permit2/lib/forge-gas-snapshot/src/",
"lib/v4-periphery/lib/permit2/:openzeppelin-contracts/=lib/v4-periphery/lib/permit2/lib/openzeppelin-contracts/",
"lib/v4-periphery/lib/permit2/:openzeppelin-contracts/=lib/v4-periphery/lib/permit2/lib/openzeppelin-contracts/",
"lib/v4-periphery/lib/v4-core/:solmate/=lib/v4-periphery/lib/v4-core/lib/solmate/",
"lib/v4-periphery/lib/v4-core/:solmate/=lib/v4-periphery/lib/v4-core/lib/solmate/",
"lib/v4-periphery/lib/v4-core/:openzeppelin-contracts/=lib/v4-periphery/lib/v4-core/lib/openzeppelin-contracts/",
"lib/v4-periphery/lib/v4-core/:openzeppelin-contracts/=lib/v4-periphery/lib/v4-core/lib/openzeppelin-contracts/",
"lib/infinity-core/:solmate/=lib/infinity-core/lib/solmate/",
"lib/infinity-core/:solmate/=lib/infinity-core/lib/solmate/",
"lib/infinity-core/:openzeppelin-contracts/=lib/infinity-core/lib/openzeppelin-contracts/",
"lib/infinity-core/:openzeppelin-contracts/=lib/infinity-core/lib/openzeppelin-contracts/",
"lib/v4-core/:solmate/=lib/v4-core/lib/solmate/",
"lib/v4-core/:solmate/=lib/v4-core/lib/solmate/",
"lib/v4-core/:openzeppelin-contracts/=lib/v4-core/lib/openzeppelin-contracts/",
"lib/v4-core/:openzeppelin-contracts/=lib/v4-core/lib/openzeppelin-contracts/",
"lib/v4-periphery/:v4-core/=lib/v4-periphery/lib/v4-core/src/",
"lib/v4-periphery/:v4-core/=lib/v4-periphery/lib/v4-core/src/",
"@ensdomains/=lib/v4-core/node_modules/@ensdomains/",
"@openzeppelin/=lib/infinity-core/lib/openzeppelin-contracts/",
"ds-test/=lib/infinity-core/lib/forge-std/lib/ds-test/src/",
"erc4626-tests/=lib/infinity-core/lib/openzeppelin-contracts/lib/erc4626-tests/",
"forge-gas-snapshot/=lib/infinity-core/lib/forge-gas-snapshot/src/",
"halmos-cheatcodes/=lib/infinity-core/lib/openzeppelin-contracts/lib/halmos-cheatcodes/src/",
"hardhat/=lib/v4-core/node_modules/hardhat/",
"openzeppelin-contracts/=lib/infinity-core/lib/openzeppelin-contracts/",
"pancake-create3-factory/=lib/infinity-core/lib/pancake-create3-factory/",
"solmate/=lib/infinity-core/lib/solmate/",
"v4-core/=lib/v4-core/src/",
"v4-periphery/=lib/v4-periphery/"
]
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.