Overview
ETH Balance
ETH Value
$0.00Multichain Info
Latest 1 from a total of 1 transactions
| Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
|---|---|---|---|---|---|---|---|---|---|
| Deploy Token And... | 15018776 | 6 days ago | IN | 0 ETH | 0.0000085 |
Latest 2 internal transactions
| Parent Transaction Hash | Block | From | To | |||
|---|---|---|---|---|---|---|
| 15018776 | 6 days ago | Contract Creation | 0 ETH | |||
| 15018776 | 6 days ago | Contract Creation | 0 ETH |
Cross-Chain Transactions
Contract Source Code Verified (Exact Match)
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.24;
import {IOwnable} from "../../../shared/interfaces/IOwnable.sol";
import {ITypeAndVersion} from "../../../shared/interfaces/ITypeAndVersion.sol";
import {ITokenAdminRegistry} from "../../interfaces/ITokenAdminRegistry.sol";
import {RateLimiter} from "../../libraries/RateLimiter.sol";
import {TokenPool} from "../../pools/TokenPool.sol";
import {RegistryModuleOwnerCustom} from "../RegistryModuleOwnerCustom.sol";
import {FactoryBurnMintERC20} from "./FactoryBurnMintERC20.sol";
import {Create2} from "../../../vendor/openzeppelin-solidity/v5.0.2/contracts/utils/Create2.sol";
/// @notice A contract for deploying new tokens and token pools, and configuring them with the token admin registry
/// @dev At the end of the transaction, the ownership transfer process will begin, but the user must accept the
/// ownership transfer in a separate transaction.
/// @dev The address prediction mechanism is only capable of deploying and predicting addresses for EVM based chains.
/// adding compatibility for other chains will require additional offchain computation.
contract TokenPoolFactory is ITypeAndVersion {
using Create2 for bytes32;
event RemoteChainConfigUpdated(uint64 indexed remoteChainSelector, RemoteChainConfig remoteChainConfig);
error InvalidZeroAddress();
/// @notice The type of pool to deploy. Types may be expanded in future versions
enum PoolType {
BURN_MINT,
LOCK_RELEASE
}
/// @dev This struct will only ever exist in memory and as calldata, and therefore does not need to be efficiently packed for storage. The struct is used to pass information to the create2 address generation function.
struct RemoteTokenPoolInfo {
uint64 remoteChainSelector; // The CCIP specific selector for the remote chain
bytes remotePoolAddress; // The address of the remote pool to either deploy or use as is. If empty, address
// will be predicted
bytes remotePoolInitCode; // Remote pool creation code if it needs to be deployed, without constructor params
// appended to the end.
RemoteChainConfig remoteChainConfig; // The addresses of the remote RMNProxy, Router, factory, and token
// decimals which are needed for determining the remote address
PoolType poolType; // The type of pool to deploy, either Burn/Mint or Lock/Release
bytes remoteTokenAddress; // EVM address for remote token. If empty, the address will be predicted
bytes remoteTokenInitCode; // The init code to be deployed on the remote chain and includes constructor params
RateLimiter.Config rateLimiterConfig; // Token Pool rate limit. Values will be applied on incoming an outgoing messages
}
// solhint-disable-next-line gas-struct-packing
struct RemoteChainConfig {
address remotePoolFactory; // The factory contract on the remote chain which will make the deployment
address remoteRouter; // The router on the remote chain
address remoteRMNProxy; // The RMNProxy contract on the remote chain
uint8 remoteTokenDecimals; // The number of decimals for the token on the remote chain
}
string public constant typeAndVersion = "TokenPoolFactory 1.5.1";
ITokenAdminRegistry private immutable i_tokenAdminRegistry;
RegistryModuleOwnerCustom private immutable i_registryModuleOwnerCustom;
address private immutable i_rmnProxy;
address private immutable i_ccipRouter;
/// @notice Construct the TokenPoolFactory
/// @param tokenAdminRegistry The address of the token admin registry
/// @param tokenAdminModule The address of the token admin module which can register the token via ownership module
/// @param rmnProxy The address of the RMNProxy contract token pools will be deployed with
/// @param ccipRouter The address of the CCIPRouter contract token pools will be deployed with
constructor(
ITokenAdminRegistry tokenAdminRegistry,
RegistryModuleOwnerCustom tokenAdminModule,
address rmnProxy,
address ccipRouter
) {
if (
address(tokenAdminRegistry) == address(0) || address(tokenAdminModule) == address(0) || rmnProxy == address(0)
|| ccipRouter == address(0)
) revert InvalidZeroAddress();
i_tokenAdminRegistry = ITokenAdminRegistry(tokenAdminRegistry);
i_registryModuleOwnerCustom = RegistryModuleOwnerCustom(tokenAdminModule);
i_rmnProxy = rmnProxy;
i_ccipRouter = ccipRouter;
}
// ================================================================
// ¦ Top-Level Deployment ¦
// ================================================================
/// @notice Deploys a token and token pool with the given token information and configures it with remote token pools
/// @dev The token and token pool are deployed in the same transaction, and the token pool is configured with the
/// remote token pools. The token pool is then set in the token admin registry. Ownership of the everything is transferred
/// to the msg.sender, but must be accepted in a separate transaction due to 2-step ownership transfer.
/// @param remoteTokenPools An array of remote token pools info to be used in the pool's applyChainUpdates function
/// or to be predicted if the pool has not been deployed yet on the remote chain
/// @param localTokenDecimals The amount of decimals to be used in the new token. Since decimals() is not part of the
/// the ERC20 standard, and thus cannot be certain to exist, the amount must be supplied via user input.
/// @param tokenInitCode The creation code for the token, which includes the constructor parameters already appended
/// @param tokenPoolInitCode The creation code for the token pool, without the constructor parameters appended
/// @param salt The salt to be used in the create2 deployment of the token and token pool to ensure a unique address
/// @return token The address of the token that was deployed
/// @return pool The address of the token pool that was deployed
function deployTokenAndTokenPool(
RemoteTokenPoolInfo[] calldata remoteTokenPools,
uint8 localTokenDecimals,
bytes memory tokenInitCode,
bytes calldata tokenPoolInitCode,
bytes32 salt
) external returns (address, address) {
// Ensure a unique deployment between senders even if the same input parameter is used to prevent
// DOS/front running attacks
salt = keccak256(abi.encodePacked(salt, msg.sender));
// Deploy the token. The constructor parameters are already provided in the tokenInitCode
address token = Create2.deploy(0, salt, tokenInitCode);
// Deploy the token pool
address pool =
_createTokenPool(token, localTokenDecimals, remoteTokenPools, tokenPoolInitCode, salt, PoolType.BURN_MINT);
// Grant the mint and burn roles to the pool for the token
FactoryBurnMintERC20(token).grantMintAndBurnRoles(pool);
// Set the token pool for token in the token admin registry since this contract is the token and pool owner
_setTokenPoolInTokenAdminRegistry(token, pool);
// Begin the 2 step ownership transfer of the newly deployed token to the msg.sender
IOwnable(token).transferOwnership(msg.sender);
return (token, pool);
}
/// @notice Deploys a token pool with an existing ERC20 token
/// @dev Since the token already exists, this contract is not the owner and therefore cannot configure the
/// token pool in the token admin registry in the same transaction. The user must invoke the calls to the
/// tokenAdminRegistry manually
/// @dev since the token already exists, the owner must grant the mint and burn roles to the pool manually
/// @param token The address of the existing token to be used in the token pool
/// @param localTokenDecimals The amount of decimals used in the existing token. Since decimals() is not part of the
/// the ERC20 standard, and thus cannot be certain to exist, the amount must be supplied via user input.
/// @param remoteTokenPools An array of remote token pools info to be used in the pool's applyChainUpdates function
/// @param tokenPoolInitCode The creation code for the token pool
/// @param salt The salt to be used in the create2 deployment of the token pool
/// @return poolAddress The address of the token pool that was deployed
function deployTokenPoolWithExistingToken(
address token,
uint8 localTokenDecimals,
RemoteTokenPoolInfo[] calldata remoteTokenPools,
bytes calldata tokenPoolInitCode,
bytes32 salt,
PoolType poolType
) external returns (address poolAddress) {
// Ensure a unique deployment between senders even if the same input parameter is used to prevent
// DOS/front running attacks
salt = keccak256(abi.encodePacked(salt, msg.sender));
// create the token pool and return the address
return _createTokenPool(token, localTokenDecimals, remoteTokenPools, tokenPoolInitCode, salt, poolType);
}
// ================================================================
// ¦ Pool Deployment/Configuration ¦
// ================================================================
/// @notice Deploys a token pool with the given token information and remote token pools
/// @param token The token to be used in the token pool
/// @param remoteTokenPools An array of remote token pools info to be used in the pool's applyChainUpdates function
/// @param tokenPoolInitCode The creation code for the token pool
/// @param salt The salt to be used in the create2 deployment of the token pool
/// @return poolAddress The address of the token pool that was deployed
function _createTokenPool(
address token,
uint8 localTokenDecimals,
RemoteTokenPoolInfo[] calldata remoteTokenPools,
bytes calldata tokenPoolInitCode,
bytes32 salt,
PoolType poolType
) private returns (address) {
// Create an array of chain updates to apply to the token pool
TokenPool.ChainUpdate[] memory chainUpdates = new TokenPool.ChainUpdate[](remoteTokenPools.length);
RemoteTokenPoolInfo memory remoteTokenPool;
for (uint256 i = 0; i < remoteTokenPools.length; ++i) {
remoteTokenPool = remoteTokenPools[i];
// If the user provides an empty byte string, indicated no token has already been deployed,
// then the address of the token needs to be predicted. Otherwise the address provided will be used.
if (remoteTokenPool.remoteTokenAddress.length == 0) {
// The user must provide the initCode for the remote token, so its address can be predicted correctly. It's
// provided in the remoteTokenInitCode field for the remoteTokenPool
remoteTokenPool.remoteTokenAddress = abi.encode(
salt.computeAddress(
keccak256(remoteTokenPool.remoteTokenInitCode), remoteTokenPool.remoteChainConfig.remotePoolFactory
)
);
}
// If the user provides an empty byte string parameter, indicating the pool has not been deployed yet,
// the address of the pool should be predicted. Otherwise use the provided address.
if (remoteTokenPool.remotePoolAddress.length == 0) {
// Address is predicted based on the init code hash and the deployer, so the hash must first be computed
// using the initCode and a concatenated set of constructor parameters.
bytes32 remotePoolInitcodeHash = _generatePoolInitcodeHash(
remoteTokenPool.remotePoolInitCode,
remoteTokenPool.remoteChainConfig,
abi.decode(remoteTokenPool.remoteTokenAddress, (address)),
remoteTokenPool.poolType
);
// Abi encode the computed remote address so it can be used as bytes in the chain update
remoteTokenPool.remotePoolAddress =
abi.encode(salt.computeAddress(remotePoolInitcodeHash, remoteTokenPool.remoteChainConfig.remotePoolFactory));
}
bytes[] memory remotePoolAddresses = new bytes[](1);
remotePoolAddresses[0] = remoteTokenPool.remotePoolAddress;
chainUpdates[i] = TokenPool.ChainUpdate({
remoteChainSelector: remoteTokenPool.remoteChainSelector,
remotePoolAddresses: remotePoolAddresses,
remoteTokenAddress: remoteTokenPool.remoteTokenAddress,
outboundRateLimiterConfig: remoteTokenPool.rateLimiterConfig,
inboundRateLimiterConfig: remoteTokenPool.rateLimiterConfig
});
}
// Construct the initArgs for the token pool using the immutable contracts for CCIP on the local chain
bytes memory tokenPoolInitArgs;
if (poolType == PoolType.BURN_MINT) {
tokenPoolInitArgs = abi.encode(token, localTokenDecimals, new address[](0), i_rmnProxy, i_ccipRouter);
} else if (poolType == PoolType.LOCK_RELEASE) {
// Lock/Release pools have an additional boolean constructor parameter that must be accounted for, acceptLiquidity,
// which is set to true by default in this case. Users wishing to set it to false must deploy the pool manually.
tokenPoolInitArgs = abi.encode(token, localTokenDecimals, new address[](0), i_rmnProxy, true, i_ccipRouter);
}
// Construct the deployment code from the initCode and the initArgs and then deploy
address poolAddress = Create2.deploy(0, salt, abi.encodePacked(tokenPoolInitCode, tokenPoolInitArgs));
// Apply the chain updates to the token pool
TokenPool(poolAddress).applyChainUpdates(new uint64[](0), chainUpdates);
// Begin the 2 step ownership transfer of the token pool to the msg.sender.
IOwnable(poolAddress).transferOwnership(address(msg.sender)); // 2 step ownership transfer
return poolAddress;
}
/// @notice Generates the hash of the init code the pool will be deployed with
/// @dev The init code hash is used with Create2 to predict the address of the pool on the remote chain
/// @dev ABI-encoding limitations prevent arbitrary constructor parameters from being used, so pool type must be
/// restricted to those with known types in the constructor. This function should be updated if new pool types are needed.
/// @param initCode The init code of the pool
/// @param remoteChainConfig The remote chain config for the pool
/// @param remoteTokenAddress The address of the remote token
/// @param poolType The type of pool to deploy
/// @return bytes32 hash of the init code to be used in the deterministic address calculation
function _generatePoolInitcodeHash(
bytes memory initCode,
RemoteChainConfig memory remoteChainConfig,
address remoteTokenAddress,
PoolType poolType
) private pure returns (bytes32) {
if (poolType == PoolType.BURN_MINT) {
return keccak256(
abi.encodePacked(
initCode,
// constructor(address token, uint8 localTokenDecimals, address[] allowlist, address rmnProxy, address router)
abi.encode(
remoteTokenAddress,
remoteChainConfig.remoteTokenDecimals,
new address[](0),
remoteChainConfig.remoteRMNProxy,
remoteChainConfig.remoteRouter
)
)
);
} else {
// if poolType is PoolType.LOCK_RELEASE, but may be expanded in future versions
return keccak256(
abi.encodePacked(
initCode,
// constructor(address token, uint8 localTokenDecimals, address[] allowList, address rmnProxy, bool acceptLiquidity, address router)
abi.encode(
remoteTokenAddress,
remoteChainConfig.remoteTokenDecimals,
new address[](0),
remoteChainConfig.remoteRMNProxy,
true,
remoteChainConfig.remoteRouter
)
)
);
}
}
/// @notice Sets the token pool address in the token admin registry for a newly deployed token pool.
/// @dev this function should only be called when the token is deployed by this contract as well, otherwise
/// the token pool will not be able to be set in the token admin registry, and this function will revert.
/// @param token The address of the token to set the pool for
/// @param pool The address of the pool to set in the token admin registry
function _setTokenPoolInTokenAdminRegistry(address token, address pool) private {
i_registryModuleOwnerCustom.registerAdminViaOwner(token);
i_tokenAdminRegistry.acceptAdminRole(token);
i_tokenAdminRegistry.setPool(token, pool);
// Begin the 2 admin transfer process which must be accepted in a separate tx.
i_tokenAdminRegistry.transferAdminRole(token, msg.sender);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @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);
/**
* @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 `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, 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 `from` to `to` 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 from, address to, uint256 amount) external returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)
pragma solidity ^0.8.20;
/**
* @dev External interface of AccessControl declared to support ERC165 detection.
*/
interface IAccessControl {
/**
* @dev The `account` is missing a role.
*/
error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);
/**
* @dev The caller of a function is not the expected one.
*
* NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.
*/
error AccessControlBadConfirmation();
/**
* @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
*
* `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
* {RoleAdminChanged} not being emitted signaling this.
*/
event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);
/**
* @dev Emitted when `account` is granted `role`.
*
* `sender` is the account that originated the contract call, an admin role
* bearer except when using {AccessControl-_setupRole}.
*/
event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Emitted when `account` is revoked `role`.
*
* `sender` is the account that originated the contract call:
* - if using `revokeRole`, it is the admin role bearer
* - if using `renounceRole`, it is the role bearer (i.e. `account`)
*/
event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) external view returns (bool);
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {AccessControl-_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) external view returns (bytes32);
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function grantRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function revokeRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been granted `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `callerConfirmation`.
*/
function renounceRole(bytes32 role, address callerConfirmation) external;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/structs/EnumerableSet.sol)
// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.
pragma solidity ^0.8.0;
/**
* @dev Library for managing
* https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
* types.
*
* Sets have the following properties:
*
* - Elements are added, removed, and checked for existence in constant time
* (O(1)).
* - Elements are enumerated in O(n). No guarantees are made on the ordering.
*
* ```
* contract Example {
* // Add the library methods
* using EnumerableSet for EnumerableSet.AddressSet;
*
* // Declare a set state variable
* EnumerableSet.AddressSet private mySet;
* }
* ```
*
* As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
* and `uint256` (`UintSet`) are supported.
*
* [WARNING]
* ====
* Trying to delete such a structure from storage will likely result in data corruption, rendering the structure
* unusable.
* See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.
*
* In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an
* array of EnumerableSet.
* ====
*/
library EnumerableSet {
// To implement this library for multiple types with as little code
// repetition as possible, we write it in terms of a generic Set type with
// bytes32 values.
// The Set implementation uses private functions, and user-facing
// implementations (such as AddressSet) are just wrappers around the
// underlying Set.
// This means that we can only create new EnumerableSets for types that fit
// in bytes32.
struct Set {
// Storage of set values
bytes32[] _values;
// Position of the value in the `values` array, plus 1 because index 0
// means a value is not in the set.
mapping(bytes32 => uint256) _indexes;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function _add(Set storage set, bytes32 value) private returns (bool) {
if (!_contains(set, value)) {
set._values.push(value);
// The value is stored at length-1, but we add 1 to all indexes
// and use 0 as a sentinel value
set._indexes[value] = set._values.length;
return true;
} else {
return false;
}
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function _remove(Set storage set, bytes32 value) private returns (bool) {
// We read and store the value's index to prevent multiple reads from the same storage slot
uint256 valueIndex = set._indexes[value];
if (valueIndex != 0) {
// Equivalent to contains(set, value)
// To delete an element from the _values array in O(1), we swap the element to delete with the last one in
// the array, and then remove the last element (sometimes called as 'swap and pop').
// This modifies the order of the array, as noted in {at}.
uint256 toDeleteIndex = valueIndex - 1;
uint256 lastIndex = set._values.length - 1;
if (lastIndex != toDeleteIndex) {
bytes32 lastValue = set._values[lastIndex];
// Move the last value to the index where the value to delete is
set._values[toDeleteIndex] = lastValue;
// Update the index for the moved value
set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex
}
// Delete the slot where the moved value was stored
set._values.pop();
// Delete the index for the deleted slot
delete set._indexes[value];
return true;
} else {
return false;
}
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function _contains(Set storage set, bytes32 value) private view returns (bool) {
return set._indexes[value] != 0;
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function _length(Set storage set) private view returns (uint256) {
return set._values.length;
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function _at(Set storage set, uint256 index) private view returns (bytes32) {
return set._values[index];
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function _values(Set storage set) private view returns (bytes32[] memory) {
return set._values;
}
// Bytes32Set
struct Bytes32Set {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _add(set._inner, value);
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _remove(set._inner, value);
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
return _contains(set._inner, value);
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(Bytes32Set storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
return _at(set._inner, index);
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {
bytes32[] memory store = _values(set._inner);
bytes32[] memory result;
/// @solidity memory-safe-assembly
assembly {
result := store
}
return result;
}
// AddressSet
struct AddressSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(AddressSet storage set, address value) internal returns (bool) {
return _add(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(AddressSet storage set, address value) internal returns (bool) {
return _remove(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(AddressSet storage set, address value) internal view returns (bool) {
return _contains(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(AddressSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(AddressSet storage set, uint256 index) internal view returns (address) {
return address(uint160(uint256(_at(set._inner, index))));
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(AddressSet storage set) internal view returns (address[] memory) {
bytes32[] memory store = _values(set._inner);
address[] memory result;
/// @solidity memory-safe-assembly
assembly {
result := store
}
return result;
}
// UintSet
struct UintSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(UintSet storage set, uint256 value) internal returns (bool) {
return _add(set._inner, bytes32(value));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(UintSet storage set, uint256 value) internal returns (bool) {
return _remove(set._inner, bytes32(value));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(UintSet storage set, uint256 value) internal view returns (bool) {
return _contains(set._inner, bytes32(value));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(UintSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(UintSet storage set, uint256 index) internal view returns (uint256) {
return uint256(_at(set._inner, index));
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(UintSet storage set) internal view returns (uint256[] memory) {
bytes32[] memory store = _values(set._inner);
uint256[] memory result;
/// @solidity memory-safe-assembly
assembly {
result := store
}
return result;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)
pragma solidity ^0.8.20;
import {IERC165} from "./IERC165.sol";
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*/
abstract contract ERC165 is IERC165 {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.24;
import {IPoolV1} from "../interfaces/IPool.sol";
import {IRMN} from "../interfaces/IRMN.sol";
import {IRouter} from "../interfaces/IRouter.sol";
import {Ownable2StepMsgSender} from "../../shared/access/Ownable2StepMsgSender.sol";
import {Pool} from "../libraries/Pool.sol";
import {RateLimiter} from "../libraries/RateLimiter.sol";
import {IERC20} from "../../vendor/openzeppelin-solidity/v4.8.3/contracts/token/ERC20/IERC20.sol";
import {IERC20Metadata} from
"../../vendor/openzeppelin-solidity/v4.8.3/contracts/token/ERC20/extensions/IERC20Metadata.sol";
import {IERC165} from "../../vendor/openzeppelin-solidity/v5.0.2/contracts/utils/introspection/IERC165.sol";
import {EnumerableSet} from "../../vendor/openzeppelin-solidity/v5.0.2/contracts/utils/structs/EnumerableSet.sol";
/// @dev This pool supports different decimals on different chains but using this feature could impact the total number
/// of tokens in circulation. Since all of the tokens are locked/burned on the source, and a rounded amount is minted/released on the
/// destination, the number of tokens minted/released could be less than the number of tokens burned/locked. This is because the source
/// chain does not know about the destination token decimals. This is not a problem if the decimals are the same on both
/// chains.
///
/// Example:
/// Assume there is a token with 6 decimals on chain A and 3 decimals on chain B.
/// - 1.234567 tokens are burned on chain A.
/// - 1.234 tokens are minted on chain B.
/// When sending the 1.234 tokens back to chain A, you will receive 1.234000 tokens on chain A, effectively losing
/// 0.000567 tokens.
/// In the case of a burnMint pool on chain A, these funds are burned in the pool on chain A.
/// In the case of a lockRelease pool on chain A, these funds accumulate in the pool on chain A.
abstract contract TokenPool is IPoolV1, Ownable2StepMsgSender {
using EnumerableSet for EnumerableSet.Bytes32Set;
using EnumerableSet for EnumerableSet.AddressSet;
using EnumerableSet for EnumerableSet.UintSet;
using RateLimiter for RateLimiter.TokenBucket;
error CallerIsNotARampOnRouter(address caller);
error ZeroAddressNotAllowed();
error SenderNotAllowed(address sender);
error AllowListNotEnabled();
error NonExistentChain(uint64 remoteChainSelector);
error ChainNotAllowed(uint64 remoteChainSelector);
error CursedByRMN();
error ChainAlreadyExists(uint64 chainSelector);
error InvalidSourcePoolAddress(bytes sourcePoolAddress);
error InvalidToken(address token);
error Unauthorized(address caller);
error PoolAlreadyAdded(uint64 remoteChainSelector, bytes remotePoolAddress);
error InvalidRemotePoolForChain(uint64 remoteChainSelector, bytes remotePoolAddress);
error InvalidRemoteChainDecimals(bytes sourcePoolData);
error OverflowDetected(uint8 remoteDecimals, uint8 localDecimals, uint256 remoteAmount);
error InvalidDecimalArgs(uint8 expected, uint8 actual);
event Locked(address indexed sender, uint256 amount);
event Burned(address indexed sender, uint256 amount);
event Released(address indexed sender, address indexed recipient, uint256 amount);
event Minted(address indexed sender, address indexed recipient, uint256 amount);
event ChainAdded(
uint64 remoteChainSelector,
bytes remoteToken,
RateLimiter.Config outboundRateLimiterConfig,
RateLimiter.Config inboundRateLimiterConfig
);
event ChainConfigured(
uint64 remoteChainSelector,
RateLimiter.Config outboundRateLimiterConfig,
RateLimiter.Config inboundRateLimiterConfig
);
event ChainRemoved(uint64 remoteChainSelector);
event RemotePoolAdded(uint64 indexed remoteChainSelector, bytes remotePoolAddress);
event RemotePoolRemoved(uint64 indexed remoteChainSelector, bytes remotePoolAddress);
event AllowListAdd(address sender);
event AllowListRemove(address sender);
event RouterUpdated(address oldRouter, address newRouter);
event RateLimitAdminSet(address rateLimitAdmin);
struct ChainUpdate {
uint64 remoteChainSelector; // Remote chain selector
bytes[] remotePoolAddresses; // Address of the remote pool, ABI encoded in the case of a remote EVM chain.
bytes remoteTokenAddress; // Address of the remote token, ABI encoded in the case of a remote EVM chain.
RateLimiter.Config outboundRateLimiterConfig; // Outbound rate limited config, meaning the rate limits for all of the onRamps for the given chain
RateLimiter.Config inboundRateLimiterConfig; // Inbound rate limited config, meaning the rate limits for all of the offRamps for the given chain
}
struct RemoteChainConfig {
RateLimiter.TokenBucket outboundRateLimiterConfig; // Outbound rate limited config, meaning the rate limits for all of the onRamps for the given chain
RateLimiter.TokenBucket inboundRateLimiterConfig; // Inbound rate limited config, meaning the rate limits for all of the offRamps for the given chain
bytes remoteTokenAddress; // Address of the remote token, ABI encoded in the case of a remote EVM chain.
EnumerableSet.Bytes32Set remotePools; // Set of remote pool hashes, ABI encoded in the case of a remote EVM chain.
}
/// @dev The bridgeable token that is managed by this pool. Pools could support multiple tokens at the same time if
/// required, but this implementation only supports one token.
IERC20 internal immutable i_token;
/// @dev The number of decimals of the token managed by this pool.
uint8 internal immutable i_tokenDecimals;
/// @dev The address of the RMN proxy
address internal immutable i_rmnProxy;
/// @dev The immutable flag that indicates if the pool is access-controlled.
bool internal immutable i_allowlistEnabled;
/// @dev A set of addresses allowed to trigger lockOrBurn as original senders.
/// Only takes effect if i_allowlistEnabled is true.
/// This can be used to ensure only token-issuer specified addresses can move tokens.
EnumerableSet.AddressSet internal s_allowlist;
/// @dev The address of the router
IRouter internal s_router;
/// @dev A set of allowed chain selectors. We want the allowlist to be enumerable to
/// be able to quickly determine (without parsing logs) who can access the pool.
/// @dev The chain selectors are in uint256 format because of the EnumerableSet implementation.
EnumerableSet.UintSet internal s_remoteChainSelectors;
mapping(uint64 remoteChainSelector => RemoteChainConfig) internal s_remoteChainConfigs;
/// @notice A mapping of hashed pool addresses to their unhashed form. This is used to be able to find the actually
/// configured pools and not just their hashed versions.
mapping(bytes32 poolAddressHash => bytes poolAddress) internal s_remotePoolAddresses;
/// @notice The address of the rate limiter admin.
/// @dev Can be address(0) if none is configured.
address internal s_rateLimitAdmin;
constructor(IERC20 token, uint8 localTokenDecimals, address[] memory allowlist, address rmnProxy, address router) {
if (address(token) == address(0) || router == address(0) || rmnProxy == address(0)) revert ZeroAddressNotAllowed();
i_token = token;
i_rmnProxy = rmnProxy;
try IERC20Metadata(address(token)).decimals() returns (uint8 actualTokenDecimals) {
if (localTokenDecimals != actualTokenDecimals) {
revert InvalidDecimalArgs(localTokenDecimals, actualTokenDecimals);
}
} catch {
// The decimals function doesn't exist, which is possible since it's optional in the ERC20 spec. We skip the check and
// assume the supplied token decimals are correct.
}
i_tokenDecimals = localTokenDecimals;
s_router = IRouter(router);
// Pool can be set as permissioned or permissionless at deployment time only to save hot-path gas.
i_allowlistEnabled = allowlist.length > 0;
if (i_allowlistEnabled) {
_applyAllowListUpdates(new address[](0), allowlist);
}
}
/// @inheritdoc IPoolV1
function isSupportedToken(
address token
) public view virtual returns (bool) {
return token == address(i_token);
}
/// @notice Gets the IERC20 token that this pool can lock or burn.
/// @return token The IERC20 token representation.
function getToken() public view returns (IERC20 token) {
return i_token;
}
/// @notice Get RMN proxy address
/// @return rmnProxy Address of RMN proxy
function getRmnProxy() public view returns (address rmnProxy) {
return i_rmnProxy;
}
/// @notice Gets the pool's Router
/// @return router The pool's Router
function getRouter() public view returns (address router) {
return address(s_router);
}
/// @notice Sets the pool's Router
/// @param newRouter The new Router
function setRouter(
address newRouter
) public onlyOwner {
if (newRouter == address(0)) revert ZeroAddressNotAllowed();
address oldRouter = address(s_router);
s_router = IRouter(newRouter);
emit RouterUpdated(oldRouter, newRouter);
}
/// @notice Signals which version of the pool interface is supported
function supportsInterface(
bytes4 interfaceId
) public pure virtual override returns (bool) {
return interfaceId == Pool.CCIP_POOL_V1 || interfaceId == type(IPoolV1).interfaceId
|| interfaceId == type(IERC165).interfaceId;
}
// ================================================================
// ¦ Validation ¦
// ================================================================
/// @notice Validates the lock or burn input for correctness on
/// - token to be locked or burned
/// - RMN curse status
/// - allowlist status
/// - if the sender is a valid onRamp
/// - rate limit status
/// @param lockOrBurnIn The input to validate.
/// @dev This function should always be called before executing a lock or burn. Not doing so would allow
/// for various exploits.
function _validateLockOrBurn(
Pool.LockOrBurnInV1 calldata lockOrBurnIn
) internal {
if (!isSupportedToken(lockOrBurnIn.localToken)) revert InvalidToken(lockOrBurnIn.localToken);
if (IRMN(i_rmnProxy).isCursed(bytes16(uint128(lockOrBurnIn.remoteChainSelector)))) revert CursedByRMN();
_checkAllowList(lockOrBurnIn.originalSender);
_onlyOnRamp(lockOrBurnIn.remoteChainSelector);
_consumeOutboundRateLimit(lockOrBurnIn.remoteChainSelector, lockOrBurnIn.amount);
}
/// @notice Validates the release or mint input for correctness on
/// - token to be released or minted
/// - RMN curse status
/// - if the sender is a valid offRamp
/// - if the source pool is valid
/// - rate limit status
/// @param releaseOrMintIn The input to validate.
/// @dev This function should always be called before executing a release or mint. Not doing so would allow
/// for various exploits.
function _validateReleaseOrMint(
Pool.ReleaseOrMintInV1 calldata releaseOrMintIn
) internal {
if (!isSupportedToken(releaseOrMintIn.localToken)) revert InvalidToken(releaseOrMintIn.localToken);
if (IRMN(i_rmnProxy).isCursed(bytes16(uint128(releaseOrMintIn.remoteChainSelector)))) revert CursedByRMN();
_onlyOffRamp(releaseOrMintIn.remoteChainSelector);
// Validates that the source pool address is configured on this pool.
if (!isRemotePool(releaseOrMintIn.remoteChainSelector, releaseOrMintIn.sourcePoolAddress)) {
revert InvalidSourcePoolAddress(releaseOrMintIn.sourcePoolAddress);
}
_consumeInboundRateLimit(releaseOrMintIn.remoteChainSelector, releaseOrMintIn.amount);
}
// ================================================================
// ¦ Token decimals ¦
// ================================================================
/// @notice Gets the IERC20 token decimals on the local chain.
function getTokenDecimals() public view virtual returns (uint8 decimals) {
return i_tokenDecimals;
}
function _encodeLocalDecimals() internal view virtual returns (bytes memory) {
return abi.encode(i_tokenDecimals);
}
function _parseRemoteDecimals(
bytes memory sourcePoolData
) internal view virtual returns (uint8) {
// Fallback to the local token decimals if the source pool data is empty. This allows for backwards compatibility.
if (sourcePoolData.length == 0) {
return i_tokenDecimals;
}
if (sourcePoolData.length != 32) {
revert InvalidRemoteChainDecimals(sourcePoolData);
}
uint256 remoteDecimals = abi.decode(sourcePoolData, (uint256));
if (remoteDecimals > type(uint8).max) {
revert InvalidRemoteChainDecimals(sourcePoolData);
}
return uint8(remoteDecimals);
}
/// @notice Calculates the local amount based on the remote amount and decimals.
/// @param remoteAmount The amount on the remote chain.
/// @param remoteDecimals The decimals of the token on the remote chain.
/// @return The local amount.
/// @dev This function protects against overflows. If there is a transaction that hits the overflow check, it is
/// probably incorrect as that means the amount cannot be represented on this chain. If the local decimals have been
/// wrongly configured, the token issuer could redeploy the pool with the correct decimals and manually re-execute the
/// CCIP tx to fix the issue.
function _calculateLocalAmount(uint256 remoteAmount, uint8 remoteDecimals) internal view virtual returns (uint256) {
if (remoteDecimals == i_tokenDecimals) {
return remoteAmount;
}
if (remoteDecimals > i_tokenDecimals) {
uint8 decimalsDiff = remoteDecimals - i_tokenDecimals;
if (decimalsDiff > 77) {
// This is a safety check to prevent overflow in the next calculation.
revert OverflowDetected(remoteDecimals, i_tokenDecimals, remoteAmount);
}
// Solidity rounds down so there is no risk of minting more tokens than the remote chain sent.
return remoteAmount / (10 ** decimalsDiff);
}
// This is a safety check to prevent overflow in the next calculation.
// More than 77 would never fit in a uint256 and would cause an overflow. We also check if the resulting amount
// would overflow.
uint8 diffDecimals = i_tokenDecimals - remoteDecimals;
if (diffDecimals > 77 || remoteAmount > type(uint256).max / (10 ** diffDecimals)) {
revert OverflowDetected(remoteDecimals, i_tokenDecimals, remoteAmount);
}
return remoteAmount * (10 ** diffDecimals);
}
// ================================================================
// ¦ Chain permissions ¦
// ================================================================
/// @notice Gets the pool address on the remote chain.
/// @param remoteChainSelector Remote chain selector.
/// @dev To support non-evm chains, this value is encoded into bytes
function getRemotePools(
uint64 remoteChainSelector
) public view returns (bytes[] memory) {
bytes32[] memory remotePoolHashes = s_remoteChainConfigs[remoteChainSelector].remotePools.values();
bytes[] memory remotePools = new bytes[](remotePoolHashes.length);
for (uint256 i = 0; i < remotePoolHashes.length; ++i) {
remotePools[i] = s_remotePoolAddresses[remotePoolHashes[i]];
}
return remotePools;
}
/// @notice Checks if the pool address is configured on the remote chain.
/// @param remoteChainSelector Remote chain selector.
/// @param remotePoolAddress The address of the remote pool.
function isRemotePool(uint64 remoteChainSelector, bytes calldata remotePoolAddress) public view returns (bool) {
return s_remoteChainConfigs[remoteChainSelector].remotePools.contains(keccak256(remotePoolAddress));
}
/// @notice Gets the token address on the remote chain.
/// @param remoteChainSelector Remote chain selector.
/// @dev To support non-evm chains, this value is encoded into bytes
function getRemoteToken(
uint64 remoteChainSelector
) public view returns (bytes memory) {
return s_remoteChainConfigs[remoteChainSelector].remoteTokenAddress;
}
/// @notice Adds a remote pool for a given chain selector. This could be due to a pool being upgraded on the remote
/// chain. We don't simply want to replace the old pool as there could still be valid inflight messages from the old
/// pool. This function allows for multiple pools to be added for a single chain selector.
/// @param remoteChainSelector The remote chain selector for which the remote pool address is being added.
/// @param remotePoolAddress The address of the new remote pool.
function addRemotePool(uint64 remoteChainSelector, bytes calldata remotePoolAddress) external onlyOwner {
if (!isSupportedChain(remoteChainSelector)) revert NonExistentChain(remoteChainSelector);
_setRemotePool(remoteChainSelector, remotePoolAddress);
}
/// @notice Removes the remote pool address for a given chain selector.
/// @dev All inflight txs from the remote pool will be rejected after it is removed. To ensure no loss of funds, there
/// should be no inflight txs from the given pool.
function removeRemotePool(uint64 remoteChainSelector, bytes calldata remotePoolAddress) external onlyOwner {
if (!isSupportedChain(remoteChainSelector)) revert NonExistentChain(remoteChainSelector);
if (!s_remoteChainConfigs[remoteChainSelector].remotePools.remove(keccak256(remotePoolAddress))) {
revert InvalidRemotePoolForChain(remoteChainSelector, remotePoolAddress);
}
emit RemotePoolRemoved(remoteChainSelector, remotePoolAddress);
}
/// @inheritdoc IPoolV1
function isSupportedChain(
uint64 remoteChainSelector
) public view returns (bool) {
return s_remoteChainSelectors.contains(remoteChainSelector);
}
/// @notice Get list of allowed chains
/// @return list of chains.
function getSupportedChains() public view returns (uint64[] memory) {
uint256[] memory uint256ChainSelectors = s_remoteChainSelectors.values();
uint64[] memory chainSelectors = new uint64[](uint256ChainSelectors.length);
for (uint256 i = 0; i < uint256ChainSelectors.length; ++i) {
chainSelectors[i] = uint64(uint256ChainSelectors[i]);
}
return chainSelectors;
}
/// @notice Sets the permissions for a list of chains selectors. Actual senders for these chains
/// need to be allowed on the Router to interact with this pool.
/// @param remoteChainSelectorsToRemove A list of chain selectors to remove.
/// @param chainsToAdd A list of chains and their new permission status & rate limits. Rate limits
/// are only used when the chain is being added through `allowed` being true.
/// @dev Only callable by the owner
function applyChainUpdates(
uint64[] calldata remoteChainSelectorsToRemove,
ChainUpdate[] calldata chainsToAdd
) external virtual onlyOwner {
for (uint256 i = 0; i < remoteChainSelectorsToRemove.length; ++i) {
uint64 remoteChainSelectorToRemove = remoteChainSelectorsToRemove[i];
// If the chain doesn't exist, revert
if (!s_remoteChainSelectors.remove(remoteChainSelectorToRemove)) {
revert NonExistentChain(remoteChainSelectorToRemove);
}
// Remove all remote pool hashes for the chain
bytes32[] memory remotePools = s_remoteChainConfigs[remoteChainSelectorToRemove].remotePools.values();
for (uint256 j = 0; j < remotePools.length; ++j) {
s_remoteChainConfigs[remoteChainSelectorToRemove].remotePools.remove(remotePools[j]);
}
delete s_remoteChainConfigs[remoteChainSelectorToRemove];
emit ChainRemoved(remoteChainSelectorToRemove);
}
for (uint256 i = 0; i < chainsToAdd.length; ++i) {
ChainUpdate memory newChain = chainsToAdd[i];
RateLimiter._validateTokenBucketConfig(newChain.outboundRateLimiterConfig, false);
RateLimiter._validateTokenBucketConfig(newChain.inboundRateLimiterConfig, false);
if (newChain.remoteTokenAddress.length == 0) {
revert ZeroAddressNotAllowed();
}
// If the chain already exists, revert
if (!s_remoteChainSelectors.add(newChain.remoteChainSelector)) {
revert ChainAlreadyExists(newChain.remoteChainSelector);
}
RemoteChainConfig storage remoteChainConfig = s_remoteChainConfigs[newChain.remoteChainSelector];
remoteChainConfig.outboundRateLimiterConfig = RateLimiter.TokenBucket({
rate: newChain.outboundRateLimiterConfig.rate,
capacity: newChain.outboundRateLimiterConfig.capacity,
tokens: newChain.outboundRateLimiterConfig.capacity,
lastUpdated: uint32(block.timestamp),
isEnabled: newChain.outboundRateLimiterConfig.isEnabled
});
remoteChainConfig.inboundRateLimiterConfig = RateLimiter.TokenBucket({
rate: newChain.inboundRateLimiterConfig.rate,
capacity: newChain.inboundRateLimiterConfig.capacity,
tokens: newChain.inboundRateLimiterConfig.capacity,
lastUpdated: uint32(block.timestamp),
isEnabled: newChain.inboundRateLimiterConfig.isEnabled
});
remoteChainConfig.remoteTokenAddress = newChain.remoteTokenAddress;
for (uint256 j = 0; j < newChain.remotePoolAddresses.length; ++j) {
_setRemotePool(newChain.remoteChainSelector, newChain.remotePoolAddresses[j]);
}
emit ChainAdded(
newChain.remoteChainSelector,
newChain.remoteTokenAddress,
newChain.outboundRateLimiterConfig,
newChain.inboundRateLimiterConfig
);
}
}
/// @notice Adds a pool address to the allowed remote token pools for a particular chain.
/// @param remoteChainSelector The remote chain selector for which the remote pool address is being added.
/// @param remotePoolAddress The address of the new remote pool.
function _setRemotePool(uint64 remoteChainSelector, bytes memory remotePoolAddress) internal {
if (remotePoolAddress.length == 0) {
revert ZeroAddressNotAllowed();
}
bytes32 poolHash = keccak256(remotePoolAddress);
// Check if the pool already exists.
if (!s_remoteChainConfigs[remoteChainSelector].remotePools.add(poolHash)) {
revert PoolAlreadyAdded(remoteChainSelector, remotePoolAddress);
}
// Add the pool to the mapping to be able to un-hash it later.
s_remotePoolAddresses[poolHash] = remotePoolAddress;
emit RemotePoolAdded(remoteChainSelector, remotePoolAddress);
}
// ================================================================
// ¦ Rate limiting ¦
// ================================================================
/// @dev The inbound rate limits should be slightly higher than the outbound rate limits. This is because many chains
/// finalize blocks in batches. CCIP also commits messages in batches: the commit plugin bundles multiple messages in
/// a single merkle root.
/// Imagine the following scenario.
/// - Chain A has an inbound and outbound rate limit of 100 tokens capacity and 1 token per second refill rate.
/// - Chain B has an inbound and outbound rate limit of 100 tokens capacity and 1 token per second refill rate.
///
/// At time 0:
/// - Chain A sends 100 tokens to Chain B.
/// At time 5:
/// - Chain A sends 5 tokens to Chain B.
/// At time 6:
/// The epoch that contains blocks [0-5] is finalized.
/// Both transactions will be included in the same merkle root and become executable at the same time. This means
/// the token pool on chain B requires a capacity of 105 to successfully execute both messages at the same time.
/// The exact additional capacity required depends on the refill rate and the size of the source chain epochs and the
/// CCIP round time. For simplicity, a 5-10% buffer should be sufficient in most cases.
/// @notice Sets the rate limiter admin address.
/// @dev Only callable by the owner.
/// @param rateLimitAdmin The new rate limiter admin address.
function setRateLimitAdmin(
address rateLimitAdmin
) external onlyOwner {
s_rateLimitAdmin = rateLimitAdmin;
emit RateLimitAdminSet(rateLimitAdmin);
}
/// @notice Gets the rate limiter admin address.
function getRateLimitAdmin() external view returns (address) {
return s_rateLimitAdmin;
}
/// @notice Consumes outbound rate limiting capacity in this pool
function _consumeOutboundRateLimit(uint64 remoteChainSelector, uint256 amount) internal {
s_remoteChainConfigs[remoteChainSelector].outboundRateLimiterConfig._consume(amount, address(i_token));
}
/// @notice Consumes inbound rate limiting capacity in this pool
function _consumeInboundRateLimit(uint64 remoteChainSelector, uint256 amount) internal {
s_remoteChainConfigs[remoteChainSelector].inboundRateLimiterConfig._consume(amount, address(i_token));
}
/// @notice Gets the token bucket with its values for the block it was requested at.
/// @return The token bucket.
function getCurrentOutboundRateLimiterState(
uint64 remoteChainSelector
) external view returns (RateLimiter.TokenBucket memory) {
return s_remoteChainConfigs[remoteChainSelector].outboundRateLimiterConfig._currentTokenBucketState();
}
/// @notice Gets the token bucket with its values for the block it was requested at.
/// @return The token bucket.
function getCurrentInboundRateLimiterState(
uint64 remoteChainSelector
) external view returns (RateLimiter.TokenBucket memory) {
return s_remoteChainConfigs[remoteChainSelector].inboundRateLimiterConfig._currentTokenBucketState();
}
/// @notice Sets the chain rate limiter config.
/// @param remoteChainSelector The remote chain selector for which the rate limits apply.
/// @param outboundConfig The new outbound rate limiter config, meaning the onRamp rate limits for the given chain.
/// @param inboundConfig The new inbound rate limiter config, meaning the offRamp rate limits for the given chain.
function setChainRateLimiterConfig(
uint64 remoteChainSelector,
RateLimiter.Config memory outboundConfig,
RateLimiter.Config memory inboundConfig
) external {
if (msg.sender != s_rateLimitAdmin && msg.sender != owner()) revert Unauthorized(msg.sender);
_setRateLimitConfig(remoteChainSelector, outboundConfig, inboundConfig);
}
function _setRateLimitConfig(
uint64 remoteChainSelector,
RateLimiter.Config memory outboundConfig,
RateLimiter.Config memory inboundConfig
) internal {
if (!isSupportedChain(remoteChainSelector)) revert NonExistentChain(remoteChainSelector);
RateLimiter._validateTokenBucketConfig(outboundConfig, false);
s_remoteChainConfigs[remoteChainSelector].outboundRateLimiterConfig._setTokenBucketConfig(outboundConfig);
RateLimiter._validateTokenBucketConfig(inboundConfig, false);
s_remoteChainConfigs[remoteChainSelector].inboundRateLimiterConfig._setTokenBucketConfig(inboundConfig);
emit ChainConfigured(remoteChainSelector, outboundConfig, inboundConfig);
}
// ================================================================
// ¦ Access ¦
// ================================================================
/// @notice Checks whether remote chain selector is configured on this contract, and if the msg.sender
/// is a permissioned onRamp for the given chain on the Router.
function _onlyOnRamp(
uint64 remoteChainSelector
) internal view {
if (!isSupportedChain(remoteChainSelector)) revert ChainNotAllowed(remoteChainSelector);
if (!(msg.sender == s_router.getOnRamp(remoteChainSelector))) revert CallerIsNotARampOnRouter(msg.sender);
}
/// @notice Checks whether remote chain selector is configured on this contract, and if the msg.sender
/// is a permissioned offRamp for the given chain on the Router.
function _onlyOffRamp(
uint64 remoteChainSelector
) internal view {
if (!isSupportedChain(remoteChainSelector)) revert ChainNotAllowed(remoteChainSelector);
if (!s_router.isOffRamp(remoteChainSelector, msg.sender)) revert CallerIsNotARampOnRouter(msg.sender);
}
// ================================================================
// ¦ Allowlist ¦
// ================================================================
function _checkAllowList(
address sender
) internal view {
if (i_allowlistEnabled) {
if (!s_allowlist.contains(sender)) {
revert SenderNotAllowed(sender);
}
}
}
/// @notice Gets whether the allowlist functionality is enabled.
/// @return true is enabled, false if not.
function getAllowListEnabled() external view returns (bool) {
return i_allowlistEnabled;
}
/// @notice Gets the allowed addresses.
/// @return The allowed addresses.
function getAllowList() external view returns (address[] memory) {
return s_allowlist.values();
}
/// @notice Apply updates to the allow list.
/// @param removes The addresses to be removed.
/// @param adds The addresses to be added.
function applyAllowListUpdates(address[] calldata removes, address[] calldata adds) external onlyOwner {
_applyAllowListUpdates(removes, adds);
}
/// @notice Internal version of applyAllowListUpdates to allow for reuse in the constructor.
function _applyAllowListUpdates(address[] memory removes, address[] memory adds) internal {
if (!i_allowlistEnabled) revert AllowListNotEnabled();
for (uint256 i = 0; i < removes.length; ++i) {
address toRemove = removes[i];
if (s_allowlist.remove(toRemove)) {
emit AllowListRemove(toRemove);
}
}
for (uint256 i = 0; i < adds.length; ++i) {
address toAdd = adds[i];
if (toAdd == address(0)) {
continue;
}
if (s_allowlist.add(toAdd)) {
emit AllowListAdd(toAdd);
}
}
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
/**
* @dev Collection of common custom errors used in multiple contracts
*
* IMPORTANT: Backwards compatibility is not guaranteed in future versions of the library.
* It is recommended to avoid relying on the error API for critical functionality.
*/
library Errors {
/**
* @dev The ETH balance of the account is not enough to perform the operation.
*/
error InsufficientBalance(uint256 balance, uint256 needed);
/**
* @dev A call to an address target failed. The target may have reverted.
*/
error FailedCall();
/**
* @dev The deployment failed.
*/
error FailedDeployment();
/**
* @dev A necessary precompile is missing.
*/
error MissingPrecompile(address);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Create2.sol)
pragma solidity ^0.8.20;
import {Errors} from "./Errors.sol";
/**
* @dev Helper to make usage of the `CREATE2` EVM opcode easier and safer.
* `CREATE2` can be used to compute in advance the address where a smart
* contract will be deployed, which allows for interesting new mechanisms known
* as 'counterfactual interactions'.
*
* See the https://eips.ethereum.org/EIPS/eip-1014#motivation[EIP] for more
* information.
*/
library Create2 {
/**
* @dev There's no code to deploy.
*/
error Create2EmptyBytecode();
/**
* @dev Deploys a contract using `CREATE2`. The address where the contract
* will be deployed can be known in advance via {computeAddress}.
*
* The bytecode for a contract can be obtained from Solidity with
* `type(contractName).creationCode`.
*
* Requirements:
*
* - `bytecode` must not be empty.
* - `salt` must have not been used for `bytecode` already.
* - the factory must have a balance of at least `amount`.
* - if `amount` is non-zero, `bytecode` must have a `payable` constructor.
*/
function deploy(uint256 amount, bytes32 salt, bytes memory bytecode) internal returns (address addr) {
if (address(this).balance < amount) {
revert Errors.InsufficientBalance(address(this).balance, amount);
}
if (bytecode.length == 0) {
revert Create2EmptyBytecode();
}
assembly ("memory-safe") {
addr := create2(amount, add(bytecode, 0x20), mload(bytecode), salt)
// if no address was created, and returndata is not empty, bubble revert
if and(iszero(addr), not(iszero(returndatasize()))) {
let p := mload(0x40)
returndatacopy(p, 0, returndatasize())
revert(p, returndatasize())
}
}
if (addr == address(0)) {
revert Errors.FailedDeployment();
}
}
/**
* @dev Returns the address where a contract will be stored if deployed via {deploy}. Any change in the
* `bytecodeHash` or `salt` will result in a new destination address.
*/
function computeAddress(bytes32 salt, bytes32 bytecodeHash) internal view returns (address) {
return computeAddress(salt, bytecodeHash, address(this));
}
/**
* @dev Returns the address where a contract will be stored if deployed via {deploy} from a contract located at
* `deployer`. If `deployer` is this contract's address, returns the same value as {computeAddress}.
*/
function computeAddress(bytes32 salt, bytes32 bytecodeHash, address deployer) internal pure returns (address addr) {
assembly ("memory-safe") {
let ptr := mload(0x40) // Get free memory pointer
// | | ? ptr ... ? ptr + 0x0B (start) ... ? ptr + 0x20 ... ? ptr + 0x40 ... |
// |-------------------|---------------------------------------------------------------------------|
// | bytecodeHash | CCCCCCCCCCCCC...CC |
// | salt | BBBBBBBBBBBBB...BB |
// | deployer | 000000...0000AAAAAAAAAAAAAAAAAAA...AA |
// | 0xFF | FF |
// |-------------------|---------------------------------------------------------------------------|
// | memory | 000000...00FFAAAAAAAAAAAAAAAAAAA...AABBBBBBBBBBBBB...BBCCCCCCCCCCCCC...CC |
// | keccak(start, 85) | ?????????????????????????????????????????????????????????????? |
mstore(add(ptr, 0x40), bytecodeHash)
mstore(add(ptr, 0x20), salt)
mstore(ptr, deployer) // Right-aligned with 12 preceding garbage bytes
let start := add(ptr, 0x0b) // The hashed data starts at the final garbage byte which we will set to 0xff
mstore8(start, 0xff)
addr := and(keccak256(start, 85), 0xffffffffffffffffffffffffffffffffffffffff)
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/extensions/ERC20Burnable.sol)
pragma solidity ^0.8.0;
import "../ERC20.sol";
import "../../../utils/Context.sol";
/**
* @dev Extension of {ERC20} that allows token holders to destroy both their own
* tokens and those that they have an allowance for, in a way that can be
* recognized off-chain (via event analysis).
*/
abstract contract ERC20Burnable is Context, ERC20 {
/**
* @dev Destroys `amount` tokens from the caller.
*
* See {ERC20-_burn}.
*/
function burn(uint256 amount) public virtual {
_burn(_msgSender(), amount);
}
/**
* @dev Destroys `amount` tokens from `account`, deducting from the caller's
* allowance.
*
* See {ERC20-_burn} and {ERC20-allowance}.
*
* Requirements:
*
* - the caller must have allowance for ``accounts``'s tokens of at least
* `amount`.
*/
function burnFrom(address account, uint256 amount) public virtual {
_spendAllowance(account, _msgSender(), amount);
_burn(account, amount);
}
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.24;
import {ITypeAndVersion} from "../../shared/interfaces/ITypeAndVersion.sol";
import {IGetCCIPAdmin} from "../interfaces/IGetCCIPAdmin.sol";
import {IOwner} from "../interfaces/IOwner.sol";
import {ITokenAdminRegistry} from "../interfaces/ITokenAdminRegistry.sol";
import {AccessControl} from "../../vendor/openzeppelin-solidity/v5.0.2/contracts/access/AccessControl.sol";
contract RegistryModuleOwnerCustom is ITypeAndVersion {
error CanOnlySelfRegister(address admin, address token);
error RequiredRoleNotFound(address msgSender, bytes32 role, address token);
error AddressZero();
event AdministratorRegistered(address indexed token, address indexed administrator);
string public constant override typeAndVersion = "RegistryModuleOwnerCustom 1.6.0";
// The TokenAdminRegistry contract
ITokenAdminRegistry internal immutable i_tokenAdminRegistry;
constructor(
address tokenAdminRegistry
) {
if (tokenAdminRegistry == address(0)) {
revert AddressZero();
}
i_tokenAdminRegistry = ITokenAdminRegistry(tokenAdminRegistry);
}
/// @notice Registers the admin of the token using the `getCCIPAdmin` method.
/// @param token The token to register the admin for.
/// @dev The caller must be the admin returned by the `getCCIPAdmin` method.
function registerAdminViaGetCCIPAdmin(
address token
) external {
_registerAdmin(token, IGetCCIPAdmin(token).getCCIPAdmin());
}
/// @notice Registers the admin of the token using the `owner` method.
/// @param token The token to register the admin for.
/// @dev The caller must be the admin returned by the `owner` method.
function registerAdminViaOwner(
address token
) external {
_registerAdmin(token, IOwner(token).owner());
}
/// @notice Registers the admin of the token using OZ's AccessControl DEFAULT_ADMIN_ROLE.
/// @param token The token to register the admin for.
/// @dev The caller must have the DEFAULT_ADMIN_ROLE as defined by the contract itself.
function registerAccessControlDefaultAdmin(
address token
) external {
bytes32 defaultAdminRole = AccessControl(token).DEFAULT_ADMIN_ROLE();
if (!AccessControl(token).hasRole(defaultAdminRole, msg.sender)) {
revert RequiredRoleNotFound(msg.sender, defaultAdminRole, token);
}
_registerAdmin(token, msg.sender);
}
/// @notice Registers the admin of the token to msg.sender given that the
/// admin is equal to msg.sender.
/// @param token The token to register the admin for.
/// @param admin The caller must be the admin.
function _registerAdmin(address token, address admin) internal {
if (admin != msg.sender) {
revert CanOnlySelfRegister(admin, token);
}
i_tokenAdminRegistry.proposeAdministrator(token, admin);
emit AdministratorRegistered(token, admin);
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {Pool} from "../libraries/Pool.sol";
import {IERC165} from "../../vendor/openzeppelin-solidity/v5.0.2/contracts/utils/introspection/IERC165.sol";
/// @notice Shared public interface for multiple V1 pool types.
/// Each pool type handles a different child token model (lock/unlock, mint/burn.)
interface IPoolV1 is IERC165 {
/// @notice Lock tokens into the pool or burn the tokens.
/// @param lockOrBurnIn Encoded data fields for the processing of tokens on the source chain.
/// @return lockOrBurnOut Encoded data fields for the processing of tokens on the destination chain.
function lockOrBurn(
Pool.LockOrBurnInV1 calldata lockOrBurnIn
) external returns (Pool.LockOrBurnOutV1 memory lockOrBurnOut);
/// @notice Releases or mints tokens to the receiver address.
/// @param releaseOrMintIn All data required to release or mint tokens.
/// @return releaseOrMintOut The amount of tokens released or minted on the local chain, denominated
/// in the local token's decimals.
/// @dev The offramp asserts that the balanceOf of the receiver has been incremented by exactly the number
/// of tokens that is returned in ReleaseOrMintOutV1.destinationAmount. If the amounts do not match, the tx reverts.
function releaseOrMint(
Pool.ReleaseOrMintInV1 calldata releaseOrMintIn
) external returns (Pool.ReleaseOrMintOutV1 memory);
/// @notice Checks whether a remote chain is supported in the token pool.
/// @param remoteChainSelector The selector of the remote chain.
/// @return true if the given chain is a permissioned remote chain.
function isSupportedChain(
uint64 remoteChainSelector
) external view returns (bool);
/// @notice Returns if the token pool supports the given token.
/// @param token The address of the token.
/// @return true if the token is supported by the pool.
function isSupportedToken(
address token
) external view returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)
pragma solidity ^0.8.20;
/**
* @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 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) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface ITypeAndVersion {
function typeAndVersion() external pure returns (string memory);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^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 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) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.24;
import {IGetCCIPAdmin} from "../../../ccip/interfaces/IGetCCIPAdmin.sol";
import {IOwnable} from "../../../shared/interfaces/IOwnable.sol";
import {IBurnMintERC20} from "../../../shared/token/ERC20/IBurnMintERC20.sol";
import {Ownable2StepMsgSender} from "../../../shared/access/Ownable2StepMsgSender.sol";
import {ERC20} from "../../../vendor/openzeppelin-solidity/v4.8.3/contracts/token/ERC20/ERC20.sol";
import {IERC20} from "../../../vendor/openzeppelin-solidity/v4.8.3/contracts/token/ERC20/IERC20.sol";
import {ERC20Burnable} from
"../../../vendor/openzeppelin-solidity/v4.8.3/contracts/token/ERC20/extensions/ERC20Burnable.sol";
import {IERC165} from "../../../vendor/openzeppelin-solidity/v4.8.3/contracts/utils/introspection/IERC165.sol";
import {EnumerableSet} from "../../../vendor/openzeppelin-solidity/v4.8.3/contracts/utils/structs/EnumerableSet.sol";
/// @notice A basic ERC20 compatible token contract with burn and minting roles.
/// @dev The constructor has been modified to support the deployment pattern used by a factory contract.
/// @dev The total supply can be limited during deployment.
contract FactoryBurnMintERC20 is IBurnMintERC20, IGetCCIPAdmin, IERC165, ERC20Burnable, Ownable2StepMsgSender {
using EnumerableSet for EnumerableSet.AddressSet;
error SenderNotMinter(address sender);
error SenderNotBurner(address sender);
error MaxSupplyExceeded(uint256 supplyAfterMint);
event MintAccessGranted(address minter);
event BurnAccessGranted(address burner);
event MintAccessRevoked(address minter);
event BurnAccessRevoked(address burner);
event CCIPAdminTransferred(address indexed previousAdmin, address indexed newAdmin);
/// @dev The number of decimals for the token
uint8 internal immutable i_decimals;
/// @dev The maximum supply of the token, 0 if unlimited
uint256 internal immutable i_maxSupply;
/// @dev the CCIPAdmin can be used to register with the CCIP token admin registry, but has no other special powers,
/// and can only be transferred by the owner.
address internal s_ccipAdmin;
/// @dev the allowed minter addresses
EnumerableSet.AddressSet internal s_minters;
/// @dev the allowed burner addresses
EnumerableSet.AddressSet internal s_burners;
/// @dev the underscores in parameter names are used to suppress compiler warnings about shadowing ERC20 functions
constructor(
string memory name,
string memory symbol,
uint8 decimals_,
uint256 maxSupply_,
uint256 preMint,
address newOwner
) ERC20(name, symbol) {
i_decimals = decimals_;
i_maxSupply = maxSupply_;
s_ccipAdmin = newOwner;
// Mint the initial supply to the new Owner, saving gas by not calling if the mint amount is zero
if (preMint != 0) _mint(newOwner, preMint);
// Grant the deployer the minter and burner roles. This contract is expected to be deployed by a factory
// contract that will transfer ownership to the correct address after deployment, so granting minting and burning
// privileges here saves gas by not requiring two transactions.
grantMintRole(newOwner);
grantBurnRole(newOwner);
}
/// @inheritdoc IERC165
function supportsInterface(
bytes4 interfaceId
) public pure virtual override returns (bool) {
return interfaceId == type(IERC20).interfaceId || interfaceId == type(IBurnMintERC20).interfaceId
|| interfaceId == type(IERC165).interfaceId || interfaceId == type(IOwnable).interfaceId
|| interfaceId == type(IGetCCIPAdmin).interfaceId;
}
// ================================================================
// ¦ ERC20 ¦
// ================================================================
/// @dev Returns the number of decimals used in its user representation.
function decimals() public view virtual override returns (uint8) {
return i_decimals;
}
/// @dev Returns the max supply of the token, 0 if unlimited.
function maxSupply() public view virtual returns (uint256) {
return i_maxSupply;
}
/// @dev Uses OZ ERC20 _transfer to disallow sending to address(0).
/// @dev Disallows sending to address(this)
function _transfer(address from, address to, uint256 amount) internal virtual override validAddress(to) {
super._transfer(from, to, amount);
}
/// @dev Uses OZ ERC20 _approve to disallow approving for address(0).
/// @dev Disallows approving for address(this)
function _approve(address owner, address spender, uint256 amount) internal virtual override validAddress(spender) {
super._approve(owner, spender, amount);
}
/// @dev Exists to be backwards compatible with the older naming convention.
/// @param spender the account being approved to spend on the users' behalf.
/// @param subtractedValue the amount being removed from the approval.
/// @return success Bool to return if the approval was successfully decreased.
function decreaseApproval(address spender, uint256 subtractedValue) external returns (bool success) {
return decreaseAllowance(spender, subtractedValue);
}
/// @dev Exists to be backwards compatible with the older naming convention.
/// @param spender the account being approved to spend on the users' behalf.
/// @param addedValue the amount being added to the approval.
function increaseApproval(address spender, uint256 addedValue) external {
increaseAllowance(spender, addedValue);
}
// ================================================================
// ¦ Burning & minting ¦
// ================================================================
/// @inheritdoc ERC20Burnable
/// @dev Uses OZ ERC20 _burn to disallow burning from address(0).
/// @dev Decreases the total supply.
function burn(
uint256 amount
) public override(IBurnMintERC20, ERC20Burnable) onlyBurner {
super.burn(amount);
}
/// @inheritdoc IBurnMintERC20
/// @dev Alias for BurnFrom for compatibility with the older naming convention.
/// @dev Uses burnFrom for all validation & logic.
function burn(address account, uint256 amount) public virtual override {
burnFrom(account, amount);
}
/// @inheritdoc ERC20Burnable
/// @dev Uses OZ ERC20 _burn to disallow burning from address(0).
/// @dev Decreases the total supply.
function burnFrom(address account, uint256 amount) public override(IBurnMintERC20, ERC20Burnable) onlyBurner {
super.burnFrom(account, amount);
}
/// @inheritdoc IBurnMintERC20
/// @dev Uses OZ ERC20 _mint to disallow minting to address(0).
/// @dev Disallows minting to address(this)
/// @dev Increases the total supply.
function mint(address account, uint256 amount) external override onlyMinter validAddress(account) {
if (i_maxSupply != 0 && totalSupply() + amount > i_maxSupply) revert MaxSupplyExceeded(totalSupply() + amount);
_mint(account, amount);
}
// ================================================================
// ¦ Roles ¦
// ================================================================
/// @notice grants both mint and burn roles to `burnAndMinter`.
/// @dev calls public functions so this function does not require
/// access controls. This is handled in the inner functions.
function grantMintAndBurnRoles(
address burnAndMinter
) external {
grantMintRole(burnAndMinter);
grantBurnRole(burnAndMinter);
}
/// @notice Grants mint role to the given address.
/// @dev only the owner can call this function.
function grantMintRole(
address minter
) public onlyOwner {
if (s_minters.add(minter)) {
emit MintAccessGranted(minter);
}
}
/// @notice Grants burn role to the given address.
/// @dev only the owner can call this function.
/// @param burner the address to grant the burner role to
function grantBurnRole(
address burner
) public onlyOwner {
if (s_burners.add(burner)) {
emit BurnAccessGranted(burner);
}
}
/// @notice Revokes mint role for the given address.
/// @dev only the owner can call this function.
/// @param minter the address to revoke the mint role from.
function revokeMintRole(
address minter
) external onlyOwner {
if (s_minters.remove(minter)) {
emit MintAccessRevoked(minter);
}
}
/// @notice Revokes burn role from the given address.
/// @dev only the owner can call this function
/// @param burner the address to revoke the burner role from
function revokeBurnRole(
address burner
) external onlyOwner {
if (s_burners.remove(burner)) {
emit BurnAccessRevoked(burner);
}
}
/// @notice Returns all permissioned minters
function getMinters() external view returns (address[] memory) {
return s_minters.values();
}
/// @notice Returns all permissioned burners
function getBurners() external view returns (address[] memory) {
return s_burners.values();
}
/// @notice Returns the current CCIPAdmin
function getCCIPAdmin() external view returns (address) {
return s_ccipAdmin;
}
/// @notice Transfers the CCIPAdmin role to a new address
/// @dev only the owner can call this function, NOT the current ccipAdmin, and 1-step ownership transfer is used.
/// @param newAdmin The address to transfer the CCIPAdmin role to. Setting to address(0) is a valid way to revoke
/// the role
function setCCIPAdmin(
address newAdmin
) public onlyOwner {
address currentAdmin = s_ccipAdmin;
s_ccipAdmin = newAdmin;
emit CCIPAdminTransferred(currentAdmin, newAdmin);
}
// ================================================================
// ¦ Access ¦
// ================================================================
/// @notice Checks whether a given address is a minter for this token.
/// @return true if the address is allowed to mint.
function isMinter(
address minter
) public view returns (bool) {
return s_minters.contains(minter);
}
/// @notice Checks whether a given address is a burner for this token.
/// @return true if the address is allowed to burn.
function isBurner(
address burner
) public view returns (bool) {
return s_burners.contains(burner);
}
/// @notice Checks whether the msg.sender is a permissioned minter for this token
/// @dev Reverts with a SenderNotMinter if the check fails
modifier onlyMinter() {
if (!isMinter(msg.sender)) revert SenderNotMinter(msg.sender);
_;
}
/// @notice Checks whether the msg.sender is a permissioned burner for this token
/// @dev Reverts with a SenderNotBurner if the check fails
modifier onlyBurner() {
if (!isBurner(msg.sender)) revert SenderNotBurner(msg.sender);
_;
}
/// @notice Check if recipient is valid (not this contract address).
/// @param recipient the account we transfer/approve to.
/// @dev Reverts with an empty revert to be compatible with the existing link token when
/// the recipient is this contract address.
modifier validAddress(
address recipient
) virtual {
// solhint-disable-next-line reason-string, gas-custom-errors
if (recipient == address(this)) revert();
_;
}
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;
interface ITokenAdminRegistry {
/// @notice Returns the pool for the given token.
function getPool(
address token
) external view returns (address);
/// @notice Proposes an administrator for the given token as pending administrator.
/// @param localToken The token to register the administrator for.
/// @param administrator The administrator to register.
function proposeAdministrator(address localToken, address administrator) external;
/// @notice Accepts the administrator role for a token.
/// @param localToken The token to accept the administrator role for.
/// @dev This function can only be called by the pending administrator.
function acceptAdminRole(
address localToken
) external;
/// @notice Sets the pool for a token. Setting the pool to address(0) effectively delists the token
/// from CCIP. Setting the pool to any other address enables the token on CCIP.
/// @param localToken The token to set the pool for.
/// @param pool The pool to set for the token.
function setPool(address localToken, address pool) external;
/// @notice Transfers the administrator role for a token to a new address with a 2-step process.
/// @param localToken The token to transfer the administrator role for.
/// @param newAdmin The address to transfer the administrator role to. Can be address(0) to cancel
/// a pending transfer.
/// @dev The new admin must call `acceptAdminRole` to accept the role.
function transferAdminRole(address localToken, address newAdmin) external;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/ERC20.sol)
pragma solidity ^0.8.0;
import "./IERC20.sol";
import "./extensions/IERC20Metadata.sol";
import "../../utils/Context.sol";
/**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin Contracts guidelines: functions revert
* instead returning `false` on failure. This behavior is nonetheless
* conventional and does not conflict with the expectations of ERC20
* applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/
contract ERC20 is Context, IERC20, IERC20Metadata {
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**
* @dev Sets the values for {name} and {symbol}.
*
* The default value of {decimals} is 18. To select a different value for
* {decimals} you should overload it.
*
* All two of these values are immutable: they can only be set once during
* construction.
*/
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5.05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless this function is
* overridden;
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual override returns (uint8) {
return 18;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address to, uint256 amount) public virtual override returns (bool) {
address owner = _msgSender();
_transfer(owner, to, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on
* `transferFrom`. This is semantically equivalent to an infinite approval.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
address owner = _msgSender();
_approve(owner, spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* NOTE: Does not update the allowance if the current allowance
* is the maximum `uint256`.
*
* Requirements:
*
* - `from` and `to` cannot be the zero address.
* - `from` must have a balance of at least `amount`.
* - the caller must have allowance for ``from``'s tokens of at least
* `amount`.
*/
function transferFrom(address from, address to, uint256 amount) public virtual override returns (bool) {
address spender = _msgSender();
_spendAllowance(from, spender, amount);
_transfer(from, to, amount);
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
address owner = _msgSender();
_approve(owner, spender, allowance(owner, spender) + addedValue);
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
address owner = _msgSender();
uint256 currentAllowance = allowance(owner, spender);
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
unchecked {
_approve(owner, spender, currentAllowance - subtractedValue);
}
return true;
}
/**
* @dev Moves `amount` of tokens from `from` to `to`.
*
* This internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `from` must have a balance of at least `amount`.
*/
function _transfer(address from, address to, uint256 amount) internal virtual {
require(from != address(0), "ERC20: transfer from the zero address");
require(to != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(from, to, amount);
uint256 fromBalance = _balances[from];
require(fromBalance >= amount, "ERC20: transfer amount exceeds balance");
unchecked {
_balances[from] = fromBalance - amount;
// Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by
// decrementing then incrementing.
_balances[to] += amount;
}
emit Transfer(from, to, amount);
_afterTokenTransfer(from, to, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
unchecked {
// Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.
_balances[account] += amount;
}
emit Transfer(address(0), account, amount);
_afterTokenTransfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
unchecked {
_balances[account] = accountBalance - amount;
// Overflow not possible: amount <= accountBalance <= totalSupply.
_totalSupply -= amount;
}
emit Transfer(account, address(0), amount);
_afterTokenTransfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Updates `owner` s allowance for `spender` based on spent `amount`.
*
* Does not update the allowance amount in case of infinite allowance.
* Revert if not enough allowance is available.
*
* Might emit an {Approval} event.
*/
function _spendAllowance(address owner, address spender, uint256 amount) internal virtual {
uint256 currentAllowance = allowance(owner, spender);
if (currentAllowance != type(uint256).max) {
require(currentAllowance >= amount, "ERC20: insufficient allowance");
unchecked {
_approve(owner, spender, currentAllowance - amount);
}
}
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual {}
/**
* @dev Hook that is called after any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* has been transferred to `to`.
* - when `from` is zero, `amount` tokens have been minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens have been burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _afterTokenTransfer(address from, address to, uint256 amount) internal virtual {}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import {Ownable2Step} from "./Ownable2Step.sol";
/// @notice Sets the msg.sender to be the owner of the contract and does not set a pending owner.
contract Ownable2StepMsgSender is Ownable2Step {
constructor() Ownable2Step(msg.sender, address(0)) {}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {IERC20} from "../../../vendor/openzeppelin-solidity/v4.8.3/contracts/token/ERC20/IERC20.sol";
interface IBurnMintERC20 is IERC20 {
/// @notice Mints new tokens for a given address.
/// @param account The address to mint the new tokens to.
/// @param amount The number of tokens to be minted.
/// @dev this function increases the total supply.
function mint(address account, uint256 amount) external;
/// @notice Burns tokens from the sender.
/// @param amount The number of tokens to be burned.
/// @dev this function decreases the total supply.
function burn(uint256 amount) external;
/// @notice Burns tokens from a given address..
/// @param account The address to burn tokens from.
/// @param amount The number of tokens to be burned.
/// @dev this function decreases the total supply.
function burn(address account, uint256 amount) external;
/// @notice Burns tokens from a given address..
/// @param account The address to burn tokens from.
/// @param amount The number of tokens to be burned.
/// @dev this function decreases the total supply.
function burnFrom(address account, uint256 amount) external;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {Client} from "../libraries/Client.sol";
interface IRouter {
error OnlyOffRamp();
/// @notice Route the message to its intended receiver contract.
/// @param message Client.Any2EVMMessage struct.
/// @param gasForCallExactCheck of params for exec
/// @param gasLimit set of params for exec
/// @param receiver set of params for exec
/// @dev if the receiver is a contracts that signals support for CCIP execution through EIP-165.
/// the contract is called. If not, only tokens are transferred.
/// @return success A boolean value indicating whether the ccip message was received without errors.
/// @return retBytes A bytes array containing return data form CCIP receiver.
/// @return gasUsed the gas used by the external customer call. Does not include any overhead.
function routeMessage(
Client.Any2EVMMessage calldata message,
uint16 gasForCallExactCheck,
uint256 gasLimit,
address receiver
) external returns (bool success, bytes memory retBytes, uint256 gasUsed);
/// @notice Returns the configured onramp for a specific destination chain.
/// @param destChainSelector The destination chain Id to get the onRamp for.
/// @return onRampAddress The address of the onRamp.
function getOnRamp(
uint64 destChainSelector
) external view returns (address onRampAddress);
/// @notice Return true if the given offRamp is a configured offRamp for the given source chain.
/// @param sourceChainSelector The source chain selector to check.
/// @param offRamp The address of the offRamp to check.
function isOffRamp(uint64 sourceChainSelector, address offRamp) external view returns (bool isOffRamp);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)
pragma solidity ^0.8.20;
import {IAccessControl} from "./IAccessControl.sol";
import {Context} from "../utils/Context.sol";
import {ERC165} from "../utils/introspection/ERC165.sol";
/**
* @dev Contract module that allows children to implement role-based access
* control mechanisms. This is a lightweight version that doesn't allow enumerating role
* members except through off-chain means by accessing the contract event logs. Some
* applications may benefit from on-chain enumerability, for those cases see
* {AccessControlEnumerable}.
*
* Roles are referred to by their `bytes32` identifier. These should be exposed
* in the external API and be unique. The best way to achieve this is by
* using `public constant` hash digests:
*
* ```solidity
* bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
* ```
*
* Roles can be used to represent a set of permissions. To restrict access to a
* function call, use {hasRole}:
*
* ```solidity
* function foo() public {
* require(hasRole(MY_ROLE, msg.sender));
* ...
* }
* ```
*
* Roles can be granted and revoked dynamically via the {grantRole} and
* {revokeRole} functions. Each role has an associated admin role, and only
* accounts that have a role's admin role can call {grantRole} and {revokeRole}.
*
* By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
* that only accounts with this role will be able to grant or revoke other
* roles. More complex role relationships can be created by using
* {_setRoleAdmin}.
*
* WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
* grant and revoke this role. Extra precautions should be taken to secure
* accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}
* to enforce additional security measures for this role.
*/
abstract contract AccessControl is Context, IAccessControl, ERC165 {
struct RoleData {
mapping(address account => bool) hasRole;
bytes32 adminRole;
}
mapping(bytes32 role => RoleData) private _roles;
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
/**
* @dev Modifier that checks that an account has a specific role. Reverts
* with an {AccessControlUnauthorizedAccount} error including the required role.
*/
modifier onlyRole(bytes32 role) {
_checkRole(role);
_;
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) public view virtual returns (bool) {
return _roles[role].hasRole[account];
}
/**
* @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`
* is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.
*/
function _checkRole(bytes32 role) internal view virtual {
_checkRole(role, _msgSender());
}
/**
* @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`
* is missing `role`.
*/
function _checkRole(bytes32 role, address account) internal view virtual {
if (!hasRole(role, account)) {
revert AccessControlUnauthorizedAccount(account, role);
}
}
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {
return _roles[role].adminRole;
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*
* May emit a {RoleGranted} event.
*/
function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {
_grantRole(role, account);
}
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*
* May emit a {RoleRevoked} event.
*/
function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {
_revokeRole(role, account);
}
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been revoked `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `callerConfirmation`.
*
* May emit a {RoleRevoked} event.
*/
function renounceRole(bytes32 role, address callerConfirmation) public virtual {
if (callerConfirmation != _msgSender()) {
revert AccessControlBadConfirmation();
}
_revokeRole(role, callerConfirmation);
}
/**
* @dev Sets `adminRole` as ``role``'s admin role.
*
* Emits a {RoleAdminChanged} event.
*/
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
bytes32 previousAdminRole = getRoleAdmin(role);
_roles[role].adminRole = adminRole;
emit RoleAdminChanged(role, previousAdminRole, adminRole);
}
/**
* @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.
*
* Internal function without access restriction.
*
* May emit a {RoleGranted} event.
*/
function _grantRole(bytes32 role, address account) internal virtual returns (bool) {
if (!hasRole(role, account)) {
_roles[role].hasRole[account] = true;
emit RoleGranted(role, account, _msgSender());
return true;
} else {
return false;
}
}
/**
* @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.
*
* Internal function without access restriction.
*
* May emit a {RoleRevoked} event.
*/
function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {
if (hasRole(role, account)) {
_roles[role].hasRole[account] = false;
emit RoleRevoked(role, account, _msgSender());
return true;
} else {
return false;
}
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import {IOwnable} from "../interfaces/IOwnable.sol";
/// @notice A minimal contract that implements 2-step ownership transfer and nothing more. It's made to be minimal
/// to reduce the impact of the bytecode size on any contract that inherits from it.
contract Ownable2Step is IOwnable {
/// @notice The pending owner is the address to which ownership may be transferred.
address private s_pendingOwner;
/// @notice The owner is the current owner of the contract.
/// @dev The owner is the second storage variable so any implementing contract could pack other state with it
/// instead of the much less used s_pendingOwner.
address private s_owner;
error OwnerCannotBeZero();
error MustBeProposedOwner();
error CannotTransferToSelf();
error OnlyCallableByOwner();
event OwnershipTransferRequested(address indexed from, address indexed to);
event OwnershipTransferred(address indexed from, address indexed to);
constructor(address newOwner, address pendingOwner) {
if (newOwner == address(0)) {
revert OwnerCannotBeZero();
}
s_owner = newOwner;
if (pendingOwner != address(0)) {
_transferOwnership(pendingOwner);
}
}
/// @notice Get the current owner
function owner() public view override returns (address) {
return s_owner;
}
/// @notice Allows an owner to begin transferring ownership to a new address. The new owner needs to call
/// `acceptOwnership` to accept the transfer before any permissions are changed.
/// @param to The address to which ownership will be transferred.
function transferOwnership(address to) public override onlyOwner {
_transferOwnership(to);
}
/// @notice validate, transfer ownership, and emit relevant events
/// @param to The address to which ownership will be transferred.
function _transferOwnership(address to) private {
if (to == msg.sender) {
revert CannotTransferToSelf();
}
s_pendingOwner = to;
emit OwnershipTransferRequested(s_owner, to);
}
/// @notice Allows an ownership transfer to be completed by the recipient.
function acceptOwnership() external override {
if (msg.sender != s_pendingOwner) {
revert MustBeProposedOwner();
}
address oldOwner = s_owner;
s_owner = msg.sender;
s_pendingOwner = address(0);
emit OwnershipTransferred(oldOwner, msg.sender);
}
/// @notice validate access
function _validateOwnership() internal view {
if (msg.sender != s_owner) {
revert OnlyCallableByOwner();
}
}
/// @notice Reverts if called by anyone other than the contract owner.
modifier onlyOwner() {
_validateOwnership();
_;
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/// @notice This library contains various token pool functions to aid constructing the return data.
library Pool {
// The tag used to signal support for the pool v1 standard
// bytes4(keccak256("CCIP_POOL_V1"))
bytes4 public constant CCIP_POOL_V1 = 0xaff2afbf;
// The number of bytes in the return data for a pool v1 releaseOrMint call.
// This should match the size of the ReleaseOrMintOutV1 struct.
uint16 public constant CCIP_POOL_V1_RET_BYTES = 32;
// The default max number of bytes in the return data for a pool v1 lockOrBurn call.
// This data can be used to send information to the destination chain token pool. Can be overwritten
// in the TokenTransferFeeConfig.destBytesOverhead if more data is required.
uint32 public constant CCIP_LOCK_OR_BURN_V1_RET_BYTES = 32;
struct LockOrBurnInV1 {
bytes receiver; // The recipient of the tokens on the destination chain, abi encoded
uint64 remoteChainSelector; // -? The chain ID of the destination chain
address originalSender; // -----? The original sender of the tx on the source chain
uint256 amount; // The amount of tokens to lock or burn, denominated in the source token's decimals
address localToken; // The address on this chain of the token to lock or burn
}
struct LockOrBurnOutV1 {
// The address of the destination token, abi encoded in the case of EVM chains
// This value is UNTRUSTED as any pool owner can return whatever value they want.
bytes destTokenAddress;
// Optional pool data to be transferred to the destination chain. Be default this is capped at
// CCIP_LOCK_OR_BURN_V1_RET_BYTES bytes. If more data is required, the TokenTransferFeeConfig.destBytesOverhead
// has to be set for the specific token.
bytes destPoolData;
}
struct ReleaseOrMintInV1 {
bytes originalSender; // The original sender of the tx on the source chain
uint64 remoteChainSelector; // -? The chain ID of the source chain
address receiver; // -----------? The recipient of the tokens on the destination chain.
uint256 amount; // The amount of tokens to release or mint, denominated in the source token's decimals
address localToken; // The address on this chain of the token to release or mint
/// @dev WARNING: sourcePoolAddress should be checked prior to any processing of funds. Make sure it matches the
/// expected pool address for the given remoteChainSelector.
bytes sourcePoolAddress; // The address of the source pool, abi encoded in the case of EVM chains
bytes sourcePoolData; // The data received from the source pool to process the release or mint
/// @dev WARNING: offchainTokenData is untrusted data.
bytes offchainTokenData; // The offchain data to process the release or mint
}
struct ReleaseOrMintOutV1 {
// The number of tokens released or minted on the destination chain, denominated in the local token's decimals.
// This value is expected to be equal to the ReleaseOrMintInV1.amount in the case where the source and destination
// chain have the same number of decimals.
uint256 destinationAmount;
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface IGetCCIPAdmin {
/// @notice Returns the admin of the token.
/// @dev This method is named to never conflict with existing methods.
function getCCIPAdmin() external view returns (address);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/// @notice This interface contains the only RMN-related functions that might be used on-chain by other CCIP contracts.
interface IRMN {
/// @notice A Merkle root tagged with the address of the commit store contract it is destined for.
struct TaggedRoot {
address commitStore;
bytes32 root;
}
/// @notice Callers MUST NOT cache the return value as a blessed tagged root could become unblessed.
function isBlessed(
TaggedRoot calldata taggedRoot
) external view returns (bool);
/// @notice Iff there is an active global or legacy curse, this function returns true.
function isCursed() external view returns (bool);
/// @notice Iff there is an active global curse, or an active curse for `subject`, this function returns true.
/// @param subject To check whether a particular chain is cursed, set to bytes16(uint128(chainSelector)).
function isCursed(
bytes16 subject
) external view returns (bool);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
// End consumer library.
library Client {
/// @dev RMN depends on this struct, if changing, please notify the RMN maintainers.
struct EVMTokenAmount {
address token; // token address on the local chain.
uint256 amount; // Amount of tokens.
}
struct Any2EVMMessage {
bytes32 messageId; // MessageId corresponding to ccipSend on source.
uint64 sourceChainSelector; // Source chain selector.
bytes sender; // abi.decode(sender) if coming from an EVM chain.
bytes data; // payload sent in original message.
EVMTokenAmount[] destTokenAmounts; // Tokens and their amounts in their destination chain representation.
}
// If extraArgs is empty bytes, the default is 200k gas limit.
struct EVM2AnyMessage {
bytes receiver; // abi.encode(receiver address) for dest EVM chains
bytes data; // Data payload
EVMTokenAmount[] tokenAmounts; // Token transfers
address feeToken; // Address of feeToken. address(0) means you will send msg.value.
bytes extraArgs; // Populate this with _argsToBytes(EVMExtraArgsV2)
}
// bytes4(keccak256("CCIP EVMExtraArgsV1"));
bytes4 public constant EVM_EXTRA_ARGS_V1_TAG = 0x97a657c9;
struct EVMExtraArgsV1 {
uint256 gasLimit;
}
function _argsToBytes(
EVMExtraArgsV1 memory extraArgs
) internal pure returns (bytes memory bts) {
return abi.encodeWithSelector(EVM_EXTRA_ARGS_V1_TAG, extraArgs);
}
// bytes4(keccak256("CCIP EVMExtraArgsV2"));
bytes4 public constant EVM_EXTRA_ARGS_V2_TAG = 0x181dcf10;
/// @param gasLimit: gas limit for the callback on the destination chain.
/// @param allowOutOfOrderExecution: if true, it indicates that the message can be executed in any order relative to other messages from the same sender.
/// This value's default varies by chain. On some chains, a particular value is enforced, meaning if the expected value
/// is not set, the message request will revert.
struct EVMExtraArgsV2 {
uint256 gasLimit;
bool allowOutOfOrderExecution;
}
function _argsToBytes(
EVMExtraArgsV2 memory extraArgs
) internal pure returns (bytes memory bts) {
return abi.encodeWithSelector(EVM_EXTRA_ARGS_V2_TAG, extraArgs);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)
pragma solidity ^0.8.0;
import "../IERC20.sol";
/**
* @dev Interface for the optional metadata functions from the ERC20 standard.
*
* _Available since v4.1._
*/
interface IERC20Metadata is IERC20 {
/**
* @dev Returns the name of the token.
*/
function name() external view returns (string memory);
/**
* @dev Returns the symbol of the token.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the decimals places of the token.
*/
function decimals() external view returns (uint8);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface IOwner {
/// @notice Returns the owner of the contract.
/// @dev This method is named to match with the OpenZeppelin Ownable contract.
function owner() external view returns (address);
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.4;
/// @notice Implements Token Bucket rate limiting.
/// @dev uint128 is safe for rate limiter state.
/// For USD value rate limiting, it can adequately store USD value in 18 decimals.
/// For ERC20 token amount rate limiting, all tokens that will be listed will have at most
/// a supply of uint128.max tokens, and it will therefore not overflow the bucket.
/// In exceptional scenarios where tokens consumed may be larger than uint128,
/// e.g. compromised issuer, an enabled RateLimiter will check and revert.
library RateLimiter {
error BucketOverfilled();
error OnlyCallableByAdminOrOwner();
error TokenMaxCapacityExceeded(uint256 capacity, uint256 requested, address tokenAddress);
error TokenRateLimitReached(uint256 minWaitInSeconds, uint256 available, address tokenAddress);
error AggregateValueMaxCapacityExceeded(uint256 capacity, uint256 requested);
error AggregateValueRateLimitReached(uint256 minWaitInSeconds, uint256 available);
error InvalidRateLimitRate(Config rateLimiterConfig);
error DisabledNonZeroRateLimit(Config config);
error RateLimitMustBeDisabled();
event TokensConsumed(uint256 tokens);
event ConfigChanged(Config config);
struct TokenBucket {
uint128 tokens; // ------? Current number of tokens that are in the bucket.
uint32 lastUpdated; // ¦ Timestamp in seconds of the last token refill, good for 100+ years.
bool isEnabled; // ------? Indication whether the rate limiting is enabled or not
uint128 capacity; // ----? Maximum number of tokens that can be in the bucket.
uint128 rate; // --------? Number of tokens per second that the bucket is refilled.
}
struct Config {
bool isEnabled; // Indication whether the rate limiting should be enabled
uint128 capacity; // ----? Specifies the capacity of the rate limiter
uint128 rate; // -------? Specifies the rate of the rate limiter
}
/// @notice _consume removes the given tokens from the pool, lowering the
/// rate tokens allowed to be consumed for subsequent calls.
/// @param requestTokens The total tokens to be consumed from the bucket.
/// @param tokenAddress The token to consume capacity for, use 0x0 to indicate aggregate value capacity.
/// @dev Reverts when requestTokens exceeds bucket capacity or available tokens in the bucket
/// @dev emits removal of requestTokens if requestTokens is > 0
function _consume(TokenBucket storage s_bucket, uint256 requestTokens, address tokenAddress) internal {
// If there is no value to remove or rate limiting is turned off, skip this step to reduce gas usage
if (!s_bucket.isEnabled || requestTokens == 0) {
return;
}
uint256 tokens = s_bucket.tokens;
uint256 capacity = s_bucket.capacity;
uint256 timeDiff = block.timestamp - s_bucket.lastUpdated;
if (timeDiff != 0) {
if (tokens > capacity) revert BucketOverfilled();
// Refill tokens when arriving at a new block time
tokens = _calculateRefill(capacity, tokens, timeDiff, s_bucket.rate);
s_bucket.lastUpdated = uint32(block.timestamp);
}
if (capacity < requestTokens) {
// Token address 0 indicates consuming aggregate value rate limit capacity.
if (tokenAddress == address(0)) revert AggregateValueMaxCapacityExceeded(capacity, requestTokens);
revert TokenMaxCapacityExceeded(capacity, requestTokens, tokenAddress);
}
if (tokens < requestTokens) {
uint256 rate = s_bucket.rate;
// Wait required until the bucket is refilled enough to accept this value, round up to next higher second
// Consume is not guaranteed to succeed after wait time passes if there is competing traffic.
// This acts as a lower bound of wait time.
uint256 minWaitInSeconds = ((requestTokens - tokens) + (rate - 1)) / rate;
if (tokenAddress == address(0)) revert AggregateValueRateLimitReached(minWaitInSeconds, tokens);
revert TokenRateLimitReached(minWaitInSeconds, tokens, tokenAddress);
}
tokens -= requestTokens;
// Downcast is safe here, as tokens is not larger than capacity
s_bucket.tokens = uint128(tokens);
emit TokensConsumed(requestTokens);
}
/// @notice Gets the token bucket with its values for the block it was requested at.
/// @return The token bucket.
function _currentTokenBucketState(
TokenBucket memory bucket
) internal view returns (TokenBucket memory) {
// We update the bucket to reflect the status at the exact time of the
// call. This means we might need to refill a part of the bucket based
// on the time that has passed since the last update.
bucket.tokens =
uint128(_calculateRefill(bucket.capacity, bucket.tokens, block.timestamp - bucket.lastUpdated, bucket.rate));
bucket.lastUpdated = uint32(block.timestamp);
return bucket;
}
/// @notice Sets the rate limited config.
/// @param s_bucket The token bucket
/// @param config The new config
function _setTokenBucketConfig(TokenBucket storage s_bucket, Config memory config) internal {
// First update the bucket to make sure the proper rate is used for all the time
// up until the config change.
uint256 timeDiff = block.timestamp - s_bucket.lastUpdated;
if (timeDiff != 0) {
s_bucket.tokens = uint128(_calculateRefill(s_bucket.capacity, s_bucket.tokens, timeDiff, s_bucket.rate));
s_bucket.lastUpdated = uint32(block.timestamp);
}
s_bucket.tokens = uint128(_min(config.capacity, s_bucket.tokens));
s_bucket.isEnabled = config.isEnabled;
s_bucket.capacity = config.capacity;
s_bucket.rate = config.rate;
emit ConfigChanged(config);
}
/// @notice Validates the token bucket config
function _validateTokenBucketConfig(Config memory config, bool mustBeDisabled) internal pure {
if (config.isEnabled) {
if (config.rate >= config.capacity || config.rate == 0) {
revert InvalidRateLimitRate(config);
}
if (mustBeDisabled) {
revert RateLimitMustBeDisabled();
}
} else {
if (config.rate != 0 || config.capacity != 0) {
revert DisabledNonZeroRateLimit(config);
}
}
}
/// @notice Calculate refilled tokens
/// @param capacity bucket capacity
/// @param tokens current bucket tokens
/// @param timeDiff block time difference since last refill
/// @param rate bucket refill rate
/// @return the value of tokens after refill
function _calculateRefill(
uint256 capacity,
uint256 tokens,
uint256 timeDiff,
uint256 rate
) private pure returns (uint256) {
return _min(capacity, tokens + timeDiff * rate);
}
/// @notice Return the smallest of two integers
/// @param a first int
/// @param b second int
/// @return smallest
function _min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface IOwnable {
function owner() external returns (address);
function transferOwnership(address recipient) external;
function acceptOwnership() external;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/structs/EnumerableSet.sol)
// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.
pragma solidity ^0.8.20;
/**
* @dev Library for managing
* https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
* types.
*
* Sets have the following properties:
*
* - Elements are added, removed, and checked for existence in constant time
* (O(1)).
* - Elements are enumerated in O(n). No guarantees are made on the ordering.
*
* ```solidity
* contract Example {
* // Add the library methods
* using EnumerableSet for EnumerableSet.AddressSet;
*
* // Declare a set state variable
* EnumerableSet.AddressSet private mySet;
* }
* ```
*
* As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
* and `uint256` (`UintSet`) are supported.
*
* [WARNING]
* ====
* Trying to delete such a structure from storage will likely result in data corruption, rendering the structure
* unusable.
* See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.
*
* In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an
* array of EnumerableSet.
* ====
*/
library EnumerableSet {
// To implement this library for multiple types with as little code
// repetition as possible, we write it in terms of a generic Set type with
// bytes32 values.
// The Set implementation uses private functions, and user-facing
// implementations (such as AddressSet) are just wrappers around the
// underlying Set.
// This means that we can only create new EnumerableSets for types that fit
// in bytes32.
struct Set {
// Storage of set values
bytes32[] _values;
// Position is the index of the value in the `values` array plus 1.
// Position 0 is used to mean a value is not in the set.
mapping(bytes32 value => uint256) _positions;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function _add(Set storage set, bytes32 value) private returns (bool) {
if (!_contains(set, value)) {
set._values.push(value);
// The value is stored at length-1, but we add 1 to all indexes
// and use 0 as a sentinel value
set._positions[value] = set._values.length;
return true;
} else {
return false;
}
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function _remove(Set storage set, bytes32 value) private returns (bool) {
// We cache the value's position to prevent multiple reads from the same storage slot
uint256 position = set._positions[value];
if (position != 0) {
// Equivalent to contains(set, value)
// To delete an element from the _values array in O(1), we swap the element to delete with the last one in
// the array, and then remove the last element (sometimes called as 'swap and pop').
// This modifies the order of the array, as noted in {at}.
uint256 valueIndex = position - 1;
uint256 lastIndex = set._values.length - 1;
if (valueIndex != lastIndex) {
bytes32 lastValue = set._values[lastIndex];
// Move the lastValue to the index where the value to delete is
set._values[valueIndex] = lastValue;
// Update the tracked position of the lastValue (that was just moved)
set._positions[lastValue] = position;
}
// Delete the slot where the moved value was stored
set._values.pop();
// Delete the tracked position for the deleted slot
delete set._positions[value];
return true;
} else {
return false;
}
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function _contains(Set storage set, bytes32 value) private view returns (bool) {
return set._positions[value] != 0;
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function _length(Set storage set) private view returns (uint256) {
return set._values.length;
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function _at(Set storage set, uint256 index) private view returns (bytes32) {
return set._values[index];
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function _values(Set storage set) private view returns (bytes32[] memory) {
return set._values;
}
// Bytes32Set
struct Bytes32Set {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _add(set._inner, value);
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _remove(set._inner, value);
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
return _contains(set._inner, value);
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(Bytes32Set storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
return _at(set._inner, index);
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {
bytes32[] memory store = _values(set._inner);
bytes32[] memory result;
/// @solidity memory-safe-assembly
assembly {
result := store
}
return result;
}
// AddressSet
struct AddressSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(AddressSet storage set, address value) internal returns (bool) {
return _add(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(AddressSet storage set, address value) internal returns (bool) {
return _remove(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(AddressSet storage set, address value) internal view returns (bool) {
return _contains(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(AddressSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(AddressSet storage set, uint256 index) internal view returns (address) {
return address(uint160(uint256(_at(set._inner, index))));
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(AddressSet storage set) internal view returns (address[] memory) {
bytes32[] memory store = _values(set._inner);
address[] memory result;
/// @solidity memory-safe-assembly
assembly {
result := store
}
return result;
}
// UintSet
struct UintSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(UintSet storage set, uint256 value) internal returns (bool) {
return _add(set._inner, bytes32(value));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(UintSet storage set, uint256 value) internal returns (bool) {
return _remove(set._inner, bytes32(value));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(UintSet storage set, uint256 value) internal view returns (bool) {
return _contains(set._inner, bytes32(value));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(UintSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(UintSet storage set, uint256 index) internal view returns (uint256) {
return uint256(_at(set._inner, index));
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(UintSet storage set) internal view returns (uint256[] memory) {
bytes32[] memory store = _values(set._inner);
uint256[] memory result;
/// @solidity memory-safe-assembly
assembly {
result := store
}
return result;
}
}{
"evmVersion": "paris",
"libraries": {},
"metadata": {
"bytecodeHash": "none",
"useLiteralContent": true
},
"optimizer": {
"enabled": true,
"runs": 26000
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"remappings": [
"@arbitrum/=node_modules/@arbitrum/",
"@eth-optimism/=node_modules/@eth-optimism/",
"@offchainlabs/=node_modules/@offchainlabs/",
"@openzeppelin/=node_modules/@openzeppelin/",
"@scroll-tech/=node_modules/@scroll-tech/",
"@zksync/=node_modules/@zksync/",
"forge-std/=src/v0.8/vendor/forge-std/src/",
"hardhat/=node_modules/hardhat/"
]
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"contract ITokenAdminRegistry","name":"tokenAdminRegistry","type":"address"},{"internalType":"contract RegistryModuleOwnerCustom","name":"tokenAdminModule","type":"address"},{"internalType":"address","name":"rmnProxy","type":"address"},{"internalType":"address","name":"ccipRouter","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"Create2EmptyBytecode","type":"error"},{"inputs":[],"name":"FailedDeployment","type":"error"},{"inputs":[{"internalType":"uint256","name":"balance","type":"uint256"},{"internalType":"uint256","name":"needed","type":"uint256"}],"name":"InsufficientBalance","type":"error"},{"inputs":[],"name":"InvalidZeroAddress","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint64","name":"remoteChainSelector","type":"uint64"},{"components":[{"internalType":"address","name":"remotePoolFactory","type":"address"},{"internalType":"address","name":"remoteRouter","type":"address"},{"internalType":"address","name":"remoteRMNProxy","type":"address"},{"internalType":"uint8","name":"remoteTokenDecimals","type":"uint8"}],"indexed":false,"internalType":"struct TokenPoolFactory.RemoteChainConfig","name":"remoteChainConfig","type":"tuple"}],"name":"RemoteChainConfigUpdated","type":"event"},{"inputs":[{"components":[{"internalType":"uint64","name":"remoteChainSelector","type":"uint64"},{"internalType":"bytes","name":"remotePoolAddress","type":"bytes"},{"internalType":"bytes","name":"remotePoolInitCode","type":"bytes"},{"components":[{"internalType":"address","name":"remotePoolFactory","type":"address"},{"internalType":"address","name":"remoteRouter","type":"address"},{"internalType":"address","name":"remoteRMNProxy","type":"address"},{"internalType":"uint8","name":"remoteTokenDecimals","type":"uint8"}],"internalType":"struct TokenPoolFactory.RemoteChainConfig","name":"remoteChainConfig","type":"tuple"},{"internalType":"enum TokenPoolFactory.PoolType","name":"poolType","type":"uint8"},{"internalType":"bytes","name":"remoteTokenAddress","type":"bytes"},{"internalType":"bytes","name":"remoteTokenInitCode","type":"bytes"},{"components":[{"internalType":"bool","name":"isEnabled","type":"bool"},{"internalType":"uint128","name":"capacity","type":"uint128"},{"internalType":"uint128","name":"rate","type":"uint128"}],"internalType":"struct RateLimiter.Config","name":"rateLimiterConfig","type":"tuple"}],"internalType":"struct TokenPoolFactory.RemoteTokenPoolInfo[]","name":"remoteTokenPools","type":"tuple[]"},{"internalType":"uint8","name":"localTokenDecimals","type":"uint8"},{"internalType":"bytes","name":"tokenInitCode","type":"bytes"},{"internalType":"bytes","name":"tokenPoolInitCode","type":"bytes"},{"internalType":"bytes32","name":"salt","type":"bytes32"}],"name":"deployTokenAndTokenPool","outputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint8","name":"localTokenDecimals","type":"uint8"},{"components":[{"internalType":"uint64","name":"remoteChainSelector","type":"uint64"},{"internalType":"bytes","name":"remotePoolAddress","type":"bytes"},{"internalType":"bytes","name":"remotePoolInitCode","type":"bytes"},{"components":[{"internalType":"address","name":"remotePoolFactory","type":"address"},{"internalType":"address","name":"remoteRouter","type":"address"},{"internalType":"address","name":"remoteRMNProxy","type":"address"},{"internalType":"uint8","name":"remoteTokenDecimals","type":"uint8"}],"internalType":"struct TokenPoolFactory.RemoteChainConfig","name":"remoteChainConfig","type":"tuple"},{"internalType":"enum TokenPoolFactory.PoolType","name":"poolType","type":"uint8"},{"internalType":"bytes","name":"remoteTokenAddress","type":"bytes"},{"internalType":"bytes","name":"remoteTokenInitCode","type":"bytes"},{"components":[{"internalType":"bool","name":"isEnabled","type":"bool"},{"internalType":"uint128","name":"capacity","type":"uint128"},{"internalType":"uint128","name":"rate","type":"uint128"}],"internalType":"struct RateLimiter.Config","name":"rateLimiterConfig","type":"tuple"}],"internalType":"struct TokenPoolFactory.RemoteTokenPoolInfo[]","name":"remoteTokenPools","type":"tuple[]"},{"internalType":"bytes","name":"tokenPoolInitCode","type":"bytes"},{"internalType":"bytes32","name":"salt","type":"bytes32"},{"internalType":"enum TokenPoolFactory.PoolType","name":"poolType","type":"uint8"}],"name":"deployTokenPoolWithExistingToken","outputs":[{"internalType":"address","name":"poolAddress","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"typeAndVersion","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"}]Contract Creation Code
6101006040523480156200001257600080fd5b50604051620019d5380380620019d58339810160408190526200003591620000d4565b6001600160a01b03841615806200005357506001600160a01b038316155b806200006657506001600160a01b038216155b806200007957506001600160a01b038116155b15620000985760405163f6b2911f60e01b815260040160405180910390fd5b6001600160a01b0393841660805291831660a052821660c0521660e0526200013c565b6001600160a01b0381168114620000d157600080fd5b50565b60008060008060808587031215620000eb57600080fd5b8451620000f881620000bb565b60208601519094506200010b81620000bb565b60408601519093506200011e81620000bb565b60608601519092506200013181620000bb565b939692955090935050565b60805160a05160c05160e05161184362000192600039600081816105f601526106890152600081816105d40152610664015260006109570152600081816109f601528181610a9f0152610b4601526118436000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c8063169ed05814610046578063181f5a7714610083578063eb03cac1146100cc575b600080fd5b610059610054366004610f38565b61010c565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020015b60405180910390f35b6100bf6040518060400160405280601681526020017f546f6b656e506f6f6c466163746f727920312e352e310000000000000000000081525081565b60405161007a9190611052565b6100df6100da366004611169565b610184565b6040805173ffffffffffffffffffffffffffffffffffffffff93841681529290911660208301520161007a565b6000823360405160200161014f92919091825260601b7fffffffffffffffffffffffffffffffffffffffff00000000000000000000000016602082015260340190565b6040516020818303038152906040528051906020012092506101778989898989898989610322565b9998505050505050505050565b60008082336040516020016101c892919091825260601b7fffffffffffffffffffffffffffffffffffffffff00000000000000000000000016602082015260340190565b60405160208183030381529060405280519060200120925060006101ee60008589610818565b90506000610203828a8d8d8b8b8b6000610322565b6040517fc630948d00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff80831660048301529192509083169063c630948d90602401600060405180830381600087803b15801561027057600080fd5b505af1158015610284573d6000803e3d6000fd5b505050506102928282610912565b6040517ff2fde38b00000000000000000000000000000000000000000000000000000000815233600482015273ffffffffffffffffffffffffffffffffffffffff83169063f2fde38b90602401600060405180830381600087803b1580156102f957600080fd5b505af115801561030d573d6000803e3d6000fd5b50939d929c50919a5050505050505050505050565b6000808667ffffffffffffffff81111561033e5761033e611065565b60405190808252806020026020018201604052801561037757816020015b610364610cc5565b81526020019060019003908161035c5790505b509050610382610d61565b60005b888110156105a05789898281811061039f5761039f61121a565b90506020028101906103b19190611249565b6103ba906113bb565b91508160a001515160000361043d5760c082015180516020909101206060830151516103e7918891610ba8565b6040805173ffffffffffffffffffffffffffffffffffffffff909216602083015201604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081840301815291905260a08301525b8160200151516000036104e857600061047b836040015184606001518560a0015180602001905181019061047191906114bc565b8660800151610be8565b6060840151519091506104919088908390610ba8565b6040805173ffffffffffffffffffffffffffffffffffffffff909216602083015201604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020840152505b604080516001808252818301909252600091816020015b60608152602001906001900390816104ff57905050905082602001518160008151811061052e5761052e61121a565b60200260200101819052506040518060a00160405280846000015167ffffffffffffffff1681526020018281526020018460a0015181526020018460e0015181526020018460e0015181525084838151811061058c5761058c61121a565b602090810291909101015250600101610385565b50606060008560018111156105b7576105b76114d9565b0361063357604080516000815260208101825261061d918e918e917f0000000000000000000000000000000000000000000000000000000000000000907f000000000000000000000000000000000000000000000000000000000000000090830161155a565b60405160208183030381529060405290506106c2565b6001856001811115610647576106476114d9565b036106c25760408051600081526020810182526106b0918e918e917f0000000000000000000000000000000000000000000000000000000000000000906001907f00000000000000000000000000000000000000000000000000000000000000009084016115ad565b60405160208183030381529060405290505b60006106f36000888b8b866040516020016106df93929190611606565b604051602081830303815290604052610818565b604080516000815260208101918290527fe8a1da170000000000000000000000000000000000000000000000000000000090915290915073ffffffffffffffffffffffffffffffffffffffff82169063e8a1da179061075690876024820161162d565b600060405180830381600087803b15801561077057600080fd5b505af1158015610784573d6000803e3d6000fd5b50506040517ff2fde38b00000000000000000000000000000000000000000000000000000000815233600482015273ffffffffffffffffffffffffffffffffffffffff8416925063f2fde38b9150602401600060405180830381600087803b1580156107ef57600080fd5b505af1158015610803573d6000803e3d6000fd5b50929f9e505050505050505050505050505050565b600083471015610861576040517fcf4791810000000000000000000000000000000000000000000000000000000081524760048201526024810185905260440160405180910390fd5b815160000361089c576040517f4ca249dc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8282516020840186f590503d1519811516156108be576040513d6000823e3d81fd5b73ffffffffffffffffffffffffffffffffffffffff811661090b576040517fb06ebf3d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b9392505050565b6040517f96ea2f7a00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff83811660048301527f000000000000000000000000000000000000000000000000000000000000000016906396ea2f7a90602401600060405180830381600087803b15801561099b57600080fd5b505af11580156109af573d6000803e3d6000fd5b50506040517f156194da00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff85811660048301527f000000000000000000000000000000000000000000000000000000000000000016925063156194da9150602401600060405180830381600087803b158015610a3c57600080fd5b505af1158015610a50573d6000803e3d6000fd5b50506040517f4e847fc700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff858116600483015284811660248301527f0000000000000000000000000000000000000000000000000000000000000000169250634e847fc79150604401600060405180830381600087803b158015610ae557600080fd5b505af1158015610af9573d6000803e3d6000fd5b50506040517fddadfa8e00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff85811660048301523360248301527f000000000000000000000000000000000000000000000000000000000000000016925063ddadfa8e9150604401600060405180830381600087803b158015610b8c57600080fd5b505af1158015610ba0573d6000803e3d6000fd5b505050505050565b6000604051836040820152846020820152828152600b8101905060ff81536055902073ffffffffffffffffffffffffffffffffffffffff16949350505050565b600080826001811115610bfd57610bfd6114d9565b03610c8b57606084015160408051600081526020808201835282880151908801518994610c329489949193919290830161155a565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081840301815290829052610c6e9291602001611807565b604051602081830303815290604052805190602001209050610cbd565b606084015160408051600081526020808201835282880151908801518994610c329489949193919260019184016115ad565b949350505050565b6040518060a00160405280600067ffffffffffffffff1681526020016060815260200160608152602001610d39604051806060016040528060001515815260200160006fffffffffffffffffffffffffffffffff16815260200160006fffffffffffffffffffffffffffffffff1681525090565b815260408051606081018252600080825260208281018290529282015291015290565b905290565b604051806101000160405280600067ffffffffffffffff1681526020016060815260200160608152602001610dfc6040518060800160405280600073ffffffffffffffffffffffffffffffffffffffff168152602001600073ffffffffffffffffffffffffffffffffffffffff168152602001600073ffffffffffffffffffffffffffffffffffffffff168152602001600060ff1681525090565b8152602001600081526020016060815260200160608152602001610d5c604051806060016040528060001515815260200160006fffffffffffffffffffffffffffffffff16815260200160006fffffffffffffffffffffffffffffffff1681525090565b73ffffffffffffffffffffffffffffffffffffffff81168114610e8257600080fd5b50565b803560ff81168114610e9657600080fd5b919050565b60008083601f840112610ead57600080fd5b50813567ffffffffffffffff811115610ec557600080fd5b6020830191508360208260051b8501011115610ee057600080fd5b9250929050565b60008083601f840112610ef957600080fd5b50813567ffffffffffffffff811115610f1157600080fd5b602083019150836020828501011115610ee057600080fd5b803560028110610e9657600080fd5b60008060008060008060008060c0898b031215610f5457600080fd5b8835610f5f81610e60565b9750610f6d60208a01610e85565b9650604089013567ffffffffffffffff80821115610f8a57600080fd5b610f968c838d01610e9b565b909850965060608b0135915080821115610faf57600080fd5b50610fbc8b828c01610ee7565b90955093505060808901359150610fd560a08a01610f29565b90509295985092959890939650565b60005b83811015610fff578181015183820152602001610fe7565b50506000910152565b60008151808452611020816020860160208601610fe4565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b60208152600061090b6020830184611008565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051610100810167ffffffffffffffff811182821017156110b8576110b8611065565b60405290565b600082601f8301126110cf57600080fd5b813567ffffffffffffffff808211156110ea576110ea611065565b604051601f83017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f0116810190828211818310171561113057611130611065565b8160405283815286602085880101111561114957600080fd5b836020870160208301376000602085830101528094505050505092915050565b600080600080600080600060a0888a03121561118457600080fd5b873567ffffffffffffffff8082111561119c57600080fd5b6111a88b838c01610e9b565b90995097508791506111bc60208b01610e85565b965060408a01359150808211156111d257600080fd5b6111de8b838c016110be565b955060608a01359150808211156111f457600080fd5b506112018a828b01610ee7565b989b979a50959894979596608090950135949350505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600082357ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe6183360301811261127d57600080fd5b9190910192915050565b803567ffffffffffffffff81168114610e9657600080fd5b6000608082840312156112b157600080fd5b6040516080810181811067ffffffffffffffff821117156112d4576112d4611065565b60405290508082356112e581610e60565b815260208301356112f581610e60565b6020820152604083013561130881610e60565b604082015261131960608401610e85565b60608201525092915050565b80356fffffffffffffffffffffffffffffffff81168114610e9657600080fd5b60006060828403121561135757600080fd5b6040516060810181811067ffffffffffffffff8211171561137a5761137a611065565b6040529050808235801515811461139057600080fd5b815261139e60208401611325565b60208201526113af60408401611325565b60408201525092915050565b60006101a082360312156113ce57600080fd5b6113d6611094565b6113df83611287565b8152602083013567ffffffffffffffff808211156113fc57600080fd5b611408368387016110be565b6020840152604085013591508082111561142157600080fd5b61142d368387016110be565b604084015261143f366060870161129f565b606084015261145060e08601610f29565b608084015261010085013591508082111561146a57600080fd5b611476368387016110be565b60a084015261012085013591508082111561149057600080fd5b5061149d368286016110be565b60c0830152506114b1366101408501611345565b60e082015292915050565b6000602082840312156114ce57600080fd5b815161090b81610e60565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b60008151808452602080850194506020840160005b8381101561154f57815173ffffffffffffffffffffffffffffffffffffffff168752958201959082019060010161151d565b509495945050505050565b600073ffffffffffffffffffffffffffffffffffffffff808816835260ff8716602084015260a0604084015261159360a0840187611508565b948116606084015292909216608090910152509392505050565b600073ffffffffffffffffffffffffffffffffffffffff808916835260ff8816602084015260c060408401526115e660c0840188611508565b9581166060840152931515608083015250911660a0909101529392505050565b828482376000838201600081528351611623818360208801610fe4565b0195945050505050565b6040808252835182820181905260009190606090818501906020808901865b8381101561167257815167ffffffffffffffff168552938201939082019060010161164c565b50508683038188015287518084528184019250600581811b850183018a840160005b848110156117f5578783037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe00187528151805167ffffffffffffffff1684528681015161012088860181905281519086018190526101408087019282891b880190910191908a019060005b8181101561174b577ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec0898503018552611739848451611008565b948c01949350918b01916001016116ff565b5050508c83015191508581038d8701526117658183611008565b9150508a8201516117a68c8701828051151582526020808201516fffffffffffffffffffffffffffffffff9081169184019190915260409182015116910152565b50608091909101518051151560c086015260208101516fffffffffffffffffffffffffffffffff90811660e0870152604082015116610100860152909787019793505090850190600101611694565b50909c9b505050505050505050505050565b60008351611819818460208801610fe4565b83519083019061182d818360208801610fe4565b0194935050505056fea164736f6c6343000818000a000000000000000000000000048b911a1ae5dd4f0aee5241a30d3deda3501d5400000000000000000000000095ade250c01701a4c63d0893c954a510f7938dc600000000000000000000000032270e4fa459ca47ae0334488e27ffb9bc9ab4a10000000000000000000000007c19b79d2a054114ab36ad758a36e92376e267da
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106100415760003560e01c8063169ed05814610046578063181f5a7714610083578063eb03cac1146100cc575b600080fd5b610059610054366004610f38565b61010c565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020015b60405180910390f35b6100bf6040518060400160405280601681526020017f546f6b656e506f6f6c466163746f727920312e352e310000000000000000000081525081565b60405161007a9190611052565b6100df6100da366004611169565b610184565b6040805173ffffffffffffffffffffffffffffffffffffffff93841681529290911660208301520161007a565b6000823360405160200161014f92919091825260601b7fffffffffffffffffffffffffffffffffffffffff00000000000000000000000016602082015260340190565b6040516020818303038152906040528051906020012092506101778989898989898989610322565b9998505050505050505050565b60008082336040516020016101c892919091825260601b7fffffffffffffffffffffffffffffffffffffffff00000000000000000000000016602082015260340190565b60405160208183030381529060405280519060200120925060006101ee60008589610818565b90506000610203828a8d8d8b8b8b6000610322565b6040517fc630948d00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff80831660048301529192509083169063c630948d90602401600060405180830381600087803b15801561027057600080fd5b505af1158015610284573d6000803e3d6000fd5b505050506102928282610912565b6040517ff2fde38b00000000000000000000000000000000000000000000000000000000815233600482015273ffffffffffffffffffffffffffffffffffffffff83169063f2fde38b90602401600060405180830381600087803b1580156102f957600080fd5b505af115801561030d573d6000803e3d6000fd5b50939d929c50919a5050505050505050505050565b6000808667ffffffffffffffff81111561033e5761033e611065565b60405190808252806020026020018201604052801561037757816020015b610364610cc5565b81526020019060019003908161035c5790505b509050610382610d61565b60005b888110156105a05789898281811061039f5761039f61121a565b90506020028101906103b19190611249565b6103ba906113bb565b91508160a001515160000361043d5760c082015180516020909101206060830151516103e7918891610ba8565b6040805173ffffffffffffffffffffffffffffffffffffffff909216602083015201604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081840301815291905260a08301525b8160200151516000036104e857600061047b836040015184606001518560a0015180602001905181019061047191906114bc565b8660800151610be8565b6060840151519091506104919088908390610ba8565b6040805173ffffffffffffffffffffffffffffffffffffffff909216602083015201604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020840152505b604080516001808252818301909252600091816020015b60608152602001906001900390816104ff57905050905082602001518160008151811061052e5761052e61121a565b60200260200101819052506040518060a00160405280846000015167ffffffffffffffff1681526020018281526020018460a0015181526020018460e0015181526020018460e0015181525084838151811061058c5761058c61121a565b602090810291909101015250600101610385565b50606060008560018111156105b7576105b76114d9565b0361063357604080516000815260208101825261061d918e918e917f00000000000000000000000032270e4fa459ca47ae0334488e27ffb9bc9ab4a1907f0000000000000000000000007c19b79d2a054114ab36ad758a36e92376e267da90830161155a565b60405160208183030381529060405290506106c2565b6001856001811115610647576106476114d9565b036106c25760408051600081526020810182526106b0918e918e917f00000000000000000000000032270e4fa459ca47ae0334488e27ffb9bc9ab4a1906001907f0000000000000000000000007c19b79d2a054114ab36ad758a36e92376e267da9084016115ad565b60405160208183030381529060405290505b60006106f36000888b8b866040516020016106df93929190611606565b604051602081830303815290604052610818565b604080516000815260208101918290527fe8a1da170000000000000000000000000000000000000000000000000000000090915290915073ffffffffffffffffffffffffffffffffffffffff82169063e8a1da179061075690876024820161162d565b600060405180830381600087803b15801561077057600080fd5b505af1158015610784573d6000803e3d6000fd5b50506040517ff2fde38b00000000000000000000000000000000000000000000000000000000815233600482015273ffffffffffffffffffffffffffffffffffffffff8416925063f2fde38b9150602401600060405180830381600087803b1580156107ef57600080fd5b505af1158015610803573d6000803e3d6000fd5b50929f9e505050505050505050505050505050565b600083471015610861576040517fcf4791810000000000000000000000000000000000000000000000000000000081524760048201526024810185905260440160405180910390fd5b815160000361089c576040517f4ca249dc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8282516020840186f590503d1519811516156108be576040513d6000823e3d81fd5b73ffffffffffffffffffffffffffffffffffffffff811661090b576040517fb06ebf3d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b9392505050565b6040517f96ea2f7a00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff83811660048301527f00000000000000000000000095ade250c01701a4c63d0893c954a510f7938dc616906396ea2f7a90602401600060405180830381600087803b15801561099b57600080fd5b505af11580156109af573d6000803e3d6000fd5b50506040517f156194da00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff85811660048301527f000000000000000000000000048b911a1ae5dd4f0aee5241a30d3deda3501d5416925063156194da9150602401600060405180830381600087803b158015610a3c57600080fd5b505af1158015610a50573d6000803e3d6000fd5b50506040517f4e847fc700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff858116600483015284811660248301527f000000000000000000000000048b911a1ae5dd4f0aee5241a30d3deda3501d54169250634e847fc79150604401600060405180830381600087803b158015610ae557600080fd5b505af1158015610af9573d6000803e3d6000fd5b50506040517fddadfa8e00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff85811660048301523360248301527f000000000000000000000000048b911a1ae5dd4f0aee5241a30d3deda3501d5416925063ddadfa8e9150604401600060405180830381600087803b158015610b8c57600080fd5b505af1158015610ba0573d6000803e3d6000fd5b505050505050565b6000604051836040820152846020820152828152600b8101905060ff81536055902073ffffffffffffffffffffffffffffffffffffffff16949350505050565b600080826001811115610bfd57610bfd6114d9565b03610c8b57606084015160408051600081526020808201835282880151908801518994610c329489949193919290830161155a565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081840301815290829052610c6e9291602001611807565b604051602081830303815290604052805190602001209050610cbd565b606084015160408051600081526020808201835282880151908801518994610c329489949193919260019184016115ad565b949350505050565b6040518060a00160405280600067ffffffffffffffff1681526020016060815260200160608152602001610d39604051806060016040528060001515815260200160006fffffffffffffffffffffffffffffffff16815260200160006fffffffffffffffffffffffffffffffff1681525090565b815260408051606081018252600080825260208281018290529282015291015290565b905290565b604051806101000160405280600067ffffffffffffffff1681526020016060815260200160608152602001610dfc6040518060800160405280600073ffffffffffffffffffffffffffffffffffffffff168152602001600073ffffffffffffffffffffffffffffffffffffffff168152602001600073ffffffffffffffffffffffffffffffffffffffff168152602001600060ff1681525090565b8152602001600081526020016060815260200160608152602001610d5c604051806060016040528060001515815260200160006fffffffffffffffffffffffffffffffff16815260200160006fffffffffffffffffffffffffffffffff1681525090565b73ffffffffffffffffffffffffffffffffffffffff81168114610e8257600080fd5b50565b803560ff81168114610e9657600080fd5b919050565b60008083601f840112610ead57600080fd5b50813567ffffffffffffffff811115610ec557600080fd5b6020830191508360208260051b8501011115610ee057600080fd5b9250929050565b60008083601f840112610ef957600080fd5b50813567ffffffffffffffff811115610f1157600080fd5b602083019150836020828501011115610ee057600080fd5b803560028110610e9657600080fd5b60008060008060008060008060c0898b031215610f5457600080fd5b8835610f5f81610e60565b9750610f6d60208a01610e85565b9650604089013567ffffffffffffffff80821115610f8a57600080fd5b610f968c838d01610e9b565b909850965060608b0135915080821115610faf57600080fd5b50610fbc8b828c01610ee7565b90955093505060808901359150610fd560a08a01610f29565b90509295985092959890939650565b60005b83811015610fff578181015183820152602001610fe7565b50506000910152565b60008151808452611020816020860160208601610fe4565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b60208152600061090b6020830184611008565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051610100810167ffffffffffffffff811182821017156110b8576110b8611065565b60405290565b600082601f8301126110cf57600080fd5b813567ffffffffffffffff808211156110ea576110ea611065565b604051601f83017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f0116810190828211818310171561113057611130611065565b8160405283815286602085880101111561114957600080fd5b836020870160208301376000602085830101528094505050505092915050565b600080600080600080600060a0888a03121561118457600080fd5b873567ffffffffffffffff8082111561119c57600080fd5b6111a88b838c01610e9b565b90995097508791506111bc60208b01610e85565b965060408a01359150808211156111d257600080fd5b6111de8b838c016110be565b955060608a01359150808211156111f457600080fd5b506112018a828b01610ee7565b989b979a50959894979596608090950135949350505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600082357ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe6183360301811261127d57600080fd5b9190910192915050565b803567ffffffffffffffff81168114610e9657600080fd5b6000608082840312156112b157600080fd5b6040516080810181811067ffffffffffffffff821117156112d4576112d4611065565b60405290508082356112e581610e60565b815260208301356112f581610e60565b6020820152604083013561130881610e60565b604082015261131960608401610e85565b60608201525092915050565b80356fffffffffffffffffffffffffffffffff81168114610e9657600080fd5b60006060828403121561135757600080fd5b6040516060810181811067ffffffffffffffff8211171561137a5761137a611065565b6040529050808235801515811461139057600080fd5b815261139e60208401611325565b60208201526113af60408401611325565b60408201525092915050565b60006101a082360312156113ce57600080fd5b6113d6611094565b6113df83611287565b8152602083013567ffffffffffffffff808211156113fc57600080fd5b611408368387016110be565b6020840152604085013591508082111561142157600080fd5b61142d368387016110be565b604084015261143f366060870161129f565b606084015261145060e08601610f29565b608084015261010085013591508082111561146a57600080fd5b611476368387016110be565b60a084015261012085013591508082111561149057600080fd5b5061149d368286016110be565b60c0830152506114b1366101408501611345565b60e082015292915050565b6000602082840312156114ce57600080fd5b815161090b81610e60565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b60008151808452602080850194506020840160005b8381101561154f57815173ffffffffffffffffffffffffffffffffffffffff168752958201959082019060010161151d565b509495945050505050565b600073ffffffffffffffffffffffffffffffffffffffff808816835260ff8716602084015260a0604084015261159360a0840187611508565b948116606084015292909216608090910152509392505050565b600073ffffffffffffffffffffffffffffffffffffffff808916835260ff8816602084015260c060408401526115e660c0840188611508565b9581166060840152931515608083015250911660a0909101529392505050565b828482376000838201600081528351611623818360208801610fe4565b0195945050505050565b6040808252835182820181905260009190606090818501906020808901865b8381101561167257815167ffffffffffffffff168552938201939082019060010161164c565b50508683038188015287518084528184019250600581811b850183018a840160005b848110156117f5578783037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe00187528151805167ffffffffffffffff1684528681015161012088860181905281519086018190526101408087019282891b880190910191908a019060005b8181101561174b577ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec0898503018552611739848451611008565b948c01949350918b01916001016116ff565b5050508c83015191508581038d8701526117658183611008565b9150508a8201516117a68c8701828051151582526020808201516fffffffffffffffffffffffffffffffff9081169184019190915260409182015116910152565b50608091909101518051151560c086015260208101516fffffffffffffffffffffffffffffffff90811660e0870152604082015116610100860152909787019793505090850190600101611694565b50909c9b505050505050505050505050565b60008351611819818460208801610fe4565b83519083019061182d818360208801610fe4565b0194935050505056fea164736f6c6343000818000a
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000048b911a1ae5dd4f0aee5241a30d3deda3501d5400000000000000000000000095ade250c01701a4c63d0893c954a510f7938dc600000000000000000000000032270e4fa459ca47ae0334488e27ffb9bc9ab4a10000000000000000000000007c19b79d2a054114ab36ad758a36e92376e267da
-----Decoded View---------------
Arg [0] : tokenAdminRegistry (address): 0x048B911A1AE5dD4f0aEE5241A30d3DEDa3501D54
Arg [1] : tokenAdminModule (address): 0x95AdE250c01701a4C63D0893C954A510f7938Dc6
Arg [2] : rmnProxy (address): 0x32270E4FA459cA47ae0334488e27ffb9bC9aB4a1
Arg [3] : ccipRouter (address): 0x7c19b79D2a054114Ab36ad758A36e92376e267DA
-----Encoded View---------------
4 Constructor Arguments found :
Arg [0] : 000000000000000000000000048b911a1ae5dd4f0aee5241a30d3deda3501d54
Arg [1] : 00000000000000000000000095ade250c01701a4c63d0893c954a510f7938dc6
Arg [2] : 00000000000000000000000032270e4fa459ca47ae0334488e27ffb9bc9ab4a1
Arg [3] : 0000000000000000000000007c19b79d2a054114ab36ad758a36e92376e267da
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.