IPoolManager

Git Source

Inherits: IPoolManagerGovernor

This contract manages the protocol owned positions of the associated uni v3 pool

Functions

WETH

Returns the WETH contract

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

Returns

NameTypeDescription
_wethIERC20The WETH token

UNISWAP_V3_FACTORY

Returns the UniswapV3 factory contract

function UNISWAP_V3_FACTORY() external view returns (IUniswapV3Factory _uniswapV3Factory);

Returns

NameTypeDescription
_uniswapV3FactoryIUniswapV3FactoryThe UniswapV3 factory contract

POOL_BYTECODE_HASH

Returns the UniswapV3 pool bytecode hash

function POOL_BYTECODE_HASH() external view returns (bytes32 _poolBytecodeHash);

Returns

NameTypeDescription
_poolBytecodeHashbytes32The UniswapV3 pool bytecode hash

lockManager

Returns the lock manager contract

function lockManager() external view returns (ILockManager _lockManager);

Returns

NameTypeDescription
_lockManagerILockManagerThe lock manager

deprecatedLockManagers

Returns a deprecated lock manager contract at a specific index

function deprecatedLockManagers(uint256 _index) external view returns (ILockManager _deprecatedLockManagers);

Returns

NameTypeDescription
_deprecatedLockManagersILockManagerA deprecated lock manager

FEE

Returns the fee of the pool manager

function FEE() external view returns (uint24 _fee);

Returns

NameTypeDescription
_feeuint24The pool manager's fee

TOKEN

Returns the non-WETH token of the underlying pool

function TOKEN() external view returns (IERC20 _token);

Returns

NameTypeDescription
_tokenIERC20The non-WETH token of the underlying pool

POOL

Returns the underlying UniswapV3 pool contract

function POOL() external view returns (IUniswapV3Pool _pool);

Returns

NameTypeDescription
_poolIUniswapV3PoolThe underlying UniswapV3 pool contract

IS_WETH_TOKEN0

Returns true if WETH token is the token0

function IS_WETH_TOKEN0() external view returns (bool _isWethToken0);

Returns

NameTypeDescription
_isWethToken0boolIf WETH is token0

seederRewards

Returns the pending to the corresponding account

function seederRewards(address _account)
    external
    view
    returns (uint256 wethPaid, uint256 tokenPaid, uint256 wethAvailable, uint256 tokenAvailable);

Parameters

NameTypeDescription
_accountaddressThe address of the account

Returns

NameTypeDescription
wethPaiduint256The amount of claimed rewards in WETH
tokenPaiduint256The amount of claimed rewards in the non-WETH token
wethAvailableuint256The amount of pending rewards in WETH
tokenAvailableuint256The amount of pending rewards in the non-WETH token

poolRewards

Returns the status of a corresponding pool manager

function poolRewards() external view returns (uint256 wethPerSeededLiquidity, uint256 tokenPerSeededLiquidity);

Returns

NameTypeDescription
wethPerSeededLiquidityuint256The value of the reward per WETH locked
tokenPerSeededLiquidityuint256The value of the reward per non-WETH token locked

deprecateLockManager

Deprecates the current lock manager and deploys a new one

function deprecateLockManager() external;

mintLiquidityForFullRange

Mint liquidity for the full-range position

function mintLiquidityForFullRange(uint256 _wethAmount, uint256 _tokenAmount) external;

Parameters

NameTypeDescription
_wethAmountuint256The amount of WETH token to be inserted in the full-range position
_tokenAmountuint256The amount of non-WETH token to be inserted in the full-range position

burn

Burns an amount of liquidity provided by a seeder

The voting power for the user remains the same but they donate all rewards

function burn(uint256 _liquidity) external;

Parameters

NameTypeDescription
_liquidityuint256The amount of liquidity

uniswapV3MintCallback

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

It is only called in the creation of the full range and when positions need to be updated

function uniswapV3MintCallback(uint256 _amount0Owed, uint256 _amount1Owed, bytes calldata _data) external;

Parameters

NameTypeDescription
_amount0Oweduint256The amount of token0
_amount1Oweduint256The amount of token1
_databytesThe data that differentiates through an address whether to mint or transfer from for the full range

increaseFullRangePosition

Increases the full-range position. The deposited tokens can not withdrawn and all of the generated fees with only benefit the pool itself

function increaseFullRangePosition(address _donor, uint128 _liquidity, uint160 _sqrtPriceX96) external;

Parameters

NameTypeDescription
_donoraddressThe user that will provide WETH and the other token
_liquidityuint128The liquidity that will be minted
_sqrtPriceX96uint160A sqrt price representing the current pool prices

