StoryHuntV3Factory
Variables
address owner
Description: The current owner of the factory contract. The owner has exclusive privileges to perform certain administrative actions, such as transferring ownership and enabling new fee amounts.
mapping(uint24 => int24) feeAmountTickSpacing
Description: Maps each fee amount to its corresponding tick spacing.
Key:
fee
(uint24)Value:
tickSpacing
(int24)
This mapping determines the granularity at which ticks can be initialized for different fee tiers.
mapping(address => mapping(address => mapping(uint24 => address))) getPool
Description: Retrieves the address of a deployed pool based on the pair of tokens and the fee tier.
Parameters:
token0
(address): The first token in the pair, sorted by address.token1
(address): The second token in the pair, sorted by address.fee
(uint24): The fee tier for the pool.
Returns:
address
: The address of the deployedStoryHuntV3Pool
corresponding to the provided tokens and fee. Returnsaddress(0)
if the pool does not exist.
Functions
function createPool(address tokenA, address tokenB, uint24 fee) external returns (address pool)
Description:
Deploys a new StoryHuntV3Pool
for the given pair of tokens and fee tier. Ensures that only unique pools are created for each token pair and fee combination.
Parameters
tokenA
address
The first token of the pair to create the pool for.
tokenB
address
The second token of the pair to create the pool for.
fee
uint24
The fee tier for the pool (e.g., 500, 3000, 10000).
Return Values
pool
address
The address of the newly created StoryHuntV3Pool
.
function transferOwnership(address newOwner) external
Description:
Initiates a two-step ownership transfer process. Only the current owner can call this function. Emits the OwnershipTransferStarted
event upon invocation.
Parameters
newOwner
address
The address of the new intended owner.
function acceptOwnership() external
Description:
Completes the ownership transfer process. The pending owner must call this function to finalize the transfer. Emits the OwnerChanged
event upon successful transfer.
function enableFeeAmount(uint24 fee, int24 tickSpacing) public
Description:
Enables a new fee tier with its corresponding tick spacing. Only the current owner can call this function. Emits the FeeAmountEnabled
event upon successful enabling.
Parameters
fee
uint24
The fee tier to enable (e.g., 500, 3000, 10000).
tickSpacing
int24
The tick spacing associated with the fee tier. Must be > 0 and < 16384.
Modifiers
modifier noDelegateCall()
Description: Prevents functions from being called through a delegatecall. This is a security measure to ensure that certain functions cannot be exploited via proxy contracts or delegatecalls.
Events
event OwnerChanged(address indexed oldOwner, address indexed newOwner)
Description: Emitted when ownership of the factory is transferred from one address to another.
Parameters
oldOwner
address
The address of the previous owner.
newOwner
address
The address of the new owner.
event OwnershipTransferStarted(address indexed oldOwner, address indexed newOwner)
Description: Emitted when the ownership transfer process is initiated by the current owner.
Parameters
oldOwner
address
The address of the current owner.
newOwner
address
The address of the intended new owner.
event FeeAmountEnabled(uint24 fee, int24 tickSpacing)
Description: Emitted when a new fee tier is enabled along with its associated tick spacing.
Parameters
fee
uint24
The fee tier that was enabled.
tickSpacing
int24
The tick spacing associated with the fee.
event PoolCreated(address indexed token0, address indexed token1, uint24 fee, int24 tickSpacing, address pool)
Description:
Emitted when a new StoryHuntV3Pool
is created for a specific token pair and fee tier.
Parameters
token0
address
The first token of the pool, sorted by address.
token1
address
The second token of the pool, sorted by address.
fee
uint24
The fee tier of the pool.
tickSpacing
int24
The tick spacing of the pool.
pool
address
The address of the newly created pool.
Usage Notes
Creating Pools
Deploying a New Pool:
Call
createPool(tokenA, tokenB, fee)
with the desired token pair and fee tier.Ensure that the fee tier has been enabled via
enableFeeAmount
before attempting to create a pool.The function will emit a
PoolCreated
event upon successful deployment.
Retrieving Pool Addresses
Fetching a Pool:
Use the
getPool(token0, token1, fee)
mapping to retrieve the address of an existing pool for a given token pair and fee tier.If the pool does not exist, the mapping returns
address(0)
.