# CCIP v1.6.1 LockReleaseTokenPool Contract API Reference
Source: https://docs.chain.link/ccip/api-reference/evm/v1.6.1/lock-release-token-pool

> For the complete documentation index, see [llms.txt](/llms.txt).

<Aside type="note" title="Integrate Chainlink CCIP v1.6.1 into your project">
  <Tabs sharedStore="ccip-v1-6-1-package" client:visible>
    <Fragment slot="tab.1">npm</Fragment>
    <Fragment slot="tab.2">yarn</Fragment>
    <Fragment slot="tab.3">foundry</Fragment>

    <Fragment slot="panel.1">
      If you use [NPM](https://www.npmjs.com/), install the [@chainlink/contracts-ccip NPM package](https://www.npmjs.com/package/@chainlink/contracts-ccip):

      ```shell
      npm install @chainlink/contracts-ccip@1.6.1
      ```
    </Fragment>

    <Fragment slot="panel.2">
      If you use [Yarn](https://yarnpkg.com/), install the [@chainlink/contracts-ccip NPM package](https://www.npmjs.com/package/@chainlink/contracts-ccip):

      ```shell
      yarn add @chainlink/contracts-ccip@1.6.1
      ```
    </Fragment>

    <Fragment slot="panel.3">
      If you use [Foundry](https://book.getfoundry.sh/), install the package:

      ```shell
      forge install smartcontractkit/chainlink-ccip@bbab0601244ce58e2ffac0dbc178a80aab1fa4a3
      ```
    </Fragment>
  </Tabs>
</Aside>

## LockReleaseTokenPool

A specialized token pool for managing native tokens through a lock and release mechanism, with support for liquidity management.

[Git Source](https://github.com/smartcontractkit/chainlink-ccip/tree/contracts-ccip-v1.6.1/chains/evm/contracts/pools/LockReleaseTokenPool.sol)

**Inherits:**

- [TokenPool](/ccip/api-reference/evm/v1.6.1/token-pool)
- [ITypeAndVersion](/ccip/api-reference/evm/v1.6.1/i-type-and-version)

> \*\*NOTE\*\*
>
>
>
> A token pool designed for native chain tokens with the following features:
>
> - Manages one token per pool instance
> - Implements lock and release mechanisms for cross-chain transfers
> - Provides liquidity management functions for proper balance tracking
> - Supports liquidity provider operations
> - Facilitates pool upgrades through liquidity transfer mechanisms

## Events

### LiquidityTransferred

```solidity
event LiquidityTransferred(address indexed from, uint256 amount);
```

<Aside>Emitted when liquidity is transferred from an older pool version during an upgrade.</Aside>

**Parameters**

| Name     | Type      | Indexed | Description                         |
| -------- | --------- | ------- | ----------------------------------- |
| `from`   | `address` | Yes     | The source pool address             |
| `amount` | `uint256` | No      | The amount of liquidity transferred |

### LiquidityAdded

```solidity
event LiquidityAdded(address indexed provider, uint256 indexed amount);
```

<Aside>Emitted when liquidity is added to the pool via [`provideLiquidity`](#provideliquidity).</Aside>

**Parameters**

| Name       | Type      | Indexed | Description                           |
| ---------- | --------- | ------- | ------------------------------------- |
| `provider` | `address` | Yes     | The address providing the liquidity   |
| `amount`   | `uint256` | Yes     | The amount of liquidity added to pool |

### LiquidityRemoved

```solidity
event LiquidityRemoved(address indexed provider, uint256 indexed amount);
```

<Aside>Emitted when liquidity is removed from the pool via [`withdrawLiquidity`](#withdrawliquidity).</Aside>

**Parameters**

| Name       | Type      | Indexed | Description                               |
| ---------- | --------- | ------- | ----------------------------------------- |
| `provider` | `address` | Yes     | The address withdrawing the liquidity     |
| `amount`   | `uint256` | Yes     | The amount of liquidity removed from pool |

### RebalancerSet

```solidity
event RebalancerSet(address oldRebalancer, address newRebalancer);
```

<Aside>Emitted when the rebalancer (liquidity manager) address is updated via [`setRebalancer`](#setrebalancer).</Aside>

**Parameters**

| Name            | Type      | Indexed | Description                            |
| --------------- | --------- | ------- | -------------------------------------- |
| `oldRebalancer` | `address` | No      | The address of the previous rebalancer |
| `newRebalancer` | `address` | No      | The address of the new rebalancer      |

## Errors

### InsufficientLiquidity

```solidity
error InsufficientLiquidity();
```

<Aside>Thrown when attempting to withdraw more liquidity than available in the pool.</Aside>

## State Variables

### s\_rebalancer

```solidity
address internal s_rebalancer;
```

<Aside>The address of the current rebalancer (liquidity manager) authorized to manage pool liquidity.</Aside>

### typeAndVersion

```solidity
string public constant override typeAndVersion = "LockReleaseTokenPool 1.6.1";
```

<Aside>A constant identifier specifying the contract type and version number.</Aside>

## Functions

### constructor

```solidity
constructor(
  IERC20 token,
  uint8 localTokenDecimals,
  address[] memory allowlist,
  address rmnProxy,
  address router
) TokenPool(token, localTokenDecimals, allowlist, rmnProxy, router);
```

> \*\*NOTE\*\*
>
>
>
> Initializes the token pool with its configuration parameters:
>
> - Sets up the token contract reference
> - Configures decimal precision for local tokens
> - Establishes the initial whitelist
> - Links to the RMN proxy and router

**Parameters**

| Name                 | Type        | Description                               |
| -------------------- | ----------- | ----------------------------------------- |
| `token`              | `IERC20`    | The token contract to manage              |
| `localTokenDecimals` | `uint8`     | The decimal precision for the local token |
| `allowlist`          | `address[]` | Initial list of authorized addresses      |
| `rmnProxy`           | `address`   | Address of the RMN proxy contract         |
| `router`             | `address`   | Address of the router contract            |

### getRebalancer

Returns the current rebalancer address.

```solidity
function getRebalancer() external view returns (address);
```

> \*\*NOTE\*\*
>
>
>
> Provides the address of the current liquidity manager (rebalancer). Can return address(0) if none is configured.

**Returns**

| Type      | Description                           |
| --------- | ------------------------------------- |
| `address` | The current liquidity manager address |

### provideLiquidity

Adds external liquidity to the pool.

```solidity
function provideLiquidity(uint256 amount) external;
```

> \*\*NOTE\*\*
>
>
>
> Allows the rebalancer to add liquidity to the pool:
>
> - Requires prior token approval
> - Only callable by the authorized rebalancer
> - Only works if the pool accepts liquidity

**Parameters**

| Name     | Type      | Description                        |
| -------- | --------- | ---------------------------------- |
| `amount` | `uint256` | The amount of liquidity to provide |

### \_releaseOrMint

Internal function that implements the token release logic for a `LockReleaseTokenPool`.

```solidity
function _releaseOrMint(address receiver, uint256 amount) internal virtual override;
```

> \*\*NOTE\*\*
>
>
>
> Overrides the virtual [`_releaseOrMint`](/ccip/api-reference/evm/v1.6.1/token-pool#_releaseormint) function from the base `TokenPool` contract:
>
> - Provides the specific "release" implementation for the `LockReleaseTokenPool`.
> - Uses `safeTransfer` to send the specified amount of tokens to the receiver.

**Parameters**

| Name       | Type      | Description                       |
| ---------- | --------- | --------------------------------- |
| `receiver` | `address` | The address to receive the tokens |
| `amount`   | `uint256` | The number of tokens to release   |

### setRebalancer

Updates the rebalancer address.

```solidity
function setRebalancer(address rebalancer) external onlyOwner;
```

<Aside>Allows the owner to update the liquidity manager (rebalancer) address.</Aside>

**Parameters**

| Name         | Type      | Description                       |
| ------------ | --------- | --------------------------------- |
| `rebalancer` | `address` | The new rebalancer address to set |

### transferLiquidity

Transfers liquidity from an older pool version.

```solidity
function transferLiquidity(address from, uint256 amount) external onlyOwner;
```

> \*\*NOTE\*\*
>
>
>
> Facilitates pool upgrades by transferring liquidity from an older pool version:
>
> - Requires this pool to be set as rebalancer in the source pool
> - Can be used in conjunction with TokenAdminRegistry updates
> - Supports both atomic and gradual migration strategies
> - Enables smooth transition of liquidity and transactions

**Parameters**

| Name     | Type      | Description                         |
| -------- | --------- | ----------------------------------- |
| `from`   | `address` | The address of the source pool      |
| `amount` | `uint256` | The amount of liquidity to transfer |

### withdrawLiquidity

Removes liquidity from the pool.

```solidity
function withdrawLiquidity(uint256 amount) external;
```

> \*\*NOTE\*\*
>
>
>
> Allows the rebalancer to withdraw liquidity:
>
> - Only callable by the authorized rebalancer
> - Requires sufficient pool balance
> - Transfers tokens directly to the caller

**Parameters**

| Name     | Type      | Description                         |
| -------- | --------- | ----------------------------------- |
| `amount` | `uint256` | The amount of liquidity to withdraw |