Verified contractPartialMIT
AnyPairLaunchGateway
Address0xca7af38b09c49a87d8a3936f47972365bf41531c
- Balance
0 ETH
- Transactions
260
- 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,049,900
- Creation transaction
- 0x8d21f98ea8…c57d7df2a8
2 files
src/AnyPairLaunchGateway.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;
import {ReentrancyGuard} from "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
interface IGatewayVaultFactory {
function predictVault(address asset) external view returns (address);
function getOrCreateVault(address asset) external returns (address);
}
interface IGatewayAssetVault {
function depositFrom(address owner, uint256 assets, address receiver, uint256 minSharesOut)
external returns (uint256 shares, uint256 receivedAssets);
}
/// @dev Engines keep their own immutable pool, fee and token state. New engine versions
/// implement this boundary while choosing their own launchData encoding.
interface IAnyPairLaunchEngine {
function launchGateway() external view returns (address);
function vaultFactory() external view returns (address);
function isKlikToken(address token) external view returns (bool);
function creatorOf(address token) external view returns (address);
function launchFromGateway(
address creator,
address fundingAsset,
uint256 assetsIn,
uint256 sharesIn,
bytes calldata launchData
) external payable returns (address token, uint256 tokensReceived);
}
/// @notice A permanent launch address with future-only version selection. This contract
/// is not a proxy: it never delegatecalls an engine, owns no liquidity or fee escrow,
/// and cannot change existing token/engine bindings or spend another caller's allowance.
contract AnyPairLaunchGateway is ReentrancyGuard {
address public immutable controller;
address public activeEngine;
address[] public engines;
mapping(address => bool) public registeredEngine;
mapping(address => uint256) public engineRegistrationBlock;
mapping(address => address) public engineOf;
struct LaunchCall {
address expectedEngine;
// Zero for ETH funding, including an ETH -> underlying routed creator buy.
address fundingAsset;
// Exact vault the user approved. Zero for native funding.
address expectedVault;
uint256 assetsIn;
uint256 minSharesOut;
uint256 deadline;
bytes launchData;
}
event LaunchEngineSelected(address indexed previousEngine, address indexed engine);
event EngineRegistered(address indexed engine, uint256 indexed version);
event TokenLaunched(address indexed token, address indexed creator, address indexed engine);
constructor(address controller_) {
require(controller_ != address(0), "zero controller");
controller = controller_;
}
/// @notice Changes only which engine may receive a NEW launch. Previously registered
/// engines and each token's original binding remain queryable forever.
function setLaunchEngine(address engine) external {
require(msg.sender == controller, "only controller");
require(engine.code.length != 0, "invalid engine");
require(IAnyPairLaunchEngine(engine).launchGateway() == address(this), "wrong gateway");
address previous = activeEngine;
if (!registeredEngine[engine]) {
registeredEngine[engine] = true;
engineRegistrationBlock[engine] = block.number;
engines.push(engine);
emit EngineRegistered(engine, engines.length - 1);
}
activeEngine = engine;
emit LaunchEngineSelected(previous, engine);
}
function engineCount() external view returns (uint256) {
return engines.length;
}
/// @notice Forward this caller's explicitly bounded payment to the selected version.
/// The caller signs both engine and vault addresses, so a default change never
/// silently sends an already prepared transaction to another version.
function launch(LaunchCall calldata request)
external payable nonReentrant returns (address token, uint256 tokensReceived)
{
address engine = request.expectedEngine;
require(engine != address(0) && engine == activeEngine, "launch version changed");
require(block.timestamp <= request.deadline, "launch expired");
uint256 shares;
if (request.fundingAsset == address(0)) {
require(request.expectedVault == address(0) && request.minSharesOut == 0, "native funding has no vault");
require(msg.value == request.assetsIn, "native amount mismatch");
} else {
require(msg.value == 0, "unexpected ETH");
IGatewayVaultFactory registry = IGatewayVaultFactory(IAnyPairLaunchEngine(engine).vaultFactory());
require(request.expectedVault == registry.predictVault(request.fundingAsset), "vault changed");
address vault = registry.getOrCreateVault(request.fundingAsset);
require(vault == request.expectedVault, "vault mismatch");
if (request.assetsIn != 0) {
// No engine-controlled payer, receiver or deposit callback exists.
// Even a malicious future engine cannot spend previous users' approvals.
(shares,) = IGatewayAssetVault(vault).depositFrom(
msg.sender, request.assetsIn, engine, request.minSharesOut
);
} else {
require(request.minSharesOut == 0, "zero deposit minimum");
}
}
(token, tokensReceived) = IAnyPairLaunchEngine(engine).launchFromGateway{value: msg.value}(
msg.sender, request.fundingAsset, request.assetsIn, shares, request.launchData
);
require(token.code.length != 0 && engineOf[token] == address(0), "invalid launched token");
require(IAnyPairLaunchEngine(engine).isKlikToken(token), "unregistered token");
require(IAnyPairLaunchEngine(engine).creatorOf(token) == msg.sender, "wrong creator");
engineOf[token] = engine;
emit TokenLaunched(token, msg.sender, engine);
}
}
lib/openzeppelin-contracts/contracts/utils/ReentrancyGuard.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/ReentrancyGuard.sol)
pragma solidity ^0.8.20;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant NOT_ENTERED = 1;
uint256 private constant ENTERED = 2;
uint256 private _status;
/**
* @dev Unauthorized reentrant call.
*/
error ReentrancyGuardReentrantCall();
constructor() {
_status = NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
// On the first call to nonReentrant, _status will be NOT_ENTERED
if (_status == ENTERED) {
revert ReentrancyGuardReentrantCall();
}
// Any calls to nonReentrant after this point will fail
_status = ENTERED;
}
function _nonReentrantAfter() private {
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = NOT_ENTERED;
}
/**
* @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
* `nonReentrant` function in the call stack.
*/
function _reentrancyGuardEntered() internal view returns (bool) {
return _status == ENTERED;
}
}
Compiler settingsShow
{
"viaIR": true,
"metadata": {
"appendCBOR": true,
"bytecodeHash": "ipfs",
"useLiteralContent": false
},
"libraries": {},
"optimizer": {
"runs": 200,
"enabled": true
},
"evmVersion": "cancun",
"remappings": [
"forge-std/=lib/forge-std/src/",
"v4-core/=lib/v4-core/",
"@uniswap/v4-core/=lib/v4-core/",
"@uniswap/v4-periphery/=lib/v4-periphery/",
"@openzeppelin/=lib/openzeppelin-contracts/",
"provenance/reference-hooklabs/:@openzeppelin/=provenance/reference-hooklabs/openzeppelin/",
"provenance/reference-hooklabs/:@openzeppelin/=provenance/reference-hooklabs/openzeppelin/",
"openzeppelin-contracts/=lib/openzeppelin-contracts/contracts/",
"v4-periphery/=lib/v4-periphery/src/"
]
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.