VinuSwapFactory

The VinuSwapFactory contract deploys VinuSwap pools and serves as the canonical registry for all pools.

Source: contracts/core/VinuSwapFactory.sol

Overview

The factory is responsible for:

  • Deploying new pools with deterministic addresses

  • Maintaining the pool registry

  • Managing ownership and access control

State Variables

owner

address public override owner;

The address with administrative privileges. Only the owner can:

  • Create new pools

  • Transfer ownership

getPool

Returns the pool address for a given token pair and fee tier.

Note: The mapping works regardless of token order - getPool[A][B][fee] returns the same address as getPool[B][A][fee].

Functions

createPool

Deploys a new pool for the given token pair.

Access Control: Only callable by owner

Parameters:

Name
Type
Description

tokenA

address

One of the tokens in the pair

tokenB

address

The other token in the pair

fee

uint24

Fee in hundredths of a bip (e.g., 3000 = 0.3%)

tickSpacing

int24

Minimum tick interval for positions

feeManager

address

Contract for dynamic fee computation

Returns:

Name
Type
Description

pool

address

Address of the newly created pool

Requirements:

  • msg.sender == owner

  • tokenA != tokenB

  • tokenA != address(0) and tokenB != address(0)

  • fee < 1000000 (< 100%)

  • tickSpacing > 0 && tickSpacing < 16384

  • Pool does not already exist for this pair/fee combination

Example:

setOwner

Transfers ownership to a new address.

Access Control: Only callable by current owner

Parameters:

Name
Type
Description

_owner

address

New owner address

Events Emitted:

  • OwnerChanged(oldOwner, newOwner)

Events

PoolCreated

Emitted when a new pool is deployed.

Note: token0 will always be less than token1 (sorted by address).

OwnerChanged

Emitted when ownership is transferred.

Pool Address Computation

Pool addresses are deterministic and can be computed off-chain:

Interface

Usage Examples

Creating a Pool

Querying a Pool

Transferring Ownership

Differences from Uniswap V3

Aspect
Uniswap V3
VinuSwap

Pool Creation

Permissionless

Owner-only

Fee Tiers

Fixed mapping to tick spacing

Custom per-pool

Fee Manager

Not supported

Required parameter

Tick Spacing

Determined by fee tier

Specified at creation

Security Considerations

  1. Owner Privilege: The owner has significant control. Consider using a multisig or timelock.

  2. Fee Manager Trust: The fee manager contract is called during every swap. Ensure it's a trusted implementation.

  3. Pool Uniqueness: Each token pair + fee combination can only have one pool.

Last updated