Skip to main content
Version: V2

Factory

Code

DMMFactory.sol

Address

DMMFactory is deployed at 0x833e4083B7ae46CeA85695c4f7ed25CDAd8886dE on the Ethereum mainnet. It was built from commit 04b47545c58fa0ab99d4bb9eae729b3be31efb0c.

Events

PoolCreated

event PoolCreated(IERC20 indexed token0, IERC20 indexed token1, address pool, uint32 ampBps, uint256 totalPool);

Emitted each time a pair is created via createPool.

  • token0 is guaranteed to be strictly less than token1 by sort order.
  • totalPool is the no. of pools created.

SetFeeConfiguration

event SetFeeConfiguration(address feeTo, uint16 governmentFeeBps);

Emitted each time the fee configuration changes.

  • feeTo refers to the address where the protocol fee is sent to
  • governmentFeeBps refers to the amount of fees to take from each liquidity addition instance

See Protocol Fee.

Read-Only Functions

getPools

function getPools(IERC20 token0, IERC20 token1) external view returns (address[] memory _tokenPools);

Returns all pools created for the pair of token0 and token1. If there are none, an empty array [] is returned.

  • token0 and token1 are interchangeable.

getPoolsLength

function getPoolsLength(IERC20 token0, IERC20 token1) external view returns (uint256);

Returns the total number of pools created for the pair of token0 and token1.

getPoolAtIndex

function getPoolAtIndex(IERC20 token0, IERC20 token1, uint256 index) external view returns (address pool);

Returns the pool address found at index of the pool array of the pair of token0 and token1.

getUnamplifiedPool

function getUnamplifiedPool(IERC20 token0, IERC20 token1) external view returns (address);

Returns the address of the pool with amplification factor 1 of the pair of token0 and token1.

isPool

function isPool(IERC20 token0, IERC20 token1, address pool) external view returns (bool);

Returns true if pool is a pool of the pair of token0 and token1, false otherwise.

allPools

function allPools(uint256) external view returns (address pair);

Returns the address of the nth pool (0-indexed) created through the factory, or address(0) (0x0000000000000000000000000000000000000000) if not enough pairs have been created yet.

  • Pass 0 for the address of the first pair created, 1 for the second, etc.

allPoolsLength

function allPoolsLength() external view returns (uint256);

Returns the total number of pools created through the factory so far.

getFeeConfiguration

function getFeeConfiguration() external view returns (address _feeTo, uint16 _governmentFeeBps);

See Protocol Fee.

feeToSetter

function feeToSetter() external view returns (address);

The address allowed to change feeTo.

State-Changing Functions

createPool

function createPool(IERC20 token0, IERC20 token1, uint32 ampBps) external returns (address pool);

Creates a pool for token0 and token1 with amplification ampBps.

  • token0 and token1 are interchangeable.
  • There can be at most 1 unamplified pool for a token pair, ie. only 1 pool can exist with ampBps = BPS (10000).
  • ampBps should exceed BPS for other non-amplified pools, and is specified in basis points (bps). For example, ampBps = 15500 means a pool of amplifcation factor of 1.55 is to be created.
  • Emits PoolCreated.

Interface

import '@dynamic-amm/smart-contracts/contracts/interfaces/IDMMFactory.sol';
pragma solidity 0.6.6;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";

interface IDMMFactory {
function createPool(
IERC20 tokenA,
IERC20 tokenB,
uint32 ampBps
) external returns (address pool);

function setFeeConfiguration(address feeTo, uint16 governmentFeeBps) external;

function setFeeToSetter(address) external;

function getFeeConfiguration() external view returns (address feeTo, uint16 governmentFeeBps);

function feeToSetter() external view returns (address);

function allPools(uint256) external view returns (address pool);

function allPoolsLength() external view returns (uint256);

function getUnamplifiedPool(IERC20 token0, IERC20 token1) external view returns (address);

function getPools(IERC20 token0, IERC20 token1)
external
view
returns (address[] memory _tokenPools);

function isPool(
IERC20 token0,
IERC20 token1,
address pool
) external view returns (bool);
}

ABI

import IDMMFactory from '@dynamic-amm/smart-contracts/artifacts/contracts/interfaces/IDMMFactory.sol/IDMMFactory.json';

https://unpkg.com/@dynamic-amm/smart-contracts/artifacts/contracts/interfaces/IDMMFactory.sol/IDMMFactory.json