From bbc3daa039362f810e8a3738ff362ce60635128d Mon Sep 17 00:00:00 2001 From: DhairyaSethi <55102840+DhairyaSethi@users.noreply.github.com> Date: Thu, 19 Dec 2024 18:39:14 +0530 Subject: [PATCH] feat: update to latest spec: naming changes, setCurrentBridgedAmount, resolve existing pool bridgeAmount comment --- lib/ccip | 2 +- ...veV3Arbitrum_GHOCCIP151Upgrade_20241209.sol | 4 ++-- .../AaveV3E2E_GHOCCIP151Upgrade_20241209.t.sol | 5 +++-- ...veV3Ethereum_GHOCCIP151Upgrade_20241209.sol | 7 +++---- ...deableBurnMintTokenPool_1_4_WithdrawLiq.sol | 18 +++++++++--------- .../IUpgradeableBurnMintTokenPool.sol | 2 +- .../IUpgradeableLockReleaseTokenPool.sol | 1 + 7 files changed, 20 insertions(+), 19 deletions(-) diff --git a/lib/ccip b/lib/ccip index 8fea66bb8..3667707a5 160000 --- a/lib/ccip +++ b/lib/ccip @@ -1 +1 @@ -Subproject commit 8fea66bb81dbcb6d4c2332c1d45b68765766f3e2 +Subproject commit 3667707a5e3a0de9d1cff62f6cdac8dc14f20ed2 diff --git a/src/20241209_Multi_GHOCCIP151Upgrade/AaveV3Arbitrum_GHOCCIP151Upgrade_20241209.sol b/src/20241209_Multi_GHOCCIP151Upgrade/AaveV3Arbitrum_GHOCCIP151Upgrade_20241209.sol index b41168a33..9b37b5666 100644 --- a/src/20241209_Multi_GHOCCIP151Upgrade/AaveV3Arbitrum_GHOCCIP151Upgrade_20241209.sol +++ b/src/20241209_Multi_GHOCCIP151Upgrade/AaveV3Arbitrum_GHOCCIP151Upgrade_20241209.sol @@ -63,10 +63,10 @@ contract AaveV3Arbitrum_GHOCCIP151Upgrade_20241209 is IProposalGenericExecutor { ); GHO.addFacilitator(address(NEW_TOKEN_POOL), 'CCIP v1.5.1 TokenPool', uint128(bucketCapacity)); - NEW_TOKEN_POOL.transferLiquidity(address(EXISTING_TOKEN_POOL), bucketLevel); // mintTo + NEW_TOKEN_POOL.mintAndTransferLiquidity(address(EXISTING_TOKEN_POOL), bucketLevel); // mintTo _upgradeExistingTokenPool(); - UpgradeableBurnMintTokenPool(address(EXISTING_TOKEN_POOL)).withdrawLiquidity(bucketLevel); // burn + UpgradeableBurnMintTokenPool(address(EXISTING_TOKEN_POOL)).burnLiquidity(bucketLevel); // burn GHO.removeFacilitator(address(EXISTING_TOKEN_POOL)); } diff --git a/src/20241209_Multi_GHOCCIP151Upgrade/AaveV3E2E_GHOCCIP151Upgrade_20241209.t.sol b/src/20241209_Multi_GHOCCIP151Upgrade/AaveV3E2E_GHOCCIP151Upgrade_20241209.t.sol index 0070a9bac..9f6c94622 100644 --- a/src/20241209_Multi_GHOCCIP151Upgrade/AaveV3E2E_GHOCCIP151Upgrade_20241209.t.sol +++ b/src/20241209_Multi_GHOCCIP151Upgrade/AaveV3E2E_GHOCCIP151Upgrade_20241209.t.sol @@ -175,8 +175,9 @@ contract AaveV3E2E_GHOCCIP151Upgrade_20241209_Base is ProtocolV3TestBase { assertEq(l1.c.tokenAdminRegistry.getPool(address(l1.c.token)), address(l1.newTokenPool)); assertEq(l1.c.token.balanceOf(address(l1.existingTokenPool)), 0); - // ! todo upgrade existing pool to reset bridgedAmount? not necessary since we reset bridgeLimit - // assertEq(l1.existingTokenPool.getCurrentBridgedAmount(), 0); + // we are not resetting currentBridgedAmount on the existing pool, the pool is deprecated by + // resetting the bridge limit + assertNotEq(l1.existingTokenPool.getCurrentBridgedAmount(), 0); assertEq(l1.existingTokenPool.getBridgeLimit(), 0); assertGt(l1.c.token.balanceOf(address(l1.newTokenPool)), 0); diff --git a/src/20241209_Multi_GHOCCIP151Upgrade/AaveV3Ethereum_GHOCCIP151Upgrade_20241209.sol b/src/20241209_Multi_GHOCCIP151Upgrade/AaveV3Ethereum_GHOCCIP151Upgrade_20241209.sol index 0da88b41e..ea494bfd0 100644 --- a/src/20241209_Multi_GHOCCIP151Upgrade/AaveV3Ethereum_GHOCCIP151Upgrade_20241209.sol +++ b/src/20241209_Multi_GHOCCIP151Upgrade/AaveV3Ethereum_GHOCCIP151Upgrade_20241209.sol @@ -49,10 +49,9 @@ contract AaveV3Ethereum_GHOCCIP151Upgrade_20241209 is IProposalGenericExecutor { function _migrateLiquidity() internal { EXISTING_TOKEN_POOL.setRebalancer(address(NEW_TOKEN_POOL)); - NEW_TOKEN_POOL.transferLiquidity({ - from: address(EXISTING_TOKEN_POOL), - amount: EXISTING_TOKEN_POOL.getCurrentBridgedAmount() - }); + uint256 bridgeAmount = EXISTING_TOKEN_POOL.getCurrentBridgedAmount(); + NEW_TOKEN_POOL.transferLiquidity(address(EXISTING_TOKEN_POOL), bridgeAmount); + NEW_TOKEN_POOL.setCurrentBridgedAmount(bridgeAmount); // disable existing pool EXISTING_TOKEN_POOL.setBridgeLimit(0); diff --git a/src/20241209_Multi_GHOCCIP151Upgrade/utils/UpgradeableBurnMintTokenPool_1_4_WithdrawLiq.sol b/src/20241209_Multi_GHOCCIP151Upgrade/utils/UpgradeableBurnMintTokenPool_1_4_WithdrawLiq.sol index 63ca6da9b..17fd351c5 100644 --- a/src/20241209_Multi_GHOCCIP151Upgrade/utils/UpgradeableBurnMintTokenPool_1_4_WithdrawLiq.sol +++ b/src/20241209_Multi_GHOCCIP151Upgrade/utils/UpgradeableBurnMintTokenPool_1_4_WithdrawLiq.sol @@ -1,4 +1,4 @@ -/// Flattened UpgradeableBurnMintTokenPool from https://github.com/aave/ccip/pull/21 +/// Flattened UpgradeableBurnMintTokenPool from https://github.com/aave/ccip/pull/21 (last commit 0c15ea8abfff732f921329b19ebe8f2c81d0b692) /// Will be removed once PR is merged and contract implementation is deployed // SPDX-License-Identifier: BUSL-1.1 @@ -1800,15 +1800,15 @@ contract UpgradeableBurnMintTokenPool is } /// @notice This function allows the owner to burn `amount` of the pool's token. This is - /// expected to be called while migrating liquidity to another pool and offboarding this - /// facilitator. - /// @dev New token pool should mint and transfer liquidity to this pool (since it does not - /// hold tokens any point in point, only mints/burns) which can be burnt and hence will reset - /// the facilitator bucket level GHO. This is needed to migrate facilitators, by offboarding - /// this token pool subsequently. + /// expected to be called while migrating facilitators by offboarding this facilitator in + /// favor of a new token pool. + /// @dev New token pool should mint and transfer liquidity to this pool (since this pool + /// does not hold tokens at any point in time) which can be burnt and hence will reduce + /// the facilitator bucket level on GHO. The naming convention is inspired from that in + /// LockRelease type token pools for the sake of consistency. /// @param amount The amount of tokens to burn. - function withdrawLiquidity(uint256 amount) external onlyOwner { - IBurnMintERC20(address(i_token)).burn(amount); + function burnLiquidity(uint256 amount) external onlyOwner { + _burn(amount); } /// @inheritdoc UpgradeableBurnMintTokenPoolAbstract diff --git a/src/interfaces/ccip/tokenPool/IUpgradeableBurnMintTokenPool.sol b/src/interfaces/ccip/tokenPool/IUpgradeableBurnMintTokenPool.sol index b1d773a5e..0ab51b5b7 100644 --- a/src/interfaces/ccip/tokenPool/IUpgradeableBurnMintTokenPool.sol +++ b/src/interfaces/ccip/tokenPool/IUpgradeableBurnMintTokenPool.sol @@ -167,7 +167,6 @@ interface IUpgradeableBurnMintTokenPool_1_5_1 { event RouterUpdated(address oldRouter, address newRouter); event TokensConsumed(uint256 tokens); - function transferLiquidity(address to, uint256 amount) external; function acceptOwnership() external; function addRemotePool(uint64 remoteChainSelector, bytes memory remotePoolAddress) external; function applyAllowListUpdates(address[] memory removes, address[] memory adds) external; @@ -201,6 +200,7 @@ interface IUpgradeableBurnMintTokenPool_1_5_1 { function lockOrBurn( IPool.LockOrBurnInV1 memory lockOrBurnIn ) external returns (IPool.LockOrBurnOutV1 memory); + function mintAndTransferLiquidity(address to, uint256 amount) external; function owner() external view returns (address); function releaseOrMint( IPool.ReleaseOrMintInV1 memory releaseOrMintIn diff --git a/src/interfaces/ccip/tokenPool/IUpgradeableLockReleaseTokenPool.sol b/src/interfaces/ccip/tokenPool/IUpgradeableLockReleaseTokenPool.sol index 873611b80..96a3dbe0f 100644 --- a/src/interfaces/ccip/tokenPool/IUpgradeableLockReleaseTokenPool.sol +++ b/src/interfaces/ccip/tokenPool/IUpgradeableLockReleaseTokenPool.sol @@ -250,6 +250,7 @@ interface IUpgradeableLockReleaseTokenPool_1_5_1 { ) external returns (IPool.ReleaseOrMintOutV1 memory); function removeRemotePool(uint64 remoteChainSelector, bytes memory remotePoolAddress) external; function setBridgeLimit(uint256 newBridgeLimit) external; + function setCurrentBridgedAmount(uint256 newBridgedAmount) external; function setBridgeLimitAdmin(address bridgeLimitAdmin) external; function setChainRateLimiterConfig( uint64 remoteChainSelector,