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.
Parameter | Type | Description |
---|---|---|
from | address | Address of the old pool |
amount | uint256 | Amount 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
Name | Type | Description |
---|---|---|
token | IERC20 | The token managed by this pool |
localTokenDecimals | uint8 | The number of decimals for the token on the local chain |
allowlist | address[] | 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 |
rmnProxy | address | Address of the RMN proxy |
acceptLiquidity | bool | Whether the pool accepts external liquidity |
router | address | Address of the router |
lockOrBurn
function lockOrBurn(
Pool.LockOrBurnInV1 calldata lockOrBurnIn
) external virtual override returns (Pool.LockOrBurnOutV1 memory)
Locks the token in the pool.
Parameters
Name | Type | Description |
---|---|---|
lockOrBurnIn | Pool.LockOrBurnInV1 | Input parameters for the lock operation |
Return Value
Type | Description |
---|---|
Pool.LockOrBurnOutV1 | Struct 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
Name | Type | Description |
---|---|---|
releaseOrMintIn | Pool.ReleaseOrMintInV1 | Input parameters for the release operation |
Return Value
Type | Description |
---|---|
Pool.ReleaseOrMintOutV1 | Struct containing the destination amount |
Liquidity Management Functions
getRebalancer
function getRebalancer() external view returns (address)
Gets the LiquidityManager address.
Return Value
Type | Description |
---|---|
address | The current liquidity manager (can be address(0) if none configured) |
setRebalancer
function setRebalancer(
address rebalancer
) external onlyOwner
Sets the LiquidityManager address.
Parameters
Name | Type | Description |
---|---|---|
rebalancer | address | New rebalancer address |
canAcceptLiquidity
function canAcceptLiquidity() external view returns (bool)
Checks if the pool can accept liquidity.
Return Value
Type | Description |
---|---|
bool | True if the pool can accept liquidity |
provideLiquidity
function provideLiquidity(
uint256 amount
) external
Adds liquidity to the pool. The tokens should be approved first.
Parameters
Name | Type | Description |
---|---|---|
amount | uint256 | Amount of liquidity to provide |
withdrawLiquidity
function withdrawLiquidity(
uint256 amount
) external
Removes liquidity from the pool. The tokens will be sent to msg.sender.
Parameters
Name | Type | Description |
---|---|---|
amount | uint256 | Amount 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:
-
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
-
Gradual Upgrade (if multicall is not available):
- First, transfer some liquidity to the new pool
- Update the TokenAdminRegistry to use the new pool
- New transactions will now use the new pool and its liquidity
- Finally, transfer the remaining liquidity using this function
Parameters
Name | Type | Description |
---|---|---|
from | address | Address of the old pool |
amount | uint256 | Amount of liquidity to transfer |
typeAndVersion
string public constant override typeAndVersion = "LockReleaseTokenPool 1.5.1"
Returns the type and version of the contract.
Return Value
Type | Description |
---|---|
string | The string "LockReleaseTokenPool 1.5.1" |