Factory
Factory Class Reference
The Doppler V4 SDK provides two factory classes for interacting with the airlock contract:
ReadFactory
- Read-only operations for querying deployed pools and modulesReadWriteFactory
- Extends ReadFactory with deployment and migration capabilities
ReadFactory
The ReadFactory
class provides read-only operations for the Doppler V4 airlock contract. It handles queries and data retrieval from deployed Doppler pools and their associated contracts.
Constructor
Parameters:
address
- The address of the airlock contractdrift
- Drift instance with read adapter (creates default if not provided)
Methods
getModuleState
Retrieves the current state/type of a module in the Doppler system. Modules serve different roles and must be whitelisted before use.
Parameters:
module
- The address of the module to check
Returns: Promise resolving to the module's current state
Module States:
NotWhitelisted
(0) - Module is not approved for useTokenFactory
(1) - Module can create tokensGovernanceFactory
(2) - Module can create governance contractsHookFactory
(3) - Module can create hooksMigrator
(4) - Module can migrate liquidity
getAssetData
Retrieves comprehensive deployment data for a Doppler asset, including all contract addresses and configuration.
Parameters:
asset
- The address of the deployed asset token
Returns: Promise resolving to complete asset deployment data including:
Numeraire (quote token) used for pricing
Timelock and governance contracts
Liquidity migrator for post-discovery trading
Pool initializer and pool addresses
Number of tokens being sold
Integrator information
ReadFactory Example
ReadWriteFactory
The ReadWriteFactory
class extends ReadFactory
with comprehensive deployment and migration capabilities for creating tokens with Doppler.
Key Features
Pool Creation: Deploy requisite doppler contracts, with tokens, hooks, and governance
Hook Mining: Find optimal hook addresses with required flags
Asset Migration: Move liquidity from price discovery to standard trading
Parameter Validation: Automatic validation and optimization of deployment parameters
Gamma Calculation: Compute optimal price movement parameters
Constructor
Parameters:
address
- The address of the airlock contractdrift
- A Drift instance with read-write adapter capabilities
Core Methods
buildConfig
Builds complete configuration for creating a new Doppler pool. This method validates parameters and tick ranges, optionally computes a valid gamma, mines hook addresses, and encodes factory data.
Parameters:
params
- Pre-deployment configuration parametersaddresses
- Addresses of required Doppler V4 contracts
Returns: Object containing creation parameters, hook address, and token address
create
Creates a new Doppler pool with token, hook, migrator, and governance. This is the main deployment method that sets up the complete ecosystem.
Parameters:
params
- Complete creation parameters frombuildConfig()
options
- Optional transaction options (gas, value, etc.)
Returns: Promise resolving to the transaction hash
simulateCreate
Simulates a pool creation transaction without executing it. Useful for gas estimation, parameter validation, and testing configurations.
Parameters:
params
- Complete creation parameters frombuildConfig()
Returns: Promise resolving to simulation results including gas estimates
migrate
Migrates liquidity for an existing asset from the current pool to the migration pool. Triggers the migration process for assets that have completed price discovery.
Parameters:
asset
- The address of the asset token to migrateoptions
- Optional transaction options
Returns: Promise resolving to the transaction hash
Example Usage
Configuration Parameters
The DopplerPreDeploymentConfig
includes:
Token Details:
name
,symbol
,totalSupply
,tokenURI
Sale Parameters:
numTokensToSell
,duration
,epochLength
Price Discovery:
tickRange
,tickSpacing
,gamma
,fee
Proceeds:
minProceeds
,maxProceeds
Governance:
yearlyMintRate
,vestingDuration
,recipients
,amounts
Integration:
integrator
,liquidityMigratorData
Validation Rules
Name and symbol are required and non-empty
Total supply and tokens to sell must be positive
Tick range must be valid (startTick < endTick)
Duration and epoch length must be positive
Tick spacing must be positive and divide gamma evenly
Epoch length must divide total duration evenly
Workflow Optimization
The factory automatically:
Mines optimal hook addresses with required flags
Validates parameter compatibility before deployment
Provides gas estimation through simulation
Optimizes gamma calculation for efficient price discovery
Last updated