Skip to content

Commit

Permalink
remove transferLiquidity function. Liquidity transfers can be manual
Browse files Browse the repository at this point in the history
  • Loading branch information
jhweintraub committed Jan 6, 2025
1 parent 8d51b3b commit f5ced7b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 124 deletions.
14 changes: 6 additions & 8 deletions contracts/gas-snapshots/ccip.gas-snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -350,14 +350,12 @@ Router_routeMessage:test_routeMessage_ExecutionEvent() (gas: 153593)
Router_routeMessage:test_routeMessage_ManualExec() (gas: 31120)
SiloedLockReleaseTokenPool_lockOrBurn:testLockOrBurn_NonSiloedFunds_Success(uint256) (runs: 256, μ: 54330, ~: 54330)
SiloedLockReleaseTokenPool_lockOrBurn:test_LockOrBurn_SiloedFunds_Success(uint256) (runs: 256, μ: 75057, ~: 75057)
SiloedLockReleaseTokenPool_provideLiqudity:test_ProvideLiquidity_ChainNotSiloed_Success() (gas: 60201)
SiloedLockReleaseTokenPool_provideLiqudity:test_ProvideLiquidity_ChainSiloed_Success() (gas: 80899)
SiloedLockReleaseTokenPool_releaseOrMint:test_ReleaseOrMint_SiloedFunds_Success() (gas: 261601)
SiloedLockReleaseTokenPool_setRebalancer:test_setRebalancer_Success() (gas: 29682)
SiloedLockReleaseTokenPool_transferLiquidity:test_transferLiquidity_MultipleTransfers_Success() (gas: 3650435)
SiloedLockReleaseTokenPool_transferLiquidity:test_transferLiquidity_Success() (gas: 3627117)
SiloedLockReleaseTokenPool_updateChainSelectorMechanism:test_updateChainSelectorMechanism_Success() (gas: 76302)
SiloedLockReleaseTokenPool_withdrawLiqudity:test_withdrawLiquidity_Success() (gas: 69484)
SiloedLockReleaseTokenPool_provideLiqudity:test_ProvideLiquidity_ChainNotSiloed_Success() (gas: 60179)
SiloedLockReleaseTokenPool_provideLiqudity:test_ProvideLiquidity_ChainSiloed_Success() (gas: 80877)
SiloedLockReleaseTokenPool_releaseOrMint:test_ReleaseOrMint_SiloedFunds_Success() (gas: 261584)
SiloedLockReleaseTokenPool_setRebalancer:test_setRebalancer_Success() (gas: 29638)
SiloedLockReleaseTokenPool_updateChainSelectorMechanism:test_updateChainSelectorMechanism_Success() (gas: 76249)
SiloedLockReleaseTokenPool_withdrawLiqudity:test_withdrawLiquidity_Success() (gas: 69467)
TokenAdminRegistry_acceptAdminRole:test_acceptAdminRole() (gas: 44236)
TokenAdminRegistry_addRegistryModule:test_addRegistryModule() (gas: 67093)
TokenAdminRegistry_getAllConfiguredTokens:test_getAllConfiguredTokens_outOfBounds() (gas: 11363)
Expand Down
29 changes: 0 additions & 29 deletions contracts/src/v0.8/ccip/pools/SiloedLockReleaseTokenPool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ pragma solidity ^0.8.24;

import {ITypeAndVersion} from "../../shared/interfaces/ITypeAndVersion.sol";

import {Ownable2StepMsgSender} from "../../shared/access/Ownable2StepMsgSender.sol";
import {Pool} from "../libraries/Pool.sol";
import {TokenPool} from "./TokenPool.sol";

Expand Down Expand Up @@ -179,32 +178,4 @@ contract SiloedLockReleaseTokenPool is TokenPool, ITypeAndVersion {
i_token.safeTransfer(msg.sender, amount);
emit LiquidityRemoved(remoteChainSelector, msg.sender, amount);
}

/// @notice This function can be used to transfer liquidity from an older version of the pool to this pool. To do so
/// this pool will have to be set as the rebalancer in the older version of the pool. This allows it to transfer the
/// funds in the old pool to the new pool.
/// @dev When upgrading a LockRelease pool, this function can be called at the same time as the pool is changed in the
/// TokenAdminRegistry. This allows for a smooth transition of both liquidity and transactions to the new pool.
/// Alternatively, when no multicall is available, a portion of the funds can be transferred to the new pool before
/// changing which pool CCIP uses, to ensure both pools can operate. Then the pool should be changed in the
/// TokenAdminRegistry, which will activate the new pool. All new transactions will use the new pool and its
/// liquidity. Finally, the remaining liquidity can be transferred to the new pool using this function one more time.
/// @param remoteChainSelector the remote chain to set. If the chain is not siloed, then no accounting will be updated,
/// which can be considered the liquidity for all non-siloed chains sharing liquidity.
/// @param from The address of the old pool.
/// @param amount The amount of liquidity to transfer.
function transferLiquidity(uint64 remoteChainSelector, address from, uint256 amount) external onlyOwner {
// If The ownership has already been accepted, do not attempt to accept again as it would fail.
if (Ownable2StepMsgSender(from).owner() != address(this)) Ownable2StepMsgSender(from).acceptOwnership();

SiloedLockReleaseTokenPool(from).withdrawLiquidity(remoteChainSelector, amount);

// Since both siloed and non-siloed token liquidity can be transferred, allow transfers from both, but only
// update internal accounting for siloed chains.
if (s_siloedChainSelectors[remoteChainSelector]) {
s_lockedTokensByChainSelector[remoteChainSelector] += amount;
}

emit LiquidityTransferred(remoteChainSelector, from, amount);
}
}

This file was deleted.

0 comments on commit f5ced7b

Please sign in to comment.