Skip to main content

EPoolFactory Contract

Overview​

The EPoolFactory deploys new EPOOL instances with deterministic pool keys. It manages encrypted obfuscation parameters and enforces canonical token ordering.

Key Features​

  • Deterministic Pool Keys: keccak256(token0, token1, swapFee)
  • Canonical Token Ordering: Lower address = token0
  • Encrypted Obfuscation Parameters: Shared across all pools
  • Pool Registry: Mapping and array for discovery

State Variables​

mapping(bytes32 => address) public getPool;        // Pool lookup by key
address[] public allPools; // All deployed pools
euint64 private minObfuscationFactor; // Global min factor
euint64 private obfuscationFactorStep; // Global step size

Core Functions​

constructor​

constructor(
externalEuint64 _minObfuscationFactorExt,
externalEuint64 _obfuscationFactorStepExt,
bytes memory inputProof
)

Initializes with encrypted obfuscation parameters. Typical values: minFactor = 1,000,000, step = 30.

createPool​

function createPool(
IERC7984 assetA,
IERC7984 assetB,
uint24 swapFee,
string memory pairName,
string memory pairSymbol,
string memory pairTokenURI
) external returns (address pool)

Deploys a new EPOOL. Automatically sorts tokens (enforces determinism). Grants the new pool access to encrypted obfuscation parameters and calls pool.initializeObfuscation().

poolFor​

function poolFor(
IERC7984 assetA,
IERC7984 assetB,
uint24 swapFee
) external view returns (address)

Deterministic pool address lookup.

setObfuscationParameters​

function setObfuscationParameters(
externalEuint64 _minObfuscationFactorExt,
externalEuint64 _obfuscationFactorStepExt,
bytes calldata inputProof
) external onlyOwner

Update global obfuscation parameters for future pools.

Events​

event PoolCreated(
address indexed assetA,
address indexed assetB,
uint24 swapFee,
address pool,
address indexed owner,
string pairName,
string pairSymbol,
string pairTokenURI
);
event ObfuscationParametersUpdated();

Pool Key Calculation​

// Tokens are sorted: lower address = token0
(token0, token1) = assetA < assetB ? (assetA, assetB) : (assetB, assetA);
bytes32 key = keccak256(abi.encodePacked(token0, token1, swapFee));

This means createPool(tokenA, tokenB, fee) and createPool(tokenB, tokenA, fee) create the same pool.

Deployed Address​

NetworkAddress
Ethereum Sepolia0xa830205E7b5e1b75a6e6EED34207C7FEc7aBEEAE
Arbitrum Sepolia0x0163880054940204296982BD708Be6F53091f66A