The Fee Manager manages trading fees for pools and the global protocol fee.
The Pool Master is an independent module that could be replaced in the future. Since the pool master will forward all fee queries to the current fee manager, it's recommended to get fees directly with the pool master.
Interface
Fees are stored in uint24 type with 6 decimals. For a protocol fee of 30%, the value will be 30,000 and for a trading fee of 0.1%, the value would be 100.
Since the default value of uint24 in the mappings is zero, the custom fee value of pools without a specific custom fee is 0, which actually indicates the pool fee will inherit the default fee of its pool type.
For pools with zero custom fee type(uint24).max will be used as the custom fee. This does not affect the default swap fee of pool types and the protocol fee, and the 0 value simply indicates zero fees.
/// @dev The manager contract to control fees.
/// Management functions are omitted.
interface IFeeManager {
function defaultSwapFee(uint16 poolType) external view returns (uint24);
// [Deprecated] The old interface before the dynamic fees update.
//function customSwapFee(address pool) external view returns (uint24);
function feeRecipient() external view returns (address);
// [Deprecated] The old interface before the dynamic fees update.
//function protocolFee(uint16 poolType) external view returns (uint24);
// [Deprecated] The old interface before the dynamic fees update.
//function getSwapFee(address pool) external view returns (uint24 swapFee);
// [Recommended] The new interface after the dynamic fees update.
/// @dev Returns `0` for zero pool fee.
function getSwapFee(
address pool,
address sender,
address tokenIn,
address tokenOut,
bytes calldata data
) external view returns (uint24 fee);
// [Recommended] The new interface after the dynamic fees update.
/// @dev Returns `0` for zero pool fee.
function getProtocolFee(address pool) external view returns (uint24 fee);
// [Recommended] The new interface after the dynamic fees update.
function getFeeRecipient() external view returns (address recipient);
// [Recommended] The new interface after the dynamic fees update.
/// @dev Returns `type(uint24).max` for zero pool fee.
function poolSwapFee(address pool) external view returns (uint24);
// [Recommended] The new interface after the dynamic fees update.
/// @dev Returns `0` for zero pool fee.
function defaultProtocolFee(uint16 poolType) external view returns (uint24);
// [Recommended] The new interface after the dynamic fees update.
/// @dev Returns `type(uint24).max` for zero pool fee.
function poolProtocolFee(address pool) external view returns (uint24);
}