diff --git a/contracts/src/v0.8/ccip/pools/GHO/UpgradeableBurnMintTokenPool.sol b/contracts/src/v0.8/ccip/pools/GHO/UpgradeableBurnMintTokenPool.sol index cae5e9d089..58be87812f 100644 --- a/contracts/src/v0.8/ccip/pools/GHO/UpgradeableBurnMintTokenPool.sol +++ b/contracts/src/v0.8/ccip/pools/GHO/UpgradeableBurnMintTokenPool.sol @@ -8,7 +8,6 @@ import {IBurnMintERC20} from "../../../shared/token/ERC20/IBurnMintERC20.sol"; import {UpgradeableTokenPool} from "./UpgradeableTokenPool.sol"; import {UpgradeableBurnMintTokenPoolAbstract} from "./UpgradeableBurnMintTokenPoolAbstract.sol"; -import {RateLimiter} from "../../libraries/RateLimiter.sol"; import {IRouter} from "../../interfaces/IRouter.sol"; @@ -19,33 +18,8 @@ import {IRouter} from "../../interfaces/IRouter.sol"; /// - Implementation of Initializable to allow upgrades /// - Move of allowlist and router definition to initialization stage contract UpgradeableBurnMintTokenPool is Initializable, UpgradeableBurnMintTokenPoolAbstract, ITypeAndVersion { - error Unauthorized(address caller); - string public constant override typeAndVersion = "BurnMintTokenPool 1.4.0"; - /// @dev The unique burn mint pool flag to signal through EIP 165. - bytes4 private constant BURN_MINT_INTERFACE_ID = bytes4(keccak256("BurnMintTokenPool")); - - /// @dev Whether or not the pool accepts liquidity. - /// External liquidity is not required when there is one canonical token deployed to a chain, - /// and CCIP is facilitating mint/burn on all the other chains, in which case the invariant - /// balanceOf(pool) on home chain == sum(totalSupply(mint/burn "wrapped" token) on all remote chains) should always hold - bool internal immutable i_acceptLiquidity; - /// @notice The address of the rebalancer. - address internal s_rebalancer; - /// @notice The address of the rate limiter admin. - /// @dev Can be address(0) if none is configured. - address internal s_rateLimitAdmin; - - /// @notice Maximum amount of tokens that can be bridged to other chains - uint256 private s_bridgeLimit; - /// @notice Amount of tokens bridged (transferred out) - /// @dev Must always be equal to or below the bridge limit - uint256 private s_currentBridged; - /// @notice The address of the bridge limit admin. - /// @dev Can be address(0) if none is configured. - address internal s_bridgeLimitAdmin; - /// @dev Constructor /// @param token The bridgeable token that is managed by this pool. /// @param armProxy The address of the arm proxy @@ -53,11 +27,8 @@ contract UpgradeableBurnMintTokenPool is Initializable, UpgradeableBurnMintToken constructor( address token, address armProxy, - bool allowlistEnabled, - bool acceptLiquidity - ) UpgradeableTokenPool(IBurnMintERC20(token), armProxy, allowlistEnabled) { - i_acceptLiquidity = acceptLiquidity; - } + bool allowlistEnabled + ) UpgradeableTokenPool(IBurnMintERC20(token), armProxy, allowlistEnabled) {} /// @dev Initializer /// @dev The address passed as `owner` must accept ownership after initialization. @@ -78,34 +49,6 @@ contract UpgradeableBurnMintTokenPool is Initializable, UpgradeableBurnMintToken } } - /// @notice Sets the rate limiter admin address. - /// @dev Only callable by the owner. - /// @param rateLimitAdmin The new rate limiter admin address. - function setRateLimitAdmin(address rateLimitAdmin) external onlyOwner { - s_rateLimitAdmin = rateLimitAdmin; - } - - /// @notice Gets the rate limiter admin address. - function getRateLimitAdmin() external view returns (address) { - return s_rateLimitAdmin; - } - - /// @notice Sets the rate limiter admin address. - /// @dev Only callable by the owner or the rate limiter admin. NOTE: overwrites the normal - /// onlyAdmin check in the base implementation to also allow the rate limiter admin. - /// @param remoteChainSelector The remote chain selector for which the rate limits apply. - /// @param outboundConfig The new outbound rate limiter config. - /// @param inboundConfig The new inbound rate limiter config. - function setChainRateLimiterConfig( - uint64 remoteChainSelector, - RateLimiter.Config memory outboundConfig, - RateLimiter.Config memory inboundConfig - ) external override { - if (msg.sender != s_rateLimitAdmin && msg.sender != owner()) revert Unauthorized(msg.sender); - - _setRateLimitConfig(remoteChainSelector, outboundConfig, inboundConfig); - } - /// @inheritdoc UpgradeableBurnMintTokenPoolAbstract function _burn(uint256 amount) internal virtual override { IBurnMintERC20(address(i_token)).burn(amount); diff --git a/contracts/src/v0.8/ccip/pools/GHO/UpgradeableBurnMintTokenPoolOld.sol b/contracts/src/v0.8/ccip/pools/GHO/UpgradeableBurnMintTokenPoolOld.sol deleted file mode 100644 index 16ab280431..0000000000 --- a/contracts/src/v0.8/ccip/pools/GHO/UpgradeableBurnMintTokenPoolOld.sol +++ /dev/null @@ -1,56 +0,0 @@ -// SPDX-License-Identifier: BUSL-1.1 -pragma solidity ^0.8.0; - -import {Initializable} from "solidity-utils/contracts/transparent-proxy/Initializable.sol"; - -import {ITypeAndVersion} from "../../../shared/interfaces/ITypeAndVersion.sol"; -import {IBurnMintERC20} from "../../../shared/token/ERC20/IBurnMintERC20.sol"; - -import {UpgradeableTokenPool} from "./UpgradeableTokenPool.sol"; -import {UpgradeableBurnMintTokenPoolAbstract} from "./UpgradeableBurnMintTokenPoolAbstract.sol"; - -import {IRouter} from "../../interfaces/IRouter.sol"; - -/// @title UpgradeableBurnMintTokenPoolOld -/// @author Aave Labs -/// @notice Upgradeable version of Chainlink's CCIP BurnMintTokenPool -/// @dev Contract adaptations: -/// - Implementation of Initializable to allow upgrades -/// - Move of allowlist and router definition to initialization stage -contract UpgradeableBurnMintTokenPoolOld is Initializable, UpgradeableBurnMintTokenPoolAbstract, ITypeAndVersion { - string public constant override typeAndVersion = "BurnMintTokenPool 1.4.0"; - - /// @dev Constructor - /// @param token The bridgeable token that is managed by this pool. - /// @param armProxy The address of the arm proxy - /// @param allowlistEnabled True if pool is set to access-controlled mode, false otherwise - constructor( - address token, - address armProxy, - bool allowlistEnabled - ) UpgradeableTokenPool(IBurnMintERC20(token), armProxy, allowlistEnabled) {} - - /// @dev Initializer - /// @dev The address passed as `owner` must accept ownership after initialization. - /// @dev The `allowlist` is only effective if pool is set to access-controlled mode - /// @param owner The address of the owner - /// @param allowlist A set of addresses allowed to trigger lockOrBurn as original senders - /// @param router The address of the router - function initialize(address owner, address[] memory allowlist, address router) public virtual initializer { - if (owner == address(0)) revert ZeroAddressNotAllowed(); - if (router == address(0)) revert ZeroAddressNotAllowed(); - _transferOwnership(owner); - - s_router = IRouter(router); - - // Pool can be set as permissioned or permissionless at deployment time only to save hot-path gas. - if (i_allowlistEnabled) { - _applyAllowListUpdates(new address[](0), allowlist); - } - } - - /// @inheritdoc UpgradeableBurnMintTokenPoolAbstract - function _burn(uint256 amount) internal virtual override { - IBurnMintERC20(address(i_token)).burn(amount); - } -} diff --git a/contracts/src/v0.8/ccip/pools/GHO/UpgradeableBurnMintTokenPoolV2.sol b/contracts/src/v0.8/ccip/pools/GHO/UpgradeableBurnMintTokenPoolV2.sol new file mode 100644 index 0000000000..38528ddff6 --- /dev/null +++ b/contracts/src/v0.8/ccip/pools/GHO/UpgradeableBurnMintTokenPoolV2.sol @@ -0,0 +1,113 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity ^0.8.0; + +import {Initializable} from "solidity-utils/contracts/transparent-proxy/Initializable.sol"; + +import {ITypeAndVersion} from "../../../shared/interfaces/ITypeAndVersion.sol"; +import {IBurnMintERC20} from "../../../shared/token/ERC20/IBurnMintERC20.sol"; + +import {UpgradeableTokenPool} from "./UpgradeableTokenPool.sol"; +import {UpgradeableBurnMintTokenPoolAbstract} from "./UpgradeableBurnMintTokenPoolAbstract.sol"; +import {RateLimiter} from "../../libraries/RateLimiter.sol"; + +import {IRouter} from "../../interfaces/IRouter.sol"; + +/// @title UpgradeableBurnMintTokenPoolV2 +/// @author Aave Labs +/// @notice Upgradeable version of Chainlink's CCIP BurnMintTokenPool +/// @dev Contract adaptations: +/// - Implementation of Initializable to allow upgrades +/// - Move of allowlist and router definition to initialization stage +contract UpgradeableBurnMintTokenPoolV2 is Initializable, UpgradeableBurnMintTokenPoolAbstract, ITypeAndVersion { + error Unauthorized(address caller); + + string public constant override typeAndVersion = "BurnMintTokenPool 1.4.0"; + + /// @dev The unique burn mint pool flag to signal through EIP 165. + bytes4 private constant BURN_MINT_INTERFACE_ID = bytes4(keccak256("BurnMintTokenPool")); + + /// @dev Whether or not the pool accepts liquidity. + /// External liquidity is not required when there is one canonical token deployed to a chain, + /// and CCIP is facilitating mint/burn on all the other chains, in which case the invariant + /// balanceOf(pool) on home chain == sum(totalSupply(mint/burn "wrapped" token) on all remote chains) should always hold + bool internal immutable i_acceptLiquidity; + /// @notice The address of the rebalancer. + address internal s_rebalancer; + /// @notice The address of the rate limiter admin. + /// @dev Can be address(0) if none is configured. + address internal s_rateLimitAdmin; + + /// @notice Maximum amount of tokens that can be bridged to other chains + uint256 private s_bridgeLimit; + /// @notice Amount of tokens bridged (transferred out) + /// @dev Must always be equal to or below the bridge limit + uint256 private s_currentBridged; + /// @notice The address of the bridge limit admin. + /// @dev Can be address(0) if none is configured. + address internal s_bridgeLimitAdmin; + + /// @dev Constructor + /// @param token The bridgeable token that is managed by this pool. + /// @param armProxy The address of the arm proxy + /// @param allowlistEnabled True if pool is set to access-controlled mode, false otherwise + constructor( + address token, + address armProxy, + bool allowlistEnabled, + bool acceptLiquidity + ) UpgradeableTokenPool(IBurnMintERC20(token), armProxy, allowlistEnabled) { + i_acceptLiquidity = acceptLiquidity; + } + + /// @dev Initializer + /// @dev The address passed as `owner` must accept ownership after initialization. + /// @dev The `allowlist` is only effective if pool is set to access-controlled mode + /// @param owner The address of the owner + /// @param allowlist A set of addresses allowed to trigger lockOrBurn as original senders + /// @param router The address of the router + function initialize(address owner, address[] memory allowlist, address router) public virtual initializer { + if (owner == address(0)) revert ZeroAddressNotAllowed(); + if (router == address(0)) revert ZeroAddressNotAllowed(); + _transferOwnership(owner); + + s_router = IRouter(router); + + // Pool can be set as permissioned or permissionless at deployment time only to save hot-path gas. + if (i_allowlistEnabled) { + _applyAllowListUpdates(new address[](0), allowlist); + } + } + + /// @notice Sets the rate limiter admin address. + /// @dev Only callable by the owner. + /// @param rateLimitAdmin The new rate limiter admin address. + function setRateLimitAdmin(address rateLimitAdmin) external onlyOwner { + s_rateLimitAdmin = rateLimitAdmin; + } + + /// @notice Gets the rate limiter admin address. + function getRateLimitAdmin() external view returns (address) { + return s_rateLimitAdmin; + } + + /// @notice Sets the rate limiter admin address. + /// @dev Only callable by the owner or the rate limiter admin. NOTE: overwrites the normal + /// onlyAdmin check in the base implementation to also allow the rate limiter admin. + /// @param remoteChainSelector The remote chain selector for which the rate limits apply. + /// @param outboundConfig The new outbound rate limiter config. + /// @param inboundConfig The new inbound rate limiter config. + function setChainRateLimiterConfig( + uint64 remoteChainSelector, + RateLimiter.Config memory outboundConfig, + RateLimiter.Config memory inboundConfig + ) external override { + if (msg.sender != s_rateLimitAdmin && msg.sender != owner()) revert Unauthorized(msg.sender); + + _setRateLimitConfig(remoteChainSelector, outboundConfig, inboundConfig); + } + + /// @inheritdoc UpgradeableBurnMintTokenPoolAbstract + function _burn(uint256 amount) internal virtual override { + IBurnMintERC20(address(i_token)).burn(amount); + } +} diff --git a/contracts/src/v0.8/ccip/test/pools/GHO/GhoBaseTest.t.sol b/contracts/src/v0.8/ccip/test/pools/GHO/GhoBaseTest.t.sol index 928b192c1c..d232af4fe6 100644 --- a/contracts/src/v0.8/ccip/test/pools/GHO/GhoBaseTest.t.sol +++ b/contracts/src/v0.8/ccip/test/pools/GHO/GhoBaseTest.t.sol @@ -7,8 +7,8 @@ import {TransparentUpgradeableProxy} from "solidity-utils/contracts/transparent- import {IBurnMintERC20} from "../../../../shared/token/ERC20/IBurnMintERC20.sol"; import {IPool} from "../../../interfaces/pools/IPool.sol"; import {UpgradeableLockReleaseTokenPool} from "../../../pools/GHO/UpgradeableLockReleaseTokenPool.sol"; +import {UpgradeableBurnMintTokenPoolV2} from "../../../pools/GHO/UpgradeableBurnMintTokenPoolV2.sol"; import {UpgradeableBurnMintTokenPool} from "../../../pools/GHO/UpgradeableBurnMintTokenPool.sol"; -import {UpgradeableBurnMintTokenPoolOld} from "../../../pools/GHO/UpgradeableBurnMintTokenPoolOld.sol"; import {UpgradeableTokenPool} from "../../../pools/GHO/UpgradeableTokenPool.sol"; import {RateLimiter} from "../../../libraries/RateLimiter.sol"; import {BaseTest} from "../../BaseTest.t.sol"; @@ -35,7 +35,7 @@ abstract contract GhoBaseTest is BaseTest { bool capacityBelowLevelUpdate; } - function _deployUpgradeableBurnMintTokenPool( + function _deployUpgradeableBurnMintTokenPoolV2( address ghoToken, address arm, address router, @@ -43,7 +43,7 @@ abstract contract GhoBaseTest is BaseTest { address proxyAdmin ) internal returns (address) { // Deploy BurnMintTokenPool for GHO token on source chain - UpgradeableBurnMintTokenPool tokenPoolImpl = new UpgradeableBurnMintTokenPool(ghoToken, arm, false, false); + UpgradeableBurnMintTokenPoolV2 tokenPoolImpl = new UpgradeableBurnMintTokenPoolV2(ghoToken, arm, false, false); // proxy deploy and init address[] memory emptyArray = new address[](0); bytes memory tokenPoolInitParams = abi.encodeWithSignature( @@ -60,13 +60,13 @@ abstract contract GhoBaseTest is BaseTest { // Manage ownership vm.stopPrank(); vm.prank(owner); - UpgradeableBurnMintTokenPool(address(tokenPoolProxy)).acceptOwnership(); + UpgradeableBurnMintTokenPoolV2(address(tokenPoolProxy)).acceptOwnership(); vm.startPrank(OWNER); return address(tokenPoolProxy); } - function _deployUpgradeableBurnMintTokenPoolOld( + function _deployUpgradeableBurnMintTokenPool( address ghoToken, address arm, address router, @@ -74,7 +74,7 @@ abstract contract GhoBaseTest is BaseTest { address proxyAdmin ) internal returns (address) { // Deploy BurnMintTokenPool for GHO token on source chain - UpgradeableBurnMintTokenPoolOld tokenPoolImpl = new UpgradeableBurnMintTokenPoolOld(ghoToken, arm, false); + UpgradeableBurnMintTokenPool tokenPoolImpl = new UpgradeableBurnMintTokenPool(ghoToken, arm, false); // proxy deploy and init address[] memory emptyArray = new address[](0); bytes memory tokenPoolInitParams = abi.encodeWithSignature( @@ -90,7 +90,7 @@ abstract contract GhoBaseTest is BaseTest { ); // Manage ownership changePrank(owner); - UpgradeableBurnMintTokenPoolOld(address(tokenPoolProxy)).acceptOwnership(); + UpgradeableBurnMintTokenPool(address(tokenPoolProxy)).acceptOwnership(); vm.stopPrank(); return address(tokenPoolProxy); @@ -103,7 +103,7 @@ abstract contract GhoBaseTest is BaseTest { address proxyAdmin ) internal { // Deploy BurnMintTokenPool for GHO token on source chain - UpgradeableBurnMintTokenPool tokenPoolImpl = new UpgradeableBurnMintTokenPool(ghoToken, arm, false, false); + UpgradeableBurnMintTokenPoolV2 tokenPoolImpl = new UpgradeableBurnMintTokenPoolV2(ghoToken, arm, false, false); // proxy upgrade vm.prank(proxyAdmin); TransparentUpgradeableProxy(tokenPoolProxy).upgradeTo(address(tokenPoolImpl)); diff --git a/contracts/src/v0.8/ccip/test/pools/GHO/GhoTokenPoolRemote.t.sol b/contracts/src/v0.8/ccip/test/pools/GHO/GhoTokenPoolRemote.t.sol index 773528c715..dd784e68c1 100644 --- a/contracts/src/v0.8/ccip/test/pools/GHO/GhoTokenPoolRemote.t.sol +++ b/contracts/src/v0.8/ccip/test/pools/GHO/GhoTokenPoolRemote.t.sol @@ -242,137 +242,3 @@ contract GhoTokenPoolEthereum_upgradeability is GhoTokenPoolRemoteSetup { assertEq(_getProxyAdminAddress(address(s_pool)), PROXY_ADMIN, "Unauthorized admin change"); } } - -contract GhoTokenPoolRemote_setChainRateLimiterConfig is GhoTokenPoolRemoteSetup { - event ConfigChanged(RateLimiter.Config); - event ChainConfigured( - uint64 chainSelector, - RateLimiter.Config outboundRateLimiterConfig, - RateLimiter.Config inboundRateLimiterConfig - ); - - uint64 internal s_remoteChainSelector; - - function setUp() public virtual override { - GhoTokenPoolRemoteSetup.setUp(); - UpgradeableTokenPool.ChainUpdate[] memory chainUpdates = new UpgradeableTokenPool.ChainUpdate[](1); - s_remoteChainSelector = 123124; - chainUpdates[0] = UpgradeableTokenPool.ChainUpdate({ - remoteChainSelector: s_remoteChainSelector, - allowed: true, - outboundRateLimiterConfig: getOutboundRateLimiterConfig(), - inboundRateLimiterConfig: getInboundRateLimiterConfig() - }); - changePrank(AAVE_DAO); - s_pool.applyChainUpdates(chainUpdates); - changePrank(OWNER); - } - - function testFuzz_SetChainRateLimiterConfigSuccess(uint128 capacity, uint128 rate, uint32 newTime) public { - // Cap the lower bound to 4 so 4/2 is still >= 2 - vm.assume(capacity >= 4); - // Cap the lower bound to 2 so 2/2 is still >= 1 - rate = uint128(bound(rate, 2, capacity - 2)); - // Bucket updates only work on increasing time - newTime = uint32(bound(newTime, block.timestamp + 1, type(uint32).max)); - vm.warp(newTime); - - uint256 oldOutboundTokens = s_pool.getCurrentOutboundRateLimiterState(s_remoteChainSelector).tokens; - uint256 oldInboundTokens = s_pool.getCurrentInboundRateLimiterState(s_remoteChainSelector).tokens; - - RateLimiter.Config memory newOutboundConfig = RateLimiter.Config({isEnabled: true, capacity: capacity, rate: rate}); - RateLimiter.Config memory newInboundConfig = RateLimiter.Config({ - isEnabled: true, - capacity: capacity / 2, - rate: rate / 2 - }); - - vm.expectEmit(); - emit ConfigChanged(newOutboundConfig); - vm.expectEmit(); - emit ConfigChanged(newInboundConfig); - vm.expectEmit(); - emit ChainConfigured(s_remoteChainSelector, newOutboundConfig, newInboundConfig); - - changePrank(AAVE_DAO); - s_pool.setChainRateLimiterConfig(s_remoteChainSelector, newOutboundConfig, newInboundConfig); - - uint256 expectedTokens = RateLimiter._min(newOutboundConfig.capacity, oldOutboundTokens); - - RateLimiter.TokenBucket memory bucket = s_pool.getCurrentOutboundRateLimiterState(s_remoteChainSelector); - assertEq(bucket.capacity, newOutboundConfig.capacity); - assertEq(bucket.rate, newOutboundConfig.rate); - assertEq(bucket.tokens, expectedTokens); - assertEq(bucket.lastUpdated, newTime); - - expectedTokens = RateLimiter._min(newInboundConfig.capacity, oldInboundTokens); - - bucket = s_pool.getCurrentInboundRateLimiterState(s_remoteChainSelector); - assertEq(bucket.capacity, newInboundConfig.capacity); - assertEq(bucket.rate, newInboundConfig.rate); - assertEq(bucket.tokens, expectedTokens); - assertEq(bucket.lastUpdated, newTime); - } - - function testOnlyOwnerOrRateLimitAdminSuccess() public { - address rateLimiterAdmin = address(28973509103597907); - - changePrank(AAVE_DAO); - s_pool.setRateLimitAdmin(rateLimiterAdmin); - - changePrank(rateLimiterAdmin); - - s_pool.setChainRateLimiterConfig( - s_remoteChainSelector, - getOutboundRateLimiterConfig(), - getInboundRateLimiterConfig() - ); - - changePrank(AAVE_DAO); - - s_pool.setChainRateLimiterConfig( - s_remoteChainSelector, - getOutboundRateLimiterConfig(), - getInboundRateLimiterConfig() - ); - } - - // Reverts - - function testOnlyOwnerReverts() public { - changePrank(STRANGER); - - vm.expectRevert(abi.encodeWithSelector(UpgradeableBurnMintTokenPool.Unauthorized.selector, STRANGER)); - s_pool.setChainRateLimiterConfig( - s_remoteChainSelector, - getOutboundRateLimiterConfig(), - getInboundRateLimiterConfig() - ); - } - - function testNonExistentChainReverts() public { - uint64 wrongChainSelector = 9084102894; - - vm.expectRevert(abi.encodeWithSelector(UpgradeableTokenPool.NonExistentChain.selector, wrongChainSelector)); - changePrank(AAVE_DAO); - s_pool.setChainRateLimiterConfig(wrongChainSelector, getOutboundRateLimiterConfig(), getInboundRateLimiterConfig()); - } -} - -contract GhoTokenPoolRemote_setRateLimitAdmin is GhoTokenPoolRemoteSetup { - function testSetRateLimitAdminSuccess() public { - assertEq(address(0), s_pool.getRateLimitAdmin()); - changePrank(AAVE_DAO); - s_pool.setRateLimitAdmin(OWNER); - assertEq(OWNER, s_pool.getRateLimitAdmin()); - } - - // Reverts - - function testSetRateLimitAdminReverts() public { - vm.startPrank(STRANGER); - - vm.expectRevert("Only callable by owner"); - s_pool.setRateLimitAdmin(STRANGER); - } -} diff --git a/contracts/src/v0.8/ccip/test/pools/GHO/GhoTokenPoolRemoteSetupOld.t.sol b/contracts/src/v0.8/ccip/test/pools/GHO/GhoTokenPoolRemoteSetupV2.t.sol similarity index 89% rename from contracts/src/v0.8/ccip/test/pools/GHO/GhoTokenPoolRemoteSetupOld.t.sol rename to contracts/src/v0.8/ccip/test/pools/GHO/GhoTokenPoolRemoteSetupV2.t.sol index 753849611f..67c341136e 100644 --- a/contracts/src/v0.8/ccip/test/pools/GHO/GhoTokenPoolRemoteSetupOld.t.sol +++ b/contracts/src/v0.8/ccip/test/pools/GHO/GhoTokenPoolRemoteSetupV2.t.sol @@ -8,13 +8,13 @@ import {stdError} from "forge-std/Test.sol"; import {UpgradeableTokenPool} from "../../../pools/GHO/UpgradeableTokenPool.sol"; import {Router} from "../../../Router.sol"; import {BurnMintERC677} from "../../../../shared/token/ERC677/BurnMintERC677.sol"; -import {UpgradeableBurnMintTokenPoolOld} from "../../../pools/GHO/UpgradeableBurnMintTokenPoolOld.sol"; import {UpgradeableBurnMintTokenPool} from "../../../pools/GHO/UpgradeableBurnMintTokenPool.sol"; +import {UpgradeableBurnMintTokenPoolV2} from "../../../pools/GHO/UpgradeableBurnMintTokenPoolV2.sol"; import {RouterSetup} from "../../router/RouterSetup.t.sol"; import {BaseTest} from "../../BaseTest.t.sol"; import {GhoBaseTest} from "./GhoBaseTest.t.sol"; -contract GhoTokenPoolRemoteSetupOld is RouterSetup, GhoBaseTest { +contract GhoTokenPoolRemoteSetupV2 is RouterSetup, GhoBaseTest { event Transfer(address indexed from, address indexed to, uint256 value); event TokensConsumed(uint256 tokens); event Burned(address indexed sender, uint256 amount); @@ -23,7 +23,7 @@ contract GhoTokenPoolRemoteSetupOld is RouterSetup, GhoBaseTest { address internal s_burnMintOffRamp = makeAddr("burn_mint_offRamp"); address internal s_burnMintOnRamp = makeAddr("burn_mint_onRamp"); - UpgradeableBurnMintTokenPool internal s_pool; + UpgradeableBurnMintTokenPoolV2 internal s_pool; function setUp() public virtual override(RouterSetup, BaseTest) { RouterSetup.setUp(); @@ -32,8 +32,8 @@ contract GhoTokenPoolRemoteSetupOld is RouterSetup, GhoBaseTest { GhoToken ghoToken = new GhoToken(AAVE_DAO); s_burnMintERC677 = BurnMintERC677(address(ghoToken)); - s_pool = UpgradeableBurnMintTokenPool( - _deployUpgradeableBurnMintTokenPoolOld( + s_pool = UpgradeableBurnMintTokenPoolV2( + _deployUpgradeableBurnMintTokenPool( address(s_burnMintERC677), address(s_mockARM), address(s_sourceRouter), @@ -50,6 +50,8 @@ contract GhoTokenPoolRemoteSetupOld is RouterSetup, GhoBaseTest { PROXY_ADMIN ); + s_pool = UpgradeableBurnMintTokenPoolV2(address(s_pool)); + // Give mint and burn privileges to source UpgradeableTokenPool (GHO-specific related) vm.startPrank(AAVE_DAO); GhoToken(address(s_burnMintERC677)).grantRole( @@ -63,8 +65,8 @@ contract GhoTokenPoolRemoteSetupOld is RouterSetup, GhoBaseTest { } function _deployWithoutUpgrade() internal { - s_pool = UpgradeableBurnMintTokenPool( - _deployUpgradeableBurnMintTokenPoolOld( + s_pool = UpgradeableBurnMintTokenPoolV2( + _deployUpgradeableBurnMintTokenPool( address(s_burnMintERC677), address(s_mockARM), address(s_sourceRouter), diff --git a/contracts/src/v0.8/ccip/test/pools/GHO/GhoTokenPoolRemoteOld.t.sol b/contracts/src/v0.8/ccip/test/pools/GHO/GhoTokenPoolRemoteV2.t.sol similarity index 95% rename from contracts/src/v0.8/ccip/test/pools/GHO/GhoTokenPoolRemoteOld.t.sol rename to contracts/src/v0.8/ccip/test/pools/GHO/GhoTokenPoolRemoteV2.t.sol index 97df9a823e..ca09a5f4c3 100644 --- a/contracts/src/v0.8/ccip/test/pools/GHO/GhoTokenPoolRemoteOld.t.sol +++ b/contracts/src/v0.8/ccip/test/pools/GHO/GhoTokenPoolRemoteV2.t.sol @@ -11,10 +11,11 @@ import {EVM2EVMOnRamp} from "../../../onRamp/EVM2EVMOnRamp.sol"; import {EVM2EVMOffRamp} from "../../../offRamp/EVM2EVMOffRamp.sol"; import {BurnMintTokenPool} from "../../../pools/BurnMintTokenPool.sol"; import {UpgradeableBurnMintTokenPool} from "../../../pools/GHO/UpgradeableBurnMintTokenPool.sol"; +import {UpgradeableBurnMintTokenPoolV2} from "../../../pools/GHO/UpgradeableBurnMintTokenPoolV2.sol"; import {RateLimiter} from "../../../libraries/RateLimiter.sol"; -import {GhoTokenPoolRemoteSetupOld} from "./GhoTokenPoolRemoteSetupOld.t.sol"; +import {GhoTokenPoolRemoteSetupV2} from "./GhoTokenPoolRemoteSetupV2.t.sol"; -contract GhoTokenPoolRemoteOld_lockOrBurn is GhoTokenPoolRemoteSetupOld { +contract GhoTokenPoolRemoteV2_lockOrBurn is GhoTokenPoolRemoteSetupV2 { function testSetupSuccess() public { assertEq(address(s_burnMintERC677), address(s_pool.getToken())); assertEq(address(s_mockARM), s_pool.getArmProxy()); @@ -112,7 +113,7 @@ contract GhoTokenPoolRemoteOld_lockOrBurn is GhoTokenPoolRemoteSetupOld { } } -contract GhoTokenPoolRemoteOld_releaseOrMint is GhoTokenPoolRemoteSetupOld { +contract GhoTokenPoolRemoteV2_releaseOrMint is GhoTokenPoolRemoteSetupV2 { function testPoolMintSuccess() public { uint256 amount = 1e19; vm.startPrank(s_burnMintOffRamp); @@ -179,7 +180,7 @@ contract GhoTokenPoolRemoteOld_releaseOrMint is GhoTokenPoolRemoteSetupOld { } } -contract GhoTokenPoolOldEthereum_upgradeability is GhoTokenPoolRemoteSetupOld { +contract GhoTokenPoolV2Ethereum_upgradeability is GhoTokenPoolRemoteSetupV2 { function testInitialization() public { // Upgradeability assertEq(_getUpgradeableVersion(address(s_pool)), 1); @@ -249,7 +250,7 @@ contract GhoTokenPoolOldEthereum_upgradeability is GhoTokenPoolRemoteSetupOld { } } -contract GhoTokenPoolRemoteOld_setChainRateLimiterConfig is GhoTokenPoolRemoteSetupOld { +contract GhoTokenPoolRemoteV2_setChainRateLimiterConfig is GhoTokenPoolRemoteSetupV2 { event ConfigChanged(RateLimiter.Config); event ChainConfigured( uint64 chainSelector, @@ -260,7 +261,7 @@ contract GhoTokenPoolRemoteOld_setChainRateLimiterConfig is GhoTokenPoolRemoteSe uint64 internal s_remoteChainSelector; function setUp() public virtual override { - GhoTokenPoolRemoteSetupOld.setUp(); + GhoTokenPoolRemoteSetupV2.setUp(); UpgradeableTokenPool.ChainUpdate[] memory chainUpdates = new UpgradeableTokenPool.ChainUpdate[](1); s_remoteChainSelector = 123124; chainUpdates[0] = UpgradeableTokenPool.ChainUpdate({ @@ -348,7 +349,7 @@ contract GhoTokenPoolRemoteOld_setChainRateLimiterConfig is GhoTokenPoolRemoteSe function testOnlyOwnerReverts() public { changePrank(STRANGER); - vm.expectRevert(abi.encodeWithSelector(UpgradeableBurnMintTokenPool.Unauthorized.selector, STRANGER)); + vm.expectRevert(abi.encodeWithSelector(UpgradeableBurnMintTokenPoolV2.Unauthorized.selector, STRANGER)); s_pool.setChainRateLimiterConfig( s_remoteChainSelector, getOutboundRateLimiterConfig(), @@ -365,7 +366,7 @@ contract GhoTokenPoolRemoteOld_setChainRateLimiterConfig is GhoTokenPoolRemoteSe } } -contract GhoTokenPoolRemoteOld_setRateLimitAdmin is GhoTokenPoolRemoteSetupOld { +contract GhoTokenPoolRemoteV2_setRateLimitAdmin is GhoTokenPoolRemoteSetupV2 { function testSetRateLimitAdminSuccess() public { assertEq(address(0), s_pool.getRateLimitAdmin()); vm.startPrank(AAVE_DAO);