Skip to main content
Helpful?

ProtocolFees

Git Source | Generated with forge doc

Inherits: IProtocolFees, Owned

Contract handling the setting and accrual of protocol fees

State Variables

protocolFeesAccrued

Given a currency address, returns the protocol fees accrued in that currency

mapping(Currency currency => uint256 amount) public protocolFeesAccrued;

protocolFeeController

Returns the current protocol fee controller address

IProtocolFeeController public protocolFeeController;

BLOCK_LIMIT_BPS

uint256 private constant BLOCK_LIMIT_BPS = 100;

Functions

constructor

constructor() Owned(msg.sender);

setProtocolFeeController

Sets the protocol fee controller

function setProtocolFeeController(IProtocolFeeController controller) external onlyOwner;

Parameters

NameTypeDescription
controllerIProtocolFeeControllerThe new protocol fee controller

setProtocolFee

Sets the protocol fee for the given pool

function setProtocolFee(PoolKey memory key, uint24 newProtocolFee) external;

Parameters

NameTypeDescription
keyPoolKeyThe key of the pool to set a protocol fee for
newProtocolFeeuint24The fee to set

collectProtocolFees

Collects the protocol fees for a given recipient and currency, returning the amount collected

This will revert if the contract is unlocked

function collectProtocolFees(address recipient, Currency currency, uint256 amount)
external
returns (uint256 amountCollected);

Parameters

NameTypeDescription
recipientaddressThe address to receive the protocol fees
currencyCurrencyThe currency to withdraw
amountuint256The amount of currency to withdraw

Returns

NameTypeDescription
amountCollecteduint256The amount of currency successfully withdrawn

_isUnlocked

abstract internal function to allow the ProtocolFees contract to access the lock

function _isUnlocked() internal virtual returns (bool);

_getPool

abstract internal function to allow the ProtocolFees contract to access pool state

this is overridden in PoolManager.sol to give access to the _pools mapping

function _getPool(PoolId id) internal virtual returns (Pool.State storage);

_fetchProtocolFee

Fetch the protocol fees for a given pool

the success of this function is false if the call fails or the returned fees are invalid

to prevent an invalid protocol fee controller from blocking pools from being initialized the success of this function is NOT checked on initialize and if the call fails, the protocol fees are set to 0.

function _fetchProtocolFee(PoolKey memory key) internal returns (uint24 protocolFee);

_updateProtocolFees

function _updateProtocolFees(Currency currency, uint256 amount) internal;
Helpful?