increaseFullRangePosition

Increases the full-range position with a given liquidity

Pool manager will make a callback to the fee manager, who will provide the liquidity

function increaseFullRangePosition(uint256 _wethAmount, uint256 _tokenAmount)
    external
    returns (uint256 __amountWeth, uint256 __amountToken);

Parameters

NameTypeDescription
_wethAmountuint256The amount of WETH token to be inserted in the full-range position
_tokenAmountuint256The amount of non-WETH to be inserted in the full-range position

Returns

NameTypeDescription
__amountWethuint256The amount in WETH added to the full range
__amountTokenuint256The amount in non-WETH token added to the full range

collectFees

Claims the fees from the UniswapV3 pool and stores them in the FeeManager

function collectFees() external;

claimRewards

Returns the rewards generated by a caller

function claimRewards(address _to) external returns (uint256 _rewardWeth, uint256 _rewardToken);

Parameters

NameTypeDescription
_toaddressThe recipient the rewards

Returns

NameTypeDescription
_rewardWethuint256The amount of rewards in WETH that were claimed
_rewardTokenuint256The amount of rewards in non-WETH token that were claimed

claimable

Returns the total amount of WETH claimable for a given account

function claimable(address _account) external view returns (uint256 _wethClaimable, uint256 _tokenClaimable);

Parameters

NameTypeDescription
_accountaddressThe address of the account

Returns

NameTypeDescription
_wethClaimableuint256The amount of WETH claimable
_tokenClaimableuint256The amount of non-WETH token claimable

burn1

Burns a little bit of liquidity in the pool to produce a new observation

The oracle corrections require at least 2 post-manipulation observations to work properly When there is no new observations after a manipulation, the oracle will make then with this function

function burn1() external;

Events

SeederLiquidityBurned

Emitted when a seeder burns liquidity

event SeederLiquidityBurned(uint256 _liquidity);

LockManagerDeprecated

Emitted when a lock manager is deprecated

event LockManagerDeprecated(ILockManager _oldLockManager, ILockManager _newLockManager);

FeesCollected

Emitted when fees are collected

event FeesCollected(uint256 _totalFeeWeth, uint256 _totalFeeToken);

RewardsAdded

Emitted when rewards are added to a pool manager

event RewardsAdded(uint256 _wethAmount, uint256 _tokenAmount);

ClaimedRewards

Emitted when a seeder claims their rewards

event ClaimedRewards(address _user, address _to, uint256 _wethAmount, uint256 _tokenAmount);

Errors

PoolManager_OnlyFactory

Thrown when someone other than the factory tries to call the method

error PoolManager_OnlyFactory();

PoolManager_OnlyPool

Thrown when someone other than the pool tries to call the method

error PoolManager_OnlyPool();

PoolManager_ActiveLockManager

Thrown when someone tries to deploy a new lock manager while the old one is still not deprecated

error PoolManager_ActiveLockManager();

PoolManager_ZeroAmount

Thrown when the amount is zero

error PoolManager_ZeroAmount();

PoolManager_ZeroAddress

Thrown when the provided address is zero

error PoolManager_ZeroAddress();

PoolManager_NoRewardsToClaim

Thrown when the user doesn't have rewards to claim

error PoolManager_NoRewardsToClaim();

PoolManager_PoolManipulated

Thrown when the price oracle detects a manipulation

error PoolManager_PoolManipulated();

PoolManager_InvalidFeeManager

Thrown when the FeeManager provided is incorrect

error PoolManager_InvalidFeeManager();

PoolManager_InvalidPriceOracle

Thrown when the caller of the burn1 function is not the current oracle

error PoolManager_InvalidPriceOracle();

Structs

SeederRewards

The amounts of paid and available rewards per seeder

struct SeederRewards {
    uint256 wethPaid;
    uint256 tokenPaid;
    uint256 wethAvailable;
    uint256 tokenAvailable;
}

PoolRewards

Pool status for internal accountancy

struct PoolRewards {
    uint256 wethPerSeededLiquidity;
    uint256 tokenPerSeededLiquidity;
}

LockManagerParams

The parameters for the lock manager

struct LockManagerParams {
    IPoolManagerFactory factory;
    IStrategy strategy;
    IERC20 token;
    IERC20 weth;
    IUniswapV3Pool pool;
    bool isWethToken0;
    uint24 fee;
    address governance;
    uint256 index;
}

Position

UniswapV3 pool position

struct Position {
    int24 lowerTick;
    int24 upperTick;
}