IFeeManager

Git Source

This contract accumulates the fees collected from UniswapV3 pools for later use

Functions

WETH

Returns the WETH token contract

function WETH() external view returns (IERC20 _weth);

Returns

NameTypeDescription
_wethIERC20The WETH token

poolManagerDeposits

Returns the amount of fees collected by a pool manager

function poolManagerDeposits(IPoolManager _poolManager)
    external
    view
    returns (uint256 wethForFullRange, uint256 tokenForFullRange);

Parameters

NameTypeDescription
_poolManagerIPoolManagerThe pool manager

Returns

NameTypeDescription
wethForFullRangeuint256The amount of WETH dedicated to increasing the full-range position
tokenForFullRangeuint256The amount of non-WETH tokens dedicated to increasing the full-range position

poolCardinality

Returns information about the pool cardinality

function poolCardinality(IPoolManager _poolManager)
    external
    view
    returns (uint256 weth, uint16 currentMax, uint16 customMax);

Parameters

NameTypeDescription
_poolManagerIPoolManagerThe pool manager

Returns

NameTypeDescription
wethuint256The amount of WETH to increase the cardinality
currentMaxuint16The maximum value of the cardinality in a pool
customMaxuint16The maximum value of the cardinality in a pool set by the governance

poolDistribution

Returns the distribution percentages in a pool

function poolDistribution(IPoolManager _poolManager)
    external
    view
    returns (uint256 wethForMaintenance, uint256 wethForCardinality, bool isInitialized);

Parameters

NameTypeDescription
_poolManagerIPoolManagerThe pool manager

Returns

NameTypeDescription
wethForMaintenanceuint256The WETH for maintenance fees percentage
wethForCardinalityuint256The WETH for cardinality fees percentage
isInitializedboolTrue if the pool is initialized

POOL_MANAGER_FACTORY

Returns the pool manager factory

function POOL_MANAGER_FACTORY() external view returns (IPoolManagerFactory _poolManagerFactory);

Returns

NameTypeDescription
_poolManagerFactoryIPoolManagerFactoryThe pool manager factory

cardinalityJob

Returns the cardinality job

function cardinalityJob() external view returns (ICardinalityJob _cardinalityJob);

Returns

NameTypeDescription
_cardinalityJobICardinalityJobThe cardinality job

maintenanceGovernance

Returns the address that receives the maintenance fee in WETH

function maintenanceGovernance() external view returns (address _maintenanceGovernance);

Returns

NameTypeDescription
_maintenanceGovernanceaddressThe address that receives the maintenance fee in WETH

poolCardinalityMax

Returns the maximum value of cardinality

655 max cardinality array length

function poolCardinalityMax() external view returns (uint16 _poolCardinalityMax);

Returns

NameTypeDescription
_poolCardinalityMaxuint16The maximum value of cardinality

swapGasCostMultiplier

Returns the gas multiplier used to calculate the cost of swapping non-WETH token to WETH

This calculates whether the cost of the swap will be higher than the amount to be swapped

function swapGasCostMultiplier() external view returns (uint256 _swapGasCostMultiplier);

Returns

NameTypeDescription
_swapGasCostMultiplieruint256The value to calculate whether the swap is profitable

depositFromPoolManager

Updates the record for fees collected from the pool manager

Splits the deposited fees into parts for different purposes

The fees from concentrated and full-range positions are handled differently

function depositFromPoolManager(uint256 _wethFees, uint256 _tokenFees) external;

Parameters

NameTypeDescription
_wethFeesuint256The total amount of WETH fees collected from the pool
_tokenFeesuint256The total amount of non-WETH token fees collected from the pool

depositFromLockManager

Updates the record for fees collected from the lock manager

Splits the deposited fees into parts for different purposes

The fees from concentrated and full-range positions are handled differently

function depositFromLockManager(uint256 _wethFees, uint256 _tokenFees) external;

Parameters

NameTypeDescription
_wethFeesuint256The total amount of WETH fees collected from the pool
_tokenFeesuint256The total amount of non-WETH token fees collected from the pool

increaseFullRangePosition

Transfers the necessary amount of WETH and token to increase the full range of a specific pool

Update the balances of tokens intended to increase the full-range position

If necessary, it will swap tokens for WETH.

function increaseFullRangePosition(
    IUniswapV3Pool _pool,
    IERC20 _token,
    uint256 _neededWeth,
    uint256 _neededToken,
    bool _isWethToken0
) external;

Parameters

