# ConcentratedLiquidityPool

{% embed url="<https://github.com/pangea-protocol/pangea-core/blob/main/contracts/pool/ConcentratedLiquidityPool.sol>" %}

## Overview

`Concentrated Liquidity Pool`은 Pangea의 Exchange Module 중 코어 컨트랙트로, 크게 6가지 기능을 수행합니다.

1. &#x20;MINT : 포지션 생성
2. BURN : 포지션 소각
3. SWAP : 풀에서 스왑처리
4. COLLECT : 발생한 스왑 수수료 수취
5. FLASH : flash loan 수행
6. DEPOSIT\_AIRDROP : 에어드랍 보상 예치 (예치된 에어드랍 보상은 1주간 선형 분배)

Concentrated Liquidity Pool은 유저의 자산을 직접적으로 다루기 때문에 Non-Upgradable Contract로 설계되었으며, low level 메서드로 구성되어 있습니다.

이를 처리하기 위해 Concentrated LiquidityPool의 메서드를 직접 호출하기 보다 high level contract인 ConcentratedLiquidityPoolManager와 poolRouter를 통해 호출하길 권합니다.&#x20;

## Methods

### burn

```solidity
function burn(int24 lower, int24 upper, uint128 amount) external nonpayable returns (uint256 token0Amount, uint256 token1Amount)
```

Burns LP tokens - should be called via the Concentrated Liquidity pool manager contract.

### collect

```solidity
function collect(int24 lower, int24 upper, uint256 desiredToken0Fees, uint256 desiredToken1Fees) external nonpayable returns (uint256 token0Fees, uint256 token1Fees)
```

Collects tokens owed to a position

### collectProtocolFee

```solidity
function collectProtocolFee() external nonpayable returns (uint128, uint128)
```

### factory

```solidity
function factory() external view returns (address)
```

Returns the address of the factory contract

### feeGrowthGlobal0

```solidity
function feeGrowthGlobal0() external view returns (uint256)
```

The fee growth of token0 collected per unit of liquidity for the entire life of the pool

### feeGrowthGlobal1

```solidity
function feeGrowthGlobal1() external view returns (uint256)
```

The fee growth of token1 collected per unit of liquidity for the entire life of the pool

### flash

```solidity
function flash(address recipient, uint256 amount0, uint256 amount1, bytes data) external nonpayable
```

Receives token0 or token1 and pays it back with fee

### getAssets

```solidity
function getAssets() external view returns (address[] tokens)
```

Returns the list of the tokens of the pool, sorted by address

### getImmutables

```solidity
function getImmutables() external view returns (uint128 MAX_TICK_LIQUIDITY, uint24 tickSpacing, uint24 swapFee, address factory, address masterDeployer, address token0, address token1)
```

### getPriceAndNearestTicks

```solidity
function getPriceAndNearestTicks() external view returns (uint160 price, int24 nearestTick)
```

Returns the price and nearestTick

### getReserves

```solidity
function getReserves() external view returns (uint128 reserve0, uint128 reserve1)
```

Returns the reserve of token0 and token1

### getSecondsGrowthAndLastObservation

```solidity
function getSecondsGrowthAndLastObservation() external view returns (uint160 secondGrowthGlobal, uint32 lastObservation)
```

Returns the information about seconds growth global and the timestamp of the observation

### liquidity

```solidity
function liquidity() external view returns (uint128)
```

Returns the current in range liquidity available to the pool

### mint

```solidity
function mint(IConcentratedLiquidityPoolStruct.MintParams data) external nonpayable returns (uint256 liquidityMinted)
```

### nearestTick

```solidity
function nearestTick() external view returns (int24)
```

Returns the tick that is just below the current price.

### positions

```solidity
function positions(address owner, int24 lower, int24 upper) external view returns (struct IConcentratedLiquidityPoolStruct.Position)
```

Returns the information about the position

### price

```solidity
function price() external view returns (uint160)
```

Sqrt of price aka. √(token1/token0), multiplied by 2^96.

### rangeFeeGrowth

```solidity
function rangeFeeGrowth(int24 lower, int24 upper) external view returns (uint256 feeGrowthInside0, uint256 feeGrowthInside1)
```

Returns the fee growth of token0 & token1 inside the given price range

### swap

```solidity
function swap(bytes data) external nonpayable returns (uint256 amountOut)
```

Swaps one token for another. The router must prefund this contract and ensure there isn't too much slippage.

### swapFee

```solidity
function swapFee() external view returns (uint24)
```

*1000 corresponds to 0.1% fee. Fee is measured in pips.*

### tickSpacing

```solidity
function tickSpacing() external view returns (uint24)
```

Returns the tick spacing of the pool.

*Ticks can only be used at multiples of this value, minimum of 1 and always positive e.g.: a tickSpacing of 3 means ticks can be created every 3rd tick, i.e., ..., -6, -3, 0, 3, 6, ...Reference: tickSpacing of 100 -> 1% between ticks.*

### ticks

```solidity
function ticks(int24 tick) external view returns (struct IConcentratedLiquidityPoolStruct.Tick)
```

Looks up the information about a specific tick in the pool

### token0

```solidity
function token0() external view returns (address)
```

Returns the address of the first of the two tokens of the pool, sorted by address

### token1

```solidity
function token1() external view returns (address)
```

Returns the address of the second of the two tokens of the pool, sorted by address

### totalTicks

```solidity
function totalTicks() external view returns (uint256)
```

Returns the number of ticks in the Pool, starts with two ticks (MIN\_TICK \~ MAX\_TICK)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://pangeaswap.gitbook.io/pangeaswap/developers/contracts/core-contracts/concentratedliquiditypool.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
