Technical Details
TakerV3Factory
Contract Name: TakerV3Factory
Contract Address: (To be provided upon deployment)
Solidity API:
The TakerV3Factory
contract is responsible for deploying Taker Swap V3 pools and managing ownership, protocol fees, and other configurations. Below are the key functions and mappings available in the factory contract:
Functions and Mappings:
owner
Type:
address
Description: Returns the current owner of the factory.
Can be updated by the current owner using the
setOwner
function.
poolDeployer
Type:
address
Description: Returns the address of the current pool deployer.
feeAmountTickSpacing
Type:
mapping(uint24 => int24)
Description: Provides the tick spacing for a specific fee amount, if enabled. Returns
0
if the fee amount is not enabled.Fee amounts are immutable once enabled and should be cached or hardcoded in the calling context.
getPool
Type:
mapping(address => mapping(address => mapping(uint24 => address)))
Description: Returns the pool address for a given token pair and fee, or
address(0)
if the pool does not exist.Token addresses (
tokenA
andtokenB
) can be passed in any order.
feeAmountTickSpacingExtraInfo
Type:
mapping(uint24 => struct TickSpacingExtraInfo)
Description: Provides extra information about tick spacing for a specific fee amount.
Key Functions:
constructor
Parameters:
address _poolDeployer
Description: Initializes the factory with the specified pool deployer address.
createPool
Function Signature:
function createPool(address tokenA, address tokenB, uint24 fee) external returns (address pool)
Description: Creates a new pool for the specified token pair and fee.
Parameters:
tokenA
: Address of one token in the pair.tokenB
: Address of the other token in the pair.fee
: Fee amount for the pool.
Return Values:
pool
: Address of the newly created pool.
Notes:
Tokens can be passed in any order.
The function reverts if the pool already exists, the fee is invalid, or the token addresses are invalid.
setOwner
Function Signature:
function setOwner(address _owner) external
Description: Updates the owner of the factory.
Parameters:
_owner
: Address of the new owner.
Notes: Can only be called by the current owner.
enableFeeAmount
Function Signature:
function enableFeeAmount(uint24 fee, int24 tickSpacing) public
Description: Enables a specific fee amount with the corresponding tick spacing.
Parameters:
fee
: Fee amount to enable (denominated in hundredths of a bip, i.e., 1e-6).tickSpacing
: Spacing between ticks for all pools created with the specified fee amount.
Notes: Fee amounts are immutable once enabled.
setFeeAmountExtraInfo
Function Signature:
function setFeeAmountExtraInfo(uint24 fee, bool whitelistRequested, bool enabled) public
Description: Updates extra information for a specific fee amount.
Parameters:
fee
: Fee amount to update.whitelistRequested
: Boolean flag indicating if the fee requires whitelisting.enabled
: Boolean flag indicating if the fee is enabled.
setWhiteListAddress
Function Signature:
function setWhiteListAddress(address user, bool verified) public
Description: Adds or removes an address from the whitelist.
Parameters:
user
: Address to whitelist.verified
: Boolean flag to add (true
) or remove (false
) the address from the whitelist.
TakerV3Pool
Solidity API:
The TakerV3Pool
contract is deployed by the factory and manages liquidity, swaps, and fees for a specific pair of tokens. Below are the key functions and parameters:
Key Parameters:
factory
Type:
address
Description: Address of the factory contract that deployed the pool.
token0
Type:
address
Description: The first token of the pool, sorted by address.
token1
Type:
address
Description: The second token of the pool, sorted by address.
fee
Type:
uint24
Description: The pool's fee in hundredths of a bip (1e-6).
tickSpacing
Type:
int24
Description: The tick spacing for the pool, which determines the granularity of liquidity positions.
liquidity
Type:
uint128
Description: The current liquidity available in the pool.
Key Functions:
initialize
Function Signature:
function initialize(uint160 sqrtPriceX96) external
Description: Sets the initial price for the pool.
Parameters:
sqrtPriceX96
: Initial sqrt price of the pool as a Q64.96 value.
mint
Function Signature:
function mint(address recipient, int24 tickLower, int24 tickUpper, uint128 amount, bytes data) external returns (uint256 amount0, uint256 amount1)
Description: Adds liquidity to the pool for a specific position.
Parameters:
recipient
: Address receiving the liquidity.tickLower
: Lower bound of the tick range.tickUpper
: Upper bound of the tick range.amount
: Amount of liquidity to mint.data
: Additional data passed to the callback.
Return Values:
amount0
: Amount of token0 added.amount1
: Amount of token1 added.
swap
Function Signature:
function swap(address recipient, bool zeroForOne, int256 amountSpecified, uint160 sqrtPriceLimitX96, bytes data) external returns (int256 amount0, int256 amount1)
Description: Executes a swap between token0 and token1.
Parameters:
recipient
: Address receiving the output of the swap.zeroForOne
: Direction of the swap (true
for token0 to token1,false
for token1 to token0).amountSpecified
: Amount of the swap (positive for exact input, negative for exact output).sqrtPriceLimitX96
: Price limit for the swap.data
: Additional data passed to the callback.
Return Values:
amount0
: Change in token0 balance.amount1
: Change in token1 balance.
burn
Function Signature:
function burn(int24 tickLower, int24 tickUpper, uint128 amount) external returns (uint256 amount0, uint256 amount1)
Description: Removes liquidity from the pool.
Parameters:
tickLower
: Lower bound of the tick range.tickUpper
: Upper bound of the tick range.amount
: Amount of liquidity to remove.
Return Values:
amount0
: Amount of token0 removed.amount1
: Amount of token1 removed.
collect
Function Signature:
function collect(address recipient, int24 tickLower, int24 tickUpper, uint128 amount0Requested, uint128 amount1Requested) external returns (uint128 amount0, uint128 amount1)
Description: Collects fees owed to a position.
Parameters:
recipient
: Address receiving the fees.tickLower
: Lower bound of the tick range.tickUpper
: Upper bound of the tick range.amount0Requested
: Maximum amount of token0 to collect.amount1Requested
: Maximum amount of token1 to collect.
Return Values:
amount0
: Amount of token0 collected.amount1
: Amount of token1 collected.
This modular design ensures gas efficiency, scalability, and security while providing developers with a robust platform for building on Taker Swap.
Last updated