NameTypeDescription
_poolIUniswapV3PoolThe pool that needs to increase the full range
_tokenIERC20The token that corresponds to the pool that needs to increase the full range
_neededWethuint256The amount of WETH needed for increase the full range
_neededTokenuint256The amount of token needed for increase the full range
_isWethToken0boolTrue if WETH is token0 in the pool

fullRangeCallback

Transfers the necessary amount of WETH and token to increase the full range of a specific pool

Callback that is called after uniswapV3MintCallback from PoolManager if the donor is the FeeManager

Updates the balances of WETH and token intended to increase the full-range position

function fullRangeCallback(IUniswapV3Pool _pool, IERC20 _token, uint256 _neededWeth, uint256 _neededToken) external;

Parameters

NameTypeDescription
_poolIUniswapV3PoolThe pool that need to increase the full range
_tokenIERC20The token that corresponds to the pool that needs to increase the full range
_neededWethuint256The amount of WETH needed to increase the full range
_neededTokenuint256The amount of token needed to increase the full range

uniswapV3SwapCallback

Callback that is called when calling the swap method in a UniswapV3 pool

It is only called when you need to swap non-WETH tokens for WETH

function uniswapV3SwapCallback(int256 _amount0Delta, int256 _amount1Delta, bytes calldata _data) external;

Parameters

NameTypeDescription
_amount0Deltaint256The amount of token0
_amount1Deltaint256The amount of token1
_databytesThe data that differentiates through an address whether to mint or transferFrom for the full range

increaseCardinality

Updates the cardinality in a pool

This method only can be called by the cardinality job

function increaseCardinality(IPoolManager _poolManager, uint256 _weth, uint16 _cardinality) external;

Parameters

NameTypeDescription
_poolManagerIPoolManagerThe pool manager
_wethuint256The amount of WETH
_cardinalityuint16The custom cardinality value

migrateTo

Migrates to a new fee manager

Should be called from a valid lock manager

function migrateTo(IFeeManager _newFeeManager) external;

Parameters

NameTypeDescription
_newFeeManagerIFeeManagerThe new fee manager

migrateFrom

Migrates from an old fee manager

Should be called from the old fee manager

Receives WETH and non-WETH tokens from the old fee manager

function migrateFrom(
    IPoolManager _poolManager,
    PoolCardinality memory _poolCardinality,
    FeeStore memory _poolManagerDeposits,
    PoolDistributionFees memory _poolDistributionFees
) external;

Parameters

NameTypeDescription
_poolManagerIPoolManagerThe pool manager that is migrating its fee manager
_poolCardinalityPoolCardinalityThe current pool cardinality
_poolManagerDepositsFeeStoreThe liquidity to deploy for the full range
_poolDistributionFeesPoolDistributionFeesThe distribution fees of the pool

setSwapGasCostMultiplier

Set the swap gas multiplier

This method only can be called by governance

function setSwapGasCostMultiplier(uint256 _swapGasCostMultiplier) external;

Parameters

NameTypeDescription
_swapGasCostMultiplieruint256The value of the gas multiplier that will be set

setCardinalityJob

Sets the cardinality job

function setCardinalityJob(ICardinalityJob _cardinalityJob) external;

Parameters

NameTypeDescription
_cardinalityJobICardinalityJobThe cardinality job

setPoolCardinalityMax

Sets the maximum value to increase the cardinality

function setPoolCardinalityMax(uint16 _poolCardinalityMax) external;

Parameters

NameTypeDescription
_poolCardinalityMaxuint16The maximum value

setPoolCardinalityTarget

Sets a custom maximum value to increase cardinality

function setPoolCardinalityTarget(IPoolManager _poolManager, uint16 _cardinality) external;

Parameters

NameTypeDescription
_poolManagerIPoolManagerThe pool manager
_cardinalityuint16The custom cardinality value

setMaintenanceGovernance

Sets maintenance governance address

function setMaintenanceGovernance(address _maintenanceGovernance) external;

Parameters

NameTypeDescription
_maintenanceGovernanceaddressThe address that has to receive the maintenance WETH

setWethForMaintenance

Sets the percentage of the WETH fees for maintenance

function setWethForMaintenance(IPoolManager _poolManager, uint256 _wethForMaintenance) external;

Parameters

NameTypeDescription
_poolManagerIPoolManagerThe pool manager
_wethForMaintenanceuint256The percentage of the WETH fees for maintenance

setWethForCardinality

Sets the percentage of the WETH fees for cardinality

function setWethForCardinality(IPoolManager _poolManager, uint256 _wethForCardinality) external;

Parameters

