Source Code
Overview
ETH Balance
0 ETH
ETH Value
$0.00View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Cross-Chain Transactions
Loading...
Loading
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.
Contract Name:
InceptionBridge
Compiler Version
v0.8.20+commit.a1b79de6
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
pragma abicoder v2;
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol";
import "@openzeppelin/contracts/interfaces/IERC20.sol";
import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "./InceptionBridgeStorage.sol";
import "../interfaces/IInceptionBridge.sol";
import "../interfaces/IXERC20Lockbox.sol";
import "../lib/EthereumVerifier.sol";
import "../lib/ProofParser.sol";
import "../lib/Utils.sol";
/// @author The InceptionLRT team
/// @title The InceptionBridge contract
/// @notice Facilitates cross-chain token(asset) transfers using the burn-mint pattern.
contract InceptionBridge is
OwnableUpgradeable,
PausableUpgradeable,
ReentrancyGuardUpgradeable,
InceptionBridgeStorage,
IInceptionBridge
{
using SafeERC20 for IERC20;
/// @custom:oz-upgrades-unsafe-allow constructor
/// @dev payable modifier reduces the deployment cost
constructor() payable {
_disableInitializers();
}
function initialize(
address initialOwner,
address notary
) external initializer {
__Ownable_init(initialOwner);
__Pausable_init();
__ReentrancyGuard_init();
__initInceptionBridgeStorage(notary);
}
/*//////////////////////////////
////// Deposit functions //////
////////////////////////////*/
/**
* @dev Tokens on source and destination chains are linked with independent supplies.
* Burns tokens on source chain (to later mint it on the destination chain).
* @param fromToken is one of the many supported tokens on the current chain.
* @param destinationChain is the destination chain ID.
* @param receiver of `amount` on the destination chain.
* @param amount of tokens to be transferred
*/
function deposit(
address fromToken,
uint256 destinationChain,
address receiver,
uint256 amount
) external override nonReentrant whenNotPaused {
_beforeDeposit();
_updateDepositCaps(fromToken, amount);
if (getDestination(fromToken, destinationChain) != address(0)) {
_deposit(fromToken, destinationChain, receiver, amount);
} else revert UnknownDestinationChain();
}
function _deposit(
address fromToken,
uint256 destinationChain,
address receiver,
uint256 amount
) internal {
if (_bridgeAddressByChainId[destinationChain] == address(0)) {
revert UnknownDestinationChain();
}
address sender = msg.sender;
address lockbox = xerc20TokenRegistry[fromToken];
if (lockbox == address(0)) {
_safeBurn(fromToken, sender, amount);
} else {
_depositIntoLockbox(lockbox, fromToken, sender, amount);
}
Metadata memory metaData = Metadata(
Utils.stringToBytes32(IERC20Extra(fromToken).name()),
Utils.stringToBytes32(IERC20Extra(fromToken).symbol()),
0,
address(0)
);
unchecked {
++_globalNonce;
}
emit Deposited(
destinationChain,
_bridgeAddressByChainId[destinationChain],
sender,
receiver,
fromToken,
getDestination(fromToken, destinationChain),
amount,
_globalNonce,
metaData
);
}
function _depositIntoLockbox(
address lockbox,
address fromToken,
address sender,
uint256 amount
) internal {
address xerc20 = address(IXERC20Lockbox(lockbox).XERC20());
if (xerc20 == address(0)) revert XERC20ZeroAddress();
/// deposit into the lockBox
IERC20(fromToken).safeTransferFrom(sender, address(this), amount);
IERC20(fromToken).safeApprove(lockbox, amount);
IXERC20Lockbox(lockbox).deposit(amount);
_safeBurn(xerc20, address(this), amount);
}
/*/////////////////////////////////
////// Withdrawal functions //////
///////////////////////////////*/
/// @dev Serves the authorized (signed) withdrawal request by the bridge committee.
/// @dev Mints the corresponding token to the `Deposited.receiver` address.
/// `encodedProof` represents the RLP-encoded 'Deposited' receipt.
/// @param rawReceipt is the raw deposit transaction receipt.
/// @param proofSignature is the signature of keccak256(`encodedProof`) by the operator.
function withdraw(
/* encodedProof */ bytes calldata,
bytes calldata rawReceipt,
bytes memory proofSignature
) external override nonReentrant whenNotPaused {
uint256 proofOffset;
uint256 receiptOffset;
assembly {
proofOffset := add(0x4, calldataload(4))
receiptOffset := add(0x4, calldataload(36))
}
(
EthereumVerifier.State memory state,
EthereumVerifier.DepositType depositType
) = EthereumVerifier.parseTransactionReceipt(receiptOffset);
if (state.chainId != block.chainid)
revert ReceiptWrongChain(block.chainid, state.chainId);
ProofParser.Proof memory proof = ProofParser.parseProof(proofOffset);
if (state.contractAddress == address(0))
revert InvalidContractAddress();
if (state.destinationContract != address(this))
revert WrongDestinationBridge();
if (_bridgeAddressByChainId[proof.chainId] != state.contractAddress)
revert UnknownBridge();
state.receiptHash = keccak256(rawReceipt);
proof.status = 0x01;
proof.receiptHash = state.receiptHash;
bytes32 proofHash;
assembly {
proofHash := keccak256(proof, _PROOF_LENGTH)
}
if (ECDSA.recover(proofHash, proofSignature) != notary)
revert WrongSignature();
_withdraw(state, depositType, proof, proofHash);
}
function _withdraw(
EthereumVerifier.State memory state,
EthereumVerifier.DepositType depositType,
ProofParser.Proof memory proof,
bytes32 payload
) internal {
if (_usedProofs[payload]) {
revert WithdrawalProofUsed();
}
_usedProofs[payload] = true;
if (depositType == EthereumVerifier.DepositType.TokenDeposit) {
_withdraw(state, proof);
} else revert InvalidAssetType();
}
function _withdraw(
EthereumVerifier.State memory state,
ProofParser.Proof memory proof
) internal {
if (state.fromToken == address(0)) revert InvalidFromTokenAddress();
if (getDestination(state.toToken, proof.chainId) != state.fromToken)
revert UnknownDestination();
_updateWithdrawCaps(state.toToken, state.amount);
address lockbox = xerc20TokenRegistry[state.toToken];
if (lockbox == address(0)) {
_safeMint(state.toToken, state.receiver, state.amount);
} else {
address xerc20 = address(IXERC20Lockbox(lockbox).XERC20());
if (xerc20 == address(0)) revert XERC20ZeroAddress();
_safeMint(xerc20, address(this), state.amount);
IXERC20Lockbox(lockbox).withdrawTo(state.receiver, state.amount);
}
emit Withdrawn(
state.receiptHash,
state.sender,
state.receiver,
state.fromToken,
state.toToken,
state.amount
);
}
function getDestination(
address fromToken,
uint256 destinationChain
) public view returns (address) {
return
_destinationTokens[
keccak256(
abi.encodePacked(
fromToken,
block.chainid,
_bridgeAddressByChainId[destinationChain],
destinationChain
)
)
];
}
/*//////////////////////////
////// SET functions //////
////////////////////////*/
function setNotary(address notaryAddress) external onlyOwner {
_setNotary(notaryAddress);
}
function setShortCap(
address tokenAddress,
uint256 amount
) external onlyOwner {
_setShortCap(tokenAddress, amount);
}
function setShortCapDuration(uint256 duration) external onlyOwner {
_setShortCapDuration(duration);
}
function setLongCapDuration(uint256 duration) external onlyOwner {
_setLongCapDuration(duration);
}
function setLongCap(address token, uint256 amount) external onlyOwner {
_setLongCap(token, amount);
}
function addBridge(
address bridge,
uint256 destinationChain
) external onlyOwner {
_addBridge(bridge, destinationChain);
}
function removeBridge(uint256 destinationChain) external onlyOwner {
_removeBridge(destinationChain);
}
function addDestination(
address fromToken,
uint256 destinationChain,
address toToken
) external onlyOwner {
_addDestination(fromToken, destinationChain, toToken);
}
function removeDestination(
address fromToken,
uint256 destinationChain,
address toToken
) external onlyOwner {
_removeDestination(fromToken, destinationChain, toToken);
}
function setXERC20Lockbox(
address token,
address xerc20Lockbox
) external onlyOwner {
_setXERC20Lockbox(token, xerc20Lockbox);
}
/*///////////////////////////////
////// Pausable functions //////
/////////////////////////////*/
function pause() external onlyOwner {
_pause();
}
function unpause() external onlyOwner {
_unpause();
}
/*///////////////////////////////
//////// Safe functions ////////
/////////////////////////////*/
function _safeBurn(
address token,
address account,
uint256 amount
) internal {
uint256 balanceBefore = IERC20(token).balanceOf(account);
IERC20Mintable(token).burn(account, amount);
uint256 balanceAfter = IERC20(token).balanceOf(account);
if (balanceAfter + amount != balanceBefore) {
revert BurnFailed();
}
}
function _safeMint(
address token,
address account,
uint256 amount
) internal {
uint256 balanceBefore = IERC20(token).balanceOf(account);
IERC20Mintable(token).mint(account, amount);
uint256 balanceAfter = IERC20(token).balanceOf(account);
if (balanceBefore + amount != balanceAfter) {
revert MintFailed();
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)
pragma solidity ^0.8.20;
import {ContextUpgradeable} from "../utils/ContextUpgradeable.sol";
import {Initializable} from "../proxy/utils/Initializable.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* The initial owner is set to the address provided by the deployer. This can
* later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {
/// @custom:storage-location erc7201:openzeppelin.storage.Ownable
struct OwnableStorage {
address _owner;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Ownable")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant OwnableStorageLocation = 0x9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300;
function _getOwnableStorage() private pure returns (OwnableStorage storage $) {
assembly {
$.slot := OwnableStorageLocation
}
}
/**
* @dev The caller account is not authorized to perform an operation.
*/
error OwnableUnauthorizedAccount(address account);
/**
* @dev The owner is not a valid owner account. (eg. `address(0)`)
*/
error OwnableInvalidOwner(address owner);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the address provided by the deployer as the initial owner.
*/
function __Ownable_init(address initialOwner) internal onlyInitializing {
__Ownable_init_unchained(initialOwner);
}
function __Ownable_init_unchained(address initialOwner) internal onlyInitializing {
if (initialOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(initialOwner);
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
OwnableStorage storage $ = _getOwnableStorage();
return $._owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
if (owner() != _msgSender()) {
revert OwnableUnauthorizedAccount(_msgSender());
}
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
if (newOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
OwnableStorage storage $ = _getOwnableStorage();
address oldOwner = $._owner;
$._owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}// 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.1) (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;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Pausable.sol)
pragma solidity ^0.8.20;
import {ContextUpgradeable} from "../utils/ContextUpgradeable.sol";
import {Initializable} from "../proxy/utils/Initializable.sol";
/**
* @dev Contract module which allows children to implement an emergency stop
* mechanism that can be triggered by an authorized account.
*
* This module is used through inheritance. It will make available the
* modifiers `whenNotPaused` and `whenPaused`, which can be applied to
* the functions of your contract. Note that they will not be pausable by
* simply including this module, only once the modifiers are put in place.
*/
abstract contract PausableUpgradeable is Initializable, ContextUpgradeable {
/// @custom:storage-location erc7201:openzeppelin.storage.Pausable
struct PausableStorage {
bool _paused;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Pausable")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant PausableStorageLocation = 0xcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f03300;
function _getPausableStorage() private pure returns (PausableStorage storage $) {
assembly {
$.slot := PausableStorageLocation
}
}
/**
* @dev Emitted when the pause is triggered by `account`.
*/
event Paused(address account);
/**
* @dev Emitted when the pause is lifted by `account`.
*/
event Unpaused(address account);
/**
* @dev The operation failed because the contract is paused.
*/
error EnforcedPause();
/**
* @dev The operation failed because the contract is not paused.
*/
error ExpectedPause();
/**
* @dev Initializes the contract in unpaused state.
*/
function __Pausable_init() internal onlyInitializing {
__Pausable_init_unchained();
}
function __Pausable_init_unchained() internal onlyInitializing {
PausableStorage storage $ = _getPausableStorage();
$._paused = false;
}
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*
* Requirements:
*
* - The contract must not be paused.
*/
modifier whenNotPaused() {
_requireNotPaused();
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*
* Requirements:
*
* - The contract must be paused.
*/
modifier whenPaused() {
_requirePaused();
_;
}
/**
* @dev Returns true if the contract is paused, and false otherwise.
*/
function paused() public view virtual returns (bool) {
PausableStorage storage $ = _getPausableStorage();
return $._paused;
}
/**
* @dev Throws if the contract is paused.
*/
function _requireNotPaused() internal view virtual {
if (paused()) {
revert EnforcedPause();
}
}
/**
* @dev Throws if the contract is not paused.
*/
function _requirePaused() internal view virtual {
if (!paused()) {
revert ExpectedPause();
}
}
/**
* @dev Triggers stopped state.
*
* Requirements:
*
* - The contract must not be paused.
*/
function _pause() internal virtual whenNotPaused {
PausableStorage storage $ = _getPausableStorage();
$._paused = true;
emit Paused(_msgSender());
}
/**
* @dev Returns to normal state.
*
* Requirements:
*
* - The contract must be paused.
*/
function _unpause() internal virtual whenPaused {
PausableStorage storage $ = _getPausableStorage();
$._paused = false;
emit Unpaused(_msgSender());
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/ReentrancyGuard.sol)
pragma solidity ^0.8.20;
import {Initializable} from "../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;
/// @custom:storage-location erc7201:openzeppelin.storage.ReentrancyGuard
struct ReentrancyGuardStorage {
uint256 _status;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.ReentrancyGuard")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant ReentrancyGuardStorageLocation = 0x9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00;
function _getReentrancyGuardStorage() private pure returns (ReentrancyGuardStorage storage $) {
assembly {
$.slot := ReentrancyGuardStorageLocation
}
}
/**
* @dev Unauthorized reentrant call.
*/
error ReentrancyGuardReentrantCall();
function __ReentrancyGuard_init() internal onlyInitializing {
__ReentrancyGuard_init_unchained();
}
function __ReentrancyGuard_init_unchained() internal onlyInitializing {
ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage();
$._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 {
ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage();
// On the first call to nonReentrant, _status will be NOT_ENTERED
if ($._status == ENTERED) {
revert ReentrancyGuardReentrantCall();
}
// Any calls to nonReentrant after this point will fail
$._status = ENTERED;
}
function _nonReentrantAfter() private {
ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage();
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
$._status = NOT_ENTERED;
}
/**
* @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
* `nonReentrant` function in the call stack.
*/
function _reentrancyGuardEntered() internal view returns (bool) {
ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage();
return $._status == ENTERED;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_transferOwnership(_msgSender());
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)
pragma solidity ^0.8.0;
/**
* @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified
* proxy whose upgrades are fully controlled by the current implementation.
*/
interface IERC1822Proxiable {
/**
* @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation
* address.
*
* IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
* bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
* function revert if invoked through a proxy.
*/
function proxiableUUID() external view returns (bytes32);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (interfaces/IERC1967.sol)
pragma solidity ^0.8.0;
/**
* @dev ERC-1967: Proxy Storage Slots. This interface contains the events defined in the ERC.
*
* _Available since v4.8.3._
*/
interface IERC1967 {
/**
* @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);
}// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (interfaces/IERC20.sol) pragma solidity ^0.8.0; import "../token/ERC20/IERC20.sol";
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (interfaces/IERC20Metadata.sol) pragma solidity ^0.8.0; import "../token/ERC20/extensions/IERC20Metadata.sol";
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (interfaces/IERC5267.sol)
pragma solidity ^0.8.0;
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 v4.4.1 (proxy/beacon/IBeacon.sol)
pragma solidity ^0.8.0;
/**
* @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.
*
* {BeaconProxy} will check that this address is a contract.
*/
function implementation() external view returns (address);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (proxy/ERC1967/ERC1967Proxy.sol)
pragma solidity ^0.8.0;
import "../Proxy.sol";
import "./ERC1967Upgrade.sol";
/**
* @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an
* implementation address that can be changed. This address is stored in storage in the location specified by
* https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the
* implementation behind the proxy.
*/
contract ERC1967Proxy is Proxy, ERC1967Upgrade {
/**
* @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.
*
* If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded
* function call, and allows initializing the storage of the proxy like a Solidity constructor.
*/
constructor(address _logic, bytes memory _data) payable {
_upgradeToAndCall(_logic, _data, false);
}
/**
* @dev Returns the current implementation address.
*/
function _implementation() internal view virtual override returns (address impl) {
return ERC1967Upgrade._getImplementation();
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (proxy/ERC1967/ERC1967Upgrade.sol)
pragma solidity ^0.8.2;
import "../beacon/IBeacon.sol";
import "../../interfaces/IERC1967.sol";
import "../../interfaces/draft-IERC1822.sol";
import "../../utils/Address.sol";
import "../../utils/StorageSlot.sol";
/**
* @dev This abstract contract provides getters and event emitting update functions for
* https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.
*
* _Available since v4.1._
*/
abstract contract ERC1967Upgrade is IERC1967 {
// This is the keccak-256 hash of "eip1967.proxy.rollback" subtracted by 1
bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;
/**
* @dev Storage slot with the address of the current implementation.
* This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is
* validated in the constructor.
*/
bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
/**
* @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 {
require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
}
/**
* @dev Perform implementation upgrade
*
* Emits an {Upgraded} event.
*/
function _upgradeTo(address newImplementation) internal {
_setImplementation(newImplementation);
emit Upgraded(newImplementation);
}
/**
* @dev Perform implementation upgrade with additional setup call.
*
* Emits an {Upgraded} event.
*/
function _upgradeToAndCall(address newImplementation, bytes memory data, bool forceCall) internal {
_upgradeTo(newImplementation);
if (data.length > 0 || forceCall) {
Address.functionDelegateCall(newImplementation, data);
}
}
/**
* @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.
*
* Emits an {Upgraded} event.
*/
function _upgradeToAndCallUUPS(address newImplementation, bytes memory data, bool forceCall) internal {
// Upgrades from old implementations will perform a rollback test. This test requires the new
// implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing
// this special case will break upgrade paths from old UUPS implementation to new ones.
if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {
_setImplementation(newImplementation);
} else {
try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {
require(slot == _IMPLEMENTATION_SLOT, "ERC1967Upgrade: unsupported proxiableUUID");
} catch {
revert("ERC1967Upgrade: new implementation is not UUPS");
}
_upgradeToAndCall(newImplementation, data, forceCall);
}
}
/**
* @dev Storage slot with the admin of the contract.
* This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is
* validated in the constructor.
*/
bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
/**
* @dev Returns the current admin.
*/
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 {
require(newAdmin != address(0), "ERC1967: new admin is the zero address");
StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;
}
/**
* @dev Changes the admin of the proxy.
*
* Emits an {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 bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.
*/
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 {
require(Address.isContract(newBeacon), "ERC1967: new beacon is not a contract");
require(
Address.isContract(IBeacon(newBeacon).implementation()),
"ERC1967: beacon implementation is not a contract"
);
StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;
}
/**
* @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does
* not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).
*
* Emits a {BeaconUpgraded} event.
*/
function _upgradeBeaconToAndCall(address newBeacon, bytes memory data, bool forceCall) internal {
_setBeacon(newBeacon);
emit BeaconUpgraded(newBeacon);
if (data.length > 0 || forceCall) {
Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol)
pragma solidity ^0.8.0;
/**
* @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM
* instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to
* be specified by overriding the virtual {_implementation} function.
*
* Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a
* different contract through the {_delegate} function.
*
* The success and return data of the delegated call will be returned back to the caller of the proxy.
*/
abstract contract Proxy {
/**
* @dev Delegates the current call to `implementation`.
*
* This function does not return to its internal call site, it will return directly to the external caller.
*/
function _delegate(address implementation) internal virtual {
assembly {
// Copy msg.data. We take full control of memory in this inline assembly
// block because it will not return to Solidity code. We overwrite the
// Solidity scratch pad at memory position 0.
calldatacopy(0, 0, calldatasize())
// Call the implementation.
// out and outsize are 0 because we don't know the size yet.
let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)
// Copy the returned data.
returndatacopy(0, 0, returndatasize())
switch result
// delegatecall returns 0 on error.
case 0 {
revert(0, returndatasize())
}
default {
return(0, returndatasize())
}
}
}
/**
* @dev This is a virtual function that should be overridden so it returns the address to which the fallback function
* and {_fallback} should delegate.
*/
function _implementation() internal view virtual returns (address);
/**
* @dev Delegates the current call to the address returned by `_implementation()`.
*
* This function does not return to its internal call site, it will return directly to the external caller.
*/
function _fallback() internal virtual {
_beforeFallback();
_delegate(_implementation());
}
/**
* @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other
* function in the contract matches the call data.
*/
fallback() external payable virtual {
_fallback();
}
/**
* @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data
* is empty.
*/
receive() external payable virtual {
_fallback();
}
/**
* @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`
* call, or as part of the Solidity `fallback` or `receive` functions.
*
* If overridden should call `super._beforeFallback()`.
*/
function _beforeFallback() internal virtual {}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.3) (proxy/transparent/ProxyAdmin.sol)
pragma solidity ^0.8.0;
import "./TransparentUpgradeableProxy.sol";
import "../../access/Ownable.sol";
/**
* @dev This is an auxiliary contract meant to be assigned as the admin of a {TransparentUpgradeableProxy}. For an
* explanation of why you would want to use this see the documentation for {TransparentUpgradeableProxy}.
*/
contract ProxyAdmin is Ownable {
/**
* @dev Returns the current implementation of `proxy`.
*
* Requirements:
*
* - This contract must be the admin of `proxy`.
*/
function getProxyImplementation(ITransparentUpgradeableProxy proxy) public view virtual returns (address) {
// We need to manually run the static call since the getter cannot be flagged as view
// bytes4(keccak256("implementation()")) == 0x5c60da1b
(bool success, bytes memory returndata) = address(proxy).staticcall(hex"5c60da1b");
require(success);
return abi.decode(returndata, (address));
}
/**
* @dev Returns the current admin of `proxy`.
*
* Requirements:
*
* - This contract must be the admin of `proxy`.
*/
function getProxyAdmin(ITransparentUpgradeableProxy proxy) public view virtual returns (address) {
// We need to manually run the static call since the getter cannot be flagged as view
// bytes4(keccak256("admin()")) == 0xf851a440
(bool success, bytes memory returndata) = address(proxy).staticcall(hex"f851a440");
require(success);
return abi.decode(returndata, (address));
}
/**
* @dev Changes the admin of `proxy` to `newAdmin`.
*
* Requirements:
*
* - This contract must be the current admin of `proxy`.
*/
function changeProxyAdmin(ITransparentUpgradeableProxy proxy, address newAdmin) public virtual onlyOwner {
proxy.changeAdmin(newAdmin);
}
/**
* @dev Upgrades `proxy` to `implementation`. See {TransparentUpgradeableProxy-upgradeTo}.
*
* Requirements:
*
* - This contract must be the admin of `proxy`.
*/
function upgrade(ITransparentUpgradeableProxy proxy, address implementation) public virtual onlyOwner {
proxy.upgradeTo(implementation);
}
/**
* @dev Upgrades `proxy` to `implementation` and calls a function on the new implementation. See
* {TransparentUpgradeableProxy-upgradeToAndCall}.
*
* Requirements:
*
* - This contract must be the admin of `proxy`.
*/
function upgradeAndCall(
ITransparentUpgradeableProxy proxy,
address implementation,
bytes memory data
) public payable virtual onlyOwner {
proxy.upgradeToAndCall{value: msg.value}(implementation, data);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (proxy/transparent/TransparentUpgradeableProxy.sol)
pragma solidity ^0.8.0;
import "../ERC1967/ERC1967Proxy.sol";
/**
* @dev Interface for {TransparentUpgradeableProxy}. In order to implement transparency, {TransparentUpgradeableProxy}
* does not implement this interface directly, and some of its functions are implemented by an internal dispatch
* mechanism. The compiler is unaware that these functions are implemented by {TransparentUpgradeableProxy} and will not
* include them in the ABI so this interface must be used to interact with it.
*/
interface ITransparentUpgradeableProxy is IERC1967 {
function admin() external view returns (address);
function implementation() external view returns (address);
function changeAdmin(address) external;
function upgradeTo(address) external;
function upgradeToAndCall(address, bytes memory) external payable;
}
/**
* @dev This contract implements a proxy that is upgradeable by an admin.
*
* To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector
* clashing], which can potentially be used in an attack, this contract uses the
* https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two
* things that go hand in hand:
*
* 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if
* that call matches one of the admin functions exposed by the proxy itself.
* 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the
* implementation. If the admin tries to call a function on the implementation it will fail with an error that says
* "admin cannot fallback to proxy target".
*
* These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing
* the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due
* to sudden errors when trying to call a function from the proxy implementation.
*
* Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,
* you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.
*
* NOTE: The real interface of this proxy is that defined in `ITransparentUpgradeableProxy`. This contract does not
* inherit from that interface, and instead the admin functions are implicitly implemented using a custom dispatch
* mechanism in `_fallback`. Consequently, the compiler will not produce an ABI for this contract. This is necessary to
* fully implement transparency without decoding reverts caused by selector clashes between the proxy and the
* implementation.
*
* WARNING: It is not recommended to extend this contract to add additional external functions. If you do so, the compiler
* will not check that there are no selector conflicts, due to the note above. A selector clash between any new function
* and the functions declared in {ITransparentUpgradeableProxy} will be resolved in favor of the new one. This could
* render the admin operations inaccessible, which could prevent upgradeability. Transparency may also be compromised.
*/
contract TransparentUpgradeableProxy is ERC1967Proxy {
/**
* @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and
* optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.
*/
constructor(address _logic, address admin_, bytes memory _data) payable ERC1967Proxy(_logic, _data) {
_changeAdmin(admin_);
}
/**
* @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.
*
* CAUTION: This modifier is deprecated, as it could cause issues if the modified function has arguments, and the
* implementation provides a function with the same selector.
*/
modifier ifAdmin() {
if (msg.sender == _getAdmin()) {
_;
} else {
_fallback();
}
}
/**
* @dev If caller is the admin process the call internally, otherwise transparently fallback to the proxy behavior
*/
function _fallback() internal virtual override {
if (msg.sender == _getAdmin()) {
bytes memory ret;
bytes4 selector = msg.sig;
if (selector == ITransparentUpgradeableProxy.upgradeTo.selector) {
ret = _dispatchUpgradeTo();
} else if (selector == ITransparentUpgradeableProxy.upgradeToAndCall.selector) {
ret = _dispatchUpgradeToAndCall();
} else if (selector == ITransparentUpgradeableProxy.changeAdmin.selector) {
ret = _dispatchChangeAdmin();
} else if (selector == ITransparentUpgradeableProxy.admin.selector) {
ret = _dispatchAdmin();
} else if (selector == ITransparentUpgradeableProxy.implementation.selector) {
ret = _dispatchImplementation();
} else {
revert("TransparentUpgradeableProxy: admin cannot fallback to proxy target");
}
assembly {
return(add(ret, 0x20), mload(ret))
}
} else {
super._fallback();
}
}
/**
* @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 _dispatchAdmin() private returns (bytes memory) {
_requireZeroValue();
address admin = _getAdmin();
return abi.encode(admin);
}
/**
* @dev Returns the current implementation.
*
* 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.
* `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`
*/
function _dispatchImplementation() private returns (bytes memory) {
_requireZeroValue();
address implementation = _implementation();
return abi.encode(implementation);
}
/**
* @dev Changes the admin of the proxy.
*
* Emits an {AdminChanged} event.
*/
function _dispatchChangeAdmin() private returns (bytes memory) {
_requireZeroValue();
address newAdmin = abi.decode(msg.data[4:], (address));
_changeAdmin(newAdmin);
return "";
}
/**
* @dev Upgrade the implementation of the proxy.
*/
function _dispatchUpgradeTo() private returns (bytes memory) {
_requireZeroValue();
address newImplementation = abi.decode(msg.data[4:], (address));
_upgradeToAndCall(newImplementation, bytes(""), false);
return "";
}
/**
* @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified
* by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the
* proxied contract.
*/
function _dispatchUpgradeToAndCall() private returns (bytes memory) {
(address newImplementation, bytes memory data) = abi.decode(msg.data[4:], (address, bytes));
_upgradeToAndCall(newImplementation, data, true);
return "";
}
/**
* @dev Returns the current admin.
*
* CAUTION: This function is deprecated. Use {ERC1967Upgrade-_getAdmin} instead.
*/
function _admin() internal view virtual returns (address) {
return _getAdmin();
}
/**
* @dev To keep this contract fully transparent, all `ifAdmin` functions must be payable. This helper is here to
* emulate some proxy functions being non-payable while still allowing value to pass through.
*/
function _requireZeroValue() private {
require(msg.value == 0);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/ERC20.sol)
pragma solidity ^0.8.0;
import "./IERC20.sol";
import "./extensions/IERC20Metadata.sol";
import "../../utils/Context.sol";
/**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* 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.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/
contract ERC20 is Context, IERC20, IERC20Metadata {
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**
* @dev Sets the values for {name} and {symbol}.
*
* All two of these values are immutable: they can only be set once during
* construction.
*/
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5.05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the 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 override returns (uint8) {
return 18;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address to, uint256 amount) public virtual override returns (bool) {
address owner = _msgSender();
_transfer(owner, to, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on
* `transferFrom`. This is semantically equivalent to an infinite approval.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
address owner = _msgSender();
_approve(owner, spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* NOTE: Does not update the allowance if the current allowance
* is the maximum `uint256`.
*
* Requirements:
*
* - `from` and `to` cannot be the zero address.
* - `from` must have a balance of at least `amount`.
* - the caller must have allowance for ``from``'s tokens of at least
* `amount`.
*/
function transferFrom(address from, address to, uint256 amount) public virtual override returns (bool) {
address spender = _msgSender();
_spendAllowance(from, spender, amount);
_transfer(from, to, amount);
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
address owner = _msgSender();
_approve(owner, spender, allowance(owner, spender) + addedValue);
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
address owner = _msgSender();
uint256 currentAllowance = allowance(owner, spender);
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
unchecked {
_approve(owner, spender, currentAllowance - subtractedValue);
}
return true;
}
/**
* @dev Moves `amount` of tokens from `from` to `to`.
*
* This internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `from` must have a balance of at least `amount`.
*/
function _transfer(address from, address to, uint256 amount) internal virtual {
require(from != address(0), "ERC20: transfer from the zero address");
require(to != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(from, to, amount);
uint256 fromBalance = _balances[from];
require(fromBalance >= amount, "ERC20: transfer amount exceeds balance");
unchecked {
_balances[from] = fromBalance - amount;
// Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by
// decrementing then incrementing.
_balances[to] += amount;
}
emit Transfer(from, to, amount);
_afterTokenTransfer(from, to, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
unchecked {
// Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.
_balances[account] += amount;
}
emit Transfer(address(0), account, amount);
_afterTokenTransfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
unchecked {
_balances[account] = accountBalance - amount;
// Overflow not possible: amount <= accountBalance <= totalSupply.
_totalSupply -= amount;
}
emit Transfer(account, address(0), amount);
_afterTokenTransfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Updates `owner` s allowance for `spender` based on spent `amount`.
*
* Does not update the allowance amount in case of infinite allowance.
* Revert if not enough allowance is available.
*
* Might emit an {Approval} event.
*/
function _spendAllowance(address owner, address spender, uint256 amount) internal virtual {
uint256 currentAllowance = allowance(owner, spender);
if (currentAllowance != type(uint256).max) {
require(currentAllowance >= amount, "ERC20: insufficient allowance");
unchecked {
_approve(owner, spender, currentAllowance - amount);
}
}
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual {}
/**
* @dev Hook that is called after any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* has been transferred to `to`.
* - when `from` is zero, `amount` tokens have been minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens have been burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _afterTokenTransfer(address from, address to, uint256 amount) internal virtual {}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.4) (token/ERC20/extensions/ERC20Permit.sol)
pragma solidity ^0.8.0;
import "./IERC20Permit.sol";
import "../ERC20.sol";
import "../../../utils/cryptography/ECDSA.sol";
import "../../../utils/cryptography/EIP712.sol";
import "../../../utils/Counters.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.
*
* _Available since v3.4._
*/
abstract contract ERC20Permit is ERC20, IERC20Permit, EIP712 {
using Counters for Counters.Counter;
mapping(address => Counters.Counter) private _nonces;
// solhint-disable-next-line var-name-mixedcase
bytes32 private constant _PERMIT_TYPEHASH =
keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)");
/**
* @dev In previous versions `_PERMIT_TYPEHASH` was declared as `immutable`.
* However, to ensure consistency with the upgradeable transpiler, we will continue
* to reserve a slot.
* @custom:oz-renamed-from _PERMIT_TYPEHASH
*/
// solhint-disable-next-line var-name-mixedcase
bytes32 private _PERMIT_TYPEHASH_DEPRECATED_SLOT;
/**
* @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.
*/
constructor(string memory name) EIP712(name, "1") {}
/**
* @inheritdoc IERC20Permit
*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) public virtual override {
require(block.timestamp <= deadline, "ERC20Permit: expired 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);
require(signer == owner, "ERC20Permit: invalid signature");
_approve(owner, spender, value);
}
/**
* @inheritdoc IERC20Permit
*/
function nonces(address owner) public view virtual override returns (uint256) {
return _nonces[owner].current();
}
/**
* @inheritdoc IERC20Permit
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view override returns (bytes32) {
return _domainSeparatorV4();
}
/**
* @dev "Consume a nonce": return the current value and increment.
*
* _Available since v4.1._
*/
function _useNonce(address owner) internal virtual returns (uint256 current) {
Counters.Counter storage nonce = _nonces[owner];
current = nonce.current();
nonce.increment();
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)
pragma solidity ^0.8.0;
import "../IERC20.sol";
/**
* @dev Interface for the optional metadata functions from the ERC20 standard.
*
* _Available since v4.1._
*/
interface IERC20Metadata is IERC20 {
/**
* @dev Returns the name of the token.
*/
function name() external view returns (string memory);
/**
* @dev Returns the symbol of the token.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the decimals places of the token.
*/
function decimals() external view returns (uint8);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.4) (token/ERC20/extensions/IERC20Permit.sol)
pragma solidity ^0.8.0;
/**
* @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 v4.9.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `from` to `to` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 amount) external returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.0;
import "../IERC20.sol";
import "../extensions/IERC20Permit.sol";
import "../../../utils/Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using Address for address;
/**
* @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.encodeWithSelector(token.transfer.selector, 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.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
/**
* @dev Deprecated. This function has issues similar to the ones found in
* {IERC20-approve}, and its usage is discouraged.
*
* Whenever possible, use {safeIncreaseAllowance} and
* {safeDecreaseAllowance} instead.
*/
function safeApprove(IERC20 token, address spender, uint256 value) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
require(
(value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
/**
* @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);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));
}
/**
* @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
unchecked {
uint256 oldAllowance = token.allowance(address(this), spender);
require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));
}
}
/**
* @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.encodeWithSelector(token.approve.selector, spender, value);
if (!_callOptionalReturnBool(token, approvalCall)) {
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));
_callOptionalReturn(token, approvalCall);
}
}
/**
* @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.
* Revert on invalid signature.
*/
function safePermit(
IERC20Permit token,
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) internal {
uint256 nonceBefore = token.nonces(owner);
token.permit(owner, spender, value, deadline, v, r, s);
uint256 nonceAfter = token.nonces(owner);
require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
require(returndata.length == 0 || abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
/**
* @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.isContract(address(token));
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
*
* Furthermore, `isContract` will also return true if the target contract within
* the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
* which only has an effect at the end of a transaction.
* ====
*
* [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://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.0/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 Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(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 v4.9.4) (utils/Context.sol)
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Counters.sol)
pragma solidity ^0.8.0;
/**
* @title Counters
* @author Matt Condon (@shrugs)
* @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number
* of elements in a mapping, issuing ERC721 ids, or counting request ids.
*
* Include with `using Counters for Counters.Counter;`
*/
library Counters {
struct Counter {
// This variable should never be directly accessed by users of the library: interactions must be restricted to
// the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add
// this feature: see https://github.com/ethereum/solidity/issues/4637
uint256 _value; // default: 0
}
function current(Counter storage counter) internal view returns (uint256) {
return counter._value;
}
function increment(Counter storage counter) internal {
unchecked {
counter._value += 1;
}
}
function decrement(Counter storage counter) internal {
uint256 value = counter._value;
require(value > 0, "Counter: decrement overflow");
unchecked {
counter._value = value - 1;
}
}
function reset(Counter storage counter) internal {
counter._value = 0;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/cryptography/ECDSA.sol)
pragma solidity ^0.8.0;
import "../Strings.sol";
/**
* @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,
InvalidSignatureV // Deprecated in v4.8
}
function _throwError(RecoverError error) private pure {
if (error == RecoverError.NoError) {
return; // no error: do nothing
} else if (error == RecoverError.InvalidSignature) {
revert("ECDSA: invalid signature");
} else if (error == RecoverError.InvalidSignatureLength) {
revert("ECDSA: invalid signature length");
} else if (error == RecoverError.InvalidSignatureS) {
revert("ECDSA: invalid signature 's' value");
}
}
/**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature` or error string. This address can then be used for verification purposes.
*
* The `ecrecover` EVM opcode 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 {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]
*
* _Available since v4.3._
*/
function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {
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);
}
}
/**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature`. This address can then be used for verification purposes.
*
* The `ecrecover` EVM opcode 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 {toEthSignedMessageHash} on it.
*/
function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, signature);
_throwError(error);
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]
*
* _Available since v4.3._
*/
function tryRecover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address, RecoverError) {
bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);
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.
*
* _Available since v4.2._
*/
function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, r, vs);
_throwError(error);
return recovered;
}
/**
* @dev Overload of {ECDSA-tryRecover} that receives the `v`,
* `r` and `s` signature fields separately.
*
* _Available since v4.3._
*/
function tryRecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address, RecoverError) {
// 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);
}
// 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);
}
return (signer, RecoverError.NoError);
}
/**
* @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) = tryRecover(hash, v, r, s);
_throwError(error);
return recovered;
}
/**
* @dev Returns an Ethereum Signed Message, created from a `hash`. This
* produces hash corresponding to the one signed with the
* https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
* JSON-RPC method as part of EIP-191.
*
* See {recover}.
*/
function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32 message) {
// 32 is the length in bytes of hash,
// enforced by the type signature above
/// @solidity memory-safe-assembly
assembly {
mstore(0x00, "\x19Ethereum Signed Message:\n32")
mstore(0x1c, hash)
message := keccak256(0x00, 0x3c)
}
}
/**
* @dev Returns an Ethereum Signed Message, created from `s`. This
* produces hash corresponding to the one signed with the
* https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
* JSON-RPC method as part of EIP-191.
*
* See {recover}.
*/
function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {
return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", Strings.toString(s.length), s));
}
/**
* @dev Returns an Ethereum Signed Typed Data, created from a
* `domainSeparator` and a `structHash`. This produces hash corresponding
* to the one signed with the
* https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]
* JSON-RPC method as part of EIP-712.
*
* See {recover}.
*/
function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32 data) {
/// @solidity memory-safe-assembly
assembly {
let ptr := mload(0x40)
mstore(ptr, "\x19\x01")
mstore(add(ptr, 0x02), domainSeparator)
mstore(add(ptr, 0x22), structHash)
data := keccak256(ptr, 0x42)
}
}
/**
* @dev Returns an Ethereum Signed Data with intended validator, created from a
* `validator` and `data` according to the version 0 of EIP-191.
*
* See {recover}.
*/
function toDataWithIntendedValidatorHash(address validator, bytes memory data) internal pure returns (bytes32) {
return keccak256(abi.encodePacked("\x19\x00", validator, data));
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/cryptography/EIP712.sol)
pragma solidity ^0.8.8;
import "./ECDSA.sol";
import "../ShortStrings.sol";
import "../../interfaces/IERC5267.sol";
/**
* @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data.
*
* The encoding specified in the EIP is very generic, and such a generic 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 their contracts 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.
*
* _Available since v3.4._
*
* @custom:oz-upgrades-unsafe-allow state-variable-immutable state-variable-assignment
*/
abstract contract EIP712 is IERC5267 {
using ShortStrings for *;
bytes32 private constant _TYPE_HASH =
keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)");
// Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to
// invalidate the cached domain separator if the chain id changes.
bytes32 private immutable _cachedDomainSeparator;
uint256 private immutable _cachedChainId;
address private immutable _cachedThis;
bytes32 private immutable _hashedName;
bytes32 private immutable _hashedVersion;
ShortString private immutable _name;
ShortString private immutable _version;
string private _nameFallback;
string private _versionFallback;
/**
* @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].
*/
constructor(string memory name, string memory version) {
_name = name.toShortStringWithFallback(_nameFallback);
_version = version.toShortStringWithFallback(_versionFallback);
_hashedName = keccak256(bytes(name));
_hashedVersion = keccak256(bytes(version));
_cachedChainId = block.chainid;
_cachedDomainSeparator = _buildDomainSeparator();
_cachedThis = address(this);
}
/**
* @dev Returns the domain separator for the current chain.
*/
function _domainSeparatorV4() internal view returns (bytes32) {
if (address(this) == _cachedThis && block.chainid == _cachedChainId) {
return _cachedDomainSeparator;
} else {
return _buildDomainSeparator();
}
}
function _buildDomainSeparator() private view returns (bytes32) {
return keccak256(abi.encode(_TYPE_HASH, _hashedName, _hashedVersion, 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 ECDSA.toTypedDataHash(_domainSeparatorV4(), structHash);
}
/**
* @dev See {EIP-5267}.
*
* _Available since v4.9._
*/
function eip712Domain()
public
view
virtual
override
returns (
bytes1 fields,
string memory name,
string memory version,
uint256 chainId,
address verifyingContract,
bytes32 salt,
uint256[] memory extensions
)
{
return (
hex"0f", // 01111
_name.toStringWithFallback(_nameFallback),
_version.toStringWithFallback(_versionFallback),
block.chainid,
address(this),
bytes32(0),
new uint256[](0)
);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol)
pragma solidity ^0.8.0;
/**
* @dev Standard math utilities missing in the Solidity language.
*/
library Math {
enum Rounding {
Down, // Toward negative infinity
Up, // Toward infinity
Zero // Toward zero
}
/**
* @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 up instead
* of rounding down.
*/
function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
// (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; // Least significant 256 bits of the product
uint256 prod1; // Most significant 256 bits of the product
assembly {
let mm := mulmod(x, y, not(0))
prod0 := mul(x, y)
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.
require(denominator > prod1, "Math: mulDiv overflow");
///////////////////////////////////////////////
// 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.
// Does not overflow because the denominator cannot be zero at this stage in the function.
uint256 twos = denominator & (~denominator + 1);
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 (rounding == Rounding.Up && 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 down.
*
* 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 + (rounding == Rounding.Up && result * result < a ? 1 : 0);
}
}
/**
* @dev Return the log in base 2, rounded down, of a positive value.
* 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 + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 10, rounded down, of a positive value.
* 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 + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 256, rounded down, of a positive value.
* 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 + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SafeCast.sol)
// This file was procedurally generated from scripts/generate/templates/SafeCast.js.
pragma solidity ^0.8.0;
/**
* @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow
* checks.
*
* Downcasting from uint256/int256 in Solidity does not revert on overflow. This can
* easily result in undesired exploitation or bugs, since developers usually
* assume that overflows raise errors. `SafeCast` restores this intuition by
* reverting the transaction when such an operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*
* Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing
* all math on `uint256` and `int256` and then downcasting.
*/
library SafeCast {
/**
* @dev Returns the downcasted uint248 from uint256, reverting on
* overflow (when the input is greater than largest uint248).
*
* Counterpart to Solidity's `uint248` operator.
*
* Requirements:
*
* - input must fit into 248 bits
*
* _Available since v4.7._
*/
function toUint248(uint256 value) internal pure returns (uint248) {
require(value <= type(uint248).max, "SafeCast: value doesn't fit in 248 bits");
return uint248(value);
}
/**
* @dev Returns the downcasted uint240 from uint256, reverting on
* overflow (when the input is greater than largest uint240).
*
* Counterpart to Solidity's `uint240` operator.
*
* Requirements:
*
* - input must fit into 240 bits
*
* _Available since v4.7._
*/
function toUint240(uint256 value) internal pure returns (uint240) {
require(value <= type(uint240).max, "SafeCast: value doesn't fit in 240 bits");
return uint240(value);
}
/**
* @dev Returns the downcasted uint232 from uint256, reverting on
* overflow (when the input is greater than largest uint232).
*
* Counterpart to Solidity's `uint232` operator.
*
* Requirements:
*
* - input must fit into 232 bits
*
* _Available since v4.7._
*/
function toUint232(uint256 value) internal pure returns (uint232) {
require(value <= type(uint232).max, "SafeCast: value doesn't fit in 232 bits");
return uint232(value);
}
/**
* @dev Returns the downcasted uint224 from uint256, reverting on
* overflow (when the input is greater than largest uint224).
*
* Counterpart to Solidity's `uint224` operator.
*
* Requirements:
*
* - input must fit into 224 bits
*
* _Available since v4.2._
*/
function toUint224(uint256 value) internal pure returns (uint224) {
require(value <= type(uint224).max, "SafeCast: value doesn't fit in 224 bits");
return uint224(value);
}
/**
* @dev Returns the downcasted uint216 from uint256, reverting on
* overflow (when the input is greater than largest uint216).
*
* Counterpart to Solidity's `uint216` operator.
*
* Requirements:
*
* - input must fit into 216 bits
*
* _Available since v4.7._
*/
function toUint216(uint256 value) internal pure returns (uint216) {
require(value <= type(uint216).max, "SafeCast: value doesn't fit in 216 bits");
return uint216(value);
}
/**
* @dev Returns the downcasted uint208 from uint256, reverting on
* overflow (when the input is greater than largest uint208).
*
* Counterpart to Solidity's `uint208` operator.
*
* Requirements:
*
* - input must fit into 208 bits
*
* _Available since v4.7._
*/
function toUint208(uint256 value) internal pure returns (uint208) {
require(value <= type(uint208).max, "SafeCast: value doesn't fit in 208 bits");
return uint208(value);
}
/**
* @dev Returns the downcasted uint200 from uint256, reverting on
* overflow (when the input is greater than largest uint200).
*
* Counterpart to Solidity's `uint200` operator.
*
* Requirements:
*
* - input must fit into 200 bits
*
* _Available since v4.7._
*/
function toUint200(uint256 value) internal pure returns (uint200) {
require(value <= type(uint200).max, "SafeCast: value doesn't fit in 200 bits");
return uint200(value);
}
/**
* @dev Returns the downcasted uint192 from uint256, reverting on
* overflow (when the input is greater than largest uint192).
*
* Counterpart to Solidity's `uint192` operator.
*
* Requirements:
*
* - input must fit into 192 bits
*
* _Available since v4.7._
*/
function toUint192(uint256 value) internal pure returns (uint192) {
require(value <= type(uint192).max, "SafeCast: value doesn't fit in 192 bits");
return uint192(value);
}
/**
* @dev Returns the downcasted uint184 from uint256, reverting on
* overflow (when the input is greater than largest uint184).
*
* Counterpart to Solidity's `uint184` operator.
*
* Requirements:
*
* - input must fit into 184 bits
*
* _Available since v4.7._
*/
function toUint184(uint256 value) internal pure returns (uint184) {
require(value <= type(uint184).max, "SafeCast: value doesn't fit in 184 bits");
return uint184(value);
}
/**
* @dev Returns the downcasted uint176 from uint256, reverting on
* overflow (when the input is greater than largest uint176).
*
* Counterpart to Solidity's `uint176` operator.
*
* Requirements:
*
* - input must fit into 176 bits
*
* _Available since v4.7._
*/
function toUint176(uint256 value) internal pure returns (uint176) {
require(value <= type(uint176).max, "SafeCast: value doesn't fit in 176 bits");
return uint176(value);
}
/**
* @dev Returns the downcasted uint168 from uint256, reverting on
* overflow (when the input is greater than largest uint168).
*
* Counterpart to Solidity's `uint168` operator.
*
* Requirements:
*
* - input must fit into 168 bits
*
* _Available since v4.7._
*/
function toUint168(uint256 value) internal pure returns (uint168) {
require(value <= type(uint168).max, "SafeCast: value doesn't fit in 168 bits");
return uint168(value);
}
/**
* @dev Returns the downcasted uint160 from uint256, reverting on
* overflow (when the input is greater than largest uint160).
*
* Counterpart to Solidity's `uint160` operator.
*
* Requirements:
*
* - input must fit into 160 bits
*
* _Available since v4.7._
*/
function toUint160(uint256 value) internal pure returns (uint160) {
require(value <= type(uint160).max, "SafeCast: value doesn't fit in 160 bits");
return uint160(value);
}
/**
* @dev Returns the downcasted uint152 from uint256, reverting on
* overflow (when the input is greater than largest uint152).
*
* Counterpart to Solidity's `uint152` operator.
*
* Requirements:
*
* - input must fit into 152 bits
*
* _Available since v4.7._
*/
function toUint152(uint256 value) internal pure returns (uint152) {
require(value <= type(uint152).max, "SafeCast: value doesn't fit in 152 bits");
return uint152(value);
}
/**
* @dev Returns the downcasted uint144 from uint256, reverting on
* overflow (when the input is greater than largest uint144).
*
* Counterpart to Solidity's `uint144` operator.
*
* Requirements:
*
* - input must fit into 144 bits
*
* _Available since v4.7._
*/
function toUint144(uint256 value) internal pure returns (uint144) {
require(value <= type(uint144).max, "SafeCast: value doesn't fit in 144 bits");
return uint144(value);
}
/**
* @dev Returns the downcasted uint136 from uint256, reverting on
* overflow (when the input is greater than largest uint136).
*
* Counterpart to Solidity's `uint136` operator.
*
* Requirements:
*
* - input must fit into 136 bits
*
* _Available since v4.7._
*/
function toUint136(uint256 value) internal pure returns (uint136) {
require(value <= type(uint136).max, "SafeCast: value doesn't fit in 136 bits");
return uint136(value);
}
/**
* @dev Returns the downcasted uint128 from uint256, reverting on
* overflow (when the input is greater than largest uint128).
*
* Counterpart to Solidity's `uint128` operator.
*
* Requirements:
*
* - input must fit into 128 bits
*
* _Available since v2.5._
*/
function toUint128(uint256 value) internal pure returns (uint128) {
require(value <= type(uint128).max, "SafeCast: value doesn't fit in 128 bits");
return uint128(value);
}
/**
* @dev Returns the downcasted uint120 from uint256, reverting on
* overflow (when the input is greater than largest uint120).
*
* Counterpart to Solidity's `uint120` operator.
*
* Requirements:
*
* - input must fit into 120 bits
*
* _Available since v4.7._
*/
function toUint120(uint256 value) internal pure returns (uint120) {
require(value <= type(uint120).max, "SafeCast: value doesn't fit in 120 bits");
return uint120(value);
}
/**
* @dev Returns the downcasted uint112 from uint256, reverting on
* overflow (when the input is greater than largest uint112).
*
* Counterpart to Solidity's `uint112` operator.
*
* Requirements:
*
* - input must fit into 112 bits
*
* _Available since v4.7._
*/
function toUint112(uint256 value) internal pure returns (uint112) {
require(value <= type(uint112).max, "SafeCast: value doesn't fit in 112 bits");
return uint112(value);
}
/**
* @dev Returns the downcasted uint104 from uint256, reverting on
* overflow (when the input is greater than largest uint104).
*
* Counterpart to Solidity's `uint104` operator.
*
* Requirements:
*
* - input must fit into 104 bits
*
* _Available since v4.7._
*/
function toUint104(uint256 value) internal pure returns (uint104) {
require(value <= type(uint104).max, "SafeCast: value doesn't fit in 104 bits");
return uint104(value);
}
/**
* @dev Returns the downcasted uint96 from uint256, reverting on
* overflow (when the input is greater than largest uint96).
*
* Counterpart to Solidity's `uint96` operator.
*
* Requirements:
*
* - input must fit into 96 bits
*
* _Available since v4.2._
*/
function toUint96(uint256 value) internal pure returns (uint96) {
require(value <= type(uint96).max, "SafeCast: value doesn't fit in 96 bits");
return uint96(value);
}
/**
* @dev Returns the downcasted uint88 from uint256, reverting on
* overflow (when the input is greater than largest uint88).
*
* Counterpart to Solidity's `uint88` operator.
*
* Requirements:
*
* - input must fit into 88 bits
*
* _Available since v4.7._
*/
function toUint88(uint256 value) internal pure returns (uint88) {
require(value <= type(uint88).max, "SafeCast: value doesn't fit in 88 bits");
return uint88(value);
}
/**
* @dev Returns the downcasted uint80 from uint256, reverting on
* overflow (when the input is greater than largest uint80).
*
* Counterpart to Solidity's `uint80` operator.
*
* Requirements:
*
* - input must fit into 80 bits
*
* _Available since v4.7._
*/
function toUint80(uint256 value) internal pure returns (uint80) {
require(value <= type(uint80).max, "SafeCast: value doesn't fit in 80 bits");
return uint80(value);
}
/**
* @dev Returns the downcasted uint72 from uint256, reverting on
* overflow (when the input is greater than largest uint72).
*
* Counterpart to Solidity's `uint72` operator.
*
* Requirements:
*
* - input must fit into 72 bits
*
* _Available since v4.7._
*/
function toUint72(uint256 value) internal pure returns (uint72) {
require(value <= type(uint72).max, "SafeCast: value doesn't fit in 72 bits");
return uint72(value);
}
/**
* @dev Returns the downcasted uint64 from uint256, reverting on
* overflow (when the input is greater than largest uint64).
*
* Counterpart to Solidity's `uint64` operator.
*
* Requirements:
*
* - input must fit into 64 bits
*
* _Available since v2.5._
*/
function toUint64(uint256 value) internal pure returns (uint64) {
require(value <= type(uint64).max, "SafeCast: value doesn't fit in 64 bits");
return uint64(value);
}
/**
* @dev Returns the downcasted uint56 from uint256, reverting on
* overflow (when the input is greater than largest uint56).
*
* Counterpart to Solidity's `uint56` operator.
*
* Requirements:
*
* - input must fit into 56 bits
*
* _Available since v4.7._
*/
function toUint56(uint256 value) internal pure returns (uint56) {
require(value <= type(uint56).max, "SafeCast: value doesn't fit in 56 bits");
return uint56(value);
}
/**
* @dev Returns the downcasted uint48 from uint256, reverting on
* overflow (when the input is greater than largest uint48).
*
* Counterpart to Solidity's `uint48` operator.
*
* Requirements:
*
* - input must fit into 48 bits
*
* _Available since v4.7._
*/
function toUint48(uint256 value) internal pure returns (uint48) {
require(value <= type(uint48).max, "SafeCast: value doesn't fit in 48 bits");
return uint48(value);
}
/**
* @dev Returns the downcasted uint40 from uint256, reverting on
* overflow (when the input is greater than largest uint40).
*
* Counterpart to Solidity's `uint40` operator.
*
* Requirements:
*
* - input must fit into 40 bits
*
* _Available since v4.7._
*/
function toUint40(uint256 value) internal pure returns (uint40) {
require(value <= type(uint40).max, "SafeCast: value doesn't fit in 40 bits");
return uint40(value);
}
/**
* @dev Returns the downcasted uint32 from uint256, reverting on
* overflow (when the input is greater than largest uint32).
*
* Counterpart to Solidity's `uint32` operator.
*
* Requirements:
*
* - input must fit into 32 bits
*
* _Available since v2.5._
*/
function toUint32(uint256 value) internal pure returns (uint32) {
require(value <= type(uint32).max, "SafeCast: value doesn't fit in 32 bits");
return uint32(value);
}
/**
* @dev Returns the downcasted uint24 from uint256, reverting on
* overflow (when the input is greater than largest uint24).
*
* Counterpart to Solidity's `uint24` operator.
*
* Requirements:
*
* - input must fit into 24 bits
*
* _Available since v4.7._
*/
function toUint24(uint256 value) internal pure returns (uint24) {
require(value <= type(uint24).max, "SafeCast: value doesn't fit in 24 bits");
return uint24(value);
}
/**
* @dev Returns the downcasted uint16 from uint256, reverting on
* overflow (when the input is greater than largest uint16).
*
* Counterpart to Solidity's `uint16` operator.
*
* Requirements:
*
* - input must fit into 16 bits
*
* _Available since v2.5._
*/
function toUint16(uint256 value) internal pure returns (uint16) {
require(value <= type(uint16).max, "SafeCast: value doesn't fit in 16 bits");
return uint16(value);
}
/**
* @dev Returns the downcasted uint8 from uint256, reverting on
* overflow (when the input is greater than largest uint8).
*
* Counterpart to Solidity's `uint8` operator.
*
* Requirements:
*
* - input must fit into 8 bits
*
* _Available since v2.5._
*/
function toUint8(uint256 value) internal pure returns (uint8) {
require(value <= type(uint8).max, "SafeCast: value doesn't fit in 8 bits");
return uint8(value);
}
/**
* @dev Converts a signed int256 into an unsigned uint256.
*
* Requirements:
*
* - input must be greater than or equal to 0.
*
* _Available since v3.0._
*/
function toUint256(int256 value) internal pure returns (uint256) {
require(value >= 0, "SafeCast: value must be positive");
return uint256(value);
}
/**
* @dev Returns the downcasted int248 from int256, reverting on
* overflow (when the input is less than smallest int248 or
* greater than largest int248).
*
* Counterpart to Solidity's `int248` operator.
*
* Requirements:
*
* - input must fit into 248 bits
*
* _Available since v4.7._
*/
function toInt248(int256 value) internal pure returns (int248 downcasted) {
downcasted = int248(value);
require(downcasted == value, "SafeCast: value doesn't fit in 248 bits");
}
/**
* @dev Returns the downcasted int240 from int256, reverting on
* overflow (when the input is less than smallest int240 or
* greater than largest int240).
*
* Counterpart to Solidity's `int240` operator.
*
* Requirements:
*
* - input must fit into 240 bits
*
* _Available since v4.7._
*/
function toInt240(int256 value) internal pure returns (int240 downcasted) {
downcasted = int240(value);
require(downcasted == value, "SafeCast: value doesn't fit in 240 bits");
}
/**
* @dev Returns the downcasted int232 from int256, reverting on
* overflow (when the input is less than smallest int232 or
* greater than largest int232).
*
* Counterpart to Solidity's `int232` operator.
*
* Requirements:
*
* - input must fit into 232 bits
*
* _Available since v4.7._
*/
function toInt232(int256 value) internal pure returns (int232 downcasted) {
downcasted = int232(value);
require(downcasted == value, "SafeCast: value doesn't fit in 232 bits");
}
/**
* @dev Returns the downcasted int224 from int256, reverting on
* overflow (when the input is less than smallest int224 or
* greater than largest int224).
*
* Counterpart to Solidity's `int224` operator.
*
* Requirements:
*
* - input must fit into 224 bits
*
* _Available since v4.7._
*/
function toInt224(int256 value) internal pure returns (int224 downcasted) {
downcasted = int224(value);
require(downcasted == value, "SafeCast: value doesn't fit in 224 bits");
}
/**
* @dev Returns the downcasted int216 from int256, reverting on
* overflow (when the input is less than smallest int216 or
* greater than largest int216).
*
* Counterpart to Solidity's `int216` operator.
*
* Requirements:
*
* - input must fit into 216 bits
*
* _Available since v4.7._
*/
function toInt216(int256 value) internal pure returns (int216 downcasted) {
downcasted = int216(value);
require(downcasted == value, "SafeCast: value doesn't fit in 216 bits");
}
/**
* @dev Returns the downcasted int208 from int256, reverting on
* overflow (when the input is less than smallest int208 or
* greater than largest int208).
*
* Counterpart to Solidity's `int208` operator.
*
* Requirements:
*
* - input must fit into 208 bits
*
* _Available since v4.7._
*/
function toInt208(int256 value) internal pure returns (int208 downcasted) {
downcasted = int208(value);
require(downcasted == value, "SafeCast: value doesn't fit in 208 bits");
}
/**
* @dev Returns the downcasted int200 from int256, reverting on
* overflow (when the input is less than smallest int200 or
* greater than largest int200).
*
* Counterpart to Solidity's `int200` operator.
*
* Requirements:
*
* - input must fit into 200 bits
*
* _Available since v4.7._
*/
function toInt200(int256 value) internal pure returns (int200 downcasted) {
downcasted = int200(value);
require(downcasted == value, "SafeCast: value doesn't fit in 200 bits");
}
/**
* @dev Returns the downcasted int192 from int256, reverting on
* overflow (when the input is less than smallest int192 or
* greater than largest int192).
*
* Counterpart to Solidity's `int192` operator.
*
* Requirements:
*
* - input must fit into 192 bits
*
* _Available since v4.7._
*/
function toInt192(int256 value) internal pure returns (int192 downcasted) {
downcasted = int192(value);
require(downcasted == value, "SafeCast: value doesn't fit in 192 bits");
}
/**
* @dev Returns the downcasted int184 from int256, reverting on
* overflow (when the input is less than smallest int184 or
* greater than largest int184).
*
* Counterpart to Solidity's `int184` operator.
*
* Requirements:
*
* - input must fit into 184 bits
*
* _Available since v4.7._
*/
function toInt184(int256 value) internal pure returns (int184 downcasted) {
downcasted = int184(value);
require(downcasted == value, "SafeCast: value doesn't fit in 184 bits");
}
/**
* @dev Returns the downcasted int176 from int256, reverting on
* overflow (when the input is less than smallest int176 or
* greater than largest int176).
*
* Counterpart to Solidity's `int176` operator.
*
* Requirements:
*
* - input must fit into 176 bits
*
* _Available since v4.7._
*/
function toInt176(int256 value) internal pure returns (int176 downcasted) {
downcasted = int176(value);
require(downcasted == value, "SafeCast: value doesn't fit in 176 bits");
}
/**
* @dev Returns the downcasted int168 from int256, reverting on
* overflow (when the input is less than smallest int168 or
* greater than largest int168).
*
* Counterpart to Solidity's `int168` operator.
*
* Requirements:
*
* - input must fit into 168 bits
*
* _Available since v4.7._
*/
function toInt168(int256 value) internal pure returns (int168 downcasted) {
downcasted = int168(value);
require(downcasted == value, "SafeCast: value doesn't fit in 168 bits");
}
/**
* @dev Returns the downcasted int160 from int256, reverting on
* overflow (when the input is less than smallest int160 or
* greater than largest int160).
*
* Counterpart to Solidity's `int160` operator.
*
* Requirements:
*
* - input must fit into 160 bits
*
* _Available since v4.7._
*/
function toInt160(int256 value) internal pure returns (int160 downcasted) {
downcasted = int160(value);
require(downcasted == value, "SafeCast: value doesn't fit in 160 bits");
}
/**
* @dev Returns the downcasted int152 from int256, reverting on
* overflow (when the input is less than smallest int152 or
* greater than largest int152).
*
* Counterpart to Solidity's `int152` operator.
*
* Requirements:
*
* - input must fit into 152 bits
*
* _Available since v4.7._
*/
function toInt152(int256 value) internal pure returns (int152 downcasted) {
downcasted = int152(value);
require(downcasted == value, "SafeCast: value doesn't fit in 152 bits");
}
/**
* @dev Returns the downcasted int144 from int256, reverting on
* overflow (when the input is less than smallest int144 or
* greater than largest int144).
*
* Counterpart to Solidity's `int144` operator.
*
* Requirements:
*
* - input must fit into 144 bits
*
* _Available since v4.7._
*/
function toInt144(int256 value) internal pure returns (int144 downcasted) {
downcasted = int144(value);
require(downcasted == value, "SafeCast: value doesn't fit in 144 bits");
}
/**
* @dev Returns the downcasted int136 from int256, reverting on
* overflow (when the input is less than smallest int136 or
* greater than largest int136).
*
* Counterpart to Solidity's `int136` operator.
*
* Requirements:
*
* - input must fit into 136 bits
*
* _Available since v4.7._
*/
function toInt136(int256 value) internal pure returns (int136 downcasted) {
downcasted = int136(value);
require(downcasted == value, "SafeCast: value doesn't fit in 136 bits");
}
/**
* @dev Returns the downcasted int128 from int256, reverting on
* overflow (when the input is less than smallest int128 or
* greater than largest int128).
*
* Counterpart to Solidity's `int128` operator.
*
* Requirements:
*
* - input must fit into 128 bits
*
* _Available since v3.1._
*/
function toInt128(int256 value) internal pure returns (int128 downcasted) {
downcasted = int128(value);
require(downcasted == value, "SafeCast: value doesn't fit in 128 bits");
}
/**
* @dev Returns the downcasted int120 from int256, reverting on
* overflow (when the input is less than smallest int120 or
* greater than largest int120).
*
* Counterpart to Solidity's `int120` operator.
*
* Requirements:
*
* - input must fit into 120 bits
*
* _Available since v4.7._
*/
function toInt120(int256 value) internal pure returns (int120 downcasted) {
downcasted = int120(value);
require(downcasted == value, "SafeCast: value doesn't fit in 120 bits");
}
/**
* @dev Returns the downcasted int112 from int256, reverting on
* overflow (when the input is less than smallest int112 or
* greater than largest int112).
*
* Counterpart to Solidity's `int112` operator.
*
* Requirements:
*
* - input must fit into 112 bits
*
* _Available since v4.7._
*/
function toInt112(int256 value) internal pure returns (int112 downcasted) {
downcasted = int112(value);
require(downcasted == value, "SafeCast: value doesn't fit in 112 bits");
}
/**
* @dev Returns the downcasted int104 from int256, reverting on
* overflow (when the input is less than smallest int104 or
* greater than largest int104).
*
* Counterpart to Solidity's `int104` operator.
*
* Requirements:
*
* - input must fit into 104 bits
*
* _Available since v4.7._
*/
function toInt104(int256 value) internal pure returns (int104 downcasted) {
downcasted = int104(value);
require(downcasted == value, "SafeCast: value doesn't fit in 104 bits");
}
/**
* @dev Returns the downcasted int96 from int256, reverting on
* overflow (when the input is less than smallest int96 or
* greater than largest int96).
*
* Counterpart to Solidity's `int96` operator.
*
* Requirements:
*
* - input must fit into 96 bits
*
* _Available since v4.7._
*/
function toInt96(int256 value) internal pure returns (int96 downcasted) {
downcasted = int96(value);
require(downcasted == value, "SafeCast: value doesn't fit in 96 bits");
}
/**
* @dev Returns the downcasted int88 from int256, reverting on
* overflow (when the input is less than smallest int88 or
* greater than largest int88).
*
* Counterpart to Solidity's `int88` operator.
*
* Requirements:
*
* - input must fit into 88 bits
*
* _Available since v4.7._
*/
function toInt88(int256 value) internal pure returns (int88 downcasted) {
downcasted = int88(value);
require(downcasted == value, "SafeCast: value doesn't fit in 88 bits");
}
/**
* @dev Returns the downcasted int80 from int256, reverting on
* overflow (when the input is less than smallest int80 or
* greater than largest int80).
*
* Counterpart to Solidity's `int80` operator.
*
* Requirements:
*
* - input must fit into 80 bits
*
* _Available since v4.7._
*/
function toInt80(int256 value) internal pure returns (int80 downcasted) {
downcasted = int80(value);
require(downcasted == value, "SafeCast: value doesn't fit in 80 bits");
}
/**
* @dev Returns the downcasted int72 from int256, reverting on
* overflow (when the input is less than smallest int72 or
* greater than largest int72).
*
* Counterpart to Solidity's `int72` operator.
*
* Requirements:
*
* - input must fit into 72 bits
*
* _Available since v4.7._
*/
function toInt72(int256 value) internal pure returns (int72 downcasted) {
downcasted = int72(value);
require(downcasted == value, "SafeCast: value doesn't fit in 72 bits");
}
/**
* @dev Returns the downcasted int64 from int256, reverting on
* overflow (when the input is less than smallest int64 or
* greater than largest int64).
*
* Counterpart to Solidity's `int64` operator.
*
* Requirements:
*
* - input must fit into 64 bits
*
* _Available since v3.1._
*/
function toInt64(int256 value) internal pure returns (int64 downcasted) {
downcasted = int64(value);
require(downcasted == value, "SafeCast: value doesn't fit in 64 bits");
}
/**
* @dev Returns the downcasted int56 from int256, reverting on
* overflow (when the input is less than smallest int56 or
* greater than largest int56).
*
* Counterpart to Solidity's `int56` operator.
*
* Requirements:
*
* - input must fit into 56 bits
*
* _Available since v4.7._
*/
function toInt56(int256 value) internal pure returns (int56 downcasted) {
downcasted = int56(value);
require(downcasted == value, "SafeCast: value doesn't fit in 56 bits");
}
/**
* @dev Returns the downcasted int48 from int256, reverting on
* overflow (when the input is less than smallest int48 or
* greater than largest int48).
*
* Counterpart to Solidity's `int48` operator.
*
* Requirements:
*
* - input must fit into 48 bits
*
* _Available since v4.7._
*/
function toInt48(int256 value) internal pure returns (int48 downcasted) {
downcasted = int48(value);
require(downcasted == value, "SafeCast: value doesn't fit in 48 bits");
}
/**
* @dev Returns the downcasted int40 from int256, reverting on
* overflow (when the input is less than smallest int40 or
* greater than largest int40).
*
* Counterpart to Solidity's `int40` operator.
*
* Requirements:
*
* - input must fit into 40 bits
*
* _Available since v4.7._
*/
function toInt40(int256 value) internal pure returns (int40 downcasted) {
downcasted = int40(value);
require(downcasted == value, "SafeCast: value doesn't fit in 40 bits");
}
/**
* @dev Returns the downcasted int32 from int256, reverting on
* overflow (when the input is less than smallest int32 or
* greater than largest int32).
*
* Counterpart to Solidity's `int32` operator.
*
* Requirements:
*
* - input must fit into 32 bits
*
* _Available since v3.1._
*/
function toInt32(int256 value) internal pure returns (int32 downcasted) {
downcasted = int32(value);
require(downcasted == value, "SafeCast: value doesn't fit in 32 bits");
}
/**
* @dev Returns the downcasted int24 from int256, reverting on
* overflow (when the input is less than smallest int24 or
* greater than largest int24).
*
* Counterpart to Solidity's `int24` operator.
*
* Requirements:
*
* - input must fit into 24 bits
*
* _Available since v4.7._
*/
function toInt24(int256 value) internal pure returns (int24 downcasted) {
downcasted = int24(value);
require(downcasted == value, "SafeCast: value doesn't fit in 24 bits");
}
/**
* @dev Returns the downcasted int16 from int256, reverting on
* overflow (when the input is less than smallest int16 or
* greater than largest int16).
*
* Counterpart to Solidity's `int16` operator.
*
* Requirements:
*
* - input must fit into 16 bits
*
* _Available since v3.1._
*/
function toInt16(int256 value) internal pure returns (int16 downcasted) {
downcasted = int16(value);
require(downcasted == value, "SafeCast: value doesn't fit in 16 bits");
}
/**
* @dev Returns the downcasted int8 from int256, reverting on
* overflow (when the input is less than smallest int8 or
* greater than largest int8).
*
* Counterpart to Solidity's `int8` operator.
*
* Requirements:
*
* - input must fit into 8 bits
*
* _Available since v3.1._
*/
function toInt8(int256 value) internal pure returns (int8 downcasted) {
downcasted = int8(value);
require(downcasted == value, "SafeCast: value doesn't fit in 8 bits");
}
/**
* @dev Converts an unsigned uint256 into a signed int256.
*
* Requirements:
*
* - input must be less than or equal to maxInt256.
*
* _Available since v3.0._
*/
function toInt256(uint256 value) internal pure returns (int256) {
// Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive
require(value <= uint256(type(int256).max), "SafeCast: value doesn't fit in an int256");
return int256(value);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol)
pragma solidity ^0.8.0;
/**
* @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 v4.9.0) (utils/ShortStrings.sol)
pragma solidity ^0.8.8;
import "./StorageSlot.sol";
// | string | 0xAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
// | length | 0x BB |
type ShortString is bytes32;
/**
* @dev This library provides functions to convert short memory strings
* into a `ShortString` type that can be used as an immutable variable.
*
* Strings of arbitrary length can be optimized using this library if
* they are short enough (up to 31 bytes) by packing them with their
* length (1 byte) in a single EVM word (32 bytes). Additionally, a
* fallback mechanism can be used for every other case.
*
* Usage example:
*
* ```solidity
* contract Named {
* using ShortStrings for *;
*
* ShortString private immutable _name;
* string private _nameFallback;
*
* constructor(string memory contractName) {
* _name = contractName.toShortStringWithFallback(_nameFallback);
* }
*
* function name() external view returns (string memory) {
* return _name.toStringWithFallback(_nameFallback);
* }
* }
* ```
*/
library ShortStrings {
// Used as an identifier for strings longer than 31 bytes.
bytes32 private constant _FALLBACK_SENTINEL = 0x00000000000000000000000000000000000000000000000000000000000000FF;
error StringTooLong(string str);
error InvalidShortString();
/**
* @dev Encode a string of at most 31 chars into a `ShortString`.
*
* This will trigger a `StringTooLong` error is the input string is too long.
*/
function toShortString(string memory str) internal pure returns (ShortString) {
bytes memory bstr = bytes(str);
if (bstr.length > 31) {
revert StringTooLong(str);
}
return ShortString.wrap(bytes32(uint256(bytes32(bstr)) | bstr.length));
}
/**
* @dev Decode a `ShortString` back to a "normal" string.
*/
function toString(ShortString sstr) internal pure returns (string memory) {
uint256 len = byteLength(sstr);
// using `new string(len)` would work locally but is not memory safe.
string memory str = new string(32);
/// @solidity memory-safe-assembly
assembly {
mstore(str, len)
mstore(add(str, 0x20), sstr)
}
return str;
}
/**
* @dev Return the length of a `ShortString`.
*/
function byteLength(ShortString sstr) internal pure returns (uint256) {
uint256 result = uint256(ShortString.unwrap(sstr)) & 0xFF;
if (result > 31) {
revert InvalidShortString();
}
return result;
}
/**
* @dev Encode a string into a `ShortString`, or write it to storage if it is too long.
*/
function toShortStringWithFallback(string memory value, string storage store) internal returns (ShortString) {
if (bytes(value).length < 32) {
return toShortString(value);
} else {
StorageSlot.getStringSlot(store).value = value;
return ShortString.wrap(_FALLBACK_SENTINEL);
}
}
/**
* @dev Decode a string that was encoded to `ShortString` or written to storage using {setWithFallback}.
*/
function toStringWithFallback(ShortString value, string storage store) internal pure returns (string memory) {
if (ShortString.unwrap(value) != _FALLBACK_SENTINEL) {
return toString(value);
} else {
return store;
}
}
/**
* @dev Return the length of a string that was encoded to `ShortString` or written to storage using {setWithFallback}.
*
* WARNING: This will return the "byte length" of the string. This may not reflect the actual length in terms of
* actual characters as the UTF-8 encoding of a single character can span over multiple bytes.
*/
function byteLengthWithFallback(ShortString value, string storage store) internal view returns (uint256) {
if (ShortString.unwrap(value) != _FALLBACK_SENTINEL) {
return byteLength(value);
} else {
return bytes(store).length;
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/StorageSlot.sol)
// This file was procedurally generated from scripts/generate/templates/StorageSlot.js.
pragma solidity ^0.8.0;
/**
* @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(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
* StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
* }
* }
* ```
*
* _Available since v4.1 for `address`, `bool`, `bytes32`, `uint256`._
* _Available since v4.9 for `string`, `bytes`._
*/
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: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol)
pragma solidity ^0.8.0;
import "./math/Math.sol";
import "./math/SignedMath.sol";
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant _SYMBOLS = "0123456789abcdef";
uint8 private constant _ADDRESS_LENGTH = 20;
/**
* @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), _SYMBOLS))
}
value /= 10;
if (value == 0) break;
}
return buffer;
}
}
/**
* @dev Converts a `int256` to its ASCII `string` decimal representation.
*/
function toString(int256 value) internal pure returns (string memory) {
return string(abi.encodePacked(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) {
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] = _SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
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 keccak256(bytes(a)) == keccak256(bytes(b));
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
pragma abicoder v2;
import "../interfaces/IInceptionBridge.sol";
import "../interfaces/IInceptionBridgeErrors.sol";
/// @author The InceptionLRT team
/// @title The InceptionBridgeStorage contract
/// @notice Stores variables for the InceptionBridge contract and facilitates their updates.
abstract contract InceptionBridgeStorage is
IInceptionBridgeStorage,
IInceptionBridgeErrors
{
uint256 internal constant _PROOF_LENGTH = 0x100;
uint256 internal _globalNonce;
address public notary;
mapping(bytes32 => bool) internal _usedProofs;
mapping(uint256 => address) internal _bridgeAddressByChainId;
/// @dev keccak256(fromToken,fromChain,_bridgeAddressByChainId(destinationChain), destinationChain) => destinationToken
mapping(bytes32 => address) internal _destinationTokens;
uint256 public shortCapDuration;
/// @dev token => Cap per 'shortCapTime'
mapping(address => uint256) public shortCaps;
/// @dev token => (epochTime/shortCapDuration) => Current Deposits
mapping(address => mapping(uint256 => uint256)) public shortCapsDeposit;
/// @dev token => (epochTime/shortCapDuration) => Current Withdraws
mapping(address => mapping(uint256 => uint256)) public shortCapsWithdraw;
uint256 public longCapDuration;
/// @dev token => cap per 'longCapTime'
mapping(address => uint256) public longCaps;
/// @dev token => (epochTime/longCapDuration) => Current Deposits
mapping(address => mapping(uint256 => uint256)) public longCapsDeposit;
/// @dev token => (epochTime/longCapDuration) => Current Withdraws
mapping(address => mapping(uint256 => uint256)) public longCapsWithdraw;
address internal _previousSender;
uint256 internal _previousDepositBlockNum;
/// token -> lockbox
mapping(address => address) public xerc20TokenRegistry;
/// @notice WARNING: Keep it up-to-date
uint256[50 - 16] private __gap;
function __initInceptionBridgeStorage(address notaryAddress) internal {
_setNotary(notaryAddress);
_setDefaultCrosschainThreshold();
}
function _beforeDeposit() internal {
if (_previousSender != address(0) && _previousDepositBlockNum != 0) {
if (
_previousSender == tx.origin &&
_previousDepositBlockNum == block.number
) {
revert MultipleDeposits();
}
}
_previousSender = tx.origin;
_previousDepositBlockNum = block.number;
}
function _updateDepositCaps(address fromToken, uint256 amount) internal {
/// Short(default: per hour)
if (
shortCapsDeposit[fromToken][getCurrentStamp(shortCapDuration)] +
amount >
shortCaps[fromToken]
) {
revert ShortCapExceeded(
shortCaps[fromToken],
shortCapsDeposit[fromToken][getCurrentStamp(shortCapDuration)] +
amount
);
}
shortCapsDeposit[fromToken][
getCurrentStamp(shortCapDuration)
] += amount;
/// Long(default: per day)
if (
longCapsDeposit[fromToken][getCurrentStamp(longCapDuration)] +
amount >
longCaps[fromToken]
) {
revert LongCapExceeded(
longCaps[fromToken],
longCapsDeposit[fromToken][getCurrentStamp(longCapDuration)] +
amount
);
}
longCapsDeposit[fromToken][getCurrentStamp(longCapDuration)] += amount;
}
function _updateWithdrawCaps(address token, uint256 amount) internal {
/// Short(default: per hour)
if (
shortCapsWithdraw[token][getCurrentStamp(shortCapDuration)] +
amount >
shortCaps[token]
) {
revert ShortCapExceeded(
shortCaps[token],
shortCapsWithdraw[token][getCurrentStamp(shortCapDuration)] +
amount
);
}
shortCapsWithdraw[token][getCurrentStamp(shortCapDuration)] += amount;
/// Long(default: per day)
if (
longCapsWithdraw[token][getCurrentStamp(longCapDuration)] + amount >
longCaps[token]
) {
revert LongCapExceeded(
longCaps[token],
longCapsWithdraw[token][getCurrentStamp(longCapDuration)] +
amount
);
}
longCapsWithdraw[token][getCurrentStamp(longCapDuration)] += amount;
}
function _setNotary(address notaryAddress) internal {
if (notaryAddress == address(0x0)) revert NullAddress();
emit NotaryChanged(notary, notaryAddress);
notary = notaryAddress;
}
/*//////////////////////////
////// SET functions //////
////////////////////////*/
function _setShortCap(address token, uint256 newValue) internal {
if (token == address(0x0)) revert NullAddress();
uint256 prevValue = shortCaps[token];
emit ShortCapChanged(token, prevValue, newValue);
shortCaps[token] = newValue;
}
function _setShortCapDuration(uint256 newValue) internal {
emit ShortCapDurationChanged(shortCapDuration, newValue);
shortCapDuration = newValue;
}
function _setLongCapDuration(uint256 newValue) internal {
emit LongCapDurationChanged(longCapDuration, newValue);
longCapDuration = newValue;
}
function _setLongCap(address token, uint256 newValue) internal {
if (token == address(0x0)) {
revert NullAddress();
}
emit LongCapChanged(token, longCaps[token], newValue);
longCaps[token] = newValue;
}
function _setDefaultCrosschainThreshold() internal {
shortCapDuration = 1 hours;
longCapDuration = 1 days;
}
function _addBridge(address bridge, uint256 destinationChain) internal {
if (bridge == address(0x0)) {
revert NullAddress();
}
if (destinationChain == 0) {
revert InvalidChain();
}
if (_bridgeAddressByChainId[destinationChain] != address(0x00)) {
revert BridgeAlreadyAdded();
}
_bridgeAddressByChainId[destinationChain] = bridge;
emit BridgeAdded(bridge, destinationChain);
}
function _removeBridge(uint256 destinationChain) internal {
if (_bridgeAddressByChainId[destinationChain] == address(0x00)) {
revert BridgeNotExist();
}
address bridge = _bridgeAddressByChainId[destinationChain];
delete _bridgeAddressByChainId[destinationChain];
emit BridgeRemoved(bridge, destinationChain);
}
function _addDestination(
address fromToken,
uint256 destinationChain,
address toToken
) internal {
if (_bridgeAddressByChainId[destinationChain] == address(0))
revert UnknownDestinationChain();
if (fromToken == address(0) || toToken == address(0))
revert NullAddress();
bytes32 direction = keccak256(
abi.encodePacked(
fromToken,
block.chainid,
_bridgeAddressByChainId[destinationChain],
destinationChain
)
);
if (_destinationTokens[direction] != address(0))
revert DestinationAlreadyExists();
_destinationTokens[direction] = toToken;
emit DestinationAdded(fromToken, toToken, destinationChain);
}
function _removeDestination(
address fromToken,
uint256 destinationChain,
address toToken
) internal {
if (_bridgeAddressByChainId[destinationChain] == address(0))
revert UnknownDestinationChain();
bytes32 direction = keccak256(
abi.encodePacked(
fromToken,
block.chainid,
_bridgeAddressByChainId[destinationChain],
destinationChain
)
);
if (_destinationTokens[direction] != toToken)
revert UnknownDestination();
delete _destinationTokens[direction];
emit DestinationRemoved(fromToken, toToken, destinationChain);
}
function _setXERC20Lockbox(address token, address lockbox) internal {
if (address(token) == address(0) || address(lockbox) == address(0))
revert NullAddress();
if (xerc20TokenRegistry[token] != address(0))
revert XERC20LockboxAlreadyAdded();
emit XERC20LockboxAdded(token, lockbox);
xerc20TokenRegistry[token] = lockbox;
}
function getCurrentStamp(uint256 duration) public view returns (uint256) {
return (block.timestamp / duration) * duration;
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "solmate/src/utils/CREATE3.sol";
import "../XERC20/XERC20.sol";
import "../XERC20/XERC20Lockbox.sol";
import "../interfaces/IFactory.sol";
/// @author The InceptionLRT team
/// @title The BridgeFactory Contract
/// @notice Facilitates the deployment of contracts via CREATE2 and CREATE3
contract BridgeFactory is IFactory {
/**
*****************************************************************************
****************************** CREATE2 FACTORY ******************************
*****************************************************************************
*/
bytes32 public bridgeSalt = "InceptionLRT Factory";
function deployCreate2(
bytes calldata creationCode
) external returns (address) {
return _deployCreate2(creationCode, msg.sender);
}
function _deployCreate2(
bytes memory bytecode,
address _sender
) internal returns (address) {
address addr = _create2(bytecode, _sender);
emit ContractCreated(addr);
return addr;
}
function _create2(
bytes memory bytecode,
address _sender
) internal returns (address) {
address payable addr;
bytes32 salt = _getSalt(_sender);
assembly {
addr := create2(0, add(bytecode, 0x20), mload(bytecode), salt)
if iszero(extcodesize(addr)) {
revert(0, 0)
}
}
return addr;
}
function getDeploymentCreate2Address(
bytes memory bytecode,
address _sender
) external view returns (address) {
bytes32 salt = _getSalt(_sender);
bytes32 rawAddress = keccak256(
abi.encodePacked(
bytes1(0xff),
address(this),
salt,
keccak256(bytecode)
)
);
return address(bytes20(rawAddress << 96));
}
function _getSalt(address _sender) internal view returns (bytes32) {
return keccak256(abi.encodePacked(bridgeSalt, _sender));
}
/**
****************************************************************************
****************************** XERC20 FACTORY ******************************
****************************************************************************
*/
/**
* @notice Deploys an XERC20 contract using CREATE3
* @dev _limits and _minters must be the same length
* @param _name The name of the token
* @param _symbol The symbol of the token
* @return _xerc20 The address of the xerc20
*/
function deployXERC20(
string memory _name,
string memory _symbol
) external returns (address _xerc20) {
_xerc20 = _deployXERC20(_name, _symbol);
emit XERC20Deployed(_xerc20);
}
/**
* @notice Deploys an XERC20Lockbox contract using CREATE3
*
* @dev When deploying a lockbox for the gas token of the chain, then, the base token needs to be address(0)
* @param _xerc20 The address of the xerc20 that you want to deploy a lockbox for
* @param _baseToken The address of the base token that you want to lock
* @param _isNative Whether or not the base token is the native (gas) token of the chain. Eg: MATIC for polygon chain
* @return _lockbox The address of the lockbox
*/
function deployLockbox(
address _xerc20,
address _baseToken,
bool _isNative
) external returns (address _lockbox) {
if (
(_baseToken == address(0) && !_isNative) ||
(_isNative && _baseToken != address(0))
) revert IXERC20Factory_BadTokenAddress();
if (XERC20(_xerc20).owner() != msg.sender)
revert IXERC20Factory_NotOwner();
_lockbox = _deployLockbox(_xerc20, _baseToken, _isNative);
emit LockboxDeployed(_lockbox);
}
/**
* @notice Deploys an XERC20 contract using CREATE3
* @dev _limits and _minters must be the same length
* @param _name The name of the token
* @param _symbol The symbol of the token
* @return _xerc20 The address of the xerc20
*/
function _deployXERC20(
string memory _name,
string memory _symbol
) internal returns (address _xerc20) {
address deployer = msg.sender;
bytes32 _salt = keccak256(abi.encodePacked(_name, _symbol, deployer));
bytes memory _creation = type(XERC20).creationCode;
bytes memory _bytecode = abi.encodePacked(
_creation,
abi.encode(_name, _symbol, address(this))
);
_xerc20 = CREATE3.deploy(_salt, _bytecode, 0);
XERC20(_xerc20).transferOwnership(deployer);
}
/**
* @notice Deploys an XERC20Lockbox contract using CREATE3
*
* @dev When deploying a lockbox for the gas token of the chain, then, the base token needs to be address(0)
* @param _xerc20 The address of the xerc20 that you want to deploy a lockbox for
* @param _baseToken The address of the base token that you want to lock
* @param _isNative Whether or not the base token is the native (gas) token of the chain. Eg: MATIC for polygon chain
* @return _lockbox The address of the lockbox
*/
function _deployLockbox(
address _xerc20,
address _baseToken,
bool _isNative
) internal returns (address _lockbox) {
address deployer = msg.sender;
bytes32 _salt = keccak256(
abi.encodePacked(_xerc20, _baseToken, deployer)
);
bytes memory _bytecode = abi.encodePacked(
type(XERC20Lockbox).creationCode,
abi.encode(_xerc20, _baseToken, _isNative)
);
_lockbox = CREATE3.deploy(_salt, _bytecode, 0);
XERC20(_xerc20).setLockbox(_lockbox);
}
function deployCreate3(
bytes calldata creationCode,
bytes32 _salt
) external returns (address) {
return _deployCreate3(creationCode, _salt);
}
function _deployCreate3(
bytes memory bytecode,
bytes32 _salt
) internal returns (address) {
address addr = CREATE3.deploy(_salt, bytecode, 0);
emit ContractCreated(addr);
return addr;
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
interface IERC20Mintable {
function mint(address account, uint256 amount) external;
function burn(address account, uint256 amount) external;
function chargeFrom(
address sender,
address recipient,
uint256 amount
) external returns (bool);
}
interface IERC20Pegged {
function getOrigin() external view returns (uint256, address);
}
interface IERC20Extra {
function name() external returns (string memory);
function decimals() external returns (uint8);
function symbol() external returns (string memory);
}
interface IERC20MetadataChangeable {
event NameChanged(string prevValue, string newValue);
event SymbolChanged(string prevValue, string newValue);
function changeName(bytes32) external;
function changeSymbol(bytes32) external;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
interface ICREATE2Factory {
event ContractCreated(address indexed addr);
function deployCreate2(
bytes calldata creationCode
) external returns (address);
}
interface ICREATE3Factory {
/**
* @notice Emitted when a new XERC20 is deployed
* @param _xerc20 The address of the xerc20
*/
event XERC20Deployed(address _xerc20);
/**
* @notice Emitted when a new XERC20Lockbox is deployed
* @param _lockbox The address of the lockbox
*/
event LockboxDeployed(address _lockbox);
/**
* @notice Reverts when a non-owner attempts to call
*/
error IXERC20Factory_NotOwner();
/**
* @notice Reverts when a lockbox is trying to be deployed from a malicious address
*/
error IXERC20Factory_BadTokenAddress();
/**
* @notice Reverts when a lockbox is already deployed
*/
error IXERC20Factory_LockboxAlreadyDeployed();
/**
* @notice Reverts when a the length of arrays sent is incorrect
*/
error IXERC20Factory_InvalidLength();
function deployXERC20(
string memory _name,
string memory _symbol
) external returns (address _xerc20);
function deployLockbox(
address _xerc20,
address _baseToken,
bool _isNative
) external returns (address _lockbox);
}
interface IFactory is ICREATE2Factory, ICREATE3Factory {}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "./IERC20.sol";
interface IInceptionBridgeStorage {
struct Metadata {
bytes32 name;
bytes32 symbol;
uint256 originChain;
address originAddress;
}
event ShortCapChanged(
address indexed token,
uint256 prevValue,
uint256 newValue
);
event LongCapChanged(
address indexed token,
uint256 prevValue,
uint256 newValue
);
event ShortCapDurationChanged(uint256 prevValue, uint256 newValue);
event LongCapDurationChanged(uint256 prevValue, uint256 newValue);
event BridgeAdded(address indexed bridge, uint256 destinationChain);
event BridgeRemoved(address indexed bridge, uint256 destinationChain);
event DestinationAdded(
address indexed fromToken,
address indexed toToken,
uint256 toChain
);
event DestinationRemoved(
address indexed fromToken,
address indexed toToken,
uint256 toChain
);
event NotaryChanged(address indexed prevValue, address indexed newValue);
event XERC20LockboxAdded(address indexed token, address indexed lockbox);
}
interface IInceptionBridge {
event Deposited(
uint256 destinationChain,
address indexed destinationBridge,
address indexed sender,
address indexed receiver,
address fromToken,
address toToken,
uint256 amount,
uint256 nonce,
IInceptionBridgeStorage.Metadata metadata
);
event Withdrawn(
bytes32 receiptHash,
address indexed sender,
address indexed receiver,
address fromToken,
address toToken,
uint256 amount
);
function deposit(
address fromToken,
uint256 destinationChain,
address receiver,
uint256 amount
) external;
function withdraw(
bytes calldata encodedProof,
bytes calldata rawReceipt,
bytes memory receiptRootSignature
) external;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
interface IInceptionBridgeErrors {
/// @dev
error ShortCapExceeded(uint256 limit, uint256 current);
/// @dev
error LongCapExceeded(uint256 limit, uint256 current);
/// @dev
error BridgeAlreadyAdded();
error BridgeNotExist();
error InvalidChain();
error MultipleDeposits();
/// @dev
error ReceiptWrongChain(uint256 required, uint256 provided);
/// @dev
error InvalidContractAddress();
error NullAddress();
/// @dev
error UnknownBridge();
/// @dev
error WrongSignature();
error WithdrawalProofUsed();
error InvalidAssetType();
error InvalidFromTokenAddress();
error UnknownDestination();
error WrongDestinationBridge();
error XERC20LockboxAlreadyAdded();
error XERC20ZeroAddress();
/// @notice non-existing-bridge
error UnknownDestinationChain();
error DestinationAlreadyExists();
error BurnFailed();
error MintFailed();
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
interface IERC20Errors {
/**
* @notice Reverts when a user with too low of a limit tries to call mint/burn
*/
error IXERC20_NotHighEnoughLimits();
/**
* @notice Reverts when caller is not the factory
*/
error IXERC20_NotFactory();
/**
* @notice Reverts when caller sets too small _limit
*/
error IXERC20_WrongBridgeLimit();
}
interface IXERC20 is IERC20Errors {
/**
* @notice Contains the full minting and burning data for a particular bridge
*
* @param minterParams The minting parameters for the bridge
* @param burnerParams The burning parameters for the bridge
*/
struct Bridge {
BridgeParameters minterParams;
BridgeParameters burnerParams;
}
/**
* @notice Emits when a lockbox is set
*
* @param _lockbox The address of the lockbox
*/
event LockboxSet(address _lockbox);
/**
* @notice Emits when a limit is set
*
* @param _mintingLimit The updated minting limit we are setting to the bridge
* @param _burningLimit The updated burning limit we are setting to the bridge
* @param _bridge The address of the bridge we are setting the limit too
*/
event BridgeLimitsSet(
uint256 _mintingLimit,
uint256 _burningLimit,
address indexed _bridge
);
/**
* @notice Contains the mint or burn parameters for a bridge
*
* @param timestamp The timestamp of the last mint/burn
* @param ratePerSecond The rate per second of the bridge
* @param maxLimit The max limit of the bridge
* @param currentLimit The current limit of the bridge
*/
struct BridgeParameters {
uint256 timestamp;
uint256 ratePerSecond;
uint256 maxLimit;
uint256 currentLimit;
}
/**
* @notice Sets the lockbox address
*
* @param _lockbox The address of the lockbox
*/
function setLockbox(address _lockbox) external;
/**
* @notice Updates the limits of any bridge
* @dev Can only be called by the owner
* @param _mintingLimit The updated minting limit we are setting to the bridge
* @param _burningLimit The updated burning limit we are setting to the bridge
* @param _bridge The address of the bridge we are setting the limits too
*/
function setBridgeLimits(
address _bridge,
uint256 _mintingLimit,
uint256 _burningLimit
) external;
/**
* @notice Returns the max limit of a minter
*
* @param _minter The minter we are viewing the limits of
* @return _limit The limit the minter has
*/
function mintingMaxLimitOf(
address _minter
) external view returns (uint256 _limit);
/**
* @notice Returns the max limit of a bridge
*
* @param _bridge the bridge we are viewing the limits of
* @return _limit The limit the bridge has
*/
function burningMaxLimitOf(
address _bridge
) external view returns (uint256 _limit);
/**
* @notice Returns the current limit of a minter
*
* @param _minter The minter we are viewing the limits of
* @return _limit The limit the minter has
*/
function mintingCurrentLimitOf(
address _minter
) external view returns (uint256 _limit);
/**
* @notice Returns the current limit of a bridge
*
* @param _bridge the bridge we are viewing the limits of
* @return _limit The limit the bridge has
*/
function burningCurrentLimitOf(
address _bridge
) external view returns (uint256 _limit);
/**
* @notice Mints tokens for a user
* @dev Can only be called by a minter
* @param _user The address of the user who needs tokens minted
* @param _amount The amount of tokens being minted
*/
function mint(address _user, uint256 _amount) external;
/**
* @notice Burns tokens for a user
* @dev Can only be called by a minter
* @param _user The address of the user who needs tokens burned
* @param _amount The amount of tokens being burned
*/
function burn(address _user, uint256 _amount) external;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "@openzeppelin/contracts/interfaces/IERC20.sol";
import "./IXERC20.sol";
interface IXERC20LockboxErrors {
/// @notice Reverts when a user tries to deposit native tokens on a non-native lockbox
error IXERC20Lockbox_NotNative();
/// @notice Reverts when a user tries to deposit non-native tokens on a native lockbox
error IXERC20Lockbox_Native();
/// @notice Reverts when a user tries to withdraw and the call fails
error IXERC20Lockbox_WithdrawFailed();
/// @notice Reverts when a user tries to withdraw to the XERC20Lockbox itself
error IXERC20Lockbox_WrongReceiver();
}
interface IXERC20Lockbox is IXERC20LockboxErrors {
/**
* @notice Emitted when tokens are deposited into the lockbox
*
* @param _sender The address of the user who deposited
* @param _amount The amount of tokens deposited
*/
event Deposit(address _sender, uint256 _amount);
/**
* @notice Emitted when tokens are withdrawn from the lockbox
*
* @param _sender The address of the user who withdrew
* @param _amount The amount of tokens withdrawn
*/
event Withdraw(address _sender, uint256 _amount);
function XERC20() external view returns (IXERC20 xerc20);
function ERC20() external view returns (IERC20 erc20);
/**
* @notice Deposit ERC20 tokens into the lockbox
*
* @param _amount The amount of tokens to deposit
*/
function deposit(uint256 _amount) external;
/**
* @notice Deposit ERC20 tokens into the lockbox, and send the XERC20 to a user
*
* @param _user The user to send the XERC20 to
* @param _amount The amount of tokens to deposit
*/
function depositTo(address _user, uint256 _amount) external;
/**
* @notice Deposit the native asset into the lockbox, and send the XERC20 to a user
*
* @param _user The user to send the XERC20 to
*/
function depositNativeTo(address _user) external payable;
/**
* @notice Withdraw ERC20 tokens from the lockbox
*
* @param _amount The amount of tokens to withdraw
*/
function withdraw(uint256 _amount) external;
/**
* @notice Withdraw ERC20 tokens from the lockbox
*
* @param _user The user to withdraw to
* @param _amount The amount of tokens to withdraw
*/
function withdrawTo(address _user, uint256 _amount) external;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
library CallDataRLPReader {
uint8 constant STRING_SHORT_START = 0x80;
uint8 constant STRING_LONG_START = 0xb8;
uint8 constant LIST_SHORT_START = 0xc0;
uint8 constant LIST_LONG_START = 0xf8;
uint8 constant WORD_SIZE = 32;
function beginIteration(
uint256 listOffset
) internal pure returns (uint256 iter) {
return listOffset + _payloadOffset(listOffset);
}
function next(uint256 iter) internal pure returns (uint256 nextIter) {
return iter + itemLength(iter);
}
function payloadLen(
uint256 ptr,
uint256 len
) internal pure returns (uint256) {
return len - _payloadOffset(ptr);
}
function receiver(uint256 ptr) internal pure returns (address) {
return address(uint160(toUint(ptr, 21)));
}
function toUint(uint256 ptr, uint256 len) internal pure returns (uint256) {
require(len > 0 && len <= 33);
uint256 offset = _payloadOffset(ptr);
uint256 numLen = len - offset;
uint256 result;
assembly {
result := calldataload(add(ptr, offset))
// cut off redundant bytes
result := shr(mul(8, sub(32, numLen)), result)
}
return result;
}
function toUintStrict(uint256 ptr) internal pure returns (uint256) {
// one byte prefix
uint256 result;
assembly {
result := calldataload(add(ptr, 1))
}
return result;
}
function rawDataPtr(uint256 ptr) internal pure returns (uint256) {
return ptr + _payloadOffset(ptr);
}
/// @return entire rlp item byte length
function itemLength(uint256 callDataPtr) internal pure returns (uint256) {
uint256 itemLen;
uint256 byte0;
assembly {
byte0 := byte(0, calldataload(callDataPtr))
}
if (byte0 < STRING_SHORT_START) itemLen = 1;
else if (byte0 < STRING_LONG_START)
itemLen = byte0 - STRING_SHORT_START + 1;
else if (byte0 < LIST_SHORT_START) {
assembly {
let byteLen := sub(byte0, 0xb7) // # of bytes the actual length is
callDataPtr := add(callDataPtr, 1) // skip over the first byte
/* 32 byte word size */
let dataLen := shr(
mul(8, sub(32, byteLen)),
calldataload(callDataPtr)
)
itemLen := add(dataLen, add(byteLen, 1))
}
} else if (byte0 < LIST_LONG_START) {
itemLen = byte0 - LIST_SHORT_START + 1;
} else {
assembly {
let byteLen := sub(byte0, 0xf7)
callDataPtr := add(callDataPtr, 1)
let dataLen := shr(
mul(8, sub(32, byteLen)),
calldataload(callDataPtr)
)
itemLen := add(dataLen, add(byteLen, 1))
}
}
return itemLen;
}
/// @return number of bytes until the data
function _payloadOffset(
uint256 callDataPtr
) private pure returns (uint256) {
uint256 byte0;
assembly {
byte0 := byte(0, calldataload(callDataPtr))
}
if (byte0 < STRING_SHORT_START) return 0;
else if (
byte0 < STRING_LONG_START ||
(byte0 >= LIST_SHORT_START && byte0 < LIST_LONG_START)
) return 1;
else if (byte0 < LIST_SHORT_START)
return byte0 - (STRING_LONG_START - 1) + 1;
else return byte0 - (LIST_LONG_START - 1) + 1;
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "./CallDataRLPReader.sol";
import "./Utils.sol";
import "../interfaces/IInceptionBridge.sol";
library EthereumVerifier {
bytes32 constant TOPIC_DEPOSITED =
keccak256(
"Deposited(uint256,address,address,address,address,address,uint256,uint256,(bytes32,bytes32,uint256,address))"
);
enum DepositType {
None,
TokenDeposit
}
struct State {
bytes32 receiptHash;
address contractAddress;
address destinationContract;
uint256 chainId;
address sender;
address receiver;
address fromToken;
address toToken;
uint256 amount;
uint256 nonce;
// metadata fields (we can't use Metadata struct here because of Solidity struct memory layout)
bytes32 symbol;
bytes32 name;
uint256 originChain;
address originToken;
}
function getMetadata(
State memory state
) internal pure returns (IInceptionBridgeStorage.Metadata memory) {
IInceptionBridgeStorage.Metadata memory metadata;
assembly {
metadata := add(state, 0x120)
}
return metadata;
}
function parseTransactionReceipt(
uint256 receiptOffset
) internal pure returns (State memory state, DepositType depositType) {
uint256 iter = CallDataRLPReader.beginIteration(receiptOffset + 0x20);
{
/* postStateOrStatus - we must ensure that tx is not reverted */
uint256 statusOffset = iter;
iter = CallDataRLPReader.next(iter);
require(
CallDataRLPReader.payloadLen(
statusOffset,
iter - statusOffset
) == 1,
"EthereumVerifier: tx is reverted"
);
}
/* skip cumulativeGasUsed */
iter = CallDataRLPReader.next(iter);
/* logs - we need to find our logs */
uint256 logs = iter;
iter = CallDataRLPReader.next(iter);
uint256 logsIter = CallDataRLPReader.beginIteration(logs);
for (; logsIter < iter; ) {
uint256 log = logsIter;
logsIter = CallDataRLPReader.next(logsIter);
/* make sure there is only one peg-in event in logs */
DepositType logType = _decodeReceiptLogs(state, log);
if (logType != DepositType.None) {
require(
depositType == DepositType.None,
"EthereumVerifier: multiple logs"
);
depositType = logType;
}
}
/* don't allow to process if peg-in type is unknown */
require(
depositType != DepositType.None,
"EthereumVerifier: missing logs"
);
return (state, depositType);
}
function _decodeReceiptLogs(
State memory state,
uint256 log
) internal pure returns (DepositType depositType) {
uint256 logIter = CallDataRLPReader.beginIteration(log);
address contractAddress;
{
/* parse smart contract address */
uint256 addressOffset = logIter;
logIter = CallDataRLPReader.next(logIter);
contractAddress = CallDataRLPReader.receiver(addressOffset);
}
/* topics */
bytes32 mainTopic;
address destinationContract;
address sender;
address receiver;
{
uint256 topicsIter = logIter;
logIter = CallDataRLPReader.next(logIter);
// Must be 4 topics RLP encoded: event signature, destinationContract, sender, receiver
// Each topic RLP encoded is 33 bytes (0xa0[32 bytes data])
// Total payload: 132 bytes. Since it's list with total size bigger than 55 bytes we need 2 bytes prefix (0xf863)
// So total size of RLP encoded topics array must be 134
if (CallDataRLPReader.itemLength(topicsIter) != 134) {
return DepositType.None;
}
topicsIter = CallDataRLPReader.beginIteration(topicsIter);
mainTopic = bytes32(CallDataRLPReader.toUintStrict(topicsIter));
topicsIter = CallDataRLPReader.next(topicsIter);
destinationContract = address(
bytes20(uint160(CallDataRLPReader.toUintStrict(topicsIter)))
);
topicsIter = CallDataRLPReader.next(topicsIter);
sender = address(
bytes20(uint160(CallDataRLPReader.toUintStrict(topicsIter)))
);
topicsIter = CallDataRLPReader.next(topicsIter);
receiver = address(
bytes20(uint160(CallDataRLPReader.toUintStrict(topicsIter)))
);
topicsIter = CallDataRLPReader.next(topicsIter);
require(topicsIter == logIter); // safety check that iteration is finished
}
uint256 ptr = CallDataRLPReader.rawDataPtr(logIter);
logIter = CallDataRLPReader.next(logIter);
uint256 len = logIter - ptr;
{
// parse logs based on topic type and check that event data has correct length
uint256 expectedLen;
if (mainTopic == TOPIC_DEPOSITED) {
expectedLen = 0x120;
depositType = DepositType.TokenDeposit;
} else {
return DepositType.None;
}
if (len != expectedLen) {
return DepositType.None;
}
}
{
// read chain id separately and verify that contract that emitted event is relevant
uint256 chainId;
assembly {
chainId := calldataload(ptr)
}
// if (chainId != Utils.currentChain()) return DepositType.None;
// All checks are passed after this point, no errors allowed and we can modify state
state.chainId = chainId;
ptr += 0x20;
len -= 0x20;
}
{
uint256 structOffset;
assembly {
// skip 6 fields: receiptHash, destinationContract, contractAddress, chainId, sender, receiver
structOffset := add(state, 0xc0)
calldatacopy(structOffset, ptr, len)
}
}
state.destinationContract = destinationContract;
state.contractAddress = contractAddress;
state.sender = sender;
state.receiver = receiver;
return depositType;
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "./CallDataRLPReader.sol";
import "./Utils.sol";
library ProofParser {
// Proof is message format signed by the protocol. It contains somewhat redundant information, so only part
// of the proof could be passed into the contract and other part can be inferred from transaction receipt
struct Proof {
uint256 chainId;
uint256 status;
bytes32 transactionHash;
uint256 blockNumber;
bytes32 blockHash;
uint256 transactionIndex;
bytes32 receiptHash;
uint256 transferAmount;
}
function parseProof(
uint256 proofOffset
) internal pure returns (Proof memory) {
Proof memory proof;
uint256 dataOffset = proofOffset + 0x20;
assembly {
calldatacopy(proof, dataOffset, 0x20) // 1 field (chainId)
dataOffset := add(dataOffset, 0x40)
calldatacopy(add(proof, 0x40), dataOffset, 0x80) // 4 fields * 0x20 = 0x80
dataOffset := add(dataOffset, 0xa0)
calldatacopy(add(proof, 0xe0), dataOffset, 0x20) // transferAmount
}
return proof;
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
library Utils {
function currentChain() internal view returns (uint256) {
uint256 chain;
assembly {
chain := chainid()
}
return chain;
}
function stringToBytes32(
string memory source
) internal pure returns (bytes32 result) {
bytes memory tempEmptyStringTest = bytes(source);
if (tempEmptyStringTest.length == 0) {
return 0x0;
}
assembly {
result := mload(add(source, 32))
}
}
function saturatingMultiply(
uint256 a,
uint256 b
) internal pure returns (uint256) {
unchecked {
if (a == 0) return 0;
uint256 c = a * b;
if (c / a != b) return type(uint256).max;
return c;
}
}
function saturatingAdd(
uint256 a,
uint256 b
) internal pure returns (uint256) {
unchecked {
uint256 c = a + b;
if (c < a) return type(uint256).max;
return c;
}
}
// Preconditions:
// 1. a may be arbitrary (up to 2 ** 256 - 1)
// 2. b * c < 2 ** 256
// Returned value: min(floor((a * b) / c), 2 ** 256 - 1)
function multiplyAndDivideFloor(
uint256 a,
uint256 b,
uint256 c
) internal pure returns (uint256) {
return
saturatingAdd(
saturatingMultiply(a / c, b),
((a % c) * b) / c // can't fail because of assumption 2.
);
}
// Preconditions:
// 1. a may be arbitrary (up to 2 ** 256 - 1)
// 2. b * c < 2 ** 256
// Returned value: min(ceil((a * b) / c), 2 ** 256 - 1)
function multiplyAndDivideCeil(
uint256 a,
uint256 b,
uint256 c
) internal pure returns (uint256) {
return
saturatingAdd(
saturatingMultiply(a / c, b),
((a % c) * b + (c - 1)) / c // can't fail because of assumption 2.
);
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "@openzeppelin/contracts/proxy/Proxy.sol";
import "@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol";
/// @dev The original OpenZeppelin Contracts (last updated v4.7.0) (proxy/ERC1967/ERC1967Proxy.sol), but
/// constructor() was removed
contract InitializableERC1967Proxy is Proxy, ERC1967Upgrade {
/**
* @dev Returns the current implementation address.
*/
function _implementation()
internal
view
virtual
override
returns (address impl)
{
return ERC1967Upgrade._getImplementation();
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol";
import "./InitializableERC1967Proxy.sol";
contract InceptionProxyAdmin is ProxyAdmin {}
/// @dev The original OpenZeppelin Contracts (last updated v4.9.0) (proxy/transparent/TransparentUpgradeableProxy.sol)
/// with replacement constructor by initializer
contract InitializableTransparentUpgradeableProxy is InitializableERC1967Proxy {
/**
* Contract initializer.
* @param _logic address of the initial implementation.
* @param admin_ Address of the proxy administrator.
* @param _data Data to send as msg.data to the implementation to initialize the proxied contract
*/
function initialize(
address _logic,
address admin_,
bytes memory _data
) external payable {
require(
_implementation() == address(0),
"implementation has already been set"
);
_upgradeToAndCall(_logic, _data, false);
_changeAdmin(admin_);
}
/**
* @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.
*
* CAUTION: This modifier is deprecated, as it could cause issues if the modified function has arguments, and the
* implementation provides a function with the same selector.
*/
modifier ifAdmin() {
if (msg.sender == _getAdmin()) {
_;
} else {
_fallback();
}
}
/**
* @dev If caller is the admin process the call internally, otherwise transparently fallback to the proxy behavior
*/
function _fallback() internal virtual override {
if (msg.sender == _getAdmin()) {
bytes memory ret;
bytes4 selector = msg.sig;
if (selector == ITransparentUpgradeableProxy.upgradeTo.selector) {
ret = _dispatchUpgradeTo();
} else if (
selector ==
ITransparentUpgradeableProxy.upgradeToAndCall.selector
) {
ret = _dispatchUpgradeToAndCall();
} else if (
selector == ITransparentUpgradeableProxy.changeAdmin.selector
) {
ret = _dispatchChangeAdmin();
} else if (
selector == ITransparentUpgradeableProxy.admin.selector
) {
ret = _dispatchAdmin();
} else if (
selector == ITransparentUpgradeableProxy.implementation.selector
) {
ret = _dispatchImplementation();
} else {
revert(
"TransparentUpgradeableProxy: admin cannot fallback to proxy target"
);
}
assembly {
return(add(ret, 0x20), mload(ret))
}
} else {
super._fallback();
}
}
/**
* @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 _dispatchAdmin() private returns (bytes memory) {
_requireZeroValue();
address admin = _getAdmin();
return abi.encode(admin);
}
/**
* @dev Returns the current implementation.
*
* 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.
* `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`
*/
function _dispatchImplementation() private returns (bytes memory) {
_requireZeroValue();
address implementation = _implementation();
return abi.encode(implementation);
}
/**
* @dev Changes the admin of the proxy.
*
* Emits an {AdminChanged} event.
*/
function _dispatchChangeAdmin() private returns (bytes memory) {
_requireZeroValue();
address newAdmin = abi.decode(msg.data[4:], (address));
_changeAdmin(newAdmin);
return "";
}
/**
* @dev Upgrade the implementation of the proxy.
*/
function _dispatchUpgradeTo() private returns (bytes memory) {
_requireZeroValue();
address newImplementation = abi.decode(msg.data[4:], (address));
_upgradeToAndCall(newImplementation, bytes(""), false);
return "";
}
/**
* @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified
* by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the
* proxied contract.
*/
function _dispatchUpgradeToAndCall() private returns (bytes memory) {
(address newImplementation, bytes memory data) = abi.decode(
msg.data[4:],
(address, bytes)
);
_upgradeToAndCall(newImplementation, data, true);
return "";
}
/**
* @dev Returns the current admin.
*
* CAUTION: This function is deprecated. Use {ERC1967Upgrade-_getAdmin} instead.
*/
function _admin() internal view virtual returns (address) {
return _getAdmin();
}
/**
* @dev To keep this contract fully transparent, all `ifAdmin` functions must be payable. This helper is here to
* emulate some proxy functions being non-payable while still allowing value to pass through.
*/
function _requireZeroValue() private {
require(msg.value == 0, "zero value is required");
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/interfaces/IERC20Metadata.sol";
contract ERC20Mintable is ERC20 {
constructor(
string memory name_,
string memory symbol_
) payable ERC20(name_, symbol_) {}
function mint(address usr, uint wad) external {
_mint(usr, wad);
}
function burn(address usr, uint wad) external {
_burn(usr, wad);
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "@openzeppelin/contracts/interfaces/IERC20.sol";
import "../interfaces/IInceptionBridge.sol";
contract MultipleDepositor {
IInceptionBridge internal _bridge;
constructor(IInceptionBridge bridge) {
_bridge = bridge;
}
function deposit(
address fromToken,
uint256 destinationChain,
address receiver,
uint256 amount,
uint256 numOfDeposits
) external {
IERC20(fromToken).transferFrom(
msg.sender,
address(this),
numOfDeposits * amount
);
IERC20(fromToken).approve(address(_bridge), numOfDeposits * amount);
for (uint256 i = 0; i < numOfDeposits; i++) {
_bridge.deposit(fromToken, destinationChain, receiver, amount);
}
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "../interfaces/IXERC20.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Permit.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
contract XERC20 is ERC20, Ownable, IXERC20, ERC20Permit {
/**
* @notice The duration it takes for the limits to fully replenish
*/
uint256 private constant _DURATION = 1 days;
/**
* @notice The address of the factory which deployed this contract
*/
address public immutable FACTORY;
/**
* @notice The address of the lockbox contract
*/
address public lockbox;
/**
* @notice Maps bridge address to bridge configurations
*/
mapping(address => Bridge) public bridges;
/**
* @param _name The name of the token
* @param _symbol The symbol of the token
* @param _factory The factory which deployed this contract
*/
constructor(
string memory _name,
string memory _symbol,
address _factory
) ERC20(_name, _symbol) ERC20Permit(_name) {
_transferOwnership(_factory);
FACTORY = _factory;
}
/**
* @notice Mints tokens for a user
* @dev Can only be called by a bridge
* @param _user The address of the user who needs tokens minted
* @param _amount The amount of tokens being minted
*/
function mint(address _user, uint256 _amount) external {
_mintWithCaller(msg.sender, _user, _amount);
}
/**
* @notice Burns tokens for a user
* @dev Can only be called by a bridge
* @param _user The address of the user who needs tokens burned
* @param _amount The amount of tokens being burned
*/
function burn(address _user, uint256 _amount) external {
_burnWithCaller(msg.sender, _user, _amount);
}
/**
* @notice Sets the lockbox address
* @param _lockbox The address of the lockbox
*/
function setLockbox(address _lockbox) external {
if (msg.sender != FACTORY) revert IXERC20_NotFactory();
lockbox = _lockbox;
emit LockboxSet(_lockbox);
}
/**
* @notice Updates the limits of any bridge
* @dev Can only be called by the owner
* @param _mintingLimit The updated minting limit we are setting to the bridge
* @param _burningLimit The updated burning limit we are setting to the bridge
* @param _bridge The address of the bridge we are setting the limits too
*/
function setBridgeLimits(
address _bridge,
uint256 _mintingLimit,
uint256 _burningLimit
) external onlyOwner {
_changeMinterLimit(_bridge, _mintingLimit);
_changeBurnerLimit(_bridge, _burningLimit);
emit BridgeLimitsSet(_mintingLimit, _burningLimit, _bridge);
}
/**
* @notice Returns the max limit of a bridge
* @param _bridge the bridge we are viewing the limits of
* @return _limit The limit the bridge has
*/
function mintingMaxLimitOf(
address _bridge
) external view returns (uint256 _limit) {
_limit = bridges[_bridge].minterParams.maxLimit;
}
/**
* @notice Returns the max limit of a bridge
* @param _bridge the bridge we are viewing the limits of
* @return _limit The limit the bridge has
*/
function burningMaxLimitOf(
address _bridge
) external view returns (uint256 _limit) {
_limit = bridges[_bridge].burnerParams.maxLimit;
}
/**
* @notice Returns the current limit of a bridge
* @param _bridge the bridge we are viewing the limits of
* @return _limit The limit the bridge has
*/
function mintingCurrentLimitOf(
address _bridge
) public view returns (uint256 _limit) {
_limit = _getCurrentLimit(
bridges[_bridge].minterParams.currentLimit,
bridges[_bridge].minterParams.maxLimit,
bridges[_bridge].minterParams.timestamp,
bridges[_bridge].minterParams.ratePerSecond
);
}
/**
* @notice Returns the current limit of a bridge
* @param _bridge the bridge we are viewing the limits of
* @return _limit The limit the bridge has
*/
function burningCurrentLimitOf(
address _bridge
) public view returns (uint256 _limit) {
_limit = _getCurrentLimit(
bridges[_bridge].burnerParams.currentLimit,
bridges[_bridge].burnerParams.maxLimit,
bridges[_bridge].burnerParams.timestamp,
bridges[_bridge].burnerParams.ratePerSecond
);
}
/**
* @notice Uses the limit of any bridge
* @param _bridge The address of the bridge who is being changed
* @param _change The change in the limit
*/
function _useMinterLimits(address _bridge, uint256 _change) internal {
uint256 _currentLimit = mintingCurrentLimitOf(_bridge);
bridges[_bridge].minterParams.timestamp = block.timestamp;
bridges[_bridge].minterParams.currentLimit = _currentLimit - _change;
}
/**
* @notice Uses the limit of any bridge
* @param _bridge The address of the bridge who is being changed
* @param _change The change in the limit
*/
function _useBurnerLimits(address _bridge, uint256 _change) internal {
uint256 _currentLimit = burningCurrentLimitOf(_bridge);
bridges[_bridge].burnerParams.timestamp = block.timestamp;
bridges[_bridge].burnerParams.currentLimit = _currentLimit - _change;
}
/**
* @notice Updates the limit of any bridge
* @dev Can only be called by the owner
* @param _bridge The address of the bridge we are setting the limit too
* @param _limit The updated limit we are setting to the bridge
*/
function _changeMinterLimit(address _bridge, uint256 _limit) internal {
if (_limit < _DURATION && _limit > 0) revert IXERC20_WrongBridgeLimit();
uint256 _oldLimit = bridges[_bridge].minterParams.maxLimit;
uint256 _currentLimit = mintingCurrentLimitOf(_bridge);
bridges[_bridge].minterParams.maxLimit = _limit;
bridges[_bridge].minterParams.currentLimit = _calculateNewCurrentLimit(
_limit,
_oldLimit,
_currentLimit
);
bridges[_bridge].minterParams.ratePerSecond = _limit / _DURATION;
bridges[_bridge].minterParams.timestamp = block.timestamp;
}
/**
* @notice Updates the limit of any bridge
* @dev Can only be called by the owner
* @param _bridge The address of the bridge we are setting the limit too
* @param _limit The updated limit we are setting to the bridge
*/
function _changeBurnerLimit(address _bridge, uint256 _limit) internal {
if (_limit < _DURATION && _limit > 0) revert IXERC20_WrongBridgeLimit();
uint256 _oldLimit = bridges[_bridge].burnerParams.maxLimit;
uint256 _currentLimit = burningCurrentLimitOf(_bridge);
bridges[_bridge].burnerParams.maxLimit = _limit;
bridges[_bridge].burnerParams.currentLimit = _calculateNewCurrentLimit(
_limit,
_oldLimit,
_currentLimit
);
bridges[_bridge].burnerParams.ratePerSecond = _limit / _DURATION;
bridges[_bridge].burnerParams.timestamp = block.timestamp;
}
/**
* @param _limit The new limit
* @param _oldLimit The old limit
* @param _currentLimit The current limit
* @return _newCurrentLimit The new current limit
*/
function _calculateNewCurrentLimit(
uint256 _limit,
uint256 _oldLimit,
uint256 _currentLimit
) internal pure returns (uint256 _newCurrentLimit) {
uint256 _difference;
if (_oldLimit > _limit) {
_difference = _oldLimit - _limit;
_newCurrentLimit = _currentLimit > _difference
? _currentLimit - _difference
: 0;
} else {
_difference = _limit - _oldLimit;
_newCurrentLimit = _currentLimit + _difference;
}
}
/**
* @param _currentLimit The current limit
* @param _maxLimit The max limit
* @param _timestamp The timestamp of the last update
* @param _ratePerSecond The rate per second
* @return _limit The current limit
*/
function _getCurrentLimit(
uint256 _currentLimit,
uint256 _maxLimit,
uint256 _timestamp,
uint256 _ratePerSecond
) internal view returns (uint256 _limit) {
_limit = _currentLimit;
if (_limit == _maxLimit) {
return _limit;
} else if (_timestamp + _DURATION <= block.timestamp) {
_limit = _maxLimit;
} else if (_timestamp + _DURATION > block.timestamp) {
uint256 _timePassed = block.timestamp - _timestamp;
uint256 _calculatedLimit = _limit + (_timePassed * _ratePerSecond);
_limit = _calculatedLimit > _maxLimit
? _maxLimit
: _calculatedLimit;
}
}
/**
* @param _caller The caller address
* @param _user The user address
* @param _amount The amount to burn
*/
function _burnWithCaller(
address _caller,
address _user,
uint256 _amount
) internal {
if (_caller != lockbox) {
uint256 _currentLimit = burningCurrentLimitOf(_caller);
if (_currentLimit < _amount) revert IXERC20_NotHighEnoughLimits();
_useBurnerLimits(_caller, _amount);
}
_burn(_user, _amount);
}
/**
* @param _caller The caller address
* @param _user The user address
* @param _amount The amount to mint
*/
function _mintWithCaller(
address _caller,
address _user,
uint256 _amount
) internal {
if (_caller != lockbox) {
uint256 _currentLimit = mintingCurrentLimitOf(_caller);
if (_currentLimit < _amount) revert IXERC20_NotHighEnoughLimits();
_useMinterLimits(_caller, _amount);
}
_mint(_user, _amount);
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/utils/math/SafeCast.sol";
import "../interfaces/IXERC20Lockbox.sol";
import "../interfaces/IXERC20.sol";
contract XERC20Lockbox is IXERC20Lockbox {
using SafeERC20 for IERC20;
using SafeCast for uint256;
/**
* @notice The XERC20 token of this contract
*/
IXERC20 public immutable XERC20;
/**
* @notice The ERC20 token of this contract
*/
IERC20 public immutable ERC20;
/**
* @notice Whether the ERC20 token is the native gas token of this chain
*/
bool public immutable IS_NATIVE;
/**
* @param _xerc20 The address of the XERC20 contract
* @param _erc20 The address of the ERC20 contract
* @param _isNative Whether the ERC20 token is the native gas token of this chain or not
*/
constructor(address _xerc20, address _erc20, bool _isNative) payable {
XERC20 = IXERC20(_xerc20);
ERC20 = IERC20(_erc20);
IS_NATIVE = _isNative;
}
/**
* @notice Deposit native tokens into the lockbox
*/
function depositNative() public payable {
if (!IS_NATIVE) revert IXERC20Lockbox_NotNative();
_deposit(msg.sender, msg.value);
}
/**
* @notice Deposit ERC20 tokens into the lockbox
* @param _amount The amount of tokens to deposit
*/
function deposit(uint256 _amount) external {
if (IS_NATIVE) revert IXERC20Lockbox_Native();
_deposit(msg.sender, _amount);
}
/**
* @notice Deposit ERC20 tokens into the lockbox, and send the XERC20 to a user
* @param _to The user to send the XERC20 to
* @param _amount The amount of tokens to deposit
*/
function depositTo(address _to, uint256 _amount) external {
if (IS_NATIVE) revert IXERC20Lockbox_Native();
_deposit(_to, _amount);
}
/**
* @notice Deposit the native asset into the lockbox, and send the XERC20 to a user
* @param _to The user to send the XERC20 to
*/
function depositNativeTo(address _to) external payable {
if (!IS_NATIVE) revert IXERC20Lockbox_NotNative();
_deposit(_to, msg.value);
}
/**
* @notice Withdraw ERC20 tokens from the lockbox
* @param _amount The amount of tokens to withdraw
*/
function withdraw(uint256 _amount) external {
_withdraw(msg.sender, _amount);
}
/**
* @notice Withdraw tokens from the lockbox
* @param _to The user to withdraw to
* @param _amount The amount of tokens to withdraw
*/
function withdrawTo(address _to, uint256 _amount) external {
_withdraw(_to, _amount);
}
/**
* @notice Withdraw tokens from the lockbox
* @param _to The user to withdraw to
* @param _amount The amount of tokens to withdraw
*/
function _withdraw(address _to, uint256 _amount) internal {
if (_to == address(this)) revert IXERC20Lockbox_WrongReceiver();
XERC20.burn(msg.sender, _amount);
if (IS_NATIVE) {
(bool _success, ) = payable(_to).call{value: _amount}("");
if (!_success) revert IXERC20Lockbox_WithdrawFailed();
} else {
ERC20.safeTransfer(_to, _amount);
}
emit Withdraw(_to, _amount);
}
/**
* @notice Deposit tokens into the lockbox
* @param _to The address to send the XERC20 to
* @param _amount The amount of tokens to deposit
*/
function _deposit(address _to, uint256 _amount) internal {
if (_to == address(this)) revert IXERC20Lockbox_WrongReceiver();
if (!IS_NATIVE)
ERC20.safeTransferFrom(msg.sender, address(this), _amount);
XERC20.mint(_to, _amount);
emit Deposit(_to, _amount);
}
/**
* @notice Fallback function to deposit native tokens
*/
receive() external payable {
depositNative();
}
}// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.0;
/// @notice Library for converting between addresses and bytes32 values.
/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/Bytes32AddressLib.sol)
library Bytes32AddressLib {
function fromLast20Bytes(bytes32 bytesValue) internal pure returns (address) {
return address(uint160(uint256(bytesValue)));
}
function fillLast12Bytes(address addressValue) internal pure returns (bytes32) {
return bytes32(bytes20(addressValue));
}
}// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.0;
import {Bytes32AddressLib} from "./Bytes32AddressLib.sol";
/// @notice Deploy to deterministic addresses without an initcode factor.
/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/CREATE3.sol)
/// @author Modified from 0xSequence (https://github.com/0xSequence/create3/blob/master/contracts/Create3.sol)
library CREATE3 {
using Bytes32AddressLib for bytes32;
//--------------------------------------------------------------------------------//
// Opcode | Opcode + Arguments | Description | Stack View //
//--------------------------------------------------------------------------------//
// 0x36 | 0x36 | CALLDATASIZE | size //
// 0x3d | 0x3d | RETURNDATASIZE | 0 size //
// 0x3d | 0x3d | RETURNDATASIZE | 0 0 size //
// 0x37 | 0x37 | CALLDATACOPY | //
// 0x36 | 0x36 | CALLDATASIZE | size //
// 0x3d | 0x3d | RETURNDATASIZE | 0 size //
// 0x34 | 0x34 | CALLVALUE | value 0 size //
// 0xf0 | 0xf0 | CREATE | newContract //
//--------------------------------------------------------------------------------//
// Opcode | Opcode + Arguments | Description | Stack View //
//--------------------------------------------------------------------------------//
// 0x67 | 0x67XXXXXXXXXXXXXXXX | PUSH8 bytecode | bytecode //
// 0x3d | 0x3d | RETURNDATASIZE | 0 bytecode //
// 0x52 | 0x52 | MSTORE | //
// 0x60 | 0x6008 | PUSH1 08 | 8 //
// 0x60 | 0x6018 | PUSH1 18 | 24 8 //
// 0xf3 | 0xf3 | RETURN | //
//--------------------------------------------------------------------------------//
bytes internal constant PROXY_BYTECODE = hex"67_36_3d_3d_37_36_3d_34_f0_3d_52_60_08_60_18_f3";
bytes32 internal constant PROXY_BYTECODE_HASH = keccak256(PROXY_BYTECODE);
function deploy(
bytes32 salt,
bytes memory creationCode,
uint256 value
) internal returns (address deployed) {
bytes memory proxyChildBytecode = PROXY_BYTECODE;
address proxy;
/// @solidity memory-safe-assembly
assembly {
// Deploy a new contract with our pre-made bytecode via CREATE2.
// We start 32 bytes into the code to avoid copying the byte length.
proxy := create2(0, add(proxyChildBytecode, 32), mload(proxyChildBytecode), salt)
}
require(proxy != address(0), "DEPLOYMENT_FAILED");
deployed = getDeployed(salt);
(bool success, ) = proxy.call{value: value}(creationCode);
require(success && deployed.code.length != 0, "INITIALIZATION_FAILED");
}
function getDeployed(bytes32 salt) internal view returns (address) {
address proxy = keccak256(
abi.encodePacked(
// Prefix:
bytes1(0xFF),
// Creator:
address(this),
// Salt:
salt,
// Bytecode hash:
PROXY_BYTECODE_HASH
)
).fromLast20Bytes();
return
keccak256(
abi.encodePacked(
// 0xd6 = 0xc0 (short RLP prefix) + 0x16 (length of: 0x94 ++ proxy ++ 0x01)
// 0x94 = 0x80 + 0x14 (0x14 = the length of an address, 20 bytes, in hex)
hex"d6_94",
proxy,
hex"01" // Nonce of the proxy contract (1)
)
).fromLast20Bytes();
}
}{
"optimizer": {
"enabled": true,
"runs": 200
},
"evmVersion": "paris",
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"abi"
]
}
}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[],"stateMutability":"payable","type":"constructor"},{"inputs":[],"name":"BridgeAlreadyAdded","type":"error"},{"inputs":[],"name":"BridgeNotExist","type":"error"},{"inputs":[],"name":"BurnFailed","type":"error"},{"inputs":[],"name":"DestinationAlreadyExists","type":"error"},{"inputs":[],"name":"EnforcedPause","type":"error"},{"inputs":[],"name":"ExpectedPause","type":"error"},{"inputs":[],"name":"InvalidAssetType","type":"error"},{"inputs":[],"name":"InvalidChain","type":"error"},{"inputs":[],"name":"InvalidContractAddress","type":"error"},{"inputs":[],"name":"InvalidFromTokenAddress","type":"error"},{"inputs":[],"name":"InvalidInitialization","type":"error"},{"inputs":[{"internalType":"uint256","name":"limit","type":"uint256"},{"internalType":"uint256","name":"current","type":"uint256"}],"name":"LongCapExceeded","type":"error"},{"inputs":[],"name":"MintFailed","type":"error"},{"inputs":[],"name":"MultipleDeposits","type":"error"},{"inputs":[],"name":"NotInitializing","type":"error"},{"inputs":[],"name":"NullAddress","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"OwnableInvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"OwnableUnauthorizedAccount","type":"error"},{"inputs":[{"internalType":"uint256","name":"required","type":"uint256"},{"internalType":"uint256","name":"provided","type":"uint256"}],"name":"ReceiptWrongChain","type":"error"},{"inputs":[],"name":"ReentrancyGuardReentrantCall","type":"error"},{"inputs":[{"internalType":"uint256","name":"limit","type":"uint256"},{"internalType":"uint256","name":"current","type":"uint256"}],"name":"ShortCapExceeded","type":"error"},{"inputs":[],"name":"UnknownBridge","type":"error"},{"inputs":[],"name":"UnknownDestination","type":"error"},{"inputs":[],"name":"UnknownDestinationChain","type":"error"},{"inputs":[],"name":"WithdrawalProofUsed","type":"error"},{"inputs":[],"name":"WrongDestinationBridge","type":"error"},{"inputs":[],"name":"WrongSignature","type":"error"},{"inputs":[],"name":"XERC20LockboxAlreadyAdded","type":"error"},{"inputs":[],"name":"XERC20ZeroAddress","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"bridge","type":"address"},{"indexed":false,"internalType":"uint256","name":"destinationChain","type":"uint256"}],"name":"BridgeAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"bridge","type":"address"},{"indexed":false,"internalType":"uint256","name":"destinationChain","type":"uint256"}],"name":"BridgeRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"destinationChain","type":"uint256"},{"indexed":true,"internalType":"address","name":"destinationBridge","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":true,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"address","name":"fromToken","type":"address"},{"indexed":false,"internalType":"address","name":"toToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"nonce","type":"uint256"},{"components":[{"internalType":"bytes32","name":"name","type":"bytes32"},{"internalType":"bytes32","name":"symbol","type":"bytes32"},{"internalType":"uint256","name":"originChain","type":"uint256"},{"internalType":"address","name":"originAddress","type":"address"}],"indexed":false,"internalType":"struct IInceptionBridgeStorage.Metadata","name":"metadata","type":"tuple"}],"name":"Deposited","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"fromToken","type":"address"},{"indexed":true,"internalType":"address","name":"toToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"toChain","type":"uint256"}],"name":"DestinationAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"fromToken","type":"address"},{"indexed":true,"internalType":"address","name":"toToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"toChain","type":"uint256"}],"name":"DestinationRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"version","type":"uint64"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"prevValue","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newValue","type":"uint256"}],"name":"LongCapChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"prevValue","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newValue","type":"uint256"}],"name":"LongCapDurationChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"prevValue","type":"address"},{"indexed":true,"internalType":"address","name":"newValue","type":"address"}],"name":"NotaryChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"prevValue","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newValue","type":"uint256"}],"name":"ShortCapChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"prevValue","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newValue","type":"uint256"}],"name":"ShortCapDurationChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"receiptHash","type":"bytes32"},{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":true,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"address","name":"fromToken","type":"address"},{"indexed":false,"internalType":"address","name":"toToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Withdrawn","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":true,"internalType":"address","name":"lockbox","type":"address"}],"name":"XERC20LockboxAdded","type":"event"},{"inputs":[{"internalType":"address","name":"bridge","type":"address"},{"internalType":"uint256","name":"destinationChain","type":"uint256"}],"name":"addBridge","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"fromToken","type":"address"},{"internalType":"uint256","name":"destinationChain","type":"uint256"},{"internalType":"address","name":"toToken","type":"address"}],"name":"addDestination","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"fromToken","type":"address"},{"internalType":"uint256","name":"destinationChain","type":"uint256"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"deposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"duration","type":"uint256"}],"name":"getCurrentStamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"fromToken","type":"address"},{"internalType":"uint256","name":"destinationChain","type":"uint256"}],"name":"getDestination","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"initialOwner","type":"address"},{"internalType":"address","name":"notary","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"longCapDuration","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"longCaps","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"longCapsDeposit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"longCapsWithdraw","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"notary","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"destinationChain","type":"uint256"}],"name":"removeBridge","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"fromToken","type":"address"},{"internalType":"uint256","name":"destinationChain","type":"uint256"},{"internalType":"address","name":"toToken","type":"address"}],"name":"removeDestination","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"setLongCap","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"duration","type":"uint256"}],"name":"setLongCapDuration","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"notaryAddress","type":"address"}],"name":"setNotary","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"tokenAddress","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"setShortCap","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"duration","type":"uint256"}],"name":"setShortCapDuration","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"address","name":"xerc20Lockbox","type":"address"}],"name":"setXERC20Lockbox","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"shortCapDuration","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"shortCaps","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"shortCapsDeposit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"shortCapsWithdraw","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes","name":"","type":"bytes"},{"internalType":"bytes","name":"rawReceipt","type":"bytes"},{"internalType":"bytes","name":"proofSignature","type":"bytes"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"xerc20TokenRegistry","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}]Contract Creation Code
60806040526200000e62000014565b620000c8565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000900460ff1615620000655760405163f92ee8a960e01b815260040160405180910390fd5b80546001600160401b0390811614620000c55780546001600160401b0319166001600160401b0390811782556040519081527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b50565b6132ce80620000d86000396000f3fe608060405234801561001057600080fd5b50600436106101e55760003560e01c80638456cb591161010f578063a7130587116100a2578063e049c3a311610071578063e049c3a314610488578063ec10b0eb146104b3578063f2fde38b146104c6578063fd194991146104d957600080fd5b8063a713058714610424578063cc1acad91461044f578063d0f4871514610462578063d10ff6c51461047557600080fd5b806390971980116100de57806390971980146103d857806390d25074146103eb5780639d54c79d146103fe578063a394a0e61461041157600080fd5b80638456cb59146103555780638bc5d4d31461035d5780638cc13012146103885780638da5cb5b146103a857600080fd5b80634e58469d11610187578063715018a611610156578063715018a614610307578063776aaae91461030f5780637c38f94314610322578063802503d51461033557600080fd5b80634e58469d14610293578063570c20b7146102be5780635ac02ed0146102d15780635c975abb146102e457600080fd5b80633f4ba83a116101c35780633f4ba83a1461022457806341dfcc581461022c578063485cc9551461026d5780634abec9431461028057600080fd5b80630d4b8402146101ea5780632d8de281146101ff5780633e276d621461021b575b600080fd5b6101fd6101f8366004612d7c565b6104ec565b005b61020860095481565b6040519081526020015b60405180910390f35b61020860055481565b6101fd610502565b61025561023a366004612db5565b600f602052600090815260409020546001600160a01b031681565b6040516001600160a01b039091168152602001610212565b6101fd61027b366004612d7c565b610514565b6101fd61028e366004612dd2565b61063e565b6102086102a1366004612deb565b600760209081526000928352604080842090915290825290205481565b6101fd6102cc366004612deb565b610652565b6101fd6102df366004612dd2565b610664565b6000805160206132598339815191525460ff166040519015158152602001610212565b6101fd610675565b6101fd61031d366004612dd2565b610687565b610255610330366004612deb565b610698565b610208610343366004612db5565b600a6020526000908152604090205481565b6101fd610703565b61020861036b366004612deb565b600b60209081526000928352604080842090915290825290205481565b610208610396366004612db5565b60066020526000908152604090205481565b7f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300546001600160a01b0316610255565b6101fd6103e6366004612e17565b610713565b6101fd6103f9366004612e59565b61072b565b600154610255906001600160a01b031681565b6101fd61041f366004612db5565b6107ae565b610208610432366004612deb565b600c60209081526000928352604080842090915290825290205481565b6101fd61045d366004612deb565b6107bf565b6101fd610470366004612f52565b6107d1565b6101fd610483366004612deb565b610979565b610208610496366004612deb565b600860209081526000928352604080842090915290825290205481565b6101fd6104c1366004612e17565b61098b565b6101fd6104d4366004612db5565b61099e565b6102086104e7366004612dd2565b6109d9565b6104f46109f0565b6104fe8282610a4b565b5050565b61050a6109f0565b610512610b2d565b565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a008054600160401b810460ff16159067ffffffffffffffff1660008115801561055a5750825b905060008267ffffffffffffffff1660011480156105775750303b155b905081158015610585575080155b156105a35760405163f92ee8a960e01b815260040160405180910390fd5b845467ffffffffffffffff1916600117855583156105cd57845460ff60401b1916600160401b1785555b6105d687610b8d565b6105de610b9e565b6105e6610bae565b6105ef86610bbe565b831561063557845460ff60401b19168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b50505050505050565b6106466109f0565b61064f81610bd9565b50565b61065a6109f0565b6104fe8282610c1a565b61066c6109f0565b61064f81610cfb565b61067d6109f0565b6105126000610d8d565b61068f6109f0565b61064f81610dfe565b600081815260036020908152604080832054905160049284926106cb92889246926001600160a01b031691899101613029565b60408051601f19818403018152918152815160209283012083529082019290925201600020546001600160a01b031690505b92915050565b61070b6109f0565b610512610e3f565b61071b6109f0565b610726838383610e88565b505050565b610733610fe1565b61073b611019565b61074361104a565b61074d84826110bb565b60006107598585610698565b6001600160a01b03161461077857610773848484846112d1565b610791565b6040516340989b0560e01b815260040160405180910390fd5b6107a8600160008051602061327983398151915255565b50505050565b6107b66109f0565b61064f816114ef565b6107c76109f0565b6104fe8282611572565b6107d9610fe1565b6107e1611019565b60048035810190602435016000806107f88361160b565b915091504682606001511461083457606082015160405163f45e832160e01b815246600482015260248101919091526044015b60405180910390fd5b600061083f85611838565b60208401519091506001600160a01b031661086d5760405163a710429d60e01b815260040160405180910390fd5b60408301516001600160a01b0316301461089a576040516335946cb160e11b815260040160405180910390fd5b6020808401518251600090815260039092526040909120546001600160a01b039081169116146108dd57604051632fba485360e01b815260040160405180910390fd5b87876040516108ed929190613062565b6040519081900390208352600160208201819052835160c0830152610100822090546001600160a01b0316610922828961187c565b6001600160a01b031614610949576040516306ad488360e31b815260040160405180910390fd5b610955848484846118a0565b505050505050610972600160008051602061327983398151915255565b5050505050565b6109816109f0565b6104fe828261192b565b6109936109f0565b6107268383836119c1565b6109a66109f0565b6001600160a01b0381166109d057604051631e4fbdf760e01b81526000600482015260240161082b565b61064f81610d8d565b6000816109e68142613088565b6106fd91906130aa565b33610a227f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300546001600160a01b031690565b6001600160a01b0316146105125760405163118cdaa760e01b815233600482015260240161082b565b6001600160a01b0382161580610a6857506001600160a01b038116155b15610a865760405163e99d5ac560e01b815260040160405180910390fd5b6001600160a01b038281166000908152600f60205260409020541615610abf57604051633d9705b960e21b815260040160405180910390fd5b806001600160a01b0316826001600160a01b03167f450f0b949a93c86abd50a59d3c2474dbfad099708b7c7355ad28f4a237de3ba160405160405180910390a36001600160a01b039182166000908152600f6020526040902080546001600160a01b03191691909216179055565b610b35611ad7565b600080516020613259833981519152805460ff191681557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a150565b610b95611b07565b61064f81611b50565b610ba6611b07565b610512611b58565b610bb6611b07565b610512611b79565b610bc7816114ef565b61064f610e1060055562015180600955565b60055460408051918252602082018390527fcd5dd143ec4e58a4fd610459b592e7a0df095b56ff28113b33ef454b7be6d235910160405180910390a1600555565b6001600160a01b038216610c415760405163e99d5ac560e01b815260040160405180910390fd5b80600003610c625760405163057f3fa760e51b815260040160405180910390fd5b6000818152600360205260409020546001600160a01b031615610c9857604051631b906d1160e11b815260040160405180910390fd5b60008181526003602090815260409182902080546001600160a01b0319166001600160a01b03861690811790915591518381527f10916f5c971b65b1a3f05d1a63bfc558ca4d659670f408b6de05007215f1812a91015b60405180910390a25050565b6000818152600360205260409020546001600160a01b0316610d30576040516328ec10bd60e21b815260040160405180910390fd5b60008181526003602090815260409182902080546001600160a01b0319811690915591518381526001600160a01b039092169182917ffc5b6fb2b8ba31620717843fd7a36a4ad996612ff9f3ece7cba2900efb43bc2b9101610cef565b7f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c19930080546001600160a01b031981166001600160a01b03848116918217845560405192169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3505050565b60095460408051918252602082018390527fc318ed6288cdf2cd1dec4feb3d48f84828f062d9b812afb65cf43135f94289ab910160405180910390a1600955565b610e47611019565b600080516020613259833981519152805460ff191660011781557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a25833610b6f565b6000828152600360205260409020546001600160a01b0316610ebd576040516340989b0560e01b815260040160405180910390fd5b6001600160a01b0383161580610eda57506001600160a01b038116155b15610ef85760405163e99d5ac560e01b815260040160405180910390fd5b6000828152600360209081526040808320549051610f2892879246926001600160a01b0390911691889101613029565b60408051601f198184030181529181528151602092830120600081815260049093529120549091506001600160a01b031615610f7757604051634268025960e01b815260040160405180910390fd5b60008181526004602090815260409182902080546001600160a01b0319166001600160a01b038681169182179092559251868152908716917f94e4f3e075f32b001fd7eb0c3c1605dc3c4d8f1c7a90c514978b4d6ba680d33891015b60405180910390a350505050565b60008051602061327983398151915280546001190161101357604051633ee5aeb560e01b815260040160405180910390fd5b60029055565b6000805160206132598339815191525460ff16156105125760405163d93c066560e01b815260040160405180910390fd5b600d546001600160a01b0316158015906110655750600e5415155b156110a357600d546001600160a01b031632148015611085575043600e54145b156110a35760405163b782497f60e01b815260040160405180910390fd5b600d80546001600160a01b0319163217905543600e55565b6001600160a01b03821660009081526006602090815260408083205460079092528220600554919284926110ee906109d9565b81526020019081526020016000205461110791906130c1565b111561117b576001600160a01b0382166000908152600660209081526040808320546007909252822060055491928492611140906109d9565b81526020019081526020016000205461115991906130c1565b60405163074d4a3b60e21b81526004810192909252602482015260440161082b565b6001600160a01b03821660009081526007602052604081206005548392906111a2906109d9565b815260200190815260200160002060008282546111bf91906130c1565b90915550506001600160a01b0382166000908152600a6020908152604080832054600b9092528220600954919284926111f7906109d9565b81526020019081526020016000205461121091906130c1565b1115611284576001600160a01b0382166000908152600a6020908152604080832054600b909252822060095491928492611249906109d9565b81526020019081526020016000205461126291906130c1565b60405163084c5e0d60e21b81526004810192909252602482015260440161082b565b6001600160a01b0382166000908152600b602052604081206009548392906112ab906109d9565b815260200190815260200160002060008282546112c891906130c1565b90915550505050565b6000838152600360205260409020546001600160a01b0316611306576040516340989b0560e01b815260040160405180910390fd5b6001600160a01b038085166000908152600f60205260409020543391168061133857611333868385611b81565b611344565b61134481878486611ced565b600060405180608001604052806113c1896001600160a01b03166306fdde036040518163ffffffff1660e01b81526004016000604051808303816000875af1158015611394573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526113bc91908101906130f8565b611e08565b8152602001611409896001600160a01b03166395d89b416040518163ffffffff1660e01b81526004016000604051808303816000875af1158015611394573d6000803e3d6000fd5b8152600060208083018290526040928301829052815460010182558982526003905220549091506001600160a01b038681169185821691167fa8df0e3d5a5de1c918dba88937a3dec15268bed6b3d0133191b9b3a7d86b2a9b898b61146e8183610698565b600054604080519485526001600160a01b039384166020808701919091529284168582015260608086018e90526080860192909252895160a08601529189015160c08501529088015160e0840152870151166101008201526101200160405180910390a450505050505050565b600160008051602061327983398151915255565b6001600160a01b0381166115165760405163e99d5ac560e01b815260040160405180910390fd5b6001546040516001600160a01b038084169216907fb83b1538cdec62b04dcd2c181a62e2ad93727bbda41580b2cd4cb8ce6e8c09a690600090a3600180546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b0382166115995760405163e99d5ac560e01b815260040160405180910390fd5b6001600160a01b03821660008181526006602090815260409182902054825181815291820185905292917f31df6ae5b1f4d8b2d9f67caa6cde087b4f3b9e12dac0aaf9a3f27d247cd23200910160405180910390a2506001600160a01b03909116600090815260066020526040902055565b604080516101c081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e08101829052610100810182905261012081018290526101408101829052610160810182905261018081018290526101a081019190915260008061169261168d8560206130c1565b611e27565b90508061169e81611e3c565b91506116b3816116ae818561316f565b611e47565b6001146117025760405162461bcd60e51b815260206004820181905260248201527f457468657265756d56657269666965723a207478206973207265766572746564604482015260640161082b565b5061170c81611e3c565b90508061171881611e3c565b9150600061172582611e27565b90505b828110156117cf578061173a81611e3c565b915060006117488783611e63565b9050600081600181111561175e5761175e613182565b146117c857600086600181111561177757611777613182565b146117c45760405162461bcd60e51b815260206004820152601f60248201527f457468657265756d56657269666965723a206d756c7469706c65206c6f677300604482015260640161082b565b8095505b5050611728565b60008460018111156117e3576117e3613182565b036118305760405162461bcd60e51b815260206004820152601e60248201527f457468657265756d56657269666965723a206d697373696e67206c6f67730000604482015260640161082b565b505050915091565b611840612d23565b611848612d23565b60006118558460206130c1565b90506020818337604081019050608081604084013760a00160208160e08401375092915050565b600080600061188b858561201f565b9150915061189881612064565b509392505050565b60008181526002602052604090205460ff16156118d05760405163e69371a360e01b815260040160405180910390fd5b6000818152600260205260409020805460ff191660019081179091558360018111156118fe576118fe613182565b036119125761190d84836121ae565b6107a8565b6040516311b2a5ab60e11b815260040160405180910390fd5b6001600160a01b0382166119525760405163e99d5ac560e01b815260040160405180910390fd5b6001600160a01b0382166000818152600a60209081526040918290205482519081529081018490527f9879bf40436c98ee8b389ce84c33503f4494a999077f6fb7aa6c4f63de6a9adf910160405180910390a26001600160a01b039091166000908152600a6020526040902055565b6000828152600360205260409020546001600160a01b03166119f6576040516340989b0560e01b815260040160405180910390fd5b6000828152600360209081526040808320549051611a2692879246926001600160a01b0390911691889101613029565b60408051808303601f190181529181528151602092830120600081815260049093529120549091506001600160a01b03838116911614611a7957604051631edd9cbb60e31b815260040160405180910390fd5b6000818152600460205260409081902080546001600160a01b0319169055516001600160a01b0383811691908616907f31358c78ed429b28e47c9e9546aeafccaea26575d8043cb50960c67d0f488b2690610fd39087815260200190565b6000805160206132598339815191525460ff1661051257604051638dfc202b60e01b815260040160405180910390fd5b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0054600160401b900460ff1661051257604051631afcd79f60e31b815260040160405180910390fd5b6109a6611b07565b611b60611b07565b600080516020613259833981519152805460ff19169055565b6114db611b07565b6040516370a0823160e01b81526001600160a01b038381166004830152600091908516906370a0823190602401602060405180830381865afa158015611bcb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bef9190613198565b604051632770a7eb60e21b81526001600160a01b0385811660048301526024820185905291925090851690639dc29fac90604401600060405180830381600087803b158015611c3d57600080fd5b505af1158015611c51573d6000803e3d6000fd5b50506040516370a0823160e01b81526001600160a01b03868116600483015260009350871691506370a0823190602401602060405180830381865afa158015611c9e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cc29190613198565b905081611ccf84836130c1565b1461097257604051631bc5aabf60e21b815260040160405180910390fd5b6000846001600160a01b031663b20a0fb96040518163ffffffff1660e01b8152600401602060405180830381865afa158015611d2d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d5191906131b1565b90506001600160a01b038116611d7a576040516331ff900360e01b815260040160405180910390fd5b611d8f6001600160a01b03851684308561241e565b611da36001600160a01b0385168684612489565b60405163b6b55f2560e01b8152600481018390526001600160a01b0386169063b6b55f2590602401600060405180830381600087803b158015611de557600080fd5b505af1158015611df9573d6000803e3d6000fd5b50505050610972813084611b81565b805160009082908203611e1e5750600092915050565b50506020015190565b6000611e328261259e565b6106fd90836130c1565b6000611e3282612618565b6000611e528361259e565b611e5c908361316f565b9392505050565b600080611e6f83611e27565b9050600081611e7d81611e3c565b9250611e88816126bb565b91506000905080808085611e9b81611e3c565b9650611ea681612618565b608614611ebd5760009750505050505050506106fd565b611ec681611e27565b905060018101359450611ed881611e3c565b905060018101356001600160a01b03169350611ef381611e3c565b905060018101356001600160a01b03169250611f0e81611e3c565b905060018101356001600160a01b03169150611f2981611e3c565b9050868114611f3757600080fd5b506000611f4387611e27565b9050611f4e87611e3c565b96506000611f5c828961316f565b905060007fa8df0e3d5a5de1c918dba88937a3dec15268bed6b3d0133191b9b3a7d86b2a9b8703611f94575060019850610120611fa6565b600099505050505050505050506106fd565b808214611fbf57600099505050505050505050506106fd565b50813560608c01819052611fd46020846130c1565b9250611fe160208361316f565b91505060c08b01818382375050506001600160a01b0392831660408a01529382166020890152811660808801529190911660a0860152505092915050565b60008082516041036120555760208301516040840151606085015160001a612049878285856126c8565b9450945050505061205d565b506000905060025b9250929050565b600081600481111561207857612078613182565b036120805750565b600181600481111561209457612094613182565b036120e15760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e61747572650000000000000000604482015260640161082b565b60028160048111156120f5576120f5613182565b036121425760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e67746800604482015260640161082b565b600381600481111561215657612156613182565b0361064f5760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b606482015260840161082b565b60c08201516001600160a01b03166121d95760405163316484bf60e11b815260040160405180910390fd5b8160c001516001600160a01b03166121f98360e001518360000151610698565b6001600160a01b03161461222057604051631edd9cbb60e31b815260040160405180910390fd5b6122338260e0015183610100015161278c565b60e08201516001600160a01b039081166000908152600f60205260409020541680612275576122708360e001518460a00151856101000151612906565b61238f565b6000816001600160a01b031663b20a0fb96040518163ffffffff1660e01b8152600401602060405180830381865afa1580156122b5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122d991906131b1565b90506001600160a01b038116612302576040516331ff900360e01b815260040160405180910390fd5b6123128130866101000151612906565b60a084015161010085015160405163040b850f60e31b81526001600160a01b0385169263205c28789261235b926004016001600160a01b03929092168252602082015260400190565b600060405180830381600087803b15801561237557600080fd5b505af1158015612389573d6000803e3d6000fd5b50505050505b8260a001516001600160a01b031683608001516001600160a01b03167fda2b5a532a1cd1f21212a3628c424c2407bf255af4e5b5d6ffbf02f9c2aa4a2e85600001518660c001518760e0015188610100015160405161241194939291909384526001600160a01b03928316602085015291166040830152606082015260800190565b60405180910390a3505050565b6040516001600160a01b03808516602483015283166044820152606481018290526107a89085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612a71565b8015806125035750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e90604401602060405180830381865afa1580156124dd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125019190613198565b155b61256e5760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b606482015260840161082b565b6040516001600160a01b03831660248201526044810182905261072690849063095ea7b360e01b90606401612452565b60008135811a60808110156125b65750600092915050565b60b88110806125d1575060c081108015906125d1575060f881105b156125df5750600192915050565b60c081101561260c576125f4600160b86131ce565b6126019060ff168261316f565b611e5c9060016130c1565b6125f4600160f86131ce565b6000808235811a608081101561263157600191506126b4565b60b88110156126575761264560808261316f565b6126509060016130c1565b91506126b4565b60c0811015612682576001939093019283356008602083900360b701021c810160b5190191506126b4565b60f88110156126965761264560c08261316f565b6001939093019283356008602083900360f701021c810160f5190191505b5092915050565b60006106fd826015612b46565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08311156126ff5750600090506003612783565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015612753573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b03811661277c57600060019250925050612783565b9150600090505b94509492505050565b6001600160a01b03821660009081526006602090815260408083205460089092528220600554919284926127bf906109d9565b8152602001908152602001600020546127d891906130c1565b1115612811576001600160a01b0382166000908152600660209081526040808320546008909252822060055491928492611140906109d9565b6001600160a01b0382166000908152600860205260408120600554839290612838906109d9565b8152602001908152602001600020600082825461285591906130c1565b90915550506001600160a01b0382166000908152600a6020908152604080832054600c90925282206009549192849261288d906109d9565b8152602001908152602001600020546128a691906130c1565b11156128df576001600160a01b0382166000908152600a6020908152604080832054600c909252822060095491928492611249906109d9565b6001600160a01b0382166000908152600c602052604081206009548392906112ab906109d9565b6040516370a0823160e01b81526001600160a01b038381166004830152600091908516906370a0823190602401602060405180830381865afa158015612950573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129749190613198565b6040516340c10f1960e01b81526001600160a01b03858116600483015260248201859052919250908516906340c10f1990604401600060405180830381600087803b1580156129c257600080fd5b505af11580156129d6573d6000803e3d6000fd5b50506040516370a0823160e01b81526001600160a01b03868116600483015260009350871691506370a0823190602401602060405180830381865afa158015612a23573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a479190613198565b905080612a5484846130c1565b146109725760405162ec6f7b60e31b815260040160405180910390fd5b6000612ac6826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612b939092919063ffffffff16565b9050805160001480612ae7575080806020019051810190612ae791906131e7565b6107265760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b606482015260840161082b565b60008082118015612b58575060218211155b612b6157600080fd5b6000612b6c8461259e565b90506000612b7a828561316f565b94909101356020949094036008029390931c9392505050565b6060612ba28484600085612baa565b949350505050565b606082471015612c0b5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b606482015260840161082b565b600080866001600160a01b03168587604051612c279190613209565b60006040518083038185875af1925050503d8060008114612c64576040519150601f19603f3d011682016040523d82523d6000602084013e612c69565b606091505b5091509150612c7a87838387612c85565b979650505050505050565b60608315612cf4578251600003612ced576001600160a01b0385163b612ced5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161082b565b5081612ba2565b612ba28383815115612d095781518083602001fd5b8060405162461bcd60e51b815260040161082b9190613225565b6040805161010081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e081019190915290565b6001600160a01b038116811461064f57600080fd5b60008060408385031215612d8f57600080fd5b8235612d9a81612d67565b91506020830135612daa81612d67565b809150509250929050565b600060208284031215612dc757600080fd5b8135611e5c81612d67565b600060208284031215612de457600080fd5b5035919050565b60008060408385031215612dfe57600080fd5b8235612e0981612d67565b946020939093013593505050565b600080600060608486031215612e2c57600080fd5b8335612e3781612d67565b9250602084013591506040840135612e4e81612d67565b809150509250925092565b60008060008060808587031215612e6f57600080fd5b8435612e7a81612d67565b9350602085013592506040850135612e9181612d67565b9396929550929360600135925050565b60008083601f840112612eb357600080fd5b50813567ffffffffffffffff811115612ecb57600080fd5b60208301915083602082850101111561205d57600080fd5b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff81118282101715612f2257612f22612ee3565b604052919050565b600067ffffffffffffffff821115612f4457612f44612ee3565b50601f01601f191660200190565b600080600080600060608688031215612f6a57600080fd5b853567ffffffffffffffff80821115612f8257600080fd5b612f8e89838a01612ea1565b90975095506020880135915080821115612fa757600080fd5b612fb389838a01612ea1565b90955093506040880135915080821115612fcc57600080fd5b508601601f81018813612fde57600080fd5b8035612ff1612fec82612f2a565b612ef9565b81815289602083850101111561300657600080fd5b816020840160208301376000602083830101528093505050509295509295909350565b6bffffffffffffffffffffffff19606095861b8116825260148201949094529190931b9091166034820152604881019190915260680190565b8183823760009101908152919050565b634e487b7160e01b600052601160045260246000fd5b6000826130a557634e487b7160e01b600052601260045260246000fd5b500490565b80820281158282048414176106fd576106fd613072565b808201808211156106fd576106fd613072565b60005b838110156130ef5781810151838201526020016130d7565b50506000910152565b60006020828403121561310a57600080fd5b815167ffffffffffffffff81111561312157600080fd5b8201601f8101841361313257600080fd5b8051613140612fec82612f2a565b81815285602083850101111561315557600080fd5b6131668260208301602086016130d4565b95945050505050565b818103818111156106fd576106fd613072565b634e487b7160e01b600052602160045260246000fd5b6000602082840312156131aa57600080fd5b5051919050565b6000602082840312156131c357600080fd5b8151611e5c81612d67565b60ff82811682821603908111156106fd576106fd613072565b6000602082840312156131f957600080fd5b81518015158114611e5c57600080fd5b6000825161321b8184602087016130d4565b9190910192915050565b60208152600082518060208401526132448160408501602087016130d4565b601f01601f1916919091016040019291505056fecd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f033009b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00a264697066735822122082f7c11eed94f3b9e719d1a3e5f7da5ee1bb3e625abc6505d59d0f4243aad75864736f6c63430008140033
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106101e55760003560e01c80638456cb591161010f578063a7130587116100a2578063e049c3a311610071578063e049c3a314610488578063ec10b0eb146104b3578063f2fde38b146104c6578063fd194991146104d957600080fd5b8063a713058714610424578063cc1acad91461044f578063d0f4871514610462578063d10ff6c51461047557600080fd5b806390971980116100de57806390971980146103d857806390d25074146103eb5780639d54c79d146103fe578063a394a0e61461041157600080fd5b80638456cb59146103555780638bc5d4d31461035d5780638cc13012146103885780638da5cb5b146103a857600080fd5b80634e58469d11610187578063715018a611610156578063715018a614610307578063776aaae91461030f5780637c38f94314610322578063802503d51461033557600080fd5b80634e58469d14610293578063570c20b7146102be5780635ac02ed0146102d15780635c975abb146102e457600080fd5b80633f4ba83a116101c35780633f4ba83a1461022457806341dfcc581461022c578063485cc9551461026d5780634abec9431461028057600080fd5b80630d4b8402146101ea5780632d8de281146101ff5780633e276d621461021b575b600080fd5b6101fd6101f8366004612d7c565b6104ec565b005b61020860095481565b6040519081526020015b60405180910390f35b61020860055481565b6101fd610502565b61025561023a366004612db5565b600f602052600090815260409020546001600160a01b031681565b6040516001600160a01b039091168152602001610212565b6101fd61027b366004612d7c565b610514565b6101fd61028e366004612dd2565b61063e565b6102086102a1366004612deb565b600760209081526000928352604080842090915290825290205481565b6101fd6102cc366004612deb565b610652565b6101fd6102df366004612dd2565b610664565b6000805160206132598339815191525460ff166040519015158152602001610212565b6101fd610675565b6101fd61031d366004612dd2565b610687565b610255610330366004612deb565b610698565b610208610343366004612db5565b600a6020526000908152604090205481565b6101fd610703565b61020861036b366004612deb565b600b60209081526000928352604080842090915290825290205481565b610208610396366004612db5565b60066020526000908152604090205481565b7f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300546001600160a01b0316610255565b6101fd6103e6366004612e17565b610713565b6101fd6103f9366004612e59565b61072b565b600154610255906001600160a01b031681565b6101fd61041f366004612db5565b6107ae565b610208610432366004612deb565b600c60209081526000928352604080842090915290825290205481565b6101fd61045d366004612deb565b6107bf565b6101fd610470366004612f52565b6107d1565b6101fd610483366004612deb565b610979565b610208610496366004612deb565b600860209081526000928352604080842090915290825290205481565b6101fd6104c1366004612e17565b61098b565b6101fd6104d4366004612db5565b61099e565b6102086104e7366004612dd2565b6109d9565b6104f46109f0565b6104fe8282610a4b565b5050565b61050a6109f0565b610512610b2d565b565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a008054600160401b810460ff16159067ffffffffffffffff1660008115801561055a5750825b905060008267ffffffffffffffff1660011480156105775750303b155b905081158015610585575080155b156105a35760405163f92ee8a960e01b815260040160405180910390fd5b845467ffffffffffffffff1916600117855583156105cd57845460ff60401b1916600160401b1785555b6105d687610b8d565b6105de610b9e565b6105e6610bae565b6105ef86610bbe565b831561063557845460ff60401b19168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b50505050505050565b6106466109f0565b61064f81610bd9565b50565b61065a6109f0565b6104fe8282610c1a565b61066c6109f0565b61064f81610cfb565b61067d6109f0565b6105126000610d8d565b61068f6109f0565b61064f81610dfe565b600081815260036020908152604080832054905160049284926106cb92889246926001600160a01b031691899101613029565b60408051601f19818403018152918152815160209283012083529082019290925201600020546001600160a01b031690505b92915050565b61070b6109f0565b610512610e3f565b61071b6109f0565b610726838383610e88565b505050565b610733610fe1565b61073b611019565b61074361104a565b61074d84826110bb565b60006107598585610698565b6001600160a01b03161461077857610773848484846112d1565b610791565b6040516340989b0560e01b815260040160405180910390fd5b6107a8600160008051602061327983398151915255565b50505050565b6107b66109f0565b61064f816114ef565b6107c76109f0565b6104fe8282611572565b6107d9610fe1565b6107e1611019565b60048035810190602435016000806107f88361160b565b915091504682606001511461083457606082015160405163f45e832160e01b815246600482015260248101919091526044015b60405180910390fd5b600061083f85611838565b60208401519091506001600160a01b031661086d5760405163a710429d60e01b815260040160405180910390fd5b60408301516001600160a01b0316301461089a576040516335946cb160e11b815260040160405180910390fd5b6020808401518251600090815260039092526040909120546001600160a01b039081169116146108dd57604051632fba485360e01b815260040160405180910390fd5b87876040516108ed929190613062565b6040519081900390208352600160208201819052835160c0830152610100822090546001600160a01b0316610922828961187c565b6001600160a01b031614610949576040516306ad488360e31b815260040160405180910390fd5b610955848484846118a0565b505050505050610972600160008051602061327983398151915255565b5050505050565b6109816109f0565b6104fe828261192b565b6109936109f0565b6107268383836119c1565b6109a66109f0565b6001600160a01b0381166109d057604051631e4fbdf760e01b81526000600482015260240161082b565b61064f81610d8d565b6000816109e68142613088565b6106fd91906130aa565b33610a227f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300546001600160a01b031690565b6001600160a01b0316146105125760405163118cdaa760e01b815233600482015260240161082b565b6001600160a01b0382161580610a6857506001600160a01b038116155b15610a865760405163e99d5ac560e01b815260040160405180910390fd5b6001600160a01b038281166000908152600f60205260409020541615610abf57604051633d9705b960e21b815260040160405180910390fd5b806001600160a01b0316826001600160a01b03167f450f0b949a93c86abd50a59d3c2474dbfad099708b7c7355ad28f4a237de3ba160405160405180910390a36001600160a01b039182166000908152600f6020526040902080546001600160a01b03191691909216179055565b610b35611ad7565b600080516020613259833981519152805460ff191681557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a150565b610b95611b07565b61064f81611b50565b610ba6611b07565b610512611b58565b610bb6611b07565b610512611b79565b610bc7816114ef565b61064f610e1060055562015180600955565b60055460408051918252602082018390527fcd5dd143ec4e58a4fd610459b592e7a0df095b56ff28113b33ef454b7be6d235910160405180910390a1600555565b6001600160a01b038216610c415760405163e99d5ac560e01b815260040160405180910390fd5b80600003610c625760405163057f3fa760e51b815260040160405180910390fd5b6000818152600360205260409020546001600160a01b031615610c9857604051631b906d1160e11b815260040160405180910390fd5b60008181526003602090815260409182902080546001600160a01b0319166001600160a01b03861690811790915591518381527f10916f5c971b65b1a3f05d1a63bfc558ca4d659670f408b6de05007215f1812a91015b60405180910390a25050565b6000818152600360205260409020546001600160a01b0316610d30576040516328ec10bd60e21b815260040160405180910390fd5b60008181526003602090815260409182902080546001600160a01b0319811690915591518381526001600160a01b039092169182917ffc5b6fb2b8ba31620717843fd7a36a4ad996612ff9f3ece7cba2900efb43bc2b9101610cef565b7f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c19930080546001600160a01b031981166001600160a01b03848116918217845560405192169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3505050565b60095460408051918252602082018390527fc318ed6288cdf2cd1dec4feb3d48f84828f062d9b812afb65cf43135f94289ab910160405180910390a1600955565b610e47611019565b600080516020613259833981519152805460ff191660011781557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a25833610b6f565b6000828152600360205260409020546001600160a01b0316610ebd576040516340989b0560e01b815260040160405180910390fd5b6001600160a01b0383161580610eda57506001600160a01b038116155b15610ef85760405163e99d5ac560e01b815260040160405180910390fd5b6000828152600360209081526040808320549051610f2892879246926001600160a01b0390911691889101613029565b60408051601f198184030181529181528151602092830120600081815260049093529120549091506001600160a01b031615610f7757604051634268025960e01b815260040160405180910390fd5b60008181526004602090815260409182902080546001600160a01b0319166001600160a01b038681169182179092559251868152908716917f94e4f3e075f32b001fd7eb0c3c1605dc3c4d8f1c7a90c514978b4d6ba680d33891015b60405180910390a350505050565b60008051602061327983398151915280546001190161101357604051633ee5aeb560e01b815260040160405180910390fd5b60029055565b6000805160206132598339815191525460ff16156105125760405163d93c066560e01b815260040160405180910390fd5b600d546001600160a01b0316158015906110655750600e5415155b156110a357600d546001600160a01b031632148015611085575043600e54145b156110a35760405163b782497f60e01b815260040160405180910390fd5b600d80546001600160a01b0319163217905543600e55565b6001600160a01b03821660009081526006602090815260408083205460079092528220600554919284926110ee906109d9565b81526020019081526020016000205461110791906130c1565b111561117b576001600160a01b0382166000908152600660209081526040808320546007909252822060055491928492611140906109d9565b81526020019081526020016000205461115991906130c1565b60405163074d4a3b60e21b81526004810192909252602482015260440161082b565b6001600160a01b03821660009081526007602052604081206005548392906111a2906109d9565b815260200190815260200160002060008282546111bf91906130c1565b90915550506001600160a01b0382166000908152600a6020908152604080832054600b9092528220600954919284926111f7906109d9565b81526020019081526020016000205461121091906130c1565b1115611284576001600160a01b0382166000908152600a6020908152604080832054600b909252822060095491928492611249906109d9565b81526020019081526020016000205461126291906130c1565b60405163084c5e0d60e21b81526004810192909252602482015260440161082b565b6001600160a01b0382166000908152600b602052604081206009548392906112ab906109d9565b815260200190815260200160002060008282546112c891906130c1565b90915550505050565b6000838152600360205260409020546001600160a01b0316611306576040516340989b0560e01b815260040160405180910390fd5b6001600160a01b038085166000908152600f60205260409020543391168061133857611333868385611b81565b611344565b61134481878486611ced565b600060405180608001604052806113c1896001600160a01b03166306fdde036040518163ffffffff1660e01b81526004016000604051808303816000875af1158015611394573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526113bc91908101906130f8565b611e08565b8152602001611409896001600160a01b03166395d89b416040518163ffffffff1660e01b81526004016000604051808303816000875af1158015611394573d6000803e3d6000fd5b8152600060208083018290526040928301829052815460010182558982526003905220549091506001600160a01b038681169185821691167fa8df0e3d5a5de1c918dba88937a3dec15268bed6b3d0133191b9b3a7d86b2a9b898b61146e8183610698565b600054604080519485526001600160a01b039384166020808701919091529284168582015260608086018e90526080860192909252895160a08601529189015160c08501529088015160e0840152870151166101008201526101200160405180910390a450505050505050565b600160008051602061327983398151915255565b6001600160a01b0381166115165760405163e99d5ac560e01b815260040160405180910390fd5b6001546040516001600160a01b038084169216907fb83b1538cdec62b04dcd2c181a62e2ad93727bbda41580b2cd4cb8ce6e8c09a690600090a3600180546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b0382166115995760405163e99d5ac560e01b815260040160405180910390fd5b6001600160a01b03821660008181526006602090815260409182902054825181815291820185905292917f31df6ae5b1f4d8b2d9f67caa6cde087b4f3b9e12dac0aaf9a3f27d247cd23200910160405180910390a2506001600160a01b03909116600090815260066020526040902055565b604080516101c081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e08101829052610100810182905261012081018290526101408101829052610160810182905261018081018290526101a081019190915260008061169261168d8560206130c1565b611e27565b90508061169e81611e3c565b91506116b3816116ae818561316f565b611e47565b6001146117025760405162461bcd60e51b815260206004820181905260248201527f457468657265756d56657269666965723a207478206973207265766572746564604482015260640161082b565b5061170c81611e3c565b90508061171881611e3c565b9150600061172582611e27565b90505b828110156117cf578061173a81611e3c565b915060006117488783611e63565b9050600081600181111561175e5761175e613182565b146117c857600086600181111561177757611777613182565b146117c45760405162461bcd60e51b815260206004820152601f60248201527f457468657265756d56657269666965723a206d756c7469706c65206c6f677300604482015260640161082b565b8095505b5050611728565b60008460018111156117e3576117e3613182565b036118305760405162461bcd60e51b815260206004820152601e60248201527f457468657265756d56657269666965723a206d697373696e67206c6f67730000604482015260640161082b565b505050915091565b611840612d23565b611848612d23565b60006118558460206130c1565b90506020818337604081019050608081604084013760a00160208160e08401375092915050565b600080600061188b858561201f565b9150915061189881612064565b509392505050565b60008181526002602052604090205460ff16156118d05760405163e69371a360e01b815260040160405180910390fd5b6000818152600260205260409020805460ff191660019081179091558360018111156118fe576118fe613182565b036119125761190d84836121ae565b6107a8565b6040516311b2a5ab60e11b815260040160405180910390fd5b6001600160a01b0382166119525760405163e99d5ac560e01b815260040160405180910390fd5b6001600160a01b0382166000818152600a60209081526040918290205482519081529081018490527f9879bf40436c98ee8b389ce84c33503f4494a999077f6fb7aa6c4f63de6a9adf910160405180910390a26001600160a01b039091166000908152600a6020526040902055565b6000828152600360205260409020546001600160a01b03166119f6576040516340989b0560e01b815260040160405180910390fd5b6000828152600360209081526040808320549051611a2692879246926001600160a01b0390911691889101613029565b60408051808303601f190181529181528151602092830120600081815260049093529120549091506001600160a01b03838116911614611a7957604051631edd9cbb60e31b815260040160405180910390fd5b6000818152600460205260409081902080546001600160a01b0319169055516001600160a01b0383811691908616907f31358c78ed429b28e47c9e9546aeafccaea26575d8043cb50960c67d0f488b2690610fd39087815260200190565b6000805160206132598339815191525460ff1661051257604051638dfc202b60e01b815260040160405180910390fd5b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0054600160401b900460ff1661051257604051631afcd79f60e31b815260040160405180910390fd5b6109a6611b07565b611b60611b07565b600080516020613259833981519152805460ff19169055565b6114db611b07565b6040516370a0823160e01b81526001600160a01b038381166004830152600091908516906370a0823190602401602060405180830381865afa158015611bcb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bef9190613198565b604051632770a7eb60e21b81526001600160a01b0385811660048301526024820185905291925090851690639dc29fac90604401600060405180830381600087803b158015611c3d57600080fd5b505af1158015611c51573d6000803e3d6000fd5b50506040516370a0823160e01b81526001600160a01b03868116600483015260009350871691506370a0823190602401602060405180830381865afa158015611c9e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cc29190613198565b905081611ccf84836130c1565b1461097257604051631bc5aabf60e21b815260040160405180910390fd5b6000846001600160a01b031663b20a0fb96040518163ffffffff1660e01b8152600401602060405180830381865afa158015611d2d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d5191906131b1565b90506001600160a01b038116611d7a576040516331ff900360e01b815260040160405180910390fd5b611d8f6001600160a01b03851684308561241e565b611da36001600160a01b0385168684612489565b60405163b6b55f2560e01b8152600481018390526001600160a01b0386169063b6b55f2590602401600060405180830381600087803b158015611de557600080fd5b505af1158015611df9573d6000803e3d6000fd5b50505050610972813084611b81565b805160009082908203611e1e5750600092915050565b50506020015190565b6000611e328261259e565b6106fd90836130c1565b6000611e3282612618565b6000611e528361259e565b611e5c908361316f565b9392505050565b600080611e6f83611e27565b9050600081611e7d81611e3c565b9250611e88816126bb565b91506000905080808085611e9b81611e3c565b9650611ea681612618565b608614611ebd5760009750505050505050506106fd565b611ec681611e27565b905060018101359450611ed881611e3c565b905060018101356001600160a01b03169350611ef381611e3c565b905060018101356001600160a01b03169250611f0e81611e3c565b905060018101356001600160a01b03169150611f2981611e3c565b9050868114611f3757600080fd5b506000611f4387611e27565b9050611f4e87611e3c565b96506000611f5c828961316f565b905060007fa8df0e3d5a5de1c918dba88937a3dec15268bed6b3d0133191b9b3a7d86b2a9b8703611f94575060019850610120611fa6565b600099505050505050505050506106fd565b808214611fbf57600099505050505050505050506106fd565b50813560608c01819052611fd46020846130c1565b9250611fe160208361316f565b91505060c08b01818382375050506001600160a01b0392831660408a01529382166020890152811660808801529190911660a0860152505092915050565b60008082516041036120555760208301516040840151606085015160001a612049878285856126c8565b9450945050505061205d565b506000905060025b9250929050565b600081600481111561207857612078613182565b036120805750565b600181600481111561209457612094613182565b036120e15760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e61747572650000000000000000604482015260640161082b565b60028160048111156120f5576120f5613182565b036121425760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e67746800604482015260640161082b565b600381600481111561215657612156613182565b0361064f5760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b606482015260840161082b565b60c08201516001600160a01b03166121d95760405163316484bf60e11b815260040160405180910390fd5b8160c001516001600160a01b03166121f98360e001518360000151610698565b6001600160a01b03161461222057604051631edd9cbb60e31b815260040160405180910390fd5b6122338260e0015183610100015161278c565b60e08201516001600160a01b039081166000908152600f60205260409020541680612275576122708360e001518460a00151856101000151612906565b61238f565b6000816001600160a01b031663b20a0fb96040518163ffffffff1660e01b8152600401602060405180830381865afa1580156122b5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122d991906131b1565b90506001600160a01b038116612302576040516331ff900360e01b815260040160405180910390fd5b6123128130866101000151612906565b60a084015161010085015160405163040b850f60e31b81526001600160a01b0385169263205c28789261235b926004016001600160a01b03929092168252602082015260400190565b600060405180830381600087803b15801561237557600080fd5b505af1158015612389573d6000803e3d6000fd5b50505050505b8260a001516001600160a01b031683608001516001600160a01b03167fda2b5a532a1cd1f21212a3628c424c2407bf255af4e5b5d6ffbf02f9c2aa4a2e85600001518660c001518760e0015188610100015160405161241194939291909384526001600160a01b03928316602085015291166040830152606082015260800190565b60405180910390a3505050565b6040516001600160a01b03808516602483015283166044820152606481018290526107a89085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612a71565b8015806125035750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e90604401602060405180830381865afa1580156124dd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125019190613198565b155b61256e5760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b606482015260840161082b565b6040516001600160a01b03831660248201526044810182905261072690849063095ea7b360e01b90606401612452565b60008135811a60808110156125b65750600092915050565b60b88110806125d1575060c081108015906125d1575060f881105b156125df5750600192915050565b60c081101561260c576125f4600160b86131ce565b6126019060ff168261316f565b611e5c9060016130c1565b6125f4600160f86131ce565b6000808235811a608081101561263157600191506126b4565b60b88110156126575761264560808261316f565b6126509060016130c1565b91506126b4565b60c0811015612682576001939093019283356008602083900360b701021c810160b5190191506126b4565b60f88110156126965761264560c08261316f565b6001939093019283356008602083900360f701021c810160f5190191505b5092915050565b60006106fd826015612b46565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08311156126ff5750600090506003612783565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015612753573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b03811661277c57600060019250925050612783565b9150600090505b94509492505050565b6001600160a01b03821660009081526006602090815260408083205460089092528220600554919284926127bf906109d9565b8152602001908152602001600020546127d891906130c1565b1115612811576001600160a01b0382166000908152600660209081526040808320546008909252822060055491928492611140906109d9565b6001600160a01b0382166000908152600860205260408120600554839290612838906109d9565b8152602001908152602001600020600082825461285591906130c1565b90915550506001600160a01b0382166000908152600a6020908152604080832054600c90925282206009549192849261288d906109d9565b8152602001908152602001600020546128a691906130c1565b11156128df576001600160a01b0382166000908152600a6020908152604080832054600c909252822060095491928492611249906109d9565b6001600160a01b0382166000908152600c602052604081206009548392906112ab906109d9565b6040516370a0823160e01b81526001600160a01b038381166004830152600091908516906370a0823190602401602060405180830381865afa158015612950573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129749190613198565b6040516340c10f1960e01b81526001600160a01b03858116600483015260248201859052919250908516906340c10f1990604401600060405180830381600087803b1580156129c257600080fd5b505af11580156129d6573d6000803e3d6000fd5b50506040516370a0823160e01b81526001600160a01b03868116600483015260009350871691506370a0823190602401602060405180830381865afa158015612a23573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a479190613198565b905080612a5484846130c1565b146109725760405162ec6f7b60e31b815260040160405180910390fd5b6000612ac6826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612b939092919063ffffffff16565b9050805160001480612ae7575080806020019051810190612ae791906131e7565b6107265760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b606482015260840161082b565b60008082118015612b58575060218211155b612b6157600080fd5b6000612b6c8461259e565b90506000612b7a828561316f565b94909101356020949094036008029390931c9392505050565b6060612ba28484600085612baa565b949350505050565b606082471015612c0b5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b606482015260840161082b565b600080866001600160a01b03168587604051612c279190613209565b60006040518083038185875af1925050503d8060008114612c64576040519150601f19603f3d011682016040523d82523d6000602084013e612c69565b606091505b5091509150612c7a87838387612c85565b979650505050505050565b60608315612cf4578251600003612ced576001600160a01b0385163b612ced5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161082b565b5081612ba2565b612ba28383815115612d095781518083602001fd5b8060405162461bcd60e51b815260040161082b9190613225565b6040805161010081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e081019190915290565b6001600160a01b038116811461064f57600080fd5b60008060408385031215612d8f57600080fd5b8235612d9a81612d67565b91506020830135612daa81612d67565b809150509250929050565b600060208284031215612dc757600080fd5b8135611e5c81612d67565b600060208284031215612de457600080fd5b5035919050565b60008060408385031215612dfe57600080fd5b8235612e0981612d67565b946020939093013593505050565b600080600060608486031215612e2c57600080fd5b8335612e3781612d67565b9250602084013591506040840135612e4e81612d67565b809150509250925092565b60008060008060808587031215612e6f57600080fd5b8435612e7a81612d67565b9350602085013592506040850135612e9181612d67565b9396929550929360600135925050565b60008083601f840112612eb357600080fd5b50813567ffffffffffffffff811115612ecb57600080fd5b60208301915083602082850101111561205d57600080fd5b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff81118282101715612f2257612f22612ee3565b604052919050565b600067ffffffffffffffff821115612f4457612f44612ee3565b50601f01601f191660200190565b600080600080600060608688031215612f6a57600080fd5b853567ffffffffffffffff80821115612f8257600080fd5b612f8e89838a01612ea1565b90975095506020880135915080821115612fa757600080fd5b612fb389838a01612ea1565b90955093506040880135915080821115612fcc57600080fd5b508601601f81018813612fde57600080fd5b8035612ff1612fec82612f2a565b612ef9565b81815289602083850101111561300657600080fd5b816020840160208301376000602083830101528093505050509295509295909350565b6bffffffffffffffffffffffff19606095861b8116825260148201949094529190931b9091166034820152604881019190915260680190565b8183823760009101908152919050565b634e487b7160e01b600052601160045260246000fd5b6000826130a557634e487b7160e01b600052601260045260246000fd5b500490565b80820281158282048414176106fd576106fd613072565b808201808211156106fd576106fd613072565b60005b838110156130ef5781810151838201526020016130d7565b50506000910152565b60006020828403121561310a57600080fd5b815167ffffffffffffffff81111561312157600080fd5b8201601f8101841361313257600080fd5b8051613140612fec82612f2a565b81815285602083850101111561315557600080fd5b6131668260208301602086016130d4565b95945050505050565b818103818111156106fd576106fd613072565b634e487b7160e01b600052602160045260246000fd5b6000602082840312156131aa57600080fd5b5051919050565b6000602082840312156131c357600080fd5b8151611e5c81612d67565b60ff82811682821603908111156106fd576106fd613072565b6000602082840312156131f957600080fd5b81518015158114611e5c57600080fd5b6000825161321b8184602087016130d4565b9190910192915050565b60208152600082518060208401526132448160408501602087016130d4565b601f01601f1916919091016040019291505056fecd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f033009b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00a264697066735822122082f7c11eed94f3b9e719d1a3e5f7da5ee1bb3e625abc6505d59d0f4243aad75864736f6c63430008140033
Deployed Bytecode Sourcemap
890:10132:36:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;9697:161;;;;;;:::i;:::-;;:::i;:::-;;1308:30:37;;;;;;;;;689:25:55;;;677:2;662:18;1308:30:37;;;;;;;;876:31;;;;;;10043:65:36;;;:::i;1843:54:37:-;;;;;;:::i;:::-;;;;;;;;;;;;-1:-1:-1;;;;;1843:54:37;;;;;;-1:-1:-1;;;;;1141:32:55;;;1123:51;;1111:2;1096:18;1843:54:37;977:203:55;1265:254:36;;;;;;:::i;:::-;;:::i;8632:113::-;;;;;;:::i;:::-;;:::i;1080:71:37:-;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;8987:155:36;;;;;;:::i;:::-;;:::i;9148:115::-;;;;;;:::i;:::-;;:::i;2692:145:3:-;-1:-1:-1;;;;;;;;;;;2821:9:3;;;2692:145;;1855:14:55;;1848:22;1830:41;;1818:2;1803:18;2692:145:3;1690:187:55;3155:101:0;;;:::i;8751:111:36:-;;;;;;:::i;:::-;;:::i;7786:477::-;;;;;;:::i;:::-;;:::i;1388:43:37:-;;;;;;:::i;:::-;;;;;;;;;;;;;;9976:61:36;;;:::i;1507:70:37:-;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;958:44;;;;;;:::i;:::-;;;;;;;;;;;;;;2441:144:0;1313:22;2570:8;-1:-1:-1;;;;;2570:8:0;2441:144;;9269:205:36;;;;;;:::i;:::-;;:::i;2073:451::-;;;;;;:::i;:::-;;:::i;544:21:37:-;;;;;-1:-1:-1;;;;;544:21:37;;;8366:103:36;;;;;;:::i;:::-;;:::i;1654:71:37:-;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;8475:151:36;;;;;;:::i;:::-;;:::i;4763:1475::-;;;;;;:::i;:::-;;:::i;8868:113::-;;;;;;:::i;:::-;;:::i;1229:72:37:-;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;9480:211:36;;;;;;:::i;:::-;;:::i;3405:215:0:-;;;;;;:::i;:::-;;:::i;8735:136:37:-;;;;;;:::i;:::-;;:::i;9697:161:36:-;2334:13:0;:11;:13::i;:::-;9812:39:36::1;9830:5;9837:13;9812:17;:39::i;:::-;9697:161:::0;;:::o;10043:65::-;2334:13:0;:11;:13::i;:::-;10091:10:36::1;:8;:10::i;:::-;10043:65::o:0;1265:254::-;8870:21:1;4302:15;;-1:-1:-1;;;4302:15:1;;;;4301:16;;4348:14;;4158:30;4726:16;;:34;;;;;4746:14;4726:34;4706:54;;4770:17;4790:11;:16;;4805:1;4790:16;:50;;;;-1:-1:-1;4818:4:1;4810:25;:30;4790:50;4770:70;;4856:12;4855:13;:30;;;;;4873:12;4872:13;4855:30;4851:91;;;4908:23;;-1:-1:-1;;;4908:23:1;;;;;;;;;;;4851:91;4951:18;;-1:-1:-1;;4951:18:1;4968:1;4951:18;;;4979:67;;;;5013:22;;-1:-1:-1;;;;5013:22:1;-1:-1:-1;;;5013:22:1;;;4979:67;1376:28:36::1;1391:12;1376:14;:28::i;:::-;1414:17;:15;:17::i;:::-;1441:24;:22;:24::i;:::-;1476:36;1505:6;1476:28;:36::i;:::-;5070:14:1::0;5066:101;;;5100:23;;-1:-1:-1;;;;5100:23:1;;;5142:14;;-1:-1:-1;5252:50:55;;5142:14:1;;5240:2:55;5225:18;5142:14:1;;;;;;;5066:101;4092:1081;;;;;1265:254:36;;:::o;8632:113::-;2334:13:0;:11;:13::i;:::-;8708:30:36::1;8729:8;8708:20;:30::i;:::-;8632:113:::0;:::o;8987:155::-;2334:13:0;:11;:13::i;:::-;9099:36:36::1;9110:6;9118:16;9099:10;:36::i;9148:115::-:0;2334:13:0;:11;:13::i;:::-;9225:31:36::1;9239:16;9225:13;:31::i;3155:101:0:-:0;2334:13;:11;:13::i;:::-;3219:30:::1;3246:1;3219:18;:30::i;8751:111:36:-:0;2334:13:0;:11;:13::i;:::-;8826:29:36::1;8846:8;8826:19;:29::i;7786:477::-:0;7898:7;8119:41;;;:23;:41;;;;;;;;;8003:221;;7936:18;;7898:7;;8003:221;;8045:9;;8080:13;;-1:-1:-1;;;;;8119:41:36;;8143:16;;8003:221;;:::i;:::-;;;;-1:-1:-1;;8003:221:36;;;;;;;;;7972:270;;8003:221;7972:270;;;;7936:320;;;;;;;;;;-1:-1:-1;7936:320:36;;-1:-1:-1;;;;;7936:320:36;;-1:-1:-1;7786:477:36;;;;;:::o;9976:61::-;2334:13:0;:11;:13::i;:::-;10022:8:36::1;:6;:8::i;9269:205::-:0;2334:13:0;:11;:13::i;:::-;9414:53:36::1;9430:9;9441:16;9459:7;9414:15;:53::i;:::-;9269:205:::0;;;:::o;2073:451::-;3251:21:4;:19;:21::i;:::-;2316:19:3::1;:17;:19::i;:::-;2262:16:36::2;:14;:16::i;:::-;2288:37;2307:9;2318:6;2288:18;:37::i;:::-;2395:1;2340:43;2355:9:::0;2366:16;2340:14:::2;:43::i;:::-;-1:-1:-1::0;;;;;2340:57:36::2;;2336:181;;2413:55;2422:9;2433:16;2451:8;2461:6;2413:8;:55::i;:::-;2336:181;;;2492:25;;-1:-1:-1::0;;;2492:25:36::2;;;;;;;;;;;2336:181;3293:20:4::0;1805:1;-1:-1:-1;;;;;;;;;;;3969:23:4;3716:283;3293:20;2073:451:36;;;;:::o;8366:103::-;2334:13:0;:11;:13::i;:::-;8437:25:36::1;8448:13;8437:10;:25::i;8475:151::-:0;2334:13:0;:11;:13::i;:::-;8585:34:36::1;8598:12;8612:6;8585:12;:34::i;4763:1475::-:0;3251:21:4;:19;:21::i;:::-;2316:19:3::1;:17;:19::i;:::-;5077:1:36::2;5064:15:::0;::::2;5055:25:::0;::::2;::::0;5132:2:::2;5119:16;5110:26;4957:19;::::0;5272:55:::2;5110:26:::0;5272:40:::2;:55::i;:::-;5156:171;;;;5359:13;5342:5;:13;;;:30;5338:102;;5426:13;::::0;::::2;::::0;5393:47:::2;::::0;-1:-1:-1;;;5393:47:36;;5411:13:::2;5393:47;::::0;::::2;5956:25:55::0;5997:18;;;5990:34;;;;5929:18;;5393:47:36::2;;;;;;;;5338:102;5451:30;5484:35;5507:11;5484:22;:35::i;:::-;5534:21;::::0;::::2;::::0;5451:68;;-1:-1:-1;;;;;;5534:35:36::2;5530:84;;5590:24;;-1:-1:-1::0;;;5590:24:36::2;;;;;;;;;;;5530:84;5629:25;::::0;::::2;::::0;-1:-1:-1;;;;;5629:42:36::2;5666:4;5629:42;5625:91;;5692:24;;-1:-1:-1::0;;;5692:24:36::2;;;;;;;;;;;5625:91;5773:21;::::0;;::::2;::::0;5755:13;;5731:38:::2;::::0;;;:23:::2;:38:::0;;;;;;;;-1:-1:-1;;;;;5731:38:36;;::::2;:63:::0;::::2;;5727:103;;5815:15;;-1:-1:-1::0;;;5815:15:36::2;;;;;;;;;;;5727:103;5871:10;;5861:21;;;;;;;:::i;:::-;;::::0;;;;::::2;::::0;;5841:41;;5907:4:::2;5892:12;::::0;::::2;:19:::0;;;5941:17;;5921::::2;::::0;::::2;:37:::0;6048:13:::2;6031:31:::0;;6130:6;;-1:-1:-1;;;;;6130:6:36::2;6086:40;6031:31:::0;6111:14;6086:13:::2;:40::i;:::-;-1:-1:-1::0;;;;;6086:50:36::2;;6082:91;;6157:16;;-1:-1:-1::0;;;6157:16:36::2;;;;;;;;;;;6082:91;6184:47;6194:5;6201:11;6214:5;6221:9;6184;:47::i;:::-;4947:1291;;;;;;3293:20:4::0;1805:1;-1:-1:-1;;;;;;;;;;;3969:23:4;3716:283;3293:20;4763:1475:36;;;;;:::o;8868:113::-;2334:13:0;:11;:13::i;:::-;8948:26:36::1;8960:5;8967:6;8948:11;:26::i;9480:211::-:0;2334:13:0;:11;:13::i;:::-;9628:56:36::1;9647:9;9658:16;9676:7;9628:18;:56::i;3405:215:0:-:0;2334:13;:11;:13::i;:::-;-1:-1:-1;;;;;3489:22:0;::::1;3485:91;;3534:31;::::0;-1:-1:-1;;;3534:31:0;;3562:1:::1;3534:31;::::0;::::1;1123:51:55::0;1096:18;;3534:31:0::1;977:203:55::0;3485:91:0::1;3585:28;3604:8;3585:18;:28::i;8735:136:37:-:0;8799:7;8856:8;8826:26;8856:8;8826:15;:26;:::i;:::-;8825:39;;;;:::i;2658:162:0:-;966:10:2;2717:7:0;1313:22;2570:8;-1:-1:-1;;;;;2570:8:0;;2441:144;2717:7;-1:-1:-1;;;;;2717:23:0;;2713:101;;2763:40;;-1:-1:-1;;;2763:40:0;;966:10:2;2763:40:0;;;1123:51:55;1096:18;;2763:40:0;977:203:55;8345:384:37;-1:-1:-1;;;;;8427:28:37;;;;:62;;-1:-1:-1;;;;;;8459:30:37;;;8427:62;8423:100;;;8510:13;;-1:-1:-1;;;8510:13:37;;;;;;;;;;;8423:100;-1:-1:-1;;;;;8538:26:37;;;8576:1;8538:26;;;:19;:26;;;;;;;:40;8534:92;;8599:27;;-1:-1:-1;;;8599:27:37;;;;;;;;;;;8534:92;8668:7;-1:-1:-1;;;;;8642:34:37;8661:5;-1:-1:-1;;;;;8642:34:37;;;;;;;;;;;-1:-1:-1;;;;;8686:26:37;;;;;;;:19;:26;;;;;:36;;-1:-1:-1;;;;;;8686:36:37;;;;;;;;8345:384::o;3674:178:3:-;2563:16;:14;:16::i;:::-;-1:-1:-1;;;;;;;;;;;3791:17:3;;-1:-1:-1;;3791:17:3::1;::::0;;3823:22:::1;966:10:2::0;3832:12:3::1;3823:22;::::0;-1:-1:-1;;;;;1141:32:55;;;1123:51;;1111:2;1096:18;3823:22:3::1;;;;;;;3722:130;3674:178::o:0;1847:127:0:-;6931:20:1;:18;:20::i;:::-;1929:38:0::1;1954:12;1929:24;:38::i;1836:97:3:-:0;6931:20:1;:18;:20::i;:::-;1899:27:3::1;:25;:27::i;2540:111:4:-:0;6931:20:1;:18;:20::i;:::-;2610:34:4::1;:32;:34::i;1985:154:37:-:0;2065:25;2076:13;2065:10;:25::i;:::-;2100:32;5893:7;5874:16;:26;5928:6;5910:15;:24;5813:128;5215:167;5311:16;;5287:51;;;5956:25:55;;;6012:2;5997:18;;5990:34;;;5287:51:37;;5929:18:55;5287:51:37;;;;;;;5348:16;:27;5215:167::o;5947:481::-;-1:-1:-1;;;;;6032:22:37;;6028:73;;6077:13;;-1:-1:-1;;;6077:13:37;;;;;;;;;;;6028:73;6114:16;6134:1;6114:21;6110:73;;6158:14;;-1:-1:-1;;;6158:14:37;;;;;;;;;;;6110:73;6249:4;6196:41;;;:23;:41;;;;;;-1:-1:-1;;;;;6196:41:37;:58;6192:116;;6277:20;;-1:-1:-1;;;6277:20:37;;;;;;;;;;;6192:116;6318:41;;;;:23;:41;;;;;;;;;:50;;-1:-1:-1;;;;;;6318:50:37;-1:-1:-1;;;;;6318:50:37;;;;;;;;6384:37;;689:25:55;;;6384:37:37;;662:18:55;6384:37:37;;;;;;;;5947:481;;:::o;6434:367::-;6559:4;6506:41;;;:23;:41;;;;;;-1:-1:-1;;;;;6506:41:37;6502:112;;6587:16;;-1:-1:-1;;;6587:16:37;;;;;;;;;;;6502:112;6623:14;6640:41;;;:23;:41;;;;;;;;;;;-1:-1:-1;;;;;;6691:48:37;;;;;6755:39;;689:25:55;;;-1:-1:-1;;;;;6640:41:37;;;;;;6755:39;;662:18:55;6755:39:37;543:177:55;3774:248:0;1313:22;3923:8;;-1:-1:-1;;;;;;3941:19:0;;-1:-1:-1;;;;;3941:19:0;;;;;;;;3975:40;;3923:8;;;;;3975:40;;3847:24;;3975:40;3837:185;;3774:248;:::o;5388:163:37:-;5482:15;;5459:49;;;5956:25:55;;;6012:2;5997:18;;5990:34;;;5459:49:37;;5929:18:55;5459:49:37;;;;;;;5518:15;:26;5388:163::o;3366:176:3:-;2316:19;:17;:19::i;:::-;-1:-1:-1;;;;;;;;;;;3484:16:3;;-1:-1:-1;;3484:16:3::1;3496:4;3484:16;::::0;;3515:20:::1;966:10:2::0;3522:12:3::1;887:96:2::0;6807:815:37;7000:1;6947:41;;;:23;:41;;;;;;-1:-1:-1;;;;;6947:41:37;6943:105;;7023:25;;-1:-1:-1;;;7023:25:37;;;;;;;;;;;6943:105;-1:-1:-1;;;;;7063:23:37;;;;:48;;-1:-1:-1;;;;;;7090:21:37;;;7063:48;7059:86;;;7132:13;;-1:-1:-1;;;7132:13:37;;;;;;;;;;;7059:86;7156:17;7291:41;;;:23;:41;;;;;;;;;7199:181;;;;7233:9;;7260:13;;-1:-1:-1;;;;;7291:41:37;;;;7315:16;;7199:181;;:::i;:::-;;;;-1:-1:-1;;7199:181:37;;;;;;;;;7176:214;;7199:181;7176:214;;;;7446:1;7405:29;;;:18;:29;;;;;;7176:214;;-1:-1:-1;;;;;;7405:29:37;:43;7401:94;;7469:26;;-1:-1:-1;;;7469:26:37;;;;;;;;;;;7401:94;7506:29;;;;:18;:29;;;;;;;;;:39;;-1:-1:-1;;;;;;7506:39:37;-1:-1:-1;;;;;7506:39:37;;;;;;;;;7561:54;;689:25:55;;;7561:54:37;;;;;;662:18:55;7561:54:37;;;;;;;;6933:689;6807:815;;;:::o;3326:384:4:-;-1:-1:-1;;;;;;;;;;;3526:9:4;;-1:-1:-1;;3526:20:4;3522:88;;3569:30;;-1:-1:-1;;;3569:30:4;;;;;;;;;;;3522:88;1847:1;3684:19;;3326:384::o;2905:128:3:-;-1:-1:-1;;;;;;;;;;;2821:9:3;;;2966:61;;;3001:15;;-1:-1:-1;;;3001:15:3;;;;;;;;;;;2145:411:37;2194:15;;-1:-1:-1;;;;;2194:15:37;:29;;;;:62;;-1:-1:-1;2227:24:37;;:29;;2194:62;2190:274;;;2293:15;;-1:-1:-1;;;;;2293:15:37;2312:9;2293:28;:88;;;;;2369:12;2341:24;;:40;2293:88;2272:182;;;2421:18;;-1:-1:-1;;;2421:18:37;;;;;;;;;;;2272:182;2473:15;:27;;-1:-1:-1;;;;;;2473:27:37;2491:9;2473:27;;;2537:12;2510:24;:39;2145:411::o;2562:1064::-;-1:-1:-1;;;;;2800:20:37;;;;;;:9;:20;;;;;;;;;2698:16;:27;;;;;2742:16;;2800:20;;2779:6;;2726:33;;:15;:33::i;:::-;2698:62;;;;;;;;;;;;:87;;;;:::i;:::-;:122;2681:359;;;-1:-1:-1;;;;;2886:20:37;;;;;;:9;:20;;;;;;;;;2924:16;:27;;;;;2968:16;;2886:20;;3009:6;;2952:33;;:15;:33::i;:::-;2924:62;;;;;;;;;;;;:91;;;;:::i;:::-;2852:177;;-1:-1:-1;;;2852:177:37;;;;;5956:25:55;;;;5997:18;;;5990:34;5929:18;;2852:177:37;5782:248:55;2681:359:37;-1:-1:-1;;;;;3049:27:37;;;;;;:16;:27;;;;;3106:16;;3137:6;;3049:27;3090:33;;:15;:33::i;:::-;3049:84;;;;;;;;;;;;:94;;;;;;;:::i;:::-;;;;-1:-1:-1;;;;;;;3305:19:37;;;;;;:8;:19;;;;;;;;;3205:15;:26;;;;;3248:15;;3305:19;;3284:6;;3232:32;;:15;:32::i;:::-;3205:60;;;;;;;;;;;;:85;;;;:::i;:::-;:119;3188:352;;;-1:-1:-1;;;;;3389:19:37;;;;;;:8;:19;;;;;;;;;3426:15;:26;;;;;3469:15;;3389:19;;3509:6;;3453:32;;:15;:32::i;:::-;3426:60;;;;;;;;;;;;:89;;;;:::i;:::-;3356:173;;-1:-1:-1;;;3356:173:37;;;;;5956:25:55;;;;5997:18;;;5990:34;5929:18;;3356:173:37;5782:248:55;3188:352:37;-1:-1:-1;;;;;3549:26:37;;;;;;:15;:26;;;;;3592:15;;3613:6;;3549:26;3576:32;;:15;:32::i;:::-;3549:60;;;;;;;;;;;;:70;;;;;;;:::i;:::-;;;;-1:-1:-1;;;;2562:1064:37:o;2530:1155:36:-;2741:1;2688:41;;;:23;:41;;;;;;-1:-1:-1;;;;;2688:41:36;2684:118;;2766:25;;-1:-1:-1;;;2766:25:36;;;;;;;;;;;2684:118;-1:-1:-1;;;;;2867:30:36;;;2811:14;2867:30;;;:19;:30;;;;;;2828:10;;2867:30;;2907:174;;2948:36;2958:9;2969:6;2977;2948:9;:36::i;:::-;2907:174;;;3015:55;3035:7;3044:9;3055:6;3063;3015:19;:55::i;:::-;3091:24;3118:191;;;;;;;;3140:52;3174:9;-1:-1:-1;;;;;3162:27:36;;:29;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;3162:29:36;;;;;;;;;;;;:::i;:::-;3140:21;:52::i;:::-;3118:191;;;;3206:54;3240:9;-1:-1:-1;;;;;3228:29:36;;:31;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;3206:54;3118:191;;3274:1;3118:191;;;;;;;;;;;;;;3344:14;;;;;;3437:41;;;:23;:41;;;;3091:218;;-1:-1:-1;;;;;;3384:294:36;;;;;;;;3437:41;3384:294;3461:16;3534:9;3557:43;3534:9;3461:16;3557:14;:43::i;:::-;3634:12;;3384:294;;;8217:25:55;;;-1:-1:-1;;;;;8316:15:55;;;8311:2;8296:18;;;8289:43;;;;8368:15;;;8348:18;;;8341:43;8415:2;8400:18;;;8393:34;;;8458:3;8443:19;;8436:35;;;;8508:13;;8269:3;8487:19;;8480:42;8565:15;;;8559:22;8553:3;8538:19;;8531:51;8625:15;;;8619:22;8613:3;8598:19;;8591:51;8689:15;;8683:22;8679:31;8673:3;8658:19;;8651:60;8204:3;8189:19;3384:294:36;;;;;;;2674:1011;;;2530:1155;;;;:::o;3716:283:4:-;1805:1;-1:-1:-1;;;;;;;;;;;3969:23:4;3716:283::o;4628:208:37:-;-1:-1:-1;;;;;4694:29:37;;4690:55;;4732:13;;-1:-1:-1;;;4732:13:37;;;;;;;;;;;4690:55;4775:6;;4761:36;;-1:-1:-1;;;;;4761:36:37;;;;4775:6;;4761:36;;4775:6;;4761:36;4807:6;:22;;-1:-1:-1;;;;;;4807:22:37;-1:-1:-1;;;;;4807:22:37;;;;;;;;;;4628:208::o;4939:270::-;-1:-1:-1;;;;;5017:21:37;;5013:47;;5047:13;;-1:-1:-1;;;5047:13:37;;;;;;;;;;;5013:47;-1:-1:-1;;;;;5091:16:37;;5071:17;5091:16;;;:9;:16;;;;;;;;;;5122:43;;5956:25:55;;;5997:18;;;5990:34;;;5091:16:37;;5122:43;;5929:18:55;5122:43:37;;;;;;;-1:-1:-1;;;;;;5175:16:37;;;;;;;:9;:16;;;;;:27;4939:270::o;1242:1652:46:-;-1:-1:-1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1355:23:46;;1405:54;1438:20;:13;1454:4;1438:20;:::i;:::-;1405:32;:54::i;:::-;1390:69;-1:-1:-1;1390:69:46;1608:28;1390:69;1608:22;:28::i;:::-;1601:35;-1:-1:-1;1675:121:46;1725:12;1759:19;1725:12;1601:35;1759:19;:::i;:::-;1675:28;:121::i;:::-;1800:1;1675:126;1650:217;;;;-1:-1:-1;;;1650:217:46;;9057:2:55;1650:217:46;;;9039:21:55;;;9076:18;;;9069:30;9135:34;9115:18;;;9108:62;9187:18;;1650:217:46;8855:356:55;1650:217:46;1469:409;1931:28;1954:4;1931:22;:28::i;:::-;1924:35;-1:-1:-1;1924:35:46;2051:28;1924:35;2051:22;:28::i;:::-;2044:35;;2089:16;2108:38;2141:4;2108:32;:38::i;:::-;2089:57;;2156:514;2174:4;2163:8;:15;2156:514;;;2210:8;2243:32;2210:8;2243:22;:32::i;:::-;2232:43;;2356:19;2378:30;2397:5;2404:3;2378:18;:30::i;:::-;2356:52;-1:-1:-1;2437:16:46;2426:7;:27;;;;;;;;:::i;:::-;;2422:238;;2517:16;2502:11;:31;;;;;;;;:::i;:::-;;2473:133;;;;-1:-1:-1;;;2473:133:46;;9550:2:55;2473:133:46;;;9532:21:55;9589:2;9569:18;;;9562:30;9628:33;9608:18;;;9601:61;9679:18;;2473:133:46;9348:355:55;2473:133:46;2638:7;2624:21;;2422:238;2182:488;;2156:514;;;2778:16;2763:11;:31;;;;;;;;:::i;:::-;;2742:108;;;;-1:-1:-1;;;2742:108:46;;9910:2:55;2742:108:46;;;9892:21:55;9949:2;9929:18;;;9922:30;9988:32;9968:18;;;9961:60;10038:18;;2742:108:46;9708:354:55;2742:108:46;2860:27;;;1242:1652;;;:::o;622:560:47:-;700:12;;:::i;:::-;724:18;;:::i;:::-;752;773;:11;787:4;773:18;:::i;:::-;752:39;;856:4;844:10;837:5;824:37;925:4;913:10;909:21;895:35;;986:4;974:10;967:4;960:5;956:16;943:48;1060:4;1044:21;1121:4;1044:21;1102:4;1091:16;;1078:48;-1:-1:-1;1170:5:47;622:560;-1:-1:-1;;622:560:47:o;3661:227:29:-;3739:7;3759:17;3778:18;3800:27;3811:4;3817:9;3800:10;:27::i;:::-;3758:69;;;;3837:18;3849:5;3837:11;:18::i;:::-;-1:-1:-1;3872:9:29;3661:227;-1:-1:-1;;;3661:227:29:o;6244:477:36:-;6452:20;;;;:11;:20;;;;;;;;6448:79;;;6495:21;;-1:-1:-1;;;6495:21:36;;;;;;;;;;;6448:79;6536:20;;;;:11;:20;;;;;:27;;-1:-1:-1;;6536:27:36;6559:4;6536:27;;;;;;6577:11;:56;;;;;;;;:::i;:::-;;6573:141;;6649:23;6659:5;6666;6649:9;:23::i;:::-;6573:141;;;6696:18;;-1:-1:-1;;;6696:18:36;;;;;;;;;;;5557:250:37;-1:-1:-1;;;;;5634:21:37;;5630:72;;5678:13;;-1:-1:-1;;;5678:13:37;;;;;;;;;;;5630:72;-1:-1:-1;;;;;5716:48:37;;5738:15;;;;:8;:15;;;;;;;;;;5716:48;;5956:25:55;;;5997:18;;;5990:34;;;5716:48:37;;5929:18:55;5716:48:37;;;;;;;-1:-1:-1;;;;;5774:15:37;;;;;;;:8;:15;;;;;:26;5557:250::o;7628:711::-;7824:1;7771:41;;;:23;:41;;;;;;-1:-1:-1;;;;;7771:41:37;7767:105;;7847:25;;-1:-1:-1;;;7847:25:37;;;;;;;;;;;7767:105;7883:17;8018:41;;;:23;:41;;;;;;;;;7926:181;;;;7960:9;;7987:13;;-1:-1:-1;;;;;8018:41:37;;;;8042:16;;7926:181;;:::i;:::-;;;;;;;-1:-1:-1;;7926:181:37;;;;;;7903:214;;7926:181;7903:214;;;;8132:29;;;;:18;:29;;;;;;7903:214;;-1:-1:-1;;;;;;8132:40:37;;;:29;;:40;8128:85;;8193:20;;-1:-1:-1;;;8193:20:37;;;;;;;;;;;8128:85;8231:29;;;;:18;:29;;;;;;;8224:36;;-1:-1:-1;;;;;;8224:36:37;;;8276:56;-1:-1:-1;;;;;8276:56:37;;;;;;;;;;;;8315:16;689:25:55;;677:2;662:18;;543:177;3105:126:3;-1:-1:-1;;;;;;;;;;;2821:9:3;;;3163:62;;3199:15;;-1:-1:-1;;;3199:15:3;;;;;;;;;;;7084:141:1;8870:21;8560:40;-1:-1:-1;;;8560:40:1;;;;7146:73;;7191:17;;-1:-1:-1;;;7191:17:1;;;;;;;;;;;1980:235:0;6931:20:1;:18;:20::i;1939:156:3:-;6931:20:1;:18;:20::i;:::-;-1:-1:-1;;;;;;;;;;;2071:17:3;;-1:-1:-1;;2071:17:3::1;::::0;;1939:156::o;2657:183:4:-;6931:20:1;:18;:20::i;10226:394:36:-;10366:32;;-1:-1:-1;;;10366:32:36;;-1:-1:-1;;;;;1141:32:55;;;10366::36;;;1123:51:55;10342:21:36;;10366:23;;;;;;1096:18:55;;10366:32:36;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;10408:43;;-1:-1:-1;;;10408:43:36;;-1:-1:-1;;;;;10448:32:55;;;10408:43:36;;;10430:51:55;10497:18;;;10490:34;;;10342:56:36;;-1:-1:-1;10408:26:36;;;;;;10403:18:55;;10408:43:36;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;10484:32:36;;-1:-1:-1;;;10484:32:36;;-1:-1:-1;;;;;1141:32:55;;;10484::36;;;1123:51:55;10461:20:36;;-1:-1:-1;10484:23:36;;;-1:-1:-1;10484:23:36;;1096:18:55;;10484:32:36;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;10461:55;-1:-1:-1;10555:13:36;10530:21;10545:6;10461:55;10530:21;:::i;:::-;:38;10526:88;;10591:12;;-1:-1:-1;;;10591:12:36;;;;;;;;;;;3691:550;3845:14;3885:7;-1:-1:-1;;;;;3870:30:36;;:32;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;3845:58;-1:-1:-1;;;;;;3917:20:36;;3913:52;;3946:19;;-1:-1:-1;;;3946:19:36;;;;;;;;;;;3913:52;4013:65;-1:-1:-1;;;;;4013:34:36;;4048:6;4064:4;4071:6;4013:34;:65::i;:::-;4088:46;-1:-1:-1;;;;;4088:29:36;;4118:7;4127:6;4088:29;:46::i;:::-;4144:39;;-1:-1:-1;;;4144:39:36;;;;;689:25:55;;;-1:-1:-1;;;;;4144:31:36;;;;;662:18:55;;4144:39:36;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4194:40;4204:6;4220:4;4227:6;4194:9;:40::i;252:320:48:-;424:26;;336:14;;403:6;;424:31;;420:72;;-1:-1:-1;478:3:48;;252:320;-1:-1:-1;;252:320:48:o;420:72::-;-1:-1:-1;;552:2:48;540:15;534:22;;252:320::o;304:158:45:-;385:12;429:26;444:10;429:14;:26::i;:::-;416:39;;:10;:39;:::i;468:116::-;519:16;561;572:4;561:10;:16::i;590:149::-;681:7;713:19;728:3;713:14;:19::i;:::-;707:25;;:3;:25;:::i;:::-;700:32;590:149;-1:-1:-1;;;590:149:45:o;2900:3675:46:-;3006:23;3041:15;3059:37;3092:3;3059:32;:37::i;:::-;3041:55;-1:-1:-1;3106:23:46;3041:55;3255:31;3041:55;3255:22;:31::i;:::-;3245:41;;3318;3345:13;3318:26;:41::i;:::-;3300:59;-1:-1:-1;3400:17:46;;-1:-1:-1;3400:17:46;;;3549:7;3580:31;3549:7;3580:22;:31::i;:::-;3570:41;;3996:40;4025:10;3996:28;:40::i;:::-;4040:3;3996:47;3992:109;;4070:16;4063:23;;;;;;;;;;;3992:109;4127:44;4160:10;4127:32;:44::i;:::-;4114:57;-1:-1:-1;1493:1:45;1484:11;;1471:25;4197:51:46;-1:-1:-1;4275:34:46;4298:10;4275:22;:34::i;:::-;4262:47;-1:-1:-1;1493:1:45;1484:11;;1471:25;-1:-1:-1;;;;;4345:99:46;;-1:-1:-1;4471:34:46;4494:10;4471:22;:34::i;:::-;4458:47;-1:-1:-1;1493:1:45;1484:11;;1471:25;-1:-1:-1;;;;;4528:99:46;;-1:-1:-1;4654:34:46;4677:10;4654:22;:34::i;:::-;4641:47;-1:-1:-1;1493:1:45;1484:11;;1471:25;-1:-1:-1;;;;;4713:99:46;;-1:-1:-1;4839:34:46;4862:10;4839:22;:34::i;:::-;4826:47;;4909:7;4895:10;:21;4887:30;;;;;;3514:1457;4981:11;4995:37;5024:7;4995:28;:37::i;:::-;4981:51;;5052:31;5075:7;5052:22;:31::i;:::-;5042:41;-1:-1:-1;5093:11:46;5107:13;5117:3;5042:41;5107:13;:::i;:::-;5093:27;;5235:19;234:143;5272:9;:28;5268:204;;-1:-1:-1;5371:24:46;;-1:-1:-1;5334:5:46;5268:204;;;5441:16;5434:23;;;;;;;;;;;;;5268:204;5496:11;5489:3;:18;5485:80;;5534:16;5527:23;;;;;;;;;;;;;5485:80;-1:-1:-1;5761:17:46;;5980:13;;;:23;;;6017:11;6024:4;5774:3;6017:11;:::i;:::-;;-1:-1:-1;6042:11:46;6049:4;6042:11;;:::i;:::-;;-1:-1:-1;;6287:4:46;6276:16;;6042:11;6336:3;6276:16;6309:36;-1:-1:-1;;;;;;;;6378:47:46;;;:25;;;:47;6435:39;;;:21;;;:39;6484:21;;:12;;;:21;6515:25;;;;:14;;;:25;-1:-1:-1;;2900:3675:46;;;;:::o;2145:730:29:-;2226:7;2235:12;2263:9;:16;2283:2;2263:22;2259:610;;2599:4;2584:20;;2578:27;2648:4;2633:20;;2627:27;2705:4;2690:20;;2684:27;2301:9;2676:36;2746:25;2757:4;2676:36;2578:27;2627;2746:10;:25::i;:::-;2739:32;;;;;;;;;2259:610;-1:-1:-1;2818:1:29;;-1:-1:-1;2822:35:29;2259:610;2145:730;;;;;:::o;570:511::-;647:20;638:5;:29;;;;;;;;:::i;:::-;;634:441;;570:511;:::o;634:441::-;743:29;734:5;:38;;;;;;;;:::i;:::-;;730:345;;788:34;;-1:-1:-1;;;788:34:29;;11010:2:55;788:34:29;;;10992:21:55;11049:2;11029:18;;;11022:30;11088:26;11068:18;;;11061:54;11132:18;;788:34:29;10808:348:55;730:345:29;852:35;843:5;:44;;;;;;;;:::i;:::-;;839:236;;903:41;;-1:-1:-1;;;903:41:29;;11363:2:55;903:41:29;;;11345:21:55;11402:2;11382:18;;;11375:30;11441:33;11421:18;;;11414:61;11492:18;;903:41:29;11161:355:55;839:236:29;974:30;965:5;:39;;;;;;;;:::i;:::-;;961:114;;1020:44;;-1:-1:-1;;;1020:44:29;;11723:2:55;1020:44:29;;;11705:21:55;11762:2;11742:18;;;11735:30;11801:34;11781:18;;;11774:62;-1:-1:-1;;;11852:18:55;;;11845:32;11894:19;;1020:44:29;11521:398:55;6727:1053:36;6860:15;;;;-1:-1:-1;;;;;6860:29:36;6856:67;;6898:25;;-1:-1:-1;;;6898:25:36;;;;;;;;;;;6856:67;6985:5;:15;;;-1:-1:-1;;;;;6937:63:36;:44;6952:5;:13;;;6967:5;:13;;;6937:14;:44::i;:::-;-1:-1:-1;;;;;6937:63:36;;6933:108;;7021:20;;-1:-1:-1;;;7021:20:36;;;;;;;;;;;6933:108;7052:48;7072:5;:13;;;7087:5;:12;;;7052:19;:48::i;:::-;7148:13;;;;-1:-1:-1;;;;;7128:34:36;;;7110:15;7128:34;;;:19;:34;;;;;;;;7172:400;;7213:54;7223:5;:13;;;7238:5;:14;;;7254:5;:12;;;7213:9;:54::i;:::-;7172:400;;;7298:14;7338:7;-1:-1:-1;;;;;7323:30:36;;:32;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;7298:58;-1:-1:-1;;;;;;7374:20:36;;7370:52;;7403:19;;-1:-1:-1;;;7403:19:36;;;;;;;;;;;7370:52;7437:46;7447:6;7463:4;7470:5;:12;;;7437:9;:46::i;:::-;7532:14;;;;7548:12;;;;7497:64;;-1:-1:-1;;;7497:64:36;;-1:-1:-1;;;;;7497:34:36;;;;;:64;;;;-1:-1:-1;;;;;10448:32:55;;;;10430:51;;10512:2;10497:18;;10490:34;10418:2;10403:18;;10256:274;7497:64:36;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;7284:288;7172:400;7667:5;:14;;;-1:-1:-1;;;;;7587:186:36;7641:5;:12;;;-1:-1:-1;;;;;7587:186:36;;7610:5;:17;;;7695:5;:15;;;7724:5;:13;;;7751:5;:12;;;7587:186;;;;;;;;12155:25:55;;;-1:-1:-1;;;;;12254:15:55;;;12249:2;12234:18;;12227:43;12306:15;;12301:2;12286:18;;12279:43;12353:2;12338:18;;12331:34;12142:3;12127:19;;11924:447;7587:186:36;;;;;;;;6846:934;6727:1053;;:::o;1355:203:22:-;1482:68;;-1:-1:-1;;;;;12634:15:55;;;1482:68:22;;;12616:34:55;12686:15;;12666:18;;;12659:43;12718:18;;;12711:34;;;1455:96:22;;1475:5;;-1:-1:-1;;;1505:27:22;12551:18:55;;1482:68:22;;;;-1:-1:-1;;1482:68:22;;;;;;;;;;;;;;-1:-1:-1;;;;;1482:68:22;-1:-1:-1;;;;;;1482:68:22;;;;;;;;;;1455:19;:96::i;1818:573::-;2143:10;;;2142:62;;-1:-1:-1;2159:39:22;;-1:-1:-1;;;2159:39:22;;2183:4;2159:39;;;12968:34:55;-1:-1:-1;;;;;13038:15:55;;;13018:18;;;13011:43;2159:15:22;;;;;12903:18:55;;2159:39:22;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;:44;2142:62;2121:163;;;;-1:-1:-1;;;2121:163:22;;13267:2:55;2121:163:22;;;13249:21:55;13306:2;13286:18;;;13279:30;13345:34;13325:18;;;13318:62;-1:-1:-1;;;13396:18:55;;;13389:52;13458:19;;2121:163:22;13065:418:55;2121:163:22;2321:62;;-1:-1:-1;;;;;10448:32:55;;2321:62:22;;;10430:51:55;10497:18;;;10490:34;;;2294:90:22;;2314:5;;-1:-1:-1;;;2344:22:22;10403:18:55;;2321:62:22;10256:274:55;3101:556:45;3182:7;3264:25;;3256:34;;126:4;3314:26;;3310:340;;;-1:-1:-1;3349:1:45;;3101:556;-1:-1:-1;;3101:556:45:o;3310:340::-;171:4;3382:25;;;:95;;-1:-1:-1;215:4:45;3424:25;;;;;:52;;-1:-1:-1;258:4:45;3453:23;;3424:52;3365:285;;;-1:-1:-1;3495:1:45;;3101:556;-1:-1:-1;;3101:556:45:o;3365:285::-;215:4;3515:24;;3511:139;;;3569:21;3589:1;171:4;3569:21;:::i;:::-;3560:31;;;;:5;:31;:::i;:::-;:35;;3594:1;3560:35;:::i;3511:139::-;3626:19;3644:1;258:4;3626:19;:::i;1705:1343::-;1769:7;;1876:25;;1868:34;;126:4;1926:26;;1922:1095;;;1964:1;1954:11;;1922:1095;;;171:4;1984:25;;1980:1037;;;2033:26;126:4;2033:5;:26;:::i;:::-;:30;;2062:1;2033:30;:::i;:::-;2023:40;;1980:1037;;;215:4;2082:24;;2078:939;;;2264:1;2247:19;;;;;2438:25;;2396:1;2403:2;2399:16;;;2175:4;2399:16;2392:24;2367:114;2509:29;;-1:-1:-1;;2509:29:45;;-1:-1:-1;2078:939:45;;;258:4;2572:23;;2568:449;;;2621:24;215:4;2621:5;:24;:::i;2568:449::-;2787:1;2770:19;;;;;2893:25;;2851:1;2858:2;2854:16;;;2733:4;2854:16;2847:24;2822:114;2964:29;;-1:-1:-1;;2964:29:45;;-1:-1:-1;2568:449:45;-1:-1:-1;3034:7:45;1705:1343;-1:-1:-1;;1705:1343:45:o;745:120::-;799:7;841:15;848:3;853:2;841:6;:15::i;5009:1456:29:-;5097:7;;6021:66;6008:79;;6004:161;;;-1:-1:-1;6119:1:29;;-1:-1:-1;6123:30:29;6103:51;;6004:161;6276:24;;;6259:14;6276:24;;;;;;;;;13871:25:55;;;13944:4;13932:17;;13912:18;;;13905:45;;;;13966:18;;;13959:34;;;14009:18;;;14002:34;;;6276:24:29;;13843:19:55;;6276:24:29;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;6276:24:29;;-1:-1:-1;;6276:24:29;;;-1:-1:-1;;;;;;;6314:20:29;;6310:101;;6366:1;6370:29;6350:50;;;;;;;6310:101;6429:6;-1:-1:-1;6437:20:29;;-1:-1:-1;5009:1456:29;;;;;;;;:::o;3632:990:37:-;-1:-1:-1;;;;;3864:16:37;;;;;;:9;:16;;;;;;;;;3765:17;:24;;;;;3806:16;;3864;;3843:6;;3790:33;;:15;:33::i;:::-;3765:59;;;;;;;;;;;;:84;;;;:::i;:::-;:115;3748:345;;;-1:-1:-1;;;;;3946:16:37;;;;;;:9;:16;;;;;;;;;3980:17;:24;;;;;4021:16;;3946;;4062:6;;4005:33;;:15;:33::i;3748:345::-;-1:-1:-1;;;;;4102:24:37;;;;;;:17;:24;;;;;4143:16;;4165:6;;4102:24;4127:33;;:15;:33::i;:::-;4102:59;;;;;;;;;;;;:69;;;;;;;:::i;:::-;;;;-1:-1:-1;;;;;;;4315:15:37;;;;;;:8;:15;;;;;;;;;4234:16;:23;;;;;4274:15;;4315;;4294:6;;4258:32;;:15;:32::i;:::-;4234:57;;;;;;;;;;;;:66;;;;:::i;:::-;:96;4217:322;;;-1:-1:-1;;;;;4395:15:37;;;;;;:8;:15;;;;;;;;;4428:16;:23;;;;;4468:15;;4395;;4508:6;;4452:32;;:15;:32::i;4217:322::-;-1:-1:-1;;;;;4548:23:37;;;;;;:16;:23;;;;;4588:15;;4609:6;;4548:23;4572:32;;:15;:32::i;10626:394:36:-;10766:32;;-1:-1:-1;;;10766:32:36;;-1:-1:-1;;;;;1141:32:55;;;10766::36;;;1123:51:55;10742:21:36;;10766:23;;;;;;1096:18:55;;10766:32:36;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;10808:43;;-1:-1:-1;;;10808:43:36;;-1:-1:-1;;;;;10448:32:55;;;10808:43:36;;;10430:51:55;10497:18;;;10490:34;;;10742:56:36;;-1:-1:-1;10808:26:36;;;;;;10403:18:55;;10808:43:36;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;10884:32:36;;-1:-1:-1;;;10884:32:36;;-1:-1:-1;;;;;1141:32:55;;;10884::36;;;1123:51:55;10861:20:36;;-1:-1:-1;10884:23:36;;;-1:-1:-1;10884:23:36;;1096:18:55;;10884:32:36;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;10861:55;-1:-1:-1;10861:55:36;10930:22;10946:6;10930:13;:22;:::i;:::-;:38;10926:88;;10991:12;;-1:-1:-1;;;10991:12:36;;;;;;;;;;;5196:642:22;5615:23;5641:69;5669:4;5641:69;;;;;;;;;;;;;;;;;5649:5;-1:-1:-1;;;;;5641:27:22;;;:69;;;;;:::i;:::-;5615:95;;5728:10;:17;5749:1;5728:22;:56;;;;5765:10;5754:30;;;;;;;;;;;;:::i;:::-;5720:111;;;;-1:-1:-1;;;5720:111:22;;14531:2:55;5720:111:22;;;14513:21:55;14570:2;14550:18;;;14543:30;14609:34;14589:18;;;14582:62;-1:-1:-1;;;14660:18:55;;;14653:40;14710:19;;5720:111:22;14329:406:55;871:433:45;936:7;969:1;963:3;:7;:20;;;;;981:2;974:3;:9;;963:20;955:29;;;;;;994:14;1011:19;1026:3;1011:14;:19::i;:::-;994:36;-1:-1:-1;1040:14:45;1057:12;994:36;1057:3;:12;:::i;:::-;1150:16;;;;1137:30;1244:2;1240:15;;;;1237:1;1233:23;1229:36;;;;;871:433;-1:-1:-1;;;871:433:45:o;4108:223:23:-;4241:12;4272:52;4294:6;4302:4;4308:1;4311:12;4272:21;:52::i;:::-;4265:59;4108:223;-1:-1:-1;;;;4108:223:23:o;5165:446::-;5330:12;5387:5;5362:21;:30;;5354:81;;;;-1:-1:-1;;;5354:81:23;;14942:2:55;5354:81:23;;;14924:21:55;14981:2;14961:18;;;14954:30;15020:34;15000:18;;;14993:62;-1:-1:-1;;;15071:18:55;;;15064:36;15117:19;;5354:81:23;14740:402:55;5354:81:23;5446:12;5460:23;5487:6;-1:-1:-1;;;;;5487:11:23;5506:5;5513:4;5487:31;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;5445:73;;;;5535:69;5562:6;5570:7;5579:10;5591:12;5535:26;:69::i;:::-;5528:76;5165:446;-1:-1:-1;;;;;;;5165:446:23:o;7671:628::-;7851:12;7879:7;7875:418;;;7906:10;:17;7927:1;7906:22;7902:286;;-1:-1:-1;;;;;1702:19:23;;;8113:60;;;;-1:-1:-1;;;8113:60:23;;15641:2:55;8113:60:23;;;15623:21:55;15680:2;15660:18;;;15653:30;15719:31;15699:18;;;15692:59;15768:18;;8113:60:23;15439:353:55;8113:60:23;-1:-1:-1;8208:10:23;8201:17;;7875:418;8249:33;8257:10;8269:12;8980:17;;:21;8976:379;;9208:10;9202:17;9264:15;9251:10;9247:2;9243:19;9236:44;8976:379;9331:12;9324:20;;-1:-1:-1;;;9324:20:23;;;;;;;;:::i;-1:-1:-1:-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o;14:131:55:-;-1:-1:-1;;;;;89:31:55;;79:42;;69:70;;135:1;132;125:12;150:388;218:6;226;279:2;267:9;258:7;254:23;250:32;247:52;;;295:1;292;285:12;247:52;334:9;321:23;353:31;378:5;353:31;:::i;:::-;403:5;-1:-1:-1;460:2:55;445:18;;432:32;473:33;432:32;473:33;:::i;:::-;525:7;515:17;;;150:388;;;;;:::o;725:247::-;784:6;837:2;825:9;816:7;812:23;808:32;805:52;;;853:1;850;843:12;805:52;892:9;879:23;911:31;936:5;911:31;:::i;1185:180::-;1244:6;1297:2;1285:9;1276:7;1272:23;1268:32;1265:52;;;1313:1;1310;1303:12;1265:52;-1:-1:-1;1336:23:55;;1185:180;-1:-1:-1;1185:180:55:o;1370:315::-;1438:6;1446;1499:2;1487:9;1478:7;1474:23;1470:32;1467:52;;;1515:1;1512;1505:12;1467:52;1554:9;1541:23;1573:31;1598:5;1573:31;:::i;:::-;1623:5;1675:2;1660:18;;;;1647:32;;-1:-1:-1;;;1370:315:55:o;1882:456::-;1959:6;1967;1975;2028:2;2016:9;2007:7;2003:23;1999:32;1996:52;;;2044:1;2041;2034:12;1996:52;2083:9;2070:23;2102:31;2127:5;2102:31;:::i;:::-;2152:5;-1:-1:-1;2204:2:55;2189:18;;2176:32;;-1:-1:-1;2260:2:55;2245:18;;2232:32;2273:33;2232:32;2273:33;:::i;:::-;2325:7;2315:17;;;1882:456;;;;;:::o;2343:525::-;2429:6;2437;2445;2453;2506:3;2494:9;2485:7;2481:23;2477:33;2474:53;;;2523:1;2520;2513:12;2474:53;2562:9;2549:23;2581:31;2606:5;2581:31;:::i;:::-;2631:5;-1:-1:-1;2683:2:55;2668:18;;2655:32;;-1:-1:-1;2739:2:55;2724:18;;2711:32;2752:33;2711:32;2752:33;:::i;:::-;2343:525;;;;-1:-1:-1;2804:7:55;;2858:2;2843:18;2830:32;;-1:-1:-1;;2343:525:55:o;2873:347::-;2924:8;2934:6;2988:3;2981:4;2973:6;2969:17;2965:27;2955:55;;3006:1;3003;2996:12;2955:55;-1:-1:-1;3029:20:55;;3072:18;3061:30;;3058:50;;;3104:1;3101;3094:12;3058:50;3141:4;3133:6;3129:17;3117:29;;3193:3;3186:4;3177:6;3169;3165:19;3161:30;3158:39;3155:59;;;3210:1;3207;3200:12;3225:127;3286:10;3281:3;3277:20;3274:1;3267:31;3317:4;3314:1;3307:15;3341:4;3338:1;3331:15;3357:275;3428:2;3422:9;3493:2;3474:13;;-1:-1:-1;;3470:27:55;3458:40;;3528:18;3513:34;;3549:22;;;3510:62;3507:88;;;3575:18;;:::i;:::-;3611:2;3604:22;3357:275;;-1:-1:-1;3357:275:55:o;3637:186::-;3685:4;3718:18;3710:6;3707:30;3704:56;;;3740:18;;:::i;:::-;-1:-1:-1;3806:2:55;3785:15;-1:-1:-1;;3781:29:55;3812:4;3777:40;;3637:186::o;3828:1266::-;3936:6;3944;3952;3960;3968;4021:2;4009:9;4000:7;3996:23;3992:32;3989:52;;;4037:1;4034;4027:12;3989:52;4077:9;4064:23;4106:18;4147:2;4139:6;4136:14;4133:34;;;4163:1;4160;4153:12;4133:34;4202:58;4252:7;4243:6;4232:9;4228:22;4202:58;:::i;:::-;4279:8;;-1:-1:-1;4176:84:55;-1:-1:-1;4367:2:55;4352:18;;4339:32;;-1:-1:-1;4383:16:55;;;4380:36;;;4412:1;4409;4402:12;4380:36;4451:60;4503:7;4492:8;4481:9;4477:24;4451:60;:::i;:::-;4530:8;;-1:-1:-1;4425:86:55;-1:-1:-1;4618:2:55;4603:18;;4590:32;;-1:-1:-1;4634:16:55;;;4631:36;;;4663:1;4660;4653:12;4631:36;-1:-1:-1;4686:24:55;;4741:4;4733:13;;4729:27;-1:-1:-1;4719:55:55;;4770:1;4767;4760:12;4719:55;4806:2;4793:16;4831:48;4847:31;4875:2;4847:31;:::i;:::-;4831:48;:::i;:::-;4902:2;4895:5;4888:17;4942:7;4937:2;4932;4928;4924:11;4920:20;4917:33;4914:53;;;4963:1;4960;4953:12;4914:53;5018:2;5013;5009;5005:11;5000:2;4993:5;4989:14;4976:45;5062:1;5057:2;5052;5045:5;5041:14;5037:23;5030:34;5083:5;5073:15;;;;;3828:1266;;;;;;;;:::o;5313:464::-;-1:-1:-1;;5596:2:55;5592:15;;;5588:24;;5576:37;;5638:2;5629:12;;5622:28;;;;5684:15;;;;5680:24;;;5675:2;5666:12;;5659:46;5730:2;5721:12;;5714:28;;;;5767:3;5758:13;;5313:464::o;6035:271::-;6218:6;6210;6205:3;6192:33;6174:3;6244:16;;6269:13;;;6244:16;6035:271;-1:-1:-1;6035:271:55:o;6311:127::-;6372:10;6367:3;6363:20;6360:1;6353:31;6403:4;6400:1;6393:15;6427:4;6424:1;6417:15;6443:217;6483:1;6509;6499:132;;6553:10;6548:3;6544:20;6541:1;6534:31;6588:4;6585:1;6578:15;6616:4;6613:1;6606:15;6499:132;-1:-1:-1;6645:9:55;;6443:217::o;6665:168::-;6738:9;;;6769;;6786:15;;;6780:22;;6766:37;6756:71;;6807:18;;:::i;6838:125::-;6903:9;;;6924:10;;;6921:36;;;6937:18;;:::i;6968:250::-;7053:1;7063:113;7077:6;7074:1;7071:13;7063:113;;;7153:11;;;7147:18;7134:11;;;7127:39;7099:2;7092:10;7063:113;;;-1:-1:-1;;7210:1:55;7192:16;;7185:27;6968:250::o;7223:648::-;7303:6;7356:2;7344:9;7335:7;7331:23;7327:32;7324:52;;;7372:1;7369;7362:12;7324:52;7405:9;7399:16;7438:18;7430:6;7427:30;7424:50;;;7470:1;7467;7460:12;7424:50;7493:22;;7546:4;7538:13;;7534:27;-1:-1:-1;7524:55:55;;7575:1;7572;7565:12;7524:55;7604:2;7598:9;7629:48;7645:31;7673:2;7645:31;:::i;7629:48::-;7700:2;7693:5;7686:17;7740:7;7735:2;7730;7726;7722:11;7718:20;7715:33;7712:53;;;7761:1;7758;7751:12;7712:53;7774:67;7838:2;7833;7826:5;7822:14;7817:2;7813;7809:11;7774:67;:::i;:::-;7860:5;7223:648;-1:-1:-1;;;;;7223:648:55:o;8722:128::-;8789:9;;;8810:11;;;8807:37;;;8824:18;;:::i;9216:127::-;9277:10;9272:3;9268:20;9265:1;9258:31;9308:4;9305:1;9298:15;9332:4;9329:1;9322:15;10067:184;10137:6;10190:2;10178:9;10169:7;10165:23;10161:32;10158:52;;;10206:1;10203;10196:12;10158:52;-1:-1:-1;10229:16:55;;10067:184;-1:-1:-1;10067:184:55:o;10535:268::-;10622:6;10675:2;10663:9;10654:7;10650:23;10646:32;10643:52;;;10691:1;10688;10681:12;10643:52;10723:9;10717:16;10742:31;10767:5;10742:31;:::i;13488:151::-;13578:4;13571:12;;;13557;;;13553:31;;13596:14;;13593:40;;;13613:18;;:::i;14047:277::-;14114:6;14167:2;14155:9;14146:7;14142:23;14138:32;14135:52;;;14183:1;14180;14173:12;14135:52;14215:9;14209:16;14268:5;14261:13;14254:21;14247:5;14244:32;14234:60;;14290:1;14287;14280:12;15147:287;15276:3;15314:6;15308:13;15330:66;15389:6;15384:3;15377:4;15369:6;15365:17;15330:66;:::i;:::-;15412:16;;;;;15147:287;-1:-1:-1;;15147:287:55:o;15797:396::-;15946:2;15935:9;15928:21;15909:4;15978:6;15972:13;16021:6;16016:2;16005:9;16001:18;15994:34;16037:79;16109:6;16104:2;16093:9;16089:18;16084:2;16076:6;16072:15;16037:79;:::i;:::-;16177:2;16156:15;-1:-1:-1;;16152:29:55;16137:45;;;;16184:2;16133:54;;15797:396;-1:-1:-1;;15797:396:55:o
Swarm Source
ipfs://82f7c11eed94f3b9e719d1a3e5f7da5ee1bb3e625abc6505d59d0f4243aad758
Loading...
Loading
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in ETH
0
Multichain Portfolio | 35 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
Loading...
Loading
Loading...
Loading
Loading...
Loading
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.