Source Code
| Transaction Hash |
|
Block
|
From
|
To
|
|||||
|---|---|---|---|---|---|---|---|---|---|
Latest 1 internal transaction
Advanced mode:
| Parent Transaction Hash | Block | From | To | |||
|---|---|---|---|---|---|---|
| 19549823 | 67 days ago | Contract Creation | 0 HYPE |
Cross-Chain Transactions
Loading...
Loading
Contract Name:
CoreDepositWallet
Compiler Version
v0.7.6+commit.7338295f
Optimization Enabled:
Yes with 100000 runs
Other Settings:
istanbul EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
/*
* Copyright 2025 Circle Internet Group, Inc. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
pragma solidity 0.7.6;
pragma abicoder v2;
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {ICoreDepositWallet} from "./interfaces/ICoreDepositWallet.sol";
import {Pausable} from "@evm-cctp-contracts/roles/Pausable.sol";
import {Rescuable} from "./roles/Rescuable.sol";
import {Initializable} from "@evm-cctp-contracts/proxy/Initializable.sol";
import {IDepositableToken} from "./interfaces/IDepositableToken.sol";
import {ICoreWriter} from "./interfaces/ICoreWriter.sol";
import {TokenMessengerV2} from "@evm-cctp-contracts/v2/TokenMessengerV2.sol";
import {TypedMemView} from "@memview-sol/contracts/TypedMemView.sol";
import {CrossChainWithdrawalHookData} from "./messages/CrossChainWithdrawalHookData.sol";
/**
* @title CoreDepositWallet
* @notice Contract for managing token deposits and transfers between HyperEVM and HyperCore. This contract is specific to 6 decimals (HyperEVM) tokens that are scaled to 8 decimals (HyperCore).
*/
contract CoreDepositWallet is ICoreDepositWallet, Pausable, Rescuable, Initializable {
// ============ Constants ============
// CCTP protocol constants.
uint32 private constant CCTP_FINALIZED_THRESHOLD = 2000; // Ensures CCTP waits for finality before attesting to messages sent by this contract.
uint256 private constant CCTP_MAX_FEE = 0;
uint256 private constant CCTP_DEFAULT_FORWARD_FEE = 200000; // 0.2 USDC (6 decimals)
uint32 private constant CCTP_FEE_LIMIT = type(uint32).max;
uint256 private constant MAX_HOOK_DATA_SIZE = 1024; // 1 KB The maximum allowed hook data size by this contract.
// HyperCore protocol constants.
uint8 private constant CORE_WRITER_ACTION_VERSION = 0x01;
uint24 private constant CORE_WRITER_SEND_ASSET_ACTION_ID = 0x00000D;
uint64 private constant CORE_TOKEN_INDEX = 0x0000000000000000;
uint32 private constant CORE_SPOT_DEX_ID = type(uint32).max;
uint32 private constant CORE_PERPS_DEX_ID = 0;
uint256 private constant CORE_SCALING_FACTOR = 100; // 6 decimals -> 8 decimals (10^(8-6))
address private constant CORE_WRITER_PRECOMPILE_ADDRESS = 0x3333333333333333333333333333333333333333;
address private constant CORE_USER_EXISTS_PRECOMPILE_ADDRESS = 0x0000000000000000000000000000000000000810;
uint64 private constant DEFAULT_NEW_CORE_ACCOUNT_FEE = 100000000; // 1 USDC (core asset units, 8 decimals)
uint256 private constant MAX_TRANSFER_VALUE_FROM_EVM = type(uint64).max / CORE_SCALING_FACTOR; // max HyperCore asset units (uint64.max) / HyperCore -> EVM scaling factor (100)
// ============ Structs ============
struct CoreDepositWalletRoles {
address owner;
address pauser;
address rescuer;
}
/**
* @notice Read-only view of the HyperCore protocol constants
*/
struct CoreProtocolConstants {
uint8 coreWriterActionVersion;
uint24 coreWriterSendAssetActionId;
uint64 coreTokenIndex;
uint32 coreSpotDexId;
uint32 corePerpsDexId;
address coreWriterPrecompileAddress;
address coreUserExistsPrecompileAddress;
uint256 coreScalingFactor;
}
/**
* @notice Read-only view of the HyperCore user exists precompile return value
*/
struct CoreUserExists {
bool exists;
}
// ============ Events ============
/**
* @notice Emitted when tokens are transferred into the contract.
* @dev Required for HyperCore to correctly process deposits from HyperEVM.
* @param from The address initiating the transfer.
* @param to The address receiving the tokens.
* @param amount The amount of tokens being transferred.
*/
event Transfer(address indexed from, address indexed to, uint256 amount);
/**
* @notice Emitted when tokens are withdrawn from the contract.
* @param to The address receiving the withdrawn tokens.
* @param value The amount of tokens being withdrawn.
*/
event Withdraw(address indexed to, uint256 value);
/**
* @notice Emitted when tokens are withdrawn from the contract and burned for cross-chain transfer.
* @param from The Hypercore address debited by the cross-chain withdrawal.
* @param to The address receiving the minted tokens on the destination chain, as bytes32.
* @param value The amount of tokens being withdrawn and burned.
* @param destinationDomain The CCTP domain ID of the destination chain.
* @param coreNonce The HyperCore transaction nonce.
*/
event CrossChainWithdraw(
address indexed from, bytes32 indexed to, uint256 value, uint32 destinationDomain, uint64 indexed coreNonce
);
/**
* @notice Emitted when the CCTP default maximum fee is updated.
* @param previousFee The previous default maximum fee.
* @param newFee The new default maximum fee.
*/
event CctpMaxFeeUpdated(uint256 previousFee, uint256 newFee);
/**
* @notice Emitted when the CCTP default forwarding fee is updated.
* @param previousFee The previous default forwarding fee.
* @param newFee The new default forwarding fee.
*/
event CctpDefaultForwardFeeUpdated(uint256 previousFee, uint256 newFee);
/**
* @notice Emitted when the CCTP forwarding fee is updated for a destination domain.
* @param destinationDomain The CCTP domain ID of the destination chain.
* @param previousFee The previous forwarding fee.
* @param newFee The new forwarding fee.
*/
event CctpForwardFeeUpdated(uint32 indexed destinationDomain, uint256 previousFee, uint256 newFee);
/**
* @notice Emitted when the newCoreAccountFee is updated
* @param previousFee Previous fee in core asset units (8 decimals)
* @param newFee New fee in core asset units (8 decimals)
*/
event NewCoreAccountFeeUpdated(uint64 previousFee, uint64 newFee);
/**
* @notice Emitted when the newCoreAccountFee is deducted from a deposit to a non-existent HyperCore account.
* @param coreRecipient The HyperCore recipient address
* @param newCoreAccountFee The configured newCoreAccountFee in core asset units (8 decimals)
* @param evmDepositAmount The original deposit amount in EVM token units (6 decimals)
* @param coreSentAmount The amount sent to the recipient on HyperCore after the newCoreAccountFee fee is deducted in core asset units (8 decimals)
*/
event NewCoreAccountFeeApplied(
address indexed coreRecipient, uint64 newCoreAccountFee, uint256 evmDepositAmount, uint64 coreSentAmount
);
/**
* @notice Emitted when a destination dex is disabled.
* @param dex The disabled destination dex
*/
event DexDisabled(uint32 indexed dex);
/**
* @notice Emitted when a destination dex is enabled.
* @param dex The enabled destination dex
*/
event DexEnabled(uint32 indexed dex);
/**
* @notice Emitted when dex forwarding is disabled.
*/
event DexForwardingDisabled();
/**
* @notice Emitted when dex forwarding is enabled.
*/
event DexForwardingEnabled();
/**
* @notice Emitted when the CoreWriter sendAsset action is called on HyperEVM to send assets to HyperCore.
* @param coreRecipient The HyperCore recipient address
* @param coreAmount The amount sent to the recipient on HyperCore in core token units (8 decimals)
* @param destinationDex The destination dex on HyperCore
*/
event SendAsset(address indexed coreRecipient, uint64 coreAmount, uint32 destinationDex);
// ============ State Variables ============
// The contract of the HyperEVM token that can be deposited and withdrawn.
IDepositableToken public immutable token;
// The contract of the HyperEVM CCTP TokenMessenger for cross-chain withdrawals.
TokenMessengerV2 public immutable tokenMessenger;
// The system address for the token spot asset on HyperCore.
address public immutable tokenSystemAddress;
// Fee deducted on HyperCore when the recipient has no existing account (core token units, 8 decimals).
uint64 public newCoreAccountFee;
// Default maximum fee for unforwarded cross-chain withdrawals via CCTP, initialized at 0 USDC.
uint256 public cctpMaxFee;
// Default forwarding fee for cross-chain withdrawals via CCTP, initialized at 0.2 USDC (6 decimals).
uint256 public cctpDefaultForwardFee;
// Per-destination domain flag indicating if a CCTP forwarding fee override is set for the destination domain.
mapping(uint32 => bool) public isCctpForwardFeeSet;
// Per-destination domain forwarding fee override used by coreReceiveWithData; falls back to cctpDefaultForwardFee if not set.
mapping(uint32 => uint256) public cctpForwardFees;
// Enabled destination dexes on HyperCore.
// Note: Values set to true in this mapping represent dexes on Hypercore which are enabled
// for forwarding deposits via CoreWriter. If a dex is not enabled,
// deposits will be sent to the recipient address on Core spot instead.
// The value of the mapping for the Core spot dex (uint32.max) is always left as false,
// because deposits to the Core spot dex do not require forwarding by CoreWriter.
mapping(uint32 => bool) public enabledDestinationDexes;
// If true, deposits will be sent to the Core spot dex instead of the specified destination dex.
bool public isDexForwardingDisabled;
// ============ Constructor ============
/**
* @notice Constructor
* @param tokenAddress The address of the managed token on HyperEVM.
* @param _tokenSystemAddress The system address for the managed token on HyperCore.
* @param tokenMessengerAddress The address of the CCTP TokenMessenger on HyperEVM.
*/
constructor(address tokenAddress, address _tokenSystemAddress, address tokenMessengerAddress) {
require(tokenAddress != address(0), "Invalid tokenAddress: zero address");
require(_tokenSystemAddress != address(0), "Invalid _tokenSystemAddress: zero address");
require(tokenMessengerAddress != address(0), "Invalid tokenMessengerAddress: zero address");
token = IDepositableToken(tokenAddress);
tokenSystemAddress = _tokenSystemAddress;
tokenMessenger = TokenMessengerV2(tokenMessengerAddress);
_disableInitializers();
}
/**
* @notice Initializes the CoreDepositWallet contract
* @dev Reverts if the tokens and forwarding addresses are not the same length.
* @param roles Roles configuration
*/
function initialize(CoreDepositWalletRoles calldata roles) external initializer {
require(roles.owner != address(0), "Invalid roles.owner: zero address");
_transferOwnership(roles.owner);
_updatePauser(roles.pauser);
_updateRescuer(roles.rescuer);
_setNewCoreAccountFee(DEFAULT_NEW_CORE_ACCOUNT_FEE);
_setNewCctpMaxFee(CCTP_MAX_FEE);
_setNewCctpDefaultForwardFee(CCTP_DEFAULT_FORWARD_FEE);
enabledDestinationDexes[CORE_PERPS_DEX_ID] = true;
}
// ============ External Functions ============
/**
* @notice Owner-only setter to update the new core account fee
* @dev This fee is deducted from deposit amounts when _coreUserExists returns false. This fee is in core token units (8 decimals).
* @param fee New fee amount in core token units (8 decimals).
*/
function updateNewCoreAccountFee(uint64 fee) external onlyOwner {
_setNewCoreAccountFee(fee);
}
/**
* @notice Owner-only setter to update the default cross-chain message fee.
* @param maxFee The new default maximum fee.
*/
function updateCctpMaxFee(uint256 maxFee) external onlyOwner {
_setNewCctpMaxFee(maxFee);
}
/**
* @notice Owner-only setter to update the default cross-chain forwarding fee.
* @param maxFee The new default forwarding fee.
*/
function updateCctpDefaultForwardFee(uint256 maxFee) external onlyOwner {
_setNewCctpDefaultForwardFee(maxFee);
}
/**
* @notice Owner-only setter to update the cross-chain forwarding fee for a specific destination domain.
* @param destinationDomain The destination domain identifier.
* @param maxFee The maximum forwarding fee for the destination domain.
*/
function updateCctpForwardFee(uint32 destinationDomain, uint256 maxFee) external onlyOwner {
require(maxFee <= CCTP_FEE_LIMIT, "Forward fee exceeds fee limit");
uint256 previousFee = cctpForwardFees[destinationDomain];
cctpForwardFees[destinationDomain] = maxFee;
isCctpForwardFeeSet[destinationDomain] = true;
emit CctpForwardFeeUpdated(destinationDomain, previousFee, maxFee);
}
/**
* @notice Owner-only function to unset a CCTP forwarding fee override for a destination domain.
* @param destinationDomain The destination domain to unset the override for.
*/
function unsetCctpForwardFee(uint32 destinationDomain) external onlyOwner {
require(isCctpForwardFeeSet[destinationDomain], "Forwarding fee not set");
uint256 previousFee = cctpForwardFees[destinationDomain];
delete cctpForwardFees[destinationDomain];
delete isCctpForwardFeeSet[destinationDomain];
emit CctpForwardFeeUpdated(destinationDomain, previousFee, 0);
}
/**
* @notice Owner-only function to enable dex forwarding.
* @dev When dex forwarding is enabled, deposits to enabled destination dexes will be forwarded via CoreWriter.
*/
function enableDexForwarding() external onlyOwner {
require(isDexForwardingDisabled, "Dex forwarding already enabled");
isDexForwardingDisabled = false;
emit DexForwardingEnabled();
}
/**
* @notice Owner-only function to disable dex forwarding.
* @dev When dex forwarding is disabled, deposits will be sent to the Core spot dex instead of the specified destination dex.
*/
function disableDexForwarding() external onlyOwner {
require(!isDexForwardingDisabled, "Dex forwarding already disabled");
isDexForwardingDisabled = true;
emit DexForwardingDisabled();
}
/**
* @notice Owner-only function to enable a destination dex.
* @dev Cannot enable the Core spot dex (uint32.max.)
* @param dex The destination dex to enable.
*/
function enableDex(uint32 dex) external onlyOwner {
require(dex != CORE_SPOT_DEX_ID, "Cannot enable spot dex");
require(!enabledDestinationDexes[dex], "Dex already enabled");
enabledDestinationDexes[dex] = true;
emit DexEnabled(dex);
}
/**
* @notice Owner-only function to disable a destination dex.
* @param dex The destination dex to disable.
*/
function disableDex(uint32 dex) external onlyOwner {
require(enabledDestinationDexes[dex], "Dex already disabled");
enabledDestinationDexes[dex] = false;
emit DexDisabled(dex);
}
/**
* @notice Deposits tokens to credit the corresponding address on HyperCore, on the specified destination dex.
* @param amount The amount of tokens being deposited.
* @param destinationDex The destination dex on HyperCore (0 for default Core Perps dex, uint32.max for Core Spot dex.)
*/
function deposit(uint256 amount, uint32 destinationDex) external override whenNotPaused {
_deposit(msg.sender, amount, destinationDex);
}
/**
* @notice Deposits tokens to credit a specific recipient on Hypercore.
* @param recipient The address receiving the tokens on HyperCore.
* @param amount The amount of tokens being deposited.
* @param destinationDex The destination dex on HyperCore (0 for default Core Perps dex, uint32.max for Core Spot dex.)
*/
function depositFor(address recipient, uint256 amount, uint32 destinationDex) external override whenNotPaused {
require(recipient != address(0), "Invalid recipient: zero address");
require(recipient != tokenSystemAddress, "Invalid recipient: system address");
require(recipient != address(this), "Invalid recipient: CoreDepositWallet");
require(!token.isBlacklisted(recipient), "Invalid recipient: blacklisted");
_deposit(recipient, amount, destinationDex);
}
/**
* @notice Deposits tokens with authorization to credit the sender on HyperCore.
* @param amount The amount of tokens being deposited.
* @param authValidAfter The timestamp after which the authorization is valid.
* @param authValidBefore The timestamp before which the authorization is valid.
* @param authNonce A unique nonce for the authorization.
* @param v The V value of the signature.
* @param r The R value of the signature.
* @param s The S value of the signature.
* @param destinationDex The destination dex on HyperCore (0 for default Core Perps dex, uint32.max for Core Spot dex.)
*/
function depositWithAuth(
uint256 amount,
uint256 authValidAfter,
uint256 authValidBefore,
bytes32 authNonce,
uint8 v,
bytes32 r,
bytes32 s,
uint32 destinationDex
) external override whenNotPaused {
require(amount > 0, "Amount must be greater than zero");
token.receiveWithAuthorization(
msg.sender,
address(this),
amount,
authValidAfter,
authValidBefore,
authNonce,
v,
r,
s
);
_depositAndForwardIfDexEnabled(msg.sender, amount, destinationDex);
}
/**
* @notice Handles the token transfer from the CoreDepositWallet to the recipient.
* @dev This function can only be called by the token's system address.
* @param to The address receiving the tokens.
* @param amount The amount of tokens being transferred.
* @return success True if the transfer succeeded.
*/
function transfer(address to, uint256 amount) external override whenNotPaused returns (bool success) {
require(msg.sender == tokenSystemAddress, "Caller is not the system address");
require(to != tokenSystemAddress, "Invalid to: system address");
require(token.transfer(to, amount), "Transfer operation failed");
emit Withdraw(to, amount);
return true;
}
/**
* @notice Handles cross-chain token withdrawals from HyperCore to a destination chain via CCTP.
* @dev This function initiates a cross-chain transfer of tokens using CCTP to mint tokens on the destination chain.
* It constructs and sends a CCTP message containing encoded hook data that embeds the optional user-provided
* data to be used on the destination chain and determines the CCTP forwarding behavior.
*
* @dev Requirements:
* - Caller must be the token system address.
* - `amount` must be strictly greater than the computed maximum withdrawal fee
* (see calculateCrossChainWithdrawalFee).
*
* @dev CCTP behavior:
* - The CCTP message's destinationCaller is always set to `bytes32(0)` and anyone can call
* MessageTransmitterV2.receiveMessage directly on the destination chain.
*
* @dev Forwarding is the process of completing the mint on the destination chain by paying gas to
* submit a transaction that includes the CCTP attestation. When forwarding is requested:
* - The forwarder subtracts a configured amount of minted tokens from the final recipient,
* not exceeding the CCTP maxFee.
* - This forwarding amount is added to the CCTP maxFee to compute the total fee for the
* cross-chain withdrawal.
*
* @dev Forwarding logic:
* The forwarding logic is determined by the user-provided data:
* - If `data` is empty: the hook data will be a default forwarding hook and forwarding will be performed.
* - If `data` begins with the CCTP forwarding magic bytes: the hook data will embed `data` and forwarding will be performed.
* - Otherwise: the hook data will embed `data` and forwarding will NOT be performed.
*
* @dev Hook data encoding:
* The hook data is constructed using the `CrossChainWithdrawalHookData` library. See that library for the full
* encoding details.
*
* @param from The HyperCore address debited by the cross-chain withdrawal.
* @param destinationRecipient The address receiving the minted tokens on the destination chain, as bytes32.
* @param destinationChainId The CCTP domain ID of the destination chain.
* @param amount The amount of tokens being transferred.
* @param coreNonce The HyperCore transaction nonce.
* @param data Optional user-provided data to embed in the CCTP message payload hook data; also determines the
* forwarding logic as described above. Must be less than or equal to MAX_HOOK_DATA_SIZE.
*/
function coreReceiveWithData(
address from,
bytes32 destinationRecipient,
uint32 destinationChainId,
uint256 amount,
uint64 coreNonce,
bytes calldata data
) external override whenNotPaused {
require(msg.sender == tokenSystemAddress, "Caller is not the system address");
require(data.length <= MAX_HOOK_DATA_SIZE, "Data length exceeds MAX_HOOK_DATA_SIZE");
bool shouldForward = _shouldForward(data);
uint256 maxFee = calculateCrossChainWithdrawalFee(shouldForward, destinationChainId);
require(amount > maxFee, "Amount must exceed maxFee");
require(token.approve(address(tokenMessenger), amount), "Token approval failed");
// Build the CCTP message payload hook data.
bytes memory hookData = CrossChainWithdrawalHookData._build(shouldForward, from, coreNonce, data);
tokenMessenger.depositForBurnWithHook(
amount,
destinationChainId,
destinationRecipient,
address(token),
bytes32(0),
maxFee,
CCTP_FINALIZED_THRESHOLD,
hookData
);
emit CrossChainWithdraw(from, destinationRecipient, amount, destinationChainId, coreNonce);
}
/**
* @notice Returns the HyperCore protocol constants
* @return constants The HyperCore protocol constants.
*/
function getCoreProtocolConstants() external pure returns (CoreProtocolConstants memory constants) {
return CoreProtocolConstants({
coreWriterActionVersion: CORE_WRITER_ACTION_VERSION,
coreWriterSendAssetActionId: CORE_WRITER_SEND_ASSET_ACTION_ID,
coreTokenIndex: CORE_TOKEN_INDEX,
coreSpotDexId: CORE_SPOT_DEX_ID,
corePerpsDexId: CORE_PERPS_DEX_ID,
coreWriterPrecompileAddress: CORE_WRITER_PRECOMPILE_ADDRESS,
coreUserExistsPrecompileAddress: CORE_USER_EXISTS_PRECOMPILE_ADDRESS,
coreScalingFactor: CORE_SCALING_FACTOR
});
}
/**
* @notice Calculates the maximum fee for the cross-chain withdrawal that will be used in depositForBurnWithHook.
* @dev Behavior:
* - If shouldForward is false, maxFee = cctpMaxFee.
* - If shouldForward is true, maxFee = cctpMaxFee + forwardFee (if destination chain fee override exists, else cctpDefaultForwardFee).
* @param shouldForward True if cross-chain forwarding should be performed, false otherwise.
* @param destinationChainId CCTP domain ID of the destination chain.
* @return maxFee The computed maximum fee for the cross-chain withdrawal that will be used in depositForBurnWithHook.
*/
function calculateCrossChainWithdrawalFee(bool shouldForward, uint32 destinationChainId)
public
view
returns (uint256 maxFee)
{
if (shouldForward) {
uint256 forwardFee = isCctpForwardFeeSet[destinationChainId]
? cctpForwardFees[destinationChainId]
: cctpDefaultForwardFee;
maxFee = cctpMaxFee + forwardFee;
} else {
maxFee = cctpMaxFee;
}
}
// ============ Internal Functions ============
/**
* @notice Deposits tokens to the recipient's account on HyperCore.
* @dev Handles the token transfer to the CoreDepositWallet on behalf of recipient.
* @param _recipient The address receiving the tokens on HyperCore.
* @param _amount The amount of tokens being deposited.
* @param _destinationDex The destination dex on HyperCore.
*/
function _deposit(address _recipient, uint256 _amount, uint32 _destinationDex) internal {
require(_amount > 0, "Amount must be greater than zero");
require(token.transferFrom(msg.sender, address(this), _amount), "Transfer operation failed");
_depositAndForwardIfDexEnabled(_recipient, _amount, _destinationDex);
}
/**
* @notice Rescue ERC20 tokens locked up in this contract.
* @dev Reverts if tokenContract matches token.
* @param tokenContract ERC20 token contract address
* @param to Recipient address
* @param amount Amount to withdraw
*/
function _rescueERC20(IERC20 tokenContract, address to, uint256 amount) internal override {
require(address(tokenContract) != address(token), "Cannot rescue token");
super._rescueERC20(tokenContract, to, amount);
}
/**
* @notice Deposits tokens to the recipient's account on HyperCore.
* @dev Behavior:
* - If dex forwarding is enabled and the specified destination dex is enabled, deposit to the
* CoreDepositWallet address on HyperCore Spot and forward to the recipient address on the specified
* destination dex via CoreWriter.
* - If dex forwarding is disabled, the destination dex is not enabled, or destinationDex is the
* HyperCore Spot dex, deposit to the recipient address on HyperCore Spot.
* - Reverts if _amount exceeds MAX_TRANSFER_VALUE_FROM_EVM.
*
* @param _recipient The address receiving the tokens on HyperCore.
* @param _amount The amount of tokens being deposited.
* @param _destinationDex The intended destination dex on HyperCore.
*/
function _depositAndForwardIfDexEnabled(address _recipient, uint256 _amount, uint32 _destinationDex) internal {
// Ensure the amount is not greater than the maximum HyperCore asset units
require(_amount <= MAX_TRANSFER_VALUE_FROM_EVM, "Amount exceeds max transfer value from EVM");
// If dex forwarding is enabled and the _destinationDex is enabled, deposit to the CoreDepositWallet address on HyperCore Spot
// and forward to the _recipient address on the _destinationDex via CoreWriter.
if (!isDexForwardingDisabled && enabledDestinationDexes[_destinationDex]) {
// Transfer to the CoreDepositWallet address on HyperCore Spot.
emit Transfer(address(this), tokenSystemAddress, _amount);
// Forward to the _recipient address on the _destinationDex via CoreWriter.
_sendAsset(_recipient, _amount, _destinationDex);
}
// Otherwise, deposit to the _recipient address on HyperCore Spot.
else {
// Transfer to the _recipient address on HyperCore Spot.
emit Transfer(_recipient, tokenSystemAddress, _amount);
}
}
/**
* @notice Move the tokens from the CoreDepositWallet's spot to a destination dex on HyperCore via CoreWriter sendAsset action.
* @dev Uses _coreUserExists() to check HyperCore account status and subtracts newCoreAccountFee from the deposit amount for new users.
* Scales the amount from 6 decimals (HyperEVM) to 8 decimals (HyperCore).
* Encodes a HyperCore CoreWriter sendAsset action:
* - Header (packed):
* - version: 1 byte (0x01)
* - actionId: 3 bytes big-endian (0x00000D = send asset)
* - Payload (ABI-encoded):
* (address recipient, // recipient address on HyperCore
* address subAccount, // always address(0) (subaccounts unused)
* uint32 sourceDex, // Core Spot dex: type(uint32).max
* uint32 destinationDex, // destination dex
* uint64 tokenIndex, // 0 for USD on the main dex
* uint64 amount) // amount in core asset units (8 decimals)
*
* Encoding:
* bytes memory payload = abi.encode(
* recipient,
* address(0),
* CORE_SPOT_DEX_ID,
* destinationDex,
* CORE_TOKEN_INDEX,
* amount
* );
* bytes memory data = abi.encodePacked(CORE_WRITER_ACTION_VERSION, CORE_WRITER_SEND_ASSET_ACTION_ID, payload);
*
* @param recipient The address receiving the tokens on HyperCore.
* @param evmAmount Amount of tokens to send from the CoreDepositWallet's spot to the destination dex in EVM token units (6 decimals).
* @param destinationDex The destination dex on HyperCore.
*/
function _sendAsset(address recipient, uint256 evmAmount, uint32 destinationDex) internal {
uint256 scaledAmount = evmAmount * CORE_SCALING_FACTOR;
uint64 coreAmount = uint64(scaledAmount);
uint64 _newCoreAccountFee = newCoreAccountFee;
if (_newCoreAccountFee > 0) {
if (!_coreUserExists(recipient)) {
require(coreAmount > _newCoreAccountFee, "Amount must exceed new account fee");
coreAmount = coreAmount - _newCoreAccountFee;
emit NewCoreAccountFeeApplied(recipient, _newCoreAccountFee, evmAmount, coreAmount);
}
}
bytes memory payload = abi.encode(
recipient,
address(0),
CORE_SPOT_DEX_ID,
destinationDex,
CORE_TOKEN_INDEX,
coreAmount
);
bytes memory data = abi.encodePacked(CORE_WRITER_ACTION_VERSION, CORE_WRITER_SEND_ASSET_ACTION_ID, payload);
ICoreWriter(CORE_WRITER_PRECOMPILE_ADDRESS).sendRawAction(data);
emit SendAsset(recipient, coreAmount, destinationDex);
}
/**
* @notice Updates the fee applied to deposits for users who don't exist on HyperCore.
* @dev This fee is deducted from deposit amounts when _coreUserExists returns false.
* @param _newCoreAccountFee The new account creation fee in core token units (8 decimals).
*/
function _setNewCoreAccountFee(uint64 _newCoreAccountFee) internal {
uint64 previous = newCoreAccountFee;
newCoreAccountFee = _newCoreAccountFee;
emit NewCoreAccountFeeUpdated(previous, _newCoreAccountFee);
}
/**
* @notice Updates the cross-chain message fee.
* @param _cctpMaxFee The new maximum fee.
*/
function _setNewCctpMaxFee(uint256 _cctpMaxFee) internal {
require(_cctpMaxFee <= CCTP_FEE_LIMIT, "Max fee exceeds fee limit");
uint256 previous = cctpMaxFee;
cctpMaxFee = _cctpMaxFee;
emit CctpMaxFeeUpdated(previous, _cctpMaxFee);
}
/**
* @notice Updates the default cross-chain forwarding fee.
* @param _cctpDefaultForwardFee The new default forwarding fee.
*/
function _setNewCctpDefaultForwardFee(uint256 _cctpDefaultForwardFee) internal {
require(_cctpDefaultForwardFee <= CCTP_FEE_LIMIT, "Forward fee exceeds fee limit");
uint256 previous = cctpDefaultForwardFee;
cctpDefaultForwardFee = _cctpDefaultForwardFee;
emit CctpDefaultForwardFeeUpdated(previous, _cctpDefaultForwardFee);
}
/**
* @notice Queries the HyperCore precompile to determine if a user account exists.
* @dev Makes a staticcall to the CORE_USER_EXISTS_PRECOMPILE_ADDRESS precompile.
* @param user The address to check for existence on HyperCore
* @return exists True if the user exists on HyperCore, false otherwise
*/
function _coreUserExists(address user) internal view returns (bool) {
(bool success, bytes memory result) = CORE_USER_EXISTS_PRECOMPILE_ADDRESS.staticcall(abi.encode(user));
require(success, "Core user exists precompile call failed");
return abi.decode(result, (CoreUserExists)).exists;
}
/**
* @notice Determines if cross-chain withdrawal forwarding should be performed.
* @dev If `data` is empty, cross-chain withdrawal forwarding should be performed.
* @dev If `data` begins with the CCTP forwarding magic bytes, cross-chain withdrawal forwarding should be performed.
* @dev Otherwise, cross-chain withdrawal forwarding should not be performed.
* @dev Reverts if hook data is malformed.
* @param data The user-provided hook data.
* @return True if cross-chain withdrawal forwarding should be performed, false otherwise.
*/
function _shouldForward(bytes calldata data) internal pure returns (bool) {
if (data.length == 0) return true;
bytes29 _data = TypedMemView.ref(data, 0);
CrossChainWithdrawalHookData._validateHookData(_data);
return CrossChainWithdrawalHookData._hasForwardingMagicBytes(_data);
}
}// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}/*
* Copyright 2025 Circle Internet Group, Inc. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
pragma solidity 0.7.6;
import {IForwardDepositReceiver} from "./IForwardDepositReceiver.sol";
/**
* @title ICoreDepositWallet
* @notice Interface for the core deposit wallet
*/
interface ICoreDepositWallet is IForwardDepositReceiver {
/**
* @notice Deposits tokens for the sender.
* @param amount The amount of tokens being deposited.
* @param destinationDex The destination dex on HyperCore.
*/
function deposit(uint256 amount, uint32 destinationDex) external;
/**
* @notice Handles the token transfer from the ICoreDepositWallet to the recipient.
* @param to The address receiving the tokens.
* @param amount The amount of tokens being transferred.
* @return success True if the transfer succeeded.
*/
function transfer(address to, uint256 amount) external returns (bool success);
/**
* @notice Handles cross-chain token withdrawals from HyperCore to a destination chain via CCTP.
* @dev This function initiates a cross-chain transfer of tokens using CCTP to mint tokens on the destination chain.
* It constructs and sends a CCTP message containing encoded hook data that embeds the optional user-provided
* data to be used on the destination chain and determines the CCTP forwarding behavior.
*
* @dev Requirements:
* - Caller must be the token system address.
* - `amount` must be strictly greater than the computed maximum withdrawal fee
* (see calculateCrossChainWithdrawalFee).
*
* @dev CCTP behavior:
* - The CCTP message's destinationCaller is always set to `bytes32(0)` and anyone can call
* MessageTransmitterV2.receiveMessage directly on the destination chain.
*
* @dev Forwarding is the process of completing the mint on the destination chain by paying gas to
* submit a transaction that includes the CCTP attestation. When forwarding is requested:
* - The forwarder subtracts a configured amount of minted tokens from the final recipient,
* not exceeding the CCTP maxFee.
* - This forwarding amount is added to the CCTP maxFee to compute the total fee for the
* cross-chain withdrawal.
*
* @dev Forwarding logic:
* The forwarding logic is determined by the user-provided data:
* - If `data` is empty: the hook data will be a default forwarding hook and forwarding will be performed.
* - If `data` begins with the CCTP forwarding magic bytes: the hook data will embed `data` and forwarding will be performed.
* - Otherwise: the hook data will embed `data` and forwarding will NOT be performed.
*
* @dev Hook data encoding:
* The hook data is constructed using the `CrossChainWithdrawalHookData` library. See that library for the full
* encoding details.
*
* @param from The HyperCore address debited by the cross-chain withdrawal.
* @param destinationRecipient The address receiving the minted tokens on the destination chain, as bytes32.
* @param destinationChainId The CCTP domain ID of the destination chain.
* @param amount The amount of tokens being transferred.
* @param coreNonce The HyperCore transaction nonce.
* @param data Optional user-provided data to embed in the CCTP message payload hook data; also determines the
* forwarding logic as described above. Must be less than or equal to MAX_HOOK_DATA_SIZE.
*/
function coreReceiveWithData(
address from,
bytes32 destinationRecipient,
uint32 destinationChainId,
uint256 amount,
uint64 coreNonce,
bytes calldata data
) external;
/**
* @notice Deposits tokens with authorization.
* @param amount The amount of tokens being deposited.
* @param authValidAfter The timestamp after which the authorization is valid.
* @param authValidBefore The timestamp before which the authorization is valid.
* @param authNonce A unique nonce for the authorization.
* @param v The V value of the signature.
* @param r The R value of the signature.
* @param s The S value of the signature.
* @param destinationDex The destination dex on HyperCore.
*/
function depositWithAuth(
uint256 amount,
uint256 authValidAfter,
uint256 authValidBefore,
bytes32 authNonce,
uint8 v,
bytes32 r,
bytes32 s,
uint32 destinationDex
) external;
}/*
* Copyright (c) 2022, Circle Internet Financial Limited.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
pragma solidity 0.7.6;
import "./Ownable2Step.sol";
/**
* @notice Base contract which allows children to implement an emergency stop
* mechanism
* @dev Forked from https://github.com/centrehq/centre-tokens/blob/0d3cab14ebd133a83fc834dbd48d0468bdf0b391/contracts/v1/Pausable.sol
* Modifications:
* 1. Update Solidity version from 0.6.12 to 0.7.6 (8/23/2022)
* 2. Change pauser visibility to private, declare external getter (11/19/22)
* 3. Add internal _updatePauser (10/8/2024)
*/
contract Pausable is Ownable2Step {
event Pause();
event Unpause();
event PauserChanged(address indexed newAddress);
address private _pauser;
bool public paused = false;
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*/
modifier whenNotPaused() {
require(!paused, "Pausable: paused");
_;
}
/**
* @dev throws if called by any account other than the pauser
*/
modifier onlyPauser() {
require(msg.sender == _pauser, "Pausable: caller is not the pauser");
_;
}
/**
* @notice Returns current pauser
* @return Pauser's address
*/
function pauser() external view returns (address) {
return _pauser;
}
/**
* @dev called by the owner to pause, triggers stopped state
*/
function pause() external onlyPauser {
paused = true;
emit Pause();
}
/**
* @dev called by the owner to unpause, returns to normal state
*/
function unpause() external onlyPauser {
paused = false;
emit Unpause();
}
/**
* @dev update the pauser role
*/
function updatePauser(address _newPauser) external onlyOwner {
_updatePauser(_newPauser);
}
/**
* @dev update the pauser role
*/
function _updatePauser(address _newPauser) internal {
require(
_newPauser != address(0),
"Pausable: new pauser is the zero address"
);
_pauser = _newPauser;
emit PauserChanged(_pauser);
}
}/*
* Copyright (c) 2025, Circle Internet Financial Limited.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
pragma solidity 0.7.6;
import "@evm-cctp-contracts/roles/Ownable2Step.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";
/**
* @notice Base contract which allows children to rescue ERC20 locked in their contract.
* @dev Forked from https://github.com/circlefin/evm-cctp-contracts/blob/5e893866d49326d62d3ecf3f7fb599dd71787469/src/roles/Rescuable.sol
* Modifications:
* 1. Add _rescueERC20 internal virtual, delegate rescueERC20 to _rescueERC20 (8/15/2025)
*/
contract Rescuable is Ownable2Step {
using SafeERC20 for IERC20;
address private _rescuer;
event RescuerChanged(address indexed newRescuer);
/**
* @notice Returns current rescuer
* @return Rescuer's address
*/
function rescuer() external view returns (address) {
return _rescuer;
}
/**
* @notice Revert if called by any account other than the rescuer.
*/
modifier onlyRescuer() {
require(msg.sender == _rescuer, "Rescuable: caller is not the rescuer");
_;
}
/**
* @notice Rescue ERC20 tokens locked up in this contract.
* @param tokenContract ERC20 token contract address
* @param to Recipient address
* @param amount Amount to withdraw
*/
function rescueERC20(IERC20 tokenContract, address to, uint256 amount) external onlyRescuer {
_rescueERC20(tokenContract, to, amount);
}
/**
* @notice Rescue ERC20 tokens locked up in this contract.
* @param tokenContract ERC20 token contract address
* @param to Recipient address
* @param amount Amount to withdraw
*/
function _rescueERC20(IERC20 tokenContract, address to, uint256 amount) internal virtual {
tokenContract.safeTransfer(to, amount);
}
/**
* @notice Assign the rescuer role to a given address.
* @param newRescuer New rescuer's address
*/
function updateRescuer(address newRescuer) external onlyOwner {
_updateRescuer(newRescuer);
}
/**
* @notice Assign the rescuer role to a given address.
* @param newRescuer New rescuer's address
*/
function _updateRescuer(address newRescuer) internal {
require(newRescuer != address(0), "Rescuable: new rescuer is the zero address");
_rescuer = newRescuer;
emit RescuerChanged(newRescuer);
}
}/*
* Copyright 2024 Circle Internet Group, Inc. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
pragma solidity 0.7.6;
import {Address} from "@openzeppelin/contracts/utils/Address.sol";
/**
* @title Initializable
* @notice Base class to support implementation contracts behind a proxy
* @dev Forked from: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/3e6c86392c97fbc30d3d20a378a6f58beba08eba/contracts/proxy/utils/Initializable.sol
* Modifications (10/5/2024):
* - Pinned to Solidity 0.7.6
* - Replaced errors with revert strings
* - Replaced address.code call with Address.isContract for Solidity 0.7.6
*/
abstract contract Initializable {
/**
* @dev Storage of the initializable contract.
*
* It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions
* when using with upgradeable contracts.
*
* @custom:storage-location erc7201:openzeppelin.storage.Initializable
*/
struct InitializableStorage {
// Indicates that the contract has been initialized.
uint64 _initialized;
// Indicates that the contract is in the process of being initialized.
bool _initializing;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Initializable")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant INITIALIZABLE_STORAGE =
0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00;
/**
* @dev Triggered when the contract has been initialized or reinitialized.
*/
event Initialized(uint64 version);
/**
* @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
* `onlyInitializing` functions can be used to initialize parent contracts.
*
* Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any
* number of times. This behavior in the constructor can be useful during testing and is not expected to be used in
* production.
*
* Emits an {Initialized} event.
*/
modifier initializer() {
// solhint-disable-next-line var-name-mixedcase
InitializableStorage storage $ = _getInitializableStorage();
// Cache values to avoid duplicated sloads
bool isTopLevelCall = !$._initializing;
uint64 initialized = $._initialized;
// Allowed calls:
// - initialSetup: the contract is not in the initializing state and no previous version was
// initialized
// - construction: the contract is initialized at version 1 (no reininitialization) and the
// current contract is just being deployed
bool initialSetup = initialized == 0 && isTopLevelCall;
// 10/5/2024 fork: use Address.isContract instead of address(this).code.length for Solidity 0.7.6.
bool construction = initialized == 1 &&
!Address.isContract(address(this));
// 10/5/2024 fork: convert custom error to require statement
require(
initialSetup || construction,
"Initializable: invalid initialization"
);
$._initialized = 1;
if (isTopLevelCall) {
$._initializing = true;
}
_;
if (isTopLevelCall) {
$._initializing = false;
emit Initialized(1);
}
}
/**
* @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
* contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
* used to initialize parent contracts.
*
* A reinitializer may be used after the original initialization step. This is essential to configure modules that
* are added through upgrades and that require initialization.
*
* When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
* cannot be nested. If one is invoked in the context of another, execution will revert.
*
* Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
* a contract, executing them in the right order is up to the developer or operator.
*
* WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization.
*
* Emits an {Initialized} event.
*/
modifier reinitializer(uint64 version) {
// solhint-disable-next-line var-name-mixedcase
InitializableStorage storage $ = _getInitializableStorage();
// 10/5/2024 fork: convert custom error to require statement
require(
!$._initializing && $._initialized < version,
"Initializable: invalid initialization"
);
$._initialized = version;
$._initializing = true;
_;
$._initializing = false;
emit Initialized(version);
}
/**
* @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
* {initializer} and {reinitializer} modifiers, directly or indirectly.
*/
modifier onlyInitializing() {
_checkInitializing();
_;
}
/**
* @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}.
*/
function _checkInitializing() internal view virtual {
// 10/5/2024 fork: convert custom error to require statement
require(_isInitializing(), "Initializable: not initializing");
}
/**
* @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
* Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
* to any version. It is recommended to use this to lock implementation contracts that are designed to be called
* through proxies.
*
* Emits an {Initialized} event the first time it is successfully executed.
*/
function _disableInitializers() internal virtual {
// solhint-disable-next-line var-name-mixedcase
InitializableStorage storage $ = _getInitializableStorage();
// 10/5/2024 fork: convert custom error to require statement
require(!$._initializing, "Initializable: invalid initialization");
if ($._initialized != type(uint64).max) {
$._initialized = type(uint64).max;
emit Initialized(type(uint64).max);
}
}
/**
* @dev Returns the highest version that has been initialized. See {reinitializer}.
*/
function _getInitializedVersion() internal view returns (uint64) {
return _getInitializableStorage()._initialized;
}
/**
* @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.
*/
function _isInitializing() internal view returns (bool) {
return _getInitializableStorage()._initializing;
}
/**
* @dev Returns a pointer to the storage namespace.
*/
// solhint-disable-next-line var-name-mixedcase
function _getInitializableStorage()
private
pure
returns (InitializableStorage storage $)
{
assembly {
$.slot := INITIALIZABLE_STORAGE
}
}
}/*
* Copyright 2025 Circle Internet Group, Inc. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
pragma solidity 0.7.6;
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {IEIP3009Token} from "./IEIP3009Token.sol";
/**
* @title IDepositableToken
* @notice Interface for a token that can be deposited into a CoreDepositWallet
*/
interface IDepositableToken is IERC20, IEIP3009Token {
/**
* @notice Checks if an account is blacklisted
* @param _account The address to check
*/
function isBlacklisted(address _account) external view returns (bool);
}/*
* Copyright 2025 Circle Internet Group, Inc. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
pragma solidity 0.7.6;
/**
* @title ICoreWriter
* @notice Interface for the CoreWriter precompile contract on HyperEVM.
*/
interface ICoreWriter {
/**
* @notice Sends a raw action to the CoreWriter precompile contract.
* @dev This function is used to send a raw action to the CoreWriter precompile contract. Used by the CoreDepositWallet for asset transfers.
* @param data The data to send to the CoreWriter precompile contract.
*/
function sendRawAction(bytes calldata data) external;
}/*
* Copyright 2024 Circle Internet Group, Inc. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
pragma solidity 0.7.6;
pragma abicoder v2;
import {SafeMath} from "@openzeppelin/contracts/math/SafeMath.sol";
import {BaseTokenMessenger} from "./BaseTokenMessenger.sol";
import {ITokenMinterV2} from "../interfaces/v2/ITokenMinterV2.sol";
import {AddressUtils} from "../messages/v2/AddressUtils.sol";
import {IRelayerV2} from "../interfaces/v2/IRelayerV2.sol";
import {IMessageHandlerV2} from "../interfaces/v2/IMessageHandlerV2.sol";
import {TypedMemView} from "@memview-sol/contracts/TypedMemView.sol";
import {BurnMessageV2} from "../messages/v2/BurnMessageV2.sol";
import {TOKEN_MESSENGER_MIN_FINALITY_THRESHOLD} from "./FinalityThresholds.sol";
/**
* @title TokenMessengerV2
* @notice Sends and receives messages to/from MessageTransmitters
* and to/from TokenMinters.
*/
contract TokenMessengerV2 is IMessageHandlerV2, BaseTokenMessenger {
// ============ Structs ============
struct TokenMessengerV2Roles {
address owner;
address rescuer;
address feeRecipient;
address denylister;
address tokenMinter;
address minFeeController;
}
// ============ Events ============
/**
* @notice Emitted when a DepositForBurn message is sent
* @param burnToken address of token burnt on source domain
* @param amount deposit amount
* @param depositor address where deposit is transferred from
* @param mintRecipient address receiving minted tokens on destination domain as bytes32
* @param destinationDomain destination domain
* @param destinationTokenMessenger address of TokenMessenger on destination domain as bytes32
* @param destinationCaller authorized caller as bytes32 of receiveMessage() on destination domain.
* If equal to bytes32(0), any address can broadcast the message.
* @param maxFee maximum fee to pay on destination domain, in units of burnToken
* @param minFinalityThreshold the minimum finality at which the message should be attested to.
* @param hookData optional hook for execution on destination domain
*/
event DepositForBurn(
address indexed burnToken,
uint256 amount,
address indexed depositor,
bytes32 mintRecipient,
uint32 destinationDomain,
bytes32 destinationTokenMessenger,
bytes32 destinationCaller,
uint256 maxFee,
uint32 indexed minFinalityThreshold,
bytes hookData
);
// ============ Libraries ============
using AddressUtils for address;
using AddressUtils for address payable;
using AddressUtils for bytes32;
using BurnMessageV2 for bytes29;
using TypedMemView for bytes;
using TypedMemView for bytes29;
using SafeMath for uint256;
// ============ Constructor ============
/**
* @param _messageTransmitter Message transmitter address
* @param _messageBodyVersion Message body version
*/
constructor(
address _messageTransmitter,
uint32 _messageBodyVersion
) BaseTokenMessenger(_messageTransmitter, _messageBodyVersion) {
_disableInitializers();
}
// ============ Initializers ============
/**
* @notice Initializes the contract
* @dev Reverts if any of the roles are the zero address
* @dev Reverts if `remoteDomains_` and `remoteTokenMessengers_` are unequal length
* @dev Each remoteTokenMessenger address must correspond to the remote domain at the same
* index in respective arrays.
* @dev Reverts if any `remoteTokenMessengers_` entry equals bytes32(0)
* @param roles Roles configuration
* @param minFee_ Minimum fee
* @param remoteDomains_ Array of remote domains to configure
* @param remoteTokenMessengers_ Array of remote token messenger addresses
*/
function initialize(
TokenMessengerV2Roles calldata roles,
uint256 minFee_,
uint32[] calldata remoteDomains_,
bytes32[] calldata remoteTokenMessengers_
) external initializer {
require(roles.owner != address(0), "Owner is the zero address");
require(
remoteDomains_.length == remoteTokenMessengers_.length,
"Invalid remote domain configuration"
);
// Roles
_transferOwnership(roles.owner);
_updateRescuer(roles.rescuer);
_updateDenylister(roles.denylister);
_setFeeRecipient(roles.feeRecipient);
// Local minter configuration
_setLocalMinter(roles.tokenMinter);
// Fee configuration
_setMinFeeController(roles.minFeeController);
_setMinFee(minFee_);
// Remote token messenger configuration
uint256 _remoteDomainsLength = remoteDomains_.length;
for (uint256 i; i < _remoteDomainsLength; ++i) {
_addRemoteTokenMessenger(
remoteDomains_[i],
remoteTokenMessengers_[i]
);
}
}
// ============ External Functions ============
/**
* @notice Deposits and burns tokens from sender to be minted on destination domain.
* Emits a `DepositForBurn` event.
* @dev reverts if:
* - given burnToken is not supported
* - given destinationDomain has no TokenMessenger registered
* - transferFrom() reverts. For example, if sender's burnToken balance or approved allowance
* to this contract is less than `amount`.
* - burn() reverts. For example, if `amount` is 0.
* - maxFee is greater than or equal to `amount`.
* - maxFee is less than `amount * minFee / MIN_FEE_MULTIPLIER`.
* - MessageTransmitterV2#sendMessage reverts.
* @param amount amount of tokens to burn
* @param destinationDomain destination domain to receive message on
* @param mintRecipient address of mint recipient on destination domain
* @param burnToken token to burn `amount` of, on local domain
* @param destinationCaller authorized caller on the destination domain, as bytes32. If equal to bytes32(0),
* any address can broadcast the message.
* @param maxFee maximum fee to pay on the destination domain, specified in units of burnToken
* @param minFinalityThreshold the minimum finality at which a burn message will be attested to.
*/
function depositForBurn(
uint256 amount,
uint32 destinationDomain,
bytes32 mintRecipient,
address burnToken,
bytes32 destinationCaller,
uint256 maxFee,
uint32 minFinalityThreshold
) external notDenylistedCallers {
bytes calldata _emptyHookData = msg.data[0:0];
_depositForBurn(
amount,
destinationDomain,
mintRecipient,
burnToken,
destinationCaller,
maxFee,
minFinalityThreshold,
_emptyHookData
);
}
/**
* @notice Deposits and burns tokens from sender to be minted on destination domain.
* Emits a `DepositForBurn` event.
* @dev reverts if:
* - `hookData` is zero-length
* - `burnToken` is not supported
* - `destinationDomain` has no TokenMessenger registered
* - transferFrom() reverts. For example, if sender's burnToken balance or approved allowance
* to this contract is less than `amount`.
* - burn() reverts. For example, if `amount` is 0.
* - maxFee is greater than or equal to `amount`.
* - maxFee is less than `amount * minFee / MIN_FEE_MULTIPLIER`.
* - MessageTransmitterV2#sendMessage reverts.
* @param amount amount of tokens to burn
* @param destinationDomain destination domain to receive message on
* @param mintRecipient address of mint recipient on destination domain, as bytes32
* @param burnToken token to burn `amount` of, on local domain
* @param destinationCaller authorized caller on the destination domain, as bytes32. If equal to bytes32(0),
* any address can broadcast the message.
* @param maxFee maximum fee to pay on the destination domain, specified in units of burnToken
* @param hookData hook data to append to burn message for interpretation on destination domain
*/
function depositForBurnWithHook(
uint256 amount,
uint32 destinationDomain,
bytes32 mintRecipient,
address burnToken,
bytes32 destinationCaller,
uint256 maxFee,
uint32 minFinalityThreshold,
bytes calldata hookData
) external notDenylistedCallers {
require(hookData.length > 0, "Hook data is empty");
_depositForBurn(
amount,
destinationDomain,
mintRecipient,
burnToken,
destinationCaller,
maxFee,
minFinalityThreshold,
hookData
);
}
/**
* @notice Handles an incoming finalized message received by the local MessageTransmitter,
* and takes the appropriate action. For a burn message, mints the
* associated token to the requested recipient on the local domain.
* @dev Validates the local sender is the local MessageTransmitter, and the
* remote sender is a registered remote TokenMessenger for `remoteDomain`.
* @param remoteDomain The domain where the message originated from.
* @param sender The sender of the message (remote TokenMessenger).
* @param messageBody The message body bytes.
* @return success Bool, true if successful.
*/
function handleReceiveFinalizedMessage(
uint32 remoteDomain,
bytes32 sender,
uint32,
bytes calldata messageBody
)
external
override
onlyLocalMessageTransmitter
onlyRemoteTokenMessenger(remoteDomain, sender)
returns (bool)
{
return _handleReceiveMessage(messageBody.ref(0), remoteDomain);
}
/**
* @notice Handles an incoming unfinalized message received by the local MessageTransmitter,
* and takes the appropriate action. For a burn message, mints the
* associated token to the requested recipient on the local domain, less fees.
* Fees are separately minted to the currently set `feeRecipient` address.
* @dev Validates the local sender is the local MessageTransmitter, and the
* remote sender is a registered remote TokenMessenger for `remoteDomain`.
* @dev Validates that `finalityThresholdExecuted` is at least 500.
* @param remoteDomain The domain where the message originated from.
* @param sender The sender of the message (remote TokenMessenger).
* @param finalityThresholdExecuted The level of finality at which the message was attested to
* @param messageBody The message body bytes.
* @return success Bool, true if successful.
*/
function handleReceiveUnfinalizedMessage(
uint32 remoteDomain,
bytes32 sender,
uint32 finalityThresholdExecuted,
bytes calldata messageBody
)
external
override
onlyLocalMessageTransmitter
onlyRemoteTokenMessenger(remoteDomain, sender)
returns (bool)
{
require(
finalityThresholdExecuted >= TOKEN_MESSENGER_MIN_FINALITY_THRESHOLD,
"Unsupported finality threshold"
);
return _handleReceiveMessage(messageBody.ref(0), remoteDomain);
}
/**
* @notice Returns the minimum fee for a given amount
* @param amount The amount for which to calculate the minimum fee
* @return The minimum fee for the given amount
*/
function getMinFeeAmount(uint256 amount) external view returns (uint256) {
if (minFee == 0) return 0;
require(amount > 1, "Amount too low");
return _calcMinFeeAmount(amount);
}
// ============ Internal Utils ============
/**
* Calculates the minimum fee amount for a given amount.
* @dev Amount should be constrained to be greater than 1.
* @dev Assumes `minFee` is non-zero.
* @param _amount The amount for which to calculate the minimum fee.
* @return The minimum fee for the given amount.
*/
function _calcMinFeeAmount(
uint256 _amount
) internal view returns (uint256) {
uint256 _minFeeAmount = _amount.mul(minFee) / MIN_FEE_MULTIPLIER;
return _minFeeAmount == 0 ? 1 : _minFeeAmount;
}
/**
* @notice Deposits and burns tokens from sender to be minted on destination domain.
* Emits a `DepositForBurn` event.
* @param _amount amount of tokens to burn (must be non-zero)
* @param _destinationDomain destination domain
* @param _mintRecipient address of mint recipient on destination domain
* @param _burnToken address of the token burned on the source chain
* @param _destinationCaller caller on the destination domain, as bytes32
* @param _maxFee maximum fee to pay on destination chain
* @param _hookData optional hook data for interpretation on destination chain
*/
function _depositForBurn(
uint256 _amount,
uint32 _destinationDomain,
bytes32 _mintRecipient,
address _burnToken,
bytes32 _destinationCaller,
uint256 _maxFee,
uint32 _minFinalityThreshold,
bytes calldata _hookData
) internal {
require(_amount > 0, "Amount must be nonzero");
require(_mintRecipient != bytes32(0), "Mint recipient must be nonzero");
require(_maxFee < _amount, "Max fee must be less than amount");
// Verify minimum fee
if (minFee > 0) {
// Implicitly constrains `_amount` to be greater than 1
// 0 < minFeeAmount <= maxFee < amount
require(
_maxFee >= _calcMinFeeAmount(_amount),
"Insufficient max fee"
);
}
bytes32 _destinationTokenMessenger = _getRemoteTokenMessenger(
_destinationDomain
);
// Deposit and burn tokens
_depositAndBurn(_burnToken, msg.sender, _amount);
// Format message body
bytes memory _burnMessage = BurnMessageV2._formatMessageForRelay(
messageBodyVersion,
_burnToken.toBytes32(),
_mintRecipient,
_amount,
msg.sender.toBytes32(),
_maxFee,
_hookData
);
// Send message
IRelayerV2(localMessageTransmitter).sendMessage(
_destinationDomain,
_destinationTokenMessenger,
_destinationCaller,
_minFinalityThreshold,
_burnMessage
);
emit DepositForBurn(
_burnToken,
_amount,
msg.sender,
_mintRecipient,
_destinationDomain,
_destinationTokenMessenger,
_destinationCaller,
_maxFee,
_minFinalityThreshold,
_hookData
);
}
/**
* @notice Validates a received message and mints the token to the mintRecipient, less fees.
* @dev Reverts if _validatedReceivedMessage fails to validate the message.
* @dev Reverts if the mint operation fails.
* @param _msg Received message
* @param _remoteDomain The domain where the message originated from
* @return success Bool, true if successful.
*/
function _handleReceiveMessage(
bytes29 _msg,
uint32 _remoteDomain
) internal returns (bool) {
// Validate message and unpack fields
(
address _mintRecipient,
bytes32 _burnToken,
uint256 _amount,
uint256 _fee
) = _validatedReceivedMessage(_msg);
// Mint tokens
_mintAndWithdraw(
_remoteDomain,
_burnToken,
_mintRecipient,
_amount - _fee,
_fee
);
return true;
}
/**
* @notice Validates a BurnMessage and unpacks relevant fields.
* @dev Reverts if the BurnMessage is malformed
* @dev Reverts if the BurnMessage version isn't supported
* @dev Reverts if the BurnMessage has expired
* @dev Reverts if the fee equals or exceeds the amount
* @dev Reverts if the fee exceeds the max fee specified on the source chain
* @param _msg Finalized message
* @return _mintRecipient The recipient of the mint, as bytes32
* @return _burnToken The address of the token burned on the source chain
* @return _amount The amount of burnToken burned
* @return _fee The fee executed
*/
function _validatedReceivedMessage(
bytes29 _msg
)
internal
view
returns (
address _mintRecipient,
bytes32 _burnToken,
uint256 _amount,
uint256 _fee
)
{
_msg._validateBurnMessageFormat();
require(
_msg._getVersion() == messageBodyVersion,
"Invalid message body version"
);
// Enforce message expiration
uint256 _expirationBlock = _msg._getExpirationBlock();
require(
_expirationBlock == 0 || _expirationBlock > block.number,
"Message expired and must be re-signed"
);
// Validate fee
_amount = _msg._getAmount();
_fee = _msg._getFeeExecuted();
require(_fee == 0 || _fee < _amount, "Fee equals or exceeds amount");
require(_fee <= _msg._getMaxFee(), "Fee exceeds max fee");
_mintRecipient = _msg._getMintRecipient().toAddress();
_burnToken = _msg._getBurnToken();
}
}// SPDX-License-Identifier: MIT OR Apache-2.0
pragma solidity >=0.5.10 <0.8.0;
import {SafeMath} from "./SafeMath.sol";
library TypedMemView {
using SafeMath for uint256;
// Why does this exist?
// the solidity `bytes memory` type has a few weaknesses.
// 1. You can't index ranges effectively
// 2. You can't slice without copying
// 3. The underlying data may represent any type
// 4. Solidity never deallocates memory, and memory costs grow
// superlinearly
// By using a memory view instead of a `bytes memory` we get the following
// advantages:
// 1. Slices are done on the stack, by manipulating the pointer
// 2. We can index arbitrary ranges and quickly convert them to stack types
// 3. We can insert type info into the pointer, and typecheck at runtime
// This makes `TypedMemView` a useful tool for efficient zero-copy
// algorithms.
// Why bytes29?
// We want to avoid confusion between views, digests, and other common
// types so we chose a large and uncommonly used odd number of bytes
//
// Note that while bytes are left-aligned in a word, integers and addresses
// are right-aligned. This means when working in assembly we have to
// account for the 3 unused bytes on the righthand side
//
// First 5 bytes are a type flag.
// - ff_ffff_fffe is reserved for unknown type.
// - ff_ffff_ffff is reserved for invalid types/errors.
// next 12 are memory address
// next 12 are len
// bottom 3 bytes are empty
// Assumptions:
// - non-modification of memory.
// - No Solidity updates
// - - wrt free mem point
// - - wrt bytes representation in memory
// - - wrt memory addressing in general
// Usage:
// - create type constants
// - use `assertType` for runtime type assertions
// - - unfortunately we can't do this at compile time yet :(
// - recommended: implement modifiers that perform type checking
// - - e.g.
// - - `uint40 constant MY_TYPE = 3;`
// - - ` modifer onlyMyType(bytes29 myView) { myView.assertType(MY_TYPE); }`
// - instantiate a typed view from a bytearray using `ref`
// - use `index` to inspect the contents of the view
// - use `slice` to create smaller views into the same memory
// - - `slice` can increase the offset
// - - `slice can decrease the length`
// - - must specify the output type of `slice`
// - - `slice` will return a null view if you try to overrun
// - - make sure to explicitly check for this with `notNull` or `assertType`
// - use `equal` for typed comparisons.
// The null view
bytes29 public constant NULL = hex"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffff";
// Mask a low uint96
uint256 constant LOW_12_MASK = 0xffffffffffffffffffffffff;
// Shift constants
uint8 constant SHIFT_TO_LEN = 24;
uint8 constant SHIFT_TO_LOC = 96 + 24;
uint8 constant SHIFT_TO_TYPE = 96 + 96 + 24;
// For nibble encoding
bytes private constant NIBBLE_LOOKUP = "0123456789abcdef";
/**
* @notice Returns the encoded hex character that represents the lower 4 bits of the argument.
* @param _byte The byte
* @return _char The encoded hex character
*/
function nibbleHex(uint8 _byte) internal pure returns (uint8 _char) {
uint8 _nibble = _byte & 0x0f; // keep bottom 4, 0 top 4
_char = uint8(NIBBLE_LOOKUP[_nibble]);
}
/**
* @notice Returns a uint16 containing the hex-encoded byte.
* @param _b The byte
* @return encoded - The hex-encoded byte
*/
function byteHex(uint8 _b) internal pure returns (uint16 encoded) {
encoded |= nibbleHex(_b >> 4); // top 4 bits
encoded <<= 8;
encoded |= nibbleHex(_b); // lower 4 bits
}
/**
* @notice Encodes the uint256 to hex. `first` contains the encoded top 16 bytes.
* `second` contains the encoded lower 16 bytes.
*
* @param _b The 32 bytes as uint256
* @return first - The top 16 bytes
* @return second - The bottom 16 bytes
*/
function encodeHex(uint256 _b) internal pure returns (uint256 first, uint256 second) {
for (uint8 i = 31; i > 15; i -= 1) {
uint8 _byte = uint8(_b >> (i * 8));
first |= byteHex(_byte);
if (i != 16) {
first <<= 16;
}
}
// abusing underflow here =_=
for (uint8 i = 15; i < 255 ; i -= 1) {
uint8 _byte = uint8(_b >> (i * 8));
second |= byteHex(_byte);
if (i != 0) {
second <<= 16;
}
}
}
/**
* @notice Changes the endianness of a uint256.
* @dev https://graphics.stanford.edu/~seander/bithacks.html#ReverseParallel
* @param _b The unsigned integer to reverse
* @return v - The reversed value
*/
function reverseUint256(uint256 _b) internal pure returns (uint256 v) {
v = _b;
// swap bytes
v = ((v >> 8) & 0x00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF) |
((v & 0x00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF) << 8);
// swap 2-byte long pairs
v = ((v >> 16) & 0x0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF) |
((v & 0x0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF) << 16);
// swap 4-byte long pairs
v = ((v >> 32) & 0x00000000FFFFFFFF00000000FFFFFFFF00000000FFFFFFFF00000000FFFFFFFF) |
((v & 0x00000000FFFFFFFF00000000FFFFFFFF00000000FFFFFFFF00000000FFFFFFFF) << 32);
// swap 8-byte long pairs
v = ((v >> 64) & 0x0000000000000000FFFFFFFFFFFFFFFF0000000000000000FFFFFFFFFFFFFFFF) |
((v & 0x0000000000000000FFFFFFFFFFFFFFFF0000000000000000FFFFFFFFFFFFFFFF) << 64);
// swap 16-byte long pairs
v = (v >> 128) | (v << 128);
}
/**
* @notice Create a mask with the highest `_len` bits set.
* @param _len The length
* @return mask - The mask
*/
function leftMask(uint8 _len) private pure returns (uint256 mask) {
// ugly. redo without assembly?
assembly {
// solium-disable-previous-line security/no-inline-assembly
mask := sar(
sub(_len, 1),
0x8000000000000000000000000000000000000000000000000000000000000000
)
}
}
/**
* @notice Return the null view.
* @return bytes29 - The null view
*/
function nullView() internal pure returns (bytes29) {
return NULL;
}
/**
* @notice Check if the view is null.
* @return bool - True if the view is null
*/
function isNull(bytes29 memView) internal pure returns (bool) {
return memView == NULL;
}
/**
* @notice Check if the view is not null.
* @return bool - True if the view is not null
*/
function notNull(bytes29 memView) internal pure returns (bool) {
return !isNull(memView);
}
/**
* @notice Check if the view is of a valid type and points to a valid location
* in memory.
* @dev We perform this check by examining solidity's unallocated memory
* pointer and ensuring that the view's upper bound is less than that.
* @param memView The view
* @return ret - True if the view is valid
*/
function isValid(bytes29 memView) internal pure returns (bool ret) {
if (typeOf(memView) == 0xffffffffff) {return false;}
uint256 _end = end(memView);
assembly {
// solhint-disable-previous-line no-inline-assembly
ret := iszero(gt(_end, mload(0x40)))
}
}
/**
* @notice Require that a typed memory view be valid.
* @dev Returns the view for easy chaining.
* @param memView The view
* @return bytes29 - The validated view
*/
function assertValid(bytes29 memView) internal pure returns (bytes29) {
require(isValid(memView), "Validity assertion failed");
return memView;
}
/**
* @notice Return true if the memview is of the expected type. Otherwise false.
* @param memView The view
* @param _expected The expected type
* @return bool - True if the memview is of the expected type
*/
function isType(bytes29 memView, uint40 _expected) internal pure returns (bool) {
return typeOf(memView) == _expected;
}
/**
* @notice Require that a typed memory view has a specific type.
* @dev Returns the view for easy chaining.
* @param memView The view
* @param _expected The expected type
* @return bytes29 - The view with validated type
*/
function assertType(bytes29 memView, uint40 _expected) internal pure returns (bytes29) {
if (!isType(memView, _expected)) {
(, uint256 g) = encodeHex(uint256(typeOf(memView)));
(, uint256 e) = encodeHex(uint256(_expected));
string memory err = string(
abi.encodePacked(
"Type assertion failed. Got 0x",
uint80(g),
". Expected 0x",
uint80(e)
)
);
revert(err);
}
return memView;
}
/**
* @notice Return an identical view with a different type.
* @param memView The view
* @param _newType The new type
* @return newView - The new view with the specified type
*/
function castTo(bytes29 memView, uint40 _newType) internal pure returns (bytes29 newView) {
// then | in the new type
uint256 _typeShift = SHIFT_TO_TYPE;
uint256 _typeBits = 40;
assembly {
// solium-disable-previous-line security/no-inline-assembly
// shift off the top 5 bytes
newView := or(newView, shr(_typeBits, shl(_typeBits, memView)))
newView := or(newView, shl(_typeShift, _newType))
}
}
/**
* @notice Unsafe raw pointer construction. This should generally not be called
* directly. Prefer `ref` wherever possible.
* @dev Unsafe raw pointer construction. This should generally not be called
* directly. Prefer `ref` wherever possible.
* @param _type The type
* @param _loc The memory address
* @param _len The length
* @return newView - The new view with the specified type, location and length
*/
function unsafeBuildUnchecked(uint256 _type, uint256 _loc, uint256 _len) private pure returns (bytes29 newView) {
uint256 _uint96Bits = 96;
uint256 _emptyBits = 24;
assembly {
// solium-disable-previous-line security/no-inline-assembly
newView := shl(_uint96Bits, or(newView, _type)) // insert type
newView := shl(_uint96Bits, or(newView, _loc)) // insert loc
newView := shl(_emptyBits, or(newView, _len)) // empty bottom 3 bytes
}
}
/**
* @notice Instantiate a new memory view. This should generally not be called
* directly. Prefer `ref` wherever possible.
* @dev Instantiate a new memory view. This should generally not be called
* directly. Prefer `ref` wherever possible.
* @param _type The type
* @param _loc The memory address
* @param _len The length
* @return newView - The new view with the specified type, location and length
*/
function build(uint256 _type, uint256 _loc, uint256 _len) internal pure returns (bytes29 newView) {
uint256 _end = _loc.add(_len);
assembly {
// solium-disable-previous-line security/no-inline-assembly
if gt(_end, mload(0x40)) {
_end := 0
}
}
if (_end == 0) {
return NULL;
}
newView = unsafeBuildUnchecked(_type, _loc, _len);
}
/**
* @notice Instantiate a memory view from a byte array.
* @dev Note that due to Solidity memory representation, it is not possible to
* implement a deref, as the `bytes` type stores its len in memory.
* @param arr The byte array
* @param newType The type
* @return bytes29 - The memory view
*/
function ref(bytes memory arr, uint40 newType) internal pure returns (bytes29) {
uint256 _len = arr.length;
uint256 _loc;
assembly {
// solium-disable-previous-line security/no-inline-assembly
_loc := add(arr, 0x20) // our view is of the data, not the struct
}
return build(newType, _loc, _len);
}
/**
* @notice Return the associated type information.
* @param memView The memory view
* @return _type - The type associated with the view
*/
function typeOf(bytes29 memView) internal pure returns (uint40 _type) {
uint256 _shift = SHIFT_TO_TYPE;
assembly {
// solium-disable-previous-line security/no-inline-assembly
_type := shr(_shift, memView) // shift out lower 27 bytes
}
}
/**
* @notice Optimized type comparison. Checks that the 5-byte type flag is equal.
* @param left The first view
* @param right The second view
* @return bool - True if the 5-byte type flag is equal
*/
function sameType(bytes29 left, bytes29 right) internal pure returns (bool) {
return (left ^ right) >> SHIFT_TO_TYPE == 0;
}
/**
* @notice Return the memory address of the underlying bytes.
* @param memView The view
* @return _loc - The memory address
*/
function loc(bytes29 memView) internal pure returns (uint96 _loc) {
uint256 _mask = LOW_12_MASK; // assembly can't use globals
uint256 _shift = SHIFT_TO_LOC;
assembly {
// solium-disable-previous-line security/no-inline-assembly
_loc := and(shr(_shift, memView), _mask)
}
}
/**
* @notice The number of memory words this memory view occupies, rounded up.
* @param memView The view
* @return uint256 - The number of memory words
*/
function words(bytes29 memView) internal pure returns (uint256) {
return uint256(len(memView)).add(31) / 32;
}
/**
* @notice The in-memory footprint of a fresh copy of the view.
* @param memView The view
* @return uint256 - The in-memory footprint of a fresh copy of the view.
*/
function footprint(bytes29 memView) internal pure returns (uint256) {
return words(memView) * 32;
}
/**
* @notice The number of bytes of the view.
* @param memView The view
* @return _len - The length of the view
*/
function len(bytes29 memView) internal pure returns (uint96 _len) {
uint256 _mask = LOW_12_MASK; // assembly can't use globals
uint256 _emptyBits = 24;
assembly {
// solium-disable-previous-line security/no-inline-assembly
_len := and(shr(_emptyBits, memView), _mask)
}
}
/**
* @notice Returns the endpoint of `memView`.
* @param memView The view
* @return uint256 - The endpoint of `memView`
*/
function end(bytes29 memView) internal pure returns (uint256) {
return loc(memView) + len(memView);
}
/**
* @notice Safe slicing without memory modification.
* @param memView The view
* @param _index The start index
* @param _len The length
* @param newType The new type
* @return bytes29 - The new view
*/
function slice(bytes29 memView, uint256 _index, uint256 _len, uint40 newType) internal pure returns (bytes29) {
uint256 _loc = loc(memView);
// Ensure it doesn't overrun the view
if (_loc.add(_index).add(_len) > end(memView)) {
return NULL;
}
_loc = _loc.add(_index);
return build(newType, _loc, _len);
}
/**
* @notice Shortcut to `slice`. Gets a view representing the first `_len` bytes.
* @param memView The view
* @param _len The length
* @param newType The new type
* @return bytes29 - The new view
*/
function prefix(bytes29 memView, uint256 _len, uint40 newType) internal pure returns (bytes29) {
return slice(memView, 0, _len, newType);
}
/**
* @notice Shortcut to `slice`. Gets a view representing the last `_len` byte.
* @param memView The view
* @param _len The length
* @param newType The new type
* @return bytes29 - The new view
*/
function postfix(bytes29 memView, uint256 _len, uint40 newType) internal pure returns (bytes29) {
return slice(memView, uint256(len(memView)).sub(_len), _len, newType);
}
/**
* @notice Construct an error message for an indexing overrun.
* @param _loc The memory address
* @param _len The length
* @param _index The index
* @param _slice The slice where the overrun occurred
* @return err - The err
*/
function indexErrOverrun(
uint256 _loc,
uint256 _len,
uint256 _index,
uint256 _slice
) internal pure returns (string memory err) {
(, uint256 a) = encodeHex(_loc);
(, uint256 b) = encodeHex(_len);
(, uint256 c) = encodeHex(_index);
(, uint256 d) = encodeHex(_slice);
err = string(
abi.encodePacked(
"TypedMemView/index - Overran the view. Slice is at 0x",
uint48(a),
" with length 0x",
uint48(b),
". Attempted to index at offset 0x",
uint48(c),
" with length 0x",
uint48(d),
"."
)
);
}
/**
* @notice Load up to 32 bytes from the view onto the stack.
* @dev Returns a bytes32 with only the `_bytes` highest bytes set.
* This can be immediately cast to a smaller fixed-length byte array.
* To automatically cast to an integer, use `indexUint`.
* @param memView The view
* @param _index The index
* @param _bytes The bytes
* @return result - The 32 byte result
*/
function index(bytes29 memView, uint256 _index, uint8 _bytes) internal pure returns (bytes32 result) {
if (_bytes == 0) {return bytes32(0);}
if (_index.add(_bytes) > len(memView)) {
revert(indexErrOverrun(loc(memView), len(memView), _index, uint256(_bytes)));
}
require(_bytes <= 32, "TypedMemView/index - Attempted to index more than 32 bytes");
uint8 bitLength = _bytes * 8;
uint256 _loc = loc(memView);
uint256 _mask = leftMask(bitLength);
assembly {
// solium-disable-previous-line security/no-inline-assembly
result := and(mload(add(_loc, _index)), _mask)
}
}
/**
* @notice Parse an unsigned integer from the view at `_index`.
* @dev Requires that the view have >= `_bytes` bytes following that index.
* @param memView The view
* @param _index The index
* @param _bytes The bytes
* @return result - The unsigned integer
*/
function indexUint(bytes29 memView, uint256 _index, uint8 _bytes) internal pure returns (uint256 result) {
return uint256(index(memView, _index, _bytes)) >> ((32 - _bytes) * 8);
}
/**
* @notice Parse an unsigned integer from LE bytes.
* @param memView The view
* @param _index The index
* @param _bytes The bytes
* @return result - The unsigned integer
*/
function indexLEUint(bytes29 memView, uint256 _index, uint8 _bytes) internal pure returns (uint256 result) {
return reverseUint256(uint256(index(memView, _index, _bytes)));
}
/**
* @notice Parse an address from the view at `_index`. Requires that the view have >= 20 bytes
* following that index.
* @param memView The view
* @param _index The index
* @return address - The address
*/
function indexAddress(bytes29 memView, uint256 _index) internal pure returns (address) {
return address(uint160(indexUint(memView, _index, 20)));
}
/**
* @notice Return the keccak256 hash of the underlying memory
* @param memView The view
* @return digest - The keccak256 hash of the underlying memory
*/
function keccak(bytes29 memView) internal pure returns (bytes32 digest) {
uint256 _loc = loc(memView);
uint256 _len = len(memView);
assembly {
// solium-disable-previous-line security/no-inline-assembly
digest := keccak256(_loc, _len)
}
}
/**
* @notice Return the sha2 digest of the underlying memory.
* @dev We explicitly deallocate memory afterwards.
* @param memView The view
* @return digest - The sha2 hash of the underlying memory
*/
function sha2(bytes29 memView) internal view returns (bytes32 digest) {
uint256 _loc = loc(memView);
uint256 _len = len(memView);
bool res;
assembly {
// solium-disable-previous-line security/no-inline-assembly
let ptr := mload(0x40)
res := staticcall(gas(), 2, _loc, _len, ptr, 0x20) // sha2 #1
digest := mload(ptr)
}
require(res, "sha2 OOG");
}
/**
* @notice Implements bitcoin's hash160 (rmd160(sha2()))
* @param memView The pre-image
* @return digest - the Digest
*/
function hash160(bytes29 memView) internal view returns (bytes20 digest) {
uint256 _loc = loc(memView);
uint256 _len = len(memView);
bool res;
assembly {
// solium-disable-previous-line security/no-inline-assembly
let ptr := mload(0x40)
res := staticcall(gas(), 2, _loc, _len, ptr, 0x20) // sha2
res := and(res, staticcall(gas(), 3, ptr, 0x20, ptr, 0x20)) // rmd160
digest := mload(add(ptr, 0xc)) // return value is 0-prefixed.
}
require(res, "hash160 OOG");
}
/**
* @notice Implements bitcoin's hash256 (double sha2)
* @param memView A view of the preimage
* @return digest - the Digest
*/
function hash256(bytes29 memView) internal view returns (bytes32 digest) {
uint256 _loc = loc(memView);
uint256 _len = len(memView);
bool res;
assembly {
// solium-disable-previous-line security/no-inline-assembly
let ptr := mload(0x40)
res := staticcall(gas(), 2, _loc, _len, ptr, 0x20) // sha2 #1
res := and(res, staticcall(gas(), 2, ptr, 0x20, ptr, 0x20)) // sha2 #2
digest := mload(ptr)
}
require(res, "hash256 OOG");
}
/**
* @notice Return true if the underlying memory is equal. Else false.
* @param left The first view
* @param right The second view
* @return bool - True if the underlying memory is equal
*/
function untypedEqual(bytes29 left, bytes29 right) internal pure returns (bool) {
return (loc(left) == loc(right) && len(left) == len(right)) || keccak(left) == keccak(right);
}
/**
* @notice Return false if the underlying memory is equal. Else true.
* @param left The first view
* @param right The second view
* @return bool - False if the underlying memory is equal
*/
function untypedNotEqual(bytes29 left, bytes29 right) internal pure returns (bool) {
return !untypedEqual(left, right);
}
/**
* @notice Compares type equality.
* @dev Shortcuts if the pointers are identical, otherwise compares type and digest.
* @param left The first view
* @param right The second view
* @return bool - True if the types are the same
*/
function equal(bytes29 left, bytes29 right) internal pure returns (bool) {
return left == right || (typeOf(left) == typeOf(right) && keccak(left) == keccak(right));
}
/**
* @notice Compares type inequality.
* @dev Shortcuts if the pointers are identical, otherwise compares type and digest.
* @param left The first view
* @param right The second view
* @return bool - True if the types are not the same
*/
function notEqual(bytes29 left, bytes29 right) internal pure returns (bool) {
return !equal(left, right);
}
/**
* @notice Copy the view to a location, return an unsafe memory reference
* @dev Super Dangerous direct memory access.
*
* This reference can be overwritten if anything else modifies memory (!!!).
* As such it MUST be consumed IMMEDIATELY.
* This function is private to prevent unsafe usage by callers.
* @param memView The view
* @param _newLoc The new location
* @return written - the unsafe memory reference
*/
function unsafeCopyTo(bytes29 memView, uint256 _newLoc) private view returns (bytes29 written) {
require(notNull(memView), "TypedMemView/copyTo - Null pointer deref");
require(isValid(memView), "TypedMemView/copyTo - Invalid pointer deref");
uint256 _len = len(memView);
uint256 _oldLoc = loc(memView);
uint256 ptr;
bool res;
assembly {
// solium-disable-previous-line security/no-inline-assembly
ptr := mload(0x40)
// revert if we're writing in occupied memory
if gt(ptr, _newLoc) {
revert(0x60, 0x20) // empty revert message
}
// use the identity precompile to copy
res := staticcall(gas(), 4, _oldLoc, _len, _newLoc, _len)
}
require(res, "identity OOG");
written = unsafeBuildUnchecked(typeOf(memView), _newLoc, _len);
}
/**
* @notice Copies the referenced memory to a new loc in memory, returning a `bytes` pointing to
* the new memory
* @dev Shortcuts if the pointers are identical, otherwise compares type and digest.
* @param memView The view
* @return ret - The view pointing to the new memory
*/
function clone(bytes29 memView) internal view returns (bytes memory ret) {
uint256 ptr;
uint256 _len = len(memView);
assembly {
// solium-disable-previous-line security/no-inline-assembly
ptr := mload(0x40) // load unused memory pointer
ret := ptr
}
unsafeCopyTo(memView, ptr + 0x20);
assembly {
// solium-disable-previous-line security/no-inline-assembly
mstore(0x40, add(add(ptr, _len), 0x20)) // write new unused pointer
mstore(ptr, _len) // write len of new array (in bytes)
}
}
/**
* @notice Join the views in memory, return an unsafe reference to the memory.
* @dev Super Dangerous direct memory access.
*
* This reference can be overwritten if anything else modifies memory (!!!).
* As such it MUST be consumed IMMEDIATELY.
* This function is private to prevent unsafe usage by callers.
* @param memViews The views
* @param _location The location in memory to which to copy & concatenate
* @return unsafeView - The conjoined view pointing to the new memory
*/
function unsafeJoin(bytes29[] memory memViews, uint256 _location) private view returns (bytes29 unsafeView) {
assembly {
// solium-disable-previous-line security/no-inline-assembly
let ptr := mload(0x40)
// revert if we're writing in occupied memory
if gt(ptr, _location) {
revert(0x60, 0x20) // empty revert message
}
}
uint256 _offset = 0;
for (uint256 i = 0; i < memViews.length; i ++) {
bytes29 memView = memViews[i];
unsafeCopyTo(memView, _location + _offset);
_offset += len(memView);
}
unsafeView = unsafeBuildUnchecked(0, _location, _offset);
}
/**
* @notice Produce the keccak256 digest of the concatenated contents of multiple views.
* @param memViews The views
* @return bytes32 - The keccak256 digest
*/
function joinKeccak(bytes29[] memory memViews) internal view returns (bytes32) {
uint256 ptr;
assembly {
// solium-disable-previous-line security/no-inline-assembly
ptr := mload(0x40) // load unused memory pointer
}
return keccak(unsafeJoin(memViews, ptr));
}
/**
* @notice Produce the sha256 digest of the concatenated contents of multiple views.
* @param memViews The views
* @return bytes32 - The sha256 digest
*/
function joinSha2(bytes29[] memory memViews) internal view returns (bytes32) {
uint256 ptr;
assembly {
// solium-disable-previous-line security/no-inline-assembly
ptr := mload(0x40) // load unused memory pointer
}
return sha2(unsafeJoin(memViews, ptr));
}
/**
* @notice copies all views, joins them into a new bytearray.
* @param memViews The views
* @return ret - The new byte array
*/
function join(bytes29[] memory memViews) internal view returns (bytes memory ret) {
uint256 ptr;
assembly {
// solium-disable-previous-line security/no-inline-assembly
ptr := mload(0x40) // load unused memory pointer
}
bytes29 _newView = unsafeJoin(memViews, ptr + 0x20);
uint256 _written = len(_newView);
uint256 _footprint = footprint(_newView);
assembly {
// solium-disable-previous-line security/no-inline-assembly
// store the legnth
mstore(ptr, _written)
// new pointer is old + 0x20 + the footprint of the body
mstore(0x40, add(add(ptr, _footprint), 0x20))
ret := ptr
}
}
}/*
* Copyright 2025 Circle Internet Group, Inc. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
pragma solidity 0.7.6;
import {TypedMemView} from "@memview-sol/contracts/TypedMemView.sol";
/**
* @title CrossChainWithdrawalHookData Library
* @notice Library for parsing and building CrossChainWithdrawal hook data
*
* @dev The user provided hook data is expected to follow the following format:
* - bytes24 - Magic bytes "cctp-forward" (optional - set to 0 to opt out of CCTP cross-chain withdrawal forwarding.)
* - any custom protocol-specific data
*
* @dev The final hook data format that will be included in the CCTP message payload hook data follows the following format:
* Bytes 0-23: bytes24 - Magic bytes "cctp-forward" or 0 if not forwarding
* Bytes 24-27: uint32 - CrossChainWithdrawal Hook Data Version ID (0)
* Bytes 28-31: uint32 - Length of CrossChainWithdrawal Hook Data (20 bytes for EVM address + 8 bytes for nonce + length of the data field)
* Bytes 32-51: address - from address
* Bytes 52-59: uint64 - HyperCore nonce (8 bytes)
* Bytes 60+: bytes - the user provided hook data
*/
library CrossChainWithdrawalHookData {
using TypedMemView for bytes29;
uint8 private constant HOOK_MAGIC_BYTES_INDEX = 0;
uint8 private constant HOOK_MAGIC_BYTES_LENGTH = 24;
uint32 private constant HOOK_VERSION = 0;
bytes24 private constant HOOK_MAGIC_BYTES = bytes24("cctp-forward");
uint8 private constant HOOK_EVM_ADDRESS_LENGTH = 20;
uint8 private constant HOOK_NONCE_LENGTH = 8;
/**
* @notice Get magic bytes from hook data.
* @dev Gets the magic bytes from bytes 0-23 of hook data.
* @param hookData Hook data
* @return bytes24 Magic bytes
*/
function _getMagicBytes(bytes29 hookData) internal pure returns (bytes24) {
return bytes24(hookData.index(HOOK_MAGIC_BYTES_INDEX, HOOK_MAGIC_BYTES_LENGTH));
}
/**
* @notice Checks if the data has the forwarding magic bytes.
* @param data The user provided hook data
* @return True if the data has forwarding magic bytes, false otherwise.
*/
function _hasForwardingMagicBytes(bytes29 data) internal pure returns (bool) {
if (data.len() < HOOK_MAGIC_BYTES_LENGTH) return false;
return _getMagicBytes(data) == HOOK_MAGIC_BYTES;
}
/**
* @notice Reverts if hook data is malformed
* @param data The hook data as bytes29
*/
function _validateHookData(bytes29 data) internal pure {
require(data.isValid(), "Malformed hook data");
}
/**
* @notice Builds the CCTP message payload hook data.
* @dev If shouldForward is true, the hook data is built with the magic bytes and the data.
* @dev If shouldForward is false, the hook data is built with the magic bytes set to 0.
* @dev The hook data is built with the following format:
* - bytes24 - Magic bytes "cctp-forward" (optional - set to 0 to opt out of CCTP cross-chain withdrawal forwarding.)
* - uint32 - CrossChainWithdrawal Hook Data Version ID (0)
* - uint32 - Length of CrossChainWithdrawal Hook Data (20 bytes for EVM address + 8 bytes for nonce + length of the data field)
* - address - from address
* - uint64 - HyperCore nonce
* - bytes - the user provided hook data
* @param shouldForward True if cross-chain forwarding should be performed, false otherwise.
* @param from The address from which the cross-chain withdrawal is being made.
* @param nonce The HyperCore transaction nonce.
* @param data The user provided hook data.
* @return bytes The built CCTP message payload hook data.
*/
function _build(bool shouldForward, address from, uint64 nonce, bytes calldata data)
internal
pure
returns (bytes memory)
{
bytes24 magic = shouldForward ? HOOK_MAGIC_BYTES : bytes24(0);
return abi.encodePacked(magic, HOOK_VERSION, uint32(data.length + HOOK_EVM_ADDRESS_LENGTH + HOOK_NONCE_LENGTH), from, nonce, data);
}
}/*
* Copyright 2025 Circle Internet Group, Inc. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
pragma solidity 0.7.6;
/**
* @title IForwardDepositReceiver
* @notice Interface for a contract that can receive deposits from the CCTP Forwarder
*/
interface IForwardDepositReceiver {
/**
* @notice Deposit tokens for a recipient
* @param recipient Recipient of the deposit
* @param amount Amount of tokens to deposit
* @param destinationId Forwarding-address-specific id used in conjunction with
* recipient to route the deposit to a specific location.
*/
function depositFor(
address recipient,
uint256 amount,
uint32 destinationId
) external;
}/*
* Copyright (c) 2022, Circle Internet Financial Limited.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
pragma solidity 0.7.6;
import "./Ownable.sol";
/**
* @dev forked from https://github.com/OpenZeppelin/openzeppelin-contracts/blob/7c5f6bc2c8743d83443fa46395d75f2f3f99054a/contracts/access/Ownable2Step.sol
* Modifications:
* 1. Update Solidity version from 0.8.0 to 0.7.6. Version 0.8.0 was used
* as base because this contract was added to OZ repo after version 0.8.0.
*
* Contract module which provides access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership} and {acceptOwnership}.
*
* This module is used through inheritance. It will make available all functions
* from parent (Ownable).
*/
abstract contract Ownable2Step is Ownable {
address private _pendingOwner;
event OwnershipTransferStarted(
address indexed previousOwner,
address indexed newOwner
);
/**
* @dev Returns the address of the pending owner.
*/
function pendingOwner() public view virtual returns (address) {
return _pendingOwner;
}
/**
* @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner)
public
virtual
override
onlyOwner
{
_pendingOwner = newOwner;
emit OwnershipTransferStarted(owner(), newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual override {
delete _pendingOwner;
super._transferOwnership(newOwner);
}
/**
* @dev The new owner accepts the ownership transfer.
*/
function acceptOwnership() external {
address sender = _msgSender();
require(
pendingOwner() == sender,
"Ownable2Step: caller is not the new owner"
);
_transferOwnership(sender);
}
}// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
import "./IERC20.sol";
import "../../math/SafeMath.sol";
import "../../utils/Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using SafeMath for uint256;
using Address for address;
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
/**
* @dev Deprecated. This function has issues similar to the ones found in
* {IERC20-approve}, and its usage is discouraged.
*
* Whenever possible, use {safeIncreaseAllowance} and
* {safeDecreaseAllowance} instead.
*/
function safeApprove(IERC20 token, address spender, uint256 value) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
// solhint-disable-next-line max-line-length
require((value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 newAllowance = token.allowance(address(this), spender).add(value);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero");
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
if (returndata.length > 0) { // Return data is optional
// solhint-disable-next-line max-line-length
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
}// SPDX-License-Identifier: MIT
pragma solidity >=0.6.2 <0.8.0;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
// solhint-disable-next-line no-inline-assembly
assembly { size := extcodesize(account) }
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: value }(data);
return _verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.staticcall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.delegatecall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}/*
* Copyright 2025 Circle Internet Group, Inc. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
pragma solidity 0.7.6;
/**
* @title EIP3009: Transfer with Authorization
* @dev https://eips.ethereum.org/EIPS/eip-3009
*/
interface IEIP3009Token {
/**
* @notice Emitted when an authorization is used
* @param authorizer Authorizer's address
* @param nonce Nonce of the authorization
*/
event AuthorizationUsed(address indexed authorizer, bytes32 indexed nonce);
/**
* @notice Receive a transfer with a signed authorization from the payer
* @dev This has an additional check to ensure that the payee's address matches
* the caller of this function to prevent front-running attacks. (See security
* considerations)
* @param from Payer's address (Authorizer)
* @param to Payee's address
* @param value Amount to be transferred
* @param validAfter The time after which this is valid (unix time)
* @param validBefore The time before which this is valid (unix time)
* @param nonce Unique nonce
* @param v v of the signature
* @param r r of the signature
* @param s s of the signature
*/
function receiveWithAuthorization(
address from,
address to,
uint256 value,
uint256 validAfter,
uint256 validBefore,
bytes32 nonce,
uint8 v,
bytes32 r,
bytes32 s
) external;
}// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
/**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/
library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
/**
* @dev Returns the substraction of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
if (b > a) return (false, 0);
return (true, a - b);
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
if (b == 0) return (false, 0);
return (true, a / b);
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
if (b == 0) return (false, 0);
return (true, a % b);
}
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
require(b <= a, "SafeMath: subtraction overflow");
return a - b;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) return 0;
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers, reverting on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
require(b > 0, "SafeMath: division by zero");
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
require(b > 0, "SafeMath: modulo by zero");
return a % b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {trySub}.
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
return a - b;
}
/**
* @dev Returns the integer division of two unsigned integers, reverting with custom message on
* division by zero. The result is rounded towards zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryDiv}.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting with custom message when dividing by zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryMod}.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
return a % b;
}
}/*
* Copyright 2024 Circle Internet Group, Inc. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
pragma solidity 0.7.6;
import {ITokenMinterV2} from "../interfaces/v2/ITokenMinterV2.sol";
import {Rescuable} from "../roles/Rescuable.sol";
import {Denylistable} from "../roles/v2/Denylistable.sol";
import {IMintBurnToken} from "../interfaces/IMintBurnToken.sol";
import {Initializable} from "../proxy/Initializable.sol";
/**
* @title BaseTokenMessenger
* @notice Base administrative functionality for TokenMessenger implementations,
* including managing remote token messengers and the local token minter.
*/
abstract contract BaseTokenMessenger is Rescuable, Denylistable, Initializable {
// ============ Events ============
/**
* @notice Emitted when a remote TokenMessenger is added
* @param domain remote domain
* @param tokenMessenger TokenMessenger on remote domain
*/
event RemoteTokenMessengerAdded(uint32 domain, bytes32 tokenMessenger);
/**
* @notice Emitted when a remote TokenMessenger is removed
* @param domain remote domain
* @param tokenMessenger TokenMessenger on remote domain
*/
event RemoteTokenMessengerRemoved(uint32 domain, bytes32 tokenMessenger);
/**
* @notice Emitted when the local minter is added
* @param localMinter address of local minter
*/
event LocalMinterAdded(address localMinter);
/**
* @notice Emitted when the local minter is removed
* @param localMinter address of local minter
*/
event LocalMinterRemoved(address localMinter);
/**
* @notice Emitted when the fee recipient is set
* @param feeRecipient address of fee recipient set
*/
event FeeRecipientSet(address feeRecipient);
/**
* @notice Emitted when the minimum fee controller is set
* @param minFeeController address of minimum fee controller
*/
event MinFeeControllerSet(address minFeeController);
/**
* @notice Emitted when the minimum fee is set
* @param minFee minimum fee
*/
event MinFeeSet(uint256 minFee);
/**
* @notice Emitted when tokens are minted
* @param mintRecipient recipient address of minted tokens
* @param amount amount of minted tokens received by `mintRecipient`
* @param mintToken contract address of minted token
* @param feeCollected fee collected for mint
*/
event MintAndWithdraw(
address indexed mintRecipient,
uint256 amount,
address indexed mintToken,
uint256 feeCollected
);
// ============ State Variables ============
// Local Message Transmitter responsible for sending and receiving messages to/from remote domains
address public immutable localMessageTransmitter;
// Version of message body format
uint32 public immutable messageBodyVersion;
// Minter responsible for minting and burning tokens on the local domain
ITokenMinterV2 public localMinter;
// Valid TokenMessengers on remote domains
mapping(uint32 => bytes32) public remoteTokenMessengers;
// Address to receive collected fees
address public feeRecipient;
// Minimum fee controller address
address public minFeeController;
// Minimum fee for all transfers in 1/1000 basis points
uint256 public minFee;
// Minimum fee multiplier to support 1/1000 basis point precision
uint256 public constant MIN_FEE_MULTIPLIER = 10_000_000;
// ============ Modifiers ============
/**
* @notice Only accept messages from a registered TokenMessenger contract on given remote domain
* @param domain The remote domain
* @param tokenMessenger The address of the TokenMessenger contract for the given remote domain
*/
modifier onlyRemoteTokenMessenger(uint32 domain, bytes32 tokenMessenger) {
require(
_isRemoteTokenMessenger(domain, tokenMessenger),
"Remote TokenMessenger unsupported"
);
_;
}
/**
* @notice Only accept messages from the registered message transmitter on local domain
*/
modifier onlyLocalMessageTransmitter() {
// Caller must be the registered message transmitter for this domain
require(_isLocalMessageTransmitter(), "Invalid message transmitter");
_;
}
/**
* @notice Reverts if called by any account other than the min fee controller
*/
modifier onlyMinFeeController() {
require(
msg.sender == minFeeController,
"Caller is not the min fee controller"
);
_;
}
// ============ Constructor ============
/**
* @param _messageTransmitter Message transmitter address
* @param _messageBodyVersion Message body version
*/
constructor(address _messageTransmitter, uint32 _messageBodyVersion) {
require(
_messageTransmitter != address(0),
"MessageTransmitter not set"
);
localMessageTransmitter = _messageTransmitter;
messageBodyVersion = _messageBodyVersion;
}
// ============ External Functions ============
/**
* @notice Add the TokenMessenger for a remote domain.
* @dev Reverts if there is already a TokenMessenger set for domain.
* @param domain Domain of remote TokenMessenger.
* @param tokenMessenger Address of remote TokenMessenger as bytes32.
*/
function addRemoteTokenMessenger(
uint32 domain,
bytes32 tokenMessenger
) external onlyOwner {
_addRemoteTokenMessenger(domain, tokenMessenger);
}
/**
* @notice Remove the TokenMessenger for a remote domain.
* @dev Reverts if there is no TokenMessenger set for `domain`.
* @param domain Domain of remote TokenMessenger
*/
function removeRemoteTokenMessenger(uint32 domain) external onlyOwner {
// No TokenMessenger set for given remote domain.
require(
remoteTokenMessengers[domain] != bytes32(0),
"No TokenMessenger set"
);
bytes32 _removedTokenMessenger = remoteTokenMessengers[domain];
delete remoteTokenMessengers[domain];
emit RemoteTokenMessengerRemoved(domain, _removedTokenMessenger);
}
/**
* @notice Add minter for the local domain.
* @dev Reverts if a minter is already set for the local domain.
* @param newLocalMinter The address of the minter on the local domain.
*/
function addLocalMinter(address newLocalMinter) external onlyOwner {
_setLocalMinter(newLocalMinter);
}
/**
* @notice Remove the minter for the local domain.
* @dev Reverts if the minter of the local domain is not set.
*/
function removeLocalMinter() external onlyOwner {
address _localMinterAddress = address(localMinter);
require(_localMinterAddress != address(0), "No local minter is set.");
delete localMinter;
emit LocalMinterRemoved(_localMinterAddress);
}
/**
* @notice Sets the fee recipient address
* @dev Reverts if not called by the owner
* @dev Reverts if `_feeRecipient` is the zero address
* @param _feeRecipient Address of fee recipient
*/
function setFeeRecipient(address _feeRecipient) external onlyOwner {
_setFeeRecipient(_feeRecipient);
}
/**
* @notice Sets the minimum fee controller address
* @dev Reverts if not called by the owner
* @dev Reverts if `_minFeeController` is the zero address
* @param _minFeeController Address of minimum fee controller
*/
function setMinFeeController(address _minFeeController) external onlyOwner {
_setMinFeeController(_minFeeController);
}
/**
* @notice Sets the minimum fee for all transfers in 1/1000 basis points
* @dev Reverts if not called by the min fee controller
* @dev Reverts if the minimum fee is equal to or greater than MIN_FEE_MULTIPLIER
* @param _minFee Minimum fee
*/
function setMinFee(uint256 _minFee) external onlyMinFeeController {
_setMinFee(_minFee);
}
/**
* @notice Returns the current initialized version
*/
function initializedVersion() external view returns (uint64) {
return _getInitializedVersion();
}
// ============ Internal Utils ============
/**
* @notice return the remote TokenMessenger for the given `_domain` if one exists, else revert.
* @param _domain The domain for which to get the remote TokenMessenger
* @return _tokenMessenger The address of the TokenMessenger on `_domain` as bytes32
*/
function _getRemoteTokenMessenger(
uint32 _domain
) internal view returns (bytes32) {
bytes32 _tokenMessenger = remoteTokenMessengers[_domain];
require(_tokenMessenger != bytes32(0), "No TokenMessenger for domain");
return _tokenMessenger;
}
/**
* @notice return the local minter address if it is set, else revert.
* @return local minter as ITokenMinter.
*/
function _getLocalMinter() internal view returns (ITokenMinterV2) {
require(address(localMinter) != address(0), "Local minter is not set");
return localMinter;
}
/**
* @notice Return true if the given remote domain and TokenMessenger is registered
* on this TokenMessenger.
* @param _domain The remote domain of the message.
* @param _tokenMessenger The address of the TokenMessenger on remote domain.
* @return true if a remote TokenMessenger is registered for `_domain` and `_tokenMessenger`,
* on this TokenMessenger.
*/
function _isRemoteTokenMessenger(
uint32 _domain,
bytes32 _tokenMessenger
) internal view returns (bool) {
return
_tokenMessenger != bytes32(0) &&
remoteTokenMessengers[_domain] == _tokenMessenger;
}
/**
* @notice Returns true if the message sender is the local registered MessageTransmitter
* @return true if message sender is the registered local message transmitter
*/
function _isLocalMessageTransmitter() internal view returns (bool) {
return msg.sender == localMessageTransmitter;
}
/**
* @notice Deposits tokens from `_from` address and burns them
* @param _burnToken address of contract to burn deposited tokens, on local domain
* @param _from address depositing the funds
* @param _amount deposit amount
*/
function _depositAndBurn(
address _burnToken,
address _from,
uint256 _amount
) internal {
ITokenMinterV2 _localMinter = _getLocalMinter();
IMintBurnToken _mintBurnToken = IMintBurnToken(_burnToken);
require(
_mintBurnToken.transferFrom(_from, address(_localMinter), _amount),
"Transfer operation failed"
);
_localMinter.burn(_burnToken, _amount);
}
/**
* @notice Mints tokens to a recipient and optionally a fee to the
* currently set fee recipient.
* @param _remoteDomain domain where burned tokens originate from
* @param _burnToken address of token burned
* @param _mintRecipient recipient address of minted tokens
* @param _amount amount of tokens to mint to `_mintRecipient`
* @param _fee fee collected for mint
*/
function _mintAndWithdraw(
uint32 _remoteDomain,
bytes32 _burnToken,
address _mintRecipient,
uint256 _amount,
uint256 _fee
) internal {
ITokenMinterV2 _minter = _getLocalMinter();
address _mintToken;
if (_fee > 0) {
_mintToken = _minter.mint(
_remoteDomain,
_burnToken,
_mintRecipient,
feeRecipient,
_amount,
_fee
);
} else {
_mintToken = _minter.mint(
_remoteDomain,
_burnToken,
_mintRecipient,
_amount
);
}
emit MintAndWithdraw(_mintRecipient, _amount, _mintToken, _fee);
}
/**
* @notice Sets the fee recipient address
* @dev Reverts if `_feeRecipient` is the zero address
* @param _feeRecipient Address of fee recipient
*/
function _setFeeRecipient(address _feeRecipient) internal {
require(_feeRecipient != address(0), "Zero address not allowed");
feeRecipient = _feeRecipient;
emit FeeRecipientSet(_feeRecipient);
}
/**
* @notice Sets the local minter for the local domain.
* @dev Reverts if a minter is already set for the local domain.
* @param _newLocalMinter The address of the minter on the local domain.
*/
function _setLocalMinter(address _newLocalMinter) internal {
require(_newLocalMinter != address(0), "Zero address not allowed");
require(
address(localMinter) == address(0),
"Local minter is already set."
);
localMinter = ITokenMinterV2(_newLocalMinter);
emit LocalMinterAdded(_newLocalMinter);
}
/**
* @notice Sets the minimum fee controller address
* @dev Reverts if `_minFeeController` is the zero address
* @param _minFeeController Address of minimum fee controller
*/
function _setMinFeeController(address _minFeeController) internal {
require(_minFeeController != address(0), "Zero address not allowed");
minFeeController = _minFeeController;
emit MinFeeControllerSet(_minFeeController);
}
/**
* @notice Sets the minimum fee for all transfers
* @dev Reverts if the minimum fee is equal to or greater than MIN_FEE_MULTIPLIER
* @param _minFee Minimum fee
*/
function _setMinFee(uint256 _minFee) internal {
require(_minFee < MIN_FEE_MULTIPLIER, "Min fee too high");
minFee = _minFee;
emit MinFeeSet(_minFee);
}
/**
* @notice Add the TokenMessenger for a remote domain.
* @dev Reverts if there is already a TokenMessenger set for domain.
* @param _domain Domain of remote TokenMessenger.
* @param _tokenMessenger Address of remote TokenMessenger as bytes32.
*/
function _addRemoteTokenMessenger(
uint32 _domain,
bytes32 _tokenMessenger
) internal {
require(_tokenMessenger != bytes32(0), "bytes32(0) not allowed");
require(
remoteTokenMessengers[_domain] == bytes32(0),
"TokenMessenger already set"
);
remoteTokenMessengers[_domain] = _tokenMessenger;
emit RemoteTokenMessengerAdded(_domain, _tokenMessenger);
}
}/*
* Copyright 2024 Circle Internet Group, Inc. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
pragma solidity 0.7.6;
import {ITokenMinter} from "../ITokenMinter.sol";
/**
* @title ITokenMinterV2
* @notice Interface for a minter of tokens that are mintable, burnable, and interchangeable
* across domains.
*/
interface ITokenMinterV2 is ITokenMinter {
/**
* @notice Mints to multiple recipients amounts of tokens corresponding to the
* given (`sourceDomain`, `burnToken`) pair.
* @param sourceDomain Source domain where `burnToken` was burned.
* @param burnToken Burned token address as bytes32.
* @param recipientOne Address to receive `amountOne` of minted tokens
* @param recipientTwo Address to receive `amountTwo` of minted tokens
* @param amountOne Amount of tokens to mint to `recipientOne`
* @param amountTwo Amount of tokens to mint to `recipientTwo`
* @return mintToken Address of the token that was minted, corresponding to the (`sourceDomain`, `burnToken`) pair
*/
function mint(
uint32 sourceDomain,
bytes32 burnToken,
address recipientOne,
address recipientTwo,
uint256 amountOne,
uint256 amountTwo
) external returns (address);
}/*
* Copyright 2024 Circle Internet Group, Inc. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
pragma solidity 0.7.6;
/**
* @title AddressUtils Library
* @notice Helper functions for converting addresses to and from bytes
**/
library AddressUtils {
/**
* @notice Converts an address to bytes32 by left-padding with zeros (alignment preserving cast.)
* @param addr The address to convert to bytes32
*/
function toBytes32(address addr) internal pure returns (bytes32) {
return bytes32(uint256(uint160(addr)));
}
/**
* @notice Converts bytes32 to address (alignment preserving cast.)
* @dev Warning: it is possible to have different input values _buf map to the same address.
* For use cases where this is not acceptable, validate that the first 12 bytes of _buf are zero-padding.
* @param _buf the bytes32 to convert to address
*/
function toAddress(bytes32 _buf) internal pure returns (address) {
return address(uint160(uint256(_buf)));
}
}/*
* Copyright 2024 Circle Internet Group, Inc. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
pragma solidity 0.7.6;
/**
* @title IRelayerV2
* @notice Sends messages from the source domain to the destination domain
*/
interface IRelayerV2 {
/**
* @notice Sends an outgoing message from the source domain.
* @dev Emits a `MessageSent` event with message information.
* WARNING: if the `destinationCaller` does not represent a valid address as bytes32, then it will not be possible
* to broadcast the message on the destination domain. If set to bytes32(0), anyone will be able to broadcast it.
* This is an advanced feature, and using bytes32(0) should be preferred for use cases where a specific destination caller is not required.
* @param destinationDomain Domain of destination chain
* @param recipient Address of message recipient on destination domain as bytes32
* @param destinationCaller Allowed caller on destination domain (see above WARNING).
* @param minFinalityThreshold Minimum finality threshold at which the message must be attested to.
* @param messageBody Content of the message, as raw bytes
*/
function sendMessage(
uint32 destinationDomain,
bytes32 recipient,
bytes32 destinationCaller,
uint32 minFinalityThreshold,
bytes calldata messageBody
) external;
}/*
* Copyright 2024 Circle Internet Group, Inc. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
pragma solidity 0.7.6;
/**
* @title IMessageHandlerV2
* @notice Handles messages on the destination domain, forwarded from
* an IReceiverV2.
*/
interface IMessageHandlerV2 {
/**
* @notice Handles an incoming finalized message from an IReceiverV2
* @dev Finalized messages have finality threshold values greater than or equal to 2000
* @param sourceDomain The source domain of the message
* @param sender The sender of the message
* @param finalityThresholdExecuted the finality threshold at which the message was attested to
* @param messageBody The raw bytes of the message body
* @return success True, if successful; false, if not.
*/
function handleReceiveFinalizedMessage(
uint32 sourceDomain,
bytes32 sender,
uint32 finalityThresholdExecuted,
bytes calldata messageBody
) external returns (bool);
/**
* @notice Handles an incoming unfinalized message from an IReceiverV2
* @dev Unfinalized messages have finality threshold values less than 2000
* @param sourceDomain The source domain of the message
* @param sender The sender of the message
* @param finalityThresholdExecuted The finality threshold at which the message was attested to
* @param messageBody The raw bytes of the message body
* @return success True, if successful; false, if not.
*/
function handleReceiveUnfinalizedMessage(
uint32 sourceDomain,
bytes32 sender,
uint32 finalityThresholdExecuted,
bytes calldata messageBody
) external returns (bool);
}/*
* Copyright 2024 Circle Internet Group, Inc. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
pragma solidity 0.7.6;
import {TypedMemView} from "@memview-sol/contracts/TypedMemView.sol";
import {BurnMessage} from "../BurnMessage.sol";
/**
* @title BurnMessageV2 Library
* @notice Library for formatted V2 BurnMessages used by TokenMessengerV2.
* @dev BurnMessageV2 format:
* Field Bytes Type Index
* version 4 uint32 0
* burnToken 32 bytes32 4
* mintRecipient 32 bytes32 36
* amount 32 uint256 68
* messageSender 32 bytes32 100
* maxFee 32 uint256 132
* feeExecuted 32 uint256 164
* expirationBlock 32 uint256 196
* hookData dynamic bytes 228
* @dev Additions from v1:
* - maxFee
* - feeExecuted
* - expirationBlock
* - hookData
**/
library BurnMessageV2 {
using TypedMemView for bytes;
using TypedMemView for bytes29;
using BurnMessage for bytes29;
// Field indices
uint8 private constant MAX_FEE_INDEX = 132;
uint8 private constant FEE_EXECUTED_INDEX = 164;
uint8 private constant EXPIRATION_BLOCK_INDEX = 196;
uint8 private constant HOOK_DATA_INDEX = 228;
uint256 private constant EMPTY_FEE_EXECUTED = 0;
uint256 private constant EMPTY_EXPIRATION_BLOCK = 0;
/**
* @notice Formats a V2 burn message
* @param _version The message body version
* @param _burnToken The burn token address on the source domain, as bytes32
* @param _mintRecipient The mint recipient address as bytes32
* @param _amount The burn amount
* @param _messageSender The message sender
* @param _maxFee The maximum fee to be paid on destination domain
* @param _hookData Optional hook data for processing on the destination domain
* @return Formatted message bytes.
*/
function _formatMessageForRelay(
uint32 _version,
bytes32 _burnToken,
bytes32 _mintRecipient,
uint256 _amount,
bytes32 _messageSender,
uint256 _maxFee,
bytes calldata _hookData
) internal pure returns (bytes memory) {
return
abi.encodePacked(
_version,
_burnToken,
_mintRecipient,
_amount,
_messageSender,
_maxFee,
EMPTY_FEE_EXECUTED,
EMPTY_EXPIRATION_BLOCK,
_hookData
);
}
// @notice Returns _message's version field
function _getVersion(bytes29 _message) internal pure returns (uint32) {
return _message._getVersion();
}
// @notice Returns _message's burnToken field
function _getBurnToken(bytes29 _message) internal pure returns (bytes32) {
return _message._getBurnToken();
}
// @notice Returns _message's mintRecipient field
function _getMintRecipient(
bytes29 _message
) internal pure returns (bytes32) {
return _message._getMintRecipient();
}
// @notice Returns _message's amount field
function _getAmount(bytes29 _message) internal pure returns (uint256) {
return _message._getAmount();
}
// @notice Returns _message's messageSender field
function _getMessageSender(
bytes29 _message
) internal pure returns (bytes32) {
return _message._getMessageSender();
}
// @notice Returns _message's maxFee field
function _getMaxFee(bytes29 _message) internal pure returns (uint256) {
return _message.indexUint(MAX_FEE_INDEX, 32);
}
// @notice Returns _message's feeExecuted field
function _getFeeExecuted(bytes29 _message) internal pure returns (uint256) {
return _message.indexUint(FEE_EXECUTED_INDEX, 32);
}
// @notice Returns _message's expirationBlock field
function _getExpirationBlock(
bytes29 _message
) internal pure returns (uint256) {
return _message.indexUint(EXPIRATION_BLOCK_INDEX, 32);
}
// @notice Returns _message's hookData field
function _getHookData(bytes29 _message) internal pure returns (bytes29) {
return
_message.slice(
HOOK_DATA_INDEX,
_message.len() - HOOK_DATA_INDEX,
0
);
}
/**
* @notice Reverts if burn message is malformed or invalid length
* @param _message The burn message as bytes29
*/
function _validateBurnMessageFormat(bytes29 _message) internal pure {
require(_message.isValid(), "Malformed message");
require(
_message.len() >= HOOK_DATA_INDEX,
"Invalid burn message: too short"
);
}
}/* * Copyright 2024 Circle Internet Group, Inc. All rights reserved. * * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ pragma solidity 0.7.6; // The threshold at which (and above) messages are considered finalized. uint32 constant FINALITY_THRESHOLD_FINALIZED = 2000; // The threshold at which (and above) messages are considered confirmed. uint32 constant FINALITY_THRESHOLD_CONFIRMED = 1000; // The minimum allowed level of finality accepted by TokenMessenger uint32 constant TOKEN_MESSENGER_MIN_FINALITY_THRESHOLD = 500;
// SPDX-License-Identifier: MIT
pragma solidity >=0.5.10;
/*
The MIT License (MIT)
Copyright (c) 2016 Smart Contract Solutions, Inc.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/
library SafeMath {
/**
* @dev Multiplies two numbers, throws on overflow.
*/
function mul(uint256 _a, uint256 _b) internal pure returns (uint256 c) {
// Gas optimization: this is cheaper than asserting 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
if (_a == 0) {
return 0;
}
c = _a * _b;
require(c / _a == _b, "Overflow during multiplication.");
return c;
}
/**
* @dev Integer division of two numbers, truncating the quotient.
*/
function div(uint256 _a, uint256 _b) internal pure returns (uint256) {
// assert(_b > 0); // Solidity automatically throws when dividing by 0
// uint256 c = _a / _b;
// assert(_a == _b * c + _a % _b); // There is no case in which this doesn't hold
return _a / _b;
}
/**
* @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 _a, uint256 _b) internal pure returns (uint256) {
require(_b <= _a, "Underflow during subtraction.");
return _a - _b;
}
/**
* @dev Adds two numbers, throws on overflow.
*/
function add(uint256 _a, uint256 _b) internal pure returns (uint256 c) {
c = _a + _b;
require(c >= _a, "Overflow during addition.");
return c;
}
}/*
* Copyright (c) 2022, Circle Internet Financial Limited.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
pragma solidity 0.7.6;
import "@openzeppelin/contracts/utils/Context.sol";
/**
* @dev forked from https://github.com/OpenZeppelin/openzeppelin-contracts/blob/7c5f6bc2c8743d83443fa46395d75f2f3f99054a/contracts/access/Ownable.sol
* Modifications:
* 1. Update Solidity version from 0.8.0 to 0.7.6 (11/9/2022). (v8 was used
* as base because it includes internal _transferOwnership method.)
* 2. Remove renounceOwnership function
*
* Description
* Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(
address indexed previousOwner,
address indexed newOwner
);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_transferOwnership(_msgSender());
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(
newOwner != address(0),
"Ownable: new owner is the zero address"
);
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}/*
* Copyright (c) 2022, Circle Internet Financial Limited.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
pragma solidity 0.7.6;
import "./Ownable2Step.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";
/**
* @notice Base contract which allows children to rescue ERC20 locked in their contract.
* @dev Forked from https://github.com/centrehq/centre-tokens/blob/0d3cab14ebd133a83fc834dbd48d0468bdf0b391/contracts/v1.1/Rescuable.sol
* Modifications:
* 1. Update Solidity version from 0.6.12 to 0.7.6 (8/23/2022)
* 2. Add internal _updateRescuer (10/8/2024)
*/
contract Rescuable is Ownable2Step {
using SafeERC20 for IERC20;
address private _rescuer;
event RescuerChanged(address indexed newRescuer);
/**
* @notice Returns current rescuer
* @return Rescuer's address
*/
function rescuer() external view returns (address) {
return _rescuer;
}
/**
* @notice Revert if called by any account other than the rescuer.
*/
modifier onlyRescuer() {
require(msg.sender == _rescuer, "Rescuable: caller is not the rescuer");
_;
}
/**
* @notice Rescue ERC20 tokens locked up in this contract.
* @param tokenContract ERC20 token contract address
* @param to Recipient address
* @param amount Amount to withdraw
*/
function rescueERC20(
IERC20 tokenContract,
address to,
uint256 amount
) external onlyRescuer {
tokenContract.safeTransfer(to, amount);
}
/**
* @notice Assign the rescuer role to a given address.
* @param newRescuer New rescuer's address
*/
function updateRescuer(address newRescuer) external onlyOwner {
_updateRescuer(newRescuer);
}
/**
* @notice Assign the rescuer role to a given address.
* @param newRescuer New rescuer's address
*/
function _updateRescuer(address newRescuer) internal {
require(
newRescuer != address(0),
"Rescuable: new rescuer is the zero address"
);
_rescuer = newRescuer;
emit RescuerChanged(newRescuer);
}
}/*
* Copyright 2024 Circle Internet Group, Inc. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
pragma solidity 0.7.6;
import {Ownable2Step} from "../Ownable2Step.sol";
/**
* @title Denylistable
* @notice Contract that allows the management and application of a denylist
*/
abstract contract Denylistable is Ownable2Step {
// ============ Events ============
/**
* @notice Emitted when the denylister is updated
* @param oldDenylister Address of the previous Denylister
* @param newDenylister Address of the new Denylister
*/
event DenylisterChanged(
address indexed oldDenylister,
address indexed newDenylister
);
/**
* @notice Emitted when `account` is added to the denylist
* @param account Address added to the denylist
*/
event Denylisted(address indexed account);
/**
* @notice Emitted when `account` is removed from the denylist
* @param account Address removed from the denylist
*/
event UnDenylisted(address indexed account);
// ============ Constants ============
// A true boolean representation in uint256
uint256 private constant _TRUE = 1;
// A false boolean representation in uint256
uint256 private constant _FALSE = 0;
// ============ State Variables ============
// The currently set denylister
address internal _denylister;
// A mapping indicating whether an account is on the denylist. 1 indicates that an
// address is on the denylist; 0 otherwise.
mapping(address => uint256) internal _denylist;
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[20] private __gap;
// ============ Modifiers ============
/**
* @dev Throws if called by any account other than the denylister.
*/
modifier onlyDenylister() {
require(
msg.sender == _denylister,
"Denylistable: caller is not denylister"
);
_;
}
/**
* @dev Performs denylist checks on the msg.sender and tx.origin addresses
*/
modifier notDenylistedCallers() {
_requireNotDenylisted(msg.sender);
if (msg.sender != tx.origin) {
_requireNotDenylisted(tx.origin);
}
_;
}
// ============ External Functions ============
/**
* @notice Updates the currently set Denylister
* @dev Reverts if not called by the Owner
* @dev Reverts if the new denylister address is the zero address
* @param newDenylister The new denylister address
*/
function updateDenylister(address newDenylister) external onlyOwner {
_updateDenylister(newDenylister);
}
/**
* @notice Adds an address to the denylist
* @param account Address to add to the denylist
*/
function denylist(address account) external onlyDenylister {
_denylist[account] = _TRUE;
emit Denylisted(account);
}
/**
* @notice Removes an address from the denylist
* @param account Address to remove from the denylist
*/
function unDenylist(address account) external onlyDenylister {
_denylist[account] = _FALSE;
emit UnDenylisted(account);
}
/**
* @notice Returns the currently set Denylister
* @return Denylister address
*/
function denylister() external view returns (address) {
return _denylister;
}
/**
* @notice Returns whether an address is currently on the denylist
* @param account Address to check
* @return True if the account is on the deny list and false if the account is not.
*/
function isDenylisted(address account) external view returns (bool) {
return _denylist[account] == _TRUE;
}
// ============ Internal Utils ============
/**
* @notice Updates the currently set denylister
* @param _newDenylister The new denylister address
*/
function _updateDenylister(address _newDenylister) internal {
require(
_newDenylister != address(0),
"Denylistable: new denylister is the zero address"
);
address _oldDenylister = _denylister;
_denylister = _newDenylister;
emit DenylisterChanged(_oldDenylister, _newDenylister);
}
/**
* @notice Checks an address against the denylist
* @dev Reverts if address is on the denylist
*/
function _requireNotDenylisted(address _address) internal view {
require(
_denylist[_address] == _FALSE,
"Denylistable: account is on denylist"
);
}
}/*
* Copyright (c) 2022, Circle Internet Financial Limited.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
pragma solidity 0.7.6;
import "../../lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol";
/**
* @title IMintBurnToken
* @notice interface for mintable and burnable ERC20 token
*/
interface IMintBurnToken is IERC20 {
/**
* @dev Function to mint tokens
* @param to The address that will receive the minted tokens.
* @param amount The amount of tokens to mint. Must be less than or equal
* to the minterAllowance of the caller.
* @return A boolean that indicates if the operation was successful.
*/
function mint(address to, uint256 amount) external returns (bool);
/**
* @dev allows a minter to burn some of its own tokens
* Validates that caller is a minter and that sender is not blacklisted
* amount is less than or equal to the minter's account balance
* @param amount uint256 the amount of tokens to be burned
*/
function burn(uint256 amount) external;
}/*
* Copyright (c) 2022, Circle Internet Financial Limited.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
pragma solidity 0.7.6;
/**
* @title ITokenMinter
* @notice interface for minter of tokens that are mintable, burnable, and interchangeable
* across domains.
*/
interface ITokenMinter {
/**
* @notice Mints `amount` of local tokens corresponding to the
* given (`sourceDomain`, `burnToken`) pair, to `to` address.
* @dev reverts if the (`sourceDomain`, `burnToken`) pair does not
* map to a nonzero local token address. This mapping can be queried using
* getLocalToken().
* @param sourceDomain Source domain where `burnToken` was burned.
* @param burnToken Burned token address as bytes32.
* @param to Address to receive minted tokens, corresponding to `burnToken`,
* on this domain.
* @param amount Amount of tokens to mint. Must be less than or equal
* to the minterAllowance of this TokenMinter for given `_mintToken`.
* @return mintToken token minted.
*/
function mint(
uint32 sourceDomain,
bytes32 burnToken,
address to,
uint256 amount
) external returns (address mintToken);
/**
* @notice Burn tokens owned by this ITokenMinter.
* @param burnToken burnable token.
* @param amount amount of tokens to burn. Must be less than or equal to this ITokenMinter's
* account balance of the given `_burnToken`.
*/
function burn(address burnToken, uint256 amount) external;
/**
* @notice Get the local token associated with the given remote domain and token.
* @param remoteDomain Remote domain
* @param remoteToken Remote token
* @return local token address
*/
function getLocalToken(uint32 remoteDomain, bytes32 remoteToken)
external
view
returns (address);
/**
* @notice Set the token controller of this ITokenMinter. Token controller
* is responsible for mapping local tokens to remote tokens, and managing
* token-specific limits
* @param newTokenController new token controller address
*/
function setTokenController(address newTokenController) external;
}/*
* Copyright (c) 2022, Circle Internet Financial Limited.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
pragma solidity 0.7.6;
import "@memview-sol/contracts/TypedMemView.sol";
/**
* @title BurnMessage Library
* @notice Library for formatted BurnMessages used by TokenMessenger.
* @dev BurnMessage format:
* Field Bytes Type Index
* version 4 uint32 0
* burnToken 32 bytes32 4
* mintRecipient 32 bytes32 36
* amount 32 uint256 68
* messageSender 32 bytes32 100
**/
library BurnMessage {
using TypedMemView for bytes;
using TypedMemView for bytes29;
uint8 private constant VERSION_INDEX = 0;
uint8 private constant VERSION_LEN = 4;
uint8 private constant BURN_TOKEN_INDEX = 4;
uint8 private constant BURN_TOKEN_LEN = 32;
uint8 private constant MINT_RECIPIENT_INDEX = 36;
uint8 private constant MINT_RECIPIENT_LEN = 32;
uint8 private constant AMOUNT_INDEX = 68;
uint8 private constant AMOUNT_LEN = 32;
uint8 private constant MSG_SENDER_INDEX = 100;
uint8 private constant MSG_SENDER_LEN = 32;
// 4 byte version + 32 bytes burnToken + 32 bytes mintRecipient + 32 bytes amount + 32 bytes messageSender
uint8 private constant BURN_MESSAGE_LEN = 132;
/**
* @notice Formats Burn message
* @param _version The message body version
* @param _burnToken The burn token address on source domain as bytes32
* @param _mintRecipient The mint recipient address as bytes32
* @param _amount The burn amount
* @param _messageSender The message sender
* @return Burn formatted message.
*/
function _formatMessage(
uint32 _version,
bytes32 _burnToken,
bytes32 _mintRecipient,
uint256 _amount,
bytes32 _messageSender
) internal pure returns (bytes memory) {
return
abi.encodePacked(
_version,
_burnToken,
_mintRecipient,
_amount,
_messageSender
);
}
/**
* @notice Retrieves the burnToken from a DepositForBurn BurnMessage
* @param _message The message
* @return sourceToken address as bytes32
*/
function _getMessageSender(bytes29 _message)
internal
pure
returns (bytes32)
{
return _message.index(MSG_SENDER_INDEX, MSG_SENDER_LEN);
}
/**
* @notice Retrieves the burnToken from a DepositForBurn BurnMessage
* @param _message The message
* @return sourceToken address as bytes32
*/
function _getBurnToken(bytes29 _message) internal pure returns (bytes32) {
return _message.index(BURN_TOKEN_INDEX, BURN_TOKEN_LEN);
}
/**
* @notice Retrieves the mintRecipient from a BurnMessage
* @param _message The message
* @return mintRecipient
*/
function _getMintRecipient(bytes29 _message)
internal
pure
returns (bytes32)
{
return _message.index(MINT_RECIPIENT_INDEX, MINT_RECIPIENT_LEN);
}
/**
* @notice Retrieves the amount from a BurnMessage
* @param _message The message
* @return amount
*/
function _getAmount(bytes29 _message) internal pure returns (uint256) {
return _message.indexUint(AMOUNT_INDEX, AMOUNT_LEN);
}
/**
* @notice Retrieves the version from a Burn message
* @param _message The message
* @return version
*/
function _getVersion(bytes29 _message) internal pure returns (uint32) {
return uint32(_message.indexUint(VERSION_INDEX, VERSION_LEN));
}
/**
* @notice Reverts if burn message is malformed or invalid length
* @param _message The burn message as bytes29
*/
function _validateBurnMessageFormat(bytes29 _message) internal pure {
require(_message.isValid(), "Malformed message");
require(_message.len() == BURN_MESSAGE_LEN, "Invalid message length");
}
}// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
/*
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with GSN meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address payable) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes memory) {
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
return msg.data;
}
}// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}{
"remappings": [
"@evm-cctp-contracts/=lib/evm-cctp-contracts/src/",
"@memview-sol/=lib/memview-sol/",
"@openzeppelin/=lib/openzeppelin-contracts/",
"forge-std/=lib/forge-std/src/",
"centre-tokens.git/=lib/evm-cctp-contracts/lib/centre-tokens.git/",
"ds-test/=lib/evm-cctp-contracts/lib/ds-test/src/",
"evm-cctp-contracts/=lib/evm-cctp-contracts/",
"memview-sol/=lib/memview-sol/contracts/",
"openzeppelin-contracts/=lib/openzeppelin-contracts/contracts/"
],
"optimizer": {
"enabled": true,
"runs": 100000
},
"metadata": {
"useLiteralContent": false,
"bytecodeHash": "ipfs"
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"evmVersion": "istanbul",
"viaIR": false
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"address","name":"tokenAddress","type":"address"},{"internalType":"address","name":"_tokenSystemAddress","type":"address"},{"internalType":"address","name":"tokenMessengerAddress","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"previousFee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newFee","type":"uint256"}],"name":"CctpDefaultForwardFeeUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint32","name":"destinationDomain","type":"uint32"},{"indexed":false,"internalType":"uint256","name":"previousFee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newFee","type":"uint256"}],"name":"CctpForwardFeeUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"previousFee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newFee","type":"uint256"}],"name":"CctpMaxFeeUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"bytes32","name":"to","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"},{"indexed":false,"internalType":"uint32","name":"destinationDomain","type":"uint32"},{"indexed":true,"internalType":"uint64","name":"coreNonce","type":"uint64"}],"name":"CrossChainWithdraw","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint32","name":"dex","type":"uint32"}],"name":"DexDisabled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint32","name":"dex","type":"uint32"}],"name":"DexEnabled","type":"event"},{"anonymous":false,"inputs":[],"name":"DexForwardingDisabled","type":"event"},{"anonymous":false,"inputs":[],"name":"DexForwardingEnabled","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"version","type":"uint64"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"coreRecipient","type":"address"},{"indexed":false,"internalType":"uint64","name":"newCoreAccountFee","type":"uint64"},{"indexed":false,"internalType":"uint256","name":"evmDepositAmount","type":"uint256"},{"indexed":false,"internalType":"uint64","name":"coreSentAmount","type":"uint64"}],"name":"NewCoreAccountFeeApplied","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"previousFee","type":"uint64"},{"indexed":false,"internalType":"uint64","name":"newFee","type":"uint64"}],"name":"NewCoreAccountFeeUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferStarted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[],"name":"Pause","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"newAddress","type":"address"}],"name":"PauserChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"newRescuer","type":"address"}],"name":"RescuerChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"coreRecipient","type":"address"},{"indexed":false,"internalType":"uint64","name":"coreAmount","type":"uint64"},{"indexed":false,"internalType":"uint32","name":"destinationDex","type":"uint32"}],"name":"SendAsset","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[],"name":"Unpause","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Withdraw","type":"event"},{"inputs":[],"name":"acceptOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"shouldForward","type":"bool"},{"internalType":"uint32","name":"destinationChainId","type":"uint32"}],"name":"calculateCrossChainWithdrawalFee","outputs":[{"internalType":"uint256","name":"maxFee","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"cctpDefaultForwardFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"","type":"uint32"}],"name":"cctpForwardFees","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"cctpMaxFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"bytes32","name":"destinationRecipient","type":"bytes32"},{"internalType":"uint32","name":"destinationChainId","type":"uint32"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint64","name":"coreNonce","type":"uint64"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"coreReceiveWithData","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint32","name":"destinationDex","type":"uint32"}],"name":"deposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint32","name":"destinationDex","type":"uint32"}],"name":"depositFor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"authValidAfter","type":"uint256"},{"internalType":"uint256","name":"authValidBefore","type":"uint256"},{"internalType":"bytes32","name":"authNonce","type":"bytes32"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"},{"internalType":"uint32","name":"destinationDex","type":"uint32"}],"name":"depositWithAuth","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"dex","type":"uint32"}],"name":"disableDex","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"disableDexForwarding","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"dex","type":"uint32"}],"name":"enableDex","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"enableDexForwarding","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"","type":"uint32"}],"name":"enabledDestinationDexes","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getCoreProtocolConstants","outputs":[{"components":[{"internalType":"uint8","name":"coreWriterActionVersion","type":"uint8"},{"internalType":"uint24","name":"coreWriterSendAssetActionId","type":"uint24"},{"internalType":"uint64","name":"coreTokenIndex","type":"uint64"},{"internalType":"uint32","name":"coreSpotDexId","type":"uint32"},{"internalType":"uint32","name":"corePerpsDexId","type":"uint32"},{"internalType":"address","name":"coreWriterPrecompileAddress","type":"address"},{"internalType":"address","name":"coreUserExistsPrecompileAddress","type":"address"},{"internalType":"uint256","name":"coreScalingFactor","type":"uint256"}],"internalType":"struct CoreDepositWallet.CoreProtocolConstants","name":"constants","type":"tuple"}],"stateMutability":"pure","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"pauser","type":"address"},{"internalType":"address","name":"rescuer","type":"address"}],"internalType":"struct CoreDepositWallet.CoreDepositWalletRoles","name":"roles","type":"tuple"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"","type":"uint32"}],"name":"isCctpForwardFeeSet","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isDexForwardingDisabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"newCoreAccountFee","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pauser","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"tokenContract","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"rescueERC20","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"rescuer","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"token","outputs":[{"internalType":"contract IDepositableToken","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tokenMessenger","outputs":[{"internalType":"contract TokenMessengerV2","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tokenSystemAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"success","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"destinationDomain","type":"uint32"}],"name":"unsetCctpForwardFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"maxFee","type":"uint256"}],"name":"updateCctpDefaultForwardFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"destinationDomain","type":"uint32"},{"internalType":"uint256","name":"maxFee","type":"uint256"}],"name":"updateCctpForwardFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"maxFee","type":"uint256"}],"name":"updateCctpMaxFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint64","name":"fee","type":"uint64"}],"name":"updateNewCoreAccountFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newPauser","type":"address"}],"name":"updatePauser","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newRescuer","type":"address"}],"name":"updateRescuer","outputs":[],"stateMutability":"nonpayable","type":"function"}]Contract Creation Code
60e06040526002805460ff60a01b191690553480156200001e57600080fd5b5060405162004a6138038062004a6183398101604081905262000041916200028c565b620000556200004f6200010e565b62000112565b6001600160a01b038316620000875760405162461bcd60e51b81526004016200007e90620002d5565b60405180910390fd5b6001600160a01b038216620000b05760405162461bcd60e51b81526004016200007e9062000317565b6001600160a01b038116620000d95760405162461bcd60e51b81526004016200007e9062000360565b6001600160601b0319606084811b821660805283811b821660c05282901b1660a052620001056200013c565b505050620003ab565b3390565b600180546001600160a01b03191690556200013981620001fb602090811b62001deb17901c565b50565b6000620001486200024b565b805490915068010000000000000000900460ff16156200019a5760405162461bcd60e51b815260040180806020018281038252602581526020018062004a3c6025913960400191505060405180910390fd5b80546001600160401b0390811614620001395780546001600160401b0319166001600160401b03908117825560408051918252517fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29181900360200190a150565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0090565b80516001600160a01b03811681146200028757600080fd5b919050565b600080600060608486031215620002a1578283fd5b620002ac846200026f565b9250620002bc602085016200026f565b9150620002cc604085016200026f565b90509250925092565b60208082526022908201527f496e76616c696420746f6b656e416464726573733a207a65726f206164647265604082015261737360f01b606082015260800190565b60208082526029908201527f496e76616c6964205f746f6b656e53797374656d416464726573733a207a65726040820152686f206164647265737360b81b606082015260800190565b6020808252602b908201527f496e76616c696420746f6b656e4d657373656e676572416464726573733a207a60408201526a65726f206164647265737360a81b606082015260800190565b60805160601c60a05160601c60c05160601c6146106200042c6000398061051f528061098b5280611021528061107a52806114b4528061264252806126d75250806107fe5280610add5280610bde525080610ab05280610c11528061113b52806115c55280611bb55280611dc9528061205c528061241452506146106000f3fe608060405234801561001057600080fd5b50600436106102ad5760003560e01c80639fd0506d1161017b578063d26b3e26116100d8578063eb42696a1161008c578063f2fde38b11610071578063f2fde38b146104ef578063f8f1b50714610502578063fc0c546a14610515576102ad565b8063eb42696a146104d4578063eeb97d18146104e7576102ad565b8063e26f7d23116100bd578063e26f7d23146104a6578063e30c3978146104b9578063ea031649146104c1576102ad565b8063d26b3e2614610480578063da6d499414610493576102ad565b8063b7a42b921161012f578063c0cfc00d11610114578063c0cfc00d14610447578063c23c545a1461045a578063d004283e1461046d576102ad565b8063b7a42b921461042c578063b8e2e3d41461043f576102ad565b8063a9059cbb11610160578063a9059cbb146103e6578063b2118a8d146103f9578063b49595b71461040c576102ad565b80639fd0506d146103d6578063a7917af3146103de576102ad565b8063461178301161022957806379ba5097116101dd578063820b3e1e116101c2578063820b3e1e146103b15780638456cb59146103c65780638da5cb5b146103ce576102ad565b806379ba5097146103965780637b5c63cf1461039e576102ad565b8063554bab3c1161020e578063554bab3c146103685780635c975abb1461037b5780636ddde35e14610383576102ad565b806346117830146103585780634c5bd54614610360576102ad565b80632ab600451161028057806338a631831161026557806338a63183146103355780633c1072d01461033d5780633f4ba83a14610350576102ad565b80632ab600451461030f5780632b2dfd2c14610322576102ad565b80630d39c3fc146102b25780630e721e6e146102d0578063108438e0146102f057806311f2b0dc146102fa575b600080fd5b6102ba61051d565b6040516102c79190613aa7565b60405180910390f35b6102e36102de366004613957565b610541565b6040516102c79190613bd2565b6102f8610556565b005b6103026105fa565b6040516102c7919061421e565b6102f861031d366004613685565b61065f565b6102f8610330366004613935565b610673565b6102ba61070c565b6102f861034b3660046138aa565b610728565b6102f8610739565b6102ba6107fc565b6102f8610820565b6102f8610376366004613685565b6108b7565b6102e36108c8565b6102f86103913660046136a1565b6108e9565b6102f8610cde565b6102f86103ac366004613957565b610d7e565b6103b9610e39565b6040516102c79190614340565b6102f8610e61565b6102ba610f3b565b6102ba610f57565b6102e3610f73565b6102e36103f4366004613756565b610f7c565b6102f861040736600461380e565b611252565b61041f61041a366004613957565b6112d2565b6040516102c791906142a8565b6102f861043a36600461398c565b6112e4565b61041f6112f5565b6102f8610455366004613957565b6112fb565b6102f8610468366004613781565b6113db565b6102f861047b366004613957565b61168c565b6102f861048e36600461384e565b61178b565b6102e36104a1366004613957565b611a28565b61041f6104b43660046137da565b611a3d565b6102ba611a98565b6102f86104cf3660046138c2565b611ab4565b6102f86104e2366004613971565b611c41565b61041f611d18565b6102f86104fd366004613685565b611d1e565b6102f86105103660046138aa565b611db6565b6102ba611dc7565b7f000000000000000000000000000000000000000000000000000000000000000081565b60086020526000908152604090205460ff1681565b61055e611e60565b60095460ff16156105a4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161059b90614179565b60405180910390fd5b600980547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790556040517f4d51b447ae2954afc7be853c99034a0acc648b00c895cd4c679c734d9e74e83090600090a1565b610602613615565b50604080516101008101825260018152600d6020820152600091810182905263ffffffff6060820152608081019190915273333333333333333333333333333333333333333360a082015261081060c0820152606460e082015290565b610667611e60565b61067081611f0a565b50565b60025474010000000000000000000000000000000000000000900460ff16156106fd57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f5061757361626c653a2070617573656400000000000000000000000000000000604482015290519081900360640190fd5b610708338383611fe5565b5050565b60035473ffffffffffffffffffffffffffffffffffffffff1690565b610730611e60565b61067081612128565b60025473ffffffffffffffffffffffffffffffffffffffff1633146107a9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602281526020018061455a6022913960400191505060405180910390fd5b600280547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff1690556040517f7805862f689e2f13df9f062ff482ad3ad112aca9e0847911ed832e158c525b3390600090a1565b7f000000000000000000000000000000000000000000000000000000000000000081565b610828611e60565b60095460ff16610864576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161059b90614053565b600980547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001690556040517fd512bc8cc69737fbe8e39acaae68a9662aa2a43ae4c9147b3b1f42e2b72dd37090600090a1565b6108bf611e60565b610670816121ac565b60025474010000000000000000000000000000000000000000900460ff1681565b60025474010000000000000000000000000000000000000000900460ff161561097357604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f5061757361626c653a2070617573656400000000000000000000000000000000604482015290519081900360640190fd5b3373ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016146109e2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161059b906140e7565b610400811115610a1e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161059b9061411c565b6000610a2a838361228d565b90506000610a388288611a3d565b9050808611610a73576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161059b9061401c565b6040517f095ea7b300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000169063095ea7b390610b07907f0000000000000000000000000000000000000000000000000000000000000000908a90600401613bac565b602060405180830381600087803b158015610b2157600080fd5b505af1158015610b35573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b5991906137be565b610b8f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161059b906141b0565b6000610b9e838b8888886122f9565b6040517f779b432d00000000000000000000000000000000000000000000000000000000815290915073ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000169063779b432d90610c44908a908c908e907f0000000000000000000000000000000000000000000000000000000000000000906000908a906107d0908b906004016142d3565b600060405180830381600087803b158015610c5e57600080fd5b505af1158015610c72573d6000803e3d6000fd5b505050508567ffffffffffffffff16898b73ffffffffffffffffffffffffffffffffffffffff167f761918307e881a4e311536b54c38a673f25126bd4ad389ccbff15ef9b3a24c418a8c604051610cca9291906142bf565b60405180910390a450505050505050505050565b6000610ce86123dd565b90508073ffffffffffffffffffffffffffffffffffffffff16610d09611a98565b73ffffffffffffffffffffffffffffffffffffffff1614610d75576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260298152602001806144626029913960400191505060405180910390fd5b610670816123e1565b610d86611e60565b63ffffffff811660009081526008602052604090205460ff16610dd5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161059b90613f2b565b63ffffffff811660008181526008602052604080822080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00169055517f28617ac96f28336fb5379386796ed53829961e329a05f2d61b597dd121d974eb9190a250565b60035474010000000000000000000000000000000000000000900467ffffffffffffffff1681565b60025473ffffffffffffffffffffffffffffffffffffffff163314610ed1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602281526020018061455a6022913960400191505060405180910390fd5b600280547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff16740100000000000000000000000000000000000000001790556040517f6985a02210a168e66602d3235cb6db0e70f92b3ba4d376a33c0f3d9434bff62590600090a1565b60005473ffffffffffffffffffffffffffffffffffffffff1690565b60025473ffffffffffffffffffffffffffffffffffffffff1690565b60095460ff1681565b60025460009074010000000000000000000000000000000000000000900460ff161561100957604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f5061757361626c653a2070617573656400000000000000000000000000000000604482015290519081900360640190fd5b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614611078576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161059b906140e7565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156110fe576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161059b90613e03565b6040517fa9059cbb00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000169063a9059cbb906111729086908690600401613bac565b602060405180830381600087803b15801561118c57600080fd5b505af11580156111a0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111c491906137be565b6111fa576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161059b90613c27565b8273ffffffffffffffffffffffffffffffffffffffff167f884edad9ce6fa2440d8a54cc123490eb96d2768479d49ff9c7366125a94243648360405161124091906142a8565b60405180910390a25060015b92915050565b60035473ffffffffffffffffffffffffffffffffffffffff1633146112c2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806144fc6024913960400191505060405180910390fd5b6112cd838383612412565b505050565b60076020526000908152604090205481565b6112ec611e60565b610670816124a3565b60055481565b611303611e60565b63ffffffff811660009081526006602052604090205460ff16611352576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161059b90613d27565b63ffffffff81166000818152600760209081526040808320805490849055600690925280832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00169055519092917f5b8634e4d215ad9368b0477d1d70372c5c4a64e99c280d0b05e60a5358933ca3916113cf9185916142b1565b60405180910390a25050565b60025474010000000000000000000000000000000000000000900460ff161561146557604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f5061757361626c653a2070617573656400000000000000000000000000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff83166114b2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161059b90613d95565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611538576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161059b90613fbf565b73ffffffffffffffffffffffffffffffffffffffff8316301415611588576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161059b90613e71565b6040517ffe575a8700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000169063fe575a87906115fa908690600401613aa7565b60206040518083038186803b15801561161257600080fd5b505afa158015611626573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061164a91906137be565b15611681576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161059b906141e7565b6112cd838383611fe5565b611694611e60565b63ffffffff81811614156116d4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161059b90613d5e565b63ffffffff811660009081526008602052604090205460ff1615611724576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161059b90613dcc565b63ffffffff811660008181526008602052604080822080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055517f2af67b09aec735f8523cab037c82de9a8af8f6114d3942da7e29c87097abbc0f9190a250565b600061179561252b565b805490915060ff68010000000000000000820416159067ffffffffffffffff166000811580156117c25750825b905060008267ffffffffffffffff1660011480156117e657506117e43061254f565b155b905081806117f15750805b611846576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602581526020018061443d6025913960400191505060405180910390fd5b84547fffffffffffffffffffffffffffffffffffffffffffffffff000000000000000016600117855583156118a75784547fffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffff16680100000000000000001785555b60006118b66020880188613685565b73ffffffffffffffffffffffffffffffffffffffff161415611904576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161059b90613ece565b6119196119146020880188613685565b6123e1565b61193161192c6040880160208901613685565b6121ac565b6119496119446060880160408901613685565b611f0a565b6119566305f5e1006124a3565b6119606000612559565b61196c62030d40612128565b6000805260086020527f5eff886ea0ce6ca488a3d6e336d6c0f75f46d19b42c06ce5ee98e42c96d256c780547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790558315611a205784547fffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffff168555604080516001815290517fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29181900360200190a15b505050505050565b60066020526000908152604090205460ff1681565b60008215611a8e5763ffffffff821660009081526006602052604081205460ff16611a6a57600554611a81565b63ffffffff83166000908152600760205260409020545b60045401915061124c9050565b5060045492915050565b60015473ffffffffffffffffffffffffffffffffffffffff1690565b60025474010000000000000000000000000000000000000000900460ff1615611b3e57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f5061757361626c653a2070617573656400000000000000000000000000000000604482015290519081900360640190fd5b60008811611b78576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161059b90613cf2565b6040517fef55bec600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000169063ef55bec690611bfa90339030908d908d908d908d908d908d908d90600401613af9565b600060405180830381600087803b158015611c1457600080fd5b505af1158015611c28573d6000803e3d6000fd5b50505050611c373389836125d1565b5050505050505050565b611c49611e60565b63ffffffff811115611c87576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161059b90613e3a565b63ffffffff8216600081815260076020908152604080832080549086905560069092529182902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600117905590519091907f5b8634e4d215ad9368b0477d1d70372c5c4a64e99c280d0b05e60a5358933ca390611d0b90849086906142b1565b60405180910390a2505050565b60045481565b611d26611e60565b600180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff8316908117909155611d71610f3b565b73ffffffffffffffffffffffffffffffffffffffff167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b611dbe611e60565b61067081612559565b7f000000000000000000000000000000000000000000000000000000000000000081565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b611e686123dd565b73ffffffffffffffffffffffffffffffffffffffff16611e86610f3b565b73ffffffffffffffffffffffffffffffffffffffff1614611f0857604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b565b73ffffffffffffffffffffffffffffffffffffffff8116611f76576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a81526020018061448b602a913960400191505060405180910390fd5b600380547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83169081179091556040517fe475e580d85111348e40d8ca33cfdd74c30fe1655c2d8537a13abc10065ffa5a90600090a250565b6000821161201f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161059b90613cf2565b6040517f23b872dd00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016906323b872dd9061209590339030908790600401613ac8565b602060405180830381600087803b1580156120af57600080fd5b505af11580156120c3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120e791906137be565b61211d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161059b90613c27565b6112cd8383836125d1565b63ffffffff811115612166576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161059b90613e3a565b60058054908290556040517fa0fc62901343902d4a08e204989b3a0944ce3a7747b99069d995121d6c6b7104906121a090839085906142b1565b60405180910390a15050565b73ffffffffffffffffffffffffffffffffffffffff8116612218576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260288152602001806144156028913960400191505060405180910390fd5b600280547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83811691909117918290556040519116907fb80482a293ca2e013eda8683c9bd7fc8347cfdaeea5ede58cba46df502c2a60490600090a250565b60008161229c5750600161124c565b60006122dd84848080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920182905250925061275f915050565b90506122e881612783565b6122f181612819565b949350505050565b606060008661230957600061232b565b7f636374702d666f727761726400000000000000000000000000000000000000005b9050806000600860ff16601460ff1687879050010188888888604051602001808867ffffffffffffffff191681526018018763ffffffff1660e01b81526004018663ffffffff1660e01b81526004018573ffffffffffffffffffffffffffffffffffffffff1660601b81526014018467ffffffffffffffff1660c01b81526008018383808284378083019250505097505050505050505060405160208183030381529060405291505095945050505050565b3390565b600180547fffffffffffffffffffffffff000000000000000000000000000000000000000016905561067081611deb565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415612498576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161059b90613bf0565b6112cd8383836128b7565b6003805467ffffffffffffffff838116740100000000000000000000000000000000000000009081027fffffffff0000000000000000ffffffffffffffffffffffffffffffffffffffff8416179093556040519290910416907fe73b50ebafb40ea9334ab6fcc45de83ecdf89e3c66316f29ca7b3e78e4cea153906121a09083908590614399565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0090565b803b15155b919050565b63ffffffff811115612597576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161059b90613cbb565b60048054908290556040517facd71710ffc7b57a489b4c6b5f105da14b5498a2e1a75d30d9fef0073d05a4ff906121a090839085906142b1565b67028f5c28f5c28f5c821115612613576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161059b90613f62565b60095460ff1615801561263b575063ffffffff811660009081526008602052604090205460ff165b156126d5577f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff163073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040516126bd91906142a8565b60405180910390a36126d08383836128d8565b6112cd565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161275291906142a8565b60405180910390a3505050565b81516000906020840161277a64ffffffffff85168284612b13565b95945050505050565b6127ae7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000008216612b74565b61067057604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f4d616c666f726d656420686f6f6b206461746100000000000000000000000000604482015290519081900360640190fd5b600060186128487fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000008416612bb1565b6bffffffffffffffffffffffff16101561286457506000612554565b7f636374702d666f7277617264000000000000000000000000000000000000000061288e83612bc5565b7fffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000161492915050565b6112cd73ffffffffffffffffffffffffffffffffffffffff84168383612bf5565b6003546064830290819074010000000000000000000000000000000000000000900467ffffffffffffffff1680156129bc5761291386612c82565b6129bc578067ffffffffffffffff168267ffffffffffffffff1611612964576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161059b9061408a565b80820391508573ffffffffffffffffffffffffffffffffffffffff167f51fe9ef4689300b6a04239a070e28049852bf9841f9b01cf51f6145044fa078e8287856040516129b393929190614355565b60405180910390a25b600086600063ffffffff876000876040516020016129df96959493929190613b56565b604051602081830303815290604052905060006001600d83604051602001612a0993929190613a30565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0818403018152908290527f17938e130000000000000000000000000000000000000000000000000000000082529150733333333333333333333333333333333333333333906317938e1390612a87908490600401613bdd565b600060405180830381600087803b158015612aa157600080fd5b505af1158015612ab5573d6000803e3d6000fd5b505050508773ffffffffffffffffffffffffffffffffffffffff167ff5e9b71b7a0ec5f112c549671463ab7b4f788764e329c97a9605296866a4a99d8588604051612b01929190614379565b60405180910390a25050505050505050565b600080612b208484612d82565b9050604051811115612b30575060005b80612b5e577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000915050612b6d565b612b69858585612df4565b9150505b9392505050565b6000612b7f82612e07565b64ffffffffff1664ffffffffff1415612b9a57506000612554565b6000612ba583612e0d565b60405110159392505050565b60181c6bffffffffffffffffffffffff1690565b600061124c7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000008316826018612e37565b6040805173ffffffffffffffffffffffffffffffffffffffff8416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb000000000000000000000000000000000000000000000000000000001790526112cd908490612fe2565b600080600061081073ffffffffffffffffffffffffffffffffffffffff1684604051602001612cb19190613aa7565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081840301815290829052612ce991613a14565b600060405180830381855afa9150503d8060008114612d24576040519150601f19603f3d011682016040523d82523d6000602084013e612d29565b606091505b509150915081612d65576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161059b90613c5e565b80806020019051810190612d799190613865565b51949350505050565b8181018281101561124c57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f4f766572666c6f7720647572696e67206164646974696f6e2e00000000000000604482015290519081900360640190fd5b606092831b9190911790911b1760181b90565b60d81c90565b6000612e1882612bb1565b612e21836130ba565b016bffffffffffffffffffffffff169050919050565b600060ff8216612e4957506000612b6d565b612e5284612bb1565b6bffffffffffffffffffffffff16612e6d8460ff8516612d82565b1115612f4c57612eae612e7f856130ba565b6bffffffffffffffffffffffff16612e9686612bb1565b6bffffffffffffffffffffffff16858560ff166130ce565b6040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015612f11578181015183820152602001612ef9565b50505050905090810190601f168015612f3e5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b60208260ff161115612fa9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252603a815260200180614520603a913960400191505060405180910390fd5b600882026000612fb8866130ba565b6bffffffffffffffffffffffff1690506000612fd383613229565b91909501511695945050505050565b6000613044826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff166132729092919063ffffffff16565b8051909150156112cd5780806020019051602081101561306357600080fd5b50516112cd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a81526020018061457c602a913960400191505060405180910390fd5b60781c6bffffffffffffffffffffffff1690565b606060006130db86613281565b91505060006130e986613281565b91505060006130f786613281565b915050600061310586613281565b9150508383838360405160200180806145a6603591397fffffffffffff000000000000000000000000000000000000000000000000000060d087811b821660358401527f2077697468206c656e6774682030780000000000000000000000000000000000603b84015286901b16604a82015260500160216144db82397fffffffffffff000000000000000000000000000000000000000000000000000060d094851b811660218301527f2077697468206c656e677468203078000000000000000000000000000000000060278301529290931b9091166036830152507f2e00000000000000000000000000000000000000000000000000000000000000603c82015260408051601d818403018152603d90920190529b9a5050505050505050505050565b7f80000000000000000000000000000000000000000000000000000000000000007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff9091011d90565b60606122f18484600085613355565b600080601f5b600f8160ff1611156132e95760ff600882021684901c6132a68161350f565b61ffff16841793508160ff166010146132c157601084901b93505b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01613287565b50600f5b60ff8160ff16101561334f5760ff600882021684901c61330c8161350f565b61ffff16831792508160ff1660001461332757601083901b92505b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff016132ed565b50915091565b6060824710156133b0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806144b56026913960400191505060405180910390fd5b6133b98561254f565b61342457604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b6000808673ffffffffffffffffffffffffffffffffffffffff1685876040518082805190602001908083835b6020831061348d57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101613450565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d80600081146134ef576040519150601f19603f3d011682016040523d82523d6000602084013e6134f4565b606091505b509150915061350482828661353f565b979650505050505050565b600061352160048360ff16901c6135bf565b60ff161760081b62ffff0016613536826135bf565b60ff1617919050565b6060831561354e575081612b6d565b82511561355e5782518084602001fd5b6040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201818152845160248401528451859391928392604401919085019080838360008315612f11578181015183820152602001612ef9565b6040805180820190915260108082527f30313233343536373839616263646566000000000000000000000000000000006020830152600091600f8416918290811061360657fe5b016020015160f81c9392505050565b6040805161010081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e081019190915290565b803563ffffffff8116811461255457600080fd5b803567ffffffffffffffff8116811461255457600080fd5b600060208284031215613696578081fd5b8135612b6d816143e4565b600080600080600080600060c0888a0312156136bb578283fd5b87356136c6816143e4565b9650602088013595506136db60408901613659565b9450606088013593506136f06080890161366d565b925060a088013567ffffffffffffffff8082111561370c578384fd5b818a0191508a601f83011261371f578384fd5b81358181111561372d578485fd5b8b602082850101111561373e578485fd5b60208301945080935050505092959891949750929550565b60008060408385031215613768578182fd5b8235613773816143e4565b946020939093013593505050565b600080600060608486031215613795578283fd5b83356137a0816143e4565b9250602084013591506137b560408501613659565b90509250925092565b6000602082840312156137cf578081fd5b8151612b6d81614406565b600080604083850312156137ec578182fd5b82356137f781614406565b915061380560208401613659565b90509250929050565b600080600060608486031215613822578283fd5b833561382d816143e4565b9250602084013561383d816143e4565b929592945050506040919091013590565b60006060828403121561385f578081fd5b50919050565b600060208284031215613876578081fd5b6040516020810181811067ffffffffffffffff8211171561389357fe5b60405282516138a181614406565b81529392505050565b6000602082840312156138bb578081fd5b5035919050565b600080600080600080600080610100898b0312156138de578081fd5b88359750602089013596506040890135955060608901359450608089013560ff8116811461390a578182fd5b935060a0890135925060c0890135915061392660e08a01613659565b90509295985092959890939650565b60008060408385031215613947578182fd5b8235915061380560208401613659565b600060208284031215613968578081fd5b612b6d82613659565b60008060408385031215613983578182fd5b61377383613659565b60006020828403121561399d578081fd5b612b6d8261366d565b73ffffffffffffffffffffffffffffffffffffffff169052565b600081518084526139d88160208601602086016143b4565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b63ffffffff169052565b60008251613a268184602087016143b4565b9190910192915050565b60007fff000000000000000000000000000000000000000000000000000000000000008560f81b1682527fffffff00000000000000000000000000000000000000000000000000000000008460e81b1660018301528251613a988160048501602087016143b4565b91909101600401949350505050565b73ffffffffffffffffffffffffffffffffffffffff91909116815260200190565b73ffffffffffffffffffffffffffffffffffffffff9384168152919092166020820152604081019190915260600190565b73ffffffffffffffffffffffffffffffffffffffff998a16815297909816602088015260408701959095526060860193909352608085019190915260a084015260ff1660c083015260e08201526101008101919091526101200190565b73ffffffffffffffffffffffffffffffffffffffff968716815294909516602085015263ffffffff92831660408501529116606083015267ffffffffffffffff908116608083015290911660a082015260c00190565b73ffffffffffffffffffffffffffffffffffffffff929092168252602082015260400190565b901515815260200190565b600060208252612b6d60208301846139c0565b60208082526013908201527f43616e6e6f742072657363756520746f6b656e00000000000000000000000000604082015260600190565b60208082526019908201527f5472616e73666572206f7065726174696f6e206661696c656400000000000000604082015260600190565b60208082526027908201527f436f726520757365722065786973747320707265636f6d70696c652063616c6c60408201527f206661696c656400000000000000000000000000000000000000000000000000606082015260800190565b60208082526019908201527f4d617820666565206578636565647320666565206c696d697400000000000000604082015260600190565b6020808252818101527f416d6f756e74206d7573742062652067726561746572207468616e207a65726f604082015260600190565b60208082526016908201527f466f7277617264696e6720666565206e6f742073657400000000000000000000604082015260600190565b60208082526016908201527f43616e6e6f7420656e61626c652073706f742064657800000000000000000000604082015260600190565b6020808252601f908201527f496e76616c696420726563697069656e743a207a65726f206164647265737300604082015260600190565b60208082526013908201527f44657820616c726561647920656e61626c656400000000000000000000000000604082015260600190565b6020808252601a908201527f496e76616c696420746f3a2073797374656d2061646472657373000000000000604082015260600190565b6020808252601d908201527f466f727761726420666565206578636565647320666565206c696d6974000000604082015260600190565b60208082526024908201527f496e76616c696420726563697069656e743a20436f72654465706f736974576160408201527f6c6c657400000000000000000000000000000000000000000000000000000000606082015260800190565b60208082526021908201527f496e76616c696420726f6c65732e6f776e65723a207a65726f2061646472657360408201527f7300000000000000000000000000000000000000000000000000000000000000606082015260800190565b60208082526014908201527f44657820616c72656164792064697361626c6564000000000000000000000000604082015260600190565b6020808252602a908201527f416d6f756e742065786365656473206d6178207472616e736665722076616c7560408201527f652066726f6d2045564d00000000000000000000000000000000000000000000606082015260800190565b60208082526021908201527f496e76616c696420726563697069656e743a2073797374656d2061646472657360408201527f7300000000000000000000000000000000000000000000000000000000000000606082015260800190565b60208082526019908201527f416d6f756e74206d75737420657863656564206d617846656500000000000000604082015260600190565b6020808252601e908201527f44657820666f7277617264696e6720616c726561647920656e61626c65640000604082015260600190565b60208082526022908201527f416d6f756e74206d75737420657863656564206e6577206163636f756e74206660408201527f6565000000000000000000000000000000000000000000000000000000000000606082015260800190565b6020808252818101527f43616c6c6572206973206e6f74207468652073797374656d2061646472657373604082015260600190565b60208082526026908201527f44617461206c656e6774682065786365656473204d41585f484f4f4b5f44415460408201527f415f53495a450000000000000000000000000000000000000000000000000000606082015260800190565b6020808252601f908201527f44657820666f7277617264696e6720616c72656164792064697361626c656400604082015260600190565b60208082526015908201527f546f6b656e20617070726f76616c206661696c65640000000000000000000000604082015260600190565b6020808252601e908201527f496e76616c696420726563697069656e743a20626c61636b6c69737465640000604082015260600190565b60006101008201905060ff835116825262ffffff602084015116602083015267ffffffffffffffff604084015116604083015263ffffffff606084015116606083015260808301516142736080840182613a0a565b5060a083015161428660a08401826139a6565b5060c083015161429960c08401826139a6565b5060e092830151919092015290565b90815260200190565b918252602082015260400190565b91825263ffffffff16602082015260400190565b60006101008a835263ffffffff808b16602085015289604085015273ffffffffffffffffffffffffffffffffffffffff891660608501528760808501528660a085015280861660c0850152508060e0840152614331818401856139c0565b9b9a5050505050505050505050565b67ffffffffffffffff91909116815260200190565b67ffffffffffffffff93841681526020810192909252909116604082015260600190565b67ffffffffffffffff92909216825263ffffffff16602082015260400190565b67ffffffffffffffff92831681529116602082015260400190565b60005b838110156143cf5781810151838201526020016143b7565b838111156143de576000848401525b50505050565b73ffffffffffffffffffffffffffffffffffffffff8116811461067057600080fd5b801515811461067057600080fdfe5061757361626c653a206e65772070617573657220697320746865207a65726f2061646472657373496e697469616c697a61626c653a20696e76616c696420696e697469616c697a6174696f6e4f776e61626c6532537465703a2063616c6c6572206973206e6f7420746865206e6577206f776e6572526573637561626c653a206e6577207265736375657220697320746865207a65726f2061646472657373416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c2e20417474656d7074656420746f20696e646578206174206f6666736574203078526573637561626c653a2063616c6c6572206973206e6f7420746865207265736375657254797065644d656d566965772f696e646578202d20417474656d7074656420746f20696e646578206d6f7265207468616e2033322062797465735061757361626c653a2063616c6c6572206973206e6f7420746865207061757365725361666545524332303a204552433230206f7065726174696f6e20646964206e6f74207375636365656454797065644d656d566965772f696e646578202d204f76657272616e2074686520766965772e20536c696365206973206174203078a2646970667358221220b08e70a9262791a76ad4a64b77a05897c28453f758d34b55f98112edf7f1ebab64736f6c63430007060033496e697469616c697a61626c653a20696e76616c696420696e697469616c697a6174696f6e000000000000000000000000b88339cb7199b77e23db6e890353e22632ba630f000000000000000000000000200000000000000000000000000000000000000000000000000000000000000028b5a0e9c621a5badaa536219b3a228c8168cf5d
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106102ad5760003560e01c80639fd0506d1161017b578063d26b3e26116100d8578063eb42696a1161008c578063f2fde38b11610071578063f2fde38b146104ef578063f8f1b50714610502578063fc0c546a14610515576102ad565b8063eb42696a146104d4578063eeb97d18146104e7576102ad565b8063e26f7d23116100bd578063e26f7d23146104a6578063e30c3978146104b9578063ea031649146104c1576102ad565b8063d26b3e2614610480578063da6d499414610493576102ad565b8063b7a42b921161012f578063c0cfc00d11610114578063c0cfc00d14610447578063c23c545a1461045a578063d004283e1461046d576102ad565b8063b7a42b921461042c578063b8e2e3d41461043f576102ad565b8063a9059cbb11610160578063a9059cbb146103e6578063b2118a8d146103f9578063b49595b71461040c576102ad565b80639fd0506d146103d6578063a7917af3146103de576102ad565b8063461178301161022957806379ba5097116101dd578063820b3e1e116101c2578063820b3e1e146103b15780638456cb59146103c65780638da5cb5b146103ce576102ad565b806379ba5097146103965780637b5c63cf1461039e576102ad565b8063554bab3c1161020e578063554bab3c146103685780635c975abb1461037b5780636ddde35e14610383576102ad565b806346117830146103585780634c5bd54614610360576102ad565b80632ab600451161028057806338a631831161026557806338a63183146103355780633c1072d01461033d5780633f4ba83a14610350576102ad565b80632ab600451461030f5780632b2dfd2c14610322576102ad565b80630d39c3fc146102b25780630e721e6e146102d0578063108438e0146102f057806311f2b0dc146102fa575b600080fd5b6102ba61051d565b6040516102c79190613aa7565b60405180910390f35b6102e36102de366004613957565b610541565b6040516102c79190613bd2565b6102f8610556565b005b6103026105fa565b6040516102c7919061421e565b6102f861031d366004613685565b61065f565b6102f8610330366004613935565b610673565b6102ba61070c565b6102f861034b3660046138aa565b610728565b6102f8610739565b6102ba6107fc565b6102f8610820565b6102f8610376366004613685565b6108b7565b6102e36108c8565b6102f86103913660046136a1565b6108e9565b6102f8610cde565b6102f86103ac366004613957565b610d7e565b6103b9610e39565b6040516102c79190614340565b6102f8610e61565b6102ba610f3b565b6102ba610f57565b6102e3610f73565b6102e36103f4366004613756565b610f7c565b6102f861040736600461380e565b611252565b61041f61041a366004613957565b6112d2565b6040516102c791906142a8565b6102f861043a36600461398c565b6112e4565b61041f6112f5565b6102f8610455366004613957565b6112fb565b6102f8610468366004613781565b6113db565b6102f861047b366004613957565b61168c565b6102f861048e36600461384e565b61178b565b6102e36104a1366004613957565b611a28565b61041f6104b43660046137da565b611a3d565b6102ba611a98565b6102f86104cf3660046138c2565b611ab4565b6102f86104e2366004613971565b611c41565b61041f611d18565b6102f86104fd366004613685565b611d1e565b6102f86105103660046138aa565b611db6565b6102ba611dc7565b7f000000000000000000000000200000000000000000000000000000000000000081565b60086020526000908152604090205460ff1681565b61055e611e60565b60095460ff16156105a4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161059b90614179565b60405180910390fd5b600980547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790556040517f4d51b447ae2954afc7be853c99034a0acc648b00c895cd4c679c734d9e74e83090600090a1565b610602613615565b50604080516101008101825260018152600d6020820152600091810182905263ffffffff6060820152608081019190915273333333333333333333333333333333333333333360a082015261081060c0820152606460e082015290565b610667611e60565b61067081611f0a565b50565b60025474010000000000000000000000000000000000000000900460ff16156106fd57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f5061757361626c653a2070617573656400000000000000000000000000000000604482015290519081900360640190fd5b610708338383611fe5565b5050565b60035473ffffffffffffffffffffffffffffffffffffffff1690565b610730611e60565b61067081612128565b60025473ffffffffffffffffffffffffffffffffffffffff1633146107a9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602281526020018061455a6022913960400191505060405180910390fd5b600280547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff1690556040517f7805862f689e2f13df9f062ff482ad3ad112aca9e0847911ed832e158c525b3390600090a1565b7f00000000000000000000000028b5a0e9c621a5badaa536219b3a228c8168cf5d81565b610828611e60565b60095460ff16610864576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161059b90614053565b600980547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001690556040517fd512bc8cc69737fbe8e39acaae68a9662aa2a43ae4c9147b3b1f42e2b72dd37090600090a1565b6108bf611e60565b610670816121ac565b60025474010000000000000000000000000000000000000000900460ff1681565b60025474010000000000000000000000000000000000000000900460ff161561097357604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f5061757361626c653a2070617573656400000000000000000000000000000000604482015290519081900360640190fd5b3373ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000200000000000000000000000000000000000000016146109e2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161059b906140e7565b610400811115610a1e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161059b9061411c565b6000610a2a838361228d565b90506000610a388288611a3d565b9050808611610a73576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161059b9061401c565b6040517f095ea7b300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000b88339cb7199b77e23db6e890353e22632ba630f169063095ea7b390610b07907f00000000000000000000000028b5a0e9c621a5badaa536219b3a228c8168cf5d908a90600401613bac565b602060405180830381600087803b158015610b2157600080fd5b505af1158015610b35573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b5991906137be565b610b8f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161059b906141b0565b6000610b9e838b8888886122f9565b6040517f779b432d00000000000000000000000000000000000000000000000000000000815290915073ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000028b5a0e9c621a5badaa536219b3a228c8168cf5d169063779b432d90610c44908a908c908e907f000000000000000000000000b88339cb7199b77e23db6e890353e22632ba630f906000908a906107d0908b906004016142d3565b600060405180830381600087803b158015610c5e57600080fd5b505af1158015610c72573d6000803e3d6000fd5b505050508567ffffffffffffffff16898b73ffffffffffffffffffffffffffffffffffffffff167f761918307e881a4e311536b54c38a673f25126bd4ad389ccbff15ef9b3a24c418a8c604051610cca9291906142bf565b60405180910390a450505050505050505050565b6000610ce86123dd565b90508073ffffffffffffffffffffffffffffffffffffffff16610d09611a98565b73ffffffffffffffffffffffffffffffffffffffff1614610d75576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260298152602001806144626029913960400191505060405180910390fd5b610670816123e1565b610d86611e60565b63ffffffff811660009081526008602052604090205460ff16610dd5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161059b90613f2b565b63ffffffff811660008181526008602052604080822080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00169055517f28617ac96f28336fb5379386796ed53829961e329a05f2d61b597dd121d974eb9190a250565b60035474010000000000000000000000000000000000000000900467ffffffffffffffff1681565b60025473ffffffffffffffffffffffffffffffffffffffff163314610ed1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602281526020018061455a6022913960400191505060405180910390fd5b600280547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff16740100000000000000000000000000000000000000001790556040517f6985a02210a168e66602d3235cb6db0e70f92b3ba4d376a33c0f3d9434bff62590600090a1565b60005473ffffffffffffffffffffffffffffffffffffffff1690565b60025473ffffffffffffffffffffffffffffffffffffffff1690565b60095460ff1681565b60025460009074010000000000000000000000000000000000000000900460ff161561100957604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f5061757361626c653a2070617573656400000000000000000000000000000000604482015290519081900360640190fd5b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000020000000000000000000000000000000000000001614611078576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161059b906140e7565b7f000000000000000000000000200000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156110fe576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161059b90613e03565b6040517fa9059cbb00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000b88339cb7199b77e23db6e890353e22632ba630f169063a9059cbb906111729086908690600401613bac565b602060405180830381600087803b15801561118c57600080fd5b505af11580156111a0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111c491906137be565b6111fa576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161059b90613c27565b8273ffffffffffffffffffffffffffffffffffffffff167f884edad9ce6fa2440d8a54cc123490eb96d2768479d49ff9c7366125a94243648360405161124091906142a8565b60405180910390a25060015b92915050565b60035473ffffffffffffffffffffffffffffffffffffffff1633146112c2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806144fc6024913960400191505060405180910390fd5b6112cd838383612412565b505050565b60076020526000908152604090205481565b6112ec611e60565b610670816124a3565b60055481565b611303611e60565b63ffffffff811660009081526006602052604090205460ff16611352576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161059b90613d27565b63ffffffff81166000818152600760209081526040808320805490849055600690925280832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00169055519092917f5b8634e4d215ad9368b0477d1d70372c5c4a64e99c280d0b05e60a5358933ca3916113cf9185916142b1565b60405180910390a25050565b60025474010000000000000000000000000000000000000000900460ff161561146557604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f5061757361626c653a2070617573656400000000000000000000000000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff83166114b2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161059b90613d95565b7f000000000000000000000000200000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611538576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161059b90613fbf565b73ffffffffffffffffffffffffffffffffffffffff8316301415611588576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161059b90613e71565b6040517ffe575a8700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000b88339cb7199b77e23db6e890353e22632ba630f169063fe575a87906115fa908690600401613aa7565b60206040518083038186803b15801561161257600080fd5b505afa158015611626573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061164a91906137be565b15611681576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161059b906141e7565b6112cd838383611fe5565b611694611e60565b63ffffffff81811614156116d4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161059b90613d5e565b63ffffffff811660009081526008602052604090205460ff1615611724576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161059b90613dcc565b63ffffffff811660008181526008602052604080822080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055517f2af67b09aec735f8523cab037c82de9a8af8f6114d3942da7e29c87097abbc0f9190a250565b600061179561252b565b805490915060ff68010000000000000000820416159067ffffffffffffffff166000811580156117c25750825b905060008267ffffffffffffffff1660011480156117e657506117e43061254f565b155b905081806117f15750805b611846576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602581526020018061443d6025913960400191505060405180910390fd5b84547fffffffffffffffffffffffffffffffffffffffffffffffff000000000000000016600117855583156118a75784547fffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffff16680100000000000000001785555b60006118b66020880188613685565b73ffffffffffffffffffffffffffffffffffffffff161415611904576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161059b90613ece565b6119196119146020880188613685565b6123e1565b61193161192c6040880160208901613685565b6121ac565b6119496119446060880160408901613685565b611f0a565b6119566305f5e1006124a3565b6119606000612559565b61196c62030d40612128565b6000805260086020527f5eff886ea0ce6ca488a3d6e336d6c0f75f46d19b42c06ce5ee98e42c96d256c780547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790558315611a205784547fffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffff168555604080516001815290517fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29181900360200190a15b505050505050565b60066020526000908152604090205460ff1681565b60008215611a8e5763ffffffff821660009081526006602052604081205460ff16611a6a57600554611a81565b63ffffffff83166000908152600760205260409020545b60045401915061124c9050565b5060045492915050565b60015473ffffffffffffffffffffffffffffffffffffffff1690565b60025474010000000000000000000000000000000000000000900460ff1615611b3e57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f5061757361626c653a2070617573656400000000000000000000000000000000604482015290519081900360640190fd5b60008811611b78576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161059b90613cf2565b6040517fef55bec600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000b88339cb7199b77e23db6e890353e22632ba630f169063ef55bec690611bfa90339030908d908d908d908d908d908d908d90600401613af9565b600060405180830381600087803b158015611c1457600080fd5b505af1158015611c28573d6000803e3d6000fd5b50505050611c373389836125d1565b5050505050505050565b611c49611e60565b63ffffffff811115611c87576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161059b90613e3a565b63ffffffff8216600081815260076020908152604080832080549086905560069092529182902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600117905590519091907f5b8634e4d215ad9368b0477d1d70372c5c4a64e99c280d0b05e60a5358933ca390611d0b90849086906142b1565b60405180910390a2505050565b60045481565b611d26611e60565b600180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff8316908117909155611d71610f3b565b73ffffffffffffffffffffffffffffffffffffffff167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b611dbe611e60565b61067081612559565b7f000000000000000000000000b88339cb7199b77e23db6e890353e22632ba630f81565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b611e686123dd565b73ffffffffffffffffffffffffffffffffffffffff16611e86610f3b565b73ffffffffffffffffffffffffffffffffffffffff1614611f0857604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b565b73ffffffffffffffffffffffffffffffffffffffff8116611f76576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a81526020018061448b602a913960400191505060405180910390fd5b600380547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83169081179091556040517fe475e580d85111348e40d8ca33cfdd74c30fe1655c2d8537a13abc10065ffa5a90600090a250565b6000821161201f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161059b90613cf2565b6040517f23b872dd00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000b88339cb7199b77e23db6e890353e22632ba630f16906323b872dd9061209590339030908790600401613ac8565b602060405180830381600087803b1580156120af57600080fd5b505af11580156120c3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120e791906137be565b61211d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161059b90613c27565b6112cd8383836125d1565b63ffffffff811115612166576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161059b90613e3a565b60058054908290556040517fa0fc62901343902d4a08e204989b3a0944ce3a7747b99069d995121d6c6b7104906121a090839085906142b1565b60405180910390a15050565b73ffffffffffffffffffffffffffffffffffffffff8116612218576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260288152602001806144156028913960400191505060405180910390fd5b600280547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83811691909117918290556040519116907fb80482a293ca2e013eda8683c9bd7fc8347cfdaeea5ede58cba46df502c2a60490600090a250565b60008161229c5750600161124c565b60006122dd84848080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920182905250925061275f915050565b90506122e881612783565b6122f181612819565b949350505050565b606060008661230957600061232b565b7f636374702d666f727761726400000000000000000000000000000000000000005b9050806000600860ff16601460ff1687879050010188888888604051602001808867ffffffffffffffff191681526018018763ffffffff1660e01b81526004018663ffffffff1660e01b81526004018573ffffffffffffffffffffffffffffffffffffffff1660601b81526014018467ffffffffffffffff1660c01b81526008018383808284378083019250505097505050505050505060405160208183030381529060405291505095945050505050565b3390565b600180547fffffffffffffffffffffffff000000000000000000000000000000000000000016905561067081611deb565b7f000000000000000000000000b88339cb7199b77e23db6e890353e22632ba630f73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415612498576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161059b90613bf0565b6112cd8383836128b7565b6003805467ffffffffffffffff838116740100000000000000000000000000000000000000009081027fffffffff0000000000000000ffffffffffffffffffffffffffffffffffffffff8416179093556040519290910416907fe73b50ebafb40ea9334ab6fcc45de83ecdf89e3c66316f29ca7b3e78e4cea153906121a09083908590614399565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0090565b803b15155b919050565b63ffffffff811115612597576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161059b90613cbb565b60048054908290556040517facd71710ffc7b57a489b4c6b5f105da14b5498a2e1a75d30d9fef0073d05a4ff906121a090839085906142b1565b67028f5c28f5c28f5c821115612613576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161059b90613f62565b60095460ff1615801561263b575063ffffffff811660009081526008602052604090205460ff165b156126d5577f000000000000000000000000200000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff163073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040516126bd91906142a8565b60405180910390a36126d08383836128d8565b6112cd565b7f000000000000000000000000200000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161275291906142a8565b60405180910390a3505050565b81516000906020840161277a64ffffffffff85168284612b13565b95945050505050565b6127ae7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000008216612b74565b61067057604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f4d616c666f726d656420686f6f6b206461746100000000000000000000000000604482015290519081900360640190fd5b600060186128487fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000008416612bb1565b6bffffffffffffffffffffffff16101561286457506000612554565b7f636374702d666f7277617264000000000000000000000000000000000000000061288e83612bc5565b7fffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000161492915050565b6112cd73ffffffffffffffffffffffffffffffffffffffff84168383612bf5565b6003546064830290819074010000000000000000000000000000000000000000900467ffffffffffffffff1680156129bc5761291386612c82565b6129bc578067ffffffffffffffff168267ffffffffffffffff1611612964576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161059b9061408a565b80820391508573ffffffffffffffffffffffffffffffffffffffff167f51fe9ef4689300b6a04239a070e28049852bf9841f9b01cf51f6145044fa078e8287856040516129b393929190614355565b60405180910390a25b600086600063ffffffff876000876040516020016129df96959493929190613b56565b604051602081830303815290604052905060006001600d83604051602001612a0993929190613a30565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0818403018152908290527f17938e130000000000000000000000000000000000000000000000000000000082529150733333333333333333333333333333333333333333906317938e1390612a87908490600401613bdd565b600060405180830381600087803b158015612aa157600080fd5b505af1158015612ab5573d6000803e3d6000fd5b505050508773ffffffffffffffffffffffffffffffffffffffff167ff5e9b71b7a0ec5f112c549671463ab7b4f788764e329c97a9605296866a4a99d8588604051612b01929190614379565b60405180910390a25050505050505050565b600080612b208484612d82565b9050604051811115612b30575060005b80612b5e577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000915050612b6d565b612b69858585612df4565b9150505b9392505050565b6000612b7f82612e07565b64ffffffffff1664ffffffffff1415612b9a57506000612554565b6000612ba583612e0d565b60405110159392505050565b60181c6bffffffffffffffffffffffff1690565b600061124c7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000008316826018612e37565b6040805173ffffffffffffffffffffffffffffffffffffffff8416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb000000000000000000000000000000000000000000000000000000001790526112cd908490612fe2565b600080600061081073ffffffffffffffffffffffffffffffffffffffff1684604051602001612cb19190613aa7565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081840301815290829052612ce991613a14565b600060405180830381855afa9150503d8060008114612d24576040519150601f19603f3d011682016040523d82523d6000602084013e612d29565b606091505b509150915081612d65576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161059b90613c5e565b80806020019051810190612d799190613865565b51949350505050565b8181018281101561124c57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f4f766572666c6f7720647572696e67206164646974696f6e2e00000000000000604482015290519081900360640190fd5b606092831b9190911790911b1760181b90565b60d81c90565b6000612e1882612bb1565b612e21836130ba565b016bffffffffffffffffffffffff169050919050565b600060ff8216612e4957506000612b6d565b612e5284612bb1565b6bffffffffffffffffffffffff16612e6d8460ff8516612d82565b1115612f4c57612eae612e7f856130ba565b6bffffffffffffffffffffffff16612e9686612bb1565b6bffffffffffffffffffffffff16858560ff166130ce565b6040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015612f11578181015183820152602001612ef9565b50505050905090810190601f168015612f3e5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b60208260ff161115612fa9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252603a815260200180614520603a913960400191505060405180910390fd5b600882026000612fb8866130ba565b6bffffffffffffffffffffffff1690506000612fd383613229565b91909501511695945050505050565b6000613044826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff166132729092919063ffffffff16565b8051909150156112cd5780806020019051602081101561306357600080fd5b50516112cd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a81526020018061457c602a913960400191505060405180910390fd5b60781c6bffffffffffffffffffffffff1690565b606060006130db86613281565b91505060006130e986613281565b91505060006130f786613281565b915050600061310586613281565b9150508383838360405160200180806145a6603591397fffffffffffff000000000000000000000000000000000000000000000000000060d087811b821660358401527f2077697468206c656e6774682030780000000000000000000000000000000000603b84015286901b16604a82015260500160216144db82397fffffffffffff000000000000000000000000000000000000000000000000000060d094851b811660218301527f2077697468206c656e677468203078000000000000000000000000000000000060278301529290931b9091166036830152507f2e00000000000000000000000000000000000000000000000000000000000000603c82015260408051601d818403018152603d90920190529b9a5050505050505050505050565b7f80000000000000000000000000000000000000000000000000000000000000007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff9091011d90565b60606122f18484600085613355565b600080601f5b600f8160ff1611156132e95760ff600882021684901c6132a68161350f565b61ffff16841793508160ff166010146132c157601084901b93505b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01613287565b50600f5b60ff8160ff16101561334f5760ff600882021684901c61330c8161350f565b61ffff16831792508160ff1660001461332757601083901b92505b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff016132ed565b50915091565b6060824710156133b0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806144b56026913960400191505060405180910390fd5b6133b98561254f565b61342457604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b6000808673ffffffffffffffffffffffffffffffffffffffff1685876040518082805190602001908083835b6020831061348d57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101613450565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d80600081146134ef576040519150601f19603f3d011682016040523d82523d6000602084013e6134f4565b606091505b509150915061350482828661353f565b979650505050505050565b600061352160048360ff16901c6135bf565b60ff161760081b62ffff0016613536826135bf565b60ff1617919050565b6060831561354e575081612b6d565b82511561355e5782518084602001fd5b6040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201818152845160248401528451859391928392604401919085019080838360008315612f11578181015183820152602001612ef9565b6040805180820190915260108082527f30313233343536373839616263646566000000000000000000000000000000006020830152600091600f8416918290811061360657fe5b016020015160f81c9392505050565b6040805161010081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e081019190915290565b803563ffffffff8116811461255457600080fd5b803567ffffffffffffffff8116811461255457600080fd5b600060208284031215613696578081fd5b8135612b6d816143e4565b600080600080600080600060c0888a0312156136bb578283fd5b87356136c6816143e4565b9650602088013595506136db60408901613659565b9450606088013593506136f06080890161366d565b925060a088013567ffffffffffffffff8082111561370c578384fd5b818a0191508a601f83011261371f578384fd5b81358181111561372d578485fd5b8b602082850101111561373e578485fd5b60208301945080935050505092959891949750929550565b60008060408385031215613768578182fd5b8235613773816143e4565b946020939093013593505050565b600080600060608486031215613795578283fd5b83356137a0816143e4565b9250602084013591506137b560408501613659565b90509250925092565b6000602082840312156137cf578081fd5b8151612b6d81614406565b600080604083850312156137ec578182fd5b82356137f781614406565b915061380560208401613659565b90509250929050565b600080600060608486031215613822578283fd5b833561382d816143e4565b9250602084013561383d816143e4565b929592945050506040919091013590565b60006060828403121561385f578081fd5b50919050565b600060208284031215613876578081fd5b6040516020810181811067ffffffffffffffff8211171561389357fe5b60405282516138a181614406565b81529392505050565b6000602082840312156138bb578081fd5b5035919050565b600080600080600080600080610100898b0312156138de578081fd5b88359750602089013596506040890135955060608901359450608089013560ff8116811461390a578182fd5b935060a0890135925060c0890135915061392660e08a01613659565b90509295985092959890939650565b60008060408385031215613947578182fd5b8235915061380560208401613659565b600060208284031215613968578081fd5b612b6d82613659565b60008060408385031215613983578182fd5b61377383613659565b60006020828403121561399d578081fd5b612b6d8261366d565b73ffffffffffffffffffffffffffffffffffffffff169052565b600081518084526139d88160208601602086016143b4565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b63ffffffff169052565b60008251613a268184602087016143b4565b9190910192915050565b60007fff000000000000000000000000000000000000000000000000000000000000008560f81b1682527fffffff00000000000000000000000000000000000000000000000000000000008460e81b1660018301528251613a988160048501602087016143b4565b91909101600401949350505050565b73ffffffffffffffffffffffffffffffffffffffff91909116815260200190565b73ffffffffffffffffffffffffffffffffffffffff9384168152919092166020820152604081019190915260600190565b73ffffffffffffffffffffffffffffffffffffffff998a16815297909816602088015260408701959095526060860193909352608085019190915260a084015260ff1660c083015260e08201526101008101919091526101200190565b73ffffffffffffffffffffffffffffffffffffffff968716815294909516602085015263ffffffff92831660408501529116606083015267ffffffffffffffff908116608083015290911660a082015260c00190565b73ffffffffffffffffffffffffffffffffffffffff929092168252602082015260400190565b901515815260200190565b600060208252612b6d60208301846139c0565b60208082526013908201527f43616e6e6f742072657363756520746f6b656e00000000000000000000000000604082015260600190565b60208082526019908201527f5472616e73666572206f7065726174696f6e206661696c656400000000000000604082015260600190565b60208082526027908201527f436f726520757365722065786973747320707265636f6d70696c652063616c6c60408201527f206661696c656400000000000000000000000000000000000000000000000000606082015260800190565b60208082526019908201527f4d617820666565206578636565647320666565206c696d697400000000000000604082015260600190565b6020808252818101527f416d6f756e74206d7573742062652067726561746572207468616e207a65726f604082015260600190565b60208082526016908201527f466f7277617264696e6720666565206e6f742073657400000000000000000000604082015260600190565b60208082526016908201527f43616e6e6f7420656e61626c652073706f742064657800000000000000000000604082015260600190565b6020808252601f908201527f496e76616c696420726563697069656e743a207a65726f206164647265737300604082015260600190565b60208082526013908201527f44657820616c726561647920656e61626c656400000000000000000000000000604082015260600190565b6020808252601a908201527f496e76616c696420746f3a2073797374656d2061646472657373000000000000604082015260600190565b6020808252601d908201527f466f727761726420666565206578636565647320666565206c696d6974000000604082015260600190565b60208082526024908201527f496e76616c696420726563697069656e743a20436f72654465706f736974576160408201527f6c6c657400000000000000000000000000000000000000000000000000000000606082015260800190565b60208082526021908201527f496e76616c696420726f6c65732e6f776e65723a207a65726f2061646472657360408201527f7300000000000000000000000000000000000000000000000000000000000000606082015260800190565b60208082526014908201527f44657820616c72656164792064697361626c6564000000000000000000000000604082015260600190565b6020808252602a908201527f416d6f756e742065786365656473206d6178207472616e736665722076616c7560408201527f652066726f6d2045564d00000000000000000000000000000000000000000000606082015260800190565b60208082526021908201527f496e76616c696420726563697069656e743a2073797374656d2061646472657360408201527f7300000000000000000000000000000000000000000000000000000000000000606082015260800190565b60208082526019908201527f416d6f756e74206d75737420657863656564206d617846656500000000000000604082015260600190565b6020808252601e908201527f44657820666f7277617264696e6720616c726561647920656e61626c65640000604082015260600190565b60208082526022908201527f416d6f756e74206d75737420657863656564206e6577206163636f756e74206660408201527f6565000000000000000000000000000000000000000000000000000000000000606082015260800190565b6020808252818101527f43616c6c6572206973206e6f74207468652073797374656d2061646472657373604082015260600190565b60208082526026908201527f44617461206c656e6774682065786365656473204d41585f484f4f4b5f44415460408201527f415f53495a450000000000000000000000000000000000000000000000000000606082015260800190565b6020808252601f908201527f44657820666f7277617264696e6720616c72656164792064697361626c656400604082015260600190565b60208082526015908201527f546f6b656e20617070726f76616c206661696c65640000000000000000000000604082015260600190565b6020808252601e908201527f496e76616c696420726563697069656e743a20626c61636b6c69737465640000604082015260600190565b60006101008201905060ff835116825262ffffff602084015116602083015267ffffffffffffffff604084015116604083015263ffffffff606084015116606083015260808301516142736080840182613a0a565b5060a083015161428660a08401826139a6565b5060c083015161429960c08401826139a6565b5060e092830151919092015290565b90815260200190565b918252602082015260400190565b91825263ffffffff16602082015260400190565b60006101008a835263ffffffff808b16602085015289604085015273ffffffffffffffffffffffffffffffffffffffff891660608501528760808501528660a085015280861660c0850152508060e0840152614331818401856139c0565b9b9a5050505050505050505050565b67ffffffffffffffff91909116815260200190565b67ffffffffffffffff93841681526020810192909252909116604082015260600190565b67ffffffffffffffff92909216825263ffffffff16602082015260400190565b67ffffffffffffffff92831681529116602082015260400190565b60005b838110156143cf5781810151838201526020016143b7565b838111156143de576000848401525b50505050565b73ffffffffffffffffffffffffffffffffffffffff8116811461067057600080fd5b801515811461067057600080fdfe5061757361626c653a206e65772070617573657220697320746865207a65726f2061646472657373496e697469616c697a61626c653a20696e76616c696420696e697469616c697a6174696f6e4f776e61626c6532537465703a2063616c6c6572206973206e6f7420746865206e6577206f776e6572526573637561626c653a206e6577207265736375657220697320746865207a65726f2061646472657373416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c2e20417474656d7074656420746f20696e646578206174206f6666736574203078526573637561626c653a2063616c6c6572206973206e6f7420746865207265736375657254797065644d656d566965772f696e646578202d20417474656d7074656420746f20696e646578206d6f7265207468616e2033322062797465735061757361626c653a2063616c6c6572206973206e6f7420746865207061757365725361666545524332303a204552433230206f7065726174696f6e20646964206e6f74207375636365656454797065644d656d566965772f696e646578202d204f76657272616e2074686520766965772e20536c696365206973206174203078a2646970667358221220b08e70a9262791a76ad4a64b77a05897c28453f758d34b55f98112edf7f1ebab64736f6c63430007060033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000b88339cb7199b77e23db6e890353e22632ba630f000000000000000000000000200000000000000000000000000000000000000000000000000000000000000028b5a0e9c621a5badaa536219b3a228c8168cf5d
-----Decoded View---------------
Arg [0] : tokenAddress (address): 0xb88339CB7199b77E23DB6E890353E22632Ba630f
Arg [1] : _tokenSystemAddress (address): 0x2000000000000000000000000000000000000000
Arg [2] : tokenMessengerAddress (address): 0x28b5a0e9C621a5BadaA536219b3a228C8168cf5d
-----Encoded View---------------
3 Constructor Arguments found :
Arg [0] : 000000000000000000000000b88339cb7199b77e23db6e890353e22632ba630f
Arg [1] : 0000000000000000000000002000000000000000000000000000000000000000
Arg [2] : 00000000000000000000000028b5a0e9c621a5badaa536219b3a228c8168cf5d
Loading...
Loading
Loading...
Loading
Loading...
Loading
Net Worth in USD
$3.00
Net Worth in HYPE
Token Allocations
USDC
100.00%
Multichain Portfolio | 35 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|---|---|---|---|---|
| HYPEREVM | 100.00% | $0.9997 | 3 | $3 |
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.