Skip to main content

Fees

Swap Fees

Fee, is a mathematical representation of the fee paid by swappers in hundredths of a percent, and it is initialized with a predetermined value in each pool. Two numbers fee_growth_global_x and fee_growth_global_y are the global fees (in xx and yy) that LPs have accrued. When a swap occurs, the values of all of the above variables change. However, only LL changes when liquidity is provided or removed.

When the tick is crossed, the contract must keep track of the amount of gross liquidity that should be added or withdrawn, as well as the fees received above and below the tick, in order to be effective. When the tick indexes are updated, the variables in the tick-indexed state are updated. Consider that, after updating the contract's global state, the pool changes the fees collected and liquidity at the precise price point, which is upper tick and lower tick in the contract's global state (lower tick).

It also keeps track of the current protocol fee. It is set to a constant value of 0.10.1 and generates a portion of the swapper fees that are currently going to protocol rather than liquidity providers.