IFeeManager
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
Name | Type | Description |
---|---|---|
_weth | IERC20 | The 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
Name | Type | Description |
---|---|---|
_poolManager | IPoolManager | The pool manager |
Returns
Name | Type | Description |
---|---|---|
wethForFullRange | uint256 | The amount of WETH dedicated to increasing the full-range position |
tokenForFullRange | uint256 | The 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
Name | Type | Description |
---|---|---|
_poolManager | IPoolManager | The pool manager |
Returns
Name | Type | Description |
---|---|---|
weth | uint256 | The amount of WETH to increase the cardinality |
currentMax | uint16 | The maximum value of the cardinality in a pool |
customMax | uint16 | The 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
Name | Type | Description |
---|---|---|
_poolManager | IPoolManager | The pool manager |
Returns
Name | Type | Description |
---|---|---|
wethForMaintenance | uint256 | The WETH for maintenance fees percentage |
wethForCardinality | uint256 | The WETH for cardinality fees percentage |
isInitialized | bool | True if the pool is initialized |
POOL_MANAGER_FACTORY
Returns the pool manager factory
function POOL_MANAGER_FACTORY() external view returns (IPoolManagerFactory _poolManagerFactory);
Returns
Name | Type | Description |
---|---|---|
_poolManagerFactory | IPoolManagerFactory | The pool manager factory |
cardinalityJob
Returns the cardinality job
function cardinalityJob() external view returns (ICardinalityJob _cardinalityJob);
Returns
Name | Type | Description |
---|---|---|
_cardinalityJob | ICardinalityJob | The cardinality job |
maintenanceGovernance
Returns the address that receives the maintenance fee in WETH
function maintenanceGovernance() external view returns (address _maintenanceGovernance);
Returns
Name | Type | Description |
---|---|---|
_maintenanceGovernance | address | The 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
Name | Type | Description |
---|---|---|
_poolCardinalityMax | uint16 | The 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
Name | Type | Description |
---|---|---|
_swapGasCostMultiplier | uint256 | The 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
Name | Type | Description |
---|---|---|
_wethFees | uint256 | The total amount of WETH fees collected from the pool |
_tokenFees | uint256 | The 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
Name | Type | Description |
---|---|---|
_wethFees | uint256 | The total amount of WETH fees collected from the pool |
_tokenFees | uint256 | The 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
Name | Type | Description |
---|---|---|
_pool | IUniswapV3Pool | The pool that needs to increase the full range |
_token | IERC20 | The token that corresponds to the pool that needs to increase the full range |
_neededWeth | uint256 | The amount of WETH needed for increase the full range |
_neededToken | uint256 | The amount of token needed for increase the full range |
_isWethToken0 | bool | True 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
Name | Type | Description |
---|---|---|
_pool | IUniswapV3Pool | The pool that need to increase the full range |
_token | IERC20 | The token that corresponds to the pool that needs to increase the full range |
_neededWeth | uint256 | The amount of WETH needed to increase the full range |
_neededToken | uint256 | The 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
Name | Type | Description |
---|---|---|
_amount0Delta | int256 | The amount of token0 |
_amount1Delta | int256 | The amount of token1 |
_data | bytes | The 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
Name | Type | Description |
---|---|---|
_poolManager | IPoolManager | The pool manager |
_weth | uint256 | The amount of WETH |
_cardinality | uint16 | The custom cardinality value |
migrateTo
Migrates to a new fee manager
Should be called from a valid lock manager
function migrateTo(IFeeManager _newFeeManager) external;
Parameters
Name | Type | Description |
---|---|---|
_newFeeManager | IFeeManager | The 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
Name | Type | Description |
---|---|---|
_poolManager | IPoolManager | The pool manager that is migrating its fee manager |
_poolCardinality | PoolCardinality | The current pool cardinality |
_poolManagerDeposits | FeeStore | The liquidity to deploy for the full range |
_poolDistributionFees | PoolDistributionFees | The 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
Name | Type | Description |
---|---|---|
_swapGasCostMultiplier | uint256 | The value of the gas multiplier that will be set |
setCardinalityJob
Sets the cardinality job
function setCardinalityJob(ICardinalityJob _cardinalityJob) external;
Parameters
Name | Type | Description |
---|---|---|
_cardinalityJob | ICardinalityJob | The cardinality job |
setPoolCardinalityMax
Sets the maximum value to increase the cardinality
function setPoolCardinalityMax(uint16 _poolCardinalityMax) external;
Parameters
Name | Type | Description |
---|---|---|
_poolCardinalityMax | uint16 | The maximum value |
setPoolCardinalityTarget
Sets a custom maximum value to increase cardinality
function setPoolCardinalityTarget(IPoolManager _poolManager, uint16 _cardinality) external;
Parameters
Name | Type | Description |
---|---|---|
_poolManager | IPoolManager | The pool manager |
_cardinality | uint16 | The custom cardinality value |
setMaintenanceGovernance
Sets maintenance governance address
function setMaintenanceGovernance(address _maintenanceGovernance) external;
Parameters
Name | Type | Description |
---|---|---|
_maintenanceGovernance | address | The 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
Name | Type | Description |
---|---|---|
_poolManager | IPoolManager | The pool manager |
_wethForMaintenance | uint256 | The 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
Name | Type | Description |
---|---|---|
_poolManager | IPoolManager | The pool manager |
_wethForCardinality | uint256 | The 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
Name | Type | Description |
---|---|---|
_poolManager | IPoolManager | The 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;
}