MaverickV2Factory

Inherits: IMaverickV2Factory, IMaverickV2FactoryAdmin, Ownable

Pool Factory contract. Deploys both permissionless and permissioned Maverick V2 pools using deterministic create2 addresses. Deployed pools can be looked up by their parameters or by the token pair. This contract is ownable with the owner having permission to set protocol fee for all pools and collect protocol fee proceeds from pools.

State Variables

poolLists

Mapping elements are [tokenA][tokenB] -> list of pools.

mapping(IERC20 => mapping(IERC20 => IMaverickV2Pool[])) private poolLists;

poolListsPermissioned

Mapping elements are [accessor][tokenA][tokenB] -> list of pools.

mapping(address => mapping(IERC20 => mapping(IERC20 => IMaverickV2Pool[]))) private poolListsPermissioned;

isFactoryPool

Bool indicating whether the pool was deployed from this factory.

mapping(IMaverickV2Pool => bool) public isFactoryPool;

isFactoryPoolPermissioned

Bool indicating whether the pool was deployed from this factory.

mapping(IMaverickV2Pool => bool) public isFactoryPoolPermissioned;

protocolFeeRatioD3

Proportion of protocol fee to collect on each swap. Value is in 3-decimal format with a maximum value of 0.25e3.

uint8 public protocolFeeRatioD3;

protocolLendingFeeRateD18

Fee rate charged by the protocol for flashloans. Value is in 18-decimal format with a maximum value of 0.02e18.

uint256 public protocolLendingFeeRateD18;

deployParameters

Called by deployer library to initialize a pool.

DeployParameters public deployParameters;

protocolFeeReceiver

Address that receives the protocol fee when users call claimProtocolFeeForPool.

address public protocolFeeReceiver;

allPools

Array of all permissionless pools.

IMaverickV2Pool[] private allPools;

allPoolsPermissioned

Array of all permissioned pools.

IMaverickV2Pool[] private allPoolsPermissioned;

Functions

constructor

constructor(address initialOwner) Ownable(initialOwner);

setProtocolFeeRatio

Set the protocol fee ratio.

function setProtocolFeeRatio(uint8 _protocolFeeRatioD3) external onlyOwner;

Parameters

setProtocolLendingFeeRate

Set the protocol lending fee rate.

function setProtocolLendingFeeRate(uint256 _protocolLendingFeeRateD18) external onlyOwner;

Parameters

setProtocolFeeReceiver

Set the protocol fee receiver address. If protocol fee is non-zero, user will be able to permissionlessly push protocol fee from a given pool to this address.

function setProtocolFeeReceiver(address receiver) external onlyOwner;

transferOwnership

Transfer ownership of the contract to a new owner.

function transferOwnership(address newOwner) public override(IMaverickV2FactoryAdmin, Ownable) onlyOwner;

Parameters

renounceOwnership

Renounce ownership of the contract.

function renounceOwnership() public override(IMaverickV2FactoryAdmin, Ownable) onlyOwner;

claimProtocolFeeForPool

Claim protocol fee for a pool and transfer it to the protocolFeeReceiver.

function claimProtocolFeeForPool(IMaverickV2Pool pool, bool isTokenA) public;

Parameters

claimProtocolFeeForPool

Claim protocol fee for a pool and transfer it to the protocolFeeReceiver.

function claimProtocolFeeForPool(IMaverickV2Pool pool) public;

Parameters

updateProtocolFeeRatioForPool

Update the protocol fee ratio for a pool. Can be called permissionlessly allowing any user to sync the pool protocol fee value with the factory protocol fee value.

function updateProtocolFeeRatioForPool(IMaverickV2Pool pool) public;

Parameters

updateProtocolLendingFeeRateForPool

Update the protocol lending fee rate for a pool. Can be called permissionlessly allowing any user to sync the pool protocol lending fee rate value with the factory value.

function updateProtocolLendingFeeRateForPool(IMaverickV2Pool pool) public;

Parameters

create

