From e60232bdf9e84bc5f4be27c9c566f121d7696aee Mon Sep 17 00:00:00 2001 From: Goran Vladika Date: Wed, 19 Jun 2024 10:05:26 +0200 Subject: [PATCH] Extract IFiatToken interface --- .../arbitrum/gateway/L2USDCGateway.sol | 7 +------ .../ethereum/gateway/L1USDCGateway.sol | 14 ++++---------- contracts/tokenbridge/libraries/IFiatToken.sol | 15 +++++++++++++++ 3 files changed, 20 insertions(+), 16 deletions(-) create mode 100644 contracts/tokenbridge/libraries/IFiatToken.sol diff --git a/contracts/tokenbridge/arbitrum/gateway/L2USDCGateway.sol b/contracts/tokenbridge/arbitrum/gateway/L2USDCGateway.sol index 7df52051a8..8cdc1783c1 100644 --- a/contracts/tokenbridge/arbitrum/gateway/L2USDCGateway.sol +++ b/contracts/tokenbridge/arbitrum/gateway/L2USDCGateway.sol @@ -2,7 +2,7 @@ pragma solidity ^0.8.4; import "./L2ArbitrumGateway.sol"; -import {L1USDCGateway} from "../../ethereum/gateway/L1USDCGateway.sol"; +import {L1USDCGateway, IFiatToken} from "../../ethereum/gateway/L1USDCGateway.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; /** @@ -199,8 +199,3 @@ contract L2USDCGateway is L2ArbitrumGateway { return true; } } - -interface IFiatToken { - function burn(uint256 _amount) external; - function mint(address _to, uint256 _amount) external; -} diff --git a/contracts/tokenbridge/ethereum/gateway/L1USDCGateway.sol b/contracts/tokenbridge/ethereum/gateway/L1USDCGateway.sol index e248a52904..514f672d13 100644 --- a/contracts/tokenbridge/ethereum/gateway/L1USDCGateway.sol +++ b/contracts/tokenbridge/ethereum/gateway/L1USDCGateway.sol @@ -9,6 +9,7 @@ import { TokenGateway, IERC20 } from "./L1ArbitrumExtendedGateway.sol"; +import {IFiatToken} from "../../libraries/IFiatToken.sol"; /** * @title Custom gateway for USDC implementing Bridged USDC Standard. @@ -84,8 +85,8 @@ contract L1USDCGateway is L1ArbitrumExtendedGateway { /** * @notice Pauses deposits. This can only be called by the owner. - * @dev Pausing is prerequisite for burning escrowed USDC tokens. Incoming withdrawals are not affected. - * It is onetime permanent action. Pausing the withdrawals needs to be done separately on the child chain. + * @dev Pausing is permanent and can't be undone. Pausing is prerequisite for burning escrowed USDC tokens. + * Incoming withdrawals are not affected. Pausing the withdrawals needs to be done separately on the child chain. */ function pauseDeposits() external onlyOwner { if (depositsPaused) { @@ -117,7 +118,7 @@ contract L1USDCGateway is L1ArbitrumExtendedGateway { revert L1USDCGateway_L2SupplyNotSet(); } - Burnable(l1USDC).burn(_amountToBurn); + IFiatToken(l1USDC).burn(_amountToBurn); emit GatewayUsdcBurned(_amountToBurn); } @@ -175,10 +176,3 @@ contract L1USDCGateway is L1ArbitrumExtendedGateway { return l2USDC; } } - -interface Burnable { - /** - * @notice Circle's referent USDC implementation exposes burn function of this signature. - */ - function burn(uint256 _amount) external; -} diff --git a/contracts/tokenbridge/libraries/IFiatToken.sol b/contracts/tokenbridge/libraries/IFiatToken.sol new file mode 100644 index 0000000000..95214835d1 --- /dev/null +++ b/contracts/tokenbridge/libraries/IFiatToken.sol @@ -0,0 +1,15 @@ +// SPDX-License-Identifier: MIT +// solhint-disable-next-line compiler-version +pragma solidity >0.6.0 <0.9.0; + +/** + * @title IFiatToken + * @dev Part of the interface that is used in Circle's referent implementation of the USDC + * Ref: https://github.com/circlefin/stablecoin-evm + * + * This interface is used in the L1USDCGateway, L1OrbitUSDCGateway and L2USDCGateway contracts. + */ +interface IFiatToken { + function burn(uint256 _amount) external; + function mint(address _to, uint256 _amount) external; +}