> ## Documentation Index
> Fetch the complete documentation index at: https://docs.forteamm.io/llms.txt
> Use this file to discover all available pages before exploring further.

# LP Token

The LP token is a token that represents the liquidity in the pool. It is minted when liquidity is added to the pool and burned when liquidity is removed from the pool. The LP token is used to track the liquidity in the pool and to receive the LP fees. It conforms to an ERC721 enumerable token. It tracks 2 key variables: w<sub>j</sub> and r<sub>j</sub>. w<sub>j</sub> is the amount of liquidity provided by the liquidity provider. r<sub>j</sub> is the amount of revenue last claimed by the liquidity provider.

## Minting

When liquidity is added to the pool, the LP token is minted to the liquidity provider. The amount of liquidity provided is the amount of liquidity added to the pool. The amount of revenue last claimed is set to h<sub>n</sub> which is the revenue parameter of the pool associated with the LP token.

## Withdrawal

```solidity theme={null}
/**
 * @dev This is the function to withdraw liquidity from the pool.
 * @param tokenId The tokenId owned by the liquidity provider.
 * @param uj The amount of liquidity being withdrawn
 */
function withdrawLiquidity(uint256 tokenId, uint256 uj) external
```

When liquidity is removed from the pool, a parameter u<sub>j</sub> is passed in along with the token ID. u<sub>j</sub> is the desired amount of liquidity that an LP would like to withdraw from their position. A parameter q is produced dividing u<sub>j</sub> by w. In order to ensure an equal amount of LPs out, we calculate the amount of xTokens owed as q \_ (x<sub>max</sub> - x). The amount of xTokens owed is then subtracted from the pool's x value. Concurrently for the amount of y tokens owed, we calculate the amount of y tokens owed as q \_ (D<sub>n</sub> - L). The amount of y tokens owed is then subtracted from the pool's y value. If w<sub>j</sub> is less than u<sub>j</sub>, then this means that there is insufficient liquidity to withdraw and the transaction reverts. If w<sub>j</sub> is greater than u<sub>j</sub>, then u<sub>j</sub> is simply subtracted from w<sub>j</sub>, indicating that the LP is withdrawing a portion of their liquidity. If w<sub>j</sub> is equal to u<sub>j</sub>, then the LP token is burned and the liquidity is removed from the pool. After the amounts have been calculated, the pool's state is updated with a new value of h and w and the parameter Z<sub>n</sub> on the curve is updated to ensure proper accounting.

## Revenue Claiming

Revenue withdrawal is initiated in the ALTBC by the function `withdrawRevenue`.

```solidity theme={null}
function withdrawRevenue(uint256 tokenId, uint256 Q) external returns (uint256 revenue)
```

Q represents the amount of revenue being withdrawn. If Q is greater than the revenue available, the transaction reverts. A new value of revenue last claimed is then calculated as r<sub>j</sub> + Q/w<sub>j</sub>. Upon revenue being claimed, the updated r<sub>j</sub> is updated to add the amount of revenue claimed. The amount of revenue claimed is the amount of revenue that is being withdrawn. The amount of revenue being withdrawn is the amount of revenue that is being withdrawn from the pool.
