ProtocolFeesController

The protocol Fees controller is used to manage protocol and pool creator fees for the Vault. Like the authorizer, it can be updated through governance.

getGlobalProtocolSwapFeePercentage

function getGlobalProtocolSwapFeePercentage() external view returns (uint256);

This function returns the current global protocol swap fee percentage. This is the default value used for new pools deployed by standard factories.

getGlobalProtocolYieldFeePercentage

function getGlobalProtocolYieldFeePercentage() external view returns (uint256);

This function returns the current global protocol yield fee percentage. This is the default value used for new pools deployed by standard factories.

getPoolProtocolSwapFeeInfo

function getPoolProtocolSwapFeeInfo(address pool) external view returns (uint256, bool);

This function returns the current protocol swap fee for a given pool and a boolean indicating whether the protocol fee has been overridden by governance. Only pools whose protocol fees have NOT been overridden can be permissionlessly updated using updateProtocolSwapFeePercentage.

Parameters:

NameTypeDescription
pooladdressThe pool for which to get the protocol swap fee info

getPoolProtocolYieldFeeInfo

function getPoolProtocolYieldFeeInfo(address pool) external view returns (uint256, bool);

This function returns the current protocol yield fee for a given pool and a boolean indicating if the protocol fee has been overridden by governance. Only pools whose protocol fees have NOT been overridden can be permissionlessly updated using updateProtocolYieldFeePercentage.

Parameters:

NameTypeDescription
pooladdressThe pool for which to get the protocol yield fee info

collectAggregateFees

function collectAggregateFees(address pool) external;

This function collects accumulated aggregate swap and yield fees for the specified pool. It makes a permissioned call on collectAggregateFees in the Vault to calculate the fee amounts, then calls sendTo to transfer the tokens, after which they are distributed to the protocol and pool creator balances. As this affects Vault accounting, it is invoked through unlock and a local "hook", with the ProtocolFeeController acting as the "Router". The Vault function supplies credit for the tokens to be taken as fees, and the fee controller takes debt (through sendTo), ensuring valid settlement.

Parameters:

NameTypeDescription
pooladdressThe pool on which all aggregate fees should be collected

getProtocolFeeAmounts

function getProtocolFeeAmounts(address pool) external view returns (uint256[] memory feeAmounts);

This function returns the amount of each pool token allocated to the protocol and available for withdrawal. It includes both swap and yield fees. Calling collectAggregateFees will transfer any pending fees from the Vault to the Protocol Fee Controller, and allocate them to the protocol and pool creator.

Parameters:

NameTypeDescription
pooladdressThe pool on which fees were collected

getPoolCreatorFeeAmounts

function getPoolCreatorFeeAmounts(address pool) external view returns (uint256[] memory feeAmounts);

This function returns the amount of each pool token allocated to the pool creator and available for withdrawal. It includes both swap and yield fees. Calling collectAggregateFees on the Vault will transfer any pending fees from the Vault to the Protocol Fee Controller, and allocate them to the protocol and pool creator.

Parameters:

NameTypeDescription
pooladdressThe pool on which fees were collected

computeAggregateFeePercentage

function computeAggregateFeePercentage(
    uint256 protocolFeePercentage,
    uint256 poolCreatorFeePercentage
) external pure returns (uint256 aggregateFeePercentage);

This function returns a calculated aggregate percentage from protocol and pool creator fee percentages. It's not tied to any particular pool; this just performs the low-level "additive fee" calculation. Note that this respects the Vault's 24-bit aggregate fee precision limit. If you try to set a fee such that the aggregate requires greater than 24-bit precision, this will revert.

Parameters:

NameTypeDescription
protocolFeePercentageuint256The protocol portion of the aggregate fee percentage
poolCreatorFeePercentageuint256The pool creator portion of the aggregate fee percentage

updateProtocolSwapFeePercentage

function updateProtocolSwapFeePercentage(address pool) external;

This function overrides the protocol swap fee percentage for a specific pool. This is a permissionless call, and will set the pool's fee to the current global fee, if it is different from the current value, and the fee is not controlled by governance (i.e., has never been overridden).

Parameters:

NameTypeDescription
pooladdressThe pool we are setting the protocol swap fee on

updateProtocolYieldFeePercentage

function updateProtocolYieldFeePercentage(address pool) external;

This function overrides the protocol yield fee percentage for a specific pool. This is a permissionless call, and will set the pool's fee to the current global fee, if it is different from the current value, and the fee is not controlled by governance (i.e., has never been overridden).

Parameters:

NameTypeDescription
pooladdressThe pool we are setting the protocol yield fee on

registerPool

function registerPool(
    address pool,
    address poolCreator,
    bool protocolFeeExempt
) external returns (uint256 aggregateSwapFeePercentage, uint256 aggregateYieldFeePercentage);