NameTypeDescription
_poolManagerIPoolManagerThe pool manager
_wethForCardinalityuint256The percentage of the WETH fees for cardinality

getMaxCardinalityForPool

Returns the max cardinality for a pool

function getMaxCardinalityForPool(IPoolManager _poolManager) external view returns (uint256 _maxCardinality);

Parameters

NameTypeDescription
_poolManagerIPoolManagerThe pool manager

Events

FeesDeposited

Emitted when the fees are deposited

event FeesDeposited(
    IPoolManager _poolManager,
    uint256 _wethFees,
    uint256 _tokenFees,
    uint256 _wethForMaintenance,
    uint256 _wethForCardinality
);

SwapGasCostMultiplierChanged

Emitted when the swap gas cost multiplier has been changed

event SwapGasCostMultiplierChanged(uint256 _swapGasCostMultiplier);

CardinalityJobSet

Emitted when the cardinality job is set

event CardinalityJobSet(ICardinalityJob _cardinalityJob);

MaintenanceGovernanceChanged

Emitted when the maintenance governance address has been changed

event MaintenanceGovernanceChanged(address _maintenanceGovernance);

WethForMaintenanceChanged

Emitted when the fees percentage of WETH for maintenance has been changed

event WethForMaintenanceChanged(uint256 _wethForMaintenance);

WethForCardinalityChanged

Emitted when the fees percentage of WETH for cardinality has been changed

event WethForCardinalityChanged(uint256 _wethForCardinality);

Migrated

Emitted when an old fee manager migrates to a new fee manager

event Migrated(address _poolManager, address _oldFeeManager, address _newFeeManager);

Errors

FeeManager_InvalidPoolManager

Thrown when we can't verify the pool manager

error FeeManager_InvalidPoolManager(IPoolManager _poolManager);

FeeManager_InvalidLockManager

Thrown when we can't verify the lock manager

error FeeManager_InvalidLockManager(ILockManager _lockManager);

FeeManager_InvalidOldFeeManager

Thrown when we can't verify the old fee manager

error FeeManager_InvalidOldFeeManager(IFeeManager _feeManager);

FeeManager_InvalidPoolManagerFactory

Thrown when we can't verify the pool manager factory

error FeeManager_InvalidPoolManagerFactory();

FeeManager_InvalidUniswapPool

Thrown when we can't verify the UniswapV3 pool

error FeeManager_InvalidUniswapPool(address _sender);

FeeManager_ExcessiveLiquidityLeft

Thrown when excess liquidity for the full range has been left over

error FeeManager_ExcessiveLiquidityLeft();

FeeManager_InvalidTokenLiquidity

Thrown when the liquidity provided of the token is incorrect

error FeeManager_InvalidTokenLiquidity();

FeeManager_SmallSwap

Thrown when the amount of ETH to get is less than the fees spent on the swap

error FeeManager_SmallSwap();

FeeManager_NotCardinalityJob

Thrown when the sender is not the cardinality job

error FeeManager_NotCardinalityJob();

FeeManager_CardinalityExceeded

Thrown when the cardinality is greater than the maximum

error FeeManager_CardinalityExceeded();

FeeManager_NonZeroCardinality

Thrown when trying to migrate fee managers, but cardinality of the pool was already initialized

error FeeManager_NonZeroCardinality();

FeeManager_NonZeroPoolDeposits

Thrown when trying to migrate fee managers, but the pool manager deposits were already initialized

error FeeManager_NonZeroPoolDeposits();

FeeManager_InitializedPoolDistribution

Thrown when trying to migrate fee managers, but pool manager distribution was already initialized

error FeeManager_InitializedPoolDistribution();

FeeManager_WethForMaintenanceExceeded

Thrown when the WETH for maintenance is greater than the maximum

error FeeManager_WethForMaintenanceExceeded();

FeeManager_WethForCardinalityExceeded

Thrown when the WETH for cardinality is greater than the maximum

error FeeManager_WethForCardinalityExceeded();

Structs

FeeStore

Total fees deposited by a pool manager

struct FeeStore {
    uint256 wethForFullRange;
    uint256 tokenForFullRange;
}

PoolCardinality

The values intended for cardinality incrementation

struct PoolCardinality {
    uint256 weth;
    uint16 currentMax;
    uint16 customMax;
}

PoolDistributionFees

The percentages of the fees directed to the maintenance and increasing cardinality

struct PoolDistributionFees {
    uint256 wethForMaintenance;
    uint256 wethForCardinality;
    bool isInitialized;
}