CCIP v1.5.1 LockReleaseTokenPool Contract API Reference

The LockReleaseTokenPool contract manages tokens on their original blockchain (native chain). When tokens are transferred across chains:

  • On the source chain: tokens are locked (held) in this pool
  • On the destination chain: an equivalent amount is released to the recipient

Since this pool needs to hold tokens to release them later, it includes features to:

  • Add and remove liquidity (token reserves)
  • Track balances for both users and liquidity providers
  • Ensure proper accounting of all token movements

Errors

InsufficientLiquidity

error InsufficientLiquidity()

Thrown when there is not enough liquidity in the pool for a withdrawal.

LiquidityNotAccepted

error LiquidityNotAccepted()

Thrown when trying to provide liquidity to a pool that doesn't accept it.

Events

LiquidityTransferred

event LiquidityTransferred(address indexed from, uint256 amount)

Emitted when liquidity is transferred from an old pool version.

ParameterTypeDescription
fromaddressAddress of the old pool
amountuint256Amount of liquidity transferred

Functions

constructor

constructor(
    IERC20 token,
    uint8 localTokenDecimals,
    address[] memory allowlist,
    address rmnProxy,
    bool acceptLiquidity,
    address router
) TokenPool(token, localTokenDecimals, allowlist, rmnProxy, router)

Initializes the token pool with the specified parameters.

Parameters

NameTypeDescription
tokenIERC20The token managed by this pool
localTokenDecimalsuint8The number of decimals for the token on the local chain
allowlistaddress[]List of addresses allowed to be original senders for token transfers. When allowlist is enabled, it ensures only token-developer specified addresses can transfer tokens
rmnProxyaddressAddress of the RMN proxy
acceptLiquidityboolWhether the pool accepts external liquidity
routeraddressAddress of the router

lockOrBurn

function lockOrBurn(
    Pool.LockOrBurnInV1 calldata lockOrBurnIn
) external virtual override returns (Pool.LockOrBurnOutV1 memory)

Locks the token in the pool.

Parameters

NameTypeDescription
lockOrBurnInPool.LockOrBurnInV1Input parameters for the lock operation

Return Value

TypeDescription
Pool.LockOrBurnOutV1Struct containing destination token address and pool data

releaseOrMint

function releaseOrMint(
    Pool.ReleaseOrMintInV1 calldata releaseOrMintIn
) external virtual override returns (Pool.ReleaseOrMintOutV1 memory)

Releases tokens from the pool to the recipient.

Parameters

NameTypeDescription
releaseOrMintInPool.ReleaseOrMintInV1Input parameters for the release operation

Return Value

TypeDescription
Pool.ReleaseOrMintOutV1Struct containing the destination amount

Liquidity Management Functions

getRebalancer

function getRebalancer() external view returns (address)

Gets the LiquidityManager address.

Return Value

TypeDescription
addressThe current liquidity manager (can be address(0) if none configured)

setRebalancer

function setRebalancer(
    address rebalancer
) external onlyOwner

Sets the LiquidityManager address.

Parameters

NameTypeDescription
rebalanceraddressNew rebalancer address

canAcceptLiquidity

function canAcceptLiquidity() external view returns (bool)

Checks if the pool can accept liquidity.

Return Value

TypeDescription
boolTrue if the pool can accept liquidity

provideLiquidity

function provideLiquidity(
    uint256 amount
) external

Adds liquidity to the pool. The tokens should be approved first.

Parameters

NameTypeDescription
amountuint256Amount of liquidity to provide

withdrawLiquidity

function withdrawLiquidity(
    uint256 amount
) external

Removes liquidity from the pool. The tokens will be sent to msg.sender.

Parameters

NameTypeDescription
amountuint256Amount of liquidity to remove

transferLiquidity

function transferLiquidity(address from, uint256 amount) external onlyOwner

Transfers liquidity from an old version of the pool to this new pool. This function is specifically designed for pool upgrades.

There are two ways to use this function during a pool upgrade:

  1. Single Transaction Upgrade (if multicall is available):

    • Call this function at the same time as updating the pool in TokenAdminRegistry
    • This ensures a smooth transition of both liquidity and transactions
  2. Gradual Upgrade (if multicall is not available):

    1. First, transfer some liquidity to the new pool
    2. Update the TokenAdminRegistry to use the new pool
    3. New transactions will now use the new pool and its liquidity
    4. Finally, transfer the remaining liquidity using this function

Parameters

NameTypeDescription
fromaddressAddress of the old pool
amountuint256Amount of liquidity to transfer

typeAndVersion

string public constant override typeAndVersion = "LockReleaseTokenPool 1.5.1"

Returns the type and version of the contract.

Return Value

TypeDescription
stringThe string "LockReleaseTokenPool 1.5.1"

Get the latest Chainlink content straight to your inbox.