Skip to main content
Helpful?

ProtocolFeeLibrary

Git Source | Generated with forge doc

library of functions related to protocol fees

State Variables

MAX_PROTOCOL_FEE

Max protocol fee is 0.1% (1000 pips)

Increasing these values could lead to overflow in Pool.swap

uint16 public constant MAX_PROTOCOL_FEE = 1000;

FEE_0_THRESHOLD

Thresholds used for optimized bounds checks on protocol fees

uint24 internal constant FEE_0_THRESHOLD = 1001;

FEE_1_THRESHOLD

uint24 internal constant FEE_1_THRESHOLD = 1001 << 12;

PIPS_DENOMINATOR

the protocol fee is represented in hundredths of a bip

uint256 internal constant PIPS_DENOMINATOR = 1_000_000;

Functions

getZeroForOneFee

function getZeroForOneFee(uint24 self) internal pure returns (uint16);

getOneForZeroFee

function getOneForZeroFee(uint24 self) internal pure returns (uint16);

isValidProtocolFee

function isValidProtocolFee(uint24 self) internal pure returns (bool valid);

calculateSwapFee

here self is just a single direction's protocol fee, not a packed type of 2 protocol fees

function calculateSwapFee(uint16 self, uint24 lpFee) internal pure returns (uint24 swapFee);
Helpful?