CLPoolDeployer

0x5952f5d501a130da00fa8fe2257d8b35ddc0a57b

Verification
Verified
v0.7.6+commit.7338295f
Type
Contract
24,244 bytes
ABI entries
7
3 read · 2 write
License
none

Contract information

Address
0x5952f5d501a130da00fa8fe2257d8b35ddc0a57b
Chain
Robinhood Chain (4663)
Compiler
v0.7.6+commit.7338295f
Optimization
Enabled
Creation tx
0xfee060748f…8e3763fac3

Token

Not a token

This contract does not expose ERC-20 metadata.

Read contract (3)

factoryAddress()address
factoryAddressSetter()address
parameters()address, address, address, uint24, int24

Events (1)

SetFactoryAddress

ABI

[
  {
    "inputs": [],
    "stateMutability": "nonpayable",
    "type": "constructor"
  },
  {
    "anonymous": false,
    "inputs": [
      {
        "indexed": true,
        "internalType": "address",
        "name": "factory",
        "type": "address"
      }
    ],
    "name": "SetFactoryAddress",
    "type": "event"
  },
  {
    "inputs": [
      {
        "internalType": "address",
        "name": "factory",
        "type": "address"
      },
      {
        "internalType": "address",
        "name": "token0",
        "type": "address"
      },
      {
        "internalType": "address",
        "name": "token1",
        "type": "address"
      },
      {
        "internalType": "uint24",
        "name": "fee",
        "type": "uint24"
      },
      {
        "internalType": "int24",
        "name": "tickSpacing",
        "type": "int24"
      }
    ],
    "name": "deploy",
    "outputs": [
      {
        "internalType": "address",
        "name": "pool",
        "type": "address"
      }
    ],
    "stateMutability": "nonpayable",
    "type": "function"
  },
  {
    "inputs": [],
    "name": "factoryAddress",
    "outputs": [
      {
        "internalType": "address",
        "name": "",
        "type": "address"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [],
    "name": "factoryAddressSetter",
    "outputs": [
      {
        "internalType": "address",
        "name": "",
        "type": "address"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [],
    "name": "parameters",
    "outputs": [
      {
        "internalType": "address",
        "name": "factory",
        "type": "address"
      },
      {
        "internalType": "address",
        "name": "token0",
        "type": "address"
      },
      {
        "internalType": "address",
        "name": "token1",
        "type": "address"
      },
      {
        "internalType": "uint24",
        "name": "fee",
        "type": "uint24"
      },
      {
        "internalType": "int24",
        "name": "tickSpacing",
        "type": "int24"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [
      {
        "internalType": "address",
        "name": "_factoryAddress",
        "type": "address"
      }
    ],
    "name": "setFactoryAddress",
    "outputs": [],
    "stateMutability": "nonpayable",
    "type": "function"
  }
]

Source code

// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity =0.7.6;

import "./interfaces/ICLPoolDeployer.sol";

import "./CLPool.sol";

contract CLPoolDeployer is ICLPoolDeployer {
    struct Parameters {
        address factory;
        address token0;
        address token1;
        uint24 fee;
        int24 tickSpacing;
    }

    /// @inheritdoc ICLPoolDeployer
    Parameters public override parameters;

    address public immutable factoryAddressSetter;
    address public factoryAddress;

    /// @notice Emitted when factory address is set
    event SetFactoryAddress(address indexed factory);

    modifier onlyFactory() {
        require(msg.sender == factoryAddress, "only factory can call deploy");
        _;
    }

    constructor() {
        factoryAddressSetter = msg.sender;
    }

    function setFactoryAddress(address _factoryAddress) external {
        require(msg.sender == factoryAddressSetter, "not factory address setter");
        require(factoryAddress == address(0), "already initialized");
        require(_factoryAddress != address(0), "zero factory address");

        factoryAddress = _factoryAddress;

        emit SetFactoryAddress(_factoryAddress);
    }

    /// @dev Deploys a pool with the given parameters by transiently setting the parameters storage slot and then
    /// clearing it after deploying the pool.
    /// @param factory The contract address of the Apex CL factory
    /// @param token0 The first token of the pool by address sort order
    /// @param token1 The second token of the pool by address sort order
    /// @param fee The fee collected upon every swap in the pool, denominated in hundredths of a bip
    /// @param tickSpacing The spacing between usable ticks
    function deploy(address factory, address token0, address token1, uint24 fee, int24 tickSpacing)
        external
        override
        onlyFactory
        returns (address pool)
    {
        parameters = Parameters({factory: factory, token0: token0, token1: token1, fee: fee, tickSpacing: tickSpacing});
        pool = address(new CLPool{salt: keccak256(abi.encode(token0, token1, fee))}());
        delete parameters;
    }
}
Chain explorer4411msChain node83ms