Skip to content

Commit

Permalink
feat: update to latest spec: naming changes, setCurrentBridgedAmount,…
Browse files Browse the repository at this point in the history
… resolve existing pool bridgeAmount comment
  • Loading branch information
DhairyaSethi committed Dec 19, 2024
1 parent 1a30dda commit bbc3daa
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit bbc3daa

Please sign in to comment.