This function adds pool-specific entries for protocol swap and yield percentages. This must be called from the Vault during pool registration. It will initialize the pool to the global protocol fee percentage values (or 0, if the protocolFeeExempt flag is set), and return the initial aggregate fee percentages, based on an initial pool creator fee of 0. The idea here is to allow protocols to "test" new pool types with zero fees. Governance can always override the protocol fee percentages: the exemption only sets the starting value, and does not mean the pool creator controls the protocol fee. (The pool creator does exclusively control pool creator fees.)

Parameters:

NameTypeDescription
pooladdressThe pool being registered
poolCreatoraddressThe address of the pool creator (or 0 if there won't be a pool creator fee)
protocolFeeExemptboolIf true, the pool is initially exempt from protocol fees

receiveAggregateFees

function receiveAggregateFees(
    address pool,
    uint256[] memory swapFeeAmounts,
    uint256[] memory yieldFeeAmounts
) external;

This function is called by the Vault when aggregate swap or yield fees are collected. Note that since charging protocol fees (i.e., distributing tokens between pool and fee balances) occurs in the Vault, but fee collection happens in the ProtocolFeeController, the swap fees reported here may encompass multiple operations. This is a permissioned call; the caller must be the Vault.

Parameters:

NameTypeDescription
pooladdressThe pool on which the swap fees were charged
swapFeeAmountsuint256[]An array sorted in token registration order, with the swap fees collected in each token
yieldFeeAmountsuint256[]An array sorted in token registration order, with the yield fees collected in each token

setGlobalProtocolSwapFeePercentage

function setGlobalProtocolSwapFeePercentage(uint256 newProtocolSwapFeePercentage) external;

This function sets the global protocol swap fee percentage, used by standard pools. This is a permissioned call.

Parameters:

NameTypeDescription
newProtocolSwapFeePercentageuint256The new protocol swap fee percentage

setGlobalProtocolYieldFeePercentage

function setGlobalProtocolYieldFeePercentage(uint256 newProtocolYieldFeePercentage) external;

This function sets the global protocol yield fee percentage, used by standard pools. This is a permissioned call.

Parameters:

NameTypeDescription
newProtocolYieldFeePercentageuint256The new protocol yield fee percentage

setProtocolSwapFeePercentage

function setProtocolSwapFeePercentage(address pool, uint256 newProtocolSwapFeePercentage) external;

This function overrides the protocol swap fee percentage for a specific pool. This is a permissioned call.

Parameters:

NameTypeDescription
pooladdressThe pool we are setting the protocol swap fee on
newProtocolSwapFeePercentageuint256The new protocol swap fee percentage for the specific pool

setProtocolYieldFeePercentage

function setProtocolYieldFeePercentage(address pool, uint256 newProtocolYieldFeePercentage) external;

This function overrides the protocol yield fee percentage for a specific pool. This is a permissioned call.

Parameters:

NameTypeDescription
pooladdressThe pool we are setting the protocol yield fee on
newProtocolYieldFeePercentageuint256The new protocol yield fee percentage

setPoolCreatorSwapFeePercentage

function setPoolCreatorSwapFeePercentage(address pool, uint256 poolCreatorSwapFeePercentage) external;

This function assigns a new pool creator swap fee percentage to the specified pool. This is a permissioned call; the caller must be the pool creator.

Parameters:

NameTypeDescription
pooladdressThe address of the pool for which the pool creator fee will be changed
poolCreatorSwapFeePercentageuint256The new pool creator swap fee percentage to apply to the pool

setPoolCreatorYieldFeePercentage

function setPoolCreatorYieldFeePercentage(address pool, uint256 poolCreatorYieldFeePercentage) external;

This function assigns a new pool creator yield fee percentage to the specified pool. This is a permissioned call; the caller must be the pool creator.

Parameters:

NameTypeDescription
pooladdressThe address of the pool for which the pool creator fee will be changed
poolCreatorYieldFeePercentageuint256The new pool creator yield fee percentage to apply to the pool

withdrawProtocolFees

function withdrawProtocolFees(address pool, address recipient) external;

This function withdraws collected protocol fees for a given pool. It sends swap and yield protocol fees to the recipient. This is a permissioned call.

Parameters:

NameTypeDescription
pooladdressThe pool on which fees were collected
recipientaddressAddress to send the tokens

withdrawPoolCreatorFees

function withdrawPoolCreatorFees(address pool, address recipient) external;

This function withdraws collected pool creator fees for a given pool. It sends swap and yield pool creator fees to the recipient. This is a permissioned call; the caller must be the pool creator.

Parameters:

NameTypeDescription
pooladdressThe pool on which fees were collected
recipientaddressAddress to send the tokens

withdrawPoolCreatorFees

function withdrawPoolCreatorFees(address pool) external;

This function withdraws collected pool creator fees for a given pool. It sends swap and yield pool creator fees to the registered pool creator. Since there is no recipient, this is a permissionless call, allowing easier automation of fee collection.

Parameters:

NameTypeDescription
pooladdressThe pool on which fees were collected