Verified contractExactMIT
FugaziFactory
Address0xf983f5a03051fdff6c8e2ab479aba0e5b3fa4802
- Balance
0.01 ETH
- Transactions
8
- Compiler
solc 0.8.24
- Same code
Only this contract
Details
- Compiler
- solc 0.8.24+commit.e11b9ed9
- Language
- solidity
- Optimization
- Yes, 200 runs
- EVM version
- cancun
- Via IR
- yes
- License
- MIT
- Match
- Exactcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 25,968,709
- Creation transaction
- 0x890a4c7978…6bfffd2ffd
4 files
- src/FugaziFactory.solmain13.5 KB
- src/FugaziToken.sol2.79 KB
- src/interfaces/IERC20Minimal.sol404 B
- src/interfaces/ILiquidityLauncher.sol982 B
src/FugaziFactory.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
import {FugaziToken} from "./FugaziToken.sol";
import {IERC20Minimal} from "./interfaces/IERC20Minimal.sol";
import {ILiquidityLauncher} from "./interfaces/ILiquidityLauncher.sol";
/// @notice Charges a native-token fee and launches fixed-supply tokens into token-only LPs.
contract FugaziFactory {
uint256 public constant FEE_SHARE_DENOMINATOR = 10_000;
uint256 public constant MIN_LIQUIDITY_SHARE_BPS = 9900;
address public immutable RESERVE_TOKEN;
uint256 public immutable TOKEN_SUPPLY;
address public owner;
address public pendingOwner;
address public liquidityLauncher;
address public liquidityRecipient;
address public feeTreasury;
uint16 public burnFeeShareBps;
uint16 public creatorFeeShareBps;
uint16 public treasuryFeeShareBps;
uint256 public deploymentFee;
/// @notice Reserve-token amount paired with the full FugaziToken supply to set the initial price.
uint256 public RESERVE_TOKEN_LIQUIDITY_AMOUNT;
/// @notice Liquidity used for future token-only positions.
uint128 public positionLiquidity;
mapping(address => bool) public isFugaziToken;
mapping(bytes32 => address) public tokenByMetadata;
address[] public allTokens;
uint256 private locked = 1;
error DuplicateToken();
error IncorrectDeploymentFee();
error InvalidAddress();
error InvalidAmount();
error InvalidMetadata();
error LiquidityCreationFailed();
error NativeTransferFailed();
error NotOwner();
error NotPendingOwner();
error ReentrantCall();
error TokenTransferFailed();
event TokenLaunched(
address indexed creator,
address indexed token,
bytes32 indexed poolId,
uint256 positionId,
uint256 liquidityAmount,
uint256 initialBuyAmount,
uint256 initialTokensBought,
string name,
string symbol,
string description,
string image
);
event DeploymentFeeUpdated(uint256 oldFee, uint256 newFee);
event LaunchConfigUpdated(uint256 reserveTokenLiquidityAmount, uint128 positionLiquidity);
event LiquidityLauncherUpdated(address indexed oldLauncher, address indexed newLauncher);
event LiquidityRecipientUpdated(address indexed oldRecipient, address indexed newRecipient);
event SwapFeeConfigUpdated(
address indexed treasury,
uint16 burnShareBps,
uint16 creatorShareBps,
uint16 treasuryShareBps
);
event OwnershipTransferred(address indexed oldOwner, address indexed newOwner);
event OwnershipTransferStarted(address indexed owner, address indexed pendingOwner);
event FeesWithdrawn(address indexed recipient, uint256 amount);
modifier onlyOwner() {
_checkOwner();
_;
}
modifier nonReentrant() {
_beforeNonReentrant();
_;
_afterNonReentrant();
}
function _checkOwner() internal view {
if (msg.sender != owner) revert NotOwner();
}
function _beforeNonReentrant() internal {
if (locked != 1) revert ReentrantCall();
locked = 2;
}
function _afterNonReentrant() internal {
locked = 1;
}
constructor(
address owner_,
address reserveToken_,
address liquidityLauncher_,
address liquidityRecipient_,
uint256 tokenSupply_,
uint256 deploymentFee_,
uint256 reserveTokenLiquidityAmount_,
uint128 positionLiquidity_,
address feeTreasury_,
uint16 burnFeeShareBps_,
uint16 creatorFeeShareBps_,
uint16 treasuryFeeShareBps_
) {
if (
owner_ == address(0) || reserveToken_ == address(0) || liquidityRecipient_ == address(0)
|| feeTreasury_ == address(0) || reserveToken_.code.length == 0
|| (liquidityLauncher_ != address(0) && liquidityLauncher_.code.length == 0)
) revert InvalidAddress();
if (
tokenSupply_ == 0 || tokenSupply_ > type(uint128).max
|| reserveTokenLiquidityAmount_ == 0
|| reserveTokenLiquidityAmount_ > type(uint128).max || positionLiquidity_ == 0
) revert InvalidAmount();
_validateFeeShares(burnFeeShareBps_, creatorFeeShareBps_, treasuryFeeShareBps_);
owner = owner_;
RESERVE_TOKEN = reserveToken_;
liquidityLauncher = liquidityLauncher_;
liquidityRecipient = liquidityRecipient_;
TOKEN_SUPPLY = tokenSupply_;
deploymentFee = deploymentFee_;
RESERVE_TOKEN_LIQUIDITY_AMOUNT = reserveTokenLiquidityAmount_;
positionLiquidity = positionLiquidity_;
feeTreasury = feeTreasury_;
burnFeeShareBps = burnFeeShareBps_;
creatorFeeShareBps = creatorFeeShareBps_;
treasuryFeeShareBps = treasuryFeeShareBps_;
emit OwnershipTransferred(address(0), owner_);
emit SwapFeeConfigUpdated(
feeTreasury_, burnFeeShareBps_, creatorFeeShareBps_, treasuryFeeShareBps_
);
emit LaunchConfigUpdated(reserveTokenLiquidityAmount_, positionLiquidity_);
}
/// @notice Deploys a token and puts at least 99% of its supply into a one-sided LP.
/// @dev Social links remain encoded in `description`, matching the existing Fugazi form:
/// `[twitter]...[/twitter][telegram]...[/telegram][website]...[/website]`.
function deployToken(
string calldata name,
string calldata symbol,
string calldata description,
string calldata image,
uint256 initialBuyAmount
) external payable nonReentrant returns (address token, bytes32 poolId, uint256 positionId) {
if (msg.value != deploymentFee) revert IncorrectDeploymentFee();
if (initialBuyAmount == 0 || initialBuyAmount > uint256(uint128(type(int128).max))) {
revert InvalidAmount();
}
if (bytes(name).length == 0 || bytes(symbol).length == 0 || bytes(image).length == 0) {
revert InvalidMetadata();
}
bytes32 metadataHash = keccak256(abi.encode(name, symbol, description, image));
if (tokenByMetadata[metadataHash] != address(0)) revert DuplicateToken();
token = address(new FugaziToken(name, symbol, description, image, msg.sender, TOKEN_SUPPLY));
isFugaziToken[token] = true;
tokenByMetadata[metadataHash] = token;
allTokens.push(token);
address launcher = liquidityLauncher;
if (launcher == address(0)) revert LiquidityCreationFailed();
_safeApprove(token, launcher, TOKEN_SUPPLY);
uint256 reserveBalanceBefore = IERC20Minimal(RESERVE_TOKEN).balanceOf(address(this));
_safeTransferFrom(RESERVE_TOKEN, msg.sender, address(this), initialBuyAmount);
if (
IERC20Minimal(RESERVE_TOKEN).balanceOf(address(this)) - reserveBalanceBefore
!= initialBuyAmount
) revert TokenTransferFailed();
_safeApprove(RESERVE_TOKEN, launcher, initialBuyAmount);
uint256 amountUsed;
uint256 amountBought;
(poolId, positionId, amountUsed, amountBought) = ILiquidityLauncher(launcher)
.createPoolAndSeedAndBuy(
token,
RESERVE_TOKEN,
TOKEN_SUPPLY,
liquidityRecipient,
RESERVE_TOKEN_LIQUIDITY_AMOUNT,
positionLiquidity,
initialBuyAmount,
msg.sender
);
if (
poolId == bytes32(0) || amountUsed > TOKEN_SUPPLY || amountBought == 0
|| amountUsed < TOKEN_SUPPLY * MIN_LIQUIDITY_SHARE_BPS / FEE_SHARE_DENOMINATOR
) {
revert LiquidityCreationFailed();
}
_safeApprove(token, launcher, 0);
_safeApprove(RESERVE_TOKEN, launcher, 0);
// Return the at-most-1% remainder plus concentrated-liquidity rounding dust to the creator.
uint256 dust = IERC20Minimal(token).balanceOf(address(this));
if (dust != 0) _safeTransfer(token, msg.sender, dust);
emit TokenLaunched(
msg.sender,
token,
poolId,
positionId,
amountUsed,
initialBuyAmount,
amountBought,
name,
symbol,
description,
image
);
}
function tokenCount() external view returns (uint256) {
return allTokens.length;
}
function setDeploymentFee(uint256 newFee) external onlyOwner {
emit DeploymentFeeUpdated(deploymentFee, newFee);
deploymentFee = newFee;
}
/// @notice Updates the price and matching LP liquidity used by future launches.
/// @dev Existing pools are unaffected because their initial price and positions are immutable.
function setLaunchConfig(uint256 newReserveTokenLiquidityAmount, uint128 newPositionLiquidity)
external
onlyOwner
{
if (
newReserveTokenLiquidityAmount == 0
|| newReserveTokenLiquidityAmount > type(uint128).max || newPositionLiquidity == 0
) revert InvalidAmount();
RESERVE_TOKEN_LIQUIDITY_AMOUNT = newReserveTokenLiquidityAmount;
positionLiquidity = newPositionLiquidity;
emit LaunchConfigUpdated(newReserveTokenLiquidityAmount, newPositionLiquidity);
}
function setLiquidityLauncher(address newLauncher) external onlyOwner {
if (newLauncher == address(0) || newLauncher.code.length == 0) revert InvalidAddress();
emit LiquidityLauncherUpdated(liquidityLauncher, newLauncher);
liquidityLauncher = newLauncher;
}
function setLiquidityRecipient(address newRecipient) external onlyOwner {
if (newRecipient == address(0)) revert InvalidAddress();
emit LiquidityRecipientUpdated(liquidityRecipient, newRecipient);
liquidityRecipient = newRecipient;
}
/// @notice Updates the reserve-token fee recipients and shares used by the V4 hook.
/// @dev Shares use basis points and must add up to 10,000. The hook reads these values on swap.
function setSwapFeeConfig(
address newTreasury,
uint16 newBurnShareBps,
uint16 newCreatorShareBps,
uint16 newTreasuryShareBps
) external onlyOwner {
if (newTreasury == address(0)) revert InvalidAddress();
_validateFeeShares(newBurnShareBps, newCreatorShareBps, newTreasuryShareBps);
feeTreasury = newTreasury;
burnFeeShareBps = newBurnShareBps;
creatorFeeShareBps = newCreatorShareBps;
treasuryFeeShareBps = newTreasuryShareBps;
emit SwapFeeConfigUpdated(
newTreasury, newBurnShareBps, newCreatorShareBps, newTreasuryShareBps
);
}
function swapFeeConfig()
external
view
returns (
address treasury,
uint16 burnShareBps,
uint16 creatorShareBps,
uint16 treasuryShareBps
)
{
return (feeTreasury, burnFeeShareBps, creatorFeeShareBps, treasuryFeeShareBps);
}
function transferOwnership(address newOwner) external onlyOwner {
if (newOwner == address(0)) revert InvalidAddress();
pendingOwner = newOwner;
emit OwnershipTransferStarted(owner, newOwner);
}
function acceptOwnership() external {
if (msg.sender != pendingOwner) revert NotPendingOwner();
address oldOwner = owner;
owner = msg.sender;
pendingOwner = address(0);
emit OwnershipTransferred(oldOwner, msg.sender);
}
function withdrawFees(address payable recipient, uint256 amount)
external
onlyOwner
nonReentrant
{
if (recipient == address(0)) revert InvalidAddress();
if (amount > address(this).balance) revert InvalidAmount();
(bool success,) = recipient.call{value: amount}("");
if (!success) revert NativeTransferFailed();
emit FeesWithdrawn(recipient, amount);
}
function _safeApprove(address token, address spender, uint256 amount) internal {
(bool success, bytes memory result) =
token.call(abi.encodeCall(IERC20Minimal.approve, (spender, amount)));
if (!success || (result.length != 0 && !abi.decode(result, (bool)))) {
revert TokenTransferFailed();
}
}
function _validateFeeShares(
uint16 burnShareBps,
uint16 creatorShareBps,
uint16 treasuryShareBps
) internal pure {
if (
burnShareBps == 0 || creatorShareBps == 0 || treasuryShareBps == 0
|| uint256(burnShareBps) + creatorShareBps + treasuryShareBps
!= FEE_SHARE_DENOMINATOR
) revert InvalidAmount();
}
function _safeTransfer(address token, address to, uint256 amount) internal {
(bool success, bytes memory result) =
token.call(abi.encodeCall(IERC20Minimal.transfer, (to, amount)));
if (!success || (result.length != 0 && !abi.decode(result, (bool)))) {
revert TokenTransferFailed();
}
}
function _safeTransferFrom(address token, address from, address to, uint256 amount) internal {
(bool success, bytes memory result) =
token.call(abi.encodeCall(IERC20Minimal.transferFrom, (from, to, amount)));
if (!success || (result.length != 0 && !abi.decode(result, (bool)))) {
revert TokenTransferFailed();
}
}
}
src/FugaziToken.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
/// @notice A fixed-supply ERC-20 launched by FugaziFactory.
contract FugaziToken {
string public name;
string public symbol;
string public description;
string public image;
uint8 public constant decimals = 18;
uint256 public immutable totalSupply;
address public immutable creator;
address public immutable factory;
mapping(address => uint256) public balanceOf;
mapping(address => mapping(address => uint256)) public allowance;
error InvalidAddress();
error InsufficientBalance();
error InsufficientAllowance();
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
constructor(
string memory name_,
string memory symbol_,
string memory description_,
string memory image_,
address creator_,
uint256 supply_
) {
if (creator_ == address(0)) revert InvalidAddress();
name = name_;
symbol = symbol_;
description = description_;
image = image_;
creator = creator_;
factory = msg.sender;
totalSupply = supply_;
balanceOf[msg.sender] = supply_;
emit Transfer(address(0), msg.sender, supply_);
}
/// @notice Compatibility alias for clients that treat the image value as token metadata.
function tokenURI() external view returns (string memory) {
return image;
}
function approve(address spender, uint256 value) external returns (bool) {
allowance[msg.sender][spender] = value;
emit Approval(msg.sender, spender, value);
return true;
}
function transfer(address to, uint256 value) external returns (bool) {
_transfer(msg.sender, to, value);
return true;
}
function transferFrom(address from, address to, uint256 value) external returns (bool) {
uint256 allowed = allowance[from][msg.sender];
if (allowed != type(uint256).max) {
if (allowed < value) revert InsufficientAllowance();
unchecked {
allowance[from][msg.sender] = allowed - value;
}
emit Approval(from, msg.sender, allowance[from][msg.sender]);
}
_transfer(from, to, value);
return true;
}
function _transfer(address from, address to, uint256 value) internal {
if (to == address(0)) revert InvalidAddress();
uint256 balance = balanceOf[from];
if (balance < value) revert InsufficientBalance();
unchecked {
balanceOf[from] = balance - value;
balanceOf[to] += value;
}
emit Transfer(from, to, value);
}
}
src/interfaces/IERC20Minimal.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
interface IERC20Minimal {
function approve(address spender, uint256 value) external returns (bool);
function transfer(address to, uint256 value) external returns (bool);
function transferFrom(address from, address to, uint256 value) external returns (bool);
function balanceOf(address account) external view returns (uint256);
}
src/interfaces/ILiquidityLauncher.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
/// @notice Creates a Uniswap V4 token/reserve pool, deposits token-only liquidity, and executes
/// the creator's initial reserve-token buy atomically.
interface ILiquidityLauncher {
/// @return poolId The Uniswap V4 pool id (V4 pools do not have individual addresses).
/// @return positionId The id of the concentrated-liquidity position.
/// @return amountUsed The amount of `token` deposited in the position.
/// @return amountBought The amount of `token` delivered to `initialBuyer`.
function createPoolAndSeedAndBuy(
address token,
address reserveToken,
uint256 tokenAmount,
address positionRecipient,
uint256 reserveTokenLiquidityAmount,
uint128 positionLiquidity,
uint256 initialBuyAmount,
address initialBuyer
)
external
returns (bytes32 poolId, uint256 positionId, uint256 amountUsed, uint256 amountBought);
}
Compiler settingsShow
{
"viaIR": true,
"metadata": {
"appendCBOR": true,
"bytecodeHash": "ipfs",
"useLiteralContent": false
},
"optimizer": {
"runs": 200,
"enabled": true
},
"evmVersion": "cancun"
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.