Overview
ETH Balance
ETH Value
$0.00Latest 1 from a total of 1 transactions
| Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
|---|---|---|---|---|---|---|---|---|---|
| Bridge Asset | 8333155 | 116 days ago | IN | 0.000001 ETH | 0.00000141 |
Latest 2 internal transactions
| Parent Transaction Hash | Block | From | To | |||
|---|---|---|---|---|---|---|
| 4281537 | 163 days ago | Contract Creation | 0 ETH | |||
| 4281537 | 163 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: AGPL-3.0
pragma solidity 0.8.28;
import "../interfaces/IBridgeL2SovereignChains.sol";
import "../PolygonZkEVMBridgeV2.sol";
import "../interfaces/IGlobalExitRootManagerL2SovereignChain.sol";
/**
* Sovereign chains bridge that will be deployed on all Sovereign chains
* Contract responsible to manage the token interactions with other networks
* This contract is not meant to replace the current zkEVM bridge contract, but deployed on sovereign networks
*/
contract BridgeL2SovereignChain is
PolygonZkEVMBridgeV2,
IBridgeL2SovereignChains
{
using SafeERC20 for ITokenWrappedBridgeUpgradeable;
// Current bridge version
string public constant BRIDGE_SOVEREIGN_VERSION = "v10.1.2";
// Map to store wrappedAddresses that are not mintable
mapping(address wrappedAddress => bool isNotMintable)
public wrappedAddressIsNotMintable;
// Bridge manager address; can set custom mapping for any token. It's highly recommend to set a timelock at this address after bootstrapping phase
address public bridgeManager;
// Emergency bridge pauser address: can pause the bridge in case of emergency, both bridges and claims
address public emergencyBridgePauser;
// Claimed global index hash chain, updated for every bridge claim as follows
// newClaimedGlobalIndexHashChain = Keccak256(oldClaimedGlobalIndexHashChain,bytes32(claimedGlobalIndex));
bytes32 public claimedGlobalIndexHashChain;
// Unset global index hash chain, updated every time the bridge manager unset a claim
// This should be use only in edge-case/emergency circumstances
// newUnsetGlobalIndexHashChain = Keccak256(oldUnsetGlobalIndexHashChain,bytes32(removedGlobalIndex));
bytes32 public unsetGlobalIndexHashChain;
// Local balance tree mapping
mapping(bytes32 tokenInfoHash => uint256 amount) public localBalanceTree;
/// @dev Deprecated in favor of _initializerVersion at PolygonZkEVMBridgeV2
/// @custom:oz-renamed-from _initializerVersion
uint8 private _initializerVersionLegacy;
// This account will be able to accept the emergencyBridgePauser role
address public pendingEmergencyBridgePauser;
// Emergency bridge unpauser address: can unpause the bridge, both bridges and claims
address public emergencyBridgeUnpauser;
// This account will be able to accept the emergencyBridgeUnpauser role
address public pendingEmergencyBridgeUnpauser;
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
*/
uint256[48] private __gap;
/**
* @dev Emitted when a bridge manager is updated
*/
event SetBridgeManager(address bridgeManager);
/**
* @notice Emitted when the emergencyBridgePauser starts the two-step transfer role setting a new pending emergencyBridgePauser.
* @param currentEmergencyBridgePauser The current emergencyBridgePauser.
* @param newEmergencyBridgePauser The new pending emergencyBridgePauser.
*/
event TransferEmergencyBridgePauserRole(
address currentEmergencyBridgePauser,
address newEmergencyBridgePauser
);
/**
* @notice Emitted when the pending emergencyBridgePauser accepts the emergencyBridgePauser role.
* @param oldEmergencyBridgePauser The previous emergencyBridgePauser.
* @param newEmergencyBridgePauser The new emergencyBridgePauser.
*/
event AcceptEmergencyBridgePauserRole(
address oldEmergencyBridgePauser,
address newEmergencyBridgePauser
);
/**
* @notice Emitted when the emergencyBridgeUnpauser starts the two-step transfer role setting a new pending emergencyBridgeUnpauser.
* @param currentEmergencyBridgeUnpauser The current emergencyBridgeUnpauser.
* @param newEmergencyBridgeUnpauser The new pending emergencyBridgeUnpauser.
*/
event TransferEmergencyBridgeUnpauserRole(
address currentEmergencyBridgeUnpauser,
address newEmergencyBridgeUnpauser
);
/**
* @notice Emitted when the pending emergencyBridgeUnpauser accepts the emergencyBridgeUnpauser role.
* @param oldEmergencyBridgeUnpauser The previous emergencyBridgeUnpauser.
* @param newEmergencyBridgeUnpauser The new emergencyBridgeUnpauser.
*/
event AcceptEmergencyBridgeUnpauserRole(
address oldEmergencyBridgeUnpauser,
address newEmergencyBridgeUnpauser
);
/**
* @dev Emitted when a token address is remapped by a sovereign token address
*/
event SetSovereignTokenAddress(
uint32 originNetwork,
address originTokenAddress,
address sovereignTokenAddress,
bool isNotMintable
);
/**
* @dev Emitted when a legacy token is migrated to a new token
*/
event MigrateLegacyToken(
address sender,
address legacyTokenAddress,
address updatedTokenAddress,
uint256 amount
);
/**
* @dev Emitted when a remapped token is removed from mapping
*/
event RemoveLegacySovereignTokenAddress(address sovereignTokenAddress);
/**
* @dev Emitted when a WETH address is remapped by a sovereign WETH address
*/
event SetSovereignWETHAddress(
address sovereignWETHTokenAddress,
bool isNotMintable
);
/**
* @dev Emitted when the claimed global index hash chain is updated (new claim)
* @param claimedGlobalIndex Global index added to the hash chain
* @param newClaimedGlobalIndexHashChain New global index hash chain value
*/
event UpdatedClaimedGlobalIndexHashChain(
bytes32 claimedGlobalIndex,
bytes32 newClaimedGlobalIndexHashChain
);
/**
* @dev Emitted when the unset global index hash chain is updated
* @param unsetGlobalIndex Global index added to the hash chain
* @param newUnsetGlobalIndexHashChain New global index hash chain value
*/
event UpdatedUnsetGlobalIndexHashChain(
bytes32 unsetGlobalIndex,
bytes32 newUnsetGlobalIndexHashChain
);
/**
* Disable initializers on the implementation following the best practices
*/
constructor() PolygonZkEVMBridgeV2() {
_disableInitializers();
}
/**
* @dev initializer function to set the initial values of the contract when the contract is deployed for the first time
* @param _networkID networkID
* @param _gasTokenAddress gas token address
* @param _gasTokenNetwork gas token network
* @param _globalExitRootManager global exit root manager address
* @param _polygonRollupManager Rollup manager address
* @notice The value of `_polygonRollupManager` on the L2 deployment of the contract will be address(0), so
* emergency state is not possible for the L2 deployment of the bridge in StateTransition chains, intentionally
* @param _gasTokenMetadata Abi encoded gas token metadata
* @param _bridgeManager bridge manager address
* @param _sovereignWETHAddress sovereign WETH address
* @param _sovereignWETHAddressIsNotMintable Flag to indicate if the wrapped ETH is not mintable
* @param _emergencyBridgePauser emergency bridge pauser address, allowed to be zero if the chain wants to disable the feature to stop the bridge
* @param _emergencyBridgeUnpauser emergency bridge unpauser address, allowed to be zero if the chain wants to disable the feature to unpause the bridge
* @param _proxiedTokensManager address of the proxied tokens manager
*/
function initialize(
uint32 _networkID,
address _gasTokenAddress,
uint32 _gasTokenNetwork,
IBasePolygonZkEVMGlobalExitRoot _globalExitRootManager,
address _polygonRollupManager,
bytes memory _gasTokenMetadata,
address _bridgeManager,
address _sovereignWETHAddress,
bool _sovereignWETHAddressIsNotMintable,
address _emergencyBridgePauser,
address _emergencyBridgeUnpauser,
address _proxiedTokensManager
) public virtual reinitializer(3) {
require(
address(_globalExitRootManager) != address(0),
InvalidZeroAddress()
);
// Network ID must be different from 0 for sovereign chains
require(_networkID != 0, InvalidZeroNetworkID());
networkID = _networkID;
globalExitRootManager = _globalExitRootManager;
polygonRollupManager = _polygonRollupManager;
bridgeManager = _bridgeManager;
emergencyBridgePauser = _emergencyBridgePauser;
emit AcceptEmergencyBridgePauserRole(address(0), emergencyBridgePauser);
emergencyBridgeUnpauser = _emergencyBridgeUnpauser;
emit AcceptEmergencyBridgeUnpauserRole(
address(0),
emergencyBridgeUnpauser
);
// Set proxied tokens manager
require(
_proxiedTokensManager != address(this),
BridgeAddressNotAllowed()
);
// It's not allowed proxiedTokensManager to be zero address. If disabling token upgradability is required, add a not owned account like 0xffff...fffff
require(_proxiedTokensManager != address(0), InvalidZeroAddress());
proxiedTokensManager = _proxiedTokensManager;
emit AcceptProxiedTokensManagerRole(address(0), proxiedTokensManager);
// Set gas token
if (_gasTokenAddress == address(0)) {
// Gas token will be ether
if (_gasTokenNetwork != 0) {
revert GasTokenNetworkMustBeZeroOnEther();
}
// Health check for sovereign WETH address
if (
_sovereignWETHAddress != address(0) ||
_sovereignWETHAddressIsNotMintable
) {
revert InvalidSovereignWETHAddressParams();
}
// WETHToken, gasTokenAddress and gasTokenNetwork will be 0
// gasTokenMetadata will be empty
} else {
// Gas token will be an erc20
gasTokenAddress = _gasTokenAddress;
gasTokenNetwork = _gasTokenNetwork;
gasTokenMetadata = _gasTokenMetadata;
// Set sovereign weth token or create new if not provided
if (_sovereignWETHAddress == address(0)) {
// Health check for sovereign WETH address is mintable
if (_sovereignWETHAddressIsNotMintable == true) {
revert InvalidSovereignWETHAddressParams();
}
// Create a wrapped token for WETH, with salt == 0
WETHToken = _deployWrappedToken(
0, // salt
abi.encode("Wrapped Ether", "WETH", 18)
);
} else {
WETHToken = ITokenWrappedBridgeUpgradeable(
_sovereignWETHAddress
);
wrappedAddressIsNotMintable[
_sovereignWETHAddress
] = _sovereignWETHAddressIsNotMintable;
}
}
// Initialize OZ contracts
__ReentrancyGuard_init();
}
/**
* @notice Override the function to prevent the contract from being initialized with this initializer
*/
function initialize(
uint32, // _networkID
address, //_gasTokenAddress
uint32, //_gasTokenNetwork
IBasePolygonZkEVMGlobalExitRoot, //_globalExitRootManager
address, //_polygonRollupManager
bytes memory //_gasTokenMetadata
)
external
override(IPolygonZkEVMBridgeV2, PolygonZkEVMBridgeV2)
initializer
{
revert InvalidInitializeFunction();
}
/**
* @notice Override the function to prevent the usage, only allowed for L1 bridge, not sovereign chains
*/
function initialize() public pure override(PolygonZkEVMBridgeV2) {
revert InvalidInitializeFunction();
}
modifier onlyBridgeManager() {
if (bridgeManager != msg.sender) {
revert OnlyBridgeManager();
}
_;
}
modifier onlyEmergencyBridgePauser() {
if (emergencyBridgePauser != msg.sender) {
revert OnlyEmergencyBridgePauser();
}
_;
}
modifier onlyEmergencyBridgeUnpauser() {
if (emergencyBridgeUnpauser != msg.sender) {
revert OnlyEmergencyBridgeUnpauser();
}
_;
}
modifier onlyGlobalExitRootRemover() {
// Only allowed to be called by GlobalExitRootRemover
if (
IGlobalExitRootManagerL2SovereignChain(
address(globalExitRootManager)
).globalExitRootRemover() != msg.sender
) {
revert OnlyGlobalExitRootRemover();
}
_;
}
/**
* @notice Remap multiple wrapped tokens to a new sovereign token address
* @dev This function is a "multi/batch call" to `setSovereignTokenAddress`
* @param originNetworks Array of Origin networks
* @param originTokenAddresses Origin token address, address of the token at the origin network.
* @param sovereignTokenAddresses Array of Addresses of the sovereign wrapped token
* @param isNotMintable Array of Flags to indicate if the wrapped token is not mintable
*/
function setMultipleSovereignTokenAddress(
uint32[] memory originNetworks,
address[] memory originTokenAddresses,
address[] memory sovereignTokenAddresses,
bool[] memory isNotMintable
) external onlyBridgeManager {
if (
originNetworks.length != originTokenAddresses.length ||
originNetworks.length != sovereignTokenAddresses.length ||
originNetworks.length != isNotMintable.length
) {
revert InputArraysLengthMismatch();
}
// Make multiple calls to setSovereignTokenAddress
for (uint256 i = 0; i < sovereignTokenAddresses.length; i++) {
_setSovereignTokenAddress(
originNetworks[i],
originTokenAddresses[i],
sovereignTokenAddresses[i],
isNotMintable[i]
);
}
}
/**
* @notice Remap a wrapped token to a new sovereign token address
* @dev This function is used to allow any existing token to be mapped with
* origin token.
* @notice If this function is called multiple times for the same existingTokenAddress,
* this will override the previous calls and only keep the last sovereignTokenAddress.
* @notice The tokenInfoToWrappedToken mapping value is replaced by the new sovereign address but it's not the case for the wrappedTokenToTokenInfo map where the value is added, this way user will always be able to withdraw their tokens
* @notice The number of decimals between sovereign token and origin token is not checked, it doesn't affect the bridge functionality but the UI.
* @notice if you set multiple sovereign token addresses for the same pair of originNetwork/originTokenAddress, means you are remapping the same tokenInfoHash
* to different sovereignTokenAddress so all those sovereignTokenAddresses will can bridge the mapped tokenInfoHash.
* @param originNetwork Origin network
* @param originTokenAddress Origin token address, address of the token at the origin network
* @param sovereignTokenAddress Address of the sovereign wrapped token
* @param isNotMintable Flag to indicate if the wrapped token is not mintable
*/
function _setSovereignTokenAddress(
uint32 originNetwork,
address originTokenAddress,
address sovereignTokenAddress,
bool isNotMintable
) internal {
// origin and sovereign token address are not 0
if (
originTokenAddress == address(0) ||
sovereignTokenAddress == address(0)
) {
revert InvalidZeroAddress();
}
// originNetwork != current network, wrapped tokens are always from other networks
if (originNetwork == networkID) {
revert OriginNetworkInvalid();
}
// Check if the token is already mapped
if (
wrappedTokenToTokenInfo[sovereignTokenAddress].originTokenAddress !=
address(0)
) {
revert TokenAlreadyMapped();
}
// Compute token info hash
bytes32 tokenInfoHash = keccak256(
abi.encodePacked(originNetwork, originTokenAddress)
);
// Set the address of the wrapper
tokenInfoToWrappedToken[tokenInfoHash] = sovereignTokenAddress;
// Set the token info mapping
// @note wrappedTokenToTokenInfo mapping is not overwritten while tokenInfoToWrappedToken it is
wrappedTokenToTokenInfo[sovereignTokenAddress] = TokenInformation(
originNetwork,
originTokenAddress
);
wrappedAddressIsNotMintable[sovereignTokenAddress] = isNotMintable;
emit SetSovereignTokenAddress(
originNetwork,
originTokenAddress,
sovereignTokenAddress,
isNotMintable
);
}
/**
* @notice Remove the address of a remapped token from the mapping. Used to stop supporting legacy sovereign tokens
* @notice It also removes the token from the isNotMintable mapping
* @notice Although the token is removed from the mapping, the user will still be able to withdraw their tokens using tokenInfoToWrappedToken mapping
* @param legacySovereignTokenAddress Address of the sovereign wrapped token
*/
function removeLegacySovereignTokenAddress(
address legacySovereignTokenAddress
) external onlyBridgeManager {
// Only allow to remove already remapped tokens
TokenInformation memory tokenInfo = wrappedTokenToTokenInfo[
legacySovereignTokenAddress
];
bytes32 tokenInfoHash = keccak256(
abi.encodePacked(
tokenInfo.originNetwork,
tokenInfo.originTokenAddress
)
);
if (
tokenInfoToWrappedToken[tokenInfoHash] == address(0) ||
tokenInfoToWrappedToken[tokenInfoHash] ==
legacySovereignTokenAddress
) {
revert TokenNotRemapped();
}
delete wrappedTokenToTokenInfo[legacySovereignTokenAddress];
delete wrappedAddressIsNotMintable[legacySovereignTokenAddress];
emit RemoveLegacySovereignTokenAddress(legacySovereignTokenAddress);
}
/**
* @notice Set the custom wrapper for weth
* @notice If this function is called multiple times this will override the previous calls and only keep the last WETHToken.
* @notice WETH will not maintain legacy versions.Users easily should be able to unwrap the legacy WETH and unwrapp it with the new one.
* @param sovereignWETHTokenAddress Address of the sovereign weth token
* @param isNotMintable Flag to indicate if the wrapped token is not mintable
*/
function setSovereignWETHAddress(
address sovereignWETHTokenAddress,
bool isNotMintable
) external onlyBridgeManager {
_setSovereignWETHAddress(sovereignWETHTokenAddress, isNotMintable);
}
function _setSovereignWETHAddress(
address sovereignWETHTokenAddress,
bool isNotMintable
) internal {
if (gasTokenAddress == address(0)) {
revert WETHRemappingNotSupportedOnGasTokenNetworks();
}
WETHToken = ITokenWrappedBridgeUpgradeable(sovereignWETHTokenAddress);
wrappedAddressIsNotMintable[sovereignWETHTokenAddress] = isNotMintable;
emit SetSovereignWETHAddress(sovereignWETHTokenAddress, isNotMintable);
}
/**
* @notice Migrates remapped token (legacy) to the new mapped token. If the token is mintable, it will be burnt and minted, otherwise it will be transferred
* @param legacyTokenAddress Address of legacy token to migrate
* @param amount Legacy token balance to migrate
*/
function migrateLegacyToken(
address legacyTokenAddress,
uint256 amount,
bytes calldata permitData
) external {
// Use permit if any
if (permitData.length != 0) {
_permit(legacyTokenAddress, permitData);
}
// Get current wrapped token address
TokenInformation memory legacyTokenInfo = wrappedTokenToTokenInfo[
legacyTokenAddress
];
if (legacyTokenInfo.originTokenAddress == address(0)) {
revert TokenNotMapped();
}
// Check current token mapped is proposed updatedTokenAddress
address currentTokenAddress = tokenInfoToWrappedToken[
keccak256(
abi.encodePacked(
legacyTokenInfo.originNetwork,
legacyTokenInfo.originTokenAddress
)
)
];
if (currentTokenAddress == legacyTokenAddress) {
revert TokenAlreadyUpdated();
}
// Proceed to migrate the token
uint256 amountToClaim = _bridgeWrappedAsset(
ITokenWrappedBridgeUpgradeable(legacyTokenAddress),
amount
);
_claimWrappedAsset(
ITokenWrappedBridgeUpgradeable(currentTokenAddress),
msg.sender,
amountToClaim
);
// Trigger event
emit MigrateLegacyToken(
msg.sender,
legacyTokenAddress,
currentTokenAddress,
amountToClaim
);
}
/**
* @notice Unset multiple claims from the claimedBitmap
* @dev This function is a "multi/batch call" to `unsetClaimedBitmap`
* @param globalIndexes Global index is defined as:
* | 191 bits | 1 bit | 32 bits | 32 bits |
* | 0 | mainnetFlag | rollupIndex | localRootIndex |
*/
function unsetMultipleClaims(
uint256[] memory globalIndexes
) external onlyGlobalExitRootRemover {
for (uint256 i = 0; i < globalIndexes.length; i++) {
uint256 globalIndex = globalIndexes[i];
// Compute leaf index and sourceBridgeNetwork from global index
uint32 leafIndex;
uint32 sourceBridgeNetwork;
// Get origin network from global index
if (globalIndex & _GLOBAL_INDEX_MAINNET_FLAG != 0) {
// The network is mainnet, therefore sourceBridgeNetwork is 0
// Last 32 bits are leafIndex
leafIndex = uint32(globalIndex);
} else {
// The network is a rollup, therefore sourceBridgeNetwork must be decoded
uint32 indexRollup = uint32(globalIndex >> 32);
sourceBridgeNetwork = indexRollup + 1;
// Last 32 bits are leafIndex
leafIndex = uint32(globalIndex);
}
// Unset the claim
_unsetClaimedBitmap(leafIndex, sourceBridgeNetwork);
// Update globalIndexHashChain
unsetGlobalIndexHashChain = Hashes.efficientKeccak256(
unsetGlobalIndexHashChain,
bytes32(globalIndex)
);
emit UpdatedUnsetGlobalIndexHashChain(
bytes32(globalIndex),
unsetGlobalIndexHashChain
);
}
}
/**
* @notice Function to deploy an upgradeable wrapped token without having to claim asset. It is used to upgrade legacy tokens to the new upgradeable token. After deploying the token it is remapped to be the new functional wtoken
* @notice This function can only be called once for each originNetwork/originTokenAddress pair because it deploys a deterministic contract with create2
* @dev WARNING: It's assumed the legacy token has not been remapped.
* @param originNetwork Origin network of the token
* @param originTokenAddress Origin token address, address of the token at the origin network.
* @param isNotMintable Flag to indicate if the proxied wrapped token is not mintable
*/
function deployWrappedTokenAndRemap(
uint32 originNetwork,
address originTokenAddress,
bool isNotMintable
) external onlyBridgeManager {
/// @dev Check the token is not native from this network is done at `_setSovereignTokenAddress`
if (
originTokenAddress == address(0) &&
originNetwork == _MAINNET_NETWORK_ID
) {
// Deploy weth only supported for chains with gas token where weth address is not zero
/// @dev Check the chain is a gas token chain is done at `_setSovereignWETHAddress`
// Deploy the proxied weth token
address wrappedTokenProxy = address(
_deployWrappedToken(
bytes32(0), // tokenInfoHash is 0 for weth
abi.encode(
WETHToken.name(),
WETHToken.symbol(),
WETHToken.decimals()
)
)
);
// Remap the deployed wrapped token
_setSovereignWETHAddress(wrappedTokenProxy, isNotMintable);
} else {
// Compute tokenInfoHash
bytes32 tokenInfoHash = keccak256(
abi.encodePacked(originNetwork, originTokenAddress)
);
ITokenWrappedBridgeUpgradeable wrappedToken = ITokenWrappedBridgeUpgradeable(
tokenInfoToWrappedToken[tokenInfoHash]
);
// Only allow to deploy a wrapped token if the token is mapped, meaning is a legacy (non upgradeable) wrapped token that will be updated to upgradeable version
require(address(wrappedToken) != address(0), TokenNotMapped());
// Deploy the wrapped token
address wrappedTokenProxy = address(
_deployWrappedToken(
tokenInfoHash,
abi.encode(
wrappedToken.name(),
wrappedToken.symbol(),
wrappedToken.decimals()
)
)
);
// Remap the deployed wrapped token
_setSovereignTokenAddress(
originNetwork,
originTokenAddress,
wrappedTokenProxy,
isNotMintable
);
}
}
/**
* @notice Updated bridge manager address, recommended to set a timelock at this address after bootstrapping phase
* @param _bridgeManager Bridge manager address
*/
function setBridgeManager(
address _bridgeManager
) external onlyBridgeManager {
if (_bridgeManager == address(0)) {
revert InvalidZeroAddress();
}
bridgeManager = _bridgeManager;
emit SetBridgeManager(bridgeManager);
}
/////////////////////////////////////////
// EmergencyBridge functions //
///////////////////////////////////////
/**
* @notice Starts the emergencyBridgePauser role transfer
* This is a two step process, the pending emergencyBridgePauser must accepted to finalize the process
* @param newEmergencyBridgePauser Address of the new pending emergencyBridgePauser
*/
function transferEmergencyBridgePauserRole(
address newEmergencyBridgePauser
) external onlyEmergencyBridgePauser {
pendingEmergencyBridgePauser = newEmergencyBridgePauser;
emit TransferEmergencyBridgePauserRole(
emergencyBridgePauser,
newEmergencyBridgePauser
);
}
/**
* @notice Allow the current pending emergencyBridgePauser to accept the emergencyBridgePauser role
*/
function acceptEmergencyBridgePauserRole() external {
require(
pendingEmergencyBridgePauser == msg.sender,
OnlyPendingEmergencyBridgePauser()
);
address oldEmergencyBridgePauser = emergencyBridgePauser;
emergencyBridgePauser = pendingEmergencyBridgePauser;
delete pendingEmergencyBridgePauser;
emit AcceptEmergencyBridgePauserRole(
oldEmergencyBridgePauser,
emergencyBridgePauser
);
}
/**
* @notice Starts the emergencyBridgeUnpauser role transfer
* This is a two step process, the pending emergencyBridgeUnpauser must accepted to finalize the process
* @param newEmergencyBridgeUnpauser Address of the new pending emergencyBridgeUnpauser
*/
function transferEmergencyBridgeUnpauserRole(
address newEmergencyBridgeUnpauser
) external onlyEmergencyBridgeUnpauser {
pendingEmergencyBridgeUnpauser = newEmergencyBridgeUnpauser;
emit TransferEmergencyBridgeUnpauserRole(
emergencyBridgeUnpauser,
newEmergencyBridgeUnpauser
);
}
/**
* @notice Allow the current pending emergencyBridgeUnpauser to accept the emergencyBridgeUnpauser role
*/
function acceptEmergencyBridgeUnpauserRole() external {
require(
pendingEmergencyBridgeUnpauser == msg.sender,
OnlyPendingEmergencyBridgeUnpauser()
);
address oldEmergencyBridgeUnpauser = emergencyBridgeUnpauser;
emergencyBridgeUnpauser = pendingEmergencyBridgeUnpauser;
delete pendingEmergencyBridgeUnpauser;
emit AcceptEmergencyBridgePauserRole(
oldEmergencyBridgeUnpauser,
emergencyBridgeUnpauser
);
}
////////////////////////////
// Private functions //
///////////////////////////
/**
* @notice Burn tokens from wrapped token to execute the bridge, if the token is not mintable it will be transferred
* note This function has been extracted to be able to override it by other contracts like Bridge2SovereignChain
* @param tokenWrapped Proxied Wrapped token to burnt
* @param amount Amount of tokens
* @return Amount of tokens that must be added to the leaf after the bridge operation
* @dev in case of tokens with non-standard transfers behavior like fee-on-transfer tokens or Max-value amount transfers user balance tokens,
* It is possible that the amount of tokens sent is different from the amount of tokens received, in those cases, the amount that should be
* added to the leaf has to be the amount received by the bridge
*/
function _bridgeWrappedAsset(
ITokenWrappedBridgeUpgradeable tokenWrapped,
uint256 amount
) internal override returns (uint256) {
// The token is either (1) a correctly wrapped token from another network
// or (2) wrapped with custom contract from origin network
if (wrappedAddressIsNotMintable[address(tokenWrapped)]) {
uint256 balanceBefore = tokenWrapped.balanceOf(address(this));
// Don't use burn but transfer to bridge
tokenWrapped.safeTransferFrom(msg.sender, address(this), amount);
uint256 balanceAfter = tokenWrapped.balanceOf(address(this));
return balanceAfter - balanceBefore;
} else {
// Burn tokens
tokenWrapped.burn(msg.sender, amount);
return amount;
}
}
/**
* @notice Mints tokens from wrapped token to proceed with the claim, if the token is not mintable it will be transferred
* note This function has been extracted to be able to override it by other contracts like BridgeL2SovereignChain
* @param tokenWrapped Proxied wrapped token to mint
* @param destinationAddress Minted token receiver
* @param amount Amount of tokens
*/
function _claimWrappedAsset(
ITokenWrappedBridgeUpgradeable tokenWrapped,
address destinationAddress,
uint256 amount
) internal override {
// If is not mintable transfer instead of mint
if (wrappedAddressIsNotMintable[address(tokenWrapped)]) {
// Transfer tokens
tokenWrapped.safeTransfer(destinationAddress, amount);
} else {
// Claim tokens
tokenWrapped.mint(destinationAddress, amount);
}
}
/**
* @notice unset a claim from the claimedBitmap
* @param leafIndex Index
* @param sourceBridgeNetwork Origin network
*/
function _unsetClaimedBitmap(
uint32 leafIndex,
uint32 sourceBridgeNetwork
) private {
uint256 globalIndex = uint256(leafIndex) +
uint256(sourceBridgeNetwork) *
_MAX_LEAFS_PER_NETWORK;
(uint256 wordPos, uint256 bitPos) = _bitmapPositions(globalIndex);
uint256 mask = 1 << bitPos;
uint256 flipped = claimedBitMap[wordPos] ^= mask;
if (flipped & mask != 0) {
revert ClaimNotSet();
}
}
/**
* @notice Function to check if an index is claimed or not
* @dev function overridden to improve a bit the performance and bytecode not checking unnecessary conditions for sovereign chains context
* @param leafIndex Index
* @param sourceBridgeNetwork Origin network
*/
function isClaimed(
uint32 leafIndex,
uint32 sourceBridgeNetwork
) external view override returns (bool) {
uint256 globalIndex = uint256(leafIndex) +
uint256(sourceBridgeNetwork) *
_MAX_LEAFS_PER_NETWORK;
(uint256 wordPos, uint256 bitPos) = _bitmapPositions(globalIndex);
uint256 mask = (1 << bitPos);
return (claimedBitMap[wordPos] & mask) == mask;
}
/**
* @notice Function to check that an index is not claimed and set it as claimed
* @dev function overridden to improve a bit the performance and bytecode not checking unnecessary conditions for sovereign chains context
* @param leafIndex Index
* @param sourceBridgeNetwork Origin network
*/
function _setAndCheckClaimed(
uint32 leafIndex,
uint32 sourceBridgeNetwork
) internal override {
uint256 globalIndex = uint256(leafIndex) +
uint256(sourceBridgeNetwork) *
_MAX_LEAFS_PER_NETWORK;
(uint256 wordPos, uint256 bitPos) = _bitmapPositions(globalIndex);
uint256 mask = 1 << bitPos;
uint256 flipped = claimedBitMap[wordPos] ^= mask;
if (flipped & mask == 0) {
revert AlreadyClaimed();
}
}
// @note This function is not used in the current implementation. We overwrite it to improve deployed bytecode size
function activateEmergencyState()
external
override(IPolygonZkEVMBridgeV2, PolygonZkEVMBridgeV2)
onlyEmergencyBridgePauser
{
_activateEmergencyState();
}
function deactivateEmergencyState()
external
override(IPolygonZkEVMBridgeV2, PolygonZkEVMBridgeV2)
onlyEmergencyBridgeUnpauser
{
_deactivateEmergencyState();
}
///////////////////////////
//// LocalBalanceTree /////
///////////////////////////
/**
* @notice Function to decrease the local balance tree
* @param originNetwork Origin network
* @param originTokenAddress Origin token address
* @param amount Amount to decrease
*/
function _decreaseLocalBalanceTree(
uint32 originNetwork,
address originTokenAddress,
uint256 amount
) internal {
// If the token is generated in this chain does not modify the Local Balance Tree
if (originNetwork == networkID) {
return;
}
// compute tokenInfoHash which identifies uniquely the token in the LocalBalanceTree
bytes32 tokenInfoHash = keccak256(
abi.encodePacked(originNetwork, originTokenAddress)
);
// revert due to an underflow explicitly
// custom error added to not wait for the EVM to revert when subtracting from uint256
if (amount > localBalanceTree[tokenInfoHash]) {
revert LocalBalanceTreeUnderflow(
originNetwork,
originTokenAddress,
amount,
localBalanceTree[tokenInfoHash]
);
}
// underflow is controlled by the previous error
localBalanceTree[tokenInfoHash] -= amount;
}
/**
* @notice Function to increase the local balance tree
* @param originNetwork Origin network
* @param originTokenAddress Origin token address
* @param amount Amount to increase
*/
function _increaseLocalBalanceTree(
uint32 originNetwork,
address originTokenAddress,
uint256 amount
) internal {
// If the token is generated in this chain does not modify the Local Balance Tree
if (originNetwork == networkID) {
return;
}
// compute tokenInfoHash which identifies uniquely the token in the LocalBalanceTree
bytes32 tokenInfoHash = keccak256(
abi.encodePacked(originNetwork, originTokenAddress)
);
// revert due to an overflow explicitly
// custom error added to not wait for the EVM to revert when adding above uint256
if (amount > type(uint256).max - localBalanceTree[tokenInfoHash]) {
revert LocalBalanceTreeOverflow(
originNetwork,
originTokenAddress,
amount,
localBalanceTree[tokenInfoHash]
);
}
// overflows is controlled by the previous error
localBalanceTree[tokenInfoHash] += amount;
}
/**
* @notice Function to add a new leaf to the bridge merkle tree
* @param leafType leaf type
* @param originNetwork Origin network
* @param originAddress Origin address
* @param destinationNetwork Destination network
* @param destinationAddress Destination address
* @param amount Amount of tokens
* @param metadataHash Metadata hash
*/
function _addLeafBridge(
uint8 leafType,
uint32 originNetwork,
address originAddress,
uint32 destinationNetwork,
address destinationAddress,
uint256 amount,
bytes32 metadataHash
) internal override {
super._addLeafBridge(
leafType,
originNetwork,
originAddress,
destinationNetwork,
destinationAddress,
amount,
metadataHash
);
if (leafType == _LEAF_TYPE_ASSET) {
_decreaseLocalBalanceTree(originNetwork, originAddress, amount);
}
if (leafType == _LEAF_TYPE_MESSAGE) {
_decreaseLocalBalanceTree(_MAINNET_NETWORK_ID, address(0), amount);
}
}
/**
* @notice Get leaf value and verify the merkle proof
* @param smtProofLocalExitRoot Smt proof to proof the leaf against the exit root
* @param smtProofRollupExitRoot Smt proof to proof the rollupLocalExitRoot against the rollups exit root
* @param globalIndex Global index
* @param mainnetExitRoot Mainnet exit root
* @param rollupExitRoot Rollup exit root
* @param leafType Leaf type
* @param originNetwork Origin network
* @param originAddress Origin address
* @param destinationNetwork Network destination
* @param destinationAddress Address destination
* @param amount message value
* @param metadataHash Hash of the metadata
*/
function _verifyLeafBridge(
bytes32[_DEPOSIT_CONTRACT_TREE_DEPTH] calldata smtProofLocalExitRoot,
bytes32[_DEPOSIT_CONTRACT_TREE_DEPTH] calldata smtProofRollupExitRoot,
uint256 globalIndex,
bytes32 mainnetExitRoot,
bytes32 rollupExitRoot,
uint8 leafType,
uint32 originNetwork,
address originAddress,
uint32 destinationNetwork,
address destinationAddress,
uint256 amount,
bytes32 metadataHash
) internal override {
bytes32 leafValue = getLeafValue(
leafType,
originNetwork,
originAddress,
destinationNetwork,
destinationAddress,
amount,
metadataHash
);
_verifyLeaf(
smtProofLocalExitRoot,
smtProofRollupExitRoot,
globalIndex,
mainnetExitRoot,
rollupExitRoot,
leafValue
);
// Update claimedGlobalIndexHashChain
claimedGlobalIndexHashChain = Hashes.efficientKeccak256(
claimedGlobalIndexHashChain,
Hashes.efficientKeccak256(bytes32(globalIndex), leafValue)
);
emit UpdatedClaimedGlobalIndexHashChain(
bytes32(globalIndex),
claimedGlobalIndexHashChain
);
if (leafType == _LEAF_TYPE_ASSET) {
_increaseLocalBalanceTree(originNetwork, originAddress, amount);
}
if (leafType == _LEAF_TYPE_MESSAGE) {
_increaseLocalBalanceTree(_MAINNET_NETWORK_ID, address(0), amount);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.1) (proxy/utils/Initializable.sol)
pragma solidity ^0.8.2;
import "../../utils/AddressUpgradeable.sol";
/**
* @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
* behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
* external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
* function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
*
* The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
* reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
* case an upgrade adds a module that needs to be initialized.
*
* For example:
*
* [.hljs-theme-light.nopadding]
* ```
* contract MyToken is ERC20Upgradeable {
* function initialize() initializer public {
* __ERC20_init("MyToken", "MTK");
* }
* }
* contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
* function initializeV2() reinitializer(2) public {
* __ERC20Permit_init("MyToken");
* }
* }
* ```
*
* TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
* possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
*
* CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
* that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
*
* [CAUTION]
* ====
* Avoid leaving a contract uninitialized.
*
* An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
* contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
* the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
*
* [.hljs-theme-light.nopadding]
* ```
* /// @custom:oz-upgrades-unsafe-allow constructor
* constructor() {
* _disableInitializers();
* }
* ```
* ====
*/
abstract contract Initializable {
/**
* @dev Indicates that the contract has been initialized.
* @custom:oz-retyped-from bool
*/
uint8 private _initialized;
/**
* @dev Indicates that the contract is in the process of being initialized.
*/
bool private _initializing;
/**
* @dev Triggered when the contract has been initialized or reinitialized.
*/
event Initialized(uint8 version);
/**
* @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
* `onlyInitializing` functions can be used to initialize parent contracts.
*
* Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a
* constructor.
*
* Emits an {Initialized} event.
*/
modifier initializer() {
bool isTopLevelCall = !_initializing;
require(
(isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),
"Initializable: contract is already initialized"
);
_initialized = 1;
if (isTopLevelCall) {
_initializing = true;
}
_;
if (isTopLevelCall) {
_initializing = false;
emit Initialized(1);
}
}
/**
* @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
* contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
* used to initialize parent contracts.
*
* A reinitializer may be used after the original initialization step. This is essential to configure modules that
* are added through upgrades and that require initialization.
*
* When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
* cannot be nested. If one is invoked in the context of another, execution will revert.
*
* Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
* a contract, executing them in the right order is up to the developer or operator.
*
* WARNING: setting the version to 255 will prevent any future reinitialization.
*
* Emits an {Initialized} event.
*/
modifier reinitializer(uint8 version) {
require(!_initializing && _initialized < version, "Initializable: contract is already initialized");
_initialized = version;
_initializing = true;
_;
_initializing = false;
emit Initialized(version);
}
/**
* @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
* {initializer} and {reinitializer} modifiers, directly or indirectly.
*/
modifier onlyInitializing() {
require(_initializing, "Initializable: contract is not initializing");
_;
}
/**
* @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
* Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
* to any version. It is recommended to use this to lock implementation contracts that are designed to be called
* through proxies.
*
* Emits an {Initialized} event the first time it is successfully executed.
*/
function _disableInitializers() internal virtual {
require(!_initializing, "Initializable: contract is initializing");
if (_initialized < type(uint8).max) {
_initialized = type(uint8).max;
emit Initialized(type(uint8).max);
}
}
/**
* @dev Returns the highest version that has been initialized. See {reinitializer}.
*/
function _getInitializedVersion() internal view returns (uint8) {
return _initialized;
}
/**
* @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.
*/
function _isInitializing() internal view returns (bool) {
return _initializing;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (security/ReentrancyGuard.sol)
pragma solidity ^0.8.0;
import "../proxy/utils/Initializable.sol";
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuardUpgradeable is Initializable {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
function __ReentrancyGuard_init() internal onlyInitializing {
__ReentrancyGuard_init_unchained();
}
function __ReentrancyGuard_init_unchained() internal onlyInitializing {
_status = _NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
// On the first call to nonReentrant, _status will be _NOT_ENTERED
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
}
function _nonReentrantAfter() private {
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[49] private __gap;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library AddressUpgradeable {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
* the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
*
* _Available since v4.8._
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata,
string memory errorMessage
) internal view returns (bytes memory) {
if (success) {
if (returndata.length == 0) {
// only check isContract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
require(isContract(target), "Address: call to non-contract");
}
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
/**
* @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason or using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
function _revert(bytes memory returndata, string memory errorMessage) private pure {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/Initializable.sol)
pragma solidity ^0.8.20;
/**
* @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
* behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
* external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
* function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
*
* The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
* reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
* case an upgrade adds a module that needs to be initialized.
*
* For example:
*
* [.hljs-theme-light.nopadding]
* ```solidity
* contract MyToken is ERC20Upgradeable {
* function initialize() initializer public {
* __ERC20_init("MyToken", "MTK");
* }
* }
*
* contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
* function initializeV2() reinitializer(2) public {
* __ERC20Permit_init("MyToken");
* }
* }
* ```
*
* TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
* possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
*
* CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
* that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
*
* [CAUTION]
* ====
* Avoid leaving a contract uninitialized.
*
* An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
* contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
* the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
*
* [.hljs-theme-light.nopadding]
* ```
* /// @custom:oz-upgrades-unsafe-allow constructor
* constructor() {
* _disableInitializers();
* }
* ```
* ====
*/
abstract contract Initializable {
/**
* @dev Storage of the initializable contract.
*
* It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions
* when using with upgradeable contracts.
*
* @custom:storage-location erc7201:openzeppelin.storage.Initializable
*/
struct InitializableStorage {
/**
* @dev Indicates that the contract has been initialized.
*/
uint64 _initialized;
/**
* @dev Indicates that the contract is in the process of being initialized.
*/
bool _initializing;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Initializable")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00;
/**
* @dev The contract is already initialized.
*/
error InvalidInitialization();
/**
* @dev The contract is not initializing.
*/
error NotInitializing();
/**
* @dev Triggered when the contract has been initialized or reinitialized.
*/
event Initialized(uint64 version);
/**
* @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
* `onlyInitializing` functions can be used to initialize parent contracts.
*
* Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any
* number of times. This behavior in the constructor can be useful during testing and is not expected to be used in
* production.
*
* Emits an {Initialized} event.
*/
modifier initializer() {
// solhint-disable-next-line var-name-mixedcase
InitializableStorage storage $ = _getInitializableStorage();
// Cache values to avoid duplicated sloads
bool isTopLevelCall = !$._initializing;
uint64 initialized = $._initialized;
// Allowed calls:
// - initialSetup: the contract is not in the initializing state and no previous version was
// initialized
// - construction: the contract is initialized at version 1 (no reininitialization) and the
// current contract is just being deployed
bool initialSetup = initialized == 0 && isTopLevelCall;
bool construction = initialized == 1 && address(this).code.length == 0;
if (!initialSetup && !construction) {
revert InvalidInitialization();
}
$._initialized = 1;
if (isTopLevelCall) {
$._initializing = true;
}
_;
if (isTopLevelCall) {
$._initializing = false;
emit Initialized(1);
}
}
/**
* @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
* contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
* used to initialize parent contracts.
*
* A reinitializer may be used after the original initialization step. This is essential to configure modules that
* are added through upgrades and that require initialization.
*
* When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
* cannot be nested. If one is invoked in the context of another, execution will revert.
*
* Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
* a contract, executing them in the right order is up to the developer or operator.
*
* WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization.
*
* Emits an {Initialized} event.
*/
modifier reinitializer(uint64 version) {
// solhint-disable-next-line var-name-mixedcase
InitializableStorage storage $ = _getInitializableStorage();
if ($._initializing || $._initialized >= version) {
revert InvalidInitialization();
}
$._initialized = version;
$._initializing = true;
_;
$._initializing = false;
emit Initialized(version);
}
/**
* @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
* {initializer} and {reinitializer} modifiers, directly or indirectly.
*/
modifier onlyInitializing() {
_checkInitializing();
_;
}
/**
* @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}.
*/
function _checkInitializing() internal view virtual {
if (!_isInitializing()) {
revert NotInitializing();
}
}
/**
* @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
* Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
* to any version. It is recommended to use this to lock implementation contracts that are designed to be called
* through proxies.
*
* Emits an {Initialized} event the first time it is successfully executed.
*/
function _disableInitializers() internal virtual {
// solhint-disable-next-line var-name-mixedcase
InitializableStorage storage $ = _getInitializableStorage();
if ($._initializing) {
revert InvalidInitialization();
}
if ($._initialized != type(uint64).max) {
$._initialized = type(uint64).max;
emit Initialized(type(uint64).max);
}
}
/**
* @dev Returns the highest version that has been initialized. See {reinitializer}.
*/
function _getInitializedVersion() internal view returns (uint64) {
return _getInitializableStorage()._initialized;
}
/**
* @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.
*/
function _isInitializing() internal view returns (bool) {
return _getInitializableStorage()._initializing;
}
/**
* @dev Returns a pointer to the storage namespace.
*/
// solhint-disable-next-line var-name-mixedcase
function _getInitializableStorage() private pure returns (InitializableStorage storage $) {
assembly {
$.slot := INITIALIZABLE_STORAGE
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/ERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
import {ContextUpgradeable} from "../../utils/ContextUpgradeable.sol";
import {IERC20Errors} from "@openzeppelin/contracts/interfaces/draft-IERC6093.sol";
import {Initializable} from "../../proxy/utils/Initializable.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}.
*
* 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].
*
* The default value of {decimals} is 18. To change this, you should override
* this function so it returns a different value.
*
* 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.
*/
abstract contract ERC20Upgradeable is Initializable, ContextUpgradeable, IERC20, IERC20Metadata, IERC20Errors {
/// @custom:storage-location erc7201:openzeppelin.storage.ERC20
struct ERC20Storage {
mapping(address account => uint256) _balances;
mapping(address account => mapping(address spender => uint256)) _allowances;
uint256 _totalSupply;
string _name;
string _symbol;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.ERC20")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant ERC20StorageLocation = 0x52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace00;
function _getERC20Storage() private pure returns (ERC20Storage storage $) {
assembly {
$.slot := ERC20StorageLocation
}
}
/**
* @dev Sets the values for {name} and {symbol}.
*
* All two of these values are immutable: they can only be set once during
* construction.
*/
function __ERC20_init(string memory name_, string memory symbol_) internal onlyInitializing {
__ERC20_init_unchained(name_, symbol_);
}
function __ERC20_init_unchained(string memory name_, string memory symbol_) internal onlyInitializing {
ERC20Storage storage $ = _getERC20Storage();
$._name = name_;
$._symbol = symbol_;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual returns (string memory) {
ERC20Storage storage $ = _getERC20Storage();
return $._name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual returns (string memory) {
ERC20Storage storage $ = _getERC20Storage();
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 default value returned by this function, unless
* it's 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 returns (uint8) {
return 18;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual returns (uint256) {
ERC20Storage storage $ = _getERC20Storage();
return $._totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual returns (uint256) {
ERC20Storage storage $ = _getERC20Storage();
return $._balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - the caller must have a balance of at least `value`.
*/
function transfer(address to, uint256 value) public virtual returns (bool) {
address owner = _msgSender();
_transfer(owner, to, value);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual returns (uint256) {
ERC20Storage storage $ = _getERC20Storage();
return $._allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* NOTE: If `value` 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 value) public virtual returns (bool) {
address owner = _msgSender();
_approve(owner, spender, value);
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 `value`.
* - the caller must have allowance for ``from``'s tokens of at least
* `value`.
*/
function transferFrom(address from, address to, uint256 value) public virtual returns (bool) {
address spender = _msgSender();
_spendAllowance(from, spender, value);
_transfer(from, to, value);
return true;
}
/**
* @dev Moves a `value` 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.
*
* NOTE: This function is not virtual, {_update} should be overridden instead.
*/
function _transfer(address from, address to, uint256 value) internal {
if (from == address(0)) {
revert ERC20InvalidSender(address(0));
}
if (to == address(0)) {
revert ERC20InvalidReceiver(address(0));
}
_update(from, to, value);
}
/**
* @dev Transfers a `value` amount of tokens from `from` to `to`, or alternatively mints (or burns) if `from`
* (or `to`) is the zero address. All customizations to transfers, mints, and burns should be done by overriding
* this function.
*
* Emits a {Transfer} event.
*/
function _update(address from, address to, uint256 value) internal virtual {
ERC20Storage storage $ = _getERC20Storage();
if (from == address(0)) {
// Overflow check required: The rest of the code assumes that totalSupply never overflows
$._totalSupply += value;
} else {
uint256 fromBalance = $._balances[from];
if (fromBalance < value) {
revert ERC20InsufficientBalance(from, fromBalance, value);
}
unchecked {
// Overflow not possible: value <= fromBalance <= totalSupply.
$._balances[from] = fromBalance - value;
}
}
if (to == address(0)) {
unchecked {
// Overflow not possible: value <= totalSupply or value <= fromBalance <= totalSupply.
$._totalSupply -= value;
}
} else {
unchecked {
// Overflow not possible: balance + value is at most totalSupply, which we know fits into a uint256.
$._balances[to] += value;
}
}
emit Transfer(from, to, value);
}
/**
* @dev Creates a `value` amount of tokens and assigns them to `account`, by transferring it from address(0).
* Relies on the `_update` mechanism
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* NOTE: This function is not virtual, {_update} should be overridden instead.
*/
function _mint(address account, uint256 value) internal {
if (account == address(0)) {
revert ERC20InvalidReceiver(address(0));
}
_update(address(0), account, value);
}
/**
* @dev Destroys a `value` amount of tokens from `account`, lowering the total supply.
* Relies on the `_update` mechanism.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* NOTE: This function is not virtual, {_update} should be overridden instead
*/
function _burn(address account, uint256 value) internal {
if (account == address(0)) {
revert ERC20InvalidSender(address(0));
}
_update(account, address(0), value);
}
/**
* @dev Sets `value` 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.
*
* Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument.
*/
function _approve(address owner, address spender, uint256 value) internal {
_approve(owner, spender, value, true);
}
/**
* @dev Variant of {_approve} with an optional flag to enable or disable the {Approval} event.
*
* By default (when calling {_approve}) the flag is set to true. On the other hand, approval changes made by
* `_spendAllowance` during the `transferFrom` operation set the flag to false. This saves gas by not emitting any
* `Approval` event during `transferFrom` operations.
*
* Anyone who wishes to continue emitting `Approval` events on the`transferFrom` operation can force the flag to
* true using the following override:
* ```
* function _approve(address owner, address spender, uint256 value, bool) internal virtual override {
* super._approve(owner, spender, value, true);
* }
* ```
*
* Requirements are the same as {_approve}.
*/
function _approve(address owner, address spender, uint256 value, bool emitEvent) internal virtual {
ERC20Storage storage $ = _getERC20Storage();
if (owner == address(0)) {
revert ERC20InvalidApprover(address(0));
}
if (spender == address(0)) {
revert ERC20InvalidSpender(address(0));
}
$._allowances[owner][spender] = value;
if (emitEvent) {
emit Approval(owner, spender, value);
}
}
/**
* @dev Updates `owner` s allowance for `spender` based on spent `value`.
*
* Does not update the allowance value in case of infinite allowance.
* Revert if not enough allowance is available.
*
* Does not emit an {Approval} event.
*/
function _spendAllowance(address owner, address spender, uint256 value) internal virtual {
uint256 currentAllowance = allowance(owner, spender);
if (currentAllowance != type(uint256).max) {
if (currentAllowance < value) {
revert ERC20InsufficientAllowance(spender, currentAllowance, value);
}
unchecked {
_approve(owner, spender, currentAllowance - value, false);
}
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/ERC20Permit.sol)
pragma solidity ^0.8.20;
import {IERC20Permit} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol";
import {ERC20Upgradeable} from "../ERC20Upgradeable.sol";
import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import {EIP712Upgradeable} from "../../../utils/cryptography/EIP712Upgradeable.sol";
import {NoncesUpgradeable} from "../../../utils/NoncesUpgradeable.sol";
import {Initializable} from "../../../proxy/utils/Initializable.sol";
/**
* @dev Implementation of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
* https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
*
* Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
* presenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't
* need to send a transaction, and thus is not required to hold Ether at all.
*/
abstract contract ERC20PermitUpgradeable is Initializable, ERC20Upgradeable, IERC20Permit, EIP712Upgradeable, NoncesUpgradeable {
bytes32 private constant PERMIT_TYPEHASH =
keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)");
/**
* @dev Permit deadline has expired.
*/
error ERC2612ExpiredSignature(uint256 deadline);
/**
* @dev Mismatched signature.
*/
error ERC2612InvalidSigner(address signer, address owner);
/**
* @dev Initializes the {EIP712} domain separator using the `name` parameter, and setting `version` to `"1"`.
*
* It's a good idea to use the same `name` that is defined as the ERC20 token name.
*/
function __ERC20Permit_init(string memory name) internal onlyInitializing {
__EIP712_init_unchained(name, "1");
}
function __ERC20Permit_init_unchained(string memory) internal onlyInitializing {}
/**
* @inheritdoc IERC20Permit
*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) public virtual {
if (block.timestamp > deadline) {
revert ERC2612ExpiredSignature(deadline);
}
bytes32 structHash = keccak256(abi.encode(PERMIT_TYPEHASH, owner, spender, value, _useNonce(owner), deadline));
bytes32 hash = _hashTypedDataV4(structHash);
address signer = ECDSA.recover(hash, v, r, s);
if (signer != owner) {
revert ERC2612InvalidSigner(signer, owner);
}
_approve(owner, spender, value);
}
/**
* @inheritdoc IERC20Permit
*/
function nonces(address owner) public view virtual override(IERC20Permit, NoncesUpgradeable) returns (uint256) {
return super.nonces(owner);
}
/**
* @inheritdoc IERC20Permit
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view virtual returns (bytes32) {
return _domainSeparatorV4();
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Context.sol)
pragma solidity ^0.8.20;
import {Initializable} from "../proxy/utils/Initializable.sol";
/**
* @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 ContextUpgradeable is Initializable {
function __Context_init() internal onlyInitializing {
}
function __Context_init_unchained() internal onlyInitializing {
}
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
// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/EIP712.sol)
pragma solidity ^0.8.20;
import {MessageHashUtils} from "@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol";
import {IERC5267} from "@openzeppelin/contracts/interfaces/IERC5267.sol";
import {Initializable} from "../../proxy/utils/Initializable.sol";
/**
* @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data.
*
* The encoding scheme specified in the EIP requires a domain separator and a hash of the typed structured data, whose
* encoding is very generic and therefore its implementation in Solidity is not feasible, thus this contract
* does not implement the encoding itself. Protocols need to implement the type-specific encoding they need in order to
* produce the hash of their typed data using a combination of `abi.encode` and `keccak256`.
*
* This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding
* scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA
* ({_hashTypedDataV4}).
*
* The implementation of the domain separator was designed to be as efficient as possible while still properly updating
* the chain id to protect against replay attacks on an eventual fork of the chain.
*
* NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method
* https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].
*
* NOTE: In the upgradeable version of this contract, the cached values will correspond to the address, and the domain
* separator of the implementation contract. This will cause the {_domainSeparatorV4} function to always rebuild the
* separator from the immutable values, which is cheaper than accessing a cached version in cold storage.
*/
abstract contract EIP712Upgradeable is Initializable, IERC5267 {
bytes32 private constant TYPE_HASH =
keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)");
/// @custom:storage-location erc7201:openzeppelin.storage.EIP712
struct EIP712Storage {
/// @custom:oz-renamed-from _HASHED_NAME
bytes32 _hashedName;
/// @custom:oz-renamed-from _HASHED_VERSION
bytes32 _hashedVersion;
string _name;
string _version;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.EIP712")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant EIP712StorageLocation = 0xa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d100;
function _getEIP712Storage() private pure returns (EIP712Storage storage $) {
assembly {
$.slot := EIP712StorageLocation
}
}
/**
* @dev Initializes the domain separator and parameter caches.
*
* The meaning of `name` and `version` is specified in
* https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]:
*
* - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.
* - `version`: the current major version of the signing domain.
*
* NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart
* contract upgrade].
*/
function __EIP712_init(string memory name, string memory version) internal onlyInitializing {
__EIP712_init_unchained(name, version);
}
function __EIP712_init_unchained(string memory name, string memory version) internal onlyInitializing {
EIP712Storage storage $ = _getEIP712Storage();
$._name = name;
$._version = version;
// Reset prior values in storage if upgrading
$._hashedName = 0;
$._hashedVersion = 0;
}
/**
* @dev Returns the domain separator for the current chain.
*/
function _domainSeparatorV4() internal view returns (bytes32) {
return _buildDomainSeparator();
}
function _buildDomainSeparator() private view returns (bytes32) {
return keccak256(abi.encode(TYPE_HASH, _EIP712NameHash(), _EIP712VersionHash(), block.chainid, address(this)));
}
/**
* @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this
* function returns the hash of the fully encoded EIP712 message for this domain.
*
* This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:
*
* ```solidity
* bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(
* keccak256("Mail(address to,string contents)"),
* mailTo,
* keccak256(bytes(mailContents))
* )));
* address signer = ECDSA.recover(digest, signature);
* ```
*/
function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {
return MessageHashUtils.toTypedDataHash(_domainSeparatorV4(), structHash);
}
/**
* @dev See {IERC-5267}.
*/
function eip712Domain()
public
view
virtual
returns (
bytes1 fields,
string memory name,
string memory version,
uint256 chainId,
address verifyingContract,
bytes32 salt,
uint256[] memory extensions
)
{
EIP712Storage storage $ = _getEIP712Storage();
// If the hashed name and version in storage are non-zero, the contract hasn't been properly initialized
// and the EIP712 domain is not reliable, as it will be missing name and version.
require($._hashedName == 0 && $._hashedVersion == 0, "EIP712: Uninitialized");
return (
hex"0f", // 01111
_EIP712Name(),
_EIP712Version(),
block.chainid,
address(this),
bytes32(0),
new uint256[](0)
);
}
/**
* @dev The name parameter for the EIP712 domain.
*
* NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs
* are a concern.
*/
function _EIP712Name() internal view virtual returns (string memory) {
EIP712Storage storage $ = _getEIP712Storage();
return $._name;
}
/**
* @dev The version parameter for the EIP712 domain.
*
* NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs
* are a concern.
*/
function _EIP712Version() internal view virtual returns (string memory) {
EIP712Storage storage $ = _getEIP712Storage();
return $._version;
}
/**
* @dev The hash of the name parameter for the EIP712 domain.
*
* NOTE: In previous versions this function was virtual. In this version you should override `_EIP712Name` instead.
*/
function _EIP712NameHash() internal view returns (bytes32) {
EIP712Storage storage $ = _getEIP712Storage();
string memory name = _EIP712Name();
if (bytes(name).length > 0) {
return keccak256(bytes(name));
} else {
// If the name is empty, the contract may have been upgraded without initializing the new storage.
// We return the name hash in storage if non-zero, otherwise we assume the name is empty by design.
bytes32 hashedName = $._hashedName;
if (hashedName != 0) {
return hashedName;
} else {
return keccak256("");
}
}
}
/**
* @dev The hash of the version parameter for the EIP712 domain.
*
* NOTE: In previous versions this function was virtual. In this version you should override `_EIP712Version` instead.
*/
function _EIP712VersionHash() internal view returns (bytes32) {
EIP712Storage storage $ = _getEIP712Storage();
string memory version = _EIP712Version();
if (bytes(version).length > 0) {
return keccak256(bytes(version));
} else {
// If the version is empty, the contract may have been upgraded without initializing the new storage.
// We return the version hash in storage if non-zero, otherwise we assume the version is empty by design.
bytes32 hashedVersion = $._hashedVersion;
if (hashedVersion != 0) {
return hashedVersion;
} else {
return keccak256("");
}
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Nonces.sol)
pragma solidity ^0.8.20;
import {Initializable} from "../proxy/utils/Initializable.sol";
/**
* @dev Provides tracking nonces for addresses. Nonces will only increment.
*/
abstract contract NoncesUpgradeable is Initializable {
/**
* @dev The nonce used for an `account` is not the expected current nonce.
*/
error InvalidAccountNonce(address account, uint256 currentNonce);
/// @custom:storage-location erc7201:openzeppelin.storage.Nonces
struct NoncesStorage {
mapping(address account => uint256) _nonces;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Nonces")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant NoncesStorageLocation = 0x5ab42ced628888259c08ac98db1eb0cf702fc1501344311d8b100cd1bfe4bb00;
function _getNoncesStorage() private pure returns (NoncesStorage storage $) {
assembly {
$.slot := NoncesStorageLocation
}
}
function __Nonces_init() internal onlyInitializing {
}
function __Nonces_init_unchained() internal onlyInitializing {
}
/**
* @dev Returns the next unused nonce for an address.
*/
function nonces(address owner) public view virtual returns (uint256) {
NoncesStorage storage $ = _getNoncesStorage();
return $._nonces[owner];
}
/**
* @dev Consumes a nonce.
*
* Returns the current value and increments nonce.
*/
function _useNonce(address owner) internal virtual returns (uint256) {
NoncesStorage storage $ = _getNoncesStorage();
// For each account, the nonce has an initial value of 0, can only be incremented by one, and cannot be
// decremented or reset. This guarantees that the nonce never overflows.
unchecked {
// It is important to do x++ and not ++x here.
return $._nonces[owner]++;
}
}
/**
* @dev Same as {_useNonce} but checking that `nonce` is the next valid for `owner`.
*/
function _useCheckedNonce(address owner, uint256 nonce) internal virtual {
uint256 current = _useNonce(owner);
if (nonce != current) {
revert InvalidAccountNonce(owner, current);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/draft-IERC6093.sol)
pragma solidity ^0.8.20;
/**
* @dev Standard ERC20 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC20 tokens.
*/
interface IERC20Errors {
/**
* @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
* @param balance Current balance for the interacting account.
* @param needed Minimum amount required to perform a transfer.
*/
error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed);
/**
* @dev Indicates a failure with the token `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
*/
error ERC20InvalidSender(address sender);
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/
error ERC20InvalidReceiver(address receiver);
/**
* @dev Indicates a failure with the `spender`’s `allowance`. Used in transfers.
* @param spender Address that may be allowed to operate on tokens without being their owner.
* @param allowance Amount of tokens a `spender` is allowed to operate with.
* @param needed Minimum amount required to perform a transfer.
*/
error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed);
/**
* @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
* @param approver Address initiating an approval operation.
*/
error ERC20InvalidApprover(address approver);
/**
* @dev Indicates a failure with the `spender` to be approved. Used in approvals.
* @param spender Address that may be allowed to operate on tokens without being their owner.
*/
error ERC20InvalidSpender(address spender);
}
/**
* @dev Standard ERC721 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC721 tokens.
*/
interface IERC721Errors {
/**
* @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in EIP-20.
* Used in balance queries.
* @param owner Address of the current owner of a token.
*/
error ERC721InvalidOwner(address owner);
/**
* @dev Indicates a `tokenId` whose `owner` is the zero address.
* @param tokenId Identifier number of a token.
*/
error ERC721NonexistentToken(uint256 tokenId);
/**
* @dev Indicates an error related to the ownership over a particular token. Used in transfers.
* @param sender Address whose tokens are being transferred.
* @param tokenId Identifier number of a token.
* @param owner Address of the current owner of a token.
*/
error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner);
/**
* @dev Indicates a failure with the token `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
*/
error ERC721InvalidSender(address sender);
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/
error ERC721InvalidReceiver(address receiver);
/**
* @dev Indicates a failure with the `operator`’s approval. Used in transfers.
* @param operator Address that may be allowed to operate on tokens without being their owner.
* @param tokenId Identifier number of a token.
*/
error ERC721InsufficientApproval(address operator, uint256 tokenId);
/**
* @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
* @param approver Address initiating an approval operation.
*/
error ERC721InvalidApprover(address approver);
/**
* @dev Indicates a failure with the `operator` to be approved. Used in approvals.
* @param operator Address that may be allowed to operate on tokens without being their owner.
*/
error ERC721InvalidOperator(address operator);
}
/**
* @dev Standard ERC1155 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC1155 tokens.
*/
interface IERC1155Errors {
/**
* @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
* @param balance Current balance for the interacting account.
* @param needed Minimum amount required to perform a transfer.
* @param tokenId Identifier number of a token.
*/
error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId);
/**
* @dev Indicates a failure with the token `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
*/
error ERC1155InvalidSender(address sender);
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/
error ERC1155InvalidReceiver(address receiver);
/**
* @dev Indicates a failure with the `operator`’s approval. Used in transfers.
* @param operator Address that may be allowed to operate on tokens without being their owner.
* @param owner Address of the current owner of a token.
*/
error ERC1155MissingApprovalForAll(address operator, address owner);
/**
* @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
* @param approver Address initiating an approval operation.
*/
error ERC1155InvalidApprover(address approver);
/**
* @dev Indicates a failure with the `operator` to be approved. Used in approvals.
* @param operator Address that may be allowed to operate on tokens without being their owner.
*/
error ERC1155InvalidOperator(address operator);
/**
* @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation.
* Used in batch transfers.
* @param idsLength Length of the array of token identifiers
* @param valuesLength Length of the array of token amounts
*/
error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC5267.sol)
pragma solidity ^0.8.20;
interface IERC5267 {
/**
* @dev MAY be emitted to signal that the domain could have changed.
*/
event EIP712DomainChanged();
/**
* @dev returns the fields and values that describe the domain separator used by this contract for EIP-712
* signature.
*/
function eip712Domain()
external
view
returns (
bytes1 fields,
string memory name,
string memory version,
uint256 chainId,
address verifyingContract,
bytes32 salt,
uint256[] memory extensions
);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Metadata.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../IERC20.sol";
/**
* @dev Interface for the optional metadata functions from the ERC20 standard.
*/
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
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Permit.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
* https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
*
* Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
* presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
* need to send a transaction, and thus is not required to hold Ether at all.
*
* ==== Security Considerations
*
* There are two important considerations concerning the use of `permit`. The first is that a valid permit signature
* expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be
* considered as an intention to spend the allowance in any specific way. The second is that because permits have
* built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should
* take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be
* generally recommended is:
*
* ```solidity
* function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {
* try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}
* doThing(..., value);
* }
*
* function doThing(..., uint256 value) public {
* token.safeTransferFrom(msg.sender, address(this), value);
* ...
* }
* ```
*
* Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of
* `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also
* {SafeERC20-safeTransferFrom}).
*
* Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so
* contracts should have entry points that don't rely on permit.
*/
interface IERC20Permit {
/**
* @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
* given ``owner``'s signed approval.
*
* IMPORTANT: The same issues {IERC20-approve} has related to transaction
* ordering also apply here.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `deadline` must be a timestamp in the future.
* - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
* over the EIP712-formatted function arguments.
* - the signature must use ``owner``'s current nonce (see {nonces}).
*
* For more information on the signature format, see the
* https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
* section].
*
* CAUTION: See Security Considerations above.
*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
/**
* @dev Returns the current nonce for `owner`. This value must be
* included whenever a signature is generated for {permit}.
*
* Every successful call to {permit} increases ``owner``'s nonce by one. This
* prevents a signature from being used multiple times.
*/
function nonces(address owner) external view returns (uint256);
/**
* @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view returns (bytes32);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.20;
/**
* @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 value of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the value of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves a `value` amount of 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 value) 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 a `value` amount of tokens 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 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the
* allowance mechanism. `value` 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 value) external returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../IERC20.sol";
import {IERC20Permit} from "../extensions/IERC20Permit.sol";
import {Address} from "../../../utils/Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using Address for address;
/**
* @dev An operation with an ERC20 token failed.
*/
error SafeERC20FailedOperation(address token);
/**
* @dev Indicates a failed `decreaseAllowance` request.
*/
error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);
/**
* @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));
}
/**
* @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
* calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
*/
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));
}
/**
* @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 oldAllowance = token.allowance(address(this), spender);
forceApprove(token, spender, oldAllowance + value);
}
/**
* @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
* value, non-reverting calls are assumed to be successful.
*/
function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
unchecked {
uint256 currentAllowance = token.allowance(address(this), spender);
if (currentAllowance < requestedDecrease) {
revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
}
forceApprove(token, spender, currentAllowance - requestedDecrease);
}
}
/**
* @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
* to be set to zero before setting it to a non-zero value, such as USDT.
*/
function forceApprove(IERC20 token, address spender, uint256 value) internal {
bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));
if (!_callOptionalReturnBool(token, approvalCall)) {
_callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));
_callOptionalReturn(token, approvalCall);
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data);
if (returndata.length != 0 && !abi.decode(returndata, (bool))) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*
* This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
*/
function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false
// and not revert is the subcall reverts.
(bool success, bytes memory returndata) = address(token).call(data);
return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && address(token).code.length > 0;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)
pragma solidity ^0.8.20;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev The ETH balance of the account is not enough to perform the operation.
*/
error AddressInsufficientBalance(address account);
/**
* @dev There's no code at `target` (it is not a contract).
*/
error AddressEmptyCode(address target);
/**
* @dev A call to an address target failed. The target may have reverted.
*/
error FailedInnerCall();
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
if (address(this).balance < amount) {
revert AddressInsufficientBalance(address(this));
}
(bool success, ) = recipient.call{value: amount}("");
if (!success) {
revert FailedInnerCall();
}
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason or custom error, it is bubbled
* up by this function (like regular Solidity function calls). However, if
* the call reverted with no returned reason, this function reverts with a
* {FailedInnerCall} error.
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
if (address(this).balance < value) {
revert AddressInsufficientBalance(address(this));
}
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target
* was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an
* unsuccessful call.
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata
) internal view returns (bytes memory) {
if (!success) {
_revert(returndata);
} else {
// only check if target is a contract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
if (returndata.length == 0 && target.code.length == 0) {
revert AddressEmptyCode(target);
}
return returndata;
}
}
/**
* @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the
* revert reason or with a default {FailedInnerCall} error.
*/
function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {
if (!success) {
_revert(returndata);
} else {
return returndata;
}
}
/**
* @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.
*/
function _revert(bytes memory returndata) private pure {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert FailedInnerCall();
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/ECDSA.sol)
pragma solidity ^0.8.20;
/**
* @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
*
* These functions can be used to verify that a message was signed by the holder
* of the private keys of a given address.
*/
library ECDSA {
enum RecoverError {
NoError,
InvalidSignature,
InvalidSignatureLength,
InvalidSignatureS
}
/**
* @dev The signature derives the `address(0)`.
*/
error ECDSAInvalidSignature();
/**
* @dev The signature has an invalid length.
*/
error ECDSAInvalidSignatureLength(uint256 length);
/**
* @dev The signature has an S value that is in the upper half order.
*/
error ECDSAInvalidSignatureS(bytes32 s);
/**
* @dev Returns the address that signed a hashed message (`hash`) with `signature` or an error. This will not
* return address(0) without also returning an error description. Errors are documented using an enum (error type)
* and a bytes32 providing additional information about the error.
*
* If no error is returned, then the address can be used for verification purposes.
*
* The `ecrecover` EVM precompile allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it.
*
* Documentation for signature generation:
* - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]
* - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]
*/
function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError, bytes32) {
if (signature.length == 65) {
bytes32 r;
bytes32 s;
uint8 v;
// ecrecover takes the signature parameters, and the only way to get them
// currently is to use assembly.
/// @solidity memory-safe-assembly
assembly {
r := mload(add(signature, 0x20))
s := mload(add(signature, 0x40))
v := byte(0, mload(add(signature, 0x60)))
}
return tryRecover(hash, v, r, s);
} else {
return (address(0), RecoverError.InvalidSignatureLength, bytes32(signature.length));
}
}
/**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature`. This address can then be used for verification purposes.
*
* The `ecrecover` EVM precompile allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it.
*/
function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
(address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, signature);
_throwError(error, errorArg);
return recovered;
}
/**
* @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.
*
* See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]
*/
function tryRecover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address, RecoverError, bytes32) {
unchecked {
bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);
// We do not check for an overflow here since the shift operation results in 0 or 1.
uint8 v = uint8((uint256(vs) >> 255) + 27);
return tryRecover(hash, v, r, s);
}
}
/**
* @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.
*/
function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address) {
(address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, r, vs);
_throwError(error, errorArg);
return recovered;
}
/**
* @dev Overload of {ECDSA-tryRecover} that receives the `v`,
* `r` and `s` signature fields separately.
*/
function tryRecover(
bytes32 hash,
uint8 v,
bytes32 r,
bytes32 s
) internal pure returns (address, RecoverError, bytes32) {
// EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
// unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
// the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most
// signatures from current libraries generate a unique signature with an s-value in the lower half order.
//
// If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
// with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
// vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
// these malleable signatures as well.
if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
return (address(0), RecoverError.InvalidSignatureS, s);
}
// If the signature is valid (and not malleable), return the signer address
address signer = ecrecover(hash, v, r, s);
if (signer == address(0)) {
return (address(0), RecoverError.InvalidSignature, bytes32(0));
}
return (signer, RecoverError.NoError, bytes32(0));
}
/**
* @dev Overload of {ECDSA-recover} that receives the `v`,
* `r` and `s` signature fields separately.
*/
function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) {
(address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, v, r, s);
_throwError(error, errorArg);
return recovered;
}
/**
* @dev Optionally reverts with the corresponding custom error according to the `error` argument provided.
*/
function _throwError(RecoverError error, bytes32 errorArg) private pure {
if (error == RecoverError.NoError) {
return; // no error: do nothing
} else if (error == RecoverError.InvalidSignature) {
revert ECDSAInvalidSignature();
} else if (error == RecoverError.InvalidSignatureLength) {
revert ECDSAInvalidSignatureLength(uint256(errorArg));
} else if (error == RecoverError.InvalidSignatureS) {
revert ECDSAInvalidSignatureS(errorArg);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/MessageHashUtils.sol)
pragma solidity ^0.8.20;
import {Strings} from "../Strings.sol";
/**
* @dev Signature message hash utilities for producing digests to be consumed by {ECDSA} recovery or signing.
*
* The library provides methods for generating a hash of a message that conforms to the
* https://eips.ethereum.org/EIPS/eip-191[EIP 191] and https://eips.ethereum.org/EIPS/eip-712[EIP 712]
* specifications.
*/
library MessageHashUtils {
/**
* @dev Returns the keccak256 digest of an EIP-191 signed data with version
* `0x45` (`personal_sign` messages).
*
* The digest is calculated by prefixing a bytes32 `messageHash` with
* `"\x19Ethereum Signed Message:\n32"` and hashing the result. It corresponds with the
* hash signed when using the https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] JSON-RPC method.
*
* NOTE: The `messageHash` parameter is intended to be the result of hashing a raw message with
* keccak256, although any bytes32 value can be safely used because the final digest will
* be re-hashed.
*
* See {ECDSA-recover}.
*/
function toEthSignedMessageHash(bytes32 messageHash) internal pure returns (bytes32 digest) {
/// @solidity memory-safe-assembly
assembly {
mstore(0x00, "\x19Ethereum Signed Message:\n32") // 32 is the bytes-length of messageHash
mstore(0x1c, messageHash) // 0x1c (28) is the length of the prefix
digest := keccak256(0x00, 0x3c) // 0x3c is the length of the prefix (0x1c) + messageHash (0x20)
}
}
/**
* @dev Returns the keccak256 digest of an EIP-191 signed data with version
* `0x45` (`personal_sign` messages).
*
* The digest is calculated by prefixing an arbitrary `message` with
* `"\x19Ethereum Signed Message:\n" + len(message)` and hashing the result. It corresponds with the
* hash signed when using the https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] JSON-RPC method.
*
* See {ECDSA-recover}.
*/
function toEthSignedMessageHash(bytes memory message) internal pure returns (bytes32) {
return
keccak256(bytes.concat("\x19Ethereum Signed Message:\n", bytes(Strings.toString(message.length)), message));
}
/**
* @dev Returns the keccak256 digest of an EIP-191 signed data with version
* `0x00` (data with intended validator).
*
* The digest is calculated by prefixing an arbitrary `data` with `"\x19\x00"` and the intended
* `validator` address. Then hashing the result.
*
* See {ECDSA-recover}.
*/
function toDataWithIntendedValidatorHash(address validator, bytes memory data) internal pure returns (bytes32) {
return keccak256(abi.encodePacked(hex"19_00", validator, data));
}
/**
* @dev Returns the keccak256 digest of an EIP-712 typed data (EIP-191 version `0x01`).
*
* The digest is calculated from a `domainSeparator` and a `structHash`, by prefixing them with
* `\x19\x01` and hashing the result. It corresponds to the hash signed by the
* https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] JSON-RPC method as part of EIP-712.
*
* See {ECDSA-recover}.
*/
function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32 digest) {
/// @solidity memory-safe-assembly
assembly {
let ptr := mload(0x40)
mstore(ptr, hex"19_01")
mstore(add(ptr, 0x02), domainSeparator)
mstore(add(ptr, 0x22), structHash)
digest := keccak256(ptr, 0x42)
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/Math.sol)
pragma solidity ^0.8.20;
/**
* @dev Standard math utilities missing in the Solidity language.
*/
library Math {
/**
* @dev Muldiv operation overflow.
*/
error MathOverflowedMulDiv();
enum Rounding {
Floor, // Toward negative infinity
Ceil, // Toward positive infinity
Trunc, // Toward zero
Expand // Away from zero
}
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the subtraction of two unsigned integers, with an overflow flag.
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
/**
* @dev Returns the largest of two numbers.
*/
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a > b ? a : b;
}
/**
* @dev Returns the smallest of two numbers.
*/
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two numbers. The result is rounded towards
* zero.
*/
function average(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b) / 2 can overflow.
return (a & b) + (a ^ b) / 2;
}
/**
* @dev Returns the ceiling of the division of two numbers.
*
* This differs from standard division with `/` in that it rounds towards infinity instead
* of rounding towards zero.
*/
function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
if (b == 0) {
// Guarantee the same behavior as in a regular Solidity division.
return a / b;
}
// (a + b - 1) / b can overflow on addition, so we distribute.
return a == 0 ? 0 : (a - 1) / b + 1;
}
/**
* @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or
* denominator == 0.
* @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by
* Uniswap Labs also under MIT license.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {
unchecked {
// 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
// use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
// variables such that product = prod1 * 2^256 + prod0.
uint256 prod0 = x * y; // Least significant 256 bits of the product
uint256 prod1; // Most significant 256 bits of the product
assembly {
let mm := mulmod(x, y, not(0))
prod1 := sub(sub(mm, prod0), lt(mm, prod0))
}
// Handle non-overflow cases, 256 by 256 division.
if (prod1 == 0) {
// Solidity will revert if denominator == 0, unlike the div opcode on its own.
// The surrounding unchecked block does not change this fact.
// See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
return prod0 / denominator;
}
// Make sure the result is less than 2^256. Also prevents denominator == 0.
if (denominator <= prod1) {
revert MathOverflowedMulDiv();
}
///////////////////////////////////////////////
// 512 by 256 division.
///////////////////////////////////////////////
// Make division exact by subtracting the remainder from [prod1 prod0].
uint256 remainder;
assembly {
// Compute remainder using mulmod.
remainder := mulmod(x, y, denominator)
// Subtract 256 bit number from 512 bit number.
prod1 := sub(prod1, gt(remainder, prod0))
prod0 := sub(prod0, remainder)
}
// Factor powers of two out of denominator and compute largest power of two divisor of denominator.
// Always >= 1. See https://cs.stackexchange.com/q/138556/92363.
uint256 twos = denominator & (0 - denominator);
assembly {
// Divide denominator by twos.
denominator := div(denominator, twos)
// Divide [prod1 prod0] by twos.
prod0 := div(prod0, twos)
// Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
twos := add(div(sub(0, twos), twos), 1)
}
// Shift in bits from prod1 into prod0.
prod0 |= prod1 * twos;
// Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
// that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
// four bits. That is, denominator * inv = 1 mod 2^4.
uint256 inverse = (3 * denominator) ^ 2;
// Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also
// works in modular arithmetic, doubling the correct bits in each step.
inverse *= 2 - denominator * inverse; // inverse mod 2^8
inverse *= 2 - denominator * inverse; // inverse mod 2^16
inverse *= 2 - denominator * inverse; // inverse mod 2^32
inverse *= 2 - denominator * inverse; // inverse mod 2^64
inverse *= 2 - denominator * inverse; // inverse mod 2^128
inverse *= 2 - denominator * inverse; // inverse mod 2^256
// Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
// This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
// less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
// is no longer required.
result = prod0 * inverse;
return result;
}
}
/**
* @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {
uint256 result = mulDiv(x, y, denominator);
if (unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0) {
result += 1;
}
return result;
}
/**
* @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded
* towards zero.
*
* Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
*/
function sqrt(uint256 a) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
// For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
//
// We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
// `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
//
// This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
// → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
// → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
//
// Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
uint256 result = 1 << (log2(a) >> 1);
// At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
// since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
// every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
// into the expected uint128 result.
unchecked {
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
return min(result, a / result);
}
}
/**
* @notice Calculates sqrt(a), following the selected rounding direction.
*/
function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = sqrt(a);
return result + (unsignedRoundsUp(rounding) && result * result < a ? 1 : 0);
}
}
/**
* @dev Return the log in base 2 of a positive value rounded towards zero.
* Returns 0 if given 0.
*/
function log2(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 128;
}
if (value >> 64 > 0) {
value >>= 64;
result += 64;
}
if (value >> 32 > 0) {
value >>= 32;
result += 32;
}
if (value >> 16 > 0) {
value >>= 16;
result += 16;
}
if (value >> 8 > 0) {
value >>= 8;
result += 8;
}
if (value >> 4 > 0) {
value >>= 4;
result += 4;
}
if (value >> 2 > 0) {
value >>= 2;
result += 2;
}
if (value >> 1 > 0) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 2, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log2(value);
return result + (unsignedRoundsUp(rounding) && 1 << result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 10 of a positive value rounded towards zero.
* Returns 0 if given 0.
*/
function log10(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >= 10 ** 64) {
value /= 10 ** 64;
result += 64;
}
if (value >= 10 ** 32) {
value /= 10 ** 32;
result += 32;
}
if (value >= 10 ** 16) {
value /= 10 ** 16;
result += 16;
}
if (value >= 10 ** 8) {
value /= 10 ** 8;
result += 8;
}
if (value >= 10 ** 4) {
value /= 10 ** 4;
result += 4;
}
if (value >= 10 ** 2) {
value /= 10 ** 2;
result += 2;
}
if (value >= 10 ** 1) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 10, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log10(value);
return result + (unsignedRoundsUp(rounding) && 10 ** result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 256 of a positive value rounded towards zero.
* Returns 0 if given 0.
*
* Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
*/
function log256(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 16;
}
if (value >> 64 > 0) {
value >>= 64;
result += 8;
}
if (value >> 32 > 0) {
value >>= 32;
result += 4;
}
if (value >> 16 > 0) {
value >>= 16;
result += 2;
}
if (value >> 8 > 0) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 256, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log256(value);
return result + (unsignedRoundsUp(rounding) && 1 << (result << 3) < value ? 1 : 0);
}
}
/**
* @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers.
*/
function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {
return uint8(rounding) % 2 == 1;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/SignedMath.sol)
pragma solidity ^0.8.20;
/**
* @dev Standard signed math utilities missing in the Solidity language.
*/
library SignedMath {
/**
* @dev Returns the largest of two signed numbers.
*/
function max(int256 a, int256 b) internal pure returns (int256) {
return a > b ? a : b;
}
/**
* @dev Returns the smallest of two signed numbers.
*/
function min(int256 a, int256 b) internal pure returns (int256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two signed numbers without overflow.
* The result is rounded towards zero.
*/
function average(int256 a, int256 b) internal pure returns (int256) {
// Formula from the book "Hacker's Delight"
int256 x = (a & b) + ((a ^ b) >> 1);
return x + (int256(uint256(x) >> 255) & (a ^ b));
}
/**
* @dev Returns the absolute unsigned value of a signed value.
*/
function abs(int256 n) internal pure returns (uint256) {
unchecked {
// must be unchecked in order to support `n = type(int256).min`
return uint256(n >= 0 ? n : -n);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Strings.sol)
pragma solidity ^0.8.20;
import {Math} from "./math/Math.sol";
import {SignedMath} from "./math/SignedMath.sol";
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant HEX_DIGITS = "0123456789abcdef";
uint8 private constant ADDRESS_LENGTH = 20;
/**
* @dev The `value` string doesn't fit in the specified `length`.
*/
error StringsInsufficientHexLength(uint256 value, uint256 length);
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
unchecked {
uint256 length = Math.log10(value) + 1;
string memory buffer = new string(length);
uint256 ptr;
/// @solidity memory-safe-assembly
assembly {
ptr := add(buffer, add(32, length))
}
while (true) {
ptr--;
/// @solidity memory-safe-assembly
assembly {
mstore8(ptr, byte(mod(value, 10), HEX_DIGITS))
}
value /= 10;
if (value == 0) break;
}
return buffer;
}
}
/**
* @dev Converts a `int256` to its ASCII `string` decimal representation.
*/
function toStringSigned(int256 value) internal pure returns (string memory) {
return string.concat(value < 0 ? "-" : "", toString(SignedMath.abs(value)));
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
unchecked {
return toHexString(value, Math.log256(value) + 1);
}
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
uint256 localValue = value;
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = HEX_DIGITS[localValue & 0xf];
localValue >>= 4;
}
if (localValue != 0) {
revert StringsInsufficientHexLength(value, length);
}
return string(buffer);
}
/**
* @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal
* representation.
*/
function toHexString(address addr) internal pure returns (string memory) {
return toHexString(uint256(uint160(addr)), ADDRESS_LENGTH);
}
/**
* @dev Returns true if the two strings are equal.
*/
function equal(string memory a, string memory b) internal pure returns (bool) {
return bytes(a).length == bytes(b).length && keccak256(bytes(a)) == keccak256(bytes(b));
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (proxy/beacon/IBeacon.sol)
pragma solidity ^0.8.20;
/**
* @dev This is the interface that {BeaconProxy} expects of its beacon.
*/
interface IBeacon {
/**
* @dev Must return an address that can be used as a delegate call target.
*
* {UpgradeableBeacon} will check that this address is a contract.
*/
function implementation() external view returns (address);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (proxy/ERC1967/ERC1967Utils.sol)
pragma solidity ^0.8.20;
import {IBeacon} from "../beacon/IBeacon.sol";
import {Address} from "../../utils/Address.sol";
import {StorageSlot} from "../../utils/StorageSlot.sol";
/**
* @dev This abstract contract provides getters and event emitting update functions for
* https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.
*/
library ERC1967Utils {
// We re-declare ERC-1967 events here because they can't be used directly from IERC1967.
// This will be fixed in Solidity 0.8.21. At that point we should remove these events.
/**
* @dev Emitted when the implementation is upgraded.
*/
event Upgraded(address indexed implementation);
/**
* @dev Emitted when the admin account has changed.
*/
event AdminChanged(address previousAdmin, address newAdmin);
/**
* @dev Emitted when the beacon is changed.
*/
event BeaconUpgraded(address indexed beacon);
/**
* @dev Storage slot with the address of the current implementation.
* This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1.
*/
// solhint-disable-next-line private-vars-leading-underscore
bytes32 internal constant IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
/**
* @dev The `implementation` of the proxy is invalid.
*/
error ERC1967InvalidImplementation(address implementation);
/**
* @dev The `admin` of the proxy is invalid.
*/
error ERC1967InvalidAdmin(address admin);
/**
* @dev The `beacon` of the proxy is invalid.
*/
error ERC1967InvalidBeacon(address beacon);
/**
* @dev An upgrade function sees `msg.value > 0` that may be lost.
*/
error ERC1967NonPayable();
/**
* @dev Returns the current implementation address.
*/
function getImplementation() internal view returns (address) {
return StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value;
}
/**
* @dev Stores a new address in the EIP1967 implementation slot.
*/
function _setImplementation(address newImplementation) private {
if (newImplementation.code.length == 0) {
revert ERC1967InvalidImplementation(newImplementation);
}
StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value = newImplementation;
}
/**
* @dev Performs implementation upgrade with additional setup call if data is nonempty.
* This function is payable only if the setup call is performed, otherwise `msg.value` is rejected
* to avoid stuck value in the contract.
*
* Emits an {IERC1967-Upgraded} event.
*/
function upgradeToAndCall(address newImplementation, bytes memory data) internal {
_setImplementation(newImplementation);
emit Upgraded(newImplementation);
if (data.length > 0) {
Address.functionDelegateCall(newImplementation, data);
} else {
_checkNonPayable();
}
}
/**
* @dev Storage slot with the admin of the contract.
* This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1.
*/
// solhint-disable-next-line private-vars-leading-underscore
bytes32 internal constant ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
/**
* @dev Returns the current admin.
*
* TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using
* the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.
* `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`
*/
function getAdmin() internal view returns (address) {
return StorageSlot.getAddressSlot(ADMIN_SLOT).value;
}
/**
* @dev Stores a new address in the EIP1967 admin slot.
*/
function _setAdmin(address newAdmin) private {
if (newAdmin == address(0)) {
revert ERC1967InvalidAdmin(address(0));
}
StorageSlot.getAddressSlot(ADMIN_SLOT).value = newAdmin;
}
/**
* @dev Changes the admin of the proxy.
*
* Emits an {IERC1967-AdminChanged} event.
*/
function changeAdmin(address newAdmin) internal {
emit AdminChanged(getAdmin(), newAdmin);
_setAdmin(newAdmin);
}
/**
* @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.
* This is the keccak-256 hash of "eip1967.proxy.beacon" subtracted by 1.
*/
// solhint-disable-next-line private-vars-leading-underscore
bytes32 internal constant BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;
/**
* @dev Returns the current beacon.
*/
function getBeacon() internal view returns (address) {
return StorageSlot.getAddressSlot(BEACON_SLOT).value;
}
/**
* @dev Stores a new beacon in the EIP1967 beacon slot.
*/
function _setBeacon(address newBeacon) private {
if (newBeacon.code.length == 0) {
revert ERC1967InvalidBeacon(newBeacon);
}
StorageSlot.getAddressSlot(BEACON_SLOT).value = newBeacon;
address beaconImplementation = IBeacon(newBeacon).implementation();
if (beaconImplementation.code.length == 0) {
revert ERC1967InvalidImplementation(beaconImplementation);
}
}
/**
* @dev Change the beacon and trigger a setup call if data is nonempty.
* This function is payable only if the setup call is performed, otherwise `msg.value` is rejected
* to avoid stuck value in the contract.
*
* Emits an {IERC1967-BeaconUpgraded} event.
*
* CAUTION: Invoking this function has no effect on an instance of {BeaconProxy} since v5, since
* it uses an immutable beacon without looking at the value of the ERC-1967 beacon slot for
* efficiency.
*/
function upgradeBeaconToAndCall(address newBeacon, bytes memory data) internal {
_setBeacon(newBeacon);
emit BeaconUpgraded(newBeacon);
if (data.length > 0) {
Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);
} else {
_checkNonPayable();
}
}
/**
* @dev Reverts if `msg.value` is not zero. It can be used to avoid `msg.value` stuck in the contract
* if an upgrade doesn't perform an initialization call.
*/
function _checkNonPayable() private {
if (msg.value > 0) {
revert ERC1967NonPayable();
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)
pragma solidity ^0.8.20;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev The ETH balance of the account is not enough to perform the operation.
*/
error AddressInsufficientBalance(address account);
/**
* @dev There's no code at `target` (it is not a contract).
*/
error AddressEmptyCode(address target);
/**
* @dev A call to an address target failed. The target may have reverted.
*/
error FailedInnerCall();
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
if (address(this).balance < amount) {
revert AddressInsufficientBalance(address(this));
}
(bool success, ) = recipient.call{value: amount}("");
if (!success) {
revert FailedInnerCall();
}
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason or custom error, it is bubbled
* up by this function (like regular Solidity function calls). However, if
* the call reverted with no returned reason, this function reverts with a
* {FailedInnerCall} error.
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
if (address(this).balance < value) {
revert AddressInsufficientBalance(address(this));
}
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target
* was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an
* unsuccessful call.
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata
) internal view returns (bytes memory) {
if (!success) {
_revert(returndata);
} else {
// only check if target is a contract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
if (returndata.length == 0 && target.code.length == 0) {
revert AddressEmptyCode(target);
}
return returndata;
}
}
/**
* @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the
* revert reason or with a default {FailedInnerCall} error.
*/
function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {
if (!success) {
_revert(returndata);
} else {
return returndata;
}
}
/**
* @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.
*/
function _revert(bytes memory returndata) private pure {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert FailedInnerCall();
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/StorageSlot.sol)
// This file was procedurally generated from scripts/generate/templates/StorageSlot.js.
pragma solidity ^0.8.20;
/**
* @dev Library for reading and writing primitive types to specific storage slots.
*
* Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
* This library helps with reading and writing to such slots without the need for inline assembly.
*
* The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
*
* Example usage to set ERC1967 implementation slot:
* ```solidity
* contract ERC1967 {
* bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
*
* function _getImplementation() internal view returns (address) {
* return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
* }
*
* function _setImplementation(address newImplementation) internal {
* require(newImplementation.code.length > 0);
* StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
* }
* }
* ```
*/
library StorageSlot {
struct AddressSlot {
address value;
}
struct BooleanSlot {
bool value;
}
struct Bytes32Slot {
bytes32 value;
}
struct Uint256Slot {
uint256 value;
}
struct StringSlot {
string value;
}
struct BytesSlot {
bytes value;
}
/**
* @dev Returns an `AddressSlot` with member `value` located at `slot`.
*/
function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `BooleanSlot` with member `value` located at `slot`.
*/
function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `Bytes32Slot` with member `value` located at `slot`.
*/
function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `Uint256Slot` with member `value` located at `slot`.
*/
function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `StringSlot` with member `value` located at `slot`.
*/
function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `StringSlot` representation of the string storage pointer `store`.
*/
function getStringSlot(string storage store) internal pure returns (StringSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := store.slot
}
}
/**
* @dev Returns an `BytesSlot` with member `value` located at `slot`.
*/
function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`.
*/
function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := store.slot
}
}
}// SPDX-License-Identifier: AGPL-3.0
pragma solidity ^0.8.20;
interface IBasePolygonZkEVMGlobalExitRoot {
/**
* @dev Thrown when the caller is not the allowed contracts
*/
error OnlyAllowedContracts();
/**
* @dev Thrown when the caller is not the coinbase neither the globalExitRootUpdater
*/
error OnlyGlobalExitRootUpdater();
/**
* @dev Thrown when trying to call a function that only the pending GlobalExitRootUpdater can call.
*/
error OnlyPendingGlobalExitRootUpdater();
/**
* @dev Thrown when the caller is not the globalExitRootRemover
*/
error OnlyGlobalExitRootRemover();
/**
* @dev Thrown when trying to call a function that only the pending GlobalExitRootRemover can call.
*/
error OnlyPendingGlobalExitRootRemover();
/**
* @dev Thrown when trying to insert a global exit root that is already set
*/
error GlobalExitRootAlreadySet();
/**
* @dev Thrown when trying to remove a ger that doesn't exist
*/
error GlobalExitRootNotFound();
/**
* @dev Thrown when trying to call a function with an input zero address
*/
error InvalidZeroAddress();
function updateExitRoot(bytes32 newRollupExitRoot) external;
function globalExitRootMap(
bytes32 globalExitRootNum
) external returns (uint256);
}// SPDX-License-Identifier: AGPL-3.0
pragma solidity ^0.8.20;
/**
* @dev Define interface for PolygonZkEVM Bridge message receiver
*/
interface IBridgeMessageReceiver {
function onMessageReceived(
address originAddress,
uint32 originNetwork,
bytes memory data
) external payable;
}// SPDX-License-Identifier: AGPL-3.0
pragma solidity ^0.8.20;
/**
* @dev Contract helper responsible to manage the emergency state
*/
contract EmergencyManager {
/**
* @dev Thrown when emergency state is active, and the function requires otherwise
*/
error OnlyNotEmergencyState();
/**
* @dev Thrown when emergency state is not active, and the function requires otherwise
*/
error OnlyEmergencyState();
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
*/
/// @custom:oz-renamed-from _gap
uint256[10] private __gap;
// Indicates whether the emergency state is active or not
bool public isEmergencyState;
/**
* @dev Emitted when emergency state is activated
*/
event EmergencyStateActivated();
/**
* @dev Emitted when emergency state is deactivated
*/
event EmergencyStateDeactivated();
/**
* @notice Only allows a function to be callable if emergency state is unactive
*/
modifier ifNotEmergencyState() {
if (isEmergencyState) {
revert OnlyNotEmergencyState();
}
_;
}
/**
* @notice Only allows a function to be callable if emergency state is active
*/
modifier ifEmergencyState() {
if (!isEmergencyState) {
revert OnlyEmergencyState();
}
_;
}
/**
* @notice Activate emergency state
*/
function _activateEmergencyState() internal virtual ifNotEmergencyState {
isEmergencyState = true;
emit EmergencyStateActivated();
}
/**
* @notice Deactivate emergency state
*/
function _deactivateEmergencyState() internal virtual ifEmergencyState {
isEmergencyState = false;
emit EmergencyStateDeactivated();
}
}// SPDX-License-Identifier: AGPL-3.0
pragma solidity ^0.8.20;
import "../v2/lib/Hashes.sol";
/**
* @dev A library that provides the necessary calculations to calculate the global exit root
*/
library GlobalExitRootLib {
function calculateGlobalExitRoot(
bytes32 mainnetExitRoot,
bytes32 rollupExitRoot
) internal pure returns (bytes32) {
return Hashes.efficientKeccak256(mainnetExitRoot, rollupExitRoot);
}
}// SPDX-License-Identifier: AGPL-3.0
pragma solidity ^0.8.20;
import "../../interfaces/IBasePolygonZkEVMGlobalExitRoot.sol";
import "./IPolygonZkEVMBridgeV2.sol";
interface IBridgeL2SovereignChains is IPolygonZkEVMBridgeV2 {
/**
* @dev Thrown when the origin network is invalid
*/
error OriginNetworkInvalid();
/**
* @dev Thrown when sender is not the bridge manager
* @notice Bridge manager can set custom mapping for any token
*/
error OnlyBridgeManager();
/**
* @dev Thrown when trying to remove a token mapping that has not been updated by a new one
*/
error TokenNotMapped();
/**
* @dev Thrown when trying to migrate a legacy token that is already the current token
*/
error TokenAlreadyUpdated();
/**
* @dev Thrown when initializing sovereign bridge with invalid sovereign WETH token params
*/
error InvalidSovereignWETHAddressParams();
/**
* @dev Thrown when initializing calling a function with invalid arrays length
*/
error InputArraysLengthMismatch();
/**
* @dev Thrown when trying to map a token that is already mapped
*/
error TokenAlreadyMapped();
/**
* @dev Thrown when trying to remove a legacy mapped token that has nor previously been remapped
*/
error TokenNotRemapped();
/**
* @dev Thrown when trying to set a custom wrapper for weth on a gas token network
*/
error WETHRemappingNotSupportedOnGasTokenNetworks();
/**
* @dev Thrown when trying to unset a not setted claim
*/
error ClaimNotSet();
/**
* @dev Thrown when trying to activate emergency state in a not allowed bridge context (e.g. sovereign chains)
*/
error EmergencyStateNotAllowed();
/**
* @dev Thrown when trying to initialize a sovereign bridge with a zero network ID, reserved for mainnet
*/
error InvalidZeroNetworkID();
/**
@dev Thrown when trying to substract more rather than available balance
*/
error LocalBalanceTreeUnderflow(
uint32 originNetwork,
address originTokenAddress,
uint256 amount,
uint256 localBalanceTreeAmount
);
/**
@dev Thrown when trying to add an amount over the maximum allowed balance
*/
error LocalBalanceTreeOverflow(
uint32 originNetwork,
address originTokenAddress,
uint256 amount,
uint256 localBalanceTreeAmount
);
/**
* @dev Thrown when the caller is not the globalExitRootRemover
*/
error OnlyGlobalExitRootRemover();
/**
* @dev Thrown when the caller is not the emergencyBridgePauser address
*/
error OnlyEmergencyBridgePauser();
/**
* @dev Thrown when trying to call a function that only the pending bridge pauser can call.
*/
error OnlyPendingEmergencyBridgePauser();
/**
* @dev Thrown when the caller is not the emergencyBridgeUnpauser address
*/
error OnlyEmergencyBridgeUnpauser();
/**
* @dev Thrown when trying to call a function that only pending bridge unpauser can call.
*/
error OnlyPendingEmergencyBridgeUnpauser();
function initialize(
uint32 _networkID,
address _gasTokenAddress,
uint32 _gasTokenNetwork,
IBasePolygonZkEVMGlobalExitRoot _globalExitRootManager,
address _polygonRollupManager,
bytes memory _gasTokenMetadata,
address _bridgeManager,
address sovereignWETHAddress,
bool _sovereignWETHAddressIsNotMintable,
address _emergencyBridgePauser,
address _emergencyBridgeUnpauser,
address _proxiedTokensManager
) external;
}// SPDX-License-Identifier: AGPL-3.0
pragma solidity 0.8.28;
interface IBytecodeStorer {
function INIT_BYTECODE_TRANSPARENT_PROXY()
external
pure
returns (bytes memory);
}// SPDX-License-Identifier: AGPL-3.0
pragma solidity ^0.8.20;
import "../../interfaces/IBasePolygonZkEVMGlobalExitRoot.sol";
interface IGlobalExitRootManagerL2SovereignChain is
IBasePolygonZkEVMGlobalExitRoot
{
/**
* @notice Get the globalExitRootUpdater address
* This variable is exposed to be used by a BridgeL2Sovereign modifier
*/
function globalExitRootRemover() external view returns (address);
}// SPDX-License-Identifier: AGPL-3.0
pragma solidity ^0.8.20;
import "../../interfaces/IBasePolygonZkEVMGlobalExitRoot.sol";
interface IPolygonZkEVMBridgeV2 {
/**
* @dev Thrown when the destination network is invalid
*/
error DestinationNetworkInvalid();
/**
* @dev Thrown when the amount does not match msg.value
*/
error AmountDoesNotMatchMsgValue();
/**
* @dev Thrown when user is bridging tokens and is also sending a value
*/
error MsgValueNotZero();
/**
* @dev Thrown when the Ether transfer on claimAsset fails
*/
error EtherTransferFailed();
/**
* @dev Thrown when the message transaction on claimMessage fails
*/
error MessageFailed();
/**
* @dev Thrown when the global exit root does not exist
*/
error GlobalExitRootInvalid();
/**
* @dev Thrown when the smt proof does not match
*/
error InvalidSmtProof();
/**
* @dev Thrown when an index is already claimed
*/
error AlreadyClaimed();
/**
* @dev Thrown when the owner of permit does not match the sender
*/
error NotValidOwner();
/**
* @dev Thrown when the spender of the permit does not match this contract address
*/
error NotValidSpender();
/**
* @dev Thrown when the amount of the permit does not match
*/
error NotValidAmount();
/**
* @dev Thrown when the permit data contains an invalid signature
*/
error NotValidSignature();
/**
* @dev Thrown when sender is not the rollup manager
*/
error OnlyRollupManager();
/**
* @dev Thrown when the permit data contains an invalid signature
*/
error NativeTokenIsEther();
/**
* @dev Thrown when the permit data contains an invalid signature
*/
error NoValueInMessagesOnGasTokenNetworks();
/**
* @dev Thrown when the permit data contains an invalid signature
*/
error GasTokenNetworkMustBeZeroOnEther();
/**
* @dev Thrown when the wrapped token proxy deployment fails
*/
error FailedProxyDeployment();
/**
* @dev Thrown when try to set a zero address to a non valid zero address field
*/
error InvalidZeroAddress();
/**
* @dev Thrown when sender is not the proxied tokens manager
*/
error OnlyProxiedTokensManager();
/**
* @dev Thrown when trying to call a function that only the pending ProxiedTokensManager can call.
*/
error OnlyPendingProxiedTokensManager();
/**
* @dev Thrown when trying to set bridgeAddress to as proxied tokens manager role.
*/
error BridgeAddressNotAllowed();
/**
* @dev Thrown when trying to initialize the incorrect initialize function
*/
error InvalidInitializeFunction();
/**
* @dev Thrown when failing to retrieve the owner from proxyAdmin
*/
error InvalidProxyAdmin(address proxyAdmin);
/**
* @dev Thrown when the owner of a proxyAdmin is zero address
*/
error InvalidZeroProxyAdminOwner(address proxyAdmin);
/**
* @dev Thrown when the global index has any unused bits set to 1
*/
error InvalidGlobalIndex();
function wrappedTokenToTokenInfo(
address destinationAddress
) external view returns (uint32, address);
function updateGlobalExitRoot() external;
function activateEmergencyState() external;
function deactivateEmergencyState() external;
function bridgeAsset(
uint32 destinationNetwork,
address destinationAddress,
uint256 amount,
address token,
bool forceUpdateGlobalExitRoot,
bytes calldata permitData
) external payable;
function bridgeMessage(
uint32 destinationNetwork,
address destinationAddress,
bool forceUpdateGlobalExitRoot,
bytes calldata metadata
) external payable;
function bridgeMessageWETH(
uint32 destinationNetwork,
address destinationAddress,
uint256 amountWETH,
bool forceUpdateGlobalExitRoot,
bytes calldata metadata
) external;
function claimAsset(
bytes32[32] calldata smtProofLocalExitRoot,
bytes32[32] calldata smtProofRollupExitRoot,
uint256 globalIndex,
bytes32 mainnetExitRoot,
bytes32 rollupExitRoot,
uint32 originNetwork,
address originTokenAddress,
uint32 destinationNetwork,
address destinationAddress,
uint256 amount,
bytes calldata metadata
) external;
function claimMessage(
bytes32[32] calldata smtProofLocalExitRoot,
bytes32[32] calldata smtProofRollupExitRoot,
uint256 globalIndex,
bytes32 mainnetExitRoot,
bytes32 rollupExitRoot,
uint32 originNetwork,
address originAddress,
uint32 destinationNetwork,
address destinationAddress,
uint256 amount,
bytes calldata metadata
) external;
function initialize(
uint32 _networkID,
address _gasTokenAddress,
uint32 _gasTokenNetwork,
IBasePolygonZkEVMGlobalExitRoot _globalExitRootManager,
address _polygonRollupManager,
bytes memory _gasTokenMetadata
) external;
function getTokenMetadata(
address token
) external view returns (bytes memory);
function getWrappedTokenBridgeImplementation()
external
view
returns (address);
function getProxiedTokensManager() external view returns (address);
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.28;
interface IProxyAdmin {
function owner() external view returns (address);
}// SPDX-License-Identifier: AGPL-3.0
pragma solidity 0.8.28;
import {IERC20Permit} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
interface ITokenWrappedBridgeUpgradeable is
IERC20,
IERC20Metadata,
IERC20Permit
{
function initialize(
string memory name,
string memory symbol,
uint8 __decimals
) external;
function mint(address to, uint256 value) external;
function burn(address account, uint256 value) external;
}// SPDX-License-Identifier: AGPL-3.0
pragma solidity 0.8.28;
import "../interfaces/IBytecodeStorer.sol";
/**
* @title BytecodeStorer
* @notice Contract to hold the bytecodes necessary to deploy wrapped and upgradable tokens, it's deployed by the bridge at the constructor and the constant is retrieved by the
* bridge through the IBytecodeStorer interface and an external call, done this way to have more bytecode available for the bridge.
*/
contract BytecodeStorer is IBytecodeStorer {
// Init code of the TokenWrappedTransparentProxy, compiled with the following config:
// version: "0.8.28",
// settings: {
// optimizer: {
// enabled: true,
// runs: 999999,
// },
// evmVersion: "shangai",
// metadata: {bytecodeHash: "none"},
// }
bytes public constant INIT_BYTECODE_TRANSPARENT_PROXY =
hex"60806040819052631d97f74d60e11b81523390633b2fee9a90608490602090600481865afa158015610033573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906100579190610433565b604080515f80825260208201909252905061007382825f6100e2565b50506100dd336001600160a01b03166338b8fbbb6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156100b4573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906100d89190610433565b61010d565b6104c8565b6100eb8361017a565b5f825111806100f75750805b156101085761010683836101b9565b505b505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f61014c5f516020610e815f395f51905f52546001600160a01b031690565b604080516001600160a01b03928316815291841660208301520160405180910390a1610177816101e5565b50565b61018381610280565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b905f90a250565b60606101de8383604051806060016040528060278152602001610ea160279139610314565b9392505050565b6001600160a01b03811661024f5760405162461bcd60e51b815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201526564647265737360d01b60648201526084015b60405180910390fd5b805f516020610e815f395f51905f525b80546001600160a01b0319166001600160a01b039290921691909117905550565b6001600160a01b0381163b6102ed5760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b6064820152608401610246565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc61025f565b60605f5f856001600160a01b031685604051610330919061047b565b5f60405180830381855af49150503d805f8114610368576040519150601f19603f3d011682016040523d82523d5f602084013e61036d565b606091505b50909250905061037f86838387610389565b9695505050505050565b606083156103f75782515f036103f0576001600160a01b0385163b6103f05760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610246565b5081610401565b6104018383610409565b949350505050565b8151156104195781518083602001fd5b8060405162461bcd60e51b81526004016102469190610496565b5f60208284031215610443575f5ffd5b81516001600160a01b03811681146101de575f5ffd5b5f5b8381101561047357818101518382015260200161045b565b50505f910152565b5f825161048c818460208701610459565b9190910192915050565b602081525f82518060208401526104b4816040850160208701610459565b601f01601f19169190910160400192915050565b6109ac806104d55f395ff3fe60806040526004361061005d575f3560e01c80635c60da1b116100425780635c60da1b146100a65780638f283970146100e3578063f851a440146101025761006c565b80633659cfe6146100745780634f1ef286146100935761006c565b3661006c5761006a610116565b005b61006a610116565b34801561007f575f5ffd5b5061006a61008e366004610854565b610130565b61006a6100a136600461086d565b610178565b3480156100b1575f5ffd5b506100ba6101eb565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100ee575f5ffd5b5061006a6100fd366004610854565b610228565b34801561010d575f5ffd5b506100ba610255565b61011e610282565b61012e610129610359565b610362565b565b610138610380565b73ffffffffffffffffffffffffffffffffffffffff1633036101705761016d8160405180602001604052805f8152505f6103bf565b50565b61016d610116565b610180610380565b73ffffffffffffffffffffffffffffffffffffffff1633036101e3576101de8383838080601f0160208091040260200160405190810160405280939291908181526020018383808284375f92019190915250600192506103bf915050565b505050565b6101de610116565b5f6101f4610380565b73ffffffffffffffffffffffffffffffffffffffff16330361021d57610218610359565b905090565b610225610116565b90565b610230610380565b73ffffffffffffffffffffffffffffffffffffffff1633036101705761016d816103e9565b5f61025e610380565b73ffffffffffffffffffffffffffffffffffffffff16330361021d57610218610380565b61028a610380565b73ffffffffffffffffffffffffffffffffffffffff16330361012e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b5f61021861044a565b365f5f375f5f365f845af43d5f5f3e80801561037c573d5ff35b3d5ffd5b5f7fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b6103c883610471565b5f825111806103d45750805b156101de576103e383836104bd565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f610412610380565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a161016d816104e9565b5f7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc6103a3565b61047a816105f5565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b905f90a250565b60606104e28383604051806060016040528060278152602001610979602791396106c0565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff811661058c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610350565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b73ffffffffffffffffffffffffffffffffffffffff81163b610699576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e7472616374000000000000000000000000000000000000006064820152608401610350565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc6105af565b60605f5f8573ffffffffffffffffffffffffffffffffffffffff16856040516106e9919061090d565b5f60405180830381855af49150503d805f8114610721576040519150601f19603f3d011682016040523d82523d5f602084013e610726565b606091505b509150915061073786838387610741565b9695505050505050565b606083156107d65782515f036107cf5773ffffffffffffffffffffffffffffffffffffffff85163b6107cf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610350565b50816107e0565b6107e083836107e8565b949350505050565b8151156107f85781518083602001fd5b806040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103509190610928565b803573ffffffffffffffffffffffffffffffffffffffff8116811461084f575f5ffd5b919050565b5f60208284031215610864575f5ffd5b6104e28261082c565b5f5f5f6040848603121561087f575f5ffd5b6108888461082c565b9250602084013567ffffffffffffffff8111156108a3575f5ffd5b8401601f810186136108b3575f5ffd5b803567ffffffffffffffff8111156108c9575f5ffd5b8660208284010111156108da575f5ffd5b939660209190910195509293505050565b5f5b838110156109055781810151838201526020016108ed565b50505f910152565b5f825161091e8184602087016108eb565b9190910192915050565b602081525f82518060208401526109468160408501602087016108eb565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a164736f6c634300081c000ab53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564";
}// SPDX-License-Identifier: AGPL-3.0
pragma solidity ^0.8.20;
import "./Hashes.sol";
/**
* This contract will be used as a helper for all the sparse merkle tree related functions
* Based on the implementation of the deposit eth2.0 contract https://github.com/ethereum/consensus-specs/blob/dev/solidity_deposit_contract/deposit_contract.sol
*/
contract DepositContractBase {
/**
* @dev Thrown when the merkle tree is full
*/
error MerkleTreeFull();
// Merkle tree levels
uint256 internal constant _DEPOSIT_CONTRACT_TREE_DEPTH = 32;
// This ensures `depositCount` will fit into 32-bits
uint256 internal constant _MAX_DEPOSIT_COUNT =
2 ** _DEPOSIT_CONTRACT_TREE_DEPTH - 1;
// Branch array which contains the necessary sibilings to compute the next root when a new
// leaf is inserted
bytes32[_DEPOSIT_CONTRACT_TREE_DEPTH] internal _branch;
// Counter of current deposits
uint256 public depositCount;
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
*/
/// @custom:oz-renamed-from _gap
uint256[10] private __gap;
/**
* @notice Computes and returns the merkle root
*/
function getRoot() public view virtual returns (bytes32) {
bytes32 node;
uint256 size = depositCount;
bytes32 currentZeroHashHeight = 0;
for (
uint256 height = 0;
height < _DEPOSIT_CONTRACT_TREE_DEPTH;
height++
) {
if (((size >> height) & 1) == 1)
node = Hashes.efficientKeccak256(_branch[height], node);
else node = Hashes.efficientKeccak256(node, currentZeroHashHeight);
currentZeroHashHeight = Hashes.efficientKeccak256(
currentZeroHashHeight,
currentZeroHashHeight
);
}
return node;
}
/**
* @notice Add a new leaf to the merkle tree
* @param leaf Leaf
*/
function _addLeaf(bytes32 leaf) internal {
bytes32 node = leaf;
// Avoid overflowing the Merkle tree (and prevent edge case in computing `_branch`)
if (depositCount >= _MAX_DEPOSIT_COUNT) {
revert MerkleTreeFull();
}
// Add deposit data root to Merkle tree (update a single `_branch` node)
uint256 size = ++depositCount;
for (
uint256 height = 0;
height < _DEPOSIT_CONTRACT_TREE_DEPTH;
height++
) {
if (((size >> height) & 1) == 1) {
_branch[height] = node;
return;
}
node = Hashes.efficientKeccak256(_branch[height], node);
}
// As the loop should always end prematurely with the `return` statement,
// this code should be unreachable. We assert `false` just to be safe.
assert(false);
}
/**
* @notice Verify merkle proof
* @param leafHash Leaf hash
* @param smtProof Smt proof
* @param index Index of the leaf
* @param root Merkle root
*/
function verifyMerkleProof(
bytes32 leafHash,
bytes32[_DEPOSIT_CONTRACT_TREE_DEPTH] calldata smtProof,
uint32 index,
bytes32 root
) public pure returns (bool) {
return calculateRoot(leafHash, smtProof, index) == root;
}
/**
* @notice Calculate root from merkle proof
* @param leafHash Leaf hash
* @param smtProof Smt proof
* @param index Index of the leaf
*/
function calculateRoot(
bytes32 leafHash,
bytes32[_DEPOSIT_CONTRACT_TREE_DEPTH] calldata smtProof,
uint32 index
) public pure returns (bytes32) {
bytes32 node = leafHash;
// Compute root
for (
uint256 height = 0;
height < _DEPOSIT_CONTRACT_TREE_DEPTH;
height++
) {
if (((index >> height) & 1) == 1)
node = Hashes.efficientKeccak256(smtProof[height], node);
else node = Hashes.efficientKeccak256(node, smtProof[height]);
}
return node;
}
}// SPDX-License-Identifier: AGPL-3.0
pragma solidity ^0.8.20;
import "@openzeppelin/contracts-upgradeable4/security/ReentrancyGuardUpgradeable.sol";
import "./DepositContractBase.sol";
/**
* This contract will be used in the PolygonZkEVMBridge contract, it inherits the DepositContractBase and adds the logic
* to calculate the leaf of the tree
*/
contract DepositContractV2 is ReentrancyGuardUpgradeable, DepositContractBase {
/**
* @notice Given the leaf data returns the leaf value
* @param leafType Leaf type --> [0] transfer Ether / ERC20 tokens, [1] message
* @param originNetwork Origin Network
* @param originAddress [0] Origin token address, 0 address is reserved for gas token address. If WETH address is zero, means this gas token is ether, else means is a custom erc20 gas token, [1] msg.sender of the message
* @param destinationNetwork Destination network
* @param destinationAddress Destination address
* @param amount [0] Amount of tokens/ether, [1] Amount of ether
* @param metadataHash Hash of the metadata
*/
function getLeafValue(
uint8 leafType,
uint32 originNetwork,
address originAddress,
uint32 destinationNetwork,
address destinationAddress,
uint256 amount,
bytes32 metadataHash
) public pure returns (bytes32) {
return
keccak256(
abi.encodePacked(
leafType,
originNetwork,
originAddress,
destinationNetwork,
destinationAddress,
amount,
metadataHash
)
);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/cryptography/Hashes.sol)
pragma solidity ^0.8.20;
/**
* @dev Library of standard hash functions.
* @notice This code is a copy from OpenZeppelin Contracts v5.1.0 (utils/cryptography/Hashes.sol) with a minor change:
* function visibility is modified from 'private' to 'internal' so it can be used in other contracts.
* @notice OpenZeppelin already did this change: https://github.com/OpenZeppelin/openzeppelin-contracts/commit/441dc141ac99622de7e535fa75dfc74af939019c
* to be included in next version of OpenZeppelin Contracts.
* _Available since v5.1._
*/
library Hashes {
/**
* @dev Implementation of keccak256(abi.encode(a, b)) that doesn't allocate or expand memory.
*/
function efficientKeccak256(
bytes32 a,
bytes32 b
) internal pure returns (bytes32 value) {
assembly ("memory-safe") {
mstore(0x00, a)
mstore(0x20, b)
value := keccak256(0x00, 0x40)
}
}
}// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.28;
// Main functionality.
import {ERC20PermitUpgradeable} from "@openzeppelin/contracts-upgradeable5/token/ERC20/extensions/ERC20PermitUpgradeable.sol";
// Other functionality.
import {Initializable} from "@openzeppelin/contracts-upgradeable5/proxy/utils/Initializable.sol";
// Interfaces
import {ITokenWrappedBridgeUpgradeable, IERC20Metadata, IERC20Permit} from "../interfaces/ITokenWrappedBridgeUpgradeable.sol";
import {ERC20Upgradeable} from "@openzeppelin/contracts-upgradeable5/token/ERC20/ERC20Upgradeable.sol";
// This contract contains the solidity code that compiles into the BASE_INIT_BYTECODE_WRAPPED_TOKEN_UPGRADEABLE constant on the PolygonZkEVMBridgeV2
// This contract should remain untouched, even if it's not used directly as dependency. The main use is to verify on block explorers
// and check the implementation.
contract TokenWrappedBridgeUpgradeable is
Initializable,
ERC20PermitUpgradeable,
ITokenWrappedBridgeUpgradeable
{
/// @dev Storage of TokenWrappedBridgeUpgradeable contract.
/// @dev It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions when using with upgradeable contracts.
/// @custom:storage-location erc7201:agglayer.storage.TokenWrappedBridgeUpgradeable
struct TokenWrappedBridgeUpgradeableStorage {
uint8 decimals;
address bridgeAddress;
}
/// @dev The storage slot at which Custom Token storage starts, following the EIP-7201 standard.
/// @dev Calculated as `keccak256(abi.encode(uint256(keccak256("agglayer.storage.TokenWrappedBridgeUpgradeable")) - 1)) & ~bytes32(uint256(0xff))`.
bytes32 private constant TOKEN_WRAPPED_BRIDGE_UPGRADEABLE_STORAGE =
hex"863b064fe9383d75d38f584f64f1aaba4520e9ebc98515fa15bdeae8c4274d00";
// Errors.
error OnlyBridge();
// Checks if the sender is the bridge
modifier onlyBridge() {
TokenWrappedBridgeUpgradeableStorage
storage $ = _getTokenWrappedBridgeUpgradeableStorage();
// Only bridge can mint and burn tokens
require(msg.sender == $.bridgeAddress, OnlyBridge());
_;
}
////////////////////////////////////////////////////////////
// Constructor //
////////////////////////////////////////////////////////////
/**
* @dev Disable initializers on the implementation following the best practices.
*/
constructor() {
// disable initializers for implementation contract
_disableInitializers();
}
////////////////////////////////////////////////////////////
// Initialization //
////////////////////////////////////////////////////////////
function initialize(
string memory name,
string memory symbol,
uint8 __decimals
) external initializer {
// Initialize the ERC20 token with the name and symbol
__ERC20_init(name, symbol);
// Initialize the ERC20Permit with the name
__ERC20Permit_init(name);
// Initialize storage
TokenWrappedBridgeUpgradeableStorage
storage $ = _getTokenWrappedBridgeUpgradeableStorage();
$.decimals = __decimals;
$.bridgeAddress = msg.sender;
}
/// @notice Mints Custom Tokens to the recipient.
/// @notice This function is only callable by the bridge.
/// @param to The address of the recipient.
/// @param value The amount of tokens to mint.
function mint(address to, uint256 value) external onlyBridge {
_mint(to, value);
}
/// @notice Notice that is not require to approve wrapped tokens to use the bridge
/// @notice burns Custom Tokens from the account.
/// @notice This function is only callable by the bridge.
/// @param account The address of the account.
/// @param value The amount of tokens to burn.
function burn(address account, uint256 value) external onlyBridge {
_burn(account, value);
}
function nonces(
address owner
)
public
view
override(ERC20PermitUpgradeable, IERC20Permit)
returns (uint256)
{
return super.nonces(owner);
}
/// @notice The number of decimals of the token.
function decimals()
public
view
override(ERC20Upgradeable, IERC20Metadata)
returns (uint8)
{
TokenWrappedBridgeUpgradeableStorage
storage $ = _getTokenWrappedBridgeUpgradeableStorage();
return $.decimals;
}
/// @notice The address of the bridge contract.
function bridgeAddress() public view returns (address) {
TokenWrappedBridgeUpgradeableStorage
storage $ = _getTokenWrappedBridgeUpgradeableStorage();
return $.bridgeAddress;
}
/// @dev A function to return a pointer for the TokenWrappedBridgeUpgradeableStorageLocation.
function _getTokenWrappedBridgeUpgradeableStorage()
internal
pure
returns (TokenWrappedBridgeUpgradeableStorage storage $)
{
assembly {
$.slot := TOKEN_WRAPPED_BRIDGE_UPGRADEABLE_STORAGE
}
}
}// SPDX-License-Identifier: AGPL-3.0
pragma solidity 0.8.28;
import "./lib/DepositContractV2.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "../interfaces/IBasePolygonZkEVMGlobalExitRoot.sol";
import "../interfaces/IBridgeMessageReceiver.sol";
import "./interfaces/IPolygonZkEVMBridgeV2.sol";
import "../lib/EmergencyManager.sol";
import "../lib/GlobalExitRootLib.sol";
import "./lib/BytecodeStorer.sol";
import {ITokenWrappedBridgeUpgradeable, TokenWrappedBridgeUpgradeable, IERC20Metadata} from "./lib/TokenWrappedBridgeUpgradeable.sol";
import {ERC1967Utils} from "@openzeppelin/contracts5/proxy/ERC1967/ERC1967Utils.sol";
import {IProxyAdmin} from "./interfaces/IProxyAdmin.sol";
/**
* PolygonZkEVMBridge that will be deployed on Ethereum and all Polygon rollups
* Contract responsible to manage the token interactions with other networks
*/
contract PolygonZkEVMBridgeV2 is
DepositContractV2,
EmergencyManager,
IPolygonZkEVMBridgeV2
{
using SafeERC20 for ITokenWrappedBridgeUpgradeable;
// Wrapped Token information struct
struct TokenInformation {
uint32 originNetwork;
address originTokenAddress;
}
// Address of the contract that contains the bytecode to deploy wrapped tokens, upgradeable tokens and the code of the transparent proxy
/// @dev the constant has been exported to a separate contract to improve this bytecode length.
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable
IBytecodeStorer public immutable wrappedTokenBytecodeStorer;
/// Address of the wrappedToken implementation, it is set at constructor and all proxied wrapped tokens will point to this implementation
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable
address internal immutable wrappedTokenBridgeImplementation;
// bytes4(keccak256(bytes("permit(address,address,uint256,uint256,uint8,bytes32,bytes32)")));
bytes4 internal constant _PERMIT_SIGNATURE = 0xd505accf;
// bytes4(keccak256(bytes("permit(address,address,uint256,uint256,bool,uint8,bytes32,bytes32)")));
bytes4 internal constant _PERMIT_SIGNATURE_DAI = 0x8fcbaf0c;
// Mainnet identifier
uint32 internal constant _MAINNET_NETWORK_ID = 0;
// ZkEVM identifier
uint32 private constant _ZKEVM_NETWORK_ID = 1;
// Leaf type asset
uint8 internal constant _LEAF_TYPE_ASSET = 0;
// Leaf type message
uint8 internal constant _LEAF_TYPE_MESSAGE = 1;
// Nullifier offset
uint256 internal constant _MAX_LEAFS_PER_NETWORK = 2 ** 32;
// Indicate where's the mainnet flag bit in the global index
uint256 internal constant _GLOBAL_INDEX_MAINNET_FLAG = 2 ** 64;
// Current bridge version
string public constant BRIDGE_VERSION = "al-v0.3.1";
// Network identifier
uint32 public networkID;
// Global Exit Root address
IBasePolygonZkEVMGlobalExitRoot public globalExitRootManager;
// Last updated deposit count to the global exit root manager
uint32 public lastUpdatedDepositCount;
// Leaf index --> claimed bit map
mapping(uint256 => uint256) public claimedBitMap;
// keccak256(OriginNetwork || tokenAddress) --> Wrapped token address
mapping(bytes32 => address) public tokenInfoToWrappedToken;
// Wrapped token Address --> Origin token information
mapping(address => TokenInformation) public wrappedTokenToTokenInfo;
// Rollup manager address, previously PolygonZkEVM
/// @custom:oz-renamed-from polygonZkEVMaddress
address public polygonRollupManager;
// Native address
address public gasTokenAddress;
// Native address
uint32 public gasTokenNetwork;
// Gas token metadata
bytes public gasTokenMetadata;
// WETH address
// @note WETH address will only be present when the native token is not ether, but another gasToken.
// This variable is set at the initialization of the contract in case there's a gas token different than ether, (gasTokenAddress != address(0) ) so a new wrapped Token will be deployed to handle ether that came from other networks
ITokenWrappedBridgeUpgradeable public WETHToken;
// Address of the proxied tokens manager, is the admin of proxied wrapped tokens
address public proxiedTokensManager;
// This account will be able to accept the proxiedTokensManager role
address public pendingProxiedTokensManager;
// @notice Value to detect if the contract has been initialized previously.
/// This mechanism is used to properly select the initializer
uint8 internal _initializerVersion;
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
*/
uint256[48] private __gap;
/**
* @dev Emitted when bridge assets or messages to another network
*/
event BridgeEvent(
uint8 leafType,
uint32 originNetwork,
address originAddress,
uint32 destinationNetwork,
address destinationAddress,
uint256 amount,
bytes metadata,
uint32 depositCount
);
/**
* @dev Emitted when a claim is done from another network
*/
event ClaimEvent(
uint256 globalIndex,
uint32 originNetwork,
address originAddress,
address destinationAddress,
uint256 amount
);
/**
* @dev Emitted when a new wrapped token is created
*/
event NewWrappedToken(
uint32 originNetwork,
address originTokenAddress,
address wrappedTokenAddress,
bytes metadata
);
/**
* @notice Emitted when the pending ProxiedTokensManager accepts the ProxiedTokensManager role.
* @param oldProxiedTokensManager The previous ProxiedTokensManager.
* @param newProxiedTokensManager The new ProxiedTokensManager.
*/
event AcceptProxiedTokensManagerRole(
address oldProxiedTokensManager,
address newProxiedTokensManager
);
/**
* @notice Emitted when the proxiedTokensManager starts the two-step transfer role setting a new pending proxiedTokensManager.
* @param currentProxiedTokensManager The current proxiedTokensManager.
* @param newProxiedTokensManager The new pending proxiedTokensManager.
*/
event TransferProxiedTokensManagerRole(
address currentProxiedTokensManager,
address newProxiedTokensManager
);
/// @dev Modifier to retrieve initializer version value previous on using the reinitializer modifier, its used in the initialize function.
modifier getInitializedVersion() {
_initializerVersion = _getInitializedVersion();
_;
/// @dev Is set to zero always after usage for transient storage mimic and better gas optimization
_initializerVersion = 0;
}
constructor() {
// Deploy the wrapped token contract
/// @dev this contract is used to store the bytecode of the wrapped token contract, previously stored in the bridge contract but moved to a separate contract to reduce the bytecode size.
wrappedTokenBytecodeStorer = new BytecodeStorer();
// Deploy the implementation of the wrapped token contract
/// @dev its the address where proxy wrapped tokens with deterministic address will point
wrappedTokenBridgeImplementation = address(
new TokenWrappedBridgeUpgradeable()
);
// Disable initializers on the implementation following the best practices
_disableInitializers();
}
/**
* @param _networkID networkID
* @param _gasTokenAddress gas token address
* @param _gasTokenNetwork gas token network
* @param _globalExitRootManager global exit root manager address
* @param _polygonRollupManager polygonZkEVM address
* @notice The value of `_polygonRollupManager` on the L2 deployment of the contract will be address(0), so
* emergency state is not possible for the L2 deployment of the bridge, intentionally
* @param _gasTokenMetadata Abi encoded gas token metadata
*/
function initialize(
uint32 _networkID,
address _gasTokenAddress,
uint32 _gasTokenNetwork,
IBasePolygonZkEVMGlobalExitRoot _globalExitRootManager,
address _polygonRollupManager,
bytes memory _gasTokenMetadata
) external virtual getInitializedVersion reinitializer(2) {
if (_initializerVersion != 0) {
revert InvalidInitializeFunction();
}
// Set PolygonTimelock contract address as proxied tokens manager, the owner of current proxy contract
_setProxiedTokensManagerFromProxy();
networkID = _networkID;
globalExitRootManager = _globalExitRootManager;
polygonRollupManager = _polygonRollupManager;
// Set gas token
if (_gasTokenAddress == address(0)) {
// Gas token will be ether
if (_gasTokenNetwork != 0) {
revert GasTokenNetworkMustBeZeroOnEther();
}
// WETHToken, gasTokenAddress and gasTokenNetwork will be 0
// gasTokenMetadata will be empty
} else {
// Gas token will be an erc20
gasTokenAddress = _gasTokenAddress;
gasTokenNetwork = _gasTokenNetwork;
gasTokenMetadata = _gasTokenMetadata;
// Create a wrapped token for WETH, with salt == 0
WETHToken = _deployWrappedToken(
0, // salt
abi.encode("Wrapped Ether", "WETH", 18)
);
}
// Initialize OZ contracts
__ReentrancyGuard_init();
}
/**
* @notice initializer to set PolygonTimelock as proxiedTokensManager
*/
function initialize()
public
virtual
getInitializedVersion
reinitializer(2)
{
if (_initializerVersion == 0) {
revert InvalidInitializeFunction();
}
// Set PolygonTimelock contract address as proxied tokens manager, the owner of current proxy contract
_setProxiedTokensManagerFromProxy();
}
modifier onlyRollupManager() {
if (polygonRollupManager != msg.sender) {
revert OnlyRollupManager();
}
_;
}
/**
* @notice Set PolygonTimelock contract address as proxied tokens manager, the owner of current proxy contract
*/
function _setProxiedTokensManagerFromProxy() private {
// Retrieve proxyAdmin from current proxy contract
address proxyAdmin = ERC1967Utils.getAdmin();
// Retrieve owner from proxyAdmin and set it as proxiedTokensManager
proxiedTokensManager = IProxyAdmin(proxyAdmin).owner();
require(
proxiedTokensManager != address(0),
InvalidZeroProxyAdminOwner(proxyAdmin)
);
emit AcceptProxiedTokensManagerRole(address(0), proxiedTokensManager);
}
/**
* @notice Deposit add a new leaf to the merkle tree
* note If this function is called with a reentrant token, it would be possible to `claimTokens` in the same call
* Reducing the supply of tokens on this contract, and actually locking tokens in the contract.
* Therefore we recommend to third parties bridges that if they do implement reentrant call of `beforeTransfer` of some reentrant tokens
* do not call any external address in that case
* note User/UI must be aware of the existing/available networks when choosing the destination network
* @param destinationNetwork Network destination
* @param destinationAddress Address destination
* @param amount Amount of tokens
* @param token Token address, 0 address is reserved for gas token address. If WETH address is zero, means this gas token is ether, else means is a custom erc20 gas token
* @param forceUpdateGlobalExitRoot Indicates if the new global exit root is updated or not
* @param permitData Raw data of the call `permit` of the token
*/
function bridgeAsset(
uint32 destinationNetwork,
address destinationAddress,
uint256 amount,
address token,
bool forceUpdateGlobalExitRoot,
bytes calldata permitData
) public payable virtual ifNotEmergencyState nonReentrant {
if (destinationNetwork == networkID) {
revert DestinationNetworkInvalid();
}
address originTokenAddress;
uint32 originNetwork;
bytes memory metadata;
uint256 leafAmount = amount;
if (token == address(0)) {
// Check gas token transfer
if (msg.value != amount) {
revert AmountDoesNotMatchMsgValue();
}
// Set gas token parameters
originNetwork = gasTokenNetwork;
originTokenAddress = gasTokenAddress;
metadata = gasTokenMetadata;
} else {
// Check msg.value is 0 if tokens are bridged
if (msg.value != 0) {
revert MsgValueNotZero();
}
// Use permit if any
if (permitData.length != 0) {
_permit(token, permitData);
}
// Check if it's WETH, this only applies on L2 networks with gasTokens
// In case ether is the native token, WETHToken will be 0, and the address 0 is already checked
if (token == address(WETHToken)) {
// Burn tokens
/// @dev in case this function is called from a sovereign bridge that has remapped wethToken with a non-standard token,
/// we have to add to the leaf the amount received to the bridge, not the amount sent
leafAmount = _bridgeWrappedAsset(
ITokenWrappedBridgeUpgradeable(token),
amount
);
// Both origin network and originTokenAddress will be 0
// Metadata will be empty
} else {
TokenInformation memory tokenInfo = wrappedTokenToTokenInfo[
token
];
if (
tokenInfo.originTokenAddress != address(0) ||
tokenInfo.originNetwork != _MAINNET_NETWORK_ID
) {
// The token is a wrapped token from another network
/// @dev in case this function is called from a sovereign bridge that has remapped the token with a non-standard token,
/// we have to add to the leaf the amount received to the bridge, not the amount sent
leafAmount = _bridgeWrappedAsset(
ITokenWrappedBridgeUpgradeable(token),
amount
);
originTokenAddress = tokenInfo.originTokenAddress;
originNetwork = tokenInfo.originNetwork;
} else {
// In order to support fee tokens check the amount received, not the transferred
uint256 balanceBefore = ITokenWrappedBridgeUpgradeable(
token
).balanceOf(address(this));
ITokenWrappedBridgeUpgradeable(token).safeTransferFrom(
msg.sender,
address(this),
amount
);
uint256 balanceAfter = ITokenWrappedBridgeUpgradeable(token)
.balanceOf(address(this));
// Override leafAmount with the received amount
leafAmount = balanceAfter - balanceBefore;
originTokenAddress = token;
originNetwork = networkID;
}
// Encode metadata
metadata = getTokenMetadata(token);
}
}
emit BridgeEvent(
_LEAF_TYPE_ASSET,
originNetwork,
originTokenAddress,
destinationNetwork,
destinationAddress,
leafAmount,
metadata,
uint32(depositCount)
);
_addLeafBridge(
_LEAF_TYPE_ASSET,
originNetwork,
originTokenAddress,
destinationNetwork,
destinationAddress,
leafAmount,
keccak256(metadata)
);
// Update the new root to the global exit root manager if set by the user
if (forceUpdateGlobalExitRoot) {
_updateGlobalExitRoot();
}
}
/**
* @notice Bridge message and send ETH value
* note User/UI must be aware of the existing/available networks when choosing the destination network
* @param destinationNetwork Network destination
* @param destinationAddress Address destination
* @param forceUpdateGlobalExitRoot Indicates if the new global exit root is updated or not
* @param metadata Message metadata
*/
function bridgeMessage(
uint32 destinationNetwork,
address destinationAddress,
bool forceUpdateGlobalExitRoot,
bytes calldata metadata
) external payable ifNotEmergencyState {
// If exist a gas token, only allow call this function without value
if (msg.value != 0 && address(WETHToken) != address(0)) {
revert NoValueInMessagesOnGasTokenNetworks();
}
_bridgeMessage(
destinationNetwork,
destinationAddress,
msg.value,
forceUpdateGlobalExitRoot,
metadata
);
}
/**
* @notice Bridge message and send ETH value
* note User/UI must be aware of the existing/available networks when choosing the destination network
* @param destinationNetwork Network destination
* @param destinationAddress Address destination
* @param amountWETH Amount of WETH tokens
* @param forceUpdateGlobalExitRoot Indicates if the new global exit root is updated or not
* @param metadata Message metadata
*/
function bridgeMessageWETH(
uint32 destinationNetwork,
address destinationAddress,
uint256 amountWETH,
bool forceUpdateGlobalExitRoot,
bytes calldata metadata
) external ifNotEmergencyState {
// If native token is ether, disable this function
if (address(WETHToken) == address(0)) {
revert NativeTokenIsEther();
}
// Burn wETH tokens
/// @dev in case this function is called from a sovereign bridge that has remapped wethToken with a non-standard token,
/// we have to add to the leaf the amount received to the bridge, not the amount sent
uint256 leafAmount = _bridgeWrappedAsset(WETHToken, amountWETH);
_bridgeMessage(
destinationNetwork,
destinationAddress,
leafAmount,
forceUpdateGlobalExitRoot,
metadata
);
}
/**
* @notice Bridge message and send ETH value
* @param destinationNetwork Network destination
* @param destinationAddress Address destination
* @param amountEther Amount of ether along with the message
* @param forceUpdateGlobalExitRoot Indicates if the new global exit root is updated or not
* @param metadata Message metadata
*/
function _bridgeMessage(
uint32 destinationNetwork,
address destinationAddress,
uint256 amountEther,
bool forceUpdateGlobalExitRoot,
bytes calldata metadata
) internal {
if (destinationNetwork == networkID) {
revert DestinationNetworkInvalid();
}
emit BridgeEvent(
_LEAF_TYPE_MESSAGE,
networkID,
msg.sender,
destinationNetwork,
destinationAddress,
amountEther,
metadata,
uint32(depositCount)
);
_addLeafBridge(
_LEAF_TYPE_MESSAGE,
networkID,
msg.sender,
destinationNetwork,
destinationAddress,
amountEther,
keccak256(metadata)
);
// Update the new root to the global exit root manager if set by the user
if (forceUpdateGlobalExitRoot) {
_updateGlobalExitRoot();
}
}
/**
* @notice Verify merkle proof and withdraw tokens/ether
* @param smtProofLocalExitRoot Smt proof to proof the leaf against the network exit root
* @param smtProofRollupExitRoot Smt proof to proof the rollupLocalExitRoot against the rollups exit root
* @param globalIndex Global index is defined as:
* | 191 bits | 1 bit | 32 bits | 32 bits |
* | 0 | mainnetFlag | rollupIndex | localRootIndex |
* note that only the rollup index will be used only in case the mainnet flag is 0
* note that global index do not assert the unused bits to 0.
* This means that when synching the events, the globalIndex must be decoded the same way that in the Smart contract
* to avoid possible synch attacks
* @param mainnetExitRoot Mainnet exit root
* @param rollupExitRoot Rollup exit root
* @param originNetwork Origin network
* @param originTokenAddress Origin token address,
* @param destinationNetwork Network destination
* @param destinationAddress Address destination
* @param amount Amount of tokens
* @param metadata Abi encoded metadata if any, empty otherwise
*/
function claimAsset(
bytes32[_DEPOSIT_CONTRACT_TREE_DEPTH] calldata smtProofLocalExitRoot,
bytes32[_DEPOSIT_CONTRACT_TREE_DEPTH] calldata smtProofRollupExitRoot,
uint256 globalIndex,
bytes32 mainnetExitRoot,
bytes32 rollupExitRoot,
uint32 originNetwork,
address originTokenAddress,
uint32 destinationNetwork,
address destinationAddress,
uint256 amount,
bytes calldata metadata
) external ifNotEmergencyState nonReentrant {
// Destination network must be this networkID
if (destinationNetwork != networkID) {
revert DestinationNetworkInvalid();
}
// Verify leaf exist and it does not have been claimed
_verifyLeafBridge(
smtProofLocalExitRoot,
smtProofRollupExitRoot,
globalIndex,
mainnetExitRoot,
rollupExitRoot,
_LEAF_TYPE_ASSET,
originNetwork,
originTokenAddress,
destinationNetwork,
destinationAddress,
amount,
keccak256(metadata)
);
emit ClaimEvent(
globalIndex,
originNetwork,
originTokenAddress,
destinationAddress,
amount
);
// Transfer funds
if (
originTokenAddress == address(0) &&
originNetwork == _MAINNET_NETWORK_ID
) {
if (address(WETHToken) == address(0)) {
// Ether is the native token
/* solhint-disable avoid-low-level-calls */
(bool success, ) = destinationAddress.call{value: amount}(
new bytes(0)
);
if (!success) {
revert EtherTransferFailed();
}
} else {
// Claim wETH
_claimWrappedAsset(WETHToken, destinationAddress, amount);
}
} else {
// Check if it's gas token
if (
originTokenAddress == gasTokenAddress &&
gasTokenNetwork == originNetwork
) {
// Transfer gas token
/* solhint-disable avoid-low-level-calls */
(bool success, ) = destinationAddress.call{value: amount}(
new bytes(0)
);
if (!success) {
revert EtherTransferFailed();
}
} else {
// Transfer tokens
if (originNetwork == networkID) {
// The token is an ERC20 from this network
ITokenWrappedBridgeUpgradeable(originTokenAddress)
.safeTransfer(destinationAddress, amount);
} else {
// The tokens is not from this network
// Create a wrapper for the token if not exist yet
bytes32 tokenInfoHash = keccak256(
abi.encodePacked(originNetwork, originTokenAddress)
);
address wrappedToken = tokenInfoToWrappedToken[
tokenInfoHash
];
if (wrappedToken == address(0)) {
// Get ERC20 metadata
// Create a new wrapped erc20 using create2
ITokenWrappedBridgeUpgradeable newWrappedToken = _deployWrappedToken(
tokenInfoHash,
metadata
);
// Mint tokens for the destination address
_claimWrappedAsset(
newWrappedToken,
destinationAddress,
amount
);
// Create mappings
tokenInfoToWrappedToken[tokenInfoHash] = address(
newWrappedToken
);
wrappedTokenToTokenInfo[
address(newWrappedToken)
] = TokenInformation(originNetwork, originTokenAddress);
emit NewWrappedToken(
originNetwork,
originTokenAddress,
address(newWrappedToken),
metadata
);
} else {
// Use the existing wrapped erc20
_claimWrappedAsset(
ITokenWrappedBridgeUpgradeable(wrappedToken),
destinationAddress,
amount
);
}
}
}
}
}
/**
* @notice Verify merkle proof and execute message
* If the receiving address is an EOA, the call will result as a success
* Which means that the amount of ether will be transferred correctly, but the message
* will not trigger any execution
* @dev any modification to this function must be done with caution, since this function has no re-entrancy check
* @dev function has not reentrancy check in purpose to not stop potential functionalities:
* - give funds back in case a message fails
* - composability on claimMessage and claimAsset
* @param smtProofLocalExitRoot Smt proof to proof the leaf against the exit root
* @param smtProofRollupExitRoot Smt proof to proof the rollupLocalExitRoot against the rollups exit root
* @param globalIndex Global index is defined as:
* | 191 bits | 1 bit | 32 bits | 32 bits |
* | 0 | mainnetFlag | rollupIndex | localRootIndex |
* note that only the rollup index will be used only in case the mainnet flag is 0
* note that global index do not assert the unused bits to 0.
* This means that when synching the events, the globalIndex must be decoded the same way that in the Smart contract
* to avoid possible synch attacks
* @param mainnetExitRoot Mainnet exit root
* @param rollupExitRoot Rollup exit root
* @param originNetwork Origin network
* @param originAddress Origin address
* @param destinationNetwork Network destination
* @param destinationAddress Address destination
* @param amount message value
* @param metadata Abi encoded metadata if any, empty otherwise
*/
function claimMessage(
bytes32[_DEPOSIT_CONTRACT_TREE_DEPTH] calldata smtProofLocalExitRoot,
bytes32[_DEPOSIT_CONTRACT_TREE_DEPTH] calldata smtProofRollupExitRoot,
uint256 globalIndex,
bytes32 mainnetExitRoot,
bytes32 rollupExitRoot,
uint32 originNetwork,
address originAddress,
uint32 destinationNetwork,
address destinationAddress,
uint256 amount,
bytes calldata metadata
) external ifNotEmergencyState {
// Destination network must be this networkID
if (destinationNetwork != networkID) {
revert DestinationNetworkInvalid();
}
// Verify leaf exist and it does not have been claimed
_verifyLeafBridge(
smtProofLocalExitRoot,
smtProofRollupExitRoot,
globalIndex,
mainnetExitRoot,
rollupExitRoot,
_LEAF_TYPE_MESSAGE,
originNetwork,
originAddress,
destinationNetwork,
destinationAddress,
amount,
keccak256(metadata)
);
emit ClaimEvent(
globalIndex,
originNetwork,
originAddress,
destinationAddress,
amount
);
// Execute message
bool success;
if (address(WETHToken) == address(0)) {
// Native token is ether
// Transfer ether
/* solhint-disable avoid-low-level-calls */
(success, ) = destinationAddress.call{value: amount}(
abi.encodeCall(
IBridgeMessageReceiver.onMessageReceived,
(originAddress, originNetwork, metadata)
)
);
} else {
// Mint wETH tokens
_claimWrappedAsset(WETHToken, destinationAddress, amount);
// Execute message
/* solhint-disable avoid-low-level-calls */
(success, ) = destinationAddress.call(
abi.encodeCall(
IBridgeMessageReceiver.onMessageReceived,
(originAddress, originNetwork, metadata)
)
);
}
if (!success) {
revert MessageFailed();
}
}
/**
* @notice Get leaf value and verify the merkle proof
* @param smtProofLocalExitRoot Smt proof to proof the leaf against the exit root
* @param smtProofRollupExitRoot Smt proof to proof the rollupLocalExitRoot against the rollups exit root
* @param globalIndex Global index
* @param mainnetExitRoot Mainnet exit root
* @param rollupExitRoot Rollup exit root
* @param leafType Leaf type
* @param originNetwork Origin network
* @param originAddress Origin address
* @param destinationNetwork Network destination
* @param destinationAddress Address destination
* @param amount message value
* @param metadataHash Hash of the metadata
*/
function _verifyLeafBridge(
bytes32[_DEPOSIT_CONTRACT_TREE_DEPTH] calldata smtProofLocalExitRoot,
bytes32[_DEPOSIT_CONTRACT_TREE_DEPTH] calldata smtProofRollupExitRoot,
uint256 globalIndex,
bytes32 mainnetExitRoot,
bytes32 rollupExitRoot,
uint8 leafType,
uint32 originNetwork,
address originAddress,
uint32 destinationNetwork,
address destinationAddress,
uint256 amount,
bytes32 metadataHash
) internal virtual {
_verifyLeaf(
smtProofLocalExitRoot,
smtProofRollupExitRoot,
globalIndex,
mainnetExitRoot,
rollupExitRoot,
getLeafValue(
leafType,
originNetwork,
originAddress,
destinationNetwork,
destinationAddress,
amount,
metadataHash
)
);
}
/**
* @notice Returns the address of a wrapper using the token information if already exist
* @param originNetwork Origin network
* @param originTokenAddress Origin token address, address of the token at the origin network.
*/
function getTokenWrappedAddress(
uint32 originNetwork,
address originTokenAddress
) external view returns (address) {
return
tokenInfoToWrappedToken[
keccak256(abi.encodePacked(originNetwork, originTokenAddress))
];
}
/**
* @notice Function to activate the emergency state
" Only can be called by the Polygon ZK-EVM in extreme situations
*/
function activateEmergencyState() external virtual onlyRollupManager {
_activateEmergencyState();
}
/**
* @notice Function to deactivate the emergency state
" Only can be called by the Polygon ZK-EVM
*/
function deactivateEmergencyState() external virtual onlyRollupManager {
_deactivateEmergencyState();
}
/**
* @notice Function to add a new leaf to the bridge merkle tree
* @param leafType leaf type
* @param originNetwork Origin network
* @param originAddress Origin address
* @param destinationNetwork Destination network
* @param destinationAddress Destination address
* @param amount Amount of tokens
* @param metadataHash Metadata hash
*/
function _addLeafBridge(
uint8 leafType,
uint32 originNetwork,
address originAddress,
uint32 destinationNetwork,
address destinationAddress,
uint256 amount,
bytes32 metadataHash
) internal virtual {
_addLeaf(
getLeafValue(
leafType,
originNetwork,
originAddress,
destinationNetwork,
destinationAddress,
amount,
metadataHash
)
);
}
/**
* @notice Verify leaf and checks that it has not been claimed
* @param smtProofLocalExitRoot Smt proof
* @param smtProofRollupExitRoot Smt proof
* @param globalIndex Index of the leaf
* @param mainnetExitRoot Mainnet exit root
* @param rollupExitRoot Rollup exit root
* @param leafValue leaf value
*/
function _verifyLeaf(
bytes32[_DEPOSIT_CONTRACT_TREE_DEPTH] calldata smtProofLocalExitRoot,
bytes32[_DEPOSIT_CONTRACT_TREE_DEPTH] calldata smtProofRollupExitRoot,
uint256 globalIndex,
bytes32 mainnetExitRoot,
bytes32 rollupExitRoot,
bytes32 leafValue
) internal virtual {
// Check blockhash where the global exit root was set
// Note that previous timestamps were set, since in only checked if != 0 it's ok
uint256 blockHashGlobalExitRoot = globalExitRootManager
.globalExitRootMap(
GlobalExitRootLib.calculateGlobalExitRoot(
mainnetExitRoot,
rollupExitRoot
)
);
// check that this global exit root exist
if (blockHashGlobalExitRoot == 0) {
revert GlobalExitRootInvalid();
}
uint32 leafIndex;
uint32 sourceBridgeNetwork;
// Get origin network from global index
if (globalIndex & _GLOBAL_INDEX_MAINNET_FLAG != 0) {
// The network is mainnet, therefore sourceBridgeNetwork is 0
// Last 32 bits are leafIndex
leafIndex = uint32(globalIndex);
// Reconstruct global index to assert that all unused bits are 0
require(
_GLOBAL_INDEX_MAINNET_FLAG + uint256(leafIndex) == globalIndex,
InvalidGlobalIndex()
);
// Verify merkle proof
if (
!verifyMerkleProof(
leafValue,
smtProofLocalExitRoot,
leafIndex,
mainnetExitRoot
)
) {
revert InvalidSmtProof();
}
} else {
// The network is a rollup, therefore sourceBridgeNetwork must be decoded
uint32 indexRollup = uint32(globalIndex >> 32);
sourceBridgeNetwork = indexRollup + 1;
// Last 32 bits are leafIndex
leafIndex = uint32(globalIndex);
// Reconstruct global index to assert that all unused bits are 0
require(
(uint256(indexRollup) << uint256(32)) + uint256(leafIndex) ==
globalIndex,
InvalidGlobalIndex()
);
// Verify merkle proof against rollup exit root
if (
!verifyMerkleProof(
calculateRoot(leafValue, smtProofLocalExitRoot, leafIndex),
smtProofRollupExitRoot,
indexRollup,
rollupExitRoot
)
) {
revert InvalidSmtProof();
}
}
// Set and check nullifier
_setAndCheckClaimed(leafIndex, sourceBridgeNetwork);
}
/**
* @notice Function to check if an index is claimed or not
* @param leafIndex Index
* @param sourceBridgeNetwork Origin network
*/
function isClaimed(
uint32 leafIndex,
uint32 sourceBridgeNetwork
) external view virtual returns (bool) {
uint256 globalIndex;
// For consistency with the previous set nullifiers
if (
networkID == _MAINNET_NETWORK_ID &&
sourceBridgeNetwork == _ZKEVM_NETWORK_ID
) {
globalIndex = uint256(leafIndex);
} else {
globalIndex =
uint256(leafIndex) +
uint256(sourceBridgeNetwork) *
_MAX_LEAFS_PER_NETWORK;
}
(uint256 wordPos, uint256 bitPos) = _bitmapPositions(globalIndex);
uint256 mask = (1 << bitPos);
return (claimedBitMap[wordPos] & mask) == mask;
}
/**
* @notice Function to check that an index is not claimed and set it as claimed
* @param leafIndex Index
* @param sourceBridgeNetwork Origin network
*/
function _setAndCheckClaimed(
uint32 leafIndex,
uint32 sourceBridgeNetwork
) internal virtual {
uint256 globalIndex;
// For consistency with the previous set nullifiers
if (
networkID == _MAINNET_NETWORK_ID &&
sourceBridgeNetwork == _ZKEVM_NETWORK_ID
) {
globalIndex = uint256(leafIndex);
} else {
globalIndex =
uint256(leafIndex) +
uint256(sourceBridgeNetwork) *
_MAX_LEAFS_PER_NETWORK;
}
(uint256 wordPos, uint256 bitPos) = _bitmapPositions(globalIndex);
uint256 mask = 1 << bitPos;
uint256 flipped = claimedBitMap[wordPos] ^= mask;
if (flipped & mask == 0) {
revert AlreadyClaimed();
}
}
/////////////////////////////////////////
// ProxiedTokensManager functions //
////////////////////////////////////////
/**
* @notice Starts the ProxiedTokensManager role transfer
* This is a two step process, the pending ProxiedTokensManager must accepted to finalize the process
* @param newProxiedTokensManager Address of the new pending ProxiedTokensManager
*/
function transferProxiedTokensManagerRole(
address newProxiedTokensManager
) external {
require(msg.sender == proxiedTokensManager, OnlyProxiedTokensManager());
pendingProxiedTokensManager = newProxiedTokensManager;
emit TransferProxiedTokensManagerRole(
proxiedTokensManager,
newProxiedTokensManager
);
}
/**
* @notice Allow the current pending ProxiedTokensManager to accept the ProxiedTokensManager role
*/
function acceptProxiedTokensManagerRole() external {
require(
msg.sender == pendingProxiedTokensManager,
OnlyPendingProxiedTokensManager()
);
address oldProxiedTokensManager = proxiedTokensManager;
proxiedTokensManager = pendingProxiedTokensManager;
delete pendingProxiedTokensManager;
emit AcceptProxiedTokensManagerRole(
oldProxiedTokensManager,
proxiedTokensManager
);
}
/**
* @notice Function to update the globalExitRoot if the last deposit is not submitted
*/
function updateGlobalExitRoot() external {
if (lastUpdatedDepositCount < depositCount) {
_updateGlobalExitRoot();
}
}
/**
* @notice Function to update the globalExitRoot
*/
function _updateGlobalExitRoot() internal {
lastUpdatedDepositCount = uint32(depositCount);
globalExitRootManager.updateExitRoot(getRoot());
}
/**
* @notice Burn tokens from wrapped token to execute the bridge
* note This function has been extracted to be able to override it by other contracts like Bridge2SovereignChain
* @param tokenWrapped Wrapped token to burnt
* @param amount Amount of tokens
* @return Amount of tokens that must be added to the leaf after the bridge operation
*/
function _bridgeWrappedAsset(
ITokenWrappedBridgeUpgradeable tokenWrapped,
uint256 amount
) internal virtual returns (uint256) {
// Burn tokens
tokenWrapped.burn(msg.sender, amount);
return amount;
}
/**
* @notice Mints tokens from wrapped token to proceed with the claim
* note This function has been extracted to be able to override it by other contracts like Bridge2SovereignChain
* @param tokenWrapped Proxied Wrapped token to mint
* @param destinationAddress Minted token receiver
* @param amount Amount of tokens
*/
function _claimWrappedAsset(
ITokenWrappedBridgeUpgradeable tokenWrapped,
address destinationAddress,
uint256 amount
) internal virtual {
// Mint tokens
tokenWrapped.mint(destinationAddress, amount);
}
/**
* @notice Function decode an index into a wordPos and bitPos
* @param index Index
*/
function _bitmapPositions(
uint256 index
) internal pure returns (uint256 wordPos, uint256 bitPos) {
wordPos = uint248(index >> 8);
bitPos = uint8(index);
}
/**
* @notice Function to call token permit method of extended ERC20
+ @param token ERC20 token address
* @param permitData Raw data of the call `permit` of the token
*/
function _permit(address token, bytes calldata permitData) internal {
bytes4 sig = bytes4(permitData[:4]);
if (sig == _PERMIT_SIGNATURE) {
(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) = abi.decode(
permitData[4:],
(
address,
address,
uint256,
uint256,
uint8,
bytes32,
bytes32
)
);
if (owner != msg.sender) {
revert NotValidOwner();
}
if (spender != address(this)) {
revert NotValidSpender();
}
/// @dev To be more aligned with the latest OpenZeppelin ERC20 implementation where ERC20 tokens allow approvals of uint.max and it is widely adopted by DeFi,
/// this check has been removed. Important to warn that removing it is not the most secure approach but has been applied because it is widely used and reduce friction and gas cost
// if (value != amount) {
// revert NotValidAmount();
// }
// we call without checking the result, in case it fails and he doesn't have enough balance
// the following transferFrom should be fail. This prevents DoS attacks from using a signature
// before the smart contract call
/* solhint-disable avoid-low-level-calls */
address(token).call(
abi.encodeWithSelector(
_PERMIT_SIGNATURE,
owner,
spender,
value,
deadline,
v,
r,
s
)
);
} else {
if (sig != _PERMIT_SIGNATURE_DAI) {
revert NotValidSignature();
}
(
address holder,
address spender,
uint256 nonce,
uint256 expiry,
bool allowed,
uint8 v,
bytes32 r,
bytes32 s
) = abi.decode(
permitData[4:],
(
address,
address,
uint256,
uint256,
bool,
uint8,
bytes32,
bytes32
)
);
if (holder != msg.sender) {
revert NotValidOwner();
}
if (spender != address(this)) {
revert NotValidSpender();
}
// we call without checking the result, in case it fails and he doesn't have enough balance
// the following transferFrom should be fail. This prevents DoS attacks from using a signature
// before the smart contract call
/* solhint-disable avoid-low-level-calls */
address(token).call(
abi.encodeWithSelector(
_PERMIT_SIGNATURE_DAI,
holder,
spender,
nonce,
expiry,
allowed,
v,
r,
s
)
);
}
}
/**
* @notice Internal function that uses create2 to deploy the upgradable wrapped tokens
* @param salt Salt used in create2 params,
* tokenInfoHash will be used as salt for all wrapped except for bridge native WETH, that will be bytes32(0)
* @param initializationArgs Encoded constructor args for the wrapped token
*/
function _deployWrappedToken(
bytes32 salt,
bytes memory initializationArgs
) internal returns (ITokenWrappedBridgeUpgradeable newWrappedTokenProxy) {
/// @dev A bytecode stored on chain is used to deploy the proxy in a way that ALWAYS it's used the same
/// bytecode, therefore the proxy addresses are the same in all chains as they are deployed deterministically with same init bytecode
/// @dev there is no constructor args as the implementation address + owner of the proxied are set at constructor level and taken from the bridge itself
bytes memory proxyInitBytecode = abi.encodePacked(
INIT_BYTECODE_TRANSPARENT_PROXY()
);
// Deploy wrapped token proxy
/// @solidity memory-safe-assembly
assembly {
newWrappedTokenProxy := create2(
0,
add(proxyInitBytecode, 0x20),
mload(proxyInitBytecode),
salt
)
}
if (address(newWrappedTokenProxy) == address(0))
revert FailedProxyDeployment();
// Initialize the wrapped token
(string memory name, string memory symbol, uint8 decimals) = abi.decode(
initializationArgs,
(string, string, uint8)
);
ITokenWrappedBridgeUpgradeable(address(newWrappedTokenProxy))
.initialize(name, symbol, decimals);
}
/**
* @notice Returns internal proxiedTokensManager address
*/
function getProxiedTokensManager() external view returns (address) {
return proxiedTokensManager;
}
/// @notice This function is used to get the implementation address of the wrapped token bridge
function getWrappedTokenBridgeImplementation()
external
view
returns (address)
{
return wrappedTokenBridgeImplementation;
}
// Helpers to safely get the metadata from a token, inspired by https://github.com/traderjoe-xyz/joe-core/blob/main/contracts/MasterChefJoeV3.sol#L55-L95
/**
* @notice Provides a safe ERC20.symbol version which returns 'NO_SYMBOL' as fallback string
* @param token The address of the ERC-20 token contract
*/
function _safeSymbol(address token) internal view returns (string memory) {
(bool success, bytes memory data) = address(token).staticcall(
abi.encodeCall(IERC20Metadata.symbol, ())
);
return success ? _returnDataToString(data) : "NO_SYMBOL";
}
/**
* @notice Provides a safe ERC20.name version which returns 'NO_NAME' as fallback string.
* @param token The address of the ERC-20 token contract.
*/
function _safeName(address token) internal view returns (string memory) {
(bool success, bytes memory data) = address(token).staticcall(
abi.encodeCall(IERC20Metadata.name, ())
);
return success ? _returnDataToString(data) : "NO_NAME";
}
/**
* @notice Provides a safe ERC20.decimals version which returns '18' as fallback value.
* Note Tokens with (decimals > 255) are not supported
* @param token The address of the ERC-20 token contract
*/
function _safeDecimals(address token) internal view returns (uint8) {
(bool success, bytes memory data) = address(token).staticcall(
abi.encodeCall(IERC20Metadata.decimals, ())
);
return success && data.length == 32 ? abi.decode(data, (uint8)) : 18;
}
/**
* @notice Function to convert returned data to string
* returns 'NOT_VALID_ENCODING' as fallback value.
* @param data returned data
*/
function _returnDataToString(
bytes memory data
) internal pure returns (string memory) {
if (data.length >= 64) {
return abi.decode(data, (string));
} else if (data.length == 32) {
// Since the strings on bytes32 are encoded left-right, check the first zero in the data
uint256 nonZeroBytes;
while (nonZeroBytes < 32 && data[nonZeroBytes] != 0) {
nonZeroBytes++;
}
// If the first one is 0, we do not handle the encoding
if (nonZeroBytes == 0) {
return "NOT_VALID_ENCODING";
}
// Create a byte array with nonZeroBytes length
bytes memory bytesArray = new bytes(nonZeroBytes);
for (uint256 i = 0; i < nonZeroBytes; i++) {
bytesArray[i] = data[i];
}
return string(bytesArray);
} else {
return "NOT_VALID_ENCODING";
}
}
////////////////////////////////
//// View functions /////
///////////////////////////////
/**
* @notice Returns the encoded token metadata
* @param token Address of the token
*/
function getTokenMetadata(
address token
) public view returns (bytes memory) {
return
abi.encode(
_safeName(token),
_safeSymbol(token),
_safeDecimals(token)
);
}
/**
* @notice Returns the INIT_BYTECODE_TRANSPARENT_PROXY from the BytecodeStorer
* @dev BytecodeStorer is a contract that contains PolygonTransparentProxy as constant, it has done this way to have more bytecode available.
* Using the on chain bytecode, we assure that transparent proxy is always deployed with the exact same bytecode, necessary to have all deployed wrapped token
* with the same address on all the chains.
*/
function INIT_BYTECODE_TRANSPARENT_PROXY()
public
view
returns (bytes memory)
{
return
IBytecodeStorer(wrappedTokenBytecodeStorer)
.INIT_BYTECODE_TRANSPARENT_PROXY();
}
/**
* @notice Returns the precalculated address of a upgradeable wrapped token using the token information
* @param originNetwork Origin network
* @param originTokenAddress Origin token address, address of the token at the origin network.
*/
function computeTokenProxyAddress(
uint32 originNetwork,
address originTokenAddress
) public view returns (address) {
bytes32 salt = keccak256(
abi.encodePacked(originNetwork, originTokenAddress)
);
bytes32 hashCreate2 = keccak256(
abi.encodePacked(
bytes1(0xff),
address(this),
salt,
keccak256(abi.encodePacked(INIT_BYTECODE_TRANSPARENT_PROXY()))
)
);
// Last 20 bytes of hash to address
return address(uint160(uint256(hashCreate2)));
}
}{
"optimizer": {
"enabled": true,
"runs": 500
},
"evmVersion": "shanghai",
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"libraries": {}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"target","type":"address"}],"name":"AddressEmptyCode","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"AddressInsufficientBalance","type":"error"},{"inputs":[],"name":"AlreadyClaimed","type":"error"},{"inputs":[],"name":"AmountDoesNotMatchMsgValue","type":"error"},{"inputs":[],"name":"BridgeAddressNotAllowed","type":"error"},{"inputs":[],"name":"ClaimNotSet","type":"error"},{"inputs":[],"name":"DestinationNetworkInvalid","type":"error"},{"inputs":[],"name":"EmergencyStateNotAllowed","type":"error"},{"inputs":[],"name":"EtherTransferFailed","type":"error"},{"inputs":[],"name":"FailedInnerCall","type":"error"},{"inputs":[],"name":"FailedProxyDeployment","type":"error"},{"inputs":[],"name":"GasTokenNetworkMustBeZeroOnEther","type":"error"},{"inputs":[],"name":"GlobalExitRootInvalid","type":"error"},{"inputs":[],"name":"InputArraysLengthMismatch","type":"error"},{"inputs":[],"name":"InvalidGlobalIndex","type":"error"},{"inputs":[],"name":"InvalidInitializeFunction","type":"error"},{"inputs":[{"internalType":"address","name":"proxyAdmin","type":"address"}],"name":"InvalidProxyAdmin","type":"error"},{"inputs":[],"name":"InvalidSmtProof","type":"error"},{"inputs":[],"name":"InvalidSovereignWETHAddressParams","type":"error"},{"inputs":[],"name":"InvalidZeroAddress","type":"error"},{"inputs":[],"name":"InvalidZeroNetworkID","type":"error"},{"inputs":[{"internalType":"address","name":"proxyAdmin","type":"address"}],"name":"InvalidZeroProxyAdminOwner","type":"error"},{"inputs":[{"internalType":"uint32","name":"originNetwork","type":"uint32"},{"internalType":"address","name":"originTokenAddress","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"localBalanceTreeAmount","type":"uint256"}],"name":"LocalBalanceTreeOverflow","type":"error"},{"inputs":[{"internalType":"uint32","name":"originNetwork","type":"uint32"},{"internalType":"address","name":"originTokenAddress","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"localBalanceTreeAmount","type":"uint256"}],"name":"LocalBalanceTreeUnderflow","type":"error"},{"inputs":[],"name":"MerkleTreeFull","type":"error"},{"inputs":[],"name":"MessageFailed","type":"error"},{"inputs":[],"name":"MsgValueNotZero","type":"error"},{"inputs":[],"name":"NativeTokenIsEther","type":"error"},{"inputs":[],"name":"NoValueInMessagesOnGasTokenNetworks","type":"error"},{"inputs":[],"name":"NotValidAmount","type":"error"},{"inputs":[],"name":"NotValidOwner","type":"error"},{"inputs":[],"name":"NotValidSignature","type":"error"},{"inputs":[],"name":"NotValidSpender","type":"error"},{"inputs":[],"name":"OnlyBridgeManager","type":"error"},{"inputs":[],"name":"OnlyEmergencyBridgePauser","type":"error"},{"inputs":[],"name":"OnlyEmergencyBridgeUnpauser","type":"error"},{"inputs":[],"name":"OnlyEmergencyState","type":"error"},{"inputs":[],"name":"OnlyGlobalExitRootRemover","type":"error"},{"inputs":[],"name":"OnlyNotEmergencyState","type":"error"},{"inputs":[],"name":"OnlyPendingEmergencyBridgePauser","type":"error"},{"inputs":[],"name":"OnlyPendingEmergencyBridgeUnpauser","type":"error"},{"inputs":[],"name":"OnlyPendingProxiedTokensManager","type":"error"},{"inputs":[],"name":"OnlyProxiedTokensManager","type":"error"},{"inputs":[],"name":"OnlyRollupManager","type":"error"},{"inputs":[],"name":"OriginNetworkInvalid","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"inputs":[],"name":"TokenAlreadyMapped","type":"error"},{"inputs":[],"name":"TokenAlreadyUpdated","type":"error"},{"inputs":[],"name":"TokenNotMapped","type":"error"},{"inputs":[],"name":"TokenNotRemapped","type":"error"},{"inputs":[],"name":"WETHRemappingNotSupportedOnGasTokenNetworks","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldEmergencyBridgePauser","type":"address"},{"indexed":false,"internalType":"address","name":"newEmergencyBridgePauser","type":"address"}],"name":"AcceptEmergencyBridgePauserRole","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldEmergencyBridgeUnpauser","type":"address"},{"indexed":false,"internalType":"address","name":"newEmergencyBridgeUnpauser","type":"address"}],"name":"AcceptEmergencyBridgeUnpauserRole","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldProxiedTokensManager","type":"address"},{"indexed":false,"internalType":"address","name":"newProxiedTokensManager","type":"address"}],"name":"AcceptProxiedTokensManagerRole","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"leafType","type":"uint8"},{"indexed":false,"internalType":"uint32","name":"originNetwork","type":"uint32"},{"indexed":false,"internalType":"address","name":"originAddress","type":"address"},{"indexed":false,"internalType":"uint32","name":"destinationNetwork","type":"uint32"},{"indexed":false,"internalType":"address","name":"destinationAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"metadata","type":"bytes"},{"indexed":false,"internalType":"uint32","name":"depositCount","type":"uint32"}],"name":"BridgeEvent","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"globalIndex","type":"uint256"},{"indexed":false,"internalType":"uint32","name":"originNetwork","type":"uint32"},{"indexed":false,"internalType":"address","name":"originAddress","type":"address"},{"indexed":false,"internalType":"address","name":"destinationAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"ClaimEvent","type":"event"},{"anonymous":false,"inputs":[],"name":"EmergencyStateActivated","type":"event"},{"anonymous":false,"inputs":[],"name":"EmergencyStateDeactivated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"address","name":"legacyTokenAddress","type":"address"},{"indexed":false,"internalType":"address","name":"updatedTokenAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"MigrateLegacyToken","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint32","name":"originNetwork","type":"uint32"},{"indexed":false,"internalType":"address","name":"originTokenAddress","type":"address"},{"indexed":false,"internalType":"address","name":"wrappedTokenAddress","type":"address"},{"indexed":false,"internalType":"bytes","name":"metadata","type":"bytes"}],"name":"NewWrappedToken","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"sovereignTokenAddress","type":"address"}],"name":"RemoveLegacySovereignTokenAddress","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"bridgeManager","type":"address"}],"name":"SetBridgeManager","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint32","name":"originNetwork","type":"uint32"},{"indexed":false,"internalType":"address","name":"originTokenAddress","type":"address"},{"indexed":false,"internalType":"address","name":"sovereignTokenAddress","type":"address"},{"indexed":false,"internalType":"bool","name":"isNotMintable","type":"bool"}],"name":"SetSovereignTokenAddress","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"sovereignWETHTokenAddress","type":"address"},{"indexed":false,"internalType":"bool","name":"isNotMintable","type":"bool"}],"name":"SetSovereignWETHAddress","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"currentEmergencyBridgePauser","type":"address"},{"indexed":false,"internalType":"address","name":"newEmergencyBridgePauser","type":"address"}],"name":"TransferEmergencyBridgePauserRole","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"currentEmergencyBridgeUnpauser","type":"address"},{"indexed":false,"internalType":"address","name":"newEmergencyBridgeUnpauser","type":"address"}],"name":"TransferEmergencyBridgeUnpauserRole","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"currentProxiedTokensManager","type":"address"},{"indexed":false,"internalType":"address","name":"newProxiedTokensManager","type":"address"}],"name":"TransferProxiedTokensManagerRole","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"claimedGlobalIndex","type":"bytes32"},{"indexed":false,"internalType":"bytes32","name":"newClaimedGlobalIndexHashChain","type":"bytes32"}],"name":"UpdatedClaimedGlobalIndexHashChain","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"unsetGlobalIndex","type":"bytes32"},{"indexed":false,"internalType":"bytes32","name":"newUnsetGlobalIndexHashChain","type":"bytes32"}],"name":"UpdatedUnsetGlobalIndexHashChain","type":"event"},{"inputs":[],"name":"BRIDGE_SOVEREIGN_VERSION","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"BRIDGE_VERSION","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"INIT_BYTECODE_TRANSPARENT_PROXY","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"WETHToken","outputs":[{"internalType":"contract ITokenWrappedBridgeUpgradeable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"acceptEmergencyBridgePauserRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"acceptEmergencyBridgeUnpauserRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"acceptProxiedTokensManagerRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"activateEmergencyState","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"destinationNetwork","type":"uint32"},{"internalType":"address","name":"destinationAddress","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"token","type":"address"},{"internalType":"bool","name":"forceUpdateGlobalExitRoot","type":"bool"},{"internalType":"bytes","name":"permitData","type":"bytes"}],"name":"bridgeAsset","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"bridgeManager","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"destinationNetwork","type":"uint32"},{"internalType":"address","name":"destinationAddress","type":"address"},{"internalType":"bool","name":"forceUpdateGlobalExitRoot","type":"bool"},{"internalType":"bytes","name":"metadata","type":"bytes"}],"name":"bridgeMessage","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint32","name":"destinationNetwork","type":"uint32"},{"internalType":"address","name":"destinationAddress","type":"address"},{"internalType":"uint256","name":"amountWETH","type":"uint256"},{"internalType":"bool","name":"forceUpdateGlobalExitRoot","type":"bool"},{"internalType":"bytes","name":"metadata","type":"bytes"}],"name":"bridgeMessageWETH","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"leafHash","type":"bytes32"},{"internalType":"bytes32[32]","name":"smtProof","type":"bytes32[32]"},{"internalType":"uint32","name":"index","type":"uint32"}],"name":"calculateRoot","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bytes32[32]","name":"smtProofLocalExitRoot","type":"bytes32[32]"},{"internalType":"bytes32[32]","name":"smtProofRollupExitRoot","type":"bytes32[32]"},{"internalType":"uint256","name":"globalIndex","type":"uint256"},{"internalType":"bytes32","name":"mainnetExitRoot","type":"bytes32"},{"internalType":"bytes32","name":"rollupExitRoot","type":"bytes32"},{"internalType":"uint32","name":"originNetwork","type":"uint32"},{"internalType":"address","name":"originTokenAddress","type":"address"},{"internalType":"uint32","name":"destinationNetwork","type":"uint32"},{"internalType":"address","name":"destinationAddress","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"metadata","type":"bytes"}],"name":"claimAsset","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32[32]","name":"smtProofLocalExitRoot","type":"bytes32[32]"},{"internalType":"bytes32[32]","name":"smtProofRollupExitRoot","type":"bytes32[32]"},{"internalType":"uint256","name":"globalIndex","type":"uint256"},{"internalType":"bytes32","name":"mainnetExitRoot","type":"bytes32"},{"internalType":"bytes32","name":"rollupExitRoot","type":"bytes32"},{"internalType":"uint32","name":"originNetwork","type":"uint32"},{"internalType":"address","name":"originAddress","type":"address"},{"internalType":"uint32","name":"destinationNetwork","type":"uint32"},{"internalType":"address","name":"destinationAddress","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"metadata","type":"bytes"}],"name":"claimMessage","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"claimedBitMap","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"claimedGlobalIndexHashChain","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"originNetwork","type":"uint32"},{"internalType":"address","name":"originTokenAddress","type":"address"}],"name":"computeTokenProxyAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"deactivateEmergencyState","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"originNetwork","type":"uint32"},{"internalType":"address","name":"originTokenAddress","type":"address"},{"internalType":"bool","name":"isNotMintable","type":"bool"}],"name":"deployWrappedTokenAndRemap","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"depositCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"emergencyBridgePauser","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"emergencyBridgeUnpauser","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"gasTokenAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"gasTokenMetadata","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"gasTokenNetwork","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint8","name":"leafType","type":"uint8"},{"internalType":"uint32","name":"originNetwork","type":"uint32"},{"internalType":"address","name":"originAddress","type":"address"},{"internalType":"uint32","name":"destinationNetwork","type":"uint32"},{"internalType":"address","name":"destinationAddress","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes32","name":"metadataHash","type":"bytes32"}],"name":"getLeafValue","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"getProxiedTokensManager","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getRoot","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"getTokenMetadata","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"originNetwork","type":"uint32"},{"internalType":"address","name":"originTokenAddress","type":"address"}],"name":"getTokenWrappedAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getWrappedTokenBridgeImplementation","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"globalExitRootManager","outputs":[{"internalType":"contract IBasePolygonZkEVMGlobalExitRoot","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"_networkID","type":"uint32"},{"internalType":"address","name":"_gasTokenAddress","type":"address"},{"internalType":"uint32","name":"_gasTokenNetwork","type":"uint32"},{"internalType":"contract IBasePolygonZkEVMGlobalExitRoot","name":"_globalExitRootManager","type":"address"},{"internalType":"address","name":"_polygonRollupManager","type":"address"},{"internalType":"bytes","name":"_gasTokenMetadata","type":"bytes"},{"internalType":"address","name":"_bridgeManager","type":"address"},{"internalType":"address","name":"_sovereignWETHAddress","type":"address"},{"internalType":"bool","name":"_sovereignWETHAddressIsNotMintable","type":"bool"},{"internalType":"address","name":"_emergencyBridgePauser","type":"address"},{"internalType":"address","name":"_emergencyBridgeUnpauser","type":"address"},{"internalType":"address","name":"_proxiedTokensManager","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"initialize","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint32","name":"","type":"uint32"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint32","name":"","type":"uint32"},{"internalType":"contract IBasePolygonZkEVMGlobalExitRoot","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"leafIndex","type":"uint32"},{"internalType":"uint32","name":"sourceBridgeNetwork","type":"uint32"}],"name":"isClaimed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isEmergencyState","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastUpdatedDepositCount","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"tokenInfoHash","type":"bytes32"}],"name":"localBalanceTree","outputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"legacyTokenAddress","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"permitData","type":"bytes"}],"name":"migrateLegacyToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"networkID","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingEmergencyBridgePauser","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingEmergencyBridgeUnpauser","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingProxiedTokensManager","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"polygonRollupManager","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"proxiedTokensManager","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"legacySovereignTokenAddress","type":"address"}],"name":"removeLegacySovereignTokenAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_bridgeManager","type":"address"}],"name":"setBridgeManager","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32[]","name":"originNetworks","type":"uint32[]"},{"internalType":"address[]","name":"originTokenAddresses","type":"address[]"},{"internalType":"address[]","name":"sovereignTokenAddresses","type":"address[]"},{"internalType":"bool[]","name":"isNotMintable","type":"bool[]"}],"name":"setMultipleSovereignTokenAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sovereignWETHTokenAddress","type":"address"},{"internalType":"bool","name":"isNotMintable","type":"bool"}],"name":"setSovereignWETHAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"tokenInfoToWrappedToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newEmergencyBridgePauser","type":"address"}],"name":"transferEmergencyBridgePauserRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newEmergencyBridgeUnpauser","type":"address"}],"name":"transferEmergencyBridgeUnpauserRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newProxiedTokensManager","type":"address"}],"name":"transferProxiedTokensManagerRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unsetGlobalIndexHashChain","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"globalIndexes","type":"uint256[]"}],"name":"unsetMultipleClaims","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"updateGlobalExitRoot","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"leafHash","type":"bytes32"},{"internalType":"bytes32[32]","name":"smtProof","type":"bytes32[32]"},{"internalType":"uint32","name":"index","type":"uint32"},{"internalType":"bytes32","name":"root","type":"bytes32"}],"name":"verifyMerkleProof","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"wrappedAddress","type":"address"}],"name":"wrappedAddressIsNotMintable","outputs":[{"internalType":"bool","name":"isNotMintable","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"wrappedTokenBytecodeStorer","outputs":[{"internalType":"contract IBytecodeStorer","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"wrappedTokenToTokenInfo","outputs":[{"internalType":"uint32","name":"originNetwork","type":"uint32"},{"internalType":"address","name":"originTokenAddress","type":"address"}],"stateMutability":"view","type":"function"}]Contract Creation Code
60c060405234801561000f575f5ffd5b5060405161001c90610146565b604051809103905ff080158015610035573d5f5f3e3d5ffd5b506001600160a01b031660805260405161004e90610153565b604051809103905ff080158015610067573d5f5f3e3d5ffd5b506001600160a01b031660a05261007c610089565b610084610089565b610160565b5f54610100900460ff16156100f45760405162461bcd60e51b815260206004820152602760248201527f496e697469616c697a61626c653a20636f6e747261637420697320696e697469604482015266616c697a696e6760c81b606482015260840160405180910390fd5b5f5460ff9081161015610144575f805460ff191660ff9081179091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b565b610fcf80615a0783390190565b611714806169d683390190565b60805160a05161587f6101885f395f6105ed01525f81816105a00152612031015261587f5ff3fe60806040526004361061039c575f3560e01c806383f24403116101de578063c514f24e11610108578063eabd372a1161009d578063f5efcd791161006d578063f5efcd7914610b32578063f67566e414610b51578063f811bff714610b83578063fb57083414610ba2575f5ffd5b8063eabd372a14610aaa578063ece93c6f14610ac9578063ee25560b14610ae8578063f214e16114610b13575f5ffd5b8063d02103ca116100d8578063d02103ca14610a2f578063d9cb3aec14610a57578063dbc1697614610a82578063e88f043614610a96575f5ffd5b8063c514f24e146109ca578063cc461632146109de578063ccaa2d11146109fd578063cd58657914610a1c575f5ffd5b8063b0b379201161017e578063be5831c71161014e578063be5831c71461093b578063bf130d7f1461095e578063c00f14ab1461097d578063c0f491631461099c575f5ffd5b8063b0b37920146108bd578063b4586962146108dc578063b8b284d0146108fb578063bab161bf1461091a575f5ffd5b80638c668f1c116101b95780638c668f1c1461084c5780638d942096146108605780638ed7e3f21461087f578063ae24490a1461089e575f5ffd5b806383f24403146107fa5780638b37b873146108195780638bd309c31461082d575f5ffd5b80633b2fee9a116102ca57806365d6f6541161025f5780636ee84b231161022f5780636ee84b231461078957806379e2cf971461079e5780638129fc1c146107b257806381b1c174146107c6575f5ffd5b806365d6f654146106f857806369e3ab121461072c5780636e4ecfed1461074b5780636e974cd41461076a575f5ffd5b80634b2f336d1161029a5780634b2f336d1461068757806357cfbee3146106a65780635ca1e165146106c5578063606617ff146106d9575f5ffd5b80633b2fee9a146105df5780633c351e10146106115780633cbc795b146106305780633e19704314610668575f5ffd5b806322e95f2c116103405780632f84c690116103105780632f84c69014610508578063318aee3d14610527578063381fef6d1461058f57806338b8fbbb146105c2575f5ffd5b806322e95f2c146104a0578063240ff378146104bf57806327aef4e8146104d25780632dfdf0b5146104f3575f5ffd5b806314cc01a01161037b57806314cc01a01461042157806315064c96146104405780631d081d8c146104695780632072f6c51461048c575f5ffd5b80626ee171146103a057806303e6e116146103c1578063136a2c6014610402575b5f5ffd5b3480156103ab575f5ffd5b506103bf6103ba366004614704565b610bc1565b005b3480156103cc575f5ffd5b5060a8546103e59061010090046001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b34801561040d575f5ffd5b506103bf61041c366004614818565b6110c1565b34801561042c575f5ffd5b5060a3546103e5906001600160a01b031681565b34801561044b575f5ffd5b506068546104599060ff1681565b60405190151581526020016103f9565b348015610474575f5ffd5b5061047e60a55481565b6040519081526020016103f9565b348015610497575f5ffd5b506103bf61121f565b3480156104ab575f5ffd5b506103e56104ba36600461489f565b611254565b6103bf6104cd366004614919565b6112a2565b3480156104dd575f5ffd5b506104e6611312565b6040516103f991906149db565b3480156104fe575f5ffd5b5061047e60535481565b348015610513575f5ffd5b5060a4546103e5906001600160a01b031681565b348015610532575f5ffd5b5061056b6105413660046149ed565b606b6020525f908152604090205463ffffffff81169064010000000090046001600160a01b031682565b6040805163ffffffff90931683526001600160a01b039091166020830152016103f9565b34801561059a575f5ffd5b506103e57f000000000000000000000000000000000000000000000000000000000000000081565b3480156105cd575f5ffd5b506070546001600160a01b03166103e5565b3480156105ea575f5ffd5b507f00000000000000000000000000000000000000000000000000000000000000006103e5565b34801561061c575f5ffd5b50606d546103e5906001600160a01b031681565b34801561063b575f5ffd5b50606d5461065390600160a01b900463ffffffff1681565b60405163ffffffff90911681526020016103f9565b348015610673575f5ffd5b5061047e610682366004614a16565b61139e565b348015610692575f5ffd5b50606f546103e5906001600160a01b031681565b3480156106b1575f5ffd5b506103bf6106c0366004614b62565b61142f565b3480156106d0575f5ffd5b5061047e61151b565b3480156106e4575f5ffd5b5060aa546103e5906001600160a01b031681565b348015610703575f5ffd5b506104e660405180604001604052806009815260200168616c2d76302e332e3160b81b81525081565b348015610737575f5ffd5b506103bf6107463660046149ed565b61159a565b348015610756575f5ffd5b506070546103e5906001600160a01b031681565b348015610775575f5ffd5b506103bf610784366004614c79565b61163d565b348015610794575f5ffd5b5061047e60a65481565b3480156107a9575f5ffd5b506103bf611991565b3480156107bd575f5ffd5b506103bf6119b2565b3480156107d1575f5ffd5b506103e56107e0366004614cbf565b606a6020525f90815260409020546001600160a01b031681565b348015610805575f5ffd5b5061047e610814366004614ce7565b6119cb565b348015610824575f5ffd5b506103bf611a5a565b348015610838575f5ffd5b506103bf6108473660046149ed565b611aeb565b348015610857575f5ffd5b506103bf611b72565b34801561086b575f5ffd5b506103bf61087a3660046149ed565b611c03565b34801561088a575f5ffd5b50606c546103e5906001600160a01b031681565b3480156108a9575f5ffd5b5060a9546103e5906001600160a01b031681565b3480156108c8575f5ffd5b506103bf6108d7366004614d23565b611c8a565b3480156108e7575f5ffd5b506103bf6108f63660046149ed565b611dda565b348015610906575f5ffd5b506103bf610915366004614d7b565b611f35565b348015610925575f5ffd5b5060685461065390610100900463ffffffff1681565b348015610946575f5ffd5b5060685461065390600160c81b900463ffffffff1681565b348015610969575f5ffd5b506103bf610978366004614df9565b611fb3565b348015610988575f5ffd5b506104e66109973660046149ed565b611fe8565b3480156109a7575f5ffd5b506104596109b63660046149ed565b60a26020525f908152604090205460ff1681565b3480156109d5575f5ffd5b506104e661202d565b3480156109e9575f5ffd5b506104596109f8366004614e25565b6120b6565b348015610a08575f5ffd5b506103bf610a17366004614e56565b612107565b6103bf610a2a366004614f35565b612523565b348015610a3a575f5ffd5b506068546103e5906501000000000090046001600160a01b031681565b348015610a62575f5ffd5b5061047e610a71366004614cbf565b60a76020525f908152604090205481565b348015610a8d575f5ffd5b506103bf6128bf565b348015610aa1575f5ffd5b506103bf6128f2565b348015610ab5575f5ffd5b506103bf610ac43660046149ed565b6129a1565b348015610ad4575f5ffd5b506071546103e5906001600160a01b031681565b348015610af3575f5ffd5b5061047e610b02366004614cbf565b60696020525f908152604090205481565b348015610b1e575f5ffd5b506103e5610b2d36600461489f565b612a41565b348015610b3d575f5ffd5b506103bf610b4c366004614e56565b612b0c565b348015610b5c575f5ffd5b506104e6604051806040016040528060078152602001663b18981718971960c91b81525081565b348015610b8e575f5ffd5b506103bf610b9d366004614fc5565b612d6c565b348015610bad575f5ffd5b50610459610bbc366004615055565b612e3f565b5f54600390610100900460ff16158015610be157505f5460ff8083169116105b610c495760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084015b60405180910390fd5b5f805461ffff191660ff8316176101001790556001600160a01b038a16610c835760405163f6b2911f60e01b815260040160405180910390fd5b8c63ffffffff165f03610ca957604051634e702fa560e01b815260040160405180910390fd5b8c606860016101000a81548163ffffffff021916908363ffffffff16021790555089606860056101000a8154816001600160a01b0302191690836001600160a01b0316021790555088606c5f6101000a8154816001600160a01b0302191690836001600160a01b031602179055508660a35f6101000a8154816001600160a01b0302191690836001600160a01b031602179055508360a45f6101000a8154816001600160a01b0302191690836001600160a01b031602179055507f85d2bdfbe58cd81abf8199c13ce2509204be4aba8603b9d29f52c4e13e7bb7935f60a45f9054906101000a90046001600160a01b0316604051610dbd9291906001600160a01b0392831681529116602082015260400190565b60405180910390a160a980546001600160a01b0319166001600160a01b038516908117909155604080515f815260208101929092527f24cc8295aa5110cc216695db944ad2458c7795c6404449be980c3ce14aed752d910160405180910390a1306001600160a01b03831603610e4657604051631ae0e03360e01b815260040160405180910390fd5b6001600160a01b038216610e6d5760405163f6b2911f60e01b815260040160405180910390fd5b607080546001600160a01b0319166001600160a01b038416908117909155604080515f815260208101929092527fa9da6fb8c39e9c2fafda878eac316815987bdc948d241ba6d75ed035e0e829f2910160405180910390a16001600160a01b038c16610f2f5763ffffffff8b1615610ef857604051630d43a60960e11b815260040160405180910390fd5b6001600160a01b038616151580610f0c5750845b15610f2a57604051630e6e237560e11b815260040160405180910390fd5b61106a565b606d805463ffffffff8d16600160a01b026001600160c01b03199091166001600160a01b038f1617179055606e610f668982615116565b506001600160a01b03861661103257841515600103610f9857604051630e6e237560e11b815260040160405180910390fd5b61100d5f5f1b6012604051602001610ff991906060808252600d908201526c2bb930b83832b21022ba3432b960991b608082015260a060208201819052600490820152630ae8aa8960e31b60c082015260ff91909116604082015260e00190565b604051602081830303815290604052612e56565b606f80546001600160a01b0319166001600160a01b039290921691909117905561106a565b606f80546001600160a01b0319166001600160a01b0388169081179091555f90815260a260205260409020805460ff19168615151790555b611072612f37565b5f805461ff001916905560405160ff821681527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a150505050505050505050505050565b606854604080516391eb796d60e01b8152905133926501000000000090046001600160a01b0316916391eb796d9160048083019260209291908290030181865afa158015611111573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061113591906151d1565b6001600160a01b03161461115c5760405163a34ddeb160e01b815260040160405180910390fd5b5f5b815181101561121b575f82828151811061117a5761117a6151ec565b602002602001015190505f5f6801000000000000000083165f146111a0578291506111b7565b602083901c6111b0816001615214565b9150839250505b6111c18282612fa9565b60a6545f90815260208490526040902060a68190556040805185815260208101929092527fc80e0aca446a59735359a7ae46124b57c47b892827642779bc6dafc84ba90b03910160405180910390a150505060010161115e565b5050565b60a4546001600160a01b0316331461124a57604051631344c5df60e11b815260040160405180910390fd5b61125261301b565b565b5f606a5f848460405160200161126b929190615230565b60408051601f198184030181529181528151602092830120835290820192909252015f20546001600160a01b031690505b92915050565b60685460ff16156112c657604051630bc011ff60e21b815260040160405180910390fd5b34158015906112df5750606f546001600160a01b031615155b156112fd576040516301bd897160e61b815260040160405180910390fd5b61130b858534868686613076565b5050505050565b606e805461131f9061509a565b80601f016020809104026020016040519081016040528092919081815260200182805461134b9061509a565b80156113965780601f1061136d57610100808354040283529160200191611396565b820191905f5260205f20905b81548152906001019060200180831161137957829003601f168201915b505050505081565b6040516001600160f81b031960f889901b1660208201526001600160e01b031960e088811b821660218401526bffffffffffffffffffffffff19606089811b821660258601529188901b909216603984015285901b16603d82015260518101839052607181018290525f90609101604051602081830303815290604052805190602001209050979650505050505050565b60a3546001600160a01b0316331461145a576040516357b738d160e11b815260040160405180910390fd5b8251845114158061146d57508151845114155b8061147a57508051845114155b156114985760405163434f49f560e11b815260040160405180910390fd5b5f5b825181101561130b576115138582815181106114b8576114b86151ec565b60200260200101518583815181106114d2576114d26151ec565b60200260200101518584815181106114ec576114ec6151ec565b6020026020010151858581518110611506576115066151ec565b602002602001015161314a565b60010161149a565b6053545f90819081805b6020811015611591578083901c60011660010361156a5761156360338260208110611552576115526151ec565b0154855f9182526020526040902090565b935061157a565b5f84815260208390526040902093505b5f8281526020839052604090209150600101611525565b50919392505050565b60a4546001600160a01b031633146115c557604051631344c5df60e11b815260040160405180910390fd5b60a8805474ffffffffffffffffffffffffffffffffffffffff0019166101006001600160a01b038481169182029290921790925560a4546040805191909216815260208101929092527fb27de219766f47b82684842855ba6130b6dbf288ac66d1c3509e7bf17f4e925a91015b60405180910390a150565b60a3546001600160a01b03163314611668576040516357b738d160e11b815260040160405180910390fd5b6001600160a01b038216158015611683575063ffffffff8316155b15611813575f6118015f5f1b606f5f9054906101000a90046001600160a01b03166001600160a01b03166306fdde036040518163ffffffff1660e01b81526004015f60405180830381865afa1580156116de573d5f5f3e3d5ffd5b505050506040513d5f823e601f3d908101601f1916820160405261170591908101906152ab565b606f5f9054906101000a90046001600160a01b03166001600160a01b03166395d89b416040518163ffffffff1660e01b81526004015f60405180830381865afa158015611754573d5f5f3e3d5ffd5b505050506040513d5f823e601f3d908101601f1916820160405261177b91908101906152ab565b606f5f9054906101000a90046001600160a01b03166001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156117cb573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906117ef91906152dd565b604051602001610ff9939291906152f8565b905061180d81836132fc565b50505050565b5f8383604051602001611827929190615230565b60408051601f1981840301815291815281516020928301205f818152606a9093529120549091506001600160a01b0316806118755760405163828d566360e01b815260040160405180910390fd5b5f61197a83836001600160a01b03166306fdde036040518163ffffffff1660e01b81526004015f60405180830381865afa1580156118b5573d5f5f3e3d5ffd5b505050506040513d5f823e601f3d908101601f191682016040526118dc91908101906152ab565b846001600160a01b03166395d89b416040518163ffffffff1660e01b81526004015f60405180830381865afa158015611917573d5f5f3e3d5ffd5b505050506040513d5f823e601f3d908101601f1916820160405261193e91908101906152ab565b856001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156117cb573d5f5f3e3d5ffd5b90506119888686838761314a565b5050505b505050565b605354606854600160c81b900463ffffffff1610156112525761125261339b565b60405163f57ac68360e01b815260040160405180910390fd5b5f83815b6020811015611a4f57600163ffffffff8516821c81169003611a1b57611a14858260208110611a0057611a006151ec565b6020020135835f9182526020526040902090565b9150611a47565b611a4482868360208110611a3157611a316151ec565b60200201355f9182526020526040902090565b91505b6001016119cf565b5090505b9392505050565b60aa546001600160a01b03163314611a855760405163d491f0c160e01b815260040160405180910390fd5b60a9805460aa80546001600160a01b038082166001600160a01b0319808616821790965594909116909155604080519190921680825260208201939093527f85d2bdfbe58cd81abf8199c13ce2509204be4aba8603b9d29f52c4e13e7bb7939101611632565b6070546001600160a01b03163314611b1657604051630866750360e01b815260040160405180910390fd5b607180546001600160a01b0319166001600160a01b038381169182179092556070546040805191909316815260208101919091527f0a34baa3feb299aef9c05cb59c6e0c8e7c0bcc65cbf0a647e7a7c8a2411591e29101611632565b6071546001600160a01b03163314611b9d57604051630b59ef2760e21b815260040160405180910390fd5b60708054607180546001600160a01b038082166001600160a01b0319808616821790965594909116909155604080519190921680825260208201939093527fa9da6fb8c39e9c2fafda878eac316815987bdc948d241ba6d75ed035e0e829f29101611632565b60a9546001600160a01b03163314611c2e57604051638e9d821f60e01b815260040160405180910390fd5b60aa80546001600160a01b0319166001600160a01b0383811691821790925560a9546040805191909316815260208101919091527ff01a62a06940517bbc898dec8c75794b9feabcd2d263c8de823b36dbbeb8779b9101611632565b8015611c9b57611c9b84838361342b565b6001600160a01b038085165f908152606b602090815260409182902082518084019093525463ffffffff81168352640100000000900490921691810182905290611cf85760405163828d566360e01b815260040160405180910390fd5b5f606a5f835f01518460200151604051602001611d16929190615230565b60408051601f198184030181529181528151602092830120835290820192909252015f20546001600160a01b03908116915086168103611d695760405163e273c4a160e01b815260040160405180910390fd5b5f611d748787613745565b9050611d818233836138c4565b604080513381526001600160a01b0389811660208301528416818301526060810183905290517fb7f8fd4d1faf9b2929dc269f59c53e3a2bccc44e9950f33a568fcbcb37eb69a99181900360800190a150505050505050565b60a3546001600160a01b03163314611e05576040516357b738d160e11b815260040160405180910390fd5b6001600160a01b038082165f908152606b6020908152604080832081518083018352905463ffffffff811680835264010000000090910490951681840181905291519094611e569390929101615230565b60408051601f1981840301815291815281516020928301205f818152606a9093529120549091506001600160a01b03161580611eaa57505f818152606a60205260409020546001600160a01b038481169116145b15611ec85760405163e0c897a760e01b815260040160405180910390fd5b6001600160a01b0383165f818152606b6020908152604080832080546001600160c01b031916905560a2825291829020805460ff1916905590519182527fc2ae0bd0ec0fd0352bfe5bacac49637af342c1e40f1b80a7f74440dc7fe3f063910160405180910390a1505050565b60685460ff1615611f5957604051630bc011ff60e21b815260040160405180910390fd5b606f546001600160a01b0316611f825760405163dde3cda760e01b815260040160405180910390fd5b606f545f90611f9a906001600160a01b031686613745565b9050611faa878783878787613076565b50505050505050565b60a3546001600160a01b03163314611fde576040516357b738d160e11b815260040160405180910390fd5b61121b82826132fc565b6060611ff382613951565b611ffc83613a14565b61200584613ac8565b604051602001612017939291906152f8565b6040516020818303038152906040529050919050565b60607f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663c514f24e6040518163ffffffff1660e01b81526004015f60405180830381865afa15801561208a573d5f5f3e3d5ffd5b505050506040513d5f823e601f3d908101601f191682016040526120b19190810190615330565b905090565b5f806120cd64010000000063ffffffff8516615375565b6120dd9063ffffffff861661538c565b600881901c5f90815260696020526040902054600160ff9092169190911b90811614949350505050565b60685460ff161561212b57604051630bc011ff60e21b815260040160405180910390fd5b612133613b7c565b60685463ffffffff8681166101009092041614612163576040516302caf51760e11b815260040160405180910390fd5b61218e8c8c8c8c8c5f8d8d8d8d8d8d8d60405161218192919061539f565b6040518091039020613bd5565b604080518b815263ffffffff891660208201526001600160a01b0388811682840152861660608201526080810185905290517f1df3f2a973a00d6635911755c260704e95e8a5876997546798770f76396fda4d9181900360a00190a16001600160a01b038616158015612205575063ffffffff8716155b156122e357606f546001600160a01b03166122c7575f6001600160a01b03851684825b6040519080825280601f01601f191660200182016040528015612252576020820181803683370190505b5060405161226091906153ae565b5f6040518083038185875af1925050503d805f811461229a576040519150601f19603f3d011682016040523d82523d5f602084013e61229f565b606091505b50509050806122c157604051630ce8f45160e31b815260040160405180910390fd5b5061250c565b606f546122de906001600160a01b031685856138c4565b61250c565b606d546001600160a01b0387811691161480156123115750606d5463ffffffff888116600160a01b90920416145b15612328575f6001600160a01b0385168482612228565b60685463ffffffff610100909104811690881603612354576122de6001600160a01b0387168585613c85565b5f8787604051602001612368929190615230565b60408051601f1981840301815291815281516020928301205f818152606a9093529120549091506001600160a01b0316806124fe575f6123dd8386868080601f0160208091040260200160405190810160405280939291908181526020018383808284375f92019190915250612e5692505050565b90506123ea8188886138c4565b80606a5f8581526020019081526020015f205f6101000a8154816001600160a01b0302191690836001600160a01b0316021790555060405180604001604052808b63ffffffff1681526020018a6001600160a01b0316815250606b5f836001600160a01b03166001600160a01b031681526020019081526020015f205f820151815f015f6101000a81548163ffffffff021916908363ffffffff1602179055506020820151815f0160046101000a8154816001600160a01b0302191690836001600160a01b031602179055509050507f490e59a1701b938786ac72570a1efeac994a3dbe96e2e883e19e902ace6e6a398a8a8388886040516124f09594939291906153f1565b60405180910390a150612509565b6125098187876138c4565b50505b61251560018055565b505050505050505050505050565b60685460ff161561254757604051630bc011ff60e21b815260040160405180910390fd5b61254f613b7c565b60685463ffffffff610100909104811690881603612580576040516302caf51760e11b815260040160405180910390fd5b5f806060876001600160a01b038816612663578834146125b35760405163b89240f560e01b815260040160405180910390fd5b606d54606e80546001600160a01b0383169650600160a01b90920463ffffffff169450906125e09061509a565b80601f016020809104026020016040519081016040528092919081815260200182805461260c9061509a565b80156126575780601f1061262e57610100808354040283529160200191612657565b820191905f5260205f20905b81548152906001019060200180831161263a57829003601f168201915b50505050509150612847565b34156126825760405163798ee6f160e01b815260040160405180910390fd5b84156126935761269388878761342b565b606f546001600160a01b03908116908916036126ba576126b3888a613745565b9050612847565b6001600160a01b038089165f908152606b602090815260409182902082518084019093525463ffffffff8116835264010000000090049092169181018290529015158061270d5750805163ffffffff1615155b1561272f5761271c898b613745565b602082015182519096509450915061283a565b6040516370a0823160e01b81523060048201525f906001600160a01b038b16906370a0823190602401602060405180830381865afa158015612773573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906127979190615439565b90506127ae6001600160a01b038b1633308e613cea565b6040516370a0823160e01b81523060048201525f906001600160a01b038c16906370a0823190602401602060405180830381865afa1580156127f2573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906128169190615439565b90506128228282615450565b6068548c9850610100900463ffffffff169650935050505b61284389611fe8565b9250505b7f501781209a1f8899323b96b4ef08b168df93e0a90c673d1e4cce39366cb62f9b5f84868e8e8688605354604051612886989796959493929190615463565b60405180910390a16128a45f84868e8e868880519060200120613d23565b86156128b2576128b261339b565b50505050611faa60018055565b60a9546001600160a01b031633146128ea57604051638e9d821f60e01b815260040160405180910390fd5b611252613d5b565b60a85461010090046001600160a01b0316331461292257604051637bb0100f60e01b815260040160405180910390fd5b60a4805460a880546001600160a01b03610100820481166001600160a01b03198516811790955574ffffffffffffffffffffffffffffffffffffffff0019909116909155604080519190921680825260208201939093527f85d2bdfbe58cd81abf8199c13ce2509204be4aba8603b9d29f52c4e13e7bb7939101611632565b60a3546001600160a01b031633146129cc576040516357b738d160e11b815260040160405180910390fd5b6001600160a01b0381166129f35760405163f6b2911f60e01b815260040160405180910390fd5b60a380546001600160a01b0319166001600160a01b0383169081179091556040519081527f32cf74f8a6d5f88593984d2cd52be5592bfa6884f5896175801a5069ef09cd6790602001611632565b5f5f8383604051602001612a56929190615230565b6040516020818303038152906040528051906020012090505f60ff60f81b3083612a7e61202d565b604051602001612a8e91906153ae565b60405160208183030381529060405280519060200120604051602001612aeb94939291906001600160f81b031994909416845260609290921b6bffffffffffffffffffffffff191660018401526015830152603582015260550190565b60408051808303601f19018152919052805160209091012095945050505050565b60685460ff1615612b3057604051630bc011ff60e21b815260040160405180910390fd5b60685463ffffffff8681166101009092041614612b60576040516302caf51760e11b815260040160405180910390fd5b612b7f8c8c8c8c8c60018d8d8d8d8d8d8d60405161218192919061539f565b604080518b815263ffffffff891660208201526001600160a01b0388811682840152861660608201526080810185905290517f1df3f2a973a00d6635911755c260704e95e8a5876997546798770f76396fda4d9181900360a00190a1606f545f906001600160a01b0316612c8e57846001600160a01b031684888a8686604051602401612c0f94939291906154d7565b60408051601f198184030181529181526020820180516001600160e01b0316630c035af960e11b17905251612c4491906153ae565b5f6040518083038185875af1925050503d805f8114612c7e576040519150601f19603f3d011682016040523d82523d5f602084013e612c83565b606091505b505080915050612d3f565b606f54612ca5906001600160a01b031686866138c4565b846001600160a01b031687898585604051602401612cc694939291906154d7565b60408051601f198184030181529181526020820180516001600160e01b0316630c035af960e11b17905251612cfb91906153ae565b5f604051808303815f865af19150503d805f8114612d34576040519150601f19603f3d011682016040523d82523d5f602084013e612d39565b606091505b50909150505b80612d5d576040516337e391c360e01b815260040160405180910390fd5b50505050505050505050505050565b5f54610100900460ff1615808015612d8a57505f54600160ff909116105b80612da35750303b158015612da357505f5460ff166001145b612e065760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610c40565b5f805460ff1916600117905580156119b2575f805461ff00191661010017905560405163f57ac68360e01b815260040160405180910390fd5b5f81612e4c8686866119cb565b1495945050505050565b5f5f612e6061202d565b604051602001612e7091906153ae565b6040516020818303038152906040529050838151602083015ff591506001600160a01b038216612eb3576040516331682e8d60e11b815260040160405180910390fd5b5f5f5f85806020019051810190612eca9190615505565b925092509250846001600160a01b0316631624f6c68484846040518463ffffffff1660e01b8152600401612f00939291906152f8565b5f604051808303815f87803b158015612f17575f5ffd5b505af1158015612f29573d5f5f3e3d5ffd5b505050505050505092915050565b5f54610100900460ff16612fa15760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608401610c40565b611252613db2565b5f612fbf64010000000063ffffffff8416615375565b612fcf9063ffffffff851661538c565b600881901c5f8181526069602052604090208054600160ff851690811b918218928390559394509192919080821615611faa57604051630631b5f760e31b815260040160405180910390fd5b60685460ff161561303f57604051630bc011ff60e21b815260040160405180910390fd5b6068805460ff191660011790556040517f2261efe5aef6fedc1fd1550b25facc9181745623049c7901287030b9ad1a5497905f90a1565b60685463ffffffff6101009091048116908716036130a7576040516302caf51760e11b815260040160405180910390fd5b7f501781209a1f8899323b96b4ef08b168df93e0a90c673d1e4cce39366cb62f9b6001606860019054906101000a900463ffffffff163389898988886053546040516130fb99989796959493929190615572565b60405180910390a161313c6001606860019054906101000a900463ffffffff1633898989888860405161312f92919061539f565b6040518091039020613d23565b82156119885761198861339b565b6001600160a01b038316158061316757506001600160a01b038216155b156131855760405163f6b2911f60e01b815260040160405180910390fd5b60685463ffffffff6101009091048116908516036131b65760405163658b23ad60e01b815260040160405180910390fd5b6001600160a01b038281165f908152606b6020526040902054640100000000900416156131f6576040516317abdeeb60e21b815260040160405180910390fd5b5f848460405160200161320a929190615230565b60408051808303601f1901815282825280516020918201205f818152606a835283812080546001600160a01b0319166001600160a01b038a8116918217909255868601865263ffffffff8c81168089528c8416878a01818152848752606b89528987209a518b54915194166001600160c01b03199091161764010000000093909516929092029390931790975560a2855291859020805460ff191689151590811790915585519182529381019590955292840192909252606083015291507fdbe8a5da6a7a916d9adfda9160167a0f8a3da415ee6610e810e753853597fce79060800160405180910390a15050505050565b606d546001600160a01b031661332557604051634cb4711360e11b815260040160405180910390fd5b606f80546001600160a01b0319166001600160a01b0384169081179091555f81815260a26020908152604091829020805460ff19168515159081179091558251938452908301527fc7318b7ed6ba4f2908a3de396d8ab49b1dadb55db5b55123247a401f29ff8d82910160405180910390a15050565b6053546068805463ffffffff909216600160c81b0263ffffffff60c81b1990921691909117908190556001600160a01b0365010000000000909104166333d6247d6133e461151b565b6040518263ffffffff1660e01b815260040161340291815260200190565b5f604051808303815f87803b158015613419575f5ffd5b505af115801561180d573d5f5f3e3d5ffd5b5f61343960048284866155e8565b6134429161560f565b9050632afa533160e01b6001600160e01b03198216016135b1575f808080808080613470896004818d6155e8565b81019061347d9190615647565b9650965096509650965096509650336001600160a01b0316876001600160a01b0316146134bd5760405163912ecce760e01b815260040160405180910390fd5b6001600160a01b03861630146134e65760405163750643af60e01b815260040160405180910390fd5b604080516001600160a01b0389811660248301528881166044830152606482018890526084820187905260ff861660a483015260c4820185905260e48083018590528351808403909101815261010490920183526020820180516001600160e01b031663d505accf60e01b1790529151918d169161356491906153ae565b5f604051808303815f865af19150503d805f811461359d576040519150601f19603f3d011682016040523d82523d5f602084013e6135a2565b606091505b5050505050505050505061180d565b6001600160e01b031981166323f2ebc360e21b146135e257604051637141605d60e11b815260040160405180910390fd5b5f808080808080806135f78a6004818e6155e8565b8101906136049190615696565b97509750975097509750975097509750336001600160a01b0316886001600160a01b0316146136465760405163912ecce760e01b815260040160405180910390fd5b6001600160a01b038716301461366f5760405163750643af60e01b815260040160405180910390fd5b604080516001600160a01b038a811660248301528981166044830152606482018990526084820188905286151560a483015260ff861660c483015260e482018590526101048083018590528351808403909101815261012490920183526020820180516001600160e01b03166323f2ebc360e21b1790529151918e16916136f691906153ae565b5f604051808303815f865af19150503d805f811461372f576040519150601f19603f3d011682016040523d82523d5f602084013e613734565b606091505b505050505050505050505050505050565b6001600160a01b0382165f90815260a2602052604081205460ff1615613861576040516370a0823160e01b81523060048201525f906001600160a01b038516906370a0823190602401602060405180830381865afa1580156137a9573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906137cd9190615439565b90506137e46001600160a01b038516333086613cea565b6040516370a0823160e01b81523060048201525f906001600160a01b038616906370a0823190602401602060405180830381865afa158015613828573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061384c9190615439565b90506138588282615450565b9250505061129c565b604051632770a7eb60e21b8152336004820152602481018390526001600160a01b03841690639dc29fac906044015f604051808303815f87803b1580156138a6575f5ffd5b505af11580156138b8573d5f5f3e3d5ffd5b5050505081905061129c565b6001600160a01b0383165f90815260a2602052604090205460ff16156138f85761198c6001600160a01b0384168383613c85565b6040516340c10f1960e01b81526001600160a01b038381166004830152602482018390528416906340c10f19906044015f604051808303815f87803b15801561393f575f5ffd5b505af1158015611faa573d5f5f3e3d5ffd5b60408051600481526024810182526020810180516001600160e01b03166306fdde0360e01b17905290516060915f9182916001600160a01b0386169161399791906153ae565b5f60405180830381855afa9150503d805f81146139cf576040519150601f19603f3d011682016040523d82523d5f602084013e6139d4565b606091505b509150915081613a0357604051806040016040528060078152602001664e4f5f4e414d4560c81b815250613a0c565b613a0c81613e1c565b949350505050565b60408051600481526024810182526020810180516001600160e01b03166395d89b4160e01b17905290516060915f9182916001600160a01b03861691613a5a91906153ae565b5f60405180830381855afa9150503d805f8114613a92576040519150601f19603f3d011682016040523d82523d5f602084013e613a97565b606091505b509150915081613a0357604051806040016040528060098152602001681393d7d4d6535093d360ba1b815250613a0c565b60408051600481526024810182526020810180516001600160e01b031663313ce56760e01b17905290515f91829182916001600160a01b03861691613b0d91906153ae565b5f60405180830381855afa9150503d805f8114613b45576040519150601f19603f3d011682016040523d82523d5f602084013e613b4a565b606091505b5091509150818015613b5d575080516020145b613b68576012613a0c565b80806020019051810190613a0c91906152dd565b600260015403613bce5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610c40565b6002600155565b5f613be58888888888888861139e565b9050613bf58d8d8d8d8d86613fb4565b60a554613c1d90613c0f8d845f9182526020526040902090565b5f9182526020526040902090565b60a5819055604080518d815260208101929092527f3e5936f910a78eb5181813a939c8d4c3e4d85f87943f659380d82ac6221b0e92910160405180910390a160ff8816613c6f57613c6f87878561417a565b5f1960ff891601612d5d57612d5d5f5f8561417a565b6040516001600160a01b0383811660248301526044820183905261198c91859182169063a9059cbb906064015b604051602081830303815290604052915060e01b6020820180516001600160e01b03838183161783525050505061425a565b60018055565b6040516001600160a01b03848116602483015283811660448301526064820183905261180d9186918216906323b872dd90608401613cb2565b613d32878787878787876142bb565b60ff8716613d4557613d458686846142d2565b5f1960ff881601611faa57611faa5f5f846142d2565b60685460ff16613d7e57604051635386698160e01b815260040160405180910390fd5b6068805460ff191690556040517f1e5e34eea33501aecf2ebec9fe0e884a40804275ea7fe10b2ba084c8374308b3905f90a1565b5f54610100900460ff16613ce45760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608401610c40565b60606040825110613e3b578180602001905181019061129c91906152ab565b8151602003613f81575f5b602081108015613e755750828181518110613e6357613e636151ec565b01602001516001600160f81b03191615155b15613e8c5780613e8481615714565b915050613e46565b805f03613ec35750506040805180820190915260128152714e4f545f56414c49445f454e434f44494e4760701b6020820152919050565b5f8167ffffffffffffffff811115613edd57613edd61462e565b6040519080825280601f01601f191660200182016040528015613f07576020820181803683370190505b5090505f5b82811015613f7957848181518110613f2657613f266151ec565b602001015160f81c60f81b828281518110613f4357613f436151ec565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff191690815f1a905350600101613f0c565b509392505050565b50506040805180820190915260128152714e4f545f56414c49445f454e434f44494e4760701b602082015290565b919050565b6068545f906501000000000090046001600160a01b031663257b3632613fe386865f9182526020526040902090565b6040518263ffffffff1660e01b815260040161400191815260200190565b6020604051808303815f875af115801561401d573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906140419190615439565b9050805f0361406257604051622f6fad60e01b815260040160405180910390fd5b5f80680100000000000000008716156140de578691508161409263ffffffff82166801000000000000000061538c565b146140b05760405163071389e960e01b815260040160405180910390fd5b6140bc848a8489612e3f565b6140d9576040516338105f3b60e21b815260040160405180910390fd5b614165565b602087901c6140ee816001615214565b88935091508261411263ffffffff821667ffffffff00000000602085901b1661538c565b146141305760405163071389e960e01b815260040160405180910390fd5b61414661413e868c866119cb565b8a8389612e3f565b614163576040516338105f3b60e21b815260040160405180910390fd5b505b61416f828261439c565b505050505050505050565b60685463ffffffff61010090910481169084160361419757505050565b5f83836040516020016141ab929190615230565b60408051601f1981840301815291815281516020928301205f81815260a79093529120549091506141dd905f19615450565b821115614232575f81815260a76020526040908190205490516323d7213360e01b815263ffffffff861660048201526001600160a01b0385166024820152604481018490526064810191909152608401610c40565b5f81815260a760205260408120805484929061424f90849061538c565b909155505050505050565b5f61426e6001600160a01b0384168361440f565b905080515f14158015614292575080806020019051810190614290919061572c565b155b1561198c57604051635274afe760e01b81526001600160a01b0384166004820152602401610c40565b611faa6142cd8888888888888861139e565b61441c565b60685463ffffffff6101009091048116908416036142ef57505050565b5f8383604051602001614303929190615230565b60408051601f1981840301815291815281516020928301205f81815260a790935291205490915082111561437f575f81815260a76020526040908190205490516314603c0160e01b815263ffffffff861660048201526001600160a01b0385166024820152604481018490526064810191909152608401610c40565b5f81815260a760205260408120805484929061424f908490615450565b5f6143b264010000000063ffffffff8416615375565b6143c29063ffffffff851661538c565b600881901c5f8181526069602052604081208054600160ff861690811b91821892839055949550929392918183169003611faa57604051630c8d9eab60e31b815260040160405180910390fd5b6060611a5383835f6144db565b80600161442b6020600261582a565b6144359190615450565b60535410614456576040516377ae67b360e11b815260040160405180910390fd5b5f60535f815461446590615714565b918290555090505f5b60208110156144d2578082901c6001166001036144a1578260338260208110614499576144996151ec565b015550505050565b6144c8603382602081106144b7576144b76151ec565b0154845f9182526020526040902090565b925060010161446e565b5061198c615835565b6060814710156145005760405163cd78605960e01b8152306004820152602401610c40565b5f5f856001600160a01b0316848660405161451b91906153ae565b5f6040518083038185875af1925050503d805f8114614555576040519150601f19603f3d011682016040523d82523d5f602084013e61455a565b606091505b509150915061456a868383614574565b9695505050505050565b60608261458957614584826145d0565b611a53565b81511580156145a057506001600160a01b0384163b155b156145c957604051639996b31560e01b81526001600160a01b0385166004820152602401610c40565b5080611a53565b8051156145e05780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b50565b803563ffffffff81168114613faf575f5ffd5b6001600160a01b03811681146145f9575f5ffd5b8035613faf8161460f565b634e487b7160e01b5f52604160045260245ffd5b604051601f8201601f1916810167ffffffffffffffff8111828210171561466b5761466b61462e565b604052919050565b5f67ffffffffffffffff82111561468c5761468c61462e565b50601f01601f191660200190565b5f82601f8301126146a9575f5ffd5b81356146bc6146b782614673565b614642565b8181528460208386010111156146d0575f5ffd5b816020850160208301375f918101602001919091529392505050565b80151581146145f9575f5ffd5b8035613faf816146ec565b5f5f5f5f5f5f5f5f5f5f5f5f6101808d8f031215614720575f5ffd5b6147298d6145fc565b9b5061473760208e01614623565b9a5061474560408e016145fc565b995061475360608e01614623565b985061476160808e01614623565b975067ffffffffffffffff60a08e0135111561477b575f5ffd5b61478b8e60a08f01358f0161469a565b965061479960c08e01614623565b95506147a760e08e01614623565b94506147b66101008e016146f9565b93506147c56101208e01614623565b92506147d46101408e01614623565b91506147e36101608e01614623565b90509295989b509295989b509295989b565b5f67ffffffffffffffff82111561480e5761480e61462e565b5060051b60200190565b5f60208284031215614828575f5ffd5b813567ffffffffffffffff81111561483e575f5ffd5b8201601f8101841361484e575f5ffd5b803561485c6146b7826147f5565b8082825260208201915060208360051b85010192508683111561487d575f5ffd5b6020840193505b8284101561456a578335825260209384019390910190614884565b5f5f604083850312156148b0575f5ffd5b6148b9836145fc565b915060208301356148c98161460f565b809150509250929050565b5f5f83601f8401126148e4575f5ffd5b50813567ffffffffffffffff8111156148fb575f5ffd5b602083019150836020828501011115614912575f5ffd5b9250929050565b5f5f5f5f5f6080868803121561492d575f5ffd5b614936866145fc565b945060208601356149468161460f565b93506040860135614956816146ec565b9250606086013567ffffffffffffffff811115614971575f5ffd5b61497d888289016148d4565b969995985093965092949392505050565b5f5b838110156149a8578181015183820152602001614990565b50505f910152565b5f81518084526149c781602086016020860161498e565b601f01601f19169290920160200192915050565b602081525f611a5360208301846149b0565b5f602082840312156149fd575f5ffd5b8135611a538161460f565b60ff811681146145f9575f5ffd5b5f5f5f5f5f5f5f60e0888a031215614a2c575f5ffd5b8735614a3781614a08565b9650614a45602089016145fc565b95506040880135614a558161460f565b9450614a63606089016145fc565b93506080880135614a738161460f565b9699959850939692959460a0840135945060c09093013592915050565b5f82601f830112614a9f575f5ffd5b8135614aad6146b7826147f5565b8082825260208201915060208360051b860101925085831115614ace575f5ffd5b602085015b83811015614af4578035614ae68161460f565b835260209283019201614ad3565b5095945050505050565b5f82601f830112614b0d575f5ffd5b8135614b1b6146b7826147f5565b8082825260208201915060208360051b860101925085831115614b3c575f5ffd5b602085015b83811015614af4578035614b54816146ec565b835260209283019201614b41565b5f5f5f5f60808587031215614b75575f5ffd5b843567ffffffffffffffff811115614b8b575f5ffd5b8501601f81018713614b9b575f5ffd5b8035614ba96146b7826147f5565b8082825260208201915060208360051b850101925089831115614bca575f5ffd5b6020840193505b82841015614bf357614be2846145fc565b825260209384019390910190614bd1565b9650505050602085013567ffffffffffffffff811115614c11575f5ffd5b614c1d87828801614a90565b935050604085013567ffffffffffffffff811115614c39575f5ffd5b614c4587828801614a90565b925050606085013567ffffffffffffffff811115614c61575f5ffd5b614c6d87828801614afe565b91505092959194509250565b5f5f5f60608486031215614c8b575f5ffd5b614c94846145fc565b92506020840135614ca48161460f565b91506040840135614cb4816146ec565b809150509250925092565b5f60208284031215614ccf575f5ffd5b5035919050565b80610400810183101561129c575f5ffd5b5f5f5f6104408486031215614cfa575f5ffd5b83359250614d0b8560208601614cd6565b9150614d1a61042085016145fc565b90509250925092565b5f5f5f5f60608587031215614d36575f5ffd5b8435614d418161460f565b935060208501359250604085013567ffffffffffffffff811115614d63575f5ffd5b614d6f878288016148d4565b95989497509550505050565b5f5f5f5f5f5f60a08789031215614d90575f5ffd5b614d99876145fc565b95506020870135614da98161460f565b9450604087013593506060870135614dc0816146ec565b9250608087013567ffffffffffffffff811115614ddb575f5ffd5b614de789828a016148d4565b979a9699509497509295939492505050565b5f5f60408385031215614e0a575f5ffd5b8235614e158161460f565b915060208301356148c9816146ec565b5f5f60408385031215614e36575f5ffd5b614e3f836145fc565b9150614e4d602084016145fc565b90509250929050565b5f5f5f5f5f5f5f5f5f5f5f5f6109208d8f031215614e72575f5ffd5b614e7c8e8e614cd6565b9b50614e8c8e6104008f01614cd6565b9a506108008d013599506108208d013598506108408d01359750614eb36108608e016145fc565b9650614ec36108808e013561460f565b6108808d01359550614ed86108a08e016145fc565b94506108c08d0135614ee98161460f565b93506108e08d0135925067ffffffffffffffff6109008e01351115614f0c575f5ffd5b614f1d8e6109008f01358f016148d4565b81935080925050509295989b509295989b509295989b565b5f5f5f5f5f5f5f60c0888a031215614f4b575f5ffd5b614f54886145fc565b96506020880135614f648161460f565b9550604088013594506060880135614f7b8161460f565b93506080880135614f8b816146ec565b925060a088013567ffffffffffffffff811115614fa6575f5ffd5b614fb28a828b016148d4565b989b979a50959850939692959293505050565b5f5f5f5f5f5f60c08789031215614fda575f5ffd5b614fe3876145fc565b95506020870135614ff38161460f565b9450615001604088016145fc565b935060608701356150118161460f565b925060808701356150218161460f565b915060a087013567ffffffffffffffff81111561503c575f5ffd5b61504889828a0161469a565b9150509295509295509295565b5f5f5f5f6104608587031215615069575f5ffd5b8435935061507a8660208701614cd6565b925061508961042086016145fc565b939692955092936104400135925050565b600181811c908216806150ae57607f821691505b6020821081036150cc57634e487b7160e01b5f52602260045260245ffd5b50919050565b601f82111561198c57805f5260205f20601f840160051c810160208510156150f75750805b601f840160051c820191505b8181101561130b575f8155600101615103565b815167ffffffffffffffff8111156151305761513061462e565b6151448161513e845461509a565b846150d2565b6020601f821160018114615176575f831561515f5750848201515b5f19600385901b1c1916600184901b17845561130b565b5f84815260208120601f198516915b828110156151a55787850151825560209485019460019092019101615185565b50848210156151c257868401515f19600387901b60f8161c191681555b50505050600190811b01905550565b5f602082840312156151e1575f5ffd5b8151611a538161460f565b634e487b7160e01b5f52603260045260245ffd5b634e487b7160e01b5f52601160045260245ffd5b63ffffffff818116838216019081111561129c5761129c615200565b60e09290921b6001600160e01b031916825260601b6bffffffffffffffffffffffff1916600482015260180190565b5f61526c6146b784614673565b905082815283838301111561527f575f5ffd5b611a5383602083018461498e565b5f82601f83011261529c575f5ffd5b611a538383516020850161525f565b5f602082840312156152bb575f5ffd5b815167ffffffffffffffff8111156152d1575f5ffd5b613a0c8482850161528d565b5f602082840312156152ed575f5ffd5b8151611a5381614a08565b606081525f61530a60608301866149b0565b828103602084015261531c81866149b0565b91505060ff83166040830152949350505050565b5f60208284031215615340575f5ffd5b815167ffffffffffffffff811115615356575f5ffd5b8201601f81018413615366575f5ffd5b613a0c8482516020840161525f565b808202811582820484141761129c5761129c615200565b8082018082111561129c5761129c615200565b818382375f9101908152919050565b5f82516153bf81846020870161498e565b9190910192915050565b81835281816020850137505f828201602090810191909152601f909101601f19169091010190565b63ffffffff861681526001600160a01b03851660208201526001600160a01b0384166040820152608060608201525f61542e6080830184866153c9565b979650505050505050565b5f60208284031215615449575f5ffd5b5051919050565b8181038181111561129c5761129c615200565b60ff8916815263ffffffff881660208201526001600160a01b038716604082015263ffffffff861660608201526001600160a01b03851660808201528360a082015261010060c08201525f6154bc6101008301856149b0565b905063ffffffff831660e08301529998505050505050505050565b6001600160a01b038516815263ffffffff84166020820152606060408201525f61456a6060830184866153c9565b5f5f5f60608486031215615517575f5ffd5b835167ffffffffffffffff81111561552d575f5ffd5b6155398682870161528d565b935050602084015167ffffffffffffffff811115615555575f5ffd5b6155618682870161528d565b9250506040840151614cb481614a08565b60ff8a16815263ffffffff891660208201526001600160a01b038816604082015263ffffffff871660608201526001600160a01b03861660808201528460a082015261010060c08201525f6155cc610100830185876153c9565b905063ffffffff831660e08301529a9950505050505050505050565b5f5f858511156155f6575f5ffd5b83861115615602575f5ffd5b5050820193919092039150565b80356001600160e01b03198116906004841015615640576001600160e01b0319600485900360031b81901b82161691505b5092915050565b5f5f5f5f5f5f5f60e0888a03121561565d575f5ffd5b87356156688161460f565b965060208801356156788161460f565b955060408801359450606088013593506080880135614a7381614a08565b5f5f5f5f5f5f5f5f610100898b0312156156ae575f5ffd5b88356156b98161460f565b975060208901356156c98161460f565b9650604089013595506060890135945060808901356156e7816146ec565b935060a08901356156f781614a08565b979a969950949793969295929450505060c08201359160e0013590565b5f6001820161572557615725615200565b5060010190565b5f6020828403121561573c575f5ffd5b8151611a53816146ec565b6001815b60018411156157825780850481111561576657615766615200565b600184161561577457908102905b60019390931c92800261574b565b935093915050565b5f826157985750600161129c565b816157a457505f61129c565b81600181146157ba57600281146157c4576157e0565b600191505061129c565b60ff8411156157d5576157d5615200565b50506001821b61129c565b5060208310610133831016604e8410600b8410161715615803575081810a61129c565b61580f5f198484615747565b805f190482111561582257615822615200565b029392505050565b5f611a53838361578a565b634e487b7160e01b5f52600160045260245ffdfea2646970667358221220e1559c2f35db1ae259a268c6bba8fd38cf4df7f213026f9875114146126edc6f64736f6c634300081c00336080604052348015600e575f5ffd5b50610fb38061001c5f395ff3fe608060405234801561000f575f5ffd5b5060043610610029575f3560e01c8063c514f24e1461002d575b5f5ffd5b61003561004b565b604051610042919061006a565b60405180910390f35b60405180610f000160405280610ec881526020016100b6610ec8913981565b602081525f82518060208401525f5b818110156100965760208186018101516040868401015201610079565b505f604082850101526040601f19601f8301168401019150509291505056fe60806040819052631d97f74d60e11b81523390633b2fee9a90608490602090600481865afa158015610033573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906100579190610433565b604080515f80825260208201909252905061007382825f6100e2565b50506100dd336001600160a01b03166338b8fbbb6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156100b4573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906100d89190610433565b61010d565b6104c8565b6100eb8361017a565b5f825111806100f75750805b156101085761010683836101b9565b505b505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f61014c5f516020610e815f395f51905f52546001600160a01b031690565b604080516001600160a01b03928316815291841660208301520160405180910390a1610177816101e5565b50565b61018381610280565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b905f90a250565b60606101de8383604051806060016040528060278152602001610ea160279139610314565b9392505050565b6001600160a01b03811661024f5760405162461bcd60e51b815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201526564647265737360d01b60648201526084015b60405180910390fd5b805f516020610e815f395f51905f525b80546001600160a01b0319166001600160a01b039290921691909117905550565b6001600160a01b0381163b6102ed5760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b6064820152608401610246565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc61025f565b60605f5f856001600160a01b031685604051610330919061047b565b5f60405180830381855af49150503d805f8114610368576040519150601f19603f3d011682016040523d82523d5f602084013e61036d565b606091505b50909250905061037f86838387610389565b9695505050505050565b606083156103f75782515f036103f0576001600160a01b0385163b6103f05760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610246565b5081610401565b6104018383610409565b949350505050565b8151156104195781518083602001fd5b8060405162461bcd60e51b81526004016102469190610496565b5f60208284031215610443575f5ffd5b81516001600160a01b03811681146101de575f5ffd5b5f5b8381101561047357818101518382015260200161045b565b50505f910152565b5f825161048c818460208701610459565b9190910192915050565b602081525f82518060208401526104b4816040850160208701610459565b601f01601f19169190910160400192915050565b6109ac806104d55f395ff3fe60806040526004361061005d575f3560e01c80635c60da1b116100425780635c60da1b146100a65780638f283970146100e3578063f851a440146101025761006c565b80633659cfe6146100745780634f1ef286146100935761006c565b3661006c5761006a610116565b005b61006a610116565b34801561007f575f5ffd5b5061006a61008e366004610854565b610130565b61006a6100a136600461086d565b610178565b3480156100b1575f5ffd5b506100ba6101eb565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100ee575f5ffd5b5061006a6100fd366004610854565b610228565b34801561010d575f5ffd5b506100ba610255565b61011e610282565b61012e610129610359565b610362565b565b610138610380565b73ffffffffffffffffffffffffffffffffffffffff1633036101705761016d8160405180602001604052805f8152505f6103bf565b50565b61016d610116565b610180610380565b73ffffffffffffffffffffffffffffffffffffffff1633036101e3576101de8383838080601f0160208091040260200160405190810160405280939291908181526020018383808284375f92019190915250600192506103bf915050565b505050565b6101de610116565b5f6101f4610380565b73ffffffffffffffffffffffffffffffffffffffff16330361021d57610218610359565b905090565b610225610116565b90565b610230610380565b73ffffffffffffffffffffffffffffffffffffffff1633036101705761016d816103e9565b5f61025e610380565b73ffffffffffffffffffffffffffffffffffffffff16330361021d57610218610380565b61028a610380565b73ffffffffffffffffffffffffffffffffffffffff16330361012e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b5f61021861044a565b365f5f375f5f365f845af43d5f5f3e80801561037c573d5ff35b3d5ffd5b5f7fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b6103c883610471565b5f825111806103d45750805b156101de576103e383836104bd565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f610412610380565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a161016d816104e9565b5f7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc6103a3565b61047a816105f5565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b905f90a250565b60606104e28383604051806060016040528060278152602001610979602791396106c0565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff811661058c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610350565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b73ffffffffffffffffffffffffffffffffffffffff81163b610699576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e7472616374000000000000000000000000000000000000006064820152608401610350565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc6105af565b60605f5f8573ffffffffffffffffffffffffffffffffffffffff16856040516106e9919061090d565b5f60405180830381855af49150503d805f8114610721576040519150601f19603f3d011682016040523d82523d5f602084013e610726565b606091505b509150915061073786838387610741565b9695505050505050565b606083156107d65782515f036107cf5773ffffffffffffffffffffffffffffffffffffffff85163b6107cf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610350565b50816107e0565b6107e083836107e8565b949350505050565b8151156107f85781518083602001fd5b806040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103509190610928565b803573ffffffffffffffffffffffffffffffffffffffff8116811461084f575f5ffd5b919050565b5f60208284031215610864575f5ffd5b6104e28261082c565b5f5f5f6040848603121561087f575f5ffd5b6108888461082c565b9250602084013567ffffffffffffffff8111156108a3575f5ffd5b8401601f810186136108b3575f5ffd5b803567ffffffffffffffff8111156108c9575f5ffd5b8660208284010111156108da575f5ffd5b939660209190910195509293505050565b5f5b838110156109055781810151838201526020016108ed565b50505f910152565b5f825161091e8184602087016108eb565b9190910192915050565b602081525f82518060208401526109468160408501602087016108eb565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a164736f6c634300081c000ab53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220f9f921f910b22a2a14f9dce017cc4be5206c1f1f3690adcea59699078c36984a64736f6c634300081c00336080604052348015600e575f5ffd5b5060156019565b60c9565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000900460ff161560685760405163f92ee8a960e01b815260040160405180910390fd5b80546001600160401b039081161460c65780546001600160401b0319166001600160401b0390811782556040519081527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b50565b61163e806100d65f395ff3fe608060405234801561000f575f5ffd5b5060043610610106575f3560e01c806370a082311161009e5780639dc29fac1161006e5780639dc29fac1461023c578063a3c573eb1461024f578063a9059cbb14610297578063d505accf146102aa578063dd62ed3e146102bd575f5ffd5b806370a08231146101f35780637ecebe001461020657806384b0196e1461021957806395d89b4114610234575f5ffd5b806323b872dd116100d957806323b872dd14610191578063313ce567146101a45780633644e515146101d857806340c10f19146101e0575f5ffd5b806306fdde031461010a578063095ea7b3146101285780631624f6c61461014b57806318160ddd14610160575b5f5ffd5b610112610314565b60405161011f919061115f565b60405180910390f35b61013b610136366004611193565b6103b9565b604051901515815260200161011f565b61015e61015936600461126a565b6103d2565b005b7f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace02545b60405190815260200161011f565b61013b61019f3660046112de565b61054a565b7f863b064fe9383d75d38f584f64f1aaba4520e9ebc98515fa15bdeae8c4274d005460405160ff909116815260200161011f565b61018361056d565b61015e6101ee366004611193565b61057b565b610183610201366004611318565b6105de565b610183610214366004611318565b61060e565b610221610618565b60405161011f9796959493929190611331565b6101126106ce565b61015e61024a366004611193565b61070c565b7f863b064fe9383d75d38f584f64f1aaba4520e9ebc98515fa15bdeae8c4274d005461010090046001600160a01b03166040516001600160a01b03909116815260200161011f565b61013b6102a5366004611193565b61076a565b61015e6102b83660046113c7565b610777565b6101836102cb36600461142d565b6001600160a01b039182165f9081527f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace016020908152604080832093909416825291909152205490565b60605f5f5160206115c95f395f51905f525b90508060030180546103379061145e565b80601f01602080910402602001604051908101604052809291908181526020018280546103639061145e565b80156103ae5780601f10610385576101008083540402835291602001916103ae565b820191905f5260205f20905b81548152906001019060200180831161039157829003601f168201915b505050505091505090565b5f336103c68185856108cc565b60019150505b92915050565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000810460ff16159067ffffffffffffffff165f8115801561041c5750825b90505f8267ffffffffffffffff1660011480156104385750303b155b905081158015610446575080155b156104645760405163f92ee8a960e01b815260040160405180910390fd5b845467ffffffffffffffff19166001178555831561049857845468ff00000000000000001916680100000000000000001785555b6104a288886108d9565b6104ab886108ef565b7f863b064fe9383d75d38f584f64f1aaba4520e9ebc98515fa15bdeae8c4274d00805460ff881674ffffffffffffffffffffffffffffffffffffffffff19909116176101003302179055831561054057845468ff000000000000000019168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b5050505050505050565b5f3361055785828561091d565b6105628585856109b7565b506001949350505050565b5f610576610a14565b905090565b5f7f863b064fe9383d75d38f584f64f1aaba4520e9ebc98515fa15bdeae8c4274d00805490915061010090046001600160a01b031633146105cf576040516338da3b1560e01b815260040160405180910390fd5b6105d98383610a1d565b505050565b5f805f5160206115c95f395f51905f525b6001600160a01b039093165f9081526020939093525050604090205490565b5f6103cc82610a51565b5f60608082808083815f5160206115e95f395f51905f52805490915015801561064357506001810154155b6106945760405162461bcd60e51b815260206004820152601560248201527f4549503731323a20556e696e697469616c697a6564000000000000000000000060448201526064015b60405180910390fd5b61069c610a5b565b6106a4610a99565b604080515f80825260208201909252600f60f81b9c939b5091995046985030975095509350915050565b7f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace0480546060915f5160206115c95f395f51905f52916103379061145e565b5f7f863b064fe9383d75d38f584f64f1aaba4520e9ebc98515fa15bdeae8c4274d00805490915061010090046001600160a01b03163314610760576040516338da3b1560e01b815260040160405180910390fd5b6105d98383610aaf565b5f336103c68185856109b7565b8342111561079b5760405163313c898160e11b81526004810185905260240161068b565b5f7f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c98888886108058c6001600160a01b03165f9081527f5ab42ced628888259c08ac98db1eb0cf702fc1501344311d8b100cd1bfe4bb006020526040902080546001810190915590565b6040805160208101969096526001600160a01b0394851690860152929091166060840152608083015260a082015260c0810186905260e0016040516020818303038152906040528051906020012090505f61085f82610ae3565b90505f61086e82878787610b0f565b9050896001600160a01b0316816001600160a01b0316146108b5576040516325c0072360e11b81526001600160a01b0380831660048301528b16602482015260440161068b565b6108c08a8a8a6108cc565b50505050505050505050565b6105d98383836001610b3b565b6108e1610c1f565b6108eb8282610c6f565b5050565b6108f7610c1f565b61091a81604051806040016040528060018152602001603160f81b815250610cbf565b50565b6001600160a01b038381165f9081527f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace0160209081526040808320938616835292905220545f1981146109b157818110156109a357604051637dc7a0d960e11b81526001600160a01b0384166004820152602481018290526044810183905260640161068b565b6109b184848484035f610b3b565b50505050565b6001600160a01b0383166109e057604051634b637e8f60e11b81525f600482015260240161068b565b6001600160a01b038216610a095760405163ec442f0560e01b81525f600482015260240161068b565b6105d9838383610d1e565b5f610576610e57565b6001600160a01b038216610a465760405163ec442f0560e01b81525f600482015260240161068b565b6108eb5f8383610d1e565b5f6103cc82610eca565b7fa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d10280546060915f5160206115e95f395f51905f52916103379061145e565b60605f5f5160206115e95f395f51905f52610326565b6001600160a01b038216610ad857604051634b637e8f60e11b81525f600482015260240161068b565b6108eb825f83610d1e565b5f6103cc610aef610a14565b8360405161190160f01b8152600281019290925260228201526042902090565b5f5f5f5f610b1f88888888610ef2565b925092509250610b2f8282610fba565b50909695505050505050565b5f5160206115c95f395f51905f526001600160a01b038516610b725760405163e602df0560e01b81525f600482015260240161068b565b6001600160a01b038416610b9b57604051634a1406b160e11b81525f600482015260240161068b565b6001600160a01b038086165f90815260018301602090815260408083209388168352929052208390558115610c1857836001600160a01b0316856001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92585604051610c0f91815260200190565b60405180910390a35b5050505050565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005468010000000000000000900460ff16610c6d57604051631afcd79f60e31b815260040160405180910390fd5b565b610c77610c1f565b5f5160206115c95f395f51905f527f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace03610cb084826114da565b50600481016109b183826114da565b610cc7610c1f565b5f5160206115e95f395f51905f527fa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d102610d0084826114da565b5060038101610d0f83826114da565b505f8082556001909101555050565b5f5160206115c95f395f51905f526001600160a01b038416610d585781816002015f828254610d4d9190611595565b90915550610dc89050565b6001600160a01b0384165f9081526020829052604090205482811015610daa5760405163391434e360e21b81526001600160a01b0386166004820152602481018290526044810184905260640161068b565b6001600160a01b0385165f9081526020839052604090209083900390555b6001600160a01b038316610de6576002810180548390039055610e04565b6001600160a01b0383165f9081526020829052604090208054830190555b826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051610e4991815260200190565b60405180910390a350505050565b5f7f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f610e81611072565b610e896110da565b60408051602081019490945283019190915260608201524660808201523060a082015260c00160405160208183030381529060405280519060200120905090565b5f807f5ab42ced628888259c08ac98db1eb0cf702fc1501344311d8b100cd1bfe4bb006105ef565b5f80807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0841115610f2b57505f91506003905082610fb0565b604080515f808252602082018084528a905260ff891692820192909252606081018790526080810186905260019060a0016020604051602081039080840390855afa158015610f7c573d5f5f3e3d5ffd5b5050604051601f1901519150506001600160a01b038116610fa757505f925060019150829050610fb0565b92505f91508190505b9450945094915050565b5f826003811115610fcd57610fcd6115b4565b03610fd6575050565b6001826003811115610fea57610fea6115b4565b036110085760405163f645eedf60e01b815260040160405180910390fd5b600282600381111561101c5761101c6115b4565b0361103d5760405163fce698f760e01b81526004810182905260240161068b565b6003826003811115611051576110516115b4565b036108eb576040516335e2f38360e21b81526004810182905260240161068b565b5f5f5160206115e95f395f51905f528161108a610a5b565b8051909150156110a257805160209091012092915050565b815480156110b1579392505050565b7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470935050505090565b5f5f5160206115e95f395f51905f52816110f2610a99565b80519091501561110a57805160209091012092915050565b600182015480156110b1579392505050565b5f81518084525f5b8181101561114057602081850181015186830182015201611124565b505f602082860101526020601f19601f83011685010191505092915050565b602081525f611171602083018461111c565b9392505050565b80356001600160a01b038116811461118e575f5ffd5b919050565b5f5f604083850312156111a4575f5ffd5b6111ad83611178565b946020939093013593505050565b634e487b7160e01b5f52604160045260245ffd5b5f82601f8301126111de575f5ffd5b813567ffffffffffffffff8111156111f8576111f86111bb565b604051601f8201601f19908116603f0116810167ffffffffffffffff81118282101715611227576112276111bb565b60405281815283820160200185101561123e575f5ffd5b816020850160208301375f918101602001919091529392505050565b803560ff8116811461118e575f5ffd5b5f5f5f6060848603121561127c575f5ffd5b833567ffffffffffffffff811115611292575f5ffd5b61129e868287016111cf565b935050602084013567ffffffffffffffff8111156112ba575f5ffd5b6112c6868287016111cf565b9250506112d56040850161125a565b90509250925092565b5f5f5f606084860312156112f0575f5ffd5b6112f984611178565b925061130760208501611178565b929592945050506040919091013590565b5f60208284031215611328575f5ffd5b61117182611178565b60ff60f81b8816815260e060208201525f61134f60e083018961111c565b8281036040840152611361818961111c565b606084018890526001600160a01b038716608085015260a0840186905283810360c0850152845180825260208087019350909101905f5b818110156113b6578351835260209384019390920191600101611398565b50909b9a5050505050505050505050565b5f5f5f5f5f5f5f60e0888a0312156113dd575f5ffd5b6113e688611178565b96506113f460208901611178565b955060408801359450606088013593506114106080890161125a565b9699959850939692959460a0840135945060c09093013592915050565b5f5f6040838503121561143e575f5ffd5b61144783611178565b915061145560208401611178565b90509250929050565b600181811c9082168061147257607f821691505b60208210810361149057634e487b7160e01b5f52602260045260245ffd5b50919050565b601f8211156105d957805f5260205f20601f840160051c810160208510156114bb5750805b601f840160051c820191505b81811015610c18575f81556001016114c7565b815167ffffffffffffffff8111156114f4576114f46111bb565b61150881611502845461145e565b84611496565b6020601f82116001811461153a575f83156115235750848201515b5f19600385901b1c1916600184901b178455610c18565b5f84815260208120601f198516915b828110156115695787850151825560209485019460019092019101611549565b508482101561158657868401515f19600387901b60f8161c191681555b50505050600190811b01905550565b808201808211156103cc57634e487b7160e01b5f52601160045260245ffd5b634e487b7160e01b5f52602160045260245ffdfe52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace00a16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d100a2646970667358221220f0e100f498b6f41fbf597025b81d217623a1e4b7d8ee5bf92572b87e86172a6264736f6c634300081c0033
Deployed Bytecode
0x60806040526004361061039c575f3560e01c806383f24403116101de578063c514f24e11610108578063eabd372a1161009d578063f5efcd791161006d578063f5efcd7914610b32578063f67566e414610b51578063f811bff714610b83578063fb57083414610ba2575f5ffd5b8063eabd372a14610aaa578063ece93c6f14610ac9578063ee25560b14610ae8578063f214e16114610b13575f5ffd5b8063d02103ca116100d8578063d02103ca14610a2f578063d9cb3aec14610a57578063dbc1697614610a82578063e88f043614610a96575f5ffd5b8063c514f24e146109ca578063cc461632146109de578063ccaa2d11146109fd578063cd58657914610a1c575f5ffd5b8063b0b379201161017e578063be5831c71161014e578063be5831c71461093b578063bf130d7f1461095e578063c00f14ab1461097d578063c0f491631461099c575f5ffd5b8063b0b37920146108bd578063b4586962146108dc578063b8b284d0146108fb578063bab161bf1461091a575f5ffd5b80638c668f1c116101b95780638c668f1c1461084c5780638d942096146108605780638ed7e3f21461087f578063ae24490a1461089e575f5ffd5b806383f24403146107fa5780638b37b873146108195780638bd309c31461082d575f5ffd5b80633b2fee9a116102ca57806365d6f6541161025f5780636ee84b231161022f5780636ee84b231461078957806379e2cf971461079e5780638129fc1c146107b257806381b1c174146107c6575f5ffd5b806365d6f654146106f857806369e3ab121461072c5780636e4ecfed1461074b5780636e974cd41461076a575f5ffd5b80634b2f336d1161029a5780634b2f336d1461068757806357cfbee3146106a65780635ca1e165146106c5578063606617ff146106d9575f5ffd5b80633b2fee9a146105df5780633c351e10146106115780633cbc795b146106305780633e19704314610668575f5ffd5b806322e95f2c116103405780632f84c690116103105780632f84c69014610508578063318aee3d14610527578063381fef6d1461058f57806338b8fbbb146105c2575f5ffd5b806322e95f2c146104a0578063240ff378146104bf57806327aef4e8146104d25780632dfdf0b5146104f3575f5ffd5b806314cc01a01161037b57806314cc01a01461042157806315064c96146104405780631d081d8c146104695780632072f6c51461048c575f5ffd5b80626ee171146103a057806303e6e116146103c1578063136a2c6014610402575b5f5ffd5b3480156103ab575f5ffd5b506103bf6103ba366004614704565b610bc1565b005b3480156103cc575f5ffd5b5060a8546103e59061010090046001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b34801561040d575f5ffd5b506103bf61041c366004614818565b6110c1565b34801561042c575f5ffd5b5060a3546103e5906001600160a01b031681565b34801561044b575f5ffd5b506068546104599060ff1681565b60405190151581526020016103f9565b348015610474575f5ffd5b5061047e60a55481565b6040519081526020016103f9565b348015610497575f5ffd5b506103bf61121f565b3480156104ab575f5ffd5b506103e56104ba36600461489f565b611254565b6103bf6104cd366004614919565b6112a2565b3480156104dd575f5ffd5b506104e6611312565b6040516103f991906149db565b3480156104fe575f5ffd5b5061047e60535481565b348015610513575f5ffd5b5060a4546103e5906001600160a01b031681565b348015610532575f5ffd5b5061056b6105413660046149ed565b606b6020525f908152604090205463ffffffff81169064010000000090046001600160a01b031682565b6040805163ffffffff90931683526001600160a01b039091166020830152016103f9565b34801561059a575f5ffd5b506103e57f000000000000000000000000357e3fc9b1a802c12fb6bf8203d8bdaa610c6e4d81565b3480156105cd575f5ffd5b506070546001600160a01b03166103e5565b3480156105ea575f5ffd5b507f000000000000000000000000d0da4f796e183d398af4797426dc25aa3a32f4306103e5565b34801561061c575f5ffd5b50606d546103e5906001600160a01b031681565b34801561063b575f5ffd5b50606d5461065390600160a01b900463ffffffff1681565b60405163ffffffff90911681526020016103f9565b348015610673575f5ffd5b5061047e610682366004614a16565b61139e565b348015610692575f5ffd5b50606f546103e5906001600160a01b031681565b3480156106b1575f5ffd5b506103bf6106c0366004614b62565b61142f565b3480156106d0575f5ffd5b5061047e61151b565b3480156106e4575f5ffd5b5060aa546103e5906001600160a01b031681565b348015610703575f5ffd5b506104e660405180604001604052806009815260200168616c2d76302e332e3160b81b81525081565b348015610737575f5ffd5b506103bf6107463660046149ed565b61159a565b348015610756575f5ffd5b506070546103e5906001600160a01b031681565b348015610775575f5ffd5b506103bf610784366004614c79565b61163d565b348015610794575f5ffd5b5061047e60a65481565b3480156107a9575f5ffd5b506103bf611991565b3480156107bd575f5ffd5b506103bf6119b2565b3480156107d1575f5ffd5b506103e56107e0366004614cbf565b606a6020525f90815260409020546001600160a01b031681565b348015610805575f5ffd5b5061047e610814366004614ce7565b6119cb565b348015610824575f5ffd5b506103bf611a5a565b348015610838575f5ffd5b506103bf6108473660046149ed565b611aeb565b348015610857575f5ffd5b506103bf611b72565b34801561086b575f5ffd5b506103bf61087a3660046149ed565b611c03565b34801561088a575f5ffd5b50606c546103e5906001600160a01b031681565b3480156108a9575f5ffd5b5060a9546103e5906001600160a01b031681565b3480156108c8575f5ffd5b506103bf6108d7366004614d23565b611c8a565b3480156108e7575f5ffd5b506103bf6108f63660046149ed565b611dda565b348015610906575f5ffd5b506103bf610915366004614d7b565b611f35565b348015610925575f5ffd5b5060685461065390610100900463ffffffff1681565b348015610946575f5ffd5b5060685461065390600160c81b900463ffffffff1681565b348015610969575f5ffd5b506103bf610978366004614df9565b611fb3565b348015610988575f5ffd5b506104e66109973660046149ed565b611fe8565b3480156109a7575f5ffd5b506104596109b63660046149ed565b60a26020525f908152604090205460ff1681565b3480156109d5575f5ffd5b506104e661202d565b3480156109e9575f5ffd5b506104596109f8366004614e25565b6120b6565b348015610a08575f5ffd5b506103bf610a17366004614e56565b612107565b6103bf610a2a366004614f35565b612523565b348015610a3a575f5ffd5b506068546103e5906501000000000090046001600160a01b031681565b348015610a62575f5ffd5b5061047e610a71366004614cbf565b60a76020525f908152604090205481565b348015610a8d575f5ffd5b506103bf6128bf565b348015610aa1575f5ffd5b506103bf6128f2565b348015610ab5575f5ffd5b506103bf610ac43660046149ed565b6129a1565b348015610ad4575f5ffd5b506071546103e5906001600160a01b031681565b348015610af3575f5ffd5b5061047e610b02366004614cbf565b60696020525f908152604090205481565b348015610b1e575f5ffd5b506103e5610b2d36600461489f565b612a41565b348015610b3d575f5ffd5b506103bf610b4c366004614e56565b612b0c565b348015610b5c575f5ffd5b506104e6604051806040016040528060078152602001663b18981718971960c91b81525081565b348015610b8e575f5ffd5b506103bf610b9d366004614fc5565b612d6c565b348015610bad575f5ffd5b50610459610bbc366004615055565b612e3f565b5f54600390610100900460ff16158015610be157505f5460ff8083169116105b610c495760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084015b60405180910390fd5b5f805461ffff191660ff8316176101001790556001600160a01b038a16610c835760405163f6b2911f60e01b815260040160405180910390fd5b8c63ffffffff165f03610ca957604051634e702fa560e01b815260040160405180910390fd5b8c606860016101000a81548163ffffffff021916908363ffffffff16021790555089606860056101000a8154816001600160a01b0302191690836001600160a01b0316021790555088606c5f6101000a8154816001600160a01b0302191690836001600160a01b031602179055508660a35f6101000a8154816001600160a01b0302191690836001600160a01b031602179055508360a45f6101000a8154816001600160a01b0302191690836001600160a01b031602179055507f85d2bdfbe58cd81abf8199c13ce2509204be4aba8603b9d29f52c4e13e7bb7935f60a45f9054906101000a90046001600160a01b0316604051610dbd9291906001600160a01b0392831681529116602082015260400190565b60405180910390a160a980546001600160a01b0319166001600160a01b038516908117909155604080515f815260208101929092527f24cc8295aa5110cc216695db944ad2458c7795c6404449be980c3ce14aed752d910160405180910390a1306001600160a01b03831603610e4657604051631ae0e03360e01b815260040160405180910390fd5b6001600160a01b038216610e6d5760405163f6b2911f60e01b815260040160405180910390fd5b607080546001600160a01b0319166001600160a01b038416908117909155604080515f815260208101929092527fa9da6fb8c39e9c2fafda878eac316815987bdc948d241ba6d75ed035e0e829f2910160405180910390a16001600160a01b038c16610f2f5763ffffffff8b1615610ef857604051630d43a60960e11b815260040160405180910390fd5b6001600160a01b038616151580610f0c5750845b15610f2a57604051630e6e237560e11b815260040160405180910390fd5b61106a565b606d805463ffffffff8d16600160a01b026001600160c01b03199091166001600160a01b038f1617179055606e610f668982615116565b506001600160a01b03861661103257841515600103610f9857604051630e6e237560e11b815260040160405180910390fd5b61100d5f5f1b6012604051602001610ff991906060808252600d908201526c2bb930b83832b21022ba3432b960991b608082015260a060208201819052600490820152630ae8aa8960e31b60c082015260ff91909116604082015260e00190565b604051602081830303815290604052612e56565b606f80546001600160a01b0319166001600160a01b039290921691909117905561106a565b606f80546001600160a01b0319166001600160a01b0388169081179091555f90815260a260205260409020805460ff19168615151790555b611072612f37565b5f805461ff001916905560405160ff821681527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a150505050505050505050505050565b606854604080516391eb796d60e01b8152905133926501000000000090046001600160a01b0316916391eb796d9160048083019260209291908290030181865afa158015611111573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061113591906151d1565b6001600160a01b03161461115c5760405163a34ddeb160e01b815260040160405180910390fd5b5f5b815181101561121b575f82828151811061117a5761117a6151ec565b602002602001015190505f5f6801000000000000000083165f146111a0578291506111b7565b602083901c6111b0816001615214565b9150839250505b6111c18282612fa9565b60a6545f90815260208490526040902060a68190556040805185815260208101929092527fc80e0aca446a59735359a7ae46124b57c47b892827642779bc6dafc84ba90b03910160405180910390a150505060010161115e565b5050565b60a4546001600160a01b0316331461124a57604051631344c5df60e11b815260040160405180910390fd5b61125261301b565b565b5f606a5f848460405160200161126b929190615230565b60408051601f198184030181529181528151602092830120835290820192909252015f20546001600160a01b031690505b92915050565b60685460ff16156112c657604051630bc011ff60e21b815260040160405180910390fd5b34158015906112df5750606f546001600160a01b031615155b156112fd576040516301bd897160e61b815260040160405180910390fd5b61130b858534868686613076565b5050505050565b606e805461131f9061509a565b80601f016020809104026020016040519081016040528092919081815260200182805461134b9061509a565b80156113965780601f1061136d57610100808354040283529160200191611396565b820191905f5260205f20905b81548152906001019060200180831161137957829003601f168201915b505050505081565b6040516001600160f81b031960f889901b1660208201526001600160e01b031960e088811b821660218401526bffffffffffffffffffffffff19606089811b821660258601529188901b909216603984015285901b16603d82015260518101839052607181018290525f90609101604051602081830303815290604052805190602001209050979650505050505050565b60a3546001600160a01b0316331461145a576040516357b738d160e11b815260040160405180910390fd5b8251845114158061146d57508151845114155b8061147a57508051845114155b156114985760405163434f49f560e11b815260040160405180910390fd5b5f5b825181101561130b576115138582815181106114b8576114b86151ec565b60200260200101518583815181106114d2576114d26151ec565b60200260200101518584815181106114ec576114ec6151ec565b6020026020010151858581518110611506576115066151ec565b602002602001015161314a565b60010161149a565b6053545f90819081805b6020811015611591578083901c60011660010361156a5761156360338260208110611552576115526151ec565b0154855f9182526020526040902090565b935061157a565b5f84815260208390526040902093505b5f8281526020839052604090209150600101611525565b50919392505050565b60a4546001600160a01b031633146115c557604051631344c5df60e11b815260040160405180910390fd5b60a8805474ffffffffffffffffffffffffffffffffffffffff0019166101006001600160a01b038481169182029290921790925560a4546040805191909216815260208101929092527fb27de219766f47b82684842855ba6130b6dbf288ac66d1c3509e7bf17f4e925a91015b60405180910390a150565b60a3546001600160a01b03163314611668576040516357b738d160e11b815260040160405180910390fd5b6001600160a01b038216158015611683575063ffffffff8316155b15611813575f6118015f5f1b606f5f9054906101000a90046001600160a01b03166001600160a01b03166306fdde036040518163ffffffff1660e01b81526004015f60405180830381865afa1580156116de573d5f5f3e3d5ffd5b505050506040513d5f823e601f3d908101601f1916820160405261170591908101906152ab565b606f5f9054906101000a90046001600160a01b03166001600160a01b03166395d89b416040518163ffffffff1660e01b81526004015f60405180830381865afa158015611754573d5f5f3e3d5ffd5b505050506040513d5f823e601f3d908101601f1916820160405261177b91908101906152ab565b606f5f9054906101000a90046001600160a01b03166001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156117cb573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906117ef91906152dd565b604051602001610ff9939291906152f8565b905061180d81836132fc565b50505050565b5f8383604051602001611827929190615230565b60408051601f1981840301815291815281516020928301205f818152606a9093529120549091506001600160a01b0316806118755760405163828d566360e01b815260040160405180910390fd5b5f61197a83836001600160a01b03166306fdde036040518163ffffffff1660e01b81526004015f60405180830381865afa1580156118b5573d5f5f3e3d5ffd5b505050506040513d5f823e601f3d908101601f191682016040526118dc91908101906152ab565b846001600160a01b03166395d89b416040518163ffffffff1660e01b81526004015f60405180830381865afa158015611917573d5f5f3e3d5ffd5b505050506040513d5f823e601f3d908101601f1916820160405261193e91908101906152ab565b856001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156117cb573d5f5f3e3d5ffd5b90506119888686838761314a565b5050505b505050565b605354606854600160c81b900463ffffffff1610156112525761125261339b565b60405163f57ac68360e01b815260040160405180910390fd5b5f83815b6020811015611a4f57600163ffffffff8516821c81169003611a1b57611a14858260208110611a0057611a006151ec565b6020020135835f9182526020526040902090565b9150611a47565b611a4482868360208110611a3157611a316151ec565b60200201355f9182526020526040902090565b91505b6001016119cf565b5090505b9392505050565b60aa546001600160a01b03163314611a855760405163d491f0c160e01b815260040160405180910390fd5b60a9805460aa80546001600160a01b038082166001600160a01b0319808616821790965594909116909155604080519190921680825260208201939093527f85d2bdfbe58cd81abf8199c13ce2509204be4aba8603b9d29f52c4e13e7bb7939101611632565b6070546001600160a01b03163314611b1657604051630866750360e01b815260040160405180910390fd5b607180546001600160a01b0319166001600160a01b038381169182179092556070546040805191909316815260208101919091527f0a34baa3feb299aef9c05cb59c6e0c8e7c0bcc65cbf0a647e7a7c8a2411591e29101611632565b6071546001600160a01b03163314611b9d57604051630b59ef2760e21b815260040160405180910390fd5b60708054607180546001600160a01b038082166001600160a01b0319808616821790965594909116909155604080519190921680825260208201939093527fa9da6fb8c39e9c2fafda878eac316815987bdc948d241ba6d75ed035e0e829f29101611632565b60a9546001600160a01b03163314611c2e57604051638e9d821f60e01b815260040160405180910390fd5b60aa80546001600160a01b0319166001600160a01b0383811691821790925560a9546040805191909316815260208101919091527ff01a62a06940517bbc898dec8c75794b9feabcd2d263c8de823b36dbbeb8779b9101611632565b8015611c9b57611c9b84838361342b565b6001600160a01b038085165f908152606b602090815260409182902082518084019093525463ffffffff81168352640100000000900490921691810182905290611cf85760405163828d566360e01b815260040160405180910390fd5b5f606a5f835f01518460200151604051602001611d16929190615230565b60408051601f198184030181529181528151602092830120835290820192909252015f20546001600160a01b03908116915086168103611d695760405163e273c4a160e01b815260040160405180910390fd5b5f611d748787613745565b9050611d818233836138c4565b604080513381526001600160a01b0389811660208301528416818301526060810183905290517fb7f8fd4d1faf9b2929dc269f59c53e3a2bccc44e9950f33a568fcbcb37eb69a99181900360800190a150505050505050565b60a3546001600160a01b03163314611e05576040516357b738d160e11b815260040160405180910390fd5b6001600160a01b038082165f908152606b6020908152604080832081518083018352905463ffffffff811680835264010000000090910490951681840181905291519094611e569390929101615230565b60408051601f1981840301815291815281516020928301205f818152606a9093529120549091506001600160a01b03161580611eaa57505f818152606a60205260409020546001600160a01b038481169116145b15611ec85760405163e0c897a760e01b815260040160405180910390fd5b6001600160a01b0383165f818152606b6020908152604080832080546001600160c01b031916905560a2825291829020805460ff1916905590519182527fc2ae0bd0ec0fd0352bfe5bacac49637af342c1e40f1b80a7f74440dc7fe3f063910160405180910390a1505050565b60685460ff1615611f5957604051630bc011ff60e21b815260040160405180910390fd5b606f546001600160a01b0316611f825760405163dde3cda760e01b815260040160405180910390fd5b606f545f90611f9a906001600160a01b031686613745565b9050611faa878783878787613076565b50505050505050565b60a3546001600160a01b03163314611fde576040516357b738d160e11b815260040160405180910390fd5b61121b82826132fc565b6060611ff382613951565b611ffc83613a14565b61200584613ac8565b604051602001612017939291906152f8565b6040516020818303038152906040529050919050565b60607f000000000000000000000000357e3fc9b1a802c12fb6bf8203d8bdaa610c6e4d6001600160a01b031663c514f24e6040518163ffffffff1660e01b81526004015f60405180830381865afa15801561208a573d5f5f3e3d5ffd5b505050506040513d5f823e601f3d908101601f191682016040526120b19190810190615330565b905090565b5f806120cd64010000000063ffffffff8516615375565b6120dd9063ffffffff861661538c565b600881901c5f90815260696020526040902054600160ff9092169190911b90811614949350505050565b60685460ff161561212b57604051630bc011ff60e21b815260040160405180910390fd5b612133613b7c565b60685463ffffffff8681166101009092041614612163576040516302caf51760e11b815260040160405180910390fd5b61218e8c8c8c8c8c5f8d8d8d8d8d8d8d60405161218192919061539f565b6040518091039020613bd5565b604080518b815263ffffffff891660208201526001600160a01b0388811682840152861660608201526080810185905290517f1df3f2a973a00d6635911755c260704e95e8a5876997546798770f76396fda4d9181900360a00190a16001600160a01b038616158015612205575063ffffffff8716155b156122e357606f546001600160a01b03166122c7575f6001600160a01b03851684825b6040519080825280601f01601f191660200182016040528015612252576020820181803683370190505b5060405161226091906153ae565b5f6040518083038185875af1925050503d805f811461229a576040519150601f19603f3d011682016040523d82523d5f602084013e61229f565b606091505b50509050806122c157604051630ce8f45160e31b815260040160405180910390fd5b5061250c565b606f546122de906001600160a01b031685856138c4565b61250c565b606d546001600160a01b0387811691161480156123115750606d5463ffffffff888116600160a01b90920416145b15612328575f6001600160a01b0385168482612228565b60685463ffffffff610100909104811690881603612354576122de6001600160a01b0387168585613c85565b5f8787604051602001612368929190615230565b60408051601f1981840301815291815281516020928301205f818152606a9093529120549091506001600160a01b0316806124fe575f6123dd8386868080601f0160208091040260200160405190810160405280939291908181526020018383808284375f92019190915250612e5692505050565b90506123ea8188886138c4565b80606a5f8581526020019081526020015f205f6101000a8154816001600160a01b0302191690836001600160a01b0316021790555060405180604001604052808b63ffffffff1681526020018a6001600160a01b0316815250606b5f836001600160a01b03166001600160a01b031681526020019081526020015f205f820151815f015f6101000a81548163ffffffff021916908363ffffffff1602179055506020820151815f0160046101000a8154816001600160a01b0302191690836001600160a01b031602179055509050507f490e59a1701b938786ac72570a1efeac994a3dbe96e2e883e19e902ace6e6a398a8a8388886040516124f09594939291906153f1565b60405180910390a150612509565b6125098187876138c4565b50505b61251560018055565b505050505050505050505050565b60685460ff161561254757604051630bc011ff60e21b815260040160405180910390fd5b61254f613b7c565b60685463ffffffff610100909104811690881603612580576040516302caf51760e11b815260040160405180910390fd5b5f806060876001600160a01b038816612663578834146125b35760405163b89240f560e01b815260040160405180910390fd5b606d54606e80546001600160a01b0383169650600160a01b90920463ffffffff169450906125e09061509a565b80601f016020809104026020016040519081016040528092919081815260200182805461260c9061509a565b80156126575780601f1061262e57610100808354040283529160200191612657565b820191905f5260205f20905b81548152906001019060200180831161263a57829003601f168201915b50505050509150612847565b34156126825760405163798ee6f160e01b815260040160405180910390fd5b84156126935761269388878761342b565b606f546001600160a01b03908116908916036126ba576126b3888a613745565b9050612847565b6001600160a01b038089165f908152606b602090815260409182902082518084019093525463ffffffff8116835264010000000090049092169181018290529015158061270d5750805163ffffffff1615155b1561272f5761271c898b613745565b602082015182519096509450915061283a565b6040516370a0823160e01b81523060048201525f906001600160a01b038b16906370a0823190602401602060405180830381865afa158015612773573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906127979190615439565b90506127ae6001600160a01b038b1633308e613cea565b6040516370a0823160e01b81523060048201525f906001600160a01b038c16906370a0823190602401602060405180830381865afa1580156127f2573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906128169190615439565b90506128228282615450565b6068548c9850610100900463ffffffff169650935050505b61284389611fe8565b9250505b7f501781209a1f8899323b96b4ef08b168df93e0a90c673d1e4cce39366cb62f9b5f84868e8e8688605354604051612886989796959493929190615463565b60405180910390a16128a45f84868e8e868880519060200120613d23565b86156128b2576128b261339b565b50505050611faa60018055565b60a9546001600160a01b031633146128ea57604051638e9d821f60e01b815260040160405180910390fd5b611252613d5b565b60a85461010090046001600160a01b0316331461292257604051637bb0100f60e01b815260040160405180910390fd5b60a4805460a880546001600160a01b03610100820481166001600160a01b03198516811790955574ffffffffffffffffffffffffffffffffffffffff0019909116909155604080519190921680825260208201939093527f85d2bdfbe58cd81abf8199c13ce2509204be4aba8603b9d29f52c4e13e7bb7939101611632565b60a3546001600160a01b031633146129cc576040516357b738d160e11b815260040160405180910390fd5b6001600160a01b0381166129f35760405163f6b2911f60e01b815260040160405180910390fd5b60a380546001600160a01b0319166001600160a01b0383169081179091556040519081527f32cf74f8a6d5f88593984d2cd52be5592bfa6884f5896175801a5069ef09cd6790602001611632565b5f5f8383604051602001612a56929190615230565b6040516020818303038152906040528051906020012090505f60ff60f81b3083612a7e61202d565b604051602001612a8e91906153ae565b60405160208183030381529060405280519060200120604051602001612aeb94939291906001600160f81b031994909416845260609290921b6bffffffffffffffffffffffff191660018401526015830152603582015260550190565b60408051808303601f19018152919052805160209091012095945050505050565b60685460ff1615612b3057604051630bc011ff60e21b815260040160405180910390fd5b60685463ffffffff8681166101009092041614612b60576040516302caf51760e11b815260040160405180910390fd5b612b7f8c8c8c8c8c60018d8d8d8d8d8d8d60405161218192919061539f565b604080518b815263ffffffff891660208201526001600160a01b0388811682840152861660608201526080810185905290517f1df3f2a973a00d6635911755c260704e95e8a5876997546798770f76396fda4d9181900360a00190a1606f545f906001600160a01b0316612c8e57846001600160a01b031684888a8686604051602401612c0f94939291906154d7565b60408051601f198184030181529181526020820180516001600160e01b0316630c035af960e11b17905251612c4491906153ae565b5f6040518083038185875af1925050503d805f8114612c7e576040519150601f19603f3d011682016040523d82523d5f602084013e612c83565b606091505b505080915050612d3f565b606f54612ca5906001600160a01b031686866138c4565b846001600160a01b031687898585604051602401612cc694939291906154d7565b60408051601f198184030181529181526020820180516001600160e01b0316630c035af960e11b17905251612cfb91906153ae565b5f604051808303815f865af19150503d805f8114612d34576040519150601f19603f3d011682016040523d82523d5f602084013e612d39565b606091505b50909150505b80612d5d576040516337e391c360e01b815260040160405180910390fd5b50505050505050505050505050565b5f54610100900460ff1615808015612d8a57505f54600160ff909116105b80612da35750303b158015612da357505f5460ff166001145b612e065760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610c40565b5f805460ff1916600117905580156119b2575f805461ff00191661010017905560405163f57ac68360e01b815260040160405180910390fd5b5f81612e4c8686866119cb565b1495945050505050565b5f5f612e6061202d565b604051602001612e7091906153ae565b6040516020818303038152906040529050838151602083015ff591506001600160a01b038216612eb3576040516331682e8d60e11b815260040160405180910390fd5b5f5f5f85806020019051810190612eca9190615505565b925092509250846001600160a01b0316631624f6c68484846040518463ffffffff1660e01b8152600401612f00939291906152f8565b5f604051808303815f87803b158015612f17575f5ffd5b505af1158015612f29573d5f5f3e3d5ffd5b505050505050505092915050565b5f54610100900460ff16612fa15760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608401610c40565b611252613db2565b5f612fbf64010000000063ffffffff8416615375565b612fcf9063ffffffff851661538c565b600881901c5f8181526069602052604090208054600160ff851690811b918218928390559394509192919080821615611faa57604051630631b5f760e31b815260040160405180910390fd5b60685460ff161561303f57604051630bc011ff60e21b815260040160405180910390fd5b6068805460ff191660011790556040517f2261efe5aef6fedc1fd1550b25facc9181745623049c7901287030b9ad1a5497905f90a1565b60685463ffffffff6101009091048116908716036130a7576040516302caf51760e11b815260040160405180910390fd5b7f501781209a1f8899323b96b4ef08b168df93e0a90c673d1e4cce39366cb62f9b6001606860019054906101000a900463ffffffff163389898988886053546040516130fb99989796959493929190615572565b60405180910390a161313c6001606860019054906101000a900463ffffffff1633898989888860405161312f92919061539f565b6040518091039020613d23565b82156119885761198861339b565b6001600160a01b038316158061316757506001600160a01b038216155b156131855760405163f6b2911f60e01b815260040160405180910390fd5b60685463ffffffff6101009091048116908516036131b65760405163658b23ad60e01b815260040160405180910390fd5b6001600160a01b038281165f908152606b6020526040902054640100000000900416156131f6576040516317abdeeb60e21b815260040160405180910390fd5b5f848460405160200161320a929190615230565b60408051808303601f1901815282825280516020918201205f818152606a835283812080546001600160a01b0319166001600160a01b038a8116918217909255868601865263ffffffff8c81168089528c8416878a01818152848752606b89528987209a518b54915194166001600160c01b03199091161764010000000093909516929092029390931790975560a2855291859020805460ff191689151590811790915585519182529381019590955292840192909252606083015291507fdbe8a5da6a7a916d9adfda9160167a0f8a3da415ee6610e810e753853597fce79060800160405180910390a15050505050565b606d546001600160a01b031661332557604051634cb4711360e11b815260040160405180910390fd5b606f80546001600160a01b0319166001600160a01b0384169081179091555f81815260a26020908152604091829020805460ff19168515159081179091558251938452908301527fc7318b7ed6ba4f2908a3de396d8ab49b1dadb55db5b55123247a401f29ff8d82910160405180910390a15050565b6053546068805463ffffffff909216600160c81b0263ffffffff60c81b1990921691909117908190556001600160a01b0365010000000000909104166333d6247d6133e461151b565b6040518263ffffffff1660e01b815260040161340291815260200190565b5f604051808303815f87803b158015613419575f5ffd5b505af115801561180d573d5f5f3e3d5ffd5b5f61343960048284866155e8565b6134429161560f565b9050632afa533160e01b6001600160e01b03198216016135b1575f808080808080613470896004818d6155e8565b81019061347d9190615647565b9650965096509650965096509650336001600160a01b0316876001600160a01b0316146134bd5760405163912ecce760e01b815260040160405180910390fd5b6001600160a01b03861630146134e65760405163750643af60e01b815260040160405180910390fd5b604080516001600160a01b0389811660248301528881166044830152606482018890526084820187905260ff861660a483015260c4820185905260e48083018590528351808403909101815261010490920183526020820180516001600160e01b031663d505accf60e01b1790529151918d169161356491906153ae565b5f604051808303815f865af19150503d805f811461359d576040519150601f19603f3d011682016040523d82523d5f602084013e6135a2565b606091505b5050505050505050505061180d565b6001600160e01b031981166323f2ebc360e21b146135e257604051637141605d60e11b815260040160405180910390fd5b5f808080808080806135f78a6004818e6155e8565b8101906136049190615696565b97509750975097509750975097509750336001600160a01b0316886001600160a01b0316146136465760405163912ecce760e01b815260040160405180910390fd5b6001600160a01b038716301461366f5760405163750643af60e01b815260040160405180910390fd5b604080516001600160a01b038a811660248301528981166044830152606482018990526084820188905286151560a483015260ff861660c483015260e482018590526101048083018590528351808403909101815261012490920183526020820180516001600160e01b03166323f2ebc360e21b1790529151918e16916136f691906153ae565b5f604051808303815f865af19150503d805f811461372f576040519150601f19603f3d011682016040523d82523d5f602084013e613734565b606091505b505050505050505050505050505050565b6001600160a01b0382165f90815260a2602052604081205460ff1615613861576040516370a0823160e01b81523060048201525f906001600160a01b038516906370a0823190602401602060405180830381865afa1580156137a9573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906137cd9190615439565b90506137e46001600160a01b038516333086613cea565b6040516370a0823160e01b81523060048201525f906001600160a01b038616906370a0823190602401602060405180830381865afa158015613828573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061384c9190615439565b90506138588282615450565b9250505061129c565b604051632770a7eb60e21b8152336004820152602481018390526001600160a01b03841690639dc29fac906044015f604051808303815f87803b1580156138a6575f5ffd5b505af11580156138b8573d5f5f3e3d5ffd5b5050505081905061129c565b6001600160a01b0383165f90815260a2602052604090205460ff16156138f85761198c6001600160a01b0384168383613c85565b6040516340c10f1960e01b81526001600160a01b038381166004830152602482018390528416906340c10f19906044015f604051808303815f87803b15801561393f575f5ffd5b505af1158015611faa573d5f5f3e3d5ffd5b60408051600481526024810182526020810180516001600160e01b03166306fdde0360e01b17905290516060915f9182916001600160a01b0386169161399791906153ae565b5f60405180830381855afa9150503d805f81146139cf576040519150601f19603f3d011682016040523d82523d5f602084013e6139d4565b606091505b509150915081613a0357604051806040016040528060078152602001664e4f5f4e414d4560c81b815250613a0c565b613a0c81613e1c565b949350505050565b60408051600481526024810182526020810180516001600160e01b03166395d89b4160e01b17905290516060915f9182916001600160a01b03861691613a5a91906153ae565b5f60405180830381855afa9150503d805f8114613a92576040519150601f19603f3d011682016040523d82523d5f602084013e613a97565b606091505b509150915081613a0357604051806040016040528060098152602001681393d7d4d6535093d360ba1b815250613a0c565b60408051600481526024810182526020810180516001600160e01b031663313ce56760e01b17905290515f91829182916001600160a01b03861691613b0d91906153ae565b5f60405180830381855afa9150503d805f8114613b45576040519150601f19603f3d011682016040523d82523d5f602084013e613b4a565b606091505b5091509150818015613b5d575080516020145b613b68576012613a0c565b80806020019051810190613a0c91906152dd565b600260015403613bce5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610c40565b6002600155565b5f613be58888888888888861139e565b9050613bf58d8d8d8d8d86613fb4565b60a554613c1d90613c0f8d845f9182526020526040902090565b5f9182526020526040902090565b60a5819055604080518d815260208101929092527f3e5936f910a78eb5181813a939c8d4c3e4d85f87943f659380d82ac6221b0e92910160405180910390a160ff8816613c6f57613c6f87878561417a565b5f1960ff891601612d5d57612d5d5f5f8561417a565b6040516001600160a01b0383811660248301526044820183905261198c91859182169063a9059cbb906064015b604051602081830303815290604052915060e01b6020820180516001600160e01b03838183161783525050505061425a565b60018055565b6040516001600160a01b03848116602483015283811660448301526064820183905261180d9186918216906323b872dd90608401613cb2565b613d32878787878787876142bb565b60ff8716613d4557613d458686846142d2565b5f1960ff881601611faa57611faa5f5f846142d2565b60685460ff16613d7e57604051635386698160e01b815260040160405180910390fd5b6068805460ff191690556040517f1e5e34eea33501aecf2ebec9fe0e884a40804275ea7fe10b2ba084c8374308b3905f90a1565b5f54610100900460ff16613ce45760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608401610c40565b60606040825110613e3b578180602001905181019061129c91906152ab565b8151602003613f81575f5b602081108015613e755750828181518110613e6357613e636151ec565b01602001516001600160f81b03191615155b15613e8c5780613e8481615714565b915050613e46565b805f03613ec35750506040805180820190915260128152714e4f545f56414c49445f454e434f44494e4760701b6020820152919050565b5f8167ffffffffffffffff811115613edd57613edd61462e565b6040519080825280601f01601f191660200182016040528015613f07576020820181803683370190505b5090505f5b82811015613f7957848181518110613f2657613f266151ec565b602001015160f81c60f81b828281518110613f4357613f436151ec565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff191690815f1a905350600101613f0c565b509392505050565b50506040805180820190915260128152714e4f545f56414c49445f454e434f44494e4760701b602082015290565b919050565b6068545f906501000000000090046001600160a01b031663257b3632613fe386865f9182526020526040902090565b6040518263ffffffff1660e01b815260040161400191815260200190565b6020604051808303815f875af115801561401d573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906140419190615439565b9050805f0361406257604051622f6fad60e01b815260040160405180910390fd5b5f80680100000000000000008716156140de578691508161409263ffffffff82166801000000000000000061538c565b146140b05760405163071389e960e01b815260040160405180910390fd5b6140bc848a8489612e3f565b6140d9576040516338105f3b60e21b815260040160405180910390fd5b614165565b602087901c6140ee816001615214565b88935091508261411263ffffffff821667ffffffff00000000602085901b1661538c565b146141305760405163071389e960e01b815260040160405180910390fd5b61414661413e868c866119cb565b8a8389612e3f565b614163576040516338105f3b60e21b815260040160405180910390fd5b505b61416f828261439c565b505050505050505050565b60685463ffffffff61010090910481169084160361419757505050565b5f83836040516020016141ab929190615230565b60408051601f1981840301815291815281516020928301205f81815260a79093529120549091506141dd905f19615450565b821115614232575f81815260a76020526040908190205490516323d7213360e01b815263ffffffff861660048201526001600160a01b0385166024820152604481018490526064810191909152608401610c40565b5f81815260a760205260408120805484929061424f90849061538c565b909155505050505050565b5f61426e6001600160a01b0384168361440f565b905080515f14158015614292575080806020019051810190614290919061572c565b155b1561198c57604051635274afe760e01b81526001600160a01b0384166004820152602401610c40565b611faa6142cd8888888888888861139e565b61441c565b60685463ffffffff6101009091048116908416036142ef57505050565b5f8383604051602001614303929190615230565b60408051601f1981840301815291815281516020928301205f81815260a790935291205490915082111561437f575f81815260a76020526040908190205490516314603c0160e01b815263ffffffff861660048201526001600160a01b0385166024820152604481018490526064810191909152608401610c40565b5f81815260a760205260408120805484929061424f908490615450565b5f6143b264010000000063ffffffff8416615375565b6143c29063ffffffff851661538c565b600881901c5f8181526069602052604081208054600160ff861690811b91821892839055949550929392918183169003611faa57604051630c8d9eab60e31b815260040160405180910390fd5b6060611a5383835f6144db565b80600161442b6020600261582a565b6144359190615450565b60535410614456576040516377ae67b360e11b815260040160405180910390fd5b5f60535f815461446590615714565b918290555090505f5b60208110156144d2578082901c6001166001036144a1578260338260208110614499576144996151ec565b015550505050565b6144c8603382602081106144b7576144b76151ec565b0154845f9182526020526040902090565b925060010161446e565b5061198c615835565b6060814710156145005760405163cd78605960e01b8152306004820152602401610c40565b5f5f856001600160a01b0316848660405161451b91906153ae565b5f6040518083038185875af1925050503d805f8114614555576040519150601f19603f3d011682016040523d82523d5f602084013e61455a565b606091505b509150915061456a868383614574565b9695505050505050565b60608261458957614584826145d0565b611a53565b81511580156145a057506001600160a01b0384163b155b156145c957604051639996b31560e01b81526001600160a01b0385166004820152602401610c40565b5080611a53565b8051156145e05780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b50565b803563ffffffff81168114613faf575f5ffd5b6001600160a01b03811681146145f9575f5ffd5b8035613faf8161460f565b634e487b7160e01b5f52604160045260245ffd5b604051601f8201601f1916810167ffffffffffffffff8111828210171561466b5761466b61462e565b604052919050565b5f67ffffffffffffffff82111561468c5761468c61462e565b50601f01601f191660200190565b5f82601f8301126146a9575f5ffd5b81356146bc6146b782614673565b614642565b8181528460208386010111156146d0575f5ffd5b816020850160208301375f918101602001919091529392505050565b80151581146145f9575f5ffd5b8035613faf816146ec565b5f5f5f5f5f5f5f5f5f5f5f5f6101808d8f031215614720575f5ffd5b6147298d6145fc565b9b5061473760208e01614623565b9a5061474560408e016145fc565b995061475360608e01614623565b985061476160808e01614623565b975067ffffffffffffffff60a08e0135111561477b575f5ffd5b61478b8e60a08f01358f0161469a565b965061479960c08e01614623565b95506147a760e08e01614623565b94506147b66101008e016146f9565b93506147c56101208e01614623565b92506147d46101408e01614623565b91506147e36101608e01614623565b90509295989b509295989b509295989b565b5f67ffffffffffffffff82111561480e5761480e61462e565b5060051b60200190565b5f60208284031215614828575f5ffd5b813567ffffffffffffffff81111561483e575f5ffd5b8201601f8101841361484e575f5ffd5b803561485c6146b7826147f5565b8082825260208201915060208360051b85010192508683111561487d575f5ffd5b6020840193505b8284101561456a578335825260209384019390910190614884565b5f5f604083850312156148b0575f5ffd5b6148b9836145fc565b915060208301356148c98161460f565b809150509250929050565b5f5f83601f8401126148e4575f5ffd5b50813567ffffffffffffffff8111156148fb575f5ffd5b602083019150836020828501011115614912575f5ffd5b9250929050565b5f5f5f5f5f6080868803121561492d575f5ffd5b614936866145fc565b945060208601356149468161460f565b93506040860135614956816146ec565b9250606086013567ffffffffffffffff811115614971575f5ffd5b61497d888289016148d4565b969995985093965092949392505050565b5f5b838110156149a8578181015183820152602001614990565b50505f910152565b5f81518084526149c781602086016020860161498e565b601f01601f19169290920160200192915050565b602081525f611a5360208301846149b0565b5f602082840312156149fd575f5ffd5b8135611a538161460f565b60ff811681146145f9575f5ffd5b5f5f5f5f5f5f5f60e0888a031215614a2c575f5ffd5b8735614a3781614a08565b9650614a45602089016145fc565b95506040880135614a558161460f565b9450614a63606089016145fc565b93506080880135614a738161460f565b9699959850939692959460a0840135945060c09093013592915050565b5f82601f830112614a9f575f5ffd5b8135614aad6146b7826147f5565b8082825260208201915060208360051b860101925085831115614ace575f5ffd5b602085015b83811015614af4578035614ae68161460f565b835260209283019201614ad3565b5095945050505050565b5f82601f830112614b0d575f5ffd5b8135614b1b6146b7826147f5565b8082825260208201915060208360051b860101925085831115614b3c575f5ffd5b602085015b83811015614af4578035614b54816146ec565b835260209283019201614b41565b5f5f5f5f60808587031215614b75575f5ffd5b843567ffffffffffffffff811115614b8b575f5ffd5b8501601f81018713614b9b575f5ffd5b8035614ba96146b7826147f5565b8082825260208201915060208360051b850101925089831115614bca575f5ffd5b6020840193505b82841015614bf357614be2846145fc565b825260209384019390910190614bd1565b9650505050602085013567ffffffffffffffff811115614c11575f5ffd5b614c1d87828801614a90565b935050604085013567ffffffffffffffff811115614c39575f5ffd5b614c4587828801614a90565b925050606085013567ffffffffffffffff811115614c61575f5ffd5b614c6d87828801614afe565b91505092959194509250565b5f5f5f60608486031215614c8b575f5ffd5b614c94846145fc565b92506020840135614ca48161460f565b91506040840135614cb4816146ec565b809150509250925092565b5f60208284031215614ccf575f5ffd5b5035919050565b80610400810183101561129c575f5ffd5b5f5f5f6104408486031215614cfa575f5ffd5b83359250614d0b8560208601614cd6565b9150614d1a61042085016145fc565b90509250925092565b5f5f5f5f60608587031215614d36575f5ffd5b8435614d418161460f565b935060208501359250604085013567ffffffffffffffff811115614d63575f5ffd5b614d6f878288016148d4565b95989497509550505050565b5f5f5f5f5f5f60a08789031215614d90575f5ffd5b614d99876145fc565b95506020870135614da98161460f565b9450604087013593506060870135614dc0816146ec565b9250608087013567ffffffffffffffff811115614ddb575f5ffd5b614de789828a016148d4565b979a9699509497509295939492505050565b5f5f60408385031215614e0a575f5ffd5b8235614e158161460f565b915060208301356148c9816146ec565b5f5f60408385031215614e36575f5ffd5b614e3f836145fc565b9150614e4d602084016145fc565b90509250929050565b5f5f5f5f5f5f5f5f5f5f5f5f6109208d8f031215614e72575f5ffd5b614e7c8e8e614cd6565b9b50614e8c8e6104008f01614cd6565b9a506108008d013599506108208d013598506108408d01359750614eb36108608e016145fc565b9650614ec36108808e013561460f565b6108808d01359550614ed86108a08e016145fc565b94506108c08d0135614ee98161460f565b93506108e08d0135925067ffffffffffffffff6109008e01351115614f0c575f5ffd5b614f1d8e6109008f01358f016148d4565b81935080925050509295989b509295989b509295989b565b5f5f5f5f5f5f5f60c0888a031215614f4b575f5ffd5b614f54886145fc565b96506020880135614f648161460f565b9550604088013594506060880135614f7b8161460f565b93506080880135614f8b816146ec565b925060a088013567ffffffffffffffff811115614fa6575f5ffd5b614fb28a828b016148d4565b989b979a50959850939692959293505050565b5f5f5f5f5f5f60c08789031215614fda575f5ffd5b614fe3876145fc565b95506020870135614ff38161460f565b9450615001604088016145fc565b935060608701356150118161460f565b925060808701356150218161460f565b915060a087013567ffffffffffffffff81111561503c575f5ffd5b61504889828a0161469a565b9150509295509295509295565b5f5f5f5f6104608587031215615069575f5ffd5b8435935061507a8660208701614cd6565b925061508961042086016145fc565b939692955092936104400135925050565b600181811c908216806150ae57607f821691505b6020821081036150cc57634e487b7160e01b5f52602260045260245ffd5b50919050565b601f82111561198c57805f5260205f20601f840160051c810160208510156150f75750805b601f840160051c820191505b8181101561130b575f8155600101615103565b815167ffffffffffffffff8111156151305761513061462e565b6151448161513e845461509a565b846150d2565b6020601f821160018114615176575f831561515f5750848201515b5f19600385901b1c1916600184901b17845561130b565b5f84815260208120601f198516915b828110156151a55787850151825560209485019460019092019101615185565b50848210156151c257868401515f19600387901b60f8161c191681555b50505050600190811b01905550565b5f602082840312156151e1575f5ffd5b8151611a538161460f565b634e487b7160e01b5f52603260045260245ffd5b634e487b7160e01b5f52601160045260245ffd5b63ffffffff818116838216019081111561129c5761129c615200565b60e09290921b6001600160e01b031916825260601b6bffffffffffffffffffffffff1916600482015260180190565b5f61526c6146b784614673565b905082815283838301111561527f575f5ffd5b611a5383602083018461498e565b5f82601f83011261529c575f5ffd5b611a538383516020850161525f565b5f602082840312156152bb575f5ffd5b815167ffffffffffffffff8111156152d1575f5ffd5b613a0c8482850161528d565b5f602082840312156152ed575f5ffd5b8151611a5381614a08565b606081525f61530a60608301866149b0565b828103602084015261531c81866149b0565b91505060ff83166040830152949350505050565b5f60208284031215615340575f5ffd5b815167ffffffffffffffff811115615356575f5ffd5b8201601f81018413615366575f5ffd5b613a0c8482516020840161525f565b808202811582820484141761129c5761129c615200565b8082018082111561129c5761129c615200565b818382375f9101908152919050565b5f82516153bf81846020870161498e565b9190910192915050565b81835281816020850137505f828201602090810191909152601f909101601f19169091010190565b63ffffffff861681526001600160a01b03851660208201526001600160a01b0384166040820152608060608201525f61542e6080830184866153c9565b979650505050505050565b5f60208284031215615449575f5ffd5b5051919050565b8181038181111561129c5761129c615200565b60ff8916815263ffffffff881660208201526001600160a01b038716604082015263ffffffff861660608201526001600160a01b03851660808201528360a082015261010060c08201525f6154bc6101008301856149b0565b905063ffffffff831660e08301529998505050505050505050565b6001600160a01b038516815263ffffffff84166020820152606060408201525f61456a6060830184866153c9565b5f5f5f60608486031215615517575f5ffd5b835167ffffffffffffffff81111561552d575f5ffd5b6155398682870161528d565b935050602084015167ffffffffffffffff811115615555575f5ffd5b6155618682870161528d565b9250506040840151614cb481614a08565b60ff8a16815263ffffffff891660208201526001600160a01b038816604082015263ffffffff871660608201526001600160a01b03861660808201528460a082015261010060c08201525f6155cc610100830185876153c9565b905063ffffffff831660e08301529a9950505050505050505050565b5f5f858511156155f6575f5ffd5b83861115615602575f5ffd5b5050820193919092039150565b80356001600160e01b03198116906004841015615640576001600160e01b0319600485900360031b81901b82161691505b5092915050565b5f5f5f5f5f5f5f60e0888a03121561565d575f5ffd5b87356156688161460f565b965060208801356156788161460f565b955060408801359450606088013593506080880135614a7381614a08565b5f5f5f5f5f5f5f5f610100898b0312156156ae575f5ffd5b88356156b98161460f565b975060208901356156c98161460f565b9650604089013595506060890135945060808901356156e7816146ec565b935060a08901356156f781614a08565b979a969950949793969295929450505060c08201359160e0013590565b5f6001820161572557615725615200565b5060010190565b5f6020828403121561573c575f5ffd5b8151611a53816146ec565b6001815b60018411156157825780850481111561576657615766615200565b600184161561577457908102905b60019390931c92800261574b565b935093915050565b5f826157985750600161129c565b816157a457505f61129c565b81600181146157ba57600281146157c4576157e0565b600191505061129c565b60ff8411156157d5576157d5615200565b50506001821b61129c565b5060208310610133831016604e8410600b8410161715615803575081810a61129c565b61580f5f198484615747565b805f190482111561582257615822615200565b029392505050565b5f611a53838361578a565b634e487b7160e01b5f52600160045260245ffdfea2646970667358221220e1559c2f35db1ae259a268c6bba8fd38cf4df7f213026f9875114146126edc6f64736f6c634300081c0033
Multichain Portfolio | 34 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
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.