Create a new MaverickV2Pool with symmetric swap fees.

function create(
    uint64 feeAIn,
    uint64 feeBIn,
    uint16 tickSpacing,
    uint32 lookback,
    IERC20 tokenA,
    IERC20 tokenB,
    int32 activeTick,
    uint8 kinds
) public returns (IMaverickV2Pool pool);

Parameters

createPermissioned

Create a new MaverickV2PoolPermissioned with symmetric swap fees.

function createPermissioned(
    uint64 fee,
    uint16 tickSpacing,
    uint32 lookback,
    IERC20 tokenA,
    IERC20 tokenB,
    int32 activeTick,
    uint8 kinds,
    address accessor
) public returns (IMaverickV2Pool pool);

Parameters

owner

Get the current factory owner.

function owner() public view override(IMaverickV2Factory, Ownable) returns (address);

lookup

Lookup a pool for given parameters.

function lookup(
    uint256 _feeAIn,
    uint256 _feeBIn,
    uint256 _tickSpacing,
    uint256 _lookback,
    IERC20 _tokenA,
    IERC20 _tokenB,
    uint8 kinds
) public view returns (IMaverickV2Pool pool);

lookup

Lookup a pool for given parameters.

function lookup(IERC20 _tokenA, IERC20 _tokenB, uint256 startIndex, uint256 endIndex)
    external
    view
    returns (IMaverickV2Pool[] memory);

Lookup a pool for given parameters.

function lookup(uint256 startIndex, uint256 endIndex) external view returns (IMaverickV2Pool[] memory);

Lookup a pool for given parameters.

function lookupPermissioned(
    uint256 _feeAIn,
    uint256 _feeBIn,
    uint256 _tickSpacing,
    uint256 _lookback,
    IERC20 _tokenA,
    IERC20 _tokenB,
    uint8 kinds,
    address accessor
) public view returns (IMaverickV2Pool pool);

Lookup a pool for given parameters.

function lookupPermissioned(IERC20 _tokenA, IERC20 _tokenB, address accessor, uint256 startIndex, uint256 endIndex)
    external
    view
    returns (IMaverickV2Pool[] memory);

Lookup a pool for given parameters.

function lookupPermissioned(uint256 startIndex, uint256 endIndex) external view returns (IMaverickV2Pool[] memory);

Address of a permissionless pool.

function poolAddress(
    uint256 feeAIn,
    uint256 feeBIn,
    uint256 tickSpacing,
    uint256 lookback,
    IERC20 tokenA,
    IERC20 tokenB,
    uint8 kinds
) public view returns (IMaverickV2Pool pool);

Address of a permissionless pool.

function poolAddress(
    uint256 feeAIn,
    uint256 feeBIn,
    uint256 tickSpacing,
    uint256 lookback,
    IERC20 tokenA,
    IERC20 tokenB,
    uint8 kinds,
    address accessor
) public view returns (IMaverickV2Pool pool);

_slice

Prune array from storage to subset of array with range [startIndex, endIndex).

function _slice(IMaverickV2Pool[] storage _pools, uint256 startIndex, uint256 endIndex)
    internal
    view
    returns (IMaverickV2Pool[] memory returnPools);

Parameters

Returns

_createChecks

Check create pool parameters to ensure they are valid. Reverts on an invalid paramter sets.

function _createChecks(
    uint256 feeAIn,
    uint256 feeBIn,
    uint256 tickSpacing,
    uint256 lookback,
    IERC20 tokenA,
    IERC20 tokenB,
    uint8 kinds
) internal view returns (uint64 tokenAScale, uint64 tokenBScale);

_checkProtocolFeeRatio

Checks the validity of the protocol fee ratio.

function _checkProtocolFeeRatio(uint8 _protocolFeeRatioD3) internal pure;

_checkProtocolLendingFeeRate

Checks the validity of the protocol lending fee rate.

function _checkProtocolLendingFeeRate(uint256 _protocolLendingFeeRateD18) internal pure;

Last updated