◆ Purpose

Uniswap has a fee of 0.3%.

1/6 of that 0.3% goes to the uniswap foundation

◆ Input & Return value

(uint112 _reserve0, uint112 _reserve1) ⇒ (bool feeOn)

https://github.com/Uniswap/v2-core/blob/master/contracts/UniswapV2Pair.sol#L89

Collecting this 0.05% fee at the time of the trade would impose an additional gas cost on every trade. To avoid this, accumulated fees are collected only when liquidity is deposited or withdrawn. The contract computes the accumulated fees, and mints new liquidity tokens to the fee beneficiary, immediately before any tokens are minted or burned.

Quoted by: Uniswap V2 Whitepaper

◆ Example

reserve0(WETH) = 43086702975516

reserve1(USDC) = 41997552572672937696884

TRUE

◆ Code and Explain

function _mintFee(uint112 _reserve0, uint112 _reserve1) private returns (bool feeOn) {
        // check the address to send fee
	      address feeTo = IUniswapV2Factory(factory).feeTo(); 
        feeOn = feeTo != address(0);
        uint _kLast = kLast; // gas savings 
				// "kLast" is stored in STORAGE, "_kLast" is stored in MEMORY
				// Maybe the material below the code is useful
        if (feeOn) {
            if (_kLast != 0) {
                uint rootK = Math.sqrt(uint(_reserve0).mul(_reserve1));
                uint rootKLast = Math.sqrt(_kLast);
                if (rootK > rootKLast) {
                    uint numerator = totalSupply.mul(rootK.sub(rootKLast));
                    uint denominator = rootK.mul(5).add(rootKLast);
                    uint liquidity = numerator / denominator;
                    if (liquidity > 0) _mint(feeTo, liquidity);
                }
            }
        } else if (_kLast != 0) {
            kLast = 0;
        }

◆ Resources