Skip to content

Commit

Permalink
formatting, remove unnec. state vars, and better natspec
Browse files Browse the repository at this point in the history
  • Loading branch information
jhweintraub committed Oct 3, 2024
1 parent eb531cc commit b7067b5
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
pragma solidity ^0.8.0;
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.24;

import {IBurnMintERC20} from "../../../shared/token/ERC20/IBurnMintERC20.sol";

import {Pool} from "../../libraries/Pool.sol";
import {BurnMintTokenPool} from "../BurnMintTokenPool.sol";

/// @notice A standard BurnMintTokenPool with modified destPoolData so that the remote pool knows to release tokens
/// instead of minting. This enables interoperability with HybridLockReleaseUSDCTokenPool which uses
// the destPoolData to determine whether to mint or release tokens.
/// @dev The only difference between this contract and BurnMintTokenPool is the destPoolData returns the
/// abi-encoded LOCK_RELEASE_FLAG instead of an empty string.
contract BurnMintWithLockReleaseFlagTokenPool is BurnMintTokenPool {
/// bytes4(keccak256("NO_CCTP_USE_LOCK_RELEASE"))
bytes4 public constant LOCK_RELEASE_FLAG = 0xfa7c07de;
Expand All @@ -20,7 +26,7 @@ contract BurnMintWithLockReleaseFlagTokenPool is BurnMintTokenPool {
/// @dev The _validateLockOrBurn check is an essential security check
function lockOrBurn(
Pool.LockOrBurnInV1 calldata lockOrBurnIn
) external virtual override returns (Pool.LockOrBurnOutV1 memory) {
) external override returns (Pool.LockOrBurnOutV1 memory) {
_validateLockOrBurn(lockOrBurnIn);

_burn(lockOrBurnIn.amount);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ contract HybridLockReleaseUSDCTokenPool is USDCTokenPool, USDCBridgeMigrator {
address[] memory allowlist,
address rmnProxy,
address router
) USDCTokenPool(tokenMessenger, token, allowlist, rmnProxy, router) USDCBridgeMigrator(address(token), router) {}
) USDCTokenPool(tokenMessenger, token, allowlist, rmnProxy, router) USDCBridgeMigrator(address(token)) {}

// ================================================================
// │ Incoming/Outgoing Mechanisms |
Expand Down Expand Up @@ -170,10 +170,12 @@ contract HybridLockReleaseUSDCTokenPool is USDCTokenPool, USDCBridgeMigrator {
function provideLiquidity(uint64 remoteChainSelector, uint256 amount) external {
if (s_liquidityProvider[remoteChainSelector] != msg.sender) revert TokenPool.Unauthorized(msg.sender);

// Prevent adding liquidity to a chain which has already been migrated
if (s_migratedChains.contains(remoteChainSelector)) {
revert TokenLockingNotAllowedAfterMigration(remoteChainSelector);
}

// prevent adding liquidity to a chain which has been proposed for migration
if (remoteChainSelector == s_proposedUSDCMigrationChain) {
revert LanePausedForCCTPMigration(remoteChainSelector);
}
Expand All @@ -192,7 +194,7 @@ contract HybridLockReleaseUSDCTokenPool is USDCTokenPool, USDCBridgeMigrator {
/// withdrawn on this chain, otherwise a mismatch may occur between locked token balance and remote circulating supply
/// which may block a potential future migration of the chain to CCTP.
function withdrawLiquidity(uint64 remoteChainSelector, uint256 amount) external onlyOwner {
// Circle requires a supply-lock to prevent outgoing messages once the migration process begins.
// A supply-lock is required to prevent outgoing messages once the migration process begins.
// This prevents new outgoing messages once the migration has begun to ensure any the procedure runs as expected
if (remoteChainSelector == s_proposedUSDCMigrationChain) {
revert LanePausedForCCTPMigration(remoteChainSelector);
Expand Down Expand Up @@ -220,7 +222,8 @@ contract HybridLockReleaseUSDCTokenPool is USDCTokenPool, USDCBridgeMigrator {
function transferLiquidity(address from, uint64 remoteChainSelector) external onlyOwner {
OwnerIsCreator(from).acceptOwnership();

// Withdraw all available liquidity from the old pool.
// Withdraw all available liquidity from the old pool. No check is needed for pending migrations, as the old pool
// will revert if the migration has begun.
uint256 withdrawAmount = HybridLockReleaseUSDCTokenPool(from).getLockedTokensForChain(remoteChainSelector);
HybridLockReleaseUSDCTokenPool(from).withdrawLiquidity(remoteChainSelector, withdrawAmount);

Expand All @@ -235,7 +238,7 @@ contract HybridLockReleaseUSDCTokenPool is USDCTokenPool, USDCBridgeMigrator {

/// @notice Return whether a lane should use the alternative L/R mechanism in the token pool.
/// @param remoteChainSelector the remote chain the lane is interacting with
/// @return bool Return true if the alternative L/R mechanism should be used
/// @return bool Return true if the alternative L/R mechanism should be used, and is decided by the Owner
function shouldUseLockRelease(uint64 remoteChainSelector) public view virtual returns (bool) {
return s_shouldUseLockRelease[remoteChainSelector];
}
Expand Down
9 changes: 3 additions & 6 deletions contracts/src/v0.8/ccip/pools/USDC/USDCBridgeMigrator.sol
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.24;

import {OwnerIsCreator} from "../../../shared/access/OwnerIsCreator.sol";
import {IBurnMintERC20} from "../../../shared/token/ERC20/IBurnMintERC20.sol";

import {EnumerableSet} from "../../../vendor/openzeppelin-solidity/v4.8.3/contracts/utils/structs/EnumerableSet.sol";

import {Router} from "../../Router.sol";

/// @notice Allows migration of a lane in a token pool from Lock/Release to CCTP supported Burn/Mint. Contract
/// functionality is based on hard requirements defined by Circle to allow for future CCTP compatibility
/// https://github.com/circlefin/stablecoin-evm/blob/master/doc/bridged_USDC_standard.md
Expand All @@ -26,8 +25,7 @@ abstract contract USDCBridgeMigrator is OwnerIsCreator {
error NoMigrationProposalPending();
error InvalidChainSelector();

IBurnMintERC20 internal immutable i_USDC;
Router internal immutable i_router;
IBurnMintERC20 private immutable i_USDC;

address internal s_circleUSDCMigrator;
uint64 internal s_proposedUSDCMigrationChain;
Expand All @@ -39,9 +37,8 @@ abstract contract USDCBridgeMigrator is OwnerIsCreator {

EnumerableSet.UintSet internal s_migratedChains;

constructor(address token, address router) {
constructor(address token) {
i_USDC = IBurnMintERC20(token);
i_router = Router(router);
}

/// @notice Burn USDC locked for a specific lane so that destination USDC can be converted from
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ pragma solidity 0.8.24;

import {Pool} from "../../libraries/Pool.sol";
import {RateLimiter} from "../../libraries/RateLimiter.sol";

import {TokenPool} from "../../pools/TokenPool.sol";
import {BurnMintWithLockReleaseFlagTokenPool} from "../../pools/USDC/BurnMintWithLockReleaseFlagTokenPool.sol";
import {BurnMintSetup} from "./BurnMintSetup.t.sol";
Expand Down

0 comments on commit b7067b5

Please sign in to comment.